@herbertgao/pi-extensions 2026.10.11 → 2026.10.12

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 (214) hide show
  1. package/README.md +7 -7
  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-subagents/CHANGELOG.md +6 -0
  7. package/node_modules/@herbertgao/pi-subagents/package.json +1 -1
  8. package/node_modules/@herbertgao/pi-subagents/src/agent-color.ts +11 -2
  9. package/node_modules/@herbertgao/pi-subagents/src/index.ts +10 -5
  10. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +3 -2
  11. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +1 -1
  12. package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +1 -0
  13. package/node_modules/@herbertgao/sol-pi/README.md +1 -1
  14. package/node_modules/@herbertgao/sol-pi/agents-install.md +2 -2
  15. package/node_modules/@narumitw/pi-btw/README.md +14 -5
  16. package/node_modules/@narumitw/pi-btw/dist/index.ts +1067 -560
  17. package/node_modules/@narumitw/pi-btw/dist/index.ts.map +4 -4
  18. package/node_modules/@narumitw/pi-btw/docs/core-alignment.md +277 -0
  19. package/node_modules/@narumitw/pi-btw/docs/native-appearance.md +857 -0
  20. package/node_modules/@narumitw/pi-btw/docs/workflows.md +34 -13
  21. package/node_modules/@narumitw/pi-btw/package.json +4 -4
  22. package/node_modules/@narumitw/pi-btw/src/btw.ts +152 -108
  23. package/node_modules/@narumitw/pi-btw/src/conversation-chrome.ts +93 -0
  24. package/node_modules/@narumitw/pi-btw/src/fullscreen-renderer.ts +329 -0
  25. package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +109 -315
  26. package/node_modules/@narumitw/pi-btw/src/keybindings.ts +100 -22
  27. package/node_modules/@narumitw/pi-btw/src/menu.ts +42 -27
  28. package/node_modules/@narumitw/pi-btw/src/session-lifetime.ts +66 -0
  29. package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +366 -164
  30. package/node_modules/@narumitw/pi-btw/src/workspace-layout.ts +96 -36
  31. package/node_modules/pi-lens/CHANGELOG.md +281 -0
  32. package/node_modules/pi-lens/README.md +13 -1
  33. package/node_modules/pi-lens/dist/{chunk-SS36ZX4J.js → chunk-24AKHFGP.js} +6 -6
  34. package/node_modules/pi-lens/dist/{chunk-JSQFTSC6.js → chunk-2FN63LPV.js} +11 -11
  35. package/node_modules/pi-lens/dist/{chunk-5UCAH366.js → chunk-2KXTHF3M.js} +20 -20
  36. package/node_modules/pi-lens/dist/{chunk-EU63SDCG.js → chunk-3DA2JDOL.js} +367 -281
  37. package/node_modules/pi-lens/dist/{chunk-RWWYJ623.js → chunk-3KAZU3VR.js} +1 -1
  38. package/node_modules/pi-lens/dist/chunk-3PTHXJXR.js +28 -0
  39. package/node_modules/pi-lens/dist/chunk-3QED2P4V.js +31 -0
  40. package/node_modules/pi-lens/dist/{chunk-N2H3ZPZY.js → chunk-3RKP3FMS.js} +1 -0
  41. package/node_modules/pi-lens/dist/{chunk-XVF2VVXP.js → chunk-5HSRT26B.js} +2 -2
  42. package/node_modules/pi-lens/dist/{chunk-MXGY6KPT.js → chunk-5IUSNGOC.js} +15 -15
  43. package/node_modules/pi-lens/dist/{chunk-EJIUXPBX.js → chunk-5OFV52AM.js} +1 -1
  44. package/node_modules/pi-lens/dist/{chunk-AW7R2GWG.js → chunk-5VSF4UUQ.js} +12 -7
  45. package/node_modules/pi-lens/dist/{chunk-6STA6Z7I.js → chunk-5WRPDP2A.js} +18 -18
  46. package/node_modules/pi-lens/dist/{chunk-YIUAVF7E.js → chunk-6DLWKFEX.js} +35 -34
  47. package/node_modules/pi-lens/dist/{chunk-WOA4LN2R.js → chunk-7D6L4MTX.js} +2 -2
  48. package/node_modules/pi-lens/dist/{chunk-GAEGEPOC.js → chunk-7HXE67BN.js} +2 -2
  49. package/node_modules/pi-lens/dist/chunk-AGSS7277.js +84 -0
  50. package/node_modules/pi-lens/dist/{chunk-R3PCY3YS.js → chunk-AMERCH6V.js} +13 -13
  51. package/node_modules/pi-lens/dist/{chunk-WU567RSC.js → chunk-ATKJFDQN.js} +14 -10
  52. package/node_modules/pi-lens/dist/{chunk-VSSBEUFT.js → chunk-AWSCPCN2.js} +16 -16
  53. package/node_modules/pi-lens/dist/{chunk-VCHXCQFG.js → chunk-BWD5EPKO.js} +3 -3
  54. package/node_modules/pi-lens/dist/{chunk-H6MF6EVN.js → chunk-CT4MN5IU.js} +1200 -230
  55. package/node_modules/pi-lens/dist/{chunk-FCSOVF55.js → chunk-CUHSHSB6.js} +6 -6
  56. package/node_modules/pi-lens/dist/{chunk-CHOW74WE.js → chunk-CYRKQRPM.js} +7 -10
  57. package/node_modules/pi-lens/dist/{chunk-Q7DUK4LX.js → chunk-DEL2U6CM.js} +5 -5
  58. package/node_modules/pi-lens/dist/{chunk-6C7JWPCP.js → chunk-DGUKIYSI.js} +26 -23
  59. package/node_modules/pi-lens/dist/{chunk-PHDMFAKM.js → chunk-DUO2TU77.js} +2 -2
  60. package/node_modules/pi-lens/dist/{chunk-MRXKYPCS.js → chunk-EBC36LNN.js} +2 -2
  61. package/node_modules/pi-lens/dist/{chunk-CSHFH5IN.js → chunk-ED36RF6Y.js} +1 -1
  62. package/node_modules/pi-lens/dist/{chunk-76MWC2K6.js → chunk-EUXZEFTV.js} +90 -97
  63. package/node_modules/pi-lens/dist/{chunk-QOZXJ4NA.js → chunk-FM4RDMKT.js} +11 -8
  64. package/node_modules/pi-lens/dist/{chunk-ACXEQZOU.js → chunk-GAQ7OQG6.js} +31 -28
  65. package/node_modules/pi-lens/dist/{chunk-XAGLWMJ4.js → chunk-GL5LUMZE.js} +23 -23
  66. package/node_modules/pi-lens/dist/{chunk-BKE7E7TC.js → chunk-GMX5OS7B.js} +9 -9
  67. package/node_modules/pi-lens/dist/{chunk-ZHFZWTZV.js → chunk-GSLNCYGG.js} +11 -11
  68. package/node_modules/pi-lens/dist/{chunk-3W7IEVVL.js → chunk-GSM5UU7A.js} +26 -34
  69. package/node_modules/pi-lens/dist/{chunk-724UL2TJ.js → chunk-GXFV6MYU.js} +3 -3
  70. package/node_modules/pi-lens/dist/chunk-HAD7QRQI.js +30 -0
  71. package/node_modules/pi-lens/dist/{chunk-QOBUHWHX.js → chunk-HRNHZA3N.js} +6 -6
  72. package/node_modules/pi-lens/dist/{chunk-VWCXW2E7.js → chunk-HWCCCQNX.js} +1 -1
  73. package/node_modules/pi-lens/dist/{chunk-7DYBLXYA.js → chunk-HYGZEMX6.js} +3 -3
  74. package/node_modules/pi-lens/dist/chunk-IJYGIDF4.js +186 -0
  75. package/node_modules/pi-lens/dist/{chunk-4W4VLAPJ.js → chunk-IQWN5JCP.js} +11 -11
  76. package/node_modules/pi-lens/dist/{chunk-SQ4TVJBR.js → chunk-IUE7SSKV.js} +7 -7
  77. package/node_modules/pi-lens/dist/{chunk-IBGIOBEE.js → chunk-IWDLU6K3.js} +68 -5
  78. package/node_modules/pi-lens/dist/{chunk-XCJN5IJU.js → chunk-IYNJ6YPZ.js} +4 -4
  79. package/node_modules/pi-lens/dist/{chunk-JAU72XNY.js → chunk-J64T55EI.js} +3 -3
  80. package/node_modules/pi-lens/dist/{chunk-2BBLFX75.js → chunk-J6MPGQTS.js} +5 -5
  81. package/node_modules/pi-lens/dist/chunk-JORED7EX.js +44 -0
  82. package/node_modules/pi-lens/dist/{chunk-6SDEP3AJ.js → chunk-JUKMK5Y4.js} +8 -8
  83. package/node_modules/pi-lens/dist/{chunk-FMSO6RDZ.js → chunk-JW3YWBVB.js} +15 -15
  84. package/node_modules/pi-lens/dist/{chunk-L3BLXZG7.js → chunk-KAPJINKN.js} +30 -69
  85. package/node_modules/pi-lens/dist/{chunk-2B73ZPOK.js → chunk-KN35K52N.js} +3 -3
  86. package/node_modules/pi-lens/dist/{chunk-C34ZXZ7O.js → chunk-KUA4OJ5Y.js} +24 -11
  87. package/node_modules/pi-lens/dist/chunk-KYUB6QDC.js +72 -0
  88. package/node_modules/pi-lens/dist/{chunk-67WMNWEE.js → chunk-LLJNQKQW.js} +12 -10
  89. package/node_modules/pi-lens/dist/chunk-LZSEQW6A.js +57 -0
  90. package/node_modules/pi-lens/dist/{chunk-ZANLILYD.js → chunk-M2IFVFWU.js} +2 -2
  91. package/node_modules/pi-lens/dist/chunk-M2UD3LPU.js +88 -0
  92. package/node_modules/pi-lens/dist/{chunk-XIJZVPD5.js → chunk-MBKQHGA7.js} +15 -15
  93. package/node_modules/pi-lens/dist/{chunk-P7266HLM.js → chunk-MPNJLASA.js} +2 -2
  94. package/node_modules/pi-lens/dist/{chunk-6GFRNVYR.js → chunk-MZGQNL3Y.js} +10 -10
  95. package/node_modules/pi-lens/dist/{chunk-ZWFS3OEF.js → chunk-N5FLEO7W.js} +33 -32
  96. package/node_modules/pi-lens/dist/{chunk-3JNKMP3B.js → chunk-O4NWQT6I.js} +4 -4
  97. package/node_modules/pi-lens/dist/{chunk-T6CPIZNT.js → chunk-OHKJ7PQF.js} +33 -32
  98. package/node_modules/pi-lens/dist/{chunk-VRZP76YM.js → chunk-P63GXC37.js} +4 -1
  99. package/node_modules/pi-lens/dist/{chunk-XTMJ7XDT.js → chunk-POMLXPMY.js} +1 -1
  100. package/node_modules/pi-lens/dist/{chunk-QQNQ7SJW.js → chunk-QBFBRV2B.js} +10 -4
  101. package/node_modules/pi-lens/dist/{chunk-CMMHNUZ2.js → chunk-R3T7CLQ2.js} +60 -38
  102. package/node_modules/pi-lens/dist/{chunk-23WOO7TX.js → chunk-R7YOCSNV.js} +10 -10
  103. package/node_modules/pi-lens/dist/{chunk-2CD5RS6M.js → chunk-RKBXZN3A.js} +23 -2
  104. package/node_modules/pi-lens/dist/{chunk-OCAGUNBC.js → chunk-RKKOYPRA.js} +12 -12
  105. package/node_modules/pi-lens/dist/{chunk-52FUZI6K.js → chunk-RMLC67LF.js} +1 -1
  106. package/node_modules/pi-lens/dist/{chunk-XMSXXAHW.js → chunk-ROYSX2S5.js} +2 -2
  107. package/node_modules/pi-lens/dist/{chunk-M6HSLBWY.js → chunk-RVK72CZX.js} +6507 -7514
  108. package/node_modules/pi-lens/dist/{chunk-FLKWCIZH.js → chunk-S2HEXIWI.js} +5 -5
  109. package/node_modules/pi-lens/dist/{chunk-UZ3TUTRV.js → chunk-S67KYG37.js} +1 -1
  110. package/node_modules/pi-lens/dist/{chunk-VCO24T4L.js → chunk-SD4I7ZO4.js} +14 -14
  111. package/node_modules/pi-lens/dist/{chunk-Z527N6YQ.js → chunk-SKAMFC7A.js} +12 -12
  112. package/node_modules/pi-lens/dist/{chunk-MQLUAEOC.js → chunk-SRYEJNES.js} +2 -2
  113. package/node_modules/pi-lens/dist/{chunk-BRGDSBJE.js → chunk-SYE6T2EB.js} +12 -12
  114. package/node_modules/pi-lens/dist/{chunk-GXW6K4YJ.js → chunk-T57LYLZT.js} +1 -1
  115. package/node_modules/pi-lens/dist/{chunk-ZXYDQ3TZ.js → chunk-T7FEBKXN.js} +48 -15
  116. package/node_modules/pi-lens/dist/{chunk-3EFKIGZN.js → chunk-TIQ2PKDW.js} +3 -3
  117. package/node_modules/pi-lens/dist/{chunk-QILIYSJF.js → chunk-TLX72JTG.js} +1 -1
  118. package/node_modules/pi-lens/dist/{chunk-TYM6OUIT.js → chunk-TOY6QKOH.js} +12 -12
  119. package/node_modules/pi-lens/dist/{chunk-IZSHAIJ7.js → chunk-TRETHTQO.js} +12 -12
  120. package/node_modules/pi-lens/dist/{chunk-3VPVG5SU.js → chunk-U44DJXQP.js} +10 -6
  121. package/node_modules/pi-lens/dist/{chunk-PNQDPDRC.js → chunk-UA7ZXYDR.js} +1 -1
  122. package/node_modules/pi-lens/dist/{chunk-OXXKQCSV.js → chunk-UBOQLVT2.js} +4 -4
  123. package/node_modules/pi-lens/dist/{chunk-QGQ5CCCG.js → chunk-UMS2MFPZ.js} +2 -2
  124. package/node_modules/pi-lens/dist/{chunk-QHJ6DQ2R.js → chunk-US7ECLD7.js} +55 -13
  125. package/node_modules/pi-lens/dist/{chunk-AB3YYG6N.js → chunk-UZ2XCLYS.js} +8 -8
  126. package/node_modules/pi-lens/dist/chunk-V35JG4JB.js +2667 -0
  127. package/node_modules/pi-lens/dist/{chunk-N3X6Q4YT.js → chunk-VOOAPROD.js} +3 -3
  128. package/node_modules/pi-lens/dist/{chunk-SAEFPSB6.js → chunk-W66O5E25.js} +21 -11
  129. package/node_modules/pi-lens/dist/{chunk-KBG47GHP.js → chunk-WMYE35PX.js} +15 -11
  130. package/node_modules/pi-lens/dist/{chunk-5NGR67U5.js → chunk-XBJVAEEO.js} +32 -5
  131. package/node_modules/pi-lens/dist/{chunk-YYOIQFRS.js → chunk-XHJBS436.js} +122 -44
  132. package/node_modules/pi-lens/dist/{chunk-GBPP5P7X.js → chunk-XTBDCR27.js} +4 -4
  133. package/node_modules/pi-lens/dist/{chunk-4UNXBNE2.js → chunk-XTFDJI3T.js} +11 -11
  134. package/node_modules/pi-lens/dist/{chunk-UXGETRP4.js → chunk-XYURS6EN.js} +13 -12
  135. package/node_modules/pi-lens/dist/{chunk-RPLINGVB.js → chunk-Y6GZHWSJ.js} +6 -6
  136. package/node_modules/pi-lens/dist/{chunk-2VUQMUMT.js → chunk-YCWYO6TQ.js} +41 -38
  137. package/node_modules/pi-lens/dist/{chunk-77M37OKR.js → chunk-YH5MVY2U.js} +7 -7
  138. package/node_modules/pi-lens/dist/{chunk-AOHZU2BM.js → chunk-YNE3RP52.js} +1 -1
  139. package/node_modules/pi-lens/dist/{chunk-YSZNHOBY.js → chunk-ZHH37KZL.js} +12 -12
  140. package/node_modules/pi-lens/dist/{chunk-ZGDGW2V3.js → chunk-ZIVJBOO3.js} +2 -2
  141. package/node_modules/pi-lens/dist/{chunk-RXCOMYPY.js → chunk-ZVUL7QYY.js} +29 -28
  142. package/node_modules/pi-lens/dist/index.js +11052 -5852
  143. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +10 -9
  144. package/node_modules/pi-lens/dist/mcp/cli.js +41 -38
  145. package/node_modules/pi-lens/dist/mcp/server.js +1120 -474
  146. package/node_modules/pi-lens/dist/mcp/worker.js +61 -58
  147. package/node_modules/pi-lens/dist/probes/installer.js +19 -19
  148. package/node_modules/pi-lens/dist/workers/project-snapshot-persist-worker.js +28 -9
  149. package/node_modules/pi-lens/dist/workers/review-graph-persist-worker.js +1 -1
  150. package/node_modules/pi-lens/docs/configuration.md +11 -0
  151. package/node_modules/pi-lens/docs/engineering-principles.md +32 -0
  152. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +1 -1
  153. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +15 -26
  154. package/node_modules/pi-lens/docs/pi-lens-fixer.md +117 -13
  155. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +97 -7
  156. package/node_modules/pi-lens/docs/pi-lens-monitor.md +8 -2
  157. package/node_modules/pi-lens/docs/pi-lens-retro.md +4 -1
  158. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +112 -4
  159. package/node_modules/pi-lens/docs/pi-lens-subagent.md +22 -14
  160. package/node_modules/pi-lens/docs/release-qa-baseline.md +3 -1
  161. package/node_modules/pi-lens/docs/servercapabilities.md +9 -19
  162. package/node_modules/pi-lens/package.json +7 -5
  163. package/node_modules/pi-lens/scripts/download-grammars.js +40 -7
  164. package/node_modules/pi-lens/scripts/lib/latency-log-phases.mjs +95 -0
  165. package/node_modules/pi-lens/scripts/rpc-load-check.mjs +570 -81
  166. package/node_modules/pi-provider-qoder/dist/index.js +323 -154
  167. package/node_modules/pi-provider-qoder/package.json +1 -1
  168. package/node_modules/pi-web-access/CHANGELOG.md +39 -0
  169. package/node_modules/pi-web-access/README.md +83 -12
  170. package/node_modules/pi-web-access/anysearch.ts +4 -3
  171. package/node_modules/pi-web-access/bocha.ts +4 -3
  172. package/node_modules/pi-web-access/brightdata-unlocker.ts +3 -2
  173. package/node_modules/pi-web-access/brightdata.ts +4 -3
  174. package/node_modules/pi-web-access/ceramic.ts +3 -2
  175. package/node_modules/pi-web-access/curator-page.ts +3 -1
  176. package/node_modules/pi-web-access/curator-server.ts +1 -0
  177. package/node_modules/pi-web-access/deepseek.ts +179 -6
  178. package/node_modules/pi-web-access/dist/index.js +1118 -688
  179. package/node_modules/pi-web-access/dist/mcp-cli.js +1081 -667
  180. package/node_modules/pi-web-access/extract.ts +58 -6
  181. package/node_modules/pi-web-access/gemini-search.ts +29 -6
  182. package/node_modules/pi-web-access/index.ts +20 -3
  183. package/node_modules/pi-web-access/jina-search.ts +6 -4
  184. package/node_modules/pi-web-access/kagi.ts +5 -4
  185. package/node_modules/pi-web-access/keenable.ts +3 -2
  186. package/node_modules/pi-web-access/linkup.ts +170 -0
  187. package/node_modules/pi-web-access/mistral-search.ts +4 -3
  188. package/node_modules/pi-web-access/ollama.ts +5 -4
  189. package/node_modules/pi-web-access/package.json +1 -1
  190. package/node_modules/pi-web-access/parallel.ts +7 -7
  191. package/node_modules/pi-web-access/perplexity.ts +5 -3
  192. package/node_modules/pi-web-access/querit.ts +4 -3
  193. package/node_modules/pi-web-access/search1api.ts +4 -3
  194. package/node_modules/pi-web-access/searchinfinity.ts +4 -3
  195. package/node_modules/pi-web-access/serpapi.ts +7 -5
  196. package/node_modules/pi-web-access/serpbase.ts +5 -4
  197. package/node_modules/pi-web-access/serpdive.ts +4 -3
  198. package/node_modules/pi-web-access/serper.ts +6 -4
  199. package/node_modules/pi-web-access/serply.ts +3 -2
  200. package/node_modules/pi-web-access/utils.ts +24 -1
  201. package/node_modules/pi-web-access/valyu.ts +4 -3
  202. package/node_modules/pi-web-access/web-tool-core.ts +5 -0
  203. package/node_modules/pi-web-access/xai-search.ts +49 -7
  204. package/node_modules/pi-web-access/xcrawl.ts +4 -3
  205. package/node_modules/pi-web-access/you.ts +3 -2
  206. package/package.json +9 -9
  207. package/node_modules/pi-lens/dist/chunk-3YN6V5TV.js +0 -85
  208. package/node_modules/pi-lens/dist/chunk-466Z26MG.js +0 -30
  209. package/node_modules/pi-lens/dist/chunk-EC47DWFA.js +0 -56
  210. package/node_modules/pi-lens/dist/chunk-KDERNTCQ.js +0 -28
  211. package/node_modules/pi-lens/dist/chunk-KSX3TXSZ.js +0 -69
  212. package/node_modules/pi-lens/dist/chunk-LOP6GRPH.js +0 -31
  213. package/node_modules/pi-lens/dist/chunk-UOPVJQ4N.js +0 -103
  214. /package/node_modules/pi-lens/dist/{chunk-FC4RP4I2.js → chunk-6HWVI6MI.js} +0 -0
