@testmuai/kane-cli 0.6.9 → 0.6.11

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 (187) hide show
  1. package/dist/ChatSurface-TZ554O4U.js +8 -0
  2. package/dist/{ChromeProfilePicker-FSZB4SZR.js → ChromeProfilePicker-54CAJDUF.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-WNMDCIHZ.js → CliFeedbackPrompt-TCAH4AHL.js} +1 -1
  4. package/dist/{CliUploadProgress-H4265KXU.js → CliUploadProgress-UURZ63VQ.js} +1 -1
  5. package/dist/{ConfigView-XCUZ44SP.js → ConfigView-5QGB7MUS.js} +1 -1
  6. package/dist/EvidenceViewOffer-SSAM4RRP.js +2 -0
  7. package/dist/{FolderPicker-S2XVCPYN.js → FolderPicker-Y5MAYFIJ.js} +1 -1
  8. package/dist/{HelpView-OPKRGNNM.js → HelpView-S3GJGSCE.js} +1 -1
  9. package/dist/{InfoBox-TW2PGJK5.js → InfoBox-LYTNNMVJ.js} +1 -1
  10. package/dist/{LinksBox-66M7XP5Y.js → LinksBox-5MSEKNSV.js} +1 -1
  11. package/dist/{ProfilesView-T2CFQPR5.js → ProfilesView-LTHE5UIO.js} +1 -1
  12. package/dist/{ProjectPicker-7ALN52CY.js → ProjectPicker-XMXIGHSE.js} +1 -1
  13. package/dist/{SaveSessionPrompt-HM3F6QML.js → SaveSessionPrompt-VQDEA4WA.js} +1 -1
  14. package/dist/SingleShotApp-A6PCNPLM.js +2 -0
  15. package/dist/{SummaryBox-BQZEGOIV.js → SummaryBox-WWF3G263.js} +1 -1
  16. package/dist/TestMdRunView-MQ7ZPFN2.js +2 -0
  17. package/dist/{WhoamiView-722MBPSG.js → WhoamiView-PDURYP7E.js} +1 -1
  18. package/dist/auth-I4RB4KO3.js +2 -0
  19. package/dist/bind-QJT726NE.js +6 -0
  20. package/dist/bootstrap-566PPFCC.js +2 -0
  21. package/dist/{bridge-V4FF5QPK.js → bridge-QCMEOQDD.js} +1 -1
  22. package/dist/{changelog-KMYZW5MI.js → changelog-OKYH4F7I.js} +1 -1
  23. package/dist/{chat-committer-MWZ4JQMM.js → chat-committer-OS7ULZMH.js} +1 -1
  24. package/dist/chat-controller-QLORQWJZ.js +2 -0
  25. package/dist/{chunk-LRA3V5GY.js → chunk-2WKX3RMA.js} +1 -1
  26. package/dist/chunk-2XMJ6YAE.js +2 -0
  27. package/dist/{chunk-FVM7TWKT.js → chunk-3AZTXJY4.js} +1 -1
  28. package/dist/{chunk-SHAA6FOD.js → chunk-3RZ63RBO.js} +1 -1
  29. package/dist/{chunk-U5QTE3WX.js → chunk-4CJ55EUY.js} +1 -1
  30. package/dist/{chunk-T4WZWKIU.js → chunk-54IB6CXK.js} +2 -2
  31. package/dist/chunk-54VQ46U2.js +14 -0
  32. package/dist/chunk-55Y65VPA.js +347 -0
  33. package/dist/chunk-5EOX4MEY.js +2 -0
  34. package/dist/{chunk-L4JIMNKW.js → chunk-6HYW5RFX.js} +1 -1
  35. package/dist/{chunk-L3HG5ONB.js → chunk-6W6AIDLJ.js} +1 -1
  36. package/dist/chunk-73OQDAXF.js +3 -0
  37. package/dist/{chunk-LEA6IHXC.js → chunk-7E24OCGX.js} +1 -1
  38. package/dist/{chunk-DKERZJYF.js → chunk-7MRBMDZ5.js} +1 -1
  39. package/dist/{chunk-345PY4SZ.js → chunk-7NLQ3QQD.js} +1 -1
  40. package/dist/chunk-7YPK6EDR.js +4 -0
  41. package/dist/chunk-BKM2LWU2.js +3 -0
  42. package/dist/{chunk-YY6WPFMT.js → chunk-DSOA6L73.js} +3 -3
  43. package/dist/{chunk-ZA4GR5R7.js → chunk-EAUUULJQ.js} +1 -1
  44. package/dist/chunk-EV3EHXEI.js +4 -0
  45. package/dist/chunk-F7WKDMX7.js +47 -0
  46. package/dist/{chunk-7Z64BL5D.js → chunk-FCHTL74E.js} +1 -1
  47. package/dist/chunk-FHKDTM5L.js +6 -0
  48. package/dist/{chunk-OSALXGD4.js → chunk-FMR2KPSK.js} +1 -1
  49. package/dist/{chunk-RGDQMKNJ.js → chunk-FRBYGSGJ.js} +1 -1
  50. package/dist/{chunk-GBYH35H5.js → chunk-FSB3FTIQ.js} +1 -1
  51. package/dist/{chunk-JHAGEBKE.js → chunk-GIMTSDNC.js} +1 -1
  52. package/dist/{chunk-FT4G3QGO.js → chunk-GLA6QL3T.js} +1 -1
  53. package/dist/chunk-H2W2UNTN.js +6 -0
  54. package/dist/{chunk-7BCZLDNX.js → chunk-HLRLP6TQ.js} +1 -1
  55. package/dist/{chunk-4FH2KFRT.js → chunk-HMM5FJJO.js} +1 -1
  56. package/dist/{chunk-TACPTX64.js → chunk-HOQEMPMQ.js} +2 -2
  57. package/dist/{chunk-MXLXKHW4.js → chunk-ICGHBZFZ.js} +1 -1
  58. package/dist/{chunk-TFVMSEIA.js → chunk-IQODWB32.js} +1 -1
  59. package/dist/{chunk-MBXWXBDM.js → chunk-J2KSZUOO.js} +1 -1
  60. package/dist/chunk-J44RN3FB.js +2 -0
  61. package/dist/{chunk-O4HWPV67.js → chunk-JXKRO2ZJ.js} +2 -2
  62. package/dist/{chunk-K5JGCJ2K.js → chunk-K7USHLVZ.js} +4 -4
  63. package/dist/{chunk-QZJID3OZ.js → chunk-KHJXOFDM.js} +1 -1
  64. package/dist/chunk-KHQHVSZ6.js +5 -0
  65. package/dist/{chunk-IWBPV3VS.js → chunk-KSZ72BSC.js} +1 -1
  66. package/dist/{chunk-QTHITA73.js → chunk-KXUSG5ZI.js} +1 -1
  67. package/dist/{chunk-DPOES6G3.js → chunk-LHDNJJGE.js} +1 -1
  68. package/dist/{chunk-P4SE6YON.js → chunk-M5PJQ5Y3.js} +1 -1
  69. package/dist/{chunk-QM3XF5TW.js → chunk-MFOH7EYR.js} +1 -1
  70. package/dist/{chunk-EWLLPUP4.js → chunk-MJBCBQC2.js} +1 -1
  71. package/dist/chunk-MMPFU2YC.js +2 -0
  72. package/dist/{chunk-RQM3DUSB.js → chunk-MR7CX5VT.js} +1 -1
  73. package/dist/{chunk-GNNMHYWE.js → chunk-MRP54NCJ.js} +1 -1
  74. package/dist/chunk-MTNUZEO7.js +12 -0
  75. package/dist/{chunk-RLICAFFQ.js → chunk-NJAHRITS.js} +1 -1
  76. package/dist/{chunk-OV2W7KBC.js → chunk-NTGYFYBP.js} +1 -1
  77. package/dist/{chunk-LMMOR7CR.js → chunk-NTNAHN25.js} +1 -1
  78. package/dist/{chunk-EASTDHNW.js → chunk-NUQ423YE.js} +1 -1
  79. package/dist/{chunk-U6TLLYRG.js → chunk-OGWC3J3C.js} +1 -1
  80. package/dist/chunk-OIYGGEUL.js +6 -0
  81. package/dist/{chunk-T2ULEJK7.js → chunk-POYZ6SAI.js} +2 -2
  82. package/dist/chunk-Q2F5QB2W.js +2 -0
  83. package/dist/{chunk-3YI4QRXF.js → chunk-QJIJC3KC.js} +1 -1
  84. package/dist/{chunk-G6F2BOFT.js → chunk-RFJAYURU.js} +1 -1
  85. package/dist/chunk-RGJIRS3B.js +2 -0
  86. package/dist/{chunk-CLYG26XV.js → chunk-RZJVQUBA.js} +35 -35
  87. package/dist/{chunk-QB4IOM3X.js → chunk-SURF5Z7Y.js} +1 -1
  88. package/dist/chunk-TDPWFYTJ.js +2 -0
  89. package/dist/chunk-V3UE6RJP.js +2 -0
  90. package/dist/chunk-VOHQA2SP.js +2 -0
  91. package/dist/{chunk-FFHBQK5N.js → chunk-XSKLH2MC.js} +2 -2
  92. package/dist/{chunk-OAEZKYYQ.js → chunk-XWSAKVEY.js} +2 -2
  93. package/dist/{chunk-F42YVALT.js → chunk-XXMNUJX4.js} +1 -1
  94. package/dist/{chunk-QZNUTCSD.js → chunk-XZRIQ3GF.js} +1 -1
  95. package/dist/chunk-Y5RNCJAN.js +19 -0
  96. package/dist/chunk-YSSTGJ7O.js +7 -0
  97. package/dist/chunk-Z2JSEL3I.js +4 -0
  98. package/dist/{chunk-R65HNFRB.js → chunk-ZNHXIRCM.js} +9 -9
  99. package/dist/{chunk-AU7WQ2O5.js → chunk-ZP4S5WGW.js} +1 -1
  100. package/dist/{chunk-NIKA2V6B.js → chunk-ZPCU6546.js} +1 -1
  101. package/dist/{config-Z4OS3HEE.js → config-QISRENF5.js} +1 -1
  102. package/dist/{cover-cmd-L2HSVDLH.js → cover-cmd-SV3I23UM.js} +1 -1
  103. package/dist/{credentials-TNEVAUHI.js → credentials-OGLK7MPV.js} +1 -1
  104. package/dist/docx-convert-ZBVQO2LG.js +2 -0
  105. package/dist/{dossier-ZHSHATVU.js → dossier-KJSJPWOW.js} +1 -1
  106. package/dist/{evidence-MA3LDBWG.js → evidence-HDD7T7DX.js} +1 -1
  107. package/dist/evolve-cmd-UE2BIMXK.js +2 -0
  108. package/dist/exit-manager-MXUD7GQ7.js +2 -0
  109. package/dist/{explain-VTRHEVUQ.js → explain-EBVIUS2X.js} +1 -1
  110. package/dist/{explain-cmd-E366QTAD.js → explain-cmd-DBUTPZHA.js} +1 -1
  111. package/dist/{explain-cmd-327F6ESA.js → explain-cmd-NWIYH5MI.js} +1 -1
  112. package/dist/extract-bind-6MQYKN3G.js +8 -0
  113. package/dist/{extract-cmd-LFVMG6UE.js → extract-cmd-2RUIWFZG.js} +1 -1
  114. package/dist/{gaps-cmd-IAEXXESW.js → gaps-cmd-CKCHH3HQ.js} +1 -1
  115. package/dist/{generate-headless-TYQRYQKJ.js → generate-headless-TUA3HGRX.js} +2 -2
  116. package/dist/index.js +67 -65
  117. package/dist/ingest-FIIO67ZN.js +2 -0
  118. package/dist/ingest-cmd-CRMY46YC.js +7 -0
  119. package/dist/interactive-bind-53FCRK34.js +10 -0
  120. package/dist/{lifecycle-cmd-KZOC4WDW.js → lifecycle-cmd-32LG364Q.js} +1 -1
  121. package/dist/{list-cmd-6X5U46RD.js → list-cmd-UTZ2PQUK.js} +1 -1
  122. package/dist/list-commands-F53ZNYOZ.js +2 -0
  123. package/dist/{logical-ids-RFGWBVML.js → logical-ids-I7B3VJEH.js} +1 -1
  124. package/dist/login-flow-D7KBR7XR.js +2 -0
  125. package/dist/{maintenance-cmd-UJG4LPWD.js → maintenance-cmd-BZAGSYGI.js} +1 -1
  126. package/dist/pdf-convert-S7VYE6AV.js +2 -0
  127. package/dist/{persist-recorded-session-RAL7UCQT.js → persist-recorded-session-5ZFS5SMZ.js} +1 -1
  128. package/dist/pipeline-MX3ZR5B3.js +2 -0
  129. package/dist/readmodel-S5RAQH3F.js +2 -0
  130. package/dist/reconcile-cmd-4377PWF5.js +2 -0
  131. package/dist/{recording-banner-MBR3Q7VD.js → recording-banner-ZZUF2MGT.js} +1 -1
  132. package/dist/{require-project-folder-KE7XOOFN.js → require-project-folder-NQBZFUPF.js} +1 -1
  133. package/dist/{revert-FRXNIP5R.js → revert-RQJE56HF.js} +1 -1
  134. package/dist/{review-cmd-XVWPSWU2.js → review-cmd-7LXGYHHQ.js} +1 -1
  135. package/dist/run-2AIQUJ55.js +2 -0
  136. package/dist/run-YH5SCBYD.js +2 -0
  137. package/dist/{run-test-md-ZCAWNP35.js → run-test-md-XOSCYVSS.js} +2 -2
  138. package/dist/{sessions-cmd-STHKGDX4.js → sessions-cmd-DTQYDZNT.js} +1 -1
  139. package/dist/{skill-installer-H5DPJJFW.js → skill-installer-VYIIWAK7.js} +1 -1
  140. package/dist/{spawner-C6B5J73J.js → spawner-7KXVKAD5.js} +1 -1
  141. package/dist/store-id-EOSGEKVK.js +2 -0
  142. package/dist/tcg-generate-U6OCCS2E.js +2 -0
  143. package/dist/testmd-actions-RPALXRZK.js +2 -0
  144. package/dist/token-refresh-S7CYBZTE.js +2 -0
  145. package/dist/{validate-basic-VBPGGHES.js → validate-basic-LP3S5PK7.js} +1 -1
  146. package/dist/{version-check-YPRCQJ7E.js → version-check-XP62HWLJ.js} +1 -1
  147. package/dist/{view-cmd-G4PGJRQH.js → view-cmd-GQBFCPDL.js} +1 -1
  148. package/dist/walk-session-YIKHE6PT.js +2 -0
  149. package/package.json +10 -6
  150. package/dist/ChatSurface-B2QJYKV4.js +0 -8
  151. package/dist/EvidenceViewOffer-5TJCRM2T.js +0 -2
  152. package/dist/SingleShotApp-YQYS6HTB.js +0 -2
  153. package/dist/TestMdRunView-7CL3PM3J.js +0 -2
  154. package/dist/bind-HNI5LCNK.js +0 -6
  155. package/dist/chat-controller-YX5A7R52.js +0 -2
  156. package/dist/chunk-2Z5MSC23.js +0 -12
  157. package/dist/chunk-4BAL4OGF.js +0 -7
  158. package/dist/chunk-4CKZAGBD.js +0 -2
  159. package/dist/chunk-4GXOBABK.js +0 -4
  160. package/dist/chunk-E4EHWO3J.js +0 -4
  161. package/dist/chunk-FXPPQL4D.js +0 -6
  162. package/dist/chunk-GLS46X7N.js +0 -5
  163. package/dist/chunk-M5JQXOCE.js +0 -12
  164. package/dist/chunk-RHNKYNNZ.js +0 -6
  165. package/dist/chunk-SORKKW7B.js +0 -6
  166. package/dist/chunk-VCYVSKPM.js +0 -2
  167. package/dist/chunk-VXLOEM2U.js +0 -347
  168. package/dist/chunk-XTO236AL.js +0 -14
  169. package/dist/chunk-XWIN3S7O.js +0 -4
  170. package/dist/evolve-cmd-DTW4EOXM.js +0 -2
  171. package/dist/exit-manager-VCSIUYBR.js +0 -2
  172. package/dist/extract-bind-DZLG4GUE.js +0 -5
  173. package/dist/ingest-CBQAXVH6.js +0 -2
  174. package/dist/ingest-cmd-JN6PLDE3.js +0 -3
  175. package/dist/interactive-bind-QEBWUJCN.js +0 -7
  176. package/dist/list-commands-BU2MSYRH.js +0 -2
  177. package/dist/login-flow-4L62GWLT.js +0 -2
  178. package/dist/pdf-convert-KYXI4FU4.js +0 -2
  179. package/dist/pipeline-PLI5WQKX.js +0 -2
  180. package/dist/readmodel-V3DVL6NP.js +0 -2
  181. package/dist/reconcile-cmd-UXY36ROJ.js +0 -2
  182. package/dist/run-5DQSL5KH.js +0 -2
  183. package/dist/run-B7BRNC3X.js +0 -2
  184. package/dist/tcg-generate-DIMZXAV3.js +0 -2
  185. package/dist/testmd-actions-X6XCV53D.js +0 -2
  186. package/dist/token-refresh-7PAPCMQK.js +0 -2
  187. package/dist/walk-session-GWOP27TX.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h}from"./chunk-QTHITA73.js";import{y as l}from"./chunk-VCYVSKPM.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
