@herbertgao/pi-extensions 2026.10.6 → 2026.10.8
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/README.md +11 -15
- package/THIRD_PARTY_NOTICES.md +2 -54
- package/extensions/clef-format.mjs +113 -0
- package/extensions/clef.mjs +112 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-debt.md +1 -1
- package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail.mjs +30 -6
- package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
- package/node_modules/@dietrichgebert/ponytail/README.md +5 -1
- package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +3 -3
- package/node_modules/@dietrichgebert/ponytail/hooks/copilot-hooks.json +4 -4
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +158 -127
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-config.js +5 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-map.js +8 -3
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-runtime.js +14 -8
- package/node_modules/@dietrichgebert/ponytail/package.json +1 -1
- package/node_modules/@dietrichgebert/ponytail/pi-extension/index.js +16 -3
- package/node_modules/@dietrichgebert/ponytail/scripts/cursor-hooks.js +13 -3
- package/node_modules/@dietrichgebert/ponytail/scripts/uninstall.js +3 -2
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +3 -3
- package/node_modules/@herbertgao/pi-agency/package.json +2 -2
- package/node_modules/@herbertgao/pi-bark/package.json +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +29 -28
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +7 -7
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +16 -27
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +49 -48
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +2 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +228 -141
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/reference/index.ts +2 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer-layout.ts +105 -23
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +59 -43
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +96 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +124 -54
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +7 -4
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +69 -28
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +23 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +24 -12
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/codemode.ts +121 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-limits.ts +3 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-palette.ts +39 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-presentation.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +13 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/message-display.ts +3 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +49 -49
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +24 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-state.ts +51 -2
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +5 -5
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark.json +71 -70
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light.json +71 -70
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +8 -0
- package/node_modules/@herbertgao/pi-subagents/docs/packages.md +211 -0
- package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +61 -63
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +24 -16
- package/node_modules/@herbertgao/pi-subagents/package.json +5 -5
- package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +51 -14
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +123 -55
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +144 -13
- package/node_modules/@herbertgao/pi-subagents/src/agent-source-badge.ts +78 -0
- package/node_modules/@herbertgao/pi-subagents/src/completion-outbox.ts +122 -0
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +171 -79
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +597 -296
- package/node_modules/@herbertgao/pi-subagents/src/package-resources.ts +724 -0
- package/node_modules/@herbertgao/pi-subagents/src/schedule.ts +1 -1
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +66 -0
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +26 -4
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +2 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +354 -32
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +33 -15
- package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +6 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/saved.ts +48 -2
- package/node_modules/@herbertgao/sol-pi/package.json +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +3 -3
- package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +89 -39
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/configuration.md +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +4 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +56 -23
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/tool-schema.md +6 -3
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/de.json +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/en.json +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/es.json +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/fr.json +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt-BR.json +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt.json +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/ru.json +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/uk.json +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/zh.json +3 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +5 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +122 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/rpc-fallback.ts +73 -36
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +10 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +15 -13
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +5 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/derivations.ts +15 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/projections.ts +4 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +29 -18
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/format-answer.ts +5 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/normalize-params.ts +46 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/response-envelope.ts +19 -8
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/types.ts +9 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/multi-select-view.ts +4 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +56 -25
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-pane.ts +131 -46
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +94 -106
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +51 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/scroll-window.ts +73 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +31 -10
- package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts.map +1 -1
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +474 -93
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
- package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
- package/node_modules/@tifan/pi-inline-skills/package.json +5 -1
- package/node_modules/@tifan/pi-inline-skills/src/index.ts +5 -2
- package/node_modules/pi-lens/CHANGELOG.md +88 -0
- package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +3 -1
- package/node_modules/pi-lens/dist/{chunk-BJF25SUG.js → chunk-23WOO7TX.js} +11 -10
- package/node_modules/pi-lens/dist/{chunk-WATC3IQR.js → chunk-2B73ZPOK.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-N2IRDBZI.js → chunk-2BBLFX75.js} +101 -11
- package/node_modules/pi-lens/dist/{chunk-TA5L5KWQ.js → chunk-2CD5RS6M.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-3TTPKMEF.js → chunk-2VUQMUMT.js} +38 -37
- package/node_modules/pi-lens/dist/{chunk-5JHXUETW.js → chunk-3EFKIGZN.js} +3 -3
- package/node_modules/pi-lens/dist/chunk-3JNKMP3B.js +17 -0
- package/node_modules/pi-lens/dist/{chunk-6P54TMWL.js → chunk-3VPVG5SU.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-ZETYB3XG.js → chunk-3W7IEVVL.js} +44 -28
- package/node_modules/pi-lens/dist/chunk-3YN6V5TV.js +85 -0
- package/node_modules/pi-lens/dist/chunk-466Z26MG.js +30 -0
- package/node_modules/pi-lens/dist/{chunk-PCHDGUKT.js → chunk-4UNXBNE2.js} +12 -11
- package/node_modules/pi-lens/dist/{chunk-J7WJZ6W7.js → chunk-4W4VLAPJ.js} +12 -11
- package/node_modules/pi-lens/dist/{chunk-F5VLZHUW.js → chunk-52FUZI6K.js} +4 -2
- package/node_modules/pi-lens/dist/{chunk-H5EV3VMF.js → chunk-5NGR67U5.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-CBD2B5CP.js → chunk-5UCAH366.js} +21 -20
- package/node_modules/pi-lens/dist/{chunk-BHWHXMQ2.js → chunk-67WMNWEE.js} +9 -8
- package/node_modules/pi-lens/dist/{chunk-USHG4DLH.js → chunk-6C7JWPCP.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-VPWKF3GN.js → chunk-6GFRNVYR.js} +11 -10
- package/node_modules/pi-lens/dist/{chunk-3JL6IFD7.js → chunk-6SDEP3AJ.js} +9 -8
- package/node_modules/pi-lens/dist/{chunk-NJF2X5XF.js → chunk-6STA6Z7I.js} +19 -17
- package/node_modules/pi-lens/dist/{chunk-KJCWXUUS.js → chunk-724UL2TJ.js} +6 -4
- package/node_modules/pi-lens/dist/{chunk-MQA2YBAH.js → chunk-76MWC2K6.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-YLN4K6WD.js → chunk-77M37OKR.js} +10 -8
- package/node_modules/pi-lens/dist/{chunk-XHSCVSOL.js → chunk-7DYBLXYA.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-OC7LYAU5.js → chunk-AB3YYG6N.js} +24 -10
- package/node_modules/pi-lens/dist/{chunk-LD7WFTRX.js → chunk-ACXEQZOU.js} +16 -16
- package/node_modules/pi-lens/dist/{chunk-VSMJK3ZJ.js → chunk-AOHZU2BM.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-T4QZ6FEH.js → chunk-AW7R2GWG.js} +65 -8
- package/node_modules/pi-lens/dist/{chunk-GAYGGICG.js → chunk-BKE7E7TC.js} +10 -9
- package/node_modules/pi-lens/dist/{chunk-EUT3B22Y.js → chunk-BRGDSBJE.js} +13 -12
- package/node_modules/pi-lens/dist/{chunk-T54VJRAD.js → chunk-C34ZXZ7O.js} +55 -11
- package/node_modules/pi-lens/dist/{chunk-UGSMCQ4D.js → chunk-CHOW74WE.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-H2W2AXD3.js → chunk-CMMHNUZ2.js} +66 -58
- package/node_modules/pi-lens/dist/chunk-CSHFH5IN.js +17 -0
- package/node_modules/pi-lens/dist/chunk-EC47DWFA.js +56 -0
- package/node_modules/pi-lens/dist/{chunk-KJN4IOEJ.js → chunk-EJIUXPBX.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-IQZXOZ7S.js → chunk-EU63SDCG.js} +720 -334
- package/node_modules/pi-lens/dist/{chunk-LNOMA3MP.js → chunk-FCSOVF55.js} +107 -3
- package/node_modules/pi-lens/dist/{chunk-CFYISHUW.js → chunk-FLKWCIZH.js} +8 -5
- package/node_modules/pi-lens/dist/{chunk-OYTMZXRF.js → chunk-FMSO6RDZ.js} +16 -14
- package/node_modules/pi-lens/dist/{chunk-IUKPRZER.js → chunk-GAEGEPOC.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-6XX5HCLK.js → chunk-GBPP5P7X.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-TQFBZVCG.js → chunk-GXW6K4YJ.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-ZZUFZUQZ.js → chunk-H6MF6EVN.js} +331 -107
- package/node_modules/pi-lens/dist/{chunk-3JSEWUWI.js → chunk-IBGIOBEE.js} +3 -3
- package/node_modules/pi-lens/dist/chunk-IZSHAIJ7.js +26 -0
- package/node_modules/pi-lens/dist/{chunk-7ELY2CSM.js → chunk-JAU72XNY.js} +16 -14
- package/node_modules/pi-lens/dist/chunk-JMYYOTQG.js +77 -0
- package/node_modules/pi-lens/dist/{chunk-ELVWJYRV.js → chunk-JSQFTSC6.js} +12 -11
- package/node_modules/pi-lens/dist/{chunk-J6DFZDFA.js → chunk-KBG47GHP.js} +4 -4
- package/node_modules/pi-lens/dist/chunk-KDERNTCQ.js +28 -0
- package/node_modules/pi-lens/dist/chunk-KSX3TXSZ.js +69 -0
- package/node_modules/pi-lens/dist/{chunk-XGUL4SLQ.js → chunk-L3BLXZG7.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-LOP6GRPH.js +31 -0
- package/node_modules/pi-lens/dist/{chunk-MTDRLSI7.js → chunk-M6HSLBWY.js} +1064 -986
- package/node_modules/pi-lens/dist/chunk-MQLUAEOC.js +162 -0
- package/node_modules/pi-lens/dist/{chunk-3MRXIJ6I.js → chunk-MRXKYPCS.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-D65GOCJB.js → chunk-MXGY6KPT.js} +19 -16
- package/node_modules/pi-lens/dist/{chunk-G3RLJYA2.js → chunk-N2H3ZPZY.js} +47 -1
- package/node_modules/pi-lens/dist/{chunk-HREZQCT3.js → chunk-N3X6Q4YT.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-HSIRMK2D.js → chunk-OCAGUNBC.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-ZOEYVXSV.js → chunk-OXXKQCSV.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-S6AMWKPC.js → chunk-P7266HLM.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-64LU2OVH.js → chunk-PHDMFAKM.js} +12 -2
- package/node_modules/pi-lens/dist/{chunk-IMSQR4WO.js → chunk-PNQDPDRC.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-IUR76K6A.js → chunk-Q7DUK4LX.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-CULQYFLU.js → chunk-QGQ5CCCG.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-UEAHAMEI.js → chunk-QHJ6DQ2R.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-BNKLYOOO.js → chunk-QILIYSJF.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-VYKKMYVT.js → chunk-QOBUHWHX.js} +11 -6
- package/node_modules/pi-lens/dist/{chunk-3PNFWVHT.js → chunk-QQNQ7SJW.js} +2 -75
- package/node_modules/pi-lens/dist/{chunk-7M4T5N3V.js → chunk-R3PCY3YS.js} +14 -13
- package/node_modules/pi-lens/dist/{chunk-MGIWSROG.js → chunk-RPLINGVB.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-CMU4RMJB.js → chunk-RWWYJ623.js} +10 -1
- package/node_modules/pi-lens/dist/{chunk-3FERWMCH.js → chunk-RXCOMYPY.js} +27 -26
- package/node_modules/pi-lens/dist/{chunk-7BX5DWSA.js → chunk-SAEFPSB6.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-N7YNJE5R.js → chunk-SQ4TVJBR.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-DMS52BEP.js → chunk-SS36ZX4J.js} +9 -7
- package/node_modules/pi-lens/dist/{chunk-JONGANYH.js → chunk-T6CPIZNT.js} +32 -30
- package/node_modules/pi-lens/dist/{chunk-6UYA642J.js → chunk-TYM6OUIT.js} +13 -12
- package/node_modules/pi-lens/dist/{chunk-ALQRYH6O.js → chunk-UXGETRP4.js} +13 -12
- package/node_modules/pi-lens/dist/{chunk-FGALODG3.js → chunk-UZ3TUTRV.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-J3FZR3YY.js → chunk-VCHXCQFG.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-3P4PF2BX.js → chunk-VCO24T4L.js} +34 -22
- package/node_modules/pi-lens/dist/{chunk-O7HZX7CA.js → chunk-VRZP76YM.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-VZHJS6DR.js → chunk-VSSBEUFT.js} +16 -15
- package/node_modules/pi-lens/dist/{chunk-U52SAGRM.js → chunk-VWCXW2E7.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-WW5BLB74.js → chunk-WOA4LN2R.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-ZMOMPX2Z.js → chunk-WU567RSC.js} +11 -10
- package/node_modules/pi-lens/dist/{chunk-N77WFUL7.js → chunk-XAGLWMJ4.js} +23 -22
- package/node_modules/pi-lens/dist/{chunk-WSEWKCXU.js → chunk-XCJN5IJU.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-IR6XFA5P.js → chunk-XIJZVPD5.js} +16 -14
- package/node_modules/pi-lens/dist/{chunk-OYOB3ZFG.js → chunk-XMSXXAHW.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-34OCDWOS.js → chunk-XTMJ7XDT.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-Z6BB4JLQ.js → chunk-XVF2VVXP.js} +5 -3
- package/node_modules/pi-lens/dist/{chunk-AFZYMAIV.js → chunk-YIUAVF7E.js} +37 -35
- package/node_modules/pi-lens/dist/{chunk-NFXP47RV.js → chunk-YSZNHOBY.js} +85 -31
- package/node_modules/pi-lens/dist/{chunk-V5MEBST3.js → chunk-YYOIQFRS.js} +21 -21
- package/node_modules/pi-lens/dist/chunk-Z527N6YQ.js +28 -0
- package/node_modules/pi-lens/dist/{chunk-D6YF5HKX.js → chunk-ZANLILYD.js} +22 -2
- package/node_modules/pi-lens/dist/{chunk-2UMYMRI3.js → chunk-ZGDGW2V3.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-6B5I6ICN.js → chunk-ZHFZWTZV.js} +12 -11
- package/node_modules/pi-lens/dist/{chunk-OEX24ECI.js → chunk-ZWFS3OEF.js} +51 -41
- package/node_modules/pi-lens/dist/{chunk-AXKPQ6ZI.js → chunk-ZXYDQ3TZ.js} +5 -5
- package/node_modules/pi-lens/dist/index.js +73783 -71033
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +18 -8
- package/node_modules/pi-lens/dist/mcp/cli.js +48 -37
- package/node_modules/pi-lens/dist/mcp/server.js +568 -397
- package/node_modules/pi-lens/dist/mcp/worker.js +67 -55
- package/node_modules/pi-lens/dist/probes/installer.js +20 -19
- package/node_modules/pi-lens/docs/astplayground.md +1 -1
- package/node_modules/pi-lens/docs/configuration.md +29 -0
- package/node_modules/pi-lens/docs/dependencies.md +3 -0
- package/node_modules/pi-lens/docs/features.md +2 -2
- package/node_modules/pi-lens/docs/globalconfig.md +2 -0
- package/node_modules/pi-lens/docs/language-coverage.md +2 -1
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +29 -7
- package/node_modules/pi-lens/docs/lsp-idle-eviction.md +38 -47
- package/node_modules/pi-lens/docs/pi-lens-fixer.md +4 -0
- package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +17 -4
- package/node_modules/pi-lens/docs/pi-lens-retro.md +2 -1
- package/node_modules/pi-lens/docs/pi-lens-reviewer.md +18 -0
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +7 -0
- package/node_modules/pi-lens/docs/real-harness.md +17 -0
- package/node_modules/pi-lens/docs/schema/pi-lens-config-v1.json +37 -2
- package/node_modules/pi-lens/docs/servercapabilities.md +15 -4
- package/node_modules/pi-lens/docs/settings.md +2 -1
- package/node_modules/pi-lens/package.json +1 -1
- package/node_modules/pi-provider-qoder/dist/index.js +166 -33
- package/node_modules/pi-provider-qoder/package.json +1 -1
- package/node_modules/pi-typesafe/README.md +3 -3
- package/node_modules/pi-typesafe/dist/backends.d.ts +7 -2
- package/node_modules/pi-typesafe/dist/backends.js +42 -0
- package/node_modules/pi-typesafe/dist/batch.d.ts +10 -6
- package/node_modules/pi-typesafe/dist/batch.js +20 -9
- package/node_modules/pi-typesafe/dist/client.d.ts +4 -1
- package/node_modules/pi-typesafe/dist/client.js +5 -4
- package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
- package/node_modules/pi-typesafe/dist/index.js +1 -1
- package/node_modules/pi-typesafe/dist/schema.d.ts +18 -3
- package/node_modules/pi-typesafe/dist/schema.js +29 -3
- package/node_modules/pi-typesafe/package.json +1 -1
- package/node_modules/pi-web-access/CHANGELOG.md +66 -0
- package/node_modules/pi-web-access/README.md +17 -8
- package/node_modules/pi-web-access/brave.ts +20 -2
- package/node_modules/pi-web-access/content-find.ts +2 -1
- package/node_modules/pi-web-access/dist/index.js +668 -408
- package/node_modules/pi-web-access/dist/mcp-cli.js +666 -418
- package/node_modules/pi-web-access/duckduckgo.ts +5 -1
- package/node_modules/pi-web-access/endpoint-pdf-extract.ts +225 -0
- package/node_modules/pi-web-access/extract.ts +54 -14
- package/node_modules/pi-web-access/fetch-params.ts +10 -0
- package/node_modules/pi-web-access/gemini-api.ts +15 -0
- package/node_modules/pi-web-access/gemini-search.ts +32 -152
- package/node_modules/pi-web-access/github-issue-pr.ts +80 -68
- package/node_modules/pi-web-access/index.ts +3 -0
- package/node_modules/pi-web-access/package.json +1 -1
- package/node_modules/pi-web-access/pdf-extract.ts +38 -4
- package/node_modules/pi-web-access/perplexity.ts +19 -2
- package/node_modules/pi-web-access/searxng.ts +2 -1
- package/node_modules/pi-web-access/ssrf-protection.ts +35 -4
- package/node_modules/pi-web-access/summary-review.ts +10 -0
- package/node_modules/pi-web-access/tool-arguments.ts +5 -2
- package/node_modules/pi-web-access/video-extract.ts +6 -2
- package/node_modules/pi-web-access/web-tool-core.ts +53 -13
- package/package.json +21 -26
- package/node_modules/pi-jev-auto-mode/CHANGELOG.md +0 -118
- package/node_modules/pi-jev-auto-mode/LICENSE +0 -21
- package/node_modules/pi-jev-auto-mode/README.md +0 -292
- package/node_modules/pi-jev-auto-mode/SECURITY.md +0 -32
- package/node_modules/pi-jev-auto-mode/docs/calibration.md +0 -154
- package/node_modules/pi-jev-auto-mode/docs/design.md +0 -164
- package/node_modules/pi-jev-auto-mode/docs/security.md +0 -124
- package/node_modules/pi-jev-auto-mode/index.ts +0 -1
- package/node_modules/pi-jev-auto-mode/package.json +0 -72
- package/node_modules/pi-jev-auto-mode/src/call.ts +0 -180
- package/node_modules/pi-jev-auto-mode/src/decide.ts +0 -86
- package/node_modules/pi-jev-auto-mode/src/extension.ts +0 -881
- package/node_modules/pi-jev-auto-mode/src/intent.ts +0 -71
- package/node_modules/pi-jev-auto-mode/src/jev/availability.ts +0 -53
- package/node_modules/pi-jev-auto-mode/src/jev/criteria.ts +0 -19
- package/node_modules/pi-jev-auto-mode/src/jev/decide.ts +0 -187
- package/node_modules/pi-jev-auto-mode/src/jev/engine.ts +0 -165
- package/node_modules/pi-jev-auto-mode/src/jev/index.ts +0 -20
- package/node_modules/pi-jev-auto-mode/src/jev/questions.ts +0 -273
- package/node_modules/pi-jev-auto-mode/src/jev/response.ts +0 -64
- package/node_modules/pi-jev-auto-mode/src/jev/state.ts +0 -20
- package/node_modules/pi-jev-auto-mode/src/jev/transport.ts +0 -117
- package/node_modules/pi-jev-auto-mode/src/jev/types.ts +0 -46
- package/node_modules/pi-jev-auto-mode/src/policy.ts +0 -558
- package/node_modules/pi-jev-auto-mode/src/records.ts +0 -184
- package/node_modules/pi-jev-auto-mode/src/settings.ts +0 -349
- package/node_modules/pi-jev-auto-mode/src/ui.ts +0 -243
- package/node_modules/pi-lens/dist/chunk-2FQ62SPM.js +0 -83
- package/node_modules/pi-lens/dist/chunk-7AXO3ZDF.js +0 -30
- package/node_modules/pi-lens/dist/chunk-KMGPUKFD.js +0 -25
- package/node_modules/pi-lens/dist/chunk-OZJINN4O.js +0 -84
- package/node_modules/pi-lens/dist/chunk-RJFED73B.js +0 -79
- package/node_modules/pi-lens/dist/chunk-RTQNRM5X.js +0 -27
- package/node_modules/pi-lens/dist/chunk-VGEVL5EQ.js +0 -29
- package/node_modules/pi-lens/dist/chunk-WPE5FPGR.js +0 -54
- package/node_modules/pi-lens/dist/chunk-Z7QQA2KT.js +0 -27
- package/node_modules/resume-from/LICENSE +0 -21
- package/node_modules/resume-from/README.md +0 -167
- package/node_modules/resume-from/dist/adapters/claude-code/adapter.d.ts +0 -20
- package/node_modules/resume-from/dist/adapters/claude-code/adapter.js +0 -59
- package/node_modules/resume-from/dist/adapters/claude-code/contract.d.ts +0 -8
- package/node_modules/resume-from/dist/adapters/claude-code/contract.js +0 -4
- package/node_modules/resume-from/dist/adapters/claude-code/entries.d.ts +0 -30
- package/node_modules/resume-from/dist/adapters/claude-code/entries.js +0 -107
- package/node_modules/resume-from/dist/adapters/claude-code/index.d.ts +0 -3
- package/node_modules/resume-from/dist/adapters/claude-code/index.js +0 -2
- package/node_modules/resume-from/dist/adapters/claude-code/layout.d.ts +0 -29
- package/node_modules/resume-from/dist/adapters/claude-code/layout.js +0 -80
- package/node_modules/resume-from/dist/adapters/claude-code/readback.d.ts +0 -9
- package/node_modules/resume-from/dist/adapters/claude-code/readback.js +0 -39
- package/node_modules/resume-from/dist/adapters/claude-code/reader.d.ts +0 -40
- package/node_modules/resume-from/dist/adapters/claude-code/reader.js +0 -436
- package/node_modules/resume-from/dist/adapters/claude-code/redaction.d.ts +0 -26
- package/node_modules/resume-from/dist/adapters/claude-code/redaction.js +0 -145
- package/node_modules/resume-from/dist/adapters/claude-code/validation.d.ts +0 -4
- package/node_modules/resume-from/dist/adapters/claude-code/validation.js +0 -39
- package/node_modules/resume-from/dist/adapters/claude-code/writer.d.ts +0 -21
- package/node_modules/resume-from/dist/adapters/claude-code/writer.js +0 -306
- package/node_modules/resume-from/dist/adapters/codex/contract.d.ts +0 -13
- package/node_modules/resume-from/dist/adapters/codex/contract.js +0 -4
- package/node_modules/resume-from/dist/adapters/codex/index.d.ts +0 -6
- package/node_modules/resume-from/dist/adapters/codex/index.js +0 -43
- package/node_modules/resume-from/dist/adapters/codex/read.d.ts +0 -44
- package/node_modules/resume-from/dist/adapters/codex/read.js +0 -723
- package/node_modules/resume-from/dist/adapters/codex/readback.d.ts +0 -9
- package/node_modules/resume-from/dist/adapters/codex/readback.js +0 -47
- package/node_modules/resume-from/dist/adapters/codex/redaction.d.ts +0 -26
- package/node_modules/resume-from/dist/adapters/codex/redaction.js +0 -145
- package/node_modules/resume-from/dist/adapters/codex/rollout.d.ts +0 -115
- package/node_modules/resume-from/dist/adapters/codex/rollout.js +0 -269
- package/node_modules/resume-from/dist/adapters/codex/validation.d.ts +0 -7
- package/node_modules/resume-from/dist/adapters/codex/validation.js +0 -78
- package/node_modules/resume-from/dist/adapters/codex/write.d.ts +0 -17
- package/node_modules/resume-from/dist/adapters/codex/write.js +0 -141
- package/node_modules/resume-from/dist/adapters/contract.d.ts +0 -78
- package/node_modules/resume-from/dist/adapters/contract.js +0 -4
- package/node_modules/resume-from/dist/adapters/pi/adapter.d.ts +0 -15
- package/node_modules/resume-from/dist/adapters/pi/adapter.js +0 -213
- package/node_modules/resume-from/dist/adapters/pi/contract.d.ts +0 -24
- package/node_modules/resume-from/dist/adapters/pi/contract.js +0 -4
- package/node_modules/resume-from/dist/adapters/pi/format.d.ts +0 -162
- package/node_modules/resume-from/dist/adapters/pi/format.js +0 -223
- package/node_modules/resume-from/dist/adapters/pi/index.d.ts +0 -7
- package/node_modules/resume-from/dist/adapters/pi/index.js +0 -10
- package/node_modules/resume-from/dist/adapters/pi/parse.d.ts +0 -41
- package/node_modules/resume-from/dist/adapters/pi/parse.js +0 -371
- package/node_modules/resume-from/dist/adapters/pi/redaction.d.ts +0 -26
- package/node_modules/resume-from/dist/adapters/pi/redaction.js +0 -145
- package/node_modules/resume-from/dist/adapters/pi/serialize.d.ts +0 -20
- package/node_modules/resume-from/dist/adapters/pi/serialize.js +0 -87
- package/node_modules/resume-from/dist/adapters/pi/validate.d.ts +0 -14
- package/node_modules/resume-from/dist/adapters/pi/validate.js +0 -134
- package/node_modules/resume-from/dist/bin.d.ts +0 -35
- package/node_modules/resume-from/dist/bin.js +0 -135
- package/node_modules/resume-from/dist/contract.d.ts +0 -10
- package/node_modules/resume-from/dist/contract.js +0 -4
- package/node_modules/resume-from/dist/host/agents.d.ts +0 -29
- package/node_modules/resume-from/dist/host/agents.js +0 -20
- package/node_modules/resume-from/dist/host/cli/args.d.ts +0 -21
- package/node_modules/resume-from/dist/host/cli/args.js +0 -187
- package/node_modules/resume-from/dist/host/cli/contract.d.ts +0 -27
- package/node_modules/resume-from/dist/host/cli/contract.js +0 -4
- package/node_modules/resume-from/dist/host/cli/index.d.ts +0 -2
- package/node_modules/resume-from/dist/host/cli/index.js +0 -1
- package/node_modules/resume-from/dist/host/cli/presentation.d.ts +0 -2
- package/node_modules/resume-from/dist/host/cli/presentation.js +0 -11
- package/node_modules/resume-from/dist/host/cli/render.d.ts +0 -3
- package/node_modules/resume-from/dist/host/cli/render.js +0 -70
- package/node_modules/resume-from/dist/host/cli/runner.d.ts +0 -8
- package/node_modules/resume-from/dist/host/cli/runner.js +0 -125
- package/node_modules/resume-from/dist/host/contract.d.ts +0 -42
- package/node_modules/resume-from/dist/host/contract.js +0 -4
- package/node_modules/resume-from/dist/host/entry.d.ts +0 -52
- package/node_modules/resume-from/dist/host/entry.js +0 -91
- package/node_modules/resume-from/dist/host/index.d.ts +0 -11
- package/node_modules/resume-from/dist/host/index.js +0 -10
- package/node_modules/resume-from/dist/host/pi-extension/command.d.ts +0 -18
- package/node_modules/resume-from/dist/host/pi-extension/command.js +0 -126
- package/node_modules/resume-from/dist/host/pi-extension/contract.d.ts +0 -34
- package/node_modules/resume-from/dist/host/pi-extension/contract.js +0 -4
- package/node_modules/resume-from/dist/host/pi-extension/index.d.ts +0 -6
- package/node_modules/resume-from/dist/host/pi-extension/index.js +0 -4
- package/node_modules/resume-from/dist/host/pi-extension/picker.d.ts +0 -16
- package/node_modules/resume-from/dist/host/pi-extension/picker.js +0 -35
- package/node_modules/resume-from/dist/host/pi-extension/presentation.d.ts +0 -2
- package/node_modules/resume-from/dist/host/pi-extension/presentation.js +0 -11
- package/node_modules/resume-from/dist/host/pi-extension/register.d.ts +0 -25
- package/node_modules/resume-from/dist/host/pi-extension/register.js +0 -11
- package/node_modules/resume-from/dist/host/pi-extension/ui.d.ts +0 -20
- package/node_modules/resume-from/dist/host/pi-extension/ui.js +0 -1
- package/node_modules/resume-from/dist/host/profile.d.ts +0 -8
- package/node_modules/resume-from/dist/host/profile.js +0 -31
- package/node_modules/resume-from/dist/host/registry.d.ts +0 -8
- package/node_modules/resume-from/dist/host/registry.js +0 -33
- package/node_modules/resume-from/dist/host/wiring.d.ts +0 -41
- package/node_modules/resume-from/dist/host/wiring.js +0 -66
- package/node_modules/resume-from/dist/import/confirmation.d.ts +0 -9
- package/node_modules/resume-from/dist/import/confirmation.js +0 -27
- package/node_modules/resume-from/dist/import/contract.d.ts +0 -43
- package/node_modules/resume-from/dist/import/contract.js +0 -4
- package/node_modules/resume-from/dist/import/discovery/contract.d.ts +0 -63
- package/node_modules/resume-from/dist/import/discovery/contract.js +0 -4
- package/node_modules/resume-from/dist/import/discovery/errors.d.ts +0 -9
- package/node_modules/resume-from/dist/import/discovery/errors.js +0 -12
- package/node_modules/resume-from/dist/import/discovery/finder.d.ts +0 -11
- package/node_modules/resume-from/dist/import/discovery/finder.js +0 -269
- package/node_modules/resume-from/dist/import/discovery/homes.d.ts +0 -23
- package/node_modules/resume-from/dist/import/discovery/homes.js +0 -83
- package/node_modules/resume-from/dist/import/discovery/index.d.ts +0 -2
- package/node_modules/resume-from/dist/import/discovery/index.js +0 -2
- package/node_modules/resume-from/dist/import/discovery/ordering.d.ts +0 -3
- package/node_modules/resume-from/dist/import/discovery/ordering.js +0 -21
- package/node_modules/resume-from/dist/import/errors.d.ts +0 -22
- package/node_modules/resume-from/dist/import/errors.js +0 -20
- package/node_modules/resume-from/dist/import/index.d.ts +0 -3
- package/node_modules/resume-from/dist/import/index.js +0 -5
- package/node_modules/resume-from/dist/import/landing/contract.d.ts +0 -44
- package/node_modules/resume-from/dist/import/landing/contract.js +0 -4
- package/node_modules/resume-from/dist/import/landing/errors.d.ts +0 -15
- package/node_modules/resume-from/dist/import/landing/errors.js +0 -15
- package/node_modules/resume-from/dist/import/landing/handover.d.ts +0 -5
- package/node_modules/resume-from/dist/import/landing/handover.js +0 -12
- package/node_modules/resume-from/dist/import/landing/index.d.ts +0 -4
- package/node_modules/resume-from/dist/import/landing/index.js +0 -4
- package/node_modules/resume-from/dist/import/landing/lander.d.ts +0 -7
- package/node_modules/resume-from/dist/import/landing/lander.js +0 -133
- package/node_modules/resume-from/dist/import/landing/marker.d.ts +0 -9
- package/node_modules/resume-from/dist/import/landing/marker.js +0 -46
- package/node_modules/resume-from/dist/import/pipeline.d.ts +0 -28
- package/node_modules/resume-from/dist/import/pipeline.js +0 -154
- package/node_modules/resume-from/dist/import/preview/builder.d.ts +0 -6
- package/node_modules/resume-from/dist/import/preview/builder.js +0 -80
- package/node_modules/resume-from/dist/import/preview/contract.d.ts +0 -39
- package/node_modules/resume-from/dist/import/preview/contract.js +0 -4
- package/node_modules/resume-from/dist/import/preview/format.d.ts +0 -19
- package/node_modules/resume-from/dist/import/preview/format.js +0 -45
- package/node_modules/resume-from/dist/import/preview/index.d.ts +0 -2
- package/node_modules/resume-from/dist/import/preview/index.js +0 -1
- package/node_modules/resume-from/dist/import/preview/warnings.d.ts +0 -14
- package/node_modules/resume-from/dist/import/preview/warnings.js +0 -86
- package/node_modules/resume-from/dist/import/transfer/contract.d.ts +0 -48
- package/node_modules/resume-from/dist/import/transfer/contract.js +0 -4
- package/node_modules/resume-from/dist/import/transfer/index.d.ts +0 -2
- package/node_modules/resume-from/dist/import/transfer/index.js +0 -1
- package/node_modules/resume-from/dist/import/transfer/rules.d.ts +0 -3
- package/node_modules/resume-from/dist/import/transfer/rules.js +0 -228
- package/node_modules/resume-from/dist/import/wiring.d.ts +0 -24
- package/node_modules/resume-from/dist/import/wiring.js +0 -37
- package/node_modules/resume-from/dist/index.d.ts +0 -36
- package/node_modules/resume-from/dist/index.js +0 -36
- package/node_modules/resume-from/dist/platform/config/contract.d.ts +0 -35
- package/node_modules/resume-from/dist/platform/config/contract.js +0 -4
- package/node_modules/resume-from/dist/platform/config/defaults.d.ts +0 -16
- package/node_modules/resume-from/dist/platform/config/defaults.js +0 -22
- package/node_modules/resume-from/dist/platform/config/errors.d.ts +0 -9
- package/node_modules/resume-from/dist/platform/config/errors.js +0 -12
- package/node_modules/resume-from/dist/platform/config/index.d.ts +0 -5
- package/node_modules/resume-from/dist/platform/config/index.js +0 -6
- package/node_modules/resume-from/dist/platform/config/loader.d.ts +0 -10
- package/node_modules/resume-from/dist/platform/config/loader.js +0 -47
- package/node_modules/resume-from/dist/platform/config/paths.d.ts +0 -13
- package/node_modules/resume-from/dist/platform/config/paths.js +0 -37
- package/node_modules/resume-from/dist/platform/config/validate.d.ts +0 -9
- package/node_modules/resume-from/dist/platform/config/validate.js +0 -117
- package/node_modules/resume-from/dist/platform/repo/contract.d.ts +0 -36
- package/node_modules/resume-from/dist/platform/repo/contract.js +0 -4
- package/node_modules/resume-from/dist/platform/repo/git.d.ts +0 -21
- package/node_modules/resume-from/dist/platform/repo/git.js +0 -77
- package/node_modules/resume-from/dist/platform/repo/index.d.ts +0 -2
- package/node_modules/resume-from/dist/platform/repo/index.js +0 -1
- package/node_modules/resume-from/dist/platform/repo/reader.d.ts +0 -3
- package/node_modules/resume-from/dist/platform/repo/reader.js +0 -170
- package/node_modules/resume-from/dist/platform/store/contract.d.ts +0 -31
- package/node_modules/resume-from/dist/platform/store/contract.js +0 -4
- package/node_modules/resume-from/dist/platform/store/file-committer.d.ts +0 -3
- package/node_modules/resume-from/dist/platform/store/file-committer.js +0 -391
- package/node_modules/resume-from/dist/platform/store/index.d.ts +0 -2
- package/node_modules/resume-from/dist/platform/store/index.js +0 -2
- package/node_modules/resume-from/dist/platform/tokens/contract.d.ts +0 -12
- package/node_modules/resume-from/dist/platform/tokens/contract.js +0 -4
- package/node_modules/resume-from/dist/platform/tokens/estimator.d.ts +0 -12
- package/node_modules/resume-from/dist/platform/tokens/estimator.js +0 -111
- package/node_modules/resume-from/dist/platform/tokens/index.d.ts +0 -2
- package/node_modules/resume-from/dist/platform/tokens/index.js +0 -1
- package/node_modules/resume-from/dist/session/contract.d.ts +0 -116
- package/node_modules/resume-from/dist/session/contract.js +0 -4
- package/node_modules/resume-from/package.json +0 -83
- package/node_modules/resume-from/shims/pi/extensions/resume-from.js +0 -118
|
@@ -2075,6 +2075,16 @@ function getVersionedApiBase() {
|
|
|
2075
2075
|
function getUploadBase() {
|
|
2076
2076
|
return `${getApiHost()}/upload/${API_VERSION}`;
|
|
2077
2077
|
}
|
|
2078
|
+
function rewriteUploadUrlOrigin(url) {
|
|
2079
|
+
try {
|
|
2080
|
+
const parsed = new URL(url);
|
|
2081
|
+
const base = getApiHost();
|
|
2082
|
+
if (parsed.origin === new URL(base).origin) return url;
|
|
2083
|
+
return `${base}${parsed.pathname}${parsed.search}`;
|
|
2084
|
+
} catch {
|
|
2085
|
+
return url;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2078
2088
|
function getLegacyCloudflareApiKey() {
|
|
2079
2089
|
return normalizeApiKey(process.env.CLOUDFLARE_API_KEY) ?? normalizeApiKey(loadConfig2().cloudflareApiKey);
|
|
2080
2090
|
}
|
|
@@ -3403,6 +3413,9 @@ async function postPerplexity(url, body, options) {
|
|
|
3403
3413
|
windowMs: RATE_LIMIT.windowMs
|
|
3404
3414
|
});
|
|
3405
3415
|
const apiKey = await getApiKey2(options.signal);
|
|
3416
|
+
const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS);
|
|
3417
|
+
const timedOut = () => timeout.aborted && !options.signal?.aborted;
|
|
3418
|
+
const timeoutError = () => new Error("Perplexity API error 408: request timed out");
|
|
3406
3419
|
let response;
|
|
3407
3420
|
try {
|
|
3408
3421
|
response = await fetch(url, {
|
|
@@ -3412,9 +3425,13 @@ async function postPerplexity(url, body, options) {
|
|
|
3412
3425
|
"Content-Type": "application/json"
|
|
3413
3426
|
},
|
|
3414
3427
|
body: JSON.stringify(body),
|
|
3415
|
-
|
|
3428
|
+
signal: options.signal ? AbortSignal.any([options.signal, timeout]) : timeout
|
|
3416
3429
|
});
|
|
3417
3430
|
} catch (err) {
|
|
3431
|
+
if (timedOut()) {
|
|
3432
|
+
activityMonitor.logError(activityId, "request timed out");
|
|
3433
|
+
throw timeoutError();
|
|
3434
|
+
}
|
|
3418
3435
|
const message = err instanceof Error ? err.message : String(err);
|
|
3419
3436
|
const redactedMessage = redactCredential(message, apiKey);
|
|
3420
3437
|
if (redactedMessage.toLowerCase().includes("abort")) {
|
|
@@ -3429,12 +3446,19 @@ async function postPerplexity(url, body, options) {
|
|
|
3429
3446
|
}
|
|
3430
3447
|
activityMonitor.logComplete(activityId, response.status);
|
|
3431
3448
|
if (!response.ok) {
|
|
3432
|
-
|
|
3449
|
+
let errorText;
|
|
3450
|
+
try {
|
|
3451
|
+
errorText = redactCredential(await response.text(), apiKey);
|
|
3452
|
+
} catch (err) {
|
|
3453
|
+
if (timedOut()) throw timeoutError();
|
|
3454
|
+
throw err;
|
|
3455
|
+
}
|
|
3433
3456
|
throw new Error(`Perplexity API error ${response.status}: ${errorText}`);
|
|
3434
3457
|
}
|
|
3435
3458
|
try {
|
|
3436
3459
|
return await response.json();
|
|
3437
3460
|
} catch (err) {
|
|
3461
|
+
if (timedOut()) throw timeoutError();
|
|
3438
3462
|
const message = err instanceof Error ? err.message : String(err);
|
|
3439
3463
|
throw new Error(`Perplexity API returned invalid JSON: ${message}`);
|
|
3440
3464
|
}
|
|
@@ -3479,7 +3503,7 @@ async function askPerplexity(prompt, options = {}) {
|
|
|
3479
3503
|
const content = data.choices?.[0]?.message?.content;
|
|
3480
3504
|
return typeof content === "string" ? content : "";
|
|
3481
3505
|
}
|
|
3482
|
-
var PERPLEXITY_SEARCH_URL, PERPLEXITY_CHAT_URL, CONFIG_PATH5, RATE_LIMIT, requestTimestamps, cachedConfig5;
|
|
3506
|
+
var PERPLEXITY_SEARCH_URL, PERPLEXITY_CHAT_URL, CONFIG_PATH5, SEARCH_TIMEOUT_MS, RATE_LIMIT, requestTimestamps, cachedConfig5;
|
|
3483
3507
|
var init_perplexity = __esm({
|
|
3484
3508
|
"perplexity.ts"() {
|
|
3485
3509
|
init_activity();
|
|
@@ -3489,6 +3513,7 @@ var init_perplexity = __esm({
|
|
|
3489
3513
|
PERPLEXITY_SEARCH_URL = "https://api.perplexity.ai/search";
|
|
3490
3514
|
PERPLEXITY_CHAT_URL = "https://api.perplexity.ai/chat/completions";
|
|
3491
3515
|
CONFIG_PATH5 = getWebSearchConfigPath();
|
|
3516
|
+
SEARCH_TIMEOUT_MS = 3e4;
|
|
3492
3517
|
RATE_LIMIT = {
|
|
3493
3518
|
maxRequests: 10,
|
|
3494
3519
|
windowMs: 60 * 1e3
|
|
@@ -3601,7 +3626,7 @@ function isParallelAvailable() {
|
|
|
3601
3626
|
return hasParallelApiKey();
|
|
3602
3627
|
}
|
|
3603
3628
|
function requestSignal2(signal) {
|
|
3604
|
-
const timeout = AbortSignal.timeout(
|
|
3629
|
+
const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS4);
|
|
3605
3630
|
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
3606
3631
|
}
|
|
3607
3632
|
function errorMessage(err) {
|
|
@@ -3795,7 +3820,7 @@ async function parallelFetch(url, body, signal) {
|
|
|
3795
3820
|
throw new Error(`Parallel API returned invalid JSON: ${errorMessage(err)}`);
|
|
3796
3821
|
}
|
|
3797
3822
|
}
|
|
3798
|
-
var PARALLEL_SEARCH_URL, PARALLEL_EXTRACT_URL, CONFIG_PATH9, MIN_PARALLEL_API_KEY_LENGTH, MIN_USEFUL_CONTENT,
|
|
3823
|
+
var PARALLEL_SEARCH_URL, PARALLEL_EXTRACT_URL, CONFIG_PATH9, MIN_PARALLEL_API_KEY_LENGTH, MIN_USEFUL_CONTENT, SEARCH_TIMEOUT_MS4, PLACEHOLDER_API_KEY_DENYLIST, cachedConfig9;
|
|
3799
3824
|
var init_parallel = __esm({
|
|
3800
3825
|
"parallel.ts"() {
|
|
3801
3826
|
init_activity();
|
|
@@ -3807,7 +3832,7 @@ var init_parallel = __esm({
|
|
|
3807
3832
|
CONFIG_PATH9 = getWebSearchConfigPath();
|
|
3808
3833
|
MIN_PARALLEL_API_KEY_LENGTH = 8;
|
|
3809
3834
|
MIN_USEFUL_CONTENT = 500;
|
|
3810
|
-
|
|
3835
|
+
SEARCH_TIMEOUT_MS4 = 6e4;
|
|
3811
3836
|
PLACEHOLDER_API_KEY_DENYLIST = /* @__PURE__ */ new Set([
|
|
3812
3837
|
"replace_with_your_parallel_api_key",
|
|
3813
3838
|
"parallel_api_key",
|
|
@@ -4237,7 +4262,7 @@ async function searchWithTinyFish(query, options = {}) {
|
|
|
4237
4262
|
buildSearchUrl(query, options, page),
|
|
4238
4263
|
apiKey,
|
|
4239
4264
|
{ method: "GET" },
|
|
4240
|
-
|
|
4265
|
+
SEARCH_TIMEOUT_MS5,
|
|
4241
4266
|
options.signal
|
|
4242
4267
|
);
|
|
4243
4268
|
if (!Array.isArray(data.results)) throw new Error("TinyFish Search API returned an unexpected response shape");
|
|
@@ -4295,7 +4320,7 @@ async function extractWithTinyFish(url, signal, options = {}) {
|
|
|
4295
4320
|
throw redactedError;
|
|
4296
4321
|
}
|
|
4297
4322
|
}
|
|
4298
|
-
var TINYFISH_SEARCH_URL, TINYFISH_FETCH_URL, CONFIG_PATH11,
|
|
4323
|
+
var TINYFISH_SEARCH_URL, TINYFISH_FETCH_URL, CONFIG_PATH11, SEARCH_TIMEOUT_MS5, FETCH_TIMEOUT_MS, MAX_FETCH_URLS, MAX_FETCH_PER_URL_TIMEOUT_MS, cachedConfig10;
|
|
4299
4324
|
var init_tinyfish = __esm({
|
|
4300
4325
|
"tinyfish.ts"() {
|
|
4301
4326
|
init_activity();
|
|
@@ -4307,7 +4332,7 @@ var init_tinyfish = __esm({
|
|
|
4307
4332
|
TINYFISH_SEARCH_URL = "https://api.search.tinyfish.ai";
|
|
4308
4333
|
TINYFISH_FETCH_URL = "https://api.fetch.tinyfish.ai";
|
|
4309
4334
|
CONFIG_PATH11 = getWebSearchConfigPath();
|
|
4310
|
-
|
|
4335
|
+
SEARCH_TIMEOUT_MS5 = 6e4;
|
|
4311
4336
|
FETCH_TIMEOUT_MS = 15e4;
|
|
4312
4337
|
MAX_FETCH_URLS = 10;
|
|
4313
4338
|
MAX_FETCH_PER_URL_TIMEOUT_MS = 11e4;
|
|
@@ -4457,7 +4482,7 @@ async function searchWithSearch1API(query, options = {}) {
|
|
|
4457
4482
|
SEARCH1API_SEARCH_URL,
|
|
4458
4483
|
apiKey,
|
|
4459
4484
|
buildSearchBody(query, options),
|
|
4460
|
-
|
|
4485
|
+
SEARCH_TIMEOUT_MS6,
|
|
4461
4486
|
options.signal
|
|
4462
4487
|
);
|
|
4463
4488
|
const results = mapSearchResults3(data.results);
|
|
@@ -4518,7 +4543,7 @@ async function extractWithSearch1API(url, signal, options = {}) {
|
|
|
4518
4543
|
throw redactedError;
|
|
4519
4544
|
}
|
|
4520
4545
|
}
|
|
4521
|
-
var SEARCH1API_SEARCH_URL, SEARCH1API_CRAWL_URL, CONFIG_PATH12,
|
|
4546
|
+
var SEARCH1API_SEARCH_URL, SEARCH1API_CRAWL_URL, CONFIG_PATH12, SEARCH_TIMEOUT_MS6, CRAWL_TIMEOUT_MS, cachedConfig11;
|
|
4522
4547
|
var init_search1api = __esm({
|
|
4523
4548
|
"search1api.ts"() {
|
|
4524
4549
|
init_activity();
|
|
@@ -4530,7 +4555,7 @@ var init_search1api = __esm({
|
|
|
4530
4555
|
SEARCH1API_SEARCH_URL = "https://api.search1api.com/search";
|
|
4531
4556
|
SEARCH1API_CRAWL_URL = "https://api.search1api.com/crawl";
|
|
4532
4557
|
CONFIG_PATH12 = getWebSearchConfigPath();
|
|
4533
|
-
|
|
4558
|
+
SEARCH_TIMEOUT_MS6 = 6e4;
|
|
4534
4559
|
CRAWL_TIMEOUT_MS = 6e4;
|
|
4535
4560
|
cachedConfig11 = null;
|
|
4536
4561
|
}
|
|
@@ -4760,7 +4785,7 @@ async function searchWithQuerit(query, options = {}) {
|
|
|
4760
4785
|
QUERIT_SEARCH_URL,
|
|
4761
4786
|
apiKey,
|
|
4762
4787
|
buildSearchBody3(query, options),
|
|
4763
|
-
|
|
4788
|
+
SEARCH_TIMEOUT_MS8,
|
|
4764
4789
|
options.signal
|
|
4765
4790
|
);
|
|
4766
4791
|
assertApiSuccess("Search", data);
|
|
@@ -4810,7 +4835,7 @@ async function extractWithQuerit(url, signal, options = {}) {
|
|
|
4810
4835
|
throw redactedError;
|
|
4811
4836
|
}
|
|
4812
4837
|
}
|
|
4813
|
-
var QUERIT_SEARCH_URL, QUERIT_CONTENTS_URL, CONFIG_PATH14,
|
|
4838
|
+
var QUERIT_SEARCH_URL, QUERIT_CONTENTS_URL, CONFIG_PATH14, SEARCH_TIMEOUT_MS8, CONTENTS_TIMEOUT_MS, MAX_CONTENT_URLS, cachedConfig13;
|
|
4814
4839
|
var init_querit = __esm({
|
|
4815
4840
|
"querit.ts"() {
|
|
4816
4841
|
init_activity();
|
|
@@ -4822,7 +4847,7 @@ var init_querit = __esm({
|
|
|
4822
4847
|
QUERIT_SEARCH_URL = "https://api.querit.ai/v1/search";
|
|
4823
4848
|
QUERIT_CONTENTS_URL = "https://api.querit.ai/v1/contents";
|
|
4824
4849
|
CONFIG_PATH14 = getWebSearchConfigPath();
|
|
4825
|
-
|
|
4850
|
+
SEARCH_TIMEOUT_MS8 = 6e4;
|
|
4826
4851
|
CONTENTS_TIMEOUT_MS = 6e4;
|
|
4827
4852
|
MAX_CONTENT_URLS = 10;
|
|
4828
4853
|
cachedConfig13 = null;
|
|
@@ -4860,15 +4885,34 @@ function loadConfigRoot() {
|
|
|
4860
4885
|
cachedConfigRoot = { signature, value };
|
|
4861
4886
|
return value;
|
|
4862
4887
|
}
|
|
4863
|
-
function
|
|
4888
|
+
function loadFetchContentConfig() {
|
|
4864
4889
|
const parsed = loadConfigRoot();
|
|
4865
|
-
if (!parsed) return
|
|
4890
|
+
if (!parsed) return void 0;
|
|
4866
4891
|
const fetchContent = parsed.fetchContent;
|
|
4867
|
-
if (fetchContent === void 0 || fetchContent === null) return
|
|
4892
|
+
if (fetchContent === void 0 || fetchContent === null) return void 0;
|
|
4868
4893
|
if (typeof fetchContent !== "object" || Array.isArray(fetchContent)) {
|
|
4869
4894
|
throw new Error(`fetchContent in ${WEB_SEARCH_CONFIG_PATH} must be an object`);
|
|
4870
4895
|
}
|
|
4871
|
-
|
|
4896
|
+
return fetchContent;
|
|
4897
|
+
}
|
|
4898
|
+
function loadFetchContentRedirectPolicy() {
|
|
4899
|
+
const redirects = loadFetchContentConfig()?.redirects;
|
|
4900
|
+
if (redirects === void 0 || redirects === null) return void 0;
|
|
4901
|
+
if (redirects !== "same-origin") {
|
|
4902
|
+
throw new Error(`fetchContent.redirects in ${WEB_SEARCH_CONFIG_PATH} must be "same-origin"`);
|
|
4903
|
+
}
|
|
4904
|
+
return redirects;
|
|
4905
|
+
}
|
|
4906
|
+
function loadFetchContentUserAgent() {
|
|
4907
|
+
const userAgent = loadFetchContentConfig()?.userAgent;
|
|
4908
|
+
if (userAgent === void 0 || userAgent === null) return DEFAULT_FETCH_CONTENT_USER_AGENT;
|
|
4909
|
+
if (typeof userAgent !== "string" || userAgent.trim().length === 0 || !/^[\t\x20-\x7e]+$/.test(userAgent)) {
|
|
4910
|
+
throw new Error(`fetchContent.userAgent in ${WEB_SEARCH_CONFIG_PATH} must be a non-empty string of printable ASCII characters`);
|
|
4911
|
+
}
|
|
4912
|
+
return userAgent.trim();
|
|
4913
|
+
}
|
|
4914
|
+
function loadFetchContentDomainPolicy() {
|
|
4915
|
+
const policy = loadFetchContentConfig()?.domainPolicy;
|
|
4872
4916
|
if (policy === void 0 || policy === null) return { ...DEFAULT_DOMAIN_POLICY };
|
|
4873
4917
|
if (typeof policy !== "object" || Array.isArray(policy)) {
|
|
4874
4918
|
throw new Error(`fetchContent.domainPolicy in ${WEB_SEARCH_CONFIG_PATH} must be an object`);
|
|
@@ -4982,6 +5026,9 @@ async function fetchRemoteUrl(url, init = {}, options = {}) {
|
|
|
4982
5026
|
if (redirects === maxRedirects) throw new Error(`Too many redirects fetching ${current.toString()}`);
|
|
4983
5027
|
const from = current;
|
|
4984
5028
|
const next = new URL(location, current);
|
|
5029
|
+
if (options.redirects === "same-origin" && next.origin !== configuredOrigin) {
|
|
5030
|
+
throw new Error(`Refused cross-origin redirect by fetch_content redirect policy: ${configuredOrigin} -> ${next.origin}`);
|
|
5031
|
+
}
|
|
4985
5032
|
current = await validateRemoteUrl(next, next.origin === configuredOrigin ? options : { ...options, allowLoopback: false });
|
|
4986
5033
|
if (response.status === 303 || (response.status === 301 || response.status === 302) && requestInit.method?.toUpperCase() === "POST") {
|
|
4987
5034
|
const { body: _body, ...nextInit } = requestInit;
|
|
@@ -5205,7 +5252,7 @@ function bytesMatchPrefix(addr, network, prefix) {
|
|
|
5205
5252
|
}
|
|
5206
5253
|
return true;
|
|
5207
5254
|
}
|
|
5208
|
-
var DEFAULT_MAX_REDIRECTS, REDIRECT_STATUSES, LOOPBACK_ALLOW_RANGES, REMOTE_DNS_PROXY_PROTOCOLS, WEB_SEARCH_CONFIG_PATH, cachedConfigRoot, DEFAULT_DOMAIN_POLICY;
|
|
5255
|
+
var DEFAULT_MAX_REDIRECTS, REDIRECT_STATUSES, LOOPBACK_ALLOW_RANGES, REMOTE_DNS_PROXY_PROTOCOLS, WEB_SEARCH_CONFIG_PATH, cachedConfigRoot, DEFAULT_DOMAIN_POLICY, DEFAULT_FETCH_CONTENT_USER_AGENT;
|
|
5209
5256
|
var init_ssrf_protection = __esm({
|
|
5210
5257
|
"ssrf-protection.ts"() {
|
|
5211
5258
|
init_utils();
|
|
@@ -5216,6 +5263,7 @@ var init_ssrf_protection = __esm({
|
|
|
5216
5263
|
WEB_SEARCH_CONFIG_PATH = getWebSearchConfigPath();
|
|
5217
5264
|
cachedConfigRoot = null;
|
|
5218
5265
|
DEFAULT_DOMAIN_POLICY = { allow: [], deny: [] };
|
|
5266
|
+
DEFAULT_FETCH_CONTENT_USER_AGENT = "OpenAI File Downloader, XaiImageApiFetch/1.0";
|
|
5219
5267
|
}
|
|
5220
5268
|
});
|
|
5221
5269
|
|
|
@@ -5523,7 +5571,7 @@ async function searchWithFirecrawl(query, options = {}) {
|
|
|
5523
5571
|
"search",
|
|
5524
5572
|
searchBody(query, options, numResults, filters),
|
|
5525
5573
|
options.signal,
|
|
5526
|
-
{ ...options, timeoutMs: options.timeoutMs ??
|
|
5574
|
+
{ ...options, timeoutMs: options.timeoutMs ?? SEARCH_TIMEOUT_MS11 },
|
|
5527
5575
|
"search",
|
|
5528
5576
|
{ type: "api", query }
|
|
5529
5577
|
);
|
|
@@ -5550,7 +5598,7 @@ async function extractWithFirecrawl(url, signal, options) {
|
|
|
5550
5598
|
const title = typeof metadataTitle === "string" && metadataTitle.trim() ? metadataTitle.trim() : typeof scrape.title === "string" ? scrape.title.trim() : "";
|
|
5551
5599
|
return { url, title, content: withPdfTruncationNotice(content, scrape.metadata), error: null };
|
|
5552
5600
|
}
|
|
5553
|
-
var CONFIG_PATH17, DEFAULT_API_VERSION, EXTRACT_TIMEOUT_MS,
|
|
5601
|
+
var CONFIG_PATH17, DEFAULT_API_VERSION, EXTRACT_TIMEOUT_MS, SEARCH_TIMEOUT_MS11, DEFAULT_MAX_REDIRECTS2, REDIRECT_STATUSES2, SUPPORTED_API_VERSIONS, cachedConfig16;
|
|
5554
5602
|
var init_firecrawl = __esm({
|
|
5555
5603
|
"firecrawl.ts"() {
|
|
5556
5604
|
init_activity();
|
|
@@ -5563,7 +5611,7 @@ var init_firecrawl = __esm({
|
|
|
5563
5611
|
CONFIG_PATH17 = getWebSearchConfigPath();
|
|
5564
5612
|
DEFAULT_API_VERSION = "v2";
|
|
5565
5613
|
EXTRACT_TIMEOUT_MS = 6e4;
|
|
5566
|
-
|
|
5614
|
+
SEARCH_TIMEOUT_MS11 = 6e4;
|
|
5567
5615
|
DEFAULT_MAX_REDIRECTS2 = 5;
|
|
5568
5616
|
REDIRECT_STATUSES2 = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
5569
5617
|
SUPPORTED_API_VERSIONS = ["v1", "v2"];
|
|
@@ -5697,7 +5745,7 @@ async function searchWithKagi(query, options = {}) {
|
|
|
5697
5745
|
method: "POST",
|
|
5698
5746
|
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "application/json" },
|
|
5699
5747
|
body: JSON.stringify({ query, limit: numResults }),
|
|
5700
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
5748
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS14), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS14)
|
|
5701
5749
|
});
|
|
5702
5750
|
} catch (err) {
|
|
5703
5751
|
const message = errorMessage12(err);
|
|
@@ -5752,7 +5800,7 @@ async function extractWithKagi(url, signal, options = {}) {
|
|
|
5752
5800
|
method: "POST",
|
|
5753
5801
|
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "application/json" },
|
|
5754
5802
|
body: JSON.stringify({ pages: [{ url }] }),
|
|
5755
|
-
signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ??
|
|
5803
|
+
signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS14), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS14)
|
|
5756
5804
|
}, {
|
|
5757
5805
|
allowRanges: ssrf.allowRanges,
|
|
5758
5806
|
trustEnvProxy: ssrf.trustEnvProxy,
|
|
@@ -5785,7 +5833,7 @@ async function extractWithKagi(url, signal, options = {}) {
|
|
|
5785
5833
|
activityMonitor.logComplete(activityId, response.status);
|
|
5786
5834
|
return parsed;
|
|
5787
5835
|
}
|
|
5788
|
-
var KAGI_SEARCH_URL, KAGI_EXTRACT_URL, CONFIG_PATH20,
|
|
5836
|
+
var KAGI_SEARCH_URL, KAGI_EXTRACT_URL, CONFIG_PATH20, SEARCH_TIMEOUT_MS14, cachedConfig19;
|
|
5789
5837
|
var init_kagi = __esm({
|
|
5790
5838
|
"kagi.ts"() {
|
|
5791
5839
|
init_activity();
|
|
@@ -5797,7 +5845,7 @@ var init_kagi = __esm({
|
|
|
5797
5845
|
KAGI_SEARCH_URL = "https://kagi.com/api/v1/search";
|
|
5798
5846
|
KAGI_EXTRACT_URL = "https://kagi.com/api/v1/extract";
|
|
5799
5847
|
CONFIG_PATH20 = getWebSearchConfigPath();
|
|
5800
|
-
|
|
5848
|
+
SEARCH_TIMEOUT_MS14 = 6e4;
|
|
5801
5849
|
cachedConfig19 = null;
|
|
5802
5850
|
}
|
|
5803
5851
|
});
|
|
@@ -5889,7 +5937,7 @@ async function searchWithOllama(query, options = {}) {
|
|
|
5889
5937
|
method: "POST",
|
|
5890
5938
|
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
5891
5939
|
body: JSON.stringify({ query, max_results: numResults }),
|
|
5892
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
5940
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS16), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS16)
|
|
5893
5941
|
});
|
|
5894
5942
|
} catch (err) {
|
|
5895
5943
|
const message = errorMessage14(err);
|
|
@@ -5943,7 +5991,7 @@ async function extractWithOllama(url, signal, options = {}) {
|
|
|
5943
5991
|
method: "POST",
|
|
5944
5992
|
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
5945
5993
|
body: JSON.stringify({ url }),
|
|
5946
|
-
signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ??
|
|
5994
|
+
signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS16), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS16)
|
|
5947
5995
|
}, {
|
|
5948
5996
|
allowRanges: ssrf.allowRanges,
|
|
5949
5997
|
trustEnvProxy: ssrf.trustEnvProxy,
|
|
@@ -5978,7 +6026,7 @@ async function extractWithOllama(url, signal, options = {}) {
|
|
|
5978
6026
|
if (!content) return null;
|
|
5979
6027
|
return { url, title: data.title, content, error: null };
|
|
5980
6028
|
}
|
|
5981
|
-
var OLLAMA_SEARCH_URL, OLLAMA_FETCH_URL, CONFIG_PATH22,
|
|
6029
|
+
var OLLAMA_SEARCH_URL, OLLAMA_FETCH_URL, CONFIG_PATH22, SEARCH_TIMEOUT_MS16, cachedConfig21;
|
|
5982
6030
|
var init_ollama = __esm({
|
|
5983
6031
|
"ollama.ts"() {
|
|
5984
6032
|
init_activity();
|
|
@@ -5989,7 +6037,7 @@ var init_ollama = __esm({
|
|
|
5989
6037
|
OLLAMA_SEARCH_URL = "https://ollama.com/api/web_search";
|
|
5990
6038
|
OLLAMA_FETCH_URL = "https://ollama.com/api/web_fetch";
|
|
5991
6039
|
CONFIG_PATH22 = getWebSearchConfigPath();
|
|
5992
|
-
|
|
6040
|
+
SEARCH_TIMEOUT_MS16 = 6e4;
|
|
5993
6041
|
cachedConfig21 = null;
|
|
5994
6042
|
}
|
|
5995
6043
|
});
|
|
@@ -6823,6 +6871,181 @@ var init_datalab_pdf_extract = __esm({
|
|
|
6823
6871
|
}
|
|
6824
6872
|
});
|
|
6825
6873
|
|
|
6874
|
+
// endpoint-pdf-extract.ts
|
|
6875
|
+
import { existsSync as existsSync45, readFileSync as readFileSync47 } from "node:fs";
|
|
6876
|
+
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
6877
|
+
function pdfSection() {
|
|
6878
|
+
if (!existsSync45(CONFIG_PATH41)) return {};
|
|
6879
|
+
let parsed;
|
|
6880
|
+
try {
|
|
6881
|
+
parsed = JSON.parse(readFileSync47(CONFIG_PATH41, "utf-8"));
|
|
6882
|
+
} catch (err) {
|
|
6883
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
6884
|
+
throw new Error(`Failed to parse ${CONFIG_PATH41}: ${message}`);
|
|
6885
|
+
}
|
|
6886
|
+
const pdf = parsed?.pdf;
|
|
6887
|
+
return pdf && typeof pdf === "object" ? pdf : {};
|
|
6888
|
+
}
|
|
6889
|
+
function normalizeString2(value) {
|
|
6890
|
+
if (typeof value !== "string") return null;
|
|
6891
|
+
const normalized = value.trim();
|
|
6892
|
+
return normalized.length > 0 ? normalized : null;
|
|
6893
|
+
}
|
|
6894
|
+
function getEndpointUrl() {
|
|
6895
|
+
const configured = normalizeString2(process.env.PDF_ENDPOINT_URL) ?? normalizeString2(pdfSection().endpointUrl);
|
|
6896
|
+
if (!configured) return null;
|
|
6897
|
+
const protocol = URL.parse(configured)?.protocol;
|
|
6898
|
+
if (protocol !== "http:" && protocol !== "https:") {
|
|
6899
|
+
throw new Error(
|
|
6900
|
+
`Failed to parse pdf.endpointUrl: expected an absolute http(s) URL, got "${configured}"`
|
|
6901
|
+
);
|
|
6902
|
+
}
|
|
6903
|
+
return configured.replace(/\/+$/, "");
|
|
6904
|
+
}
|
|
6905
|
+
function getEndpointTimeoutMs() {
|
|
6906
|
+
const configured = pdfSection().endpointTimeoutMs;
|
|
6907
|
+
if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) {
|
|
6908
|
+
return Math.min(configured, 3e5);
|
|
6909
|
+
}
|
|
6910
|
+
return DEFAULT_TIMEOUT_MS2;
|
|
6911
|
+
}
|
|
6912
|
+
function isEndpointApiAvailable() {
|
|
6913
|
+
try {
|
|
6914
|
+
return getEndpointUrl() !== null;
|
|
6915
|
+
} catch {
|
|
6916
|
+
return true;
|
|
6917
|
+
}
|
|
6918
|
+
}
|
|
6919
|
+
async function readCapped(response, maxBytes, overflowThrows) {
|
|
6920
|
+
const reader = response.body?.getReader();
|
|
6921
|
+
if (!reader) return "";
|
|
6922
|
+
const decoder = new TextDecoder();
|
|
6923
|
+
let text4 = "";
|
|
6924
|
+
let received = 0;
|
|
6925
|
+
for (; ; ) {
|
|
6926
|
+
const { done, value } = await reader.read();
|
|
6927
|
+
if (done) return text4 + decoder.decode();
|
|
6928
|
+
const room = maxBytes - received;
|
|
6929
|
+
received += value.byteLength;
|
|
6930
|
+
if (received >= maxBytes) {
|
|
6931
|
+
await reader.cancel();
|
|
6932
|
+
if (overflowThrows && received > maxBytes) {
|
|
6933
|
+
throw new Error("PDF parser endpoint returned an oversized response");
|
|
6934
|
+
}
|
|
6935
|
+
return text4 + decoder.decode(value.subarray(0, room));
|
|
6936
|
+
}
|
|
6937
|
+
text4 += decoder.decode(value, { stream: true });
|
|
6938
|
+
}
|
|
6939
|
+
}
|
|
6940
|
+
async function readJson(response) {
|
|
6941
|
+
const text4 = await readCapped(response, MAX_RESPONSE_BYTES2, true);
|
|
6942
|
+
try {
|
|
6943
|
+
const parsed = JSON.parse(text4);
|
|
6944
|
+
if (parsed && typeof parsed === "object") return parsed;
|
|
6945
|
+
} catch {
|
|
6946
|
+
}
|
|
6947
|
+
throw new Error("PDF parser endpoint returned a non-JSON response");
|
|
6948
|
+
}
|
|
6949
|
+
async function errorBody(response) {
|
|
6950
|
+
try {
|
|
6951
|
+
const text4 = await readCapped(response, MAX_ERROR_BODY_BYTES2, false);
|
|
6952
|
+
return text4 ? `: ${text4}` : "";
|
|
6953
|
+
} catch {
|
|
6954
|
+
return "";
|
|
6955
|
+
}
|
|
6956
|
+
}
|
|
6957
|
+
function markdownResult(payload) {
|
|
6958
|
+
const markdown = typeof payload.markdown === "string" ? payload.markdown.replaceAll("\0", "") : "";
|
|
6959
|
+
if (markdown.trim().length === 0) {
|
|
6960
|
+
const error = normalizeString2(payload.error);
|
|
6961
|
+
throw new Error(
|
|
6962
|
+
error ? `PDF parser endpoint failed: ${error}` : "PDF parser endpoint returned no markdown"
|
|
6963
|
+
);
|
|
6964
|
+
}
|
|
6965
|
+
return { markdown, pages: typeof payload.pages === "number" ? payload.pages : void 0 };
|
|
6966
|
+
}
|
|
6967
|
+
async function extractPDFViaEndpoint(buffer, options) {
|
|
6968
|
+
options.signal?.throwIfAborted();
|
|
6969
|
+
const endpointUrl2 = getEndpointUrl();
|
|
6970
|
+
if (!endpointUrl2) {
|
|
6971
|
+
throw new Error("PDF endpoint extraction requires a configured pdf.endpointUrl");
|
|
6972
|
+
}
|
|
6973
|
+
const ssrf = loadSsrfConfig();
|
|
6974
|
+
const guard = {
|
|
6975
|
+
allowRanges: ssrf.allowRanges,
|
|
6976
|
+
trustEnvProxy: ssrf.trustEnvProxy,
|
|
6977
|
+
allowLoopback: isLoopbackHostname(new URL(endpointUrl2).hostname),
|
|
6978
|
+
...options.lookup ? { lookup: options.lookup } : {}
|
|
6979
|
+
};
|
|
6980
|
+
const engine = normalizeString2(pdfSection().endpointEngine);
|
|
6981
|
+
const form = new FormData();
|
|
6982
|
+
form.append("file", new Blob([buffer], { type: "application/pdf" }), "document.pdf");
|
|
6983
|
+
if (engine) form.append("engine", engine);
|
|
6984
|
+
form.append("max_pages", String(options.maxPages));
|
|
6985
|
+
const timeoutMs = options.timeoutMs ?? getEndpointTimeoutMs();
|
|
6986
|
+
const deadline = Date.now() + timeoutMs;
|
|
6987
|
+
const signal = options.signal;
|
|
6988
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
6989
|
+
const combined = signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
6990
|
+
const response = await fetchRemoteUrl(
|
|
6991
|
+
endpointUrl2,
|
|
6992
|
+
{ method: "POST", body: form, signal: combined },
|
|
6993
|
+
guard
|
|
6994
|
+
);
|
|
6995
|
+
if (!response.ok) {
|
|
6996
|
+
throw new Error(
|
|
6997
|
+
`PDF parser endpoint returned HTTP ${response.status}${await errorBody(response)}`
|
|
6998
|
+
);
|
|
6999
|
+
}
|
|
7000
|
+
let payload = await readJson(response);
|
|
7001
|
+
const jobId = normalizeString2(payload.job_id);
|
|
7002
|
+
if (typeof payload.markdown === "string" || !jobId) {
|
|
7003
|
+
return markdownResult(payload);
|
|
7004
|
+
}
|
|
7005
|
+
const jobsUrl = new URL(`jobs/${encodeURIComponent(jobId)}`, endpointUrl2).toString();
|
|
7006
|
+
for (let interval = 1e3; Date.now() < deadline; interval = Math.min(interval * 2, MAX_POLL_INTERVAL_MS)) {
|
|
7007
|
+
await sleep2(Math.min(interval, deadline - Date.now()), void 0, { signal });
|
|
7008
|
+
const poll = await fetchRemoteUrl(jobsUrl, { signal: combined }, guard);
|
|
7009
|
+
if (!poll.ok) {
|
|
7010
|
+
throw new Error(
|
|
7011
|
+
`PDF parser job status returned HTTP ${poll.status}${await errorBody(poll)}`
|
|
7012
|
+
);
|
|
7013
|
+
}
|
|
7014
|
+
payload = await readJson(poll);
|
|
7015
|
+
const status = normalizeString2(payload.status)?.toLowerCase();
|
|
7016
|
+
if (status === "error" || status === "failed") {
|
|
7017
|
+
const error = normalizeString2(payload.error) ?? "unknown parser error";
|
|
7018
|
+
throw new Error(`PDF parser endpoint job failed: ${error}`);
|
|
7019
|
+
}
|
|
7020
|
+
if (status === "done") {
|
|
7021
|
+
let result = payload.result;
|
|
7022
|
+
if (typeof result === "string") {
|
|
7023
|
+
const raw = result;
|
|
7024
|
+
try {
|
|
7025
|
+
result = JSON.parse(raw);
|
|
7026
|
+
} catch {
|
|
7027
|
+
return { markdown: raw.replaceAll("\0", "") };
|
|
7028
|
+
}
|
|
7029
|
+
}
|
|
7030
|
+
if (result && typeof result === "object") return markdownResult(result);
|
|
7031
|
+
throw new Error("PDF parser endpoint job completed without a result");
|
|
7032
|
+
}
|
|
7033
|
+
}
|
|
7034
|
+
throw new Error("PDF parser endpoint job timed out");
|
|
7035
|
+
}
|
|
7036
|
+
var DEFAULT_TIMEOUT_MS2, MAX_POLL_INTERVAL_MS, MAX_RESPONSE_BYTES2, MAX_ERROR_BODY_BYTES2, CONFIG_PATH41;
|
|
7037
|
+
var init_endpoint_pdf_extract = __esm({
|
|
7038
|
+
"endpoint-pdf-extract.ts"() {
|
|
7039
|
+
init_ssrf_protection();
|
|
7040
|
+
init_utils();
|
|
7041
|
+
DEFAULT_TIMEOUT_MS2 = 12e4;
|
|
7042
|
+
MAX_POLL_INTERVAL_MS = 3e3;
|
|
7043
|
+
MAX_RESPONSE_BYTES2 = 4 * 1024 * 1024;
|
|
7044
|
+
MAX_ERROR_BODY_BYTES2 = 300;
|
|
7045
|
+
CONFIG_PATH41 = getWebSearchConfigPath();
|
|
7046
|
+
}
|
|
7047
|
+
});
|
|
7048
|
+
|
|
6826
7049
|
// gemini-pdf-extract.ts
|
|
6827
7050
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
6828
7051
|
async function extractPDFViaGemini(buffer, options) {
|
|
@@ -6834,7 +7057,7 @@ async function extractPDFViaGemini(buffer, options) {
|
|
|
6834
7057
|
PDF_MIME_TYPE,
|
|
6835
7058
|
{
|
|
6836
7059
|
signal: options.signal,
|
|
6837
|
-
timeoutMs: options.timeoutMs ??
|
|
7060
|
+
timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS3
|
|
6838
7061
|
}
|
|
6839
7062
|
);
|
|
6840
7063
|
if (result.blockReason) {
|
|
@@ -6898,23 +7121,23 @@ function removeDuplicateInitialTitle(markdown, title) {
|
|
|
6898
7121
|
function normalizeTitle(value) {
|
|
6899
7122
|
return value.normalize("NFKC").toLocaleLowerCase().replace(/[`*_~]/g, "").replace(/[\p{P}\p{S}\s]+/gu, "");
|
|
6900
7123
|
}
|
|
6901
|
-
var PDF_MIME_TYPE,
|
|
7124
|
+
var PDF_MIME_TYPE, DEFAULT_TIMEOUT_MS3, PAGE_MARKER_PATTERN;
|
|
6902
7125
|
var init_gemini_pdf_extract = __esm({
|
|
6903
7126
|
"gemini-pdf-extract.ts"() {
|
|
6904
7127
|
init_gemini_api();
|
|
6905
7128
|
PDF_MIME_TYPE = "application/pdf";
|
|
6906
|
-
|
|
7129
|
+
DEFAULT_TIMEOUT_MS3 = 12e4;
|
|
6907
7130
|
PAGE_MARKER_PATTERN = /^<!-- Page (\d+) -->$/gm;
|
|
6908
7131
|
}
|
|
6909
7132
|
});
|
|
6910
7133
|
|
|
6911
7134
|
// pdf-extract.ts
|
|
6912
|
-
import { existsSync as
|
|
7135
|
+
import { existsSync as existsSync46, readFileSync as readFileSync48 } from "node:fs";
|
|
6913
7136
|
import { writeFile as writeFile2, mkdir } from "node:fs/promises";
|
|
6914
7137
|
import { join as join6, basename as basename3 } from "node:path";
|
|
6915
7138
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
6916
7139
|
function loadPDFConfig() {
|
|
6917
|
-
if (!
|
|
7140
|
+
if (!existsSync46(CONFIG_PATH42)) {
|
|
6918
7141
|
return {
|
|
6919
7142
|
enabled: true,
|
|
6920
7143
|
maxSizeMB: DEFAULT_PDF_MAX_SIZE_MB,
|
|
@@ -6924,13 +7147,13 @@ function loadPDFConfig() {
|
|
|
6924
7147
|
datalabTimeoutMs: DEFAULT_DATALAB_TIMEOUT_MS
|
|
6925
7148
|
};
|
|
6926
7149
|
}
|
|
6927
|
-
const rawText =
|
|
7150
|
+
const rawText = readFileSync48(CONFIG_PATH42, "utf-8");
|
|
6928
7151
|
let raw;
|
|
6929
7152
|
try {
|
|
6930
7153
|
raw = JSON.parse(rawText);
|
|
6931
7154
|
} catch (err) {
|
|
6932
7155
|
const message = err instanceof Error ? err.message : String(err);
|
|
6933
|
-
throw new Error(`Failed to parse ${
|
|
7156
|
+
throw new Error(`Failed to parse ${CONFIG_PATH42}: ${message}`);
|
|
6934
7157
|
}
|
|
6935
7158
|
const root = raw && typeof raw === "object" ? raw : {};
|
|
6936
7159
|
const pdf = root.pdf && typeof root.pdf === "object" ? root.pdf : {};
|
|
@@ -6976,6 +7199,31 @@ async function extractPDFToMarkdown(buffer, url, options = {}) {
|
|
|
6976
7199
|
const safeMaxPages = maxPages === void 0 ? pdfConfig.maxPages : Number.isFinite(maxPages) ? Math.max(1, Math.floor(maxPages)) : DEFAULT_MAX_PAGES;
|
|
6977
7200
|
const urlTitle = extractTitleFromURL(url);
|
|
6978
7201
|
const provider = pdfConfig.provider;
|
|
7202
|
+
if (provider === "auto" || provider === "endpoint") {
|
|
7203
|
+
if (provider === "endpoint" && !isEndpointApiAvailable()) {
|
|
7204
|
+
throw new Error(
|
|
7205
|
+
'PDF provider "endpoint" requires a configured pdf.endpointUrl'
|
|
7206
|
+
);
|
|
7207
|
+
}
|
|
7208
|
+
try {
|
|
7209
|
+
if (isEndpointApiAvailable()) {
|
|
7210
|
+
const result = await extractPDFViaEndpoint(buffer, {
|
|
7211
|
+
maxPages: safeMaxPages,
|
|
7212
|
+
...signal ? { signal } : {}
|
|
7213
|
+
});
|
|
7214
|
+
return writeMarkdownResult({
|
|
7215
|
+
markdownBody: result.markdown,
|
|
7216
|
+
title: urlTitle,
|
|
7217
|
+
pages: result.pages ?? countPageMarkers2(result.markdown),
|
|
7218
|
+
outputDir,
|
|
7219
|
+
filename,
|
|
7220
|
+
url
|
|
7221
|
+
});
|
|
7222
|
+
}
|
|
7223
|
+
} catch (err) {
|
|
7224
|
+
if (shouldRethrowExtractionError(err, signal)) throw err;
|
|
7225
|
+
}
|
|
7226
|
+
}
|
|
6979
7227
|
if (provider === "auto" || provider === "datalab") {
|
|
6980
7228
|
try {
|
|
6981
7229
|
if (isDatalabApiAvailable()) {
|
|
@@ -7070,9 +7318,11 @@ async function writeMarkdownResult(options) {
|
|
|
7070
7318
|
lines.push(`# ${options.title}`);
|
|
7071
7319
|
lines.push("");
|
|
7072
7320
|
lines.push(`> Source: ${options.url}`);
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7321
|
+
if (options.pages > 0) {
|
|
7322
|
+
lines.push(
|
|
7323
|
+
`> Pages: ${options.pages}${options.truncated ? ` (extracted first ${options.pagesToExtract})` : ""}`
|
|
7324
|
+
);
|
|
7325
|
+
}
|
|
7076
7326
|
if (options.metaAuthor) lines.push(`> Author: ${options.metaAuthor}`);
|
|
7077
7327
|
lines.push("");
|
|
7078
7328
|
lines.push("---");
|
|
@@ -7139,16 +7389,18 @@ function isPDF(url, contentType) {
|
|
|
7139
7389
|
return false;
|
|
7140
7390
|
}
|
|
7141
7391
|
}
|
|
7142
|
-
var PDF_PROVIDER_VALUES, DEFAULT_PDF_MAX_SIZE_MB, MAX_PDF_MAX_SIZE_MB, MAX_DATALAB_TIMEOUT_MS, DEFAULT_MAX_PAGES, DEFAULT_OUTPUT_DIR,
|
|
7392
|
+
var PDF_PROVIDER_VALUES, DEFAULT_PDF_MAX_SIZE_MB, MAX_PDF_MAX_SIZE_MB, MAX_DATALAB_TIMEOUT_MS, DEFAULT_MAX_PAGES, DEFAULT_OUTPUT_DIR, CONFIG_PATH42, PAGE_MARKER_PATTERN2;
|
|
7143
7393
|
var init_pdf_extract = __esm({
|
|
7144
7394
|
"pdf-extract.ts"() {
|
|
7145
7395
|
init_credential_source();
|
|
7146
7396
|
init_datalab_pdf_extract();
|
|
7147
7397
|
init_gemini_api();
|
|
7398
|
+
init_endpoint_pdf_extract();
|
|
7148
7399
|
init_gemini_pdf_extract();
|
|
7149
7400
|
init_utils();
|
|
7150
7401
|
PDF_PROVIDER_VALUES = /* @__PURE__ */ new Set([
|
|
7151
7402
|
"auto",
|
|
7403
|
+
"endpoint",
|
|
7152
7404
|
"gemini",
|
|
7153
7405
|
"datalab",
|
|
7154
7406
|
"unpdf"
|
|
@@ -7158,32 +7410,32 @@ var init_pdf_extract = __esm({
|
|
|
7158
7410
|
MAX_DATALAB_TIMEOUT_MS = 3e5;
|
|
7159
7411
|
DEFAULT_MAX_PAGES = 100;
|
|
7160
7412
|
DEFAULT_OUTPUT_DIR = join6(tmpdir3(), "pi-web-pdf");
|
|
7161
|
-
|
|
7413
|
+
CONFIG_PATH42 = getWebSearchConfigPath();
|
|
7162
7414
|
PAGE_MARKER_PATTERN2 = /^<!-- Page (\d+) -->$/gm;
|
|
7163
7415
|
}
|
|
7164
7416
|
});
|
|
7165
7417
|
|
|
7166
7418
|
// github-issue-pr.ts
|
|
7167
7419
|
import { execFile as execFile4 } from "node:child_process";
|
|
7168
|
-
import { existsSync as
|
|
7420
|
+
import { existsSync as existsSync47, readFileSync as readFileSync49 } from "node:fs";
|
|
7169
7421
|
function loadConfig37() {
|
|
7170
7422
|
if (cachedConfig37) return cachedConfig37;
|
|
7171
7423
|
const defaults2 = { enabled: true };
|
|
7172
|
-
if (!
|
|
7424
|
+
if (!existsSync47(CONFIG_PATH43)) {
|
|
7173
7425
|
cachedConfig37 = defaults2;
|
|
7174
7426
|
return cachedConfig37;
|
|
7175
7427
|
}
|
|
7176
7428
|
let parsed;
|
|
7177
7429
|
try {
|
|
7178
|
-
parsed = JSON.parse(
|
|
7430
|
+
parsed = JSON.parse(readFileSync49(CONFIG_PATH43, "utf-8"));
|
|
7179
7431
|
} catch (err) {
|
|
7180
7432
|
const message = err instanceof Error ? err.message : String(err);
|
|
7181
|
-
throw new Error(`Failed to parse ${
|
|
7433
|
+
throw new Error(`Failed to parse ${CONFIG_PATH43}: ${message}`);
|
|
7182
7434
|
}
|
|
7183
7435
|
const root = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
7184
7436
|
const value = root.githubPrIssue;
|
|
7185
7437
|
if (value !== void 0 && (typeof value !== "object" || value === null || Array.isArray(value))) {
|
|
7186
|
-
throw new Error(`githubPrIssue in ${
|
|
7438
|
+
throw new Error(`githubPrIssue in ${CONFIG_PATH43} must be an object`);
|
|
7187
7439
|
}
|
|
7188
7440
|
const enabled = typeof value?.enabled === "boolean" ? value.enabled : true;
|
|
7189
7441
|
cachedConfig37 = { enabled };
|
|
@@ -7493,23 +7745,38 @@ function milestoneTitle(value) {
|
|
|
7493
7745
|
if (!value || typeof value !== "object" || Array.isArray(value)) return "none";
|
|
7494
7746
|
return stringValue(value.title) || "none";
|
|
7495
7747
|
}
|
|
7496
|
-
function truncateText(text4, limit, label, appendix) {
|
|
7748
|
+
function truncateText(text4, limit, label, appendix, tool) {
|
|
7497
7749
|
if (text4.length <= limit) return text4;
|
|
7498
|
-
|
|
7750
|
+
const lastSpace = text4.slice(0, limit + 1).search(/\s\S*$/);
|
|
7751
|
+
const cut = lastSpace > limit * 0.8 ? lastSpace : limit;
|
|
7752
|
+
appendix.push(`## ${label} (continued)
|
|
7753
|
+
|
|
7754
|
+
${text4.slice(cut)}`);
|
|
7755
|
+
return `${text4.slice(0, cut)}
|
|
7499
7756
|
|
|
7500
|
-
${
|
|
7501
|
-
|
|
7757
|
+
[${label} truncated; ${tool ? `the rest is stored under "${label} (continued)": use ${tool} findText or offset` : "use the gh escalation commands below for the rest"}]`;
|
|
7758
|
+
}
|
|
7759
|
+
function storeOmitted(appendix, section, items) {
|
|
7760
|
+
if (items.length > 0) appendix.push(`## ${section} (continued)
|
|
7502
7761
|
|
|
7503
|
-
|
|
7762
|
+
${items.join("\n")}`);
|
|
7504
7763
|
}
|
|
7505
|
-
function
|
|
7764
|
+
function omissionMarker(section, noun, shown, fetched, atLeast, tool, gh = "the gh command below") {
|
|
7765
|
+
const stored = fetched > shown && tool ? `${fetched - shown} more stored under "${section} (continued)": use ${tool} findText or offset` : "";
|
|
7766
|
+
if (atLeast !== null) return `[${shown} ${noun} shown from at least ${atLeast}; ${stored ? `${stored}; for the rest ` : ""}use ${gh}]`;
|
|
7767
|
+
if (fetched <= shown) return null;
|
|
7768
|
+
return `[${shown} of ${fetched} ${noun} shown; ${stored ? `${stored}, or ${gh}` : `use ${gh}`}]`;
|
|
7769
|
+
}
|
|
7770
|
+
function appendLimitedSection(lines, title, items, max, marker, appendix, tool) {
|
|
7506
7771
|
lines.push(`## ${title}`);
|
|
7507
7772
|
if (items.length === 0) {
|
|
7508
7773
|
lines.push("none", "");
|
|
7509
7774
|
return;
|
|
7510
7775
|
}
|
|
7511
7776
|
lines.push(...items.slice(0, max));
|
|
7512
|
-
|
|
7777
|
+
storeOmitted(appendix, title, items.slice(max));
|
|
7778
|
+
const omitted = omissionMarker(title, marker, max, items.length, null, tool);
|
|
7779
|
+
if (omitted) lines.push(omitted);
|
|
7513
7780
|
lines.push("");
|
|
7514
7781
|
}
|
|
7515
7782
|
function objectArray(value) {
|
|
@@ -7524,26 +7791,21 @@ function anchorMatches(anchor, comment) {
|
|
|
7524
7791
|
const id = commentId(comment);
|
|
7525
7792
|
return anchor === `issuecomment-${id}` || anchor === `discussion_r${id}`;
|
|
7526
7793
|
}
|
|
7527
|
-
function renderComments(comments, anchor, appendix) {
|
|
7794
|
+
function renderComments(comments, anchor, appendix, tool) {
|
|
7528
7795
|
const forced = anchor ? comments.find((comment) => anchorMatches(anchor, comment)) : void 0;
|
|
7529
7796
|
const selected = comments.slice(0, MAX_INLINE_COMMENTS);
|
|
7530
7797
|
if (forced && !selected.includes(forced)) selected.push(forced);
|
|
7531
|
-
const
|
|
7798
|
+
const render = (comment, inline) => {
|
|
7532
7799
|
const body = stringValue(comment.body);
|
|
7533
|
-
const label = `comment ${commentId(comment) ||
|
|
7800
|
+
const label = `comment ${commentId(comment) || comments.indexOf(comment) + 1}`;
|
|
7801
|
+
const text4 = inline ? truncateText(body, COMMENT_INLINE_CHARS, label, appendix, tool) : body;
|
|
7534
7802
|
return `- ${authorLogin(comment.author ?? comment.user)} at ${stringValue(comment.createdAt) || stringValue(comment.created_at)}${forced === comment ? " [anchored]" : ""}:
|
|
7535
|
-
${
|
|
7536
|
-
}
|
|
7803
|
+
${text4.replace(/\n/g, "\n ")}`;
|
|
7804
|
+
};
|
|
7805
|
+
const lines = selected.map((comment) => render(comment, true));
|
|
7806
|
+
storeOmitted(appendix, "Conversation comments", comments.slice(MAX_INLINE_COMMENTS).filter((comment) => comment !== forced).map((comment) => render(comment, false)));
|
|
7537
7807
|
return lines;
|
|
7538
7808
|
}
|
|
7539
|
-
function renderCommentMarker(comments, renderedCount, total) {
|
|
7540
|
-
const knownTotal = numberValue(total);
|
|
7541
|
-
if (knownTotal !== null && knownTotal > comments.length) {
|
|
7542
|
-
return `[${renderedCount} comments shown from at least ${knownTotal}; use get_search_content findText or offset, or gh issue view -c]`;
|
|
7543
|
-
}
|
|
7544
|
-
if (comments.length > renderedCount) return `[${renderedCount} of ${comments.length} comments shown; use get_search_content findText or offset, or gh issue view -c]`;
|
|
7545
|
-
return null;
|
|
7546
|
-
}
|
|
7547
7809
|
function commentCountText(view) {
|
|
7548
7810
|
const comments = objectArray(view.comments).length;
|
|
7549
7811
|
const total = numberValue(view.commentsCount);
|
|
@@ -7557,7 +7819,7 @@ function reviewThreadCountText(comments, total, bounded, unavailable) {
|
|
|
7557
7819
|
if (knownTotal !== null && knownTotal > comments.length) return `at least ${knownTotal}`;
|
|
7558
7820
|
return String(comments.length || knownTotal || 0);
|
|
7559
7821
|
}
|
|
7560
|
-
function renderChecks(value) {
|
|
7822
|
+
function renderChecks(value, appendix, tool) {
|
|
7561
7823
|
const checks = objectArray(value);
|
|
7562
7824
|
if (checks.length === 0) return ["No check rollup data available."];
|
|
7563
7825
|
const rows = checks.map((check) => {
|
|
@@ -7566,19 +7828,21 @@ function renderChecks(value) {
|
|
|
7566
7828
|
return `- ${name}: ${state}`;
|
|
7567
7829
|
});
|
|
7568
7830
|
const failing = rows.filter((row) => !/(success|neutral|skipped|completed)$/i.test(row));
|
|
7569
|
-
|
|
7831
|
+
storeOmitted(appendix, "Checks", rows.slice(MAX_INLINE_CHECKS));
|
|
7832
|
+
const omitted = omissionMarker("Checks", "checks", MAX_INLINE_CHECKS, rows.length, null, tool);
|
|
7833
|
+
return [`Rollup: ${failing.length === 0 ? "no failing checks in shown data" : `${failing.length} non-passing checks in shown data`}`, ...rows.slice(0, MAX_INLINE_CHECKS), ...omitted ? [omitted] : []];
|
|
7570
7834
|
}
|
|
7571
|
-
function renderReviewVerdicts(value, appendix) {
|
|
7835
|
+
function renderReviewVerdicts(value, appendix, tool) {
|
|
7572
7836
|
const latest = /* @__PURE__ */ new Map();
|
|
7573
7837
|
for (const review of objectArray(value)) latest.set(authorLogin(review.author ?? review.user), review);
|
|
7574
7838
|
return [...latest.entries()].map(([author, review]) => {
|
|
7575
7839
|
const state = stringValue(review.state) || "COMMENTED";
|
|
7576
|
-
const body = truncateText(stringValue(review.body), 300, `review by ${author}`, appendix);
|
|
7840
|
+
const body = truncateText(stringValue(review.body), 300, `review by ${author}`, appendix, tool);
|
|
7577
7841
|
return `- ${author}: ${state}${body ? ` \u2014 ${body.replace(/\n/g, " ")}` : ""}`;
|
|
7578
7842
|
});
|
|
7579
7843
|
}
|
|
7580
|
-
function renderReviewVerdictsOrUnavailable(view, appendix) {
|
|
7581
|
-
const rendered = renderReviewVerdicts(view.reviews, appendix);
|
|
7844
|
+
function renderReviewVerdictsOrUnavailable(view, appendix, tool) {
|
|
7845
|
+
const rendered = renderReviewVerdicts(view.reviews, appendix, tool);
|
|
7582
7846
|
if (rendered.length > 0) return rendered;
|
|
7583
7847
|
return view.reviewsUnavailable === true ? ["Unavailable in this GitHub fetch path; use gh for review verdicts."] : [];
|
|
7584
7848
|
}
|
|
@@ -7590,25 +7854,15 @@ function renderFiles(value) {
|
|
|
7590
7854
|
return `- ${path} (+${additions}/\u2212${deletions})`;
|
|
7591
7855
|
});
|
|
7592
7856
|
}
|
|
7593
|
-
function appendFilesSection(lines, view) {
|
|
7857
|
+
function appendFilesSection(lines, view, appendix, tool) {
|
|
7594
7858
|
lines.push("## Files");
|
|
7595
7859
|
const files = renderFiles(view.files);
|
|
7596
|
-
if (files.length === 0) {
|
|
7597
|
-
const total2 = numberValue(view.changedFiles);
|
|
7598
|
-
if (total2 !== null && total2 > 0) {
|
|
7599
|
-
lines.push(`[0 files shown from at least ${total2}; use get_search_content offset or the gh command below for more]`, "");
|
|
7600
|
-
return;
|
|
7601
|
-
}
|
|
7602
|
-
lines.push("none", "");
|
|
7603
|
-
return;
|
|
7604
|
-
}
|
|
7605
|
-
lines.push(...files.slice(0, MAX_INLINE_FILES));
|
|
7606
7860
|
const total = numberValue(view.changedFiles);
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7861
|
+
const omitted = omissionMarker("Files", "files", Math.min(files.length, MAX_INLINE_FILES), files.length, total !== null && total > files.length ? total : null, tool);
|
|
7862
|
+
if (files.length === 0 && !omitted) lines.push("none");
|
|
7863
|
+
lines.push(...files.slice(0, MAX_INLINE_FILES));
|
|
7864
|
+
storeOmitted(appendix, "Files", files.slice(MAX_INLINE_FILES));
|
|
7865
|
+
if (omitted) lines.push(omitted);
|
|
7612
7866
|
lines.push("");
|
|
7613
7867
|
}
|
|
7614
7868
|
function renderCommits(value) {
|
|
@@ -7631,31 +7885,31 @@ function renderLinkedOrUnavailable(view, field, kind) {
|
|
|
7631
7885
|
if (linked.length > 0) return linked;
|
|
7632
7886
|
return view.linkedReferencesUnavailable === true ? ["Unavailable in this GitHub fetch path; use gh for linked references."] : [];
|
|
7633
7887
|
}
|
|
7634
|
-
function renderReviewThreads(comments, anchor, appendix, total, bounded, unavailable) {
|
|
7888
|
+
function renderReviewThreads(comments, anchor, appendix, tool, total, bounded, unavailable) {
|
|
7635
7889
|
if (unavailable) return ["Unavailable in this GitHub fetch path; use gh for review thread comments."];
|
|
7636
7890
|
const forced = anchor ? comments.find((comment) => anchorMatches(anchor, comment)) : void 0;
|
|
7637
7891
|
const selected = comments.slice(0, MAX_INLINE_REVIEW_THREADS);
|
|
7638
7892
|
if (forced && !selected.includes(forced)) selected.push(forced);
|
|
7639
|
-
const
|
|
7893
|
+
const render = (comment, inline) => {
|
|
7640
7894
|
const path = stringValue(comment.path) || "unknown path";
|
|
7641
7895
|
const line = numberValue(comment.line) ?? numberValue(comment.original_line) ?? numberValue(comment.position) ?? "?";
|
|
7642
|
-
const
|
|
7896
|
+
const text4 = stringValue(comment.body);
|
|
7897
|
+
const body = inline ? truncateText(text4, COMMENT_INLINE_CHARS, `review thread comment ${commentId(comment) || comments.indexOf(comment) + 1}`, appendix, tool) : text4;
|
|
7643
7898
|
return `- ${path}:${line} \u2014 ${authorLogin(comment.user ?? comment.author)}${forced === comment ? " [anchored]" : ""} (resolution state unknown):
|
|
7644
7899
|
${body.replace(/\n/g, "\n ")}`;
|
|
7645
|
-
}
|
|
7900
|
+
};
|
|
7901
|
+
const lines = selected.map((comment) => render(comment, true));
|
|
7902
|
+
storeOmitted(appendix, "Review thread comments", comments.slice(MAX_INLINE_REVIEW_THREADS).filter((comment) => comment !== forced).map((comment) => render(comment, false)));
|
|
7646
7903
|
const knownTotal = numberValue(total);
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
lines.push(`[${selected.length} review thread comments shown from at least ${knownTotal}; use get_search_content offset, or gh api repos/<owner>/<repo>/pulls/<number>/comments]`);
|
|
7651
|
-
} else if (comments.length > selected.length) {
|
|
7652
|
-
lines.push(`[${selected.length} of ${comments.length} review thread comments shown; use get_search_content offset, or gh api repos/<owner>/<repo>/pulls/<number>/comments]`);
|
|
7653
|
-
}
|
|
7904
|
+
const atLeast = bounded ? comments.length : knownTotal !== null && knownTotal > comments.length ? knownTotal : null;
|
|
7905
|
+
const omitted = omissionMarker("Review thread comments", "review thread comments", selected.length, comments.length, atLeast, tool, "gh api repos/<owner>/<repo>/pulls/<number>/comments");
|
|
7906
|
+
if (omitted) lines.push(omitted);
|
|
7654
7907
|
return lines;
|
|
7655
7908
|
}
|
|
7656
7909
|
function renderGitHubPrIssue(data) {
|
|
7657
7910
|
const { view } = data;
|
|
7658
7911
|
const appendix = [];
|
|
7912
|
+
const tool = data.retrievalTool === void 0 ? "get_search_content" : data.retrievalTool;
|
|
7659
7913
|
const title = stringValue(view.title) || `${data.owner}/${data.repo}#${data.number}`;
|
|
7660
7914
|
const number = numberValue(view.number) ?? data.number;
|
|
7661
7915
|
const stateParts = [stringValue(view.state) || "unknown"];
|
|
@@ -7683,45 +7937,48 @@ function renderGitHubPrIssue(data) {
|
|
|
7683
7937
|
if (data.anchor) lines.push(`- requested anchor: #${data.anchor}`);
|
|
7684
7938
|
lines.push("");
|
|
7685
7939
|
lines.push("## Body");
|
|
7686
|
-
lines.push(truncateText(stringValue(view.body) || "(empty)", BODY_INLINE_CHARS, "body", appendix), "");
|
|
7940
|
+
lines.push(truncateText(stringValue(view.body) || "(empty)", BODY_INLINE_CHARS, "body", appendix, tool), "");
|
|
7687
7941
|
if (data.kind === "pull") {
|
|
7688
7942
|
lines.push("## Checks");
|
|
7689
|
-
lines.push(...renderChecks(view.statusCheckRollup), "");
|
|
7690
|
-
appendLimitedSection(lines, "Review verdicts", renderReviewVerdictsOrUnavailable(view, appendix), MAX_INLINE_REVIEWS, "review verdicts");
|
|
7691
|
-
appendLimitedSection(lines, "Linked references", renderLinkedOrUnavailable(view, "closingIssuesReferences", "closing"), 20, "linked references");
|
|
7692
|
-
appendFilesSection(lines, view);
|
|
7693
|
-
appendLimitedSection(lines, "Commits", renderCommitsOrUnavailable(view), MAX_INLINE_COMMITS, "commits");
|
|
7943
|
+
lines.push(...renderChecks(view.statusCheckRollup, appendix, tool), "");
|
|
7944
|
+
appendLimitedSection(lines, "Review verdicts", renderReviewVerdictsOrUnavailable(view, appendix, tool), MAX_INLINE_REVIEWS, "review verdicts", appendix, tool);
|
|
7945
|
+
appendLimitedSection(lines, "Linked references", renderLinkedOrUnavailable(view, "closingIssuesReferences", "closing"), 20, "linked references", appendix, tool);
|
|
7946
|
+
appendFilesSection(lines, view, appendix, tool);
|
|
7947
|
+
appendLimitedSection(lines, "Commits", renderCommitsOrUnavailable(view), MAX_INLINE_COMMITS, "commits", appendix, tool);
|
|
7694
7948
|
} else {
|
|
7695
|
-
appendLimitedSection(lines, "Closed by pull requests", renderLinkedOrUnavailable(view, "closedByPullRequestsReferences", "closedBy"), 20, "pull requests");
|
|
7949
|
+
appendLimitedSection(lines, "Closed by pull requests", renderLinkedOrUnavailable(view, "closedByPullRequestsReferences", "closedBy"), 20, "pull requests", appendix, tool);
|
|
7696
7950
|
}
|
|
7697
7951
|
lines.push("## Conversation comments");
|
|
7698
|
-
const
|
|
7699
|
-
const
|
|
7952
|
+
const comments = objectArray(view.comments);
|
|
7953
|
+
const commentLines = renderComments(comments, data.anchor, appendix, tool);
|
|
7954
|
+
const knownCommentTotal = numberValue(view.commentsCount);
|
|
7955
|
+
const commentMarker = omissionMarker("Conversation comments", "comments", commentLines.length, comments.length, knownCommentTotal !== null && knownCommentTotal > comments.length ? knownCommentTotal : null, tool, "gh issue view -c");
|
|
7700
7956
|
if (commentMarker) commentLines.push(commentMarker);
|
|
7701
7957
|
if (view.anchorUnavailable === true && data.anchor?.startsWith("issuecomment-")) commentLines.push("[anchored comment unavailable for this issue or pull request]");
|
|
7702
7958
|
lines.push(...commentLines.length > 0 ? commentLines : ["none"], "");
|
|
7703
7959
|
if (data.kind === "pull") {
|
|
7704
7960
|
lines.push("## Review thread comments");
|
|
7705
|
-
const threadLines = renderReviewThreads(data.reviewThreads, data.anchor, appendix, view.reviewCommentsCount, data.reviewThreadsBounded, data.reviewThreadsUnavailable);
|
|
7961
|
+
const threadLines = renderReviewThreads(data.reviewThreads, data.anchor, appendix, tool, view.reviewCommentsCount, data.reviewThreadsBounded, data.reviewThreadsUnavailable);
|
|
7706
7962
|
if (view.anchorUnavailable === true && data.anchor?.startsWith("discussion_r")) threadLines.push("[anchored review thread comment unavailable for this pull request]");
|
|
7707
7963
|
lines.push(...threadLines.length > 0 ? threadLines : ["none"], "");
|
|
7708
7964
|
}
|
|
7709
7965
|
if (data.fallbackNotes.length > 0) {
|
|
7710
7966
|
lines.push("## Availability notes", ...data.fallbackNotes.map((note) => `- ${note}`), "");
|
|
7711
7967
|
}
|
|
7712
|
-
if (appendix.length > 0) lines.push("## Appendix", ...appendix, "");
|
|
7713
7968
|
const viewCommand = data.kind === "pull" ? `gh pr view ${data.number} --repo ${data.owner}/${data.repo}` : `gh issue view ${data.number} --repo ${data.owner}/${data.repo} -c`;
|
|
7969
|
+
const diffCommand = data.kind === "pull" ? `gh pr diff ${data.number} --repo ${data.owner}/${data.repo}` : "";
|
|
7714
7970
|
lines.push("## Escalation commands");
|
|
7715
7971
|
lines.push(`- Full view: \`${viewCommand}\``);
|
|
7716
|
-
if (
|
|
7717
|
-
lines.push(
|
|
7972
|
+
if (diffCommand) lines.push(`- Complete diff: \`${diffCommand}\``);
|
|
7973
|
+
if (tool) lines.push(`- Stored full document: use \`${tool}\` with \`offset\` or \`findText\`.`);
|
|
7974
|
+
if (appendix.length > 0) lines.push("", "## Appendix", "", appendix.join("\n\n"));
|
|
7718
7975
|
const content = lines.join("\n");
|
|
7719
7976
|
return {
|
|
7720
7977
|
url: data.url,
|
|
7721
7978
|
title: `${data.owner}/${data.repo} ${data.kind} #${data.number}: ${title}`,
|
|
7722
7979
|
content: content.length > MAX_DOC_CHARS ? `${content.slice(0, MAX_DOC_CHARS)}
|
|
7723
7980
|
|
|
7724
|
-
[GitHub document truncated at ${MAX_DOC_CHARS} chars; use
|
|
7981
|
+
[GitHub document truncated at ${MAX_DOC_CHARS} chars; use \`${viewCommand}\`${diffCommand ? ` or \`${diffCommand}\`` : ""} for complete data]` : content,
|
|
7725
7982
|
error: null
|
|
7726
7983
|
};
|
|
7727
7984
|
}
|
|
@@ -7730,6 +7987,7 @@ async function extractGitHubIssuePr(url, signal, options) {
|
|
|
7730
7987
|
if (!info) return null;
|
|
7731
7988
|
if (!loadConfig37().enabled) return null;
|
|
7732
7989
|
if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
|
|
7990
|
+
const retrievalTool = options?.toolNames ? options.toolNames.getSearchContent ?? null : void 0;
|
|
7733
7991
|
const ghAvailable2 = await checkGhAvailable(signal);
|
|
7734
7992
|
if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
|
|
7735
7993
|
if (ghAvailable2) {
|
|
@@ -7741,23 +7999,23 @@ async function extractGitHubIssuePr(url, signal, options) {
|
|
|
7741
7999
|
if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
|
|
7742
8000
|
if (threads.anchorUnavailable) viewed.view.anchorUnavailable = true;
|
|
7743
8001
|
const notes = [...viewed.notes, ...threads.note ? [threads.note] : []];
|
|
7744
|
-
return renderGitHubPrIssue({ url, owner: info.owner, repo: info.repo, kind: info.kind, number: info.number, anchor: info.anchor, view: viewed.view, reviewThreads: threads.comments, reviewThreadsBounded: threads.bounded, reviewThreadsUnavailable: threads.unavailable, fallbackNotes: notes });
|
|
8002
|
+
return renderGitHubPrIssue({ url, owner: info.owner, repo: info.repo, kind: info.kind, number: info.number, anchor: info.anchor, view: viewed.view, reviewThreads: threads.comments, reviewThreadsBounded: threads.bounded, reviewThreadsUnavailable: threads.unavailable, fallbackNotes: notes, retrievalTool });
|
|
7745
8003
|
}
|
|
7746
8004
|
} else {
|
|
7747
8005
|
showGhHint();
|
|
7748
8006
|
}
|
|
7749
8007
|
const fallback = await restFallback(url, info, options, signal);
|
|
7750
8008
|
if (!fallback) return null;
|
|
7751
|
-
if ("data" in fallback) return renderGitHubPrIssue(fallback.data);
|
|
8009
|
+
if ("data" in fallback) return renderGitHubPrIssue({ ...fallback.data, retrievalTool });
|
|
7752
8010
|
return fallback;
|
|
7753
8011
|
}
|
|
7754
|
-
var
|
|
8012
|
+
var CONFIG_PATH43, GH_TIMEOUT_MS, GH_TOTAL_TIMEOUT_MS, MAX_DOC_CHARS, BODY_INLINE_CHARS, COMMENT_INLINE_CHARS, MAX_INLINE_COMMENTS, MAX_INLINE_REVIEWS, MAX_INLINE_CHECKS, MAX_INLINE_FILES, MAX_INLINE_COMMITS, MAX_INLINE_REVIEW_THREADS, REST_HEADERS, PR_SUBPATHS, PR_FIELDS, PR_CORE_FIELDS, ISSUE_FIELDS, ISSUE_CORE_FIELDS, cachedConfig37;
|
|
7755
8013
|
var init_github_issue_pr = __esm({
|
|
7756
8014
|
"github-issue-pr.ts"() {
|
|
7757
8015
|
init_github_api();
|
|
7758
8016
|
init_ssrf_protection();
|
|
7759
8017
|
init_utils();
|
|
7760
|
-
|
|
8018
|
+
CONFIG_PATH43 = getWebSearchConfigPath();
|
|
7761
8019
|
GH_TIMEOUT_MS = 1e4;
|
|
7762
8020
|
GH_TOTAL_TIMEOUT_MS = 2e4;
|
|
7763
8021
|
MAX_DOC_CHARS = 15e4;
|
|
@@ -7843,15 +8101,15 @@ var init_github_issue_pr = __esm({
|
|
|
7843
8101
|
});
|
|
7844
8102
|
|
|
7845
8103
|
// feature-config.ts
|
|
7846
|
-
import { existsSync as
|
|
8104
|
+
import { existsSync as existsSync48, readFileSync as readFileSync50 } from "node:fs";
|
|
7847
8105
|
function loadFeatureConfig() {
|
|
7848
|
-
if (!
|
|
8106
|
+
if (!existsSync48(CONFIG_PATH44)) return {};
|
|
7849
8107
|
try {
|
|
7850
|
-
const raw = JSON.parse(
|
|
8108
|
+
const raw = JSON.parse(readFileSync50(CONFIG_PATH44, "utf-8"));
|
|
7851
8109
|
return raw && typeof raw === "object" ? raw : {};
|
|
7852
8110
|
} catch (err) {
|
|
7853
8111
|
const message = err instanceof Error ? err.message : String(err);
|
|
7854
|
-
throw new Error(`Failed to parse ${
|
|
8112
|
+
throw new Error(`Failed to parse ${CONFIG_PATH44}: ${message}`);
|
|
7855
8113
|
}
|
|
7856
8114
|
}
|
|
7857
8115
|
function isImageEnabled() {
|
|
@@ -7864,17 +8122,17 @@ function canAttachImages() {
|
|
|
7864
8122
|
return false;
|
|
7865
8123
|
}
|
|
7866
8124
|
}
|
|
7867
|
-
var
|
|
8125
|
+
var CONFIG_PATH44;
|
|
7868
8126
|
var init_feature_config = __esm({
|
|
7869
8127
|
"feature-config.ts"() {
|
|
7870
8128
|
init_utils();
|
|
7871
|
-
|
|
8129
|
+
CONFIG_PATH44 = getWebSearchConfigPath();
|
|
7872
8130
|
}
|
|
7873
8131
|
});
|
|
7874
8132
|
|
|
7875
8133
|
// youtube-extract.ts
|
|
7876
8134
|
import { execFileSync } from "node:child_process";
|
|
7877
|
-
import { existsSync as
|
|
8135
|
+
import { existsSync as existsSync49, readFileSync as readFileSync51 } from "node:fs";
|
|
7878
8136
|
function errorMessage29(err) {
|
|
7879
8137
|
return err instanceof Error ? err.message : String(err);
|
|
7880
8138
|
}
|
|
@@ -7895,17 +8153,17 @@ function normalizeEnabled2(value, fallback) {
|
|
|
7895
8153
|
}
|
|
7896
8154
|
function loadYouTubeConfig() {
|
|
7897
8155
|
if (cachedConfig38) return cachedConfig38;
|
|
7898
|
-
if (!
|
|
8156
|
+
if (!existsSync49(CONFIG_PATH45)) {
|
|
7899
8157
|
cachedConfig38 = { ...defaults };
|
|
7900
8158
|
return cachedConfig38;
|
|
7901
8159
|
}
|
|
7902
|
-
const rawText =
|
|
8160
|
+
const rawText = readFileSync51(CONFIG_PATH45, "utf-8");
|
|
7903
8161
|
let raw;
|
|
7904
8162
|
try {
|
|
7905
8163
|
raw = JSON.parse(rawText);
|
|
7906
8164
|
} catch (err) {
|
|
7907
8165
|
const message = err instanceof Error ? err.message : String(err);
|
|
7908
|
-
throw new Error(`Failed to parse ${
|
|
8166
|
+
throw new Error(`Failed to parse ${CONFIG_PATH45}: ${message}`);
|
|
7909
8167
|
}
|
|
7910
8168
|
const yt = raw.youtube ?? {};
|
|
7911
8169
|
cachedConfig38 = {
|
|
@@ -8104,7 +8362,7 @@ ${answer}
|
|
|
8104
8362
|
return null;
|
|
8105
8363
|
}
|
|
8106
8364
|
}
|
|
8107
|
-
var
|
|
8365
|
+
var CONFIG_PATH45, YOUTUBE_PROMPT, YOUTUBE_REGEX, defaults, cachedConfig38;
|
|
8108
8366
|
var init_youtube_extract = __esm({
|
|
8109
8367
|
"youtube-extract.ts"() {
|
|
8110
8368
|
init_activity();
|
|
@@ -8114,7 +8372,7 @@ var init_youtube_extract = __esm({
|
|
|
8114
8372
|
init_perplexity();
|
|
8115
8373
|
init_extract();
|
|
8116
8374
|
init_utils();
|
|
8117
|
-
|
|
8375
|
+
CONFIG_PATH45 = getWebSearchConfigPath();
|
|
8118
8376
|
YOUTUBE_PROMPT = `Extract the complete content of this YouTube video. Include:
|
|
8119
8377
|
1. Video title, channel name, and duration
|
|
8120
8378
|
2. A brief summary (2-3 sentences)
|
|
@@ -8226,23 +8484,23 @@ URL: `;
|
|
|
8226
8484
|
});
|
|
8227
8485
|
|
|
8228
8486
|
// crawl4ai.ts
|
|
8229
|
-
import { existsSync as
|
|
8487
|
+
import { existsSync as existsSync50, readFileSync as readFileSync52 } from "node:fs";
|
|
8230
8488
|
function loadConfig38() {
|
|
8231
8489
|
if (cachedConfig39) return cachedConfig39;
|
|
8232
|
-
if (!
|
|
8490
|
+
if (!existsSync50(CONFIG_PATH46)) {
|
|
8233
8491
|
cachedConfig39 = {};
|
|
8234
8492
|
return cachedConfig39;
|
|
8235
8493
|
}
|
|
8236
|
-
const raw =
|
|
8494
|
+
const raw = readFileSync52(CONFIG_PATH46, "utf8");
|
|
8237
8495
|
let parsed;
|
|
8238
8496
|
try {
|
|
8239
8497
|
parsed = JSON.parse(raw);
|
|
8240
8498
|
} catch (err) {
|
|
8241
8499
|
const message = err instanceof Error ? err.message : String(err);
|
|
8242
|
-
throw new Error(`Failed to parse ${
|
|
8500
|
+
throw new Error(`Failed to parse ${CONFIG_PATH46}: ${message}`);
|
|
8243
8501
|
}
|
|
8244
8502
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
8245
|
-
throw new Error(`Invalid config in ${
|
|
8503
|
+
throw new Error(`Invalid config in ${CONFIG_PATH46}: expected a JSON object`);
|
|
8246
8504
|
}
|
|
8247
8505
|
cachedConfig39 = parsed;
|
|
8248
8506
|
return cachedConfig39;
|
|
@@ -8255,13 +8513,13 @@ function normalizeBaseUrl5(value) {
|
|
|
8255
8513
|
try {
|
|
8256
8514
|
parsed = new URL(trimmed);
|
|
8257
8515
|
} catch {
|
|
8258
|
-
throw new Error(`Invalid Crawl4AI base URL in ${
|
|
8516
|
+
throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH46}: expected an HTTP or HTTPS URL`);
|
|
8259
8517
|
}
|
|
8260
8518
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
8261
|
-
throw new Error(`Invalid Crawl4AI base URL in ${
|
|
8519
|
+
throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH46}: expected an HTTP or HTTPS URL`);
|
|
8262
8520
|
}
|
|
8263
8521
|
if (parsed.username || parsed.password) {
|
|
8264
|
-
throw new Error(`Invalid Crawl4AI base URL in ${
|
|
8522
|
+
throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH46}: URL credentials are not allowed`);
|
|
8265
8523
|
}
|
|
8266
8524
|
parsed.pathname = parsed.pathname.replace(/\/+$/, "");
|
|
8267
8525
|
parsed.search = "";
|
|
@@ -8276,7 +8534,7 @@ function requireBaseUrl4() {
|
|
|
8276
8534
|
if (!baseUrl) {
|
|
8277
8535
|
throw new Error(
|
|
8278
8536
|
`Crawl4AI base URL not configured. Either:
|
|
8279
|
-
1. Set crawl4aiBaseUrl in ${
|
|
8537
|
+
1. Set crawl4aiBaseUrl in ${CONFIG_PATH46}
|
|
8280
8538
|
2. Set CRAWL4AI_BASE_URL environment variable`
|
|
8281
8539
|
);
|
|
8282
8540
|
}
|
|
@@ -8375,14 +8633,14 @@ async function extractWithCrawl4ai(url, signal, options) {
|
|
|
8375
8633
|
throw err;
|
|
8376
8634
|
}
|
|
8377
8635
|
}
|
|
8378
|
-
var
|
|
8636
|
+
var CONFIG_PATH46, EXTRACT_TIMEOUT_MS2, MARKDOWN_FILTER, cachedConfig39;
|
|
8379
8637
|
var init_crawl4ai = __esm({
|
|
8380
8638
|
"crawl4ai.ts"() {
|
|
8381
8639
|
init_activity();
|
|
8382
8640
|
init_credential_source();
|
|
8383
8641
|
init_ssrf_protection();
|
|
8384
8642
|
init_utils();
|
|
8385
|
-
|
|
8643
|
+
CONFIG_PATH46 = getWebSearchConfigPath();
|
|
8386
8644
|
EXTRACT_TIMEOUT_MS2 = 6e4;
|
|
8387
8645
|
MARKDOWN_FILTER = "fit";
|
|
8388
8646
|
cachedConfig39 = null;
|
|
@@ -8390,7 +8648,7 @@ var init_crawl4ai = __esm({
|
|
|
8390
8648
|
});
|
|
8391
8649
|
|
|
8392
8650
|
// brightdata-unlocker.ts
|
|
8393
|
-
import { existsSync as
|
|
8651
|
+
import { existsSync as existsSync51, readFileSync as readFileSync53 } from "node:fs";
|
|
8394
8652
|
function parseFailureDetail(err) {
|
|
8395
8653
|
const message = err instanceof Error ? err.message : String(err);
|
|
8396
8654
|
const position = message.match(/at position \d+(?: \(line \d+ column \d+\))?/);
|
|
@@ -8398,19 +8656,19 @@ function parseFailureDetail(err) {
|
|
|
8398
8656
|
}
|
|
8399
8657
|
function loadConfig39() {
|
|
8400
8658
|
if (cachedConfig40) return cachedConfig40;
|
|
8401
|
-
if (!
|
|
8659
|
+
if (!existsSync51(CONFIG_PATH47)) {
|
|
8402
8660
|
cachedConfig40 = {};
|
|
8403
8661
|
return cachedConfig40;
|
|
8404
8662
|
}
|
|
8405
|
-
const raw =
|
|
8663
|
+
const raw = readFileSync53(CONFIG_PATH47, "utf8");
|
|
8406
8664
|
let parsed;
|
|
8407
8665
|
try {
|
|
8408
8666
|
parsed = JSON.parse(raw);
|
|
8409
8667
|
} catch (err) {
|
|
8410
|
-
throw new Error(`Failed to parse ${
|
|
8668
|
+
throw new Error(`Failed to parse ${CONFIG_PATH47}: ${parseFailureDetail(err)}`);
|
|
8411
8669
|
}
|
|
8412
8670
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
8413
|
-
throw new Error(`Invalid config in ${
|
|
8671
|
+
throw new Error(`Invalid config in ${CONFIG_PATH47}: expected a JSON object`);
|
|
8414
8672
|
}
|
|
8415
8673
|
cachedConfig40 = parsed;
|
|
8416
8674
|
return cachedConfig40;
|
|
@@ -8425,7 +8683,7 @@ function zoneSetting() {
|
|
|
8425
8683
|
const fromEnv = process.env.BRIGHTDATA_UNLOCKER_ZONE;
|
|
8426
8684
|
if (typeof fromEnv === "string" && fromEnv.trim()) return { raw: fromEnv.trim(), label: "BRIGHTDATA_UNLOCKER_ZONE" };
|
|
8427
8685
|
const configured = loadConfig39().brightdataUnlockerZone;
|
|
8428
|
-
if (typeof configured === "string" && configured.trim()) return { raw: configured.trim(), label: `brightdataUnlockerZone in ${
|
|
8686
|
+
if (typeof configured === "string" && configured.trim()) return { raw: configured.trim(), label: `brightdataUnlockerZone in ${CONFIG_PATH47}` };
|
|
8429
8687
|
return null;
|
|
8430
8688
|
}
|
|
8431
8689
|
function getZone() {
|
|
@@ -8443,7 +8701,7 @@ function requireZone() {
|
|
|
8443
8701
|
}
|
|
8444
8702
|
throw new Error(
|
|
8445
8703
|
`Bright Data Web Unlocker zone not configured. Either:
|
|
8446
|
-
1. Set brightdataUnlockerZone in ${
|
|
8704
|
+
1. Set brightdataUnlockerZone in ${CONFIG_PATH47}
|
|
8447
8705
|
2. Set BRIGHTDATA_UNLOCKER_ZONE environment variable
|
|
8448
8706
|
The zone must be of type "unblocker"; a SERP zone will not serve Web Unlocker requests.`
|
|
8449
8707
|
);
|
|
@@ -8458,7 +8716,7 @@ async function getApiKey27(signal) {
|
|
|
8458
8716
|
if (!apiKey) {
|
|
8459
8717
|
throw new Error(
|
|
8460
8718
|
`Bright Data API key not found. Either:
|
|
8461
|
-
1. Create ${
|
|
8719
|
+
1. Create ${CONFIG_PATH47} with { "brightdataApiKey": "your-key" }
|
|
8462
8720
|
2. Set BRIGHTDATA_API_KEY environment variable
|
|
8463
8721
|
Get a key at https://brightdata.com/cp/setting/users`
|
|
8464
8722
|
);
|
|
@@ -8567,14 +8825,14 @@ async function extractWithBrightDataUnlocker(url, signal, options) {
|
|
|
8567
8825
|
if (!content) return null;
|
|
8568
8826
|
return { url, title: headingTitle(content), content, error: null };
|
|
8569
8827
|
}
|
|
8570
|
-
var
|
|
8828
|
+
var CONFIG_PATH47, BRIGHTDATA_REQUEST_URL, EXTRACT_TIMEOUT_MS3, DEFAULT_MAX_REDIRECTS3, REDIRECT_STATUSES3, ZONE_PATTERN2, cachedConfig40;
|
|
8571
8829
|
var init_brightdata_unlocker = __esm({
|
|
8572
8830
|
"brightdata-unlocker.ts"() {
|
|
8573
8831
|
init_activity();
|
|
8574
8832
|
init_credential_source();
|
|
8575
8833
|
init_ssrf_protection();
|
|
8576
8834
|
init_utils();
|
|
8577
|
-
|
|
8835
|
+
CONFIG_PATH47 = getWebSearchConfigPath();
|
|
8578
8836
|
BRIGHTDATA_REQUEST_URL = "https://api.brightdata.com/request";
|
|
8579
8837
|
EXTRACT_TIMEOUT_MS3 = 6e4;
|
|
8580
8838
|
DEFAULT_MAX_REDIRECTS3 = 5;
|
|
@@ -8586,7 +8844,7 @@ var init_brightdata_unlocker = __esm({
|
|
|
8586
8844
|
|
|
8587
8845
|
// video-extract.ts
|
|
8588
8846
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
8589
|
-
import { existsSync as
|
|
8847
|
+
import { existsSync as existsSync52, readFileSync as readFileSync54, readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
|
|
8590
8848
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
8591
8849
|
import { resolve, extname as extname2, basename as basename4, join as join7, dirname as dirname2 } from "node:path";
|
|
8592
8850
|
function shouldRethrow3(err) {
|
|
@@ -8607,17 +8865,17 @@ function normalizeMaxSizeMB(value, fallback) {
|
|
|
8607
8865
|
}
|
|
8608
8866
|
function loadVideoConfig() {
|
|
8609
8867
|
if (cachedVideoConfig) return cachedVideoConfig;
|
|
8610
|
-
if (!
|
|
8868
|
+
if (!existsSync52(CONFIG_PATH48)) {
|
|
8611
8869
|
cachedVideoConfig = { ...VIDEO_CONFIG_DEFAULTS };
|
|
8612
8870
|
return cachedVideoConfig;
|
|
8613
8871
|
}
|
|
8614
|
-
const rawText =
|
|
8872
|
+
const rawText = readFileSync54(CONFIG_PATH48, "utf-8");
|
|
8615
8873
|
let raw;
|
|
8616
8874
|
try {
|
|
8617
8875
|
raw = JSON.parse(rawText);
|
|
8618
8876
|
} catch (err) {
|
|
8619
8877
|
const message = err instanceof Error ? err.message : String(err);
|
|
8620
|
-
throw new Error(`Failed to parse ${
|
|
8878
|
+
throw new Error(`Failed to parse ${CONFIG_PATH48}: ${message}`);
|
|
8621
8879
|
}
|
|
8622
8880
|
const v = raw.video ?? {};
|
|
8623
8881
|
cachedVideoConfig = {
|
|
@@ -8663,10 +8921,10 @@ function isVideoFile(input) {
|
|
|
8663
8921
|
}
|
|
8664
8922
|
function resolveFilePath(filePath) {
|
|
8665
8923
|
const absolutePath = resolve(filePath);
|
|
8666
|
-
if (
|
|
8924
|
+
if (existsSync52(absolutePath)) return absolutePath;
|
|
8667
8925
|
const dir = dirname2(absolutePath);
|
|
8668
8926
|
const base = basename4(absolutePath);
|
|
8669
|
-
if (!
|
|
8927
|
+
if (!existsSync52(dir)) return null;
|
|
8670
8928
|
try {
|
|
8671
8929
|
const normalizedBase = normalizeSpaces(base);
|
|
8672
8930
|
const match = readdirSync4(dir).find((f) => normalizeSpaces(f) === normalizedBase);
|
|
@@ -8824,8 +9082,9 @@ async function uploadToFilesApi(info, apiKey, signal) {
|
|
|
8824
9082
|
}
|
|
8825
9083
|
const uploadUrl = initRes.headers.get("x-goog-upload-url");
|
|
8826
9084
|
if (!uploadUrl) throw new Error("No upload URL in response headers");
|
|
9085
|
+
const routedUploadUrl = rewriteUploadUrlOrigin(uploadUrl);
|
|
8827
9086
|
const fileData = await readFile2(info.absolutePath);
|
|
8828
|
-
const uploadRes = await fetchGeminiApi(
|
|
9087
|
+
const uploadRes = await fetchGeminiApi(routedUploadUrl, {
|
|
8829
9088
|
method: "PUT",
|
|
8830
9089
|
headers: {
|
|
8831
9090
|
"Content-Length": String(info.sizeBytes),
|
|
@@ -8864,7 +9123,7 @@ function deleteGeminiFile(fileName, apiKey) {
|
|
|
8864
9123
|
function extractVideoTitle(text4, filePath) {
|
|
8865
9124
|
return extractHeadingTitle(text4) ?? basename4(filePath, extname2(filePath));
|
|
8866
9125
|
}
|
|
8867
|
-
var
|
|
9126
|
+
var CONFIG_PATH48, DEFAULT_VIDEO_PROMPT, VIDEO_EXTENSIONS, VIDEO_CONFIG_DEFAULTS, cachedVideoConfig;
|
|
8868
9127
|
var init_video_extract = __esm({
|
|
8869
9128
|
"video-extract.ts"() {
|
|
8870
9129
|
init_activity();
|
|
@@ -8873,7 +9132,7 @@ var init_video_extract = __esm({
|
|
|
8873
9132
|
init_gemini_api();
|
|
8874
9133
|
init_extract();
|
|
8875
9134
|
init_utils();
|
|
8876
|
-
|
|
9135
|
+
CONFIG_PATH48 = getWebSearchConfigPath();
|
|
8877
9136
|
DEFAULT_VIDEO_PROMPT = `Extract the complete content of this video. Include:
|
|
8878
9137
|
1. Video title (infer from content if not explicit), duration
|
|
8879
9138
|
2. A brief summary (2-3 sentences)
|
|
@@ -9358,13 +9617,13 @@ __export(extract_exports, {
|
|
|
9358
9617
|
readPDFResponseBuffer: () => readPDFResponseBuffer,
|
|
9359
9618
|
resolveFetchTimeoutMs: () => resolveFetchTimeoutMs
|
|
9360
9619
|
});
|
|
9361
|
-
import { existsSync as
|
|
9620
|
+
import { existsSync as existsSync53, readFileSync as readFileSync55 } from "node:fs";
|
|
9362
9621
|
import pLimit from "p-limit";
|
|
9363
9622
|
function loadFetchTimeoutMs() {
|
|
9364
|
-
if (!
|
|
9623
|
+
if (!existsSync53(WEB_SEARCH_CONFIG_PATH3)) return DEFAULT_TIMEOUT_MS4;
|
|
9365
9624
|
let raw;
|
|
9366
9625
|
try {
|
|
9367
|
-
raw = JSON.parse(
|
|
9626
|
+
raw = JSON.parse(readFileSync55(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
|
|
9368
9627
|
} catch (err) {
|
|
9369
9628
|
const message = err instanceof Error ? err.message : String(err);
|
|
9370
9629
|
throw new Error(`Failed to parse ${WEB_SEARCH_CONFIG_PATH3}: ${message}`);
|
|
@@ -9373,12 +9632,12 @@ function loadFetchTimeoutMs() {
|
|
|
9373
9632
|
throw new Error(`Invalid config in ${WEB_SEARCH_CONFIG_PATH3}: expected a JSON object`);
|
|
9374
9633
|
}
|
|
9375
9634
|
const fetchConfig = raw.fetch;
|
|
9376
|
-
if (fetchConfig === void 0) return
|
|
9635
|
+
if (fetchConfig === void 0) return DEFAULT_TIMEOUT_MS4;
|
|
9377
9636
|
if (!fetchConfig || typeof fetchConfig !== "object" || Array.isArray(fetchConfig)) {
|
|
9378
9637
|
throw new Error(`fetch in ${WEB_SEARCH_CONFIG_PATH3} must be an object`);
|
|
9379
9638
|
}
|
|
9380
9639
|
const value = fetchConfig.timeout;
|
|
9381
|
-
if (value === void 0) return
|
|
9640
|
+
if (value === void 0) return DEFAULT_TIMEOUT_MS4;
|
|
9382
9641
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
9383
9642
|
throw new Error(`Invalid fetch.timeout in ${WEB_SEARCH_CONFIG_PATH3}: expected a positive finite number of seconds, got ${JSON.stringify(value)}`);
|
|
9384
9643
|
}
|
|
@@ -9439,7 +9698,7 @@ function isAbortException2(err) {
|
|
|
9439
9698
|
return err instanceof DOMException && (err.name === "AbortError" || err.name === "TimeoutError");
|
|
9440
9699
|
}
|
|
9441
9700
|
function isRedirectPolicyError(message) {
|
|
9442
|
-
return message.startsWith("Authenticated fetch refused cross-origin redirect") || message.startsWith("Blocked internal ") || message.startsWith("Blocked hostname by fetch_content domain policy") || message.startsWith("Hostname not allowed by fetch_content domain policy") || message.startsWith("Too many redirects fetching ") || message === "Only HTTP and HTTPS URLs can be fetched remotely" || message === "URL must include a hostname" || message.startsWith("Failed to resolve ");
|
|
9701
|
+
return message.startsWith("Authenticated fetch refused cross-origin redirect") || message.startsWith("Refused cross-origin redirect by fetch_content redirect policy") || message.startsWith("Blocked internal ") || message.startsWith("Blocked hostname by fetch_content domain policy") || message.startsWith("Hostname not allowed by fetch_content domain policy") || message.startsWith("Too many redirects fetching ") || message === "Only HTTP and HTTPS URLs can be fetched remotely" || message === "URL must include a hostname" || message.startsWith("Failed to resolve ");
|
|
9443
9702
|
}
|
|
9444
9703
|
function isNonRecoverableHttpError(error) {
|
|
9445
9704
|
return !!error && (NON_RECOVERABLE_ERRORS.some((prefix) => error.startsWith(prefix)) || isRedirectPolicyError(error) || isConfigParseError(error));
|
|
@@ -9451,6 +9710,9 @@ function imageGateError() {
|
|
|
9451
9710
|
return errorMessage32(err);
|
|
9452
9711
|
}
|
|
9453
9712
|
}
|
|
9713
|
+
function redirectPolicyRouteRefusal(url, path) {
|
|
9714
|
+
return { url, title: "", content: "", error: `Extraction path ${path} is disabled by the fetch_content same-origin redirect policy because its redirect chain cannot be observed` };
|
|
9715
|
+
}
|
|
9454
9716
|
async function resolveAuthCookieHeader(url, profile) {
|
|
9455
9717
|
const parsed = assertAuthFetchUrl(profile, url.toString());
|
|
9456
9718
|
const result = await getBrowserCookiesForHosts({ hosts: [parsed.hostname], profile: profile.chromeProfile, requestUrl: parsed });
|
|
@@ -9469,6 +9731,7 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
|
|
|
9469
9731
|
proxy: validationOptions.proxy,
|
|
9470
9732
|
...validationOptions.lookup ? { lookup: validationOptions.lookup } : {}
|
|
9471
9733
|
});
|
|
9734
|
+
const originalOrigin = current.origin;
|
|
9472
9735
|
let requestInit = init;
|
|
9473
9736
|
for (let redirects = 0; redirects <= 5; redirects++) {
|
|
9474
9737
|
const cookieHeader = await resolveAuthCookieHeader(current, profile);
|
|
@@ -9479,7 +9742,11 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
|
|
|
9479
9742
|
if (!location) return response;
|
|
9480
9743
|
if (redirects === 5) throw new Error(`Too many redirects fetching ${current.toString()}`);
|
|
9481
9744
|
const from = current;
|
|
9482
|
-
|
|
9745
|
+
const next = new URL(location, current);
|
|
9746
|
+
if (validationOptions.redirects === "same-origin" && next.origin !== originalOrigin) {
|
|
9747
|
+
throw new Error(`Refused cross-origin redirect by fetch_content redirect policy: ${originalOrigin} -> ${next.origin}`);
|
|
9748
|
+
}
|
|
9749
|
+
current = await validateRemoteUrl(next, {
|
|
9483
9750
|
allowRanges: validationOptions.ssrf.allowRanges,
|
|
9484
9751
|
trustEnvProxy: validationOptions.ssrf.trustEnvProxy,
|
|
9485
9752
|
domainPolicy: validationOptions.domainPolicy,
|
|
@@ -9495,12 +9762,12 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
|
|
|
9495
9762
|
throw new Error(`Too many redirects fetching ${current.toString()}`);
|
|
9496
9763
|
}
|
|
9497
9764
|
function loadFetchRouting() {
|
|
9498
|
-
if (!
|
|
9765
|
+
if (!existsSync53(WEB_SEARCH_CONFIG_PATH3)) {
|
|
9499
9766
|
return { providers: DEFAULT_FETCH_PROVIDER_ORDER, allowRemoteHostedProviders: false };
|
|
9500
9767
|
}
|
|
9501
9768
|
let raw;
|
|
9502
9769
|
try {
|
|
9503
|
-
const parsed = JSON.parse(
|
|
9770
|
+
const parsed = JSON.parse(readFileSync55(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
|
|
9504
9771
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
9505
9772
|
throw new Error("expected a JSON object");
|
|
9506
9773
|
}
|
|
@@ -9698,6 +9965,12 @@ async function extractContent(url, signal, options) {
|
|
|
9698
9965
|
if (signal?.aborted) {
|
|
9699
9966
|
return { url, title: "", content: "", error: "Aborted" };
|
|
9700
9967
|
}
|
|
9968
|
+
let redirectPolicy;
|
|
9969
|
+
try {
|
|
9970
|
+
redirectPolicy = options?.redirects ?? loadFetchContentRedirectPolicy();
|
|
9971
|
+
} catch (err) {
|
|
9972
|
+
return { url, title: "", content: "", error: errorMessage32(err) };
|
|
9973
|
+
}
|
|
9701
9974
|
let remoteUrl = null;
|
|
9702
9975
|
try {
|
|
9703
9976
|
const parsed = new URL(url);
|
|
@@ -9708,6 +9981,7 @@ async function extractContent(url, signal, options) {
|
|
|
9708
9981
|
try {
|
|
9709
9982
|
const ssrf = loadSsrfConfig();
|
|
9710
9983
|
const domainPolicy = loadFetchContentDomainPolicy();
|
|
9984
|
+
loadFetchContentUserAgent();
|
|
9711
9985
|
await validateRemoteUrl(remoteUrl, {
|
|
9712
9986
|
allowRanges: ssrf.allowRanges,
|
|
9713
9987
|
trustEnvProxy: ssrf.trustEnvProxy,
|
|
@@ -9726,6 +10000,11 @@ async function extractContent(url, signal, options) {
|
|
|
9726
10000
|
return { url, title: "", content: "", error: errorMessage32(err) };
|
|
9727
10001
|
}
|
|
9728
10002
|
}
|
|
10003
|
+
if (redirectPolicy) {
|
|
10004
|
+
if (parseGitHubIssuePrUrl(url)) return redirectPolicyRouteRefusal(url, "GitHub issue/PR");
|
|
10005
|
+
if (parseGitHubUrl(url)) return redirectPolicyRouteRefusal(url, "GitHub repository");
|
|
10006
|
+
if (isYouTubeURL(url).isYouTube) return redirectPolicyRouteRefusal(url, "YouTube");
|
|
10007
|
+
}
|
|
9729
10008
|
if (options?.frames || options?.timestamp) {
|
|
9730
10009
|
const disabled = imageGateError();
|
|
9731
10010
|
if (disabled) return { url, title: "", content: "", error: disabled };
|
|
@@ -9820,7 +10099,7 @@ async function extractContent(url, signal, options) {
|
|
|
9820
10099
|
if ("error" in frame) {
|
|
9821
10100
|
return { url, title: `Frame at ${options.timestamp}`, content: frame.error, error: frame.error };
|
|
9822
10101
|
}
|
|
9823
|
-
return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame };
|
|
10102
|
+
return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame, mimeType: frame.mimeType };
|
|
9824
10103
|
}
|
|
9825
10104
|
const localVideo2 = safeVideoInfo(url);
|
|
9826
10105
|
if (localVideo2.status === "invalid") {
|
|
@@ -9844,7 +10123,7 @@ async function extractContent(url, signal, options) {
|
|
|
9844
10123
|
if ("error" in frame) {
|
|
9845
10124
|
return { url, title: `Frame at ${options.timestamp}`, content: frame.error, error: frame.error };
|
|
9846
10125
|
}
|
|
9847
|
-
return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame };
|
|
10126
|
+
return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame, mimeType: frame.mimeType };
|
|
9848
10127
|
}
|
|
9849
10128
|
return { url, title: "", content: "", error: "Timestamp extraction only works with YouTube and local video files" };
|
|
9850
10129
|
}
|
|
@@ -9928,7 +10207,10 @@ async function extractContent(url, signal, options) {
|
|
|
9928
10207
|
} catch (err) {
|
|
9929
10208
|
return { url, title: "", content: "", error: errorMessage32(err) };
|
|
9930
10209
|
}
|
|
9931
|
-
|
|
10210
|
+
if (redirectPolicy && !fetchRouting.providers.includes("http")) {
|
|
10211
|
+
return redirectPolicyRouteRefusal(url, fetchRouting.providers[0]);
|
|
10212
|
+
}
|
|
10213
|
+
const providerOrder = redirectPolicy ? ["http"] : remoteUrl && !fetchRouting.allowRemoteHostedProviders ? fetchRouting.providers.filter((provider) => !REMOTE_HOSTED_FETCH_PROVIDERS.has(provider)) : fetchRouting.providers;
|
|
9932
10214
|
if (providerOrder.length === 0) {
|
|
9933
10215
|
return {
|
|
9934
10216
|
url,
|
|
@@ -10153,6 +10435,7 @@ async function extractContent(url, signal, options) {
|
|
|
10153
10435
|
if (finalHttpResult?.status === 404 || finalHttpResult?.status === 410) {
|
|
10154
10436
|
return { ...finalHttpResult, error: notFoundGuidance(finalHttpResult, options?.toolNames) };
|
|
10155
10437
|
}
|
|
10438
|
+
if (redirectPolicy && finalHttpResult) return finalHttpResult;
|
|
10156
10439
|
const searchToolName = options?.toolNames?.webSearch;
|
|
10157
10440
|
const jinaHint = jinaReaderGuidance(fetchRouting, providerOrder, Boolean(remoteUrl) && !fetchRouting.allowRemoteHostedProviders);
|
|
10158
10441
|
const guidance = [
|
|
@@ -10263,12 +10546,13 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
|
|
|
10263
10546
|
try {
|
|
10264
10547
|
const ssrf = loadSsrfConfig();
|
|
10265
10548
|
const domainPolicy = loadFetchContentDomainPolicy();
|
|
10549
|
+
const redirects = options?.redirects ?? loadFetchContentRedirectPolicy();
|
|
10266
10550
|
const authProfile = options?.authFetchProfile;
|
|
10267
10551
|
const requestInit = {
|
|
10268
10552
|
signal: controller.signal,
|
|
10269
10553
|
__proxy: options?.proxy,
|
|
10270
10554
|
headers: {
|
|
10271
|
-
"User-Agent":
|
|
10555
|
+
"User-Agent": loadFetchContentUserAgent(),
|
|
10272
10556
|
"Accept": preferMarkdown ? MARKDOWN_FIRST_ACCEPT : BROWSER_ACCEPT,
|
|
10273
10557
|
"Accept-Language": "en-US,en;q=0.9",
|
|
10274
10558
|
"Cache-Control": "no-cache",
|
|
@@ -10279,13 +10563,14 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
|
|
|
10279
10563
|
"Upgrade-Insecure-Requests": "1"
|
|
10280
10564
|
}
|
|
10281
10565
|
};
|
|
10282
|
-
const response = authProfile ? await fetchAuthenticatedRemoteUrl(url, requestInit, { ssrf, domainPolicy, proxy: options?.proxy, ...options?.lookup ? { lookup: options.lookup } : {} }, authProfile) : await fetchRemoteUrl(
|
|
10566
|
+
const response = authProfile ? await fetchAuthenticatedRemoteUrl(url, requestInit, { ssrf, domainPolicy, redirects, proxy: options?.proxy, ...options?.lookup ? { lookup: options.lookup } : {} }, authProfile) : await fetchRemoteUrl(
|
|
10283
10567
|
url,
|
|
10284
10568
|
requestInit,
|
|
10285
10569
|
{
|
|
10286
10570
|
allowRanges: ssrf.allowRanges,
|
|
10287
10571
|
trustEnvProxy: ssrf.trustEnvProxy,
|
|
10288
10572
|
domainPolicy,
|
|
10573
|
+
redirects,
|
|
10289
10574
|
proxy: options?.proxy,
|
|
10290
10575
|
...options?.lookup ? { lookup: options.lookup } : {}
|
|
10291
10576
|
}
|
|
@@ -10325,7 +10610,8 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
|
|
|
10325
10610
|
if (options?.mode === "raw") {
|
|
10326
10611
|
if (!isTextContentType(contentType)) {
|
|
10327
10612
|
activityMonitor.logComplete(activityId, response.status);
|
|
10328
|
-
|
|
10613
|
+
const hint = isPDFContent ? '; retry without mode for Markdown, or with mode "answer" and a prompt' : "";
|
|
10614
|
+
return { url, title: "", content: "", error: `Unsupported content type in raw mode: ${mimeType || "missing"}${hint}`, mimeType, status: response.status };
|
|
10329
10615
|
}
|
|
10330
10616
|
const text5 = await readTextResponseWithLimit(response, maxResponseSize);
|
|
10331
10617
|
activityMonitor.logComplete(activityId, response.status);
|
|
@@ -10374,8 +10660,8 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
|
|
|
10374
10660
|
title: result.title,
|
|
10375
10661
|
content: options?.mode === "answer" ? result.content : `PDF extracted and saved to: ${result.outputPath}
|
|
10376
10662
|
|
|
10377
|
-
Pages: ${result.pages}
|
|
10378
|
-
Characters: ${result.chars}`,
|
|
10663
|
+
${result.pages > 0 ? `Pages: ${result.pages}
|
|
10664
|
+
` : ""}Characters: ${result.chars}`,
|
|
10379
10665
|
error: null
|
|
10380
10666
|
};
|
|
10381
10667
|
} catch (err) {
|
|
@@ -10548,7 +10834,7 @@ async function fetchAllContent(urls, signal, options) {
|
|
|
10548
10834
|
return sanitized.omissions.length > 0 ? { ...result, content: sanitized.text } : result;
|
|
10549
10835
|
});
|
|
10550
10836
|
}
|
|
10551
|
-
var
|
|
10837
|
+
var DEFAULT_TIMEOUT_MS4, MAX_CONFIGURED_TIMEOUT_MS, CONCURRENT_LIMIT, WEB_SEARCH_CONFIG_PATH3, NON_RECOVERABLE_ERRORS, MIN_USEFUL_CONTENT2, SUPPORTED_IMAGE_TYPES, FETCH_PROVIDERS, DEFAULT_FETCH_PROVIDER_ORDER, REMOTE_HOSTED_FETCH_PROVIDERS, REDIRECT_STATUSES4, turndownInstance, fetchLimit, JINA_READER_BASE, DEFAULT_RANGE_FRAMES, MIN_FRAME_INTERVAL, BROWSER_ACCEPT, MARKDOWN_FIRST_ACCEPT;
|
|
10552
10838
|
var init_extract = __esm({
|
|
10553
10839
|
"extract.ts"() {
|
|
10554
10840
|
init_activity();
|
|
@@ -10578,7 +10864,7 @@ var init_extract = __esm({
|
|
|
10578
10864
|
init_chrome_cookies();
|
|
10579
10865
|
init_data_uri_sanitize();
|
|
10580
10866
|
init_ssrf_protection();
|
|
10581
|
-
|
|
10867
|
+
DEFAULT_TIMEOUT_MS4 = 3e4;
|
|
10582
10868
|
MAX_CONFIGURED_TIMEOUT_MS = 2147483647;
|
|
10583
10869
|
CONCURRENT_LIMIT = 3;
|
|
10584
10870
|
WEB_SEARCH_CONFIG_PATH3 = getWebSearchConfigPath();
|
|
@@ -10617,6 +10903,7 @@ function normalizeFetchContentParams(params) {
|
|
|
10617
10903
|
const answerModel = normalizeOptionalString(params.answerModel);
|
|
10618
10904
|
const auth = normalizeAuth(params.auth);
|
|
10619
10905
|
const proxy = normalizeProxy(params.proxy);
|
|
10906
|
+
const redirects = normalizeRedirects(params.redirects);
|
|
10620
10907
|
return {
|
|
10621
10908
|
urlList,
|
|
10622
10909
|
options: {
|
|
@@ -10628,7 +10915,8 @@ function normalizeFetchContentParams(params) {
|
|
|
10628
10915
|
...mode !== void 0 ? { mode } : {},
|
|
10629
10916
|
...answerModel !== void 0 ? { answerModel } : {},
|
|
10630
10917
|
...auth !== void 0 ? { auth } : {},
|
|
10631
|
-
...proxy !== void 0 ? { proxy } : {}
|
|
10918
|
+
...proxy !== void 0 ? { proxy } : {},
|
|
10919
|
+
...redirects !== void 0 ? { redirects } : {}
|
|
10632
10920
|
}
|
|
10633
10921
|
};
|
|
10634
10922
|
}
|
|
@@ -10651,6 +10939,11 @@ function normalizeMode(value) {
|
|
|
10651
10939
|
if (value === "readable" || value === "raw" || value === "answer") return value;
|
|
10652
10940
|
throw new Error('mode must be "readable", "raw", or "answer"');
|
|
10653
10941
|
}
|
|
10942
|
+
function normalizeRedirects(value) {
|
|
10943
|
+
if (value === void 0) return void 0;
|
|
10944
|
+
if (value === "same-origin") return value;
|
|
10945
|
+
throw new Error('redirects must be "same-origin"');
|
|
10946
|
+
}
|
|
10654
10947
|
function normalizeAuth(value) {
|
|
10655
10948
|
if (value === void 0 || value === false) return void 0;
|
|
10656
10949
|
if (value === true) return true;
|
|
@@ -11409,7 +11702,7 @@ init_credential_source();
|
|
|
11409
11702
|
init_utils();
|
|
11410
11703
|
var BRAVE_API_BASE_URL = "https://api.search.brave.com/res/v1";
|
|
11411
11704
|
var CONFIG_PATH7 = getWebSearchConfigPath();
|
|
11412
|
-
var
|
|
11705
|
+
var SEARCH_TIMEOUT_MS2 = 3e4;
|
|
11413
11706
|
var braveRateLimit = new BraveRateLimitCoordinator();
|
|
11414
11707
|
var cachedConfig7 = null;
|
|
11415
11708
|
function loadConfig6() {
|
|
@@ -11484,6 +11777,31 @@ function matchesDomainFilters(url, filters) {
|
|
|
11484
11777
|
}
|
|
11485
11778
|
return !filters.blocked.some((domain) => hostMatchesDomain(hostname2, domain));
|
|
11486
11779
|
}
|
|
11780
|
+
var HTML_ENTITIES = {
|
|
11781
|
+
"&": "&",
|
|
11782
|
+
"<": "<",
|
|
11783
|
+
">": ">",
|
|
11784
|
+
""": '"',
|
|
11785
|
+
"'": "'",
|
|
11786
|
+
" ": " ",
|
|
11787
|
+
"—": "\u2014",
|
|
11788
|
+
"–": "\u2013",
|
|
11789
|
+
"…": "\u2026",
|
|
11790
|
+
"’": "\u2019",
|
|
11791
|
+
"‘": "\u2018",
|
|
11792
|
+
"”": "\u201D",
|
|
11793
|
+
"“": "\u201C",
|
|
11794
|
+
"·": "\xB7",
|
|
11795
|
+
"•": "\u2022",
|
|
11796
|
+
"°": "\xB0"
|
|
11797
|
+
};
|
|
11798
|
+
function stripHtml(value) {
|
|
11799
|
+
return value.replace(/<[^>]*>/g, "").replace(/&(?:#(x?)([0-9a-f]+)|[a-z]+);/gi, (entity, hex, digits) => {
|
|
11800
|
+
if (!digits) return HTML_ENTITIES[entity.toLowerCase()] ?? entity;
|
|
11801
|
+
const code = Number.parseInt(digits, hex ? 16 : 10);
|
|
11802
|
+
return code <= 1114111 && (code < 55296 || code > 57343) ? String.fromCodePoint(code) : entity;
|
|
11803
|
+
}).trim();
|
|
11804
|
+
}
|
|
11487
11805
|
function isBraveAvailable() {
|
|
11488
11806
|
return hasCredentialSource({
|
|
11489
11807
|
provider: "Brave",
|
|
@@ -11521,7 +11839,7 @@ Get a key at https://brave.com/search/api/`
|
|
|
11521
11839
|
if (freshness) params.set("freshness", freshness);
|
|
11522
11840
|
}
|
|
11523
11841
|
try {
|
|
11524
|
-
const searchDeadline = AbortSignal.timeout(
|
|
11842
|
+
const searchDeadline = AbortSignal.timeout(SEARCH_TIMEOUT_MS2);
|
|
11525
11843
|
const searchSignal = options.signal ? AbortSignal.any([searchDeadline, options.signal]) : searchDeadline;
|
|
11526
11844
|
const response = await braveRateLimit.run(async () => {
|
|
11527
11845
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
@@ -11555,9 +11873,9 @@ Get a key at https://brave.com/search/api/`
|
|
|
11555
11873
|
for (const item of data.web?.results ?? []) {
|
|
11556
11874
|
if (!item.url || !matchesDomainFilters(item.url, domainFilters)) continue;
|
|
11557
11875
|
results.push({
|
|
11558
|
-
title: item.title || item.url,
|
|
11876
|
+
title: stripHtml(item.title || "") || item.url,
|
|
11559
11877
|
url: item.url,
|
|
11560
|
-
snippet: item.description || ""
|
|
11878
|
+
snippet: stripHtml(item.description || "")
|
|
11561
11879
|
});
|
|
11562
11880
|
if (results.length >= numResults) break;
|
|
11563
11881
|
}
|
|
@@ -11592,7 +11910,7 @@ import { existsSync as existsSync11, readFileSync as readFileSync12 } from "node
|
|
|
11592
11910
|
var OPENAI_RESPONSES_URL = "https://api.openai.com/v1/responses";
|
|
11593
11911
|
var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
|
11594
11912
|
var CONFIG_PATH8 = getWebSearchConfigPath();
|
|
11595
|
-
var
|
|
11913
|
+
var SEARCH_TIMEOUT_MS3 = 6e4;
|
|
11596
11914
|
var EXCLUDED_MODEL_SEGMENTS = /* @__PURE__ */ new Set(["pro", "ultra"]);
|
|
11597
11915
|
var MODEL_PREFERENCE = [
|
|
11598
11916
|
(id) => id.includes("luna"),
|
|
@@ -12194,7 +12512,7 @@ async function runOpenAISearch(query, options, auth, ctx) {
|
|
|
12194
12512
|
method: "POST",
|
|
12195
12513
|
headers: requestHeaders,
|
|
12196
12514
|
body: JSON.stringify(body),
|
|
12197
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
12515
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS3), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS3)
|
|
12198
12516
|
}, ["Authorization", "x-opencode-session", "x-opencode-client", "chatgpt-account-id", ...Object.keys(auth.headers)]);
|
|
12199
12517
|
if (!response.ok) {
|
|
12200
12518
|
activityMonitor.logError(activityId, `HTTP ${response.status}`);
|
|
@@ -12265,7 +12583,7 @@ init_utils();
|
|
|
12265
12583
|
import { existsSync as existsSync15, readFileSync as readFileSync16 } from "node:fs";
|
|
12266
12584
|
var SEARCHINFINITY_SEARCH_URL = "https://torchlight.byteintlapi.com/search_api/web_search";
|
|
12267
12585
|
var CONFIG_PATH13 = getWebSearchConfigPath();
|
|
12268
|
-
var
|
|
12586
|
+
var SEARCH_TIMEOUT_MS7 = 3e4;
|
|
12269
12587
|
var cachedConfig12 = null;
|
|
12270
12588
|
function loadConfig11() {
|
|
12271
12589
|
if (cachedConfig12) return cachedConfig12;
|
|
@@ -12363,7 +12681,7 @@ async function searchinfinityJsonRequest(apiKey, body, signal) {
|
|
|
12363
12681
|
"Content-Type": "application/json"
|
|
12364
12682
|
},
|
|
12365
12683
|
body: JSON.stringify(body),
|
|
12366
|
-
signal: requestSignal6(signal,
|
|
12684
|
+
signal: requestSignal6(signal, SEARCH_TIMEOUT_MS7)
|
|
12367
12685
|
});
|
|
12368
12686
|
} catch (err) {
|
|
12369
12687
|
const message = errorMessage5(err);
|
|
@@ -12444,7 +12762,7 @@ init_utils();
|
|
|
12444
12762
|
import { existsSync as existsSync17, readFileSync as readFileSync18 } from "node:fs";
|
|
12445
12763
|
var TAVILY_API_BASE_URL = "https://api.tavily.com";
|
|
12446
12764
|
var CONFIG_PATH15 = getWebSearchConfigPath();
|
|
12447
|
-
var
|
|
12765
|
+
var SEARCH_TIMEOUT_MS9 = 6e4;
|
|
12448
12766
|
var cachedConfig14 = null;
|
|
12449
12767
|
function loadConfig13() {
|
|
12450
12768
|
if (cachedConfig14) return cachedConfig14;
|
|
@@ -12517,7 +12835,7 @@ function mapDomainFilter6(domainFilter) {
|
|
|
12517
12835
|
};
|
|
12518
12836
|
}
|
|
12519
12837
|
function requestSignal8(signal) {
|
|
12520
|
-
const timeout = AbortSignal.timeout(
|
|
12838
|
+
const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS9);
|
|
12521
12839
|
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
12522
12840
|
}
|
|
12523
12841
|
function errorMessage7(err) {
|
|
@@ -12655,7 +12973,7 @@ init_utils();
|
|
|
12655
12973
|
import { existsSync as existsSync18, readFileSync as readFileSync19 } from "node:fs";
|
|
12656
12974
|
var YOU_SEARCH_URL = "https://ydc-index.io/v1/search";
|
|
12657
12975
|
var CONFIG_PATH16 = getWebSearchConfigPath();
|
|
12658
|
-
var
|
|
12976
|
+
var SEARCH_TIMEOUT_MS10 = 6e4;
|
|
12659
12977
|
var cachedConfig15 = null;
|
|
12660
12978
|
function loadConfig14() {
|
|
12661
12979
|
if (cachedConfig15) return cachedConfig15;
|
|
@@ -12730,7 +13048,7 @@ async function searchWithYou(query, options = {}) {
|
|
|
12730
13048
|
...mapDomainFilter7(options.domainFilter)
|
|
12731
13049
|
};
|
|
12732
13050
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
12733
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
13051
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS10);
|
|
12734
13052
|
let response;
|
|
12735
13053
|
let entries;
|
|
12736
13054
|
try {
|
|
@@ -12759,7 +13077,7 @@ async function searchWithYou(query, options = {}) {
|
|
|
12759
13077
|
}
|
|
12760
13078
|
const message = errorMessage8(err);
|
|
12761
13079
|
const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
|
|
12762
|
-
const outgoing = providerTimeout ? new Error(`You.com request timed out after ${Math.round(
|
|
13080
|
+
const outgoing = providerTimeout ? new Error(`You.com request timed out after ${Math.round(SEARCH_TIMEOUT_MS10 / 1e3)}s`) : (() => {
|
|
12763
13081
|
const redactedMessage = redactCredential(message, apiKey);
|
|
12764
13082
|
if (redactedMessage === message && err instanceof Error) return err;
|
|
12765
13083
|
const redactedError = new Error(redactedMessage);
|
|
@@ -12805,7 +13123,7 @@ init_utils();
|
|
|
12805
13123
|
import { existsSync as existsSync21, readFileSync as readFileSync22 } from "node:fs";
|
|
12806
13124
|
var JINA_SEARCH_BASE_URL = "https://s.jina.ai/";
|
|
12807
13125
|
var CONFIG_PATH18 = getWebSearchConfigPath();
|
|
12808
|
-
var
|
|
13126
|
+
var SEARCH_TIMEOUT_MS12 = 6e4;
|
|
12809
13127
|
var cachedConfig17 = null;
|
|
12810
13128
|
function loadConfig16() {
|
|
12811
13129
|
if (cachedConfig17) return cachedConfig17;
|
|
@@ -12881,7 +13199,7 @@ function buildSearchRequest(query, options, numResults) {
|
|
|
12881
13199
|
return { url: url.toString(), filters };
|
|
12882
13200
|
}
|
|
12883
13201
|
function requestSignal10(signal) {
|
|
12884
|
-
const timeout = AbortSignal.timeout(
|
|
13202
|
+
const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS12);
|
|
12885
13203
|
return {
|
|
12886
13204
|
timeout,
|
|
12887
13205
|
signal: signal ? AbortSignal.any([signal, timeout]) : timeout
|
|
@@ -13025,7 +13343,7 @@ init_utils();
|
|
|
13025
13343
|
import { existsSync as existsSync22, readFileSync as readFileSync23 } from "node:fs";
|
|
13026
13344
|
var SERPDIVE_API_URL = "https://api.serpdive.com/v1/search";
|
|
13027
13345
|
var CONFIG_PATH19 = getWebSearchConfigPath();
|
|
13028
|
-
var
|
|
13346
|
+
var SEARCH_TIMEOUT_MS13 = 6e4;
|
|
13029
13347
|
var MODELS = ["krill", "mako", "moby"];
|
|
13030
13348
|
var DEFAULT_MODEL2 = "krill";
|
|
13031
13349
|
var cachedConfig18 = null;
|
|
@@ -13108,7 +13426,7 @@ function applyRecencyHint(query, recencyFilter) {
|
|
|
13108
13426
|
return hint ? `${query} ${hint}` : query;
|
|
13109
13427
|
}
|
|
13110
13428
|
function requestSignal11(signal) {
|
|
13111
|
-
const timeout = AbortSignal.timeout(
|
|
13429
|
+
const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS13);
|
|
13112
13430
|
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
13113
13431
|
}
|
|
13114
13432
|
function errorMessage11(err) {
|
|
@@ -13230,7 +13548,7 @@ init_utils();
|
|
|
13230
13548
|
import { existsSync as existsSync24, readFileSync as readFileSync25 } from "node:fs";
|
|
13231
13549
|
var BOCHA_SEARCH_URL = "https://api.bochaai.com/v1/web-search";
|
|
13232
13550
|
var CONFIG_PATH21 = getWebSearchConfigPath();
|
|
13233
|
-
var
|
|
13551
|
+
var SEARCH_TIMEOUT_MS15 = 6e4;
|
|
13234
13552
|
var cachedConfig20 = null;
|
|
13235
13553
|
function loadConfig19() {
|
|
13236
13554
|
if (cachedConfig20) return cachedConfig20;
|
|
@@ -13360,7 +13678,7 @@ async function searchWithBocha(query, options = {}) {
|
|
|
13360
13678
|
method: "POST",
|
|
13361
13679
|
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "application/json" },
|
|
13362
13680
|
body: JSON.stringify({ query, count: numResults, freshness: mapFreshness(options.recencyFilter), summary: true }),
|
|
13363
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
13681
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS15), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS15)
|
|
13364
13682
|
});
|
|
13365
13683
|
} catch (err) {
|
|
13366
13684
|
const message = errorMessage13(err);
|
|
@@ -13412,7 +13730,7 @@ init_search_result_count_normalization();
|
|
|
13412
13730
|
init_utils();
|
|
13413
13731
|
import { existsSync as existsSync26, readFileSync as readFileSync27 } from "node:fs";
|
|
13414
13732
|
var CONFIG_PATH23 = getWebSearchConfigPath();
|
|
13415
|
-
var
|
|
13733
|
+
var SEARCH_TIMEOUT_MS17 = 3e4;
|
|
13416
13734
|
var cachedConfig22 = null;
|
|
13417
13735
|
function loadConfig21() {
|
|
13418
13736
|
if (cachedConfig22) return cachedConfig22;
|
|
@@ -13552,9 +13870,10 @@ async function searchWithSearXNG(query, options = {}) {
|
|
|
13552
13870
|
const response = await fetchRemoteUrl(url, {
|
|
13553
13871
|
method: "GET",
|
|
13554
13872
|
headers,
|
|
13555
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
13873
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS17), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS17)
|
|
13556
13874
|
}, {
|
|
13557
13875
|
...loadSsrfConfig(),
|
|
13876
|
+
allowLoopback: isLoopbackHostname(url.hostname),
|
|
13558
13877
|
onRedirect: ({ from, to, init }) => from.origin === to.origin ? init : { ...init, headers: { Accept: "application/json" } }
|
|
13559
13878
|
});
|
|
13560
13879
|
if (!response.ok) {
|
|
@@ -13599,7 +13918,7 @@ init_utils();
|
|
|
13599
13918
|
import { existsSync as existsSync27, readFileSync as readFileSync28 } from "node:fs";
|
|
13600
13919
|
var CONFIG_PATH24 = getWebSearchConfigPath();
|
|
13601
13920
|
var DEFAULT_BASE_URL = "https://degoog.org";
|
|
13602
|
-
var
|
|
13921
|
+
var SEARCH_TIMEOUT_MS18 = 3e4;
|
|
13603
13922
|
var cachedConfig23 = null;
|
|
13604
13923
|
function loadConfig22() {
|
|
13605
13924
|
if (cachedConfig23) return cachedConfig23;
|
|
@@ -13773,7 +14092,7 @@ async function searchWithDegoog(query, options = {}) {
|
|
|
13773
14092
|
if (engines.length > 0) body.engines = engines;
|
|
13774
14093
|
const url = new URL(`${baseUrl}/api/search`);
|
|
13775
14094
|
const activityId = activityMonitor.logStart({ type: "api", query: searchQuery });
|
|
13776
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
14095
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS18);
|
|
13777
14096
|
let response;
|
|
13778
14097
|
let entries;
|
|
13779
14098
|
try {
|
|
@@ -13811,7 +14130,7 @@ async function searchWithDegoog(query, options = {}) {
|
|
|
13811
14130
|
}
|
|
13812
14131
|
const message = errorMessage15(err);
|
|
13813
14132
|
const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
|
|
13814
|
-
const outgoing = providerTimeout ? new Error(`degoog request timed out after ${Math.round(
|
|
14133
|
+
const outgoing = providerTimeout ? new Error(`degoog request timed out after ${Math.round(SEARCH_TIMEOUT_MS18 / 1e3)}s`) : (() => {
|
|
13815
14134
|
const redactedMessage = redactSecrets(message, secrets);
|
|
13816
14135
|
if (redactedMessage === message && err instanceof Error) return err;
|
|
13817
14136
|
const redactedError = new Error(redactedMessage);
|
|
@@ -13853,7 +14172,7 @@ init_activity();
|
|
|
13853
14172
|
init_domain_filter_normalization();
|
|
13854
14173
|
init_search_result_count_normalization();
|
|
13855
14174
|
var SEARCH_URL = "https://html.duckduckgo.com/html/";
|
|
13856
|
-
var
|
|
14175
|
+
var SEARCH_TIMEOUT_MS19 = 3e4;
|
|
13857
14176
|
function normalizeDomainFilters5(domainFilter) {
|
|
13858
14177
|
const filters = { allowed: [], blocked: [] };
|
|
13859
14178
|
for (const raw of domainFilter ?? []) {
|
|
@@ -13897,7 +14216,7 @@ async function searchWithDuckDuckGo(query, options = {}) {
|
|
|
13897
14216
|
Accept: "text/html",
|
|
13898
14217
|
"User-Agent": "Mozilla/5.0 (compatible; pi-web-access/1.0; +https://github.com/nicobailon/pi-web-access)"
|
|
13899
14218
|
},
|
|
13900
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
14219
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS19), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS19)
|
|
13901
14220
|
});
|
|
13902
14221
|
if (!response.ok) {
|
|
13903
14222
|
const body = await response.text();
|
|
@@ -13905,6 +14224,9 @@ async function searchWithDuckDuckGo(query, options = {}) {
|
|
|
13905
14224
|
}
|
|
13906
14225
|
const { parseHTML } = await import("linkedom");
|
|
13907
14226
|
const { document } = parseHTML(await response.text());
|
|
14227
|
+
if (response.status === 202 || document.querySelector(".anomaly-modal__box, #challenge-form")) {
|
|
14228
|
+
throw new Error(`DuckDuckGo blocked the request with a bot check (HTTP ${response.status}, rate limited); use another search provider`);
|
|
14229
|
+
}
|
|
13908
14230
|
const filters = normalizeDomainFilters5(options.domainFilter);
|
|
13909
14231
|
const results = [];
|
|
13910
14232
|
let parseableResults = 0;
|
|
@@ -13921,7 +14243,7 @@ async function searchWithDuckDuckGo(query, options = {}) {
|
|
|
13921
14243
|
results.push({ title, url: resultUrl, snippet });
|
|
13922
14244
|
if (results.length >= normalizeSearchResultCount(options.numResults)) break;
|
|
13923
14245
|
}
|
|
13924
|
-
if (parseableResults === 0) {
|
|
14246
|
+
if (parseableResults === 0 && !document.querySelector(".no-results__message")) {
|
|
13925
14247
|
throw new Error("DuckDuckGo returned no parseable results (invalid response)");
|
|
13926
14248
|
}
|
|
13927
14249
|
activityMonitor.logComplete(activityId, response.status);
|
|
@@ -13945,7 +14267,7 @@ init_utils();
|
|
|
13945
14267
|
import { existsSync as existsSync28, readFileSync as readFileSync29 } from "node:fs";
|
|
13946
14268
|
var ANYSEARCH_API_URL = "https://api.anysearch.com/v1/search";
|
|
13947
14269
|
var CONFIG_PATH25 = getWebSearchConfigPath();
|
|
13948
|
-
var
|
|
14270
|
+
var SEARCH_TIMEOUT_MS20 = 3e4;
|
|
13949
14271
|
var cachedConfig24 = null;
|
|
13950
14272
|
function loadConfig23() {
|
|
13951
14273
|
if (cachedConfig24) return cachedConfig24;
|
|
@@ -14030,7 +14352,7 @@ async function searchWithAnySearch(query, options = {}) {
|
|
|
14030
14352
|
"Content-Type": "application/json"
|
|
14031
14353
|
},
|
|
14032
14354
|
body: JSON.stringify(body),
|
|
14033
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
14355
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS20), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS20)
|
|
14034
14356
|
});
|
|
14035
14357
|
} catch (err) {
|
|
14036
14358
|
const message = errorMessage16(err);
|
|
@@ -14085,7 +14407,7 @@ init_utils();
|
|
|
14085
14407
|
import { existsSync as existsSync29, readFileSync as readFileSync30 } from "node:fs";
|
|
14086
14408
|
var XCRAWL_API_URL = "https://run.xcrawl.com/v1/serp";
|
|
14087
14409
|
var CONFIG_PATH26 = getWebSearchConfigPath();
|
|
14088
|
-
var
|
|
14410
|
+
var SEARCH_TIMEOUT_MS21 = 6e4;
|
|
14089
14411
|
var cachedConfig25 = null;
|
|
14090
14412
|
function loadConfig24() {
|
|
14091
14413
|
if (cachedConfig25) return cachedConfig25;
|
|
@@ -14205,7 +14527,7 @@ async function searchWithXCrawl(query, options = {}) {
|
|
|
14205
14527
|
}
|
|
14206
14528
|
const body = { engine: "google_search", q: query };
|
|
14207
14529
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
14208
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
14530
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS21);
|
|
14209
14531
|
let response;
|
|
14210
14532
|
try {
|
|
14211
14533
|
response = await fetch(XCRAWL_API_URL, {
|
|
@@ -14226,7 +14548,7 @@ async function searchWithXCrawl(query, options = {}) {
|
|
|
14226
14548
|
const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
|
|
14227
14549
|
let outgoing;
|
|
14228
14550
|
if (providerTimeout) {
|
|
14229
|
-
outgoing = new Error(`XCrawl search request timed out after ${Math.round(
|
|
14551
|
+
outgoing = new Error(`XCrawl search request timed out after ${Math.round(SEARCH_TIMEOUT_MS21 / 1e3)}s`);
|
|
14230
14552
|
} else {
|
|
14231
14553
|
const redactedMessage = redactCredential(message, apiKey);
|
|
14232
14554
|
outgoing = redactedMessage === message && err instanceof Error ? err : new Error(redactedMessage);
|
|
@@ -14270,7 +14592,7 @@ init_utils();
|
|
|
14270
14592
|
import { existsSync as existsSync30, readFileSync as readFileSync31 } from "node:fs";
|
|
14271
14593
|
var XAI_RESPONSES_URL = "https://api.x.ai/v1/responses";
|
|
14272
14594
|
var CONFIG_PATH27 = getWebSearchConfigPath();
|
|
14273
|
-
var
|
|
14595
|
+
var SEARCH_TIMEOUT_MS22 = 6e4;
|
|
14274
14596
|
var WEB_SEARCH_AUTH_MODEL_CANDIDATES = ["grok-4.5", "grok-4.3", "grok-build-0.1"];
|
|
14275
14597
|
var X_SEARCH_AUTH_MODEL_CANDIDATES = ["grok-4.6", ...WEB_SEARCH_AUTH_MODEL_CANDIDATES];
|
|
14276
14598
|
var DEFAULT_XAI_SEARCH_TOOLS = ["web_search"];
|
|
@@ -14523,7 +14845,7 @@ async function searchWithXai(query, options = {}, ctx) {
|
|
|
14523
14845
|
input: buildInput(query, options, tools),
|
|
14524
14846
|
tools: tools.map((type) => ({ type }))
|
|
14525
14847
|
}),
|
|
14526
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
14848
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS22), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS22)
|
|
14527
14849
|
});
|
|
14528
14850
|
if (!response.ok) {
|
|
14529
14851
|
activityMonitor.logError(activityId, `HTTP ${response.status}`);
|
|
@@ -14570,7 +14892,7 @@ init_utils();
|
|
|
14570
14892
|
import { existsSync as existsSync31, readFileSync as readFileSync32 } from "node:fs";
|
|
14571
14893
|
var BRIGHTDATA_API_URL = "https://api.brightdata.com/request";
|
|
14572
14894
|
var CONFIG_PATH28 = getWebSearchConfigPath();
|
|
14573
|
-
var
|
|
14895
|
+
var SEARCH_TIMEOUT_MS23 = 6e4;
|
|
14574
14896
|
var ZONE_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
14575
14897
|
var RECENCY_TBS = {
|
|
14576
14898
|
day: "qdr:d",
|
|
@@ -14709,7 +15031,7 @@ function passesDomainFilters4(url, filters) {
|
|
|
14709
15031
|
return filters.include.some((domain) => domainMatches4(hostname2, domain));
|
|
14710
15032
|
}
|
|
14711
15033
|
function requestSignal12(signal) {
|
|
14712
|
-
const timeout = AbortSignal.timeout(
|
|
15034
|
+
const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS23);
|
|
14713
15035
|
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
14714
15036
|
}
|
|
14715
15037
|
function errorMessage18(err) {
|
|
@@ -14867,7 +15189,7 @@ init_utils();
|
|
|
14867
15189
|
import { existsSync as existsSync32, readFileSync as readFileSync33 } from "node:fs";
|
|
14868
15190
|
var SERPBASE_API_URL = "https://api.serpbase.dev/google/search";
|
|
14869
15191
|
var CONFIG_PATH29 = getWebSearchConfigPath();
|
|
14870
|
-
var
|
|
15192
|
+
var SEARCH_TIMEOUT_MS24 = 6e4;
|
|
14871
15193
|
var RECENCY_TBS2 = {
|
|
14872
15194
|
day: "qdr:d",
|
|
14873
15195
|
week: "qdr:w",
|
|
@@ -14986,7 +15308,7 @@ async function searchWithSerpBase(query, options = {}) {
|
|
|
14986
15308
|
try {
|
|
14987
15309
|
response = await fetch(url, {
|
|
14988
15310
|
headers: { Accept: "application/json" },
|
|
14989
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
15311
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS24), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS24)
|
|
14990
15312
|
});
|
|
14991
15313
|
} catch (err) {
|
|
14992
15314
|
const message = errorMessage19(err);
|
|
@@ -15036,7 +15358,7 @@ init_utils();
|
|
|
15036
15358
|
import { existsSync as existsSync33, readFileSync as readFileSync34 } from "node:fs";
|
|
15037
15359
|
var SERPAPI_SEARCH_URL = "https://serpapi.com/search.json";
|
|
15038
15360
|
var CONFIG_PATH30 = getWebSearchConfigPath();
|
|
15039
|
-
var
|
|
15361
|
+
var SEARCH_TIMEOUT_MS25 = 6e4;
|
|
15040
15362
|
var RECENCY_TBS3 = {
|
|
15041
15363
|
day: "qdr:d",
|
|
15042
15364
|
week: "qdr:w",
|
|
@@ -15141,7 +15463,7 @@ async function searchWithSerpApi(query, options = {}) {
|
|
|
15141
15463
|
url.searchParams.set("num", String(requestCount));
|
|
15142
15464
|
if (options.recencyFilter) url.searchParams.set("tbs", RECENCY_TBS3[options.recencyFilter]);
|
|
15143
15465
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
15144
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
15466
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS25);
|
|
15145
15467
|
let response;
|
|
15146
15468
|
let entries;
|
|
15147
15469
|
try {
|
|
@@ -15168,7 +15490,7 @@ async function searchWithSerpApi(query, options = {}) {
|
|
|
15168
15490
|
}
|
|
15169
15491
|
const message = errorMessage20(err);
|
|
15170
15492
|
const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
|
|
15171
|
-
const outgoing = providerTimeout ? new Error(`SerpApi request timed out after ${Math.round(
|
|
15493
|
+
const outgoing = providerTimeout ? new Error(`SerpApi request timed out after ${Math.round(SEARCH_TIMEOUT_MS25 / 1e3)}s`) : (() => {
|
|
15172
15494
|
const redactedMessage = redactCredential(message, apiKey);
|
|
15173
15495
|
if (redactedMessage === message && err instanceof Error) return err;
|
|
15174
15496
|
const redactedError = new Error(redactedMessage);
|
|
@@ -15204,7 +15526,7 @@ init_utils();
|
|
|
15204
15526
|
import { existsSync as existsSync34, readFileSync as readFileSync35 } from "node:fs";
|
|
15205
15527
|
var SERPER_SEARCH_URL = "https://google.serper.dev/search";
|
|
15206
15528
|
var CONFIG_PATH31 = getWebSearchConfigPath();
|
|
15207
|
-
var
|
|
15529
|
+
var SEARCH_TIMEOUT_MS26 = 6e4;
|
|
15208
15530
|
var RECENCY_TBS4 = {
|
|
15209
15531
|
day: "qdr:d",
|
|
15210
15532
|
week: "qdr:w",
|
|
@@ -15308,7 +15630,7 @@ async function searchWithSerper(query, options = {}) {
|
|
|
15308
15630
|
method: "POST",
|
|
15309
15631
|
headers: { "X-API-KEY": apiKey, "Content-Type": "application/json", Accept: "application/json" },
|
|
15310
15632
|
body: JSON.stringify({ q: buildQuery4(query, filters), num: requestCount, ...options.recencyFilter ? { tbs: RECENCY_TBS4[options.recencyFilter] } : {} }),
|
|
15311
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
15633
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS26), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS26)
|
|
15312
15634
|
});
|
|
15313
15635
|
} catch (err) {
|
|
15314
15636
|
const message = errorMessage21(err);
|
|
@@ -15365,7 +15687,7 @@ init_utils();
|
|
|
15365
15687
|
import { existsSync as existsSync35, readFileSync as readFileSync36 } from "node:fs";
|
|
15366
15688
|
var SERPLY_SEARCH_URL = "https://api.serply.io/v1/search";
|
|
15367
15689
|
var CONFIG_PATH32 = getWebSearchConfigPath();
|
|
15368
|
-
var
|
|
15690
|
+
var SEARCH_TIMEOUT_MS27 = 6e4;
|
|
15369
15691
|
var RECENCY_TBS5 = {
|
|
15370
15692
|
day: "qdr:d",
|
|
15371
15693
|
week: "qdr:w",
|
|
@@ -15463,7 +15785,7 @@ async function searchWithSerply(query, options = {}) {
|
|
|
15463
15785
|
url.searchParams.set("num", String(requestCount));
|
|
15464
15786
|
if (options.recencyFilter) url.searchParams.set("tbs", RECENCY_TBS5[options.recencyFilter]);
|
|
15465
15787
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
15466
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
15788
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS27);
|
|
15467
15789
|
let response;
|
|
15468
15790
|
let entries;
|
|
15469
15791
|
try {
|
|
@@ -15490,7 +15812,7 @@ async function searchWithSerply(query, options = {}) {
|
|
|
15490
15812
|
}
|
|
15491
15813
|
const message = errorMessage22(err);
|
|
15492
15814
|
const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
|
|
15493
|
-
const outgoing = providerTimeout ? new Error(`Serply request timed out after ${Math.round(
|
|
15815
|
+
const outgoing = providerTimeout ? new Error(`Serply request timed out after ${Math.round(SEARCH_TIMEOUT_MS27 / 1e3)}s`) : (() => {
|
|
15494
15816
|
const redactedMessage = redactCredential(message, apiKey);
|
|
15495
15817
|
if (redactedMessage === message && err instanceof Error) return err;
|
|
15496
15818
|
const redactedError = new Error(redactedMessage);
|
|
@@ -15532,7 +15854,7 @@ init_utils();
|
|
|
15532
15854
|
import { existsSync as existsSync36, readFileSync as readFileSync37 } from "node:fs";
|
|
15533
15855
|
import { isIP as isIP2 } from "node:net";
|
|
15534
15856
|
var MCP_URL = "https://agent-toolkit.app.baizhi.cloud/mcp";
|
|
15535
|
-
var
|
|
15857
|
+
var SEARCH_TIMEOUT_MS28 = 6e4;
|
|
15536
15858
|
var CONFIG_PATH33 = getWebSearchConfigPath();
|
|
15537
15859
|
function credentialOptions() {
|
|
15538
15860
|
let config = {};
|
|
@@ -15575,7 +15897,7 @@ function searchArguments(query, options) {
|
|
|
15575
15897
|
}
|
|
15576
15898
|
async function searchWithBaizhi(query, options = {}) {
|
|
15577
15899
|
const args = searchArguments(query, options);
|
|
15578
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
15900
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS28);
|
|
15579
15901
|
const signal = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
|
|
15580
15902
|
if (signal.aborted) throw new Error("Aborted");
|
|
15581
15903
|
const apiKey = await resolveCredential({ ...credentialOptions(), signal });
|
|
@@ -15603,8 +15925,8 @@ async function searchWithBaizhi(query, options = {}) {
|
|
|
15603
15925
|
const client = new Client({ name: "pi-web-access-baizhi", version: "1.0.0" });
|
|
15604
15926
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
15605
15927
|
try {
|
|
15606
|
-
await client.connect(transport, { signal, timeout:
|
|
15607
|
-
const result = await client.callTool({ name: "websearch_search", arguments: args }, void 0, { signal, timeout:
|
|
15928
|
+
await client.connect(transport, { signal, timeout: SEARCH_TIMEOUT_MS28 });
|
|
15929
|
+
const result = await client.callTool({ name: "websearch_search", arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS28 });
|
|
15608
15930
|
if (result.isError) throw new Error("Baizhi search tool returned an error");
|
|
15609
15931
|
const parts = [];
|
|
15610
15932
|
if (result.structuredContent !== void 0) parts.push(JSON.stringify(result.structuredContent, null, 2));
|
|
@@ -15648,7 +15970,7 @@ var MCP_URLS = {
|
|
|
15648
15970
|
china: "https://open.bigmodel.cn/api/mcp/web_search_prime/mcp"
|
|
15649
15971
|
};
|
|
15650
15972
|
var RECENCY = { day: "oneDay", week: "oneWeek", month: "oneMonth", year: "oneYear" };
|
|
15651
|
-
var
|
|
15973
|
+
var SEARCH_TIMEOUT_MS29 = 6e4;
|
|
15652
15974
|
var CONFIG_PATH34 = getWebSearchConfigPath();
|
|
15653
15975
|
function loadConfig31() {
|
|
15654
15976
|
if (!existsSync37(CONFIG_PATH34)) return {};
|
|
@@ -15719,7 +16041,7 @@ async function searchWithZai(query, options = {}) {
|
|
|
15719
16041
|
const mcpUrl = endpointUrl(config);
|
|
15720
16042
|
const args = searchArguments2(query, options);
|
|
15721
16043
|
const limit = normalizeSearchResultCount(options.numResults);
|
|
15722
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
16044
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS29);
|
|
15723
16045
|
const signal = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
|
|
15724
16046
|
if (signal.aborted) throw new Error("Aborted");
|
|
15725
16047
|
const apiKey = await resolveCredential({ ...credentialOptions2(config), signal });
|
|
@@ -15747,11 +16069,11 @@ async function searchWithZai(query, options = {}) {
|
|
|
15747
16069
|
const client = new Client({ name: "pi-web-access-zai", version: "1.0.0" });
|
|
15748
16070
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
15749
16071
|
try {
|
|
15750
|
-
await client.connect(transport, { signal, timeout:
|
|
15751
|
-
const { tools } = await client.listTools(void 0, { signal, timeout:
|
|
16072
|
+
await client.connect(transport, { signal, timeout: SEARCH_TIMEOUT_MS29 });
|
|
16073
|
+
const { tools } = await client.listTools(void 0, { signal, timeout: SEARCH_TIMEOUT_MS29 });
|
|
15752
16074
|
const toolName = tools.find((tool) => tool.name === "web_search_prime" || tool.name === "webSearchPrime")?.name;
|
|
15753
16075
|
if (!toolName) throw new Error("Z.ai returned invalid response: web search tool not listed");
|
|
15754
|
-
const result = await client.callTool({ name: toolName, arguments: args }, void 0, { signal, timeout:
|
|
16076
|
+
const result = await client.callTool({ name: toolName, arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS29 });
|
|
15755
16077
|
if (result.isError) throw new Error("Z.ai search tool returned an error");
|
|
15756
16078
|
const text4 = (Array.isArray(result.content) ? result.content : []).find((item) => item.type === "text" && typeof item.text === "string");
|
|
15757
16079
|
if (!text4) throw new Error("Z.ai returned invalid response: no search text");
|
|
@@ -15788,7 +16110,7 @@ init_utils();
|
|
|
15788
16110
|
import { existsSync as existsSync38, readFileSync as readFileSync39 } from "node:fs";
|
|
15789
16111
|
var VALYU_SEARCH_URL = "https://api.valyu.ai/v1/search";
|
|
15790
16112
|
var CONFIG_PATH35 = getWebSearchConfigPath();
|
|
15791
|
-
var
|
|
16113
|
+
var SEARCH_TIMEOUT_MS30 = 6e4;
|
|
15792
16114
|
var MAX_SNIPPET_CHARS = 2500;
|
|
15793
16115
|
var MAX_CONTENT_CHARS = 4e3;
|
|
15794
16116
|
var cachedConfig32 = null;
|
|
@@ -15882,7 +16204,7 @@ async function searchWithValyu(query, options = {}) {
|
|
|
15882
16204
|
method: "POST",
|
|
15883
16205
|
headers: { "x-api-key": apiKey, "Content-Type": "application/json", Accept: "application/json" },
|
|
15884
16206
|
body: JSON.stringify({ query, max_num_results: numResults, ...mapDomainFilter9(options.domainFilter), ...startDate ? { start_date: startDate } : {} }),
|
|
15885
|
-
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
16207
|
+
signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS30), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS30)
|
|
15886
16208
|
});
|
|
15887
16209
|
} catch (err) {
|
|
15888
16210
|
const message = errorMessage23(err);
|
|
@@ -15942,7 +16264,7 @@ var KEENABLE_SEARCH_URL = "https://api.keenable.ai/v1/search";
|
|
|
15942
16264
|
var KEENABLE_PUBLIC_SEARCH_URL = "https://api.keenable.ai/v1/search/public";
|
|
15943
16265
|
var KEENABLE_CLIENT_TITLE = "pi-web-access";
|
|
15944
16266
|
var CONFIG_PATH36 = getWebSearchConfigPath();
|
|
15945
|
-
var
|
|
16267
|
+
var SEARCH_TIMEOUT_MS31 = 3e4;
|
|
15946
16268
|
var MAX_REQUEST_RESULTS = 50;
|
|
15947
16269
|
var MAX_SNIPPET_CHARS2 = 500;
|
|
15948
16270
|
var RECENCY_DAYS = {
|
|
@@ -16044,7 +16366,7 @@ async function searchWithKeenable(query, options = {}) {
|
|
|
16044
16366
|
...apiKey ? { "X-API-Key": apiKey } : {}
|
|
16045
16367
|
};
|
|
16046
16368
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
16047
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
16369
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS31);
|
|
16048
16370
|
let response;
|
|
16049
16371
|
let entries;
|
|
16050
16372
|
try {
|
|
@@ -16074,7 +16396,7 @@ async function searchWithKeenable(query, options = {}) {
|
|
|
16074
16396
|
}
|
|
16075
16397
|
const message = errorMessage24(err);
|
|
16076
16398
|
const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
|
|
16077
|
-
const outgoing = providerTimeout ? new Error(`Keenable request timed out after ${Math.round(
|
|
16399
|
+
const outgoing = providerTimeout ? new Error(`Keenable request timed out after ${Math.round(SEARCH_TIMEOUT_MS31 / 1e3)}s`) : (() => {
|
|
16078
16400
|
const redactedMessage = redactCredential(message, apiKey);
|
|
16079
16401
|
if (redactedMessage === message && err instanceof Error) return err;
|
|
16080
16402
|
const redactedError = new Error(redactedMessage);
|
|
@@ -16121,7 +16443,7 @@ init_utils();
|
|
|
16121
16443
|
import { existsSync as existsSync40, readFileSync as readFileSync41 } from "node:fs";
|
|
16122
16444
|
var CERAMIC_SEARCH_URL = "https://api.ceramic.ai/search";
|
|
16123
16445
|
var CONFIG_PATH37 = getWebSearchConfigPath();
|
|
16124
|
-
var
|
|
16446
|
+
var SEARCH_TIMEOUT_MS32 = 3e4;
|
|
16125
16447
|
var MAX_REQUEST_RESULTS2 = 20;
|
|
16126
16448
|
var REQUEST_DESCRIPTION_CHARS = 1e3;
|
|
16127
16449
|
var MAX_SNIPPET_CHARS3 = 500;
|
|
@@ -16225,7 +16547,7 @@ async function searchWithCeramic(query, options = {}) {
|
|
|
16225
16547
|
maxDescriptionLength: REQUEST_DESCRIPTION_CHARS
|
|
16226
16548
|
};
|
|
16227
16549
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
16228
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
16550
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS32);
|
|
16229
16551
|
let response;
|
|
16230
16552
|
let entries;
|
|
16231
16553
|
try {
|
|
@@ -16258,7 +16580,7 @@ async function searchWithCeramic(query, options = {}) {
|
|
|
16258
16580
|
}
|
|
16259
16581
|
const message = errorMessage25(err);
|
|
16260
16582
|
const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
|
|
16261
|
-
const outgoing = providerTimeout ? new Error(`Ceramic request timed out after ${Math.round(
|
|
16583
|
+
const outgoing = providerTimeout ? new Error(`Ceramic request timed out after ${Math.round(SEARCH_TIMEOUT_MS32 / 1e3)}s`) : (() => {
|
|
16262
16584
|
const redactedMessage = redactCredential(message, apiKey);
|
|
16263
16585
|
if (redactedMessage === message && err instanceof Error) return err;
|
|
16264
16586
|
const redactedError = new Error(redactedMessage);
|
|
@@ -16303,7 +16625,7 @@ init_search_result_count_normalization();
|
|
|
16303
16625
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
16304
16626
|
var KIMI_SEARCH_URL = "https://api.kimi.com/coding/v1/search";
|
|
16305
16627
|
var KIMI_PROVIDERS = ["kimi-coding", "kimi-code"];
|
|
16306
|
-
var
|
|
16628
|
+
var SEARCH_TIMEOUT_MS33 = 3e4;
|
|
16307
16629
|
function buildRequestHeaders(auth) {
|
|
16308
16630
|
const headers = new Headers();
|
|
16309
16631
|
for (const [name, value] of Object.entries(auth.headers)) {
|
|
@@ -16418,7 +16740,7 @@ async function searchWithKimi(query, options = {}, ctx) {
|
|
|
16418
16740
|
throw new Error("Kimi Code web search unavailable. Run /login kimi-coding to authenticate a Kimi Code Plan account.");
|
|
16419
16741
|
}
|
|
16420
16742
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
16421
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
16743
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS33);
|
|
16422
16744
|
const requestSignal15 = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
|
|
16423
16745
|
try {
|
|
16424
16746
|
const response = await fetch(KIMI_SEARCH_URL, {
|
|
@@ -16473,7 +16795,7 @@ init_utils();
|
|
|
16473
16795
|
import { existsSync as existsSync41, readFileSync as readFileSync42 } from "node:fs";
|
|
16474
16796
|
var MISTRAL_CONVERSATIONS_URL = "https://api.mistral.ai/v1/conversations";
|
|
16475
16797
|
var CONFIG_PATH38 = getWebSearchConfigPath();
|
|
16476
|
-
var
|
|
16798
|
+
var SEARCH_TIMEOUT_MS34 = 6e4;
|
|
16477
16799
|
var DEFAULT_SEARCH_MODEL = "mistral-small-latest";
|
|
16478
16800
|
var DEFAULT_SEARCH_TOOL = "web_search";
|
|
16479
16801
|
var MAX_RESULTS = 20;
|
|
@@ -16649,7 +16971,7 @@ async function searchWithMistral(query, options = {}) {
|
|
|
16649
16971
|
const tool = resolveSearchTool(config.mistralSearchTool);
|
|
16650
16972
|
const numResults = normalizeCount4(options.numResults);
|
|
16651
16973
|
const apiKey = await getApiKey26(options.signal);
|
|
16652
|
-
const requestSignal15 = options.signal ? AbortSignal.any([AbortSignal.timeout(
|
|
16974
|
+
const requestSignal15 = options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS34), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS34);
|
|
16653
16975
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
16654
16976
|
try {
|
|
16655
16977
|
const response = await fetch(MISTRAL_CONVERSATIONS_URL, {
|
|
@@ -16838,11 +17160,11 @@ function errorMessage27(err) {
|
|
|
16838
17160
|
function isAbortError2(err) {
|
|
16839
17161
|
return errorMessage27(err).toLowerCase().includes("abort");
|
|
16840
17162
|
}
|
|
16841
|
-
async function tryOpenAIInAuto(query, options, fallbackErrors) {
|
|
17163
|
+
async function tryOpenAIInAuto(query, options, fallbackErrors, take) {
|
|
16842
17164
|
try {
|
|
16843
17165
|
if (await isOpenAISearchAvailable(options.extensionContext)) {
|
|
16844
17166
|
const result = await searchWithOpenAI(query, options, options.extensionContext);
|
|
16845
|
-
return
|
|
17167
|
+
return take(result, "openai");
|
|
16846
17168
|
}
|
|
16847
17169
|
} catch (err) {
|
|
16848
17170
|
if (isAbortError2(err)) throw err;
|
|
@@ -17164,168 +17486,58 @@ async function search(query, options = {}) {
|
|
|
17164
17486
|
return searchWithConfiguredRouting(query, options, config.searchRouting);
|
|
17165
17487
|
}
|
|
17166
17488
|
const fallbackErrors = [];
|
|
17489
|
+
let firstEmpty;
|
|
17490
|
+
const take = (result, provider2) => {
|
|
17491
|
+
if (!result) return null;
|
|
17492
|
+
const response = { ...result, provider: provider2 };
|
|
17493
|
+
if (result.results.length || result.answer.trim()) return response;
|
|
17494
|
+
firstEmpty ??= response;
|
|
17495
|
+
return null;
|
|
17496
|
+
};
|
|
17167
17497
|
const allowed = new Set(config.allowedProviders ?? RESOLVED_SEARCH_PROVIDERS);
|
|
17168
|
-
|
|
17498
|
+
const attempt = async (provider2) => {
|
|
17499
|
+
if (!allowed.has(provider2) || !await isResolvedProviderAvailable(provider2, options)) return null;
|
|
17169
17500
|
try {
|
|
17170
|
-
|
|
17171
|
-
return { ...result, provider: "searxng" };
|
|
17501
|
+
return take(await searchWithResolvedProvider(provider2, query, options), provider2);
|
|
17172
17502
|
} catch (err) {
|
|
17173
17503
|
if (isAbortError2(err)) throw err;
|
|
17174
|
-
fallbackErrors.push(
|
|
17504
|
+
fallbackErrors.push(`${providerLabel(provider2)}: ${errorMessage27(err)}`);
|
|
17505
|
+
return null;
|
|
17175
17506
|
}
|
|
17176
|
-
}
|
|
17507
|
+
};
|
|
17508
|
+
const searxng = await attempt("searxng");
|
|
17509
|
+
if (searxng) return searxng;
|
|
17177
17510
|
let triedOpenAI = false;
|
|
17178
17511
|
if (allowed.has("openai") && (!options.extensionContext || isOpenAISubscriptionModelSelected(options.extensionContext))) {
|
|
17179
17512
|
triedOpenAI = true;
|
|
17180
|
-
const result = await tryOpenAIInAuto(query, options, fallbackErrors);
|
|
17513
|
+
const result = await tryOpenAIInAuto(query, options, fallbackErrors, take);
|
|
17181
17514
|
if (result) return result;
|
|
17182
17515
|
}
|
|
17183
17516
|
if (allowed.has("exa") && isExaAvailable()) {
|
|
17184
17517
|
try {
|
|
17185
|
-
const
|
|
17186
|
-
if (
|
|
17518
|
+
const response = take(await searchWithExa(query, options), "exa");
|
|
17519
|
+
if (response) return response;
|
|
17187
17520
|
} catch (err) {
|
|
17188
17521
|
if (err instanceof CredentialResolutionError || isAbortError2(err)) throw err;
|
|
17189
17522
|
fallbackErrors.push(`Exa: ${errorMessage27(err)}`);
|
|
17190
17523
|
}
|
|
17191
17524
|
}
|
|
17192
17525
|
if (allowed.has("openai") && !triedOpenAI) {
|
|
17193
|
-
const result = await tryOpenAIInAuto(query, options, fallbackErrors);
|
|
17526
|
+
const result = await tryOpenAIInAuto(query, options, fallbackErrors, take);
|
|
17194
17527
|
if (result) return result;
|
|
17195
17528
|
}
|
|
17196
|
-
|
|
17197
|
-
|
|
17198
|
-
|
|
17199
|
-
return { ...result, provider: "brave" };
|
|
17200
|
-
} catch (err) {
|
|
17201
|
-
if (isAbortError2(err)) throw err;
|
|
17202
|
-
fallbackErrors.push(`Brave: ${errorMessage27(err)}`);
|
|
17203
|
-
}
|
|
17204
|
-
}
|
|
17205
|
-
if (allowed.has("parallel") && isParallelAvailable()) {
|
|
17206
|
-
try {
|
|
17207
|
-
const result = await searchWithParallel(query, options);
|
|
17208
|
-
return { ...result, provider: "parallel" };
|
|
17209
|
-
} catch (err) {
|
|
17210
|
-
if (isAbortError2(err)) throw err;
|
|
17211
|
-
fallbackErrors.push(`Parallel: ${errorMessage27(err)}`);
|
|
17212
|
-
}
|
|
17213
|
-
}
|
|
17214
|
-
if (allowed.has("tinyfish") && isTinyFishAvailable()) {
|
|
17215
|
-
try {
|
|
17216
|
-
const result = await searchWithTinyFish(query, options);
|
|
17217
|
-
return { ...result, provider: "tinyfish" };
|
|
17218
|
-
} catch (err) {
|
|
17219
|
-
if (isAbortError2(err)) throw err;
|
|
17220
|
-
fallbackErrors.push(`TinyFish: ${errorMessage27(err)}`);
|
|
17221
|
-
}
|
|
17222
|
-
}
|
|
17223
|
-
if (allowed.has("search1api") && isSearch1APIAvailable()) {
|
|
17224
|
-
try {
|
|
17225
|
-
const result = await searchWithSearch1API(query, options);
|
|
17226
|
-
return { ...result, provider: "search1api" };
|
|
17227
|
-
} catch (err) {
|
|
17228
|
-
if (isAbortError2(err)) throw err;
|
|
17229
|
-
fallbackErrors.push(`Search1API: ${errorMessage27(err)}`);
|
|
17230
|
-
}
|
|
17231
|
-
}
|
|
17232
|
-
if (allowed.has("searchinfinity") && isSearchinfinityAvailable()) {
|
|
17233
|
-
try {
|
|
17234
|
-
const result = await searchWithSearchinfinity(query, options);
|
|
17235
|
-
return { ...result, provider: "searchinfinity" };
|
|
17236
|
-
} catch (err) {
|
|
17237
|
-
if (isAbortError2(err)) throw err;
|
|
17238
|
-
fallbackErrors.push(`Searchinfinity: ${errorMessage27(err)}`);
|
|
17239
|
-
}
|
|
17240
|
-
}
|
|
17241
|
-
if (allowed.has("querit") && isQueritAvailable()) {
|
|
17242
|
-
try {
|
|
17243
|
-
const result = await searchWithQuerit(query, options);
|
|
17244
|
-
return { ...result, provider: "querit" };
|
|
17245
|
-
} catch (err) {
|
|
17246
|
-
if (isAbortError2(err)) throw err;
|
|
17247
|
-
fallbackErrors.push(`Querit: ${errorMessage27(err)}`);
|
|
17248
|
-
}
|
|
17249
|
-
}
|
|
17250
|
-
if (allowed.has("tavily") && isTavilyAvailable()) {
|
|
17251
|
-
try {
|
|
17252
|
-
const result = await searchWithTavily(query, options);
|
|
17253
|
-
return { ...result, provider: "tavily" };
|
|
17254
|
-
} catch (err) {
|
|
17255
|
-
if (isAbortError2(err)) throw err;
|
|
17256
|
-
fallbackErrors.push(`Tavily: ${errorMessage27(err)}`);
|
|
17257
|
-
}
|
|
17258
|
-
}
|
|
17259
|
-
if (allowed.has("firecrawl") && isFirecrawlAvailable()) {
|
|
17260
|
-
try {
|
|
17261
|
-
const result = await searchWithFirecrawl(query, options);
|
|
17262
|
-
return { ...result, provider: "firecrawl" };
|
|
17263
|
-
} catch (err) {
|
|
17264
|
-
if (isAbortError2(err)) throw err;
|
|
17265
|
-
fallbackErrors.push(`Firecrawl: ${errorMessage27(err)}`);
|
|
17266
|
-
}
|
|
17267
|
-
}
|
|
17268
|
-
if (allowed.has("jina") && isJinaSearchAvailable()) {
|
|
17269
|
-
try {
|
|
17270
|
-
const result = await searchWithJina(query, options);
|
|
17271
|
-
return { ...result, provider: "jina" };
|
|
17272
|
-
} catch (err) {
|
|
17273
|
-
if (isAbortError2(err)) throw err;
|
|
17274
|
-
fallbackErrors.push(`Jina: ${errorMessage27(err)}`);
|
|
17275
|
-
}
|
|
17276
|
-
}
|
|
17277
|
-
if (allowed.has("serpdive") && isSerpdiveAvailable()) {
|
|
17278
|
-
try {
|
|
17279
|
-
const result = await searchWithSerpdive(query, options);
|
|
17280
|
-
return { ...result, provider: "serpdive" };
|
|
17281
|
-
} catch (err) {
|
|
17282
|
-
if (isAbortError2(err)) throw err;
|
|
17283
|
-
fallbackErrors.push(`SERPdive: ${errorMessage27(err)}`);
|
|
17284
|
-
}
|
|
17285
|
-
}
|
|
17286
|
-
if (allowed.has("kagi") && isKagiAvailable()) {
|
|
17287
|
-
try {
|
|
17288
|
-
const result = await searchWithKagi(query, options);
|
|
17289
|
-
return { ...result, provider: "kagi" };
|
|
17290
|
-
} catch (err) {
|
|
17291
|
-
if (isAbortError2(err)) throw err;
|
|
17292
|
-
fallbackErrors.push(`Kagi: ${errorMessage27(err)}`);
|
|
17293
|
-
}
|
|
17294
|
-
}
|
|
17295
|
-
if (allowed.has("bocha") && isBochaAvailable()) {
|
|
17296
|
-
try {
|
|
17297
|
-
const result = await searchWithBocha(query, options);
|
|
17298
|
-
return { ...result, provider: "bocha" };
|
|
17299
|
-
} catch (err) {
|
|
17300
|
-
if (isAbortError2(err)) throw err;
|
|
17301
|
-
fallbackErrors.push(`Bocha: ${errorMessage27(err)}`);
|
|
17302
|
-
}
|
|
17303
|
-
}
|
|
17304
|
-
if (allowed.has("ollama") && isOllamaAvailable()) {
|
|
17305
|
-
try {
|
|
17306
|
-
const result = await searchWithOllama(query, options);
|
|
17307
|
-
return { ...result, provider: "ollama" };
|
|
17308
|
-
} catch (err) {
|
|
17309
|
-
if (isAbortError2(err)) throw err;
|
|
17310
|
-
fallbackErrors.push(`Ollama: ${errorMessage27(err)}`);
|
|
17311
|
-
}
|
|
17312
|
-
}
|
|
17313
|
-
if (allowed.has("perplexity") && isPerplexityAvailable()) {
|
|
17314
|
-
try {
|
|
17315
|
-
const result = await searchWithPerplexity(query, options);
|
|
17316
|
-
return { ...result, provider: "perplexity" };
|
|
17317
|
-
} catch (err) {
|
|
17318
|
-
if (isAbortError2(err)) throw err;
|
|
17319
|
-
fallbackErrors.push(`Perplexity: ${errorMessage27(err)}`);
|
|
17320
|
-
}
|
|
17529
|
+
for (const provider2 of ["brave", "parallel", "tinyfish", "search1api", "searchinfinity", "querit", "tavily", "firecrawl", "jina", "serpdive", "kagi", "bocha", "ollama", "perplexity"]) {
|
|
17530
|
+
const response = await attempt(provider2);
|
|
17531
|
+
if (response) return response;
|
|
17321
17532
|
}
|
|
17322
17533
|
if (allowed.has("gemini")) try {
|
|
17323
|
-
const
|
|
17324
|
-
if (
|
|
17534
|
+
const response = take(await searchWithGemini(query, options, false), "gemini");
|
|
17535
|
+
if (response) return response;
|
|
17325
17536
|
} catch (err) {
|
|
17326
17537
|
if (isAbortError2(err)) throw err;
|
|
17327
17538
|
fallbackErrors.push(`Gemini: ${errorMessage27(err)}`);
|
|
17328
17539
|
}
|
|
17540
|
+
if (firstEmpty) return firstEmpty;
|
|
17329
17541
|
if (fallbackErrors.length > 0) {
|
|
17330
17542
|
throw new Error(`Auto provider search failed:
|
|
17331
17543
|
- ${fallbackErrors.join("\n - ")}`);
|
|
@@ -22175,9 +22387,17 @@ Error: ${result.error}`;
|
|
|
22175
22387
|
return lines.join("\n");
|
|
22176
22388
|
}
|
|
22177
22389
|
lines.push("Sources:");
|
|
22390
|
+
const [perSource, perQuery] = result.answer?.trim() ? [200, 3e3] : [600, 12e3];
|
|
22391
|
+
let budgetLeft = perQuery;
|
|
22178
22392
|
for (let i = 0; i < result.results.length; i++) {
|
|
22179
22393
|
const source = result.results[i];
|
|
22180
22394
|
lines.push(`${i + 1}. ${source.title} \u2014 ${source.url}`);
|
|
22395
|
+
const text4 = (source.snippet ?? "").replace(/\s+/g, " ").trim();
|
|
22396
|
+
const limit = Math.min(perSource, budgetLeft);
|
|
22397
|
+
if (!text4 || limit <= 0) continue;
|
|
22398
|
+
const snippet = text4.length <= limit ? text4 : `${text4.slice(0, limit - 1)}\u2026`;
|
|
22399
|
+
budgetLeft -= snippet.length;
|
|
22400
|
+
lines.push(` ${snippet}`);
|
|
22181
22401
|
}
|
|
22182
22402
|
return lines.join("\n");
|
|
22183
22403
|
}
|
|
@@ -22499,7 +22719,7 @@ import { randomUUID as randomUUID3 } from "node:crypto";
|
|
|
22499
22719
|
import { execFileSync as execFileSync3, spawn as spawn3 } from "node:child_process";
|
|
22500
22720
|
import { createRequire } from "node:module";
|
|
22501
22721
|
import { platform } from "node:os";
|
|
22502
|
-
import { existsSync as
|
|
22722
|
+
import { existsSync as existsSync55, readFileSync as readFileSync57, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "node:fs";
|
|
22503
22723
|
import { join as join8 } from "node:path";
|
|
22504
22724
|
init_gemini_api();
|
|
22505
22725
|
init_gemini_web();
|
|
@@ -22522,6 +22742,7 @@ function parseStringifiedArrays(args, keys) {
|
|
|
22522
22742
|
output[key] = parsed;
|
|
22523
22743
|
}
|
|
22524
22744
|
} catch {
|
|
22745
|
+
throw new Error(`${key} must be an array of strings; the given value is not valid JSON`);
|
|
22525
22746
|
}
|
|
22526
22747
|
}
|
|
22527
22748
|
return output ?? args;
|
|
@@ -22775,7 +22996,7 @@ function registerWebToolActivation(pi, tools, mode) {
|
|
|
22775
22996
|
}
|
|
22776
22997
|
|
|
22777
22998
|
// web-tool-core.ts
|
|
22778
|
-
import { existsSync as
|
|
22999
|
+
import { existsSync as existsSync54, readFileSync as readFileSync56 } from "node:fs";
|
|
22779
23000
|
import pLimit2 from "p-limit";
|
|
22780
23001
|
init_auth_fetch();
|
|
22781
23002
|
|
|
@@ -22944,7 +23165,7 @@ function findContent(text4, queries, mode) {
|
|
|
22944
23165
|
if (contained.length === 0) continue;
|
|
22945
23166
|
const prefix = range.start > 0 ? "\u2026" : "";
|
|
22946
23167
|
const suffix = range.end < text4.length ? "\u2026" : "";
|
|
22947
|
-
const snippet = `${prefix}${text4.slice(range.start, range.end).replace(/\s+/g, " ").trim()}${suffix}`;
|
|
23168
|
+
const snippet = `${prefix}${text4.slice(range.start, range.end).replace(/[\uD800-\uDFFF]/gu, "\uFFFD").replace(/\s+/g, " ").trim()}${suffix}`;
|
|
22948
23169
|
const counts = contained.map((result) => `${overflow ? result.id : `"${result.query}"`} \xD7${result.count}`).join(", ");
|
|
22949
23170
|
sections.push(`${index + 1}. ${counts}
|
|
22950
23171
|
${snippet}`);
|
|
@@ -23172,8 +23393,8 @@ function parseConfigRoot(raw) {
|
|
|
23172
23393
|
return parsed;
|
|
23173
23394
|
}
|
|
23174
23395
|
function loadConfig40() {
|
|
23175
|
-
if (!
|
|
23176
|
-
return parseConfigRoot(
|
|
23396
|
+
if (!existsSync54(WEB_SEARCH_CONFIG_PATH4)) return {};
|
|
23397
|
+
return parseConfigRoot(readFileSync56(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
|
|
23177
23398
|
}
|
|
23178
23399
|
var DEFAULT_TOOL_NAMES = {
|
|
23179
23400
|
webSearch: "web_search",
|
|
@@ -23318,7 +23539,7 @@ function fetchStructuredContent(responseId, results) {
|
|
|
23318
23539
|
};
|
|
23319
23540
|
}
|
|
23320
23541
|
function initialContentSlice(content, maxChars) {
|
|
23321
|
-
let endOffset = Math.min(content.length, maxChars);
|
|
23542
|
+
let endOffset = pageEnd(content, 0, Math.min(content.length, maxChars));
|
|
23322
23543
|
if (endOffset < content.length) {
|
|
23323
23544
|
const lineBreak = content.lastIndexOf("\n", endOffset);
|
|
23324
23545
|
if (lineBreak >= Math.floor(maxChars * 0.8)) endOffset = lineBreak + 1;
|
|
@@ -23471,7 +23692,8 @@ function boundSearchPresentation(text4, guidance, truncationGuidance, maxChars)
|
|
|
23471
23692
|
function registeredFetchToolNames(settings) {
|
|
23472
23693
|
return {
|
|
23473
23694
|
...settings.enabledTools.webSearch ? { webSearch: settings.toolNames.webSearch } : {},
|
|
23474
|
-
...settings.enabledTools.fetchContent ? { fetchContent: settings.toolNames.fetchContent } : {}
|
|
23695
|
+
...settings.enabledTools.fetchContent ? { fetchContent: settings.toolNames.fetchContent } : {},
|
|
23696
|
+
...settings.enabledTools.getSearchContent ? { getSearchContent: settings.toolNames.getSearchContent } : {}
|
|
23475
23697
|
};
|
|
23476
23698
|
}
|
|
23477
23699
|
function storedContentSourceNames(settings) {
|
|
@@ -23481,14 +23703,21 @@ function storedContentSourceNames(settings) {
|
|
|
23481
23703
|
...settings.enabledTools.fetchContent ? [settings.toolNames.fetchContent] : []
|
|
23482
23704
|
]);
|
|
23483
23705
|
}
|
|
23706
|
+
function pageEnd(content, offset, end) {
|
|
23707
|
+
if (end <= offset || end >= content.length) return end;
|
|
23708
|
+
const high = content.charCodeAt(end - 1);
|
|
23709
|
+
const low = content.charCodeAt(end);
|
|
23710
|
+
if (high < 55296 || high > 56319 || low < 56320 || low > 57343) return end;
|
|
23711
|
+
return end - 1 > offset ? end - 1 : end + 1;
|
|
23712
|
+
}
|
|
23484
23713
|
function sliceWithContinuation(content, offset, limit, maxChars, continuationAt) {
|
|
23485
|
-
let endOffset = offset + Math.min(limit, content.length - offset);
|
|
23714
|
+
let endOffset = pageEnd(content, offset, offset + Math.min(limit, content.length - offset));
|
|
23486
23715
|
let continuation = "";
|
|
23487
23716
|
while (endOffset < content.length) {
|
|
23488
23717
|
continuation = continuationAt(endOffset);
|
|
23489
23718
|
const overflow = endOffset - offset + continuation.length - maxChars;
|
|
23490
23719
|
if (overflow <= 0) break;
|
|
23491
|
-
endOffset
|
|
23720
|
+
endOffset = pageEnd(content, offset, endOffset - overflow);
|
|
23492
23721
|
}
|
|
23493
23722
|
return { endOffset, text: content.slice(offset, endOffset) + (endOffset < content.length ? continuation : "") };
|
|
23494
23723
|
}
|
|
@@ -23592,8 +23821,12 @@ Full search results are stored as responseId "${searchId}". `;
|
|
|
23592
23821
|
return value;
|
|
23593
23822
|
};
|
|
23594
23823
|
const presentation = hasApprovedSummary ? { text: unboundedPresentation, truncated: false, originalChars: unboundedPresentation.length, returnedChars: unboundedPresentation.length, omittedChars: 0 } : boundSearchPresentation(unboundedPresentation, buildGuidance(false), buildGuidance(true), maxInlineContentChars);
|
|
23824
|
+
const summaryGuidance = hasApprovedSummary ? buildGuidance(false) : "";
|
|
23595
23825
|
return {
|
|
23596
|
-
content: [
|
|
23826
|
+
content: [
|
|
23827
|
+
{ type: "text", text: presentation.text },
|
|
23828
|
+
...summaryGuidance ? [{ type: "text", text: summaryGuidance }] : []
|
|
23829
|
+
],
|
|
23597
23830
|
structuredContent: searchStructuredContent(searchId, fetchId, opts.results),
|
|
23598
23831
|
details: {
|
|
23599
23832
|
queries: opts.queryList,
|
|
@@ -23858,7 +24091,7 @@ Full search results are stored as responseId "${searchId}". `;
|
|
|
23858
24091
|
const fetchResults = await fetchAllContent2(urlList, signal, fetchOptions(requestOptions, options.proxy));
|
|
23859
24092
|
const presentedResults = mode === "answer" ? await Promise.all(fetchResults.map(async (result) => {
|
|
23860
24093
|
if (result.error) return result;
|
|
23861
|
-
if (result.
|
|
24094
|
+
if (result.mimeType?.startsWith("image/") || result.frames?.length) {
|
|
23862
24095
|
return { ...result, error: "Page answer requires textual fetched content" };
|
|
23863
24096
|
}
|
|
23864
24097
|
try {
|
|
@@ -23904,7 +24137,8 @@ Full search results are stored as responseId "${searchId}". `;
|
|
|
23904
24137
|
|
|
23905
24138
|
---
|
|
23906
24139
|
Showing ${slice.endOffset} of ${fullLength} chars, ${slice.shownBytes} of ${slice.totalBytes} bytes, and ${slice.shownLines} of ${slice.totalLines} lines. `;
|
|
23907
|
-
|
|
24140
|
+
if (mode === "answer") output2 += "Stored content is the original source, not the remaining answer. ";
|
|
24141
|
+
output2 += storedContent ? getSearchContentEnabled ? mode === "answer" ? `Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0, offset: 0 }) to read the original source from the beginning.` : `Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0, offset: ${slice.endOffset} }) for the next slice.` : "Content retrieval is not registered." : "Authenticated fetch cache is off; repeat the fetch to read more.";
|
|
23908
24142
|
}
|
|
23909
24143
|
const content = [];
|
|
23910
24144
|
if (result.frames?.length) {
|
|
@@ -23916,6 +24150,15 @@ Showing ${slice.endOffset} of ${fullLength} chars, ${slice.shownBytes} of ${slic
|
|
|
23916
24150
|
content.push({ type: "image", data: result.thumbnail.data, mimeType: result.thumbnail.mimeType });
|
|
23917
24151
|
}
|
|
23918
24152
|
content.push({ type: "text", text: output2 });
|
|
24153
|
+
if (!truncated && storedContent && getSearchContentEnabled) {
|
|
24154
|
+
const storedLabel = mode === "answer" ? "Original source content" : "Full content";
|
|
24155
|
+
content.push({
|
|
24156
|
+
type: "text",
|
|
24157
|
+
text: `
|
|
24158
|
+
---
|
|
24159
|
+
${storedLabel} is stored as responseId "${responseId}". Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0, offset: 0 }) to retrieve it.`
|
|
24160
|
+
});
|
|
24161
|
+
}
|
|
23919
24162
|
const imageCount = (result.frames?.length ?? 0) + (result.thumbnail ? 1 : 0);
|
|
23920
24163
|
return {
|
|
23921
24164
|
content,
|
|
@@ -23944,19 +24187,33 @@ Showing ${slice.endOffset} of ${fullLength} chars, ${slice.shownBytes} of ${slic
|
|
|
23944
24187
|
}
|
|
23945
24188
|
};
|
|
23946
24189
|
}
|
|
23947
|
-
let
|
|
24190
|
+
let budget = mode === "answer" ? getMaxInlineContentChars() : 0;
|
|
24191
|
+
let output = mode === "answer" ? "## Page answers\n" : "## Fetched URLs\n\n";
|
|
23948
24192
|
for (const { url, title, content, error } of presentedResults) {
|
|
23949
|
-
if (
|
|
23950
|
-
output += `- ${url}: Error - ${error}
|
|
24193
|
+
if (mode !== "answer") {
|
|
24194
|
+
output += error ? `- ${url}: Error - ${error}
|
|
24195
|
+
` : `- ${title || url} (${content.length} chars)
|
|
24196
|
+
`;
|
|
24197
|
+
} else if (error) {
|
|
24198
|
+
output += `
|
|
24199
|
+
### ${url}
|
|
24200
|
+
Error: ${error}
|
|
23951
24201
|
`;
|
|
23952
24202
|
} else {
|
|
23953
|
-
|
|
24203
|
+
const shown = content.slice(0, budget);
|
|
24204
|
+
budget -= shown.length;
|
|
24205
|
+
const marker = shown.length === content.length ? "" : `
|
|
24206
|
+
[answer ${shown.length ? "truncated at the output limit;" : "omitted; earlier answers used the output limit,"} fetch fewer URLs per call for complete answers]`;
|
|
24207
|
+
output += `
|
|
24208
|
+
### ${title || url}
|
|
24209
|
+
${shown}${marker}
|
|
23954
24210
|
`;
|
|
23955
24211
|
}
|
|
23956
24212
|
}
|
|
24213
|
+
const retrievalHint = mode === "answer" ? `Stored content is the original source pages, not the answers. Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0, offset: 0 }) to read the first source; urlIndex follows the order above.` : `Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0 }) to retrieve bounded content slices.`;
|
|
23957
24214
|
output += storedContent ? getSearchContentEnabled ? `
|
|
23958
24215
|
---
|
|
23959
|
-
|
|
24216
|
+
${retrievalHint}` : "\n---\nContent retrieval is not registered." : "\n---\nAuthenticated fetch cache is off; repeat the fetch to read content.";
|
|
23960
24217
|
return {
|
|
23961
24218
|
...successful === 0 ? { isError: true } : {},
|
|
23962
24219
|
content: [{ type: "text", text: output }],
|
|
@@ -24210,7 +24467,7 @@ ${text5}` }],
|
|
|
24210
24467
|
details: { error: "Offset out of range", offset, contentLength: urlData.content.length }
|
|
24211
24468
|
};
|
|
24212
24469
|
}
|
|
24213
|
-
const endOffset = Math.min(offset + limit, urlData.content.length);
|
|
24470
|
+
const endOffset = pageEnd(urlData.content, offset, Math.min(offset + limit, urlData.content.length));
|
|
24214
24471
|
const contentSlice = urlData.content.slice(offset, endOffset);
|
|
24215
24472
|
const hasMore = endOffset < urlData.content.length;
|
|
24216
24473
|
let text4 = `# ${urlData.title || urlData.url}
|
|
@@ -24308,12 +24565,12 @@ function renderSearchErrorPlan(plan, expanded, theme) {
|
|
|
24308
24565
|
}
|
|
24309
24566
|
function saveConfig(updates) {
|
|
24310
24567
|
let config = {};
|
|
24311
|
-
if (
|
|
24312
|
-
config = parseConfigRoot(
|
|
24568
|
+
if (existsSync55(WEB_SEARCH_CONFIG_PATH4)) {
|
|
24569
|
+
config = parseConfigRoot(readFileSync57(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
|
|
24313
24570
|
}
|
|
24314
24571
|
Object.assign(config, updates);
|
|
24315
24572
|
const dir = getWebSearchConfigDir();
|
|
24316
|
-
if (!
|
|
24573
|
+
if (!existsSync55(dir)) mkdirSync3(dir, { recursive: true });
|
|
24317
24574
|
writeFileSync3(WEB_SEARCH_CONFIG_PATH4, JSON.stringify(config, null, 2) + "\n");
|
|
24318
24575
|
}
|
|
24319
24576
|
var TOOL_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
@@ -24599,7 +24856,7 @@ function findGlimpseMjs() {
|
|
|
24599
24856
|
try {
|
|
24600
24857
|
const globalRoot = execFileSync3("npm", ["root", "-g"], { encoding: "utf-8" }).trim();
|
|
24601
24858
|
const entry = join8(globalRoot, "glimpseui", "src", "glimpse.mjs");
|
|
24602
|
-
if (
|
|
24859
|
+
if (existsSync55(entry)) return entry;
|
|
24603
24860
|
} catch {
|
|
24604
24861
|
}
|
|
24605
24862
|
return null;
|
|
@@ -25841,6 +26098,9 @@ Open manually: ${handle.url}` }],
|
|
|
25841
26098
|
})),
|
|
25842
26099
|
proxy: Type2.Optional(Type2.String({
|
|
25843
26100
|
description: "http(s) or socks proxy URL (e.g. http://host:port or socks5h://host:port) used for this fetch. Needed when the target is unreachable directly; localhost and NO_PROXY hosts always bypass the proxy. Empty string forces direct access."
|
|
26101
|
+
})),
|
|
26102
|
+
redirects: Type2.Optional(StringEnum(["same-origin"], {
|
|
26103
|
+
description: "Refuse cross-origin redirects: every redirect target must match the requested URL's scheme, hostname and effective port, and extraction paths whose redirect chain cannot be observed are refused instead of used."
|
|
25844
26104
|
}))
|
|
25845
26105
|
}),
|
|
25846
26106
|
outputSchema: fetchContentOutputSchema,
|