@@ -1,15 +1,19 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { activityMonitor } from "./activity.ts";
3
3
  import { normalizeDomain } from "./domain-filter-normalization.ts";
4
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
4
5
  import type { SearchOptions, SearchResponse } from "./perplexity.ts";
5
6
  import { formatSearchResultsAsAnswer } from "./search-answer-formatting.ts";
6
7
  import { normalizeSearchResultCount } from "./search-result-count-normalization.ts";
7
8
  import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
8
- import { fetchWithCredentialRedirects, getWebSearchConfigPath } from "./utils.ts";
9
+ import { loadFetchContentDomainPolicy, loadSsrfConfig, validateRemoteUrl } from "./ssrf-protection.ts";
10
+ import { fetchWithCredentialRedirects, getWebSearchConfigPath, resolveProviderApiUrl } from "./utils.ts";
9
11
 
10
12
  const DEEPSEEK_SEARCH_URL = "https://api.deepseek.com/v1/tools/search";
13
+ const DEEPSEEK_FETCH_URL = "https://api.deepseek.com/v1/tools/fetch";
11
14
  const CONFIG_PATH = getWebSearchConfigPath();
12
15
  const SEARCH_TIMEOUT_MS = 30_000;
16
+ const FETCH_TIMEOUT_MS = 60_000;
13
17
  // The API rejects queries over 128 Unicode characters, operators included.
