@testmuai/kane-cli 0.4.10 → 0.6.0

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 (198) hide show
  1. package/dist/ChatSurface-I6PFL3OE.js +9 -0
  2. package/dist/{ChromeProfilePicker-EFEVOCWS.js → ChromeProfilePicker-YG7TKHM5.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-PPGJMKHQ.js → CliFeedbackPrompt-5RUIP4KA.js} +1 -1
  4. package/dist/CliUploadProgress-YQYPZNEV.js +2 -0
  5. package/dist/{ConfigView-Y7E4Q647.js → ConfigView-HZ7MFCAJ.js} +1 -1
  6. package/dist/EvidenceViewOffer-N4UED7VY.js +2 -0
  7. package/dist/FolderPicker-NAFYP7ES.js +2 -0
  8. package/dist/HelpView-BLWTCQ6T.js +2 -0
  9. package/dist/{InfoBox-BQ2QOIUP.js → InfoBox-7ZZGMYHY.js} +1 -1
  10. package/dist/{LinksBox-DX6BJAX5.js → LinksBox-63Q5YS5X.js} +1 -1
  11. package/dist/{ProfilesView-X35WWM4L.js → ProfilesView-AVYB43ES.js} +1 -1
  12. package/dist/{ProjectPicker-Y4A4UVHA.js → ProjectPicker-EINNALUG.js} +1 -1
  13. package/dist/{SaveSessionPrompt-IS6HZSF4.js → SaveSessionPrompt-C3LCI2KZ.js} +1 -1
  14. package/dist/ScrollbackTap-Q3IOKNMS.js +2 -0
  15. package/dist/SingleShotApp-PS42WWT7.js +2 -0
  16. package/dist/{SummaryBox-47MHU37V.js → SummaryBox-NRPQ2AMW.js} +1 -1
  17. package/dist/TestMdRunView-5FVCEQZI.js +2 -0
  18. package/dist/{WhoamiView-KVIQCGRC.js → WhoamiView-YLMIEJQN.js} +1 -1
  19. package/dist/archive-committer-3NI773TP.js +2 -0
  20. package/dist/bind-QYQ5IT4S.js +6 -0
  21. package/dist/bridge-QENVIWWC.js +2 -0
  22. package/dist/{changelog-S4ZLEQLC.js → changelog-4RSI7UIO.js} +1 -1
  23. package/dist/chat-committer-RTJCKQMM.js +2 -0
  24. package/dist/chat-controller-OTBYHB4Y.js +3 -0
  25. package/dist/chunk-22A2ECA2.js +2 -0
  26. package/dist/{chunk-OHT5RY5E.js → chunk-25YSMNUP.js} +1 -1
  27. package/dist/{chunk-LPUQ4HWQ.js → chunk-2WVKOZ6W.js} +1 -1
  28. package/dist/chunk-2YQ6TW77.js +82 -0
  29. package/dist/{chunk-FKAXPYV7.js → chunk-3SK5GXQM.js} +1 -1
  30. package/dist/chunk-427OQS2N.js +2 -0
  31. package/dist/chunk-5446YVGQ.js +4 -0
  32. package/dist/chunk-5ILXUQIX.js +2 -0
  33. package/dist/chunk-5Q46BEG7.js +2 -0
  34. package/dist/chunk-5U3GOEGG.js +7 -0
  35. package/dist/chunk-5Y2G4NC7.js +2 -0
  36. package/dist/chunk-6BQD2BXI.js +3 -0
  37. package/dist/chunk-6PS65QFF.js +2 -0
  38. package/dist/chunk-ABSEKYIB.js +13 -0
  39. package/dist/chunk-AD46OCZ4.js +4 -0
  40. package/dist/chunk-AE6SS34N.js +4 -0
  41. package/dist/chunk-B2OAEEKI.js +14 -0
  42. package/dist/chunk-B2PZAB7J.js +4 -0
  43. package/dist/chunk-BC7UVJJB.js +2 -0
  44. package/dist/chunk-BV3EARZO.js +17 -0
  45. package/dist/{chunk-QSXYNJOW.js → chunk-C5NNT7Y3.js} +1 -1
  46. package/dist/{chunk-GSKA5DKJ.js → chunk-CBIW5DTU.js} +1 -1
  47. package/dist/chunk-CE664P73.js +2 -0
  48. package/dist/{chunk-IGZPQQFP.js → chunk-D5SHVZGD.js} +1 -1
  49. package/dist/chunk-D5T4ARTB.js +2 -0
  50. package/dist/chunk-DFS4RMVP.js +2 -0
  51. package/dist/chunk-DM2GL24Z.js +3 -0
  52. package/dist/chunk-FAXRERS6.js +6 -0
  53. package/dist/chunk-FPGOV4AQ.js +17 -0
  54. package/dist/chunk-FXPPQL4D.js +6 -0
  55. package/dist/chunk-FYOCF7DY.js +2 -0
  56. package/dist/chunk-GIGD4M7V.js +5 -0
  57. package/dist/chunk-GIRXJOJI.js +2 -0
  58. package/dist/{chunk-AKLIPQVR.js → chunk-GNGGFK7C.js} +1 -1
  59. package/dist/{chunk-RQZCGHG7.js → chunk-H7ZQ4AWL.js} +1 -1
  60. package/dist/{chunk-HUAOH2JK.js → chunk-HYW5VDEC.js} +1 -1
  61. package/dist/chunk-I2S6KNZW.js +2 -0
  62. package/dist/chunk-IACKIGPX.js +2 -0
  63. package/dist/chunk-IF2R3AR4.js +6 -0
  64. package/dist/{chunk-KKIFXAJY.js → chunk-INP7FG6V.js} +1 -1
  65. package/dist/{chunk-G3PWEKD7.js → chunk-IPCC3P6T.js} +2 -2
  66. package/dist/chunk-JFAFKHDX.js +4 -0
  67. package/dist/chunk-KHDUQ33H.js +2 -0
  68. package/dist/chunk-KHU7C6EE.js +2 -0
  69. package/dist/chunk-LBBPMEO2.js +2 -0
  70. package/dist/chunk-LKXVYWKG.js +356 -0
  71. package/dist/chunk-LMJTY32X.js +6 -0
  72. package/dist/chunk-M5JQXOCE.js +12 -0
  73. package/dist/chunk-ME3GYVBV.js +2 -0
  74. package/dist/{chunk-QC73LMAN.js → chunk-MESFNOY3.js} +1 -1
  75. package/dist/chunk-MKD3KZPM.js +2 -0
  76. package/dist/{chunk-NUGGT2XH.js → chunk-MQ7DJ2XC.js} +1 -1
  77. package/dist/{chunk-IT66S24L.js → chunk-N2BUF6YU.js} +1 -1
  78. package/dist/chunk-NFOBDHZK.js +147 -0
  79. package/dist/chunk-NNZV5RCE.js +2 -0
  80. package/dist/{chunk-GF44B552.js → chunk-NOOHQBUD.js} +1 -1
  81. package/dist/chunk-NTJDMMLC.js +61 -0
  82. package/dist/chunk-NWZTYAJB.js +9 -0
  83. package/dist/{chunk-RB2YKN77.js → chunk-OXARXMMD.js} +1 -1
  84. package/dist/chunk-PGEMGGBS.js +26 -0
  85. package/dist/{chunk-JKLKZCJS.js → chunk-QI6WZ56Y.js} +1 -1
  86. package/dist/{chunk-6ATKQYAL.js → chunk-QK6KZMYG.js} +1 -1
  87. package/dist/chunk-QPZRHAYK.js +4 -0
  88. package/dist/chunk-RFHMDQXZ.js +3 -0
  89. package/dist/chunk-RGEAEAZB.js +20 -0
  90. package/dist/chunk-RKWJG3WW.js +19 -0
  91. package/dist/chunk-RTWWPEQ7.js +8 -0
  92. package/dist/chunk-TZVURR5H.js +5 -0
  93. package/dist/chunk-VJUIW2ES.js +4 -0
  94. package/dist/chunk-VK7RF53I.js +2 -0
  95. package/dist/{chunk-VLWWDXBN.js → chunk-VXS23M67.js} +1 -1
  96. package/dist/{chunk-KJLOYIWT.js → chunk-WFAMF4SG.js} +1 -1
  97. package/dist/chunk-WFSQZG26.js +11 -0
  98. package/dist/chunk-WG3BBXJF.js +7 -0
  99. package/dist/chunk-WUMNIGPR.js +2 -0
  100. package/dist/chunk-WUNN5OCH.js +4 -0
  101. package/dist/chunk-XQDDUVD3.js +4 -0
  102. package/dist/chunk-Y2S3PW7N.js +102 -0
  103. package/dist/chunk-YANCBRER.js +3 -0
  104. package/dist/{chunk-YAOWO2GE.js → chunk-YWWKKKXY.js} +1 -1
  105. package/dist/chunk-Z56AWGVY.js +2 -0
  106. package/dist/chunk-ZKYYZ5NO.js +6 -0
  107. package/dist/{chunk-EQC7WE2O.js → chunk-ZO7ROBPR.js} +1 -1
  108. package/dist/chunk-ZXDA4K6G.js +2 -0
  109. package/dist/chunk-ZZOSDBYN.js +23 -0
  110. package/dist/cover-cmd-Y5L4O4Q3.js +2 -0
  111. package/dist/credentials-WUEKK7FI.js +2 -0
  112. package/dist/descriptor-SL5A7RQE.js +2 -0
  113. package/dist/distill-cmd-EYCCCFL3.js +2 -0
  114. package/dist/evidence-4BSNTVND.js +2 -0
  115. package/dist/evolve-cmd-VUWLH3CO.js +2 -0
  116. package/dist/exit-manager-VCSIUYBR.js +2 -0
  117. package/dist/explain-JIXUWEFJ.js +2 -0
  118. package/dist/explain-cmd-55WRDIMW.js +9 -0
  119. package/dist/explain-cmd-RIDEMDMY.js +3 -0
  120. package/dist/extract-bind-T7SUAID6.js +5 -0
  121. package/dist/extract-cmd-LZW7CRT3.js +6 -0
  122. package/dist/gaps-cmd-P2DRK6FW.js +2 -0
  123. package/dist/gate-FACZRGOC.js +2 -0
  124. package/dist/{generate-headless-ODYT3HT7.js → generate-headless-C55T3GGR.js} +2 -2
  125. package/dist/headless-io-GXHKDPHB.js +2 -0
  126. package/dist/index.js +76 -39
  127. package/dist/ingest-4CGBXC2L.js +2 -0
  128. package/dist/ingest-cmd-FJ3SLTT4.js +3 -0
  129. package/dist/interactive-bind-P6AGLUMM.js +7 -0
  130. package/dist/interrupt-guard-UREUWNRL.js +2 -0
  131. package/dist/lifecycle-cmd-56OZT4LY.js +2 -0
  132. package/dist/list-cmd-JB2ABACD.js +3 -0
  133. package/dist/list-commands-M34USUNO.js +2 -0
  134. package/dist/logical-ids-QRRUXV5E.js +2 -0
  135. package/dist/login-flow-GMLHK6JT.js +2 -0
  136. package/dist/maintenance-cmd-E3HEEVQW.js +2 -0
  137. package/dist/open-MQLQKFAW.js +2 -0
  138. package/dist/persist-recorded-session-L2KAY37H.js +3 -0
  139. package/dist/pipeline-FJXQIFW7.js +2 -0
  140. package/dist/readmodel-MPTENJ2R.js +2 -0
  141. package/dist/reconcile-cmd-KTCH4KZQ.js +8 -0
  142. package/dist/{recording-banner-3XTXU2VL.js → recording-banner-2KIVZAXY.js} +1 -1
  143. package/dist/require-project-folder-NOGEHZTS.js +2 -0
  144. package/dist/revert-3TKLOYQA.js +2 -0
  145. package/dist/review-cmd-SL52N4TM.js +4 -0
  146. package/dist/run-P4CHG2VH.js +2 -0
  147. package/dist/run-test-md-ICLG4OPX.js +17 -0
  148. package/dist/{scrollback-6GINSTL2.js → scrollback-JLPJR25X.js} +1 -1
  149. package/dist/sessions-cmd-STHKGDX4.js +23 -0
  150. package/dist/signals-cmd-LXHZQLXZ.js +2 -0
  151. package/dist/{skill-installer-GYYMVNE4.js → skill-installer-KGPXQRCE.js} +1 -1
  152. package/dist/spawner-DDD3ICOX.js +2 -0
  153. package/dist/tcg-generate-KBXZIIHB.js +2 -0
  154. package/dist/testmd-actions-45BY3YFO.js +2 -0
  155. package/dist/{tms-client-NNYXLXZK.js → tms-client-VD3B3SMU.js} +1 -1
  156. package/dist/token-refresh-OCFALJ7U.js +2 -0
  157. package/dist/turn-preflight-I5SM4UIZ.js +2 -0
  158. package/dist/ui-JEJGTURD.js +4 -0
  159. package/dist/{validate-basic-4YMRWYLS.js → validate-basic-QCD4VN37.js} +1 -1
  160. package/dist/{version-check-GU2LS6NM.js → version-check-55YZMQUI.js} +1 -1
  161. package/dist/view-cmd-QE2FS3GB.js +436 -0
  162. package/package.json +8 -6
  163. package/dist/CliUploadProgress-3GGOTLPQ.js +0 -2
  164. package/dist/FolderPicker-LI5JKG2S.js +0 -2
  165. package/dist/HelpView-KHQYGSD2.js +0 -2
  166. package/dist/SingleShotApp-RO25ZX2E.js +0 -2
  167. package/dist/TestMdRunView-OXVWHOV3.js +0 -2
  168. package/dist/chunk-53O3GMZR.js +0 -8
  169. package/dist/chunk-7GOX44H7.js +0 -103
  170. package/dist/chunk-AH4AXJML.js +0 -2
  171. package/dist/chunk-AT45XB6X.js +0 -60
  172. package/dist/chunk-BH6EP2LD.js +0 -85
  173. package/dist/chunk-BQACGLXW.js +0 -5
  174. package/dist/chunk-C6S4IEBC.js +0 -2
  175. package/dist/chunk-DMG5QABA.js +0 -2
  176. package/dist/chunk-G2GQ67DP.js +0 -11
  177. package/dist/chunk-HPZREZKG.js +0 -2
  178. package/dist/chunk-IS62CNJW.js +0 -20
  179. package/dist/chunk-LOIRZFV3.js +0 -10
  180. package/dist/chunk-LRKWPAGK.js +0 -2
  181. package/dist/chunk-MDBXYXSC.js +0 -2
  182. package/dist/chunk-NAAPNSZD.js +0 -17
  183. package/dist/chunk-PUU7A26K.js +0 -11
  184. package/dist/chunk-SQOIKS77.js +0 -6
  185. package/dist/chunk-UAYCLUUZ.js +0 -27
  186. package/dist/chunk-UBN6J3ZA.js +0 -2
  187. package/dist/chunk-XCOU6AYD.js +0 -6
  188. package/dist/chunk-XCYCX4TU.js +0 -17
  189. package/dist/exit-manager-V2NW7A7U.js +0 -2
  190. package/dist/list-commands-PNYMVI6X.js +0 -2
  191. package/dist/login-flow-FIYH6K4A.js +0 -2
  192. package/dist/persist-recorded-session-OJPXI4HP.js +0 -3
  193. package/dist/pipeline-34CX3UBO.js +0 -2
  194. package/dist/require-project-folder-CFX6U6BZ.js +0 -2
  195. package/dist/run-test-md-YWKVMQDJ.js +0 -14
  196. package/dist/tcg-generate-KLY7QZY2.js +0 -2
  197. package/dist/testmd-actions-OUY5BOAV.js +0 -2
  198. package/dist/token-refresh-QCHKMPCM.js +0 -2
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as F,b as z,c as ne,d as R}from"./chunk-2YQ6TW77.js";import{a as D}from"./chunk-WAOCHXJ5.js";import{b as U}from"./chunk-FYOCF7DY.js";import{a as j}from"./chunk-2WVKOZ6W.js";import{a as C}from"./chunk-NLCCBXXV.js";import{a as O}from"./chunk-RZ4F3BHX.js";import{e as te}from"./chunk-UR6MHSHU.js";import{readFileSync as Z,existsSync as w,readdirSync as Ee,mkdirSync as T,writeFileSync as x}from"fs";import{readFile as ee,unlink as be}from"fs/promises";import{join as E}from"path";import{randomUUID as P}from"crypto";function V(t){return t?t.includes(`
3
+ `)?t.split(`
4
+ `).map(e=>e.trim()).filter(Boolean):t.split(". ").map(e=>e.trim()).filter(Boolean).map(e=>e.endsWith(".")?e:e+"."):[]}function L(t,e){return!t||!e?t:t.replace(/\{\{(.+?)\}\}/g,(s,n)=>{let o=e[n];return o?o.value:s}).replace(/\$\{(.+?)\}/g,(s,n)=>{let o=e[n];return o?o.value:s})}var ie={click:"CLICK",double_click:"CLICK",type:"TYPE",fill:"TYPE",select:"SELECT",hover:"HOVER",drag:"DRAG_DROP",upload_files:"UPLOAD",navigate:"OPEN",go_back:"NAVIGATE",go_forward:"NAVIGATE",refresh:"REFRESH",press_key:"SENDKEYS",scroll:"SCROLL_PIXELS",scroll_into_view:"SCROLL_UNTIL_ELEMENT",wait:"WAIT",wait_until:"WAIT_UNTIL",wait_for_load:"WAIT_FOR_LOAD",switch_tab:"SWITCH_TAB",new_tab:"NEW_TAB",close_tab:"CLOSE_TAB",api:"API",evaluate_js:"EVALUATE_JS",vision_query:"VISION_QUERY",textual_query:"TEXTUAL_QUERY",get_url:"GET_URL",get_title:"GET_TITLE",assert:"ASSERTION",math:"MATHEMATICAL_OPERATION",set_cookies:"SET_COOKIES",delete_cookies:"DELETE_COOKIES",clear_cookies:"CLEAR_COOKIES",set_local_storage:"SET_LOCAL_STORAGE",delete_local_storage:"DELETE_LOCAL_STORAGE",clear_local_storage:"CLEAR_LOCAL_STORAGE",set_clipboard:"SET_CLIPBOARD",paste_clipboard:"PASTE_CLIPBOARD",clear_clipboard:"CLEAR_CLIPBOARD"},q={literal:"SET_VARIABLE",condition:"SET_VARIABLE",visual:"VISION_QUERY",dom:"TEXTUAL_QUERY",url:"GET_URL",title:"GET_TITLE",devtool_network:"DEVTOOLS_NETWORK_QUERY",devtool_console:"DEVTOOLS_CONSOLE_QUERY",devtool_cookies:"DEVTOOLS_COOKIES_QUERY",devtool_storage:"DEVTOOLS_STORAGE_QUERY",devtool_performance:"DEVTOOLS_PERFORMANCE",api_response:"API_CALLS_QUERY",textual_visual:"TEXTUAL_ANALYZER"},se=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD","VISION_QUERY","DRAG_DROP","SELECT"]);function $(t,e){if(t==="analyze"){let n=e?.action_params?.analyzer_type??"";return q[n]}let s=ie[t];return s||console.warn(`[migrator] UNKNOWN action_type "${t}" \u2014 falling back to "${t.toUpperCase()}"; explicit mapping required`),s??t.toUpperCase()}function K(t,e){if(!t||!e)return"";try{let s=new Date(t);return isNaN(s.getTime())?"":new Date(s.getTime()+e).toISOString()}catch{return""}}function G(t){try{return JSON.parse(t.output_value??"{}")}catch{return{}}}function oe(t){let e=t.output_variable??"";if(!e)return"[]";let n={...G(t)};return delete n.body,JSON.stringify([{name:e,unique_key:(t.action_id??"").replace(/-/g,"").slice(0,8)||P().replace(/-/g,"").slice(0,8),value:n,variable_description:"API Response"}])}function re(t,e,s){let n=t.action_params??{},o=se.has(e)?"Vision Agent":"Operation Agent",l={operation_type:e};e==="OPEN"&&(l.url=n.url??""),e==="SET_VARIABLE"&&(l.variable_name=t.output_variable??n.key??"",l.variable_value=t.output_value??"");let i={},r={},a=t.action_instruction??"",u=n.text??"",d=n.url??"",g=[["intent",a],["value",u],["url",d]];for(let[h,m]of Object.entries(s)){let b=String(m);if(h.startsWith("secrets."))for(let[I,v]of g)v.includes(b)&&(r[I]=h);for(let[I,v]of g)v.includes(b)&&!(I in i)&&(i[I]=v)}let _=t.action_type,c={operation:t.action_instruction??"",agent:o,operation_dict:l,reasoning:_==="analyze"?n.query??"":t.intent??t.action_instruction??"",variable:i,secrets:r,params:{}};_==="analyze"&&typeof n.code=="string"&&n.code&&(c.code=n.code),_==="analyze"&&typeof n.code_js=="string"&&n.code_js&&(c.code_js=n.code_js),_==="analyze"&&typeof n.condition_expression=="string"&&n.condition_expression&&(c.condition_expression=n.condition_expression),n.uses_websocket===!0&&(c.uses_websocket=!0),n.uses_sse===!0&&(c.uses_sse=!0),_==="analyze"&&n.analyzer_type==="textual_visual"&&(typeof n.wrapped_js=="string"&&(c.wrapped_js=n.wrapped_js),Array.isArray(n.locators)&&(c.locators=n.locators),typeof n.operator=="string"&&(c.operator=n.operator),Array.isArray(n.transforms)&&(c.transforms=n.transforms),typeof n.query=="string"&&(c.query=n.query),typeof n.expected_value=="string"&&(c.expected_value=n.expected_value),typeof n.needs_unit_conversion=="boolean"&&(c.needs_unit_conversion=n.needs_unit_conversion));let f={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[_];return f&&n[f]!==void 0&&(c[f]=n[f]),_==="set_clipboard"&&typeof n.html=="string"&&n.html&&(c.html=n.html),c}function ae(t){let e=t.assertion_tree??{};if(typeof e.passed=="boolean")return e.passed;let s=e.sub_results??[];return s.length===0?e.status==="passed":(e.composite_operator??"and")==="or"?s.some(o=>o.passed===!0):s.every(o=>o.passed===!0)}function X(t){return t.map(e=>({description:e.description??"",store_key:e.store_key??"",expected_value:e.expected??"",extracted_value:e.extracted_value??"",operator:e.operator??"equals",transforms:e.transforms??[]}))}function le(t){let e=t.assertion_tree??{},s=e.sub_results??[],n=X(s);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:s,sub_checks:n,composite_operator:e.composite_operator??"and",verification:e.verification??"",claim:e.description??""}}function ce(t){let s=(t.action_params??{}).assertion_tree??{},n=s.sub_results??[],o=X(n);return[{operation:t.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:n,sub_checks:o,composite_operator:s.composite_operator??"and",verification:"",claim:s.description??t.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function ue(t,e,s,n){let o=t.visual_data;if(!o||o.x==null||o.y==null)return null;let l=e?`${e}/test_screenshots`:"";return{x:o.x,y:o.y,confidence:0,bbox:o.bbox??null,bbox_source:o.bbox?"accessibility_tree":"fallback",viewport_width:o.viewport_width??1280,viewport_height:o.viewport_height??800,scale_factor:null,raw_image_url:l?`${l}/untagged_screenshot/${s}.${n?.get(s)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function B(t,e={},s="",n){let o=t.action_type,l=$(o,t),i=t.action_params??{},r=t.coordinates??null,a=t.selectors??null,u=!!(a&&a.length>0),d=t.timestamp??"",g=t.duration_ms??0,_=t.variables_used??{},c=t.action_id??P(),p=P(),f=K(d,g),h="",m="";o==="navigate"?(m=i.url??"",h=m):o==="type"||o==="fill"?h=i.text??"":o==="press_key"?h=i.key??"":o==="wait"?h=String(i.ms??i.timeout_ms??""):o==="evaluate_js"?h=i.script??"":o==="analyze"&&l==="SET_VARIABLE"&&(h=t.output_value??"");let b="";o==="go_back"?b="back":o==="go_forward"&&(b="forward");let I=L(h,e),v=L(m,e),A=L(t.action_instruction??"",e),y=re(t,l,_);return{operation_id:c,instruction_id:p,instruction:A,intent:A,operation_start:d,operation_end:f,status:t.status??"",command:l,name:"",target:"",value:I,message:"",operation_dict:"",frame:t.frame_info?JSON.stringify(t.frame_info):"",error_message:t.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(y),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:s?`${s}/test_screenshots/untagged_screenshot/${c}.${n?.get(c)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:v,navigation_direction:b,tagified_image_url:"",query_variable_name:t.output_variable??"",query_variable_value:t.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:l==="ASSERTION"?ae(i):"",query_info_dict:{},query_content_confidence:"none",debugging_logs:[],locator_index:0,query_html:"",user_variables:"[]",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,tab_index:String(i.tab_index??""),tab_identifier:String(i.tab_identifier??""),scroll_value:i.amount??1,scroll_direction:i.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:o==="evaluate_js"?i.script??"":"",code_error:"",hide:!1,dismiss_dialog:!1,use_v2_mobile_tagging:!1,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:r!==null&&!u,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:u?null:r?.x??null,y_coord:u?null:r?.y??null,target_x_coord:i.target_x??null,target_y_coord:i.target_y??null,source_description:i.source_description??null,target_description:i.target_description??null,use_coordinates:r!==null&&!u,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:u?a.map(k=>({type:k.isXPath?"xpath":"css",...k})):"",selector_target:"",math_result_variable_name:"",math_result_variable_value:"",expression_tree:l==="ASSERTION"?le(i):i.expression_tree??{},assertion_tree:i.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,db_query:"",db_details:{},db_query_decoded:"",is_global_variable:!1,is_global_variable_persist:!1,global_variable_id:"",wait_for_element_timeout:0,failure_condition:l==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},start_coordinates:i.source_coordinates?{x:i.source_coordinates[0],y:i.source_coordinates[1]}:{},end_coordinates:i.target_coordinates?{x:i.target_coordinates[0],y:i.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:o==="api"?{request:t.action_params?.api_data?.request??{}}:{},output_variables:o==="api"?t.output_variable?{[t.output_variable]:null}:{}:t.output_variable?{[t.output_variable]:t.output_value??""}:{},visual_context:ue(t,s,c,n),reasoning:o==="analyze"?i.query??"":t.intent??t.action_instruction??""}}function M(t,e,s={}){let n=t.action_type,o=$(n,t),l=t.timestamp??"",i=t.duration_ms??0,r=K(l,i),a=o==="ASSERTION"||o==="MATHEMATICAL_OPERATION";return{instruction_id:e.instruction_id,instruction_class:a?"non_driver_action":"driver_action",module_id:"",instruction:L(t.action_instruction??"",s),command:o,error:null,parent_instruction_id:"",classification_layer_resp:o==="ASSERTION"?ce(t):[],classification_error:{},operations:[e],status:t.status??"",start_timestamp:l,end_timestamp:r,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&t.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&t.action_params?.analyzer_type?.startsWith("devtool_")?t.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?t.action_params?.script??"":"",user_variables:n==="api"?oe(t):"[]",api_data:n==="api"?{request:t.action_params?.api_data?.request??{},response:G(t)}:{},params_used:!1,hard_assertion:o==="ASSERTION"?t.action_params?.failure_condition==="hard":!1,expected_outcome:"",module_execution_index:0,module_version:null,network_throttle:{},isEdited:!1,use_query_assertion_v2:!1,db_query:"",db_details:{},network_assertion_content:{},screenshot_command:"",smartui_contents:{},generative_id:"",plan_id:"",generative_objective:"",error_message:"",error_code:"",reason:"",title:"",used_variables:[],reasoning:n==="analyze"?t.action_params?.query??"":t.intent??t.action_instruction??""}}function de(t,e=[]){let s=t.action_params??{},n=s.branches??[],o=s.winning_index??-1,l=s.sub_results??[],i={};for(let a of l){let u=a.sub_results;if(u)for(let d of u){let g=d.store_key;g&&(i[g]=d)}}let r=n.map((a,u)=>{let d=u===o,g=(a.sub_checks??[]).map(_=>{let c=i[_.store_key];return{description:_.description,store_key:_.store_key,expected_value:_.expected_value,stored_value:c?.extracted_value??_.stored_value,operator:_.operator??c?.operator??"equals",transforms:_.transforms??c?.transforms??[]}});if(g.length===0&&a.condition&&l.length>0){let c=l.find(p=>p.branch_index===u)?.sub_results??[];c.length>0&&(g=c.map(p=>({description:p.description??a.condition,store_key:p.store_key??"",expected_value:p.expected??"true",stored_value:p.extracted_value??void 0,operator:p.operator??"equals",transforms:p.transforms??[]})))}return{branch_index:u,condition:a.condition??null,branch_type:a.branch_type??"sub_objective",passed:d,sub_objective:null,custom_event:a.custom_event??null,children:d?e:[],sub_checks:a.condition?g:[],composite_operator:a.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${P().slice(0,8)}`,instruction:t.action_instruction??"",instruction_class:"driver_action",command:"",status:t.status??"success",resolved_branch_index:o,branches:r,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:t.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function Y(t,e,s){for(let n of t)n.content_type==="instruction"&&"generative_id"in n&&(n.generative_id=e,n.generative_objective=s)}function N(t,e={},s="",n,o){let l=[],i=0;for(;i<t.length;){let r=t[i],a=r.action_type;if(!o?.keepFailedActions&&r.status==="error"&&a!=="assert"&&a!=="if_else"&&a!=="child_agent_start"&&a!=="child_agent_end"&&!(r.until_condition&&!r.error)){i+=1;continue}if(a==="analyze"&&!q[r.action_params?.analyzer_type??""]){i+=1;continue}if(a==="child_agent_start"){let u=r.action_params?.child_id??"",d=r.action_params?.objective??"",g=[];i+=1;let _=1,c="error",p;for(;i<t.length&&_>0;){let y=t[i],k=y.action_type;if(k==="child_agent_start")_+=1;else if(k==="child_agent_end"&&(_-=1,_===0)){c=y.status??"success",p=y,i+=1;break}_>0&&g.push(y),i+=1}let f=N(g,e,s,n);Y(f,u,d);let h=p?.action_params?.result_code??null,m=p?.action_params?.reason_code??null,b=p?.action_params?.error_message??null,I=p?.action_params?.summary??null,v=p?.action_params?.one_liner??null,A=c==="error";l.push({content_type:"generative_block",instruction_id:`generative_block_${u}`,generative_id:u,objective:d,status:c,children:f,error_message:A?b??null:null,error_code:A?m??null:null,result_code:h??null,bifurcation_context:[],approach_reason:V(I),one_liner:v??null});continue}else if(a==="child_agent_end"){i+=1;continue}else if(a==="if_else"){i+=1;let u=[];for(;i<t.length&&t[i].action_type==="child_agent_start";){let d=t[i],g=d.action_params?.child_id??"",_=d.action_params?.objective??"",c=[];i+=1;let p=1,f="error";for(;i<t.length&&p>0;){let m=t[i];if(m.action_type==="child_agent_start")p+=1;else if(m.action_type==="child_agent_end"&&(p-=1,p===0)){f=m.status??"success",i+=1;break}p>0&&c.push(m),i+=1}let h=N(c,e,s,n);u.push(...h)}l.push(de(r,u));continue}else if(a==="query_tool"){i+=1;continue}else if(r.until_condition){let u=B(r,e,s,n),d=M(r,u,e),g=typeof r.until_condition_met=="boolean"?r.until_condition_met:r.status==="success";l.push({content_type:"until_block",instruction_id:`until_${P().slice(0,8)}`,condition:r.until_condition,max_retries:r.until_max_retries??10,settle_ms:r.until_settle_ms??500,current_count:0,condition_met:g,children:[d],generative_id:"",generative_objective:"",variables_used:{},status:r.status??"success"})}else{let u=B(r,e,s,n),d=M(r,u,e);l.push(d)}i+=1}return l}function S(t,e={},s="",n,o){let l=[];for(let i of t){let r=N(i.records,e,s,n,o);if(r.length===0)continue;let a=P().replace(/-/g,"");Y(r,a,i.objective);let u=r.some(c=>"status"in c&&typeof c.status=="string"?c.status==="error"||c.status==="failed":!1),d=i.resultCode?parseInt(i.resultCode,10):null,g=d!==null&&!isNaN(d)&&d>=200,_=u||g?"error":"success";l.push({content_type:"generative_block",instruction_id:`generative_block_${a}`,generative_id:a,objective:i.objective,status:_,children:r,error_message:_==="error"?i.errorMessage??null:null,error_code:_==="error"?i.reasonCode??null:null,result_code:i.resultCode??null,bifurcation_context:[],approach_reason:V(i.summary),one_liner:i.oneLiner??null})}return{instructions:l}}var H=te(ne(),1);import{createWriteStream as _e}from"fs";import{readFile as pe}from"fs/promises";import{join as ge,basename as fe}from"path";import{tmpdir as he}from"os";var me=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function W(t){let e=ge(he(),`${fe(t)}_artifacts.zip`);return new Promise((s,n)=>{let o=_e(e),l=(0,H.default)("zip",{zlib:{level:6}});o.on("close",()=>s(e)),l.on("error",n),l.pipe(o),l.glob("**/*",{cwd:t,ignore:me}),l.finalize()})}async function J(t){return pe(t)}async function Ie(t,e){return ee(U(t,e))}function ve(t){return{key:"artifacts",content_type:"application/zip",filename:`${t}.evidence`}}var Q=class{config;controller;testId;constructor(e){this.config=e,this.controller=new D(e.controllerBaseUrl,e.auth),this.testId=e.testId}log(e,s,n,o){this.config.log?.(e,s,n,o)}async execute(){let{onProgress:e}=this.config;try{if(!this.testId)return this.log("error","PIPELINE_ABORT","No test_id available"),{success:!1,testId:null,error:"No test_id available"};let s=this.config.evidence,n=null;if(this.config.shouldUploadArtifacts!==!1){e("convert","running");let r=this.collectNdjsonPerRun(),a=r.reduce((f,h)=>f+h.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:a,run_groups:r.length});let u=this.config.variables??{};this.log("info","PIPELINE_CONVERT_VARS","Variables for template resolution",{keys:Object.keys(u)});let{instructions:d}=r.length>0?S(r,u,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:d.length});let g=this.buildExecutionEnvelope(d),_=Buffer.from(JSON.stringify(g));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(_.length/1024).toFixed(1)});let c=E(this.config.sessionDir,"execution.json");x(c,JSON.stringify(g,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:c});let p=s?.packTestDir??this.config.evidenceRead?.packTestDir;if(p){let f=E(p,"auteur");T(f,{recursive:!0}),x(E(f,"execution.json"),JSON.stringify(g,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:E(f,"execution.json")})}if(e("convert","done"),s)n=_;else{e("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let f=null,h;try{f=await W(this.config.sessionDir),h=await J(f),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(h.length/1024/1024).toFixed(1),path:f}),e("zip","done",`${(h.length/1024/1024).toFixed(1)}MB`)}finally{f&&await be(f).catch(()=>{})}e("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let m=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:m.urls.artifacts?.blob_url,blob_url:m.urls.blob?.blob_url}),e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(h.length/1024/1024).toFixed(1),blob_size_kb:+(_.length/1024).toFixed(1)}),await Promise.all([R(m.urls.artifacts.upload_url,h,"application/zip"),R(m.urls.blob.upload_url,_,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),e("upload","done")}}else{let r=this.collectNdjsonPerRun(),a=this.config.variables??{},{instructions:u}=r.length>0?S(r,a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0}):{instructions:[]},d=this.buildExecutionEnvelope(u),g=E(this.config.sessionDir,"execution.json");x(g,JSON.stringify(d,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:g});let _=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(_){let c=E(_,"auteur");T(c,{recursive:!0});let p=this.readAuthoredExecution();x(E(c,"execution.json"),p??JSON.stringify(d,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:E(c,"execution.json"),source:p?"authored":"run_envelope"})}e("convert","skipped"),e("zip","skipped"),e("presign","skipped"),e("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){e("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),e("atomic_replace","done")}catch(r){let a=r instanceof Error?r.message:String(r);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:a}),e("atomic_replace","failed",a),r}}else e("atomic_replace","skipped");let o,l;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){e("commit_lock","running");let r=await this.config.onCommitLock();if(r.ok)o=r.testcaseId,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:o??"none"}),e("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:r.reason,message:r.message}),e("commit_lock","failed",`${r.reason??"unknown"}: ${r.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${r.reason??"unknown"}`}}else e("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){e("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let r=new j(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),a=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective];if(o=(await r.endTest(this.testId,{commit_id:this.config.commitId,time_taken:Math.round(this.config.totalDuration),steps_count:this.config.totalSteps,commit_message:this.config.firstObjective.slice(0,255),objectives:a})).testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:o??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(o)}catch(d){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(d)})}e("finalize","done")}else e("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(o&&this.config.shareApiBaseUrl)try{l=await this.generateShareLink(o),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:l})}catch(r){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(r)})}if(s&&n){let r=null;e("zip","running");try{await s.sealFn({testcaseId:o,shareId:l}),r=s.sealedPackPath?await ee(s.sealedPackPath):await Ie(s.executionId,s.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:s.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(r.length/1024/1024).toFixed(1)})}catch(a){let u=a instanceof Error?a.message:String(a);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:s.executionId,error:u})}if(r){e("zip","done",`${(r.length/1024/1024).toFixed(1)}MB`),e("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[ve(s.executionId),{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:a.urls.artifacts?.blob_url,blob_url:a.urls.blob?.blob_url}),e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(r.length/1024/1024).toFixed(1),blob_size_kb:+(n.length/1024).toFixed(1)}),await Promise.all([R(a.urls.artifacts.upload_url,r,"application/zip"),R(a.urls.blob.upload_url,n,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),e("upload","done")}else{e("zip","skipped"),e("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(n.length/1024).toFixed(1)}),await R(a.urls.blob.upload_url,n,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),e("upload","done")}}let i;if(this.config.codeExport?.enabled&&o){let r=!1;try{await this.triggerCodeExport(o),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),r=!0}catch(a){let u=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:u}),e("code_export","failed",`trigger failed: ${u}`)}if(r){e("code_export","running","Waiting for code generation\u2026");try{i=await this.pollAndDownloadCode(o,e),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:i}),e("code_export","done",i)}catch(a){let u=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:u}),e("code_export","failed",u)}}}else e("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:o,shareId:l,codeExportDir:i}}catch(s){return{success:!1,testId:this.testId,error:s instanceof Error?s.message:String(s)}}}async runCodeExport(e,s){let n=s??this.config.onProgress,o=!1;try{await this.triggerCodeExport(e),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:e}),o=!0}catch(l){let i=l instanceof Error?l.message:String(l);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:i}),n("code_export","failed",`trigger failed: ${i}`)}if(o){n("code_export","running","Waiting for code generation\u2026");try{let l=await this.pollAndDownloadCode(e,n);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:l}),n("code_export","done",l),l}catch(l){let i=l instanceof Error?l.message:String(l);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:i}),n("code_export","failed",i);return}}}collectNdjsonPerRun(){let e=[],s=this.config.runObjectives??[],n=this.config.runMetadata??[],o=this.config.evidence??this.config.evidenceRead;for(let l=0;l<this.config.runDirs.length;l++){let i=this.config.runDirs[l],r=s[l]||this.config.firstObjective,a=n[l],u=o?this.readNdjsonFromFile(E(o.packTestDir,"logs",`${o.runIndices?.[l]??l}-actions.ndjson`)):this.readNdjsonFromDir(i);u.length>0&&e.push({objective:r,records:u,resultCode:a?.resultCode,reasonCode:a?.reasonCode,errorMessage:a?.errorMessage,summary:a?.summary,oneLiner:a?.oneLiner})}if(e.length===0){let l=E(this.config.sessionDir,"runs");if(w(l))try{let r=Ee(l,{withFileTypes:!0}).filter(a=>a.isDirectory()).map(a=>a.name).sort();for(let a of r){let u=E(l,a),d=this.readNdjsonFromDir(u);d.length>0&&e.push({objective:this.config.firstObjective,records:d})}}catch{}}return e}readNdjsonFromDir(e){let s=[E(e,"run-test","actions.ndjson"),E(e,"actions.ndjson")];for(let n of s)if(w(n))return this.readNdjsonFromFile(n);return[]}readNdjsonFromFile(e){let s=[];if(!w(e))return s;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:e});let n=Z(e,"utf-8");for(let o of n.split(`
5
+ `)){let l=o.trim();if(l)try{s.push(JSON.parse(l))}catch{}}return s}async generateShareLink(e){let s=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:s,testcase_id:e});let n={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[e],entityType:"Test Case Details",expiresAt:7})},o=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:o,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let l=o?await this.config.authResolver.fetch(s,n):await O(s,{...n,headers:{...n.headers,Authorization:this.buildAuthHeader()}});if(!l.ok)throw new Error(`Share link API failed: ${l.status} ${await l.text()}`);let i=await l.json();if(!i.shareId)throw new Error("Share link API returned no shareId");return i.shareId}async triggerCodeExport(e){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:s,body:n}=F({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:e,codeExport:this.config.codeExport});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:s});let o={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)},l=this.config.authResolver?await this.config.authResolver.fetch(s,o):await O(s,{...o,headers:{...o.headers,Authorization:this.buildAuthHeader()}});if(!l.ok)throw new Error(`Code export failed: ${l.status} ${await l.text()}`)}async pollAndDownloadCode(e,s){let n=z({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:e}),o=this.config.exitTimeoutMs??3e5,l=5e3,i=Date.now()+o;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:n,timeout_ms:o});let r=(a,u)=>this.config.authResolver?this.config.authResolver.fetch(a,u):O(a,{...u,headers:{...u?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<i;){let a=await r(n,{method:"GET",headers:{Accept:"application/json"}});if(!a.ok){let c=await a.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:a.status,body:c.slice(0,200)}),new Error(`code export poll skipped: HTTP ${a.status}`)}let d=(await a.json()).data?.find(c=>c.code_name==="kane-cli-trigger");if(!d){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),s("code_export","running","Waiting for code generation\u2026"),await this.sleep(l);continue}let g=d.status.toLowerCase();if(g==="in progress"||g==="in_progress"||g==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:d.status}),s("code_export","running","Generating code\u2026"),await this.sleep(l);continue}if(!d.url||d.url.length===0)throw new Error(`Code export status=${d.status} but no files returned`);let _=this.config.codeExportDir??E(this.config.sessionDir,"code-export");T(_,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:d.url.length,dir:_}),s("code_export","running",`Downloading ${d.url.length} files\u2026`);for(let c of d.url){let p=E(_,c.file_name),f=await O(c.file_url);if(!f.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:c.file_name,status:f.status});continue}let h=await f.text();x(p,h,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:c.file_name,size_bytes:h.length})}return _}throw new Error("Code export timed out")}sleep(e){return new Promise(s=>setTimeout(s,e))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:C(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let e=this.config.authoredExecutionPath;if(!e)return null;try{let s=Z(e,"utf8");return JSON.parse(s),s}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:e}),null}}buildExecutionEnvelope(e){let s=this.config.runStatuses.every(i=>i==="passed")?"success":"error",n=this.config.variableIds??{},o=[];if(this.config.variables)for(let[i,r]of Object.entries(this.config.variables)){if(r.secret)continue;let a=i.startsWith("global.")?i.slice(7):i;o.push({id:n[a]??0,name:a,value:r.value,session_value:r.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let l=[];for(let i of this.collectNdjsonPerRun())for(let r of i.records)r.output_variable&&r.output_value!=null&&l.push({name:r.output_variable,value:String(r.output_value),value_type:"test_level",variable_description:"ANALYZE result"});return{test_id:this.testId,version:"v4",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:s,commit_id:this.config.commitId,instructions:e,modules:[],uploaded_files:[],test_params:[],test_level_variables:JSON.stringify(l),test_global_variables:o,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:0,environment:"",mobile_browser:!1,native_popups:[],smartui:{},module_index:0}}};export{Ie as a,ve as b,Q as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as t,b as i}from"./chunk-B2PZAB7J.js";import{i as s,j as e}from"./chunk-IACKIGPX.js";function a(r,n){return"sha256:"+i(Buffer.from("assurance."+r+"\0"+t(s(r,n)),"utf8"))}function f(r,n,o,u){return"sha256:"+i(Buffer.from("assurance.edge\0"+t({type:r,src:n,dst:o,props:e(r,u)}),"utf8"))}function d(r,n){return{source_id:r,blob:n}}function p(r){return{...r,derived:!0}}export{a,f as b,d as c,p as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as f}from"./chunk-FPFOW6BS.js";import{a as h}from"./chunk-JKLKZCJS.js";import{a as d}from"./chunk-KKIFXAJY.js";var o=class extends Error{constructor(a,l){super(a);this.code=l;this.name="AuthError"}};async function k(c){let{creds:i,env:a,usernameFlag:l,accessKeyFlag:g,log:t}=c,e=null,u=null;if(l&&g)e={username:l,access_key:g},t("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:l});else{let r=i.resolveAuth();r?.method==="basic"&&(e={username:r.username,access_key:r.access_key},t("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:r.username}))}if(!e){let{credentials:r,profile:E}=i.getActiveCredentials();if(!r)throw new o("Not authenticated \u2014 no credentials found","not_authenticated");if(u=r.access_token,r.expires_at-Date.now()/1e3<300)try{let n=await h({creds:i,profile:E,env:a,credentials:r});n&&(u=n.accessToken,t("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(n){let m=n instanceof Error?n.message:String(n);throw t("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:m}),new o(`Token refresh failed: ${m}`,"refresh_failed")}}let b=d(a),v=async()=>u,y=e?{username:e.username,access_key:e.access_key}:null,p=new f(b.controllerBaseUrl,v,y,t),s=await p.resolve();return s&&!e&&(e={username:s.username,access_key:s.access_key},t("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:s.username})),{basicAuth:e,token:u,resolver:p,resolvedCreds:s}}export{o as a,k as b};
2
+ import{a as h}from"./chunk-FPFOW6BS.js";import{a as f}from"./chunk-QI6WZ56Y.js";import{a as m}from"./chunk-INP7FG6V.js";var o=class extends Error{constructor(a,l){super(a);this.code=l;this.name="AuthError"}};async function k(c){let{creds:i,env:a,usernameFlag:l,accessKeyFlag:p,log:t}=c,e=null,u=null;if(l&&p)e={username:l,access_key:p},t("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:l});else{let r=i.resolveAuth();r?.method==="basic"&&(e={username:r.username,access_key:r.access_key},t("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:r.username}))}if(!e){let{credentials:r,profile:E}=i.getActiveCredentials();if(!r)throw new o("Not authenticated \u2014 no credentials found","not_authenticated");if(u=r.access_token,r.expires_at-Date.now()/1e3<300)try{let n=await f({creds:i,profile:E,env:a,credentials:r});n&&(u=n.accessToken,t("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(n){let d=n instanceof Error?n.message:String(n);throw t("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:d}),new o(`Token refresh failed: ${d}`,"refresh_failed")}}let v=m(a),b=async()=>u,y=e?{username:e.username,access_key:e.access_key}:null,g=new h(v.controllerBaseUrl,b,y,t),s=await g.resolve();return s&&!e&&(e={username:s.username,access_key:s.access_key},t("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:s.username})),{basicAuth:e,token:u,resolver:g,resolvedCreds:s}}export{o as a,k as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as f}from"./chunk-DMG5QABA.js";import{x as t}from"./chunk-LRKWPAGK.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as r,b as n}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as p}from"./chunk-UR6MHSHU.js";var c=p(B(),1);var e=p(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,a){return s.map(l=>l.name===o?{...l,status:d,detail:a}:l)}function R(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),a=Math.round(o%60);return`${d}m ${a}s`}function D(s){let[o,d]=(0,c.useState)(0),a=c.default.useRef(Date.now());return(0,c.useEffect)(()=>{if(!s)return;a.current=Date.now();let l=setInterval(()=>{d(Date.now()-a.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:a}){let l=D(o==="uploading");return o==="uploading"?(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,children:[" ",R(l)]})]}),(0,e.jsx)(r,{flexDirection:"column",marginTop:1,children:s.filter(i=>i.status!=="skipped").map((i,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",u=i.status==="done",m=i.status==="running",g=i.status==="failed";return(0,e.jsxs)(r,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(r,{width:3,children:m?(0,e.jsx)(f,{}):u?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:u?t.dim:m?void 0:g?t.red:t.muted,children:i.label}),i.detail&&(0,e.jsxs)(n,{color:t.dim,children:[" ",i.detail]})]},i.name)})}),(0,e.jsx)(r,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),a&&(0,e.jsxs)(r,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:a})]})]})}export{v as a,U as b,h as c};
2
+ import{a as f}from"./chunk-5Q46BEG7.js";import{x as t}from"./chunk-MKD3KZPM.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as r,b as n}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as p}from"./chunk-UR6MHSHU.js";var c=p(B(),1);var e=p(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,a){return s.map(l=>l.name===o?{...l,status:d,detail:a}:l)}function R(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),a=Math.round(o%60);return`${d}m ${a}s`}function D(s){let[o,d]=(0,c.useState)(0),a=c.default.useRef(Date.now());return(0,c.useEffect)(()=>{if(!s)return;a.current=Date.now();let l=setInterval(()=>{d(Date.now()-a.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:a}){let l=D(o==="uploading");return o==="uploading"?(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,children:[" ",R(l)]})]}),(0,e.jsx)(r,{flexDirection:"column",marginTop:1,children:s.filter(i=>i.status!=="skipped").map((i,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",u=i.status==="done",m=i.status==="running",g=i.status==="failed";return(0,e.jsxs)(r,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(r,{width:3,children:m?(0,e.jsx)(f,{}):u?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:u?t.dim:m?void 0:g?t.red:t.muted,children:i.label}),i.detail&&(0,e.jsxs)(n,{color:t.dim,children:[" ",i.detail]})]},i.name)})}),(0,e.jsx)(r,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),a&&(0,e.jsxs)(r,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:a})]})]})}export{v as a,U as b,h as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,e as o}from"./chunk-LRKWPAGK.js";import{readFileSync as f,writeFileSync as d,mkdirSync as h,realpathSync as g}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function w(){try{let t=process.argv[1];if(t&&g(t).includes("/Cellar/"))return b}catch{}return C}var m=y(c,"version-check.json"),S=1440*60*1e3;function k(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<S)return t}catch{}return null}function A(t){try{h(c,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);for(let s=0;s<3;s++){let e=(n[s]??0)-(i[s]??0);if(e!==0)return e}return 0}function p(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);return(n[0]??0)!==(i[0]??0)?"major":(n[1]??0)!==(i[1]??0)?"minor":"patch"}async function j(){try{let t=k();if(t)return u(a,t.latest)>0?{current:a,latest:t.latest,severity:p(a,t.latest)}:null;let r=new AbortController,i=setTimeout(()=>r.abort(),5e3),n=await l(o,{headers:{Accept:"application/json"},signal:r.signal});if(clearTimeout(i),!n.ok)return null;let e=(await n.json())["dist-tags"]?.latest;return e?(A(e),u(a,e)>0?{current:a,latest:e,severity:p(a,e)}:null):null}catch{return null}}export{w as a,u as b,p as c,j as d};
2
+ import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,e as o}from"./chunk-MKD3KZPM.js";import{readFileSync as f,writeFileSync as d,mkdirSync as h,realpathSync as g}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function w(){try{let t=process.argv[1];if(t&&g(t).includes("/Cellar/"))return b}catch{}return C}var m=y(c,"version-check.json"),S=1440*60*1e3;function k(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<S)return t}catch{}return null}function A(t){try{h(c,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);for(let s=0;s<3;s++){let e=(n[s]??0)-(i[s]??0);if(e!==0)return e}return 0}function p(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);return(n[0]??0)!==(i[0]??0)?"major":(n[1]??0)!==(i[1]??0)?"minor":"patch"}async function j(){try{let t=k();if(t)return u(a,t.latest)>0?{current:a,latest:t.latest,severity:p(a,t.latest)}:null;let r=new AbortController,i=setTimeout(()=>r.abort(),5e3),n=await l(o,{headers:{Accept:"application/json"},signal:r.signal});if(clearTimeout(i),!n.ok)return null;let e=(await n.json())["dist-tags"]?.latest;return e?(A(e),u(a,e)>0?{current:a,latest:e,severity:p(a,e)}:null):null}catch{return null}}export{w as a,u as b,p as c,j as d};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{d as f}from"./chunk-JFAFKHDX.js";import{a as v}from"./chunk-GIRXJOJI.js";import{g}from"./chunk-B2PZAB7J.js";import{d as m,f as u}from"./chunk-IACKIGPX.js";var w=3,S={edit:"edit",reject:"mistake",dedup_dropped:"mistake",approve:"usage",enhance:"directed-edit",add:"directed-edit",default_accepted:"usage",default_overridden:"edit",gap_resolution:"usage",dedup_kept:"usage"};function T(y){let{contextDir:i,graph:o,watermark:_,by:N}=y,{signals:$}=f(i,_),h=$.filter(e=>e.event_id===void 0||o.appliedEvents.has(e.event_id)),s=new Map;for(let e of h){let t=e.event_id??`${e.ts}|${e.id}|${e.verdict}|${e.polarity}`;s.has(`${t}|${e.polarity}|${e.verdict}`)||s.set(`${t}|${e.polarity}|${e.verdict}`,e)}let k=[...s.values()].sort((e,t)=>(e.event_id??e.ts)<(t.event_id??t.ts)?-1:1),n=new Map;for(let e of k){let t=`${e.verdict}|${e.tag??""}`,r=n.get(t)??{verdict:e.verdict,tag:e.tag,events:new Set};r.events.add(e.event_id??e.ts),n.set(t,r)}let d=[],a=0;for(let[,e]of[...n.entries()].sort(([t],[r])=>t<r?-1:1)){if(e.events.size<w)continue;let r={derived:!0,statement:`${e.verdict}${e.tag?`/${e.tag}`:""} recurs (${e.events.size} distinct events) \u2014 bias future proposals ${e.verdict==="approve"?"toward":"away from"} this pattern`,learned_from_kind:S[e.verdict]??"usage",learned_from:[...e.events].sort()},c=u("stylenote",r);if(c.length>0)return{record:null,errors:c.map(l=>({code:l.code,detail:l.detail})),minted:0};let p=v("stylenote",r);o.hasNode(p)||(d.push({cid:p,label:m.STYLENOTE,content:r}),a+=1)}return d.length===0?{record:null,errors:null,minted:0}:{record:g(i,{ts:new Date().toISOString(),proposal_id:null,nodes:d,edges:[],review:[],supersessions:[],source_head_moves:{}},{expectPrev:o.latestHash}).record,errors:null,minted:a}}export{T as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var l="assurance/context@1";var u={source:{hashed:["blob","source_id"],required:["blob","source_id"],enums:{}},usecase:{hashed:["actors","criteria","derived","description","risk","summary","title","value"],required:["derived","risk","title"],enums:{risk:["high","med","low"]}},scenario:{hashed:["case_type","derived","description","intent","parameters","tags","technique_notes","title"],required:["case_type","derived","intent","title"],enums:{case_type:["happy","negative","boundary","edge","security","a11y","perf","i18n"]}},ac:{hashed:["derived","expected_answer","kind","measurable","risk","text"],required:["derived","risk","text"],enums:{risk:["high","med","low"],kind:["presence","forbidden-presence","count","delta","state-transition","absolute","bound","propagation","latency","graded"]}},test:{hashed:["check","config","definitionId","derived","objectives_blob","surface_required","test_md_blob","title"],required:["definitionId","derived","title"],enums:{}},gap:{hashed:["derived","kind","question","ref","risk","risk_rationale","text","uc"],required:["derived","kind"],enums:{kind:["ambiguous","incomplete","contradictory","unmeasurable","missing-expected-result","budget-evicted","invariant-unexercised"],risk:["high","med","low"]}},stylenote:{hashed:["derived","learned_from_kind","statement","tags","text"],unhashed:["learned_from"],required:["derived","learned_from_kind","statement"],enums:{learned_from_kind:["edit","directed-edit","mistake","usage"]}}},f={DERIVES:{src:["source"],dst:["usecase","ac","scenario","test"],salient:["anchor","source_cid","source_id"],props:["anchor","quote","source_cid","source_id"],pin:{comparesTo:"source_head"},cardinality:"many",acyclic:!1},belongs_to:{src:["scenario"],dst:["usecase"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"one-live-per-src",acyclic:!1},scoped_to:{src:["ac"],dst:["scenario","usecase"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"one-live-per-src",acyclic:!1},exercises:{src:["scenario"],dst:["ac"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!1},verifies:{src:["test"],dst:["ac"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!1},automates:{src:["test"],dst:["scenario"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"one-live-per-src-and-dst",acyclic:!1},depends_on:{src:["usecase","scenario"],dst:["usecase","scenario"],salient:[],props:["reason"],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!0},reuses:{src:["test"],dst:["test"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!0},annotates:{src:["gap","stylenote"],dst:["source","usecase","scenario","ac","test"],salient:[],props:["reason"],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!1}},E=["presence","forbidden-presence","count","delta","state-transition","absolute","bound","propagation","latency","graded"];var g={presence:{operators:["exists","forall"],baseline:"null",requires:[]},"forbidden-presence":{operators:["exists","forall"],baseline:"null",requires:[]},count:{operators:["equals","gte","lte"],baseline:"null",requires:[],operand_forms:["literal","derived"]},delta:{operators:["changed-by"],baseline:"required",requires:[]},"state-transition":{operators:["changed-by","equals"],baseline:"required",requires:[]},absolute:{operators:["equals","contains","gte","lte"],baseline:"null",requires:[]},bound:{operators:["gte","lte"],baseline:"null",requires:[]},propagation:{operators:["exists","equals"],baseline:"null",requires:[]},latency:{operators:["lte"],baseline:"null",requires:["within"]},graded:{operators:["gte"],baseline:"null",requires:["metric","threshold"]}},y=Object.freeze({SOURCE:"source",USECASE:"usecase",SCENARIO:"scenario",AC:"ac",TEST:"test",GAP:"gap",STYLENOTE:"stylenote"}),h=Object.freeze({DERIVES:"DERIVES",BELONGS_TO:"belongs_to",SCOPED_TO:"scoped_to",EXERCISES:"exercises",VERIFIES:"verifies",AUTOMATES:"automates",DEPENDS_ON:"depends_on",REUSES:"reuses",ANNOTATES:"annotates"});function c(r,s,t){let n=[],e=g[r];if(!e)return n.push({code:"BAD_CHECK",detail:`${t}.kind ${JSON.stringify(r)} not in ${E.join("|")}`}),n;let o=s.operator;o!==void 0&&!e.operators.includes(o)&&n.push({code:"BAD_CHECK",detail:`${t}: operator ${JSON.stringify(o)} illegal for kind "${String(r)}" (legal: ${e.operators.join("|")})`});for(let a of e.requires)(s[a]===void 0||s[a]===null||s[a]==="")&&n.push({code:"BAD_CHECK",detail:`${t}: kind "${String(r)}" requires "${a}"`});e.baseline==="null"&&s.baseline!==void 0&&s.baseline!==null&&n.push({code:"BAD_CHECK",detail:`${t}: kind "${String(r)}" must carry baseline null (only delta/state-transition have one)`});let i=s.operand;if(i!==null&&typeof i=="object"&&!Array.isArray(i)){let a=Object.keys(i),d=i.derived;(!(e.operand_forms?.includes("derived")??!1)||a.length!==1||a[0]!=="derived"||typeof d!="string"||!d.trim())&&n.push({code:"BAD_CHECK",detail:`${t}: object operand is only the count derivation form {derived: "<how the runtime value is computed>"}`})}return n}function m(r,s){let t=u[r];if(!t)return[{code:"UNKNOWN_LABEL",detail:`unknown node label ${JSON.stringify(r)}`}];let n=[];for(let e of Object.keys(s))s[e]!==void 0&&!t.hashed.includes(e)&&!(t.unhashed??[]).includes(e)&&n.push({code:"UNKNOWN_FIELD",detail:`${r}.${e} is not in the ${l} schema`});for(let e of t.required)(s[e]===void 0||s[e]===null)&&n.push({code:"MISSING_FIELD",detail:`${r}.${e} is required`});for(let[e,o]of Object.entries(t.enums)){let i=s[e];i!==void 0&&!o.includes(i)&&n.push({code:"BAD_ENUM",detail:`${r}.${e} ${JSON.stringify(i)} not in ${o.join("|")}`})}if(r==="test"&&s.check&&typeof s.check=="object"){let e=s.check;n.push(...c(e.kind,e,"test.check"))}if(r==="ac"&&s.expected_answer&&typeof s.expected_answer=="object"){let e=s.expected_answer;n.push(...c(s.kind??e.kind,e,"ac.expected_answer"))}return n}function p(r){return f[r]}function S(r,s,t,n){let e=p(r);if(!e)return[{code:"UNKNOWN_EDGE_TYPE",detail:`unknown edge type ${JSON.stringify(r)}`}];let o=[];e.src.includes(s)||o.push({code:"ILLEGAL_EDGE",detail:`${r} src must be ${e.src.join("|")}, got ${s}`}),e.dst.includes(t)||o.push({code:"ILLEGAL_EDGE",detail:`${r} dst must be ${e.dst.join("|")}, got ${t}`}),r==="depends_on"&&s!==t&&o.push({code:"ILLEGAL_EDGE",detail:`depends_on links same-label nodes only, got ${s}\u2192${t}`});for(let i of e.salient)(n[i]===void 0||n[i]===null)&&o.push({code:"MISSING_SALIENT",detail:`${r}.props.${i} is salient (inside the ecid) and required`});for(let i of Object.keys(n))n[i]!==void 0&&(e.props.includes(i)||o.push({code:"UNKNOWN_EDGE_PROP",detail:`${r}.props.${i} is not in the ${l} schema`}));return o}function k(r,s){let t=u[r];if(!t)return s;let n={};for(let e of t.hashed)s[e]!==void 0&&(n[e]=s[e]);return n}function N(r,s){let t=p(r);if(!t)return s;let n={};for(let e of t.salient)s[e]!==void 0&&(n[e]=s[e]);return n}export{l as a,u as b,f as c,y as d,h as e,m as f,p as g,S as h,k as i,N as j};
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as u,c as p}from"./chunk-WUMNIGPR.js";import{spawn as m}from"child_process";var y=new Set(["progress","ask_user","graph_query","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete"]);function v(l,s={}){let a=s.spawnCmd!==void 0?s.spawnCmd:u();if(!a)throw new Error("assurance-agent not found \u2014 expected an npm platform package, a sibling assurance-agent/dist binary, or assurance-agent/main.py (dev)");let n=m(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(l.session_id,s.auth)});if(n.stdin.write(JSON.stringify(l)+`
3
+ `),s.onStderr){let e="";n.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
4
+ `))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&s.onStderr(o)}})}let g=new Promise(e=>{n.on("exit",(r,i)=>e({code:r,signal:i}))});async function*f(){let e="",r=!1;for await(let i of n.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
5
+ `))>=0;){let d=e.slice(0,o).trim();if(e=e.slice(o+1),!d)continue;let c;try{c=JSON.parse(d)}catch{s.onWarn?.(`agent: skipping malformed line: ${d.slice(0,120)}`);continue}let t=c;if(!t||typeof t!="object"||!y.has(t.type)){s.onWarn?.(`agent: skipping unknown event type "${t&&typeof t=="object"?String(t.type??"?"):"?"}"`);continue}if(yield t,t.type==="done"){r=!0;break}}if(r)break}await g.catch(()=>{})}return{events:f(),send:e=>{n.stdin&&!n.stdin.destroyed&&n.stdin.write(JSON.stringify(e)+`
6
+ `)},kill:()=>{n.kill("SIGTERM")},exited:g}}export{v as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{w as s}from"./chunk-LRKWPAGK.js";function n(r="prod"){let e=s[r];return r!=="stage"?e:{authBaseUrl:process.env.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:process.env.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:process.env.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:process.env.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:process.env.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:process.env.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:process.env.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:process.env.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:process.env.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost}}export{n as a};
2
+ import{w as s}from"./chunk-MKD3KZPM.js";function n(r="prod"){let e=s[r];return r!=="stage"?e:{authBaseUrl:process.env.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:process.env.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:process.env.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:process.env.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:process.env.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:process.env.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:process.env.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:process.env.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:process.env.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost,evidenceViewerUrl:process.env.KANE_STAGE_EVIDENCE_VIEWER_URL??e.evidenceViewerUrl}}export{n as a};
@@ -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{g as a}from"./chunk-LOIRZFV3.js";import{a as m}from"./chunk-LPUQ4HWQ.js";import{a as h}from"./chunk-RB2YKN77.js";import{a as y}from"./chunk-KKIFXAJY.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{h as a}from"./chunk-M5JQXOCE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-INP7FG6V.js";import{a as h}from"./chunk-OXARXMMD.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-QCHKMPCM.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-OCFALJ7U.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}
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{appendFileSync as o,existsSync as u,mkdirSync as g,readFileSync as p}from"fs";import{join as d}from"path";function m(e,n){g(e,{recursive:!0}),o(d(e,"signals.ndjson"),JSON.stringify(n)+`
3
+ `)}function v(e,n){switch(n){case"approved":return[{...e,verdict:"approved",polarity:"preference"}];case"rejected":return[{...e,verdict:"rejected",polarity:"preference"},{...e,verdict:"rejected",polarity:"mistake",tag:"wrong-uc-inference"}];case"edited":return[{...e,verdict:"edited",polarity:"correction"}];case"supersede":return[{...e,verdict:"supersede",polarity:"preference"},{...e,verdict:"supersede",polarity:"correction",tag:"superseded-prior-version"}];case"skipped":return[]}}function S(e,n){let r=(t,i,s,c)=>({...n,id:s,verdict:t,polarity:i,...c!==void 0?{tag:c}:{},event_id:e.eventId,target:s});switch(e.kind){case"approve":return[r("approve","preference",e.target)];case"edit":return[r("edit","preference",e.target),r("edit","correction",e.target)];case"enhance":return[r("enhance","preference",e.target)];case"reject":{let t=[r("reject","preference",e.target),r("reject","mistake",e.target,"wrong-uc-inference")];return e.redirectTo!==void 0&&t.push(r("dedup_dropped","correction",e.target),r("dedup_kept","preference",e.redirectTo)),t}case"add":return[];case"resolve_question":{if(e.resolution==="deferred")return[];if(e.resolution==="assumed-default")return[r("default_accepted","preference",e.questionId)];let t=e.answer?.optionIds?.[0]??(e.answer?.freeText!==void 0?"free-text":void 0),i=[r("gap_resolution","preference",e.questionId,t)];return e.overrodeRecommendation&&i.push(r("default_overridden","correction",e.questionId,t)),i}}}function y(e,n){let r=d(e,"signals.ndjson");if(!u(r))return{signals:[],watermark:0};let t=p(r),i=t.lastIndexOf(10),s=i===-1?0:i+1;n!==void 0&&n<s&&(s=n);let c=[];for(let a of t.subarray(0,s).toString("utf8").split(`
4
+ `))if(a.trim())try{c.push(JSON.parse(a))}catch{}return{signals:c,watermark:s}}export{m as a,v as b,S as c,y as d};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as o}from"./chunk-B2PZAB7J.js";import{existsSync as c,mkdirSync as f,readFileSync as u,renameSync as l,writeFileSync as g}from"fs";import{dirname as p,join as a}from"path";function i(t,r){let n=r.startsWith("sha256:")?r.slice(7):r;return a(t,"blobs",n.slice(0,2),n.slice(2))}function B(t,r){return i(t,r)}function m(t){let r=Buffer.concat([Buffer.from("assurance.blob\0","utf8"),t]);return"sha256:"+o(r)}function d(t,r){let n=m(r),e=i(t,n);if(!c(e)){f(p(e),{recursive:!0});let s=`${e}.tmp-${process.pid}`;g(s,r),l(s,e)}return n}function S(t,r){let n=i(t,r);return c(n)?u(n):null}export{B as a,m as b,d as c,S as d};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as i,b as s}from"./chunk-L5LI2JF4.js";import{existsSync as o,mkdirSync as l,readFileSync as c,writeFileSync as g}from"fs";import{dirname as u,join as m}from"path";function a(t,r){let e=r.startsWith("sha256:")?r.slice(7):r;return m(t,"design","rationale",`${e}.yaml`)}function h(t,r,e){let n=a(t,r);return l(u(n),{recursive:!0}),g(n,s(e,{sortKeys:!0,lineWidth:-1})),n}function y(t,r){let e=a(t,r);return o(e)?i(c(e,"utf8")):null}export{h as a,y as b};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as S}from"./chunk-QK6KZMYG.js";import{x as o}from"./chunk-MKD3KZPM.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(r=>r.kind==="replay").length,l=e.decisions.filter(r=>r.kind==="author").length,p=e.outcomes.filter(r=>r.status==="passed").length,d=e.outcomes.filter(r=>r.status==="failed").length,f=e.outcomes.filter(r=>r.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let s=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${d} failed, ${f} skipped)`,T=`${t} replay \xB7 ${l} author`,C=e.retryTriggered,_="yes \u2014 run recovered after a replay miss",u,h=o.dim;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",h=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let r=e.uploadResult?.testcaseId;u=r?`\u2713 pushed (testcase=${r})`:"\u2713 pushed",h=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:s},breakdown:T,showRetries:C,retriesText:_,commitText:u,commitColor:h,artifactsText:v,uploadText:m,uploadColor:g}}function O(e){let t=e.decisions.filter(s=>s.kind==="replay").length,l=e.decisions.filter(s=>s.kind==="author").length,p=e.outcomes.filter(s=>s.status==="passed").length,d=e.outcomes.filter(s=>s.status==="failed").length,f=e.outcomes.filter(s=>s.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:p,failed:d,skipped:f,replay_decisions:t,author_decisions:l},retries:{triggered:e.retryTriggered},commit:{committed:n,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),l=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&l.push({label:"retries",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),l.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),l.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),l.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:l})}function I({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let l=setTimeout(()=>t(),50);return()=>clearTimeout(l)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,O as b,D as c,I as d};