@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
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{extname as o}from"path";var s={kind:"jira",media_type:"application/x-kane-jira-envelope",extensions:[],cite:"verbatim",maxBytes:2e6},n=[{kind:"text",media_type:"text/plain",extensions:[".txt"],cite:"verbatim",maxBytes:2e6},{kind:"markdown",media_type:"text/markdown",extensions:[".md",".markdown"],cite:"verbatim",maxBytes:2e6},{kind:"image",media_type:"image/png",extensions:[".png"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/jpeg",extensions:[".jpg",".jpeg"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/webp",extensions:[".webp"],cite:"anchor-only",maxBytes:5e6},{kind:"text",media_type:"application/json",extensions:[".json"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"application/yaml",extensions:[".yaml",".yml"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"application/toml",extensions:[".toml"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"application/xml",extensions:[".xml"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"text/plain",extensions:[".log"],cite:"verbatim",maxBytes:2e6},{kind:"pdf",media_type:"application/pdf",extensions:[".pdf"],cite:"verbatim",maxBytes:25e6,sniff:e=>e.subarray(0,5).toString("latin1")==="%PDF-"},{kind:"docx",media_type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",extensions:[".docx"],cite:"verbatim",maxBytes:25e6,sniff:e=>e.length>=4&&e[0]===80&&e[1]===75&&e[2]===3&&e[3]===4,sniffFail:e=>e.length>=8&&e.subarray(0,8).equals(d)?"DOCX_ENCRYPTED_OR_LEGACY: password-protected Office file (or a legacy .doc renamed .docx) \u2014 remove the password / save as .docx and re-ingest":void 0},s],d=Buffer.from([208,207,17,224,161,177,26,225]),x={pdf:"pdf",docx:"docx",jira:"jira"},r=new Set(Object.keys(x));function p(e){let a=o(e).toLowerCase(),i=n.find(t=>t.extensions.includes(a));return i?{ok:!0,media:i}:{ok:!1,code:"UNSUPPORTED_MEDIA",allowlist:n.flatMap(t=>t.extensions)}}export{s as a,x as b,r as c,p as d};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ function S(e,n){let{width:t,height:r,channels:a}=n;if(e.length!==t*r*a)throw new Error(`appearanceSignature: buffer ${e.length} bytes does not match ${t}x${r}x${a}`);let f=9,h=8,x=new Array(f*h);for(let o=0;o<h;o++){let l=Math.floor(o*r/h),d=Math.min(r,Math.max(l+1,Math.floor((o+1)*r/h)));for(let c=0;c<f;c++){let y=Math.floor(c*t/f),A=Math.min(t,Math.max(y+1,Math.floor((c+1)*t/f))),b=0,p=0;for(let u=l;u<d;u++)for(let m=y;m<A;m++){let s=(u*t+m)*a;b+=a===1?e[s]:Math.floor((e[s]*299+e[s+1]*587+e[s+2]*114)/1e3),p+=1}x[o*f+c]=Math.floor(b/p)}}let M="",i=0,g=0;for(let o=0;o<h;o++)for(let l=0;l<f-1;l++)i=i<<1|(x[o*f+l+1]>x[o*f+l]?1:0),g+=1,g===4&&(M+=i.toString(16),i=0,g=0);return M}var $=(()=>{let e=new Uint32Array(256);for(let n=0;n<256;n++){let t=n;for(let r=0;r<8;r++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t>>>0}return e})();function C(e){let n=4294967295;for(let t=0;t<e.length;t++)n=$[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}export{S as a,C as b};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-FPFOW6BS.js";import{h as a}from"./chunk-M5JQXOCE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-QZJID3OZ.js";import{a as h}from"./chunk-DPOES6G3.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
2
+ import{a as k}from"./chunk-FPFOW6BS.js";import{p as a}from"./chunk-Y5RNCJAN.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-KHJXOFDM.js";import{a as h}from"./chunk-LHDNJJGE.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
3
3
  `)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
4
- `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-7PAPCMQK.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
4
+ `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-S7CYBZTE.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
5
5
  `,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
6
6
  `,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
7
7
  `,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as B,b as V,c as se}from"./chunk-TACPTX64.js";import{a as j,b as N}from"./chunk-RLICAFFQ.js";import{a as ne,b as oe}from"./chunk-2YQ6TW77.js";import{a as C,b as Y,e as M,f as te,m as re}from"./chunk-RKWJG3WW.js";import{a as L}from"./chunk-FVM7TWKT.js";import{a as ee}from"./chunk-WAOCHXJ5.js";import{a as Z}from"./chunk-JHAGEBKE.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as H}from"./chunk-QZJID3OZ.js";import{a as O}from"./chunk-DPOES6G3.js";import{y as h}from"./chunk-VCYVSKPM.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as g,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Je,rmSync as pe,unlinkSync as Ke}from"fs";import{resolve as G}from"path";import{promises as ie,realpathSync as ke}from"fs";import{homedir as be}from"os";import{join as q,parse as Te,relative as ae,resolve as ce}from"path";var le=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function ue(e){try{return ke(ce(e))}catch{return ce(e)}}function Ee(e){let r=ue(e),s=ue(be()),n=Te(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Ee(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),m;try{m=await ie.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of m){if(t++,t>r){c=!0,f="max_entries";break}let w=b.name,E=q(a,w);if(b.isDirectory()){if(le.has(w)||w.startsWith(".")||w.startsWith("output-")||n.has(w))continue;l.push(E)}else if(b.isFile()&&w.endsWith("_test.md")&&(o.push({path:E,relPath:ae(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let m=[{dir:q(e.root,".testmuai","tests"),depth:0}];for(;m.length>0&&!c;){let{dir:b,depth:w}=m.shift(),E;try{E=await ie.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let x=u.name,y=q(b,x);if(u.isDirectory()){if(w>=20||x.startsWith(".")||x.startsWith("output-")||le.has(x))continue;m.push({dir:y,depth:w+1})}else if(u.isFile()&&x.endsWith("_test.md")&&(o.push({path:y,relPath:ae(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as Se}from"fs";function W(e){try{return re(e,Se(e,"utf8")).global.tags??[]}catch{return[]}}import{mkdirSync as ve,writeFileSync as Re}from"fs";import{join as Pe}from"path";function de(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Me(e){let r=ne({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:de(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function De(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:de(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);ve(e.outDir,{recursive:!0});for(let l of c.url){let a=Pe(e.outDir,l.file_name),m=await A(l.file_url);if(!m.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:m.status});continue}let b=await m.text();Re(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function fe(e){return await Me(e),await De(e)}var T=v(X(),1);import{existsSync as $e,readFileSync as Ce}from"fs";var p=v(F(),1);function Ie(e){B(e);let r=M(e);if(!$e(r))return null;try{return JSON.parse(Ce(r,"utf8"))}catch{return{}}}function Fe(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Oe(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ae(e){return e==="tests-dir"?"\u2726":" "}function Le(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Be(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,m]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),x=[];for(let y of u.results){let K=Ie(y.path);K?.org_id!==void 0&&K.org_id!==r||x.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Fe(K),source:y.source,tags:W(y.path)})}t(x),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Le(u,a)).map(u=>({id:u.path,label:`${Oe(u.status)} ${Ae(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),w=(0,T.useMemo)(()=>Ne(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(g,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(g,{color:h.red,children:i})})]});let E=a==="all"?"all":je(a);return(0,p.jsx)(Z,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let x=o.find(y=>y.path===u.id);x&&s(x)},onCancel:n,onTab:()=>m(u=>Be(u)),extraHint:"cycle filter",footer:w})}function je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ne(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(g,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(g,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(g,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(g,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Ue,readFileSync as We}from"fs";var d=v(F(),1);function ge({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Ue(a))try{i(JSON.parse(We(a,"utf8")))}catch{i(null)}},[e]),Q((a,m)=>{if(m.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:m})=>m?(0,d.jsxs)(g,{children:[(0,d.jsx)(g,{color:h.dim,children:a.padEnd(14)}),m]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(g,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(g,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Je(r,"utf8"))}catch{return null}}function he(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return he(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
2
+ import{a as B,b as V,c as se}from"./chunk-HOQEMPMQ.js";import{a as j,b as N}from"./chunk-NJAHRITS.js";import{a as ne,b as oe}from"./chunk-2YQ6TW77.js";import{a as C,b as Y,e as M,f as te,m as re}from"./chunk-RKWJG3WW.js";import{a as L}from"./chunk-3AZTXJY4.js";import{a as ee}from"./chunk-WAOCHXJ5.js";import{a as Z}from"./chunk-GIMTSDNC.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as H}from"./chunk-KHJXOFDM.js";import{a as O}from"./chunk-LHDNJJGE.js";import{y as h}from"./chunk-MMPFU2YC.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as g,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Je,rmSync as pe,unlinkSync as Ke}from"fs";import{resolve as G}from"path";import{promises as ie,realpathSync as ke}from"fs";import{homedir as be}from"os";import{join as q,parse as Te,relative as ae,resolve as ce}from"path";var le=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function ue(e){try{return ke(ce(e))}catch{return ce(e)}}function Ee(e){let r=ue(e),s=ue(be()),n=Te(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Ee(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),m;try{m=await ie.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of m){if(t++,t>r){c=!0,f="max_entries";break}let w=b.name,E=q(a,w);if(b.isDirectory()){if(le.has(w)||w.startsWith(".")||w.startsWith("output-")||n.has(w))continue;l.push(E)}else if(b.isFile()&&w.endsWith("_test.md")&&(o.push({path:E,relPath:ae(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let m=[{dir:q(e.root,".testmuai","tests"),depth:0}];for(;m.length>0&&!c;){let{dir:b,depth:w}=m.shift(),E;try{E=await ie.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let x=u.name,y=q(b,x);if(u.isDirectory()){if(w>=20||x.startsWith(".")||x.startsWith("output-")||le.has(x))continue;m.push({dir:y,depth:w+1})}else if(u.isFile()&&x.endsWith("_test.md")&&(o.push({path:y,relPath:ae(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as Se}from"fs";function W(e){try{return re(e,Se(e,"utf8")).global.tags??[]}catch{return[]}}import{mkdirSync as ve,writeFileSync as Re}from"fs";import{join as Pe}from"path";function de(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Me(e){let r=ne({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:de(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function De(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:de(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);ve(e.outDir,{recursive:!0});for(let l of c.url){let a=Pe(e.outDir,l.file_name),m=await A(l.file_url);if(!m.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:m.status});continue}let b=await m.text();Re(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function fe(e){return await Me(e),await De(e)}var T=v(X(),1);import{existsSync as $e,readFileSync as Ce}from"fs";var p=v(F(),1);function Ie(e){B(e);let r=M(e);if(!$e(r))return null;try{return JSON.parse(Ce(r,"utf8"))}catch{return{}}}function Fe(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Oe(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ae(e){return e==="tests-dir"?"\u2726":" "}function Le(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Be(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,m]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),x=[];for(let y of u.results){let K=Ie(y.path);K?.org_id!==void 0&&K.org_id!==r||x.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Fe(K),source:y.source,tags:W(y.path)})}t(x),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Le(u,a)).map(u=>({id:u.path,label:`${Oe(u.status)} ${Ae(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),w=(0,T.useMemo)(()=>Ne(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(g,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(g,{color:h.red,children:i})})]});let E=a==="all"?"all":je(a);return(0,p.jsx)(Z,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let x=o.find(y=>y.path===u.id);x&&s(x)},onCancel:n,onTab:()=>m(u=>Be(u)),extraHint:"cycle filter",footer:w})}function je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ne(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(g,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(g,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(g,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(g,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Ue,readFileSync as We}from"fs";var d=v(F(),1);function ge({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Ue(a))try{i(JSON.parse(We(a,"utf8")))}catch{i(null)}},[e]),Q((a,m)=>{if(m.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:m})=>m?(0,d.jsxs)(g,{children:[(0,d.jsx)(g,{color:h.dim,children:a.padEnd(14)}),m]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(g,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(g,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Je(r,"utf8"))}catch{return null}}function he(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return he(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
3
3
  Switch profiles with \`kane-cli profiles switch\` to act on it.
4
4
  `),2)}async function Ut(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await V({isInteractive:r,creds:s,config:n});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function Wt(e,r){if(process.stdin.isTTY&&!e.json)return await Ye(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
5
5
  `),2;throw o}for(let o of n.results){let t=$(o.path);if(!he(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:C(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
6
6
  `)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
7
- `),0}var _e=-1001,ye=-1002,we=-1003,_={action:null,path:null};function Xe(e,r){return _.action=e,_.path=r,e==="run"?_e:e==="export"?ye:we}function He({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(ge,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Xe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Ye(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(He,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===_e&&_.path){let{runTestMdFile:t}=await import("./run-test-md-ZCAWNP35.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===ye&&_.path){let t=await qe(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Ve(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Jt(e,r){let s=G(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
7
+ `),0}var _e=-1001,ye=-1002,we=-1003,_={action:null,path:null};function Xe(e,r){return _.action=e,_.path=r,e==="run"?_e:e==="export"?ye:we}function He({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(ge,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Xe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Ye(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(He,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===_e&&_.path){let{runTestMdFile:t}=await import("./run-test-md-XOSCYVSS.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===ye&&_.path){let t=await qe(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Ve(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Jt(e,r){let s=G(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
8
8
  `),2;let n=$(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:C(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
9
9
  `),0}async function Ve(e,r,s){let n=G(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
10
10
  `),2;let o=$(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-5Y2G4NC7.js";import{y as o}from"./chunk-VCYVSKPM.js";import{a as n}from"./chunk-HCBYKLMW.js";import{b as t}from"./chunk-C44QQJR4.js";import{a as s}from"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var l=r(s(),1);var m=r(n(),1),i=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function b({active:e=!0}){let[p,c]=(0,l.useState)(0);return a(()=>{c(f=>(f+1)%i.length)},e?80:null),(0,m.jsx)(t,{color:o.orange,children:e?i[p]:"\u25CF"})}export{b as a};
2
+ import{a}from"./chunk-5Y2G4NC7.js";import{y as o}from"./chunk-MMPFU2YC.js";import{a as n}from"./chunk-HCBYKLMW.js";import{b as t}from"./chunk-C44QQJR4.js";import{a as s}from"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var l=r(s(),1);var m=r(n(),1),i=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function b({active:e=!0}){let[p,c]=(0,l.useState)(0);return a(()=>{c(f=>(f+1)%i.length)},e?80:null),(0,m.jsx)(t,{color:o.orange,children:e?i[p]:"\u25CF"})}export{b as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as t}from"./chunk-U5QTE3WX.js";async function l(e){let o=e.credentials.expires_at,i=e.thresholdSeconds??300;if(o-Date.now()/1e3>=i)return null;let r=e.creds.loadClient(e.profile,e.env);if(!r)return null;let n=await new t(e.env).refreshToken(e.credentials.refresh_token,r.client_id),s=Math.floor(Date.now()/1e3)+n.expires_in;return e.creds.saveCredentials(e.profile,e.env,{access_token:n.access_token,refresh_token:n.refresh_token,expires_at:s,scope:n.scope}),{accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:s,scope:n.scope}}export{l as a};
2
+ import{a as t}from"./chunk-4CJ55EUY.js";async function l(e){let o=e.credentials.expires_at,i=e.thresholdSeconds??300;if(o-Date.now()/1e3>=i)return null;let r=e.creds.loadClient(e.profile,e.env);if(!r)return null;let n=await new t(e.env).refreshToken(e.credentials.refresh_token,r.client_id),s=Math.floor(Date.now()/1e3)+n.expires_in;return e.creds.saveCredentials(e.profile,e.env,{access_token:n.access_token,refresh_token:n.refresh_token,expires_at:s,scope:n.scope}),{accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:s,scope:n.scope}}export{l as a};
@@ -0,0 +1,19 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{c as g}from"./chunk-5EOX4MEY.js";var h={ASR_CMD_START:"info",ASR_CMD_END:"info",ASR_AGENT_SPAWN:"info",ASR_WORK_ITEM_START:"info",ASR_WORK_ITEM_END:"info",ASR_PROPOSAL:"info",ASR_VALIDATE_FAILED:"warn",ASR_COMMIT:"info",ASR_SESSION_PAUSED:"info",ASR_SESSION_RESUMED:"info",ASR_SESSION_COMPLETE:"info",ASR_AGENT_EXIT:"warn",ASR_RECONCILE_PLAN:"info",ASR_RECONCILE_ROW_END:"info",ASR_HIGH_RISK_CI:"warn",ASR_INGEST:"info",ASR_CONTEXT_CLONED:"warn",ASR_ERROR:"error",ASR_CRASH:"error"},O={ASR_CMD_START:["source_count","resumed","applied_plan"],ASR_CMD_END:["exit_code","duration_ms","credits_total","work_items_total","work_items_failed"],ASR_AGENT_SPAWN:["tier","duration_ms"],ASR_WORK_ITEM_START:["work_item_index","work_item_count","source_kind"],ASR_WORK_ITEM_END:["work_item_index","work_item_count","outcome","duration_ms","error_domain","error_code"],ASR_PROPOSAL:["item_count","turn_index"],ASR_VALIDATE_FAILED:["error_code","count","turn_index"],ASR_COMMIT:["trusted","derived","archived","items","items_dropped","record_seq"],ASR_SESSION_PAUSED:["pending_questions","pending_proposals"],ASR_SESSION_RESUMED:["resume_count","expired_session_id"],ASR_SESSION_COMPLETE:["duration_ms","credits_total"],ASR_AGENT_EXIT:["exit_code","signal"],ASR_RECONCILE_PLAN:["row_count","add_count","modify_count","archive_count"],ASR_RECONCILE_ROW_END:["row_index","kind","outcome","duration_ms"],ASR_HIGH_RISK_CI:["count"],ASR_INGEST:["work_item_index","work_item_count","format","bytes","media_facts"],ASR_CONTEXT_CLONED:[],ASR_ERROR:["error_domain","error_code","exit_code","turn_index"],ASR_CRASH:["error_domain","error_code","error_name"]},k=[[/^(auth_expired|401|preflight_auth|AUTH)/i,"auth"],[/^(credit_denied|402|CREDIT)/i,"credit"],[/^(stream_drop|read_timeout|connect_failed|dns|E(CONN|AI_AGAIN|TIMEDOUT)|network)/i,"network"],[/^(frame_parse|post_terminal_data|eof_without_terminal|turn_id_mismatch|binding_mismatch|schema_invalid|frame_too_large|protocol)/i,"protocol"],[/^(provider_error|http_5\d\d|turn_exhausted|adapter_integrity)/i,"provider"],[/^(STALE_BASIS|R\d+|validation|criteria)/i,"validation"],[/^(BLOB_MISSING|SOURCE_UNKNOWN|SESSION_(LOCKED|EXPIRED|MISSING|LOCK_LOST)|NO_STORE|fsck|store)/i,"store"],[/^(usage|EX2|SOURCE_WITH_RESUME|HIGH_RISK_CI|bad_flag|no_tty)/i,"usage"],[/^agent_(crash|exit)/i,"agent_crash"]];function D(e){let t=(e||"unknown").slice(0,64);for(let[n,r]of k)if(n.test(t))return{error_domain:r,error_code:t};return{error_domain:"cli_crash",error_code:t}}import{randomBytes as L}from"crypto";var v=/^(uc|sc|ac|t|gap|sty)-\d+$/,$="0123456789abcdefghijklmnopqrstuvwxyz";function b(e){let t="",n=L(e);for(let r=0;r<e;r++)t+=$[n[r]%36];return t}function q(e=new Date){let t=(r,o)=>String(r).padStart(o,"0");return`as-${`${e.getUTCFullYear()}${t(e.getUTCMonth()+1,2)}${t(e.getUTCDate(),2)}T${t(e.getUTCHours(),2)}${t(e.getUTCMinutes(),2)}`}-${b(8)}`}var C=-1,S=0;function z(e=new Date){let t=e.getTime(),n=L(10);t===C?S=S+1&4095:(C=t,S=(n[0]<<8|n[1])&4095);let r=Buffer.alloc(16);r.writeUIntBE(t,0,6),r[6]=112|S>>8,r[7]=S&255,r[8]=128|n[2]&63,n.copy(r,9,3,10);let o=r.toString("hex");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var U=64,G=128,P=/^[A-Za-z0-9._:@\/-]+$/,H=0;function W(e,t){if(typeof t=="number"&&Number.isFinite(t)||typeof t=="boolean")return t;if(typeof t!="string")return;let n=e.endsWith("_id")||e==="signal"?G:U;if(!(t.length===0||t.length>n)&&P.test(t))return t}function w(e,t,n={}){let r=O[t],o={};for(let i of r){let s=n[i];if(s==null)continue;if(i==="items"){let u=Array.isArray(s)?s.filter(y=>typeof y=="string"):[],f=u.filter(y=>v.test(y));f.length>0&&(o.items=f.slice(0,50).join(","));let p=u.length-f.length;p>0&&(o.items_dropped=p);continue}let a=W(i,s);a!==void 0&&(o[i]=a)}if(typeof n.error_code=="string"&&r.includes("error_code")){let{error_domain:i,error_code:s}=D(n.error_code);o.error_code=s,r.includes("error_domain")&&(o.error_domain=i)}return{level:h[t],event:t,message:t,session_id:e.session_id,operation_id:e.operation_id,...e.parent_operation_id?{parent_operation_id:e.parent_operation_id}:{},...e.agent_session_id?{agent_session_id:e.agent_session_id}:{},context_lineage_id:e.context_lineage_id??null,context_instance_id:e.context_instance_id??null,verb:e.verb,mode:e.mode,component:"kane-cli",seq:H++,event_time:new Date().toISOString(),context:o}}import _ from"fs";import F from"path";var K=500,j=7;function M(e){if(e.length!==0)try{let t=g();_.mkdirSync(F.dirname(t),{recursive:!0});let n=e.map(r=>JSON.stringify(r)).join(`
3
+ `)+`
4
+ `;_.appendFileSync(t,n,{flag:"a",mode:384}),V()}catch{}}async function re(e){let t=g(),n=`${t}.claim-${process.pid}`,r;try{_.renameSync(t,n),r=_.readFileSync(n,"utf8")}catch{return}let o=[];for(let i of r.split(`
5
+ `))if(i.trim())try{o.push(JSON.parse(i))}catch{}try{(o.length===0?!0:await e(o))?_.unlinkSync(n):(_.appendFileSync(t,r,{flag:"a",mode:384}),_.unlinkSync(n))}catch{try{_.appendFileSync(t,r,{flag:"a",mode:384}),_.unlinkSync(n)}catch{}}}function V(e=K,t=j){try{let n=g(),o=_.readFileSync(n,"utf8").split(`
6
+ `).filter(u=>u.trim()),i=Date.now()-t*24*3600*1e3,a=o.filter(u=>{try{let f=JSON.parse(u),p=Date.parse(f.event_time??f.timestamp??"");return Number.isNaN(p)||p>=i}catch{return!1}}).slice(-e);a.length!==o.length&&_.writeFileSync(n,a.length?a.join(`
7
+ `)+`
8
+ `:"",{mode:384})}catch{}}var l=null;function _e(e){l=e}function ce(){return l}var I=()=>!!process.env.KANE_DEV_MODE,c=[],R=!1,N=null,A=null,x=null,d=null,E=[];function ae(e){if(d=e,e&&E.length>0){let t=E;E=[];for(let n of t)try{e.log(n.level,n.event,n.message,n.context)}catch{}}}function de(e,t,n,r){if(d){try{d.log(e,t,n,r)}catch{}return}E.push({level:e,event:t,message:n,context:r})}function le(){return d}function ue(){return R}function fe(e,t){c=c.filter(n=>n.name!==e),c.push({name:e,fn:t})}function pe(e){c=c.filter(t=>t.name!==e)}function Se(e,t){let n=c.find(o=>o.name===e);if(!n)return;c=c.filter(o=>o.name!==e);let r=!0;try{n.fn()}catch(o){r=!1,process.stderr.write(`[exit-manager] cleanup(${e}) failed: ${o instanceof Error?o.message:String(o)}
9
+ `)}t&&r&&I()&&process.stderr.write(`[exit-manager] cleanup(${e}): ${t}
10
+ `)}function m(e,t,n=!1,r){if(R){process.exit(N??e);return}if(R=!0,N=e,n&&d)try{d.log("error","CRASH",t),d.shutdownSync()}catch{}if(n&&l&&e!==130&&e!==143)try{let s=/Uncaught exception:\s*([A-Za-z0-9_$]+)/.exec(t)?.[1]??"crash";M([w(l,"ASR_CRASH",{error_code:"cli_crash",error_name:s})])}catch{}let o=[...c].reverse(),i=[];for(let s of o)try{s.fn(),i.push(s.name)}catch(a){process.stderr.write(`[exit-manager] cleanup(${s.name}) failed: ${a instanceof Error?a.message:String(a)}
11
+ `)}if(c=[],I()&&(process.stderr.write(`[exit-manager] shutdown(${e}): ${t}
12
+ `),i.length>0&&process.stderr.write(`[exit-manager] cleaned up: ${i.join(", ")}
13
+ `)),n){if(x)try{x()}catch{}e===130||e===143||(process.stderr.write(`
14
+ kane-cli crashed: ${t}
15
+ `+(i.length>0?`Resources cleaned up (${i.join(", ")}).
16
+ `:"")),l&&process.stderr.write(`session: ${l.session_id} \u2014 share this id with support
17
+ `),r&&I()?process.stderr.write(`${r}
18
+ `):process.stderr.write(`(re-run with KANE_DEV_MODE=1 for the full stack)
19
+ `)),process.exit(e);return}if(A&&!n){A();return}process.exit(e)}function Ee(e){A=e}function ge(e){x=e}var T=!1;function me(){T||(T=!0,process.on("SIGINT",()=>{m(130,"Received SIGINT",!0)}),process.on("SIGTERM",()=>{m(143,"Received SIGTERM",!0)}),process.on("uncaughtException",e=>{m(1,`Uncaught exception: ${e.name}: ${e.message}`,!0,e.stack)}),process.on("unhandledRejection",e=>{m(1,`Unhandled rejection: ${String(e)}`,!0,e instanceof Error?e.stack:void 0)}))}function Re(){c=[],R=!1,N=null,A=null,x=null,d=null,E=[],T=!1,l=null}export{h as a,q as b,z as c,w as d,M as e,re as f,_e as g,ce as h,ae as i,de as j,le as k,ue as l,fe as m,pe as n,Se as o,m as p,Ee as q,ge as r,me as s,Re as t};
@@ -0,0 +1,7 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as O}from"./chunk-TDPWFYTJ.js";import{a as b}from"./chunk-3AZTXJY4.js";import{a as N}from"./chunk-KHJXOFDM.js";import{e as A,j as w}from"./chunk-MMPFU2YC.js";import{spawn as U,execSync as B}from"child_process";import{appendFileSync as L,existsSync as E,mkdirSync as K}from"fs";import{homedir as G}from"os";import{join as D,resolve as t,dirname as C}from"path";import{fileURLToPath as W}from"url";import{createInterface as P}from"readline";async function*T(e){let n=P({input:e,crlfDelay:1/0});for await(let l of n){let r=l.trim();if(r)try{let a=JSON.parse(r);a&&typeof a.type=="string"&&(yield a)}catch{}}}function h(e){return e==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_BIFURCATION_PHASES:"1"},unset:["V16_NETWORK_WS","V16_NETWORK_SSE"]}:{set:{V16_BIFURCATION_PHASES:"1"},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_NETWORK_WS","V16_NETWORK_SSE"]}}function M(e){return e?{set:{},unset:["V16_AGENT_SKIP_CP_FINAL"]}:{set:{V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}}function I(e){return e==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var o=C(W(import.meta.url));function j(){for(let e of["python3","python"])try{return B(`${e} --version`,{stdio:"ignore"}),e}catch{}return null}function $(){let n=process.platform==="win32"?"v16-runner.exe":"v16-runner",l={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"linux-arm64":["@testmuai/kane-cli-linux-arm64","@lambdatestincprivate/kane-cli-linux-arm64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},r=`${process.platform}-${process.arch}`,a=l[r];if(a)for(let s of a){let m=[t(o,"..","node_modules",s,"bin",n),t(o,"..","..","node_modules",s,"bin",n),t(o,"..","..","..","node_modules",s,"bin",n),t(o,"..","..","..","..","node_modules",s,"bin",n)];for(let u of m)if(E(u))return{cmd:u,args:[]}}let _=[t(o,"bin",n),t(o,"..","bin",n),t(o,"..","..","..","..","v16-runner","dist",n),t(o,"..","..","..","v16-runner","dist",n),t(o,"..","..","v16-runner","dist",n),t(process.cwd(),"v16-runner","dist",n),t(process.cwd(),"..","v16-runner","dist",n)];for(let s of _)if(E(s))return{cmd:s,args:[]};let v=[t(o,"..","..","v16-runner"),t(o,"..","..","..","..","v16-runner"),t(o,"..","..","..","v16-runner"),t(process.cwd(),"v16-runner"),t(process.cwd(),"..","v16-runner")];for(let s of v)if(E(t(s,"main.py"))){for(let u of[t(s,".venv","bin","python"),t(s,"..",".venv","bin","python"),t(s,"..","browser-agent",".venv","bin","python")])if(E(u))return{cmd:u,args:["main.py"],cwd:s};let m=j();if(m)return{cmd:m,args:["main.py"],cwd:s}}return null}function ie(e,n){let l=$();if(!l)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");process.env.KANE_SPAWN_DEBUG&&process.stderr.write(`[spawn-debug] ${JSON.stringify(l)}
3
+ `);let r={...process.env};n?.environment&&(r.TESTMUAI_ENV=n.environment),r.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(r.PYTHONIOENCODING="utf-8");let a=N(n?.environment);r.V16_SERVER_API_HOST=a.v16ServerHost,r.ATMS_URL=a.tmsBaseUrl.replace(/\/api\/?$/,""),e.username&&e.access_key&&(r.LT_USERNAME=e.username,r.LT_ACCESS_KEY=e.access_key),e.session_id&&(r.TESTMUAI_SESSION_ID=e.session_id);let _=h(n?.mode??"testing");Object.assign(r,_.set);for(let i of _.unset)delete r[i];let v=new b().load(),s=I(n?.assertionMode??(v.assertion_mode==="visual"?"visual":"dom"));Object.assign(r,s.set);for(let i of s.unset)delete r[i];let m=n?.finalValidation??v.final_validation,u=M(m);Object.assign(r,u.set);for(let i of u.unset)delete r[i];let g=O();g!==void 0&&e.ap_mode===void 0&&(e.ap_mode=g),e.telemetry_proxy_url===void 0&&process.env.KANE_TELEMETRY!=="0"&&(e.telemetry_proxy_url=w),e.media_upload===void 0&&e.org_id&&e.username&&e.access_key&&(e.media_upload={url:a.shareApiBaseUrl.replace(/\/$/,"")+"/mfs/v1.0/media/upload",artefacts_host:a.mediaArtefactsHost,org_id:e.org_id,media_dir:A});let d=U(l.cmd,l.args,{stdio:["pipe","pipe","pipe"],env:r,cwd:l.cwd});d.stdin.on("error",()=>{}),d.stdin.write(JSON.stringify(e)+`
4
+ `);let p=e.session_id?D(G(),".testmuai","kaneai","sessions",e.session_id,"runner-stderr.log"):null;if(p)try{K(C(p),{recursive:!0}),L(p,`--- runner spawn ${new Date().toISOString()} run_index=${e.run_index} ---
5
+ `)}catch{}let S=1e5,f="";d.stderr.on("data",i=>{if(f+=i.toString(),f.length>S&&(f=f.slice(-S)),p)try{L(p,i)}catch{}}),d.on("error",i=>{n?.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:i.message})});let R=null,y=null,k=new Promise(i=>{d.on("close",(c,x)=>{R=c,y=x?String(x):null,n?.log?.("info","RUNNER_EXIT","Runner exited",{code:c,signal:y??"none"}),i({code:c,signal:y})})}),V=T(d.stdout);return{child:d,events:V,sendUserResponse(i){let c=JSON.stringify({type:"user_response",answer:i});try{d.stdin.write(c+`
6
+ `)}catch{}},sendCancel(i){let c=JSON.stringify({type:"cancel",reason:i});try{d.stdin.write(c+`
7
+ `)}catch{}},cancel(){d.kill("SIGTERM")},get stderr(){return f},get exitCode(){return R},get exitSignal(){return y},exited:k}}export{$ as a,ie as b};
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as B,d as F}from"./chunk-V3UE6RJP.js";import{b as M}from"./chunk-DNNZ353O.js";import{a as k}from"./chunk-Q2F5QB2W.js";import{b as w,c as p}from"./chunk-NVGBE2DR.js";import{a as A}from"./chunk-7E24OCGX.js";import{a as N,c as L}from"./chunk-6HYW5RFX.js";import{e as R}from"./chunk-J2KSZUOO.js";import{a as O,d as C,f as $}from"./chunk-5YPBPZUR.js";import{existsSync as V,mkdirSync as H,readFileSync as K,writeFileSync as Z}from"fs";import{basename as X,extname as U,join as Y}from"path";var T=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function z(e){return typeof e=="string"&&e!=="."&&e!==".."&&T.test(e)}function S(e){if(!z(e))throw new Error(`unsafe logical_id: ${JSON.stringify(e)} \u2014 must match ${String(T)} (no path separators)`)}function q(e,r,t){return k({source_id:e,source_cid:"sha256:".padEnd(71,"0"),doc_kind:r,numbered_text:M(t)})}var P=2e3;function Q(e){let t=X(e,U(e)).toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"");return S(t),t}function me(e){let r=/^(.*?)[-_.]?v?\d+$/.exec(e);if(!r)return null;let t=(r[1]??"").replace(/[-_.]+$/,"");return t.length>0&&t!==e?t:null}function j(e){let r=Y(e,"meta.json");V(r)||(H(e,{recursive:!0}),Z(r,JSON.stringify({schema:O,canonicalizer:"v1"},null,2)+`
3
+ `))}async function fe(e){let{contextDir:r,filePath:t,asId:o,confirmSameSource:f,converters:b}=e;j(r);let n=K(t),s=F(t);if(!s.ok)throw new Error(`UNSUPPORTED_MEDIA: ${U(t)} \u2014 supported: ${s.allowlist.join(" ")}`);if(n.byteLength>s.media.maxBytes)throw new Error(`FILE_TOO_LARGE: ${n.byteLength} bytes > ${s.media.maxBytes} cap for ${s.media.media_type}`);if(s.media.sniff&&!s.media.sniff(n)){let c=s.media.sniffFail?.(n);throw new Error(c??`MEDIA_SNIFF_MISMATCH: ${t} does not look like ${s.media.media_type}`)}let d;return o!==void 0?(S(o),d=o):d=Q(t),W({contextDir:r,bytes:n,media:s.media,sourceId:d,label:t,confirmSameSource:f,converters:b})}async function W(e){let{contextDir:r,bytes:t,media:o,confirmSameSource:f,converters:b}=e,n=e.sourceId,s=e.label??n;if(j(r),t.byteLength>o.maxBytes)throw new Error(`FILE_TOO_LARGE: ${t.byteLength} bytes > ${o.maxBytes} cap for ${o.media_type}`);let d=[],c=B[o.kind];if(o.cite==="verbatim"&&!c){try{new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{throw new Error(`ENCODING_UNSUPPORTED: ${s} is not valid UTF-8 \u2014 re-save it as UTF-8 and re-ingest`)}t.toString("utf8").split(`
4
+ `).some(a=>a.length>P)&&d.push(`long line detected (> ${P} chars) \u2014 anchors lose granularity; consider pretty-printing before ingest`)}let l=w(t),g=A(r),u=g.heads.get(n),G=u!=null?g.getNode(u)?.content:void 0;if(u!=null&&G?.blob===l)return{status:"unchanged",source_id:n,cid:u,blob:l};if(u==null){for(let[a,i]of g.heads.entries())if(!(a===n||i==null)&&g.getNode(i)?.content.blob===l){if(f&&await f(a))return{status:"unchanged",source_id:a,cid:i,blob:l};break}}let I={},y,m=null,h=null;if(c){let a=b?.[c];if(!a)throw new Error(`${c.toUpperCase()}_CONVERTER_MISSING: ${c} ingestion requires the converter \u2014 the command layer wires it`);let i=await a(t);m=Buffer.from(i.projection,"utf8");let x=q(n,o.kind,m);if(x>4e5)throw new Error(`PROJECTION_TOO_LARGE: serialized source payload ${x} bytes > ${4e5} \u2014 split the document and re-ingest`);I={text_blob:w(m),...i.inventory.length>0?{images:i.inventory}:{},converter:i.converter},h=i.blobs,y={kind:o.kind,...i.pages!==void 0?{pages:i.pages}:{},delivered:i.delivered.length,omitted:i.inventory.length-i.delivered.length}}if(p(r,t),m!==null&&p(r,m),h!==null)for(let[,a]of h)p(r,a);let _=L(n,l),v=$("source",_);if(v.length>0)throw new Error(`source node fails ${v[0].code}: ${v[0].detail}`);let E=N("source",_);return R(r,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:E,label:C.SOURCE,content:_}],edges:[],review:[],supersessions:[],media:{[n]:{format:o.kind,media_type:o.media_type,anchors_supported:c?["L-L","img#ref"]:o.cite==="verbatim"?["L-L"]:[],...I}},source_head_moves:{[n]:E}}),{status:u!=null?"versioned":"created",source_id:n,cid:E,blob:l,...d.length?{warnings:d}:{},...y?{composite:y}:{}}}export{S as a,q as b,Q as c,me as d,fe as e,W as f};
@@ -1,17 +1,17 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as m}from"./chunk-L5LI2JF4.js";import{c as p}from"./chunk-VCYVSKPM.js";import{randomUUID as E}from"crypto";import{mkdirSync as F,writeFileSync as f,appendFileSync as O,existsSync as v}from"fs";import{join as u}from"path";import{writeFileSync as w,mkdirSync as x,existsSync as I}from"fs";import{join as h,relative as j}from"path";function _(n){let t=Object.keys(n.frontmatter).length>0?m(n.frontmatter).trimEnd():"",s=["---"];return t&&s.push(t),s.push("---",""),s.push(`# ${n.heading}`,""),n.steps.forEach((i,r)=>{s.push(`## Step ${r+1}`,i,"")}),s.join(`
3
- `)}function C(n,e){let t={},s={},i=e;for(let[r,l]of Object.entries(n)){if(r.startsWith("global.")||r.startsWith("secrets.user.")||r.startsWith("environment.")){let o=r.startsWith("secrets.user.");t[r]={value:l.value,secret:o,syntax:`{{${r}}}`,type:o?"secret":r.startsWith("environment.")?"environment":"global"},s[r]=r;continue}if(l.secret){let o=`secrets.user.${r}`;t[o]={value:l.value,secret:!0,syntax:`{{secrets.user.${r}}}`,type:"secret"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{secrets.user.${r}}}`)}else{let o=`global.${r}`;t[o]={value:l.value,secret:!1,syntax:`{{global.${r}}}`,type:"global"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{global.${r}}}`)}}return{variables:t,objective:i,keyMap:s}}var y=/\{\{\s*(?:global|secrets\.user|environment)\.([^{}]+?)\s*\}\}/g;function c(n){return typeof n!="string"||!n.includes("{{")?n:n.replace(y,"{{$1}}")}function d(n){if(typeof n=="string")return c(n);if(Array.isArray(n))return n.map(e=>d(e));if(n&&typeof n=="object"){let e={};for(let[t,s]of Object.entries(n))e[t]=d(s);return e}return n}var L=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),N=new Set(["model","env"]),g=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=h(this.opts.cwd,".testmuai","tests");try{x(t,{recursive:!0})}catch(a){process.stderr.write(`
4
- \u26A0 Failed to create ${j(this.opts.cwd,t)}/
2
+ import{a as _}from"./chunk-TDPWFYTJ.js";import{b as m}from"./chunk-L5LI2JF4.js";import{c as h}from"./chunk-MMPFU2YC.js";import{randomUUID as F}from"crypto";import{mkdirSync as A,writeFileSync as v,appendFileSync as O,existsSync as b}from"fs";import{join as u}from"path";import{writeFileSync as x,mkdirSync as I,existsSync as j}from"fs";import{join as p,relative as L}from"path";function f(n){let t=Object.keys(n.frontmatter).length>0?m(n.frontmatter).trimEnd():"",s=["---"];return t&&s.push(t),s.push("---",""),s.push(`# ${n.heading}`,""),n.steps.forEach((i,r)=>{s.push(`## Step ${r+1}`,i,"")}),s.join(`
3
+ `)}function T(n,e){let t={},s={},i=e;for(let[r,l]of Object.entries(n)){if(r.startsWith("global.")||r.startsWith("secrets.user.")||r.startsWith("environment.")){let o=r.startsWith("secrets.user.");t[r]={value:l.value,secret:o,syntax:`{{${r}}}`,type:o?"secret":r.startsWith("environment.")?"environment":"global"},s[r]=r;continue}if(l.secret){let o=`secrets.user.${r}`;t[o]={value:l.value,secret:!0,syntax:`{{secrets.user.${r}}}`,type:"secret"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{secrets.user.${r}}}`)}else{let o=`global.${r}`;t[o]={value:l.value,secret:!1,syntax:`{{global.${r}}}`,type:"global"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{global.${r}}}`)}}return{variables:t,objective:i,keyMap:s}}var w=/\{\{\s*(?:global|secrets\.user|environment)\.([^{}]+?)\s*\}\}/g;function c(n){return typeof n!="string"||!n.includes("{{")?n:n.replace(w,"{{$1}}")}function d(n){if(typeof n=="string")return c(n);if(Array.isArray(n))return n.map(e=>d(e));if(n&&typeof n=="object"){let e={};for(let[t,s]of Object.entries(n))e[t]=d(s);return e}return n}var N=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),$=new Set(["model","env"]),g=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=p(this.opts.cwd,".testmuai","tests");try{I(t,{recursive:!0})}catch(a){process.stderr.write(`
4
+ \u26A0 Failed to create ${L(this.opts.cwd,t)}/
5
5
  ${a.message}
6
6
  Your test recording was NOT saved.
7
7
 
8
- `);return}let s=h(t,`${e}_test.md`),i=2,r=!1;for(;I(s);)s=h(t,`${e}-${i}_test.md`),i++,r=!0;let l=d($(this.opts.getResolvedGlobal())),o=_({frontmatter:l,heading:`Session: ${e}`,steps:this.objectives.map(c)});try{w(s,o,"utf8")}catch(a){process.stderr.write(`
8
+ `);return}let s=p(t,`${e}_test.md`),i=2,r=!1;for(;j(s);)s=p(t,`${e}-${i}_test.md`),i++,r=!0;let l=d(E(this.opts.getResolvedGlobal())),o=f({frontmatter:l,heading:`Session: ${e}`,steps:this.objectives.map(c)});try{x(s,o,"utf8")}catch(a){process.stderr.write(`
9
9
  \u26A0 Failed to save your test recording.
10
10
  ${a.message}
11
11
  Path: ${s}
12
12
 
13
- `);return}this.lastWrittenPath=s,this.lastCollisionSuffixed=r}};function $(n){let e={};for(let[t,s]of Object.entries(n))L.has(t)||N.has(t)||(e[t]=s);return e}var A=u(p,"sessions"),b=class{sessionId;sessionDir;runs=[];_flows=[];_nextIndex=0;_started=!1;_testId=null;_testcaseId=null;_projectId=null;_orgId=null;_userName=null;_userEmail=null;_uploadStatus="pending";_uploadAttempts=0;_uploadError=null;_firstObjective=null;_firstUrl=null;_auteurVariables={};_screenshotSas=null;_model="";_environment="";_profile=null;_plan=null;_startedAt="";_remoteLogger=null;_earlyLogBuffer=[];_recorder=null;_resolvedGlobal={};_sessionName=null;_recordingEnabled=!0;_stepRunRecords=[];constructor(e){this.sessionId=E();let t=e?.baseDir?u(e.baseDir,"sessions"):A;this.sessionDir=u(t,this.sessionId)}setResolvedGlobal(e){this._resolvedGlobal={...this._resolvedGlobal,...e}}setSessionName(e){this._sessionName=e}get sessionName(){return this._sessionName}setRecordingEnabled(e){this._recordingEnabled=e}get recorder(){return this._recorder}flushRecorder(){try{this._recorder?.flush()}catch(e){process.stderr.write(`[recorder] flush failed: ${e.message}
14
- `)}}start(e){if(!this._started){this._started=!0,this._model=e.model,this._environment=e.environment,this._profile=e.profile,this._startedAt=new Date().toISOString();try{F(this.sessionDir,{recursive:!0}),this._recorder=new g({cwd:process.cwd(),getResolvedGlobal:()=>this._resolvedGlobal,getName:()=>this._sessionName});let t={session_id:this.sessionId,started_at:this._startedAt,model:e.model,environment:e.environment,profile:e.profile,plan:this._plan,objectives:[],runs:[],status:"in_progress"};f(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
15
- `)}catch{}this._log(`SESSION START session_id=${this.sessionId}`),this._log(`CONFIG model=${e.model} env=${e.environment} profile=${e.profile}`),this._earlyLogBuffer.push({level:"info",event:"SESSION_START",message:"Session started",context:{session_id:this.sessionId}},{level:"info",event:"CONFIG",message:"Session config",context:{model:e.model,environment:e.environment,profile:e.profile}})}}setPlan(e){this._plan=e;let t={level:"info",event:"SESSION_INFO",message:"Session info",context:{session_id:this.sessionId,plan:e??null}};this._remoteLogger?this._remoteLogger.log(t.level,t.event,t.message,t.context):this._earlyLogBuffer.push(t)}get plan(){return this._plan}setRemoteLogger(e){this._remoteLogger=e;for(let t of this._earlyLogBuffer)e.log(t.level,t.event,t.message,t.context);this._earlyLogBuffer=[]}get hasRemoteLogger(){return this._remoteLogger!==null}setAuteurVariables(e){Object.assign(this._auteurVariables,e)}get auteurVariables(){return this._auteurVariables}setScreenshotSas(e){this._screenshotSas=e}get screenshotSas(){return this._screenshotSas}get screenshotBaseUrl(){return this._screenshotSas?`${this._screenshotSas.base_url}/${this._screenshotSas.container}`:""}get startedAt(){return this._startedAt||new Date().toISOString()}log(e,t,s,i){if(t===void 0){this._log(e);let o=e.indexOf(" "),a=o>0?e.slice(0,o):e,R=o>0?e.slice(o+1):"",S=/fail|error/i.test(e)?"error":"info";this._remoteLogger?.log(S,a,R||e);return}let r=e,l=s;this._log(`${t} ${l}`,i),this._remoteLogger?.log(r,t,l,i)}logStep(e,t,s){this._log(`${e} ${t}`,s);let i=this._nextIndex>0?this._nextIndex-1:0;this._remoteLogger?.logStep(i,e,t,s)}logCommand(e){this._log(`COMMAND ${e}`)}logRunStart(e,t,s){this._log(`RUN ${e} START objective="${t.slice(0,100)}" url=${s}`),this._remoteLogger?.setRunIndex(e),this._remoteLogger?.log("info","RUN_START",`Run ${e} started`,{run_index:e,objective:t,url:s})}logRunEnd(e,t,s,i,r){let l=(s??0).toFixed(1),o=(i??"").slice(0,100),a=r==null||r===""||Number.isNaN(Number(r))?null:Number(r);this._log(`RUN ${e} END status=${t} duration=${l}s summary="${o}"`,a!=null?{result_code:a}:void 0),this._remoteLogger?.log("info","RUN_END",`Run ${e} ended`,{run_index:e,status:t,duration:s??0,summary:i??"",result_code:a}),t!=="failed"&&t!=="error"&&this._remoteLogger?.discardSteps(e)}escalateRun(e){this._remoteLogger?.escalate(e)}logChromeLaunch(e,t){this._log(`CHROME LAUNCH port=${e} endpoint=${t}`),this._remoteLogger?.log("info","CHROME_LAUNCH","Chrome launched",{port:e,cdp_endpoint:t})}async finish(e="complete"){this._log(`SESSION END status=${e} total_runs=${this.runs.length}`),this._remoteLogger?.log("info","SESSION_END","Session ended",{status:e,total_runs:this.runs.length}),await this._remoteLogger?.shutdown();let t={session_id:this.sessionId,started_at:this._startedAt,ended_at:new Date().toISOString(),model:this._model,environment:this._environment,profile:this._profile,plan:this._plan,status:e,total_runs:this.runs.length,test_id:this._testId,testcase_id:this._testcaseId,commit_id:this.sessionId,project_id:this._projectId,upload_status:this._uploadStatus,upload_attempts:this._uploadAttempts,last_upload_attempt:this._uploadAttempts>0?new Date().toISOString():null,upload_error:this._uploadError,runs:this.runs.map(s=>({index:s.index,objective:s.objective,status:s.status,summary:s.summary,run_dir:s.run_dir}))};v(this.sessionDir)&&f(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
16
- `),this.flushRecorder(),this._recorder=null}nextRunIndex(){return this._nextIndex}addRunResult(e,t){this.runs.push(e),this._nextIndex+=t??1,this._recordingEnabled&&this._recorder?.appendObjective(e.objective)}getContext(){return{prior_runs:this.runs.map(e=>({index:e.index,objective:e.objective,summary:e.summary,status:e.status,memory:e.context.memory,variables:e.context.variables,pointer:e.context.pointer}))}}addFlow(e){let t={...e,index:this._flows.length+1};return this._flows.push(t),t}getFlows(){return[...this._flows]}getFlow(e){return this._flows.find(t=>t.index===e)}clearFlows(){this._flows=[]}recordStepRun(e){this._stepRunRecords.push(e)}getStepRunRecords(){return[...this._stepRunRecords]}getRunsAsStepRecords(){return this.runs.map((e,t)=>({testmdStepIndex:t+1,runIndex:e.index,totalRunDirs:e.run_dirs?.length??1}))}snapshot(){return{runsLen:this.runs.length,nextRunIndex:this._nextIndex,stepRunRecordsLen:this._stepRunRecords.length}}rollback(e){this.runs.length=e.runsLen,this._nextIndex=e.nextRunIndex,this._stepRunRecords.length=e.stepRunRecordsLen}setTestId(e){this._testId=e}get testId(){return this._testId}setTestcaseId(e){this._testcaseId=e}get testcaseId(){return this._testcaseId}setProjectId(e){this._projectId=e}setOrgId(e){this._orgId=e}get orgId(){return this._orgId}setUserIdentity(e,t){e&&(this._userName=e),t&&(this._userEmail=t)}get userName(){return this._userName}get userEmail(){return this._userEmail}setFirstRun(e,t){this._firstObjective||(this._firstObjective=e,this._firstUrl=t)}get firstObjective(){return this._firstObjective}get firstUrl(){return this._firstUrl}getRunDirs(){let e=[];for(let t of this.runs)t.run_dirs&&t.run_dirs.length>0?e.push(...t.run_dirs):t.run_dir&&e.push(t.run_dir);return e}getRunObjectives(){let e=[];for(let t of this.runs)t.flow_objectives&&t.flow_objectives.length>0?e.push(...t.flow_objectives):e.push(t.objective);return e}getRunMetadata(){let e=[];for(let t of this.runs)if(t.perFlowMetadata&&t.perFlowMetadata.length>0)e.push(...t.perFlowMetadata);else{let s={resultCode:t.resultCode,reasonCode:t.reasonCode,errorMessage:t.status==="failed"?t.summary??null:null,summary:t.summary,oneLiner:t.oneLiner},i=t.run_dirs?.length??1;for(let r=0;r<i;r++)e.push(s)}return e}setUploadStatus(e,t){this._uploadStatus=e,this._uploadAttempts+=1,this._uploadError=t??null}_log(e,t){if(!(!this._started||!v(this.sessionDir)))try{let s=new Date().toISOString().slice(0,19).replace("T"," "),i=u(this.sessionDir,"tui.log"),r=t&&Object.keys(t).length>0?` ${JSON.stringify(t)}`:"";O(i,`[${s}] ${e}${r}
17
- `)}catch{}}};export{_ as a,C as b,b as c};
13
+ `);return}this.lastWrittenPath=s,this.lastCollisionSuffixed=r}};function E(n){let e={};for(let[t,s]of Object.entries(n))N.has(t)||$.has(t)||(e[t]=s);return e}var D=u(h,"sessions"),R=class{sessionId;sessionDir;runs=[];_flows=[];_nextIndex=0;_started=!1;_testId=null;_testcaseId=null;_projectId=null;_orgId=null;_userName=null;_userEmail=null;_uploadStatus="pending";_uploadAttempts=0;_uploadError=null;_firstObjective=null;_firstUrl=null;_auteurVariables={};_screenshotSas=null;_model="";_environment="";_profile=null;_plan=null;_startedAt="";_remoteLogger=null;_earlyLogBuffer=[];_recorder=null;_resolvedGlobal={};_sessionName=null;_recordingEnabled=!0;_stepRunRecords=[];constructor(e){this.sessionId=F();let t=e?.baseDir?u(e.baseDir,"sessions"):D;this.sessionDir=u(t,this.sessionId)}setResolvedGlobal(e){this._resolvedGlobal={...this._resolvedGlobal,...e}}setSessionName(e){this._sessionName=e}get sessionName(){return this._sessionName}setRecordingEnabled(e){this._recordingEnabled=e}get recorder(){return this._recorder}flushRecorder(){try{this._recorder?.flush()}catch(e){process.stderr.write(`[recorder] flush failed: ${e.message}
14
+ `)}}start(e){if(!this._started){this._started=!0,this._model=e.model,this._environment=e.environment,this._profile=e.profile,this._startedAt=new Date().toISOString();try{A(this.sessionDir,{recursive:!0}),this._recorder=new g({cwd:process.cwd(),getResolvedGlobal:()=>this._resolvedGlobal,getName:()=>this._sessionName});let t={session_id:this.sessionId,started_at:this._startedAt,model:e.model,environment:e.environment,profile:e.profile,plan:this._plan,objectives:[],runs:[],status:"in_progress"};v(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
15
+ `)}catch{}this._log(`SESSION START session_id=${this.sessionId}`),this._log(`CONFIG model=${e.model} env=${e.environment} profile=${e.profile}`),this._earlyLogBuffer.push({level:"info",event:"SESSION_START",message:"Session started",context:{session_id:this.sessionId}},{level:"info",event:"CONFIG",message:"Session config",context:{model:e.model,environment:e.environment,profile:e.profile}})}}setPlan(e){this._plan=e;let t={level:"info",event:"SESSION_INFO",message:"Session info",context:{session_id:this.sessionId,plan:e??null}};this._remoteLogger?this._remoteLogger.log(t.level,t.event,t.message,t.context):this._earlyLogBuffer.push(t)}get plan(){return this._plan}get apMode(){return _()}setRemoteLogger(e){this._remoteLogger=e;for(let t of this._earlyLogBuffer)e.log(t.level,t.event,t.message,t.context);this._earlyLogBuffer=[]}get hasRemoteLogger(){return this._remoteLogger!==null}setAuteurVariables(e){Object.assign(this._auteurVariables,e)}get auteurVariables(){return this._auteurVariables}setScreenshotSas(e){this._screenshotSas=e}get screenshotSas(){return this._screenshotSas}get screenshotBaseUrl(){return this._screenshotSas?`${this._screenshotSas.base_url}/${this._screenshotSas.container}`:""}get startedAt(){return this._startedAt||new Date().toISOString()}log(e,t,s,i){if(t===void 0){this._log(e);let o=e.indexOf(" "),a=o>0?e.slice(0,o):e,S=o>0?e.slice(o+1):"",y=/fail|error/i.test(e)?"error":"info";this._remoteLogger?.log(y,a,S||e);return}let r=e,l=s;this._log(`${t} ${l}`,i),this._remoteLogger?.log(r,t,l,i)}logStep(e,t,s){this._log(`${e} ${t}`,s);let i=this._nextIndex>0?this._nextIndex-1:0;this._remoteLogger?.logStep(i,e,t,s)}logCommand(e){this._log(`COMMAND ${e}`)}logRunStart(e,t,s){this._log(`RUN ${e} START objective="${t.slice(0,100)}" url=${s}`),this._remoteLogger?.setRunIndex(e),this._remoteLogger?.log("info","RUN_START",`Run ${e} started`,{run_index:e,objective:t,url:s})}logRunEnd(e,t,s,i,r){let l=(s??0).toFixed(1),o=(i??"").slice(0,100),a=r==null||r===""||Number.isNaN(Number(r))?null:Number(r);this._log(`RUN ${e} END status=${t} duration=${l}s summary="${o}"`,a!=null?{result_code:a}:void 0),this._remoteLogger?.log("info","RUN_END",`Run ${e} ended`,{run_index:e,status:t,duration:s??0,summary:i??"",result_code:a}),t!=="failed"&&t!=="error"&&this._remoteLogger?.discardSteps(e)}escalateRun(e){this._remoteLogger?.escalate(e)}logChromeLaunch(e,t){this._log(`CHROME LAUNCH port=${e} endpoint=${t}`),this._remoteLogger?.log("info","CHROME_LAUNCH","Chrome launched",{port:e,cdp_endpoint:t})}async finish(e="complete"){this._log(`SESSION END status=${e} total_runs=${this.runs.length}`),this._remoteLogger?.log("info","SESSION_END","Session ended",{status:e,total_runs:this.runs.length}),await this._remoteLogger?.shutdown();let t={session_id:this.sessionId,started_at:this._startedAt,ended_at:new Date().toISOString(),model:this._model,environment:this._environment,profile:this._profile,plan:this._plan,status:e,total_runs:this.runs.length,test_id:this._testId,testcase_id:this._testcaseId,commit_id:this.sessionId,project_id:this._projectId,upload_status:this._uploadStatus,upload_attempts:this._uploadAttempts,last_upload_attempt:this._uploadAttempts>0?new Date().toISOString():null,upload_error:this._uploadError,runs:this.runs.map(s=>({index:s.index,objective:s.objective,status:s.status,summary:s.summary,run_dir:s.run_dir}))};b(this.sessionDir)&&v(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
16
+ `),this.flushRecorder(),this._recorder=null}nextRunIndex(){return this._nextIndex}addRunResult(e,t){this.runs.push(e),this._nextIndex+=t??1,this._recordingEnabled&&this._recorder?.appendObjective(e.objective)}getContext(){return{prior_runs:this.runs.map(e=>({index:e.index,objective:e.objective,summary:e.summary,status:e.status,memory:e.context.memory,variables:e.context.variables,pointer:e.context.pointer}))}}addFlow(e){let t={...e,index:this._flows.length+1};return this._flows.push(t),t}getFlows(){return[...this._flows]}getFlow(e){return this._flows.find(t=>t.index===e)}clearFlows(){this._flows=[]}recordStepRun(e){this._stepRunRecords.push(e)}getStepRunRecords(){return[...this._stepRunRecords]}getRunsAsStepRecords(){return this.runs.map((e,t)=>({testmdStepIndex:t+1,runIndex:e.index,totalRunDirs:e.run_dirs?.length??1}))}snapshot(){return{runsLen:this.runs.length,nextRunIndex:this._nextIndex,stepRunRecordsLen:this._stepRunRecords.length}}rollback(e){this.runs.length=e.runsLen,this._nextIndex=e.nextRunIndex,this._stepRunRecords.length=e.stepRunRecordsLen}setTestId(e){this._testId=e}get testId(){return this._testId}setTestcaseId(e){this._testcaseId=e}get testcaseId(){return this._testcaseId}setProjectId(e){this._projectId=e}setOrgId(e){this._orgId=e}get orgId(){return this._orgId}setUserIdentity(e,t){e&&(this._userName=e),t&&(this._userEmail=t)}get userName(){return this._userName}get userEmail(){return this._userEmail}setFirstRun(e,t){this._firstObjective||(this._firstObjective=e,this._firstUrl=t)}get firstObjective(){return this._firstObjective}get firstUrl(){return this._firstUrl}getRunDirs(){let e=[];for(let t of this.runs)t.run_dirs&&t.run_dirs.length>0?e.push(...t.run_dirs):t.run_dir&&e.push(t.run_dir);return e}getRunObjectives(){let e=[];for(let t of this.runs)t.flow_objectives&&t.flow_objectives.length>0?e.push(...t.flow_objectives):e.push(t.objective);return e}getRunMetadata(){let e=[];for(let t of this.runs)if(t.perFlowMetadata&&t.perFlowMetadata.length>0)e.push(...t.perFlowMetadata);else{let s={resultCode:t.resultCode,reasonCode:t.reasonCode,errorMessage:t.status==="failed"?t.summary??null:null,summary:t.summary,oneLiner:t.oneLiner},i=t.run_dirs?.length??1;for(let r=0;r<i;r++)e.push(s)}return e}setUploadStatus(e,t){this._uploadStatus=e,this._uploadAttempts+=1,this._uploadError=t??null}_log(e,t){if(!(!this._started||!b(this.sessionDir)))try{let s=new Date().toISOString().slice(0,19).replace("T"," "),i=u(this.sessionDir,"tui.log"),r=t&&Object.keys(t).length>0?` ${JSON.stringify(t)}`:"";O(i,`[${s}] ${e}${r}
17
+ `)}catch{}}};export{f as a,T as b,R as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-R65HNFRB.js";import{b as D}from"./chunk-4BAL4OGF.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
2
+ import{a as $}from"./chunk-ZNHXIRCM.js";import{b as D}from"./chunk-YSSTGJ7O.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
3
3
 
4
4
  `))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
5
5
  `))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".md",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as l}from"./chunk-EWLLPUP4.js";import{a as p}from"./chunk-RZ4F3BHX.js";import{a as m}from"./chunk-QZJID3OZ.js";import{a as f}from"./chunk-DPOES6G3.js";import{a as c,c as s,i as a,x as u}from"./chunk-VCYVSKPM.js";var v="/public/skills/kane-cli";function C(){try{let n=new f().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await p(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
2
+ import{b as l}from"./chunk-MJBCBQC2.js";import{a as p}from"./chunk-RZ4F3BHX.js";import{a as m}from"./chunk-KHJXOFDM.js";import{a as f}from"./chunk-LHDNJJGE.js";import{a as c,c as s,i as a,x as u}from"./chunk-MMPFU2YC.js";var v="/public/skills/kane-cli";function C(){try{let n=new f().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await p(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-QZJID3OZ.js";import"./chunk-VCYVSKPM.js";import"./chunk-UR6MHSHU.js";export{a as getEnvironment};
2
+ import{a}from"./chunk-KHJXOFDM.js";import"./chunk-MMPFU2YC.js";import"./chunk-UR6MHSHU.js";export{a as getEnvironment};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as d,b as w,d as x}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{e as b,f as k}from"./chunk-CJJXT5DO.js";import{d as $}from"./chunk-QM4S2APK.js";import"./chunk-BC7UVJJB.js";import{e as v}from"./chunk-EHN5HTUD.js";import{a as h}from"./chunk-L5LI2JF4.js";import{a as y}from"./chunk-LEA6IHXC.js";import"./chunk-RGDQMKNJ.js";import"./chunk-L3HG5ONB.js";import"./chunk-L4JIMNKW.js";import"./chunk-MBXWXBDM.js";import"./chunk-IAHKTEET.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{basename as f}from"path";import{statSync as R}from"fs";function S(s,e){if(!s)return 1;let r=s.resolve(e);return!r||r.superseded?1:s.getNode(r.tip)?.content.risk==="high"?3:1}function C(s,e){return s.usecases.map(r=>{let n=r.acceptance_criteria??[],a=n.filter(o=>(o.covered_by??[]).length>0),u=n.filter(o=>o.execution==="passed"),c=n.filter(o=>o.execution==="failed"),p=n.filter(o=>o.execution==="blocked"),i=0,l=0;for(let o of n){let g=S(e,o.id);i+=g,o.execution==="passed"&&(l+=g)}let t=i===0?0:Math.round(100*l/i),m=a.length===0?"uncovered":n.length===u.length?"covered":p.length>0&&c.length===0?"blocked":"partial";return{id:r.id,title:r.title,status:m,pct:t,acs:{total:n.length,covered:a.length,passed:u.length,failed:c.length,blocked:p.length},stale:n.filter(o=>o.fresh==="stale").map(o=>o.id)}})}async function A(s){let e=await b(s);return e.length===0?null:e.map(r=>({p:r,m:R(r).mtimeMs})).sort((r,n)=>n.m-r.m)[0].p}var D={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function G(s){let e=Math.round(s/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function E(s,e=x(),r=process.cwd()){let n=w(r,e);if(!n)return 2;let a=s.from?await k(s.from,r):await A(r);if(!a)return d(e,s.from?`no evidence pack at '${s.from}'`:"no evidence pack in .testmuai/evidence \u2014 run a test first, or pass --from <pack>"),2;let u=await v(a,"coverage/usecases.yaml");if(u==null)return d(e,`${f(a)} carries no coverage/usecases.yaml \u2014 the pack predates coverage or its project had no .context at seal time`),2;let c=h(u);if(!c||!Array.isArray(c.usecases))return d(e,`${f(a)}: coverage/usecases.yaml is not a usecases document`),2;let p=y(n),i=C(c,p),l=await $(p,"design");if(s.json)return e.out(JSON.stringify({pack:a,depth:i,completeness:l},null,2)),0;e.out(`coverage \u2014 ${f(a)}`),e.out(""),e.out("depth (proven by the pack):");for(let t of i){let m=t.stale.length?` \xB7 ${t.stale.length} stale`:"";e.out(` ${D[t.status]} ${G(t.pct)} ${String(t.pct).padStart(3)}% ${t.id} \u2014 ${t.status} (${t.acs.passed}/${t.acs.total} ACs proven${t.acs.failed?`, ${t.acs.failed} failed`:""}${t.acs.blocked?`, ${t.acs.blocked} blocked`:""})${m}`)}e.out(""),e.out("completeness (live graph):"),l.length===0&&e.out(" no design gaps \u2014 every AC verified, every use-case scenarioed");for(let t of l)e.out(` [${t.risk}] ${t.tag} ${t.ref} \u2014 ${t.why}`),e.out(` \u2192 ${t.ready_command}`);return 0}export{E as coverCommand,C as depthRows};
2
+ import{a as d,b as w,d as x}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{e as b,f as k}from"./chunk-CJJXT5DO.js";import{d as $}from"./chunk-QM4S2APK.js";import"./chunk-BC7UVJJB.js";import{e as v}from"./chunk-EHN5HTUD.js";import{a as h}from"./chunk-L5LI2JF4.js";import{a as y}from"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";import{basename as f}from"path";import{statSync as R}from"fs";function S(s,e){if(!s)return 1;let r=s.resolve(e);return!r||r.superseded?1:s.getNode(r.tip)?.content.risk==="high"?3:1}function C(s,e){return s.usecases.map(r=>{let n=r.acceptance_criteria??[],a=n.filter(o=>(o.covered_by??[]).length>0),u=n.filter(o=>o.execution==="passed"),c=n.filter(o=>o.execution==="failed"),p=n.filter(o=>o.execution==="blocked"),i=0,l=0;for(let o of n){let g=S(e,o.id);i+=g,o.execution==="passed"&&(l+=g)}let t=i===0?0:Math.round(100*l/i),m=a.length===0?"uncovered":n.length===u.length?"covered":p.length>0&&c.length===0?"blocked":"partial";return{id:r.id,title:r.title,status:m,pct:t,acs:{total:n.length,covered:a.length,passed:u.length,failed:c.length,blocked:p.length},stale:n.filter(o=>o.fresh==="stale").map(o=>o.id)}})}async function A(s){let e=await b(s);return e.length===0?null:e.map(r=>({p:r,m:R(r).mtimeMs})).sort((r,n)=>n.m-r.m)[0].p}var D={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function G(s){let e=Math.round(s/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function E(s,e=x(),r=process.cwd()){let n=w(r,e);if(!n)return 2;let a=s.from?await k(s.from,r):await A(r);if(!a)return d(e,s.from?`no evidence pack at '${s.from}'`:"no evidence pack in .testmuai/evidence \u2014 run a test first, or pass --from <pack>"),2;let u=await v(a,"coverage/usecases.yaml");if(u==null)return d(e,`${f(a)} carries no coverage/usecases.yaml \u2014 the pack predates coverage or its project had no .context at seal time`),2;let c=h(u);if(!c||!Array.isArray(c.usecases))return d(e,`${f(a)}: coverage/usecases.yaml is not a usecases document`),2;let p=y(n),i=C(c,p),l=await $(p,"design");if(s.json)return e.out(JSON.stringify({pack:a,depth:i,completeness:l},null,2)),0;e.out(`coverage \u2014 ${f(a)}`),e.out(""),e.out("depth (proven by the pack):");for(let t of i){let m=t.stale.length?` \xB7 ${t.stale.length} stale`:"";e.out(` ${D[t.status]} ${G(t.pct)} ${String(t.pct).padStart(3)}% ${t.id} \u2014 ${t.status} (${t.acs.passed}/${t.acs.total} ACs proven${t.acs.failed?`, ${t.acs.failed} failed`:""}${t.acs.blocked?`, ${t.acs.blocked} blocked`:""})${m}`)}e.out(""),e.out("completeness (live graph):"),l.length===0&&e.out(" no design gaps \u2014 every AC verified, every use-case scenarioed");for(let t of l)e.out(` [${t.risk}] ${t.tag} ${t.ref} \u2014 ${t.why}`),e.out(` \u2192 ${t.ready_command}`);return 0}export{E as coverCommand,C as depthRows};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-DPOES6G3.js";import"./chunk-VCYVSKPM.js";import"./chunk-UR6MHSHU.js";export{a as CredentialsManager};
2
+ import{a}from"./chunk-LHDNJJGE.js";import"./chunk-MMPFU2YC.js";import"./chunk-UR6MHSHU.js";export{a as CredentialsManager};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i}from"./chunk-F7WKDMX7.js";import"./chunk-Q2F5QB2W.js";import"./chunk-VOHQA2SP.js";import"./chunk-NVGBE2DR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";export{a as DOCX_CONVERTER_POLICY,b as DOCX_CONVERTER_VERSION,d as DOCX_IMAGE_CAP,c as DOCX_IMAGE_DIMENSION_FLOOR,f as DOCX_IMAGE_MAX_BYTES,g as DOCX_IMAGE_MAX_PIXELS,e as DOCX_VISION_BYTE_BUDGET,i as convertDocx,h as renderTokens};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as u}from"./chunk-TFVMSEIA.js";import"./chunk-L3HG5ONB.js";import"./chunk-L4JIMNKW.js";import"./chunk-MBXWXBDM.js";import"./chunk-IAHKTEET.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";var w=i=>`cite ${i.source_id??"?"} ${i.anchor??""}${i.quote?` \u2014 "${i.quote}"`:""}`;function C(i,_){let l=i.resolve(_);if(!l)return null;let c=l.tip,$=i.nodeLabel.get(c);if(!$)return null;let y=i.getNode(c);if(!y)return null;let s=y.content,f=i.displayNameOf(c)??_,d=[],r=(e,t,n=!1)=>{d.push({text:`${e.padEnd(12)} ${t}`,dim:n})},S=i.trust.get(c)??"derived";r("status",`${S}${i.superseded.has(c)?" \xB7 superseded":""}`,!0);let k=typeof s.risk=="string"?s.risk:null;k&&r("risk",k);for(let[e,t]of[["title",null],["description","description"],["value","value"],["summary","summary"],["statement","statement"],["text","text"],["intent","intent"],["case_type","case type"],["technique_notes","technique"],["kind","kind"],["change_note","change"]]){if(!t)continue;let n=s[e];typeof n=="string"&&n&&r(t,n)}let p=[];{let e=l.cid,t=new Set;for(;!t.has(e);){t.add(e),p.push(e);let n=i.superseded.get(e);if(typeof n!="string")break;e=n}}let g=p.flatMap(e=>i.edgesInto(e)).filter(e=>e.type==="DERIVES"),x=e=>{if(!e.source_cid||!e.anchor)return;let t=/^L(\d+)-L(\d+)$/.exec(e.anchor);if(!t)return;let n=i.getNode(e.source_cid)?.content?.text_blob;if(typeof n!="string")return;let o=n.split(`
2
+ import{a as u}from"./chunk-IQODWB32.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";var w=i=>`cite ${i.source_id??"?"} ${i.anchor??""}${i.quote?` \u2014 "${i.quote}"`:""}`;function C(i,_){let l=i.resolve(_);if(!l)return null;let c=l.tip,$=i.nodeLabel.get(c);if(!$)return null;let y=i.getNode(c);if(!y)return null;let s=y.content,f=i.displayNameOf(c)??_,d=[],r=(e,t,n=!1)=>{d.push({text:`${e.padEnd(12)} ${t}`,dim:n})},S=i.trust.get(c)??"derived";r("status",`${S}${i.superseded.has(c)?" \xB7 superseded":""}`,!0);let k=typeof s.risk=="string"?s.risk:null;k&&r("risk",k);for(let[e,t]of[["title",null],["description","description"],["value","value"],["summary","summary"],["statement","statement"],["text","text"],["intent","intent"],["case_type","case type"],["technique_notes","technique"],["kind","kind"],["change_note","change"]]){if(!t)continue;let n=s[e];typeof n=="string"&&n&&r(t,n)}let p=[];{let e=l.cid,t=new Set;for(;!t.has(e);){t.add(e),p.push(e);let n=i.superseded.get(e);if(typeof n!="string")break;e=n}}let g=p.flatMap(e=>i.edgesInto(e)).filter(e=>e.type==="DERIVES"),x=e=>{if(!e.source_cid||!e.anchor)return;let t=/^L(\d+)-L(\d+)$/.exec(e.anchor);if(!t)return;let n=i.getNode(e.source_cid)?.content?.text_blob;if(typeof n!="string")return;let o=n.split(`
3
3
  `).slice(Number(t[1])-1,Number(t[2])).join(" ").trim();return o?o.length>120?`${o.slice(0,119)}\u2026`:o:void 0},h=new Map;for(let e of g){let t=e.props;t.claim&&h.set(t.claim,{source_id:t.source_id,anchor:t.anchor,quote:x(t)})}let L=Array.isArray(s.criteria)?s.criteria:[];for(let[e,t]of L.entries()){r(e===0?"criteria":"",`${e+1}. ${t}`);let n=h.get(t);n&&d.push({text:` ${w(n)}`,dim:!0})}let b=g.find(e=>!e.props.claim);if(b){let e=b.props;d.push({text:` ${w({...e,quote:x(e)})}`,dim:!0})}let a=s.check;a?.kind&&r("check",`${a.kind}${a.verified_against?` vs ${u(String(a.verified_against))}`:""}`);let m=s.expected_answer;m?.operator&&r("expects",`${m.operator} \xB7 ${String(m.operand??"")}`);let v=new Set,q=!0;for(let e of g){let t=e.props,n=`${t.source_id??"?"}@${t.source_cid??e.src}`;v.has(n)||(v.add(n),r(q?"provenance":"",`${t.source_id??"?"} @ ${String(t.source_cid??e.src).slice(7,15)}`,!0),q=!1)}let D=p.flatMap(e=>i.edgesFrom(e)).filter(e=>e.type==="depends_on");for(let[e,t]of D.entries()){let n=String(i.getNode(i.tipOf(t.dst))?.content?.title??""),o=i.displayNameOf(t.dst);r(e===0?"depends on":"",`${o?u(o):t.dst.slice(0,12)}${n?` ${n}`:""}`)}return{id:u(f),rawId:f,title:String(s.title??s.text??s.statement??f),label:$,lines:d}}export{C as buildDossier};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{$ as fa,A as J,B as K,C as L,D as M,E as N,F as O,G as P,H as Q,L as R,M as S,N as T,O as U,P as V,Q as W,R as X,S as Y,T as Z,U as _,V as $,W as aa,X as ba,Y as ca,Z as da,_ as ea,a,aa as ga,b,ba as ha,c,ca as ia,d,e,f,g,h,i,j,k as t,l as u,m as v,n as w,o as x,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H,z as I}from"./chunk-O4HWPV67.js";import"./chunk-FCMLIK7P.js";import{a as n,b as o,c as p,e as q,f as r,g as s}from"./chunk-CJJXT5DO.js";import"./chunk-QM4S2APK.js";import"./chunk-ZPDM6FO7.js";import"./chunk-BC7UVJJB.js";import"./chunk-NVGBE2DR.js";import{a as k,b as l,c as m}from"./chunk-EHN5HTUD.js";import"./chunk-L5LI2JF4.js";import"./chunk-LEA6IHXC.js";import"./chunk-RGDQMKNJ.js";import"./chunk-L3HG5ONB.js";import"./chunk-L4JIMNKW.js";import"./chunk-MBXWXBDM.js";import"./chunk-IAHKTEET.js";import"./chunk-5YPBPZUR.js";import"./chunk-QZJID3OZ.js";import"./chunk-VCYVSKPM.js";import"./chunk-UR6MHSHU.js";export{P as EvidenceSession,C as appendExecutionPointer,M as assembleExecutionEnv,i as buildEnvironment,j as buildEvidenceRunConfig,g as buildExternalId,z as buildLogsMetaYaml,y as buildResultYaml,t as buildRunYaml,O as createCdpBrowserCapture,u as createRunningPack,v as createRunningPackRoot,H as declareLogsFromDir,J as diagnostics,x as discardPack,ba as ensureAuteurExecution,N as fetchCdpBrowserString,L as finalizeEvidencePack,U as finalizeInlineEvidence,K as finalizeMemberTestLogs,da as flattenAuteurLeafIds,ca as flattenAuteurLeaves,T as inlineEvidenceBlock,q as listPacks,p as newExecutionId,h as normalizeOs,S as noteInlineSpawn,$ as offerEvidenceView,o as packPath,I as packTestLogsDir,V as parseRange,D as readExecutionPointers,ia as readPackLeafIds,ha as readPackLeaves,s as recoverStore,fa as remapReplayActionIds,r as resolvePack,ga as resolveReplayResultSteps,F as rollupTestStatus,aa as runEvidenceMerge,_ as runEvidenceServe,E as runEvidenceValidate,Q as runStartupRecovery,l as sealPack,w as sealPackById,Z as serveHint,d as shortHash,c as slugify,W as startEvidenceLocalServer,R as startInlineEvidence,n as storeDir,m as sweepStore,ea as synthesizeSkippedTail,f as testIdForInline,e as testIdForTestmd,k as validatePack,a as verdictFromResultCode,X as viewerBaseFor,Y as viewerUrlFor,b as worstOf,G as worstResultCode,B as writeLogsMeta,A as writeResult};
2
+ import{$ as fa,A as J,B as K,C as L,D as M,E as N,F as O,G as P,H as Q,L as R,M as S,N as T,O as U,P as V,Q as W,R as X,S as Y,T as Z,U as _,V as $,W as aa,X as ba,Y as ca,Z as da,_ as ea,a,aa as ga,b,ba as ha,c,ca as ia,d,e,f,g,h,i,j,k as t,l as u,m as v,n as w,o as x,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H,z as I}from"./chunk-JXKRO2ZJ.js";import"./chunk-FCMLIK7P.js";import{a as n,b as o,c as p,e as q,f as r,g as s}from"./chunk-CJJXT5DO.js";import"./chunk-QM4S2APK.js";import"./chunk-ZPDM6FO7.js";import"./chunk-BC7UVJJB.js";import"./chunk-NVGBE2DR.js";import{a as k,b as l,c as m}from"./chunk-EHN5HTUD.js";import"./chunk-L5LI2JF4.js";import"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-KHJXOFDM.js";import"./chunk-MMPFU2YC.js";import"./chunk-UR6MHSHU.js";export{P as EvidenceSession,C as appendExecutionPointer,M as assembleExecutionEnv,i as buildEnvironment,j as buildEvidenceRunConfig,g as buildExternalId,z as buildLogsMetaYaml,y as buildResultYaml,t as buildRunYaml,O as createCdpBrowserCapture,u as createRunningPack,v as createRunningPackRoot,H as declareLogsFromDir,J as diagnostics,x as discardPack,ba as ensureAuteurExecution,N as fetchCdpBrowserString,L as finalizeEvidencePack,U as finalizeInlineEvidence,K as finalizeMemberTestLogs,da as flattenAuteurLeafIds,ca as flattenAuteurLeaves,T as inlineEvidenceBlock,q as listPacks,p as newExecutionId,h as normalizeOs,S as noteInlineSpawn,$ as offerEvidenceView,o as packPath,I as packTestLogsDir,V as parseRange,D as readExecutionPointers,ia as readPackLeafIds,ha as readPackLeaves,s as recoverStore,fa as remapReplayActionIds,r as resolvePack,ga as resolveReplayResultSteps,F as rollupTestStatus,aa as runEvidenceMerge,_ as runEvidenceServe,E as runEvidenceValidate,Q as runStartupRecovery,l as sealPack,w as sealPackById,Z as serveHint,d as shortHash,c as slugify,W as startEvidenceLocalServer,R as startInlineEvidence,n as storeDir,m as sweepStore,ea as synthesizeSkippedTail,f as testIdForInline,e as testIdForTestmd,k as validatePack,a as verdictFromResultCode,X as viewerBaseFor,Y as viewerUrlFor,b as worstOf,G as worstResultCode,B as writeLogsMeta,A as writeResult};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e,f,g}from"./chunk-54IB6CXK.js";import"./chunk-GRB66C5S.js";import"./chunk-JFAFKHDX.js";import"./chunk-3C5GMAM4.js";import"./chunk-RN4OSVTG.js";import"./chunk-DNNZ353O.js";import"./chunk-BC7UVJJB.js";import"./chunk-NVGBE2DR.js";import"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";export{b as designStateOf,g as evolveCommand,c as evolveOneUc,f as liveRunDesignForUc,a as resolveParentUc,e as runEvolveCommand,d as staleTargets};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n}from"./chunk-Y5RNCJAN.js";import"./chunk-5EOX4MEY.js";import"./chunk-UR6MHSHU.js";export{n as _reset,i as cleanup,h as deregister,e as getRemoteLogger,b as getSupportContext,m as installHandlers,f as isShuttingDown,d as logOrBufferRemote,g as register,k as setInkExit,c as setRemoteLogger,a as setSupportContext,l as setTerminalRestore,j as shutdown};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-7Z64BL5D.js";import"./chunk-MBXWXBDM.js";import"./chunk-IAHKTEET.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";export{a as explain};
2
+ import{a}from"./chunk-FCHTL74E.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";export{a as explain};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as E}from"./chunk-KHU7C6EE.js";import{a as x}from"./chunk-7Z64BL5D.js";import{a as k}from"./chunk-BC7UVJJB.js";import"./chunk-L5LI2JF4.js";import{a as h}from"./chunk-LEA6IHXC.js";import"./chunk-RGDQMKNJ.js";import"./chunk-L3HG5ONB.js";import"./chunk-L4JIMNKW.js";import"./chunk-MBXWXBDM.js";import"./chunk-IAHKTEET.js";import{d,e as g}from"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";async function _(f,$={}){let m=$.contextDir??k(process.cwd()),e=$.out??(c=>process.stdout.write(c+`
2
+ import{a as x}from"./chunk-FCHTL74E.js";import{b as E}from"./chunk-KHU7C6EE.js";import{a as k}from"./chunk-BC7UVJJB.js";import"./chunk-L5LI2JF4.js";import{a as h}from"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import{d,e as g}from"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";async function _(f,$={}){let m=$.contextDir??k(process.cwd()),e=$.out??(c=>process.stdout.write(c+`
3
3
  `)),o=h(m),u=o.resolve(f);if(!u){let c=[...o.names.keys()].filter(n=>/^(t|sc|ac|gap)-/.test(n)).sort();return e(`no design rationale recorded for ${f} (exists: ${c.slice(0,12).join(", ")||"(no designed items)"})`),1}let a=u.tip,s=o.nodeLabel.get(a),r=o.getNode(a),l=o.nameOf.get(a)??a.slice(0,19);if(s===d.TEST){let c=String(r?.content.definitionId??""),n=c?E(m,c):null;if(!n){let i=null;for(let S of o.edgesFrom(a))if(S.type===g.VERIFIES){for(let p of o.edgesFrom(S.dst))if(p.type===g.SCOPED_TO){i=o.nameOf.get(p.dst)??p.dst.slice(0,19);break}if(i)break}return e(`no design rationale recorded for ${f} (exists: test ${l}, but its sidecar is missing \u2014 re-run: kane-cli design tests${i?` --use-case ${i}`:""} --force)`),1}e(`${l} \u2014 ${String(r?.content.title??"")}`),e(`technique: ${n.technique}`),e(`profile family: ${n.profile_family}`),e(`anchored to: ${n.anchor}`),e(`expected how: ${n.expected_how}`),e(`combinatorial: strength ${n.combinatorial.strength} \u2014 ${n.combinatorial.reason}`),e(`surface: ${n.surface_state} \xB7 deferred bindings: ${n.deferred_bindings}`);let t=r?.content.check;t&&e(`check: ${String(t.kind)} ${String(t.operator)} ${String(t.operand??t.within??"")} \u2014 verified against ${String(t.verified_against)}`);for(let i of o.edgesFrom(a))i.type===g.AUTOMATES&&e(`automates: ${o.nameOf.get(i.dst)??i.dst.slice(0,19)}`),i.type===g.VERIFIES&&e(`verifies: ${o.nameOf.get(i.dst)??i.dst.slice(0,19)}`),i.type===g.REUSES&&e(`imports: ${o.nameOf.get(i.dst)??i.dst.slice(0,19)}`);return 0}if(s===d.SCENARIO||s===d.AC||s===d.GAP){let n=x(m,o,f).entries.filter(t=>t.kind==="judgement"||t.kind==="review");if(e(`${l} \u2014 ${String(r?.content.title??r?.content.text??"")}`),s===d.SCENARIO&&(e(`case type: ${String(r?.content.case_type??"")} \xB7 intent: ${String(r?.content.intent??"")}`),e(`technique: ${String(r?.content.technique_notes??"")}`)),s===d.AC){let t=r?.content.expected_answer;e(`kind: ${String(r?.content.kind??"")}${t?` \xB7 oracle: ${String(t.operator)} ${String(t.operand??"")}`:""}`)}n.length===0&&e("(no recorded judgements yet \u2014 approvals and design-time judgements land here)");for(let t of n)e(t.kind==="judgement"?`judgement: ${t.rationale??t.detail}`:`review: ${t.detail}`);return 0}return e(`no design rationale recorded for ${f} (exists: ${s??"nothing"} ${l} \u2014 design explains tests, scenarios, ACs, and gaps)`),1}export{_ as designExplainCommand};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as a}from"./chunk-GRB66C5S.js";import{a as i}from"./chunk-7Z64BL5D.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import{a as n}from"./chunk-LEA6IHXC.js";import"./chunk-RGDQMKNJ.js";import"./chunk-L3HG5ONB.js";import"./chunk-L4JIMNKW.js";import"./chunk-MBXWXBDM.js";import"./chunk-IAHKTEET.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";async function f(s,p){let o=a(process.cwd(),{out:r=>process.stdout.write(r+`
2
+ import{b as a}from"./chunk-GRB66C5S.js";import{a as i}from"./chunk-FCHTL74E.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import{a as n}from"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";async function f(s,p){let o=a(process.cwd(),{out:r=>process.stdout.write(r+`
3
3
  `),err:r=>process.stderr.write(r+`
4
4
  `),confirm:async()=>!1,isTTY:!!process.stdout.isTTY});if(!o)return 2;let c=n(o),t=i(o,c,s);if(p.json)return process.stdout.write(JSON.stringify(t)+`
5
5
  `),t.target?0:1;if(!t.target)return process.stdout.write(`error: ${s} names nothing in the graph
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{e as Y,f as E}from"./chunk-MTNUZEO7.js";import"./chunk-K7USHLVZ.js";import"./chunk-MR7CX5VT.js";import"./chunk-J44RN3FB.js";import"./chunk-JFAFKHDX.js";import{c as V}from"./chunk-YKTYVJBN.js";import"./chunk-CVOGP253.js";import"./chunk-427OQS2N.js";import{a as x}from"./chunk-M5PJQ5Y3.js";import{a as z}from"./chunk-3C5GMAM4.js";import"./chunk-GG43HSU2.js";import"./chunk-FMR2KPSK.js";import{d as N}from"./chunk-HLRLP6TQ.js";import{c as I}from"./chunk-RN4OSVTG.js";import"./chunk-V3UE6RJP.js";import"./chunk-DNNZ353O.js";import{a as M,b as R}from"./chunk-73OQDAXF.js";import"./chunk-FHKDTM5L.js";import"./chunk-2XMJ6YAE.js";import"./chunk-BKM2LWU2.js";import{a as P}from"./chunk-BC7UVJJB.js";import"./chunk-NVGBE2DR.js";import"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-Y5RNCJAN.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-MMPFU2YC.js";import"./chunk-UR6MHSHU.js";async function W(o){let[{render:e},t,{QuestionBatchPrompt:m}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),p=t.default??t;return new Promise(f=>{let n=e(p.createElement(m,{questions:o,onSubmit:h=>{n.unmount(),f(h)}}))})}async function J(o,e){let[{render:t},m,{ReviewChecklist:p}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),f=m.default??m;return new Promise(n=>{let h=t(f.createElement(p,{items:o.map(a=>{let g=e.get(a.temp_ref);return{uc:a,dedupWith:g&&!g.archived?g.cid:void 0,archivedMatch:g?.archived?{cid:g.cid,reason:g.reason}:void 0}}),onSubmit:a=>{h.unmount(),n(a)}}))})}async function K(o){let{createInterface:e}=await import("readline/promises"),t=e({input:process.stdin,output:process.stdout});try{let m=await t.question(`${o} [y/N] `);return/^y(es)?$/i.test(m.trim())}finally{t.close()}}async function ie(o){let e=P(process.cwd()),t=R({verb:"extract",mode:o.plan?"cli":"interactive",contextRoot:e,env:M(),resumeSid:o.resume,write:!0,longSession:!0}),p={...await N(),...t.spawnEnv()},f=await V(p);if(!f.ok)return process.stderr.write((f.message??"error: turn-endpoint preflight failed")+`
3
+ `),process.stderr.write(t.supportFooter()+`
4
+ `),t.error("preflight_auth"),await t.end({exit_code:2}),2;let n=async()=>f;if(o.plan){let s=await E(o,{contextDir:e,agent:x,preflightTurn:n,ask:W,review:J,confirmStale:K,out:u=>process.stdout.write(u+`
5
+ `),progress:u=>process.stderr.write(u+`
6
+ `),isTTY:I(),auth:p,telemetry:t});return s===1&&process.stderr.write(t.supportFooter()+`
7
+ `),await t.end({exit_code:s}),s}let[{render:h},a,{ScrollbackProvider:g},{ChatSurface:k},{ScrollbackTap:i},{makeChatController:S},{setInkExit:C},H]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-TZ554O4U.js"),import("./ScrollbackTap-Q3IOKNMS.js"),import("./chat-controller-QLORQWJZ.js"),import("./exit-manager-MXUD7GQ7.js"),Promise.all([import("./chat-committer-OS7ULZMH.js"),import("./descriptor-KXDJ4XYD.js"),import("./explain-EBVIUS2X.js"),import("./readmodel-S5RAQH3F.js")])]),[{commitChatTurn:$},{topologyDescriptor:L},{explain:O},{openGraph:y}]=H,A=a.default??a,c=S({commitChatTurn:$,descriptor:L(),contextDir:e,refreshGraph:()=>y(e),graph:y(e),explain:O,by:{kind:"human",id:"owner"},dedupFlags:s=>Y(s,y(e))}),D={current:null},j=0,_=null,v=!1,Q=()=>{if(j+=1,j>=2){try{b.unmount()}catch{}process.exit(130)}c.requestPause(),_=setTimeout(()=>{v||(v=!0,(async()=>{c.ledger({kind:"interrupted",detail:"the agent did not confirm the pause within 5s"}),await D.current?.flush();try{b.unmount()}catch{}process.exit(130)})())},5e3)},U=await import("./dossier-KJSJPWOW.js"),q=s=>{try{return U.buildDossier(y(e),s)}catch{return null}},B={listUcs:()=>{let s=y(e),u=new Set(c.state.turns.flatMap(r=>(r.items??[]).map(l=>l.title.toLowerCase()))),d={high:0,med:1,low:2};return s.byLabel("usecase").filter(r=>!s.superseded.has(r.cid)).map((r,l)=>{let w=r.content,T=String(w.title??r.cid.slice(0,12)),G=z(s,r.cid),F=G?G.designed_at_cid===r.cid?"current":"stale":void 0;return{key:r.cid,title:T,badge:F==="current"?"designed":F==="stale"?"designed \xB7 stale":u.has(T.toLowerCase())?"drafted this session":"existing",designed:F,risk:w.risk,i:l}}).sort((r,l)=>(d[r.risk??"zz"]??3)-(d[l.risk??"zz"]??3)||r.i-l.i).map(({key:r,title:l,badge:w,designed:T})=>({key:r,title:l,badge:w,designed:T}))},runDesignChild:async(s,u=!1)=>{let[{runDesign:d}]=await Promise.all([import("./run-2AIQUJ55.js")]),r="",l=await d({useCase:s,force:u,mode:"interactive"},{contextDir:e,agent:x,preflightTurn:n,ask:w=>c.ask(w),chat:c,nested:!0,out:w=>{r=w},progress:()=>{},isTTY:!0,auth:p});return l!==0&&r&&c.note(r),l}},b=h(A.createElement(g,null,A.createElement(i,{into:D}),A.createElement(k,{controller:c,verb:"extract",onCtrlC:Q,chain:B,inspect:q})),{exitOnCtrlC:!1});C(()=>b.unmount()),c.ledger({kind:"banner",text:"kane-cli context \xB7 extract \xB7 interactive"});try{let s=E(o,{contextDir:e,agent:x,preflightTurn:n,ask:d=>c.ask(d),review:async d=>new Map(d.map(r=>[r.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!0,out:d=>c.note(d),progress:()=>{},isTTY:I(),auth:p,chat:c,telemetry:t});s.finally(()=>{v=!0});let u=await s;return u===1&&process.stderr.write(t.supportFooter()+`
8
+ `),await t.end({exit_code:u}),u}finally{v=!0,_&&clearTimeout(_),await D.current?.flush();try{b.unmount()}catch{}}}async function ae(o){let e=R({verb:"extract",mode:o.mode,contextRoot:P(process.cwd()),env:M(),resumeSid:o.resume,write:!0,longSession:!0}),t={...await N(),...e.spawnEnv()},{makeHeadlessIO:m,resolveEncoding:p,guardedChannels:f}=await import("./headless-io-PWW6YKH2.js"),n=m(p(o.mode),"extract"),{makeInterruptGuard:h}=await import("./interrupt-guard-UREUWNRL.js"),a=h(x,i=>n.out(i)),k=f(n,()=>a.interrupted(),/^error: (agent failed|repair run failed|agent ended)/);try{let i=await E(o,{contextDir:P(process.cwd()),agent:a.agent,preflightTurn:()=>V(t),ask:async()=>[],review:async S=>new Map(S.map(C=>[C.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!1,out:k.out,emit:k.emit,progress:n.progress,isTTY:!1,auth:t,telemetry:e});return a.interrupted()&&i!==3?(n.out("interrupted \u2014 no session saved"),await e.end({exit_code:130}),n.done(130)):(i===1&&n.out(e.supportFooter()),await e.end({exit_code:i}),n.done(i))}catch(i){return n.event({type:"error",message:`error: extract failed: ${i instanceof Error?i.message:String(i)}`}),n.out(`error: extract failed: ${i instanceof Error?i.message:String(i)}`),n.out("hint: per-run trace logs live under .context/logs/ (extract-*.log)"),n.done(1)}finally{a.dispose()}}export{ae as bindExtractHeadless,ie as bindExtractInteractive};
@@ -3,4 +3,4 @@ import{a as s}from"./chunk-BC7UVJJB.js";import"./chunk-UR6MHSHU.js";import{exist
3
3
  `),2;let n=async(r,t)=>{if(process.stderr.write(r+`
4
4
  `),e.mode!=="agent")return 2;let{makeHeadlessIO:a,agentRefusal:c}=await import("./headless-io-PWW6YKH2.js");return c(a("ndjson","extract"),r,t)};if(e.apply)return n("extract: --apply is not implemented yet \u2014 coming with the plan\u2192apply workflow (run without --apply, or use --plan to preview)");{let{validateResumeMessage:r}=await import("./headless-io-PWW6YKH2.js"),t=r(e,"extract");if(t)return n(t)}if(!d(s(process.cwd())))return n("error: no context store here (run `kane-cli context ingest <files>` first)","NO_STORE");if(!e.mode&&!process.stdin.isTTY)return process.stderr.write(`extract: no TTY \u2014 pass an explicit --mode agent|ci|override to run headless
5
5
  `),2;let i=e.mode??"interactive";if(i==="interactive"){if(!process.stdin.isTTY||!process.stdout.isTTY)return process.stderr.write(`extract: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
6
- `),2;let{bindExtractInteractive:r}=await import("./extract-bind-DZLG4GUE.js");return r(e)}let{bindExtractHeadless:o}=await import("./extract-bind-DZLG4GUE.js");return o({...e,mode:i})}export{l as extractCommand};
6
+ `),2;let{bindExtractInteractive:r}=await import("./extract-bind-6MQYKN3G.js");return r(e)}let{bindExtractHeadless:o}=await import("./extract-bind-6MQYKN3G.js");return o({...e,mode:i})}export{l as extractCommand};