@testmuai/kane-cli 0.10.3 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChatSurface-DN7VVN3Y.js +2 -0
- package/dist/ChromeProfilePicker-TVGWXTUU.js +2 -0
- package/dist/{CliFeedbackPrompt-JWCTMIGI.js → CliFeedbackPrompt-L5ILK66U.js} +1 -1
- package/dist/{CliUploadProgress-XFRRFRL4.js → CliUploadProgress-IU6BQLMV.js} +1 -1
- package/dist/{ConfigView-6JF4DOJN.js → ConfigView-LU5IRRQU.js} +1 -1
- package/dist/EvidenceViewOffer-DNTARDEL.js +2 -0
- package/dist/FolderPicker-6E5GE2K2.js +2 -0
- package/dist/InfoBox-SFFPLWCV.js +2 -0
- package/dist/LinksBox-6YDTIO6I.js +2 -0
- package/dist/ProfilesView-6C5HJQ3Y.js +2 -0
- package/dist/ProjectPicker-YIQIVXGK.js +2 -0
- package/dist/SaveSessionPrompt-X3N6OGYB.js +2 -0
- package/dist/SingleShotApp-MXNJPU6A.js +2 -0
- package/dist/SummaryBox-T7PDXDKS.js +2 -0
- package/dist/TestMdRunView-HRJSBP2C.js +2 -0
- package/dist/TestrunEvidenceTable-OGMWTJQF.js +2 -0
- package/dist/{WhoamiView-H7JNLLCY.js → WhoamiView-WGCWD7GP.js} +1 -1
- package/dist/{app-client-U2YYF65L.js → app-client-2RR5ATI6.js} +1 -1
- package/dist/app-download-ZS6ZMX2Z.js +2 -0
- package/dist/{assurance-job-F4L3T4VJ.js → assurance-job-QO4VJJCL.js} +1 -1
- package/dist/{binary-K3XMILST.js → binary-CCCTW3QQ.js} +1 -1
- package/dist/bind-JU4XPDN3.js +2 -0
- package/dist/bootstrap-BV7HAARR.js +2 -0
- package/dist/{bridge-2UHJOVLX.js → bridge-SPGIYAAG.js} +1 -1
- package/dist/{catalog-YCU6OHNV.js → catalog-ZAROGOJA.js} +1 -1
- package/dist/{catalog-client-MVEEHTG2.js → catalog-client-QLHCEPPZ.js} +1 -1
- package/dist/{changelog-5UB3AQT6.js → changelog-6L7W76ZH.js} +1 -1
- package/dist/chat-committer-7E3TRZ6P.js +2 -0
- package/dist/chat-controller-5ZBG23L6.js +2 -0
- package/dist/child-MNLSG77W.js +2 -0
- package/dist/{chunk-LRNUGKYH.js → chunk-2CJ75THZ.js} +1 -1
- package/dist/{chunk-UWPG5MWM.js → chunk-2EKLTUY2.js} +1 -1
- package/dist/{chunk-C4KAPGBS.js → chunk-2KPJ62RZ.js} +3 -3
- package/dist/{chunk-SMGRXKXX.js → chunk-2VLM4L3S.js} +1 -1
- package/dist/{chunk-ZHAMVLQZ.js → chunk-3A4KK22B.js} +1 -1
- package/dist/{chunk-L3BUPFAQ.js → chunk-3CFAE36M.js} +1 -1
- package/dist/{chunk-TU2KPOW2.js → chunk-3DFBFYTD.js} +2 -2
- package/dist/{chunk-6FFX4S7N.js → chunk-3HGKFRFL.js} +1 -1
- package/dist/{chunk-VKVYT6KZ.js → chunk-3JATEWA5.js} +2 -2
- package/dist/{chunk-GXQYFOBD.js → chunk-3O2RPYPM.js} +1 -1
- package/dist/chunk-3UY4WPMQ.js +8 -0
- package/dist/{chunk-6HRNG4CK.js → chunk-3VSAAB2W.js} +1 -1
- package/dist/{chunk-RNHSULQM.js → chunk-454IWKHT.js} +1 -1
- package/dist/{chunk-ZMWTRXFH.js → chunk-4DRFMDAW.js} +1 -1
- package/dist/{chunk-HRIDAK6Y.js → chunk-4FA44D6S.js} +1 -1
- package/dist/{chunk-YVVFXBT5.js → chunk-4G2T54FE.js} +1 -1
- package/dist/{chunk-N7IWR45S.js → chunk-4KFSSETE.js} +1 -1
- package/dist/chunk-4QV2RL6P.js +34 -0
- package/dist/{chunk-ERRIDBE7.js → chunk-4WFN23DE.js} +1 -1
- package/dist/{chunk-NPAUSUNM.js → chunk-4WKFM72U.js} +1 -1
- package/dist/{chunk-BLVDV3QQ.js → chunk-55W3WAAL.js} +1 -1
- package/dist/{chunk-YQZ736IQ.js → chunk-56NUPYFG.js} +1 -1
- package/dist/{chunk-PI7OXS62.js → chunk-5EAJO372.js} +1 -1
- package/dist/{chunk-35WUYKGO.js → chunk-5HJRYEOT.js} +1 -1
- package/dist/{chunk-Y3RJHWNK.js → chunk-5OGYXLOR.js} +1 -1
- package/dist/{chunk-CQDCNP7V.js → chunk-5ORBAYTU.js} +1 -1
- package/dist/{chunk-KKLCXRW6.js → chunk-642LB5R2.js} +1 -1
- package/dist/{chunk-OBNVGD5H.js → chunk-662MCICY.js} +1 -1
- package/dist/{chunk-PCQK62MP.js → chunk-6CMBA5SG.js} +1 -1
- package/dist/{chunk-X6FCXBXU.js → chunk-6FVGPKVX.js} +1 -1
- package/dist/{chunk-32HED7X2.js → chunk-6KUUSONE.js} +1 -1
- package/dist/{chunk-VCVEZEVS.js → chunk-6PURZLKM.js} +1 -1
- package/dist/{chunk-ZCBOHWN3.js → chunk-73EHVDL5.js} +1 -1
- package/dist/{chunk-QHH42RH5.js → chunk-7KASYSFM.js} +1 -1
- package/dist/{chunk-SJQTTEXQ.js → chunk-7V6JPZBM.js} +1 -1
- package/dist/{chunk-WE7HRAGO.js → chunk-7WWCIS2B.js} +1 -1
- package/dist/{chunk-M7A66MSK.js → chunk-A74JRNNX.js} +1 -1
- package/dist/{chunk-ENRFXGID.js → chunk-ABAUIIPD.js} +1 -1
- package/dist/{chunk-YILRYMMG.js → chunk-ABNQL3PQ.js} +1 -1
- package/dist/{chunk-GQAWZEA4.js → chunk-ACBNVGVJ.js} +1 -1
- package/dist/{chunk-YPGZ5E4I.js → chunk-AFOP7DVG.js} +1 -1
- package/dist/{chunk-JTNEF5ZP.js → chunk-AL6IAMYV.js} +1 -1
- package/dist/chunk-APXJRWIJ.js +2 -0
- package/dist/{chunk-EBJW6POT.js → chunk-ATCJ7EHL.js} +1 -1
- package/dist/{chunk-IZ66FKPC.js → chunk-BIGOLVK6.js} +1 -1
- package/dist/{chunk-LHJSIHLC.js → chunk-BIXABKSK.js} +1 -1
- package/dist/chunk-BK3LWNKB.js +102 -0
- package/dist/{chunk-X2MDL6S4.js → chunk-BPTWMV5L.js} +1 -1
- package/dist/{chunk-4CJQ7XZP.js → chunk-BV7NUIRT.js} +1 -1
- package/dist/{chunk-UJ37XGSP.js → chunk-BXAPTB2H.js} +3 -3
- package/dist/{chunk-X7S7IGCV.js → chunk-BXJNL22L.js} +1 -1
- package/dist/{chunk-Z24SD2EJ.js → chunk-C3DMMAFP.js} +1 -1
- package/dist/chunk-CBEMXSWF.js +2 -0
- package/dist/{chunk-IEHJG6J4.js → chunk-CVVZ6NWR.js} +1 -1
- package/dist/{chunk-OZNYQONA.js → chunk-DAV4ONGS.js} +3 -3
- package/dist/{chunk-MEBEVHGP.js → chunk-DBMDAWTA.js} +1 -1
- package/dist/{chunk-CNHKZE4F.js → chunk-DJ76NDW6.js} +1 -1
- package/dist/{chunk-ZPU3WAC4.js → chunk-DRWHVVW6.js} +1 -1
- package/dist/{chunk-Z47ZEFH7.js → chunk-DXXHCLFC.js} +1 -1
- package/dist/{chunk-35BG2EMW.js → chunk-E3C4OWSD.js} +1 -1
- package/dist/{chunk-KQ4XKTIZ.js → chunk-ECPSBI2Z.js} +1 -1
- package/dist/{chunk-X45RZIAJ.js → chunk-EG3B52WU.js} +1 -1
- package/dist/{chunk-EJGCIGQY.js → chunk-EOLMWSLX.js} +1 -1
- package/dist/{chunk-GAKBHNC4.js → chunk-EUGFABAS.js} +1 -1
- package/dist/{chunk-OTMHCHH6.js → chunk-EWK3UPEN.js} +1 -1
- package/dist/{chunk-NI3TIAD7.js → chunk-EWSNJ3IX.js} +1 -1
- package/dist/{chunk-SALZ6WSF.js → chunk-F4XCCOWC.js} +1 -1
- package/dist/{chunk-YNDELIXL.js → chunk-FH4FWIET.js} +1 -1
- package/dist/chunk-FQ2AMM3E.js +3 -0
- package/dist/{chunk-5YYCCM6K.js → chunk-FTP2K6RS.js} +1 -1
- package/dist/{chunk-JBKHX5ES.js → chunk-GJYMR4RT.js} +1 -1
- package/dist/{chunk-NHGPMYM3.js → chunk-GMSWZIAS.js} +1 -1
- package/dist/{chunk-AHT2ORJT.js → chunk-GPIVYCHQ.js} +1 -1
- package/dist/{chunk-ZDCXWEQG.js → chunk-GRQKMOKE.js} +1 -1
- package/dist/{chunk-E4GIGM5V.js → chunk-H6IPGZTP.js} +1 -1
- package/dist/{chunk-7Y55CO42.js → chunk-H6QHG62O.js} +1 -1
- package/dist/{chunk-MINDIQET.js → chunk-HBGYEA3O.js} +1 -1
- package/dist/{chunk-VO2NNXKR.js → chunk-HGKAUG7L.js} +1 -1
- package/dist/{chunk-Q4SMITTV.js → chunk-HMGM4KO6.js} +1 -1
- package/dist/{chunk-CTHUX7O4.js → chunk-I3G3IUKY.js} +1 -1
- package/dist/{chunk-MD3RABID.js → chunk-IDWAG6L4.js} +1 -1
- package/dist/{chunk-TM6VLC6V.js → chunk-IPIARGHE.js} +1 -1
- package/dist/chunk-IQMJJN52.js +3 -0
- package/dist/{chunk-WEJR2V7R.js → chunk-J3XOEMKO.js} +1 -1
- package/dist/{chunk-GJXO6FF7.js → chunk-JBUKEIYL.js} +1 -1
- package/dist/{chunk-7RELCXRW.js → chunk-JE5M5QIK.js} +1 -1
- package/dist/{chunk-QEM5ZRDN.js → chunk-JJDD4HPX.js} +1 -1
- package/dist/{chunk-NRAPCFI2.js → chunk-JM45SLKV.js} +2 -2
- package/dist/{chunk-GEZVC4S3.js → chunk-JM6AKCN4.js} +1 -1
- package/dist/{chunk-3KY7HHQU.js → chunk-JSSM2TWY.js} +1 -1
- package/dist/{chunk-3MD2XLE7.js → chunk-JYSIPTX3.js} +9 -8
- package/dist/{chunk-AVLYSNEG.js → chunk-KJZD2ADR.js} +1 -1
- package/dist/chunk-KLY6IQD5.js +26 -0
- package/dist/{chunk-LTPOMMAB.js → chunk-LB5NIDW6.js} +1 -1
- package/dist/{chunk-HV2CDY4K.js → chunk-LCBDNZL3.js} +1 -1
- package/dist/{chunk-SIHX5FW5.js → chunk-LJKTIKZY.js} +1 -1
- package/dist/{chunk-SXBPUUQ5.js → chunk-LLDEAV3W.js} +1 -1
- package/dist/{chunk-PTLOOVV4.js → chunk-LV7OWLJK.js} +1 -1
- package/dist/{chunk-TUSG7DIL.js → chunk-MNELOQ4J.js} +1 -1
- package/dist/{chunk-3ZC7GSMM.js → chunk-MOAZZKIZ.js} +1 -1
- package/dist/{chunk-YWWVF5OU.js → chunk-MQU6EA44.js} +1 -1
- package/dist/chunk-MTMHB5LF.js +2 -0
- package/dist/{chunk-Q4ALB7SH.js → chunk-MWLRLQ27.js} +1 -1
- package/dist/{chunk-OHGL4GEJ.js → chunk-MZ4GTIO2.js} +1 -1
- package/dist/chunk-NKJRAQ6L.js +6 -0
- package/dist/{chunk-LPJKNX6D.js → chunk-NMCE7VR2.js} +1 -1
- package/dist/{chunk-7V34ZMMS.js → chunk-OKCVG7AG.js} +1 -1
- package/dist/{chunk-LZGAFKYH.js → chunk-OMCJD4LH.js} +1 -1
- package/dist/{chunk-OOGKX4Y6.js → chunk-OSEXVHEN.js} +1 -1
- package/dist/{chunk-EZMRWXRT.js → chunk-OVB5GVRB.js} +1 -1
- package/dist/{chunk-ND6OP3O2.js → chunk-OX3ZAGCH.js} +1 -1
- package/dist/{chunk-LXK4B2FE.js → chunk-P43YHCF3.js} +1 -1
- package/dist/{chunk-ZMIKNNO6.js → chunk-P7V24ZXP.js} +1 -1
- package/dist/{chunk-3NWUXRSI.js → chunk-PBVNX43X.js} +1 -1
- package/dist/{chunk-MEMXFTLD.js → chunk-PEHVBCXM.js} +1 -1
- package/dist/{chunk-4UX5N7YI.js → chunk-PHKJIJ7D.js} +1 -1
- package/dist/{chunk-BBJAKSA7.js → chunk-PMYN3XMN.js} +2 -2
- package/dist/{chunk-R6TFRAMZ.js → chunk-PUNFWBRW.js} +1 -1
- package/dist/chunk-Q5B54TR5.js +2 -0
- package/dist/{chunk-KCXLRR3Q.js → chunk-QEBVYQNC.js} +1 -1
- package/dist/{chunk-PB6RXDWQ.js → chunk-QFA6JPVE.js} +2 -2
- package/dist/{chunk-TAY7J5VS.js → chunk-QLGQDNA3.js} +1 -1
- package/dist/{chunk-7SU53QGU.js → chunk-QOXUGYEA.js} +1 -1
- package/dist/{chunk-LV7224DG.js → chunk-QXZGBYGQ.js} +1 -1
- package/dist/{chunk-4KL3TSTT.js → chunk-QYWWL7M7.js} +4 -4
- package/dist/{chunk-M2E5CPPV.js → chunk-RG3FNO37.js} +1 -1
- package/dist/{chunk-YCVEI7BT.js → chunk-RNKJXVG2.js} +1 -1
- package/dist/{chunk-HBLHKQR7.js → chunk-S5PIVHPC.js} +1 -1
- package/dist/{chunk-LUA25RYS.js → chunk-S74NLCFZ.js} +1 -1
- package/dist/chunk-SBW3QVHN.js +7 -0
- package/dist/{chunk-2TK4MDF2.js → chunk-SMSQVGLH.js} +1 -1
- package/dist/{chunk-Y2HQMJGS.js → chunk-SO3IXFAJ.js} +1 -1
- package/dist/{chunk-T77LTLAD.js → chunk-SULRMI2J.js} +1 -1
- package/dist/{chunk-KL7XFNSD.js → chunk-SZQNYDST.js} +1 -1
- package/dist/chunk-T5FQRUI2.js +47 -0
- package/dist/{chunk-HVOXMCKE.js → chunk-TCK7WR3M.js} +1 -1
- package/dist/{chunk-OCMPWCKQ.js → chunk-TELSHQ3W.js} +1 -1
- package/dist/{chunk-FOLUB336.js → chunk-TFSWG7AS.js} +1 -1
- package/dist/{chunk-2JFRN62I.js → chunk-TLYFHPNM.js} +2 -2
- package/dist/{chunk-CB2BWDHG.js → chunk-TO2ROHIJ.js} +4 -4
- package/dist/{chunk-PRBWZXFA.js → chunk-TOOJTCON.js} +6 -6
- package/dist/{chunk-DQXQJJOP.js → chunk-TXRWH6HL.js} +2 -2
- package/dist/chunk-U5V3L5QH.js +2 -0
- package/dist/{chunk-WIVKLNIO.js → chunk-UVBPUZC4.js} +1 -1
- package/dist/{chunk-23DKB2MT.js → chunk-UVL6XQHU.js} +1 -1
- package/dist/{chunk-DC5F2ADJ.js → chunk-UZKVV3LW.js} +1 -1
- package/dist/{chunk-YDB72F4K.js → chunk-V4SL74TK.js} +1 -1
- package/dist/chunk-V57R4X3O.js +5 -0
- package/dist/{chunk-LLQWEGXD.js → chunk-W5EDS4DF.js} +1 -1
- package/dist/{chunk-6QH75BPJ.js → chunk-WB4JZ67W.js} +1 -1
- package/dist/{chunk-W54BX6HC.js → chunk-WCIRLITM.js} +1 -1
- package/dist/{chunk-OCVDMZWB.js → chunk-WHMCVH3T.js} +1 -1
- package/dist/{chunk-XKOVEMVZ.js → chunk-WMIR4UXG.js} +1 -1
- package/dist/chunk-WMXBRC4B.js +21 -0
- package/dist/{chunk-RQKMSNEU.js → chunk-WTMCDYR3.js} +1 -1
- package/dist/{chunk-DXIQVBMI.js → chunk-WZ3FE5MT.js} +1 -1
- package/dist/{chunk-3RO2YGKH.js → chunk-X3O4VGTM.js} +1 -1
- package/dist/{chunk-GLM5UGTF.js → chunk-X66NIHT4.js} +1 -1
- package/dist/{chunk-B7ZX5HEN.js → chunk-XDAFRUAJ.js} +1 -1
- package/dist/{chunk-JNPFEBUR.js → chunk-XDAHKZ4J.js} +1 -1
- package/dist/{chunk-ZCL7XIVS.js → chunk-XKJZG4GR.js} +1 -1
- package/dist/chunk-XTQUCCJH.js +2 -0
- package/dist/{chunk-SVIIUKJ2.js → chunk-Y7GSOKXS.js} +1 -1
- package/dist/chunk-YIBLZIXF.js +13 -0
- package/dist/{chunk-J4FIESTB.js → chunk-YKOZBFR3.js} +1 -1
- package/dist/{chunk-TM45NPWL.js → chunk-YWQNZRJG.js} +1 -1
- package/dist/chunk-YZP4F23B.js +18 -0
- package/dist/{chunk-QE4AWNOV.js → chunk-Z4O5HOFX.js} +6 -6
- package/dist/{chunk-KBGMQYMD.js → chunk-ZFKR5I3J.js} +1 -1
- package/dist/{chunk-6QCCTZO3.js → chunk-ZHENGHYZ.js} +1 -1
- package/dist/{chunk-SSOUYKVG.js → chunk-ZIRSTOEV.js} +1 -1
- package/dist/{chunk-AT7AT3AR.js → chunk-ZVSZ6DIQ.js} +5 -5
- package/dist/command-span-HZSKIZH7.js +2 -0
- package/dist/commands-X5T6YANK.js +2 -0
- package/dist/{committer-UO3B3S5Y.js → committer-L2HXEODA.js} +1 -1
- package/dist/{config-7WTZPMAH.js → config-F5Q6QX27.js} +1 -1
- package/dist/cover-cmd-PWUZU4HK.js +2 -0
- package/dist/{credentials-5WIFF5DG.js → credentials-D5KQMHCK.js} +1 -1
- package/dist/{deps-bundle-BLLJ2BQ4.js → deps-bundle-R7FNIV4M.js} +1 -1
- package/dist/{deps-resolve-WQ6J6RLI.js → deps-resolve-IF6P6NWI.js} +1 -1
- package/dist/design-chat-HYK3HNIM.js +2 -0
- package/dist/{design-committer-7YIPFKMO.js → design-committer-ZKNW5LUS.js} +1 -1
- package/dist/design-headless-DR7WB37W.js +2 -0
- package/dist/design-remote-TGUNEWEM.js +3 -0
- package/dist/device-env-LZB3PKMA.js +2 -0
- package/dist/dispatch-BGH5PVZ4.js +2 -0
- package/dist/doctor-PLFEA2HM.js +2 -0
- package/dist/{docx-convert-DO5AQYD3.js → docx-convert-PA5S2S7P.js} +1 -1
- package/dist/{dossier-5XKNAK6Q.js → dossier-B6KBSRJY.js} +1 -1
- package/dist/evidence-SRWISQMQ.js +2 -0
- package/dist/evolve-cmd-2BALEYZU.js +2 -0
- package/dist/evolve-remote-OHOUWO65.js +2 -0
- package/dist/exit-manager-UZ7DGXS4.js +2 -0
- package/dist/{explain-cmd-KNDORU2D.js → explain-cmd-A5YMPXAJ.js} +1 -1
- package/dist/explain-cmd-VTDAMXAW.js +12 -0
- package/dist/explore-UZWQRJ7H.js +2 -0
- package/dist/explore-context-tty-PAKJVDJU.js +2 -0
- package/dist/explore-entry-ZOPO7DBZ.js +6 -0
- package/dist/{explore-live-XIWWUV52.js → explore-live-RUAAZGX4.js} +1 -1
- package/dist/{explore-run-tty-M56I23IF.js → explore-run-tty-DYLMHI7F.js} +2 -2
- package/dist/{extract-bind-LZ22VFKB.js → extract-bind-WPICR4IC.js} +3 -3
- package/dist/extract-chat-KVUB5HPM.js +2 -0
- package/dist/{extract-cmd-46E2XDWZ.js → extract-cmd-OJ7LXSKL.js} +2 -2
- package/dist/extract-headless-OQJSUSG4.js +2 -0
- package/dist/{feeder-NGWIPZ26.js → feeder-VAY4NYBX.js} +1 -1
- package/dist/folder-flags-MEZUAXTT.js +2 -0
- package/dist/gaps-cmd-2R4RMWN6.js +3 -0
- package/dist/gate-SM4HPJLA.js +2 -0
- package/dist/gate-VJ7W5QIH.js +2 -0
- package/dist/{generate-headless-HXAVEAEZ.js → generate-headless-XR3RVULC.js} +3 -3
- package/dist/hold-passthrough-ZHOC2Q26.js +2 -0
- package/dist/identity-66TGWITQ.js +2 -0
- package/dist/{impact-cmd-TJTUFAFO.js → impact-cmd-EL3QSOAF.js} +2 -2
- package/dist/index.js +185 -184
- package/dist/ingest-6UQGSQYU.js +2 -0
- package/dist/ingest-cmd-N3USC7TW.js +8 -0
- package/dist/ingest-remote-2VKWAFJZ.js +2 -0
- package/dist/install-3IEM3I3X.js +2 -0
- package/dist/{interactive-bind-SOD7VTAY.js → interactive-bind-F7QTQOKC.js} +4 -4
- package/dist/{interactive-remote-7ZSTI66T.js → interactive-remote-A33J4KMP.js} +2 -2
- package/dist/lane-EHU4JRRU.js +2 -0
- package/dist/lattice-auth-IJT542IF.js +2 -0
- package/dist/lifecycle-cmd-OKUFZKEX.js +2 -0
- package/dist/list-cmd-7OTI66MQ.js +3 -0
- package/dist/list-commands-FZPVH76I.js +2 -0
- package/dist/{list-remote-EFCET42K.js → list-remote-BQ4NILCA.js} +1 -1
- package/dist/{locks-cmd-AZKCSGHI.js → locks-cmd-76IU4JB7.js} +1 -1
- package/dist/{logical-ids-74PLU3VR.js → logical-ids-YMNV2MDB.js} +1 -1
- package/dist/login-flow-BYQ7SYGB.js +2 -0
- package/dist/maintenance-cmd-BLV7K4RK.js +2 -0
- package/dist/mobile-prompts-5TGLJUBV.js +2 -0
- package/dist/onboarding-F4EIJ4GD.js +5 -0
- package/dist/open-provider-LXCPVNUU.js +2 -0
- package/dist/{pdf-convert-YB6PJFMI.js → pdf-convert-N2C3KB4Q.js} +1 -1
- package/dist/persist-recorded-session-WYMOHDTB.js +3 -0
- package/dist/phase-seed-G5JSYKSL.js +2 -0
- package/dist/pipeline-XYM6HIDZ.js +2 -0
- package/dist/{policy-commands-4PUGESCW.js → policy-commands-AOLVAZZD.js} +1 -1
- package/dist/prepare-target-P4AZWC37.js +2 -0
- package/dist/pull-cmd-C4HMYD4I.js +2 -0
- package/dist/pull-route-MHW5PWDW.js +2 -0
- package/dist/readmodel-FARAAPUU.js +2 -0
- package/dist/real-device-run-WAOWKEFJ.js +2 -0
- package/dist/reconcile-cmd-VXY737OT.js +5 -0
- package/dist/reconcile-deps-TILDRCHG.js +2 -0
- package/dist/{reconcile-remote-3W6ZTO3G.js → reconcile-remote-UGW2433E.js} +2 -2
- package/dist/recording-banner-EPOTSMYF.js +2 -0
- package/dist/registry-WTWTFRXD.js +2 -0
- package/dist/remote-entry-SPA4CSJJ.js +2 -0
- package/dist/remote-mode-QO6BDGXM.js +4 -0
- package/dist/remote-words-TAZT4YBT.js +2 -0
- package/dist/{require-project-folder-3DTI2CVB.js → require-project-folder-WBCAVVMB.js} +1 -1
- package/dist/resolve-run-intent-RBOCIYEA.js +2 -0
- package/dist/{resolver-CDF7QKVD.js → resolver-3BGIXYYJ.js} +1 -1
- package/dist/revert-F6MKJ73M.js +2 -0
- package/dist/review-cmd-WE6I5XTY.js +5 -0
- package/dist/run-EABFRFOF.js +2 -0
- package/dist/run-LX3ARF53.js +2 -0
- package/dist/run-remote-6Y62RWMJ.js +2 -0
- package/dist/run-startup-gate-Q7FP2IRE.js +2 -0
- package/dist/run-test-md-24MBKBC6.js +20 -0
- package/dist/session-worker.js +2 -2
- package/dist/{sessions-cmd-TLUITRG5.js → sessions-cmd-5NS5P4CP.js} +2 -2
- package/dist/{sessions-remote-INO7AWKB.js → sessions-remote-75PDRPOY.js} +1 -1
- package/dist/{skill-installer-7JH5QCJF.js → skill-installer-7PK64TZE.js} +1 -1
- package/dist/store-AVYBL5HB.js +2 -0
- package/dist/store-choice-ZWU3PDNL.js +2 -0
- package/dist/store-guard-ETUXXG7X.js +2 -0
- package/dist/{store-site-K5NHLI7D.js → store-site-AFXB6SBW.js} +1 -1
- package/dist/{stream-warnings-GM7YEOVG.js → stream-warnings-I5LUWVFU.js} +1 -1
- package/dist/support-id-RISKXA53.js +2 -0
- package/dist/sync-cmd-CSTMT6E6.js +2 -0
- package/dist/sync-setup-Y53K6TJ6.js +2 -0
- package/dist/tcg-generate-VQLI6NGK.js +2 -0
- package/dist/{test-definition-53XNBEDE.js → test-definition-GXEKFRRB.js} +1 -1
- package/dist/testmd-actions-BE4YJ6ZZ.js +2 -0
- package/dist/{testmd-sync-LYHEXWCT.js → testmd-sync-QZWVWTZZ.js} +1 -1
- package/dist/token-refresh-PZ3TOKAL.js +2 -0
- package/dist/{use-case-ref-44BPIP4N.js → use-case-ref-E3PJDHQB.js} +1 -1
- package/dist/{validate-basic-66XDPA3S.js → validate-basic-QWPESO74.js} +1 -1
- package/dist/verdicts-KB6YTIY6.js +2 -0
- package/dist/{version-check-SHNVYTMU.js → version-check-EOYWTY3Z.js} +1 -1
- package/dist/{view-cmd-QOB3O6YW.js → view-cmd-KG4HI334.js} +1 -1
- package/dist/walk-session-WM4S2JMV.js +2 -0
- package/dist/with-telemetry-RJM3JKL6.js +2 -0
- package/package.json +11 -11
- package/dist/ChatSurface-Z26BOE5U.js +0 -2
- package/dist/ChromeProfilePicker-ODRIAXL3.js +0 -2
- package/dist/EvidenceViewOffer-6344EX74.js +0 -2
- package/dist/FolderPicker-4PCYHE75.js +0 -2
- package/dist/InfoBox-NJ2DL7YC.js +0 -2
- package/dist/LinksBox-HNDNFVUT.js +0 -2
- package/dist/ProfilesView-DEJKJOHY.js +0 -2
- package/dist/ProjectPicker-DTWMWOH7.js +0 -2
- package/dist/SaveSessionPrompt-3GCLB3ZT.js +0 -2
- package/dist/SingleShotApp-HMOXO5DW.js +0 -2
- package/dist/SummaryBox-7PPDMSSM.js +0 -2
- package/dist/TestMdRunView-QLKRUU4V.js +0 -2
- package/dist/TestrunEvidenceTable-T2JUB4TE.js +0 -2
- package/dist/app-download-GKRF2EIM.js +0 -2
- package/dist/bind-SSHAZAB3.js +0 -2
- package/dist/bootstrap-XGKU4WXB.js +0 -2
- package/dist/chat-committer-ZKEKJA2R.js +0 -2
- package/dist/chat-controller-FXRJXUG3.js +0 -2
- package/dist/child-JHYENXE7.js +0 -2
- package/dist/chunk-2RBMQTYS.js +0 -26
- package/dist/chunk-5F5IVART.js +0 -8
- package/dist/chunk-6SD4XTYC.js +0 -6
- package/dist/chunk-7YV2FCN4.js +0 -3
- package/dist/chunk-A2DODRHG.js +0 -2
- package/dist/chunk-BJO6J5X2.js +0 -3
- package/dist/chunk-DIOK3SER.js +0 -34
- package/dist/chunk-DREQ3RAA.js +0 -2
- package/dist/chunk-HC6VLPUB.js +0 -5
- package/dist/chunk-NZJSGINB.js +0 -47
- package/dist/chunk-SXRHKXSE.js +0 -2
- package/dist/chunk-UJLULWSR.js +0 -21
- package/dist/chunk-ULIIYKZB.js +0 -7
- package/dist/chunk-UXGMKRS4.js +0 -102
- package/dist/chunk-VO66KP2W.js +0 -2
- package/dist/chunk-X52YIWGG.js +0 -13
- package/dist/chunk-ZIHQ5JGB.js +0 -18
- package/dist/commands-JBFLLT7A.js +0 -2
- package/dist/cover-cmd-DU6ZYJFL.js +0 -2
- package/dist/design-chat-ZICGVYIH.js +0 -2
- package/dist/design-headless-HYWZIIDS.js +0 -2
- package/dist/design-remote-HPX4VZ63.js +0 -3
- package/dist/device-env-4P4GUVBW.js +0 -2
- package/dist/dispatch-BV6XMCN3.js +0 -2
- package/dist/doctor-Z2YQ2DBX.js +0 -2
- package/dist/evidence-BJIID6VT.js +0 -2
- package/dist/evolve-cmd-GZCUSCEK.js +0 -2
- package/dist/evolve-remote-LILOAHYH.js +0 -2
- package/dist/exit-manager-EGWAZHCR.js +0 -2
- package/dist/explain-cmd-LXIVHGN7.js +0 -12
- package/dist/explore-SA2P3SGX.js +0 -2
- package/dist/explore-context-tty-PERKIWXD.js +0 -2
- package/dist/explore-entry-E6EY3VV3.js +0 -6
- package/dist/extract-chat-Z64LEAJ5.js +0 -2
- package/dist/extract-headless-XLS56LMN.js +0 -2
- package/dist/folder-flags-ZIDJVDKX.js +0 -2
- package/dist/gaps-cmd-XYOBJVTO.js +0 -3
- package/dist/gate-AK44VDHC.js +0 -2
- package/dist/gate-NB5CJMTN.js +0 -2
- package/dist/hold-passthrough-JGHWMYDM.js +0 -2
- package/dist/identity-HL5CJJXR.js +0 -2
- package/dist/ingest-ZHHHBUXR.js +0 -2
- package/dist/ingest-cmd-OJSKTSQK.js +0 -8
- package/dist/ingest-remote-2WM6PYUW.js +0 -2
- package/dist/install-JBWBF3WX.js +0 -2
- package/dist/lane-CNGO7LH5.js +0 -2
- package/dist/lattice-auth-UQPFQSG7.js +0 -2
- package/dist/lifecycle-cmd-DGIO3VAO.js +0 -2
- package/dist/list-cmd-HQIN3HX4.js +0 -3
- package/dist/list-commands-OFRRBU3D.js +0 -2
- package/dist/login-flow-SYKXXDLH.js +0 -2
- package/dist/maintenance-cmd-X5247RSJ.js +0 -2
- package/dist/mobile-prompts-I66ENBDW.js +0 -2
- package/dist/onboarding-6HIP3KW6.js +0 -5
- package/dist/open-provider-XDJKT3W3.js +0 -2
- package/dist/persist-recorded-session-RSSMTVF3.js +0 -3
- package/dist/phase-seed-ZZSJME7M.js +0 -2
- package/dist/pipeline-NTJDH5TC.js +0 -2
- package/dist/prepare-target-AI3GGZF6.js +0 -2
- package/dist/pull-cmd-NRVB5ZN7.js +0 -2
- package/dist/pull-route-FWCZW76M.js +0 -2
- package/dist/readmodel-TRV4E3MW.js +0 -2
- package/dist/real-device-run-NQ7RNH7C.js +0 -2
- package/dist/reconcile-cmd-7B7THAFJ.js +0 -5
- package/dist/reconcile-deps-UDQBWSLE.js +0 -2
- package/dist/recording-banner-WVDTWTSE.js +0 -2
- package/dist/registry-PFOSXOIH.js +0 -2
- package/dist/remote-entry-BZU4NFNS.js +0 -2
- package/dist/remote-mode-NXUKDUXG.js +0 -4
- package/dist/remote-words-JRDDNOZ6.js +0 -2
- package/dist/resolve-run-intent-QCL7QXIB.js +0 -2
- package/dist/revert-QKHPCRT6.js +0 -2
- package/dist/review-cmd-XBK3TGRE.js +0 -5
- package/dist/run-CSYGVV3D.js +0 -2
- package/dist/run-YUHHD54J.js +0 -2
- package/dist/run-remote-SFR3F2T5.js +0 -2
- package/dist/run-startup-gate-QSFJRYUY.js +0 -2
- package/dist/run-test-md-ZSREINDQ.js +0 -20
- package/dist/store-X4UK4AP7.js +0 -2
- package/dist/store-choice-27HDIFTU.js +0 -2
- package/dist/store-guard-ZXKB5DQH.js +0 -2
- package/dist/sync-cmd-2PCO7LZA.js +0 -2
- package/dist/sync-setup-5WQO73Y5.js +0 -2
- package/dist/tcg-generate-DGJD5KSM.js +0 -2
- package/dist/testmd-actions-XE2JPQHB.js +0 -2
- package/dist/token-refresh-E4FTJVHY.js +0 -2
- package/dist/verdicts-PVB7TV5S.js +0 -2
- package/dist/walk-session-WIEROYOT.js +0 -2
- package/dist/with-telemetry-T2PWI5CY.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as V}from"./chunk-RTVWQK7I.js";import{a as j,f as q}from"./chunk-
|
|
2
|
+
import{a as V}from"./chunk-RTVWQK7I.js";import{a as j,f as q}from"./chunk-TOOJTCON.js";import{c as H,e as A,g as P}from"./chunk-4KCYNP2K.js";import{c as _}from"./chunk-XDAHKZ4J.js";import{a as O}from"./chunk-VZJ6LUXX.js";import{n as L}from"./chunk-WZ3FE5MT.js";import{c as h}from"./chunk-BWXLZS5O.js";import{a as I}from"./chunk-GFLB2SHW.js";import{M as S}from"./chunk-5EAJO372.js";import{o as D}from"./chunk-HYJVYYAZ.js";function F(e,n){try{let s=e.sessions().peek(n);return!s||!L(s,e.sessions().hasBase(n))?!1:(e.sessions().resume(n).complete({ended:"failed",code:"SESSION_KEPT_NOTHING"}),!0)}catch{return!1}}var J=e=>e!==null?{fixCmd:e}:{};function Q(e,n){return e.recordsSince(null).flatMap(o=>{let r=o.design_phase?.phase;return o.sid===n&&typeof r=="string"&&_[r]?[_[r]]:[]}).at(-1)}function X(e,n,s){return e.recordsSince(s).some(o=>o.sid!==n||!o.design_of?!1:o.design_phase?.phase==="tests"||o.nodes.some(r=>r.label==="test"))}async function le(e,n,s){let o=n.enterNested?.("opening the design\u2026")??(()=>{});try{return await Z(e,n,s)}finally{o()}}async function Z(e,n,s){let{force:o=!1,verb:r="design",childSession:d}=e,i=e.resume===!0?d:void 0;if(e.resume===!0&&i===void 0)return n.note("design child not resumed \u2014 a resume needs the child's session"),n.endUnstartedTurn(),2;if(i!==void 0&&F(s.store,i.id))return n.note(`design child ${i.id} kept nothing to resume \u2014 its agent never started; its offer opens again`),n.endUnstartedTurn(),2;let f=(()=>{if(i===void 0)return e.ucRef;try{return s.store.sessions().peek(i.id)?.use_case??e.ucRef}catch{return e.ucRef}})(),y=!1;if(i===void 0)try{let t=H(S(s.store),f);if(!t.ok&&(t.code==="UC_UNREVIEWED"||t.code==="UC_ARCHIVED")){let l=e.confirmUnreviewed??(C=>P(m=>n.ask(m),C)),a=!A(t);if(a||!await l(t))return n.note(t.reviewCmd!==void 0?`design child refused \u2014 approve it first: ${t.reviewCmd}`:"design child refused \u2014 approve it first"),n.endUnstartedTurn(),e.onEnded?.(a?"refused":"declined",a?{code:t.code}:void 0),2;y=!0}}catch{y=!1}let p=(()=>{try{let t=S(s.store),l=t.resolve(f);return(l?t.getNode(l.tip)?.content?.title:void 0)??f}catch{return f}})(),c=d?.id??i?.id,E=i?null:s.store.head(),B=i&&c!==void 0?Q(s.store,c):void 0,W=h(n.state.turns).entries.length,R=()=>h(n.state.turns).entries.filter(t=>t.kind==="test").length,$=R(),T=n.state.credits?.total,K=Date.now();n.ledger({kind:"childOpen",verb:r,subject:p,...d?{sid:d.id}:{},...i?{resumed:!0}:{},...e.replaces?{replaces:e.replaces}:{},...B?{landed:B}:{},...e.evolution?{update:!0}:{},...e.evolution?.changed?{changed:!0}:{}});let M=t=>{let l=Math.max(1,Math.round((Date.now()-K)/1e3)),a=h(n.state.turns).entries.length-W,C=R()-$,m=n.state.credits?.total,w=m!==void 0&&T!==void 0?m-T:m,U=e.evolution!==void 0&&t===0&&c!==void 0&&!s.store.recordsSince(E).some(x=>x.sid===c),G=t===0&&c!==void 0&&!U&&!X(s.store,c,E);if(n.ledger(t===0?{kind:"childClose",verb:r,subject:p,ok:!0,durS:l,...e.evolution?{update:!0}:{},...U?{untouched:!0}:{},...G?{unfinished:!0}:{},...a>0?{results:`${a} item${a===1?"":"s"}`}:{},...C>0?{tests:C}:{},...e.evolution&&c!==void 0?{testsWritten:j(s.store.recordsSince(E).filter(x=>x.sid===c),S(s.store))}:{},...w!==void 0&&w>0?{credits:w}:{}}:{kind:"childClose",verb:r,subject:p,ok:!1,durS:l,exitCode:t,...e.evolution?{update:!0}:{},...J(i!==void 0?D().command("next.resume_child",{sid:i.id}):D().command("next.design_use_case",{use_case:f,force:o||r==="evolve"}))}),e.quietEnding)return;let z=h(n.state.turns).entries.length;n.ledger({kind:"childBack",parentVerb:"extract",context:D().text("chat.child_back",{drafts:z})})},b="",u=1,v=!1,k,g,N=d?.id,Y=(...t)=>(v=!0,s.agent(...t));try{u=await q(i?{resume:i.id,mode:"interactive"}:{useCase:f,force:o,mode:"interactive",...y?{allowUnreviewed:!0}:{},...e.statement?{agentStatement:e.statement}:{},...e.evolution?.because?{because:e.evolution.because}:{},...e.evolution?.changeDelta!==void 0?{changeDelta:e.evolution.changeDelta}:{},...e.evolution?.priorDesign!==void 0?{priorDesign:e.evolution.priorDesign}:{},...d?{sessionId:d.id,registerSession:t=>d.register(t)}:{}},{...s,emit:t=>{!v&&k===void 0&&(k=O(t)??void 0),s.emit?.(V(t,{verb:"design",...N!==void 0?{id:N}:{}}))},agent:Y,ask:t=>n.ask(t),chat:n,nested:!0,out:t=>{b=t},progress:()=>{},isTTY:!0})}catch(t){if(!(e.onHeld&&t instanceof I&&t.code==="SESSION_CLASH"))throw t;g={heldBy:t.extra?.heldBy??null},u=2}finally{let t=u===3&&n.state.status==="pausing";g?n.ledger({kind:"childClose",verb:r,subject:p,ok:!1,durS:0,held:!0}):t&&e.quietEnding||M(u),v||n.endUnstartedTurn(),v&&!t?e.onEnded?.("ran",{exit:u}):g?e.onEnded?.("refused",{code:"SESSION_CLASH"}):k?.final&&e.onEnded?.("refused",{code:k.code})}return g?(e.onHeld(g.heldBy),u):(u!==0&&b&&!e.quietEnding&&n.note(b),u)}export{Q as a,X as b,le as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{f as s}from"./chunk-ZCRZFAOT.js";import o from"fs";import h from"path";import{execSync as p}from"child_process";import{readFileSync as c}from"fs";import{createHash as f}from"crypto";import{hostname as d,platform as g,arch as m}from"os";var a=null;function u(){return a||(a=l(),a)}function l(){let i=g();if(i==="darwin")try{let n=p("ioreg -rd1 -c IOPlatformExpertDevice",{encoding:"utf-8",timeout:5e3}).match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);if(n?.[1])return n[1]}catch{}if(i==="linux")try{let r=c("/etc/machine-id","utf-8").trim();if(r)return r}catch{}let t=`${d()}:${i}:${m()}`;return f("sha256").update(t).digest("hex").slice(0,32)}var y=new Set(["org_id","user_id","plan","user_type"]);function k(i){let t={machine_id:u(),env:i};try{let r=JSON.parse(o.readFileSync(s(i),"utf8"));for(let[n,e]of Object.entries(r))y.has(n)&&typeof e=="string"&&e.length>0&&e.length<=128&&(t[n]=e)}catch{}return t}async function A(i,t){if(!t)return;let r={};if(t.org_id!==void 0&&t.org_id!==null&&(r.org_id=String(t.org_id)),t.user_id!==void 0&&t.user_id!==null&&(r.user_id=String(t.user_id)),typeof t.plan=="string"&&t.plan&&(r.plan=t.plan),typeof t.user_type=="string"&&t.user_type&&(r.user_type=t.user_type),Object.keys(r).length===0)return;let n=s(i);await o.promises.mkdir(h.dirname(n),{recursive:!0});let e=`${n}.tmp-${process.pid}`;await o.promises.writeFile(e,JSON.stringify(r),{mode:384}),await o.promises.rename(e,n)}function M(i){try{o.rmSync(s(i),{force:!0})}catch{}}export{u as a,k as b,A as c,M as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as j}from"./chunk-MUX2A37P.js";import{b as g,d as C,e as q,f as I}from"./chunk-W5HFUBXD.js";import{a as V}from"./chunk-
|
|
2
|
+
import{a as j}from"./chunk-MUX2A37P.js";import{b as g,d as C,e as q,f as I}from"./chunk-W5HFUBXD.js";import{a as V}from"./chunk-OVB5GVRB.js";import{B as k,F as S,M as R,ea as h,fa as P,v as b}from"./chunk-5EAJO372.js";import{o as v}from"./chunk-HYJVYYAZ.js";function M(t,e,s,p=g()){return{store:t,rootSid:e,locks:t.locks(e),probe:s??j(t,{...p.calls(()=>({})),readVector:(i,u,n)=>C(t,i,u,n),writeVector:(i,u,n,r)=>q(t,i,u,n,r),prefetchVectors:(i,u,n)=>I(t,i,u,n)})}}var O=new WeakMap;function B(t){let e=O.get(t);return e||O.set(t,e=g()),e}var Y=new Set(["archive"]);async function U(t,e,s,p){let i=R(t.store);if(s.v==="defer")return{outcome:"deferred"};if(e.kind==="MODIFY_HELD"){if(!e.heldPayload)return{outcome:"failed",detail:`${e.ref} carries no held payload`};let r=e.heldPayload;if(s.v==="keep_current"){if(!r.event_id)return{outcome:"failed",detail:v().text("note.held_no_event_id",{sid:r.sid})};let{commitChatTurn:o}=await import("./chat-committer-7E3TRZ6P.js"),m=o({store:t.store,graph:i,ops:[{kind:"resolve_question",questionId:`drop-held:${r.sid}:${r.tempRef}`,resolution:"deferred",eventId:r.event_id}],by:p});return m.errors?{outcome:"failed",detail:m.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"held-dropped"}),{outcome:"committed",detail:"held payload dropped (recorded) \u2014 the owner's resume will not re-present it"})}if(s.v==="approve"){let o=r.content._held??null;if(!o?.source_id||!o.source_cid||!o.anchor||!o.quote)return{outcome:"failed",detail:v().text("note.held_no_provenance",{sid:r.sid})};{let a=i.mediaOf(o.source_cid),f=b(t.store,i,o.source_cid),w=a.format==="image"?null:f?k(f):null;if(a.format!=="image"&&w===null)return{outcome:"failed",detail:v().text("note.held_no_citable_text",{sid:r.sid,source_id:o.source_id,source_cid:o.source_cid})};let $=S(a,{anchor:o.anchor,quote:o.quote},w);if($.length>0)return{outcome:"failed",detail:v().text("note.held_unverified",{sid:r.sid,errors:$.map(y=>`${y.code}: ${y.detail}`).join("; ")})}}let{commitProposal:m}=await import("./committer-L2HXEODA.js"),{_held:d,...c}=r.content,D={version:1,read_basis:i.latestHash,source:{source_id:o.source_id,source_cid:o.source_cid},use_cases:[{temp_ref:r.tempRef,title:String(c.title??r.tempRef),...c.summary!==void 0?{summary:c.summary}:{},risk:String(c.risk??"med"),cite:{anchor:o.anchor,quote:o.quote},depends_on_hint:[],matches_existing:null}]},l=await V(M(t.store,t.rootSid??`review-${process.pid}`,void 0,B(t)),{verb:"maintain",ucTargets:[],newBuCandidates:[{tempRef:r.tempRef,title:String(c.title??r.tempRef),probeText:`${String(c.title??"")} ${String(c.summary??"")}`.trim()}],sourcePins:[{source_id:o.source_id,source_cid:o.source_cid}],readBasis:i.latestHash,...r.event_id?{eventIds:[r.event_id]}:{}},a=>{let f=m({store:t.store,graph:a.graph,scope:a.scope,proposal:D,proposalId:null,verdicts:new Map([[r.tempRef,{resolution:"skipped"}]]),by:p,autoName:!0,allowStaleBasis:!0,eventIds:r.event_id?[r.event_id]:a.eventIds("maintain",1),sid:a.sid,probeHits:a.probeHits});return f.errors!==null?{errors:f.errors}:{result:f,record:f.record}}),_=l.ok&&"result"in l?l.result:{record:null,errors:l.ok?null:l.kind==="validation"?l.errors:[{code:l.kind==="contended"?l.err.code:"UNSETTLED",detail:l.kind==="contended"?`held by ${l.err.holder?.owner_sid??"another session"}`:"concurrent activity kept moving the store"}]};return _.errors?{outcome:"failed",detail:_.errors.map(a=>`${a.code}: ${a.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"held-applied"}),{outcome:"committed",detail:`held payload committed (derived) by ${p.id}`})}return{outcome:"failed",detail:`verdict ${s.v} does not apply to a MODIFY_HELD card`}}let u=i.resolve(e.ref);if(!u)return{outcome:"failed",detail:`${e.ref} names nothing in the graph`};let n=i.tipOf(u.cid);if(s.v==="archive"){if(!s.because||!s.because.trim())return{outcome:"failed",detail:"archive requires --because (a reason the record keeps)"};let r=h({store:t.store,graph:i,verdicts:new Map([[n,{resolution:"rejected",reason:s.because}]]),by:p});return r.errors?{outcome:"failed",detail:r.errors.map(o=>`${o.code}: ${o.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"archived",reason:s.because}),{outcome:"retired"})}if(s.v==="approve"){let r=h({store:t.store,graph:i,verdicts:new Map([[n,{resolution:"approved"}]]),by:p});return r.errors?{outcome:"failed",detail:r.errors.map(o=>`${o.code}: ${o.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"approved"}),{outcome:"applied"})}if(s.v==="merge"||s.v==="keep_both"){if(e.kind!=="PAIR"||!e.pair)return{outcome:"failed",detail:`${e.ref} is not a PAIR card`};let r=i.resolve(e.pair.candidate_cid);if(!r)return{outcome:"failed",detail:`pair candidate ${e.pair.candidate_ref} names nothing`};let o=i.tipOf(r.cid);if(s.v==="merge"){let d=P({store:t.store,graph:i,survivor:o,merged:n,reason:`pair merge: duplicate of ${e.pair.candidate_ref} (score ${e.pair.score})`,by:p});return d.errors?{outcome:"failed",detail:d.errors.map(c=>`${c.code}: ${c.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"pair-merged",reason:e.pair.candidate_ref}),{outcome:"committed",detail:`merged into ${e.pair.candidate_ref} \u2014 survivor stays derived`})}let m=h({store:t.store,graph:i,verdicts:new Map([[n,{resolution:"approved"}],[o,{resolution:"approved"}]]),by:p});return m.errors?{outcome:"failed",detail:m.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(t.signals?.({ref:e.ref,verdict:"pair-kept-both",reason:e.pair.candidate_ref}),{outcome:"applied",detail:"both promoted as distinct"})}return{outcome:"failed",detail:`verdict ${s.v} does not apply to a ${e.kind} card`}}export{M as a,B as b,Y as c,U as d};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as is,b as os}from"./chunk-PUNFWBRW.js";import{b as zr}from"./chunk-J3XOEMKO.js";import{a as Kr}from"./chunk-MUX2A37P.js";import{a as Vr,b as Wr,c as es,f as rs,h as ss,i as ns,j as nt,k as as,l as cs,m as ds,n as hs,o as ks,p as Es,q as $s,r as Rs,s as As}from"./chunk-3UY4WPMQ.js";import{b as Mt,c as ms}from"./chunk-VZJ6LUXX.js";import{a as ts,b as Lt,c as us,d as ls,e as gs,f as _s,g as ps,h as vs,i as ws,j as ys,m as bs,o as Bt,p as xs,q as Ss}from"./chunk-WZ3FE5MT.js";import{b as Nt,c as st,d as Jr,e as Yr,f as Qr}from"./chunk-W5HFUBXD.js";import{b as Ut,c as Zr}from"./chunk-SULRMI2J.js";import{b as Xr}from"./chunk-73ZFOJOK.js";import{a as rt}from"./chunk-OVB5GVRB.js";import{b as fs}from"./chunk-Z55KBMYV.js";import{a as jr,d as Gr,e as Pt,f as Dt,g as qr}from"./chunk-3JLEDSG5.js";import{e as Hr,h as Fr}from"./chunk-3A4KK22B.js";import{f as Mr}from"./chunk-CB344EDO.js";import{a as tt}from"./chunk-FNUGDPTS.js";import{b as Br}from"./chunk-GBQ4K25P.js";import{i as Ur,m as Lr}from"./chunk-C3DMMAFP.js";import{a as Pr,e as Dr,f as Nr}from"./chunk-ZHWU6L2G.js";import{a as Tr}from"./chunk-W5EDS4DF.js";import{a as Cr}from"./chunk-XB6BJPDL.js";import{b as Or}from"./chunk-ZCIWQHCO.js";import{$ as Ue,B as Tt,M as Y,da as Ot,v as Ne,w as Ir}from"./chunk-5EAJO372.js";import{c as et,n as Ar}from"./chunk-DBMW3VUN.js";import{f as xe}from"./chunk-KU3YHPWZ.js";import{b as Rr}from"./chunk-7V4BQSSV.js";import{b as Er,d as Ze,f as Ct,h as $r}from"./chunk-G4K3TP2I.js";import{c as It,o as kr}from"./chunk-HYJVYYAZ.js";import{randomBytes as cn}from"crypto";import{appendFileSync as dn,mkdirSync as un}from"fs";import{dirname as ln,extname as mn}from"path";var it="toc",rn=256*1024,Is=200,Le={read:"source_read",edges:"graph_get_edges"},jt=40;function Ts(t,e,h){if(t===void 0)return{code:"TABLE_INDEX_MISSING",detail:"its unit index is not in the blob store"};if(t===null)return{code:"TABLE_INDEX_INVALID",detail:"the blob its fact names as its unit index is not a unit index"};if(t.plugin!==e.id||t.rules!==e.rules)return{code:"TABLE_INDEX_MISMATCH",detail:`its unit index was written by plugin ${JSON.stringify(t.plugin)} under rules ${JSON.stringify(t.rules)}, not by ${JSON.stringify(e.id)} under rules ${JSON.stringify(e.rules)} as its fact says`};let d=a=>Array.isArray(a)&&a.length===2&&Number.isInteger(a[0])&&Number.isInteger(a[1])&&a[0]>=1&&a[0]<=a[1]&&a[1]<=h;for(let a of t.units)if(!(a.lines!==void 0?[a.lines]:Array.isArray(a.segments)?a.segments:[null]).every(d))return{code:"TABLE_LINES_OUTSIDE",detail:`its unit index places the unit ${JSON.stringify(a.id)} at lines the text of ${h} lines does not have`};return t.units.some(a=>a.id!==et&&a.lines!==void 0)?null:{code:"TABLE_NO_UNITS",detail:"its unit index lists no unit, so there is nothing to make a table of"}}var Gt=([t,e])=>`L${t}-L${e}`,Ht=t=>Buffer.byteLength(t,"utf8"),Ft=t=>Pr(t)?.replace(/\|/g,"/")??null;function Cs(t,e){let h=Ft(t.ref??t.id)??Ft(t.id)??"?",d=e==="none"?null:Ft(t.label),a=d===null?null:e==="cut"&&d.length>jt?`${d.slice(0,jt)}\u2026`:d;return`${Gt(t.lines)} | ${h}${a===null?"":` | ${a}`}`}function sn(t,e){for(let a of["whole","cut","none"]){let l=t.map(y=>Cs(y,a));if(Ht(l.join(`
|
|
3
|
+
`))<=e)return{lines:l,labels:a,listed:t.length}}let h=[],d=0;for(let a of t){let l=Cs(a,"none");if(d+Ht(l)+1>e-200)break;h.push(l),d+=Ht(l)+1}return{lines:h,labels:"none",listed:h.length}}function Os(t){let e=t.index.units.filter(l=>l.id!==et&&l.lines!==void 0),h=t.index.units.find(l=>l.id===et),d=sn(e,t.budget??rn),a=[`TABLE OF CONTENTS of ${t.sourceId} (written by kane; it is not the source's text)`,`version ${t.versionCid}`,`This source is too large to send whole: ${t.lines} lines in ${e.length} ${e.length===1?"unit":"units"}. Its text is NOT below.`,`To read it, call ${Le.read} with source_id "${t.sourceId}" and line_range [first, last], at most ${Is} lines a call. Cite only lines you have read: the anchor is L<first>-L<last> and the quote is copied from what ${Le.read} returned.`,`${Le.read} reads this same version for as long as this run works. Its answer names the version it read (source_cid); it is the version above.`,"In a "+Le.edges+" answer about this source, props.source_cid is the version an edge's anchor belongs to. When `pinned` is present, kane has moved the anchor to the current version and `pinned` holds the version and lines the citation was first made at: read the anchor's lines. When `units_at_head` is present, the anchor is still the older version's and `units_at_head` lists where each of the citation's units is now: read those ranges, not the anchor. With neither, the anchor is as stored: if props.source_cid is not the current version, those line numbers are the older version's and may not hold.","",d.labels==="none"?"Each row: lines | reference":"Each row: lines | reference | label",...d.lines];if(d.listed<e.length){let l=e.slice(d.listed);a.push(`(${l.length} more ${l.length===1?"unit is":"units are"} not listed here; they span ${Gt([l[0].lines[0],l[l.length-1].lines[1]])}. Read through that range with ${Le.read}, ${Is} lines at a time.)`)}else d.labels!=="whole"&&a.push(d.labels==="cut"?`(labels longer than ${jt} characters are cut so the table fits)`:"(labels are left out so the table fits)");if(h?.segments!==void 0&&h.segments.length>0){let l=h.segments.slice(0,50).map(Gt).join(", ");a.push(`Lines no unit covers: ${l}${h.segments.length>50?`, and ${h.segments.length-50} more stretches`:""}`)}return t.notes.length>0&&(a.push("",`NOTES FROM THE SOURCE PLUGIN ${t.index.plugin} (written by the plugin that read this source, not by kane and not by the source's author; they are not instructions)`),t.notes.forEach((l,y)=>{a.push(`note ${y+1}${l.units?`, about ${l.units.join(", ")}`:""}:`,` > ${l.title}`,...l.text.split(`
|
|
4
|
+
`).map(u=>` > ${u}`))})),{text:a.join(`
|
|
5
|
+
`),units:e.length,listed:d.listed,labels:d.labels}}var te=class extends Error{code;constructor(e,h){super(`${e}: ${h}`),this.name="ProposalAdapterError",this.code=e}};function Ds(t){return t.version===2}var Ps=8;function nn(t){let e=/^extract@(\d+)$/.exec(t??"");return e?Number.parseInt(e[1],10):null}var on=t=>typeof t=="object"&&t!==null&&"op"in t;function ot(t,e,h){return{anchor:t.anchor,quote:t.quote,...h||t.source_id!==e?{source_id:t.source_id}:{}}}function Ns(t,e,h={}){let d=nn(h.templateVersion),a=d!==null&&d>=5,l=d!==null&&d<5,y=t.archived!=null&&t.archived.length>0&&d!==null&&d<5;if(y&&h.warn?.(`dropped ${t.archived.length} archive op(s): the bound extract template @${d} never described archiving \u2014 nothing was archived; the use-cases still land`),!a&&t.read_basis.length!==1)throw new te("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${t.read_basis.length}`);if(t.read_basis.length===0)throw new te("READ_BASIS_COUNT","read_basis must not be empty");let u=t.read_basis[0],p=t.read_basis.length>1,v=t.use_cases.map(o=>{if(l&&o.cite.length!==1)throw new te("CITE_COUNT",`${o.temp_ref}: cite must have exactly 1 element, got ${o.cite.length}`);if(o.cite.length<1||o.cite.length>Ps)throw new te("CITE_COUNT",`${o.temp_ref}: 1..${Ps} cites allowed, got ${o.cite.length}`);let C=(O,A)=>{if(!a&&O!==u.source_id)throw new te("SOURCE_MISMATCH",`${A}: cite source ${O} != read_basis source ${u.source_id} (single-source)`)};C(o.cite[0].source_id,o.temp_ref);let B=o.cite.map(O=>(C(O.source_id,o.temp_ref),ot(O,u.source_id,a&&(p||O.source_id!==u.source_id)))),q=(o.updated?.criteria??[]).some(on);if(!a&&q)throw new te("CRITERIA_OPS_UNSUPPORTED",`${o.temp_ref}: op-union updated.criteria (keep/set/remove) needs an extract@5+ binding \u2014 this session is bound to ${h.templateVersion??"an unversioned template"}`);return{temp_ref:o.temp_ref,title:o.title,...o.description!==void 0?{description:o.description}:{},...o.summary!==void 0?{summary:o.summary}:{},...o.actors!==void 0?{actors:o.actors}:{},...o.value!==void 0?{value:o.value}:{},risk:o.risk,cite:B[0],...B.length>1?{cites:B}:{},...o.criteria!=null&&o.criteria.length>0?{criteria:o.criteria.map((O,A)=>(C(O.cite.source_id,`${o.temp_ref}.criteria[${A}]`),{text:O.text,cite:ot(O.cite,u.source_id,a&&O.cite.source_id!==u.source_id)}))}:{},depends_on_hint:o.depends_on_hint,matches_existing:o.matches_existing,...o.conflicts_with!=null?{conflicts_with:o.conflicts_with}:{},...o.changed?{changed:!0}:{},...o.updated!=null?{updated:{...o.updated.title!=null?{title:o.updated.title}:{},...o.updated.description!=null?{description:o.updated.description}:{},...o.updated.summary!=null?{summary:o.updated.summary}:{},...o.updated.actors!=null?{actors:o.updated.actors}:{},...o.updated.value!=null?{value:o.updated.value}:{},...o.updated.risk!=null?{risk:o.updated.risk}:{},...o.updated.criteria!=null?{criteria:q?o.updated.criteria.map(O=>O.op==="set"?{op:"set",text:O.text,cite:ot(O.cite,u.source_id,a&&O.cite.source_id!==u.source_id)}:O.op==="keep"?{op:"keep",ref:O.ref,text:O.text}:{op:"remove",ref:O.ref,text:O.text,reason:O.reason}):o.updated.criteria.map((O,A)=>(C(O.cite.source_id,`${o.temp_ref}.updated.criteria[${A}]`),{text:O.text,cite:ot(O.cite,u.source_id,a&&O.cite.source_id!==u.source_id)}))}:{}}}:{},...o.change_note!=null?{change_note:o.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:u.source_id,source_cid:u.source_cid},use_cases:v,...p?{sources:t.read_basis.map(o=>({source_id:o.source_id,source_cid:o.source_cid}))}:{},...t.extraction_of!=null&&t.extraction_of.length>0?{extraction_claims:t.extraction_of.map(o=>({source_id:o.source_id,completeness:o.completeness}))}:{},...t.archived!=null&&t.archived.length>0&&!y?{archived:t.archived.map(o=>({target:o.target,reason:o.reason,basis:o.basis}))}:{}}}var qt=new Map;function Us(t,e){return qt.set(t,{parked:e}),()=>{qt.delete(t)}}function Ls(t,e){if(!(!t||!e||e.owner_sid!==t.sid||e.pid!==process.pid||!e.alive))return qt.get(t.sid)}function Ms(t){let{store:e,graph:h}=t,d=t.maxDigestBytes??4096,a={},l=[];for(let[p,v]of h.heads){if(a[p]=v,typeof v!="string")continue;let o=h.mediaOf(v),C=h.getNode(v)?.content?.blob;if(typeof C=="string")if(o.format==="image")l.push({source_id:p,cid:v,format:"image",blobRef:{path:e.blobPath(C),cid:C}});else{let B=Ne(e,h,v)?.toString("utf8")??"";l.push({source_id:p,cid:v,format:o.format,text:B})}}l.sort((p,v)=>p.source_id<v.source_id?-1:1);let y=[];for(let p of h.byLabel(xe.STYLENOTE).sort((v,o)=>v.cid<o.cid?-1:1))h.superseded.has(p.cid)||y.push(`\u2022 ${String(p.content.statement)} [${String(p.content.learned_from_kind)}]`);let u="";for(let p of y){if(Buffer.byteLength(u+p+`
|
|
6
|
+
`,"utf8")>d)break;u+=p+`
|
|
7
|
+
`}return{read_basis:a,sources:l,styleNoteDigest:u}}function Bs(t,e){let h=Ms({store:t,graph:e}).styleNoteDigest;return h.length>0?h:void 0}function Vt(t,e,h,d={}){let{reservedEventIds:a,probe:l,runAuth:y}=d,u=null,p=()=>u??=y&&Object.keys(y).length>0?Promise.resolve(y):Mr(h).catch(()=>({}));return{store:t,rootSid:e,locks:t.locks(e),probe:l??Kr(t,{...(d.similarity??Nt()).calls(async()=>({env:process.env,auth:await p()})),readVector:(v,o,C)=>Jr(t,v,o,C),writeVector:(v,o,C,B)=>Yr(t,v,o,C,B),prefetchVectors:(v,o,C)=>Qr(t,v,o,C)}),...a?.length?{reservedEventIds:a}:{}}}function hn(t,e){let h=(t.images??[]).filter(d=>d.delivery==="selected");if(h.length!==0)return h.map(d=>({ref:d.ref,...d.page!==void 0?{page:d.page}:{},...d.loc!==void 0?{loc:d.loc}:{},media_type:d.media_type,blob_ref:{path:e.blobPath(d.blob),cid:d.blob}}))}function at(t){return t.toISOString().replace(/[-:]/g,"").slice(0,15)}function Hs(t,e){return`ext-${at(t)}-${cn(4).toString("hex")}-${gn(e)}`}function fn(t,e,h){let d=`${e}-${h}`,a=d;for(let l=2;t.proposals().read(a)!==null;l+=1)a=`${d}-${l}`;return a}function gn(t){return t.startsWith("su-conv-")?`conv-${Rr(Buffer.from(t,"utf8")).slice(0,8)}`:t}function Xs(t){return t.source_id.startsWith("su-conv-")?"the conversation":t.source_id}function _n(t,e,h){return`reading ${Xs(t)}${h>1?` (source ${e} of ${h})`:""}`}function Me(t){return t.toLowerCase().trim().replace(/\s+/g," ")}function Fs(t,e){let h=new Map,d=new Map,a=new Map;for(let{cid:y,content:u}of e.byLabel(xe.USECASE)){if(e.superseded.has(y))continue;(e.trust.get(y)==="archived"?a:d).set(Me(String(u.title??"")),y)}let l=y=>e.trust.get(y)==="archived"?{cid:y,archived:!0,reason:e.archivedReason.get(y)}:{cid:y};for(let y of t.use_cases){if(y.matches_existing){let v=y.matches_existing.cid;if(e.superseded.has(v)){let o=e.tipOf(v);v=e.superseded.has(o)?null:o}if(v!==null){h.set(y.temp_ref,l(v));continue}}let u=d.get(Me(y.title));if(u){h.set(y.temp_ref,{cid:u});continue}let p=a.get(Me(y.title));p&&h.set(y.temp_ref,l(p))}return h}var js=/^(\S+)\.criteria\[(\d+)\]/;function pn(t,e,h){if(e.length===0||!e.every(a=>js.test(a.detail)))return!1;let d=new Map;for(let a of e){let l=js.exec(a.detail),y=d.get(l[1])??new Set;y.add(Number(l[2])),d.set(l[1],y)}for(let a of t.use_cases){let l=d.get(a.temp_ref);l?.size&&(a.criteria=(a.criteria??[]).filter((y,u)=>!l.has(u)),h(`${a.temp_ref}: dropped ${l.size} criteria with unverifiable cites \u2014 committed without them (criteria are hints, not oracles)`))}return!0}async function Wt(t,e,h,d,a=()=>{},l,y){let u=(p,v)=>a(p,v,t.session_id);return ns(t,e,h,d,a,{async onProposalEvent(p){let v=p,o=null,C=null,B=!1;if(Ds(v))try{o=Ns(v,t.read_basis,{templateVersion:y?.()??null,warn:q=>{e.out(`warning: ${q}`),u("adapter",{warn:q})}}),u("adapter",{ok:!0,use_cases:o.use_cases.length})}catch(q){B=q instanceof te,C=B?q.message:String(q),u("adapter",{ok:!1,error:C})}else o=v;if(o&&t.source.kind===it&&o.extraction_claims==null&&(o.extraction_claims=[{source_id:t.source.source_id,completeness:"partial"}]),o&&o.use_cases.length===0&&(e.out("warning: the agent proposed ZERO use-cases for this source"),e.emit?.({type:"warning",code:"ZERO_USE_CASES",message:"the agent proposed ZERO use-cases for this source"})),l&&o){let q=await l(o);if(q!==null)return{proposal:null,error:q,fatal:!0}}else if(l&&C&&B){let q=await l({refused:C});if(q!==null)return{proposal:null,error:q,fatal:!0};C=null}else if(l&&C)return{proposal:null,error:C,fatal:!0};return{proposal:o,error:C}}})}function Gs(t,e){let h=new Map;for(let{cid:a,content:l}of e.byLabel(xe.USECASE))e.superseded.has(a)||h.set(Me(String(l.title??"")),a);let d=[];for(let a of t.use_cases){let l=null;if(a.matches_existing?.cid&&e.hasNode(a.matches_existing.cid)){let y=e.tipOf(a.matches_existing.cid);l=e.superseded.has(y)?null:y}l=l??h.get(Me(a.title))??null,l&&d.push({ref:a.temp_ref,cid:l,...e.displayNameOf(l)?{id:e.displayNameOf(l)}:{}})}return d}function vn(t,e,h){let d=new Set(e),a=t.map(l=>d.has(l.cid)?{...l,own:!0}:l);return{own:Math.min(h,a.filter(l=>"own"in l).length),marked:a}}var wn=new Set(["agent","ci","override"]),qs=3;async function Ci(t,e){let d=(t.mode==="override"||t.mode==="ci")&&!t.plan&&!t.posture&&e.emit!==void 0?is(e.store):null,a=await yn(t,e);if(d!==null)try{e.emit({type:"extract_use_cases",use_cases:os(e.store,d)})}catch{}return a}async function yn(t,e){let h=u=>e.emit?.(u);if(t.sessionId!==void 0){let u=$r(e.store.sessions(),t.sessionId,t.resume);if(u!==null){let p=`error: the session id given for this run is refused: ${u}`;return e.out(p),h({type:"error",message:p,code:"SESSION_ID_REFUSED",final:!0}),2}}let d=`ext-${at(e.now?.()??new Date)}-lk${Math.random().toString(36).slice(2,8)}`,l=e.store.locks(d,e.now?{now:e.now}:void 0).tryAcquire([{kind:"extract"}],{hold:"session",verb:"extract"});if("contended"in l){let u=l.contended.holder,p=Ls(t.underLock,u);if(p?.parked())return Ws(t,e);if(p){let o="this chat's own extraction is still working \u2014 review the changes once it is waiting for you";return e.out(o),h({type:"error",message:o,code:"EXTRACT_LOCKED",final:!1}),2}let v=`another extraction is running on this context${u?` (pid ${u.pid})`:""} \u2014 retry when it finishes`;return e.out(v),h({type:"error",message:v,code:"EXTRACT_LOCKED",final:!1}),2}let y=Us(d,()=>e.chat?.state.status==="idle");e.onExtractLock?.({sid:d});try{return await Ws(t,e)}finally{y(),e.onExtractLock?.(null),l.release()}}function Vs(t,e,h){let d=(a,l,y)=>(h.out(a),h.emit?.({type:"error",message:l,code:y,final:!0}),!0);if(t.trust==="hold"){let a="error: --trust hold has no meaning here \u2014 a reconcile IS the review; drop the flag";return d(`${a} [TRUST_USAGE]`,a,"TRUST_USAGE")}if(e==="ci"){let a="reconcile posture is not available under --mode ci \u2014 a held changeset needs a durable session; use --mode agent";return d(`error: ${a}`,a,"POSTURE_USAGE")}if(t.withSource){let a="error: a reconcile review covers one source; --with-source cannot join another to it";return d(a,a,"POSTURE_ONE_SOURCE")}return!1}async function Ws(t,e){let h=ds(e.emit);e={...e,emit:h.emit,similarity:e.similarity??Nt()};let d=i=>e.emit?.(i),a=()=>h.failed(),l=!1,y=()=>l?cs:{ended:"complete"},u=kr(),p=t.mode??"interactive";if(t.posture==="reconcile"){if(Vs(t,p,e))return 2;if(!t.source||!t.changeContext){let i="reconcile posture needs a pinned source and its change context \u2014 internal wiring fault";return e.out(`error: ${i}`),d({type:"error",message:i,code:"POSTURE_USAGE",final:!0}),2}}if(t.trust==="hold"&&p==="interactive")return e.out("error: --trust hold only applies to headless runs \u2014 in interactive chat you review items in-session anyway; use --mode agent to hold everything for review"),d({type:"error",message:"error: --trust hold only applies to headless runs \u2014 use --mode agent",code:"TRUST_USAGE",final:!0}),2;if(p==="interactive"){if(!e.isTTY)return e.out("extract: --mode interactive needs a TTY (use --mode agent|ci|override headless)"),2}else if(!wn.has(p))return e.out(`extract: unknown mode "${p}" \u2014 interactive | agent | ci | override`),2;if(t.trust!==void 0){if(p==="ci")return e.out("error: --trust is not available under --mode ci (ci is fail-closed \u2014 no trust dials)"),d({type:"error",message:"error: --trust is not available under --mode ci",code:"TRUST_UNDER_CI",final:!0}),2;if(t.trust!=="auto"&&t.trust!=="hold")return e.out(`error: --trust must be auto | hold, got '${t.trust}'`),d({type:"error",message:`error: --trust must be auto | hold, got '${t.trust}'`,code:"TRUST_USAGE",final:!0}),2}let v=e.telemetry?.enabled?e.telemetry:void 0,o=at(e.now?.()??new Date),C=Vr({telemetryIds:v?.ids,provider:e.tracePath,verb:"extract",storeLocalPath:e.store.logFile(`extract-${o}.log`)}),B=Wr(C,es);C&&un(ln(C),{recursive:!0});let q=`run-${o}-${Math.random().toString(36).slice(2,8)}`,O=i=>i==="error"||i==="failed_proposal"?"error":i==="repair_respawn"?"warn":"info",A=(i,f,k)=>{if(C)try{dn(C,JSON.stringify({ts:new Date().toISOString(),level:O(i),run_id:q,...v?{user_session_id:v.ids.session_id}:{},...k?{session_id:k}:{},kind:i,data:f})+`
|
|
8
|
+
`)}catch{}v?.wireTrace(i,f,k)};{let i=e.out;e.out=f=>{A("transcript",{line:f}),i(f)}}e.chat||e.out(`trace: ${B}`),e.emit?.({type:"run_start",mode:p,trace:C,...v?{session:v.ids.session_id}:{}});let Xt=Br();if(Xt&&e.out(Xt),e.preflightTurn){let i=await e.preflightTurn();if(A("preflight",i),!i.ok)return e.out(i.message??"error: turn-endpoint preflight failed"),d({type:"error",message:i.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT",final:i.final===!0}),2}let le=Y(e.store);e.store.prefetch(Cr(le),{token:null});let zt=Bs(e.store,le),_e=t.sources?.length?t.sources:t.source?[t.source]:[];if(_e.length>0){if(t.resume){let i="error: --source cannot be combined with --resume (the resumed session already has its scope)";return e.out(i),d({type:"error",message:i,code:"SOURCE_WITH_RESUME",final:!0}),2}for(let i of _e){let f=le.heads.get(i);if(typeof f!="string"){let k=f===null?`error: --source ${i} was ingested but is retired \u2014 re-ingest it to extract again`:`error: --source ${i} is not an ingested source (kane-cli context list shows them)`;return e.out(k),d({type:"error",message:k,code:"SOURCE_UNKNOWN",final:!0}),2}}}let m=null,I=null,ct=[],re=[],dt=0;if(t.resume){try{{let s=await Ss(e.store,t.resume,le,{verb:"extract",deps:{onWarn:_=>e.out(`note: ${_}`),ownActors:xs(e.by)}});{let _=Object.keys(s.handle.state.read_basis??{});if(_.length>1){let D=u.text("MULTI_SOURCE_RESUME",{sid:t.resume,sources:_.length});return e.out(D),d({type:"error",message:D,code:"MULTI_SOURCE_RESUME",final:!0}),s.handle.release(),2}I=s,A("resume_kind",{kind:s.view.pointer===null?"bare-base":s.view.pointer.at==="final"?"pause":"crash"}),dt=s.view.agent?.usage_total?.credits??0,e.chat?.creditsSoFar?.(dt),m={handle:s.handle,represent:s.represent,questions:s.questions,staleBasis:s.drift.map(D=>D.subject)}}}}catch(s){let _=s instanceof Error?s.message:String(s);return e.out(`error: ${_}`),s instanceof Bt||s instanceof Er?d({type:"error",message:`error: ${_}`,code:s.code,final:ms(s.code)}):e.emit?.({type:"error",message:`error: ${_}`}),s instanceof Bt?2:1}let i=I?null:ts(m.handle.state.verb,"extract",t.resume);if(i)return e.out(i.message),d({type:"error",message:i.message,code:i.code,final:!0}),m.handle.release(),2;let f=m.handle.state.change_basis;if(f&&(le.heads.get(f.source_id)??null)!==f.new_head){let s=u.text("CHANGE_BASIS_MOVED",{source_id:f.source_id,sid:t.resume});return e.out(s),d({type:"error",message:s,code:"CHANGE_BASIS_MOVED",final:!0}),m.handle.release(),2}let k=m.handle.state;if((k.posture==="reconcile"||k.reconcile!=null)&&t.posture!=="reconcile"){let s=m.handle,_=(pe,P,ce=!0)=>(e.out(pe),d({type:"error",message:pe,code:P,final:ce}),s.release(),2);if(p==="interactive"&&!t.plan&&e.chat)return _(u.text("POSTURE_IN_CHAT",{sid:t.resume}),"POSTURE_IN_CHAT");if(Vs(t,p,e))return s.release(),2;if(!f)return _(`error: session ${t.resume} is a reconcile review with no change basis to resume against`,"POSTURE_USAGE");let D=zr(e.store,f.source_id,t.changeSince?{since:t.changeSince}:{});if(D.kind==="unchanged")return _(`error: session ${t.resume} reconciles ${f.source_id}, and no use case of it is behind its current version, which has been read`,"POSTURE_USAGE");if(D.kind==="first")return _(`error: session ${t.resume} was a reconcile of ${f.source_id}, which has no earlier version to reconcile against`,"POSTURE_USAGE");if(D.kind==="unreadable")return _(`error: session ${t.resume} reconciles ${f.source_id}, but its version ${D.version} cannot be read`,"SOURCE_UNREADABLE",!1);t={...t,posture:"reconcile",changeContext:D.changeContext}}if(I&&I.view.pointer!==null&&I.drift.length>0){if(!await e.confirmStale(`changed since the pause: ${I.drift.map(_=>_.subject).join(", ")} \u2014 re-ground and continue against the current versions?`)){let _=`resume aborted: the context moved since the pause (${I.drift.map(D=>D.subject).join(", ")}) \u2014 session ${t.resume} is preserved`;return e.out(_),d({type:"error",message:_,code:"RESUME_DRIFT",final:!0}),m.handle.release(),2}}else m.staleBasis.length>0&&e.out(`note: changed since the pause: ${m.staleBasis.join(", ")} \u2014 re-presented items may be stale`);let L=[...new Set([...m.handle.state.held_receipts??[],...I?.view.kane?.held_receipts??[]])];L.length>0&&(e.chat?.holdReceipt?ct=L:e={...e,initialMessage:[L.join(`
|
|
9
|
+
|
|
10
|
+
`),e.initialMessage].filter(Boolean).join(`
|
|
11
|
+
|
|
12
|
+
`)});let x=m.handle.state.conv_source||I?.base.conv_source;if(I&&x){let s=I.view.kane?I.view.kane.store_watermark:I.base.store_watermark;if(re=Hr(e.store,x,s,I.view.agent?.delta_items??[],I.view.kane?.sent_unread??[]),re.length>0){let _=ys(re.length);e.chat?e.chat.note(_):e.out(_)}}m.handle.state.assumed.length>0&&e.out(u.text("note.assumed_defaults",{sid:m.handle.state.sid,count:m.handle.state.assumed.length}))}let Kt=le.extractedSourceCids,Se=!!(t.force||m?.handle.state.force),oe=[],me=[],Be=_e.length>0?new Set(_e):null,ke=e.note??e.out;for(let[i,f]of le.heads.entries())if(f!=null&&!(Be&&!Be.has(i))){if(!Be&&!m&&i.startsWith("su-conv-")){ke(u.text("note.conversation_source_skipped",{source_id:i})),me.push({source_id:i,reason:"conversation"});continue}if(m){let k=i in m.handle.state.read_basis,L=m.handle.state.corpus_cursor.remaining.includes(i);if(!k&&!L)continue;if(L&&!Se&&Kt.has(f)){ke(u.text("note.already_extracted",{source_id:i})),me.push({source_id:i,reason:"cached"});continue}}else if(!Se&&Kt.has(f)){ke(u.text("note.already_extracted",{source_id:i})),me.push({source_id:i,reason:"cached"});continue}oe.push({source_id:i,cid:f})}let zs=i=>{let f=e.pendingReconcilePlan?.(i)??null;f&&ke(u.text("note.reconcile_plan_pending",{source_id:i,pending:f.pending,path:f.path}))};for(let i of me)i.reason==="cached"&&zs(i.source_id);if(e.emit?.({type:"corpus",sources:oe,skipped:me}),oe.length===0){if(m){let f=Object.keys(m.handle.state.read_basis),k=u.text("SOURCE_MISSING",{sid:m.handle.state.sid,sources:f.join(", ")||"unknown"});return e.out(k),d({type:"error",message:k,code:"SOURCE_MISSING",final:!0}),m.handle.release(),2}let i=me.length>0&&me.every(f=>f.reason==="conversation");return ke(Be?u.text("note.nothing_to_extract",{sources:_e.join(", "),count:_e.length}):i?u.text("note.only_conversation_sources",{}):u.text("note.all_extracted",{})),0}let Q=!t.plan&&p!=="ci",He=e.now?.()??new Date,Ee=t.resume??t.sessionId??Hs(He,oe[0].source_id),j=null,Fe=!1;Q&&!m&&(t.registerSession&&await t.registerSession(Ee),j=e.store.sessions().create({sid:Ee,mode:"agent",created_at:He.toISOString(),expires_at:Ct(He),agent_state:{schema:2,items:[],provider_state:""},pending:{questions:[],proposals:[]},assumed:[],read_basis:{[oe[0].source_id]:oe[0].cid},corpus_cursor:{remaining:oe.slice(1).map(i=>i.source_id)},conv_source:"",verb:"extract",...Se?{force:!0}:{},...t.changeContext?{change_basis:{source_id:t.changeContext.source_id,new_head:t.changeContext.new_head}}:{},...t.posture==="reconcile"?{posture:"reconcile"}:{},...v?{user_session_id:v.ids.session_id}:{}}));let ut=I?I.represent.map(i=>i.event_id).filter(i=>typeof i=="string"):[],S=m?.handle??j,Jt=!1,Yt=()=>{e.store.sessions().tidy()},Qt=i=>{if(j){try{j.complete(i)}catch{j.release()}j=null,S=null,Yt()}},K=new Map;for(let i of Pt(m?.handle.state.pending.answers))K.set(i.id,i);let $e=new Set,Zt=()=>{let i=m?.handle;if($e.size===0||!i)return;let f=[...$e];$e.clear();for(let k of f)K.delete(k);i.reconcileSave({appliedEvents:f.map(k=>`resolveq:${t.resume}:${k}`),heldReceipts:i.state.held_receipts??[],pending:{...i.state.pending,answers:(i.state.pending.answers??[]).filter(k=>!f.includes(k.id))}})},je=m?m.questions.map(gs).filter(i=>!Dt(K.get(i.id),i)):[];if(m&&je.length>0&&!t.message&&!t.withSource&&!e.initialMessage&&re.length===0){e.out(`re-presenting ${je.length} unanswered question(s) from the paused session`);let i=await e.ask(je);if(!Array.isArray(i)&&"paused"in i||e.chat?.state.status==="pausing")return m.handle.release(),e.out(`session ${t.resume} paused at its question`),3;if(Array.isArray(i)){for(let f of i){let k=je.find(L=>L.id===f.id);k&&K.set(f.id,Gr(k,f))}m.handle.save({pending:{...m.handle.state.pending,answers:Pt([...K.values()])}})}}let Re=e.by??{kind:"human",id:"owner"},G=p==="interactive"&&!t.plan&&!!e.chat,se=0,er=0,Ae=!1,he=0,Ie=!1,tr=0,lt=()=>{Ae||(Ae=!0,e.similarity&&st(e.similarity,A),e.out(u.text("note.dedup_reduced",{})),e.emit?.({type:"degraded",reason:"embed_fallback"}))},Ge=null,fe=()=>S??j,mt=(i,f,k)=>{let L=fe();if(!L)return;let x=f.map(_=>({label:"usecase",content:{title:_.title,..._.summary!==void 0?{summary:_.summary}:{},..._.risk!==void 0?{risk:_.risk}:{},derived:!0,_held:{source_id:i.source_id,source_cid:i.cid,anchor:_.cite?.anchor??"L1-L1",quote:_.cite?.quote??""}},rationale:`held (${k==="degraded"?"embed degraded \u2014 lexical dedup only":"--trust hold"}): ${i.source_id} @ ${i.cid.slice(0,19)} ${_.cite?.anchor??""}`,edges:[],tempRef:_.temp_ref})),s=L.state.pending;L.save({pending:{questions:s.questions,proposals:[...s.proposals,...x]}}),he+=x.length,k==="degraded"&&(tr+=x.length),Ge=L.state.sid,e.emit?.({type:"held",source_id:i.source_id,count:x.length,reason:k==="degraded"?"embed_degraded":"trust_hold"})},ae=[],V=i=>{ae.push(i),h.recorded()},rr=!1,U=[...oe];try{let i=x=>{let s=S;if(!s)return;let _=s.state.ingest_schedule??[];if(!_.some(P=>P.status==="pending"))return;let D=Y(e.store),pe=_.map(P=>P.status!=="pending"?P:(D.heads.get(P.source_id)??null)!==P.cid?(e.out(u.text("note.landed_changed",{source_id:P.source_id})),{...P,status:"skipped",note:"head moved since landing"}):D.extractedSourceCids.has(P.cid)||U.some(N=>N.source_id===P.source_id&&N.cid===P.cid)?{...P,status:"done"}:U.some(N=>N.source_id===P.source_id)?(e.out(u.text("note.landed_older_queued",{source_id:P.source_id})),{...P,status:"skipped",note:"an older version of the source was already queued this run"}):(U.push({source_id:P.source_id,cid:P.cid}),e.out(`queued ${P.source_id} for extraction in this run (landed mid-run)`),{...P,status:"done"}));s.save({ingest_schedule:pe,corpus_cursor:{remaining:U.slice(x+1).map(P=>P.source_id)}})},f=dt,k=0,L=x=>{let s=U[x];if(!s)return;let _=ae.includes(s.source_id);v?.event("ASR_WORK_ITEM_END",{work_item_index:x,work_item_count:U.length,outcome:_?"failed":"ok",duration_ms:Date.now()-k}),v?.setRunTotals?.({credits_total:f})};for(let x=0;x<U.length;i(x),L(x),x++){let s=U[x];k=Date.now(),v?.event("ASR_WORK_ITEM_START",{work_item_index:x,work_item_count:U.length});let _=Y(e.store),D={current:_};e.chat?.attachOnCommitted?.(r=>{D.current=r});let pe=_.getNode(s.cid),P=String(pe?.content.blob??""),ce=Ne(e.store,_,s.cid);if(!ce){e.out(u.text("BLOB_MISSING",{source_id:s.source_id})),e.emit?.({type:"error",source_id:s.source_id,message:`error: ${s.source_id}: blob ${P} missing from .context/blobs`,code:"BLOB_MISSING"}),V(s.source_id);continue}let N=_.mediaOf(s.cid),qe=N.media_type.startsWith("image/");if(!qe){let r=Ir(ce);if(r){e.out(u.text("note.reingest_binary",{source_id:s.source_id,kind:r})),e.emit?.({type:"source_skipped",source_id:s.source_id,reason:"binary_pre_media"});continue}}let ht=qe?`0001| (image source ${s.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:Tt(ce),sr=ht,nr=Ur.has(N.format)?N.format:mn(s.source_id)||"md";if(!qe&&N.format==="plugin"&&N.plugin!==void 0&&Lr(s.source_id,N.format,ce)>4e5){let r=ht.split(`
|
|
13
|
+
`).length,n=N.plugin.index!==void 0?e.store.getBlob(N.plugin.index):null,c=N.plugin.index===void 0||n===null?void 0:Ar(n),g=N.plugin.index===void 0?{code:"TABLE_INDEX_MISSING",detail:"this version was stored without a unit index"}:Ts(c,N.plugin,r);if(g!==null){let F=`error: ${s.source_id} is too large to send to the agent whole (${ce.byteLength} bytes of text) and cannot be sent as a table of contents: ${g.detail} \u2014 ingest a new version of ${s.source_id} with a working ${N.plugin.id} plugin (changed bytes are read and indexed afresh); the same bytes again keep this index [${g.code}]`;e.out(F),e.emit?.({type:"error",source_id:s.source_id,message:F,code:g.code}),V(s.source_id);continue}let T=new Set(c.units.map(F=>F.id)),b=Dr(F=>e.store.getBlob(F),N.plugin);N.plugin.notes!==void 0&&b===null&&e.out(`note: the notes of ${s.source_id} could not be read and were left out of what the agent is sent`);let E=Nr(b,"extract").filter(F=>(F.units??[]).every(ge=>T.has(ge)));sr=Os({sourceId:s.source_id,versionCid:s.cid,index:c,lines:r,notes:E}).text,nr=it}let Ve=(r,n)=>{let c=new Map;c.set(s.source_id,{media:N,numberedText:ht});for(let g of n.sources??[]){if(c.has(g.source_id))continue;let T=Ne(e.store,r,g.source_cid);if(!T)continue;let b=r.mediaOf(g.source_cid),E=b.media_type.startsWith("image/")?`0001| (image source ${g.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:Tt(T);c.set(g.source_id,{media:b,numberedText:E})}return c},Ks=at(e.now?.()??new Date),ne=fn(e.store,Ks,s.source_id),J=!!(m&&s.source_id in m.handle.state.read_basis);if(I&&J&&(I.spawnConfig.source.kind===it||I.spawnConfig.source.kind==="plugin")&&I.spawnConfig.source.source_cid!==s.cid){let r=`error: ${s.source_id} has a newer version (${s.cid.slice(0,19)}) than the one this session began on (${I.spawnConfig.source.source_cid.slice(0,19)}); what the session holds is the older version's, and a resumed run would read the newer one \u2014 this session cannot go on; start a new extract of ${s.source_id}: kane-cli context extract --source ${s.source_id} [PLUGIN_VERSION_MOVED]`;e.out(r),e.emit?.({type:"error",source_id:s.source_id,message:r,code:"PLUGIN_VERSION_MOVED"}),V(s.source_id);continue}let Ce=S?Ee:Hs(e.now?.()??new Date,s.source_id);!S&&Q&&await t.remainderSession?.(Ce);let ft=U.slice(x+1).map(r=>r.source_id);S&&Q&&!J&&S.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:ft}});let de="";if(G){let r=Fr({store:e.store,graph:Y(e.store),sessionStamp:Ce,by:Re});r.errors===null||r.errors[0]?.code==="CONV_SOURCE_EXISTS"?(de=r.sourceId,e.chat.attachConversationSource?.(de),D.current=Y(e.store)):e.out(`warning: notes you add in chat can't be saved to the context this session (${r.errors[0]?.detail})`)}let ir={type:"run_config",version:1,session_id:Ce,mode:p,source:{source_id:s.source_id,source_cid:s.cid,kind:nr,numbered_text:sr,...(()=>{let r=hn(N,e.store);return r?{images:r}:{}})()},existing_use_cases:_.byLabel(xe.USECASE).filter(({cid:r})=>_.trust.get(r)!=="archived"&&!_.superseded.has(r)).map(({cid:r,content:n})=>({id:r,title:String(n.title??""),summary:String(n.summary??"")})),read_basis:D.current.latestHash,max_free_text_rounds:rs,graph_reads:!0,verb:"extract",...zt!==void 0?{style_note_digest:zt}:{},...t.changeContext&&t.changeContext.source_id===s.source_id?{change_context:t.changeContext}:{},topology:fs(),...G?{chat:!0}:{},...qe?{image_sources:[{source_id:s.source_id,source_cid:s.cid,media_type:N.media_type,blob_ref:{path:e.store.blobPath(P),cid:P}}]}:{},...m&&!I&&s.source_id in m.handle.state.read_basis?{resume:{agent_state:m.handle.state.agent_state}}:{},...Q&&S?{checkpoints:!0}:{}},$=I&&J?{...I.spawnConfig,mode:p}:ir;if(Q&&S&&!Jt){Jt=!0;let{resume:r,...n}=ir;e.store.sessions().initCheckpoints(Ee,{schema:Tr,kind:"base",sid:Ee,verb:"extract",mode:p,created_at:He.toISOString(),run_config:n,conv_source:de||S.state.conv_source||"",store_watermark:e.store.serialize(e.store.head())})}let or=I&&J?0:S?.state.checkpoint?.seq??0,Te={current:null};if($.resume&&"schema"in $.resume){let r=$.resume.binding?.template_version;typeof r=="string"&&(Te.current=r)}let ve=null,gt=Q&&S?bs({store:e.store,handle:S,seqBase:()=>or,awaits:(r,n)=>{let c=ps($.session_id,de||null,r,n);return ve=c?.event_id??null,c?.event_prefix&&e.chat?.opIdPrefix?.(c.event_prefix.slice(0,-1)),c},peekHeldReceipts:()=>e.chat?.peekHeldReceipts?.()??[],readBasis:()=>({[s.source_id]:s.cid}),corpusCursor:()=>({remaining:ft}),onSoftCap:r=>e.out(r),onStat:r=>A("ckpt_stat",r,$.session_id),...e.now?{now:e.now}:{}}):void 0,we=gt?{...gt,persist:(r,n)=>{let c=r.binding?.template_version;typeof c=="string"&&c&&(Te.current=c);let g=gt.persist(r,n);return Zt(),g}}:void 0;G||e.out(m&&s.source_id in m.handle.state.read_basis?`resuming: ${s.source_id} (session ${t.resume})`:`reading ${s.source_id} (source ${x+1} of ${U.length})`),e.emit?.({type:"source_start",source_id:s.source_id,cid:s.cid,index:x+1,total:U.length,resumed:!!(m&&s.source_id in m.handle.state.read_basis)});let _t=u.sourceName?.(s.source_id)??Xs(s),ar=u.header?.("header.extract",{source:_t,sources:U.length,index:x+1});e.chat?.ledger?.(ar?{kind:"header",...ar,source:{index:x+1,of:U.length,name:_t}}:{kind:"banner",text:_n(s,x+1,U.length)});let We=I?.view.agent?.delta_items??[],ue=J?I?.view.kane?.awaits:void 0,cr=vs(e.store,m?.handle.state.applied_events??[],ue),Js=!!ue?.event_id&&cr&&!!us(We)?.name.startsWith("finalize");if(J&&m&&!G&&t.posture!=="reconcile"&&Js&&re.length===0){i(x),m.handle.complete({ended:"complete"}),e.out(`session ${t.resume} complete`),e.emit?.({type:"session_complete",sid:t.resume,source_id:s.source_id}),m=null,S=null;continue}let dr=!!(ue&&!cr&&Lt(We));dr&&ue&&(e.out(ws(ue.call)),$.resend_last_output=!0,ve=ue.event_id??null,ue.event_prefix&&e.chat?.opIdPrefix?.(ue.event_prefix.slice(0,-1))),J&&(t.message||e.initialMessage||re.length>0)&&($.resend_open_ask=!1);let ur=J&&!t.message&&!e.initialMessage&&!dr&&re.length===0,lr=ur&&Lt(We),mr=ur&&K.size===0&&ls(We);e.chat?.setWorking?.(`Reading ${_t}\u2026`);let pt=new Map;A("spawn",{source_id:s.source_id,source_cid:s.cid,resume:!!m,chat:G},$.session_id);let vt=!1,hr=!1,wt=!1,yt=0,fr=r=>hs({source:r.source,use_cases:r.use_cases}),bt=new Map;if(J&&I)try{let r=e.store.parse(I.base.store_watermark),n=r!==null&&e.store.resolveToken(r)!==null?r:null;for(let c of e.store.recordsSince(n)){if(c.sid!==$.session_id||c.proposal_id===null)continue;let g=e.store.proposals().read(c.proposal_id);if(!g)continue;bt.set(fr(g),c);let T=G?Gs(g,Y(e.store)):[];T.length>0&&e.chat?.registerAliases?.(T)}}catch{}let gr=null,_r=r=>{let n=!e.nested&&yt<qs;if(e.emit?.({type:"validate_failed",source_id:s.source_id,codes:r.map(c=>c.split(":")[0]),repairing:n}),e.nested)return e.chat?.ledger?.({kind:"commit",ok:!1,line:u.text("chat.proposal_refused",{}),warnings:r,refused:r.map(c=>({code:c.split(":")[0]}))}),hr=!0,null;if(!n){let c=`error: the agent's proposal for ${s.source_id} still failed validation after ${qs} repairs (${r.join("; ")}) \u2014 the session ended`;return e.out(c),e.emit?.({type:"error",source_id:s.source_id,message:c,code:"REPAIR_LIMIT"}),gr=c,c}return yt+=1,e.chat.repair(`[auto-repair] the proposal failed validation: ${r.join("; ")} \u2014 please re-finalize with these fixed.`),null},pr=async r=>{if("refused"in r)return A("kane_validate",{refused:r.refused},$.session_id),_r([r.refused]);let n=r,c=ve;ve=null;let g=fr(n),T=bt.get(g);if(T){c&&fe()?.markApplied([c]),vt=!0;let R=Es(Y(e.store),T);return e.chat?.ledger?.({kind:"commit",ok:!0,line:$s("proposal",R)}),As(R)&&e.chat?.holdReceipt?.(Rs(R)),null}let b=Y(e.store),E=Ue(n,Ve(b,n),b);if(A("kane_validate",{errors:E.map(R=>R.code)},$.session_id),E.length>0)return _r(E.map(R=>`${R.code}: ${R.detail}`));let F=Y(e.store),ge=Fs(n,F);e.store.proposals().write(ne,n);let Qs=new Map(n.use_cases.map(R=>[R.temp_ref,{resolution:"skipped"}])),Zs=Vt(e.store,$.session_id,e.credentials,{reservedEventIds:ut,probe:e.probe,runAuth:e.auth,similarity:e.similarity}),en={...Ut(n,F),...c?{eventIds:[c]}:{}},Z=await rt(Zs,en,R=>{if(R.degradedProbe&&fe()!==null&&n.use_cases.some(Qe=>Qe.matches_existing==null))return{result:{degradedHold:!0},record:null};let z=Ot({store:e.store,graph:R.graph,scope:R.scope,proposal:n,proposalId:ne,verdicts:Qs,by:{kind:"ai",id:"extract-agent"},autoName:!0,allowStaleBasis:!0,eventIds:R.eventIds("extract",1),...Q?{sid:R.sid}:{},probeHits:R.probeHits,...e.matchUnreviewed?{matchUnreviewed:!0}:{}});return z.errors!==null?{errors:z.errors}:{result:z,record:z.record}});e.similarity&&st(e.similarity,A);let Rt=Z.ok&&"result"in Z?Z.result:null;if(Rt!==null&&"degradedHold"in Rt)return lt(),mt(s,n.use_cases,"degraded"),c&&fe()?.markApplied([c]),wt=!0,e.chat.ledger?.({kind:"commit",ok:!1,line:u.text("chat.held_degraded",{held:n.use_cases.length}),held:!0}),null;let ee=Rt??{record:null,errors:Z.ok?null:Z.kind==="validation"?Z.errors:[{code:Z.kind==="contended"?Z.err.code:"UNSETTLED",detail:Z.kind==="contended"?`held by ${Z.err.holder?.owner_sid??"another session"}`:"concurrent activity kept moving the store"}]};if(ee.errors)return e.chat.ledger?.({kind:"commit",ok:!1,line:u.text("chat.commit_failed",{}),warnings:ee.errors.map(R=>`${R.code}: ${R.detail}`),refused:ee.errors.map(R=>({code:R.code}))}),null;vt=!0,yt=0,ee.record&&bt.set(g,ee.record),ee.record?.event_ids?.length&&S?.markApplied(ee.record.event_ids);{let R=ee.record.review.filter(z=>z.kind==="pending_update");R.length>0&&(G||e.out(u.text("chat.updates_held",{count:R.length})),e.emit?.({type:"update_held",count:R.length,targets:R.map(z=>z.id)}),e.chat?.ledger?.({kind:"commit",ok:!0,line:u.text("chat.updates_held",{count:R.length}),held:!0,heldChanges:R.length}))}let Je=ee.record.nodes.length;se+=Je;let Ye=n.use_cases.length-Je,At=0;{let R=Y(e.store),z=vn(Gs(n,R),e.addedBefore?.()??[],Ye);z.marked.length>0&&e.chat.registerAliases?.(z.marked),At=z.own,D.current=R;let Qe=De=>{for(let[tn,Sr]of R.names)if(Sr===De&&!R.superseded.has(Sr))return tn},xr=jr({verb:"extract",commitN:1,phase:"proposal",committed:ee.record.nodes.map(De=>({cid:De.cid,...Qe(De.cid)?{logical_id:Qe(De.cid)}:{}})),reused:Ye},R);e.emit?.(xr.event),e.chat.holdReceipt?.(xr.text)}return A("commit",{derived:Je,evidence_matched:Ye,chat:!0},$.session_id),e.chat.ledger?.({kind:"commit",ok:!0,line:u.text("chat.added_use_cases",{minted:Je+At,matched:Ye-At})}),null},ye=!!(m&&s.source_id in m.handle.state.read_basis);ye&&K.size>0&&e.chat?.answersHeld([...K.values()]);let M=ye&&K.size>0?{...e,ask:async r=>{if(r.every(n=>Dt(K.get(n.id),n)&&!$e.has(n.id))){let n=r.map(c=>qr(K.get(c.id)));for(let c of r)$e.add(c.id);return e.out(`answered ${r.length} re-asked question(s) from the held resume answers`),n}return e.ask(r)}}:e;ye&&t.message&&(M={...M,initialMessage:t.message}),ye&&ct.length>0&&(M={...M,heldAtSpawn:ct}),ye&&re.length>0&&(M={...M,redeliverAtSpawn:re}),f>0&&(M={...M,creditsBefore:f}),(lr||mr)&&(M={...M,readyAtSpawn:!0,...lr&&!mr?{checkInAtSpawn:!0}:{}}),M={...M,onEmbedDegraded:lt};let be,xt;if(S){let r=S,n=M.ask,c=as({store:e.store,credentials:e.credentials,onRefusal:e.onIngestRefusal,handle:r,note:g=>e.chat?e.chat.note(g):e.out(g),schedule:t.trust!=="hold",...t.trust==="hold"?{scheduleRefused:u.text("note.schedule_refused",{})}:{},graphSlot:D,...e.now?{now:e.now}:{}});if(M={...M,ask:async g=>{let T=await n(g);if(Array.isArray(T)){let b=T.filter(E=>{if(E.free_text==null||E.free_text.trim()==="")return!1;let F=g.find(ge=>ge.id===E.id);return E.selected_index!=null&&F?.options[E.selected_index]?.input===!0}).map(E=>E.free_text.trim());if(b.length>0){let E=r.state.ingest_registry;for(let F of b)E=nt(E,F,e.now?.()??new Date);r.save({ingest_registry:E})}}return T},ingest:c},ye&&t.withSource){let g=(r.state.pending?.proposals??[]).filter(E=>E.content?._held!=null).length;if(t.trust==="hold"||g>0){let E=g>0?`error: --with-source can't add a source to a session holding ${g} item(s) for review \u2014 resume without --with-source to finish the review first, then land it with kane-cli context ingest [HOLD_MULTI_SOURCE]`:"error: --with-source is not available with --trust hold \u2014 held work from a multi-source run can't be resumed yet; drop --trust hold, or land the source separately with kane-cli context ingest [HOLD_MULTI_SOURCE]";return e.out(E),d({type:"error",code:"HOLD_MULTI_SOURCE",message:E,final:!0}),2}let T=t.withSource;r.save({ingest_registry:nt(r.state.ingest_registry,T,e.now?.()??new Date)});let b=await c({id:`withsource-${r.state.sid}`,ref:T,purpose:null});if(!b.ok)return e.out(`error: --with-source: ${b.error.message}`),d({type:"error",code:b.error.code,message:`--with-source: ${b.error.message}`,final:!1}),2;M={...M,pendingDeferral:{ingested:{source_id:b.result.source_id,cid:b.result.cid}}}}xt=()=>{if(!e.chat?.attachIngest)return;let g=e.chat;be=g.attachIngest(async T=>{try{r.save({ingest_registry:nt(r.state.ingest_registry,T,e.now?.()??new Date)});let b=await c({id:`attach-${r.state.sid}-${(r.state.ingest_registry??[]).length}`,ref:T,purpose:null});return b.ok?(g.deferBatch({source_id:b.result.source_id,cid:b.result.cid}),{ok:!0}):{ok:!1,error:b.error.message}}catch(b){return{ok:!1,error:b instanceof Error?b.message:String(b)}}})},xt()}let w;try{w=await Wt($,{...M,graphSlot:D,...we?{checkpoint:we}:{}},pt,_,A,G?pr:void 0,()=>Te.current),f=w.creditsTotal??f}catch(r){if(r instanceof tt)return be?.(),e.chat?.setWorking?.(null),e.out(`error: ${r.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:r.message}),2;throw r}if(be?.(),e.chat?.setWorking?.(null),w.errorCode==="binding_mismatch"&&I&&J){let r=await e.ask([{id:"binding-mismatch",text:"this session's saved conversation is no longer accepted by the service \u2014 start the conversation fresh (committed work is kept), or stop and keep the session?",risk:"high",rationale:"the service refused the saved conversation on the first turn after resume",options:[{label:"start fresh",detail:"continue with a fresh conversation \u2014 earlier answers may be re-asked"},{label:"stop",detail:"stop here; the session stays resumable"}],recommended_index:1,allow_free_text:!1}]);if((Array.isArray(r)?r.find(g=>g.id==="binding-mismatch"):void 0)?.selected_index!==0){let g=`resume abandoned: binding mismatch on session ${Ce} \u2014 the session is preserved`;return e.out(g),e.emit?.({type:"error",message:g,code:"BINDING_MISMATCH"}),2}A("binding_migrate",{sid:Ce},$.session_id),xt?.();let c=$.resume&&"schema"in $.resume?{...$.resume,binding:{}}:void 0;try{w=await Wt({...$,...c?{resume:c}:{}},{...M,graphSlot:D,...we?{checkpoint:we}:{}},pt,_,A,G?pr:void 0,()=>Te.current),f=w.creditsTotal??f}catch(g){if(g instanceof tt)return be?.(),e.chat?.setWorking?.(null),e.out(`error: ${g.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:g.message}),2;throw be?.(),g}be?.(),e.chat?.setWorking?.(null)}if(w.error&&w.error===gr){V(s.source_id);continue}if(w.error){let r=w.error.startsWith("proposal failed validation after repair:");r&&A("agent_error_detail",{error:w.error},$.session_id);let n=r?u.text("AGENT_FAILED.invalid_proposal",{source_id:s.source_id}):`error: agent failed for ${s.source_id}: ${w.error}`;e.out(n),e.emit?.({type:"error",source_id:s.source_id,message:n,code:w.errorCode??"AGENT_FAILED"}),V(s.source_id);continue}if(w.noDefault){let r=ss(w.noDefault,s.source_id);e.out(r),e.emit?.({type:"error",source_id:s.source_id,message:r,code:"NO_DEFAULT_ANSWER",questions:w.noDefault.map(n=>n.id)}),V(s.source_id);continue}if(w.highRisk)return e.out(`error: ${w.highRisk.length} high-risk decision${w.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),e.emit?.({type:"error",source_id:s.source_id,message:`error: high-risk question(s) in ci mode (fail-closed): ${w.highRisk.map(r=>r.id).join(", ")}`,code:"HIGH_RISK_CI"}),1;if(w.paused?.cause&&!Q){let r=`error: agent failed for ${s.source_id}: the model service did not answer (${w.paused.cause.message})`;e.out(r),e.emit?.({type:"error",source_id:s.source_id,...Mt(w.paused.cause),message:r}),V(s.source_id);continue}if(w.paused){let r=U.slice(x+1).map(E=>E.source_id),n=m?.handle??j,c=n??e.store.sessions().create({sid:$.session_id,mode:"agent",created_at:(e.now?.()??new Date).toISOString(),expires_at:Ct(e.now?.()??new Date),agent_state:w.paused.agent_state,pending:{questions:[],proposals:[]},assumed:[],read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:r},conv_source:de,verb:"extract",...Se?{force:!0}:{},...t.changeContext?{change_basis:{source_id:t.changeContext.source_id,new_head:t.changeContext.new_head}}:{},...t.posture==="reconcile"?{posture:"reconcile"}:{},...v?{user_session_id:v.ids.session_id}:{}});Fe=!0;try{de&&c.state.conv_source!==de&&c.save({conv_source:de});let E=e.chat?.drainHeldReceipts?.()??[];(E.length>0||(c.state.held_receipts?.length??0)>0)&&c.save({held_receipts:E}),n&&c.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:r},...Se&&!c.state.force?{force:!0}:{},...v&&c.state.user_session_id!==v.ids.session_id?{user_session_id:v.ids.session_id}:{}}),_s(c,w.paused,Zt)}catch(E){let F=c.state.checkpoint,ge=`error: couldn't persist the pause for session ${c.state.sid}`+(F?` \u2014 last durable checkpoint: seq ${F.seq} @ ${F.ts}`:" \u2014 no durable checkpoint exists")+` (${E instanceof Error?E.message:String(E)})`;return e.out(ge),e.emit?.({type:"error",message:ge,code:"PAUSE_PERSIST_FAILED",sid:c.state.sid}),1}A("session_paused",{sid:c.state.sid,pending:c.state.pending},$.session_id);let g={verb:"extract",sid:c.state.sid,mode:p},T=u.command("next.resume_session",g),b=w.paused.cause;if(G||e.out(b?u.text("note.model_unavailable_kept",{...g,detail:b.message}):u.text("note.paused",g)),e.emit?.({type:"session_paused",sid:c.state.sid,source_id:s.source_id,mode:p,...T!==null?{resume:T}:{},expires_at:Ze(e.store.sessions(),c.state),pending_questions:w.paused.pending.questions,...b?{cause:Mt(b)}:{}}),G){let E=e.chat?.state.credits?.total;e.onSummary?.({state:"paused",reason:b?"the model service did not answer":"ctrl+c",facts:[...b?[b.message]:[],`session ${c.state.sid} saved`+(se>0?` \u2014 ${se} use-case${se===1?"":"s"} committed so far`:""),...Ze(e.store.sessions(),c.state)?[`expires: ${c.state.expires_at}`]:[],...E!==void 0?[`credits used: ${E.toFixed(1)}`]:[]],...It(u,g),tracePath:B})}return 3}if(w.crashed){let r=S?.state.checkpoint;if(S&&r){let n={verb:"extract",sid:S.state.sid,mode:p},c=u.command("next.resume_session",n);try{S.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:ft}})}catch{}if(A("agent_crashed_resumable",{sid:S.state.sid,seq:r.seq},$.session_id),G||e.out(u.text("note.crashed",{...n,seq:r.seq})),e.emit?.({type:"session_paused",sid:S.state.sid,source_id:s.source_id,mode:p,...c!==null?{resume:c}:{},expires_at:Ze(e.store.sessions(),S.state),crashed:!0}),G){let g=e.chat?.state.credits?.total;e.onSummary?.({state:"crashed",facts:[`agent crashed \u2014 session ${S.state.sid} is resumable at checkpoint seq ${r.seq}`,"at most the in-flight turn was lost",...g!==void 0?[`credits used: ${g.toFixed(1)}`]:[]],...It(u,n),tracePath:B})}return Fe=!0,S.release(),3}e.out(`error: agent crashed for ${s.source_id} with no durable checkpoint`),e.emit?.({type:"error",source_id:s.source_id,message:`error: agent crashed for ${s.source_id} with no durable checkpoint`,code:"AGENT_CRASHED"}),V(s.source_id);continue}if(G){if(er+=w.assumedDefaults??0,w.error||(w.sentComplete||(l=!0),hr))return 1;if(!vt&&!wt){let r=U.length-x-1,n=u.text("note.nothing_committed",{source_id:s.source_id,remaining:r});G||e.out(n);let c=e.chat?.state?.credits?.total;e.onSummary?.({state:"complete",facts:[n,...se>0?[`${se} use-case${se===1?"":"s"} saved earlier in this run`]:[],...c!==void 0?[`credits used: ${c.toFixed(1)}`]:[]],tracePath:B});{let g=(S?.state.ingest_schedule??[]).filter(T=>T.status==="pending");g.length>0&&e.out(u.text("note.landed_not_extracted",{count:g.length,sources:g.map(T=>T.source_id).join(", ")}))}return m&&s.source_id in m.handle.state.read_basis&&(m.handle.complete(y()),m=null,S=null),Qt(y()),0}m&&s.source_id in m.handle.state.read_basis&&!wt&&(i(x),m.handle.complete(y()),m=null,S=null);continue}if(!w.proposal){e.out(`error: agent ended without a proposal for ${s.source_id}`),e.emit?.({type:"error",source_id:s.source_id,message:`error: agent ended without a proposal for ${s.source_id}`,code:"NO_PROPOSAL"}),V(s.source_id);continue}let X=Ue(w.proposal,Ve(_,w.proposal),_);if(A("kane_validate",{errors:X.map(r=>r.code)},$.session_id),X.length>0&&pn(w.proposal,X,r=>e.out(r))&&(A("criteria_dropped",{source_id:s.source_id},$.session_id),X=Ue(w.proposal,Ve(_,w.proposal),_)),X.length>0){e.out("the agent's proposal didn't validate \u2014 retrying once"),e.emit?.({type:"validate_failed",source_id:s.source_id,codes:X.map(n=>n.code),repairing:!0}),A("repair_respawn",{source_id:s.source_id},$.session_id),I&&J||(or=S?.state.checkpoint?.seq??0);let r=w.creditsTotal??M.creditsBefore;try{w=await Wt($,{...M,...r!==void 0&&r>0?{creditsBefore:r}:{},graphSlot:D,...we?{checkpoint:we}:{}},pt,_,A,void 0,()=>Te.current),f=w.creditsTotal??f}catch(n){if(n instanceof tt)return e.out(`error: ${n.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:n.message}),2;throw n}if(w.error||!w.proposal){e.out(`error: repair run failed for ${s.source_id}`),e.emit?.({type:"error",source_id:s.source_id,message:`error: repair run failed for ${s.source_id}`,code:"REPAIR_FAILED"}),V(s.source_id);continue}if(X=Ue(w.proposal,Ve(_,w.proposal),_),X.length>0){A("validation_details",{errors:X.map(n=>({code:n.code,detail:n.detail}))},$.session_id),e.out(`\u2717 validation failed \u2014 ${X.map(n=>n.code).join(", ")} (details: ${B})`),e.emit?.({type:"validate_failed",source_id:s.source_id,codes:X.map(n=>n.code),repairing:!1}),e.emit?.({type:"error",source_id:s.source_id,message:`error: proposal failed validation after repair (${X.map(n=>n.code).join(", ")})`,code:"PROPOSAL_INVALID"}),V(s.source_id);continue}}let H=w.proposal,Xe=Fs(H,_);if(e.store.proposals().write(ne,H),t.plan){e.out(`plan: ${H.use_cases.length} use-case(s) proposed from ${s.source_id} (nothing committed)`);for(let r of H.use_cases){let n=Xe.get(r.temp_ref),c=n?n.archived?` \u2248 matches ARCHIVED ${n.cid.slice(0,19)}${n.reason?` \u2014 previously rejected: "${n.reason}"`:" \u2014 previously rejected"}`:` \u2248 matches ${n.cid.slice(0,19)}`:"";e.out(` [${r.risk}] ${r.title} \u2014 cite ${r.cite.anchor}${c}`)}e.emit?.({type:"plan",source_id:s.source_id,use_cases:H.use_cases.map(r=>{let n=Xe.get(r.temp_ref);return{risk:r.risk,title:r.title,anchor:r.cite.anchor,...n?{match:n.cid,match_archived:!!n.archived}:{}}})}),w.assumedDefaults&&e.out(`assumed: ${w.assumedDefaults} default(s) auto-taken (assumed)`);continue}for(let r of H.use_cases){if(!r.conflicts_with?.length)continue;let n=r.conflicts_with.filter(g=>_.resolve(g)!==null),c=r.conflicts_with.filter(g=>_.resolve(g)===null);c.length>0&&(e.out(`note: ${r.temp_ref}: dropped unresolvable conflict hint(s): ${c.join(", ")}`),r.conflicts_with=n.length>0?n:void 0)}A("review_start",{use_cases:H.use_cases.length,flags:Xe.size},$.session_id);let ze=await e.review(H.use_cases,Xe);if(A("review_verdicts",[...ze.entries()].map(([r,n])=>({ref:r,resolution:n.resolution})),$.session_id),e.store.proposals().writeReview(ne,H.use_cases.map(r=>{let n=ze.get(r.temp_ref)??{resolution:"skipped"};return{id:r.temp_ref,kind:"review-item",resolution:n.resolution,edit:n.edit??null,reason:n.reason??null,...n.supersedeTarget?{supersede_target:n.supersedeTarget}:{},by:Re}})),t.posture==="reconcile"){let r=Xr(H),n=fe(),c=r.adds.length+r.updates.length+r.archives.length,g=n?.state.reconcile?.proposal_id,T={proposal_id:ne,verdicts:{},...g&&g!==ne?{replaces:g}:{}};n&&c>0&&n.save({reconcile:{...T,pending:!0}});let b=await Zr({store:e.store,ctx:Vt(e.store,$.session_id,e.credentials,{reservedEventIds:ut,probe:e.probe,runAuth:e.auth,similarity:e.similarity}),graph:_,sid:$.session_id,proposalId:ne,proposal:H,by:Re,durable:Q,...e.matchUnreviewed?{matchUnreviewed:!0}:{}});b.ok||e.out("note: the unchanged-match evidence attach did not land this run \u2014 the held changeset is unaffected; re-run reconcile to refresh it"),b.skippedAttach>0&&e.out(u.text("note.evidence_not_attached",{count:b.skippedAttach})),n&&c>0&&(b.ok&&n.save({reconcile:T}),he+=c,Ie=!0,Ge=n.state.sid,e.out(`held: ${c} change(s) from ${s.source_id} await your verdicts \u2014 nothing from the changeset committed`),e.emit?.({type:"held",source_id:s.source_id,count:c,reason:"reconcile"})),c===0&&m&&!m.handle.state.reconcile&&s.source_id in m.handle.state.read_basis&&(i(x),m.handle.complete({ended:"complete"}),e.out(`session ${t.resume} complete`),e.emit?.({type:"session_complete",sid:t.resume,source_id:s.source_id}),m=null,S=null);continue}if((Ae||t.trust==="hold")&&fe()&&H.use_cases.some(r=>r.matches_existing==null)){mt(s,H.use_cases,Ae?"degraded":"trust_hold");continue}let vr=Vt(e.store,$.session_id,e.credentials,{reservedEventIds:ut,probe:e.probe,runAuth:e.auth,similarity:e.similarity}),wr=r=>{if(r.degradedProbe&&fe()!==null&&H.use_cases.some(c=>c.matches_existing==null))return{result:{degradedHold:!0},record:null};let n=Ot({store:e.store,graph:r.graph,scope:r.scope,proposal:H,proposalId:ne,verdicts:ze,by:Re,autoName:!0,allowStaleBasis:!0,eventIds:r.eventIds("extract",1),...Q?{sid:r.sid}:{},probeHits:r.probeHits,...e.matchUnreviewed?{matchUnreviewed:!0}:{}});return n.errors!==null?{errors:n.errors}:{result:n,record:n.record}},yr=ve;ve=null;let br={...Ut(H,_),...yr?{eventIds:[yr]}:{}},W=await rt(vr,br,wr);if(!W.ok&&W.kind==="drifted"){if(!await e.confirmStale(`the context changed while you reviewed (${W.asks.map(n=>n.detail).join("; ")}) \u2014 commit against the new head anyway?`)){e.out("aborted: proposal not committed"),e.emit?.({type:"error",source_id:s.source_id,message:"aborted: proposal not committed",code:"STALE_BASIS"}),V(s.source_id);continue}W=await rt(vr,{...br,sourcePins:[]},wr)}e.similarity&&st(e.similarity,A);let St=W.ok&&"result"in W?W.result:null;if(St!==null&&"degradedHold"in St){lt(),mt(s,H.use_cases,"degraded");continue}let Oe=St??(W.ok?{record:null,errors:null}:{record:null,errors:W.kind==="validation"?W.errors:W.kind==="contended"?[{code:W.err.code,detail:`a use-case this proposal touches is held by ${W.err.holder?.owner_sid??"another session"} \u2014 try again when it frees`}]:[{code:"UNSETTLED",detail:"concurrent activity kept moving the store \u2014 retry when quieter"}]});if(Oe.errors){A("commit_error_details",{errors:Oe.errors.map(r=>({code:r.code,detail:r.detail}))},$.session_id),e.out(`\u2717 commit failed \u2014 ${Oe.errors.map(r=>r.code).join(", ")} (details: ${B})`),e.emit?.({type:"error",source_id:s.source_id,message:`error: commit failed: ${Oe.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}`,code:"COMMIT_FAILED"}),V(s.source_id);continue}let Ys=new Date().toISOString();for(let r of H.use_cases){let n=ze.get(r.temp_ref)??{resolution:"skipped"};for(let c of Or({ts:Ys,command:"context extract",id:r.temp_ref,by:Re},n.resolution))e.store.signals().append(c)}let ie=Oe.record;ie.event_ids?.length&&S?.markApplied(ie.event_ids);let kt=new Map(ie.review.map(r=>[r.id,r.resolution])),Et=[...kt.values()].filter(r=>r==="approved"||r==="edited").length,Ke=[...kt.values()].filter(r=>r==="rejected").length,Pe=ie.nodes.filter(r=>!kt.has(r.cid)).length,$t=ie.supersessions.filter(r=>r.kind==="node"&&r.new!==r.old).length;A("commit",{trusted:Et,derived:Pe,archived:Ke},$.session_id),e.out(`saved ${Et+Pe} use-case(s)`+(Pe>0?` \xB7 ${Pe} awaiting review`:"")+(Ke>0?` \xB7 ${Ke} archived`:"")+($t>0?` \xB7 ${$t} superseded`:""));{let r=ie.review.filter(n=>n.kind==="pending_update");r.length>0&&(e.out(`${r.length} update(s) held for review`),e.emit?.({type:"update_held",count:r.length,targets:r.map(n=>n.id)}))}w.assumedDefaults&&e.out(`assumed: ${w.assumedDefaults} default(s) auto-taken (assumed)`),e.emit?.({type:"commit",source_id:s.source_id,proposal_id:ne,trusted:Et,derived:Pe,archived:Ke,superseded:$t,assumed:w.assumedDefaults??0,evidence_matched:Math.max(0,H.use_cases.length-ie.nodes.length),minted:ie.nodes.map(r=>{let n=ie.names?.find(c=>c.cid===r.cid)?.slug;return{cid:r.cid,...n?{logical_id:n}:{}}})}),m&&s.source_id in m.handle.state.read_basis&&(i(x),m.handle.complete({ended:"complete"}),e.out(`session ${t.resume} complete`),e.emit?.({type:"session_complete",sid:t.resume,source_id:s.source_id}),v?.event("ASR_SESSION_COMPLETE",{duration_ms:Date.now()-Date.parse(m.handle.state.created_at),credits_total:f}),m=null,S=null)}if(S){let x=S.state.ingest_schedule??[];x.some(s=>s.status==="pending")&&S.save({ingest_schedule:x.map(s=>s.status==="pending"?{...s,status:"skipped",note:u.text("note.not_reached",{})}:s)})}rr=!0}finally{if(v?.setRunTotals?.({work_items_total:U.length,work_items_failed:ae.length}),Ae&&v?.event("ASR_EMBED_DEGRADED",{held:tr}),m?.handle.release(),j&&!Fe&&!rr){let i=j.state.checkpoint;if(i)e.out(u.text("note.session_kept",{verb:"extract",sid:j.state.sid,mode:p,seq:i.seq,ts:i.ts})),j.release();else{try{j.complete(a())}catch{j.release()}Yt()}j=null}}if(G){let i=e.chat?.state.ledger.filter(L=>L.kind==="answer"&&L.receipt.form==="assumed").length??0,f=er+i,k=e.chat?.state.credits?.total;e.onSummary?.({state:"complete",facts:[`saved ${se} use-case${se===1?"":"s"} across ${U.length} source${U.length===1?"":"s"}`,...f>0?[`${f} assumed default(s)`]:[],...k!==void 0?[`credits used: ${k.toFixed(1)}`]:[]],tracePath:B})}if(t.plan||ks(e.store),he>0&&(j||Ge)){Fe=!0;let i=j?.state.sid??Ge,f=Ie?u.command("next.review_held_changeset",{}):u.command("next.resume_session",{verb:"extract",sid:i,mode:p});!G&&!(Ie&&e.reviewsHeld)&&e.out(Ie?u.text("note.changeset_held_for_review",{sid:i,held:he}):u.text("note.held_for_review",{sid:i,mode:p,held:he}));let k=Ie&&p!=="interactive",L=k?u.command("next.show_session",{sid:i}):null;if(e.emit?.({type:"session_paused",sid:i,...k?f!==null?{held_review:{cmd:f,needs:"tty"}}:{}:f!==null?{resume:f}:{},...L!==null?{next:[{cmd:L,why:"shows the session and the changeset it holds; its verdicts are given in a terminal",title:"Show the held session"}]}:{},held:he}),G){let x=e.chat?.state.credits?.total;e.onSummary?.({state:"paused",reason:"held for review",facts:[`${he} held item(s) await your review`,...x!==void 0?[`credits used: ${x.toFixed(1)}`]:[]],...f!==null?{resume:f}:{},tracePath:B})}return j?.release(),3}return ae.length>0&&e.out(u.text("note.sources_failed",{failed:ae.length,total:U.length,sources:ae.join(", ")})),Qt(ae.length>0?h.failedRecorded():y()),ae.length>0?1:0}export{Vt as a,hn as b,Hs as c,gn as d,Xs as e,_n as f,Fs as g,vn as h,Ci as i};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{homedir as s}from"os";import{join as t}from"path";var g="0.10.
|
|
2
|
+
import{homedir as s}from"os";import{join as t}from"path";var g="0.10.4";var a=t(s(),".testmuai","kaneai"),h=t(a,"profiles"),u=t(a,"tui-config.json"),U=t(a,"media"),_="https://registry.npmjs.org/@testmuai/kane-cli",x="https://api.github.com/repos/LambdaTest/kane-cli/releases",i="@testmuai/kane-cli-skill",A=`https://registry.npmjs.org/${i}`,r="kane-cli",L=[{dir:t(s(),".claude","skills",r),agent:"Claude Code"},{dir:t(s(),".agents","skills",r),agent:"Codex CLI"},{dir:t(s(),".gemini","skills",r),agent:"Gemini CLI"}],I="https://dd-proxy.lambdatest.com/intake/kane-cli",R="https://kaneai-playground.lambdatest.io",E=9222,C=9230,v=t(a,"chrome-profiles"),o=t(a,"hints"),f=t(o,"state.json");function B(e){return t(o,`catalog-${e}.json`)}var l=t(a,"evidence");function S(e){return t(l,`catalog-kane-cli-${e}.json`)}var c=t(a,"mobile");function T(e,n="android"){return t(c,n==="ios"?`device-catalog-ios-${e}.json`:`device-catalog-${e}.json`)}var m="127.0.0.1",N=18392,k=18400,p="/callback";function O(e){return`http://${m}:${e}${p}`}var P="KANE CLI",D="*",H={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com",mobileAppBaseUrl:"https://api.lambdatest.com",mobileHubUrl:"https://mobile-hub.lambdatest.com/wd/hub",lrmaaBaseUrl:"https://mobile-api.lambdatest.com/mobile-automation/api/v1",latticeBaseUrl:"https://kaneai-api.lambdatest.com/v16-lattice",deviceStreamUrl:"https://stream-microfrontend.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com",mobileAppBaseUrl:"https://stage-api.lambdatestinternal.com",mobileHubUrl:"https://stage-mobile-hub.lambdatestinternal.com/wd/hub",lrmaaBaseUrl:"https://stage-mobile-api.lambdatestinternal.com/mobile-automation/api/v1",latticeBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-lattice",deviceStreamUrl:"https://stage-stream-microfrontend.lambdatestinternal.com"}},M={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{g as a,a as b,u as c,U as d,_ as e,x as f,i as g,L as h,I as i,R as j,E as k,C as l,v as m,f as n,B as o,S as p,T as q,m as r,N as s,k as t,p as u,O as v,P as w,D as x,H as y,M as z};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as g}from"./chunk-
|
|
2
|
+
import{b as g}from"./chunk-YKOZBFR3.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
|
|
3
3
|
`),f(this.configFile,384)}getActiveProfile(){return this.readConfig().active_profile??null}setActiveProfile(t){let i=this.readConfig();i.active_profile=t,this.writeConfig(i)}getDefaultEnv(){return this.readConfig().default_env??"prod"}setDefaultEnv(t){let i=this.readConfig();i.default_env=t,this.writeConfig(i)}credentialsPath(t,i){return n(this.profilesDir,t,i,"credentials")}clientPath(t,i){return n(this.profilesDir,t,i,"client.json")}basicAuthPath(t,i){return n(this.profilesDir,t,i,"basic-auth")}profileConfigPath(t,i){return n(this.profilesDir,t,i,"profile-config.json")}saveProfileConfig(t,i,r){let e=this.loadProfileConfig(t,i)??{};this.writeSecure(this.profileConfigPath(t,i),{...e,...r})}loadProfileConfig(t,i){try{return JSON.parse(o(this.profileConfigPath(t,i),"utf-8"))}catch{return null}}writeSecure(t,i){try{u(P(t),{recursive:!0,mode:448}),h(t,JSON.stringify(i,null,2)+`
|
|
4
4
|
`),f(t,384)}catch(r){let e=r instanceof Error?r.message:String(r);process.stderr.write(`[auth] Failed to save credentials: ${e}
|
|
5
5
|
`)}}saveCredentials(t,i,r){this.writeSecure(this.credentialsPath(t,i),r)}loadCredentials(t,i){try{return JSON.parse(o(this.credentialsPath(t,i),"utf-8"))}catch{return null}}saveClient(t,i,r){this.writeSecure(this.clientPath(t,i),r)}loadClient(t,i){try{return JSON.parse(o(this.clientPath(t,i),"utf-8"))}catch{return null}}getActiveCredentials(){let t=this.getActiveProfile();if(!t)return{credentials:null,profile:null,env:null};let i=this.getDefaultEnv();return{credentials:this.loadCredentials(t,i),profile:t,env:i}}saveBasicAuth(t,i,r){this.writeSecure(this.basicAuthPath(t,i),r)}loadBasicAuth(t,i){try{return JSON.parse(o(this.basicAuthPath(t,i),"utf-8"))}catch{return null}}deleteBasicAuth(t,i){try{s(this.basicAuthPath(t,i))}catch{}}resolveAuth(){let t=this.getActiveProfile();if(!t)return null;let i=this.getDefaultEnv(),r=this.loadBasicAuth(t,i);return r?{method:"basic",...r,profile:t,env:i}:this.loadCredentials(t,i)?{method:"oauth",profile:t,env:i}:null}listProfiles(){let t=[];try{for(let i of a(this.profilesDir)){let r=n(this.profilesDir,i);try{for(let e of a(r)){let c=n(r,e),v=l(n(c,"credentials")),p=l(n(c,"client.json")),y=l(n(c,"basic-auth"));(v||p||y)&&t.push({profile:i,env:e})}}catch{}}}catch{}return t}deleteProfile(t,i){try{s(this.credentialsPath(t,i))}catch{}if(this.getActiveProfile()===t){let r=this.readConfig();delete r.active_profile,this.writeConfig(r)}}deleteProfileFull(t,i){if(i){try{s(this.credentialsPath(t,i))}catch{}try{s(this.clientPath(t,i))}catch{}try{s(this.basicAuthPath(t,i))}catch{}try{s(this.profileConfigPath(t,i))}catch{}}else try{let r=n(this.profilesDir,t);for(let e of a(r)){try{s(n(r,e,"credentials"))}catch{}try{s(n(r,e,"client.json"))}catch{}try{s(n(r,e,"basic-auth"))}catch{}try{s(n(r,e,"profile-config.json"))}catch{}}}catch{}}};export{d as a};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as y,c as I}from"./chunk-72KYMWQ5.js";import{b}from"./chunk-CCOD4GQJ.js";import{a as x}from"./chunk-TDPWFYTJ.js";import{c as R}from"./chunk-VZ7KXRXB.js";import{b as f}from"./chunk-YKOZBFR3.js";import{f as S}from"./chunk-WMXBRC4B.js";import{a as v}from"./chunk-RZ4F3BHX.js";import{randomUUID as U}from"crypto";import{mkdirSync as P,writeFileSync as h,appendFileSync as B,existsSync as _,readFileSync as G}from"fs";import{join as u}from"path";import{writeFileSync as T,mkdirSync as w,existsSync as A}from"fs";import{join as m,relative as N}from"path";function C(r){let t=Object.keys(r.frontmatter).length>0?R(r.frontmatter).trimEnd():"",s=["---"];return t&&s.push(t),s.push("---",""),s.push(`# ${r.heading}`,""),r.steps.forEach((n,i)=>{s.push(`## Step ${i+1}`,n,"")}),s.join(`
|
|
3
|
+
`)}var k=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),D=new Set(["model","env"]),c=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=m(this.opts.cwd,".testmuai","tests");try{w(t,{recursive:!0})}catch(l){process.stderr.write(`
|
|
4
|
+
\u26A0 Failed to create ${N(this.opts.cwd,t)}/
|
|
5
|
+
${l.message}
|
|
6
|
+
Your test recording was NOT saved.
|
|
7
|
+
|
|
8
|
+
`);return}let s=m(t,`${e}_test.md`),n=2,i=!1;for(;A(s);)s=m(t,`${e}-${n}_test.md`),n++,i=!0;let a=I(j(this.opts.getResolvedGlobal())),o=C({frontmatter:a,heading:`Session: ${e}`,steps:this.objectives.map(y)});try{T(s,o,"utf8")}catch(l){process.stderr.write(`
|
|
9
|
+
\u26A0 Failed to save your test recording.
|
|
10
|
+
${l.message}
|
|
11
|
+
Path: ${s}
|
|
12
|
+
|
|
13
|
+
`);return}this.lastWrittenPath=s,this.lastCollisionSuffixed=i}};function j(r){let e={};for(let[t,s]of Object.entries(r))k.has(t)||D.has(t)||(e[t]=s);return e}var O="kaneCliSessionCompleted",$={prod:"https://test-backend.lambdatest.com/api/analytics/event",stage:"https://stage-test-backend.lambdatestinternal.com/api/analytics/event"};function F(r,e=process.env){return e.KANE_ANALYTICS_API_URL||$[r]}var p=class{constructor(e,t=3e3){this.endpoint=e;this.timeoutMs=t}async sendSessionCompleted(e,t){let s=new AbortController,n=setTimeout(()=>s.abort(),this.timeoutMs);try{let i=await v(this.endpoint,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({userId:e,event:O,data:t}),signal:s.signal});return{ok:i.ok,status:i.status}}catch{return{ok:!1,status:null}}finally{clearTimeout(n)}}};async function g(r,e,t){return new p(F(r)).sendSessionCompleted(e,t)}function M(r){let e=Math.max(0,(Date.parse(r.completedAt)-Date.parse(r.startedAt))/1e3);return{referenceId:r.referenceId,startedAt:r.startedAt,completedAt:r.completedAt,durationSeconds:Math.round(Math.max(0,r.durationSeconds??e)*1e3)/1e3,creditsConsumed:Number.isFinite(r.creditsConsumed)?Math.max(0,r.creditsConsumed):0,runType:r.runType,target:r.target}}function te(r){let e=r.find(t=>t.mobile);return e?e.platform==="ios"?"simulator":"emulator":"desktop"}async function E(r,e=g){if(process.env.KANE_CLI_MODE==="hyperexecute"||!Number.isInteger(r.userId)||r.userId<=0||!r.data.referenceId||r.runsCompleted<=0)return;let t=M(r.data),s=await e(r.env,r.userId,t).catch(()=>({ok:!1,status:null}));r.log?.(s.ok?"info":"warn",s.ok?"CRM_EVENT_SENT":"CRM_EVENT_FAILED",s.ok?"CRM event delivered":"CRM event delivery failed",{event:"kaneCliSessionCompleted",reference_id:r.data.referenceId,status_code:s.status})}var K=u(f,"sessions"),J=1e3,L=class{sessionId;sessionDir;runs=[];_flows=[];_nextIndex=0;_activeRunIndex=null;_screenshotQueue=null;_surface=null;_logTarget=null;_runType=null;_lineage={};_runStartedAtMs=null;_sessionEndLogged=!1;_dropExitTail=null;_screenshotSummaryLogged=!1;_started=!1;_testId=null;_saveBlocker=null;_testcaseId=null;_projectId=null;_orgId=null;_userName=null;_userEmail=null;_uploadStatus="pending";_uploadAttempts=0;_uploadError=null;_firstObjective=null;_firstUrl=null;_auteurVariables={};_screenshotSas=null;_model="";_environment="";_profile=null;_plan=null;_startedAt="";_remoteLogger=null;_earlyLogBuffer=[];_recorder=null;_resolvedGlobal={};_sessionName=null;_recordingEnabled=!0;_stepRunRecords=[];_completionUserId=null;_completionMetadata=null;_completionReporter;_reportCompletion;_completionReported=!1;constructor(e){this.sessionId=U();let t=e?.baseDir?u(e.baseDir,"sessions"):K;this.sessionDir=u(t,this.sessionId),this._completionReporter=e?.reporter??((s,n)=>g(this._environment==="stage"?"stage":"prod",s,n)),this._reportCompletion=e?.report!==!1}setCompletionIdentity(e){Number.isInteger(e)&&e>0&&(this._completionUserId=e)}setCompletionMetadata(e){this._completionMetadata??=e}async reportCompletedSession(e){if(this.recordCreditsConsumed(e.creditsConsumed),e.runsCompleted<=0||this._completionReported||!this._reportCompletion||this._completionUserId===null||this._completionMetadata===null||!this._startedAt)return;this._completionReported=!0;let t=e.completedAt??new Date().toISOString();await E({env:this._environment==="stage"?"stage":"prod",userId:this._completionUserId,runsCompleted:e.runsCompleted,data:{referenceId:this.sessionId,startedAt:this._startedAt,completedAt:t,durationSeconds:e.durationSeconds,creditsConsumed:e.creditsConsumed,...this._completionMetadata},log:(s,n,i,a)=>this.log(s,n,i,a)},(s,n,i)=>this._completionReporter(n,i))}recordCreditsConsumed(e){let t=u(this.sessionDir,"session.json");if(_(t))try{let s=JSON.parse(G(t,"utf8"));s.credits_consumed=Number.isFinite(e)?Math.max(0,e):0,h(t,JSON.stringify(s,null,2)+`
|
|
14
|
+
`)}catch{}}setResolvedGlobal(e){this._resolvedGlobal={...this._resolvedGlobal,...e}}setSessionName(e){this._sessionName=e}get sessionName(){return this._sessionName}setRecordingEnabled(e){this._recordingEnabled=e}get recorder(){return this._recorder}flushRecorder(){try{this._recorder?.flush()}catch(e){process.stderr.write(`[recorder] flush failed: ${e.message}
|
|
15
|
+
`)}}get started(){return this._started}start(e){if(!this._started){this._started=!0,this._dropExitTail=S(t=>this.endOnExit(t)),e.surface&&!this._surface&&(this._surface=e.surface),e.runType&&!this._runType&&(this._runType=e.runType),e.target&&!this._logTarget&&(this._logTarget=e.target),this._model=e.model,this._environment=e.environment,this._profile=e.profile,this._startedAt=new Date().toISOString();try{P(this.sessionDir,{recursive:!0}),this._recorder=new c({cwd:process.cwd(),getResolvedGlobal:()=>this._resolvedGlobal,getName:()=>this._sessionName});let t={session_id:this.sessionId,started_at:this._startedAt,model:e.model,environment:e.environment,profile:e.profile,plan:this._plan,objectives:[],runs:[],status:"in_progress"};h(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
|
|
16
|
+
`)}catch{}this._log(`SESSION START session_id=${this.sessionId}`),this._log(`CONFIG model=${e.model} env=${e.environment} profile=${e.profile}`),this._earlyLogBuffer.push({level:"info",event:"SESSION_START",message:"Session started",context:{session_id:this.sessionId,surface:this._surface,run_type:this._runType,target:this._logTarget?.target??null,device_kind:this._logTarget?.device_kind??null,model:e.model,environment:e.environment,profile:e.profile,...this._lineage}})}}setLineage(e){e.surface&&(this._surface=e.surface);let{surface:t,...s}=e;this._lineage={...this._lineage,...s}}setRunTarget(e){if(this._logTarget&&this._logTarget.target===e.target&&this._logTarget.device_kind===e.device_kind||(this._logTarget=e,!this._started))return;let t=this._earlyLogBuffer.find(s=>s.event==="SESSION_START");if(t){t.context={...t.context,target:e.target,device_kind:e.device_kind};return}this._remoteLogger?.amendUnsent("SESSION_START",{target:e.target,device_kind:e.device_kind})||this.log("info","SESSION_TARGET","Session target",{target:e.target,device_kind:e.device_kind})}setPlan(e){this._plan=e;let t={level:"info",event:"SESSION_INFO",message:"Session info",context:{session_id:this.sessionId,plan:e??null}};this._remoteLogger?this._remoteLogger.log(t.level,t.event,t.message,t.context):this._earlyLogBuffer.push(t)}get plan(){return this._plan}get apMode(){return x()??"v2"}setRemoteLogger(e){this._remoteLogger=e;for(let t of this._earlyLogBuffer)e.log(t.level,t.event,t.message,t.context);this._earlyLogBuffer=[]}get hasRemoteLogger(){return this._remoteLogger!==null}setAuteurVariables(e){Object.assign(this._auteurVariables,e)}get auteurVariables(){return this._auteurVariables}setScreenshotSas(e){this._screenshotSas=e}get screenshotSas(){return this._screenshotSas}get screenshotBaseUrl(){return this._screenshotSas?`${this._screenshotSas.base_url}/${this._screenshotSas.container}`:""}get startedAt(){return this._startedAt||new Date().toISOString()}log(e,t,s,n){if(t===void 0){this._log(e);let o=e.indexOf(" "),l=o>0?e.slice(0,o):e,d=o>0?e.slice(o+1):"";this._remoteLogger?.log("info",l,d||e);return}let i=e,a=s;this._log(`${t} ${a}`,n),this._remoteLogger?this._remoteLogger.log(i,t,a,n):this._earlyLogBuffer.length<J&&this._earlyLogBuffer.push({level:i,event:t,message:a,context:n})}logStep(e,t,s){this._log(`${e} ${t}`,s),this._remoteLogger?.logStep(this.activeRunIndex,e,t,s)}get activeRunIndex(){return this._activeRunIndex??this._nextIndex}logCommand(e){this._log(`COMMAND ${e}`)}logRunStart(e,t,s){this._log(`RUN ${e} START objective="${t.slice(0,100)}" url=${s}`),this._activeRunIndex=e,this._runStartedAtMs=Date.now(),this._remoteLogger?.setRunIndex(e,`run-${e}`),this._remoteLogger?.log("info","RUN_START",`Run ${e} started`,{run_index:e,run_id:`run-${e}`,surface:this._surface,objective:t,url:s})}logRunEnd(e,t,s,n,i){let a=(s??0).toFixed(1),o=(n??"").slice(0,100),l=i==null||i===""||Number.isNaN(Number(i))?null:Number(i);this._log(`RUN ${e} END status=${t} duration=${a}s summary="${o}"`,l!=null?{result_code:l}:void 0),this._remoteLogger?.log("info","RUN_END",`Run ${e} ended`,{run_index:e,run_id:`run-${e}`,surface:this._surface,status:t,duration:s??0,duration_ms:this._runStartedAtMs!=null?Date.now()-this._runStartedAtMs:Math.round((s??0)*1e3),summary:n??"",result_code:l}),t!=="passed"?this._remoteLogger?.escalate(e):this._remoteLogger?.discardSteps(e),this._activeRunIndex===e&&(this._activeRunIndex=null),this._runStartedAtMs=null,this._remoteLogger?.setRunIndex(null)}enterRun(e){this._activeRunIndex=e,this._remoteLogger?.setRunIndex(e,`run-${e}`)}exitRun(){this._activeRunIndex=null,this._remoteLogger?.setRunIndex(null)}escalateRun(e=this.activeRunIndex){this._remoteLogger?.escalate(e)}setScreenshotQueue(e){this._screenshotQueue=e}escalateAll(){this._remoteLogger?.escalateAll()}discardAll(){this._remoteLogger?.discardAll()}logChromeLaunch(e,t){this._log(`CHROME LAUNCH port=${e} endpoint=${t}`),this._remoteLogger?.log("info","CHROME_LAUNCH","Chrome launched",{port:e,cdp_endpoint:t})}async finish(e="complete"){let t=typeof e=="string"?e:"complete",s=typeof e=="string"?void 0:e,n=s?.status??this.deriveSessionStatus(),i=new Date().toISOString();this._log(`SESSION END status=${n} total_runs=${this.runs.length}`),this._screenshotQueue&&!this._screenshotSummaryLogged&&(this._screenshotSummaryLogged=!0,this._remoteLogger?.log("info","SCREENSHOT_SUMMARY","Screenshot uploads",this._screenshotQueue.stats())),this._dropExitTail?.(),this._dropExitTail=null,this.logSessionEnd(n,s?.reason),await this._remoteLogger?.flushNow();let a={session_id:this.sessionId,started_at:this._startedAt,ended_at:i,model:this._model,environment:this._environment,profile:this._profile,plan:this._plan,status:t,outcome:n,total_runs:this.runs.length,test_id:this._testId,testcase_id:this._testcaseId,commit_id:this.sessionId,project_id:this._projectId,upload_status:this._uploadStatus,upload_attempts:this._uploadAttempts,last_upload_attempt:this._uploadAttempts>0?new Date().toISOString():null,upload_error:this._uploadError,runs:this.runs.map(o=>({index:o.index,objective:o.objective,status:o.status,summary:o.summary,run_dir:o.run_dir}))};if(_(this.sessionDir)&&h(u(this.sessionDir,"session.json"),JSON.stringify(a,null,2)+`
|
|
17
|
+
`),this.flushRecorder(),this._recorder=null,this._flows.length>0){let o=this._flows.reduce((l,d)=>l+(Number.isFinite(d.creditsConsumed)?d.creditsConsumed??0:0),0);await this.reportCompletedSession({runsCompleted:this._flows.length,completedAt:i,creditsConsumed:o})}}runCounts(){let e=this._flows.length>0?this._flows.map(t=>t.status):this.runs.map(t=>String(t.status));return{total:e.length,passed:e.filter(t=>t==="passed").length,failed:e.filter(t=>t==="failed").length,error:e.filter(t=>t==="error").length}}logSessionEnd(e,t){if(this._sessionEndLogged)return;this._sessionEndLogged=!0;let s=this.runCounts();this._remoteLogger?.log("info","SESSION_END","Session ended",{status:e,...t?{reason:t}:{},total_runs:this.runs.length,runs_total:s.total,runs_passed:s.passed,runs_failed:s.failed,runs_error:s.error,duration_ms:this._startedAt?Date.now()-Date.parse(this._startedAt):null,surface:this._surface,run_type:this._runType,...this._lineage})}endOnExit(e){if(this._dropExitTail=null,this._sessionEndLogged)return;let t=e.kind==="signal"?e.signal.toLowerCase():e.kind==="crash"?"crash":"exit";this._activeRunIndex!==null&&this.logRunEnd(this._activeRunIndex,e.kind==="crash"?"error":"cancelled",void 0,t,null);let s=e.kind==="signal"?"cancelled":e.kind==="crash"?"error":this.deriveSessionStatus();this.logSessionEnd(s,t);try{this._remoteLogger?.shutdownSync()}catch{}}deriveSessionStatus(){let e=this.runCounts();return e.total===0?"no_runs":e.error>0?"error":e.failed>0||e.passed<e.total?"failed":"passed"}nextRunIndex(){return this._nextIndex}addRunResult(e,t){this.runs.push(e),this._nextIndex+=t??1,this._recordingEnabled&&this._recorder?.appendObjective(e.objective)}getContext(){return{prior_runs:this.runs.map(e=>({index:e.index,objective:e.objective,summary:e.summary,status:e.status,memory:e.context.memory,variables:e.context.variables,pointer:e.context.pointer}))}}addFlow(e){let t={...e,index:this._flows.length+1};return this._flows.push(t),t}getFlows(){return[...this._flows]}getFlow(e){return this._flows.find(t=>t.index===e)}clearFlows(){this._flows=[]}recordStepRun(e){this._stepRunRecords.push(e)}getStepRunRecords(){return[...this._stepRunRecords]}getRunsAsStepRecords(){return this.runs.map((e,t)=>({testmdStepIndex:t+1,runIndex:e.index,totalRunDirs:e.run_dirs?.length??1}))}snapshot(){return{runsLen:this.runs.length,nextRunIndex:this._nextIndex,stepRunRecordsLen:this._stepRunRecords.length}}rollback(e){this.runs.length=e.runsLen,this._nextIndex=e.nextRunIndex,this._stepRunRecords.length=e.stepRunRecordsLen}setTestId(e){this._testId=e,this._saveBlocker=null}get testId(){return this._testId}setSaveBlocker(e){this._saveBlocker=e}get saveBlocker(){return this._saveBlocker}setTestcaseId(e){this._testcaseId=e}get testcaseId(){return this._testcaseId}setProjectId(e){this._projectId=e}setOrgId(e){this._orgId=e}get orgId(){return this._orgId}setUserIdentity(e,t){e&&(this._userName=e),t&&(this._userEmail=t)}get userName(){return this._userName}get userEmail(){return this._userEmail}setFirstRun(e,t){this._firstObjective||(this._firstObjective=e,this._firstUrl=t)}get firstObjective(){return this._firstObjective}get firstUrl(){return this._firstUrl}getRunDirs(){let e=[];for(let t of this.runs)t.run_dirs&&t.run_dirs.length>0?e.push(...t.run_dirs):t.run_dir&&e.push(t.run_dir);return e}getRunObjectives(){let e=[];for(let t of this.runs)t.flow_objectives&&t.flow_objectives.length>0?e.push(...t.flow_objectives):e.push(t.objective);return e}getRunMetadata(){let e=[];for(let t of this.runs)if(t.perFlowMetadata&&t.perFlowMetadata.length>0)e.push(...t.perFlowMetadata);else{let s={resultCode:t.resultCode,reasonCode:t.reasonCode,errorMessage:t.status==="failed"?t.summary??null:null,summary:t.summary,oneLiner:t.oneLiner},n=t.run_dirs?.length??1;for(let i=0;i<n;i++)e.push(s)}return e}setUploadStatus(e,t){this._uploadStatus=e,this._uploadAttempts+=1,this._uploadError=t??null}_log(e,t){if(!(!this._started||!_(this.sessionDir)))try{let s=new Date().toISOString().slice(0,19).replace("T"," "),n=u(this.sessionDir,"tui.log"),i=t&&Object.keys(t).length>0?` ${JSON.stringify(t)}`:"";B(n,b(`[${s}] ${e}${i}
|
|
18
|
+
`))}catch{}}};export{C as a,te as b,E as c,L as d};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{S as G,T as I,U as O,V as _}from"./chunk-
|
|
2
|
+
import{S as G,T as I,U as O,V as _}from"./chunk-DAV4ONGS.js";import{a as S}from"./chunk-TCK7WR3M.js";import{a as u}from"./chunk-73Y6T2UK.js";import{Ia as N}from"./chunk-5EAJO372.js";import{existsSync as M}from"fs";var q=new Set(["interactive","agent","ci","override"]);function B(t){return t.mode!=null&&!q.has(t.mode)?{error:`design: --mode must be interactive | agent | ci | override, got '${t.mode}'`}:t.strength!=null&&t.strength!=="pairwise"&&t.strength!=="3-wise"?{error:`design: --strength must be pairwise | 3-wise, got '${t.strength}'`}:t.max!=null&&(!Number.isInteger(t.max)||t.max<1)?{error:"design: --max must be a positive integer"}:!t.useCase&&!t.resume?{error:"design: --use-case is required (or --resume <sid> \u2014 the session remembers its use-case)"}:{useCase:t.useCase,max:t.max,strength:t.strength,mode:t.mode,force:t.force,resume:t.resume,plan:t.plan,message:t.message,phase:t.phase,allowUnreviewed:t.allowUnreviewed,because:t.because,changeDelta:t.changeDelta,priorDesign:t.priorDesign,...t.repinsKept?{repinsKept:!0}:{},statement:t.statement}}async function Z(t){let p=async(e,r)=>{if(t.mode!=="agent")return process.stderr.write(e+`
|
|
3
3
|
`),2;let{makeHeadlessIO:i,agentRefusal:d}=await import("./headless-io-FFM5T6KL.js");return d(i("ndjson","design"),e,r)};if(t.mode!=null&&!["interactive","agent","ci","override"].includes(t.mode)){let{makeHeadlessIO:e,agentRefusal:r}=await import("./headless-io-FFM5T6KL.js");return r(e("ndjson","design"),`design: --mode must be interactive | agent | ci | override, got '${t.mode}'`,"MODE_USAGE")}let l=t.json===!0;{let{jsonModeRefusal:e}=await import("./headless-io-FFM5T6KL.js"),r=e("design",t.mode,l);if(r!==null)return process.stderr.write(`${r}
|
|
4
|
-
`),2}let h=B(t);if("error"in h)return p(h.error);let s=h;if(s.useCase?.startsWith("sha256:"))try{let[{openGraph:e},{expandUseCaseRef:r}]=await Promise.all([import("./readmodel-
|
|
5
|
-
next: ${e.remedy}`,e.code);let{makeHeadlessIO:r}=await import("./headless-io-FFM5T6KL.js"),i=r("ndjson","design");return i.event(_(e)),i.done(2,"refused")}}if(s.useCase&&!t.allowUnreviewed)try{let[{openGraph:e},{consentCanStart:r,designEntryGate:i},{peekSession:d}]=await Promise.all([import("./readmodel-
|
|
4
|
+
`),2}let h=B(t);if("error"in h)return p(h.error);let s=h;if(s.useCase?.startsWith("sha256:"))try{let[{openGraph:e},{expandUseCaseRef:r}]=await Promise.all([import("./readmodel-FARAAPUU.js"),import("./use-case-ref-E3PJDHQB.js")]);s.useCase=r(e(u(process.cwd())),s.useCase)}catch{}{let{validateResumeMessage:e}=await import("./headless-io-FFM5T6KL.js"),r=e(s,"design");if(r)return p(r)}{let{gateStructuredFlags:e}=await import("./structured-answers-EQ2AP3F7.js"),r=e(t,"design");if(r)return p(r,"STRUCTURED_FLAGS_USAGE")}if(!M(u(process.cwd())))return p("error: no context store here (run `kane-cli context ingest` + `kane-cli context extract` first)","NO_STORE");{let e=O(u(process.cwd()));if(e){if(t.mode!=="agent")return p(`error: ${e.text}
|
|
5
|
+
next: ${e.remedy}`,e.code);let{makeHeadlessIO:r}=await import("./headless-io-FFM5T6KL.js"),i=r("ndjson","design");return i.event(_(e)),i.done(2,"refused")}}if(s.useCase&&!t.allowUnreviewed)try{let[{openGraph:e},{consentCanStart:r,designEntryGate:i},{peekSession:d}]=await Promise.all([import("./readmodel-FARAAPUU.js"),import("./trust-gate-674C2NZS.js"),import("./sessions-NH2EG7BP.js")]),y;try{y=s.resume?d(u(process.cwd()),s.resume)?.use_case:void 0}catch{y=void 0}let o=i(e(u(process.cwd())),{useCase:s.useCase,resuming:!!s.resume,sessionUseCase:y});if(o){let b=r(o),T=s.mode??"interactive";if(b&&T==="interactive"&&process.stdin.isTTY&&process.stdout.isTTY){let{createInterface:x}=await import("readline/promises"),m=x({input:process.stdin,output:process.stderr}),g=(await m.question(`design: ${o.detail}
|
|
6
6
|
Design against it anyway? (y/N) `)).trim().toLowerCase();if(m.close(),g!=="y"&&g!=="yes")return process.stderr.write(`aborted \u2014 approve it first: ${o.reviewCmd}
|
|
7
7
|
`),2;s.allowUnreviewed=!0}else if(t.mode==="agent"){let{makeHeadlessIO:x}=await import("./headless-io-FFM5T6KL.js"),m=x("ndjson","design");m.event({type:"error",code:o.code,message:`design: ${o.detail}`,next:[o.reviewCmd]});let g=`kane-cli design tests --use-case ${s.useCase} --mode agent --allow-unreviewed`;return m.event({type:"done",status:"refused",exit_code:2,next:b?[o.reviewCmd,g]:[o.reviewCmd]}),2}else return process.stderr.write(`design: ${o.detail} (${o.reviewCmd})
|
|
8
8
|
`),2}}catch(e){process.env.KANE_DEBUG&&process.stderr.write(`trust gate skipped: ${String(e)}
|
|
9
9
|
`)}let n=null,f=null;try{if(!s.mode&&!process.stdin.isTTY)return process.stderr.write(`design: no TTY \u2014 pass an explicit --mode agent|ci|override to run headless
|
|
10
10
|
`),2;let e=s.mode??"interactive";if(e==="interactive"){if(!process.stdin.isTTY||!process.stdout.isTTY)return process.stderr.write(`design: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
|
|
11
|
-
`),2;let{bindDesignInteractive:a}=await import("./interactive-bind-
|
|
11
|
+
`),2;let{bindDesignInteractive:a}=await import("./interactive-bind-F7QTQOKC.js");return await a(s)}let{runAgent:r}=await import("./bridge-SPGIYAAG.js"),{makeInterruptGuard:i}=await import("./interrupt-guard-QETBPINI.js"),{baseUrlAdvisory:d}=await import("./turn-preflight-R4PU6NYY.js"),{makeHeadlessIO:y,resolveEncoding:o,guardedChannels:b}=await import("./headless-io-FFM5T6KL.js"),{withStructuredNext:T,prepareStructuredResume:x}=await import("./structured-answers-EQ2AP3F7.js");n=T(y(o(e,l),"design"));let m=await G(u(process.cwd()));m&&(o(e,l)==="ndjson"?n.event(I(m)):n.progress(m.text));let g=n,k=a=>{g.out(a),g.event({type:"note",text:a})},{telemetryBootstrap:Y,telemetryEnvName:H}=await import("./bootstrap-BV7HAARR.js"),v=Y({verb:"design",mode:e,contextRoot:u(process.cwd()),env:H(),resumeSid:s.resume,write:!0,longSession:!0});f=a=>v.end(a);let c=x({opts:t,reader:S(u(process.cwd())).sessions(),verb:"design"});if(c.kind==="refuse")return n.out(c.error),e==="agent"&&n.event({type:"error",message:c.error,code:c.code}),await v.end({exit_code:2}),e==="agent"?n.done(2,"refused"):2;let D;if(c.kind==="apply"){for(let a of c.notes)k(a);if(c.matchedQids.length>0){k(`applying ${c.matchedQids.length} structured answer(s) from --answer to the paused session's pending questions`);for(let a of c.matchedQids)n.event({type:"panel_resolved",id:a,by:"user",via:"flag"})}c.statement&&(D=[s.message,c.statement].filter(Boolean).join(`
|
|
12
12
|
|
|
13
|
-
`))}let R=d();R&&k(R);let C=i(r,a=>n.out(a)),j=b(n,()=>C.interrupted(),/^error: (design agent failed|the design agent ended)/);try{let a=e==="interactive"&&process.stdin.isTTY&&process.stdout.isTTY?async E=>{let{createInterface:L}=await import("readline/promises"),A=L({input:process.stdin,output:process.stdout});try{return/^y(es)?$/i.test((await A.question(`${E} [y/N] `)).trim())}finally{A.close()}}:void 0,{headlessDesign:P}=await import("./design-headless-
|
|
13
|
+
`))}let R=d();R&&k(R);let C=i(r,a=>n.out(a)),j=b(n,()=>C.interrupted(),/^error: (design agent failed|the design agent ended)/);try{let a=e==="interactive"&&process.stdin.isTTY&&process.stdout.isTTY?async E=>{let{createInterface:L}=await import("readline/promises"),A=L({input:process.stdin,output:process.stdout});try{return/^y(es)?$/i.test((await A.question(`${E} [y/N] `)).trim())}finally{A.close()}}:void 0,{headlessDesign:P}=await import("./design-headless-DR7WB37W.js"),{localSite:K}=await import("./store-site-AFXB6SBW.js"),$=u(process.cwd()),w=await P({...s,mode:e,...D!==void 0?{message:D}:{},...a?{confirmRetarget:a}:{}},K($,S($)),{out:j.out,emit:E=>{t.onEvent?.(E),j.emit(E)},progress:g.progress,channel:o(e,l)==="ndjson"},{agent:C.agent,telemetry:v});if(C.interrupted()&&w!==3)return n.out("interrupted \u2014 no session saved"),await v.end({exit_code:130}),n.done(130);if(w===1&&n.out(v.supportFooter()),await v.end({exit_code:w}),w!==0)return n.done(w);let U=await z($,s.useCase,s.resume);return U.length>0?n.done(w,void 0,U):n.done(w)}finally{C.dispose()}}catch(e){if(e instanceof N)return f&&await f({exit_code:2}).catch(()=>{}),n?(n.event(_({code:e.code,text:e.message,remedy:e.remedy})),n.done(2,"refused")):(process.stderr.write(`error: ${e.message}
|
|
14
14
|
next: ${e.remedy}
|
|
15
15
|
`),2);f&&await f({exit_code:1}).catch(()=>{});let r=e instanceof Error?e.message:String(e);n?.event({type:"error",message:`error: design failed: ${r}`});let i=n?d=>n.out(d):d=>process.stderr.write(d+`
|
|
16
|
-
`);return i(`error: design failed: ${r}`),(process.env.ASSURANCE_LOG_LEVEL??"").toLowerCase()==="debug"&&e instanceof Error&&e.stack&&i(e.stack),i('hint: the full trace is in the file named on the "trace:" line at the start of this run'),n?n.done(1):1}}async function z(t,p,l){try{let[{openGraph:h},{peekSession:s},{awaitingOfUseCase:n},{shellArg:f}]=await Promise.all([import("./readmodel-
|
|
16
|
+
`);return i(`error: design failed: ${r}`),(process.env.ASSURANCE_LOG_LEVEL??"").toLowerCase()==="debug"&&e instanceof Error&&e.stack&&i(e.stack),i('hint: the full trace is in the file named on the "trace:" line at the start of this run'),n?n.done(1):1}}async function z(t,p,l){try{let[{openGraph:h},{peekSession:s},{awaitingOfUseCase:n},{shellArg:f}]=await Promise.all([import("./readmodel-FARAAPUU.js"),import("./sessions-NH2EG7BP.js"),import("./stream-warnings-I5LUWVFU.js"),import("./shell-arg-FN3MT5U7.js")]),e=p??(l?s(t,l)?.use_case:void 0);if(!e)return[];let r=h(t);return[...n(r,e)].map(([i,d])=>({cmd:`kane-cli context review --approve ${f(r.displayNameOf(i)??i.slice(0,19))} --mode agent`,why:`approves the criterion ${d.size===1?"1 test checks":`${d.size} tests check`}`}))}catch{return[]}}export{B as a,Z as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{g as o,h as a}from"./chunk-
|
|
2
|
+
import{g as o,h as a}from"./chunk-LV7OWLJK.js";import{mkdirSync as p,writeFileSync as f,chmodSync as d,existsSync as m}from"fs";var y={darwin:"https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute",linux:"https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute",win32:"https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe"};function h(s){let t=y[s];if(!t)throw new Error(`unsupported platform for hyperexecute: ${s}`);return t}async function g(s,t={}){let i=t.platform??process.platform,u=t.existsImpl??m,c=t.fetchImpl??(r=>fetch(r)),e=a(s);if(u(e))return{status:"present",path:e};try{let r=h(i),n=await c(r);if(!n.ok)return{status:"failed",path:e,error:`download failed: HTTP ${n.status}`};let l=Buffer.from(await n.arrayBuffer());return p(o(s),{recursive:!0}),f(e,l),d(e,493),{status:"downloaded",path:e}}catch(r){return{status:"failed",path:e,error:r instanceof Error?r.message:String(r)}}}export{h as a,g as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{g as f}from"./chunk-47WQBG5I.js";import{a as l}from"./chunk-KM3YCIDV.js";import{i as u}from"./chunk-
|
|
2
|
+
import{g as f}from"./chunk-47WQBG5I.js";import{a as l}from"./chunk-KM3YCIDV.js";import{i as u}from"./chunk-YIBLZIXF.js";import{a as c}from"./chunk-FH4FWIET.js";import{f as s}from"./chunk-CB344EDO.js";import{c as p}from"./chunk-GBQ4K25P.js";import{b as i}from"./chunk-ATCJ7EHL.js";async function E(n,o,e,t){let m=async()=>{let r=t.auth??{...await s(i),...t.telemetry?.spawnEnv()??{}};return u(e.sid!==void 0&&n.resume===void 0?{...n,sessionId:e.sid}:n,{store:o.store,pendingReconcilePlan:a=>o.dir===null?null:f(o.dir,a),agent:t.agent,tracePath:c,credentials:i,onIngestRefusal:l,preflightTurn:t.preflightTurn??(()=>p(r)),ask:async()=>[],review:async a=>new Map(a.map(d=>[d.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!1,out:e.out,...e.note?{note:e.note}:{},emit:e.emit,progress:e.progress,isTTY:!1,auth:r,...t.telemetry?{telemetry:t.telemetry}:{},...t.probe?{probe:t.probe}:{},...t.matchUnreviewed?{matchUnreviewed:!0}:{},...e.onSummary?{onSummary:e.onSummary}:{}})};if(!e.channel)return m();let{runWithChannel:g}=await import("./run-channel-IIIYXOIW.js");return g({event:r=>e.emit(r)},m)}export{E as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as J,d as X,h as B,i as Y,j as Q,k as V,l as Z,m as ee,n as te,o as F,p as ne}from"./chunk-7V34ZMMS.js";import{d as P}from"./chunk-B7ZX5HEN.js";import{I as se,J as oe,L as R,M as E,N as ae,Na as k,a as ie,r as A}from"./chunk-PI7OXS62.js";import{f as x,h as re}from"./chunk-KU3YHPWZ.js";import{existsSync as D,readFileSync as I,renameSync as $e,writeFileSync as Ee}from"fs";import{dirname as q,isAbsolute as T,resolve as N}from"path";var ve=new Set(["inline","testmd","testrun"]),ye=new Set(["inferred","authored","runtime-derived"]),C=new Set(["passed","failed","broken","skipped"]);function ce(t,e,n){if(n.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"a run with no designed units attaches no facts \u2014 skip the call"}]};let a=e;for(let s=0;;s++){let o=t.head(),c=t.serialize(o);if(!t.sameToken(t.parse(a.latestHash),o)){if(s>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:`graph opened at ${String(a.latestHash)} but chain head is ${String(c)} \u2014 retry budget exhausted`}]};a=E(t);continue}let d=be(t,a,n);if(d!=="cas")return d;if(s>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 retry budget exhausted"}]};a=E(t)}}function de(t,e){return ve.has(t.mode)?C.has(t.verdict)?ye.has(t.oracle_mode)?typeof t.drift_flag!="boolean"||typeof t.stale_at_run!="boolean"?[{code:"MISSING_FIELD",detail:`${e}: drift_flag and stale_at_run are required booleans`}]:!t.execution_id||!t.started_at||!t.definition_id_at_run?[{code:"MISSING_FIELD",detail:`${e}: execution_id, started_at and definition_id_at_run are required`}]:[]:[{code:"BAD_ORACLE_MODE",detail:`${e}: oracle_mode '${t.oracle_mode}' not in inferred|authored|runtime-derived`}]:[{code:"BAD_VERDICT",detail:`${e}: verdict '${t.verdict}' not in ${[...C].join("|")}`}]:[{code:"BAD_MODE",detail:`${e}: mode '${t.mode}' not in inline|testmd|testrun`}]}function ue(t,e,n,a){return{about:e,definition_id_at_run:t.definition_id_at_run,verdict:t.verdict,...n&&n.length?{per_ac:n}:{},drift_flag:t.drift_flag,oracle_mode:t.oracle_mode,stale_at_run:t.stale_at_run,...a.length?{unresolved_acs:a}:{},execution_id:t.execution_id,...t.evidence_id?{evidence_id:t.evidence_id}:{},...t.duration_ms!==void 0?{duration_ms:t.duration_ms}:{},started_at:t.started_at,mode:t.mode,local:t.local,...t.via_parent?{via_parent:t.via_parent}:{}}}function pe(t,e,n={}){if(!Array.isArray(e.facts)||e.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"parked line carries no facts"}]};for(let a=0;;a++){let s=E(t),o=e.facts.filter(r=>s.appliedEvents.has(r.event_id)).map(r=>r.event_id),c=e.facts.filter(r=>!s.appliedEvents.has(r.event_id));if(c.length===0)return{record:null,errors:null,applied:[],skipped:o,rejected:[]};let d=[],u=[],l=[],h=[];for(let r of c){let i=`executions[${r.ref}]`,f=[];if(!r.about_cid||!s.hasNode(r.about_cid))f.push({code:"UNKNOWN_REF",detail:`${i}: about_cid '${String(r.about_cid)}' is not in the graph \u2014 the pinned run-time target is gone`});else if(s.nodeLabel.get(r.about_cid)!==x.TEST)f.push({code:"ILLEGAL_TARGET",detail:`${i}: execution facts attach to tests \u2014 '${r.about_cid}' is a ${s.nodeLabel.get(r.about_cid)}`});else if(!r.event_id)f.push({code:"MISSING_FIELD",detail:`${i}: parked facts require event_id`});else{f.push(...de(r,i));for(let g of r.per_ac??[])C.has(g.verdict)||f.push({code:"BAD_VERDICT",detail:`${i}.per_ac['${g.ac_ref}']: verdict '${g.verdict}'`})}if(f.length>0){d.push({event_id:r.event_id??"",errors:f});continue}let p=[],m=[],v=[...r.unresolved_acs??[]];for(let g of r.per_ac??[]){let $=g.ac_cid&&s.hasNode(g.ac_cid)&&s.nodeLabel.get(g.ac_cid)===x.AC?g.ac_cid:null,y=$?null:s.resolve(g.ac_ref),_=$??(y?s.tipOf(y.cid):null);if(!_||!$&&(s.superseded.has(_)||s.nodeLabel.get(_)!==x.AC)){v.push(g.ac_ref);continue}p.push({ac_ref:s.nameOf.get(_)??g.ac_ref,ac_cid:_,verdict:g.verdict}),m.push(_)}u.push(ue(r,r.about_cid,p,v)),h.push({about_cid:r.about_cid,per_ac:m}),l.push(r.event_id)}if(u.length===0)return{record:null,errors:null,applied:[],skipped:o,rejected:d};try{let r=R(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:u,event_ids:[...l].sort(),source_head_moves:{}},{returnWarnings:!0,graph:s,expectPrev:s.latestHash,intent:{v:1,verb:"parked",args:A({line:e}),pins:{facts:h}},busyRetry:{deadlineMs:5e3},provenance:n.provenance});return{record:r.record,errors:null,applied:l,skipped:o,rejected:d,...r.warnings?{warnings:r.warnings}:{}}}catch(r){if(!(r instanceof k))throw r;if(a>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 parked replay retry budget exhausted (line stays queued)"}]}}}}function be(t,e,n){let a=[],s=[],o=[];for(let d of n.facts){let u=`executions[${d.ref}]`,l=n.pinned?null:e.resolve(d.ref),h=n.pinned?d.about_cid&&e.hasNode(d.about_cid)?d.about_cid:null:l?e.tipOf(l.cid):null;if(!h||!n.pinned&&e.superseded.has(h)){a.push({code:"UNKNOWN_REF",detail:`${u}: '${n.pinned?String(d.about_cid):d.ref}' is not a ${n.pinned?"":"live "}committed node`});continue}if(e.nodeLabel.get(h)!==x.TEST){a.push({code:"ILLEGAL_TARGET",detail:`${u}: execution facts attach to tests \u2014 '${d.ref}' is a ${e.nodeLabel.get(h)}`});continue}let r=de(d,u);if(r.length>0){a.push(...r);continue}let i=[],f=[];for(let p of d.per_ac??[]){let m=n.pinned?null:e.resolve(p.ac_ref),v=n.pinned?p.ac_cid&&e.hasNode(p.ac_cid)?p.ac_cid:null:m?e.tipOf(m.cid):null;if(!v||!n.pinned&&e.superseded.has(v)||e.nodeLabel.get(v)!==x.AC){a.push({code:"UNKNOWN_REF",detail:`${u}.per_ac: '${n.pinned?String(p.ac_cid):p.ac_ref}' is not a${n.pinned?"n":" live"} AC`});continue}if(!C.has(p.verdict)){a.push({code:"BAD_VERDICT",detail:`${u}.per_ac['${p.ac_ref}']: verdict '${p.verdict}'`});continue}i.push({ac_ref:e.nameOf.get(v)??v,ac_cid:v,verdict:p.verdict}),f.push(v)}s.push(ue(d,h,i,d.unresolved_acs??[])),o.push({about_cid:h,per_ac:f})}if(a.length>0)return{record:null,errors:a};let c;try{c=R(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:s,...n.eventIds&&n.eventIds.length>0?{event_ids:n.eventIds}:{},source_head_moves:{}},{returnWarnings:!0,graph:e,expectPrev:e.latestHash,intent:{v:1,verb:"execution",args:A({facts:n.facts,by:n.by,eventIds:n.eventIds??null}),pins:{facts:o}},busyRetry:{deadlineMs:n.lockDeadlineMs??5e3},provenance:n.provenance})}catch(d){if(d instanceof k)return"cas";throw d}return{record:c.record,errors:null,...c.warnings?{warnings:c.warnings}:{}}}function Ye(t){let e={failed:3,broken:2,skipped:1,passed:0},n=new Map;for(let a of t)for(let s of a.verifies??[]){let o=n.get(s);(o===void 0||(e[a.status]??0)>(e[o]??0))&&n.set(s,a.status)}return[...n.entries()].map(([a,s])=>({ref:a,verdict:s}))}function Qe(t){let e=[],{store:n}=t;if(!n.exists())return{synced:0,superseded:0,skipped:"no-context",warnings:e};let a=t.by??{kind:"ai",id:"exec-sync"},s=t.lockDeadlineMs;try{Se(n,e,s)}catch(i){e.push(`sync: parked-facts replay failed (${i instanceof Error?i.message:String(i)}) \u2014 queue intact, retrying next sync`)}let o=E(n),c=[],d=0,u=new Set,l=new Set(t.members.map(i=>T(i.path)?i.path:N(t.projectDir,i.path))),h=new Map;for(let i of t.members){let f=T(i.path)?i.path:N(t.projectDir,i.path);if(!D(f)){e.push(`sync: member file missing: ${f} \u2014 skipped, no fact attached`);continue}for(let p of xe(f,e))if(!u.has(p.path))try{let m=p.path===f,v=!m&&l.has(p.path),g=m?void 0:F(I(f,"utf8"))?.id,$=I(p.path,"utf8"),y=F($);if(!y?.id){u.add(p.path);continue}let _=o.resolve(y.id),S=_?o.tipOf(_.cid):null;if(!_||!S||o.superseded.has(S)){u.add(p.path),e.push(`sync: ${y.id} does not resolve to a live test \u2014 skipped (foreign store?)`);continue}let L=B(V($,ee(q(p.path),o))),_e=String(o.getNode(S)?.content.test_md_blob??""),j=B(V(_e,Z(o))),G=o.getNode(S)?.content.definitionId,M=typeof G=="string"?G:j,w=!1,O=S;if(L===j)y.base!==M&&he(p.path,$,M,e);else if(y.base===j||y.base===M){let b=Ie(n,o,S,$,L,q(p.path),a);b.error?(e.push(`sync: could not supersede ${y.id}: ${b.error}`),w=!0):(d++,O=b.newCid,w=b.oracleTier,he(p.path,I(p.path,"utf8"),L,e),o=E(n))}else w=!0,e.push(y.base?`sync: ${y.id} was edited from an older version \u2014 graph kept; reconcile via a redesign or maintain`:`sync: ${y.id} carries no base pin (hand-copied file?) \u2014 fact attached with drift flag`);if(v){w&&h.set(p.path,!0);continue}u.add(p.path);let H=o.getNode(O)?.content.check,W=m?i.acs??[]:[],U=W.filter(b=>fe(o,b.ref)),z=W.filter(b=>!fe(o,b.ref)).map(b=>b.ref);c.push({ref:y.id,about_cid:O,definition_id_at_run:L,verdict:i.verdict,...U.length?{per_ac:U.map(b=>{let K=ge(o,b.ref);return{ac_ref:b.ref,...K?{ac_cid:K}:{},verdict:b.verdict}})}:{},drift_flag:w||h.get(p.path)===!0||m&&i.driftFlag===!0,oracle_mode:H?.expected_mode??(J(H?.operand)?"runtime-derived":"inferred"),stale_at_run:o.stale(O)!=="fresh",...z.length?{unresolved_acs:z}:{},execution_id:i.executionId,...i.evidenceId?{evidence_id:i.evidenceId}:{},...i.durationMs!==void 0?{duration_ms:i.durationMs}:{},started_at:i.startedAt,mode:i.mode,local:i.local,...g?{via_parent:g}:{}})}catch(m){p.path!==f&&l.has(p.path)||u.add(p.path),e.push(`sync: ${p.path} failed to sync (${m instanceof Error?m.message:String(m)}) \u2014 skipped; other members unaffected`)}}if(c.length===0)return{synced:0,superseded:d,warnings:e};let r;try{r=ce(n,E(n),{facts:c,by:a,eventIds:c.map(i=>`exec-fact:${i.execution_id}:${i.ref}`),lockDeadlineMs:s})}catch(i){return e.push(`sync facts: commit threw: ${i instanceof Error?i.message:String(i)}`),le(n,c,a,e,s),{synced:0,superseded:d,warnings:e}}return r.errors?(le(n,c,a,e,s),e.push(...r.errors.map(i=>`sync facts: ${i.code}: ${i.detail}`)),{synced:0,superseded:d,warnings:e}):(r.warnings&&e.push(...r.warnings.map(i=>`sync facts: ${i}`)),{synced:c.length,superseded:d,warnings:e})}function le(t,e,n,a,s){try{let o={by:n,ts:new Date().toISOString(),facts:e.map(u=>({...u,about_cid:u.about_cid??"",event_id:`exec-fact:${u.execution_id}:${u.ref}`}))},{where:c,sideFile:d}=t.parkedFacts().park(JSON.stringify(o),{deadlineMs:s??5e3});d&&a.push(`sync facts: store lock busy \u2014 parked to ${c}; it drains on the next sync`),a.push(`sync facts: commit failed \u2014 ${e.length} fact(s) parked to ${c}; they replay on the next sync`)}catch(o){a.push(`sync facts: could not park the failed batch (${o instanceof Error?o.message:String(o)}) \u2014 this run's facts are LOST`)}}function Se(t,e,n){let a=t.parkedFacts(),s=n??5e3,o=a.snapshot({deadlineMs:s});if("fenced"in o){e.push(`sync: parked facts stay queued while rebase ${o.fenced} is open \u2014 they drain on the first sync after it is finished`);return}let c=o.lines;if(c.length===0)return;let d=new Set,u=[];for(let l of c){let h=null;try{let i=JSON.parse(l);i&&Array.isArray(i.facts)&&(h=i)}catch{}if(!h){u.push({parent:l,line:l}),d.add(l);continue}let r=pe(t,h);if(r.errors){if(r.errors.some(i=>i.code==="STALE_BASIS")){e.push(`sync: parked facts replay deferred (${r.errors[0].detail}) \u2014 retrying next sync`);continue}u.push({parent:l,line:l}),d.add(l),e.push(`sync: parked facts line quarantined to ${a.quarantinePath} (${r.errors.map(i=>`${i.code}: ${i.detail}`).join("; ")})`);continue}for(let i of r.rejected){let f=h.facts.find(p=>p.event_id===i.event_id);u.push({parent:l,line:JSON.stringify({...f??{event_id:i.event_id},_reason:i.errors})})}if(r.rejected.length>0){let i=r.rejected.map(f=>f.errors.map(p=>`${p.code}: ${p.detail}`).join("; ")).join(" | ");e.push(`sync: ${r.rejected.length} parked fact(s) quarantined to ${a.quarantinePath} (${i})`)}d.add(l),r.warnings&&e.push(...r.warnings.map(i=>`sync: ${i}`)),r.applied.length>0&&e.push(`sync: replayed ${r.applied.length} parked fact(s) from a previous run`)}if(d.size!==0)try{a.settle(d,u,{deadlineMs:s})}catch(l){e.push(`sync: queue rewrite failed (${l instanceof Error?l.message:String(l)}) \u2014 already-applied lines dedupe next sync; bad lines re-quarantine then`)}}function xe(t,e){let n=[],a=new Set,s=o=>{if(a.has(o)||!D(o))return;a.add(o);let c;try{c=I(o,"utf8")}catch(d){e.push(`sync: unreadable unit ${o} (${d instanceof Error?d.message:String(d)}) \u2014 skipped`);return}for(let d of c.split(`
|
|
2
|
+
import{I as se,J as oe,L as R,M as E,N as ae,Na as k,a as ie,r as A}from"./chunk-5EAJO372.js";import{f as x,h as re}from"./chunk-KU3YHPWZ.js";import{a as J,d as X,h as B,i as Y,j as Q,k as V,l as Z,m as ee,n as te,o as F,p as ne}from"./chunk-OKCVG7AG.js";import{d as P}from"./chunk-XDAFRUAJ.js";import{existsSync as D,readFileSync as I,renameSync as $e,writeFileSync as Ee}from"fs";import{dirname as q,isAbsolute as T,resolve as N}from"path";var ve=new Set(["inline","testmd","testrun"]),ye=new Set(["inferred","authored","runtime-derived"]),C=new Set(["passed","failed","broken","skipped"]);function ce(t,e,n){if(n.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"a run with no designed units attaches no facts \u2014 skip the call"}]};let a=e;for(let s=0;;s++){let o=t.head(),c=t.serialize(o);if(!t.sameToken(t.parse(a.latestHash),o)){if(s>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:`graph opened at ${String(a.latestHash)} but chain head is ${String(c)} \u2014 retry budget exhausted`}]};a=E(t);continue}let d=be(t,a,n);if(d!=="cas")return d;if(s>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 retry budget exhausted"}]};a=E(t)}}function de(t,e){return ve.has(t.mode)?C.has(t.verdict)?ye.has(t.oracle_mode)?typeof t.drift_flag!="boolean"||typeof t.stale_at_run!="boolean"?[{code:"MISSING_FIELD",detail:`${e}: drift_flag and stale_at_run are required booleans`}]:!t.execution_id||!t.started_at||!t.definition_id_at_run?[{code:"MISSING_FIELD",detail:`${e}: execution_id, started_at and definition_id_at_run are required`}]:[]:[{code:"BAD_ORACLE_MODE",detail:`${e}: oracle_mode '${t.oracle_mode}' not in inferred|authored|runtime-derived`}]:[{code:"BAD_VERDICT",detail:`${e}: verdict '${t.verdict}' not in ${[...C].join("|")}`}]:[{code:"BAD_MODE",detail:`${e}: mode '${t.mode}' not in inline|testmd|testrun`}]}function ue(t,e,n,a){return{about:e,definition_id_at_run:t.definition_id_at_run,verdict:t.verdict,...n&&n.length?{per_ac:n}:{},drift_flag:t.drift_flag,oracle_mode:t.oracle_mode,stale_at_run:t.stale_at_run,...a.length?{unresolved_acs:a}:{},execution_id:t.execution_id,...t.evidence_id?{evidence_id:t.evidence_id}:{},...t.duration_ms!==void 0?{duration_ms:t.duration_ms}:{},started_at:t.started_at,mode:t.mode,local:t.local,...t.via_parent?{via_parent:t.via_parent}:{}}}function pe(t,e,n={}){if(!Array.isArray(e.facts)||e.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"parked line carries no facts"}]};for(let a=0;;a++){let s=E(t),o=e.facts.filter(r=>s.appliedEvents.has(r.event_id)).map(r=>r.event_id),c=e.facts.filter(r=>!s.appliedEvents.has(r.event_id));if(c.length===0)return{record:null,errors:null,applied:[],skipped:o,rejected:[]};let d=[],u=[],l=[],h=[];for(let r of c){let i=`executions[${r.ref}]`,f=[];if(!r.about_cid||!s.hasNode(r.about_cid))f.push({code:"UNKNOWN_REF",detail:`${i}: about_cid '${String(r.about_cid)}' is not in the graph \u2014 the pinned run-time target is gone`});else if(s.nodeLabel.get(r.about_cid)!==x.TEST)f.push({code:"ILLEGAL_TARGET",detail:`${i}: execution facts attach to tests \u2014 '${r.about_cid}' is a ${s.nodeLabel.get(r.about_cid)}`});else if(!r.event_id)f.push({code:"MISSING_FIELD",detail:`${i}: parked facts require event_id`});else{f.push(...de(r,i));for(let g of r.per_ac??[])C.has(g.verdict)||f.push({code:"BAD_VERDICT",detail:`${i}.per_ac['${g.ac_ref}']: verdict '${g.verdict}'`})}if(f.length>0){d.push({event_id:r.event_id??"",errors:f});continue}let p=[],m=[],v=[...r.unresolved_acs??[]];for(let g of r.per_ac??[]){let $=g.ac_cid&&s.hasNode(g.ac_cid)&&s.nodeLabel.get(g.ac_cid)===x.AC?g.ac_cid:null,y=$?null:s.resolve(g.ac_ref),_=$??(y?s.tipOf(y.cid):null);if(!_||!$&&(s.superseded.has(_)||s.nodeLabel.get(_)!==x.AC)){v.push(g.ac_ref);continue}p.push({ac_ref:s.nameOf.get(_)??g.ac_ref,ac_cid:_,verdict:g.verdict}),m.push(_)}u.push(ue(r,r.about_cid,p,v)),h.push({about_cid:r.about_cid,per_ac:m}),l.push(r.event_id)}if(u.length===0)return{record:null,errors:null,applied:[],skipped:o,rejected:d};try{let r=R(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:u,event_ids:[...l].sort(),source_head_moves:{}},{returnWarnings:!0,graph:s,expectPrev:s.latestHash,intent:{v:1,verb:"parked",args:A({line:e}),pins:{facts:h}},busyRetry:{deadlineMs:5e3},provenance:n.provenance});return{record:r.record,errors:null,applied:l,skipped:o,rejected:d,...r.warnings?{warnings:r.warnings}:{}}}catch(r){if(!(r instanceof k))throw r;if(a>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 parked replay retry budget exhausted (line stays queued)"}]}}}}function be(t,e,n){let a=[],s=[],o=[];for(let d of n.facts){let u=`executions[${d.ref}]`,l=n.pinned?null:e.resolve(d.ref),h=n.pinned?d.about_cid&&e.hasNode(d.about_cid)?d.about_cid:null:l?e.tipOf(l.cid):null;if(!h||!n.pinned&&e.superseded.has(h)){a.push({code:"UNKNOWN_REF",detail:`${u}: '${n.pinned?String(d.about_cid):d.ref}' is not a ${n.pinned?"":"live "}committed node`});continue}if(e.nodeLabel.get(h)!==x.TEST){a.push({code:"ILLEGAL_TARGET",detail:`${u}: execution facts attach to tests \u2014 '${d.ref}' is a ${e.nodeLabel.get(h)}`});continue}let r=de(d,u);if(r.length>0){a.push(...r);continue}let i=[],f=[];for(let p of d.per_ac??[]){let m=n.pinned?null:e.resolve(p.ac_ref),v=n.pinned?p.ac_cid&&e.hasNode(p.ac_cid)?p.ac_cid:null:m?e.tipOf(m.cid):null;if(!v||!n.pinned&&e.superseded.has(v)||e.nodeLabel.get(v)!==x.AC){a.push({code:"UNKNOWN_REF",detail:`${u}.per_ac: '${n.pinned?String(p.ac_cid):p.ac_ref}' is not a${n.pinned?"n":" live"} AC`});continue}if(!C.has(p.verdict)){a.push({code:"BAD_VERDICT",detail:`${u}.per_ac['${p.ac_ref}']: verdict '${p.verdict}'`});continue}i.push({ac_ref:e.nameOf.get(v)??v,ac_cid:v,verdict:p.verdict}),f.push(v)}s.push(ue(d,h,i,d.unresolved_acs??[])),o.push({about_cid:h,per_ac:f})}if(a.length>0)return{record:null,errors:a};let c;try{c=R(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:s,...n.eventIds&&n.eventIds.length>0?{event_ids:n.eventIds}:{},source_head_moves:{}},{returnWarnings:!0,graph:e,expectPrev:e.latestHash,intent:{v:1,verb:"execution",args:A({facts:n.facts,by:n.by,eventIds:n.eventIds??null}),pins:{facts:o}},busyRetry:{deadlineMs:n.lockDeadlineMs??5e3},provenance:n.provenance})}catch(d){if(d instanceof k)return"cas";throw d}return{record:c.record,errors:null,...c.warnings?{warnings:c.warnings}:{}}}function Ye(t){let e={failed:3,broken:2,skipped:1,passed:0},n=new Map;for(let a of t)for(let s of a.verifies??[]){let o=n.get(s);(o===void 0||(e[a.status]??0)>(e[o]??0))&&n.set(s,a.status)}return[...n.entries()].map(([a,s])=>({ref:a,verdict:s}))}function Qe(t){let e=[],{store:n}=t;if(!n.exists())return{synced:0,superseded:0,skipped:"no-context",warnings:e};let a=t.by??{kind:"ai",id:"exec-sync"},s=t.lockDeadlineMs;try{Se(n,e,s)}catch(i){e.push(`sync: parked-facts replay failed (${i instanceof Error?i.message:String(i)}) \u2014 queue intact, retrying next sync`)}let o=E(n),c=[],d=0,u=new Set,l=new Set(t.members.map(i=>T(i.path)?i.path:N(t.projectDir,i.path))),h=new Map;for(let i of t.members){let f=T(i.path)?i.path:N(t.projectDir,i.path);if(!D(f)){e.push(`sync: member file missing: ${f} \u2014 skipped, no fact attached`);continue}for(let p of xe(f,e))if(!u.has(p.path))try{let m=p.path===f,v=!m&&l.has(p.path),g=m?void 0:F(I(f,"utf8"))?.id,$=I(p.path,"utf8"),y=F($);if(!y?.id){u.add(p.path);continue}let _=o.resolve(y.id),S=_?o.tipOf(_.cid):null;if(!_||!S||o.superseded.has(S)){u.add(p.path),e.push(`sync: ${y.id} does not resolve to a live test \u2014 skipped (foreign store?)`);continue}let L=B(V($,ee(q(p.path),o))),_e=String(o.getNode(S)?.content.test_md_blob??""),j=B(V(_e,Z(o))),G=o.getNode(S)?.content.definitionId,M=typeof G=="string"?G:j,w=!1,O=S;if(L===j)y.base!==M&&he(p.path,$,M,e);else if(y.base===j||y.base===M){let b=Ie(n,o,S,$,L,q(p.path),a);b.error?(e.push(`sync: could not supersede ${y.id}: ${b.error}`),w=!0):(d++,O=b.newCid,w=b.oracleTier,he(p.path,I(p.path,"utf8"),L,e),o=E(n))}else w=!0,e.push(y.base?`sync: ${y.id} was edited from an older version \u2014 graph kept; reconcile via a redesign or maintain`:`sync: ${y.id} carries no base pin (hand-copied file?) \u2014 fact attached with drift flag`);if(v){w&&h.set(p.path,!0);continue}u.add(p.path);let H=o.getNode(O)?.content.check,W=m?i.acs??[]:[],U=W.filter(b=>fe(o,b.ref)),z=W.filter(b=>!fe(o,b.ref)).map(b=>b.ref);c.push({ref:y.id,about_cid:O,definition_id_at_run:L,verdict:i.verdict,...U.length?{per_ac:U.map(b=>{let K=ge(o,b.ref);return{ac_ref:b.ref,...K?{ac_cid:K}:{},verdict:b.verdict}})}:{},drift_flag:w||h.get(p.path)===!0||m&&i.driftFlag===!0,oracle_mode:H?.expected_mode??(J(H?.operand)?"runtime-derived":"inferred"),stale_at_run:o.stale(O)!=="fresh",...z.length?{unresolved_acs:z}:{},execution_id:i.executionId,...i.evidenceId?{evidence_id:i.evidenceId}:{},...i.durationMs!==void 0?{duration_ms:i.durationMs}:{},started_at:i.startedAt,mode:i.mode,local:i.local,...g?{via_parent:g}:{}})}catch(m){p.path!==f&&l.has(p.path)||u.add(p.path),e.push(`sync: ${p.path} failed to sync (${m instanceof Error?m.message:String(m)}) \u2014 skipped; other members unaffected`)}}if(c.length===0)return{synced:0,superseded:d,warnings:e};let r;try{r=ce(n,E(n),{facts:c,by:a,eventIds:c.map(i=>`exec-fact:${i.execution_id}:${i.ref}`),lockDeadlineMs:s})}catch(i){return e.push(`sync facts: commit threw: ${i instanceof Error?i.message:String(i)}`),le(n,c,a,e,s),{synced:0,superseded:d,warnings:e}}return r.errors?(le(n,c,a,e,s),e.push(...r.errors.map(i=>`sync facts: ${i.code}: ${i.detail}`)),{synced:0,superseded:d,warnings:e}):(r.warnings&&e.push(...r.warnings.map(i=>`sync facts: ${i}`)),{synced:c.length,superseded:d,warnings:e})}function le(t,e,n,a,s){try{let o={by:n,ts:new Date().toISOString(),facts:e.map(u=>({...u,about_cid:u.about_cid??"",event_id:`exec-fact:${u.execution_id}:${u.ref}`}))},{where:c,sideFile:d}=t.parkedFacts().park(JSON.stringify(o),{deadlineMs:s??5e3});d&&a.push(`sync facts: store lock busy \u2014 parked to ${c}; it drains on the next sync`),a.push(`sync facts: commit failed \u2014 ${e.length} fact(s) parked to ${c}; they replay on the next sync`)}catch(o){a.push(`sync facts: could not park the failed batch (${o instanceof Error?o.message:String(o)}) \u2014 this run's facts are LOST`)}}function Se(t,e,n){let a=t.parkedFacts(),s=n??5e3,o=a.snapshot({deadlineMs:s});if("fenced"in o){e.push(`sync: parked facts stay queued while rebase ${o.fenced} is open \u2014 they drain on the first sync after it is finished`);return}let c=o.lines;if(c.length===0)return;let d=new Set,u=[];for(let l of c){let h=null;try{let i=JSON.parse(l);i&&Array.isArray(i.facts)&&(h=i)}catch{}if(!h){u.push({parent:l,line:l}),d.add(l);continue}let r=pe(t,h);if(r.errors){if(r.errors.some(i=>i.code==="STALE_BASIS")){e.push(`sync: parked facts replay deferred (${r.errors[0].detail}) \u2014 retrying next sync`);continue}u.push({parent:l,line:l}),d.add(l),e.push(`sync: parked facts line quarantined to ${a.quarantinePath} (${r.errors.map(i=>`${i.code}: ${i.detail}`).join("; ")})`);continue}for(let i of r.rejected){let f=h.facts.find(p=>p.event_id===i.event_id);u.push({parent:l,line:JSON.stringify({...f??{event_id:i.event_id},_reason:i.errors})})}if(r.rejected.length>0){let i=r.rejected.map(f=>f.errors.map(p=>`${p.code}: ${p.detail}`).join("; ")).join(" | ");e.push(`sync: ${r.rejected.length} parked fact(s) quarantined to ${a.quarantinePath} (${i})`)}d.add(l),r.warnings&&e.push(...r.warnings.map(i=>`sync: ${i}`)),r.applied.length>0&&e.push(`sync: replayed ${r.applied.length} parked fact(s) from a previous run`)}if(d.size!==0)try{a.settle(d,u,{deadlineMs:s})}catch(l){e.push(`sync: queue rewrite failed (${l instanceof Error?l.message:String(l)}) \u2014 already-applied lines dedupe next sync; bad lines re-quarantine then`)}}function xe(t,e){let n=[],a=new Set,s=o=>{if(a.has(o)||!D(o))return;a.add(o);let c;try{c=I(o,"utf8")}catch(d){e.push(`sync: unreadable unit ${o} (${d instanceof Error?d.message:String(d)}) \u2014 skipped`);return}for(let d of c.split(`
|
|
3
3
|
`)){let u=/^@import\s+(\S+)\s*$/.exec(d.trim());if(!u)continue;let l=T(u[1])?u[1]:N(q(o),u[1]);if(!D(l))continue;let h;try{h=I(l,"utf8")}catch(r){e.push(`sync: unreadable import ${l} (${r instanceof Error?r.message:String(r)}) \u2014 skipped; importer continues`);continue}F(h)?.id&&s(l)}n.push({path:o})};return s(t),n}function fe(t,e){return ge(t,e)!==null}function ge(t,e){let n=ae(t,e);return n!==null&&t.nodeLabel.get(n)==="ac"?n:null}function ke(t,e,n,a){let s=t.split(`
|
|
4
4
|
`),o=Q(s),c={};return{blob:s.map((u,l)=>{let h=Y.exec(u.trim());if(!h||o.has(l))return u;let r=h[1];if(a&&r in a){let v=n.tipOf(a[r]);c[r]=v;let g=n.displayNameOf(v);return g?`@import ${g}`:u}let i=n.resolve(r);if(i)return c[r]=i.tip,u;if(e===null&&!T(r))return u;let f=T(r)?r:N(e,r);if(!D(f))return u;let p=F(I(f,"utf8"))?.id,m=p?n.resolve(p):null;return!p||!m?u:(c[r]=m.tip,`@import ${p}`)}).join(`
|
|
5
5
|
`),imports:c}}function Ie(t,e,n,a,s,o,c,d={}){let u=e.getNode(n);if(!u)return{oracleTier:!1,error:"tip unreadable"};let{blob:l,imports:h}=ke(ne(a),o,e,d.imports),r=String(u.content.test_md_blob??""),i=/^#\s+(.+?)\s*$/m.exec(l)?.[1]??String(u.content.title??""),f={...u.content,test_md_blob:l,definitionId:s,title:i};{let _=we(l);_.target!==void 0?f.target=_.target:delete f.target,_.app!==void 0?f.app=_.app:delete f.app}let p=re("test",f);if(p.length>0)return{oracleTier:!1,error:p.map(_=>_.detail).join("; ")};let m=ie("test",f);if(m===n)return{newCid:n,oracleTier:!1};let v=me(r)!==me(l);if(se(e,n,m))return{oracleTier:v,error:"file content reproduces an already-superseded version (supersession cycle guard) \u2014 graph kept; re-edit forward or redesign"};let g=oe({graph:e,oldTip:n,newCid:m,newLabel:"test",by:c,reason:`re-blessed onto ${m} (edited on disk, run sync)`});if(g.errors.length>0)return{oracleTier:v,error:`edge re-bless refused: ${g.errors.join("; ")}`};let $=t.head(),y=t.serialize($);if(!t.sameToken(t.parse(e.latestHash),$)){if(d.throwTransient)throw new k(`store advanced under the sync (basis ${String(e.latestHash)} vs head ${String(y)})`);return{oracleTier:v,error:`store advanced under the sync (basis ${String(e.latestHash)} vs head ${String(y)}) \u2014 re-run to retry`}}try{R(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:m,label:"test",content:f}],edges:g.edges,review:[{id:m,kind:"review-item",resolution:"edited",edit:null,reason:"edited on disk (run sync)",by:c}],supersessions:[{kind:"node",old:n,new:m,reason:"edited on disk (run sync)",by:c},...g.supersessions],source_head_moves:{}},{graph:e,expectPrev:y,intent:{v:1,verb:"exec-supersede",args:A({tip:n,raw:a,fileId:s,by:c}),pins:{tip:n,imports:h}},provenance:d.provenance})}catch(_){if(d.throwTransient&&_ instanceof k)throw _;return{oracleTier:v,error:_ instanceof Error?_.message:String(_)}}return{newCid:m,oracleTier:v}}function we(t){let e=X(t);return{...typeof e.target=="string"?{target:e.target}:{},...typeof e.app=="string"?{app:e.app}:{}}}function me(t){let e=[],n=t.split(`
|