14
18
  const MAX_QUERY_CHARS = 128;
15
19
  // `summary` is documented as 600-800 characters and written for models; keep it whole.
@@ -22,6 +26,7 @@ const RECENCY_DAYS: Record<NonNullable<SearchOptions["recencyFilter"]>, number>
22
26
  };
23
27
 
24
28
  interface WebSearchConfig {
29
+ deepseekBaseUrl?: unknown;
25
30
  deepseekApiKey?: unknown;
26
31
  }
27
32
 
@@ -30,6 +35,11 @@ interface DeepSeekResult {
30
35
  url?: unknown;
31
36
  snippet?: unknown;
32
37
  summary?: unknown;
38
+ content?: unknown;
39
+ }
40
+
41
+ interface DeepSeekSearchOptions extends SearchOptions {
42
+ includeContent?: boolean;
33
43
  }
34
44
 
35
45
  let cachedConfig: WebSearchConfig | null = null;
@@ -106,6 +116,83 @@ function errorMessage(err: unknown): string {
106
116
  return err instanceof Error ? err.message : String(err);
107
117
  }
108
118
 
119
+ // DeepSeek Fetch escapes Markdown punctuation even when the content is already Markdown.
120
+ // Keep escapes that could change emphasis, code spans and links; unescape only the safe subset.
121
+ function unescapeMarkdownSegment(segment: string): string {
122
+ return segment.replace(/\\([/.,:()&+#>|!_\-"'])/g, (match, char: string, offset: number, whole: string) => {
123
+ if (char === "!" && whole[offset + 2] === "[") return match;
124
+ return char;
125
+ });
126
+ }
127
+
128
+ function normalizeInlineMarkdown(line: string): string {
129
+ return line
130
+ .split(/(`+[^`]*`+)/g)
131
+ .map((part, index) => (index % 2 === 0 ? unescapeMarkdownSegment(part) : part))
132
+ .join("");
133
+ }
134
+
135
+ function normalizeDeepSeekMarkdown(markdown: string): string {
136
+ let fence: { char: string; length: number } | null = null;
137
+ return markdown
138
+ .split("\n")
139
+ .map((line) => {
140
+ const match = line.match(/^\s{0,3}(`{3,}|~{3,})/);
141
+ if (match) {
142
+ const marker = match[1]!;
143
+ if (fence === null) {
144
+ fence = { char: marker[0]!, length: marker.length };
145
+ } else if (
146
+ marker[0] === fence.char &&
147
+ marker.length >= fence.length &&
148
+ line.slice(match[0].length).trim() === ""
149
+ ) {
150
+ fence = null;
151
+ }
152
+ return line;
153
+ }
154
+ return fence === null ? normalizeInlineMarkdown(line) : line;
155
+ })
156
+ .join("\n");
157
+ }
158
+
159
+ const ERROR_TITLE = /^(?:404\b|page not found\b|not found\b)/i;
160
+
161
+ function firstMarkdownHeading(content: string): string {
162
+ let fence: { char: string; length: number } | null = null;
163
+ for (const line of content.split("\n")) {
164
+ const fenceMatch = line.match(/^\s{0,3}(`{3,}|~{3,})/);
165
+ if (fenceMatch) {
166
+ const marker = fenceMatch[1]!;
167
+ if (fence === null) {
168
+ fence = { char: marker[0]!, length: marker.length };
169
+ } else if (
170
+ marker[0] === fence.char &&
171
+ marker.length >= fence.length &&
172
+ line.slice(fenceMatch[0].length).trim() === ""
173
+ ) {
174
+ fence = null;
175
+ }
176
+ continue;
177
+ }
178
+ if (fence !== null) continue;
179
+ const heading = line.match(/^\s{0,3}#{1,6}\s+(.+?)\s*#*\s*$/);
180
+ if (heading) return heading[1]!.trim();
181
+ }
182
+ return "";
183
+ }
184
+
185
+ // A site-level 404 can still return 200 + a short navigation shell. Do not reject
186
+ // short pages generally: some valid pages are shorter than MIN_USEFUL_CONTENT.
187
+ // A title alone is not enough: "404 Not Found - HTTP" can be a real article.
188
+ function isUnusableDeepSeekPage(title: string, content: string): boolean {
189
+ // Long pages are real content even if their title or first heading happens to be an error term.
190
+ if (content.length >= 500) return false;
191
+ const heading = firstMarkdownHeading(content);
192
+ if (heading !== "" && ERROR_TITLE.test(heading)) return true;
193
+ return ERROR_TITLE.test(text(title)) && /\b(?:404|page not found|not found)\b/i.test(content.slice(0, 200));
194
+ }
195
+
109
196
  function parseResponse(value: unknown): DeepSeekResult[] {
110
197
  const results = value && typeof value === "object" && !Array.isArray(value) ? (value as Record<string, unknown>).results : undefined;
111
198
  if (!Array.isArray(results)) throw new Error("DeepSeek returned invalid response: expected a results array");
@@ -126,7 +213,7 @@ export function isDeepSeekAvailable(): boolean {
126
213
  return hasCredentialSource({ provider: "DeepSeek", configuredValue: loadConfig().deepseekApiKey, environmentValue: process.env.DEEPSEEK_API_KEY });
127
214
  }
128
215
 
129
- export async function searchWithDeepSeek(query: string, options: SearchOptions = {}): Promise<SearchResponse> {
216
+ export async function searchWithDeepSeek(query: string, options: DeepSeekSearchOptions = {}): Promise<SearchResponse> {
130
217
  const builtQuery = buildQuery(query, options);
131
218
  const apiKey = await requireApiKey(options.signal);
132
219
  const numResults = normalizeSearchResultCount(options.numResults);
@@ -135,14 +222,14 @@ export async function searchWithDeepSeek(query: string, options: SearchOptions =
135
222
  let response: Response;
136
223
  let entries: DeepSeekResult[];
137
224
  try {
138
- response = await fetchWithCredentialRedirects(DEEPSEEK_SEARCH_URL, {
225
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("deepseek", DEEPSEEK_SEARCH_URL, loadConfig().deepseekBaseUrl), {
139
226
  method: "POST",
140
227
  headers: {
141
228
  Accept: "application/json",
142
229
  "Content-Type": "application/json",
143
230
  Authorization: `Bearer ${apiKey}`,
144
231
  },
145
- body: JSON.stringify({ query: builtQuery, count: numResults }),
232
+ body: JSON.stringify({ query: builtQuery, count: numResults, ...(options.includeContent ? { need_content: true } : {}) }),
146
233
  signal: options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal,
147
234
  }, ["Authorization"]);
148
235
  if (!response.ok) {
@@ -178,6 +265,7 @@ export async function searchWithDeepSeek(query: string, options: SearchOptions =
178
265
  }
179
266
  activityMonitor.logComplete(activityId, response.status);
180
267
  const results: SearchResponse["results"] = [];
268
+ const inlineContent: ExtractedContent[] = [];
181
269
  const seen = new Set<string>();
182
270
  for (const entry of entries) {
183
271
  if (!entry || typeof entry !== "object") continue;
@@ -191,14 +279,99 @@ export async function searchWithDeepSeek(query: string, options: SearchOptions =
191
279
  if (resultUrl.protocol !== "http:" && resultUrl.protocol !== "https:") continue;
192
280
  if (seen.has(resultUrl.href)) continue;
193
281
  seen.add(resultUrl.href);
282
+ const title = text(entry.title) || `Source ${results.length + 1}`;
194
283
  results.push({
195
- title: text(entry.title) || `Source ${results.length + 1}`,
284
+ title,
196
285
  url: resultUrl.href,
197
286
  snippet: (text(entry.summary) || text(entry.snippet)).slice(0, MAX_SNIPPET_CHARS),
198
287
  });
288
+ if (options.includeContent) {
289
+ // Search content is not pre-escaped (unlike Fetch), so its backslashes are real text.
290
+ const content = typeof entry.content === "string" ? entry.content.trim() : "";
291
+ if (content) inlineContent.push({ url: resultUrl.href, title, content, error: null });
292
+ }
199
293
  if (results.length >= numResults) break;
200
294
  }
201
295
  // A non-empty page with no usable entry is a broken response, not "no results", so routing can fall back.
202
296
  if (entries.length > 0 && results.length === 0) throw new Error("DeepSeek returned invalid response: no result had an http(s) URL");
203
- return { answer: formatSearchResultsAsAnswer(results), results };
297
+ const searchResponse: SearchResponse = { answer: formatSearchResultsAsAnswer(results), results };
298
+ if (inlineContent.length > 0) searchResponse.inlineContent = inlineContent;
299
+ return searchResponse;
300
+ }
301
+
302
+ /**
303
+ * Fetch a single page through DeepSeek's Fetch API, which returns page content
304
+ * already converted to Markdown. Opt-in via `fetchRouting.providers`.
305
+ */
306
+ export async function extractWithDeepSeek(
307
+ url: string,
308
+ signal?: AbortSignal,
309
+ options: ExtractOptions = {},
310
+ ): Promise<ExtractedContent | null> {
311
+ const apiKey = await requireApiKey(signal);
312
+ const activityId = activityMonitor.logStart({ type: "fetch", url });
313
+ const timeoutMs = options.timeoutMs ?? FETCH_TIMEOUT_MS;
314
+ const timeoutSignal = AbortSignal.timeout(timeoutMs);
315
+ try {
316
+ const ssrf = loadSsrfConfig();
317
+ await validateRemoteUrl(url, {
318
+ allowRanges: ssrf.allowRanges,
319
+ trustEnvProxy: ssrf.trustEnvProxy,
320
+ domainPolicy: loadFetchContentDomainPolicy(),
321
+ ...(options.lookup ? { lookup: options.lookup } : {}),
322
+ });
323
+ const response = await fetchWithCredentialRedirects(resolveProviderApiUrl("deepseek", DEEPSEEK_FETCH_URL, loadConfig().deepseekBaseUrl), {
324
+ method: "POST",
325
+ headers: {
326
+ Accept: "application/json",
327
+ "Content-Type": "application/json",
328
+ Authorization: `Bearer ${apiKey}`,
329
+ },
330
+ body: JSON.stringify({ url }),
331
+ signal: signal ? AbortSignal.any([timeoutSignal, signal]) : timeoutSignal,
332
+ }, ["Authorization"]);
333
+ if (!response.ok) {
334
+ const errorText = redactCredential(describeError(await response.text()), apiKey).slice(0, 300);
335
+ throw new Error(`DeepSeek Fetch error ${response.status}: ${errorText}`);
336
+ }
337
+ let rawData: unknown;
338
+ try {
339
+ rawData = await response.json();
340
+ } catch (err) {
341
+ if (err instanceof Error && err.name === "TimeoutError") throw err;
342
+ throw new Error(`DeepSeek Fetch returned invalid JSON: ${errorMessage(err)}`);
343
+ }
344
+ if (!rawData || typeof rawData !== "object" || Array.isArray(rawData)) {
345
+ throw new Error("DeepSeek Fetch returned an unexpected response shape");
346
+ }
347
+ const page = rawData as { title?: unknown; content?: unknown };
348
+ const title = typeof page.title === "string" ? page.title.trim() : "";
349
+ const content = typeof page.content === "string" ? normalizeDeepSeekMarkdown(page.content).trim() : "";
350
+ if (!content || isUnusableDeepSeekPage(title, content)) {
351
+ activityMonitor.logComplete(activityId, response.status);
352
+ return null;
353
+ }
354
+ activityMonitor.logComplete(activityId, response.status);
355
+ return {
356
+ url,
357
+ title,
358
+ content,
359
+ error: null,
360
+ };
361
+ } catch (err) {
362
+ const message = errorMessage(err);
363
+ if (signal?.aborted) {
364
+ activityMonitor.logComplete(activityId, 0);
365
+ throw new Error("Aborted");
366
+ }
367
+ activityMonitor.logError(activityId, redactCredential(message, apiKey));
368
+ if (err instanceof Error && err.name === "TimeoutError") {
369
+ throw new Error(`DeepSeek Fetch request timed out after ${Math.round(timeoutMs / 1000)}s`);
370
+ }
371
+ const redactedMessage = redactCredential(message, apiKey);
372
+ if (redactedMessage === message) throw err;
373
+ const redactedError = new Error(redactedMessage);
374
+ if (err instanceof Error) redactedError.name = err.name;
375
+ throw redactedError;
376
+ }
204
377
  }