@testmuai/kane-cli 0.10.4 → 0.10.5
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-DN7VVN3Y.js → ChatSurface-WKYH5MYP.js} +1 -1
- package/dist/{ChromeProfilePicker-TVGWXTUU.js → ChromeProfilePicker-ROQIRMWR.js} +1 -1
- package/dist/{CliFeedbackPrompt-L5ILK66U.js → CliFeedbackPrompt-55OKAT4W.js} +1 -1
- package/dist/{CliUploadProgress-IU6BQLMV.js → CliUploadProgress-NK2U3CKQ.js} +1 -1
- package/dist/{ConfigView-LU5IRRQU.js → ConfigView-7A5JTKLF.js} +1 -1
- package/dist/{EvidenceViewOffer-DNTARDEL.js → EvidenceViewOffer-U7J5ZRVK.js} +1 -1
- package/dist/{FolderPicker-6E5GE2K2.js → FolderPicker-R4QDIFTW.js} +1 -1
- package/dist/{InfoBox-SFFPLWCV.js → InfoBox-SRQ4TSUT.js} +1 -1
- package/dist/{LinksBox-6YDTIO6I.js → LinksBox-7BWLLQVR.js} +1 -1
- package/dist/{ProfilesView-6C5HJQ3Y.js → ProfilesView-TQTJR4WQ.js} +1 -1
- package/dist/{ProjectPicker-YIQIVXGK.js → ProjectPicker-A5SXNDUL.js} +1 -1
- package/dist/{SaveSessionPrompt-X3N6OGYB.js → SaveSessionPrompt-IECYZMXW.js} +1 -1
- package/dist/SingleShotApp-MN5IE6EU.js +2 -0
- package/dist/{SummaryBox-T7PDXDKS.js → SummaryBox-WFOS6GON.js} +1 -1
- package/dist/{TestMdRunView-HRJSBP2C.js → TestMdRunView-URNSXIVC.js} +1 -1
- package/dist/TestrunEvidenceTable-SZPZMW3J.js +2 -0
- package/dist/{WhoamiView-WGCWD7GP.js → WhoamiView-G6QP4SID.js} +1 -1
- package/dist/{app-download-ZS6ZMX2Z.js → app-download-UGLDWWTX.js} +1 -1
- package/dist/{assurance-job-QO4VJJCL.js → assurance-job-V5QB36WJ.js} +1 -1
- package/dist/{binary-CCCTW3QQ.js → binary-32FXH6PQ.js} +1 -1
- package/dist/{bind-JU4XPDN3.js → bind-3PB77PWJ.js} +1 -1
- package/dist/{bootstrap-BV7HAARR.js → bootstrap-A2O4UZUJ.js} +1 -1
- package/dist/{catalog-ZAROGOJA.js → catalog-P5IOIVYP.js} +1 -1
- package/dist/{catalog-client-QLHCEPPZ.js → catalog-client-LR2KPSU7.js} +1 -1
- package/dist/{changelog-6L7W76ZH.js → changelog-GKIKDJ32.js} +1 -1
- package/dist/{chunk-FTP2K6RS.js → chunk-2AHQ3D3D.js} +1 -1
- package/dist/{chunk-SZQNYDST.js → chunk-2G7UYQOW.js} +1 -1
- package/dist/{chunk-3O2RPYPM.js → chunk-2MBNAW2G.js} +1 -1
- package/dist/{chunk-SO3IXFAJ.js → chunk-2NP3THOE.js} +1 -1
- package/dist/{chunk-YZP4F23B.js → chunk-37KFCYHG.js} +1 -1
- package/dist/{chunk-Z4O5HOFX.js → chunk-3RJRCAUX.js} +3 -3
- package/dist/{chunk-PBVNX43X.js → chunk-4DM5EWEV.js} +1 -1
- package/dist/{chunk-QYWWL7M7.js → chunk-5K7PCSTP.js} +1 -1
- package/dist/{chunk-LCBDNZL3.js → chunk-5LKDOE3P.js} +1 -1
- package/dist/{chunk-ZVSZ6DIQ.js → chunk-5OFHMBZC.js} +2 -2
- package/dist/{chunk-SMSQVGLH.js → chunk-63BFLTJI.js} +1 -1
- package/dist/{chunk-PMYN3XMN.js → chunk-642GD7E6.js} +1 -1
- package/dist/{chunk-HMGM4KO6.js → chunk-66C5A2F5.js} +1 -1
- package/dist/{chunk-3HGKFRFL.js → chunk-6OL5EVRC.js} +1 -1
- package/dist/{chunk-LLDEAV3W.js → chunk-6PZ3SVWE.js} +1 -1
- package/dist/{chunk-7V6JPZBM.js → chunk-6VG2FG67.js} +1 -1
- package/dist/{chunk-Q5B54TR5.js → chunk-6WN4WSXR.js} +1 -1
- package/dist/{chunk-TO2ROHIJ.js → chunk-76MKY7FG.js} +2 -2
- package/dist/{chunk-2CJ75THZ.js → chunk-77BZTEHJ.js} +1 -1
- package/dist/chunk-7TSM2FCL.js +5 -0
- package/dist/{chunk-ECPSBI2Z.js → chunk-A5C7HIAH.js} +1 -1
- package/dist/{chunk-BV7NUIRT.js → chunk-AXOSLGQ4.js} +1 -1
- package/dist/{chunk-DJ76NDW6.js → chunk-BDZWRJAL.js} +1 -1
- package/dist/{chunk-6PURZLKM.js → chunk-BFRWZPIK.js} +1 -1
- package/dist/{chunk-MWLRLQ27.js → chunk-BLHFNL5K.js} +1 -1
- package/dist/chunk-BRWCWZE3.js +2 -0
- package/dist/{chunk-IQMJJN52.js → chunk-BZEW7CSM.js} +1 -1
- package/dist/{chunk-TXRWH6HL.js → chunk-C466XER3.js} +2 -2
- package/dist/{chunk-55W3WAAL.js → chunk-C4UME2PA.js} +1 -1
- package/dist/{chunk-ZHENGHYZ.js → chunk-CBPACEYQ.js} +1 -1
- package/dist/{chunk-IDWAG6L4.js → chunk-CJGQFKLJ.js} +1 -1
- package/dist/{chunk-4G2T54FE.js → chunk-CQBLJTDU.js} +1 -1
- package/dist/{chunk-BPTWMV5L.js → chunk-CVVUBCB7.js} +1 -1
- package/dist/{chunk-4WFN23DE.js → chunk-EIQSXD7B.js} +1 -1
- package/dist/{chunk-AFOP7DVG.js → chunk-EP4WGGMY.js} +1 -1
- package/dist/{chunk-S5PIVHPC.js → chunk-F4GWIX66.js} +1 -1
- package/dist/{chunk-GMSWZIAS.js → chunk-FHULYIG3.js} +1 -1
- package/dist/{chunk-JE5M5QIK.js → chunk-FKA5SWWF.js} +1 -1
- package/dist/{chunk-WHMCVH3T.js → chunk-FLGOQ6Q6.js} +1 -1
- package/dist/{chunk-ABNQL3PQ.js → chunk-FNBHP75S.js} +1 -1
- package/dist/{chunk-GJYMR4RT.js → chunk-FOURJ24E.js} +1 -1
- package/dist/{chunk-UZKVV3LW.js → chunk-FOUUD3LI.js} +1 -1
- package/dist/{chunk-CVVZ6NWR.js → chunk-FP6JCXOS.js} +1 -1
- package/dist/{chunk-WMIR4UXG.js → chunk-H23ZMHHC.js} +1 -1
- package/dist/{chunk-ZFKR5I3J.js → chunk-HHF7AM3D.js} +1 -1
- package/dist/{chunk-6CMBA5SG.js → chunk-HTJDMLZS.js} +1 -1
- package/dist/{chunk-DRWHVVW6.js → chunk-HY5BBSYX.js} +1 -1
- package/dist/{chunk-RG3FNO37.js → chunk-IPXITNFD.js} +1 -1
- package/dist/{chunk-EWSNJ3IX.js → chunk-IT6M7OMG.js} +1 -1
- package/dist/{chunk-5OGYXLOR.js → chunk-ITG5WMQG.js} +1 -1
- package/dist/{chunk-MZ4GTIO2.js → chunk-J3YID4A5.js} +1 -1
- package/dist/{chunk-TELSHQ3W.js → chunk-J44FV6CH.js} +1 -1
- package/dist/{chunk-JYSIPTX3.js → chunk-J5D4IGAM.js} +1 -1
- package/dist/{chunk-WB4JZ67W.js → chunk-J5QFO7LW.js} +1 -1
- package/dist/{chunk-EOLMWSLX.js → chunk-JGQ3VB44.js} +1 -1
- package/dist/{chunk-MOAZZKIZ.js → chunk-JVXEAO62.js} +1 -1
- package/dist/{chunk-YWQNZRJG.js → chunk-JYH7CTF7.js} +1 -1
- package/dist/{chunk-FH4FWIET.js → chunk-JZ7GFPKZ.js} +1 -1
- package/dist/{chunk-I3G3IUKY.js → chunk-KUSHV5SR.js} +1 -1
- package/dist/{chunk-NMCE7VR2.js → chunk-LMOW4NM5.js} +1 -1
- package/dist/{chunk-UVBPUZC4.js → chunk-LPJX5L3F.js} +1 -1
- package/dist/{chunk-4FA44D6S.js → chunk-LWP7E5FU.js} +1 -1
- package/dist/{chunk-MQU6EA44.js → chunk-LXYXCANZ.js} +1 -1
- package/dist/{chunk-5HJRYEOT.js → chunk-MAQVRBUQ.js} +1 -1
- package/dist/{chunk-4WKFM72U.js → chunk-MBNSCXVK.js} +1 -1
- package/dist/{chunk-P7V24ZXP.js → chunk-MIQ6J5YG.js} +1 -1
- package/dist/{chunk-454IWKHT.js → chunk-MUL2QFG2.js} +1 -1
- package/dist/{chunk-DBMDAWTA.js → chunk-N4XUGIAK.js} +1 -1
- package/dist/{chunk-ACBNVGVJ.js → chunk-NAUIJF72.js} +1 -1
- package/dist/{chunk-QFA6JPVE.js → chunk-NFDVDEOH.js} +2 -2
- package/dist/{chunk-BIXABKSK.js → chunk-NGBXXBHP.js} +1 -1
- package/dist/{chunk-RNKJXVG2.js → chunk-NIBNVPAE.js} +1 -1
- package/dist/{chunk-DAV4ONGS.js → chunk-NNVHWFLI.js} +1 -1
- package/dist/{chunk-QOXUGYEA.js → chunk-NZ7UCAN6.js} +1 -1
- package/dist/{chunk-HGKAUG7L.js → chunk-OPR5XIPT.js} +1 -1
- package/dist/{chunk-QXZGBYGQ.js → chunk-PCL2FYPE.js} +1 -1
- package/dist/{chunk-KJZD2ADR.js → chunk-PE3CEG6E.js} +1 -1
- package/dist/{chunk-3VSAAB2W.js → chunk-PKXWYYVK.js} +1 -1
- package/dist/{chunk-56NUPYFG.js → chunk-PSBR2LVL.js} +1 -1
- package/dist/{chunk-H6QHG62O.js → chunk-PZOQ2IQK.js} +1 -1
- package/dist/{chunk-2VLM4L3S.js → chunk-Q4QCSO6Y.js} +1 -1
- package/dist/{chunk-MNELOQ4J.js → chunk-QJ5XHVS5.js} +1 -1
- package/dist/{chunk-JJDD4HPX.js → chunk-QRUAI2ST.js} +1 -1
- package/dist/{chunk-2KPJ62RZ.js → chunk-QWEQ742S.js} +1 -1
- package/dist/{chunk-DXXHCLFC.js → chunk-R6S4EJ5R.js} +1 -1
- package/dist/{chunk-7WWCIS2B.js → chunk-RHQLDNZL.js} +1 -1
- package/dist/{chunk-X3O4VGTM.js → chunk-RM5ZVDVR.js} +1 -1
- package/dist/{chunk-4KFSSETE.js → chunk-RU3SWHRE.js} +1 -1
- package/dist/{chunk-662MCICY.js → chunk-S5UITUBB.js} +1 -1
- package/dist/{chunk-T5FQRUI2.js → chunk-SACFQNUH.js} +7 -7
- package/dist/{chunk-EG3B52WU.js → chunk-SDIHDYWT.js} +1 -1
- package/dist/{chunk-GPIVYCHQ.js → chunk-SFHDRKUX.js} +1 -1
- package/dist/{chunk-EWK3UPEN.js → chunk-SLISNOG6.js} +1 -1
- package/dist/{chunk-OSEXVHEN.js → chunk-TC2PHBPH.js} +1 -1
- package/dist/{chunk-FQ2AMM3E.js → chunk-TPCW5OU5.js} +1 -1
- package/dist/{chunk-P43YHCF3.js → chunk-UJYC2XDD.js} +1 -1
- package/dist/chunk-UV7FPIBL.js +2 -0
- package/dist/{chunk-A74JRNNX.js → chunk-UWEBI76C.js} +1 -1
- package/dist/{chunk-LV7OWLJK.js → chunk-UWQ4KXLB.js} +1 -1
- package/dist/{chunk-73EHVDL5.js → chunk-V24LUINK.js} +1 -1
- package/dist/{chunk-OX3ZAGCH.js → chunk-V3IWCGZT.js} +1 -1
- package/dist/{chunk-4QV2RL6P.js → chunk-VEE2O524.js} +1 -1
- package/dist/{chunk-3JATEWA5.js → chunk-VJRXJJML.js} +2 -2
- package/dist/{chunk-JM45SLKV.js → chunk-VKIUHHNT.js} +2 -2
- package/dist/{chunk-7KASYSFM.js → chunk-W3PQMIXE.js} +1 -1
- package/dist/{chunk-S74NLCFZ.js → chunk-WAC5WISH.js} +1 -1
- package/dist/{chunk-KLY6IQD5.js → chunk-XJV5SF3X.js} +3 -3
- package/dist/{chunk-ATCJ7EHL.js → chunk-XRJH4UF3.js} +1 -1
- package/dist/{chunk-SBW3QVHN.js → chunk-Y3RDLUH5.js} +5 -5
- package/dist/{chunk-BXAPTB2H.js → chunk-YF22VTR5.js} +3 -3
- package/dist/{chunk-TLYFHPNM.js → chunk-YLI7DQMJ.js} +2 -2
- package/dist/{chunk-BK3LWNKB.js → chunk-YQXOD7SV.js} +3 -3
- package/dist/{chunk-PHKJIJ7D.js → chunk-YTWBNACA.js} +1 -1
- package/dist/{chunk-QEBVYQNC.js → chunk-YUFXE6WU.js} +1 -1
- package/dist/{commands-X5T6YANK.js → commands-TRAUFCRZ.js} +1 -1
- package/dist/{config-F5Q6QX27.js → config-O3BWQUP4.js} +1 -1
- package/dist/{cover-cmd-PWUZU4HK.js → cover-cmd-SAWVP7TL.js} +1 -1
- package/dist/{credentials-D5KQMHCK.js → credentials-NNNODDXF.js} +1 -1
- package/dist/{deps-bundle-R7FNIV4M.js → deps-bundle-CXKBCA7W.js} +1 -1
- package/dist/{deps-resolve-IF6P6NWI.js → deps-resolve-K7XNTRZX.js} +1 -1
- package/dist/{design-chat-HYK3HNIM.js → design-chat-S4KYE6PP.js} +1 -1
- package/dist/{design-headless-DR7WB37W.js → design-headless-DDAFAJNR.js} +1 -1
- package/dist/{design-remote-TGUNEWEM.js → design-remote-UITWJ72Q.js} +2 -2
- package/dist/device-env-SBTHFSVK.js +2 -0
- package/dist/doctor-SRMLENYN.js +2 -0
- package/dist/{evidence-SRWISQMQ.js → evidence-FOWW3MOS.js} +1 -1
- package/dist/{evolve-cmd-2BALEYZU.js → evolve-cmd-MDK2H4JY.js} +1 -1
- package/dist/{evolve-remote-OHOUWO65.js → evolve-remote-4G7YFC5H.js} +1 -1
- package/dist/{explain-cmd-VTDAMXAW.js → explain-cmd-Q4NLNJFB.js} +1 -1
- package/dist/{explore-UZWQRJ7H.js → explore-MWUMVGRM.js} +1 -1
- package/dist/{explore-context-tty-PAKJVDJU.js → explore-context-tty-QLMZGYBX.js} +1 -1
- package/dist/{explore-entry-ZOPO7DBZ.js → explore-entry-QMCVGRP4.js} +4 -4
- package/dist/{explore-live-RUAAZGX4.js → explore-live-QIET6WO4.js} +1 -1
- package/dist/{explore-run-tty-DYLMHI7F.js → explore-run-tty-6UTBRCEF.js} +2 -2
- package/dist/{extract-bind-WPICR4IC.js → extract-bind-UTERWZMW.js} +3 -3
- package/dist/{extract-chat-KVUB5HPM.js → extract-chat-4WBNRVPG.js} +1 -1
- package/dist/{extract-cmd-OJ7LXSKL.js → extract-cmd-SYZX6CML.js} +2 -2
- package/dist/{extract-headless-OQJSUSG4.js → extract-headless-QBF77JWP.js} +1 -1
- package/dist/{folder-flags-MEZUAXTT.js → folder-flags-IJ556UET.js} +1 -1
- package/dist/{gaps-cmd-2R4RMWN6.js → gaps-cmd-E55OGZ7P.js} +1 -1
- package/dist/{gate-SM4HPJLA.js → gate-5UIJVMHL.js} +1 -1
- package/dist/{generate-headless-XR3RVULC.js → generate-headless-VYD2QIUO.js} +2 -2
- package/dist/{impact-cmd-EL3QSOAF.js → impact-cmd-3P6SKFJC.js} +2 -2
- package/dist/index.js +20 -20
- package/dist/{ingest-cmd-N3USC7TW.js → ingest-cmd-HMTLO5MB.js} +3 -3
- package/dist/{ingest-remote-2VKWAFJZ.js → ingest-remote-NIW5VAGW.js} +1 -1
- package/dist/install-KJDAGU2R.js +2 -0
- package/dist/{interactive-bind-F7QTQOKC.js → interactive-bind-K3ZQFHLH.js} +2 -2
- package/dist/{interactive-remote-A33J4KMP.js → interactive-remote-SGM76D6M.js} +1 -1
- package/dist/{lattice-auth-IJT542IF.js → lattice-auth-DCAVEQKY.js} +1 -1
- package/dist/{lifecycle-cmd-OKUFZKEX.js → lifecycle-cmd-Y5DH2PL5.js} +1 -1
- package/dist/{list-cmd-7OTI66MQ.js → list-cmd-RYHICCUV.js} +1 -1
- package/dist/{list-commands-FZPVH76I.js → list-commands-QFTIQE6Q.js} +1 -1
- package/dist/{list-remote-BQ4NILCA.js → list-remote-PWAQBF57.js} +1 -1
- package/dist/login-flow-W7RAVXSD.js +2 -0
- package/dist/{maintenance-cmd-BLV7K4RK.js → maintenance-cmd-JNP2KCSI.js} +1 -1
- package/dist/{mobile-prompts-5TGLJUBV.js → mobile-prompts-SP2RULD7.js} +1 -1
- package/dist/{onboarding-F4EIJ4GD.js → onboarding-YPIKXNYA.js} +1 -1
- package/dist/{persist-recorded-session-WYMOHDTB.js → persist-recorded-session-BWGA7WXR.js} +1 -1
- package/dist/{pipeline-XYM6HIDZ.js → pipeline-YE4IRKQX.js} +1 -1
- package/dist/{policy-commands-AOLVAZZD.js → policy-commands-MSJIPHDB.js} +1 -1
- package/dist/{prepare-target-P4AZWC37.js → prepare-target-G7LU4LYX.js} +1 -1
- package/dist/{pull-cmd-C4HMYD4I.js → pull-cmd-G3PVSSFP.js} +1 -1
- package/dist/{pull-route-MHW5PWDW.js → pull-route-5JQUUSU7.js} +1 -1
- package/dist/real-device-run-425XK527.js +2 -0
- package/dist/{reconcile-cmd-VXY737OT.js → reconcile-cmd-QJBYZVUB.js} +4 -4
- package/dist/{reconcile-remote-UGW2433E.js → reconcile-remote-JMV26DLX.js} +2 -2
- package/dist/{recording-banner-EPOTSMYF.js → recording-banner-VZ67EWWQ.js} +1 -1
- package/dist/{registry-WTWTFRXD.js → registry-3YMKU5GC.js} +1 -1
- package/dist/{remote-entry-SPA4CSJJ.js → remote-entry-6LQRYR5F.js} +1 -1
- package/dist/{remote-mode-QO6BDGXM.js → remote-mode-35BQUMEL.js} +1 -1
- package/dist/{remote-words-TAZT4YBT.js → remote-words-QXVFVHOB.js} +1 -1
- package/dist/{require-project-folder-WBCAVVMB.js → require-project-folder-O2XCXDRE.js} +1 -1
- package/dist/{resolve-run-intent-RBOCIYEA.js → resolve-run-intent-QCRZPYXM.js} +1 -1
- package/dist/{resolver-3BGIXYYJ.js → resolver-LWXOB7PH.js} +1 -1
- package/dist/{review-cmd-WE6I5XTY.js → review-cmd-PYU7YCAC.js} +1 -1
- package/dist/{run-remote-6Y62RWMJ.js → run-remote-PS45MTHW.js} +1 -1
- package/dist/{run-startup-gate-Q7FP2IRE.js → run-startup-gate-YBQB2JLF.js} +1 -1
- package/dist/{run-test-md-24MBKBC6.js → run-test-md-XYOCVA6F.js} +2 -2
- package/dist/session-worker.js +2 -2
- package/dist/{sessions-cmd-5NS5P4CP.js → sessions-cmd-WUWZYZJW.js} +1 -1
- package/dist/{sessions-remote-75PDRPOY.js → sessions-remote-4J7ITZB4.js} +1 -1
- package/dist/{skill-installer-7PK64TZE.js → skill-installer-54ZAFNOB.js} +1 -1
- package/dist/{store-AVYBL5HB.js → store-2F26FIUS.js} +1 -1
- package/dist/{store-choice-ZWU3PDNL.js → store-choice-ZE7AZMRC.js} +1 -1
- package/dist/{store-guard-ETUXXG7X.js → store-guard-X5FIEZWZ.js} +1 -1
- package/dist/{sync-cmd-CSTMT6E6.js → sync-cmd-TAVE44DU.js} +1 -1
- package/dist/{sync-setup-Y53K6TJ6.js → sync-setup-M65RX34Y.js} +1 -1
- package/dist/tcg-generate-OXZF7TNQ.js +2 -0
- package/dist/{testmd-actions-BE4YJ6ZZ.js → testmd-actions-4OHRME2Z.js} +1 -1
- package/dist/{testmd-sync-QZWVWTZZ.js → testmd-sync-HM24JCS7.js} +1 -1
- package/dist/token-refresh-3SEDPIXO.js +2 -0
- package/dist/{validate-basic-QWPESO74.js → validate-basic-HWDR665U.js} +1 -1
- package/dist/{version-check-EOYWTY3Z.js → version-check-DRE5KT7F.js} +1 -1
- package/dist/{view-cmd-KG4HI334.js → view-cmd-3UKV3YEX.js} +1 -1
- package/dist/{walk-session-WM4S2JMV.js → walk-session-W6OLG5NT.js} +1 -1
- package/dist/{with-telemetry-RJM3JKL6.js → with-telemetry-BF4BGK5S.js} +1 -1
- package/package.json +11 -11
- package/dist/SingleShotApp-MXNJPU6A.js +0 -2
- package/dist/TestrunEvidenceTable-OGMWTJQF.js +0 -2
- package/dist/chunk-APXJRWIJ.js +0 -2
- package/dist/chunk-V57R4X3O.js +0 -5
- package/dist/chunk-YKOZBFR3.js +0 -2
- package/dist/device-env-LZB3PKMA.js +0 -2
- package/dist/doctor-PLFEA2HM.js +0 -2
- package/dist/install-3IEM3I3X.js +0 -2
- package/dist/login-flow-BYQ7SYGB.js +0 -2
- package/dist/real-device-run-WAOWKEFJ.js +0 -2
- package/dist/tcg-generate-VQLI6NGK.js +0 -2
- package/dist/token-refresh-PZ3TOKAL.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as v,b as P}from"./chunk-QLGQDNA3.js";import{a as x,c as $,d as B,e as k}from"./chunk-EUGFABAS.js";import{b as F,d as I}from"./chunk-UVL6XQHU.js";import{c as M,d as _,e as R}from"./chunk-
|
|
2
|
+
import{a as v,b as P}from"./chunk-QLGQDNA3.js";import{a as x,c as $,d as B,e as k}from"./chunk-EUGFABAS.js";import{b as F,d as I}from"./chunk-UVL6XQHU.js";import{c as M,d as _,e as R}from"./chunk-RHQLDNZL.js";import{a as S}from"./chunk-4C7WVQOD.js";import{o as j}from"./chunk-OKCVG7AG.js";import{existsSync as A,readdirSync as U,readFileSync as D}from"fs";import{join as L}from"path";var H=new Set(["unwritable","unreadable","unresolved"]),K=/^@import\s+(\S+)\s*$/,N=1e3;async function V(e){let i=[];for(let t=e.basePosition+1;t<=e.position;t++)i.push(await e.person.mainRecord(e.projectId,t));return i}async function re(e){try{let i=Array.from({length:Math.max(0,e.landing.position-e.landing.basePosition)},(f,p)=>e.landing.basePosition+1+p),[t,d]=await Promise.all([Promise.all(i.map(f=>e.person.mainRecord(e.projectId,f))),e.person.nodes(e.projectId,"usecase")]),c=new Map(d.flatMap(f=>f.name?[[f.cid,f.name]]:[])),g=new Set;for(let{record:f}of t){for(let l of M(f))l.label==="usecase"&&g.add(l.cid);let p=f.design_of?.uc_cid;typeof p=="string"&&g.add(p);for(let l of f.edges??[])(l.type==="belongs_to"||l.type==="scoped_to")&&typeof l.dst=="string"&&g.add(l.dst)}let w=f=>e.person.mainNode(e.projectId,f).catch(p=>p instanceof S&&p.code==="NOT_FOUND"?null:Promise.reject(p)),h=new Set;for(let f of g){let p=c.get(f);if(p){h.add(p.toLowerCase());continue}let l=await w(f);for(let u=0;l!==null&&l.name===null&&l.supersededBy&&u<N;u++)l=await w(l.supersededBy);l?.label==="usecase"&&l.name&&h.add(l.name.toLowerCase())}return h}catch(i){(e.trace??v("test-manager"))(`the session's use cases couldn't be read after the save: ${P(i)}`);return}}function C(e){let i=e.content.test_md_blob;return typeof i!="string"?[]:i.split(`
|
|
3
3
|
`).flatMap(t=>{let d=K.exec(t.trim());return d?[d[1]]:[]})}async function W(e){let i=new Map,t=new Map,d=new Map,c=new Map;for(let{record:n}of e.records){for(let o of M(n))i.set(o.cid,{label:o.label,content:o.content});for(let{cid:o,slug:r}of _(n))t.set(o,r),d.set(r,o);for(let o of R(n))c.set(o.old,o.new)}let{chainOf:g,tipOf:w}=T(c),h=n=>e.person.mainNode(e.projectId,n).catch(o=>o instanceof S&&o.code==="NOT_FOUND"?null:Promise.reject(o)),f=new Map([...c].flatMap(([n,o])=>o===null?[]:[[o,n]]));for(let[n,o]of[...i]){if(o.label!=="test"||c.has(n))continue;let r=n;for(let y=0;f.has(r)&&!t.has(r)&&y<N;y++)r=f.get(r);if(t.has(r)||i.has(r))continue;let m=await h(r);m===null||m.label!=="test"||!m.name||d.has(m.name)||(i.set(r,{label:m.label,content:m.content}),t.set(r,m.name),d.set(m.name,r))}let p=[...t.keys()].filter(n=>{if(i.get(n)?.label!=="test")return!1;let{later:o,retired:r}=g(n);return!r&&!o.some(m=>t.has(m))}),l=await X({read:h,nodes:i,nameOf:t,byName:d,next:c,tests:p,cwd:e.cwd}),u=e.trace??v("test-files"),s=await z({records:e.records,read:h,nameOf:t,here:[...l.wrote,...l.unchanged??[]],cwd:e.cwd,trace:u}).catch(n=>(u(`the replaced tests' files couldn't be looked for: ${P(n)}`),[])),a=q({tests:p,nodes:i,nameOf:t,tipOf:w,minted:l,cwd:e.cwd,trace:e.trace??v("test-files")});return{...l,saved:p.map(n=>t.get(n)),...s.length>0?{replaced:s}:{},...a?{needed:a}:{}}}function T(e){let i=t=>{let d=[],c=t;for(let g=0;e.has(c)&&g<N;g++){let w=e.get(c);if(w===null)return{later:d,retired:!0};d.push(w),c=w}return{later:d,retired:!1}};return{chainOf:i,tipOf:t=>i(t).later.at(-1)??t}}async function X(e){let{read:i,nodes:t,nameOf:d,byName:c,next:g,tests:w}=e,{chainOf:h,tipOf:f}=T(g),p=w.flatMap(u=>C(t.get(f(u))));for(;p.length>0;){let u=p.pop();if(c.has(u))continue;let s=await i(u);if(s===null||s.label!=="test")continue;let a=s;for(let n=0;a.supersededBy&&n<N;n++){let o=await i(a.supersededBy);if(o===null)throw new Error(`main names ${a.supersededBy} as what replaced ${a.cid}, but doesn't hold it`);a=o}t.set(s.cid,{label:s.label,content:s.content}),t.set(a.cid,{label:a.label,content:a.content}),d.set(s.cid,u),c.set(u,s.cid),a.cid!==s.cid&&g.set(s.cid,a.cid),p.push(...C(t.get(a.cid)))}return I({graph:{nameOf:d,getNode:u=>t.get(u)??null,resolve:u=>{let s=c.get(u)??(t.has(u)?u:void 0);if(s===void 0)return null;let{later:a,retired:n}=h(s),o=a.at(-1)??s;return{cid:s,tip:o,superseded:n||o!==s}}},cids:w,cwd:e.cwd,skipSame:!0,refuseUnwritable:!0,...e.overwriteEdited?{overwriteEdited:!0}:{}})}function q(e){try{let i=new Map([...e.minted.wrote,...e.minted.unchanged??[]].map(d=>[d.id,d.path])),t=x({cwd:e.cwd,tests:e.tests.map(d=>{let c=e.nameOf.get(d);return $(c,e.nodes.get(e.tipOf(d))?.content??{},i.get(c))})});if(t.variables.length===0&&t.noStartPage.length===0)return;try{B(t,e.cwd)}catch(d){e.trace(`the variables the saved tests need couldn't be written to ${t.file}: ${k(d)}`)}return t}catch(i){e.trace(`what the saved tests need couldn't be read: ${k(i)}`);return}}async function z(e){let i=new Map,t=new Map,d=new Set,c=new Map;for(let{record:s}of e.records){for(let r of M(s))d.add(r.cid);for(let r of R(s))c.set(r.old,r.new);for(let r of s.edges??[])r.type!=="verifies"||typeof r.src!="string"||typeof r.dst!="string"||t.set(r.src,(t.get(r.src)??new Set).add(r.dst));let a=s.design_of?.uc_cid;if(typeof a!="string")continue;let n=i.get(a)??{retired:[],made:[]};i.set(a,n);let o=new Set(M(s).flatMap(r=>r.label==="test"?[r.cid]:[]));for(let r of R(s))(r.new===null||r.new!==r.old&&o.has(r.new))&&n.retired.push(r.old);n.made.push(...o)}let g=F(e.cwd);if(![...i.values()].some(s=>s.retired.length>0)||!A(g))return[];let w=new Map(e.here.map(s=>[s.id,s.path])),h=new Set(e.here.map(s=>s.path)),f=new Map;for(let s of U(g)){let a=L(g,s);if(!(!s.endsWith("_test.md")||h.has(a)))try{let n=j(D(a,"utf8"));n?.base&&n.id&&f.set(n.base,{id:n.id,file:a})}catch{}}let p=new Set([...i.values()].flatMap(s=>s.made.flatMap(a=>[...t.get(a)??[]]))),l=async s=>{let a=new Set;for(let n=s,o=0;n&&!a.has(n)&&o<N;o++){if(a.add(n),!c.has(n)&&!p.has(n)&&!d.has(n)){let r=await e.read(n).catch(m=>e.trace(`a criterion's later versions couldn't be read: ${P(m)}`));c.set(n,r?.supersededBy??null)}n=c.get(n)}return a},u=[];for(let{retired:s,made:a}of i.values())for(let n of s){let o=await e.read(n),r=o?.label==="test"?o.content.definitionId:void 0,m=typeof r=="string"?f.get(r):void 0;if(!m||!o)continue;let y=new Set;for(let b of o.edgesOut)if(b.type==="verifies"){b.other&&c.set(b.dst,b.other.supersededBy);for(let O of await l(b.dst))y.add(O)}let E=a.flatMap(b=>{let O=w.get(e.nameOf.get(b)??"");return O&&[...t.get(b)??[]].some(G=>y.has(G))?[O]:[]});u.push({test:m.id,file:m.file,replacedBy:E})}return u}async function ie(e){let i=e.trace??v("test-files");try{let t=await V({person:e.person,projectId:e.projectId,basePosition:e.landing.basePosition,position:e.landing.position}),d=await W({person:e.person,projectId:e.projectId,records:t,cwd:e.cwd,trace:i});for(let c of d.refused)H.has(c.kind)&&i(`test file for ${c.id} not written: ${c.reason}`);return d}catch(t){return i(`main couldn't be read after the save: ${P(t)}`),"unread"}}export{re as a,X as b,ie as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as c}from"./chunk-5D7ENQTQ.js";import{c as b,
|
|
2
|
+
import{b as c}from"./chunk-5D7ENQTQ.js";import{c as b,k as v}from"./chunk-BRWCWZE3.js";import{a as w}from"./chunk-2XW33VOK.js";import{d as h,h as g}from"./chunk-A7RJQJNT.js";import{readFileSync as C,writeFileSync as k,mkdirSync as x,existsSync as T}from"fs";import{dirname as S}from"path";var f={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:v,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",assertion_failure_mode:"stop",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},I=f;function E(r){let{mobile:e,...o}=r,t={...o};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 i=n.default_target?.id?.trim();i&&(t.device=i)}n.default_app&&(t.app=n.default_app);let a={};n.no_reset!==void 0&&(a.no_reset=n.no_reset),n.appium_url!==void 0&&(a.appium_url=n.appium_url);for(let i of c)n[i]!==void 0&&(a[i]=n[i]);return Object.keys(a).length>0&&(t.mobile=a),t}function R(r){let e=r.mobile??{},o=typeof r.target=="string"?r.target:void 0,t=typeof r.device=="string"&&r.device.trim()!==""?r.device.trim():void 0,n=d=>typeof d=="string"&&d.trim()!==""?d.trim():void 0,s=n(r.device_name),l=n(r.os_version),a=typeof r.app=="string"&&r.app!==""?r.app:void 0,i={},_=o??e.tui_target;_&&(i.tui_target=_);let p=w(_,void 0).kind,u=h(p)?p:null;u&&(s||l)?i.default_target={platform:g(u),kind:u,...s?{name:s}:{},...l?{os_version:l}:{}}:u&&t?i.default_target={platform:g(u),kind:u,id:t}:(e.default_target?.id?.trim()||e.default_target?.name?.trim())&&(i.default_target=e.default_target);let m=a??e.default_app;m&&(i.default_app=m),e.no_reset!==void 0&&(i.no_reset=e.no_reset),e.appium_url!==void 0&&(i.appium_url=e.appium_url);for(let d of c)e[d]!==void 0&&(i[d]=e[d]);return Object.keys(i).length>0?i:void 0}var y=class{constructor(e=b){this.path=e}exists(){return T(this.path)}load(){try{let e=C(this.path,"utf-8"),o=JSON.parse(e),t=R(o),{target:n,device:s,app:l,...a}=o;return{...f,...a,...t?{mobile:t}:{},code_export:{...f.code_export,...o.code_export??{}},generate:{...f.generate,...o.generate??{}}}}catch{return{...f,code_export:{...f.code_export},generate:{...f.generate}}}}write(e){try{x(S(this.path),{recursive:!0}),k(this.path,JSON.stringify(E(e),null,2)+`
|
|
3
3
|
`)}catch(o){let t=o instanceof Error?o.message:String(o);process.stderr.write(`[config] Failed to save config: ${t}
|
|
4
4
|
`)}}set(e,o){let t=this.load();t[e]=o,this.write(t)}save(e){this.write({...this.load(),...e})}getMobile(){return this.load().mobile??{}}setMobile(e){let o={...this.getMobile()};for(let t of Object.keys(e)){let n=e[t];n===void 0?delete o[t]:o[t]=n}this.set("mobile",Object.keys(o).length>0?o:void 0)}writeRaw(e){this.write(e)}};export{I as a,y as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as h}from"./chunk-
|
|
2
|
+
import{a as h}from"./chunk-NIBNVPAE.js";import{a as A}from"./chunk-HCBYKLMW.js";import{A as l}from"./chunk-BRWCWZE3.js";import{a as c,b as f,i as P}from"./chunk-33DWJV67.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as B}from"./chunk-
|
|
2
|
+
import{a as B}from"./chunk-FOURJ24E.js";import{b as N,f as d}from"./chunk-AXOSLGQ4.js";import{a as g,b as E}from"./chunk-QLGQDNA3.js";import{e as y,f as _}from"./chunk-IT6M7OMG.js";import{b as F,f as U,g as v}from"./chunk-RM5ZVDVR.js";import{d as C,e as O,i as x}from"./chunk-XMPTFXPW.js";import{C as h,Ha as c,f as R,r as P,w as S}from"./chunk-RHQLDNZL.js";import{a as w}from"./chunk-4C7WVQOD.js";async function I(e,r){let o=await r.project(e);return o===null?"no_access":o.marked?"marked":"unmarked"}var M=5e3;async function D(e,r=()=>!0){try{for(;;){if(!r())return{found:!1,failed:!0};let o=await e.next();if(o.done)return{found:!1};if(o.value.length>0)return{found:!0,rows:o.value}}}catch{return{found:!1,failed:!0}}}async function j(e,r={}){let o=await L(e,r.budgetMs??M);return o.state==="unknown"&&G(`shared projects weren't checked, so this folder goes on locally: ${o.reason}`),o}async function L(e,r){let o;try{o=await y()}catch(a){return a instanceof x?{state:"unknown",reason:"not signed in",signedOut:!0}:{state:"unknown",reason:"the credentials couldn't be read"}}let t,n=!1,s=new Promise(a=>{t=setTimeout(()=>{n=!0,a({state:"unknown",reason:`the project list took over ${r} ms`})},r)}),l=(async()=>{let a=R({url:e,basicAuth:o}).projects(),i=await D(a,()=>!n);return i.found?{state:"rolled_out",first:{rows:i.rows,more:a}}:i.failed?{state:"unknown",reason:"the project list couldn't be read"}:{state:"not_rolled_out"}})();try{return await Promise.race([l,s])}finally{clearTimeout(t)}}var G=g("remote-check");var T=e=>({code:e.code,message:e.message,...e.remedy?{remedy:e.remedy}:{}});async function A(e,r=_(e.latticeUrl)){let o;try{o=await I(e.projectId,r)}catch(t){if(t instanceof x)return T(t);if(t instanceof w&&t.retryable)return c.noConnection();if(t instanceof w&&t.status===401)return c.credentialsRejected();throw t}return o==="no_access"?c.noAccess(e.projectName):null}function H(e,r,o,t){if(e instanceof w){if(e.code==="SESSION_CLASH"&&t!==void 0&&h(e.extra.heldBy)!==null)return{...c.projectBusy({project:r.projectName,verb:t.verb==="evolve"?"design":t.verb,resume:o!==null,held:h(e.extra.heldBy),...t.useCase?{useCase:t.useCase}:{},...t.title!==void 0?{title:t.title}:{},...t.agent?{agent:!0}:{}}),exit:2};if(e.code==="MARK_REFUSED")return{...c.markRefused(r.projectName,r.onboarded===!0),exit:2};if(e.code==="PROJECT_NOT_MARKED")return{...c.assuranceOff(r.projectName),exit:2};if(e.retryable)return{...c.noConnectionAtStart(),exit:2};if(e.status===401)return{...c.credentialsRejected(),exit:2};if(e.code==="SESSION_ENDED")return{...$(e,o??""),exit:2};if(e.code==="NOT_FOUND"&&o!==null)return{...c.noSuchSession(o),exit:2};if(e.code==="FORMS_REFUSED")return{...J(e.extra)?c.versionCliOlder():c.versionServiceOlder(),exit:2}}else if(e instanceof B)return{...e.side==="cli_older"?c.versionCliOlder():c.versionServiceOlder(),exit:2};return{...c.openFailed(),exit:1}}function $(e,r){return e.extra.ended==="failed"?c.sessionFailed(r):c.sessionFinished(r)}function J(e){let r=typeof e.claimed=="number"?e.claimed:null;return r===null?!1:typeof e.oldestRead=="number"&&r<e.oldestRead?!0:typeof e.highestWriter=="number"&&e.highestWriter>r}async function fe(e,r,o,t={}){P({verb:e,mode:r?"agent":"interactive"});let n=await K(e,r,o,t);return n!==null&&"exit"in n&&await S(),n}async function K(e,r,o,t){let n=F(process.cwd()),s=e.split(" ").at(-1);if(t.project!==void 0||t.local===!0){let i=await W(n,e,s,r,{...t,...o!==void 0?{resume:o}:{}});if(i!=="undecided")return i}if(n.kind==="refuse")return{exit:d(n.refusal,s,r)};let l=n;if(n.kind==="pick"){if(o===void 0){if(!N.has(e)||!(!r&&C()&&t.onboard!==!1))return null;let u=await j(n.latticeUrl);if(u.state==="unknown"&&u.signedOut&&e==="context ingest"){let{signIn:m}=await import("./onboarding-YPIKXNYA.js");if(await m()!=="signed_in")return null;u=await j(n.latticeUrl)}if(u.state!=="rolled_out")return null;let{onboard:k}=await import("./onboarding-YPIKXNYA.js"),p=e==="context extract"?"context extract":"context ingest",f=await k(n,{first:u.first,verb:p});return"exit"in f?f:"local"in f?p==="context extract"&&f.made?{exit:0}:null:{choice:f.choice}}if((await j(n.latticeUrl)).state!=="rolled_out")return null;try{l=await V(n,o,await y())}catch(i){return i instanceof x?{exit:d(T(i),s,r)}:{exit:d(H(i,{kind:"remote",latticeUrl:n.latticeUrl,projectId:"",projectName:""},o),s,r)}}}if(l.kind!=="remote")return null;let a=await A(l);return a?{exit:d(a,s,r)}:{choice:l}}async function W(e,r,o,t,n){let[{decideFolderFlags:s},{personTms:l,workLocally:a}]=await Promise.all([import("./folder-flags-IJ556UET.js"),import("./onboarding-YPIKXNYA.js")]),i=await s(e,{...n,agent:t},{getProject:async m=>(await l()).getProject(m)});if(i.kind==="none")return"undecided";if(i.kind==="refuse")return{exit:d(i.refusal,o,t)};let u=r==="context extract"?"context extract":"context ingest";if(i.kind==="local"){let m=a(u,{print:!t});if(!m.made)return null;if(t){let b=O("ndjson","extract");if(b.event({type:"folder_local",gitignore:m.gitignore}),u==="context extract")return{exit:b.done(0)}}return u==="context extract"?{exit:0}:null}if(n.notBuilt)return{exit:d(n.notBuilt,o,t)};let k=e;try{v(process.cwd(),{projectId:i.projectId,projectName:i.projectName,writtenBy:"kane-cli"})}catch(m){return g("remote-check")(`the folder's link couldn't be written: ${E(m)}`),{exit:d(c.projectFileUnwritable(U(process.cwd())),o,t)}}let p={kind:"remote",latticeUrl:k.latticeUrl,projectId:i.projectId,projectName:i.projectName,onboarded:!0},f=await A(p);return f?{exit:d(f,o,t)}:{choice:p}}async function V(e,r,o,t){let n=R({url:e.latticeUrl,basicAuth:o,...t?{fetch:t}:{}}),s=await n.getSession(r),l="";for await(let a of n.projects()){let i=a.find(u=>u.projectId===s.projectId);if(i){l=i.name;break}}return{kind:"remote",latticeUrl:e.latticeUrl,projectId:s.projectId,projectName:l}}export{A as a,H as b,$ as c,fe as d,V as e};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as w,c as L,g as fe,j as ge}from"./chunk-GRQKMOKE.js";import{b as pe}from"./chunk-ATCJ7EHL.js";import{d as X}from"./chunk-DBMW3VUN.js";import{a as Q}from"./chunk-7V4BQSSV.js";import{a as de}from"./chunk-4QTH7VYE.js";import{a as ue,b as le}from"./chunk-73EHVDL5.js";var De={requestMs:3e4,requests:64,redirects:5,bodyBytes:X.contentBytes},Fe=new Set(["authorization","proxy-authorization","cookie","host"]),He=new Set(["set-cookie","set-cookie2","www-authenticate","proxy-authenticate"]);function he(e){try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.origin:null}catch{return null}}async function Je(e,t,n,r){let i=Number(e.headers.get("content-length"));if(Number.isFinite(i)&&i>t&&(await e.body?.cancel().catch(()=>{}),r(`${n} answered with ${i} bytes; a plugin's source may be at most ${t}`)),e.body===null)return new Uint8Array(0);let s=e.body.getReader(),u=[],c=0;for(;;){let{done:k,value:x}=await s.read();if(k)break;c+=x.byteLength,c>t&&(await s.cancel().catch(()=>{}),r(`${n} answered with more than ${t} bytes; a plugin's source may be at most ${t}`)),u.push(x)}let l=new Uint8Array(c),g=0;for(let k of u)l.set(k,g),g+=k.byteLength;return l}function xe(e){let{plugin:t}=e,n={...De,...e.limits},r=e.fetchImpl??fetch,i=new Set(e.allow.map(h=>he(h)).filter(h=>h!==null)),s=[...i].join(", ")||"no origin",u=0,c=null,l=!1,g=new Set,k=()=>{throw new L({code:"PLUGIN_CONNECTION_REFUSED",message:`the connection for plugin ${t} is closed: its fetch has ended`,plugin:t,hook:"fetch"})},x=(h,o)=>{let d=new L({code:h,message:o,plugin:t,hook:"fetch"});throw c??=d,d},$=h=>x("PLUGIN_CONNECTION_REFUSED",`plugin ${t} ${h}`),R=(h,o)=>{let d=he(h);return d===null&&$(`${o} ${JSON.stringify(h)}, which is not an http or https URL`),i.has(d)||$(`${o} ${h}, which is not an origin it may reach \u2014 it may reach ${s}`),new URL(h)};return{get breach(){return c},close(){l=!0;for(let h of g)h.abort();g.clear()},async request(h){l&&k();let o=h.method??"GET",d=o==="POST"?h.body:void 0;o!=="GET"&&o!=="POST"&&$(`asked for a ${JSON.stringify(o)} request; a plugin's connection makes GET and POST requests only`);let p={};for(let[m,O]of Object.entries(h.headers??{})){let E=m.toLowerCase();Fe.has(E)&&$(`set the ${E} header itself; the host adds its own credentials, and a plugin never sends any`),p[E]=String(O)}let a=R(h.url,"asked the connection for");for(let m=0;;m+=1){u+=1,u>n.requests&&$(`made more than ${n.requests} requests in one fetch`);let O={...p};for(let[C,T]of Object.entries(await e.authorize(a)))O[C.toLowerCase()]=String(T);l&&k();let E=new AbortController;g.add(E);let I=setTimeout(()=>E.abort(),n.requestMs),U;try{U=await r(a,{method:o,headers:O,redirect:"manual",signal:E.signal,...d!==void 0?{body:d}:{}})}catch(C){throw g.delete(E),clearTimeout(I),l&&k(),E.signal.aborted?new Error(`${a.origin} did not answer plugin ${t}'s request within ${n.requestMs/1e3} seconds`):new Error(`plugin ${t}'s request to ${a.origin} failed: ${C instanceof Error?C.message:String(C)}`)}try{let C=U.status>=300&&U.status<400?U.headers.get("location"):null;if(C!==null){await U.body?.cancel().catch(()=>{}),m>=n.redirects&&$(`was redirected more than ${n.redirects} times from ${h.url}`),a=R(new URL(C,a).href,"was redirected to"),(U.status===303||(U.status===301||U.status===302)&&o==="POST")&&(o="GET",d=void 0,delete p["content-type"],delete p["content-length"]);continue}let T=await Je(U,n.bodyBytes,a.href,M=>x("PLUGIN_CONTENT_TOO_LARGE",M)),H={};return U.headers.forEach((M,S)=>{He.has(S.toLowerCase())||(H[S.toLowerCase()]=M)}),{status:U.status,headers:H,body:T}}catch(C){throw l&&!(C instanceof L)&&k(),E.signal.aborted?new Error(`${a.origin} did not finish answering plugin ${t}'s request within ${n.requestMs/1e3} seconds`):C}finally{g.delete(E),clearTimeout(I)}}}}}var ee=()=>ue(le()).controllerBaseUrl,Me={explore:e=>[new URL(e).origin]};async function Xe(e){let t=await e.controller();if(t.basic)return{authorization:de(t.basic.username,t.basic.accessKey)};if(t.token)return{authorization:`Bearer ${t.token}`};throw new Error("no credentials for the controller: run `kane-cli login`, then try again")}var Ge="run `kane-cli login`, then run the command again";function qe(e,t){let n=null;return{get breach(){return t.breach??n},close:()=>t.close(),request:async r=>{if(n!==null)throw n;let i=await t.request(r);return i.status===401&&n===null&&(n=new L({code:"PLUGIN_REFUSED",message:`${new URL(r.url).origin} refused the credential this run holds (${i.status}) when plugin ${e} fetched`,plugin:e,hook:"fetch",remedy:Ge})),i}}}function Ve(e,t={}){let n=t.origins??Me;if(!Object.hasOwn(n,e))return;let r=n[e],i=t.credentials??pe;return qe(e,xe({plugin:e,allow:r((t.controller??ee)()),authorize:()=>Xe(i),...t.fetchImpl?{fetchImpl:t.fetchImpl}:{}}))}var we=e=>Ve(e);import{createHash as ze}from"crypto";var re="exploration-export/1",F="exploration-export/2",We=new Set([re,F]),ye="/exploration/{id}/assurance",W="explore",te=/^[0-9a-f]{8}-[0-9a-f]{4}-[47][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;function $e(e){let t=`${W}://`;if(!e.startsWith(t))return{ok:!1,why:`it does not start with ${t}`};let n=e.slice(t.length),r=n.indexOf("?"),i=r===-1?n:n.slice(0,r);if(!te.test(i))return{ok:!1,why:`${JSON.stringify(i)} is not an exploration id: a lowercase UUID, as kane-cli explore prints it`};if(r===-1)return{ok:!0,value:{exploration:i}};let s={exploration:i};for(let u of n.slice(r+1).split("&")){let c=/^(run|cut)=(.*)$/.exec(u);if(c===null)return{ok:!1,why:`after "?" only run=<run id> and cut=<N>|end may come; found ${JSON.stringify(u)}`};let[,l,g]=c;if(s[l]!==void 0)return{ok:!1,why:`${l} is given twice`};if(l==="run"){if(!te.test(g))return{ok:!1,why:`${JSON.stringify(g)} is not a run id: a lowercase UUID`};s.run=g}else if(g==="end")s.cut="end";else if(/^(0|[1-9]\d{0,8})$/.test(g))s.cut=Number(g);else return{ok:!1,why:`${JSON.stringify(g)} is not a cut: a whole number or end`}}return{ok:!0,value:s}}var me=e=>`explore-${e.exploration}`,Ee=e=>`${W}://${e.exploration}`,Be={junction:"junctions",control:"controls",flow:"flows",finding:"findings"},ne=/^[A-Za-z0-9][A-Za-z0-9._:/#-]{0,127}$/,y=e=>{throw new w(`the exploration export cannot be read: ${e}`,"the explorer answered an export this build does not understand; update kane-cli, or report it to the explorer's team")};function oe(e){if(typeof e!="string"||!We.has(e))throw new w(`exploration export version ${JSON.stringify(e)} is not supported by this build \u2014 update kane-cli`,"update kane-cli, then ingest it again")}var P=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),D=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0,Ke=(e,t)=>e.id<t.id?-1:e.id>t.id?1:0;function z(e,t){let n=Be[e];Array.isArray(t)||y(`${n} is not a list`);let r=new Set;return t.map((i,s)=>{P(i)||y(`${n}[${s}] is not an object`);let u=i;(typeof u.id!="string"||!ne.test(u.id))&&y(`${n}[${s}] has no id the explorer gives a ${e}`);let c=u.id;return r.has(c)&&y(`${n} names ${c} twice`),r.add(c),(u.fp===void 0||u.fp===null)&&y(`${n}[${s}] (${c}) has no fp, which its fingerprint is made of`),{id:c,fp:u.fp,text:P(u.text)?u.text:{},info:P(u.info)?u.info:{}}}).sort(Ke)}var Ye=new Set(["stopped","completed","paused","failed","cancelled"]),ie="x-export-digest",_e=(e,t)=>t===`sha256:${ze("sha256").update(e).digest("hex")}`;function B(e,t){P(e)||y(`${t} has no cursor`);let n=e;oe(n.export_version),(typeof n.run!="string"||n.run==="")&&y(`${t}'s cursor names no run`),D(n.run_version)||y(`${t}'s cursor has no whole run_version`),D(n.deltas)||y(`${t}'s cursor has no whole deltas`);let r={export_version:n.export_version,run:n.run,run_version:n.run_version,deltas:n.deltas};return r.export_version===F&&(n.cut!=="end"&&!D(n.cut)&&y(`${t}'s cursor has no cut (a whole number or end)`),typeof n.provisional!="boolean"&&y(`${t}'s cursor does not say whether it is provisional`),r.cut=n.cut,r.provisional=n.provisional),r}var se=e=>JSON.stringify(e.export_version===F?[e.export_version,e.run,e.run_version,e.deltas,e.cut??"end",e.provisional===!0]:[e.export_version,e.run,e.run_version,e.deltas]);function ke(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Array.isArray(t)||t.length<4)return null;let[n,r,i,s,u,c]=t;return typeof n!="string"||typeof r!="string"||!D(i)||!D(s)?null:{export_version:n,run:r,run_version:i,deltas:s,...t.length>=6&&(u==="end"||D(u))?{cut:u,provisional:c===!0}:{}}}function be(e){let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{y("it is not JSON")}P(t)||y("it is not a JSON object");let n=t;P(n.cursor)||y("the export has no cursor");let r=n.cursor;return n.cursor={export_version:r.export_version,...r.provisional!==void 0?{provisional:r.provisional}:{}},delete n.run_state,new TextEncoder().encode(JSON.stringify(n))}function Ze(e,t){if(P(e)&&e.run!==void 0)return B(e,t);P(e)||y(`${t} has no cursor`);let n=e;return oe(n.export_version),n.export_version===F&&typeof n.provisional!="boolean"&&y(`${t}'s cursor does not say whether it is provisional`),{export_version:n.export_version,...typeof n.provisional=="boolean"?{provisional:n.provisional}:{}}}function Se(e){return ve(e,B,!0)}function K(e){return ve(e,Ze,!1)}function ve(e,t,n){let r;try{r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{y("it is not JSON")}P(r)||y("it is not a JSON object");let i=r;oe(i.export_version),(typeof i.exploration_id!="string"||!te.test(i.exploration_id))&&y("exploration_id is not a lowercase UUID");let s=t(i.cursor,"the export");if(s.export_version!==i.export_version&&y(`its cursor is of ${s.export_version}, the export of ${String(i.export_version)}`),n&&s.provisional!==!0&&(typeof i.run_state!="string"||!Ye.has(i.run_state))){let x=s.run;throw new w(`the export of exploration ${i.exploration_id} is of ${x!==void 0?`run ${x}`:"a run"}, which has not ended (${JSON.stringify(i.run_state??null)}): the export is read once it ends`,"try again after the run ends; the current version is kept")}let u=x=>typeof i[x]=="string"?i[x]:null,c={junctions:z("junction",i.junctions),controls:z("control",i.controls),flows:z("flow",i.flows),findings:z("finding",i.findings)},l=new Set(Object.values(c).flatMap(x=>x.map($=>$.id))),g=i.redirects??{};P(g)||y("redirects is not an object");let k={};for(let[x,$]of Object.entries(g).sort(([R],[h])=>R<h?-1:R>h?1:0))(!ne.test(x)||typeof $!="string"||!ne.test($))&&y(`the redirect from ${JSON.stringify(x)} is not one explorer id to another`),Object.hasOwn(g,$)&&y(`the redirect from ${x} goes to ${$}, which is itself redirected: a redirect names the unit that took the id over`),l.has(x)&&y(`${x} is both a unit and redirected to ${$}`),l.has($)||y(`${x} is redirected to ${$}, which is not a unit of the export`),k[x]=$;return{export_version:i.export_version,exploration_id:i.exploration_id,project_id:u("project_id"),target_url:u("target_url"),cursor:s,run_state:u("run_state"),skipped:D(i.skipped)?i.skipped:0,...c,redirects:k}}import{createHash as Qe}from"crypto";var b={junction:"junction",control:"control",flow:"flow",retiredFlow:"flow.retired",finding:"finding",alias:"merged"},Re=/^[0-9a-f]{64}$/,j={junction:e=>`j:${e}`,control:e=>`c:${Re.test(e)?e.slice(0,16):e}`,flow:e=>`f:${e}`,finding:e=>`fd:${e}`},Oe=e=>Qe("sha256").update(Q(e),"utf8").digest().subarray(0,16).toString("base64url"),G=(e,t)=>Oe({kind:e,fp:t.fp}),et=(e,t)=>Oe({kind:"alias",survivor:e,fingerprint:t}),v=(e,t=200)=>{let n=(typeof e=="string"?e:Q(e??null)).replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1)}\u2026`:n},N=e=>JSON.stringify(v(e??"")),Y=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),f=(e,t)=>Y(e)?e[t]:void 0,_=e=>typeof e=="string"&&e!==""?e:void 0,ae=e=>typeof e=="string"&&Re.test(e)?e.slice(0,12):v(e),tt=" (in flight at this cut: not citable yet)";function Z(e){let t=o=>e.cursor.provisional===!0&&o.info.settled===!1,n=o=>t(o)?tt:"",r=[],i=[],s=new Map,u=(o,d,p,a,m,O)=>{let E=s.get(o);if(E!==void 0)throw new w(`two units of exploration ${e.exploration_id} have the id ${o} (${E} and ${d}), so neither can be told apart`,"report it to kane's team: the unit id needs more of the explorer's id");s.set(o,d),i.push({id:o,ref:o,kind:p,lines:[a,r.length],fingerprint:m,...O!==void 0?{label:v(O,80)}:{}})},c=new Map;for(let o of["junction","control","flow","finding"])for(let d of e[`${o}s`])c.set(d.id,o);let l=o=>{if(typeof o!="string")return v(o);let d=c.get(e.redirects[o]??o);return d!==void 0?j[d](o):o};r.push(`Exploration ${e.exploration_id}${e.target_url!==null?` of ${v(e.target_url)}`:""}`),r.push(`Project: ${e.project_id??"none"}`),e.skipped>0&&r.push(`Left out by the explorer: ${e.skipped} item(s) whose ids cannot be cited`),r.push("Units: j: a screen, c: a control on it, f: a flow, fd: a finding. Cite the unit's id.");let g=new Map,k=new Set(e.junctions.map(o=>o.id)),x=new Map,$=[];for(let o of e.controls){let d=_(o.info.junction);d!==void 0&&k.has(d)?x.set(d,[...x.get(d)??[],o]):$.push(o)}let R=o=>{let{text:d,fp:p,info:a}=o,m=[_(d.container)?` in ${N(d.container)}`:"",_(f(p,"href_pattern"))?` to ${v(f(p,"href_pattern"))}`:"",a.disabled===!0?" disabled":"",f(p,"gated")===!0?" gated":""].join("");r.push(`${j.control(o.id)} ${v(_(d.role)??f(p,"role")??"control")} ${N(d.name??d.label)}${m}${n(o)}`);let O=G("control",o);g.set(o.id,O),t(o)||u(j.control(o.id),o.id,b.control,r.length,O)};r.push("","## Screens");for(let o of e.junctions){let d=j.junction(o.id),{text:p,fp:a,info:m}=o;r.push("");let O=r.length+1;r.push(`${d} screen ${N(p.name??p.heading??p.url_pattern??o.id)} at ${v(p.url_pattern??f(a,"url_pattern")??"?")}${n(o)}`),_(p.heading)&&p.heading!==p.name&&r.push(` heading: ${N(p.heading)}`);let E=f(a,"signatures");r.push(` kind ${v(f(a,"kind")??"?")}, ${Array.isArray(E)?E.length:0} version(s), current ${ae(m.current_signature??"none")}`);let I=G("junction",o);g.set(o.id,I),t(o)||u(d,o.id,b.junction,O,I,_(p.name));for(let U of x.get(o.id)??[])R(U)}if($.length>0){r.push("","## Controls on no screen of this export");for(let o of $)R(o)}r.push("","## Flows");for(let o of e.flows){let d=j.flow(o.id),{text:p,fp:a,info:m}=o;r.push("");let O=r.length+1,E=f(a,"exit")!==null&&f(a,"exit")!==void 0?l(f(a,"exit")):"(no exit)";r.push(`${d} flow ${N(p.name??o.id)}: ${l(f(a,"entry"))} to ${E}, ${v(m.status??"?")}${n(o)}`),r.push(` steps key: ${ae(f(a,"steps_key")??"none")}`);let I=Array.isArray(p.steps)?p.steps:[];for(let S of I)r.push(` step: ${v(f(S,"kind")??"step")} ${N(f(S,"label")??"")}`);let U=Array.isArray(p.assertions)?p.assertions:[];for(let S of U)r.push(` asserts ${ae(f(S,"id"))}: ${N(f(S,"text")??"")}`);let C=f(a,"assertions");Array.isArray(C)&&C.length!==U.length&&r.push(` assertions: ${C.length}`);let T=f(a,"stateful");(Y(T)||f(a,"state")===!0||_(f(a,"in_state")))&&r.push(` stateful${Y(T)?` ${v([T.type,T.role,T.kind].filter(S=>typeof S=="string").join(" "))}`:""}${f(a,"state")===!0?", sets state":""}${_(f(a,"in_state"))?`, needs ${N(f(a,"in_state"))}`:""}`),_(f(a,"after_flow"))&&r.push(` after: ${l(f(a,"after_flow"))}`);let H=_(f(a,"retired"));H!==void 0&&r.push(` retired: ${v(H)}${_(f(a,"superseded_by"))?`, superseded by ${l(f(a,"superseded_by"))}`:""}`);let M=Array.isArray(m.changes)?m.changes.filter(Y).slice(-3).reverse():[];for(let S of M){let Le=_(S.from_exit)||_(S.to_exit)?`: exit ${_(S.from_exit)?l(S.from_exit):"none"} to ${_(S.to_exit)?l(S.to_exit):"none"}`:"";r.push(` changed in run ${v(S.run_id??"?")}: ${v(S.kind??"a change")}${Le}`)}t(o)||u(d,o.id,H!==void 0?b.retiredFlow:b.flow,O,G("flow",o),_(p.name))}r.push("","## Findings");for(let o of e.findings){let d=j.finding(o.id),{text:p,fp:a,info:m}=o;r.push("");let O=r.length+1,E=(Array.isArray(m.junctions)?m.junctions:[]).map(l).join(", "),I=[_(f(a,"candidate"))?` at ${l(f(a,"candidate"))}`:"",E!==""?` on ${E}`:""].join("");r.push(`${d} finding ${v(f(a,"kind")??"?")}${_(f(a,"category"))?` (${v(f(a,"category"))})`:""}${I}${_(m.severity)?`, ${v(m.severity)}`:""}${n(o)}`),_(p.title)&&r.push(` ${N(p.title)}`),_(p.description)&&r.push(` ${N(p.description)}`),f(a,"blocked_by")!==null&&f(a,"blocked_by")!==void 0&&r.push(` blocked by: ${v(f(a,"blocked_by"))}`),t(o)||u(d,o.id,b.finding,O,G("finding",o),_(p.title))}let h=Object.entries(e.redirects);if(h.length>0){r.push("","## Merged");for(let[o,d]of h){let p=c.get(d),a=e[`${p}s`].find(m=>m.id===d);r.push(`${j[p](o)} merged into ${j[p](d)}${n(a)}`),t(a)||u(j[p](o),o,b.alias,r.length,et(d,g.get(d)??G(p,e[`${p}s`].find(m=>m.id===d))))}}return{text:r.join(`
|
|
2
|
+
import{b as w,c as L,g as fe,j as ge}from"./chunk-GRQKMOKE.js";import{b as pe}from"./chunk-XRJH4UF3.js";import{d as X}from"./chunk-DBMW3VUN.js";import{a as Q}from"./chunk-7V4BQSSV.js";import{a as de}from"./chunk-4QTH7VYE.js";import{a as ue,b as le}from"./chunk-V24LUINK.js";var De={requestMs:3e4,requests:64,redirects:5,bodyBytes:X.contentBytes},Fe=new Set(["authorization","proxy-authorization","cookie","host"]),He=new Set(["set-cookie","set-cookie2","www-authenticate","proxy-authenticate"]);function he(e){try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.origin:null}catch{return null}}async function Je(e,t,n,r){let i=Number(e.headers.get("content-length"));if(Number.isFinite(i)&&i>t&&(await e.body?.cancel().catch(()=>{}),r(`${n} answered with ${i} bytes; a plugin's source may be at most ${t}`)),e.body===null)return new Uint8Array(0);let s=e.body.getReader(),u=[],c=0;for(;;){let{done:k,value:x}=await s.read();if(k)break;c+=x.byteLength,c>t&&(await s.cancel().catch(()=>{}),r(`${n} answered with more than ${t} bytes; a plugin's source may be at most ${t}`)),u.push(x)}let l=new Uint8Array(c),g=0;for(let k of u)l.set(k,g),g+=k.byteLength;return l}function xe(e){let{plugin:t}=e,n={...De,...e.limits},r=e.fetchImpl??fetch,i=new Set(e.allow.map(h=>he(h)).filter(h=>h!==null)),s=[...i].join(", ")||"no origin",u=0,c=null,l=!1,g=new Set,k=()=>{throw new L({code:"PLUGIN_CONNECTION_REFUSED",message:`the connection for plugin ${t} is closed: its fetch has ended`,plugin:t,hook:"fetch"})},x=(h,o)=>{let d=new L({code:h,message:o,plugin:t,hook:"fetch"});throw c??=d,d},$=h=>x("PLUGIN_CONNECTION_REFUSED",`plugin ${t} ${h}`),R=(h,o)=>{let d=he(h);return d===null&&$(`${o} ${JSON.stringify(h)}, which is not an http or https URL`),i.has(d)||$(`${o} ${h}, which is not an origin it may reach \u2014 it may reach ${s}`),new URL(h)};return{get breach(){return c},close(){l=!0;for(let h of g)h.abort();g.clear()},async request(h){l&&k();let o=h.method??"GET",d=o==="POST"?h.body:void 0;o!=="GET"&&o!=="POST"&&$(`asked for a ${JSON.stringify(o)} request; a plugin's connection makes GET and POST requests only`);let p={};for(let[m,O]of Object.entries(h.headers??{})){let E=m.toLowerCase();Fe.has(E)&&$(`set the ${E} header itself; the host adds its own credentials, and a plugin never sends any`),p[E]=String(O)}let a=R(h.url,"asked the connection for");for(let m=0;;m+=1){u+=1,u>n.requests&&$(`made more than ${n.requests} requests in one fetch`);let O={...p};for(let[C,T]of Object.entries(await e.authorize(a)))O[C.toLowerCase()]=String(T);l&&k();let E=new AbortController;g.add(E);let I=setTimeout(()=>E.abort(),n.requestMs),U;try{U=await r(a,{method:o,headers:O,redirect:"manual",signal:E.signal,...d!==void 0?{body:d}:{}})}catch(C){throw g.delete(E),clearTimeout(I),l&&k(),E.signal.aborted?new Error(`${a.origin} did not answer plugin ${t}'s request within ${n.requestMs/1e3} seconds`):new Error(`plugin ${t}'s request to ${a.origin} failed: ${C instanceof Error?C.message:String(C)}`)}try{let C=U.status>=300&&U.status<400?U.headers.get("location"):null;if(C!==null){await U.body?.cancel().catch(()=>{}),m>=n.redirects&&$(`was redirected more than ${n.redirects} times from ${h.url}`),a=R(new URL(C,a).href,"was redirected to"),(U.status===303||(U.status===301||U.status===302)&&o==="POST")&&(o="GET",d=void 0,delete p["content-type"],delete p["content-length"]);continue}let T=await Je(U,n.bodyBytes,a.href,M=>x("PLUGIN_CONTENT_TOO_LARGE",M)),H={};return U.headers.forEach((M,S)=>{He.has(S.toLowerCase())||(H[S.toLowerCase()]=M)}),{status:U.status,headers:H,body:T}}catch(C){throw l&&!(C instanceof L)&&k(),E.signal.aborted?new Error(`${a.origin} did not finish answering plugin ${t}'s request within ${n.requestMs/1e3} seconds`):C}finally{g.delete(E),clearTimeout(I)}}}}}var ee=()=>ue(le()).controllerBaseUrl,Me={explore:e=>[new URL(e).origin]};async function Xe(e){let t=await e.controller();if(t.basic)return{authorization:de(t.basic.username,t.basic.accessKey)};if(t.token)return{authorization:`Bearer ${t.token}`};throw new Error("no credentials for the controller: run `kane-cli login`, then try again")}var Ge="run `kane-cli login`, then run the command again";function qe(e,t){let n=null;return{get breach(){return t.breach??n},close:()=>t.close(),request:async r=>{if(n!==null)throw n;let i=await t.request(r);return i.status===401&&n===null&&(n=new L({code:"PLUGIN_REFUSED",message:`${new URL(r.url).origin} refused the credential this run holds (${i.status}) when plugin ${e} fetched`,plugin:e,hook:"fetch",remedy:Ge})),i}}}function Ve(e,t={}){let n=t.origins??Me;if(!Object.hasOwn(n,e))return;let r=n[e],i=t.credentials??pe;return qe(e,xe({plugin:e,allow:r((t.controller??ee)()),authorize:()=>Xe(i),...t.fetchImpl?{fetchImpl:t.fetchImpl}:{}}))}var we=e=>Ve(e);import{createHash as ze}from"crypto";var re="exploration-export/1",F="exploration-export/2",We=new Set([re,F]),ye="/exploration/{id}/assurance",W="explore",te=/^[0-9a-f]{8}-[0-9a-f]{4}-[47][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;function $e(e){let t=`${W}://`;if(!e.startsWith(t))return{ok:!1,why:`it does not start with ${t}`};let n=e.slice(t.length),r=n.indexOf("?"),i=r===-1?n:n.slice(0,r);if(!te.test(i))return{ok:!1,why:`${JSON.stringify(i)} is not an exploration id: a lowercase UUID, as kane-cli explore prints it`};if(r===-1)return{ok:!0,value:{exploration:i}};let s={exploration:i};for(let u of n.slice(r+1).split("&")){let c=/^(run|cut)=(.*)$/.exec(u);if(c===null)return{ok:!1,why:`after "?" only run=<run id> and cut=<N>|end may come; found ${JSON.stringify(u)}`};let[,l,g]=c;if(s[l]!==void 0)return{ok:!1,why:`${l} is given twice`};if(l==="run"){if(!te.test(g))return{ok:!1,why:`${JSON.stringify(g)} is not a run id: a lowercase UUID`};s.run=g}else if(g==="end")s.cut="end";else if(/^(0|[1-9]\d{0,8})$/.test(g))s.cut=Number(g);else return{ok:!1,why:`${JSON.stringify(g)} is not a cut: a whole number or end`}}return{ok:!0,value:s}}var me=e=>`explore-${e.exploration}`,Ee=e=>`${W}://${e.exploration}`,Be={junction:"junctions",control:"controls",flow:"flows",finding:"findings"},ne=/^[A-Za-z0-9][A-Za-z0-9._:/#-]{0,127}$/,y=e=>{throw new w(`the exploration export cannot be read: ${e}`,"the explorer answered an export this build does not understand; update kane-cli, or report it to the explorer's team")};function oe(e){if(typeof e!="string"||!We.has(e))throw new w(`exploration export version ${JSON.stringify(e)} is not supported by this build \u2014 update kane-cli`,"update kane-cli, then ingest it again")}var P=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),D=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0,Ke=(e,t)=>e.id<t.id?-1:e.id>t.id?1:0;function z(e,t){let n=Be[e];Array.isArray(t)||y(`${n} is not a list`);let r=new Set;return t.map((i,s)=>{P(i)||y(`${n}[${s}] is not an object`);let u=i;(typeof u.id!="string"||!ne.test(u.id))&&y(`${n}[${s}] has no id the explorer gives a ${e}`);let c=u.id;return r.has(c)&&y(`${n} names ${c} twice`),r.add(c),(u.fp===void 0||u.fp===null)&&y(`${n}[${s}] (${c}) has no fp, which its fingerprint is made of`),{id:c,fp:u.fp,text:P(u.text)?u.text:{},info:P(u.info)?u.info:{}}}).sort(Ke)}var Ye=new Set(["stopped","completed","paused","failed","cancelled"]),ie="x-export-digest",_e=(e,t)=>t===`sha256:${ze("sha256").update(e).digest("hex")}`;function B(e,t){P(e)||y(`${t} has no cursor`);let n=e;oe(n.export_version),(typeof n.run!="string"||n.run==="")&&y(`${t}'s cursor names no run`),D(n.run_version)||y(`${t}'s cursor has no whole run_version`),D(n.deltas)||y(`${t}'s cursor has no whole deltas`);let r={export_version:n.export_version,run:n.run,run_version:n.run_version,deltas:n.deltas};return r.export_version===F&&(n.cut!=="end"&&!D(n.cut)&&y(`${t}'s cursor has no cut (a whole number or end)`),typeof n.provisional!="boolean"&&y(`${t}'s cursor does not say whether it is provisional`),r.cut=n.cut,r.provisional=n.provisional),r}var se=e=>JSON.stringify(e.export_version===F?[e.export_version,e.run,e.run_version,e.deltas,e.cut??"end",e.provisional===!0]:[e.export_version,e.run,e.run_version,e.deltas]);function ke(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Array.isArray(t)||t.length<4)return null;let[n,r,i,s,u,c]=t;return typeof n!="string"||typeof r!="string"||!D(i)||!D(s)?null:{export_version:n,run:r,run_version:i,deltas:s,...t.length>=6&&(u==="end"||D(u))?{cut:u,provisional:c===!0}:{}}}function be(e){let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{y("it is not JSON")}P(t)||y("it is not a JSON object");let n=t;P(n.cursor)||y("the export has no cursor");let r=n.cursor;return n.cursor={export_version:r.export_version,...r.provisional!==void 0?{provisional:r.provisional}:{}},delete n.run_state,new TextEncoder().encode(JSON.stringify(n))}function Ze(e,t){if(P(e)&&e.run!==void 0)return B(e,t);P(e)||y(`${t} has no cursor`);let n=e;return oe(n.export_version),n.export_version===F&&typeof n.provisional!="boolean"&&y(`${t}'s cursor does not say whether it is provisional`),{export_version:n.export_version,...typeof n.provisional=="boolean"?{provisional:n.provisional}:{}}}function Se(e){return ve(e,B,!0)}function K(e){return ve(e,Ze,!1)}function ve(e,t,n){let r;try{r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{y("it is not JSON")}P(r)||y("it is not a JSON object");let i=r;oe(i.export_version),(typeof i.exploration_id!="string"||!te.test(i.exploration_id))&&y("exploration_id is not a lowercase UUID");let s=t(i.cursor,"the export");if(s.export_version!==i.export_version&&y(`its cursor is of ${s.export_version}, the export of ${String(i.export_version)}`),n&&s.provisional!==!0&&(typeof i.run_state!="string"||!Ye.has(i.run_state))){let x=s.run;throw new w(`the export of exploration ${i.exploration_id} is of ${x!==void 0?`run ${x}`:"a run"}, which has not ended (${JSON.stringify(i.run_state??null)}): the export is read once it ends`,"try again after the run ends; the current version is kept")}let u=x=>typeof i[x]=="string"?i[x]:null,c={junctions:z("junction",i.junctions),controls:z("control",i.controls),flows:z("flow",i.flows),findings:z("finding",i.findings)},l=new Set(Object.values(c).flatMap(x=>x.map($=>$.id))),g=i.redirects??{};P(g)||y("redirects is not an object");let k={};for(let[x,$]of Object.entries(g).sort(([R],[h])=>R<h?-1:R>h?1:0))(!ne.test(x)||typeof $!="string"||!ne.test($))&&y(`the redirect from ${JSON.stringify(x)} is not one explorer id to another`),Object.hasOwn(g,$)&&y(`the redirect from ${x} goes to ${$}, which is itself redirected: a redirect names the unit that took the id over`),l.has(x)&&y(`${x} is both a unit and redirected to ${$}`),l.has($)||y(`${x} is redirected to ${$}, which is not a unit of the export`),k[x]=$;return{export_version:i.export_version,exploration_id:i.exploration_id,project_id:u("project_id"),target_url:u("target_url"),cursor:s,run_state:u("run_state"),skipped:D(i.skipped)?i.skipped:0,...c,redirects:k}}import{createHash as Qe}from"crypto";var b={junction:"junction",control:"control",flow:"flow",retiredFlow:"flow.retired",finding:"finding",alias:"merged"},Re=/^[0-9a-f]{64}$/,j={junction:e=>`j:${e}`,control:e=>`c:${Re.test(e)?e.slice(0,16):e}`,flow:e=>`f:${e}`,finding:e=>`fd:${e}`},Oe=e=>Qe("sha256").update(Q(e),"utf8").digest().subarray(0,16).toString("base64url"),G=(e,t)=>Oe({kind:e,fp:t.fp}),et=(e,t)=>Oe({kind:"alias",survivor:e,fingerprint:t}),v=(e,t=200)=>{let n=(typeof e=="string"?e:Q(e??null)).replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1)}\u2026`:n},N=e=>JSON.stringify(v(e??"")),Y=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),f=(e,t)=>Y(e)?e[t]:void 0,_=e=>typeof e=="string"&&e!==""?e:void 0,ae=e=>typeof e=="string"&&Re.test(e)?e.slice(0,12):v(e),tt=" (in flight at this cut: not citable yet)";function Z(e){let t=o=>e.cursor.provisional===!0&&o.info.settled===!1,n=o=>t(o)?tt:"",r=[],i=[],s=new Map,u=(o,d,p,a,m,O)=>{let E=s.get(o);if(E!==void 0)throw new w(`two units of exploration ${e.exploration_id} have the id ${o} (${E} and ${d}), so neither can be told apart`,"report it to kane's team: the unit id needs more of the explorer's id");s.set(o,d),i.push({id:o,ref:o,kind:p,lines:[a,r.length],fingerprint:m,...O!==void 0?{label:v(O,80)}:{}})},c=new Map;for(let o of["junction","control","flow","finding"])for(let d of e[`${o}s`])c.set(d.id,o);let l=o=>{if(typeof o!="string")return v(o);let d=c.get(e.redirects[o]??o);return d!==void 0?j[d](o):o};r.push(`Exploration ${e.exploration_id}${e.target_url!==null?` of ${v(e.target_url)}`:""}`),r.push(`Project: ${e.project_id??"none"}`),e.skipped>0&&r.push(`Left out by the explorer: ${e.skipped} item(s) whose ids cannot be cited`),r.push("Units: j: a screen, c: a control on it, f: a flow, fd: a finding. Cite the unit's id.");let g=new Map,k=new Set(e.junctions.map(o=>o.id)),x=new Map,$=[];for(let o of e.controls){let d=_(o.info.junction);d!==void 0&&k.has(d)?x.set(d,[...x.get(d)??[],o]):$.push(o)}let R=o=>{let{text:d,fp:p,info:a}=o,m=[_(d.container)?` in ${N(d.container)}`:"",_(f(p,"href_pattern"))?` to ${v(f(p,"href_pattern"))}`:"",a.disabled===!0?" disabled":"",f(p,"gated")===!0?" gated":""].join("");r.push(`${j.control(o.id)} ${v(_(d.role)??f(p,"role")??"control")} ${N(d.name??d.label)}${m}${n(o)}`);let O=G("control",o);g.set(o.id,O),t(o)||u(j.control(o.id),o.id,b.control,r.length,O)};r.push("","## Screens");for(let o of e.junctions){let d=j.junction(o.id),{text:p,fp:a,info:m}=o;r.push("");let O=r.length+1;r.push(`${d} screen ${N(p.name??p.heading??p.url_pattern??o.id)} at ${v(p.url_pattern??f(a,"url_pattern")??"?")}${n(o)}`),_(p.heading)&&p.heading!==p.name&&r.push(` heading: ${N(p.heading)}`);let E=f(a,"signatures");r.push(` kind ${v(f(a,"kind")??"?")}, ${Array.isArray(E)?E.length:0} version(s), current ${ae(m.current_signature??"none")}`);let I=G("junction",o);g.set(o.id,I),t(o)||u(d,o.id,b.junction,O,I,_(p.name));for(let U of x.get(o.id)??[])R(U)}if($.length>0){r.push("","## Controls on no screen of this export");for(let o of $)R(o)}r.push("","## Flows");for(let o of e.flows){let d=j.flow(o.id),{text:p,fp:a,info:m}=o;r.push("");let O=r.length+1,E=f(a,"exit")!==null&&f(a,"exit")!==void 0?l(f(a,"exit")):"(no exit)";r.push(`${d} flow ${N(p.name??o.id)}: ${l(f(a,"entry"))} to ${E}, ${v(m.status??"?")}${n(o)}`),r.push(` steps key: ${ae(f(a,"steps_key")??"none")}`);let I=Array.isArray(p.steps)?p.steps:[];for(let S of I)r.push(` step: ${v(f(S,"kind")??"step")} ${N(f(S,"label")??"")}`);let U=Array.isArray(p.assertions)?p.assertions:[];for(let S of U)r.push(` asserts ${ae(f(S,"id"))}: ${N(f(S,"text")??"")}`);let C=f(a,"assertions");Array.isArray(C)&&C.length!==U.length&&r.push(` assertions: ${C.length}`);let T=f(a,"stateful");(Y(T)||f(a,"state")===!0||_(f(a,"in_state")))&&r.push(` stateful${Y(T)?` ${v([T.type,T.role,T.kind].filter(S=>typeof S=="string").join(" "))}`:""}${f(a,"state")===!0?", sets state":""}${_(f(a,"in_state"))?`, needs ${N(f(a,"in_state"))}`:""}`),_(f(a,"after_flow"))&&r.push(` after: ${l(f(a,"after_flow"))}`);let H=_(f(a,"retired"));H!==void 0&&r.push(` retired: ${v(H)}${_(f(a,"superseded_by"))?`, superseded by ${l(f(a,"superseded_by"))}`:""}`);let M=Array.isArray(m.changes)?m.changes.filter(Y).slice(-3).reverse():[];for(let S of M){let Le=_(S.from_exit)||_(S.to_exit)?`: exit ${_(S.from_exit)?l(S.from_exit):"none"} to ${_(S.to_exit)?l(S.to_exit):"none"}`:"";r.push(` changed in run ${v(S.run_id??"?")}: ${v(S.kind??"a change")}${Le}`)}t(o)||u(d,o.id,H!==void 0?b.retiredFlow:b.flow,O,G("flow",o),_(p.name))}r.push("","## Findings");for(let o of e.findings){let d=j.finding(o.id),{text:p,fp:a,info:m}=o;r.push("");let O=r.length+1,E=(Array.isArray(m.junctions)?m.junctions:[]).map(l).join(", "),I=[_(f(a,"candidate"))?` at ${l(f(a,"candidate"))}`:"",E!==""?` on ${E}`:""].join("");r.push(`${d} finding ${v(f(a,"kind")??"?")}${_(f(a,"category"))?` (${v(f(a,"category"))})`:""}${I}${_(m.severity)?`, ${v(m.severity)}`:""}${n(o)}`),_(p.title)&&r.push(` ${N(p.title)}`),_(p.description)&&r.push(` ${N(p.description)}`),f(a,"blocked_by")!==null&&f(a,"blocked_by")!==void 0&&r.push(` blocked by: ${v(f(a,"blocked_by"))}`),t(o)||u(d,o.id,b.finding,O,G("finding",o),_(p.title))}let h=Object.entries(e.redirects);if(h.length>0){r.push("","## Merged");for(let[o,d]of h){let p=c.get(d),a=e[`${p}s`].find(m=>m.id===d);r.push(`${j[p](o)} merged into ${j[p](d)}${n(a)}`),t(a)||u(j[p](o),o,b.alias,r.length,et(d,g.get(d)??G(p,e[`${p}s`].find(m=>m.id===d))))}}return{text:r.join(`
|
|
3
3
|
`)+`
|
|
4
4
|
`,units:i}}var nt="explore",rt="exploration-export/1";function Ue(e,t,n){let r=ye.replace("{id}",t.exploration);return`${e.replace(/\/+$/,"")}${r}/${n}?cut=${t.cut??"end"}${t.run!==void 0?`&run=${t.run}`:""}`}function ot(e,t){let n=e.headers[ie];if(n===void 0)throw new w(`the export of exploration ${t.exploration} came with no digest (the ${ie} header)`,V);if(!_e(e.body,n))throw new w(`the export of exploration ${t.exploration} is not the bytes its digest names: it was changed on the way, or not served whole`,V);let r=Se(e.body);if(r.exploration_id!==t.exploration)throw new w(`the explorer answered the export of exploration ${r.exploration_id} when asked for ${t.exploration}`,"report it to the explorer's team");if(t.run!==void 0&&r.cursor.run!==t.run)throw new w(`the explorer answered the export as of run ${r.cursor.run} when asked for run ${t.run}`,"report it to the explorer's team");if(r.export_version!==F)throw new w(`the explorer answered ${r.export_version} when asked for a cut (export/2)`,"report it to the explorer's team");if((r.cursor.cut??"end")!==(t.cut??"end"))throw new w(`the explorer answered ${r.cursor.cut==="end"?"the end":`cut ${String(r.cursor.cut)}`} when asked for ${ce(t)}`,"report it to the explorer's team");return Z(r),r}var ce=e=>e.cut===void 0||e.cut==="end"?e.run!==void 0?`the end of run ${e.run}`:"its latest ended run":`cut ${e.cut}${e.run!==void 0?` of run ${e.run}`:""}`,Ce=e=>{let t=$e(e);if(!t.ok)throw new w(`${e} is not an exploration reference: ${t.why}`,"name it as explore://<exploration id>, with ?run=<run id> and/or cut=<N>|end to read one cut");return t.value},V="try again later; the current version is kept";function it(e){try{let t=JSON.parse(new TextDecoder().decode(e));return typeof t=="object"&&t!==null?t:{}}catch{return{}}}function Pe(e,t,n,r){let i=`exploration ${n.exploration}${n.run!==void 0?` at run ${n.run}`:""}`,s=it(t);throw e===409&&s.code==="CUT_SUPERSEDED"?new w(`${ce(n)} of exploration ${n.exploration} is superseded (CUT_SUPERSEDED): a later run's cuts are served now`,"nothing to do: a later cut covers it"):e===404&&s.code==="CUT_NOT_FOUND"?new w(`${ce(n)} of exploration ${n.exploration} was never taken (CUT_NOT_FOUND)`,"name a cut the controller took (a checkpoint or a sync), or cut=end"):e===409&&s.code==="RUN_ACTIVE"?new w(`a run of exploration ${n.exploration} is in progress${typeof s.active_run=="string"?` (run ${s.active_run})`:""}: the export is read once it ends`,"try again after the run ends; the current version is kept"):e===409&&s.code==="EXPLORATION_OUTDATED"?new w(`${i} can no longer be read (OUTDATED): re-explore`,"explore the site again, then ingest the new exploration"):e===404&&s.code==="NO_ENDED_RUN"?new w(`exploration ${n.exploration} has no ended run yet: the export is read once its first run ends`,"try again after the first run ends"):e===404?new w(`${i} was not found (404): the explorer has no such exploration${n.run!==void 0?" or run":""}, or it is not one of your organisation's`,"check the id, and that kane-cli is signed in to the controller the exploration ran on"):e===401||e===403?new w(`the controller refused kane-cli's credentials (${e}) for ${i}`,"sign in again with kane-cli login, then try again"):e===400?new w(`the explorer refused the request for the ${r} of ${i} (400)${typeof s.error=="string"?`: ${s.error.slice(0,200)}`:""}`,"report it to kane's team"):new w(`the explorer answered ${e} for the ${r} of ${i}`,V)}async function Ne(e,t,n){try{return await e.connection.request({url:t,headers:{accept:"application/json"}})}catch(r){throw r instanceof L?r:new w(`exploration ${n.exploration} could not be read: ${r instanceof Error?r.message:String(r)}`,V)}}function Te(e){return{manifest:{contract:1,id:nt,version:"0.1.0",rules:rt,capabilities:["remote","explain","context","coverage","cites-deep"],claims:{schemes:[W]}},claim(t){if(t.isFile)return null;let n=Ce(t.ref),r=Ee(n);return{sourceId:me(n),label:`Exploration ${n.exploration}`,...r!==t.ref?{recorded:r}:{}}},async fetch(t){let n=Ce(t.ref);if(t.cursor!==null){let s=await Ne(t,Ue(e.controller,n,"head"),n);s.status!==200&&Pe(s.status,s.body,n,"head");let u;try{u=JSON.parse(new TextDecoder().decode(s.body))}catch{throw new w(`the head of exploration ${n.exploration} is not JSON`,V)}let c=B(u?.cursor,"the head");if(n.run!==void 0&&c.run!==n.run)throw new w(`the explorer answered the head as of run ${c.run} when asked for run ${n.run}`,"report it to the explorer's team");if(se(c)===t.cursor)return{kind:"unchanged"};let l=ke(t.cursor);if(l!==null&&l.export_version===re&&c.export_version===F&&l.run_version===c.run_version&&l.deltas===c.deltas)return{kind:"unchanged"}}let r=await Ne(t,Ue(e.controller,n,"export"),n);r.status!==200&&Pe(r.status,r.body,n,"export");let i=ot(r,n);return{kind:"content",bytes:be(r.body),cursor:se(i.cursor)}},render(t){return{text:Z(K(t.bytes)).text}},index(t){return Z(K(t.bytes)).units},explain:at,context:ct,coverage:ut}}var Ie=e=>e.replace(/\n$/,"").split(`
|
|
5
5
|
`).slice(1).map(t=>t.trim()),A=e=>e.split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as s}from"./chunk-HCBYKLMW.js";import{
|
|
2
|
+
import{a as s}from"./chunk-HCBYKLMW.js";import{A as i}from"./chunk-BRWCWZE3.js";import{a as m,b as o}from"./chunk-33DWJV67.js";import{e as x}from"./chunk-UR6MHSHU.js";var t=x(s(),1);function d({label:r,text:c,accent:a,color:n,width:l=15}){return(0,t.jsxs)(o,{children:[(0,t.jsx)(o,{color:i.dim,children:` ${r.padEnd(l)}`}),(0,t.jsx)(o,{color:n??(a?i.assuranceAccent:void 0),children:c})]})}function u({head:r,rows:c,minWidth:a=15}){let n=c.filter(e=>e.text),l=Math.max(a,...n.map(e=>e.label.length+2));return(0,t.jsxs)(m,{flexDirection:"column",children:[r?(0,t.jsx)(o,{bold:!0,children:r}):null,n.map((e,p)=>(0,t.jsx)(d,{label:e.label,text:e.text,color:e.color,width:l},p))]})}export{d as a,u as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-5Y2G4NC7.js";import{a as n}from"./chunk-HCBYKLMW.js";import{
|
|
2
|
+
import{a}from"./chunk-5Y2G4NC7.js";import{a as n}from"./chunk-HCBYKLMW.js";import{A as t}from"./chunk-BRWCWZE3.js";import{b as o}from"./chunk-33DWJV67.js";import{a as s}from"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var l=r(s(),1);var m=r(n(),1),i=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function b({active:e=!0}){let[p,c]=(0,l.useState)(0);return a(()=>{c(f=>(f+1)%i.length)},e?80:null),(0,m.jsx)(o,{color:t.orange,children:e?i[p]:"\u25CF"})}export{b as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as l}from"./chunk-
|
|
2
|
+
import{b as l}from"./chunk-R6S4EJ5R.js";import{a as m}from"./chunk-V24LUINK.js";import{a as p}from"./chunk-JYH7CTF7.js";import{a as c,b as s,h as a,z as u}from"./chunk-BRWCWZE3.js";import{a as f}from"./chunk-RZ4F3BHX.js";var v="/public/skills/kane-cli";function C(){try{let n=new p().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await f(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{q as i,r as u}from"./chunk-WMXBRC4B.js";async function d(e){if(!e.isInteractive)return{recovered:!1};if(f(e.creds,e.authOnly===!0))return{recovered:!1};let{SingleShotApp:a}=await import("./SingleShotApp-
|
|
2
|
+
import{q as i,r as u}from"./chunk-WMXBRC4B.js";async function d(e){if(!e.isInteractive)return{recovered:!1};if(f(e.creds,e.authOnly===!0))return{recovered:!1};let{SingleShotApp:a}=await import("./SingleShotApp-MN5IE6EU.js"),{ScrollbackProvider:t}=await import("./scrollback-GGNBDFQV.js"),{render:r}=await import("./build-5ZN47FAT.js"),o=await import("./react-QWOAB3TB.js"),n={current:null},l={current:!1},{waitUntilExit:c,unmount:s}=r(o.default.createElement(t,null,o.default.createElement(a,{resultRef:n,mode:"login",loginCompleteRef:l,...e.authOnly?{authOnly:!0}:{}})),{exitOnCtrlC:!1});u(()=>s()),await c();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),l.current?{recovered:!0}:e.onCancel==="return"?{recovered:!1,cancelled:!0}:(i(0,"Startup gate cancelled"),{recovered:!1})}function f(e,a=!1){let t=e.getActiveProfile(),r=e.getDefaultEnv();if(!t||!!!(e.loadBasicAuth(t,r)||e.loadCredentials(t,r)))return!1;if(a)return!0;let n=e.loadProfileConfig(t,r)??{};return!!n.project_id&&!!n.folder_id}export{d as a,f as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as ae}from"./chunk-MMBBQ4OZ.js";import{j as R}from"./chunk-
|
|
2
|
+
import{a as ae}from"./chunk-MMBBQ4OZ.js";import{j as R}from"./chunk-VKIUHHNT.js";import{c as ne,e as re,i as se,j as K}from"./chunk-Z7S3IWUX.js";import{d as $,e as oe}from"./chunk-4JOD47QI.js";import{a as ie}from"./chunk-RZ4F3BHX.js";import{spawn as ze}from"child_process";import{closeSync as Xe,existsSync as Ge,mkdirSync as We,openSync as Ye,readFileSync as Ze,rmSync as Qe}from"fs";import{homedir as ge}from"os";import{dirname as X,join as S}from"path";import{access as Re,mkdir as de,readFile as Le}from"fs/promises";import{homedir as Ce}from"os";import{arch as Fe,platform as Be}from"process";import{join as M}from"path";var Ue=35,qe="google_apis",Ve="KaneCLI_Pixel_API35",He="KaneAI_Pixel_API35";function Ht(t){return t===He?Ve:t}var je=1;function Ke(t,e){return t==="darwin"&&e==="arm64"?"arm64-v8a":"x86_64"}function Je(){return{home:Ce(),os:Be,arch:Fe}}async function le(t){try{return await Re(t),!0}catch{return!1}}var J=class{deps;constructor(e={}){this.deps={...Je(),...e}}paths(){let e=M(this.deps.home,".testmuai","kaneai","mobile"),r=M(e,"android-sdk");return{root:r,emulatorDir:M(r,"emulator"),systemImageDir:M(r,"system-images",`android-${Ue}`,qe,Ke(this.deps.os,this.deps.arch)),avdHome:M(e,"avd"),manifest:M(r,"sdk-manifest.json")}}environment(){let e=this.paths();return{ANDROID_HOME:e.root,ANDROID_SDK_ROOT:e.root,ANDROID_AVD_HOME:e.avdHome}}async ensureSdkRootMarkers(){let e=this.paths().root;await de(M(e,"platforms"),{recursive:!0}),await de(M(e,"platform-tools"),{recursive:!0})}async status(){let e=this.paths(),r=null;try{r=JSON.parse(await Le(e.manifest,"utf8"))}catch{}if(!r||r.schemaVersion!==je)return{emulator:!1,systemImage:!1};let o=this.deps.os==="win32"?"emulator.exe":"emulator";return{emulator:!!r.components.emulator&&await le(M(e.emulatorDir,o)),systemImage:!!r.components.systemImage&&await le(M(e.systemImageDir,"system.img"))}}},ue;function B(){return ue??=new J,ue}var G="android",et="http://127.0.0.1:4723/status",tt=2e3,z=(()=>{let t=Number(process.env.KANE_CLI_EMULATOR_BOOT_TIMEOUT_MS);return Number.isFinite(t)&&t>=3e4?t:3e5})(),it=1e3,nt=3e5;var rt=5,ce="Run `kane-cli doctor --target emulator --install` to install the managed Appium tree.",st={device:"ready",unauthorized:"unauthorized",offline:"offline"};function ot(t){let e={};for(let r of t){let o=r.indexOf(":");o<=0||(e[r.slice(0,o)]=r.slice(o+1))}return e}function at(t){let e=[];for(let r of t.split(`
|
|
3
3
|
`)){let o=r.trim();if(!o||o.startsWith("*"))continue;let u=o.toLowerCase();if(u.startsWith("list of devices")||u.startsWith("adb server"))continue;let g=o.split(/\s+/),p=g[0],w=g[1];if(!p||!w)continue;let v=ot(g.slice(2)),x=/^(localhost|127\.0\.0\.1):\d{1,5}$/.test(p),P=/^[A-Za-z0-9._-]+:\d{1,5}$/.test(p),C=/^sdk_/.test(v.product??"")||/^sdk_/.test(v.model??"")||/^emu/.test(v.device??"");if(!p.startsWith("emulator-")&&!x&&!(P&&C))continue;let l=v.model?v.model.replace(/_/g," "):void 0;e.push({platform:G,kind:"emulator",id:p,displayName:l??p,state:st[w]??"offline"})}return e}function me(t){let e=[];for(let r of t.split(`
|
|
4
4
|
`)){let o=r.trim();o&&/^[A-Za-z0-9._-]+$/.test(o)&&(e.includes(o)||e.push(o))}return e}function dt(t){for(let e of t.split(`
|
|
5
5
|
`)){let r=e.trim();if(!(!r||r==="OK"))return r}}function lt(t){let e=/^Version\s+(\S+)/m.exec(t);return e?.[1]?e[1].split("-")[0]:/Android Debug Bridge version\s+(\S+)/.exec(t)?.[1]}function ut(t){let e=[];for(let r of t.split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as s,b as o,e as c}from"./chunk-
|
|
2
|
+
import{a as s,b as o,e as c}from"./chunk-BRWCWZE3.js";import{a as l}from"./chunk-RZ4F3BHX.js";import{readFileSync as f,writeFileSync as d,mkdirSync as g,realpathSync as h}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function N(){try{let t=process.argv[1];if(t&&h(t).includes("/Cellar/"))return b}catch{}return C}var m=y(o,"version-check.json"),w=1440*60*1e3;function A(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<w)return t}catch{}return null}function k(t){try{g(o,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);for(let i=0;i<3;i++){let a=(r[i]??0)-(n[i]??0);if(a!==0)return a}return 0}function p(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);return(r[0]??0)!==(n[0]??0)?"major":(r[1]??0)!==(n[1]??0)?"minor":"patch"}async function T(){try{let t=A();if(t)return u(s,t.latest)>0?{current:s,latest:t.latest,severity:p(s,t.latest)}:null;let e=new AbortController,n=setTimeout(()=>e.abort(),5e3),r=await l(c,{headers:{Accept:"application/json"},signal:e.signal});if(clearTimeout(n),!r.ok)return null;let a=(await r.json())["dist-tags"]?.latest;return a?(k(a),u(s,a)>0?{current:s,latest:a,severity:p(s,a)}:null):null}catch{return null}}async function v(t=5e3){let e=new AbortController,n=setTimeout(()=>e.abort(),t);try{let r=await l(c,{headers:{Accept:"application/json"},signal:e.signal});return r.ok?(await r.json())["dist-tags"]?.latest??null:null}catch{return null}finally{clearTimeout(n)}}export{N as a,u as b,p as c,T as d,v as e};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as Ee,b as te}from"./chunk-GFLB2SHW.js";import{a as ee}from"./chunk-2TVPA3LL.js";import{c as G}from"./chunk-22PIMG52.js";import{a as v,b as be,d as B,e as Te}from"./chunk-4C7WVQOD.js";import{na as ve,oa as P}from"./chunk-5EAJO372.js";import{a as M}from"./chunk-QXQ7KVEN.js";import{a as Se}from"./chunk-DXXHCLFC.js";import{d as ye,e as Re,f as Z,h as $e}from"./chunk-IQMJJN52.js";import{a as we}from"./chunk-APXJRWIJ.js";import{a as z}from"./chunk-WTMCDYR3.js";import{e as fe}from"./chunk-WMXBRC4B.js";import{basename as wt,relative as ce}from"path";function Vt(e){return e.scope?.state==="finalized"?"saved":e.scope?.state==="discarded"?"discarded":e.ended==="complete"?"ready_to_save":e.ended==="failed"||e.status==="failed"?"failed":e.status==="paused"||e.status==="needs_attention"?"paused":"running"}var ne=["useCases","criteria","scenarios","tests","openQuestions","sources","styleNotes"],H=new Set(["sources","styleNotes"]);function xe(e){return ne.reduce((t,n)=>t+(H.has(n)?0:e[n]??0),0)}var nt=new Set(["NO_CASE","CASE_BROKEN","TEST_FILE_STALE","CASE_ARCHIVED"]),U=e=>typeof e=="string"?e:null;function st(e){let t=e.extra;switch(e.code){case"CASE_BROKEN":return{code:"CASE_BROKEN",session:U(t.session),caseId:U(t.caseId)??"",reason:t.reason==="moved"?"moved":"deleted"};case"CASE_ARCHIVED":return{code:"CASE_ARCHIVED",caseId:U(t.caseId)??"",internalId:U(t.internalId)??""};default:return{code:e.code,session:U(t.session),useCase:U(t.useCase)}}}function Jt(e){return(Array.isArray(e.nodes)?e.nodes:[]).filter(n=>typeof n.cid=="string"&&typeof n.label=="string").map(n=>({cid:n.cid,label:n.label,content:typeof n.content=="object"&&n.content!==null?n.content:{}}))}function qt(e){return(Array.isArray(e.names)?e.names:[]).filter(n=>typeof n.cid=="string"&&typeof n.slug=="string").map(n=>({cid:n.cid,slug:n.slug}))}function Kt(e){return(Array.isArray(e.supersessions)?e.supersessions:[]).filter(n=>n.kind==="node"&&typeof n.old=="string").map(n=>({old:n.old,new:typeof n.new=="string"?n.new:null}))}function Yt(e){let{request:t,exchange:n}=B(e),o=(s,r)=>`/v1/projects/${encodeURIComponent(s)}/uploads/${r}`,d=s=>`/v1/sessions/${encodeURIComponent(s)}`,a=async(s,r=null)=>{let l=[],g=r;do{let c=await t("GET",`${s}${g===null?"":`&after=${encodeURIComponent(g)}`}`);l.push(...c.items),g=c.next}while(g!==null);return l},i=async(s,r)=>{let l=await t("GET",`/v1/projects/${encodeURIComponent(s)}/sessions/${encodeURIComponent(r)}`),{proposes:g,heldChanges:c,changes:p,approves:u,archives:m,removes:w,chatTurns:h,uncounted:f}=l.drafts;return{proposes:g,heldChanges:c??0,changes:p??{},approves:u??{},archives:m??{},removes:w??{},chatTurns:h??0,uncounted:typeof f=="number"?f:null}};return{async*projects(){for(let s=1;s!==null;){let r=await t("GET",`/v1/projects?page=${s}`);r.items.length>0&&(yield r.items.map(({projectId:l,name:g,marked:c})=>({projectId:l,name:g,marked:c}))),s=r.next}},async project(s){let l=(await t("GET",`/v1/projects?projectId=${encodeURIComponent(s)}`)).items.find(g=>g.projectId===s);return l===void 0?null:{projectId:s,marked:l.marked===!0,mainPosition:l.context?.mainPosition??null}},async testCase(s,r,l){try{let g=await t("GET",`/v1/projects/${encodeURIComponent(s)}/tests/${encodeURIComponent(r)}/case?base=${encodeURIComponent(l)}`),{test:c,scenario:p,useCase:u,caseId:m,internalId:w,title:h,current:f,counts:$,canAttach:S}=g;return{linked:{test:c,scenario:p,useCase:u,caseId:m,internalId:w,title:h,current:f,counts:$,canAttach:S}}}catch(g){if(g instanceof v&&g.status===409&&nt.has(g.code))return{refused:st(g)};throw g}},async testCases(s){let r=await t("GET",`/v1/projects/${encodeURIComponent(s)}/graph?project=1&types=testCase`),l=g=>g.linkState==="linked"&&typeof g.internalId=="string"&&/^TC-\d+$/.test(g.internalId)?g.internalId:null;return new Map(r.nodes.filter(g=>g.type==="testCase").map(g=>[g.id,l(g.data)]))},async createSession(s){return(await t("POST","/v1/sessions",s)).session},async sources(s){let r=[],l=null;do{let g=`limit=1000${l===null?"":`&after=${encodeURIComponent(l)}`}`,c=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/sources?${g}`);r.push(...c.items.map(({sourceId:p,head:u,completeness:m,origin:w,media:h})=>({sourceId:p,head:u,completeness:m,...w!==void 0?{origin:w}:{},...h!==void 0?{media:h}:{}}))),l=c.next}while(l!==null);return r},async mainRecord(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/positions/${r}`);return{position:l.position,record:l.record}},async mainNode(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/nodes/${encodeURIComponent(r)}`);return{cid:l.cid,name:l.name,label:l.label,content:l.content??{},supersededBy:l.supersededBy??null,edgesOut:(l.edgesOut??[]).map(({type:g,dst:c,other:p})=>({type:g,dst:c,other:p??null}))}},nodes:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=${encodeURIComponent(r)}&limit=1000`),async testsWithContent(s){let r=`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=test&content=1&limit=200`,l;try{l=await t("GET",r)}catch(c){if(c instanceof v&&c.status===400&&c.code==="BAD_REQUEST"&&c.message.includes('Unrecognized key: "content"'))return null;throw c}let g=l.next===null?[]:await a(r,l.next);return[...l.items,...g].map(c=>({...c,content:c.content??{}}))},edges:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/edges?type=${encodeURIComponent(r)}&limit=1000`),stale:s=>a(`/v1/internal/projects/${encodeURIComponent(s)}/stale?limit=1000`),async listSessions(s,r={}){let l=[],g=null,c=`${r.sourceId?`&sourceId=${encodeURIComponent(r.sourceId)}`:""}${r.useCase?`&useCase=${encodeURIComponent(r.useCase)}`:""}`;do{let p=`projectId=${encodeURIComponent(s)}${c}${g===null?"":`&after=${encodeURIComponent(g)}`}`,u=await t("GET",`/v1/sessions?${p}`);l.push(...u.items),g=u.next}while(g!==null);return l},getSession:s=>t("GET",d(s)),setStatus:(s,r)=>t("PATCH",d(s),{status:r}),land:(s,r)=>t("POST",`${d(s)}/land`,{generation:r}),discard:(s,r)=>t("POST",`${d(s)}/discard`,r===void 0?{}:{generation:r}),proposes:async(s,r)=>(await i(s,r)).proposes,counts:i,openUpload:(s,r)=>t("POST",`/v1/projects/${encodeURIComponent(s)}/uploads`,r),putUpload:async(s,r,l,g)=>{let{response:c,bytes:p}=await n("PUT",s,l,{headers:r,route:"PUT upload",...g?{onSend:g}:{}}),u=c.headers.get("etag");if(p.length>0)try{let m=JSON.parse(p.toString("utf8"));typeof m.etag=="string"&&(u=m.etag)}catch{}if(!u)throw new v(c.status,"BAD_RESPONSE","the upload's store answered no etag");return{etag:u}},completeUpload:(s,r,l)=>t("POST",`${o(s,r)}/complete`,{etag:l}),getUpload:(s,r)=>t("GET",o(s,r)),uploadResult:(s,r,l)=>t("POST",`${o(s,r)}/result`,l),async projectCoverage(s){let{state:r,doc:l}=await t("GET",`/v1/projects/${encodeURIComponent(s)}/coverage`);return{state:r,doc:l}},async coverageRun(s,r){return{pack:(await t("POST",`/v1/projects/${encodeURIComponent(s)}/coverage/run`,r)).pack}}}}import{isMainThread as lt}from"worker_threads";import{createHash as dt}from"crypto";function se(e){return e instanceof Error?e.message:String(e)}var ke="SUPERSEDED_WRITER",en="LEASE_LAPSED";function tn(e){let t=`/v1/sessions/${encodeURIComponent(e.sessionId)}/host`,{exchange:n,request:o}=B(e),d=i=>i===null?"limit=1000":`after=${encodeURIComponent(i)}&limit=1000`,a=i=>i===void 0?t:`${t}/children/${encodeURIComponent(i)}`;return{claim:()=>o("POST",`${t}/claim`,{forms:1}),session:()=>o("GET",t),renewLease:i=>o("POST",`${t}/lease`,{generation:i}),save:i=>o("PATCH",t,i),checkpointRows:i=>o("GET",`${a(i)}/checkpoints`,void 0,!0),async readCheckpointRow(i,s){return(await o("GET",`${a(s)}/checkpoints/${i}`,void 0,!0)).text},async writeCheckpointRow(i,s,r,{ifAbsent:l=!1,childId:g}={}){let c=`${a(g)}/checkpoints/${s}${l?"?ifAbsent=true":""}`;return(await o("PUT",c,{generation:i,text:r})).stored},async removeCheckpointRow(i,s,r){await o("DELETE",`${a(r)}/checkpoints/${s}?generation=${i}`)},registerChild:(i,s,r)=>o("POST",`${t}/children`,{generation:i,childId:s,...r?{useCase:r}:{}}),async sessionSide(){return(await o("GET",`${t}/side`)).text},async putSessionSide(i,s){await o("PUT",`${t}/side`,{generation:i,text:s})},saveChildPointer:(i,s,r,l)=>o("PATCH",a(s),{generation:i,checkpoint:r,state:l}),async sessionState(i){let{text:s}=await o("GET",`${a(i)}/state`);return s===null?null:JSON.parse(s)},async putSessionState(i,s,r){await o("PUT",`${a(r)}/state`,{generation:i,text:JSON.stringify(s)})},scope:()=>o("GET",`${t}/scope`),draftsPage:i=>o("GET",`${t}/scope/drafts?${d(i)}`,void 0,!0),appendDraft:(i,s)=>o("POST",`${t}/scope/drafts`,{generation:i,...s}),mainNodes:(i,s)=>o("POST",`${t}/main/nodes`,{position:i,cids:s}),async mainHistory(){let{response:i,bytes:s}=await n("GET",`${t}/main/history`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0}),r=Number(i.headers.get("lattice-history-position")),l=i.headers.get("lattice-history-hash");if(!Number.isInteger(r)||r<0||!l)throw new v(i.status,"UNEXPECTED_ANSWER",`GET ${t}/main/history answered without its Lattice-History-Position and Lattice-History-Hash headers`);return{position:r,hash:l,forms:be(i,"lattice-history-forms"),json:s}},async getBlob(i){try{return(await n("GET",`${t}/blobs/${encodeURIComponent(i)}`,void 0,{bulk:!0})).bytes}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},putBlob:(i,s)=>o("PUT",`${t}/blobs?generation=${i}`,s),async files(i){return(await o("GET",`${t}/files?prefix=${encodeURIComponent(i)}`)).items},async readFile(i){try{let{response:s,bytes:r}=await n("GET",`${t}/file?name=${encodeURIComponent(i)}`,void 0,{bulk:!0}),l=Number(s.headers.get("lattice-file-version"));if(!Number.isInteger(l)||l<1)throw new v(s.status,"UNEXPECTED_ANSWER",`GET ${t}/file answered ${i} without a Lattice-File-Version header`);return{text:r.toString("utf8"),version:l}}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},async embeddings(i,s){let r=`alias=${encodeURIComponent(i)}&purpose=${encodeURIComponent(s)}`,{bytes:l}=await n("GET",`${t}/embeddings?${r}`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0});return JSON.parse(l.toString("utf8"))},putEmbeddings:(i,s)=>o("POST",`${t}/embeddings`,{generation:i,...s}),putFile:(i,s,r,l)=>o("PUT",`${t}/file?name=${encodeURIComponent(s)}&generation=${i}&version=${r}`,l),appendEvents:(i,s)=>o("POST",`${t}/events`,{generation:i,events:s}),async eventsAfter(i){let s=[],r=null;do{let l=r===null?`after=${i}&limit=1000`:`after=${encodeURIComponent(r)}&limit=1000`,g=await o("GET",`${t}/events?${l}`);s.push(...g.items),r=g.next}while(r!==null);return s}}}var re="the session cannot go on: the project's context is being imported; it is served once an import of it completes",ot=5*6e4,Ce=2e3,it=15e3;function _e(e){return e instanceof v&&e.code==="CONTEXT_IMPORTING"}function Ie(){return new v(409,"CONTEXT_IMPORTING",re)}function on(e={}){let t=e.sleep??(a=>new Promise(i=>setTimeout(i,a))),n=e.budgetMs??ot,o=0,d=Ce;return{async wait(){let a=n-o;if(a<=0)return!1;let i=Math.min(d,a);return await t(i),o+=i,d=Math.min(d*2,it),!0},answered(){o=0,d=Ce}}}var R={scope:"store.scope",mainNodes:"store.mainNodes",mainNodesAhead:"store.mainNodesAhead",mainHistory:"store.mainHistory",drafts:"store.drafts",appendDraft:"store.appendDraft",vectorsRead:"store.vectorsRead",vectorsWrite:"store.vectorsWrite",getBlob:"store.getBlob",putBlob:"store.putBlob",chainRead:"chain.read",chainList:"chain.list",chainWrite:"chain.write",chainWriteIfAbsent:"chain.writeIfAbsent",chainRemove:"chain.remove",filesRead:"files.read",filesList:"files.list",filesWrite:"files.write",pointer:"session.pointer",stateGet:"session.stateGet",statePut:"session.statePut",acknowledge:"session.acknowledge",registerChild:"session.registerChild",children:"session.children",sideGet:"session.sideGet",sideSave:"session.sideSave"};var Pe=3e4,D=class extends Error{constructor(n,o,d,a=null){super(`Lattice refused ${n} (${o}): ${d}`);this.op=n;this.code=o;this.requestId=a;this.name="StepRefusedError"}};function ct(e){return e.status!==0?"not_ready":/no answer within/.test(e.message)?"timeout":"unreachable"}var Oe=new Set([ke,"SESSION_ENDED","PROJECT_NOT_MARKED"]);function fn(e,t){let n=t.sleep??(c=>new Promise(p=>setTimeout(p,c))),o=t.retryDeadlineMs??12e4,d=new Map((t.children??[]).map(c=>[c.childId,c.checkpoint?.pointer??null]));async function a(c,p){let u=Te(o,n,t.now);for(;;)try{let m=await p();return t.imports?.answered(),m}catch(m){if(!(m instanceof v))throw m;if(_e(m)&&t.imports){if(await t.imports.wait())continue;throw t.onStopped?.(Ie()),te(new Error(`Lattice refused ${c}: ${re}`),m)}if(Oe.has(m.code)&&t.onStopped?.(m),!m.retryable)throw new D(c,m.code,m.message,m.requestId);let w=h=>t.onRetry?.({op:c,attempt:u.attempt,nextInMs:h,giveUpAt:u.endsAt()??0,cause:ct(m)});if(!await u.again(w))throw t.onStopped?.(new v(m.status,m.code,`Lattice did not take ${c} within ${o/1e3} s: ${m.message}`,null,null,{},m.requestId)),te(new Error(`Lattice refused ${c} (${m.code}, still after ${o/1e3} s): ${m.message}`),m)}}async function i(c,p){try{return await p()}catch(u){throw u instanceof v?(Oe.has(u.code)&&t.onStopped?.(u),new D(c,u.code,u.message,u.requestId)):u}}async function s(c,p){let u=R.acknowledge,m=t.log;if(!m)throw new Error("the checkpoint barrier needs the session log, and this host gave it none");let w=Date.now()+Pe;for(;m.lastSeq()<c.eventSeq;){if(Date.now()>w)throw new Error(`the session log reached event ${m.lastSeq()}, not ${c.eventSeq}, within ${Pe/1e3} s; the checkpoint is not acknowledged`);await n(5)}await ut(m.flush(),o),await a(u,()=>e.writeCheckpointRow(t.generation,`side-${c.pointer.seq}.json`,JSON.stringify(c.side),{childId:p}));let h={pointer:c.pointer,covers:{eventSeq:c.eventSeq,scope:c.scope}},f=JSON.stringify(c.state);p===void 0?await a(u,()=>e.save({generation:t.generation,checkpoint:h,state:f})):d.set(p,(await a(u,()=>e.saveChildPointer(t.generation,p,h,f))).checkpoint.pointer)}async function r(){let c=await a(R.mainHistory,()=>e.mainHistory()),p=dt("sha256").update(c.json).digest("hex");if(p!==c.hash)throw new Error(`main's history from Lattice hashes to ${p}, not to ${c.hash}, the hash Lattice gave for it`);if(t.historyForms!==void 0&&c.forms!==t.historyForms){let u=`main's history pack was built at engine forms ${c.forms??"none named"}, not at ${t.historyForms}, the forms of the Lattice that took this host's claim: another Lattice served it`;throw t.onStopped?.(new v(409,"HISTORY_FORMS_MISMATCH",u)),new Error(u)}return c.json.toString("utf8")}let l=new Map,g=c=>`${Number(c.position)}:${c.cids.join(",")}`;return async(c,p)=>{let u=p??{},m=u.after??null,w=typeof u.childId=="string"?u.childId:void 0;switch(c){case R.scope:return await a(c,()=>e.scope());case R.mainHistory:return{json:await r()};case R.mainNodesAhead:{let h=e.mainNodes(Number(u.position),u.cids);return h.catch(()=>{}),l.set(g(u),h),null}case R.mainNodes:{let h=l.get(g(u));if(l.delete(g(u)),h)try{return await h}catch{}return await a(c,()=>e.mainNodes(Number(u.position),u.cids))}case R.drafts:return await a(c,()=>e.draftsPage(m));case R.appendDraft:{let h={eventId:u.eventId??null,record:u.record??null,envelope:u.envelope??null};return await a(c,()=>e.appendDraft(t.generation,h))}case R.filesRead:return(await a(c,()=>e.readFile(W(u.name))))?.text??null;case R.filesList:{let h=`${W(u.folder)}/`;return(await a(c,()=>e.files(h))).map($=>$.name.slice(h.length)).filter($=>!$.includes("/"))}case R.filesWrite:{if(!String(u.name).startsWith("rationale/"))throw new Error(`the host writes only test rationales; ${W(u.name)} is a configuration file, written by an operator`);try{return await a(c,()=>e.putFile(t.generation,W(u.name),0,Buffer.from(String(u.text),"utf8"))),{written:!0}}catch(h){if(/\(FILE_CHANGED\)/.test(se(h)))return{written:!1,message:se(h)};throw h}}case R.vectorsRead:return await i(c,()=>e.embeddings(String(u.alias),String(u.purpose)));case R.vectorsWrite:{let h={alias:String(u.alias),purpose:String(u.purpose),dims:Number(u.dims),vectors:u.vectors??{}};return await i(c,()=>e.putEmbeddings(t.generation,h))}case R.getBlob:{let h=await a(c,()=>e.getBlob(String(u.fingerprint)));return{bytes:h===null?null:h.toString("base64")}}case R.putBlob:return await a(c,()=>e.putBlob(t.generation,Buffer.from(String(u.bytes),"base64")));case R.chainRead:return await a(c,()=>e.readCheckpointRow(String(u.name),w));case R.chainList:return await a(c,()=>e.checkpointRows(w));case R.chainWrite:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{childId:w})),null;case R.chainWriteIfAbsent:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{ifAbsent:!0,childId:w}));case R.chainRemove:return await a(c,()=>e.removeCheckpointRow(t.generation,String(u.name),w)),null;case R.pointer:return w!==void 0?d.get(w)??null:(await a(c,()=>e.session())).checkpoint?.pointer??null;case R.stateGet:return await a(c,()=>e.sessionState(w));case R.statePut:return await a(c,()=>e.putSessionState(t.generation,u.state??null,w)),null;case R.acknowledge:return await s(u,w),null;case R.children:return[...(t.children??[]).map(h=>h.childId)];case R.sideGet:return await a(c,()=>e.sessionSide());case R.sideSave:return await a(c,()=>e.putSessionSide(t.generation,String(u.text))),{saved:!0};case R.registerChild:{let h=typeof u.useCase=="string"?u.useCase:void 0,f=await a(c,async()=>{try{return await e.registerChild(t.generation,String(u.childId),h)}catch($){throw $ instanceof v&&$.code==="SESSION_CLASH"?new Ee($.message,$.code,{heldBy:$.extra.heldBy??null},$.requestId):$}});return d.set(f.childId,f.checkpoint?.pointer??null),null}default:throw new Error(`the session thread asked for ${c}, which the main thread does not answer`)}}}function W(e){return`design/${String(e)}`}async function ut(e,t){let n,o=new Promise((d,a)=>{n=setTimeout(()=>a(new Error(`the session's events were not stored within ${t/1e3} s; the checkpoint is not acknowledged`)),t)});try{await Promise.race([e,o])}finally{clearTimeout(n)}}var x={verb:"remote",mode:"interactive"},oe=null,Ne=new Set;function Tn(e){x={...x,...e}}function V(e,t){return Ae(e,t),z()}function Ae(e,t){if(!(!Z()||Ne.has(e))){Ne.add(e);try{oe??=$e({verb:x.verb,mode:x.mode,contextRoot:null,env:Re(),sessionId:z(),errorsOnly:!0}),Object.assign(oe.ids,{...x.projectId?{project_id:x.projectId}:{},...x.latticeSessionId?{lattice_session_id:x.latticeSessionId}:{}}),oe.spoolError(e,t?{request_id:t}:{})}catch{}}}function gt(e){return e instanceof v||e instanceof D?`lattice_${e.code}`:"cli_crash"}function mt(e){let t=e?.requestId;return typeof t=="string"&&t?t:null}async function ht(){!Z()||!lt||await Promise.race([fe(we()).catch(()=>{}),new Promise(e=>setTimeout(e,ye).unref())])}async function xn(e,t){return e instanceof v&&Ae(gt(e),mt(e)),await ht(),t}import{isAbsolute as pt,relative as De}from"path";var k=e=>" ".repeat(e);function ft(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var J=e=>e===1?"this test runs":"these tests run";function Ue(e,t,n){if(n===void 0||t+e.length<=n)return[k(t)+e];let o=[],d="";for(let a of e.split(" "))d&&t+d.length+1+a.length>n?(o.push(k(t)+d),d=a):d=d?`${d} ${a}`:a;return[...o,k(t)+d]}function _n(e,t){let n=e.variables.length;if(n===0)return[];let o=n===1?`\u2692 1 variable needs a value before ${J(t.tests)}; fill it in:`:`\u2692 ${n} variables need values before ${J(t.tests)}; fill them in:`,d=[k(t.indent)+o,k(t.indent+4)+(De(t.cwd,e.file)||e.file)],a=e.variables.filter(i=>i.start_page).map(i=>i.name);return a.length===1?d.push(...Ue(`${a[0]} is the page ${t.tests===1?"it starts":"they start"} on`,t.indent+4,t.columns)):a.length>1&&d.push(...Ue(`${ft(a)} are the pages they start on`,t.indent+4,t.columns)),d}function Le(e,t){let n=t.cwd??process.cwd(),o=s=>pt(s)&&De(n,s)||s,d=e.length;if(d===0)return[];let a=d===1?"\u2692 1 test has no start page yet, so it can't run as it is:":`\u2692 ${d} tests have no start page yet, so they can't run as they are:`,i=d===1?"name the page in its first step, or run it with --url <the page>":"name the page in each one's first step, or run them with --url <the page>";return[k(t.indent)+a,...e.map(s=>k(t.indent+4)+(s.file?o(s.file):`${s.test} ${s.title}`)),k(t.indent+4)+i]}function je(e,t){let n=e.variables.length,o=e.noStartPage.length;return[...n===0?[]:[n===1?`1 variable needs a value before ${J(t.tests)}`:`${n} variables need values before ${J(t.tests)}`],...o===0?[]:[o===1?"1 test has no start page yet":`${o} tests have no start page yet`]]}function Bn(e,t="--mode agent"){if(!e.next)return e.remedy?{remedy:e.remedy}:{};let n=(e.remedy??"").split(`
|
|
2
|
+
import{a as Ee,b as te}from"./chunk-GFLB2SHW.js";import{a as ee}from"./chunk-2TVPA3LL.js";import{c as G}from"./chunk-22PIMG52.js";import{a as v,b as be,d as B,e as Te}from"./chunk-4C7WVQOD.js";import{na as ve,oa as P}from"./chunk-5EAJO372.js";import{a as M}from"./chunk-QXQ7KVEN.js";import{a as Se}from"./chunk-R6S4EJ5R.js";import{d as ye,e as Re,f as Z,h as $e}from"./chunk-BZEW7CSM.js";import{a as we}from"./chunk-UV7FPIBL.js";import{a as z}from"./chunk-WTMCDYR3.js";import{e as fe}from"./chunk-WMXBRC4B.js";import{basename as wt,relative as ce}from"path";function Vt(e){return e.scope?.state==="finalized"?"saved":e.scope?.state==="discarded"?"discarded":e.ended==="complete"?"ready_to_save":e.ended==="failed"||e.status==="failed"?"failed":e.status==="paused"||e.status==="needs_attention"?"paused":"running"}var ne=["useCases","criteria","scenarios","tests","openQuestions","sources","styleNotes"],H=new Set(["sources","styleNotes"]);function xe(e){return ne.reduce((t,n)=>t+(H.has(n)?0:e[n]??0),0)}var nt=new Set(["NO_CASE","CASE_BROKEN","TEST_FILE_STALE","CASE_ARCHIVED"]),U=e=>typeof e=="string"?e:null;function st(e){let t=e.extra;switch(e.code){case"CASE_BROKEN":return{code:"CASE_BROKEN",session:U(t.session),caseId:U(t.caseId)??"",reason:t.reason==="moved"?"moved":"deleted"};case"CASE_ARCHIVED":return{code:"CASE_ARCHIVED",caseId:U(t.caseId)??"",internalId:U(t.internalId)??""};default:return{code:e.code,session:U(t.session),useCase:U(t.useCase)}}}function Jt(e){return(Array.isArray(e.nodes)?e.nodes:[]).filter(n=>typeof n.cid=="string"&&typeof n.label=="string").map(n=>({cid:n.cid,label:n.label,content:typeof n.content=="object"&&n.content!==null?n.content:{}}))}function qt(e){return(Array.isArray(e.names)?e.names:[]).filter(n=>typeof n.cid=="string"&&typeof n.slug=="string").map(n=>({cid:n.cid,slug:n.slug}))}function Kt(e){return(Array.isArray(e.supersessions)?e.supersessions:[]).filter(n=>n.kind==="node"&&typeof n.old=="string").map(n=>({old:n.old,new:typeof n.new=="string"?n.new:null}))}function Yt(e){let{request:t,exchange:n}=B(e),o=(s,r)=>`/v1/projects/${encodeURIComponent(s)}/uploads/${r}`,d=s=>`/v1/sessions/${encodeURIComponent(s)}`,a=async(s,r=null)=>{let l=[],g=r;do{let c=await t("GET",`${s}${g===null?"":`&after=${encodeURIComponent(g)}`}`);l.push(...c.items),g=c.next}while(g!==null);return l},i=async(s,r)=>{let l=await t("GET",`/v1/projects/${encodeURIComponent(s)}/sessions/${encodeURIComponent(r)}`),{proposes:g,heldChanges:c,changes:p,approves:u,archives:m,removes:w,chatTurns:h,uncounted:f}=l.drafts;return{proposes:g,heldChanges:c??0,changes:p??{},approves:u??{},archives:m??{},removes:w??{},chatTurns:h??0,uncounted:typeof f=="number"?f:null}};return{async*projects(){for(let s=1;s!==null;){let r=await t("GET",`/v1/projects?page=${s}`);r.items.length>0&&(yield r.items.map(({projectId:l,name:g,marked:c})=>({projectId:l,name:g,marked:c}))),s=r.next}},async project(s){let l=(await t("GET",`/v1/projects?projectId=${encodeURIComponent(s)}`)).items.find(g=>g.projectId===s);return l===void 0?null:{projectId:s,marked:l.marked===!0,mainPosition:l.context?.mainPosition??null}},async testCase(s,r,l){try{let g=await t("GET",`/v1/projects/${encodeURIComponent(s)}/tests/${encodeURIComponent(r)}/case?base=${encodeURIComponent(l)}`),{test:c,scenario:p,useCase:u,caseId:m,internalId:w,title:h,current:f,counts:$,canAttach:S}=g;return{linked:{test:c,scenario:p,useCase:u,caseId:m,internalId:w,title:h,current:f,counts:$,canAttach:S}}}catch(g){if(g instanceof v&&g.status===409&&nt.has(g.code))return{refused:st(g)};throw g}},async testCases(s){let r=await t("GET",`/v1/projects/${encodeURIComponent(s)}/graph?project=1&types=testCase`),l=g=>g.linkState==="linked"&&typeof g.internalId=="string"&&/^TC-\d+$/.test(g.internalId)?g.internalId:null;return new Map(r.nodes.filter(g=>g.type==="testCase").map(g=>[g.id,l(g.data)]))},async createSession(s){return(await t("POST","/v1/sessions",s)).session},async sources(s){let r=[],l=null;do{let g=`limit=1000${l===null?"":`&after=${encodeURIComponent(l)}`}`,c=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/sources?${g}`);r.push(...c.items.map(({sourceId:p,head:u,completeness:m,origin:w,media:h})=>({sourceId:p,head:u,completeness:m,...w!==void 0?{origin:w}:{},...h!==void 0?{media:h}:{}}))),l=c.next}while(l!==null);return r},async mainRecord(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/positions/${r}`);return{position:l.position,record:l.record}},async mainNode(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/nodes/${encodeURIComponent(r)}`);return{cid:l.cid,name:l.name,label:l.label,content:l.content??{},supersededBy:l.supersededBy??null,edgesOut:(l.edgesOut??[]).map(({type:g,dst:c,other:p})=>({type:g,dst:c,other:p??null}))}},nodes:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=${encodeURIComponent(r)}&limit=1000`),async testsWithContent(s){let r=`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=test&content=1&limit=200`,l;try{l=await t("GET",r)}catch(c){if(c instanceof v&&c.status===400&&c.code==="BAD_REQUEST"&&c.message.includes('Unrecognized key: "content"'))return null;throw c}let g=l.next===null?[]:await a(r,l.next);return[...l.items,...g].map(c=>({...c,content:c.content??{}}))},edges:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/edges?type=${encodeURIComponent(r)}&limit=1000`),stale:s=>a(`/v1/internal/projects/${encodeURIComponent(s)}/stale?limit=1000`),async listSessions(s,r={}){let l=[],g=null,c=`${r.sourceId?`&sourceId=${encodeURIComponent(r.sourceId)}`:""}${r.useCase?`&useCase=${encodeURIComponent(r.useCase)}`:""}`;do{let p=`projectId=${encodeURIComponent(s)}${c}${g===null?"":`&after=${encodeURIComponent(g)}`}`,u=await t("GET",`/v1/sessions?${p}`);l.push(...u.items),g=u.next}while(g!==null);return l},getSession:s=>t("GET",d(s)),setStatus:(s,r)=>t("PATCH",d(s),{status:r}),land:(s,r)=>t("POST",`${d(s)}/land`,{generation:r}),discard:(s,r)=>t("POST",`${d(s)}/discard`,r===void 0?{}:{generation:r}),proposes:async(s,r)=>(await i(s,r)).proposes,counts:i,openUpload:(s,r)=>t("POST",`/v1/projects/${encodeURIComponent(s)}/uploads`,r),putUpload:async(s,r,l,g)=>{let{response:c,bytes:p}=await n("PUT",s,l,{headers:r,route:"PUT upload",...g?{onSend:g}:{}}),u=c.headers.get("etag");if(p.length>0)try{let m=JSON.parse(p.toString("utf8"));typeof m.etag=="string"&&(u=m.etag)}catch{}if(!u)throw new v(c.status,"BAD_RESPONSE","the upload's store answered no etag");return{etag:u}},completeUpload:(s,r,l)=>t("POST",`${o(s,r)}/complete`,{etag:l}),getUpload:(s,r)=>t("GET",o(s,r)),uploadResult:(s,r,l)=>t("POST",`${o(s,r)}/result`,l),async projectCoverage(s){let{state:r,doc:l}=await t("GET",`/v1/projects/${encodeURIComponent(s)}/coverage`);return{state:r,doc:l}},async coverageRun(s,r){return{pack:(await t("POST",`/v1/projects/${encodeURIComponent(s)}/coverage/run`,r)).pack}}}}import{isMainThread as lt}from"worker_threads";import{createHash as dt}from"crypto";function se(e){return e instanceof Error?e.message:String(e)}var ke="SUPERSEDED_WRITER",en="LEASE_LAPSED";function tn(e){let t=`/v1/sessions/${encodeURIComponent(e.sessionId)}/host`,{exchange:n,request:o}=B(e),d=i=>i===null?"limit=1000":`after=${encodeURIComponent(i)}&limit=1000`,a=i=>i===void 0?t:`${t}/children/${encodeURIComponent(i)}`;return{claim:()=>o("POST",`${t}/claim`,{forms:1}),session:()=>o("GET",t),renewLease:i=>o("POST",`${t}/lease`,{generation:i}),save:i=>o("PATCH",t,i),checkpointRows:i=>o("GET",`${a(i)}/checkpoints`,void 0,!0),async readCheckpointRow(i,s){return(await o("GET",`${a(s)}/checkpoints/${i}`,void 0,!0)).text},async writeCheckpointRow(i,s,r,{ifAbsent:l=!1,childId:g}={}){let c=`${a(g)}/checkpoints/${s}${l?"?ifAbsent=true":""}`;return(await o("PUT",c,{generation:i,text:r})).stored},async removeCheckpointRow(i,s,r){await o("DELETE",`${a(r)}/checkpoints/${s}?generation=${i}`)},registerChild:(i,s,r)=>o("POST",`${t}/children`,{generation:i,childId:s,...r?{useCase:r}:{}}),async sessionSide(){return(await o("GET",`${t}/side`)).text},async putSessionSide(i,s){await o("PUT",`${t}/side`,{generation:i,text:s})},saveChildPointer:(i,s,r,l)=>o("PATCH",a(s),{generation:i,checkpoint:r,state:l}),async sessionState(i){let{text:s}=await o("GET",`${a(i)}/state`);return s===null?null:JSON.parse(s)},async putSessionState(i,s,r){await o("PUT",`${a(r)}/state`,{generation:i,text:JSON.stringify(s)})},scope:()=>o("GET",`${t}/scope`),draftsPage:i=>o("GET",`${t}/scope/drafts?${d(i)}`,void 0,!0),appendDraft:(i,s)=>o("POST",`${t}/scope/drafts`,{generation:i,...s}),mainNodes:(i,s)=>o("POST",`${t}/main/nodes`,{position:i,cids:s}),async mainHistory(){let{response:i,bytes:s}=await n("GET",`${t}/main/history`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0}),r=Number(i.headers.get("lattice-history-position")),l=i.headers.get("lattice-history-hash");if(!Number.isInteger(r)||r<0||!l)throw new v(i.status,"UNEXPECTED_ANSWER",`GET ${t}/main/history answered without its Lattice-History-Position and Lattice-History-Hash headers`);return{position:r,hash:l,forms:be(i,"lattice-history-forms"),json:s}},async getBlob(i){try{return(await n("GET",`${t}/blobs/${encodeURIComponent(i)}`,void 0,{bulk:!0})).bytes}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},putBlob:(i,s)=>o("PUT",`${t}/blobs?generation=${i}`,s),async files(i){return(await o("GET",`${t}/files?prefix=${encodeURIComponent(i)}`)).items},async readFile(i){try{let{response:s,bytes:r}=await n("GET",`${t}/file?name=${encodeURIComponent(i)}`,void 0,{bulk:!0}),l=Number(s.headers.get("lattice-file-version"));if(!Number.isInteger(l)||l<1)throw new v(s.status,"UNEXPECTED_ANSWER",`GET ${t}/file answered ${i} without a Lattice-File-Version header`);return{text:r.toString("utf8"),version:l}}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},async embeddings(i,s){let r=`alias=${encodeURIComponent(i)}&purpose=${encodeURIComponent(s)}`,{bytes:l}=await n("GET",`${t}/embeddings?${r}`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0});return JSON.parse(l.toString("utf8"))},putEmbeddings:(i,s)=>o("POST",`${t}/embeddings`,{generation:i,...s}),putFile:(i,s,r,l)=>o("PUT",`${t}/file?name=${encodeURIComponent(s)}&generation=${i}&version=${r}`,l),appendEvents:(i,s)=>o("POST",`${t}/events`,{generation:i,events:s}),async eventsAfter(i){let s=[],r=null;do{let l=r===null?`after=${i}&limit=1000`:`after=${encodeURIComponent(r)}&limit=1000`,g=await o("GET",`${t}/events?${l}`);s.push(...g.items),r=g.next}while(r!==null);return s}}}var re="the session cannot go on: the project's context is being imported; it is served once an import of it completes",ot=5*6e4,Ce=2e3,it=15e3;function _e(e){return e instanceof v&&e.code==="CONTEXT_IMPORTING"}function Ie(){return new v(409,"CONTEXT_IMPORTING",re)}function on(e={}){let t=e.sleep??(a=>new Promise(i=>setTimeout(i,a))),n=e.budgetMs??ot,o=0,d=Ce;return{async wait(){let a=n-o;if(a<=0)return!1;let i=Math.min(d,a);return await t(i),o+=i,d=Math.min(d*2,it),!0},answered(){o=0,d=Ce}}}var R={scope:"store.scope",mainNodes:"store.mainNodes",mainNodesAhead:"store.mainNodesAhead",mainHistory:"store.mainHistory",drafts:"store.drafts",appendDraft:"store.appendDraft",vectorsRead:"store.vectorsRead",vectorsWrite:"store.vectorsWrite",getBlob:"store.getBlob",putBlob:"store.putBlob",chainRead:"chain.read",chainList:"chain.list",chainWrite:"chain.write",chainWriteIfAbsent:"chain.writeIfAbsent",chainRemove:"chain.remove",filesRead:"files.read",filesList:"files.list",filesWrite:"files.write",pointer:"session.pointer",stateGet:"session.stateGet",statePut:"session.statePut",acknowledge:"session.acknowledge",registerChild:"session.registerChild",children:"session.children",sideGet:"session.sideGet",sideSave:"session.sideSave"};var Pe=3e4,D=class extends Error{constructor(n,o,d,a=null){super(`Lattice refused ${n} (${o}): ${d}`);this.op=n;this.code=o;this.requestId=a;this.name="StepRefusedError"}};function ct(e){return e.status!==0?"not_ready":/no answer within/.test(e.message)?"timeout":"unreachable"}var Oe=new Set([ke,"SESSION_ENDED","PROJECT_NOT_MARKED"]);function fn(e,t){let n=t.sleep??(c=>new Promise(p=>setTimeout(p,c))),o=t.retryDeadlineMs??12e4,d=new Map((t.children??[]).map(c=>[c.childId,c.checkpoint?.pointer??null]));async function a(c,p){let u=Te(o,n,t.now);for(;;)try{let m=await p();return t.imports?.answered(),m}catch(m){if(!(m instanceof v))throw m;if(_e(m)&&t.imports){if(await t.imports.wait())continue;throw t.onStopped?.(Ie()),te(new Error(`Lattice refused ${c}: ${re}`),m)}if(Oe.has(m.code)&&t.onStopped?.(m),!m.retryable)throw new D(c,m.code,m.message,m.requestId);let w=h=>t.onRetry?.({op:c,attempt:u.attempt,nextInMs:h,giveUpAt:u.endsAt()??0,cause:ct(m)});if(!await u.again(w))throw t.onStopped?.(new v(m.status,m.code,`Lattice did not take ${c} within ${o/1e3} s: ${m.message}`,null,null,{},m.requestId)),te(new Error(`Lattice refused ${c} (${m.code}, still after ${o/1e3} s): ${m.message}`),m)}}async function i(c,p){try{return await p()}catch(u){throw u instanceof v?(Oe.has(u.code)&&t.onStopped?.(u),new D(c,u.code,u.message,u.requestId)):u}}async function s(c,p){let u=R.acknowledge,m=t.log;if(!m)throw new Error("the checkpoint barrier needs the session log, and this host gave it none");let w=Date.now()+Pe;for(;m.lastSeq()<c.eventSeq;){if(Date.now()>w)throw new Error(`the session log reached event ${m.lastSeq()}, not ${c.eventSeq}, within ${Pe/1e3} s; the checkpoint is not acknowledged`);await n(5)}await ut(m.flush(),o),await a(u,()=>e.writeCheckpointRow(t.generation,`side-${c.pointer.seq}.json`,JSON.stringify(c.side),{childId:p}));let h={pointer:c.pointer,covers:{eventSeq:c.eventSeq,scope:c.scope}},f=JSON.stringify(c.state);p===void 0?await a(u,()=>e.save({generation:t.generation,checkpoint:h,state:f})):d.set(p,(await a(u,()=>e.saveChildPointer(t.generation,p,h,f))).checkpoint.pointer)}async function r(){let c=await a(R.mainHistory,()=>e.mainHistory()),p=dt("sha256").update(c.json).digest("hex");if(p!==c.hash)throw new Error(`main's history from Lattice hashes to ${p}, not to ${c.hash}, the hash Lattice gave for it`);if(t.historyForms!==void 0&&c.forms!==t.historyForms){let u=`main's history pack was built at engine forms ${c.forms??"none named"}, not at ${t.historyForms}, the forms of the Lattice that took this host's claim: another Lattice served it`;throw t.onStopped?.(new v(409,"HISTORY_FORMS_MISMATCH",u)),new Error(u)}return c.json.toString("utf8")}let l=new Map,g=c=>`${Number(c.position)}:${c.cids.join(",")}`;return async(c,p)=>{let u=p??{},m=u.after??null,w=typeof u.childId=="string"?u.childId:void 0;switch(c){case R.scope:return await a(c,()=>e.scope());case R.mainHistory:return{json:await r()};case R.mainNodesAhead:{let h=e.mainNodes(Number(u.position),u.cids);return h.catch(()=>{}),l.set(g(u),h),null}case R.mainNodes:{let h=l.get(g(u));if(l.delete(g(u)),h)try{return await h}catch{}return await a(c,()=>e.mainNodes(Number(u.position),u.cids))}case R.drafts:return await a(c,()=>e.draftsPage(m));case R.appendDraft:{let h={eventId:u.eventId??null,record:u.record??null,envelope:u.envelope??null};return await a(c,()=>e.appendDraft(t.generation,h))}case R.filesRead:return(await a(c,()=>e.readFile(W(u.name))))?.text??null;case R.filesList:{let h=`${W(u.folder)}/`;return(await a(c,()=>e.files(h))).map($=>$.name.slice(h.length)).filter($=>!$.includes("/"))}case R.filesWrite:{if(!String(u.name).startsWith("rationale/"))throw new Error(`the host writes only test rationales; ${W(u.name)} is a configuration file, written by an operator`);try{return await a(c,()=>e.putFile(t.generation,W(u.name),0,Buffer.from(String(u.text),"utf8"))),{written:!0}}catch(h){if(/\(FILE_CHANGED\)/.test(se(h)))return{written:!1,message:se(h)};throw h}}case R.vectorsRead:return await i(c,()=>e.embeddings(String(u.alias),String(u.purpose)));case R.vectorsWrite:{let h={alias:String(u.alias),purpose:String(u.purpose),dims:Number(u.dims),vectors:u.vectors??{}};return await i(c,()=>e.putEmbeddings(t.generation,h))}case R.getBlob:{let h=await a(c,()=>e.getBlob(String(u.fingerprint)));return{bytes:h===null?null:h.toString("base64")}}case R.putBlob:return await a(c,()=>e.putBlob(t.generation,Buffer.from(String(u.bytes),"base64")));case R.chainRead:return await a(c,()=>e.readCheckpointRow(String(u.name),w));case R.chainList:return await a(c,()=>e.checkpointRows(w));case R.chainWrite:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{childId:w})),null;case R.chainWriteIfAbsent:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{ifAbsent:!0,childId:w}));case R.chainRemove:return await a(c,()=>e.removeCheckpointRow(t.generation,String(u.name),w)),null;case R.pointer:return w!==void 0?d.get(w)??null:(await a(c,()=>e.session())).checkpoint?.pointer??null;case R.stateGet:return await a(c,()=>e.sessionState(w));case R.statePut:return await a(c,()=>e.putSessionState(t.generation,u.state??null,w)),null;case R.acknowledge:return await s(u,w),null;case R.children:return[...(t.children??[]).map(h=>h.childId)];case R.sideGet:return await a(c,()=>e.sessionSide());case R.sideSave:return await a(c,()=>e.putSessionSide(t.generation,String(u.text))),{saved:!0};case R.registerChild:{let h=typeof u.useCase=="string"?u.useCase:void 0,f=await a(c,async()=>{try{return await e.registerChild(t.generation,String(u.childId),h)}catch($){throw $ instanceof v&&$.code==="SESSION_CLASH"?new Ee($.message,$.code,{heldBy:$.extra.heldBy??null},$.requestId):$}});return d.set(f.childId,f.checkpoint?.pointer??null),null}default:throw new Error(`the session thread asked for ${c}, which the main thread does not answer`)}}}function W(e){return`design/${String(e)}`}async function ut(e,t){let n,o=new Promise((d,a)=>{n=setTimeout(()=>a(new Error(`the session's events were not stored within ${t/1e3} s; the checkpoint is not acknowledged`)),t)});try{await Promise.race([e,o])}finally{clearTimeout(n)}}var x={verb:"remote",mode:"interactive"},oe=null,Ne=new Set;function Tn(e){x={...x,...e}}function V(e,t){return Ae(e,t),z()}function Ae(e,t){if(!(!Z()||Ne.has(e))){Ne.add(e);try{oe??=$e({verb:x.verb,mode:x.mode,contextRoot:null,env:Re(),sessionId:z(),errorsOnly:!0}),Object.assign(oe.ids,{...x.projectId?{project_id:x.projectId}:{},...x.latticeSessionId?{lattice_session_id:x.latticeSessionId}:{}}),oe.spoolError(e,t?{request_id:t}:{})}catch{}}}function gt(e){return e instanceof v||e instanceof D?`lattice_${e.code}`:"cli_crash"}function mt(e){let t=e?.requestId;return typeof t=="string"&&t?t:null}async function ht(){!Z()||!lt||await Promise.race([fe(we()).catch(()=>{}),new Promise(e=>setTimeout(e,ye).unref())])}async function xn(e,t){return e instanceof v&&Ae(gt(e),mt(e)),await ht(),t}import{isAbsolute as pt,relative as De}from"path";var k=e=>" ".repeat(e);function ft(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var J=e=>e===1?"this test runs":"these tests run";function Ue(e,t,n){if(n===void 0||t+e.length<=n)return[k(t)+e];let o=[],d="";for(let a of e.split(" "))d&&t+d.length+1+a.length>n?(o.push(k(t)+d),d=a):d=d?`${d} ${a}`:a;return[...o,k(t)+d]}function _n(e,t){let n=e.variables.length;if(n===0)return[];let o=n===1?`\u2692 1 variable needs a value before ${J(t.tests)}; fill it in:`:`\u2692 ${n} variables need values before ${J(t.tests)}; fill them in:`,d=[k(t.indent)+o,k(t.indent+4)+(De(t.cwd,e.file)||e.file)],a=e.variables.filter(i=>i.start_page).map(i=>i.name);return a.length===1?d.push(...Ue(`${a[0]} is the page ${t.tests===1?"it starts":"they start"} on`,t.indent+4,t.columns)):a.length>1&&d.push(...Ue(`${ft(a)} are the pages they start on`,t.indent+4,t.columns)),d}function Le(e,t){let n=t.cwd??process.cwd(),o=s=>pt(s)&&De(n,s)||s,d=e.length;if(d===0)return[];let a=d===1?"\u2692 1 test has no start page yet, so it can't run as it is:":`\u2692 ${d} tests have no start page yet, so they can't run as they are:`,i=d===1?"name the page in its first step, or run it with --url <the page>":"name the page in each one's first step, or run them with --url <the page>";return[k(t.indent)+a,...e.map(s=>k(t.indent+4)+(s.file?o(s.file):`${s.test} ${s.title}`)),k(t.indent+4)+i]}function je(e,t){let n=e.variables.length,o=e.noStartPage.length;return[...n===0?[]:[n===1?`1 variable needs a value before ${J(t.tests)}`:`${n} variables need values before ${J(t.tests)}`],...o===0?[]:[o===1?"1 test has no start page yet":`${o} tests have no start page yet`]]}function Bn(e,t="--mode agent"){if(!e.next)return e.remedy?{remedy:e.remedy}:{};let n=(e.remedy??"").split(`
|
|
3
3
|
`).filter(o=>!/^\s+kane-cli /.test(o)).join(" ").replace(/(, run)?:$/,"").replace(/[,;]\s*(then\s+)?run:\s*kane-cli\b.*$/,"").trim();return{...n?{remedy:n}:{},next:e.next.map(o=>({cmd:`${o.cmd} ${t}`,why:o.why}))}}function Gn(e){let t=e;return!t||typeof t.sessionId!="string"||typeof t.verb!="string"?null:{sessionId:t.sessionId,verb:t.verb,useCase:typeof t.useCase=="string"?t.useCase:null,mine:t.mine===!0,status:typeof t.status=="string"?t.status:"running"}}var Hn=e=>({sid:e.sessionId,verb:e.verb,use_case:e.useCase,mine:e.mine,status:e.status}),yt={useCases:["use-case","use-cases"],criteria:["acceptance criterion","acceptance criteria"],scenarios:["scenario","scenarios"],tests:["test","tests"],openQuestions:["open question","open questions"],sources:["source","sources"],styleNotes:["style note","style notes"]},ue=ne.map(e=>[e,...yt[e]]),X=(e,t=H)=>{let n=ue.filter(([d])=>(e[d]??0)>0),o=n.filter(([d])=>!t.has(d));return o.length>0?o:n},Rt=new Set(["styleNotes"]),le=e=>e?ue.filter(([t])=>(e[t]??0)>0).map(([t,n,o])=>`${e[t]} ${e[t]===1?n:o}`):[];function $t(e){let t=o=>o?I(X(o).map(([d,a,i])=>`${o[d]} ${o[d]===1?a:i}`)):"",n=[[t(e),"added"],...Ve.map(({key:o,done:d})=>[t(e[o]),o==="changes"?"changed":d])].filter(([o])=>o!=="").map(([o,d])=>`${o} ${d}`);return N(e)>0&&n.push(Ke(N(e))),n.length>0?n.join(", "):null}function Wn(e){let t=$t(e.counts),n=[G(e.durS),...t?[t]:[],...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 "),o=e.title?`"${e.title}"`:P(e.id??"");return t||(e.counts.uncounted??0)>0?`\u25CF updated ${o} \u2014 ${n}`:`\u25CF nothing changed in ${o} \u2014 ${n}`}function Vn(e){let t=e.title?`"${e.title}"`:P(e.id??""),n=[G(e.durS),`${e.tests} ${e.tests===1?"test":"tests"}`,...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]];return`\u25CF designed ${t} \u2014 ${n.join(" \xB7 ")}`}function Jn(e){return`\u25CF finished ${e.title?`"${e.title}"`:P(e.id??"")} \u2014 ${[G(e.durS),...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 ")}`}var I=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`,Ve=[{key:"changes",row:"updates",done:"updated",saving:"updates"},{key:"approves",row:"approves",done:"approved",saving:"approves"},{key:"archives",row:"archives",done:"archived",saving:"archives"},{key:"replaces",row:"replaces",done:"replaced",saving:"replaces"},{key:"removes",row:"removes",done:"removed",saving:"removes"}],Q=e=>Ve.filter(({key:t})=>j(e[t])),Je=e=>Q(e).length>0,ge=e=>e===1?"1 test":`${e} tests`,vt=e=>[...Q(e).map(({key:t,done:n})=>`${I(le(e[t]))} ${n}`),...e.keeps?[`${ge(e.keeps)} marked up to date`]:[]],qn=e=>[...Q(e).map(({key:t,saving:n})=>`saving it ${n} ${I(le(e[t]))}${t==="removes"?" from the project":""}`),...e.keeps?[`saving it marks ${ge(e.keeps)} up to date`]:[]],Kn=e=>[...vt(e),...N(e)>0?[Ye(N(e))]:[]],Yn=e=>ue.reduce((t,[n])=>t+(H.has(n)?0:e.changes?.[n]??0),0),Xn=e=>xe(e),bt=e=>F(e)!==""||j(e.changes)||j(e.approves)||j(e.archives),St="this session's work",Qn=e=>F(e)?"throw away what this session added":me(e)?"throw away this session's chat":"throw away this session's work",zn="already discarded \u2014 nothing was saved",Zn=e=>bt(e)?"your team can see it now":me(e)?Et:xt(e)?St:"",Et="this session's chat";function es(e,t){let n=t.removes;if(e==="extract"||!n||!((n.scenarios??0)>0||(n.tests??0)>0))return t;let o={...(n.scenarios??0)>0?{scenarios:n.scenarios}:{},...(n.tests??0)>0?{tests:n.tests}:{}},{scenarios:d,tests:a,...i}=n,{removes:s,...r}=t;return{...r,replaces:o,...j(i)?{removes:i}:{}}}function ts(e){let t=new Map;for(let n of e){if(n.kind!=="evolve_diff")continue;let o=n.payload??n.body;if(typeof o?.use_case!="string")continue;let d=o.repinned?.tests;typeof d=="number"&&d>0?t.set(o.use_case,d):t.delete(o.use_case)}return t}function ns(e,t){let n=[...t.values()].reduce((i,s)=>i+s,0);if(n===0)return e;let o=Math.max(0,(e.uncounted??0)-t.size),{uncounted:d,...a}=e;return{...a,keeps:n,...o>0?{uncounted:o}:{}}}var Tt=["changes","approves","archives","removes"],N=e=>e.heldChanges??0,j=e=>Object.values(e??{}).some(t=>(t??0)>0),qe=e=>!(e.adds??F(e))&&!Je(e)&&N(e)===0&&(e.keeps??0)===0,me=e=>qe(e)&&(e.chatTurns??0)>0&&(e.uncounted??0)===0,xt=e=>qe(e)&&!me(e);async function ss(e,t,n){let o=await e.counts(t,n),{proposes:d,heldChanges:a,chatTurns:i,uncounted:s}=o;return{...d,...a>0?{heldChanges:a}:{},...Object.fromEntries(Tt.flatMap(r=>j(o[r])?[[r,o[r]]]:[])),...i&&i>0?{chatTurns:i}:{},...typeof s=="number"?{exact:!0}:{},...typeof s=="number"&&s>0?{uncounted:s}:{}}}function Ke(e){return e===1?"1 change to an existing use-case":`${e} changes to existing use-cases`}function Ye(e){return`${Ke(e)}, saved but not applied`}var kt=e=>F(e)!==""||Je(e)||N(e)>0||(e.keeps??0)>0||(e.chatTurns??0)>0||(e.uncounted??0)>0,rs=(e,t)=>e.exact?kt(e):t;function os(e,t){let n=F(e),o=N(e),d=[];n&&d.push(["adds",n]);for(let{key:s,row:r}of Q(e))d.push([r,le(e[s]).join(", ")]);e.keeps&&d.push(["keeps",`${ge(e.keeps)}, marked up to date`]),o>0&&d.push(["held",Ye(o)]);let a=(e.chatTurns??0)>0;((e.uncounted??0)>0||!e.exact&&d.length===0&&!a)&&d.push(["other","work not counted here"]),a&&d.push(["chat","saved with the session; your team can read it"]),d.push(["project",t?"changed since this session started":"no changes since this session started"]);let i=s=>(s?.scenarios??0)+(s?.tests??0);return i(e)+i(e.changes)>0&&d.push(["then","its test cases are created or updated in Test Manager"]),d}function F(e){return X(e,Rt).map(([t,n,o])=>`${e[t]} ${e[t]===1?n:o}`).join(", ")}function is(e){let t=X(e);if(t.length!==1)return"your work is";let[n,o,d]=t[0];return e[n]===1?`your ${o} is`:`your ${e[n]} ${d} are`}function Ct(e,t=[]){return t.length>0?`start a new session from the latest project, adding this session's documents again; run:
|
|
4
4
|
${Xe(t)}`:`${e.startsWith("kane-cli design tests")?"to design it again from the latest project":"to start a new session from the latest project"}, run:
|
|
5
5
|
${e}`}var Xe=e=>`kane-cli context ingest ${e.map(Y).join(" ")}`;function as(e,t){return e.length>0?[...new Set(e)]:_t(t)}function _t(e){return[...new Set((e.uploads??[]).filter(t=>t.outcome==="created"&&t.filename).map(t=>t.filename))]}function It(e){let t=X(e);if(t.length!==1)return"its work";let[n,o,d]=t[0];return e[n]===1?`its ${o}`:`its ${e[n]} ${d}`}function ds(e){return e.replace(/\s*\([^()]*→[^()]*\)/g,"")}function cs(e,t,n){return`kane-cli ${e==="design"?"design tests":"context extract"} --resume ${t}${n?" --mode agent":""}`}var Me=e=>`updating kane-cli won't help \u2014 share this id with support: ${V(`refused_${e}`)}`,q="in a folder linked to a shared project",L="check the file, then run the command again",ie=e=>[`${e} has more inside it than kane-cli can read`,"save a smaller copy, or a PDF of it, then run the command again"],Pt={PDF_ENCRYPTED:e=>[`${e} is password-protected`,"remove the password, then run the command again"],PDF_NO_TEXT_LAYER:e=>[`${e} has no text to read; scanned PDFs aren't supported yet`,"use a PDF with text in it, then run the command again"],PDF_UNREADABLE:e=>[`${e} can't be read as a PDF`,L],DOCX_UNREADABLE:e=>[`${e} can't be read as a Word document`,L],DOCX_NOT_WORDPROCESSING:e=>[`${e} can't be read as a Word document`,L],DOCX_NO_TEXT:e=>[`${e} has no text to add`,L],DOCX_ENCRYPTED_OR_LEGACY:e=>[`${e} is password-protected or in the old Word format`,"save it as a .docx without a password, then run the command again"],DOCX_PART_TOO_LARGE:ie,DOCX_TOO_MANY_PARTS:ie,DOCX_BOMB:ie,SOURCE_ID_OWNED:e=>[`${e} can't become a version of that source: a source plugin reads it`,"add it under another id with --as <id>, then run the command again"]},Ot={changed_both_sides:"it was changed in Test Manager too; choose there which steps to keep",not_pushable:"its steps can't be changed from here; change them in Test Manager",archived:"it's archived in Test Manager; restore it there first",busy:"a test run is using it; wait until the run ends",not_accepted:"Test Manager has different steps for it; choose there which to keep"},O=e=>`${e} ${e===1?"test case":"test cases"}`,Fe={test_on_older_version:"it changed after its test was designed",test_unreadable:"its test can't be read",test_has_no_steps:"its test has no steps"},Qe=e=>ve.test(e)?e.toLowerCase():e,ze=e=>Object.hasOwn(Fe,e)?Fe[e]:void 0,Ze=e=>e.useCase&&ze(e.reason)!==void 0&&e.reason!=="test_unreadable"?Qe(e.useCase):null;function us(e){if(!e||e==="unread")return;let t=new Map([...e.wrote,...e.unchanged??[]].map(n=>[n.id.toLowerCase(),n.path]));for(let n of e.refused)n.file&&t.set(n.id.toLowerCase(),n.file);return n=>t.get(n.toLowerCase())}var de=e=>e.reason==="test_unreadable";function Nt(e,t){let n=ze(e.reason);if(n===void 0)return[{text:" it can't be sent to Test Manager yet",tone:"detail"}];if(e.reason==="test_unreadable"){let d=t?.(e.test);return[{text:` ${n}${d?`: ${pe(d)}`:""}`,tone:"detail"}]}let o=Ze(e);return o===null?[{text:` ${n}`,tone:"detail"}]:[{text:` ${n}; to design its tests again, run:`,tone:"detail"},{text:` kane-cli design tests --use-case ${o}`,tone:"detail",command:!0}]}var K=(e,t)=>t===void 0||typeof e.useCase!="string"||t.has(Qe(e.useCase));function At(e,t,n){let o=e===1,d=`to see ${o?"its use-case":"their use-cases"}, run: kane-cli context list --stale`,a=o?"1 scenario of another use-case":`${e} scenarios of other use-cases`;return n?[{text:` ${a} ${o?"isn't":"aren't"} in Test Manager either`,tone:"detail"},{text:` ${d}`,tone:"detail"}]:[{text:`${a} in ${y(t)} ${o?"isn't":"aren't"} in Test Manager`,tone:"detail"},{text:` ${d}`,tone:"detail"}]}var C="some test cases may not be there yet";function he(e,t){switch(e){case"TEST_MANAGER_TIMEOUT":return{why:`Test Manager took too long, so ${C}`,lead:`Test Manager took too long; ${C}`,next:"to finish them (nothing is saved twice), run:",remedy:!1,support:!1,agentCode:"TEST_MANAGER_TIMED_OUT"};case"FORGE_UNAVAILABLE":return{why:`Test Manager couldn't be reached, so ${C}`,lead:`Test Manager couldn't be reached; ${C}`,next:"to finish them (nothing is saved twice), run:",remedy:!1,support:!0,agentCode:"TEST_MANAGER_UNREACHABLE"};case"FORGE_REFUSED":return{why:`Test Manager refused your account, so ${C}`,lead:`Test Manager refused your account; ${C}`,next:"ask a Test Manager admin to grant your account access, then run:",remedy:!0,support:!1,agentCode:"PROJECT_NO_ACCESS"};case"PROJECT_NOT_MARKED":return{why:`assurance is now off for "${t}", so ${C}`,lead:`assurance is now off for "${t}"; ${C}`,next:"to try them again later (nothing is saved twice), run:",remedy:!0,support:!1,agentCode:"ASSURANCE_OFF"};default:return{why:"some test cases couldn't be created or updated in Test Manager",lead:"some test cases couldn't be created or updated in Test Manager",next:"to try them again (nothing is saved twice), run:",remedy:!1,support:!0,agentCode:"TEST_MANAGER_FAILED"}}}function ls(e,t,n,o,d){let a={receipt:null,summary:null,lines:[],support:!1};if(!e)return a;let{made:i,updated:s,waiting:r,error:l}=e,g=e.nextRun??[],c=e.notCovered??[],p=c.filter(b=>K(b,o)),u=c.length-p.length;if(i===0&&s===0&&r===0&&l===null&&g.length===0&&c.length===0)return a;let m=i>0&&s>0?`${O(i)} created and ${s} updated in Test Manager`:i>0?`${O(i)} created in Test Manager`:s>0?`${O(s)} updated in Test Manager`:null,w={text:` kane-cli context sessions save ${t}`,tone:"plain"},h=b=>b===1?"wasn't":"weren't",f=[];if(g.length>0){let b=g.length===1;f.push({text:`${O(g.length)} in Test Manager ${b?"updates on its":"update on their"} next kane-cli run:`,tone:"plain"});for(let A of g)f.push({text:` "${A.title}"`,tone:"detail"});(r>0||l!==null||c.length>0)&&f.push({text:"",tone:"plain"})}if(r>0){f.push({text:`warning: ${O(r)} in Test Manager ${h(r)} updated`,tone:"warning"});for(let b of e.waitingOn)f.push({text:` "${b.title}"`,tone:"detail"},{text:` ${Ot[b.reason]}`,tone:"detail"})}if(p.length>0){let b=p.length;f.push({text:`warning: ${b} ${b===1?"scenario wasn't":"scenarios weren't"} sent to Test Manager`,tone:"warning"});for(let A of p)f.push({text:` "${A.title}"`,tone:"detail"},...Nt(A,d))}u>0&&f.push(...At(u,n,p.length>0));let $=l===null?null:he(l.code,n);$&&f.push({text:`warning: the session was saved, but ${$.why}`,tone:"warning"});let S=$?$.remedy||r===0?$.next:"then, to finish them (nothing is saved twice), run:":r>0?`then, to update ${r===1?"it":"them"} (nothing is saved twice), run:`:null;S!==null&&f.push({text:`next: ${S}`,tone:"plain"},w);let E=[];if(m!==null&&E.push(m),r>0&&E.push(m!==null?`${r} ${h(r)} updated yet`:`${O(r)} in Test Manager ${h(r)} updated yet`),p.length>0){let b=p.length;E.push(`${E.length>0?b:`${b} ${b===1?"scenario":"scenarios"}`} ${b===1?"wasn't":"weren't"} sent to Test Manager`)}return $&&E.push(E.length>0?"some may not be there yet":$.lead),{receipt:m,summary:E.length>0?E.join("; "):null,...g.length>0?{nextRunSummary:`${O(g.length)} ${g.length===1?"updates on its":"update on their"} next kane-cli run`}:{},lines:f,support:($?.support??!1)||p.some(de)}}function gs(e,t,n,o){if(!e)return;let d=e.notCovered??[],a=[...new Set(d.flatMap(s=>{let r=K(s,n)?Ze(s):null;return r===null?[]:[r]}))],i=[...e.error!==null?[{cmd:`kane-cli context sessions save ${t} --mode agent`,why:"finishes the test cases that may not be there yet"}]:[],...a.map(s=>({cmd:`kane-cli design tests --use-case ${s} --force --mode agent`,why:"designs the use case's tests again, so its scenarios reach Test Manager"}))];return{total:e.total,created:e.made,updated:e.updated,already_there:e.linked,waiting:e.waiting,waiting_on:e.waitingOn.map(({scenario:s,title:r,reason:l})=>({scenario:s,title:r,reason:l})),next_run:(e.nextRun??[]).map(({scenario:s,title:r})=>({scenario:s,title:r})),...d.length>0?{not_covered:d.map(s=>{let r=de(s)?o?.(s.test):void 0;return{scenario:s.scenario,title:s.title,test:s.test,reason:s.reason,in_session:K(s,n),...r?{file:pe(r)}:{}}})}:{},...e.error!==null?{error:he(e.error.code,"").agentCode}:{},...d.some(s=>K(s,n)&&de(s))?{support_id:V("refused_TEST_UNREADABLE")}:{},...i.length>0?{next:i}:{}}}var Be=new Set(["duplicate","unwritable"]),et=e=>Be.has(e.kind)||e.kind==="import"&&e.via!==void 0&&Be.has(e.via),Ut=new Set(["unreadable","unresolved"]);function Dt(e,t){return!e||e.variables.length===0&&e.noStartPage.length===0?{}:{needed:{...e,tests:t},neededFacts:je(e,{tests:t})}}function Lt(e){if(!e||e.length===0)return{};let t=e.length===1?"1 test file here was replaced and won't run any more":`${e.length} test files here were replaced and won't run any more`;return{replacedHead:`\u2692 ${t}:`,replaced:e.map(n=>({file:ce(process.cwd(),n.file)||n.file,by:n.replacedBy.map(o=>wt(o))})),replacedSummary:t}}function jt(e){return e!=null&&e.error===null}var tt=(e,t)=>{if(!jt(t)||t.waitingOn.length>0)return[];let n=new Set((t.notCovered??[]).map(o=>o.test.toLowerCase()));return e.filter(o=>o.file&&!n.has(o.id.toLowerCase()))},pe=e=>M(ce(process.cwd(),e)||e);function ms(e,t,n,o={}){let d={text:` kane-cli context sessions save ${t}`,tone:"plain"};if(e==="unread")return{line:null,lines:[{text:"warning: the session was saved, but its test files couldn't be written here",tone:"warning"},{text:"next: to write them (nothing is saved twice), run:",tone:"plain"},d],support:!0,summary:"its test files aren't written here yet",kept:null,again:"all"};let a=e.wrote.length,i=e.refused.length,s=a+(e.unchanged?.length??0),r=s+i,l=e.saved?new Set(e.saved):null,g=l?e.wrote.filter(S=>!l.has(S.id)).length:0,c=S=>`${g} ${g===1?"test":"tests"} ${S?"it imports":"they import"}`,p=a===0?null:n||i===0&&s>a?`\u2692 wrote ${a===1?"1 test file that was":`${a} test files that were`} missing or out of date here`:i>0?`\u2692 wrote ${a} of the ${r} test files`:g>0?`\u2692 wrote ${a} test files, for ${a-g===1?`the saved test and ${c(!0)}`:`${a-g} saved tests and ${c(!1)}`}`:a===1?"\u2692 wrote 1 test file, for the saved test":`\u2692 wrote ${a} test files, one for each saved test`,u={...Lt(e.replaced),...Dt(e.needed,e.saved?.length??r)};if(i===0)return{line:p,lines:[],support:!1,summary:null,kept:null,again:0,...u};let w=[{text:`warning: ${i===r?`${i===1?"1 test file wasn't":`${i} test files weren't`} written`:`${i} of the ${r} test files ${i===1?"wasn't":"weren't"} written`}`,tone:"warning"}];for(let S of e.refused)w.push({text:S.title?` "${S.title}"`:" a test with no title",tone:"detail"},{text:` ${ee(S)}`,tone:"detail"});let h=e.refused.filter(et).length;h>0&&w.push({text:`next: then, to write ${h===1?"it":"them"} (nothing is saved twice), run:`,tone:"plain"},d);let f=e.refused.filter(S=>S.kind==="edited");if(f.length>0){let S=f.length===1,E=tt(f,o.testManager);if(E.length>0){w.push({text:E.length===1?"next: to send your edit to its test case in Test Manager, run:":"next: to send your edits to their test cases in Test Manager, run:",tone:"plain"});for(let A of E)w.push({text:` kane-cli testmd run ${pe(A.file)}`,tone:"plain"})}let b=`${E.length>0?"or, to":"next: to"} get the project's ${S?"version, move it":"versions, move them"} out of this folder`;h>0?w.push({text:`${b} and save again`,tone:"plain"}):w.push({text:`${b}, then run:`,tone:"plain"},d)}let $=i-f.length;return{line:p,lines:w,support:e.refused.some(S=>Ut.has(S.kind)),summary:s>0?`${s} of the ${r} test files written here`:$===0?null:f.length>0?`${$} of the ${r} test files ${$===1?"isn't":"aren't"} written here yet`:r===1?"its test file isn't written here yet":"its test files aren't written here yet",kept:f.length===0?null:f.length>1?`${f.length} test files here keep your edits`:r===1?"its test file here keeps your edit":"1 test file here keeps your edit",again:h,...u}}function hs(e,t,n){if(!e||!t||t.again===0)return null;let o=`write ${t.again===1?"the test file":"the test files"}`;return e.error!==null?he(e.error.code,n).remedy?null:`next: to finish them and ${o} (nothing is saved twice), run:`:e.waiting>0?`next: then, to update ${e.waiting===1?"the test case":"the test cases"} and ${o} (nothing is saved twice), run:`:null}function ps(e,t,n={}){let o=`kane-cli context sessions save ${t} --mode agent`;if(e==="unread")return{written:[],refused:[],error:"TEST_FILES_NOT_WRITTEN",next:[{cmd:o,why:"writes the test files here"}]};let d=e.refused.some(et),a=e.refused.filter(r=>r.kind==="edited"),i=a.length===0?"":a.length===1?", and the project's version of a kept file once it's moved out of its folder":", and the project's version of the kept files once they're moved out of their folder",s=[...d?[{cmd:o,why:`writes the test files not written here${i}`}]:[],...tt(a,n.testManager).map(r=>({cmd:`kane-cli testmd run ${M(r.file)} --agent`,why:"sends your edit to its test case in Test Manager"})),...a.length>0&&!d?[{cmd:o,why:"writes the project's version, once the file is moved out of its folder"}]:[]];return{written:e.wrote.map(r=>r.path),refused:e.refused.map(r=>({test:r.id,title:r.title,reason:ee(r),...r.kind==="edited"&&r.file?{file:r.file}:{}})),...e.replaced?.length?{replaced:e.replaced.map(r=>({test:r.test,file:r.file,replaced_by:r.replacedBy}))}:{},...e.needed?.variables.length?{variables_needed:{file:e.needed.file,variables:e.needed.variables}}:{},...e.needed?.noStartPage.length?{no_start_page:e.needed.noStartPage.map(r=>({test:r.test,...r.file?{file:r.file}:{}}))}:{},...s.length>0?{next:s}:{}}}var Mt={ac:"an acceptance criterion",scenario:"a scenario",test:"a test",gap:"an open question",source:"a source",stylenote:"a style note"},T=(e,t)=>e?`"${e}"`:P(t),Ge=(e,t,n)=>`${e} ${e===1?t:n}`,fs={trusted:"approved",derived:"proposed",archived:"archived"},ws={yes:"yes",source_changed:"no: its source changed",source_removed:"no: its source was removed",tests_out_of_date:"no: its tests are out of date",designed_from_changed:"no: what it was designed from changed",archived:"-"},ys={source_changed:"its source changed",source_removed:"its source was removed",tests_out_of_date:"changed after its tests were designed"},y=e=>e?`"${e}"`:"this session's project",_=(e,t)=>`kane-cli design tests --use-case ${e}${t}`,ae=e=>e?"its source's change was put off in an earlier review; to take it up":"to review its source's change",He=e=>e.split(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as p}from"./chunk-73Y6T2UK.js";import{Ha as l}from"./chunk-
|
|
2
|
+
import{a as p}from"./chunk-73Y6T2UK.js";import{Ha as l}from"./chunk-RHQLDNZL.js";import{c as u}from"./chunk-V24LUINK.js";import{existsSync as d,mkdirSync as m,readFileSync as j,rmSync as g,writeFileSync as y,statSync as I}from"fs";import{dirname as f,join as n}from"path";var o=n(".testmuai","assurance.json");function N(e,r=u()){let t={kind:"local",dir:p(e)},s=r.trim().replace(/\/+$/,"");if(!s)return t;let a=d(n(e,o));if(d(t.dir))return a?{kind:"refuse",code:"BOTH_STORES",refusal:l.bothStores(i(n(e,o))?.projectName??null)}:t;if(!a)return{kind:"pick",latticeUrl:s};let c=i(n(e,o));return c===null?{kind:"refuse",code:"PROJECT_FILE_UNREADABLE",refusal:l.linkUnreadable()}:{kind:"remote",latticeUrl:s,projectId:c.projectId,projectName:c.projectName}}function P(e){return i(n(e,o))?.lastUserId??null}function R(e,r){let t=i(n(e,o));t!==null&&t.lastUserId!==r&&S(e,{...t,lastUserId:r})}function i(e){try{let r=JSON.parse(j(e,"utf8"));return typeof r!="object"||r===null||Array.isArray(r)||typeof r.projectId!="string"||r.projectId===""||typeof r.projectName!="string"?null:{projectId:r.projectId,projectName:r.projectName,writtenBy:typeof r.writtenBy=="string"?r.writtenBy:"",...typeof r.lastUserId=="string"?{lastUserId:r.lastUserId}:{}}}catch{return null}}function O(e){try{return!I(n(e,f(o))).isDirectory()}catch{return!1}}function S(e,r){let t=n(e,o);m(f(t),{recursive:!0}),y(t,JSON.stringify(r,null,2)+`
|
|
3
3
|
`)}function A(e){g(n(e,o),{force:!0})}export{o as a,N as b,P as c,R as d,i as e,O as f,S as g,A as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{h as m,i as h,j as _,o as w,p as E,q as l,r as f,s as u,t as d,u as x}from"./chunk-
|
|
2
|
+
import{h as m,i as h,j as _,o as w,p as E,q as l,r as f,s as u,t as d,u as x}from"./chunk-SLISNOG6.js";import{a as g,b as y}from"./chunk-KGNE5CIM.js";function C(t,e){let r=typeof t.body?.retry_after_s=="number"?t.body.retry_after_s:null;if(t.code==="TOO_SOON")return`${r!==null?`in ${Math.max(1,Math.ceil(r/60))} min, `:"later, "}kane-cli explore context sync ${e}`;if(t.code==="CONTEXT_OFF")return`kane-cli explore context on ${e}`}async function b(t,e,r){if(r.out&&!r.projectNames)return;let s=await new y({baseUrl:t.controllerBaseUrl,auth:t.basic,timeoutMs:w}).viewSummary(e),n=typeof s?.project_id=="string"?s.project_id:"";if(n)return(await E(r,t)([n]))[n]??n.slice(0,8)}function k(t){let e=typeof t.body?.retry_after_s=="number"?t.body.retry_after_s:null;return t.code==="TOO_SOON"&&e!==null?`TOO_SOON: the last cut was taken too recently (a run's end takes one too); the next can start in ${Math.max(1,Math.ceil(e/60))} min`:t.code==="CONTEXT_OFF"?`CONTEXT_OFF: assurance context is off for this exploration${typeof t.body?.off_reason=="string"?` (${t.body.off_reason})`:""}; turn it on with explore context on`:u(t)}async function N(t,e,r,s={}){let n=f(s,e,r),i=await l(r,`explore context ${t}`);if(!i.ok)return n.fail(i.error);let a=d(i);try{if(t==="sync"){let o=await a.syncContext(e);if(!n.tty)n.event({type:"explore_context_sync",exploration_id:e,state:o.state,job_id:o.job_id??null,cut:o.cut??null,trigger:o.trigger??null,running_job_id:o.running_job_id??null,hx_job_link:o.hx_job_link??null,...o.state==="failed"?{error:o.error??null}:{}});else if(o.state!=="failed")for(let O of h(e,o))n.out(O);return o.state==="failed"?n.fail(T(e,o),1,j(e,o)):n.ok()}let c=t==="status"?await a.getContext(e):await a.setContext(e,t==="on");if(!n.tty)n.event({type:"explore_context",exploration_id:e,action:t,context:c});else if(t==="status")for(let o of m(c,{project:await b(i,e,s)}))n.out(o);else for(let o of _(e,c,t,await b(i,e,s)))n.out(o);return n.ok()}catch(c){let o=A(c,t,e);return n.fail(o.message,o.code,o.next)}}function A(t,e,r){if(t instanceof g){if(t.code==="NO_ENDED_RUN")return{message:"NO_ENDED_RUN: no run of this exploration has ended yet; the first assurance job runs when one ends",code:1,next:"run it first: kane-cli explore run \u2026, then sync"};if(t.status===404)return{message:`exploration ${r} not found, or this service has no assurance context yet`,code:2};if(t.status===501)return{message:`this service has no assurance context yet (exploration ${r})`,code:2};if(t.code==="NOT_CONFIGURED")return{message:"NOT_CONFIGURED: assurance jobs are not set up on this service (no HyperExecute or report URL); context stays on and runs once they are",code:1};if(t.status===401||t.status===403)return{message:u(t),code:2};if(t.status<500){let s=C(t,r);return{message:k(t),code:1,...s?{next:s}:{}}}}return{message:`could not ${e==="status"?"read":e==="sync"?"sync":"change"} the assurance context: ${u(t)}`,code:1}}function T(t,e){return`${e.error?.code??"LAUNCH_FAILED"}: the assurance job could not launch${e.error?.message?` (${e.error.message})`:""}; explore context status ${t} shows it`}function j(t,e){let r=e.error?.code??"LAUNCH_FAILED";return`try again: kane-cli explore context sync ${t}${r==="HX_TRIGGER_FAILED"?"; or run with --local-orchestration":""}`}var $="usage: kane-cli explore context <status|on|off|sync> <exploration-id> (or explore context <exploration-id> on a terminal for the panel)";async function F(t,e,r={}){let s=f(r,t??null,e);if(!s.tty||!t)return s.fail($);let n=await l(e,"explore context");if(!n.ok)return s.fail(n.error);let{runContextPanel:i}=await import("./explore-context-tty-QLMZGYBX.js"),a=typeof e.env=="string"?e.env:"prod";return await i({client:d(n),explorationId:t,env:a})==="exit"?130:0}function p(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function U(t){let e=x(t.command("context").description("An exploration's assurance context (on by default): on, off, status, sync; with only the id, the panel on a terminal").argument("[exploration-id]","The exploration (no action: the context panel on a terminal)")).action(async(s,n)=>{process.exitCode=await F(s,p(n))}),r=[["status","Whether context is on, what is pending or running, and what the last assurance job did"],["on","Turn assurance context on (catches up from the newest ended run)"],["off","Turn assurance context off: the next cut is skipped; nothing already saved is deleted"],["sync","Ask for an assurance job now: launched, pending behind a running job, or up to date"]];for(let[s,n]of r)x(e.command(s).description(n).argument("<exploration-id>","The exploration")).action(async(i,a)=>{process.exitCode=await N(s,i,{...p(e.opts()),...p(a)})})}export{A as a,T as b,U as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{g as D}from"./chunk-
|
|
2
|
+
import{g as D}from"./chunk-Y3RDLUH5.js";import{a as $}from"./chunk-37KFCYHG.js";import{a as E}from"./chunk-4QTH7VYE.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
|
|
3
3
|
|
|
4
4
|
`))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
|
|
5
5
|
`))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".md",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`
|