@testmuai/kane-cli 0.2.6 → 0.2.7
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.
- package/dist/{ChromeProfilePicker-GFXYO62T.js → ChromeProfilePicker-TSTGICKC.js} +1 -1
- package/dist/{CliFeedbackPrompt-F3ZTTEUY.js → CliFeedbackPrompt-D2GV3CIR.js} +1 -1
- package/dist/{CliUploadProgress-DNE54O2E.js → CliUploadProgress-3LN7ZAQQ.js} +1 -1
- package/dist/ConfigView-HFR7OLBN.js +2 -0
- package/dist/FolderPicker-JMDO2YEV.js +2 -0
- package/dist/{HelpView-WVCLJJMT.js → HelpView-GAECHNPW.js} +1 -1
- package/dist/{LinksBox-I4PYUQY7.js → LinksBox-VNX4GTYY.js} +1 -1
- package/dist/{LoginWizard-ZGXMGBNJ.js → LoginWizard-POE64KP6.js} +1 -1
- package/dist/{ProfilesView-AUJOUVYZ.js → ProfilesView-AJFBUG46.js} +1 -1
- package/dist/ProjectPicker-FTUZCSBL.js +2 -0
- package/dist/{WhoamiView-CY65SJE3.js → WhoamiView-FSFBRPAS.js} +1 -1
- package/dist/{changelog-CHSXQF3G.js → changelog-WJATJ25O.js} +1 -1
- package/dist/{chunk-OIERCP6B.js → chunk-22Q72KEE.js} +1 -1
- package/dist/chunk-32JVIWDK.js +2 -0
- package/dist/chunk-5TNGPFD4.js +2 -0
- package/dist/chunk-665WKKCX.js +2 -0
- package/dist/{chunk-EWT2AY54.js → chunk-DCUGTUXD.js} +1 -1
- package/dist/{chunk-Y4NPKZOF.js → chunk-FGRL7YK2.js} +1 -1
- package/dist/chunk-HFQ7T5KT.js +2 -0
- package/dist/{chunk-ATLXF7HN.js → chunk-HPYGNTYE.js} +1 -1
- package/dist/chunk-IEPLQSZE.js +106 -0
- package/dist/{chunk-PSB4TGW4.js → chunk-JWPOUEON.js} +9 -9
- package/dist/{chunk-6HRAVME7.js → chunk-KBTVURNO.js} +1 -1
- package/dist/{chunk-3C7VPJXD.js → chunk-LAVCECRF.js} +1 -1
- package/dist/chunk-N5O3NTGW.js +2 -0
- package/dist/{chunk-WSRUIIRY.js → chunk-ND4JFVHY.js} +1 -1
- package/dist/{chunk-5BRNKEYT.js → chunk-QDWB44VO.js} +1 -1
- package/dist/{chunk-O7HXQ753.js → chunk-QXBLFS66.js} +1 -1
- package/dist/chunk-RZYQ7T3Y.js +2 -0
- package/dist/index.js +51 -54
- package/dist/{logging-O5R56LPM.js → logging-X4C7SASV.js} +1 -1
- package/dist/login-flow-47Y4Y2UB.js +2 -0
- package/dist/{pipeline-NXUVAHY5.js → pipeline-W3MWTZHK.js} +1 -1
- package/dist/{tms-client-T4HO73MT.js → tms-client-VH42IFUF.js} +1 -1
- package/dist/{updater-WVTXO7SS.js → updater-L2ORCIIP.js} +1 -1
- package/dist/{version-check-SR6WBC6M.js → version-check-IF4G6QYT.js} +1 -1
- package/package.json +5 -4
- package/dist/ConfigView-MTU2VXM3.js +0 -2
- package/dist/FolderPicker-VVQBL3YD.js +0 -2
- package/dist/ProjectPicker-3WKERA5V.js +0 -2
- package/dist/chunk-36GHKMI7.js +0 -2
- package/dist/chunk-6SF4L62W.js +0 -2
- package/dist/chunk-CW5PVMPK.js +0 -2
- package/dist/chunk-KMHVGLJY.js +0 -2
- package/dist/chunk-THEP5K6T.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c}from"./chunk-
|
|
2
|
+
import{a,b,c}from"./chunk-QXBLFS66.js";import"./chunk-HCBYKLMW.js";import"./chunk-22Q72KEE.js";import"./chunk-Q7JVDEOV.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{c as ChromeProfilePicker,b as formatChromeProfileLine,a as listChromeProfiles};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as r}from"./chunk-
|
|
2
|
+
import{a as r}from"./chunk-LAVCECRF.js";import"./chunk-HCBYKLMW.js";import"./chunk-22Q72KEE.js";import{c as e}from"./chunk-Q7JVDEOV.js";import{a as i}from"./chunk-6YGTRKDT.js";import{e as m}from"./chunk-UR6MHSHU.js";var t=m(i(),1);async function d(){return new Promise(o=>{let c=e(t.default.createElement(r,{onSubmit:n=>{c.unmount(),o(n)}}),{stdout:process.stderr,exitOnCtrlC:!1})})}export{d as renderFeedbackPrompt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as P,d as g,e as f}from"./chunk-
|
|
2
|
+
import{c as P,d as g,e as f}from"./chunk-QDWB44VO.js";import{a as c}from"./chunk-HCBYKLMW.js";import"./chunk-22Q72KEE.js";import{c as d}from"./chunk-Q7JVDEOV.js";import{a as h}from"./chunk-6YGTRKDT.js";import{e as p}from"./chunk-UR6MHSHU.js";var e=p(h(),1);var m=p(c(),1);function w({pipeline:t,buildShareUrl:r,onDone:o}){let[n,i]=(0,e.useState)(P()),[S,l]=(0,e.useState)("uploading"),[U,R]=(0,e.useState)(),[C,E]=(0,e.useState)();return(0,e.useEffect)(()=>{let x=t.config.onProgress;t.config.onProgress=(s,u,a)=>{x(s,u,a),i(y=>g(y,s,u,a))},t.execute().then(s=>{s.success?(R(r?.(s)),l("success")):(E(s.error),l("failed")),setTimeout(()=>o(s),1500)})},[]),(0,m.jsx)(f,{steps:n,status:S,testUrl:U,error:C})}async function O(t,r){return new Promise(o=>{let n=d(e.default.createElement(w,{pipeline:t,buildShareUrl:r,onDone:i=>{n.unmount(),o(i)}}),{stdout:process.stderr,exitOnCtrlC:!1})})}export{O as renderUploadProgress};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as d,b as l,c as r}from"./chunk-DCUGTUXD.js";import{a as m}from"./chunk-HCBYKLMW.js";import{t as o}from"./chunk-22Q72KEE.js";import{a as t,j as u}from"./chunk-Q7JVDEOV.js";import{a as h}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var f=n(h(),1);var e=n(m(),1);function S({model:c,mode:s,authLabel:g,profile:b,env:p,defaultUrl:i,projectId:v,folderId:x,windowSize:w,chromeProfile:B}){let{exit:a}=u();return(0,f.useEffect)(()=>{let C=setTimeout(()=>a(),50);return()=>clearTimeout(C)},[a]),(0,e.jsx)(t,{flexDirection:"column",children:(0,e.jsx)(d,{title:"Configuration",children:(0,e.jsxs)(t,{flexDirection:"column",paddingY:1,children:[(0,e.jsx)(r,{label:"Auth"}),(0,e.jsx)(l,{label:" method",value:g}),(0,e.jsx)(l,{label:" profile",value:b}),(0,e.jsx)(l,{label:" env",value:p}),(0,e.jsx)(r,{label:"Defaults"}),(0,e.jsx)(l,{label:" url",value:i??"(none)",valueColor:i?o.cyan:o.dimmed}),(0,e.jsx)(l,{label:" model",value:c}),(0,e.jsx)(l,{label:" mode",value:s}),(0,e.jsx)(l,{label:" window",value:w}),(0,e.jsx)(l,{label:" project",value:v??"(none)"}),(0,e.jsx)(l,{label:" folder",value:x??"(none)"}),(0,e.jsx)(r,{label:"Paths"}),(0,e.jsx)(l,{label:" chrome",value:B,valueColor:o.dimmed})]})})})}export{S as ConfigView};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a,b}from"./chunk-5TNGPFD4.js";import"./chunk-RZYQ7T3Y.js";import"./chunk-N5O3NTGW.js";import"./chunk-HCBYKLMW.js";import"./chunk-22Q72KEE.js";import"./chunk-Q7JVDEOV.js";import"./chunk-6YGTRKDT.js";import"./chunk-HFQ7T5KT.js";import"./chunk-DXKKUGFG.js";import"./chunk-UR6MHSHU.js";export{b as FolderPicker,a as formatFolderLine};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as f}from"./chunk-HCBYKLMW.js";import{a as h,b as l,t}from"./chunk-
|
|
2
|
+
import{a as f}from"./chunk-HCBYKLMW.js";import{a as h,b as l,t}from"./chunk-22Q72KEE.js";import{a as n,b as o,j as x,k as p}from"./chunk-Q7JVDEOV.js";import{a as T}from"./chunk-6YGTRKDT.js";import{e as u}from"./chunk-UR6MHSHU.js";var b=u(T(),1);var e=u(f(),1),w="https://www.testmuai.com/support/docs/kane-cli-introduction",B="https://github.com/LambdaTest/kane-cli/issues";function L(){let{exit:c}=x(),{stdout:i}=p(),s=i?.columns??80;return(0,b.useEffect)(()=>{let d=setTimeout(()=>c(),50);return()=>clearTimeout(d)},[c]),(0,e.jsxs)(n,{flexDirection:"column",children:[(0,e.jsxs)(n,{paddingX:1,paddingTop:1,flexDirection:"column",children:[(0,e.jsx)(o,{color:t.purple,bold:!0,children:l}),(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dimmed,children:"Browser automation powered by AI "}),(0,e.jsxs)(o,{color:t.muted,children:[" v",h]})]})]}),(0,e.jsx)(o,{children:" "}),(0,e.jsx)(m,{title:"USAGE",children:(0,e.jsxs)(o,{color:t.cyan,children:[" $ ",l," ","<command>"," [flags]"]})}),(0,e.jsxs)(m,{title:"COMMANDS",children:[(0,e.jsx)(a,{cmd:"run",args:"<objective>",desc:"Run a browser automation task",highlight:!0}),(0,e.jsx)(a,{cmd:"login",desc:"Auth setup (interactive, --oauth, or --username)"}),(0,e.jsx)(a,{cmd:"logout",desc:"Revoke tokens + delete profile"}),(0,e.jsx)(a,{cmd:"whoami",desc:"Show authenticated identity"}),(0,e.jsx)(a,{cmd:"config",args:"show|set-\u2026|reset",desc:"Manage configuration"}),(0,e.jsx)(a,{cmd:"profiles",args:"list|switch|delete",desc:"Manage auth profiles"})]}),(0,e.jsxs)(m,{title:"RUN FLAGS",children:[(0,e.jsx)(r,{long:"--max-steps",arg:"<n>",desc:"Max agent steps (default: 30)"}),(0,e.jsx)(r,{long:"--timeout",arg:"<sec>",desc:"Kill run after N seconds"}),(0,e.jsx)(r,{long:"--headless",desc:"No visible browser window"}),(0,e.jsx)(r,{long:"--variables",arg:"<json>",desc:"Inline variables as JSON"}),(0,e.jsx)(r,{long:"--variables-file",arg:"<path>",desc:"Load variables from file"}),(0,e.jsx)(r,{long:"--ws-endpoint",arg:"<url>",desc:"Remote browser (LambdaTest)"}),(0,e.jsx)(r,{long:"--cdp-endpoint",arg:"<url>",desc:"Connect to existing Chrome CDP"}),(0,e.jsx)(r,{long:"--cft",desc:"Use Playwright Chromium instead of managed Chrome"}),(0,e.jsx)(r,{long:"--global-context",arg:"<file>",desc:"Override global context markdown"}),(0,e.jsx)(r,{long:"--local-context",arg:"<file>",desc:"Override local context markdown"}),(0,e.jsx)(r,{long:"--username",arg:"<user>",desc:"Basic auth (skip OAuth)"}),(0,e.jsx)(r,{long:"--access-key",arg:"<key>",desc:"Basic auth access key"}),(0,e.jsx)(r,{long:"--env",arg:"<name>",desc:"Environment (prod or stage)"}),(0,e.jsx)(r,{long:"--agent",desc:"NDJSON output (no UI)",highlight:!0})]}),(0,e.jsxs)(m,{title:"EXAMPLES",children:[(0,e.jsx)(g,{label:"Search",cmd:`${l} run "Search for laptop"`}),(0,e.jsx)(g,{label:"Headless",cmd:`${l} run "Verify login" --headless`}),(0,e.jsx)(g,{label:"Variables",cmd:`${l} run "Login as {{user}}" --variables '{"user":{"value":"alice"}}'`}),(0,e.jsx)(g,{label:"Agent",cmd:`${l} run "Add to cart" --agent | jq .status`})]}),(0,e.jsxs)(n,{flexDirection:"column",marginTop:0,paddingX:1,children:[(0,e.jsx)(o,{color:t.muted,children:"\u2500".repeat(Math.min(s-2,70))}),(0,e.jsxs)(n,{gap:3,children:[(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dimmed,children:"Docs "}),(0,e.jsx)(o,{color:t.cyan,underline:!0,children:w})]}),(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dimmed,children:"Bugs "}),(0,e.jsx)(o,{color:t.cyan,underline:!0,children:B})]})]})]}),(0,e.jsx)(o,{children:" "})]})}function m({title:c,children:i}){return(0,e.jsxs)(n,{flexDirection:"column",marginBottom:1,children:[(0,e.jsx)(n,{marginLeft:1,children:(0,e.jsx)(o,{bold:!0,color:t.dimmed,children:c})}),i]})}function a({cmd:c,args:i,desc:s,highlight:d}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsx)(n,{width:12,children:(0,e.jsx)(o,{color:d?t.purple:t.green,bold:!0,children:c})}),(0,e.jsx)(n,{width:28,children:i?(0,e.jsx)(o,{color:t.dimmed,children:i}):null}),(0,e.jsx)(o,{color:t.dimmed,children:s})]})}function r({long:c,arg:i,desc:s,highlight:d}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsxs)(n,{width:26,children:[(0,e.jsx)(o,{color:d?t.purple:t.cyan,children:c}),i&&(0,e.jsxs)(o,{color:t.dimmed,children:[" ",i]})]}),(0,e.jsx)(o,{color:t.dimmed,children:s})]})}function g({label:c,cmd:i}){return(0,e.jsxs)(n,{marginLeft:2,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dimmed,children:["# ",c]}),(0,e.jsxs)(o,{color:t.cyan,children:["$ ",i]})]})}export{L as HelpView};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-HPYGNTYE.js";import"./chunk-HCBYKLMW.js";import"./chunk-22Q72KEE.js";import"./chunk-Q7JVDEOV.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as LinksBox};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-KBTVURNO.js";import"./chunk-HCBYKLMW.js";import"./chunk-22Q72KEE.js";import"./chunk-Q7JVDEOV.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{b as LoginWizard,a as getWizardSteps};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-ND4JFVHY.js";import"./chunk-HCBYKLMW.js";import"./chunk-22Q72KEE.js";import"./chunk-Q7JVDEOV.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{b as ProfilesView,a as formatProfileLine};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a,b}from"./chunk-665WKKCX.js";import"./chunk-RZYQ7T3Y.js";import"./chunk-N5O3NTGW.js";import"./chunk-HCBYKLMW.js";import"./chunk-22Q72KEE.js";import"./chunk-Q7JVDEOV.js";import"./chunk-6YGTRKDT.js";import"./chunk-HFQ7T5KT.js";import"./chunk-DXKKUGFG.js";import"./chunk-UR6MHSHU.js";export{b as ProjectPicker,a as formatProjectLine};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as s,b as o}from"./chunk-
|
|
2
|
+
import{a as s,b as o}from"./chunk-DCUGTUXD.js";import{a as x}from"./chunk-HCBYKLMW.js";import{t as i}from"./chunk-22Q72KEE.js";import{a as r,b as n,j as u}from"./chunk-Q7JVDEOV.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as t}from"./chunk-UR6MHSHU.js";var p=t(B(),1);var e=t(x(),1);function R({profile:f,env:g,authenticated:a,authMethod:v,username:m,tokenStatus:l,expiresAt:c}){let{exit:d}=u();return(0,p.useEffect)(()=>{let b=setTimeout(()=>d(),50);return()=>clearTimeout(b)},[d]),(0,e.jsx)(r,{flexDirection:"column",children:(0,e.jsx)(s,{title:"Identity",variant:a?"success":"warning",children:(0,e.jsxs)(r,{flexDirection:"column",paddingY:1,children:[(0,e.jsx)(r,{children:a?(0,e.jsx)(n,{color:i.green,bold:!0,children:"\u2713 Authenticated"}):(0,e.jsx)(n,{color:i.yellow,bold:!0,children:"\u26A0 Not logged in"})}),(0,e.jsxs)(r,{flexDirection:"column",marginTop:1,children:[(0,e.jsx)(o,{label:"Profile",value:f}),(0,e.jsx)(o,{label:"Environment",value:g}),(0,e.jsx)(o,{label:"Method",value:v}),m&&(0,e.jsx)(o,{label:"User",value:m}),l&&(0,e.jsx)(o,{label:"Token",value:l,valueColor:l==="valid"?i.green:l==="expired"?i.red:i.dimmed}),c&&(0,e.jsx)(o,{label:"Expires",value:c})]})]})})})}export{R as WhoamiView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as i,f as c}from"./chunk-
|
|
2
|
+
import{c as i,f as c}from"./chunk-22Q72KEE.js";import"./chunk-UR6MHSHU.js";import{readFileSync as h,writeFileSync as g,mkdirSync as u}from"fs";import{join as d}from"path";var l=d(i,"changelog-cache.json"),f=3600*1e3;function p(){try{let e=JSON.parse(h(l,"utf-8"));if(Date.now()-e.cachedAt<f)return e}catch{}return null}function y(e){try{u(i,{recursive:!0}),g(l,JSON.stringify({entries:e,cachedAt:Date.now()}))}catch{}}async function E(e){try{let t=p();if(t){let r=t.entries;return e?.all?r:r.slice(0,5)}let n=new AbortController,o=setTimeout(()=>n.abort(),5e3),a=await fetch(`${c}?per_page=30`,{headers:{Accept:"application/vnd.github+json"},signal:n.signal});if(clearTimeout(o),!a.ok)return[];let s=(await a.json()).map(r=>({version:r.tag_name.replace(/^v/,""),date:r.published_at?r.published_at.slice(0,10):"",body:r.body??""}));return y(s),e?.all?s:s.slice(0,5)}catch{return[]}}function A(e){if(e.length===0)return"Could not fetch changelog. Visit https://github.com/LambdaTest/kane-cli/releases";let t=["kane-cli Changelog","\u2500".repeat(40),""];for(let n of e){if(t.push(`v${n.version} (${n.date})`),n.body){let o=n.body.split(`
|
|
3
3
|
`).filter(a=>a.trim());for(let a of o)t.push(` ${a}`)}t.push("")}return t.join(`
|
|
4
4
|
`)}export{E as fetchChangelog,A as formatChangelog};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{homedir as s}from"os";import{join as t}from"path";var c="0.2.
|
|
2
|
+
import{homedir as s}from"os";import{join as t}from"path";var c="0.2.7",l="kane-cli",e=t(s(),".testmuai","kaneai"),m=t(e,"profiles"),i=t(e,"tui-config.json"),d="https://registry.npmjs.org/@testmuai/kane-cli",h="https://api.github.com/repos/LambdaTest/kane-cli/releases",f="https://dd-proxy.lambdatest.com/intake/kane-cli",u="https://kaneai-playground.lambdatest.io",_=9222,b=9230,U=t(e,"chrome-profiles"),r="127.0.0.1",x=18392,g=18400,o="/callback";function A(a){return`http://${r}:${a}${o}`}var R="KANE CLI",L="*",C={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server"}},E={base:"#ffffff",primary:"#ff9500",secondary:"#888888",accent:"#ffffff",dim:"#666666",ambient:"#444444",statusPass:"#4ade80",statusFail:"#ef4444",purple:"#ff9500",cyan:"#ff9500",yellow:"#ff9500",green:"#4ade80",greenDim:"#666666",red:"#ef4444",redDim:"#666666",dimmed:"#666666",muted:"#444444"};export{c as a,l as b,e as c,i as d,d as e,h as f,f as g,u as h,_ as i,b as j,U as k,r as l,x as m,g as n,o,A as p,R as q,L as r,C as s,E as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as u,g as f}from"./chunk-22Q72KEE.js";var o=class{config;buffer=[];stepBuffer=new Map;flushTimer=null;currentRunIndex=null;stopped=!1;_droppedBatches=0;_droppedEntries=0;constructor(e){this.config=e}start(){if(this.flushTimer)return;let e=this.config.flushIntervalMs??5e3;this.flushTimer=setInterval(()=>{this.flush().catch(()=>{})},e),this.flushTimer.unref&&this.flushTimer.unref()}setRunIndex(e){this.currentRunIndex=e}log(e,t,i,n={}){if(this.stopped)return;let r=this.buildEntry(e,t,i,n);this.buffer.push(r)}logStep(e,t,i,n={}){if(this.stopped)return;let r=this.buildEntry("debug",t,i,n);r.run_index=e,this.stepBuffer.has(e)||this.stepBuffer.set(e,[]),this.stepBuffer.get(e).push(r)}escalate(e){let t=this.stepBuffer.get(e);t&&t.length>0&&this.buffer.push(...t),this.stepBuffer.delete(e)}discardSteps(e){this.stepBuffer.delete(e)}async flush(){if(this.buffer.length===0)return;let e=this.buffer.splice(0),t=null;try{t=await this.config.getToken()}catch{this.buffer.unshift(...e);return}let i={"Content-Type":"application/json"};t&&(i.Authorization=`Bearer ${t}`);let n=JSON.stringify(e);for(let r=0;r<3;r++){try{let h=new AbortController,p=setTimeout(()=>h.abort(),1e4),d=await fetch(this.config.proxyUrl,{method:"POST",headers:i,body:n,signal:h.signal});if(clearTimeout(p),d.ok)return}catch{}r<2&&await new Promise(h=>setTimeout(h,1e3*Math.pow(2,r)))}this._droppedBatches++,this._droppedEntries+=e.length}get droppedBatches(){return this._droppedBatches}get droppedEntries(){return this._droppedEntries}async shutdown(){this._droppedBatches>0&&this.log("warn","LOG_DROPS",`Dropped ${this._droppedEntries} entries in ${this._droppedBatches} batches`,{dropped_batches:this._droppedBatches,dropped_entries:this._droppedEntries}),this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),await this.flush()}shutdownSync(){this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}get bufferSize(){return this.buffer.length}stepBufferSize(e){return this.stepBuffer.get(e)?.length??0}buildEntry(e,t,i,n){return{hostname:"kane-cli",service:"kane-cli",ddsource:"kane-cli",ddtags:`env:${this.config.environment},version:${this.config.device.cli_version}`,level:e,event:t,message:i,session_id:this.config.sessionId,run_index:this.currentRunIndex,identity:this.config.identity,device:this.config.device,context:n,timestamp:new Date().toISOString()}}};import{platform as l,arch as g}from"os";function y(s){let e={proxyUrl:f,sessionId:s.sessionId,identity:s.identity,device:{cli_version:u,platform:l(),arch:g()},environment:s.environment,getToken:s.getToken};return new o(e)}export{o as a,y as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as I}from"./chunk-RZYQ7T3Y.js";import{a as v}from"./chunk-N5O3NTGW.js";import{a as S}from"./chunk-HCBYKLMW.js";import{t as a}from"./chunk-22Q72KEE.js";import{a as l,b as i,i as F}from"./chunk-Q7JVDEOV.js";import{a as O}from"./chunk-6YGTRKDT.js";import{a as y}from"./chunk-HFQ7T5KT.js";import{e as N}from"./chunk-UR6MHSHU.js";var o=N(O(),1);var e=N(S(),1);function U(r,m,x,u){return{id:r,label:`${m} (${r}) \xB7 ${x} tests`,isActive:r===u}}function q({resolver:r,projectId:m,currentFolderId:x,env:u,onSelect:B,onCancel:C}){let[_,A]=(0,o.useState)([]),[$,b]=(0,o.useState)(!0),[k,w]=(0,o.useState)(null),[f,d]=(0,o.useState)("list"),[L,E]=(0,o.useState)(""),[P,g]=(0,o.useState)(null),p=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{if(!r){w("Login first to browse folders"),b(!1);return}(async()=>{try{let t=r.cached??await r.resolve();if(!t){w("Login first to browse folders"),b(!1);return}let n=v(u),h=(await new y(n.tmsBaseUrl,t.username,t.access_key).listFolders(m)).map(T=>U(T.id,T.name,T.test_cases_count,x));A(h),h.length===0&&(p.current=!0,d("naming"))}catch(t){w(t instanceof Error?t.message:String(t))}finally{b(!1)}})()},[r,m,x,u]),F((t,n)=>{if(f==="naming"){if(n.escape){E(""),g(null),p.current?C():d("list");return}if(n.return){let c=L.trim();if(!c){g("Name cannot be empty");return}if(!m){g("No project selected \u2014 pick a project first");return}g(null),d("creating"),(async()=>{try{if(!r)throw new Error("Not authenticated");let s=r.cached??await r.resolve();if(!s)throw new Error("Not authenticated");let h=v(u),R=await new y(h.tmsBaseUrl,s.username,s.access_key).createFolder(m,c);B(R.id,R.name)}catch(s){g(s instanceof Error?s.message:String(s)),d("naming")}})();return}if(n.backspace||n.delete){E(c=>c.slice(0,-1));return}n.tab||n.ctrl||n.meta||t&&E(c=>c+t)}}),f==="naming"||f==="creating"?(0,e.jsxs)(l,{flexDirection:"column",borderStyle:"round",borderColor:a.primary,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:a.primary,bold:!0,children:"Create new folder"}),p.current&&(0,e.jsx)(l,{marginTop:1,children:(0,e.jsx)(i,{color:a.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(l,{marginTop:1,children:[(0,e.jsx)(i,{color:a.dim,children:"Name: "}),(0,e.jsx)(i,{children:L}),f==="naming"&&(0,e.jsx)(i,{inverse:!0,children:" "})]}),P&&(0,e.jsx)(l,{marginTop:1,children:(0,e.jsx)(i,{color:a.red,children:P})}),f==="creating"&&(0,e.jsx)(l,{marginTop:1,children:(0,e.jsx)(i,{color:a.dim,children:"Creating..."})}),f==="naming"&&(0,e.jsx)(l,{marginTop:1,children:(0,e.jsxs)(i,{color:a.dim,children:["\u21B5 create \xB7 esc ",p.current?"cancel":"back"]})})]}):(0,e.jsx)(I,{title:"Folders",items:_,loading:$,error:k,itemNoun:"folders",onTab:()=>{p.current=!1,d("naming")},extraHint:"tab to create new",onSelect:t=>{let n=t.label.split(" (")[0];B(t.id,n)},onCancel:C})}export{U as a,q as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as S}from"./chunk-RZYQ7T3Y.js";import{a as E}from"./chunk-N5O3NTGW.js";import{a as R}from"./chunk-HCBYKLMW.js";import{t as s}from"./chunk-22Q72KEE.js";import{a as m,b as i,i as L}from"./chunk-Q7JVDEOV.js";import{a as O}from"./chunk-6YGTRKDT.js";import{a as w}from"./chunk-HFQ7T5KT.js";import{e as b}from"./chunk-UR6MHSHU.js";var o=b(O(),1);var e=b(R(),1);function U(r,p,u){return{id:r,label:`${p} (${r})`,isActive:r===u}}function q({resolver:r,currentProjectId:p,env:u,onSelect:N,onCancel:y}){let[I,A]=(0,o.useState)([]),[_,h]=(0,o.useState)(!0),[$,j]=(0,o.useState)(null),[l,f]=(0,o.useState)("list"),[v,T]=(0,o.useState)(""),[B,d]=(0,o.useState)(null),g=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{if(!r){j("Login first to browse projects"),h(!1);return}(async()=>{try{let t=r.cached??await r.resolve();if(!t){j("Login first to browse projects"),h(!1);return}let n=E(u),x=(await new w(n.tmsBaseUrl,t.username,t.access_key).listProjects()).map(P=>U(P.project_id,P.name,p));A(x),x.length===0&&(g.current=!0,f("naming"))}catch(t){j(t instanceof Error?t.message:String(t))}finally{h(!1)}})()},[r,p,u]),L((t,n)=>{if(l==="naming"){if(n.escape){T(""),d(null),g.current?y():f("list");return}if(n.return){let c=v.trim();if(!c){d("Name cannot be empty");return}d(null),f("creating"),(async()=>{try{if(!r)throw new Error("Not authenticated");let a=r.cached??await r.resolve();if(!a)throw new Error("Not authenticated");let x=E(u),C=await new w(x.tmsBaseUrl,a.username,a.access_key).createProject(c);N(C.id,C.name)}catch(a){d(a instanceof Error?a.message:String(a)),f("naming")}})();return}if(n.backspace||n.delete){T(c=>c.slice(0,-1));return}n.tab||n.ctrl||n.meta||t&&T(c=>c+t)}}),l==="naming"||l==="creating"?(0,e.jsxs)(m,{flexDirection:"column",borderStyle:"round",borderColor:s.primary,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:s.primary,bold:!0,children:"Create new project"}),g.current&&(0,e.jsx)(m,{marginTop:1,children:(0,e.jsx)(i,{color:s.dim,children:"No projects yet \u2014 let's create one."})}),(0,e.jsxs)(m,{marginTop:1,children:[(0,e.jsx)(i,{color:s.dim,children:"Name: "}),(0,e.jsx)(i,{children:v}),l==="naming"&&(0,e.jsx)(i,{inverse:!0,children:" "})]}),B&&(0,e.jsx)(m,{marginTop:1,children:(0,e.jsx)(i,{color:s.red,children:B})}),l==="creating"&&(0,e.jsx)(m,{marginTop:1,children:(0,e.jsx)(i,{color:s.dim,children:"Creating..."})}),l==="naming"&&(0,e.jsx)(m,{marginTop:1,children:(0,e.jsxs)(i,{color:s.dim,children:["\u21B5 create \xB7 esc ",g.current?"cancel":"back"]})})]}):(0,e.jsx)(S,{title:"Projects",items:I,loading:_,error:$,itemNoun:"projects",onTab:()=>{g.current=!1,f("naming")},extraHint:"tab to create new",onSelect:t=>{let n=t.label.replace(` (${t.id})`,"");N(t.id,n)},onCancel:y})}export{U as a,q as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as m}from"./chunk-HCBYKLMW.js";import{t as o}from"./chunk-
|
|
2
|
+
import{a as m}from"./chunk-HCBYKLMW.js";import{t as o}from"./chunk-22Q72KEE.js";import{a as r,b as i}from"./chunk-Q7JVDEOV.js";import{e as a}from"./chunk-UR6MHSHU.js";var e=a(m(),1),u={default:o.muted,error:o.red,success:o.green,info:o.purple,warning:o.yellow};function T({title:t,titleColor:l,borderColor:d,variant:n="default",children:c,width:s,paddingX:x=2,paddingY:g=0,marginBottom:p=0}){let f=d??u[n],B=l??(n==="default"?o.purple:u[n]);return(0,e.jsxs)(r,{flexDirection:"column",marginBottom:p,children:[t&&(0,e.jsx)(r,{marginBottom:0,children:(0,e.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,e.jsx)(r,{borderStyle:"round",borderColor:f,flexDirection:"column",paddingX:x,paddingY:g,width:s,children:c})]})}function h({label:t,value:l,labelColor:d=o.dimmed,valueColor:n,labelWidth:c=14}){return(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:c,children:(0,e.jsx)(i,{color:d,children:t})}),(0,e.jsx)(i,{color:n,children:l})]})}function C({label:t}){return(0,e.jsx)(r,{marginTop:1,marginBottom:0,children:(0,e.jsx)(i,{bold:!0,children:t})})}export{T as a,h as b,C as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as n,c as s,e as c}from"./chunk-
|
|
2
|
+
import{a as n,c as s,e as c}from"./chunk-22Q72KEE.js";import{readFileSync as p,writeFileSync as f,mkdirSync as h}from"fs";import{join as d}from"path";var m=d(s,"version-check.json"),g=1440*60*1e3;function y(){try{let t=JSON.parse(p(m,"utf-8"));if(Date.now()-t.checkedAt<g)return t}catch{}return null}function C(t){try{h(s,{recursive:!0}),f(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,i){let a=t.split(".").map(Number),e=i.split(".").map(Number);for(let o=0;o<3;o++){let r=(e[o]??0)-(a[o]??0);if(r!==0)return r}return 0}function l(t,i){let a=t.split(".").map(Number),e=i.split(".").map(Number);return(e[0]??0)!==(a[0]??0)?"major":(e[1]??0)!==(a[1]??0)?"minor":"patch"}async function N(){try{let t=y();if(t)return u(n,t.latest)>0?{current:n,latest:t.latest,severity:l(n,t.latest)}:null;let i=new AbortController,a=setTimeout(()=>i.abort(),5e3),e=await fetch(c,{headers:{Accept:"application/json"},signal:i.signal});if(clearTimeout(a),!e.ok)return null;let r=(await e.json())["dist-tags"]?.latest;return r?(C(r),u(n,r)>0?{current:n,latest:r,severity:l(n,r)}:null):null}catch{return null}}export{u as a,l as b,N as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as h}from"./chunk-DXKKUGFG.js";var m=class extends h{constructor(e,t,s){super(e,{username:t,accessKey:s})}async listProjects(e){let i=[],r=!1;for(let a=1;a<=100;a++){let n=`${this.baseUrl}/v1/projects?page=${a}&per_page=200&sort=created_at`,o=await fetch(n,{method:"GET",headers:this.headers()});if(!o.ok)throw new Error(`List projects failed: ${o.status} ${await o.text()}`);let d=(await o.json()).data??[];if(e&&!r&&d.length>0){let c=d[0];e("info","PROJECT_SAMPLE","Project list sample",{project_id:c.project_id,name:c.name}),r=!0}if(i.push(...d),d.length<200)break}return i}async getDefaultFolder(e){let t=await fetch(`${this.baseUrl}/v1/projects/${e}/folder/default`,{method:"GET",headers:this.headers()});if(!t.ok)throw new Error(`Get default folder failed: ${t.status} ${await t.text()}`);return(await t.json()).id}async listFolders(e){let t=await fetch(`${this.baseUrl}/v1/folder/entity/${e}`,{method:"GET",headers:this.headers()});if(!t.ok)throw new Error(`List folders failed: ${t.status} ${await t.text()}`);return(await t.json()).data??[]}async createProject(e){let t=await fetch(`${this.baseUrl}/v1/projects`,{method:"POST",headers:{...this.headers(),"Content-Type":"application/json"},body:JSON.stringify({name:e,description:"",tags:[],source:"KTM"})});if(!t.ok)throw new Error(`Create project failed: ${t.status} ${await t.text()}`);return{id:(await t.json()).id,name:e}}async createFolder(e,t){let s=await fetch(`${this.baseUrl}/v1/folder`,{method:"POST",headers:{...this.headers(),"Content-Type":"application/json"},body:JSON.stringify({folders:[{name:t,description:"",entity_id:e,entity_type:"project"}]})});if(!s.ok)throw new Error(`Create folder failed: ${s.status} ${await s.text()}`);return{id:(await s.json()).id,name:t}}async createAtmTest(e,t){let s=t?`Bearer ${t}`:this.authHeader,i=await fetch(`${this.baseUrl}/kane-cli/v1/test`,{method:"POST",headers:{Authorization:s,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!i.ok)throw new Error(`Create ATM test failed: ${i.status} ${await i.text()}`);let r=await i.json();if(!r.test_id)throw new Error("Create ATM test returned no test_id");return r.test_id}async endTest(e,t,s){let i=s?`Bearer ${s}`:this.authHeader,r=new URLSearchParams({commit_id:t.commit_id,time_taken:String(t.time_taken),steps_count:String(t.steps_count),commit_message:t.commit_message}),a={};t.objectives&&t.objectives.length>0&&(a.objectives=t.objectives);let n=await fetch(`${this.baseUrl}/kane-cli/v1/test/${e}?${r.toString()}`,{method:"DELETE",headers:{Authorization:i,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(a)});if(!n.ok)throw new Error(`End test failed: ${n.status} ${await n.text()}`);let o=await n.json();return{testcase_id:o.data?.testcase_id??"",test_id:o.data?.test_id??e,project_id:o.data?.project_id??""}}async submitFeedback(e,t){let s=t?`Bearer ${t}`:this.authHeader,i={instruction_id:e.instruction_id,test_id:e.test_id,feedback_type:e.feedback_type,mode:e.mode??"human"};e.details&&(i.details=e.details);let r=await fetch(`${this.baseUrl}/atm/v1/generative-feedback`,{method:"POST",headers:{Authorization:s,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(i)});if(!r.ok)throw new Error(`Submit feedback failed: ${r.status} ${await r.text()}`);return await r.json()}};export{m as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as c}from"./chunk-HCBYKLMW.js";import{t as a}from"./chunk-
|
|
2
|
+
import{a as c}from"./chunk-HCBYKLMW.js";import{t as a}from"./chunk-22Q72KEE.js";import{a as s,b as u,j as p}from"./chunk-Q7JVDEOV.js";import{a as T}from"./chunk-6YGTRKDT.js";import{e as l}from"./chunk-UR6MHSHU.js";var x=l(T(),1);function g(n,e){if(!e)return n;let i=n.trim()||e;return`\x1B]8;;${e}\x07${i}\x1B]8;;\x07`}var r=l(c(),1);function h({shareableLink:n,testCaseLink:e,codeExportDir:i,autoExit:m=!0}){let{exit:f}=p();(0,x.useEffect)(()=>{if(!m)return;let t=setTimeout(()=>f(),100);return()=>clearTimeout(t)},[f,m]);let o=[];return n&&o.push({label:"ShareLink",url:n}),e&&o.push({label:"TestCase",url:e}),i&&o.push({label:"CodeExport",url:i,linkUrl:`file://${i}`}),o.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:o.map(t=>(0,r.jsxs)(s,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(u,{color:a.primary,children:[t.label,":"]}),(0,r.jsx)(u,{color:a.dim,children:g(t.url,t.linkUrl??t.url)})]},t.label))})}export{h as a};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as V}from"./chunk-N5O3NTGW.js";import{c as K,l as _,m as B,n as E,o as Y,p as G,q as X,r as q}from"./chunk-22Q72KEE.js";import{createServer as qe}from"http";import{randomBytes as Ve}from"crypto";import{URL as Qe}from"url";import ce from"process";import{Buffer as le}from"buffer";import de from"path";import{fileURLToPath as Ue}from"url";import{promisify as He}from"util";import fe from"child_process";import je,{constants as ze}from"fs/promises";import re from"process";import te,{constants as Se}from"fs/promises";import ee from"process";import be from"os";import L from"fs";import ve from"fs";import Q from"fs";var T;function we(){try{return Q.statSync("/.dockerenv"),!0}catch{return!1}}function ye(){try{return Q.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function F(){return T===void 0&&(T=we()||ye()),T}var O,xe=()=>{try{return ve.statSync("/run/.containerenv"),!0}catch{return!1}};function h(){return O===void 0&&(O=xe()||F()),O}var Z=()=>{if(ee.platform!=="linux")return!1;if(be.release().toLowerCase().includes("microsoft"))return!h();try{if(L.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!h()}catch{}return L.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||L.existsSync("/run/WSL")?!h():!1},m=ee.env.__IS_WSL_TEST__?Z:Z();var Pe=(()=>{let o="/mnt/",e;return async function(){if(e)return e;let r="/etc/wsl.conf",t=!1;try{await te.access(r,Se.F_OK),t=!0}catch{}if(!t)return o;let i=await te.readFile(r,{encoding:"utf8"}),n=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return n?(e=n.groups.mountPoint.trim(),e=e.endsWith("/")?e:`${e}/`,e):o}})(),Ce=async()=>`${await Pe()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,I=async()=>m?Ce():`${re.env.SYSTEMROOT||re.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;function p(o,e,r){let t=i=>Object.defineProperty(o,e,{value:i,enumerable:!0,writable:!0});return Object.defineProperty(o,e,{configurable:!0,enumerable:!0,get(){let i=r();return t(i),i},set(i){t(i)}}),o}import{promisify as $e}from"util";import N from"process";import{execFile as Re}from"child_process";import{promisify as Ae}from"util";import ke from"process";import{execFile as _e}from"child_process";var Be=Ae(_e);async function M(){if(ke.platform!=="darwin")throw new Error("macOS only");let{stdout:o}=await Be("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),r=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(o)?.groups.id??"com.apple.Safari";return r==="com.apple.safari"?"com.apple.Safari":r}import Ee from"process";import{promisify as Te}from"util";import{execFile as Fe,execFileSync as Pr}from"child_process";var Oe=Te(Fe);async function oe(o,{humanReadableOutput:e=!0,signal:r}={}){if(Ee.platform!=="darwin")throw new Error("macOS only");let t=e?[]:["-ss"],i={};r&&(i.signal=r);let{stdout:n}=await Oe("osascript",["-e",o,t],i);return n.trim()}async function $(o){return oe(`tell application "Finder" to set app_path to application file id "${o}" as string
|
|
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 Le}from"util";import{execFile as Ie}from"child_process";var Me=Le(Ie),P={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"}},Er=new Map(Object.entries(P)),R=class extends Error{};async function D(o=Me){let{stdout:e}=await o("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),r=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(e);if(!r)throw new R(`Cannot find Windows browser in stdout: ${JSON.stringify(e)}`);let{id:t}=r.groups,i=t.lastIndexOf("."),n=t.lastIndexOf("-"),a=i===-1?void 0:t.slice(0,i),s=n===-1?void 0:t.slice(0,n);return P[t]??P[a]??P[s]??{name:t,id:t}}var De=$e(Re),Ne=o=>o.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase());async function U(){if(N.platform==="darwin"){let o=await M();return{name:await $(o),id:o}}if(N.platform==="linux"){let{stdout:o}=await De("xdg-mime",["query","default","x-scheme-handler/http"]),e=o.trim();return{name:Ne(e.replace(/.desktop$/,"").replace("-"," ")),id:e}}if(N.platform==="win32")return D();throw new Error("Only macOS, Linux, and Windows are supported")}var We=He(fe.execFile),H=de.dirname(Ue(import.meta.url)),ie=de.join(H,"xdg-open"),{platform:v,arch:ne}=ce;async function Je(){let o=await I(),e=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,r=le.from(e,"utf16le").toString("base64"),{stdout:t}=await We(o,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",r],{encoding:"utf8"}),i=t.trim(),n={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return n[i]?{id:n[i]}:{}}var se=async(o,e)=>{let r;for(let t of o)try{return await e(t)}catch(i){r=i}throw r},C=async o=>{if(o={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...o},Array.isArray(o.app))return se(o.app,s=>C({...o,app:s}));let{name:e,arguments:r=[]}=o.app??{};if(r=[...r],Array.isArray(e))return se(e,s=>C({...o,app:{name:s,arguments:r}}));if(e==="browser"||e==="browserPrivate"){let s={"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"},c={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},l=m?await Je():await U();if(l.id in s){let f=s[l.id];return e==="browserPrivate"&&r.push(c[f]),C({...o,app:{name:w[f],arguments:r}})}throw new Error(`${l.name} is not supported as a default browser`)}let t,i=[],n={};if(v==="darwin")t="open",o.wait&&i.push("--wait-apps"),o.background&&i.push("--background"),o.newInstance&&i.push("--new"),e&&i.push("-a",e);else if(v==="win32"||m&&!h()&&!e){t=await I(),i.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),m||(n.windowsVerbatimArguments=!0);let s=["Start"];o.wait&&s.push("-Wait"),e?(s.push(`"\`"${e}\`""`),o.target&&r.push(o.target)):o.target&&s.push(`"${o.target}"`),r.length>0&&(r=r.map(c=>`"\`"${c}\`""`),s.push("-ArgumentList",r.join(","))),o.target=le.from(s.join(" "),"utf16le").toString("base64")}else{if(e)t=e;else{let s=!H||H==="/",c=!1;try{await je.access(ie,ze.X_OK),c=!0}catch{}t=ce.versions.electron??(v==="android"||s||!c)?"xdg-open":ie}r.length>0&&i.push(...r),o.wait||(n.stdio="ignore",n.detached=!0)}v==="darwin"&&r.length>0&&i.push("--args",...r),o.target&&i.push(o.target);let a=fe.spawn(t,i,n);return o.wait?new Promise((s,c)=>{a.once("error",c),a.once("close",l=>{if(!o.allowNonzeroExitCode&&l>0){c(new Error(`Exited with code ${l}`));return}s(a)})}):(a.unref(),a)},Ke=(o,e)=>{if(typeof o!="string")throw new TypeError("Expected a `target`");return C({...e,target:o})};function ae(o){if(typeof o=="string"||Array.isArray(o))return o;let{[ne]:e}=o;if(!e)throw new Error(`${ne} is not supported`);return e}function A({[v]:o},{wsl:e}){if(e&&m)return ae(e);if(!o)throw new Error(`${v} is not supported`);return ae(o)}var w={};p(w,"chrome",()=>A({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"]}}));p(w,"brave",()=>A({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"]}}));p(w,"firefox",()=>A({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));p(w,"edge",()=>A({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));p(w,"browser",()=>"browser");p(w,"browserPrivate",()=>"browserPrivate");var ue=Ke;import{createHash as Ye,randomBytes as Ge}from"crypto";var x=class{authBaseUrl;consentUrl;constructor(e="prod"){let r=V(e);this.authBaseUrl=r.authBaseUrl,this.consentUrl=r.consentUrl}static generatePkce(){let e=Ge(96).toString("base64url").slice(0,128),r=Ye("sha256").update(e).digest("base64url");return[e,r]}buildAuthorizationUrl(e,r,t,i){let n=new URLSearchParams({response_type:"code",client_id:e,redirect_uri:i,scope:q,code_challenge:r,code_challenge_method:"S256",state:t});return`${this.consentUrl}/oauth2?${n.toString()}`}async registerClient(e){let r=await fetch(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:X,redirect_uris:[e],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!r.ok)throw new Error(`DCR failed: ${r.status} ${await r.text()}`);return r.json()}async exchangeCode(e,r,t,i){let n=await fetch(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:e,redirect_uri:i,client_id:r,code_verifier:t})});if(!n.ok)throw new Error(`Token exchange failed: ${n.status}`);return n.json()}async refreshToken(e,r){let t=await fetch(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:e,client_id:r})});if(!t.ok)throw new Error(`Token refresh failed: ${t.status}`);return t.json()}async revokeToken(e,r,t="access_token"){await fetch(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e,token_type_hint:t,client_id:r})})}async validateToken(e){let r=new AbortController,t=setTimeout(()=>r.abort(),1e4);try{let i=await fetch(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${e}`,Accept:"application/json","Content-Type":"application/json"},signal:r.signal});return clearTimeout(t),i.ok}catch{return clearTimeout(t),!1}}};import{readFileSync as b,writeFileSync as me,mkdirSync as pe,readdirSync as j,unlinkSync as u,existsSync as z,chmodSync as ge}from"fs";import{join as d,dirname as Xe}from"path";var k=class{baseDir;profilesDir;configFile;constructor(e=K){this.baseDir=e,this.profilesDir=d(e,"profiles"),this.configFile=d(e,"config.json")}readConfig(){try{return JSON.parse(b(this.configFile,"utf-8"))}catch{return{}}}writeConfig(e){pe(this.baseDir,{recursive:!0,mode:448}),me(this.configFile,JSON.stringify(e,null,2)+`
|
|
4
|
+
`),ge(this.configFile,384)}getActiveProfile(){return this.readConfig().active_profile??null}setActiveProfile(e){let r=this.readConfig();r.active_profile=e,this.writeConfig(r)}getDefaultEnv(){return this.readConfig().default_env??"prod"}setDefaultEnv(e){let r=this.readConfig();r.default_env=e,this.writeConfig(r)}credentialsPath(e,r){return d(this.profilesDir,e,r,"credentials")}clientPath(e,r){return d(this.profilesDir,e,r,"client.json")}basicAuthPath(e,r){return d(this.profilesDir,e,r,"basic-auth")}profileConfigPath(e,r){return d(this.profilesDir,e,r,"profile-config.json")}saveProfileConfig(e,r,t){let i=this.loadProfileConfig(e,r)??{};this.writeSecure(this.profileConfigPath(e,r),{...i,...t})}loadProfileConfig(e,r){try{return JSON.parse(b(this.profileConfigPath(e,r),"utf-8"))}catch{return null}}writeSecure(e,r){try{pe(Xe(e),{recursive:!0,mode:448}),me(e,JSON.stringify(r,null,2)+`
|
|
5
|
+
`),ge(e,384)}catch(t){let i=t instanceof Error?t.message:String(t);process.stderr.write(`[auth] Failed to save credentials: ${i}
|
|
6
|
+
`)}}saveCredentials(e,r,t){this.writeSecure(this.credentialsPath(e,r),t)}loadCredentials(e,r){try{return JSON.parse(b(this.credentialsPath(e,r),"utf-8"))}catch{return null}}saveClient(e,r,t){this.writeSecure(this.clientPath(e,r),t)}loadClient(e,r){try{return JSON.parse(b(this.clientPath(e,r),"utf-8"))}catch{return null}}getActiveCredentials(){let e=this.getActiveProfile();if(!e)return{credentials:null,profile:null,env:null};let r=this.getDefaultEnv();return{credentials:this.loadCredentials(e,r),profile:e,env:r}}saveBasicAuth(e,r,t){this.writeSecure(this.basicAuthPath(e,r),t)}loadBasicAuth(e,r){try{return JSON.parse(b(this.basicAuthPath(e,r),"utf-8"))}catch{return null}}deleteBasicAuth(e,r){try{u(this.basicAuthPath(e,r))}catch{}}resolveAuth(){let e=this.getActiveProfile();if(!e)return null;let r=this.getDefaultEnv(),t=this.loadBasicAuth(e,r);return t?{method:"basic",...t,profile:e,env:r}:this.loadCredentials(e,r)?{method:"oauth",profile:e,env:r}:null}listProfiles(){let e=[];try{for(let r of j(this.profilesDir)){let t=d(this.profilesDir,r);try{for(let i of j(t)){let n=d(t,i),a=z(d(n,"credentials")),s=z(d(n,"client.json")),c=z(d(n,"basic-auth"));(a||s||c)&&e.push({profile:r,env:i})}}catch{}}}catch{}return e}deleteProfile(e,r){try{u(this.credentialsPath(e,r))}catch{}if(this.getActiveProfile()===e){let t=this.readConfig();delete t.active_profile,this.writeConfig(t)}}deleteProfileFull(e,r){if(r){try{u(this.credentialsPath(e,r))}catch{}try{u(this.clientPath(e,r))}catch{}try{u(this.basicAuthPath(e,r))}catch{}try{u(this.profileConfigPath(e,r))}catch{}}else try{let t=d(this.profilesDir,e);for(let i of j(t)){try{u(d(t,i,"credentials"))}catch{}try{u(d(t,i,"client.json"))}catch{}try{u(d(t,i,"basic-auth"))}catch{}try{u(d(t,i,"profile-config.json"))}catch{}}}catch{}}};var he=class{profile;environment;creds;oauth;constructor(e="default",r="prod",t){this.profile=e,this.environment=r,this.creds=t??new k,this.oauth=new x(r)}async login(){let{server:e,port:r}=await this.startCallbackServer(),t=G(r);try{let i=this.creds.loadClient(this.profile,this.environment),n=i?.redirect_uris;(!i||!n?.includes(t))&&(i=await this.oauth.registerClient(t),this.creds.saveClient(this.profile,this.environment,i));let a=i.client_id,[s,c]=x.generatePkce(),l=Ve(32).toString("hex"),f=this.oauth.buildAuthorizationUrl(a,c,l,t),g=await this.waitForCallback(e,r,f,l);if(!g)throw new Error("Login cancelled or timed out");let y=await this.oauth.exchangeCode(g,a,s,t),S={access_token:y.access_token,refresh_token:y.refresh_token,expires_at:Math.floor(Date.now()/1e3)+y.expires_in,scope:y.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,S),this.creds.setActiveProfile(this.profile),S}catch(i){throw e.close(),i}}startCallbackServer(){return new Promise((e,r)=>{let t=B,i=()=>{let n=qe();n.on("error",a=>{a.code==="EADDRINUSE"&&t<E?(t++,i()):r(new Error(`Failed to start callback server: ${a.message}. Ports ${B}-${E} are all in use.`))}),n.listen(t,_,()=>{e({server:n,port:t})})};i()})}waitForCallback(e,r,t,i){return new Promise(n=>{let a=!1,s=setTimeout(()=>c(null),12e4),c=l=>{a||(a=!0,clearTimeout(s),e.close(),n(l))};e.on("request",(l,f)=>{let g=new Qe(l.url??"/",`http://${_}:${r}`);if(g.pathname!==Y){f.writeHead(404),f.end();return}let y=g.searchParams.get("state"),S=g.searchParams.get("code");if(g.searchParams.get("error")){f.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),f.end(W({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),c(null);return}if(y!==i){f.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),f.end(W({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),c(null);return}f.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),f.end(W({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),c(S)}),ue(t).catch(l=>{let f=l instanceof Error?l.message:String(l);process.stderr.write(`[auth] Could not open browser: ${f}
|
|
7
|
+
Please open this URL manually: ${t}
|
|
8
|
+
`)})})}};function W(o){let e=o.state==="success",r=e?"#22c55e":"#ef4444",t=e?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",i=e?'<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>',n=o.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="utf-8" />
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
13
|
+
<title>${J(o.title)} \xB7 KaneAI</title>
|
|
14
|
+
<style>
|
|
15
|
+
:root {
|
|
16
|
+
color-scheme: light dark;
|
|
17
|
+
--bg: #f7f7f8;
|
|
18
|
+
--card: #ffffff;
|
|
19
|
+
--fg: #0a0a0a;
|
|
20
|
+
--muted: #6b7280;
|
|
21
|
+
--border: rgba(0, 0, 0, 0.06);
|
|
22
|
+
--shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
|
|
23
|
+
}
|
|
24
|
+
@media (prefers-color-scheme: dark) {
|
|
25
|
+
:root {
|
|
26
|
+
--bg: #0a0a0a;
|
|
27
|
+
--card: #141416;
|
|
28
|
+
--fg: #f5f5f7;
|
|
29
|
+
--muted: #9ca3af;
|
|
30
|
+
--border: rgba(255, 255, 255, 0.08);
|
|
31
|
+
--shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
* { box-sizing: border-box; }
|
|
35
|
+
html, body { height: 100%; }
|
|
36
|
+
body {
|
|
37
|
+
margin: 0;
|
|
38
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
39
|
+
background: var(--bg);
|
|
40
|
+
color: var(--fg);
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
padding: 24px;
|
|
45
|
+
-webkit-font-smoothing: antialiased;
|
|
46
|
+
}
|
|
47
|
+
.card {
|
|
48
|
+
width: 100%;
|
|
49
|
+
max-width: 420px;
|
|
50
|
+
background: var(--card);
|
|
51
|
+
border: 1px solid var(--border);
|
|
52
|
+
border-radius: 16px;
|
|
53
|
+
box-shadow: var(--shadow);
|
|
54
|
+
padding: 40px 32px 32px;
|
|
55
|
+
text-align: center;
|
|
56
|
+
animation: rise 280ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
|
|
57
|
+
}
|
|
58
|
+
@keyframes rise {
|
|
59
|
+
from { opacity: 0; transform: translateY(8px); }
|
|
60
|
+
to { opacity: 1; transform: translateY(0); }
|
|
61
|
+
}
|
|
62
|
+
.icon {
|
|
63
|
+
width: 64px;
|
|
64
|
+
height: 64px;
|
|
65
|
+
margin: 0 auto 20px;
|
|
66
|
+
border-radius: 999px;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
background: ${t};
|
|
71
|
+
color: ${r};
|
|
72
|
+
}
|
|
73
|
+
h1 {
|
|
74
|
+
font-size: 22px;
|
|
75
|
+
font-weight: 600;
|
|
76
|
+
letter-spacing: -0.01em;
|
|
77
|
+
margin: 0 0 8px;
|
|
78
|
+
}
|
|
79
|
+
p {
|
|
80
|
+
margin: 0;
|
|
81
|
+
color: var(--muted);
|
|
82
|
+
font-size: 14.5px;
|
|
83
|
+
line-height: 1.5;
|
|
84
|
+
}
|
|
85
|
+
.brand {
|
|
86
|
+
margin-top: 28px;
|
|
87
|
+
padding-top: 20px;
|
|
88
|
+
border-top: 1px solid var(--border);
|
|
89
|
+
font-size: 12px;
|
|
90
|
+
letter-spacing: 0.08em;
|
|
91
|
+
text-transform: uppercase;
|
|
92
|
+
color: var(--muted);
|
|
93
|
+
}
|
|
94
|
+
.brand strong { color: var(--fg); font-weight: 600; letter-spacing: 0.08em; }
|
|
95
|
+
</style>
|
|
96
|
+
</head>
|
|
97
|
+
<body>
|
|
98
|
+
<main class="card" role="status" aria-live="polite">
|
|
99
|
+
<div class="icon">${i}</div>
|
|
100
|
+
<h1>${J(o.title)}</h1>
|
|
101
|
+
<p>${J(o.message)}</p>
|
|
102
|
+
<div class="brand"><strong>KaneAI</strong> \xB7 CLI</div>
|
|
103
|
+
</main>
|
|
104
|
+
${n}
|
|
105
|
+
</body>
|
|
106
|
+
</html>`}function J(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}export{k as a,x as b,he as c};
|