@testmuai/kane-cli 0.10.0 → 0.10.3
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-Z26BOE5U.js +2 -0
- package/dist/{ChromeProfilePicker-FWPUDKD6.js → ChromeProfilePicker-ODRIAXL3.js} +1 -1
- package/dist/{CliFeedbackPrompt-D5L2DO6A.js → CliFeedbackPrompt-JWCTMIGI.js} +1 -1
- package/dist/{CliUploadProgress-HQX57WE6.js → CliUploadProgress-XFRRFRL4.js} +1 -1
- package/dist/{ConfigView-DGQXKEON.js → ConfigView-6JF4DOJN.js} +1 -1
- package/dist/EvidenceViewOffer-6344EX74.js +2 -0
- package/dist/FolderPicker-4PCYHE75.js +2 -0
- package/dist/InfoBox-NJ2DL7YC.js +2 -0
- package/dist/{LinksBox-WZ4RAMSH.js → LinksBox-HNDNFVUT.js} +1 -1
- package/dist/{ProfilesView-AGRNPGSW.js → ProfilesView-DEJKJOHY.js} +1 -1
- package/dist/ProjectPicker-DTWMWOH7.js +2 -0
- package/dist/SaveSessionPrompt-3GCLB3ZT.js +2 -0
- package/dist/SingleShotApp-HMOXO5DW.js +2 -0
- package/dist/{SummaryBox-XQJUZBAN.js → SummaryBox-7PPDMSSM.js} +1 -1
- package/dist/TestMdRunView-QLKRUU4V.js +2 -0
- package/dist/TestrunEvidenceTable-T2JUB4TE.js +2 -0
- package/dist/{WhoamiView-JQCURK2M.js → WhoamiView-H7JNLLCY.js} +1 -1
- package/dist/{app-download-OU6AGH2X.js → app-download-GKRF2EIM.js} +1 -1
- package/dist/{assurance-job-ZI3L6I4F.js → assurance-job-F4L3T4VJ.js} +1 -1
- package/dist/{auth-7Z54TMQQ.js → auth-WBIEHHDS.js} +1 -1
- package/dist/{binary-S5YL5GJD.js → binary-K3XMILST.js} +1 -1
- package/dist/{bind-LIV72SEZ.js → bind-SSHAZAB3.js} +1 -1
- package/dist/{bootstrap-3V6TOO6I.js → bootstrap-XGKU4WXB.js} +1 -1
- package/dist/bridge-2UHJOVLX.js +2 -0
- package/dist/{catalog-I3PC6LT6.js → catalog-YCU6OHNV.js} +1 -1
- package/dist/{catalog-client-WKYG3JN6.js → catalog-client-MVEEHTG2.js} +1 -1
- package/dist/{changelog-IHNWFYWY.js → changelog-5UB3AQT6.js} +1 -1
- package/dist/chat-committer-ZKEKJA2R.js +2 -0
- package/dist/chat-controller-FXRJXUG3.js +2 -0
- package/dist/child-JHYENXE7.js +2 -0
- package/dist/{chunk-ZTAZ2R5Z.js → chunk-23DKB2MT.js} +1 -1
- package/dist/{chunk-UX2CDUPE.js → chunk-2JFRN62I.js} +2 -2
- package/dist/chunk-2RBMQTYS.js +26 -0
- package/dist/{chunk-VVCZRCRD.js → chunk-2TK4MDF2.js} +1 -1
- package/dist/{chunk-G3J4XY3Z.js → chunk-32HED7X2.js} +1 -1
- package/dist/{chunk-GRURFGBP.js → chunk-32MFECUA.js} +1 -1
- package/dist/{chunk-N3KTLWJL.js → chunk-35BG2EMW.js} +1 -1
- package/dist/{chunk-4523YDTG.js → chunk-35WUYKGO.js} +1 -1
- package/dist/{chunk-KDR662D2.js → chunk-3KY7HHQU.js} +1 -1
- package/dist/{chunk-UNWPBMVM.js → chunk-3MD2XLE7.js} +2 -2
- package/dist/{chunk-YKL5H4K6.js → chunk-3NWUXRSI.js} +1 -1
- package/dist/{chunk-QQI6N3FO.js → chunk-3RO2YGKH.js} +1 -1
- package/dist/{chunk-AGXAJ2II.js → chunk-3ZC7GSMM.js} +1 -1
- package/dist/{chunk-I2MC6VVX.js → chunk-4C7WVQOD.js} +1 -1
- package/dist/{chunk-VQZOKTJ2.js → chunk-4CJQ7XZP.js} +1 -1
- package/dist/{chunk-7KX2BHKG.js → chunk-4KCYNP2K.js} +1 -1
- package/dist/{chunk-AUBSLPJZ.js → chunk-4KL3TSTT.js} +5 -5
- package/dist/{chunk-AG5XJWEV.js → chunk-4UX5N7YI.js} +1 -1
- package/dist/{chunk-WERIGVOH.js → chunk-5F5IVART.js} +1 -1
- package/dist/{chunk-RFEON5GN.js → chunk-5XVWT6UK.js} +1 -1
- package/dist/{chunk-FBQ7PQJV.js → chunk-5YYCCM6K.js} +1 -1
- package/dist/{chunk-SBR6D6GS.js → chunk-6FFX4S7N.js} +1 -1
- package/dist/{chunk-DHYGCHKB.js → chunk-6HRNG4CK.js} +1 -1
- package/dist/{chunk-HBVHIEPB.js → chunk-6QCCTZO3.js} +1 -1
- package/dist/{chunk-GI2JPIX5.js → chunk-6QH75BPJ.js} +1 -1
- package/dist/{chunk-5R3ODQHH.js → chunk-6SD4XTYC.js} +1 -1
- package/dist/{chunk-J4LQAT5P.js → chunk-7LYLJ75Z.js} +1 -1
- package/dist/{chunk-Y3YULFCK.js → chunk-7RELCXRW.js} +1 -1
- package/dist/{chunk-GXMD23XB.js → chunk-7SU53QGU.js} +1 -1
- package/dist/{chunk-DTYT6KBO.js → chunk-7Y55CO42.js} +1 -1
- package/dist/{chunk-2L3A5NKZ.js → chunk-7YV2FCN4.js} +1 -1
- package/dist/{chunk-ULGBK4NS.js → chunk-A2DODRHG.js} +1 -1
- package/dist/{chunk-EVZLINBN.js → chunk-AHT2ORJT.js} +1 -1
- package/dist/{chunk-RDH3E25Q.js → chunk-AT7AT3AR.js} +2 -2
- package/dist/{chunk-ZI3X7DI2.js → chunk-AVLYSNEG.js} +1 -1
- package/dist/{chunk-GET4DINR.js → chunk-BBJAKSA7.js} +1 -1
- package/dist/{chunk-CBVHP7JB.js → chunk-BJO6J5X2.js} +1 -1
- package/dist/{chunk-G3CYFCSR.js → chunk-BLVDV3QQ.js} +1 -1
- package/dist/{chunk-2N75WO7Y.js → chunk-C4KAPGBS.js} +1 -1
- package/dist/{chunk-XLQ4F6BI.js → chunk-CB2BWDHG.js} +2 -2
- package/dist/chunk-CB344EDO.js +2 -0
- package/dist/chunk-CCOD4GQJ.js +2 -0
- package/dist/{chunk-JSLKCCD2.js → chunk-CNHKZE4F.js} +1 -1
- package/dist/{chunk-CJE7PKRV.js → chunk-CQDCNP7V.js} +1 -1
- package/dist/{chunk-3OVFKUXV.js → chunk-CTHUX7O4.js} +1 -1
- package/dist/{chunk-4JWJH6TB.js → chunk-DC5F2ADJ.js} +1 -1
- package/dist/chunk-DIOK3SER.js +34 -0
- package/dist/{chunk-EQWMOGLO.js → chunk-DQXQJJOP.js} +2 -2
- package/dist/{chunk-EH43VWVR.js → chunk-DXIQVBMI.js} +1 -1
- package/dist/{chunk-WZLDFEWR.js → chunk-E4GIGM5V.js} +1 -1
- package/dist/{chunk-K3OSK6PB.js → chunk-EBJW6POT.js} +1 -1
- package/dist/{chunk-MYZHOBS4.js → chunk-EHB55V23.js} +1 -1
- package/dist/{chunk-RARD6TC6.js → chunk-EJGCIGQY.js} +1 -1
- package/dist/{chunk-OR2B6T3B.js → chunk-ENRFXGID.js} +1 -1
- package/dist/{chunk-3ZPEQDXZ.js → chunk-ERRIDBE7.js} +1 -1
- package/dist/{chunk-HGVM2OZU.js → chunk-EZMRWXRT.js} +1 -1
- package/dist/chunk-F2F257PU.js +6 -0
- package/dist/{chunk-AUJSC7PU.js → chunk-FNUGDPTS.js} +1 -1
- package/dist/{chunk-MPEIMWQI.js → chunk-FOLUB336.js} +1 -1
- package/dist/{chunk-HHW6MRU3.js → chunk-G4K3TP2I.js} +1 -1
- package/dist/{chunk-P2ZQDQDB.js → chunk-GAKBHNC4.js} +1 -1
- package/dist/{chunk-DPGOAFKF.js → chunk-GBQ4K25P.js} +1 -1
- package/dist/{chunk-PCDIEYV6.js → chunk-GEZVC4S3.js} +1 -1
- package/dist/{chunk-PL3SG3M2.js → chunk-GJXO6FF7.js} +1 -1
- package/dist/{chunk-252GEI3H.js → chunk-GLM5UGTF.js} +1 -1
- package/dist/{chunk-JOCEZK2M.js → chunk-GQAWZEA4.js} +1 -1
- package/dist/{chunk-45URQUAK.js → chunk-GXQYFOBD.js} +1 -1
- package/dist/{chunk-PBWYQR5I.js → chunk-HBLHKQR7.js} +1 -1
- package/dist/chunk-HC6VLPUB.js +5 -0
- package/dist/{chunk-K2PLULJD.js → chunk-HRIDAK6Y.js} +1 -1
- package/dist/{chunk-D6CS62O7.js → chunk-HV2CDY4K.js} +1 -1
- package/dist/{chunk-P2LDAW3C.js → chunk-HVOXMCKE.js} +1 -1
- package/dist/{chunk-4I7YN6YY.js → chunk-HYJVYYAZ.js} +2 -2
- package/dist/{chunk-GYDJO32R.js → chunk-IEHJG6J4.js} +1 -1
- package/dist/{chunk-GGS3ATPB.js → chunk-IZ66FKPC.js} +1 -1
- package/dist/{chunk-QMOGBKJM.js → chunk-J4FIESTB.js} +1 -1
- package/dist/{chunk-436FZ4KG.js → chunk-JBKHX5ES.js} +1 -1
- package/dist/{chunk-EX6ORR7P.js → chunk-JNPFEBUR.js} +1 -1
- package/dist/{chunk-AU26ZZTX.js → chunk-JTNEF5ZP.js} +1 -1
- package/dist/{chunk-5IO5ZC4S.js → chunk-KBGMQYMD.js} +1 -1
- package/dist/{chunk-WX4VGH5Q.js → chunk-KCXLRR3Q.js} +1 -1
- package/dist/{chunk-4R4YUOVY.js → chunk-KKLCXRW6.js} +1 -1
- package/dist/{chunk-YGMQXS2J.js → chunk-KL7XFNSD.js} +1 -1
- package/dist/{chunk-MJKRJGER.js → chunk-KQ4XKTIZ.js} +1 -1
- package/dist/{chunk-I2VU2DTS.js → chunk-L3BUPFAQ.js} +4 -4
- package/dist/{chunk-ZZNQIFFI.js → chunk-LHJSIHLC.js} +1 -1
- package/dist/{chunk-2GE5X2A5.js → chunk-LLQWEGXD.js} +1 -1
- package/dist/{chunk-PQXYHI5W.js → chunk-LPJKNX6D.js} +1 -1
- package/dist/{chunk-ZGQM6KWN.js → chunk-LRNUGKYH.js} +1 -1
- package/dist/chunk-LTPOMMAB.js +2 -0
- package/dist/{chunk-MHB6DMKZ.js → chunk-LUA25RYS.js} +1 -1
- package/dist/{chunk-2PZKMT3I.js → chunk-LV7224DG.js} +1 -1
- package/dist/{chunk-X3J4CC27.js → chunk-LXK4B2FE.js} +1 -1
- package/dist/{chunk-YH4VZVHJ.js → chunk-LZGAFKYH.js} +1 -1
- package/dist/{chunk-3QICDXY5.js → chunk-LZPYIFHZ.js} +1 -1
- package/dist/{chunk-4BUEOKFV.js → chunk-M2E5CPPV.js} +1 -1
- package/dist/{chunk-65BG6GAE.js → chunk-M7A66MSK.js} +1 -1
- package/dist/{chunk-JX5NVKTV.js → chunk-MD3RABID.js} +1 -1
- package/dist/{chunk-QECTIQAC.js → chunk-MEBEVHGP.js} +1 -1
- package/dist/{chunk-52VCA4K2.js → chunk-MEMXFTLD.js} +1 -1
- package/dist/{chunk-U7NRZBB5.js → chunk-MINDIQET.js} +1 -1
- package/dist/{chunk-HJLMH7ZM.js → chunk-MUX2A37P.js} +1 -1
- package/dist/{chunk-YKOEABP2.js → chunk-N7IWR45S.js} +1 -1
- package/dist/{chunk-WQR2GYP7.js → chunk-ND6OP3O2.js} +1 -1
- package/dist/{chunk-URAYFJGM.js → chunk-NHGPMYM3.js} +1 -1
- package/dist/{chunk-ZKPY3AXW.js → chunk-NI3TIAD7.js} +1 -1
- package/dist/{chunk-JCSVBD4F.js → chunk-NPAUSUNM.js} +1 -1
- package/dist/{chunk-XMALVGH7.js → chunk-NRAPCFI2.js} +2 -2
- package/dist/{chunk-567D5ZTO.js → chunk-NZJSGINB.js} +16 -16
- package/dist/{chunk-A4BB6GLN.js → chunk-OBNVGD5H.js} +1 -1
- package/dist/{chunk-BRVIK3BU.js → chunk-OCMPWCKQ.js} +1 -1
- package/dist/{chunk-4SJAOAYY.js → chunk-OCVDMZWB.js} +1 -1
- package/dist/{chunk-JRSEAXFE.js → chunk-OHGL4GEJ.js} +1 -1
- package/dist/{chunk-YYVBE6W2.js → chunk-OOGKX4Y6.js} +1 -1
- package/dist/{chunk-QWZJ5QDO.js → chunk-OTMHCHH6.js} +2 -2
- package/dist/{chunk-Z5BFCTHI.js → chunk-OZNYQONA.js} +2 -2
- package/dist/{chunk-EPJ5SJL2.js → chunk-PB6RXDWQ.js} +2 -2
- package/dist/{chunk-TZVPDGJD.js → chunk-PCQK62MP.js} +1 -1
- package/dist/{chunk-Z777GGHB.js → chunk-PI7OXS62.js} +1 -1
- package/dist/{chunk-MW2WNYJO.js → chunk-PRBWZXFA.js} +2 -2
- package/dist/{chunk-2SY2NCOP.js → chunk-PTLOOVV4.js} +1 -1
- package/dist/{chunk-EC5IP5HZ.js → chunk-Q4ALB7SH.js} +1 -1
- package/dist/{chunk-FYCD765R.js → chunk-Q4JV4U65.js} +58 -58
- package/dist/{chunk-CJQUVHHS.js → chunk-Q4SMITTV.js} +1 -1
- package/dist/{chunk-NJCN6LP5.js → chunk-QE4AWNOV.js} +6 -6
- package/dist/{chunk-BY2B4YJN.js → chunk-QEM5ZRDN.js} +1 -1
- package/dist/{chunk-VA3BSIUQ.js → chunk-QHH42RH5.js} +1 -1
- package/dist/{chunk-FPPVNF53.js → chunk-R6TFRAMZ.js} +1 -1
- package/dist/{chunk-3T2TYDPT.js → chunk-RNHSULQM.js} +1 -1
- package/dist/{chunk-32Y6QVFG.js → chunk-SALZ6WSF.js} +1 -1
- package/dist/chunk-SB26HQO7.js +2 -0
- package/dist/{chunk-4NUSW4A2.js → chunk-SIHX5FW5.js} +1 -1
- package/dist/{chunk-LHQUCRCH.js → chunk-SJQTTEXQ.js} +1 -1
- package/dist/{chunk-W3NWHWK2.js → chunk-SMGRXKXX.js} +1 -1
- package/dist/{chunk-USJ3LUAL.js → chunk-SSOUYKVG.js} +1 -1
- package/dist/{chunk-2B75UL7Y.js → chunk-SVIIUKJ2.js} +1 -1
- package/dist/{chunk-7ZJWUWSN.js → chunk-SXBPUUQ5.js} +1 -1
- package/dist/{chunk-QVP4FSKT.js → chunk-T77LTLAD.js} +1 -1
- package/dist/{chunk-KRRZCY7U.js → chunk-TAY7J5VS.js} +1 -1
- package/dist/chunk-TD6GCEIK.js +2 -0
- package/dist/{chunk-VZA7BPCK.js → chunk-TM45NPWL.js} +1 -1
- package/dist/{chunk-ZY65IZJR.js → chunk-TM6VLC6V.js} +1 -1
- package/dist/{chunk-COJINPOK.js → chunk-TU2KPOW2.js} +2 -2
- package/dist/{chunk-JTJ7IPNI.js → chunk-TUSG7DIL.js} +1 -1
- package/dist/{chunk-3BSYOCSW.js → chunk-U2VYTVKV.js} +1 -1
- package/dist/{chunk-JQ7ZZQXC.js → chunk-UJ37XGSP.js} +3 -3
- package/dist/chunk-ULIIYKZB.js +7 -0
- package/dist/{chunk-LNHBZEDC.js → chunk-UWPG5MWM.js} +1 -1
- package/dist/{chunk-UUWSULIM.js → chunk-UXGMKRS4.js} +61 -60
- package/dist/{chunk-6DZ7LVOG.js → chunk-VCVEZEVS.js} +1 -1
- package/dist/{chunk-ZRDX2ARO.js → chunk-VKVYT6KZ.js} +2 -2
- package/dist/{chunk-B2WFW74J.js → chunk-VO2NNXKR.js} +1 -1
- package/dist/{chunk-B7JLM3IX.js → chunk-W54BX6HC.js} +1 -1
- package/dist/{chunk-IZ65ZPWY.js → chunk-W5HFUBXD.js} +1 -1
- package/dist/{chunk-TLOYTGVT.js → chunk-WE7HRAGO.js} +1 -1
- package/dist/{chunk-GRO6DLN3.js → chunk-WEJR2V7R.js} +1 -1
- package/dist/{chunk-YI4ESDAX.js → chunk-WIVKLNIO.js} +1 -1
- package/dist/chunk-WLEWXE6L.js +2 -0
- package/dist/{chunk-DBTMKBHU.js → chunk-X2MDL6S4.js} +1 -1
- package/dist/{chunk-MKPDF26Q.js → chunk-X45RZIAJ.js} +1 -1
- package/dist/{chunk-G2KTWFMU.js → chunk-X52YIWGG.js} +1 -1
- package/dist/{chunk-UEPJ26X2.js → chunk-X6FCXBXU.js} +1 -1
- package/dist/{chunk-LXM7VHYN.js → chunk-X7S7IGCV.js} +1 -1
- package/dist/{chunk-FVYIV36L.js → chunk-XKOVEMVZ.js} +1 -1
- package/dist/{chunk-3UHPVQLU.js → chunk-Y2HQMJGS.js} +1 -1
- package/dist/{chunk-4MNSP4EO.js → chunk-Y3RJHWNK.js} +1 -1
- package/dist/{chunk-A3TCFSCK.js → chunk-YCVEI7BT.js} +1 -1
- package/dist/{chunk-JGRXMTME.js → chunk-YDB72F4K.js} +1 -1
- package/dist/{chunk-7C4IEL5V.js → chunk-YILRYMMG.js} +1 -1
- package/dist/{chunk-7DFBOVUB.js → chunk-YJAQZMJT.js} +1 -1
- package/dist/{chunk-JGLADDRH.js → chunk-YNDELIXL.js} +1 -1
- package/dist/{chunk-WKZLK57W.js → chunk-YPGZ5E4I.js} +1 -1
- package/dist/{chunk-NTXFPNAP.js → chunk-YQZ736IQ.js} +1 -1
- package/dist/{chunk-FPVGA6XT.js → chunk-YVVFXBT5.js} +1 -1
- package/dist/{chunk-JT6WLJSV.js → chunk-YWWVF5OU.js} +1 -1
- package/dist/{chunk-RLOJH5O6.js → chunk-Z24SD2EJ.js} +1 -1
- package/dist/{chunk-ENG2UTMX.js → chunk-Z36KVIRR.js} +1 -1
- package/dist/{chunk-JFBEHCJN.js → chunk-Z47ZEFH7.js} +1 -1
- package/dist/{chunk-6NFOH4AC.js → chunk-ZAQGIC33.js} +1 -1
- package/dist/{chunk-GGV336P5.js → chunk-ZCBOHWN3.js} +1 -1
- package/dist/{chunk-AIGQCMGY.js → chunk-ZCL7XIVS.js} +1 -1
- package/dist/{chunk-ORNVIEUA.js → chunk-ZDCXWEQG.js} +1 -1
- package/dist/{chunk-6TNLITJO.js → chunk-ZHAMVLQZ.js} +1 -1
- package/dist/{chunk-FLOQ5NZL.js → chunk-ZIHQ5JGB.js} +4 -4
- package/dist/{chunk-PTISAIZW.js → chunk-ZMIKNNO6.js} +1 -1
- package/dist/{chunk-H4KPNGY4.js → chunk-ZMWTRXFH.js} +1 -1
- package/dist/{chunk-ONZ2CSTZ.js → chunk-ZPU3WAC4.js} +1 -1
- package/dist/commands-JBFLLT7A.js +2 -0
- package/dist/{committer-26UZDYSA.js → committer-UO3B3S5Y.js} +1 -1
- package/dist/{config-B472DZSR.js → config-7WTZPMAH.js} +1 -1
- package/dist/cover-cmd-DU6ZYJFL.js +2 -0
- package/dist/{credentials-TLT3RQOO.js → credentials-5WIFF5DG.js} +1 -1
- package/dist/{deps-bundle-CMTIWBS5.js → deps-bundle-BLLJ2BQ4.js} +1 -1
- package/dist/{deps-resolve-XLFZK74A.js → deps-resolve-WQ6J6RLI.js} +1 -1
- package/dist/{design-chat-I7X3QDDY.js → design-chat-ZICGVYIH.js} +1 -1
- package/dist/design-committer-7YIPFKMO.js +2 -0
- package/dist/design-headless-HYWZIIDS.js +2 -0
- package/dist/{design-remote-UDC5FP45.js → design-remote-HPX4VZ63.js} +2 -2
- package/dist/device-env-4P4GUVBW.js +2 -0
- package/dist/dispatch-BV6XMCN3.js +2 -0
- package/dist/{doctor-UHFCIM4B.js → doctor-Z2YQ2DBX.js} +1 -1
- package/dist/{docx-convert-N4KMLLKO.js → docx-convert-DO5AQYD3.js} +1 -1
- package/dist/{dossier-6KMKEIXV.js → dossier-5XKNAK6Q.js} +1 -1
- package/dist/evidence-BJIID6VT.js +2 -0
- package/dist/evidence-presentation-LSFOZGLH.js +2 -0
- package/dist/evolve-cmd-GZCUSCEK.js +2 -0
- package/dist/evolve-remote-LILOAHYH.js +2 -0
- package/dist/{explain-cmd-R67B4YR3.js → explain-cmd-KNDORU2D.js} +1 -1
- package/dist/{explain-cmd-235TY7QX.js → explain-cmd-LXIVHGN7.js} +1 -1
- package/dist/explore-SA2P3SGX.js +2 -0
- package/dist/{explore-context-tty-YXEFT32U.js → explore-context-tty-PERKIWXD.js} +1 -1
- package/dist/{explore-entry-V6L5FSP4.js → explore-entry-E6EY3VV3.js} +4 -4
- package/dist/{explore-live-N5VBLBUI.js → explore-live-XIWWUV52.js} +1 -1
- package/dist/{explore-run-tty-ZZQ33GNA.js → explore-run-tty-M56I23IF.js} +2 -2
- package/dist/{extract-bind-BTINHHE5.js → extract-bind-LZ22VFKB.js} +3 -3
- package/dist/extract-chat-Z64LEAJ5.js +2 -0
- package/dist/{extract-cmd-45OZETCM.js → extract-cmd-46E2XDWZ.js} +2 -2
- package/dist/extract-headless-XLS56LMN.js +2 -0
- package/dist/{feeder-L55TH2NC.js → feeder-NGWIPZ26.js} +1 -1
- package/dist/folder-flags-ZIDJVDKX.js +2 -0
- package/dist/gaps-cmd-XYOBJVTO.js +3 -0
- package/dist/gate-AK44VDHC.js +2 -0
- package/dist/gate-NB5CJMTN.js +2 -0
- package/dist/{generate-headless-DAH3HHRQ.js → generate-headless-HXAVEAEZ.js} +2 -2
- package/dist/hold-passthrough-JGHWMYDM.js +2 -0
- package/dist/{impact-cmd-3VFJAKYK.js → impact-cmd-TJTUFAFO.js} +2 -2
- package/dist/index.js +4159 -190
- package/dist/ingest-ZHHHBUXR.js +2 -0
- package/dist/{ingest-cmd-YSEH5EPU.js → ingest-cmd-OJSKTSQK.js} +3 -3
- package/dist/ingest-remote-2WM6PYUW.js +2 -0
- package/dist/install-JBWBF3WX.js +2 -0
- package/dist/{interactive-bind-P3GTFIZM.js → interactive-bind-SOD7VTAY.js} +4 -4
- package/dist/{interactive-remote-PBRQHTAF.js → interactive-remote-7ZSTI66T.js} +1 -1
- package/dist/lane-CNGO7LH5.js +2 -0
- package/dist/lattice-auth-UQPFQSG7.js +2 -0
- package/dist/{lifecycle-cmd-PUNFWKV5.js → lifecycle-cmd-DGIO3VAO.js} +1 -1
- package/dist/{list-cmd-RD7YBF4S.js → list-cmd-HQIN3HX4.js} +1 -1
- package/dist/{list-commands-UZELZAB3.js → list-commands-OFRRBU3D.js} +1 -1
- package/dist/{list-remote-KGKXPCQA.js → list-remote-EFCET42K.js} +1 -1
- package/dist/{locks-cmd-LXZ6I4QG.js → locks-cmd-AZKCSGHI.js} +1 -1
- package/dist/{logical-ids-D5PFYY4C.js → logical-ids-74PLU3VR.js} +1 -1
- package/dist/login-flow-SYKXXDLH.js +2 -0
- package/dist/{maintenance-cmd-WRWBCP3R.js → maintenance-cmd-X5247RSJ.js} +1 -1
- package/dist/{mobile-prompts-Z7NQHRGP.js → mobile-prompts-I66ENBDW.js} +1 -1
- package/dist/{objective-variable-gate-3Z7DNVVC.js → objective-variable-gate-V5HHFOUS.js} +1 -1
- package/dist/{onboarding-ZP4XDYEO.js → onboarding-6HIP3KW6.js} +1 -1
- package/dist/open-provider-XDJKT3W3.js +2 -0
- package/dist/pdf-convert-YB6PJFMI.js +2 -0
- package/dist/persist-recorded-session-RSSMTVF3.js +3 -0
- package/dist/phase-seed-ZZSJME7M.js +2 -0
- package/dist/pipeline-NTJDH5TC.js +2 -0
- package/dist/{policy-commands-TY6WOR73.js → policy-commands-4PUGESCW.js} +1 -1
- package/dist/{prepare-target-EVL2QSXA.js → prepare-target-AI3GGZF6.js} +1 -1
- package/dist/{pull-cmd-QJQANBAW.js → pull-cmd-NRVB5ZN7.js} +1 -1
- package/dist/{pull-route-AIOTLA3D.js → pull-route-FWCZW76M.js} +1 -1
- package/dist/readmodel-TRV4E3MW.js +2 -0
- package/dist/real-device-run-NQ7RNH7C.js +2 -0
- package/dist/{reconcile-cmd-IJTQAJZX.js → reconcile-cmd-7B7THAFJ.js} +4 -4
- package/dist/reconcile-deps-UDQBWSLE.js +2 -0
- package/dist/{reconcile-remote-23D6SXXT.js → reconcile-remote-3W6ZTO3G.js} +2 -2
- package/dist/{recording-banner-MNRMMEX4.js → recording-banner-WVDTWTSE.js} +1 -1
- package/dist/registry-PFOSXOIH.js +2 -0
- package/dist/remote-entry-BZU4NFNS.js +2 -0
- package/dist/{remote-mode-AFNCN6EE.js → remote-mode-NXUKDUXG.js} +1 -1
- package/dist/{remote-words-RCNFI2TQ.js → remote-words-JRDDNOZ6.js} +1 -1
- package/dist/{require-project-folder-7UH43GHI.js → require-project-folder-3DTI2CVB.js} +1 -1
- package/dist/{resolve-run-intent-XEWFYMGN.js → resolve-run-intent-QCL7QXIB.js} +1 -1
- package/dist/{resolver-QMPX6RBR.js → resolver-CDF7QKVD.js} +1 -1
- package/dist/revert-QKHPCRT6.js +2 -0
- package/dist/{review-cmd-2OECKNL5.js → review-cmd-XBK3TGRE.js} +1 -1
- package/dist/run-CSYGVV3D.js +2 -0
- package/dist/run-YUHHD54J.js +2 -0
- package/dist/{run-channel-63SVP5OI.js → run-channel-IIIYXOIW.js} +1 -1
- package/dist/run-remote-SFR3F2T5.js +2 -0
- package/dist/{run-startup-gate-USQFSW47.js → run-startup-gate-QSFJRYUY.js} +1 -1
- package/dist/run-test-md-ZSREINDQ.js +20 -0
- package/dist/session-worker.js +2 -2
- package/dist/{sessions-CFV7FOIT.js → sessions-NH2EG7BP.js} +1 -1
- package/dist/{sessions-cmd-LQ2LZQOC.js → sessions-cmd-TLUITRG5.js} +2 -2
- package/dist/{sessions-remote-H7CQST42.js → sessions-remote-INO7AWKB.js} +1 -1
- package/dist/{skill-installer-LKYY6XFJ.js → skill-installer-7JH5QCJF.js} +1 -1
- package/dist/spawner-MQ4XEHIX.js +2 -0
- package/dist/{store-KM5MG3XB.js → store-X4UK4AP7.js} +1 -1
- package/dist/store-choice-27HDIFTU.js +2 -0
- package/dist/{store-guard-34GG2TW2.js → store-guard-ZXKB5DQH.js} +1 -1
- package/dist/{store-site-ZSFINU6C.js → store-site-K5NHLI7D.js} +1 -1
- package/dist/stream-warnings-GM7YEOVG.js +2 -0
- package/dist/sync-cmd-2PCO7LZA.js +2 -0
- package/dist/{sync-setup-QQXYO6R4.js → sync-setup-5WQO73Y5.js} +1 -1
- package/dist/tcg-generate-DGJD5KSM.js +2 -0
- package/dist/testmd-actions-XE2JPQHB.js +2 -0
- package/dist/{testmd-sync-PQ4GFKHB.js → testmd-sync-LYHEXWCT.js} +1 -1
- package/dist/{tms-client-XWCR7O7J.js → tms-client-J4OCD3EP.js} +1 -1
- package/dist/token-refresh-E4FTJVHY.js +2 -0
- package/dist/{trust-gate-AT2XBWN4.js → trust-gate-674C2NZS.js} +1 -1
- package/dist/{turn-preflight-LHYLRL7G.js → turn-preflight-R4PU6NYY.js} +1 -1
- package/dist/{use-case-ref-NA3IXGQW.js → use-case-ref-44BPIP4N.js} +1 -1
- package/dist/{validate-basic-3DX3MMC7.js → validate-basic-66XDPA3S.js} +1 -1
- package/dist/{variable-receipt-BXSZO36E.js → variable-receipt-7PRKDTRJ.js} +1 -1
- package/dist/verdicts-PVB7TV5S.js +2 -0
- package/dist/{version-check-OV6AOVED.js → version-check-SHNVYTMU.js} +1 -1
- package/dist/{view-cmd-QDKBBNIU.js → view-cmd-QOB3O6YW.js} +1 -1
- package/dist/{walk-session-BAYYPIKN.js → walk-session-WIEROYOT.js} +1 -1
- package/dist/with-telemetry-T2PWI5CY.js +2 -0
- package/package.json +16 -16
- package/dist/ChatSurface-XUV3EQPZ.js +0 -2
- package/dist/EvidenceViewOffer-EIANIYN7.js +0 -2
- package/dist/FolderPicker-XOA7FTHF.js +0 -2
- package/dist/InfoBox-OBH7SUGC.js +0 -2
- package/dist/ProjectPicker-6KRLKV4U.js +0 -2
- package/dist/SaveSessionPrompt-J2OPDEOO.js +0 -2
- package/dist/SingleShotApp-QI4B2TSL.js +0 -2
- package/dist/TestMdRunView-I4MV54FB.js +0 -2
- package/dist/TestrunEvidenceTable-WEIUSW3E.js +0 -2
- package/dist/bridge-SDEP7Y33.js +0 -2
- package/dist/chat-committer-FM5NG46O.js +0 -2
- package/dist/chat-controller-FWFQVZTB.js +0 -2
- package/dist/child-H2YSDFCG.js +0 -2
- package/dist/chunk-2EVP636F.js +0 -26
- package/dist/chunk-34R7BNZ2.js +0 -2
- package/dist/chunk-5T6II7VN.js +0 -7
- package/dist/chunk-6K5BEEAJ.js +0 -2
- package/dist/chunk-HMQ5M4JJ.js +0 -34
- package/dist/chunk-KF4DKXSS.js +0 -2
- package/dist/chunk-NOFJXCYP.js +0 -5
- package/dist/chunk-SB6P5EQH.js +0 -2
- package/dist/chunk-Y6Y6RAY4.js +0 -2
- package/dist/commands-QOORPTSI.js +0 -2
- package/dist/cover-cmd-3VO6QC5Y.js +0 -2
- package/dist/design-committer-Y7R56RFZ.js +0 -2
- package/dist/design-headless-HUQOXLZB.js +0 -2
- package/dist/device-env-MMGISNHN.js +0 -2
- package/dist/dispatch-P2445PUU.js +0 -2
- package/dist/evidence-M3JTOJNL.js +0 -2
- package/dist/evidence-presentation-DV3DRB4S.js +0 -2
- package/dist/evolve-cmd-K3JXACMN.js +0 -2
- package/dist/evolve-remote-CUDVV2O2.js +0 -2
- package/dist/explore-UDD5FHXW.js +0 -2
- package/dist/extract-chat-ABZ5S7UU.js +0 -2
- package/dist/extract-headless-ALEFAMVS.js +0 -2
- package/dist/folder-flags-HTKJCXKB.js +0 -2
- package/dist/gaps-cmd-ROGQWK5X.js +0 -3
- package/dist/gate-QA5J7UZA.js +0 -2
- package/dist/gate-XFFFX5ZF.js +0 -2
- package/dist/hold-passthrough-K5PP26CP.js +0 -2
- package/dist/ingest-S5R736ZV.js +0 -2
- package/dist/ingest-remote-C6AP2Q7E.js +0 -2
- package/dist/install-B26Y2NU4.js +0 -2
- package/dist/lane-7IEAE6AC.js +0 -2
- package/dist/lattice-auth-7EL4ET3P.js +0 -2
- package/dist/login-flow-CHLGQGHK.js +0 -2
- package/dist/open-provider-U26BBVUE.js +0 -2
- package/dist/pdf-convert-LMKOKLXT.js +0 -2
- package/dist/persist-recorded-session-4IRYG5CJ.js +0 -3
- package/dist/phase-seed-2H6OXZXT.js +0 -2
- package/dist/pipeline-U7D25NST.js +0 -2
- package/dist/readmodel-KXCFPL2M.js +0 -2
- package/dist/real-device-run-QODMDUXF.js +0 -2
- package/dist/reconcile-deps-2CTIFXDR.js +0 -2
- package/dist/registry-MZYBLEW2.js +0 -2
- package/dist/remote-entry-DW2J56N4.js +0 -2
- package/dist/revert-37346WLE.js +0 -2
- package/dist/run-JWOHNWA3.js +0 -2
- package/dist/run-QFJ6ZRVD.js +0 -2
- package/dist/run-remote-66QTUQ2M.js +0 -2
- package/dist/run-test-md-7DRWCSQE.js +0 -19
- package/dist/spawner-C7NLLM4F.js +0 -2
- package/dist/store-choice-4J2NN6OQ.js +0 -2
- package/dist/stream-warnings-N4KVVWXV.js +0 -2
- package/dist/sync-cmd-3CHSWWWW.js +0 -2
- package/dist/tcg-generate-IPD5FQUW.js +0 -2
- package/dist/testmd-actions-V7P7BMKE.js +0 -2
- package/dist/token-refresh-LR33BKAB.js +0 -2
- package/dist/verdicts-7GKZEDHV.js +0 -2
- package/dist/with-telemetry-62LW4VFI.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as ke,b as we,c as H,d as b,m as N,n as J,o as _e,p as be}from"./chunk-COJINPOK.js";import{a as ye}from"./chunk-RTVWQK7I.js";import{b as pe,c as fe,e as ge}from"./chunk-GRO6DLN3.js";import{a as me}from"./chunk-VZJ6LUXX.js";import{n as ve}from"./chunk-EH43VWVR.js";import{b as he}from"./chunk-IZ65ZPWY.js";import{M as D}from"./chunk-Z777GGHB.js";import{e as K}from"./chunk-HHW6MRU3.js";import{m as ue}from"./chunk-4I7YN6YY.js";var Ce=4;function He(t){return{ucRef:t.key,force:t.kind==="evolve",verb:t.kind}}function L(t,o,C){for(let{sid:R}of t.sessions().list()){if(C&&!C(R))continue;let p;try{p=t.sessions().peek(R)}catch{continue}if(!p?.reconcile||K(p,new Date)||(H(t,p.reconcile),b(t,p.reconcile.proposal_id).resolved))continue;let A=p.change_basis?.source_id??Object.keys(p.read_basis)[0]??"";if(!(o!==void 0&&A!==o))return{sid:p.sid,proposalId:p.reconcile.proposal_id,source:A,...p.change_basis?{changeBasis:{source_id:p.change_basis.source_id,to_cid:p.change_basis.new_head}}:{}}}return null}function V(t,o,C){let R=[];for(let{sid:p}of t.sessions().list()){if(C&&!C(p))continue;let h;try{h=t.sessions().peek(p)}catch{continue}if(!h?.reconcile||K(h,new Date))continue;let A=h.change_basis?.source_id??Object.keys(h.read_basis)[0]??"";o!==void 0&&A!==o||(H(t,h.reconcile),R.push(h.reconcile.proposal_id))}return R}var xe=80;function Pe(t){return{kind:t.kind,ref:t.display,title:t.kind==="ADD"?t.title:`${t.display} \xB7 ${t.title}`,why:t.changeLine,origin:"content-change",...t.tier!==void 0?{tier:t.tier}:{},...t.diffSummary==null&&t.diff.length>0?{diff:t.diff}:{},...t.diffSummary!=null?{diffSummary:t.diffSummary,viewDiff:!0}:{},...t.cites.length>0?{citeLines:t.cites.map(o=>`cite ${o.source_id??"conversation"} ${o.anchor} \u2014 "${o.quote.slice(0,xe)}"`)}:{},...t.impact?{impact:{stale_refs:Array(t.impact.stale).fill("\xB7"),...t.impact.direct.length>0?{direct_refs:t.impact.direct}:{}}}:{}}}function Ne(t){let o=t.store,C=t.changeSince?{since:t.changeSince}:{},R=he(),p=t.by??{kind:"human",id:"owner"},h=n=>t.emit?.(n),A=t.emitWalkSignal??((n,e,r)=>o.signals().append({ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:e,polarity:"preference",by:p,target:n,...r!==void 0?{reason:r}:{}})),j=new Set(t.sessionId?[t.sessionId]:[]),y=t.sessionId?n=>j.has(n)||[...t.children?.()??[]].includes(n):void 0,g=o.proposals(),k=t.changeContext?.source_id,$=new Map;t.changeContext&&$.set(t.changeContext.source_id,t.changeContext.old_head);let Re=n=>{let e=$.get(n);if(e)return e;try{let r=ge(o,n,C);return r&&$.set(n,r.old_head),r?.old_head}catch{return}},X=n=>{let e=g.read(n);if(!e)return[];let r=N(e,D(o)),s=b(o,n);return J(r,s.verdicts)},Z=new Set,Se=()=>{let n=D(o);for(let{sid:e}of o.sessions().list()){if(y&&!y(e))continue;let r;try{r=o.sessions().peek(e)}catch{continue}if(!r||K(r,new Date))continue;let s=(r.ingest_schedule??[]).filter(i=>{if(i.status!=="skipped"||!(i.note??"").includes("review"))return!1;let a=n.heads.get(i.source_id);return typeof a!="string"||!n.extractedSourceCids.has(a)?!0:(Z.has(i.source_id)||(Z.add(i.source_id),t.note?.(`the new version of ${i.source_id} that waited for review has been extracted since, so its changes are not read again`)),!1)});if(s.length>0)return{source:s[0].source_id,count:s.length}}return null},ee=async(n,e,r,s)=>{let i=await Y(r,(d,l)=>(d(n),G({resume:n,...s!==null?{message:s}:{},mode:W},l))),a=null;try{a=o.sessions().peek(n)}catch{a=null}if(a?.reconcile&&a.reconcile.proposal_id!==e)H(o,a.reconcile);else{let d=g.verdicts(e);d.steer&&(delete d.steer,g.saveVerdicts(e,d))}return i},W=t.ask?"interactive":"override",q=!1,_=null,M=null,B=null,te={paused:!0},ne=t.ask,re=ne?n=>q?Promise.resolve(te):new Promise((e,r)=>{B=()=>e(te),ne(n).then(e,r)}).finally(()=>{B=null}):void 0,G=async(n,e)=>{let[{runExtract:r},{runAgent:s},{resolveAgentAuthEnv:i},{preflightTurn:a}]=await Promise.all([import("./run-QFJ6ZRVD.js"),import("./bridge-SDEP7Y33.js"),import("./spawner-C7NLLM4F.js"),import("./turn-preflight-LHYLRL7G.js")]),d=t.auth??await i(t.credentials),l=!1,c=!1;M=null;let u=t.parentLock?.()??null,S={...n,...t.changeSince?{changeSince:t.changeSince}:{}},Q=await r(u?{...S,underLock:u}:S,{...t.nested?{nested:!0}:{},...t.by?{by:t.by}:{},reviewsHeld:!0,...t.telemetry?{telemetry:t.telemetry}:{},...t.tracePath?{tracePath:t.tracePath}:{},...t.narrate?{narrate:t.narrate}:{},emit:f=>{f.type==="held"&&(c=!0),f.type==="error"&&(M={code:String(f.code??"ERROR"),message:String(f.message??"the run failed")});let m=me(f);m&&_===null&&(_=m);let P=f.type==="session_paused"?f.cause:void 0;P&&typeof P.code=="string"&&_===null&&(_={code:P.code,final:!1}),t.emit&&e(f)},agent:t.agent??s,store:o,credentials:t.credentials,onIngestRefusal:t.onIngestRefusal,preflightTurn:t.preflightTurn??(()=>a(d)),...t.probe?{probe:t.probe}:{},...t.matchUnreviewed?{matchUnreviewed:!0}:{},ask:re?async f=>{let m=await re(f);return!Array.isArray(m)&&"paused"in m&&(l=!0),m}:async f=>f.map(m=>({id:m.id,selected_index:m.recommended_index,free_text:null})),review:async f=>new Map(f.map(m=>[m.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!0,out:f=>t.note?.(f),progress:()=>{},isTTY:t.ask!==void 0,auth:d});return q=!1,Q!==3||c?Q:l?Ce:1},Y=async(n,e)=>{let r=null,s,i=[],a=u=>ye(u,{verb:"extract",...s!==void 0?{id:s}:{}}),d=u=>{r===null?i.push(u):t.emit?.(a(u))},l=u=>{r=Date.now(),s=u,h({type:"child_start",child:"extract",subject:n,...u?{session_id:u}:{}});for(let S of i.splice(0))t.emit?.(a(S))},c=1;try{return c=await e(l,d),c}finally{if(r!==null){let u=Math.round((Date.now()-r)/1e3);h({type:"child_end",child:"extract",ok:c===0||c===3||c===Ce,dur_s:u,exit_code:c})}else for(let u of i.splice(0))t.emit?.(a(u))}},ie=async n=>{let e=null;try{e=o.sessions().peek(n)}catch{return}if(!e?.reconcile?.pending)return;let r;try{r=o.sessions().resume(n)}catch{return}try{let s=r.state.reconcile;if(!s?.pending)return;let i=g.read(s.proposal_id);if(i){let[{extractProtocolCtx:l},{landHoldPassthrough:c}]=await Promise.all([import("./run-QFJ6ZRVD.js"),import("./hold-passthrough-K5PP26CP.js")]);if(!(await c({store:o,ctx:l(o,n,t.credentials,{probe:t.probe,runAuth:t.auth,similarity:R}),graph:D(o),sid:n,proposalId:s.proposal_id,proposal:i,by:p,durable:!0,...t.matchUnreviewed?{matchUnreviewed:!0}:{}})).ok)return}let{pending:a,...d}=s;r.save({reconcile:d})}finally{r.release()}},De=async(n,e)=>{let r=null;try{r=o.sessions().peek(e)}catch{r=null}if(!r)return F.startReview(n);if(o.sessions().isLive(e))return t.note?.(`session ${e} is running \u2014 it is not resumed here`),_={code:"SESSION_LOCKED",final:!1},2;if(r.reconcile?.pending&&await ie(e),r.reconcile&&g.read(r.reconcile.proposal_id)){let s=g.verdicts(r.reconcile.proposal_id).steer;if(!s)return 3;j.add(e);let i=(r.checkpoint?.seq??0)>s.seq;return ee(e,r.reconcile.proposal_id,n,i?null:s.text)}if(ve(r,o.sessions().hasBase(e))){try{o.sessions().resume(e).complete({ended:"failed",code:"SESSION_KEPT_NOTHING"})}catch{}return F.startReview(n)}return j.add(e),Y(n,(s,i)=>(s(e),G({resume:e,mode:W},i)))},se=n=>{if(o.sessions().isLive(n))return!1;let e=null;try{e=o.sessions().peek(n)}catch{e=null}return!e?.checkpoint&&!o.sessions().hasBase(n)&&o.sessions().appliedEvents(n).length===0},F={lastReadError(){return M},pending(){let n=L(o,k,y);if(n){let r=X(n.proposalId).length;return r>0?{source:n.source,count:r,kind:"cards"}:null}let e=Se();return e?{source:e.source,count:e.count,kind:"needs-run"}:null},loadCards(){let n=L(o,k,y);if(!n)return[];let e=X(n.proposalId),r=e.filter(d=>d.kind==="ADD"||d.ref!=null),s=e.filter(d=>d.kind!=="ADD"&&d.ref==null);for(let d of s)t.note?.(`dropped: [${d.kind}] ${d.title} \u2014 its target was retired while the review was open; nothing lands`);let i=g.verdicts(n.proposalId),a=r.map(d=>{let l=we(i.verdicts[d.key]);return l==="another session"&&t.note?.(`saving: [${d.kind}] ${d.title} \u2014 another session is saving its verdict; it comes back here if that save does not land`),{key:d.key,card:Pe(d),viewLines:d.diff,...l?{saving:l}:{}}});return h({type:"review_cards",source:n.source,cards:a.map(d=>({key:d.key,card:d.card})),dropped:s.map(d=>({kind:d.kind,title:d.title}))}),a},async applyVerdict(n,e,r){let s=L(o,k,y);s&&await ie(s.sid);let i=L(o,k,y),a=(v,ae)=>{let le=i?.source??k;return h({type:"card_refused",...le?{source:le}:{},key:n,verdict:e,code:v,refusal:ae}),{ok:!1,refusal:ae,code:v}};if(!i)return a("HOLD_GONE","the held changeset is gone \u2014 nothing to verdict");let d=g.read(i.proposalId);if(!d)return a("PROPOSAL_UNREADABLE",ue().text("PROPOSAL_UNREADABLE",{proposal:i.proposalId}));if(n in b(o,i.proposalId).verdicts)return a("ALREADY_VERDICTED","that change was already verdicted (another surface?) \u2014 refresh the review");let l=D(o),c=N(d,l).find(v=>v.key===n);if(!c)return a("CARD_GONE","that change no longer builds a card \u2014 the set may have moved; re-open the review");let u=Re(i.source),S=i.changeBasis?{source_id:i.changeBasis.source_id,...u?{from_cid:u}:{},...i.changeBasis.to_cid?{to_cid:i.changeBasis.to_cid}:{}}:void 0,f=`${e==="approve"?c.kind==="ARCHIVE"?"retired":"approved":e==="reject"?"rejected":"deferred"} change \xB7 [${c.kind}] ${c.display}${c.kind==="ADD"?"":` ${c.title}`} (you)`,m={verdict:e,...r?{note:r}:{},at:new Date().toISOString(),line:f},P=o.serialize(o.head()),I=_e(l,c),O=ke(i.proposalId,n),z={after:P,process:O.process,pid:O.pid},T=I?{target:I,...i.changeBasis?{source:i.changeBasis.source_id}:{},by:p}:void 0,oe=e==="reject"?null:e==="defer"?{...z,kind:"gap",proposal_id:i.proposalId,text:c.changeLine||c.title}:c.kind==="ARCHIVE"?{...z,kind:"archive",target:I??"",...T?{closes:T}:{}}:{...z,kind:"record",proposal_id:`${i.proposalId}:${n}`,offer:{kind:c.kind==="MODIFY"?"evolve":"design",title:c.kind==="ADD"?c.title:c.display,...c.kind==="MODIFY"&&I?{fallback:I}:{}},...c.kind==="MODIFY"&&T?{closes:T}:{}},de=g.verdicts(i.proposalId);de.verdicts[n]=oe?{...m,pending:oe}:m,g.saveVerdicts(i.proposalId,de);let ce=()=>{let v=g.verdicts(i.proposalId);delete v.verdicts[n],g.saveVerdicts(i.proposalId,v)},w;try{w=await be({store:o,graph:l,proposal:d,proposalId:i.proposalId,card:c,verdict:e,...r?{note:r}:{},by:p,sid:i.sid,...S?{changeBasis:S}:{},signals:v=>A(v.ref,v.verdict,v.reason),...t.probe?{probe:t.probe}:{},...t.matchUnreviewed?{matchUnreviewed:!0}:{}})}catch(v){throw ce(),O.done(),v}if(!w.ok)return ce(),O.done(),a(w.code,w.refusal);let U=w.offer&&w.offer.target?{kind:w.offer.kind,key:w.offer.target,title:c.kind==="ADD"?c.title:c.display}:void 0,E=g.verdicts(i.proposalId);E.verdicts[n]={...m,...U?{offer:U}:{}};let Ae=J(N(d,D(o)),E.verdicts).length,Ee=Object.values(E.verdicts).some(v=>v.pending);Ae===0&&!Ee&&(E.resolved=!0),g.saveVerdicts(i.proposalId,E),O.done();let x={ok:!0,line:f,...w.note?{note:w.note}:{},...U?{offer:U}:{}};return h({type:"card_verdict",source:i.source,key:n,verdict:e,line:x.line,...x.note?{note:x.note}:{},...x.offer?{offer:x.offer}:{}}),E.resolved&&h({type:"review_resolved",source:i.source}),x},async resumeReview(n,e,r){_=null;let s=await De(n,e);return r&&_&&(r.refused=_),s},givenVerdicts(){let n=[];for(let e of V(o,k,y))for(let[r,s]of Object.entries(b(o,e).verdicts))s.verdict!=="steer"&&n.push({card:r,verdict:s.verdict,...s.note?{note:s.note}:{},...s.line?{line:s.line}:{},at:s.at});return n.sort((e,r)=>e.at.localeCompare(r.at))},resumableChildren(){let n=[];for(let e of V(o,k,y))for(let[r,s]of Object.entries(b(o,e).verdicts)){let i=s.offer;i?.answer!=="accepted"||i.child===void 0||i.ended!==void 0||se(i.child)||n.push({proposalId:e,card:r,offer:{kind:i.kind,key:i.key,title:i.title},child:i.child,at:s.at})}return n.sort((e,r)=>e.at.localeCompare(r.at)).map(({proposalId:e,card:r,offer:s,child:i})=>({proposalId:e,card:r,offer:s,child:i}))},pendingOffers(){let n=[];for(let e of V(o,k,y))for(let[r,s]of Object.entries(b(o,e).verdicts)){if(!s.offer)continue;let{kind:i,key:a,title:d,answer:l,child:c,ended:u}=s.offer;l===void 0?n.push({proposalId:e,card:r,offer:{kind:i,key:a,title:d},at:s.at}):l==="accepted"&&c!==void 0&&u===void 0&&se(c)&&n.push({proposalId:e,card:r,offer:{kind:i,key:a,title:d},at:s.at,reopened:!0})}return n.sort((e,r)=>e.at.localeCompare(r.at)).map(({proposalId:e,card:r,offer:s,reopened:i})=>({proposalId:e,card:r,offer:s,...i?{reopened:i}:{}}))},offerAnswered(n,e,r,s){if(!V(o,k,y).includes(n))return!1;let i=b(o,n),a=i.verdicts[e];if(!a?.offer)return!1;let{kind:d,key:l,title:c}=a.offer;return a.offer={kind:d,key:l,title:c,answer:r,...r==="accepted"&&s!==void 0?{child:s}:{}},g.saveVerdicts(n,i),!0},offerEnded(n,e,r){if(!V(o,k,y).includes(n))return!1;let s=b(o,n),i=s.verdicts[e];return i?.offer?(i.offer={...i.offer,ended:r},g.saveVerdicts(n,s),!0):!1},async startReview(n){let e=pe(o,n,C);if(e.kind==="unchanged")return t.note?.(`no use case of ${n} is behind its current version, which has been read \u2014 nothing to review`),0;if(e.kind!=="ok"){let a=e.kind==="first"?`no change context for ${n}`:`${n}'s version ${e.version} cannot be read`;return t.note?.(`${a} \u2014 nothing to review`),_=e.kind==="first"?{code:"POSTURE_USAGE",final:!0}:{code:"SOURCE_UNREADABLE",final:!1},2}let r=e.changeContext;$.set(n,r.old_head);let s=D(o).extractedSourceCids.has(r.new_head)&&fe(o,n).length>0,i=t.childSession?.(n);return Y(n,(a,d)=>{let l=i&&{id:i.id,register:async c=>{await i.register(c),j.add(c),a(c)}};return l||a(),t.runPostureChild?t.runPostureChild(n,r,l):G({mode:W,posture:"reconcile",source:n,changeContext:r,...s?{force:!0}:{},...l?{sessionId:l.id,registerSession:c=>l.register(c)}:{}},d)})},requestPause(){return q=!0,B?(B(),!0):!1},async steer(n){let e=L(o,k,y);if(!e)return t.note?.("nothing is held to steer \u2014 the review has no changeset"),2;if(o.sessions().isLive(e.sid))return t.note?.(`session ${e.sid} is running \u2014 steer it there`),2;let r=g.verdicts(e.proposalId);return r.steer={text:n,at:new Date().toISOString(),seq:o.sessions().peek(e.sid)?.checkpoint?.seq??0},g.saveVerdicts(e.proposalId,r),ee(e.sid,e.proposalId,e.source,n)}};return F}export{Ce as a,He as b,Pe as c,Ne as d};
|
|
2
|
+
import{a as ke,b as we,c as H,d as b,m as N,n as J,o as _e,p as be}from"./chunk-TU2KPOW2.js";import{a as ye}from"./chunk-RTVWQK7I.js";import{b as pe,c as fe,e as ge}from"./chunk-WEJR2V7R.js";import{a as me}from"./chunk-VZJ6LUXX.js";import{n as ve}from"./chunk-DXIQVBMI.js";import{b as he}from"./chunk-W5HFUBXD.js";import{M as D}from"./chunk-PI7OXS62.js";import{e as K}from"./chunk-G4K3TP2I.js";import{o as ue}from"./chunk-HYJVYYAZ.js";var Ce=4;function He(t){return{ucRef:t.key,force:t.kind==="evolve",verb:t.kind}}function L(t,o,C){for(let{sid:R}of t.sessions().list()){if(C&&!C(R))continue;let p;try{p=t.sessions().peek(R)}catch{continue}if(!p?.reconcile||K(p,new Date)||(H(t,p.reconcile),b(t,p.reconcile.proposal_id).resolved))continue;let A=p.change_basis?.source_id??Object.keys(p.read_basis)[0]??"";if(!(o!==void 0&&A!==o))return{sid:p.sid,proposalId:p.reconcile.proposal_id,source:A,...p.change_basis?{changeBasis:{source_id:p.change_basis.source_id,to_cid:p.change_basis.new_head}}:{}}}return null}function V(t,o,C){let R=[];for(let{sid:p}of t.sessions().list()){if(C&&!C(p))continue;let h;try{h=t.sessions().peek(p)}catch{continue}if(!h?.reconcile||K(h,new Date))continue;let A=h.change_basis?.source_id??Object.keys(h.read_basis)[0]??"";o!==void 0&&A!==o||(H(t,h.reconcile),R.push(h.reconcile.proposal_id))}return R}var xe=80;function Pe(t){return{kind:t.kind,ref:t.display,title:t.kind==="ADD"?t.title:`${t.display} \xB7 ${t.title}`,why:t.changeLine,origin:"content-change",...t.tier!==void 0?{tier:t.tier}:{},...t.diffSummary==null&&t.diff.length>0?{diff:t.diff}:{},...t.diffSummary!=null?{diffSummary:t.diffSummary,viewDiff:!0}:{},...t.cites.length>0?{citeLines:t.cites.map(o=>`cite ${o.source_id??"conversation"} ${o.anchor} \u2014 "${o.quote.slice(0,xe)}"`)}:{},...t.impact?{impact:{stale_refs:Array(t.impact.stale).fill("\xB7"),...t.impact.direct.length>0?{direct_refs:t.impact.direct}:{}}}:{}}}function Ne(t){let o=t.store,C=t.changeSince?{since:t.changeSince}:{},R=he(),p=t.by??{kind:"human",id:"owner"},h=n=>t.emit?.(n),A=t.emitWalkSignal??((n,e,r)=>o.signals().append({ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:e,polarity:"preference",by:p,target:n,...r!==void 0?{reason:r}:{}})),j=new Set(t.sessionId?[t.sessionId]:[]),y=t.sessionId?n=>j.has(n)||[...t.children?.()??[]].includes(n):void 0,g=o.proposals(),k=t.changeContext?.source_id,$=new Map;t.changeContext&&$.set(t.changeContext.source_id,t.changeContext.old_head);let Re=n=>{let e=$.get(n);if(e)return e;try{let r=ge(o,n,C);return r&&$.set(n,r.old_head),r?.old_head}catch{return}},X=n=>{let e=g.read(n);if(!e)return[];let r=N(e,D(o)),s=b(o,n);return J(r,s.verdicts)},Z=new Set,Se=()=>{let n=D(o);for(let{sid:e}of o.sessions().list()){if(y&&!y(e))continue;let r;try{r=o.sessions().peek(e)}catch{continue}if(!r||K(r,new Date))continue;let s=(r.ingest_schedule??[]).filter(i=>{if(i.status!=="skipped"||!(i.note??"").includes("review"))return!1;let a=n.heads.get(i.source_id);return typeof a!="string"||!n.extractedSourceCids.has(a)?!0:(Z.has(i.source_id)||(Z.add(i.source_id),t.note?.(`the new version of ${i.source_id} that waited for review has been extracted since, so its changes are not read again`)),!1)});if(s.length>0)return{source:s[0].source_id,count:s.length}}return null},ee=async(n,e,r,s)=>{let i=await Y(r,(d,l)=>(d(n),G({resume:n,...s!==null?{message:s}:{},mode:W},l))),a=null;try{a=o.sessions().peek(n)}catch{a=null}if(a?.reconcile&&a.reconcile.proposal_id!==e)H(o,a.reconcile);else{let d=g.verdicts(e);d.steer&&(delete d.steer,g.saveVerdicts(e,d))}return i},W=t.ask?"interactive":"override",q=!1,_=null,M=null,B=null,te={paused:!0},ne=t.ask,re=ne?n=>q?Promise.resolve(te):new Promise((e,r)=>{B=()=>e(te),ne(n).then(e,r)}).finally(()=>{B=null}):void 0,G=async(n,e)=>{let[{runExtract:r},{runAgent:s},{resolveAgentAuthEnv:i},{preflightTurn:a}]=await Promise.all([import("./run-YUHHD54J.js"),import("./bridge-2UHJOVLX.js"),import("./spawner-MQ4XEHIX.js"),import("./turn-preflight-R4PU6NYY.js")]),d=t.auth??await i(t.credentials),l=!1,c=!1;M=null;let u=t.parentLock?.()??null,S={...n,...t.changeSince?{changeSince:t.changeSince}:{}},Q=await r(u?{...S,underLock:u}:S,{...t.nested?{nested:!0}:{},...t.by?{by:t.by}:{},reviewsHeld:!0,...t.telemetry?{telemetry:t.telemetry}:{},...t.tracePath?{tracePath:t.tracePath}:{},...t.narrate?{narrate:t.narrate}:{},emit:f=>{f.type==="held"&&(c=!0),f.type==="error"&&(M={code:String(f.code??"ERROR"),message:String(f.message??"the run failed")});let m=me(f);m&&_===null&&(_=m);let P=f.type==="session_paused"?f.cause:void 0;P&&typeof P.code=="string"&&_===null&&(_={code:P.code,final:!1}),t.emit&&e(f)},agent:t.agent??s,store:o,credentials:t.credentials,onIngestRefusal:t.onIngestRefusal,preflightTurn:t.preflightTurn??(()=>a(d)),...t.probe?{probe:t.probe}:{},...t.matchUnreviewed?{matchUnreviewed:!0}:{},ask:re?async f=>{let m=await re(f);return!Array.isArray(m)&&"paused"in m&&(l=!0),m}:async f=>f.map(m=>({id:m.id,selected_index:m.recommended_index,free_text:null})),review:async f=>new Map(f.map(m=>[m.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!0,out:f=>t.note?.(f),progress:()=>{},isTTY:t.ask!==void 0,auth:d});return q=!1,Q!==3||c?Q:l?Ce:1},Y=async(n,e)=>{let r=null,s,i=[],a=u=>ye(u,{verb:"extract",...s!==void 0?{id:s}:{}}),d=u=>{r===null?i.push(u):t.emit?.(a(u))},l=u=>{r=Date.now(),s=u,h({type:"child_start",child:"extract",subject:n,...u?{session_id:u}:{}});for(let S of i.splice(0))t.emit?.(a(S))},c=1;try{return c=await e(l,d),c}finally{if(r!==null){let u=Math.round((Date.now()-r)/1e3);h({type:"child_end",child:"extract",ok:c===0||c===3||c===Ce,dur_s:u,exit_code:c})}else for(let u of i.splice(0))t.emit?.(a(u))}},ie=async n=>{let e=null;try{e=o.sessions().peek(n)}catch{return}if(!e?.reconcile?.pending)return;let r;try{r=o.sessions().resume(n)}catch{return}try{let s=r.state.reconcile;if(!s?.pending)return;let i=g.read(s.proposal_id);if(i){let[{extractProtocolCtx:l},{landHoldPassthrough:c}]=await Promise.all([import("./run-YUHHD54J.js"),import("./hold-passthrough-JGHWMYDM.js")]);if(!(await c({store:o,ctx:l(o,n,t.credentials,{probe:t.probe,runAuth:t.auth,similarity:R}),graph:D(o),sid:n,proposalId:s.proposal_id,proposal:i,by:p,durable:!0,...t.matchUnreviewed?{matchUnreviewed:!0}:{}})).ok)return}let{pending:a,...d}=s;r.save({reconcile:d})}finally{r.release()}},De=async(n,e)=>{let r=null;try{r=o.sessions().peek(e)}catch{r=null}if(!r)return F.startReview(n);if(o.sessions().isLive(e))return t.note?.(`session ${e} is running \u2014 it is not resumed here`),_={code:"SESSION_LOCKED",final:!1},2;if(r.reconcile?.pending&&await ie(e),r.reconcile&&g.read(r.reconcile.proposal_id)){let s=g.verdicts(r.reconcile.proposal_id).steer;if(!s)return 3;j.add(e);let i=(r.checkpoint?.seq??0)>s.seq;return ee(e,r.reconcile.proposal_id,n,i?null:s.text)}if(ve(r,o.sessions().hasBase(e))){try{o.sessions().resume(e).complete({ended:"failed",code:"SESSION_KEPT_NOTHING"})}catch{}return F.startReview(n)}return j.add(e),Y(n,(s,i)=>(s(e),G({resume:e,mode:W},i)))},se=n=>{if(o.sessions().isLive(n))return!1;let e=null;try{e=o.sessions().peek(n)}catch{e=null}return!e?.checkpoint&&!o.sessions().hasBase(n)&&o.sessions().appliedEvents(n).length===0},F={lastReadError(){return M},pending(){let n=L(o,k,y);if(n){let r=X(n.proposalId).length;return r>0?{source:n.source,count:r,kind:"cards"}:null}let e=Se();return e?{source:e.source,count:e.count,kind:"needs-run"}:null},loadCards(){let n=L(o,k,y);if(!n)return[];let e=X(n.proposalId),r=e.filter(d=>d.kind==="ADD"||d.ref!=null),s=e.filter(d=>d.kind!=="ADD"&&d.ref==null);for(let d of s)t.note?.(`dropped: [${d.kind}] ${d.title} \u2014 its target was retired while the review was open; nothing lands`);let i=g.verdicts(n.proposalId),a=r.map(d=>{let l=we(i.verdicts[d.key]);return l==="another session"&&t.note?.(`saving: [${d.kind}] ${d.title} \u2014 another session is saving its verdict; it comes back here if that save does not land`),{key:d.key,card:Pe(d),viewLines:d.diff,...l?{saving:l}:{}}});return h({type:"review_cards",source:n.source,cards:a.map(d=>({key:d.key,card:d.card})),dropped:s.map(d=>({kind:d.kind,title:d.title}))}),a},async applyVerdict(n,e,r){let s=L(o,k,y);s&&await ie(s.sid);let i=L(o,k,y),a=(v,ae)=>{let le=i?.source??k;return h({type:"card_refused",...le?{source:le}:{},key:n,verdict:e,code:v,refusal:ae}),{ok:!1,refusal:ae,code:v}};if(!i)return a("HOLD_GONE","the held changeset is gone \u2014 nothing to verdict");let d=g.read(i.proposalId);if(!d)return a("PROPOSAL_UNREADABLE",ue().text("PROPOSAL_UNREADABLE",{proposal:i.proposalId}));if(n in b(o,i.proposalId).verdicts)return a("ALREADY_VERDICTED","that change was already verdicted (another surface?) \u2014 refresh the review");let l=D(o),c=N(d,l).find(v=>v.key===n);if(!c)return a("CARD_GONE","that change no longer builds a card \u2014 the set may have moved; re-open the review");let u=Re(i.source),S=i.changeBasis?{source_id:i.changeBasis.source_id,...u?{from_cid:u}:{},...i.changeBasis.to_cid?{to_cid:i.changeBasis.to_cid}:{}}:void 0,f=`${e==="approve"?c.kind==="ARCHIVE"?"retired":"approved":e==="reject"?"rejected":"deferred"} change \xB7 [${c.kind}] ${c.display}${c.kind==="ADD"?"":` ${c.title}`} (you)`,m={verdict:e,...r?{note:r}:{},at:new Date().toISOString(),line:f},P=o.serialize(o.head()),I=_e(l,c),O=ke(i.proposalId,n),z={after:P,process:O.process,pid:O.pid},T=I?{target:I,...i.changeBasis?{source:i.changeBasis.source_id}:{},by:p}:void 0,oe=e==="reject"?null:e==="defer"?{...z,kind:"gap",proposal_id:i.proposalId,text:c.changeLine||c.title}:c.kind==="ARCHIVE"?{...z,kind:"archive",target:I??"",...T?{closes:T}:{}}:{...z,kind:"record",proposal_id:`${i.proposalId}:${n}`,offer:{kind:c.kind==="MODIFY"?"evolve":"design",title:c.kind==="ADD"?c.title:c.display,...c.kind==="MODIFY"&&I?{fallback:I}:{}},...c.kind==="MODIFY"&&T?{closes:T}:{}},de=g.verdicts(i.proposalId);de.verdicts[n]=oe?{...m,pending:oe}:m,g.saveVerdicts(i.proposalId,de);let ce=()=>{let v=g.verdicts(i.proposalId);delete v.verdicts[n],g.saveVerdicts(i.proposalId,v)},w;try{w=await be({store:o,graph:l,proposal:d,proposalId:i.proposalId,card:c,verdict:e,...r?{note:r}:{},by:p,sid:i.sid,...S?{changeBasis:S}:{},signals:v=>A(v.ref,v.verdict,v.reason),...t.probe?{probe:t.probe}:{},...t.matchUnreviewed?{matchUnreviewed:!0}:{}})}catch(v){throw ce(),O.done(),v}if(!w.ok)return ce(),O.done(),a(w.code,w.refusal);let U=w.offer&&w.offer.target?{kind:w.offer.kind,key:w.offer.target,title:c.kind==="ADD"?c.title:c.display}:void 0,E=g.verdicts(i.proposalId);E.verdicts[n]={...m,...U?{offer:U}:{}};let Ae=J(N(d,D(o)),E.verdicts).length,Ee=Object.values(E.verdicts).some(v=>v.pending);Ae===0&&!Ee&&(E.resolved=!0),g.saveVerdicts(i.proposalId,E),O.done();let x={ok:!0,line:f,...w.note?{note:w.note}:{},...U?{offer:U}:{}};return h({type:"card_verdict",source:i.source,key:n,verdict:e,line:x.line,...x.note?{note:x.note}:{},...x.offer?{offer:x.offer}:{}}),E.resolved&&h({type:"review_resolved",source:i.source}),x},async resumeReview(n,e,r){_=null;let s=await De(n,e);return r&&_&&(r.refused=_),s},givenVerdicts(){let n=[];for(let e of V(o,k,y))for(let[r,s]of Object.entries(b(o,e).verdicts))s.verdict!=="steer"&&n.push({card:r,verdict:s.verdict,...s.note?{note:s.note}:{},...s.line?{line:s.line}:{},at:s.at});return n.sort((e,r)=>e.at.localeCompare(r.at))},resumableChildren(){let n=[];for(let e of V(o,k,y))for(let[r,s]of Object.entries(b(o,e).verdicts)){let i=s.offer;i?.answer!=="accepted"||i.child===void 0||i.ended!==void 0||se(i.child)||n.push({proposalId:e,card:r,offer:{kind:i.kind,key:i.key,title:i.title},child:i.child,at:s.at})}return n.sort((e,r)=>e.at.localeCompare(r.at)).map(({proposalId:e,card:r,offer:s,child:i})=>({proposalId:e,card:r,offer:s,child:i}))},pendingOffers(){let n=[];for(let e of V(o,k,y))for(let[r,s]of Object.entries(b(o,e).verdicts)){if(!s.offer)continue;let{kind:i,key:a,title:d,answer:l,child:c,ended:u}=s.offer;l===void 0?n.push({proposalId:e,card:r,offer:{kind:i,key:a,title:d},at:s.at}):l==="accepted"&&c!==void 0&&u===void 0&&se(c)&&n.push({proposalId:e,card:r,offer:{kind:i,key:a,title:d},at:s.at,reopened:!0})}return n.sort((e,r)=>e.at.localeCompare(r.at)).map(({proposalId:e,card:r,offer:s,reopened:i})=>({proposalId:e,card:r,offer:s,...i?{reopened:i}:{}}))},offerAnswered(n,e,r,s){if(!V(o,k,y).includes(n))return!1;let i=b(o,n),a=i.verdicts[e];if(!a?.offer)return!1;let{kind:d,key:l,title:c}=a.offer;return a.offer={kind:d,key:l,title:c,answer:r,...r==="accepted"&&s!==void 0?{child:s}:{}},g.saveVerdicts(n,i),!0},offerEnded(n,e,r){if(!V(o,k,y).includes(n))return!1;let s=b(o,n),i=s.verdicts[e];return i?.offer?(i.offer={...i.offer,ended:r},g.saveVerdicts(n,s),!0):!1},async startReview(n){let e=pe(o,n,C);if(e.kind==="unchanged")return t.note?.(`no use case of ${n} is behind its current version, which has been read \u2014 nothing to review`),0;if(e.kind!=="ok"){let a=e.kind==="first"?`no change context for ${n}`:`${n}'s version ${e.version} cannot be read`;return t.note?.(`${a} \u2014 nothing to review`),_=e.kind==="first"?{code:"POSTURE_USAGE",final:!0}:{code:"SOURCE_UNREADABLE",final:!1},2}let r=e.changeContext;$.set(n,r.old_head);let s=D(o).extractedSourceCids.has(r.new_head)&&fe(o,n).length>0,i=t.childSession?.(n);return Y(n,(a,d)=>{let l=i&&{id:i.id,register:async c=>{await i.register(c),j.add(c),a(c)}};return l||a(),t.runPostureChild?t.runPostureChild(n,r,l):G({mode:W,posture:"reconcile",source:n,changeContext:r,...s?{force:!0}:{},...l?{sessionId:l.id,registerSession:c=>l.register(c)}:{}},d)})},requestPause(){return q=!0,B?(B(),!0):!1},async steer(n){let e=L(o,k,y);if(!e)return t.note?.("nothing is held to steer \u2014 the review has no changeset"),2;if(o.sessions().isLive(e.sid))return t.note?.(`session ${e.sid} is running \u2014 steer it there`),2;let r=g.verdicts(e.proposalId);return r.steer={text:n,at:new Date().toISOString(),seq:o.sessions().peek(e.sid)?.checkpoint?.seq??0},g.saveVerdicts(e.proposalId,r),ee(e.sid,e.proposalId,e.source,n)}};return F}export{Ce as a,He as b,Pe as c,Ne as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{h as I}from"./chunk-SXRHKXSE.js";import{f as c,h as w,i as y,l,q as f,t as A}from"./chunk-A7RJQJNT.js";import{b as m}from"./chunk-
|
|
2
|
+
import{h as I}from"./chunk-SXRHKXSE.js";import{f as c,h as w,i as y,l,q as f,t as A}from"./chunk-A7RJQJNT.js";import{b as m}from"./chunk-J4FIESTB.js";import{createHash as U}from"crypto";import{createReadStream as F}from"fs";import{mkdir as x,readFile as P,rename as $,writeFile as D}from"fs/promises";import{dirname as b,join as E}from"path";var k=60,S=5;function C(){return{entries:[]}}function v(){return E(m,"mobile","app-cache.json")}async function h(e){let r=U("sha256");for await(let t of F(e))r.update(t);return r.digest("hex")}function N(){return{readFile:e=>P(e,"utf8"),writeFile:async(e,r)=>{await x(b(e),{recursive:!0});let t=`${e}.tmp`;await D(t,r),await $(t,e)},hashFile:h,now:()=>new Date}}function g(e){if(!e)return;let r=/\/(\d{4})\/(\d{2})\/(\d{2})\//.exec(e);if(!r)return;let[,t,a,i]=r,o=new Date(`${t}-${a}-${i}T00:00:00Z`);return Number.isNaN(o.getTime())?void 0:o.toISOString()}function O(e,r){if(!e.storedAt)return!0;let t=new Date(e.storedAt).getTime();return Number.isNaN(t)?!0:(r.getTime()-t)/864e5>=k-S}var d=class{deps;constructor(r={}){this.deps={...N(),...r}}async read(){try{let r=JSON.parse(await this.deps.readFile(v()));if(!r||typeof r!="object")return C();let t=r;return{entries:Array.isArray(t.entries)?t.entries:[]}}catch{return C()}}async write(r){await this.deps.writeFile(v(),JSON.stringify(r,null,2))}async hashOf(r){return this.deps.hashFile(r)}async lookup(r){return(await this.read()).entries.find(a=>a.sha256===r.sha256&&a.env===r.env&&a.orgId===r.orgId&&a.type===r.type)}async remember(r){let t=await this.read();t.entries=[...t.entries.filter(a=>!(a.sha256===r.sha256&&a.env===r.env&&a.orgId===r.orgId&&a.type===r.type)),r],await this.write(t)}async forget(r){let t=await this.read(),a=t.entries.length;t.entries=t.entries.filter(i=>!(i.sha256===r.sha256&&i.env===r.env&&i.orgId===r.orgId&&i.type===r.type)),t.entries.length!==a&&await this.write(t)}isNearExpiry(r){return O(r,this.deps.now())}};import{createHash as j}from"crypto";import{readdir as T,stat as _}from"fs/promises";import{basename as p,extname as B,join as R,relative as Y}from"path";function ae(e){return e.skipped===!0}function H(e,r){return A(r,e)?null:B(e).toLowerCase()===".ipa"&&!c(r)?`${p(e)} is a device build \u2014 .ipa is not accepted for ${r} runs.`:c(r)?`${p(e)} is not an ${y(w(r))} build \u2014 ${l(r)} takes ${f(r).join(" or ")}.`:`${p(e)} cannot be uploaded for ${l(r)} \u2014 expected one of ${f(r).join(", ")}.`}async function J(e,r){if(!(await _(e)).isDirectory())return r.hashOf(e);let a=[],i=async n=>{for(let s of await T(n,{withFileTypes:!0})){let u=R(n,s.name);s.isDirectory()?await i(u):s.isFile()&&a.push(u)}};await i(e),a.sort();let o=j("sha256");for(let n of a)o.update(Y(e,n)),o.update("\0"),o.update(await h(n)),o.update("\0");return o.digest("hex")}async function se(e){let r=H(e.path,e.type);if(r)return{skipped:!0,reason:r};let t=e.cache??new d,a=e.client??new I(e.baseUrl,{...e.auth,orgId:e.orgId}),i;try{i=await J(e.path,t)}catch(s){return{skipped:!0,reason:`could not read ${p(e.path)}: ${s.message}`}}let o={sha256:i,env:e.env,orgId:e.orgId,type:e.type},n=await t.lookup(o);if(n){if(await a.liveness(n.appId)!=="gone")return{appId:n.appId,...n.appUrl?{appUrl:n.appUrl}:{},fromCache:!0};e.onProgress?.(`${n.appId} is no longer in the cloud \u2014 uploading again`),await t.forget(o)}try{e.onProgress?.(`uploading ${p(e.path)}\u2026`);let s=await a.upload(e.path,e.type);return await t.remember({sha256:i,env:e.env,orgId:e.orgId,type:e.type,appId:s.appId,...s.appUrl?{appUrl:s.appUrl}:{},...g(s.url)?{storedAt:g(s.url)}:{},sourcePath:e.path}),e.onProgress?.(s.cached?`${p(e.path)} already in the cloud (${s.appId})`:`${p(e.path)} uploaded (${s.appId})`),{appId:s.appId,...s.appUrl?{appUrl:s.appUrl}:{},fromCache:!1}}catch(s){return{skipped:!0,reason:s.message}}}export{d as a,ae as b,H as c,J as d,se as e};
|
|
@@ -1,5 +1,5 @@
|
|
|
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-ZCBOHWN3.js";import{a as p}from"./chunk-RZ4F3BHX.js";function f(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=new Array(t.length+1),o=new Array(t.length+1);for(let r=0;r<=t.length;r++)n[r]=r;for(let r=1;r<=e.length;r++){o[0]=r;for(let i=1;i<=t.length;i++){let s=e[r-1]===t[i-1]?0:1;o[i]=Math.min(n[i]+1,o[i-1]+1,n[i-1]+s)}[n,o]=[o,n]}return n[t.length]}function C(e){let t=e.indexOf(".");return t>=0?e.slice(0,t):e}function l(e){return e.toLowerCase().replace(/\+/g,"plus").replace(/[^a-z0-9]/g,"")}function u(e){return e==="ios"?{os:"iOS",device:"simulator",target:"simulator"}:{os:"Android",device:"emulator",target:"emulator"}}var x=.4,y=3;function _(e,t,n){let o=l(t);if(o==="")return[];let r=Math.max(1,Math.round(o.length*x)),i=[];for(let s of e.devices){if(n&&!s.osVersions.includes(n))continue;let a=Math.min(f(o,l(s.name)),s.configName?f(o,l(s.configName)):1/0);a<=r&&i.push({device:s,score:a})}return i.sort((s,a)=>s.score-a.score||s.device.name.localeCompare(a.device.name)),i.slice(0,y).map(s=>s.device)}function w(e,t){let n=Number.parseFloat(t);if(!Number.isFinite(n))return e.osVersions[e.osVersions.length-1];let o,r=1/0;for(let i of e.osVersions){let s=Math.abs(Number.parseFloat(i)-n);Number.isFinite(s)&&s<r&&(r=s,o=i)}return o??e.osVersions[e.osVersions.length-1]}function D(e){return` See all devices: kane-cli devices list --target ${u(e).target} --remote`}function N(e,t){let n=l(t);return e.devices.find(o=>l(o.name)===n||o.configName!==void 0&&l(o.configName)===n)}function k(e,t){return e.runson?.[C(t)]}function G(e,t,n){let o=u(e.platform),r=N(e,t);if(!r){let i=_(e,t,n),s=i.length?` Did you mean: ${i.map(a=>`${a.name} (${a.osVersions.join(", ")})`).join(`
|
|
3
3
|
`)}
|
|
4
4
|
`:"";return{ok:!1,code:"device_not_found",detail:`no ${o.device} device named "${t}"`+(n&&i.length?` running ${o.os} ${n}`:"")+`.
|
|
5
5
|
${s}${D(e.platform)}`}}if(!r.osVersions.includes(n)){let i=w(r,n);return{ok:!1,code:"device_os_version_unsupported",detail:`${r.name} does not run ${o.os} ${n}.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as xe}from"./chunk-
|
|
2
|
+
import{a as xe}from"./chunk-GBQ4K25P.js";import{a as W,b as H}from"./chunk-PGESS7BW.js";import{a as G}from"./chunk-FWGUISUG.js";import{a as se,b as ae,c as ce,d as ue,e as le,q as U}from"./chunk-Z24SD2EJ.js";import{b as V}from"./chunk-CQDCNP7V.js";import{M as F,j as D,k as N}from"./chunk-PI7OXS62.js";import{g as Ue,o as v}from"./chunk-HYJVYYAZ.js";var A="https://integrations.lambdatest.com",y=class extends Error{constructor(t,r){super(r);this.code=t;this.name="LisError"}};function Nt(e){let n=e.TESTMUAI_ENV==="stage"?"stage":"prod";return`${Ue().authEnvironments[n].shareApiBaseUrl}/lis/api/v1`}function Pt(e){let n=e.env??process.env,t=e.auth?.TESTMUAI_BASIC_AUTH||n.TESTMUAI_BASIC_AUTH;if(t)return{authorization:`Basic ${t}`};let r=e.auth?.TESTMUAI_API_KEY||n.TESTMUAI_API_KEY;return r?{authorization:`Bearer ${r}`}:{}}function C(e){let n=e.split(`
|
|
3
3
|
`,1)[0].replace(/[\u0000-\u001f\u007f-\u009f]/g,"");return n.length>200?`${n.slice(0,200)}\u2026`:n}function Tt(e,n,t="the issue"){return e===401||e===403?new y("LIS_AUTH",v().text("LIS_AUTH",{})):e>=500?new y("LIS_UNAVAILABLE",`the integrations service returned an error (HTTP ${e}) \u2014 retry later`):new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${t}: ${C(n)||`HTTP ${e}`}`)}function P(e){try{return JSON.parse(e.bytes.toString("utf8"))}catch{throw new y("LIS_UNAVAILABLE","the integrations service returned a malformed response \u2014 retry later")}}function be(e){try{return JSON.parse(e.bytes.toString("utf8"))}catch{return{}}}function Be(e){return be(e).code}function R(e,n="the issue",t="Atlassian"){let r=be(e),i=t==="Atlassian"?"Confluence":t;switch(r.code){case"TOKEN_EXPIRED":return new y("LIS_SETUP",`your ${t} connection needs a resync \u2014 reconnect at ${A} and retry`);case"NOT_INSTALLED":return new y("LIS_SETUP",`no ${t} connection for this account \u2014 create one at ${A} and retry`);case"SCOPE_MISSING":return new y("LIS_SETUP",`the connection has no ${i} access \u2014 reconnect with ${i} at ${A} and retry`);case"FORBIDDEN":return new y("LIS_FORBIDDEN",`you don't have access to ${n}`);case"NOT_FOUND":return new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${n}: ${C(r.message??"")||"not found"}`);case"PAYLOAD_TOO_LARGE":return new y("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");case"INVALID_PAYLOAD":return new y("LIS_UNAVAILABLE",`the integrations service rejected the request (${C(r.message??"")||"invalid payload"}) \u2014 retry later`);case"NOT_SUPPORTED":return new y("LIS_UNAVAILABLE","the integrations service does not support this operation yet");case"UPSTREAM_ERROR":case"UPSTREAM_TIMEOUT":return new y("LIS_UNAVAILABLE",`${t} is not responding through the integrations service \u2014 retry later`);default:return Tt(e.status,r.message??"",n)}}var Dt=3e4,Ut=5;async function k(e,n,t){let r=t.env??process.env,i=t.fetchImpl??fetch;for(let o=0;;o++){let u=new AbortController,l=setTimeout(()=>u.abort(),Dt);try{let s=await i(`${Nt(r)}${e}`,{...n,headers:{"content-type":"application/json",...Pt(t),...n.headers??{}},signal:u.signal}),c=await Promise.race([s.arrayBuffer(),new Promise((f,p)=>{u.signal.addEventListener("abort",()=>p(new DOMException("aborted","AbortError")),{once:!0})})]),a={status:s.status,ok:s.ok,headers:s.headers,bytes:Buffer.from(c)};if(a.status===429){if(o>0)throw new y("LIS_RATE_LIMITED","the integrations service is busy \u2014 try again in a moment");let f=be(a).data?.retry_after_sec,p=Math.min(Math.max(typeof f=="number"&&Number.isFinite(f)?f:1,0),Ut);clearTimeout(l),await new Promise(h=>setTimeout(h,p*1e3));continue}return a}catch(s){throw s instanceof y?s:u.signal.aborted?new y("LIS_UNAVAILABLE","the integrations service did not respond within 30 seconds \u2014 retry later"):new y("LIS_UNAVAILABLE",`could not reach the integrations service (${C(s instanceof Error?s.message:String(s))}) \u2014 check your connection and retry`)}finally{clearTimeout(l)}}}function Y(e){let n=e.headers.get("content-type")??"application/octet-stream";if(n.includes("json"))try{let t=JSON.parse(e.bytes.toString("utf8")),r=t.content??t.data?.content;if(typeof r=="string")return{bytes:Buffer.from(r,"base64"),mediaType:t.mime_type??t.data?.mime_type??"application/octet-stream"}}catch{}return{bytes:e.bytes,mediaType:n}}async function q(e={}){let n=await k("/jira/info",{method:"GET"},e);if(!n.ok)throw R(n);let t=P(n),r=(t.data?.SELECTED_PROJECTS??[]).map(i=>i?.key).filter(i=>typeof i=="string"&&i.length>0);return{installed:t.data?.INSTALLED==="YES",selectAll:t.data?.SELECT_ALL===!0,selectedProjects:r,capabilities:{document:t.data?.capabilities?.document===!0,comments:t.data?.capabilities?.comments===!0}}}async function Q(e,n={}){let t=await k("/jira/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"jira",issueKey:e})},n);if(!t.ok)throw R(t);let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${C(r.message??"")||"issue not found or not accessible"}`);return r.data}var je=100,xt=5e3,Bt=60;async function ee(e,n={}){let t=[],r=new Set,i=null,o=0;for(let u=0;;u++){if(u>=Bt)throw new y("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let l=await k("/jira/issue/comments",{method:"POST",body:JSON.stringify({resource_id:e,max_results:je,cursor:i,start_at:o,order_by:"created",fetch_all:!1})},n);if(!l.ok)throw R(l,"the issue's comments");let s=P(l);if(s.type==="error"||!s.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${C(s.message??"")||"unavailable"}`);for(let g of s.data.comments??[]){let d=String(g.id);r.has(d)||(r.add(d),t.push(g))}let c=s.data.pagination;if(!c?.has_more)return t;if(t.length>=xt)throw new y("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let a=c.next_cursor??null,f=c.next_start_at!=null,p=f?c.next_start_at:o+je;if(!(a!=null&&a!==i||a==null&&f&&p!==o))throw new y("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");i=a,o=p}}async function te(e,n={}){let t=await k("/jira/attachment",{method:"POST",body:JSON.stringify({attachment_id:e})},n);if(!t.ok){if(Be(t)===void 0){if(t.status===413)throw new y("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");if(t.status===404)throw new y("JIRA_NOT_CONNECTED",`Jira is not connected for this account \u2014 connect it at ${A} and retry`)}throw R(t,`attachment ${e}`)}return Y(t)}var de="kane.source.jira/2";function Me(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){let n=e.map(Me).filter(t=>t!==null);return n.length===0?null:n.join(", ")}if(e!==null&&typeof e=="object"){let n=e;for(let t of["name","value","displayName"])if(typeof n[t]=="string")return n[t];return null}return null}function Fe(e,n,t){let r=[],i={},o=e.additional_fields??{};for(let a of Object.keys(o).sort()){let f=Me(o[a]);if(f===null){r.push(`field "${a}" has no stable text form \u2014 dropped from the envelope`);continue}i[a]=f}let u=[...e.attachments??[]].map(a=>({id:String(a.id),filename:a.filename??"",media_type:a.mime_type??"application/octet-stream",size:a.size??0})).sort((a,f)=>{let p=Number(a.id),h=Number(f.id);return Number.isFinite(p)&&Number.isFinite(h)?p-h:a.id<f.id?-1:a.id>f.id?1:0}),l=t.map(a=>({id:String(a.id),author:a.author?.display_name??"",body:a.body??"",created:a.created??""})).sort((a,f)=>{if(a.created!==f.created)return a.created<f.created?-1:1;let p=Number(a.id),h=Number(f.id);return Number.isFinite(p)&&Number.isFinite(h)&&p!==h?p-h:a.id<f.id?-1:a.id>f.id?1:0}),s=e.key;if(!/^[A-Za-z][A-Za-z0-9_]*-\d+$/.test(s))throw new Error(`cannot build a stable identity for issue key "${s}" \u2014 expected a PROJECT-NUMBER key`);let c={schema:de,site:n,project:s.slice(0,s.lastIndexOf("-")),issue:{id:e.id,key:s},content:{summary:e.summary??"",description:e.description??"",fields:i},attachments:u,comments:l};return{bytes:Buffer.from(JSON.stringify(c),"utf8"),envelope:c,warnings:r}}var Je=64,jt=16,Mt=6e6,Ft=5e7,Jt=12e6,Kt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},Vt=new Set(["png","jpeg","webp"]);function _e(e){return async n=>{let t;try{t=JSON.parse(n.toString("utf8"))}catch{throw new Error("JIRA_ENVELOPE_SCHEMA: source bytes are not a kane jira envelope")}if(t.schema!==de)throw new Error(`JIRA_ENVELOPE_SCHEMA: unknown envelope schema "${t.schema}" \u2014 this CLI understands ${de}`);let r=[],i=new Map,o=[],u=0,l=new Map,s=[];for(let f=0;f<t.attachments.length;f++){let p=t.attachments[f],h=`i${f+1}`,g=`attachment:${p.filename}`,d=S=>`[img#${h}] ${p.filename} (${p.media_type}, ${p.size} bytes${S?"":" \u2014 not delivered"})`,m=(S,O,M)=>{r.push({ref:h,loc:g,media_type:S,...M?.blob?{blob:M.blob}:{},...M?.appearance?{appearance:M.appearance}:{},delivery:O,...M?.duplicate_of?{duplicate_of:M.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){m(p.media_type,"unsupported-vision-media-type"),s.push(d(!1));continue}let E;try{E=await e.fetchAttachment(p.id)}catch{m(p.media_type,"external-image-not-fetched"),s.push(d(!1));continue}let I=E.bytes,w=W(I),b=Kt[w.format],L=V(I);if(i.set(L,I),!Vt.has(w.format)){let S=w.format==="gif"||w.format==="bmp"||w.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";m(b,S,{blob:L}),s.push(d(!1));continue}if(w.width===void 0||w.height===void 0||w.width*w.height>Ft){m(b,"undecodable",{blob:L}),s.push(d(!1));continue}let _;if(w.format==="png"||w.format==="jpeg"){let S=H(I,w.format);if(S===null){m(b,"undecodable",{blob:L}),s.push(d(!1));continue}_=G(S.data,{width:S.width,height:S.height,channels:S.channels})}if(w.width<Je||w.height<Je){m(b,"below-dimension-floor",{blob:L,appearance:_}),s.push(d(!1));continue}let T=l.get(L);if(T!==void 0){m(b,"duplicate",{blob:L,appearance:_,duplicate_of:T}),s.push(d(!1));continue}if(I.byteLength>Mt){m(b,"image-too-large",{blob:L,appearance:_}),s.push(d(!1));continue}if(u+I.byteLength>Jt){m(b,"vision-byte-budget-reached",{blob:L,appearance:_}),s.push(d(!1));continue}if(o.length>=jt){m(b,"image-cap-reached",{blob:L,appearance:_}),s.push(d(!1));continue}l.set(L,h),u+=I.byteLength,o.push(h),m(b,"selected",{blob:L,appearance:_}),s.push(d(!0))}let c=[];c.push(`${t.issue.key} \xB7 ${t.site}/${t.project}`,`Summary: ${t.content.summary}`),t.content.description!==""&&c.push("",...t.content.description.split(`
|
|
4
4
|
`));let a=Object.keys(t.content.fields);return a.length>0&&c.push("","--- fields ---",...a.map(f=>`${f}: ${t.content.fields[f]}`)),s.length>0&&c.push("","--- attachments ---",...s),t.comments.length>0&&(c.push("","--- comments ---"),t.comments.forEach((f,p)=>{p>0&&c.push(""),c.push(`[${p+1}] ${f.author} \xB7 ${f.created}`,...f.body.split(`
|
|
5
5
|
`))})),{projection:c.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`,inventory:r,blobs:i,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var Gt=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function ne(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}let t=n.pathname.split("/").filter(Boolean),r=t.lastIndexOf("browse");if(r===-1||r+1>=t.length)return null;let i=t[r+1];return Gt.test(i)?{site:n.hostname,issueKey:i.toUpperCase()}:null}function pe(e,n){let t=F(e),r=t.heads.get(n);return r==null?null:Ve(e,t,r)}function fe(e,n){let r=pe(e,n)?.site;return typeof r=="string"&&r.length>0?r:null}function we(e,n,t,r){let i=F(e);for(let[o,u]of i.heads){if(u==null||i.mediaOf(u).format!==n)continue;let l=Ve(e,i,u);if(l===null)continue;let s=l;for(let c of t){if(s===null||typeof s!="object"){s=void 0;break}s=s[c]}if(s===r)return o}return null}function Ve(e,n,t){let r=n.getNode(t)?.content?.blob;if(typeof r!="string")return null;let i=e.getBlob(r);if(i===null)return null;try{let o=JSON.parse(i.toString("utf8"));return o!==null&&typeof o=="object"?o:null}catch{return null}}var Ke={jira:"a jira issue source",confluence:"a confluence page source",linear:"a linear issue source","linear-doc":"a linear document source",web:"a web page source"};function x(e,n,t){let r=F(e),i=r.heads.get(n);if(i==null)return null;let o=r.mediaOf(i).format;if(o===t)return null;let u=Ke[o]??`${o} content`;return v().text("note.kind_taken",{source_id:n,backing:u,kind:Ke[t]??t})}function $(e,n){let t=F(e);for(let r=2;;r++)if(!t.heads.has(`${n}-${r}`))return`${n}-${r}`}function J(e,n){let t=F(e),r=t.heads.get(n);return r==null?null:t.mediaOf(r).format}async function Ge(e,n,t){let r=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee};try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.jiraInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Atlassian connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.comments===!1)return{ok:!1,failure:{code:"NO_COMMENTS_ACCESS",message:`the connection cannot read issue comments yet \u2014 resync it at ${A} and retry`}};let l=e.issueKey.slice(0,e.issueKey.lastIndexOf("-"));if(!u.selectAll&&u.selectedProjects.length>0&&!u.selectedProjects.includes(l))return{ok:!1,failure:{code:"PROJECT_NOT_SELECTED",message:`project ${l} is not in the integration's selected projects (${u.selectedProjects.join(", ")}) \u2014 add it at ${A}`,facts:{project:l}}};let s=await r.jiraIssue(e.issueKey,o),c=await r.jiraComments(e.issueKey,o),a=e.site;if(s.host)try{a=new URL(s.host).hostname}catch{a=s.host.replace(/^https?:\/\//,"").replace(/[/:].*$/,"")}let{bytes:f,warnings:p}=Fe(s,a,c),h=n??e.issueKey.toLowerCase();try{N(h)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}return{ok:!0,bytes:f,site:a,sourceId:h,warnings:p,lis:r,lisDeps:o}}catch(i){return i instanceof y?{ok:!1,failure:{code:i.code,message:i.message}}:{ok:!1,failure:{code:"FETCH_FAILED",message:He(i instanceof Error?i.message:String(i))}}}}function We(e,n,t){let r=x(e,n,"jira");if(r!==null)return{code:"KIND_MISMATCH",message:r,facts:{id:n,heldKind:J(e,n)??"",freeId:$(e,n)}};let i=fe(e,n);return i!==null&&i!==t?{code:"SITE_MOVED",message:v().text("note.site_moved",{source_id:n,previous:i,site:t}),facts:{id:n,freeId:$(e,n)}}:null}async function Wt(e,n,t,r,i){let o=ne(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)`),{code:1};let u=await Ge(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,site:s,sourceId:c,warnings:a,lis:f,lisDeps:p}=u;try{let h=We(r,c,s);if(h!==null)return(t.err??t.out)(`error: ${e}: ${h.message}`),{code:1};let g=await U({store:r,bytes:l,media:se,sourceId:c,label:e,confirmSameSource:t.isTTY?d=>t.confirm(`identical content already ingested as ${d} \u2014 treat as the same source?`):void 0,converters:{jira:_e({fetchAttachment:d=>f.jiraAttachment(d,p)})}});t.out(B(t.isTTY,g,o.issueKey));for(let d of a)t.out(`warning: ${d}`);for(let d of g.warnings??[])t.out(`warning: ${d}`);if(g.composite){let d=g.composite.delivered+g.composite.omitted;t.out(`${g.source_id}: jira, ${d} attachments, ${g.composite.delivered} images delivered (${g.composite.omitted} omitted)`)}return{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid,...g.gitignore?{gitignore:g.gitignore}:{}}}}catch(h){return h instanceof y?((t.err??t.out)(`error: ${e}: ${h.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${He(h instanceof Error?h.message:String(h))}`),{code:1})}}async function Ht(e,n,t){let r=ne(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await Ge(r,n,t);return i.ok?{ok:!0,fetched:{provider:"jira",sourceId:i.sourceId,bytes:i.bytes,media:se,label:e,display:r.issueKey,origin:{kind:"jira",url:e},identity:{site:i.site},warnings:i.warnings}}:i}async function Yt(e,n,t){let r=We(n,e.sourceId,e.identity.site??"");if(r!==null)return{ok:!1,failure:r};let i=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee},u={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env};return{ok:!0,media:se,label:e.label,converters:{jira:_e({fetchAttachment:l=>i.jiraAttachment(l,u)})}}}function He(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the issue's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the description or attachments in Jira and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?"the issue's text is too large to ingest \u2014 trim the description in Jira and retry":e}var Ye={name:"jira",hint:"Jira issue URLs (https://<site>/browse/KEY-123)",match:e=>ne(e)!==null,ingest:Wt,sourceIdFor:e=>{let n=ne(e);return n?n.issueKey.toLowerCase():null},fetch:Ht,prepare:Yt};async function Le(e,n={}){let t=await k("/jira/document",{method:"POST",body:JSON.stringify({resource_id:e,format:"markdown"})},n);if(!t.ok)throw R(t,"the page");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the page: ${C(r.message??"")||"page not found or not accessible"}`);return r.data}async function Ie(e,n={}){let t=await k("/jira/attachment",{method:"POST",body:JSON.stringify({source:"confluence",download:e})},n);if(!t.ok)throw R(t,"the page's attachment");return{bytes:Y(t).bytes}}var me="kane.source.confluence/1";function ze(e,n){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this page \u2014 the integrations service returned no page id");let t=[...e.labels??[]].filter(o=>typeof o=="string").sort(),r=[...e.attachments??[]].map(o=>({id:String(o.id),filename:o.filename??"",media_type:o.mime_type??"application/octet-stream",size:o.size??0})).sort((o,u)=>o.id<u.id?-1:o.id>u.id?1:0),i={schema:me,site:n,page:{id:e.id},space:{key:e.space?.key??""},title:e.title??"",labels:t,content:{body:e.body??""},attachments:r};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}var Xe=64,zt=16,Xt=6e6,Zt=5e7,qt=12e6,Qt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},en=new Set(["png","jpeg","webp"]);function Ze(e){let n=new Map(Object.entries(e.downloads));return async t=>{let r;try{r=JSON.parse(t.toString("utf8"))}catch{throw new Error("CONFLUENCE_ENVELOPE_SCHEMA: source bytes are not a kane confluence envelope")}if(r.schema!==me)throw new Error(`CONFLUENCE_ENVELOPE_SCHEMA: unknown envelope schema "${r.schema}" \u2014 this CLI understands ${me}`);let i=[],o=new Map,u=[],l=0,s=new Map,c=[];for(let f=0;f<r.attachments.length;f++){let p=r.attachments[f],h=`i${f+1}`,g=`attachment:${p.filename}`,d=O=>`[img#${h}] ${p.filename} (${p.media_type}, ${p.size} bytes${O?"":" \u2014 not delivered"})`,m=(O,M,K)=>{i.push({ref:h,loc:g,media_type:O,...K?.blob?{blob:K.blob}:{},...K?.appearance?{appearance:K.appearance}:{},delivery:M,...K?.duplicate_of?{duplicate_of:K.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){m(p.media_type,"unsupported-vision-media-type"),c.push(d(!1));continue}let E=n.get(p.id);if(!E){m(p.media_type,"external-image-not-fetched"),c.push(d(!1));continue}let I;try{I=await e.fetchAttachment({id:p.id,download:E})}catch{m(p.media_type,"external-image-not-fetched"),c.push(d(!1));continue}let w=I.bytes,b=W(w),L=Qt[b.format],_=V(w);if(o.set(_,w),!en.has(b.format)){let O=b.format==="gif"||b.format==="bmp"||b.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";m(L,O,{blob:_}),c.push(d(!1));continue}if(b.width===void 0||b.height===void 0||b.width*b.height>Zt){m(L,"undecodable",{blob:_}),c.push(d(!1));continue}let T;if(b.format==="png"||b.format==="jpeg"){let O=H(w,b.format);if(O===null){m(L,"undecodable",{blob:_}),c.push(d(!1));continue}T=G(O.data,{width:O.width,height:O.height,channels:O.channels})}if(b.width<Xe||b.height<Xe){m(L,"below-dimension-floor",{blob:_,appearance:T}),c.push(d(!1));continue}let S=s.get(_);if(S!==void 0){m(L,"duplicate",{blob:_,appearance:T,duplicate_of:S}),c.push(d(!1));continue}if(w.byteLength>Xt){m(L,"image-too-large",{blob:_,appearance:T}),c.push(d(!1));continue}if(l+w.byteLength>qt){m(L,"vision-byte-budget-reached",{blob:_,appearance:T}),c.push(d(!1));continue}if(u.length>=zt){m(L,"image-cap-reached",{blob:_,appearance:T}),c.push(d(!1));continue}s.set(_,h),l+=w.byteLength,u.push(h),m(L,"selected",{blob:_,appearance:T}),c.push(d(!0))}let a=[];return a.push(`${r.title} \xB7 ${r.site} \xB7 ${r.space.key}`),r.labels.length>0&&a.push(`labels: ${r.labels.join(", ")}`),r.content.body!==""&&a.push("",...r.content.body.split(`
|
|
7
|
+
`,inventory:r,blobs:i,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var Gt=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function ne(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}let t=n.pathname.split("/").filter(Boolean),r=t.lastIndexOf("browse");if(r===-1||r+1>=t.length)return null;let i=t[r+1];return Gt.test(i)?{site:n.hostname,issueKey:i.toUpperCase()}:null}function pe(e,n){let t=F(e),r=t.heads.get(n);return r==null?null:Ve(e,t,r)}function fe(e,n){let r=pe(e,n)?.site;return typeof r=="string"&&r.length>0?r:null}function we(e,n,t,r){let i=F(e);for(let[o,u]of i.heads){if(u==null||i.mediaOf(u).format!==n)continue;let l=Ve(e,i,u);if(l===null)continue;let s=l;for(let c of t){if(s===null||typeof s!="object"){s=void 0;break}s=s[c]}if(s===r)return o}return null}function Ve(e,n,t){let r=n.getNode(t)?.content?.blob;if(typeof r!="string")return null;let i=e.getBlob(r);if(i===null)return null;try{let o=JSON.parse(i.toString("utf8"));return o!==null&&typeof o=="object"?o:null}catch{return null}}var Ke={jira:"a jira issue source",confluence:"a confluence page source",linear:"a linear issue source","linear-doc":"a linear document source",web:"a web page source"};function x(e,n,t){let r=F(e),i=r.heads.get(n);if(i==null)return null;let o=r.mediaOf(i).format;if(o===t)return null;let u=Ke[o]??`${o} content`;return v().text("note.kind_taken",{source_id:n,backing:u,kind:Ke[t]??t})}function $(e,n){let t=F(e);for(let r=2;;r++)if(!t.heads.has(`${n}-${r}`))return`${n}-${r}`}function J(e,n){let t=F(e),r=t.heads.get(n);return r==null?null:t.mediaOf(r).format}async function Ge(e,n,t){let r=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee};try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.jiraInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Atlassian connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.comments===!1)return{ok:!1,failure:{code:"NO_COMMENTS_ACCESS",message:`the connection cannot read issue comments yet \u2014 resync it at ${A} and retry`}};let l=e.issueKey.slice(0,e.issueKey.lastIndexOf("-"));if(!u.selectAll&&u.selectedProjects.length>0&&!u.selectedProjects.includes(l))return{ok:!1,failure:{code:"PROJECT_NOT_SELECTED",message:`project ${l} is not in the integration's selected projects (${u.selectedProjects.join(", ")}) \u2014 add it at ${A}`,facts:{project:l}}};let s=await r.jiraIssue(e.issueKey,o),c=await r.jiraComments(e.issueKey,o),a=e.site;if(s.host)try{a=new URL(s.host).hostname}catch{a=s.host.replace(/^https?:\/\//,"").replace(/[/:].*$/,"")}let{bytes:f,warnings:p}=Fe(s,a,c),h=n??e.issueKey.toLowerCase();try{N(h)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}return{ok:!0,bytes:f,site:a,sourceId:h,warnings:p,lis:r,lisDeps:o}}catch(i){return i instanceof y?{ok:!1,failure:{code:i.code,message:i.message}}:{ok:!1,failure:{code:"FETCH_FAILED",message:He(i instanceof Error?i.message:String(i))}}}}function We(e,n,t){let r=x(e,n,"jira");if(r!==null)return{code:"KIND_MISMATCH",message:r,facts:{id:n,heldKind:J(e,n)??"",freeId:$(e,n)}};let i=fe(e,n);return i!==null&&i!==t?{code:"SITE_MOVED",message:v().text("note.site_moved",{source_id:n,previous:i,site:t}),facts:{id:n,freeId:$(e,n)}}:null}async function Wt(e,n,t,r,i){let o=ne(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)`),{code:1};let u=await Ge(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,site:s,sourceId:c,warnings:a,lis:f,lisDeps:p}=u;try{let h=We(r,c,s);if(h!==null)return(t.err??t.out)(`error: ${e}: ${h.message}`),{code:1};let g=await U({store:r,bytes:l,media:se,sourceId:c,label:e,confirmSameSource:t.isTTY?d=>t.confirm(`identical content already ingested as ${d} \u2014 treat as the same source?`):void 0,converters:{jira:_e({fetchAttachment:d=>f.jiraAttachment(d,p)})}});t.out(B(t.isTTY,g,o.issueKey));for(let d of a)t.out(`warning: ${d}`);for(let d of g.warnings??[])t.out(`warning: ${d}`);if(g.composite){let d=g.composite.delivered+g.composite.omitted;t.out(`${g.source_id}: jira, ${d} attachments, ${g.composite.delivered} images delivered (${g.composite.omitted} omitted)`)}return{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid,...g.gitignore?{gitignore:g.gitignore}:{}}}}catch(h){return h instanceof y?((t.err??t.out)(`error: ${e}: ${h.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${He(h instanceof Error?h.message:String(h))}`),{code:1})}}async function Ht(e,n,t){let r=ne(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await Ge(r,n,t);return i.ok?{ok:!0,fetched:{provider:"jira",sourceId:i.sourceId,bytes:i.bytes,media:se,label:e,display:r.issueKey,origin:{kind:"jira",url:e},identity:{site:i.site},warnings:i.warnings}}:i}async function Yt(e,n,t){let r=We(n,e.sourceId,e.identity.site??"");if(r!==null)return{ok:!1,failure:r};let i=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee},u={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env};return{ok:!0,media:se,label:e.label,converters:{jira:_e({fetchAttachment:l=>i.jiraAttachment(l,u)})}}}function He(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the issue's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the description or attachments in Jira and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?"the issue's text is too large to ingest \u2014 trim the description in Jira and retry":e}var Ye={name:"jira",hint:"Jira issue URLs (https://<site>/browse/KEY-123)",match:e=>ne(e)!==null,ingest:Wt,sourceIdFor:e=>{let n=ne(e);return n?n.issueKey.toLowerCase():null},fetch:Ht,prepare:Yt};async function Le(e,n={}){let t=await k("/jira/document",{method:"POST",body:JSON.stringify({resource_id:e,format:"markdown"})},n);if(!t.ok)throw R(t,"the page");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the page: ${C(r.message??"")||"page not found or not accessible"}`);return r.data}async function Ie(e,n={}){let t=await k("/jira/attachment",{method:"POST",body:JSON.stringify({source:"confluence",download:e})},n);if(!t.ok)throw R(t,"the page's attachment");return{bytes:Y(t).bytes}}var me="kane.source.confluence/1";function ze(e,n){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this page \u2014 the integrations service returned no page id");let t=[...e.labels??[]].filter(o=>typeof o=="string").sort(),r=[...e.attachments??[]].map(o=>({id:String(o.id),filename:o.filename??"",media_type:o.mime_type??"application/octet-stream",size:o.size??0})).sort((o,u)=>o.id<u.id?-1:o.id>u.id?1:0),i={schema:me,site:n,page:{id:e.id},space:{key:e.space?.key??""},title:e.title??"",labels:t,content:{body:e.body??""},attachments:r};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}var Xe=64,zt=16,Xt=6e6,Zt=5e7,qt=12e6,Qt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},en=new Set(["png","jpeg","webp"]);function Ze(e){let n=new Map(Object.entries(e.downloads));return async t=>{let r;try{r=JSON.parse(t.toString("utf8"))}catch{throw new Error("CONFLUENCE_ENVELOPE_SCHEMA: source bytes are not a kane confluence envelope")}if(r.schema!==me)throw new Error(`CONFLUENCE_ENVELOPE_SCHEMA: unknown envelope schema "${r.schema}" \u2014 this CLI understands ${me}`);let i=[],o=new Map,u=[],l=0,s=new Map,c=[];for(let f=0;f<r.attachments.length;f++){let p=r.attachments[f],h=`i${f+1}`,g=`attachment:${p.filename}`,d=O=>`[img#${h}] ${p.filename} (${p.media_type}, ${p.size} bytes${O?"":" \u2014 not delivered"})`,m=(O,M,K)=>{i.push({ref:h,loc:g,media_type:O,...K?.blob?{blob:K.blob}:{},...K?.appearance?{appearance:K.appearance}:{},delivery:M,...K?.duplicate_of?{duplicate_of:K.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){m(p.media_type,"unsupported-vision-media-type"),c.push(d(!1));continue}let E=n.get(p.id);if(!E){m(p.media_type,"external-image-not-fetched"),c.push(d(!1));continue}let I;try{I=await e.fetchAttachment({id:p.id,download:E})}catch{m(p.media_type,"external-image-not-fetched"),c.push(d(!1));continue}let w=I.bytes,b=W(w),L=Qt[b.format],_=V(w);if(o.set(_,w),!en.has(b.format)){let O=b.format==="gif"||b.format==="bmp"||b.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";m(L,O,{blob:_}),c.push(d(!1));continue}if(b.width===void 0||b.height===void 0||b.width*b.height>Zt){m(L,"undecodable",{blob:_}),c.push(d(!1));continue}let T;if(b.format==="png"||b.format==="jpeg"){let O=H(w,b.format);if(O===null){m(L,"undecodable",{blob:_}),c.push(d(!1));continue}T=G(O.data,{width:O.width,height:O.height,channels:O.channels})}if(b.width<Xe||b.height<Xe){m(L,"below-dimension-floor",{blob:_,appearance:T}),c.push(d(!1));continue}let S=s.get(_);if(S!==void 0){m(L,"duplicate",{blob:_,appearance:T,duplicate_of:S}),c.push(d(!1));continue}if(w.byteLength>Xt){m(L,"image-too-large",{blob:_,appearance:T}),c.push(d(!1));continue}if(l+w.byteLength>qt){m(L,"vision-byte-budget-reached",{blob:_,appearance:T}),c.push(d(!1));continue}if(u.length>=zt){m(L,"image-cap-reached",{blob:_,appearance:T}),c.push(d(!1));continue}s.set(_,h),l+=w.byteLength,u.push(h),m(L,"selected",{blob:_,appearance:T}),c.push(d(!0))}let a=[];return a.push(`${r.title} \xB7 ${r.site} \xB7 ${r.space.key}`),r.labels.length>0&&a.push(`labels: ${r.labels.join(", ")}`),r.content.body!==""&&a.push("",...r.content.body.split(`
|
|
8
8
|
`)),c.length>0&&a.push("","--- attachments ---",...c),{projection:a.join(`
|
|
9
9
|
`)+`
|
|
10
|
-
`,inventory:i,blobs:o,delivered:u,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var tn=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function re(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}let t=n.pathname.split("/").filter(Boolean),r=t.indexOf("wiki");if(r===-1||t[r+1]!=="spaces"||t[r+3]!=="pages")return null;let i=t[r+2],o=t[r+4];return i===void 0||o===void 0||!tn.test(i)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:i,pageId:o}}async function qe(e,n,t){let r=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee},i=t.confluence??{confluenceDocument:Le,confluenceAttachment:Ie};try{let u={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},l=await r.jiraInfo(u);if(!l.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Atlassian connection for this account \u2014 create one at ${A} and retry`}};if(l.capabilities.document===!1)return{ok:!1,failure:{code:"NO_CONFLUENCE_ACCESS",message:`the connection has no Confluence access \u2014 reconnect with Confluence at ${A} and retry`}};let s=await i.confluenceDocument(e.pageId,u),c=e.site;if(s.url)try{c=new URL(s.url).hostname}catch{}let{bytes:a,warnings:f}=ze(s,c),p=n??`page-${e.pageId}`;try{N(p)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}let h=Object.fromEntries((s.attachments??[]).filter(g=>typeof g.download=="string"&&g.download.length>0).map(g=>[String(g.id),g.download]));return{ok:!0,bytes:a,site:c,sourceId:p,...s.title?{title:s.title}:{},warnings:f,downloads:h,remote:i,lisDeps:u}}catch(o){return o instanceof y?{ok:!1,failure:{code:o.code,message:o.message}}:{ok:!1,failure:{code:"FETCH_FAILED",message:tt(o instanceof Error?o.message:String(o))}}}}function Qe(e,n,t){let r=x(e,n,"confluence");if(r!==null)return{code:"KIND_MISMATCH",message:r,facts:{id:n,heldKind:J(e,n)??"",freeId:$(e,n)}};let i=fe(e,n);return i!==null&&i!==t?{code:"SITE_MOVED",message:v().text("note.site_moved",{source_id:n,previous:i,site:t}),facts:{id:n,freeId:$(e,n)}}:null}var et=(e,n,t)=>({confluence:Ze({downloads:e,fetchAttachment:r=>n.confluenceAttachment(r.download,t)})});async function nn(e,n,t,r,i){let o=re(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)`),{code:1};let u=await qe(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,site:s,sourceId:c,warnings:a,downloads:f,remote:p,lisDeps:h}=u;try{let g=Qe(r,c,s);if(g!==null)return(t.err??t.out)(`error: ${e}: ${g.message}`),{code:1};let d=await U({store:r,bytes:l,media:ae,sourceId:c,label:e,confirmSameSource:t.isTTY?m=>t.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:et(f,p,h)});t.out(B(t.isTTY,d,`${o.spaceKey}/${o.pageId}`));for(let m of a)t.out(`warning: ${m}`);for(let m of d.warnings??[])t.out(`warning: ${m}`);if(d.composite){let m=d.composite.delivered+d.composite.omitted;t.out(`${d.source_id}: confluence, ${m} attachments, ${d.composite.delivered} images delivered (${d.composite.omitted} omitted)`)}return{code:0,result:{status:d.status,source_id:d.source_id,source_cid:d.cid,...d.gitignore?{gitignore:d.gitignore}:{}}}}catch(g){return g instanceof y?((t.err??t.out)(`error: ${e}: ${g.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${tt(g instanceof Error?g.message:String(g))}`),{code:1})}}async function rn(e,n,t){let r=re(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await qe(r,n,t);return i.ok?{ok:!0,fetched:{provider:"confluence",sourceId:i.sourceId,bytes:i.bytes,media:ae,label:e,display:`${r.spaceKey}/${r.pageId}`,...i.title?{title:i.title}:{},origin:{kind:"confluence",url:e},identity:{site:i.site},warnings:i.warnings,downloads:i.downloads}}:i}async function on(e,n,t){let r=Qe(n,e.sourceId,e.identity.site??"");if(r!==null)return{ok:!1,failure:r};let i=t.confluence??{confluenceDocument:Le,confluenceAttachment:Ie},u={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env};return{ok:!0,media:ae,label:e.label,converters:et(e.downloads??{},i,u)}}function tt(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the page in Confluence and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?"the page's text is too large to ingest \u2014 trim the page in Confluence and retry":e}var nt={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:e=>re(e)!==null,ingest:nn,sourceIdFor:e=>{let n=re(e);return n?`page-${n.pageId}`:null},fetch:rn,prepare:on};async function rt(e={}){let n=await k("/linear-app/info",{method:"GET"},e);if(!n.ok)throw R(n,"the connection","Linear");let t=P(n);return{installed:t.data?.INSTALLED==="YES",capabilities:{issue:t.data?.capabilities?.issue===!0,comments:t.data?.capabilities?.comments===!0,document:t.data?.capabilities?.document===!0}}}async function it(e,n={}){let t=await k("/linear-app/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"linear-app",issueKey:e})},n);if(!t.ok)throw R(t,"the issue","Linear");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${C(r.message??"")||"issue not found or not accessible"}`);return r.data}var sn=100,an=5e3,cn=60;async function ot(e,n={}){let t=[],r=new Set,i=null;for(let o=0;;o++){if(o>=cn)throw new y("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let u=await k("/linear-app/issue/comments",{method:"POST",body:JSON.stringify({resource_id:e,max_results:sn,...i===null?{}:{cursor:i},fetch_all:!1})},n);if(!u.ok)throw R(u,"the issue's comments","Linear");let l=P(u);if(l.type==="error"||!l.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${C(l.message??"")||"unavailable"}`);if(l.data.partial)throw new y("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 retry later");for(let a of l.data.comments??[]){if(typeof a.id!="string"||a.id==="")throw new y("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 a comment row has no comment id");r.has(a.id)||(r.add(a.id),t.push(a))}let s=l.data.pagination;if(!s?.has_more)return t;if(t.length>=an)throw new y("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let c=s.next_cursor??null;if(c==null||c===i)throw new y("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");i=c}}async function st(e,n={}){let t=await k("/linear-app/document",{method:"POST",body:JSON.stringify({resource_id:e,format:"markdown"})},n);if(!t.ok)throw R(t,"the document","Linear");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the document: ${C(r.message??"")||"document not found or not accessible"}`);return r.data}async function at(e,n={}){let t=await k("/linear-app/attachment",{method:"POST",body:JSON.stringify({attachment_id:e})},n);if(!t.ok)throw R(t,"the attachment","Linear");return{bytes:Y(t).bytes}}var ge="kane.source.linear/1",he="kane.source.linear-doc/1",un=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g;function z(e){return e.replace(un,n=>{let t=n.indexOf("?");return t===-1?n:n.slice(0,t)})}function ct(e,n){return e.id<n.id?-1:e.id>n.id?1:0}function ln(e,n){return ct(e,n)||(e.filename<n.filename?-1:e.filename>n.filename?1:0)||(e.url<n.url?-1:e.url>n.url?1:0)}function ut(e,n,t){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this issue \u2014 the integrations service returned no issue id");let r=e.key;if(!/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(r)){let c=String(r).replace(/[\u0000-\u001f\u007f-\u009f]/g,"").slice(0,80);throw new Error(`cannot build a stable identity for issue key "${c}" \u2014 expected a TEAM-NUMBER key`)}let i={},o=[...e.labels??[]].filter(c=>typeof c=="string").sort();o.length>0&&(i.labels=o.join(", ")),typeof e.priority=="string"&&e.priority!==""&&(i.priority=e.priority),typeof e.project=="string"&&e.project!==""&&(i.project=e.project),typeof e.status=="string"&&e.status!==""&&(i.status=e.status);let u=(e.attachments??[]).map(c=>({id:c.id!=null&&String(c.id)!==""?String(c.id):z(c.download??""),filename:c.filename??"",url:z(c.download??"")})).sort(ln),l=n.map(c=>({id:String(c.id),author:c.author?.display_name??"",body:z(c.body??""),created:c.created??""})).sort((c,a)=>c.created!==a.created?c.created<a.created?-1:1:ct(c,a)),s={schema:ge,site:t,team:r.slice(0,r.lastIndexOf("-")),issue:{uuid:e.id,key:r},content:{title:e.summary??"",description:z(e.description??""),fields:i},attachments:u,comments:l};return{bytes:Buffer.from(JSON.stringify(s),"utf8"),envelope:s,warnings:[]}}function lt(e,n,t){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this document \u2014 the integrations service returned no document id");let r=(e.attachments??[]).map(o=>({url:z(o.download??String(o.id??"")),filename:o.filename??""})).sort((o,u)=>o.url<u.url?-1:o.url>u.url?1:0),i={schema:he,site:n,document:{uuid:e.id,slug_id:t},project:{id:e.space?.key??""},title:e.title??"",content:{body:z(e.body??"")},attachments:r};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}var dt=64,dn=16,pn=6e6,fn=5e7,mn=12e6,ye=64,pt="https://uploads.linear.app/",gn=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g,hn={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},yn=new Set(["png","jpeg","webp"]);async function ft(e,n){let t=[],r=new Map,i=[],o=0,u=new Map,l=[];for(let s=0;s<e.length;s++){let c=e[s],a=`i${s+1}`,f=b=>`[img#${a}] ${c.label}${b?"":" \u2014 not delivered"}`,p=(b,L,_)=>{t.push({ref:a,loc:c.loc,media_type:b,..._?.blob?{blob:_.blob}:{},..._?.appearance?{appearance:_.appearance}:{},delivery:L,..._?.duplicate_of?{duplicate_of:_.duplicate_of}:{}})},h;try{h=await n(c.url)}catch{p("application/octet-stream","external-image-not-fetched"),l.push(f(!1));continue}let g=h.bytes,d=W(g),m=hn[d.format],E=V(g);if(r.set(E,g),!yn.has(d.format)){let b=d.format==="gif"||d.format==="bmp"||d.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(m,b,{blob:E}),l.push(f(!1));continue}if(d.width===void 0||d.height===void 0||d.width*d.height>fn){p(m,"undecodable",{blob:E}),l.push(f(!1));continue}let I;if(d.format==="png"||d.format==="jpeg"){let b=H(g,d.format);if(b===null){p(m,"undecodable",{blob:E}),l.push(f(!1));continue}I=G(b.data,{width:b.width,height:b.height,channels:b.channels})}if(d.width<dt||d.height<dt){p(m,"below-dimension-floor",{blob:E,appearance:I}),l.push(f(!1));continue}let w=u.get(E);if(w!==void 0){p(m,"duplicate",{blob:E,appearance:I,duplicate_of:w}),l.push(f(!1));continue}if(g.byteLength>pn){p(m,"image-too-large",{blob:E,appearance:I}),l.push(f(!1));continue}if(o+g.byteLength>mn){p(m,"vision-byte-budget-reached",{blob:E,appearance:I}),l.push(f(!1));continue}if(i.length>=dn){p(m,"image-cap-reached",{blob:E,appearance:I}),l.push(f(!1));continue}u.set(E,a),o+=g.byteLength,i.push(a),p(m,"selected",{blob:E,appearance:I}),l.push(f(!0))}return{inventory:t,blobs:r,delivered:i,lines:l}}function En(e){let n=new Set,t=[];for(let r of e.match(gn)??[])n.has(r)||(n.add(r),t.push(r));return t}function ve(e){return async n=>{let t;try{t=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_ENVELOPE_SCHEMA: source bytes are not a kane linear envelope")}if(t.schema!==ge)throw new Error(`LINEAR_ENVELOPE_SCHEMA: unknown envelope schema "${t.schema}" \u2014 this CLI understands ${ge}`);let r=[],i=new Set;for(let a of En(t.content.description))i.add(a),r.push({url:a,label:a,loc:`body:${a}`});let o=[];for(let a of t.attachments)if(a.url.startsWith(pt)){if(i.has(a.url)){if(a.filename!==""){let f=r.find(p=>p.url===a.url);f!==void 0&&f.label===f.url&&(f.label=a.filename)}continue}i.add(a.url),r.push({url:a.url,label:a.filename||a.url,loc:`attachment:${a.filename||a.url}`})}else a.url!==""&&o.push(`[${o.length+1}] ${a.filename||a.url} \u2014 ${a.url}`);let u=Math.max(0,r.length-ye),l=await ft(r.slice(0,ye),e.fetchAttachment);u>0&&l.lines.push(`${u} more upload links not examined`);let s=[];s.push(`${t.issue.key} \xB7 ${t.site}`,`Title: ${t.content.title}`),t.content.description!==""&&s.push("",...t.content.description.split(`
|
|
10
|
+
`,inventory:i,blobs:o,delivered:u,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var tn=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function re(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}let t=n.pathname.split("/").filter(Boolean),r=t.indexOf("wiki");if(r===-1||t[r+1]!=="spaces"||t[r+3]!=="pages")return null;let i=t[r+2],o=t[r+4];return i===void 0||o===void 0||!tn.test(i)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:i,pageId:o}}async function qe(e,n,t){let r=t.lis??{jiraInfo:q,jiraIssue:Q,jiraAttachment:te,jiraComments:ee},i=t.confluence??{confluenceDocument:Le,confluenceAttachment:Ie};try{let u={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},l=await r.jiraInfo(u);if(!l.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Atlassian connection for this account \u2014 create one at ${A} and retry`}};if(l.capabilities.document===!1)return{ok:!1,failure:{code:"NO_CONFLUENCE_ACCESS",message:`the connection has no Confluence access \u2014 reconnect with Confluence at ${A} and retry`}};let s=await i.confluenceDocument(e.pageId,u),c=e.site;if(s.url)try{c=new URL(s.url).hostname}catch{}let{bytes:a,warnings:f}=ze(s,c),p=n??`page-${e.pageId}`;try{N(p)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}let h=Object.fromEntries((s.attachments??[]).filter(g=>typeof g.download=="string"&&g.download.length>0).map(g=>[String(g.id),g.download]));return{ok:!0,bytes:a,site:c,sourceId:p,...s.title?{title:s.title}:{},warnings:f,downloads:h,remote:i,lisDeps:u}}catch(o){return o instanceof y?{ok:!1,failure:{code:o.code,message:o.message}}:{ok:!1,failure:{code:"FETCH_FAILED",message:tt(o instanceof Error?o.message:String(o))}}}}function Qe(e,n,t){let r=x(e,n,"confluence");if(r!==null)return{code:"KIND_MISMATCH",message:r,facts:{id:n,heldKind:J(e,n)??"",freeId:$(e,n)}};let i=fe(e,n);return i!==null&&i!==t?{code:"SITE_MOVED",message:v().text("note.site_moved",{source_id:n,previous:i,site:t}),facts:{id:n,freeId:$(e,n)}}:null}var et=(e,n,t)=>({confluence:Ze({downloads:e,fetchAttachment:r=>n.confluenceAttachment(r.download,t)})});async function nn(e,n,t,r,i){let o=re(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)`),{code:1};let u=await qe(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,site:s,sourceId:c,warnings:a,downloads:f,remote:p,lisDeps:h}=u;try{let g=Qe(r,c,s);if(g!==null)return(t.err??t.out)(`error: ${e}: ${g.message}`),{code:1};let d=await U({store:r,bytes:l,media:ae,sourceId:c,label:e,confirmSameSource:t.isTTY?m=>t.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:et(f,p,h)});t.out(B(t.isTTY,d,`${o.spaceKey}/${o.pageId}`));for(let m of a)t.out(`warning: ${m}`);for(let m of d.warnings??[])t.out(`warning: ${m}`);if(d.composite){let m=d.composite.delivered+d.composite.omitted;t.out(`${d.source_id}: confluence, ${m} attachments, ${d.composite.delivered} images delivered (${d.composite.omitted} omitted)`)}return{code:0,result:{status:d.status,source_id:d.source_id,source_cid:d.cid,...d.gitignore?{gitignore:d.gitignore}:{}}}}catch(g){return g instanceof y?((t.err??t.out)(`error: ${e}: ${g.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${tt(g instanceof Error?g.message:String(g))}`),{code:1})}}async function rn(e,n,t){let r=re(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await qe(r,n,t);return i.ok?{ok:!0,fetched:{provider:"confluence",sourceId:i.sourceId,bytes:i.bytes,media:ae,label:e,display:`${r.spaceKey}/${r.pageId}`,...i.title?{title:i.title}:{},origin:{kind:"confluence",url:e},identity:{site:i.site},warnings:i.warnings,downloads:i.downloads}}:i}async function on(e,n,t){let r=Qe(n,e.sourceId,e.identity.site??"");if(r!==null)return{ok:!1,failure:r};let i=t.confluence??{confluenceDocument:Le,confluenceAttachment:Ie},u={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env};return{ok:!0,media:ae,label:e.label,converters:et(e.downloads??{},i,u)}}function tt(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the page in Confluence and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?"the page's text is too large to ingest \u2014 trim the page in Confluence and retry":e}var nt={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:e=>re(e)!==null,ingest:nn,sourceIdFor:e=>{let n=re(e);return n?`page-${n.pageId}`:null},fetch:rn,prepare:on};async function rt(e={}){let n=await k("/linear-app/info",{method:"GET"},e);if(!n.ok)throw R(n,"the connection","Linear");let t=P(n);return{installed:t.data?.INSTALLED==="YES",capabilities:{issue:t.data?.capabilities?.issue===!0,comments:t.data?.capabilities?.comments===!0,document:t.data?.capabilities?.document===!0}}}async function it(e,n={}){let t=await k("/linear-app/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"linear-app",issueKey:e})},n);if(!t.ok)throw R(t,"the issue","Linear");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${C(r.message??"")||"issue not found or not accessible"}`);return r.data}var sn=100,an=5e3,cn=60;async function ot(e,n={}){let t=[],r=new Set,i=null;for(let o=0;;o++){if(o>=cn)throw new y("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let u=await k("/linear-app/issue/comments",{method:"POST",body:JSON.stringify({resource_id:e,max_results:sn,...i===null?{}:{cursor:i},fetch_all:!1})},n);if(!u.ok)throw R(u,"the issue's comments","Linear");let l=P(u);if(l.type==="error"||!l.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${C(l.message??"")||"unavailable"}`);if(l.data.partial)throw new y("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 retry later");for(let a of l.data.comments??[]){if(typeof a.id!="string"||a.id==="")throw new y("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 a comment row has no comment id");r.has(a.id)||(r.add(a.id),t.push(a))}let s=l.data.pagination;if(!s?.has_more)return t;if(t.length>=an)throw new y("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let c=s.next_cursor??null;if(c==null||c===i)throw new y("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");i=c}}async function st(e,n={}){let t=await k("/linear-app/document",{method:"POST",body:JSON.stringify({resource_id:e,format:"markdown"})},n);if(!t.ok)throw R(t,"the document","Linear");let r=P(t);if(r.type==="error"||!r.data)throw new y("JIRA_ISSUE_UNAVAILABLE",`could not fetch the document: ${C(r.message??"")||"document not found or not accessible"}`);return r.data}async function at(e,n={}){let t=await k("/linear-app/attachment",{method:"POST",body:JSON.stringify({attachment_id:e})},n);if(!t.ok)throw R(t,"the attachment","Linear");return{bytes:Y(t).bytes}}var ge="kane.source.linear/1",he="kane.source.linear-doc/1",un=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g;function z(e){return e.replace(un,n=>{let t=n.indexOf("?");return t===-1?n:n.slice(0,t)})}function ct(e,n){return e.id<n.id?-1:e.id>n.id?1:0}function ln(e,n){return ct(e,n)||(e.filename<n.filename?-1:e.filename>n.filename?1:0)||(e.url<n.url?-1:e.url>n.url?1:0)}function ut(e,n,t){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this issue \u2014 the integrations service returned no issue id");let r=e.key;if(!/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(r)){let c=String(r).replace(/[\u0000-\u001f\u007f-\u009f]/g,"").slice(0,80);throw new Error(`cannot build a stable identity for issue key "${c}" \u2014 expected a TEAM-NUMBER key`)}let i={},o=[...e.labels??[]].filter(c=>typeof c=="string").sort();o.length>0&&(i.labels=o.join(", ")),typeof e.priority=="string"&&e.priority!==""&&(i.priority=e.priority),typeof e.project=="string"&&e.project!==""&&(i.project=e.project),typeof e.status=="string"&&e.status!==""&&(i.status=e.status);let u=(e.attachments??[]).map(c=>({id:c.id!=null&&String(c.id)!==""?String(c.id):z(c.download??""),filename:c.filename??"",url:z(c.download??"")})).sort(ln),l=n.map(c=>({id:String(c.id),author:c.author?.display_name??"",body:z(c.body??""),created:c.created??""})).sort((c,a)=>c.created!==a.created?c.created<a.created?-1:1:ct(c,a)),s={schema:ge,site:t,team:r.slice(0,r.lastIndexOf("-")),issue:{uuid:e.id,key:r},content:{title:e.summary??"",description:z(e.description??""),fields:i},attachments:u,comments:l};return{bytes:Buffer.from(JSON.stringify(s),"utf8"),envelope:s,warnings:[]}}function lt(e,n,t){if(typeof e.id!="string"||e.id==="")throw new Error("cannot build a stable identity for this document \u2014 the integrations service returned no document id");let r=(e.attachments??[]).map(o=>({url:z(o.download??String(o.id??"")),filename:o.filename??""})).sort((o,u)=>o.url<u.url?-1:o.url>u.url?1:0),i={schema:he,site:n,document:{uuid:e.id,slug_id:t},project:{id:e.space?.key??""},title:e.title??"",content:{body:z(e.body??"")},attachments:r};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}var dt=64,dn=16,pn=6e6,fn=5e7,mn=12e6,ye=64,pt="https://uploads.linear.app/",gn=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g,hn={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},yn=new Set(["png","jpeg","webp"]);async function ft(e,n){let t=[],r=new Map,i=[],o=0,u=new Map,l=[];for(let s=0;s<e.length;s++){let c=e[s],a=`i${s+1}`,f=b=>`[img#${a}] ${c.label}${b?"":" \u2014 not delivered"}`,p=(b,L,_)=>{t.push({ref:a,loc:c.loc,media_type:b,..._?.blob?{blob:_.blob}:{},..._?.appearance?{appearance:_.appearance}:{},delivery:L,..._?.duplicate_of?{duplicate_of:_.duplicate_of}:{}})},h;try{h=await n(c.url)}catch{p("application/octet-stream","external-image-not-fetched"),l.push(f(!1));continue}let g=h.bytes,d=W(g),m=hn[d.format],E=V(g);if(r.set(E,g),!yn.has(d.format)){let b=d.format==="gif"||d.format==="bmp"||d.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(m,b,{blob:E}),l.push(f(!1));continue}if(d.width===void 0||d.height===void 0||d.width*d.height>fn){p(m,"undecodable",{blob:E}),l.push(f(!1));continue}let I;if(d.format==="png"||d.format==="jpeg"){let b=H(g,d.format);if(b===null){p(m,"undecodable",{blob:E}),l.push(f(!1));continue}I=G(b.data,{width:b.width,height:b.height,channels:b.channels})}if(d.width<dt||d.height<dt){p(m,"below-dimension-floor",{blob:E,appearance:I}),l.push(f(!1));continue}let w=u.get(E);if(w!==void 0){p(m,"duplicate",{blob:E,appearance:I,duplicate_of:w}),l.push(f(!1));continue}if(g.byteLength>pn){p(m,"image-too-large",{blob:E,appearance:I}),l.push(f(!1));continue}if(o+g.byteLength>mn){p(m,"vision-byte-budget-reached",{blob:E,appearance:I}),l.push(f(!1));continue}if(i.length>=dn){p(m,"image-cap-reached",{blob:E,appearance:I}),l.push(f(!1));continue}u.set(E,a),o+=g.byteLength,i.push(a),p(m,"selected",{blob:E,appearance:I}),l.push(f(!0))}return{inventory:t,blobs:r,delivered:i,lines:l}}function En(e){let n=new Set,t=[];for(let r of e.match(gn)??[])n.has(r)||(n.add(r),t.push(r));return t}function ve(e){return async n=>{let t;try{t=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_ENVELOPE_SCHEMA: source bytes are not a kane linear envelope")}if(t.schema!==ge)throw new Error(`LINEAR_ENVELOPE_SCHEMA: unknown envelope schema "${t.schema}" \u2014 this CLI understands ${ge}`);let r=[],i=new Set;for(let a of En(t.content.description))i.add(a),r.push({url:a,label:a,loc:`body:${a}`});let o=[];for(let a of t.attachments)if(a.url.startsWith(pt)){if(i.has(a.url)){if(a.filename!==""){let f=r.find(p=>p.url===a.url);f!==void 0&&f.label===f.url&&(f.label=a.filename)}continue}i.add(a.url),r.push({url:a.url,label:a.filename||a.url,loc:`attachment:${a.filename||a.url}`})}else a.url!==""&&o.push(`[${o.length+1}] ${a.filename||a.url} \u2014 ${a.url}`);let u=Math.max(0,r.length-ye),l=await ft(r.slice(0,ye),e.fetchAttachment);u>0&&l.lines.push(`${u} more upload links not examined`);let s=[];s.push(`${t.issue.key} \xB7 ${t.site}`,`Title: ${t.content.title}`),t.content.description!==""&&s.push("",...t.content.description.split(`
|
|
11
11
|
`));let c=Object.keys(t.content.fields);return c.length>0&&s.push("","--- fields ---",...c.map(a=>`${a}: ${t.content.fields[a]}`)),l.lines.length>0&&s.push("","--- images ---",...l.lines),o.length>0&&s.push("","--- links ---",...o),t.comments.length>0&&(s.push("","--- comments ---"),t.comments.forEach((a,f)=>{f>0&&s.push(""),s.push(`[${f+1}] ${a.author} \xB7 ${a.created}`,...a.body.split(`
|
|
12
12
|
`))})),{projection:s.join(`
|
|
13
13
|
`)+`
|
|
14
14
|
`,inventory:l.inventory,blobs:l.blobs,delivered:l.delivered,converter:{name:"linear-convert",version:"1",policy:"v1"}}}}function Ae(e){return async n=>{let t;try{t=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_DOC_ENVELOPE_SCHEMA: source bytes are not a kane linear document envelope")}if(t.schema!==he)throw new Error(`LINEAR_DOC_ENVELOPE_SCHEMA: unknown envelope schema "${t.schema}" \u2014 this CLI understands ${he}`);let r=new Set,i=[];for(let s of t.attachments)!s.url.startsWith(pt)||r.has(s.url)||(r.add(s.url),i.push({url:s.url,label:s.filename||s.url,loc:`body:${s.url}`}));let o=Math.max(0,i.length-ye),u=await ft(i.slice(0,ye),e.fetchAttachment);o>0&&u.lines.push(`${o} more upload links not examined`);let l=[];return l.push(`${t.title} \xB7 ${t.site}`),t.content.body!==""&&l.push("",...t.content.body.split(`
|
|
15
15
|
`)),u.lines.length>0&&l.push("","--- images ---",...u.lines),{projection:l.join(`
|
|
16
16
|
`)+`
|
|
17
|
-
`,inventory:u.inventory,blobs:u.blobs,delivered:u.delivered,converter:{name:"linear-doc-convert",version:"1",policy:"v1"}}}}var bn=/^[A-Za-z][A-Za-z0-9]*-\d+$/,_n=/-([0-9a-f]{12})$/;function Se(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}return n.hostname.toLowerCase()!=="linear.app"?null:n.pathname.split("/").filter(Boolean)}function mt(e){let n=Se(e);return n===null||n.length<3?null:{workspace:n[0],segs:n}}function X(e){let n=mt(e);if(n===null||n.segs[1]!=="issue")return null;let t=n.segs[2];return bn.test(t)?{workspace:n.workspace,key:t}:null}function Z(e){let n=mt(e);if(n===null||n.segs[1]!=="document")return null;let t=n.segs[2].match(_n);return t===null?null:{workspace:n.workspace,slugId:t[1]}}var wn=new Set(["project","team","view","initiative","cycle","roadmap","inbox","triage","my-issues"]),gt=new Set(["docs","features","method","blog","customers","pricing","integrations","developers","changelog","about","careers","security","download","contact","now","switch","homepage"]);function Re(e){let n=Se(e);return n===null||n.length<2||!wn.has(n[1])||gt.has(n[0].toLowerCase())?null:{workspace:n[0],section:n[1]}}function ke(e){let n=Se(e);return n===null||n.length<2||n[1]!=="issue"&&n[1]!=="document"||gt.has(n[0].toLowerCase())||X(e)!==null||Z(e)!==null?null:{workspace:n[0],section:n[1]}}function ht(e){let n=X(e);return n?n.key.toLowerCase():null}function yt(e){let n=Z(e);return n?`doc-${n.slugId}`:null}var Oe={linearInfo:rt,linearIssue:it,linearComments:ot,linearDocument:st,linearAttachment:at};function bt(e,n){if(e)try{let t=new URL(e).pathname.split("/").filter(Boolean)[0];if(t)return`linear.app/${t.toLowerCase()}`}catch{}return`linear.app/${n.toLowerCase()}`}function Ln(e,n,t,r,i,o){let u=pe(e,r);if(u!==null&&typeof u.schema=="string"&&u.schema.startsWith(`kane.source.${n}/`)){let s=u;for(let c of t)s=s!==null&&typeof s=="object"?s[c]:void 0;if(typeof s=="string"&&s!==""&&s!==i)return v().text("note.key_recycled",{source_id:r,what:o})}let l=we(e,n,t,i);return l!==null&&l!==r?`this ${o} is already ingested as '${l}' (its key changed) \u2014 reconcile that source, or retire it to re-ingest under the new key`:null}function In(e,n,t,r){let i=pe(e,t);if(i===null||typeof i.schema!="string"||!i.schema.startsWith(`kane.source.${n}/`))return null;let o=i.site;return typeof o!="string"||o.length===0||o===r?null:v().text("note.site_moved",{source_id:t,previous:o,site:r})}function Ce(e,n,t,r,i,o,u){let l=Ln(e,n,t,r,i,o);if(l!==null){let a=we(e,n,t,i);return{code:"UUID_MOVED",message:l,facts:a!==null&&a!==r?{holder:a}:{id:r,freeId:$(e,r)}}}let s=x(e,r,n);if(s!==null)return{code:"KIND_MISMATCH",message:s,facts:{id:r,heldKind:J(e,r)??"",freeId:$(e,r)}};let c=In(e,n,r,u);return c!==null?{code:"SITE_MOVED",message:c,facts:{id:r,freeId:$(e,r)}}:null}var _t=(e,n)=>e instanceof y?{code:e.code,message:e.message}:{code:"FETCH_FAILED",message:$e(e instanceof Error?e.message:String(e),n,"Linear")};async function wt(e,n,t){let r=t.linear??Oe;try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.linearInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Linear connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.issue===!1||u.capabilities.comments===!1)return{ok:!1,failure:{code:"NO_ISSUE_ACCESS",message:`the connection cannot read issues or their comments yet \u2014 resync it at ${A} and retry`}};let l=await r.linearIssue(e.key,o),s=await r.linearComments(e.key,o),c=bt(l.host,e.workspace),{bytes:a,envelope:f,warnings:p}=ut(l,s,c),h=n??e.key.toLowerCase();try{N(h)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}return{ok:!0,bytes:a,key:f.issue.key,uuid:f.issue.uuid,site:c,sourceId:h,warnings:p,lis:r,lisDeps:o}}catch(i){return{ok:!1,failure:_t(i,"issue")}}}async function Lt(e,n,t){let r=t.linear??Oe;try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.linearInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Linear connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.document===!1)return{ok:!1,failure:{code:"NO_DOCUMENT_ACCESS",message:`the connection cannot read documents yet \u2014 resync it at ${A} and retry`}};let l=await r.linearDocument(e.slugId,o),s=bt(l.url,e.workspace),{bytes:c,envelope:a,warnings:f}=lt(l,s,e.slugId),p=n??`doc-${e.slugId}`;try{N(p)}catch(h){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:h instanceof Error?h.message:String(h)}}}return{ok:!0,bytes:c,title:a.title||`document ${e.slugId}`,uuid:a.document.uuid,site:s,sourceId:p,warnings:f,lis:r,lisDeps:o}}catch(i){return{ok:!1,failure:_t(i,"document")}}}async function vn(e,n,t,r,i){let o=X(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)`),{code:1};let u=await wt(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,key:s,uuid:c,site:a,sourceId:f,warnings:p,lis:h,lisDeps:g}=u;try{let d=Ce(r,"linear",["issue","uuid"],f,c,"issue",a);if(d!==null)return(t.err??t.out)(`error: ${e}: ${d.message}`),{code:1};let m=await U({store:r,bytes:l,media:ue,sourceId:f,label:e,confirmSameSource:t.isTTY?E=>t.confirm(`identical content already ingested as ${E} \u2014 treat as the same source?`):void 0,converters:{linear:ve({fetchAttachment:E=>h.linearAttachment(E,g)})}});t.out(B(t.isTTY,m,s));for(let E of p)t.out(`warning: ${E}`);for(let E of m.warnings??[])t.out(`warning: ${E}`);if(m.composite){let E=m.composite.delivered+m.composite.omitted;t.out(`${m.source_id}: linear, ${E} images, ${m.composite.delivered} delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(d){return d instanceof y?((t.err??t.out)(`error: ${e}: ${d.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${$e(d instanceof Error?d.message:String(d),"issue","Linear")}`),{code:1})}}async function An(e,n,t,r,i){let o=Z(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)`),{code:1};let u=await Lt(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,title:s,uuid:c,site:a,sourceId:f,warnings:p,lis:h,lisDeps:g}=u;try{let d=Ce(r,"linear-doc",["document","uuid"],f,c,"document",a);if(d!==null)return(t.err??t.out)(`error: ${e}: ${d.message}`),{code:1};let m=await U({store:r,bytes:l,media:le,sourceId:f,label:e,confirmSameSource:t.isTTY?E=>t.confirm(`identical content already ingested as ${E} \u2014 treat as the same source?`):void 0,converters:{linearDoc:Ae({fetchAttachment:E=>h.linearAttachment(E,g)})}});t.out(B(t.isTTY,m,s));for(let E of p)t.out(`warning: ${E}`);for(let E of m.warnings??[])t.out(`warning: ${E}`);if(m.composite){let E=m.composite.delivered+m.composite.omitted;t.out(`${m.source_id}: linear document, ${E} images, ${m.composite.delivered} delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(d){return d instanceof y?((t.err??t.out)(`error: ${e}: ${d.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${$e(d instanceof Error?d.message:String(d),"document","Linear")}`),{code:1})}}async function Sn(e,n,t){let r=X(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await wt(r,n,t);return i.ok?{ok:!0,fetched:{provider:"linear",sourceId:i.sourceId,bytes:i.bytes,media:ue,label:e,display:i.key,origin:{kind:"linear",url:e},identity:{site:i.site,uuid:i.uuid},warnings:i.warnings}}:i}async function Rn(e,n,t){let r=Z(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await Lt(r,n,t);return i.ok?{ok:!0,fetched:{provider:"linear-doc",sourceId:i.sourceId,bytes:i.bytes,media:le,label:e,display:i.title,origin:{kind:"linear-doc",url:e},identity:{site:i.site,uuid:i.uuid},warnings:i.warnings}}:i}function It(e){return async(n,t,r)=>{let i=e==="linear",o=Ce(t,e,i?["issue","uuid"]:["document","uuid"],n.sourceId,n.identity.uuid??"",i?"issue":"document",n.identity.site??"");if(o!==null)return{ok:!1,failure:o};let u=r.linear??Oe,s={auth:await(r.authEnv??(async()=>(await import("./auth-7Z54TMQQ.js")).resolveLisAuthEnv({credentials:r.credentials})))(),env:process.env},c=a=>u.linearAttachment(a,s);return i?{ok:!0,media:ue,label:n.label,converters:{linear:ve({fetchAttachment:c})}}:{ok:!0,media:le,label:n.label,converters:{linearDoc:Ae({fetchAttachment:c})}}}}function $e(e,n,t){let r=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return r?`the ${n}'s content is too large to ingest (${r[1]}; the limit is ${r[2]}) \u2014 trim the ${n} in ${t} and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?`the ${n}'s text is too large to ingest \u2014 trim the ${n} in ${t} and retry`:e}var vt={name:"linear",hint:"Linear issue URLs (https://linear.app/<workspace>/issue/KEY-123)",match:e=>X(e)!==null,ingest:vn,sourceIdFor:ht,fetch:Sn,prepare:It("linear")},At={name:"linear-doc",hint:"Linear document URLs (https://linear.app/<workspace>/document/<slug>)",match:e=>Z(e)!==null,ingest:An,sourceIdFor:yt,fetch:Rn,prepare:It("linear-doc")};function Et(e){let n=Re(e);if(n===null){let t=ke(e);return t!==null?{code:"LINEAR_LINK_MALFORMED",message:`this Linear ${t.section} link is incomplete or malformed \u2014 use the full form (https://linear.app/${t.workspace}/issue/KEY-123 or https://linear.app/${t.workspace}/document/<slug>-<id>)`}:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear workspace page"}}return{code:"LINEAR_PAGE",message:`this Linear page can't be ingested \u2014 only issue and document URLs are supported; ingest the project's issues or documents individually (https://linear.app/${n.workspace}/issue/KEY-123)`}}var St={name:"linear-page",hint:"Linear issue or document URLs (other linear.app pages are not ingestable)",match:e=>Re(e)!==null||ke(e)!==null,ingest:async(e,n,t)=>((t.err??t.out)(`error: ${e}: ${Et(e).message}`),{code:1}),sourceIdFor:()=>null,fetch:async e=>({ok:!1,failure:Et(e)})};var kn=new Set(["invalid_url","target_disallowed","page_not_found","page_access_blocked","page_paywalled","unsupported_content_type","page_too_large","page_timeout","scrape_unavailable","scrape_rate_limited","internal_error","credit_denied"]);async function Ne(e,n){let t=n.env??process.env,r=n.fetchImpl??fetch,i=xe(t),o={"Content-Type":"application/json"},u=await n.authEnv(),l=u.TESTMUAI_BASIC_AUTH??t.TESTMUAI_BASIC_AUTH,s=u.TESTMUAI_API_KEY??t.TESTMUAI_API_KEY;l?o.Authorization=`Basic ${l}`:s&&(o.Authorization=`Bearer ${s}`);let c;try{c=await r(`${i}/assurance/web/scrape`,{method:"POST",headers:o,body:JSON.stringify({url:e}),signal:AbortSignal.timeout(n.timeoutMs??55e3)})}catch{return{ok:!1,kind:"transport_unreachable"}}if(c.status===401)return{ok:!1,kind:"auth_rejected"};let a;try{a=await c.json()}catch{return{ok:!1,kind:c.status===404?"route_missing":"malformed_response"}}if(c.ok){let p=a.page;return p===void 0||typeof p.markdown!="string"||p.markdown===""||typeof p.final_url!="string"||p.final_url===""||typeof p.projection?.kind!="string"||typeof p.projection?.version!="string"?{ok:!1,kind:"malformed_response"}:{ok:!0,page:p}}let f=a.code;return typeof f=="string"&&kn.has(f)?{ok:!1,kind:f}:c.status===404?{ok:!1,kind:"route_missing"}:c.status===403?{ok:!1,kind:"auth_rejected"}:{ok:!1,kind:"malformed_response"}}var Pe="kane.source.web/1";function Te(e,n,t){if(t==="")throw new Error("cannot build a web source from an empty page projection");if(n.kind===""||n.version==="")throw new Error("cannot build a stable identity without a server-reported projection kind/version");let r={schema:Pe,url:e,projection:{kind:n.kind,version:n.version},content:{markdown:t}};return{bytes:Buffer.from(JSON.stringify(r),"utf8"),envelope:r}}var On=new Set(["markdown"]);function De(){return async e=>{let n;try{n=JSON.parse(e.toString("utf8"))}catch{throw new Error("this web source's stored envelope is not readable \u2014 re-ingest the page")}if(n.schema!==Pe)throw new Error(`unknown web envelope schema '${String(n.schema)}' \u2014 re-ingest the page with this CLI version`);if(!On.has(n.projection?.kind??""))throw new Error(v().text("note.web_projection_unknown",{kind:String(n.projection?.kind)}));if(typeof n.content?.markdown!="string"||n.content.markdown==="")throw new Error("this web source's stored envelope carries no content \u2014 re-ingest the page");return{projection:n.content.markdown,inventory:[],blobs:new Map,delivered:[],converter:{name:"web-convert",version:"1",policy:"markdown-passthrough"}}}}import{createHash as Cn}from"crypto";function Rt(e){return ie(e)!==null}function ie(e){if(!/^https?:\/\//i.test(e))return null;let n;try{n=new URL(e)}catch{return null}return n.hostname===""?null:(n.hash="",n.username="",n.password="",n.toString())}function Ee(e){let n=ie(e);if(n===null)return null;let t=new URL(n),r=(t.hostname+t.pathname).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,""),i=Cn("sha256").update(n,"utf8").digest("hex").slice(0,8);return`${r||"page"}-${i}`}function kt(e,n){let t=F(e),r=t.heads.get(n);if(r==null)return null;let i=t.getNode(r)?.content?.blob;if(typeof i!="string")return null;let o=e.getBlob(i);if(o===null)return null;try{let u=JSON.parse(o.toString("utf8"));return u.schema!=="kane.source.web/1"?null:typeof u.url=="string"&&u.url.length>0?u.url:null}catch{return null}}function oe(e){switch(e){case"invalid_url":return"this is not a valid public HTTP or HTTPS page URL \u2014 check the address and try again";case"target_disallowed":return"that address cannot be fetched because it does not point to an allowed public web page";case"page_not_found":return"the page could not be found \u2014 check that the URL is correct and that the page still exists";case"page_access_blocked":return"the page refused automated access, so its contents could not be ingested \u2014 use a publicly accessible version of the page";case"page_paywalled":return"the page is behind a paywall or sign-in screen, so its full contents could not be ingested \u2014 use a publicly accessible copy";case"unsupported_content_type":return"the URL does not point to an HTML web page \u2014 download the document and ingest the supported file instead";case"page_too_large":return"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first";case"page_timeout":return"the page took too long to load \u2014 try again later";case"scrape_unavailable":case"scrape_rate_limited":case"internal_error":return"the page ingest service is temporarily unavailable \u2014 try again later";case"credit_denied":return"the page could not be ingested \u2014 your organization is out of credits";case"auth_rejected":return v().text("note.web_login",{});case"route_missing":return"ingesting web pages is not available in your environment yet \u2014 nothing is wrong with the URL; try again later";case"transport_unreachable":return"the page ingest service could not be reached \u2014 check your connection and try again";case"malformed_response":return"the page ingest service returned a response that could not be read safely \u2014 try again later"}}function Ot(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page contains too much text to ingest as a single source (${n[1]}; the limit is ${n[2]}) \u2014 use a narrower page or trim the content first`:e.startsWith("PROJECTION_TOO_LARGE:")?"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first":e}async function $n(e,n,t,r,i){let o=ie(e);if(o===null)return(t.err??t.out)(`error: ${e}: ${oe("invalid_url")}`),{code:1};let u=Ee(e),l=n??u;if(l===null)return(t.err??t.out)(`error: ${e}: ${oe("invalid_url")}`),{code:1};try{N(l)}catch(h){return(t.err??t.out)(`error: ${e}: ${h instanceof Error?h.message:String(h)}`),{code:1}}let s=x(r,l,"web");if(s!==null)return(t.err??t.out)(`error: ${e}: ${s}`),{code:1};let c=kt(r,l);if(c!==null&&c!==o){if(!t.isTTY)return(t.err??t.out)(`error: ${e}: ${v().text("note.web_url_changed",{source_id:l,previous:c})}`),{code:1};if(!await t.confirm(`source '${l}' was ingested from ${c} \u2014 treat ${o} as its new version (replaces the current version; items built on it go stale)?`))return t.out(v().text("note.web_id_taken",{url:e})),{code:1}}let a=i.web?.scrape??Ne,f=i.authEnv??(async()=>(await import("./spawner-C7NLLM4F.js")).resolveAgentAuthEnv(i.credentials)),p=await a(o,{authEnv:f});if(!p.ok)return(t.err??t.out)(`error: ${e}: ${oe(p.kind)}`),{code:1};try{let{bytes:h}=Te(o,p.page.projection,p.page.markdown),g=await U({store:r,bytes:h,media:ce,sourceId:l,label:o,confirmSameSource:t.isTTY?m=>t.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:{web:De()}}),d=new URL(o).hostname+new URL(o).pathname;t.out(B(t.isTTY,g,d));for(let m of g.warnings??[])t.out(`warning: ${m}`);return t.isTTY&&p.page.title&&t.out(` title: ${p.page.title}`),{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid,...g.gitignore?{gitignore:g.gitignore}:{}}}}catch(h){return(t.err??t.out)(`error: ${e}: ${Ot(h instanceof Error?h.message:String(h))}`),{code:1}}}async function Nn(e,n,t){let r=ie(e),i=r===null?null:n??Ee(e);if(r===null||i===null)return{ok:!1,failure:{code:"invalid_url",message:oe("invalid_url")}};if(!D(i))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(i)}};let o=t.web?.scrape??Ne,u=t.authEnv??(async()=>(await import("./spawner-C7NLLM4F.js")).resolveAgentAuthEnv(t.credentials)),l=await o(r,{authEnv:u});if(!l.ok)return{ok:!1,failure:{code:l.kind,message:oe(l.kind)}};try{let{bytes:s}=Te(r,l.page.projection,l.page.markdown),c=new URL(r);return{ok:!0,fetched:{provider:"web",sourceId:i,bytes:s,media:ce,label:r,display:c.hostname+c.pathname,origin:{kind:"web",url:r},identity:{url:r},warnings:[]}}}catch(s){return{ok:!1,failure:{code:"FETCH_FAILED",message:Ot(s instanceof Error?s.message:String(s))}}}}async function Pn(e,n){let t=x(n,e.sourceId,"web");if(t!==null)return{ok:!1,failure:{code:"KIND_MISMATCH",message:t,facts:{id:e.sourceId,heldKind:J(n,e.sourceId)??"",freeId:$(n,e.sourceId)}}};let r=kt(n,e.sourceId);return r!==null&&r!==e.identity.url?{ok:!1,failure:{code:"WEB_URL_CHANGED",message:v().text("note.web_url_changed",{source_id:e.sourceId,previous:r}),facts:{id:e.sourceId,previous:r,freeId:$(n,e.sourceId)}}}:{ok:!0,media:ce,label:e.label,converters:{web:De()}}}var Ct={name:"web",hint:"any public web page URL (https://\u2026)",match:Rt,ingest:$n,sourceIdFor:Ee,fetch:Nn,prepare:Pn};function B(e,n,t){return e?n.status==="created"?`landed ${n.source_id} (${t}) \u2014 new source`:n.status==="versioned"?`landed ${n.source_id} (${t}) \u2014 new version; dependents go stale`:`${n.source_id} unchanged \u2014 already landed`:`${n.status} ${n.source_id} source ${n.cid} blob ${n.blob}`}var $t=[Ye,nt,vt,At,St,Ct];function wi(e){return/^https?:\/\/.+/i.test(e)}function Li(e){return $t.find(n=>n.match(e))??null}function j(e){try{return N(e),""}catch(n){return n instanceof Error?n.message:String(n)}}function Ii(e){return $t.find(n=>n.name===e)??null}export{ne as a,pe as b,re as c,X as d,Z as e,Re as f,ke as g,B as h,$t as i,wi as j,Li as k,j as l,Ii as m};
|
|
17
|
+
`,inventory:u.inventory,blobs:u.blobs,delivered:u.delivered,converter:{name:"linear-doc-convert",version:"1",policy:"v1"}}}}var bn=/^[A-Za-z][A-Za-z0-9]*-\d+$/,_n=/-([0-9a-f]{12})$/;function Se(e){if(!/^https?:\/\/.+/i.test(e))return null;let n;try{n=new URL(e)}catch{return null}return n.hostname.toLowerCase()!=="linear.app"?null:n.pathname.split("/").filter(Boolean)}function mt(e){let n=Se(e);return n===null||n.length<3?null:{workspace:n[0],segs:n}}function X(e){let n=mt(e);if(n===null||n.segs[1]!=="issue")return null;let t=n.segs[2];return bn.test(t)?{workspace:n.workspace,key:t}:null}function Z(e){let n=mt(e);if(n===null||n.segs[1]!=="document")return null;let t=n.segs[2].match(_n);return t===null?null:{workspace:n.workspace,slugId:t[1]}}var wn=new Set(["project","team","view","initiative","cycle","roadmap","inbox","triage","my-issues"]),gt=new Set(["docs","features","method","blog","customers","pricing","integrations","developers","changelog","about","careers","security","download","contact","now","switch","homepage"]);function Re(e){let n=Se(e);return n===null||n.length<2||!wn.has(n[1])||gt.has(n[0].toLowerCase())?null:{workspace:n[0],section:n[1]}}function ke(e){let n=Se(e);return n===null||n.length<2||n[1]!=="issue"&&n[1]!=="document"||gt.has(n[0].toLowerCase())||X(e)!==null||Z(e)!==null?null:{workspace:n[0],section:n[1]}}function ht(e){let n=X(e);return n?n.key.toLowerCase():null}function yt(e){let n=Z(e);return n?`doc-${n.slugId}`:null}var Oe={linearInfo:rt,linearIssue:it,linearComments:ot,linearDocument:st,linearAttachment:at};function bt(e,n){if(e)try{let t=new URL(e).pathname.split("/").filter(Boolean)[0];if(t)return`linear.app/${t.toLowerCase()}`}catch{}return`linear.app/${n.toLowerCase()}`}function Ln(e,n,t,r,i,o){let u=pe(e,r);if(u!==null&&typeof u.schema=="string"&&u.schema.startsWith(`kane.source.${n}/`)){let s=u;for(let c of t)s=s!==null&&typeof s=="object"?s[c]:void 0;if(typeof s=="string"&&s!==""&&s!==i)return v().text("note.key_recycled",{source_id:r,what:o})}let l=we(e,n,t,i);return l!==null&&l!==r?`this ${o} is already ingested as '${l}' (its key changed) \u2014 reconcile that source, or retire it to re-ingest under the new key`:null}function In(e,n,t,r){let i=pe(e,t);if(i===null||typeof i.schema!="string"||!i.schema.startsWith(`kane.source.${n}/`))return null;let o=i.site;return typeof o!="string"||o.length===0||o===r?null:v().text("note.site_moved",{source_id:t,previous:o,site:r})}function Ce(e,n,t,r,i,o,u){let l=Ln(e,n,t,r,i,o);if(l!==null){let a=we(e,n,t,i);return{code:"UUID_MOVED",message:l,facts:a!==null&&a!==r?{holder:a}:{id:r,freeId:$(e,r)}}}let s=x(e,r,n);if(s!==null)return{code:"KIND_MISMATCH",message:s,facts:{id:r,heldKind:J(e,r)??"",freeId:$(e,r)}};let c=In(e,n,r,u);return c!==null?{code:"SITE_MOVED",message:c,facts:{id:r,freeId:$(e,r)}}:null}var _t=(e,n)=>e instanceof y?{code:e.code,message:e.message}:{code:"FETCH_FAILED",message:$e(e instanceof Error?e.message:String(e),n,"Linear")};async function wt(e,n,t){let r=t.linear??Oe;try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.linearInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Linear connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.issue===!1||u.capabilities.comments===!1)return{ok:!1,failure:{code:"NO_ISSUE_ACCESS",message:`the connection cannot read issues or their comments yet \u2014 resync it at ${A} and retry`}};let l=await r.linearIssue(e.key,o),s=await r.linearComments(e.key,o),c=bt(l.host,e.workspace),{bytes:a,envelope:f,warnings:p}=ut(l,s,c),h=n??e.key.toLowerCase();try{N(h)}catch(g){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:g instanceof Error?g.message:String(g)}}}return{ok:!0,bytes:a,key:f.issue.key,uuid:f.issue.uuid,site:c,sourceId:h,warnings:p,lis:r,lisDeps:o}}catch(i){return{ok:!1,failure:_t(i,"issue")}}}async function Lt(e,n,t){let r=t.linear??Oe;try{let o={auth:await(t.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:t.credentials})))(),env:process.env},u=await r.linearInfo(o);if(!u.installed)return{ok:!1,failure:{code:"NO_CONNECTION",message:`no Linear connection for this account \u2014 create one at ${A} and retry`}};if(u.capabilities.document===!1)return{ok:!1,failure:{code:"NO_DOCUMENT_ACCESS",message:`the connection cannot read documents yet \u2014 resync it at ${A} and retry`}};let l=await r.linearDocument(e.slugId,o),s=bt(l.url,e.workspace),{bytes:c,envelope:a,warnings:f}=lt(l,s,e.slugId),p=n??`doc-${e.slugId}`;try{N(p)}catch(h){return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:h instanceof Error?h.message:String(h)}}}return{ok:!0,bytes:c,title:a.title||`document ${e.slugId}`,uuid:a.document.uuid,site:s,sourceId:p,warnings:f,lis:r,lisDeps:o}}catch(i){return{ok:!1,failure:_t(i,"document")}}}async function vn(e,n,t,r,i){let o=X(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)`),{code:1};let u=await wt(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,key:s,uuid:c,site:a,sourceId:f,warnings:p,lis:h,lisDeps:g}=u;try{let d=Ce(r,"linear",["issue","uuid"],f,c,"issue",a);if(d!==null)return(t.err??t.out)(`error: ${e}: ${d.message}`),{code:1};let m=await U({store:r,bytes:l,media:ue,sourceId:f,label:e,confirmSameSource:t.isTTY?E=>t.confirm(`identical content already ingested as ${E} \u2014 treat as the same source?`):void 0,converters:{linear:ve({fetchAttachment:E=>h.linearAttachment(E,g)})}});t.out(B(t.isTTY,m,s));for(let E of p)t.out(`warning: ${E}`);for(let E of m.warnings??[])t.out(`warning: ${E}`);if(m.composite){let E=m.composite.delivered+m.composite.omitted;t.out(`${m.source_id}: linear, ${E} images, ${m.composite.delivered} delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(d){return d instanceof y?((t.err??t.out)(`error: ${e}: ${d.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${$e(d instanceof Error?d.message:String(d),"issue","Linear")}`),{code:1})}}async function An(e,n,t,r,i){let o=Z(e);if(o===null)return(t.err??t.out)(`error: ${e}: unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)`),{code:1};let u=await Lt(o,n,i);if(!u.ok)return(t.err??t.out)(`error: ${e}: ${u.failure.message}`),{code:1};let{bytes:l,title:s,uuid:c,site:a,sourceId:f,warnings:p,lis:h,lisDeps:g}=u;try{let d=Ce(r,"linear-doc",["document","uuid"],f,c,"document",a);if(d!==null)return(t.err??t.out)(`error: ${e}: ${d.message}`),{code:1};let m=await U({store:r,bytes:l,media:le,sourceId:f,label:e,confirmSameSource:t.isTTY?E=>t.confirm(`identical content already ingested as ${E} \u2014 treat as the same source?`):void 0,converters:{linearDoc:Ae({fetchAttachment:E=>h.linearAttachment(E,g)})}});t.out(B(t.isTTY,m,s));for(let E of p)t.out(`warning: ${E}`);for(let E of m.warnings??[])t.out(`warning: ${E}`);if(m.composite){let E=m.composite.delivered+m.composite.omitted;t.out(`${m.source_id}: linear document, ${E} images, ${m.composite.delivered} delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(d){return d instanceof y?((t.err??t.out)(`error: ${e}: ${d.message}`),{code:1}):((t.err??t.out)(`error: ${e}: ${$e(d instanceof Error?d.message:String(d),"document","Linear")}`),{code:1})}}async function Sn(e,n,t){let r=X(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await wt(r,n,t);return i.ok?{ok:!0,fetched:{provider:"linear",sourceId:i.sourceId,bytes:i.bytes,media:ue,label:e,display:i.key,origin:{kind:"linear",url:e},identity:{site:i.site,uuid:i.uuid},warnings:i.warnings}}:i}async function Rn(e,n,t){let r=Z(e);if(r===null)return{ok:!1,failure:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)"}};if(n!==void 0&&!D(n))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(n)}};let i=await Lt(r,n,t);return i.ok?{ok:!0,fetched:{provider:"linear-doc",sourceId:i.sourceId,bytes:i.bytes,media:le,label:e,display:i.title,origin:{kind:"linear-doc",url:e},identity:{site:i.site,uuid:i.uuid},warnings:i.warnings}}:i}function It(e){return async(n,t,r)=>{let i=e==="linear",o=Ce(t,e,i?["issue","uuid"]:["document","uuid"],n.sourceId,n.identity.uuid??"",i?"issue":"document",n.identity.site??"");if(o!==null)return{ok:!1,failure:o};let u=r.linear??Oe,s={auth:await(r.authEnv??(async()=>(await import("./auth-WBIEHHDS.js")).resolveLisAuthEnv({credentials:r.credentials})))(),env:process.env},c=a=>u.linearAttachment(a,s);return i?{ok:!0,media:ue,label:n.label,converters:{linear:ve({fetchAttachment:c})}}:{ok:!0,media:le,label:n.label,converters:{linearDoc:Ae({fetchAttachment:c})}}}}function $e(e,n,t){let r=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return r?`the ${n}'s content is too large to ingest (${r[1]}; the limit is ${r[2]}) \u2014 trim the ${n} in ${t} and retry`:e.startsWith("PROJECTION_TOO_LARGE:")?`the ${n}'s text is too large to ingest \u2014 trim the ${n} in ${t} and retry`:e}var vt={name:"linear",hint:"Linear issue URLs (https://linear.app/<workspace>/issue/KEY-123)",match:e=>X(e)!==null,ingest:vn,sourceIdFor:ht,fetch:Sn,prepare:It("linear")},At={name:"linear-doc",hint:"Linear document URLs (https://linear.app/<workspace>/document/<slug>)",match:e=>Z(e)!==null,ingest:An,sourceIdFor:yt,fetch:Rn,prepare:It("linear-doc")};function Et(e){let n=Re(e);if(n===null){let t=ke(e);return t!==null?{code:"LINEAR_LINK_MALFORMED",message:`this Linear ${t.section} link is incomplete or malformed \u2014 use the full form (https://linear.app/${t.workspace}/issue/KEY-123 or https://linear.app/${t.workspace}/document/<slug>-<id>)`}:{code:"UNSUPPORTED_URL",message:"unsupported remote URL \u2014 expected a Linear workspace page"}}return{code:"LINEAR_PAGE",message:`this Linear page can't be ingested \u2014 only issue and document URLs are supported; ingest the project's issues or documents individually (https://linear.app/${n.workspace}/issue/KEY-123)`}}var St={name:"linear-page",hint:"Linear issue or document URLs (other linear.app pages are not ingestable)",match:e=>Re(e)!==null||ke(e)!==null,ingest:async(e,n,t)=>((t.err??t.out)(`error: ${e}: ${Et(e).message}`),{code:1}),sourceIdFor:()=>null,fetch:async e=>({ok:!1,failure:Et(e)})};var kn=new Set(["invalid_url","target_disallowed","page_not_found","page_access_blocked","page_paywalled","unsupported_content_type","page_too_large","page_timeout","scrape_unavailable","scrape_rate_limited","internal_error","credit_denied"]);async function Ne(e,n){let t=n.env??process.env,r=n.fetchImpl??fetch,i=xe(t),o={"Content-Type":"application/json"},u=await n.authEnv(),l=u.TESTMUAI_BASIC_AUTH??t.TESTMUAI_BASIC_AUTH,s=u.TESTMUAI_API_KEY??t.TESTMUAI_API_KEY;l?o.Authorization=`Basic ${l}`:s&&(o.Authorization=`Bearer ${s}`);let c;try{c=await r(`${i}/assurance/web/scrape`,{method:"POST",headers:o,body:JSON.stringify({url:e}),signal:AbortSignal.timeout(n.timeoutMs??55e3)})}catch{return{ok:!1,kind:"transport_unreachable"}}if(c.status===401)return{ok:!1,kind:"auth_rejected"};let a;try{a=await c.json()}catch{return{ok:!1,kind:c.status===404?"route_missing":"malformed_response"}}if(c.ok){let p=a.page;return p===void 0||typeof p.markdown!="string"||p.markdown===""||typeof p.final_url!="string"||p.final_url===""||typeof p.projection?.kind!="string"||typeof p.projection?.version!="string"?{ok:!1,kind:"malformed_response"}:{ok:!0,page:p}}let f=a.code;return typeof f=="string"&&kn.has(f)?{ok:!1,kind:f}:c.status===404?{ok:!1,kind:"route_missing"}:c.status===403?{ok:!1,kind:"auth_rejected"}:{ok:!1,kind:"malformed_response"}}var Pe="kane.source.web/1";function Te(e,n,t){if(t==="")throw new Error("cannot build a web source from an empty page projection");if(n.kind===""||n.version==="")throw new Error("cannot build a stable identity without a server-reported projection kind/version");let r={schema:Pe,url:e,projection:{kind:n.kind,version:n.version},content:{markdown:t}};return{bytes:Buffer.from(JSON.stringify(r),"utf8"),envelope:r}}var On=new Set(["markdown"]);function De(){return async e=>{let n;try{n=JSON.parse(e.toString("utf8"))}catch{throw new Error("this web source's stored envelope is not readable \u2014 re-ingest the page")}if(n.schema!==Pe)throw new Error(`unknown web envelope schema '${String(n.schema)}' \u2014 re-ingest the page with this CLI version`);if(!On.has(n.projection?.kind??""))throw new Error(v().text("note.web_projection_unknown",{kind:String(n.projection?.kind)}));if(typeof n.content?.markdown!="string"||n.content.markdown==="")throw new Error("this web source's stored envelope carries no content \u2014 re-ingest the page");return{projection:n.content.markdown,inventory:[],blobs:new Map,delivered:[],converter:{name:"web-convert",version:"1",policy:"markdown-passthrough"}}}}import{createHash as Cn}from"crypto";function Rt(e){return ie(e)!==null}function ie(e){if(!/^https?:\/\//i.test(e))return null;let n;try{n=new URL(e)}catch{return null}return n.hostname===""?null:(n.hash="",n.username="",n.password="",n.toString())}function Ee(e){let n=ie(e);if(n===null)return null;let t=new URL(n),r=(t.hostname+t.pathname).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,""),i=Cn("sha256").update(n,"utf8").digest("hex").slice(0,8);return`${r||"page"}-${i}`}function kt(e,n){let t=F(e),r=t.heads.get(n);if(r==null)return null;let i=t.getNode(r)?.content?.blob;if(typeof i!="string")return null;let o=e.getBlob(i);if(o===null)return null;try{let u=JSON.parse(o.toString("utf8"));return u.schema!=="kane.source.web/1"?null:typeof u.url=="string"&&u.url.length>0?u.url:null}catch{return null}}function oe(e){switch(e){case"invalid_url":return"this is not a valid public HTTP or HTTPS page URL \u2014 check the address and try again";case"target_disallowed":return"that address cannot be fetched because it does not point to an allowed public web page";case"page_not_found":return"the page could not be found \u2014 check that the URL is correct and that the page still exists";case"page_access_blocked":return"the page refused automated access, so its contents could not be ingested \u2014 use a publicly accessible version of the page";case"page_paywalled":return"the page is behind a paywall or sign-in screen, so its full contents could not be ingested \u2014 use a publicly accessible copy";case"unsupported_content_type":return"the URL does not point to an HTML web page \u2014 download the document and ingest the supported file instead";case"page_too_large":return"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first";case"page_timeout":return"the page took too long to load \u2014 try again later";case"scrape_unavailable":case"scrape_rate_limited":case"internal_error":return"the page ingest service is temporarily unavailable \u2014 try again later";case"credit_denied":return"the page could not be ingested \u2014 your organization is out of credits";case"auth_rejected":return v().text("note.web_login",{});case"route_missing":return"ingesting web pages is not available in your environment yet \u2014 nothing is wrong with the URL; try again later";case"transport_unreachable":return"the page ingest service could not be reached \u2014 check your connection and try again";case"malformed_response":return"the page ingest service returned a response that could not be read safely \u2014 try again later"}}function Ot(e){let n=e.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page contains too much text to ingest as a single source (${n[1]}; the limit is ${n[2]}) \u2014 use a narrower page or trim the content first`:e.startsWith("PROJECTION_TOO_LARGE:")?"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first":e}async function $n(e,n,t,r,i){let o=ie(e);if(o===null)return(t.err??t.out)(`error: ${e}: ${oe("invalid_url")}`),{code:1};let u=Ee(e),l=n??u;if(l===null)return(t.err??t.out)(`error: ${e}: ${oe("invalid_url")}`),{code:1};try{N(l)}catch(h){return(t.err??t.out)(`error: ${e}: ${h instanceof Error?h.message:String(h)}`),{code:1}}let s=x(r,l,"web");if(s!==null)return(t.err??t.out)(`error: ${e}: ${s}`),{code:1};let c=kt(r,l);if(c!==null&&c!==o){if(!t.isTTY)return(t.err??t.out)(`error: ${e}: ${v().text("note.web_url_changed",{source_id:l,previous:c})}`),{code:1};if(!await t.confirm(`source '${l}' was ingested from ${c} \u2014 treat ${o} as its new version (replaces the current version; items built on it go stale)?`))return t.out(v().text("note.web_id_taken",{url:e})),{code:1}}let a=i.web?.scrape??Ne,f=i.authEnv??(async()=>(await import("./spawner-MQ4XEHIX.js")).resolveAgentAuthEnv(i.credentials)),p=await a(o,{authEnv:f});if(!p.ok)return(t.err??t.out)(`error: ${e}: ${oe(p.kind)}`),{code:1};try{let{bytes:h}=Te(o,p.page.projection,p.page.markdown),g=await U({store:r,bytes:h,media:ce,sourceId:l,label:o,confirmSameSource:t.isTTY?m=>t.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:{web:De()}}),d=new URL(o).hostname+new URL(o).pathname;t.out(B(t.isTTY,g,d));for(let m of g.warnings??[])t.out(`warning: ${m}`);return t.isTTY&&p.page.title&&t.out(` title: ${p.page.title}`),{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid,...g.gitignore?{gitignore:g.gitignore}:{}}}}catch(h){return(t.err??t.out)(`error: ${e}: ${Ot(h instanceof Error?h.message:String(h))}`),{code:1}}}async function Nn(e,n,t){let r=ie(e),i=r===null?null:n??Ee(e);if(r===null||i===null)return{ok:!1,failure:{code:"invalid_url",message:oe("invalid_url")}};if(!D(i))return{ok:!1,failure:{code:"BAD_SOURCE_ID",message:j(i)}};let o=t.web?.scrape??Ne,u=t.authEnv??(async()=>(await import("./spawner-MQ4XEHIX.js")).resolveAgentAuthEnv(t.credentials)),l=await o(r,{authEnv:u});if(!l.ok)return{ok:!1,failure:{code:l.kind,message:oe(l.kind)}};try{let{bytes:s}=Te(r,l.page.projection,l.page.markdown),c=new URL(r);return{ok:!0,fetched:{provider:"web",sourceId:i,bytes:s,media:ce,label:r,display:c.hostname+c.pathname,origin:{kind:"web",url:r},identity:{url:r},warnings:[]}}}catch(s){return{ok:!1,failure:{code:"FETCH_FAILED",message:Ot(s instanceof Error?s.message:String(s))}}}}async function Pn(e,n){let t=x(n,e.sourceId,"web");if(t!==null)return{ok:!1,failure:{code:"KIND_MISMATCH",message:t,facts:{id:e.sourceId,heldKind:J(n,e.sourceId)??"",freeId:$(n,e.sourceId)}}};let r=kt(n,e.sourceId);return r!==null&&r!==e.identity.url?{ok:!1,failure:{code:"WEB_URL_CHANGED",message:v().text("note.web_url_changed",{source_id:e.sourceId,previous:r}),facts:{id:e.sourceId,previous:r,freeId:$(n,e.sourceId)}}}:{ok:!0,media:ce,label:e.label,converters:{web:De()}}}var Ct={name:"web",hint:"any public web page URL (https://\u2026)",match:Rt,ingest:$n,sourceIdFor:Ee,fetch:Nn,prepare:Pn};function B(e,n,t){return e?n.status==="created"?`landed ${n.source_id} (${t}) \u2014 new source`:n.status==="versioned"?`landed ${n.source_id} (${t}) \u2014 new version; dependents go stale`:`${n.source_id} unchanged \u2014 already landed`:`${n.status} ${n.source_id} source ${n.cid} blob ${n.blob}`}var $t=[Ye,nt,vt,At,St,Ct];function wi(e){return/^https?:\/\/.+/i.test(e)}function Li(e){return $t.find(n=>n.match(e))??null}function j(e){try{return N(e),""}catch(n){return n instanceof Error?n.message:String(n)}}function Ii(e){return $t.find(n=>n.name===e)??null}export{ne as a,pe as b,re as c,X as d,Z as e,Re as f,ke as g,B as h,$t as i,wi as j,Li as k,j as l,Ii as m};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as Q,c as Z,d as ee,e as fe,f as de}from"./chunk-
|
|
2
|
+
import{b as Q,c as Z,d as ee,e as fe,f as de}from"./chunk-SJQTTEXQ.js";import{a as ge}from"./chunk-MD3RABID.js";import{d as le}from"./chunk-ZIHQ5JGB.js";import{a as ue}from"./chunk-X45RZIAJ.js";import{b as se}from"./chunk-HV2CDY4K.js";import{b as ae}from"./chunk-LV7224DG.js";import{a as R,b as E,d as ce}from"./chunk-VE3SUJMA.js";import{c as N}from"./chunk-5YYCCM6K.js";import{d as ne}from"./chunk-WLEWXE6L.js";import{b as re,c as ie}from"./chunk-WIVKLNIO.js";import{e as M}from"./chunk-SB26HQO7.js";import{b as oe}from"./chunk-TZXXJWHA.js";import{i as te}from"./chunk-Z7S3IWUX.js";import{r as w}from"./chunk-UJLULWSR.js";import{a as B}from"./chunk-ZCBOHWN3.js";import{a as T,c as W,e as I}from"./chunk-2XW33VOK.js";import{f as z,g as H}from"./chunk-A7RJQJNT.js";import{a as Y}from"./chunk-TM45NPWL.js";import{a as J}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as O,j as q}from"./chunk-33DWJV67.js";import{a as ye}from"./chunk-6YGTRKDT.js";import{e as F}from"./chunk-UR6MHSHU.js";var s=F(ye(),1);var r=F(J(),1);function Ae(f){return f.mode==="login"?f.authOnly?"done":"ensure-project":f.complete?"done":f.hasProject?"ensure-folder":"ensure-project"}function Je({resultRef:f,mode:p="singleshot",loginCompleteRef:d,authOnly:A=!1}){let{exit:h}=q(),k=(0,s.useRef)(new Y),P=(0,s.useRef)(new ae),g=(0,s.useRef)(new le),o=k.current,a=P.current,U=g.current,pe=Q(),[x,m]=(0,s.useState)(p==="login"?"login":"gate"),[X,me]=(0,s.useState)(null),[we,$]=(0,s.useState)(null),[Ee,L]=(0,s.useState)(null),[G,ve]=(0,s.useState)(null),[K,S]=(0,s.useState)([]),b=(0,s.useCallback)((e,t,i,n)=>U.log(e,t,i,n),[U]),ke=(0,s.useCallback)((e,t)=>{e?R(o,a,e,t):a.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[o,a]),C=(0,s.useCallback)(()=>{if(p==="login")d&&(d.current=!0),h();else{let e=a.load().mobile,t=T(e?.tui_target,e?.default_target?.kind),i=t.kind==="unset"||t.kind==="choose-mobile"&&oe();m(i?"target":"input")}},[p,h,d,a]),_=(0,s.useCallback)((e,t)=>{let i=R(o,a,e,t),n=Ae({mode:p,authOnly:A,hasProject:!!i.projectId,complete:ce(i)});n==="done"?C():m(n)},[o,a,C,p,A]);O((e,t)=>{t.ctrl&&e==="c"&&w(0,"Ctrl+C exit")});let V=(0,s.useRef)(!1);s.default.useEffect(()=>{V.current||(V.current=!0,p!=="login"&&de(o,b).then(e=>{me(e),e.status==="authenticated"?_(e.result.profile,e.result.env):e.status==="needs_pick"?m("pick"):($(e.profile??null),L(e.env??null),m("login"))}).catch(e=>{ve(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[o,b]);let he=(0,s.useCallback)(e=>{f.current={objective:e},h()},[f,h]),Pe=(0,s.useCallback)(async(e,t)=>{o.setActiveProfile(e),o.setDefaultEnv(t),(await fe(o,e,t,b)).status==="authenticated"?_(e,t):($(e),L(t),m("login"))},[o,b,_]),j=(0,s.useCallback)(()=>{let e=o.getActiveProfile(),t=o.getDefaultEnv();if(!e)return null;let i=B(t),n=o.loadBasicAuth(e,t);return new ue(i.controllerBaseUrl,async()=>o.loadCredentials(e,t)?.access_token??null,n,b)},[o,b]),xe=(0,s.useCallback)(async()=>{let e=j();if(!e)return null;let t=e.cached??await e.resolve();if(!t)return null;let i=B(o.getDefaultEnv()),n=new M(i.tmsBaseUrl,t.username,t.access_key);try{let v=(await n.listProjects()).find(D=>D.name==="KaneAI Generated");if(v)return{id:v.project_id,name:v.name};let y=await n.createProject("KaneAI Generated");return{id:y.id,name:y.name}}catch{return null}},[j,o]),be=(0,s.useCallback)(async e=>{let t=j();if(!t)return null;let i=t.cached??await t.resolve();if(!i)return null;let n=B(o.getDefaultEnv()),l=new M(n.tmsBaseUrl,i.username,i.access_key);try{let y=(await l.listFolders(e)).find(je=>je.name==="Untitled");if(y)return{id:y.id,name:y.name};let D=await l.createFolder(e,"Untitled");return{id:D.id,name:D.name}}catch{return null}},[j,o]);if(x==="gate")return(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(G)return(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"red",children:G}),(0,r.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(x==="pick"&&X?.status==="needs_pick")return(0,r.jsx)(Ce,{profiles:X.profiles,onSelect:Pe});if(x==="login")return(0,r.jsx)(ee,{devMode:process.env.KANE_DEV_MODE==="1",profiles:o.listProfiles(),onBasicLogin:async(e,t,i,n)=>{let{validateBasicAuth:l}=await import("./validate-basic-66XDPA3S.js");await l(t,i,n),o.saveBasicAuth(e,t,{username:i,access_key:n}),o.setActiveProfile(e),o.setDefaultEnv(t)},onOAuthLogin:async(e,t)=>{let{LoginFlow:i}=await import("./login-flow-SYKXXDLH.js");o.setDefaultEnv(t),o.setActiveProfile(e),await new i(e,t,o).login()},onComplete:(e,t)=>{$(e),L(t),o.setActiveProfile(e),o.setDefaultEnv(t),_(e,t)},onCancel:()=>{w(0,"Login cancelled")}});if(x==="ensure-project"){let e=o.getActiveProfile()??"default",t=o.getDefaultEnv(),i=()=>{if(p==="login"){m("ensure-folder");return}R(o,a,e,t).folderId?C():m("ensure-folder")};return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(ie,{resolver:j(),currentProjectId:a.load().project_id,env:t,...re,onSelect:(n,l)=>{E(o,a,e,t,{projectId:n,projectName:l}),S(v=>[...v,`\u2713 Project: ${l} (${n})`]),i()},onCancel:async()=>{let n=await xe();n&&(E(o,a,e,t,{projectId:n.id,projectName:n.name}),S(l=>[...l,`\u2713 Default project: ${n.name} (${n.id})`]),i())}})]})}if(x==="ensure-folder"){let e=o.getActiveProfile()??"default",t=o.getDefaultEnv(),i=o.loadProfileConfig(e,t);return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(se,{resolver:j(),projectId:i?.project_id??"",currentFolderId:a.load().folder_id,env:t,onSelect:(n,l)=>{E(o,a,e,t,{folderId:n,folderName:l}),S(v=>[...v,`\u2713 Folder: ${l} (${n})`]),C()},onCancel:async()=>{if(!i?.project_id)return;let n=await be(i.project_id);n&&(E(o,a,e,t,{folderId:n.id,folderName:n.name}),S(l=>[...l,`\u2713 Default folder: ${n.name} (${n.id})`]),C())}})]})}if(x==="target"){let e=T(a.load().mobile?.tui_target,a.load().mobile?.default_target?.kind).kind==="choose-mobile";return(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(ge,{mode:e?"legacy-mobile":"all",onSelect:t=>{a.setMobile({tui_target:t}),m("input")},onCancel:()=>m("input")})})}if(x==="input"){let e=a.load().mobile,t=T(e?.tui_target,e?.default_target?.kind),i=(()=>{if(H(t.kind)){let n=te(e?.default_target)??"(no device)",l=N(e?.default_app)??"(no app)";return`Config: ${I(t.kind)} \xB7 ${n} \xB7 ${l}`}if(z(t.kind)){let n=W(e,t.kind),l=N(n.app)??"(no app)";return`Config: ${I(t.kind)} \xB7 ${ne(n)} \xB7 ${l}`}return"Config: Desktop \xB7 Chrome"})();return(0,r.jsxs)(c,{flexDirection:"column",children:[K.length>0&&(0,r.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:K.map((n,l)=>(0,r.jsx)(u,{color:"green",children:n},l))}),(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(u,{color:"gray",children:i})}),(0,r.jsx)(Z,{onSubmit:he,onEscape:()=>w(0,"User pressed Escape"),history:pe,placeholder:"Type an objective..."})]})}return(0,r.jsx)(r.Fragment,{})}function Ce({profiles:f,onSelect:p}){let[d,A]=(0,s.useState)(0),[h,k]=(0,s.useState)(!1);return O((P,g)=>{if(!h){if(g.escape){w(0,"Profile picker cancelled");return}if(g.upArrow&&d>0&&A(o=>o-1),g.downArrow&&d<f.length-1&&A(o=>o+1),g.return){k(!0);let o=f[d];p(o.profile,o.env).catch(()=>k(!1))}}}),(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,r.jsx)(c,{marginTop:1,flexDirection:"column",children:f.map((P,g)=>(0,r.jsxs)(u,{children:[g===d?"\u276F ":" ",(0,r.jsx)(u,{color:g===d?"#ff9500":"white",bold:g===d,children:P.profile}),(0,r.jsxs)(u,{color:"gray",children:[" [",P.env,"]"]})]},`${P.profile}-${P.env}`))}),h&&(0,r.jsx)(c,{marginTop:1,children:(0,r.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{Ae as a,Je as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{Ea as L,Ua as U}from"./chunk-
|
|
2
|
+
import{Ea as L,Ua as U}from"./chunk-PI7OXS62.js";import{a as E}from"./chunk-YJAQZMJT.js";var x="ckpt/1";var B="checkpoints",m="base.json",y=t=>`delta-${t}.json`,w=t=>`full-${t}.json`,re=["turn","ask","final"],se=["extract","design","walk"];function d(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function D(t){return Array.isArray(t)&&t.every(r=>typeof r=="string")}function K(t){let r=[],e=(n,i)=>{n||r.push(i)};if(!d(t))return{ok:!1,errors:["record: not an object"]};e(t.schema===x,`schema: expected "${x}"`);let s=t.kind;if(s==="base")e(typeof t.sid=="string"&&t.sid.length>0,"base.sid: non-empty string"),e(typeof t.verb=="string"&&se.includes(t.verb),"base.verb: extract|design|walk"),e(typeof t.mode=="string","base.mode: string"),e(typeof t.created_at=="string","base.created_at: string"),e(d(t.run_config),"base.run_config: object"),d(t.run_config)&&e(!("resume"in t.run_config),"base.run_config: must not carry `resume`"),e(typeof t.conv_source=="string",'base.conv_source: string ("" when absent)'),e(typeof t.store_watermark=="string"||t.store_watermark===null,"base.store_watermark: string | null (null = genesis)");else if(s==="delta"||s==="full"){e(typeof t.sid=="string"&&t.sid.length>0,"delta.sid: non-empty string"),e(Number.isInteger(t.seq)&&t.seq>=1,"delta.seq: integer \u2265 1"),e(Number.isInteger(t.turn_id),"delta.turn_id: integer"),e(typeof t.at=="string"&&re.includes(t.at),"delta.at: turn|ask|final"),e(typeof t.ts=="string","delta.ts: string");let n=t.agent;if(d(n)){e(Number.isInteger(n.agent_state_schema),"agent.agent_state_schema: integer"),e(Array.isArray(n.delta_items),"agent.delta_items: array"),e(d(n.binding),"agent.binding: object");let o=n.usage_total;e(d(o)&&typeof o.input_tokens=="number"&&typeof o.output_tokens=="number"&&typeof o.credits=="number","agent.usage_total: {input_tokens, output_tokens, credits} numbers"),n.base_fingerprint!==void 0&&e(typeof n.base_fingerprint=="string","agent.base_fingerprint: string when present"),s==="full"&&e(typeof n.base_fingerprint=="string","full: agent.base_fingerprint required")}else r.push("delta.agent: object");let i=t.kane;if(d(i)){e(D(i.applied_events),"kane.applied_events: string[]"),e(D(i.held_receipts),"kane.held_receipts: string[]");let o=i.pending;e(d(o)&&Array.isArray(o.questions)&&Array.isArray(o.proposals),"kane.pending: {questions[], proposals[]}"),e(Array.isArray(i.parent_asks),"kane.parent_asks: array"),e(d(i.read_basis),"kane.read_basis: object");let p=i.corpus_cursor;if(e(d(p)&&D(p.remaining),"kane.corpus_cursor: {remaining: string[]}"),e(typeof i.store_watermark=="string"||i.store_watermark===null,"kane.store_watermark: string | null (null = genesis)"),i.awaits!==void 0){let a=i.awaits;e(d(i.awaits)&&typeof a.call=="string"&&(typeof a.event_id=="string"||typeof a.event_prefix=="string"),"kane.awaits: {call, event_id | event_prefix}")}i.ingest_registry!==void 0&&e(Array.isArray(i.ingest_registry)&&i.ingest_registry.every(a=>d(a)&&typeof a.ref=="string"&&typeof a.entered_at=="string"),"kane.ingest_registry: [{ref, entered_at, consumed?}]"),i.sent_unread!==void 0&&e(D(i.sent_unread),"kane.sent_unread: string[]"),i.ingest_schedule!==void 0&&e(Array.isArray(i.ingest_schedule)&&i.ingest_schedule.every(a=>d(a)&&typeof a.source_id=="string"&&typeof a.cid=="string"&&["pending","done","skipped"].includes(String(a.status))),"kane.ingest_schedule: [{source_id, cid, status}]")}else r.push("delta.kane: object")}else r.push('kind: expected "base" | "delta" | "full"');return{ok:r.length===0,errors:r}}import{readFileSync as ke}from"fs";import{join as _e}from"path";import{closeSync as N,linkSync as ie,mkdirSync as G,openSync as I,readFileSync as oe,readdirSync as Y,renameSync as ae,rmSync as F,statSync as ce,writeFileSync as M}from"fs";import{join as j}from"path";function pe(t,r){let e=j(t,"sessions",r,B),s=n=>j(e,n);return{read:n=>{try{return oe(s(n),"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}},list:()=>{try{return Y(e)}catch{return[]}},write:(n,i)=>{G(e,{recursive:!0}),le(s(n),i,e)},writeIfAbsent:(n,i)=>(G(e,{recursive:!0}),de(s(n),i,e)),remove:n=>F(s(n),{force:!0}),bytes:()=>fe(e)}}function le(t,r,e){let s=`${t}.tmp-${process.pid}`,n=I(s,"w");try{M(n,r,{mode:384}),E(n)}finally{N(n)}ae(s,t);try{let i=I(e,"r");E(i),N(i)}catch{}}var ue=new Set(["EPERM","ENOTSUP","EXDEV"]);function de(t,r,e){let s=`${t}.tmp-${process.pid}`,n=I(s,"w");try{M(n,r,{mode:384}),E(n)}finally{N(n)}try{ie(s,t)}catch(i){let o=i.code??"";if(o==="EEXIST")return!1;if(!ue.has(o))throw i;if(!ge(t,r))return!1}finally{F(s,{force:!0})}try{let i=I(e,"r");E(i),N(i)}catch{}return!0}function ge(t,r){let e;try{e=I(t,"wx")}catch(n){if(n.code==="EEXIST")return!1;throw n}let s=!1;try{M(e,r),E(e),s=!0}finally{N(e),s||F(t,{force:!0})}return!0}function fe(t){let r=0;try{for(let e of Y(t))try{r+=ce(j(t,e)).size}catch{}}catch{return 0}return r}var me=3,$e=600*1e3,h=class extends Error{constructor(e,s){super(`${e}: ${s}`);this.code=e}},S=class extends Error{constructor(r){super(`CHECKPOINT_WRITE: ${r}`)}},V=class extends S{},he=(t,r)=>_e(t,"sessions",r,"state.json"),Ce=new Set,J=new Set;function W(t,r,e){for(let s of Ce)try{s(t,r,e)}catch{}}var be=new Set;function De(t,r=new Date){for(let e of be)try{e(t,r)}catch{}}function He(t,r){let e=JSON.stringify(r)+`
|
|
3
3
|
`;t.writeIfAbsent(m,e)||ye(t.read(m))||(t.remove(m),t.writeIfAbsent(m,e))}function ye(t){if(t===null)return!1;try{return JSON.parse(t),!0}catch{return!1}}function Z(t,r){let e;try{e=JSON.parse(r)}catch(n){throw new h("CHECKPOINT_CORRUPT",`${t}: ${n.message}`)}let s=K(e);if(!s.ok)throw new h("CHECKPOINT_CORRUPT",`${t}: ${s.errors.join("; ")}`);return e}function X(t,r){let e=t.read(r);if(e===null)throw new h("CHECKPOINT_MISSING",`${r} is not in the chain`);return Z(r,e)}function ee(t){let r=[],e=[];for(let s of t.list()){let n=/^delta-(\d+)\.json$/.exec(s);n&&r.push(Number(n[1]));let i=/^full-(\d+)\.json$/.exec(s);i&&e.push(Number(i[1]))}return r.sort((s,n)=>s-n),e.sort((s,n)=>s-n),{deltas:r,fulls:e}}function Be(t,r){try{return JSON.parse(ke(he(t,r),"utf8")).checkpoint??null}catch{return null}}function te(t,r,e){let s=[],n,i=0;if(e.full_seq!==null){let a=X(t,w(e.full_seq));s.push(a),n=a.agent.base_fingerprint,i=e.full_seq}let o;for(let a=i+1;a<=e.seq;a++)try{let u=X(t,y(a));s.push(u),!n&&u.agent.base_fingerprint&&(n=u.agent.base_fingerprint)}catch(u){if(u instanceof h&&u.code==="CHECKPOINT_CORRUPT"){o={resumableAt:a-1,turnsLost:e.seq-(a-1)};break}throw u}if(s.length===0)throw new h("CHECKPOINT_CORRUPT",`${r}: pointer names seq ${e.seq} but no chain records exist`);return{items:s.flatMap(a=>a.agent.delta_items),last:s[s.length-1],base_fingerprint:n,fallback:o}}function Ke(t,r,e,s,n){let i=performance.now(),o=r.state.sid,p=r.state.checkpoint;if(p){if(e.seq<p.seq)throw new S(`seq regression: got ${e.seq}, pointer at ${p.seq} (${o})`);if(e.seq===p.seq){if(e.turn_id===p.turn_id&&e.at===p.at)return p;throw new S(`seq regression: seq ${e.seq} re-used with different metadata (turn ${e.turn_id}/${p.turn_id}, at ${e.at}/${p.at}) (${o})`)}}let a=(n?.now??(()=>new Date))(),u=a.toISOString(),l={schema:x,kind:"delta",sid:o,seq:e.seq,turn_id:e.turn_id,at:e.at,ts:u,agent:{agent_state_schema:e.agent_state_schema,delta_items:e.delta_items,binding:e.binding,usage_total:e.usage_total,...e.base_fingerprint!==void 0?{base_fingerprint:e.base_fingerprint}:{}},kane:s},A=Math.max(1,n?.retries??me),g=JSON.stringify(l)+`
|
|
4
4
|
`,C=!1;Buffer.byteLength(g)>524288&&!J.has(o)&&(J.add(o),C=!0,n?.onSoftCap?.("note: this session's checkpoints are getting large \u2014 long pasted inputs are kept verbatim; consider ingesting big documents as sources instead"));let v=!1,q;for(let f=0;f<A&&!v;f++)try{t.write(y(e.seq),g),v=!0}catch(k){q=k}if(!v)throw new S(`delta-${e.seq} write failed after ${A} attempts: ${q?.message??"unknown"} (${o})`);let _=p?.full_seq??null,P=t.bytes()>67108864;if(e.seq%25===0||P){let f=[],k=e.base_fingerprint;if(p){let R=te(t,o,p);f=R.items,k=k??R.base_fingerprint}if(f=[...f,...e.delta_items],!k)throw new S(`compaction at seq ${e.seq}: no base_fingerprint anywhere in the chain (${o})`);let c={...l,kind:"full",agent:{...l.agent,delta_items:f,base_fingerprint:k}};t.write(w(e.seq),JSON.stringify(c)+`
|
|
5
5
|
`),_=e.seq}let b={seq:e.seq,turn_id:e.turn_id,at:e.at,ts:u,full_seq:_};if(r.save({checkpoint:b}),_===e.seq){let{deltas:f,fulls:k}=ee(t);for(let c of f)c<=_&&t.remove(y(c));for(let c of k)c<_&&t.remove(w(c))}let T=t.bytes();if(P&&T>67108864)throw W(o,b,a),new V(`session ${o} checkpoint dir is ${Math.round(T/(1024*1024))}MB (cap ${Math.round(67108864/(1024*1024))}MB) even after compaction \u2014 pausing; resume in a fresh session or trim the conversation`);return W(o,b,a),n?.onStat?.({sid:o,seq:e.seq,persist_ms:performance.now()-i,bytes:Buffer.byteLength(g),dir_bytes:T,compacted:_===e.seq,soft_warned:C}),b}function je(t,r,e){let s=t.read(m);if(s===null)throw new h("CHECKPOINT_MISSING",`${r}: no ${m} \u2014 not a checkpoint session`);let n=Z(m,s),i=p=>{let{deltas:a,fulls:u}=ee(t);if(!p){let g=[...a.map(y),...u.map(w)];return{base:n,agent:null,kane:null,pointer:null,orphans:g}}let l=te(t,r,p),A=[...a.filter(g=>g>p.seq).map(y),...u.filter(g=>g>p.seq).map(w)];return{base:n,agent:{delta_items:l.items,binding:l.last.agent.binding,base_fingerprint:l.base_fingerprint,agent_state_schema:l.last.agent.agent_state_schema,...l.last.agent.usage_total?{usage_total:l.last.agent.usage_total}:{}},kane:l.last.kane,pointer:p,orphans:A,...l.fallback?{fallback:l.fallback}:{}}},o=e();try{return i(o)}catch(p){if(!(p instanceof h&&p.code==="CHECKPOINT_MISSING"))throw p;return i(e())}}function Fe(t,r){let e=[];for(let s of U(t).records)if(s.sid===r)for(let n of s.event_ids??[])e.push(n);return e}function Me(t,r,e,s,n){let i=n.verb??"extract",o=t.parse(e.store_watermark),p=o===null?null:t.resolveToken(o);if(o!==null&&p===null)throw new L(`watermark not in chain: ${e.store_watermark} names no record in this store (rebuilt or foreign?) \u2014 re-ground the session or abandon it`);let a=t.recordsSince(o),u=p===null?0:t.sessions().recordCount(r,p.seq),l=new Map;for(let c of a)c.sid===r&&l.set(c.seq,++u);let A=c=>l.get(c.seq)??0,g=new Set(e.applied_events),C=0,v=[];for(let c of a){if(typeof c.sid!="string"){C+=1;continue}if(c.sid===r){if((c.event_ids??[]).length===0){C+=1;continue}v.push(c)}}C>0&&n.onNote?.(`reconcile: skipped ${C} store record(s) not attributable to this session (pre-sid grace)`);let q=n.ownActors??["extract-agent","design-agent","owner"],_=[],P=[];for(let c of v){if(n.resent!==void 0&&(c.event_ids??[]).includes(n.resent))continue;let R=(c.event_ids??[]).filter(ne=>!g.has(ne));if(R.length===0)continue;P.push(...R);let O;try{O=n.composeReceipt(c,s,{verb:i,commitN:A(c),...n.ucRef?{ucRef:n.ucRef}:{},...n.typedBlockers?{typedBlockers:!0}:{},...n.ignoreGaps?.size?{ignoreGaps:n.ignoreGaps}:{}}).text}catch{O=`commit ${R[0]} at ${c.ts} \u2014 details unavailable (graph moved since)`}let $=c.review?.[0]?.by;$?.id&&!q.includes($.id)&&(O+=`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{h as w}from"./chunk-SXRHKXSE.js";import{a as h}from"./chunk-RZ4F3BHX.js";import{b as f}from"./chunk-
|
|
2
|
+
import{h as w}from"./chunk-SXRHKXSE.js";import{a as h}from"./chunk-RZ4F3BHX.js";import{b as f}from"./chunk-J4FIESTB.js";import{mkdtemp as O,rm as $}from"fs/promises";import{createWriteStream as R}from"fs";import{Readable as U}from"stream";import{pipeline as F}from"stream/promises";import{tmpdir as T}from"os";import{basename as z,join as A}from"path";import{access as x,cp as P,mkdir as g,readdir as y,readFile as S,rename as I,rm as k,stat as b,writeFile as v}from"fs/promises";import{basename as D,join as d}from"path";function u(){return d(f,"mobile","apps")}function m(){return d(u(),"index.json")}function C(){return{readIndex:async()=>{try{let e=JSON.parse(await S(m(),"utf8"));return{apps:Array.isArray(e.apps)?e.apps:[]}}catch{return{apps:[]}}},writeIndex:async r=>{await g(u(),{recursive:!0});let e=`${m()}.tmp`;await v(e,JSON.stringify(r,null,2)),await I(e,m())},exists:async r=>{try{return await x(r),!0}catch{return!1}},copy:(r,e)=>P(r,e,{recursive:!0,force:!0}),remove:r=>k(r,{recursive:!0,force:!0}),sizeOf:async r=>{try{return(await b(r)).size}catch{return}},now:()=>new Date}}var c=class{deps;constructor(e={}){this.deps={...C(),...e}}async list(){let{apps:e}=await this.deps.readIndex();return[...e].sort((t,s)=>s.lastUsedAt.localeCompare(t.lastUsedAt))}async find(e){return(await this.deps.readIndex()).apps.find(t=>t.key===e)}async put(e){let t=await this.deps.readIndex(),s=t.apps.find(n=>n.key===e.key),a=this.deps.now().toISOString();if(s&&await this.deps.exists(s.path))return s.lastUsedAt=a,await this.deps.writeIndex(t),s;s&&(t.apps=t.apps.filter(n=>n.key!==e.key));let l=D(e.name??e.sourcePath),o=d(u(),e.key),p=d(o,l);await g(o,{recursive:!0}),await this.deps.copy(e.sourcePath,p);let i={key:e.key,path:p,name:l,source:e.source,...e.source==="local"?{originPath:e.sourcePath}:{},addedAt:a,lastUsedAt:a,...await this.deps.sizeOf(p).then(n=>n?{bytes:n}:{})};return t.apps=[...t.apps.filter(n=>n.key!==e.key),i],await this.deps.writeIndex(t),i}async exists(e){if(await this.deps.sizeOf(e.path)!==void 0)return!0;try{return await y(e.path),!0}catch{return!1}}async forget(e){let t=await this.deps.readIndex(),s=t.apps.find(a=>a.key===e);s&&(await this.deps.remove(s.path),t.apps=t.apps.filter(a=>a.key!==e),await this.deps.writeIndex(t))}async prune(){let e=await this.deps.readIndex(),t=[];for(let s of e.apps)if(await this.deps.sizeOf(s.path)!==void 0)t.push(s);else try{await y(s.path),t.push(s)}catch{}return t.length!==e.apps.length&&await this.deps.writeIndex({apps:t}),t}};var E=30*6e4,j=/^APP\d{6,}$/;function Y(r){return!!r&&j.test(r.trim())}function _(){return{store:new c,client:(r,e)=>new w(r,e),fetchToFile:async(r,e)=>{let t=await h(r,{method:"GET",signal:AbortSignal.timeout(E)});if(!t.ok)throw new Error(`Downloading the app failed: ${t.status} ${t.statusText}`);if(!t.body)throw new Error("Downloading the app failed: empty response body");await F(U.fromWeb(t.body),R(e))}}}async function Z(r,e={}){let t={..._(),...e},s=r.appId.trim(),a=await t.store.find(s);if(a&&await t.store.exists(a))return r.onProgress?.(`using the copy of ${a.name} already on this machine`),await t.store.put({key:s,sourcePath:a.path,source:"cloud",name:a.name}),{path:a.path,name:a.name,fromStore:!0};r.onProgress?.(`looking up ${s}\u2026`);let o=await t.client(r.baseUrl,r.auth).details(s);if(r.accepts&&!r.accepts.some(i=>o.name.toLowerCase().endsWith(i)))throw new Error(`${o.name} cannot run on this device \u2014 expected ${r.accepts.join(" or ")}.`);r.onProgress?.(`downloading ${o.name} \u2014 this can take a while, please wait\u2026`);let p=await O(A(T(),"kane-app-dl-"));try{let i=A(p,z(o.name));await t.fetchToFile(o.url,i);let n=await t.store.put({key:s,sourcePath:i,source:"cloud",name:o.name});return r.onProgress?.(`${o.name} is ready`),{path:n.path,name:n.name,fromStore:!1,details:o}}finally{await $(p,{recursive:!0,force:!0})}}export{c as a,Y as b,Z as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{K as $,s as p}from"./chunk-
|
|
2
|
+
import{K as $,s as p}from"./chunk-WE7HRAGO.js";import{a as f}from"./chunk-QXQ7KVEN.js";import{oa as u}from"./chunk-PI7OXS62.js";var w=e=>e===1?"1 change":`${e} changes`,v=e=>e===1?"waits":"wait";function c(e){let t=/^(\S+-\d+) · (.+)$/.exec(e.title);return t?`${u(t[1])} "${t[2]}"`:`"${e.title}"`}var y=e=>typeof e=="string"?`"${e}"`:e.bare,d=y,j=e=>typeof e=="string"?e:e.bare;function D(e,t){return t.page?{...e,page:t.page}:null}var m=e=>e.page?.bare?{bare:e.page.shown}:e.page?.shown??e.source,O={header:e=>`reviewing what changed in ${d(e)}`,held:(e,t)=>{let n=t.filter(s=>s==="ADD").length,i=t.filter(s=>s==="ARCHIVE").length,r=t.length-n-i,o=[n>0?`${n} new ${n===1?"use-case":"use-cases"}`:null,r>0?`${r} changed`:null,i>0?`${i} no longer in it`:null].filter(s=>s!==null);return`${w(t.length)} from ${d(e)} ${v(t.length)} for your review: ${o.join(", ")}`},waiting:(e,t)=>`${w(t)} from ${d(e)} ${v(t)} for your review`,reviewRow:(e,t)=>`review ${w(t)} from ${d(e)}`,finishForNow:{label:"finish for now",detail:"the review waits in this session"},adjust:"adjust \u2014 tell me what to change",reviewed:(e,t)=>{let n=t.approved+t.rejected+t.deferred,i=[t.approved>0?`${t.approved} approved`:null,t.rejected>0?t.rejected===1?"1 kept as it was":`${t.rejected} kept as they were`:null,t.deferred>0?`${t.deferred} left for later`:null].filter(r=>r!==null);return`reviewed ${n===1?"the change":`the ${n} changes`} from ${d(e)}: ${i.join(" \xB7 ")}`},finishSession:"finish the session",diffTitle:e=>c(e),receipt:(e,t)=>{let n=c(e),i=e.kind==="ADD",r="nothing is saved for this change, and it may be suggested again";return t==="approve"?{line:i?`added ${n} to this session`:e.kind==="ARCHIVE"?`archived ${n} in this session`:`approved the change to ${n} in this session`}:t==="reject"?{line:i?`left ${n} out of this session`:`kept ${n} as it is`,note:r}:{line:i?`left ${n} out for now, as an open question`:`left ${n} as it is for now, as an open question`}},refused:(e,t,n)=>t==="TARGET_RETIRED"?{line:`${c(e)} was archived while you were reviewing, so nothing changed`}:t==="SOURCE_MOVED"?{line:`${d(m(n))} changed again while you were reviewing, so this change wasn't taken`,next:["next: to review the latest version, run:",n.page?` kane-cli context ingest ${f(n.page.address)}${n.page.as?` --as ${f(n.page.as)}`:""}`:` kane-cli maintain reconcile --from ${n.file} --source-id ${n.source}`]}:t==="SOURCE_UNRESOLVED"?{line:`${d(m(n))} was removed while you were reviewing, so this change can't be taken`}:t==="ARCHIVE_UNRESOLVED"?{line:`${c(e)} changed while you were reviewing, so it can't be archived`,moveOn:!0}:t==="CONCURRENT_APPEND"?{line:"that didn't go through: the project was busy; try the card again"}:t==="ALREADY_VERDICTED"||t==="CARD_GONE"||t==="HOLD_GONE"?{line:"that change isn't in this review anymore, so nothing was done"}:{line:"that change can't be taken, so nothing was done",next:[`if this keeps failing, share this id with support: ${p(`refused_${t}`)}`]},chatRefused:e=>{let t=[];for(let n of e){let i=n.ref?`${u(n.ref)}${n.title?` "${n.title}"`:""}`:null;n.code==="EXPECTED_CID_MOVED"&&i?n.moved?t.push(`${i} changed after the agent read it, so this edit wasn't made`,"continue, and the agent works from its latest version"):t.push(`the agent's edit to ${i} didn't match it as it is now, so it wasn't made`,"continue, and the agent reads it again"):t.push("continue, and the agent tries again",`if this keeps failing, share this id with support: ${p(`refused_${n.code}`)}`)}return[...new Set(t)]},approveRefused:e=>{let t=e.find(n=>n.code==="EXPECTED_CID_MOVED"&&n.ref);return t?{line:`${`${u(t.ref)}${t.title?` "${t.title}"`:""}`} changed after it was shown to you, so nothing was approved`,notes:['view what was added to see it as it is now, then pick "looks good" again']}:{line:"that didn't go through, so nothing was approved",notes:['pick "looks good" again',`if this keeps failing, share this id with support: ${p(`refused_${e[0]?.code??"APPROVE"}`)}`]}},diffSummary:e=>{let t=e.filter(s=>s.field==="criteria"),n=Math.max(t.filter(s=>s.op==="+").length,t.filter(s=>s.op==="-").length),i=[...new Set(e.filter(s=>s.field!=="criteria").map(s=>s.field))],r=i.length>0?`its ${i.join(" and ")}`:null,o=n>0?`${n} acceptance ${n===1?"criterion":"criteria"} changed`:null;return o&&r?`${o}, and ${r}`:o??`${r} changed`},steering:"reading the change again, with your words",steerNothing:"your words left nothing to review",steerFailed:"that didn't go through; the changes wait as they were",offerAsks:e=>e>0?"design its tests again?":"design its tests?",notLanded:"that didn't go through; try the card again",offer:(e,t)=>t>0?{headline:t===1?`the test of "${e}" was designed for its old version`:`the ${t} tests of "${e}" were designed for its old version`,rows:[{key:"run",label:t===1?"design it again now":"design them again now",detail:t===1?"replaces it if it no longer fits":"replaces any that no longer fit"},{key:"later",label:"later",detail:`kane-cli context list --stale lists ${t===1?"it":"them"}`}]}:{headline:`"${e}" has no tests yet`,rows:[{key:"run",label:"design its tests now"},{key:"later",label:"later",detail:"design them after you save"}]},childOpen:(e,t)=>`designing the tests of "${t}"${e==="evolve"?" again":""}`,childClosed:(e,t,n)=>[`designed the tests of "${t}"${e==="evolve"?" again":""}`,n.join(" \xB7 ")].filter(Boolean).join(" \u2014 "),childTests:(e,t)=>`${l(t)}${e==="evolve"?"":" added"}`,back:e=>`back to the review \u2014 ${l(e)} added in this session`,againBack:e=>{let t=(a,h)=>a===1?`its test ${h}`:`its ${a} tests ${h}`,i=[e.replaced.scenarios+e.replaced.tests>0&&"replaced",e.updated>0&&"updated",e.kept>0&&"kept"].filter(a=>a!==!1);if(i.length===0)return null;let r=`${[...e.replaced.scenarios>0?[k(e.replaced.scenarios)]:[],...e.replaced.tests>0?[l(e.replaced.tests)]:[]].join(" and ")} replaced`;if(i.length===1)return`back to the review \u2014 ${i[0]==="replaced"?e.replaced.scenarios===0?t(e.replaced.tests,"replaced"):r:i[0]==="updated"?t(e.updated,"updated"):e.kept===1?"its test kept as it was":`its ${e.kept} tests kept as they were`}`;let o=[],s=0;return i.forEach((a,h)=>{let b=h===i.length-1;if(a==="replaced"){o.push(r),s+=e.replaced.tests;return}let g=a==="updated"?e.updated:e.kept;b?o.push(s>0?`the other ${g===1?"test":`${g} tests`} ${a}`:t(g,a)):(o.push(`${l(g)} ${a}`),s+=g)}),`back to the review \u2014 ${o.join(", ")}`},childUnfinished:e=>e==="evolve"?"designing its tests again didn't finish":"designing its tests didn't finish",childFailed:(e,t)=>`couldn't design the tests of "${t}"${e==="evolve"?" again":""}`,childFailedNext:(e,t)=>t==="evolve"?["next: to update them later, run:",` kane-cli maintain evolve ${e}`]:["next: to design its tests later, run:",` kane-cli design tests --use-case ${e}`],childFailedNew:"its tests can be designed after you save this session",updateOpen:(e,t)=>`updating the tests of "${e}"${t?" \u2014 its use-case changed":""}`,updateClosed:(e,t)=>[`updated the tests of "${e}"`,t.join(" \xB7 ")].filter(Boolean).join(" \u2014 "),updateTests:e=>[...e.added>0?[`${l(e.added)} added`]:[],...$({changes:{tests:e.updated}})].join(", ")||null,updateUnfinished:e=>`updating the tests of "${e}" didn't finish`,updateFinishing:"finishing the update\u2026",updateFailed:e=>`couldn't update the tests of "${e}"`,updateUntouched:e=>`finished here: the tests of "${e}" weren't changed`,childHeld:(e,t)=>[{text:` \u2717 its tests can't be designed again now: ${e?"you're designing them in another session":"someone else is designing them"}`},{text:" the change stays approved in this session; to update its tests later, run:",dim:!0},{text:` kane-cli maintain evolve ${t}`,dim:!0}]},l=e=>e===1?"1 test":`${e} tests`,k=e=>e===1?"1 scenario":`${e} scenarios`;function S(e){return/^\S+-\d+ · (.+)$/.exec(e.title)?.[1]??e.title}export{c as a,y as b,j as c,D as d,m as e,O as f,S as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{c as h}from"./chunk-E4GIGM5V.js";import{P as v,ta as O,xb as y,yb as G,zb as b}from"./chunk-PI7OXS62.js";import{f as i,g as a,i as S}from"./chunk-KU3YHPWZ.js";import{o as m}from"./chunk-HYJVYYAZ.js";var C=new Set([a.BELONGS_TO,a.SCOPED_TO]),N="re-pinned onto the use case's live version: its update changed nothing";function A(e,s){let n=e.tipOf(s);return e.superseded.has(n)?[]:b(e,n).filter(t=>t!==n).flatMap(t=>e.edgesInto(t).filter(r=>C.has(r.type)&&!e.superseded.has(r.src)))}function k(e,s){for(let n of e.edgesFrom(s)){if(S(n.type)?.pin?.comparesTo!=="dst_tip"||!e.superseded.has(n.dst))continue;let t=e.tipOf(n.dst);if(e.superseded.has(t)||e.nodeLabel.get(t)===i.USECASE&&!C.has(n.type))return!1}return!0}function U(e){let{store:s,graph:n,by:t}=e,r=A(n,e.ucTip);if(r.length===0)return{record:null,moved:0,errors:null};let c=n.tipOf(e.ucTip),l=r.flatMap(o=>[{kind:"retract",target:o.src,expectedCid:o.src,edgeEcid:o.ecid,reason:N,eventId:`repin:${o.ecid}`},{kind:"enhance",target:o.src,expectedCid:o.src,edges:[{type:o.type,src:o.src,dst:c,props:o.props}],eventId:`repin:${o.ecid}:live`}]),d=h({store:s,graph:n,ops:l,by:t,mintable:[],learn:!1,...e.sid?{sid:e.sid}:{}});return d.errors?{record:null,moved:0,errors:d.errors}:{record:d.record,moved:r.length,errors:null}}var L=new Set([i.USECASE,i.SCENARIO,i.AC,i.TEST]);function $(e,s){return!e.superseded.has(s)&&e.trust.get(s)!=="archived"}function f(e,s,n){let t=e.edgesFrom(s).find(r=>r.type===n);return t?e.tipOf(t.dst):null}function D(e,s,n){if(n===i.USECASE)return s;if(n===i.SCENARIO)return f(e,s,a.BELONGS_TO);if(n===i.AC){let t=f(e,s,a.SCOPED_TO);return t?e.nodeLabel.get(t)===i.USECASE?t:f(e,t,a.BELONGS_TO):null}if(n===i.TEST){let t=f(e,s,a.AUTOMATES);return t?f(e,t,a.BELONGS_TO):null}return null}function*x(e,s){for(let{cid:n,state:t}of e.staleList()){if(t==="superseded")continue;let r=e.nodeLabel.get(n);!r||!L.has(r)||!$(e,n)||D(e,n,r)===s&&(yield{cid:n,label:r})}}function T(e,s){for(let{cid:n}of x(e,s))if(y(e,n))return!0;return!1}function q(e,s){let n=new Set,t=!1,r=!0;for(let{cid:c,label:l}of x(e,s)){let d=G(e,c);if(l===i.USECASE)for(let o of d.sources)n.add(o);else d.sources.length>0&&([t,r]=[!0,!1]);d.pin&&([t,r]=[!0,r&&k(e,c)])}return{sources:[...n].sort(),design:t,repinnable:t&&r}}var z=e=>e.sources.length>0&&!e.design;function _(e,s){let n=null;for(let[t,r]of e.designOf)t!==s&&e.tipOf(t)!==s||(n==null||r.seq>n.seq)&&(n={...r,designed_at_cid:t});return n}function F(e,s){let n=_(e,s);if(n!=null)return n.designed_at_cid===s||!T(e,s)?"current":"stale"}function R(e,s){let n=O(e.superseded,c=>e.nodeLabel.get(c)),t=[s],r=s;for(;n.has(r);)r=n.get(r),t.unshift(r);return t}function Y(e,s,n){let t=v(e,s);if(!t.ok&&t.why==="unknown"){let u=[...e.names.keys()].filter(w=>w.startsWith("uc-")).sort().slice(0,6);return{ok:!1,code:2,message:`unknown use-case '${s}' \u2014 no live node by that logical id or cid${u.length?` (known: ${u.join(", ")})`:""}`}}if(!t.ok&&t.why==="removed")return{ok:!1,code:2,message:`use-case '${s}' was removed (tombstoned) \u2014 nothing to design`};if(!t.ok)return{ok:!1,code:2,message:`'${s}' is a ${t.label??"missing node"}, not a use-case \u2014 design runs per use-case`};let r=t.cid,c=e.resolve(s)?.cid,l=e.nameOf.get(r)??(c?e.nameOf.get(c):void 0)??e.displayNameOf(r)??r.slice(0,19);if(e.trust.get(r)==="archived"){let u=e.archivedReason.get(r);return{ok:!1,code:2,message:`use-case '${l}' is archived${u?` (${u})`:""} \u2014 design runs only over live use-cases`}}let d=_(e,r);if(d==null||n)return{ok:!0};let o=R(e,r),p=o.length;if(F(e,r)==="current")return{ok:!1,code:2,message:m().text("note.already_designed",{use_case:l,version:p}),wall:{kind:"already-designed",display:l,currentV:p}};let g=o.indexOf(d.designed_at_cid),E=g>=0?`v${g+1}`:"an earlier version";return{ok:!1,code:2,message:m().text("note.design_stale",{use_case:l,designed:E,current:p}),wall:{kind:"designed-stale",display:l,currentV:p,designedV:E}}}export{U as a,L as b,$ as c,D as d,T as e,q as f,z as g,_ as h,F as i,Y as j};
|