@testmuai/kane-cli 0.8.14 → 0.8.15
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-AVL3TJA2.js → ChatSurface-2GPR4S7I.js} +1 -1
- package/dist/{ChromeProfilePicker-WJZJOZ6Z.js → ChromeProfilePicker-XAZGCJKR.js} +1 -1
- package/dist/{CliFeedbackPrompt-65BQF5G5.js → CliFeedbackPrompt-4SILDU7S.js} +1 -1
- package/dist/{CliUploadProgress-HEBZYKGN.js → CliUploadProgress-OAQBY55Y.js} +1 -1
- package/dist/{ConfigView-JEVQ2SO4.js → ConfigView-FDBMJC26.js} +1 -1
- package/dist/EvidenceViewOffer-YSNRKKPC.js +2 -0
- package/dist/FolderPicker-XCTJ5447.js +2 -0
- package/dist/{InfoBox-KM5DLBCV.js → InfoBox-ZPUBB7J4.js} +1 -1
- package/dist/{LinksBox-FQA36GTV.js → LinksBox-MNNNOH23.js} +1 -1
- package/dist/{ProfilesView-76KGHTMK.js → ProfilesView-GY5QCIT3.js} +1 -1
- package/dist/{ProjectPicker-65YOU46H.js → ProjectPicker-UCHMCNFV.js} +1 -1
- package/dist/{SaveSessionPrompt-QD6BNTWO.js → SaveSessionPrompt-ATVHKAHN.js} +1 -1
- package/dist/SingleShotApp-IPNZBFXB.js +2 -0
- package/dist/{SummaryBox-N2B6DUDD.js → SummaryBox-2DTNE25L.js} +1 -1
- package/dist/TestMdRunView-2FQIEI5W.js +2 -0
- package/dist/{TestrunEvidenceTable-3WLQVTF4.js → TestrunEvidenceTable-6UE5EMON.js} +1 -1
- package/dist/{WhoamiView-T26HA4ZZ.js → WhoamiView-TFCHIOW5.js} +1 -1
- package/dist/{app-download-XKZWFMEK.js → app-download-N7MLJQ42.js} +1 -1
- package/dist/{auth-PPJANIMZ.js → auth-IQPCVCZK.js} +1 -1
- package/dist/{binary-DKWWODT2.js → binary-VML7EGV4.js} +1 -1
- package/dist/{bind-62AZYFAY.js → bind-YV6V5AI6.js} +2 -2
- package/dist/{bootstrap-6IJNZIPT.js → bootstrap-KCPWDBLX.js} +1 -1
- package/dist/bridge-5UKX7YIO.js +2 -0
- package/dist/{changelog-UTGJ7FSP.js → changelog-CJFWGRIL.js} +1 -1
- package/dist/chunk-27ERHOW3.js +2 -0
- package/dist/{chunk-WR42Q3HU.js → chunk-2WRBCTNM.js} +1 -1
- package/dist/{chunk-73ULUGBM.js → chunk-3D5MKSG3.js} +1 -1
- package/dist/{chunk-2BFXT7VQ.js → chunk-3GELV4IN.js} +3 -3
- package/dist/{chunk-O6U2HU5M.js → chunk-4TMQTSIO.js} +1 -1
- package/dist/{chunk-X74PP5NJ.js → chunk-5HTSKF5K.js} +1 -1
- package/dist/{chunk-MLRO7OH3.js → chunk-6DHEOPXX.js} +1 -1
- package/dist/{chunk-WBHSPN55.js → chunk-6GLFQHSW.js} +2 -2
- package/dist/chunk-6K4FDYMH.js +89 -0
- package/dist/{chunk-3BHRGHIZ.js → chunk-6L5RV62W.js} +1 -1
- package/dist/{chunk-N7ZRF5K3.js → chunk-74FHTDEE.js} +1 -1
- package/dist/{chunk-CGT4NFQN.js → chunk-7EGIX6Y4.js} +2 -2
- package/dist/{chunk-3YX3RQXO.js → chunk-7WDPU33M.js} +1 -1
- package/dist/{chunk-JKX57HA7.js → chunk-7X4R6464.js} +1 -1
- package/dist/{chunk-RQLU4NDG.js → chunk-A557OSRS.js} +1 -1
- package/dist/{chunk-3SPOJWRA.js → chunk-AYJ2YZP5.js} +1 -1
- package/dist/{chunk-YHVG7V3E.js → chunk-BMVE73M7.js} +1 -1
- package/dist/chunk-CAOZKSQ3.js +8 -0
- package/dist/{chunk-L6MOO4WT.js → chunk-CNPIJFZM.js} +1 -1
- package/dist/{chunk-EMSLJTYN.js → chunk-D6GBOFK5.js} +1 -1
- package/dist/{chunk-FFFB5BXL.js → chunk-DMCEGMGB.js} +1 -1
- package/dist/{chunk-J7NRD4Q7.js → chunk-DMT3W26F.js} +1 -1
- package/dist/{chunk-NOLYYHVG.js → chunk-EDQZIEPJ.js} +1 -1
- package/dist/{chunk-K7K23DIQ.js → chunk-EFTRH35G.js} +1 -1
- package/dist/{chunk-LL5DQO6V.js → chunk-EJXBKCNF.js} +1 -1
- package/dist/{chunk-OH2NSBO6.js → chunk-EPE2ELDH.js} +1 -1
- package/dist/{chunk-42FHKRPA.js → chunk-FXO7JKMZ.js} +3 -3
- package/dist/{chunk-VNFCX2SH.js → chunk-GSDXZS4U.js} +1 -1
- package/dist/{chunk-4K5XTIJ6.js → chunk-GZ65ZA4C.js} +1 -1
- package/dist/{chunk-Q7XBMBMR.js → chunk-HLCETZ73.js} +1 -1
- package/dist/{chunk-B2ZGG7WM.js → chunk-HYTBEPC2.js} +1 -1
- package/dist/{chunk-AC7BPO4X.js → chunk-IAHOLH5W.js} +1 -1
- package/dist/{chunk-GESG672R.js → chunk-JCMHB4KH.js} +1 -1
- package/dist/{chunk-XGHMZJGI.js → chunk-JFUFWICY.js} +2 -2
- package/dist/{chunk-JH6E632O.js → chunk-JGAMMOUC.js} +1 -1
- package/dist/{chunk-KOL6ZWOQ.js → chunk-JL3L6KOG.js} +1 -1
- package/dist/chunk-JQCOKL6U.js +15 -0
- package/dist/{chunk-M7DN6FO3.js → chunk-JSS22MFY.js} +9 -9
- package/dist/chunk-JVEZBJJ7.js +2 -0
- package/dist/{chunk-ZWHPIR2Z.js → chunk-KALEPJAV.js} +2 -2
- package/dist/{chunk-O2APH6TZ.js → chunk-KUS324VE.js} +1 -1
- package/dist/{chunk-NDCRJXYF.js → chunk-LJGAXIDU.js} +1 -1
- package/dist/{chunk-ZKEOPIQ3.js → chunk-M36MOFJW.js} +1 -1
- package/dist/{chunk-O5AS2ZIX.js → chunk-MLYNVJNH.js} +1 -1
- package/dist/{chunk-GKZ2KVE6.js → chunk-N3CVR4Z2.js} +1 -1
- package/dist/{chunk-6F6YI3ZG.js → chunk-NLEA6NPU.js} +1 -1
- package/dist/{chunk-SGHP44WS.js → chunk-NUJVYAI4.js} +1 -1
- package/dist/{chunk-IQ7NGOAT.js → chunk-NWNG5UWD.js} +1 -1
- package/dist/{chunk-IICQ5KRD.js → chunk-O66WXOOC.js} +3 -3
- package/dist/{chunk-ZA4M4O7E.js → chunk-OFWJBOGT.js} +2 -2
- package/dist/{chunk-MNE5VMHT.js → chunk-OGDAWNFY.js} +1 -1
- package/dist/{chunk-75I46VTM.js → chunk-ORQGQSWG.js} +2 -2
- package/dist/{chunk-YHR2YAN5.js → chunk-OWGFFJKK.js} +1 -1
- package/dist/{chunk-SQDQADWD.js → chunk-PGXJ275T.js} +1 -1
- package/dist/{chunk-P3JUE2RM.js → chunk-Q77QO3PC.js} +4 -4
- package/dist/{chunk-JJJSDDQ2.js → chunk-QVLYK5JL.js} +1 -1
- package/dist/{chunk-UXH3RMQ7.js → chunk-QXRT6HSV.js} +1 -1
- package/dist/{chunk-RH6KFHJB.js → chunk-R7QMZBBH.js} +1 -1
- package/dist/{chunk-BJYGWXVP.js → chunk-RI4ILZZC.js} +1 -1
- package/dist/{chunk-PGU64EWQ.js → chunk-RQILLYSP.js} +1 -1
- package/dist/chunk-S4JUCBCT.js +7 -0
- package/dist/{chunk-4BBDKWM3.js → chunk-SHSXOYKT.js} +1 -1
- package/dist/{chunk-7RAI77XD.js → chunk-SIYSKT6I.js} +1 -1
- package/dist/{chunk-22QIVSQR.js → chunk-SWTJMTBY.js} +1 -1
- package/dist/{chunk-X5276I5H.js → chunk-T4R26WER.js} +2 -2
- package/dist/{chunk-BAKJPQGU.js → chunk-TEHZUSUY.js} +1 -1
- package/dist/{chunk-RBHQXWR7.js → chunk-TVELOH5A.js} +1 -1
- package/dist/{chunk-6LGED4FC.js → chunk-UHSNUUX3.js} +2 -2
- package/dist/{chunk-QPUVOVD7.js → chunk-UZIMYV5U.js} +1 -1
- package/dist/{chunk-WILT62DP.js → chunk-VOTIGXQ4.js} +1 -1
- package/dist/{chunk-SFTFHFG3.js → chunk-VZDLRJ5N.js} +1 -1
- package/dist/{chunk-2RMHDOP4.js → chunk-W77SZLFC.js} +1 -1
- package/dist/{chunk-QJ5O27SJ.js → chunk-WFBJNVMQ.js} +1 -1
- package/dist/{chunk-SX56MVUO.js → chunk-WNB2IYHY.js} +1 -1
- package/dist/chunk-XSUJJB7Z.js +11 -0
- package/dist/{chunk-NBMLBCJ3.js → chunk-XUJXGE42.js} +1 -1
- package/dist/{chunk-ARG56PJG.js → chunk-XXE7W5AV.js} +1 -1
- package/dist/{chunk-DA57DXCF.js → chunk-YAAQER2L.js} +1 -1
- package/dist/{chunk-7L25ZNNP.js → chunk-YGMUNNKH.js} +1 -1
- package/dist/{chunk-OO5GMBVI.js → chunk-YKYKOV6U.js} +1 -1
- package/dist/{chunk-C74ABM24.js → chunk-YZVR7ESF.js} +1 -1
- package/dist/{chunk-GPIXV7AV.js → chunk-Z3YYMZHT.js} +1 -1
- package/dist/{chunk-WOA7VCGA.js → chunk-Z73ZYROU.js} +1 -1
- package/dist/{chunk-LR5DJ6EN.js → chunk-ZCSEBT2W.js} +1 -1
- package/dist/{chunk-KOPP4CJW.js → chunk-ZEVU2OT3.js} +1 -1
- package/dist/{chunk-IQ7GPETF.js → chunk-ZKCCG3GK.js} +1 -1
- package/dist/{config-3AKWRTFS.js → config-UGCWZGH5.js} +1 -1
- package/dist/{cover-cmd-ZLAWMEC2.js → cover-cmd-SWJ2NZUZ.js} +1 -1
- package/dist/{credentials-Q4WH5CBN.js → credentials-GWLYYRTL.js} +1 -1
- package/dist/{deps-bundle-RVZK6LZJ.js → deps-bundle-VNGC2UG6.js} +1 -1
- package/dist/{deps-resolve-6F2U4TJP.js → deps-resolve-YLCEU6I7.js} +1 -1
- package/dist/{dispatch-46BETGXY.js → dispatch-OMQCT7WO.js} +1 -1
- package/dist/{doctor-WRPG56HH.js → doctor-B4Z6RPKQ.js} +1 -1
- package/dist/{evidence-XWR32HWP.js → evidence-XJGXVLO5.js} +1 -1
- package/dist/{evolve-cmd-27ZQN6YB.js → evolve-cmd-QQQPPGL3.js} +1 -1
- package/dist/{explain-cmd-JCJTXVZY.js → explain-cmd-XVE6Z67Q.js} +1 -1
- package/dist/{extract-bind-D5BYYGYA.js → extract-bind-7IDQS4QP.js} +2 -2
- package/dist/{extract-cmd-CCYW7FIY.js → extract-cmd-KIEOBRIT.js} +1 -1
- package/dist/{gaps-cmd-3VJKQ25D.js → gaps-cmd-RGIPUSIR.js} +1 -1
- package/dist/{generate-headless-2M6UT3IK.js → generate-headless-XGRIDD6O.js} +2 -2
- package/dist/index.js +134 -136
- package/dist/{ingest-cmd-HVTUK264.js → ingest-cmd-R5H5SF5K.js} +1 -1
- package/dist/install-W3VPVPAQ.js +2 -0
- package/dist/{interactive-bind-OJCYNQPI.js → interactive-bind-X5DVLRRW.js} +3 -3
- package/dist/{lifecycle-cmd-GWFGUGTC.js → lifecycle-cmd-6R2PR2HM.js} +1 -1
- package/dist/{list-cmd-AXDW64OY.js → list-cmd-QCIYKWYQ.js} +1 -1
- package/dist/{list-commands-YNZ6EFIF.js → list-commands-VRRCVWKO.js} +1 -1
- package/dist/login-flow-5HL2QYEL.js +2 -0
- package/dist/{maintenance-cmd-QEMK6YNV.js → maintenance-cmd-GZ4EMT3V.js} +1 -1
- package/dist/{mobile-prompts-OXHA5GHJ.js → mobile-prompts-CMIVWDHQ.js} +1 -1
- package/dist/objective-variable-gate-EEYJ6B3X.js +2 -0
- package/dist/{open-provider-E5VUGFNE.js → open-provider-UFSCTIQQ.js} +1 -1
- package/dist/{persist-recorded-session-KWPH37HI.js → persist-recorded-session-JXL5E53A.js} +1 -1
- package/dist/pipeline-RSCRNNPW.js +2 -0
- package/dist/prepare-target-XZ3FTVBW.js +2 -0
- package/dist/{reconcile-cmd-V7TDYETT.js → reconcile-cmd-4VRTUM2D.js} +1 -1
- package/dist/{reconcile-deps-X6IGH4CA.js → reconcile-deps-ZCJ2QCK5.js} +2 -2
- package/dist/{reconcile-engine-OGXSIE7O.js → reconcile-engine-IVLZCYZB.js} +1 -1
- package/dist/{recording-banner-IZWN2XFY.js → recording-banner-SRLPSTFP.js} +1 -1
- package/dist/registry-CPQHW2L2.js +2 -0
- package/dist/{require-project-folder-PEEUITK6.js → require-project-folder-SKEZMSN7.js} +1 -1
- package/dist/{resolve-run-intent-JGXXE45Y.js → resolve-run-intent-THC3EPAX.js} +1 -1
- package/dist/{resolver-TY7XLJBN.js → resolver-2NUNLK7N.js} +1 -1
- package/dist/{review-cmd-74YTPT7E.js → review-cmd-BMJQZ6XJ.js} +1 -1
- package/dist/{run-GRYWYKIH.js → run-TURFDLC6.js} +1 -1
- package/dist/{run-DN4XARP2.js → run-UDP5VPYS.js} +1 -1
- package/dist/{run-test-md-DFCKCQ4T.js → run-test-md-MRYNFNPO.js} +2 -2
- package/dist/{skill-installer-GRU3HOYF.js → skill-installer-CVJ5VTEJ.js} +1 -1
- package/dist/{spawner-LNMD4NJF.js → spawner-7FUA3JXA.js} +1 -1
- package/dist/{store-guard-Q4MYZQHF.js → store-guard-XQ5MSUB2.js} +1 -1
- package/dist/{sync-cmd-H6Y5EB3L.js → sync-cmd-5INKTZN2.js} +1 -1
- package/dist/{sync-setup-THGRBKTA.js → sync-setup-4R54VRAO.js} +1 -1
- package/dist/tcg-generate-2BOPGRM6.js +2 -0
- package/dist/testmd-actions-2CPJZAC2.js +2 -0
- package/dist/testmd-sync-HYZI6NRM.js +2 -0
- package/dist/token-refresh-NTE4LQRN.js +2 -0
- package/dist/{validate-basic-RCBEELSB.js → validate-basic-OKLJLDML.js} +1 -1
- package/dist/{variable-receipt-JHRW73Z6.js → variable-receipt-CMCDUJI2.js} +1 -1
- package/dist/{verdicts-XFXDRND4.js → verdicts-EMCYGQWM.js} +1 -1
- package/dist/{version-check-Z774UWW3.js → version-check-4DQJBSXW.js} +1 -1
- package/dist/{view-cmd-I4LQGJ2X.js → view-cmd-P3XRFORJ.js} +1 -1
- package/dist/{walk-session-FP52IGLB.js → walk-session-MUGS6CZY.js} +1 -1
- package/dist/{with-telemetry-P6RUPWBH.js → with-telemetry-3T53GIQC.js} +1 -1
- package/package.json +11 -11
- package/dist/EvidenceViewOffer-5MB4ZXKM.js +0 -2
- package/dist/FolderPicker-SYFXH6D5.js +0 -2
- package/dist/SingleShotApp-U54ETXS3.js +0 -2
- package/dist/TestMdRunView-WA4TC5PT.js +0 -2
- package/dist/bridge-X5DEJL6F.js +0 -2
- package/dist/chunk-53MPG2J3.js +0 -11
- package/dist/chunk-KN65CUNT.js +0 -15
- package/dist/chunk-L4M7753M.js +0 -2
- package/dist/chunk-LBNADEQN.js +0 -8
- package/dist/chunk-LNV7C2YO.js +0 -6
- package/dist/chunk-ZZTZJPT2.js +0 -88
- package/dist/install-5WJLE7XT.js +0 -2
- package/dist/login-flow-PRXFPRYZ.js +0 -2
- package/dist/objective-variable-gate-76GYUHEP.js +0 -2
- package/dist/pipeline-A2OGF4XW.js +0 -2
- package/dist/prepare-target-P6BWJZBZ.js +0 -2
- package/dist/registry-GOLIFVK5.js +0 -2
- package/dist/tcg-generate-SZZ7MJXY.js +0 -2
- package/dist/testmd-actions-MRIUOOXO.js +0 -2
- package/dist/testmd-sync-UYVJ47BN.js +0 -2
- package/dist/token-refresh-KN5JK2U4.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as w,b as O}from"./chunk-4PMZ5FCD.js";import{a as I}from"./chunk-KBM3XHAM.js";import{f as L}from"./chunk-5LJRZI7S.js";import{a as N,b as k}from"./chunk-BKM2LWU2.js";import{a as R,b as y,c as T,d as m,e as A,g as b,h as r}from"./chunk-RSSOJ3L2.js";import{b as x}from"./chunk-5EOX4MEY.js";import{a as E}from"./chunk-RZ4F3BHX.js";import{a as g,i as v}from"./chunk-
|
|
2
|
+
import{a as w,b as O}from"./chunk-4PMZ5FCD.js";import{a as I}from"./chunk-KBM3XHAM.js";import{f as L}from"./chunk-5LJRZI7S.js";import{a as N,b as k}from"./chunk-BKM2LWU2.js";import{a as R,b as y,c as T,d as m,e as A,g as b,h as r}from"./chunk-RSSOJ3L2.js";import{b as x}from"./chunk-5EOX4MEY.js";import{a as E}from"./chunk-RZ4F3BHX.js";import{a as g,i as v}from"./chunk-HYTBEPC2.js";import{platform as X,arch as Y}from"os";import P from"fs";import M from"fs";import D from"path";var V=1e3,d=0,j=new Set([130,3]),a=class t{ids;logger;opts;ended=!1;createdAt=Date.now();errorState;constructor(e,n={emitted:!1}){this.ids=e.envelope,this.logger=e.logger,this.opts=e,this.errorState=n}get enabled(){return this.logger!==null}event(e,n={}){if(!this.logger)return;e==="ASR_ERROR"&&(this.errorState.emitted=!0);let i=m(this.ids,e,n);this.logger.log(R[e],e,e,C(i))}error(e,n={}){this.logger&&(this.logger.escalate(d),this.event("ASR_ERROR",{...n,error_code:e}))}child(e,n){return new t({...this.opts,envelope:{...this.ids,operation_id:n,parent_operation_id:this.ids.operation_id,verb:"design"}},this.errorState)}async lateBindContext(e){if(!(!this.logger||this.ids.context_instance_id))try{let{ensureStoreIds:n}=await import("./store-id-EOSGEKVK.js"),{ids:i,cloned:s}=n(e);this.ids.context_lineage_id=i.context_lineage_id,this.ids.context_instance_id=i.context_instance_id,s&&this.event("ASR_CONTEXT_CLONED")}catch{}}agentSession(e){this.ids.agent_session_id=e}spawnEnv(){if(!this.opts.telemetryEnabled)return{};let e={TESTMUAI_USER_SESSION_ID:this.ids.session_id,TESTMUAI_OPERATION_ID:this.ids.operation_id,TESTMUAI_CLIENT_VERSION:this.opts.clientVersion,TESTMUAI_TELEMETRY_PROXY_URL:this.opts.proxyUrl};return this.ids.context_instance_id&&(e.TESTMUAI_CONTEXT_INSTANCE_ID=this.ids.context_instance_id),e}traceTee(){return e=>{if(!this.logger)return;let n=typeof e.kind=="string"?e.kind.slice(0,64):"trace",i={...C(m(this.ids,"ASR_CMD_START",{})),trace_kind:n};typeof e.code=="string"&&(i.trace_code=e.code.slice(0,64)),delete i.event,this.logger.logStep(d,`trace_${n}`,n,i)}}wireTrace(e,n,i){if(!this.logger)return;i&&this.agentSession(i);let s=n&&typeof n=="object"?n:{};switch(e){case"spawn":this.event("ASR_AGENT_SPAWN",{tier:s.tier});break;case"session_paused":this.event("ASR_SESSION_PAUSED",s);break;case"commit":this.event("ASR_COMMIT",s);break;default:this.traceTee()({kind:e,code:typeof s.code=="string"?s.code:void 0})}}banner(){return`session: ${this.ids.session_id}`}supportFooter(){return`if this keeps failing, share this id with support: ${this.ids.session_id}`}async end(e){if(!this.ended){if(this.ended=!0,e.duration_ms===void 0&&(e={...e,duration_ms:Date.now()-this.createdAt}),this.logger)if(e.exit_code===0?this.logger.discardSteps(d):this.logger.escalate(d),e.exit_code>0&&!j.has(e.exit_code)&&!this.errorState.emitted&&this.event("ASR_ERROR",{error_code:e.exit_code===2?"usage_exit_unattributed":`exit_${e.exit_code}_unattributed`,exit_code:e.exit_code}),this.event("ASR_CMD_END",e),this.opts.longSession)await this.logger.shutdown();else{let n=await this.logger.flushOnce(V);(n==="failed"||n==="timeout")&&A(this.logger.drainBuffer())}this.logger&&this.writeManifestLine(e.exit_code),r(null)}}writeManifestLine(e){try{let n=x(this.ids.context_instance_id??null);M.mkdirSync(D.dirname(n),{recursive:!0});let i={ts:new Date().toISOString(),session_id:this.ids.session_id,operation_id:this.ids.operation_id,agent_session_id:this.ids.agent_session_id,verb:this.ids.verb,mode:this.ids.mode,exit_code:e};M.appendFileSync(n,JSON.stringify(i)+`
|
|
3
3
|
`,{flag:"a",mode:384})}catch{}}};function C(t){let e={event:t.event,session_id:t.session_id,operation_id:t.operation_id,verb:t.verb,mode:t.mode,component:t.component,seq:t.seq,context_lineage_id:t.context_lineage_id,context_instance_id:t.context_instance_id};t.parent_operation_id&&(e.parent_operation_id=t.parent_operation_id),t.agent_session_id&&(e.agent_session_id=t.agent_session_id);for(let[n,i]of Object.entries(t.context))e[n]=i;return e}var u=process.env.KANE_TELEMETRY_URL||v;function B(){return process.env.TESTMUAI_BASE_URL?"custom":process.env.TESTMUAI_ENV==="stage"?"stage":"prod"}function _e(t){let e=process.env.KANE_TELEMETRY!=="0"&&(!process.env.VITEST||process.env.KANE_TELEMETRY==="1"),n=t.env??B(),i=null;if(t.resumeSid&&t.contextRoot)try{let o=L(t.contextRoot,t.resumeSid);o?.user_session_id&&(i=o.user_session_id)}catch{}if(!i&&t.applyPlanPath)try{let o=JSON.parse(P.readFileSync(t.applyPlanPath,"utf8"));o.telemetry?.user_session_id&&(i=o.telemetry.user_session_id)}catch{}let s=i!==null;i||(i=y());let l=null,c=null,f=!1;if(t.contextRoot&&P.existsSync(t.contextRoot))if(t.write&&e){let o=k(t.contextRoot);l=o.ids.context_lineage_id,c=o.ids.context_instance_id,f=o.cloned}else{let o=N(t.contextRoot);l=o?.context_lineage_id??null,c=o?.context_instance_id??null}let h={session_id:i,operation_id:T(),context_lineage_id:l,context_instance_id:c,verb:t.verb,mode:t.mode,component:"kane-cli"},_=null;if(e){let o=I(n),S={org_id:o.org_id??"",user_id:o.user_id??"",machine_id:o.machine_id,email:null,email_domain:"",user_type:o.user_type??"unknown",env:o.env,plan:o.plan??"unknown"},U=t.mode==="interactive"||t.mode==="cli"?"cli":"agent";_=new w({proxyUrl:u,sessionId:i,identity:S,device:{cli_version:g,platform:X(),arch:Y(),host_agent:O(),invocation_mode:U},getToken:async()=>null}),t.longSession&&_.start()}let p=new a({envelope:h,logger:_,longSession:!!t.longSession,proxyUrl:u,clientVersion:`kane-cli/${g}`,telemetryEnabled:e});return e&&(r(h),p.event("ASR_CMD_START",{resumed:s,applied_plan:!!t.applyPlanPath}),f&&p.event("ASR_CONTEXT_CLONED"),b(async o=>{try{return(await E(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).ok}catch{return!1}}).catch(()=>{})),p}export{B as a,_e as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as u,d as p}from"./chunk-
|
|
2
|
+
import{c as u,d as p}from"./chunk-GZ65ZA4C.js";import{spawn as h}from"child_process";var k=new Set(["progress","ask_user","graph_query","ingest_request","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete","state_checkpoint"]);function v(g,n={}){let a=n.spawnCmd!==void 0?n.spawnCmd:u();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let f=g.source.images?.length??0;a.tier==="dev-python"&&f>0&&n.onWarn?.("warn: development agent in use \u2014 if image citations are missing, update the agent package");let t=h(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(g.session_id,n.auth)});if(t.stdin.write(JSON.stringify(g)+`
|
|
3
3
|
`),n.onStderr){let e="";t.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
|
|
4
4
|
`))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&n.onStderr(o)}})}let d=new Promise(e=>{t.on("exit",(r,i)=>e({code:r,signal:i}))});async function*m(){let e="",r=!1;for await(let i of t.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
|
|
5
5
|
`))>=0;){let l=e.slice(0,o).trim();if(e=e.slice(o+1),!l)continue;let c;try{c=JSON.parse(l)}catch{n.onWarn?.(`agent: skipping malformed line: ${l.slice(0,120)}`);continue}let s=c;if(!s||typeof s!="object"||!k.has(s.type)){n.onWarn?.(`agent: skipping unknown event type "${s&&typeof s=="object"?String(s.type??"?"):"?"}"`);continue}if(yield s,s.type==="done"){r=!0;break}}if(r)break}await d.catch(()=>{})}return{events:m(),send:e=>{t.stdin&&!t.stdin.destroyed&&t.stdin.write(JSON.stringify(e)+`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as br}from"./chunk-OPL2MIQG.js";import{a as yr}from"./chunk-TU6IMGWO.js";import{a as hr}from"./chunk-TNBF5OMZ.js";import{a as gr,b as mr}from"./chunk-HOA4VWSD.js";import{a as fr}from"./chunk-KZG4E5RM.js";import{c as pr,d as ur}from"./chunk-52WM3XYO.js";import{a as cr,d as lr}from"./chunk-BB2W35TW.js";import{a as or,g as xt,h as ir,n as ar,p as dr}from"./chunk-AHXOKBVE.js";import{e as ct,f as jt,g as Tt,h as Le}from"./chunk-
|
|
2
|
+
import{a as br}from"./chunk-OPL2MIQG.js";import{a as yr}from"./chunk-TU6IMGWO.js";import{a as hr}from"./chunk-TNBF5OMZ.js";import{a as gr,b as mr}from"./chunk-HOA4VWSD.js";import{a as fr}from"./chunk-KZG4E5RM.js";import{c as pr,d as ur}from"./chunk-52WM3XYO.js";import{a as cr,d as lr}from"./chunk-BB2W35TW.js";import{a as or,g as xt,h as ir,n as ar,p as dr}from"./chunk-AHXOKBVE.js";import{e as ct,f as jt,g as Tt,h as Le}from"./chunk-BMVE73M7.js";import{A as er,B as qt,C as te,D as it,E as fe,F as tr,G as ne,H as _e,I as at,J as nr,K as Y,L as Fe,M as dt,N as Re,O as rr,P as sr,S as Be,a as Bn,b as Dn,c as Ae,d as Pe,e as le,f as st,g as Hn,h as Gn,i as pe,j as Un,k as qe,l as je,m as Kn,n as ot,o as ue,p as Yn,q as zn,r as Qn,s as Zn,t as At,u as Pt,v as X,w as Te,x as Xn,y as Nt,z as xe}from"./chunk-UHSNUUX3.js";import{b as Fn,d as Ln,g as Ct,h as K}from"./chunk-H6TNBKGR.js";import{a as R,b as Mn,d as ee,e as Ne,h as Jn,i as Vn,k as Wn}from"./chunk-YLQHY4A7.js";import{a as jn,b as Tn,e as xn}from"./chunk-VOTIGXQ4.js";import{b as sn,f as on,h as an,k as dn,l as cn}from"./chunk-SWTJMTBY.js";import{b as Ot,d as ce}from"./chunk-IE3OO5GI.js";import{a as qn}from"./chunk-CH273NAE.js";import{b as ve}from"./chunk-BKM2LWU2.js";import{A as tt,B as nt,C as rt,D as Nn,q as In,r as Sn,s as En,t as On,u as Cn,v as An,w as Pn}from"./chunk-GP7WD4UY.js";import{B as oe,C as wn,D as vn,F as $e,G as Xe,J as $n,K as Ce,O as kn,P as et,U as _n,W as Rn,X as ke,b as rn,c as de,f as Et,h as ln,l as pn,m as un,o as Oe,p as O,q as fn,t as hn,v as gn,x as mn,y as yn,z as bn}from"./chunk-3N6IAVD5.js";import{d as Qe,e as Ze}from"./chunk-AKX4VRRR.js";import{existsSync as Ue,readdirSync as ss,readFileSync as os,realpathSync as Do,statSync as Mo,writeFileSync as Ho}from"fs";import{basename as Rt,join as Ke,relative as Go,resolve as tn}from"path";import{randomBytes as ks}from"crypto";var wr=8,De=()=>Wn(ks(8).toString("hex")),vr=(e,t)=>e!==null&&Buffer.from(e).equals(Buffer.from(t)),_s=[["P1 exclusive create",async e=>{for(let t=1;t<=2;t++){let n=De(),r=Buffer.from(`probe ${t} first`);if(await e.putIfAbsent(n,r)!=="created")return"a fresh key was reported as existing";if(await e.putIfAbsent(n,Buffer.from(`probe ${t} second`))!=="exists")return"the second write to one key was not refused";if(!vr(await e.get(n),r))return"the second write replaced the first"}return null}],["P2 contention",async e=>{let t=De(),r=(await Promise.all(Array.from({length:wr},(o,i)=>e.putIfAbsent(t,Buffer.from(`contender ${i}`))))).filter(o=>o==="created").length;return r===1?null:`${r} of ${wr} concurrent writers were told "created"`}],["P3 read-after-write",async e=>{let t=De(),n=Buffer.from("visible");return await e.putIfAbsent(t,n),await e.head(t)?vr(await e.get(t),n)?(await e.list(t)).includes(t)?null:"list does not show a key just created":"get does not return the bytes just created":"head does not see a key just created"}],["P4 definitive absence",async e=>await e.head(De())?"a never-written key was reported present":null]];async function lt(e){if(e.probe){let r=await e.probe();return{tier:Math.max(r.tier,e.ceilingTier),detail:r.detail}}let t=1,n="all probes passed";for(let[r,o]of _s){let i;try{i=await o(e)}catch(s){if(s instanceof R){if(!(s.code==="SYNC_LOCATION_REFUSED_WRITE"&&r.startsWith("P1")&&await $r(e)))throw s;n=`${r}: ${s.message}`,t=3;break}n=`${r}: ${s instanceof Error?s.message:String(s)}`,t=r.startsWith("P1")&&await $r(e)?3:2;break}if(i!==null){n=`${r}: ${i}`,t=2;break}}return{tier:Math.max(t,e.ceilingTier),detail:n}}async function $r(e){try{return!await e.head(De())}catch(t){if(t instanceof R)throw t;return!1}}import{existsSync as Rs,readFileSync as Rr}from"fs";import{join as Is}from"path";async function Ft(e,t,n,r){let i=le(e).entries[n];if(!i)throw new Error(`no sync state for ${n} \u2014 run kane-cli context sync add ${n} <descriptor> first`);if(i.tier!==1)throw new R("SYNC_READ_ONLY",`${n} is a tier ${i.tier} location: it can be cloned and pulled, never pushed`,"push to a location whose probe reached tier 1, or pull from this one");let s=await qe(e,t,i.witness);switch(s.kind){case"empty-storage":case"ahead":case"up-to-date":break;case"behind":case"empty-local":throw new R("SYNC_BEHIND",`${n} holds ${s.storage.seq} records, this store ${s.local?.seq??0}: it has records this store has not seen`,`kane-cli context pull ${n}`);case"diverged":throw new R("SYNC_DIVERGED",`you and ${n} both added work after position ${s.at-1}; nothing was pushed`,`run kane-cli context pull ${n} --rebase to save your local work, take the team version from ${n}, and then reapply yours`);case"foreign-lineage":throw new R("SYNC_FOREIGN_LINEAGE",`${n} holds a different history (its first record is not this store's)`,`to work on it, clone it: kane-cli context clone <descriptor of ${n}> <dir>; to share this store, add an empty location`)}let d=s.storage,c=bn(e),a;try{gn(e),a=Ss(e,d)}catch(F){throw F instanceof hn?new R("SYNC_REBASE_PENDING",`${F.message.split(";")[0]}; nothing was pushed`,F.remedy):F}finally{c()}let l=a.map(F=>Es(e,F)),g=0,p=0,f=0,u=0,y=d,b=null,h=null,m=t.beginTransaction?await t.beginTransaction():void 0,w=m?{...t,head:m.head,get:m.get,list:t.list.bind(t),putIfAbsent:t.putIfAbsent.bind(t)}:t,v=m?m.stageIfAbsent.bind(m):t.putIfAbsent.bind(t),x=[],ae=F=>m?x.push(F):r(F);try{let F=new Set;for(let A of l){for(let $ of A.blobs)if(await v($.key,$.bytes)!=="exists")p++,F.add($.key);else if(!F.has($.key)){let M=await w.get($.key);if(M===null||Ot(Buffer.from(M))!==$.fp){h=new R("SYNC_OBJECT_CORRUPT",`the blob ${$.fp} ${n} already holds does not hash to its name (named by record ${A.seq}); the record was not pushed`,"the storage object needs a human look before anything more is pushed to it");break}F.add($.key)}if(h)break;A.proposal&&await v(A.proposal.key,A.proposal.bytes)!=="exists"&&f++;let Q=Ne(A.seq);if(await v(Q,A.raw)!=="exists")g++;else if((await pe(w,A.seq)).hash===A.hash)ae(`position ${A.seq} is already on ${n}`),u++;else{b=A.seq;break}y={seq:A.seq,hash:A.hash}}if(m||await _r(t,y,d,n),y&&!await w.head(ee)){let A=await pe(w,1),Q={layout:1,canonicalizer:"v1",genesis_hash:A.hash};await v(ee,Buffer.from(JSON.stringify(Q)+`
|
|
3
3
|
`,"utf8"))!=="exists"&&ae(`wrote ${ee} on ${n}`)}if(m){if(y){let M=await w.get(ee),T=await pe(w,1),be={};try{let Z=JSON.parse(Buffer.from(M??[]).toString("utf8"));Z&&typeof Z=="object"&&!Array.isArray(Z)&&(be=Z)}catch{}if(be.layout!==1||be.canonicalizer!=="v1"||be.genesis_hash!==T.hash)throw new R("SYNC_OBJECT_CORRUPT",`${ee} does not describe this context's verified genesis and format.`,"Ask the location owner to inspect the metadata before publishing.")}if(h)throw h;if(b!==null)throw new R("SYNC_POSITION_TAKEN",`position ${b} on ${n} was taken by another writer; this batch was not published`,kr(n,b));let A=await m.commit(),Q=new Set(A.created),$=l.filter(M=>Q.has(Ne(M.seq))).length;u+=g-$,g=$,p=new Set(l.flatMap(M=>M.blobs.map(T=>T.key)).filter(M=>Q.has(M))).size,f=new Set(l.flatMap(M=>M.proposal?[M.proposal.key]:[]).filter(M=>Q.has(M))).size}m&&await _r(t,y,d,n);for(let A of x)r(A);let U="";if(y)try{Kn(e,n,y,{forwardOnly:!0})}catch(A){if(b===null||!(A instanceof O))throw A;U=" (the witness was not saved; the next pull records it)"}if(h)throw h;if(b!==null)throw new R("SYNC_POSITION_TAKEN",`position ${b} on ${n} was taken by another writer while this push ran; this store's history through position ${y?.seq??0} is confirmed on ${n}${U}`,kr(n,b))}finally{await m?.abort()}return{pushed:g,from:d?.seq??0,to:y?.seq??0,blobs:p,proposals:f,alreadyThere:u}}function kr(e,t){return t===1?`${e} holds a different history: to work on it, clone it with kane-cli context clone <descriptor of ${e}> <dir>; to share this store, add an empty location`:`kane-cli context pull ${e} --rebase`}async function _r(e,t,n,r){if(!t||t.seq<=(n?.seq??0))return;let o=await pe(e,t.seq);if(o.hash!==t.hash)throw new R("SYNC_OBJECT_CORRUPT",`${r} answered "created" for position ${t.seq} but serves a record hashing ${o.hash}, not ${t.hash}`,"The location needs inspection before publishing more context.")}function Ss(e,t){let{records:n,hashes:r}=Ce(e,t?.seq??0,t?.hash??null);return n.map((o,i)=>{let s=r[i],d=Rr(Is(e,"commits",`${String(o.seq).padStart(6,"0")}-${s.slice(7,19)}.json`));if(oe(JSON.parse(d.toString("utf8")))!==s)throw new Error(`record ${o.seq} changed on disk while it was being read \u2014 run kane-cli context fsck`);return{rec:o,hash:s,raw:d}})}function Es(e,{rec:t,hash:n,raw:r}){{let o=Bn(t),i=o.blobs.map(s=>{let d=ce(e,s);if(d===null)throw new R("SYNC_CLOSURE_MISSING",`record ${t.seq} names blob ${s}, which this store does not hold`,"restore the blob from a copy of this store, or run kane-cli context fsck");if(Ot(d)!==s)throw new R("SYNC_LOCAL_BLOB_CORRUPT",`record ${t.seq} names blob ${s}, but the local file does not hash to that: it is torn`,"restore the blob from a copy of this store, or run kane-cli context fsck");return{key:Jn(s),fp:s,bytes:d}});return{seq:t.seq,hash:n,raw:new Uint8Array(r),blobs:i,proposal:Os(e,o.proposalId)}}}function Os(e,t){if(t===null)return null;let n=ln(e,t);if(!Rs(n))return null;let r=Rr(n);return{key:Vn(t,Dn(r.toString("utf8"))),bytes:r}}import{existsSync as Cs,readdirSync as As,readFileSync as Ir}from"fs";import{basename as Ps,join as Lt}from"path";var Ns=/^\d{6}-[0-9a-f]{12}\.json$/;function Bt(e,t){let n=Lt(e,"commits"),r=Cs(n)?As(n).filter(s=>Ns.test(s)).sort():[],o=t.hash,i=t.seq;return r.map(s=>{let d;try{d=JSON.parse(Ir(Lt(n,s),"utf8"))}catch(a){throw new O(`backup record ${s} is not JSON: ${String(a)}`)}if(i+=1,d.seq!==i||d.prev_hash!==o)throw new O(`backup record ${s} does not continue the chain at ${i} from ${String(o)}`);let c=oe(d);if(!c.slice(7).startsWith(s.slice(7,19)))throw new O(`backup record ${s} does not match its name`);return o=c,{seq:i,hash:c,body:d}})}function pt(e,t){let n=JSON.parse(Ir(Lt(t,"base-witness.json"),"utf8")),r=$e(e),o=r.records.slice(0,n.base.seq),i=Bt(t,n.base),s=[...o,...i.map(f=>f.body)],d=[...r.hashes.slice(0,n.base.seq),...i.map(f=>f.hash)],c=new Map;for(let f of s)for(let u of f.nodes)c.set(u.cid,{label:u.label,content:u.content});let a=_n();Rn(e,a,s,d,{writeNodeFiles:!1});let l=Nn(e,a,c),g=new Map(i.map(f=>[f.seq,f])),p=f=>l.displayNameOf(f)??f.slice(0,19);return{backupDir:t,backupId:Ps(t),from:n.from,base:n.base,index:a,graph:l,records:i,chain:s,recordAt:f=>g.get(f),resolveName:f=>l.resolve(f)?.cid,nameOf:f=>l.displayNameOf(f)??void 0,displayNameFor:f=>{let u=Dt(t,f),y=Object.keys(f.source_head_moves),b=u==="revert"?String(qs(t,f)??""):u==="names"?(f.names??[]).map(h=>h.slug).join(", "):y.length>0?y.join(", "):f.nodes.length>0?[...new Set(f.nodes.map(h=>p(h.cid)))].join(", "):(f.executions?.length??0)>0?[...new Set(f.executions.map(h=>p(h.about)))].join(", "):f.review.length>0?[...new Set(f.review.map(h=>p(h.id)))].join(", "):f.supersessions.length>0?[...new Set(f.supersessions.map(h=>h.kind==="node"?p(h.old):h.ecid.slice(0,19)))].join(", "):y.join(", ");return b?`${u} ${b}`:u}}}function qs(e,t){try{let r=Oe(e,oe(t))?.args?.seq;return typeof r=="number"?r:void 0}catch{return}}function Dt(e,t){let n=null;try{n=Oe(e,oe(t))}catch{n=null}if(n)return n.verb;if(t.intent_verb)return t.intent_verb;let r=Object.entries(t.source_head_moves);return(t.executions?.length??0)>0?"execution":t.design_of?"design":t.proposal_id!=null?"extract":t.conv?t.conv.turn===0?"conv-mint":"conv-turn":r.length===1&&r[0][1]===null&&t.supersessions.some(o=>o.kind==="node"&&o.new===null)?"retire":r.length===1&&typeof r[0][1]=="string"&&t.nodes.some(o=>o.label==="source")?"ingest":t.review.some(o=>o.resolution==="reset")||t.supersessions.some(o=>o.kind==="node"&&o.new===o.old||o.kind==="edge"&&o.revoke)?"revert":t.nodes.length===0&&t.edges.length===0&&t.supersessions.length===1&&t.supersessions[0].kind==="node"&&t.supersessions[0].new===null?"archive":t.nodes.length===0&&t.edges.length===0&&t.review.length===0&&(t.names?.length??0)>0?"names":t.nodes.length===0&&t.edges.length===0&&t.supersessions.length===0&&t.review.length>0?"review":"unknown"}import{existsSync as Sr,readdirSync as js,readFileSync as Mt}from"fs";import{isAbsolute as Ts,join as ut,normalize as xs,relative as Fs,sep as Ls}from"path";var Bs=e=>e===""||Ts(e)||e.includes("\\")||xs(e).split(Ls).some(t=>t==="..")||e.startsWith("./")||e.includes("\0");function He(e){let t=ut(e,"manifest.json");if(!Sr(t))throw new O(`backup ${e} has no manifest.json \u2014 it was never completed; kane-cli context sync doctor`);let n;try{n=JSON.parse(Mt(t,"utf8"))}catch(s){throw new O(`backup manifest ${t} is not JSON: ${s instanceof Error?s.message:String(s)}`)}if(!Array.isArray(n))throw new O(`backup manifest ${t} is not a list`);let r=new Set,o=[];for(let s of n){let d=typeof s?.name=="string"?s.name:"";if(Bs(d))throw new O(`backup manifest names an unsafe path ${JSON.stringify(s?.name)} \u2014 the backup is not trusted`);let c=ut(e,d);if(!Sr(c))throw new O(`backup file ${d} is missing from ${e}`);let a=Mt(c);if("sha256:"+rn(a)!==s.hash)throw new O(`backup file ${d} does not match its manifest hash \u2014 the backup was changed after it was written`);if(d.startsWith("commits/"))try{r.add(oe(JSON.parse(a.toString("utf8"))))}catch(l){throw new O(`backup record ${d} is not a record: ${l instanceof Error?l.message:String(l)}`)}d.startsWith("intents/")&&o.push(d)}let i=new Set(n.map(s=>s.name));for(let s of Er(e)){let d=Fs(e,s);if(d!=="manifest.json"&&!i.has(d))throw new O(`backup ${e} holds ${d}, which its manifest does not name \u2014 the backup was changed after it was written`)}for(let s of o){let d;try{d=JSON.parse(Mt(ut(e,s),"utf8"))}catch(a){throw new O(`backup envelope ${s} is not JSON: ${a instanceof Error?a.message:String(a)}`)}let c=pn(d);if(c!==null)throw new O(`backup envelope ${s} is not a valid intent: ${c}`);if(typeof d.born?.hash!="string"||!r.has(d.born.hash))throw new O(`backup envelope ${s} was born from a record the backup does not hold`)}}function Er(e){let t=[];for(let n of js(e,{withFileTypes:!0})){let r=ut(e,n.name);n.isDirectory()?t.push(...Er(r)):t.push(r)}return t}import{basename as co,join as lo}from"path";import{existsSync as po,readFileSync as uo}from"fs";var G=class extends Error{},B=(e,t)=>({kind:"apply",inputs:e,...t&&t.length>0?{aliases:t}:{}}),V=e=>({kind:"noop",reason:e}),Ht=e=>({kind:"dedupe",as:e}),k=(e,t,n,r,o={})=>({kind:"hold",hold:{kind:e,mine:t,theirs:n,answers:r,detail:o}}),Or=(e,t)=>{let n=ft(t.label,t.content);return e.graph.byLabel(t.label).filter(r=>!e.graph.superseded.has(r.cid)&&ft(t.label,r.content)===n).map(r=>r.cid)},re=e=>e?e.slice(0,19):"none",H=(e,t)=>e.maps.cid.rewrite(t);function I(e,t,n){if(typeof t!="string")throw new G(`${n} was not pinned`);let r=H(e,t);if(!e.graph.hasNode(r))throw new G(`${n} ${_(e,t)} has no counterpart on ${e.location}`);return r}var j=(e,t)=>e.graph.tipOf(t),Gt=(e,t)=>e.graph.superseded.has(e.graph.tipOf(t)),_=(e,t)=>e.fold.nameOf(t)??re(t),S=(e,t)=>e.graph.displayNameOf(t)??re(t);function Jt(e,t,n,r){let o=r==="fold"?e.fold.graph:e.graph,i=o.displayNameOf(t);if(i!==null&&i!==n)return i;let s=o.tipOf(t);for(let[a,l]of o.heads)if(l===t||l===s)return a;let d=o.getNode(t);if(d?.label==="source"&&typeof d.content.source_id=="string")return d.content.source_id;let c=d?.content.title??d?.content.text??d?.content.statement;return d&&typeof c=="string"&&c!==""?`${d.label} "${z(c,32)}"`:re(t)}var L=e=>e.created_by?.by?.id??e.review[0]?.by.id??e.supersessions[0]?.by.id??e.names?.[0]?.by.id??"someone",P=e=>e.ts;function z(e,t=48){let n=typeof e=="string"?e:JSON.stringify(e);return n.length>t?`${n.slice(0,t-1)}\u2026`:n}function he(e,t,n,r){return`${[...new Set([...Object.keys(e),...Object.keys(t)])].filter(s=>s!=="derived"&&JSON.stringify(e[s])!==JSON.stringify(t[s])).map(s=>`${s} "${z(e[s]??"")}" \u2192 "${z(t[s]??"")}"`).join(", ")||"no field changed"} by ${n} at ${r}`}function ie(e,t){for(let n of e.theirs)for(let r of n.supersessions)if(r.kind==="node"&&r.old===t)return{rec:n,next:r.new}}function Vt(e,t){let n=new Set([t]);for(let o=!0;o;){o=!1;for(let[i,s]of e.graph.superseded)typeof s=="string"&&n.has(s)&&!n.has(i)&&(n.add(i),o=!0)}let r=[];for(let o of e.theirs)for(let i of o.review)n.has(i.id)&&i.resolution!=="pending"&&r.push({rec:o,resolution:i.resolution});return r}var Ds=new Set(Object.values(Ze).filter(e=>e!==Ze.DERIVES&&e!==Ze.ANNOTATES));function Wt(e,t){let n=new Set,r=[],o=[t,e.graph.tipOf(t)];for(;o.length>0;){let i=o.pop();if(!n.has(i)){n.add(i);for(let s of e.graph.edgesInto(i))!Ds.has(s.type)||e.graph.superseded.has(s.src)||(!(s.src in e.fold.index.nodeLabel)&&!r.some(d=>d.cid===s.src)&&r.push({cid:s.src,label:e.graph.nodeLabel.get(s.src)??"node"}),o.push(s.src))}}return r}function Ut(e){let t=new Map;for(let n of e)t.set(n.label,(t.get(n.label)??0)+1);return[...t].map(([n,r])=>`${r} ${n}${r===1?"":"s"}`).join(", ")}function ht(e,t,n){if(!e.theirs.some(o=>o.edges.some(i=>i.type===t&&i.src===n)))return;let r=e.graph.edgesFrom(n).find(o=>o.type===t);return r?{live:r.dst}:void 0}function Ie(e,t){let n=t.event_ids??[],r=n.filter(i=>i in e.index.eventDigests);return n.length===0||r.length===0?void 0:r.every(i=>{let s=n.indexOf(i),d=t.event_digests?.[s];return d!==void 0&&d!==""&&e.index.eventDigests[i]===d})&&r.length===n.length?V("already applied: every event id is in the chain with the same intent"):k("ambiguous",`committed ${n.length} event id${n.length===1?"":"s"}`,`${r.length} of them already in the shared chain under another intent`,["keep-theirs"],{event_ids:n})}function Ms(e){return String(e??"").toLowerCase().trim().replace(/\s+/g," ")}function ft(e,t){let n=t.question;return`${e}\0${Ms(t.title??t.text??t.statement??n?.header??t.source_id??"")}`}function Cr(e,t){let n=[],r=new Set;for(let o of e.nodes){let i=ft(o.label,o.content),s=t.nodes.find(d=>!r.has(d.cid)&&ft(d.label,d.content)===i);s&&(r.add(s.cid),n.push([o.cid,s.cid]))}for(let o of e.nodes){if(n.some(([s])=>s===o.cid))continue;let i=t.nodes.find(s=>!r.has(s.cid)&&s.label===o.label);i&&(r.add(i.cid),n.push([o.cid,i.cid]))}return n}function Ar(e,t){let n=[],r=new Set;for(let o of t.names??[]){if(!tt.test(o.slug))continue;let i=t.nodes.find(d=>d.cid===o.cid);if(!i||e.graph.nameOf.has(H(e,o.cid)))continue;let s=nt(i.label,d=>r.has(d),e.graph.names.keys());s!==null&&(r.add(s),s!==o.slug&&n.push({from:o.slug,to:s}))}return n}function Pr(e,t,n){let r=[];for(let o of e.names??[]){let i=n.find(([d])=>d===o.cid)?.[1],s=t.names?.find(d=>d.cid===i);s&&s.slug!==o.slug&&r.push({from:o.slug,to:s.slug})}return r}function Nr(e,t,n){let r=e===void 0?void 0:e.split(`
|
|
4
4
|
`).map(s=>{let d=/^(##\s.*?)\s@verifies\s+(.+?)\s*$/.exec(s);if(d)return`${d[1]} @verifies ${d[2].split(",").map(l=>l.trim()).filter(Boolean).map(n).join(", ")}`;let c=/^(\s*)@import\s+(\S+)\s*$/.exec(s);if(c)return`${c[1]}@import ${n(c[2])}`;let a=/^## Import: (\S+)\s*$/.exec(s);return a?`## Import: ${n(a[1])}`:s}).join(`
|
|
5
5
|
`),o=!1,i=t===void 0?void 0:t.split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as m,c}from"./chunk-EYOCNMUM.js";import{c as b,j as h}from"./chunk-
|
|
2
|
+
import{a as m,c}from"./chunk-EYOCNMUM.js";import{c as b,j as h}from"./chunk-HYTBEPC2.js";import{readFileSync as w,writeFileSync as y,mkdirSync as C,existsSync as k}from"fs";import{dirname as x}from"path";var f={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:h,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0};function T(o){let{mobile:e,...i}=o,t={...i};delete t.target,delete t.device,delete t.device_name,delete t.os_version,delete t.app;let n=e??{};n.tui_target&&(t.target=n.tui_target);let s=n.default_target?.name?.trim(),l=n.default_target?.os_version?.trim();if(s||l)s&&(t.device_name=s),l&&(t.os_version=l);else{let r=n.default_target?.id?.trim();r&&(t.device=r)}n.default_app&&(t.app=n.default_app);let a={};return n.no_reset!==void 0&&(a.no_reset=n.no_reset),n.appium_url!==void 0&&(a.appium_url=n.appium_url),n.auto_grant_permissions!==void 0&&(a.auto_grant_permissions=n.auto_grant_permissions),n.auto_accept_alerts!==void 0&&(a.auto_accept_alerts=n.auto_accept_alerts),Object.keys(a).length>0&&(t.mobile=a),t}function S(o){let e=o.mobile??{},i=typeof o.target=="string"?o.target:void 0,t=typeof o.device=="string"&&o.device.trim()!==""?o.device.trim():void 0,n=g=>typeof g=="string"&&g.trim()!==""?g.trim():void 0,s=n(o.device_name),l=n(o.os_version),a=typeof o.app=="string"&&o.app!==""?o.app:void 0,r={},u=i??e.tui_target;u&&(r.tui_target=u);let _=m(u,void 0).kind,d=_==="emulator"||_==="simulator"?_:null;d&&(s||l)?r.default_target={platform:c(d),kind:d,...s?{name:s}:{},...l?{os_version:l}:{}}:d&&t?r.default_target={platform:c(d),kind:d,id:t}:(e.default_target?.id?.trim()||e.default_target?.name?.trim())&&(r.default_target=e.default_target);let p=a??e.default_app;return p&&(r.default_app=p),e.no_reset!==void 0&&(r.no_reset=e.no_reset),e.appium_url!==void 0&&(r.appium_url=e.appium_url),e.auto_grant_permissions!==void 0&&(r.auto_grant_permissions=e.auto_grant_permissions),e.auto_accept_alerts!==void 0&&(r.auto_accept_alerts=e.auto_accept_alerts),Object.keys(r).length>0?r:void 0}var v=class{constructor(e=b){this.path=e}exists(){return k(this.path)}load(){try{let e=w(this.path,"utf-8"),i=JSON.parse(e),t=S(i),{target:n,device:s,app:l,...a}=i;return{...f,...a,...t?{mobile:t}:{},code_export:{...f.code_export,...i.code_export??{}},generate:{...f.generate,...i.generate??{}}}}catch{return{...f,code_export:{...f.code_export},generate:{...f.generate}}}}write(e){try{C(x(this.path),{recursive:!0}),y(this.path,JSON.stringify(T(e),null,2)+`
|
|
3
3
|
`)}catch(i){let t=i instanceof Error?i.message:String(i);process.stderr.write(`[config] Failed to save config: ${t}
|
|
4
4
|
`)}}set(e,i){let t=this.load();t[e]=i,this.write(t)}save(e){this.write({...this.load(),...e})}getMobile(){return this.load().mobile??{}}setMobile(e){let i={...this.getMobile()};for(let t of Object.keys(e)){let n=e[t];n===void 0?delete i[t]:i[t]=n}this.set("mobile",Object.keys(i).length>0?i:void 0)}writeRaw(e){this.write(e)}};export{v as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as B,c as S,d as T}from"./chunk-
|
|
2
|
+
import{b as B,c as S,d as T}from"./chunk-GSDXZS4U.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-XXE7W5AV.js";import{y as n}from"./chunk-HYTBEPC2.js";import{a as h}from"./chunk-HCBYKLMW.js";import{a as i,b as c,c as w,i as x}from"./chunk-C44QQJR4.js";import{a as L}from"./chunk-6YGTRKDT.js";import{e as u}from"./chunk-UR6MHSHU.js";var l=u(L(),1);var r=u(h(),1);function y(e){return new Map(e.map((o,s)=>[`${s}-${o.label}`,o.packPath]))}async function H(e){let o=e.deps?.viewerBase??S(e.env),s=e.deps?.startServer??B,a=e.deps?.openUrl??(m=>g(m).then(()=>{})),t=y(e.rows),d;try{d=await s({packs:t,allowedOrigins:[new URL(o).origin]});let m=d,D=async p=>{let v=[...t.keys()][p];await a(T(m.urlFor(v),o))};if(e.deps?.hold){await e.deps.hold();return}await new Promise(p=>{let v=w(l.default.createElement(P,{rows:e.rows,onOpen:D,onDone:()=>{v.unmount(),p()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}finally{await d?.close()}}function I(e){return e==="passed"?n.green:e==="failed"||e==="broken"||e==="cancelled"?n.red:n.dim}var b=40,R=9,k=20;function f(e,o){return e.length>o?e.slice(0,o-1)+"\u2026":e.padEnd(o)}function O({row:e,selected:o}){let s=e.testId??e.commitId??"";return(0,r.jsxs)(i,{children:[(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:n.orange,children:o?"\u25B8":" "})}),(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:e.kind==="execution"?n.orange:n.muted,children:e.kind==="execution"?"\u25CF":"\u25CB"})}),(0,r.jsx)(i,{width:b,flexShrink:0,children:(0,r.jsx)(c,{color:o?n.orange:void 0,bold:o,wrap:"truncate-end",children:f(e.label,b)})}),(0,r.jsx)(i,{width:R,flexShrink:0,children:(0,r.jsx)(c,{color:I(e.status),bold:o,wrap:"truncate-end",children:f(e.status,R)})}),(0,r.jsx)(i,{width:k,flexShrink:0,children:(0,r.jsx)(c,{color:n.dim,wrap:"truncate-end",children:f(s,k)})})]})}function P(e){let[o,s]=(0,l.useState)(0);return x((a,t)=>{t.upArrow?s(d=>Math.max(0,d-1)):t.downArrow?s(d=>Math.min(e.rows.length-1,d+1)):t.return||a==="o"?e.onOpen(o):(a==="q"||t.escape)&&e.onDone()}),(0,r.jsx)(E,{title:"Evidence",borderColor:n.muted,children:(0,r.jsxs)(i,{flexDirection:"column",children:[e.rows.map((a,t)=>(0,r.jsx)(O,{row:a,selected:t===o},t)),(0,r.jsx)(i,{marginTop:1,children:(0,r.jsx)(c,{color:n.dim,children:"\u2191/\u2193 move \xB7 enter/o open \xB7 q quit"})})]})})}export{y as a,H as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as G,f as q,h as H}from"./chunk-
|
|
2
|
+
import{d as G,f as q,h as H}from"./chunk-6L5RV62W.js";import{a as j,b as z,c as K}from"./chunk-QVLYK5JL.js";import{d as B,f as O}from"./chunk-A557OSRS.js";import{a as N}from"./chunk-MMBBQ4OZ.js";import{b as F,c as $,j as R}from"./chunk-6GLFQHSW.js";import{a as L}from"./chunk-TZXXJWHA.js";import{n as T}from"./chunk-RSSOJ3L2.js";import{a as Y,b as C,c as V}from"./chunk-IAHOLH5W.js";import{h as J}from"./chunk-TAOHYWEO.js";import{e as E}from"./chunk-Z7S3IWUX.js";import{b as M}from"./chunk-HYTBEPC2.js";function X(e){return e.kind==="simulator"?e.id:e.virtualName??e.id}function Z(e,r,t={}){let o={platform:e.platform,udid:e.id,target_kind:e.kind};return r&&(o.app_package=r),t.noReset!==void 0&&(o.no_reset=t.noReset),t.appiumUrl&&(o.appium_url=t.appiumUrl),e.platform==="android"&&t.autoGrantPermissions!==void 0&&(o.auto_grant_permissions=t.autoGrantPermissions),e.platform==="ios"&&t.autoAcceptAlerts!==void 0&&(o.auto_accept_alerts=t.autoAcceptAlerts),o}function Q(e=process.env){let r=e.KANE_APPIUM_URL?.trim();return r||null}import{createHash as De}from"crypto";import{readdir as ke,stat as xe}from"fs/promises";import{basename as g,extname as Ie,join as Ue,relative as Se}from"path";import{createHash as ge}from"crypto";import{createReadStream as fe}from"fs";import{mkdir as me,readFile as he,rename as ve,writeFile as we}from"fs/promises";import{dirname as be,join as ye}from"path";var Pe=60,Te=5;function W(){return{entries:[]}}function ee(){return ye(M,"mobile","app-cache.json")}async function A(e){let r=ge("sha256");for await(let t of fe(e))r.update(t);return r.digest("hex")}function Ce(){return{readFile:e=>he(e,"utf8"),writeFile:async(e,r)=>{await me(be(e),{recursive:!0});let t=`${e}.tmp`;await we(t,r),await ve(t,e)},hashFile:A,now:()=>new Date}}function D(e){if(!e)return;let r=/\/(\d{4})\/(\d{2})\/(\d{2})\//.exec(e);if(!r)return;let[,t,o,a]=r,s=new Date(`${t}-${o}-${a}T00:00:00Z`);return Number.isNaN(s.getTime())?void 0:s.toISOString()}function Ae(e,r){if(!e.storedAt)return!0;let t=new Date(e.storedAt).getTime();return Number.isNaN(t)?!0:(r.getTime()-t)/864e5>=Pe-Te}var u=class{deps;constructor(r={}){this.deps={...Ce(),...r}}async read(){try{let r=JSON.parse(await this.deps.readFile(ee()));if(!r||typeof r!="object")return W();let t=r;return{entries:Array.isArray(t.entries)?t.entries:[]}}catch{return W()}}async write(r){await this.deps.writeFile(ee(),JSON.stringify(r,null,2))}async hashOf(r){return this.deps.hashFile(r)}async lookup(r){return(await this.read()).entries.find(o=>o.sha256===r.sha256&&o.env===r.env&&o.orgId===r.orgId&&o.type===r.type)}async remember(r){let t=await this.read();t.entries=[...t.entries.filter(o=>!(o.sha256===r.sha256&&o.env===r.env&&o.orgId===r.orgId&&o.type===r.type)),r],await this.write(t)}async forget(r){let t=await this.read(),o=t.entries.length;t.entries=t.entries.filter(a=>!(a.sha256===r.sha256&&a.env===r.env&&a.orgId===r.orgId&&a.type===r.type)),t.entries.length!==o&&await this.write(t)}isNearExpiry(r){return Ae(r,this.deps.now())}};var re={emulator:[".apk"],simulator:[".zip"]};function te(e){return e.skipped===!0}function _e(e,r){let t=Ie(e).toLowerCase();return t===".ipa"?`${g(e)} is a device build \u2014 .ipa is not accepted for ${r} runs.`:re[r].includes(t)?null:`${g(e)} cannot be uploaded for a ${r} run \u2014 expected one of ${re[r].join(", ")}.`}async function k(e,r){if(!(await xe(e)).isDirectory())return r.hashOf(e);let o=[],a=async p=>{for(let i of await ke(p,{withFileTypes:!0})){let n=Ue(p,i.name);i.isDirectory()?await a(n):i.isFile()&&o.push(n)}};await a(e),o.sort();let s=De("sha256");for(let p of o)s.update(Se(e,p)),s.update("\0"),s.update(await A(p)),s.update("\0");return s.digest("hex")}async function oe(e){let r=_e(e.path,e.type);if(r)return{skipped:!0,reason:r};let t=e.cache??new u,o=e.client??new J(e.baseUrl,{...e.auth,orgId:e.orgId}),a;try{a=await k(e.path,t)}catch(i){return{skipped:!0,reason:`could not read ${g(e.path)}: ${i.message}`}}let s={sha256:a,env:e.env,orgId:e.orgId,type:e.type},p=await t.lookup(s);if(p){if(await o.liveness(p.appId)!=="gone")return{appId:p.appId,...p.appUrl?{appUrl:p.appUrl}:{},fromCache:!0};e.onProgress?.(`${p.appId} is no longer in the cloud \u2014 uploading again`),await t.forget(s)}try{e.onProgress?.(`uploading ${g(e.path)}\u2026`);let i=await o.upload(e.path,e.type);return await t.remember({sha256:a,env:e.env,orgId:e.orgId,type:e.type,appId:i.appId,...i.appUrl?{appUrl:i.appUrl}:{},...D(i.url)?{storedAt:D(i.url)}:{},sourcePath:e.path}),e.onProgress?.(i.cached?`${g(e.path)} already in the cloud (${i.appId})`:`${g(e.path)} uploaded (${i.appId})`),{appId:i.appId,...i.appUrl?{appUrl:i.appUrl}:{},fromCache:!1}}catch(i){return{skipped:!0,reason:i.message}}}function v(e){return`${e.platform}|${X(e)}`}var m=new Map,ae=new Set;function ie(e){return ae.has(v(e))}function nr(e,r,t){r.state==="stopped"&&(m.has(v(r))||se(e,r,t))}async function ne(e,r,t){let o=m.get(v(r));return o?(t?.(`waiting for ${r.displayName} to finish booting\u2026`),o):se(e,r,t)}function se(e,r,t){let o=v(r),a=e.prepare(r,t);m.set(o,a),r.state==="stopped"&&a.then(()=>ae.add(o),()=>{});let s=()=>{m.get(o)===a&&m.delete(o)};return a.then(s,s),a.catch(()=>{}),a}import{basename as Me}from"path";import{spawnSync as Ee}from"child_process";async function Fe(e,r,t){if(!e.teardownPlan||!t.appPackage&&!t.shutdown)return;let o;try{o=await e.teardownPlan(r,t)}catch{return}o.length!==0&&T(`device:${r.id}`,()=>{G({udid:r.id,displayName:r.displayName});for(let a of o)try{Ee(a.file,a.args,{timeout:3e4,stdio:"ignore"})}catch{}})}var pe={emulator:[".apk"],simulator:[".zip"]};async function $e(e,r,t,o){if(e.kind==="package")return e;if(e.kind==="app_id"){let a=r.cloudUpload;if(!a)throw new Error(`${e.value} is an app id, which needs an account to download it. Log in, or pass a path to a local build instead.`);let s=await V({appId:e.value,baseUrl:a.baseUrl,auth:a.auth,...pe[t]?{accepts:pe[t]}:{},...o?{onProgress:o}:{}}),p=I(s.path);if(!p||p.kind==="app_id")throw new Error(`${s.name} is not a build this CLI can install (from ${e.value}).`);return p}try{let a=new u,s=await k(e.value,a),p=new Y;await p.find(s)||o?.(`copying ${Me(e.value)} into the local app store\u2026`);let n=await p.put({key:s,sourcePath:e.value,source:"local"});return{...e,value:n.path}}catch{return e}}function Re(e){T(`appium:${e}`,()=>{H({deviceClass:e,owner:process.pid})})}var x=class extends Error{constructor(r){super(r),this.name="MobileHostUnsupportedError"}},w=class extends Error{constructor(t,o){super(t);this.doctorText=o;this.name="MobilePreflightError"}};async function Ne(e,r,t){let o=t.cloudUpload,a=await oe({path:e,type:r,env:o.env,orgId:o.orgId,userId:o.userId,auth:o.auth,baseUrl:o.baseUrl,...t.onProgress?{onProgress:t.onProgress}:{}});if(te(a)){t.onProgress?.(`app not uploaded \u2014 ${a.reason}`);return}return a.appId}var Be="app must be a build (.apk for an emulator, .zip of the .app bundle for a simulator) or an app id from your cloud uploads \u2014 a package id names something already installed on one device, so it cannot be uploaded, exported as code, or run anywhere else.",de=/\.(apk|zip)$/i;function I(e){let r=e.trim();if(C(r))return{kind:"app_id",value:r};let t=de.exec(r)?.[1]?.toLowerCase();return t?{kind:t,value:r}:null}function Oe(e){return!!e&&(de.test(e)||C(e.trim()))}function Le(e){return e.filter(r=>r.required&&r.status==="fail")}function je(e,r){return!!r&&E(e,r)}async function Dr(e){let r=L();if(!r.supported)throw new x(r.reason);let t=Q()??e.appiumUrl??e.defaults?.appium_url,o=!!(e.agent||!e.interactive),a=R(),s=!!N();o&&e.platform?.toLowerCase()!=="ios"&&!s&&((await a.status("emulator")).installed||await a.ensure("emulator",{automatic:!0,onProgress:e.onProgress}));let p=await j(e.platform,{appiumUrl:t});if(K(p)){let d=p.sections.flatMap(P=>Le(P.checks)).map(P=>P.label).join(", ");throw new w(`Mobile toolchain not ready (${d}). Run \`kane-cli doctor --target ${e.platform?.toLowerCase()==="ios"?"simulator":e.platform?.toLowerCase()==="android"?"emulator":"<emulator|simulator>"}\` for details.`,z(p))}let i=await O({device:e.device,platform:e.platform,defaultTarget:e.defaults?.default_target,interactive:e.interactive}),n;if(i.ok)n=i.target;else if(i.reason==="needs-picker"&&e.pickTarget){let d=await e.pickTarget(i.candidates);if(!d)throw new Error("Target selection cancelled");n=d}else throw new Error(i.message);let f=B(n.platform);if(!f)throw new Error(`No provider for platform "${n.platform}"`);let l=F(n);if(!l)throw new Error(`No managed dependencies serve ${n.platform} ${n.kind} targets yet.`);if(!(s&&n.platform.toLowerCase()==="android"))try{await a.ensure(l,{automatic:o,onProgress:e.onProgress})}catch(d){throw d instanceof $?new w(d.message,d.message):d}let le=n.state!=="ready"||ie(n);n=await ne(f,n,e.onProgress);let ce=await q(l,{...t?{appiumUrl:t}:{},device:{udid:n.id,displayName:n.displayName},onProgress:e.onProgress});Re(l);let U=je(n,e.defaults?.default_target)?e.defaults?.default_app:void 0,h=e.app??(Oe(U)?U:void 0);if(e.app&&!I(e.app))throw new Error(`${e.app}: ${Be}`);let c=h?I(h):null,S=c?await $e(c,e,l,e.onProgress):null,b=S?await f.ensureApp(n,S,e.onProgress):void 0,y=c?.kind==="app_id"?c.value:e.cloudUpload&&c&&h?await Ne(c.value,l,e):void 0;await Fe(f,n,{shutdown:le,...b?{appPackage:b}:{}});let ue=Z(n,b,{noReset:e.noReset??e.defaults?.no_reset,appiumUrl:ce.url,autoGrantPermissions:e.defaults?.auto_grant_permissions,autoAcceptAlerts:e.defaults?.auto_accept_alerts}),_=y??h;return{device:ue,target:n,provider:f,...y?{appId:y}:{},..._?{appRef:_}:{}}}export{X as a,Z as b,te as c,_e as d,oe as e,nr as f,ne as g,x as h,w as i,Be as j,I as k,Oe as l,Dr as m};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as g}from"./chunk-BPMSNGXQ.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{a as m}from"./chunk-
|
|
2
|
+
import{a as g}from"./chunk-BPMSNGXQ.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{a as m}from"./chunk-EPE2ELDH.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new g(m(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),n=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(l=>l.name===n);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let l=await d.createProject(n);t=l.id,s=l.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(l=>l.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let l=await d.createFolder(t,o);c=l.id,i=l.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??n,folderId:c,folderName:i??o}}function A(e,r,d){let n=e.loadProfileConfig(r,d)??{};return{projectId:n.project_id??null,folderId:n.folder_id??null}}function N(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
|
|
3
3
|
|
|
4
4
|
discover IDs:
|
|
5
5
|
kane-cli projects list --search "<keyword>" --limit 10
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as g}from"./chunk-
|
|
2
|
+
import{b as g}from"./chunk-HYTBEPC2.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
|
|
3
3
|
`),f(this.configFile,384)}getActiveProfile(){return this.readConfig().active_profile??null}setActiveProfile(t){let i=this.readConfig();i.active_profile=t,this.writeConfig(i)}getDefaultEnv(){return this.readConfig().default_env??"prod"}setDefaultEnv(t){let i=this.readConfig();i.default_env=t,this.writeConfig(i)}credentialsPath(t,i){return n(this.profilesDir,t,i,"credentials")}clientPath(t,i){return n(this.profilesDir,t,i,"client.json")}basicAuthPath(t,i){return n(this.profilesDir,t,i,"basic-auth")}profileConfigPath(t,i){return n(this.profilesDir,t,i,"profile-config.json")}saveProfileConfig(t,i,r){let e=this.loadProfileConfig(t,i)??{};this.writeSecure(this.profileConfigPath(t,i),{...e,...r})}loadProfileConfig(t,i){try{return JSON.parse(o(this.profileConfigPath(t,i),"utf-8"))}catch{return null}}writeSecure(t,i){try{u(P(t),{recursive:!0,mode:448}),h(t,JSON.stringify(i,null,2)+`
|
|
4
4
|
`),f(t,384)}catch(r){let e=r instanceof Error?r.message:String(r);process.stderr.write(`[auth] Failed to save credentials: ${e}
|
|
5
5
|
`)}}saveCredentials(t,i,r){this.writeSecure(this.credentialsPath(t,i),r)}loadCredentials(t,i){try{return JSON.parse(o(this.credentialsPath(t,i),"utf-8"))}catch{return null}}saveClient(t,i,r){this.writeSecure(this.clientPath(t,i),r)}loadClient(t,i){try{return JSON.parse(o(this.clientPath(t,i),"utf-8"))}catch{return null}}getActiveCredentials(){let t=this.getActiveProfile();if(!t)return{credentials:null,profile:null,env:null};let i=this.getDefaultEnv();return{credentials:this.loadCredentials(t,i),profile:t,env:i}}saveBasicAuth(t,i,r){this.writeSecure(this.basicAuthPath(t,i),r)}loadBasicAuth(t,i){try{return JSON.parse(o(this.basicAuthPath(t,i),"utf-8"))}catch{return null}}deleteBasicAuth(t,i){try{s(this.basicAuthPath(t,i))}catch{}}resolveAuth(){let t=this.getActiveProfile();if(!t)return null;let i=this.getDefaultEnv(),r=this.loadBasicAuth(t,i);return r?{method:"basic",...r,profile:t,env:i}:this.loadCredentials(t,i)?{method:"oauth",profile:t,env:i}:null}listProfiles(){let t=[];try{for(let i of a(this.profilesDir)){let r=n(this.profilesDir,i);try{for(let e of a(r)){let c=n(r,e),v=l(n(c,"credentials")),p=l(n(c,"client.json")),y=l(n(c,"basic-auth"));(v||p||y)&&t.push({profile:i,env:e})}}catch{}}}catch{}return t}deleteProfile(t,i){try{s(this.credentialsPath(t,i))}catch{}if(this.getActiveProfile()===t){let r=this.readConfig();delete r.active_profile,this.writeConfig(r)}}deleteProfileFull(t,i){if(i){try{s(this.credentialsPath(t,i))}catch{}try{s(this.clientPath(t,i))}catch{}try{s(this.basicAuthPath(t,i))}catch{}try{s(this.profileConfigPath(t,i))}catch{}}else try{let r=n(this.profilesDir,t);for(let e of a(r)){try{s(n(r,e,"credentials"))}catch{}try{s(n(r,e,"client.json"))}catch{}try{s(n(r,e,"basic-auth"))}catch{}try{s(n(r,e,"profile-config.json"))}catch{}}}catch{}}};export{d as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as
|
|
2
|
+
import{b as K,c as H}from"./chunk-PDXZROJM.js";import{S as G}from"./chunk-7EGIX6Y4.js";import{b as $}from"./chunk-5GUD3CIH.js";import{a as q}from"./chunk-27ERHOW3.js";import{a as It,b as k}from"./chunk-NBXYL2JT.js";import{a as V}from"./chunk-BPMSNGXQ.js";import{a as z}from"./chunk-DHJSM5DT.js";import{a as M}from"./chunk-NLCCBXXV.js";import{a as R}from"./chunk-RZ4F3BHX.js";import{e as yt}from"./chunk-UR6MHSHU.js";import{readFileSync as L,existsSync as U,readdirSync as ee,mkdirSync as F,writeFileSync as w}from"fs";import{readFile as Et,unlink as ne}from"fs/promises";import{join as E}from"path";import{existsSync as Kt,mkdirSync as Ht,readdirSync as pt,writeFileSync as Jt}from"fs";import{join as S}from"path";import{randomUUID as v}from"crypto";var vt=["children","instructions","branches","module_content","true_branch","false_branch"];function W(e){let t=new Map,n=i=>{if(!i||typeof i!="object")return;let r=i;if(Array.isArray(r.operations))for(let o of r.operations){let s=o.operation_id;typeof s=="string"&&s&&!t.has(s)&&t.set(s,r)}for(let o of vt){let s=r[o];Array.isArray(s)?s.forEach(n):s&&typeof s=="object"&&n(s)}};return e.forEach(n),t}function X(e,t){let n=new Map;for(let i of e){let r=i.action_id?t.get(i.action_id):void 0;if(!r)continue;let o=n.get(r)??[];o.push(i),n.set(r,o)}return n.size===0?null:[...n].map(([i,r])=>kt(i,r))}function At(e){if(!e.timestamp||e.duration_ms==null)return"";let t=new Date(e.timestamp);return isNaN(t.getTime())?"":new Date(t.getTime()+e.duration_ms).toISOString()}function J(e){if(e!=null)try{return JSON.parse(e)}catch{return e}}function Y(e,t,n){let i=e.user_variables,r=typeof i=="string",o;try{o=r?JSON.parse(i):i??[]}catch{return}if(!Array.isArray(o)||o.length===0)return;let s=o.find(c=>t&&c.name===t)??(o.length===1?o[0]:void 0);s&&(s.value=n,e.user_variables=r?JSON.stringify(o):o)}function kt(e,t){let n=structuredClone(e),i=t[0],r=t[t.length-1];switch(n.status=t.find(o=>o.status!=="success")?.status??i.status,n.start_timestamp=i.timestamp??n.start_timestamp,n.end_timestamp=At(r)||n.end_timestamp,n.content_type){case"api":{let o=r.action_params?.api_data?.response;o&&typeof o=="object"&&(n.api_data={...n.api_data??{},response:o},Y(n,r.output_variable,o));break}case"script":{r.output_value!=null&&Y(n,r.output_variable??n.output_variable_name,r.output_value);break}case"db_query":{r.output_value!=null&&(n.db_details={...n.db_details??{},carried_out_query:J(r.output_value)});break}case"screenshot_command":{let o=J(r.output_value);o&&typeof o=="object"&&(n.smartui_results=o);break}case"network_assertion":case"network_query":break;default:break}return n}var Rt="/home/kaneai/Downloads";function O(e){return`${Rt}/${e}`}function tt(e){return"FILE__"+e.replace(/[^A-Za-z0-9]/g,"_")}function N(e){let t=e?.media;return!t||!t.name||!t.media_url?null:{media_id:t.media_id??"",name:t.name,media_url:t.media_url,type:t.type??"doc"}}function et(e){return e?e.includes(`
|
|
3
3
|
`)?e.split(`
|
|
4
|
-
`).map(t=>t.trim()).filter(Boolean):e.split(". ").map(t=>t.trim()).filter(Boolean).map(t=>t.endsWith(".")?t:t+"."):[]}function T(e){return typeof e=="string"&&e.includes("{{secrets.")}var Rt={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"},et={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"},Pt=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function nt(e,t){if(e==="analyze"){let i=t?.action_params?.analyzer_type??"";return et[i]}if(e==="scroll"&&t?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let n=Rt[e];return n||console.warn(`[migrator] UNKNOWN action_type "${e}" \u2014 falling back to "${e.toUpperCase()}"; explicit mapping required`),n??e.toUpperCase()}function it(e,t){if(!e||!t)return"";try{let n=new Date(e);return isNaN(n.getTime())?"":new Date(n.getTime()+t).toISOString()}catch{return""}}function ot(e){try{return JSON.parse(e.output_value??"{}")}catch{return{}}}function St(e){let t=e.output_variable??"";if(!t)return"[]";let i={...ot(e)};return delete i.body,JSON.stringify([{name:t,unique_key:(e.action_id??"").replace(/-/g,"").slice(0,8)||v().replace(/-/g,"").slice(0,8),value:i,variable_description:"API Response"}])}function wt(e,t,n){let i=e.action_params??{},r=Pt.has(t)?"Vision Agent":"Operation Agent",o={operation_type:t};if(t==="OPEN"&&(o.url=i.url??""),t==="SET_VARIABLE"&&(o.variable_name=e.output_variable??i.key??"",o.variable_value=e.output_value??""),t==="UPLOAD_FILE"){let m=N(i);m&&(o.value=O(m.name))}let s={},c={},a=e.action_instruction??"",l=i.text??"",u=i.url??"",_=[["intent",a],["value",l],["url",u]];for(let[m,h]of Object.entries(n)){let I=String(h);if(m.startsWith("secrets."))for(let[y,b]of _)b.includes(I)&&(c[y]=m);for(let[y,b]of _)b.includes(I)&&!(y in s)&&(s[y]=b)}let p=e.action_type,d={operation:e.action_instruction??"",agent:r,operation_dict:o,reasoning:p==="analyze"?i.query??"":e.intent??e.action_instruction??"",variable:s,secrets:c,params:{}};p==="analyze"&&typeof i.code=="string"&&i.code&&(d.code=i.code),p==="analyze"&&typeof i.code_js=="string"&&i.code_js&&(d.code_js=i.code_js),p==="analyze"&&typeof i.condition_expression=="string"&&i.condition_expression&&(d.condition_expression=i.condition_expression),i.uses_websocket===!0&&(d.uses_websocket=!0),i.uses_sse===!0&&(d.uses_sse=!0),p==="analyze"&&i.analyzer_type==="textual_visual"&&(typeof i.wrapped_js=="string"&&(d.wrapped_js=i.wrapped_js),Array.isArray(i.locators)&&(d.locators=i.locators),typeof i.operator=="string"&&(d.operator=i.operator),Array.isArray(i.transforms)&&(d.transforms=i.transforms),typeof i.query=="string"&&(d.query=i.query),typeof i.expected_value=="string"&&(d.expected_value=i.expected_value),typeof i.needs_unit_conversion=="boolean"&&(d.needs_unit_conversion=i.needs_unit_conversion),typeof i.condition=="string"&&(d.condition=i.condition));let f={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[p];return f&&i[f]!==void 0&&(d[f]=i[f]),p==="set_clipboard"&&typeof i.html=="string"&&i.html&&(d.html=i.html),d}function xt(e){let t=e.assertion_tree??{};if(typeof t.passed=="boolean")return t.passed;let n=t.sub_results??[];return n.length===0?t.status==="passed":(t.composite_operator??"and")==="or"?n.some(r=>r.passed===!0):n.every(r=>r.passed===!0)}function rt(e){return e.map(t=>({description:t.description??"",store_key:t.store_key??"",expected_value:t.expected??"",extracted_value:t.extracted_value??"",operator:t.operator??"equals",transforms:t.transforms??[]}))}function Ot(e){let t=e.assertion_tree??{},n=t.sub_results??[],i=rt(n);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:n,sub_checks:i,composite_operator:t.composite_operator??"and",verification:t.verification??"",claim:t.description??""}}function Nt(e){let n=(e.action_params??{}).assertion_tree??{},i=n.sub_results??[],r=rt(i);return[{operation:e.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:i,sub_checks:r,composite_operator:n.composite_operator??"and",verification:"",claim:n.description??e.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function Lt(e,t,n,i){let r=e.visual_data;if(!r||r.x==null||r.y==null)return null;let o=t?`${t}/test_screenshots`:"";return{x:r.x,y:r.y,confidence:0,bbox:r.bbox??null,bbox_source:r.bbox?"accessibility_tree":"fallback",viewport_width:r.viewport_width??1280,viewport_height:r.viewport_height??800,scale_factor:null,raw_image_url:o?`${o}/untagged_screenshot/${n}.${i?.get(n)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function Tt(e){if(!e)return"";let t=e;return typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.frameInfo)&&(t=e.frameInfo),!Array.isArray(t)||t.length===0?"":JSON.stringify(t)}function Ct(e){return/^(android|ios)_native$/i.test(e.platform??"")}function st(e,t){return e.map(n=>({...n,type:t?n.strategy??n.type??"native":n.isXPath?"xpath":"css"}))}function jt(e,t,n){let i={selector_target:"",drag_displacement:{},hold_duration_ms:null,move_duration_ms:null,hold_at_destination_ms:null};if(e!=="drag")return i;let r=t.target_selectors,o={};typeof t.direction=="string"&&t.direction&&(o.direction=t.direction,typeof t.fraction=="number"&&(o.fraction=t.fraction));let s=c=>typeof t[c]=="number"?Math.trunc(t[c]):null;return{selector_target:Array.isArray(r)&&r.length>0?st(r,n):"",drag_displacement:o,hold_duration_ms:s("hold_duration_ms"),move_duration_ms:s("move_duration_ms"),hold_at_destination_ms:s("hold_at_destination_ms")}}function X(e,t="",n){let i=e.action_type,r=nt(i,e),o=e.action_params??{},s=e.coordinates??null,c=e.selectors??null,a=!!(c&&c.length>0),l=Ct(e),u=jt(i,o,l),_=e.timestamp??"",p=e.duration_ms??0,d=e.variables_used??{},g=e.action_id??v(),f=v(),m=it(_,p),h="",I="";if(i==="navigate")I=o.url??"",h=I;else if(i==="type"||i==="fill")h=o.text??"";else if(i==="press_key")h=o.key??"";else if(i==="wait")h=String(o.ms??o.timeout_ms??"");else if(i==="evaluate_js")h=o.script??"";else if(i==="upload_files"){let B=N(o);B&&(h=O(B.name))}else i==="analyze"&&r==="SET_VARIABLE"&&(h=e.output_value??"");let y="";i==="go_back"?y="back":i==="go_forward"&&(y="forward");let b=e.action_instruction??"",A=T(h)||T(I)||T(b),x=wt(e,r,d);return{operation_id:g,instruction_id:f,instruction:b,intent:b,operation_start:_,operation_end:m,status:e.status??"",command:r,name:"",target:"",value:h,message:"",operation_dict:"",frame:Tt(e.frame_info),error_message:e.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(x),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:t?`${t}/test_screenshots/untagged_screenshot/${g}.${n?.get(g)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:I,navigation_direction:y,tagified_image_url:"",query_variable_name:e.output_variable??"",query_variable_value:e.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:r==="ASSERTION"?xt(o):"",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(o.tab_index??""),tab_identifier:String(o.tab_identifier??""),scroll_value:o.amount??1,scroll_direction:o.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:i==="evaluate_js"?o.script??"":"",code_error:"",hide:A,dismiss_dialog:!1,use_v2_mobile_tagging:l,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:s!==null&&!a,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:a?null:s?.x??null,y_coord:a?null:s?.y??null,target_x_coord:o.target_x??null,target_y_coord:o.target_y??null,source_description:o.source_description??null,target_description:o.target_description??null,use_coordinates:s!==null&&!a,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:a?st(c,l):"",selector_target:u.selector_target,math_result_variable_name:"",math_result_variable_value:"",expression_tree:r==="ASSERTION"?Ot(o):o.expression_tree??{},assertion_tree:o.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:e.reprobe??!1,click_modifier:(o.click_count??1)>=2?{kind:"multi_click",frequency:o.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:{},drag_displacement:u.drag_displacement,hold_duration_ms:u.hold_duration_ms,move_duration_ms:u.move_duration_ms,hold_at_destination_ms:u.hold_at_destination_ms,start_coordinates:o.source_coordinates?{x:o.source_coordinates[0],y:o.source_coordinates[1]}:{},end_coordinates:o.target_coordinates?{x:o.target_coordinates[0],y:o.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:i==="api"?{request:e.action_params?.api_data?.request??{}}:{},output_variables:i==="api"?e.output_variable?{[e.output_variable]:null}:{}:e.output_variable?{[e.output_variable]:e.output_value??""}:{},visual_context:Lt(e,t,g,n),reasoning:i==="analyze"?o.query??"":e.intent??e.action_instruction??""}}function Z(e,t){let n=e.action_type,i=nt(n,e),r=e.timestamp??"",o=e.duration_ms??0,s=it(r,o),c=i==="ASSERTION"||i==="MATHEMATICAL_OPERATION";return{instruction_id:t.instruction_id,instruction_class:c?"non_driver_action":"driver_action",module_id:"",instruction:e.action_instruction??"",command:i,error:null,parent_instruction_id:"",classification_layer_resp:i==="ASSERTION"?Nt(e):[],classification_error:{},operations:[t],status:e.status??"",start_timestamp:r,end_timestamp:s,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&e.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&e.action_params?.analyzer_type?.startsWith("devtool_")?e.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?e.action_params?.script??"":"",user_variables:n==="api"?St(e):"[]",api_data:n==="api"?{request:e.action_params?.api_data?.request??{},response:ot(e)}:{},params_used:!1,hard_assertion:i==="ASSERTION"?e.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:n==="analyze"?e.action_params?.query??"":e.intent??e.action_instruction??""}}function Dt(e,t=[]){let n=e.action_params??{},i=n.branches??[],r=n.winning_index??-1,o=n.sub_results??[],s={};for(let a of o){let l=a.sub_results;if(l)for(let u of l){let _=u.store_key;_&&(s[_]=u)}}let c=i.map((a,l)=>{let u=l===r,_=(a.sub_checks??[]).map(p=>{let d=s[p.store_key];return{description:p.description,store_key:p.store_key,expected_value:p.expected_value,stored_value:d?.extracted_value??p.stored_value,operator:p.operator??d?.operator??"equals",transforms:p.transforms??d?.transforms??[]}});if(_.length===0&&a.condition&&o.length>0){let d=o.find(g=>g.branch_index===l)?.sub_results??[];d.length>0&&(_=d.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?t:[],sub_checks:a.condition?_:[],composite_operator:a.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${v().slice(0,8)}`,instruction:e.action_instruction??"",instruction_class:"driver_action",command:"",status:e.status??"success",resolved_branch_index:r,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:e.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function at(e,t,n){for(let i of e)i.content_type==="instruction"&&"generative_id"in i&&(i.generative_id=t,i.generative_objective=n)}function C(e,t="",n,i){let r=[],o=0;for(;o<e.length;){let s=e[o],c=s.action_type;if(!i?.keepFailedActions&&s.status==="error"&&c!=="assert"&&c!=="if_else"&&c!=="child_agent_start"&&c!=="child_agent_end"&&!(s.until_condition&&!s.error)){o+=1;continue}if(c==="analyze"&&(!et[s.action_params?.analyzer_type??""]||s.action_params?.analyzer_type==="textual_visual"&&s.action_params?.code)){o+=1;continue}if(c==="child_agent_start"){let a=s.action_params?.child_id??"",l=s.action_params?.objective??"",u=[];o+=1;let _=1,p="error",d;for(;o<e.length&&_>0;){let A=e[o],x=A.action_type;if(x==="child_agent_start")_+=1;else if(x==="child_agent_end"&&(_-=1,_===0)){p=A.status??"success",d=A,o+=1;break}_>0&&u.push(A),o+=1}let g=C(u,t,n);at(g,a,l);let f=d?.action_params?.result_code??null,m=d?.action_params?.reason_code??null,h=d?.action_params?.error_message??null,I=d?.action_params?.summary??null,y=d?.action_params?.one_liner??null,b=p==="error";r.push({content_type:"generative_block",instruction_id:`generative_block_${a}`,generative_id:a,objective:l,status:p,children:g,error_message:b?h??null:null,error_code:b?m??null:null,result_code:f??null,bifurcation_context:[],approach_reason:tt(I),one_liner:y??null});continue}else if(c==="child_agent_end"){o+=1;continue}else if(c==="if_else"){o+=1;let a=[];for(;o<e.length&&e[o].action_type==="child_agent_start";){let l=e[o],u=l.action_params?.child_id??"",_=l.action_params?.objective??"",p=[];o+=1;let d=1,g="error";for(;o<e.length&&d>0;){let m=e[o];if(m.action_type==="child_agent_start")d+=1;else if(m.action_type==="child_agent_end"&&(d-=1,d===0)){g=m.status??"success",o+=1;break}d>0&&p.push(m),o+=1}let f=C(p,t,n);a.push(...f)}r.push(Dt(s,a));continue}else if(c==="query_tool"){o+=1;continue}else if(s.until_condition){let a=X(s,t,n),l=Z(s,a),u=typeof s.until_condition_met=="boolean"?s.until_condition_met:s.status==="success";r.push({content_type:"until_block",instruction_id:`until_${v().slice(0,8)}`,condition:s.until_condition,max_retries:s.until_max_retries??10,settle_ms:s.until_settle_ms??500,current_count:0,condition_met:u,children:[l],generative_id:"",generative_objective:"",variables_used:{},status:s.status??"success"})}else{let a=X(s,t,n),l=Z(s,a);r.push(l)}o+=1}return r}function P(e,t="",n,i){let r=[],o=[],s=i?.passthrough,c=s?Y(s.authoredInstructions):null;for(let d of e){if(s&&c&&d.flatIndex!==void 0&&s.replayOnlyFlatIndices.has(d.flatIndex)){let b=W(d.records,c);if(b){for(let A of b)r.push(A),o.push(d.flatIndex);continue}console.warn(`[migrator] replay-only passthrough: no authored operation matched step ${d.flatIndex} (action_id \u2260 any operation_id in the authored blob) \u2014 falling back to this run's records`)}let g=C(d.records,t,n,i);if(g.length===0)continue;let f=v().replace(/-/g,"");at(g,f,d.objective);let m=g.some(b=>"status"in b&&typeof b.status=="string"?b.status==="error"||b.status==="failed":!1),h=d.resultCode?parseInt(d.resultCode,10):null,I=h!==null&&!isNaN(h)&&h>=200,y=m||I?"error":"success";r.push({content_type:"generative_block",instruction_id:`generative_block_${f}`,generative_id:f,objective:d.objective,status:y,children:g,error_message:y==="error"?d.errorMessage??null:null,error_code:y==="error"?d.reasonCode??null:null,result_code:d.resultCode??null,bifurcation_context:[],approach_reason:tt(d.summary),one_liner:d.oneLiner??null}),o.push(d.flatIndex)}let a=r.map((d,g)=>({block:d,flat:o[g]})),l=i?.moduleSpans??[],u=i?.blockSpans??[],_=i?.authoredBlocks??[];l.length>0&&(a=ct(a,l,u,_));let p=dt(u,l);return p.length>0&&(a=j(a,p,_)),{instructions:a.map(d=>d.block)}}function ct(e,t,n,i){let r=[],o=c=>c===void 0?void 0:t.find(a=>c>=a.flatFrom&&c<=a.flatTo),s=0;for(;s<e.length;){let c=o(e[s].flat);if(!c){r.push(e[s]),s++;continue}let a=[];for(;s<e.length&&o(e[s].flat)===c;)a.push(e[s++]);let l=ct(a,c.children,n,i),u=dt(ut(n,c),c.children);u.length>0&&(l=j(l,u,i)),r.push({block:$t(c,l.map(_=>_.block)),flat:a[0].flat})}return r}function lt(e,t){return e.flatFrom>=t.flatFrom&&e.flatTo<=t.flatTo}function ut(e,t){let n=[];for(let i of e)lt(i,t)?n.push(i):n.push(...ut(i.children,t));return n}function dt(e,t){let n=[],i=o=>{for(let s of o)n.push(s),i(s.children)};i(t);let r=o=>o.filter(s=>!n.some(c=>lt(s,c))).map(s=>({...s,children:r(s.children)}));return n.length>0?r(e):e}function j(e,t,n){let i=[...t].sort((l,u)=>l.flatFrom-u.flatFrom),r=[],o=(l,u)=>{r.push({block:zt(l,u,n),flat:l.flatFrom})},s=(l,u)=>l!==void 0&&l>=u.flatFrom&&l<=u.flatTo,c=0,a=0;for(;a<e.length;){let l=e[a].flat;for(;c<i.length&&l!==void 0&&i[c].flatTo<l;)o(i[c++],[]);let u=c<i.length&&s(l,i[c])?i[c]:void 0;if(!u){r.push(e[a]),a++;continue}let _=[];for(;a<e.length&&s(e[a].flat,u);)_.push(e[a++]);o(u,_),c++}for(;c<i.length;)o(i[c++],[]);return r}function Ut(e){let t=new Map;for(let n of e)t.set(n.flat,n);return e.filter(n=>t.get(n.flat)===n)}var Ft=["children","instructions","branches","module_content","true_branch","false_branch"];function Bt(e,t){if(!t)return;let n=[...e];for(;n.length>0;){let i=n.pop();if(!i||typeof i!="object")continue;let r=i;if(r.instruction_id===t&&(r.content_type==="conditional_block"||r.content_type==="until_block"))return r;for(let o of Ft){let s=r[o];Array.isArray(s)?n.push(...s):s&&typeof s=="object"&&n.push(s)}}}function Mt(e,t,n){if(!e)return[];if(t==="while")return Array.isArray(e.children)?e.children:[];let r=(Array.isArray(e.branches)?e.branches:[])[n];return r&&Array.isArray(r.children)?r.children:[]}function zt(e,t,n){let i=Bt(n,e.blockId),r=e.branches.map((o,s)=>{let c=t.filter(u=>u.flat!==void 0&&u.flat>=o.flatFrom&&u.flat<=o.flatTo);e.kind==="while"&&(c=Ut(c));let a=j(c,e.children,n).map(u=>u.block);if(a.length>0)return a;let l=Mt(i,e.kind,s);return l.length===0&&!o.taken&&console.warn(`[migrator] control-flow: branch ${s} of block ${e.blockId||e.instruction} did not run and no authored block matched \u2014 emitted empty`),l});return e.kind==="if"?Vt(e,r,i):qt(e,r[0]??[],i)}function Vt(e,t,n){let i=Array.isArray(n?.branches)?n.branches:[],r=D(t.flat()),o=e.branches.map((s,c)=>{let a=i[c];return{branch_index:c,condition:s.branch_type==="else"?null:s.condition,branch_type:s.branch_type,passed:s.taken,sub_objective:null,custom_event:a?.custom_event??null,children:t[c],sub_checks:Array.isArray(a?.sub_checks)?a.sub_checks:[],composite_operator:a?.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:e.blockId||`if_else_${v().slice(0,8)}`,instruction:e.instruction,instruction_class:"driver_action",command:"",status:r?"error":"success",resolved_branch_index:e.branches.findIndex(s=>s.taken),branches:o,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:r?.message??"",error_code:r?.code??"",reason:"",start_timestamp:"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function qt(e,t,n){let i=e.whileCfg??{max_retries:5,settle_ms:500,on_exhaust:"fail",iterations:0,condition_met:!1},r=D(t),o=(s,c)=>n&&n[s]!==void 0?n[s]:c;return{content_type:"until_block",instruction_id:e.blockId||`until_${v().slice(0,8)}`,condition:e.instruction,max_retries:i.max_retries,settle_ms:i.settle_ms,current_count:i.iterations,condition_met:i.condition_met,children:t,generative_id:"",generative_objective:"",variables_used:{},status:r?"error":"success",on_exhaust:o("on_exhaust",i.on_exhaust),mode:o("mode",""),check:o("check",""),conditions:o("conditions",[]),connectors:o("connectors",[]),sub_checks:o("sub_checks",[]),composite_operator:o("composite_operator","and")}}function D(e){for(let t of e){let n="status"in t&&typeof t.status=="string"?t.status:"";if(n==="error"||n==="failed"){let i="error_message"in t?t.error_message:void 0,r="error_code"in t?t.error_code:void 0;return{message:i??null,code:r??null}}}return null}function $t(e,t){let n=e.meta,i=(l,u="")=>typeof n[l]=="string"?n[l]:u,r=(l,u=!1)=>typeof n[l]=="boolean"?n[l]:u,o=l=>Array.isArray(n[l])?n[l]:[],s=typeof n.module_version=="number"||typeof n.module_version=="string"?n.module_version:null,c=i("module_id"),a=D(t);return{content_type:$,instruction_id:`module_block_${c}`,module_id:c,module_version:s,module_instance_id:v(),module_name:i("module_name"),module_description:i("module_description"),module_platform:i("module_platform"),creation_mode:i("creation_mode","Agent"),tms_status:i("tms_status","active"),is_validated:r("is_validated"),is_dirty:e.dirty,enrichment_id:i("enrichment_id"),tags:o("tags"),project_ids:o("project_ids"),link_to_all:r("link_to_all"),status:a?"error":"success",children:t,error_message:a?.message??null,error_code:a?.code??null,update_available:!1,update_info:{}}}function pt(e,t){let n;try{n=_t(e)}catch{return 0}let i=0,r=n.filter(o=>/^\d+$/.test(o)).sort((o,s)=>Number(o)-Number(s));for(let o of r){let s=S(e,o),c=S(s,"logs");if(!Gt(c))continue;let a;try{a=_t(c)}catch{continue}let l=a.filter(p=>p.endsWith("-actions.ndjson")).sort((p,d)=>(parseInt(p,10)||0)-(parseInt(d,10)||0)),u=[];for(let p of l){let d=t.readActions(S(c,p));d.length&&u.push({objective:t.objective??"",records:d})}if(u.length===0)continue;let{instructions:_}=P(u,t.screenshotBaseUrl??"",t.extMap,{keepFailedActions:!0});if(_.length!==0)try{let p=S(s,"auteur");Kt(p,{recursive:!0}),Ht(S(p,"execution.json"),JSON.stringify(t.buildBlob(_),null,2)),i++,t.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:o,instructions:_.length})}catch(p){t.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:o,error:p instanceof Error?p.message:String(p)})}}return i}var gt=Et(yt(),1);import{createWriteStream as Jt}from"fs";import{readFile as Yt}from"fs/promises";import{join as Wt,basename as Xt}from"path";import{tmpdir as Zt}from"os";var Qt=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function ft(e){let t=Wt(Zt(),`${Xt(e)}_artifacts.zip`);return new Promise((n,i)=>{let r=Jt(t),o=(0,gt.default)("zip",{zlib:{level:6}});r.on("close",()=>n(t)),o.on("error",i),o.pipe(r),o.glob("**/*",{cwd:e,ignore:Qt}),o.finalize()})}async function mt(e){return Yt(e)}async function ne(e,t){return bt(q(e,t))}function ie(e){return{key:"artifacts",content_type:"application/zip",filename:`${e}.evidence`}}var ht=class{config;controller;testId;constructor(t){this.config=t,this.controller=new z(t.controllerBaseUrl,t.auth),this.testId=t.testId}log(t,n,i,r){this.config.log?.(t,n,i,r)}async execute(){let{onProgress:t}=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 n=this.config.evidence,i=null;if(this.config.shouldUploadArtifacts!==!1){t("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.loadReplayOnlyPassthrough(),{instructions:u}=c.length>0?P(c,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{moduleSpans:this.config.moduleSpans,...l?{passthrough:l}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:u.length});let _=this.buildExecutionEnvelope(u),p=Buffer.from(JSON.stringify(_));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(p.length/1024).toFixed(1)});let d=E(this.config.sessionDir,"execution.json");w(d,JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:d});let g=n?.packTestDir??this.config.evidenceRead?.packTestDir;if(g){let f=E(g,"auteur");F(f,{recursive:!0}),w(E(f,"execution.json"),JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:E(f,"execution.json")}),this.deriveArchivedAttemptBlobs(g)}if(t("convert","done"),n)i=p;else{t("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let f=null,m;try{f=await ft(this.config.sessionDir),m=await mt(f),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(m.length/1024/1024).toFixed(1),path:f}),t("zip","done",`${(m.length/1024/1024).toFixed(1)}MB`)}finally{f&&await ee(f).catch(()=>{})}t("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}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(m.length/1024/1024).toFixed(1),blob_size_kb:+(p.length/1024).toFixed(1)}),await Promise.all([k(h.urls.artifacts.upload_url,m,"application/zip"),k(h.urls.blob.upload_url,p,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}}else{let c=this.collectNdjsonPerRun(),a=this.loadReplayOnlyPassthrough(),{instructions:l}=c.length>0?P(c,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0,moduleSpans:this.config.moduleSpans,...a?{passthrough:a}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]},u=this.buildExecutionEnvelope(l),_=E(this.config.sessionDir,"execution.json");w(_,JSON.stringify(u,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:_});let p=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(p){let d=E(p,"auteur");F(d,{recursive:!0});let g=this.readAuthoredExecution();w(E(d,"execution.json"),g??JSON.stringify(u,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:E(d,"execution.json"),source:g?"authored":"run_envelope"}),this.deriveArchivedAttemptBlobs(p)}t("convert","skipped"),t("zip","skipped"),t("presign","skipped"),t("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){t("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),t("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}),t("atomic_replace","failed",a),c}}else t("atomic_replace","skipped");let r,o;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){t("commit_lock","running");let c=await this.config.onCommitLock();if(c.ok)r=c.testcaseId||void 0,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:r??"none",trigger:c.trigger??null,test_instance_id:c.testInstanceId??null}),t("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:c.reason,message:c.message}),t("commit_lock","failed",`${c.reason??"unknown"}: ${c.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${c.reason??"unknown"}`}}else t("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){t("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let c=new V(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(r=(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:r??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(r)}catch(u){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(u)})}t("finalize","done")}else t("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(r&&this.config.shareApiBaseUrl)try{o=await this.generateShareLink(r),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:o})}catch(c){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(c)})}if(n&&i){let c=null;t("zip","running");try{await n.sealFn({testcaseId:r,shareId:o}),c=n.sealedPackPath?await bt(n.sealedPackPath):await ne(n.executionId,n.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:n.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:n.executionId,error:l})}if(c){t("zip","done",`${(c.length/1024/1024).toFixed(1)}MB`),t("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[ie(n.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}),t("presign","done"),t("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([k(a.urls.artifacts.upload_url,c,"application/zip"),k(a.urls.blob.upload_url,i,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}else{t("zip","skipped"),t("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(i.length/1024).toFixed(1)}),await k(a.urls.blob.upload_url,i,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),t("upload","done")}}let s;if(this.config.codeExport?.enabled&&r){let c=!1;try{await this.triggerCodeExport(r),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}),t("code_export","failed",`trigger failed: ${l}`)}if(c){t("code_export","running","Waiting for code generation\u2026");try{s=await this.pollAndDownloadCode(r,t),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:s}),t("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}),t("code_export","failed",l)}}}else t("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:r,shareId:o,codeExportDir:s}}catch(n){return{success:!1,testId:this.testId,error:n instanceof Error?n.message:String(n)}}}async runCodeExport(t,n){let i=n??this.config.onProgress,r=!1;try{await this.triggerCodeExport(t),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:t}),r=!0}catch(o){let s=o instanceof Error?o.message:String(o);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:s}),i("code_export","failed",`trigger failed: ${s}`)}if(r){i("code_export","running","Waiting for code generation\u2026");try{let o=await this.pollAndDownloadCode(t,i);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:o}),i("code_export","done",o),o}catch(o){let s=o instanceof Error?o.message:String(o);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:s}),i("code_export","failed",s);return}}}deriveArchivedAttemptBlobs(t){try{let n=pt(t,{readActions:i=>this.readNdjsonFromFile(i),buildBlob:i=>this.buildExecutionEnvelope(i),objective:this.config.firstObjective,screenshotBaseUrl:this.config.screenshotBaseUrl??"",extMap:this.config.screenshotExtMap,log:(i,r,o,s)=>this.log(i,r,o,s)});n>0&&this.log("info","PIPELINE_ARCHIVED_ATTEMPTS","Nested retry-attempt blobs derived",{count:n})}catch(n){this.log("debug","PIPELINE_ARCHIVED_ATTEMPTS_FAILED","Nested attempt blob pass failed",{error:n instanceof Error?n.message:String(n)})}}collectNdjsonPerRun(){let t=[],n=this.config.runObjectives??[],i=this.config.runMetadata??[],r=this.config.evidence??this.config.evidenceRead;for(let o=0;o<this.config.runDirs.length;o++){let s=this.config.runDirs[o],c=n[o]||this.config.firstObjective,a=i[o],l=r?this.readNdjsonFromFile(E(r.packTestDir,"logs",`${r.runIndices?.[o]??o}-actions.ndjson`)):this.readNdjsonFromDir(s);if(l.length>0){let u=r?.runIndices?.[o]??o,_=this.config.runFlatIndex?.[u];t.push({objective:c,records:l,..._!==void 0?{flatIndex:_}:{},resultCode:a?.resultCode,reasonCode:a?.reasonCode,errorMessage:a?.errorMessage,summary:a?.summary,oneLiner:a?.oneLiner})}}if(t.length===0){let o=E(this.config.sessionDir,"runs");if(U(o))try{let c=te(o,{withFileTypes:!0}).filter(a=>a.isDirectory()).map(a=>a.name).sort();for(let a of c){let l=E(o,a),u=this.readNdjsonFromDir(l);u.length>0&&t.push({objective:this.config.firstObjective,records:u})}}catch{}}return t}readNdjsonFromDir(t){let n=[E(t,"run-test","actions.ndjson"),E(t,"actions.ndjson")];for(let i of n)if(U(i))return this.readNdjsonFromFile(i);return[]}readNdjsonFromFile(t){let n=[];if(!U(t))return n;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:t});let i=L(t,"utf-8");for(let r of i.split(`
|
|
5
|
-
`)){let o=r.trim();if(o)try{n.push(JSON.parse(o))}catch{}}return n}async generateShareLink(t){let n=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:n,testcase_id:t});let i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[t],entityType:"Test Case Details",expiresAt:7})},r=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:r,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let o=r?await this.config.authResolver.fetch(n,i):await R(n,{...i,headers:{...i.headers,Authorization:this.buildAuthHeader()}});if(!o.ok)throw new Error(`Share link API failed: ${o.status} ${await o.text()}`);let s=await o.json();if(!s.shareId)throw new Error("Share link API returned no shareId");return s.shareId}async triggerCodeExport(t){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:n,body:i}=
|
|
4
|
+
`).map(t=>t.trim()).filter(Boolean):e.split(". ").map(t=>t.trim()).filter(Boolean).map(t=>t.endsWith(".")?t:t+"."):[]}function T(e){return typeof e=="string"&&e.includes("{{secrets.")}var Pt={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"},nt={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"},St=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function it(e,t){if(e==="analyze"){let i=t?.action_params?.analyzer_type??"";return nt[i]}if(e==="scroll"&&t?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let n=Pt[e];return n||console.warn(`[migrator] UNKNOWN action_type "${e}" \u2014 falling back to "${e.toUpperCase()}"; explicit mapping required`),n??e.toUpperCase()}function ot(e,t){if(!e||!t)return"";try{let n=new Date(e);return isNaN(n.getTime())?"":new Date(n.getTime()+t).toISOString()}catch{return""}}function rt(e){try{return JSON.parse(e.output_value??"{}")}catch{return{}}}function wt(e){let t=e.output_variable??"";if(!t)return"[]";let i={...rt(e)};return delete i.body,JSON.stringify([{name:t,unique_key:(e.action_id??"").replace(/-/g,"").slice(0,8)||v().replace(/-/g,"").slice(0,8),value:i,variable_description:"API Response"}])}function xt(e,t,n){let i=e.action_params??{},r=St.has(t)?"Vision Agent":"Operation Agent",o={operation_type:t};if(t==="OPEN"&&(o.url=i.url??""),t==="SET_VARIABLE"&&(o.variable_name=e.output_variable??i.key??"",o.variable_value=e.output_value??""),t==="UPLOAD_FILE"){let m=N(i);m&&(o.value=O(m.name))}let s={},c={},a=e.action_instruction??"",l=i.text??"",u=i.url??"",_=[["intent",a],["value",l],["url",u]];for(let[m,h]of Object.entries(n)){let I=String(h);if(m.startsWith("secrets."))for(let[y,b]of _)b.includes(I)&&(c[y]=m);for(let[y,b]of _)b.includes(I)&&!(y in s)&&(s[y]=b)}let p=e.action_type,d={operation:e.action_instruction??"",agent:r,operation_dict:o,reasoning:p==="analyze"?i.query??"":e.intent??e.action_instruction??"",variable:s,secrets:c,params:{}};p==="analyze"&&typeof i.code=="string"&&i.code&&(d.code=i.code),p==="analyze"&&typeof i.code_js=="string"&&i.code_js&&(d.code_js=i.code_js),p==="analyze"&&typeof i.condition_expression=="string"&&i.condition_expression&&(d.condition_expression=i.condition_expression),i.uses_websocket===!0&&(d.uses_websocket=!0),i.uses_sse===!0&&(d.uses_sse=!0),p==="analyze"&&i.analyzer_type==="textual_visual"&&(typeof i.wrapped_js=="string"&&(d.wrapped_js=i.wrapped_js),Array.isArray(i.locators)&&(d.locators=i.locators),typeof i.operator=="string"&&(d.operator=i.operator),Array.isArray(i.transforms)&&(d.transforms=i.transforms),typeof i.query=="string"&&(d.query=i.query),typeof i.expected_value=="string"&&(d.expected_value=i.expected_value),typeof i.needs_unit_conversion=="boolean"&&(d.needs_unit_conversion=i.needs_unit_conversion),typeof i.condition=="string"&&(d.condition=i.condition));let f={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[p];return f&&i[f]!==void 0&&(d[f]=i[f]),p==="set_clipboard"&&typeof i.html=="string"&&i.html&&(d.html=i.html),d}function Ot(e){let t=e.assertion_tree??{};if(typeof t.passed=="boolean")return t.passed;let n=t.sub_results??[];return n.length===0?t.status==="passed":(t.composite_operator??"and")==="or"?n.some(r=>r.passed===!0):n.every(r=>r.passed===!0)}function st(e){return e.map(t=>({description:t.description??"",store_key:t.store_key??"",expected_value:t.expected??"",extracted_value:t.extracted_value??"",operator:t.operator??"equals",transforms:t.transforms??[]}))}function Nt(e){let t=e.assertion_tree??{},n=t.sub_results??[],i=st(n);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:n,sub_checks:i,composite_operator:t.composite_operator??"and",verification:t.verification??"",claim:t.description??""}}function Lt(e){let n=(e.action_params??{}).assertion_tree??{},i=n.sub_results??[],r=st(i);return[{operation:e.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:i,sub_checks:r,composite_operator:n.composite_operator??"and",verification:"",claim:n.description??e.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function Tt(e,t,n,i){let r=e.visual_data;if(!r||r.x==null||r.y==null)return null;let o=t?`${t}/test_screenshots`:"";return{x:r.x,y:r.y,confidence:0,bbox:r.bbox??null,bbox_source:r.bbox?"accessibility_tree":"fallback",viewport_width:r.viewport_width??1280,viewport_height:r.viewport_height??800,scale_factor:null,raw_image_url:o?`${o}/untagged_screenshot/${n}.${i?.get(n)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function Ct(e){if(!e)return"";let t=e;return typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.frameInfo)&&(t=e.frameInfo),!Array.isArray(t)||t.length===0?"":JSON.stringify(t)}function jt(e){return/^(android|ios)_native$/i.test(e.platform??"")}function at(e,t){return e.map(n=>({...n,type:t?n.strategy??n.type??"native":n.isXPath?"xpath":"css"}))}function Dt(e,t,n){let i={selector_target:"",drag_displacement:{},hold_duration_ms:null,move_duration_ms:null,hold_at_destination_ms:null};if(e!=="drag")return i;let r=t.target_selectors,o={};typeof t.direction=="string"&&t.direction&&(o.direction=t.direction,typeof t.fraction=="number"&&(o.fraction=t.fraction));let s=c=>typeof t[c]=="number"?Math.trunc(t[c]):null;return{selector_target:Array.isArray(r)&&r.length>0?at(r,n):"",drag_displacement:o,hold_duration_ms:s("hold_duration_ms"),move_duration_ms:s("move_duration_ms"),hold_at_destination_ms:s("hold_at_destination_ms")}}function Z(e,t="",n){let i=e.action_type,r=it(i,e),o=e.action_params??{},s=e.coordinates??null,c=e.selectors??null,a=!!(c&&c.length>0),l=jt(e),u=Dt(i,o,l),_=e.timestamp??"",p=e.duration_ms??0,d=e.variables_used??{},g=e.action_id??v(),f=v(),m=ot(_,p),h="",I="";if(i==="navigate")I=o.url??"",h=I;else if(i==="type"||i==="fill")h=o.text??"";else if(i==="press_key")h=o.key??"";else if(i==="wait")h=String(o.ms??o.timeout_ms??"");else if(i==="evaluate_js")h=o.script??"";else if(i==="upload_files"){let B=N(o);B&&(h=O(B.name))}else i==="analyze"&&r==="SET_VARIABLE"&&(h=e.output_value??"");let y="";i==="go_back"?y="back":i==="go_forward"&&(y="forward");let b=e.action_instruction??"",A=T(h)||T(I)||T(b),x=xt(e,r,d);return{operation_id:g,instruction_id:f,instruction:b,intent:b,operation_start:_,operation_end:m,status:e.status??"",command:r,name:"",target:"",value:h,message:"",operation_dict:"",frame:Ct(e.frame_info),error_message:e.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(x),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:t?`${t}/test_screenshots/untagged_screenshot/${g}.${n?.get(g)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:I,navigation_direction:y,tagified_image_url:"",query_variable_name:e.output_variable??"",query_variable_value:e.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:r==="ASSERTION"?Ot(o):"",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(o.tab_index??""),tab_identifier:String(o.tab_identifier??""),scroll_value:o.amount??1,scroll_direction:o.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:i==="evaluate_js"?o.script??"":"",code_error:"",hide:A,dismiss_dialog:!1,use_v2_mobile_tagging:l,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:s!==null&&!a,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:a?null:s?.x??null,y_coord:a?null:s?.y??null,target_x_coord:o.target_x??null,target_y_coord:o.target_y??null,source_description:o.source_description??null,target_description:o.target_description??null,use_coordinates:s!==null&&!a,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:a?at(c,l):"",selector_target:u.selector_target,math_result_variable_name:"",math_result_variable_value:"",expression_tree:r==="ASSERTION"?Nt(o):o.expression_tree??{},assertion_tree:o.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:e.reprobe??!1,click_modifier:(o.click_count??1)>=2?{kind:"multi_click",frequency:o.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:{},drag_displacement:u.drag_displacement,hold_duration_ms:u.hold_duration_ms,move_duration_ms:u.move_duration_ms,hold_at_destination_ms:u.hold_at_destination_ms,start_coordinates:o.source_coordinates?{x:o.source_coordinates[0],y:o.source_coordinates[1]}:{},end_coordinates:o.target_coordinates?{x:o.target_coordinates[0],y:o.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:i==="api"?{request:e.action_params?.api_data?.request??{}}:{},output_variables:i==="api"?e.output_variable?{[e.output_variable]:null}:{}:e.output_variable?{[e.output_variable]:e.output_value??""}:{},visual_context:Tt(e,t,g,n),reasoning:i==="analyze"?o.query??"":e.intent??e.action_instruction??""}}function Q(e,t){let n=e.action_type,i=it(n,e),r=e.timestamp??"",o=e.duration_ms??0,s=ot(r,o),c=i==="ASSERTION"||i==="MATHEMATICAL_OPERATION";return{instruction_id:t.instruction_id,instruction_class:c?"non_driver_action":"driver_action",module_id:"",instruction:e.action_instruction??"",command:i,error:null,parent_instruction_id:"",classification_layer_resp:i==="ASSERTION"?Lt(e):[],classification_error:{},operations:[t],status:e.status??"",start_timestamp:r,end_timestamp:s,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&e.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&e.action_params?.analyzer_type?.startsWith("devtool_")?e.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?e.action_params?.script??"":"",user_variables:n==="api"?wt(e):"[]",api_data:n==="api"?{request:e.action_params?.api_data?.request??{},response:rt(e)}:{},params_used:!1,hard_assertion:i==="ASSERTION"?e.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:n==="analyze"?e.action_params?.query??"":e.intent??e.action_instruction??""}}function Ut(e,t=[]){let n=e.action_params??{},i=n.branches??[],r=n.winning_index??-1,o=n.sub_results??[],s={};for(let a of o){let l=a.sub_results;if(l)for(let u of l){let _=u.store_key;_&&(s[_]=u)}}let c=i.map((a,l)=>{let u=l===r,_=(a.sub_checks??[]).map(p=>{let d=s[p.store_key];return{description:p.description,store_key:p.store_key,expected_value:p.expected_value,stored_value:d?.extracted_value??p.stored_value,operator:p.operator??d?.operator??"equals",transforms:p.transforms??d?.transforms??[]}});if(_.length===0&&a.condition&&o.length>0){let d=o.find(g=>g.branch_index===l)?.sub_results??[];d.length>0&&(_=d.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?t:[],sub_checks:a.condition?_:[],composite_operator:a.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${v().slice(0,8)}`,instruction:e.action_instruction??"",instruction_class:"driver_action",command:"",status:e.status??"success",resolved_branch_index:r,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:e.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function ct(e,t,n){for(let i of e)i.content_type==="instruction"&&"generative_id"in i&&(i.generative_id=t,i.generative_objective=n)}function C(e,t="",n,i){let r=[],o=0;for(;o<e.length;){let s=e[o],c=s.action_type;if(!i?.keepFailedActions&&s.status==="error"&&c!=="assert"&&c!=="if_else"&&c!=="child_agent_start"&&c!=="child_agent_end"&&!(s.until_condition&&!s.error)){o+=1;continue}if(c==="analyze"&&(!nt[s.action_params?.analyzer_type??""]||s.action_params?.analyzer_type==="textual_visual"&&s.action_params?.code)){o+=1;continue}if(c==="child_agent_start"){let a=s.action_params?.child_id??"",l=s.action_params?.objective??"",u=[];o+=1;let _=1,p="error",d;for(;o<e.length&&_>0;){let A=e[o],x=A.action_type;if(x==="child_agent_start")_+=1;else if(x==="child_agent_end"&&(_-=1,_===0)){p=A.status??"success",d=A,o+=1;break}_>0&&u.push(A),o+=1}let g=C(u,t,n);ct(g,a,l);let f=d?.action_params?.result_code??null,m=d?.action_params?.reason_code??null,h=d?.action_params?.error_message??null,I=d?.action_params?.summary??null,y=d?.action_params?.one_liner??null,b=p==="error";r.push({content_type:"generative_block",instruction_id:`generative_block_${a}`,generative_id:a,objective:l,status:p,children:g,error_message:b?h??null:null,error_code:b?m??null:null,result_code:f??null,bifurcation_context:[],approach_reason:et(I),one_liner:y??null});continue}else if(c==="child_agent_end"){o+=1;continue}else if(c==="if_else"){o+=1;let a=[];for(;o<e.length&&e[o].action_type==="child_agent_start";){let l=e[o],u=l.action_params?.child_id??"",_=l.action_params?.objective??"",p=[];o+=1;let d=1,g="error";for(;o<e.length&&d>0;){let m=e[o];if(m.action_type==="child_agent_start")d+=1;else if(m.action_type==="child_agent_end"&&(d-=1,d===0)){g=m.status??"success",o+=1;break}d>0&&p.push(m),o+=1}let f=C(p,t,n);a.push(...f)}r.push(Ut(s,a));continue}else if(c==="query_tool"){o+=1;continue}else if(s.until_condition){let a=Z(s,t,n),l=Q(s,a),u=typeof s.until_condition_met=="boolean"?s.until_condition_met:s.status==="success";r.push({content_type:"until_block",instruction_id:`until_${v().slice(0,8)}`,condition:s.until_condition,max_retries:s.until_max_retries??10,settle_ms:s.until_settle_ms??500,current_count:0,condition_met:u,children:[l],generative_id:"",generative_objective:"",variables_used:{},status:s.status??"success"})}else{let a=Z(s,t,n),l=Q(s,a);r.push(l)}o+=1}return r}function P(e,t="",n,i){let r=[],o=[],s=i?.passthrough,c=s?W(s.authoredInstructions):null;for(let d of e){if(s&&c&&d.flatIndex!==void 0&&s.replayOnlyFlatIndices.has(d.flatIndex)){let b=X(d.records,c);if(b){for(let A of b)r.push(A),o.push(d.flatIndex);continue}console.warn(`[migrator] replay-only passthrough: no authored operation matched step ${d.flatIndex} (action_id \u2260 any operation_id in the authored blob) \u2014 falling back to this run's records`)}let g=C(d.records,t,n,i);if(g.length===0)continue;let f=v().replace(/-/g,"");ct(g,f,d.objective);let m=g.some(b=>"status"in b&&typeof b.status=="string"?b.status==="error"||b.status==="failed":!1),h=d.resultCode?parseInt(d.resultCode,10):null,I=h!==null&&!isNaN(h)&&h>=200,y=m||I?"error":"success";r.push({content_type:"generative_block",instruction_id:`generative_block_${f}`,generative_id:f,objective:d.objective,status:y,children:g,error_message:y==="error"?d.errorMessage??null:null,error_code:y==="error"?d.reasonCode??null:null,result_code:d.resultCode??null,bifurcation_context:[],approach_reason:et(d.summary),one_liner:d.oneLiner??null}),o.push(d.flatIndex)}let a=r.map((d,g)=>({block:d,flat:o[g]})),l=i?.moduleSpans??[],u=i?.blockSpans??[],_=i?.authoredBlocks??[];l.length>0&&(a=lt(a,l,u,_));let p=_t(u,l);return p.length>0&&(a=j(a,p,_)),{instructions:a.map(d=>d.block)}}function lt(e,t,n,i){let r=[],o=c=>c===void 0?void 0:t.find(a=>c>=a.flatFrom&&c<=a.flatTo),s=0;for(;s<e.length;){let c=o(e[s].flat);if(!c){r.push(e[s]),s++;continue}let a=[];for(;s<e.length&&o(e[s].flat)===c;)a.push(e[s++]);let l=lt(a,c.children,n,i),u=_t(dt(n,c),c.children);u.length>0&&(l=j(l,u,i)),r.push({block:Gt(c,l.map(_=>_.block)),flat:a[0].flat})}return r}function ut(e,t){return e.flatFrom>=t.flatFrom&&e.flatTo<=t.flatTo}function dt(e,t){let n=[];for(let i of e)ut(i,t)?n.push(i):n.push(...dt(i.children,t));return n}function _t(e,t){let n=[],i=o=>{for(let s of o)n.push(s),i(s.children)};i(t);let r=o=>o.filter(s=>!n.some(c=>ut(s,c))).map(s=>({...s,children:r(s.children)}));return n.length>0?r(e):e}function j(e,t,n){let i=[...t].sort((l,u)=>l.flatFrom-u.flatFrom),r=[],o=(l,u)=>{r.push({block:Vt(l,u,n),flat:l.flatFrom})},s=(l,u)=>l!==void 0&&l>=u.flatFrom&&l<=u.flatTo,c=0,a=0;for(;a<e.length;){let l=e[a].flat;for(;c<i.length&&l!==void 0&&i[c].flatTo<l;)o(i[c++],[]);let u=c<i.length&&s(l,i[c])?i[c]:void 0;if(!u){r.push(e[a]),a++;continue}let _=[];for(;a<e.length&&s(e[a].flat,u);)_.push(e[a++]);o(u,_),c++}for(;c<i.length;)o(i[c++],[]);return r}function Ft(e){let t=new Map;for(let n of e)t.set(n.flat,n);return e.filter(n=>t.get(n.flat)===n)}var Bt=["children","instructions","branches","module_content","true_branch","false_branch"];function Mt(e,t){if(!t)return;let n=[...e];for(;n.length>0;){let i=n.pop();if(!i||typeof i!="object")continue;let r=i;if(r.instruction_id===t&&(r.content_type==="conditional_block"||r.content_type==="until_block"))return r;for(let o of Bt){let s=r[o];Array.isArray(s)?n.push(...s):s&&typeof s=="object"&&n.push(s)}}}function zt(e,t,n){if(!e)return[];if(t==="while")return Array.isArray(e.children)?e.children:[];let r=(Array.isArray(e.branches)?e.branches:[])[n];return r&&Array.isArray(r.children)?r.children:[]}function Vt(e,t,n){let i=Mt(n,e.blockId),r=e.branches.map((o,s)=>{let c=t.filter(u=>u.flat!==void 0&&u.flat>=o.flatFrom&&u.flat<=o.flatTo);e.kind==="while"&&(c=Ft(c));let a=j(c,e.children,n).map(u=>u.block);if(a.length>0)return a;let l=zt(i,e.kind,s);return l.length===0&&!o.taken&&console.warn(`[migrator] control-flow: branch ${s} of block ${e.blockId||e.instruction} did not run and no authored block matched \u2014 emitted empty`),l});return e.kind==="if"?qt(e,r,i):$t(e,r[0]??[],i)}function qt(e,t,n){let i=Array.isArray(n?.branches)?n.branches:[],r=D(t.flat()),o=e.branches.map((s,c)=>{let a=i[c];return{branch_index:c,condition:s.branch_type==="else"?null:s.condition,branch_type:s.branch_type,passed:s.taken,sub_objective:null,custom_event:a?.custom_event??null,children:t[c],sub_checks:Array.isArray(a?.sub_checks)?a.sub_checks:[],composite_operator:a?.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:e.blockId||`if_else_${v().slice(0,8)}`,instruction:e.instruction,instruction_class:"driver_action",command:"",status:r?"error":"success",resolved_branch_index:e.branches.findIndex(s=>s.taken),branches:o,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:r?.message??"",error_code:r?.code??"",reason:"",start_timestamp:"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function $t(e,t,n){let i=e.whileCfg??{max_retries:5,settle_ms:500,on_exhaust:"fail",iterations:0,condition_met:!1},r=D(t),o=(s,c)=>n&&n[s]!==void 0?n[s]:c;return{content_type:"until_block",instruction_id:e.blockId||`until_${v().slice(0,8)}`,condition:e.instruction,max_retries:i.max_retries,settle_ms:i.settle_ms,current_count:i.iterations,condition_met:i.condition_met,children:t,generative_id:"",generative_objective:"",variables_used:{},status:r?"error":"success",on_exhaust:o("on_exhaust",i.on_exhaust),mode:o("mode",""),check:o("check",""),conditions:o("conditions",[]),connectors:o("connectors",[]),sub_checks:o("sub_checks",[]),composite_operator:o("composite_operator","and")}}function D(e){for(let t of e){let n="status"in t&&typeof t.status=="string"?t.status:"";if(n==="error"||n==="failed"){let i="error_message"in t?t.error_message:void 0,r="error_code"in t?t.error_code:void 0;return{message:i??null,code:r??null}}}return null}function Gt(e,t){let n=e.meta,i=(l,u="")=>typeof n[l]=="string"?n[l]:u,r=(l,u=!1)=>typeof n[l]=="boolean"?n[l]:u,o=l=>Array.isArray(n[l])?n[l]:[],s=typeof n.module_version=="number"||typeof n.module_version=="string"?n.module_version:null,c=i("module_id"),a=D(t);return{content_type:G,instruction_id:`module_block_${c}`,module_id:c,module_version:s,module_instance_id:v(),module_name:i("module_name"),module_description:i("module_description"),module_platform:i("module_platform"),creation_mode:i("creation_mode","Agent"),tms_status:i("tms_status","active"),is_validated:r("is_validated"),is_dirty:e.dirty,enrichment_id:i("enrichment_id"),tags:o("tags"),project_ids:o("project_ids"),link_to_all:r("link_to_all"),status:a?"error":"success",children:t,error_message:a?.message??null,error_code:a?.code??null,update_available:!1,update_info:{}}}function gt(e,t){let n;try{n=pt(e)}catch{return 0}let i=0,r=n.filter(o=>/^\d+$/.test(o)).sort((o,s)=>Number(o)-Number(s));for(let o of r){let s=S(e,o),c=S(s,"logs");if(!Kt(c))continue;let a;try{a=pt(c)}catch{continue}let l=a.filter(p=>p.endsWith("-actions.ndjson")).sort((p,d)=>(parseInt(p,10)||0)-(parseInt(d,10)||0)),u=[];for(let p of l){let d=t.readActions(S(c,p));d.length&&u.push({objective:t.objective??"",records:d})}if(u.length===0)continue;let{instructions:_}=P(u,t.screenshotBaseUrl??"",t.extMap,{keepFailedActions:!0});if(_.length!==0)try{let p=S(s,"auteur");Ht(p,{recursive:!0}),Jt(S(p,"execution.json"),JSON.stringify(t.buildBlob(_),null,2)),i++,t.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:o,instructions:_.length})}catch(p){t.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:o,error:p instanceof Error?p.message:String(p)})}}return i}var ft=yt(It(),1);import{createWriteStream as Yt}from"fs";import{readFile as Wt}from"fs/promises";import{join as Xt,basename as Zt}from"path";import{tmpdir as Qt}from"os";var te=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function mt(e){let t=Xt(Qt(),`${Zt(e)}_artifacts.zip`);return new Promise((n,i)=>{let r=Yt(t),o=(0,ft.default)("zip",{zlib:{level:6}});r.on("close",()=>n(t)),o.on("error",i),o.pipe(r),o.glob("**/*",{cwd:e,ignore:te}),o.finalize()})}async function ht(e){return Wt(e)}async function ie(e,t){return Et($(e,t))}function oe(e){return{key:"artifacts",content_type:"application/zip",filename:`${e}.evidence`}}var bt=class{config;controller;testId;constructor(t){this.config=t,this.controller=new z(t.controllerBaseUrl,t.auth),this.testId=t.testId}log(t,n,i,r){this.config.log?.(t,n,i,r)}async execute(){let{onProgress:t}=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 n=this.config.evidence,i=null;if(this.config.shouldUploadArtifacts!==!1){t("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.loadReplayOnlyPassthrough(),{instructions:u}=c.length>0?P(c,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{moduleSpans:this.config.moduleSpans,...l?{passthrough:l}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:u.length});let _=this.buildExecutionEnvelope(u),p=Buffer.from(JSON.stringify(_));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(p.length/1024).toFixed(1)});let d=E(this.config.sessionDir,"execution.json");w(d,JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:d});let g=n?.packTestDir??this.config.evidenceRead?.packTestDir;if(g){let f=E(g,"auteur");F(f,{recursive:!0}),w(E(f,"execution.json"),JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:E(f,"execution.json")}),this.deriveArchivedAttemptBlobs(g)}if(t("convert","done"),n)i=p;else{t("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let f=null,m;try{f=await mt(this.config.sessionDir),m=await ht(f),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(m.length/1024/1024).toFixed(1),path:f}),t("zip","done",`${(m.length/1024/1024).toFixed(1)}MB`)}finally{f&&await ne(f).catch(()=>{})}t("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}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(m.length/1024/1024).toFixed(1),blob_size_kb:+(p.length/1024).toFixed(1)}),await Promise.all([k(h.urls.artifacts.upload_url,m,"application/zip"),k(h.urls.blob.upload_url,p,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}}else{let c=this.collectNdjsonPerRun(),a=this.loadReplayOnlyPassthrough(),{instructions:l}=c.length>0?P(c,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0,moduleSpans:this.config.moduleSpans,...a?{passthrough:a}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]},u=this.buildExecutionEnvelope(l),_=E(this.config.sessionDir,"execution.json");w(_,JSON.stringify(u,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:_});let p=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(p){let d=E(p,"auteur");F(d,{recursive:!0});let g=this.readAuthoredExecution();w(E(d,"execution.json"),g??JSON.stringify(u,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:E(d,"execution.json"),source:g?"authored":"run_envelope"}),this.deriveArchivedAttemptBlobs(p)}t("convert","skipped"),t("zip","skipped"),t("presign","skipped"),t("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){t("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),t("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}),t("atomic_replace","failed",a),c}}else t("atomic_replace","skipped");let r,o;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){t("commit_lock","running");let c=await this.config.onCommitLock();if(c.ok)r=c.testcaseId||void 0,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:r??"none",trigger:c.trigger??null,test_instance_id:c.testInstanceId??null}),t("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:c.reason,message:c.message}),t("commit_lock","failed",`${c.reason??"unknown"}: ${c.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${c.reason??"unknown"}`}}else t("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){t("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let c=new V(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(r=(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:r??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(r)}catch(u){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(u)})}t("finalize","done")}else t("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(r&&this.config.shareApiBaseUrl)try{o=await this.generateShareLink(r),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:o})}catch(c){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(c)})}if(n&&i){let c=null;t("zip","running");try{await n.sealFn({testcaseId:r,shareId:o}),c=n.sealedPackPath?await Et(n.sealedPackPath):await ie(n.executionId,n.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:n.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:n.executionId,error:l})}if(c){t("zip","done",`${(c.length/1024/1024).toFixed(1)}MB`),t("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[oe(n.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}),t("presign","done"),t("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([k(a.urls.artifacts.upload_url,c,"application/zip"),k(a.urls.blob.upload_url,i,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}else{t("zip","skipped"),t("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(i.length/1024).toFixed(1)}),await k(a.urls.blob.upload_url,i,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),t("upload","done")}}let s;if(this.config.codeExport?.enabled&&r){let c=!1;try{await this.triggerCodeExport(r),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}),t("code_export","failed",`trigger failed: ${l}`)}if(c){t("code_export","running","Waiting for code generation\u2026");try{s=await this.pollAndDownloadCode(r,t),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:s}),t("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}),t("code_export","failed",l)}}}else t("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:r,shareId:o,codeExportDir:s}}catch(n){return{success:!1,testId:this.testId,error:n instanceof Error?n.message:String(n)}}}async runCodeExport(t,n){let i=n??this.config.onProgress,r=!1;try{await this.triggerCodeExport(t),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:t}),r=!0}catch(o){let s=o instanceof Error?o.message:String(o);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:s}),i("code_export","failed",`trigger failed: ${s}`)}if(r){i("code_export","running","Waiting for code generation\u2026");try{let o=await this.pollAndDownloadCode(t,i);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:o}),i("code_export","done",o),o}catch(o){let s=o instanceof Error?o.message:String(o);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:s}),i("code_export","failed",s);return}}}deriveArchivedAttemptBlobs(t){try{let n=gt(t,{readActions:i=>this.readNdjsonFromFile(i),buildBlob:i=>this.buildExecutionEnvelope(i),objective:this.config.firstObjective,screenshotBaseUrl:this.config.screenshotBaseUrl??"",extMap:this.config.screenshotExtMap,log:(i,r,o,s)=>this.log(i,r,o,s)});n>0&&this.log("info","PIPELINE_ARCHIVED_ATTEMPTS","Nested retry-attempt blobs derived",{count:n})}catch(n){this.log("debug","PIPELINE_ARCHIVED_ATTEMPTS_FAILED","Nested attempt blob pass failed",{error:n instanceof Error?n.message:String(n)})}}collectNdjsonPerRun(){let t=[],n=this.config.runObjectives??[],i=this.config.runMetadata??[],r=this.config.evidence??this.config.evidenceRead;for(let o=0;o<this.config.runDirs.length;o++){let s=this.config.runDirs[o],c=n[o]||this.config.firstObjective,a=i[o],l=r?this.readNdjsonFromFile(E(r.packTestDir,"logs",`${r.runIndices?.[o]??o}-actions.ndjson`)):this.readNdjsonFromDir(s);if(l.length>0){let u=r?.runIndices?.[o]??o,_=this.config.runFlatIndex?.[u];t.push({objective:c,records:l,..._!==void 0?{flatIndex:_}:{},resultCode:a?.resultCode,reasonCode:a?.reasonCode,errorMessage:a?.errorMessage,summary:a?.summary,oneLiner:a?.oneLiner})}}if(t.length===0){let o=E(this.config.sessionDir,"runs");if(U(o))try{let c=ee(o,{withFileTypes:!0}).filter(a=>a.isDirectory()).map(a=>a.name).sort();for(let a of c){let l=E(o,a),u=this.readNdjsonFromDir(l);u.length>0&&t.push({objective:this.config.firstObjective,records:u})}}catch{}}return t}readNdjsonFromDir(t){let n=[E(t,"run-test","actions.ndjson"),E(t,"actions.ndjson")];for(let i of n)if(U(i))return this.readNdjsonFromFile(i);return[]}readNdjsonFromFile(t){let n=[];if(!U(t))return n;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:t});let i=L(t,"utf-8");for(let r of i.split(`
|
|
5
|
+
`)){let o=r.trim();if(o)try{n.push(JSON.parse(o))}catch{}}return n}async generateShareLink(t){let n=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:n,testcase_id:t});let i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[t],entityType:"Test Case Details",expiresAt:7})},r=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:r,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let o=r?await this.config.authResolver.fetch(n,i):await R(n,{...i,headers:{...i.headers,Authorization:this.buildAuthHeader()}});if(!o.ok)throw new Error(`Share link API failed: ${o.status} ${await o.text()}`);let s=await o.json();if(!s.shareId)throw new Error("Share link API returned no shareId");return s.shareId}async triggerCodeExport(t){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:n,body:i}=K({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t,codeExport:this.config.codeExport,mobile:this.config.mobile});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:n});let r={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(i)},o=this.config.authResolver?await this.config.authResolver.fetch(n,r):await R(n,{...r,headers:{...r.headers,Authorization:this.buildAuthHeader()}});if(!o.ok)throw new Error(`Code export failed: ${o.status} ${await o.text()}`)}async pollAndDownloadCode(t,n){let i=H({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t}),r=this.config.exitTimeoutMs??3e5,o=5e3,s=Date.now()+r;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:i,timeout_ms:r});let c=(a,l)=>this.config.authResolver?this.config.authResolver.fetch(a,l):R(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 d=await a.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:a.status,body:d.slice(0,200)}),new Error(`code export poll skipped: HTTP ${a.status}`)}let u=(await a.json()).data?.find(d=>d.code_name==="kane-cli-trigger");if(!u){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),n("code_export","running","Waiting for code generation\u2026"),await this.sleep(o);continue}let _=u.status.toLowerCase();if(_==="in progress"||_==="in_progress"||_==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:u.status}),n("code_export","running","Generating code\u2026"),await this.sleep(o);continue}if(!u.url||u.url.length===0)throw new Error(`Code export status=${u.status} but no files returned`);let p=this.config.codeExportDir??E(this.config.sessionDir,"code-export");F(p,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:u.url.length,dir:p}),n("code_export","running",`Downloading ${u.url.length} files\u2026`);for(let d of u.url){let g=E(p,d.file_name),f=await R(d.file_url);if(!f.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:d.file_name,status:f.status});continue}let m=await f.text();w(g,m,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:d.file_name,size_bytes:m.length})}return p}throw new Error("Code export timed out")}sleep(t){return new Promise(n=>setTimeout(n,t))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:M(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let t=this.config.authoredExecutionPath;if(!t)return null;try{let n=L(t,"utf8");return JSON.parse(n),n}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:t}),null}}loadAuthoredBlocks(){let t=this.config.blockAuthoredExecutionPath;if(!t)return[];try{let n=JSON.parse(L(t,"utf8"));return Array.isArray(n.instructions)?n.instructions:[]}catch(n){return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 branches that did not run this time upload empty",{path:t,error:n instanceof Error?n.message:String(n)}),[]}}loadReplayOnlyPassthrough(){let t=this.config.replayOnlyPassthrough;if(!(!t||t.flatIndices.length===0))try{let n=JSON.parse(L(t.authoredExecutionPath,"utf8"));if(!Array.isArray(n.instructions))throw new Error("no instructions array");return{authoredInstructions:n.instructions,replayOnlyFlatIndices:new Set(t.flatIndices)}}catch(n){this.log("warn","PIPELINE_PASSTHROUGH_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 replay-only steps convert from this run's records",{path:t.authoredExecutionPath,flat_indices:t.flatIndices,error:n instanceof Error?n.message:String(n)});return}}buildExecutionEnvelope(t){let n=this.config.runStatuses.every(l=>l==="passed")?"success":"error",i=this.config.variableIds??{},r=[];if(this.config.variables)for(let[l,u]of Object.entries(this.config.variables)){if(u.secret||q(u))continue;let _=l.startsWith("global.")?l.slice(7):l;r.push({id:i[_]??0,name:_,value:u.value,session_value:u.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let o=[],s=l=>{let u=o.find(_=>_.name===l.name);u?u.value=l.value:o.push(l)},c=[],a=new Set;for(let l of this.collectNdjsonPerRun())for(let u of l.records)if(u.output_variable&&u.output_value!=null&&s({name:u.output_variable,value:String(u.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),u.action_type==="upload_files"){let _=N(u.action_params);if(_){let p=_.media_id||_.media_url;if(!a.has(p)){a.add(p),c.push({media_url:_.media_url,media_id:_.media_id,name:_.name,type:_.type});let d=O(_.name);s({name:tt(_.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:n,commit_id:this.config.commitId,instructions:t,modules:[],uploaded_files:c,test_params:this.config.testParams??[],test_level_variables:JSON.stringify(o),test_global_variables:r,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{ie as a,oe as b,bt as c};
|