@testmuai/kane-cli 0.8.5 → 0.8.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/dist/{ChatSurface-HAIVTS4J.js → ChatSurface-S2P7WMBI.js} +1 -1
- package/dist/{ChromeProfilePicker-5ILSVC2K.js → ChromeProfilePicker-7DTJK2QW.js} +1 -1
- package/dist/{CliFeedbackPrompt-LFKEYMKP.js → CliFeedbackPrompt-Y3OYZX54.js} +1 -1
- package/dist/{CliUploadProgress-Y7ITY2I7.js → CliUploadProgress-I3N5WDNJ.js} +1 -1
- package/dist/{ConfigView-OECNNCXC.js → ConfigView-EOYCKYJS.js} +1 -1
- package/dist/{EvidenceViewOffer-FODRAS6Z.js → EvidenceViewOffer-AQ3KB3EN.js} +1 -1
- package/dist/FolderPicker-RCHRYYC4.js +2 -0
- package/dist/{InfoBox-HWMHNWPM.js → InfoBox-QBXPPMM2.js} +1 -1
- package/dist/{LinksBox-TAGYCFFO.js → LinksBox-L24KON4U.js} +1 -1
- package/dist/{ProfilesView-QJBR3RCM.js → ProfilesView-H6XCTIXI.js} +1 -1
- package/dist/{ProjectPicker-PP75ILZU.js → ProjectPicker-F6JGF2B3.js} +1 -1
- package/dist/{SaveSessionPrompt-UCRET3II.js → SaveSessionPrompt-QGO65DZN.js} +1 -1
- package/dist/SingleShotApp-AY3XFEYT.js +2 -0
- package/dist/{SummaryBox-SLM3OFS2.js → SummaryBox-OZIZQY4B.js} +1 -1
- package/dist/TestMdRunView-RPW4MIJA.js +2 -0
- package/dist/{TestrunEvidenceTable-PTIBYAXO.js → TestrunEvidenceTable-A7WTTKTV.js} +1 -1
- package/dist/{WhoamiView-WPHMNYUV.js → WhoamiView-EB5AV27X.js} +1 -1
- package/dist/{app-download-GYQYLGT3.js → app-download-SQ4RDY3E.js} +1 -1
- package/dist/{auth-3DLNMZC2.js → auth-TW24FZQF.js} +1 -1
- package/dist/{binary-XJ3RF3VO.js → binary-5LMQJ3CZ.js} +1 -1
- package/dist/{bind-2N4Q6YKH.js → bind-SJ6DOVQ4.js} +2 -2
- package/dist/{bootstrap-5IHKW5SE.js → bootstrap-BTEXO6HX.js} +1 -1
- package/dist/bridge-GQJ35GTL.js +2 -0
- package/dist/{changelog-WCCTI47M.js → changelog-JLSLSA3Y.js} +1 -1
- package/dist/chunk-2DCNCH32.js +4 -0
- package/dist/{chunk-PEI2566X.js → chunk-2R7KL7YG.js} +1 -1
- package/dist/{chunk-T3XDMR5B.js → chunk-3LEVCW6R.js} +1 -1
- package/dist/{chunk-NLECZCMZ.js → chunk-3UUPP5W3.js} +1 -1
- package/dist/{chunk-PCOSE5SW.js → chunk-4NSP2NPT.js} +1 -1
- package/dist/{chunk-FTZPWXF7.js → chunk-4ONGF4NT.js} +1 -1
- package/dist/{chunk-ZFZ7YXEU.js → chunk-5COGCNED.js} +1 -1
- package/dist/{chunk-DCUT3GJA.js → chunk-7VZCXW74.js} +1 -1
- package/dist/{chunk-CGYSFLM2.js → chunk-A44G533S.js} +1 -1
- package/dist/{chunk-ZIRMSWKS.js → chunk-AO3PBE2V.js} +1 -1
- package/dist/{chunk-AJPLHW4T.js → chunk-ATWDQCDA.js} +1 -1
- package/dist/{chunk-UX3KPYTI.js → chunk-AWD56KGX.js} +1 -1
- package/dist/{chunk-YFLKS4UV.js → chunk-B4Q6FMIP.js} +3 -3
- package/dist/chunk-B5QGIUJA.js +26 -0
- package/dist/chunk-BN6AHQL7.js +17 -0
- package/dist/chunk-BRTARADN.js +4 -0
- package/dist/{chunk-BAL7E4OH.js → chunk-C4WTZSX4.js} +1 -1
- package/dist/{chunk-TCK3QMKY.js → chunk-CLLQQPBZ.js} +1 -1
- package/dist/{chunk-LA2EMSHE.js → chunk-CZUOGGUK.js} +1 -1
- package/dist/{chunk-FRSHEJUS.js → chunk-D4SRHIJ5.js} +1 -1
- package/dist/{chunk-Z2T7E5HM.js → chunk-DN3E6RT6.js} +2 -2
- package/dist/{chunk-PUFJEU46.js → chunk-DZCG7FFP.js} +1 -1
- package/dist/{chunk-CNNJ4U2L.js → chunk-E5S4BASB.js} +1 -1
- package/dist/{chunk-HQWLSA5M.js → chunk-ESC7AOCX.js} +1 -1
- package/dist/{chunk-W27F2NWA.js → chunk-EXERQHXV.js} +1 -1
- package/dist/{chunk-PWYEOBXV.js → chunk-FJYDEWOA.js} +1 -1
- package/dist/{chunk-35EUIBYJ.js → chunk-FMUCZWS3.js} +1 -1
- package/dist/{chunk-PB3GADUD.js → chunk-FUNKVREV.js} +1 -1
- package/dist/{chunk-GZ4X53ZA.js → chunk-FYS5VIOG.js} +2 -2
- package/dist/{chunk-HFCDUFV3.js → chunk-GC5U55MW.js} +1 -1
- package/dist/{chunk-RY6TFVAX.js → chunk-GELPKSLC.js} +1 -1
- package/dist/{chunk-5S46D5AJ.js → chunk-IGJIDN4U.js} +1 -1
- package/dist/{chunk-K2QV7FGP.js → chunk-INK66XQS.js} +1 -1
- package/dist/{chunk-EFRJNPBZ.js → chunk-IWM5EZC3.js} +2 -2
- package/dist/chunk-JCD6FP7A.js +5 -0
- package/dist/{chunk-M335FQYJ.js → chunk-JN44V63O.js} +2 -2
- package/dist/{chunk-GYF4CH62.js → chunk-KDXQNLVV.js} +2 -2
- package/dist/{chunk-O3AY6JHJ.js → chunk-KLTKEGDH.js} +1 -1
- package/dist/{chunk-MJ56GUKS.js → chunk-KQ2MYMOS.js} +1 -1
- package/dist/chunk-LN7233E2.js +20 -0
- package/dist/{chunk-KWKUMBHS.js → chunk-MKSTP2XN.js} +2 -2
- package/dist/{chunk-NHOHQBIF.js → chunk-NT3UETTV.js} +1 -1
- package/dist/{chunk-CCUGKBIH.js → chunk-OFW3ZVTP.js} +1 -1
- package/dist/{chunk-WLOGO44E.js → chunk-OYJBABRV.js} +1 -1
- package/dist/{chunk-JJWQUQJ2.js → chunk-P3RKXL3V.js} +1 -1
- package/dist/{chunk-MUGMUKSZ.js → chunk-PT7V5WDQ.js} +1 -1
- package/dist/chunk-Q4V2GK5U.js +2 -0
- package/dist/{chunk-3AJ3QSF5.js → chunk-QBG7XEGQ.js} +2 -2
- package/dist/{chunk-E3BXNQYE.js → chunk-QISE272H.js} +1 -1
- package/dist/{chunk-G4AFOZKU.js → chunk-QQAAPFIR.js} +1 -1
- package/dist/{chunk-PQUMOFT5.js → chunk-RDNKYRKY.js} +1 -1
- package/dist/{chunk-5NSYHRDN.js → chunk-RX5TZZNQ.js} +1 -1
- package/dist/{chunk-TJZMYU2W.js → chunk-RZLD7TPG.js} +1 -1
- package/dist/{chunk-66BSTNLD.js → chunk-S66MCU2Y.js} +1 -1
- package/dist/{chunk-WYST42WI.js → chunk-SORVX3KI.js} +1 -1
- package/dist/{chunk-KX2GOJ4C.js → chunk-SQC4P2Q7.js} +1 -1
- package/dist/{chunk-JRQKUQWL.js → chunk-SQGBFCFO.js} +1 -1
- package/dist/{chunk-T5LKD2OB.js → chunk-SS5TOK2J.js} +1 -1
- package/dist/{chunk-DJ7T7BMV.js → chunk-TDS6LG6T.js} +1 -1
- package/dist/{chunk-7JUUNZQP.js → chunk-TKYJTXWL.js} +1 -1
- package/dist/{chunk-JN2DP4R2.js → chunk-TQKIE7AX.js} +1 -1
- package/dist/{chunk-K7UYWAZH.js → chunk-TZFT7R7B.js} +1 -1
- package/dist/{chunk-AMULIFC5.js → chunk-USI2WMAK.js} +1 -1
- package/dist/{chunk-NYSMQ7UY.js → chunk-VMCSRLRC.js} +1 -1
- package/dist/{chunk-7PADFQ5S.js → chunk-VOBXYDJW.js} +2 -2
- package/dist/{chunk-R7OGNE3W.js → chunk-WMQJBEQP.js} +1 -1
- package/dist/{chunk-OWTEHU6B.js → chunk-XJILZ2WN.js} +1 -1
- package/dist/{chunk-2K2BX23I.js → chunk-XQFITNA3.js} +1 -1
- package/dist/{chunk-4D3DNCQY.js → chunk-XY325HDJ.js} +1 -1
- package/dist/{chunk-Q6JHBDW2.js → chunk-YEQVJWEF.js} +1 -1
- package/dist/{chunk-6BTZ2Q4P.js → chunk-YHTYPTDD.js} +1 -1
- package/dist/{chunk-2WSOPZJU.js → chunk-YZ45OEH3.js} +1 -1
- package/dist/{chunk-BJHII5SD.js → chunk-Z35BUPZT.js} +1 -1
- package/dist/{chunk-4UMQDH52.js → chunk-ZLSWHCWO.js} +1 -1
- package/dist/{chunk-FDWEL5HR.js → chunk-ZRKPZLLG.js} +1 -1
- package/dist/{config-OKTAPFOT.js → config-6TQIMTNB.js} +1 -1
- package/dist/{credentials-SO3DSQEM.js → credentials-ZSNM4BTD.js} +1 -1
- package/dist/{deps-bundle-FRM65BQO.js → deps-bundle-D2ZC2SPT.js} +1 -1
- package/dist/{deps-resolve-RPZORKUN.js → deps-resolve-VRBMFUTX.js} +1 -1
- package/dist/{dispatch-OZRMWY25.js → dispatch-2PBSJ7YW.js} +1 -1
- package/dist/doctor-OWRRDA4Z.js +2 -0
- package/dist/{evidence-5AUZMKE3.js → evidence-NDAKCCHQ.js} +1 -1
- package/dist/{evolve-cmd-TWYJL4EG.js → evolve-cmd-DIA5EWUT.js} +1 -1
- package/dist/{extract-bind-EW7XUDLQ.js → extract-bind-TJ2STXV5.js} +2 -2
- package/dist/{extract-cmd-HOVGMBGM.js → extract-cmd-FLOYO6HL.js} +1 -1
- package/dist/{generate-headless-FYTJULPG.js → generate-headless-DBT4MKQT.js} +2 -2
- package/dist/index.js +69 -69
- package/dist/{ingest-4447MYLF.js → ingest-JO5NJENZ.js} +1 -1
- package/dist/{ingest-cmd-RJLTFNMN.js → ingest-cmd-T6HM3AHK.js} +1 -1
- package/dist/install-NIVU4XVS.js +2 -0
- package/dist/{interactive-bind-PSEYAL54.js → interactive-bind-7UDJY4CF.js} +3 -3
- package/dist/{list-commands-2SVSEAP6.js → list-commands-DA4ZXOPJ.js} +1 -1
- package/dist/login-flow-NHBJVDW6.js +2 -0
- package/dist/{mobile-prompts-T6HZ2YLY.js → mobile-prompts-JS7GPVKS.js} +1 -1
- package/dist/{persist-recorded-session-O2NCYTSD.js → persist-recorded-session-LE3LGFOS.js} +1 -1
- package/dist/pipeline-MTAZDCZR.js +2 -0
- package/dist/prepare-target-YK2DLDWB.js +2 -0
- package/dist/{reconcile-cmd-FU3JIHTO.js → reconcile-cmd-CYRYVS5B.js} +1 -1
- package/dist/{reconcile-deps-SUKZA2FL.js → reconcile-deps-FYXRAMF2.js} +2 -2
- package/dist/{reconcile-engine-ILL4M3NW.js → reconcile-engine-6AT6EVGS.js} +1 -1
- package/dist/{recording-banner-5VXVKCV4.js → recording-banner-YMKWR3M3.js} +1 -1
- package/dist/{registry-BKV3EDTK.js → registry-V45ZQ6Q5.js} +1 -1
- package/dist/{require-project-folder-2IO6IX5W.js → require-project-folder-3KS7KTME.js} +1 -1
- package/dist/resolve-run-intent-W32G6WM6.js +2 -0
- package/dist/{resolver-CBTWTZZR.js → resolver-V5VP5FLT.js} +1 -1
- package/dist/{run-EXIYK6PU.js → run-26IR3CKX.js} +1 -1
- package/dist/{run-R7GND73C.js → run-5IYI2TJI.js} +1 -1
- package/dist/{run-test-md-664ASWRQ.js → run-test-md-FO2RNNOD.js} +2 -2
- package/dist/{skill-installer-QLQK4JJE.js → skill-installer-W4TT5MST.js} +1 -1
- package/dist/{spawner-ANLF7OX3.js → spawner-ZSYJQGQW.js} +1 -1
- package/dist/tcg-generate-ONLV5GXG.js +2 -0
- package/dist/{testmd-actions-QZD3N4EH.js → testmd-actions-NPILETCQ.js} +1 -1
- package/dist/token-refresh-G2CSTY4B.js +2 -0
- package/dist/{types-VYEOJ6U2.js → types-O23GN2YM.js} +1 -1
- package/dist/{validate-basic-D7IJUFUQ.js → validate-basic-727KRHX6.js} +1 -1
- package/dist/{verdicts-EO5TZ5BW.js → verdicts-TDJLJJ3F.js} +1 -1
- package/dist/{version-check-JRLPWQ6T.js → version-check-A2JQYRI2.js} +1 -1
- package/dist/{walk-session-IODOH7QU.js → walk-session-HB3OOWVR.js} +1 -1
- package/dist/{with-telemetry-ASNQQBGP.js → with-telemetry-HSD6CXDS.js} +1 -1
- package/package.json +11 -11
- package/dist/FolderPicker-5U3RHHBE.js +0 -2
- package/dist/SingleShotApp-XWOPGLKZ.js +0 -2
- package/dist/TestMdRunView-6BY3IUH5.js +0 -2
- package/dist/bridge-LOBTHY3P.js +0 -2
- package/dist/chunk-6DTWVLSJ.js +0 -4
- package/dist/chunk-BG66IAO6.js +0 -19
- package/dist/chunk-BVKDHHPK.js +0 -5
- package/dist/chunk-KBMQGNKO.js +0 -26
- package/dist/chunk-UOMRMCMI.js +0 -2
- package/dist/chunk-VT2XNEOD.js +0 -10
- package/dist/chunk-X2FM67OM.js +0 -4
- package/dist/doctor-VWGEQYBB.js +0 -2
- package/dist/install-46S4VOZ4.js +0 -2
- package/dist/login-flow-U43QVFPH.js +0 -2
- package/dist/pipeline-BHEA7ODT.js +0 -2
- package/dist/prepare-target-27UN4KNO.js +0 -2
- package/dist/resolve-run-intent-ZML3HKG7.js +0 -2
- package/dist/tcg-generate-VBC5ODDI.js +0 -2
- package/dist/token-refresh-PIUX5OFA.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{i as S}from"./chunk-KRKGZ2ZW.js";import{a as C,b as k,c as R,d as D}from"./chunk-
|
|
2
|
+
import{i as S}from"./chunk-KRKGZ2ZW.js";import{a as C,b as k,c as R,d as D}from"./chunk-BN6AHQL7.js";import{j as T,k as $,l as b}from"./chunk-2DCNCH32.js";import{g as E}from"./chunk-R7QAS6LZ.js";import{c as y}from"./chunk-5DT7PIGB.js";import{a as O}from"./chunk-CH273NAE.js";import{A as _}from"./chunk-TH47OOBV.js";import{existsSync as H}from"fs";import{basename as q}from"path";import{appendFileSync as L,mkdirSync as U}from"fs";import{homedir as F}from"os";import{dirname as G,join as j}from"path";function P(c,s){let n=/^(DOCX_[A-Z_]+):/.exec(s)?.[1];if(n)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??j(F(),".testmuai","kaneai","context-refusals.log");U(G(u),{recursive:!0}),L(u,`${new Date().toISOString()} ${n} ${c}
|
|
3
3
|
`)}catch{}}async function w(c,s,n,u=process.cwd(),p){let l=O(u),g=[];if(s.as!==void 0&&c.length>1)return(n.err??n.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${c.length})`,"AS_SINGLE_SOURCE"),{code:2,results:g};for(let o of c){if(R(o)){let a=D(o);if(a===null)return(n.err??n.out)(`error: ${o}: unsupported remote URL \u2014 supported: ${k.map(d=>d.hint).join("; ")}`,"UNSUPPORTED_URL"),{code:1,results:g};let r=await a.ingest(o,s.as,n,l,p);if(r.code!==0)return{code:r.code,results:g};r.result&&g.push({status:r.result.status==="versioned"?"versioned":r.result.status==="unchanged"?"unchanged":"created",source_id:r.result.source_id,source_cid:r.result.source_cid});continue}let f=s.as,v;if(f===void 0&&H(l)){let a=T(o),r=$(a);if(r){let d=_(l);d.heads.get(r)!=null&&d.heads.get(a)==null&&(v=r,n.isTTY&&await n.confirm(`${a} looks like a new version of existing source '${r}' \u2014 ingest as '${r}' (replaces the current version; items built on it go stale)?`)&&(f=r))}}let e;try{e=await b({contextDir:l,filePath:o,asId:f,confirmSameSource:n.isTTY?a=>n.confirm(`identical bytes already ingested as ${a} \u2014 treat as the same source?`):void 0,converters:{pdf:E,docx:S}})}catch(a){let r=a instanceof Error?a.message:String(a);return P(o,r),(n.err??n.out)(`error: ${o}: ${r}`,"INGEST_FAILED"),{code:1,results:g}}n.out(C(n.isTTY,e,q(o)));for(let a of e.warnings??[])n.out(`warning: ${a}`);if(e.composite&&(e.composite.delivered>0||e.composite.omitted>0)){let a=e.composite.pages!==void 0?` ${e.composite.pages} pages,`:"";n.out(`${e.source_id}: ${e.composite.kind},${a} ${e.composite.delivered} images delivered (${e.composite.omitted} omitted)`)}let m;if(!n.isTTY&&e.status==="created"){let a=_(l);for(let[r,d]of a.heads.entries())if(!(r===e.source_id||d==null)&&a.getNode(d)?.content.blob===e.blob){m=r,n.out(`hint: identical bytes already ingested as ${r} \u2014 merged later via review`);break}}g.push({status:e.status,source_id:e.source_id,source_cid:e.cid,...e.warnings?.length?{warnings:e.warnings}:{},...e.composite?{media:{kind:e.composite.kind,...e.composite.pages!==void 0?{pages:e.composite.pages}:{},delivered:e.composite.delivered,omitted:e.composite.omitted}}:{},...m?{duplicate_of:m}:{},...v&&f===void 0?{lineage_candidate:v}:{}})}return{code:0,results:g}}async function se(c,s,n,u=process.cwd(),p){return(await w(c,s,n,u,p)).code}async function ie(c,s){if(s.mode!=null&&!["interactive","agent","ci","override"].includes(s.mode)){let{makeHeadlessIO:t,agentRefusal:i}=await import("./headless-io-66RG5NN5.js");return i(t("ndjson","extract"),`ingest: --mode must be interactive | agent | ci | override, got '${s.mode}'`,"MODE_USAGE")}let n=y();if(s.mode==="interactive"&&!n)return process.stderr.write(`ingest: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
|
|
4
4
|
`),2;let u=s.mode??(n?"interactive":void 0),p=u==="interactive"||u==="agent"||u==="override";if(!p&&(s.plan||s.force||s.trust!==void 0))return process.stderr.write(`ingest: --plan/--force/--trust steer the extraction \u2014 not available when only landing (use --mode agent to extract headless)
|
|
5
5
|
`),2;let{createInterface:l}=await import("readline/promises"),g=u==="agent",o=g?(await import("./headless-io-66RG5NN5.js")).makeHeadlessIO("ndjson","extract"):null,f=[],v=()=>{for(let t of f.splice(0))o.event({type:"error",message:t.message,...t.code?{code:t.code}:{}})},e=t=>{for(let i of t)o.event({type:"ingested",source_id:i.source_id,status:i.status,cid:i.source_cid,...i.warnings?.length?{warnings:i.warnings}:{},...i.media?{media:i.media}:{},...i.duplicate_of?{duplicate_of:i.duplicate_of}:{},...i.lineage_candidate?{lineage_candidate:i.lineage_candidate}:{}})},m=o?{out:()=>{},err:(t,i)=>f.push({message:t.replace(/^error: /,""),...i?{code:i}:{}}),isTTY:!1,confirm:async()=>!1}:{out:t=>process.stdout.write(t+`
|
|
6
6
|
`),err:t=>process.stderr.write(t+`
|
|
7
|
-
`),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-
|
|
7
|
+
`),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-HSD6CXDS.js");return t("ingest",async()=>{let{code:i,results:h}=await w(c,{as:s.as},m,void 0,void 0);if(i!==0)return i;let I=h.filter(Y=>Y.status!=="unchanged").length;return I>0&&(m.err??m.out)(`landed ${I} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let a;try{a=o?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:o.event},()=>w(c,{as:s.as},m,void 0,void 0)):await w(c,{as:s.as},m,void 0,void 0)}catch(t){if(o)return v(),o.event({type:"error",message:t instanceof Error?t.message:String(t),code:"INGEST_FAILED"}),o.done(1,"error");throw t}let{code:r,results:d}=a;if(r!==0)return o?(e(d),v(),o.done(r,r===2?"refused":"error")):r;if(d.length===0)return o?o.done(0):0;let{extractCommand:A}=await import("./extract-cmd-FLOYO6HL.js"),N=[...new Set(d.map(t=>t.source_id))],x=await A({...s.mode!==void 0?{mode:s.mode}:{},...s.plan?{plan:!0}:{},...s.force?{force:!0}:{},...s.trust!==void 0?{trust:s.trust}:{},sources:N,landed:d});if(x===2&&!g){let t=d.filter(i=>i.status!=="unchanged").length;t>0&&(m.err??m.out)(`note: the ${t} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return x}export{w as a,se as b,ie as c};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as V,b as q,c as le,d as A}from"./chunk-2YQ6TW77.js";import{b as z}from"./chunk-5GUD3CIH.js";import{a as B}from"./chunk-BPMSNGXQ.js";import{a as M}from"./chunk-DPUV6OSP.js";import{a as F}from"./chunk-NLCCBXXV.js";import{a as L}from"./chunk-RZ4F3BHX.js";import{e as ce}from"./chunk-UR6MHSHU.js";import{readFileSync as oe,existsSync as j,readdirSync as Se,mkdirSync as U,writeFileSync as x}from"fs";import{readFile as ae,unlink as Te}from"fs/promises";import{join as E}from"path";import{existsSync as ye,mkdirSync as Re,readdirSync as ee,writeFileSync as Ae}from"fs";import{join as k}from"path";import{randomUUID as P}from"crypto";var ue="/home/kaneai/Downloads";function w(t){return`${ue}/${t}`}function K(t){return"FILE__"+t.replace(/[^A-Za-z0-9]/g,"_")}function C(t){let e=t?.media;return!e||!e.name||!e.media_url?null:{media_id:e.media_id??"",name:e.name,media_url:e.media_url,type:e.type??"doc"}}function H(t){return t?t.includes(`
|
|
3
|
+
`)?t.split(`
|
|
4
|
+
`).map(e=>e.trim()).filter(Boolean):t.split(". ").map(e=>e.trim()).filter(Boolean).map(e=>e.endsWith(".")?e:e+"."):[]}function T(t,e){return!t||!e?t:t.replace(/\{\{(.+?)\}\}/g,(o,i)=>{let n=e[i];return n?n.value:o}).replace(/\$\{(.+?)\}/g,(o,i)=>{let n=e[i];return n?n.value:o})}var de={click:"CLICK",double_click:"CLICK",type:"TYPE",fill:"TYPE",clear:"CLEAR",select:"SELECT",hover:"HOVER",drag:"DRAG_DROP",upload_files:"UPLOAD_FILE",navigate:"OPEN",go_back:"NAVIGATE",go_forward:"NAVIGATE",refresh:"REFRESH",press_key:"SENDKEYS",scroll:"SCROLL_PIXELS",scroll_into_view:"SCROLL_UNTIL_ELEMENT",wait:"WAIT",wait_until:"WAIT_UNTIL",wait_for_load:"WAIT_FOR_LOAD",switch_tab:"SWITCH_TAB",new_tab:"NEW_TAB",close_tab:"CLOSE_TAB",api:"API",evaluate_js:"EVALUATE_JS",vision_query:"VISION_QUERY",textual_query:"TEXTUAL_QUERY",get_url:"GET_URL",get_title:"GET_TITLE",assert:"ASSERTION",math:"MATHEMATICAL_OPERATION",set_cookies:"SET_COOKIES",delete_cookies:"DELETE_COOKIES",clear_cookies:"CLEAR_COOKIES",set_local_storage:"SET_LOCAL_STORAGE",delete_local_storage:"DELETE_LOCAL_STORAGE",clear_local_storage:"CLEAR_LOCAL_STORAGE",set_clipboard:"SET_CLIPBOARD",paste_clipboard:"PASTE_CLIPBOARD",clear_clipboard:"CLEAR_CLIPBOARD",device_control:"DEVICE_CONTROL",device_control_query:"DEVICE_CONTROL_QUERY"},X={literal:"SET_VARIABLE",condition:"SET_VARIABLE",visual:"VISION_QUERY",dom:"TEXTUAL_QUERY",url:"GET_URL",title:"GET_TITLE",devtool_network:"DEVTOOLS_NETWORK_QUERY",devtool_console:"DEVTOOLS_CONSOLE_QUERY",devtool_cookies:"DEVTOOLS_COOKIES_QUERY",devtool_storage:"DEVTOOLS_STORAGE_QUERY",devtool_performance:"DEVTOOLS_PERFORMANCE",api_response:"API_CALLS_QUERY",textual_visual:"TEXTUAL_ANALYZER"},_e=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function Y(t,e){if(t==="analyze"){let i=e?.action_params?.analyzer_type??"";return X[i]}if(t==="scroll"&&e?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let o=de[t];return o||console.warn(`[migrator] UNKNOWN action_type "${t}" \u2014 falling back to "${t.toUpperCase()}"; explicit mapping required`),o??t.toUpperCase()}function W(t,e){if(!t||!e)return"";try{let o=new Date(t);return isNaN(o.getTime())?"":new Date(o.getTime()+e).toISOString()}catch{return""}}function J(t){try{return JSON.parse(t.output_value??"{}")}catch{return{}}}function pe(t){let e=t.output_variable??"";if(!e)return"[]";let i={...J(t)};return delete i.body,JSON.stringify([{name:e,unique_key:(t.action_id??"").replace(/-/g,"").slice(0,8)||P().replace(/-/g,"").slice(0,8),value:i,variable_description:"API Response"}])}function ge(t,e,o){let i=t.action_params??{},n=_e.has(e)?"Vision Agent":"Operation Agent",r={operation_type:e};if(e==="OPEN"&&(r.url=i.url??""),e==="SET_VARIABLE"&&(r.variable_name=t.output_variable??i.key??"",r.variable_value=t.output_value??""),e==="UPLOAD_FILE"){let m=C(i);m&&(r.value=w(m.name))}let s={},c={},a=t.action_instruction??"",l=i.text??"",u=i.url??"",p=[["intent",a],["value",l],["url",u]];for(let[m,h]of Object.entries(o)){let I=String(h);if(m.startsWith("secrets."))for(let[b,v]of p)v.includes(I)&&(c[b]=m);for(let[b,v]of p)v.includes(I)&&!(b in s)&&(s[b]=v)}let d=t.action_type,_={operation:t.action_instruction??"",agent:n,operation_dict:r,reasoning:d==="analyze"?i.query??"":t.intent??t.action_instruction??"",variable:s,secrets:c,params:{}};d==="analyze"&&typeof i.code=="string"&&i.code&&(_.code=i.code),d==="analyze"&&typeof i.code_js=="string"&&i.code_js&&(_.code_js=i.code_js),d==="analyze"&&typeof i.condition_expression=="string"&&i.condition_expression&&(_.condition_expression=i.condition_expression),i.uses_websocket===!0&&(_.uses_websocket=!0),i.uses_sse===!0&&(_.uses_sse=!0),d==="analyze"&&i.analyzer_type==="textual_visual"&&(typeof i.wrapped_js=="string"&&(_.wrapped_js=i.wrapped_js),Array.isArray(i.locators)&&(_.locators=i.locators),typeof i.operator=="string"&&(_.operator=i.operator),Array.isArray(i.transforms)&&(_.transforms=i.transforms),typeof i.query=="string"&&(_.query=i.query),typeof i.expected_value=="string"&&(_.expected_value=i.expected_value),typeof i.needs_unit_conversion=="boolean"&&(_.needs_unit_conversion=i.needs_unit_conversion),typeof i.condition=="string"&&(_.condition=i.condition));let f={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[d];return f&&i[f]!==void 0&&(_[f]=i[f]),d==="set_clipboard"&&typeof i.html=="string"&&i.html&&(_.html=i.html),_}function fe(t){let e=t.assertion_tree??{};if(typeof e.passed=="boolean")return e.passed;let o=e.sub_results??[];return o.length===0?e.status==="passed":(e.composite_operator??"and")==="or"?o.some(n=>n.passed===!0):o.every(n=>n.passed===!0)}function Z(t){return t.map(e=>({description:e.description??"",store_key:e.store_key??"",expected_value:e.expected??"",extracted_value:e.extracted_value??"",operator:e.operator??"equals",transforms:e.transforms??[]}))}function me(t){let e=t.assertion_tree??{},o=e.sub_results??[],i=Z(o);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:o,sub_checks:i,composite_operator:e.composite_operator??"and",verification:e.verification??"",claim:e.description??""}}function he(t){let o=(t.action_params??{}).assertion_tree??{},i=o.sub_results??[],n=Z(i);return[{operation:t.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:i,sub_checks:n,composite_operator:o.composite_operator??"and",verification:"",claim:o.description??t.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function Ee(t,e,o,i){let n=t.visual_data;if(!n||n.x==null||n.y==null)return null;let r=e?`${e}/test_screenshots`:"";return{x:n.x,y:n.y,confidence:0,bbox:n.bbox??null,bbox_source:n.bbox?"accessibility_tree":"fallback",viewport_width:n.viewport_width??1280,viewport_height:n.viewport_height??800,scale_factor:null,raw_image_url:r?`${r}/untagged_screenshot/${o}.${i?.get(o)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function be(t){if(!t)return"";let e=t;return typeof t=="object"&&!Array.isArray(t)&&Array.isArray(t.frameInfo)&&(e=t.frameInfo),!Array.isArray(e)||e.length===0?"":JSON.stringify(e)}function Ie(t){return/^(android|ios)_native$/i.test(t.platform??"")}function $(t,e={},o="",i){let n=t.action_type,r=Y(n,t),s=t.action_params??{},c=t.coordinates??null,a=t.selectors??null,l=!!(a&&a.length>0),u=Ie(t),p=t.timestamp??"",d=t.duration_ms??0,_=t.variables_used??{},g=t.action_id??P(),f=P(),m=W(p,d),h="",I="";if(n==="navigate")I=s.url??"",h=I;else if(n==="type"||n==="fill")h=s.text??"";else if(n==="press_key")h=s.key??"";else if(n==="wait")h=String(s.ms??s.timeout_ms??"");else if(n==="evaluate_js")h=s.script??"";else if(n==="upload_files"){let R=C(s);R&&(h=w(R.name))}else n==="analyze"&&r==="SET_VARIABLE"&&(h=t.output_value??"");let b="";n==="go_back"?b="back":n==="go_forward"&&(b="forward");let v=T(h,e),O=T(I,e),y=T(t.action_instruction??"",e),S=ge(t,r,_);return{operation_id:g,instruction_id:f,instruction:y,intent:y,operation_start:p,operation_end:m,status:t.status??"",command:r,name:"",target:"",value:v,message:"",operation_dict:"",frame:be(t.frame_info),error_message:t.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(S),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:o?`${o}/test_screenshots/untagged_screenshot/${g}.${i?.get(g)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:O,navigation_direction:b,tagified_image_url:"",query_variable_name:t.output_variable??"",query_variable_value:t.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:r==="ASSERTION"?fe(s):"",query_info_dict:{},query_content_confidence:"none",debugging_logs:[],locator_index:0,query_html:"",user_variables:"[]",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,tab_index:String(s.tab_index??""),tab_identifier:String(s.tab_identifier??""),scroll_value:s.amount??1,scroll_direction:s.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:n==="evaluate_js"?s.script??"":"",code_error:"",hide:!1,dismiss_dialog:!1,use_v2_mobile_tagging:u,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:c!==null&&!l,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:l?null:c?.x??null,y_coord:l?null:c?.y??null,target_x_coord:s.target_x??null,target_y_coord:s.target_y??null,source_description:s.source_description??null,target_description:s.target_description??null,use_coordinates:c!==null&&!l,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:l?a.map(R=>({...R,type:u?R.strategy??R.type??"native":R.isXPath?"xpath":"css"})):"",selector_target:"",math_result_variable_name:"",math_result_variable_value:"",expression_tree:r==="ASSERTION"?me(s):s.expression_tree??{},assertion_tree:s.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:t.reprobe??!1,click_modifier:(s.click_count??1)>=2?{kind:"multi_click",frequency:s.click_count}:null,db_query:"",db_details:{},db_query_decoded:"",is_global_variable:!1,is_global_variable_persist:!1,global_variable_id:"",wait_for_element_timeout:0,failure_condition:r==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},start_coordinates:s.source_coordinates?{x:s.source_coordinates[0],y:s.source_coordinates[1]}:{},end_coordinates:s.target_coordinates?{x:s.target_coordinates[0],y:s.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:n==="api"?{request:t.action_params?.api_data?.request??{}}:{},output_variables:n==="api"?t.output_variable?{[t.output_variable]:null}:{}:t.output_variable?{[t.output_variable]:t.output_value??""}:{},visual_context:Ee(t,o,g,i),reasoning:n==="analyze"?s.query??"":t.intent??t.action_instruction??""}}function G(t,e,o={}){let i=t.action_type,n=Y(i,t),r=t.timestamp??"",s=t.duration_ms??0,c=W(r,s),a=n==="ASSERTION"||n==="MATHEMATICAL_OPERATION";return{instruction_id:e.instruction_id,instruction_class:a?"non_driver_action":"driver_action",module_id:"",instruction:T(t.action_instruction??"",o),command:n,error:null,parent_instruction_id:"",classification_layer_resp:n==="ASSERTION"?he(t):[],classification_error:{},operations:[e],status:t.status??"",start_timestamp:r,end_timestamp:c,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:i==="api"?"api":i==="analyze"&&t.action_params?.analyzer_type==="api_response"?"api_calls_query":i==="analyze"&&t.action_params?.analyzer_type?.startsWith("devtool_")?t.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:i==="evaluate_js"?t.action_params?.script??"":"",user_variables:i==="api"?pe(t):"[]",api_data:i==="api"?{request:t.action_params?.api_data?.request??{},response:J(t)}:{},params_used:!1,hard_assertion:n==="ASSERTION"?t.action_params?.failure_condition==="hard":!1,expected_outcome:"",module_execution_index:0,module_version:null,network_throttle:{},isEdited:!1,use_query_assertion_v2:!1,db_query:"",db_details:{},network_assertion_content:{},screenshot_command:"",smartui_contents:{},generative_id:"",plan_id:"",generative_objective:"",error_message:"",error_code:"",reason:"",title:"",used_variables:[],reasoning:i==="analyze"?t.action_params?.query??"":t.intent??t.action_instruction??""}}function ve(t,e=[]){let o=t.action_params??{},i=o.branches??[],n=o.winning_index??-1,r=o.sub_results??[],s={};for(let a of r){let l=a.sub_results;if(l)for(let u of l){let p=u.store_key;p&&(s[p]=u)}}let c=i.map((a,l)=>{let u=l===n,p=(a.sub_checks??[]).map(d=>{let _=s[d.store_key];return{description:d.description,store_key:d.store_key,expected_value:d.expected_value,stored_value:_?.extracted_value??d.stored_value,operator:d.operator??_?.operator??"equals",transforms:d.transforms??_?.transforms??[]}});if(p.length===0&&a.condition&&r.length>0){let _=r.find(g=>g.branch_index===l)?.sub_results??[];_.length>0&&(p=_.map(g=>({description:g.description??a.condition,store_key:g.store_key??"",expected_value:g.expected??"true",stored_value:g.extracted_value??void 0,operator:g.operator??"equals",transforms:g.transforms??[]})))}return{branch_index:l,condition:a.condition??null,branch_type:a.branch_type??"sub_objective",passed:u,sub_objective:null,custom_event:a.custom_event??null,children:u?e:[],sub_checks:a.condition?p:[],composite_operator:a.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${P().slice(0,8)}`,instruction:t.action_instruction??"",instruction_class:"driver_action",command:"",status:t.status??"success",resolved_branch_index:n,branches:c,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:t.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function Q(t,e,o){for(let i of t)i.content_type==="instruction"&&"generative_id"in i&&(i.generative_id=e,i.generative_objective=o)}function D(t,e={},o="",i,n){let r=[],s=0;for(;s<t.length;){let c=t[s],a=c.action_type;if(!n?.keepFailedActions&&c.status==="error"&&a!=="assert"&&a!=="if_else"&&a!=="child_agent_start"&&a!=="child_agent_end"&&!(c.until_condition&&!c.error)){s+=1;continue}if(a==="analyze"&&!X[c.action_params?.analyzer_type??""]){s+=1;continue}if(a==="child_agent_start"){let l=c.action_params?.child_id??"",u=c.action_params?.objective??"",p=[];s+=1;let d=1,_="error",g;for(;s<t.length&&d>0;){let y=t[s],S=y.action_type;if(S==="child_agent_start")d+=1;else if(S==="child_agent_end"&&(d-=1,d===0)){_=y.status??"success",g=y,s+=1;break}d>0&&p.push(y),s+=1}let f=D(p,e,o,i);Q(f,l,u);let m=g?.action_params?.result_code??null,h=g?.action_params?.reason_code??null,I=g?.action_params?.error_message??null,b=g?.action_params?.summary??null,v=g?.action_params?.one_liner??null,O=_==="error";r.push({content_type:"generative_block",instruction_id:`generative_block_${l}`,generative_id:l,objective:u,status:_,children:f,error_message:O?I??null:null,error_code:O?h??null:null,result_code:m??null,bifurcation_context:[],approach_reason:H(b),one_liner:v??null});continue}else if(a==="child_agent_end"){s+=1;continue}else if(a==="if_else"){s+=1;let l=[];for(;s<t.length&&t[s].action_type==="child_agent_start";){let u=t[s],p=u.action_params?.child_id??"",d=u.action_params?.objective??"",_=[];s+=1;let g=1,f="error";for(;s<t.length&&g>0;){let h=t[s];if(h.action_type==="child_agent_start")g+=1;else if(h.action_type==="child_agent_end"&&(g-=1,g===0)){f=h.status??"success",s+=1;break}g>0&&_.push(h),s+=1}let m=D(_,e,o,i);l.push(...m)}r.push(ve(c,l));continue}else if(a==="query_tool"){s+=1;continue}else if(c.until_condition){let l=$(c,e,o,i),u=G(c,l,e),p=typeof c.until_condition_met=="boolean"?c.until_condition_met:c.status==="success";r.push({content_type:"until_block",instruction_id:`until_${P().slice(0,8)}`,condition:c.until_condition,max_retries:c.until_max_retries??10,settle_ms:c.until_settle_ms??500,current_count:0,condition_met:p,children:[u],generative_id:"",generative_objective:"",variables_used:{},status:c.status??"success"})}else{let l=$(c,e,o,i),u=G(c,l,e);r.push(u)}s+=1}return r}function N(t,e={},o="",i,n){let r=[];for(let s of t){let c=D(s.records,e,o,i,n);if(c.length===0)continue;let a=P().replace(/-/g,"");Q(c,a,s.objective);let l=c.some(_=>"status"in _&&typeof _.status=="string"?_.status==="error"||_.status==="failed":!1),u=s.resultCode?parseInt(s.resultCode,10):null,p=u!==null&&!isNaN(u)&&u>=200,d=l||p?"error":"success";r.push({content_type:"generative_block",instruction_id:`generative_block_${a}`,generative_id:a,objective:s.objective,status:d,children:c,error_message:d==="error"?s.errorMessage??null:null,error_code:d==="error"?s.reasonCode??null:null,result_code:s.resultCode??null,bifurcation_context:[],approach_reason:H(s.summary),one_liner:s.oneLiner??null})}return{instructions:r}}function te(t,e){let o;try{o=ee(t)}catch{return 0}let i=0,n=o.filter(r=>/^\d+$/.test(r)).sort((r,s)=>Number(r)-Number(s));for(let r of n){let s=k(t,r),c=k(s,"logs");if(!ye(c))continue;let a;try{a=ee(c)}catch{continue}let l=a.filter(d=>d.endsWith("-actions.ndjson")).sort((d,_)=>(parseInt(d,10)||0)-(parseInt(_,10)||0)),u=[];for(let d of l){let _=e.readActions(k(c,d));_.length&&u.push({objective:e.objective??"",records:_})}if(u.length===0)continue;let{instructions:p}=N(u,e.vars??{},e.screenshotBaseUrl??"",e.extMap,{keepFailedActions:!0});if(p.length!==0)try{let d=k(s,"auteur");Re(d,{recursive:!0}),Ae(k(d,"execution.json"),JSON.stringify(e.buildBlob(p),null,2)),i++,e.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:r,instructions:p.length})}catch(d){e.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:r,error:d instanceof Error?d.message:String(d)})}}return i}var ie=ce(le(),1);import{createWriteStream as Pe}from"fs";import{readFile as Le}from"fs/promises";import{join as Ne,basename as ke}from"path";import{tmpdir as xe}from"os";var Oe=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function ne(t){let e=Ne(xe(),`${ke(t)}_artifacts.zip`);return new Promise((o,i)=>{let n=Pe(e),r=(0,ie.default)("zip",{zlib:{level:6}});n.on("close",()=>o(e)),r.on("error",i),r.pipe(n),r.glob("**/*",{cwd:t,ignore:Oe}),r.finalize()})}async function se(t){return Le(t)}async function we(t,e){return ae(z(t,e))}function Ce(t){return{key:"artifacts",content_type:"application/zip",filename:`${t}.evidence`}}var re=class{config;controller;testId;constructor(e){this.config=e,this.controller=new M(e.controllerBaseUrl,e.auth),this.testId=e.testId}log(e,o,i,n){this.config.log?.(e,o,i,n)}async execute(){let{onProgress:e}=this.config;try{if(!this.testId)return this.log("error","PIPELINE_ABORT","No test_id available"),{success:!1,testId:null,error:"No test_id available"};let o=this.config.evidence,i=null;if(this.config.shouldUploadArtifacts!==!1){e("convert","running");let c=this.collectNdjsonPerRun(),a=c.reduce((f,m)=>f+m.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:a,run_groups:c.length});let l=this.config.variables??{};this.log("info","PIPELINE_CONVERT_VARS","Variables for template resolution",{keys:Object.keys(l)});let{instructions:u}=c.length>0?N(c,l,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:u.length});let p=this.buildExecutionEnvelope(u),d=Buffer.from(JSON.stringify(p));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(d.length/1024).toFixed(1)});let _=E(this.config.sessionDir,"execution.json");x(_,JSON.stringify(p,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:_});let g=o?.packTestDir??this.config.evidenceRead?.packTestDir;if(g){let f=E(g,"auteur");U(f,{recursive:!0}),x(E(f,"execution.json"),JSON.stringify(p,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:E(f,"execution.json")}),this.deriveArchivedAttemptBlobs(g,l)}if(e("convert","done"),o)i=d;else{e("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let f=null,m;try{f=await ne(this.config.sessionDir),m=await se(f),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(m.length/1024/1024).toFixed(1),path:f}),e("zip","done",`${(m.length/1024/1024).toFixed(1)}MB`)}finally{f&&await Te(f).catch(()=>{})}e("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let h=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:h.urls.artifacts?.blob_url,blob_url:h.urls.blob?.blob_url}),e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(m.length/1024/1024).toFixed(1),blob_size_kb:+(d.length/1024).toFixed(1)}),await Promise.all([A(h.urls.artifacts.upload_url,m,"application/zip"),A(h.urls.blob.upload_url,d,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),e("upload","done")}}else{let c=this.collectNdjsonPerRun(),a=this.config.variables??{},{instructions:l}=c.length>0?N(c,a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0}):{instructions:[]},u=this.buildExecutionEnvelope(l),p=E(this.config.sessionDir,"execution.json");x(p,JSON.stringify(u,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:p});let d=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(d){let _=E(d,"auteur");U(_,{recursive:!0});let g=this.readAuthoredExecution();x(E(_,"execution.json"),g??JSON.stringify(u,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:E(_,"execution.json"),source:g?"authored":"run_envelope"}),this.deriveArchivedAttemptBlobs(d,a)}e("convert","skipped"),e("zip","skipped"),e("presign","skipped"),e("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){e("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),e("atomic_replace","done")}catch(c){let a=c instanceof Error?c.message:String(c);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:a}),e("atomic_replace","failed",a),c}}else e("atomic_replace","skipped");let n,r;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){e("commit_lock","running");let c=await this.config.onCommitLock();if(c.ok)n=c.testcaseId,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:n??"none"}),e("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:c.reason,message:c.message}),e("commit_lock","failed",`${c.reason??"unknown"}: ${c.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${c.reason??"unknown"}`}}else e("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){e("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let c=new B(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),a=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective];if(n=(await c.endTest(this.testId,{commit_id:this.config.commitId,time_taken:Math.round(this.config.totalDuration),steps_count:this.config.totalSteps,commit_message:this.config.firstObjective.slice(0,255),objectives:a})).testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:n??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(n)}catch(u){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(u)})}e("finalize","done")}else e("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(n&&this.config.shareApiBaseUrl)try{r=await this.generateShareLink(n),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:r})}catch(c){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(c)})}if(o&&i){let c=null;e("zip","running");try{await o.sealFn({testcaseId:n,shareId:r}),c=o.sealedPackPath?await ae(o.sealedPackPath):await we(o.executionId,o.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:o.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(c.length/1024/1024).toFixed(1)})}catch(a){let l=a instanceof Error?a.message:String(a);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:o.executionId,error:l})}if(c){e("zip","done",`${(c.length/1024/1024).toFixed(1)}MB`),e("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[Ce(o.executionId),{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:a.urls.artifacts?.blob_url,blob_url:a.urls.blob?.blob_url}),e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(c.length/1024/1024).toFixed(1),blob_size_kb:+(i.length/1024).toFixed(1)}),await Promise.all([A(a.urls.artifacts.upload_url,c,"application/zip"),A(a.urls.blob.upload_url,i,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),e("upload","done")}else{e("zip","skipped"),e("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(i.length/1024).toFixed(1)}),await A(a.urls.blob.upload_url,i,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),e("upload","done")}}let s;if(this.config.mobile&&this.config.codeExport?.enabled)this.log("info","PIPELINE_CODE_EXPORT_SKIPPED","Code export is not supported for device runs"),e("code_export","skipped","not supported on mobile yet");else if(this.config.codeExport?.enabled&&n){let c=!1;try{await this.triggerCodeExport(n),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),c=!0}catch(a){let l=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:l}),e("code_export","failed",`trigger failed: ${l}`)}if(c){e("code_export","running","Waiting for code generation\u2026");try{s=await this.pollAndDownloadCode(n,e),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:s}),e("code_export","done",s)}catch(a){let l=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:l}),e("code_export","failed",l)}}}else e("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:n,shareId:r,codeExportDir:s}}catch(o){return{success:!1,testId:this.testId,error:o instanceof Error?o.message:String(o)}}}async runCodeExport(e,o){let i=o??this.config.onProgress,n=!1;try{await this.triggerCodeExport(e),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:e}),n=!0}catch(r){let s=r instanceof Error?r.message:String(r);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:s}),i("code_export","failed",`trigger failed: ${s}`)}if(n){i("code_export","running","Waiting for code generation\u2026");try{let r=await this.pollAndDownloadCode(e,i);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:r}),i("code_export","done",r),r}catch(r){let s=r instanceof Error?r.message:String(r);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:s}),i("code_export","failed",s);return}}}deriveArchivedAttemptBlobs(e,o){try{let i=te(e,{readActions:n=>this.readNdjsonFromFile(n),buildBlob:n=>this.buildExecutionEnvelope(n),objective:this.config.firstObjective,vars:o,screenshotBaseUrl:this.config.screenshotBaseUrl??"",extMap:this.config.screenshotExtMap,log:(n,r,s,c)=>this.log(n,r,s,c)});i>0&&this.log("info","PIPELINE_ARCHIVED_ATTEMPTS","Nested retry-attempt blobs derived",{count:i})}catch(i){this.log("debug","PIPELINE_ARCHIVED_ATTEMPTS_FAILED","Nested attempt blob pass failed",{error:i instanceof Error?i.message:String(i)})}}collectNdjsonPerRun(){let e=[],o=this.config.runObjectives??[],i=this.config.runMetadata??[],n=this.config.evidence??this.config.evidenceRead;for(let r=0;r<this.config.runDirs.length;r++){let s=this.config.runDirs[r],c=o[r]||this.config.firstObjective,a=i[r],l=n?this.readNdjsonFromFile(E(n.packTestDir,"logs",`${n.runIndices?.[r]??r}-actions.ndjson`)):this.readNdjsonFromDir(s);l.length>0&&e.push({objective:c,records:l,resultCode:a?.resultCode,reasonCode:a?.reasonCode,errorMessage:a?.errorMessage,summary:a?.summary,oneLiner:a?.oneLiner})}if(e.length===0){let r=E(this.config.sessionDir,"runs");if(j(r))try{let c=Se(r,{withFileTypes:!0}).filter(a=>a.isDirectory()).map(a=>a.name).sort();for(let a of c){let l=E(r,a),u=this.readNdjsonFromDir(l);u.length>0&&e.push({objective:this.config.firstObjective,records:u})}}catch{}}return e}readNdjsonFromDir(e){let o=[E(e,"run-test","actions.ndjson"),E(e,"actions.ndjson")];for(let i of o)if(j(i))return this.readNdjsonFromFile(i);return[]}readNdjsonFromFile(e){let o=[];if(!j(e))return o;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:e});let i=oe(e,"utf-8");for(let n of i.split(`
|
|
5
|
+
`)){let r=n.trim();if(r)try{o.push(JSON.parse(r))}catch{}}return o}async generateShareLink(e){let o=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:o,testcase_id:e});let i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[e],entityType:"Test Case Details",expiresAt:7})},n=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:n,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let r=n?await this.config.authResolver.fetch(o,i):await L(o,{...i,headers:{...i.headers,Authorization:this.buildAuthHeader()}});if(!r.ok)throw new Error(`Share link API failed: ${r.status} ${await r.text()}`);let s=await r.json();if(!s.shareId)throw new Error("Share link API returned no shareId");return s.shareId}async triggerCodeExport(e){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:o,body:i}=V({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:e,codeExport:this.config.codeExport});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:o});let n={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(i)},r=this.config.authResolver?await this.config.authResolver.fetch(o,n):await L(o,{...n,headers:{...n.headers,Authorization:this.buildAuthHeader()}});if(!r.ok)throw new Error(`Code export failed: ${r.status} ${await r.text()}`)}async pollAndDownloadCode(e,o){let i=q({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:e}),n=this.config.exitTimeoutMs??3e5,r=5e3,s=Date.now()+n;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:i,timeout_ms:n});let c=(a,l)=>this.config.authResolver?this.config.authResolver.fetch(a,l):L(a,{...l,headers:{...l?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<s;){let a=await c(i,{method:"GET",headers:{Accept:"application/json"}});if(!a.ok){let _=await a.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:a.status,body:_.slice(0,200)}),new Error(`code export poll skipped: HTTP ${a.status}`)}let u=(await a.json()).data?.find(_=>_.code_name==="kane-cli-trigger");if(!u){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),o("code_export","running","Waiting for code generation\u2026"),await this.sleep(r);continue}let p=u.status.toLowerCase();if(p==="in progress"||p==="in_progress"||p==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:u.status}),o("code_export","running","Generating code\u2026"),await this.sleep(r);continue}if(!u.url||u.url.length===0)throw new Error(`Code export status=${u.status} but no files returned`);let d=this.config.codeExportDir??E(this.config.sessionDir,"code-export");U(d,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:u.url.length,dir:d}),o("code_export","running",`Downloading ${u.url.length} files\u2026`);for(let _ of u.url){let g=E(d,_.file_name),f=await L(_.file_url);if(!f.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:_.file_name,status:f.status});continue}let m=await f.text();x(g,m,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:_.file_name,size_bytes:m.length})}return d}throw new Error("Code export timed out")}sleep(e){return new Promise(o=>setTimeout(o,e))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:F(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let e=this.config.authoredExecutionPath;if(!e)return null;try{let o=oe(e,"utf8");return JSON.parse(o),o}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:e}),null}}buildExecutionEnvelope(e){let o=this.config.runStatuses.every(a=>a==="passed")?"success":"error",i=this.config.variableIds??{},n=[];if(this.config.variables)for(let[a,l]of Object.entries(this.config.variables)){if(l.secret)continue;let u=a.startsWith("global.")?a.slice(7):a;n.push({id:i[u]??0,name:u,value:l.value,session_value:l.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let r=[],s=[],c=new Set;for(let a of this.collectNdjsonPerRun())for(let l of a.records)if(l.output_variable&&l.output_value!=null&&r.push({name:l.output_variable,value:String(l.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),l.action_type==="upload_files"){let u=C(l.action_params);if(u){let p=u.media_id||u.media_url;if(!c.has(p)){c.add(p),s.push({media_url:u.media_url,media_id:u.media_id,name:u.name,type:u.type});let d=w(u.name);r.push({name:K(u.name),value:d,value_type:"string",variable_description:`variable for ${d}`})}}}return{test_id:this.testId,version:"v4",auto_heal_version:this.config.apMode==="v2"?"AH2":"",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:o,commit_id:this.config.commitId,instructions:e,modules:[],uploaded_files:s,test_params:[],test_level_variables:JSON.stringify(r),test_global_variables:n,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:0,environment:"",mobile_browser:!1,native_popups:[],smartui:{},module_index:0}}};export{we as a,Ce as b,re as c};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as K}from"./chunk-
|
|
2
|
+
import{b as K}from"./chunk-7VZCXW74.js";import{a as B,b as U,c as Y}from"./chunk-AFPHLUQ5.js";import{a as j}from"./chunk-DNNZ353O.js";import{d as F}from"./chunk-XWKUZJCP.js";import{A as k,a as L,b as V,k as G,o as N}from"./chunk-TH47OOBV.js";import{d as I}from"./chunk-DUAXZYAD.js";import{d as v,e as x,g as H}from"./chunk-WXHQYYD5.js";function ee(t,e,n,i,s){let f=n.rows.filter(u=>{let d=i.get(u.temp_ref);return d!==void 0&&d!=="reject"});if(f.length===0)return{record:null,errors:null};let o={version:1,read_basis:e.latestHash,source:{source_id:n.source_id,source_cid:e.heads.get(n.source_id)??""},use_cases:f.map(u=>u.uc)},p=new Map;for(let u of f){let d=i.get(u.temp_ref);typeof d=="object"?p.set(u.temp_ref,{resolution:"edited",edit:d.edited}):p.set(u.temp_ref,{resolution:u.uc.matches_existing&&u.uc.changed?"edited":"approved"})}let g=Y(o,e,n.staged_source_cid);if(g.errors!==null)return{record:null,errors:g.errors};let r=g.proposal,l=o.source.source_cid?D(t,e,o.source.source_cid):null;if(l!==null){r=U(r,l);let u=G(r,B(l),e);if(u.length>0)return{record:null,errors:[{code:"HELD_CITES_STALE",detail:"the source moved after this plan staged \u2014 its quotes no longer verify against the current head; re-run kane-cli maintain reconcile to re-stage"},...u]}}let m=`held-${(e.latestHash??"root").slice(-12)}-${f.length}`;return N({contextDir:t,graph:e,proposal:r,proposalId:m,verdicts:p,by:s,autoName:!0})}function W(t,e,n=[]){let i=K(t,e),s=new Set,f=[],o=l=>{!l||s.has(l)||(s.add(l),f.push(y(t,l)))};for(let l of i.pairs)o(l.scenario),o(l.test);for(let[l,m]of i.verifies){o(l);for(let u of m)o(u)}if(n.length===0)return{stale_refs:f};let p=l=>`${String(l.props.source_id)}\0${String(l.props.anchor)}`,g=new Set;for(let{cid:l}of t.byLabel(v.USECASE))if(t.tipOf(l)===e)for(let m of t.edgesInto(l)){if(m.type!==x.DERIVES)continue;let u=m.props.claim;typeof u=="string"&&n.includes(u)&&g.add(p(m))}if(g.size===0)return{stale_refs:f};let r=new Set;for(let[l,m]of i.verifies)if(t.edgesInto(l).some(d=>d.type===x.DERIVES&&g.has(p(d)))){r.add(y(t,l));for(let d of m)r.add(y(t,d))}return{stale_refs:f,...r.size>0?{direct_refs:[...r]}:{}}}var q="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",te="suite untouched; graph updated";function M(t,e){return!t.superseded.has(e)&&t.trust.get(e)!=="archived"}function y(t,e,n=new Set){let i=t.nameOf.get(e);if(i!==void 0)return i;if(n.has(e))return e;n.add(e);for(let[s,f]of t.superseded){if(f!==e)continue;let o=y(t,s,n);if(o!==s)return o}return e}function C(t){return String(t).slice(0,19)}function A(t,e,n){let i=t.edgesFrom(e).find(s=>s.type===n);return i?t.tipOf(i.dst):null}function X(t,e){let n=t.nodeLabel.get(e);if(n===v.USECASE)return e;if(n===v.SCENARIO)return A(t,e,x.BELONGS_TO);if(n===v.AC){let i=A(t,e,x.SCOPED_TO);return i?t.nodeLabel.get(i)===v.USECASE?i:A(t,i,x.BELONGS_TO):null}if(n===v.TEST){let i=A(t,e,x.AUTOMATES);return i?A(t,i,x.BELONGS_TO):null}return null}function z(t,e){let n=[],i=new Map;for(let s of t.derivesInto(e))i.set(String(s.props.source_id),s);for(let[s,f]of i){let o=t.heads.get(s);if(o==null){n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source retired`);continue}if(o!==f.props.source_cid){let p=t.convChains.get(s)?.chain;if(p&&p.includes(String(f.props.source_cid)))continue;n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source head moved to ${C(o)}`)}}for(let s of t.edgesFrom(e))H(s.type)?.pin?.comparesTo==="dst_tip"&&t.superseded.has(s.dst)&&n.push(`${s.type} pin \u2192 ${y(t,s.dst)} \u2014 target superseded`);return n.join("; ")||"structural pin broken"}var ne=new Set([v.USECASE,v.SCENARIO,v.AC,v.TEST]);function $(t,e){return t.ref<e.ref?-1:t.ref>e.ref?1:0}function D(t,e,n){let i=j(t,e,n);return i===null?null:i.toString("utf8")}function se(t,e,n,i,s){let f=n.props.quote;if(typeof f=="string"&&f.length>0)return i.includes(f);let o=String(n.props.source_cid);s.has(o)||s.set(o,D(t,e,o));let p=s.get(o);if(p===null)return!1;let g=V(p,String(n.props.anchor));return g===null?!1:g.split(`
|
|
3
3
|
`).some(r=>r.trim().length>0&&i.includes(r.trim()))}function oe(t,e,n){let i=L(String(e.props.anchor));if(i?.kind!=="img-part")return!1;let f=(t.mediaOf(String(e.props.source_cid)).images??[]).find(r=>r.ref===i.ref),o=f?.blob;if(o===void 0)return!1;let p=t.mediaOf(n).images??[];if(p.some(r=>r.blob===o))return!0;let g=f?.appearance;return g!==void 0&&p.filter(r=>r.appearance===g).length===1}var J=128*1024,Q=64*1024;function re(t,e){let n=t.split(`
|
|
4
4
|
`),i=e.split(`
|
|
5
5
|
`),s=0;for(;s<n.length&&s<i.length&&n[s]===i[s];)s++;let f=n.length,o=i.length;for(;f>s&&o>s&&n[f-1]===i[o-1];)f--,o--;if(f===s&&o===s)return"";let p=n.slice(s,f),g=i.slice(s,o),l=ie(p,g,2e3),m=[];if(l===null)m.push(`@@ old L${s+1}-L${f} \u2192 new L${s+1}-L${o} @@`,...p.map(u=>`- ${u}`),...g.map(u=>`+ ${u}`));else{let u=l.map((a,h)=>a.op==="="?-1:h).filter(a=>a>=0),d=0;for(;d<u.length;){let a=d;for(;a+1<u.length&&u[a+1]-u[a]<=3;)a++;let h=Math.max(u[d]-1,0),R=Math.min(u[a]+1,l.length-1),b=l.slice(h,R+1),S=s+(b[0].ai??0)+1,_=s+(b[0].bi??0)+1,c=b.filter(E=>E.op!=="+").length,w=b.filter(E=>E.op!=="-").length;m.push(`@@ old L${S}-L${S+Math.max(c-1,0)} \u2192 new L${_}-L${_+Math.max(w-1,0)} @@`);for(let E of b)m.push(E.op==="="?` ${E.line}`:`${E.op} ${E.line}`);d=a+1}}return m.join(`
|
|
6
6
|
`)}function ie(t,e,n){let i=t.length,s=e.length,f=Math.min(i+s,n),o=new Map([[1,0]]),p=[],g=!1;for(let u=0;u<=f&&!g;u++){p.push(new Map(o));for(let d=-u;d<=u;d+=2){let a=d===-u||d!==u&&(o.get(d-1)??0)<(o.get(d+1)??0)?o.get(d+1)??0:(o.get(d-1)??0)+1,h=a-d;for(;a<i&&h<s&&t[a]===e[h];)a++,h++;if(o.set(d,a),a>=i&&h>=s){g=!0;break}}}if(!g)return null;let r=i,l=s,m=[];for(let u=p.length-1;u>0;u--){let d=p[u],a=r-l,h=a===-u||a!==u&&(d.get(a-1)??0)<(d.get(a+1)??0)?a+1:a-1,R=d.get(h)??0,b=R-h;for(;r>R&&l>b;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;u>0&&(r===R?(m.push({op:"+",line:e[l-1],ai:r,bi:l-1}),l--):(m.push({op:"-",line:t[r-1],ai:r-1,bi:l}),r--))}for(;r>0&&l>0;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;for(;r>0;)m.push({op:"-",line:t[r-1],ai:r-1,bi:0}),r--;for(;l>0;)m.push({op:"+",line:e[l-1],ai:0,bi:l-1}),l--;return m.reverse()}function ce(t){let e=Buffer.byteLength(t,"utf8");if(e<=J+Q)return{diff:t,truncated:!1};let n=Buffer.from(t,"utf8"),i=J;for(;i>0&&(n[i]&192)===128;)i--;let s=e-Q;for(;s<e&&(n[s]&192)===128;)s++;let f=n.subarray(0,i).toString("utf8"),o=n.subarray(s).toString("utf8");return{diff:`${f}
|
|
7
7
|
\u2026 [diff truncated: ${e-i-(e-s)} bytes omitted] \u2026
|
|
8
|
-
${o}`,truncated:!0}}function ae(t,e){let n=k(t),i=n.heads.get(e);if(typeof i!="string")return null;let s=[];for(let d of I(t).records){let a=d.source_head_moves?.[e];a!==void 0&&a!==s[s.length-1]&&s.push(a)}let f=s.lastIndexOf(i),o=f>0?s[f-1]:null;if(typeof o!="string"||o===i)return null;let p=D(t,n,o),g=D(t,n,i);if(p===null||g===null)return null;let{diff:r,truncated:l}=ce(re(p,g)),m=new Set,u=[];for(let d of n.edgesFrom(o))d.type!==x.DERIVES||n.nodeLabel.get(d.dst)!==v.USECASE||m.has(d.dst)||(m.add(d.dst),u.push({id:d.dst,title:String(n.getNode(d.dst)?.content.title??"")}));return{source_id:e,old_head:o,new_head:i,diff:r,...l?{truncated:!0}:{},prior_ucs:u}}function de(t,e,n){let i=t.getNode(e)?.content??{},s=t.getNode(n)?.content??{},o=[...new Set([...Object.keys(i),...Object.keys(s)])].sort().filter(p=>JSON.stringify(i[p])!==JSON.stringify(s[p]));return o.length>0?`updated: ${o.join(", ")}`:"updated"}function le(t,e,n,i,s,f,o){let p=new Set((o?.rows??[]).map(a=>a.matched_cid).filter(a=>!!a)),g=[];for(let[a,h]of n.superseded)h===null||a===h||e.superseded.has(a)||n.nodeLabel.get(a)===v.USECASE&&g.push({kind:"MODIFY",ref:y(n,a),old_cid:a,new_cid:h,summary:de(n,a,h)});let r=f.map(a=>({kind:"ADD",ref:y(n,a),cid:a}));for(let a of o?.rows??[])a.kind==="MODIFY"&&a.matched_cid?g.push({kind:"MODIFY",ref:y(n,a.matched_cid),old_cid:a.matched_cid,new_cid:null,summary:`${a.why} (staged)`}):a.kind==="ADD"&&r.push({kind:"ADD",ref:a.title,cid:null});let l=[],m=D(t,n,s),u=new Map;for(let{cid:a}of n.byLabel(v.USECASE)){if(!M(n,a)||p.has(a))continue;let h=n.derivesInto(a),R=h.filter(_=>String(_.props.source_id)===i);R.length===0||R.some(_=>_.props.source_cid===s)||R.some(_=>{let c=String(_.props.anchor),w=L(c);return w?.kind==="img-whole"?!1:w?.kind==="img-part"?oe(n,_,s):m!==null&&se(t,n,_,m,u)})||h.some(_=>{let c=String(_.props.source_id);if(c===i)return!1;let w=n.heads.get(c);return w!=null})||l.push({kind:"ARCHIVE",ref:y(n,a),cid:a,why:`evidence decayed: no quote from ${i} relocates into @${C(s)}, no other live source, no fresh evidence this run`,impact:W(n,n.tipOf(a))})}let d=(a,h)=>a.ref<h.ref?-1:a.ref>h.ref?1:0;return[...g.sort(d),...r.sort(d),...l.sort(d)]}function Ee(t,e,n,i,s){let f=e.rows.find(d=>d.temp_ref===n);if(!f)return{ok:!1,message:`held item ${n} missing from the plan artifact`};let o=f,p=k(t);if(o.matched_cid){let d=p.tipOf(o.matched_cid);if(p.superseded.get(d)===null)return{ok:!1,message:`use-case for "${o.title}" was retired meanwhile \u2014 nothing to update`};d!==o.matched_cid&&(o={...o,matched_cid:d,uc:{...o.uc,matches_existing:{cid:d}}})}let g=s?{edited:s}:"approve",r=ee(t,p,{source_id:e.source_id,...e.staged_source_cid!==void 0?{staged_source_cid:e.staged_source_cid}:{},rows:[o]},new Map([[o.temp_ref,g]]),i);if(r.errors)return{ok:!1,message:r.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")};let l=k(t),m=o.matched_cid?l.tipOf(o.matched_cid):r.record?.nodes.find(d=>d.label==="usecase")?.cid??r.record?.review[0]?.id;return{ok:!0,ref:m?y(l,m):o.title,kind:o.kind}}async function Re(t,e,n,i={}){let s=k(t),f=s.heads.get(e)??null,o=new Set(s.staleList().filter(c=>c.state==="stale").map(c=>c.cid)),p=await n.reingest(e);if(p.status==="unchanged"&&!i.resumeHeld)return{source_id:e,changed:!1,head:{status:p.status,before:f,after:p.cid},note:`nothing to reconcile \u2014 ${e} is unchanged`,skipped_arms:q,changeset:[],rows:[]};let g=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await n.reextract(e),r=k(t),l=g.minted.map(c=>{let w=y(r,c);return{kind:"ADD",origin:"content-change",ref:w,reason:`new use-case extracted from ${e}`,provenance:`extraction commit \u2014 DERIVES ${e} @ ${C(p.cid)}`,action:`kane-cli design tests --use-case ${w}`}}),m=r.staleList().filter(c=>c.state==="stale"&&!o.has(c.cid)&&M(r,c.cid)).map(c=>c.cid),u=m.map(c=>{let w=y(r,c),E=ne.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:z(r,c),action:E?`kane-cli maintain evolve ${w}`:`kane-cli design explain ${w}`}}),d=[],a=[];for(let c of g.held?.rows??[])if(c.kind==="ADD")d.push({kind:"ADD",origin:"content-change",ref:c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit + design"});else{let w=c.matched_cid?r.tipOf(c.matched_cid):null,E=w?r.getNode(w)?.content.criteria??[]:[],T=(c.uc.updated?.criteria??[]).map(O=>typeof O=="string"?O:O.text),Z=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?W(r,w,Z):void 0;a.push({kind:"MODIFY",origin:"content-change",ref:c.matched_cid?y(r,c.matched_cid):c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...P?{impact:P}:{}})}let h=new Set;for(let c of[...g.minted,...g.matched])h.add(r.tipOf(c));for(let c of g.held?.rows??[])c.matched_cid&&h.add(r.tipOf(c.matched_cid));for(let c of m){let w=X(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await F(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=X(r,w.tip);!E||!h.has(r.tipOf(E))||R.push({kind:"ADD",origin:"content-change",ref:c.ref,reason:c.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${y(r,E)}`,action:c.ready_command})}let b=[];for(let{cid:c}of r.byLabel(v.USECASE))M(r,c)&&r.stale(c)==="orphaned"&&b.push({kind:"REMOVE",ref:y(r,c),reason:"orphaned \u2014 no live source evidences this use-case",provenance:z(r,c),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,_=[...l.sort($),...d.sort($),...R.sort($),...a.sort($),...u.sort($),...b.sort($)].filter(c=>{let w=`${c.kind}\0${c.ref}`;return S.has(w)?!1:(S.add(w),!0)});return{source_id:e,changed:!0,head:{status:p.status,before:f,after:p.cid},note:te,skipped_arms:q,changeset:le(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function ye(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-
|
|
8
|
+
${o}`,truncated:!0}}function ae(t,e){let n=k(t),i=n.heads.get(e);if(typeof i!="string")return null;let s=[];for(let d of I(t).records){let a=d.source_head_moves?.[e];a!==void 0&&a!==s[s.length-1]&&s.push(a)}let f=s.lastIndexOf(i),o=f>0?s[f-1]:null;if(typeof o!="string"||o===i)return null;let p=D(t,n,o),g=D(t,n,i);if(p===null||g===null)return null;let{diff:r,truncated:l}=ce(re(p,g)),m=new Set,u=[];for(let d of n.edgesFrom(o))d.type!==x.DERIVES||n.nodeLabel.get(d.dst)!==v.USECASE||m.has(d.dst)||(m.add(d.dst),u.push({id:d.dst,title:String(n.getNode(d.dst)?.content.title??"")}));return{source_id:e,old_head:o,new_head:i,diff:r,...l?{truncated:!0}:{},prior_ucs:u}}function de(t,e,n){let i=t.getNode(e)?.content??{},s=t.getNode(n)?.content??{},o=[...new Set([...Object.keys(i),...Object.keys(s)])].sort().filter(p=>JSON.stringify(i[p])!==JSON.stringify(s[p]));return o.length>0?`updated: ${o.join(", ")}`:"updated"}function le(t,e,n,i,s,f,o){let p=new Set((o?.rows??[]).map(a=>a.matched_cid).filter(a=>!!a)),g=[];for(let[a,h]of n.superseded)h===null||a===h||e.superseded.has(a)||n.nodeLabel.get(a)===v.USECASE&&g.push({kind:"MODIFY",ref:y(n,a),old_cid:a,new_cid:h,summary:de(n,a,h)});let r=f.map(a=>({kind:"ADD",ref:y(n,a),cid:a}));for(let a of o?.rows??[])a.kind==="MODIFY"&&a.matched_cid?g.push({kind:"MODIFY",ref:y(n,a.matched_cid),old_cid:a.matched_cid,new_cid:null,summary:`${a.why} (staged)`}):a.kind==="ADD"&&r.push({kind:"ADD",ref:a.title,cid:null});let l=[],m=D(t,n,s),u=new Map;for(let{cid:a}of n.byLabel(v.USECASE)){if(!M(n,a)||p.has(a))continue;let h=n.derivesInto(a),R=h.filter(_=>String(_.props.source_id)===i);R.length===0||R.some(_=>_.props.source_cid===s)||R.some(_=>{let c=String(_.props.anchor),w=L(c);return w?.kind==="img-whole"?!1:w?.kind==="img-part"?oe(n,_,s):m!==null&&se(t,n,_,m,u)})||h.some(_=>{let c=String(_.props.source_id);if(c===i)return!1;let w=n.heads.get(c);return w!=null})||l.push({kind:"ARCHIVE",ref:y(n,a),cid:a,why:`evidence decayed: no quote from ${i} relocates into @${C(s)}, no other live source, no fresh evidence this run`,impact:W(n,n.tipOf(a))})}let d=(a,h)=>a.ref<h.ref?-1:a.ref>h.ref?1:0;return[...g.sort(d),...r.sort(d),...l.sort(d)]}function Ee(t,e,n,i,s){let f=e.rows.find(d=>d.temp_ref===n);if(!f)return{ok:!1,message:`held item ${n} missing from the plan artifact`};let o=f,p=k(t);if(o.matched_cid){let d=p.tipOf(o.matched_cid);if(p.superseded.get(d)===null)return{ok:!1,message:`use-case for "${o.title}" was retired meanwhile \u2014 nothing to update`};d!==o.matched_cid&&(o={...o,matched_cid:d,uc:{...o.uc,matches_existing:{cid:d}}})}let g=s?{edited:s}:"approve",r=ee(t,p,{source_id:e.source_id,...e.staged_source_cid!==void 0?{staged_source_cid:e.staged_source_cid}:{},rows:[o]},new Map([[o.temp_ref,g]]),i);if(r.errors)return{ok:!1,message:r.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")};let l=k(t),m=o.matched_cid?l.tipOf(o.matched_cid):r.record?.nodes.find(d=>d.label==="usecase")?.cid??r.record?.review[0]?.id;return{ok:!0,ref:m?y(l,m):o.title,kind:o.kind}}async function Re(t,e,n,i={}){let s=k(t),f=s.heads.get(e)??null,o=new Set(s.staleList().filter(c=>c.state==="stale").map(c=>c.cid)),p=await n.reingest(e);if(p.status==="unchanged"&&!i.resumeHeld)return{source_id:e,changed:!1,head:{status:p.status,before:f,after:p.cid},note:`nothing to reconcile \u2014 ${e} is unchanged`,skipped_arms:q,changeset:[],rows:[]};let g=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await n.reextract(e),r=k(t),l=g.minted.map(c=>{let w=y(r,c);return{kind:"ADD",origin:"content-change",ref:w,reason:`new use-case extracted from ${e}`,provenance:`extraction commit \u2014 DERIVES ${e} @ ${C(p.cid)}`,action:`kane-cli design tests --use-case ${w}`}}),m=r.staleList().filter(c=>c.state==="stale"&&!o.has(c.cid)&&M(r,c.cid)).map(c=>c.cid),u=m.map(c=>{let w=y(r,c),E=ne.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:z(r,c),action:E?`kane-cli maintain evolve ${w}`:`kane-cli design explain ${w}`}}),d=[],a=[];for(let c of g.held?.rows??[])if(c.kind==="ADD")d.push({kind:"ADD",origin:"content-change",ref:c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit + design"});else{let w=c.matched_cid?r.tipOf(c.matched_cid):null,E=w?r.getNode(w)?.content.criteria??[]:[],T=(c.uc.updated?.criteria??[]).map(O=>typeof O=="string"?O:O.text),Z=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?W(r,w,Z):void 0;a.push({kind:"MODIFY",origin:"content-change",ref:c.matched_cid?y(r,c.matched_cid):c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...P?{impact:P}:{}})}let h=new Set;for(let c of[...g.minted,...g.matched])h.add(r.tipOf(c));for(let c of g.held?.rows??[])c.matched_cid&&h.add(r.tipOf(c.matched_cid));for(let c of m){let w=X(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await F(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=X(r,w.tip);!E||!h.has(r.tipOf(E))||R.push({kind:"ADD",origin:"content-change",ref:c.ref,reason:c.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${y(r,E)}`,action:c.ready_command})}let b=[];for(let{cid:c}of r.byLabel(v.USECASE))M(r,c)&&r.stale(c)==="orphaned"&&b.push({kind:"REMOVE",ref:y(r,c),reason:"orphaned \u2014 no live source evidences this use-case",provenance:z(r,c),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,_=[...l.sort($),...d.sort($),...R.sort($),...a.sort($),...u.sort($),...b.sort($)].filter(c=>{let w=`${c.kind}\0${c.ref}`;return S.has(w)?!1:(S.add(w),!0)});return{source_id:e,changed:!0,head:{status:p.status,before:f,after:p.cid},note:te,skipped_arms:q,changeset:le(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function ye(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-JO5NJENZ.js"),{convertPdf:s}=await import("./pdf-convert-OZIRUADA.js"),{convertDocx:f}=await import("./docx-convert-JMUMT5C4.js"),o=await i({contextDir:t,filePath:e,asId:n,converters:{pdf:s,docx:f}});return{status:o.status,cid:o.cid}}}function be(t,e,n,i){return async()=>{let f=(i??(await import("./dispatch-2PBSJ7YW.js")).findProvider)(e);if(!f)throw new Error(`the remote re-ingest failed \u2014 no provider matches '${e}'`);let o=await f.ingest(e,void 0,{out:n.out,err:n.err,confirm:async()=>!0,isTTY:!1},t,void 0);if(o.code!==0||!o.result)throw new Error("the remote re-ingest failed \u2014 fix the reported problem and re-run");return{status:o.result.status,cid:o.result.source_cid}}}function xe(t,e={}){return async n=>{let i=[],[{runExtract:s},{resolveAgentAuthEnv:f},{runAgent:o},{preflightTurn:p}]=await Promise.all([import("./run-5IYI2TJI.js"),import("./spawner-ZSYJQGQW.js"),import("./bridge-GQJ35GTL.js"),import("./turn-preflight-JGYT7LXP.js")]),g=await f(),r=new Set(k(t).byLabel(v.USECASE).map(S=>S.cid)),l=ae(t,n)??void 0,m=0,u=await s({mode:"override",source:n,...l?{changeContext:l}:{}},{contextDir:t,agent:o,preflightTurn:()=>p(g),ask:async()=>[],review:async S=>{if(!e.stage)return new Map(S.map(c=>[c.temp_ref,{resolution:c.matches_existing&&c.changed?"edited":"skipped"}]));let _=new Map;for(let c of S){if(c.matches_existing&&!c.changed){_.set(c.temp_ref,{resolution:"skipped"});continue}i.push({kind:c.matches_existing?"MODIFY":"ADD",temp_ref:c.temp_ref,title:c.title,why:c.matches_existing?`updated: ${Object.keys(c.updated??{}).join(", ")||"content"}`:`newly extracted from ${n}`,...c.matches_existing?{matched_cid:c.matches_existing.cid,updated:c.updated}:{},uc:c}),_.set(c.temp_ref,{resolution:"rejected"})}return _},confirmStale:async()=>!1,out:S=>e.hostOut?.(S),progress:S=>e.hostProgress?.(S),emit:S=>{S.type==="commit"&&typeof S.assumed=="number"&&(m+=S.assumed),e.hostEmit?.(S)},isTTY:!1,auth:g});if(u!==0)throw new Error(`reconcile: re-extract of ${n} failed (exit ${u})`);let d=k(t),a=d.heads.get(n),h=[],R=[];if(typeof a=="string"){let S=new Set;for(let _ of d.edgesFrom(a))_.type!==x.DERIVES||d.nodeLabel.get(_.dst)!==v.USECASE||S.has(_.dst)||(S.add(_.dst),!(e.stage&&d.trust.get(_.dst)==="archived")&&(r.has(_.dst)?R:h).push(_.dst))}let b=k(t).heads.get(n);return{minted:h,matched:R,defaultsTaken:m,...e.stage?{held:{source_id:n,...b!=null?{staged_source_cid:b}:{},rows:i}}:{}}}}export{ee as a,W as b,q as c,te as d,M as e,X as f,ne as g,re as h,ce as i,ae as j,Ee as k,Re as l,ye as m,be as n,xe as o};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as p,c as E,d as j,e as y,f as M,g as C,i as A,l as D,m as F,q as T,s as $,t as O}from"./chunk-DEZ7CXGM.js";import{c as H,d as z}from"./chunk-2YQ6TW77.js";import{a as k}from"./chunk-
|
|
2
|
+
import{b as p,c as E,d as j,e as y,f as M,g as C,i as A,l as D,m as F,q as T,s as $,t as O}from"./chunk-DEZ7CXGM.js";import{c as H,d as z}from"./chunk-2YQ6TW77.js";import{a as k}from"./chunk-BRTARADN.js";import{p as B,q as R}from"./chunk-56PAQAX5.js";import{a as P}from"./chunk-OFW3ZVTP.js";import{e as q}from"./chunk-UR6MHSHU.js";import{existsSync as f,mkdirSync as V,readFileSync as Z,renameSync as N,writeFileSync as K}from"fs";import{join as Q}from"path";function fe(e){D(p(e));let t=p(e);if(!f(t))return;let n=Q(t,"meta.json"),r=y(e);if(f(n)&&!f(r))try{V(j(e),{recursive:!0}),N(n,r)}catch(o){process.stderr.write(`warn: meta.json migration failed: ${o.message}
|
|
3
3
|
`)}let i=C(e);if(f(i)){let o="python";try{let c=new k().load();c.code_export?.language&&(o=c.code_export.language)}catch{}let a=M(e,"playwright",o);if(!f(a))try{N(i,a)}catch(c){process.stderr.write(`warn: generated-code migration failed: ${c.message}
|
|
4
4
|
`)}}if(f(r))try{let o=JSON.parse(Z(r,"utf8"));"md5sum"in o&&(delete o.md5sum,K(r,JSON.stringify(o,null,2)+`
|
|
5
5
|
`,"utf8"))}catch(o){process.stderr.write(`warn: meta.json md5sum strip failed: ${o.message}
|
|
6
|
-
`)}}async function ye(e){if(!e.isInteractive)return{recovered:!1};if(W(e.creds))return{recovered:!1};let{SingleShotApp:t}=await import("./SingleShotApp-
|
|
6
|
+
`)}}async function ye(e){if(!e.isInteractive)return{recovered:!1};if(W(e.creds))return{recovered:!1};let{SingleShotApp:t}=await import("./SingleShotApp-AY3XFEYT.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{render:r}=await import("./build-JIKYOZUH.js"),i=await import("./react-QWOAB3TB.js"),o={current:null},a={current:!1},{waitUntilExit:c,unmount:l}=r(i.default.createElement(n,null,i.default.createElement(t,{resultRef:o,mode:"login",loginCompleteRef:a})),{exitOnCtrlC:!1});R(()=>l()),await c();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),a.current?{recovered:!0}:(B(0,"Startup gate cancelled"),{recovered:!1})}function W(e){let t=e.getActiveProfile(),n=e.getDefaultEnv();if(!t||!!!(e.loadBasicAuth(t,n)||e.loadCredentials(t,n)))return!1;let i=e.loadProfileConfig(t,n)??{};return!!i.project_id&&!!i.folder_id}var J=q(H(),1);import{existsSync as v,readFileSync as U,readdirSync as X,statSync as Y}from"fs";import{dirname as ee,isAbsolute as te,join as g,relative as x,resolve as re,sep as h}from"path";import{createHash as ne}from"crypto";var S="testmd-bundle.json",d=class extends Error{constructor(t){super(t),this.name="BundleUsageError"}},_=e=>e.split(h).join("/");function I(e){if(!v(e))return[];let t=[];for(let n of X(e).sort()){let r=g(e,n);Y(r).isDirectory()?t.push(...I(r)):t.push(r)}return t}function se(e){let t=e.map(r=>ee(r).split(h)),n=t[0];for(let r of t.slice(1)){let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;n=n.slice(0,i)}return n.join(h)||h}function ie(e){for(let t of e){let n=F(t,U(t,"utf8"));for(let r of n.steps)if(r.body.kind==="import_ref"&&te(r.body.path))throw new d(`bundle sync: absolute @import is not portable after unzip: ${t} step ${r.index} (@import ${r.body.path})`)}}function G(e){let t=re(e),n=T(t);if(!n?.commit_id||!n?.test_id)throw new d(`bundle sync: ${t} is not authored \u2014 run \`kane-cli testmd run\` first (output-<stem>/.internal/meta.json needs commit_id + test_id)`);let r;try{r=O(t)}catch(s){throw s instanceof $?new d(`bundle sync: ${s.message}`):s}let i=[t];for(let s of r.steps)for(let u of s.trace.slice(1))i.includes(u.file)||i.push(u.file);ie(i);let o=[];for(let s of r.unitFiles){if(s.file===t)continue;let u=p(s.file);o.includes(u)||o.push(u)}let a=[...i],c=s=>{v(s)&&a.push(s)};c(E(t)),a.push(y(t)),c(g(p(t),".internal","execution.json")),a.push(...I(A(t)));for(let s of o)c(g(s,"Result.md")),a.push(...I(g(s,".internal","steps")));let l=se(a);if(v(g(l,S)))throw new d(`bundle sync: a real file named ${S} exists at the zip root (${l}) \u2014 it would collide with the generated manifest`);let b=a.map(s=>{let u=U(s);return{abs:s,rel:_(x(l,s)),sha256:ne("sha256").update(u).digest("hex"),bytes:u.length}}).sort((s,u)=>s.rel<u.rel?-1:1),m=_(x(l,t)),L={schema_version:2,entry:m,commit_id:n.commit_id,test_id:n.test_id,testcase_id:n.testcase_id??null,project_id:n.project_id??null,folder_id:n.folder_id??null,org_id:n.org_id??null,created_at:new Date().toISOString(),producer:{name:"kane-cli",version:P},files:b.map(s=>({path:s.rel,sha256:s.sha256,bytes:s.bytes})),units:r.unitFiles.filter(s=>s.file!==t).map(s=>({path:_(x(l,s.file)),kind:s.kind}))};return{zipRoot:l,entry:m,files:b,manifest:L}}var w=e=>e instanceof Error?e.message:String(e);function oe(e){return new Promise((t,n)=>{let r=(0,J.default)("zip",{zlib:{level:6}}),i=[];r.on("data",o=>i.push(o)),r.on("error",n),r.on("end",()=>t(Buffer.concat(i))),r.append(JSON.stringify(e.manifest,null,2)+`
|
|
7
7
|
`,{name:S});for(let o of e.files)r.file(o.abs,{name:o.rel});r.finalize()})}async function ae(e){let{plan:t,controller:n,testId:r,sessionId:i,commitId:o}=e,a;try{a=await oe(t)}catch(l){return{ok:!1,stage:"zip",error:w(l)}}let c;try{let l={key:"testmd",content_type:"application/zip",filename:`${o}-testmd.zip`},m=(await n.getPresignedUrls(r,i,[l])).urls?.testmd?.upload_url;if(!m)return{ok:!1,stage:"presign",error:"presign response missing testmd upload_url"};c=m}catch(l){return{ok:!1,stage:"presign",error:w(l)}}try{await z(c,a,"application/zip")}catch(l){return{ok:!1,stage:"upload",error:w(l)}}return{ok:!0,bytes:a.length}}async function Ee(e){let t;try{t=G(e.sourcePath)}catch(n){return n instanceof d?{ok:!1,stage:"collect",error:n.message}:{ok:!1,stage:"collect",error:w(n)}}return ae({...e,plan:t})}function je(e){return e.shouldUploadPipeline&&e.uploadSucceeded&&!!e.metaCommitId&&!!e.metaTestId}export{fe as a,ye as b,G as c,Ee as d,je as e};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as Ke}from"./chunk-ZKSN2SJ7.js";import{a as ze,b as ue}from"./chunk-3Q6WAK6P.js";import{a as Ue,b as We}from"./chunk-JZ26R6UL.js";import{a as Z,b as Le,e as le,f as de,g as Be,h as He}from"./chunk-
|
|
2
|
+
import{a as Ke}from"./chunk-ZKSN2SJ7.js";import{a as ze,b as ue}from"./chunk-3Q6WAK6P.js";import{a as Ue,b as We}from"./chunk-JZ26R6UL.js";import{a as Z,b as Le,e as le,f as de,g as Be,h as He}from"./chunk-ATWDQCDA.js";import{a as Ne,c as je,d as Fe,e as me,f as Ge}from"./chunk-ZGBSGZZM.js";import{a as Ae,b as Ie,c as Oe}from"./chunk-EXERQHXV.js";import{a as Re,b as Ce,c as Te}from"./chunk-BB2W35TW.js";import{a as qe}from"./chunk-L2TV4G56.js";import{c as Pe}from"./chunk-6KPPGMO2.js";import{a as $e,e as Ee}from"./chunk-GFKCTYCA.js";import{a as Me}from"./chunk-IMR64OCZ.js";import{c as Ve}from"./chunk-V444REBC.js";import{b as ye,c as we,d as ve,e as ae,h as oe,i as ce}from"./chunk-ZSXDZI56.js";import{b as ne}from"./chunk-VZ7KXRXB.js";import{a as be,b as re}from"./chunk-IDX3TOPY.js";import{A as U}from"./chunk-TH47OOBV.js";import{f as De}from"./chunk-DUAXZYAD.js";import{a as ke,e as xe,f as Se}from"./chunk-DBIBROYW.js";import{d as z,e as X}from"./chunk-WXHQYYD5.js";import{a as _e}from"./chunk-5EOX4MEY.js";import{mkdirSync as St,appendFileSync as Dt,rmdirSync as dt}from"fs";import{randomBytes as $t}from"crypto";import{dirname as mt,join as he}from"path";function Qe(t,e){let n=[];for(let i of e??[]){let g=t.resolve(i.ref)?.tip??null;g!==i.cid&&n.push({ref:i.ref,pinned:i.cid,now:g})}return n}import{existsSync as ge,readFileSync as pe,readdirSync as pt}from"fs";import{join as te}from"path";var Ye=`
|
|
3
3
|
version: 1
|
|
4
4
|
techniques:
|
|
5
5
|
- id: eqp
|
|
@@ -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-AO3PBE2V.js";import{m as d,x as o}from"./chunk-OFW3ZVTP.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};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as G}from"./chunk-MMBBQ4OZ.js";import{j as O}from"./chunk-DN3E6RT6.js";import{d as E,e as z}from"./chunk-4JOD47QI.js";import{a as X}from"./chunk-RZ4F3BHX.js";import{spawn as Ie}from"child_process";import{existsSync as $e,readFileSync as Ne}from"fs";import{homedir as Ee}from"os";import{dirname as Q,join as S}from"path";import{access as we,mkdir as W,readFile as be}from"fs/promises";import{homedir as ye}from"os";import{arch as Ae,platform as xe}from"process";import{join as D}from"path";var Se=35,ke="google_apis",Te="KaneCLI_Pixel_API35",De="KaneAI_Pixel_API35";function yt(t){return t===De?Te:t}var Pe=1;function Me(t,e){return t==="darwin"&&e==="arm64"?"arm64-v8a":"x86_64"}function _e(){return{home:ye(),os:xe,arch:Ae}}async function Y(t){try{return await we(t),!0}catch{return!1}}var V=class{deps;constructor(e={}){this.deps={..._e(),...e}}paths(){let e=D(this.deps.home,".testmuai","kaneai","mobile"),r=D(e,"android-sdk");return{root:r,emulatorDir:D(r,"emulator"),systemImageDir:D(r,"system-images",`android-${Se}`,ke,Me(this.deps.os,this.deps.arch)),avdHome:D(e,"avd"),manifest:D(r,"sdk-manifest.json")}}environment(){let e=this.paths();return{ANDROID_HOME:e.root,ANDROID_SDK_ROOT:e.root,ANDROID_AVD_HOME:e.avdHome}}async ensureSdkRootMarkers(){let e=this.paths().root;await W(D(e,"platforms"),{recursive:!0}),await W(D(e,"platform-tools"),{recursive:!0})}async status(){let e=this.paths(),r=null;try{r=JSON.parse(await be(e.manifest,"utf8"))}catch{}if(!r||r.schemaVersion!==Pe)return{emulator:!1,systemImage:!1};let o=this.deps.os==="win32"?"emulator.exe":"emulator";return{emulator:!!r.components.emulator&&await Y(D(e.emulatorDir,o)),systemImage:!!r.components.systemImage&&await Y(D(e.systemImageDir,"system.img"))}}},Z;function L(){return Z??=new V,Z}var H="android",Oe="http://127.0.0.1:4723/status",Re=2e3,ee=12e4,Ce=1e3,Le=3e5;var Fe=5,te="Run `kane-cli doctor --target emulator --install` to install the managed Appium tree.",Be={device:"ready",unauthorized:"unauthorized",offline:"offline"};function Ue(t){let e={};for(let r of t){let o=r.indexOf(":");o<=0||(e[r.slice(0,o)]=r.slice(o+1))}return e}function qe(t){let e=[];for(let r of t.split(`
|
|
3
|
+
`)){let o=r.trim();if(!o||o.startsWith("*"))continue;let c=o.toLowerCase();if(c.startsWith("list of devices")||c.startsWith("adb server"))continue;let f=o.split(/\s+/),p=f[0],v=f[1];if(!p||!v||!p.startsWith("emulator-"))continue;let h=Ue(f.slice(2)),b=h.model?h.model.replace(/_/g," "):void 0;e.push({platform:H,kind:"emulator",id:p,displayName:b??p,state:Be[v]??"offline"})}return e}function ie(t){let e=[];for(let r of t.split(`
|
|
4
|
+
`)){let o=r.trim();o&&/^[A-Za-z0-9._-]+$/.test(o)&&(e.includes(o)||e.push(o))}return e}function Ve(t){for(let e of t.split(`
|
|
5
|
+
`)){let r=e.trim();if(!(!r||r==="OK"))return r}}function He(t){let e=/^Version\s+(\S+)/m.exec(t);return e?.[1]?e[1].split("-")[0]:/Android Debug Bridge version\s+(\S+)/.exec(t)?.[1]}function je(t){let e=[];for(let r of t.split(`
|
|
6
|
+
`)){let o=r.trim();if(!o.startsWith("package:"))continue;let c=o.slice(8).trim();c&&!e.includes(c)&&e.push(c)}return e.sort()}function Je(t){let e=Number(t.trim());return Number.isInteger(e)&&e>0?e:void 0}function Ke(t){return[...new Set(t.split(",").map(e=>e.trim()).filter(Boolean))]}var Xe=[{match:/INSTALL_FAILED_VERIFICATION|verif(?:ier|ication)/i,hint:`Package verification blocked the install. Disable it for adb installs:
|
|
7
|
+
adb -s <device> shell settings put global verifier_verify_adb_installs 0`},{match:/INSTALL_FAILED_UPDATE_INCOMPATIBLE|INSTALL_FAILED_VERSION_DOWNGRADE|signatures do not match/i,hint:`A different build of this package is already installed. Uninstall it first:
|
|
8
|
+
adb -s <device> uninstall <package>`},{match:/INSUFFICIENT_STORAGE/i,hint:"The device is out of storage. Free space on the device and retry."}];function ze(t){for(let{match:e,hint:r}of Xe)if(e.test(t))return r}function j(t,e,r=Fe){let o=t.toLowerCase(),c=e.filter(v=>v.toLowerCase().includes(o)),f=Math.max(6,Math.floor(o.length/2)),p=e.filter(v=>!c.includes(v)&&Ge(v.toLowerCase(),o)>=f);return[...c,...p].slice(0,r)}function Ge(t,e){let r=Math.min(t.length,e.length),o=0;for(;o<r&&t[o]===e[o];)o++;return o}function ne(t){return t&&/^hw\.device\.name\s*=\s*(.+)\s*$/m.exec(t)?.[1]?.trim()||void 0}function We(){return X(Oe,{signal:AbortSignal.timeout(Re)}).then(t=>t.ok,()=>!1)}function Ye(t,e,r){Ie(t,e,{stdio:"ignore",detached:!0,...r?{env:{...process.env,...r}}:{}}).unref()}function Ze(){return{exec:E,spawnDetached:Ye,fileExists:$e,env:process.env,home:Ee(),os:process.platform,probeAppiumServer:We,now:()=>Date.now(),sleep:z,mobileDeps:{status:t=>O().status(t),environment:t=>O().environment(t)},sdkSuite:{status:()=>L().status(),environment:()=>L().environment(),emulatorPath:()=>{let t=L().paths().emulatorDir;return S(t,process.platform==="win32"?"emulator.exe":"emulator")},ensureSdkRootMarkers:()=>L().ensureSdkRootMarkers()}}}function re(t={}){let e={...Ze(),...t},r={},o=new Set;function c(i){return e.os==="win32"?`${i}.exe`:i}function f(i){if(e.readAvdConfig)return e.readAvdConfig(i);let n=[e.env.ANDROID_AVD_HOME,S(e.home,".android","avd"),e.sdkSuite.environment().ANDROID_AVD_HOME];for(let s of n){if(!s)continue;let a=S(s,`${i}.avd`,"config.ini");try{if(e.fileExists(a))return Ne(a,"utf8")}catch{}}}function p(){return e.os==="win32"?"appium.cmd":"appium"}function v(){let i=[];for(let n of["ANDROID_HOME","ANDROID_SDK_ROOT"]){let s=e.env[n];s&&s.trim()!==""&&i.push(s.trim())}return e.os==="darwin"?i.push(S(e.home,"Library","Android","sdk")):e.os==="win32"?i.push(S(e.home,"AppData","Local","Android","Sdk")):i.push(S(e.home,"Android","Sdk")),i}function h(i){let n=i==="adb"?"platform-tools":"emulator";return v().map(s=>S(s,n,c(i)))}async function b(i){let n=e.os==="win32"?"where":"which",s=await e.exec(n,[c(i)],{timeoutMs:5e3});if(s.code!==0)return null;let a=s.stdout.split(`
|
|
9
|
+
`)[0]?.trim();return a&&a!==""?a:null}async function $(i){let n=await e.exec(i,["-version"],{timeoutMs:1e4});return/Android emulator version/i.test(`${n.stdout}
|
|
10
|
+
${n.stderr}`)}async function M(i){if(i==="adb"){let n=G(e.env);if(n){let a=S(n.platformToolsDir,c("adb"));if(e.fileExists(a)){let d={path:a,source:"sdk"};return r[i]=d,d}return delete r[i],null}if((await e.mobileDeps.status("emulator")).installed){let a=await e.mobileDeps.environment("emulator");if(a.platformToolsDir){let d={path:S(a.platformToolsDir,c("adb")),source:"local"};return r[i]=d,d}}return delete r[i],null}if(i==="emulator"){if((await e.sdkSuite.status()).emulator){let d={path:e.sdkSuite.emulatorPath(),source:"local"};return r[i]=d,d}let s=h(i).filter(d=>e.fileExists(d)),a=await b(i);a&&!s.includes(a)&&s.push(a);for(let d of s){if(!await $(d))continue;let m={path:d,source:"sdk"};return r[i]=m,m}}return delete r[i],null}async function l(){let i=await M("adb");if(!i)throw new Error("Managed adb is not installed.\nRun `kane-cli doctor --target emulator --install` to install the pinned Android platform-tools.");return i.path}async function u(i){let n=await e.exec(i,["devices","-l"],{timeoutMs:2e4});return qe(n.stdout)}async function g(i,n){let s=await e.exec(i,["-s",n,"shell","getprop","ro.boot.qemu.avd_name"],{timeoutMs:1e4});if(s.code===0){let d=s.stdout.split(`
|
|
11
|
+
`)[0]?.trim();if(d)return d}let a=await e.exec(i,["-s",n,"emu","avd","name"],{timeoutMs:1e4});if(a.code===0)return Ve(a.stdout)}async function y(i){let n=await M("emulator");if(!n)return[];let s=await e.exec(n.path,["-list-avds"],{timeoutMs:2e4}),a=s.code===0?ie(s.stdout):[];if(o.clear(),(await e.sdkSuite.status()).emulator){let m=await e.exec(n.path,["-list-avds"],{timeoutMs:2e4,env:{...e.env,...e.sdkSuite.environment()}});if(m.code===0)for(let w of ie(m.stdout))o.add(w),a.includes(w)||a.push(w)}return a.filter(m=>!i.has(m)).map(m=>{let w=ne(f(m));return{platform:H,kind:"emulator",id:m,displayName:m,state:"stopped",virtualName:m,...w?{modelIdentifier:w}:{}}})}async function k(){let i=await M("adb");if(!i)return[];let n=await u(i.path),s=new Set;for(let d of n){if(d.kind!=="emulator"||d.state!=="ready")continue;let m=await g(i.path,d.id);if(!m)continue;d.virtualName=m,d.displayName=m;let w=ne(f(m));w&&(d.modelIdentifier=w),s.add(m)}let a=await y(s);return[...n,...a]}function A(i,n){return[`${i} did not finish booting within ${ee/1e3}s.`,n?`It attached as ${n} but never reported sys.boot_completed=1.`:"It never attached to adb.","The emulator process is still running \u2014 check its window for errors.","Common causes: no hardware acceleration (install the Android Emulator","hypervisor driver / enable KVM), or a corrupt AVD (recreate it in","Android Studio's Device Manager)."].join(`
|
|
12
|
+
`)}async function _(i,n,s){let a=await M("emulator");if(!a)throw new Error("The Android `emulator` binary was not found, so AVDs cannot be booted.\nInstall it via Android Studio's SDK Manager (Android Emulator) and set ANDROID_HOME.");let d=new Set((await u(i)).map(B=>B.id)),m=o.has(n);m&&await e.sdkSuite.ensureSdkRootMarkers();let w=m?{...e.env,...e.sdkSuite.environment()}:void 0;e.spawnDetached(a.path,["-avd",n],w),s?.(`booting ${n}\u2026`);let T=e.now()+ee,x;for(;e.now()<T;){if(await e.sleep(Ce),!x){let I=(await u(i)).find(C=>C.kind==="emulator"&&!d.has(C.id));I&&(x=I.id,s?.(`${n} attached as ${x}, waiting for boot\u2026`));continue}if((await e.exec(i,["-s",x,"shell","getprop","sys.boot_completed"],{timeoutMs:1e4})).stdout.trim()==="1")return x}throw new Error(A(n,x))}async function P(i,n){let s=await l();if(i.state==="ready")return N(i,s);if(i.state==="unauthorized")throw new Error(`${i.displayName} (${i.id}) is UNAUTHORIZED. Accept the USB-debugging prompt on the device, then retry.`);if(i.state==="offline")throw new Error(`${i.displayName} (${i.id}) is offline. Reconnect it (USB) or re-run \`adb connect ${i.id}\` (wireless), then retry.`);let a=i.virtualName??i.id,d=await _(s,a,n);return N({...i,kind:"emulator",id:d,displayName:a,state:"ready",virtualName:a},s)}async function N(i,n){let[s,a,d,m]=await Promise.all([e.exec(n,["-s",i.id,"shell","getprop","ro.build.version.sdk"],{timeoutMs:1e4}),e.exec(n,["-s",i.id,"shell","getprop","ro.build.version.release"],{timeoutMs:1e4}),e.exec(n,["-s",i.id,"shell","getprop","ro.product.cpu.abilist"],{timeoutMs:1e4}),e.exec(n,["-s",i.id,"shell","getprop","ro.product.cpu.abi"],{timeoutMs:1e4})]),w=s.code===0?Je(s.stdout):void 0,T=a.code===0?a.stdout.trim():"",x=Ke(d.code===0&&d.stdout.trim()!==""?d.stdout:m.stdout);return{...i,...w!==void 0?{androidApiLevel:w}:{},...T!==""?{osVersion:T}:{},...x.length>0?{androidAbis:x}:{}}}async function F(i){let n=await l(),s=await e.exec(n,["-s",i.id,"shell","pm","list","packages","-3"],{timeoutMs:3e4});if(s.code!==0)throw new Error(`Could not list installed packages on ${i.id}: ${s.stderr.trim()||`adb exited ${s.code}`}`);return je(s.stdout)}async function ce(i){let n;try{let{default:s}=await import("./adbkit-apkreader-ORZBGCJQ.js");n=(await(await s.open(i)).readManifest())?.package}catch(s){let a=s instanceof Error?s.message:String(s);throw new Error(`Could not read the package name from ${i} (${a}).
|
|
13
|
+
Pass the package name explicitly with --app <package>.`)}if(typeof n!="string"||n.trim()==="")throw new Error(`${i} has no package name in its manifest.
|
|
14
|
+
Pass the package name explicitly with --app <package>.`);return n.trim()}async function me(i,n,s){let a=await l();s?.(`installing ${n} on ${i.id}\u2026`);let d=await e.exec(a,["-s",i.id,"install","-r",n],{timeoutMs:Le}),m=`${d.stdout}
|
|
15
|
+
${d.stderr}`;if(d.code===0&&!/\bFailure\b/i.test(m))return;let w=ze(m),T=[`Installing ${n} on ${i.id} failed (adb exited ${d.code}).`,m.trim()];throw w&&T.push("",w),new Error(T.filter(x=>x!=="").join(`
|
|
16
|
+
`))}async function pe(i,n,s){if(n.kind==="package"){let a=await F(i);if(a.includes(n.value))return n.value;let d=j(n.value,a),m=[`${n.value} is not installed on ${i.displayName} (${i.id}).`];throw d.length>0?m.push("Close matches:",...d.map(w=>` ${w}`)):m.push("Pass a local .apk path to --app to install it instead."),new Error(m.join(`
|
|
17
|
+
`))}if(n.kind!=="apk"){let a=n.kind==="aab"?"Android app bundles are not directly installable; build an APK first.":n.kind==="apks"?"Split bundles are not supported yet.":`${n.kind} artifacts are not installable on Android.`;throw new Error(a)}return await me(i,n.value,s),ce(n.value)}async function fe(){let i=await e.mobileDeps.status("emulator");return i.installed?{status:i,env:await e.mobileDeps.environment("emulator")}:null}async function ge(i={}){let n=[],s=await fe(),a=await e.mobileDeps.status("emulator"),d=await M("adb");if(d){let I=await e.exec(d.path,["version"],{timeoutMs:1e4}),C=He(I.stdout);n.push({id:"android.adb",fixedByBundle:!0,label:"adb",required:!0,status:"pass",detail:C?`platform-tools ${C} \xB7 ${d.path}`:d.path})}else n.push({id:"android.adb",fixedByBundle:!0,label:"adb",required:!0,status:"fail",detail:a.corrupt??"managed mobile dependencies are not installed",fixText:"Run `kane-cli doctor --target emulator --install` to download the managed mobile deps bundle under ~/.testmuai/kaneai/mobile."});let m=!i.appiumUrl;s?.env.appiumHome?n.push({id:"android.appium",fixedByBundle:!0,label:"Appium",required:m,status:"pass",detail:S(Q(s.env.appiumHome),"appium","node_modules",".bin",p())}):n.push({id:"android.appium",fixedByBundle:!0,label:"Appium",required:m,status:m?"fail":"info",detail:i.appiumUrl?`managed Appium not required because --appium-url is set (${i.appiumUrl})`:a.corrupt??"managed Appium is not installed",...m?{fixText:te}:{}}),n.push({id:"android.uiautomator2",fixedByBundle:!0,label:"uiautomator2 driver",required:m,status:s?"pass":m?"fail":"info",detail:s?"bundled in the managed mobile deps":i.appiumUrl?"managed driver not required because --appium-url is set":"not installed in the managed deps tree",...s||!m?{}:{fixText:te}});let w=S(e.home,".testmuai","kaneai","mobile","trees");e.fileExists(w)&&n.push({id:"android.legacy-trees",label:"legacy toolchain trees",required:!1,status:"info",detail:`${w} predates the deps bundle \u2014 removed automatically by the next bundle install`});let T=await b("adb");T&&n.push({id:"android.system-adb",label:"system adb",required:!1,status:"info",detail:`${T} (ignored; managed adb always wins and may restart its server)`});let x=await b("appium");x&&n.push({id:"android.system-appium",label:"system Appium",required:!1,status:"info",detail:`${x} (ignored; managed Appium always wins)`});let B=await e.sdkSuite.status(),q=await M("emulator");if(B.emulator?n.push({id:"android.emulator",label:"emulator",required:!1,status:"pass",detail:`managed emulator \xB7 ${e.sdkSuite.emulatorPath()}`}):q?n.push({id:"android.emulator",label:"emulator",required:!1,status:"info",detail:`${q.path} (system install)`}):n.push({id:"android.emulator",label:"emulator",required:!1,status:"info",detail:"not installed, so stopped AVDs are not listed. Install it with the Android SDK (Android Studio \u2192 SDK Manager \u2192 Android Emulator)."}),e.os==="darwin"){let I=await e.exec("sysctl",["-n","kern.hv_support"],{timeoutMs:5e3});n.push({id:"android.virtualization",label:"virtualization",required:!1,status:"info",detail:I.code===0&&I.stdout.trim()==="1"?"Hypervisor.framework available":"Hypervisor.framework not reported \u2014 emulator boots may hang"})}else e.os==="linux"?n.push({id:"android.virtualization",label:"virtualization",required:!1,status:"info",detail:e.fileExists("/dev/kvm")?"/dev/kvm present":"/dev/kvm missing \u2014 enable KVM or emulator boots will hang"}):n.push({id:"android.virtualization",label:"virtualization",required:!1,status:"info",detail:"not checked on this host"});return n}async function he(i){let n=await e.mobileDeps.environment("emulator"),s=[...n.dirs],a=r.emulator,d=a?.source==="sdk"?Q(a.path):void 0;return d&&!s.includes(d)&&s.push(d),{...n,dirs:s}}async function ve(i,n){let s=await l(),a=[];return n.appPackage&&a.push({label:`closing ${n.appPackage}`,file:s,args:["-s",i.id,"shell","am","force-stop",n.appPackage]}),n.shutdown&&a.push({label:`shutting down ${i.displayName}`,file:s,args:["-s",i.id,"emu","kill"]}),a}return{platform:H,available:()=>!0,checks:ge,discover:k,prepare:P,listApps:F,ensureApp:pe,teardownPlan:ve,toolEnv:he}}import{mkdtemp as se,readdir as Qe,rm as oe,writeFile as et}from"fs/promises";import{tmpdir as ae}from"os";import{join as R}from"path";var de="ios",tt=12e4,it=3e5,nt="an .ipa cannot be installed on a simulator \u2014 use a .zip of the .app build";function rt(t){let e=/\.iOS-(\d+)-(\d+)$/.exec(t);return e?`${e[1]}.${e[2]}`:void 0}function st(t){let e;try{e=JSON.parse(t)}catch{return[]}let r=[];for(let[o,c]of Object.entries(e.devices??{})){let f=rt(o);for(let p of c??[]){let v=typeof p.udid=="string"?p.udid:void 0,h=typeof p.name=="string"?p.name:void 0;if(!v||!h)continue;let b=p.state==="Booted"?"ready":p.state==="Shutdown"?"stopped":"offline",$=typeof p.deviceTypeIdentifier=="string"?p.deviceTypeIdentifier.replace(/^com\.apple\.CoreSimulator\.SimDeviceType\./,""):void 0;r.push({platform:de,kind:"simulator",id:v,displayName:f?`${h} (iOS ${f})`:h,state:b,virtualName:h,...f?{osVersion:f}:{},...$?{modelIdentifier:$}:{}})}}return r}function ot(t){let e;try{e=JSON.parse(t)}catch{return[]}let r=[];for(let[o,c]of Object.entries(e)){if(c?.ApplicationType!=="User")continue;let f=c.CFBundleIdentifier??o;r.includes(f)||r.push(f)}return r.sort()}function at(t){let e;try{e=JSON.parse(t)}catch{return[]}let r=[];for(let[o,c]of Object.entries(e)){let f=c?.CFBundleIdentifier??o;f&&!r.includes(f)&&r.push(f)}return r.sort()}var J=16;function dt(t){return/^Xcode (\d+(?:\.\d+)*)/m.exec(t)?.[1]}async function lt(t){let e=await se(R(ae(),"kane-app-unzip-")),r=()=>oe(e,{recursive:!0,force:!0}),o=await E("unzip",["-q",t,"-d",e],{timeoutMs:10*6e4});if(o.code!==0)throw await r(),new Error(`Could not unpack ${t}: ${o.stderr.trim()||`unzip exited ${o.code}`}`);for(let c of[e,R(e,"Payload")]){let f;try{f=await Qe(c)}catch{continue}let p=f.find(v=>v.toLowerCase().endsWith(".app"));if(p)return{appPath:R(c,p),cleanup:r}}throw await r(),new Error(`${t} does not contain a .app bundle.`)}async function ut(t){let e=await se(R(ae(),"kane-plist-"));try{let r=R(e,"input.plist");await et(r,t);let o=await E("plutil",["-convert","json","-o","-",r],{timeoutMs:15e3});if(o.code!==0)throw new Error(`plutil could not convert simctl output: ${o.stderr.trim()}`);return o.stdout}finally{await oe(e,{recursive:!0,force:!0})}}function ct(){return{exec:E,os:process.platform,convertPlistToJson:ut,mobileDeps:{status:()=>O().status("simulator"),environment:()=>O().environment("simulator")}}}function le(t={}){let e={...ct(),...t};async function r(l,u=3e4){return e.exec("xcrun",["simctl",...l],{timeoutMs:u})}async function o(){let l=await r(["list","devices","available","--json"]);return l.code!==0?[]:st(l.stdout)}async function c(){return o()}async function f(l,u){let g=await e.exec("open",["-a","Simulator","--args","-CurrentDeviceUDID",l],{timeoutMs:15e3});g.code!==0&&u?.(`could not open Simulator.app (${g.stderr.trim()||`exit ${g.code}`}); the device is booted and the run continues headless`)}async function p(l,u){if(l.state!=="ready"&&l.state!=="stopped")throw new Error(`${l.displayName} (${l.id}) is ${l.state}; open Simulator.app to inspect it, then retry.`);l.kind==="simulator"&&await f(l.id,u),l.state==="stopped"&&u?.(`booting ${l.displayName}\u2026`);let g=await r(["bootstatus",l.id,"-b"],tt);if(g.code!==0)throw new Error(`Could not boot ${l.displayName}: ${g.stderr.trim()||g.stdout.trim()||`simctl bootstatus exited ${g.code}`}`);let y=(await o()).find(k=>k.id===l.id);if(y?.state==="ready")return y;throw new Error(`${l.displayName} finished booting but simctl still reports it as ${y?.state??"missing"}.`)}async function v(l){let u=await r(["listapps",l.id]);if(u.code!==0)throw new Error(`Could not list apps on ${l.displayName}: ${u.stderr.trim()||`simctl exited ${u.code}`}`);return ot(await e.convertPlistToJson(u.stdout))}async function h(l){let u=R(l,"Info.plist"),g=await e.exec("plutil",["-convert","json","-o","-",u],{timeoutMs:15e3});if(g.code!==0)throw new Error(`${l} Info.plist could not be read: ${g.stderr.trim()||`plutil exited ${g.code}`}`);let y;try{y=JSON.parse(g.stdout)}catch{throw new Error(`${l} Info.plist did not contain valid JSON from plutil.`)}if(!y.CFBundleIdentifier)throw new Error(`${l} has no CFBundleIdentifier in its Info.plist.`);return y.CFBundleIdentifier}async function b(l,u,g){if(u.kind==="package"){let A=await r(["listapps",l.id]);if(A.code!==0)throw new Error(`Could not list apps on ${l.displayName}: ${A.stderr.trim()||`simctl exited ${A.code}`}`);let _=at(await e.convertPlistToJson(A.stdout));if(_.includes(u.value))return u.value;let P=j(u.value,_),N=[`${u.value} is not installed on ${l.displayName} (${l.id}).`];throw P.length>0?N.push("Close matches:",...P.map(F=>` ${F}`)):N.push("Pass a .zip of the .app bundle to install it instead."),new Error(N.join(`
|
|
18
|
+
`))}if(u.kind==="ipa")throw new Error(`${nt}.`);if(u.kind!=="app"&&u.kind!=="zip")throw new Error(`${u.kind} artifacts are Android-only and not installable on iOS.`);let y=u.value,k;if(u.kind==="zip"){g?.(`unpacking ${u.value}\u2026`);let A=await lt(u.value);y=A.appPath,k=A.cleanup}g?.(`installing ${y} on ${l.displayName}\u2026`);try{let A=await r(["install",l.id,y],it);if(A.code!==0)throw new Error(`Installing ${u.value} on ${l.displayName} failed: ${A.stderr.trim()||A.stdout.trim()}`);return await h(y)}finally{await k?.()}}async function $(l={}){let u=[],g=await e.exec("xcode-select",["-p"],{timeoutMs:1e4});if(g.code===0&&g.stdout.trim()!==""){let _=await e.exec("xcodebuild",["-version"],{timeoutMs:3e4}),P=_.code===0?dt(_.stdout):void 0;P?Number(P.split(".")[0])<J?u.push({id:"ios.xcode",label:"Xcode",required:!0,status:"fail",detail:`Xcode ${P} is older than the required Xcode ${J}`,fixText:`Update Xcode to ${J} or newer from the App Store.`}):u.push({id:"ios.xcode",label:"Xcode",required:!0,status:"pass",detail:`Xcode ${P} \xB7 ${g.stdout.trim()}`}):u.push({id:"ios.xcode",label:"Xcode",required:!0,status:"fail",detail:`${g.stdout.trim()} has no usable xcodebuild (Command Line Tools only?)`,fixText:"Install full Xcode from the App Store, then run `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer`."})}else u.push({id:"ios.xcode",label:"Xcode",required:!0,status:"fail",detail:"xcode-select reports no developer directory",fixText:"Install Xcode from the App Store, then run `xcode-select --install`."});let y=await e.exec("xcrun",["simctl","help"],{timeoutMs:15e3});u.push(y.code===0?{id:"ios.xcrun",label:"xcrun",required:!0,status:"pass",detail:"simctl reachable"}:{id:"ios.xcrun",label:"xcrun",required:!0,status:"fail",detail:`xcrun cannot run simctl: ${y.stderr.trim()||y.stdout.trim()||`exit ${y.code}`}`,fixText:"Run `xcode-select --install`, then confirm with `xcrun simctl list devices`. If Xcode is installed, `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer` repoints it."});let k=!l.appiumUrl,A=await e.mobileDeps.status();return u.push({id:"ios.xcuitest",fixedByBundle:!0,label:"xcuitest driver",required:k,status:A.installed?"pass":k?"fail":"info",detail:A.installed?"bundled in the managed mobile deps (with prebuilt WDA)":l.appiumUrl?"managed driver not required because --appium-url is set":A.corrupt??"the simulator deps bundle is not installed",...A.installed||!k?{}:{fixText:"Run `kane-cli doctor --target simulator --install` to download the simulator deps bundle."}}),u}async function M(l,u){let g=[];return u.appPackage&&g.push({label:`closing ${u.appPackage}`,file:"xcrun",args:["simctl","terminate",l.id,u.appPackage]}),u.shutdown&&g.push({label:`shutting down ${l.displayName}`,file:"xcrun",args:["simctl","shutdown",l.id]}),g}return{platform:de,available:()=>e.os==="darwin",checks:$,discover:c,prepare:p,listApps:v,ensureApp:b,teardownPlan:M,toolEnv:()=>e.mobileDeps.environment()}}var ue=[re(),le()];function U(){return ue.filter(t=>t.available())}function Vt(){return U().map(t=>t.platform)}function Ht(){return ue.map(t=>t.platform)}function mt(t){let e=t.toLowerCase();return U().find(r=>r.platform.toLowerCase()===e)}async function pt(t){let e=t?U().filter(o=>o.platform.toLowerCase()===t.toLowerCase()):U(),r=[];for(let o of e)try{r.push(...await o.discover())}catch{}return r}function ft(t,e){let r=e.toLowerCase();return t.id.toLowerCase()===r||t.virtualName?.toLowerCase()===r}function gt(t){let e=t.virtualName&&t.virtualName!==t.id?`${t.displayName} (${t.virtualName})`:t.displayName;return`${t.id} \u2014 ${e} [${t.platform} \xB7 ${t.kind} \xB7 ${t.state}]`}function K(t){return t.length===0?"":`
|
|
19
|
+
${t.map(e=>` ${gt(e)}`).join(`
|
|
20
|
+
`)}`}async function jt(t,e={}){let r=e.discover??pt,o=e.providerFor??mt,c=await r(t.platform),f=h=>{let b=o(h.platform);return b?{ok:!0,target:h,provider:b}:{ok:!1,reason:"not-found",candidates:c,message:`No provider is registered for platform '${h.platform}'.`}};if(t.device){let h=c.filter(b=>ft(b,t.device));return h.length===0?{ok:!1,reason:"not-found",candidates:c,message:`No target matches --device '${t.device}'.`+(c.length>0?` Available:${K(c)}`:" No targets were found \u2014 run `kane-cli doctor --target <emulator|simulator>`.")}:f(h.find(b=>b.state==="ready")??h[0])}let p=t.defaultTarget;if(p&&(!t.platform||t.platform.toLowerCase()===p.platform.toLowerCase())){let h=c.find(b=>b.platform===p.platform&&b.kind===p.kind&&(b.id===p.id||b.virtualName===p.id));return h?f(h):{ok:!1,reason:t.interactive?"needs-picker":"not-found",candidates:c,message:`The saved default target '${p.id}' (${p.platform} \xB7 ${p.kind}) is not connected. `+(t.interactive?"Pick a target to bind this run.":"Pass --device <id> explicitly \u2014 kane-cli never binds a different device on its own.")+(c.length>0?` Available:${K(c)}`:"")}}if(c.length===0)return{ok:!1,reason:"none-found",candidates:[],message:"No emulator or simulator found. Start an Android emulator or boot an iOS simulator, then run `kane-cli devices list --target <emulator|simulator>`."};let v=c.filter(h=>h.state==="ready");return v.length===1?f(v[0]):t.interactive?{ok:!1,reason:"needs-picker",candidates:c,message:v.length===0?"No target is ready \u2014 pick one to prepare it.":"More than one target is ready \u2014 pick one."}:{ok:!1,reason:"ambiguous",candidates:c,message:(v.length===0?"No target is ready.":`${v.length} targets are ready.`)+` Pass --device <id>:${K(c)}`}}export{yt as a,Vt as b,Ht as c,mt as d,pt as e,jt as f};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as B,b as H,d as ie}from"./chunk-
|
|
2
|
+
import{a as B,b as H,d as ie}from"./chunk-KDXQNLVV.js";import{a as j,b as N}from"./chunk-PT7V5WDQ.js";import{a as C,b as G,e as M,f as te,m as re,n as ne}from"./chunk-DEZ7CXGM.js";import{a as oe,b as se}from"./chunk-2YQ6TW77.js";import{a as L}from"./chunk-BRTARADN.js";import{a as ee}from"./chunk-CZUOGGUK.js";import{a as q}from"./chunk-OYJBABRV.js";import{a as Z}from"./chunk-DPUV6OSP.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-ZLSWHCWO.js";import{x as h}from"./chunk-OFW3ZVTP.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as m,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Ge,rmSync as he,unlinkSync as He}from"fs";import{resolve as z}from"path";import{promises as ae,realpathSync as be}from"fs";import{homedir as Te}from"os";import{join as V,parse as Ee,relative as ce,resolve as le}from"path";var ue=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function de(e){try{return be(le(e))}catch{return le(e)}}function Se(e){let r=de(e),s=de(Te()),n=Ee(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Se(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),g;try{g=await ae.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of g){if(t++,t>r){c=!0,f="max_entries";break}let x=b.name,E=V(a,x);if(b.isDirectory()){if(ue.has(x)||x.startsWith(".")||x.startsWith("output-")||n.has(x))continue;l.push(E)}else if(b.isFile()&&x.endsWith("_test.md")&&(o.push({path:E,relPath:ce(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!c;){let{dir:b,depth:x}=g.shift(),E;try{E=await ae.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let w=u.name,y=V(b,w);if(u.isDirectory()){if(x>=20||w.startsWith(".")||w.startsWith("output-")||ue.has(w))continue;g.push({dir:y,depth:x+1})}else if(u.isFile()&&w.endsWith("_test.md")&&(o.push({path:y,relPath:ce(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as ve}from"fs";function Re(e){let r;try{r=ve(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{return{tags:[],...Me(r)?{mobileTarget:Pe}:{}}}}var Pe={platform:"",app:""};function Me(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return!1;let s=r[1].split(/\r?\n/);if(s.some(o=>/^target:\s*['"]?(emulator|simulator)['"]?\s*$/.test(o)))return!0;let n=s.findIndex(o=>/^target:\s*$/.test(o));return n<0?!1:s.slice(n+1).some(o=>/^\s+\S/.test(o))}function W(e){return Re(e).tags}import{mkdirSync as De,writeFileSync as $e}from"fs";import{join as Ce}from"path";function fe(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Ie(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:fe(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Fe(e){let r=se({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:fe(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);De(e.outDir,{recursive:!0});for(let l of c.url){let a=Ce(e.outDir,l.file_name),g=await A(l.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:g.status});continue}let b=await g.text();$e(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function ge(e){return await Ie(e),await Fe(e)}var T=v(X(),1);import{existsSync as Oe,readFileSync as Ae}from"fs";var p=v(F(),1);function Le(e){B(e);let r=M(e);if(!Oe(r))return null;try{return JSON.parse(Ae(r,"utf8"))}catch{return{}}}function Be(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function je(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ne(e){return e==="tests-dir"?"\u2726":" "}function Ue(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var Y=["all","synced","local","never_run","cli","hand"];function We(e){let r=Y.indexOf(e);return Y[(r+1)%Y.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,g]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),w=[];for(let y of u.results){let K=Le(y.path);K?.org_id!==void 0&&K.org_id!==r||w.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Be(K),source:y.source,tags:W(y.path)})}t(w),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Ue(u,a)).map(u=>({id:u.path,label:`${je(u.status)} ${Ne(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),x=(0,T.useMemo)(()=>Ke(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(m,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(m,{color:h.red,children:i})})]});let E=a==="all"?"all":Je(a);return(0,p.jsx)(ee,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let w=o.find(y=>y.path===u.id);w&&s(w)},onCancel:n,onTab:()=>g(u=>We(u)),extraHint:"cycle filter",footer:x})}function Je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ke(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(m,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(m,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(m,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(m,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(m,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(m,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Xe,readFileSync as qe}from"fs";var d=v(F(),1);function pe({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Xe(a))try{i(JSON.parse(qe(a,"utf8")))}catch{i(null)}},[e]),Q((a,g)=>{if(g.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:g})=>g?(0,d.jsxs)(m,{children:[(0,d.jsx)(m,{color:h.dim,children:a.padEnd(14)}),g]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(m,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(m,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(m,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(m,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Ge(r,"utf8"))}catch{return null}}function _e(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return _e(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
|
|
3
3
|
Switch profiles with \`kane-cli profiles switch\` to act on it.
|
|
4
4
|
`),2)}async function Xt(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await H({isInteractive:r,creds:s,config:n});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function qt(e,r){if(process.stdin.isTTY&&!e.json)return await ze(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
|
|
5
5
|
`),2;throw o}for(let o of n.results){let t=$(o.path);if(!_e(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:C(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
|
|
6
6
|
`)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
|
|
7
|
-
`),0}var ye=-1001,xe=-1002,we=-1003,_={action:null,path:null};function Ve(e,r){return _.action=e,_.path=r,e==="run"?ye:e==="export"?xe:we}function Ye({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(pe,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ve(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function ze(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(Ye,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===ye&&_.path){let{runTestMdFile:t}=await import("./run-test-md-
|
|
7
|
+
`),0}var ye=-1001,xe=-1002,we=-1003,_={action:null,path:null};function Ve(e,r){return _.action=e,_.path=r,e==="run"?ye:e==="export"?xe:we}function Ye({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(pe,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ve(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function ze(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(Ye,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===ye&&_.path){let{runTestMdFile:t}=await import("./run-test-md-FO2RNNOD.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===xe&&_.path){let t=await Ze(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Qe(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Gt(e,r){let s=z(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
|
|
8
8
|
`),2;let n=$(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:C(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
|
|
9
9
|
`),0}async function Qe(e,r,s){let n=z(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
|
|
10
10
|
`),2;let o=$(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as u,b as x}from"./chunk-
|
|
2
|
+
import{a as u,b as x}from"./chunk-RDNKYRKY.js";import{x as m}from"./chunk-OFW3ZVTP.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:c,borderColor:d,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:c,borderColor:d,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dim,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{homedir as a}from"os";import{join as t}from"path";var m="0.8.
|
|
2
|
+
import{homedir as a}from"os";import{join as t}from"path";var m="0.8.6";var e=t(a(),".testmuai","kaneai"),d=t(e,"profiles"),g=t(e,"tui-config.json"),h=t(e,"media"),b="https://registry.npmjs.org/@testmuai/kane-cli",A="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",_=`https://registry.npmjs.org/${n}`,r="kane-cli",L=[{dir:t(a(),".claude","skills",r),agent:"Claude Code"},{dir:t(a(),".agents","skills",r),agent:"Codex CLI"},{dir:t(a(),".gemini","skills",r),agent:"Gemini CLI"}],x="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",u=9222,R=9230,I=t(e,"chrome-profiles"),o=t(e,"hints"),E=t(o,"state.json");function C(s){return t(o,`catalog-${s}.json`)}var c="127.0.0.1",T=18392,S=18400,i="/callback";function f(s){return`http://${c}:${s}${i}`}var B="KANE CLI",N="*",P={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com",mobileAppBaseUrl:"https://api.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com",mobileAppBaseUrl:"https://stage-api.lambdatestinternal.com"}},O={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{m as a,e as b,g as c,h as d,b as e,A as f,n as g,L as h,x as i,U as j,u as k,R as l,I as m,E as n,C as o,c as p,T as q,S as r,i as s,f as t,B as u,N as v,P as w,O as x};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{w as s}from"./chunk-
|
|
2
|
+
import{w as s}from"./chunk-OFW3ZVTP.js";function n(r="prod"){let e=s[r];return r!=="stage"?e:{authBaseUrl:process.env.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:process.env.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:process.env.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:process.env.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:process.env.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:process.env.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:process.env.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:process.env.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:process.env.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost,evidenceViewerUrl:process.env.KANE_STAGE_EVIDENCE_VIEWER_URL??e.evidenceViewerUrl,mediaArtefactsHost:process.env.KANE_STAGE_MEDIA_ARTEFACTS_HOST??e.mediaArtefactsHost,mobileAppBaseUrl:process.env.KANE_STAGE_MOBILE_APP_URL??e.mobileAppBaseUrl}}export{n as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{e as $e}from"./chunk-
|
|
2
|
+
import{e as $e}from"./chunk-XJILZ2WN.js";import{a as te}from"./chunk-RX5TZZNQ.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-NT3UETTV.js";import{a as ve}from"./chunk-RDNKYRKY.js";import{x as i}from"./chunk-OFW3ZVTP.js";import{b as ye}from"./chunk-DFS4RMVP.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};
|