@herbertgao/pi-extensions 2026.10.11 → 2026.10.13

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.
Files changed (221) hide show
  1. package/README.md +8 -8
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/node_modules/@herbertgao/pi-agency/README.md +5 -3
  4. package/node_modules/@herbertgao/pi-agency/package.json +1 -1
  5. package/node_modules/@herbertgao/pi-agency/src/index.ts +51 -7
  6. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +6 -8
  7. package/node_modules/@herbertgao/pi-cc-extensions/README.md +6 -8
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +11 -2
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +28 -6
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +33 -12
  11. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +16 -3
  12. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  13. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  14. package/node_modules/@herbertgao/pi-subagents/package.json +1 -1
  15. package/node_modules/@herbertgao/pi-subagents/src/agent-color.ts +11 -2
  16. package/node_modules/@herbertgao/pi-subagents/src/index.ts +10 -5
  17. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +3 -2
  18. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +1 -1
  19. package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +1 -0
  20. package/node_modules/@herbertgao/sol-pi/README.md +1 -1
  21. package/node_modules/@herbertgao/sol-pi/agents-install.md +2 -2
  22. package/node_modules/@narumitw/pi-btw/README.md +14 -5
  23. package/node_modules/@narumitw/pi-btw/dist/index.ts +1067 -560
  24. package/node_modules/@narumitw/pi-btw/dist/index.ts.map +4 -4
  25. package/node_modules/@narumitw/pi-btw/docs/core-alignment.md +277 -0
  26. package/node_modules/@narumitw/pi-btw/docs/native-appearance.md +857 -0
  27. package/node_modules/@narumitw/pi-btw/docs/workflows.md +34 -13
  28. package/node_modules/@narumitw/pi-btw/package.json +4 -4
  29. package/node_modules/@narumitw/pi-btw/src/btw.ts +152 -108
  30. package/node_modules/@narumitw/pi-btw/src/conversation-chrome.ts +93 -0
  31. package/node_modules/@narumitw/pi-btw/src/fullscreen-renderer.ts +329 -0
  32. package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +109 -315
  33. package/node_modules/@narumitw/pi-btw/src/keybindings.ts +100 -22
  34. package/node_modules/@narumitw/pi-btw/src/menu.ts +42 -27
  35. package/node_modules/@narumitw/pi-btw/src/session-lifetime.ts +66 -0
  36. package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +366 -164
  37. package/node_modules/@narumitw/pi-btw/src/workspace-layout.ts +96 -36
  38. package/node_modules/pi-lens/CHANGELOG.md +281 -0
  39. package/node_modules/pi-lens/README.md +13 -1
  40. package/node_modules/pi-lens/dist/{chunk-SS36ZX4J.js → chunk-24AKHFGP.js} +6 -6
  41. package/node_modules/pi-lens/dist/{chunk-JSQFTSC6.js → chunk-2FN63LPV.js} +11 -11
  42. package/node_modules/pi-lens/dist/{chunk-5UCAH366.js → chunk-2KXTHF3M.js} +20 -20
  43. package/node_modules/pi-lens/dist/{chunk-EU63SDCG.js → chunk-3DA2JDOL.js} +367 -281
  44. package/node_modules/pi-lens/dist/{chunk-RWWYJ623.js → chunk-3KAZU3VR.js} +1 -1
  45. package/node_modules/pi-lens/dist/chunk-3PTHXJXR.js +28 -0
  46. package/node_modules/pi-lens/dist/chunk-3QED2P4V.js +31 -0
  47. package/node_modules/pi-lens/dist/{chunk-N2H3ZPZY.js → chunk-3RKP3FMS.js} +1 -0
  48. package/node_modules/pi-lens/dist/{chunk-XVF2VVXP.js → chunk-5HSRT26B.js} +2 -2
  49. package/node_modules/pi-lens/dist/{chunk-MXGY6KPT.js → chunk-5IUSNGOC.js} +15 -15
  50. package/node_modules/pi-lens/dist/{chunk-EJIUXPBX.js → chunk-5OFV52AM.js} +1 -1
  51. package/node_modules/pi-lens/dist/{chunk-AW7R2GWG.js → chunk-5VSF4UUQ.js} +12 -7
  52. package/node_modules/pi-lens/dist/{chunk-6STA6Z7I.js → chunk-5WRPDP2A.js} +18 -18
  53. package/node_modules/pi-lens/dist/{chunk-YIUAVF7E.js → chunk-6DLWKFEX.js} +35 -34
  54. package/node_modules/pi-lens/dist/{chunk-WOA4LN2R.js → chunk-7D6L4MTX.js} +2 -2
  55. package/node_modules/pi-lens/dist/{chunk-GAEGEPOC.js → chunk-7HXE67BN.js} +2 -2
  56. package/node_modules/pi-lens/dist/chunk-AGSS7277.js +84 -0
  57. package/node_modules/pi-lens/dist/{chunk-R3PCY3YS.js → chunk-AMERCH6V.js} +13 -13
  58. package/node_modules/pi-lens/dist/{chunk-WU567RSC.js → chunk-ATKJFDQN.js} +14 -10
  59. package/node_modules/pi-lens/dist/{chunk-VSSBEUFT.js → chunk-AWSCPCN2.js} +16 -16
  60. package/node_modules/pi-lens/dist/{chunk-VCHXCQFG.js → chunk-BWD5EPKO.js} +3 -3
  61. package/node_modules/pi-lens/dist/{chunk-H6MF6EVN.js → chunk-CT4MN5IU.js} +1200 -230
  62. package/node_modules/pi-lens/dist/{chunk-FCSOVF55.js → chunk-CUHSHSB6.js} +6 -6
  63. package/node_modules/pi-lens/dist/{chunk-CHOW74WE.js → chunk-CYRKQRPM.js} +7 -10
  64. package/node_modules/pi-lens/dist/{chunk-Q7DUK4LX.js → chunk-DEL2U6CM.js} +5 -5
  65. package/node_modules/pi-lens/dist/{chunk-6C7JWPCP.js → chunk-DGUKIYSI.js} +26 -23
  66. package/node_modules/pi-lens/dist/{chunk-PHDMFAKM.js → chunk-DUO2TU77.js} +2 -2
  67. package/node_modules/pi-lens/dist/{chunk-MRXKYPCS.js → chunk-EBC36LNN.js} +2 -2
  68. package/node_modules/pi-lens/dist/{chunk-CSHFH5IN.js → chunk-ED36RF6Y.js} +1 -1
  69. package/node_modules/pi-lens/dist/{chunk-76MWC2K6.js → chunk-EUXZEFTV.js} +90 -97
  70. package/node_modules/pi-lens/dist/{chunk-QOZXJ4NA.js → chunk-FM4RDMKT.js} +11 -8
  71. package/node_modules/pi-lens/dist/{chunk-ACXEQZOU.js → chunk-GAQ7OQG6.js} +31 -28
  72. package/node_modules/pi-lens/dist/{chunk-XAGLWMJ4.js → chunk-GL5LUMZE.js} +23 -23
  73. package/node_modules/pi-lens/dist/{chunk-BKE7E7TC.js → chunk-GMX5OS7B.js} +9 -9
  74. package/node_modules/pi-lens/dist/{chunk-ZHFZWTZV.js → chunk-GSLNCYGG.js} +11 -11
  75. package/node_modules/pi-lens/dist/{chunk-3W7IEVVL.js → chunk-GSM5UU7A.js} +26 -34
  76. package/node_modules/pi-lens/dist/{chunk-724UL2TJ.js → chunk-GXFV6MYU.js} +3 -3
  77. package/node_modules/pi-lens/dist/chunk-HAD7QRQI.js +30 -0
  78. package/node_modules/pi-lens/dist/{chunk-QOBUHWHX.js → chunk-HRNHZA3N.js} +6 -6
  79. package/node_modules/pi-lens/dist/{chunk-VWCXW2E7.js → chunk-HWCCCQNX.js} +1 -1
  80. package/node_modules/pi-lens/dist/{chunk-7DYBLXYA.js → chunk-HYGZEMX6.js} +3 -3
  81. package/node_modules/pi-lens/dist/chunk-IJYGIDF4.js +186 -0
  82. package/node_modules/pi-lens/dist/{chunk-4W4VLAPJ.js → chunk-IQWN5JCP.js} +11 -11
  83. package/node_modules/pi-lens/dist/{chunk-SQ4TVJBR.js → chunk-IUE7SSKV.js} +7 -7
  84. package/node_modules/pi-lens/dist/{chunk-IBGIOBEE.js → chunk-IWDLU6K3.js} +68 -5
  85. package/node_modules/pi-lens/dist/{chunk-XCJN5IJU.js → chunk-IYNJ6YPZ.js} +4 -4
  86. package/node_modules/pi-lens/dist/{chunk-JAU72XNY.js → chunk-J64T55EI.js} +3 -3
  87. package/node_modules/pi-lens/dist/{chunk-2BBLFX75.js → chunk-J6MPGQTS.js} +5 -5
  88. package/node_modules/pi-lens/dist/chunk-JORED7EX.js +44 -0
  89. package/node_modules/pi-lens/dist/{chunk-6SDEP3AJ.js → chunk-JUKMK5Y4.js} +8 -8
  90. package/node_modules/pi-lens/dist/{chunk-FMSO6RDZ.js → chunk-JW3YWBVB.js} +15 -15
  91. package/node_modules/pi-lens/dist/{chunk-L3BLXZG7.js → chunk-KAPJINKN.js} +30 -69
  92. package/node_modules/pi-lens/dist/{chunk-2B73ZPOK.js → chunk-KN35K52N.js} +3 -3
  93. package/node_modules/pi-lens/dist/{chunk-C34ZXZ7O.js → chunk-KUA4OJ5Y.js} +24 -11
  94. package/node_modules/pi-lens/dist/chunk-KYUB6QDC.js +72 -0
  95. package/node_modules/pi-lens/dist/{chunk-67WMNWEE.js → chunk-LLJNQKQW.js} +12 -10
  96. package/node_modules/pi-lens/dist/chunk-LZSEQW6A.js +57 -0
  97. package/node_modules/pi-lens/dist/{chunk-ZANLILYD.js → chunk-M2IFVFWU.js} +2 -2
  98. package/node_modules/pi-lens/dist/chunk-M2UD3LPU.js +88 -0
  99. package/node_modules/pi-lens/dist/{chunk-XIJZVPD5.js → chunk-MBKQHGA7.js} +15 -15
  100. package/node_modules/pi-lens/dist/{chunk-P7266HLM.js → chunk-MPNJLASA.js} +2 -2
  101. package/node_modules/pi-lens/dist/{chunk-6GFRNVYR.js → chunk-MZGQNL3Y.js} +10 -10
  102. package/node_modules/pi-lens/dist/{chunk-ZWFS3OEF.js → chunk-N5FLEO7W.js} +33 -32
  103. package/node_modules/pi-lens/dist/{chunk-3JNKMP3B.js → chunk-O4NWQT6I.js} +4 -4
  104. package/node_modules/pi-lens/dist/{chunk-T6CPIZNT.js → chunk-OHKJ7PQF.js} +33 -32
  105. package/node_modules/pi-lens/dist/{chunk-VRZP76YM.js → chunk-P63GXC37.js} +4 -1
  106. package/node_modules/pi-lens/dist/{chunk-XTMJ7XDT.js → chunk-POMLXPMY.js} +1 -1
  107. package/node_modules/pi-lens/dist/{chunk-QQNQ7SJW.js → chunk-QBFBRV2B.js} +10 -4
  108. package/node_modules/pi-lens/dist/{chunk-CMMHNUZ2.js → chunk-R3T7CLQ2.js} +60 -38
  109. package/node_modules/pi-lens/dist/{chunk-23WOO7TX.js → chunk-R7YOCSNV.js} +10 -10
  110. package/node_modules/pi-lens/dist/{chunk-2CD5RS6M.js → chunk-RKBXZN3A.js} +23 -2
  111. package/node_modules/pi-lens/dist/{chunk-OCAGUNBC.js → chunk-RKKOYPRA.js} +12 -12
  112. package/node_modules/pi-lens/dist/{chunk-52FUZI6K.js → chunk-RMLC67LF.js} +1 -1
  113. package/node_modules/pi-lens/dist/{chunk-XMSXXAHW.js → chunk-ROYSX2S5.js} +2 -2
  114. package/node_modules/pi-lens/dist/{chunk-M6HSLBWY.js → chunk-RVK72CZX.js} +6507 -7514
  115. package/node_modules/pi-lens/dist/{chunk-FLKWCIZH.js → chunk-S2HEXIWI.js} +5 -5
  116. package/node_modules/pi-lens/dist/{chunk-UZ3TUTRV.js → chunk-S67KYG37.js} +1 -1
  117. package/node_modules/pi-lens/dist/{chunk-VCO24T4L.js → chunk-SD4I7ZO4.js} +14 -14
  118. package/node_modules/pi-lens/dist/{chunk-Z527N6YQ.js → chunk-SKAMFC7A.js} +12 -12
  119. package/node_modules/pi-lens/dist/{chunk-MQLUAEOC.js → chunk-SRYEJNES.js} +2 -2
  120. package/node_modules/pi-lens/dist/{chunk-BRGDSBJE.js → chunk-SYE6T2EB.js} +12 -12
  121. package/node_modules/pi-lens/dist/{chunk-GXW6K4YJ.js → chunk-T57LYLZT.js} +1 -1
  122. package/node_modules/pi-lens/dist/{chunk-ZXYDQ3TZ.js → chunk-T7FEBKXN.js} +48 -15
  123. package/node_modules/pi-lens/dist/{chunk-3EFKIGZN.js → chunk-TIQ2PKDW.js} +3 -3
  124. package/node_modules/pi-lens/dist/{chunk-QILIYSJF.js → chunk-TLX72JTG.js} +1 -1
  125. package/node_modules/pi-lens/dist/{chunk-TYM6OUIT.js → chunk-TOY6QKOH.js} +12 -12
  126. package/node_modules/pi-lens/dist/{chunk-IZSHAIJ7.js → chunk-TRETHTQO.js} +12 -12
  127. package/node_modules/pi-lens/dist/{chunk-3VPVG5SU.js → chunk-U44DJXQP.js} +10 -6
  128. package/node_modules/pi-lens/dist/{chunk-PNQDPDRC.js → chunk-UA7ZXYDR.js} +1 -1
  129. package/node_modules/pi-lens/dist/{chunk-OXXKQCSV.js → chunk-UBOQLVT2.js} +4 -4
  130. package/node_modules/pi-lens/dist/{chunk-QGQ5CCCG.js → chunk-UMS2MFPZ.js} +2 -2
  131. package/node_modules/pi-lens/dist/{chunk-QHJ6DQ2R.js → chunk-US7ECLD7.js} +55 -13
  132. package/node_modules/pi-lens/dist/{chunk-AB3YYG6N.js → chunk-UZ2XCLYS.js} +8 -8
  133. package/node_modules/pi-lens/dist/chunk-V35JG4JB.js +2667 -0
  134. package/node_modules/pi-lens/dist/{chunk-N3X6Q4YT.js → chunk-VOOAPROD.js} +3 -3
  135. package/node_modules/pi-lens/dist/{chunk-SAEFPSB6.js → chunk-W66O5E25.js} +21 -11
  136. package/node_modules/pi-lens/dist/{chunk-KBG47GHP.js → chunk-WMYE35PX.js} +15 -11
  137. package/node_modules/pi-lens/dist/{chunk-5NGR67U5.js → chunk-XBJVAEEO.js} +32 -5
  138. package/node_modules/pi-lens/dist/{chunk-YYOIQFRS.js → chunk-XHJBS436.js} +122 -44
  139. package/node_modules/pi-lens/dist/{chunk-GBPP5P7X.js → chunk-XTBDCR27.js} +4 -4
  140. package/node_modules/pi-lens/dist/{chunk-4UNXBNE2.js → chunk-XTFDJI3T.js} +11 -11
  141. package/node_modules/pi-lens/dist/{chunk-UXGETRP4.js → chunk-XYURS6EN.js} +13 -12
  142. package/node_modules/pi-lens/dist/{chunk-RPLINGVB.js → chunk-Y6GZHWSJ.js} +6 -6
  143. package/node_modules/pi-lens/dist/{chunk-2VUQMUMT.js → chunk-YCWYO6TQ.js} +41 -38
  144. package/node_modules/pi-lens/dist/{chunk-77M37OKR.js → chunk-YH5MVY2U.js} +7 -7
  145. package/node_modules/pi-lens/dist/{chunk-AOHZU2BM.js → chunk-YNE3RP52.js} +1 -1
  146. package/node_modules/pi-lens/dist/{chunk-YSZNHOBY.js → chunk-ZHH37KZL.js} +12 -12
  147. package/node_modules/pi-lens/dist/{chunk-ZGDGW2V3.js → chunk-ZIVJBOO3.js} +2 -2
  148. package/node_modules/pi-lens/dist/{chunk-RXCOMYPY.js → chunk-ZVUL7QYY.js} +29 -28
  149. package/node_modules/pi-lens/dist/index.js +11052 -5852
  150. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +10 -9
  151. package/node_modules/pi-lens/dist/mcp/cli.js +41 -38
  152. package/node_modules/pi-lens/dist/mcp/server.js +1120 -474
  153. package/node_modules/pi-lens/dist/mcp/worker.js +61 -58
  154. package/node_modules/pi-lens/dist/probes/installer.js +19 -19
  155. package/node_modules/pi-lens/dist/workers/project-snapshot-persist-worker.js +28 -9
  156. package/node_modules/pi-lens/dist/workers/review-graph-persist-worker.js +1 -1
  157. package/node_modules/pi-lens/docs/configuration.md +11 -0
  158. package/node_modules/pi-lens/docs/engineering-principles.md +32 -0
  159. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +1 -1
  160. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +15 -26
  161. package/node_modules/pi-lens/docs/pi-lens-fixer.md +117 -13
  162. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +97 -7
  163. package/node_modules/pi-lens/docs/pi-lens-monitor.md +8 -2
  164. package/node_modules/pi-lens/docs/pi-lens-retro.md +4 -1
  165. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +112 -4
  166. package/node_modules/pi-lens/docs/pi-lens-subagent.md +22 -14
  167. package/node_modules/pi-lens/docs/release-qa-baseline.md +3 -1
  168. package/node_modules/pi-lens/docs/servercapabilities.md +9 -19
  169. package/node_modules/pi-lens/package.json +7 -5
  170. package/node_modules/pi-lens/scripts/download-grammars.js +40 -7
  171. package/node_modules/pi-lens/scripts/lib/latency-log-phases.mjs +95 -0
  172. package/node_modules/pi-lens/scripts/rpc-load-check.mjs +570 -81
  173. package/node_modules/pi-provider-qoder/dist/index.js +545 -221
  174. package/node_modules/pi-provider-qoder/package.json +1 -1
  175. package/node_modules/pi-web-access/CHANGELOG.md +39 -0
  176. package/node_modules/pi-web-access/README.md +83 -12
  177. package/node_modules/pi-web-access/anysearch.ts +4 -3
  178. package/node_modules/pi-web-access/bocha.ts +4 -3
  179. package/node_modules/pi-web-access/brightdata-unlocker.ts +3 -2
  180. package/node_modules/pi-web-access/brightdata.ts +4 -3
  181. package/node_modules/pi-web-access/ceramic.ts +3 -2
  182. package/node_modules/pi-web-access/curator-page.ts +3 -1
  183. package/node_modules/pi-web-access/curator-server.ts +1 -0
  184. package/node_modules/pi-web-access/deepseek.ts +179 -6
  185. package/node_modules/pi-web-access/dist/index.js +1118 -688
  186. package/node_modules/pi-web-access/dist/mcp-cli.js +1081 -667
  187. package/node_modules/pi-web-access/extract.ts +58 -6
  188. package/node_modules/pi-web-access/gemini-search.ts +29 -6
  189. package/node_modules/pi-web-access/index.ts +20 -3
  190. package/node_modules/pi-web-access/jina-search.ts +6 -4
  191. package/node_modules/pi-web-access/kagi.ts +5 -4
  192. package/node_modules/pi-web-access/keenable.ts +3 -2
  193. package/node_modules/pi-web-access/linkup.ts +170 -0
  194. package/node_modules/pi-web-access/mistral-search.ts +4 -3
  195. package/node_modules/pi-web-access/ollama.ts +5 -4
  196. package/node_modules/pi-web-access/package.json +1 -1
  197. package/node_modules/pi-web-access/parallel.ts +7 -7
  198. package/node_modules/pi-web-access/perplexity.ts +5 -3
  199. package/node_modules/pi-web-access/querit.ts +4 -3
  200. package/node_modules/pi-web-access/search1api.ts +4 -3
  201. package/node_modules/pi-web-access/searchinfinity.ts +4 -3
  202. package/node_modules/pi-web-access/serpapi.ts +7 -5
  203. package/node_modules/pi-web-access/serpbase.ts +5 -4
  204. package/node_modules/pi-web-access/serpdive.ts +4 -3
  205. package/node_modules/pi-web-access/serper.ts +6 -4
  206. package/node_modules/pi-web-access/serply.ts +3 -2
  207. package/node_modules/pi-web-access/utils.ts +24 -1
  208. package/node_modules/pi-web-access/valyu.ts +4 -3
  209. package/node_modules/pi-web-access/web-tool-core.ts +5 -0
  210. package/node_modules/pi-web-access/xai-search.ts +49 -7
  211. package/node_modules/pi-web-access/xcrawl.ts +4 -3
  212. package/node_modules/pi-web-access/you.ts +3 -2
  213. package/package.json +10 -10
  214. package/node_modules/pi-lens/dist/chunk-3YN6V5TV.js +0 -85
  215. package/node_modules/pi-lens/dist/chunk-466Z26MG.js +0 -30
  216. package/node_modules/pi-lens/dist/chunk-EC47DWFA.js +0 -56
  217. package/node_modules/pi-lens/dist/chunk-KDERNTCQ.js +0 -28
  218. package/node_modules/pi-lens/dist/chunk-KSX3TXSZ.js +0 -69
  219. package/node_modules/pi-lens/dist/chunk-LOP6GRPH.js +0 -31
  220. package/node_modules/pi-lens/dist/chunk-UOPVJQ4N.js +0 -103
  221. /package/node_modules/pi-lens/dist/{chunk-FC4RP4I2.js → chunk-6HWVI6MI.js} +0 -0
