@testmuai/kane-cli 0.6.4 → 0.6.6
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/bin/kane-cli.cjs +91 -0
- package/bin/resolve-runtime.cjs +45 -0
- package/dist/{ChatSurface-VXYU6KFW.js → ChatSurface-LV3KW6WN.js} +1 -1
- package/dist/{ChromeProfilePicker-QWTM7DK6.js → ChromeProfilePicker-6PLUQ5TW.js} +1 -1
- package/dist/{CliFeedbackPrompt-6NVWMONO.js → CliFeedbackPrompt-I4F56IVK.js} +1 -1
- package/dist/{CliUploadProgress-2YRQLECI.js → CliUploadProgress-ULRSPKY3.js} +1 -1
- package/dist/{ConfigView-I4R5M7BO.js → ConfigView-7NMYALEA.js} +1 -1
- package/dist/{EvidenceViewOffer-54GEARRX.js → EvidenceViewOffer-KQKPTMXA.js} +1 -1
- package/dist/{FolderPicker-5VWBYTAK.js → FolderPicker-4IOVDO2P.js} +1 -1
- package/dist/{HelpView-OJZW4XWX.js → HelpView-SHMVMHNU.js} +1 -1
- package/dist/{InfoBox-TGELGCBR.js → InfoBox-W2LZVGQS.js} +1 -1
- package/dist/{LinksBox-B5EBRY26.js → LinksBox-ZS25VTBY.js} +1 -1
- package/dist/{ProfilesView-3SJRIBHQ.js → ProfilesView-XBBRIQ3U.js} +1 -1
- package/dist/{ProjectPicker-72HKMBEY.js → ProjectPicker-AUN47FXS.js} +1 -1
- package/dist/{SaveSessionPrompt-CK5SGNRO.js → SaveSessionPrompt-Z2K225VN.js} +1 -1
- package/dist/SingleShotApp-M7R5PW4X.js +2 -0
- package/dist/{SummaryBox-ABB7ST26.js → SummaryBox-4T545XRB.js} +1 -1
- package/dist/TestMdRunView-JXRXMACE.js +2 -0
- package/dist/{WhoamiView-OF354UGC.js → WhoamiView-GCVD35EX.js} +1 -1
- package/dist/{bind-BWILBZGR.js → bind-JLMT57Q3.js} +2 -2
- package/dist/{bridge-LNDJS3HH.js → bridge-PDJEOSAJ.js} +1 -1
- package/dist/{changelog-BWCEZQ23.js → changelog-D65HWZDM.js} +1 -1
- package/dist/{chunk-AXABTFCD.js → chunk-24OFJ7SE.js} +1 -1
- package/dist/{chunk-UZSG54OY.js → chunk-24VYAMMK.js} +1 -1
- package/dist/{chunk-6LRKYF67.js → chunk-262ES67I.js} +2 -2
- package/dist/{chunk-64QURIT6.js → chunk-2BWRAY3Y.js} +1 -1
- package/dist/{chunk-2K4XOHVK.js → chunk-2WO7G2HO.js} +1 -1
- package/dist/{chunk-BYUARJE7.js → chunk-32GP7KTM.js} +1 -1
- package/dist/{chunk-IRRGSC7B.js → chunk-3Z3UIW5H.js} +1 -1
- package/dist/{chunk-QNNBNIR7.js → chunk-4A6BLXQN.js} +2 -2
- package/dist/{chunk-ACEODVSC.js → chunk-4R2HOA7J.js} +1 -1
- package/dist/{chunk-XUJ5EPVW.js → chunk-4SXD6XWV.js} +1 -1
- package/dist/{chunk-ADOXYGZE.js → chunk-5JJ245FW.js} +1 -1
- package/dist/{chunk-OB6CKLEL.js → chunk-6CZIEK6B.js} +1 -1
- package/dist/{chunk-POI6DCP6.js → chunk-6NIV7AVZ.js} +1 -1
- package/dist/chunk-6SGPN76K.js +2 -0
- package/dist/{chunk-I2JUBAPU.js → chunk-6XHAXAL2.js} +1 -1
- package/dist/{chunk-DNOBOZPO.js → chunk-AKHUNBQS.js} +1 -1
- package/dist/{chunk-IOTJZTHX.js → chunk-BLSZ4H5W.js} +12 -12
- package/dist/{chunk-5KSB5MOF.js → chunk-BV5QKFMJ.js} +1 -1
- package/dist/{chunk-4MUHS3UL.js → chunk-C42WWO7Y.js} +1 -1
- package/dist/chunk-D7L6UW5Z.js +7 -0
- package/dist/{chunk-MVF4KRHA.js → chunk-EOLQUB4Q.js} +1 -1
- package/dist/{chunk-PYB2EXRE.js → chunk-EWTX7HSU.js} +2 -2
- package/dist/chunk-GLS46X7N.js +5 -0
- package/dist/{chunk-YI4XULHR.js → chunk-HA5GE57Z.js} +15 -15
- package/dist/{chunk-YMSN25DX.js → chunk-HWA7WD44.js} +1 -1
- package/dist/{chunk-3HEPW6SN.js → chunk-JF7Q2I45.js} +1 -1
- package/dist/{chunk-QZI43UNV.js → chunk-JTEY32TL.js} +1 -1
- package/dist/{chunk-HNE4TDOZ.js → chunk-JU5KRCKD.js} +4 -4
- package/dist/{chunk-ANIVHX3P.js → chunk-JV356AYH.js} +1 -1
- package/dist/{chunk-MK2G7VIF.js → chunk-KI2DVQSA.js} +1 -1
- package/dist/{chunk-DXK55KGR.js → chunk-KNCHEM6A.js} +1 -1
- package/dist/{chunk-CT2I5KUM.js → chunk-KYHXDJN4.js} +1 -1
- package/dist/{chunk-652FEDL4.js → chunk-L26LU6TU.js} +2 -2
- package/dist/{chunk-3WJJ43MT.js → chunk-LABIRPOT.js} +1 -1
- package/dist/{chunk-IXVR66NS.js → chunk-LEQ2B3PR.js} +1 -1
- package/dist/{chunk-WE57PD6K.js → chunk-LLS47HUA.js} +1 -1
- package/dist/{chunk-OLXOZJ7X.js → chunk-LURGFJEE.js} +1 -1
- package/dist/{chunk-5CTMOJG4.js → chunk-MSPZOEFB.js} +1 -1
- package/dist/{chunk-PICCLJSO.js → chunk-MY32TBBR.js} +1 -1
- package/dist/{chunk-STH6I3UB.js → chunk-N6DO2LBH.js} +1 -1
- package/dist/{chunk-O66EU5UV.js → chunk-OFEOWKM3.js} +1 -1
- package/dist/{chunk-BOO7YXAV.js → chunk-P4HW2NTZ.js} +1 -1
- package/dist/{chunk-CY5NDMO7.js → chunk-RIMJDJWY.js} +1 -1
- package/dist/{chunk-ZQP3MCZW.js → chunk-RV2NXHIC.js} +1 -1
- package/dist/{chunk-WT3SMSY5.js → chunk-S2C62SDY.js} +1 -1
- package/dist/{chunk-FV4LLU3T.js → chunk-UZJ7MRBV.js} +1 -1
- package/dist/{chunk-W36P7S5W.js → chunk-VBCE4U4B.js} +1 -1
- package/dist/{chunk-CLTANA4L.js → chunk-WJGBXJT4.js} +2 -2
- package/dist/{chunk-BNN6ZDJW.js → chunk-WWH7CW5R.js} +1 -1
- package/dist/{chunk-WFEGGQJ4.js → chunk-XQL53VB7.js} +1 -1
- package/dist/{config-OJF53CHL.js → config-6PAZZ7CR.js} +1 -1
- package/dist/{credentials-NLJHSVBY.js → credentials-BJCIWQWA.js} +1 -1
- package/dist/{evidence-UPOFW3XC.js → evidence-7VE5EGEF.js} +1 -1
- package/dist/{evolve-cmd-MVALOB3G.js → evolve-cmd-RUGUWKAG.js} +1 -1
- package/dist/{extract-bind-SSTKQGTV.js → extract-bind-YS7C4KZ3.js} +2 -2
- package/dist/{extract-cmd-GO4UV7ER.js → extract-cmd-Z4PMDIMZ.js} +1 -1
- package/dist/{generate-headless-2HYMSVN5.js → generate-headless-IWY32HC4.js} +2 -2
- package/dist/index.js +12 -12
- package/dist/{interactive-bind-Q5TQFQ6N.js → interactive-bind-ZIIJDRBU.js} +2 -2
- package/dist/{list-commands-6WDXAECV.js → list-commands-SSXJQGE7.js} +1 -1
- package/dist/login-flow-HRS6YACY.js +2 -0
- package/dist/{persist-recorded-session-KHIMN4A3.js → persist-recorded-session-3AOYZJT2.js} +1 -1
- package/dist/{pipeline-2HRAWT5U.js → pipeline-IZSODNCC.js} +1 -1
- package/dist/{reconcile-cmd-DH4VV6PG.js → reconcile-cmd-6HVZJFG3.js} +1 -1
- package/dist/{recording-banner-SADVYNEP.js → recording-banner-KKEUWS3N.js} +1 -1
- package/dist/{require-project-folder-LP7V26IU.js → require-project-folder-NPTKR2AW.js} +1 -1
- package/dist/{run-RT2VMPTQ.js → run-2A7M7EJK.js} +1 -1
- package/dist/{run-XAZMT7WO.js → run-6AFY35QW.js} +1 -1
- package/dist/{run-test-md-ATB2HZRG.js → run-test-md-QNC6KDMN.js} +2 -2
- package/dist/{skill-installer-DE2LSSKU.js → skill-installer-ULFNSE6X.js} +1 -1
- package/dist/{spawner-GOTVIFR5.js → spawner-DWONVIPI.js} +1 -1
- package/dist/tcg-generate-IHHPRVNG.js +2 -0
- package/dist/{testmd-actions-RYQHBX4K.js → testmd-actions-S3ZNOZEK.js} +1 -1
- package/dist/token-refresh-CFVOA62N.js +2 -0
- package/dist/{validate-basic-6BQ2L7TT.js → validate-basic-4OLDKIA2.js} +1 -1
- package/dist/{version-check-YW3FUWDH.js → version-check-UL4S6R4N.js} +1 -1
- package/dist/{walk-session-O4TMVORI.js → walk-session-N3BP57HK.js} +1 -1
- package/package.json +15 -7
- package/bin/kane-cli.js +0 -2
- package/dist/SingleShotApp-AJBIWW74.js +0 -2
- package/dist/TestMdRunView-5PMLLLFT.js +0 -2
- package/dist/chunk-E3BO7OVR.js +0 -7
- package/dist/chunk-HJGUEZLW.js +0 -2
- package/dist/chunk-IJPFAWBH.js +0 -5
- package/dist/login-flow-XQMJFC4H.js +0 -2
- package/dist/tcg-generate-7PUXJ5R4.js +0 -2
- package/dist/token-refresh-F5KRV7ER.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as $}from"./chunk-
|
|
2
|
+
import{a as $}from"./chunk-6XHAXAL2.js";import{b as D}from"./chunk-D7L6UW5Z.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
|
|
3
3
|
|
|
4
|
-
`))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let
|
|
5
|
-
`))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,
|
|
6
|
-
`).trim()}function wt(e){return{mode:"bifurcate",objective:e.objective,model:e.model,session_id:e.sessionId,run_index:0,width:0,height:0,stream:!0,variables:e.variables,...e.auth}}async function St(e,t,n){let i=D(e,t),
|
|
4
|
+
`))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
|
|
5
|
+
`))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`
|
|
6
|
+
`).trim()}function wt(e){return{mode:"bifurcate",objective:e.objective,model:e.model,session_id:e.sessionId,run_index:0,width:0,height:0,stream:!0,variables:e.variables,...e.auth}}async function St(e,t,n){let i=D(e,t),d=()=>i.cancel();n?.addEventListener("abort",d);let r=null,o=null;try{for await(let p of i.events)if(p.type==="bifurcation_result"){let a=p,c=(a.sub_objectives??[]).map((g,m)=>({...g,sequence_index:m}));r={sub_objectives:c,extracted_variables:a.extracted_variables??{},total_flows:c.length,is_single_flow:c.length<=1,credits_consumed:a.credits_consumed??0}}else p.type==="error"&&(o=p.message??"bifurcation error")}finally{n?.removeEventListener("abort",d),i.cancel()}if(r)return r;throw new Error(o??"bifurcation produced no result")}export{U as a,je as b,q as c,Re as d,Ce as e,P as f,v as g,Ue as h,R as i,ct as j,Y as k,ft as l,Ae as m,ht as n,wt as o,St as p,de as q,Ge as r,B as s,Xe as t,tt as u,rt as v};
|
|
@@ -2,4 +2,4 @@ import { createRequire } from 'module'; const require = createRequire(import.met
|
|
|
2
2
|
import{a as O}from"./chunk-3C5GMAM4.js";import{a as S,b as A,d as P}from"./chunk-GRB66C5S.js";import{a as U}from"./chunk-JFAFKHDX.js";import{a as G}from"./chunk-QPZRHAYK.js";import{d as T}from"./chunk-2PQXEEVY.js";import{a as E,b as $}from"./chunk-MCQXRJGH.js";import{d as g,e as m}from"./chunk-5YPBPZUR.js";var v=(e,t,n=new Set)=>{let o=e.nameOf.get(t);if(o!==void 0)return o;if(n.has(t))return t;n.add(t);for(let[s,r]of e.superseded){if(r!==t)continue;let c=v(e,s,n);if(c!==s)return c}return t};function M(e,t){let n=e.stale(t);if(n==="fresh")return;if(n==="orphaned")return"orphaned \u2014 no live source evidences this item";let o=[],s=new Map;for(let r of e.derivesInto(t))s.set(String(r.props.source_id),r);for(let[r,c]of s){let i=e.heads.get(r);if(i==null||i===c.props.source_cid)continue;let u=e.convChains.get(r)?.chain;u&&u.includes(String(c.props.source_cid))||o.push(`DERIVES pin ${r}@${String(c.props.source_cid).slice(0,19)} broke \u2014 the source head moved`)}for(let r of e.edgesFrom(t)){if(r.type===m.DERIVES||!e.superseded.has(r.dst))continue;let c=e.tipOf(r.dst);if(e.superseded.has(c)){o.push(`${r.type} pin \u2192 ${v(e,r.dst)} \u2014 target retired`);continue}let i=L(e,r.dst,c);o.push(i.length>0?`${v(e,r.dst)} updated: ${i.map(u=>u.field).join(", ")}`:`${r.type} pin \u2192 ${v(e,r.dst)} \u2014 target superseded`)}return o.length>0?o.join("; "):"stale \u2014 a pinned dependency moved"}function L(e,t,n){let o=e.getNode(t)?.content??{},s=e.getNode(n)?.content??{},r=i=>i===void 0?"":Array.isArray(i)?i.map(String).join(" \xB7 "):typeof i=="object"?JSON.stringify(i):String(i),c=[];for(let i of[...new Set([...Object.keys(o),...Object.keys(s)])].sort())JSON.stringify(o[i])!==JSON.stringify(s[i])&&c.push({field:i,old:r(o[i]),new:r(s[i])});return c}function V(e,t){let n=[];for(let{cid:o}of e.byLabel(g.SCENARIO))e.superseded.has(o)||e.edgesFrom(o).some(s=>s.type===m.BELONGS_TO&&e.tipOf(s.dst)===t)&&n.push(o);return n}function R(e,t){let n=[],o=[],s=[],r=V(e,t),c=new Set(r),i=(u,f)=>{let d=M(e,f);return d===void 0?u:{...u,stale:!0,stale_reason:d}};for(let u of r){let f=e.getNode(u)?.content??{};n.push(i({ref:v(e,u),title:String(f.title??""),case_type:String(f.case_type??""),intent:String(f.intent??"")},u));for(let d of e.edgesInto(u)){if(d.type!==m.AUTOMATES||e.superseded.has(d.src))continue;let a=e.getNode(d.src)?.content??{},l=e.edgesFrom(d.src).filter(p=>p.type===m.VERIFIES&&!e.superseded.has(p.dst)).map(p=>v(e,p.dst));o.push(i({ref:v(e,d.src),title:String(a.title??""),check:a.check,verifies:l},d.src))}}for(let{cid:u}of e.byLabel(g.AC)){if(e.superseded.has(u))continue;let f=e.edgesFrom(u).find(p=>p.type===m.SCOPED_TO);if(!f)continue;let d=e.tipOf(f.dst);if(!(d===t||c.has(d)))continue;let l=e.getNode(u)?.content??{};s.push(i({ref:v(e,u),text:String(l.text??""),kind:String(l.kind??""),scope:d===t?"use-case":v(e,d)},u))}return{scenarios:n,tests:o,acs:s}}function I(e,t,n){let o=t.getNode(n)?.content.blob;if(typeof o!="string")return null;let s=T(e,o);return s===null?null:s.toString("utf8")}function q(e,t){let n=t.split(`
|
|
3
3
|
`).map(s=>s.replace(/^\d+\| /,"")),o=[];for(let s of e.split(`
|
|
4
4
|
`)){let r=s.trim();if(r.length===0)continue;let c=n.find(i=>i.includes(r));c!==void 0&&!o.includes(c.trim())&&o.push(c.trim())}return o.length>0?o.join(`
|
|
5
|
-
`):{removed:!0}}function J(e,t,n,o){if(o!==void 0&&o.trim().length>0)return{kind:"user-directive",text:o.trim()};let s=[n,...R(t,n).acs.map(u=>t.resolve(u.ref)?.cid??"")].filter(Boolean),r=[],c=new Set;for(let u of s){let f=new Map;for(let d of t.derivesInto(u))f.set(String(d.props.source_id),d);for(let[d,a]of f){let l=t.heads.get(d);if(l==null||l===a.props.source_cid)continue;let p=String(a.props.anchor),b=`${d}\0${p}`;if(c.has(b)||p==="img#whole")continue;c.add(b);let k=I(e,t,String(a.props.source_cid)),w=k===null?null:G(k,p);if(w===null)continue;let x=I(e,t,l);r.push({source_id:d,anchor:p,old_anchor_text:w,new_anchor_text:x===null?{removed:!0}:q(w,x)})}}let i;for(let[u,f]of t.superseded){if(f!==n||t.nodeLabel.get(u)!==g.USECASE)continue;let d=L(t,u,n);d.length>0&&(i=d);break}return{kind:"source-change",changes:r,...i?{uc_updated:i}:{}}}function N(e,t,n,o){let s=R(t,n);if(s.scenarios.length===0&&s.tests.length===0&&s.acs.length===0)return;let r=J(e,t,n,o);if(!(r.kind==="source-change"&&r.changes.length===0&&!r.uc_updated))return{prior_design:s,change_delta:r}}var _=new Set([g.USECASE,g.SCENARIO,g.AC,g.TEST]);function h(e,t){return!e.superseded.has(t)&&e.trust.get(t)!=="archived"}function y(e,t,n){let o=e.edgesFrom(t).find(s=>s.type===n);return o?e.tipOf(o.dst):null}function D(e,t,n){if(n===g.USECASE)return t;if(n===g.SCENARIO)return y(e,t,m.BELONGS_TO);if(n===g.AC){let o=y(e,t,m.SCOPED_TO);return o?e.nodeLabel.get(o)===g.USECASE?o:y(e,o,m.BELONGS_TO):null}if(n===g.TEST){let o=y(e,t,m.AUTOMATES);return o?y(e,o,m.BELONGS_TO):null}return null}function j(e,t){let n=e.nameOf.get(t);if(n)return n;for(let[o,s]of e.names)if(e.tipOf(s)===t)return o;return t}function B(e,t){return{ucTip:t,display:j(e,t),seamRef:e.nameOf.get(t)??t}}function Y(e,t){let n=e.resolve(t);if(!n)return{ok:!1,message:`unknown ref '${t}' \u2014 no test/scenario/ac/use-case by that id or cid`};let o=n.tip,s=e.nodeLabel.get(o);if(!s||!_.has(s))return{ok:!1,message:`'${t}' is a ${s??"missing node"} \u2014 evolve takes a test, scenario, acceptance criterion, or use-case`};let r=D(e,o,s);return!r||e.nodeLabel.get(r)!==g.USECASE?{ok:!1,message:`cannot resolve '${t}' to a parent use-case \u2014 its ${s} chain is broken`}:e.superseded.has(r)?{ok:!1,message:`use-case ${j(e,r)} was removed \u2014 nothing to evolve`}:{ok:!0,target:B(e,r)}}function de(e,t){return C(e,t)}function C(e,t){let n=[];for(let{cid:s}of e.byLabel(g.SCENARIO)){if(!h(e,s)||!e.edgesFrom(s).some(c=>c.type===m.BELONGS_TO&&e.tipOf(c.dst)===t))continue;let r=e.edgesInto(s).filter(c=>c.type===m.AUTOMATES&&h(e,c.src));if(r.length===0)n.push({scenario:s,test:null});else for(let c of r)n.push({scenario:s,test:c.src})}let o=new Map;for(let{cid:s}of e.byLabel(g.AC)){if(!h(e,s)||D(e,s,g.AC)!==t)continue;let r=e.edgesInto(s).filter(c=>c.type===m.VERIFIES&&h(e,c.src)).map(c=>c.src).sort();o.set(s,r)}return{pairs:n,verifies:o}}function H(e,t){let n=c=>`${c.scenario}\0${c.test??""}`,o=new Set(e.pairs.map(n)),s=new Set(t.pairs.map(n)),r=[];for(let[c,i]of e.verifies){let u=t.verifies.get(c);u&&(i.length===u.length&&i.every((f,d)=>f===u[d])||r.push({ac:c,before:i,after:u}))}return{superseded:e.pairs.filter(c=>!s.has(n(c))),minted:t.pairs.filter(c=>!o.has(n(c))),retained:t.pairs.filter(c=>o.has(n(c))),moves:r}}function z(e,t,n,o,s){let r=i=>t.nameOf.get(i)??i,c=i=>` - ${r(i.scenario)} \xB7 ${i.test?r(i.test):"(no test)"}`;e.out(`evolved: use-case ${n} \u2014 design record ${o.before} \u2192 ${o.after}`),e.out(`superseded: ${s.superseded.length} pair(s)`);for(let i of s.superseded)e.out(c(i));e.out(`minted: ${s.minted.length} pair(s)`);for(let i of s.minted)e.out(c(i));e.out(`retained: ${s.retained.length} pair(s)`);for(let i of s.retained)e.out(c(i));if(s.moves.length===0)e.out("verifies moves: none");else{e.out("verifies moves:");for(let i of s.moves){let u=f=>f.length>0?f.map(r).join(" + "):"(none)";e.out(` - ${r(i.ac)}: ${u(i.before)} \u2192 ${u(i.after)}`)}}}async function F(e,t,n,o,s,r){let c=E(e),i=O(c,t.ucTip);if(!i)return r==="batch"?(o.out(`note: ${t.display} has no design output \u2014 nothing to evolve; run kane-cli design tests --use-case ${t.display} first`),{code:0,outcome:"no-design"}):(S(o,`nothing to evolve \u2014 run kane-cli design tests --use-case ${t.display} first (no design output)`),{code:2,outcome:"no-design"});let u=C(c,t.ucTip),f=`evolve re-designs the parent use-case ${t.display}; ${u.pairs.length} pair(s) affected`;if(n.yes)o.out(f);else if(!await o.confirm(`${f} \u2014 proceed?`))return o.out(r==="batch"?`skipped ${t.display}`:"declined \u2014 nothing evolved"),{code:0,outcome:"declined"};let d=N(e,c,t.ucTip,n.because),a=await s(t.seamRef,{yes:!!n.yes,...n.mode?{mode:n.mode}:{},...n.because?{because:n.because}:{},...d!==void 0?{changeDelta:d.change_delta,priorDesign:d.prior_design}:{}});if(a===3)return o.out(`design session for ${t.display} paused \u2014 resume with \`kane-cli design tests --resume\`, then re-run evolve for the diff`),{code:a,outcome:"paused"};if(a!==0)return S(o,`design run for ${t.display} ended with exit code ${a} \u2014 no diff to report`),{code:a,outcome:"failed"};let l=E(e),p=l.tipOf(t.ucTip),b=O(l,p)?.seq;return z(o,l,t.display,{before:i.seq,after:b??"?"},H(u,C(l,p))),{code:0,outcome:"evolved"}}function K(e){let t=new Map,n=0;for(let{cid:s,state:r}of e.staleList()){if(r==="superseded")continue;let c=e.nodeLabel.get(s);if(!c||!_.has(c)||!h(e,s)||!$(e,s))continue;let i=D(e,s,c);!i||e.nodeLabel.get(i)!==g.USECASE||e.superseded.has(i)||(n++,t.has(i)||t.set(i,B(e,i)))}return{targets:[...t.values()].sort((s,r)=>s.display<r.display?-1:s.display>r.display?1:0),staleCount:n}}function Q(e,t){for(let{cid:n,state:o}of e.staleList()){if(o==="superseded")continue;let s=e.nodeLabel.get(n);if(!(!s||!_.has(s)||!h(e,n))&&$(e,n)&&D(e,n,s)===t)return!0}return!1}async function W(e,t,n,o={},s=process.cwd()){if(e&&t.fromStale)return S(n,"pass a <ref> OR --from-stale, not both"),2;if(!e&&!t.fromStale)return S(n,"evolve needs a <ref> or --from-stale"),2;let r=A(s,n);if(!r)return 2;let c=o.runDesignForUc??X;n.out(`evolving ${e??"stale use-cases"}: reading the graph\u2026`);let i=E(r),u,f=null;if(e){let a=Y(i,e);if(!a.ok)return S(n,a.message),2;if(!t.because&&O(i,a.target.ucTip)&&!Q(i,a.target.ucTip))return S(n,`nothing changed underneath ${e} \u2014 its sources and requirements are current; use --because "<reason>" to re-design anyway`),2;u=[a.target]}else{let{targets:a,staleCount:l}=K(i);if(a.length===0)return n.out("nothing stale \u2014 nothing to evolve"),0;f=`from-stale: ${l} stale node(s) \u2192 ${a.length} use-case(s)`,u=a}if(!t.yes&&!n.isTTY)return S(n,"evolve needs a TTY \u2014 the blast-radius confirm is the point; headless evolution rides `kane-cli maintain reconcile`"),2;if(f&&n.out(f),e){let a=await F(r,u[0],t,n,c,"single");return a.outcome==="evolved"&&t.because&&U(r,{ts:new Date().toISOString(),command:"evolve",id:e,verdict:"gap-resolved-evolve",polarity:"preference",by:{kind:"human",id:process.env.USER??"operator"},target:e,reason:t.because}),a.code}let d=0;for(let a of u){let{code:l}=await F(r,a,t,n,c,"batch");l!==0&&d===0&&(d=l)}return d}var X=async(e,t)=>{let{designTestsCommand:n}=await import("./bind-
|
|
5
|
+
`):{removed:!0}}function J(e,t,n,o){if(o!==void 0&&o.trim().length>0)return{kind:"user-directive",text:o.trim()};let s=[n,...R(t,n).acs.map(u=>t.resolve(u.ref)?.cid??"")].filter(Boolean),r=[],c=new Set;for(let u of s){let f=new Map;for(let d of t.derivesInto(u))f.set(String(d.props.source_id),d);for(let[d,a]of f){let l=t.heads.get(d);if(l==null||l===a.props.source_cid)continue;let p=String(a.props.anchor),b=`${d}\0${p}`;if(c.has(b)||p==="img#whole")continue;c.add(b);let k=I(e,t,String(a.props.source_cid)),w=k===null?null:G(k,p);if(w===null)continue;let x=I(e,t,l);r.push({source_id:d,anchor:p,old_anchor_text:w,new_anchor_text:x===null?{removed:!0}:q(w,x)})}}let i;for(let[u,f]of t.superseded){if(f!==n||t.nodeLabel.get(u)!==g.USECASE)continue;let d=L(t,u,n);d.length>0&&(i=d);break}return{kind:"source-change",changes:r,...i?{uc_updated:i}:{}}}function N(e,t,n,o){let s=R(t,n);if(s.scenarios.length===0&&s.tests.length===0&&s.acs.length===0)return;let r=J(e,t,n,o);if(!(r.kind==="source-change"&&r.changes.length===0&&!r.uc_updated))return{prior_design:s,change_delta:r}}var _=new Set([g.USECASE,g.SCENARIO,g.AC,g.TEST]);function h(e,t){return!e.superseded.has(t)&&e.trust.get(t)!=="archived"}function y(e,t,n){let o=e.edgesFrom(t).find(s=>s.type===n);return o?e.tipOf(o.dst):null}function D(e,t,n){if(n===g.USECASE)return t;if(n===g.SCENARIO)return y(e,t,m.BELONGS_TO);if(n===g.AC){let o=y(e,t,m.SCOPED_TO);return o?e.nodeLabel.get(o)===g.USECASE?o:y(e,o,m.BELONGS_TO):null}if(n===g.TEST){let o=y(e,t,m.AUTOMATES);return o?y(e,o,m.BELONGS_TO):null}return null}function j(e,t){let n=e.nameOf.get(t);if(n)return n;for(let[o,s]of e.names)if(e.tipOf(s)===t)return o;return t}function B(e,t){return{ucTip:t,display:j(e,t),seamRef:e.nameOf.get(t)??t}}function Y(e,t){let n=e.resolve(t);if(!n)return{ok:!1,message:`unknown ref '${t}' \u2014 no test/scenario/ac/use-case by that id or cid`};let o=n.tip,s=e.nodeLabel.get(o);if(!s||!_.has(s))return{ok:!1,message:`'${t}' is a ${s??"missing node"} \u2014 evolve takes a test, scenario, acceptance criterion, or use-case`};let r=D(e,o,s);return!r||e.nodeLabel.get(r)!==g.USECASE?{ok:!1,message:`cannot resolve '${t}' to a parent use-case \u2014 its ${s} chain is broken`}:e.superseded.has(r)?{ok:!1,message:`use-case ${j(e,r)} was removed \u2014 nothing to evolve`}:{ok:!0,target:B(e,r)}}function de(e,t){return C(e,t)}function C(e,t){let n=[];for(let{cid:s}of e.byLabel(g.SCENARIO)){if(!h(e,s)||!e.edgesFrom(s).some(c=>c.type===m.BELONGS_TO&&e.tipOf(c.dst)===t))continue;let r=e.edgesInto(s).filter(c=>c.type===m.AUTOMATES&&h(e,c.src));if(r.length===0)n.push({scenario:s,test:null});else for(let c of r)n.push({scenario:s,test:c.src})}let o=new Map;for(let{cid:s}of e.byLabel(g.AC)){if(!h(e,s)||D(e,s,g.AC)!==t)continue;let r=e.edgesInto(s).filter(c=>c.type===m.VERIFIES&&h(e,c.src)).map(c=>c.src).sort();o.set(s,r)}return{pairs:n,verifies:o}}function H(e,t){let n=c=>`${c.scenario}\0${c.test??""}`,o=new Set(e.pairs.map(n)),s=new Set(t.pairs.map(n)),r=[];for(let[c,i]of e.verifies){let u=t.verifies.get(c);u&&(i.length===u.length&&i.every((f,d)=>f===u[d])||r.push({ac:c,before:i,after:u}))}return{superseded:e.pairs.filter(c=>!s.has(n(c))),minted:t.pairs.filter(c=>!o.has(n(c))),retained:t.pairs.filter(c=>o.has(n(c))),moves:r}}function z(e,t,n,o,s){let r=i=>t.nameOf.get(i)??i,c=i=>` - ${r(i.scenario)} \xB7 ${i.test?r(i.test):"(no test)"}`;e.out(`evolved: use-case ${n} \u2014 design record ${o.before} \u2192 ${o.after}`),e.out(`superseded: ${s.superseded.length} pair(s)`);for(let i of s.superseded)e.out(c(i));e.out(`minted: ${s.minted.length} pair(s)`);for(let i of s.minted)e.out(c(i));e.out(`retained: ${s.retained.length} pair(s)`);for(let i of s.retained)e.out(c(i));if(s.moves.length===0)e.out("verifies moves: none");else{e.out("verifies moves:");for(let i of s.moves){let u=f=>f.length>0?f.map(r).join(" + "):"(none)";e.out(` - ${r(i.ac)}: ${u(i.before)} \u2192 ${u(i.after)}`)}}}async function F(e,t,n,o,s,r){let c=E(e),i=O(c,t.ucTip);if(!i)return r==="batch"?(o.out(`note: ${t.display} has no design output \u2014 nothing to evolve; run kane-cli design tests --use-case ${t.display} first`),{code:0,outcome:"no-design"}):(S(o,`nothing to evolve \u2014 run kane-cli design tests --use-case ${t.display} first (no design output)`),{code:2,outcome:"no-design"});let u=C(c,t.ucTip),f=`evolve re-designs the parent use-case ${t.display}; ${u.pairs.length} pair(s) affected`;if(n.yes)o.out(f);else if(!await o.confirm(`${f} \u2014 proceed?`))return o.out(r==="batch"?`skipped ${t.display}`:"declined \u2014 nothing evolved"),{code:0,outcome:"declined"};let d=N(e,c,t.ucTip,n.because),a=await s(t.seamRef,{yes:!!n.yes,...n.mode?{mode:n.mode}:{},...n.because?{because:n.because}:{},...d!==void 0?{changeDelta:d.change_delta,priorDesign:d.prior_design}:{}});if(a===3)return o.out(`design session for ${t.display} paused \u2014 resume with \`kane-cli design tests --resume\`, then re-run evolve for the diff`),{code:a,outcome:"paused"};if(a!==0)return S(o,`design run for ${t.display} ended with exit code ${a} \u2014 no diff to report`),{code:a,outcome:"failed"};let l=E(e),p=l.tipOf(t.ucTip),b=O(l,p)?.seq;return z(o,l,t.display,{before:i.seq,after:b??"?"},H(u,C(l,p))),{code:0,outcome:"evolved"}}function K(e){let t=new Map,n=0;for(let{cid:s,state:r}of e.staleList()){if(r==="superseded")continue;let c=e.nodeLabel.get(s);if(!c||!_.has(c)||!h(e,s)||!$(e,s))continue;let i=D(e,s,c);!i||e.nodeLabel.get(i)!==g.USECASE||e.superseded.has(i)||(n++,t.has(i)||t.set(i,B(e,i)))}return{targets:[...t.values()].sort((s,r)=>s.display<r.display?-1:s.display>r.display?1:0),staleCount:n}}function Q(e,t){for(let{cid:n,state:o}of e.staleList()){if(o==="superseded")continue;let s=e.nodeLabel.get(n);if(!(!s||!_.has(s)||!h(e,n))&&$(e,n)&&D(e,n,s)===t)return!0}return!1}async function W(e,t,n,o={},s=process.cwd()){if(e&&t.fromStale)return S(n,"pass a <ref> OR --from-stale, not both"),2;if(!e&&!t.fromStale)return S(n,"evolve needs a <ref> or --from-stale"),2;let r=A(s,n);if(!r)return 2;let c=o.runDesignForUc??X;n.out(`evolving ${e??"stale use-cases"}: reading the graph\u2026`);let i=E(r),u,f=null;if(e){let a=Y(i,e);if(!a.ok)return S(n,a.message),2;if(!t.because&&O(i,a.target.ucTip)&&!Q(i,a.target.ucTip))return S(n,`nothing changed underneath ${e} \u2014 its sources and requirements are current; use --because "<reason>" to re-design anyway`),2;u=[a.target]}else{let{targets:a,staleCount:l}=K(i);if(a.length===0)return n.out("nothing stale \u2014 nothing to evolve"),0;f=`from-stale: ${l} stale node(s) \u2192 ${a.length} use-case(s)`,u=a}if(!t.yes&&!n.isTTY)return S(n,"evolve needs a TTY \u2014 the blast-radius confirm is the point; headless evolution rides `kane-cli maintain reconcile`"),2;if(f&&n.out(f),e){let a=await F(r,u[0],t,n,c,"single");return a.outcome==="evolved"&&t.because&&U(r,{ts:new Date().toISOString(),command:"evolve",id:e,verdict:"gap-resolved-evolve",polarity:"preference",by:{kind:"human",id:process.env.USER??"operator"},target:e,reason:t.because}),a.code}let d=0;for(let a of u){let{code:l}=await F(r,a,t,n,c,"batch");l!==0&&d===0&&(d=l)}return d}var X=async(e,t)=>{let{designTestsCommand:n}=await import("./bind-JLMT57Q3.js"),o=()=>n({useCase:e,force:!0,...t.mode?{mode:t.mode}:t.yes?{mode:"override"}:{},...t.because?{because:t.because}:{},...t.changeDelta!==void 0?{changeDelta:t.changeDelta}:{},...t.priorDesign!==void 0?{priorDesign:t.priorDesign}:{}});if(t.mode!=="agent")return o();let s=process.stdout.write;process.stdout.write=((...r)=>!0);try{return await o()}finally{process.stdout.write=s}};async function ae(e,t){return W(e,t,P(),{})}export{Y as a,de as b,F as c,K as d,W as e,X as f,ae as g};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as $e}from"./chunk-
|
|
2
|
+
import{c as $e}from"./chunk-5JJ245FW.js";import{a as te}from"./chunk-2WO7G2HO.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-6NIV7AVZ.js";import{a as ve}from"./chunk-3Z3UIW5H.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{y as i}from"./chunk-6SGPN76K.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={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 Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.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((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
|
|
3
3
|
`)){if(l===""){n.push("");continue}let a="";for(let u of l.split(" ")){let c=u;for(;c.length>t;)a&&(n.push(a),a=""),n.push(c.slice(0,t)),c=c.slice(t);a===""?a=c:a.length+1+c.length<=t?a+=" "+c:(n.push(a),a=c)}n.push(a)}return n}function je({text:e,maxLines:t=3}){let{stdout:n}=ee(),l=Math.max(20,(n?.columns??80)-7),a=!e.trim(),[u,c]=(0,De.useState)(!0);K(()=>c(T=>!T),500);let v=(a?"Thinking\u2026":e)+(u?"\u258C":" "),S=ze(v,l).slice(-t);for(;S.length<t;)S.push("");return(0,me.jsx)(s,{borderStyle:"round",borderColor:i.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:S.map((T,d)=>(0,me.jsx)(o,{color:a?i.dim:i.secondary,wrap:"truncate-end",children:T.length?T:" "},d))})}var U=R(k(),1);function se({activity:e,describe:t,describeVisible:n}){return(0,U.jsxs)(U.Fragment,{children:[e?(0,U.jsx)(Pe,{label:e.label,shimmer:e.shimmer}):null,n?(0,U.jsx)(je,{text:t??""}):null]})}var r=R(k(),1);function le(e){for(let t of e){if(t.children&&t.children.length>0){let n=le(t.children);if(n)return n}if(t.status==="running")return t}}function z(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function Fe(e){let t=[];for(let n of e)z(n)||(n.children&&n.children.length>0?t.push({...n,children:Fe(n.children)}):t.push(n));return t}function ge(e,t){if(!e)return null;let n=e.objective??"";return n.length>0&&!/^Step \d+$/.test(n)?{label:n+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function P({step:e,indent:t=2}){let n=e.actionType?Oe(e.actionType):null,l=e.status==="running",a=e.status==="passed",u=e.status==="failed",c=e.status==="pending"||e.status==="stopped",{stdout:v}=ee(),S=v?.columns??80,T=Math.max(20,S-t-21),d=e.objective??"",L=d.length>T?d.slice(0,T-1)+"\u2026":d,O=(e.duration??0)*1e3,y=e.duration!=null?O<1e3?`${Math.round(O)}ms`:`${(O/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsxs)(s,{marginLeft:t,children:[(0,r.jsx)(s,{width:4,children:(0,r.jsxs)(o,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(s,{width:3,children:l?(0,r.jsx)(te,{}):a?(0,r.jsx)(o,{color:i.green,bold:!0,children:"\u2713"}):u?(0,r.jsx)(o,{color:i.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:i.muted,children:"\u25CB"})}),(0,r.jsx)(s,{flexGrow:1,children:l?(0,r.jsx)(oe,{text:L,active:!0}):u?(0,r.jsx)(o,{color:i.red,children:L}):c?(0,r.jsx)(o,{color:i.dim,children:L}):(0,r.jsx)(o,{color:i.dim,children:L})}),(a||u)&&n?(0,r.jsx)(s,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:i.muted,children:n})}):(0,r.jsx)(s,{width:3,marginLeft:1}),(0,r.jsx)(s,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:i.dim,children:y})})]}),e.children&&e.children.length>0&&(0,r.jsx)(s,{flexDirection:"column",children:e.children.map((h,b)=>(0,r.jsx)(P,{step:h,indent:t+2},`child-${b}`))})]})}function Xe(e){return e.type==="cm_init"?(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(P,{step:e.step})})}function _e({steps:e,bifurcated:t,flows:n,cmInitCounts:l,maxSteps:a=50,staticSteps:u=!1,onStepCommit:c,describe:v,describeVisible:S,describeRevealing:T}){let d=(0,I.useRef)(new Set),L=(0,I.useRef)(!1),O=(0,I.useRef)(new Set),y=(0,I.useRef)(!1),h=(0,I.useRef)(new Set),b=(0,I.useRef)(0);(0,I.useEffect)(()=>{e.length===0&&b.current>0&&(d.current.clear(),L.current=!1,O.current.clear(),y.current=!1,h.current.clear()),b.current=e.length},[e.length]);let B=e.flatMap(p=>[p,...p.children??[]]),F=B.some(p=>p.status==="running"),M=B.some(p=>p.status==="failed"),X=B.length===0||B.every(p=>p.status==="pending"),Y=B.filter(p=>p.status==="passed"||p.status==="failed").length,N;X?N="starting":F?N="running":M?N="failed":N="passed";let J=(0,I.useRef)(null),[ce,he]=(0,I.useState)(0);(0,I.useEffect)(()=>{B.length===0||X?(J.current=null,he(0)):F&&J.current==null&&(J.current=Date.now())},[F,X,B.length]),(0,I.useEffect)(()=>{if(!F)return;let p=setInterval(()=>{J.current!=null&&he((Date.now()-J.current)/1e3)},500);return()=>clearInterval(p)},[F]);let ae=(0,I.useRef)(new Set),[,xe]=(0,I.useState)(0),be=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c||!u||t)return;let p=[];!be.current&&l&&l[0]!=null&&(be.current=!0,l[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:l[0]}));for(let g of e)(g.status==="passed"||g.status==="failed")&&!ae.current.has(g.index)&&(ae.current.add(g.index),p.push({key:`step_${g.index}`,type:"step",step:{...g,children:g.children?[...g.children]:void 0}}));if(p.length>0){for(let g of p)c(Xe(g));xe(g=>g+1)}},[e,t,l,u,c]),(0,I.useEffect)(()=>{if(!c||u)return;let p=d.current.size;if(!t&&!y.current&&l&&l[0]!=null&&(y.current=!0,l[0]>0&&c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25A0 Generated task with ",l[0]," checkpoints"]})}))),t&&n&&!L.current&&(L.current=!0,c((0,r.jsx)(o,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+n.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let g=e.flatMap((x,f)=>{let m=x.children??[];return!O.current.has(f)&&m.length>0&&(O.current.add(f),c((0,r.jsx)(o,{color:i.purple,children:" Flow "+(f+1)+": "+(n?.[f]??"")})),l?.[f]!=null&&l[f]>0&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})})))),l?.[f]!=null&&l[f]>0&&O.current.has(f)&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})}))),m});for(let x of g){let f=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){d.current.has(f)||(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...x,children:void 0}})})));for(let $ of x.children??[]){let w=`child-${x.childId??"p"}-${x.index}-${$.childId??"p"}-${$.index}-${$.objective}`;d.current.has(w)||($.status==="passed"||$.status==="failed"||$.status==="stopped")&&(d.current.add(w),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:$})})))}continue}d.current.has(f)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:x})})))}}else for(let g of e){let x=`${g.index}-${g.objective}`,f=!!g.branchObjective;f&&!d.current.has(x)&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})));for(let m of g.children??[]){let $=`child-${g.index}-${m.childId??"p"}-${m.index}-${m.objective}`;d.current.has($)||(m.status==="passed"||m.status==="failed"||m.status==="stopped")&&(d.current.add($),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:m})})))}!f&&!d.current.has(x)&&(g.status==="passed"||g.status==="failed"||g.status==="stopped")&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})))}d.current.size>p&&xe(g=>g+1)},[e,c,t,n,l]);let G=[];if(u&&!t)for(let p of e)ae.current.has(p.index)||G.push(p);else if(c&&!u)if(t)for(let p of e){let g=p.children??[],x=[];for(let f of g){let m=`${f.childId??"p"}-${f.index}-${f.objective}`,$=d.current.has(m);if(f.branchObjective){let w=(f.children??[]).filter(Q=>{let ue=`child-${f.childId??"p"}-${f.index}-${Q.childId??"p"}-${Q.index}-${Q.objective}`;return!d.current.has(ue)});(!$||w.length>0)&&x.push({...f,children:w})}else $||x.push(f)}x.length>0&&G.push({...p,children:x})}else for(let p of e){let g=`${p.index}-${p.objective}`,x=d.current.has(g),f=(p.children??[]).filter(m=>{let $=`child-${p.index}-${m.childId??"p"}-${m.index}-${m.objective}`;return!d.current.has($)});x?f.length>0&&G.push({...p,children:f}):G.push({...p,children:f})}if(!u){let p=c?G:e,g=le(p),x=ge(g,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[t?c?p.length>0?(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((m,$)=>(0,r.jsx)(s,{flexDirection:"column",marginTop:$>0?1:0,children:m.children&&m.children.length>0?m.children.map(w=>{if(z(w))return null;let Q=!!w.branchObjective,ue=`${w.childId??"p"}-${w.index}-${w.objective}`,Ke=d.current.has(ue);return Q?(0,r.jsxs)(s,{flexDirection:"column",children:[!Ke&&(0,r.jsx)(P,{step:{...w,children:void 0}}),(w.children??[]).filter(Z=>!z(Z)).map(Z=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:Z})},`f${$}-${w.index}-${Z.childId??"p"}-${Z.index}`))]},`f${$}-host-${w.childId??"p"}-${w.index}`):(0,r.jsx)(P,{step:w},`f${$}-${w.childId??"p"}-${w.index}`)}):m.status==="pending"&&(0,r.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})},$))}):null:(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(m,$)=>z(m)?null:(0,r.jsx)(P,{step:m},$)}):(0,r.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!c&&l&&l[0]!=null&&(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",l[0]," checkpoints"]}),p.filter(m=>!(m.status==="running"&&(!m.children||m.children.length===0))).map(m=>{let $=`${m.index}-${m.objective}`;return c&&d.current.has($)?(0,r.jsx)(s,{flexDirection:"column",children:(m.children??[]).filter(w=>!z(w)).map(w=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:w})},`${w.childId??"p"}-${w.index}`))},`branch-children-${m.index}`):(0,r.jsx)(P,{step:m},m.index)})]}),(0,r.jsx)(se,{activity:x,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}if(t){let p=le(e),g=ge(p,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(x,f)=>z(x)?null:(0,r.jsx)(P,{step:x},f)}),(0,r.jsx)(se,{activity:g,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}let Ne=le(G),Ge=ge(Ne,T),Re=Fe(G);return(0,r.jsxs)(s,{flexDirection:"column",children:[Re.length>0&&(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Re.map(p=>(0,r.jsx)(P,{step:p},p.index))}),(0,r.jsx)(se,{activity:Ge,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}var W=R(k(),1);function Ae({runner:e,runKey:t,onStepCommit:n}){let l=Ie({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,W.jsxs)(W.Fragment,{children:[l&&(0,W.jsx)(ke,{label:l.label,hasBifurcation:l.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,W.jsx)(_e,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:n},`run-${t}`)]})}var D=R(k(),1),Ye=64;function Je(e){return e.split(`
|
|
4
4
|
`).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function qe({status:e,summary:t,duration:n,steps:l,stepsPassed:a,stepsFailed:u,reason:c,creditsConsumed:v}){let S=e==="passed",T=S?i.green:i.red,d=S?"\u2713":"\u2717",L=e.toUpperCase(),O=a??(S?l:Math.max(0,l-1)),y=u??(S?0:1),h=y>0?`${l} steps (${O} passed, ${y} failed)`:`${l} steps`,b=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`,B=Je(t);return(0,D.jsx)(s,{flexDirection:"column",marginTop:1,children:(0,D.jsxs)(s,{borderStyle:"round",borderColor:T,flexDirection:"column",paddingX:2,paddingY:1,width:Ye+6,children:[(0,D.jsxs)(s,{flexDirection:"column",children:[(0,D.jsxs)(o,{bold:!0,color:T,children:[d," ",L]}),(0,D.jsxs)(o,{color:i.dim,wrap:"wrap",children:[h," \xB7 ",b,typeof v=="number"&&v>0?` \xB7 ${parseFloat(v.toFixed(4))} credits`:""]})]}),B.length>0&&(0,D.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:B.map((F,M)=>(0,D.jsxs)(s,{marginBottom:M<B.length-1?1:0,children:[(0,D.jsx)(o,{color:i.orange,children:"\u25CF "}),(0,D.jsx)(s,{flexShrink:1,children:(0,D.jsx)(o,{wrap:"wrap",children:F})})]},M))}),c&&!S&&(0,D.jsx)(s,{marginTop:1,children:(0,D.jsxs)(o,{color:i.red,wrap:"wrap",children:["Reason: ",c]})})]})})}var j=R(k(),1);function Me({message:e,code:t,remediation:n,docsUrl:l}){return(0,j.jsx)(ve,{title:"Error",variant:"error",children:(0,j.jsxs)(s,{flexDirection:"column",paddingY:1,children:[(0,j.jsxs)(o,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,j.jsxs)(s,{marginTop:0,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Code: "}),(0,j.jsx)(o,{color:i.dim,children:t})]}),n&&(0,j.jsxs)(s,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.green,bold:!0,children:"Fix:"}),(0,j.jsxs)(o,{color:i.orange,children:["$ ",n]})]}),l&&(0,j.jsxs)(s,{marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Docs: "}),(0,j.jsx)(o,{color:i.orange,underline:!0,children:l})]})]})})}var E=R(k(),1);function un(e){let{exit:t}=Te(),{append:n}=ye(),l=(0,A.useRef)(!1);(0,A.useEffect)(()=>{l.current||(l.current=!0,n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsxs)(s,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,E.jsx)(o,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.orange,children:e.topBanner.model}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.dim,children:e.topBanner.auth})]})})),n((0,E.jsx)(Qe,{data:e.globalConfig})),e.priorAttemptRollup&&n((0,E.jsx)(o,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let a=(0,A.useRef)(null),u=(0,A.useCallback)(async y=>{let h=await e.getNextStep(y);return h?(a.current=h,h.config):(a.current=null,null)},[e]),c=(0,A.useCallback)((y,h)=>{let b=a.current;if(!b)return;let B=b.mode==="replay"?"cyan":"#dc4e08",F=b.modeReason?` (${b.modeReason})`:"",M=b.perStepOverrides?Object.entries(b.perStepOverrides):[];n((0,E.jsxs)(s,{flexDirection:"column",marginBottom:0,children:[(0,E.jsxs)(o,{children:[(0,E.jsxs)(o,{color:i.dim,children:[b.banner.stepLabel," "]}),(0,E.jsxs)(o,{color:B,children:["[",b.mode,"]"]}),(0,E.jsx)(o,{color:i.dim,children:F})]}),(0,E.jsx)(o,{color:i.dim,children:b.banner.objective}),M.length>0&&(0,E.jsxs)(o,{color:i.dim,children:["overrides: ",M.map(([X,Y])=>`${X}=${Y}`).join(", ")]})]}))},[n]),v=(0,A.useRef)(0),S=(0,A.useRef)(!1),T=(0,A.useCallback)((y,h)=>(y.hadError?n((0,E.jsx)(Me,{message:y.reason??"Runner error",code:"RUNNER_ERROR"})):n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsx)(qe,{status:y.status,summary:y.runEnd?.summary??"",duration:y.runEnd?.duration??0,steps:y.stepsTotal,stepsPassed:y.stepsPassed,stepsFailed:y.stepsFailed,reason:y.runEnd?.reason,creditsConsumed:y.runEnd?.credits_consumed})})),e.onStepEnd?.(y,h)??!0),[n,e]),d=we({getNextConfig:u,onStepStart:c,onStepEnd:T,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),L=250,O=5e3;return Se((y,h)=>{if(h.ctrl&&y==="c"){let b=Date.now(),B=b-v.current;if(B<L)return;S.current&&B<O?(d.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>t())):(S.current=!0,n((0,E.jsx)(o,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),v.current=b}}),(0,E.jsx)(s,{flexDirection:"column",children:d.phase!=="done"&&(0,E.jsx)(Ae,{runner:d.runner,runKey:d.currentStepIndex,onStepCommit:n})})}function Qe({data:e}){return(0,E.jsx)(Be,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{_e as a,ke as b,Ie as c,de as d,qe as e,Me as f,un as g};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as K,d as W}from"./chunk-RE3BZVGE.js";import{d as D}from"./chunk-JFAFKHDX.js";import{a as G}from"./chunk-YKTYVJBN.js";import{d as X}from"./chunk-2PQXEEVY.js";import{a as Q}from"./chunk-MCQXRJGH.js";import{a as H}from"./chunk-ZZLR3O5A.js";import{g as z}from"./chunk-ZG2V2ODK.js";import{d as U,f as j}from"./chunk-5YPBPZUR.js";import{a as P,c as B}from"./chunk-
|
|
2
|
+
import{b as K,d as W}from"./chunk-RE3BZVGE.js";import{d as D}from"./chunk-JFAFKHDX.js";import{a as G}from"./chunk-YKTYVJBN.js";import{d as X}from"./chunk-2PQXEEVY.js";import{a as Q}from"./chunk-MCQXRJGH.js";import{a as H}from"./chunk-ZZLR3O5A.js";import{g as z}from"./chunk-ZG2V2ODK.js";import{d as U,f as j}from"./chunk-5YPBPZUR.js";import{a as P,c as B}from"./chunk-6SGPN76K.js";function lt(t){let e=process.env.HOME??"";return e&&t.startsWith(e)?`~${t.slice(e.length)}`:t}import{readFileSync as Se,writeFileSync as Ee,renameSync as $e,mkdirSync as Re}from"fs";import{dirname as Ce,join as Te}from"path";var O=1,Me=720*60*1e3;function F(t){return Te(B,"embeddings",`alias-${t}.json`)}function J(t,e=Date.now()){return t!==null&&e-t.fetchedAt<Me}function Y(t){try{let e=JSON.parse(Se(t,"utf-8"));return e.wrapperVersion!==O||typeof e.purposes!="object"||e.purposes===null?null:{wrapperVersion:O,writtenByVersion:String(e.writtenByVersion??""),purposes:e.purposes}}catch{return null}}function Z(t,e,n=F(t)){let r=Y(n)?.purposes?.[e];return!r||typeof r.alias!="string"||typeof r.dims!="number"||typeof r.fetchedAt!="number"?null:{alias:r.alias,dims:r.dims,fetchedAt:r.fetchedAt}}function q(t,e,n,s=F(t)){try{Re(Ce(s),{recursive:!0});let a=Y(s)?.purposes??{};a[e]={alias:n.alias,dims:n.dims,fetchedAt:Date.now()};let o={wrapperVersion:O,writtenByVersion:P,purposes:a},m=`${s}.tmp`;Ee(m,JSON.stringify(o,null,2)+`
|
|
3
3
|
`),$e(m,s)}catch(r){process.stderr.write(`[embed] Failed to save alias cache: ${r instanceof Error?r.message:String(r)}
|
|
4
4
|
`)}}function De(t){return t.TESTMUAI_ENV==="stage"?"stage":"prod"}function ee(t){let e=t.env??process.env,n=t.auth?.TESTMUAI_BASIC_AUTH||e.TESTMUAI_BASIC_AUTH;if(n)return{authorization:`Basic ${n}`};let s=t.auth?.TESTMUAI_API_KEY||e.TESTMUAI_API_KEY;return s?{authorization:`Bearer ${s}`}:{}}async function te(t,e={}){let n=e.env??process.env,s=De(n),r=e.aliasCacheFile??F(s),a=e.now??Date.now,o=Z(s,t,r);if(J(o,a()))return{alias:o.alias,dims:o.dims};let d=`${G(n)}/assurance/embed/alias?purpose=${encodeURIComponent(t)}`,f=await(e.fetchImpl??fetch)(d,{method:"GET",headers:ee(e)});if(!f.ok)throw new Error(`embed alias resolve failed: ${f.status}`);let c=await f.json();return q(s,t,{alias:c.alias,dims:c.dims},r),{alias:c.alias,dims:c.dims}}async function ne(t,e,n={}){let s=n.env??process.env,r=G(s),a=await(n.fetchImpl??fetch)(`${r}/assurance/embed`,{method:"POST",headers:{...ee(n),"content-type":"application/json"},body:JSON.stringify({purpose:t,input:e})});if(!a.ok)throw new Error(`embed failed: ${a.status}`);return await a.json()}import{randomBytes as nt}from"crypto";function re(t,e){let n=Math.min(t.length,e.length),s=0,r=0,a=0;for(let o=0;o<n;o++)s+=t[o]*e[o],r+=t[o]*t[o],a+=e[o]*e[o];return r===0||a===0?0:s/(Math.sqrt(r)*Math.sqrt(a))}function se(t,e,n){return n*t+(1-n)*e}var ie=.7;import{readFileSync as Fe,writeFileSync as Ne,renameSync as Le,mkdirSync as Ge}from"fs";import{dirname as Oe,join as oe}from"path";function Ve(t){return oe(t,"embeddings")}function Ie(t){let e=t.indexOf(":");return e>=0?t.slice(e+1):t}function ae(t,e,n){let s=Ie(n);return oe(Ve(t),e,s.slice(0,2),`${s.slice(2)}.f32`)}function ce(t,e,n){try{let s=Fe(ae(t,e,n)),r=new Float32Array(Math.floor(s.length/4));for(let a=0;a<r.length;a++)r[a]=s.readFloatLE(a*4);return r}catch{return null}}function le(t,e,n,s){try{let r=ae(t,e,n);Ge(Oe(r),{recursive:!0});let a=Buffer.alloc(s.length*4);for(let m=0;m<s.length;m++)a.writeFloatLE(s[m],m*4);let o=`${r}.tmp`;Ne(o,a),Le(o,r)}catch(r){process.stderr.write(`[embed] Failed to cache vector: ${r instanceof Error?r.message:String(r)}
|
|
5
5
|
`)}}var Pe=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar"],Be=["source_read","source_grep"],Ue=[...Pe,...Be],fe=50,V=200,pe=10,ge=50,ue=20,je=200,He=50;function N(t,e,n){let s=typeof t=="number"&&Number.isFinite(t)?Math.floor(t):e;return Math.max(1,Math.min(s,n))}function $(t,e){let n=t[e];if(typeof n!="string"||n.length===0)throw new w(`param "${e}" must be a non-empty string`);return n}function E(t,e){let n=t[e];if(n==null)return null;if(typeof n!="string")throw new w(`param "${e}" must be a string when present`);return n}var w=class extends Error{};function I(t,e){let n=t.getNode(e);return n?{cid:e,label:n.label,content:n.content,trust:t.trust.get(e)??null,freshness:t.stale(e)}:null}function de(t){return new Set(t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function he(t,...e){let n=de(t);if(n.size===0)return 0;let s=t.trim().toLowerCase(),r=0;for(let a of e){let o=de(a);if(o.size===0)continue;let m=0;for(let c of n)o.has(c)&&m++;let d=n.size+o.size-m,f=d===0?0:m/d;s&&a.toLowerCase().includes(s)&&(f=Math.max(f,.9)),r=Math.max(r,f)}return r}function ze(t,e){let n=$(e,"cid"),s=E(e,"type"),r=E(e,"direction")??"both";if(!["out","in","both"].includes(r))throw new w('param "direction" must be out|in|both');let a=N(e.limit,fe,V),o=[];return(r==="out"||r==="both")&&o.push(...t.edgesFrom(n)),(r==="in"||r==="both")&&o.push(...t.edgesInto(n)),o.filter(m=>s==null||m.type===s).slice(0,a)}function Qe(t,e){let n=$(e,"source_id"),s=t.heads.get(n)??null,r=[];for(let a of t.nodeLabel.keys()){let o=t.derivesInto(a).filter(d=>d.props.source_id===n).map(d=>({source_cid:d.props.source_cid,anchor:d.props.anchor??null}));if(o.length===0)continue;let m=I(t,a);if(m&&(r.push({...m,pins:o,pinned_to_head:s!=null&&o.some(d=>d.source_cid===s)}),r.length>=V))break}return r}function Xe(t,e){let n=$(e,"label"),s=E(e,"trust"),r=E(e,"freshness"),a=N(e.limit,fe,V),o=[];for(let{cid:m}of t.byLabel(n)){let d=I(t,m);if(d&&!(s!=null&&d.trust!==s)&&!(r!=null&&d.freshness!==r)&&(o.push(d),o.length>=a))break}return o}function Ke(t){return t.staleList().map(({cid:e,state:n})=>{let s=t.getNode(e);return{cid:e,state:n,label:s?.label??null,title:s?.content.title??null}})}function We(t,e){let n=$(e,"text"),s=E(e,"label")??"usecase",r=N(e.k,pe,ge),a=[];for(let{cid:o,content:m}of t.byLabel(s)){let d=String(m.title??""),f=String(m.summary??""),c=he(n,d,f);c<=0||a.push({cid:o,title:d,summary:f,score:Math.round(c*1e3)/1e3,trust:t.trust.get(o)??null,freshness:t.stale(o)})}return a.sort((o,m)=>m.score-o.score||o.cid.localeCompare(m.cid)),a.slice(0,r)}function _e(t,e,n){let s=t.heads.get(n);if(typeof s!="string"){let o=[...t.heads.keys()].sort().join(", ");throw new w(`unknown source_id "${n}" \u2014 known: ${o||"(none)"}`)}if(t.mediaOf(s).format==="image")throw new w(`source "${n}" is an image \u2014 no line window (cite img#whole)`);let r=t.getNode(s)?.content?.blob,a=typeof r=="string"?X(e,r):null;if(a==null)throw new w(`source "${n}" blob is missing from the store`);return{head:s,lines:a.toString("utf8").replace(/\n$/,"").split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{existsSync as l}from"fs";import{dirname as f,resolve as i}from"path";import{fileURLToPath as d}from"url";var g=f(d(import.meta.url));function p(){return[i(g,".."),i(g,"../../..")]}function A(o){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[o]??null}function h(){let o=A(`${process.platform}-${process.arch}`),n=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let r of p()){for(let s of o?["@testmuai","@lambdatestincprivate"]:[]){let e=i(r,"node_modules",s,o,"bin",n);if(l(e))return{cmd:e,args:[]}}let a=i(r,"../assurance-agent/dist",n);if(l(a))return{cmd:a,args:[]};let t=i(r,"../assurance-agent/main.py");if(l(t)){let s=i(r,"../assurance-agent/.venv/bin/python");return{cmd:l(s)?s:"python3",args:[t]}}}return null}function w(o,n={}){return{...process.env,...n,TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:o,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function x(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:o}=await import("./credentials-
|
|
2
|
+
import{existsSync as l}from"fs";import{dirname as f,resolve as i}from"path";import{fileURLToPath as d}from"url";var g=f(d(import.meta.url));function p(){return[i(g,".."),i(g,"../../..")]}function A(o){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[o]??null}function h(){let o=A(`${process.platform}-${process.arch}`),n=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let r of p()){for(let s of o?["@testmuai","@lambdatestincprivate"]:[]){let e=i(r,"node_modules",s,o,"bin",n);if(l(e))return{cmd:e,args:[]}}let a=i(r,"../assurance-agent/dist",n);if(l(a))return{cmd:a,args:[]};let t=i(r,"../assurance-agent/main.py");if(l(t)){let s=i(r,"../assurance-agent/.venv/bin/python");return{cmd:l(s)?s:"python3",args:[t]}}}return null}function w(o,n={}){return{...process.env,...n,TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:o,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function x(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:o}=await import("./credentials-BJCIWQWA.js"),n=process.env.TESTMUAI_ENV==="stage"?"stage":"prod",r=new o,a=r.getActiveProfile()??"default",t={TESTMUAI_ENV:n},s=r.loadBasicAuth(a,n);if(s)return t.TESTMUAI_BASIC_AUTH=Buffer.from(`${s.username}:${s.access_key}`,"utf8").toString("base64"),t;let e=r.loadCredentials(a,n);if(e){try{let{refreshOAuthToken:u}=await import("./token-refresh-CFVOA62N.js");await u({creds:r,profile:a,env:n,credentials:e})}catch{}let c=r.loadCredentials(a,n)??e;if(typeof c.access_token=="string"){let u=await E(n,c.access_token);return u?(t.TESTMUAI_BASIC_AUTH=u,t):(t.TESTMUAI_API_KEY=c.access_token,t)}}return{}}catch{return{}}}var _=8e3;function m(){return process.stderr.write("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry\n"),null}async function E(o,n){if(process.env.TESTMUAI_BASE_URL)return null;try{let[{getEnvironment:r},{ControllerClient:a}]=await Promise.all([import("./config-6PAZZ7CR.js"),import("./controller-client-RD2YEMAH.js")]),t=new a(r(o).controllerBaseUrl,n),s;try{let e=await Promise.race([t.getTmsCredentials().catch(()=>null),new Promise(c=>{s=setTimeout(()=>c(null),_)})]);return typeof e?.username!="string"||!e.username||typeof e.access_key!="string"||!e.access_key?m():Buffer.from(`${e.username}:${e.access_key}`,"utf8").toString("base64")}finally{clearTimeout(s)}}catch{return m()}}export{A as a,h as b,w as c,x as d};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as k}from"./chunk-FPFOW6BS.js";import{h as a}from"./chunk-M5JQXOCE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-
|
|
2
|
+
import{a as k}from"./chunk-FPFOW6BS.js";import{h as a}from"./chunk-M5JQXOCE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-AKHUNBQS.js";import{a as h}from"./chunk-P4HW2NTZ.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
|
|
3
3
|
`)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
|
|
4
|
-
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-
|
|
4
|
+
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-CFVOA62N.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
|
|
5
5
|
`,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
|
|
6
6
|
`,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
|
|
7
7
|
`,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-4SXD6XWV.js";import{n as d,y as o}from"./chunk-6SGPN76K.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as h}from"./chunk-
|
|
2
|
+
import{a as h}from"./chunk-4SXD6XWV.js";import{y as l}from"./chunk-6SGPN76K.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-
|
|
2
|
+
import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-6NIV7AVZ.js";import{y as s}from"./chunk-6SGPN76K.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as c,c as p}from"./chunk-
|
|
2
|
+
import{b as c,c as p}from"./chunk-KYHXDJN4.js";import{spawn as m}from"child_process";var y=new Set(["progress","ask_user","graph_query","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete"]);function S(d,s={}){let a=s.spawnCmd!==void 0?s.spawnCmd:c();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let n=m(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(d.session_id,s.auth)});if(n.stdin.write(JSON.stringify(d)+`
|
|
3
3
|
`),s.onStderr){let e="";n.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
|
|
4
4
|
`))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&s.onStderr(o)}})}let g=new Promise(e=>{n.on("exit",(r,i)=>e({code:r,signal:i}))});async function*f(){let e="",r=!1;for await(let i of n.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
|
|
5
5
|
`))>=0;){let l=e.slice(0,o).trim();if(e=e.slice(o+1),!l)continue;let u;try{u=JSON.parse(l)}catch{s.onWarn?.(`agent: skipping malformed line: ${l.slice(0,120)}`);continue}let t=u;if(!t||typeof t!="object"||!y.has(t.type)){s.onWarn?.(`agent: skipping unknown event type "${t&&typeof t=="object"?String(t.type??"?"):"?"}"`);continue}if(yield t,t.type==="done"){r=!0;break}}if(r)break}await g.catch(()=>{})}return{events:f(),send:e=>{n.stdin&&!n.stdin.destroyed&&n.stdin.write(JSON.stringify(e)+`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-C42WWO7Y.js";import{c as k}from"./chunk-RFHMDQXZ.js";import{a as C}from"./chunk-P4HW2NTZ.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-6SGPN76K.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
|
|
3
3
|
Please open this URL manually: ${e}
|
|
4
4
|
`)})})}};function v(s){let r=s.state==="success",o=r?"#22c55e":"#ef4444",e=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",t=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=s.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
|
|
5
5
|
<html lang="en">
|
|
@@ -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-4SXD6XWV.js";import{y as r}from"./chunk-6SGPN76K.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as i,i as X}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var u=P(G(),1);var e=P(Y(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:F,error:L=null,itemNoun:T="items",onSelect:H,onCancel:E,defaultActiveId:w,onTab:y,extraHint:N}=t,[x,d]=(0,u.useState)(0),[S,g]=(0,u.useState)(0),[s,A]=(0,u.useState)(""),[C,h]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let n=c.findIndex(o=>o.id===C);if(n>=0){g(Math.floor(n/f)),d(n%f);return}}let l=w?c.findIndex(n=>n.id===w):c.findIndex(n=>n.isActive);l>=0?(g(Math.floor(l/f)),d(l%f),t.preserveSelectionById&&h(c[l].id)):t.preserveSelectionById&&(g(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let l=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(l)},[s,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?c:K(c,s),M=S*f,p=Math.min(M+f,m.length),D=Math.ceil(m.length/f),O=p-M,v=m.slice(M,p);return X((l,n)=>{if(L){n.escape&&E();return}if(n.escape){s?(A(""),d(0),g(0)):E();return}if(n.tab&&y){y();return}if(n.upArrow){if(x>0){let o=x-1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S>0){let o=S-1,b=f-1;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.downArrow){if(x<O-1){let o=x+1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S<D-1){let o=S+1,b=0;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.return&&v[x]){H(v[x]);return}if(n.backspace||n.delete){A(o=>o.slice(0,-1)),d(0),g(0);return}l&&!n.ctrl&&!n.meta&&(A(o=>o+l),d(0),g(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.secondary,children:F??`Loading ${T}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsxs)(i,{color:r.dim,children:[" (",m.length,!t.onSearch&&s?`/${c.length}`:""," ",T,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(i,{color:r.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{children:s}),(0,e.jsx)(i,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(i,{color:r.dim,children:["Search ",T,"\u2026"]}),(0,e.jsx)(i,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(i,{color:r.secondary,children:["Searching ",T,"\u2026"]}):m.length===0?(0,e.jsxs)(i,{color:r.dim,children:["No ",T,' match "',s,'"']}):v.map((l,n)=>{let o=n===x,b=o?"\u276F ":" ",$=l.isActive?r.green:o?r.orange:void 0;return(0,e.jsxs)(i,{color:$,children:[b,l.label,l.isActive?" \u25CF selected":""]},l.id)})}),!t.searching&&D>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(i,{color:r.dim,children:["Page ",S+1,"/",D]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&N?[{keys:"tab",label:N}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
|
|
@@ -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-
|
|
2
|
+
import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-MY32TBBR.js";import{a as k}from"./chunk-2WVKOZ6W.js";import{a as B}from"./chunk-AKHUNBQS.js";import{a as R}from"./chunk-4SXD6XWV.js";import{y as c}from"./chunk-6SGPN76K.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 b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-3Z3UIW5H.js";import{y as l}from"./chunk-6SGPN76K.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";var u=p(f(),1),T=5;function _({thinking:t,expanded:e,thinkingDone:o,maxLines:i=T}){if(!e)return(0,u.jsxs)(m,{paddingX:1,children:[(0,u.jsx)(s,{color:l.dim,children:o?"\u2237 thinking complete ":"\u2237 thinking\u2026 "}),(0,u.jsx)(s,{color:l.muted,children:o?"(ctrl+t to view)":"(ctrl+t to show)"})]});let g=t.split(`
|
|
3
3
|
`),n=Math.max(0,g.length-i),a=n>0?g.slice(-i).join(`
|
|
4
4
|
`):t;return(0,u.jsxs)(b,{variant:"default",paddingX:1,children:[n>0&&(0,u.jsxs)(s,{color:l.muted,children:["\u22EE (",n," earlier line",n===1?"":"s"," hidden)"]}),(0,u.jsx)(s,{color:l.dim,children:a}),o&&(0,u.jsx)(s,{color:l.muted,children:"\u2014 thinking complete"})]})}function k(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
|
|
5
5
|
`),e}var c=p(f(),1),B=t=>t!==void 0&&/[A-Za-z0-9]/.test(t);function x(t){let e=[],o="",i=()=>{o&&(e.push({text:o}),o="")},g=(a,d,r)=>(a===0||!B(t[a-1]))&&(d+r>=t.length||!B(t[d+r])),n=0;for(;n<t.length;){let a=t.slice(n,n+2),d=t[n];if(a==="**"||a==="__"){let r=t.indexOf(a,n+2);if(r!==-1&&r>n+2&&(a==="**"||g(n,r,2))){i(),e.push({text:t.slice(n+2,r),bold:!0}),n=r+2;continue}}if(d==="`"){let r=t.indexOf("`",n+1);if(r!==-1&&r>n+1){i(),e.push({text:t.slice(n+1,r),code:!0}),n=r+1;continue}}if(d==="*"||d==="_"){let r=t.indexOf(d,n+1);if(r!==-1&&r>n+1&&(d==="*"||g(n,r,1))){i(),e.push({text:t.slice(n+1,r),italic:!0}),n=r+1;continue}}o+=d,n+=1}return i(),e.length===0&&e.push({text:""}),e}function h(t){return t.map((e,o)=>(0,c.jsx)(s,{bold:e.bold,italic:e.italic,color:e.code?l.dim:void 0,children:e.text},o))}function S(t){return t.split(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as g}from"./chunk-
|
|
2
|
+
import{c as g}from"./chunk-6SGPN76K.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{a as z,b as ee,c as te}from"./chunk-
|
|
2
|
+
import{a as z,b as ee,c as te}from"./chunk-JF7Q2I45.js";import{c as K,d as V}from"./chunk-6CZIEK6B.js";import{c as J}from"./chunk-6XHAXAL2.js";import{a as Q}from"./chunk-VBCE4U4B.js";import{a as Z}from"./chunk-FPFOW6BS.js";import{b as H}from"./chunk-HWA7WD44.js";import{b as W}from"./chunk-N6DO2LBH.js";import{h as E}from"./chunk-M5JQXOCE.js";import{a as O}from"./chunk-2WVKOZ6W.js";import{a as _}from"./chunk-AKHUNBQS.js";import{a as k,b as A,d as Y}from"./chunk-VE3SUJMA.js";import{a as q}from"./chunk-P4HW2NTZ.js";import{a as G}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as I,j as X}from"./chunk-C44QQJR4.js";import{a as ue}from"./chunk-6YGTRKDT.js";import{e as F}from"./chunk-UR6MHSHU.js";var i=F(ue(),1);var r=F(G(),1);function _e({resultRef:h,mode:d="singleshot",loginCompleteRef:f}){let{exit:m}=X(),C=(0,i.useRef)(new q),S=(0,i.useRef)(new Q),v=(0,i.useRef)(new J),t=C.current,l=S.current,$=v.current,ne=K(),[P,g]=(0,i.useState)(d==="login"?"login":"gate"),[L,re]=(0,i.useState)(null),[de,R]=(0,i.useState)(null),[ge,T]=(0,i.useState)(null),[N,oe]=(0,i.useState)(null),[U,B]=(0,i.useState)([]),x=(0,i.useCallback)((e,n,s,o)=>$.log(e,n,s,o),[$]),pe=(0,i.useCallback)((e,n)=>{e?k(t,l,e,n):l.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[t,l]),y=(0,i.useCallback)(()=>{d==="login"?(f&&(f.current=!0),m()):g("input")},[d,m,f]),D=(0,i.useCallback)((e,n)=>{let s=k(t,l,e,n);if(d==="login"){g("ensure-project");return}Y(s)?y():s.projectId?g("ensure-folder"):g("ensure-project")},[t,l,y,d]);I((e,n)=>{n.ctrl&&e==="c"&&E(0,"Ctrl+C exit")});let M=(0,i.useRef)(!1);i.default.useEffect(()=>{M.current||(M.current=!0,d!=="login"&&te(t,x).then(e=>{re(e),e.status==="authenticated"?D(e.result.profile,e.result.env):e.status==="needs_pick"?g("pick"):(R(e.profile??null),T(e.env??null),g("login"))}).catch(e=>{oe(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[t,x]);let ie=(0,i.useCallback)(e=>{h.current={objective:e},m()},[h,m]),se=(0,i.useCallback)(async(e,n)=>{t.setActiveProfile(e),t.setDefaultEnv(n),(await ee(t,e,n,x)).status==="authenticated"?D(e,n):(R(e),T(n),g("login"))},[t,x,D]),w=(0,i.useCallback)(()=>{let e=t.getActiveProfile(),n=t.getDefaultEnv();if(!e)return null;let s=_(n),o=t.loadBasicAuth(e,n);return new Z(s.controllerBaseUrl,async()=>t.loadCredentials(e,n)?.access_token??null,o,x)},[t,x]),le=(0,i.useCallback)(async()=>{let e=w();if(!e)return null;let n=e.cached??await e.resolve();if(!n)return null;let s=_(t.getDefaultEnv()),o=new O(s.tmsBaseUrl,n.username,n.access_key);try{let p=(await o.listProjects()).find(b=>b.name==="KaneAI Generated");if(p)return{id:p.project_id,name:p.name};let j=await o.createProject("KaneAI Generated");return{id:j.id,name:j.name}}catch{return null}},[w,t]),ae=(0,i.useCallback)(async e=>{let n=w();if(!n)return null;let s=n.cached??await n.resolve();if(!s)return null;let o=_(t.getDefaultEnv()),a=new O(o.tmsBaseUrl,s.username,s.access_key);try{let j=(await a.listFolders(e)).find(ce=>ce.name==="Untitled");if(j)return{id:j.id,name:j.name};let b=await a.createFolder(e,"Untitled");return{id:b.id,name:b.name}}catch{return null}},[w,t]);if(P==="gate")return(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(N)return(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"red",children:N}),(0,r.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(P==="pick"&&L?.status==="needs_pick")return(0,r.jsx)(fe,{profiles:L.profiles,onSelect:se});if(P==="login")return(0,r.jsx)(z,{devMode:process.env.KANE_DEV_MODE==="1",profiles:t.listProfiles(),onBasicLogin:async(e,n,s,o)=>{let{validateBasicAuth:a}=await import("./validate-basic-4OLDKIA2.js");await a(n,s,o),t.saveBasicAuth(e,n,{username:s,access_key:o}),t.setActiveProfile(e),t.setDefaultEnv(n)},onOAuthLogin:async(e,n)=>{let{LoginFlow:s}=await import("./login-flow-HRS6YACY.js");t.setDefaultEnv(n),t.setActiveProfile(e),await new s(e,n,t).login()},onComplete:(e,n)=>{R(e),T(n),t.setActiveProfile(e),t.setDefaultEnv(n),D(e,n)},onCancel:()=>{E(0,"Login cancelled")}});if(P==="ensure-project"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=()=>{if(d==="login"){g("ensure-folder");return}k(t,l,e,n).folderId?y():g("ensure-folder")};return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(H,{resolver:w(),currentProjectId:l.load().project_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{projectId:o,projectName:a}),B(p=>[...p,`\u2713 Project: ${a} (${o})`]),s()},onCancel:async()=>{let o=await le();o&&(A(t,l,e,n,{projectId:o.id,projectName:o.name}),B(a=>[...a,`\u2713 Default project: ${o.name} (${o.id})`]),s())}})]})}if(P==="ensure-folder"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=t.loadProfileConfig(e,n);return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(W,{resolver:w(),projectId:s?.project_id??"",currentFolderId:l.load().folder_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{folderId:o,folderName:a}),B(p=>[...p,`\u2713 Folder: ${a} (${o})`]),y()},onCancel:async()=>{if(!s?.project_id)return;let o=await ae(s.project_id);o&&(A(t,l,e,n,{folderId:o.id,folderName:o.name}),B(a=>[...a,`\u2713 Default folder: ${o.name} (${o.id})`]),y())}})]})}return P==="input"?(0,r.jsxs)(c,{flexDirection:"column",children:[U.length>0&&(0,r.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:U.map((e,n)=>(0,r.jsx)(u,{color:"green",children:e},n))}),(0,r.jsx)(V,{onSubmit:ie,onEscape:()=>E(0,"User pressed Escape"),history:ne,placeholder:"Type an objective..."})]}):(0,r.jsx)(r.Fragment,{})}function fe({profiles:h,onSelect:d}){let[f,m]=(0,i.useState)(0),[C,S]=(0,i.useState)(!1);return I((v,t)=>{if(!C){if(t.escape){E(0,"Profile picker cancelled");return}if(t.upArrow&&f>0&&m(l=>l-1),t.downArrow&&f<h.length-1&&m(l=>l+1),t.return){S(!0);let l=h[f];d(l.profile,l.env).catch(()=>S(!1))}}}),(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,r.jsx)(c,{marginTop:1,flexDirection:"column",children:h.map((v,t)=>(0,r.jsxs)(u,{children:[t===f?"\u276F ":" ",(0,r.jsx)(u,{color:t===f?"#ff9500":"white",bold:t===f,children:v.profile}),(0,r.jsxs)(u,{color:"gray",children:[" [",v.env,"]"]})]},`${v.profile}-${v.env}`))}),C&&(0,r.jsx)(c,{marginTop:1,children:(0,r.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{_e as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as S}from"./chunk-
|
|
2
|
+
import{a as S}from"./chunk-6NIV7AVZ.js";import{y as o}from"./chunk-6SGPN76K.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(r=>r.kind==="replay").length,l=e.decisions.filter(r=>r.kind==="author").length,p=e.outcomes.filter(r=>r.status==="passed").length,d=e.outcomes.filter(r=>r.status==="failed").length,f=e.outcomes.filter(r=>r.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let s=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${d} failed, ${f} skipped)`,T=`${t} replay \xB7 ${l} author`,C=e.retryTriggered,_="yes \u2014 run recovered after a replay miss",u,h=o.dim;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",h=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let r=e.uploadResult?.testcaseId;u=r?`\u2713 pushed (testcase=${r})`:"\u2713 pushed",h=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:s},breakdown:T,showRetries:C,retriesText:_,commitText:u,commitColor:h,artifactsText:v,uploadText:m,uploadColor:g}}function O(e){let t=e.decisions.filter(s=>s.kind==="replay").length,l=e.decisions.filter(s=>s.kind==="author").length,p=e.outcomes.filter(s=>s.status==="passed").length,d=e.outcomes.filter(s=>s.status==="failed").length,f=e.outcomes.filter(s=>s.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:p,failed:d,skipped:f,replay_decisions:t,author_decisions:l},retries:{triggered:e.retryTriggered},commit:{committed:n,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),l=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&l.push({label:"retries",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),l.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),l.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),l.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:l})}function I({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let l=setTimeout(()=>t(),50);return()=>clearTimeout(l)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,O as b,D as c,I as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as m}from"./chunk-
|
|
2
|
+
import{a as m}from"./chunk-4SXD6XWV.js";import{y as t}from"./chunk-6SGPN76K.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as l}from"./chunk-
|
|
2
|
+
import{b as l}from"./chunk-JTEY32TL.js";import{a as p}from"./chunk-RZ4F3BHX.js";import{a as m}from"./chunk-AKHUNBQS.js";import{a as f}from"./chunk-P4HW2NTZ.js";import{a as c,c as s,i as a,x as u}from"./chunk-6SGPN76K.js";var v="/public/skills/kane-cli";function C(){try{let n=new f().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await p(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as s,
|
|
2
|
+
import{d as s,k as l}from"./chunk-6SGPN76K.js";import{readFileSync as g,writeFileSync as o,mkdirSync as i,existsSync as p}from"fs";import{dirname as a}from"path";var n={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:l,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0},c=class{constructor(r=s){this.path=r}exists(){return p(this.path)}load(){try{let r=g(this.path,"utf-8"),e=JSON.parse(r);return{...n,...e,code_export:{...n.code_export,...e.code_export??{}},generate:{...n.generate,...e.generate??{}}}}catch{return{...n,code_export:{...n.code_export},generate:{...n.generate}}}}set(r,e){try{let t=this.load();t[r]=e,i(a(this.path),{recursive:!0}),o(this.path,JSON.stringify(t,null,2)+`
|
|
3
3
|
`)}catch(t){let d=t instanceof Error?t.message:String(t);process.stderr.write(`[config] Failed to save config: ${d}
|
|
4
4
|
`)}}save(r){try{let t={...this.load(),...r};i(a(this.path),{recursive:!0}),o(this.path,JSON.stringify(t,null,2)+`
|
|
5
5
|
`)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`[config] Failed to save config: ${t}
|