@qwen-code/qwen-code 0.26.2-preview.0 → 0.26.2-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/chunks/{MaxSizedBox-K6YUM3DX.js → MaxSizedBox-EGHZ2BPF.js} +1 -1
- package/chunks/{StandaloneSessionPicker-75IC33SN.js → StandaloneSessionPicker-UVCW6YW3.js} +1 -1
- package/chunks/{acp-subagent-executor-3NHBJRPL.js → acp-subagent-executor-AQ7AWSD4.js} +1 -1
- package/chunks/{acpAgent-JT6KQPTH.js → acpAgent-IV7JAGD7.js} +3 -3
- package/chunks/{advisor-TI2UVEZK.js → advisor-UZ4TF65D.js} +1 -1
- package/chunks/{agent-SWIZZZMY.js → agent-CNLVAWDD.js} +1 -1
- package/chunks/{agent-headless-USWEJ4GW.js → agent-headless-ZJUJLUJS.js} +1 -1
- package/chunks/{agent-host-client-ZFIMQX33.js → agent-host-client-SN5V2KBH.js} +1 -1
- package/chunks/{agent-host-connections-LOFD7O7Q.js → agent-host-connections-VKMAJIIU.js} +1 -1
- package/chunks/{anthropicContentGenerator-HMLEI4FI.js → anthropicContentGenerator-QTJVPAMI.js} +1 -1
- package/chunks/{autofix-pr-NKR2VSLB.js → autofix-pr-U7GNSH27.js} +1 -1
- package/chunks/{batch-JQZ3TOHA.js → batch-MBEWETXN.js} +1 -1
- package/chunks/{bridge-EIWWT4P6.js → bridge-TEJLNYV3.js} +1 -1
- package/chunks/{channel-settings-store-FLRLUA67.js → channel-settings-store-QNCKWWBL.js} +1 -1
- package/chunks/{chunk-244YTFYD.js → chunk-23KDY7UW.js} +1 -1
- package/chunks/{chunk-7TDMQJTD.js → chunk-2DWWSMTV.js} +1 -1
- package/chunks/{chunk-UU2LTNSF.js → chunk-3IZMVLVZ.js} +1 -1
- package/chunks/{chunk-B6T4ESBM.js → chunk-3JI7IKJL.js} +1 -1
- package/chunks/{chunk-Y5TT2G3N.js → chunk-427MARCP.js} +1 -1
- package/chunks/{chunk-KX7JS2P7.js → chunk-4NNNGSQY.js} +3 -3
- package/chunks/{chunk-6TQS2WQO.js → chunk-4RM7KY3Z.js} +2 -2
- package/chunks/{chunk-YL3N2UGG.js → chunk-5X7S4AE6.js} +5 -5
- package/chunks/{chunk-K2HAY5PY.js → chunk-5XAECBED.js} +1 -1
- package/chunks/{chunk-VCHFBETO.js → chunk-66KKSLUO.js} +1 -1
- package/chunks/{chunk-BSJR2KEF.js → chunk-6CIIDUZW.js} +1 -1
- package/chunks/{chunk-22CLK7PK.js → chunk-7EBRMQYW.js} +1 -1
- package/chunks/{chunk-J4TFGZ4A.js → chunk-7FSC2NKA.js} +1 -1
- package/chunks/{chunk-6JFC5M6B.js → chunk-A5TAAMML.js} +1 -1
- package/chunks/{chunk-DHHACQVN.js → chunk-AOYSX44A.js} +1 -1
- package/chunks/{chunk-VFVZ2DY7.js → chunk-AZCMQ3DD.js} +2 -2
- package/chunks/{chunk-BQJXWIMR.js → chunk-B6F7CVBP.js} +1 -1
- package/chunks/{chunk-OVPEAKOQ.js → chunk-BDQOLT37.js} +1 -1
- package/chunks/{chunk-5SYUBQNO.js → chunk-BIWEUAKG.js} +1 -1
- package/chunks/{chunk-BZM66PQO.js → chunk-BJ5R7LOM.js} +1 -1
- package/chunks/{chunk-4R2OHBH3.js → chunk-BKUFRNME.js} +1 -1
- package/chunks/{chunk-NIYWNFVF.js → chunk-BNZSPX2I.js} +1 -1
- package/chunks/{chunk-FJV2ECNY.js → chunk-D2URRVOK.js} +1 -1
- package/chunks/{chunk-GT6CHVAI.js → chunk-DANP7CMW.js} +1 -1
- package/chunks/{chunk-FHFLD4DR.js → chunk-DBHLRZGI.js} +1 -1
- package/chunks/{chunk-Y2UXZJLM.js → chunk-DL7TKH2E.js} +2 -2
- package/chunks/{chunk-MCQE2U7N.js → chunk-DOWKH5OZ.js} +6 -6
- package/chunks/{chunk-UHRLBY3C.js → chunk-DPHQJPCU.js} +1 -1
- package/chunks/{chunk-PV2VT25U.js → chunk-DPNGBOI7.js} +1 -1
- package/chunks/{chunk-NCDNF7UJ.js → chunk-DXRXF4QD.js} +1 -1
- package/chunks/{chunk-OCVRMNEQ.js → chunk-DZ3GV34J.js} +1 -1
- package/chunks/{chunk-3QIAXWWW.js → chunk-EU2MKUK4.js} +1 -1
- package/chunks/{chunk-KMAVI6FB.js → chunk-EVBUXPGM.js} +1 -1
- package/chunks/{chunk-BVSTV4JM.js → chunk-F3ZRU2SA.js} +1 -1
- package/chunks/{chunk-TBZY477Y.js → chunk-FCZYH27X.js} +1 -1
- package/chunks/{chunk-JCOK67LT.js → chunk-FNDMWG43.js} +1 -1
- package/chunks/{chunk-5SF32OGU.js → chunk-GDXLJJSW.js} +1 -1
- package/chunks/{chunk-SO6FCPRI.js → chunk-GZYIXB7Y.js} +1 -1
- package/chunks/{chunk-WZPTWC7X.js → chunk-HHNAH4IH.js} +1 -1
- package/chunks/{chunk-7KCAOXNL.js → chunk-HOKROBQZ.js} +1 -1
- package/chunks/{chunk-34ZBUQJV.js → chunk-IGPAATQW.js} +1 -1
- package/chunks/{chunk-2ZTRKK2O.js → chunk-INFBJDWM.js} +1 -1
- package/chunks/{chunk-IEJ2CGRN.js → chunk-J3R7ZNSA.js} +1 -1
- package/chunks/{chunk-KT5MPRYB.js → chunk-JCRS367I.js} +1 -1
- package/chunks/{chunk-7JWJTRP6.js → chunk-JFVXZFMV.js} +1 -1
- package/chunks/{chunk-47LP4MBD.js → chunk-JKMGS2VD.js} +1 -1
- package/chunks/{chunk-WRJ3PMDZ.js → chunk-JUQ7T2MV.js} +1 -1
- package/chunks/{chunk-NZX3UWNF.js → chunk-KQ4TDFNE.js} +1 -1
- package/chunks/{chunk-X7D4VKMX.js → chunk-L6BKKN42.js} +1 -1
- package/chunks/{chunk-YG5HVFMY.js → chunk-L7Y6MOHS.js} +1 -1
- package/chunks/{chunk-UFTIUKD4.js → chunk-LGYXZJI3.js} +1 -1
- package/chunks/{chunk-JQGGILML.js → chunk-LPOEVTKD.js} +1 -1
- package/chunks/{chunk-5KI55A6S.js → chunk-LRXS7ZI2.js} +1 -1
- package/chunks/{chunk-CKVHEYXW.js → chunk-LYYVSCNL.js} +1 -1
- package/chunks/{chunk-LIIMQ4DI.js → chunk-LZNBHBAJ.js} +6 -6
- package/chunks/{chunk-H4GDEXMF.js → chunk-M3C6RDGC.js} +1 -1
- package/chunks/{chunk-KKKUB3RQ.js → chunk-MNVMHVQJ.js} +1 -1
- package/chunks/{chunk-2B3W7IQY.js → chunk-MVGQFFIK.js} +1 -1
- package/chunks/{chunk-Q35A2RGO.js → chunk-NC7BCZPQ.js} +1 -1
- package/chunks/{chunk-2ZOTG3NW.js → chunk-NE627MUW.js} +1 -1
- package/chunks/{chunk-W4P2EN3V.js → chunk-NZNRCPGE.js} +1 -1
- package/chunks/{chunk-YPDQJQ3S.js → chunk-P3M4WWRA.js} +1 -1
- package/chunks/{chunk-DVB36ASH.js → chunk-P534ONQN.js} +1 -1
- package/chunks/{chunk-EL5J4ESB.js → chunk-QF44NNSC.js} +1 -1
- package/chunks/{chunk-IQPJOBPI.js → chunk-QHGCDHNW.js} +1 -1
- package/chunks/{chunk-EVZC4KEQ.js → chunk-QWJX7NIP.js} +1 -1
- package/chunks/{chunk-J2TJL2F4.js → chunk-S53G54DW.js} +2 -2
- package/chunks/{chunk-3A6LFJJV.js → chunk-SMNFL3AD.js} +1 -1
- package/chunks/{chunk-WDO3K3P2.js → chunk-TOBNWST4.js} +1 -1
- package/chunks/{chunk-AVGJ4HE3.js → chunk-TQSBUHAM.js} +1 -1
- package/chunks/{chunk-ABUS7DNN.js → chunk-TW5QEP2J.js} +1 -1
- package/chunks/{chunk-WYM4Z4D5.js → chunk-UEB2F43V.js} +1 -1
- package/chunks/{chunk-FUUPMVD2.js → chunk-UPPE4I6H.js} +1 -1
- package/chunks/{chunk-UHBJVFZA.js → chunk-US42COBM.js} +1 -1
- package/chunks/{chunk-RMQNBSMK.js → chunk-UUY6XSQI.js} +1 -1
- package/chunks/{chunk-UVQUQNCA.js → chunk-UZI3IA27.js} +1 -1
- package/chunks/{chunk-SXJ2E33J.js → chunk-V6VMUJ47.js} +1 -1
- package/chunks/{chunk-5UFCNJGN.js → chunk-VG2ZINTO.js} +1 -1
- package/chunks/{chunk-JPPPJ2GN.js → chunk-VJI6MHWX.js} +1 -1
- package/chunks/{chunk-AUI7WVSU.js → chunk-VOBNHBCJ.js} +1 -1
- package/chunks/{chunk-3BNJDZHU.js → chunk-VUEZWMI4.js} +1 -1
- package/chunks/{chunk-LMNKCL55.js → chunk-W7ZX6WB3.js} +2 -2
- package/chunks/{chunk-HVS6V2UZ.js → chunk-WA2LKUVP.js} +1 -1
- package/chunks/{chunk-7APLU2XE.js → chunk-WFFCJ5PF.js} +1 -1
- package/chunks/{chunk-3TD4WAG5.js → chunk-WQY5GE65.js} +1 -1
- package/chunks/{chunk-3YWRMF6C.js → chunk-WSESLSKK.js} +1 -1
- package/chunks/{chunk-NILCQMZ7.js → chunk-XFJV5NYT.js} +1 -1
- package/chunks/{chunk-LGBGUITT.js → chunk-XIYLRIW4.js} +1 -1
- package/chunks/{chunk-KS74L67R.js → chunk-XQ2NYKJH.js} +1 -1
- package/chunks/{chunk-JB2NOB6W.js → chunk-Y3VRWG52.js} +1 -1
- package/chunks/{chunk-GVZ6D2NL.js → chunk-YBISME5B.js} +1 -1
- package/chunks/{chunk-2C2253QI.js → chunk-YJNWPSB3.js} +1 -1
- package/chunks/{chunk-O2T3GQ6F.js → chunk-YWVV5STA.js} +1 -1
- package/chunks/{chunk-MAQZSOHI.js → chunk-ZH4J3FL6.js} +1 -1
- package/chunks/{chunk-THNEKTPK.js → chunk-ZSKCF6DI.js} +1 -1
- package/chunks/{chunk-Z7BAHKO5.js → chunk-ZW6456SD.js} +1 -1
- package/chunks/{chunk-DMSZ2TB3.js → chunk-ZWM3LLT7.js} +1 -1
- package/chunks/{codex-subagent-executor-DQ5LQQWO.js → codex-subagent-executor-DWWT7246.js} +1 -1
- package/chunks/{config-utils-CY6HLKZ5.js → config-utils-NGZB522W.js} +1 -1
- package/chunks/{contextCommand-SGBWI7O6.js → contextCommand-7QCW2YNX.js} +1 -1
- package/chunks/{core-runtime-4DP27LCC.js → core-runtime-PSVNDJPD.js} +1 -1
- package/chunks/{create-sub-session-ECPDZMBX.js → create-sub-session-JTSEMEJE.js} +1 -1
- package/chunks/{cron-create-OO4OG3EI.js → cron-create-VGIDTUMX.js} +1 -1
- package/chunks/{daemon-git-worktree-guard-OYDNHT7P.js → daemon-git-worktree-guard-IQRGS7IH.js} +1 -1
- package/chunks/{daemon-status-provider-JGDLXPC6.js → daemon-status-provider-R4MYCYPG.js} +1 -1
- package/chunks/{daemon-trust-policy-5HRARS54.js → daemon-trust-policy-VAUKFZ2N.js} +1 -1
- package/chunks/{daemon-trust-policy-monitor-RM7FVIIC.js → daemon-trust-policy-monitor-E5HIO6RP.js} +1 -1
- package/chunks/{deferred-core-runtime-3CXBZIOG.js → deferred-core-runtime-FLOFQJPU.js} +1 -1
- package/chunks/{edit-DJPESAAY.js → edit-OOVQUGKV.js} +1 -1
- package/chunks/{enterPlanMode-IHBLRIF3.js → enterPlanMode-AUWVTQLT.js} +1 -1
- package/chunks/{environment-JN5SD347.js → environment-RM5OXYP4.js} +1 -1
- package/chunks/{errors-NUJCME3Y.js → errors-CLDJGHVD.js} +1 -1
- package/chunks/{execution-tool-I3SWG6I3.js → execution-tool-JFBVOKPW.js} +1 -1
- package/chunks/{execution-worker-62UZMAMJ.js → execution-worker-MNJZD72W.js} +1 -1
- package/chunks/{exitPlanMode-JIC4V3FE.js → exitPlanMode-PC6XG4TW.js} +1 -1
- package/chunks/{fast-path-NIOIL5YI.js → fast-path-V4DN3CRZ.js} +1 -1
- package/chunks/{glob-EQ4QNAHF.js → glob-DTZROBDS.js} +1 -1
- package/chunks/{goal-tools-DYTTSBQG.js → goal-tools-FUVGTY33.js} +1 -1
- package/chunks/{handleAutoUpdate-44BTG5L5.js → handleAutoUpdate-U4LVTHGU.js} +1 -1
- package/chunks/{i18n-FTHZAHCT.js → i18n-XOKNDFYP.js} +1 -1
- package/chunks/{initializer-MSGKXC75.js → initializer-XBR5J4CY.js} +1 -1
- package/chunks/{installationInfo-4XJMJJYU.js → installationInfo-4AOEOUI6.js} +1 -1
- package/chunks/{interactive-mod-session-DFLRYO2Q.js → interactive-mod-session-YGZK2JK2.js} +1 -1
- package/chunks/{list-ODZ7Z6VI.js → list-TCGKVPH4.js} +1 -1
- package/chunks/{llm-O64DHKP7.js → llm-SKFTN5UN.js} +4 -4
- package/chunks/{llm-content-generator-SK24I6QS.js → llm-content-generator-GWHXT3WS.js} +1 -1
- package/chunks/{loadedSettingsAdapter-6PEBUZT5.js → loadedSettingsAdapter-ZALZGZE7.js} +1 -1
- package/chunks/{local-ED3UEKWP.js → local-RWTWYS5Z.js} +1 -1
- package/chunks/{local-execution-environment-PUKES5LO.js → local-execution-environment-R6JWLD65.js} +1 -1
- package/chunks/{loggingContentGenerator-UHOJVSRR.js → loggingContentGenerator-UJV6QFOY.js} +1 -1
- package/chunks/{loop-wakeup-NSJQETPZ.js → loop-wakeup-BU2RRYHA.js} +1 -1
- package/chunks/{manage-memory-5RRB6FLH.js → manage-memory-XI57JN4T.js} +1 -1
- package/chunks/{managed-execution-engine-MZAP7SK6.js → managed-execution-engine-BA5PABMP.js} +1 -1
- package/chunks/{managed-local-serve-XMES3HXL.js → managed-local-serve-MFKN22K6.js} +1 -1
- package/chunks/{managed-npm-update-R5KGY7G2.js → managed-npm-update-ZGN43NUA.js} +1 -1
- package/chunks/{managed-runtime-attestation-worker-O2KNHHV6.js → managed-runtime-attestation-worker-YN2VBGYN.js} +1 -1
- package/chunks/{managed-runtime-bootstrap-HOTLM6DE.js → managed-runtime-bootstrap-SGQVMUJE.js} +1 -1
- package/chunks/{managed-runtime-session-worker-QZX44ZTD.js → managed-runtime-session-worker-4UMF3VBY.js} +1 -1
- package/chunks/{managed-runtime-ssh-worker-U425WQ65.js → managed-runtime-ssh-worker-7XA6KRBN.js} +1 -1
- package/chunks/{managed-session-authority-THHDHCBP.js → managed-session-authority-IJGYAOEL.js} +1 -1
- package/chunks/{mcp-AR7EK4WY.js → mcp-V3L7B5YK.js} +1 -1
- package/chunks/{memory-C2TSF6BK.js → memory-3T6FPNAK.js} +1 -1
- package/chunks/{model-call-collection-25WR55OH.js → model-call-collection-WTTITWWM.js} +1 -1
- package/chunks/{model-configuration-KC7DQGKV.js → model-configuration-T6SSGI4J.js} +1 -1
- package/chunks/{modelConfigUtils-QEHMVLSQ.js → modelConfigUtils-TQA25QJC.js} +1 -1
- package/chunks/{monitor-PDQUZD23.js → monitor-5ZAOJSEE.js} +1 -1
- package/chunks/{nonInteractiveCli-WY2YFONU.js → nonInteractiveCli-YFINLVA7.js} +1 -1
- package/chunks/{nonInteractiveToolExecutor-7RJZYPHJ.js → nonInteractiveToolExecutor-DE3WACL5.js} +1 -1
- package/chunks/{notebook-edit-P4ITXF5H.js → notebook-edit-UK6HBRO3.js} +1 -1
- package/chunks/{omni-AYUPB2QM.js → omni-65LF5QK4.js} +1 -1
- package/chunks/{openaiContentGenerator-V5IK4ITO.js → openaiContentGenerator-HX7NCSV5.js} +1 -1
- package/chunks/{openaiResponsesContentGenerator-DYDH6KWT.js → openaiResponsesContentGenerator-CFA6U6Y5.js} +1 -1
- package/chunks/{pidfile-INPBL2DK.js → pidfile-ZVKJUNTZ.js} +1 -1
- package/chunks/{processUtils-J4UDEDS4.js → processUtils-VS6CJT7E.js} +1 -1
- package/chunks/{prompt-terminal-ledger-QLOQWHYE.js → prompt-terminal-ledger-UF5RDB57.js} +1 -1
- package/chunks/{qwenContentGenerator-RU43XKKB.js → qwenContentGenerator-GM3ZSI7E.js} +1 -1
- package/chunks/{reactive-degrade-2Q3Z3KAR.js → reactive-degrade-TSAQWZ5F.js} +1 -1
- package/chunks/{read-file-472BQ25I.js → read-file-J267NT45.js} +1 -1
- package/chunks/{resumeHistoryUtils-7SUFKZDC.js → resumeHistoryUtils-IM46VFDV.js} +1 -1
- package/chunks/{review-WX52IWJR.js → review-4B64XTCL.js} +1 -1
- package/chunks/{ripGrep-4GPGLKAM.js → ripGrep-YLOSXO7P.js} +1 -1
- package/chunks/{run-qwen-serve-MXK4RBKL.js → run-qwen-serve-SAHEC44O.js} +1 -1
- package/chunks/{runtime-WHU3AGFT.js → runtime-SJDZHV6J.js} +1 -1
- package/chunks/{sandboxConfig-7DBXEQJH.js → sandboxConfig-47EXXMUA.js} +1 -1
- package/chunks/{scheduled-tasks-O5RV6G6U.js → scheduled-tasks-E6RCTUUS.js} +1 -1
- package/chunks/{scheduler-HLMS5LR5.js → scheduler-SE3IWIWA.js} +1 -1
- package/chunks/{search-memory-PYND7ZX3.js → search-memory-2W7VJC4Q.js} +1 -1
- package/chunks/{send-message-TMLYTQOI.js → send-message-63YGQP6G.js} +1 -1
- package/chunks/{serve-EBNBRAME.js → serve-F4ML2WNL.js} +1 -1
- package/chunks/{server-63BRDBL5.js → server-S56IB4TT.js} +3 -3
- package/chunks/{session-XB6J4CZD.js → session-2CUVLZ4H.js} +1 -1
- package/chunks/{session-attachments-root-PFK475N2.js → session-attachments-root-FINBX7K5.js} +1 -1
- package/chunks/{session-execution-engine-selector-P6TJTCKR.js → session-execution-engine-selector-UGC7DGUN.js} +1 -1
- package/chunks/{session-pr-refresh-PM7VAQTV.js → session-pr-refresh-KQLQ4MZY.js} +1 -1
- package/chunks/{sessionService-PO3LLZIZ.js → sessionService-Q6N7LF7Z.js} +1 -1
- package/chunks/{settings-JDQSRXP3.js → settings-23I6H76E.js} +1 -1
- package/chunks/{shell-JCEX3HKM.js → shell-IUECEVVY.js} +1 -1
- package/chunks/{skill-JSZBONIZ.js → skill-YKUETMPC.js} +1 -1
- package/chunks/{skill-settings-YGFG6GPN.js → skill-settings-ODYXOPCA.js} +1 -1
- package/chunks/{spawnChannel-VIIWSWTL.js → spawnChannel-7XU2SRWZ.js} +1 -1
- package/chunks/{standalone-update-2UU6FQZL.js → standalone-update-SWI2RL3L.js} +1 -1
- package/chunks/{start-opentui-ui-OSZZNSLY.js → start-opentui-ui-T53QJGCH.js} +1 -1
- package/chunks/{startInteractiveUI-FFH66MYH.js → startInteractiveUI-USTZGQOE.js} +1 -1
- package/chunks/{team-create-TKGDJ3NU.js → team-create-4A2XUE3D.js} +1 -1
- package/chunks/{team-plan-approval-3VJF4G6Z.js → team-plan-approval-4TS5CYN6.js} +1 -1
- package/chunks/{terminal-image-renderer-T3VJRZGP.js → terminal-image-renderer-C7553YV6.js} +1 -1
- package/chunks/{theme-manager-ZGUFLFUI.js → theme-manager-GTW75GOO.js} +1 -1
- package/chunks/{tool-call-3EQS5KSE.js → tool-call-YTUMWL3A.js} +1 -1
- package/chunks/{tool-result-media-7LFNVQ6E.js → tool-result-media-JYOYBX4J.js} +1 -1
- package/chunks/{tool-search-UDZ4S7T5.js → tool-search-Y4XTT2WF.js} +1 -1
- package/chunks/{total-session-admission-U4MII4RA.js → total-session-admission-EMJ5NRGL.js} +1 -1
- package/chunks/{trustedFolders-2NQJCIN3.js → trustedFolders-YG6WAVRE.js} +1 -1
- package/chunks/{update-relaunch-YKLWSCLC.js → update-relaunch-4QYQRCP4.js} +1 -1
- package/chunks/{updateCheck-YDLTQQRU.js → updateCheck-VRFPSX4G.js} +1 -1
- package/chunks/{upload-config-5QQKWF4O.js → upload-config-UCKGUYYQ.js} +1 -1
- package/chunks/{useAutoAcceptIndicator-AJS4WTU2.js → useAutoAcceptIndicator-2VGLKD7B.js} +1 -1
- package/chunks/{validateNonInterActiveAuth-AETOT7ZW.js → validateNonInterActiveAuth-GGMQXKKU.js} +1 -1
- package/chunks/{version-IB6DLRAG.js → version-Y46PG7II.js} +1 -1
- package/chunks/{web-fetch-LS3QARNR.js → web-fetch-7MPU555L.js} +1 -1
- package/chunks/{web-search-FGHRIVEB.js → web-search-HU2CL2X2.js} +1 -1
- package/chunks/{workflow-FX6XNETQ.js → workflow-U3D34QQX.js} +1 -1
- package/chunks/{workflow-ancestor-trust-5XXBGN6F.js → workflow-ancestor-trust-OWC4YTMR.js} +1 -1
- package/chunks/{workspace-agents-UJKLYPUK.js → workspace-agents-KHLAWSAR.js} +1 -1
- package/chunks/{workspace-providers-status-4JOHMTAW.js → workspace-providers-status-T57SE3YX.js} +1 -1
- package/chunks/{workspace-recovery-worker-XFEYQ4TP.js → workspace-recovery-worker-VYQ723ZE.js} +1 -1
- package/chunks/{workspace-registration-store-LWAPVNYC.js → workspace-registration-store-I7PR3A2Y.js} +1 -1
- package/chunks/{workspace-registry-M7OC376O.js → workspace-registry-YYUBXCLH.js} +1 -1
- package/chunks/{workspace-runtime-coordinator-CYHIL47L.js → workspace-runtime-coordinator-5ICAQO7W.js} +1 -1
- package/chunks/{workspace-service-43VZZ56B.js → workspace-service-YROWXOLQ.js} +1 -1
- package/chunks/{workspace-skills-status-V2TT6UJQ.js → workspace-skills-status-DKKQDTZJ.js} +1 -1
- package/chunks/{workspace-trust-reconciler-YZ4AG5ZW.js → workspace-trust-reconciler-3FPMUZDO.js} +1 -1
- package/chunks/{write-file-TGEH5MEZ.js → write-file-7QQVYFDT.js} +1 -1
- package/chunks/{zoom-image-TT6R7H2H.js → zoom-image-WL5EB6Q7.js} +1 -1
- package/cli.js +2 -2
- package/execution-worker.js +1 -1
- package/export-transcript-document.js +1 -1
- package/package.json +3 -3
- package/web-shell/assets/{PierreFilePreview-OsApm5-S.js → PierreFilePreview-BZ17f56_.js} +1 -1
- package/web-shell/assets/{SpreadsheetPreview-I1v1EzV7.js → SpreadsheetPreview-Bvkvr_5u.js} +1 -1
- package/web-shell/assets/{WorkspaceFileBrowser-BO6aug7i.js → WorkspaceFileBrowser-BJ_I4Uoz.js} +1 -1
- package/web-shell/assets/{abnfDiagram-VCTEODGH-DxuLMyN0.js → abnfDiagram-VCTEODGH-iuaBM15V.js} +1 -1
- package/web-shell/assets/{agents-route-CSJf6QPO.js → agents-route-CycwfNSC.js} +1 -1
- package/web-shell/assets/{arc-3--LekYQ.js → arc-C0lt8n55.js} +1 -1
- package/web-shell/assets/{architectureDiagram-5GKGNRK7-Dihq4uto.js → architectureDiagram-5GKGNRK7-Bw326d-A.js} +1 -1
- package/web-shell/assets/{blockDiagram-NRAW4CY4-BnaRPM2o.js → blockDiagram-NRAW4CY4-CHtFgBjV.js} +1 -1
- package/web-shell/assets/{c4Diagram-UCG6FXSJ-BtC94eMa.js → c4Diagram-UCG6FXSJ-Bx66oJT9.js} +1 -1
- package/web-shell/assets/channel-CRJuO00u.js +1 -0
- package/web-shell/assets/{chunk-2Q5K7J3B-2ZTXWP6M.js → chunk-2Q5K7J3B-BIshvfa_.js} +1 -1
- package/web-shell/assets/{chunk-5VM5RSS4-DBh7DP1F.js → chunk-5VM5RSS4-BZeRS6uD.js} +1 -1
- package/web-shell/assets/{chunk-F27PBJKO-xzqbWXBw.js → chunk-F27PBJKO-El-CGY2R.js} +1 -1
- package/web-shell/assets/{chunk-G27WJ6UU-DxnCrpxK.js → chunk-G27WJ6UU-DO8ZfQL_.js} +1 -1
- package/web-shell/assets/{chunk-JWPE2WC7-BPjRsozm.js → chunk-JWPE2WC7-yYFrrKAj.js} +1 -1
- package/web-shell/assets/{chunk-LCL6LL3I-Q2HgB3lf.js → chunk-LCL6LL3I-BFGuOKN0.js} +1 -1
- package/web-shell/assets/{chunk-POPQ4Y6H-9tlPaKu-.js → chunk-POPQ4Y6H-GRHK6sdV.js} +1 -1
- package/web-shell/assets/{chunk-SVP7TREG-DkNdOHCU.js → chunk-SVP7TREG-DwDu6GqZ.js} +1 -1
- package/web-shell/assets/{chunk-XXDRQBXY-D0G-Dhfi.js → chunk-XXDRQBXY-RoNDjkIy.js} +1 -1
- package/web-shell/assets/classDiagram-DTDB5LWJ-pPPByLA7.js +1 -0
- package/web-shell/assets/classDiagram-v2-JRS7N3AN-pPPByLA7.js +1 -0
- package/web-shell/assets/{cose-bilkent-JH36ORCC-Ck0tHxul.js → cose-bilkent-JH36ORCC-CYNiiONE.js} +1 -1
- package/web-shell/assets/{cynefin-OW5HDTMX-a4-NTMHi.js → cynefin-OW5HDTMX-DC1_lDIG.js} +1 -1
- package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-Pg41Zbf2.js → cynefinDiagram-5FMLGOSQ-D2VxKm2n.js} +1 -1
- package/web-shell/assets/{dagre-3AP2YEHR-DT_ZmqkF.js → dagre-3AP2YEHR-C4_BHzpM.js} +1 -1
- package/web-shell/assets/{diagram-S7CK7UJ4-hapdMOl1.js → diagram-S7CK7UJ4-BpAO4-Gv.js} +1 -1
- package/web-shell/assets/{diagram-UQ7AKVKN-YZ0nbk56.js → diagram-UQ7AKVKN-DqUsFdsX.js} +1 -1
- package/web-shell/assets/{diagram-VSXAHHWV-DA_yNbWy.js → diagram-VSXAHHWV-DcMXIYMy.js} +1 -1
- package/web-shell/assets/{diagram-VX7I27RA-DoULuCLT.js → diagram-VX7I27RA-I3nr09ex.js} +1 -1
- package/web-shell/assets/{diagram-Z3DM3KII-B5c9o9zL.js → diagram-Z3DM3KII-CN-gvsTo.js} +1 -1
- package/web-shell/assets/{docx-preview-BulxdBjs.js → docx-preview-31J6RsS0.js} +1 -1
- package/web-shell/assets/{ebnfDiagram-PWID7BFC-B5hgIg3m.js → ebnfDiagram-PWID7BFC-DOQvLWlM.js} +1 -1
- package/web-shell/assets/{erDiagram-SSCWMZ5O-BEfEPozi.js → erDiagram-SSCWMZ5O-Cb5ijFZh.js} +1 -1
- package/web-shell/assets/{flowDiagram-A5DVABFB-CQHNk92v.js → flowDiagram-A5DVABFB-BecqqjnZ.js} +1 -1
- package/web-shell/assets/{ganttDiagram-EL5Y4UJY-BabdVgIM.js → ganttDiagram-EL5Y4UJY-DWY5vzQl.js} +1 -1
- package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-ujRZBFUo.js → gitGraphDiagram-WWUBYQGX-DqBnsZmZ.js} +1 -1
- package/web-shell/assets/{index-B9uXebIR.js → index-DDmiUW3b.js} +6 -6
- package/web-shell/assets/{index-DSZXdZnu.js → index-DabH7kHA.js} +1 -1
- package/web-shell/assets/{infoDiagram-RXCK75RN-CUHj9jJC.js → infoDiagram-RXCK75RN-MlotyOdT.js} +1 -1
- package/web-shell/assets/{ishikawaDiagram-5VMMS53U-CulW_q81.js → ishikawaDiagram-5VMMS53U-Daq_85C7.js} +1 -1
- package/web-shell/assets/{journeyDiagram-EYS64GPL-BR46CvRQ.js → journeyDiagram-EYS64GPL-OipivCxL.js} +1 -1
- package/web-shell/assets/{kanban-definition-3QL26DDD-HAoUqzFy.js → kanban-definition-3QL26DDD-zqaz7dLu.js} +1 -1
- package/web-shell/assets/{layout-DYLl7fyA.js → layout-Bi3msQMQ.js} +1 -1
- package/web-shell/assets/{linear-DPXABjDZ.js → linear-D4gPORvD.js} +1 -1
- package/web-shell/assets/{mermaid.core-Bi30Gi0n.js → mermaid.core-BUnytF7a.js} +6 -6
- package/web-shell/assets/{mindmap-definition-FBJOCRG2-B1_lUq4o.js → mindmap-definition-FBJOCRG2-B_X4iChu.js} +1 -1
- package/web-shell/assets/{pegDiagram-XKGWAZYB-Cy8tjJJC.js → pegDiagram-XKGWAZYB-z4wYBoBW.js} +1 -1
- package/web-shell/assets/{pieDiagram-E7YTZNPT-D6waLVVi.js → pieDiagram-E7YTZNPT-Dvyg6FYo.js} +1 -1
- package/web-shell/assets/{quadrantDiagram-AXDQQJYC--6ehi_FI.js → quadrantDiagram-AXDQQJYC-CJBWU2Dk.js} +1 -1
- package/web-shell/assets/{railroadDiagram-O6MQD6OU-BhLy40X4.js → railroadDiagram-O6MQD6OU-Dl_An1O0.js} +1 -1
- package/web-shell/assets/{requirementDiagram-EFPCY7ZU-BVNXTgNP.js → requirementDiagram-EFPCY7ZU-Tw8FwaYU.js} +1 -1
- package/web-shell/assets/{sankeyDiagram-P5KCCOFB-BHgTytxV.js → sankeyDiagram-P5KCCOFB-BCPCkbR0.js} +1 -1
- package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-CgOsTvhu.js → sequenceDiagram-WJ2MYXX4-DDj7uFTG.js} +1 -1
- package/web-shell/assets/{sizeCapture-X5ZJPWSS-vCQBQ5FI.js → sizeCapture-X5ZJPWSS-B9eVSpKb.js} +1 -1
- package/web-shell/assets/{stateDiagram-HBIQ2CUA-DytMYRWJ.js → stateDiagram-HBIQ2CUA-Bf4BZP_V.js} +1 -1
- package/web-shell/assets/stateDiagram-v2-4QOOHH4V-BPJi6Gre.js +1 -0
- package/web-shell/assets/{swimlanes-XN3QIQJK-CTGnifOP.js → swimlanes-XN3QIQJK-dyTWsZFj.js} +1 -1
- package/web-shell/assets/swimlanesDiagram-VK2B7HYN-Bw4NRtJQ.js +8 -0
- package/web-shell/assets/{timeline-definition-24CTP7MA-DEJ1cbn2.js → timeline-definition-24CTP7MA-DVl1A4uL.js} +1 -1
- package/web-shell/assets/{vennDiagram-4TSXK5OY-K1e4SjS0.js → vennDiagram-4TSXK5OY-Boosxy9D.js} +1 -1
- package/web-shell/assets/{wardleyDiagram-VM6X3IG4-DEX-GkRp.js → wardleyDiagram-VM6X3IG4-C6wlY8jy.js} +1 -1
- package/web-shell/assets/{xychartDiagram-S5SC5T6Z-B6wYXreH.js → xychartDiagram-S5SC5T6Z-CkzZe3ro.js} +1 -1
- package/web-shell/index.html +1 -1
- package/web-shell/sw.js +1 -1
- package/web-shell/assets/channel-CLVrtVFX.js +0 -1
- package/web-shell/assets/classDiagram-DTDB5LWJ-Df2T70oB.js +0 -1
- package/web-shell/assets/classDiagram-v2-JRS7N3AN-Df2T70oB.js +0 -1
- package/web-shell/assets/stateDiagram-v2-4QOOHH4V-CcjUJGng.js +0 -1
- package/web-shell/assets/swimlanesDiagram-VK2B7HYN-Dt8NvQfX.js +0 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{MAX_DROPPED_MSG_IDS,MAX_FRAME_BYTES,MAX_RETAINED_REPLY_TOKEN_CHARS,MAX_SENDER_KEY_CHARS,MAX_SOCKET_PATH_BYTES,SOCKET_DIR_NAME,isLocalIpcPath,parsePeerAuthLine,parsePeerFrame,peerSenderKey,probePeerSocketVerdict,resolvePeerSocketCandidates}from"./chunk-MKH3EH7O.js";import{scanForSecrets}from"./chunk-AKWYMQKU.js";import{collectPtyProcessTree}from"./chunk-PGRN3GZY.js";import{BudgetExhaustedError,IDE_DEFINITIONS,MCP_BUDGET_REARM_FRACTION,MCP_BUDGET_WARN_FRACTION,McpClient,ORPHAN_TOOL_USE_REPAIR_REASON,POOLED_TRANSPORTS_DEFAULT,QWEN_CODE_COMPANION_EXTENSION_NAME,SessionService,StandardFileSystemService,aggregateUsage,buildSessionHistoryFromConversation,buildSyntheticToolResponseParts,classifyShellCommandSafety,classifyShellCommandSafetyInDirectory,coerceMcpFilterEntries,connectionIdOf,convertToFunctionErrorResponse,convertToFunctionResponse,createForkedChat,detectTurnInterruption,discoveryTimeoutFor,estimateContentTokens,evaluateToolInvocationGuard,finalizeToolResponses,getCacheSafeParams,getCacheSafeParamsSessionId,getTimeRangeBounds,isClearedMediaPlaceholder,isPoolable,listDescendantPids,listExistingSkillDirNames,loadUsageHistoryWithLive,mcpSessionMetadataKey,mcpTransportOf,normalizeMcpIncludeEntry,observeToolResultBoundary,parseConnectionId,recursivelyHydrateStrings,repairOrphanedToolUseTurns,runForkedAgent,runWithForkedChatModel,runWithTimeout,sigtermPids,stripToolResultImages,toolResultBoundaryArtifact,toolResultPartDiagnosticValues,withoutAutoMemorySnapshots}from"./chunk-LIIMQ4DI.js";import{shellResultText}from"./chunk-T7CHK6C2.js";import{runGit,runGitCapture,streamGitRecords}from"./chunk-ILECDNJX.js";import{hasVerifiableInode,openNoFollow,openSyncNoFollow}from"./chunk-QXQGUM3Y.js";import{projectUserTranscriptForDisplay}from"./chunk-DBA3F3D7.js";import{toolSearchBridgeSentence}from"./chunk-4WFGJVTF.js";import{flattenPeerLabel}from"./chunk-BYU42MLK.js";import{isPidAlive}from"./chunk-5LZ2DPLH.js";import{getProjectSkillsRoot}from"./chunk-XQJOZDV7.js";import{parse}from"./chunk-KLC3OD2M.js";import{glob,globSync}from"./chunk-OBOU4ZZM.js";import{isDeferredToolBridgeAvailable}from"./chunk-QX4PIAJI.js";import{require_picomatch}from"./chunk-TDHEAGDX.js";import{BUILT_IN_OUTPUT_STYLES,getBuiltInOutputStyle}from"./chunk-OV3EBH6J.js";import{NO_EXEC_CONFIG}from"./chunk-EBMCWXGZ.js";import{require_proper_lockfile}from"./chunk-YIW3H46P.js";import{disposeConoutWorker,loadPty,loadXtermHeadless,noteConPtyHostReleased,releaseConPtyHost}from"./chunk-CQCSNHPU.js";import{stripAnsi}from"./chunk-YGLM5XPP.js";import{resolveBundleDir}from"./chunk-4NPYOXJO.js";import{escapeJsonTagCharacters}from"./chunk-NTRFETZB.js";import{fetchWithPolicy}from"./chunk-OZGM5CCE.js";import{getModelsForProviderProtocol,tryResolveModelProtocol}from"./chunk-OVPEAKOQ.js";import{COMBINED_PASS_TOLERANCE_FACTOR,TOOL_OUTPUT_TRUNCATED_PREFIX,TRUNCATION_FALLBACK_ENVELOPE_SLACK,addMCPStatusChangeListener,removeMCPStatusChangeListener,updateMCPServerStatus}from"./chunk-TNCN2JX2.js";import{E_TIMEOUT,Mutex,withTimeout}from"./chunk-HDGTWJ24.js";import{runSideQuery}from"./chunk-K7JCVESI.js";import{MEMORY_SECTION_HEADER,VISION_BRIDGE_MAX_IMAGES,VISION_BRIDGE_MAX_IMAGE_BASE64_BYTES,detectFileType,getCurrentMemoryFilename,isCacheableReadResult,isWithinRoot,processSingleFileContent}from"./chunk-Y6HHV4LC.js";import{getInvocationContext}from"./chunk-SLD7H2FA.js";import{DEFAULT_IMAGE_TOKEN_ESTIMATE,estimatePartChars}from"./chunk-Q6UAOTP3.js";import{atomicWriteFile,atomicWriteJSON}from"./chunk-BMHYEQTI.js";import{isBinary,normalizeContent,stripAnsiAndControl,stripHtmlComments}from"./chunk-4YLXNRRH.js";import{AUTO_MEMORY_SNAPSHOT_METADATA,SYSTEM_REMINDER_CLOSE,SYSTEM_REMINDER_OPEN,cloneApiHistory,getFolderStructure,getStartupContextLength,isSystemReminderContent,stripSystemReminderBlocks}from"./chunk-B3ZFUGTC.js";import{getQwenIgnoreFileNames,require_ignore}from"./chunk-5DTFN37U.js";import{ToolNames,canonicalToolName}from"./chunk-SBZFGYYS.js";import{createDebugLogger}from"./chunk-JAUJI56S.js";import{Storage}from"./chunk-EPODBRBP.js";import{PATH_ARG_KEYS,QWEN_DIR,tildeifyPath,unescapePath}from"./chunk-OKN3Z5C5.js";import{getErrorMessage,isAbortError,isNodeError}from"./chunk-XYB7GC5U.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name,__require,__toESM}from"./chunk-KBWJGX7I.js";init_esbuild_shims();var JsonFormatter=class{static{__name(this,"JsonFormatter")}format(response,stats,error){const output={};if(response!==void 0){output.response=stripAnsi(response)}if(stats){output.stats=stats}if(error){output.error=error}return JSON.stringify(output,null,2)}formatError(error,code){const jsonError={type:error.constructor.name,message:stripAnsi(error.message),...code&&{code}};return this.format(void 0,void 0,jsonError)}};init_esbuild_shims();function createPlanId(sessionId,historyLength){return`${sessionId}:${historyLength}`}__name(createPlanId,"createPlanId");function buildVisibleNotice(kind,repairs,historyGaps){if(kind==="clean"){return void 0}if(kind==="degraded_history"){return`Resumed session history is incomplete: detected ${historyGaps.length} missing parent link(s). Automatic continuation is disabled for this recovery.`}if(kind==="interrupted_prompt"){return"Previous session appears to have stopped after user input before the model completed a response."}const synthesized=repairs.filter(repair=>repair.type==="synthesized_tool_result").length;if(synthesized>0){return`Previous session appears to have stopped during tool execution. Synthesized ${synthesized} failed tool result(s) so the history can continue safely.`}return"Previous session appears to have stopped during tool execution."}__name(buildVisibleNotice,"buildVisibleNotice");function buildSessionRecoveryPlan({sessionId,conversation,historyGaps,options}){return buildSessionRecoveryPlanFromApiHistory({sessionId,...buildSessionHistoryFromConversation(conversation),historyGaps,options})}__name(buildSessionRecoveryPlan,"buildSessionRecoveryPlan");function buildSessionRecoveryPlanFromApiHistory({sessionId,apiHistory:inputApiHistory,completedToolCallIds,trailingSystemNotifications,historyGaps,options}){const originalApiHistory=inputApiHistory;const gaps=historyGaps??[];const planId=createPlanId(sessionId,originalApiHistory.length);const apiHistory=cloneApiHistory(originalApiHistory);const repairResult=repairOrphanedToolUseTurns(apiHistory);const repairs=[...repairResult.injected.map(repair=>({type:"synthesized_tool_result",callId:repair.callId,name:repair.name})),...repairResult.droppedDuplicates.map(repair=>({type:"dropped_duplicate_tool_result",callId:repair.callId,name:repair.name})),...gaps.map(gap=>({type:"history_gap",childUuid:gap.childUuid,missingParentUuid:gap.missingParentUuid}))];if(gaps.length>0){return{planId,sessionId,kind:"degraded_history",originalApiHistory,apiHistory,repairs,canContinue:false,canAutoContinue:false,requiresUserConfirmation:true,visibleNotice:buildVisibleNotice("degraded_history",repairs,gaps)}}const interruption=detectTurnInterruption(originalApiHistory,completedToolCallIds,trailingSystemNotifications);if(interruption.kind==="none"){return{planId,sessionId,kind:"clean",originalApiHistory,apiHistory,repairs,canContinue:false,canAutoContinue:false,requiresUserConfirmation:false}}if(interruption.kind==="interrupted_prompt"){const continuation2={mode:"retry_user_parts",parts:interruption.parts,displayText:"Continue interrupted user prompt"};return{planId,sessionId,kind:"interrupted_prompt",originalApiHistory,apiHistory,repairs,canContinue:true,canAutoContinue:options?.allowAutoContinue===true,requiresUserConfirmation:options?.allowAutoContinue!==true,visibleNotice:buildVisibleNotice("interrupted_prompt",repairs,gaps),continuation:continuation2}}const continuation={mode:"tool_result_parts",parts:buildSyntheticToolResponseParts(interruption.danglingCalls,ORPHAN_TOOL_USE_REPAIR_REASON),displayText:"Continue interrupted tool turn"};return{planId,sessionId,kind:"interrupted_turn",originalApiHistory,apiHistory,repairs,canContinue:true,canAutoContinue:false,requiresUserConfirmation:true,visibleNotice:buildVisibleNotice("interrupted_turn",repairs,gaps),continuation}}__name(buildSessionRecoveryPlanFromApiHistory,"buildSessionRecoveryPlanFromApiHistory");init_esbuild_shims();init_esbuild_shims();import{EventEmitter}from"node:events";init_esbuild_shims();var debugLogger=createDebugLogger("McpPool:Entry");function defaultPoolEntryOptions(transport){const isRemote=transport==="http"||transport==="sse"||transport==="websocket";return{drainDelayMs:3e4,maxIdleMs:5*6e4,maxReconnectAttempts:isRemote?5:3,reconnectStrategy:isRemote?{kind:"exponential",baseMs:1e3,capMs:16e3}:{kind:"fixed",delayMs:5e3}}}__name(defaultPoolEntryOptions,"defaultPoolEntryOptions");var PoolEntry=class{constructor(id,serverName,entryIndex,cfg,client,cliConfig,opts,onClosed,aggregateStatusByName){this.id=id;this.serverName=serverName;this.entryIndex=entryIndex;this.cfg=cfg;this.client=client;this.cliConfig=cliConfig;this.opts=opts;this.onClosed=onClosed;this.aggregateStatusByName=aggregateStatusByName;this.transportId=connectionIdOf(serverName,cfg);this.emitter.setMaxListeners(0);this.statusChangeListener=(name,status)=>{if(name!==this.serverName)return;if(status===void 0)return;if(this.suppressNextStatusEcho){this.suppressNextStatusEcho=false;return}if(this.client.getStatus()!==status)return;if(status===this.localStatus)return;this.localStatus=status;if(status==="disconnected"&&(this.state==="active"||this.state==="draining")&&!this.restartInProgress){const wasDraining=this.state==="draining";this.state="failed";if(wasDraining){this.cancelDrainTimer()}if(this.maxIdleTimer){clearTimeout(this.maxIdleTimer);this.maxIdleTimer=void 0}if(this.statusChangeListener){removeMCPStatusChangeListener(this.statusChangeListener);this.statusChangeListener=void 0}debugLogger.error(`PoolEntry ${this.id} silent transport drop (prev state='${wasDraining?"draining":"active"}', localStatus\u2192DISCONNECTED). Transitioning to 'failed'; evicting from pool.entries + pooledConnections (W122 R20).`);const upstreamError=this.client.getLastTransportError();this.emit({kind:"failed",serverName:this.serverName,generation:this._generation,lastError:upstreamError?`transport disconnected (silent transport drop): ${upstreamError.message}`:"transport disconnected (silent transport drop)"});for(const[sid]of[...this.subscribers]){this.detach(sid)}void this.sweepAndDisconnect("silent_drop").then(result=>{const partialSignal=result.descendantsFound!==void 0&&result.descendantsSignaled!==void 0&&result.descendantsSignaled<result.descendantsFound;if(result.pidSweepError!==void 0||partialSignal){debugLogger.warn(`PoolEntry ${this.id} silent-drop sweep observability: descendantsFound=${result.descendantsFound??"unknown"}, descendantsSignaled=${result.descendantsSignaled??"unknown"}, pidSweepError=${result.pidSweepError?.message??"none"}. Possible orphan-process pressure \u2014 operator should check for lingering subprocess descendants of the dead transport.`)}this.updateGlobalStatus()},()=>{this.updateGlobalStatus()});this.updateGlobalStatus();this.onClosed(this.id)}};addMCPStatusChangeListener(this.statusChangeListener)}static{__name(this,"PoolEntry")}localStatus="connecting";state="spawning";_generation=0;refs=new Set;subscribers=new Map;subscriberHandles=new Map;toolsSnapshot=[];promptsSnapshot=[];resourcesSnapshot=[];drainTimer;maxIdleTimer;firstIdleAt;restartInFlight;restartInProgress=false;emitter=new EventEmitter;statusChangeListener;suppressNextStatusEcho=false;transportId;get generation(){return this._generation}get currentState(){return this.state}get transportKind(){return mcpTransportOf(this.cfg)}isTerminated(){return this.state==="closed"||this.state==="failed"}markActive(initialTools,initialPrompts,initialResources){if(this.state==="closed"||this.state==="failed")return;this.toolsSnapshot=initialTools;this.promptsSnapshot=initialPrompts;this.resourcesSnapshot=initialResources;this.state="active";this.localStatus="connected";this.updateGlobalStatus()}attach(sessionId,view,opts){if(this.state==="closed"||this.state==="failed"){throw new Error(`Cannot attach to PoolEntry ${this.id} in state ${this.state}`)}const previousState=this.state;const hadRef=this.refs.has(sessionId);const previousView=this.subscribers.get(sessionId);const previousHandle=this.subscriberHandles.get(sessionId);this.refs.add(sessionId);this.subscribers.set(sessionId,view);this.cancelDrainTimer();if(this.state==="draining")this.state="active";if(this.state==="active"&&opts?.skipReplay!==true){try{view.applyTools(this.toolsSnapshot);view.applyPrompts(this.promptsSnapshot);view.applyResources(this.resourcesSnapshot)}catch(err){if(!hadRef){this.refs.delete(sessionId);this.subscribers.delete(sessionId);this.subscriberHandles.delete(sessionId);try{view.teardown()}catch{}}else if(previousView){this.subscribers.set(sessionId,previousView);if(previousHandle){this.subscriberHandles.set(sessionId,previousHandle)}}if(previousState==="draining"&&this.refs.size===0){this.startDrainTimer(this.opts.drainDelayMs)}else{this.state=previousState}debugLogger.error(`Snapshot replay failed for ${sessionId}/${this.serverName}: ${String(err)}`);throw err}}const handle=new PooledConnectionImpl(this,sessionId,opts?.release);this.subscriberHandles.set(sessionId,handle);return handle}updateSessionConfig(sessionId,cfg){if(this.isTerminated()){throw new Error(`Cannot update config on PoolEntry ${this.id} in state ${this.state}`)}const view=this.subscribers.get(sessionId);if(!view){throw new Error(`Cannot update config for detached session ${sessionId} on PoolEntry ${this.id}`)}if(!view.updateConfig(cfg))return;if(this.state==="active"){view.applyTools(this.toolsSnapshot);view.applyPrompts(this.promptsSnapshot);view.applyResources(this.resourcesSnapshot)}}detach(sessionId){const view=this.subscribers.get(sessionId);if(view){try{view.teardown()}catch(err){debugLogger.error(`View teardown failed for ${sessionId}/${this.serverName}: ${String(err)}`)}}this.subscribers.delete(sessionId);this.subscriberHandles.delete(sessionId);this.refs.delete(sessionId)}startDrainTimer(delayMs){this.cancelDrainTimer();this.state="draining";if(this.firstIdleAt===void 0){this.firstIdleAt=Date.now();this.maxIdleTimer=setTimeout(()=>{if(this.refs.size>0){debugLogger.debug(`PoolEntry ${this.id} max-idle reached but ${this.refs.size} sessions active; deferring close, resetting first-idle window`);this.maxIdleTimer=void 0;this.firstIdleAt=void 0;return}debugLogger.warn(`PoolEntry ${this.id} hit MAX_IDLE_MS (${this.opts.maxIdleMs}ms); force-closing`);void this.forceShutdown("max_idle")},this.opts.maxIdleMs);this.maxIdleTimer.unref?.()}this.drainTimer=setTimeout(()=>{void this.forceShutdown("drain_timer")},delayMs);this.drainTimer.unref?.()}cancelDrainTimer(){if(this.drainTimer){clearTimeout(this.drainTimer);this.drainTimer=void 0}}async forceShutdown(reason){if(this.state==="closed"||this.state==="failed")return;this.state="closed";this.localStatus="disconnected";this.suppressNextStatusEcho=true;this.cancelDrainTimer();if(this.maxIdleTimer){clearTimeout(this.maxIdleTimer);this.maxIdleTimer=void 0}if(this.statusChangeListener){removeMCPStatusChangeListener(this.statusChangeListener);this.statusChangeListener=void 0}this.emit({kind:"disconnected",serverName:this.serverName,generation:this._generation,reason:"transport_closed"});for(const[sid]of this.subscribers){this.detach(sid)}await this.sweepAndDisconnect(reason);this.updateGlobalStatus();this.onClosed(this.id)}async sweepAndDisconnect(reason){const result={};try{const rootPid=this.client.getTransportPid?.();if(rootPid!==void 0){const descendants=await listDescendantPids(rootPid);if(descendants.length>0){result.descendantsFound=descendants.length;result.descendantsSignaled=sigtermPids(descendants);debugLogger.debug(`Sent SIGTERM to ${result.descendantsSignaled}/${descendants.length} descendants of pid ${rootPid} for ${this.id} (${reason})`)}}}catch(err){result.pidSweepError=err instanceof Error?err:new Error(String(err));debugLogger.warn(`Descendant pid sweep failed for ${this.id} (${reason}): ${String(err)}. Proceeding with disconnect.`)}try{await this.client.disconnect()}catch(err){debugLogger.error(`client.disconnect failed for ${this.id} (${reason}): ${String(err)}`)}return result}async restart(){if(this.restartInFlight)return this.restartInFlight;this.restartInFlight=this.doRestart().finally(()=>{this.restartInFlight=void 0});return this.restartInFlight}async doRestart(){if(this.state==="closed"||this.state==="failed"){throw new Error(`Cannot restart PoolEntry ${this.id} in state ${this.state}`)}this.restartInProgress=true;try{return await this.doRestartInner()}finally{this.restartInProgress=false}}async doRestartInner(){this.cancelDrainTimer();if(this.maxIdleTimer){clearTimeout(this.maxIdleTimer);this.maxIdleTimer=void 0}this.firstIdleAt=void 0;if(this.state==="draining"){this.state="active"}const oldGen=this._generation;this._generation+=1;this.emit({kind:"disconnected",serverName:this.serverName,generation:oldGen,reason:"restart"});await this.sweepAndDisconnect("restart");let snap;try{const timeoutMs=discoveryTimeoutFor(this.cfg);snap=await runWithTimeout((async()=>{await this.client.connect();return this.client.discoverAndReturn(this.cliConfig,{applyConfigFilters:false})})(),timeoutMs,`pool restart for ${this.id} (pool will roll back the restart and free its budget slot)`)}catch(err){debugLogger.error(`Restart of ${this.id} failed at connect/discover: ${String(err)}. Transitioning to 'failed'.`);await this.sweepAndDisconnect("restart_failed");this.state="failed";this.localStatus="disconnected";this.suppressNextStatusEcho=true;this.updateGlobalStatus();if(this.statusChangeListener){removeMCPStatusChangeListener(this.statusChangeListener);this.statusChangeListener=void 0}this.emit({kind:"failed",serverName:this.serverName,generation:this._generation,lastError:err instanceof Error?err.message:String(err)});for(const[sid]of this.subscribers){this.detach(sid)}this.onClosed(this.id);throw err}if(oldGen+1!==this._generation){await this.sweepAndDisconnect("restart_superseded");throw new Error(`Restart of ${this.id} superseded by newer generation; discarded stale snapshot + swept new transport.`)}const currentState=this.state;if(currentState==="closed"||currentState==="failed"){await this.sweepAndDisconnect("restart_superseded");throw new Error(`Restart of ${this.id} aborted: entry state is ${currentState} (forceShutdown ran concurrently mid-restart). Snapshot discarded; new transport swept.`)}this.toolsSnapshot=snap.tools;this.promptsSnapshot=snap.prompts;if(snap.resources.length>0){this.resourcesSnapshot=snap.resources}for(const[sid,view]of this.subscribers){try{view.applyTools(this.toolsSnapshot);view.applyPrompts(this.promptsSnapshot);view.applyResources(this.resourcesSnapshot)}catch(err){debugLogger.error(`Restart fan-out to view ${sid}/${this.serverName} failed: ${String(err)}`)}}this.localStatus="connected";this.suppressNextStatusEcho=true;this.updateGlobalStatus();this.emit({kind:"reconnected",serverName:this.serverName,generation:this._generation});this.emit({kind:"toolsChanged",serverName:this.serverName,snapshot:this.toolsSnapshot,generation:this._generation});this.emit({kind:"promptsChanged",serverName:this.serverName,snapshot:this.promptsSnapshot,generation:this._generation});this.emit({kind:"resourcesChanged",serverName:this.serverName,snapshot:this.resourcesSnapshot,generation:this._generation})}emit(event){const listeners=this.emitter.listeners("event");for(const listener of listeners){try{listener(event)}catch(err){debugLogger.error(`PoolEntry listener error for ${this.id} (event.kind=${event.kind}): ${err instanceof Error?err.message:String(err)}`)}}}internalOn(listener){this.emitter.on("event",listener)}internalOff(listener){this.emitter.off("event",listener)}updateGlobalStatus(){const aggregated=this.aggregateStatusByName(this.serverName);updateMCPServerStatus(this.serverName,aggregated)}getLocalStatus(){return this.localStatus}};var PooledConnectionImpl=class{constructor(entry,sessionId,releaseCallback){this.entry=entry;this.sessionId=sessionId;this.releaseCallback=releaseCallback}static{__name(this,"PooledConnectionImpl")}listeners=new Set;released=false;get id(){return this.entry.id}get transportId(){return this.entry.transportId}get serverName(){return this.entry.serverName}get entryIndex(){return this.entry.entryIndex}get client(){return this.entry.client}get toolsSnapshot(){return this.entry.toolsSnapshot}get promptsSnapshot(){return this.entry.promptsSnapshot}get resourcesSnapshot(){return this.entry.resourcesSnapshot}updateConfig(cfg){if(this.released){throw new Error(`Cannot update config on released MCP connection ${this.id}`)}this.entry.updateSessionConfig(this.sessionId,cfg)}on(event,listener){if(event!=="event")return this;if(this.listeners.has(listener))return this;this.listeners.add(listener);this.entry.internalOn(listener);return this}off(event,listener){if(event!=="event")return this;this.listeners.delete(listener);this.entry.internalOff(listener);return this}release(){if(this.released)return;this.released=true;for(const l of this.listeners){this.entry.internalOff(l)}this.listeners.clear();this.releaseCallback?.()}};init_esbuild_shims();var debugLogger2=createDebugLogger("McpPool:View");function compileNameFilter(includeTools,excludeTools){return{excludeSet:excludeTools?new Set(coerceMcpFilterEntries(excludeTools)):void 0,includeSet:includeTools!=null?new Set(coerceMcpFilterEntries(includeTools).map(normalizeMcpIncludeEntry)):void 0}}__name(compileNameFilter,"compileNameFilter");function compiledFilterAccepts(filter2,name){if(filter2.excludeSet?.has(name))return false;if(!filter2.includeSet)return true;return filter2.includeSet.has(name)}__name(compiledFilterAccepts,"compiledFilterAccepts");var SessionMcpView=class{constructor(sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry,sessionId,serverName,cfg){this.sessionToolRegistry=sessionToolRegistry;this.sessionPromptRegistry=sessionPromptRegistry;this.sessionResourceRegistry=sessionResourceRegistry;this.sessionId=sessionId;this.serverName=serverName;this.cfg=cfg;this.metadataKey=mcpSessionMetadataKey(cfg)}static{__name(this,"SessionMcpView")}metadataKey;applyTools(snapshot){this.sessionToolRegistry.removeMcpToolsByServer(this.serverName);const filter2=compileNameFilter(this.cfg.includeTools,this.cfg.excludeTools);let registered=0;for(const tool of snapshot){if(!compiledFilterAccepts(filter2,tool.serverToolName)){continue}const sessionTool=tool.withSessionConfig(this.cfg.trust,this.cfg.alwaysLoadTools===true);try{this.sessionToolRegistry.registerTool(sessionTool);registered+=1}catch(err){debugLogger2.error(`SessionMcpView[${this.sessionId}/${this.serverName}] failed to register tool ${tool.serverToolName}: ${String(err instanceof Error?err.message:err)}`)}}debugLogger2.debug(`SessionMcpView[${this.sessionId}/${this.serverName}] applied ${snapshot.length} tools (filtered to ${registered} registered)`)}applyPrompts(snapshot){this.sessionPromptRegistry.removePromptsByServer(this.serverName);const filter2=compileNameFilter(this.cfg.includeTools,this.cfg.excludeTools);let registered=0;for(const prompt of snapshot){if(!compiledFilterAccepts(filter2,prompt.name)){continue}try{this.sessionPromptRegistry.registerPrompt(prompt);registered+=1}catch(err){debugLogger2.error(`SessionMcpView[${this.sessionId}/${this.serverName}] failed to register prompt ${prompt.name}: ${String(err instanceof Error?err.message:err)}`)}}debugLogger2.debug(`SessionMcpView[${this.sessionId}/${this.serverName}] applied ${snapshot.length} prompts (filtered to ${registered} registered)`)}applyResources(snapshot){if(snapshot.length===0){return}this.sessionResourceRegistry.removeResourcesByServer(this.serverName);for(const resource of snapshot){try{this.sessionResourceRegistry.registerResource(resource)}catch(err){debugLogger2.error(`SessionMcpView[${this.sessionId}/${this.serverName}] failed to register resource ${resource.uri}: ${String(err instanceof Error?err.message:err)}`)}}debugLogger2.debug(`SessionMcpView[${this.sessionId}/${this.serverName}] applied ${snapshot.length} resources`)}updateConfig(cfg){const nextKey=mcpSessionMetadataKey(cfg);const changed=this.metadataKey!==nextKey;this.cfg=cfg;this.metadataKey=nextKey;return changed}teardown(){this.sessionToolRegistry.removeMcpToolsByServer(this.serverName);this.sessionPromptRegistry.removePromptsByServer(this.serverName);this.sessionResourceRegistry.removeResourcesByServer(this.serverName);debugLogger2.debug(`SessionMcpView[${this.sessionId}/${this.serverName}] torn down`)}};var debugLogger3=createDebugLogger("McpPool");var McpTransportPool=class{constructor(cliConfig,options){this.cliConfig=cliConfig;this.opts={workspaceContext:options.workspaceContext,debugMode:options.debugMode,sendSdkMcpMessage:options.sendSdkMcpMessage,pooledTransports:options.pooledTransports??POOLED_TRANSPORTS_DEFAULT,drainDelayMs:options.drainDelayMs??3e4,entryOptions:options.entryOptions??defaultPoolEntryOptions,budget:options.budget}}static{__name(this,"McpTransportPool")}entries=new Map;unpooledIds=new Set;spawnInFlight=new Map;sessionToEntries=new Map;draining=false;nextIndexByName=new Map;opts;getBudget(){return this.opts.budget}hasNameSibling(serverName){for(const e of this.entries.values()){if(e.serverName===serverName)return true}for(const id of this.spawnInFlight.keys()){try{if(parseConnectionId(id).serverName===serverName)return true}catch{}}return false}async acquire(serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry){if(this.draining){throw new Error(`McpTransportPool is draining; refusing acquire for ${serverName} (session ${sessionId})`)}const poolable=isPoolable(cfg,this.opts.pooledTransports);const id=poolable?connectionIdOf(serverName,cfg):void 0;if(id!==void 0){const existing=this.entries.get(id);if(existing&&!existing.isTerminated()){try{const conn=this.attachPooledSession(existing,id,serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry);this.indexAttach(sessionId,id);return conn}catch(err){if(existing.isTerminated()){this.evictEntry(id,existing);debugLogger3.warn(`pool self-heal: evicted terminal entry ${id} (state='${existing.currentState}', serverName='${serverName}') mid-attach race; falling through to spawn fresh entry`)}else{throw err}}}else if(existing&&existing.isTerminated()){this.evictEntry(id,existing);debugLogger3.warn(`pool self-heal: evicted stale terminal entry ${id} (state='${existing.currentState}', serverName='${serverName}') before fast-path attach; falling through to spawn fresh entry`)}}let reservationResult;if(this.opts.budget!==void 0){const reservation=this.opts.budget.tryReserve(serverName);if(reservation==="refused"){const transport=mcpTransportOf(cfg);this.opts.budget.recordRefusal(serverName,transport);throw new BudgetExhaustedError(serverName,this.opts.budget.getBudget()??0,this.opts.budget.getReservedCount())}reservationResult=reservation}if(!poolable){try{return await this.createUnpooledConnection(serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry)}catch(err){this.rollbackReservationOnSpawnFailure(reservationResult,serverName);throw err}}if(id===void 0){throw new Error("unreachable: poolable && id === undefined")}let inFlight=this.spawnInFlight.get(id);if(!inFlight){const spawnPromise=this.spawnEntry(serverName,cfg,id);inFlight=spawnPromise.finally(()=>{this.spawnInFlight.delete(id)}).catch(err=>{this.rollbackReservationOnSpawnFailure(reservationResult,serverName);throw err});this.spawnInFlight.set(id,inFlight)}this.indexAttach(sessionId,id);let entry;try{entry=await inFlight}catch(err){this.indexDetach(sessionId,id);throw err}if(!this.entries.has(id)||entry.isTerminated()){this.indexDetach(sessionId,id);throw new Error(`PoolEntry ${id} torn down before attach (concurrent release)`)}try{const conn=this.attachPooledSession(entry,id,serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry);this.indexAttach(sessionId,id);return conn}catch(err){this.indexDetach(sessionId,id);throw err}}release(id,sessionId){const entry=this.entries.get(id);if(!entry)return;entry.detach(sessionId);this.indexDetach(sessionId,id);if(entry.refs.size===0){if(this.unpooledIds.has(id)){void entry.forceShutdown("manual");return}entry.startDrainTimer(this.opts.drainDelayMs)}}releaseSession(sessionId){const ids=this.sessionToEntries.get(sessionId);if(!ids)return;const idList=[...ids];for(const id of idList){const entry=this.entries.get(id);if(!entry)continue;entry.detach(sessionId);if(entry.refs.size===0){if(this.unpooledIds.has(id)){void entry.forceShutdown("manual");continue}entry.startDrainTimer(this.opts.drainDelayMs)}}this.sessionToEntries.delete(sessionId)}async restartByName(serverName,opts){if(this.draining)return[];const matching=[...this.entries.values()].filter(e=>e.serverName===serverName&&(opts?.entryIndex===void 0||e.entryIndex===opts.entryIndex));if(matching.length===0)return[];return Promise.all(matching.map(async entry=>{const started=Date.now();try{await entry.restart();if(entry.refs.size===0&&!this.unpooledIds.has(entry.id)){entry.startDrainTimer(this.opts.drainDelayMs)}return{entryIndex:entry.entryIndex,restarted:true,durationMs:Date.now()-started}}catch(err){return{entryIndex:entry.entryIndex,restarted:false,reason:String(err instanceof Error?err.message:err)}}}))}getSnapshot(){const byName=new Map;let total=0;let subprocessCount=0;for(const entry of this.entries.values()){const status=entry.getLocalStatus();if(status==="connected"){total+=1;if(entry.transportKind==="stdio"){subprocessCount+=1}}const row=byName.get(entry.serverName)??{entryCount:0,entrySummary:[]};row.entryCount+=1;row.entrySummary.push({entryIndex:entry.entryIndex,refs:entry.refs.size,status});byName.set(entry.serverName,row)}return{total,subprocessCount,byName:Object.fromEntries(byName.entries())}}aggregateStatusByName(serverName){let sawConnecting=false;for(const entry of this.entries.values()){if(entry.serverName!==serverName)continue;const s=entry.getLocalStatus();if(s==="connected")return"connected";if(s==="connecting")sawConnecting=true}return sawConnecting?"connecting":"disconnected"}async drainAll(opts){const timeoutMs=opts?.timeoutMs??1e4;const force=opts?.force??false;this.draining=true;const deadline=Date.now()+timeoutMs;if(this.spawnInFlight.size>0){const spawnWait=Promise.allSettled([...this.spawnInFlight.values()]);let inflightTimer;await Promise.race([spawnWait.then(()=>{if(inflightTimer)clearTimeout(inflightTimer)}),new Promise(resolve9=>{inflightTimer=setTimeout(()=>{const stuckIds=[...this.spawnInFlight.keys()];debugLogger3.warn(`drainAll: spawnInFlight wait timed out after ${timeoutMs}ms; ${stuckIds.length} spawn(s) still in-flight: ${stuckIds.join(", ")}. Proceeding with drain.`);resolve9()},Math.max(0,deadline-Date.now()));inflightTimer.unref?.()})])}const entries=[...this.entries.values()];const drained=[];const errors=[];const shutdownPromises=entries.map(entry=>entry.forceShutdown(force?"manual":"drain_timer").then(()=>drained.push(entry.entryIndex)).catch(err=>{errors.push({entryIndex:entry.entryIndex,serverName:entry.serverName,error:String(err instanceof Error?err.message:err)})}));let drainTimer;const remaining=Math.max(0,deadline-Date.now());await Promise.race([Promise.all(shutdownPromises).then(()=>{if(drainTimer)clearTimeout(drainTimer)}),new Promise(resolve9=>{drainTimer=setTimeout(()=>resolve9(),remaining);drainTimer.unref?.()})]);const drainedCount=drained.length;const errorsCount=errors.length;const forced=Math.max(0,entries.length-drainedCount-errorsCount);const errorsCopy=[...errors];this.entries.clear();this.unpooledIds.clear();this.sessionToEntries.clear();this.spawnInFlight.clear();return{drained:drainedCount,forced,errors:errorsCopy}}attachPooledSession(entry,id,serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry){const view=new SessionMcpView(sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry,sessionId,serverName,cfg);return entry.attach(sessionId,view,{release:__name(()=>this.release(id,sessionId),"release")})}rollbackReservationOnSpawnFailure(reservationResult,serverName){if(this.opts.budget!==void 0&&reservationResult==="reserved"&&!this.hasNameSibling(serverName)){this.opts.budget.release(serverName)}}evictEntry(id,entry){if(entry===void 0)return;const current=this.entries.get(id);if(current!==entry)return;this.entries.delete(id);if(this.opts.budget!==void 0){if(!this.hasNameSibling(entry.serverName)){this.opts.budget.release(entry.serverName)}}}async spawnEntry(serverName,cfg,id){const entryIndex=this.allocateEntryIndex(serverName);const transport=mcpTransportOf(cfg);const entryOpts=this.opts.entryOptions(transport);const client=new McpClient(serverName,cfg,poisonedToolRegistry(serverName),poisonedPromptRegistry(serverName),this.opts.workspaceContext,this.opts.debugMode,this.opts.sendSdkMcpMessage);const entryRef={current:void 0};const onClosedForThisEntry=__name(closedId=>{this.evictEntry(closedId,entryRef.current)},"onClosedForThisEntry");const entry=new PoolEntry(id,serverName,entryIndex,cfg,client,this.cliConfig,entryOpts,onClosedForThisEntry,name=>this.aggregateStatusByName(name));entryRef.current=entry;try{const timeoutMs=discoveryTimeoutFor(cfg);const snap=await runWithTimeout((async()=>{await client.connect();return client.discoverAndReturn(this.cliConfig,{applyConfigFilters:false})})(),timeoutMs,`pool spawn for ${id} (pool will roll back the spawn and free its budget slot)`);if(this.draining){debugLogger3.warn(`Spawn for ${id} completed while pool is draining; discarding entry`);try{await entry.forceShutdown("manual")}catch{}throw new Error(`McpTransportPool is draining; discarded spawn ${id}`)}this.entries.set(id,entry);entry.markActive(snap.tools,snap.prompts,snap.resources);debugLogger3.info(`Spawned pool entry ${id} (entryIndex=${entryIndex}, transport=${transport})`);return entry}catch(err){debugLogger3.error(`Failed to spawn pool entry for '${serverName}' (id=${id}, transport=${transport}): ${String(err)}`);try{await entry.forceShutdown("manual")}catch{}this.entries.delete(id);try{await client.disconnect()}catch{}throw err}}allocateEntryIndex(serverName){const next=this.nextIndexByName.get(serverName)??0;this.nextIndexByName.set(serverName,next+1);return next}indexAttach(sessionId,id){let ids=this.sessionToEntries.get(sessionId);if(!ids){ids=new Set;this.sessionToEntries.set(sessionId,ids)}ids.add(id)}indexDetach(sessionId,id){const ids=this.sessionToEntries.get(sessionId);if(!ids)return;ids.delete(id);if(ids.size===0)this.sessionToEntries.delete(sessionId)}async createUnpooledConnection(serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry){const entryIndex=this.allocateEntryIndex(serverName);const id=`${serverName}::unpooled-${entryIndex}`;const transport=mcpTransportOf(cfg);const entryOpts=this.opts.entryOptions(transport);const client=new McpClient(serverName,cfg,sessionToolRegistry,sessionPromptRegistry,this.opts.workspaceContext,this.opts.debugMode,this.opts.sendSdkMcpMessage);const view=new SessionMcpView(sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry,sessionId,serverName,cfg);const entry=new PoolEntry(id,serverName,entryIndex,cfg,client,this.cliConfig,entryOpts,closedId=>{this.entries.delete(closedId);this.unpooledIds.delete(closedId);if(this.opts.budget!==void 0){if(!this.hasNameSibling(serverName)){this.opts.budget.release(serverName)}}},()=>client.getStatus());try{this.entries.set(id,entry);this.unpooledIds.add(id);this.indexAttach(sessionId,id);const timeoutMs=discoveryTimeoutFor(cfg);const snap=await runWithTimeout((async()=>{await client.connect();return await client.discoverAndReturn(this.cliConfig,{applyConfigFilters:false})})(),timeoutMs,`unpooled spawn for ${id} (pool will roll back the spawn and free its budget slot)`);if(this.draining||!this.entries.has(id)||entry.isTerminated()){try{view.teardown()}catch{}try{await entry.forceShutdown("manual")}catch{}this.indexDetach(sessionId,id);throw new Error(`McpTransportPool is draining or unpooled ${id} was cancelled`)}entry.markActive(snap.tools,snap.prompts,snap.resources);const conn=entry.attach(sessionId,view,{release:__name(()=>{this.indexDetach(sessionId,id);void entry.forceShutdown("manual")},"release")});return conn}catch(err){try{await entry.forceShutdown("manual")}catch{}this.entries.delete(id);this.unpooledIds.delete(id);this.indexDetach(sessionId,id);try{await client.disconnect()}catch{}throw err}}};function poisonedToolRegistry(serverName){return{registerTool(){throw new Error(`Pool invariant violated: poisoned ToolRegistry for ${serverName} received registerTool. A pool path must use discoverAndReturn, not discover.`)}}}__name(poisonedToolRegistry,"poisonedToolRegistry");function poisonedPromptRegistry(serverName){return{registerPrompt(){throw new Error(`Pool invariant violated: poisoned PromptRegistry for ${serverName} received registerPrompt. A pool path must use discoverAndReturn.`)}}}__name(poisonedPromptRegistry,"poisonedPromptRegistry");init_esbuild_shims();var debugLogger4=createDebugLogger("McpPool:Budget");var WorkspaceMcpBudget=class{static{__name(this,"WorkspaceMcpBudget")}clientBudget;mode;onEvent;reservedSlots=new Set;pendingRefusalNames=new Set;pendingRefusalTransports=new Map;lastRefusedServerNames=[];warnArmed=true;bulkPassDepth=0;constructor(opts){this.clientBudget=opts.clientBudget;this.mode=opts.mode;this.onEvent=opts.mode==="off"?void 0:opts.onEvent}getMode(){return this.mode}getBudget(){return this.clientBudget}getReservedSlots(){return Array.from(this.reservedSlots)}getRefusedServerNames(){return this.lastRefusedServerNames}getReservedCount(){return this.reservedSlots.size}tryReserve(serverName){if(this.reservedSlots.has(serverName))return"already_held";if(this.clientBudget===void 0||this.mode==="off"){return"reserved"}if(this.mode==="enforce"&&this.reservedSlots.size>=this.clientBudget){return"refused"}this.reservedSlots.add(serverName);this.evaluateState();return"reserved"}release(serverName){const had=this.reservedSlots.delete(serverName);if(had)this.evaluateState();return had}recordRefusal(serverName,transport){if(this.mode!=="enforce")return;this.pendingRefusalNames.add(serverName);this.pendingRefusalTransports.set(serverName,transport);debugLogger4.warn(`MCP server '${serverName}' refused at pool acquire (budget exhausted, budget=${this.clientBudget}, mode=${this.mode})`);if(this.bulkPassDepth===0){this.flushRefusedBatch()}}beginBulkPass(){if(this.bulkPassDepth===0){this.lastRefusedServerNames=[]}this.bulkPassDepth+=1}endBulkPass(){if(this.bulkPassDepth===0){debugLogger4.warn("WorkspaceMcpBudget.endBulkPass called without matching beginBulkPass; ignoring");return}this.bulkPassDepth-=1;if(this.bulkPassDepth>0)return;this.flushRefusedBatch()}flushRefusedBatch(){if(this.pendingRefusalNames.size===0)return;if(this.clientBudget===void 0||this.mode!=="enforce"){this.pendingRefusalNames.clear();this.pendingRefusalTransports.clear();return}const refusedServers=[];const names=[];for(const name of this.pendingRefusalNames){const transport=this.pendingRefusalTransports.get(name)??"unknown";refusedServers.push({name,transport,reason:"budget_exhausted"});names.push(name)}this.lastRefusedServerNames=Object.freeze(names);this.pendingRefusalNames.clear();this.pendingRefusalTransports.clear();if(this.onEvent){try{this.onEvent({kind:"refused_batch",refusedServers,budget:this.clientBudget,liveCount:this.reservedSlots.size,reservedCount:this.reservedSlots.size,mode:"enforce"})}catch(err){debugLogger4.error(`WorkspaceMcpBudget refused_batch event delivery failed: ${err instanceof Error?err.message:String(err)}`)}}}evaluateState(){if(this.mode==="off"||this.clientBudget===void 0)return;const ratio=this.reservedSlots.size/this.clientBudget;if(this.warnArmed&&ratio>=MCP_BUDGET_WARN_FRACTION){this.warnArmed=false;debugLogger4.info(`MCP workspace budget warning fired (ratio=${ratio.toFixed(2)}, reservedCount=${this.reservedSlots.size}, budget=${this.clientBudget}, mode=${this.mode})`);if(this.onEvent){try{this.onEvent({kind:"budget_warning",liveCount:this.reservedSlots.size,reservedCount:this.reservedSlots.size,budget:this.clientBudget,thresholdRatio:MCP_BUDGET_WARN_FRACTION,mode:this.mode})}catch(err){debugLogger4.error(`WorkspaceMcpBudget budget_warning event delivery failed: ${err instanceof Error?err.message:String(err)}`)}}}else if(!this.warnArmed&&ratio<MCP_BUDGET_REARM_FRACTION){this.warnArmed=true;debugLogger4.info(`MCP workspace budget warning re-armed (ratio=${ratio.toFixed(2)}, budget=${this.clientBudget}; next 75% crossing will fire)`)}}};init_esbuild_shims();function preservePlaceholders(value,resolved,original){if(typeof original==="string"&&value===resolved)return original;if(Array.isArray(value)&&Array.isArray(resolved)&&Array.isArray(original)){return value.map((entry,index)=>preservePlaceholders(entry,resolved[index],original[index]))}if(value&&resolved&&original&&typeof value==="object"&&!Array.isArray(value)&&typeof resolved==="object"&&!Array.isArray(resolved)&&typeof original==="object"&&!Array.isArray(original)){return Object.fromEntries(Object.entries(value).map(([key,entry])=>[key,preservePlaceholders(entry,resolved[key],original[key])]))}return value}__name(preservePlaceholders,"preservePlaceholders");function preserveModelProviderPlaceholders(models,provider,resolvedProviders,rawProviders,mapping){const pairs=Object.entries(resolvedProviders).flatMap(([providerId,entries])=>{if(!Array.isArray(entries))return[];return entries.flatMap((entry,index)=>{const resolved=provider==="openai"?getModelsForProviderProtocol({[providerId]:[entry]},"openai",mapping)[0]:providerId===provider?entry:void 0;return resolved?[{providerId,resolved,source:entry,raw:rawProviders[providerId]?.[index]??entry}]:[]})});return models.map(model=>{const matches=pairs.filter(({resolved})=>resolved.id===model.id&&resolved.baseUrl===model.baseUrl&&tryResolveModelProtocol(provider,resolved,mapping)===tryResolveModelProtocol(provider,model,mapping));const sourceMatches=matches.filter(pair=>pair.providerId===matches[0]?.providerId);if(sourceMatches.length>1&&sourceMatches.some(pair=>JSON.stringify(pair.raw)!==JSON.stringify(pair.source))){throw new Error("Cannot preserve placeholders in an ambiguous model configuration. Remove duplicate model entries first.")}const match=matches[0];return match?preservePlaceholders(model,match.resolved,match.raw):model})}__name(preserveModelProviderPlaceholders,"preserveModelProviderPlaceholders");init_esbuild_shims();init_esbuild_shims();var DISCOVERY_TIMEOUT_MS=5e3;var DISCOVERY_MAX_BYTES=1024*1024;var MAX_MODEL_ID_LENGTH=256;var UNSAFE_MODEL_ID_CHARS=/[,\p{C}\p{Zl}\p{Zp}]/u;function readModels(value){if(!value||typeof value!=="object"||!("data"in value)){return null}const data=value.data;if(!Array.isArray(data)){return null}const models=[];const seen=new Set;for(const item of data){if(!item||typeof item!=="object"||!("id"in item)){return null}const id=item.id;if(typeof id!=="string"){return null}const trimmedId=id.trim();if(trimmedId&&trimmedId.length<=MAX_MODEL_ID_LENGTH&&!UNSAFE_MODEL_ID_CHARS.test(trimmedId)&&!seen.has(trimmedId)){seen.add(trimmedId);const created=item.created;const creationTime=typeof created==="number"&&Number.isFinite(created)&&created>=0?created:void 0;models.push({id:trimmedId,...creationTime===void 0?{}:{created:creationTime}})}}return models.length>0?models:null}__name(readModels,"readModels");function mergeModelSpecs(discoveredModels,staticModels){const staticModelsById=new Map(staticModels.map(model=>[model.id,model]));const orderedModels=[...discoveredModels];if(orderedModels.every(model=>model.created!==void 0)){orderedModels.sort((left,right)=>(right.created??0)-(left.created??0))}return orderedModels.map(({id})=>staticModelsById.get(id)??{id})}__name(mergeModelSpecs,"mergeModelSpecs");async function discoverProviderModels({baseUrl,apiKey,staticModels,signal}){const normalizedBaseUrl=baseUrl.trim();const normalizedApiKey=apiKey.trim();if(!normalizedBaseUrl||!normalizedApiKey){return null}try{const modelsUrl=`${normalizedBaseUrl.replace(/\/+$/,"")}/models`;const result=await fetchWithPolicy(modelsUrl,{timeoutMs:DISCOVERY_TIMEOUT_MS,maxBytes:DISCOVERY_MAX_BYTES,maxRedirects:2,headers:{Accept:"application/json",Authorization:`Bearer ${normalizedApiKey}`},signal});if(result.kind!=="response"||result.status<200||result.status>=300){return null}const models=readModels(JSON.parse(result.body.toString("utf8")));return models?mergeModelSpecs(models,staticModels):null}catch{return null}}__name(discoverProviderModels,"discoverProviderModels");init_esbuild_shims();var IMAGE_CAPABILITY=Object.freeze({autoHandlesWrongModel:true,maxBytes:VISION_BRIDGE_MAX_IMAGE_BASE64_BYTES,maxImagesPerTurn:VISION_BRIDGE_MAX_IMAGES});init_esbuild_shims();var debugLogger5=createDebugLogger("SESSION_RECAP");var RECENT_MESSAGE_WINDOW=30;var RECAP_SYSTEM_PROMPT=`You generate session recaps for a programming assistant CLI.
|
|
3
|
+
import{MAX_DROPPED_MSG_IDS,MAX_FRAME_BYTES,MAX_RETAINED_REPLY_TOKEN_CHARS,MAX_SENDER_KEY_CHARS,MAX_SOCKET_PATH_BYTES,SOCKET_DIR_NAME,isLocalIpcPath,parsePeerAuthLine,parsePeerFrame,peerSenderKey,probePeerSocketVerdict,resolvePeerSocketCandidates}from"./chunk-MKH3EH7O.js";import{scanForSecrets}from"./chunk-AKWYMQKU.js";import{collectPtyProcessTree}from"./chunk-PGRN3GZY.js";import{BudgetExhaustedError,IDE_DEFINITIONS,MCP_BUDGET_REARM_FRACTION,MCP_BUDGET_WARN_FRACTION,McpClient,ORPHAN_TOOL_USE_REPAIR_REASON,POOLED_TRANSPORTS_DEFAULT,QWEN_CODE_COMPANION_EXTENSION_NAME,SessionService,StandardFileSystemService,aggregateUsage,buildSessionHistoryFromConversation,buildSyntheticToolResponseParts,classifyShellCommandSafety,classifyShellCommandSafetyInDirectory,coerceMcpFilterEntries,connectionIdOf,convertToFunctionErrorResponse,convertToFunctionResponse,createForkedChat,detectTurnInterruption,discoveryTimeoutFor,estimateContentTokens,evaluateToolInvocationGuard,finalizeToolResponses,getCacheSafeParams,getCacheSafeParamsSessionId,getTimeRangeBounds,isClearedMediaPlaceholder,isPoolable,listDescendantPids,listExistingSkillDirNames,loadUsageHistoryWithLive,mcpSessionMetadataKey,mcpTransportOf,normalizeMcpIncludeEntry,observeToolResultBoundary,parseConnectionId,recursivelyHydrateStrings,repairOrphanedToolUseTurns,runForkedAgent,runWithForkedChatModel,runWithTimeout,sigtermPids,stripToolResultImages,toolResultBoundaryArtifact,toolResultPartDiagnosticValues,withoutAutoMemorySnapshots}from"./chunk-LZNBHBAJ.js";import{shellResultText}from"./chunk-T7CHK6C2.js";import{runGit,runGitCapture,streamGitRecords}from"./chunk-ILECDNJX.js";import{hasVerifiableInode,openNoFollow,openSyncNoFollow}from"./chunk-QXQGUM3Y.js";import{projectUserTranscriptForDisplay}from"./chunk-DBA3F3D7.js";import{toolSearchBridgeSentence}from"./chunk-4WFGJVTF.js";import{flattenPeerLabel}from"./chunk-BYU42MLK.js";import{isPidAlive}from"./chunk-5LZ2DPLH.js";import{getProjectSkillsRoot}from"./chunk-XQJOZDV7.js";import{parse}from"./chunk-KLC3OD2M.js";import{glob,globSync}from"./chunk-OBOU4ZZM.js";import{isDeferredToolBridgeAvailable}from"./chunk-QX4PIAJI.js";import{require_picomatch}from"./chunk-TDHEAGDX.js";import{BUILT_IN_OUTPUT_STYLES,getBuiltInOutputStyle}from"./chunk-OV3EBH6J.js";import{NO_EXEC_CONFIG}from"./chunk-EBMCWXGZ.js";import{require_proper_lockfile}from"./chunk-YIW3H46P.js";import{disposeConoutWorker,loadPty,loadXtermHeadless,noteConPtyHostReleased,releaseConPtyHost}from"./chunk-CQCSNHPU.js";import{stripAnsi}from"./chunk-YGLM5XPP.js";import{resolveBundleDir}from"./chunk-4NPYOXJO.js";import{escapeJsonTagCharacters}from"./chunk-NTRFETZB.js";import{fetchWithPolicy}from"./chunk-OZGM5CCE.js";import{getModelsForProviderProtocol,tryResolveModelProtocol}from"./chunk-BDQOLT37.js";import{COMBINED_PASS_TOLERANCE_FACTOR,TOOL_OUTPUT_TRUNCATED_PREFIX,TRUNCATION_FALLBACK_ENVELOPE_SLACK,addMCPStatusChangeListener,removeMCPStatusChangeListener,updateMCPServerStatus}from"./chunk-TNCN2JX2.js";import{E_TIMEOUT,Mutex,withTimeout}from"./chunk-HDGTWJ24.js";import{runSideQuery}from"./chunk-K7JCVESI.js";import{MEMORY_SECTION_HEADER,VISION_BRIDGE_MAX_IMAGES,VISION_BRIDGE_MAX_IMAGE_BASE64_BYTES,detectFileType,getCurrentMemoryFilename,isCacheableReadResult,isWithinRoot,processSingleFileContent}from"./chunk-Y6HHV4LC.js";import{getInvocationContext}from"./chunk-SLD7H2FA.js";import{DEFAULT_IMAGE_TOKEN_ESTIMATE,estimatePartChars}from"./chunk-Q6UAOTP3.js";import{atomicWriteFile,atomicWriteJSON}from"./chunk-BMHYEQTI.js";import{isBinary,normalizeContent,stripAnsiAndControl,stripHtmlComments}from"./chunk-4YLXNRRH.js";import{AUTO_MEMORY_SNAPSHOT_METADATA,SYSTEM_REMINDER_CLOSE,SYSTEM_REMINDER_OPEN,cloneApiHistory,getFolderStructure,getStartupContextLength,isSystemReminderContent,stripSystemReminderBlocks}from"./chunk-B3ZFUGTC.js";import{getQwenIgnoreFileNames,require_ignore}from"./chunk-5DTFN37U.js";import{ToolNames,canonicalToolName}from"./chunk-SBZFGYYS.js";import{createDebugLogger}from"./chunk-JAUJI56S.js";import{Storage}from"./chunk-EPODBRBP.js";import{PATH_ARG_KEYS,QWEN_DIR,tildeifyPath,unescapePath}from"./chunk-OKN3Z5C5.js";import{getErrorMessage,isAbortError,isNodeError}from"./chunk-XYB7GC5U.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name,__require,__toESM}from"./chunk-KBWJGX7I.js";init_esbuild_shims();var JsonFormatter=class{static{__name(this,"JsonFormatter")}format(response,stats,error){const output={};if(response!==void 0){output.response=stripAnsi(response)}if(stats){output.stats=stats}if(error){output.error=error}return JSON.stringify(output,null,2)}formatError(error,code){const jsonError={type:error.constructor.name,message:stripAnsi(error.message),...code&&{code}};return this.format(void 0,void 0,jsonError)}};init_esbuild_shims();function createPlanId(sessionId,historyLength){return`${sessionId}:${historyLength}`}__name(createPlanId,"createPlanId");function buildVisibleNotice(kind,repairs,historyGaps){if(kind==="clean"){return void 0}if(kind==="degraded_history"){return`Resumed session history is incomplete: detected ${historyGaps.length} missing parent link(s). Automatic continuation is disabled for this recovery.`}if(kind==="interrupted_prompt"){return"Previous session appears to have stopped after user input before the model completed a response."}const synthesized=repairs.filter(repair=>repair.type==="synthesized_tool_result").length;if(synthesized>0){return`Previous session appears to have stopped during tool execution. Synthesized ${synthesized} failed tool result(s) so the history can continue safely.`}return"Previous session appears to have stopped during tool execution."}__name(buildVisibleNotice,"buildVisibleNotice");function buildSessionRecoveryPlan({sessionId,conversation,historyGaps,options}){return buildSessionRecoveryPlanFromApiHistory({sessionId,...buildSessionHistoryFromConversation(conversation),historyGaps,options})}__name(buildSessionRecoveryPlan,"buildSessionRecoveryPlan");function buildSessionRecoveryPlanFromApiHistory({sessionId,apiHistory:inputApiHistory,completedToolCallIds,trailingSystemNotifications,historyGaps,options}){const originalApiHistory=inputApiHistory;const gaps=historyGaps??[];const planId=createPlanId(sessionId,originalApiHistory.length);const apiHistory=cloneApiHistory(originalApiHistory);const repairResult=repairOrphanedToolUseTurns(apiHistory);const repairs=[...repairResult.injected.map(repair=>({type:"synthesized_tool_result",callId:repair.callId,name:repair.name})),...repairResult.droppedDuplicates.map(repair=>({type:"dropped_duplicate_tool_result",callId:repair.callId,name:repair.name})),...gaps.map(gap=>({type:"history_gap",childUuid:gap.childUuid,missingParentUuid:gap.missingParentUuid}))];if(gaps.length>0){return{planId,sessionId,kind:"degraded_history",originalApiHistory,apiHistory,repairs,canContinue:false,canAutoContinue:false,requiresUserConfirmation:true,visibleNotice:buildVisibleNotice("degraded_history",repairs,gaps)}}const interruption=detectTurnInterruption(originalApiHistory,completedToolCallIds,trailingSystemNotifications);if(interruption.kind==="none"){return{planId,sessionId,kind:"clean",originalApiHistory,apiHistory,repairs,canContinue:false,canAutoContinue:false,requiresUserConfirmation:false}}if(interruption.kind==="interrupted_prompt"){const continuation2={mode:"retry_user_parts",parts:interruption.parts,displayText:"Continue interrupted user prompt"};return{planId,sessionId,kind:"interrupted_prompt",originalApiHistory,apiHistory,repairs,canContinue:true,canAutoContinue:options?.allowAutoContinue===true,requiresUserConfirmation:options?.allowAutoContinue!==true,visibleNotice:buildVisibleNotice("interrupted_prompt",repairs,gaps),continuation:continuation2}}const continuation={mode:"tool_result_parts",parts:buildSyntheticToolResponseParts(interruption.danglingCalls,ORPHAN_TOOL_USE_REPAIR_REASON),displayText:"Continue interrupted tool turn"};return{planId,sessionId,kind:"interrupted_turn",originalApiHistory,apiHistory,repairs,canContinue:true,canAutoContinue:false,requiresUserConfirmation:true,visibleNotice:buildVisibleNotice("interrupted_turn",repairs,gaps),continuation}}__name(buildSessionRecoveryPlanFromApiHistory,"buildSessionRecoveryPlanFromApiHistory");init_esbuild_shims();init_esbuild_shims();import{EventEmitter}from"node:events";init_esbuild_shims();var debugLogger=createDebugLogger("McpPool:Entry");function defaultPoolEntryOptions(transport){const isRemote=transport==="http"||transport==="sse"||transport==="websocket";return{drainDelayMs:3e4,maxIdleMs:5*6e4,maxReconnectAttempts:isRemote?5:3,reconnectStrategy:isRemote?{kind:"exponential",baseMs:1e3,capMs:16e3}:{kind:"fixed",delayMs:5e3}}}__name(defaultPoolEntryOptions,"defaultPoolEntryOptions");var PoolEntry=class{constructor(id,serverName,entryIndex,cfg,client,cliConfig,opts,onClosed,aggregateStatusByName){this.id=id;this.serverName=serverName;this.entryIndex=entryIndex;this.cfg=cfg;this.client=client;this.cliConfig=cliConfig;this.opts=opts;this.onClosed=onClosed;this.aggregateStatusByName=aggregateStatusByName;this.transportId=connectionIdOf(serverName,cfg);this.emitter.setMaxListeners(0);this.statusChangeListener=(name,status)=>{if(name!==this.serverName)return;if(status===void 0)return;if(this.suppressNextStatusEcho){this.suppressNextStatusEcho=false;return}if(this.client.getStatus()!==status)return;if(status===this.localStatus)return;this.localStatus=status;if(status==="disconnected"&&(this.state==="active"||this.state==="draining")&&!this.restartInProgress){const wasDraining=this.state==="draining";this.state="failed";if(wasDraining){this.cancelDrainTimer()}if(this.maxIdleTimer){clearTimeout(this.maxIdleTimer);this.maxIdleTimer=void 0}if(this.statusChangeListener){removeMCPStatusChangeListener(this.statusChangeListener);this.statusChangeListener=void 0}debugLogger.error(`PoolEntry ${this.id} silent transport drop (prev state='${wasDraining?"draining":"active"}', localStatus\u2192DISCONNECTED). Transitioning to 'failed'; evicting from pool.entries + pooledConnections (W122 R20).`);const upstreamError=this.client.getLastTransportError();this.emit({kind:"failed",serverName:this.serverName,generation:this._generation,lastError:upstreamError?`transport disconnected (silent transport drop): ${upstreamError.message}`:"transport disconnected (silent transport drop)"});for(const[sid]of[...this.subscribers]){this.detach(sid)}void this.sweepAndDisconnect("silent_drop").then(result=>{const partialSignal=result.descendantsFound!==void 0&&result.descendantsSignaled!==void 0&&result.descendantsSignaled<result.descendantsFound;if(result.pidSweepError!==void 0||partialSignal){debugLogger.warn(`PoolEntry ${this.id} silent-drop sweep observability: descendantsFound=${result.descendantsFound??"unknown"}, descendantsSignaled=${result.descendantsSignaled??"unknown"}, pidSweepError=${result.pidSweepError?.message??"none"}. Possible orphan-process pressure \u2014 operator should check for lingering subprocess descendants of the dead transport.`)}this.updateGlobalStatus()},()=>{this.updateGlobalStatus()});this.updateGlobalStatus();this.onClosed(this.id)}};addMCPStatusChangeListener(this.statusChangeListener)}static{__name(this,"PoolEntry")}localStatus="connecting";state="spawning";_generation=0;refs=new Set;subscribers=new Map;subscriberHandles=new Map;toolsSnapshot=[];promptsSnapshot=[];resourcesSnapshot=[];drainTimer;maxIdleTimer;firstIdleAt;restartInFlight;restartInProgress=false;emitter=new EventEmitter;statusChangeListener;suppressNextStatusEcho=false;transportId;get generation(){return this._generation}get currentState(){return this.state}get transportKind(){return mcpTransportOf(this.cfg)}isTerminated(){return this.state==="closed"||this.state==="failed"}markActive(initialTools,initialPrompts,initialResources){if(this.state==="closed"||this.state==="failed")return;this.toolsSnapshot=initialTools;this.promptsSnapshot=initialPrompts;this.resourcesSnapshot=initialResources;this.state="active";this.localStatus="connected";this.updateGlobalStatus()}attach(sessionId,view,opts){if(this.state==="closed"||this.state==="failed"){throw new Error(`Cannot attach to PoolEntry ${this.id} in state ${this.state}`)}const previousState=this.state;const hadRef=this.refs.has(sessionId);const previousView=this.subscribers.get(sessionId);const previousHandle=this.subscriberHandles.get(sessionId);this.refs.add(sessionId);this.subscribers.set(sessionId,view);this.cancelDrainTimer();if(this.state==="draining")this.state="active";if(this.state==="active"&&opts?.skipReplay!==true){try{view.applyTools(this.toolsSnapshot);view.applyPrompts(this.promptsSnapshot);view.applyResources(this.resourcesSnapshot)}catch(err){if(!hadRef){this.refs.delete(sessionId);this.subscribers.delete(sessionId);this.subscriberHandles.delete(sessionId);try{view.teardown()}catch{}}else if(previousView){this.subscribers.set(sessionId,previousView);if(previousHandle){this.subscriberHandles.set(sessionId,previousHandle)}}if(previousState==="draining"&&this.refs.size===0){this.startDrainTimer(this.opts.drainDelayMs)}else{this.state=previousState}debugLogger.error(`Snapshot replay failed for ${sessionId}/${this.serverName}: ${String(err)}`);throw err}}const handle=new PooledConnectionImpl(this,sessionId,opts?.release);this.subscriberHandles.set(sessionId,handle);return handle}updateSessionConfig(sessionId,cfg){if(this.isTerminated()){throw new Error(`Cannot update config on PoolEntry ${this.id} in state ${this.state}`)}const view=this.subscribers.get(sessionId);if(!view){throw new Error(`Cannot update config for detached session ${sessionId} on PoolEntry ${this.id}`)}if(!view.updateConfig(cfg))return;if(this.state==="active"){view.applyTools(this.toolsSnapshot);view.applyPrompts(this.promptsSnapshot);view.applyResources(this.resourcesSnapshot)}}detach(sessionId){const view=this.subscribers.get(sessionId);if(view){try{view.teardown()}catch(err){debugLogger.error(`View teardown failed for ${sessionId}/${this.serverName}: ${String(err)}`)}}this.subscribers.delete(sessionId);this.subscriberHandles.delete(sessionId);this.refs.delete(sessionId)}startDrainTimer(delayMs){this.cancelDrainTimer();this.state="draining";if(this.firstIdleAt===void 0){this.firstIdleAt=Date.now();this.maxIdleTimer=setTimeout(()=>{if(this.refs.size>0){debugLogger.debug(`PoolEntry ${this.id} max-idle reached but ${this.refs.size} sessions active; deferring close, resetting first-idle window`);this.maxIdleTimer=void 0;this.firstIdleAt=void 0;return}debugLogger.warn(`PoolEntry ${this.id} hit MAX_IDLE_MS (${this.opts.maxIdleMs}ms); force-closing`);void this.forceShutdown("max_idle")},this.opts.maxIdleMs);this.maxIdleTimer.unref?.()}this.drainTimer=setTimeout(()=>{void this.forceShutdown("drain_timer")},delayMs);this.drainTimer.unref?.()}cancelDrainTimer(){if(this.drainTimer){clearTimeout(this.drainTimer);this.drainTimer=void 0}}async forceShutdown(reason){if(this.state==="closed"||this.state==="failed")return;this.state="closed";this.localStatus="disconnected";this.suppressNextStatusEcho=true;this.cancelDrainTimer();if(this.maxIdleTimer){clearTimeout(this.maxIdleTimer);this.maxIdleTimer=void 0}if(this.statusChangeListener){removeMCPStatusChangeListener(this.statusChangeListener);this.statusChangeListener=void 0}this.emit({kind:"disconnected",serverName:this.serverName,generation:this._generation,reason:"transport_closed"});for(const[sid]of this.subscribers){this.detach(sid)}await this.sweepAndDisconnect(reason);this.updateGlobalStatus();this.onClosed(this.id)}async sweepAndDisconnect(reason){const result={};try{const rootPid=this.client.getTransportPid?.();if(rootPid!==void 0){const descendants=await listDescendantPids(rootPid);if(descendants.length>0){result.descendantsFound=descendants.length;result.descendantsSignaled=sigtermPids(descendants);debugLogger.debug(`Sent SIGTERM to ${result.descendantsSignaled}/${descendants.length} descendants of pid ${rootPid} for ${this.id} (${reason})`)}}}catch(err){result.pidSweepError=err instanceof Error?err:new Error(String(err));debugLogger.warn(`Descendant pid sweep failed for ${this.id} (${reason}): ${String(err)}. Proceeding with disconnect.`)}try{await this.client.disconnect()}catch(err){debugLogger.error(`client.disconnect failed for ${this.id} (${reason}): ${String(err)}`)}return result}async restart(){if(this.restartInFlight)return this.restartInFlight;this.restartInFlight=this.doRestart().finally(()=>{this.restartInFlight=void 0});return this.restartInFlight}async doRestart(){if(this.state==="closed"||this.state==="failed"){throw new Error(`Cannot restart PoolEntry ${this.id} in state ${this.state}`)}this.restartInProgress=true;try{return await this.doRestartInner()}finally{this.restartInProgress=false}}async doRestartInner(){this.cancelDrainTimer();if(this.maxIdleTimer){clearTimeout(this.maxIdleTimer);this.maxIdleTimer=void 0}this.firstIdleAt=void 0;if(this.state==="draining"){this.state="active"}const oldGen=this._generation;this._generation+=1;this.emit({kind:"disconnected",serverName:this.serverName,generation:oldGen,reason:"restart"});await this.sweepAndDisconnect("restart");let snap;try{const timeoutMs=discoveryTimeoutFor(this.cfg);snap=await runWithTimeout((async()=>{await this.client.connect();return this.client.discoverAndReturn(this.cliConfig,{applyConfigFilters:false})})(),timeoutMs,`pool restart for ${this.id} (pool will roll back the restart and free its budget slot)`)}catch(err){debugLogger.error(`Restart of ${this.id} failed at connect/discover: ${String(err)}. Transitioning to 'failed'.`);await this.sweepAndDisconnect("restart_failed");this.state="failed";this.localStatus="disconnected";this.suppressNextStatusEcho=true;this.updateGlobalStatus();if(this.statusChangeListener){removeMCPStatusChangeListener(this.statusChangeListener);this.statusChangeListener=void 0}this.emit({kind:"failed",serverName:this.serverName,generation:this._generation,lastError:err instanceof Error?err.message:String(err)});for(const[sid]of this.subscribers){this.detach(sid)}this.onClosed(this.id);throw err}if(oldGen+1!==this._generation){await this.sweepAndDisconnect("restart_superseded");throw new Error(`Restart of ${this.id} superseded by newer generation; discarded stale snapshot + swept new transport.`)}const currentState=this.state;if(currentState==="closed"||currentState==="failed"){await this.sweepAndDisconnect("restart_superseded");throw new Error(`Restart of ${this.id} aborted: entry state is ${currentState} (forceShutdown ran concurrently mid-restart). Snapshot discarded; new transport swept.`)}this.toolsSnapshot=snap.tools;this.promptsSnapshot=snap.prompts;if(snap.resources.length>0){this.resourcesSnapshot=snap.resources}for(const[sid,view]of this.subscribers){try{view.applyTools(this.toolsSnapshot);view.applyPrompts(this.promptsSnapshot);view.applyResources(this.resourcesSnapshot)}catch(err){debugLogger.error(`Restart fan-out to view ${sid}/${this.serverName} failed: ${String(err)}`)}}this.localStatus="connected";this.suppressNextStatusEcho=true;this.updateGlobalStatus();this.emit({kind:"reconnected",serverName:this.serverName,generation:this._generation});this.emit({kind:"toolsChanged",serverName:this.serverName,snapshot:this.toolsSnapshot,generation:this._generation});this.emit({kind:"promptsChanged",serverName:this.serverName,snapshot:this.promptsSnapshot,generation:this._generation});this.emit({kind:"resourcesChanged",serverName:this.serverName,snapshot:this.resourcesSnapshot,generation:this._generation})}emit(event){const listeners=this.emitter.listeners("event");for(const listener of listeners){try{listener(event)}catch(err){debugLogger.error(`PoolEntry listener error for ${this.id} (event.kind=${event.kind}): ${err instanceof Error?err.message:String(err)}`)}}}internalOn(listener){this.emitter.on("event",listener)}internalOff(listener){this.emitter.off("event",listener)}updateGlobalStatus(){const aggregated=this.aggregateStatusByName(this.serverName);updateMCPServerStatus(this.serverName,aggregated)}getLocalStatus(){return this.localStatus}};var PooledConnectionImpl=class{constructor(entry,sessionId,releaseCallback){this.entry=entry;this.sessionId=sessionId;this.releaseCallback=releaseCallback}static{__name(this,"PooledConnectionImpl")}listeners=new Set;released=false;get id(){return this.entry.id}get transportId(){return this.entry.transportId}get serverName(){return this.entry.serverName}get entryIndex(){return this.entry.entryIndex}get client(){return this.entry.client}get toolsSnapshot(){return this.entry.toolsSnapshot}get promptsSnapshot(){return this.entry.promptsSnapshot}get resourcesSnapshot(){return this.entry.resourcesSnapshot}updateConfig(cfg){if(this.released){throw new Error(`Cannot update config on released MCP connection ${this.id}`)}this.entry.updateSessionConfig(this.sessionId,cfg)}on(event,listener){if(event!=="event")return this;if(this.listeners.has(listener))return this;this.listeners.add(listener);this.entry.internalOn(listener);return this}off(event,listener){if(event!=="event")return this;this.listeners.delete(listener);this.entry.internalOff(listener);return this}release(){if(this.released)return;this.released=true;for(const l of this.listeners){this.entry.internalOff(l)}this.listeners.clear();this.releaseCallback?.()}};init_esbuild_shims();var debugLogger2=createDebugLogger("McpPool:View");function compileNameFilter(includeTools,excludeTools){return{excludeSet:excludeTools?new Set(coerceMcpFilterEntries(excludeTools)):void 0,includeSet:includeTools!=null?new Set(coerceMcpFilterEntries(includeTools).map(normalizeMcpIncludeEntry)):void 0}}__name(compileNameFilter,"compileNameFilter");function compiledFilterAccepts(filter2,name){if(filter2.excludeSet?.has(name))return false;if(!filter2.includeSet)return true;return filter2.includeSet.has(name)}__name(compiledFilterAccepts,"compiledFilterAccepts");var SessionMcpView=class{constructor(sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry,sessionId,serverName,cfg){this.sessionToolRegistry=sessionToolRegistry;this.sessionPromptRegistry=sessionPromptRegistry;this.sessionResourceRegistry=sessionResourceRegistry;this.sessionId=sessionId;this.serverName=serverName;this.cfg=cfg;this.metadataKey=mcpSessionMetadataKey(cfg)}static{__name(this,"SessionMcpView")}metadataKey;applyTools(snapshot){this.sessionToolRegistry.removeMcpToolsByServer(this.serverName);const filter2=compileNameFilter(this.cfg.includeTools,this.cfg.excludeTools);let registered=0;for(const tool of snapshot){if(!compiledFilterAccepts(filter2,tool.serverToolName)){continue}const sessionTool=tool.withSessionConfig(this.cfg.trust,this.cfg.alwaysLoadTools===true);try{this.sessionToolRegistry.registerTool(sessionTool);registered+=1}catch(err){debugLogger2.error(`SessionMcpView[${this.sessionId}/${this.serverName}] failed to register tool ${tool.serverToolName}: ${String(err instanceof Error?err.message:err)}`)}}debugLogger2.debug(`SessionMcpView[${this.sessionId}/${this.serverName}] applied ${snapshot.length} tools (filtered to ${registered} registered)`)}applyPrompts(snapshot){this.sessionPromptRegistry.removePromptsByServer(this.serverName);const filter2=compileNameFilter(this.cfg.includeTools,this.cfg.excludeTools);let registered=0;for(const prompt of snapshot){if(!compiledFilterAccepts(filter2,prompt.name)){continue}try{this.sessionPromptRegistry.registerPrompt(prompt);registered+=1}catch(err){debugLogger2.error(`SessionMcpView[${this.sessionId}/${this.serverName}] failed to register prompt ${prompt.name}: ${String(err instanceof Error?err.message:err)}`)}}debugLogger2.debug(`SessionMcpView[${this.sessionId}/${this.serverName}] applied ${snapshot.length} prompts (filtered to ${registered} registered)`)}applyResources(snapshot){if(snapshot.length===0){return}this.sessionResourceRegistry.removeResourcesByServer(this.serverName);for(const resource of snapshot){try{this.sessionResourceRegistry.registerResource(resource)}catch(err){debugLogger2.error(`SessionMcpView[${this.sessionId}/${this.serverName}] failed to register resource ${resource.uri}: ${String(err instanceof Error?err.message:err)}`)}}debugLogger2.debug(`SessionMcpView[${this.sessionId}/${this.serverName}] applied ${snapshot.length} resources`)}updateConfig(cfg){const nextKey=mcpSessionMetadataKey(cfg);const changed=this.metadataKey!==nextKey;this.cfg=cfg;this.metadataKey=nextKey;return changed}teardown(){this.sessionToolRegistry.removeMcpToolsByServer(this.serverName);this.sessionPromptRegistry.removePromptsByServer(this.serverName);this.sessionResourceRegistry.removeResourcesByServer(this.serverName);debugLogger2.debug(`SessionMcpView[${this.sessionId}/${this.serverName}] torn down`)}};var debugLogger3=createDebugLogger("McpPool");var McpTransportPool=class{constructor(cliConfig,options){this.cliConfig=cliConfig;this.opts={workspaceContext:options.workspaceContext,debugMode:options.debugMode,sendSdkMcpMessage:options.sendSdkMcpMessage,pooledTransports:options.pooledTransports??POOLED_TRANSPORTS_DEFAULT,drainDelayMs:options.drainDelayMs??3e4,entryOptions:options.entryOptions??defaultPoolEntryOptions,budget:options.budget}}static{__name(this,"McpTransportPool")}entries=new Map;unpooledIds=new Set;spawnInFlight=new Map;sessionToEntries=new Map;draining=false;nextIndexByName=new Map;opts;getBudget(){return this.opts.budget}hasNameSibling(serverName){for(const e of this.entries.values()){if(e.serverName===serverName)return true}for(const id of this.spawnInFlight.keys()){try{if(parseConnectionId(id).serverName===serverName)return true}catch{}}return false}async acquire(serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry){if(this.draining){throw new Error(`McpTransportPool is draining; refusing acquire for ${serverName} (session ${sessionId})`)}const poolable=isPoolable(cfg,this.opts.pooledTransports);const id=poolable?connectionIdOf(serverName,cfg):void 0;if(id!==void 0){const existing=this.entries.get(id);if(existing&&!existing.isTerminated()){try{const conn=this.attachPooledSession(existing,id,serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry);this.indexAttach(sessionId,id);return conn}catch(err){if(existing.isTerminated()){this.evictEntry(id,existing);debugLogger3.warn(`pool self-heal: evicted terminal entry ${id} (state='${existing.currentState}', serverName='${serverName}') mid-attach race; falling through to spawn fresh entry`)}else{throw err}}}else if(existing&&existing.isTerminated()){this.evictEntry(id,existing);debugLogger3.warn(`pool self-heal: evicted stale terminal entry ${id} (state='${existing.currentState}', serverName='${serverName}') before fast-path attach; falling through to spawn fresh entry`)}}let reservationResult;if(this.opts.budget!==void 0){const reservation=this.opts.budget.tryReserve(serverName);if(reservation==="refused"){const transport=mcpTransportOf(cfg);this.opts.budget.recordRefusal(serverName,transport);throw new BudgetExhaustedError(serverName,this.opts.budget.getBudget()??0,this.opts.budget.getReservedCount())}reservationResult=reservation}if(!poolable){try{return await this.createUnpooledConnection(serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry)}catch(err){this.rollbackReservationOnSpawnFailure(reservationResult,serverName);throw err}}if(id===void 0){throw new Error("unreachable: poolable && id === undefined")}let inFlight=this.spawnInFlight.get(id);if(!inFlight){const spawnPromise=this.spawnEntry(serverName,cfg,id);inFlight=spawnPromise.finally(()=>{this.spawnInFlight.delete(id)}).catch(err=>{this.rollbackReservationOnSpawnFailure(reservationResult,serverName);throw err});this.spawnInFlight.set(id,inFlight)}this.indexAttach(sessionId,id);let entry;try{entry=await inFlight}catch(err){this.indexDetach(sessionId,id);throw err}if(!this.entries.has(id)||entry.isTerminated()){this.indexDetach(sessionId,id);throw new Error(`PoolEntry ${id} torn down before attach (concurrent release)`)}try{const conn=this.attachPooledSession(entry,id,serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry);this.indexAttach(sessionId,id);return conn}catch(err){this.indexDetach(sessionId,id);throw err}}release(id,sessionId){const entry=this.entries.get(id);if(!entry)return;entry.detach(sessionId);this.indexDetach(sessionId,id);if(entry.refs.size===0){if(this.unpooledIds.has(id)){void entry.forceShutdown("manual");return}entry.startDrainTimer(this.opts.drainDelayMs)}}releaseSession(sessionId){const ids=this.sessionToEntries.get(sessionId);if(!ids)return;const idList=[...ids];for(const id of idList){const entry=this.entries.get(id);if(!entry)continue;entry.detach(sessionId);if(entry.refs.size===0){if(this.unpooledIds.has(id)){void entry.forceShutdown("manual");continue}entry.startDrainTimer(this.opts.drainDelayMs)}}this.sessionToEntries.delete(sessionId)}async restartByName(serverName,opts){if(this.draining)return[];const matching=[...this.entries.values()].filter(e=>e.serverName===serverName&&(opts?.entryIndex===void 0||e.entryIndex===opts.entryIndex));if(matching.length===0)return[];return Promise.all(matching.map(async entry=>{const started=Date.now();try{await entry.restart();if(entry.refs.size===0&&!this.unpooledIds.has(entry.id)){entry.startDrainTimer(this.opts.drainDelayMs)}return{entryIndex:entry.entryIndex,restarted:true,durationMs:Date.now()-started}}catch(err){return{entryIndex:entry.entryIndex,restarted:false,reason:String(err instanceof Error?err.message:err)}}}))}getSnapshot(){const byName=new Map;let total=0;let subprocessCount=0;for(const entry of this.entries.values()){const status=entry.getLocalStatus();if(status==="connected"){total+=1;if(entry.transportKind==="stdio"){subprocessCount+=1}}const row=byName.get(entry.serverName)??{entryCount:0,entrySummary:[]};row.entryCount+=1;row.entrySummary.push({entryIndex:entry.entryIndex,refs:entry.refs.size,status});byName.set(entry.serverName,row)}return{total,subprocessCount,byName:Object.fromEntries(byName.entries())}}aggregateStatusByName(serverName){let sawConnecting=false;for(const entry of this.entries.values()){if(entry.serverName!==serverName)continue;const s=entry.getLocalStatus();if(s==="connected")return"connected";if(s==="connecting")sawConnecting=true}return sawConnecting?"connecting":"disconnected"}async drainAll(opts){const timeoutMs=opts?.timeoutMs??1e4;const force=opts?.force??false;this.draining=true;const deadline=Date.now()+timeoutMs;if(this.spawnInFlight.size>0){const spawnWait=Promise.allSettled([...this.spawnInFlight.values()]);let inflightTimer;await Promise.race([spawnWait.then(()=>{if(inflightTimer)clearTimeout(inflightTimer)}),new Promise(resolve9=>{inflightTimer=setTimeout(()=>{const stuckIds=[...this.spawnInFlight.keys()];debugLogger3.warn(`drainAll: spawnInFlight wait timed out after ${timeoutMs}ms; ${stuckIds.length} spawn(s) still in-flight: ${stuckIds.join(", ")}. Proceeding with drain.`);resolve9()},Math.max(0,deadline-Date.now()));inflightTimer.unref?.()})])}const entries=[...this.entries.values()];const drained=[];const errors=[];const shutdownPromises=entries.map(entry=>entry.forceShutdown(force?"manual":"drain_timer").then(()=>drained.push(entry.entryIndex)).catch(err=>{errors.push({entryIndex:entry.entryIndex,serverName:entry.serverName,error:String(err instanceof Error?err.message:err)})}));let drainTimer;const remaining=Math.max(0,deadline-Date.now());await Promise.race([Promise.all(shutdownPromises).then(()=>{if(drainTimer)clearTimeout(drainTimer)}),new Promise(resolve9=>{drainTimer=setTimeout(()=>resolve9(),remaining);drainTimer.unref?.()})]);const drainedCount=drained.length;const errorsCount=errors.length;const forced=Math.max(0,entries.length-drainedCount-errorsCount);const errorsCopy=[...errors];this.entries.clear();this.unpooledIds.clear();this.sessionToEntries.clear();this.spawnInFlight.clear();return{drained:drainedCount,forced,errors:errorsCopy}}attachPooledSession(entry,id,serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry){const view=new SessionMcpView(sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry,sessionId,serverName,cfg);return entry.attach(sessionId,view,{release:__name(()=>this.release(id,sessionId),"release")})}rollbackReservationOnSpawnFailure(reservationResult,serverName){if(this.opts.budget!==void 0&&reservationResult==="reserved"&&!this.hasNameSibling(serverName)){this.opts.budget.release(serverName)}}evictEntry(id,entry){if(entry===void 0)return;const current=this.entries.get(id);if(current!==entry)return;this.entries.delete(id);if(this.opts.budget!==void 0){if(!this.hasNameSibling(entry.serverName)){this.opts.budget.release(entry.serverName)}}}async spawnEntry(serverName,cfg,id){const entryIndex=this.allocateEntryIndex(serverName);const transport=mcpTransportOf(cfg);const entryOpts=this.opts.entryOptions(transport);const client=new McpClient(serverName,cfg,poisonedToolRegistry(serverName),poisonedPromptRegistry(serverName),this.opts.workspaceContext,this.opts.debugMode,this.opts.sendSdkMcpMessage);const entryRef={current:void 0};const onClosedForThisEntry=__name(closedId=>{this.evictEntry(closedId,entryRef.current)},"onClosedForThisEntry");const entry=new PoolEntry(id,serverName,entryIndex,cfg,client,this.cliConfig,entryOpts,onClosedForThisEntry,name=>this.aggregateStatusByName(name));entryRef.current=entry;try{const timeoutMs=discoveryTimeoutFor(cfg);const snap=await runWithTimeout((async()=>{await client.connect();return client.discoverAndReturn(this.cliConfig,{applyConfigFilters:false})})(),timeoutMs,`pool spawn for ${id} (pool will roll back the spawn and free its budget slot)`);if(this.draining){debugLogger3.warn(`Spawn for ${id} completed while pool is draining; discarding entry`);try{await entry.forceShutdown("manual")}catch{}throw new Error(`McpTransportPool is draining; discarded spawn ${id}`)}this.entries.set(id,entry);entry.markActive(snap.tools,snap.prompts,snap.resources);debugLogger3.info(`Spawned pool entry ${id} (entryIndex=${entryIndex}, transport=${transport})`);return entry}catch(err){debugLogger3.error(`Failed to spawn pool entry for '${serverName}' (id=${id}, transport=${transport}): ${String(err)}`);try{await entry.forceShutdown("manual")}catch{}this.entries.delete(id);try{await client.disconnect()}catch{}throw err}}allocateEntryIndex(serverName){const next=this.nextIndexByName.get(serverName)??0;this.nextIndexByName.set(serverName,next+1);return next}indexAttach(sessionId,id){let ids=this.sessionToEntries.get(sessionId);if(!ids){ids=new Set;this.sessionToEntries.set(sessionId,ids)}ids.add(id)}indexDetach(sessionId,id){const ids=this.sessionToEntries.get(sessionId);if(!ids)return;ids.delete(id);if(ids.size===0)this.sessionToEntries.delete(sessionId)}async createUnpooledConnection(serverName,cfg,sessionId,sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry){const entryIndex=this.allocateEntryIndex(serverName);const id=`${serverName}::unpooled-${entryIndex}`;const transport=mcpTransportOf(cfg);const entryOpts=this.opts.entryOptions(transport);const client=new McpClient(serverName,cfg,sessionToolRegistry,sessionPromptRegistry,this.opts.workspaceContext,this.opts.debugMode,this.opts.sendSdkMcpMessage);const view=new SessionMcpView(sessionToolRegistry,sessionPromptRegistry,sessionResourceRegistry,sessionId,serverName,cfg);const entry=new PoolEntry(id,serverName,entryIndex,cfg,client,this.cliConfig,entryOpts,closedId=>{this.entries.delete(closedId);this.unpooledIds.delete(closedId);if(this.opts.budget!==void 0){if(!this.hasNameSibling(serverName)){this.opts.budget.release(serverName)}}},()=>client.getStatus());try{this.entries.set(id,entry);this.unpooledIds.add(id);this.indexAttach(sessionId,id);const timeoutMs=discoveryTimeoutFor(cfg);const snap=await runWithTimeout((async()=>{await client.connect();return await client.discoverAndReturn(this.cliConfig,{applyConfigFilters:false})})(),timeoutMs,`unpooled spawn for ${id} (pool will roll back the spawn and free its budget slot)`);if(this.draining||!this.entries.has(id)||entry.isTerminated()){try{view.teardown()}catch{}try{await entry.forceShutdown("manual")}catch{}this.indexDetach(sessionId,id);throw new Error(`McpTransportPool is draining or unpooled ${id} was cancelled`)}entry.markActive(snap.tools,snap.prompts,snap.resources);const conn=entry.attach(sessionId,view,{release:__name(()=>{this.indexDetach(sessionId,id);void entry.forceShutdown("manual")},"release")});return conn}catch(err){try{await entry.forceShutdown("manual")}catch{}this.entries.delete(id);this.unpooledIds.delete(id);this.indexDetach(sessionId,id);try{await client.disconnect()}catch{}throw err}}};function poisonedToolRegistry(serverName){return{registerTool(){throw new Error(`Pool invariant violated: poisoned ToolRegistry for ${serverName} received registerTool. A pool path must use discoverAndReturn, not discover.`)}}}__name(poisonedToolRegistry,"poisonedToolRegistry");function poisonedPromptRegistry(serverName){return{registerPrompt(){throw new Error(`Pool invariant violated: poisoned PromptRegistry for ${serverName} received registerPrompt. A pool path must use discoverAndReturn.`)}}}__name(poisonedPromptRegistry,"poisonedPromptRegistry");init_esbuild_shims();var debugLogger4=createDebugLogger("McpPool:Budget");var WorkspaceMcpBudget=class{static{__name(this,"WorkspaceMcpBudget")}clientBudget;mode;onEvent;reservedSlots=new Set;pendingRefusalNames=new Set;pendingRefusalTransports=new Map;lastRefusedServerNames=[];warnArmed=true;bulkPassDepth=0;constructor(opts){this.clientBudget=opts.clientBudget;this.mode=opts.mode;this.onEvent=opts.mode==="off"?void 0:opts.onEvent}getMode(){return this.mode}getBudget(){return this.clientBudget}getReservedSlots(){return Array.from(this.reservedSlots)}getRefusedServerNames(){return this.lastRefusedServerNames}getReservedCount(){return this.reservedSlots.size}tryReserve(serverName){if(this.reservedSlots.has(serverName))return"already_held";if(this.clientBudget===void 0||this.mode==="off"){return"reserved"}if(this.mode==="enforce"&&this.reservedSlots.size>=this.clientBudget){return"refused"}this.reservedSlots.add(serverName);this.evaluateState();return"reserved"}release(serverName){const had=this.reservedSlots.delete(serverName);if(had)this.evaluateState();return had}recordRefusal(serverName,transport){if(this.mode!=="enforce")return;this.pendingRefusalNames.add(serverName);this.pendingRefusalTransports.set(serverName,transport);debugLogger4.warn(`MCP server '${serverName}' refused at pool acquire (budget exhausted, budget=${this.clientBudget}, mode=${this.mode})`);if(this.bulkPassDepth===0){this.flushRefusedBatch()}}beginBulkPass(){if(this.bulkPassDepth===0){this.lastRefusedServerNames=[]}this.bulkPassDepth+=1}endBulkPass(){if(this.bulkPassDepth===0){debugLogger4.warn("WorkspaceMcpBudget.endBulkPass called without matching beginBulkPass; ignoring");return}this.bulkPassDepth-=1;if(this.bulkPassDepth>0)return;this.flushRefusedBatch()}flushRefusedBatch(){if(this.pendingRefusalNames.size===0)return;if(this.clientBudget===void 0||this.mode!=="enforce"){this.pendingRefusalNames.clear();this.pendingRefusalTransports.clear();return}const refusedServers=[];const names=[];for(const name of this.pendingRefusalNames){const transport=this.pendingRefusalTransports.get(name)??"unknown";refusedServers.push({name,transport,reason:"budget_exhausted"});names.push(name)}this.lastRefusedServerNames=Object.freeze(names);this.pendingRefusalNames.clear();this.pendingRefusalTransports.clear();if(this.onEvent){try{this.onEvent({kind:"refused_batch",refusedServers,budget:this.clientBudget,liveCount:this.reservedSlots.size,reservedCount:this.reservedSlots.size,mode:"enforce"})}catch(err){debugLogger4.error(`WorkspaceMcpBudget refused_batch event delivery failed: ${err instanceof Error?err.message:String(err)}`)}}}evaluateState(){if(this.mode==="off"||this.clientBudget===void 0)return;const ratio=this.reservedSlots.size/this.clientBudget;if(this.warnArmed&&ratio>=MCP_BUDGET_WARN_FRACTION){this.warnArmed=false;debugLogger4.info(`MCP workspace budget warning fired (ratio=${ratio.toFixed(2)}, reservedCount=${this.reservedSlots.size}, budget=${this.clientBudget}, mode=${this.mode})`);if(this.onEvent){try{this.onEvent({kind:"budget_warning",liveCount:this.reservedSlots.size,reservedCount:this.reservedSlots.size,budget:this.clientBudget,thresholdRatio:MCP_BUDGET_WARN_FRACTION,mode:this.mode})}catch(err){debugLogger4.error(`WorkspaceMcpBudget budget_warning event delivery failed: ${err instanceof Error?err.message:String(err)}`)}}}else if(!this.warnArmed&&ratio<MCP_BUDGET_REARM_FRACTION){this.warnArmed=true;debugLogger4.info(`MCP workspace budget warning re-armed (ratio=${ratio.toFixed(2)}, budget=${this.clientBudget}; next 75% crossing will fire)`)}}};init_esbuild_shims();function preservePlaceholders(value,resolved,original){if(typeof original==="string"&&value===resolved)return original;if(Array.isArray(value)&&Array.isArray(resolved)&&Array.isArray(original)){return value.map((entry,index)=>preservePlaceholders(entry,resolved[index],original[index]))}if(value&&resolved&&original&&typeof value==="object"&&!Array.isArray(value)&&typeof resolved==="object"&&!Array.isArray(resolved)&&typeof original==="object"&&!Array.isArray(original)){return Object.fromEntries(Object.entries(value).map(([key,entry])=>[key,preservePlaceholders(entry,resolved[key],original[key])]))}return value}__name(preservePlaceholders,"preservePlaceholders");function preserveModelProviderPlaceholders(models,provider,resolvedProviders,rawProviders,mapping){const pairs=Object.entries(resolvedProviders).flatMap(([providerId,entries])=>{if(!Array.isArray(entries))return[];return entries.flatMap((entry,index)=>{const resolved=provider==="openai"?getModelsForProviderProtocol({[providerId]:[entry]},"openai",mapping)[0]:providerId===provider?entry:void 0;return resolved?[{providerId,resolved,source:entry,raw:rawProviders[providerId]?.[index]??entry}]:[]})});return models.map(model=>{const matches=pairs.filter(({resolved})=>resolved.id===model.id&&resolved.baseUrl===model.baseUrl&&tryResolveModelProtocol(provider,resolved,mapping)===tryResolveModelProtocol(provider,model,mapping));const sourceMatches=matches.filter(pair=>pair.providerId===matches[0]?.providerId);if(sourceMatches.length>1&&sourceMatches.some(pair=>JSON.stringify(pair.raw)!==JSON.stringify(pair.source))){throw new Error("Cannot preserve placeholders in an ambiguous model configuration. Remove duplicate model entries first.")}const match=matches[0];return match?preservePlaceholders(model,match.resolved,match.raw):model})}__name(preserveModelProviderPlaceholders,"preserveModelProviderPlaceholders");init_esbuild_shims();init_esbuild_shims();var DISCOVERY_TIMEOUT_MS=5e3;var DISCOVERY_MAX_BYTES=1024*1024;var MAX_MODEL_ID_LENGTH=256;var UNSAFE_MODEL_ID_CHARS=/[,\p{C}\p{Zl}\p{Zp}]/u;function readModels(value){if(!value||typeof value!=="object"||!("data"in value)){return null}const data=value.data;if(!Array.isArray(data)){return null}const models=[];const seen=new Set;for(const item of data){if(!item||typeof item!=="object"||!("id"in item)){return null}const id=item.id;if(typeof id!=="string"){return null}const trimmedId=id.trim();if(trimmedId&&trimmedId.length<=MAX_MODEL_ID_LENGTH&&!UNSAFE_MODEL_ID_CHARS.test(trimmedId)&&!seen.has(trimmedId)){seen.add(trimmedId);const created=item.created;const creationTime=typeof created==="number"&&Number.isFinite(created)&&created>=0?created:void 0;models.push({id:trimmedId,...creationTime===void 0?{}:{created:creationTime}})}}return models.length>0?models:null}__name(readModels,"readModels");function mergeModelSpecs(discoveredModels,staticModels){const staticModelsById=new Map(staticModels.map(model=>[model.id,model]));const orderedModels=[...discoveredModels];if(orderedModels.every(model=>model.created!==void 0)){orderedModels.sort((left,right)=>(right.created??0)-(left.created??0))}return orderedModels.map(({id})=>staticModelsById.get(id)??{id})}__name(mergeModelSpecs,"mergeModelSpecs");async function discoverProviderModels({baseUrl,apiKey,staticModels,signal}){const normalizedBaseUrl=baseUrl.trim();const normalizedApiKey=apiKey.trim();if(!normalizedBaseUrl||!normalizedApiKey){return null}try{const modelsUrl=`${normalizedBaseUrl.replace(/\/+$/,"")}/models`;const result=await fetchWithPolicy(modelsUrl,{timeoutMs:DISCOVERY_TIMEOUT_MS,maxBytes:DISCOVERY_MAX_BYTES,maxRedirects:2,headers:{Accept:"application/json",Authorization:`Bearer ${normalizedApiKey}`},signal});if(result.kind!=="response"||result.status<200||result.status>=300){return null}const models=readModels(JSON.parse(result.body.toString("utf8")));return models?mergeModelSpecs(models,staticModels):null}catch{return null}}__name(discoverProviderModels,"discoverProviderModels");init_esbuild_shims();var IMAGE_CAPABILITY=Object.freeze({autoHandlesWrongModel:true,maxBytes:VISION_BRIDGE_MAX_IMAGE_BASE64_BYTES,maxImagesPerTurn:VISION_BRIDGE_MAX_IMAGES});init_esbuild_shims();var debugLogger5=createDebugLogger("SESSION_RECAP");var RECENT_MESSAGE_WINDOW=30;var RECAP_SYSTEM_PROMPT=`You generate session recaps for a programming assistant CLI.
|
|
4
4
|
|
|
5
5
|
The user stepped away and is coming back. Recap in under 40 words, 1-2 plain sentences, no markdown. Lead with the overall goal and current task, then the one next action. Skip root-cause narrative, fix internals, secondary to-dos, and em-dash tangents.
|
|
6
6
|
|