@@ -3,7 +3,7 @@ import { activityMonitor } from "./activity.ts";
3
3
  import { normalizeDomain } from "./domain-filter-normalization.ts";
4
4
  import type { SearchOptions, SearchResponse, SearchResult } from "./perplexity.ts";
5
5
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
6
- import { getWebSearchConfigPath } from "./utils.ts";
6
+ import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
7
7
 
8
8
  const MISTRAL_CONVERSATIONS_URL = "https://api.mistral.ai/v1/conversations";
9
9
  const CONFIG_PATH = getWebSearchConfigPath();
@@ -15,6 +15,7 @@ const MAX_RESULTS = 20;
15
15
  type MistralSearchTool = "web_search" | "web_search_premium";
16
16
 
17
17
  interface WebSearchConfig {
18
+ mistralSearchBaseUrl?: unknown;
18
19
  mistralApiKey?: unknown;
19
20
  mistralSearchModel?: unknown;
20
21
  mistralSearchTool?: unknown;
@@ -222,7 +223,7 @@ export async function searchWithMistral(query: string, options: SearchOptions =
222
223
  const activityId = activityMonitor.logStart({ type: "api", query });
223
224
 
224
225
  try {
225
- const response = await fetch(MISTRAL_CONVERSATIONS_URL, {
226
+ const response = await fetchWithCredentialRedirects(resolveProviderApiUrl("mistralSearch", MISTRAL_CONVERSATIONS_URL, loadConfig().mistralSearchBaseUrl), {
226
227
  method: "POST",
227
228
  headers: {
228
229
  Authorization: `Bearer ${apiKey}`,
@@ -235,7 +236,7 @@ export async function searchWithMistral(query: string, options: SearchOptions =
235
236
  tools: [{ type: tool }],
236
237
  }),
237
238
  signal: requestSignal,
238
- });
239
+ }, ["Authorization"]);
239
240
 
240
241
  if (!response.ok) {
241
242
  const errorText = redactCredential(await response.text(), apiKey);
@@ -5,7 +5,7 @@ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
5
5
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
6
6
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
7
7
  import { fetchRemoteUrl, loadFetchContentDomainPolicy, loadSsrfConfig, validateRemoteUrl, type Lookup, type SsrfConfig } from "./ssrf-protection.ts";
8
- import { getWebSearchConfigPath } from "./utils.ts";
8
+ import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
9
9
 
10
10
  const OLLAMA_SEARCH_URL = "https://ollama.com/api/web_search";
11
11
  const OLLAMA_FETCH_URL = "https://ollama.com/api/web_fetch";
@@ -13,6 +13,7 @@ const CONFIG_PATH = getWebSearchConfigPath();
13
13
  const SEARCH_TIMEOUT_MS = 60_000;
14
14
 
15
15
  interface WebSearchConfig {
16
+ ollamaBaseUrl?: unknown;
16
17
  ollamaApiKey?: unknown;
17
18
  }
18
19
 
@@ -133,12 +134,12 @@ export async function searchWithOllama(query: string, options: OllamaSearchOptio
133
134
  const activityId = activityMonitor.logStart({ type: "api", query });
134
135
  let response: Response;
135
136
  try {
136
- response = await fetch(OLLAMA_SEARCH_URL, {
137
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("ollama", OLLAMA_SEARCH_URL, loadConfig().ollamaBaseUrl), {
137
138
  method: "POST",
138
139
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
139
140
  body: JSON.stringify({ query, max_results: numResults }),
140
141
  signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS),
141
- });
142
+ }, ["Authorization"]);
142
143
  } catch (err) {
143
144
  const message = errorMessage(err);
144
145
  const redactedMessage = redactCredential(message, apiKey);
@@ -194,7 +195,7 @@ export async function extractWithOllama(url: string, signal?: AbortSignal, optio
194
195
  const activityId = activityMonitor.logStart({ type: "api", query: `ollama fetch: ${url}` });
195
196
  let response: Response;
196
197
  try {
197
- response = await fetchRemoteUrl(OLLAMA_FETCH_URL, {
198
+ response = await fetchRemoteUrl(resolveProviderApiUrl("ollama", OLLAMA_FETCH_URL, loadConfig().ollamaBaseUrl), {
198
199
  method: "POST",
199
200
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
200
201
  body: JSON.stringify({ url }),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-web-access",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "description": "Web search, URL fetching, GitHub repo cloning, PDF extraction, YouTube video understanding, and local video analysis for Pi coding agent. Supports OpenAI, Brave, Parallel, TinyFish, Search1API, Searchinfinity, Querit, Tavily, Firecrawl, Crawl4AI, Jina, SERPdive, Kagi, Ollama, AnySearch, Bright Data SERP, SerpBase, SerpApi, Serply, You.com, SearXNG, degoog, Exa, Perplexity, Gemini, Kimi, and Mistral.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,10 +4,9 @@ import { normalizeDomain } from "./domain-filter-normalization.ts";
4
4
  import type { ExtractedContent, ExtractOptions } from "./extract.ts";
5
5
  import type { SearchOptions, SearchResponse } from "./perplexity.ts";
6
6
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
7
- import { getWebSearchConfigPath } from "./utils.ts";
7
+ import { fetchWithCredentialRedirects, getWebSearchConfigPath, resolveProviderApiUrl } from "./utils.ts";
8
8
 
9
- const PARALLEL_SEARCH_URL = "https://api.parallel.ai/v1/search";
10
- const PARALLEL_EXTRACT_URL = "https://api.parallel.ai/v1/extract";
9
+ const PARALLEL_API_BASE_URL = "https://api.parallel.ai";
11
10
  const CONFIG_PATH = getWebSearchConfigPath();
12
11
  const MIN_PARALLEL_API_KEY_LENGTH = 8;
13
12
  const MIN_USEFUL_CONTENT = 500;
@@ -30,6 +29,7 @@ const PLACEHOLDER_API_KEY_DENYLIST = new Set([
30
29
 
31
30
  interface WebSearchConfig {
32
31
  parallelApiKey?: unknown;
32
+ parallelBaseUrl?: unknown;
33
33
  }
34
34
 
35
35
  interface V1WebSearchResult {
@@ -293,14 +293,14 @@ async function fetchAndMapExtractResult(
293
293
  body: Record<string, unknown>,
294
294
  signal?: AbortSignal,
295
295
  ): Promise<{ mapped: ExtractedContent | null; result: V1ExtractResult | undefined }> {
296
- const data = await parallelFetch(PARALLEL_EXTRACT_URL, body, signal);
296
+ const data = await parallelFetch(resolveProviderApiUrl("parallel", `${PARALLEL_API_BASE_URL}/v1/extract`, loadConfig().parallelBaseUrl), body, signal);
297
297
  if (hasExtractUrlError(data.errors, url)) return { mapped: null, result: undefined };
298
298
  const result = findExtractResult(data.results as V1ExtractResult[] | undefined, url);
299
299
  return { mapped: mapExtractResult(result), result };
300
300
  }
301
301
 
302
302
  export async function searchWithParallel(query: string, options: ParallelSearchOptions = {}): Promise<SearchResponse> {
303
- const data = await parallelFetch(PARALLEL_SEARCH_URL, buildSearchRequestBody(query, options), options.signal);
303
+ const data = await parallelFetch(resolveProviderApiUrl("parallel", `${PARALLEL_API_BASE_URL}/v1/search`, loadConfig().parallelBaseUrl), buildSearchRequestBody(query, options), options.signal);
304
304
  const results = data.results as V1WebSearchResult[] | undefined;
305
305
  const response: SearchResponse = {
306
306
  answer: buildAnswerFromExcerpts(results),
@@ -335,7 +335,7 @@ async function parallelFetch(
335
335
  const activityId = activityMonitor.logStart(activityContext(url, body));
336
336
  let response: Response;
337
337
  try {
338
- response = await fetch(url, {
338
+ response = await fetchWithCredentialRedirects(url, {
339
339
  method: "POST",
340
340
  headers: {
341
341
  "x-api-key": apiKey,
@@ -343,7 +343,7 @@ async function parallelFetch(
343
343
  },
344
344
  body: JSON.stringify(body),
345
345
  signal: requestSignal(signal),
346
- });
346
+ }, ["x-api-key"]);
347
347
  } catch (err) {
348
348
  const message = errorMessage(err);
349
349
  const redactedMessage = redactCredential(message, apiKey);
@@ -3,7 +3,7 @@ import { activityMonitor } from "./activity.ts";
3
3
  import type { ExtractedContent } from "./extract.ts";
4
4
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
5
5
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
6
- import { getWebSearchConfigPath } from "./utils.ts";
6
+ import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
7
7
 
8
8
  const PERPLEXITY_SEARCH_URL = "https://api.perplexity.ai/search";
9
9
  const PERPLEXITY_CHAT_URL = "https://api.perplexity.ai/chat/completions";
@@ -37,6 +37,7 @@ export interface SearchOptions {
37
37
  }
38
38
 
39
39
  interface WebSearchConfig {
40
+ perplexityBaseUrl?: unknown;
40
41
  perplexityApiKey?: unknown;
41
42
  }
42
43
 
@@ -118,6 +119,7 @@ async function postPerplexity(
118
119
  body: Record<string, unknown>,
119
120
  options: PerplexityRequestOptions,
120
121
  ): Promise<Record<string, unknown>> {
122
+ const apiUrl = resolveProviderApiUrl("perplexity", url, loadConfig().perplexityBaseUrl);
121
123
  checkRateLimit();
122
124
 
123
125
  const activityId = activityMonitor.logStart({ type: "api", query: options.activityQuery });
@@ -138,7 +140,7 @@ async function postPerplexity(
138
140
 
139
141
  let response: Response;
140
142
  try {
141
- response = await fetch(url, {
143
+ response = await fetchWithCredentialRedirects(apiUrl, {
142
144
  method: "POST",
143
145
  headers: {
144
146
  Authorization: `Bearer ${apiKey}`,
@@ -146,7 +148,7 @@ async function postPerplexity(
146
148
  },
147
149
  body: JSON.stringify(body),
148
150
  signal: options.signal ? AbortSignal.any([options.signal, timeout]) : timeout,
149
- });
151
+ }, ["Authorization"]);
150
152
  } catch (err) {
151
153
  if (timedOut()) {
152
154
  activityMonitor.logError(activityId, "request timed out");
@@ -6,7 +6,7 @@ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
6
6
  import type { SearchOptions, SearchResponse } from "./perplexity.ts";
7
7
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
8
8
  import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
9
- import { getWebSearchConfigPath } from "./utils.ts";
9
+ import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
10
10
 
11
11
  const QUERIT_SEARCH_URL = "https://api.querit.ai/v1/search";
12
12
  const QUERIT_CONTENTS_URL = "https://api.querit.ai/v1/contents";
@@ -16,6 +16,7 @@ const CONTENTS_TIMEOUT_MS = 60_000;
16
16
  const MAX_CONTENT_URLS = 10;
17
17
 
18
18
  interface WebSearchConfig {
19
+ queritBaseUrl?: unknown;
19
20
  queritApiKey?: unknown;
20
21
  }
21
22
 
@@ -193,7 +194,7 @@ async function queritJsonRequest<T>(
193
194
  ): Promise<T> {
194
195
  let response: Response;
195
196
  try {
196
- response = await fetch(url, {
197
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("querit", url, loadConfig().queritBaseUrl), {
197
198
  method: "POST",
198
199
  headers: {
199
200
  Authorization: `Bearer ${apiKey}`,
@@ -202,7 +203,7 @@ async function queritJsonRequest<T>(
202
203
  },
203
204
  body: JSON.stringify(body),
204
205
  signal: requestSignal(signal, timeoutMs),
205
- });
206
+ }, ["Authorization"]);
206
207
  } catch (err) {
207
208
  const message = errorMessage(err);
208
209
  const isRequestAbort = err instanceof Error
@@ -6,7 +6,7 @@ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
6
6
  import type { SearchOptions, SearchResponse } from "./perplexity.ts";
7
7
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
8
8
  import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
9
- import { getWebSearchConfigPath } from "./utils.ts";
9
+ import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
10
10
 
11
11
  const SEARCH1API_SEARCH_URL = "https://api.search1api.com/search";
12
12
  const SEARCH1API_CRAWL_URL = "https://api.search1api.com/crawl";
@@ -15,6 +15,7 @@ const SEARCH_TIMEOUT_MS = 60_000;
15
15
  const CRAWL_TIMEOUT_MS = 60_000;
16
16
 
17
17
  interface WebSearchConfig {
18
+ search1apiBaseUrl?: unknown;
18
19
  search1apiApiKey?: unknown;
19
20
  }
20
21
 
@@ -140,7 +141,7 @@ async function search1APIJsonRequest<T>(
140
141
  ): Promise<T> {
141
142
  let response: Response;
142
143
  try {
143
- response = await fetch(url, {
144
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("search1api", url, loadConfig().search1apiBaseUrl), {
144
145
  method: "POST",
145
146
  headers: {
146
147
  Authorization: `Bearer ${apiKey}`,
@@ -148,7 +149,7 @@ async function search1APIJsonRequest<T>(
148
149
  },
149
150
  body: JSON.stringify(body),
150
151
  signal: requestSignal(signal, timeoutMs),
151
- });
152
+ }, ["Authorization"]);
152
153
  } catch (err) {
153
154
  const message = errorMessage(err);
154
155
  const redactedMessage = redactCredential(message, apiKey);
@@ -5,7 +5,7 @@ import { hasCredentialSource, redactCredential, resolveCredential } from "./cred
5
5
  import type { SearchOptions, SearchResponse } from "./perplexity.ts";
6
6
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
7
7
  import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
8
- import { getWebSearchConfigPath } from "./utils.ts";
8
+ import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
9
9
 
10
10
  const SEARCHINFINITY_SEARCH_URL = "https://torchlight.byteintlapi.com/search_api/web_search";
11
11
  const CONFIG_PATH = getWebSearchConfigPath();
@@ -13,6 +13,7 @@ const CONFIG_PATH = getWebSearchConfigPath();
13
13
  const SEARCH_TIMEOUT_MS = 30_000;
14
14
 
15
15
  interface WebSearchConfig {
16
+ searchinfinityBaseUrl?: unknown;
16
17
  searchinfinityApiKey?: unknown;
17
18
  }
18
19
 
@@ -162,7 +163,7 @@ async function searchinfinityJsonRequest(
162
163
  ): Promise<SearchinfinitySearchResponse> {
163
164
  let response: Response;
164
165
  try {
165
- response = await fetch(SEARCHINFINITY_SEARCH_URL, {
166
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("searchinfinity", SEARCHINFINITY_SEARCH_URL, loadConfig().searchinfinityBaseUrl), {
166
167
  method: "POST",
167
168
  headers: {
168
169
  Authorization: `Bearer ${apiKey}`,
@@ -170,7 +171,7 @@ async function searchinfinityJsonRequest(
170
171
  },
171
172
  body: JSON.stringify(body),
172
173
  signal: requestSignal(signal, SEARCH_TIMEOUT_MS),
173
- });
174
+ }, ["Authorization"]);
174
175
  } catch (err) {
175
176
  const message = errorMessage(err);
176
177
  const redactedMessage = redactCredential(message, apiKey);
@@ -5,9 +5,9 @@ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
5
5
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
6
6
  import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
7
7
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
8
- import { getWebSearchConfigPath } from "./utils.ts";
8
+ import { fetchWithCredentialRedirects, getWebSearchConfigPath, resolveProviderApiUrl } from "./utils.ts";
9
9
 
10
- const SERPAPI_SEARCH_URL = "https://serpapi.com/search.json";
10
+ const SERPAPI_API_BASE_URL = "https://serpapi.com";
11
11
  const CONFIG_PATH = getWebSearchConfigPath();
12
12
  const SEARCH_TIMEOUT_MS = 60_000;
13
13
  const RECENCY_TBS: Record<NonNullable<SearchOptions["recencyFilter"]>, string> = {
@@ -19,6 +19,7 @@ const RECENCY_TBS: Record<NonNullable<SearchOptions["recencyFilter"]>, string> =
19
19
 
20
20
  interface WebSearchConfig {
21
21
  serpapiApiKey?: unknown;
22
+ serpapiBaseUrl?: unknown;
22
23
  }
23
24
 
24
25
  interface SerpApiOrganicResult {
@@ -130,11 +131,12 @@ export function isSerpApiAvailable(): boolean {
130
131
  }
131
132
 
132
133
  export async function searchWithSerpApi(query: string, options: SearchOptions = {}): Promise<SearchResponse> {
134
+ const apiUrl = resolveProviderApiUrl("serpapi", `${SERPAPI_API_BASE_URL}/search.json`, loadConfig().serpapiBaseUrl);
133
135
  const apiKey = await requireApiKey(options.signal);
134
136
  const numResults = normalizeSearchResultCount(options.numResults);
135
137
  const filters = parseDomainFilter(options.domainFilter);
136
138
  const requestCount = options.domainFilter?.length ? Math.min(20, numResults + 5) : numResults;
137
- const url = new URL(SERPAPI_SEARCH_URL);
139
+ const url = new URL(apiUrl);
138
140
  url.searchParams.set("engine", "google");
139
141
  url.searchParams.set("q", buildQuery(query, filters));
140
142
  url.searchParams.set("api_key", apiKey);
@@ -145,10 +147,10 @@ export async function searchWithSerpApi(query: string, options: SearchOptions =
145
147
  let response: Response;
146
148
  let entries: SerpApiOrganicResult[];
147
149
  try {
148
- response = await fetch(url, {
150
+ response = await fetchWithCredentialRedirects(url.toString(), {
149
151
  headers: { Accept: "application/json" },
150
152
  signal: options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal,
151
- });
153
+ }, [], ["api_key"]);
152
154
  if (!response.ok) {
153
155
  const errorText = await response.text();
154
156
  throw new Error(`SerpApi error ${response.status}: ${redactCredential(errorText, apiKey).slice(0, 300)}`);
@@ -4,7 +4,7 @@ import { normalizeDomain } from "./domain-filter-normalization.ts";
4
4
  import type { SearchOptions, SearchResponse } from "./perplexity.ts";
5
5
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
6
6
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
7
- import { getWebSearchConfigPath } from "./utils.ts";
7
+ import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
8
8
 
9
9
  const SERPBASE_API_URL = "https://api.serpbase.dev/google/search";
10
10
  const CONFIG_PATH = getWebSearchConfigPath();
@@ -17,6 +17,7 @@ const RECENCY_TBS: Record<string, string> = {
17
17
  };
18
18
 
19
19
  interface WebSearchConfig {
20
+ serpbaseBaseUrl?: unknown;
20
21
  serpbaseApiKey?: unknown;
21
22
  }
22
23
 
@@ -157,7 +158,7 @@ export async function searchWithSerpBase(query: string, options: SearchOptions =
157
158
  const apiKey = await requireApiKey(options.signal);
158
159
  const numResults = normalizeCount(options.numResults);
159
160
  const filters = parseDomainFilter(options.domainFilter);
160
- const url = new URL(SERPBASE_API_URL);
161
+ const url = new URL(resolveProviderApiUrl("serpbase", SERPBASE_API_URL, loadConfig().serpbaseBaseUrl));
161
162
  url.searchParams.set("q", buildQuery(query, filters));
162
163
  // SerpBase's Google Search endpoint authenticates with an `api_key` query parameter.
163
164
  url.searchParams.set("api_key", apiKey);
@@ -166,10 +167,10 @@ export async function searchWithSerpBase(query: string, options: SearchOptions =
166
167
  const activityId = activityMonitor.logStart({ type: "api", query });
167
168
  let response: Response;
168
169
  try {
169
- response = await fetch(url, {
170
+ response = await fetchWithCredentialRedirects(String(url), {
170
171
  headers: { Accept: "application/json" },
171
172
  signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS),
172
- });
173
+ }, [], ["api_key"]);
173
174
  } catch (err) {
174
175
  const message = errorMessage(err);
175
176
  const redactedMessage = redactCredential(message, apiKey);
@@ -5,7 +5,7 @@ import type { ExtractedContent } from "./extract.ts";
5
5
  import type { SearchOptions, SearchResponse } from "./perplexity.ts";
6
6
  import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
7
7
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
8
- import { getWebSearchConfigPath } from "./utils.ts";
8
+ import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
9
9
 
10
10
  const SERPDIVE_API_URL = "https://api.serpdive.com/v1/search";
11
11
  const CONFIG_PATH = getWebSearchConfigPath();
@@ -23,6 +23,7 @@ type SerpdiveModel = (typeof MODELS)[number];
23
23
  const DEFAULT_MODEL: SerpdiveModel = "krill";
24
24
 
25
25
  interface WebSearchConfig {
26
+ serpdiveBaseUrl?: unknown;
26
27
  serpdiveApiKey?: unknown;
27
28
  serpdiveModel?: unknown;
28
29
  }
@@ -231,7 +232,7 @@ export async function searchWithSerpdive(query: string, options: SerpdiveSearchO
231
232
  const activityId = activityMonitor.logStart({ type: "api", query });
232
233
  let response: Response;
233
234
  try {
234
- response = await fetch(SERPDIVE_API_URL, {
235
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("serpdive", SERPDIVE_API_URL, loadConfig().serpdiveBaseUrl), {
235
236
  method: "POST",
236
237
  headers: {
237
238
  "Authorization": `Bearer ${apiKey}`,
@@ -239,7 +240,7 @@ export async function searchWithSerpdive(query: string, options: SerpdiveSearchO
239
240
  },
240
241
  body: JSON.stringify(body),
241
242
  signal: requestSignal(options.signal),
242
- });
243
+ }, ["Authorization"]);
243
244
  } catch (err) {
244
245
  const message = errorMessage(err);
245
246
  const redactedMessage = redactCredential(message, apiKey);
@@ -5,9 +5,9 @@ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
5
5
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
6
6
  import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
7
7
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
8
- import { getWebSearchConfigPath } from "./utils.ts";
8
+ import { fetchWithCredentialRedirects, getWebSearchConfigPath, resolveProviderApiUrl } from "./utils.ts";
9
9
 
10
- const SERPER_SEARCH_URL = "https://google.serper.dev/search";
10
+ const SERPER_API_BASE_URL = "https://google.serper.dev";
11
11
  const CONFIG_PATH = getWebSearchConfigPath();
12
12
  const SEARCH_TIMEOUT_MS = 60_000;
13
13
  const RECENCY_TBS: Record<NonNullable<SearchOptions["recencyFilter"]>, string> = {
@@ -19,6 +19,7 @@ const RECENCY_TBS: Record<NonNullable<SearchOptions["recencyFilter"]>, string> =
19
19
 
20
20
  interface WebSearchConfig {
21
21
  serperApiKey?: unknown;
22
+ serperBaseUrl?: unknown;
22
23
  }
23
24
 
24
25
  interface SerperResult {
@@ -129,6 +130,7 @@ export function isSerperAvailable(): boolean {
129
130
  }
130
131
 
131
132
  export async function searchWithSerper(query: string, options: SearchOptions = {}): Promise<SearchResponse> {
133
+ const apiUrl = resolveProviderApiUrl("serper", `${SERPER_API_BASE_URL}/search`, loadConfig().serperBaseUrl);
132
134
  const apiKey = await requireApiKey(options.signal);
133
135
  const numResults = normalizeSearchResultCount(options.numResults);
134
136
  const filters = parseDomainFilter(options.domainFilter);
@@ -136,12 +138,12 @@ export async function searchWithSerper(query: string, options: SearchOptions = {
136
138
  const activityId = activityMonitor.logStart({ type: "api", query });
137
139
  let response: Response;
138
140
  try {
139
- response = await fetch(SERPER_SEARCH_URL, {
141
+ response = await fetchWithCredentialRedirects(apiUrl, {
140
142
  method: "POST",
141
143
  headers: { "X-API-KEY": apiKey, "Content-Type": "application/json", Accept: "application/json" },
142
144
  body: JSON.stringify({ q: buildQuery(query, filters), num: requestCount, ...(options.recencyFilter ? { tbs: RECENCY_TBS[options.recencyFilter] } : {}) }),
143
145
  signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS),
144
- });
146
+ }, ["X-API-KEY"]);
145
147
  } catch (err) {
146
148
  const message = errorMessage(err);
147
149
  const redactedMessage = redactCredential(message, apiKey);
@@ -5,7 +5,7 @@ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
5
5
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
6
6
  import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
7
7
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
8
- import { fetchWithCredentialRedirects, getWebSearchConfigPath } from "./utils.ts";
8
+ import { fetchWithCredentialRedirects, getWebSearchConfigPath, resolveProviderApiUrl } from "./utils.ts";
9
9
 
10
10
  const SERPLY_SEARCH_URL = "https://api.serply.io/v1/search";
11
11
  const CONFIG_PATH = getWebSearchConfigPath();
@@ -18,6 +18,7 @@ const RECENCY_TBS: Record<NonNullable<SearchOptions["recencyFilter"]>, string> =
18
18
  };
19
19
 
20
20
  interface WebSearchConfig {
21
+ serplyBaseUrl?: unknown;
21
22
  serplyApiKey?: unknown;
22
23
  }
23
24
 
@@ -129,7 +130,7 @@ export async function searchWithSerply(query: string, options: SearchOptions = {
129
130
  const numResults = normalizeSearchResultCount(options.numResults);
130
131
  const filters = parseDomainFilter(options.domainFilter);
131
132
  const requestCount = options.domainFilter?.length ? Math.min(20, numResults + 5) : numResults;
132
- const url = new URL(SERPLY_SEARCH_URL);
133
+ const url = new URL(resolveProviderApiUrl("serply", SERPLY_SEARCH_URL, loadConfig().serplyBaseUrl));
133
134
  url.searchParams.set("q", buildQuery(query, filters));
134
135
  url.searchParams.set("num", String(requestCount));
135
136
  if (options.recencyFilter) url.searchParams.set("tbs", RECENCY_TBS[options.recencyFilter]);
@@ -85,6 +85,25 @@ export function resolveApiBaseUrl(options: ApiBaseUrlOptions): string {
85
85
  return url.toString().replace(/\/+$/, "");
86
86
  }
87
87
 
88
+ // Other tools commonly set the bare OLLAMA_BASE_URL (a local Ollama server) and DEEPSEEK_BASE_URL
89
+ // (an OpenAI-compatible root ending in /v1), so these providers read PI_-prefixed names instead.
90
+ const PI_PREFIXED_ENVIRONMENT_STEMS = new Set(["ollama", "deepseek"]);
91
+
92
+ /** Resolve a provider's API root without dropping its endpoint path or a gateway prefix. */
93
+ export function resolveProviderApiUrl(configStem: string, defaultUrl: string, configuredValue: unknown): string {
94
+ const official = new URL(defaultUrl);
95
+ const environmentKey = (PI_PREFIXED_ENVIRONMENT_STEMS.has(configStem) ? "PI_" : "")
96
+ + configStem.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase() + "_BASE_URL";
97
+ const baseUrl = resolveApiBaseUrl({
98
+ configKey: configStem + "BaseUrl",
99
+ configuredValue,
100
+ defaultValue: official.origin,
101
+ environmentKey,
102
+ environmentValue: process.env[environmentKey],
103
+ });
104
+ return baseUrl + official.pathname + official.search;
105
+ }
106
+
88
107
  const API_REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
89
108
  const API_REQUEST_BODY_HEADERS = ["Content-Encoding", "Content-Language", "Content-Location", "Content-Type"];
90
109
  const MAX_API_REDIRECTS = 5;
@@ -93,8 +112,11 @@ export async function fetchWithCredentialRedirects(
93
112
  url: string,
94
113
  init: RequestInit,
95
114
  credentialHeaders: readonly string[],
115
+ credentialQueryParams: readonly string[] = [],
96
116
  ): Promise<Response> {
97
117
  let current = new URL(url);
118
+ const source = new URL(url);
119
+ for (const name of credentialQueryParams) source.searchParams.delete(name);
98
120
  let requestInit = init;
99
121
 
100
122
  for (let redirects = 0; ; redirects++) {
@@ -104,7 +126,7 @@ export async function fetchWithCredentialRedirects(
104
126
  const location = response.headers.get("location");
105
127
  if (!location) return response;
106
128
  if (redirects === MAX_API_REDIRECTS) {
107
- throw new Error(`Too many API redirects from ${url}`);
129
+ throw new Error(`Too many API redirects from ${source}`);
108
130
  }
109
131
 
110
132
  const next = new URL(location, current);
@@ -122,6 +144,7 @@ export async function fetchWithCredentialRedirects(
122
144
  requestInit = { ...withoutBody, method: "GET", headers };
123
145
  }
124
146
  if (next.origin !== current.origin) {
147
+ for (const name of credentialQueryParams) next.searchParams.delete(name);
125
148
  const headers = new Headers(requestInit.headers);
126
149
  for (const name of credentialHeaders) headers.delete(name);
127
150
  requestInit = { ...requestInit, headers };
@@ -6,7 +6,7 @@ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
6
6
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
7
7
  import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
8
8
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
9
- import { getWebSearchConfigPath } from "./utils.ts";
9
+ import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
10
10
 
11
11
  const VALYU_SEARCH_URL = "https://api.valyu.ai/v1/search";
12
12
  const CONFIG_PATH = getWebSearchConfigPath();
@@ -15,6 +15,7 @@ const MAX_SNIPPET_CHARS = 2_500;
15
15
  const MAX_CONTENT_CHARS = 4_000;
16
16
 
17
17
  interface WebSearchConfig {
18
+ valyuBaseUrl?: unknown;
18
19
  valyuApiKey?: unknown;
19
20
  }
20
21
 
@@ -123,12 +124,12 @@ export async function searchWithValyu(query: string, options: SearchOptions & {
123
124
  const activityId = activityMonitor.logStart({ type: "api", query });
124
125
  let response: Response;
125
126
  try {
126
- response = await fetch(VALYU_SEARCH_URL, {
127
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("valyu", VALYU_SEARCH_URL, loadConfig().valyuBaseUrl), {
127
128
  method: "POST",
128
129
  headers: { "x-api-key": apiKey, "Content-Type": "application/json", Accept: "application/json" },
129
130
  body: JSON.stringify({ query, max_num_results: numResults, ...mapDomainFilter(options.domainFilter), ...(startDate ? { start_date: startDate } : {}) }),
130
131
  signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS),
131
- });
132
+ }, ["x-api-key"]);
132
133
  } catch (err) {
133
134
  const message = errorMessage(err);
134
135
  const redactedMessage = redactCredential(message, apiKey);
@@ -64,6 +64,8 @@ export interface WebSearchConfig {
64
64
  valyuApiKey?: unknown;
65
65
  keenableApiKey?: unknown;
66
66
  ceramicApiKey?: unknown;
67
+ linkupApiKey?: unknown;
68
+ linkupDepth?: unknown;
67
69
  deepseekApiKey?: unknown;
68
70
  degoogBaseUrl?: unknown;
69
71
  degoogApiKey?: unknown;
@@ -771,6 +773,7 @@ export function createWebToolCore(host: WebToolCoreHost): WebToolCoreInstance {
771
773
  const allUrls: string[] = [];
772
774
  const allInlineContent: ExtractedContent[] = [];
773
775
  const resolvedProvider = resolveRequestedProvider(params.provider);
776
+ const providerFromConfig = (normalizeProviderInput(params.provider) ?? "auto") === "auto";
774
777
 
775
778
  const queryResponses = await runSearchQueries(queryList, async (query) => {
776
779
  signal?.throwIfAborted();
@@ -782,6 +785,7 @@ export function createWebToolCore(host: WebToolCoreHost): WebToolCoreInstance {
782
785
  try {
783
786
  const { answer, results, inlineContent, provider, providerResponses } = await search(query, {
784
787
  provider: resolvedProvider,
788
+ providerFromConfig,
785
789
  numResults: params.numResults,
786
790
  recencyFilter,
787
791
  domainFilter: params.domainFilter,
@@ -880,6 +884,7 @@ export function createWebToolCore(host: WebToolCoreHost): WebToolCoreInstance {
880
884
  try {
881
885
  const response = await search(query, {
882
886
  provider: resolveRequestedProvider(params.provider),
887
+ providerFromConfig: (normalizeProviderInput(params.provider) ?? "auto") === "auto",
883
888
  numResults,
884
889
  recencyFilter,
885
890
  domainFilter,