@qwen-code/qwen-code 0.19.11 → 0.19.12-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/batch/SKILL.md +6 -0
- package/bundled/qc-helper/docs/configuration/model-providers.md +11 -0
- package/bundled/qc-helper/docs/configuration/settings.md +11 -10
- package/bundled/qc-helper/docs/features/channels/overview.md +66 -11
- package/bundled/qc-helper/docs/features/sub-agents.md +8 -8
- package/bundled/qc-helper/docs/features/worktree.md +2 -2
- package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +42 -7
- package/bundled/qc-helper/docs/qwen-serve.md +102 -40
- package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +1 -1
- package/bundled/review/SKILL.md +60 -49
- package/bundled/simplify/SKILL.md +1 -1
- package/chunks/{MaxSizedBox-L6TGYDM3.js → MaxSizedBox-3KIWAU6Z.js} +31 -32
- package/chunks/{StandaloneSessionPicker-AKEQHU5P.js → StandaloneSessionPicker-TF626NO7.js} +45 -46
- package/chunks/acp-startup-profiler-N3RHHXJ3.js +25 -0
- package/chunks/{acpAgent-PTNBGJDN.js → acpAgent-JDVJXVBO.js} +1863 -507
- package/chunks/{agent-AJOMOZPJ.js → agent-BONWC4VY.js} +26 -27
- package/chunks/{agent-headless-CYKOMAXS.js → agent-headless-H7HKMGLZ.js} +26 -27
- package/chunks/{anthropicContentGenerator-HBRXJSP4.js → anthropicContentGenerator-ZZRGFEES.js} +35 -12
- package/chunks/{artifact-tool-MIZLXBLF.js → artifact-tool-PHO5XEGZ.js} +5 -5
- package/chunks/{askUserQuestion-XMJVPNWM.js → askUserQuestion-CEPBT47X.js} +2 -47
- package/chunks/{bridge-QKISWPCI.js → bridge-ATN2TLWJ.js} +31 -32
- package/chunks/{ca-CODEN7TD.js → ca-2SL2BXTK.js} +3 -2
- package/chunks/{channel-worker-group-SOUWTFHC.js → channel-worker-group-S3H5QHTI.js} +4 -4
- package/chunks/{channel-worker-manager-LOVSV3WW.js → channel-worker-manager-ZJ4HTMO2.js} +4 -4
- package/chunks/{channel-worker-supervisor-XW6MHJBQ.js → channel-worker-supervisor-JA6VZ5V5.js} +3 -3
- package/chunks/{chunk-ZIXOTAPZ.js → chunk-2DZ7E27L.js} +92 -3
- package/chunks/{chunk-L5U3ELZX.js → chunk-335ECZTA.js} +1 -1
- package/chunks/{chunk-2FO5GFKZ.js → chunk-3DJY4IFO.js} +1 -1
- package/chunks/{chunk-4AGTGMCQ.js → chunk-3PE7OY2G.js} +12 -12
- package/chunks/{chunk-QOTQH4CB.js → chunk-4AGBO6RB.js} +27 -10
- package/chunks/{chunk-Y66VOBRP.js → chunk-4CA4WUMS.js} +2 -2
- package/chunks/{chunk-LQIDP6K5.js → chunk-4CHDYDG3.js} +1 -1
- package/chunks/{chunk-574PTLMU.js → chunk-4OVECYBM.js} +407 -92
- package/chunks/{chunk-TV6K2FB4.js → chunk-4RPARQ5D.js} +2 -2
- package/chunks/{chunk-TL4R5TRK.js → chunk-4W55BHOC.js} +2 -2
- package/chunks/{chunk-RCEEXIOO.js → chunk-4XCVGEEX.js} +3 -3
- package/chunks/{chunk-3DWIFU7L.js → chunk-53UMEONK.js} +1 -1
- package/chunks/{chunk-AU3MFJPL.js → chunk-54KPEDM2.js} +8 -8
- package/chunks/{chunk-T76DGHGG.js → chunk-66F4IJ4L.js} +5 -5
- package/chunks/{chunk-YLSSEUAM.js → chunk-675SVDMD.js} +354 -278
- package/chunks/{chunk-NVTQZXR7.js → chunk-6QGZVKOO.js} +91 -52
- package/chunks/{chunk-NJOFRXTM.js → chunk-6TDA4EVC.js} +4200 -3450
- package/chunks/{chunk-BYH2JRK3.js → chunk-6WZZHJSZ.js} +5 -5
- package/chunks/{chunk-7X7TEQNX.js → chunk-76BFY7AF.js} +13 -0
- package/chunks/chunk-7KS72E2N.js +883 -0
- package/chunks/{chunk-CF5VJRGC.js → chunk-7LMAKIWE.js} +1 -1
- package/chunks/{chunk-WMNXXRGL.js → chunk-7O7WZH7N.js} +31 -31
- package/chunks/{chunk-7ZYHLN67.js → chunk-7OZGMFHC.js} +26 -75
- package/chunks/{chunk-6WPJRYLZ.js → chunk-7SX6WZNO.js} +3 -3
- package/chunks/{chunk-JGUT3LWZ.js → chunk-ANRANWVE.js} +4 -1
- package/chunks/{chunk-JD44PNGJ.js → chunk-AWOU24F6.js} +10 -5
- package/chunks/{chunk-6WGZDD67.js → chunk-BEFQGC6H.js} +2 -2
- package/chunks/{chunk-KXYJPRT5.js → chunk-BEZPRKD3.js} +28 -6
- package/chunks/{chunk-FYQ22K62.js → chunk-CHVH4DVN.js} +6 -5
- package/chunks/{chunk-LS56TX3M.js → chunk-CMHJEUVB.js} +1 -1
- package/chunks/{chunk-FXKOAEXP.js → chunk-CXWUXRD5.js} +14 -14
- package/chunks/{chunk-CAHY5ABC.js → chunk-DULSE2SH.js} +1 -1
- package/chunks/{chunk-SQ5BK3GO.js → chunk-DYUPBU7H.js} +1 -1
- package/chunks/{chunk-FNX3LGAK.js → chunk-E655RDRL.js} +1 -1
- package/chunks/{chunk-N5VIZTND.js → chunk-EWPLL4OT.js} +1 -1
- package/chunks/{chunk-FSA7ERJ2.js → chunk-F2RR4HO2.js} +1 -1
- package/chunks/{chunk-S63Z5V42.js → chunk-F2YCCUXI.js} +4 -4
- package/chunks/{chunk-3AYLDB6B.js → chunk-FEZXQXW2.js} +1 -1
- package/chunks/{chunk-OWT2CAEQ.js → chunk-GEHSF7MS.js} +105 -12
- package/chunks/{chunk-LXLTBIDP.js → chunk-HCCR43AY.js} +1 -1
- package/chunks/{chunk-7NMU22Q3.js → chunk-HQ7MDVBO.js} +18 -7
- package/chunks/{chunk-KSZKSE23.js → chunk-HVWPSGDY.js} +1 -1
- package/chunks/{chunk-YFVO2HOR.js → chunk-HZXU6YZW.js} +5 -5
- package/chunks/{chunk-HASK4LMI.js → chunk-IKLWU6YS.js} +13 -6
- package/chunks/{chunk-GNBBAQ6J.js → chunk-ILQ42UG6.js} +111 -40
- package/chunks/{chunk-THXDQSTA.js → chunk-IQRQVPGN.js} +49 -154
- package/chunks/{chunk-SPJQO2CE.js → chunk-J2MKYJKZ.js} +2 -2
- package/chunks/{chunk-SUARMD4Q.js → chunk-J6NT5YTN.js} +28 -2
- package/chunks/{chunk-TYLOFD2U.js → chunk-JCJPZMJV.js} +1 -1
- package/chunks/{chunk-BYB3GF2T.js → chunk-JCYMQU5F.js} +133 -6
- package/chunks/{chunk-6EDDYPI3.js → chunk-JUNVFQVY.js} +4 -4
- package/chunks/{chunk-CH2XVB47.js → chunk-K7P34F2J.js} +3 -3
- package/chunks/{chunk-5VWYKIMW.js → chunk-KANTXY7B.js} +2 -2
- package/chunks/{chunk-K7VD4XLT.js → chunk-LHEQDKAR.js} +1 -1
- package/chunks/{chunk-A2HWMJVO.js → chunk-LKR7QQ63.js} +3 -3
- package/chunks/{chunk-4HUDDSO5.js → chunk-LLIGYAQU.js} +4 -4
- package/chunks/{chunk-5Z452MMD.js → chunk-LODZMRXC.js} +154 -83
- package/chunks/{chunk-FBU7WRZI.js → chunk-LPHGXXZX.js} +6 -1
- package/chunks/{chunk-CPFIQVZJ.js → chunk-LYFDJTXE.js} +1 -1
- package/chunks/{chunk-TIOE2OPE.js → chunk-MCYZTKBV.js} +2 -2
- package/chunks/{chunk-ZQIYGQCG.js → chunk-MHEZV3OY.js} +506 -143
- package/chunks/{chunk-JWICTOXS.js → chunk-NGTQA57Y.js} +2 -2
- package/chunks/{chunk-5CNYZ7TN.js → chunk-NJQPQ4IO.js} +7 -7
- package/chunks/chunk-NSZJQACR.js +45 -0
- package/chunks/{chunk-DOPUYNXO.js → chunk-NUHSLBJZ.js} +7 -7
- package/chunks/{chunk-CITWNIXJ.js → chunk-NVUGS23Y.js} +5 -5
- package/chunks/{chunk-2Z5UX4KI.js → chunk-OSSDHJDU.js} +1 -1
- package/chunks/{chunk-YUZI3WAC.js → chunk-OWAK7LMW.js} +7 -0
- package/chunks/{chunk-Y3KFTWVX.js → chunk-OZWJAFFE.js} +6 -6
- package/chunks/{chunk-YGYSMY2R.js → chunk-PSISZNIT.js} +1629 -1142
- package/chunks/{chunk-4ROQY23C.js → chunk-PTXVHS2O.js} +7 -7
- package/chunks/{chunk-OKAIGAYW.js → chunk-QGONRHUS.js} +3 -3
- package/chunks/{chunk-PZL23GTM.js → chunk-QR6U5QPP.js} +8 -0
- package/chunks/chunk-QSG4ZFG4.js +257 -0
- package/chunks/{chunk-BXBDC476.js → chunk-R32BTEZY.js} +5 -5
- package/chunks/{chunk-AVEOWVOM.js → chunk-R3VWUU2E.js} +1 -1
- package/chunks/{chunk-RP5R7MB6.js → chunk-R4RIMOJL.js} +12 -12
- package/chunks/{chunk-ARKANCNX.js → chunk-SGPFJMRP.js} +1 -1
- package/chunks/{chunk-3M75MSVA.js → chunk-SMASS3CY.js} +1 -1
- package/chunks/{chunk-4IJMTYCB.js → chunk-SNONG66P.js} +818 -29
- package/chunks/chunk-TDKQP3M6.js +201 -0
- package/chunks/{chunk-VFX7EZIR.js → chunk-TFV3XVAZ.js} +8 -1
- package/chunks/{chunk-4LD5APFL.js → chunk-TYQMGACW.js} +1 -0
- package/chunks/{chunk-7NFB7LBQ.js → chunk-UE5TZ55T.js} +8 -0
- package/chunks/{chunk-F333XEAU.js → chunk-UOA2IHRI.js} +4 -3
- package/chunks/{chunk-VRR65QYW.js → chunk-V4PCIS25.js} +5 -1
- package/chunks/{chunk-WIEO4CWB.js → chunk-VAJS2E2D.js} +1 -1
- package/chunks/{chunk-GLNHPRZT.js → chunk-W4DFAUAO.js} +1 -1
- package/chunks/{chunk-STZQCNN3.js → chunk-W7H223ZZ.js} +1 -1
- package/chunks/{chunk-6Y6ORE2G.js → chunk-WACI4VES.js} +288 -20
- package/chunks/{chunk-WTNZ6DXB.js → chunk-WEPXQKGP.js} +1 -1
- package/chunks/{chunk-4BJVSIS3.js → chunk-WHQNBBWW.js} +2 -2
- package/chunks/{chunk-QDJ2R4CM.js → chunk-WTHRMVKB.js} +3 -3
- package/chunks/{chunk-L4Y55KIS.js → chunk-X6YQWCIJ.js} +1 -1
- package/chunks/{chunk-Q6TUALBE.js → chunk-XAAEDML2.js} +1 -1
- package/chunks/{chunk-BUAXJVNP.js → chunk-XACBIZJB.js} +3 -3
- package/chunks/{chunk-2OG646IN.js → chunk-XFJU7SVP.js} +4 -4
- package/chunks/{chunk-KKRTYONM.js → chunk-XSPFQQRE.js} +3 -3
- package/chunks/{chunk-V2DXTLUE.js → chunk-Y5UDBQYF.js} +3 -3
- package/chunks/{chunk-MQOVXZAF.js → chunk-YN2I5I42.js} +529 -61
- package/chunks/{chunk-FMNYGWOD.js → chunk-Z4ZCVYJ5.js} +14 -8
- package/chunks/{chunk-SY7NEYX4.js → chunk-ZFHHBRRA.js} +2 -2
- package/chunks/{chunk-QYG4BY6Q.js → chunk-ZPVGEMVC.js} +1 -1
- package/chunks/{computer-use-VZZMJEQ7.js → computer-use-UY4A72X7.js} +26 -27
- package/chunks/{config-utils-IQQT3GCI.js → config-utils-KWTRFP7D.js} +3 -3
- package/chunks/{contextCommand-PORKIZSY.js → contextCommand-3DZ2SVH6.js} +30 -31
- package/chunks/{create-sub-session-EAB2U5XW.js → create-sub-session-DIJOV6HV.js} +2 -2
- package/chunks/{create-sub-session-XVFKHAFW.js → create-sub-session-OT7WXLDO.js} +27 -28
- package/chunks/{cron-create-GMVKSXZT.js → cron-create-X462ERYA.js} +4 -4
- package/chunks/{cron-delete-VDZKUAVK.js → cron-delete-SL5UJUM3.js} +4 -4
- package/chunks/{cron-list-UG7C7RAR.js → cron-list-3MD6SVXI.js} +4 -4
- package/chunks/{daemon-IHR6WSPB.js → daemon-ZW6LHOXT.js} +91 -14
- package/chunks/{daemon-status-provider-ABLBA3UJ.js → daemon-status-provider-GTZOYSBO.js} +35 -36
- package/chunks/{de-NOXPCSYN.js → de-I7ZIYXZC.js} +3 -2
- package/chunks/{dist-PX2ERZ6I.js → dist-HCUUS6IH.js} +2 -2
- package/chunks/{dist-VYWUKURL.js → dist-O2IP3G5D.js} +1 -1
- package/chunks/{dist-GXJVCOS7.js → dist-RZBJT5O2.js} +2 -1
- package/chunks/{dist-V2YVLYOW.js → dist-Y54RURGT.js} +3 -1
- package/chunks/{dist-DOPL5LSQ.js → dist-YTPTCUAD.js} +1 -1
- package/chunks/{dist-4WCQEZIN.js → dist-ZJHKKWUD.js} +1 -1
- package/chunks/{earlyInputCapture-DJCU5SPU.js → earlyInputCapture-GGWVGBZ7.js} +27 -28
- package/chunks/{edit-O4VV5AO6.js → edit-JN467GIR.js} +27 -28
- package/chunks/{en-JFVULHTB.js → en-XE34GKAA.js} +7 -3
- package/chunks/{enter-worktree-XQYDDI2I.js → enter-worktree-MMO4VBQE.js} +26 -27
- package/chunks/{enterPlanMode-CESVMQBV.js → enterPlanMode-BRZOG4DB.js} +27 -30
- package/chunks/{environment-5KXOLZNR.js → environment-LOCDCWMZ.js} +29 -30
- package/chunks/{errors-EBUTCBAQ.js → errors-XXSL5HGG.js} +29 -30
- package/chunks/{exit-worktree-MWGNSPNX.js → exit-worktree-UD7PI5H5.js} +26 -27
- package/chunks/exitPlanMode-EIUETQI6.js +389 -0
- package/chunks/{fast-path-6V73F2T2.js → fast-path-ULGAEUVK.js} +2 -2
- package/chunks/{fr-HVFNU42H.js → fr-X7KDVZIY.js} +3 -2
- package/chunks/{gemini-TEFJZCIZ.js → gemini-KW3APZ4P.js} +133 -80
- package/chunks/{geminiContentGenerator-M56BEXWI.js → geminiContentGenerator-4BQ5QHPR.js} +5 -5
- package/chunks/{glob-DMYFEEAZ.js → glob-FPKAMR6B.js} +32 -28
- package/chunks/{grep-GYE47MD4.js → grep-MOGRCYB4.js} +32 -28
- package/chunks/{handleAutoUpdate-OLUY4L7L.js → handleAutoUpdate-QUMRZZOS.js} +33 -34
- package/chunks/{i18n-462JC7IY.js → i18n-F3W6YUYP.js} +28 -29
- package/chunks/{initializer-Y7WD4D2I.js → initializer-KLU2KAIZ.js} +33 -34
- package/chunks/{installationInfo-I2Z3BKCE.js → installationInfo-P3ZP2SIZ.js} +27 -28
- package/chunks/{ja-PY5AF544.js → ja-2ICT3KXF.js} +3 -2
- package/chunks/{keychain-token-storage-AU22CQI6.js → keychain-token-storage-K23CFKGN.js} +2 -2
- package/chunks/{list-XQ5MSAXP.js → list-4X6D5JD2.js} +35 -36
- package/chunks/{loadedSettingsAdapter-TQOWYE7C.js → loadedSettingsAdapter-446B6WKA.js} +32 -33
- package/chunks/{loop-wakeup-QXWZSCYM.js → loop-wakeup-6H7OENTB.js} +5 -5
- package/chunks/{ls-2OUTG3IZ.js → ls-APTSOOS5.js} +4 -4
- package/chunks/{lsp-4VMNXZW6.js → lsp-HPACPJAN.js} +2 -2
- package/chunks/{mcp-22LLEEVM.js → mcp-JYVOJZOD.js} +32 -33
- package/chunks/{monitor-VKG324X3.js → monitor-KY7YH7TL.js} +26 -27
- package/chunks/nonInteractiveCli-EK35TLVJ.js +129 -0
- package/chunks/{notebook-edit-FJJRBQ3S.js → notebook-edit-IHGW42QK.js} +27 -28
- package/chunks/{openaiContentGenerator-4T2OGTR5.js → openaiContentGenerator-FURUCKQJ.js} +13 -14
- package/chunks/{pidfile-XL3MDCBM.js → pidfile-WKUVXDMR.js} +27 -28
- package/chunks/{processUtils-7UCFN34D.js → processUtils-LHSRN76X.js} +2 -2
- package/chunks/{pt-A3PRQXMU.js → pt-JJ4XPIBP.js} +3 -2
- package/chunks/{qwenContentGenerator-PQUXJDIZ.js → qwenContentGenerator-NRLM7R36.js} +30 -31
- package/chunks/{qwenOAuth2-LEYOU7RU.js → qwenOAuth2-5FNX3AWH.js} +22 -5
- package/chunks/{read-file-3EYQML7E.js → read-file-VLEAEXFP.js} +9 -10
- package/chunks/{read-mcp-resource-JUFHCKSC.js → read-mcp-resource-C6NT52T6.js} +2 -2
- package/chunks/{record-artifact-DWSMBXYY.js → record-artifact-ENCU7QCL.js} +2 -2
- package/chunks/{ripGrep-S6WPGQNA.js → ripGrep-MT23EIDD.js} +26 -27
- package/chunks/{ru-IBCWUTOC.js → ru-STR4KTW7.js} +3 -2
- package/chunks/{run-qwen-serve-NSKBT3HU.js → run-qwen-serve-5HWOQFLI.js} +63 -47
- package/chunks/{runtime-LG5ZZ3VH.js → runtime-6IVKJSLW.js} +38 -37
- package/chunks/{scheduler-PLX3VVTB.js → scheduler-63GJG75U.js} +26 -27
- package/chunks/{send-message-JZ752NWD.js → send-message-5GZ4FX2V.js} +3 -3
- package/chunks/{serve-S2ZLRZZR.js → serve-3LL7RRDP.js} +32 -33
- package/chunks/{server-5ECMV4TM.js → server-AA24QLPA.js} +1672 -615
- package/chunks/{session-ILSONWG4.js → session-LRVCFQQQ.js} +102 -75
- package/chunks/{settings-BOE7WWSA.js → settings-ZX3OKUT4.js} +36 -37
- package/chunks/{shell-VW664JIZ.js → shell-KR3IMYH6.js} +26 -27
- package/chunks/{skill-COHV6625.js → skill-QLM2LSF7.js} +11 -12
- package/chunks/{spawnChannel-5UUR5XOZ.js → spawnChannel-6WFOK3SA.js} +28 -29
- package/chunks/{src-XPKFZ3RN.js → src-ADLNIPHD.js} +101 -72
- package/chunks/{standalone-update-IOOJ2NZQ.js → standalone-update-C54OTJWJ.js} +29 -30
- package/chunks/{startInteractiveUI-3NGJGXXS.js → startInteractiveUI-KFAOS6HC.js} +2342 -1796
- package/chunks/{stdioHelpers-UMY72QRP.js → stdioHelpers-HGIYTWAY.js} +3 -1
- package/chunks/{syntheticOutput-LELY6HAI.js → syntheticOutput-ULOVVLY4.js} +3 -3
- package/chunks/{task-create-QY3BIMNM.js → task-create-DUE2PMNI.js} +7 -7
- package/chunks/{task-list-D2U47WBJ.js → task-list-WVPNX7BZ.js} +5 -5
- package/chunks/{task-stop-N6E5IYLH.js → task-stop-CPEQWOT6.js} +2 -2
- package/chunks/{task-update-HJCQILLB.js → task-update-HY2LNFFB.js} +7 -7
- package/chunks/{team-create-UPLVZQFX.js → team-create-Q5B5M7UD.js} +26 -27
- package/chunks/{team-delete-RCWYDRF4.js → team-delete-JJV6IUOA.js} +5 -5
- package/chunks/{team-plan-approval-F5F432RO.js → team-plan-approval-J55PXNY2.js} +26 -27
- package/chunks/{theme-manager-JJE4BJ67.js → theme-manager-QWTDRPHV.js} +27 -28
- package/chunks/todoWrite-JHHIDOIV.js +358 -0
- package/chunks/{tool-search-LRXI4JLZ.js → tool-search-LSSKWZKH.js} +10 -11
- package/chunks/{total-session-admission-I4DHN6UP.js → total-session-admission-S6ATY5HY.js} +32 -33
- package/chunks/{trustedFolders-SEH7LNX2.js → trustedFolders-CY4TUPDJ.js} +28 -29
- package/chunks/turndown.cjs-FZHGMUTY.js +17670 -0
- package/chunks/{update-relaunch-T6ZKBUA6.js → update-relaunch-IOKOUV3K.js} +6 -6
- package/chunks/{updateCheck-FWLXZPRO.js → updateCheck-YNRFE4V7.js} +30 -31
- package/chunks/{validateNonInterActiveAuth-X6K2VWYT.js → validateNonInterActiveAuth-OXTECS4B.js} +68 -68
- package/chunks/{version-LIFSOGSE.js → version-2CZQQDL5.js} +1 -1
- package/chunks/web-fetch-7QTEGJI5.js +938 -0
- package/chunks/{workflow-NX2DFWGD.js → workflow-G3CZU256.js} +29 -30
- package/chunks/{workspace-providers-status-VYD6M2NE.js → workspace-providers-status-UHQOIPAZ.js} +35 -36
- package/chunks/{workspace-registration-store-2Y6PWOEL.js → workspace-registration-store-5WPCMX4F.js} +1 -1
- package/chunks/{workspace-registry-PKBDBWCA.js → workspace-registry-LAQCRQTH.js} +32 -33
- package/chunks/{workspace-service-HHORUHTS.js → workspace-service-6ZEUJY2Z.js} +38 -39
- package/chunks/{workspace-skills-status-O5Q26LIY.js → workspace-skills-status-YG6OITSM.js} +33 -34
- package/chunks/{write-file-NVAEZ3J2.js → write-file-E7T3PU3B.js} +60 -28
- package/chunks/{zh-PAUNIMHQ.js → zh-6ANG2HTL.js} +7 -3
- package/chunks/{zh-TW-GNEUIUFF.js → zh-TW-4RR3YHNN.js} +7 -3
- package/cli-entry.js +37 -2
- package/cli.js +17 -11
- package/locales/ca.js +3 -2
- package/locales/de.js +3 -2
- package/locales/en.js +10 -5
- package/locales/fr.js +3 -2
- package/locales/ja.js +3 -2
- package/locales/pt.js +3 -2
- package/locales/ru.js +3 -2
- package/locales/zh-TW.js +9 -3
- package/locales/zh.js +9 -3
- package/package.json +3 -3
- package/web-shell/assets/{arc-H74fE8UR.js → arc-_dVIKMdB.js} +1 -1
- package/web-shell/assets/{architectureDiagram-3BPJPVTR-DN3kEq-I.js → architectureDiagram-3BPJPVTR-MuN3nKpL.js} +1 -1
- package/web-shell/assets/{blockDiagram-GPEHLZMM-BrqbsFUF.js → blockDiagram-GPEHLZMM-BtmvJjzx.js} +1 -1
- package/web-shell/assets/{c4Diagram-AAUBKEIU-ClFhU1P-.js → c4Diagram-AAUBKEIU-Dvi58_BU.js} +1 -1
- package/web-shell/assets/channel-Bi5TehaT.js +1 -0
- package/web-shell/assets/{chunk-2J33WTMH-jCIcG0_M.js → chunk-2J33WTMH-YqxOVhS1.js} +1 -1
- package/web-shell/assets/{chunk-4BX2VUAB-DSkGe62-.js → chunk-4BX2VUAB-DoBgbC9z.js} +1 -1
- package/web-shell/assets/{chunk-55IACEB6-BxBHOGTd.js → chunk-55IACEB6-3NEQrBAr.js} +1 -1
- package/web-shell/assets/{chunk-727SXJPM-v_DS7dH7.js → chunk-727SXJPM-DrCZQxp0.js} +1 -1
- package/web-shell/assets/{chunk-AQP2D5EJ-1RzEKRPq.js → chunk-AQP2D5EJ-m_g3zjgv.js} +1 -1
- package/web-shell/assets/{chunk-FMBD7UC4-DyrSbLOX.js → chunk-FMBD7UC4-D1_crABJ.js} +1 -1
- package/web-shell/assets/{chunk-ND2GUHAM-BCmdsZiy.js → chunk-ND2GUHAM-BdhgVtBx.js} +1 -1
- package/web-shell/assets/{chunk-QZHKN3VN-CphHGW2D.js → chunk-QZHKN3VN-BlmThhm-.js} +1 -1
- package/web-shell/assets/classDiagram-4FO5ZUOK-BKhhRdd1.js +1 -0
- package/web-shell/assets/classDiagram-v2-Q7XG4LA2-BKhhRdd1.js +1 -0
- package/web-shell/assets/{cose-bilkent-S5V4N54A-D5kRC7Fi.js → cose-bilkent-S5V4N54A-Cbjm_00Z.js} +1 -1
- package/web-shell/assets/{dagre-BM42HDAG-DIiyJJ0U.js → dagre-BM42HDAG-C39QNVgC.js} +1 -1
- package/web-shell/assets/{diagram-2AECGRRQ-BOcuB8xU.js → diagram-2AECGRRQ-DNXSAixC.js} +1 -1
- package/web-shell/assets/{diagram-5GNKFQAL-CMgiZ4d3.js → diagram-5GNKFQAL-BCbGUPEA.js} +1 -1
- package/web-shell/assets/{diagram-KO2AKTUF-Ctx8pfN0.js → diagram-KO2AKTUF-1eujKSDC.js} +1 -1
- package/web-shell/assets/{diagram-LMA3HP47-BT5REAWC.js → diagram-LMA3HP47-DUMKXgql.js} +1 -1
- package/web-shell/assets/{diagram-OG6HWLK6-CJkUqXcp.js → diagram-OG6HWLK6-BFktU3_u.js} +1 -1
- package/web-shell/assets/{erDiagram-TEJ5UH35-DyvNNX6v.js → erDiagram-TEJ5UH35-BvJC7DLk.js} +1 -1
- package/web-shell/assets/{flowDiagram-I6XJVG4X-VBf8_My8.js → flowDiagram-I6XJVG4X-Cgu3PlOt.js} +1 -1
- package/web-shell/assets/{ganttDiagram-6RSMTGT7-CviJnR7B.js → ganttDiagram-6RSMTGT7-DLNXN5Xh.js} +1 -1
- package/web-shell/assets/{gitGraphDiagram-PVQCEYII-BY66_Oze.js → gitGraphDiagram-PVQCEYII-BQFRDv6R.js} +1 -1
- package/web-shell/assets/index-C_ouplMQ.js +1187 -0
- package/web-shell/assets/{index-DhYuvi3j.js → index-CdC3pjP3.js} +1 -1
- package/web-shell/assets/index-XGDFJE-X.css +5 -0
- package/web-shell/assets/{infoDiagram-5YYISTIA-D2jaewWZ.js → infoDiagram-5YYISTIA-DT2mOSvp.js} +1 -1
- package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-BpnNTyi5.js → ishikawaDiagram-YF4QCWOH-9fy_K4bd.js} +1 -1
- package/web-shell/assets/{journeyDiagram-JHISSGLW-CA55GNZF.js → journeyDiagram-JHISSGLW-CoGSEuhE.js} +1 -1
- package/web-shell/assets/{kanban-definition-UN3LZRKU-DyiSl_Ts.js → kanban-definition-UN3LZRKU-BP9hHYIj.js} +1 -1
- package/web-shell/assets/{linear-B-sN3dkV.js → linear-uIroDsmp.js} +1 -1
- package/web-shell/assets/{mermaid.core-xf9SXDdb.js → mermaid.core-BUwoStsA.js} +5 -5
- package/web-shell/assets/{mindmap-definition-RKZ34NQL-DXhr2kRk.js → mindmap-definition-RKZ34NQL-DZB-FWim.js} +1 -1
- package/web-shell/assets/{pieDiagram-4H26LBE5-DUXpbfGQ.js → pieDiagram-4H26LBE5-YPptloKl.js} +1 -1
- package/web-shell/assets/{quadrantDiagram-W4KKPZXB-NeDQYeWw.js → quadrantDiagram-W4KKPZXB-dgk3DSzm.js} +1 -1
- package/web-shell/assets/{requirementDiagram-4Y6WPE33-BSbFRL1A.js → requirementDiagram-4Y6WPE33-BH2En2i9.js} +1 -1
- package/web-shell/assets/{sankeyDiagram-5OEKKPKP-gg27cAaN.js → sankeyDiagram-5OEKKPKP-BB98feeI.js} +1 -1
- package/web-shell/assets/{sequenceDiagram-3UESZ5HK-Bi_1TSs4.js → sequenceDiagram-3UESZ5HK-CunAIGh8.js} +1 -1
- package/web-shell/assets/{stateDiagram-AJRCARHV-CboCCRaf.js → stateDiagram-AJRCARHV-DTJs_-I2.js} +1 -1
- package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DrfFMYta.js +1 -0
- package/web-shell/assets/{timeline-definition-PNZ67QCA-DrGpF_jn.js → timeline-definition-PNZ67QCA-Cd4AN7O0.js} +1 -1
- package/web-shell/assets/{vennDiagram-CIIHVFJN-DCaJU67x.js → vennDiagram-CIIHVFJN-xIG-rUU9.js} +1 -1
- package/web-shell/assets/{wardley-L42UT6IY-p0QcW1aP.js → wardley-L42UT6IY-D1UyjIcG.js} +1 -1
- package/web-shell/assets/{wardleyDiagram-YWT4CUSO-DiEVxj1W.js → wardleyDiagram-YWT4CUSO-BVM0Mb99.js} +1 -1
- package/web-shell/assets/{xychartDiagram-2RQKCTM6-iQB8nSlA.js → xychartDiagram-2RQKCTM6-BX31JDSz.js} +1 -1
- package/web-shell/index.html +2 -2
- package/chunks/chunk-2HRYPZT5.js +0 -25
- package/chunks/chunk-QAW7PIHT.js +0 -168
- package/chunks/chunk-RTV5TUYB.js +0 -143
- package/chunks/chunk-ZPAHLFZU.js +0 -172
- package/chunks/exitPlanMode-HYQL4XMB.js +0 -909
- package/chunks/nonInteractiveCli-UMYUT643.js +0 -129
- package/chunks/todoWrite-FKCGATPJ.js +0 -531
- package/chunks/web-fetch-CFCWTCAP.js +0 -5673
- package/web-shell/assets/channel-NFC5ADAa.js +0 -1
- package/web-shell/assets/classDiagram-4FO5ZUOK-DHgwjz3X.js +0 -1
- package/web-shell/assets/classDiagram-v2-Q7XG4LA2-DHgwjz3X.js +0 -1
- package/web-shell/assets/index-8xIBbHV3.js +0 -1143
- package/web-shell/assets/index-DLyhlZZO.css +0 -5
- package/web-shell/assets/stateDiagram-v2-BHNVJYJU-CXRqms6P.js +0 -1
|
@@ -0,0 +1,883 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import {
|
|
4
|
+
getRateLimitErrorDetails,
|
|
5
|
+
getRetryAfterDelayMs,
|
|
6
|
+
getRetryDelayMs,
|
|
7
|
+
isQwenQuotaExceededError,
|
|
8
|
+
isRateLimitError,
|
|
9
|
+
retryContext
|
|
10
|
+
} from "./chunk-YN2I5I42.js";
|
|
11
|
+
import {
|
|
12
|
+
isTlsVerificationDisabled
|
|
13
|
+
} from "./chunk-4CHDYDG3.js";
|
|
14
|
+
import {
|
|
15
|
+
createDebugLogger,
|
|
16
|
+
getErrorMessage,
|
|
17
|
+
getErrorStatus,
|
|
18
|
+
isAbortError
|
|
19
|
+
} from "./chunk-UE5TZ55T.js";
|
|
20
|
+
import {
|
|
21
|
+
init_esbuild_shims
|
|
22
|
+
} from "./chunk-5O2XNYP6.js";
|
|
23
|
+
import {
|
|
24
|
+
__name
|
|
25
|
+
} from "./chunk-J2S4EL5Y.js";
|
|
26
|
+
|
|
27
|
+
// packages/core/src/utils/retry.ts
|
|
28
|
+
init_esbuild_shims();
|
|
29
|
+
|
|
30
|
+
// packages/core/src/utils/retryErrorClassification.ts
|
|
31
|
+
init_esbuild_shims();
|
|
32
|
+
function classifyRetryError(error, context = {}) {
|
|
33
|
+
if (isRetryAbortError(error)) {
|
|
34
|
+
return {
|
|
35
|
+
kind: "abort",
|
|
36
|
+
diagnosis: "fail-fast",
|
|
37
|
+
reason: "aborted"
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const details = getRateLimitErrorDetails(error);
|
|
41
|
+
const statusCode = details.statusCode;
|
|
42
|
+
const providerFields = getProviderFields(error);
|
|
43
|
+
const providerCode = details.providerCode ?? providerFields.providerCode;
|
|
44
|
+
const providerMessage = details.providerMessage ?? providerFields.providerMessage;
|
|
45
|
+
const requestId = details.requestId ?? providerFields.requestId;
|
|
46
|
+
const common = {
|
|
47
|
+
...statusCode !== void 0 ? { statusCode } : {},
|
|
48
|
+
...providerCode !== void 0 ? { providerCode } : {},
|
|
49
|
+
...providerMessage !== void 0 ? { providerMessage } : {},
|
|
50
|
+
...requestId !== void 0 ? { requestId } : {}
|
|
51
|
+
};
|
|
52
|
+
if (context.authType === "qwen-oauth" /* QWEN_OAUTH */ && isQwenQuotaExceededError(error)) {
|
|
53
|
+
return {
|
|
54
|
+
kind: "provider-business",
|
|
55
|
+
diagnosis: "fail-fast",
|
|
56
|
+
reason: "qwen-oauth-free-tier-quota",
|
|
57
|
+
...common
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (isAllocatedQuotaExceeded(providerCode)) {
|
|
61
|
+
return {
|
|
62
|
+
kind: "provider-business",
|
|
63
|
+
diagnosis: "fail-fast",
|
|
64
|
+
reason: "allocated-quota-exceeded",
|
|
65
|
+
...common
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (isRateLimitError(error, context.extraRetryErrorCodes)) {
|
|
69
|
+
const kind = details.transport === "sse" ? "sse-provider" : statusCode !== void 0 ? "http" : "provider";
|
|
70
|
+
return {
|
|
71
|
+
kind,
|
|
72
|
+
diagnosis: "retryable",
|
|
73
|
+
reason: "rate-limit",
|
|
74
|
+
...common
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const transportCode = getTransportCode(error);
|
|
78
|
+
if (transportCode !== void 0 && (statusCode === void 0 || statusCode >= 500)) {
|
|
79
|
+
return {
|
|
80
|
+
kind: "transport",
|
|
81
|
+
diagnosis: "retryable",
|
|
82
|
+
reason: "transport-error",
|
|
83
|
+
transportCode,
|
|
84
|
+
...statusCode !== void 0 ? { statusCode } : {}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (statusCode !== void 0) {
|
|
88
|
+
const kind = details.transport === "sse" ? "sse-provider" : "http";
|
|
89
|
+
if (statusCode === 529) {
|
|
90
|
+
return {
|
|
91
|
+
kind,
|
|
92
|
+
diagnosis: "retryable",
|
|
93
|
+
reason: "capacity-overload",
|
|
94
|
+
...common
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (statusCode === 401 || statusCode === 403) {
|
|
98
|
+
return {
|
|
99
|
+
kind,
|
|
100
|
+
diagnosis: "fail-fast",
|
|
101
|
+
reason: "auth-error",
|
|
102
|
+
...common
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (statusCode >= 400 && statusCode < 500) {
|
|
106
|
+
return {
|
|
107
|
+
kind,
|
|
108
|
+
diagnosis: "fail-fast",
|
|
109
|
+
reason: "client-error",
|
|
110
|
+
...common
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (statusCode >= 500 && statusCode < 600) {
|
|
114
|
+
return {
|
|
115
|
+
kind,
|
|
116
|
+
diagnosis: "retryable",
|
|
117
|
+
reason: "server-error",
|
|
118
|
+
...common
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
kind,
|
|
123
|
+
diagnosis: "unknown",
|
|
124
|
+
reason: "http-status",
|
|
125
|
+
...common
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
kind: "unknown",
|
|
130
|
+
diagnosis: "unknown",
|
|
131
|
+
reason: "unclassified",
|
|
132
|
+
...common
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
__name(classifyRetryError, "classifyRetryError");
|
|
136
|
+
function isRetryAbortError(error) {
|
|
137
|
+
if (isAbortError(error)) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
return error instanceof Error && error.name === "CanceledError";
|
|
141
|
+
}
|
|
142
|
+
__name(isRetryAbortError, "isRetryAbortError");
|
|
143
|
+
function getTransportCode(error) {
|
|
144
|
+
if (typeof error !== "object" || error === null) {
|
|
145
|
+
return void 0;
|
|
146
|
+
}
|
|
147
|
+
const directCode = error.code;
|
|
148
|
+
if (typeof directCode === "string" && isTransportCode(directCode)) {
|
|
149
|
+
return directCode;
|
|
150
|
+
}
|
|
151
|
+
const cause = error instanceof Error ? error.cause : void 0;
|
|
152
|
+
if (typeof cause === "object" && cause !== null) {
|
|
153
|
+
const causeCode = cause.code;
|
|
154
|
+
if (typeof causeCode === "string" && isTransportCode(causeCode)) {
|
|
155
|
+
return causeCode;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return void 0;
|
|
159
|
+
}
|
|
160
|
+
__name(getTransportCode, "getTransportCode");
|
|
161
|
+
function isTransportCode(code) {
|
|
162
|
+
return TRANSPORT_ERROR_CODES.has(code);
|
|
163
|
+
}
|
|
164
|
+
__name(isTransportCode, "isTransportCode");
|
|
165
|
+
var TRANSPORT_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
166
|
+
"EAI_AGAIN",
|
|
167
|
+
"ECONNABORTED",
|
|
168
|
+
"ECONNREFUSED",
|
|
169
|
+
"ECONNRESET",
|
|
170
|
+
"EHOSTUNREACH",
|
|
171
|
+
"ENETUNREACH",
|
|
172
|
+
"ENOTFOUND",
|
|
173
|
+
"EPIPE",
|
|
174
|
+
"ETIMEDOUT",
|
|
175
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
176
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
177
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
178
|
+
"UND_ERR_SOCKET"
|
|
179
|
+
]);
|
|
180
|
+
function isAllocatedQuotaExceeded(providerCode) {
|
|
181
|
+
return providerCode === "Throttling.AllocationQuota";
|
|
182
|
+
}
|
|
183
|
+
__name(isAllocatedQuotaExceeded, "isAllocatedQuotaExceeded");
|
|
184
|
+
function getProviderFields(error) {
|
|
185
|
+
if (typeof error !== "object" || error === null) {
|
|
186
|
+
return {};
|
|
187
|
+
}
|
|
188
|
+
const source = error;
|
|
189
|
+
const rawCode = typeof source.code === "string" || typeof source.code === "number" ? String(source.code) : void 0;
|
|
190
|
+
const isHttpStatusEcho = typeof source.code === "number" && source.code >= 100 && source.code < 600;
|
|
191
|
+
const providerCode = error instanceof Error && rawCode?.startsWith("ERR_") || isHttpStatusEcho ? void 0 : rawCode;
|
|
192
|
+
const requestId = typeof source.request_id === "string" ? source.request_id : typeof source.requestId === "string" ? source.requestId : void 0;
|
|
193
|
+
const providerMessage = typeof source.message === "string" && (!(error instanceof Error) || providerCode !== void 0 || requestId !== void 0) ? source.message : void 0;
|
|
194
|
+
return {
|
|
195
|
+
...providerCode !== void 0 ? { providerCode } : {},
|
|
196
|
+
...providerMessage !== void 0 ? { providerMessage } : {},
|
|
197
|
+
...requestId !== void 0 ? { requestId } : {}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
__name(getProviderFields, "getProviderFields");
|
|
201
|
+
var FALLBACK_ELIGIBLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 503, 529]);
|
|
202
|
+
function isFallbackEligible(classification) {
|
|
203
|
+
return classification.kind !== "transport" && classification.statusCode !== void 0 && FALLBACK_ELIGIBLE_STATUS_CODES.has(classification.statusCode) && classification.diagnosis !== "fail-fast" && classification.diagnosis !== "unknown";
|
|
204
|
+
}
|
|
205
|
+
__name(isFallbackEligible, "isFallbackEligible");
|
|
206
|
+
|
|
207
|
+
// packages/core/src/utils/retry.ts
|
|
208
|
+
var debugLogger = createDebugLogger("RETRY");
|
|
209
|
+
var PERSISTENT_MAX_BACKOFF_MS = 5 * 60 * 1e3;
|
|
210
|
+
var PERSISTENT_CAP_MS = 6 * 60 * 60 * 1e3;
|
|
211
|
+
var HEARTBEAT_INTERVAL_MS = 3e4;
|
|
212
|
+
var DEFAULT_RETRY_OPTIONS = {
|
|
213
|
+
maxAttempts: 7,
|
|
214
|
+
initialDelayMs: 1500,
|
|
215
|
+
maxDelayMs: 3e4,
|
|
216
|
+
// 30 seconds
|
|
217
|
+
shouldRetryOnError: defaultShouldRetry
|
|
218
|
+
};
|
|
219
|
+
function defaultShouldRetry(error, extraRetryErrorCodes) {
|
|
220
|
+
const status = getErrorStatus(error);
|
|
221
|
+
return isRateLimitError(error, extraRetryErrorCodes) || status !== void 0 && status >= 500 && status < 600;
|
|
222
|
+
}
|
|
223
|
+
__name(defaultShouldRetry, "defaultShouldRetry");
|
|
224
|
+
function hasRetryAfterStatus(status) {
|
|
225
|
+
return status === 429 || status === 503;
|
|
226
|
+
}
|
|
227
|
+
__name(hasRetryAfterStatus, "hasRetryAfterStatus");
|
|
228
|
+
function isTransientCapacityError(error) {
|
|
229
|
+
const status = getErrorStatus(error);
|
|
230
|
+
return status === 429 || status === 529;
|
|
231
|
+
}
|
|
232
|
+
__name(isTransientCapacityError, "isTransientCapacityError");
|
|
233
|
+
function isUnattendedMode() {
|
|
234
|
+
const val = process.env["QWEN_CODE_UNATTENDED_RETRY"];
|
|
235
|
+
return val === "true" || val === "1";
|
|
236
|
+
}
|
|
237
|
+
__name(isUnattendedMode, "isUnattendedMode");
|
|
238
|
+
function delay(ms, signal) {
|
|
239
|
+
return new Promise((resolve, reject) => {
|
|
240
|
+
if (signal?.aborted) {
|
|
241
|
+
return reject(new Error("Retry aborted by signal"));
|
|
242
|
+
}
|
|
243
|
+
const cleanup = /* @__PURE__ */ __name(() => {
|
|
244
|
+
signal?.removeEventListener("abort", onAbort);
|
|
245
|
+
}, "cleanup");
|
|
246
|
+
function onAbort() {
|
|
247
|
+
clearTimeout(timeout);
|
|
248
|
+
cleanup();
|
|
249
|
+
reject(new Error("Retry aborted by signal"));
|
|
250
|
+
}
|
|
251
|
+
__name(onAbort, "onAbort");
|
|
252
|
+
const timeout = setTimeout(() => {
|
|
253
|
+
cleanup();
|
|
254
|
+
resolve();
|
|
255
|
+
}, ms);
|
|
256
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
257
|
+
if (signal?.aborted) {
|
|
258
|
+
clearTimeout(timeout);
|
|
259
|
+
cleanup();
|
|
260
|
+
reject(new Error("Retry aborted by signal"));
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
__name(delay, "delay");
|
|
265
|
+
async function sleepWithHeartbeat(totalMs, ctx) {
|
|
266
|
+
let remaining = totalMs;
|
|
267
|
+
while (remaining > 0) {
|
|
268
|
+
if (ctx.signal?.aborted) {
|
|
269
|
+
throw new Error("Retry aborted by signal");
|
|
270
|
+
}
|
|
271
|
+
const chunk = Math.max(1, Math.min(remaining, ctx.heartbeatInterval));
|
|
272
|
+
await delay(chunk, ctx.signal);
|
|
273
|
+
remaining -= chunk;
|
|
274
|
+
if (remaining > 0 && ctx.heartbeatFn) {
|
|
275
|
+
ctx.heartbeatFn({
|
|
276
|
+
attempt: ctx.attempt,
|
|
277
|
+
remainingMs: remaining,
|
|
278
|
+
error: ctx.error
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
__name(sleepWithHeartbeat, "sleepWithHeartbeat");
|
|
284
|
+
async function retryWithBackoff(fn, options) {
|
|
285
|
+
if (options?.maxAttempts !== void 0 && options.maxAttempts <= 0) {
|
|
286
|
+
throw new Error("maxAttempts must be a positive number.");
|
|
287
|
+
}
|
|
288
|
+
const cleanOptions = options ? Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null)) : {};
|
|
289
|
+
const {
|
|
290
|
+
maxAttempts,
|
|
291
|
+
initialDelayMs,
|
|
292
|
+
maxDelayMs,
|
|
293
|
+
authType,
|
|
294
|
+
extraRetryErrorCodes,
|
|
295
|
+
shouldRetryOnError,
|
|
296
|
+
shouldRetryOnContent,
|
|
297
|
+
persistentMode,
|
|
298
|
+
persistentMaxBackoffMs,
|
|
299
|
+
persistentCapMs,
|
|
300
|
+
heartbeatIntervalMs,
|
|
301
|
+
heartbeatFn,
|
|
302
|
+
signal,
|
|
303
|
+
onRetry
|
|
304
|
+
} = {
|
|
305
|
+
...DEFAULT_RETRY_OPTIONS,
|
|
306
|
+
...cleanOptions
|
|
307
|
+
};
|
|
308
|
+
const hasCustomShouldRetryOnError = typeof options?.shouldRetryOnError === "function";
|
|
309
|
+
const persistent = persistentMode ?? false;
|
|
310
|
+
const maxBackoff = persistentMaxBackoffMs ?? PERSISTENT_MAX_BACKOFF_MS;
|
|
311
|
+
const capMs = persistentCapMs ?? PERSISTENT_CAP_MS;
|
|
312
|
+
const heartbeatInterval = heartbeatIntervalMs ?? HEARTBEAT_INTERVAL_MS;
|
|
313
|
+
let attempt = 0;
|
|
314
|
+
let persistentAttempt = 0;
|
|
315
|
+
let currentDelay = initialDelayMs;
|
|
316
|
+
const requestEntryTime = Date.now();
|
|
317
|
+
let iterationCount = 0;
|
|
318
|
+
let retryTotalDelayMs = 0;
|
|
319
|
+
let lastContentResult;
|
|
320
|
+
let hadContentRetry = false;
|
|
321
|
+
while (attempt < maxAttempts) {
|
|
322
|
+
attempt++;
|
|
323
|
+
iterationCount++;
|
|
324
|
+
const requestSetupMs = Date.now() - requestEntryTime;
|
|
325
|
+
try {
|
|
326
|
+
const result = await retryContext.run(
|
|
327
|
+
{ attempt: iterationCount, retryTotalDelayMs, requestSetupMs },
|
|
328
|
+
() => fn()
|
|
329
|
+
);
|
|
330
|
+
if (shouldRetryOnContent && shouldRetryOnContent(result)) {
|
|
331
|
+
lastContentResult = result;
|
|
332
|
+
hadContentRetry = true;
|
|
333
|
+
const delayMs = getRetryDelayMs({
|
|
334
|
+
// attempt: 1 — currentDelay already tracks exponential growth;
|
|
335
|
+
// getRetryDelayMs is called here only for jitter calculation.
|
|
336
|
+
attempt: 1,
|
|
337
|
+
initialDelayMs: currentDelay,
|
|
338
|
+
maxDelayMs,
|
|
339
|
+
jitterRatio: 0.3
|
|
340
|
+
});
|
|
341
|
+
debugLogger.warn(
|
|
342
|
+
`Attempt ${iterationCount}: response rejected by content check. Retrying with backoff in ${Math.ceil(delayMs / 1e3)}s...`
|
|
343
|
+
);
|
|
344
|
+
await delay(delayMs, signal);
|
|
345
|
+
retryTotalDelayMs += delayMs;
|
|
346
|
+
currentDelay = Math.min(maxDelayMs, currentDelay * 2);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
return result;
|
|
350
|
+
} catch (error) {
|
|
351
|
+
const errorStatus = getErrorStatus(error);
|
|
352
|
+
const retryDiagnostics = classifyRetryError(error, {
|
|
353
|
+
authType,
|
|
354
|
+
extraRetryErrorCodes
|
|
355
|
+
});
|
|
356
|
+
if (retryDiagnostics.kind === "abort") {
|
|
357
|
+
throw error;
|
|
358
|
+
}
|
|
359
|
+
if (authType === "qwen-oauth" /* QWEN_OAUTH */ && isQwenQuotaExceededError(error)) {
|
|
360
|
+
debugLogger.error(
|
|
361
|
+
"Qwen OAuth quota exceeded, fast-failing",
|
|
362
|
+
retryDiagnostics,
|
|
363
|
+
error
|
|
364
|
+
);
|
|
365
|
+
throw new Error(
|
|
366
|
+
`Qwen OAuth free tier has been discontinued as of 2026-04-15.
|
|
367
|
+
|
|
368
|
+
To continue using Qwen Code, try one of these alternatives:
|
|
369
|
+
- OpenRouter: https://openrouter.ai/docs/quickstart
|
|
370
|
+
- Fireworks AI: https://docs.fireworks.ai/api-reference/introduction
|
|
371
|
+
- ModelStudio: https://help.aliyun.com/zh/model-studio/coding-plan
|
|
372
|
+
|
|
373
|
+
After setting up your API key, run /auth to configure your provider.`
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
const isTransient = isTransientCapacityError(error);
|
|
377
|
+
const callerAllowsRetry = hasCustomShouldRetryOnError ? shouldRetryOnError(error) : defaultShouldRetry(error, extraRetryErrorCodes);
|
|
378
|
+
const isFailFast = retryDiagnostics.diagnosis === "fail-fast";
|
|
379
|
+
const shouldPersist = persistent && isTransient && callerAllowsRetry && !isFailFast;
|
|
380
|
+
if (!shouldPersist) {
|
|
381
|
+
if (attempt >= maxAttempts || !callerAllowsRetry) {
|
|
382
|
+
throw error;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
let delayMs;
|
|
386
|
+
if (shouldPersist) {
|
|
387
|
+
persistentAttempt++;
|
|
388
|
+
const retryAfterMs = hasRetryAfterStatus(errorStatus) ? getRetryAfterDelayMs(error) : null;
|
|
389
|
+
if (retryAfterMs !== null && retryAfterMs > 0) {
|
|
390
|
+
delayMs = Math.min(retryAfterMs, capMs);
|
|
391
|
+
} else {
|
|
392
|
+
delayMs = getRetryDelayMs({
|
|
393
|
+
attempt: persistentAttempt,
|
|
394
|
+
initialDelayMs,
|
|
395
|
+
maxDelayMs: Math.min(maxBackoff, capMs),
|
|
396
|
+
jitterRatio: 0.25
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
const reportedAttempt = persistentAttempt;
|
|
400
|
+
debugLogger.warn(
|
|
401
|
+
`[Persistent] Attempt ${reportedAttempt} failed with status ${errorStatus ?? "unknown"}. Retrying in ${Math.ceil(delayMs / 1e3)}s...`,
|
|
402
|
+
retryDiagnostics,
|
|
403
|
+
error
|
|
404
|
+
);
|
|
405
|
+
if (!signal?.aborted) {
|
|
406
|
+
try {
|
|
407
|
+
onRetry?.({
|
|
408
|
+
attempt: iterationCount,
|
|
409
|
+
error,
|
|
410
|
+
errorStatus,
|
|
411
|
+
delayMs
|
|
412
|
+
});
|
|
413
|
+
} catch (cbError) {
|
|
414
|
+
debugLogger.warn(
|
|
415
|
+
`onRetry callback threw (swallowed): ${cbError instanceof Error ? cbError.message : String(cbError)}`
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
await sleepWithHeartbeat(delayMs, {
|
|
420
|
+
attempt: reportedAttempt,
|
|
421
|
+
error,
|
|
422
|
+
heartbeatInterval,
|
|
423
|
+
heartbeatFn,
|
|
424
|
+
signal
|
|
425
|
+
});
|
|
426
|
+
retryTotalDelayMs += delayMs;
|
|
427
|
+
if (attempt >= maxAttempts) {
|
|
428
|
+
attempt = maxAttempts - 1;
|
|
429
|
+
}
|
|
430
|
+
} else {
|
|
431
|
+
const retryAfterMs = hasRetryAfterStatus(errorStatus) ? getRetryAfterDelayMs(error) : null;
|
|
432
|
+
let actualDelayMs;
|
|
433
|
+
if (retryAfterMs !== null && retryAfterMs > 0) {
|
|
434
|
+
actualDelayMs = retryAfterMs;
|
|
435
|
+
currentDelay = initialDelayMs;
|
|
436
|
+
logRetryAtStatusLevel(
|
|
437
|
+
`Attempt ${attempt} failed with status ${errorStatus ?? "unknown"}. Retrying after explicit delay of ${retryAfterMs}ms...`,
|
|
438
|
+
retryDiagnostics,
|
|
439
|
+
error,
|
|
440
|
+
errorStatus
|
|
441
|
+
);
|
|
442
|
+
} else {
|
|
443
|
+
actualDelayMs = getRetryDelayMs({
|
|
444
|
+
// attempt: 1 — currentDelay already tracks exponential growth;
|
|
445
|
+
// getRetryDelayMs is called here only for jitter calculation.
|
|
446
|
+
attempt: 1,
|
|
447
|
+
initialDelayMs: currentDelay,
|
|
448
|
+
maxDelayMs,
|
|
449
|
+
jitterRatio: 0.3
|
|
450
|
+
});
|
|
451
|
+
currentDelay = Math.min(maxDelayMs, currentDelay * 2);
|
|
452
|
+
logRetryAttempt(
|
|
453
|
+
attempt,
|
|
454
|
+
error,
|
|
455
|
+
retryDiagnostics,
|
|
456
|
+
errorStatus,
|
|
457
|
+
actualDelayMs
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
if (!signal?.aborted) {
|
|
461
|
+
try {
|
|
462
|
+
onRetry?.({
|
|
463
|
+
attempt: iterationCount,
|
|
464
|
+
error,
|
|
465
|
+
errorStatus,
|
|
466
|
+
delayMs: actualDelayMs
|
|
467
|
+
});
|
|
468
|
+
} catch (cbError) {
|
|
469
|
+
debugLogger.warn(
|
|
470
|
+
`onRetry callback threw (swallowed): ${cbError instanceof Error ? cbError.message : String(cbError)}`
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
await delay(actualDelayMs, signal);
|
|
475
|
+
retryTotalDelayMs += actualDelayMs;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (hadContentRetry) {
|
|
480
|
+
return lastContentResult;
|
|
481
|
+
}
|
|
482
|
+
throw new Error("Retry attempts exhausted");
|
|
483
|
+
}
|
|
484
|
+
__name(retryWithBackoff, "retryWithBackoff");
|
|
485
|
+
function logRetryAttempt(attempt, error, retryDiagnostics, errorStatus, delayMs) {
|
|
486
|
+
const backoff = delayMs !== void 0 ? `Retrying with backoff in ${Math.ceil(delayMs / 1e3)}s...` : "Retrying with backoff...";
|
|
487
|
+
const message = errorStatus ? `Attempt ${attempt} failed with status ${errorStatus}. ${backoff}` : `Attempt ${attempt} failed. ${backoff}`;
|
|
488
|
+
logRetryAtStatusLevel(message, retryDiagnostics, error, errorStatus);
|
|
489
|
+
}
|
|
490
|
+
__name(logRetryAttempt, "logRetryAttempt");
|
|
491
|
+
function logRetryAtStatusLevel(message, retryDiagnostics, error, errorStatus) {
|
|
492
|
+
if (errorStatus !== void 0 && errorStatus >= 500 && errorStatus < 600) {
|
|
493
|
+
debugLogger.error(message, retryDiagnostics, error);
|
|
494
|
+
} else {
|
|
495
|
+
debugLogger.warn(message, retryDiagnostics, error);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
__name(logRetryAtStatusLevel, "logRetryAtStatusLevel");
|
|
499
|
+
|
|
500
|
+
// packages/core/src/utils/fetch.ts
|
|
501
|
+
init_esbuild_shims();
|
|
502
|
+
import { URL } from "node:url";
|
|
503
|
+
var PRIVATE_IP_RANGES = [
|
|
504
|
+
/^10\./,
|
|
505
|
+
/^127\./,
|
|
506
|
+
/^172\.(1[6-9]|2[0-9]|3[0-1])\./,
|
|
507
|
+
/^192\.168\./,
|
|
508
|
+
// IPv4 link-local (incl. cloud metadata endpoints) and CGNAT 100.64.0.0/10.
|
|
509
|
+
/^169\.254\./,
|
|
510
|
+
/^100\.(6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\./,
|
|
511
|
+
/^0\.0\.0\.0$/,
|
|
512
|
+
/^::1$/,
|
|
513
|
+
/^::$/,
|
|
514
|
+
// ULA fc00::/7 covers fc00: through fdff: (fd00: is the common prefix in
|
|
515
|
+
// practice); link-local fe80::/10 covers fe80: through febf:.
|
|
516
|
+
/^f[cd][0-9a-f]{2}:/i,
|
|
517
|
+
/^fe[89ab][0-9a-f]:/i
|
|
518
|
+
];
|
|
519
|
+
var TLS_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
520
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
521
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
522
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
523
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
524
|
+
"CERT_HAS_EXPIRED",
|
|
525
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
526
|
+
]);
|
|
527
|
+
var FETCH_TROUBLESHOOTING_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
528
|
+
...TLS_ERROR_CODES,
|
|
529
|
+
"ECONNRESET",
|
|
530
|
+
"ETIMEDOUT",
|
|
531
|
+
"ECONNREFUSED",
|
|
532
|
+
"ENOTFOUND",
|
|
533
|
+
"EAI_AGAIN",
|
|
534
|
+
"EHOSTUNREACH",
|
|
535
|
+
"ENETUNREACH"
|
|
536
|
+
]);
|
|
537
|
+
var FetchError = class extends Error {
|
|
538
|
+
constructor(message, code) {
|
|
539
|
+
super(message);
|
|
540
|
+
this.code = code;
|
|
541
|
+
this.name = "FetchError";
|
|
542
|
+
}
|
|
543
|
+
static {
|
|
544
|
+
__name(this, "FetchError");
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
var CONNECTION_LEVEL_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
548
|
+
...TLS_ERROR_CODES,
|
|
549
|
+
"ECONNREFUSED",
|
|
550
|
+
"EPROTO",
|
|
551
|
+
"ERR_SSL_WRONG_VERSION_NUMBER",
|
|
552
|
+
// Servers that don't speak TLS on 443 often reset during the handshake
|
|
553
|
+
// rather than refusing the connection. Safe to include: the http fallback
|
|
554
|
+
// only ever fires for URLs the caller requested as http.
|
|
555
|
+
"ECONNRESET",
|
|
556
|
+
"UND_ERR_SOCKET",
|
|
557
|
+
// Filtered port 443 (silent drop): undici's own bounded connect timeout.
|
|
558
|
+
// Deliberately NOT the full-budget ETIMEDOUT — that can fire mid-body on
|
|
559
|
+
// a healthy https server, and a fallback there would double a worst-case
|
|
560
|
+
// 60s wait for an ambiguous gain.
|
|
561
|
+
"UND_ERR_CONNECT_TIMEOUT"
|
|
562
|
+
]);
|
|
563
|
+
function isConnectionLevelError(error) {
|
|
564
|
+
return error instanceof FetchError && error.code !== void 0 && CONNECTION_LEVEL_ERROR_CODES.has(error.code);
|
|
565
|
+
}
|
|
566
|
+
__name(isConnectionLevelError, "isConnectionLevelError");
|
|
567
|
+
function mappedIpv4(hostname) {
|
|
568
|
+
const match = /^::ffff:(.+)$/i.exec(hostname);
|
|
569
|
+
if (!match) return void 0;
|
|
570
|
+
const tail = match[1];
|
|
571
|
+
if (tail.includes(".")) return tail;
|
|
572
|
+
const groups = tail.split(":");
|
|
573
|
+
if (groups.length !== 2) return void 0;
|
|
574
|
+
const hi = Number.parseInt(groups[0], 16);
|
|
575
|
+
const lo = Number.parseInt(groups[1], 16);
|
|
576
|
+
if (Number.isNaN(hi) || Number.isNaN(lo)) return void 0;
|
|
577
|
+
return `${hi >> 8}.${hi & 255}.${lo >> 8}.${lo & 255}`;
|
|
578
|
+
}
|
|
579
|
+
__name(mappedIpv4, "mappedIpv4");
|
|
580
|
+
function isPrivateIp(url) {
|
|
581
|
+
try {
|
|
582
|
+
const hostname = new URL(url).hostname.replace(/^\[|\]$/g, "");
|
|
583
|
+
const target = mappedIpv4(hostname) ?? hostname;
|
|
584
|
+
return PRIVATE_IP_RANGES.some((range) => range.test(target));
|
|
585
|
+
} catch (_e) {
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
__name(isPrivateIp, "isPrivateIp");
|
|
590
|
+
var INTERNAL_HOST_SUFFIXES = [".local", ".internal", ".lan", ".home.arpa"];
|
|
591
|
+
function isPrivateHost(url) {
|
|
592
|
+
try {
|
|
593
|
+
const hostname = new URL(url).hostname.toLowerCase();
|
|
594
|
+
return hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "host.docker.internal" || // Single-label hostnames (intranet, ci, printserver) are never public.
|
|
595
|
+
// IPv6 literals are bracketed and dot-free but CAN be public — they
|
|
596
|
+
// are classified by isPrivateIp below, not by this heuristic.
|
|
597
|
+
!hostname.includes(".") && !hostname.startsWith("[") || INTERNAL_HOST_SUFFIXES.some((suffix) => hostname.endsWith(suffix)) || isPrivateIp(url);
|
|
598
|
+
} catch {
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
__name(isPrivateHost, "isPrivateHost");
|
|
603
|
+
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
604
|
+
function isPermittedRedirect(originalUrl, redirectUrl) {
|
|
605
|
+
try {
|
|
606
|
+
const original = new URL(originalUrl);
|
|
607
|
+
const redirect = new URL(redirectUrl);
|
|
608
|
+
if (redirect.protocol !== original.protocol) return false;
|
|
609
|
+
if (redirect.port !== original.port) return false;
|
|
610
|
+
if (redirect.username || redirect.password) return false;
|
|
611
|
+
const stripWww = /* @__PURE__ */ __name((hostname) => hostname.replace(/^www\./, ""), "stripWww");
|
|
612
|
+
return stripWww(original.hostname) === stripWww(redirect.hostname);
|
|
613
|
+
} catch {
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
__name(isPermittedRedirect, "isPermittedRedirect");
|
|
618
|
+
var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([403, 429]);
|
|
619
|
+
var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
620
|
+
"ECONNRESET",
|
|
621
|
+
"EAI_AGAIN",
|
|
622
|
+
"UND_ERR_SOCKET"
|
|
623
|
+
]);
|
|
624
|
+
var RETRY_DELAY_MS = 500;
|
|
625
|
+
async function fetchWithPolicy(url, options) {
|
|
626
|
+
const timeoutSignal = AbortSignal.timeout(options.timeoutMs);
|
|
627
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
|
|
628
|
+
const abortError = /* @__PURE__ */ __name(() => {
|
|
629
|
+
if (options.signal?.aborted) {
|
|
630
|
+
return options.signal.reason instanceof Error ? options.signal.reason : new FetchError("Request aborted", "ABORT_ERR");
|
|
631
|
+
}
|
|
632
|
+
if (timeoutSignal.aborted) {
|
|
633
|
+
return new FetchError(
|
|
634
|
+
`Request timed out after ${options.timeoutMs}ms`,
|
|
635
|
+
"ETIMEDOUT"
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
return void 0;
|
|
639
|
+
}, "abortError");
|
|
640
|
+
let first;
|
|
641
|
+
try {
|
|
642
|
+
first = await fetchPolicyAttempt(url, options, signal, timeoutSignal);
|
|
643
|
+
} catch (error) {
|
|
644
|
+
if (error instanceof FetchError && error.code !== void 0 && RETRYABLE_ERROR_CODES.has(error.code) && !signal.aborted) {
|
|
645
|
+
try {
|
|
646
|
+
await delay(RETRY_DELAY_MS, signal);
|
|
647
|
+
} catch {
|
|
648
|
+
throw abortError() ?? error;
|
|
649
|
+
}
|
|
650
|
+
return fetchPolicyAttempt(url, options, signal, timeoutSignal);
|
|
651
|
+
}
|
|
652
|
+
throw error;
|
|
653
|
+
}
|
|
654
|
+
if (first.kind === "response" && RETRYABLE_STATUSES.has(first.status) && !signal.aborted) {
|
|
655
|
+
try {
|
|
656
|
+
await delay(RETRY_DELAY_MS, signal);
|
|
657
|
+
return await fetchPolicyAttempt(url, options, signal, timeoutSignal);
|
|
658
|
+
} catch {
|
|
659
|
+
const aborted = abortError();
|
|
660
|
+
if (aborted) throw aborted;
|
|
661
|
+
return first;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return first;
|
|
665
|
+
}
|
|
666
|
+
__name(fetchWithPolicy, "fetchWithPolicy");
|
|
667
|
+
async function fetchPolicyAttempt(url, options, signal, timeoutSignal) {
|
|
668
|
+
const wrapAbort = /* @__PURE__ */ __name((error) => {
|
|
669
|
+
if (options.signal?.aborted) {
|
|
670
|
+
throw options.signal.reason instanceof Error ? options.signal.reason : new FetchError("Request aborted", "ABORT_ERR");
|
|
671
|
+
}
|
|
672
|
+
if (timeoutSignal.aborted) {
|
|
673
|
+
throw new FetchError(
|
|
674
|
+
`Request timed out after ${options.timeoutMs}ms`,
|
|
675
|
+
"ETIMEDOUT"
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
if (error instanceof FetchError) throw error;
|
|
679
|
+
const code = getErrorCode(error) ?? (error instanceof Error ? getErrorCode(error.cause) : void 0);
|
|
680
|
+
throw new FetchError(getErrorMessage(error), code);
|
|
681
|
+
}, "wrapAbort");
|
|
682
|
+
let currentUrl = url;
|
|
683
|
+
for (let hop = 0; hop <= options.maxRedirects; hop++) {
|
|
684
|
+
let response;
|
|
685
|
+
try {
|
|
686
|
+
response = await fetch(currentUrl, {
|
|
687
|
+
signal,
|
|
688
|
+
headers: options.headers,
|
|
689
|
+
redirect: "manual"
|
|
690
|
+
});
|
|
691
|
+
} catch (error) {
|
|
692
|
+
return wrapAbort(error);
|
|
693
|
+
}
|
|
694
|
+
if (REDIRECT_STATUSES.has(response.status)) {
|
|
695
|
+
const location = response.headers.get("location");
|
|
696
|
+
await response.body?.cancel().catch(() => {
|
|
697
|
+
});
|
|
698
|
+
if (!location) {
|
|
699
|
+
throw new FetchError("Redirect response missing Location header");
|
|
700
|
+
}
|
|
701
|
+
let redirectUrl;
|
|
702
|
+
try {
|
|
703
|
+
redirectUrl = new URL(location, currentUrl).toString();
|
|
704
|
+
} catch {
|
|
705
|
+
throw new FetchError(
|
|
706
|
+
`Redirect response has a malformed Location header: ${location}`
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
if (!isPermittedRedirect(currentUrl, redirectUrl)) {
|
|
710
|
+
return {
|
|
711
|
+
kind: "cross-host-redirect",
|
|
712
|
+
originalUrl: currentUrl,
|
|
713
|
+
redirectUrl,
|
|
714
|
+
status: response.status
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
currentUrl = redirectUrl;
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
if (response.status < 200 || response.status >= 300) {
|
|
721
|
+
await response.body?.cancel().catch(() => {
|
|
722
|
+
});
|
|
723
|
+
return {
|
|
724
|
+
kind: "response",
|
|
725
|
+
status: response.status,
|
|
726
|
+
statusText: response.statusText,
|
|
727
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
728
|
+
contentDisposition: response.headers.get("content-disposition") ?? "",
|
|
729
|
+
body: Buffer.alloc(0),
|
|
730
|
+
finalUrl: currentUrl
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
const contentLength = Number(response.headers.get("content-length"));
|
|
734
|
+
if (Number.isFinite(contentLength) && contentLength > options.maxBytes) {
|
|
735
|
+
await response.body?.cancel().catch(() => {
|
|
736
|
+
});
|
|
737
|
+
throw new FetchError(
|
|
738
|
+
`Response too large: ${contentLength} bytes exceeds the ${options.maxBytes}-byte limit`,
|
|
739
|
+
"EMSGSIZE"
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
const chunks = [];
|
|
743
|
+
let total = 0;
|
|
744
|
+
if (response.body) {
|
|
745
|
+
const reader = response.body.getReader();
|
|
746
|
+
try {
|
|
747
|
+
for (; ; ) {
|
|
748
|
+
const { done, value } = await reader.read();
|
|
749
|
+
if (done) break;
|
|
750
|
+
total += value.byteLength;
|
|
751
|
+
if (total > options.maxBytes) {
|
|
752
|
+
throw new FetchError(
|
|
753
|
+
`Response too large: exceeded the ${options.maxBytes}-byte limit while streaming`,
|
|
754
|
+
"EMSGSIZE"
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
chunks.push(value);
|
|
758
|
+
}
|
|
759
|
+
} catch (error) {
|
|
760
|
+
await reader.cancel().catch(() => {
|
|
761
|
+
});
|
|
762
|
+
if (error instanceof FetchError) throw error;
|
|
763
|
+
return wrapAbort(error);
|
|
764
|
+
} finally {
|
|
765
|
+
reader.releaseLock();
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return {
|
|
769
|
+
kind: "response",
|
|
770
|
+
status: response.status,
|
|
771
|
+
statusText: response.statusText,
|
|
772
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
773
|
+
contentDisposition: response.headers.get("content-disposition") ?? "",
|
|
774
|
+
body: Buffer.concat(chunks, total),
|
|
775
|
+
finalUrl: currentUrl
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
throw new FetchError(
|
|
779
|
+
`Too many redirects (exceeded ${options.maxRedirects})`,
|
|
780
|
+
"EMAXREDIRECTS"
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
__name(fetchPolicyAttempt, "fetchPolicyAttempt");
|
|
784
|
+
function getErrorCode(error) {
|
|
785
|
+
if (!error || typeof error !== "object") {
|
|
786
|
+
return void 0;
|
|
787
|
+
}
|
|
788
|
+
if ("code" in error && typeof error["code"] === "string") {
|
|
789
|
+
return error["code"];
|
|
790
|
+
}
|
|
791
|
+
return void 0;
|
|
792
|
+
}
|
|
793
|
+
__name(getErrorCode, "getErrorCode");
|
|
794
|
+
function formatUnknownErrorMessage(error) {
|
|
795
|
+
if (typeof error === "string") {
|
|
796
|
+
return error;
|
|
797
|
+
}
|
|
798
|
+
if (typeof error === "number" || typeof error === "boolean" || typeof error === "bigint") {
|
|
799
|
+
return String(error);
|
|
800
|
+
}
|
|
801
|
+
if (error instanceof Error) {
|
|
802
|
+
return error.message;
|
|
803
|
+
}
|
|
804
|
+
if (!error || typeof error !== "object") {
|
|
805
|
+
return void 0;
|
|
806
|
+
}
|
|
807
|
+
const message = error["message"];
|
|
808
|
+
if (typeof message === "string") {
|
|
809
|
+
return message;
|
|
810
|
+
}
|
|
811
|
+
return void 0;
|
|
812
|
+
}
|
|
813
|
+
__name(formatUnknownErrorMessage, "formatUnknownErrorMessage");
|
|
814
|
+
function formatErrorCause(error) {
|
|
815
|
+
if (!(error instanceof Error)) {
|
|
816
|
+
return void 0;
|
|
817
|
+
}
|
|
818
|
+
const cause = error.cause;
|
|
819
|
+
if (!cause) {
|
|
820
|
+
return void 0;
|
|
821
|
+
}
|
|
822
|
+
const causeCode = getErrorCode(cause);
|
|
823
|
+
const causeMessage = formatUnknownErrorMessage(cause);
|
|
824
|
+
if (!causeCode && !causeMessage) {
|
|
825
|
+
return void 0;
|
|
826
|
+
}
|
|
827
|
+
if (causeCode && causeMessage && !causeMessage.includes(causeCode)) {
|
|
828
|
+
return `${causeCode}: ${causeMessage}`;
|
|
829
|
+
}
|
|
830
|
+
return causeMessage ?? causeCode;
|
|
831
|
+
}
|
|
832
|
+
__name(formatErrorCause, "formatErrorCause");
|
|
833
|
+
function formatFetchErrorForUser(error, options = {}) {
|
|
834
|
+
const errorMessage = getErrorMessage(error);
|
|
835
|
+
const code = error instanceof Error ? getErrorCode(error.cause) ?? getErrorCode(error) : getErrorCode(error);
|
|
836
|
+
const cause = formatErrorCause(error);
|
|
837
|
+
const fullErrorMessage = [
|
|
838
|
+
errorMessage,
|
|
839
|
+
cause ? `(cause: ${cause})` : void 0
|
|
840
|
+
].filter(Boolean).join(" ");
|
|
841
|
+
const shouldShowFetchHints = errorMessage.toLowerCase().includes("fetch failed") || code != null && FETCH_TROUBLESHOOTING_ERROR_CODES.has(code);
|
|
842
|
+
const shouldShowTlsHint = code != null && TLS_ERROR_CODES.has(code);
|
|
843
|
+
if (!shouldShowFetchHints) {
|
|
844
|
+
return fullErrorMessage;
|
|
845
|
+
}
|
|
846
|
+
const hintLines = [
|
|
847
|
+
"",
|
|
848
|
+
"Troubleshooting:",
|
|
849
|
+
...options.url ? [`- Confirm you can reach ${options.url} from this machine.`] : [],
|
|
850
|
+
"- If you are behind a proxy, pass `--proxy <url>` (or set `proxy` in settings).",
|
|
851
|
+
...shouldShowTlsHint ? isTlsVerificationDisabled() ? [
|
|
852
|
+
"- TLS verification is already disabled (`--insecure` / `QWEN_TLS_INSECURE`), so this is likely a network or protocol issue rather than a certificate trust problem."
|
|
853
|
+
] : [
|
|
854
|
+
"- If your network uses a corporate TLS inspection CA, set `NODE_EXTRA_CA_CERTS` to your CA bundle.",
|
|
855
|
+
"- For a trusted self-signed endpoint, pass `--insecure` (or set `QWEN_TLS_INSECURE=1`) to skip certificate verification."
|
|
856
|
+
] : []
|
|
857
|
+
];
|
|
858
|
+
return `${fullErrorMessage}${hintLines.join("\n")}`;
|
|
859
|
+
}
|
|
860
|
+
__name(formatFetchErrorForUser, "formatFetchErrorForUser");
|
|
861
|
+
|
|
862
|
+
export {
|
|
863
|
+
classifyRetryError,
|
|
864
|
+
isFallbackEligible,
|
|
865
|
+
isTransientCapacityError,
|
|
866
|
+
isUnattendedMode,
|
|
867
|
+
delay,
|
|
868
|
+
retryWithBackoff,
|
|
869
|
+
isConnectionLevelError,
|
|
870
|
+
isPrivateHost,
|
|
871
|
+
fetchWithPolicy,
|
|
872
|
+
formatFetchErrorForUser
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* @license
|
|
876
|
+
* Copyright 2026 Google LLC
|
|
877
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
878
|
+
*/
|
|
879
|
+
/**
|
|
880
|
+
* @license
|
|
881
|
+
* Copyright 2025 Google LLC
|
|
882
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
883
|
+
*/
|