@testmuai/kane-cli 0.4.7 → 0.4.8

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 (76) hide show
  1. package/dist/{ChromeProfilePicker-HZP2G3K4.js → ChromeProfilePicker-B2PUH2LL.js} +1 -1
  2. package/dist/{CliFeedbackPrompt-FTEA5JNK.js → CliFeedbackPrompt-647ESLIL.js} +1 -1
  3. package/dist/{CliUploadProgress-3OPVLWXH.js → CliUploadProgress-U325KQO6.js} +1 -1
  4. package/dist/{ConfigView-NMRRHEMR.js → ConfigView-NKD7QMUV.js} +1 -1
  5. package/dist/FolderPicker-2LEIB5F5.js +2 -0
  6. package/dist/{HelpView-RIRNOKNM.js → HelpView-35KKWQVE.js} +1 -1
  7. package/dist/{InfoBox-AXNZSJME.js → InfoBox-OIZ3APE3.js} +1 -1
  8. package/dist/{LinksBox-PYJZFOAG.js → LinksBox-DLIYPE3S.js} +1 -1
  9. package/dist/{ProfilesView-BVR2IFBT.js → ProfilesView-CFYBJIL4.js} +1 -1
  10. package/dist/{ProjectPicker-3FZJ4RK3.js → ProjectPicker-ASHXV4HU.js} +1 -1
  11. package/dist/{SaveSessionPrompt-INCEUNPR.js → SaveSessionPrompt-ATKVPQEJ.js} +1 -1
  12. package/dist/SingleShotApp-JYKEW3WS.js +2 -0
  13. package/dist/{SummaryBox-FMDQB4GN.js → SummaryBox-AAXB55TE.js} +1 -1
  14. package/dist/TestMdRunView-U35UBFHZ.js +2 -0
  15. package/dist/{WhoamiView-JLEFXOHP.js → WhoamiView-TRGZE2NZ.js} +1 -1
  16. package/dist/{changelog-O5IX7XHA.js → changelog-JBGYPN7J.js} +1 -1
  17. package/dist/{chunk-ACIVGK3W.js → chunk-25YRWDQ7.js} +1 -1
  18. package/dist/{chunk-2TAGK72D.js → chunk-3PISMPFM.js} +1 -1
  19. package/dist/{chunk-GRFHOT5X.js → chunk-5VZSCQXN.js} +1 -1
  20. package/dist/{chunk-V7ONIYZZ.js → chunk-AD6DPSIZ.js} +1 -1
  21. package/dist/{chunk-XBL2ZPYQ.js → chunk-ALF5ETLD.js} +1 -1
  22. package/dist/{chunk-DPWUXRRO.js → chunk-BGXAW2B5.js} +1 -1
  23. package/dist/{chunk-5W225L2A.js → chunk-C2E2DKY3.js} +1 -1
  24. package/dist/{chunk-467Q6LTP.js → chunk-CL5SB2I7.js} +1 -1
  25. package/dist/{chunk-2H3DN3F5.js → chunk-CVC6MQN6.js} +1 -1
  26. package/dist/{chunk-HFRJE27Y.js → chunk-DMLJUTQO.js} +1 -1
  27. package/dist/{chunk-7DJANARQ.js → chunk-EAUU5F4P.js} +1 -1
  28. package/dist/{chunk-OXHG2VIS.js → chunk-F5ZL4XYL.js} +1 -1
  29. package/dist/{chunk-WJRZKLUW.js → chunk-F6VA5YBJ.js} +3 -3
  30. package/dist/{chunk-KWGOSWHO.js → chunk-GRIQ4OQL.js} +1 -1
  31. package/dist/{chunk-JPJFIOL7.js → chunk-HZUTFC3G.js} +1 -1
  32. package/dist/chunk-IT2GFEFH.js +5 -0
  33. package/dist/{chunk-NXAP7EWY.js → chunk-IXYUSFH2.js} +2 -2
  34. package/dist/{chunk-SX3MRVIA.js → chunk-K266M5ZM.js} +1 -1
  35. package/dist/{chunk-ZHQVKKQZ.js → chunk-LY3DAHNE.js} +2 -2
  36. package/dist/{chunk-Y7Q7OG2K.js → chunk-LZEYE2WE.js} +1 -1
  37. package/dist/{chunk-YVYIWAPJ.js → chunk-RBG4VTHQ.js} +1 -1
  38. package/dist/{chunk-AVEPDV55.js → chunk-SH5FUG47.js} +1 -1
  39. package/dist/{chunk-PGKK7FRX.js → chunk-SRQ7P3WI.js} +1 -1
  40. package/dist/{chunk-YIZ6D6YX.js → chunk-SSPIKPHV.js} +1 -1
  41. package/dist/{chunk-6F5KNQEY.js → chunk-SVZUJ2QE.js} +1 -1
  42. package/dist/{chunk-JFSBM4Z2.js → chunk-UR4NSWY7.js} +1 -1
  43. package/dist/{chunk-DTFX3TMY.js → chunk-UVOM74DG.js} +14 -14
  44. package/dist/{chunk-PI6BJEFB.js → chunk-W67JBBQF.js} +2 -2
  45. package/dist/{chunk-4DRZNE2I.js → chunk-WKS4ST3B.js} +1 -1
  46. package/dist/{chunk-VVPV3NA5.js → chunk-WZ6GNXM3.js} +1 -1
  47. package/dist/chunk-XCMNFMSO.js +8 -0
  48. package/dist/{chunk-YTWM34XC.js → chunk-YJVA6LBY.js} +1 -1
  49. package/dist/{chunk-KHDW3N76.js → chunk-YYSABHRE.js} +1 -1
  50. package/dist/{chunk-5QBGINQ5.js → chunk-ZQ5IPBXJ.js} +1 -1
  51. package/dist/{chunk-QLSRT65Q.js → chunk-ZQPTSSU6.js} +1 -1
  52. package/dist/{chunk-JSHGADRY.js → chunk-ZRGEUDG5.js} +1 -1
  53. package/dist/{generate-headless-J2Z5B3A5.js → generate-headless-VB52MM2A.js} +2 -2
  54. package/dist/index.js +32 -32
  55. package/dist/{list-commands-UD7CKE46.js → list-commands-X6EXASQG.js} +1 -1
  56. package/dist/login-flow-R5IGUIPA.js +2 -0
  57. package/dist/{persist-recorded-session-W44GRYTY.js → persist-recorded-session-EI4ISSRI.js} +1 -1
  58. package/dist/{recording-banner-I7W76JOM.js → recording-banner-BQQSRJIF.js} +1 -1
  59. package/dist/{require-project-folder-R746X2BU.js → require-project-folder-LSM4YSKJ.js} +1 -1
  60. package/dist/{run-test-md-NZ32YJC7.js → run-test-md-VR2Q46Q3.js} +3 -3
  61. package/dist/{skill-installer-GXQ6LRHC.js → skill-installer-JS7LUETO.js} +1 -1
  62. package/dist/tcg-generate-YQJZTSSI.js +2 -0
  63. package/dist/testmd-actions-FAQYABQT.js +2 -0
  64. package/dist/token-refresh-XM3DXY2A.js +2 -0
  65. package/dist/{validate-basic-SYV4FFMJ.js → validate-basic-W7UJ5D25.js} +1 -1
  66. package/dist/{version-check-6EDCR423.js → version-check-ACQ5Z7JV.js} +1 -1
  67. package/package.json +6 -6
  68. package/dist/FolderPicker-3YHJUXE3.js +0 -2
  69. package/dist/SingleShotApp-QDTII55J.js +0 -2
  70. package/dist/TestMdRunView-FTWVR2DR.js +0 -2
  71. package/dist/chunk-PGBUS6CL.js +0 -8
  72. package/dist/chunk-RJW244F2.js +0 -5
  73. package/dist/login-flow-MCDTID4T.js +0 -2
  74. package/dist/tcg-generate-74IGNDXD.js +0 -2
  75. package/dist/testmd-actions-52KGXWZI.js +0 -2
  76. package/dist/token-refresh-4XAFVTGR.js +0 -2
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as l,d,e as m,f as g,g as S,k as y}from"./chunk-AH4AXJML.js";import{a as u}from"./chunk-PGBUS6CL.js";import{g as p,h as f}from"./chunk-LOIRZFV3.js";import{existsSync as s,mkdirSync as h,readFileSync as C,renameSync as w,writeFileSync as R}from"fs";import{join as x}from"path";function G(e){y(l(e));let r=l(e);if(!s(r))return;let n=x(r,"meta.json"),o=m(e);if(s(n)&&!s(o))try{h(d(e),{recursive:!0}),w(n,o)}catch(t){process.stderr.write(`warn: meta.json migration failed: ${t.message}
2
+ import{b as l,d,e as m,f as g,g as S,k as y}from"./chunk-AH4AXJML.js";import{a as u}from"./chunk-XCMNFMSO.js";import{g as p,h as f}from"./chunk-LOIRZFV3.js";import{existsSync as s,mkdirSync as h,readFileSync as C,renameSync as w,writeFileSync as R}from"fs";import{join as x}from"path";function G(e){y(l(e));let r=l(e);if(!s(r))return;let n=x(r,"meta.json"),o=m(e);if(s(n)&&!s(o))try{h(d(e),{recursive:!0}),w(n,o)}catch(t){process.stderr.write(`warn: meta.json migration failed: ${t.message}
3
3
  `)}let a=S(e);if(s(a)){let t="python";try{let i=new u().load();i.code_export?.language&&(t=i.code_export.language)}catch{}let c=g(e,"playwright",t);if(!s(c))try{w(a,c)}catch(i){process.stderr.write(`warn: generated-code migration failed: ${i.message}
4
4
  `)}}if(s(o))try{let t=JSON.parse(C(o,"utf8"));"md5sum"in t&&(delete t.md5sum,R(o,JSON.stringify(t,null,2)+`
5
5
  `,"utf8"))}catch(t){process.stderr.write(`warn: meta.json md5sum strip failed: ${t.message}
6
- `)}}async function O(e){if(!e.isInteractive)return{recovered:!1};if(E(e.creds))return{recovered:!1};let{SingleShotApp:r}=await import("./SingleShotApp-QDTII55J.js"),{ScrollbackProvider:n}=await import("./scrollback-6GINSTL2.js"),{render:o}=await import("./build-JIKYOZUH.js"),a=await import("./react-QWOAB3TB.js"),t={current:null},c={current:!1},{waitUntilExit:i,unmount:v}=o(a.default.createElement(n,null,a.default.createElement(r,{resultRef:t,mode:"login",loginCompleteRef:c})),{exitOnCtrlC:!1});f(()=>v()),await i();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),c.current?{recovered:!0}:(p(0,"Startup gate cancelled"),{recovered:!1})}function E(e){let r=e.getActiveProfile(),n=e.getDefaultEnv();if(!r||!!!(e.loadBasicAuth(r,n)||e.loadCredentials(r,n)))return!1;let a=e.loadProfileConfig(r,n)??{};return!!a.project_id&&!!a.folder_id}export{G as a,O as b};
6
+ `)}}async function O(e){if(!e.isInteractive)return{recovered:!1};if(E(e.creds))return{recovered:!1};let{SingleShotApp:r}=await import("./SingleShotApp-JYKEW3WS.js"),{ScrollbackProvider:n}=await import("./scrollback-6GINSTL2.js"),{render:o}=await import("./build-JIKYOZUH.js"),a=await import("./react-QWOAB3TB.js"),t={current:null},c={current:!1},{waitUntilExit:i,unmount:v}=o(a.default.createElement(n,null,a.default.createElement(r,{resultRef:t,mode:"login",loginCompleteRef:c})),{exitOnCtrlC:!1});f(()=>v()),await i();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),c.current?{recovered:!0}:(p(0,"Startup gate cancelled"),{recovered:!1})}function E(e){let r=e.getActiveProfile(),n=e.getDefaultEnv();if(!r||!!!(e.loadBasicAuth(r,n)||e.loadCredentials(r,n)))return!1;let a=e.loadProfileConfig(r,n)??{};return!!a.project_id&&!!a.folder_id}export{G as a,O as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-SX3MRVIA.js";import{b as D}from"./chunk-RJW244F2.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??"",l=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:l,headline:e.headline,scenarios:e.scenarios}}),l&&U(l)){let r=l.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,l=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(),l),h;try{h=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),!h.ok){e.signal.removeEventListener("abort",a);let w=await oe(h);if(h.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(h.status,w)}if(!h.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let g=h.body.getReader(),m=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await g.cancel().catch(()=>{});return}let{done:w,value:s}=await g.read();if(w)break;b+=m.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
2
+ import{a as $}from"./chunk-K266M5ZM.js";import{b as D}from"./chunk-IT2GFEFH.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??"",l=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:l,headline:e.headline,scenarios:e.scenarios}}),l&&U(l)){let r=l.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,l=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(),l),h;try{h=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),!h.ok){e.signal.removeEventListener("abort",a);let w=await oe(h);if(h.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(h.status,w)}if(!h.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let g=h.body.getReader(),m=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await g.cancel().catch(()=>{});return}let{done:w,value:s}=await g.read();if(w)break;b+=m.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 d=ie(u);d&&(yield d)}}}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,l=!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,d){let y=q({requestId:s,objective:f});d&&(y=P(y,{type:"snapshot",data:d}),d.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 h(s,f){let u=new FormData;u.append("prompt",s.prompt),l=s.memoryEnhancement??!0,u.append("memory_enhancement",String(l)),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 d=s.projectId??e.projectId,y=s.folderId??e.folderId;d&&u.append("project_id",d),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 g(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),d=await p(u),y=d?.data??d,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function m(s,f,u){let d=new FormData;d.append("prompt",f),d.append("chat_enabled","true"),d.append("memory_enhancement",String(l)),u?.mappings&&d.append("mappings",JSON.stringify(u.mappings)),W(d,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:d});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 d;try{d=await u.clone().json()}catch{}throw x(u.status,d)}}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 d;try{d=await u.clone().json()}catch{}throw x(u.status,d)}}return{start:h,attach:g,chat:m,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 le=new Set([".txt",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),de=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=[],l=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),h=pe(c)?c:j(t,c);if(!ce(h)){n.push(`Not found: ${a}`);continue}let g;try{g=G(h)}catch{n.push(`Cannot resolve: ${a}`);continue}if(l.has(g))continue;let m;try{m=ae(g)}catch{n.push(`Cannot read: ${a}`);continue}if(!m.isFile()){n.push(`Not a file: ${a}`);continue}if(m.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(g).toLowerCase();if(!le.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(m.size>de){n.push(`Too large (>50MB): ${a}`);continue}g!==o&&!g.startsWith(p)&&i.push(`Outside working dir: ${a}`),l.add(g),r.push(g)}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:l,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:h}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let g=a.length?await p.upload(o,a,p.onUpload):[],m=r?p.buildMappings(t,l):void 0;return{promptText:t,mappings:m,attachments:g,warnings:h}}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,l=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([l]),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 m;try{m=await p.clone().json()}catch{}throw x(p.status,m)}let a=await p.json(),c=a?.data??a,h=c?.gemini_response?.uri,g=c?.gemini_response?.mimeType;if(!c?.file_key||!h){let m=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: [${m}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:h,mimeType:g??"application/octet-stream"}}async function tt(e,t,n,i={}){let l=[];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{l.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 l}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let l of e.matchAll(ye)){let r=Number(l[2]),o=Number(l[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 h=a[c];h&&(i[`s${r}.c${c+1}`]=String(h.id))}}for(let l of e.matchAll(be)){let r=Number(l[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 l=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:l})}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 l=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(l,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],h=new Map;for(let m of e.scenarios){let b=(m.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(m.scode))??T(m.sid)??`s${m.id}`,s=h.get(w)??new Set;h.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",d=`${u}_test.md`;for(let y=2;s.has(d);y++)d=`${u}-${y}_test.md`;s.add(d),c.push({dir:w,file:d,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let g=xe(_(t,".tcg-tmp-"));try{N(_(g,"helpers"),{recursive:!0}),ee(_(g,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let m=[],b=new Set;for(let s of c){let f=_(g,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),m.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(g,a);let w=m.map(s=>s.replace(g,a));return{suiteDir:a,paths:w}}catch(m){try{te(g,{recursive:!0,force:!0})}catch{}throw m}}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,l)=>{t.push(`${l+1}. ${i.step}`)})),t.join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{x as o}from"./chunk-DPWUXRRO.js";import{a as m}from"./chunk-HCBYKLMW.js";import{a as e,b as i}from"./chunk-C44QQJR4.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:o.muted,error:o.red,success:o.green,info:o.orange,warning:o.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?o.orange:s[n]);return(0,r.jsxs)(e,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(e,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(e,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=o.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(e,{children:[(0,r.jsx)(e,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(e,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(e,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
2
+ import{x as o}from"./chunk-BGXAW2B5.js";import{a as m}from"./chunk-HCBYKLMW.js";import{a as e,b as i}from"./chunk-C44QQJR4.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:o.muted,error:o.red,success:o.green,info:o.orange,warning:o.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?o.orange:s[n]);return(0,r.jsxs)(e,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(e,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(e,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=o.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(e,{children:[(0,r.jsx)(e,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(e,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(e,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{d as s,j as l}from"./chunk-BGXAW2B5.js";import{readFileSync as g,writeFileSync as o,mkdirSync as i,existsSync as p}from"fs";import{dirname as a}from"path";var n={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:l,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"visual",network_ws:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0},c=class{constructor(r=s){this.path=r}exists(){return p(this.path)}load(){try{let r=g(this.path,"utf-8"),e=JSON.parse(r);return{...n,...e,code_export:{...n.code_export,...e.code_export??{}},generate:{...n.generate,...e.generate??{}}}}catch{return{...n,code_export:{...n.code_export},generate:{...n.generate}}}}set(r,e){try{let t=this.load();t[r]=e,i(a(this.path),{recursive:!0}),o(this.path,JSON.stringify(t,null,2)+`
3
+ `)}catch(t){let d=t instanceof Error?t.message:String(t);process.stderr.write(`[config] Failed to save config: ${d}
4
+ `)}}save(r){try{let t={...this.load(),...r};i(a(this.path),{recursive:!0}),o(this.path,JSON.stringify(t,null,2)+`
5
+ `)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`[config] Failed to save config: ${t}
6
+ `)}}writeRaw(r){try{i(a(this.path),{recursive:!0}),o(this.path,JSON.stringify(r,null,2)+`
7
+ `)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`[config] Failed to save config: ${t}
8
+ `)}}};export{c as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as We}from"./chunk-RJW244F2.js";import{a as ue,b as Te}from"./chunk-JFSBM4Z2.js";import{d as Ke,f as xe}from"./chunk-LOIRZFV3.js";import{a as Ue}from"./chunk-Y7Q7OG2K.js";import{a as qe}from"./chunk-VVPV3NA5.js";import{b as Ge}from"./chunk-C6S4IEBC.js";import{x as l}from"./chunk-DPWUXRRO.js";import{a as D}from"./chunk-HCBYKLMW.js";import{a as u,b as s,i as Me,j as Ne,k as ye}from"./chunk-C44QQJR4.js";import{a as ce}from"./chunk-6YGTRKDT.js";import{e as k}from"./chunk-UR6MHSHU.js";var ee=k(ce(),1);var U=k(ce(),1);var A=k(ce(),1);function be(e,t){let r=null,a=(d,p)=>{for(let i=0;i<d.length;i++){let T=d[i],f=[...p,i];t(T)&&(r===null||f.length>r.length)&&(r=f),T.children&&T.children.length>0&&a(T.children,f)}};return a(e,[]),r}function Se(e,t,r){if(t.length===0)return[...e];let a=t[0],d=[...e],p=d[a];if(t.length===1)d[a]=r(p);else{let i=t.slice(1),T=Se(p.children??[],i,r);d[a]={...p,children:T}}return d}function _e(e){let t=e.indexOf(": ");return t>0&&t<15?e.slice(t+2):e}function Le(e){return e.map(t=>{let r=t.children?Le(t.children):t.children;return t.status==="running"?{...t,status:"stopped",phase:void 0,children:r}:r!==t.children?{...t,children:r}:t})}function He(e,t,r,a,d){let[p,i]=(0,A.useState)(!1),[T,f]=(0,A.useState)([]),[$,h]=(0,A.useState)(null),[M,N]=(0,A.useState)(null),[C,v]=(0,A.useState)(null),[I,E]=(0,A.useState)(null),[V,Q]=(0,A.useState)([]),[se,ie]=(0,A.useState)(null),[ne,ae]=(0,A.useState)(void 0),G=(0,A.useRef)(null),W=(0,A.useRef)(null),Y=(0,A.useRef)(0),me=(0,A.useRef)(!1),Re=(0,A.useCallback)(async(Z,b)=>{let y=G.current;if(y){try{await y.exited}catch{}G.current=null}f([]),h(null),N(null),v(null),E(null),Q([]),ie(null),ae(Z.max_steps),i(!0),W.current=null,Y.current=0;let x;try{x=We(Z,b)}catch(g){v(g instanceof Error?g.message:String(g)),i(!1);return}G.current=x,Ke("runner",()=>x.cancel()),(async()=>{me.current=!1;let g=!1;for await(let n of x.events){if(me.current)break;switch(n.type){case"run_start":if(n.child_id)break;if(W.current&&!W.current.isSingleFlow){let B=Y.current;Y.current++,f(O=>O.map((R,w)=>w===B?{...R,status:"running"}:R.status==="running"&&!R.children?.some(c=>c.status==="running")?{...R,status:R.children?.some(c=>c.status==="failed")?"failed":"passed"}:R))}break;case"bifurcation":{let B=n.flows??[],O=n.count??B.length,R={flows:B,isSingleFlow:n.is_single_flow??O<=1};E(R),W.current=R,Y.current=0,f(B.map((w,c)=>({index:c+1,objective:w??`Flow ${c+1}`,status:"pending"})));break}case"step_start":{t?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let B=n.index,O=n.objective??`Step ${B}`,R=n.child_id,w=W.current&&!W.current.isSingleFlow;if(R)f(c=>{let m=be(c,L=>L.branchChildId===R)??be(c,L=>L.status==="running");return m?Se(c,m,L=>{let F=(L.children??[]).map(H=>H.status==="running"&&H.childId===R?{...H,status:"stopped",phase:void 0}:H);return F.push({index:B,objective:O,status:"running",childId:R}),{...L,children:F}}):c});else if(w){let c=Math.max(0,Y.current-1);f(m=>{let L=[...m];if(c>=L.length)return m;let F={...L[c]},ge=[...F.children??[]].map(ve=>ve.status==="running"&&ve.childId===void 0?{...ve,status:"stopped",phase:void 0}:ve);return ge.push({index:B,objective:O,status:"running"}),F.children=ge,F.status="running",L[c]=F,L})}else f(c=>{let m=Le(c);return m.some(F=>F.index===B)?m.map(F=>F.index===B?{...F,status:"running",objective:O}:F):[...m,{index:B,objective:O,status:"running"}]});break}case"step_event":{t?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let B=n.child_id,O=W.current&&!W.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){Q(R=>[...R,n.checkpoint_count]);break}if(n.event==="replay_started"){ie({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&r?.(n.detail),B){let R=c=>{if(c.index!==n.index||c.childId!==B)return c;let m={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(m.objective=n.detail),n.action_type&&(m.actionType=n.action_type),{...c,...m}},w=c=>c.map(m=>{let L=R(m);return L!==m?L:m.children&&m.children.length>0?{...m,children:w(m.children)}:m});f(c=>c.map(m=>m.children?{...m,children:w(m.children)}:m))}else if(O){let R=Math.max(0,Y.current-1);f(w=>{let c=[...w];if(R>=c.length)return w;let m={...c[R]},L=[...m.children??[]];if(!L.some(H=>H.index===n.index&&H.childId===void 0))L.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let H=0;H<L.length;H++){if(L[H].index!==n.index||L[H].childId!==void 0)continue;let ge={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(ge.objective=n.detail),n.action_type&&(ge.actionType=n.action_type),L[H]={...L[H],...ge}}return m.children=L,c[R]=m,c})}else f(R=>R.some(c=>c.index===n.index)?R.map(c=>{if(c.index!==n.index)return c;let m={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(m.objective=n.detail),n.action_type&&(m.actionType=n.action_type),{...c,...m}}):[...Le(R),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{t?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),a?.();let B=n.child_id,O=W.current&&!W.current.isSingleFlow;if(B){let R=c=>c.index===n.index&&c.childId===B?{...c,status:n.status,duration:n.duration,phase:void 0,objective:c.objective.startsWith("Step ")?_e(n.summary||c.objective):c.objective}:c,w=c=>c.map(m=>{let L=R(m);return L!==m?L:m.children&&m.children.length>0?{...m,children:w(m.children)}:m});f(c=>c.map(m=>m.children?{...m,children:w(m.children)}:m))}else if(O){let R=Math.max(0,Y.current-1);f(w=>{let c=[...w];if(R>=c.length)return w;let m={...c[R]},L=(m.children??[]).map(F=>F.index===n.index&&F.childId===void 0?{...F,status:n.status,duration:n.duration,phase:void 0,objective:F.objective.startsWith("Step ")?_e(n.summary||F.objective):F.objective}:F);return m.children=L,c[R]=m,c})}else f(R=>R.map(w=>w.index===n.index?{...w,status:n.status,duration:n.duration,phase:void 0,objective:w.objective.startsWith("Step ")?_e(n.summary||w.objective):w.objective}:w));{let w=W.current&&!W.current.isSingleFlow?Math.max(0,Y.current-1):0;e?.(n.index,w,n.child_id)}break}case"child_agent_start":{let B=n.objective??"",O=n.child_id;f(R=>{let w=be(R,c=>c.status==="running");return w?Se(R,w,c=>({...c,objective:`${B} (branch)`,phase:`child: ${B.slice(0,50)}`,branchObjective:B,branchChildId:O})):R});break}case"child_agent_end":{let B=n.child_id,O=`child ${n.success?"done":"failed"}`;f(R=>{let w=be(R,c=>c.branchChildId===B);return w?Se(R,w,c=>({...c,phase:O})):R.map(c=>c.phase?.startsWith("child:")?{...c,phase:O}:c)});break}case"describe_trigger":d?.(n);break;case"ask_user":h(n.question??"");break;case"run_end":f(B=>B.map(O=>O.status==="running"?{...O,status:n.status,phase:void 0}:O)),i(!1),N(n),g=!0;break;case"error":i(!1),v(n.message??"Runner error"),f(B=>B.map(O=>O.status==="running"?{...O,status:"failed",phase:void 0}:O));break}}let{code:S,signal:P}=await x.exited,_=x.stderr,le=S===0&&!P,oe=[];S!==null&&S!==0&&oe.push(`Runner exited with code ${S}`),P&&oe.push(`Runner killed by signal ${P}`),_&&(!le||!g?oe.push(_):b?.log?.("debug","RUNNER_STDERR_BENIGN","Runner stderr on clean exit",{stderr:_})),G.current===x&&(oe.length>0&&v(oe.join(`
2
+ import{b as We}from"./chunk-IT2GFEFH.js";import{a as ue,b as Te}from"./chunk-UR4NSWY7.js";import{d as Ke,f as xe}from"./chunk-LOIRZFV3.js";import{a as Ue}from"./chunk-LZEYE2WE.js";import{a as qe}from"./chunk-WZ6GNXM3.js";import{b as Ge}from"./chunk-C6S4IEBC.js";import{x as l}from"./chunk-BGXAW2B5.js";import{a as D}from"./chunk-HCBYKLMW.js";import{a as u,b as s,i as Me,j as Ne,k as ye}from"./chunk-C44QQJR4.js";import{a as ce}from"./chunk-6YGTRKDT.js";import{e as k}from"./chunk-UR6MHSHU.js";var ee=k(ce(),1);var U=k(ce(),1);var A=k(ce(),1);function be(e,t){let r=null,a=(d,p)=>{for(let i=0;i<d.length;i++){let T=d[i],f=[...p,i];t(T)&&(r===null||f.length>r.length)&&(r=f),T.children&&T.children.length>0&&a(T.children,f)}};return a(e,[]),r}function Se(e,t,r){if(t.length===0)return[...e];let a=t[0],d=[...e],p=d[a];if(t.length===1)d[a]=r(p);else{let i=t.slice(1),T=Se(p.children??[],i,r);d[a]={...p,children:T}}return d}function _e(e){let t=e.indexOf(": ");return t>0&&t<15?e.slice(t+2):e}function Le(e){return e.map(t=>{let r=t.children?Le(t.children):t.children;return t.status==="running"?{...t,status:"stopped",phase:void 0,children:r}:r!==t.children?{...t,children:r}:t})}function He(e,t,r,a,d){let[p,i]=(0,A.useState)(!1),[T,f]=(0,A.useState)([]),[$,h]=(0,A.useState)(null),[M,N]=(0,A.useState)(null),[C,v]=(0,A.useState)(null),[I,E]=(0,A.useState)(null),[V,Q]=(0,A.useState)([]),[se,ie]=(0,A.useState)(null),[ne,ae]=(0,A.useState)(void 0),G=(0,A.useRef)(null),W=(0,A.useRef)(null),Y=(0,A.useRef)(0),me=(0,A.useRef)(!1),Re=(0,A.useCallback)(async(Z,b)=>{let y=G.current;if(y){try{await y.exited}catch{}G.current=null}f([]),h(null),N(null),v(null),E(null),Q([]),ie(null),ae(Z.max_steps),i(!0),W.current=null,Y.current=0;let x;try{x=We(Z,b)}catch(g){v(g instanceof Error?g.message:String(g)),i(!1);return}G.current=x,Ke("runner",()=>x.cancel()),(async()=>{me.current=!1;let g=!1;for await(let n of x.events){if(me.current)break;switch(n.type){case"run_start":if(n.child_id)break;if(W.current&&!W.current.isSingleFlow){let B=Y.current;Y.current++,f(O=>O.map((R,w)=>w===B?{...R,status:"running"}:R.status==="running"&&!R.children?.some(c=>c.status==="running")?{...R,status:R.children?.some(c=>c.status==="failed")?"failed":"passed"}:R))}break;case"bifurcation":{let B=n.flows??[],O=n.count??B.length,R={flows:B,isSingleFlow:n.is_single_flow??O<=1};E(R),W.current=R,Y.current=0,f(B.map((w,c)=>({index:c+1,objective:w??`Flow ${c+1}`,status:"pending"})));break}case"step_start":{t?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let B=n.index,O=n.objective??`Step ${B}`,R=n.child_id,w=W.current&&!W.current.isSingleFlow;if(R)f(c=>{let m=be(c,L=>L.branchChildId===R)??be(c,L=>L.status==="running");return m?Se(c,m,L=>{let F=(L.children??[]).map(H=>H.status==="running"&&H.childId===R?{...H,status:"stopped",phase:void 0}:H);return F.push({index:B,objective:O,status:"running",childId:R}),{...L,children:F}}):c});else if(w){let c=Math.max(0,Y.current-1);f(m=>{let L=[...m];if(c>=L.length)return m;let F={...L[c]},ge=[...F.children??[]].map(ve=>ve.status==="running"&&ve.childId===void 0?{...ve,status:"stopped",phase:void 0}:ve);return ge.push({index:B,objective:O,status:"running"}),F.children=ge,F.status="running",L[c]=F,L})}else f(c=>{let m=Le(c);return m.some(F=>F.index===B)?m.map(F=>F.index===B?{...F,status:"running",objective:O}:F):[...m,{index:B,objective:O,status:"running"}]});break}case"step_event":{t?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let B=n.child_id,O=W.current&&!W.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){Q(R=>[...R,n.checkpoint_count]);break}if(n.event==="replay_started"){ie({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&r?.(n.detail),B){let R=c=>{if(c.index!==n.index||c.childId!==B)return c;let m={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(m.objective=n.detail),n.action_type&&(m.actionType=n.action_type),{...c,...m}},w=c=>c.map(m=>{let L=R(m);return L!==m?L:m.children&&m.children.length>0?{...m,children:w(m.children)}:m});f(c=>c.map(m=>m.children?{...m,children:w(m.children)}:m))}else if(O){let R=Math.max(0,Y.current-1);f(w=>{let c=[...w];if(R>=c.length)return w;let m={...c[R]},L=[...m.children??[]];if(!L.some(H=>H.index===n.index&&H.childId===void 0))L.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let H=0;H<L.length;H++){if(L[H].index!==n.index||L[H].childId!==void 0)continue;let ge={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(ge.objective=n.detail),n.action_type&&(ge.actionType=n.action_type),L[H]={...L[H],...ge}}return m.children=L,c[R]=m,c})}else f(R=>R.some(c=>c.index===n.index)?R.map(c=>{if(c.index!==n.index)return c;let m={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(m.objective=n.detail),n.action_type&&(m.actionType=n.action_type),{...c,...m}}):[...Le(R),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{t?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),a?.();let B=n.child_id,O=W.current&&!W.current.isSingleFlow;if(B){let R=c=>c.index===n.index&&c.childId===B?{...c,status:n.status,duration:n.duration,phase:void 0,objective:c.objective.startsWith("Step ")?_e(n.summary||c.objective):c.objective}:c,w=c=>c.map(m=>{let L=R(m);return L!==m?L:m.children&&m.children.length>0?{...m,children:w(m.children)}:m});f(c=>c.map(m=>m.children?{...m,children:w(m.children)}:m))}else if(O){let R=Math.max(0,Y.current-1);f(w=>{let c=[...w];if(R>=c.length)return w;let m={...c[R]},L=(m.children??[]).map(F=>F.index===n.index&&F.childId===void 0?{...F,status:n.status,duration:n.duration,phase:void 0,objective:F.objective.startsWith("Step ")?_e(n.summary||F.objective):F.objective}:F);return m.children=L,c[R]=m,c})}else f(R=>R.map(w=>w.index===n.index?{...w,status:n.status,duration:n.duration,phase:void 0,objective:w.objective.startsWith("Step ")?_e(n.summary||w.objective):w.objective}:w));{let w=W.current&&!W.current.isSingleFlow?Math.max(0,Y.current-1):0;e?.(n.index,w,n.child_id)}break}case"child_agent_start":{let B=n.objective??"",O=n.child_id;f(R=>{let w=be(R,c=>c.status==="running");return w?Se(R,w,c=>({...c,objective:`${B} (branch)`,phase:`child: ${B.slice(0,50)}`,branchObjective:B,branchChildId:O})):R});break}case"child_agent_end":{let B=n.child_id,O=`child ${n.success?"done":"failed"}`;f(R=>{let w=be(R,c=>c.branchChildId===B);return w?Se(R,w,c=>({...c,phase:O})):R.map(c=>c.phase?.startsWith("child:")?{...c,phase:O}:c)});break}case"describe_trigger":d?.(n);break;case"ask_user":h(n.question??"");break;case"run_end":f(B=>B.map(O=>O.status==="running"?{...O,status:n.status,phase:void 0}:O)),i(!1),N(n),g=!0;break;case"error":i(!1),v(n.message??"Runner error"),f(B=>B.map(O=>O.status==="running"?{...O,status:"failed",phase:void 0}:O));break}}let{code:S,signal:P}=await x.exited,_=x.stderr,le=S===0&&!P,oe=[];S!==null&&S!==0&&oe.push(`Runner exited with code ${S}`),P&&oe.push(`Runner killed by signal ${P}`),_&&(!le||!g?oe.push(_):b?.log?.("debug","RUNNER_STDERR_BENIGN","Runner stderr on clean exit",{stderr:_})),G.current===x&&(oe.length>0&&v(oe.join(`
3
3
  `)),i(!1),xe("runner","Event stream ended"),G.current=null)})().catch(g=>{let S=[`Runner event loop error: ${g}`];x.exitCode!==null&&x.exitCode!==0&&S.push(`Exit code: ${x.exitCode}`),x.exitSignal&&S.push(`Signal: ${x.exitSignal}`),x.stderr&&S.push(x.stderr),G.current===x&&(v(S.join(`
4
4
  `)),i(!1),xe("runner","Event loop error"),G.current=null)})},[e,t,r,a,d]),re=(0,A.useCallback)(Z=>{G.current?.sendUserResponse(Z),h(null)},[]),Ce=(0,A.useCallback)(()=>{let Z=G.current;Z&&(Z.sendCancel("user"),i(!1),h(null),setTimeout(()=>{G.current===Z&&(xe("runner","User cancelled run"),G.current=null)},5e3))},[]),Pe=(0,A.useCallback)(()=>{f([]),N(null),v(null)},[]);return(0,A.useEffect)(()=>()=>{me.current=!0,xe("runner","Component unmounted"),G.current=null},[]),{isRunning:p,steps:T,askingUser:$,lastRunEnd:M,runError:C,bifurcationInfo:I,cmInitCounts:V,replayInfo:se,maxSteps:ne,startRun:Re,sendAnswer:re,cancelRun:Ce,clearLastRun:Pe}}function Oe(e){let t=e.flatMap(p=>[p,...p.children??[]]),r=t.filter(p=>p.status==="passed").length,a=t.filter(p=>p.status==="failed").length,d=t.filter(p=>p.status==="passed"||p.status==="failed").length;return{passed:r,failed:a,total:d}}function Ve(e){let t=He(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[r,a]=(0,U.useState)(0),[d,p]=(0,U.useState)("idle"),i=(0,U.useRef)("idle"),T=(0,U.useRef)(0),f=(0,U.useRef)(!1),$=(0,U.useRef)(null),h=(0,U.useRef)(null),M=(0,U.useCallback)(v=>{i.current=v,p(v)},[]),N=(0,U.useCallback)(async v=>{let I=await e.getNextConfig(v);if(!I){M("done"),e.onAllComplete?.();return}let E=v?T.current+1:0;T.current=E,a(E),e.onStepStart?.(I,E),$.current=null,h.current=null,M("running"),await t.startRun(I,e.spawnOpts)},[t,e,M]);(0,U.useEffect)(()=>{f.current||(f.current=!0,N(null))},[]),(0,U.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===$.current||i.current!=="running")return;$.current=t.lastRunEnd,i.current="transitioning",p("transitioning");let v=t.lastRunEnd,I=Oe(t.steps),E=t.bifurcationInfo,V={status:v.status==="passed"?"passed":"failed",duration_s:v.duration??0,reason:v.reason,runEnd:v,hadError:!1,stepsPassed:I.passed,stepsFailed:I.failed,stepsTotal:I.total,bifurcationFlows:E&&!E.isSingleFlow?E.flows:null};if(!(e.onStepEnd?.(V,T.current)??!0)){M("done"),e.onAllComplete?.();return}N(V)},[t.lastRunEnd]),(0,U.useEffect)(()=>{if(!t.runError||t.runError===h.current||t.lastRunEnd||i.current!=="running")return;h.current=t.runError,i.current="transitioning",p("transitioning");let v=Oe(t.steps),I={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:v.passed,stepsFailed:v.failed,stepsTotal:v.total,bifurcationFlows:null};if(!(e.onStepEnd?.(I,T.current)??!0)){M("done"),e.onAllComplete?.();return}N(I)},[t.runError,t.lastRunEnd]);let C=(0,U.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:r,phase:d,cancel:C}}var je=k(ce(),1);var Be=k(D(),1),ze=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Xe({label:e,hasBifurcation:t=!1}){let[r,a]=(0,je.useState)(0),[d,p]=(0,je.useState)(0);ue(()=>{a(T=>(T+1)%ze.length)},80),ue(()=>{p(T=>(T+1)%4)},400);let i=e??(t?"Planning approach":"Analyzing objective");return(0,Be.jsxs)(u,{marginLeft:1,children:[(0,Be.jsxs)(s,{color:l.orange,children:[ze[r]," "]}),(0,Be.jsxs)(s,{color:l.dim,children:[i,".".repeat(d+1)]})]})}function Ye(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let r=e.steps.findIndex(d=>d.status==="running");return(r===-1?e.cmInitCounts.length===0:r>=e.cmInitCounts.length)?{label:r>0?`Planning flow ${r+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(r=>r.children?.length)?null:{hasBifurcation:!!t}}var q=k(ce(),1);var Qe=k(ce(),1);var we=k(D(),1),lt="#ffc580",ct="#ffd9a8",Je="#ffffff";function Ie({text:e,active:t=!0}){let[r,a]=(0,Qe.useState)(0),d=4;if(ue(()=>{a(i=>(i+1)%(e.length+d*2))},t?80:null),!t)return(0,we.jsx)(s,{color:Je,children:e});let p=e.split("").map((i,T)=>{let f=r-d,$=Math.abs(T-f-d/2),h;return $<=d/2?h=lt:$<=d?h=ct:h=Je,(0,we.jsx)(s,{color:h,children:i},T)});return(0,we.jsx)(s,{children:p})}var J=k(D(),1),ut={starting:l.orange,running:l.orange,passed:l.green,failed:l.red,cancelled:l.dim,timed_out:l.orange};function $e({currentStep:e,maxSteps:t,elapsed:r,status:a}){let d=ut[a]??l.orange,p=r<60?`${r.toFixed(1)}s`:`${Math.floor(r/60)}m ${Math.round(r%60)}s`;return(0,J.jsxs)(u,{marginLeft:3,children:[(0,J.jsx)(s,{color:l.dim,children:"Steps "}),(0,J.jsx)(s,{bold:!0,children:e}),(0,J.jsxs)(s,{color:l.dim,children:["/",t]}),(0,J.jsx)(s,{children:" "}),(0,J.jsx)(s,{color:l.dim,children:"Elapsed "}),(0,J.jsx)(s,{bold:!0,children:p}),(0,J.jsx)(s,{children:" "}),(0,J.jsx)(s,{color:l.dim,children:"Status "}),(0,J.jsx)(s,{bold:!0,color:d,children:a})]})}var dt={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Ze(e){return dt[e]??"\u25CF"}var te=k(D(),1);function De({steps:e,flows:t,cmInitCounts:r,renderStep:a}){return(0,te.jsxs)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,te.jsxs)(s,{color:l.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((d,p)=>(0,te.jsxs)(u,{flexDirection:"column",marginTop:p>0?1:0,children:[(0,te.jsxs)(s,{color:l.orange,children:["Flow ",p+1,": ",t?.[p]??d.objective]}),r&&r[p]!=null&&(0,te.jsxs)(s,{color:l.dim,children:[" \u25AA Generated task with ",r[p]," checkpoints"]}),d.children&&d.children.length>0?d.children.map(i=>{let T=!!i.branchObjective,f=`f${p}-${i.childId??"p"}-${i.index}`;return T?(0,te.jsxs)(u,{flexDirection:"column",children:[a({...i,children:void 0},f),(i.children??[]).map($=>(0,te.jsx)(u,{marginLeft:2,children:a($,`${f}-${$.childId??"p"}-${$.index}`)},`${f}-${$.childId??"p"}-${$.index}`))]},`${f}-host`):a(i,f)}):d.status==="pending"&&(0,te.jsx)(s,{color:l.dim,children:" \u25CB Waiting..."})]},p))]})}var de=k(D(),1);function et({label:e,shimmer:t=!1}){return(0,de.jsxs)(u,{marginLeft:6,children:[(0,de.jsx)(Te,{}),(0,de.jsx)(s,{children:" "}),t?(0,de.jsx)(Ie,{text:e,active:!0}):(0,de.jsx)(s,{color:l.dim,children:e})]})}var tt=k(ce(),1);var Fe=k(D(),1);function pt(e,t){let r=[];for(let a of e.split(`
5
5
  `)){if(a===""){r.push("");continue}let d="";for(let p of a.split(" ")){let i=p;for(;i.length>t;)d&&(r.push(d),d=""),r.push(i.slice(0,t)),i=i.slice(t);d===""?d=i:d.length+1+i.length<=t?d+=" "+i:(r.push(d),d=i)}r.push(d)}return r}function nt({text:e,maxLines:t=3}){let{stdout:r}=ye(),a=Math.max(20,(r?.columns??80)-7),d=!e.trim(),[p,i]=(0,tt.useState)(!0);ue(()=>i($=>!$),500);let T=(d?"Thinking\u2026":e)+(p?"\u258C":" "),f=pt(T,a).slice(-t);for(;f.length<t;)f.push("");return(0,Fe.jsx)(u,{borderStyle:"round",borderColor:l.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:f.map(($,h)=>(0,Fe.jsx)(s,{color:d?l.dim:l.secondary,wrap:"truncate-end",children:$.length?$:" "},h))})}var pe=k(D(),1);function Ee({activity:e,describe:t,describeVisible:r}){return(0,pe.jsxs)(pe.Fragment,{children:[e?(0,pe.jsx)(et,{label:e.label,shimmer:e.shimmer}):null,r?(0,pe.jsx)(nt,{text:t??""}):null]})}var o=k(D(),1);function ke(e){for(let t of e){if(t.children&&t.children.length>0){let r=ke(t.children);if(r)return r}if(t.status==="running")return t}}function he(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function rt(e){let t=[];for(let r of e)he(r)||(r.children&&r.children.length>0?t.push({...r,children:rt(r.children)}):t.push(r));return t}function Ae(e,t){if(!e)return null;let r=e.objective??"";return r.length>0&&!/^Step \d+$/.test(r)?{label:r+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function K({step:e,indent:t=2}){let r=e.actionType?Ze(e.actionType):null,a=e.status==="running",d=e.status==="passed",p=e.status==="failed",i=e.status==="pending"||e.status==="stopped",{stdout:T}=ye(),f=T?.columns??80,$=Math.max(20,f-t-21),h=e.objective??"",M=h.length>$?h.slice(0,$-1)+"\u2026":h,N=(e.duration??0)*1e3,C=e.duration!=null?N<1e3?`${Math.round(N)}ms`:`${(N/1e3).toFixed(1)}s`:"";return(0,o.jsxs)(u,{flexDirection:"column",children:[(0,o.jsxs)(u,{marginLeft:t,children:[(0,o.jsx)(u,{width:4,children:(0,o.jsxs)(s,{color:l.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,o.jsx)(u,{width:3,children:a?(0,o.jsx)(Te,{}):d?(0,o.jsx)(s,{color:l.green,bold:!0,children:"\u2713"}):p?(0,o.jsx)(s,{color:l.red,bold:!0,children:"\u2717"}):(0,o.jsx)(s,{color:l.muted,children:"\u25CB"})}),(0,o.jsx)(u,{flexGrow:1,children:a?(0,o.jsx)(Ie,{text:M,active:!0}):p?(0,o.jsx)(s,{color:l.red,children:M}):i?(0,o.jsx)(s,{color:l.dim,children:M}):(0,o.jsx)(s,{color:l.dim,children:M})}),(d||p)&&r?(0,o.jsx)(u,{width:3,marginLeft:1,children:(0,o.jsx)(s,{color:l.muted,children:r})}):(0,o.jsx)(u,{width:3,marginLeft:1}),(0,o.jsx)(u,{width:7,justifyContent:"flex-end",children:(0,o.jsx)(s,{color:l.dim,children:C})})]}),e.children&&e.children.length>0&&(0,o.jsx)(u,{flexDirection:"column",children:e.children.map((v,I)=>(0,o.jsx)(K,{step:v,indent:t+2},`child-${I}`))})]})}function ft(e){return e.type==="cm_init"?(0,o.jsx)(u,{marginLeft:2,paddingLeft:1,children:(0,o.jsxs)(s,{color:l.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,o.jsx)(u,{marginLeft:2,paddingLeft:1,children:(0,o.jsx)(K,{step:e.step})})}function ot({steps:e,bifurcated:t,flows:r,cmInitCounts:a,maxSteps:d=50,staticSteps:p=!1,onStepCommit:i,describe:T,describeVisible:f,describeRevealing:$}){let h=(0,q.useRef)(new Set),M=(0,q.useRef)(!1),N=(0,q.useRef)(new Set),C=(0,q.useRef)(!1),v=(0,q.useRef)(new Set),I=(0,q.useRef)(0);(0,q.useEffect)(()=>{e.length===0&&I.current>0&&(h.current.clear(),M.current=!1,N.current.clear(),C.current=!1,v.current.clear()),I.current=e.length},[e.length]);let E=e.flatMap(b=>[b,...b.children??[]]),V=E.some(b=>b.status==="running"),Q=E.some(b=>b.status==="failed"),se=E.length===0||E.every(b=>b.status==="pending"),ie=E.filter(b=>b.status==="passed"||b.status==="failed").length,ne;se?ne="starting":V?ne="running":Q?ne="failed":ne="passed";let ae=(0,q.useRef)(null),[G,W]=(0,q.useState)(0);(0,q.useEffect)(()=>{E.length===0||se?(ae.current=null,W(0)):V&&ae.current==null&&(ae.current=Date.now())},[V,se,E.length]),(0,q.useEffect)(()=>{if(!V)return;let b=setInterval(()=>{ae.current!=null&&W((Date.now()-ae.current)/1e3)},500);return()=>clearInterval(b)},[V]);let Y=(0,q.useRef)(new Set),[,me]=(0,q.useState)(0),Re=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(!i||!p||t)return;let b=[];!Re.current&&a&&a[0]!=null&&(Re.current=!0,a[0]>0&&b.push({key:"cm_init_0",type:"cm_init",count:a[0]}));for(let y of e)(y.status==="passed"||y.status==="failed")&&!Y.current.has(y.index)&&(Y.current.add(y.index),b.push({key:`step_${y.index}`,type:"step",step:{...y,children:y.children?[...y.children]:void 0}}));if(b.length>0){for(let y of b)i(ft(y));me(y=>y+1)}},[e,t,a,p,i]),(0,q.useEffect)(()=>{if(!i||p)return;let b=h.current.size;if(!t&&!C.current&&a&&a[0]!=null&&(C.current=!0,a[0]>0&&i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsxs)(s,{color:l.dim,children:["\u25A0 Generated task with ",a[0]," checkpoints"]})}))),t&&r&&!M.current&&(M.current=!0,i((0,o.jsx)(s,{color:l.purple,children:"\u2501\u2501 Bifurcated into "+r.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let y=e.flatMap((x,g)=>{let S=x.children??[];return!N.current.has(g)&&S.length>0&&(N.current.add(g),i((0,o.jsx)(s,{color:l.purple,children:" Flow "+(g+1)+": "+(r?.[g]??"")})),a?.[g]!=null&&a[g]>0&&!v.current.has(g)&&(v.current.add(g),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsxs)(s,{color:l.dim,children:[" \u25AA Generated task with ",a[g]," checkpoints"]})})))),a?.[g]!=null&&a[g]>0&&N.current.has(g)&&!v.current.has(g)&&(v.current.add(g),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsxs)(s,{color:l.dim,children:[" \u25AA Generated task with ",a[g]," checkpoints"]})}))),S});for(let x of y){let g=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){h.current.has(g)||(h.current.add(g),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:{...x,children:void 0}})})));for(let P of x.children??[]){let _=`child-${x.childId??"p"}-${x.index}-${P.childId??"p"}-${P.index}-${P.objective}`;h.current.has(_)||(P.status==="passed"||P.status==="failed"||P.status==="stopped")&&(h.current.add(_),i((0,o.jsx)(u,{marginLeft:4,children:(0,o.jsx)(K,{step:P})})))}continue}h.current.has(g)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(h.current.add(g),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:x})})))}}else for(let y of e){let x=`${y.index}-${y.objective}`,g=!!y.branchObjective;g&&!h.current.has(x)&&(h.current.add(x),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:{...y,children:void 0}})})));for(let S of y.children??[]){let P=`child-${y.index}-${S.childId??"p"}-${S.index}-${S.objective}`;h.current.has(P)||(S.status==="passed"||S.status==="failed"||S.status==="stopped")&&(h.current.add(P),i((0,o.jsx)(u,{marginLeft:4,children:(0,o.jsx)(K,{step:S})})))}!g&&!h.current.has(x)&&(y.status==="passed"||y.status==="failed"||y.status==="stopped")&&(h.current.add(x),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:{...y,children:void 0}})})))}h.current.size>b&&me(y=>y+1)},[e,i,t,r,a]);let re=[];if(p&&!t)for(let b of e)Y.current.has(b.index)||re.push(b);else if(i&&!p)if(t)for(let b of e){let y=b.children??[],x=[];for(let g of y){let S=`${g.childId??"p"}-${g.index}-${g.objective}`,P=h.current.has(S);if(g.branchObjective){let _=(g.children??[]).filter(le=>{let oe=`child-${g.childId??"p"}-${g.index}-${le.childId??"p"}-${le.index}-${le.objective}`;return!h.current.has(oe)});(!P||_.length>0)&&x.push({...g,children:_})}else P||x.push(g)}x.length>0&&re.push({...b,children:x})}else for(let b of e){let y=`${b.index}-${b.objective}`,x=h.current.has(y),g=(b.children??[]).filter(S=>{let P=`child-${b.index}-${S.childId??"p"}-${S.index}-${S.objective}`;return!h.current.has(P)});x?g.length>0&&re.push({...b,children:g}):re.push({...b,children:g})}if(!p){let b=i?re:e,y=ke(b),x=Ae(y,$);return(0,o.jsxs)(u,{flexDirection:"column",children:[t?i?b.length>0?(0,o.jsx)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:b.map((S,P)=>(0,o.jsx)(u,{flexDirection:"column",marginTop:P>0?1:0,children:S.children&&S.children.length>0?S.children.map(_=>{if(he(_))return null;let le=!!_.branchObjective,oe=`${_.childId??"p"}-${_.index}-${_.objective}`,n=h.current.has(oe);return le?(0,o.jsxs)(u,{flexDirection:"column",children:[!n&&(0,o.jsx)(K,{step:{..._,children:void 0}}),(_.children??[]).filter(B=>!he(B)).map(B=>(0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:B})},`f${P}-${_.index}-${B.childId??"p"}-${B.index}`))]},`f${P}-host-${_.childId??"p"}-${_.index}`):(0,o.jsx)(K,{step:_},`f${P}-${_.childId??"p"}-${_.index}`)}):S.status==="pending"&&(0,o.jsx)(s,{color:l.dim,children:" \u25CB Waiting..."})},P))}):null:(0,o.jsx)(De,{steps:e,flows:r,cmInitCounts:a,renderStep:(S,P)=>he(S)?null:(0,o.jsx)(K,{step:S},P)}):(0,o.jsxs)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!i&&a&&a[0]!=null&&(0,o.jsxs)(s,{color:l.dim,children:["\u25AA Generated task with ",a[0]," checkpoints"]}),b.filter(S=>!(S.status==="running"&&(!S.children||S.children.length===0))).map(S=>{let P=`${S.index}-${S.objective}`;return i&&h.current.has(P)?(0,o.jsx)(u,{flexDirection:"column",children:(S.children??[]).filter(_=>!he(_)).map(_=>(0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:_})},`${_.childId??"p"}-${_.index}`))},`branch-children-${S.index}`):(0,o.jsx)(K,{step:S},S.index)})]}),(0,o.jsx)(Ee,{activity:x,describe:T,describeVisible:f}),E.length>0&&(0,o.jsx)($e,{currentStep:ie,maxSteps:d,elapsed:G,status:ne})]})}if(t){let b=ke(e),y=Ae(b,$);return(0,o.jsxs)(u,{flexDirection:"column",children:[(0,o.jsx)(De,{steps:e,flows:r,cmInitCounts:a,renderStep:(x,g)=>he(x)?null:(0,o.jsx)(K,{step:x},g)}),(0,o.jsx)(Ee,{activity:y,describe:T,describeVisible:f}),E.length>0&&(0,o.jsx)($e,{currentStep:ie,maxSteps:d,elapsed:G,status:ne})]})}let Ce=ke(re),Pe=Ae(Ce,$),Z=rt(re);return(0,o.jsxs)(u,{flexDirection:"column",children:[Z.length>0&&(0,o.jsx)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Z.map(b=>(0,o.jsx)(K,{step:b},b.index))}),(0,o.jsx)(Ee,{activity:Pe,describe:T,describeVisible:f}),E.length>0&&(0,o.jsx)($e,{currentStep:ie,maxSteps:d,elapsed:G,status:ne})]})}var fe=k(D(),1);function it({runner:e,runKey:t,onStepCommit:r}){let a=Ye({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,fe.jsxs)(fe.Fragment,{children:[a&&(0,fe.jsx)(Xe,{label:a.label,hasBifurcation:a.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,fe.jsx)(ot,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:r},`run-${t}`)]})}var z=k(D(),1),mt=64;function gt(e){return e.split(`
@@ -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-DPWUXRRO.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-BGXAW2B5.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};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as f}from"./chunk-JFSBM4Z2.js";import{x as t}from"./chunk-DPWUXRRO.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{b as f}from"./chunk-UR4NSWY7.js";import{x as t}from"./chunk-BGXAW2B5.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{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-Y7Q7OG2K.js";import{x as s}from"./chunk-DPWUXRRO.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
2
+ import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-LZEYE2WE.js";import{x as s}from"./chunk-BGXAW2B5.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-LPUQ4HWQ.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{a as g}from"./chunk-2TAGK72D.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new m(g(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),l=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(n=>n.name===l);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let n=await d.createProject(l);t=n.id,s=n.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(n=>n.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let n=await d.createFolder(t,o);c=n.id,i=n.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??l,folderId:c,folderName:i??o}}function N(e,r,d){let l=e.loadProfileConfig(r,d)??{};return{projectId:l.project_id??null,folderId:l.folder_id??null}}function A(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
2
+ import{a as m}from"./chunk-LPUQ4HWQ.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{a as g}from"./chunk-3PISMPFM.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new m(g(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),l=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(n=>n.name===l);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let n=await d.createProject(l);t=n.id,s=n.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(n=>n.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let n=await d.createFolder(t,o);c=n.id,i=n.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??l,folderId:c,folderName:i??o}}function N(e,r,d){let l=e.loadProfileConfig(r,d)??{};return{projectId:l.project_id??null,folderId:l.folder_id??null}}function A(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
3
3
 
4
4
  discover IDs:
5
5
  kane-cli projects list --search "<keyword>" --limit 10
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as T,f as P,g as $,h as G,j as N,k as M,l as B,m as I,n as L,o as U,p as F,r as z,s as C,t as _,u as O,v as K}from"./chunk-4DRZNE2I.js";import{d as J}from"./chunk-KHDW3N76.js";import{b as k}from"./chunk-HFRJE27Y.js";import{c as E}from"./chunk-SX3MRVIA.js";import"./chunk-L5LI2JF4.js";import{a as q}from"./chunk-PGBUS6CL.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-RJW244F2.js";import{d as x,e as A}from"./chunk-LOIRZFV3.js";import{g as H}from"./chunk-JSHGADRY.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-AVEPDV55.js";import{a as j}from"./chunk-JPJFIOL7.js";import"./chunk-XBL2ZPYQ.js";import{a as R}from"./chunk-2TAGK72D.js";import"./chunk-RZ4F3BHX.js";import"./chunk-DPWUXRRO.js";import"./chunk-UR6MHSHU.js";import{join as se}from"path";async function V(t){let e=t.projectId,n=t.folderId,r=null;if(!e&&t.autoResolve){let l=await t.resolver.resolve();if(!l)throw new $("unauthorized; run `kane-cli login`");let u=await H({creds:t.autoResolve.creds,config:t.autoResolve.config,profile:t.autoResolve.profile,env:t.autoResolve.envName,tmsCreds:{username:l.username,access_key:l.access_key},isLocal:!1,log:t.log});u.status==="ok"&&(e=u.projectId,n=n??u.folderId,u.autoDefaulted&&(r={projectId:u.autoDefaulted.projectId,projectName:u.autoDefaulted.projectName,folderId:u.autoDefaulted.folderId,folderName:u.autoDefaulted.folderName}))}return{baseUrl:`${t.env.testGeneratorBaseUrl}/test-generator/api/v2`,tmsBaseUrl:t.env.tmsBaseUrl,authResolver:t.resolver,projectId:e,folderId:n,suiteName:t.suiteName,autoDefaulted:r,log:t.log}}function Z(t){return t.reduce((e,n)=>e+(n.test_cases?.length??0),0)}var y=class{constructor(e=n=>process.stdout.write(n)){this.write=e}emit(e){this.write(JSON.stringify(e)+`
2
+ import{a as T,f as P,g as $,h as G,j as N,k as M,l as B,m as I,n as L,o as U,p as F,r as z,s as C,t as _,u as O,v as K}from"./chunk-WKS4ST3B.js";import{d as J}from"./chunk-YYSABHRE.js";import{b as k}from"./chunk-DMLJUTQO.js";import{c as E}from"./chunk-K266M5ZM.js";import"./chunk-L5LI2JF4.js";import{a as q}from"./chunk-XCMNFMSO.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-IT2GFEFH.js";import{d as x,e as A}from"./chunk-LOIRZFV3.js";import{g as H}from"./chunk-ZRGEUDG5.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-SH5FUG47.js";import{a as j}from"./chunk-HZUTFC3G.js";import"./chunk-ALF5ETLD.js";import{a as R}from"./chunk-3PISMPFM.js";import"./chunk-RZ4F3BHX.js";import"./chunk-BGXAW2B5.js";import"./chunk-UR6MHSHU.js";import{join as se}from"path";async function V(t){let e=t.projectId,n=t.folderId,r=null;if(!e&&t.autoResolve){let l=await t.resolver.resolve();if(!l)throw new $("unauthorized; run `kane-cli login`");let u=await H({creds:t.autoResolve.creds,config:t.autoResolve.config,profile:t.autoResolve.profile,env:t.autoResolve.envName,tmsCreds:{username:l.username,access_key:l.access_key},isLocal:!1,log:t.log});u.status==="ok"&&(e=u.projectId,n=n??u.folderId,u.autoDefaulted&&(r={projectId:u.autoDefaulted.projectId,projectName:u.autoDefaulted.projectName,folderId:u.autoDefaulted.folderId,folderName:u.autoDefaulted.folderName}))}return{baseUrl:`${t.env.testGeneratorBaseUrl}/test-generator/api/v2`,tmsBaseUrl:t.env.tmsBaseUrl,authResolver:t.resolver,projectId:e,folderId:n,suiteName:t.suiteName,autoDefaulted:r,log:t.log}}function Z(t){return t.reduce((e,n)=>e+(n.test_cases?.length??0),0)}var y=class{constructor(e=n=>process.stdout.write(n)){this.write=e}emit(e){this.write(JSON.stringify(e)+`
3
3
  `)}onStart(e){this.emit({type:"generate_start",request_id:e.requestId,objective_chars:e.objectiveChars,scenario_limit:e.scenarioLimit,per_scenario_limit:e.perScenarioLimit,is_refine:e.isRefine})}onUpload(e){this.emit({type:"generate_upload",file:e.file,index:e.index,total:e.total,status:e.status})}onThinking(e){this.emit({type:"generate_thinking",took_ms:e.tookMs})}onProgress(e){this.emit({type:"generate_progress",pct:e})}onSnapshot(e){this.emit({type:"generate_snapshot",scenario_count:e.scenarios.length,case_count:Z(e.scenarios),scenarios:e.scenarios})}onClarification(e){this.emit({type:"generate_clarification",text:e})}onChat(e){this.emit({type:"generate_chat",text:e})}onError(e){this.emit({type:"error",message:e})}onSaveResult(e){this.emit({type:"generate_save_result",suite_dir:e.suiteDir,saved:e.saved,fell_back:e.fellBack,...e.warning?{warning:e.warning}:{}})}onDone(e){this.emit({type:"generate_done",request_id:e.requestId,status:e.status,scenario_count:e.scenarioCount,case_count:e.caseCount,refine_hint:e.refineHint,save_hint:e.saveHint,...e.suiteDir?{suite_dir:e.suiteDir}:{}})}onUpdateAvailable(e){this.emit({type:"update_available",current:e.current,latest:e.latest,severity:e.severity})}},S=class{constructor(e=n=>process.stdout.write(n)){this.write=e}onStart(e){let n=e.isRefine?"Refining":"Generating";this.write(`${n} (request ${e.requestId})\u2026
4
4
  `)}onUpload(e){e.status==="uploading"&&this.write(` uploading ${e.file} (${e.index}/${e.total})
5
5
  `)}onThinking(e){let n=e.tookMs?` (${Math.round(e.tookMs/1e3)}s)`:"";this.write(` thinking${n}
@@ -16,6 +16,6 @@ import{a as T,f as P,g as $,h as G,j as N,k as M,l as B,m as I,n as L,o as U,p a
16
16
  `),this.write(` Save: ${e.saveHint}
17
17
  `),e.suiteDir&&this.write(` Saved: ${e.suiteDir}
18
18
  `)}onUpdateAvailable(e){this.write(`(update available: ${e.current} \u2192 ${e.latest})
19
- `)}};import{createHash as ee}from"crypto";function te(t){return ee("sha1").update(JSON.stringify({t:t.title,p:t.preconditions,m:t.manual_steps})).digest("hex")}function re(t){let e=[];for(let n of t.scenarios)for(let r of n.test_cases??[])I(r)&&r.manual_steps!=null&&e.push(r);return e}async function ne(t,e,n){let r=new Array(t.length),l=0,u=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let d=l++;if(d>=t.length)return;try{r[d]={ok:!0,value:await n(t[d])}}catch{r[d]={ok:!1}}}});return await Promise.all(u),r}async function Y(t,e,n){let r=re(t),l=n.run??(async(c,s)=>{let m=await n.resolveAuth(),o=U({objective:c,model:n.model,sessionId:n.sessionId,auth:m});return F(o,n.spawnOpts,s)}),u=r.map(te),d=[...new Set(u)],g=new Map;d.forEach(c=>{g.set(c,r[u.indexOf(c)])});let p=d.map(c=>g.get(c)),v=await ne(p,n.concurrency??3,c=>l(L(c))),i=new Map;d.forEach((c,s)=>{let m=v[s];m.ok&&i.set(c,m.value)});let f=new Map;r.forEach((c,s)=>{f.set(c.id,i.get(u[s]))});let a=0;for(let c of t.scenarios)for(let s of c.test_cases??[])I(s)&&!f.get(s.id)&&a++;let w=c=>{let s=f.get(c.id);return s?N(s,c):M(c)};return{...await B(t,e,{suiteName:n.suiteName,redirectBareCwd:!1},w),fellBack:a}}function Pe(t,e){let n=!!t.agent||!!t.refine||!!t.save||!e,r=t.agent?"agent":"plain";return{headless:n,mode:r}}function $e(t){return t.refine&&t.save?{error:"use --refine or --save, not both"}:t.save?t.objective?{error:"--save takes no objective; use --refine to add to a request"}:t.req?{op:"save"}:{error:"--save requires --req <id>"}:t.refine?t.req?t.objective?t.out?{error:"--out is only valid with --save"}:{op:"refine"}:{error:"--refine needs a refinement objective"}:{error:"--refine requires --req <id>"}:t.req?{error:"--req requires --refine or --save"}:t.out?{error:"--out is only valid with --save"}:t.objective?{op:"new"}:{error:"provide an objective, or use --refine/--save with --req"}}function ie(){return se(process.cwd(),".testmuai","tests")}function Ge(t){if(typeof t!="string")return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length?e:void 0}var X="tcg-generate-headless";function Q(t){return{refineHint:`kane-cli generate "<refinement>" --refine --req ${t}`,saveHint:`kane-cli generate --save --req ${t}`}}function W(t){return t.scenarios.reduce((e,n)=>e+(n.test_cases?.length??0),0)}function oe(t){return t==="completed"?0:t==="stopped"?3:1}async function Ne(t,e){let n=e.write??(i=>process.stdout.write(i)),r=e.sink??(e.mode==="agent"?new y(n):new S(n)),l,u,d=null;try{let i=await e.makeClient();l=i.client,u=i.conn,d=i.autoDefaulted}catch(i){return r.onError(i.message),2}if(e.mode==="agent"&&d){let{buildAutoDefaultedNdjson:i}=await import("./require-project-folder-R746X2BU.js");n(i(d))}try{let i=await(e.checkUpdate??J)();i&&r.onUpdateAvailable(i)}catch{}let g=t.reqId??null;x(X,()=>{g&&l.cancel(g).catch(()=>{})});let p=process.cwd(),v={validate:e.validate??z,upload:e.upload??O,buildMappings:K,onUpload:i=>r.onUpload(i)};try{if(t.op==="save"){let s;try{s=(await l.attach(t.reqId)).state}catch(D){return r.onError(D.message),2}g=s.requestId,r.onSnapshot(s);let m=t.outDir??ie(),o=await e.materialize(s,m,t.suiteName);r.onSaveResult({suiteDir:o.suiteDir,saved:o.paths.length,fellBack:o.fellBack,warning:o.warning});let h=Q(s.requestId);return r.onDone({requestId:s.requestId,status:"completed",scenarioCount:s.scenarios.length,caseCount:W(s),refineHint:h.refineHint,saveHint:h.saveHint,suiteDir:o.suiteDir}),0}let i=t.op==="refine",f,a;if(i){let s;try{s=await l.attach(t.reqId)}catch(o){return r.onError(o.message),2}if(a=s.state,g=a.requestId,a.error)return r.onError(a.error),2;let m;try{m=await _({promptText:t.objective,filePaths:t.files??[],cwd:p,scenarios:a.scenarios,isRefine:!0,conn:u,deps:v})}catch(o){if(o instanceof C){for(let h of o.errors)r.onError(h);return 2}return r.onError(o.message),2}for(let o of m.warnings)process.stderr.write(`warning: ${o}
19
+ `)}};import{createHash as ee}from"crypto";function te(t){return ee("sha1").update(JSON.stringify({t:t.title,p:t.preconditions,m:t.manual_steps})).digest("hex")}function re(t){let e=[];for(let n of t.scenarios)for(let r of n.test_cases??[])I(r)&&r.manual_steps!=null&&e.push(r);return e}async function ne(t,e,n){let r=new Array(t.length),l=0,u=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let d=l++;if(d>=t.length)return;try{r[d]={ok:!0,value:await n(t[d])}}catch{r[d]={ok:!1}}}});return await Promise.all(u),r}async function Y(t,e,n){let r=re(t),l=n.run??(async(c,s)=>{let m=await n.resolveAuth(),o=U({objective:c,model:n.model,sessionId:n.sessionId,auth:m});return F(o,n.spawnOpts,s)}),u=r.map(te),d=[...new Set(u)],g=new Map;d.forEach(c=>{g.set(c,r[u.indexOf(c)])});let p=d.map(c=>g.get(c)),v=await ne(p,n.concurrency??3,c=>l(L(c))),i=new Map;d.forEach((c,s)=>{let m=v[s];m.ok&&i.set(c,m.value)});let f=new Map;r.forEach((c,s)=>{f.set(c.id,i.get(u[s]))});let a=0;for(let c of t.scenarios)for(let s of c.test_cases??[])I(s)&&!f.get(s.id)&&a++;let w=c=>{let s=f.get(c.id);return s?N(s,c):M(c)};return{...await B(t,e,{suiteName:n.suiteName,redirectBareCwd:!1},w),fellBack:a}}function Pe(t,e){let n=!!t.agent||!!t.refine||!!t.save||!e,r=t.agent?"agent":"plain";return{headless:n,mode:r}}function $e(t){return t.refine&&t.save?{error:"use --refine or --save, not both"}:t.save?t.objective?{error:"--save takes no objective; use --refine to add to a request"}:t.req?{op:"save"}:{error:"--save requires --req <id>"}:t.refine?t.req?t.objective?t.out?{error:"--out is only valid with --save"}:{op:"refine"}:{error:"--refine needs a refinement objective"}:{error:"--refine requires --req <id>"}:t.req?{error:"--req requires --refine or --save"}:t.out?{error:"--out is only valid with --save"}:t.objective?{op:"new"}:{error:"provide an objective, or use --refine/--save with --req"}}function ie(){return se(process.cwd(),".testmuai","tests")}function Ge(t){if(typeof t!="string")return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length?e:void 0}var X="tcg-generate-headless";function Q(t){return{refineHint:`kane-cli generate "<refinement>" --refine --req ${t}`,saveHint:`kane-cli generate --save --req ${t}`}}function W(t){return t.scenarios.reduce((e,n)=>e+(n.test_cases?.length??0),0)}function oe(t){return t==="completed"?0:t==="stopped"?3:1}async function Ne(t,e){let n=e.write??(i=>process.stdout.write(i)),r=e.sink??(e.mode==="agent"?new y(n):new S(n)),l,u,d=null;try{let i=await e.makeClient();l=i.client,u=i.conn,d=i.autoDefaulted}catch(i){return r.onError(i.message),2}if(e.mode==="agent"&&d){let{buildAutoDefaultedNdjson:i}=await import("./require-project-folder-LSM4YSKJ.js");n(i(d))}try{let i=await(e.checkUpdate??J)();i&&r.onUpdateAvailable(i)}catch{}let g=t.reqId??null;x(X,()=>{g&&l.cancel(g).catch(()=>{})});let p=process.cwd(),v={validate:e.validate??z,upload:e.upload??O,buildMappings:K,onUpload:i=>r.onUpload(i)};try{if(t.op==="save"){let s;try{s=(await l.attach(t.reqId)).state}catch(D){return r.onError(D.message),2}g=s.requestId,r.onSnapshot(s);let m=t.outDir??ie(),o=await e.materialize(s,m,t.suiteName);r.onSaveResult({suiteDir:o.suiteDir,saved:o.paths.length,fellBack:o.fellBack,warning:o.warning});let h=Q(s.requestId);return r.onDone({requestId:s.requestId,status:"completed",scenarioCount:s.scenarios.length,caseCount:W(s),refineHint:h.refineHint,saveHint:h.saveHint,suiteDir:o.suiteDir}),0}let i=t.op==="refine",f,a;if(i){let s;try{s=await l.attach(t.reqId)}catch(o){return r.onError(o.message),2}if(a=s.state,g=a.requestId,a.error)return r.onError(a.error),2;let m;try{m=await _({promptText:t.objective,filePaths:t.files??[],cwd:p,scenarios:a.scenarios,isRefine:!0,conn:u,deps:v})}catch(o){if(o instanceof C){for(let h of o.errors)r.onError(h);return 2}return r.onError(o.message),2}for(let o of m.warnings)process.stderr.write(`warning: ${o}
20
20
  `);r.onStart({requestId:a.requestId,objectiveChars:m.promptText.length,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,isRefine:!0});try{await l.chat(t.reqId,m.promptText,{mappings:m.mappings,attachments:m.attachments})}catch(o){return r.onError(o.message),2}f=s.events}else{let s;try{s=await _({promptText:t.objective,filePaths:t.files??[],cwd:p,scenarios:[],isRefine:!1,conn:u,deps:v})}catch(o){if(o instanceof C){for(let h of o.errors)r.onError(h);return 2}return r.onError(o.message),2}for(let o of s.warnings)process.stderr.write(`warning: ${o}
21
21
  `);let m;try{m=await l.start({prompt:s.promptText,attachments:s.attachments,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,memoryEnhancement:t.memory})}catch(o){return r.onError(o.message),2}a=m.state,g=a.requestId,r.onStart({requestId:a.requestId,objectiveChars:s.promptText.length,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,isRefine:!1}),f=m.events}let w="";for await(let s of f){switch(a=P(a,s),s.type){case"thinking_done":r.onThinking({tookMs:s.tookMs});break;case"progress":r.onProgress(s.pct);break;case"clarification":r.onClarification(s.text);break;case"chat":r.onChat(s.text);break;case"error":r.onError(s.message);break;case"done":w=s.status;break;default:break}if(s.type==="done"||s.type!=="thinking"&&a.status&&T(a.status))break}r.onSnapshot(a);let b=w||a.status||"completed",c=Q(a.requestId);return r.onDone({requestId:a.requestId,status:b,scenarioCount:a.scenarios.length,caseCount:W(a),refineHint:c.refineHint,saveHint:c.saveHint,suiteDir:void 0}),oe(b)}finally{A(X)}}var ae=()=>{};async function Me(t){let e=new j,n=new q,r=e.getActiveProfile()??"default",l=t.env??e.getDefaultEnv()??"prod",u=R(l),d=new E;t.name&&d.setSessionName(t.name);let g=n.load().model,p=async()=>{let i=await k({creds:e,env:l,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}}),f=await V({resolver:i.resolver,env:u,log:ae,projectId:t.projectId,folderId:t.folderId,autoResolve:t.projectId?void 0:{creds:e,config:n,profile:r,envName:l}});return{client:G(f),conn:f,autoDefaulted:f.autoDefaulted??null}},v=async()=>{let i=await k({creds:e,env:l,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}});return i.basicAuth?{username:i.basicAuth.username,access_key:i.basicAuth.access_key}:i.token?{auth:{type:"bearer",token:i.token}}:{}};return{mode:t.mode,makeClient:p,materialize:(i,f,a)=>Y(i,f,{model:g,sessionId:d.sessionId,resolveAuth:v,spawnOpts:{environment:l},suiteName:a})}}export{Me as buildHeadlessDeps,Pe as decideGenerateMode,ie as defaultOutDir,Ge as parseFilesFlag,$e as resolveGenerateOp,Ne as runGenerateHeadless};