2
+ import{a as h}from"./chunk-KXUSG5ZI.js";import{y as l}from"./chunk-MMPFU2YC.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as $e}from"./chunk-U6TLLYRG.js";import{a as te}from"./chunk-F42YVALT.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-DKERZJYF.js";import{a as ve}from"./chunk-3YI4QRXF.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{y as i}from"./chunk-VCYVSKPM.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
2
+ import{c as $e}from"./chunk-OGWC3J3C.js";import{a as te}from"./chunk-XXMNUJX4.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-7MRBMDZ5.js";import{a as ve}from"./chunk-QJIJC3KC.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{y as i}from"./chunk-MMPFU2YC.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
3
3
  `)){if(l===""){n.push("");continue}let a="";for(let u of l.split(" ")){let c=u;for(;c.length>t;)a&&(n.push(a),a=""),n.push(c.slice(0,t)),c=c.slice(t);a===""?a=c:a.length+1+c.length<=t?a+=" "+c:(n.push(a),a=c)}n.push(a)}return n}function je({text:e,maxLines:t=3}){let{stdout:n}=ee(),l=Math.max(20,(n?.columns??80)-7),a=!e.trim(),[u,c]=(0,De.useState)(!0);K(()=>c(T=>!T),500);let v=(a?"Thinking\u2026":e)+(u?"\u258C":" "),S=ze(v,l).slice(-t);for(;S.length<t;)S.push("");return(0,me.jsx)(s,{borderStyle:"round",borderColor:i.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:S.map((T,d)=>(0,me.jsx)(o,{color:a?i.dim:i.secondary,wrap:"truncate-end",children:T.length?T:" "},d))})}var U=R(k(),1);function se({activity:e,describe:t,describeVisible:n}){return(0,U.jsxs)(U.Fragment,{children:[e?(0,U.jsx)(Pe,{label:e.label,shimmer:e.shimmer}):null,n?(0,U.jsx)(je,{text:t??""}):null]})}var r=R(k(),1);function le(e){for(let t of e){if(t.children&&t.children.length>0){let n=le(t.children);if(n)return n}if(t.status==="running")return t}}function z(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function Fe(e){let t=[];for(let n of e)z(n)||(n.children&&n.children.length>0?t.push({...n,children:Fe(n.children)}):t.push(n));return t}function ge(e,t){if(!e)return null;let n=e.objective??"";return n.length>0&&!/^Step \d+$/.test(n)?{label:n+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function P({step:e,indent:t=2}){let n=e.actionType?Oe(e.actionType):null,l=e.status==="running",a=e.status==="passed",u=e.status==="failed",c=e.status==="pending"||e.status==="stopped",{stdout:v}=ee(),S=v?.columns??80,T=Math.max(20,S-t-21),d=e.objective??"",L=d.length>T?d.slice(0,T-1)+"\u2026":d,O=(e.duration??0)*1e3,y=e.duration!=null?O<1e3?`${Math.round(O)}ms`:`${(O/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsxs)(s,{marginLeft:t,children:[(0,r.jsx)(s,{width:4,children:(0,r.jsxs)(o,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(s,{width:3,children:l?(0,r.jsx)(te,{}):a?(0,r.jsx)(o,{color:i.green,bold:!0,children:"\u2713"}):u?(0,r.jsx)(o,{color:i.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:i.muted,children:"\u25CB"})}),(0,r.jsx)(s,{flexGrow:1,children:l?(0,r.jsx)(oe,{text:L,active:!0}):u?(0,r.jsx)(o,{color:i.red,children:L}):c?(0,r.jsx)(o,{color:i.dim,children:L}):(0,r.jsx)(o,{color:i.dim,children:L})}),(a||u)&&n?(0,r.jsx)(s,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:i.muted,children:n})}):(0,r.jsx)(s,{width:3,marginLeft:1}),(0,r.jsx)(s,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:i.dim,children:y})})]}),e.children&&e.children.length>0&&(0,r.jsx)(s,{flexDirection:"column",children:e.children.map((h,b)=>(0,r.jsx)(P,{step:h,indent:t+2},`child-${b}`))})]})}function Xe(e){return e.type==="cm_init"?(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(P,{step:e.step})})}function _e({steps:e,bifurcated:t,flows:n,cmInitCounts:l,maxSteps:a=50,staticSteps:u=!1,onStepCommit:c,describe:v,describeVisible:S,describeRevealing:T}){let d=(0,I.useRef)(new Set),L=(0,I.useRef)(!1),O=(0,I.useRef)(new Set),y=(0,I.useRef)(!1),h=(0,I.useRef)(new Set),b=(0,I.useRef)(0);(0,I.useEffect)(()=>{e.length===0&&b.current>0&&(d.current.clear(),L.current=!1,O.current.clear(),y.current=!1,h.current.clear()),b.current=e.length},[e.length]);let B=e.flatMap(p=>[p,...p.children??[]]),F=B.some(p=>p.status==="running"),M=B.some(p=>p.status==="failed"),X=B.length===0||B.every(p=>p.status==="pending"),Y=B.filter(p=>p.status==="passed"||p.status==="failed").length,N;X?N="starting":F?N="running":M?N="failed":N="passed";let J=(0,I.useRef)(null),[ce,he]=(0,I.useState)(0);(0,I.useEffect)(()=>{B.length===0||X?(J.current=null,he(0)):F&&J.current==null&&(J.current=Date.now())},[F,X,B.length]),(0,I.useEffect)(()=>{if(!F)return;let p=setInterval(()=>{J.current!=null&&he((Date.now()-J.current)/1e3)},500);return()=>clearInterval(p)},[F]);let ae=(0,I.useRef)(new Set),[,xe]=(0,I.useState)(0),be=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c||!u||t)return;let p=[];!be.current&&l&&l[0]!=null&&(be.current=!0,l[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:l[0]}));for(let g of e)(g.status==="passed"||g.status==="failed")&&!ae.current.has(g.index)&&(ae.current.add(g.index),p.push({key:`step_${g.index}`,type:"step",step:{...g,children:g.children?[...g.children]:void 0}}));if(p.length>0){for(let g of p)c(Xe(g));xe(g=>g+1)}},[e,t,l,u,c]),(0,I.useEffect)(()=>{if(!c||u)return;let p=d.current.size;if(!t&&!y.current&&l&&l[0]!=null&&(y.current=!0,l[0]>0&&c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25A0 Generated task with ",l[0]," checkpoints"]})}))),t&&n&&!L.current&&(L.current=!0,c((0,r.jsx)(o,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+n.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let g=e.flatMap((x,f)=>{let m=x.children??[];return!O.current.has(f)&&m.length>0&&(O.current.add(f),c((0,r.jsx)(o,{color:i.purple,children:" Flow "+(f+1)+": "+(n?.[f]??"")})),l?.[f]!=null&&l[f]>0&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})})))),l?.[f]!=null&&l[f]>0&&O.current.has(f)&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})}))),m});for(let x of g){let f=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){d.current.has(f)||(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...x,children:void 0}})})));for(let $ of x.children??[]){let w=`child-${x.childId??"p"}-${x.index}-${$.childId??"p"}-${$.index}-${$.objective}`;d.current.has(w)||($.status==="passed"||$.status==="failed"||$.status==="stopped")&&(d.current.add(w),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:$})})))}continue}d.current.has(f)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:x})})))}}else for(let g of e){let x=`${g.index}-${g.objective}`,f=!!g.branchObjective;f&&!d.current.has(x)&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})));for(let m of g.children??[]){let $=`child-${g.index}-${m.childId??"p"}-${m.index}-${m.objective}`;d.current.has($)||(m.status==="passed"||m.status==="failed"||m.status==="stopped")&&(d.current.add($),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:m})})))}!f&&!d.current.has(x)&&(g.status==="passed"||g.status==="failed"||g.status==="stopped")&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})))}d.current.size>p&&xe(g=>g+1)},[e,c,t,n,l]);let G=[];if(u&&!t)for(let p of e)ae.current.has(p.index)||G.push(p);else if(c&&!u)if(t)for(let p of e){let g=p.children??[],x=[];for(let f of g){let m=`${f.childId??"p"}-${f.index}-${f.objective}`,$=d.current.has(m);if(f.branchObjective){let w=(f.children??[]).filter(Q=>{let ue=`child-${f.childId??"p"}-${f.index}-${Q.childId??"p"}-${Q.index}-${Q.objective}`;return!d.current.has(ue)});(!$||w.length>0)&&x.push({...f,children:w})}else $||x.push(f)}x.length>0&&G.push({...p,children:x})}else for(let p of e){let g=`${p.index}-${p.objective}`,x=d.current.has(g),f=(p.children??[]).filter(m=>{let $=`child-${p.index}-${m.childId??"p"}-${m.index}-${m.objective}`;return!d.current.has($)});x?f.length>0&&G.push({...p,children:f}):G.push({...p,children:f})}if(!u){let p=c?G:e,g=le(p),x=ge(g,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[t?c?p.length>0?(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((m,$)=>(0,r.jsx)(s,{flexDirection:"column",marginTop:$>0?1:0,children:m.children&&m.children.length>0?m.children.map(w=>{if(z(w))return null;let Q=!!w.branchObjective,ue=`${w.childId??"p"}-${w.index}-${w.objective}`,Ke=d.current.has(ue);return Q?(0,r.jsxs)(s,{flexDirection:"column",children:[!Ke&&(0,r.jsx)(P,{step:{...w,children:void 0}}),(w.children??[]).filter(Z=>!z(Z)).map(Z=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:Z})},`f${$}-${w.index}-${Z.childId??"p"}-${Z.index}`))]},`f${$}-host-${w.childId??"p"}-${w.index}`):(0,r.jsx)(P,{step:w},`f${$}-${w.childId??"p"}-${w.index}`)}):m.status==="pending"&&(0,r.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})},$))}):null:(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(m,$)=>z(m)?null:(0,r.jsx)(P,{step:m},$)}):(0,r.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!c&&l&&l[0]!=null&&(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",l[0]," checkpoints"]}),p.filter(m=>!(m.status==="running"&&(!m.children||m.children.length===0))).map(m=>{let $=`${m.index}-${m.objective}`;return c&&d.current.has($)?(0,r.jsx)(s,{flexDirection:"column",children:(m.children??[]).filter(w=>!z(w)).map(w=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:w})},`${w.childId??"p"}-${w.index}`))},`branch-children-${m.index}`):(0,r.jsx)(P,{step:m},m.index)})]}),(0,r.jsx)(se,{activity:x,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}if(t){let p=le(e),g=ge(p,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(x,f)=>z(x)?null:(0,r.jsx)(P,{step:x},f)}),(0,r.jsx)(se,{activity:g,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}let Ne=le(G),Ge=ge(Ne,T),Re=Fe(G);return(0,r.jsxs)(s,{flexDirection:"column",children:[Re.length>0&&(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Re.map(p=>(0,r.jsx)(P,{step:p},p.index))}),(0,r.jsx)(se,{activity:Ge,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}var W=R(k(),1);function Ae({runner:e,runKey:t,onStepCommit:n}){let l=Ie({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,W.jsxs)(W.Fragment,{children:[l&&(0,W.jsx)(ke,{label:l.label,hasBifurcation:l.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,W.jsx)(_e,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:n},`run-${t}`)]})}var D=R(k(),1),Ye=64;function Je(e){return e.split(`
4
4
  `).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function qe({status:e,summary:t,duration:n,steps:l,stepsPassed:a,stepsFailed:u,reason:c,creditsConsumed:v}){let S=e==="passed",T=S?i.green:i.red,d=S?"\u2713":"\u2717",L=e.toUpperCase(),O=a??(S?l:Math.max(0,l-1)),y=u??(S?0:1),h=y>0?`${l} steps (${O} passed, ${y} failed)`:`${l} steps`,b=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`,B=Je(t);return(0,D.jsx)(s,{flexDirection:"column",marginTop:1,children:(0,D.jsxs)(s,{borderStyle:"round",borderColor:T,flexDirection:"column",paddingX:2,paddingY:1,width:Ye+6,children:[(0,D.jsxs)(s,{flexDirection:"column",children:[(0,D.jsxs)(o,{bold:!0,color:T,children:[d," ",L]}),(0,D.jsxs)(o,{color:i.dim,wrap:"wrap",children:[h," \xB7 ",b,typeof v=="number"&&v>0?` \xB7 ${parseFloat(v.toFixed(4))} credits`:""]})]}),B.length>0&&(0,D.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:B.map((F,M)=>(0,D.jsxs)(s,{marginBottom:M<B.length-1?1:0,children:[(0,D.jsx)(o,{color:i.orange,children:"\u25CF "}),(0,D.jsx)(s,{flexShrink:1,children:(0,D.jsx)(o,{wrap:"wrap",children:F})})]},M))}),c&&!S&&(0,D.jsx)(s,{marginTop:1,children:(0,D.jsxs)(o,{color:i.red,wrap:"wrap",children:["Reason: ",c]})})]})})}var j=R(k(),1);function Me({message:e,code:t,remediation:n,docsUrl:l}){return(0,j.jsx)(ve,{title:"Error",variant:"error",children:(0,j.jsxs)(s,{flexDirection:"column",paddingY:1,children:[(0,j.jsxs)(o,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,j.jsxs)(s,{marginTop:0,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Code: "}),(0,j.jsx)(o,{color:i.dim,children:t})]}),n&&(0,j.jsxs)(s,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.green,bold:!0,children:"Fix:"}),(0,j.jsxs)(o,{color:i.orange,children:["$ ",n]})]}),l&&(0,j.jsxs)(s,{marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Docs: "}),(0,j.jsx)(o,{color:i.orange,underline:!0,children:l})]})]})})}var E=R(k(),1);function un(e){let{exit:t}=Te(),{append:n}=ye(),l=(0,A.useRef)(!1);(0,A.useEffect)(()=>{l.current||(l.current=!0,n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsxs)(s,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,E.jsx)(o,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.orange,children:e.topBanner.model}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.dim,children:e.topBanner.auth})]})})),n((0,E.jsx)(Qe,{data:e.globalConfig})),e.priorAttemptRollup&&n((0,E.jsx)(o,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let a=(0,A.useRef)(null),u=(0,A.useCallback)(async y=>{let h=await e.getNextStep(y);return h?(a.current=h,h.config):(a.current=null,null)},[e]),c=(0,A.useCallback)((y,h)=>{let b=a.current;if(!b)return;let B=b.mode==="replay"?"cyan":"#dc4e08",F=b.modeReason?` (${b.modeReason})`:"",M=b.perStepOverrides?Object.entries(b.perStepOverrides):[];n((0,E.jsxs)(s,{flexDirection:"column",marginBottom:0,children:[(0,E.jsxs)(o,{children:[(0,E.jsxs)(o,{color:i.dim,children:[b.banner.stepLabel," "]}),(0,E.jsxs)(o,{color:B,children:["[",b.mode,"]"]}),(0,E.jsx)(o,{color:i.dim,children:F})]}),(0,E.jsx)(o,{color:i.dim,children:b.banner.objective}),M.length>0&&(0,E.jsxs)(o,{color:i.dim,children:["overrides: ",M.map(([X,Y])=>`${X}=${Y}`).join(", ")]})]}))},[n]),v=(0,A.useRef)(0),S=(0,A.useRef)(!1),T=(0,A.useCallback)((y,h)=>(y.hadError?n((0,E.jsx)(Me,{message:y.reason??"Runner error",code:"RUNNER_ERROR"})):n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsx)(qe,{status:y.status,summary:y.runEnd?.summary??"",duration:y.runEnd?.duration??0,steps:y.stepsTotal,stepsPassed:y.stepsPassed,stepsFailed:y.stepsFailed,reason:y.runEnd?.reason,creditsConsumed:y.runEnd?.credits_consumed})})),e.onStepEnd?.(y,h)??!0),[n,e]),d=we({getNextConfig:u,onStepStart:c,onStepEnd:T,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),L=250,O=5e3;return Se((y,h)=>{if(h.ctrl&&y==="c"){let b=Date.now(),B=b-v.current;if(B<L)return;S.current&&B<O?(d.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>t())):(S.current=!0,n((0,E.jsx)(o,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),v.current=b}}),(0,E.jsx)(s,{flexDirection:"column",children:d.phase!=="done"&&(0,E.jsx)(Ae,{runner:d.runner,runKey:d.currentStepIndex,onStepCommit:n})})}function Qe({data:e}){return(0,E.jsx)(Be,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{_e as a,ke as b,Ie as c,de as d,qe as e,Me as f,un as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as L}from"./chunk-RFHMDQXZ.js";import{Q as O,S}from"./chunk-O4HWPV67.js";import{e as P,f as R}from"./chunk-M5JQXOCE.js";import{y as s}from"./chunk-VCYVSKPM.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
2
+ import{c as L}from"./chunk-RFHMDQXZ.js";import{Q as O,S}from"./chunk-JXKRO2ZJ.js";import{m as P,n as R}from"./chunk-Y5RNCJAN.js";import{y as s}from"./chunk-MMPFU2YC.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as J}from"./chunk-4BAL4OGF.js";import{e as H,g as P}from"./chunk-M5JQXOCE.js";import{a as ce}from"./chunk-6YGTRKDT.js";import{e as ue}from"./chunk-UR6MHSHU.js";var u=ue(ce(),1);function $(p,r){let f=null,R=(b,j)=>{for(let S=0;S<b.length;S++){let y=b[S],l=[...j,S];r(y)&&(f===null||l.length>f.length)&&(f=l),y.children&&y.children.length>0&&R(y.children,l)}};return R(p,[]),f}function T(p,r,f){if(r.length===0)return[...p];let R=r[0],b=[...p],j=b[R];if(r.length===1)b[R]=f(j);else{let S=r.slice(1),y=T(j.children??[],S,f);b[R]={...j,children:y}}return b}function K(){return{steps:[],maxOrdinal:0}}function le(p,r){if(r.type==="run_start"&&r.environment?.resolution)return{...p,resolution:r.environment.resolution};if(r.type==="step_end"&&typeof r.ordinal=="number"&&r.id){let f={id:r.id,ordinal:r.ordinal,status:r.status,...r.kind?{kind:r.kind}:{},...typeof r.duration=="number"?{duration_ms:Math.round(r.duration*1e3)}:{},...typeof r.action_id=="string"&&r.action_id?{action_id:r.action_id}:{}};return{...p,steps:[...p.steps,f],maxOrdinal:Math.max(p.maxOrdinal,r.ordinal)}}return p}function D(p){let r=p.indexOf(": ");return r>0&&r<15?p.slice(r+2):p}function W(p){return p.map(r=>{let f=r.children?W(r.children):r.children;return r.status==="running"?{...r,status:"stopped",phase:void 0,children:f}:f!==r.children?{...r,children:f}:r})}function Se(p,r,f,R,b){let[j,S]=(0,u.useState)(!1),[y,l]=(0,u.useState)([]),[Q,B]=(0,u.useState)(null),[X,F]=(0,u.useState)(null),[Y,w]=(0,u.useState)(null),[Z,L]=(0,u.useState)(null),[ee,q]=(0,u.useState)([]),[ne,G]=(0,u.useState)(null),[te,ie]=(0,u.useState)(void 0),m=(0,u.useRef)(null),x=(0,u.useRef)(null),_=(0,u.useRef)(0),A=(0,u.useRef)(!1),O=(0,u.useRef)(K()),re=(0,u.useCallback)(async(I,V)=>{let z=m.current;if(z){try{await z.exited}catch{}m.current=null}l([]),B(null),F(null),w(null),L(null),q([]),G(null),ie(I.max_steps),S(!0),x.current=null,_.current=0,O.current=K();let h;try{h=J(I,V)}catch(E){w(E instanceof Error?E.message:String(E)),S(!1);return}m.current=h,H("runner",()=>h.cancel()),(async()=>{A.current=!1;let E=!1;for await(let e of h.events){if(A.current)break;switch(O.current=le(O.current,e),e.type){case"run_start":if(e.child_id)break;if(x.current&&!x.current.isSingleFlow){let o=_.current;_.current++,l(d=>d.map((i,s)=>s===o?{...i,status:"running"}:i.status==="running"&&!i.children?.some(n=>n.status==="running")?{...i,status:i.children?.some(n=>n.status==="failed")?"failed":"passed"}:i))}break;case"bifurcation":{let o=e.flows??[],d=e.count??o.length,i={flows:o,isSingleFlow:e.is_single_flow??d<=1};L(i),x.current=i,_.current=0,l(o.map((s,n)=>({index:n+1,objective:s??`Flow ${n+1}`,status:"pending"})));break}case"step_start":{r?.("STEP_START",`Step ${e.index} started`,{index:e.index,objective:e.objective,child_id:e.child_id});let o=e.index,d=e.objective??`Step ${o}`,i=e.child_id,s=x.current&&!x.current.isSingleFlow;if(i)l(n=>{let t=$(n,a=>a.branchChildId===i)??$(n,a=>a.status==="running");return t?T(n,t,a=>{let c=(a.children??[]).map(g=>g.status==="running"&&g.childId===i?{...g,status:"stopped",phase:void 0}:g);return c.push({index:o,objective:d,status:"running",childId:i}),{...a,children:c}}):n});else if(s){let n=Math.max(0,_.current-1);l(t=>{let a=[...t];if(n>=a.length)return t;let c={...a[n]},k=[...c.children??[]].map(U=>U.status==="running"&&U.childId===void 0?{...U,status:"stopped",phase:void 0}:U);return k.push({index:o,objective:d,status:"running"}),c.children=k,c.status="running",a[n]=c,a})}else l(n=>{let t=W(n);return t.some(c=>c.index===o)?t.map(c=>c.index===o?{...c,status:"running",objective:d}:c):[...t,{index:o,objective:d,status:"running"}]});break}case"step_event":{r?.("STEP_EVENT",`Step ${e.index} ${e.event}`,{index:e.index,phase:e.event,action_type:e.action_type,detail:e.detail,child_id:e.child_id});let o=e.child_id,d=x.current&&!x.current.isSingleFlow;if(e.event==="cm_init"&&e.checkpoint_count!=null){q(i=>[...i,e.checkpoint_count]);break}if(e.event==="replay_started"){G({recordingLength:e.recording_length??0});break}if(e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&f?.(e.detail),o){let i=n=>{if(n.index!==e.index||n.childId!==o)return n;let t={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(t.objective=e.detail),e.action_type&&(t.actionType=e.action_type),{...n,...t}},s=n=>n.map(t=>{let a=i(t);return a!==t?a:t.children&&t.children.length>0?{...t,children:s(t.children)}:t});l(n=>n.map(t=>t.children?{...t,children:s(t.children)}:t))}else if(d){let i=Math.max(0,_.current-1);l(s=>{let n=[...s];if(i>=n.length)return s;let t={...n[i]},a=[...t.children??[]];if(!a.some(g=>g.index===e.index&&g.childId===void 0))a.push({index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type});else for(let g=0;g<a.length;g++){if(a[g].index!==e.index||a[g].childId!==void 0)continue;let k={phase:e.event};e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(k.objective=e.detail),e.action_type&&(k.actionType=e.action_type),a[g]={...a[g],...k}}return t.children=a,n[i]=t,n})}else l(i=>i.some(n=>n.index===e.index)?i.map(n=>{if(n.index!==e.index)return n;let t={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(t.objective=e.detail),e.action_type&&(t.actionType=e.action_type),{...n,...t}}):[...W(i),{index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type}]);break}case"step_end":{r?.("STEP_END",`Step ${e.index} ${e.status}`,{index:e.index,status:e.status,duration:e.duration,summary:e.summary,child_id:e.child_id}),R?.();let o=e.child_id,d=x.current&&!x.current.isSingleFlow;if(o){let i=n=>n.index===e.index&&n.childId===o?{...n,status:e.status,duration:e.duration,phase:void 0,objective:n.objective.startsWith("Step ")?D(e.summary||n.objective):n.objective}:n,s=n=>n.map(t=>{let a=i(t);return a!==t?a:t.children&&t.children.length>0?{...t,children:s(t.children)}:t});l(n=>n.map(t=>t.children?{...t,children:s(t.children)}:t))}else if(d){let i=Math.max(0,_.current-1);l(s=>{let n=[...s];if(i>=n.length)return s;let t={...n[i]},a=(t.children??[]).map(c=>c.index===e.index&&c.childId===void 0?{...c,status:e.status,duration:e.duration,phase:void 0,objective:c.objective.startsWith("Step ")?D(e.summary||c.objective):c.objective}:c);return t.children=a,n[i]=t,n})}else l(i=>i.map(s=>s.index===e.index?{...s,status:e.status,duration:e.duration,phase:void 0,objective:s.objective.startsWith("Step ")?D(e.summary||s.objective):s.objective}:s));{let s=x.current&&!x.current.isSingleFlow?Math.max(0,_.current-1):0,n=typeof e.ordinal=="number"&&e.id?{ordinal:e.ordinal,id:e.id}:void 0;p?.(e.index,s,e.child_id,n)}break}case"child_agent_start":{let o=e.objective??"",d=e.child_id;l(i=>{let s=$(i,n=>n.status==="running");return s?T(i,s,n=>({...n,objective:`${o} (branch)`,phase:`child: ${o.slice(0,50)}`,branchObjective:o,branchChildId:d})):i});break}case"child_agent_end":{let o=e.child_id,d=`child ${e.success?"done":"failed"}`;l(i=>{let s=$(i,n=>n.branchChildId===o);return s?T(i,s,n=>({...n,phase:d})):i.map(n=>n.phase?.startsWith("child:")?{...n,phase:d}:n)});break}case"describe_trigger":b?.(e);break;case"ask_user":B(e.question??"");break;case"run_end":l(o=>o.map(d=>d.status==="running"?{...d,status:e.status,phase:void 0}:d)),S(!1),F(e),E=!0;break;case"error":S(!1),w(e.message??"Runner error"),l(o=>o.map(d=>d.status==="running"?{...d,status:"failed",phase:void 0}:d));break}}let{code:v,signal:M}=await h.exited,N=h.stderr,de=v===0&&!M,C=[];v!==null&&v!==0&&C.push(`Runner exited with code ${v}`),M&&C.push(`Runner killed by signal ${M}`),N&&(!de||!E?C.push(N):V?.log?.("debug","RUNNER_STDERR_BENIGN","Runner stderr on clean exit",{stderr:N})),m.current===h&&(C.length>0&&w(C.join(`
2
+ import{b as J}from"./chunk-YSSTGJ7O.js";import{m as H,o as P}from"./chunk-Y5RNCJAN.js";import{a as ce}from"./chunk-6YGTRKDT.js";import{e as ue}from"./chunk-UR6MHSHU.js";var u=ue(ce(),1);function $(p,r){let f=null,R=(b,j)=>{for(let S=0;S<b.length;S++){let y=b[S],l=[...j,S];r(y)&&(f===null||l.length>f.length)&&(f=l),y.children&&y.children.length>0&&R(y.children,l)}};return R(p,[]),f}function T(p,r,f){if(r.length===0)return[...p];let R=r[0],b=[...p],j=b[R];if(r.length===1)b[R]=f(j);else{let S=r.slice(1),y=T(j.children??[],S,f);b[R]={...j,children:y}}return b}function K(){return{steps:[],maxOrdinal:0}}function le(p,r){if(r.type==="run_start"&&r.environment?.resolution)return{...p,resolution:r.environment.resolution};if(r.type==="step_end"&&typeof r.ordinal=="number"&&r.id){let f={id:r.id,ordinal:r.ordinal,status:r.status,...r.kind?{kind:r.kind}:{},...typeof r.duration=="number"?{duration_ms:Math.round(r.duration*1e3)}:{},...typeof r.action_id=="string"&&r.action_id?{action_id:r.action_id}:{}};return{...p,steps:[...p.steps,f],maxOrdinal:Math.max(p.maxOrdinal,r.ordinal)}}return p}function D(p){let r=p.indexOf(": ");return r>0&&r<15?p.slice(r+2):p}function W(p){return p.map(r=>{let f=r.children?W(r.children):r.children;return r.status==="running"?{...r,status:"stopped",phase:void 0,children:f}:f!==r.children?{...r,children:f}:r})}function Se(p,r,f,R,b){let[j,S]=(0,u.useState)(!1),[y,l]=(0,u.useState)([]),[Q,B]=(0,u.useState)(null),[X,F]=(0,u.useState)(null),[Y,w]=(0,u.useState)(null),[Z,L]=(0,u.useState)(null),[ee,q]=(0,u.useState)([]),[ne,G]=(0,u.useState)(null),[te,ie]=(0,u.useState)(void 0),m=(0,u.useRef)(null),x=(0,u.useRef)(null),_=(0,u.useRef)(0),A=(0,u.useRef)(!1),O=(0,u.useRef)(K()),re=(0,u.useCallback)(async(I,V)=>{let z=m.current;if(z){try{await z.exited}catch{}m.current=null}l([]),B(null),F(null),w(null),L(null),q([]),G(null),ie(I.max_steps),S(!0),x.current=null,_.current=0,O.current=K();let h;try{h=J(I,V)}catch(E){w(E instanceof Error?E.message:String(E)),S(!1);return}m.current=h,H("runner",()=>h.cancel()),(async()=>{A.current=!1;let E=!1;for await(let e of h.events){if(A.current)break;switch(O.current=le(O.current,e),e.type){case"run_start":if(e.child_id)break;if(x.current&&!x.current.isSingleFlow){let o=_.current;_.current++,l(d=>d.map((i,s)=>s===o?{...i,status:"running"}:i.status==="running"&&!i.children?.some(n=>n.status==="running")?{...i,status:i.children?.some(n=>n.status==="failed")?"failed":"passed"}:i))}break;case"bifurcation":{let o=e.flows??[],d=e.count??o.length,i={flows:o,isSingleFlow:e.is_single_flow??d<=1};L(i),x.current=i,_.current=0,l(o.map((s,n)=>({index:n+1,objective:s??`Flow ${n+1}`,status:"pending"})));break}case"step_start":{r?.("STEP_START",`Step ${e.index} started`,{index:e.index,objective:e.objective,child_id:e.child_id});let o=e.index,d=e.objective??`Step ${o}`,i=e.child_id,s=x.current&&!x.current.isSingleFlow;if(i)l(n=>{let t=$(n,a=>a.branchChildId===i)??$(n,a=>a.status==="running");return t?T(n,t,a=>{let c=(a.children??[]).map(g=>g.status==="running"&&g.childId===i?{...g,status:"stopped",phase:void 0}:g);return c.push({index:o,objective:d,status:"running",childId:i}),{...a,children:c}}):n});else if(s){let n=Math.max(0,_.current-1);l(t=>{let a=[...t];if(n>=a.length)return t;let c={...a[n]},k=[...c.children??[]].map(U=>U.status==="running"&&U.childId===void 0?{...U,status:"stopped",phase:void 0}:U);return k.push({index:o,objective:d,status:"running"}),c.children=k,c.status="running",a[n]=c,a})}else l(n=>{let t=W(n);return t.some(c=>c.index===o)?t.map(c=>c.index===o?{...c,status:"running",objective:d}:c):[...t,{index:o,objective:d,status:"running"}]});break}case"step_event":{r?.("STEP_EVENT",`Step ${e.index} ${e.event}`,{index:e.index,phase:e.event,action_type:e.action_type,detail:e.detail,child_id:e.child_id});let o=e.child_id,d=x.current&&!x.current.isSingleFlow;if(e.event==="cm_init"&&e.checkpoint_count!=null){q(i=>[...i,e.checkpoint_count]);break}if(e.event==="replay_started"){G({recordingLength:e.recording_length??0});break}if(e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&f?.(e.detail),o){let i=n=>{if(n.index!==e.index||n.childId!==o)return n;let t={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(t.objective=e.detail),e.action_type&&(t.actionType=e.action_type),{...n,...t}},s=n=>n.map(t=>{let a=i(t);return a!==t?a:t.children&&t.children.length>0?{...t,children:s(t.children)}:t});l(n=>n.map(t=>t.children?{...t,children:s(t.children)}:t))}else if(d){let i=Math.max(0,_.current-1);l(s=>{let n=[...s];if(i>=n.length)return s;let t={...n[i]},a=[...t.children??[]];if(!a.some(g=>g.index===e.index&&g.childId===void 0))a.push({index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type});else for(let g=0;g<a.length;g++){if(a[g].index!==e.index||a[g].childId!==void 0)continue;let k={phase:e.event};e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(k.objective=e.detail),e.action_type&&(k.actionType=e.action_type),a[g]={...a[g],...k}}return t.children=a,n[i]=t,n})}else l(i=>i.some(n=>n.index===e.index)?i.map(n=>{if(n.index!==e.index)return n;let t={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(t.objective=e.detail),e.action_type&&(t.actionType=e.action_type),{...n,...t}}):[...W(i),{index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type}]);break}case"step_end":{r?.("STEP_END",`Step ${e.index} ${e.status}`,{index:e.index,status:e.status,duration:e.duration,summary:e.summary,child_id:e.child_id}),R?.();let o=e.child_id,d=x.current&&!x.current.isSingleFlow;if(o){let i=n=>n.index===e.index&&n.childId===o?{...n,status:e.status,duration:e.duration,phase:void 0,objective:n.objective.startsWith("Step ")?D(e.summary||n.objective):n.objective}:n,s=n=>n.map(t=>{let a=i(t);return a!==t?a:t.children&&t.children.length>0?{...t,children:s(t.children)}:t});l(n=>n.map(t=>t.children?{...t,children:s(t.children)}:t))}else if(d){let i=Math.max(0,_.current-1);l(s=>{let n=[...s];if(i>=n.length)return s;let t={...n[i]},a=(t.children??[]).map(c=>c.index===e.index&&c.childId===void 0?{...c,status:e.status,duration:e.duration,phase:void 0,objective:c.objective.startsWith("Step ")?D(e.summary||c.objective):c.objective}:c);return t.children=a,n[i]=t,n})}else l(i=>i.map(s=>s.index===e.index?{...s,status:e.status,duration:e.duration,phase:void 0,objective:s.objective.startsWith("Step ")?D(e.summary||s.objective):s.objective}:s));{let s=x.current&&!x.current.isSingleFlow?Math.max(0,_.current-1):0,n=typeof e.ordinal=="number"&&e.id?{ordinal:e.ordinal,id:e.id}:void 0;p?.(e.index,s,e.child_id,n)}break}case"child_agent_start":{let o=e.objective??"",d=e.child_id;l(i=>{let s=$(i,n=>n.status==="running");return s?T(i,s,n=>({...n,objective:`${o} (branch)`,phase:`child: ${o.slice(0,50)}`,branchObjective:o,branchChildId:d})):i});break}case"child_agent_end":{let o=e.child_id,d=`child ${e.success?"done":"failed"}`;l(i=>{let s=$(i,n=>n.branchChildId===o);return s?T(i,s,n=>({...n,phase:d})):i.map(n=>n.phase?.startsWith("child:")?{...n,phase:d}:n)});break}case"describe_trigger":b?.(e);break;case"ask_user":B(e.question??"");break;case"run_end":l(o=>o.map(d=>d.status==="running"?{...d,status:e.status,phase:void 0}:d)),S(!1),F(e),E=!0;break;case"error":S(!1),w(e.message??"Runner error"),l(o=>o.map(d=>d.status==="running"?{...d,status:"failed",phase:void 0}:d));break}}let{code:v,signal:M}=await h.exited,N=h.stderr,de=v===0&&!M,C=[];v!==null&&v!==0&&C.push(`Runner exited with code ${v}`),M&&C.push(`Runner killed by signal ${M}`),N&&(!de||!E?C.push(N):V?.log?.("debug","RUNNER_STDERR_BENIGN","Runner stderr on clean exit",{stderr:N})),m.current===h&&(C.length>0&&w(C.join(`
3
3
  `)),S(!1),P("runner","Event stream ended"),m.current=null)})().catch(E=>{let v=[`Runner event loop error: ${E}`];h.exitCode!==null&&h.exitCode!==0&&v.push(`Exit code: ${h.exitCode}`),h.exitSignal&&v.push(`Signal: ${h.exitSignal}`),h.stderr&&v.push(h.stderr),m.current===h&&(w(v.join(`
4
4
  `)),S(!1),P("runner","Event loop error"),m.current=null)})},[p,r,f,R,b]),se=(0,u.useCallback)(I=>{m.current?.sendUserResponse(I),B(null)},[]),ae=(0,u.useCallback)(()=>{let I=m.current;I&&(I.sendCancel("user"),S(!1),B(null),setTimeout(()=>{m.current===I&&(P("runner","User cancelled run"),m.current=null)},5e3))},[]),oe=(0,u.useCallback)(()=>{l([]),F(null),w(null)},[]);return(0,u.useEffect)(()=>()=>{A.current=!0,P("runner","Component unmounted"),m.current=null},[]),{isRunning:j,steps:y,askingUser:Q,lastRunEnd:X,runError:Y,bifurcationInfo:Z,cmInitCounts:ee,replayInfo:ne,maxSteps:te,startRun:re,sendAnswer:se,cancelRun:ae,clearLastRun:oe,getEvidenceState:()=>O.current}}export{K as a,le as b,Se as c};
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as G,c as P,e as J,h as q,i as z,j as Q,m as V,n as X,o as T}from"./chunk-RKWJG3WW.js";import{e as U}from"./chunk-EHN5HTUD.js";import{copyFileSync as ae,cpSync as le,existsSync as w,mkdirSync as ue,readFileSync as Oe,readdirSync as pe,rmSync as Te,writeFileSync as _e}from"fs";import{dirname as Ae,isAbsolute as Le,join as R,relative as Ee,resolve as Ne}from"path";import{writeFileSync as ge,mkdirSync as Se,readFileSync as Re}from"fs";import{dirname as Ie,basename as Y}from"path";function ee(e){let t=e.outPath??P(e.sourcePath);Se(Ie(t),{recursive:!0});let s=[];s.push("---"),s.push(`test: ../${Y(e.sourcePath)}`),s.push(`status: ${e.overallStatus}`),s.push(`started: ${e.startedISO}`),s.push(`duration_s: ${e.durationS}`),s.push(`session_id: ${e.sessionId}`),s.push("---",""),s.push(`# ${e.title??Y(e.sourcePath)} \u2014 Result`,"");for(let l=0;l<e.rootSteps.length;l++){let a=e.rootSteps[l],i=e.outcomes.find(p=>p.rootStepIndex===l+1);if(s.push(ye(a,i)),i?.stepMd5&&s.push(`md5: ${i.stepMd5}`),i?.status==="failed"&&i.reason&&s.push(`Reason: ${i.reason}`),i?.softFailures?.length)for(let p of i.softFailures){let o=p.reason?`: ${p.reason}`:"";s.push(`\u26A0 optional sub-step ${p.subStepIndex} failed${o}`)}a.body.kind==="objective"&&i?.status!=="skipped"&&s.push(a.body.text),s.push("")}return ge(t,s.join(`
3
+ `),"utf8"),t}function ye(e,t){if(!t)return`## ${e.heading} (no outcome)`;let s=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let l=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let a=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${s}${a})`}if(t.refKind&&t.status==="failed"){let a=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",i=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${l} (via @${t.refKind} ${t.refLabel}${a}, ${s}${i})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${s})`:`## ${e.heading} \u2717 failed${l} (${s})`}var xe=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,be=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,ke=/^md5:\s+([a-f0-9]{32})\s*$/;function Z(e,t){for(let s=t;s<e.length&&!/^##\s/.test(e[s]);s++){if(e[s].trim()==="")continue;let l=ke.exec(e[s]);return l?l[1]:null}return null}function $(e){let s=Re(e,"utf8").split(`
4
+ `),l="passed";if(s[0]?.trim()==="---")for(let i=1;i<s.length&&s[i].trim()!=="---";i++){let p=/^status:\s+(passed|failed|interrupted)\s*$/.exec(s[i]);p&&(l=p[1])}let a=[];for(let i=0;i<s.length;i++){let p=xe.exec(s[i]);if(!p)continue;let o=p[1],r=p[2],c=p[3]??"",m=r.startsWith("\u2713")?"passed":r.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let f=be.exec(c),b=f?.[1]??"",g=f?.[2]??null;a.push({kind:"import",heading:o,status:m,md5:Z(s,i+1),importPath:b,helperResultRelPath:g})}else a.push({kind:"objective",heading:o,status:m,md5:Z(s,i+1)})}return{overallStatus:l,steps:a}}import{copyFileSync as te,existsSync as K,mkdirSync as ve,writeFileSync as se,promises as Ge}from"fs";import{join as D,dirname as re,basename as Pe}from"path";async function ne(e){for(let t=0;t<e.totalRunDirs;t++){let s=e.runIndex+t,l=D(e.sessionDir,"runs",String(s)),a=D(e.stagingStepDir,"flows",String(t));ve(a,{recursive:!0});let i=D(a,"actions.ndjson");if(e.packTestDir){let r=D(e.packTestDir,"logs",`${s}-actions.ndjson`);if(K(r)){te(r,i);continue}let c=re(re(e.packTestDir)),m=Pe(e.packTestDir),I=K(c)?await U(c,`tests/${m}/logs/${s}-actions.ndjson`).catch(()=>null):null;se(i,I??"");continue}let p=[D(l,"run-test","actions.ndjson"),D(l,"actions.ndjson")],o=!1;for(let r of p)if(K(r)){te(r,i),o=!0;break}o||se(i,"")}}import{existsSync as _,readdirSync as we}from"fs";import{dirname as $e,join as M,basename as C}from"path";function et(e){let t=[],s=new Set,l=new Map;function a(r){if(l.has(r))return l.get(r);let c=P(r),m=_(c)?$(c):null;return l.set(r,m),m}let i=new Map;function p(r){if(i.has(r))return i.get(r);let c=M(r,"Result.md"),m=_(c)?$(c):null;return i.set(r,m),m}function o(r){for(let c=1;c<r.trace.length;c++){let m=r.trace[c-1],I=a(m.file);if(!I)continue;let f=I.steps[m.stepIndex-1];if(f){if(f.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(C(f.importPath)!==C(r.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(f.md5!=null&&f.md5!==m.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let r of e.steps){let c=r.trace[r.trace.length-1].stepIndex,m=s.has(r.owningFile);for(let g=0;g<r.trace.length-1&&!m;g++)s.has(r.trace[g].file)&&(m=!0);if(m){t.push({kind:"author",reason:a(r.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let I=o(r);if(I){t.push(I);for(let g=0;g<r.trace.length;g++)s.add(r.trace[g].file);continue}let f=a(r.owningFile),b;if(f===null&&r.trace.length>1){let g=H(r.trace);b=ie(r,p(g),c,g)}else b=ie(r,f,c);if(t.push(b),b.kind==="author"){s.add(r.owningFile);for(let g=0;g<r.trace.length-1;g++)s.add(r.trace[g].file)}}return t}function ie(e,t,s,l=null){if(!t)return{kind:"author",reason:"no-result-md"};let a=t.steps[s-1];if(!a)return{kind:"author",reason:"no-result-md"};if(a.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(a.status!=="passed")return{kind:"author",reason:"recorded-failed"};let i=T(e);if(i!==a.md5)return{kind:"author",reason:"md5-mismatch"};let p=l===null?Q(e.owningFile,s,i.slice(0,8)):M(l,".internal","steps",`${s}-${i.slice(0,8)}`),o=De(p);return o===0?{kind:"author",reason:"missing-recording"}:{kind:"replay",recordingDir:p,flowCount:o}}function De(e){let t=M(e,"flows");if(!_(t))return 0;let s;try{s=we(t,{withFileTypes:!0}).filter(a=>a.isDirectory()&&/^\d+$/.test(a.name)).map(a=>parseInt(a.name,10))}catch{return 0}if(s.length===0)return 0;let l=Math.max(...s);for(let a=0;a<=l;a++)if(!_(M(t,String(a),"actions.ndjson")))return 0;return l+1}function tt(e){return e.some(t=>t.kind==="author")}function st(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function H(e){let t=i=>{let p=C(i);return p.endsWith("_test.md")?p.slice(0,-8):p.endsWith(".md")?p.slice(0,-3):p},s=t(e[0].file),l=t(e[e.length-1].file),a=e.slice(0,-1).map(i=>String(i.stepIndex));return M($e(e[e.length-1].file),`helper-output-${l}-${s}-${a.join("-")}`)}function rt(e){return Array.from({length:e.flowCount},(t,s)=>M(e.recordingDir,"flows",String(s),"actions.ndjson"))}import{existsSync as oe,mkdirSync as Me,rmSync as je,cpSync as Fe}from"fs";function de(e,t){oe(e)&&(oe(t)&&je(t,{recursive:!0,force:!0}),Me(t,{recursive:!0}),Fe(e,t,{recursive:!0}))}async function gt(e){let t=new Map;for(let o of e.stepRunRecords)t.set(o.testmdStepIndex,o);let s=e.authoredFlatIdx??new Set,l=[],a=[],i=new Map,p=o=>{if(i.has(o))return i.get(o);let r=R(o,"Result.md"),c=w(r)?$(r):null;return i.set(o,c),c};for(let o of e.resolvedTest.unitFiles){let r=o.file===e.resolvedTest.rootPath,c=V(o.file,Oe(o.file,"utf8")),m=P(o.file),I=w(m)?$(m):null,f=[],b=[],g=[],j=[];if(!r)for(let d of e.resolvedTest.steps){if(d.owningFile!==o.file||d.trace.length<2)continue;let n=H(d.trace);j.includes(n)||j.push(n)}let F=d=>{if(I!==null)return null;for(let n of j){let v=p(n)?.steps[d-1];if(v)return{row:v,dir:n}}return null},W=[],A=!1,B=!1,L=!1,E=!1;for(let d of c.steps){let n=d.index,u=I?.steps[n-1];if(d.body.kind==="objective"){let h=e.resolvedTest.steps.filter(S=>S.owningFile===o.file&&S.trace[S.trace.length-1].stepIndex===n&&t.has(S.flatIndex)),y=h.length>0?h[h.length-1]:null;if(y){A=!0,s.has(y.flatIndex)&&(B=!0);let S=T(y),x;r?x=e.outcomes.find(he=>he.rootStepIndex===n)??{rootStepIndex:n,status:"skipped"}:x={rootStepIndex:n,status:ce(y,e.outcomes)},x.status==="failed"&&(L=!0),x.stepMd5==null&&(x.stepMd5=S),f.push(x),b.push({stepIndex:n,md5:S,rec:t.get(y.flatIndex)}),(!u||u.kind!=="objective"||u.status!==x.status||x.status==="passed"&&u.md5!==S)&&(E=!0)}else if(u&&u.kind==="objective")f.push({rootStepIndex:n,status:u.status,...u.md5?{stepMd5:u.md5}:{}}),g.push(n);else if(!r&&F(n)?.row.kind==="objective"){let S=F(n),x=S.row;f.push({rootStepIndex:n,status:x.status,...x.md5?{stepMd5:x.md5}:{}}),W.push({psIdx:n,dir:S.dir})}else r?f.push(e.outcomes.find(S=>S.rootStepIndex===n)??{rootStepIndex:n,status:"skipped"}):f.push({rootStepIndex:n,status:"skipped"});continue}let v=Le(d.body.path)?d.body.path:Ne(Ae(o.file),d.body.path),O=X({path:d.body.path,bindings:d.body.bindings,optional:d.optional??!1}),me=Ee(G(o.file),P(v)),N=e.resolvedTest.steps.filter(h=>h.trace.some((y,S)=>S<h.trace.length-1&&y.file===o.file&&y.stepIndex===n)&&t.has(h.flatIndex));if(N.length>0){A=!0;let h;if(r)h=e.outcomes.find(y=>y.rootStepIndex===n)??{rootStepIndex:n,status:"passed",refKind:"import",refLabel:d.body.path};else{let y=N.some(S=>ce(S,e.outcomes)==="failed");h={rootStepIndex:n,status:y?"failed":"passed",refKind:"import",refLabel:d.body.path,inlinedCount:N.length}}h.status==="failed"&&(L=!0),h.stepMd5==null&&(h.stepMd5=O),h.helperResultRelPath==null&&(h.helperResultRelPath=me),f.push(h),(!u||u.kind!=="import"||u.status!==h.status||u.md5!==O)&&(E=!0)}else if(u&&u.kind==="import")f.push({rootStepIndex:n,status:u.status,refKind:"import",refLabel:u.importPath,...u.md5?{stepMd5:u.md5}:{},...u.helperResultRelPath?{helperResultRelPath:u.helperResultRelPath}:{}});else if(!r&&F(n)?.row.kind==="import"){let h=F(n).row;f.push({rootStepIndex:n,status:h.status,refKind:"import",refLabel:d.body.path})}else r?f.push(e.outcomes.find(h=>h.rootStepIndex===n)??{rootStepIndex:n,status:"skipped",refKind:"import",refLabel:d.body.path}):f.push({rootStepIndex:n,status:"skipped",refKind:"import",refLabel:d.body.path})}if(!(r||A&&(B||L||I===null||E)))continue;l.push(o.file);let k=q(o.file);ue(R(k,".internal"),{recursive:!0});for(let d of b){let n=R(k,".internal","steps",`${d.stepIndex}-${d.md5.slice(0,8)}`);ue(n,{recursive:!0}),await ne({sessionDir:e.sessionDir,runIndex:d.rec.runIndex,totalRunDirs:d.rec.totalRunDirs,stagingStepDir:n,packTestDir:e.packTestDir})}if(g.length>0){let d=z(o.file);if(w(d))for(let n of pe(d)){let u=parseInt(n.split("-")[0]??"",10);!Number.isNaN(u)&&g.includes(u)&&le(R(d,n),R(k,".internal","steps",n),{recursive:!0})}}for(let d of W){let n=R(d.dir,".internal","steps");if(w(n))for(let u of pe(n))parseInt(u.split("-")[0]??"",10)===d.psIdx&&le(R(n,u),R(k,".internal","steps",u),{recursive:!0})}let fe=f.some(d=>d.status==="failed");if(ee({sourcePath:o.file,title:c.title,rootSteps:c.steps,outcomes:f,overallStatus:r?e.overallStatus:fe?"failed":"passed",startedISO:e.startedISO,durationS:r?e.durationS:0,sessionId:e.sessionId,outPath:R(k,"Result.md")}),r){let d={};e.commitId&&(d.commit_id=e.commitId),e.tmsIds.testId&&(d.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(d.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(d.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(d.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(d.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(d.session_name=e.tmsIds.sessionName),_e(R(k,".internal","meta.json"),JSON.stringify(d,null,2)+`
5
+ `,"utf8");let n=R(e.sessionDir,"execution.json");if(w(n))try{ae(n,R(k,".internal","execution.json"))}catch{}if(e.codeExportDir){let u=e.codeExportLanguage??"python",v=R(k,`playwright-${u}-code`);try{de(e.codeExportDir,v)}catch(O){process.stderr.write(`warn: codegen copy failed: ${O.message}
6
+ `)}}}else if(o.kind==="test"){let d=J(o.file);if(w(d))try{ae(d,R(k,".internal","meta.json"))}catch{}}!r&&j.length>0&&f.every(n=>n.status!=="skipped")&&a.push({unitFile:o.file,dirs:j.filter(n=>w(n))})}return{changedUnitFiles:l,legacySweep:a}}function St(e){for(let t of e)try{Te(t,{recursive:!0,force:!0})}catch{}}function ce(e,t){let s=e.trace[0].stepIndex,l=t.find(o=>o.rootStepIndex===s);if(!l)return"skipped";if(l.status==="passed")return"passed";if(l.status==="skipped")return"skipped";let a=e.trace.slice(1).map(o=>o.stepIndex),i=l.failedSubStepIndex??[],p=Math.min(a.length,i.length);for(let o=0;o<p;o++)if(a[o]!==i[o])return a[o]<i[o]?"passed":"skipped";return a.length===i.length?"failed":a.length<i.length?"passed":"skipped"}export{ee as a,et as b,tt as c,st as d,rt as e,de as f,gt as g,St as h};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-2WVKOZ6W.js";import{a as g}from"./chunk-QZJID3OZ.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new m(g(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),n=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(l=>l.name===n);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let l=await d.createProject(n);t=l.id,s=l.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(l=>l.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let l=await d.createFolder(t,o);c=l.id,i=l.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??n,folderId:c,folderName:i??o}}function A(e,r,d){let n=e.loadProfileConfig(r,d)??{};return{projectId:n.project_id??null,folderId:n.folder_id??null}}function N(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
2
+ import{a as m}from"./chunk-2WVKOZ6W.js";import{a as g}from"./chunk-KHJXOFDM.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new m(g(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),n=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(l=>l.name===n);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let l=await d.createProject(n);t=l.id,s=l.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(l=>l.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let l=await d.createFolder(t,o);c=l.id,i=l.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??n,folderId:c,folderName:i??o}}function A(e,r,d){let n=e.loadProfileConfig(r,d)??{};return{projectId:n.project_id??null,folderId:n.folder_id??null}}function N(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
3
3
 
4
4
  discover IDs:
5
5
  kane-cli projects list --search "<keyword>" --limit 10
@@ -14,4 +14,4 @@ set them:
14
14
  kane-cli config folder <folder-id>
15
15
  `;function C(e,r){return k(e,r)}function D(e){return`info: auto-configured project "${e.projectName}" (${e.projectId}) and folder "${e.folderName}" (${e.folderId}). Change with: kane-cli config project <id> / kane-cli config folder <id>.`}function S(e){return`${JSON.stringify(T(e))}
16
16
  `}function T(e){return{type:"project_folder_auto_defaulted",project_id:e.projectId,project_name:e.projectName,folder_id:e.folderId,folder_name:e.folderName}}async function x(e){if(e.isLocal)return e.log("info","GATE_SKIP_LOCAL","Gate skipped (--local)",{}),{status:"skip",reason:"local"};j(e.creds,e.config,e.profile,e.env,e.log);let r=A(e.creds,e.profile,e.env),d=null;if(r.projectId!==null){let o=g(e.env);d=await new m(o.tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key).validateProjectFolder(r.projectId,r.folderId??""),e.log("info","GATE_VALIDATE","TMS project/folder validation",{project:d.project,folder:d.folder,folder_was_cached:r.folderId!==null})}else r.folderId!==null&&(f(e.creds,e.config,e.profile,e.env,{folderId:null,folderName:null}),e.log("warn","GATE_CLEARED_ORPHAN_FOLDER","Cleared orphan folder (no project cached)",{folder_id:r.folderId}),r.folderId=null);let n=N(r,d);if(n==="ok")return{status:"ok",projectId:r.projectId,folderId:r.folderId};if(n==="ok-tms-degraded")return e.log("warn","GATE_TMS_DEGRADED","TMS validation failed; using cached IDs",{project_id:r.projectId,folder_id:r.folderId}),{status:"ok",projectId:r.projectId,folderId:r.folderId};if(d){let o={};d.project==="missing"?(o.projectId=null,o.projectName=null,o.folderId=null,o.folderName=null):d.folder==="missing"&&(o.folderId=null,o.folderName=null),Object.keys(o).length>0&&(f(e.creds,e.config,e.profile,e.env,o),e.log("info","GATE_CLEARED_STALE","Cleared stale cached IDs before re-resolve",{project_cleared:d.project==="missing",folder_cleared:d.folder==="missing"||d.project==="missing"}))}try{let o=await p({creds:e.creds,config:e.config,profile:e.profile,env:e.env,tmsCreds:e.tmsCreds,log:e.log}),t={projectId:o.projectId,projectName:o.projectName,folderId:o.folderId,folderName:o.folderName};return e.log("info","GATE_AUTO_DEFAULTED","Auto-configured project/folder",{project_id:t.projectId,project_name:t.projectName,folder_id:t.folderId,folder_name:t.folderName}),e.onAnnounce?e.onAnnounce(t):process.stderr.write(`${D(t)}
17
- `),{status:"ok",projectId:t.projectId,folderId:t.folderId,autoDefaulted:t}}catch(o){let t=C(e.profile,e.env);if(e.log("error","GATE_FATAL","Auto-default failed",{profile:e.profile,env:e.env,cached_project_id:r.projectId,cached_folder_id:r.folderId,validation:d,error:o instanceof Error?o.message:String(o)}),e.onFatalExit)e.onFatalExit(t);else{process.stderr.write(t);let{shutdown:s}=await import("./exit-manager-VCSIUYBR.js");s(2,"Project/folder gate failed")}return{status:"cancelled"}}}export{p as a,A as b,N as c,C as d,D as e,S as f,T as g,x as h};
17
+ `),{status:"ok",projectId:t.projectId,folderId:t.folderId,autoDefaulted:t}}catch(o){let t=C(e.profile,e.env);if(e.log("error","GATE_FATAL","Auto-default failed",{profile:e.profile,env:e.env,cached_project_id:r.projectId,cached_folder_id:r.folderId,validation:d,error:o instanceof Error?o.message:String(o)}),e.onFatalExit)e.onFatalExit(t);else{process.stderr.write(t);let{shutdown:s}=await import("./exit-manager-MXUD7GQ7.js");s(2,"Project/folder gate failed")}return{status:"cancelled"}}}export{p as a,A as b,N as c,C as d,D as e,S as f,T as g,x as h};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ function i(t){let n=Object.entries(t).map(([e,r])=>`${JSON.stringify(e)}: ${JSON.stringify(r)}`).join(", ");return Buffer.byteLength(`{${n}}`,"utf8")}export{i as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{y as o}from"./chunk-VCYVSKPM.js";import{a as m}from"./chunk-HCBYKLMW.js";import{a as e,b as i}from"./chunk-C44QQJR4.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:o.muted,error:o.red,success:o.green,info:o.orange,warning:o.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?o.orange:s[n]);return(0,r.jsxs)(e,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(e,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(e,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=o.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(e,{children:[(0,r.jsx)(e,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(e,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(e,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
2
+ import{y as o}from"./chunk-MMPFU2YC.js";import{a as m}from"./chunk-HCBYKLMW.js";import{a as e,b as i}from"./chunk-C44QQJR4.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:o.muted,error:o.red,success:o.green,info:o.orange,warning:o.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?o.orange:s[n]);return(0,r.jsxs)(e,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(e,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(e,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=o.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(e,{children:[(0,r.jsx)(e,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(e,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(e,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  function l(r){let{isAgent:c,log:m}=r,a=r.stdout??process.stderr,s=r.stdin??process.stdin,p=t=>{c&&process.stdout.write(JSON.stringify(t)+`
3
- `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-7CL3PM3J.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:d}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await d()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-H4265KXU.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-BQZEGOIV.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-66M7XP5Y.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onRetryAttempt(t){p({type:"test_md_retry_attempt",...t})},onAgentEvent(t){p(t)}}}export{l as a};
3
+ `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-MQ7ZPFN2.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:d}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await d()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-UURZ63VQ.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-WWF3G263.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-5MSEKNSV.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onRetryAttempt(t){p({type:"test_md_retry_attempt",...t})},onAgentEvent(t){p(t)}}}export{l as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as P}from"./chunk-YCCUBQY4.js";import{y as a}from"./chunk-MMPFU2YC.js";import{a as S}from"./chunk-HCBYKLMW.js";import{a as M,b as n,i as $,k as B}from"./chunk-C44QQJR4.js";import{a as N}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var o=b(S(),1);function Q(m){let e=m.findIndex(c=>c.free);return e>=0?e:null}var _=60,I=100;function X({headline:m,ask:e=!1,rows:c,sel:r,focused:T,legend:u,freeText:l=null,freeTextNote:x,sublines:i=[]}){let{stdout:t}=B(),f=t?.columns??80,A=f<_,s=Math.min(f-1,I),g=d=>T&&r===d?(0,o.jsx)(n,{color:a.assuranceAccent,children:"\u276F"}):" ",p=e?`? ${m}`:m,w=Math.max(4,s-3),h=i.map((d,v)=>(0,o.jsx)(n,{color:a.dim,children:` ${d.length>w?`${d.slice(0,w-1)}\u2026`:d}`},`sub-${v}`)),C=0,E=c.map((d,v)=>d.free?l?(0,o.jsxs)(M,{flexDirection:"column",children:[(0,o.jsxs)(M,{children:[(0,o.jsxs)(n,{children:[(0,o.jsx)(n,{color:a.assuranceAccent,children:"\u276F"})," ",(0,o.jsx)(n,{color:a.dim,children:"\u270E "})]}),(0,o.jsx)(P,{value:l.value,onChange:l.onChange,onSubmit:l.onSubmit,onCancel:l.onCancel,placeholder:d.label})]}),x?(0,o.jsx)(n,{color:a.muted,children:` ${x}`}):null]},d.key):(0,o.jsxs)(n,{children:[g(v)," ",(0,o.jsx)(n,{color:a.dim,children:`\u270E ${d.label}`})]},d.key):(C+=1,(0,o.jsxs)(n,{bold:T&&r===v,children:[g(v),` ${C}. ${d.label}`,d.detail?(0,o.jsx)(n,{color:a.dim,bold:!1,children:` \u2014 ${d.detail}`}):null]},d.key)));if(A)return(0,o.jsxs)(M,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,o.jsx)(n,{bold:!0,color:a.assuranceAccent,children:p}),h,E,(0,o.jsx)(n,{color:a.muted,children:u})]});let L=Math.max(2,s-(3+p.length+1)),F=Math.max(2,s-(3+u.length+1));return(0,o.jsxs)(M,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,o.jsxs)(n,{color:a.assuranceAccent,children:["\u2500\u2500 ",(0,o.jsx)(n,{bold:!0,children:p}),` ${"\u2500".repeat(L)}`]}),h,(0,o.jsx)(n,{children:" "}),E,(0,o.jsx)(n,{children:" "}),(0,o.jsxs)(n,{color:a.assuranceAccent,children:["\u2500\u2500 ",(0,o.jsx)(n,{color:a.muted,children:u}),` ${"\u2500".repeat(F)}`]})]})}var R=b(S(),1),K="ctrl+t thinking \xB7 ctrl+c exit";function D(m,e){if(m.length<=e)return m;if(e<=1)return"\u2026";let c=Math.ceil((e-1)/2),r=Math.floor((e-1)/2);return`${m.slice(0,c)}\u2026${r>0?m.slice(-r):""}`}function J({verb:m,subject:e,pendingCount:c,creditsTotal:r,state:T,hints:u=K}){let{stdout:l}=B(),x=l?.columns??80,i=[];i.push(m),T&&i.push(T),r!==void 0&&i.push(`${r.toFixed(1)} credits`);let t=c?`[${c} pending]`:null,f=" \xB7 ",s=[...i,...t?[t]:[]].join(f).length,g,p=[...i,...e?[e]:[],...t?[t]:[],u].join(f);if(p.length<=x)g=p;else{let w=x-s-(e?f.length:0)-f.length-u.length;if(e&&w>=8)g=[...i,D(e,w),...t?[t]:[],u].join(f);else{let h=x-s-(e?f.length:0);g=[...i,...e&&h>=4?[D(e,h)]:[],...t?[t]:[]].join(f)}}if(T){let w=` \xB7 ${T}`,h=g.indexOf(w);if(h>=0)return(0,R.jsxs)(n,{color:a.dim,children:[g.slice(0,h+3),(0,R.jsx)(n,{color:a.assuranceAccent,children:T}),g.slice(h+w.length)]})}return(0,R.jsx)(n,{color:a.dim,children:g})}var O=b(N(),1);function Z({onToggleThinking:m,onCtrlC:e,explorer:c,panel:r}){let u=(0,O.useRef)(null),l=(0,O.useRef)(""),x=()=>{u.current&&clearTimeout(u.current),u.current=null,l.current=""};return(0,O.useEffect)(()=>x,[]),$((i,t)=>{if(t.ctrl&&i==="t"){m();return}if(t.ctrl&&i==="c"){e();return}if(!t.ctrl&&i.includes("")){e();return}if(!t.ctrl&&i.includes("")){m();return}if(c&&c.isOpen()){let f=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{x(),c.onBack()},150)};if(u.current){if(t.upArrow||t.downArrow||t.return){x(),t.return?c.onEnter():c.onMove(t.upArrow?-1:1);return}if(l.current+=i,l.current==="["){f();return}let A=l.current;x();let s=/^\[([ABCD])/.exec(A);if(s){(s[1]==="A"||s[1]==="B")&&c.onMove(s[1]==="A"?-1:1);return}c.onBack();return}if(t.upArrow){c.onMove(-1);return}if(t.downArrow){c.onMove(1);return}if(t.return){c.onEnter();return}if(t.escape){l.current="",f();return}return}if(r&&r.isFocused()){let f=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{x(),r.onBack()},150)};if(u.current){if(t.upArrow||t.downArrow||t.return||t.leftArrow||t.rightArrow){x(),t.return?r.onSelect():t.leftArrow?r.onLeft?.():t.rightArrow?r.onRight?.():r.onMove(t.upArrow?-1:1);return}if(l.current+=i,l.current==="["){f();return}let A=l.current;x();let s=/^\[([ABCD])/.exec(A);if(s){s[1]==="A"||s[1]==="B"?r.onMove(s[1]==="A"?-1:1):s[1]==="C"?r.onRight?.():r.onLeft?.();return}r.onBack();return}if(t.upArrow){r.onMove(-1);return}if(t.downArrow){r.onMove(1);return}if(t.leftArrow){r.onLeft?.();return}if(t.rightArrow){r.onRight?.();return}if(t.return){r.onSelect();return}if(t.escape){l.current="",f();return}if(/^[1-9]$/.test(i)){r.onDigit(Number(i));return}if(t.tab){r.onTab?.();return}if(i===" "&&r.isMulti()){r.onSpace();return}if(i&&!t.ctrl&&!t.meta){r.onType(i);return}return}}),null}export{Q as a,X as b,J as c,Z as d};