@testmuai/kane-cli 0.4.8 → 0.4.9

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 (77) hide show
  1. package/dist/{ChromeProfilePicker-B2PUH2LL.js → ChromeProfilePicker-BOTCHMXH.js} +1 -1
  2. package/dist/{CliFeedbackPrompt-647ESLIL.js → CliFeedbackPrompt-BV4VVYOY.js} +1 -1
  3. package/dist/{CliUploadProgress-U325KQO6.js → CliUploadProgress-Y4H43W5T.js} +1 -1
  4. package/dist/{ConfigView-NKD7QMUV.js → ConfigView-JPBD47MS.js} +1 -1
  5. package/dist/FolderPicker-M4RFRBYV.js +2 -0
  6. package/dist/{HelpView-35KKWQVE.js → HelpView-ZZYE2TKZ.js} +1 -1
  7. package/dist/{InfoBox-OIZ3APE3.js → InfoBox-3ZLQZGUE.js} +1 -1
  8. package/dist/{LinksBox-DLIYPE3S.js → LinksBox-UYMOQGSW.js} +1 -1
  9. package/dist/{ProfilesView-CFYBJIL4.js → ProfilesView-YUMYSOZ4.js} +1 -1
  10. package/dist/{ProjectPicker-ASHXV4HU.js → ProjectPicker-CJVGBY42.js} +1 -1
  11. package/dist/{SaveSessionPrompt-ATKVPQEJ.js → SaveSessionPrompt-DFVUWTOK.js} +1 -1
  12. package/dist/SingleShotApp-IOEEYVGJ.js +2 -0
  13. package/dist/{SummaryBox-AAXB55TE.js → SummaryBox-3VIRYWQA.js} +1 -1
  14. package/dist/TestMdRunView-MRSDDMSF.js +2 -0
  15. package/dist/{WhoamiView-TRGZE2NZ.js → WhoamiView-GMM4V7ZV.js} +1 -1
  16. package/dist/{changelog-JBGYPN7J.js → changelog-FNJ4P2IF.js} +1 -1
  17. package/dist/{chunk-RBG4VTHQ.js → chunk-2J3VB6DW.js} +1 -1
  18. package/dist/{chunk-BGXAW2B5.js → chunk-3UCNDPTN.js} +1 -1
  19. package/dist/{chunk-5VZSCQXN.js → chunk-42WWGBRK.js} +1 -1
  20. package/dist/{chunk-LY3DAHNE.js → chunk-6PBX7QI7.js} +2 -2
  21. package/dist/chunk-7N5H4KTV.js +5 -0
  22. package/dist/{chunk-GRIQ4OQL.js → chunk-7NTOV5DV.js} +1 -1
  23. package/dist/{chunk-ZQPTSSU6.js → chunk-AH36DUIX.js} +1 -1
  24. package/dist/{chunk-SSPIKPHV.js → chunk-CLRWPXDJ.js} +1 -1
  25. package/dist/{chunk-SVZUJ2QE.js → chunk-CY4HAOSP.js} +1 -1
  26. package/dist/{chunk-25YRWDQ7.js → chunk-DKGNV3VP.js} +1 -1
  27. package/dist/{chunk-K266M5ZM.js → chunk-DXJ5FL25.js} +1 -1
  28. package/dist/{chunk-SH5FUG47.js → chunk-FN6ZRV4C.js} +1 -1
  29. package/dist/{chunk-DMLJUTQO.js → chunk-FTMJTGT4.js} +1 -1
  30. package/dist/{chunk-EAUU5F4P.js → chunk-GBTPZGJB.js} +1 -1
  31. package/dist/{chunk-3PISMPFM.js → chunk-HPJP7NES.js} +1 -1
  32. package/dist/{chunk-ZQ5IPBXJ.js → chunk-HYOST7EA.js} +1 -1
  33. package/dist/{chunk-F5ZL4XYL.js → chunk-IO3PBDKN.js} +1 -1
  34. package/dist/{chunk-C2E2DKY3.js → chunk-JBOXYLDH.js} +1 -1
  35. package/dist/{chunk-LZEYE2WE.js → chunk-JHSSBES2.js} +1 -1
  36. package/dist/{chunk-W67JBBQF.js → chunk-JO3QZB6D.js} +2 -2
  37. package/dist/{chunk-WKS4ST3B.js → chunk-JQXARCVE.js} +1 -1
  38. package/dist/{chunk-SRQ7P3WI.js → chunk-KLVCLGHX.js} +1 -1
  39. package/dist/{chunk-ZRGEUDG5.js → chunk-LJDFBQFR.js} +1 -1
  40. package/dist/{chunk-HZUTFC3G.js → chunk-LZUTY7XS.js} +1 -1
  41. package/dist/{chunk-UR4NSWY7.js → chunk-MUZCEGJD.js} +1 -1
  42. package/dist/chunk-QMAHNXS6.js +8 -0
  43. package/dist/{chunk-F6VA5YBJ.js → chunk-QW5G7TX3.js} +3 -3
  44. package/dist/{chunk-ALF5ETLD.js → chunk-RJFHOZG6.js} +1 -1
  45. package/dist/{chunk-YJVA6LBY.js → chunk-SEU6OXMD.js} +1 -1
  46. package/dist/{chunk-WZ6GNXM3.js → chunk-UJDIXFEE.js} +1 -1
  47. package/dist/{chunk-CVC6MQN6.js → chunk-UVBE3JJV.js} +1 -1
  48. package/dist/{chunk-YYSABHRE.js → chunk-VSJAOEBB.js} +1 -1
  49. package/dist/{chunk-CL5SB2I7.js → chunk-WEPNJVBA.js} +1 -1
  50. package/dist/{chunk-AD6DPSIZ.js → chunk-WKJY6TRR.js} +1 -1
  51. package/dist/chunk-XA7UFTB7.js +27 -0
  52. package/dist/{chunk-IXYUSFH2.js → chunk-YK63DTUC.js} +2 -2
  53. package/dist/{generate-headless-VB52MM2A.js → generate-headless-ZRRQT56R.js} +2 -2
  54. package/dist/index.js +13 -13
  55. package/dist/{list-commands-X6EXASQG.js → list-commands-M3JL6XBB.js} +1 -1
  56. package/dist/login-flow-DOAIDKIV.js +2 -0
  57. package/dist/{persist-recorded-session-EI4ISSRI.js → persist-recorded-session-3I4KMEXA.js} +1 -1
  58. package/dist/{recording-banner-BQQSRJIF.js → recording-banner-P6EKDS2Y.js} +1 -1
  59. package/dist/{require-project-folder-LSM4YSKJ.js → require-project-folder-SEMMD3EG.js} +1 -1
  60. package/dist/{run-test-md-VR2Q46Q3.js → run-test-md-PXG4RFDI.js} +3 -3
  61. package/dist/{skill-installer-JS7LUETO.js → skill-installer-SU52XOIT.js} +1 -1
  62. package/dist/tcg-generate-5T6S2E7L.js +2 -0
  63. package/dist/testmd-actions-N7VS4FS6.js +2 -0
  64. package/dist/token-refresh-LSHPT46T.js +2 -0
  65. package/dist/{validate-basic-W7UJ5D25.js → validate-basic-EKSOPOMF.js} +1 -1
  66. package/dist/{version-check-ACQ5Z7JV.js → version-check-4K4JHG7B.js} +1 -1
  67. package/package.json +6 -6
  68. package/dist/FolderPicker-2LEIB5F5.js +0 -2
  69. package/dist/SingleShotApp-JYKEW3WS.js +0 -2
  70. package/dist/TestMdRunView-U35UBFHZ.js +0 -2
  71. package/dist/chunk-IT2GFEFH.js +0 -5
  72. package/dist/chunk-UVOM74DG.js +0 -27
  73. package/dist/chunk-XCMNFMSO.js +0 -8
  74. package/dist/login-flow-R5IGUIPA.js +0 -2
  75. package/dist/tcg-generate-YQJZTSSI.js +0 -2
  76. package/dist/testmd-actions-FAQYABQT.js +0 -2
  77. package/dist/token-refresh-XM3DXY2A.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-RBG4VTHQ.js";import{a as k}from"./chunk-LPUQ4HWQ.js";import{a as B}from"./chunk-3PISMPFM.js";import{a as R}from"./chunk-EAUU5F4P.js";import{x as c}from"./chunk-BGXAW2B5.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as l}from"./chunk-C44QQJR4.js";import{a as J}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,i,y,m){return{id:n,label:`${i} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:i,currentFolderId:y,env:m,onSelect:x,onCancel:w}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,b]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),h=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=B(m),T=new k(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let s=await T.listFolders(i);yield{page:1,folders:s,totalLoaded:s.length,done:!0}})();for await(let s of F){if(d(!1),s.totalLoaded===0){h.current=!0,b("naming"),g(!1);return}M(s.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),s.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,i,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!i){f("No project selected \u2014 pick a project first");return}f(null),b("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=B(m),s=await new k(T.tmsBaseUrl,a.username,a.access_key).createFolder(i,r);x(s.id,s.name)}catch(a){f(a instanceof Error?a.message:String(a)),b("naming")}})()},[n,i,m,x]),H=(0,t.useCallback)(()=>{v(""),f(null),h.current?w():b("list")},[w]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:c.orange,bold:!0,children:"Create new folder"}),h.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(l,{color:c.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(l,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:h.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{h.current=!1,b("naming")},extraHint:"tab to create new",onSelect:o=>{let r=o.label.split(" (")[0];x(o.id,r)},onCancel:w})}export{X as a,W as b};
2
+ import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-2J3VB6DW.js";import{a as k}from"./chunk-LPUQ4HWQ.js";import{a as B}from"./chunk-HPJP7NES.js";import{a as R}from"./chunk-GBTPZGJB.js";import{x as c}from"./chunk-3UCNDPTN.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as l}from"./chunk-C44QQJR4.js";import{a as J}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,i,y,m){return{id:n,label:`${i} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:i,currentFolderId:y,env:m,onSelect:x,onCancel:w}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,b]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),h=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=B(m),T=new k(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let s=await T.listFolders(i);yield{page:1,folders:s,totalLoaded:s.length,done:!0}})();for await(let s of F){if(d(!1),s.totalLoaded===0){h.current=!0,b("naming"),g(!1);return}M(s.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),s.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,i,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!i){f("No project selected \u2014 pick a project first");return}f(null),b("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=B(m),s=await new k(T.tmsBaseUrl,a.username,a.access_key).createFolder(i,r);x(s.id,s.name)}catch(a){f(a instanceof Error?a.message:String(a)),b("naming")}})()},[n,i,m,x]),H=(0,t.useCallback)(()=>{v(""),f(null),h.current?w():b("list")},[w]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:c.orange,bold:!0,children:"Create new folder"}),h.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(l,{color:c.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(l,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:h.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{h.current=!1,b("naming")},extraHint:"tab to create new",onSelect:o=>{let r=o.label.split(" (")[0];x(o.id,r)},onCancel:w})}export{X as a,W as b};
@@ -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-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.
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-HPJP7NES.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{c as g}from"./chunk-BGXAW2B5.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
2
+ import{c as g}from"./chunk-3UCNDPTN.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
3
3
  `),f(this.configFile,384)}getActiveProfile(){return this.readConfig().active_profile??null}setActiveProfile(t){let i=this.readConfig();i.active_profile=t,this.writeConfig(i)}getDefaultEnv(){return this.readConfig().default_env??"prod"}setDefaultEnv(t){let i=this.readConfig();i.default_env=t,this.writeConfig(i)}credentialsPath(t,i){return n(this.profilesDir,t,i,"credentials")}clientPath(t,i){return n(this.profilesDir,t,i,"client.json")}basicAuthPath(t,i){return n(this.profilesDir,t,i,"basic-auth")}profileConfigPath(t,i){return n(this.profilesDir,t,i,"profile-config.json")}saveProfileConfig(t,i,r){let e=this.loadProfileConfig(t,i)??{};this.writeSecure(this.profileConfigPath(t,i),{...e,...r})}loadProfileConfig(t,i){try{return JSON.parse(o(this.profileConfigPath(t,i),"utf-8"))}catch{return null}}writeSecure(t,i){try{u(P(t),{recursive:!0,mode:448}),h(t,JSON.stringify(i,null,2)+`
4
4
  `),f(t,384)}catch(r){let e=r instanceof Error?r.message:String(r);process.stderr.write(`[auth] Failed to save credentials: ${e}
5
5
  `)}}saveCredentials(t,i,r){this.writeSecure(this.credentialsPath(t,i),r)}loadCredentials(t,i){try{return JSON.parse(o(this.credentialsPath(t,i),"utf-8"))}catch{return null}}saveClient(t,i,r){this.writeSecure(this.clientPath(t,i),r)}loadClient(t,i){try{return JSON.parse(o(this.clientPath(t,i),"utf-8"))}catch{return null}}getActiveCredentials(){let t=this.getActiveProfile();if(!t)return{credentials:null,profile:null,env:null};let i=this.getDefaultEnv();return{credentials:this.loadCredentials(t,i),profile:t,env:i}}saveBasicAuth(t,i,r){this.writeSecure(this.basicAuthPath(t,i),r)}loadBasicAuth(t,i){try{return JSON.parse(o(this.basicAuthPath(t,i),"utf-8"))}catch{return null}}deleteBasicAuth(t,i){try{s(this.basicAuthPath(t,i))}catch{}}resolveAuth(){let t=this.getActiveProfile();if(!t)return null;let i=this.getDefaultEnv(),r=this.loadBasicAuth(t,i);return r?{method:"basic",...r,profile:t,env:i}:this.loadCredentials(t,i)?{method:"oauth",profile:t,env:i}:null}listProfiles(){let t=[];try{for(let i of a(this.profilesDir)){let r=n(this.profilesDir,i);try{for(let e of a(r)){let c=n(r,e),v=l(n(c,"credentials")),p=l(n(c,"client.json")),y=l(n(c,"basic-auth"));(v||p||y)&&t.push({profile:i,env:e})}}catch{}}}catch{}return t}deleteProfile(t,i){try{s(this.credentialsPath(t,i))}catch{}if(this.getActiveProfile()===t){let r=this.readConfig();delete r.active_profile,this.writeConfig(r)}}deleteProfileFull(t,i){if(i){try{s(this.credentialsPath(t,i))}catch{}try{s(this.clientPath(t,i))}catch{}try{s(this.basicAuthPath(t,i))}catch{}try{s(this.profileConfigPath(t,i))}catch{}}else try{let r=n(this.profilesDir,t);for(let e of a(r)){try{s(n(r,e,"credentials"))}catch{}try{s(n(r,e,"client.json"))}catch{}try{s(n(r,e,"basic-auth"))}catch{}try{s(n(r,e,"profile-config.json"))}catch{}}}catch{}}};export{d as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{x as a}from"./chunk-BGXAW2B5.js";import{a as c}from"./chunk-HCBYKLMW.js";import{b as u}from"./chunk-C44QQJR4.js";import{a as l}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var s=n(l(),1);var o=n(l(),1);function f(r,e){let t=(0,o.useRef)(r);t.current=r,(0,o.useEffect)(()=>{if(e===null)return;let i=setInterval(()=>t.current(),e);return()=>clearInterval(i)},[e])}var p=n(c(),1),m=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function I({active:r=!0}){let[e,t]=(0,s.useState)(0);return f(()=>{t(i=>(i+1)%m.length)},r?80:null),(0,p.jsx)(u,{color:a.orange,children:r?m[e]:"\u25CF"})}export{f as a,I as b};
2
+ import{x as a}from"./chunk-3UCNDPTN.js";import{a as c}from"./chunk-HCBYKLMW.js";import{b as u}from"./chunk-C44QQJR4.js";import{a as l}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var s=n(l(),1);var o=n(l(),1);function f(r,e){let t=(0,o.useRef)(r);t.current=r,(0,o.useEffect)(()=>{if(e===null)return;let i=setInterval(()=>t.current(),e);return()=>clearInterval(i)},[e])}var p=n(c(),1),m=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function I({active:r=!0}){let[e,t]=(0,s.useState)(0);return f(()=>{t(i=>(i+1)%m.length)},r?80:null),(0,p.jsx)(u,{color:a.orange,children:r?m[e]:"\u25CF"})}export{f as a,I as b};
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{d as a,j as l}from"./chunk-3UCNDPTN.js";import{readFileSync as g,writeFileSync as o,mkdirSync as i,existsSync as p}from"fs";import{dirname as s}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,network_sse:!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=a){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(s(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(s(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(s(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{a as Se,b as nr}from"./chunk-C5UNZ6ZY.js";import{a as ar}from"./chunk-BH6EP2LD.js";import{c as or}from"./chunk-S3DAAAE5.js";import{b as sr,c as ut,d as dt,e as ve,f as mt,g as ir}from"./chunk-PUU7A26K.js";import{a as Ue,b as se,c as tr,e as le,f as lt,i as rr,j as ct}from"./chunk-AH4AXJML.js";import{b as ue}from"./chunk-K266M5ZM.js";import{a as Xt}from"./chunk-WAOCHXJ5.js";import{a as er,b as at}from"./chunk-IT2GFEFH.js";import{a as Wt,b as ot,c as it,d as je,e as Jt,f as Qt}from"./chunk-LOIRZFV3.js";import{f as Yt,g as Zt}from"./chunk-ZRGEUDG5.js";import{a as zt}from"./chunk-LPUQ4HWQ.js";import{a as De,b as Gt}from"./chunk-NLCCBXXV.js";import{a as W}from"./chunk-3PISMPFM.js";import{a as D}from"./chunk-RZ4F3BHX.js";import{a as Ht}from"./chunk-E47GFYXA.js";import{a as Kt,c as rt,i as qt,j as Le,k as st,l as nt}from"./chunk-BGXAW2B5.js";import{join as qe,basename as En}from"path";import{existsSync as ds,readFileSync as An}from"fs";import{existsSync as ft}from"fs";import{join as Fe,basename as lr}from"path";function cr(e,t){if(!t||!ft(t))return e.steps.map(()=>({kind:"author",reason:"no-result-md"}));let r=dt(t),s=[],n=new Set,o=new Map;function a(i){let l=ve(i),h=Fe(l,"Result.md");if(o.has(h))return o.get(h);let f=ft(h)?dt(h):null;return o.set(h,f),f}function u(i){for(let l=1;l<i.trace.length;l++){let f=i.trace[l-1].file===e.rootPath?r:a(i.trace.slice(0,l));if(!f)return{kind:"author",reason:"no-result-md"};let w=i.trace[l-1].stepIndex,g=f.steps[w-1];if(!g)return{kind:"author",reason:"no-result-md"};if(g.kind!=="import")return{kind:"author",reason:"structure-mismatch"};let I=lr(g.importPath),S=lr(i.trace[l].file);if(I!==S)return{kind:"author",reason:"structure-mismatch"};if(g.status!=="passed")return{kind:"author",reason:"recorded-failed"}}return null}for(let i of e.steps){let l=i.trace[i.trace.length-1].file,h=i.trace[i.trace.length-1].stepIndex,f=n.has(l);for(let S=0;S<i.trace.length-1&&!f;S++)n.has(i.trace[S].file)&&(f=!0);if(f){s.push({kind:"author",reason:"downstream-of-divergence"});continue}let w=u(i);if(w){s.push(w);for(let S=0;S<i.trace.length;S++)n.add(i.trace[S].file);continue}let g=l===e.rootPath?r:a(i.trace),I=Es(i,g,h);if(s.push(I),I.kind==="author"){n.add(l);for(let S=0;S<i.trace.length-1;S++)n.add(i.trace[S].file)}}return s}function Es(e,t,r){if(!t)return{kind:"author",reason:"no-result-md"};let s=t.steps[r-1];if(!s)return{kind:"author",reason:"no-result-md"};if(s.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(s.status!=="passed")return{kind:"author",reason:"recorded-failed"};let n=sr(e);if(n!==s.md5)return{kind:"author",reason:"md5-mismatch"};let o=e.trace.length===1?rr(e.trace[0].file,r,n.slice(0,8)):Fe(ve(e.trace),".internal","steps",`${r}-${n.slice(0,8)}`),a=Fe(o,"flows","0","actions.ndjson");return ft(a)?{kind:"replay",recordingDir:o}:{kind:"author",reason:"missing-recording"}}function ur(e){return e.some(t=>t.kind==="author")}function Me(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function dr(e){return Fe(e.recordingDir,"flows","0","actions.ndjson")}function mr(e,t){if(process.env.KANE_REPLAY_TRACE==="1")for(let r=0;r<e.steps.length;r++){let s=e.steps[r],n=t[r],o=" ".repeat(s.trace.length-1),a=`step ${s.flatIndex}`;n.kind==="replay"?process.stderr.write(`[replay-trace] ${o}${a}: REPLAY (would skip; v1 always authors)
2
+ import{a as Se,b as nr}from"./chunk-C5UNZ6ZY.js";import{a as ar}from"./chunk-BH6EP2LD.js";import{c as or}from"./chunk-S3DAAAE5.js";import{b as sr,c as ut,d as dt,e as ve,f as mt,g as ir}from"./chunk-PUU7A26K.js";import{a as Ue,b as se,c as tr,e as le,f as lt,i as rr,j as ct}from"./chunk-AH4AXJML.js";import{b as ue}from"./chunk-DXJ5FL25.js";import{a as Xt}from"./chunk-WAOCHXJ5.js";import{a as er,b as at}from"./chunk-7N5H4KTV.js";import{a as Wt,b as ot,c as it,d as je,e as Jt,f as Qt}from"./chunk-LOIRZFV3.js";import{f as Yt,g as Zt}from"./chunk-LJDFBQFR.js";import{a as zt}from"./chunk-LPUQ4HWQ.js";import{a as De,b as Gt}from"./chunk-NLCCBXXV.js";import{a as W}from"./chunk-HPJP7NES.js";import{a as D}from"./chunk-RZ4F3BHX.js";import{a as Ht}from"./chunk-E47GFYXA.js";import{a as Kt,c as rt,i as qt,j as Le,k as st,l as nt}from"./chunk-3UCNDPTN.js";import{join as qe,basename as En}from"path";import{existsSync as ds,readFileSync as An}from"fs";import{existsSync as ft}from"fs";import{join as Fe,basename as lr}from"path";function cr(e,t){if(!t||!ft(t))return e.steps.map(()=>({kind:"author",reason:"no-result-md"}));let r=dt(t),s=[],n=new Set,o=new Map;function a(i){let l=ve(i),h=Fe(l,"Result.md");if(o.has(h))return o.get(h);let f=ft(h)?dt(h):null;return o.set(h,f),f}function u(i){for(let l=1;l<i.trace.length;l++){let f=i.trace[l-1].file===e.rootPath?r:a(i.trace.slice(0,l));if(!f)return{kind:"author",reason:"no-result-md"};let w=i.trace[l-1].stepIndex,g=f.steps[w-1];if(!g)return{kind:"author",reason:"no-result-md"};if(g.kind!=="import")return{kind:"author",reason:"structure-mismatch"};let I=lr(g.importPath),S=lr(i.trace[l].file);if(I!==S)return{kind:"author",reason:"structure-mismatch"};if(g.status!=="passed")return{kind:"author",reason:"recorded-failed"}}return null}for(let i of e.steps){let l=i.trace[i.trace.length-1].file,h=i.trace[i.trace.length-1].stepIndex,f=n.has(l);for(let S=0;S<i.trace.length-1&&!f;S++)n.has(i.trace[S].file)&&(f=!0);if(f){s.push({kind:"author",reason:"downstream-of-divergence"});continue}let w=u(i);if(w){s.push(w);for(let S=0;S<i.trace.length;S++)n.add(i.trace[S].file);continue}let g=l===e.rootPath?r:a(i.trace),I=Es(i,g,h);if(s.push(I),I.kind==="author"){n.add(l);for(let S=0;S<i.trace.length-1;S++)n.add(i.trace[S].file)}}return s}function Es(e,t,r){if(!t)return{kind:"author",reason:"no-result-md"};let s=t.steps[r-1];if(!s)return{kind:"author",reason:"no-result-md"};if(s.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(s.status!=="passed")return{kind:"author",reason:"recorded-failed"};let n=sr(e);if(n!==s.md5)return{kind:"author",reason:"md5-mismatch"};let o=e.trace.length===1?rr(e.trace[0].file,r,n.slice(0,8)):Fe(ve(e.trace),".internal","steps",`${r}-${n.slice(0,8)}`),a=Fe(o,"flows","0","actions.ndjson");return ft(a)?{kind:"replay",recordingDir:o}:{kind:"author",reason:"missing-recording"}}function ur(e){return e.some(t=>t.kind==="author")}function Me(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function dr(e){return Fe(e.recordingDir,"flows","0","actions.ndjson")}function mr(e,t){if(process.env.KANE_REPLAY_TRACE==="1")for(let r=0;r<e.steps.length;r++){let s=e.steps[r],n=t[r],o=" ".repeat(s.trace.length-1),a=`step ${s.flatIndex}`;n.kind==="replay"?process.stderr.write(`[replay-trace] ${o}${a}: REPLAY (would skip; v1 always authors)
3
3
  `):process.stderr.write(`[replay-trace] ${o}${a}: AUTHOR (${n.reason})
4
4
  `)}}function de(e){process.env.KANE_REPLAY_TRACE==="1"&&process.stderr.write(e)}function fr(e,t){let r=e===0?"(none)":`0..${e-1}`,s=e>=t?"(none)":`${e}..${t-1}`;de(`[replay-trace] phase: replay ${r}, author ${s}
5
5
  `)}function pr(e,t){de(`[replay-trace] step ${e}: REPLAY ${t==="ok"?"OK":"FAILED"}
@@ -14,7 +14,7 @@ import{a as Se,b as nr}from"./chunk-C5UNZ6ZY.js";import{a as ar}from"./chunk-BH6
14
14
  `):e==="linux"?["Google Chrome is required but was not found at /usr/bin/google-chrome.","(amd64 / x86_64 only \u2014 Google does not ship Chrome for Linux ARM.)","","Debian / Ubuntu (any version):"," wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"," sudo apt install -y ./google-chrome-stable_current_amd64.deb","","Fedora / RHEL / AlmaLinux / Rocky:"," sudo dnf install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
15
15
  `):e==="win32"?["Google Chrome is required but was not found in Program Files or AppData.","","Install via winget (Windows 10 1809+):"," winget install --id Google.Chrome -e --silent","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=C:\\path\\to\\chrome.exe","to point at a non-standard install."].join(`
16
16
  `):["Google Chrome is required.","Install from https://www.google.com/chrome/","(Note: no official Chrome builds for BSD or Alpine/musl Linux.)"].join(`
17
- `)}function Hs(e){let t=Ie(),r=[`--remote-debugging-port=${e.port}`,`--user-data-dir=${e.userDataDir}`,`--window-size=${e.width},${e.height}`,"--no-first-run","--no-default-browser-check","--disable-blink-features=AutomationControlled","--disable-features=DownloadBubble,DownloadBubbleV2","--safebrowsing-disable-download-protection","--disable-popup-blocking","--disable-notifications","--disable-infobars","--disable-translate","--disable-prompt-on-repost","--disable-background-networking","--disable-client-side-phishing-detection","--disable-default-apps","--disable-hang-monitor","--disable-sync","--metrics-recording-only","--safebrowsing-disable-auto-update","--disable-backgrounding-occluded-windows","--disable-background-timer-throttling","--test-type=webdriver","--allow-pre-commit-input","--enable-logging","--v=1"];return t==="linux"&&(r.push("--no-sandbox"),r.push("--disable-dev-shm-usage"),r.push("--password-store=basic")),t==="darwin"&&r.push("--use-mock-keychain"),e.headless&&r.push("--headless=new"),r}function Ks(e){return new Promise(t=>{let r=Ms({port:e,host:"127.0.0.1"});r.setTimeout(1e3),r.on("connect",()=>{r.destroy(),t(!0)}),r.on("timeout",()=>{r.destroy(),t(!1)}),r.on("error",()=>{r.destroy(),t(!1)})})}async function qs(){for(let e=st;e<=nt;e++)if(!await Ks(e))return e;throw new Error(`All CDP ports ${st}-${nt} are in use. Close other Chrome instances.`)}var _e=class extends Error{constructor(t){super(t),this.name="CdpReadinessError"}};async function Gs(e,t){let r=Date.now(),s=`http://127.0.0.1:${e}/json/version`;for(;Date.now()-r<t;){try{if((await D(s)).ok)return`http://127.0.0.1:${e}`}catch{}await new Promise(n=>setTimeout(n,200))}throw new _e(`Chrome CDP not ready after ${t}ms on port ${e}`)}var zs=3e4,Ws=2;function Mr(e,t,r){let s=process.env[e];if(s==null||s.trim()==="")return t;let n=Number(s);return!Number.isInteger(n)||n<r?t:n}function Js(e){return Math.min(500*e,3e3)}function Nr(e,t){try{if(e.pid)if(t==="win32")$r("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"});else try{process.kill(-e.pid,"SIGKILL")}catch{e.kill("SIGKILL")}else e.kill("SIGKILL")}catch{}}async function Br(e){let t=process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD;if(!(t!=null&&Ns.has(t.toLowerCase()))&&!Bs())throw ot()?.log("error","CHROME_NOT_FOUND","Startup gate: Chrome unavailable at standard system paths",{platform:process.platform,kane_cli_chrome_path:process.env.KANE_CLI_CHROME_PATH??null,skip_browser_download:process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD??null}),new Be(Vs());let s=Ie(),n=$s(),o=Mr("KANE_CLI_CDP_TIMEOUT_MS",zs,1),u=Mr("KANE_CLI_CDP_RETRIES",Ws,0)+1,i;for(let l=1;l<=u;l++){let h=await qs(),f=Hs({port:h,...e});e.startUrl&&f.push(e.startUrl);let w=$r(n,f,{stdio:"ignore",detached:!0});w.unref();try{let g=await new Promise((I,S)=>{w.on("error",k=>{S(new Error(`Failed to launch Chrome: ${k.message}. Is Chrome installed at ${n}?`))}),w.on("close",k=>{k!==null&&k!==0&&S(new _e(`Chrome exited during startup with code ${k}`))}),Gs(h,o).then(I,S)});return{process:w,port:h,cdpEndpoint:g,kill(){Nr(w,s)}}}catch(g){if(i=g,!(g instanceof _e))throw g;Nr(w,s),ot()?.log("warn","CHROME_CDP_LAUNCH_RETRY",`Chrome CDP launch attempt ${l}/${u} failed`,{attempt:l,max_attempts:u,port:h,timeout_ms:o,headless:e.headless??!1,error:g.message}),l<u&&await new Promise(I=>setTimeout(I,Js(l)))}}throw i??new Error("Chrome launch failed after retries")}async function Vr(e){if(e.cft)return{instance:null,tempDir:null};if(e.wsEndpoint)return{wsEndpoint:e.wsEndpoint,instance:null,tempDir:null};if(e.cdpEndpoint){let n=await D(`${e.cdpEndpoint}/json/version`);if(!n.ok)throw new Error(`CDP endpoint not reachable: ${e.cdpEndpoint} (${n.status})`);return{cdpEndpoint:e.cdpEndpoint,instance:null,tempDir:null}}let t,r=null;if(e.config.chrome_profile_path)t=e.config.chrome_profile_path.replace("~",process.env.HOME??"~");else{r=Qs(Zs(Xs(),"kane-clean-")),t=r;let n=r;je("tempDir",()=>{try{Ys(n,{recursive:!0,force:!0})}catch{}})}let s=await Br({userDataDir:t,width:e.config.window_size.width,height:e.config.window_size.height,startUrl:e.startUrl,headless:e.headless});return{cdpEndpoint:s.cdpEndpoint,instance:s,tempDir:r}}function Hr(e){let t={objective:e.objective,model:e.model,width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,stream:!0,max_steps:e.maxSteps??30,headless:e.headless??!1};return e.url&&(t.url=e.url),e.requireStartUrl&&(t.require_start_url=!0),e.chrome.wsEndpoint?t.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(t.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(t.username=e.auth.basicAuth.username,t.access_key=e.auth.basicAuth.access_key):e.auth.token&&(t.auth={type:"bearer",token:e.auth.token}),e.disableAskUser&&(t.disable_ask_user=!0),e.enableTaskSkills&&(t.enable_task_skills=!0),e.networkWs&&(t.network_ws=!0),e.variables&&Object.keys(e.variables).length>0&&(t.variables=e.variables),e.globalContext&&(t.global_context=e.globalContext),e.localContext&&(t.local_context=e.localContext),e.sessionContext&&(t.session_context=e.sessionContext),t}import{readdirSync as en,readFileSync as qr,existsSync as Gr}from"fs";import{join as tn}from"path";function Kr(e,t){if(!Gr(e))return{};let r={},s;try{s=en(e).filter(n=>n.endsWith(".json")).sort()}catch{return{}}for(let n of s)try{let o=qr(tn(e,n),"utf-8"),a=JSON.parse(o);if(a&&typeof a=="object"){for(let[u,i]of Object.entries(a))if(i&&typeof i=="object"&&"value"in i){let l=i;r[u]={value:l.value,secret:l.secret??!1,syntax:l.syntax??`{{${u}}}`}}}}catch{t?t("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:n}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${n}
17
+ `)}function Hs(e){let t=Ie(),r=[`--remote-debugging-port=${e.port}`,`--user-data-dir=${e.userDataDir}`,`--window-size=${e.width},${e.height}`,"--no-first-run","--no-default-browser-check","--disable-blink-features=AutomationControlled","--disable-features=DownloadBubble,DownloadBubbleV2","--safebrowsing-disable-download-protection","--disable-popup-blocking","--disable-notifications","--disable-infobars","--disable-translate","--disable-prompt-on-repost","--disable-background-networking","--disable-client-side-phishing-detection","--disable-default-apps","--disable-hang-monitor","--disable-sync","--metrics-recording-only","--safebrowsing-disable-auto-update","--disable-backgrounding-occluded-windows","--disable-background-timer-throttling","--test-type=webdriver","--allow-pre-commit-input","--enable-logging","--v=1"];return t==="linux"&&(r.push("--no-sandbox"),r.push("--disable-dev-shm-usage"),r.push("--password-store=basic")),t==="darwin"&&r.push("--use-mock-keychain"),e.headless&&r.push("--headless=new"),r}function Ks(e){return new Promise(t=>{let r=Ms({port:e,host:"127.0.0.1"});r.setTimeout(1e3),r.on("connect",()=>{r.destroy(),t(!0)}),r.on("timeout",()=>{r.destroy(),t(!1)}),r.on("error",()=>{r.destroy(),t(!1)})})}async function qs(){for(let e=st;e<=nt;e++)if(!await Ks(e))return e;throw new Error(`All CDP ports ${st}-${nt} are in use. Close other Chrome instances.`)}var _e=class extends Error{constructor(t){super(t),this.name="CdpReadinessError"}};async function Gs(e,t){let r=Date.now(),s=`http://127.0.0.1:${e}/json/version`;for(;Date.now()-r<t;){try{if((await D(s)).ok)return`http://127.0.0.1:${e}`}catch{}await new Promise(n=>setTimeout(n,200))}throw new _e(`Chrome CDP not ready after ${t}ms on port ${e}`)}var zs=3e4,Ws=2;function Mr(e,t,r){let s=process.env[e];if(s==null||s.trim()==="")return t;let n=Number(s);return!Number.isInteger(n)||n<r?t:n}function Js(e){return Math.min(500*e,3e3)}function Nr(e,t){try{if(e.pid)if(t==="win32")$r("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"});else try{process.kill(-e.pid,"SIGKILL")}catch{e.kill("SIGKILL")}else e.kill("SIGKILL")}catch{}}async function Br(e){let t=process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD;if(!(t!=null&&Ns.has(t.toLowerCase()))&&!Bs())throw ot()?.log("error","CHROME_NOT_FOUND","Startup gate: Chrome unavailable at standard system paths",{platform:process.platform,kane_cli_chrome_path:process.env.KANE_CLI_CHROME_PATH??null,skip_browser_download:process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD??null}),new Be(Vs());let s=Ie(),n=$s(),o=Mr("KANE_CLI_CDP_TIMEOUT_MS",zs,1),u=Mr("KANE_CLI_CDP_RETRIES",Ws,0)+1,i;for(let l=1;l<=u;l++){let h=await qs(),f=Hs({port:h,...e});e.startUrl&&f.push(e.startUrl);let w=$r(n,f,{stdio:"ignore",detached:!0});w.unref();try{let g=await new Promise((I,S)=>{w.on("error",k=>{S(new Error(`Failed to launch Chrome: ${k.message}. Is Chrome installed at ${n}?`))}),w.on("close",k=>{k!==null&&k!==0&&S(new _e(`Chrome exited during startup with code ${k}`))}),Gs(h,o).then(I,S)});return{process:w,port:h,cdpEndpoint:g,kill(){Nr(w,s)}}}catch(g){if(i=g,!(g instanceof _e))throw g;Nr(w,s),ot()?.log("warn","CHROME_CDP_LAUNCH_RETRY",`Chrome CDP launch attempt ${l}/${u} failed`,{attempt:l,max_attempts:u,port:h,timeout_ms:o,headless:e.headless??!1,error:g.message}),l<u&&await new Promise(I=>setTimeout(I,Js(l)))}}throw i??new Error("Chrome launch failed after retries")}async function Vr(e){if(e.cft)return{instance:null,tempDir:null};if(e.wsEndpoint)return{wsEndpoint:e.wsEndpoint,instance:null,tempDir:null};if(e.cdpEndpoint){let n=await D(`${e.cdpEndpoint}/json/version`);if(!n.ok)throw new Error(`CDP endpoint not reachable: ${e.cdpEndpoint} (${n.status})`);return{cdpEndpoint:e.cdpEndpoint,instance:null,tempDir:null}}let t,r=null;if(e.config.chrome_profile_path)t=e.config.chrome_profile_path.replace("~",process.env.HOME??"~");else{r=Qs(Zs(Xs(),"kane-clean-")),t=r;let n=r;je("tempDir",()=>{try{Ys(n,{recursive:!0,force:!0})}catch{}})}let s=await Br({userDataDir:t,width:e.config.window_size.width,height:e.config.window_size.height,startUrl:e.startUrl,headless:e.headless});return{cdpEndpoint:s.cdpEndpoint,instance:s,tempDir:r}}function Hr(e){let t={objective:e.objective,model:e.model,width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,stream:!0,max_steps:e.maxSteps??30,headless:e.headless??!1};return e.url&&(t.url=e.url),e.requireStartUrl&&(t.require_start_url=!0),e.chrome.wsEndpoint?t.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(t.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(t.username=e.auth.basicAuth.username,t.access_key=e.auth.basicAuth.access_key):e.auth.token&&(t.auth={type:"bearer",token:e.auth.token}),e.disableAskUser&&(t.disable_ask_user=!0),e.enableTaskSkills&&(t.enable_task_skills=!0),e.networkWs&&(t.network_ws=!0),e.networkSse&&(t.network_sse=!0),e.variables&&Object.keys(e.variables).length>0&&(t.variables=e.variables),e.globalContext&&(t.global_context=e.globalContext),e.localContext&&(t.local_context=e.localContext),e.sessionContext&&(t.session_context=e.sessionContext),t}import{readdirSync as en,readFileSync as qr,existsSync as Gr}from"fs";import{join as tn}from"path";function Kr(e,t){if(!Gr(e))return{};let r={},s;try{s=en(e).filter(n=>n.endsWith(".json")).sort()}catch{return{}}for(let n of s)try{let o=qr(tn(e,n),"utf-8"),a=JSON.parse(o);if(a&&typeof a=="object"){for(let[u,i]of Object.entries(a))if(i&&typeof i=="object"&&"value"in i){let l=i;r[u]={value:l.value,secret:l.secret??!1,syntax:l.syntax??`{{${u}}}`}}}}catch{t?t("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:n}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${n}
18
18
  `)}return r}function zr(e){if(!Gr(e))throw new Error(`Variables file not found: ${e}`);let t=qr(e,"utf-8"),r=JSON.parse(t),s={};if(r&&typeof r=="object"){for(let[n,o]of Object.entries(r))if(o&&typeof o=="object"&&"value"in o){let a=o;s[n]={value:a.value,secret:a.secret??!1,syntax:a.syntax??`{{${n}}}`}}}return s}function Wr(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Invalid --variables JSON")}let r={};if(t&&typeof t=="object"){for(let[s,n]of Object.entries(t))if(n&&typeof n=="object"&&"value"in n){let o=n;r[s]={value:o.value,secret:o.secret??!1,syntax:o.syntax??`{{${s}}}`}}}return r}function Jr(e,t,r){let s=Kr(e,r),n=Kr(t,r);return{...s,...n}}var fe=class{constructor(t){this.baseUrl=t}async pushSecret(t){let r=De(t.username,t.accessKey),s=await D(`${this.baseUrl}/logistics/v1.0/secrets/create`,{method:"PUT",headers:{Authorization:r,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({secretKey:t.secretKey,secretValue:t.secretValue,orgId:t.orgId,username:t.username,scope:"user",type:"user",accessKey:t.accessKey})});if(!s.ok)throw new Error(`Push secret failed: ${s.status} ${await s.text()}`)}static extractVariableKeys(t){let r=t.matchAll(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g),s=new Set;for(let n of r)s.add(n[1]);return[...s]}};var pe=class extends Gt{constructor(t,r,s){super(t,{username:r,accessKey:s})}async upsertVariable(t){let r=t.environmentId??0,s=await D(`${this.baseUrl}/v1/variables`,{method:"POST",headers:this.headers(),body:JSON.stringify({name:t.name,value:String(t.value),type:"variable",value_type:"string",is_persist:t.isPersist??!1,environment_id:r})});if(s.ok)return{id:(await s.json()).id??0};if(s.status!==409&&s.status!==422)return{id:0};if(!(await D(`${this.baseUrl}/v1/variables/name/${encodeURIComponent(t.name)}`,{method:"PUT",headers:this.headers(),body:JSON.stringify({value:String(t.value),value_type:"string",type:"variable",environment_id:r})})).ok)return{id:0};let o=await D(`${this.baseUrl}/v1/variables/${encodeURIComponent(t.name)}?environment_id=${r}`,{method:"GET",headers:this.headers()});return o.ok?{id:(await o.json()).data?.id??0}:{id:0}}};function Qr(e,t){if(Object.keys(e).length===0)return{};let r={};for(let[s,n]of Object.entries(e)){let o=n.syntax??`{{${s}}}`;t.includes(o)&&(r[s]=n)}return r}function Yr(e){let t=Jr(e.globalDir,e.localDir,e.onLoadError),r=e.file?zr(e.file):{},s=e.inline?Wr(e.inline):{},n={...t,...r,...s},o=Object.keys(n).length>0,{variables:a,objective:u}=o?ue(n,e.objective):{variables:{},objective:e.objective},i=Object.entries(n).filter(([,h])=>h.secret),l=Object.entries(n).filter(([,h])=>!h.secret);return{raw:n,auteur:a,auteurObjective:u,secretEntries:i,nonSecretEntries:l}}async function Zr(e){if(e.localMode)return{};let t=W(e.env);if(e.variables.secretEntries.length>0){let s=new fe(t.secretsBaseUrl);for(let[n,o]of e.variables.secretEntries)s.pushSecret({secretKey:n,secretValue:o.value,username:e.auth.username,accessKey:e.auth.access_key,orgId:e.orgId}).then(()=>e.log("info","SECRET_PUSH_OK","Secret pushed",{key:n})).catch(a=>e.log("error","SECRET_PUSH_FAILED","Secret push failed",{key:n,error:String(a)}))}let r={};if(e.variables.nonSecretEntries.length>0){let s=new pe(t.tmsBaseUrl,e.auth.username,e.auth.access_key);for(let[n,o]of e.variables.nonSecretEntries)try{let a=await s.upsertVariable({name:n,value:o.value});r[n]=a.id,e.log("info","VAR_PUSH_OK","Variable pushed",{name:n,id:a.id})}catch(a){e.log("error","VAR_PUSH_FAILED","Variable push failed",{name:n,error:String(a)})}}return r}import{readFileSync as rn,existsSync as sn}from"fs";function It(e){if(!sn(e))return null;try{return rn(e,"utf-8").trim()||null}catch{return null}}import{writeFileSync as nn,mkdirSync as on}from"fs";import{dirname as Xr}from"path";function Ct(e){let t=le(e.sourcePath);try{on(Xr(t),{recursive:!0})}catch(s){return process.stderr.write(`
19
19
  \u26A0 Failed to create output directory.
20
20
  ${s.message}
@@ -45,7 +45,7 @@ import{a as Se,b as nr}from"./chunk-C5UNZ6ZY.js";import{a as ar}from"./chunk-BH6
45
45
  `),!1;let m=c.sessionId,v=o.onLockConflict??i.rootGlobal.on_lock_conflict??"readonly",y=await fs({tmsBaseUrl:w.tmsBaseUrl,testId:p.testId,fromCommitId:p.fromCommitId,newCommitId:m,basicAuth:d,onLockConflict:v});return y==="ok"?(_=!0,p.newCommitId=m,c.log("info","MID_RUN_LOCK_ACQUIRED","Mid-run lock acquired",{test_id:p.testId}),a&&t.onLockState({phase:"acquired",scope:"mid_run"}),vt({baseUrl:ze(w.tmsBaseUrl),testId:p.testId,auth:We(d),lifecycle:r}),!0):(c.log("error","MID_RUN_LOCK_CONFLICT","Mid-run lock acquisition failed",{reason:y}),a&&t.onLockState({phase:"conflict",scope:"mid_run",reason:y}),process.stderr.write(`error: mid-run lock acquisition failed (${y})
46
46
  `),!1)};if(a){let d=o.author===!0;d&&(pt(),c.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed"));let{authorBoundary:m,cancelledInPhase:v,shrinkCount:y}=await yr({decisions:p.decisions,forceAuthor:d,hasRetry:o.retry===!0||o.retryCount!==void 0,maxShrinks:o.retryCount!==void 0?parseInt(o.retryCount,10):Se.maxShrinks,runReplayPhase:Rs,session:c,accumulator:te,acquireLockIfNeeded:$t});if(N=y>0,y>0&&(c.log("info","RETRY_TRIGGERED","Retry loop triggered",{shrink_count:y,final_author_boundary:m}),t.onRetryAttempt({shrink_count:y,final_author_boundary:m,complete_reauthor:m===0})),m===0&&y>0&&c.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback",{shrink_count:y}),!v&&m>=0)for(let b=m;b<i.steps.length;b++){let R=i.steps[b];if(!te.shouldRunFlatStep(R))continue;Nt(b),L=!0;let C=c.nextRunIndex();ne=C,await Ze(he(oe.raw,R.config.variables,R.objective).raw);let A=Mt(b,C),J=Date.now(),z=null,U=null,K=null,B=!1,Y=0;try{let E=at(A,{environment:f,assertionMode:Lt});r.register("runner",()=>{it()&&(P=!0);try{E.cancel()}catch{}}),F?.setRunActive(!0);try{for await(let T of E.events){if(t.onAgentEvent(T),T.type==="bifurcation"){let x=T.count??T.flows?.length??0;(T.is_single_flow??x<=1)||(K=T.flows??null,B=!0,Y=0)}else if(T.type==="run_start"&&B)Y++;else if(T.type==="step_event"&&T.event==="reasoning")F?.setStepText(T.detail);else if(T.type==="step_end"&&(T.status==="passed"&&F?.setStepComplete(),be)){let x=B?Math.max(0,Y-1):0;be(T.index,x,T.child_id)}if(T.type==="run_end"){z=T;break}if(T.type==="error"){U=T.message??"runner error";break}}try{E.cancel()}catch{}}finally{F?.setRunActive(!1),r.cleanup("runner","Step complete")}}catch(E){U=E.message}let Z=Math.round((Date.now()-J)/1e3),O=et(b,C,z,K,U,Z);if(c.recordStepRun({testmdStepIndex:i.steps[b].flatIndex,runIndex:C,totalRunDirs:z?.total_runs??1}),!O||P)break}}else{let{effectiveDecisions:d}=await import("./effective-decisions-DRM3JSR4.js"),{decideRetry:m}=await import("./replay-policy-6USQBT3E.js"),v=o.retry===!0||o.retryCount!==void 0,y=o.retryCount!==void 0?parseInt(o.retryCount,10):Se.maxShrinks,b=o.author===!0;b&&(pt(),c.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed"));let R=b?0:Me(p.decisions),C=0,A=null,J=p.decisions.filter(B=>B.kind==="replay").length,z=p.decisions.length-J,U=[];o.push&&U.push("--push"),v&&U.push("--retry"),o.retryCount!==void 0&&U.push(`--retry-count=${o.retryCount}`),b&&U.push("--author");let K={source:s,steps:{total:p.decisions.length,replay:J,author:z},model:I,viewport:{width:$.window_size.width,height:$.window_size.height},chrome:Q.cdpEndpoint??Q.wsEndpoint??"managed",session:c.sessionName??"ephemeral",variables:{count:Object.keys(H.raw).length,secrets:Object.values(H.raw).filter(B=>B.secret).length,names:Object.keys(H.raw)},flags:U,mode:h.mode??"testing"};for(;;){let B=c.snapshot(),Y=te.snapshot(),Z=d(p.decisions,R,b);if(C>=1){let x=R===0?`\u21BB Complete re-author \u2014 retry budget exhausted (${C}/${y})`:`\u21BB Retry ${C}/${y} \u2014 replay 0..${R-1}, author ${R}..${p.decisions.length-1}
47
47
  reason: replay miss at step ${(A??0)+1}`;process.stderr.write(x+`
48
- `)}let O=C>=1&&R>0&&A!==null?{startIdx:0,endIdx:A,count:A}:void 0;F?.setRunActive(!0);let E=await jn({decisions:Z,resolved:i,session:c,accumulator:te,tuiConfig:$,globalConfig:K,buildStepConfigAt:Mt,buildReplayConfig:x=>{let X=p.decisions[x];if(X.kind!=="replay")throw new Error("expected replay decision at index "+x);let re=i.steps[x];return ht({step:re,decision:X,chrome:Q,auth:l,sessionId:c.sessionId,runIndex:c.nextRunIndex(),sessionDir:c.sessionDir,windowSize:{width:$.window_size.width,height:$.window_size.height},forceNavigateUrl:x===0?ye??void 0:void 0,sessionContext:c.getContext(),variables:Pn(oe.raw,re.config.variables,re.objective)})},onAnyAuthorStep:()=>{L=!0},onCancel:()=>{V=!0},topBannerModel:I,topBannerAuth:`${S.getActiveProfile()??"no profile"}/${f}`,spawnOpts:{environment:f,mode:h.mode??"testing",assertionMode:Lt,log:(x,X,re,tt)=>c.log(x,X,re,tt)},priorAttemptRollup:O,pushStepLevelDelta:(x,X)=>Ze(he(oe.raw,x,X).raw),onSequencerStepEnd:(x,X,re,tt)=>{let Is=Math.round((Date.now()-tt)/1e3),Cs=x.hadError?x.reason??"runner error":null,ks=et(X,re,x.runEnd,x.bifurcationFlows??null,Cs,Is);return c.recordStepRun({testmdStepIndex:i.steps[X].flatIndex,runIndex:re,totalRunDirs:x.runEnd?.total_runs??x.bifurcationFlows?.length??1}),ks},screenshotDispatcher:be,onReasoning:x=>F?.setStepText(x),onStepComplete:()=>F?.setStepComplete(),onSpawnStart:x=>{ne=x},host:t});if(F?.setRunActive(!1),E.cancelled){r.cleanup("marker-overlay","user cancelled run"),r.cleanup("chrome","user cancelled run");break}if(E.failedAt===null)break;let T=m({failedAt:E.failedAt,shrinkCount:C,hasRetry:v,maxShrinks:y});if(T.kind==="fail"||!_&&!await $t())break;c.rollback(B),te.rollback(Y),T.kind==="complete-reauthor"?R=0:R=T.newAuthorBoundary,C++,N=!0,c.log("info","RETRY_TRIGGERED","Retry loop triggered (TTY)",{shrink_count:C,failed_at:A}),R===0&&c.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback (TTY)",{shrink_count:C}),A=E.failedAt}}let M=te.finalize(),ie=Math.round((Date.now()-vs)/1e3),ws={session:c,resolvedAuth:l,chromeResult:Q,chromeInstance:xe??null,testId:c.testId??null,preparedVariables:H,variableIds:Pe,globalContext:jt,localContext:Ut,tuiConfig:$,env:f,localMode:!!o.local},ae=await es(ws,{performUpload:async()=>{if(!l.basicAuth)return null;let d=W(f),m=(L||o.push===!0)&&!V,v=(_||p.isFirstRun)&&!V&&M.overallStatus==="passed",y=ge&&(_||p.isFirstRun);c.log("info","PIPELINE_GATE_STATE","Derived gate state (finalize)",{phase:"finalize",shouldUploadArtifacts:ge,shouldUploadPipeline:y,shouldReplaceLocalOutput:m,shouldCommit:v,lockHeld:_,anyAuthorStepRan:L,cancelled:V,overallStatus:M.overallStatus});let b=os({session:c,env:f,auth:l,variables:H,variableIds:Pe,projectId:G,folderId:Ae,totalSteps:M.outcomes.length,totalDuration:ie,screenshotExtMap:Ee?.getExtMap(),codeExport:as({codeExport:o.codeExport,codeLanguage:o.codeLanguage,skipCodeValidation:o.skipCodeValidation},$.code_export),onProgress:()=>{},log:(C,A,J,z)=>c.log(C,A,J,z),shouldUploadArtifacts:y,shouldReplaceLocalOutput:m,shouldCommit:v,isFirstRun:p.isFirstRun,resolvedTest:i,sourcePath:s,stepRunRecords:c.getStepRunRecords(),outcomes:M.outcomes,overallStatus:M.overallStatus,fromCommitId:p.fromCommitId,startedISO:Xe,durationS:ie,tmsIds:{testId:p.testId??c.testId??void 0,testcaseId:p.testcaseId??c.testcaseId??void 0,projectId:G??void 0,folderId:Ae??void 0,orgId:c.orgId??void 0,sessionName:c.sessionName??Ue(s)},tmsBaseUrl:w.tmsBaseUrl,testId:p.testId??void 0,newCommitId:p.newCommitId??void 0,basicAuth:l.basicAuth??void 0,decisions:p.decisions,wantsPush:o.push===!0,retryTriggered:N,forceAuthor:o.author===!0});p.newCommitId!=null&&(b.skipTmsFinalize=!0);let R=new ar(b);return a?await R.execute():await t.runUpload(R,C=>{if(C.testcaseId&&C.shareId&&G)return wt(d.testManagerUiUrl,G,C.testcaseId,C.shareId)})},runCleanup:()=>{r.cleanup("chrome","test.md run complete")},log:(d,m,v,y)=>c.log(d,m,v,y)},{overallStatus:M.overallStatus,outcomes:M.outcomes,sourcePath:s,title:i.rootTitle,rootSteps:i.rootSteps,startedISO:Xe,durationS:ie,localMode:!!o.local,skipLocalWrites:!0});await Ln(s,p,c,M.outcomes,M.overallStatus,Xe,ie,ae.uploadResult,$,o,{resolvedAuth:l,tmsBaseUrl:w.tmsBaseUrl},_,V);let Bt=W(f),Te=ae.uploadResult?.testcaseId,Oe=Te&&ae.uploadResult?.shareId&&G?wt(Bt.testManagerUiUrl,G,Te,ae.uploadResult.shareId):void 0,Vt={overallStatus:M.overallStatus,durationS:ie,decisions:p.decisions,outcomes:M.outcomes,cancelled:V,retryTriggered:N,lockHeld:_,anyAuthorStepRan:L,isFirstRun:p.isFirstRun,wantsPush:o.push===!0,uploadResult:ae.uploadResult,shouldUploadArtifacts:ge,shouldReplaceLocalOutput:L&&!V,shouldCommit:(_||p.isFirstRun)&&!V&&M.overallStatus==="passed",shareUrl:Oe},{buildSummaryEvent:_s}=await import("./SummaryBox-AAXB55TE.js");if(a?t.onAgentEvent(_s(Vt)):await t.onSummary(Vt),!a){let d=Te&&G?Fr(Bt.testManagerUiUrl,G,Te):void 0;await t.onLinks({recordedTestPath:s,outputDir:se(s),shareableLink:Oe,testCaseLink:d,codeExportDir:ae.uploadResult?.codeExportDir})}return t.onAgentEvent({type:"test_md_done",overall_status:M.overallStatus,duration_s:ie,session_id:c.sessionId,...Oe?{share_url:Oe}:{}}),{overallStatus:M.overallStatus,exitCode:M.overallStatus==="passed"?0:1,outputDir:se(s),durationS:ie,uploadResult:ae.uploadResult}}function xn(e,t){let r={...e,...t},s=Object.keys(r).length>0?ue(r,""):{variables:{},objective:"",keyMap:{}};return{raw:r,auteur:s.variables,auteurObjective:"",secretEntries:Object.entries(r).filter(([,n])=>n.secret),nonSecretEntries:Object.entries(r).filter(([,n])=>!n.secret)}}function he(e,t,r){let s={...e,...t??{}};if(Object.keys(s).length===0)return{raw:s,variables:{},objective:r};let n=ue(s,r);return{raw:s,variables:Qr(n.variables,n.objective),objective:n.objective}}function Pn(e,t,r){let s=he(e,t,r).variables;return Object.keys(s).length>0?s:void 0}function ms(e,t){let r=new Set(Ge),s={...e};for(let[n,o]of Object.entries(t))r.has(n)||n!=="variables"&&o!==void 0&&e[n]===void 0&&(s[n]=o);return s}function Tn(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}async function On(e,t,r,s,n,o){let a=tr(e),u=cr(t,ds(a)?a:null);mr(t,u);let i=le(e),l=ds(i)?JSON.parse(An(i,"utf8")):null,h=l?.testcase_id,f=l?.test_id,w=l?.commit_id,g=r.push===!0,I=r.retry===!0||r.retryCount!==void 0,S=r.author===!0;g&&!h&&process.stderr.write(`[--push] no meta.json yet \u2014 flag is a no-op on first run
48
+ `)}let O=C>=1&&R>0&&A!==null?{startIdx:0,endIdx:A,count:A}:void 0;F?.setRunActive(!0);let E=await jn({decisions:Z,resolved:i,session:c,accumulator:te,tuiConfig:$,globalConfig:K,buildStepConfigAt:Mt,buildReplayConfig:x=>{let X=p.decisions[x];if(X.kind!=="replay")throw new Error("expected replay decision at index "+x);let re=i.steps[x];return ht({step:re,decision:X,chrome:Q,auth:l,sessionId:c.sessionId,runIndex:c.nextRunIndex(),sessionDir:c.sessionDir,windowSize:{width:$.window_size.width,height:$.window_size.height},forceNavigateUrl:x===0?ye??void 0:void 0,sessionContext:c.getContext(),variables:Pn(oe.raw,re.config.variables,re.objective)})},onAnyAuthorStep:()=>{L=!0},onCancel:()=>{V=!0},topBannerModel:I,topBannerAuth:`${S.getActiveProfile()??"no profile"}/${f}`,spawnOpts:{environment:f,mode:h.mode??"testing",assertionMode:Lt,log:(x,X,re,tt)=>c.log(x,X,re,tt)},priorAttemptRollup:O,pushStepLevelDelta:(x,X)=>Ze(he(oe.raw,x,X).raw),onSequencerStepEnd:(x,X,re,tt)=>{let Is=Math.round((Date.now()-tt)/1e3),Cs=x.hadError?x.reason??"runner error":null,ks=et(X,re,x.runEnd,x.bifurcationFlows??null,Cs,Is);return c.recordStepRun({testmdStepIndex:i.steps[X].flatIndex,runIndex:re,totalRunDirs:x.runEnd?.total_runs??x.bifurcationFlows?.length??1}),ks},screenshotDispatcher:be,onReasoning:x=>F?.setStepText(x),onStepComplete:()=>F?.setStepComplete(),onSpawnStart:x=>{ne=x},host:t});if(F?.setRunActive(!1),E.cancelled){r.cleanup("marker-overlay","user cancelled run"),r.cleanup("chrome","user cancelled run");break}if(E.failedAt===null)break;let T=m({failedAt:E.failedAt,shrinkCount:C,hasRetry:v,maxShrinks:y});if(T.kind==="fail"||!_&&!await $t())break;c.rollback(B),te.rollback(Y),T.kind==="complete-reauthor"?R=0:R=T.newAuthorBoundary,C++,N=!0,c.log("info","RETRY_TRIGGERED","Retry loop triggered (TTY)",{shrink_count:C,failed_at:A}),R===0&&c.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback (TTY)",{shrink_count:C}),A=E.failedAt}}let M=te.finalize(),ie=Math.round((Date.now()-vs)/1e3),ws={session:c,resolvedAuth:l,chromeResult:Q,chromeInstance:xe??null,testId:c.testId??null,preparedVariables:H,variableIds:Pe,globalContext:jt,localContext:Ut,tuiConfig:$,env:f,localMode:!!o.local},ae=await es(ws,{performUpload:async()=>{if(!l.basicAuth)return null;let d=W(f),m=(L||o.push===!0)&&!V,v=(_||p.isFirstRun)&&!V&&M.overallStatus==="passed",y=ge&&(_||p.isFirstRun);c.log("info","PIPELINE_GATE_STATE","Derived gate state (finalize)",{phase:"finalize",shouldUploadArtifacts:ge,shouldUploadPipeline:y,shouldReplaceLocalOutput:m,shouldCommit:v,lockHeld:_,anyAuthorStepRan:L,cancelled:V,overallStatus:M.overallStatus});let b=os({session:c,env:f,auth:l,variables:H,variableIds:Pe,projectId:G,folderId:Ae,totalSteps:M.outcomes.length,totalDuration:ie,screenshotExtMap:Ee?.getExtMap(),codeExport:as({codeExport:o.codeExport,codeLanguage:o.codeLanguage,skipCodeValidation:o.skipCodeValidation},$.code_export),onProgress:()=>{},log:(C,A,J,z)=>c.log(C,A,J,z),shouldUploadArtifacts:y,shouldReplaceLocalOutput:m,shouldCommit:v,isFirstRun:p.isFirstRun,resolvedTest:i,sourcePath:s,stepRunRecords:c.getStepRunRecords(),outcomes:M.outcomes,overallStatus:M.overallStatus,fromCommitId:p.fromCommitId,startedISO:Xe,durationS:ie,tmsIds:{testId:p.testId??c.testId??void 0,testcaseId:p.testcaseId??c.testcaseId??void 0,projectId:G??void 0,folderId:Ae??void 0,orgId:c.orgId??void 0,sessionName:c.sessionName??Ue(s)},tmsBaseUrl:w.tmsBaseUrl,testId:p.testId??void 0,newCommitId:p.newCommitId??void 0,basicAuth:l.basicAuth??void 0,decisions:p.decisions,wantsPush:o.push===!0,retryTriggered:N,forceAuthor:o.author===!0});p.newCommitId!=null&&(b.skipTmsFinalize=!0);let R=new ar(b);return a?await R.execute():await t.runUpload(R,C=>{if(C.testcaseId&&C.shareId&&G)return wt(d.testManagerUiUrl,G,C.testcaseId,C.shareId)})},runCleanup:()=>{r.cleanup("chrome","test.md run complete")},log:(d,m,v,y)=>c.log(d,m,v,y)},{overallStatus:M.overallStatus,outcomes:M.outcomes,sourcePath:s,title:i.rootTitle,rootSteps:i.rootSteps,startedISO:Xe,durationS:ie,localMode:!!o.local,skipLocalWrites:!0});await Ln(s,p,c,M.outcomes,M.overallStatus,Xe,ie,ae.uploadResult,$,o,{resolvedAuth:l,tmsBaseUrl:w.tmsBaseUrl},_,V);let Bt=W(f),Te=ae.uploadResult?.testcaseId,Oe=Te&&ae.uploadResult?.shareId&&G?wt(Bt.testManagerUiUrl,G,Te,ae.uploadResult.shareId):void 0,Vt={overallStatus:M.overallStatus,durationS:ie,decisions:p.decisions,outcomes:M.outcomes,cancelled:V,retryTriggered:N,lockHeld:_,anyAuthorStepRan:L,isFirstRun:p.isFirstRun,wantsPush:o.push===!0,uploadResult:ae.uploadResult,shouldUploadArtifacts:ge,shouldReplaceLocalOutput:L&&!V,shouldCommit:(_||p.isFirstRun)&&!V&&M.overallStatus==="passed",shareUrl:Oe},{buildSummaryEvent:_s}=await import("./SummaryBox-3VIRYWQA.js");if(a?t.onAgentEvent(_s(Vt)):await t.onSummary(Vt),!a){let d=Te&&G?Fr(Bt.testManagerUiUrl,G,Te):void 0;await t.onLinks({recordedTestPath:s,outputDir:se(s),shareableLink:Oe,testCaseLink:d,codeExportDir:ae.uploadResult?.codeExportDir})}return t.onAgentEvent({type:"test_md_done",overall_status:M.overallStatus,duration_s:ie,session_id:c.sessionId,...Oe?{share_url:Oe}:{}}),{overallStatus:M.overallStatus,exitCode:M.overallStatus==="passed"?0:1,outputDir:se(s),durationS:ie,uploadResult:ae.uploadResult}}function xn(e,t){let r={...e,...t},s=Object.keys(r).length>0?ue(r,""):{variables:{},objective:"",keyMap:{}};return{raw:r,auteur:s.variables,auteurObjective:"",secretEntries:Object.entries(r).filter(([,n])=>n.secret),nonSecretEntries:Object.entries(r).filter(([,n])=>!n.secret)}}function he(e,t,r){let s={...e,...t??{}};if(Object.keys(s).length===0)return{raw:s,variables:{},objective:r};let n=ue(s,r);return{raw:s,variables:Qr(n.variables,n.objective),objective:n.objective}}function Pn(e,t,r){let s=he(e,t,r).variables;return Object.keys(s).length>0?s:void 0}function ms(e,t){let r=new Set(Ge),s={...e};for(let[n,o]of Object.entries(t))r.has(n)||n!=="variables"&&o!==void 0&&e[n]===void 0&&(s[n]=o);return s}function Tn(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}async function On(e,t,r,s,n,o){let a=tr(e),u=cr(t,ds(a)?a:null);mr(t,u);let i=le(e),l=ds(i)?JSON.parse(An(i,"utf8")):null,h=l?.testcase_id,f=l?.test_id,w=l?.commit_id,g=r.push===!0,I=r.retry===!0||r.retryCount!==void 0,S=r.author===!0;g&&!h&&process.stderr.write(`[--push] no meta.json yet \u2014 flag is a no-op on first run
49
49
  `),S&&(h=void 0,f=void 0,w=void 0);let k=s.resolvedAuth.basicAuth;if(!k){let N=await s.resolvedAuth.resolver.resolve(!0);N?.username&&N?.access_key&&(k={username:N.username,access_key:N.access_key},s.resolvedAuth.basicAuth=k)}let c=!!k,P=!r.local&&c&&f!=null&&w!=null&&h!=null,p=P&&(ur(u)||g);if(g&&!P)return process.stderr.write(`error: --push requires authenticated credentials for the lock API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
50
50
  `),{resolved:t,decisions:u,testId:f,testcaseId:h,fromCommitId:w,newCommitId:null,isFirstRun:!1,hasAuth:c,canLock:P,lockAcquired:!1,abort:{exitCode:2}};if(I&&!P)return process.stderr.write(`error: --retry requires authenticated credentials for the lock API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
51
51
  `),{resolved:t,decisions:u,testId:f,testcaseId:h,fromCommitId:w,newCommitId:null,isFirstRun:!1,hasAuth:c,canLock:P,lockAcquired:!1,abort:{exitCode:2}};if(S&&!c)return process.stderr.write(`error: --author requires authenticated credentials for the TMS API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as c}from"./chunk-3PISMPFM.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{u as s,v as a}from"./chunk-BGXAW2B5.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
2
+ import{a as c}from"./chunk-HPJP7NES.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{u as s,v as a}from"./chunk-3UCNDPTN.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l 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-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(`
2
+ import{b as We}from"./chunk-7N5H4KTV.js";import{a as ue,b as Te}from"./chunk-MUZCEGJD.js";import{d as Ke,f as xe}from"./chunk-LOIRZFV3.js";import{a as Ue}from"./chunk-JHSSBES2.js";import{a as qe}from"./chunk-UJDIXFEE.js";import{b as Ge}from"./chunk-C6S4IEBC.js";import{x as l}from"./chunk-3UCNDPTN.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{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};
2
+ import{x as o}from"./chunk-3UCNDPTN.js";import{a as m}from"./chunk-HCBYKLMW.js";import{a as e,b as i}from"./chunk-C44QQJR4.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:o.muted,error:o.red,success:o.green,info:o.orange,warning:o.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?o.orange:s[n]);return(0,r.jsxs)(e,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(e,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(e,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=o.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(e,{children:[(0,r.jsx)(e,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(e,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(e,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as D}from"./chunk-HZUTFC3G.js";import{a as A}from"./chunk-ALF5ETLD.js";import{p as S,q as C,r as P,s as U,t as N}from"./chunk-BGXAW2B5.js";import{createServer as Oe}from"http";import{randomBytes as He}from"crypto";import{URL as $e}from"url";import Z from"process";import{Buffer as ee}from"buffer";import re from"path";import{fileURLToPath as ke}from"url";import{promisify as Le}from"util";import te from"child_process";import Me,{constants as Ie}from"fs/promises";import Y from"process";import G,{constants as me}from"fs/promises";import j from"process";import le from"os";import L from"fs";import se from"fs";import z from"fs";var E;function ie(){try{return z.statSync("/.dockerenv"),!0}catch{return!1}}function ae(){try{return z.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function B(){return E===void 0&&(E=ie()||ae()),E}var k,ce=()=>{try{return se.statSync("/run/.containerenv"),!0}catch{return!1}};function u(){return k===void 0&&(k=ce()||B()),k}var K=()=>{if(j.platform!=="linux")return!1;if(le.release().toLowerCase().includes("microsoft"))return!u();try{if(L.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!u()}catch{}return L.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||L.existsSync("/run/WSL")?!u():!1},d=j.env.__IS_WSL_TEST__?K:K();var de=(()=>{let e="/mnt/",r;return async function(){if(r)return r;let t="/etc/wsl.conf",n=!1;try{await G.access(t,me.F_OK),n=!0}catch{}if(!n)return e;let o=await G.readFile(t,{encoding:"utf8"}),i=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(o);return i?(r=i.groups.mountPoint.trim(),r=r.endsWith("/")?r:`${r}/`,r):e}})(),fe=async()=>`${await de()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,M=async()=>d?fe():`${Y.env.SYSTEMROOT||Y.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;function f(e,r,t){let n=o=>Object.defineProperty(e,r,{value:o,enumerable:!0,writable:!0});return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){let o=t();return n(o),o},set(o){n(o)}}),e}import{promisify as Pe}from"util";import O from"process";import{execFile as Ae}from"child_process";import{promisify as pe}from"util";import ue from"process";import{execFile as ge}from"child_process";var he=pe(ge);async function I(){if(ue.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await he("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";return t==="com.apple.safari"?"com.apple.Safari":t}import we from"process";import{promisify as xe}from"util";import{execFile as ye,execFileSync as cr}from"child_process";var ve=xe(ye);async function X(e,{humanReadableOutput:r=!0,signal:t}={}){if(we.platform!=="darwin")throw new Error("macOS only");let n=r?[]:["-ss"],o={};t&&(o.signal=t);let{stdout:i}=await ve("osascript",["-e",e,n],o);return i.trim()}async function T(e){return X(`tell application "Finder" to set app_path to application file id "${e}" as string
2
+ import{a as D}from"./chunk-LZUTY7XS.js";import{a as A}from"./chunk-RJFHOZG6.js";import{p as S,q as C,r as P,s as U,t as N}from"./chunk-3UCNDPTN.js";import{createServer as Oe}from"http";import{randomBytes as He}from"crypto";import{URL as $e}from"url";import Z from"process";import{Buffer as ee}from"buffer";import re from"path";import{fileURLToPath as ke}from"url";import{promisify as Le}from"util";import te from"child_process";import Me,{constants as Ie}from"fs/promises";import Y from"process";import G,{constants as me}from"fs/promises";import j from"process";import le from"os";import L from"fs";import se from"fs";import z from"fs";var E;function ie(){try{return z.statSync("/.dockerenv"),!0}catch{return!1}}function ae(){try{return z.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function B(){return E===void 0&&(E=ie()||ae()),E}var k,ce=()=>{try{return se.statSync("/run/.containerenv"),!0}catch{return!1}};function u(){return k===void 0&&(k=ce()||B()),k}var K=()=>{if(j.platform!=="linux")return!1;if(le.release().toLowerCase().includes("microsoft"))return!u();try{if(L.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!u()}catch{}return L.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||L.existsSync("/run/WSL")?!u():!1},d=j.env.__IS_WSL_TEST__?K:K();var de=(()=>{let e="/mnt/",r;return async function(){if(r)return r;let t="/etc/wsl.conf",n=!1;try{await G.access(t,me.F_OK),n=!0}catch{}if(!n)return e;let o=await G.readFile(t,{encoding:"utf8"}),i=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(o);return i?(r=i.groups.mountPoint.trim(),r=r.endsWith("/")?r:`${r}/`,r):e}})(),fe=async()=>`${await de()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,M=async()=>d?fe():`${Y.env.SYSTEMROOT||Y.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;function f(e,r,t){let n=o=>Object.defineProperty(e,r,{value:o,enumerable:!0,writable:!0});return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){let o=t();return n(o),o},set(o){n(o)}}),e}import{promisify as Pe}from"util";import O from"process";import{execFile as Ae}from"child_process";import{promisify as pe}from"util";import ue from"process";import{execFile as ge}from"child_process";var he=pe(ge);async function I(){if(ue.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await he("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";return t==="com.apple.safari"?"com.apple.Safari":t}import we from"process";import{promisify as xe}from"util";import{execFile as ye,execFileSync as cr}from"child_process";var ve=xe(ye);async function X(e,{humanReadableOutput:r=!0,signal:t}={}){if(we.platform!=="darwin")throw new Error("macOS only");let n=r?[]:["-ss"],o={};t&&(o.signal=t);let{stdout:i}=await ve("osascript",["-e",e,n],o);return i.trim()}async function T(e){return X(`tell application "Finder" to set app_path to application file id "${e}" as string
3
3
  tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as be}from"util";import{execFile as Se}from"child_process";var Ce=be(Se),y={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},ur=new Map(Object.entries(y)),F=class extends Error{};async function _(e=Ce){let{stdout:r}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(r);if(!t)throw new F(`Cannot find Windows browser in stdout: ${JSON.stringify(r)}`);let{id:n}=t.groups,o=n.lastIndexOf("."),i=n.lastIndexOf("-"),c=o===-1?void 0:n.slice(0,o),a=i===-1?void 0:n.slice(0,i);return y[n]??y[c]??y[a]??{name:n,id:n}}var Ee=Pe(Ae),Be=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,r=>r.toUpperCase());async function H(){if(O.platform==="darwin"){let e=await I();return{name:await T(e),id:e}}if(O.platform==="linux"){let{stdout:e}=await Ee("xdg-mime",["query","default","x-scheme-handler/http"]),r=e.trim();return{name:Be(r.replace(/.desktop$/,"").replace("-"," ")),id:r}}if(O.platform==="win32")return _();throw new Error("Only macOS, Linux, and Windows are supported")}var Te=Le(te.execFile),$=re.dirname(ke(import.meta.url)),q=re.join($,"xdg-open"),{platform:w,arch:V}=Z;async function Fe(){let e=await M(),r=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,t=ee.from(r,"utf16le").toString("base64"),{stdout:n}=await Te(e,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",t],{encoding:"utf8"}),o=n.trim(),i={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return i[o]?{id:i[o]}:{}}var J=async(e,r)=>{let t;for(let n of e)try{return await r(n)}catch(o){t=o}throw t},v=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return J(e.app,a=>v({...e,app:a}));let{name:r,arguments:t=[]}=e.app??{};if(t=[...t],Array.isArray(r))return J(r,a=>v({...e,app:{name:a,arguments:t}}));if(r==="browser"||r==="browserPrivate"){let a={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.Browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},l={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},s=d?await Fe():await H();if(s.id in a){let m=a[s.id];return r==="browserPrivate"&&t.push(l[m]),v({...e,app:{name:g[m],arguments:t}})}throw new Error(`${s.name} is not supported as a default browser`)}let n,o=[],i={};if(w==="darwin")n="open",e.wait&&o.push("--wait-apps"),e.background&&o.push("--background"),e.newInstance&&o.push("--new"),r&&o.push("-a",r);else if(w==="win32"||d&&!u()&&!r){n=await M(),o.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),d||(i.windowsVerbatimArguments=!0);let a=["Start"];e.wait&&a.push("-Wait"),r?(a.push(`"\`"${r}\`""`),e.target&&t.push(e.target)):e.target&&a.push(`"${e.target}"`),t.length>0&&(t=t.map(l=>`"\`"${l}\`""`),a.push("-ArgumentList",t.join(","))),e.target=ee.from(a.join(" "),"utf16le").toString("base64")}else{if(r)n=r;else{let a=!$||$==="/",l=!1;try{await Me.access(q,Ie.X_OK),l=!0}catch{}n=Z.versions.electron??(w==="android"||a||!l)?"xdg-open":q}t.length>0&&o.push(...t),e.wait||(i.stdio="ignore",i.detached=!0)}w==="darwin"&&t.length>0&&o.push("--args",...t),e.target&&o.push(e.target);let c=te.spawn(n,o,i);return e.wait?new Promise((a,l)=>{c.once("error",l),c.once("close",s=>{if(!e.allowNonzeroExitCode&&s>0){l(new Error(`Exited with code ${s}`));return}a(c)})}):(c.unref(),c)},_e=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return v({...r,target:e})};function Q(e){if(typeof e=="string"||Array.isArray(e))return e;let{[V]:r}=e;if(!r)throw new Error(`${V} is not supported`);return r}function b({[w]:e},{wsl:r}){if(r&&d)return Q(r);if(!e)throw new Error(`${w} is not supported`);return Q(e)}var g={};f(g,"chrome",()=>b({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));f(g,"brave",()=>b({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));f(g,"firefox",()=>b({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));f(g,"edge",()=>b({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));f(g,"browser",()=>"browser");f(g,"browserPrivate",()=>"browserPrivate");var oe=_e;var ne=class{profile;environment;creds;oauth;constructor(r="default",t="prod",n){this.profile=r,this.environment=t,this.creds=n??new D,this.oauth=new A(t)}async login(){let{server:r,port:t}=await this.startCallbackServer(),n=N(t);try{let o=this.creds.loadClient(this.profile,this.environment),i=o?.redirect_uris;(!o||!i?.includes(n))&&(o=await this.oauth.registerClient(n),this.creds.saveClient(this.profile,this.environment,o));let c=o.client_id,[a,l]=A.generatePkce(),s=He(32).toString("hex"),m=this.oauth.buildAuthorizationUrl(c,l,s,n),p=await this.waitForCallback(r,t,m,s);if(!p)throw new Error("Login cancelled or timed out");let h=await this.oauth.exchangeCode(p,c,a,n),x={access_token:h.access_token,refresh_token:h.refresh_token,expires_at:Math.floor(Date.now()/1e3)+h.expires_in,scope:h.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,x),this.creds.setActiveProfile(this.profile),x}catch(o){throw r.close(),o}}startCallbackServer(){return new Promise((r,t)=>{let n=C,o=()=>{let i=Oe();i.on("error",c=>{c.code==="EADDRINUSE"&&n<P?(n++,o()):t(new Error(`Failed to start callback server: ${c.message}. Ports ${C}-${P} are all in use.`))}),i.listen(n,S,()=>{r({server:i,port:n})})};o()})}waitForCallback(r,t,n,o){return new Promise(i=>{let c=!1,a=setTimeout(()=>l(null),12e4),l=s=>{c||(c=!0,clearTimeout(a),r.close(),i(s))};r.on("request",(s,m)=>{let p=new $e(s.url??"/",`http://${S}:${t}`);if(p.pathname!==U){m.writeHead(404),m.end();return}let h=p.searchParams.get("state"),x=p.searchParams.get("code");if(p.searchParams.get("error")){m.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),m.end(R({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),l(null);return}if(h!==o){m.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),m.end(R({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),l(null);return}m.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),m.end(R({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),l(x)}),oe(n).catch(s=>{let m=s instanceof Error?s.message:String(s);process.stderr.write(`[auth] Could not open browser: ${m}
4
4
  Please open this URL manually: ${n}
5
5
  `)})})}};function R(e){let r=e.state==="success",t=r?"#22c55e":"#ef4444",n=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",o=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=e.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
@@ -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-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};
2
+ import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,e as o}from"./chunk-3UCNDPTN.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{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-RBG4VTHQ.js";import{a as T}from"./chunk-LPUQ4HWQ.js";import{a as k}from"./chunk-3PISMPFM.js";import{a as _}from"./chunk-EAUU5F4P.js";import{x as i}from"./chunk-BGXAW2B5.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as u,b as s}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as S}from"./chunk-UR6MHSHU.js";var e=S(K(),1);var r=S(O(),1);function V(n,x,c){return{id:n,label:`${x} (${n})`,isActive:n===c}}function se({resolver:n,currentProjectId:x,env:c,onSelect:w,onCancel:C}){let[q,B]=(0,e.useState)([]),[D,l]=(0,e.useState)(!0),[H,m]=(0,e.useState)(!1),[J,g]=(0,e.useState)(!1),[Q,P]=(0,e.useState)(null),[d,p]=(0,e.useState)("list"),[v,R]=(0,e.useState)(""),[E,h]=(0,e.useState)(null),[I,X]=(0,e.useState)(""),b=(0,e.useRef)(!1),A=(0,e.useRef)(!0);(0,e.useEffect)(()=>{if(!n){P("Login first to browse projects"),l(!1);return}let o=new AbortController,a=I.trim();return A.current?l(!0):a&&g(!0),m(!0),P(null),(async()=>{try{let t=n.cached??await n.resolve();if(!t){P("Login first to browse projects"),l(!1),m(!1),g(!1);return}let L=k(c),F=new T(L.tmsBaseUrl,t.username,t.access_key),f=!0,N=0,G=a?{signal:o.signal,name:a,perPage:10}:{signal:o.signal,perPage:10};for await(let y of F.listProjectsStream(G)){if(f&&(l(!1),g(!1),A.current=!1,f=!1),y.totalLoaded===0&&y.done&&N===0&&!a){b.current=!0,p("naming"),m(!1);return}let M=y.projects.map(j=>V(j.project_id,j.name,x));B(N===0?M:j=>[...j,...M]),N+=y.projects.length,y.done&&m(!1)}f&&(l(!1),m(!1),g(!1))}catch(t){if(t?.name==="AbortError")return;P(t instanceof Error?t.message:String(t)),l(!1),m(!1),g(!1)}})(),()=>o.abort()},[n,x,c,I]);let Y=(0,e.useCallback)(o=>{let a=o.trim();if(!a){h("Name cannot be empty");return}h(null),p("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let t=n.cached??await n.resolve();if(!t)throw new Error("Not authenticated");let L=k(c),f=await new T(L.tmsBaseUrl,t.username,t.access_key).createProject(a);w(f.id,f.name)}catch(t){h(t instanceof Error?t.message:String(t)),p("naming")}})()},[n,c,w]),z=(0,e.useCallback)(()=>{R(""),h(null),b.current?C():p("list")},[C]);return d==="naming"||d==="creating"?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(s,{color:i.orange,bold:!0,children:"Create new project"}),b.current&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"No projects yet \u2014 let's create one."})}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(s,{color:i.dim,children:"Name: "}),d==="naming"?(0,r.jsx)($,{value:v,onChange:o=>{R(o),E&&h(null)},onSubmit:Y,onCancel:z}):(0,r.jsx)(s,{children:v})]}),E&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.red,children:E})}),d==="creating"&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"Creating..."})}),d==="naming"&&(0,r.jsx)(_,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,r.jsx)(U,{title:"Projects",items:q,loading:D,loadingMore:H,searching:J,preserveSelectionById:!0,onSearch:X,error:Q,itemNoun:"projects",onTab:()=>{b.current=!1,p("naming")},extraHint:"tab to create new",onSelect:o=>{let a=o.label.replace(` (${o.id})`,"");w(o.id,a)},onCancel:C})}export{V as a,se as b};
2
+ import{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-2J3VB6DW.js";import{a as T}from"./chunk-LPUQ4HWQ.js";import{a as k}from"./chunk-HPJP7NES.js";import{a as _}from"./chunk-GBTPZGJB.js";import{x as i}from"./chunk-3UCNDPTN.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as u,b as s}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as S}from"./chunk-UR6MHSHU.js";var e=S(K(),1);var r=S(O(),1);function V(n,x,c){return{id:n,label:`${x} (${n})`,isActive:n===c}}function se({resolver:n,currentProjectId:x,env:c,onSelect:w,onCancel:C}){let[q,B]=(0,e.useState)([]),[D,l]=(0,e.useState)(!0),[H,m]=(0,e.useState)(!1),[J,g]=(0,e.useState)(!1),[Q,P]=(0,e.useState)(null),[d,p]=(0,e.useState)("list"),[v,R]=(0,e.useState)(""),[E,h]=(0,e.useState)(null),[I,X]=(0,e.useState)(""),b=(0,e.useRef)(!1),A=(0,e.useRef)(!0);(0,e.useEffect)(()=>{if(!n){P("Login first to browse projects"),l(!1);return}let o=new AbortController,a=I.trim();return A.current?l(!0):a&&g(!0),m(!0),P(null),(async()=>{try{let t=n.cached??await n.resolve();if(!t){P("Login first to browse projects"),l(!1),m(!1),g(!1);return}let L=k(c),F=new T(L.tmsBaseUrl,t.username,t.access_key),f=!0,N=0,G=a?{signal:o.signal,name:a,perPage:10}:{signal:o.signal,perPage:10};for await(let y of F.listProjectsStream(G)){if(f&&(l(!1),g(!1),A.current=!1,f=!1),y.totalLoaded===0&&y.done&&N===0&&!a){b.current=!0,p("naming"),m(!1);return}let M=y.projects.map(j=>V(j.project_id,j.name,x));B(N===0?M:j=>[...j,...M]),N+=y.projects.length,y.done&&m(!1)}f&&(l(!1),m(!1),g(!1))}catch(t){if(t?.name==="AbortError")return;P(t instanceof Error?t.message:String(t)),l(!1),m(!1),g(!1)}})(),()=>o.abort()},[n,x,c,I]);let Y=(0,e.useCallback)(o=>{let a=o.trim();if(!a){h("Name cannot be empty");return}h(null),p("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let t=n.cached??await n.resolve();if(!t)throw new Error("Not authenticated");let L=k(c),f=await new T(L.tmsBaseUrl,t.username,t.access_key).createProject(a);w(f.id,f.name)}catch(t){h(t instanceof Error?t.message:String(t)),p("naming")}})()},[n,c,w]),z=(0,e.useCallback)(()=>{R(""),h(null),b.current?C():p("list")},[C]);return d==="naming"||d==="creating"?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(s,{color:i.orange,bold:!0,children:"Create new project"}),b.current&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"No projects yet \u2014 let's create one."})}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(s,{color:i.dim,children:"Name: "}),d==="naming"?(0,r.jsx)($,{value:v,onChange:o=>{R(o),E&&h(null)},onSubmit:Y,onCancel:z}):(0,r.jsx)(s,{children:v})]}),E&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.red,children:E})}),d==="creating"&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"Creating..."})}),d==="naming"&&(0,r.jsx)(_,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,r.jsx)(U,{title:"Projects",items:q,loading:D,loadingMore:H,searching:J,preserveSelectionById:!0,onSearch:X,error:Q,itemNoun:"projects",onTab:()=>{b.current=!1,p("naming")},extraHint:"tab to create new",onSelect:o=>{let a=o.label.replace(` (${o.id})`,"");w(o.id,a)},onCancel:C})}export{V as a,se as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h}from"./chunk-EAUU5F4P.js";import{x as l}from"./chunk-BGXAW2B5.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
2
+ import{a as h}from"./chunk-GBTPZGJB.js";import{x as l}from"./chunk-3UCNDPTN.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};