@qwen-code/qwen-code 0.23.0 → 0.23.1-preview.1
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/bundled/new-app/SKILL.md +1 -1
- package/bundled/qc-helper/docs/configuration/auth.md +84 -12
- package/bundled/qc-helper/docs/configuration/settings.md +76 -74
- package/bundled/qc-helper/docs/features/arena.md +15 -20
- package/bundled/qc-helper/docs/features/channels/overview.md +7 -2
- package/bundled/qc-helper/docs/features/code-review.md +22 -19
- package/bundled/qc-helper/docs/features/commands.md +51 -10
- package/bundled/qc-helper/docs/features/followup-suggestions.md +1 -1
- package/bundled/qc-helper/docs/features/goals.md +8 -0
- package/bundled/qc-helper/docs/features/headless.md +2 -2
- package/bundled/qc-helper/docs/features/hooks.md +19 -19
- package/bundled/qc-helper/docs/features/output-styles.md +35 -2
- package/bundled/qc-helper/docs/qwen-serve.md +67 -52
- package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +3 -1
- package/bundled/qc-helper/docs/support/troubleshooting.md +3 -3
- package/bundled/review/SKILL.md +45 -41
- package/bundled/review/references/aone.md +1 -1
- package/bundled/review/references/posting.md +1 -1
- package/bundled/workflow-creator/SKILL.md +48 -0
- package/bundled/zvec-grep-install/SKILL.md +57 -0
- package/chunks/MaxSizedBox-5ARLO5PR.js +116 -0
- package/chunks/{StandaloneSessionPicker-QUMO4LLQ.js → StandaloneSessionPicker-T6B322CB.js} +87 -82
- package/chunks/{acp-startup-profiler-M4X5F3VK.js → acp-startup-profiler-6ULXXQMS.js} +2 -2
- package/chunks/{acpAgent-2GTFCIEP.js → acpAgent-WTDEY5KD.js} +1041 -364
- package/chunks/{agent-XKF5SZWU.js → agent-NXPUXEVZ.js} +46 -43
- package/chunks/agent-headless-QQZTWOKO.js +88 -0
- package/chunks/{anthropicContentGenerator-L76MR5OR.js → anthropicContentGenerator-6XDHXIII.js} +16 -9
- package/chunks/{artifact-tool-MYCL2QCS.js → artifact-tool-DFVVJXL2.js} +3 -3
- package/chunks/askUserQuestion-GF7VQ44M.js +14 -0
- package/chunks/bridge-OHY5OGOZ.js +123 -0
- package/chunks/{ca-BNU7YNDE.js → ca-KC2AISNS.js} +1 -0
- package/chunks/{channel-management-service-4MTCEGJB.js → channel-management-service-ZDDG3G5S.js} +4 -4
- package/chunks/channel-settings-store-7BJAS2SU.js +126 -0
- package/chunks/{channel-worker-group-47F4ISUZ.js → channel-worker-group-2ISMRENV.js} +6 -6
- package/chunks/{channel-worker-manager-I5Y44GYR.js → channel-worker-manager-VSRPVPRH.js} +6 -6
- package/chunks/{channel-worker-supervisor-6VCLUXFE.js → channel-worker-supervisor-SRJBK72Z.js} +4 -4
- package/chunks/{chunk-5RTTI4GE.js → chunk-2RYWGYB3.js} +4 -3
- package/chunks/{chunk-FUO5V5KI.js → chunk-2UWQX4FP.js} +2 -2
- package/chunks/{chunk-L26ONV2Y.js → chunk-2WGJG2KW.js} +9 -8
- package/chunks/{chunk-JHN7UIDW.js → chunk-2XRE4KE4.js} +1 -1
- package/chunks/chunk-32CM56LO.js +20 -0
- package/chunks/{chunk-SI7WDR3U.js → chunk-32YDNYXP.js} +129 -14
- package/chunks/{chunk-ZHO2CW6D.js → chunk-3CZ2BQV6.js} +1 -1
- package/chunks/{chunk-FD5SJOWT.js → chunk-3K456UJF.js} +9 -4
- package/chunks/{chunk-5M6IDOMF.js → chunk-3K65MUKD.js} +105 -0
- package/chunks/chunk-3UMWOKJC.js +78 -0
- package/chunks/{chunk-UM2FFKXN.js → chunk-43JNQAHO.js} +3 -3
- package/chunks/{chunk-KM3XVTMO.js → chunk-43NOB5NM.js} +112 -12
- package/chunks/{chunk-G5PBOQWI.js → chunk-47BZVBTE.js} +3 -3
- package/chunks/{chunk-32LU3APX.js → chunk-4F2QRVW6.js} +1 -1
- package/chunks/{chunk-KMU3ZHH4.js → chunk-4HC4DYKN.js} +2 -2
- package/chunks/{chunk-22UH7VTP.js → chunk-4HOEU2OR.js} +1 -1
- package/chunks/{chunk-NXKOVOM5.js → chunk-4IQKBLTQ.js} +15 -9
- package/chunks/{chunk-M4KFODIP.js → chunk-4JAGXZR3.js} +1 -1
- package/chunks/{chunk-PDAKFU7M.js → chunk-4LIPOIXS.js} +1 -1
- package/chunks/{chunk-LEPCWS5A.js → chunk-4MCY33Y2.js} +3 -3
- package/chunks/{chunk-U6D2PPMN.js → chunk-4VUVBN3Y.js} +1 -1
- package/chunks/{chunk-37JFWFCD.js → chunk-4VZCORNT.js} +1 -1
- package/chunks/{daemon-RKDGBFLK.js → chunk-537SQ2AI.js} +2216 -1721
- package/chunks/{chunk-VNAYZAFX.js → chunk-54TF2ZIQ.js} +4 -4
- package/chunks/{chunk-OKTNXDVO.js → chunk-565U2ANU.js} +1 -1
- package/chunks/chunk-5ETULJLP.js +74 -0
- package/chunks/{chunk-ADYN7P2Y.js → chunk-5JLQWQK6.js} +8 -6
- package/chunks/{chunk-BFY33IB4.js → chunk-5MTARK4Y.js} +7 -7
- package/chunks/{chunk-BJXCYUGM.js → chunk-5YY5MZT6.js} +1 -1
- package/chunks/{chunk-4PSDSCW3.js → chunk-64MQTIX7.js} +3 -3
- package/chunks/{chunk-54C6PIGT.js → chunk-6UIACMGH.js} +3 -3
- package/chunks/{chunk-ALUYNJPM.js → chunk-7BZS4ZDV.js} +1362 -1140
- package/chunks/{chunk-LB3WQQJK.js → chunk-7OCIQNKX.js} +2 -2
- package/chunks/{chunk-QKDNS6FU.js → chunk-7VEYUF3N.js} +13 -2
- package/chunks/{chunk-AZJLY2XZ.js → chunk-AHBLRVD5.js} +5 -5
- package/chunks/{chunk-VWTSRH6C.js → chunk-AQ5NAGWI.js} +89 -17
- package/chunks/{chunk-MOF6VZN2.js → chunk-AXPOOQAW.js} +2 -2
- package/chunks/{chunk-CVX63TFJ.js → chunk-B44JBZBB.js} +3 -3
- package/chunks/{chunk-AI35S34R.js → chunk-B54PFQS5.js} +3 -3
- package/chunks/{chunk-373DQUVA.js → chunk-BF3RUIVP.js} +5 -4
- package/chunks/{chunk-RJUVTJEZ.js → chunk-BKNY7PDI.js} +1 -1
- package/chunks/{chunk-UKYXYWI2.js → chunk-BUQN5LTI.js} +2 -2
- package/chunks/{chunk-O5CD7T4T.js → chunk-BW4333PP.js} +0 -95
- package/chunks/{chunk-UPFRILIL.js → chunk-CWNC7M73.js} +2 -2
- package/chunks/{chunk-3L724BJ5.js → chunk-CZACBHAW.js} +6 -6
- package/chunks/{chunk-EBDGRBZX.js → chunk-D4CU6DKR.js} +6 -6
- package/chunks/{chunk-G7HBEEX7.js → chunk-D6PIMKY3.js} +9 -9
- package/chunks/{chunk-ENYUKMFK.js → chunk-DJXSOEFB.js} +1 -1
- package/chunks/{chunk-C2VWOXHS.js → chunk-DNPHKA72.js} +8 -8
- package/chunks/{chunk-UUASLXHW.js → chunk-E4L5BM2B.js} +5 -5
- package/chunks/{chunk-HT5S5TRQ.js → chunk-EDIDYZBT.js} +4 -11
- package/chunks/{chunk-5H5S4UY5.js → chunk-EFT7OMDN.js} +1 -1
- package/chunks/{chunk-GB4UKWY5.js → chunk-EJNYBDYC.js} +2 -2
- package/chunks/{chunk-NQ4L2CMD.js → chunk-ER273QE6.js} +53 -9
- package/chunks/{chunk-RKW36UWC.js → chunk-EWNKP4V4.js} +1 -1
- package/chunks/{chunk-UJ4DUYIH.js → chunk-F53KKZUD.js} +2 -2
- package/chunks/{chunk-EFTPIZIC.js → chunk-FDOGGKAA.js} +21 -0
- package/chunks/{chunk-AQ37AY7B.js → chunk-FKJM6JKY.js} +5 -0
- package/chunks/{chunk-KEVYJSI4.js → chunk-G34YLYCS.js} +13 -13
- package/chunks/{chunk-P6UIF2OW.js → chunk-GCFZ2LAX.js} +195 -10
- package/chunks/{chunk-VGHZT6JR.js → chunk-GELRJXE2.js} +1 -1
- package/chunks/{chunk-ZDFQGHZH.js → chunk-GMNLYQOS.js} +1 -1
- package/chunks/{chunk-KOGW3YWJ.js → chunk-GVVCLL2P.js} +12 -12
- package/chunks/{chunk-OSSTATJF.js → chunk-GXZHYPHZ.js} +428 -30
- package/chunks/{chunk-IPATA3T2.js → chunk-GZWW2QWR.js} +2 -2
- package/chunks/{chunk-C4TIXFDZ.js → chunk-H3UDNQLO.js} +6 -4
- package/chunks/chunk-HD7O6WLV.js +18 -0
- package/chunks/{chunk-4UANMABT.js → chunk-HFTB354P.js} +259 -49
- package/chunks/{chunk-LOBDDFYK.js → chunk-HJ34U5J4.js} +5 -5
- package/chunks/{chunk-M4LBBSVP.js → chunk-HY3DXYZK.js} +2 -2
- package/chunks/{chunk-4F7GQGXB.js → chunk-I72PHOKL.js} +1451 -415
- package/chunks/{chunk-YPWZTR7F.js → chunk-IFD3BTEA.js} +3 -3
- package/chunks/{chunk-EWRW2WQC.js → chunk-IKLFS6SC.js} +5 -5
- package/chunks/{chunk-VPSIC437.js → chunk-IQN2CCIE.js} +66 -6
- package/chunks/{chunk-F7NF2IOE.js → chunk-IXSGOSEG.js} +7 -7
- package/chunks/{chunk-ODZF64DM.js → chunk-IZ2U57NY.js} +1 -1
- package/chunks/{chunk-4BGDFKQE.js → chunk-J3O5I5ZD.js} +24 -7
- package/chunks/{chunk-DYTW3QVG.js → chunk-J6MB5ZHZ.js} +1 -1
- package/chunks/{chunk-HJBHMANB.js → chunk-JBTZUFR4.js} +11 -8
- package/chunks/{chunk-SRF4KTAG.js → chunk-JLWFGYXU.js} +4 -4
- package/chunks/{chunk-SX2QIMJV.js → chunk-JOPC3FND.js} +5 -5
- package/chunks/chunk-JPEAQJNS.js +2142 -0
- package/chunks/{chunk-ZTPGUFQV.js → chunk-JRYL3T2O.js} +24 -5
- package/chunks/{chunk-GXUTFQXK.js → chunk-KE3Q4JMY.js} +4 -4
- package/chunks/{chunk-LKODFJRD.js → chunk-KFFCDLKV.js} +1 -1
- package/chunks/{chunk-4M24B5J5.js → chunk-KJJPJYHI.js} +79 -30
- package/chunks/chunk-KK2GZGBK.js +21080 -0
- package/chunks/{chunk-64QH2UC6.js → chunk-KPXRFTT7.js} +12 -1
- package/chunks/{chunk-JZWOCUZ3.js → chunk-L4R7BCVV.js} +1 -1
- package/chunks/{chunk-IG4W5SJR.js → chunk-LDS57224.js} +3 -3
- package/chunks/{chunk-UAKRDON5.js → chunk-LK7S2D6V.js} +4 -4
- package/chunks/{chunk-4HVH57J3.js → chunk-LMJQSPWB.js} +21 -6
- package/chunks/{chunk-ANVG3BVV.js → chunk-LNYV4GXX.js} +13 -3
- package/chunks/{chunk-RM4WT2XB.js → chunk-LPBQODMR.js} +4 -4
- package/chunks/{chunk-XEAAO654.js → chunk-M3JGHRMQ.js} +1 -1
- package/chunks/{chunk-AMDSOFFV.js → chunk-MATEIJZF.js} +1 -0
- package/chunks/{chunk-LHBNR6EU.js → chunk-MNEYUNOE.js} +2 -2
- package/chunks/{chunk-I4NRYS6A.js → chunk-MUZCSTOO.js} +11 -11
- package/chunks/{chunk-I5N4EAS6.js → chunk-MWHY26G3.js} +1 -1
- package/chunks/{chunk-7XL4WRXM.js → chunk-N6VQ37ZZ.js} +2 -2
- package/chunks/{chunk-AHYTURFB.js → chunk-N7EYO2E7.js} +1 -1
- package/chunks/{chunk-LU77UT4D.js → chunk-N7VURC4O.js} +24 -26
- package/chunks/{chunk-DSX7KQPM.js → chunk-NAKALAL4.js} +227 -29
- package/chunks/{chunk-QQD2GART.js → chunk-NGX4NUNP.js} +3 -3
- package/chunks/{chunk-2M3EWQNG.js → chunk-NUQFUXOG.js} +17 -1
- package/chunks/{chunk-E4JNFXNI.js → chunk-NXWYCSPL.js} +3 -3
- package/chunks/{chunk-6A2D4QSO.js → chunk-O2GG7H4C.js} +4 -4
- package/chunks/{chunk-ZKFTS3OV.js → chunk-O45WBTNS.js} +6 -6
- package/chunks/{chunk-KGV55H53.js → chunk-OECNP26L.js} +1 -1
- package/chunks/{chunk-S6H3ELPG.js → chunk-P4RUUG64.js} +1 -1
- package/chunks/{chunk-GH2S4GD5.js → chunk-P5LDR7FI.js} +21 -68
- package/chunks/{chunk-RN3YGDCA.js → chunk-P6LATTDG.js} +4 -4
- package/chunks/{chunk-WP4AX3XD.js → chunk-PTFFWTTO.js} +3 -3
- package/chunks/{chunk-DTVQSSNM.js → chunk-PZUOHCWI.js} +3 -3
- package/chunks/{chunk-VYIUNFEA.js → chunk-PZV2FASB.js} +3 -3
- package/chunks/{chunk-XLXAZLDR.js → chunk-Q2SAQTEJ.js} +1 -1
- package/chunks/{chunk-47RYEQW5.js → chunk-QMFOYPGV.js} +2 -2
- package/chunks/{chunk-SULZPKTA.js → chunk-QSC5YOEC.js} +3 -3
- package/chunks/{chunk-F33GFWPR.js → chunk-QWZOOIR3.js} +58 -18
- package/chunks/{chunk-H43PSPYS.js → chunk-R355CUNQ.js} +4 -4
- package/chunks/{chunk-DQCKVAF5.js → chunk-RDKXZ2LS.js} +3 -3
- package/chunks/{chunk-7JMGTOH7.js → chunk-RPBMP6BN.js} +21 -1
- package/chunks/{chunk-5Q5RC2WE.js → chunk-RVNS7NWN.js} +2 -2
- package/chunks/{chunk-7RB56BRJ.js → chunk-SAZS4IWW.js} +6 -4
- package/chunks/{chunk-5EIOJGCR.js → chunk-SFMCYMVF.js} +4 -4
- package/chunks/{chunk-TMKTOTMQ.js → chunk-SN5FV4FY.js} +5 -5
- package/chunks/{chunk-QJGYU5PG.js → chunk-TDP7UULF.js} +1 -1
- package/chunks/{chunk-EIJT2PQ6.js → chunk-TIGXX4PA.js} +2 -2
- package/chunks/{chunk-PCRBLMIN.js → chunk-TMWB67LS.js} +21 -3
- package/chunks/{chunk-JUARRUMA.js → chunk-UEZOXZNI.js} +1358 -646
- package/chunks/{chunk-KFN2IZYR.js → chunk-UKADFFL2.js} +3 -3
- package/chunks/{chunk-TJYRTS4S.js → chunk-UKKYOIVT.js} +2 -2
- package/chunks/{chunk-EVFDRBUM.js → chunk-URSCX7S7.js} +12 -7
- package/chunks/{chunk-U4DJ5XB3.js → chunk-VDXYYVCD.js} +269 -70
- package/chunks/{chunk-4LIFGNI4.js → chunk-VEFRT7NX.js} +1 -1
- package/chunks/chunk-VFFQAOPR.js +18 -0
- package/chunks/{chunk-3AKCBZVW.js → chunk-VU7O7CGQ.js} +3 -3
- package/chunks/{chunk-RAFQIHN2.js → chunk-VUSSAGKI.js} +76 -5
- package/chunks/{chunk-TQHPVKO6.js → chunk-VY6UVU7G.js} +6 -6
- package/chunks/{chunk-S2T7H5MI.js → chunk-W4LL5RZO.js} +1 -1
- package/chunks/{chunk-ZGCKTAL5.js → chunk-WEXA2DNG.js} +2 -0
- package/chunks/{chunk-NVVJTUSL.js → chunk-WR3SH3EY.js} +136 -85
- package/chunks/{chunk-JR42V4UY.js → chunk-WTW36TJ3.js} +1 -1
- package/chunks/{chunk-TSZSGQ3N.js → chunk-WXC6OAWD.js} +1 -1
- package/chunks/{chunk-ZVP4PWBU.js → chunk-X35VIWWJ.js} +1 -1
- package/chunks/{chunk-KHP66DFN.js → chunk-XFFRI3WM.js} +1 -1
- package/chunks/{chunk-EIY7SUPZ.js → chunk-XHGGYCTA.js} +1 -1
- package/chunks/{chunk-BA4WJC4L.js → chunk-XOVVCGZX.js} +1 -1
- package/chunks/{chunk-VBWD6C27.js → chunk-XUSOYE2I.js} +1 -1
- package/chunks/{chunk-NUHOLAQ6.js → chunk-XWJFDJZK.js} +1 -1
- package/chunks/{chunk-65HWLGA7.js → chunk-XY3USGFE.js} +3 -3
- package/chunks/{chunk-STCVJXQB.js → chunk-Y3ZKI4RQ.js} +56 -26
- package/chunks/{chunk-QAK5475D.js → chunk-Y53DG2HA.js} +1 -1
- package/chunks/{chunk-3JQZVCBI.js → chunk-YCDL2SAS.js} +2 -2
- package/chunks/{chunk-NSUKQ4DN.js → chunk-YHDGABDC.js} +3 -3
- package/chunks/{chunk-FRICLXCZ.js → chunk-Z6WZPXQH.js} +3 -3
- package/chunks/{chunk-EAHOJF6V.js → chunk-ZAFYHRVY.js} +12 -0
- package/chunks/{chunk-MP6YZ4RK.js → chunk-ZAZ3NFL6.js} +852 -309
- package/chunks/{chunk-7TBU7PU2.js → chunk-ZSTCM3MX.js} +1 -1
- package/chunks/{chunk-NRL5CUZT.js → chunk-ZTAVGFKA.js} +1 -1
- package/chunks/config-utils-QXDOTXEQ.js +119 -0
- package/chunks/contextCommand-RN4KARWC.js +112 -0
- package/chunks/{core-runtime-B4UKKIAQ.js → core-runtime-NAZCOKHB.js} +63 -58
- package/chunks/{create-sub-session-NJ24B4US.js → create-sub-session-BCSM4WKB.js} +61 -56
- package/chunks/{create-sub-session-LUPWEUHR.js → create-sub-session-BQ3SE4TX.js} +3 -3
- package/chunks/{cron-create-CRSPET3H.js → cron-create-D6HQ7I7I.js} +4 -4
- package/chunks/{cron-delete-DB77SZTU.js → cron-delete-KK3D2SQV.js} +4 -4
- package/chunks/{cron-list-U2JNYWV6.js → cron-list-VBF3IZMF.js} +4 -4
- package/chunks/daemon-LCUELM6E.js +191 -0
- package/chunks/{daemon-git-worktree-guard-O2HPOBAB.js → daemon-git-worktree-guard-3K5CAU36.js} +62 -57
- package/chunks/daemon-status-provider-4X3ZZQTZ.js +122 -0
- package/chunks/daemon-trust-policy-R45CFUJA.js +118 -0
- package/chunks/{daemon-trust-policy-monitor-JL7F4Y4Q.js → daemon-trust-policy-monitor-DSSFCO3K.js} +69 -64
- package/chunks/{de-T4BLOKEC.js → de-UU2YTO37.js} +1 -0
- package/chunks/deferred-core-runtime-UO2M6WYI.js +120 -0
- package/chunks/{display-image-73C7XNRK.js → display-image-EVVTBVYE.js} +6 -6
- package/chunks/{dist-EDHQIBYD.js → dist-3T5MDUHP.js} +62 -20
- package/chunks/{dist-ZCJLKQSP.js → dist-AFH3BMZZ.js} +18 -10
- package/chunks/{dist-LXFYIJNG.js → dist-MK5PPBRF.js} +40 -9
- package/chunks/{dist-GT64AAUR.js → dist-PH5RSTEA.js} +56 -20
- package/chunks/{dist-62OZ7QXB.js → dist-QUU7TVE3.js} +35 -12
- package/chunks/{dist-JVXT4VUJ.js → dist-R5Y34V6T.js} +11 -2
- package/chunks/{dist-L6URO6CK.js → dist-SB2XRXZA.js} +5 -1
- package/chunks/{dist-QAF5DO3Y.js → dist-SIHF5MU2.js} +326 -131
- package/chunks/{dist-PDGNRVPY.js → dist-UVHW2U56.js} +20 -1
- package/chunks/earlyInputCapture-BXP7V2P3.js +22 -0
- package/chunks/{edit-SUGXY63Y.js → edit-VNBCTRWP.js} +48 -44
- package/chunks/{en-2RATMNX7.js → en-JMR535HP.js} +3 -1
- package/chunks/{enter-worktree-B6USKSIK.js → enter-worktree-CEVK7MQ2.js} +7 -7
- package/chunks/{enterPlanMode-MDX4RVVL.js → enterPlanMode-4KMZMUIA.js} +48 -45
- package/chunks/environment-S2HYQDON.js +135 -0
- package/chunks/errors-DAAN5TL7.js +119 -0
- package/chunks/{exit-worktree-DLQ73SJH.js → exit-worktree-D3YE6MUN.js} +7 -7
- package/chunks/exitPlanMode-HR36HG3D.js +86 -0
- package/chunks/{fast-path-Y73R42LV.js → fast-path-4IWSW3UV.js} +3 -3
- package/chunks/{fast-path-settings-MFUR3IWK.js → fast-path-settings-ISEJPRYE.js} +6 -4
- package/chunks/{fr-BGHGYX6A.js → fr-HKNWVXRJ.js} +1 -0
- package/chunks/{glob-DMGH7EZN.js → glob-IZYB2XH2.js} +46 -43
- package/chunks/{goal-tools-3RF3PXCL.js → goal-tools-VGUPKQDJ.js} +46 -43
- package/chunks/{grep-AJVLCVXC.js → grep-OUVLNXG7.js} +9 -8
- package/chunks/handleAutoUpdate-D56FMDTW.js +115 -0
- package/chunks/i18n-BKE5WO6T.js +130 -0
- package/chunks/{image-gen-VOIDOHOB.js → image-gen-SHVQ3XID.js} +8 -8
- package/chunks/initializer-MS4SGEHF.js +119 -0
- package/chunks/installationInfo-542MGC4S.js +113 -0
- package/chunks/{ja-G3FTD5XE.js → ja-GJS5RZGU.js} +1 -0
- package/chunks/{keychain-token-storage-REZVMJA6.js → keychain-token-storage-NQ5XWIPX.js} +2 -2
- package/chunks/list-H6XTKUWL.js +122 -0
- package/chunks/{list-agents-SBMONIUK.js → list-agents-ULYBGJXC.js} +6 -6
- package/chunks/{llm-K26SUDVK.js → llm-3NUC4EJY.js} +132 -113
- package/chunks/{llm-content-generator-TT6EAUD4.js → llm-content-generator-R4NL3OQN.js} +40 -13
- package/chunks/loadedSettingsAdapter-3XLKYDVT.js +116 -0
- package/chunks/{loggingContentGenerator-EYQBA4M4.js → loggingContentGenerator-ZYSWVNEO.js} +55 -52
- package/chunks/{loop-wakeup-QA6SHCZT.js → loop-wakeup-B27BEYRL.js} +5 -5
- package/chunks/{lowlight-J2OZNPCA.js → lowlight-BTE423KL.js} +3 -6
- package/chunks/{ls-HEJNCEYO.js → ls-3IIMMVKF.js} +5 -4
- package/chunks/{lsp-WOQKNZP6.js → lsp-VJAT7XKS.js} +2 -2
- package/chunks/{managed-npm-update-HIJTODQT.js → managed-npm-update-L2I53ZAI.js} +62 -57
- package/chunks/mcp-4PIXQASW.js +116 -0
- package/chunks/{monitor-DKNZQAB2.js → monitor-O2YQTOZZ.js} +50 -46
- package/chunks/{node-UETAYMMO.js → node-ISQAFKIS.js} +2 -2
- package/chunks/nonInteractiveCli-LV7CDBA2.js +198 -0
- package/chunks/{notebook-edit-MGHTRL2D.js → notebook-edit-4RE2ALH4.js} +48 -44
- package/chunks/{openaiContentGenerator-ZJIEQ3ZJ.js → openaiContentGenerator-7ND7K5CP.js} +30 -25
- package/chunks/pidfile-UFTLQ7NP.js +117 -0
- package/chunks/{processUtils-UY3SAJJZ.js → processUtils-3XBB4FYV.js} +2 -2
- package/chunks/prompt-terminal-ledger-2QASOGMM.js +111 -0
- package/chunks/{pt-D73IFYT7.js → pt-FXMYXEUV.js} +1 -0
- package/chunks/{qwenContentGenerator-VI4KATRY.js → qwenContentGenerator-AELTUTH6.js} +52 -49
- package/chunks/{qwenOAuth2-7AOCKSOQ.js → qwenOAuth2-BS5D2LYV.js} +7 -7
- package/chunks/{read-file-P7F4P7LV.js → read-file-PDWHZPHX.js} +13 -11
- package/chunks/{read-mcp-resource-GLAGB6R7.js → read-mcp-resource-YXJZ75UB.js} +2 -2
- package/chunks/{record-artifact-SWVR7NSU.js → record-artifact-WJDOV6XU.js} +4 -4
- package/chunks/{report-findings-AL5YW3KI.js → report-findings-Q4UACKWR.js} +5 -5
- package/chunks/{request-shutdown-5YK4IZ54.js → request-shutdown-2YZ3E3GH.js} +8 -8
- package/chunks/resumeHistoryUtils-QRXZEEBA.js +124 -0
- package/chunks/ripGrep-KSOOLE6H.js +39 -0
- package/chunks/{ru-QMISLKRH.js → ru-RMHURE5U.js} +1 -0
- package/chunks/{run-qwen-serve-OGTEEUR2.js → run-qwen-serve-RTAREPT6.js} +84 -70
- package/chunks/runtime-ESFSCJRZ.js +154 -0
- package/chunks/scheduled-tasks-6ZHRNBH6.js +133 -0
- package/chunks/{scheduler-73YXGUGW.js → scheduler-DQI6KV7T.js} +63 -58
- package/chunks/{sdk-exporters-http-3JO5TJNU.js → sdk-exporters-http-7R2ARBPV.js} +2 -2
- package/chunks/{sdk-impl-HZAUUTHJ.js → sdk-impl-YOLO7LV4.js} +4 -4
- package/chunks/{send-message-JC7NJTY6.js → send-message-PQCVSVMN.js} +24 -24
- package/chunks/serve-FY7ZEW52.js +124 -0
- package/chunks/{server-AOYZVVOM.js → server-KNDY6K5F.js} +1594 -273
- package/chunks/{session-UAWFNFGI.js → session-MCEPXAZP.js} +113 -105
- package/chunks/session-attachments-root-OLNAE6GF.js +109 -0
- package/chunks/{session-pr-refresh-CT2INROL.js → session-pr-refresh-HKJHQQQK.js} +67 -62
- package/chunks/{settings-BHRGDASJ.js → settings-VXO4WBMK.js} +68 -63
- package/chunks/shell-U263OTES.js +96 -0
- package/chunks/{skill-ZGBKNCHQ.js → skill-SDODGBKL.js} +19 -17
- package/chunks/skill-settings-YEIA22QJ.js +124 -0
- package/chunks/spawnChannel-4WJZVFPP.js +117 -0
- package/chunks/standalone-update-ZWVQUO64.js +124 -0
- package/chunks/{start-opentui-ui-FZ4USOU7.js → start-opentui-ui-BFYCJQRZ.js} +1199 -190
- package/chunks/{startInteractiveUI-E2WQJUOA.js → startInteractiveUI-JYAFCMHL.js} +2977 -2319
- package/chunks/{syntheticOutput-HJNZSEHN.js → syntheticOutput-AUAJBNXR.js} +3 -3
- package/chunks/{task-create-6RSD54S5.js → task-create-LD5ISM3E.js} +12 -12
- package/chunks/{task-list-IQSACPOM.js → task-list-YISJ4RJA.js} +5 -5
- package/chunks/{task-stop-HE2LRQNW.js → task-stop-65ZOVATJ.js} +2 -2
- package/chunks/{task-update-XAJ2NYOA.js → task-update-AAN4ZVEY.js} +15 -15
- package/chunks/{team-create-SOKMYSQU.js → team-create-KU7MABNO.js} +47 -44
- package/chunks/{team-delete-NGNNKGMG.js → team-delete-XFRRTJTT.js} +5 -5
- package/chunks/{team-plan-approval-U7ZWXYAY.js → team-plan-approval-DPB377A3.js} +46 -43
- package/chunks/terminal-image-renderer-WGWRENOF.js +124 -0
- package/chunks/theme-manager-GBUFULSO.js +108 -0
- package/chunks/{todoWrite-5UTVUXHA.js → todoWrite-G7NT4IFP.js} +5 -5
- package/chunks/{tool-search-IAI2RVWT.js → tool-search-6YUXHBPT.js} +19 -17
- package/chunks/total-session-admission-54R2JQ5L.js +118 -0
- package/chunks/trustedFolders-KAJIDJTH.js +128 -0
- package/chunks/{update-relaunch-5RWKZAL3.js → update-relaunch-XM4IWBFD.js} +5 -5
- package/chunks/updateCheck-W6UZFURI.js +124 -0
- package/chunks/useAutoAcceptIndicator-LAWYHY3U.js +126 -0
- package/chunks/{validateNonInterActiveAuth-QPFEKATS.js → validateNonInterActiveAuth-7WCKHRN2.js} +109 -101
- package/chunks/{version-JKNG7YDH.js → version-3ZU43RJ6.js} +1 -1
- package/chunks/{web-fetch-X3AHIIHW.js → web-fetch-QHI2SQL4.js} +16 -14
- package/chunks/{web-search-K2FMOGS5.js → web-search-3KZZKWNY.js} +9 -8
- package/chunks/{workflow-TOLPAK5G.js → workflow-HRW7Y2X4.js} +330 -1667
- package/chunks/workspace-providers-status-KTGCWCPC.js +120 -0
- package/chunks/{workspace-registration-store-KQWVVW4Y.js → workspace-registration-store-LHLPPWNE.js} +1 -1
- package/chunks/workspace-registry-X34MLN52.js +127 -0
- package/chunks/workspace-runtime-coordinator-U4PW4P7K.js +128 -0
- package/chunks/workspace-service-KD7BCGYL.js +132 -0
- package/chunks/workspace-skills-status-YJGO6Y3T.js +119 -0
- package/chunks/{workspace-trust-reconciler-IBDFQBQS.js → workspace-trust-reconciler-EUYHISCH.js} +74 -69
- package/chunks/write-file-EBSB34NJ.js +91 -0
- package/chunks/{zh-25DF7OGK.js → zh-DVFYHRK5.js} +3 -1
- package/chunks/{zh-TW-5EDMZVGK.js → zh-TW-W2GNP2IU.js} +3 -1
- package/chunks/{zoom-image-IFXSN74N.js → zoom-image-UJ5VKWKP.js} +13 -11
- package/cli.js +13 -13
- package/export-transcript-document.js +617 -0
- package/locales/ca.js +1 -0
- package/locales/de.js +1 -0
- package/locales/en.js +5 -2
- package/locales/fr.js +1 -0
- package/locales/ja.js +1 -0
- package/locales/pt.js +1 -0
- package/locales/ru.js +1 -0
- package/locales/zh-TW.js +5 -2
- package/locales/zh.js +5 -2
- package/package.json +5 -4
- package/web-shell/assets/{abnfDiagram-VCTEODGH-Cxf7xE_Z.js → abnfDiagram-VCTEODGH-Dur--luQ.js} +1 -1
- package/web-shell/assets/{arc-ESi1eNkE.js → arc-tYLobxFi.js} +1 -1
- package/web-shell/assets/{architectureDiagram-5GKGNRK7-D9l7-bDo.js → architectureDiagram-5GKGNRK7-IG6aXD03.js} +1 -1
- package/web-shell/assets/{blockDiagram-NRAW4CY4-Bc8DEasw.js → blockDiagram-NRAW4CY4-C6eBSkfA.js} +1 -1
- package/web-shell/assets/{c4Diagram-UCG6FXSJ-Dimb2Hmh.js → c4Diagram-UCG6FXSJ-BrX3HJqB.js} +1 -1
- package/web-shell/assets/channel-uEkvKckd.js +1 -0
- package/web-shell/assets/{chunk-2Q5K7J3B-jVDmOpAQ.js → chunk-2Q5K7J3B-B3fcJ8ee.js} +1 -1
- package/web-shell/assets/{chunk-5VM5RSS4-DbG_SwdB.js → chunk-5VM5RSS4-CeC90yKM.js} +1 -1
- package/web-shell/assets/{chunk-F27PBJKO-QEc4cY1v.js → chunk-F27PBJKO-CW44RVki.js} +1 -1
- package/web-shell/assets/{chunk-G27WJ6UU-iJ36lQ3X.js → chunk-G27WJ6UU-D1PAMukD.js} +1 -1
- package/web-shell/assets/{chunk-JWPE2WC7-DuArnVtF.js → chunk-JWPE2WC7-Dt3Y2Fvx.js} +1 -1
- package/web-shell/assets/{chunk-LCL6LL3I-DxOf1zwL.js → chunk-LCL6LL3I-CZHw2lLI.js} +1 -1
- package/web-shell/assets/{chunk-POPQ4Y6H-lVLu9Ild.js → chunk-POPQ4Y6H-ysNAdTGx.js} +1 -1
- package/web-shell/assets/{chunk-SVP7TREG-C6XYlIer.js → chunk-SVP7TREG-BdNXW6YQ.js} +1 -1
- package/web-shell/assets/{chunk-XXDRQBXY-CiG2j2Ji.js → chunk-XXDRQBXY-DgqQ9UA8.js} +1 -1
- package/web-shell/assets/classDiagram-DTDB5LWJ-DuPsnhWS.js +1 -0
- package/web-shell/assets/classDiagram-v2-JRS7N3AN-DuPsnhWS.js +1 -0
- package/web-shell/assets/{cose-bilkent-JH36ORCC-DGVHMMVm.js → cose-bilkent-JH36ORCC-BILImXzJ.js} +1 -1
- package/web-shell/assets/{cynefin-OW5HDTMX-D6cgpCnH.js → cynefin-OW5HDTMX-DR88Pund.js} +1 -1
- package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-BKv4Z-UX.js → cynefinDiagram-5FMLGOSQ-BYFbfkA6.js} +1 -1
- package/web-shell/assets/{dagre-3AP2YEHR-B4ABMIG-.js → dagre-3AP2YEHR-rfpyc6sX.js} +1 -1
- package/web-shell/assets/{diagram-S7CK7UJ4-DgCkp_Lm.js → diagram-S7CK7UJ4-BJxLmEwH.js} +1 -1
- package/web-shell/assets/{diagram-UQ7AKVKN-FG0FNokz.js → diagram-UQ7AKVKN-H34xm7k3.js} +1 -1
- package/web-shell/assets/{diagram-VSXAHHWV-JgkP9qg-.js → diagram-VSXAHHWV-HYxhwNLx.js} +1 -1
- package/web-shell/assets/{diagram-VX7I27RA-ADh2x83l.js → diagram-VX7I27RA-BJazso8F.js} +1 -1
- package/web-shell/assets/{diagram-Z3DM3KII-yXqoYF1J.js → diagram-Z3DM3KII-Clje1aNy.js} +1 -1
- package/web-shell/assets/{ebnfDiagram-PWID7BFC-Duk83Ek_.js → ebnfDiagram-PWID7BFC-M93YBkFh.js} +1 -1
- package/web-shell/assets/{erDiagram-SSCWMZ5O-DMdvxySG.js → erDiagram-SSCWMZ5O-DY8XzSHU.js} +1 -1
- package/web-shell/assets/{flowDiagram-A5DVABFB-DHjVgSji.js → flowDiagram-A5DVABFB-CE6Aylcq.js} +1 -1
- package/web-shell/assets/{ganttDiagram-EL5Y4UJY-DMM9DkCE.js → ganttDiagram-EL5Y4UJY-DI-5LL22.js} +1 -1
- package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-t_ug9vO8.js → gitGraphDiagram-WWUBYQGX-C7BZWElk.js} +1 -1
- package/web-shell/assets/index-CVyqwW7y.js +2142 -0
- package/web-shell/assets/{index-zqvnpGHv.js → index-DclFHns9.js} +1 -1
- package/web-shell/assets/index-FO7JXPnH.css +36 -0
- package/web-shell/assets/{infoDiagram-RXCK75RN-eT1fANNm.js → infoDiagram-RXCK75RN-CGUSy4Pc.js} +1 -1
- package/web-shell/assets/{ishikawaDiagram-5VMMS53U-k3evzZNn.js → ishikawaDiagram-5VMMS53U-B5BVks9q.js} +1 -1
- package/web-shell/assets/{journeyDiagram-EYS64GPL-CGim3EAi.js → journeyDiagram-EYS64GPL-CFh6Tf7h.js} +1 -1
- package/web-shell/assets/{kanban-definition-3QL26DDD-WHfJo-22.js → kanban-definition-3QL26DDD-B7TlxP7c.js} +1 -1
- package/web-shell/assets/{layout-DkqIaFlJ.js → layout-Br_pZq2Q.js} +1 -1
- package/web-shell/assets/{linear-Bdkd3mCz.js → linear-BVlP6fte.js} +1 -1
- package/web-shell/assets/{mermaid.core-CGw0LkT_.js → mermaid.core-TrcYWoiF.js} +6 -6
- package/web-shell/assets/{mindmap-definition-FBJOCRG2-C9V4rBvo.js → mindmap-definition-FBJOCRG2-BJ4LzqjZ.js} +1 -1
- package/web-shell/assets/{pegDiagram-XKGWAZYB-CwoI2T5G.js → pegDiagram-XKGWAZYB-1b_MxlOl.js} +1 -1
- package/web-shell/assets/{pieDiagram-E7YTZNPT-DaTmBmPG.js → pieDiagram-E7YTZNPT-B8zl0YhY.js} +1 -1
- package/web-shell/assets/{quadrantDiagram-AXDQQJYC-plh6MyGI.js → quadrantDiagram-AXDQQJYC-CIZO8ukl.js} +1 -1
- package/web-shell/assets/{railroadDiagram-O6MQD6OU-D_b-S0iK.js → railroadDiagram-O6MQD6OU-CepHSbCj.js} +1 -1
- package/web-shell/assets/{requirementDiagram-EFPCY7ZU-zUzTN7VE.js → requirementDiagram-EFPCY7ZU-BCgxkcSW.js} +1 -1
- package/web-shell/assets/{sankeyDiagram-P5KCCOFB-m6AhoD0l.js → sankeyDiagram-P5KCCOFB-CE5CcoMM.js} +1 -1
- package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-Cwhzsine.js → sequenceDiagram-WJ2MYXX4-DvgHi-d5.js} +1 -1
- package/web-shell/assets/{sizeCapture-X5ZJPWSS-CcZuKIae.js → sizeCapture-X5ZJPWSS-T-fAsCPX.js} +1 -1
- package/web-shell/assets/{stateDiagram-HBIQ2CUA-CFoiJwD_.js → stateDiagram-HBIQ2CUA-DYHaul-5.js} +1 -1
- package/web-shell/assets/stateDiagram-v2-4QOOHH4V-BcYho9a4.js +1 -0
- package/web-shell/assets/{swimlanes-XN3QIQJK-CgS9hcaV.js → swimlanes-XN3QIQJK-Dbz3Qiej.js} +1 -1
- package/web-shell/assets/swimlanesDiagram-VK2B7HYN-D6HsOIgX.js +8 -0
- package/web-shell/assets/{timeline-definition-24CTP7MA-Dzzc05t9.js → timeline-definition-24CTP7MA-9NVRts3N.js} +1 -1
- package/web-shell/assets/{vennDiagram-4TSXK5OY-DemK0f7Y.js → vennDiagram-4TSXK5OY-C7cb7vnH.js} +1 -1
- package/web-shell/assets/{wardleyDiagram-VM6X3IG4-CquLxtMr.js → wardleyDiagram-VM6X3IG4-CG-8Ddjm.js} +1 -1
- package/web-shell/assets/{xychartDiagram-S5SC5T6Z-BTBKTM5g.js → xychartDiagram-S5SC5T6Z-iGeYAcP4.js} +1 -1
- package/web-shell/index.html +2 -2
- package/chunks/MaxSizedBox-B3D7545A.js +0 -111
- package/chunks/agent-headless-OC2IB55D.js +0 -85
- package/chunks/askUserQuestion-THQZMG44.js +0 -322
- package/chunks/bridge-IHSBI2YJ.js +0 -118
- package/chunks/channel-settings-store-BVKWAI2T.js +0 -121
- package/chunks/chunk-I2TMJPCV.js +0 -448
- package/chunks/chunk-QI27MKNQ.js +0 -4008
- package/chunks/config-utils-LVSYDLHZ.js +0 -114
- package/chunks/contextCommand-TZD7UAJK.js +0 -107
- package/chunks/daemon-status-provider-GRRVCJFW.js +0 -117
- package/chunks/daemon-trust-policy-YJL442BK.js +0 -113
- package/chunks/deferred-core-runtime-S32AYVZI.js +0 -115
- package/chunks/earlyInputCapture-BBPCIVZG.js +0 -108
- package/chunks/environment-VN6RXDVN.js +0 -130
- package/chunks/errors-UEY36PIT.js +0 -114
- package/chunks/exitPlanMode-EPHIEDAA.js +0 -83
- package/chunks/handleAutoUpdate-HVWQT2AU.js +0 -110
- package/chunks/i18n-5OR7NTRZ.js +0 -125
- package/chunks/initializer-JE5RQSOE.js +0 -114
- package/chunks/installationInfo-KO3CCSCK.js +0 -108
- package/chunks/list-3IORSFIY.js +0 -117
- package/chunks/loadedSettingsAdapter-KLLFZF3M.js +0 -111
- package/chunks/mcp-A2UEHETW.js +0 -111
- package/chunks/nonInteractiveCli-YA47F2F4.js +0 -190
- package/chunks/pidfile-ETHAZNMY.js +0 -112
- package/chunks/prompt-terminal-ledger-GZ747VYE.js +0 -106
- package/chunks/resumeHistoryUtils-DPZKFW24.js +0 -119
- package/chunks/ripGrep-C7LJKUPZ.js +0 -37
- package/chunks/runtime-LNBLEMZS.js +0 -149
- package/chunks/scheduled-tasks-FLDYZQOF.js +0 -128
- package/chunks/serve-3UR2H4CV.js +0 -119
- package/chunks/session-attachments-root-ZCGXQQTR.js +0 -104
- package/chunks/shell-YHOGC7TO.js +0 -93
- package/chunks/skill-settings-AKSP665O.js +0 -119
- package/chunks/spawnChannel-N25MBB6F.js +0 -112
- package/chunks/standalone-update-XGPWJDRN.js +0 -119
- package/chunks/terminal-image-renderer-KKM4OBLO.js +0 -117
- package/chunks/theme-manager-GQHF3A7T.js +0 -103
- package/chunks/total-session-admission-G4CGCSTG.js +0 -113
- package/chunks/trustedFolders-D2I3FDPB.js +0 -123
- package/chunks/updateCheck-ZXOQDFEI.js +0 -119
- package/chunks/useAutoAcceptIndicator-6EK4QGAH.js +0 -121
- package/chunks/workspace-providers-status-PCJK3RC7.js +0 -115
- package/chunks/workspace-registry-YNIOB6HJ.js +0 -122
- package/chunks/workspace-runtime-coordinator-WG2RNEN7.js +0 -123
- package/chunks/workspace-service-G4ZNBOFH.js +0 -127
- package/chunks/workspace-skills-status-FMTPPMWC.js +0 -114
- package/chunks/write-file-YTLFY2S5.js +0 -88
- package/web-shell/assets/channel-B7ohGDil.js +0 -1
- package/web-shell/assets/classDiagram-DTDB5LWJ-DdFpqpfD.js +0 -1
- package/web-shell/assets/classDiagram-v2-JRS7N3AN-DdFpqpfD.js +0 -1
- package/web-shell/assets/index-BGZRqbRo.css +0 -36
- package/web-shell/assets/index-DRri_6_x.js +0 -2067
- package/web-shell/assets/stateDiagram-v2-4QOOHH4V--H8HdEmk.js +0 -1
- package/web-shell/assets/swimlanesDiagram-VK2B7HYN-ShE9OIgf.js +0 -8
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
import {
|
|
4
4
|
MAX_FRAME_BYTES,
|
|
5
|
+
MAX_SOCKET_PATH_BYTES,
|
|
6
|
+
SOCKET_DIR_NAME,
|
|
5
7
|
isLocalIpcPath,
|
|
6
8
|
parsePeerAuthLine,
|
|
7
9
|
parsePeerFrame,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
probePeerSocketVerdict,
|
|
11
|
+
resolvePeerSocketCandidates
|
|
12
|
+
} from "./chunk-HFTB354P.js";
|
|
10
13
|
import {
|
|
11
14
|
scanForSecrets
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BUQN5LTI.js";
|
|
13
16
|
import {
|
|
14
17
|
BudgetExhaustedError,
|
|
15
18
|
CoreToolScheduler,
|
|
@@ -47,6 +50,7 @@ import {
|
|
|
47
50
|
getPty,
|
|
48
51
|
getTimeRangeBounds,
|
|
49
52
|
isAllowedMemoryPath,
|
|
53
|
+
isClearedMediaPlaceholder,
|
|
50
54
|
isPoolable,
|
|
51
55
|
listDescendantPids,
|
|
52
56
|
listExistingSkillDirNames,
|
|
@@ -70,7 +74,7 @@ import {
|
|
|
70
74
|
stripToolResultImages,
|
|
71
75
|
toolResultBoundaryArtifact,
|
|
72
76
|
toolResultPartDiagnosticValues
|
|
73
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-I72PHOKL.js";
|
|
74
78
|
import {
|
|
75
79
|
hasVerifiableInode,
|
|
76
80
|
openNoFollow
|
|
@@ -80,36 +84,46 @@ import {
|
|
|
80
84
|
} from "./chunk-TWPJO254.js";
|
|
81
85
|
import {
|
|
82
86
|
projectUserTranscriptForDisplay
|
|
83
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-FDOGGKAA.js";
|
|
88
|
+
import {
|
|
89
|
+
resolveBundleDir
|
|
90
|
+
} from "./chunk-PZV2FASB.js";
|
|
84
91
|
import {
|
|
85
92
|
glob,
|
|
86
93
|
globSync
|
|
87
94
|
} from "./chunk-QJNDUTOL.js";
|
|
88
|
-
import {
|
|
89
|
-
getProjectSkillsRoot
|
|
90
|
-
} from "./chunk-H43PSPYS.js";
|
|
91
|
-
import {
|
|
92
|
-
resolveBundleDir
|
|
93
|
-
} from "./chunk-VYIUNFEA.js";
|
|
94
95
|
import {
|
|
95
96
|
escapeJsonTagCharacters
|
|
96
97
|
} from "./chunk-CHEIIBT3.js";
|
|
98
|
+
import {
|
|
99
|
+
isPidAlive
|
|
100
|
+
} from "./chunk-BF3RUIVP.js";
|
|
101
|
+
import {
|
|
102
|
+
getProjectSkillsRoot,
|
|
103
|
+
parse
|
|
104
|
+
} from "./chunk-R355CUNQ.js";
|
|
97
105
|
import {
|
|
98
106
|
require_proper_lockfile
|
|
99
107
|
} from "./chunk-MLXTMF7H.js";
|
|
108
|
+
import {
|
|
109
|
+
BUILT_IN_OUTPUT_STYLES,
|
|
110
|
+
getBuiltInOutputStyle
|
|
111
|
+
} from "./chunk-GXZHYPHZ.js";
|
|
100
112
|
import {
|
|
101
113
|
fetchWithPolicy
|
|
102
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-UKADFFL2.js";
|
|
103
115
|
import {
|
|
104
116
|
COMBINED_PASS_TOLERANCE_FACTOR,
|
|
105
117
|
TOOL_OUTPUT_TRUNCATED_PREFIX,
|
|
106
118
|
TRUNCATION_FALLBACK_ENVELOPE_SLACK,
|
|
107
119
|
addMCPStatusChangeListener,
|
|
108
|
-
getInvocationContext,
|
|
109
120
|
removeMCPStatusChangeListener,
|
|
110
121
|
runSideQuery,
|
|
111
122
|
updateMCPServerStatus
|
|
112
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-P5LDR7FI.js";
|
|
124
|
+
import {
|
|
125
|
+
getInvocationContext
|
|
126
|
+
} from "./chunk-5ETULJLP.js";
|
|
113
127
|
import {
|
|
114
128
|
E_TIMEOUT,
|
|
115
129
|
Mutex,
|
|
@@ -122,38 +136,46 @@ import {
|
|
|
122
136
|
detectFileType,
|
|
123
137
|
getCurrentMemoryFilename,
|
|
124
138
|
isCacheableReadResult,
|
|
139
|
+
isWithinRoot,
|
|
125
140
|
processSingleFileContent
|
|
126
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-J6MB5ZHZ.js";
|
|
127
142
|
import {
|
|
128
143
|
getAutoMemoryRoot,
|
|
129
144
|
getUserAutoMemoryRoot
|
|
130
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-EDIDYZBT.js";
|
|
131
146
|
import {
|
|
132
147
|
atomicWriteFile
|
|
133
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-XFFRI3WM.js";
|
|
149
|
+
import {
|
|
150
|
+
isBinary,
|
|
151
|
+
normalizeContent,
|
|
152
|
+
stripAnsiAndControl,
|
|
153
|
+
stripHtmlComments
|
|
154
|
+
} from "./chunk-7VEYUF3N.js";
|
|
134
155
|
import {
|
|
135
156
|
getFolderStructure,
|
|
136
157
|
getStartupContextLength,
|
|
137
158
|
isSystemReminderContent,
|
|
138
159
|
stripSystemReminderBlocks
|
|
139
|
-
} from "./chunk-
|
|
160
|
+
} from "./chunk-D6PIMKY3.js";
|
|
140
161
|
import {
|
|
141
162
|
getQwenIgnoreFileNames,
|
|
142
163
|
require_ignore
|
|
143
|
-
} from "./chunk-
|
|
164
|
+
} from "./chunk-IZ2U57NY.js";
|
|
144
165
|
import {
|
|
145
166
|
ToolNames,
|
|
146
167
|
canonicalToolName
|
|
147
|
-
} from "./chunk-
|
|
168
|
+
} from "./chunk-RPBMP6BN.js";
|
|
148
169
|
import {
|
|
149
170
|
PATH_ARG_KEYS,
|
|
171
|
+
QWEN_DIR,
|
|
150
172
|
Storage,
|
|
151
173
|
createDebugLogger,
|
|
152
174
|
getErrorMessage,
|
|
153
175
|
isAbortError,
|
|
154
176
|
tildeifyPath,
|
|
155
177
|
unescapePath
|
|
156
|
-
} from "./chunk-
|
|
178
|
+
} from "./chunk-ZAFYHRVY.js";
|
|
157
179
|
import {
|
|
158
180
|
init_esbuild_shims
|
|
159
181
|
} from "./chunk-5O2XNYP6.js";
|
|
@@ -172,8 +194,8 @@ var require_utils = __commonJS({
|
|
|
172
194
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
173
195
|
exports.normalizePath = exports.isRootDirectory = exports.convertSlashes = exports.cleanPath = void 0;
|
|
174
196
|
var path_1 = __require("path");
|
|
175
|
-
function cleanPath(
|
|
176
|
-
let normalized2 = (0, path_1.normalize)(
|
|
197
|
+
function cleanPath(path20) {
|
|
198
|
+
let normalized2 = (0, path_1.normalize)(path20);
|
|
177
199
|
if (normalized2.length > 1 && normalized2[normalized2.length - 1] === path_1.sep)
|
|
178
200
|
normalized2 = normalized2.substring(0, normalized2.length - 1);
|
|
179
201
|
return normalized2;
|
|
@@ -181,28 +203,28 @@ var require_utils = __commonJS({
|
|
|
181
203
|
__name(cleanPath, "cleanPath");
|
|
182
204
|
exports.cleanPath = cleanPath;
|
|
183
205
|
var SLASHES_REGEX = /[\\/]/g;
|
|
184
|
-
function convertSlashes(
|
|
185
|
-
return
|
|
206
|
+
function convertSlashes(path20, separator) {
|
|
207
|
+
return path20.replace(SLASHES_REGEX, separator);
|
|
186
208
|
}
|
|
187
209
|
__name(convertSlashes, "convertSlashes");
|
|
188
210
|
exports.convertSlashes = convertSlashes;
|
|
189
211
|
var WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
190
|
-
function isRootDirectory(
|
|
191
|
-
return
|
|
212
|
+
function isRootDirectory(path20) {
|
|
213
|
+
return path20 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path20);
|
|
192
214
|
}
|
|
193
215
|
__name(isRootDirectory, "isRootDirectory");
|
|
194
216
|
exports.isRootDirectory = isRootDirectory;
|
|
195
|
-
function normalizePath2(
|
|
217
|
+
function normalizePath2(path20, options) {
|
|
196
218
|
const { resolvePaths, normalizePath: normalizePath3, pathSeparator } = options;
|
|
197
|
-
const pathNeedsCleaning = process.platform === "win32" &&
|
|
219
|
+
const pathNeedsCleaning = process.platform === "win32" && path20.includes("/") || path20.startsWith(".");
|
|
198
220
|
if (resolvePaths)
|
|
199
|
-
|
|
221
|
+
path20 = (0, path_1.resolve)(path20);
|
|
200
222
|
if (normalizePath3 || pathNeedsCleaning)
|
|
201
|
-
|
|
202
|
-
if (
|
|
223
|
+
path20 = cleanPath(path20);
|
|
224
|
+
if (path20 === ".")
|
|
203
225
|
return "";
|
|
204
|
-
const needsSeperator =
|
|
205
|
-
return convertSlashes(needsSeperator ?
|
|
226
|
+
const needsSeperator = path20[path20.length - 1] !== pathSeparator;
|
|
227
|
+
return convertSlashes(needsSeperator ? path20 + pathSeparator : path20, pathSeparator);
|
|
206
228
|
}
|
|
207
229
|
__name(normalizePath2, "normalizePath");
|
|
208
230
|
exports.normalizePath = normalizePath2;
|
|
@@ -277,9 +299,9 @@ var require_push_directory = __commonJS({
|
|
|
277
299
|
paths.push(directoryPath || ".");
|
|
278
300
|
}, "pushDirectory");
|
|
279
301
|
var pushDirectoryFilter = /* @__PURE__ */ __name((directoryPath, paths, filters) => {
|
|
280
|
-
const
|
|
281
|
-
if (filters.every((filter2) => filter2(
|
|
282
|
-
paths.push(
|
|
302
|
+
const path20 = directoryPath || ".";
|
|
303
|
+
if (filters.every((filter2) => filter2(path20, true))) {
|
|
304
|
+
paths.push(path20);
|
|
283
305
|
}
|
|
284
306
|
}, "pushDirectoryFilter");
|
|
285
307
|
var empty = /* @__PURE__ */ __name(() => {
|
|
@@ -390,31 +412,31 @@ var require_resolve_symlink = __commonJS({
|
|
|
390
412
|
exports.build = void 0;
|
|
391
413
|
var fs_1 = __importDefault(__require("fs"));
|
|
392
414
|
var path_1 = __require("path");
|
|
393
|
-
var resolveSymlinksAsync = /* @__PURE__ */ __name(function(
|
|
415
|
+
var resolveSymlinksAsync = /* @__PURE__ */ __name(function(path20, state, callback) {
|
|
394
416
|
const { queue, options: { suppressErrors } } = state;
|
|
395
417
|
queue.enqueue();
|
|
396
|
-
fs_1.default.realpath(
|
|
418
|
+
fs_1.default.realpath(path20, (error, resolvedPath) => {
|
|
397
419
|
if (error)
|
|
398
420
|
return queue.dequeue(suppressErrors ? null : error, state);
|
|
399
|
-
fs_1.default.stat(resolvedPath, (error2,
|
|
421
|
+
fs_1.default.stat(resolvedPath, (error2, stat5) => {
|
|
400
422
|
if (error2)
|
|
401
423
|
return queue.dequeue(suppressErrors ? null : error2, state);
|
|
402
|
-
if (
|
|
424
|
+
if (stat5.isDirectory() && isRecursive(path20, resolvedPath, state))
|
|
403
425
|
return queue.dequeue(null, state);
|
|
404
|
-
callback(
|
|
426
|
+
callback(stat5, resolvedPath);
|
|
405
427
|
queue.dequeue(null, state);
|
|
406
428
|
});
|
|
407
429
|
});
|
|
408
430
|
}, "resolveSymlinksAsync");
|
|
409
|
-
var resolveSymlinks = /* @__PURE__ */ __name(function(
|
|
431
|
+
var resolveSymlinks = /* @__PURE__ */ __name(function(path20, state, callback) {
|
|
410
432
|
const { queue, options: { suppressErrors } } = state;
|
|
411
433
|
queue.enqueue();
|
|
412
434
|
try {
|
|
413
|
-
const resolvedPath = fs_1.default.realpathSync(
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
435
|
+
const resolvedPath = fs_1.default.realpathSync(path20);
|
|
436
|
+
const stat5 = fs_1.default.statSync(resolvedPath);
|
|
437
|
+
if (stat5.isDirectory() && isRecursive(path20, resolvedPath, state))
|
|
416
438
|
return;
|
|
417
|
-
callback(
|
|
439
|
+
callback(stat5, resolvedPath);
|
|
418
440
|
} catch (e) {
|
|
419
441
|
if (!suppressErrors)
|
|
420
442
|
throw e;
|
|
@@ -427,10 +449,10 @@ var require_resolve_symlink = __commonJS({
|
|
|
427
449
|
}
|
|
428
450
|
__name(build, "build");
|
|
429
451
|
exports.build = build;
|
|
430
|
-
function isRecursive(
|
|
452
|
+
function isRecursive(path20, resolved, state) {
|
|
431
453
|
if (state.options.useRealPaths)
|
|
432
454
|
return isRecursiveUsingRealPaths(resolved, state);
|
|
433
|
-
let parent = (0, path_1.dirname)(
|
|
455
|
+
let parent = (0, path_1.dirname)(path20);
|
|
434
456
|
let depth = 1;
|
|
435
457
|
while (parent !== state.root && depth < 2) {
|
|
436
458
|
const resolvedPath = state.symlinks.get(parent);
|
|
@@ -440,7 +462,7 @@ var require_resolve_symlink = __commonJS({
|
|
|
440
462
|
else
|
|
441
463
|
parent = (0, path_1.dirname)(parent);
|
|
442
464
|
}
|
|
443
|
-
state.symlinks.set(
|
|
465
|
+
state.symlinks.set(path20, resolved);
|
|
444
466
|
return depth > 1;
|
|
445
467
|
}
|
|
446
468
|
__name(isRecursive, "isRecursive");
|
|
@@ -726,21 +748,21 @@ var require_walker = __commonJS({
|
|
|
726
748
|
const filename = this.joinPath(entry.name, directoryPath);
|
|
727
749
|
this.pushFile(filename, files, this.state.counts, filters);
|
|
728
750
|
} else if (entry.isDirectory()) {
|
|
729
|
-
let
|
|
730
|
-
if (exclude && exclude(entry.name,
|
|
751
|
+
let path20 = joinPath.joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
752
|
+
if (exclude && exclude(entry.name, path20))
|
|
731
753
|
continue;
|
|
732
|
-
this.pushDirectory(
|
|
733
|
-
this.walkDirectory(this.state,
|
|
754
|
+
this.pushDirectory(path20, paths, filters);
|
|
755
|
+
this.walkDirectory(this.state, path20, path20, depth - 1, this.walk);
|
|
734
756
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
735
|
-
let
|
|
736
|
-
this.resolveSymlink(
|
|
737
|
-
if (
|
|
757
|
+
let path20 = joinPath.joinPathWithBasePath(entry.name, directoryPath);
|
|
758
|
+
this.resolveSymlink(path20, this.state, (stat5, resolvedPath) => {
|
|
759
|
+
if (stat5.isDirectory()) {
|
|
738
760
|
resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options);
|
|
739
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath :
|
|
761
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path20 + pathSeparator))
|
|
740
762
|
return;
|
|
741
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath :
|
|
763
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path20 + pathSeparator, depth - 1, this.walk);
|
|
742
764
|
} else {
|
|
743
|
-
resolvedPath = useRealPaths ? resolvedPath :
|
|
765
|
+
resolvedPath = useRealPaths ? resolvedPath : path20;
|
|
744
766
|
const filename = (0, path_1.basename)(resolvedPath);
|
|
745
767
|
const directoryPath2 = (0, utils_1.normalizePath)((0, path_1.dirname)(resolvedPath), this.state.options);
|
|
746
768
|
resolvedPath = this.joinPath(filename, directoryPath2);
|
|
@@ -765,11 +787,11 @@ var require_async = __commonJS({
|
|
|
765
787
|
exports.callback = exports.promise = void 0;
|
|
766
788
|
var walker_1 = require_walker();
|
|
767
789
|
function promise(root, options) {
|
|
768
|
-
return new Promise((
|
|
790
|
+
return new Promise((resolve6, reject) => {
|
|
769
791
|
callback(root, options, (err, output) => {
|
|
770
792
|
if (err)
|
|
771
793
|
return reject(err);
|
|
772
|
-
|
|
794
|
+
resolve6(output);
|
|
773
795
|
});
|
|
774
796
|
});
|
|
775
797
|
}
|
|
@@ -967,7 +989,7 @@ var require_builder = __commonJS({
|
|
|
967
989
|
isMatch = globFn(patterns, ...options);
|
|
968
990
|
this.globCache[patterns.join("\0")] = isMatch;
|
|
969
991
|
}
|
|
970
|
-
this.options.filters.push((
|
|
992
|
+
this.options.filters.push((path20) => isMatch(path20));
|
|
971
993
|
return this;
|
|
972
994
|
}
|
|
973
995
|
};
|
|
@@ -1047,7 +1069,7 @@ var JsonFormatter = class {
|
|
|
1047
1069
|
// packages/core/src/core/nonInteractiveToolExecutor.ts
|
|
1048
1070
|
init_esbuild_shims();
|
|
1049
1071
|
async function executeToolCall(config, toolCallRequest, abortSignal, options = {}) {
|
|
1050
|
-
return new Promise((
|
|
1072
|
+
return new Promise((resolve6, reject) => {
|
|
1051
1073
|
new CoreToolScheduler({
|
|
1052
1074
|
config,
|
|
1053
1075
|
chatRecordingService: options.recordToolResult === false ? void 0 : config.getChatRecordingService(),
|
|
@@ -1056,7 +1078,7 @@ async function executeToolCall(config, toolCallRequest, abortSignal, options = {
|
|
|
1056
1078
|
if (options.onAllToolCallsComplete) {
|
|
1057
1079
|
await options.onAllToolCallsComplete(completedToolCalls);
|
|
1058
1080
|
}
|
|
1059
|
-
|
|
1081
|
+
resolve6(completedToolCalls[0].response);
|
|
1060
1082
|
}, "onAllToolCallsComplete"),
|
|
1061
1083
|
onToolCallsUpdate: options.onToolCallsUpdate,
|
|
1062
1084
|
onToolResultFullTurnModel: options.onToolResultFullTurnModel,
|
|
@@ -2550,7 +2572,7 @@ var McpTransportPool = class {
|
|
|
2550
2572
|
spawnWait.then(() => {
|
|
2551
2573
|
if (inflightTimer) clearTimeout(inflightTimer);
|
|
2552
2574
|
}),
|
|
2553
|
-
new Promise((
|
|
2575
|
+
new Promise((resolve6) => {
|
|
2554
2576
|
inflightTimer = setTimeout(
|
|
2555
2577
|
() => {
|
|
2556
2578
|
const stuckIds = [...this.spawnInFlight.keys()];
|
|
@@ -2559,7 +2581,7 @@ var McpTransportPool = class {
|
|
|
2559
2581
|
", "
|
|
2560
2582
|
)}. Proceeding with drain.`
|
|
2561
2583
|
);
|
|
2562
|
-
|
|
2584
|
+
resolve6();
|
|
2563
2585
|
},
|
|
2564
2586
|
Math.max(0, deadline - Date.now())
|
|
2565
2587
|
);
|
|
@@ -2585,8 +2607,8 @@ var McpTransportPool = class {
|
|
|
2585
2607
|
Promise.all(shutdownPromises).then(() => {
|
|
2586
2608
|
if (drainTimer) clearTimeout(drainTimer);
|
|
2587
2609
|
}),
|
|
2588
|
-
new Promise((
|
|
2589
|
-
drainTimer = setTimeout(() =>
|
|
2610
|
+
new Promise((resolve6) => {
|
|
2611
|
+
drainTimer = setTimeout(() => resolve6(), remaining);
|
|
2590
2612
|
drainTimer.unref?.();
|
|
2591
2613
|
})
|
|
2592
2614
|
]);
|
|
@@ -4572,6 +4594,552 @@ function takeRecentDialog(history, windowSize) {
|
|
|
4572
4594
|
}
|
|
4573
4595
|
__name(takeRecentDialog, "takeRecentDialog");
|
|
4574
4596
|
|
|
4597
|
+
// packages/core/src/ipc/uds-inbox.ts
|
|
4598
|
+
init_esbuild_shims();
|
|
4599
|
+
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
4600
|
+
import * as fsSync from "node:fs";
|
|
4601
|
+
import * as fs from "node:fs/promises";
|
|
4602
|
+
import * as net from "node:net";
|
|
4603
|
+
import * as path from "node:path";
|
|
4604
|
+
var debugLogger6 = createDebugLogger("PEER_IPC");
|
|
4605
|
+
var SOCKET_DIR_MODE = 448;
|
|
4606
|
+
var SOCKET_MODE = 384;
|
|
4607
|
+
var EMPTY_FALLBACK_DIR_GRACE_MS = 6e4;
|
|
4608
|
+
var SWEEP_BATCH_SIZE = 16;
|
|
4609
|
+
var MAX_PEER_CONNECTIONS = 64;
|
|
4610
|
+
var LINE_DEADLINE_MS = 3e4;
|
|
4611
|
+
var lastStartFailure = null;
|
|
4612
|
+
function getLastPeerInboxFailure() {
|
|
4613
|
+
return lastStartFailure;
|
|
4614
|
+
}
|
|
4615
|
+
__name(getLastPeerInboxFailure, "getLastPeerInboxFailure");
|
|
4616
|
+
function describePeerInboxFailure(failure) {
|
|
4617
|
+
const where = path.dirname(failure.socketPath);
|
|
4618
|
+
const attempts = failure.attempts > 1 ? ` Tried ${failure.attempts} candidate paths.` : "";
|
|
4619
|
+
switch (failure.cause) {
|
|
4620
|
+
case "non_local":
|
|
4621
|
+
return `the socket path "${failure.socketPath}" is not an absolute local path. ${failure.hint}${attempts}`;
|
|
4622
|
+
case "unsupported_platform":
|
|
4623
|
+
return `cross-session messaging is not available on this platform. ${failure.hint}${attempts}`;
|
|
4624
|
+
case "not_directory":
|
|
4625
|
+
return `"${where}" could not be created or is not a plain directory (${failure.detail}). ${failure.hint}${attempts}`;
|
|
4626
|
+
case "foreign_owner":
|
|
4627
|
+
return `"${where}" belongs to another user. ${failure.hint}${attempts}`;
|
|
4628
|
+
case "permission":
|
|
4629
|
+
return `this user cannot create or lock down "${where}" (${failure.detail}). ${failure.hint}${attempts}`;
|
|
4630
|
+
case "missing_ancestor":
|
|
4631
|
+
return `a parent of "${where}" does not exist. ${failure.hint}${attempts}`;
|
|
4632
|
+
case "path_too_long":
|
|
4633
|
+
return `"${failure.socketPath}" is longer than the ${MAX_SOCKET_PATH_BYTES}-byte socket path limit. ${failure.hint}${attempts}`;
|
|
4634
|
+
case "sibling_too_long":
|
|
4635
|
+
return `the socket path "${failure.socketPath}" is in use or could not be verified free, and the alternative name needed to work around it would exceed the ${MAX_SOCKET_PATH_BYTES}-byte socket path limit. ${failure.hint}${attempts}`;
|
|
4636
|
+
case "bind_failed":
|
|
4637
|
+
return `the socket could not be bound at "${failure.socketPath}" (${failure.detail}). ${failure.hint}${attempts}`;
|
|
4638
|
+
case "chmod_failed":
|
|
4639
|
+
return `the socket at "${failure.socketPath}" could not be restricted to this user (${failure.detail}). ${failure.hint}${attempts}`;
|
|
4640
|
+
default:
|
|
4641
|
+
return `${failure.detail} (at "${failure.socketPath}"). ${failure.hint}${attempts}`;
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4644
|
+
__name(describePeerInboxFailure, "describePeerInboxFailure");
|
|
4645
|
+
var HINT_RUNTIME_DIR = "Set XDG_RUNTIME_DIR (or TMPDIR) to a directory you own, then restart.";
|
|
4646
|
+
var InboxSetupError = class extends Error {
|
|
4647
|
+
constructor(failureCause, message, hint = HINT_RUNTIME_DIR) {
|
|
4648
|
+
super(message);
|
|
4649
|
+
this.failureCause = failureCause;
|
|
4650
|
+
this.hint = hint;
|
|
4651
|
+
this.name = "InboxSetupError";
|
|
4652
|
+
}
|
|
4653
|
+
static {
|
|
4654
|
+
__name(this, "InboxSetupError");
|
|
4655
|
+
}
|
|
4656
|
+
};
|
|
4657
|
+
function classify(error, socketPath) {
|
|
4658
|
+
if (error instanceof InboxSetupError) {
|
|
4659
|
+
return {
|
|
4660
|
+
cause: error.failureCause,
|
|
4661
|
+
socketPath,
|
|
4662
|
+
detail: error.message,
|
|
4663
|
+
hint: error.hint,
|
|
4664
|
+
attempts: 1
|
|
4665
|
+
};
|
|
4666
|
+
}
|
|
4667
|
+
const code = error?.code;
|
|
4668
|
+
const detail = describe(error);
|
|
4669
|
+
const base = { socketPath, detail, attempts: 1 };
|
|
4670
|
+
switch (code) {
|
|
4671
|
+
case "EACCES":
|
|
4672
|
+
case "EPERM":
|
|
4673
|
+
case "EROFS":
|
|
4674
|
+
return { ...base, cause: "permission", hint: HINT_RUNTIME_DIR };
|
|
4675
|
+
case "ENOENT":
|
|
4676
|
+
return { ...base, cause: "missing_ancestor", hint: HINT_RUNTIME_DIR };
|
|
4677
|
+
// mkdir(recursive) reports a file in the way as EEXIST, not ENOTDIR.
|
|
4678
|
+
case "EEXIST":
|
|
4679
|
+
case "ENOTDIR":
|
|
4680
|
+
case "ELOOP":
|
|
4681
|
+
return {
|
|
4682
|
+
...base,
|
|
4683
|
+
cause: "not_directory",
|
|
4684
|
+
hint: "Remove it, or set XDG_RUNTIME_DIR to a directory you own, then restart."
|
|
4685
|
+
};
|
|
4686
|
+
case "ENAMETOOLONG":
|
|
4687
|
+
return {
|
|
4688
|
+
...base,
|
|
4689
|
+
cause: "path_too_long",
|
|
4690
|
+
hint: "Set XDG_RUNTIME_DIR or TMPDIR to a shorter directory, then restart."
|
|
4691
|
+
};
|
|
4692
|
+
default:
|
|
4693
|
+
return { ...base, cause: "unknown", hint: HINT_RUNTIME_DIR };
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
__name(classify, "classify");
|
|
4697
|
+
async function classifyMkdirFailure(error, socketPath, socketDir) {
|
|
4698
|
+
if (error?.code === "ENOENT") {
|
|
4699
|
+
try {
|
|
4700
|
+
await fs.lstat(path.dirname(socketDir));
|
|
4701
|
+
return classify(
|
|
4702
|
+
new InboxSetupError("permission", describe(error)),
|
|
4703
|
+
socketPath
|
|
4704
|
+
);
|
|
4705
|
+
} catch {
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4708
|
+
return classify(error, socketPath);
|
|
4709
|
+
}
|
|
4710
|
+
__name(classifyMkdirFailure, "classifyMkdirFailure");
|
|
4711
|
+
var SOCKET_FILENAME = /^\d+(-[0-9a-f]{8})?\.sock$/;
|
|
4712
|
+
function pidOfSocketFilename(name) {
|
|
4713
|
+
if (!SOCKET_FILENAME.test(name)) return null;
|
|
4714
|
+
const pid = Number.parseInt(name.split(/[-.]/)[0], 10);
|
|
4715
|
+
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
4716
|
+
}
|
|
4717
|
+
__name(pidOfSocketFilename, "pidOfSocketFilename");
|
|
4718
|
+
function siblingOverflowFailure(socketPath) {
|
|
4719
|
+
return classify(
|
|
4720
|
+
new InboxSetupError(
|
|
4721
|
+
"sibling_too_long",
|
|
4722
|
+
`${socketPath} is in use or could not be verified free and a sibling name would exceed sun_path`,
|
|
4723
|
+
"Set XDG_RUNTIME_DIR or TMPDIR to a shorter directory, then restart."
|
|
4724
|
+
),
|
|
4725
|
+
socketPath
|
|
4726
|
+
);
|
|
4727
|
+
}
|
|
4728
|
+
__name(siblingOverflowFailure, "siblingOverflowFailure");
|
|
4729
|
+
function siblingSocketPath(socketPath) {
|
|
4730
|
+
const dir = path.dirname(socketPath);
|
|
4731
|
+
const base = path.basename(socketPath, ".sock").split("-")[0];
|
|
4732
|
+
const sibling = path.join(
|
|
4733
|
+
dir,
|
|
4734
|
+
`${base}-${randomBytes(4).toString("hex")}.sock`
|
|
4735
|
+
);
|
|
4736
|
+
return Buffer.byteLength(sibling) <= MAX_SOCKET_PATH_BYTES ? sibling : null;
|
|
4737
|
+
}
|
|
4738
|
+
__name(siblingSocketPath, "siblingSocketPath");
|
|
4739
|
+
var NONCE_DIRNAME = new RegExp(`^${SOCKET_DIR_NAME}-[0-9a-f]{16}$`);
|
|
4740
|
+
function createLineReader(onLine, onOverflow) {
|
|
4741
|
+
let buffer = "";
|
|
4742
|
+
return (chunk) => {
|
|
4743
|
+
buffer += chunk;
|
|
4744
|
+
let newline = buffer.indexOf("\n");
|
|
4745
|
+
while (newline !== -1) {
|
|
4746
|
+
const line = buffer.slice(0, newline);
|
|
4747
|
+
buffer = buffer.slice(newline + 1);
|
|
4748
|
+
if (line.trim().length > 0) onLine(line);
|
|
4749
|
+
newline = buffer.indexOf("\n");
|
|
4750
|
+
}
|
|
4751
|
+
if (buffer.length > MAX_FRAME_BYTES) {
|
|
4752
|
+
buffer = "";
|
|
4753
|
+
onOverflow();
|
|
4754
|
+
}
|
|
4755
|
+
};
|
|
4756
|
+
}
|
|
4757
|
+
__name(createLineReader, "createLineReader");
|
|
4758
|
+
async function sweepOrphanSockets(dir, selfSocketPath) {
|
|
4759
|
+
let entries;
|
|
4760
|
+
try {
|
|
4761
|
+
entries = await fs.readdir(dir);
|
|
4762
|
+
} catch {
|
|
4763
|
+
return 0;
|
|
4764
|
+
}
|
|
4765
|
+
let swept = 0;
|
|
4766
|
+
for (let offset = 0; offset < entries.length; offset += SWEEP_BATCH_SIZE) {
|
|
4767
|
+
await Promise.all(
|
|
4768
|
+
entries.slice(offset, offset + SWEEP_BATCH_SIZE).map(async (name) => {
|
|
4769
|
+
const pid = pidOfSocketFilename(name);
|
|
4770
|
+
if (pid === null) return;
|
|
4771
|
+
const fullPath = path.join(dir, name);
|
|
4772
|
+
if (fullPath === selfSocketPath) return;
|
|
4773
|
+
if (isPidAlive(pid)) return;
|
|
4774
|
+
if (await probePeerSocketVerdict(fullPath) !== "dead") return;
|
|
4775
|
+
if (isPidAlive(pid)) return;
|
|
4776
|
+
try {
|
|
4777
|
+
await fs.unlink(fullPath);
|
|
4778
|
+
swept += 1;
|
|
4779
|
+
} catch {
|
|
4780
|
+
}
|
|
4781
|
+
})
|
|
4782
|
+
);
|
|
4783
|
+
}
|
|
4784
|
+
if (swept > 0) {
|
|
4785
|
+
debugLogger6.debug(`swept ${swept} orphaned peer socket(s) from ${dir}`);
|
|
4786
|
+
}
|
|
4787
|
+
return swept;
|
|
4788
|
+
}
|
|
4789
|
+
__name(sweepOrphanSockets, "sweepOrphanSockets");
|
|
4790
|
+
async function sweepOrphanSocketDirs(parent, selfDir) {
|
|
4791
|
+
let entries;
|
|
4792
|
+
try {
|
|
4793
|
+
entries = await fs.readdir(parent);
|
|
4794
|
+
} catch {
|
|
4795
|
+
return 0;
|
|
4796
|
+
}
|
|
4797
|
+
const uid = typeof process.getuid === "function" ? process.getuid() : null;
|
|
4798
|
+
let swept = 0;
|
|
4799
|
+
for (let offset = 0; offset < entries.length; offset += SWEEP_BATCH_SIZE) {
|
|
4800
|
+
await Promise.all(
|
|
4801
|
+
entries.slice(offset, offset + SWEEP_BATCH_SIZE).map(async (name) => {
|
|
4802
|
+
if (!NONCE_DIRNAME.test(name)) return;
|
|
4803
|
+
const dir = path.join(parent, name);
|
|
4804
|
+
if (dir === selfDir) return;
|
|
4805
|
+
try {
|
|
4806
|
+
const stat5 = await fs.lstat(dir);
|
|
4807
|
+
if (!stat5.isDirectory()) return;
|
|
4808
|
+
if (uid !== null && stat5.uid !== uid) return;
|
|
4809
|
+
const files = await fs.readdir(dir);
|
|
4810
|
+
if (files.length === 0 && Date.now() - stat5.mtimeMs < EMPTY_FALLBACK_DIR_GRACE_MS) {
|
|
4811
|
+
return;
|
|
4812
|
+
}
|
|
4813
|
+
for (const file of files) {
|
|
4814
|
+
const pid = pidOfSocketFilename(file);
|
|
4815
|
+
if (pid === null || isPidAlive(pid)) return;
|
|
4816
|
+
if (await probePeerSocketVerdict(path.join(dir, file)) !== "dead")
|
|
4817
|
+
return;
|
|
4818
|
+
}
|
|
4819
|
+
for (const file of files) {
|
|
4820
|
+
const pid = pidOfSocketFilename(file);
|
|
4821
|
+
if (pid === null || isPidAlive(pid)) return;
|
|
4822
|
+
}
|
|
4823
|
+
for (const file of files) await fs.unlink(path.join(dir, file));
|
|
4824
|
+
await fs.rmdir(dir);
|
|
4825
|
+
swept += 1;
|
|
4826
|
+
} catch {
|
|
4827
|
+
}
|
|
4828
|
+
})
|
|
4829
|
+
);
|
|
4830
|
+
}
|
|
4831
|
+
if (swept > 0) {
|
|
4832
|
+
debugLogger6.debug(
|
|
4833
|
+
`swept ${swept} orphaned peer socket director${swept === 1 ? "y" : "ies"} from ${parent}`
|
|
4834
|
+
);
|
|
4835
|
+
}
|
|
4836
|
+
return swept;
|
|
4837
|
+
}
|
|
4838
|
+
__name(sweepOrphanSocketDirs, "sweepOrphanSocketDirs");
|
|
4839
|
+
function sweepAround(socketPath) {
|
|
4840
|
+
const dir = path.dirname(socketPath);
|
|
4841
|
+
const base = path.basename(dir);
|
|
4842
|
+
if (base === SOCKET_DIR_NAME) return sweepOrphanSockets(dir, socketPath);
|
|
4843
|
+
if (NONCE_DIRNAME.test(base)) {
|
|
4844
|
+
return sweepOrphanSocketDirs(path.dirname(dir), dir);
|
|
4845
|
+
}
|
|
4846
|
+
return Promise.resolve(0);
|
|
4847
|
+
}
|
|
4848
|
+
__name(sweepAround, "sweepAround");
|
|
4849
|
+
async function startPeerInbox(options) {
|
|
4850
|
+
const candidates = options.socketPath !== void 0 ? [options.socketPath] : resolvePeerSocketCandidates();
|
|
4851
|
+
let failure = null;
|
|
4852
|
+
for (const [index, candidate] of candidates.entries()) {
|
|
4853
|
+
const result = await bindAt(
|
|
4854
|
+
candidate,
|
|
4855
|
+
options,
|
|
4856
|
+
options.socketPath === void 0
|
|
4857
|
+
);
|
|
4858
|
+
if ("inbox" in result) {
|
|
4859
|
+
lastStartFailure = null;
|
|
4860
|
+
if (index > 0) {
|
|
4861
|
+
debugLogger6.warn(
|
|
4862
|
+
`peer inbox bound at fallback path ${candidate} after ${index} unusable candidate(s)`
|
|
4863
|
+
);
|
|
4864
|
+
}
|
|
4865
|
+
for (const sweepCandidate of candidates) {
|
|
4866
|
+
void sweepAround(sweepCandidate).catch(() => {
|
|
4867
|
+
});
|
|
4868
|
+
}
|
|
4869
|
+
return result.inbox;
|
|
4870
|
+
}
|
|
4871
|
+
const attempt = { ...result.failure, attempts: index + 1 };
|
|
4872
|
+
debugLogger6.warn(
|
|
4873
|
+
`peer inbox could not bind at ${candidate} (${attempt.cause}): ${attempt.detail}`
|
|
4874
|
+
);
|
|
4875
|
+
if (attempt.cause === "unsupported_platform") {
|
|
4876
|
+
failure = { ...attempt, attempts: 1 };
|
|
4877
|
+
break;
|
|
4878
|
+
}
|
|
4879
|
+
if (failure === null) {
|
|
4880
|
+
failure = attempt;
|
|
4881
|
+
} else {
|
|
4882
|
+
failure.attempts = index + 1;
|
|
4883
|
+
}
|
|
4884
|
+
}
|
|
4885
|
+
if (failure) {
|
|
4886
|
+
lastStartFailure = failure;
|
|
4887
|
+
debugLogger6.error(
|
|
4888
|
+
`cross-session messaging is OFF for this session: ${describePeerInboxFailure(failure)}`
|
|
4889
|
+
);
|
|
4890
|
+
}
|
|
4891
|
+
return null;
|
|
4892
|
+
}
|
|
4893
|
+
__name(startPeerInbox, "startPeerInbox");
|
|
4894
|
+
async function bindAt(requestedPath, options, automaticPath) {
|
|
4895
|
+
let socketPath = requestedPath;
|
|
4896
|
+
if (!isLocalIpcPath(socketPath)) {
|
|
4897
|
+
const unsupportedPlatform = automaticPath && process.platform === "win32";
|
|
4898
|
+
return {
|
|
4899
|
+
failure: classify(
|
|
4900
|
+
new InboxSetupError(
|
|
4901
|
+
unsupportedPlatform ? "unsupported_platform" : "non_local",
|
|
4902
|
+
unsupportedPlatform ? "automatic peer inbox paths are not supported on Windows" : `refusing to bind a non-local IPC path: ${socketPath}`,
|
|
4903
|
+
unsupportedPlatform ? "Disable cross-session messaging for this session." : "Use an absolute local path."
|
|
4904
|
+
),
|
|
4905
|
+
requestedPath
|
|
4906
|
+
)
|
|
4907
|
+
};
|
|
4908
|
+
}
|
|
4909
|
+
if (Buffer.byteLength(socketPath) > MAX_SOCKET_PATH_BYTES) {
|
|
4910
|
+
return {
|
|
4911
|
+
failure: classify(
|
|
4912
|
+
Object.assign(new Error(`${socketPath} exceeds sun_path`), {
|
|
4913
|
+
code: "ENAMETOOLONG"
|
|
4914
|
+
}),
|
|
4915
|
+
requestedPath
|
|
4916
|
+
)
|
|
4917
|
+
};
|
|
4918
|
+
}
|
|
4919
|
+
const socketDir = path.dirname(socketPath);
|
|
4920
|
+
const dropDirIfEmpty = /* @__PURE__ */ __name(async () => {
|
|
4921
|
+
await fs.rmdir(socketDir).catch(() => {
|
|
4922
|
+
});
|
|
4923
|
+
}, "dropDirIfEmpty");
|
|
4924
|
+
const dir = socketDir;
|
|
4925
|
+
try {
|
|
4926
|
+
await fs.mkdir(dir, { recursive: true, mode: SOCKET_DIR_MODE });
|
|
4927
|
+
} catch (error) {
|
|
4928
|
+
await dropDirIfEmpty();
|
|
4929
|
+
return {
|
|
4930
|
+
failure: await classifyMkdirFailure(error, requestedPath, socketDir)
|
|
4931
|
+
};
|
|
4932
|
+
}
|
|
4933
|
+
try {
|
|
4934
|
+
const dirStat = await fs.lstat(dir);
|
|
4935
|
+
const uid = typeof process.getuid === "function" ? process.getuid() : null;
|
|
4936
|
+
if (!dirStat.isDirectory()) {
|
|
4937
|
+
throw new InboxSetupError(
|
|
4938
|
+
"not_directory",
|
|
4939
|
+
`${dir} is not a directory`,
|
|
4940
|
+
"Remove it, or set XDG_RUNTIME_DIR to a directory you own, then restart."
|
|
4941
|
+
);
|
|
4942
|
+
}
|
|
4943
|
+
if (uid !== null && dirStat.uid !== uid) {
|
|
4944
|
+
throw new InboxSetupError(
|
|
4945
|
+
"foreign_owner",
|
|
4946
|
+
`${dir} belongs to uid ${dirStat.uid}, not ${uid}`
|
|
4947
|
+
);
|
|
4948
|
+
}
|
|
4949
|
+
await fs.chmod(dir, SOCKET_DIR_MODE);
|
|
4950
|
+
} catch (error) {
|
|
4951
|
+
await dropDirIfEmpty();
|
|
4952
|
+
return { failure: classify(error, requestedPath) };
|
|
4953
|
+
}
|
|
4954
|
+
if (await probePeerSocketVerdict(socketPath) !== "dead") {
|
|
4955
|
+
const sibling = siblingSocketPath(socketPath);
|
|
4956
|
+
if (sibling === null) {
|
|
4957
|
+
await dropDirIfEmpty();
|
|
4958
|
+
return { failure: siblingOverflowFailure(requestedPath) };
|
|
4959
|
+
}
|
|
4960
|
+
debugLogger6.debug(
|
|
4961
|
+
`${socketPath} is in use or could not be verified free; binding at ${sibling}`
|
|
4962
|
+
);
|
|
4963
|
+
socketPath = sibling;
|
|
4964
|
+
}
|
|
4965
|
+
try {
|
|
4966
|
+
await fs.unlink(socketPath);
|
|
4967
|
+
} catch {
|
|
4968
|
+
}
|
|
4969
|
+
const connections = /* @__PURE__ */ new Set();
|
|
4970
|
+
const lineDeadlineMs = options.lineDeadlineMs ?? LINE_DEADLINE_MS;
|
|
4971
|
+
const server = net.createServer({ allowHalfOpen: true }, (socket) => {
|
|
4972
|
+
connections.add(socket);
|
|
4973
|
+
socket.setEncoding("utf8");
|
|
4974
|
+
socket.unref();
|
|
4975
|
+
let deadline = null;
|
|
4976
|
+
const arm = /* @__PURE__ */ __name(() => {
|
|
4977
|
+
if (deadline) clearTimeout(deadline);
|
|
4978
|
+
deadline = setTimeout(() => {
|
|
4979
|
+
deadline = null;
|
|
4980
|
+
debugLogger6.debug(
|
|
4981
|
+
`closing a peer connection that sent no complete line within ${lineDeadlineMs} ms`
|
|
4982
|
+
);
|
|
4983
|
+
socket.destroy();
|
|
4984
|
+
}, lineDeadlineMs);
|
|
4985
|
+
deadline.unref();
|
|
4986
|
+
}, "arm");
|
|
4987
|
+
arm();
|
|
4988
|
+
let authed = options.requiredToken === void 0;
|
|
4989
|
+
let auth;
|
|
4990
|
+
let refused = false;
|
|
4991
|
+
const read2 = createLineReader(
|
|
4992
|
+
(line) => {
|
|
4993
|
+
if (refused) return;
|
|
4994
|
+
if (!authed) {
|
|
4995
|
+
arm();
|
|
4996
|
+
const presented = parsePeerAuthLine(line);
|
|
4997
|
+
if (presented !== null) {
|
|
4998
|
+
auth = authKindOf(options, presented);
|
|
4999
|
+
}
|
|
5000
|
+
if (auth !== void 0) {
|
|
5001
|
+
authed = true;
|
|
5002
|
+
return;
|
|
5003
|
+
}
|
|
5004
|
+
debugLogger6.debug(
|
|
5005
|
+
"dropping a connection whose first line did not authenticate: no valid auth line, or token mismatch"
|
|
5006
|
+
);
|
|
5007
|
+
refused = true;
|
|
5008
|
+
socket.destroy();
|
|
5009
|
+
return;
|
|
5010
|
+
}
|
|
5011
|
+
const frame = parsePeerFrame(line);
|
|
5012
|
+
if (frame === null) {
|
|
5013
|
+
debugLogger6.debug(
|
|
5014
|
+
`dropping unparseable frame: ${line.slice(0, 200)}`
|
|
5015
|
+
);
|
|
5016
|
+
return;
|
|
5017
|
+
}
|
|
5018
|
+
arm();
|
|
5019
|
+
try {
|
|
5020
|
+
options.onFrame(frame, auth);
|
|
5021
|
+
} catch (error) {
|
|
5022
|
+
debugLogger6.error(`onFrame threw: ${describe(error)}`);
|
|
5023
|
+
}
|
|
5024
|
+
},
|
|
5025
|
+
() => {
|
|
5026
|
+
debugLogger6.error(
|
|
5027
|
+
"peer sent more than 1 MiB without a newline; dropping the connection"
|
|
5028
|
+
);
|
|
5029
|
+
socket.destroy();
|
|
5030
|
+
}
|
|
5031
|
+
);
|
|
5032
|
+
socket.on("data", read2);
|
|
5033
|
+
socket.on("end", () => {
|
|
5034
|
+
socket.end();
|
|
5035
|
+
});
|
|
5036
|
+
socket.on("error", (error) => {
|
|
5037
|
+
debugLogger6.debug(`peer connection error: ${error.message}`);
|
|
5038
|
+
});
|
|
5039
|
+
socket.on("close", () => {
|
|
5040
|
+
if (deadline) clearTimeout(deadline);
|
|
5041
|
+
deadline = null;
|
|
5042
|
+
connections.delete(socket);
|
|
5043
|
+
});
|
|
5044
|
+
});
|
|
5045
|
+
server.maxConnections = MAX_PEER_CONNECTIONS;
|
|
5046
|
+
server.on("error", (error) => {
|
|
5047
|
+
debugLogger6.error(`peer inbox server error: ${describe(error)}`);
|
|
5048
|
+
});
|
|
5049
|
+
const listenAt = /* @__PURE__ */ __name((target) => new Promise((resolve6, reject) => {
|
|
5050
|
+
server.once("error", reject);
|
|
5051
|
+
server.listen(target, () => {
|
|
5052
|
+
server.removeListener("error", reject);
|
|
5053
|
+
resolve6();
|
|
5054
|
+
});
|
|
5055
|
+
}), "listenAt");
|
|
5056
|
+
try {
|
|
5057
|
+
await listenAt(socketPath);
|
|
5058
|
+
} catch (error) {
|
|
5059
|
+
const sibling = error?.code === "EADDRINUSE" ? siblingSocketPath(socketPath) : null;
|
|
5060
|
+
if (error?.code === "EADDRINUSE" && sibling === null) {
|
|
5061
|
+
await dropDirIfEmpty();
|
|
5062
|
+
return { failure: siblingOverflowFailure(requestedPath) };
|
|
5063
|
+
}
|
|
5064
|
+
let raced = error;
|
|
5065
|
+
if (sibling !== null) {
|
|
5066
|
+
try {
|
|
5067
|
+
await listenAt(sibling);
|
|
5068
|
+
socketPath = sibling;
|
|
5069
|
+
raced = null;
|
|
5070
|
+
} catch (retryError) {
|
|
5071
|
+
raced = retryError;
|
|
5072
|
+
}
|
|
5073
|
+
}
|
|
5074
|
+
if (raced !== null) {
|
|
5075
|
+
await dropDirIfEmpty();
|
|
5076
|
+
const classified = classify(raced, requestedPath);
|
|
5077
|
+
return {
|
|
5078
|
+
failure: classified.cause === "unknown" ? {
|
|
5079
|
+
...classified,
|
|
5080
|
+
cause: "bind_failed",
|
|
5081
|
+
hint: "If another process holds the path, restart after it exits; otherwise set XDG_RUNTIME_DIR to a directory you own."
|
|
5082
|
+
} : classified
|
|
5083
|
+
};
|
|
5084
|
+
}
|
|
5085
|
+
}
|
|
5086
|
+
try {
|
|
5087
|
+
await fs.chmod(socketPath, SOCKET_MODE);
|
|
5088
|
+
} catch (error) {
|
|
5089
|
+
server.close();
|
|
5090
|
+
try {
|
|
5091
|
+
fsSync.unlinkSync(socketPath);
|
|
5092
|
+
} catch {
|
|
5093
|
+
}
|
|
5094
|
+
await dropDirIfEmpty();
|
|
5095
|
+
return {
|
|
5096
|
+
failure: {
|
|
5097
|
+
...classify(error, requestedPath),
|
|
5098
|
+
cause: "chmod_failed"
|
|
5099
|
+
}
|
|
5100
|
+
};
|
|
5101
|
+
}
|
|
5102
|
+
server.unref();
|
|
5103
|
+
debugLogger6.debug(`peer inbox listening: ${socketPath}`);
|
|
5104
|
+
let closed = false;
|
|
5105
|
+
return {
|
|
5106
|
+
inbox: {
|
|
5107
|
+
socketPath,
|
|
5108
|
+
async close() {
|
|
5109
|
+
if (closed) return;
|
|
5110
|
+
closed = true;
|
|
5111
|
+
for (const socket of connections) socket.destroy();
|
|
5112
|
+
connections.clear();
|
|
5113
|
+
await new Promise((resolve6) => server.close(() => resolve6()));
|
|
5114
|
+
try {
|
|
5115
|
+
await fs.unlink(socketPath);
|
|
5116
|
+
} catch {
|
|
5117
|
+
}
|
|
5118
|
+
debugLogger6.debug(`peer inbox closed: ${socketPath}`);
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
};
|
|
5122
|
+
}
|
|
5123
|
+
__name(bindAt, "bindAt");
|
|
5124
|
+
function tokenMatches(expected, presented) {
|
|
5125
|
+
const a = Buffer.from(expected);
|
|
5126
|
+
const b = Buffer.from(presented);
|
|
5127
|
+
return a.length === b.length && timingSafeEqual(a, b);
|
|
5128
|
+
}
|
|
5129
|
+
__name(tokenMatches, "tokenMatches");
|
|
5130
|
+
function authKindOf(options, presented) {
|
|
5131
|
+
const peer = options.requiredToken !== void 0 && tokenMatches(options.requiredToken, presented);
|
|
5132
|
+
const child = options.childToken !== void 0 && tokenMatches(options.childToken, presented);
|
|
5133
|
+
if (peer) return "peer";
|
|
5134
|
+
if (child) return "child";
|
|
5135
|
+
return void 0;
|
|
5136
|
+
}
|
|
5137
|
+
__name(authKindOf, "authKindOf");
|
|
5138
|
+
function describe(error) {
|
|
5139
|
+
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
5140
|
+
}
|
|
5141
|
+
__name(describe, "describe");
|
|
5142
|
+
|
|
4575
5143
|
// packages/core/src/services/web-terminal-registry.ts
|
|
4576
5144
|
init_esbuild_shims();
|
|
4577
5145
|
import { spawnSync } from "node:child_process";
|
|
@@ -4909,8 +5477,8 @@ var WebTerminalRegistry = class {
|
|
|
4909
5477
|
|
|
4910
5478
|
// packages/core/src/memory/remember.ts
|
|
4911
5479
|
init_esbuild_shims();
|
|
4912
|
-
import
|
|
4913
|
-
var
|
|
5480
|
+
import path2 from "node:path";
|
|
5481
|
+
var debugLogger7 = createDebugLogger("AUTO_MEMORY_REMEMBER");
|
|
4914
5482
|
function buildManagedRememberPrompt(fact, projectRoot, options = {}) {
|
|
4915
5483
|
const trimmed = fact.trim();
|
|
4916
5484
|
const projectDir = projectRoot ? getAutoMemoryRoot(projectRoot) : void 0;
|
|
@@ -5085,20 +5653,20 @@ async function runManagedRememberByAgent(params) {
|
|
|
5085
5653
|
],
|
|
5086
5654
|
abortSignal: params.abortSignal,
|
|
5087
5655
|
suppressChatRecording: true,
|
|
5088
|
-
completeAfterFirstSuccessfulWrite: /* @__PURE__ */ __name((filePath) =>
|
|
5656
|
+
completeAfterFirstSuccessfulWrite: /* @__PURE__ */ __name((filePath) => path2.basename(filePath) !== "MEMORY.md", "completeAfterFirstSuccessfulWrite")
|
|
5089
5657
|
});
|
|
5090
5658
|
} catch (err) {
|
|
5091
5659
|
await Promise.all([
|
|
5092
5660
|
...params.scope !== "user" ? [rebuildManagedAutoMemoryIndex(params.projectRoot)] : [],
|
|
5093
5661
|
...params.scope !== "project" ? [rebuildUserAutoMemoryIndex()] : []
|
|
5094
5662
|
]).catch((rebuildErr) => {
|
|
5095
|
-
|
|
5663
|
+
debugLogger7.error("Memory index rebuild failed:", rebuildErr);
|
|
5096
5664
|
});
|
|
5097
5665
|
throw err;
|
|
5098
5666
|
}
|
|
5099
5667
|
const filesWritten = result.filesWritten ?? [];
|
|
5100
5668
|
const entryFilesWritten = filesWritten.filter(
|
|
5101
|
-
(filePath) =>
|
|
5669
|
+
(filePath) => path2.basename(filePath) !== "MEMORY.md"
|
|
5102
5670
|
);
|
|
5103
5671
|
const { writtenScopes, escapeError } = (() => {
|
|
5104
5672
|
const scopes = [];
|
|
@@ -5118,33 +5686,33 @@ async function runManagedRememberByAgent(params) {
|
|
|
5118
5686
|
const rebuildWrittenScopes = /* @__PURE__ */ __name(() => Promise.all([
|
|
5119
5687
|
writtenScopes.includes("project") ? rebuildManagedAutoMemoryIndex(params.projectRoot) : Promise.resolve(),
|
|
5120
5688
|
writtenScopes.includes("user") ? params.scope === "user" ? rebuildUserAutoMemoryIndex() : rebuildUserAutoMemoryIndex().catch((err) => {
|
|
5121
|
-
|
|
5689
|
+
debugLogger7.error("User memory index rebuild failed:", err);
|
|
5122
5690
|
}) : Promise.resolve()
|
|
5123
5691
|
]), "rebuildWrittenScopes");
|
|
5124
5692
|
if (escapeError !== void 0) {
|
|
5125
5693
|
if (result.status === "completed") {
|
|
5126
5694
|
await rebuildWrittenScopes().catch((err) => {
|
|
5127
|
-
|
|
5695
|
+
debugLogger7.error("Memory index rebuild failed:", err);
|
|
5128
5696
|
});
|
|
5129
5697
|
throw escapeError;
|
|
5130
5698
|
}
|
|
5131
|
-
|
|
5699
|
+
debugLogger7.error("Remember write audit failed:", escapeError);
|
|
5132
5700
|
}
|
|
5133
5701
|
if (result.status === "failed" || result.status === "cancelled") {
|
|
5134
5702
|
await rebuildWrittenScopes().catch((err) => {
|
|
5135
|
-
|
|
5703
|
+
debugLogger7.error("Memory index rebuild failed:", err);
|
|
5136
5704
|
});
|
|
5137
5705
|
throw new Error(
|
|
5138
5706
|
result.terminateReason || (result.status === "failed" ? "Remember agent failed" : "Remember agent cancelled")
|
|
5139
5707
|
);
|
|
5140
5708
|
}
|
|
5141
5709
|
if (entryFilesWritten.length === 0) {
|
|
5142
|
-
|
|
5710
|
+
debugLogger7.warn("Remember agent completed without writing memory.", {
|
|
5143
5711
|
filesTouched: result.filesTouched,
|
|
5144
5712
|
finalTextLength: result.finalText?.length ?? 0
|
|
5145
5713
|
});
|
|
5146
5714
|
await rebuildWrittenScopes().catch((err) => {
|
|
5147
|
-
|
|
5715
|
+
debugLogger7.error("Memory index rebuild failed:", err);
|
|
5148
5716
|
});
|
|
5149
5717
|
throw Object.assign(new Error("Remember agent did not update any memory"), {
|
|
5150
5718
|
code: "remember_no_update"
|
|
@@ -5156,7 +5724,7 @@ async function runManagedRememberByAgent(params) {
|
|
|
5156
5724
|
);
|
|
5157
5725
|
if (params.scope && touchedScopes.some((scope) => scope !== params.scope)) {
|
|
5158
5726
|
await rebuildWrittenScopes().catch((err) => {
|
|
5159
|
-
|
|
5727
|
+
debugLogger7.error("Memory index rebuild failed:", err);
|
|
5160
5728
|
});
|
|
5161
5729
|
throw Object.assign(
|
|
5162
5730
|
new Error(
|
|
@@ -5251,19 +5819,19 @@ ${tickText}`,
|
|
|
5251
5819
|
|
|
5252
5820
|
// packages/core/src/skills/bundled/loop/loop-tick-resolver.ts
|
|
5253
5821
|
init_esbuild_shims();
|
|
5254
|
-
import * as
|
|
5822
|
+
import * as path4 from "node:path";
|
|
5255
5823
|
|
|
5256
5824
|
// packages/core/src/skills/bundled/loop/loop-task-file.ts
|
|
5257
5825
|
init_esbuild_shims();
|
|
5258
|
-
import * as
|
|
5259
|
-
import * as
|
|
5260
|
-
var
|
|
5826
|
+
import * as fs2 from "node:fs/promises";
|
|
5827
|
+
import * as path3 from "node:path";
|
|
5828
|
+
var debugLogger8 = createDebugLogger("LOOP_TASK_FILE");
|
|
5261
5829
|
var LOOP_TASK_FILE_MAX_BYTES = 25e3;
|
|
5262
5830
|
var moduleRealDirCache = /* @__PURE__ */ new Map();
|
|
5263
5831
|
function resolveRealDir(dir, cache) {
|
|
5264
5832
|
let real = cache.get(dir);
|
|
5265
5833
|
if (real === void 0) {
|
|
5266
|
-
real =
|
|
5834
|
+
real = fs2.realpath(dir);
|
|
5267
5835
|
real.catch(() => cache.delete(dir));
|
|
5268
5836
|
cache.set(dir, real);
|
|
5269
5837
|
}
|
|
@@ -5274,19 +5842,19 @@ function isWithin(root, real) {
|
|
|
5274
5842
|
if (real === root) {
|
|
5275
5843
|
return true;
|
|
5276
5844
|
}
|
|
5277
|
-
const prefix = root.endsWith(
|
|
5845
|
+
const prefix = root.endsWith(path3.sep) ? root : root + path3.sep;
|
|
5278
5846
|
return real.startsWith(prefix);
|
|
5279
5847
|
}
|
|
5280
5848
|
__name(isWithin, "isWithin");
|
|
5281
5849
|
async function readBoundedTaskFile(filePath) {
|
|
5282
|
-
const handle = await
|
|
5850
|
+
const handle = await fs2.open(filePath, "r");
|
|
5283
5851
|
try {
|
|
5284
|
-
const
|
|
5285
|
-
if (!
|
|
5852
|
+
const stat5 = await handle.stat();
|
|
5853
|
+
if (!stat5.isFile()) {
|
|
5286
5854
|
return null;
|
|
5287
5855
|
}
|
|
5288
5856
|
const cap = LOOP_TASK_FILE_MAX_BYTES + 1;
|
|
5289
|
-
const allocSize = Math.min(cap,
|
|
5857
|
+
const allocSize = Math.min(cap, stat5.size + 1);
|
|
5290
5858
|
const buffer = Buffer.alloc(allocSize);
|
|
5291
5859
|
let total = 0;
|
|
5292
5860
|
while (total < allocSize) {
|
|
@@ -5306,7 +5874,7 @@ async function readBoundedTaskFile(filePath) {
|
|
|
5306
5874
|
try {
|
|
5307
5875
|
await handle.close();
|
|
5308
5876
|
} catch (closeErr) {
|
|
5309
|
-
|
|
5877
|
+
debugLogger8.debug("failed to close loop.md handle", { closeErr });
|
|
5310
5878
|
}
|
|
5311
5879
|
}
|
|
5312
5880
|
}
|
|
@@ -5314,47 +5882,47 @@ __name(readBoundedTaskFile, "readBoundedTaskFile");
|
|
|
5314
5882
|
async function readLoopTaskFile({
|
|
5315
5883
|
projectRoot,
|
|
5316
5884
|
homeDir,
|
|
5317
|
-
homeQwenDir =
|
|
5885
|
+
homeQwenDir = path3.join(homeDir, ".qwen"),
|
|
5318
5886
|
allowProjectFile = false,
|
|
5319
5887
|
realDirCache = moduleRealDirCache
|
|
5320
5888
|
}) {
|
|
5321
5889
|
if (!allowProjectFile) {
|
|
5322
|
-
|
|
5890
|
+
debugLogger8.debug("skipping project loop.md: folder is untrusted");
|
|
5323
5891
|
}
|
|
5324
5892
|
const candidates = [
|
|
5325
5893
|
...allowProjectFile ? [
|
|
5326
5894
|
{
|
|
5327
5895
|
source: "project",
|
|
5328
|
-
path:
|
|
5896
|
+
path: path3.join(projectRoot, ".qwen", "loop.md")
|
|
5329
5897
|
}
|
|
5330
5898
|
] : [],
|
|
5331
|
-
{ source: "home", path:
|
|
5899
|
+
{ source: "home", path: path3.join(homeQwenDir, "loop.md") }
|
|
5332
5900
|
];
|
|
5333
5901
|
for (const { source, path: filePath } of candidates) {
|
|
5334
5902
|
let buffer;
|
|
5335
5903
|
try {
|
|
5336
5904
|
if (source === "project") {
|
|
5337
|
-
const projectStat = await
|
|
5905
|
+
const projectStat = await fs2.lstat(filePath);
|
|
5338
5906
|
if (projectStat.isSymbolicLink()) {
|
|
5339
|
-
|
|
5907
|
+
debugLogger8.debug("skipping symlinked project loop.md", { filePath });
|
|
5340
5908
|
continue;
|
|
5341
5909
|
}
|
|
5342
5910
|
if (!projectStat.isFile()) {
|
|
5343
|
-
|
|
5911
|
+
debugLogger8.debug("skipping non-regular project loop.md", {
|
|
5344
5912
|
filePath
|
|
5345
5913
|
});
|
|
5346
5914
|
continue;
|
|
5347
5915
|
}
|
|
5348
5916
|
if (projectStat.nlink > 1) {
|
|
5349
|
-
|
|
5917
|
+
debugLogger8.debug("skipping hard-linked project loop.md", {
|
|
5350
5918
|
filePath
|
|
5351
5919
|
});
|
|
5352
5920
|
continue;
|
|
5353
5921
|
}
|
|
5354
5922
|
const realRoot = await resolveRealDir(projectRoot, realDirCache);
|
|
5355
|
-
const real = await
|
|
5923
|
+
const real = await fs2.realpath(filePath);
|
|
5356
5924
|
if (!isWithin(realRoot, real)) {
|
|
5357
|
-
|
|
5925
|
+
debugLogger8.debug(
|
|
5358
5926
|
"skipping project loop.md that escapes the workspace",
|
|
5359
5927
|
{
|
|
5360
5928
|
filePath,
|
|
@@ -5365,19 +5933,19 @@ async function readLoopTaskFile({
|
|
|
5365
5933
|
}
|
|
5366
5934
|
buffer = await readBoundedTaskFile(real);
|
|
5367
5935
|
} else {
|
|
5368
|
-
const homeStat = await
|
|
5936
|
+
const homeStat = await fs2.stat(filePath);
|
|
5369
5937
|
if (!homeStat.isFile()) {
|
|
5370
|
-
|
|
5938
|
+
debugLogger8.debug("skipping non-regular home loop.md", { filePath });
|
|
5371
5939
|
continue;
|
|
5372
5940
|
}
|
|
5373
5941
|
if (homeStat.nlink > 1) {
|
|
5374
|
-
|
|
5942
|
+
debugLogger8.debug("skipping hard-linked home loop.md", { filePath });
|
|
5375
5943
|
continue;
|
|
5376
5944
|
}
|
|
5377
5945
|
const realHome = await resolveRealDir(homeDir, realDirCache);
|
|
5378
|
-
const real = await
|
|
5946
|
+
const real = await fs2.realpath(filePath);
|
|
5379
5947
|
if (!isWithin(realHome, real)) {
|
|
5380
|
-
|
|
5948
|
+
debugLogger8.debug(
|
|
5381
5949
|
"skipping home loop.md that escapes the home directory",
|
|
5382
5950
|
{ filePath, resolved: real }
|
|
5383
5951
|
);
|
|
@@ -5396,7 +5964,7 @@ async function readLoopTaskFile({
|
|
|
5396
5964
|
continue;
|
|
5397
5965
|
}
|
|
5398
5966
|
if (buffer.toString("utf8").trim().length === 0) {
|
|
5399
|
-
|
|
5967
|
+
debugLogger8.debug("skipping whitespace-only loop.md", {
|
|
5400
5968
|
source,
|
|
5401
5969
|
filePath
|
|
5402
5970
|
});
|
|
@@ -5431,7 +5999,7 @@ async function readLoopTaskFile({
|
|
|
5431
5999
|
} else {
|
|
5432
6000
|
content = buffer.toString("utf8");
|
|
5433
6001
|
}
|
|
5434
|
-
|
|
6002
|
+
debugLogger8.debug("read loop.md", {
|
|
5435
6003
|
source,
|
|
5436
6004
|
bytes: buffer.byteLength,
|
|
5437
6005
|
truncated
|
|
@@ -5570,8 +6138,8 @@ ${tickText}`,
|
|
|
5570
6138
|
* - any other out-of-$HOME dir → a generic placeholder, never the path.
|
|
5571
6139
|
* The real absolute path stays in LOCAL debug logs only. */
|
|
5572
6140
|
homeLoopLabel() {
|
|
5573
|
-
const homeQwenDir = this.deps.homeQwenDir ??
|
|
5574
|
-
const homeLoopPath =
|
|
6141
|
+
const homeQwenDir = this.deps.homeQwenDir ?? path4.join(this.deps.homeDir, ".qwen");
|
|
6142
|
+
const homeLoopPath = path4.join(homeQwenDir, "loop.md");
|
|
5575
6143
|
const tildeified = tildeifyPath(homeLoopPath);
|
|
5576
6144
|
if (tildeified !== homeLoopPath) {
|
|
5577
6145
|
return tildeified.replace(/\\/g, "/");
|
|
@@ -6012,9 +6580,9 @@ function encodeInsightProgressMessage(stage, progress, detail) {
|
|
|
6012
6580
|
return JSON.stringify(payload);
|
|
6013
6581
|
}
|
|
6014
6582
|
__name(encodeInsightProgressMessage, "encodeInsightProgressMessage");
|
|
6015
|
-
function encodeInsightReadyMessage(
|
|
6583
|
+
function encodeInsightReadyMessage(path20) {
|
|
6016
6584
|
const payload = {
|
|
6017
|
-
insight_ready: { path:
|
|
6585
|
+
insight_ready: { path: path20 }
|
|
6018
6586
|
};
|
|
6019
6587
|
return JSON.stringify(payload);
|
|
6020
6588
|
}
|
|
@@ -6029,8 +6597,8 @@ __name(encodeInsightErrorMessage, "encodeInsightErrorMessage");
|
|
|
6029
6597
|
|
|
6030
6598
|
// packages/core/src/core/logger.ts
|
|
6031
6599
|
init_esbuild_shims();
|
|
6032
|
-
import
|
|
6033
|
-
import { promises as
|
|
6600
|
+
import path5 from "node:path";
|
|
6601
|
+
import { promises as fs3 } from "node:fs";
|
|
6034
6602
|
var LOG_FILE_NAME = "logs.json";
|
|
6035
6603
|
function encodeTagName(str) {
|
|
6036
6604
|
return encodeURIComponent(str);
|
|
@@ -6083,7 +6651,7 @@ var Logger = class {
|
|
|
6083
6651
|
throw new Error("Log file path not set during read attempt.");
|
|
6084
6652
|
}
|
|
6085
6653
|
try {
|
|
6086
|
-
const fileContent = await
|
|
6654
|
+
const fileContent = await fs3.readFile(this.logFilePath, "utf-8");
|
|
6087
6655
|
const parsedLogs = JSON.parse(fileContent);
|
|
6088
6656
|
if (!Array.isArray(parsedLogs)) {
|
|
6089
6657
|
this.debugLogger.debug(
|
|
@@ -6119,7 +6687,7 @@ var Logger = class {
|
|
|
6119
6687
|
if (!this.logFilePath) return;
|
|
6120
6688
|
const backupPath = `${this.logFilePath}.${reason}.${Date.now()}.bak`;
|
|
6121
6689
|
try {
|
|
6122
|
-
await
|
|
6690
|
+
await fs3.rename(this.logFilePath, backupPath);
|
|
6123
6691
|
this.debugLogger.debug(`Backed up corrupted log file to ${backupPath}`);
|
|
6124
6692
|
} catch (_backupError) {
|
|
6125
6693
|
}
|
|
@@ -6129,12 +6697,12 @@ var Logger = class {
|
|
|
6129
6697
|
return;
|
|
6130
6698
|
}
|
|
6131
6699
|
this.qwenDir = this.storage.getProjectTempDir();
|
|
6132
|
-
this.logFilePath =
|
|
6700
|
+
this.logFilePath = path5.join(this.qwenDir, LOG_FILE_NAME);
|
|
6133
6701
|
try {
|
|
6134
|
-
await
|
|
6702
|
+
await fs3.mkdir(this.qwenDir, { recursive: true });
|
|
6135
6703
|
let fileExisted = true;
|
|
6136
6704
|
try {
|
|
6137
|
-
await
|
|
6705
|
+
await fs3.access(this.logFilePath);
|
|
6138
6706
|
} catch (_e) {
|
|
6139
6707
|
fileExisted = false;
|
|
6140
6708
|
}
|
|
@@ -6358,12 +6926,12 @@ var Logger = class {
|
|
|
6358
6926
|
throw new Error("Checkpoint file path not set.");
|
|
6359
6927
|
}
|
|
6360
6928
|
const encodedTag = encodeTagName(tag);
|
|
6361
|
-
return
|
|
6929
|
+
return path5.join(this.qwenDir, `checkpoint-${encodedTag}.json`);
|
|
6362
6930
|
}
|
|
6363
6931
|
async _getCheckpointPath(tag) {
|
|
6364
6932
|
const newPath = this._checkpointPath(tag);
|
|
6365
6933
|
try {
|
|
6366
|
-
await
|
|
6934
|
+
await fs3.access(newPath);
|
|
6367
6935
|
return newPath;
|
|
6368
6936
|
} catch (error) {
|
|
6369
6937
|
const nodeError = error;
|
|
@@ -6371,9 +6939,9 @@ var Logger = class {
|
|
|
6371
6939
|
throw error;
|
|
6372
6940
|
}
|
|
6373
6941
|
}
|
|
6374
|
-
const oldPath =
|
|
6942
|
+
const oldPath = path5.join(this.qwenDir, `checkpoint-${tag}.json`);
|
|
6375
6943
|
try {
|
|
6376
|
-
await
|
|
6944
|
+
await fs3.access(oldPath);
|
|
6377
6945
|
return oldPath;
|
|
6378
6946
|
} catch (error) {
|
|
6379
6947
|
const nodeError = error;
|
|
@@ -6390,9 +6958,9 @@ var Logger = class {
|
|
|
6390
6958
|
);
|
|
6391
6959
|
return;
|
|
6392
6960
|
}
|
|
6393
|
-
const
|
|
6961
|
+
const path20 = this._checkpointPath(tag);
|
|
6394
6962
|
try {
|
|
6395
|
-
await atomicWriteFile(
|
|
6963
|
+
await atomicWriteFile(path20, JSON.stringify(conversation, null, 2), {
|
|
6396
6964
|
encoding: "utf-8"
|
|
6397
6965
|
});
|
|
6398
6966
|
} catch (error) {
|
|
@@ -6406,13 +6974,13 @@ var Logger = class {
|
|
|
6406
6974
|
);
|
|
6407
6975
|
return [];
|
|
6408
6976
|
}
|
|
6409
|
-
const
|
|
6977
|
+
const path20 = await this._getCheckpointPath(tag);
|
|
6410
6978
|
try {
|
|
6411
|
-
const fileContent = await
|
|
6979
|
+
const fileContent = await fs3.readFile(path20, "utf-8");
|
|
6412
6980
|
const parsedContent = JSON.parse(fileContent);
|
|
6413
6981
|
if (!Array.isArray(parsedContent)) {
|
|
6414
6982
|
this.debugLogger.warn(
|
|
6415
|
-
`Checkpoint file at ${
|
|
6983
|
+
`Checkpoint file at ${path20} is not a valid JSON array. Returning empty checkpoint.`
|
|
6416
6984
|
);
|
|
6417
6985
|
return [];
|
|
6418
6986
|
}
|
|
@@ -6423,7 +6991,7 @@ var Logger = class {
|
|
|
6423
6991
|
return [];
|
|
6424
6992
|
}
|
|
6425
6993
|
this.debugLogger.error(
|
|
6426
|
-
`Failed to read or parse checkpoint file ${
|
|
6994
|
+
`Failed to read or parse checkpoint file ${path20}:`,
|
|
6427
6995
|
error
|
|
6428
6996
|
);
|
|
6429
6997
|
return [];
|
|
@@ -6439,7 +7007,7 @@ var Logger = class {
|
|
|
6439
7007
|
let deletedSomething = false;
|
|
6440
7008
|
const newPath = this._checkpointPath(tag);
|
|
6441
7009
|
try {
|
|
6442
|
-
await
|
|
7010
|
+
await fs3.unlink(newPath);
|
|
6443
7011
|
deletedSomething = true;
|
|
6444
7012
|
} catch (error) {
|
|
6445
7013
|
const nodeError = error;
|
|
@@ -6451,10 +7019,10 @@ var Logger = class {
|
|
|
6451
7019
|
throw error;
|
|
6452
7020
|
}
|
|
6453
7021
|
}
|
|
6454
|
-
const oldPath =
|
|
7022
|
+
const oldPath = path5.join(this.qwenDir, `checkpoint-${tag}.json`);
|
|
6455
7023
|
if (newPath !== oldPath) {
|
|
6456
7024
|
try {
|
|
6457
|
-
await
|
|
7025
|
+
await fs3.unlink(oldPath);
|
|
6458
7026
|
deletedSomething = true;
|
|
6459
7027
|
} catch (error) {
|
|
6460
7028
|
const nodeError = error;
|
|
@@ -6478,34 +7046,330 @@ var Logger = class {
|
|
|
6478
7046
|
let filePath;
|
|
6479
7047
|
try {
|
|
6480
7048
|
filePath = await this._getCheckpointPath(tag);
|
|
6481
|
-
await
|
|
7049
|
+
await fs3.access(filePath);
|
|
6482
7050
|
return true;
|
|
6483
7051
|
} catch (error) {
|
|
6484
7052
|
const nodeError = error;
|
|
6485
7053
|
if (nodeError.code === "ENOENT") {
|
|
6486
7054
|
return false;
|
|
6487
7055
|
}
|
|
6488
|
-
this.debugLogger.error(
|
|
6489
|
-
`Failed to check checkpoint existence for ${filePath ?? `path for tag "${tag}"`}:`,
|
|
6490
|
-
error
|
|
7056
|
+
this.debugLogger.error(
|
|
7057
|
+
`Failed to check checkpoint existence for ${filePath ?? `path for tag "${tag}"`}:`,
|
|
7058
|
+
error
|
|
7059
|
+
);
|
|
7060
|
+
throw error;
|
|
7061
|
+
}
|
|
7062
|
+
}
|
|
7063
|
+
close() {
|
|
7064
|
+
this.initialized = false;
|
|
7065
|
+
this.logFilePath = void 0;
|
|
7066
|
+
this.logs = [];
|
|
7067
|
+
this.lastLoggedUserEntry = null;
|
|
7068
|
+
this.writeQueue = Promise.resolve();
|
|
7069
|
+
this.sessionId = void 0;
|
|
7070
|
+
this.messageId = 0;
|
|
7071
|
+
}
|
|
7072
|
+
};
|
|
7073
|
+
|
|
7074
|
+
// packages/core/src/core/output-style-files.ts
|
|
7075
|
+
init_esbuild_shims();
|
|
7076
|
+
import * as fs4 from "fs/promises";
|
|
7077
|
+
import * as os from "os";
|
|
7078
|
+
import * as path6 from "path";
|
|
7079
|
+
var debugLogger9 = createDebugLogger("OUTPUT_STYLE_FILES");
|
|
7080
|
+
var OUTPUT_STYLES_DIR_NAME = "output-styles";
|
|
7081
|
+
var MAX_OUTPUT_STYLE_FILE_BYTES = 25e3;
|
|
7082
|
+
var MAX_OUTPUT_STYLE_NAME_LENGTH = 64;
|
|
7083
|
+
var MAX_DERIVED_DESCRIPTION_LENGTH = 120;
|
|
7084
|
+
var KNOWN_FRONTMATTER_KEYS = /* @__PURE__ */ new Set([
|
|
7085
|
+
"name",
|
|
7086
|
+
"description",
|
|
7087
|
+
"keep-coding-instructions"
|
|
7088
|
+
]);
|
|
7089
|
+
var FRONTMATTER_FENCE = /^---[ \t]*\n([\s\S]*?)\n?---[ \t]*(?:\n|$)([\s\S]*)$/;
|
|
7090
|
+
function isFrontmatterBlock(block) {
|
|
7091
|
+
let sawKey = false;
|
|
7092
|
+
for (const line of block.split("\n")) {
|
|
7093
|
+
const trimmed = line.trimStart();
|
|
7094
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
7095
|
+
continue;
|
|
7096
|
+
}
|
|
7097
|
+
if (/^\s/.test(line)) {
|
|
7098
|
+
if (!sawKey) {
|
|
7099
|
+
return false;
|
|
7100
|
+
}
|
|
7101
|
+
continue;
|
|
7102
|
+
}
|
|
7103
|
+
const key = /^([A-Za-z0-9_-]+):(?:\s|$)/.exec(line)?.[1];
|
|
7104
|
+
if (!key || !KNOWN_FRONTMATTER_KEYS.has(key)) {
|
|
7105
|
+
return false;
|
|
7106
|
+
}
|
|
7107
|
+
sawKey = true;
|
|
7108
|
+
}
|
|
7109
|
+
return sawKey || !block.trim();
|
|
7110
|
+
}
|
|
7111
|
+
__name(isFrontmatterBlock, "isFrontmatterBlock");
|
|
7112
|
+
function parseOutputStyleFile(content, filePath, source) {
|
|
7113
|
+
const normalized2 = normalizeContent(content);
|
|
7114
|
+
const fence = FRONTMATTER_FENCE.exec(normalized2);
|
|
7115
|
+
const match = fence && isFrontmatterBlock(fence[1]) ? fence : null;
|
|
7116
|
+
const frontmatter = match ? parse(match[1]) : {};
|
|
7117
|
+
const body = stripHtmlComments(match ? match[2] : normalized2).trim();
|
|
7118
|
+
const fallbackName = path6.basename(filePath).replace(/\.md$/i, "").trim();
|
|
7119
|
+
const name = validateOutputStyleName(
|
|
7120
|
+
typeof frontmatter["name"] === "string" ? frontmatter["name"].trim() : fallbackName
|
|
7121
|
+
);
|
|
7122
|
+
if (!body) {
|
|
7123
|
+
throw new Error("the file has no prompt body");
|
|
7124
|
+
}
|
|
7125
|
+
const declaredDescription = sanitizeDescription(
|
|
7126
|
+
typeof frontmatter["description"] === "string" ? frontmatter["description"] : ""
|
|
7127
|
+
);
|
|
7128
|
+
const description = declaredDescription || sanitizeDescription(deriveDescription(body)) || `Custom ${name} output style`;
|
|
7129
|
+
const keepCodingInstructions = resolveKeepCodingInstructions(
|
|
7130
|
+
frontmatter,
|
|
7131
|
+
name,
|
|
7132
|
+
filePath
|
|
7133
|
+
);
|
|
7134
|
+
const unknownKeys = Object.keys(frontmatter).filter(
|
|
7135
|
+
(key) => !KNOWN_FRONTMATTER_KEYS.has(key)
|
|
7136
|
+
);
|
|
7137
|
+
if (unknownKeys.length > 0) {
|
|
7138
|
+
debugLogger9.warn(
|
|
7139
|
+
`Output style ${filePath}: ignoring unknown frontmatter keys ${unknownKeys.join(", ")}`
|
|
7140
|
+
);
|
|
7141
|
+
}
|
|
7142
|
+
return { name, source, description, keepCodingInstructions, prompt: body };
|
|
7143
|
+
}
|
|
7144
|
+
__name(parseOutputStyleFile, "parseOutputStyleFile");
|
|
7145
|
+
function resolveKeepCodingInstructions(frontmatter, name, filePath) {
|
|
7146
|
+
if (!("keep-coding-instructions" in frontmatter)) {
|
|
7147
|
+
return getBuiltInOutputStyle(name)?.keepCodingInstructions ?? false;
|
|
7148
|
+
}
|
|
7149
|
+
const raw = frontmatter["keep-coding-instructions"];
|
|
7150
|
+
const spelling = typeof raw === "string" ? raw.trim().toLowerCase() : raw;
|
|
7151
|
+
if (spelling === true || spelling === "true") {
|
|
7152
|
+
return true;
|
|
7153
|
+
}
|
|
7154
|
+
if (spelling !== false && spelling !== "false") {
|
|
7155
|
+
debugLogger9.warn(
|
|
7156
|
+
`Output style ${filePath}: keep-coding-instructions value ${JSON.stringify(raw)} is not true or false; treating it as false`
|
|
7157
|
+
);
|
|
7158
|
+
}
|
|
7159
|
+
return false;
|
|
7160
|
+
}
|
|
7161
|
+
__name(resolveKeepCodingInstructions, "resolveKeepCodingInstructions");
|
|
7162
|
+
function sanitizeDescription(description) {
|
|
7163
|
+
const flattened = stripAnsiAndControl(description).replace(new RegExp("\\p{Cf}", "gu"), "").replace(/\s+/gu, " ").trim();
|
|
7164
|
+
return flattened.length > MAX_DERIVED_DESCRIPTION_LENGTH ? flattened.slice(0, MAX_DERIVED_DESCRIPTION_LENGTH) : flattened;
|
|
7165
|
+
}
|
|
7166
|
+
__name(sanitizeDescription, "sanitizeDescription");
|
|
7167
|
+
function validateOutputStyleName(name) {
|
|
7168
|
+
if (!name) {
|
|
7169
|
+
throw new Error("the style name is empty");
|
|
7170
|
+
}
|
|
7171
|
+
if (name.length > MAX_OUTPUT_STYLE_NAME_LENGTH) {
|
|
7172
|
+
throw new Error(
|
|
7173
|
+
`the style name is longer than ${MAX_OUTPUT_STYLE_NAME_LENGTH} characters`
|
|
7174
|
+
);
|
|
7175
|
+
}
|
|
7176
|
+
if (/[\p{Cc}\p{Cf}]/u.test(name)) {
|
|
7177
|
+
throw new Error("the style name contains control characters");
|
|
7178
|
+
}
|
|
7179
|
+
if (name.toLowerCase() === "default") {
|
|
7180
|
+
throw new Error('"default" is reserved for the built-in default style');
|
|
7181
|
+
}
|
|
7182
|
+
return name;
|
|
7183
|
+
}
|
|
7184
|
+
__name(validateOutputStyleName, "validateOutputStyleName");
|
|
7185
|
+
function deriveDescription(body) {
|
|
7186
|
+
let inFence = false;
|
|
7187
|
+
for (const rawLine of body.split("\n")) {
|
|
7188
|
+
const trimmed = rawLine.trim();
|
|
7189
|
+
if (trimmed.startsWith("```") || trimmed.startsWith("~~~")) {
|
|
7190
|
+
inFence = !inFence;
|
|
7191
|
+
continue;
|
|
7192
|
+
}
|
|
7193
|
+
if (inFence) {
|
|
7194
|
+
continue;
|
|
7195
|
+
}
|
|
7196
|
+
const line = trimmed.replace(/^(?:#{1,6}\s+|[-*+]\s+|>\s*|\d+[.)]\s+)/, "").replace(/[*_`]/g, "").trim();
|
|
7197
|
+
if (!line) {
|
|
7198
|
+
continue;
|
|
7199
|
+
}
|
|
7200
|
+
return line.length > MAX_DERIVED_DESCRIPTION_LENGTH ? `${line.slice(0, MAX_DERIVED_DESCRIPTION_LENGTH - 1)}\u2026` : line;
|
|
7201
|
+
}
|
|
7202
|
+
return "";
|
|
7203
|
+
}
|
|
7204
|
+
__name(deriveDescription, "deriveDescription");
|
|
7205
|
+
async function resolveStyleFileToRead(filePath, source, confineTo) {
|
|
7206
|
+
const stat5 = source === "project" ? await fs4.lstat(filePath) : await fs4.stat(filePath);
|
|
7207
|
+
if (source === "project" && stat5.isSymbolicLink()) {
|
|
7208
|
+
debugLogger9.warn(`Skipping output style ${filePath}: it is a symlink`);
|
|
7209
|
+
return null;
|
|
7210
|
+
}
|
|
7211
|
+
if (!stat5.isFile()) {
|
|
7212
|
+
return null;
|
|
7213
|
+
}
|
|
7214
|
+
if (stat5.nlink > 1) {
|
|
7215
|
+
debugLogger9.warn(`Skipping output style ${filePath}: it is a hard link`);
|
|
7216
|
+
return null;
|
|
7217
|
+
}
|
|
7218
|
+
const realPath = await fs4.realpath(filePath);
|
|
7219
|
+
const realRoot = await fs4.realpath(confineTo);
|
|
7220
|
+
if (realPath !== realRoot && !isWithinRoot(realPath, realRoot)) {
|
|
7221
|
+
debugLogger9.warn(
|
|
7222
|
+
`Skipping output style ${filePath}: it resolves outside ${realRoot}`
|
|
7223
|
+
);
|
|
7224
|
+
return null;
|
|
7225
|
+
}
|
|
7226
|
+
return realPath;
|
|
7227
|
+
}
|
|
7228
|
+
__name(resolveStyleFileToRead, "resolveStyleFileToRead");
|
|
7229
|
+
async function readBoundedStyleFile(readPath) {
|
|
7230
|
+
const handle = await fs4.open(readPath, "r");
|
|
7231
|
+
try {
|
|
7232
|
+
const cap = MAX_OUTPUT_STYLE_FILE_BYTES + 1;
|
|
7233
|
+
const buffer = Buffer.alloc(cap);
|
|
7234
|
+
let total = 0;
|
|
7235
|
+
while (total < cap) {
|
|
7236
|
+
const { bytesRead } = await handle.read(
|
|
7237
|
+
buffer,
|
|
7238
|
+
total,
|
|
7239
|
+
cap - total,
|
|
7240
|
+
total
|
|
7241
|
+
);
|
|
7242
|
+
if (bytesRead === 0) {
|
|
7243
|
+
break;
|
|
7244
|
+
}
|
|
7245
|
+
total += bytesRead;
|
|
7246
|
+
}
|
|
7247
|
+
return buffer.subarray(0, total);
|
|
7248
|
+
} finally {
|
|
7249
|
+
await handle.close();
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7252
|
+
__name(readBoundedStyleFile, "readBoundedStyleFile");
|
|
7253
|
+
async function loadOutputStylesFromDir(dir, source, confineTo) {
|
|
7254
|
+
let entries;
|
|
7255
|
+
try {
|
|
7256
|
+
entries = await fs4.readdir(dir);
|
|
7257
|
+
} catch (error) {
|
|
7258
|
+
if (error.code !== "ENOENT") {
|
|
7259
|
+
debugLogger9.warn(`Cannot read output styles directory ${dir}:`, error);
|
|
7260
|
+
}
|
|
7261
|
+
return [];
|
|
7262
|
+
}
|
|
7263
|
+
const styles = [];
|
|
7264
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7265
|
+
for (const entry of entries.filter((e) => /\.md$/i.test(e)).sort()) {
|
|
7266
|
+
const filePath = path6.join(dir, entry);
|
|
7267
|
+
try {
|
|
7268
|
+
const readPath = await resolveStyleFileToRead(
|
|
7269
|
+
filePath,
|
|
7270
|
+
source,
|
|
7271
|
+
confineTo
|
|
7272
|
+
);
|
|
7273
|
+
if (!readPath) {
|
|
7274
|
+
continue;
|
|
7275
|
+
}
|
|
7276
|
+
const buffer = await readBoundedStyleFile(readPath);
|
|
7277
|
+
if (buffer.byteLength > MAX_OUTPUT_STYLE_FILE_BYTES) {
|
|
7278
|
+
debugLogger9.warn(
|
|
7279
|
+
`Skipping output style ${filePath}: larger than ${MAX_OUTPUT_STYLE_FILE_BYTES} bytes`
|
|
7280
|
+
);
|
|
7281
|
+
continue;
|
|
7282
|
+
}
|
|
7283
|
+
if (isBinary(buffer)) {
|
|
7284
|
+
debugLogger9.warn(
|
|
7285
|
+
`Skipping output style ${filePath}: it is not UTF-8 text`
|
|
7286
|
+
);
|
|
7287
|
+
continue;
|
|
7288
|
+
}
|
|
7289
|
+
const style = parseOutputStyleFile(
|
|
7290
|
+
buffer.toString("utf8"),
|
|
7291
|
+
filePath,
|
|
7292
|
+
source
|
|
7293
|
+
);
|
|
7294
|
+
const key = style.name.toLowerCase();
|
|
7295
|
+
if (seen.has(key)) {
|
|
7296
|
+
debugLogger9.warn(
|
|
7297
|
+
`Skipping output style ${filePath}: another file in ${dir} already defines "${style.name}"`
|
|
7298
|
+
);
|
|
7299
|
+
continue;
|
|
7300
|
+
}
|
|
7301
|
+
seen.add(key);
|
|
7302
|
+
styles.push(style);
|
|
7303
|
+
} catch (error) {
|
|
7304
|
+
debugLogger9.warn(
|
|
7305
|
+
`Skipping output style ${filePath}: ${error instanceof Error ? error.message : String(error)}`
|
|
6491
7306
|
);
|
|
6492
|
-
throw error;
|
|
6493
7307
|
}
|
|
6494
7308
|
}
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
7309
|
+
return styles;
|
|
7310
|
+
}
|
|
7311
|
+
__name(loadOutputStylesFromDir, "loadOutputStylesFromDir");
|
|
7312
|
+
function getUserOutputStylesDir() {
|
|
7313
|
+
return path6.join(Storage.getGlobalQwenDir(), OUTPUT_STYLES_DIR_NAME);
|
|
7314
|
+
}
|
|
7315
|
+
__name(getUserOutputStylesDir, "getUserOutputStylesDir");
|
|
7316
|
+
function getUserOutputStylesRoot() {
|
|
7317
|
+
const envDir = process.env["QWEN_HOME"];
|
|
7318
|
+
if (envDir) {
|
|
7319
|
+
return Storage.getGlobalQwenDir();
|
|
7320
|
+
}
|
|
7321
|
+
return os.homedir() || path6.dirname(Storage.getGlobalQwenDir());
|
|
7322
|
+
}
|
|
7323
|
+
__name(getUserOutputStylesRoot, "getUserOutputStylesRoot");
|
|
7324
|
+
function getProjectOutputStylesDir(projectRoot) {
|
|
7325
|
+
return path6.join(projectRoot, QWEN_DIR, OUTPUT_STYLES_DIR_NAME);
|
|
7326
|
+
}
|
|
7327
|
+
__name(getProjectOutputStylesDir, "getProjectOutputStylesDir");
|
|
7328
|
+
async function loadOutputStyleCatalog(options = {}) {
|
|
7329
|
+
const projectRoot = options.projectRoot;
|
|
7330
|
+
const includeProject = projectRoot !== void 0 && path6.resolve(getProjectOutputStylesDir(projectRoot)) !== path6.resolve(getUserOutputStylesDir());
|
|
7331
|
+
const [projectStyles, userStyles] = await Promise.all([
|
|
7332
|
+
includeProject ? loadOutputStylesFromDir(
|
|
7333
|
+
getProjectOutputStylesDir(projectRoot),
|
|
7334
|
+
"project",
|
|
7335
|
+
projectRoot
|
|
7336
|
+
) : Promise.resolve([]),
|
|
7337
|
+
loadOutputStylesFromDir(
|
|
7338
|
+
getUserOutputStylesDir(),
|
|
7339
|
+
"user",
|
|
7340
|
+
getUserOutputStylesRoot()
|
|
7341
|
+
)
|
|
7342
|
+
]);
|
|
7343
|
+
const winners = /* @__PURE__ */ new Map();
|
|
7344
|
+
for (const style of [
|
|
7345
|
+
...projectStyles,
|
|
7346
|
+
...userStyles,
|
|
7347
|
+
...BUILT_IN_OUTPUT_STYLES
|
|
7348
|
+
]) {
|
|
7349
|
+
const key = style.name.toLowerCase();
|
|
7350
|
+
const winner = winners.get(key);
|
|
7351
|
+
if (winner) {
|
|
7352
|
+
debugLogger9.debug(
|
|
7353
|
+
`Output style "${style.name}" (${style.source}) is shadowed by the ${winner.source} style of the same name`
|
|
7354
|
+
);
|
|
7355
|
+
continue;
|
|
7356
|
+
}
|
|
7357
|
+
winners.set(key, style);
|
|
6503
7358
|
}
|
|
6504
|
-
|
|
7359
|
+
return [...BUILT_IN_OUTPUT_STYLES, ...userStyles, ...projectStyles].filter(
|
|
7360
|
+
(style) => winners.get(style.name.toLowerCase()) === style
|
|
7361
|
+
);
|
|
7362
|
+
}
|
|
7363
|
+
__name(loadOutputStyleCatalog, "loadOutputStyleCatalog");
|
|
7364
|
+
function findOutputStyle(styles, name) {
|
|
7365
|
+
const wanted = name.trim().toLowerCase();
|
|
7366
|
+
return styles.find((style) => style.name.toLowerCase() === wanted);
|
|
7367
|
+
}
|
|
7368
|
+
__name(findOutputStyle, "findOutputStyle");
|
|
6505
7369
|
|
|
6506
7370
|
// packages/core/src/tools/client-mcp-registrar.ts
|
|
6507
7371
|
init_esbuild_shims();
|
|
6508
|
-
var
|
|
7372
|
+
var debugLogger10 = createDebugLogger("CLIENT_MCP_REGISTRAR");
|
|
6509
7373
|
var CLIENT_MCP_MESSAGE_TIMEOUT_MS = 3e4;
|
|
6510
7374
|
var ClientMcpRegistrar = class {
|
|
6511
7375
|
static {
|
|
@@ -6528,7 +7392,7 @@ var ClientMcpRegistrar = class {
|
|
|
6528
7392
|
*/
|
|
6529
7393
|
registerServer(serverName) {
|
|
6530
7394
|
this.servers.add(serverName);
|
|
6531
|
-
|
|
7395
|
+
debugLogger10.debug(`Registered client MCP server '${serverName}'`);
|
|
6532
7396
|
}
|
|
6533
7397
|
/**
|
|
6534
7398
|
* Drop a server name and reject any in-flight requests targeting it. Returns
|
|
@@ -6541,7 +7405,7 @@ var ClientMcpRegistrar = class {
|
|
|
6541
7405
|
new Error(`client MCP server '${serverName}' was unregistered`)
|
|
6542
7406
|
);
|
|
6543
7407
|
if (existed) {
|
|
6544
|
-
|
|
7408
|
+
debugLogger10.debug(`Unregistered client MCP server '${serverName}'`);
|
|
6545
7409
|
}
|
|
6546
7410
|
return existed;
|
|
6547
7411
|
}
|
|
@@ -6601,7 +7465,7 @@ var ClientMcpRegistrar = class {
|
|
|
6601
7465
|
}
|
|
6602
7466
|
return Promise.resolve(ack);
|
|
6603
7467
|
}
|
|
6604
|
-
return new Promise((
|
|
7468
|
+
return new Promise((resolve6, reject) => {
|
|
6605
7469
|
const timer = setTimeout(() => {
|
|
6606
7470
|
this.pending.delete(id);
|
|
6607
7471
|
reject(
|
|
@@ -6611,7 +7475,7 @@ var ClientMcpRegistrar = class {
|
|
|
6611
7475
|
);
|
|
6612
7476
|
}, this.messageTimeoutMs);
|
|
6613
7477
|
timer.unref?.();
|
|
6614
|
-
this.pending.set(id, { resolve:
|
|
7478
|
+
this.pending.set(id, { resolve: resolve6, reject, timer, server: serverName });
|
|
6615
7479
|
let sendResult;
|
|
6616
7480
|
try {
|
|
6617
7481
|
sendResult = this.sendFrame({
|
|
@@ -6641,7 +7505,7 @@ var ClientMcpRegistrar = class {
|
|
|
6641
7505
|
resolveMessage(id, payload) {
|
|
6642
7506
|
const pending = this.pending.get(id);
|
|
6643
7507
|
if (!pending) {
|
|
6644
|
-
|
|
7508
|
+
debugLogger10.debug(`Dropping mcp_message with unknown id '${id}'`);
|
|
6645
7509
|
return false;
|
|
6646
7510
|
}
|
|
6647
7511
|
this.pending.delete(id);
|
|
@@ -6692,15 +7556,50 @@ function isWsl(env2) {
|
|
|
6692
7556
|
}
|
|
6693
7557
|
__name(isWsl, "isWsl");
|
|
6694
7558
|
|
|
6695
|
-
// packages/core/src/services/
|
|
7559
|
+
// packages/core/src/services/api-user-prompt.ts
|
|
6696
7560
|
init_esbuild_shims();
|
|
6697
|
-
|
|
6698
|
-
"
|
|
6699
|
-
|
|
6700
|
-
"
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
7561
|
+
function isApiUserPrompt(content, options) {
|
|
7562
|
+
if (content.role !== "user") return false;
|
|
7563
|
+
if (!content.parts || content.parts.length === 0) return false;
|
|
7564
|
+
if (content.parts.some((part) => "functionResponse" in part)) return false;
|
|
7565
|
+
if (isSystemReminderContent(content)) return false;
|
|
7566
|
+
const excludeTextPart = options?.excludeTextPart;
|
|
7567
|
+
if (excludeTextPart && content.parts.some(
|
|
7568
|
+
(part) => "text" in part && typeof part.text === "string" && excludeTextPart(part.text)
|
|
7569
|
+
)) {
|
|
7570
|
+
return false;
|
|
7571
|
+
}
|
|
7572
|
+
return content.parts.some((part) => {
|
|
7573
|
+
if (!("text" in part) || !part.text) return false;
|
|
7574
|
+
return !(options?.excludeClearedMediaPlaceholders && isClearedMediaPlaceholder(part.text));
|
|
7575
|
+
});
|
|
7576
|
+
}
|
|
7577
|
+
__name(isApiUserPrompt, "isApiUserPrompt");
|
|
7578
|
+
function findApiRewindCutPoint(apiHistory, turnIndex, options) {
|
|
7579
|
+
const startIndex = getStartupContextLength(apiHistory, {
|
|
7580
|
+
includeCompressed: true
|
|
7581
|
+
});
|
|
7582
|
+
if (turnIndex <= 0) return startIndex;
|
|
7583
|
+
let seen = 0;
|
|
7584
|
+
for (let index = startIndex; index < apiHistory.length; index++) {
|
|
7585
|
+
if (!isApiUserPrompt(apiHistory[index], options)) continue;
|
|
7586
|
+
if (seen === turnIndex) return index;
|
|
7587
|
+
seen += 1;
|
|
7588
|
+
}
|
|
7589
|
+
return -1;
|
|
7590
|
+
}
|
|
7591
|
+
__name(findApiRewindCutPoint, "findApiRewindCutPoint");
|
|
7592
|
+
function countApiUserPrompts(apiHistory, options) {
|
|
7593
|
+
const startIndex = getStartupContextLength(apiHistory, {
|
|
7594
|
+
includeCompressed: true
|
|
7595
|
+
});
|
|
7596
|
+
let count = 0;
|
|
7597
|
+
for (let index = startIndex; index < apiHistory.length; index++) {
|
|
7598
|
+
if (isApiUserPrompt(apiHistory[index], options)) count += 1;
|
|
7599
|
+
}
|
|
7600
|
+
return count;
|
|
7601
|
+
}
|
|
7602
|
+
__name(countApiUserPrompts, "countApiUserPrompts");
|
|
6704
7603
|
|
|
6705
7604
|
// packages/core/src/services/session-reference-service.ts
|
|
6706
7605
|
init_esbuild_shims();
|
|
@@ -6821,207 +7720,12 @@ ${body}`;
|
|
|
6821
7720
|
}
|
|
6822
7721
|
};
|
|
6823
7722
|
|
|
6824
|
-
// packages/core/src/ipc/uds-inbox.ts
|
|
6825
|
-
init_esbuild_shims();
|
|
6826
|
-
import { timingSafeEqual } from "node:crypto";
|
|
6827
|
-
import * as fsSync from "node:fs";
|
|
6828
|
-
import * as fs3 from "node:fs/promises";
|
|
6829
|
-
import * as net from "node:net";
|
|
6830
|
-
import * as path5 from "node:path";
|
|
6831
|
-
var debugLogger9 = createDebugLogger("PEER_IPC");
|
|
6832
|
-
var SOCKET_DIR_MODE = 448;
|
|
6833
|
-
var SOCKET_MODE = 384;
|
|
6834
|
-
var MAX_PEER_CONNECTIONS = 64;
|
|
6835
|
-
var CONNECTION_IDLE_TIMEOUT_MS = 3e4;
|
|
6836
|
-
function createLineReader(onLine, onOverflow) {
|
|
6837
|
-
let buffer = "";
|
|
6838
|
-
return (chunk) => {
|
|
6839
|
-
buffer += chunk;
|
|
6840
|
-
let newline = buffer.indexOf("\n");
|
|
6841
|
-
while (newline !== -1) {
|
|
6842
|
-
const line = buffer.slice(0, newline);
|
|
6843
|
-
buffer = buffer.slice(newline + 1);
|
|
6844
|
-
if (line.trim().length > 0) onLine(line);
|
|
6845
|
-
newline = buffer.indexOf("\n");
|
|
6846
|
-
}
|
|
6847
|
-
if (buffer.length > MAX_FRAME_BYTES) {
|
|
6848
|
-
buffer = "";
|
|
6849
|
-
onOverflow();
|
|
6850
|
-
}
|
|
6851
|
-
};
|
|
6852
|
-
}
|
|
6853
|
-
__name(createLineReader, "createLineReader");
|
|
6854
|
-
async function startPeerInbox(options) {
|
|
6855
|
-
const socketPath = options.socketPath ?? resolvePeerSocketPath();
|
|
6856
|
-
if (!isLocalIpcPath(socketPath)) {
|
|
6857
|
-
debugLogger9.error(`refusing to bind a non-local IPC path: ${socketPath}`);
|
|
6858
|
-
return null;
|
|
6859
|
-
}
|
|
6860
|
-
try {
|
|
6861
|
-
const dir = path5.dirname(socketPath);
|
|
6862
|
-
await fs3.mkdir(dir, { recursive: true, mode: SOCKET_DIR_MODE });
|
|
6863
|
-
const dirStat = await fs3.lstat(dir);
|
|
6864
|
-
const uid = typeof process.getuid === "function" ? process.getuid() : null;
|
|
6865
|
-
if (!dirStat.isDirectory()) {
|
|
6866
|
-
throw new Error(`${dir} is not a directory`);
|
|
6867
|
-
}
|
|
6868
|
-
if (uid !== null && dirStat.uid !== uid) {
|
|
6869
|
-
throw new Error(`${dir} belongs to uid ${dirStat.uid}, not ${uid}`);
|
|
6870
|
-
}
|
|
6871
|
-
await fs3.chmod(dir, SOCKET_DIR_MODE);
|
|
6872
|
-
} catch (error) {
|
|
6873
|
-
debugLogger9.error(`peer inbox directory unusable: ${describe(error)}`);
|
|
6874
|
-
return null;
|
|
6875
|
-
}
|
|
6876
|
-
try {
|
|
6877
|
-
await fs3.unlink(socketPath);
|
|
6878
|
-
} catch {
|
|
6879
|
-
}
|
|
6880
|
-
const connections = /* @__PURE__ */ new Set();
|
|
6881
|
-
const server = net.createServer({ allowHalfOpen: true }, (socket) => {
|
|
6882
|
-
connections.add(socket);
|
|
6883
|
-
socket.setEncoding("utf8");
|
|
6884
|
-
socket.unref();
|
|
6885
|
-
socket.setTimeout(CONNECTION_IDLE_TIMEOUT_MS, () => {
|
|
6886
|
-
debugLogger9.debug("dropping an idle peer connection");
|
|
6887
|
-
socket.destroy();
|
|
6888
|
-
});
|
|
6889
|
-
let authed = options.requiredToken === void 0;
|
|
6890
|
-
let auth;
|
|
6891
|
-
let refused = false;
|
|
6892
|
-
const read2 = createLineReader(
|
|
6893
|
-
(line) => {
|
|
6894
|
-
if (refused) return;
|
|
6895
|
-
if (!authed) {
|
|
6896
|
-
const presented = parsePeerAuthLine(line);
|
|
6897
|
-
if (presented !== null) {
|
|
6898
|
-
auth = authKindOf(options, presented);
|
|
6899
|
-
}
|
|
6900
|
-
if (auth !== void 0) {
|
|
6901
|
-
authed = true;
|
|
6902
|
-
return;
|
|
6903
|
-
}
|
|
6904
|
-
debugLogger9.debug(
|
|
6905
|
-
"dropping a connection whose first line did not authenticate: no valid auth line, or token mismatch"
|
|
6906
|
-
);
|
|
6907
|
-
refused = true;
|
|
6908
|
-
socket.destroy();
|
|
6909
|
-
return;
|
|
6910
|
-
}
|
|
6911
|
-
const frame = parsePeerFrame(line);
|
|
6912
|
-
if (frame === null) {
|
|
6913
|
-
debugLogger9.debug(
|
|
6914
|
-
`dropping unparseable frame: ${line.slice(0, 200)}`
|
|
6915
|
-
);
|
|
6916
|
-
return;
|
|
6917
|
-
}
|
|
6918
|
-
try {
|
|
6919
|
-
options.onFrame(frame, auth);
|
|
6920
|
-
} catch (error) {
|
|
6921
|
-
debugLogger9.error(`onFrame threw: ${describe(error)}`);
|
|
6922
|
-
}
|
|
6923
|
-
},
|
|
6924
|
-
() => {
|
|
6925
|
-
debugLogger9.error(
|
|
6926
|
-
"peer sent more than 1 MiB without a newline; dropping the connection"
|
|
6927
|
-
);
|
|
6928
|
-
socket.destroy();
|
|
6929
|
-
}
|
|
6930
|
-
);
|
|
6931
|
-
socket.on("data", read2);
|
|
6932
|
-
socket.on("end", () => {
|
|
6933
|
-
socket.end();
|
|
6934
|
-
});
|
|
6935
|
-
socket.on("error", (error) => {
|
|
6936
|
-
debugLogger9.debug(`peer connection error: ${error.message}`);
|
|
6937
|
-
});
|
|
6938
|
-
socket.on("close", () => {
|
|
6939
|
-
connections.delete(socket);
|
|
6940
|
-
});
|
|
6941
|
-
});
|
|
6942
|
-
server.maxConnections = MAX_PEER_CONNECTIONS;
|
|
6943
|
-
server.on("error", (error) => {
|
|
6944
|
-
debugLogger9.error(`peer inbox server error: ${describe(error)}`);
|
|
6945
|
-
});
|
|
6946
|
-
try {
|
|
6947
|
-
await new Promise((resolve5, reject) => {
|
|
6948
|
-
server.once("error", reject);
|
|
6949
|
-
server.listen(socketPath, () => {
|
|
6950
|
-
server.removeListener("error", reject);
|
|
6951
|
-
resolve5();
|
|
6952
|
-
});
|
|
6953
|
-
});
|
|
6954
|
-
} catch (error) {
|
|
6955
|
-
const code = error?.code;
|
|
6956
|
-
if (code === "ENAMETOOLONG") {
|
|
6957
|
-
debugLogger9.error(
|
|
6958
|
-
`peer inbox socket path is too long to bind (${Buffer.byteLength(
|
|
6959
|
-
socketPath
|
|
6960
|
-
)} bytes): ${socketPath}. Set XDG_RUNTIME_DIR or TMPDIR to a shorter directory.`
|
|
6961
|
-
);
|
|
6962
|
-
} else {
|
|
6963
|
-
debugLogger9.error(`peer inbox failed to bind: ${describe(error)}`);
|
|
6964
|
-
}
|
|
6965
|
-
return null;
|
|
6966
|
-
}
|
|
6967
|
-
try {
|
|
6968
|
-
await fs3.chmod(socketPath, SOCKET_MODE);
|
|
6969
|
-
} catch (error) {
|
|
6970
|
-
debugLogger9.error(
|
|
6971
|
-
`peer inbox socket could not be restricted to 0600, refusing to listen: ${describe(error)}`
|
|
6972
|
-
);
|
|
6973
|
-
server.close();
|
|
6974
|
-
try {
|
|
6975
|
-
fsSync.unlinkSync(socketPath);
|
|
6976
|
-
} catch {
|
|
6977
|
-
}
|
|
6978
|
-
return null;
|
|
6979
|
-
}
|
|
6980
|
-
server.unref();
|
|
6981
|
-
debugLogger9.debug(`peer inbox listening: ${socketPath}`);
|
|
6982
|
-
let closed = false;
|
|
6983
|
-
return {
|
|
6984
|
-
socketPath,
|
|
6985
|
-
async close() {
|
|
6986
|
-
if (closed) return;
|
|
6987
|
-
closed = true;
|
|
6988
|
-
for (const socket of connections) socket.destroy();
|
|
6989
|
-
connections.clear();
|
|
6990
|
-
await new Promise((resolve5) => server.close(() => resolve5()));
|
|
6991
|
-
try {
|
|
6992
|
-
await fs3.unlink(socketPath);
|
|
6993
|
-
} catch {
|
|
6994
|
-
}
|
|
6995
|
-
debugLogger9.debug(`peer inbox closed: ${socketPath}`);
|
|
6996
|
-
}
|
|
6997
|
-
};
|
|
6998
|
-
}
|
|
6999
|
-
__name(startPeerInbox, "startPeerInbox");
|
|
7000
|
-
function tokenMatches(expected, presented) {
|
|
7001
|
-
const a = Buffer.from(expected);
|
|
7002
|
-
const b = Buffer.from(presented);
|
|
7003
|
-
return a.length === b.length && timingSafeEqual(a, b);
|
|
7004
|
-
}
|
|
7005
|
-
__name(tokenMatches, "tokenMatches");
|
|
7006
|
-
function authKindOf(options, presented) {
|
|
7007
|
-
const peer = options.requiredToken !== void 0 && tokenMatches(options.requiredToken, presented);
|
|
7008
|
-
const child = options.childToken !== void 0 && tokenMatches(options.childToken, presented);
|
|
7009
|
-
if (peer) return "peer";
|
|
7010
|
-
if (child) return "child";
|
|
7011
|
-
return void 0;
|
|
7012
|
-
}
|
|
7013
|
-
__name(authKindOf, "authKindOf");
|
|
7014
|
-
function describe(error) {
|
|
7015
|
-
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
7016
|
-
}
|
|
7017
|
-
__name(describe, "describe");
|
|
7018
|
-
|
|
7019
7723
|
// packages/core/src/utils/conversation-branches.ts
|
|
7020
7724
|
init_esbuild_shims();
|
|
7021
7725
|
|
|
7022
7726
|
// packages/core/src/services/toolUseSummary.ts
|
|
7023
7727
|
init_esbuild_shims();
|
|
7024
|
-
var
|
|
7728
|
+
var debugLogger11 = createDebugLogger("TOOL_USE_SUMMARY");
|
|
7025
7729
|
var TOOL_USE_SUMMARY_SYSTEM_PROMPT = `Write a short summary label describing what these tool calls accomplished. It appears as a single-line row in a mobile app and truncates around 30 characters, so think git-commit-subject, not sentence.
|
|
7026
7730
|
|
|
7027
7731
|
Keep the verb in past tense and the most distinctive noun. Drop articles, connectors, and long location context first.
|
|
@@ -7042,7 +7746,7 @@ async function generateToolUseSummary(params) {
|
|
|
7042
7746
|
}
|
|
7043
7747
|
const model = config.getFastModel();
|
|
7044
7748
|
if (!model) {
|
|
7045
|
-
|
|
7749
|
+
debugLogger11.debug("No fast model configured \u2014 skipping summary generation");
|
|
7046
7750
|
return null;
|
|
7047
7751
|
}
|
|
7048
7752
|
if (signal.aborted) {
|
|
@@ -7065,7 +7769,7 @@ ${toolSummaries}
|
|
|
7065
7769
|
|
|
7066
7770
|
Label:`;
|
|
7067
7771
|
if (!config.getLlmClient()) {
|
|
7068
|
-
|
|
7772
|
+
debugLogger11.debug("No gemini client available \u2014 skipping");
|
|
7069
7773
|
return null;
|
|
7070
7774
|
}
|
|
7071
7775
|
const result = await runSideQuery(config, {
|
|
@@ -7084,19 +7788,19 @@ Label:`;
|
|
|
7084
7788
|
});
|
|
7085
7789
|
if (signal.aborted) return null;
|
|
7086
7790
|
if (!result.text) {
|
|
7087
|
-
|
|
7791
|
+
debugLogger11.debug("Summary generation returned empty result");
|
|
7088
7792
|
return null;
|
|
7089
7793
|
}
|
|
7090
7794
|
const cleaned = cleanSummary(result.text);
|
|
7091
7795
|
if (!cleaned) {
|
|
7092
|
-
|
|
7796
|
+
debugLogger11.debug(`Summary cleaned to empty: raw="${result.text}"`);
|
|
7093
7797
|
return null;
|
|
7094
7798
|
}
|
|
7095
|
-
|
|
7799
|
+
debugLogger11.debug(`Summary generated: "${cleaned}"`);
|
|
7096
7800
|
return cleaned;
|
|
7097
7801
|
} catch (err) {
|
|
7098
7802
|
if (signal.aborted) return null;
|
|
7099
|
-
|
|
7803
|
+
debugLogger11.warn(
|
|
7100
7804
|
`Summary generation failed: ${err instanceof Error ? err.message : String(err)}`
|
|
7101
7805
|
);
|
|
7102
7806
|
return null;
|
|
@@ -7170,7 +7874,7 @@ __name(cleanSummary, "cleanSummary");
|
|
|
7170
7874
|
|
|
7171
7875
|
// packages/core/src/services/usage-dashboard-service.ts
|
|
7172
7876
|
init_esbuild_shims();
|
|
7173
|
-
var
|
|
7877
|
+
var debugLogger12 = createDebugLogger("USAGE_DASHBOARD");
|
|
7174
7878
|
var DEFAULT_HEATMAP_DAYS = 183;
|
|
7175
7879
|
var MAX_DAILY_DAYS = 92;
|
|
7176
7880
|
var MS_PER_DAY = 24 * 60 * 60 * 1e3;
|
|
@@ -7295,7 +7999,7 @@ function buildUsageDashboard(records, options = {}) {
|
|
|
7295
7999
|
);
|
|
7296
8000
|
const daily = buildDaily(records, dailyStart, now);
|
|
7297
8001
|
const heatmap = buildHeatmap(records, now - heatmapDays * MS_PER_DAY, now);
|
|
7298
|
-
|
|
8002
|
+
debugLogger12.debug(
|
|
7299
8003
|
`built dashboard range=${range} records=${records.length} models=${models.length} skills=${skills.length} dailyPoints=${daily.length}`
|
|
7300
8004
|
);
|
|
7301
8005
|
return {
|
|
@@ -7625,13 +8329,13 @@ __name(serializeChannelMemoryDocument, "serializeChannelMemoryDocument");
|
|
|
7625
8329
|
// packages/core/src/memory/channel-memory.ts
|
|
7626
8330
|
init_esbuild_shims();
|
|
7627
8331
|
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
7628
|
-
import { createHash as createHash4, randomBytes } from "node:crypto";
|
|
7629
|
-
import * as
|
|
7630
|
-
import * as
|
|
8332
|
+
import { createHash as createHash4, randomBytes as randomBytes2 } from "node:crypto";
|
|
8333
|
+
import * as fs5 from "node:fs/promises";
|
|
8334
|
+
import * as path7 from "node:path";
|
|
7631
8335
|
var CHANNEL_MEMORY_FILE_NAME = "CHANNEL.json";
|
|
7632
8336
|
var LEGACY_CHANNEL_MEMORY_FILE_NAME = "CHANNEL.md";
|
|
7633
8337
|
var MAX_CHANNEL_MEMORY_BYTES = 1024 * 1024;
|
|
7634
|
-
var
|
|
8338
|
+
var debugLogger13 = createDebugLogger("CHANNEL_MEMORY");
|
|
7635
8339
|
var pendingMutations = /* @__PURE__ */ new Map();
|
|
7636
8340
|
var LOCK_OPTIONS = {
|
|
7637
8341
|
realpath: false,
|
|
@@ -7644,7 +8348,7 @@ var LOCK_OPTIONS = {
|
|
|
7644
8348
|
},
|
|
7645
8349
|
stale: 5e3,
|
|
7646
8350
|
onCompromised: /* @__PURE__ */ __name((err) => {
|
|
7647
|
-
|
|
8351
|
+
debugLogger13.warn("channel memory lock compromised:", err);
|
|
7648
8352
|
}, "onCompromised")
|
|
7649
8353
|
};
|
|
7650
8354
|
function isMissingFile(error) {
|
|
@@ -7667,11 +8371,11 @@ async function releaseLock(release) {
|
|
|
7667
8371
|
__name(releaseLock, "releaseLock");
|
|
7668
8372
|
async function cleanupLegacyAfterCommit(legacyPath, expectedBytes) {
|
|
7669
8373
|
try {
|
|
7670
|
-
const currentBytes = await
|
|
8374
|
+
const currentBytes = await fs5.readFile(legacyPath);
|
|
7671
8375
|
if (legacyHash(currentBytes) !== legacyHash(expectedBytes) || !currentBytes.equals(expectedBytes)) {
|
|
7672
8376
|
return;
|
|
7673
8377
|
}
|
|
7674
|
-
await
|
|
8378
|
+
await fs5.unlink(legacyPath);
|
|
7675
8379
|
} catch {
|
|
7676
8380
|
}
|
|
7677
8381
|
}
|
|
@@ -7687,7 +8391,7 @@ function hashedThreadPath(target) {
|
|
|
7687
8391
|
}
|
|
7688
8392
|
__name(hashedThreadPath, "hashedThreadPath");
|
|
7689
8393
|
function getChannelMemoryDirectory(target) {
|
|
7690
|
-
return
|
|
8394
|
+
return path7.join(
|
|
7691
8395
|
Storage.getGlobalQwenDir(),
|
|
7692
8396
|
"channels",
|
|
7693
8397
|
"memory",
|
|
@@ -7697,11 +8401,11 @@ function getChannelMemoryDirectory(target) {
|
|
|
7697
8401
|
}
|
|
7698
8402
|
__name(getChannelMemoryDirectory, "getChannelMemoryDirectory");
|
|
7699
8403
|
function getChannelMemoryFilePath(target) {
|
|
7700
|
-
return
|
|
8404
|
+
return path7.join(getChannelMemoryDirectory(target), CHANNEL_MEMORY_FILE_NAME);
|
|
7701
8405
|
}
|
|
7702
8406
|
__name(getChannelMemoryFilePath, "getChannelMemoryFilePath");
|
|
7703
8407
|
function getLegacyChannelMemoryFilePath(target) {
|
|
7704
|
-
return
|
|
8408
|
+
return path7.join(
|
|
7705
8409
|
getChannelMemoryDirectory(target),
|
|
7706
8410
|
LEGACY_CHANNEL_MEMORY_FILE_NAME
|
|
7707
8411
|
);
|
|
@@ -7711,8 +8415,8 @@ async function serializeMutation(directory, task) {
|
|
|
7711
8415
|
const previous = pendingMutations.get(directory) ?? Promise.resolve();
|
|
7712
8416
|
let resolveCurrent = /* @__PURE__ */ __name(() => {
|
|
7713
8417
|
}, "resolveCurrent");
|
|
7714
|
-
const current = new Promise((
|
|
7715
|
-
resolveCurrent =
|
|
8418
|
+
const current = new Promise((resolve6) => {
|
|
8419
|
+
resolveCurrent = resolve6;
|
|
7716
8420
|
});
|
|
7717
8421
|
const queued = previous.then(
|
|
7718
8422
|
() => current,
|
|
@@ -7733,7 +8437,7 @@ async function serializeMutation(directory, task) {
|
|
|
7733
8437
|
__name(serializeMutation, "serializeMutation");
|
|
7734
8438
|
async function readFileIfExists(filePath) {
|
|
7735
8439
|
try {
|
|
7736
|
-
return await
|
|
8440
|
+
return await fs5.readFile(filePath);
|
|
7737
8441
|
} catch (error) {
|
|
7738
8442
|
if (isMissingFile(error)) {
|
|
7739
8443
|
return void 0;
|
|
@@ -7796,21 +8500,21 @@ async function loadChannelMemory(target) {
|
|
|
7796
8500
|
}
|
|
7797
8501
|
__name(loadChannelMemory, "loadChannelMemory");
|
|
7798
8502
|
async function writeChannelMemory(filePath, serialized) {
|
|
7799
|
-
const tempPath = `${filePath}.${process.pid}.${
|
|
8503
|
+
const tempPath = `${filePath}.${process.pid}.${randomBytes2(6).toString("hex")}.tmp`;
|
|
7800
8504
|
let committed = false;
|
|
7801
8505
|
try {
|
|
7802
|
-
const handle = await
|
|
8506
|
+
const handle = await fs5.open(tempPath, "wx", 384);
|
|
7803
8507
|
try {
|
|
7804
8508
|
await handle.writeFile(serialized, "utf8");
|
|
7805
8509
|
await handle.sync();
|
|
7806
8510
|
} finally {
|
|
7807
8511
|
await handle.close();
|
|
7808
8512
|
}
|
|
7809
|
-
await
|
|
8513
|
+
await fs5.rename(tempPath, filePath);
|
|
7810
8514
|
committed = true;
|
|
7811
8515
|
} finally {
|
|
7812
8516
|
if (!committed) {
|
|
7813
|
-
await
|
|
8517
|
+
await fs5.unlink(tempPath).catch((error) => {
|
|
7814
8518
|
if (!isMissingFile(error)) {
|
|
7815
8519
|
throw error;
|
|
7816
8520
|
}
|
|
@@ -7821,12 +8525,12 @@ async function writeChannelMemory(filePath, serialized) {
|
|
|
7821
8525
|
__name(writeChannelMemory, "writeChannelMemory");
|
|
7822
8526
|
async function mutateChannelMemory(target, apply) {
|
|
7823
8527
|
const filePath = getChannelMemoryFilePath(target);
|
|
7824
|
-
const directory =
|
|
8528
|
+
const directory = path7.dirname(filePath);
|
|
7825
8529
|
const legacyPath = getLegacyChannelMemoryFilePath(target);
|
|
7826
8530
|
return serializeMutation(directory, async () => {
|
|
7827
|
-
await
|
|
7828
|
-
const lockPath =
|
|
7829
|
-
const lockHandle = await
|
|
8531
|
+
await fs5.mkdir(directory, { recursive: true });
|
|
8532
|
+
const lockPath = path7.join(directory, ".channel-memory.lock");
|
|
8533
|
+
const lockHandle = await fs5.open(lockPath, "a", 384);
|
|
7830
8534
|
await lockHandle.close();
|
|
7831
8535
|
const release = await import_proper_lockfile.default.lock(lockPath, LOCK_OPTIONS);
|
|
7832
8536
|
let releaseLegacy;
|
|
@@ -7865,7 +8569,7 @@ async function listChannelMemoryEntries(target) {
|
|
|
7865
8569
|
__name(listChannelMemoryEntries, "listChannelMemoryEntries");
|
|
7866
8570
|
async function getFileRevision(filePath) {
|
|
7867
8571
|
try {
|
|
7868
|
-
const stats = await
|
|
8572
|
+
const stats = await fs5.stat(filePath, { bigint: true });
|
|
7869
8573
|
return [
|
|
7870
8574
|
stats.dev,
|
|
7871
8575
|
stats.ino,
|
|
@@ -7918,7 +8622,7 @@ async function addChannelMemoryEntries(target, texts, createdBy) {
|
|
|
7918
8622
|
}
|
|
7919
8623
|
let randomHex;
|
|
7920
8624
|
do {
|
|
7921
|
-
randomHex =
|
|
8625
|
+
randomHex = randomBytes2(6).toString("hex");
|
|
7922
8626
|
} while (ids.has(`m-${randomHex}`));
|
|
7923
8627
|
const entry = createChannelMemoryEntry({
|
|
7924
8628
|
text,
|
|
@@ -8205,8 +8909,8 @@ __name(buildLearnVideoSkillRequest, "buildLearnVideoSkillRequest");
|
|
|
8205
8909
|
|
|
8206
8910
|
// packages/core/src/memory/writeContextFile.ts
|
|
8207
8911
|
init_esbuild_shims();
|
|
8208
|
-
import { promises as
|
|
8209
|
-
import * as
|
|
8912
|
+
import { promises as fs6 } from "node:fs";
|
|
8913
|
+
import * as path8 from "node:path";
|
|
8210
8914
|
var fileLocks = /* @__PURE__ */ new Map();
|
|
8211
8915
|
var FILE_LOCK_TIMEOUT_MS = 3e4;
|
|
8212
8916
|
function getFileLock(filePath) {
|
|
@@ -8234,7 +8938,7 @@ var WorkspaceMemoryWriteTimeoutError = class extends Error {
|
|
|
8234
8938
|
}
|
|
8235
8939
|
};
|
|
8236
8940
|
async function writeWorkspaceContextFile(options) {
|
|
8237
|
-
if (!
|
|
8941
|
+
if (!path8.isAbsolute(options.projectRoot)) {
|
|
8238
8942
|
throw new Error(
|
|
8239
8943
|
`writeWorkspaceContextFile: projectRoot must be absolute, got "${options.projectRoot}"`
|
|
8240
8944
|
);
|
|
@@ -8260,10 +8964,10 @@ async function runWrite(filePath, options) {
|
|
|
8260
8964
|
return { filePath, bytesWritten: 0, changed: false };
|
|
8261
8965
|
}
|
|
8262
8966
|
options.assertCanCommit?.();
|
|
8263
|
-
await
|
|
8967
|
+
await fs6.mkdir(path8.dirname(filePath), { recursive: true });
|
|
8264
8968
|
if (options.mode === "replace") {
|
|
8265
8969
|
options.assertCanCommit?.();
|
|
8266
|
-
await
|
|
8970
|
+
await fs6.writeFile(filePath, options.content, {
|
|
8267
8971
|
encoding: "utf8",
|
|
8268
8972
|
mode: 420
|
|
8269
8973
|
});
|
|
@@ -8275,7 +8979,7 @@ async function runWrite(filePath, options) {
|
|
|
8275
8979
|
}
|
|
8276
8980
|
const next = await composeAppendedContent(filePath, options.content);
|
|
8277
8981
|
options.assertCanCommit?.();
|
|
8278
|
-
await
|
|
8982
|
+
await fs6.writeFile(filePath, next, { encoding: "utf8", mode: 420 });
|
|
8279
8983
|
return {
|
|
8280
8984
|
filePath,
|
|
8281
8985
|
bytesWritten: Buffer.byteLength(next, "utf8"),
|
|
@@ -8286,9 +8990,9 @@ __name(runWrite, "runWrite");
|
|
|
8286
8990
|
function resolveContextFilePath(scope, projectRoot) {
|
|
8287
8991
|
const filename = getCurrentMemoryFilename();
|
|
8288
8992
|
if (scope === "workspace") {
|
|
8289
|
-
return
|
|
8993
|
+
return path8.join(projectRoot, filename);
|
|
8290
8994
|
}
|
|
8291
|
-
return
|
|
8995
|
+
return path8.join(Storage.getGlobalQwenDir(), filename);
|
|
8292
8996
|
}
|
|
8293
8997
|
__name(resolveContextFilePath, "resolveContextFilePath");
|
|
8294
8998
|
var MAX_EXISTING_FILE_BYTES = 16 * 1024 * 1024;
|
|
@@ -8312,15 +9016,15 @@ var WorkspaceMemoryFileTooLargeError = class extends Error {
|
|
|
8312
9016
|
async function composeAppendedContent(filePath, newContent) {
|
|
8313
9017
|
let existing = "";
|
|
8314
9018
|
try {
|
|
8315
|
-
const
|
|
8316
|
-
if (
|
|
9019
|
+
const stat5 = await fs6.stat(filePath);
|
|
9020
|
+
if (stat5.size > MAX_EXISTING_FILE_BYTES) {
|
|
8317
9021
|
throw new WorkspaceMemoryFileTooLargeError(
|
|
8318
9022
|
filePath,
|
|
8319
|
-
|
|
9023
|
+
stat5.size,
|
|
8320
9024
|
MAX_EXISTING_FILE_BYTES
|
|
8321
9025
|
);
|
|
8322
9026
|
}
|
|
8323
|
-
existing = await
|
|
9027
|
+
existing = await fs6.readFile(filePath, "utf8");
|
|
8324
9028
|
} catch (err) {
|
|
8325
9029
|
if (err instanceof WorkspaceMemoryFileTooLargeError) throw err;
|
|
8326
9030
|
if (!isEnoent(err)) throw err;
|
|
@@ -8399,9 +9103,9 @@ __name(trimNewlines, "trimNewlines");
|
|
|
8399
9103
|
init_esbuild_shims();
|
|
8400
9104
|
import * as child_process from "node:child_process";
|
|
8401
9105
|
import * as process2 from "node:process";
|
|
8402
|
-
import * as
|
|
8403
|
-
import * as
|
|
8404
|
-
import * as
|
|
9106
|
+
import * as path9 from "node:path";
|
|
9107
|
+
import * as fs7 from "node:fs";
|
|
9108
|
+
import * as os2 from "node:os";
|
|
8405
9109
|
function getVsCodeCommand(platform2 = process2.platform) {
|
|
8406
9110
|
return platform2 === "win32" ? "code.cmd" : "code";
|
|
8407
9111
|
}
|
|
@@ -8424,27 +9128,27 @@ async function findVsCodeCommand(platform2 = process2.platform) {
|
|
|
8424
9128
|
} catch {
|
|
8425
9129
|
}
|
|
8426
9130
|
const locations = [];
|
|
8427
|
-
const homeDir =
|
|
9131
|
+
const homeDir = os2.homedir();
|
|
8428
9132
|
if (platform2 === "darwin") {
|
|
8429
9133
|
locations.push(
|
|
8430
9134
|
"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code",
|
|
8431
|
-
|
|
9135
|
+
path9.join(homeDir, "Library/Application Support/Code/bin/code")
|
|
8432
9136
|
);
|
|
8433
9137
|
} else if (platform2 === "linux") {
|
|
8434
9138
|
locations.push(
|
|
8435
9139
|
"/usr/share/code/bin/code",
|
|
8436
9140
|
"/snap/bin/code",
|
|
8437
|
-
|
|
9141
|
+
path9.join(homeDir, ".local/share/code/bin/code")
|
|
8438
9142
|
);
|
|
8439
9143
|
} else if (platform2 === "win32") {
|
|
8440
9144
|
locations.push(
|
|
8441
|
-
|
|
9145
|
+
path9.join(
|
|
8442
9146
|
process2.env["ProgramFiles"] || "C:\\Program Files",
|
|
8443
9147
|
"Microsoft VS Code",
|
|
8444
9148
|
"bin",
|
|
8445
9149
|
"code.cmd"
|
|
8446
9150
|
),
|
|
8447
|
-
|
|
9151
|
+
path9.join(
|
|
8448
9152
|
homeDir,
|
|
8449
9153
|
"AppData",
|
|
8450
9154
|
"Local",
|
|
@@ -8456,7 +9160,7 @@ async function findVsCodeCommand(platform2 = process2.platform) {
|
|
|
8456
9160
|
);
|
|
8457
9161
|
}
|
|
8458
9162
|
for (const location of locations) {
|
|
8459
|
-
if (
|
|
9163
|
+
if (fs7.existsSync(location)) {
|
|
8460
9164
|
return location;
|
|
8461
9165
|
}
|
|
8462
9166
|
}
|
|
@@ -8623,10 +9327,10 @@ __name(lspServerConfigHash, "lspServerConfigHash");
|
|
|
8623
9327
|
|
|
8624
9328
|
// packages/core/src/lsp/LspConfigLoader.ts
|
|
8625
9329
|
init_esbuild_shims();
|
|
8626
|
-
import * as
|
|
8627
|
-
import * as
|
|
9330
|
+
import * as fs8 from "node:fs";
|
|
9331
|
+
import * as path10 from "path";
|
|
8628
9332
|
import { pathToFileURL } from "url";
|
|
8629
|
-
var
|
|
9333
|
+
var debugLogger14 = createDebugLogger("LSP");
|
|
8630
9334
|
var MAX_TCP_PORT = 65535;
|
|
8631
9335
|
var LspConfigLoader = class {
|
|
8632
9336
|
constructor(workspaceRoot) {
|
|
@@ -8640,25 +9344,25 @@ var LspConfigLoader = class {
|
|
|
8640
9344
|
* Supports basic format: { "language": { "command": "...", "extensionToLanguage": {...} } }
|
|
8641
9345
|
*/
|
|
8642
9346
|
async loadUserConfigs() {
|
|
8643
|
-
const lspConfigPath =
|
|
8644
|
-
if (!
|
|
9347
|
+
const lspConfigPath = path10.join(this.workspaceRoot, ".lsp.json");
|
|
9348
|
+
if (!fs8.existsSync(lspConfigPath)) {
|
|
8645
9349
|
return [];
|
|
8646
9350
|
}
|
|
8647
9351
|
try {
|
|
8648
|
-
const configContent =
|
|
9352
|
+
const configContent = fs8.readFileSync(lspConfigPath, "utf-8");
|
|
8649
9353
|
const data = JSON.parse(configContent);
|
|
8650
9354
|
return this.parseConfigSource(data, lspConfigPath, {
|
|
8651
9355
|
forceTrustRequired: true
|
|
8652
9356
|
});
|
|
8653
9357
|
} catch (error) {
|
|
8654
|
-
|
|
9358
|
+
debugLogger14.warn("Failed to load user .lsp.json config:", error);
|
|
8655
9359
|
return [];
|
|
8656
9360
|
}
|
|
8657
9361
|
}
|
|
8658
9362
|
async loadUserConfigsStrict() {
|
|
8659
|
-
const lspConfigPath =
|
|
9363
|
+
const lspConfigPath = path10.join(this.workspaceRoot, ".lsp.json");
|
|
8660
9364
|
try {
|
|
8661
|
-
const configContent =
|
|
9365
|
+
const configContent = fs8.readFileSync(lspConfigPath, "utf-8");
|
|
8662
9366
|
const data = JSON.parse(configContent);
|
|
8663
9367
|
return this.parseUserConfigSourceStrict(data, lspConfigPath);
|
|
8664
9368
|
} catch (error) {
|
|
@@ -8687,14 +9391,14 @@ var LspConfigLoader = class {
|
|
|
8687
9391
|
extension.path,
|
|
8688
9392
|
lspServers
|
|
8689
9393
|
);
|
|
8690
|
-
if (!
|
|
8691
|
-
|
|
9394
|
+
if (!fs8.existsSync(configPath)) {
|
|
9395
|
+
debugLogger14.warn(
|
|
8692
9396
|
`LSP config not found for ${originBase}: ${configPath}`
|
|
8693
9397
|
);
|
|
8694
9398
|
continue;
|
|
8695
9399
|
}
|
|
8696
9400
|
try {
|
|
8697
|
-
const configContent =
|
|
9401
|
+
const configContent = fs8.readFileSync(configPath, "utf-8");
|
|
8698
9402
|
const data = JSON.parse(configContent);
|
|
8699
9403
|
const hydrated = this.hydrateExtensionLspConfig(data, extension.path);
|
|
8700
9404
|
configs.push(
|
|
@@ -8704,7 +9408,7 @@ var LspConfigLoader = class {
|
|
|
8704
9408
|
)
|
|
8705
9409
|
);
|
|
8706
9410
|
} catch (error) {
|
|
8707
|
-
|
|
9411
|
+
debugLogger14.warn(
|
|
8708
9412
|
`Failed to load extension LSP config from ${configPath}:`,
|
|
8709
9413
|
error
|
|
8710
9414
|
);
|
|
@@ -8718,7 +9422,7 @@ var LspConfigLoader = class {
|
|
|
8718
9422
|
...this.parseConfigSource(hydrated, `${originBase} (lspServers)`)
|
|
8719
9423
|
);
|
|
8720
9424
|
} else {
|
|
8721
|
-
|
|
9425
|
+
debugLogger14.warn(
|
|
8722
9426
|
`LSP config for ${originBase} must be an object or a JSON file path.`
|
|
8723
9427
|
);
|
|
8724
9428
|
}
|
|
@@ -8824,15 +9528,15 @@ var LspConfigLoader = class {
|
|
|
8824
9528
|
return { ok: true, configs };
|
|
8825
9529
|
}
|
|
8826
9530
|
resolveExtensionConfigPath(extensionPath, configPath) {
|
|
8827
|
-
return
|
|
9531
|
+
return path10.isAbsolute(configPath) ? path10.resolve(configPath) : path10.resolve(extensionPath, configPath);
|
|
8828
9532
|
}
|
|
8829
9533
|
hydrateExtensionLspConfig(source, extensionPath) {
|
|
8830
9534
|
return recursivelyHydrateStrings(source, {
|
|
8831
9535
|
extensionPath,
|
|
8832
9536
|
CLAUDE_PLUGIN_ROOT: extensionPath,
|
|
8833
9537
|
workspacePath: this.workspaceRoot,
|
|
8834
|
-
"/":
|
|
8835
|
-
pathSeparator:
|
|
9538
|
+
"/": path10.sep,
|
|
9539
|
+
pathSeparator: path10.sep
|
|
8836
9540
|
});
|
|
8837
9541
|
}
|
|
8838
9542
|
buildServerConfig(name, languages, spec, origin, options = {}) {
|
|
@@ -8856,13 +9560,13 @@ var LspConfigLoader = class {
|
|
|
8856
9560
|
const trustRequired = options.forceTrustRequired ? true : typeof spec["trustRequired"] === "boolean" ? spec["trustRequired"] : true;
|
|
8857
9561
|
const socket = this.normalizeSocketOptions(spec);
|
|
8858
9562
|
if (transport === "stdio" && !command) {
|
|
8859
|
-
|
|
9563
|
+
debugLogger14.warn(
|
|
8860
9564
|
`LSP config error in ${origin}: ${name} missing command`
|
|
8861
9565
|
);
|
|
8862
9566
|
return null;
|
|
8863
9567
|
}
|
|
8864
9568
|
if (transport !== "stdio" && !socket) {
|
|
8865
|
-
|
|
9569
|
+
debugLogger14.warn(
|
|
8866
9570
|
`LSP config error in ${origin}: ${name} missing socket info`
|
|
8867
9571
|
);
|
|
8868
9572
|
return null;
|
|
@@ -8999,12 +9703,12 @@ var LspConfigLoader = class {
|
|
|
8999
9703
|
if (typeof value !== "string" || value.trim() === "") {
|
|
9000
9704
|
return this.workspaceRoot;
|
|
9001
9705
|
}
|
|
9002
|
-
const resolved =
|
|
9003
|
-
const root =
|
|
9004
|
-
if (resolved === root || resolved.startsWith(root +
|
|
9706
|
+
const resolved = path10.isAbsolute(value) ? path10.resolve(value) : path10.resolve(this.workspaceRoot, value);
|
|
9707
|
+
const root = path10.resolve(this.workspaceRoot);
|
|
9708
|
+
if (resolved === root || resolved.startsWith(root + path10.sep)) {
|
|
9005
9709
|
return resolved;
|
|
9006
9710
|
}
|
|
9007
|
-
|
|
9711
|
+
debugLogger14.warn(
|
|
9008
9712
|
`LSP workspaceFolder must be within ${this.workspaceRoot}; using workspace root instead.`
|
|
9009
9713
|
);
|
|
9010
9714
|
return this.workspaceRoot;
|
|
@@ -9016,7 +9720,7 @@ init_esbuild_shims();
|
|
|
9016
9720
|
import * as cp from "node:child_process";
|
|
9017
9721
|
import * as net2 from "node:net";
|
|
9018
9722
|
import { StringDecoder } from "node:string_decoder";
|
|
9019
|
-
var
|
|
9723
|
+
var debugLogger15 = createDebugLogger("LSP");
|
|
9020
9724
|
var MAX_STDERR_TAIL_BYTES = 8192;
|
|
9021
9725
|
function trimTail(value, maxBytes) {
|
|
9022
9726
|
const buffer = Buffer.from(value, "utf8");
|
|
@@ -9081,7 +9785,7 @@ var JsonRpcConnection = class {
|
|
|
9081
9785
|
try {
|
|
9082
9786
|
this.disposer?.();
|
|
9083
9787
|
} catch (error) {
|
|
9084
|
-
|
|
9788
|
+
debugLogger15.warn("LSP disposer failed:", error);
|
|
9085
9789
|
}
|
|
9086
9790
|
}
|
|
9087
9791
|
sendRequest(method, params) {
|
|
@@ -9095,12 +9799,12 @@ var JsonRpcConnection = class {
|
|
|
9095
9799
|
method,
|
|
9096
9800
|
params
|
|
9097
9801
|
};
|
|
9098
|
-
const requestPromise = new Promise((
|
|
9802
|
+
const requestPromise = new Promise((resolve6, reject) => {
|
|
9099
9803
|
const timer = setTimeout(() => {
|
|
9100
9804
|
this.pendingRequests.delete(id);
|
|
9101
9805
|
reject(new Error(`LSP request timeout: ${method}`));
|
|
9102
9806
|
}, DEFAULT_LSP_REQUEST_TIMEOUT_MS);
|
|
9103
|
-
this.pendingRequests.set(id, { resolve:
|
|
9807
|
+
this.pendingRequests.set(id, { resolve: resolve6, reject, timer });
|
|
9104
9808
|
});
|
|
9105
9809
|
this.writeMessage(payload);
|
|
9106
9810
|
return requestPromise;
|
|
@@ -9208,7 +9912,7 @@ var JsonRpcConnection = class {
|
|
|
9208
9912
|
try {
|
|
9209
9913
|
this.writer(header + json);
|
|
9210
9914
|
} catch (error) {
|
|
9211
|
-
|
|
9915
|
+
debugLogger15.warn("LSP write failed:", error);
|
|
9212
9916
|
this.end();
|
|
9213
9917
|
}
|
|
9214
9918
|
}
|
|
@@ -9228,7 +9932,7 @@ var LspConnectionFactory = class _LspConnectionFactory {
|
|
|
9228
9932
|
* 创建基于 stdio 的 LSP 连接
|
|
9229
9933
|
*/
|
|
9230
9934
|
static async createStdioConnection(command, args, options, timeoutMs = 1e4) {
|
|
9231
|
-
return new Promise((
|
|
9935
|
+
return new Promise((resolve6, reject) => {
|
|
9232
9936
|
const spawnOptions = {
|
|
9233
9937
|
stdio: "pipe",
|
|
9234
9938
|
...options
|
|
@@ -9267,14 +9971,14 @@ var LspConnectionFactory = class _LspConnectionFactory {
|
|
|
9267
9971
|
);
|
|
9268
9972
|
});
|
|
9269
9973
|
processInstance.stderr?.on("error", (err) => {
|
|
9270
|
-
|
|
9974
|
+
debugLogger15.warn(`LSP stderr stream error for ${command}:`, err);
|
|
9271
9975
|
});
|
|
9272
9976
|
const connection = new JsonRpcConnection(
|
|
9273
9977
|
(payload) => processInstance.stdin?.write(payload),
|
|
9274
9978
|
() => processInstance.stdin?.end()
|
|
9275
9979
|
);
|
|
9276
9980
|
processInstance.stdin.on("error", (err) => {
|
|
9277
|
-
|
|
9981
|
+
debugLogger15.warn(`LSP stdin stream error for ${command}:`, err);
|
|
9278
9982
|
connection.end();
|
|
9279
9983
|
});
|
|
9280
9984
|
connection.listen(processInstance.stdout);
|
|
@@ -9287,7 +9991,7 @@ var LspConnectionFactory = class _LspConnectionFactory {
|
|
|
9287
9991
|
recordProcessExit(code, signal);
|
|
9288
9992
|
connection.end();
|
|
9289
9993
|
});
|
|
9290
|
-
|
|
9994
|
+
resolve6({
|
|
9291
9995
|
connection,
|
|
9292
9996
|
process: processInstance,
|
|
9293
9997
|
processDiagnostics
|
|
@@ -9308,7 +10012,7 @@ var LspConnectionFactory = class _LspConnectionFactory {
|
|
|
9308
10012
|
* 创建基于 socket 的 LSP 连接(支持 TCP 或 unix socket)
|
|
9309
10013
|
*/
|
|
9310
10014
|
static async createSocketConnection(options, timeoutMs = 1e4) {
|
|
9311
|
-
return new Promise((
|
|
10015
|
+
return new Promise((resolve6, reject) => {
|
|
9312
10016
|
let socketOptions;
|
|
9313
10017
|
if (options.path) {
|
|
9314
10018
|
socketOptions = { path: options.path };
|
|
@@ -9342,7 +10046,7 @@ var LspConnectionFactory = class _LspConnectionFactory {
|
|
|
9342
10046
|
connection.listen(socket);
|
|
9343
10047
|
socket.once("close", () => connection.end());
|
|
9344
10048
|
socket.once("error", () => connection.end());
|
|
9345
|
-
|
|
10049
|
+
resolve6({
|
|
9346
10050
|
connection,
|
|
9347
10051
|
socket
|
|
9348
10052
|
});
|
|
@@ -9357,7 +10061,7 @@ var LspConnectionFactory = class _LspConnectionFactory {
|
|
|
9357
10061
|
try {
|
|
9358
10062
|
await lspConnection.connection.shutdown();
|
|
9359
10063
|
} catch (e) {
|
|
9360
|
-
|
|
10064
|
+
debugLogger15.warn("LSP shutdown failed:", e);
|
|
9361
10065
|
} finally {
|
|
9362
10066
|
lspConnection.connection.end();
|
|
9363
10067
|
}
|
|
@@ -10032,10 +10736,10 @@ ${value}
|
|
|
10032
10736
|
// packages/core/src/lsp/LspServerManager.ts
|
|
10033
10737
|
init_esbuild_shims();
|
|
10034
10738
|
import { spawn as spawn2 } from "node:child_process";
|
|
10035
|
-
import * as
|
|
10036
|
-
import * as
|
|
10739
|
+
import * as fs9 from "node:fs";
|
|
10740
|
+
import * as path11 from "path";
|
|
10037
10741
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
10038
|
-
var
|
|
10742
|
+
var debugLogger16 = createDebugLogger("LSP");
|
|
10039
10743
|
var SECURITY_SENSITIVE_ENV_KEYS = /* @__PURE__ */ new Set([
|
|
10040
10744
|
"DYLD_INSERT_LIBRARIES",
|
|
10041
10745
|
"DYLD_LIBRARY_PATH",
|
|
@@ -10072,7 +10776,7 @@ var LspServerManager = class {
|
|
|
10072
10776
|
});
|
|
10073
10777
|
this.serverConfigHashes.set(config.name, lspServerConfigHash(config));
|
|
10074
10778
|
}
|
|
10075
|
-
|
|
10779
|
+
debugLogger16.info(
|
|
10076
10780
|
`Prepared ${configs.length} LSP server config(s): ${formatServerNames(
|
|
10077
10781
|
configs.map((config) => config.name)
|
|
10078
10782
|
)}`
|
|
@@ -10081,7 +10785,7 @@ var LspServerManager = class {
|
|
|
10081
10785
|
/** Drops all prepared handles without attempting process shutdown. */
|
|
10082
10786
|
clearServerHandles() {
|
|
10083
10787
|
if (this.serverHandles.size > 0) {
|
|
10084
|
-
|
|
10788
|
+
debugLogger16.info(
|
|
10085
10789
|
`Clearing ${this.serverHandles.size} LSP server handle(s): ${formatServerNames(
|
|
10086
10790
|
Array.from(this.serverHandles.keys())
|
|
10087
10791
|
)}`
|
|
@@ -10142,7 +10846,7 @@ var LspServerManager = class {
|
|
|
10142
10846
|
* before their handles are deleted or replaced.
|
|
10143
10847
|
*/
|
|
10144
10848
|
async doReconcileServerConfigs(configs) {
|
|
10145
|
-
|
|
10849
|
+
debugLogger16.info(
|
|
10146
10850
|
`Reconciling LSP server configs: desired=${formatServerNames(
|
|
10147
10851
|
configs.map((config) => config.name)
|
|
10148
10852
|
)}`
|
|
@@ -10214,7 +10918,7 @@ var LspServerManager = class {
|
|
|
10214
10918
|
result.added.push(name);
|
|
10215
10919
|
}
|
|
10216
10920
|
}
|
|
10217
|
-
|
|
10921
|
+
debugLogger16.info(
|
|
10218
10922
|
`LSP reconcile result: added=${formatServerNames(
|
|
10219
10923
|
result.added
|
|
10220
10924
|
)}, removed=${formatServerNames(
|
|
@@ -10249,7 +10953,7 @@ var LspServerManager = class {
|
|
|
10249
10953
|
const uri = pathToFileURL2(tsFile).toString();
|
|
10250
10954
|
const languageId = tsFile.endsWith(".tsx") ? "typescriptreact" : tsFile.endsWith(".jsx") ? "javascriptreact" : tsFile.endsWith(".js") ? "javascript" : "typescript";
|
|
10251
10955
|
try {
|
|
10252
|
-
const text =
|
|
10956
|
+
const text = fs9.readFileSync(tsFile, "utf-8");
|
|
10253
10957
|
handle.connection.send({
|
|
10254
10958
|
jsonrpc: "2.0",
|
|
10255
10959
|
method: "textDocument/didOpen",
|
|
@@ -10263,12 +10967,12 @@ var LspServerManager = class {
|
|
|
10263
10967
|
}
|
|
10264
10968
|
});
|
|
10265
10969
|
await new Promise(
|
|
10266
|
-
(
|
|
10970
|
+
(resolve6) => setTimeout(resolve6, DEFAULT_LSP_WARMUP_DELAY_MS)
|
|
10267
10971
|
);
|
|
10268
10972
|
handle.warmedUp = true;
|
|
10269
10973
|
return uri;
|
|
10270
10974
|
} catch (error) {
|
|
10271
|
-
|
|
10975
|
+
debugLogger16.warn("TypeScript server warm-up failed:", error);
|
|
10272
10976
|
return void 0;
|
|
10273
10977
|
}
|
|
10274
10978
|
}
|
|
@@ -10315,7 +11019,7 @@ var LspServerManager = class {
|
|
|
10315
11019
|
async doStartServer(name, handle) {
|
|
10316
11020
|
const workspaceTrusted = this.config.isTrustedFolder();
|
|
10317
11021
|
if ((this.requireTrustedWorkspace || handle.config.trustRequired) && !workspaceTrusted) {
|
|
10318
|
-
|
|
11022
|
+
debugLogger16.warn(
|
|
10319
11023
|
`LSP server ${name} requires trusted workspace, skipping startup`
|
|
10320
11024
|
);
|
|
10321
11025
|
handle.status = "FAILED";
|
|
@@ -10328,7 +11032,7 @@ var LspServerManager = class {
|
|
|
10328
11032
|
workspaceTrusted
|
|
10329
11033
|
);
|
|
10330
11034
|
if (!trusted) {
|
|
10331
|
-
|
|
11035
|
+
debugLogger16.warn(
|
|
10332
11036
|
`Workspace trust check failed, not starting LSP server ${name}`
|
|
10333
11037
|
);
|
|
10334
11038
|
handle.status = "FAILED";
|
|
@@ -10338,7 +11042,7 @@ var LspServerManager = class {
|
|
|
10338
11042
|
if (handle.config.command) {
|
|
10339
11043
|
const commandCwd = handle.config.workspaceFolder ?? this.workspaceRoot;
|
|
10340
11044
|
if (!this.isPathSafe(handle.config.command, this.workspaceRoot, commandCwd)) {
|
|
10341
|
-
|
|
11045
|
+
debugLogger16.warn(
|
|
10342
11046
|
`LSP server ${name} command path is unsafe: ${handle.config.command}`
|
|
10343
11047
|
);
|
|
10344
11048
|
handle.status = "FAILED";
|
|
@@ -10350,7 +11054,7 @@ var LspServerManager = class {
|
|
|
10350
11054
|
handle.config.env,
|
|
10351
11055
|
commandCwd
|
|
10352
11056
|
)) {
|
|
10353
|
-
|
|
11057
|
+
debugLogger16.warn(
|
|
10354
11058
|
`LSP server ${name} command not found: ${handle.config.command}`
|
|
10355
11059
|
);
|
|
10356
11060
|
handle.status = "FAILED";
|
|
@@ -10365,7 +11069,7 @@ var LspServerManager = class {
|
|
|
10365
11069
|
handle.processDiagnostics = void 0;
|
|
10366
11070
|
handle.warmedUp = false;
|
|
10367
11071
|
handle.status = "IN_PROGRESS";
|
|
10368
|
-
|
|
11072
|
+
debugLogger16.info(
|
|
10369
11073
|
`Starting LSP server ${name}: command=${handle.config.command ?? "<none>"}, transport=${handle.config.transport}, languages=${formatServerNames(
|
|
10370
11074
|
handle.config.languages
|
|
10371
11075
|
)}`
|
|
@@ -10390,7 +11094,7 @@ var LspServerManager = class {
|
|
|
10390
11094
|
}
|
|
10391
11095
|
handle.status = "READY";
|
|
10392
11096
|
this.attachRestartHandler(name, handle);
|
|
10393
|
-
|
|
11097
|
+
debugLogger16.info(`LSP server ${name} started successfully`);
|
|
10394
11098
|
} catch (error) {
|
|
10395
11099
|
handle.status = "FAILED";
|
|
10396
11100
|
handle.error = error;
|
|
@@ -10404,21 +11108,21 @@ var LspServerManager = class {
|
|
|
10404
11108
|
}
|
|
10405
11109
|
await this.releaseServerResources(name, handle, false);
|
|
10406
11110
|
if (handle.processDiagnostics) {
|
|
10407
|
-
|
|
11111
|
+
debugLogger16.error(
|
|
10408
11112
|
`LSP server ${name} process diagnostics:`,
|
|
10409
11113
|
handle.processDiagnostics
|
|
10410
11114
|
);
|
|
10411
11115
|
}
|
|
10412
11116
|
handle.connection = void 0;
|
|
10413
11117
|
handle.process = void 0;
|
|
10414
|
-
|
|
11118
|
+
debugLogger16.error(`LSP server ${name} failed to start:`, error);
|
|
10415
11119
|
}
|
|
10416
11120
|
}
|
|
10417
11121
|
/**
|
|
10418
11122
|
* Stops a server and resets runtime-only handle state.
|
|
10419
11123
|
*/
|
|
10420
11124
|
async stopServer(name, handle) {
|
|
10421
|
-
|
|
11125
|
+
debugLogger16.info(`Stopping LSP server ${name}`);
|
|
10422
11126
|
handle.stopRequested = true;
|
|
10423
11127
|
handle.startupAbortController?.abort();
|
|
10424
11128
|
if (handle.startingPromise) {
|
|
@@ -10431,7 +11135,7 @@ var LspServerManager = class {
|
|
|
10431
11135
|
handle.status = "NOT_STARTED";
|
|
10432
11136
|
handle.warmedUp = false;
|
|
10433
11137
|
handle.restartAttempts = 0;
|
|
10434
|
-
|
|
11138
|
+
debugLogger16.info(`LSP server ${name} stopped`);
|
|
10435
11139
|
}
|
|
10436
11140
|
async abortAndWaitForStartup(handle) {
|
|
10437
11141
|
if (!handle.startingPromise) {
|
|
@@ -10455,14 +11159,14 @@ var LspServerManager = class {
|
|
|
10455
11159
|
handle.connection.end();
|
|
10456
11160
|
}
|
|
10457
11161
|
} catch (error) {
|
|
10458
|
-
|
|
11162
|
+
debugLogger16.error(`Error closing LSP server ${name}:`, error);
|
|
10459
11163
|
}
|
|
10460
11164
|
}
|
|
10461
11165
|
if (handle.process && handle.process.exitCode === null) {
|
|
10462
11166
|
try {
|
|
10463
11167
|
handle.process.kill();
|
|
10464
11168
|
} catch (error) {
|
|
10465
|
-
|
|
11169
|
+
debugLogger16.warn(`Error killing LSP server ${name} process:`, error);
|
|
10466
11170
|
}
|
|
10467
11171
|
}
|
|
10468
11172
|
}
|
|
@@ -10482,8 +11186,8 @@ var LspServerManager = class {
|
|
|
10482
11186
|
try {
|
|
10483
11187
|
await Promise.race([
|
|
10484
11188
|
shutdownPromise,
|
|
10485
|
-
new Promise((
|
|
10486
|
-
timerId = setTimeout(
|
|
11189
|
+
new Promise((resolve6) => {
|
|
11190
|
+
timerId = setTimeout(resolve6, timeout);
|
|
10487
11191
|
if (typeof timerId === "object" && timerId !== null && "unref" in timerId) {
|
|
10488
11192
|
timerId.unref();
|
|
10489
11193
|
}
|
|
@@ -10508,7 +11212,7 @@ var LspServerManager = class {
|
|
|
10508
11212
|
}
|
|
10509
11213
|
handle.processExitedUnexpectedly = true;
|
|
10510
11214
|
if (!handle.config.restartOnCrash) {
|
|
10511
|
-
|
|
11215
|
+
debugLogger16.warn(
|
|
10512
11216
|
`LSP server ${name} exited but restartOnCrash is disabled`
|
|
10513
11217
|
);
|
|
10514
11218
|
handle.status = "FAILED";
|
|
@@ -10517,7 +11221,7 @@ var LspServerManager = class {
|
|
|
10517
11221
|
}
|
|
10518
11222
|
const maxRestarts = handle.config.maxRestarts ?? DEFAULT_LSP_MAX_RESTARTS;
|
|
10519
11223
|
if (maxRestarts <= 0) {
|
|
10520
|
-
|
|
11224
|
+
debugLogger16.warn(
|
|
10521
11225
|
`LSP server ${name} exited but maxRestarts is ${maxRestarts}`
|
|
10522
11226
|
);
|
|
10523
11227
|
handle.status = "FAILED";
|
|
@@ -10526,7 +11230,7 @@ var LspServerManager = class {
|
|
|
10526
11230
|
}
|
|
10527
11231
|
const attempts = handle.restartAttempts ?? 0;
|
|
10528
11232
|
if (attempts >= maxRestarts) {
|
|
10529
|
-
|
|
11233
|
+
debugLogger16.warn(
|
|
10530
11234
|
`LSP server ${name} reached max restart attempts (${maxRestarts}), stopping restarts`
|
|
10531
11235
|
);
|
|
10532
11236
|
handle.status = "FAILED";
|
|
@@ -10534,7 +11238,7 @@ var LspServerManager = class {
|
|
|
10534
11238
|
return;
|
|
10535
11239
|
}
|
|
10536
11240
|
handle.restartAttempts = attempts + 1;
|
|
10537
|
-
|
|
11241
|
+
debugLogger16.warn(
|
|
10538
11242
|
`LSP server ${name} exited (code ${code ?? "unknown"}), restarting (${handle.restartAttempts}/${maxRestarts})`
|
|
10539
11243
|
);
|
|
10540
11244
|
this.enqueueCrashRestart(name, handle);
|
|
@@ -10582,7 +11286,7 @@ var LspServerManager = class {
|
|
|
10582
11286
|
const next = this.reconcileQueue.then(restart, restart);
|
|
10583
11287
|
this.reconcileQueue = next.catch(() => void 0);
|
|
10584
11288
|
void next.catch((error) => {
|
|
10585
|
-
|
|
11289
|
+
debugLogger16.warn(`LSP server ${name} crash restart failed:`, error);
|
|
10586
11290
|
});
|
|
10587
11291
|
}
|
|
10588
11292
|
resetHandle(handle) {
|
|
@@ -10590,14 +11294,14 @@ var LspServerManager = class {
|
|
|
10590
11294
|
try {
|
|
10591
11295
|
handle.connection.end();
|
|
10592
11296
|
} catch (error) {
|
|
10593
|
-
|
|
11297
|
+
debugLogger16.warn("Error closing LSP connection during reset:", error);
|
|
10594
11298
|
}
|
|
10595
11299
|
}
|
|
10596
11300
|
if (handle.process && handle.process.exitCode === null) {
|
|
10597
11301
|
try {
|
|
10598
11302
|
handle.process.kill();
|
|
10599
11303
|
} catch (error) {
|
|
10600
|
-
|
|
11304
|
+
debugLogger16.warn("Error killing LSP process during reset:", error);
|
|
10601
11305
|
}
|
|
10602
11306
|
}
|
|
10603
11307
|
handle.connection = void 0;
|
|
@@ -10616,7 +11320,7 @@ var LspServerManager = class {
|
|
|
10616
11320
|
const filteredEnv = {};
|
|
10617
11321
|
for (const [key, value] of Object.entries(env2)) {
|
|
10618
11322
|
if (SECURITY_SENSITIVE_ENV_KEYS.has(key.toUpperCase())) {
|
|
10619
|
-
|
|
11323
|
+
debugLogger16.warn(
|
|
10620
11324
|
`Ignoring security-sensitive LSP server env override: ${key}`
|
|
10621
11325
|
);
|
|
10622
11326
|
continue;
|
|
@@ -10642,7 +11346,7 @@ var LspServerManager = class {
|
|
|
10642
11346
|
for (const [key, value] of Object.entries(env2)) {
|
|
10643
11347
|
const normalizedKey = key.toUpperCase();
|
|
10644
11348
|
if (normalizedKey === "PATH" || SECURITY_SENSITIVE_ENV_KEYS.has(normalizedKey)) {
|
|
10645
|
-
|
|
11349
|
+
debugLogger16.warn(
|
|
10646
11350
|
`Ignoring security-sensitive LSP command probe env override: ${key}`
|
|
10647
11351
|
);
|
|
10648
11352
|
continue;
|
|
@@ -10686,11 +11390,11 @@ var LspServerManager = class {
|
|
|
10686
11390
|
}
|
|
10687
11391
|
async delayWithAbort(delayMs, signal) {
|
|
10688
11392
|
if (!signal) {
|
|
10689
|
-
await new Promise((
|
|
11393
|
+
await new Promise((resolve6) => setTimeout(resolve6, delayMs));
|
|
10690
11394
|
return;
|
|
10691
11395
|
}
|
|
10692
11396
|
this.throwIfStartupAborted(signal);
|
|
10693
|
-
await new Promise((
|
|
11397
|
+
await new Promise((resolve6, reject) => {
|
|
10694
11398
|
const onAbort = /* @__PURE__ */ __name(() => {
|
|
10695
11399
|
clearTimeout(timerId);
|
|
10696
11400
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -10698,7 +11402,7 @@ var LspServerManager = class {
|
|
|
10698
11402
|
}, "onAbort");
|
|
10699
11403
|
const timerId = setTimeout(() => {
|
|
10700
11404
|
signal.removeEventListener("abort", onAbort);
|
|
10701
|
-
|
|
11405
|
+
resolve6();
|
|
10702
11406
|
}, delayMs);
|
|
10703
11407
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
10704
11408
|
});
|
|
@@ -10867,7 +11571,7 @@ var LspServerManager = class {
|
|
|
10867
11571
|
*/
|
|
10868
11572
|
async waitForSocketProcessSpawn(process3, signal) {
|
|
10869
11573
|
this.throwIfStartupAborted(signal);
|
|
10870
|
-
await new Promise((
|
|
11574
|
+
await new Promise((resolve6, reject) => {
|
|
10871
11575
|
let settled = false;
|
|
10872
11576
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
10873
11577
|
process3.off("spawn", onSpawn);
|
|
@@ -10882,7 +11586,7 @@ var LspServerManager = class {
|
|
|
10882
11586
|
cleanup();
|
|
10883
11587
|
complete();
|
|
10884
11588
|
}, "settle");
|
|
10885
|
-
const onSpawn = /* @__PURE__ */ __name(() => settle(
|
|
11589
|
+
const onSpawn = /* @__PURE__ */ __name(() => settle(resolve6), "onSpawn");
|
|
10886
11590
|
const onError = /* @__PURE__ */ __name((error) => settle(
|
|
10887
11591
|
() => reject(new Error(`Failed to spawn LSP server: ${error.message}`))
|
|
10888
11592
|
), "onError");
|
|
@@ -10891,7 +11595,7 @@ var LspServerManager = class {
|
|
|
10891
11595
|
try {
|
|
10892
11596
|
process3.kill();
|
|
10893
11597
|
} catch (error) {
|
|
10894
|
-
|
|
11598
|
+
debugLogger16.warn(
|
|
10895
11599
|
"Error killing aborted LSP socket process:",
|
|
10896
11600
|
error
|
|
10897
11601
|
);
|
|
@@ -10936,7 +11640,7 @@ var LspServerManager = class {
|
|
|
10936
11640
|
async initializeLspServer(connection, config) {
|
|
10937
11641
|
const workspaceFolderPath = config.workspaceFolder ?? this.workspaceRoot;
|
|
10938
11642
|
const workspaceFolder = {
|
|
10939
|
-
name:
|
|
11643
|
+
name: path11.basename(workspaceFolderPath) || workspaceFolderPath,
|
|
10940
11644
|
uri: config.rootUri
|
|
10941
11645
|
};
|
|
10942
11646
|
const initializeParams = {
|
|
@@ -10998,7 +11702,7 @@ var LspServerManager = class {
|
|
|
10998
11702
|
* @returns true if the command can be spawned, false if not found
|
|
10999
11703
|
*/
|
|
11000
11704
|
async commandExists(command, env2, cwd) {
|
|
11001
|
-
return new Promise((
|
|
11705
|
+
return new Promise((resolve6) => {
|
|
11002
11706
|
let settled = false;
|
|
11003
11707
|
const settle = /* @__PURE__ */ __name((value) => {
|
|
11004
11708
|
if (settled) {
|
|
@@ -11006,7 +11710,7 @@ var LspServerManager = class {
|
|
|
11006
11710
|
}
|
|
11007
11711
|
settled = true;
|
|
11008
11712
|
clearTimeout(timerId);
|
|
11009
|
-
|
|
11713
|
+
resolve6(value);
|
|
11010
11714
|
}, "settle");
|
|
11011
11715
|
const child = spawn2(command, ["--version"], {
|
|
11012
11716
|
stdio: ["ignore", "ignore", "ignore"],
|
|
@@ -11041,16 +11745,16 @@ var LspServerManager = class {
|
|
|
11041
11745
|
* - Relative paths that escape the workspace (e.g. "../../bin/evil")
|
|
11042
11746
|
*/
|
|
11043
11747
|
isPathSafe(command, workspacePath, cwd) {
|
|
11044
|
-
if (!command.includes(
|
|
11748
|
+
if (!command.includes(path11.sep) && !command.includes("/")) {
|
|
11045
11749
|
return true;
|
|
11046
11750
|
}
|
|
11047
|
-
if (
|
|
11751
|
+
if (path11.isAbsolute(command)) {
|
|
11048
11752
|
return true;
|
|
11049
11753
|
}
|
|
11050
|
-
const resolvedWorkspacePath =
|
|
11051
|
-
const basePath = cwd ?
|
|
11052
|
-
const resolvedPath =
|
|
11053
|
-
return resolvedPath.startsWith(resolvedWorkspacePath +
|
|
11754
|
+
const resolvedWorkspacePath = path11.resolve(workspacePath);
|
|
11755
|
+
const basePath = cwd ? path11.resolve(cwd) : resolvedWorkspacePath;
|
|
11756
|
+
const resolvedPath = path11.resolve(basePath, command);
|
|
11757
|
+
return resolvedPath.startsWith(resolvedWorkspacePath + path11.sep) || resolvedPath === resolvedWorkspacePath;
|
|
11054
11758
|
}
|
|
11055
11759
|
/**
|
|
11056
11760
|
* Check whether the workspace trust level allows starting an LSP server.
|
|
@@ -11064,12 +11768,12 @@ var LspServerManager = class {
|
|
|
11064
11768
|
return true;
|
|
11065
11769
|
}
|
|
11066
11770
|
if (this.requireTrustedWorkspace || serverConfig.trustRequired) {
|
|
11067
|
-
|
|
11771
|
+
debugLogger16.warn(
|
|
11068
11772
|
`Workspace not trusted, skipping LSP server ${serverName} (${serverConfig.command ?? serverConfig.transport})`
|
|
11069
11773
|
);
|
|
11070
11774
|
return false;
|
|
11071
11775
|
}
|
|
11072
|
-
|
|
11776
|
+
debugLogger16.info(
|
|
11073
11777
|
`Untrusted workspace, but LSP server ${serverName} has trustRequired=false, attempting cautious startup`
|
|
11074
11778
|
);
|
|
11075
11779
|
return true;
|
|
@@ -11310,11 +12014,11 @@ var NativeLspClient = class {
|
|
|
11310
12014
|
|
|
11311
12015
|
// packages/core/src/lsp/NativeLspService.ts
|
|
11312
12016
|
init_esbuild_shims();
|
|
11313
|
-
import * as
|
|
12017
|
+
import * as path12 from "path";
|
|
11314
12018
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "url";
|
|
11315
|
-
import * as
|
|
12019
|
+
import * as fs10 from "node:fs";
|
|
11316
12020
|
import { promises as fsp } from "node:fs";
|
|
11317
|
-
var
|
|
12021
|
+
var debugLogger17 = createDebugLogger("LSP");
|
|
11318
12022
|
var LANGUAGE_ID_TO_EXTENSIONS = {
|
|
11319
12023
|
typescript: ["ts", "tsx"],
|
|
11320
12024
|
typescriptreact: ["tsx"],
|
|
@@ -11372,7 +12076,7 @@ var NativeLspService = class {
|
|
|
11372
12076
|
const workspaceTrusted = this.config.isTrustedFolder();
|
|
11373
12077
|
this.serverManager.clearServerHandles();
|
|
11374
12078
|
if (this.requireTrustedWorkspace && !workspaceTrusted) {
|
|
11375
|
-
|
|
12079
|
+
debugLogger17.warn(
|
|
11376
12080
|
"Workspace is not trusted, skipping LSP server discovery"
|
|
11377
12081
|
);
|
|
11378
12082
|
return;
|
|
@@ -11390,7 +12094,7 @@ var NativeLspService = class {
|
|
|
11390
12094
|
serverConfigs,
|
|
11391
12095
|
workspaceTrusted
|
|
11392
12096
|
);
|
|
11393
|
-
|
|
12097
|
+
debugLogger17.info(
|
|
11394
12098
|
`Discovered ${admitted.length} LSP server config(s): ${formatServerNames2(
|
|
11395
12099
|
admitted.map((config) => config.name)
|
|
11396
12100
|
)}, skipped=${formatServerNames2(skipped.map((server) => server.name))}`
|
|
@@ -11425,7 +12129,7 @@ var NativeLspService = class {
|
|
|
11425
12129
|
async doReinitialize(signal) {
|
|
11426
12130
|
this.throwIfReinitializeAborted(signal);
|
|
11427
12131
|
const workspaceTrusted = this.config.isTrustedFolder();
|
|
11428
|
-
|
|
12132
|
+
debugLogger17.info(
|
|
11429
12133
|
`Reinitializing LSP servers: workspaceRoot=${this.workspaceRoot}, trusted=${workspaceTrusted}`
|
|
11430
12134
|
);
|
|
11431
12135
|
if (this.requireTrustedWorkspace && !workspaceTrusted) {
|
|
@@ -11444,7 +12148,7 @@ var NativeLspService = class {
|
|
|
11444
12148
|
},
|
|
11445
12149
|
skipped: []
|
|
11446
12150
|
};
|
|
11447
|
-
|
|
12151
|
+
debugLogger17.info(
|
|
11448
12152
|
`LSP reinitialize result: added=<none>, removed=${formatServerNames2(
|
|
11449
12153
|
removed
|
|
11450
12154
|
)}, restarted=<none>, unchanged=<none>, failed=<none>, skipped=<none>`
|
|
@@ -11486,7 +12190,7 @@ var NativeLspService = class {
|
|
|
11486
12190
|
signal
|
|
11487
12191
|
);
|
|
11488
12192
|
this.throwIfReinitializeAborted(signal);
|
|
11489
|
-
|
|
12193
|
+
debugLogger17.info(
|
|
11490
12194
|
`LSP reinitialize result: added=${formatServerNames2(
|
|
11491
12195
|
reconcile.added
|
|
11492
12196
|
)}, removed=${formatServerNames2(
|
|
@@ -11506,7 +12210,7 @@ var NativeLspService = class {
|
|
|
11506
12210
|
const skipped = [];
|
|
11507
12211
|
for (const config of configs) {
|
|
11508
12212
|
if (!workspaceTrusted && config.trustRequired) {
|
|
11509
|
-
|
|
12213
|
+
debugLogger17.warn(
|
|
11510
12214
|
`LSP server ${config.name} requires trusted workspace, skipping`
|
|
11511
12215
|
);
|
|
11512
12216
|
skipped.push({ name: config.name, reason: "server_trust_required" });
|
|
@@ -11551,7 +12255,7 @@ var NativeLspService = class {
|
|
|
11551
12255
|
try {
|
|
11552
12256
|
openedAny = this.sendDocumentOpen(name, handle, uri) || openedAny;
|
|
11553
12257
|
} catch (error) {
|
|
11554
|
-
|
|
12258
|
+
debugLogger17.warn(
|
|
11555
12259
|
`Failed to replay document ${uri} for LSP server ${name}:`,
|
|
11556
12260
|
error
|
|
11557
12261
|
);
|
|
@@ -11680,14 +12384,14 @@ var NativeLspService = class {
|
|
|
11680
12384
|
try {
|
|
11681
12385
|
filePath = fileURLToPath(uri);
|
|
11682
12386
|
} catch (error) {
|
|
11683
|
-
|
|
12387
|
+
debugLogger17.warn(`Failed to resolve file path for ${uri}:`, error);
|
|
11684
12388
|
return false;
|
|
11685
12389
|
}
|
|
11686
12390
|
let text;
|
|
11687
12391
|
try {
|
|
11688
|
-
text =
|
|
12392
|
+
text = fs10.readFileSync(filePath, "utf-8");
|
|
11689
12393
|
} catch (error) {
|
|
11690
|
-
|
|
12394
|
+
debugLogger17.warn(
|
|
11691
12395
|
`Failed to read file for LSP didOpen: ${filePath}`,
|
|
11692
12396
|
error
|
|
11693
12397
|
);
|
|
@@ -11725,7 +12429,7 @@ var NativeLspService = class {
|
|
|
11725
12429
|
this.openedDocuments.set(serverName, openedForServer);
|
|
11726
12430
|
}
|
|
11727
12431
|
resolveLanguageId(filePath, handle) {
|
|
11728
|
-
const ext =
|
|
12432
|
+
const ext = path12.extname(filePath).slice(1).toLowerCase();
|
|
11729
12433
|
if (ext && handle.config.extensionToLanguage) {
|
|
11730
12434
|
const mapping = handle.config.extensionToLanguage;
|
|
11731
12435
|
return mapping[ext] ?? mapping["." + ext];
|
|
@@ -11853,11 +12557,11 @@ var NativeLspService = class {
|
|
|
11853
12557
|
}
|
|
11854
12558
|
async delay(ms, signal) {
|
|
11855
12559
|
if (!signal) {
|
|
11856
|
-
await new Promise((
|
|
12560
|
+
await new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
11857
12561
|
return;
|
|
11858
12562
|
}
|
|
11859
12563
|
this.throwIfReinitializeAborted(signal);
|
|
11860
|
-
await new Promise((
|
|
12564
|
+
await new Promise((resolve6, reject) => {
|
|
11861
12565
|
const onAbort = /* @__PURE__ */ __name(() => {
|
|
11862
12566
|
clearTimeout(timer);
|
|
11863
12567
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -11865,7 +12569,7 @@ var NativeLspService = class {
|
|
|
11865
12569
|
}, "onAbort");
|
|
11866
12570
|
const timer = setTimeout(() => {
|
|
11867
12571
|
signal.removeEventListener("abort", onAbort);
|
|
11868
|
-
|
|
12572
|
+
resolve6();
|
|
11869
12573
|
}, ms);
|
|
11870
12574
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
11871
12575
|
});
|
|
@@ -11915,7 +12619,7 @@ var NativeLspService = class {
|
|
|
11915
12619
|
}
|
|
11916
12620
|
}
|
|
11917
12621
|
} catch (error) {
|
|
11918
|
-
|
|
12622
|
+
debugLogger17.warn(
|
|
11919
12623
|
`LSP workspace/symbol failed for ${serverName}:`,
|
|
11920
12624
|
error
|
|
11921
12625
|
);
|
|
@@ -11966,7 +12670,7 @@ var NativeLspService = class {
|
|
|
11966
12670
|
return definitions.slice(0, limit);
|
|
11967
12671
|
}
|
|
11968
12672
|
} catch (error) {
|
|
11969
|
-
|
|
12673
|
+
debugLogger17.warn(
|
|
11970
12674
|
`LSP textDocument/definition failed for ${name}:`,
|
|
11971
12675
|
error
|
|
11972
12676
|
);
|
|
@@ -12020,7 +12724,7 @@ var NativeLspService = class {
|
|
|
12020
12724
|
return refs.slice(0, limit);
|
|
12021
12725
|
}
|
|
12022
12726
|
} catch (error) {
|
|
12023
|
-
|
|
12727
|
+
debugLogger17.warn(
|
|
12024
12728
|
`LSP textDocument/references failed for ${name}:`,
|
|
12025
12729
|
error
|
|
12026
12730
|
);
|
|
@@ -12061,7 +12765,7 @@ var NativeLspService = class {
|
|
|
12061
12765
|
return normalized2;
|
|
12062
12766
|
}
|
|
12063
12767
|
} catch (error) {
|
|
12064
|
-
|
|
12768
|
+
debugLogger17.warn(`LSP textDocument/hover failed for ${name}:`, error);
|
|
12065
12769
|
}
|
|
12066
12770
|
}
|
|
12067
12771
|
return null;
|
|
@@ -12121,7 +12825,7 @@ var NativeLspService = class {
|
|
|
12121
12825
|
return symbols.slice(0, limit);
|
|
12122
12826
|
}
|
|
12123
12827
|
} catch (error) {
|
|
12124
|
-
|
|
12828
|
+
debugLogger17.warn(
|
|
12125
12829
|
`LSP textDocument/documentSymbol failed for ${name}:`,
|
|
12126
12830
|
error
|
|
12127
12831
|
);
|
|
@@ -12175,7 +12879,7 @@ var NativeLspService = class {
|
|
|
12175
12879
|
return implementations.slice(0, limit);
|
|
12176
12880
|
}
|
|
12177
12881
|
} catch (error) {
|
|
12178
|
-
|
|
12882
|
+
debugLogger17.warn(
|
|
12179
12883
|
`LSP textDocument/implementation failed for ${name}:`,
|
|
12180
12884
|
error
|
|
12181
12885
|
);
|
|
@@ -12229,7 +12933,7 @@ var NativeLspService = class {
|
|
|
12229
12933
|
return items.slice(0, limit);
|
|
12230
12934
|
}
|
|
12231
12935
|
} catch (error) {
|
|
12232
|
-
|
|
12936
|
+
debugLogger17.warn(
|
|
12233
12937
|
`LSP textDocument/prepareCallHierarchy failed for ${name}:`,
|
|
12234
12938
|
error
|
|
12235
12939
|
);
|
|
@@ -12269,7 +12973,7 @@ var NativeLspService = class {
|
|
|
12269
12973
|
return calls.slice(0, limit);
|
|
12270
12974
|
}
|
|
12271
12975
|
} catch (error) {
|
|
12272
|
-
|
|
12976
|
+
debugLogger17.warn(
|
|
12273
12977
|
`LSP callHierarchy/incomingCalls failed for ${name}:`,
|
|
12274
12978
|
error
|
|
12275
12979
|
);
|
|
@@ -12309,7 +13013,7 @@ var NativeLspService = class {
|
|
|
12309
13013
|
return calls.slice(0, limit);
|
|
12310
13014
|
}
|
|
12311
13015
|
} catch (error) {
|
|
12312
|
-
|
|
13016
|
+
debugLogger17.warn(
|
|
12313
13017
|
`LSP callHierarchy/outgoingCalls failed for ${name}:`,
|
|
12314
13018
|
error
|
|
12315
13019
|
);
|
|
@@ -12349,7 +13053,7 @@ var NativeLspService = class {
|
|
|
12349
13053
|
}
|
|
12350
13054
|
}
|
|
12351
13055
|
} catch (error) {
|
|
12352
|
-
|
|
13056
|
+
debugLogger17.warn(
|
|
12353
13057
|
`LSP textDocument/diagnostic failed for ${name}:`,
|
|
12354
13058
|
error
|
|
12355
13059
|
);
|
|
@@ -12391,7 +13095,7 @@ var NativeLspService = class {
|
|
|
12391
13095
|
}
|
|
12392
13096
|
}
|
|
12393
13097
|
} catch (error) {
|
|
12394
|
-
|
|
13098
|
+
debugLogger17.warn(`LSP workspace/diagnostic failed for ${name}:`, error);
|
|
12395
13099
|
}
|
|
12396
13100
|
if (results.length >= limit) {
|
|
12397
13101
|
break;
|
|
@@ -12441,7 +13145,7 @@ var NativeLspService = class {
|
|
|
12441
13145
|
return actions.slice(0, limit);
|
|
12442
13146
|
}
|
|
12443
13147
|
} catch (error) {
|
|
12444
|
-
|
|
13148
|
+
debugLogger17.warn(
|
|
12445
13149
|
`LSP textDocument/codeAction failed for ${name}:`,
|
|
12446
13150
|
error
|
|
12447
13151
|
);
|
|
@@ -12469,7 +13173,7 @@ var NativeLspService = class {
|
|
|
12469
13173
|
}
|
|
12470
13174
|
return true;
|
|
12471
13175
|
} catch (error) {
|
|
12472
|
-
|
|
13176
|
+
debugLogger17.error("Failed to apply workspace edit:", error);
|
|
12473
13177
|
return false;
|
|
12474
13178
|
}
|
|
12475
13179
|
}
|
|
@@ -12478,8 +13182,8 @@ var NativeLspService = class {
|
|
|
12478
13182
|
*/
|
|
12479
13183
|
async applyTextEdits(uri, edits) {
|
|
12480
13184
|
let filePath = uri.startsWith("file://") ? fileURLToPath(uri) : uri;
|
|
12481
|
-
if (!
|
|
12482
|
-
filePath =
|
|
13185
|
+
if (!path12.isAbsolute(filePath)) {
|
|
13186
|
+
filePath = path12.resolve(this.workspaceRoot, filePath);
|
|
12483
13187
|
}
|
|
12484
13188
|
if (!this.workspaceContext.isPathWithinWorkspace(filePath)) {
|
|
12485
13189
|
throw new Error(`Refusing to apply edits outside workspace: ${filePath}`);
|
|
@@ -12514,7 +13218,7 @@ var NativeLspService = class {
|
|
|
12514
13218
|
lines.splice(startLine, endLine - startLine + 1, ...newLines);
|
|
12515
13219
|
}
|
|
12516
13220
|
try {
|
|
12517
|
-
await fsp.access(filePath,
|
|
13221
|
+
await fsp.access(filePath, fs10.constants.W_OK);
|
|
12518
13222
|
} catch (err) {
|
|
12519
13223
|
if (err?.code !== "ENOENT") {
|
|
12520
13224
|
throw err;
|
|
@@ -12732,7 +13436,7 @@ __name(createFollowupController, "createFollowupController");
|
|
|
12732
13436
|
|
|
12733
13437
|
// packages/core/src/followup/suggestionGenerator.ts
|
|
12734
13438
|
init_esbuild_shims();
|
|
12735
|
-
var
|
|
13439
|
+
var debugLogger18 = createDebugLogger("FOLLOWUP");
|
|
12736
13440
|
var SUGGESTION_PROMPT = `[SUGGESTION MODE: Suggest what the user might naturally type next.]
|
|
12737
13441
|
|
|
12738
13442
|
FIRST: Read the LAST FEW LINES of the assistant's most recent message -- that's where
|
|
@@ -12794,7 +13498,7 @@ async function generatePromptSuggestion(config, conversationHistory, abortSignal
|
|
|
12794
13498
|
const cacheSafe = options?.enableCacheSharing ? getCacheSafeParams(sessionId) : null;
|
|
12795
13499
|
const modelOverride = options?.model;
|
|
12796
13500
|
const cacheSharingState = cacheSafe ? "true" : cacheSafeSessionId ? "session_mismatch" : "false";
|
|
12797
|
-
|
|
13501
|
+
debugLogger18.debug(
|
|
12798
13502
|
`Generating suggestion: cacheSharing=${cacheSharingState}, model=${modelOverride || "(default)"}`
|
|
12799
13503
|
);
|
|
12800
13504
|
const raw = cacheSafe ? await generateViaForkedQuery(
|
|
@@ -12810,23 +13514,23 @@ async function generatePromptSuggestion(config, conversationHistory, abortSignal
|
|
|
12810
13514
|
);
|
|
12811
13515
|
const suggestion = typeof raw === "string" ? raw.trim() : null;
|
|
12812
13516
|
if (!suggestion) {
|
|
12813
|
-
|
|
13517
|
+
debugLogger18.debug("Suggestion generation returned empty result");
|
|
12814
13518
|
return { suggestion: null, filterReason: "empty" };
|
|
12815
13519
|
}
|
|
12816
13520
|
const filterReason = getFilterReason(suggestion);
|
|
12817
13521
|
if (filterReason) {
|
|
12818
|
-
|
|
13522
|
+
debugLogger18.debug(
|
|
12819
13523
|
`Suggestion filtered: reason=${filterReason}, text="${suggestion}"`
|
|
12820
13524
|
);
|
|
12821
13525
|
return { suggestion: null, filterReason };
|
|
12822
13526
|
}
|
|
12823
|
-
|
|
13527
|
+
debugLogger18.debug(`Suggestion accepted: "${suggestion}"`);
|
|
12824
13528
|
return { suggestion };
|
|
12825
13529
|
} catch (error) {
|
|
12826
13530
|
if (abortSignal.aborted) {
|
|
12827
13531
|
return { suggestion: null };
|
|
12828
13532
|
}
|
|
12829
|
-
|
|
13533
|
+
debugLogger18.warn("Suggestion generation failed:", error);
|
|
12830
13534
|
return { suggestion: null, filterReason: "error" };
|
|
12831
13535
|
}
|
|
12832
13536
|
}
|
|
@@ -12980,7 +13684,7 @@ __name(getFilterReason, "getFilterReason");
|
|
|
12980
13684
|
init_esbuild_shims();
|
|
12981
13685
|
import { mkdir as mkdir3, copyFile, rm } from "node:fs/promises";
|
|
12982
13686
|
import { existsSync as existsSync3 } from "node:fs";
|
|
12983
|
-
import { join as
|
|
13687
|
+
import { join as join9, dirname as dirname5, relative, isAbsolute as isAbsolute5 } from "node:path";
|
|
12984
13688
|
import { tmpdir } from "node:os";
|
|
12985
13689
|
import { randomUUID } from "node:crypto";
|
|
12986
13690
|
var OverlayFs = class {
|
|
@@ -12988,7 +13692,7 @@ var OverlayFs = class {
|
|
|
12988
13692
|
constructor(realCwd) {
|
|
12989
13693
|
this.realCwd = realCwd;
|
|
12990
13694
|
const id = randomUUID().slice(0, 8);
|
|
12991
|
-
this.overlayDir =
|
|
13695
|
+
this.overlayDir = join9(
|
|
12992
13696
|
tmpdir(),
|
|
12993
13697
|
"qwen-speculation",
|
|
12994
13698
|
String(process.pid),
|
|
@@ -13027,9 +13731,9 @@ var OverlayFs = class {
|
|
|
13027
13731
|
if (this.writtenFiles.has(rel)) {
|
|
13028
13732
|
return this.writtenFiles.get(rel);
|
|
13029
13733
|
}
|
|
13030
|
-
const overlayPath =
|
|
13031
|
-
await mkdir3(
|
|
13032
|
-
const originalPath =
|
|
13734
|
+
const overlayPath = join9(this.overlayDir, rel);
|
|
13735
|
+
await mkdir3(dirname5(overlayPath), { recursive: true });
|
|
13736
|
+
const originalPath = join9(this.realCwd, rel);
|
|
13033
13737
|
if (existsSync3(originalPath)) {
|
|
13034
13738
|
try {
|
|
13035
13739
|
await copyFile(originalPath, overlayPath);
|
|
@@ -13052,9 +13756,9 @@ var OverlayFs = class {
|
|
|
13052
13756
|
async applyToReal() {
|
|
13053
13757
|
const applied = [];
|
|
13054
13758
|
for (const [rel, overlayPath] of this.writtenFiles) {
|
|
13055
|
-
const realPath =
|
|
13759
|
+
const realPath = join9(this.realCwd, rel);
|
|
13056
13760
|
try {
|
|
13057
|
-
await mkdir3(
|
|
13761
|
+
await mkdir3(dirname5(realPath), { recursive: true });
|
|
13058
13762
|
await copyFile(overlayPath, realPath);
|
|
13059
13763
|
applied.push(realPath);
|
|
13060
13764
|
} catch {
|
|
@@ -13076,7 +13780,7 @@ var OverlayFs = class {
|
|
|
13076
13780
|
* Returns null if the path is outside cwd.
|
|
13077
13781
|
*/
|
|
13078
13782
|
toRelative(inputPath) {
|
|
13079
|
-
const abs = isAbsolute5(inputPath) ? inputPath :
|
|
13783
|
+
const abs = isAbsolute5(inputPath) ? inputPath : join9(this.realCwd, inputPath);
|
|
13080
13784
|
const rel = relative(this.realCwd, abs);
|
|
13081
13785
|
if (isAbsolute5(rel) || rel.startsWith("..")) {
|
|
13082
13786
|
return null;
|
|
@@ -13165,7 +13869,7 @@ __name(rewritePathArgs, "rewritePathArgs");
|
|
|
13165
13869
|
|
|
13166
13870
|
// packages/core/src/followup/speculation.ts
|
|
13167
13871
|
init_esbuild_shims();
|
|
13168
|
-
var
|
|
13872
|
+
var debugLogger19 = createDebugLogger("SPECULATION");
|
|
13169
13873
|
var MAX_SPECULATION_TURNS = 20;
|
|
13170
13874
|
var MAX_SPECULATION_MESSAGES = 100;
|
|
13171
13875
|
function observeSpeculationProducer(params) {
|
|
@@ -13413,7 +14117,7 @@ async function runSpeculativeLoop(config, state, cacheSafe, modelOverride) {
|
|
|
13413
14117
|
break;
|
|
13414
14118
|
}
|
|
13415
14119
|
if (!guardDecision.allowed) {
|
|
13416
|
-
|
|
14120
|
+
debugLogger19.debug(
|
|
13417
14121
|
`Speculative guard denial: ${guardDecision.reason}`
|
|
13418
14122
|
);
|
|
13419
14123
|
hitBoundary = true;
|
|
@@ -13651,20 +14355,20 @@ __name(generatePipelinedSuggestion, "generatePipelinedSuggestion");
|
|
|
13651
14355
|
// packages/core/src/utils/filesearch/fileSearch.ts
|
|
13652
14356
|
init_esbuild_shims();
|
|
13653
14357
|
var import_picomatch3 = __toESM(require_picomatch(), 1);
|
|
13654
|
-
import
|
|
14358
|
+
import path16 from "node:path";
|
|
13655
14359
|
|
|
13656
14360
|
// packages/core/src/utils/filesearch/ignore.ts
|
|
13657
14361
|
init_esbuild_shims();
|
|
13658
14362
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
13659
14363
|
var import_picomatch = __toESM(require_picomatch(), 1);
|
|
13660
|
-
import
|
|
13661
|
-
import
|
|
14364
|
+
import fs11 from "node:fs";
|
|
14365
|
+
import path13 from "node:path";
|
|
13662
14366
|
var hasFileExtension = (0, import_picomatch.default)("**/*[*.]*");
|
|
13663
|
-
var
|
|
14367
|
+
var debugLogger20 = createDebugLogger("FILE_SEARCH_IGNORE");
|
|
13664
14368
|
function loadIgnoreRules(options) {
|
|
13665
14369
|
const ignorer = new Ignore();
|
|
13666
14370
|
if (options.useGitignore) {
|
|
13667
|
-
const gitignorePath =
|
|
14371
|
+
const gitignorePath = path13.join(options.projectRoot, ".gitignore");
|
|
13668
14372
|
const gitignoreContent = readIgnoreFile(gitignorePath);
|
|
13669
14373
|
if (gitignoreContent !== void 0) {
|
|
13670
14374
|
ignorer.add(gitignoreContent);
|
|
@@ -13674,7 +14378,7 @@ function loadIgnoreRules(options) {
|
|
|
13674
14378
|
for (const ignoreFileName of getQwenIgnoreFileNames(
|
|
13675
14379
|
options.customIgnoreFiles
|
|
13676
14380
|
)) {
|
|
13677
|
-
const qwenignorePath =
|
|
14381
|
+
const qwenignorePath = path13.join(options.projectRoot, ignoreFileName);
|
|
13678
14382
|
const qwenignoreContent = readIgnoreFile(qwenignorePath);
|
|
13679
14383
|
if (qwenignoreContent !== void 0) {
|
|
13680
14384
|
ignorer.addSource(qwenignoreContent);
|
|
@@ -13695,11 +14399,11 @@ function loadIgnoreRules(options) {
|
|
|
13695
14399
|
__name(loadIgnoreRules, "loadIgnoreRules");
|
|
13696
14400
|
function readIgnoreFile(filePath) {
|
|
13697
14401
|
try {
|
|
13698
|
-
return
|
|
14402
|
+
return fs11.readFileSync(filePath, "utf8");
|
|
13699
14403
|
} catch (_error) {
|
|
13700
14404
|
const error = _error;
|
|
13701
14405
|
if (error.code !== "ENOENT") {
|
|
13702
|
-
|
|
14406
|
+
debugLogger20.warn(`Failed to read ${filePath}: ${error.message}`);
|
|
13703
14407
|
}
|
|
13704
14408
|
return void 0;
|
|
13705
14409
|
}
|
|
@@ -13848,8 +14552,8 @@ __name(hasGlobSyntax, "hasGlobSyntax");
|
|
|
13848
14552
|
// packages/core/src/utils/filesearch/crawler.ts
|
|
13849
14553
|
init_esbuild_shims();
|
|
13850
14554
|
var import_fdir = __toESM(require_dist(), 1);
|
|
13851
|
-
import
|
|
13852
|
-
import
|
|
14555
|
+
import path14 from "node:path";
|
|
14556
|
+
import fs12 from "node:fs";
|
|
13853
14557
|
import { spawn as spawn3 } from "node:child_process";
|
|
13854
14558
|
|
|
13855
14559
|
// packages/core/src/utils/filesearch/crawlCache.ts
|
|
@@ -13934,7 +14638,7 @@ var write = /* @__PURE__ */ __name((key, results, ttlMs) => {
|
|
|
13934
14638
|
|
|
13935
14639
|
// packages/core/src/utils/filesearch/crawler.ts
|
|
13936
14640
|
function toPosixPath(p) {
|
|
13937
|
-
return p.split(
|
|
14641
|
+
return p.split(path14.sep).join(path14.posix.sep);
|
|
13938
14642
|
}
|
|
13939
14643
|
__name(toPosixPath, "toPosixPath");
|
|
13940
14644
|
function normalizeGitPath(p, stripTrailingSlash = false) {
|
|
@@ -14030,7 +14734,7 @@ function redactArgsForLog(args) {
|
|
|
14030
14734
|
if (/^[A-Za-z]:[\\/]/.test(t) || t.startsWith("/") && t.length > 1) {
|
|
14031
14735
|
return "<abs-path>";
|
|
14032
14736
|
}
|
|
14033
|
-
if (t.includes(
|
|
14737
|
+
if (t.includes(path14.sep) && t.length > 32) {
|
|
14034
14738
|
return "<path>";
|
|
14035
14739
|
}
|
|
14036
14740
|
return t;
|
|
@@ -14061,7 +14765,7 @@ function withSafeGitConfig(args) {
|
|
|
14061
14765
|
}
|
|
14062
14766
|
__name(withSafeGitConfig, "withSafeGitConfig");
|
|
14063
14767
|
function canonicalStatePath(p) {
|
|
14064
|
-
return toPosixPath(
|
|
14768
|
+
return toPosixPath(path14.resolve(p));
|
|
14065
14769
|
}
|
|
14066
14770
|
__name(canonicalStatePath, "canonicalStatePath");
|
|
14067
14771
|
function getStateKey(options) {
|
|
@@ -14106,28 +14810,28 @@ function resolveGitDir(crawlDirectory) {
|
|
|
14106
14810
|
}
|
|
14107
14811
|
let current = crawlDirectory;
|
|
14108
14812
|
while (current) {
|
|
14109
|
-
const gitPath =
|
|
14813
|
+
const gitPath = path14.join(current, ".git");
|
|
14110
14814
|
try {
|
|
14111
|
-
const
|
|
14112
|
-
if (
|
|
14815
|
+
const stat5 = fs12.statSync(gitPath);
|
|
14816
|
+
if (stat5.isDirectory()) {
|
|
14113
14817
|
pathCacheSet(resolveGitDirCache, cacheKey, gitPath);
|
|
14114
14818
|
return gitPath;
|
|
14115
14819
|
}
|
|
14116
|
-
if (
|
|
14117
|
-
const contents =
|
|
14820
|
+
if (stat5.isFile()) {
|
|
14821
|
+
const contents = fs12.readFileSync(gitPath, "utf8").trim();
|
|
14118
14822
|
const match = contents.match(/^gitdir:\s*(.+)$/i);
|
|
14119
14823
|
if (!match) {
|
|
14120
14824
|
pathCacheSet(resolveGitDirCache, cacheKey, null);
|
|
14121
14825
|
return null;
|
|
14122
14826
|
}
|
|
14123
14827
|
const resolvedGitDir = match[1].trim();
|
|
14124
|
-
let resolvedAbs =
|
|
14828
|
+
let resolvedAbs = path14.isAbsolute(resolvedGitDir) ? path14.resolve(resolvedGitDir) : path14.resolve(current, resolvedGitDir);
|
|
14125
14829
|
try {
|
|
14126
|
-
resolvedAbs =
|
|
14830
|
+
resolvedAbs = fs12.realpathSync(resolvedAbs);
|
|
14127
14831
|
try {
|
|
14128
|
-
|
|
14832
|
+
fs12.statSync(path14.join(resolvedAbs, "HEAD"));
|
|
14129
14833
|
} catch {
|
|
14130
|
-
|
|
14834
|
+
fs12.statSync(path14.join(resolvedAbs, "index"));
|
|
14131
14835
|
}
|
|
14132
14836
|
} catch {
|
|
14133
14837
|
pathCacheSet(resolveGitDirCache, cacheKey, null);
|
|
@@ -14143,7 +14847,7 @@ function resolveGitDir(crawlDirectory) {
|
|
|
14143
14847
|
return null;
|
|
14144
14848
|
}
|
|
14145
14849
|
}
|
|
14146
|
-
const parent =
|
|
14850
|
+
const parent = path14.dirname(current);
|
|
14147
14851
|
if (parent === current) {
|
|
14148
14852
|
break;
|
|
14149
14853
|
}
|
|
@@ -14159,8 +14863,8 @@ function getGitRootMtime(crawlDirectory) {
|
|
|
14159
14863
|
if (!gitDir) {
|
|
14160
14864
|
return null;
|
|
14161
14865
|
}
|
|
14162
|
-
const indexPath =
|
|
14163
|
-
const indexStat =
|
|
14866
|
+
const indexPath = path14.join(gitDir, "index");
|
|
14867
|
+
const indexStat = fs12.statSync(indexPath);
|
|
14164
14868
|
return indexStat.mtimeMs;
|
|
14165
14869
|
} catch {
|
|
14166
14870
|
}
|
|
@@ -14216,7 +14920,7 @@ function computeLinesFingerprint(lines) {
|
|
|
14216
14920
|
__name(computeLinesFingerprint, "computeLinesFingerprint");
|
|
14217
14921
|
function runCommand(command, args, cwd, timeoutMs = 2e4, options) {
|
|
14218
14922
|
const collectLines = options?.collectLines !== false;
|
|
14219
|
-
return new Promise((
|
|
14923
|
+
return new Promise((resolve6) => {
|
|
14220
14924
|
const lines = [];
|
|
14221
14925
|
let settled = false;
|
|
14222
14926
|
let timedOut = false;
|
|
@@ -14228,7 +14932,7 @@ function runCommand(command, args, cwd, timeoutMs = 2e4, options) {
|
|
|
14228
14932
|
return;
|
|
14229
14933
|
}
|
|
14230
14934
|
settled = true;
|
|
14231
|
-
|
|
14935
|
+
resolve6({ success, lines: resultLines });
|
|
14232
14936
|
}, "finalize");
|
|
14233
14937
|
let stderrBuf = "";
|
|
14234
14938
|
let child;
|
|
@@ -14396,19 +15100,19 @@ function normalizePath(p) {
|
|
|
14396
15100
|
}
|
|
14397
15101
|
__name(normalizePath, "normalizePath");
|
|
14398
15102
|
function getPosixRelative(from, to) {
|
|
14399
|
-
const fromResolved =
|
|
14400
|
-
const toResolved =
|
|
15103
|
+
const fromResolved = path14.resolve(from);
|
|
15104
|
+
const toResolved = path14.resolve(to);
|
|
14401
15105
|
let fromAbs = fromResolved;
|
|
14402
15106
|
let toAbs = toResolved;
|
|
14403
15107
|
try {
|
|
14404
|
-
fromAbs =
|
|
15108
|
+
fromAbs = fs12.realpathSync(fromResolved);
|
|
14405
15109
|
} catch {
|
|
14406
15110
|
}
|
|
14407
15111
|
try {
|
|
14408
|
-
toAbs =
|
|
15112
|
+
toAbs = fs12.realpathSync(toResolved);
|
|
14409
15113
|
} catch {
|
|
14410
15114
|
}
|
|
14411
|
-
const relative2 =
|
|
15115
|
+
const relative2 = path14.relative(fromAbs, toAbs);
|
|
14412
15116
|
const posixRel = toPosixPath(relative2);
|
|
14413
15117
|
return posixRel === "" ? "." : posixRel;
|
|
14414
15118
|
}
|
|
@@ -14417,18 +15121,18 @@ function isValidIgnorePath(relativePath) {
|
|
|
14417
15121
|
if (!relativePath || relativePath === ".") {
|
|
14418
15122
|
return false;
|
|
14419
15123
|
}
|
|
14420
|
-
if (
|
|
15124
|
+
if (path14.posix.isAbsolute(relativePath)) {
|
|
14421
15125
|
return false;
|
|
14422
15126
|
}
|
|
14423
15127
|
return relativePath !== ".." && !relativePath.startsWith("../") && !relativePath.includes("/../");
|
|
14424
15128
|
}
|
|
14425
15129
|
__name(isValidIgnorePath, "isValidIgnorePath");
|
|
14426
15130
|
function toFdirExcludeRelativePath(crawlDirectory, dirPath) {
|
|
14427
|
-
const base =
|
|
14428
|
-
const absoluteCandidate =
|
|
14429
|
-
let rel =
|
|
15131
|
+
const base = path14.resolve(crawlDirectory);
|
|
15132
|
+
const absoluteCandidate = path14.isAbsolute(dirPath) ? dirPath : path14.join(base, dirPath);
|
|
15133
|
+
let rel = path14.relative(base, absoluteCandidate);
|
|
14430
15134
|
rel = toPosixPath(rel);
|
|
14431
|
-
if (!rel || rel.startsWith("..") ||
|
|
15135
|
+
if (!rel || rel.startsWith("..") || path14.posix.isAbsolute(rel)) {
|
|
14432
15136
|
return null;
|
|
14433
15137
|
}
|
|
14434
15138
|
return isValidIgnorePath(rel) ? rel : null;
|
|
@@ -14518,7 +15222,7 @@ __name(isUnderIgnoredDirectory, "isUnderIgnoredDirectory");
|
|
|
14518
15222
|
var YIELD_INTERVAL = 1e3;
|
|
14519
15223
|
async function maybeYield(index) {
|
|
14520
15224
|
if (index > 0 && index % YIELD_INTERVAL === 0) {
|
|
14521
|
-
await new Promise((
|
|
15225
|
+
await new Promise((resolve6) => setImmediate(resolve6));
|
|
14522
15226
|
}
|
|
14523
15227
|
}
|
|
14524
15228
|
__name(maybeYield, "maybeYield");
|
|
@@ -14635,16 +15339,16 @@ function posixPathUnderGitRoot(normalizedFile, relativeToGitRoot, relativeToCraw
|
|
|
14635
15339
|
if (relativeToGitRoot && relativeToGitRoot !== ".") {
|
|
14636
15340
|
const rest = sliceAfterGitPathspecPrefix(nf, normGitRoot);
|
|
14637
15341
|
if (rest !== null) {
|
|
14638
|
-
return
|
|
15342
|
+
return path14.posix.join(normCrawlDir, rest);
|
|
14639
15343
|
}
|
|
14640
15344
|
if (equalsRepoRelativeCaseAware(nf, normGitRoot)) {
|
|
14641
15345
|
const base = nf.replace(/\/+$/, "");
|
|
14642
15346
|
return `${base}/`;
|
|
14643
15347
|
}
|
|
14644
15348
|
const nfFile = nf.replace(/\/+$/, "");
|
|
14645
|
-
return
|
|
15349
|
+
return path14.posix.join(normCrawlDir, nfFile);
|
|
14646
15350
|
}
|
|
14647
|
-
return
|
|
15351
|
+
return path14.posix.join(normCrawlDir, nf.replace(/\/+$/, ""));
|
|
14648
15352
|
}
|
|
14649
15353
|
__name(posixPathUnderGitRoot, "posixPathUnderGitRoot");
|
|
14650
15354
|
async function crawlWithGitLsFiles(stateKey, crawlDirectory, cwd, options, workingTreePrefetch) {
|
|
@@ -14721,13 +15425,13 @@ async function crawlWithGitLsFiles(stateKey, crawlDirectory, cwd, options, worki
|
|
|
14721
15425
|
if (deletedSet.has(normalizedFile)) {
|
|
14722
15426
|
return true;
|
|
14723
15427
|
}
|
|
14724
|
-
let
|
|
15428
|
+
let stat5;
|
|
14725
15429
|
try {
|
|
14726
|
-
|
|
15430
|
+
stat5 = fs12.lstatSync(path14.join(gitRoot, ...normalizedFile.split("/")));
|
|
14727
15431
|
} catch {
|
|
14728
15432
|
return true;
|
|
14729
15433
|
}
|
|
14730
|
-
if (
|
|
15434
|
+
if (stat5.isDirectory()) {
|
|
14731
15435
|
return true;
|
|
14732
15436
|
}
|
|
14733
15437
|
if (relativeToGitRoot && relativeToGitRoot !== "." && normalizedFile === relativeToGitRoot) {
|
|
@@ -14825,7 +15529,7 @@ function collectDirectoryRows(options) {
|
|
|
14825
15529
|
const dirFilter = options.ignore.getDirectoryFilter();
|
|
14826
15530
|
const rows = [];
|
|
14827
15531
|
const visit = /* @__PURE__ */ __name((dir, relativePath, depth) => {
|
|
14828
|
-
const cwdRelative = relativePath === "" ? relativeToCrawlDir :
|
|
15532
|
+
const cwdRelative = relativePath === "" ? relativeToCrawlDir : path14.posix.join(relativeToCrawlDir, relativePath);
|
|
14829
15533
|
if (cwdRelative !== ".") {
|
|
14830
15534
|
const row = cwdRelative.endsWith("/") ? cwdRelative : `${cwdRelative}/`;
|
|
14831
15535
|
if (!isValidIgnorePath(row.slice(0, -1)) || dirFilter(row)) {
|
|
@@ -14838,7 +15542,7 @@ function collectDirectoryRows(options) {
|
|
|
14838
15542
|
}
|
|
14839
15543
|
let entries;
|
|
14840
15544
|
try {
|
|
14841
|
-
entries =
|
|
15545
|
+
entries = fs12.readdirSync(dir, { withFileTypes: true });
|
|
14842
15546
|
} catch {
|
|
14843
15547
|
return;
|
|
14844
15548
|
}
|
|
@@ -14846,8 +15550,8 @@ function collectDirectoryRows(options) {
|
|
|
14846
15550
|
if (!entry.isDirectory()) {
|
|
14847
15551
|
continue;
|
|
14848
15552
|
}
|
|
14849
|
-
const childRelative = relativePath ?
|
|
14850
|
-
visit(
|
|
15553
|
+
const childRelative = relativePath ? path14.posix.join(relativePath, entry.name) : entry.name;
|
|
15554
|
+
visit(path14.join(dir, entry.name), childRelative, depth + 1);
|
|
14851
15555
|
}
|
|
14852
15556
|
}, "visit");
|
|
14853
15557
|
visit(options.crawlDirectory, "", 0);
|
|
@@ -14885,7 +15589,7 @@ async function crawlWithRipgrep(stateKey, crawlDirectory, cwd, options) {
|
|
|
14885
15589
|
return false;
|
|
14886
15590
|
}
|
|
14887
15591
|
const normalizedFile = normalizePath(file);
|
|
14888
|
-
const fullPath =
|
|
15592
|
+
const fullPath = path14.posix.join(relativeToCrawlDir, normalizedFile);
|
|
14889
15593
|
if (!shouldIncludeFile(fullPath, dirFilter, fileFilter)) {
|
|
14890
15594
|
return true;
|
|
14891
15595
|
}
|
|
@@ -14944,7 +15648,7 @@ async function crawlWithFdir(options) {
|
|
|
14944
15648
|
return dirFilter(`${relativePath}/`);
|
|
14945
15649
|
}).filter((filePath, isDirectory) => {
|
|
14946
15650
|
if (isDirectory) return true;
|
|
14947
|
-
const cwdRelative =
|
|
15651
|
+
const cwdRelative = path14.posix.join(relativeToCrawlDir, filePath);
|
|
14948
15652
|
if (!isValidIgnorePath(cwdRelative)) {
|
|
14949
15653
|
return false;
|
|
14950
15654
|
}
|
|
@@ -14957,7 +15661,7 @@ async function crawlWithFdir(options) {
|
|
|
14957
15661
|
} catch {
|
|
14958
15662
|
return [];
|
|
14959
15663
|
}
|
|
14960
|
-
const mapped = results.filter((p) => p.length > 0 && p !== ".").map((p) =>
|
|
15664
|
+
const mapped = results.filter((p) => p.length > 0 && p !== ".").map((p) => path14.posix.join(relativeToCrawlDir, p));
|
|
14961
15665
|
if (relativeToCrawlDir !== ".") {
|
|
14962
15666
|
const rootDir = relativeToCrawlDir.endsWith("/") ? relativeToCrawlDir : `${relativeToCrawlDir}/`;
|
|
14963
15667
|
if (!mapped.includes(rootDir)) {
|
|
@@ -15084,8 +15788,8 @@ __name(applyMaxFilesLimit, "applyMaxFilesLimit");
|
|
|
15084
15788
|
|
|
15085
15789
|
// packages/core/src/utils/filesearch/fzfWorkerHandle.ts
|
|
15086
15790
|
init_esbuild_shims();
|
|
15087
|
-
import
|
|
15088
|
-
import
|
|
15791
|
+
import fs13 from "node:fs";
|
|
15792
|
+
import path15 from "node:path";
|
|
15089
15793
|
import { Worker } from "node:worker_threads";
|
|
15090
15794
|
|
|
15091
15795
|
// node_modules/fzf/dist/fzf.es.js
|
|
@@ -15952,7 +16656,7 @@ function basicMatch(query) {
|
|
|
15952
16656
|
__name(basicMatch, "basicMatch");
|
|
15953
16657
|
var isNode = typeof __require !== "undefined" && typeof window === "undefined";
|
|
15954
16658
|
function asyncMatcher(token, len, iter2, onFinish) {
|
|
15955
|
-
return new Promise((
|
|
16659
|
+
return new Promise((resolve6, reject) => {
|
|
15956
16660
|
const INCREMENT = 1e3;
|
|
15957
16661
|
let i = 0, end = Math.min(INCREMENT, len);
|
|
15958
16662
|
const step = /* @__PURE__ */ __name(() => {
|
|
@@ -15965,7 +16669,7 @@ function asyncMatcher(token, len, iter2, onFinish) {
|
|
|
15965
16669
|
end = Math.min(end + INCREMENT, len);
|
|
15966
16670
|
isNode ? setImmediate(step) : setTimeout(step);
|
|
15967
16671
|
} else {
|
|
15968
|
-
|
|
16672
|
+
resolve6(onFinish());
|
|
15969
16673
|
}
|
|
15970
16674
|
}, "step");
|
|
15971
16675
|
step();
|
|
@@ -16137,11 +16841,11 @@ var inProcessTransport = {
|
|
|
16137
16841
|
var resolvedWorkerPath;
|
|
16138
16842
|
function getWorkerScriptPath() {
|
|
16139
16843
|
if (resolvedWorkerPath !== void 0) return resolvedWorkerPath;
|
|
16140
|
-
const candidate =
|
|
16844
|
+
const candidate = path15.join(
|
|
16141
16845
|
resolveBundleDir(import.meta.url),
|
|
16142
16846
|
"fzfWorker.js"
|
|
16143
16847
|
);
|
|
16144
|
-
resolvedWorkerPath =
|
|
16848
|
+
resolvedWorkerPath = fs13.existsSync(candidate) ? candidate : null;
|
|
16145
16849
|
return resolvedWorkerPath;
|
|
16146
16850
|
}
|
|
16147
16851
|
__name(getWorkerScriptPath, "getWorkerScriptPath");
|
|
@@ -16237,12 +16941,12 @@ var workerTransport = {
|
|
|
16237
16941
|
}
|
|
16238
16942
|
await readyPromise;
|
|
16239
16943
|
const reqId = nextReqId++;
|
|
16240
|
-
return new Promise((
|
|
16944
|
+
return new Promise((resolve6, reject) => {
|
|
16241
16945
|
if (readyState === "disposed" || readyState === "failed") {
|
|
16242
16946
|
reject(new Error(`fzf worker not available (${readyState})`));
|
|
16243
16947
|
return;
|
|
16244
16948
|
}
|
|
16245
|
-
pending.set(reqId, { resolve:
|
|
16949
|
+
pending.set(reqId, { resolve: resolve6, reject });
|
|
16246
16950
|
try {
|
|
16247
16951
|
worker.postMessage({ type: "find", reqId, pattern, limit });
|
|
16248
16952
|
} catch (err) {
|
|
@@ -16337,7 +17041,7 @@ async function filter(allPaths, pattern, signal) {
|
|
|
16337
17041
|
const results = [];
|
|
16338
17042
|
for (const [i, p] of allPaths.entries()) {
|
|
16339
17043
|
if (i % 1e3 === 0) {
|
|
16340
|
-
await new Promise((
|
|
17044
|
+
await new Promise((resolve6) => setImmediate(resolve6));
|
|
16341
17045
|
if (signal?.aborted) {
|
|
16342
17046
|
throw new AbortError();
|
|
16343
17047
|
}
|
|
@@ -16416,7 +17120,7 @@ var RecursiveFileSearch = class {
|
|
|
16416
17120
|
const results = [];
|
|
16417
17121
|
for (const [i, candidate] of filteredCandidates.entries()) {
|
|
16418
17122
|
if (i % 1e3 === 0) {
|
|
16419
|
-
await new Promise((
|
|
17123
|
+
await new Promise((resolve6) => setImmediate(resolve6));
|
|
16420
17124
|
if (options.signal?.aborted) {
|
|
16421
17125
|
throw new AbortError();
|
|
16422
17126
|
}
|
|
@@ -16458,9 +17162,9 @@ var DirectoryFileSearch = class {
|
|
|
16458
17162
|
throw new Error("Engine not initialized. Call initialize() first.");
|
|
16459
17163
|
}
|
|
16460
17164
|
pattern = pattern || "*";
|
|
16461
|
-
const dir = pattern.endsWith("/") ? pattern :
|
|
16462
|
-
const crawlDirectory =
|
|
16463
|
-
const listingProjectRoot =
|
|
17165
|
+
const dir = pattern.endsWith("/") ? pattern : path16.dirname(pattern);
|
|
17166
|
+
const crawlDirectory = path16.join(this.options.projectRoot, dir);
|
|
17167
|
+
const listingProjectRoot = path16.resolve(crawlDirectory) === path16.resolve(this.options.projectRoot);
|
|
16464
17168
|
const results = await crawl({
|
|
16465
17169
|
crawlDirectory,
|
|
16466
17170
|
cwd: this.options.projectRoot,
|
|
@@ -16541,13 +17245,13 @@ __name(analyzeToolResultRetention, "analyzeToolResultRetention");
|
|
|
16541
17245
|
|
|
16542
17246
|
// packages/core/src/utils/pathReader.ts
|
|
16543
17247
|
init_esbuild_shims();
|
|
16544
|
-
import { promises as
|
|
16545
|
-
import
|
|
17248
|
+
import { promises as fs14 } from "node:fs";
|
|
17249
|
+
import path17 from "node:path";
|
|
16546
17250
|
async function readPathFromWorkspace(pathStr, config) {
|
|
16547
17251
|
const workspace = config.getWorkspaceContext();
|
|
16548
17252
|
const fileService = config.getFileService();
|
|
16549
17253
|
let absolutePath = null;
|
|
16550
|
-
if (
|
|
17254
|
+
if (path17.isAbsolute(pathStr)) {
|
|
16551
17255
|
if (!workspace.isPathWithinWorkspace(pathStr)) {
|
|
16552
17256
|
throw new Error(
|
|
16553
17257
|
`Absolute path is outside of the allowed workspace: ${pathStr}`
|
|
@@ -16557,9 +17261,9 @@ async function readPathFromWorkspace(pathStr, config) {
|
|
|
16557
17261
|
} else {
|
|
16558
17262
|
const searchDirs = workspace.getDirectories();
|
|
16559
17263
|
for (const dir of searchDirs) {
|
|
16560
|
-
const potentialPath =
|
|
17264
|
+
const potentialPath = path17.resolve(dir, pathStr);
|
|
16561
17265
|
try {
|
|
16562
|
-
await
|
|
17266
|
+
await fs14.access(potentialPath);
|
|
16563
17267
|
absolutePath = potentialPath;
|
|
16564
17268
|
break;
|
|
16565
17269
|
} catch {
|
|
@@ -16569,7 +17273,7 @@ async function readPathFromWorkspace(pathStr, config) {
|
|
|
16569
17273
|
if (!absolutePath) {
|
|
16570
17274
|
throw new Error(`Path not found in workspace: ${pathStr}`);
|
|
16571
17275
|
}
|
|
16572
|
-
const stats = await
|
|
17276
|
+
const stats = await fs14.stat(absolutePath);
|
|
16573
17277
|
if (stats.isDirectory()) {
|
|
16574
17278
|
const allParts = [];
|
|
16575
17279
|
allParts.push({
|
|
@@ -16585,7 +17289,7 @@ async function readPathFromWorkspace(pathStr, config) {
|
|
|
16585
17289
|
absolute: true
|
|
16586
17290
|
});
|
|
16587
17291
|
const relativeFiles = files.map(
|
|
16588
|
-
(p) =>
|
|
17292
|
+
(p) => path17.relative(config.getTargetDir(), p)
|
|
16589
17293
|
);
|
|
16590
17294
|
const filteringOptions = config.getFileFilteringOptions();
|
|
16591
17295
|
const filteredFiles = fileService.filterFiles(relativeFiles, {
|
|
@@ -16593,10 +17297,10 @@ async function readPathFromWorkspace(pathStr, config) {
|
|
|
16593
17297
|
respectQwenIgnore: filteringOptions.respectQwenIgnore
|
|
16594
17298
|
});
|
|
16595
17299
|
const finalFiles = filteredFiles.map(
|
|
16596
|
-
(p) =>
|
|
17300
|
+
(p) => path17.resolve(config.getTargetDir(), p)
|
|
16597
17301
|
);
|
|
16598
17302
|
for (const filePath of finalFiles) {
|
|
16599
|
-
const relativePathForDisplay =
|
|
17303
|
+
const relativePathForDisplay = path17.relative(absolutePath, filePath);
|
|
16600
17304
|
allParts.push({ text: `--- ${relativePathForDisplay} ---
|
|
16601
17305
|
` });
|
|
16602
17306
|
const result = await processSingleFileContent(filePath, config, {
|
|
@@ -16612,7 +17316,7 @@ async function readPathFromWorkspace(pathStr, config) {
|
|
|
16612
17316
|
allParts.push({ text: `--- End of content for directory: ${pathStr} ---` });
|
|
16613
17317
|
return allParts;
|
|
16614
17318
|
} else {
|
|
16615
|
-
const relativePath =
|
|
17319
|
+
const relativePath = path17.relative(config.getTargetDir(), absolutePath);
|
|
16616
17320
|
const singleFileFilteringOptions = config.getFileFilteringOptions();
|
|
16617
17321
|
const filtered = fileService.filterFiles([relativePath], {
|
|
16618
17322
|
respectGitIgnore: singleFileFilteringOptions.respectGitIgnore,
|
|
@@ -16631,25 +17335,25 @@ __name(readPathFromWorkspace, "readPathFromWorkspace");
|
|
|
16631
17335
|
|
|
16632
17336
|
// packages/core/src/utils/projectSummary.ts
|
|
16633
17337
|
init_esbuild_shims();
|
|
16634
|
-
import * as
|
|
16635
|
-
import * as
|
|
17338
|
+
import * as fs15 from "fs/promises";
|
|
17339
|
+
import * as path18 from "path";
|
|
16636
17340
|
var PROJECT_SUMMARY_FILENAME = "PROJECT_SUMMARY.md";
|
|
16637
17341
|
var WELCOME_BACK_STATE_FILENAME = "welcome-back-state.json";
|
|
16638
17342
|
function getProjectSummaryPath() {
|
|
16639
|
-
return
|
|
17343
|
+
return path18.join(process.cwd(), ".qwen", PROJECT_SUMMARY_FILENAME);
|
|
16640
17344
|
}
|
|
16641
17345
|
__name(getProjectSummaryPath, "getProjectSummaryPath");
|
|
16642
17346
|
function getWelcomeBackStatePath() {
|
|
16643
|
-
return
|
|
17347
|
+
return path18.join(process.cwd(), ".qwen", WELCOME_BACK_STATE_FILENAME);
|
|
16644
17348
|
}
|
|
16645
17349
|
__name(getWelcomeBackStatePath, "getWelcomeBackStatePath");
|
|
16646
|
-
function buildSummaryFingerprint(
|
|
16647
|
-
return `${
|
|
17350
|
+
function buildSummaryFingerprint(stat5) {
|
|
17351
|
+
return `${stat5.mtimeMs}:${stat5.size}`;
|
|
16648
17352
|
}
|
|
16649
17353
|
__name(buildSummaryFingerprint, "buildSummaryFingerprint");
|
|
16650
17354
|
async function getWelcomeBackState() {
|
|
16651
17355
|
try {
|
|
16652
|
-
const raw = await
|
|
17356
|
+
const raw = await fs15.readFile(getWelcomeBackStatePath(), "utf-8");
|
|
16653
17357
|
const parsed = JSON.parse(raw);
|
|
16654
17358
|
if (parsed.version !== 1 || parsed.lastChoice !== "restart" || typeof parsed.summaryFingerprint !== "string") {
|
|
16655
17359
|
return null;
|
|
@@ -16665,7 +17369,7 @@ async function getWelcomeBackState() {
|
|
|
16665
17369
|
__name(getWelcomeBackState, "getWelcomeBackState");
|
|
16666
17370
|
async function saveWelcomeBackRestartChoice(summaryFingerprint) {
|
|
16667
17371
|
const statePath = getWelcomeBackStatePath();
|
|
16668
|
-
await
|
|
17372
|
+
await fs15.mkdir(path18.dirname(statePath), { recursive: true });
|
|
16669
17373
|
const state = {
|
|
16670
17374
|
version: 1,
|
|
16671
17375
|
lastChoice: "restart",
|
|
@@ -16678,7 +17382,7 @@ async function saveWelcomeBackRestartChoice(summaryFingerprint) {
|
|
|
16678
17382
|
__name(saveWelcomeBackRestartChoice, "saveWelcomeBackRestartChoice");
|
|
16679
17383
|
async function clearWelcomeBackState() {
|
|
16680
17384
|
try {
|
|
16681
|
-
await
|
|
17385
|
+
await fs15.rm(getWelcomeBackStatePath(), { force: true });
|
|
16682
17386
|
} catch {
|
|
16683
17387
|
}
|
|
16684
17388
|
}
|
|
@@ -16686,15 +17390,15 @@ __name(clearWelcomeBackState, "clearWelcomeBackState");
|
|
|
16686
17390
|
async function getProjectSummaryInfo() {
|
|
16687
17391
|
const summaryPath = getProjectSummaryPath();
|
|
16688
17392
|
try {
|
|
16689
|
-
await
|
|
17393
|
+
await fs15.access(summaryPath);
|
|
16690
17394
|
} catch {
|
|
16691
17395
|
return {
|
|
16692
17396
|
hasHistory: false
|
|
16693
17397
|
};
|
|
16694
17398
|
}
|
|
16695
17399
|
try {
|
|
16696
|
-
const summaryStat = await
|
|
16697
|
-
const content = await
|
|
17400
|
+
const summaryStat = await fs15.stat(summaryPath);
|
|
17401
|
+
const content = await fs15.readFile(summaryPath, "utf-8");
|
|
16698
17402
|
const summaryFingerprint = buildSummaryFingerprint(summaryStat);
|
|
16699
17403
|
const timestampMatch = content.match(/\*\*Update time\*\*: (.+)/);
|
|
16700
17404
|
const timestamp = timestampMatch ? timestampMatch[1] : (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -16762,9 +17466,9 @@ __name(getProjectSummaryInfo, "getProjectSummaryInfo");
|
|
|
16762
17466
|
|
|
16763
17467
|
// packages/core/src/tools/readManyFiles.ts
|
|
16764
17468
|
init_esbuild_shims();
|
|
16765
|
-
import * as
|
|
16766
|
-
import * as
|
|
16767
|
-
import * as
|
|
17469
|
+
import * as fs16 from "node:fs";
|
|
17470
|
+
import * as os3 from "node:os";
|
|
17471
|
+
import * as path19 from "node:path";
|
|
16768
17472
|
var DEFAULT_OUTPUT_HEADER = "\n--- Content from referenced files ---";
|
|
16769
17473
|
var DEFAULT_OUTPUT_TERMINATOR = "\n--- End of content ---";
|
|
16770
17474
|
var SNAPSHOT_MAX_SIZE_BYTES = 100 * 1024 * 1024;
|
|
@@ -16784,7 +17488,7 @@ async function readManyFiles(config, options) {
|
|
|
16784
17488
|
for (const rawPattern of inputPatterns) {
|
|
16785
17489
|
signal?.throwIfAborted();
|
|
16786
17490
|
const normalizedPattern = rawPattern.replace(/\\/g, "/");
|
|
16787
|
-
const fullPath =
|
|
17491
|
+
const fullPath = path19.resolve(projectRoot, normalizedPattern);
|
|
16788
17492
|
const displayPath = displayPaths?.get(fullPath) ?? fullPath;
|
|
16789
17493
|
const validatedIdentity = validatedPathIdentities?.get(fullPath);
|
|
16790
17494
|
if (validatedPathIdentities && !validatedIdentity) continue;
|
|
@@ -16803,7 +17507,7 @@ async function readManyFiles(config, options) {
|
|
|
16803
17507
|
if (validatedIdentity && !await matchesValidatedPathIdentity(fullPath, validatedIdentity)) {
|
|
16804
17508
|
continue;
|
|
16805
17509
|
}
|
|
16806
|
-
const stats =
|
|
17510
|
+
const stats = fs16.existsSync(fullPath) ? fs16.statSync(fullPath) : null;
|
|
16807
17511
|
if (stats?.isDirectory()) {
|
|
16808
17512
|
const { contentParts: dirParts, info } = await readDirectory(
|
|
16809
17513
|
config,
|
|
@@ -16923,9 +17627,9 @@ async function readValidatedTextFileContent(config, filePath, expected, preserve
|
|
|
16923
17627
|
__name(readValidatedTextFileContent, "readValidatedTextFileContent");
|
|
16924
17628
|
async function matchesValidatedPathIdentity(filePath, expected) {
|
|
16925
17629
|
try {
|
|
16926
|
-
const canonicalPath = await
|
|
17630
|
+
const canonicalPath = await fs16.promises.realpath(filePath);
|
|
16927
17631
|
if (canonicalPath !== filePath) return false;
|
|
16928
|
-
const stats = await
|
|
17632
|
+
const stats = await fs16.promises.stat(canonicalPath);
|
|
16929
17633
|
return statsMatchValidatedIdentity(stats, expected);
|
|
16930
17634
|
} catch {
|
|
16931
17635
|
return false;
|
|
@@ -16954,13 +17658,13 @@ async function snapshotValidatedFile(filePath, expected, signal) {
|
|
|
16954
17658
|
if (stats.size > SNAPSHOT_MAX_SIZE_BYTES) {
|
|
16955
17659
|
return void 0;
|
|
16956
17660
|
}
|
|
16957
|
-
snapshotDir = await
|
|
16958
|
-
|
|
17661
|
+
snapshotDir = await fs16.promises.mkdtemp(
|
|
17662
|
+
path19.join(os3.tmpdir(), "qwen-validated-read-")
|
|
16959
17663
|
);
|
|
16960
|
-
const snapshotPath =
|
|
16961
|
-
const target = await
|
|
17664
|
+
const snapshotPath = path19.join(snapshotDir, path19.basename(filePath));
|
|
17665
|
+
const target = await fs16.promises.open(
|
|
16962
17666
|
snapshotPath,
|
|
16963
|
-
|
|
17667
|
+
fs16.constants.O_WRONLY | fs16.constants.O_CREAT | fs16.constants.O_EXCL,
|
|
16964
17668
|
384
|
|
16965
17669
|
);
|
|
16966
17670
|
try {
|
|
@@ -17001,7 +17705,7 @@ async function snapshotValidatedFile(filePath, expected, signal) {
|
|
|
17001
17705
|
result = {
|
|
17002
17706
|
filePath: snapshotPath,
|
|
17003
17707
|
stats,
|
|
17004
|
-
cleanup: /* @__PURE__ */ __name(() =>
|
|
17708
|
+
cleanup: /* @__PURE__ */ __name(() => fs16.promises.rm(snapshotDir, { recursive: true, force: true }), "cleanup")
|
|
17005
17709
|
};
|
|
17006
17710
|
return result;
|
|
17007
17711
|
} finally {
|
|
@@ -17013,7 +17717,7 @@ async function snapshotValidatedFile(filePath, expected, signal) {
|
|
|
17013
17717
|
return void 0;
|
|
17014
17718
|
} finally {
|
|
17015
17719
|
if (snapshotDir && !result) {
|
|
17016
|
-
await
|
|
17720
|
+
await fs16.promises.rm(snapshotDir, { recursive: true, force: true });
|
|
17017
17721
|
}
|
|
17018
17722
|
}
|
|
17019
17723
|
}
|
|
@@ -17165,6 +17869,8 @@ export {
|
|
|
17165
17869
|
encodeInsightErrorMessage,
|
|
17166
17870
|
Logger,
|
|
17167
17871
|
executeToolCall,
|
|
17872
|
+
loadOutputStyleCatalog,
|
|
17873
|
+
findOutputStyle,
|
|
17168
17874
|
TURN_INTERRUPTION_HISTORY_TAIL_COUNT,
|
|
17169
17875
|
detectTurnInterruption,
|
|
17170
17876
|
buildSessionRecoveryPlan,
|
|
@@ -17194,9 +17900,14 @@ export {
|
|
|
17194
17900
|
findProviderByCredentials,
|
|
17195
17901
|
getAllProviderBaseUrls,
|
|
17196
17902
|
applyProviderInstallPlan,
|
|
17903
|
+
isApiUserPrompt,
|
|
17904
|
+
findApiRewindCutPoint,
|
|
17905
|
+
countApiUserPrompts,
|
|
17197
17906
|
IMAGE_CAPABILITY,
|
|
17198
17907
|
generateSessionRecap,
|
|
17199
17908
|
SessionReferenceService,
|
|
17909
|
+
getLastPeerInboxFailure,
|
|
17910
|
+
describePeerInboxFailure,
|
|
17200
17911
|
startPeerInbox,
|
|
17201
17912
|
WebTerminalRegistry,
|
|
17202
17913
|
generateToolUseSummary,
|
|
@@ -17284,12 +17995,12 @@ export {
|
|
|
17284
17995
|
*/
|
|
17285
17996
|
/**
|
|
17286
17997
|
* @license
|
|
17287
|
-
* Copyright
|
|
17998
|
+
* Copyright 2026 Qwen
|
|
17288
17999
|
* SPDX-License-Identifier: Apache-2.0
|
|
17289
18000
|
*/
|
|
17290
18001
|
/**
|
|
17291
18002
|
* @license
|
|
17292
|
-
* Copyright
|
|
18003
|
+
* Copyright 2025 Qwen
|
|
17293
18004
|
* SPDX-License-Identifier: Apache-2.0
|
|
17294
18005
|
*/
|
|
17295
18006
|
/**
|
|
@@ -17300,7 +18011,8 @@ export {
|
|
|
17300
18011
|
* Shared Follow-up Suggestions State Logic
|
|
17301
18012
|
*
|
|
17302
18013
|
* Framework-agnostic state management for prompt suggestions,
|
|
17303
|
-
*
|
|
18014
|
+
* used by the CLI (Ink) follow-up hook; Web Shell's daemon followup hook
|
|
18015
|
+
* maintains its own copy.
|
|
17304
18016
|
*/
|
|
17305
18017
|
/**
|
|
17306
18018
|
* @license
|