@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.
Files changed (511) hide show
  1. package/README.md +11 -15
  2. package/THIRD_PARTY_NOTICES.md +2 -54
  3. package/extensions/clef-format.mjs +113 -0
  4. package/extensions/clef.mjs +112 -0
  5. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-debt.md +1 -1
  6. package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail.mjs +30 -6
  7. package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
  8. package/node_modules/@dietrichgebert/ponytail/README.md +5 -1
  9. package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +3 -3
  10. package/node_modules/@dietrichgebert/ponytail/hooks/copilot-hooks.json +4 -4
  11. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +158 -127
  12. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-config.js +5 -0
  13. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-map.js +8 -3
  14. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-runtime.js +14 -8
  15. package/node_modules/@dietrichgebert/ponytail/package.json +1 -1
  16. package/node_modules/@dietrichgebert/ponytail/pi-extension/index.js +16 -3
  17. package/node_modules/@dietrichgebert/ponytail/scripts/cursor-hooks.js +13 -3
  18. package/node_modules/@dietrichgebert/ponytail/scripts/uninstall.js +3 -2
  19. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +3 -3
  20. package/node_modules/@herbertgao/pi-agency/package.json +2 -2
  21. package/node_modules/@herbertgao/pi-bark/package.json +2 -2
  22. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +29 -28
  23. package/node_modules/@herbertgao/pi-cc-extensions/README.md +7 -7
  24. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +16 -27
  25. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +49 -48
  26. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +2 -3
  27. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +228 -141
  28. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/reference/index.ts +2 -3
  29. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer-layout.ts +105 -23
  30. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +59 -43
  31. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +96 -0
  32. package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +6 -0
  33. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +124 -54
  34. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +7 -4
  35. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +69 -28
  36. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +23 -8
  37. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts +2 -2
  38. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +24 -12
  39. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/codemode.ts +121 -6
  40. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-limits.ts +3 -2
  41. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-palette.ts +39 -8
  42. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-presentation.ts +2 -2
  43. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +13 -13
  44. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/message-display.ts +3 -2
  45. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +49 -49
  46. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +24 -0
  47. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-state.ts +51 -2
  48. package/node_modules/@herbertgao/pi-cc-extensions/package.json +5 -5
  49. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark.json +71 -70
  50. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light.json +71 -70
  51. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +8 -0
  52. package/node_modules/@herbertgao/pi-subagents/docs/packages.md +211 -0
  53. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +61 -63
  54. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +24 -16
  55. package/node_modules/@herbertgao/pi-subagents/package.json +5 -5
  56. package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +51 -14
  57. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +123 -55
  58. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +144 -13
  59. package/node_modules/@herbertgao/pi-subagents/src/agent-source-badge.ts +78 -0
  60. package/node_modules/@herbertgao/pi-subagents/src/completion-outbox.ts +122 -0
  61. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +171 -79
  62. package/node_modules/@herbertgao/pi-subagents/src/index.ts +597 -296
  63. package/node_modules/@herbertgao/pi-subagents/src/package-resources.ts +724 -0
  64. package/node_modules/@herbertgao/pi-subagents/src/schedule.ts +1 -1
  65. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +66 -0
  66. package/node_modules/@herbertgao/pi-subagents/src/types.ts +26 -4
  67. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +2 -0
  68. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +354 -32
  69. package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +33 -15
  70. package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +6 -0
  71. package/node_modules/@herbertgao/pi-subagents/src/workflow/saved.ts +48 -2
  72. package/node_modules/@herbertgao/sol-pi/package.json +2 -2
  73. package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +3 -3
  74. package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +89 -39
  75. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/configuration.md +1 -1
  76. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +4 -4
  77. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +56 -23
  78. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/tool-schema.md +6 -3
  79. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/de.json +3 -1
  80. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/en.json +3 -1
  81. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/es.json +3 -1
  82. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/fr.json +3 -1
  83. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt-BR.json +3 -1
  84. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt.json +3 -1
  85. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/ru.json +3 -1
  86. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/uk.json +3 -1
  87. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/zh.json +3 -1
  88. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +5 -2
  89. package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +122 -0
  90. package/node_modules/@juicesharp/rpiv-ask-user-question/rpc-fallback.ts +73 -36
  91. package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +10 -1
  92. package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +15 -13
  93. package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +5 -1
  94. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/derivations.ts +15 -0
  95. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/projections.ts +4 -1
  96. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +29 -18
  97. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +1 -1
  98. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/format-answer.ts +5 -2
  99. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/normalize-params.ts +46 -0
  100. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/response-envelope.ts +19 -8
  101. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/types.ts +9 -2
  102. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/multi-select-view.ts +4 -2
  103. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +56 -25
  104. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-pane.ts +131 -46
  105. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +94 -106
  106. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +51 -0
  107. package/node_modules/@juicesharp/rpiv-ask-user-question/view/scroll-window.ts +73 -0
  108. package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +31 -10
  109. package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts.map +1 -1
  110. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +474 -93
  111. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
  112. package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
  113. package/node_modules/@tifan/pi-inline-skills/package.json +5 -1
  114. package/node_modules/@tifan/pi-inline-skills/src/index.ts +5 -2
  115. package/node_modules/pi-lens/CHANGELOG.md +88 -0
  116. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +3 -1
  117. package/node_modules/pi-lens/dist/{chunk-BJF25SUG.js → chunk-23WOO7TX.js} +11 -10
  118. package/node_modules/pi-lens/dist/{chunk-WATC3IQR.js → chunk-2B73ZPOK.js} +3 -3
  119. package/node_modules/pi-lens/dist/{chunk-N2IRDBZI.js → chunk-2BBLFX75.js} +101 -11
  120. package/node_modules/pi-lens/dist/{chunk-TA5L5KWQ.js → chunk-2CD5RS6M.js} +2 -2
  121. package/node_modules/pi-lens/dist/{chunk-3TTPKMEF.js → chunk-2VUQMUMT.js} +38 -37
  122. package/node_modules/pi-lens/dist/{chunk-5JHXUETW.js → chunk-3EFKIGZN.js} +3 -3
  123. package/node_modules/pi-lens/dist/chunk-3JNKMP3B.js +17 -0
  124. package/node_modules/pi-lens/dist/{chunk-6P54TMWL.js → chunk-3VPVG5SU.js} +6 -6
  125. package/node_modules/pi-lens/dist/{chunk-ZETYB3XG.js → chunk-3W7IEVVL.js} +44 -28
  126. package/node_modules/pi-lens/dist/chunk-3YN6V5TV.js +85 -0
  127. package/node_modules/pi-lens/dist/chunk-466Z26MG.js +30 -0
  128. package/node_modules/pi-lens/dist/{chunk-PCHDGUKT.js → chunk-4UNXBNE2.js} +12 -11
  129. package/node_modules/pi-lens/dist/{chunk-J7WJZ6W7.js → chunk-4W4VLAPJ.js} +12 -11
  130. package/node_modules/pi-lens/dist/{chunk-F5VLZHUW.js → chunk-52FUZI6K.js} +4 -2
  131. package/node_modules/pi-lens/dist/{chunk-H5EV3VMF.js → chunk-5NGR67U5.js} +2 -2
  132. package/node_modules/pi-lens/dist/{chunk-CBD2B5CP.js → chunk-5UCAH366.js} +21 -20
  133. package/node_modules/pi-lens/dist/{chunk-BHWHXMQ2.js → chunk-67WMNWEE.js} +9 -8
  134. package/node_modules/pi-lens/dist/{chunk-USHG4DLH.js → chunk-6C7JWPCP.js} +7 -7
  135. package/node_modules/pi-lens/dist/{chunk-VPWKF3GN.js → chunk-6GFRNVYR.js} +11 -10
  136. package/node_modules/pi-lens/dist/{chunk-3JL6IFD7.js → chunk-6SDEP3AJ.js} +9 -8
  137. package/node_modules/pi-lens/dist/{chunk-NJF2X5XF.js → chunk-6STA6Z7I.js} +19 -17
  138. package/node_modules/pi-lens/dist/{chunk-KJCWXUUS.js → chunk-724UL2TJ.js} +6 -4
  139. package/node_modules/pi-lens/dist/{chunk-MQA2YBAH.js → chunk-76MWC2K6.js} +3 -3
  140. package/node_modules/pi-lens/dist/{chunk-YLN4K6WD.js → chunk-77M37OKR.js} +10 -8
  141. package/node_modules/pi-lens/dist/{chunk-XHSCVSOL.js → chunk-7DYBLXYA.js} +3 -3
  142. package/node_modules/pi-lens/dist/{chunk-OC7LYAU5.js → chunk-AB3YYG6N.js} +24 -10
  143. package/node_modules/pi-lens/dist/{chunk-LD7WFTRX.js → chunk-ACXEQZOU.js} +16 -16
  144. package/node_modules/pi-lens/dist/{chunk-VSMJK3ZJ.js → chunk-AOHZU2BM.js} +1 -1
  145. package/node_modules/pi-lens/dist/{chunk-T4QZ6FEH.js → chunk-AW7R2GWG.js} +65 -8
  146. package/node_modules/pi-lens/dist/{chunk-GAYGGICG.js → chunk-BKE7E7TC.js} +10 -9
  147. package/node_modules/pi-lens/dist/{chunk-EUT3B22Y.js → chunk-BRGDSBJE.js} +13 -12
  148. package/node_modules/pi-lens/dist/{chunk-T54VJRAD.js → chunk-C34ZXZ7O.js} +55 -11
  149. package/node_modules/pi-lens/dist/{chunk-UGSMCQ4D.js → chunk-CHOW74WE.js} +1 -1
  150. package/node_modules/pi-lens/dist/{chunk-H2W2AXD3.js → chunk-CMMHNUZ2.js} +66 -58
  151. package/node_modules/pi-lens/dist/chunk-CSHFH5IN.js +17 -0
  152. package/node_modules/pi-lens/dist/chunk-EC47DWFA.js +56 -0
  153. package/node_modules/pi-lens/dist/{chunk-KJN4IOEJ.js → chunk-EJIUXPBX.js} +1 -1
  154. package/node_modules/pi-lens/dist/{chunk-IQZXOZ7S.js → chunk-EU63SDCG.js} +720 -334
  155. package/node_modules/pi-lens/dist/{chunk-LNOMA3MP.js → chunk-FCSOVF55.js} +107 -3
  156. package/node_modules/pi-lens/dist/{chunk-CFYISHUW.js → chunk-FLKWCIZH.js} +8 -5
  157. package/node_modules/pi-lens/dist/{chunk-OYTMZXRF.js → chunk-FMSO6RDZ.js} +16 -14
  158. package/node_modules/pi-lens/dist/{chunk-IUKPRZER.js → chunk-GAEGEPOC.js} +2 -2
  159. package/node_modules/pi-lens/dist/{chunk-6XX5HCLK.js → chunk-GBPP5P7X.js} +4 -4
  160. package/node_modules/pi-lens/dist/{chunk-TQFBZVCG.js → chunk-GXW6K4YJ.js} +1 -1
  161. package/node_modules/pi-lens/dist/{chunk-ZZUFZUQZ.js → chunk-H6MF6EVN.js} +331 -107
  162. package/node_modules/pi-lens/dist/{chunk-3JSEWUWI.js → chunk-IBGIOBEE.js} +3 -3
  163. package/node_modules/pi-lens/dist/chunk-IZSHAIJ7.js +26 -0
  164. package/node_modules/pi-lens/dist/{chunk-7ELY2CSM.js → chunk-JAU72XNY.js} +16 -14
  165. package/node_modules/pi-lens/dist/chunk-JMYYOTQG.js +77 -0
  166. package/node_modules/pi-lens/dist/{chunk-ELVWJYRV.js → chunk-JSQFTSC6.js} +12 -11
  167. package/node_modules/pi-lens/dist/{chunk-J6DFZDFA.js → chunk-KBG47GHP.js} +4 -4
  168. package/node_modules/pi-lens/dist/chunk-KDERNTCQ.js +28 -0
  169. package/node_modules/pi-lens/dist/chunk-KSX3TXSZ.js +69 -0
  170. package/node_modules/pi-lens/dist/{chunk-XGUL4SLQ.js → chunk-L3BLXZG7.js} +2 -2
  171. package/node_modules/pi-lens/dist/chunk-LOP6GRPH.js +31 -0
  172. package/node_modules/pi-lens/dist/{chunk-MTDRLSI7.js → chunk-M6HSLBWY.js} +1064 -986
  173. package/node_modules/pi-lens/dist/chunk-MQLUAEOC.js +162 -0
  174. package/node_modules/pi-lens/dist/{chunk-3MRXIJ6I.js → chunk-MRXKYPCS.js} +2 -2
  175. package/node_modules/pi-lens/dist/{chunk-D65GOCJB.js → chunk-MXGY6KPT.js} +19 -16
  176. package/node_modules/pi-lens/dist/{chunk-G3RLJYA2.js → chunk-N2H3ZPZY.js} +47 -1
  177. package/node_modules/pi-lens/dist/{chunk-HREZQCT3.js → chunk-N3X6Q4YT.js} +3 -3
  178. package/node_modules/pi-lens/dist/{chunk-HSIRMK2D.js → chunk-OCAGUNBC.js} +15 -15
  179. package/node_modules/pi-lens/dist/{chunk-ZOEYVXSV.js → chunk-OXXKQCSV.js} +6 -6
  180. package/node_modules/pi-lens/dist/{chunk-S6AMWKPC.js → chunk-P7266HLM.js} +2 -2
  181. package/node_modules/pi-lens/dist/{chunk-64LU2OVH.js → chunk-PHDMFAKM.js} +12 -2
  182. package/node_modules/pi-lens/dist/{chunk-IMSQR4WO.js → chunk-PNQDPDRC.js} +1 -1
  183. package/node_modules/pi-lens/dist/{chunk-IUR76K6A.js → chunk-Q7DUK4LX.js} +5 -5
  184. package/node_modules/pi-lens/dist/{chunk-CULQYFLU.js → chunk-QGQ5CCCG.js} +2 -2
  185. package/node_modules/pi-lens/dist/{chunk-UEAHAMEI.js → chunk-QHJ6DQ2R.js} +11 -11
  186. package/node_modules/pi-lens/dist/{chunk-BNKLYOOO.js → chunk-QILIYSJF.js} +1 -1
  187. package/node_modules/pi-lens/dist/{chunk-VYKKMYVT.js → chunk-QOBUHWHX.js} +11 -6
  188. package/node_modules/pi-lens/dist/{chunk-3PNFWVHT.js → chunk-QQNQ7SJW.js} +2 -75
  189. package/node_modules/pi-lens/dist/{chunk-7M4T5N3V.js → chunk-R3PCY3YS.js} +14 -13
  190. package/node_modules/pi-lens/dist/{chunk-MGIWSROG.js → chunk-RPLINGVB.js} +7 -7
  191. package/node_modules/pi-lens/dist/{chunk-CMU4RMJB.js → chunk-RWWYJ623.js} +10 -1
  192. package/node_modules/pi-lens/dist/{chunk-3FERWMCH.js → chunk-RXCOMYPY.js} +27 -26
  193. package/node_modules/pi-lens/dist/{chunk-7BX5DWSA.js → chunk-SAEFPSB6.js} +11 -11
  194. package/node_modules/pi-lens/dist/{chunk-N7YNJE5R.js → chunk-SQ4TVJBR.js} +10 -10
  195. package/node_modules/pi-lens/dist/{chunk-DMS52BEP.js → chunk-SS36ZX4J.js} +9 -7
  196. package/node_modules/pi-lens/dist/{chunk-JONGANYH.js → chunk-T6CPIZNT.js} +32 -30
  197. package/node_modules/pi-lens/dist/{chunk-6UYA642J.js → chunk-TYM6OUIT.js} +13 -12
  198. package/node_modules/pi-lens/dist/{chunk-ALQRYH6O.js → chunk-UXGETRP4.js} +13 -12
  199. package/node_modules/pi-lens/dist/{chunk-FGALODG3.js → chunk-UZ3TUTRV.js} +1 -1
  200. package/node_modules/pi-lens/dist/{chunk-J3FZR3YY.js → chunk-VCHXCQFG.js} +3 -3
  201. package/node_modules/pi-lens/dist/{chunk-3P4PF2BX.js → chunk-VCO24T4L.js} +34 -22
  202. package/node_modules/pi-lens/dist/{chunk-O7HZX7CA.js → chunk-VRZP76YM.js} +1 -1
  203. package/node_modules/pi-lens/dist/{chunk-VZHJS6DR.js → chunk-VSSBEUFT.js} +16 -15
  204. package/node_modules/pi-lens/dist/{chunk-U52SAGRM.js → chunk-VWCXW2E7.js} +1 -1
  205. package/node_modules/pi-lens/dist/{chunk-WW5BLB74.js → chunk-WOA4LN2R.js} +2 -2
  206. package/node_modules/pi-lens/dist/{chunk-ZMOMPX2Z.js → chunk-WU567RSC.js} +11 -10
  207. package/node_modules/pi-lens/dist/{chunk-N77WFUL7.js → chunk-XAGLWMJ4.js} +23 -22
  208. package/node_modules/pi-lens/dist/{chunk-WSEWKCXU.js → chunk-XCJN5IJU.js} +4 -4
  209. package/node_modules/pi-lens/dist/{chunk-IR6XFA5P.js → chunk-XIJZVPD5.js} +16 -14
  210. package/node_modules/pi-lens/dist/{chunk-OYOB3ZFG.js → chunk-XMSXXAHW.js} +2 -2
  211. package/node_modules/pi-lens/dist/{chunk-34OCDWOS.js → chunk-XTMJ7XDT.js} +1 -1
  212. package/node_modules/pi-lens/dist/{chunk-Z6BB4JLQ.js → chunk-XVF2VVXP.js} +5 -3
  213. package/node_modules/pi-lens/dist/{chunk-AFZYMAIV.js → chunk-YIUAVF7E.js} +37 -35
  214. package/node_modules/pi-lens/dist/{chunk-NFXP47RV.js → chunk-YSZNHOBY.js} +85 -31
  215. package/node_modules/pi-lens/dist/{chunk-V5MEBST3.js → chunk-YYOIQFRS.js} +21 -21
  216. package/node_modules/pi-lens/dist/chunk-Z527N6YQ.js +28 -0
  217. package/node_modules/pi-lens/dist/{chunk-D6YF5HKX.js → chunk-ZANLILYD.js} +22 -2
  218. package/node_modules/pi-lens/dist/{chunk-2UMYMRI3.js → chunk-ZGDGW2V3.js} +2 -2
  219. package/node_modules/pi-lens/dist/{chunk-6B5I6ICN.js → chunk-ZHFZWTZV.js} +12 -11
  220. package/node_modules/pi-lens/dist/{chunk-OEX24ECI.js → chunk-ZWFS3OEF.js} +51 -41
  221. package/node_modules/pi-lens/dist/{chunk-AXKPQ6ZI.js → chunk-ZXYDQ3TZ.js} +5 -5
  222. package/node_modules/pi-lens/dist/index.js +73783 -71033
  223. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +18 -8
  224. package/node_modules/pi-lens/dist/mcp/cli.js +48 -37
  225. package/node_modules/pi-lens/dist/mcp/server.js +568 -397
  226. package/node_modules/pi-lens/dist/mcp/worker.js +67 -55
  227. package/node_modules/pi-lens/dist/probes/installer.js +20 -19
  228. package/node_modules/pi-lens/docs/astplayground.md +1 -1
  229. package/node_modules/pi-lens/docs/configuration.md +29 -0
  230. package/node_modules/pi-lens/docs/dependencies.md +3 -0
  231. package/node_modules/pi-lens/docs/features.md +2 -2
  232. package/node_modules/pi-lens/docs/globalconfig.md +2 -0
  233. package/node_modules/pi-lens/docs/language-coverage.md +2 -1
  234. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +29 -7
  235. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +38 -47
  236. package/node_modules/pi-lens/docs/pi-lens-fixer.md +4 -0
  237. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +17 -4
  238. package/node_modules/pi-lens/docs/pi-lens-retro.md +2 -1
  239. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +18 -0
  240. package/node_modules/pi-lens/docs/pi-lens-subagent.md +7 -0
  241. package/node_modules/pi-lens/docs/real-harness.md +17 -0
  242. package/node_modules/pi-lens/docs/schema/pi-lens-config-v1.json +37 -2
  243. package/node_modules/pi-lens/docs/servercapabilities.md +15 -4
  244. package/node_modules/pi-lens/docs/settings.md +2 -1
  245. package/node_modules/pi-lens/package.json +1 -1
  246. package/node_modules/pi-provider-qoder/dist/index.js +166 -33
  247. package/node_modules/pi-provider-qoder/package.json +1 -1
  248. package/node_modules/pi-typesafe/README.md +3 -3
  249. package/node_modules/pi-typesafe/dist/backends.d.ts +7 -2
  250. package/node_modules/pi-typesafe/dist/backends.js +42 -0
  251. package/node_modules/pi-typesafe/dist/batch.d.ts +10 -6
  252. package/node_modules/pi-typesafe/dist/batch.js +20 -9
  253. package/node_modules/pi-typesafe/dist/client.d.ts +4 -1
  254. package/node_modules/pi-typesafe/dist/client.js +5 -4
  255. package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
  256. package/node_modules/pi-typesafe/dist/index.js +1 -1
  257. package/node_modules/pi-typesafe/dist/schema.d.ts +18 -3
  258. package/node_modules/pi-typesafe/dist/schema.js +29 -3
  259. package/node_modules/pi-typesafe/package.json +1 -1
  260. package/node_modules/pi-web-access/CHANGELOG.md +66 -0
  261. package/node_modules/pi-web-access/README.md +17 -8
  262. package/node_modules/pi-web-access/brave.ts +20 -2
  263. package/node_modules/pi-web-access/content-find.ts +2 -1
  264. package/node_modules/pi-web-access/dist/index.js +668 -408
  265. package/node_modules/pi-web-access/dist/mcp-cli.js +666 -418
  266. package/node_modules/pi-web-access/duckduckgo.ts +5 -1
  267. package/node_modules/pi-web-access/endpoint-pdf-extract.ts +225 -0
  268. package/node_modules/pi-web-access/extract.ts +54 -14
  269. package/node_modules/pi-web-access/fetch-params.ts +10 -0
  270. package/node_modules/pi-web-access/gemini-api.ts +15 -0
  271. package/node_modules/pi-web-access/gemini-search.ts +32 -152
  272. package/node_modules/pi-web-access/github-issue-pr.ts +80 -68
  273. package/node_modules/pi-web-access/index.ts +3 -0
  274. package/node_modules/pi-web-access/package.json +1 -1
  275. package/node_modules/pi-web-access/pdf-extract.ts +38 -4
  276. package/node_modules/pi-web-access/perplexity.ts +19 -2
  277. package/node_modules/pi-web-access/searxng.ts +2 -1
  278. package/node_modules/pi-web-access/ssrf-protection.ts +35 -4
  279. package/node_modules/pi-web-access/summary-review.ts +10 -0
  280. package/node_modules/pi-web-access/tool-arguments.ts +5 -2
  281. package/node_modules/pi-web-access/video-extract.ts +6 -2
  282. package/node_modules/pi-web-access/web-tool-core.ts +53 -13
  283. package/package.json +21 -26
  284. package/node_modules/pi-jev-auto-mode/CHANGELOG.md +0 -118
  285. package/node_modules/pi-jev-auto-mode/LICENSE +0 -21
  286. package/node_modules/pi-jev-auto-mode/README.md +0 -292
  287. package/node_modules/pi-jev-auto-mode/SECURITY.md +0 -32
  288. package/node_modules/pi-jev-auto-mode/docs/calibration.md +0 -154
  289. package/node_modules/pi-jev-auto-mode/docs/design.md +0 -164
  290. package/node_modules/pi-jev-auto-mode/docs/security.md +0 -124
  291. package/node_modules/pi-jev-auto-mode/index.ts +0 -1
  292. package/node_modules/pi-jev-auto-mode/package.json +0 -72
  293. package/node_modules/pi-jev-auto-mode/src/call.ts +0 -180
  294. package/node_modules/pi-jev-auto-mode/src/decide.ts +0 -86
  295. package/node_modules/pi-jev-auto-mode/src/extension.ts +0 -881
  296. package/node_modules/pi-jev-auto-mode/src/intent.ts +0 -71
  297. package/node_modules/pi-jev-auto-mode/src/jev/availability.ts +0 -53
  298. package/node_modules/pi-jev-auto-mode/src/jev/criteria.ts +0 -19
  299. package/node_modules/pi-jev-auto-mode/src/jev/decide.ts +0 -187
  300. package/node_modules/pi-jev-auto-mode/src/jev/engine.ts +0 -165
  301. package/node_modules/pi-jev-auto-mode/src/jev/index.ts +0 -20
  302. package/node_modules/pi-jev-auto-mode/src/jev/questions.ts +0 -273
  303. package/node_modules/pi-jev-auto-mode/src/jev/response.ts +0 -64
  304. package/node_modules/pi-jev-auto-mode/src/jev/state.ts +0 -20
  305. package/node_modules/pi-jev-auto-mode/src/jev/transport.ts +0 -117
  306. package/node_modules/pi-jev-auto-mode/src/jev/types.ts +0 -46
  307. package/node_modules/pi-jev-auto-mode/src/policy.ts +0 -558
  308. package/node_modules/pi-jev-auto-mode/src/records.ts +0 -184
  309. package/node_modules/pi-jev-auto-mode/src/settings.ts +0 -349
  310. package/node_modules/pi-jev-auto-mode/src/ui.ts +0 -243
  311. package/node_modules/pi-lens/dist/chunk-2FQ62SPM.js +0 -83
  312. package/node_modules/pi-lens/dist/chunk-7AXO3ZDF.js +0 -30
  313. package/node_modules/pi-lens/dist/chunk-KMGPUKFD.js +0 -25
  314. package/node_modules/pi-lens/dist/chunk-OZJINN4O.js +0 -84
  315. package/node_modules/pi-lens/dist/chunk-RJFED73B.js +0 -79
  316. package/node_modules/pi-lens/dist/chunk-RTQNRM5X.js +0 -27
  317. package/node_modules/pi-lens/dist/chunk-VGEVL5EQ.js +0 -29
  318. package/node_modules/pi-lens/dist/chunk-WPE5FPGR.js +0 -54
  319. package/node_modules/pi-lens/dist/chunk-Z7QQA2KT.js +0 -27
  320. package/node_modules/resume-from/LICENSE +0 -21
  321. package/node_modules/resume-from/README.md +0 -167
  322. package/node_modules/resume-from/dist/adapters/claude-code/adapter.d.ts +0 -20
  323. package/node_modules/resume-from/dist/adapters/claude-code/adapter.js +0 -59
  324. package/node_modules/resume-from/dist/adapters/claude-code/contract.d.ts +0 -8
  325. package/node_modules/resume-from/dist/adapters/claude-code/contract.js +0 -4
  326. package/node_modules/resume-from/dist/adapters/claude-code/entries.d.ts +0 -30
  327. package/node_modules/resume-from/dist/adapters/claude-code/entries.js +0 -107
  328. package/node_modules/resume-from/dist/adapters/claude-code/index.d.ts +0 -3
  329. package/node_modules/resume-from/dist/adapters/claude-code/index.js +0 -2
  330. package/node_modules/resume-from/dist/adapters/claude-code/layout.d.ts +0 -29
  331. package/node_modules/resume-from/dist/adapters/claude-code/layout.js +0 -80
  332. package/node_modules/resume-from/dist/adapters/claude-code/readback.d.ts +0 -9
  333. package/node_modules/resume-from/dist/adapters/claude-code/readback.js +0 -39
  334. package/node_modules/resume-from/dist/adapters/claude-code/reader.d.ts +0 -40
  335. package/node_modules/resume-from/dist/adapters/claude-code/reader.js +0 -436
  336. package/node_modules/resume-from/dist/adapters/claude-code/redaction.d.ts +0 -26
  337. package/node_modules/resume-from/dist/adapters/claude-code/redaction.js +0 -145
  338. package/node_modules/resume-from/dist/adapters/claude-code/validation.d.ts +0 -4
  339. package/node_modules/resume-from/dist/adapters/claude-code/validation.js +0 -39
  340. package/node_modules/resume-from/dist/adapters/claude-code/writer.d.ts +0 -21
  341. package/node_modules/resume-from/dist/adapters/claude-code/writer.js +0 -306
  342. package/node_modules/resume-from/dist/adapters/codex/contract.d.ts +0 -13
  343. package/node_modules/resume-from/dist/adapters/codex/contract.js +0 -4
  344. package/node_modules/resume-from/dist/adapters/codex/index.d.ts +0 -6
  345. package/node_modules/resume-from/dist/adapters/codex/index.js +0 -43
  346. package/node_modules/resume-from/dist/adapters/codex/read.d.ts +0 -44
  347. package/node_modules/resume-from/dist/adapters/codex/read.js +0 -723
  348. package/node_modules/resume-from/dist/adapters/codex/readback.d.ts +0 -9
  349. package/node_modules/resume-from/dist/adapters/codex/readback.js +0 -47
  350. package/node_modules/resume-from/dist/adapters/codex/redaction.d.ts +0 -26
  351. package/node_modules/resume-from/dist/adapters/codex/redaction.js +0 -145
  352. package/node_modules/resume-from/dist/adapters/codex/rollout.d.ts +0 -115
  353. package/node_modules/resume-from/dist/adapters/codex/rollout.js +0 -269
  354. package/node_modules/resume-from/dist/adapters/codex/validation.d.ts +0 -7
  355. package/node_modules/resume-from/dist/adapters/codex/validation.js +0 -78
  356. package/node_modules/resume-from/dist/adapters/codex/write.d.ts +0 -17
  357. package/node_modules/resume-from/dist/adapters/codex/write.js +0 -141
  358. package/node_modules/resume-from/dist/adapters/contract.d.ts +0 -78
  359. package/node_modules/resume-from/dist/adapters/contract.js +0 -4
  360. package/node_modules/resume-from/dist/adapters/pi/adapter.d.ts +0 -15
  361. package/node_modules/resume-from/dist/adapters/pi/adapter.js +0 -213
  362. package/node_modules/resume-from/dist/adapters/pi/contract.d.ts +0 -24
  363. package/node_modules/resume-from/dist/adapters/pi/contract.js +0 -4
  364. package/node_modules/resume-from/dist/adapters/pi/format.d.ts +0 -162
  365. package/node_modules/resume-from/dist/adapters/pi/format.js +0 -223
  366. package/node_modules/resume-from/dist/adapters/pi/index.d.ts +0 -7
  367. package/node_modules/resume-from/dist/adapters/pi/index.js +0 -10
  368. package/node_modules/resume-from/dist/adapters/pi/parse.d.ts +0 -41
  369. package/node_modules/resume-from/dist/adapters/pi/parse.js +0 -371
  370. package/node_modules/resume-from/dist/adapters/pi/redaction.d.ts +0 -26
  371. package/node_modules/resume-from/dist/adapters/pi/redaction.js +0 -145
  372. package/node_modules/resume-from/dist/adapters/pi/serialize.d.ts +0 -20
  373. package/node_modules/resume-from/dist/adapters/pi/serialize.js +0 -87
  374. package/node_modules/resume-from/dist/adapters/pi/validate.d.ts +0 -14
  375. package/node_modules/resume-from/dist/adapters/pi/validate.js +0 -134
  376. package/node_modules/resume-from/dist/bin.d.ts +0 -35
  377. package/node_modules/resume-from/dist/bin.js +0 -135
  378. package/node_modules/resume-from/dist/contract.d.ts +0 -10
  379. package/node_modules/resume-from/dist/contract.js +0 -4
  380. package/node_modules/resume-from/dist/host/agents.d.ts +0 -29
  381. package/node_modules/resume-from/dist/host/agents.js +0 -20
  382. package/node_modules/resume-from/dist/host/cli/args.d.ts +0 -21
  383. package/node_modules/resume-from/dist/host/cli/args.js +0 -187
  384. package/node_modules/resume-from/dist/host/cli/contract.d.ts +0 -27
  385. package/node_modules/resume-from/dist/host/cli/contract.js +0 -4
  386. package/node_modules/resume-from/dist/host/cli/index.d.ts +0 -2
  387. package/node_modules/resume-from/dist/host/cli/index.js +0 -1
  388. package/node_modules/resume-from/dist/host/cli/presentation.d.ts +0 -2
  389. package/node_modules/resume-from/dist/host/cli/presentation.js +0 -11
  390. package/node_modules/resume-from/dist/host/cli/render.d.ts +0 -3
  391. package/node_modules/resume-from/dist/host/cli/render.js +0 -70
  392. package/node_modules/resume-from/dist/host/cli/runner.d.ts +0 -8
  393. package/node_modules/resume-from/dist/host/cli/runner.js +0 -125
  394. package/node_modules/resume-from/dist/host/contract.d.ts +0 -42
  395. package/node_modules/resume-from/dist/host/contract.js +0 -4
  396. package/node_modules/resume-from/dist/host/entry.d.ts +0 -52
  397. package/node_modules/resume-from/dist/host/entry.js +0 -91
  398. package/node_modules/resume-from/dist/host/index.d.ts +0 -11
  399. package/node_modules/resume-from/dist/host/index.js +0 -10
  400. package/node_modules/resume-from/dist/host/pi-extension/command.d.ts +0 -18
  401. package/node_modules/resume-from/dist/host/pi-extension/command.js +0 -126
  402. package/node_modules/resume-from/dist/host/pi-extension/contract.d.ts +0 -34
  403. package/node_modules/resume-from/dist/host/pi-extension/contract.js +0 -4
  404. package/node_modules/resume-from/dist/host/pi-extension/index.d.ts +0 -6
  405. package/node_modules/resume-from/dist/host/pi-extension/index.js +0 -4
  406. package/node_modules/resume-from/dist/host/pi-extension/picker.d.ts +0 -16
  407. package/node_modules/resume-from/dist/host/pi-extension/picker.js +0 -35
  408. package/node_modules/resume-from/dist/host/pi-extension/presentation.d.ts +0 -2
  409. package/node_modules/resume-from/dist/host/pi-extension/presentation.js +0 -11
  410. package/node_modules/resume-from/dist/host/pi-extension/register.d.ts +0 -25
  411. package/node_modules/resume-from/dist/host/pi-extension/register.js +0 -11
  412. package/node_modules/resume-from/dist/host/pi-extension/ui.d.ts +0 -20
  413. package/node_modules/resume-from/dist/host/pi-extension/ui.js +0 -1
  414. package/node_modules/resume-from/dist/host/profile.d.ts +0 -8
  415. package/node_modules/resume-from/dist/host/profile.js +0 -31
  416. package/node_modules/resume-from/dist/host/registry.d.ts +0 -8
  417. package/node_modules/resume-from/dist/host/registry.js +0 -33
  418. package/node_modules/resume-from/dist/host/wiring.d.ts +0 -41
  419. package/node_modules/resume-from/dist/host/wiring.js +0 -66
  420. package/node_modules/resume-from/dist/import/confirmation.d.ts +0 -9
  421. package/node_modules/resume-from/dist/import/confirmation.js +0 -27
  422. package/node_modules/resume-from/dist/import/contract.d.ts +0 -43
  423. package/node_modules/resume-from/dist/import/contract.js +0 -4
  424. package/node_modules/resume-from/dist/import/discovery/contract.d.ts +0 -63
  425. package/node_modules/resume-from/dist/import/discovery/contract.js +0 -4
  426. package/node_modules/resume-from/dist/import/discovery/errors.d.ts +0 -9
  427. package/node_modules/resume-from/dist/import/discovery/errors.js +0 -12
  428. package/node_modules/resume-from/dist/import/discovery/finder.d.ts +0 -11
  429. package/node_modules/resume-from/dist/import/discovery/finder.js +0 -269
  430. package/node_modules/resume-from/dist/import/discovery/homes.d.ts +0 -23
  431. package/node_modules/resume-from/dist/import/discovery/homes.js +0 -83
  432. package/node_modules/resume-from/dist/import/discovery/index.d.ts +0 -2
  433. package/node_modules/resume-from/dist/import/discovery/index.js +0 -2
  434. package/node_modules/resume-from/dist/import/discovery/ordering.d.ts +0 -3
  435. package/node_modules/resume-from/dist/import/discovery/ordering.js +0 -21
  436. package/node_modules/resume-from/dist/import/errors.d.ts +0 -22
  437. package/node_modules/resume-from/dist/import/errors.js +0 -20
  438. package/node_modules/resume-from/dist/import/index.d.ts +0 -3
  439. package/node_modules/resume-from/dist/import/index.js +0 -5
  440. package/node_modules/resume-from/dist/import/landing/contract.d.ts +0 -44
  441. package/node_modules/resume-from/dist/import/landing/contract.js +0 -4
  442. package/node_modules/resume-from/dist/import/landing/errors.d.ts +0 -15
  443. package/node_modules/resume-from/dist/import/landing/errors.js +0 -15
  444. package/node_modules/resume-from/dist/import/landing/handover.d.ts +0 -5
  445. package/node_modules/resume-from/dist/import/landing/handover.js +0 -12
  446. package/node_modules/resume-from/dist/import/landing/index.d.ts +0 -4
  447. package/node_modules/resume-from/dist/import/landing/index.js +0 -4
  448. package/node_modules/resume-from/dist/import/landing/lander.d.ts +0 -7
  449. package/node_modules/resume-from/dist/import/landing/lander.js +0 -133
  450. package/node_modules/resume-from/dist/import/landing/marker.d.ts +0 -9
  451. package/node_modules/resume-from/dist/import/landing/marker.js +0 -46
  452. package/node_modules/resume-from/dist/import/pipeline.d.ts +0 -28
  453. package/node_modules/resume-from/dist/import/pipeline.js +0 -154
  454. package/node_modules/resume-from/dist/import/preview/builder.d.ts +0 -6
  455. package/node_modules/resume-from/dist/import/preview/builder.js +0 -80
  456. package/node_modules/resume-from/dist/import/preview/contract.d.ts +0 -39
  457. package/node_modules/resume-from/dist/import/preview/contract.js +0 -4
  458. package/node_modules/resume-from/dist/import/preview/format.d.ts +0 -19
  459. package/node_modules/resume-from/dist/import/preview/format.js +0 -45
  460. package/node_modules/resume-from/dist/import/preview/index.d.ts +0 -2
  461. package/node_modules/resume-from/dist/import/preview/index.js +0 -1
  462. package/node_modules/resume-from/dist/import/preview/warnings.d.ts +0 -14
  463. package/node_modules/resume-from/dist/import/preview/warnings.js +0 -86
  464. package/node_modules/resume-from/dist/import/transfer/contract.d.ts +0 -48
  465. package/node_modules/resume-from/dist/import/transfer/contract.js +0 -4
  466. package/node_modules/resume-from/dist/import/transfer/index.d.ts +0 -2
  467. package/node_modules/resume-from/dist/import/transfer/index.js +0 -1
  468. package/node_modules/resume-from/dist/import/transfer/rules.d.ts +0 -3
  469. package/node_modules/resume-from/dist/import/transfer/rules.js +0 -228
  470. package/node_modules/resume-from/dist/import/wiring.d.ts +0 -24
  471. package/node_modules/resume-from/dist/import/wiring.js +0 -37
  472. package/node_modules/resume-from/dist/index.d.ts +0 -36
  473. package/node_modules/resume-from/dist/index.js +0 -36
  474. package/node_modules/resume-from/dist/platform/config/contract.d.ts +0 -35
  475. package/node_modules/resume-from/dist/platform/config/contract.js +0 -4
  476. package/node_modules/resume-from/dist/platform/config/defaults.d.ts +0 -16
  477. package/node_modules/resume-from/dist/platform/config/defaults.js +0 -22
  478. package/node_modules/resume-from/dist/platform/config/errors.d.ts +0 -9
  479. package/node_modules/resume-from/dist/platform/config/errors.js +0 -12
  480. package/node_modules/resume-from/dist/platform/config/index.d.ts +0 -5
  481. package/node_modules/resume-from/dist/platform/config/index.js +0 -6
  482. package/node_modules/resume-from/dist/platform/config/loader.d.ts +0 -10
  483. package/node_modules/resume-from/dist/platform/config/loader.js +0 -47
  484. package/node_modules/resume-from/dist/platform/config/paths.d.ts +0 -13
  485. package/node_modules/resume-from/dist/platform/config/paths.js +0 -37
  486. package/node_modules/resume-from/dist/platform/config/validate.d.ts +0 -9
  487. package/node_modules/resume-from/dist/platform/config/validate.js +0 -117
  488. package/node_modules/resume-from/dist/platform/repo/contract.d.ts +0 -36
  489. package/node_modules/resume-from/dist/platform/repo/contract.js +0 -4
  490. package/node_modules/resume-from/dist/platform/repo/git.d.ts +0 -21
  491. package/node_modules/resume-from/dist/platform/repo/git.js +0 -77
  492. package/node_modules/resume-from/dist/platform/repo/index.d.ts +0 -2
  493. package/node_modules/resume-from/dist/platform/repo/index.js +0 -1
  494. package/node_modules/resume-from/dist/platform/repo/reader.d.ts +0 -3
  495. package/node_modules/resume-from/dist/platform/repo/reader.js +0 -170
  496. package/node_modules/resume-from/dist/platform/store/contract.d.ts +0 -31
  497. package/node_modules/resume-from/dist/platform/store/contract.js +0 -4
  498. package/node_modules/resume-from/dist/platform/store/file-committer.d.ts +0 -3
  499. package/node_modules/resume-from/dist/platform/store/file-committer.js +0 -391
  500. package/node_modules/resume-from/dist/platform/store/index.d.ts +0 -2
  501. package/node_modules/resume-from/dist/platform/store/index.js +0 -2
  502. package/node_modules/resume-from/dist/platform/tokens/contract.d.ts +0 -12
  503. package/node_modules/resume-from/dist/platform/tokens/contract.js +0 -4
  504. package/node_modules/resume-from/dist/platform/tokens/estimator.d.ts +0 -12
  505. package/node_modules/resume-from/dist/platform/tokens/estimator.js +0 -111
  506. package/node_modules/resume-from/dist/platform/tokens/index.d.ts +0 -2
  507. package/node_modules/resume-from/dist/platform/tokens/index.js +0 -1
  508. package/node_modules/resume-from/dist/session/contract.d.ts +0 -116
  509. package/node_modules/resume-from/dist/session/contract.js +0 -4
  510. package/node_modules/resume-from/package.json +0 -83
  511. package/node_modules/resume-from/shims/pi/extensions/resume-from.js +0 -118
@@ -943,6 +943,16 @@ function getVersionedApiBase() {
943
943
  function getUploadBase() {
944
944
  return `${getApiHost()}/upload/${API_VERSION}`;
945
945
  }
946
+ function rewriteUploadUrlOrigin(url) {
947
+ try {
948
+ const parsed = new URL(url);
949
+ const base = getApiHost();
950
+ if (parsed.origin === new URL(base).origin) return url;
951
+ return `${base}${parsed.pathname}${parsed.search}`;
952
+ } catch {
953
+ return url;
954
+ }
955
+ }
946
956
  function getLegacyCloudflareApiKey() {
947
957
  return normalizeApiKey(process.env.CLOUDFLARE_API_KEY) ?? normalizeApiKey(loadConfig2().cloudflareApiKey);
948
958
  }
@@ -2180,6 +2190,9 @@ async function postPerplexity(url, body, options) {
2180
2190
  windowMs: RATE_LIMIT.windowMs
2181
2191
  });
2182
2192
  const apiKey = await getApiKey2(options.signal);
2193
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS);
2194
+ const timedOut = () => timeout.aborted && !options.signal?.aborted;
2195
+ const timeoutError = () => new Error("Perplexity API error 408: request timed out");
2183
2196
  let response;
2184
2197
  try {
2185
2198
  response = await fetch(url, {
@@ -2189,9 +2202,13 @@ async function postPerplexity(url, body, options) {
2189
2202
  "Content-Type": "application/json"
2190
2203
  },
2191
2204
  body: JSON.stringify(body),
2192
- ...options.signal ? { signal: options.signal } : {}
2205
+ signal: options.signal ? AbortSignal.any([options.signal, timeout]) : timeout
2193
2206
  });
2194
2207
  } catch (err) {
2208
+ if (timedOut()) {
2209
+ activityMonitor.logError(activityId, "request timed out");
2210
+ throw timeoutError();
2211
+ }
2195
2212
  const message = err instanceof Error ? err.message : String(err);
2196
2213
  const redactedMessage = redactCredential(message, apiKey);
2197
2214
  if (redactedMessage.toLowerCase().includes("abort")) {
@@ -2206,12 +2223,19 @@ async function postPerplexity(url, body, options) {
2206
2223
  }
2207
2224
  activityMonitor.logComplete(activityId, response.status);
2208
2225
  if (!response.ok) {
2209
- const errorText = redactCredential(await response.text(), apiKey);
2226
+ let errorText;
2227
+ try {
2228
+ errorText = redactCredential(await response.text(), apiKey);
2229
+ } catch (err) {
2230
+ if (timedOut()) throw timeoutError();
2231
+ throw err;
2232
+ }
2210
2233
  throw new Error(`Perplexity API error ${response.status}: ${errorText}`);
2211
2234
  }
2212
2235
  try {
2213
2236
  return await response.json();
2214
2237
  } catch (err) {
2238
+ if (timedOut()) throw timeoutError();
2215
2239
  const message = err instanceof Error ? err.message : String(err);
2216
2240
  throw new Error(`Perplexity API returned invalid JSON: ${message}`);
2217
2241
  }
@@ -2256,7 +2280,7 @@ async function askPerplexity(prompt, options = {}) {
2256
2280
  const content = data.choices?.[0]?.message?.content;
2257
2281
  return typeof content === "string" ? content : "";
2258
2282
  }
2259
- var PERPLEXITY_SEARCH_URL, PERPLEXITY_CHAT_URL, CONFIG_PATH4, RATE_LIMIT, requestTimestamps, cachedConfig4;
2283
+ var PERPLEXITY_SEARCH_URL, PERPLEXITY_CHAT_URL, CONFIG_PATH4, SEARCH_TIMEOUT_MS, RATE_LIMIT, requestTimestamps, cachedConfig4;
2260
2284
  var init_perplexity = __esm({
2261
2285
  "perplexity.ts"() {
2262
2286
  init_activity();
@@ -2266,6 +2290,7 @@ var init_perplexity = __esm({
2266
2290
  PERPLEXITY_SEARCH_URL = "https://api.perplexity.ai/search";
2267
2291
  PERPLEXITY_CHAT_URL = "https://api.perplexity.ai/chat/completions";
2268
2292
  CONFIG_PATH4 = getWebSearchConfigPath();
2293
+ SEARCH_TIMEOUT_MS = 3e4;
2269
2294
  RATE_LIMIT = {
2270
2295
  maxRequests: 10,
2271
2296
  windowMs: 60 * 1e3
@@ -2378,7 +2403,7 @@ function isParallelAvailable() {
2378
2403
  return hasParallelApiKey();
2379
2404
  }
2380
2405
  function requestSignal2(signal) {
2381
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS3);
2406
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS4);
2382
2407
  return signal ? AbortSignal.any([signal, timeout]) : timeout;
2383
2408
  }
2384
2409
  function errorMessage(err) {
@@ -2572,7 +2597,7 @@ async function parallelFetch(url, body, signal) {
2572
2597
  throw new Error(`Parallel API returned invalid JSON: ${errorMessage(err)}`);
2573
2598
  }
2574
2599
  }
2575
- var PARALLEL_SEARCH_URL, PARALLEL_EXTRACT_URL, CONFIG_PATH8, MIN_PARALLEL_API_KEY_LENGTH, MIN_USEFUL_CONTENT, SEARCH_TIMEOUT_MS3, PLACEHOLDER_API_KEY_DENYLIST, cachedConfig8;
2600
+ var PARALLEL_SEARCH_URL, PARALLEL_EXTRACT_URL, CONFIG_PATH8, MIN_PARALLEL_API_KEY_LENGTH, MIN_USEFUL_CONTENT, SEARCH_TIMEOUT_MS4, PLACEHOLDER_API_KEY_DENYLIST, cachedConfig8;
2576
2601
  var init_parallel = __esm({
2577
2602
  "parallel.ts"() {
2578
2603
  init_activity();
@@ -2584,7 +2609,7 @@ var init_parallel = __esm({
2584
2609
  CONFIG_PATH8 = getWebSearchConfigPath();
2585
2610
  MIN_PARALLEL_API_KEY_LENGTH = 8;
2586
2611
  MIN_USEFUL_CONTENT = 500;
2587
- SEARCH_TIMEOUT_MS3 = 6e4;
2612
+ SEARCH_TIMEOUT_MS4 = 6e4;
2588
2613
  PLACEHOLDER_API_KEY_DENYLIST = /* @__PURE__ */ new Set([
2589
2614
  "replace_with_your_parallel_api_key",
2590
2615
  "parallel_api_key",
@@ -3014,7 +3039,7 @@ async function searchWithTinyFish(query, options = {}) {
3014
3039
  buildSearchUrl(query, options, page),
3015
3040
  apiKey,
3016
3041
  { method: "GET" },
3017
- SEARCH_TIMEOUT_MS4,
3042
+ SEARCH_TIMEOUT_MS5,
3018
3043
  options.signal
3019
3044
  );
3020
3045
  if (!Array.isArray(data.results)) throw new Error("TinyFish Search API returned an unexpected response shape");
@@ -3072,7 +3097,7 @@ async function extractWithTinyFish(url, signal, options = {}) {
3072
3097
  throw redactedError;
3073
3098
  }
3074
3099
  }
3075
- var TINYFISH_SEARCH_URL, TINYFISH_FETCH_URL, CONFIG_PATH10, SEARCH_TIMEOUT_MS4, FETCH_TIMEOUT_MS, MAX_FETCH_URLS, MAX_FETCH_PER_URL_TIMEOUT_MS, cachedConfig9;
3100
+ var TINYFISH_SEARCH_URL, TINYFISH_FETCH_URL, CONFIG_PATH10, SEARCH_TIMEOUT_MS5, FETCH_TIMEOUT_MS, MAX_FETCH_URLS, MAX_FETCH_PER_URL_TIMEOUT_MS, cachedConfig9;
3076
3101
  var init_tinyfish = __esm({
3077
3102
  "tinyfish.ts"() {
3078
3103
  init_activity();
@@ -3084,7 +3109,7 @@ var init_tinyfish = __esm({
3084
3109
  TINYFISH_SEARCH_URL = "https://api.search.tinyfish.ai";
3085
3110
  TINYFISH_FETCH_URL = "https://api.fetch.tinyfish.ai";
3086
3111
  CONFIG_PATH10 = getWebSearchConfigPath();
3087
- SEARCH_TIMEOUT_MS4 = 6e4;
3112
+ SEARCH_TIMEOUT_MS5 = 6e4;
3088
3113
  FETCH_TIMEOUT_MS = 15e4;
3089
3114
  MAX_FETCH_URLS = 10;
3090
3115
  MAX_FETCH_PER_URL_TIMEOUT_MS = 11e4;
@@ -3234,7 +3259,7 @@ async function searchWithSearch1API(query, options = {}) {
3234
3259
  SEARCH1API_SEARCH_URL,
3235
3260
  apiKey,
3236
3261
  buildSearchBody(query, options),
3237
- SEARCH_TIMEOUT_MS5,
3262
+ SEARCH_TIMEOUT_MS6,
3238
3263
  options.signal
3239
3264
  );
3240
3265
  const results = mapSearchResults3(data.results);
@@ -3295,7 +3320,7 @@ async function extractWithSearch1API(url, signal, options = {}) {
3295
3320
  throw redactedError;
3296
3321
  }
3297
3322
  }
3298
- var SEARCH1API_SEARCH_URL, SEARCH1API_CRAWL_URL, CONFIG_PATH11, SEARCH_TIMEOUT_MS5, CRAWL_TIMEOUT_MS, cachedConfig10;
3323
+ var SEARCH1API_SEARCH_URL, SEARCH1API_CRAWL_URL, CONFIG_PATH11, SEARCH_TIMEOUT_MS6, CRAWL_TIMEOUT_MS, cachedConfig10;
3299
3324
  var init_search1api = __esm({
3300
3325
  "search1api.ts"() {
3301
3326
  init_activity();
@@ -3307,7 +3332,7 @@ var init_search1api = __esm({
3307
3332
  SEARCH1API_SEARCH_URL = "https://api.search1api.com/search";
3308
3333
  SEARCH1API_CRAWL_URL = "https://api.search1api.com/crawl";
3309
3334
  CONFIG_PATH11 = getWebSearchConfigPath();
3310
- SEARCH_TIMEOUT_MS5 = 6e4;
3335
+ SEARCH_TIMEOUT_MS6 = 6e4;
3311
3336
  CRAWL_TIMEOUT_MS = 6e4;
3312
3337
  cachedConfig10 = null;
3313
3338
  }
@@ -3537,7 +3562,7 @@ async function searchWithQuerit(query, options = {}) {
3537
3562
  QUERIT_SEARCH_URL,
3538
3563
  apiKey,
3539
3564
  buildSearchBody3(query, options),
3540
- SEARCH_TIMEOUT_MS7,
3565
+ SEARCH_TIMEOUT_MS8,
3541
3566
  options.signal
3542
3567
  );
3543
3568
  assertApiSuccess("Search", data);
@@ -3587,7 +3612,7 @@ async function extractWithQuerit(url, signal, options = {}) {
3587
3612
  throw redactedError;
3588
3613
  }
3589
3614
  }
3590
- var QUERIT_SEARCH_URL, QUERIT_CONTENTS_URL, CONFIG_PATH13, SEARCH_TIMEOUT_MS7, CONTENTS_TIMEOUT_MS, MAX_CONTENT_URLS, cachedConfig12;
3615
+ var QUERIT_SEARCH_URL, QUERIT_CONTENTS_URL, CONFIG_PATH13, SEARCH_TIMEOUT_MS8, CONTENTS_TIMEOUT_MS, MAX_CONTENT_URLS, cachedConfig12;
3591
3616
  var init_querit = __esm({
3592
3617
  "querit.ts"() {
3593
3618
  init_activity();
@@ -3599,7 +3624,7 @@ var init_querit = __esm({
3599
3624
  QUERIT_SEARCH_URL = "https://api.querit.ai/v1/search";
3600
3625
  QUERIT_CONTENTS_URL = "https://api.querit.ai/v1/contents";
3601
3626
  CONFIG_PATH13 = getWebSearchConfigPath();
3602
- SEARCH_TIMEOUT_MS7 = 6e4;
3627
+ SEARCH_TIMEOUT_MS8 = 6e4;
3603
3628
  CONTENTS_TIMEOUT_MS = 6e4;
3604
3629
  MAX_CONTENT_URLS = 10;
3605
3630
  cachedConfig12 = null;
@@ -3637,15 +3662,34 @@ function loadConfigRoot() {
3637
3662
  cachedConfigRoot = { signature, value };
3638
3663
  return value;
3639
3664
  }
3640
- function loadFetchContentDomainPolicy() {
3665
+ function loadFetchContentConfig() {
3641
3666
  const parsed = loadConfigRoot();
3642
- if (!parsed) return { ...DEFAULT_DOMAIN_POLICY };
3667
+ if (!parsed) return void 0;
3643
3668
  const fetchContent = parsed.fetchContent;
3644
- if (fetchContent === void 0 || fetchContent === null) return { ...DEFAULT_DOMAIN_POLICY };
3669
+ if (fetchContent === void 0 || fetchContent === null) return void 0;
3645
3670
  if (typeof fetchContent !== "object" || Array.isArray(fetchContent)) {
3646
3671
  throw new Error(`fetchContent in ${WEB_SEARCH_CONFIG_PATH} must be an object`);
3647
3672
  }
3648
- const policy = fetchContent.domainPolicy;
3673
+ return fetchContent;
3674
+ }
3675
+ function loadFetchContentRedirectPolicy() {
3676
+ const redirects = loadFetchContentConfig()?.redirects;
3677
+ if (redirects === void 0 || redirects === null) return void 0;
3678
+ if (redirects !== "same-origin") {
3679
+ throw new Error(`fetchContent.redirects in ${WEB_SEARCH_CONFIG_PATH} must be "same-origin"`);
3680
+ }
3681
+ return redirects;
3682
+ }
3683
+ function loadFetchContentUserAgent() {
3684
+ const userAgent = loadFetchContentConfig()?.userAgent;
3685
+ if (userAgent === void 0 || userAgent === null) return DEFAULT_FETCH_CONTENT_USER_AGENT;
3686
+ if (typeof userAgent !== "string" || userAgent.trim().length === 0 || !/^[\t\x20-\x7e]+$/.test(userAgent)) {
3687
+ throw new Error(`fetchContent.userAgent in ${WEB_SEARCH_CONFIG_PATH} must be a non-empty string of printable ASCII characters`);
3688
+ }
3689
+ return userAgent.trim();
3690
+ }
3691
+ function loadFetchContentDomainPolicy() {
3692
+ const policy = loadFetchContentConfig()?.domainPolicy;
3649
3693
  if (policy === void 0 || policy === null) return { ...DEFAULT_DOMAIN_POLICY };
3650
3694
  if (typeof policy !== "object" || Array.isArray(policy)) {
3651
3695
  throw new Error(`fetchContent.domainPolicy in ${WEB_SEARCH_CONFIG_PATH} must be an object`);
@@ -3759,6 +3803,9 @@ async function fetchRemoteUrl(url, init = {}, options = {}) {
3759
3803
  if (redirects === maxRedirects) throw new Error(`Too many redirects fetching ${current.toString()}`);
3760
3804
  const from = current;
3761
3805
  const next = new URL(location, current);
3806
+ if (options.redirects === "same-origin" && next.origin !== configuredOrigin) {
3807
+ throw new Error(`Refused cross-origin redirect by fetch_content redirect policy: ${configuredOrigin} -> ${next.origin}`);
3808
+ }
3762
3809
  current = await validateRemoteUrl(next, next.origin === configuredOrigin ? options : { ...options, allowLoopback: false });
3763
3810
  if (response.status === 303 || (response.status === 301 || response.status === 302) && requestInit.method?.toUpperCase() === "POST") {
3764
3811
  const { body: _body, ...nextInit } = requestInit;
@@ -3982,7 +4029,7 @@ function bytesMatchPrefix(addr, network, prefix) {
3982
4029
  }
3983
4030
  return true;
3984
4031
  }
3985
- var DEFAULT_MAX_REDIRECTS, REDIRECT_STATUSES, LOOPBACK_ALLOW_RANGES, REMOTE_DNS_PROXY_PROTOCOLS, WEB_SEARCH_CONFIG_PATH, cachedConfigRoot, DEFAULT_DOMAIN_POLICY;
4032
+ 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;
3986
4033
  var init_ssrf_protection = __esm({
3987
4034
  "ssrf-protection.ts"() {
3988
4035
  init_utils();
@@ -3993,6 +4040,7 @@ var init_ssrf_protection = __esm({
3993
4040
  WEB_SEARCH_CONFIG_PATH = getWebSearchConfigPath();
3994
4041
  cachedConfigRoot = null;
3995
4042
  DEFAULT_DOMAIN_POLICY = { allow: [], deny: [] };
4043
+ DEFAULT_FETCH_CONTENT_USER_AGENT = "OpenAI File Downloader, XaiImageApiFetch/1.0";
3996
4044
  }
3997
4045
  });
3998
4046
 
@@ -4300,7 +4348,7 @@ async function searchWithFirecrawl(query, options = {}) {
4300
4348
  "search",
4301
4349
  searchBody(query, options, numResults, filters),
4302
4350
  options.signal,
4303
- { ...options, timeoutMs: options.timeoutMs ?? SEARCH_TIMEOUT_MS10 },
4351
+ { ...options, timeoutMs: options.timeoutMs ?? SEARCH_TIMEOUT_MS11 },
4304
4352
  "search",
4305
4353
  { type: "api", query }
4306
4354
  );
@@ -4327,7 +4375,7 @@ async function extractWithFirecrawl(url, signal, options) {
4327
4375
  const title = typeof metadataTitle === "string" && metadataTitle.trim() ? metadataTitle.trim() : typeof scrape.title === "string" ? scrape.title.trim() : "";
4328
4376
  return { url, title, content: withPdfTruncationNotice(content, scrape.metadata), error: null };
4329
4377
  }
4330
- var CONFIG_PATH16, DEFAULT_API_VERSION, EXTRACT_TIMEOUT_MS, SEARCH_TIMEOUT_MS10, DEFAULT_MAX_REDIRECTS2, REDIRECT_STATUSES2, SUPPORTED_API_VERSIONS, cachedConfig15;
4378
+ var CONFIG_PATH16, DEFAULT_API_VERSION, EXTRACT_TIMEOUT_MS, SEARCH_TIMEOUT_MS11, DEFAULT_MAX_REDIRECTS2, REDIRECT_STATUSES2, SUPPORTED_API_VERSIONS, cachedConfig15;
4331
4379
  var init_firecrawl = __esm({
4332
4380
  "firecrawl.ts"() {
4333
4381
  init_activity();
@@ -4340,7 +4388,7 @@ var init_firecrawl = __esm({
4340
4388
  CONFIG_PATH16 = getWebSearchConfigPath();
4341
4389
  DEFAULT_API_VERSION = "v2";
4342
4390
  EXTRACT_TIMEOUT_MS = 6e4;
4343
- SEARCH_TIMEOUT_MS10 = 6e4;
4391
+ SEARCH_TIMEOUT_MS11 = 6e4;
4344
4392
  DEFAULT_MAX_REDIRECTS2 = 5;
4345
4393
  REDIRECT_STATUSES2 = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
4346
4394
  SUPPORTED_API_VERSIONS = ["v1", "v2"];
@@ -4474,7 +4522,7 @@ async function searchWithKagi(query, options = {}) {
4474
4522
  method: "POST",
4475
4523
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "application/json" },
4476
4524
  body: JSON.stringify({ query, limit: numResults }),
4477
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS13), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS13)
4525
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS14), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS14)
4478
4526
  });
4479
4527
  } catch (err) {
4480
4528
  const message = errorMessage12(err);
@@ -4529,7 +4577,7 @@ async function extractWithKagi(url, signal, options = {}) {
4529
4577
  method: "POST",
4530
4578
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "application/json" },
4531
4579
  body: JSON.stringify({ pages: [{ url }] }),
4532
- signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS13), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS13)
4580
+ signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS14), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS14)
4533
4581
  }, {
4534
4582
  allowRanges: ssrf.allowRanges,
4535
4583
  trustEnvProxy: ssrf.trustEnvProxy,
@@ -4562,7 +4610,7 @@ async function extractWithKagi(url, signal, options = {}) {
4562
4610
  activityMonitor.logComplete(activityId, response.status);
4563
4611
  return parsed;
4564
4612
  }
4565
- var KAGI_SEARCH_URL, KAGI_EXTRACT_URL, CONFIG_PATH19, SEARCH_TIMEOUT_MS13, cachedConfig18;
4613
+ var KAGI_SEARCH_URL, KAGI_EXTRACT_URL, CONFIG_PATH19, SEARCH_TIMEOUT_MS14, cachedConfig18;
4566
4614
  var init_kagi = __esm({
4567
4615
  "kagi.ts"() {
4568
4616
  init_activity();
@@ -4574,7 +4622,7 @@ var init_kagi = __esm({
4574
4622
  KAGI_SEARCH_URL = "https://kagi.com/api/v1/search";
4575
4623
  KAGI_EXTRACT_URL = "https://kagi.com/api/v1/extract";
4576
4624
  CONFIG_PATH19 = getWebSearchConfigPath();
4577
- SEARCH_TIMEOUT_MS13 = 6e4;
4625
+ SEARCH_TIMEOUT_MS14 = 6e4;
4578
4626
  cachedConfig18 = null;
4579
4627
  }
4580
4628
  });
@@ -4666,7 +4714,7 @@ async function searchWithOllama(query, options = {}) {
4666
4714
  method: "POST",
4667
4715
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
4668
4716
  body: JSON.stringify({ query, max_results: numResults }),
4669
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS15), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS15)
4717
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS16), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS16)
4670
4718
  });
4671
4719
  } catch (err) {
4672
4720
  const message = errorMessage14(err);
@@ -4720,7 +4768,7 @@ async function extractWithOllama(url, signal, options = {}) {
4720
4768
  method: "POST",
4721
4769
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
4722
4770
  body: JSON.stringify({ url }),
4723
- signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS15), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS15)
4771
+ signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS16), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS16)
4724
4772
  }, {
4725
4773
  allowRanges: ssrf.allowRanges,
4726
4774
  trustEnvProxy: ssrf.trustEnvProxy,
@@ -4755,7 +4803,7 @@ async function extractWithOllama(url, signal, options = {}) {
4755
4803
  if (!content) return null;
4756
4804
  return { url, title: data.title, content, error: null };
4757
4805
  }
4758
- var OLLAMA_SEARCH_URL, OLLAMA_FETCH_URL, CONFIG_PATH21, SEARCH_TIMEOUT_MS15, cachedConfig20;
4806
+ var OLLAMA_SEARCH_URL, OLLAMA_FETCH_URL, CONFIG_PATH21, SEARCH_TIMEOUT_MS16, cachedConfig20;
4759
4807
  var init_ollama = __esm({
4760
4808
  "ollama.ts"() {
4761
4809
  init_activity();
@@ -4766,7 +4814,7 @@ var init_ollama = __esm({
4766
4814
  OLLAMA_SEARCH_URL = "https://ollama.com/api/web_search";
4767
4815
  OLLAMA_FETCH_URL = "https://ollama.com/api/web_fetch";
4768
4816
  CONFIG_PATH21 = getWebSearchConfigPath();
4769
- SEARCH_TIMEOUT_MS15 = 6e4;
4817
+ SEARCH_TIMEOUT_MS16 = 6e4;
4770
4818
  cachedConfig20 = null;
4771
4819
  }
4772
4820
  });
@@ -5600,6 +5648,181 @@ var init_datalab_pdf_extract = __esm({
5600
5648
  }
5601
5649
  });
5602
5650
 
5651
+ // endpoint-pdf-extract.ts
5652
+ import { existsSync as existsSync43, readFileSync as readFileSync45 } from "node:fs";
5653
+ import { setTimeout as sleep2 } from "node:timers/promises";
5654
+ function pdfSection() {
5655
+ if (!existsSync43(CONFIG_PATH40)) return {};
5656
+ let parsed;
5657
+ try {
5658
+ parsed = JSON.parse(readFileSync45(CONFIG_PATH40, "utf-8"));
5659
+ } catch (err) {
5660
+ const message = err instanceof Error ? err.message : String(err);
5661
+ throw new Error(`Failed to parse ${CONFIG_PATH40}: ${message}`);
5662
+ }
5663
+ const pdf = parsed?.pdf;
5664
+ return pdf && typeof pdf === "object" ? pdf : {};
5665
+ }
5666
+ function normalizeString2(value) {
5667
+ if (typeof value !== "string") return null;
5668
+ const normalized = value.trim();
5669
+ return normalized.length > 0 ? normalized : null;
5670
+ }
5671
+ function getEndpointUrl() {
5672
+ const configured = normalizeString2(process.env.PDF_ENDPOINT_URL) ?? normalizeString2(pdfSection().endpointUrl);
5673
+ if (!configured) return null;
5674
+ const protocol = URL.parse(configured)?.protocol;
5675
+ if (protocol !== "http:" && protocol !== "https:") {
5676
+ throw new Error(
5677
+ `Failed to parse pdf.endpointUrl: expected an absolute http(s) URL, got "${configured}"`
5678
+ );
5679
+ }
5680
+ return configured.replace(/\/+$/, "");
5681
+ }
5682
+ function getEndpointTimeoutMs() {
5683
+ const configured = pdfSection().endpointTimeoutMs;
5684
+ if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) {
5685
+ return Math.min(configured, 3e5);
5686
+ }
5687
+ return DEFAULT_TIMEOUT_MS2;
5688
+ }
5689
+ function isEndpointApiAvailable() {
5690
+ try {
5691
+ return getEndpointUrl() !== null;
5692
+ } catch {
5693
+ return true;
5694
+ }
5695
+ }
5696
+ async function readCapped(response, maxBytes, overflowThrows) {
5697
+ const reader = response.body?.getReader();
5698
+ if (!reader) return "";
5699
+ const decoder = new TextDecoder();
5700
+ let text4 = "";
5701
+ let received = 0;
5702
+ for (; ; ) {
5703
+ const { done, value } = await reader.read();
5704
+ if (done) return text4 + decoder.decode();
5705
+ const room = maxBytes - received;
5706
+ received += value.byteLength;
5707
+ if (received >= maxBytes) {
5708
+ await reader.cancel();
5709
+ if (overflowThrows && received > maxBytes) {
5710
+ throw new Error("PDF parser endpoint returned an oversized response");
5711
+ }
5712
+ return text4 + decoder.decode(value.subarray(0, room));
5713
+ }
5714
+ text4 += decoder.decode(value, { stream: true });
5715
+ }
5716
+ }
5717
+ async function readJson(response) {
5718
+ const text4 = await readCapped(response, MAX_RESPONSE_BYTES2, true);
5719
+ try {
5720
+ const parsed = JSON.parse(text4);
5721
+ if (parsed && typeof parsed === "object") return parsed;
5722
+ } catch {
5723
+ }
5724
+ throw new Error("PDF parser endpoint returned a non-JSON response");
5725
+ }
5726
+ async function errorBody(response) {
5727
+ try {
5728
+ const text4 = await readCapped(response, MAX_ERROR_BODY_BYTES2, false);
5729
+ return text4 ? `: ${text4}` : "";
5730
+ } catch {
5731
+ return "";
5732
+ }
5733
+ }
5734
+ function markdownResult(payload) {
5735
+ const markdown = typeof payload.markdown === "string" ? payload.markdown.replaceAll("\0", "") : "";
5736
+ if (markdown.trim().length === 0) {
5737
+ const error = normalizeString2(payload.error);
5738
+ throw new Error(
5739
+ error ? `PDF parser endpoint failed: ${error}` : "PDF parser endpoint returned no markdown"
5740
+ );
5741
+ }
5742
+ return { markdown, pages: typeof payload.pages === "number" ? payload.pages : void 0 };
5743
+ }
5744
+ async function extractPDFViaEndpoint(buffer, options) {
5745
+ options.signal?.throwIfAborted();
5746
+ const endpointUrl2 = getEndpointUrl();
5747
+ if (!endpointUrl2) {
5748
+ throw new Error("PDF endpoint extraction requires a configured pdf.endpointUrl");
5749
+ }
5750
+ const ssrf = loadSsrfConfig();
5751
+ const guard = {
5752
+ allowRanges: ssrf.allowRanges,
5753
+ trustEnvProxy: ssrf.trustEnvProxy,
5754
+ allowLoopback: isLoopbackHostname(new URL(endpointUrl2).hostname),
5755
+ ...options.lookup ? { lookup: options.lookup } : {}
5756
+ };
5757
+ const engine = normalizeString2(pdfSection().endpointEngine);
5758
+ const form = new FormData();
5759
+ form.append("file", new Blob([buffer], { type: "application/pdf" }), "document.pdf");
5760
+ if (engine) form.append("engine", engine);
5761
+ form.append("max_pages", String(options.maxPages));
5762
+ const timeoutMs = options.timeoutMs ?? getEndpointTimeoutMs();
5763
+ const deadline = Date.now() + timeoutMs;
5764
+ const signal = options.signal;
5765
+ const timeout = AbortSignal.timeout(timeoutMs);
5766
+ const combined = signal ? AbortSignal.any([signal, timeout]) : timeout;
5767
+ const response = await fetchRemoteUrl(
5768
+ endpointUrl2,
5769
+ { method: "POST", body: form, signal: combined },
5770
+ guard
5771
+ );
5772
+ if (!response.ok) {
5773
+ throw new Error(
5774
+ `PDF parser endpoint returned HTTP ${response.status}${await errorBody(response)}`
5775
+ );
5776
+ }
5777
+ let payload = await readJson(response);
5778
+ const jobId = normalizeString2(payload.job_id);
5779
+ if (typeof payload.markdown === "string" || !jobId) {
5780
+ return markdownResult(payload);
5781
+ }
5782
+ const jobsUrl = new URL(`jobs/${encodeURIComponent(jobId)}`, endpointUrl2).toString();
5783
+ for (let interval = 1e3; Date.now() < deadline; interval = Math.min(interval * 2, MAX_POLL_INTERVAL_MS)) {
5784
+ await sleep2(Math.min(interval, deadline - Date.now()), void 0, { signal });
5785
+ const poll = await fetchRemoteUrl(jobsUrl, { signal: combined }, guard);
5786
+ if (!poll.ok) {
5787
+ throw new Error(
5788
+ `PDF parser job status returned HTTP ${poll.status}${await errorBody(poll)}`
5789
+ );
5790
+ }
5791
+ payload = await readJson(poll);
5792
+ const status = normalizeString2(payload.status)?.toLowerCase();
5793
+ if (status === "error" || status === "failed") {
5794
+ const error = normalizeString2(payload.error) ?? "unknown parser error";
5795
+ throw new Error(`PDF parser endpoint job failed: ${error}`);
5796
+ }
5797
+ if (status === "done") {
5798
+ let result = payload.result;
5799
+ if (typeof result === "string") {
5800
+ const raw = result;
5801
+ try {
5802
+ result = JSON.parse(raw);
5803
+ } catch {
5804
+ return { markdown: raw.replaceAll("\0", "") };
5805
+ }
5806
+ }
5807
+ if (result && typeof result === "object") return markdownResult(result);
5808
+ throw new Error("PDF parser endpoint job completed without a result");
5809
+ }
5810
+ }
5811
+ throw new Error("PDF parser endpoint job timed out");
5812
+ }
5813
+ var DEFAULT_TIMEOUT_MS2, MAX_POLL_INTERVAL_MS, MAX_RESPONSE_BYTES2, MAX_ERROR_BODY_BYTES2, CONFIG_PATH40;
5814
+ var init_endpoint_pdf_extract = __esm({
5815
+ "endpoint-pdf-extract.ts"() {
5816
+ init_ssrf_protection();
5817
+ init_utils();
5818
+ DEFAULT_TIMEOUT_MS2 = 12e4;
5819
+ MAX_POLL_INTERVAL_MS = 3e3;
5820
+ MAX_RESPONSE_BYTES2 = 4 * 1024 * 1024;
5821
+ MAX_ERROR_BODY_BYTES2 = 300;
5822
+ CONFIG_PATH40 = getWebSearchConfigPath();
5823
+ }
5824
+ });
5825
+
5603
5826
  // gemini-pdf-extract.ts
5604
5827
  import { Buffer as Buffer2 } from "node:buffer";
5605
5828
  async function extractPDFViaGemini(buffer, options) {
@@ -5611,7 +5834,7 @@ async function extractPDFViaGemini(buffer, options) {
5611
5834
  PDF_MIME_TYPE,
5612
5835
  {
5613
5836
  signal: options.signal,
5614
- timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS2
5837
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS3
5615
5838
  }
5616
5839
  );
5617
5840
  if (result.blockReason) {
@@ -5675,23 +5898,23 @@ function removeDuplicateInitialTitle(markdown, title) {
5675
5898
  function normalizeTitle(value) {
5676
5899
  return value.normalize("NFKC").toLocaleLowerCase().replace(/[`*_~]/g, "").replace(/[\p{P}\p{S}\s]+/gu, "");
5677
5900
  }
5678
- var PDF_MIME_TYPE, DEFAULT_TIMEOUT_MS2, PAGE_MARKER_PATTERN;
5901
+ var PDF_MIME_TYPE, DEFAULT_TIMEOUT_MS3, PAGE_MARKER_PATTERN;
5679
5902
  var init_gemini_pdf_extract = __esm({
5680
5903
  "gemini-pdf-extract.ts"() {
5681
5904
  init_gemini_api();
5682
5905
  PDF_MIME_TYPE = "application/pdf";
5683
- DEFAULT_TIMEOUT_MS2 = 12e4;
5906
+ DEFAULT_TIMEOUT_MS3 = 12e4;
5684
5907
  PAGE_MARKER_PATTERN = /^<!-- Page (\d+) -->$/gm;
5685
5908
  }
5686
5909
  });
5687
5910
 
5688
5911
  // pdf-extract.ts
5689
- import { existsSync as existsSync43, readFileSync as readFileSync45 } from "node:fs";
5912
+ import { existsSync as existsSync44, readFileSync as readFileSync46 } from "node:fs";
5690
5913
  import { writeFile as writeFile2, mkdir } from "node:fs/promises";
5691
5914
  import { join as join5, basename as basename2 } from "node:path";
5692
5915
  import { tmpdir as tmpdir3 } from "node:os";
5693
5916
  function loadPDFConfig() {
5694
- if (!existsSync43(CONFIG_PATH40)) {
5917
+ if (!existsSync44(CONFIG_PATH41)) {
5695
5918
  return {
5696
5919
  enabled: true,
5697
5920
  maxSizeMB: DEFAULT_PDF_MAX_SIZE_MB,
@@ -5701,13 +5924,13 @@ function loadPDFConfig() {
5701
5924
  datalabTimeoutMs: DEFAULT_DATALAB_TIMEOUT_MS
5702
5925
  };
5703
5926
  }
5704
- const rawText = readFileSync45(CONFIG_PATH40, "utf-8");
5927
+ const rawText = readFileSync46(CONFIG_PATH41, "utf-8");
5705
5928
  let raw;
5706
5929
  try {
5707
5930
  raw = JSON.parse(rawText);
5708
5931
  } catch (err) {
5709
5932
  const message = err instanceof Error ? err.message : String(err);
5710
- throw new Error(`Failed to parse ${CONFIG_PATH40}: ${message}`);
5933
+ throw new Error(`Failed to parse ${CONFIG_PATH41}: ${message}`);
5711
5934
  }
5712
5935
  const root = raw && typeof raw === "object" ? raw : {};
5713
5936
  const pdf = root.pdf && typeof root.pdf === "object" ? root.pdf : {};
@@ -5753,6 +5976,31 @@ async function extractPDFToMarkdown(buffer, url, options = {}) {
5753
5976
  const safeMaxPages = maxPages === void 0 ? pdfConfig.maxPages : Number.isFinite(maxPages) ? Math.max(1, Math.floor(maxPages)) : DEFAULT_MAX_PAGES;
5754
5977
  const urlTitle = extractTitleFromURL(url);
5755
5978
  const provider = pdfConfig.provider;
5979
+ if (provider === "auto" || provider === "endpoint") {
5980
+ if (provider === "endpoint" && !isEndpointApiAvailable()) {
5981
+ throw new Error(
5982
+ 'PDF provider "endpoint" requires a configured pdf.endpointUrl'
5983
+ );
5984
+ }
5985
+ try {
5986
+ if (isEndpointApiAvailable()) {
5987
+ const result = await extractPDFViaEndpoint(buffer, {
5988
+ maxPages: safeMaxPages,
5989
+ ...signal ? { signal } : {}
5990
+ });
5991
+ return writeMarkdownResult({
5992
+ markdownBody: result.markdown,
5993
+ title: urlTitle,
5994
+ pages: result.pages ?? countPageMarkers2(result.markdown),
5995
+ outputDir,
5996
+ filename,
5997
+ url
5998
+ });
5999
+ }
6000
+ } catch (err) {
6001
+ if (shouldRethrowExtractionError(err, signal)) throw err;
6002
+ }
6003
+ }
5756
6004
  if (provider === "auto" || provider === "datalab") {
5757
6005
  try {
5758
6006
  if (isDatalabApiAvailable()) {
@@ -5847,9 +6095,11 @@ async function writeMarkdownResult(options) {
5847
6095
  lines.push(`# ${options.title}`);
5848
6096
  lines.push("");
5849
6097
  lines.push(`> Source: ${options.url}`);
5850
- lines.push(
5851
- `> Pages: ${options.pages}${options.truncated ? ` (extracted first ${options.pagesToExtract})` : ""}`
5852
- );
6098
+ if (options.pages > 0) {
6099
+ lines.push(
6100
+ `> Pages: ${options.pages}${options.truncated ? ` (extracted first ${options.pagesToExtract})` : ""}`
6101
+ );
6102
+ }
5853
6103
  if (options.metaAuthor) lines.push(`> Author: ${options.metaAuthor}`);
5854
6104
  lines.push("");
5855
6105
  lines.push("---");
@@ -5916,16 +6166,18 @@ function isPDF(url, contentType) {
5916
6166
  return false;
5917
6167
  }
5918
6168
  }
5919
- 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_PATH40, PAGE_MARKER_PATTERN2;
6169
+ 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_PATH41, PAGE_MARKER_PATTERN2;
5920
6170
  var init_pdf_extract = __esm({
5921
6171
  "pdf-extract.ts"() {
5922
6172
  init_credential_source();
5923
6173
  init_datalab_pdf_extract();
5924
6174
  init_gemini_api();
6175
+ init_endpoint_pdf_extract();
5925
6176
  init_gemini_pdf_extract();
5926
6177
  init_utils();
5927
6178
  PDF_PROVIDER_VALUES = /* @__PURE__ */ new Set([
5928
6179
  "auto",
6180
+ "endpoint",
5929
6181
  "gemini",
5930
6182
  "datalab",
5931
6183
  "unpdf"
@@ -5935,7 +6187,7 @@ var init_pdf_extract = __esm({
5935
6187
  MAX_DATALAB_TIMEOUT_MS = 3e5;
5936
6188
  DEFAULT_MAX_PAGES = 100;
5937
6189
  DEFAULT_OUTPUT_DIR = join5(tmpdir3(), "pi-web-pdf");
5938
- CONFIG_PATH40 = getWebSearchConfigPath();
6190
+ CONFIG_PATH41 = getWebSearchConfigPath();
5939
6191
  PAGE_MARKER_PATTERN2 = /^<!-- Page (\d+) -->$/gm;
5940
6192
  }
5941
6193
  });
@@ -6113,7 +6365,7 @@ var init_github_api = __esm({
6113
6365
  });
6114
6366
 
6115
6367
  // github-extract.ts
6116
- import { chmodSync, closeSync as closeSync2, constants as fsConstants, existsSync as existsSync44, lstatSync as lstatSync2, mkdirSync as mkdirSync2, mkdtempSync as mkdtempSync2, openSync as openSync2, readFileSync as readFileSync46, readSync, readdirSync as readdirSync3, realpathSync as realpathSync2, rmSync as rmSync2, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "node:fs";
6368
+ import { chmodSync, closeSync as closeSync2, constants as fsConstants, existsSync as existsSync45, lstatSync as lstatSync2, mkdirSync as mkdirSync2, mkdtempSync as mkdtempSync2, openSync as openSync2, readFileSync as readFileSync47, readSync, readdirSync as readdirSync3, realpathSync as realpathSync2, rmSync as rmSync2, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "node:fs";
6117
6369
  import { lstat as lstatAsync, open as openAsync, opendir as opendirAsync, readFile as readFileAsync, realpath as realpathAsync, rm as rmAsync } from "node:fs/promises";
6118
6370
  import { execFile as execFile3, spawn as spawn2 } from "node:child_process";
6119
6371
  import { createHash as createHash2 } from "node:crypto";
@@ -6149,17 +6401,17 @@ function loadGitHubConfig() {
6149
6401
  cloneTimeoutSeconds: 30,
6150
6402
  clonePath: "/tmp/pi-github-repos"
6151
6403
  };
6152
- if (!existsSync44(CONFIG_PATH41)) {
6404
+ if (!existsSync45(CONFIG_PATH42)) {
6153
6405
  cachedConfig36 = defaults2;
6154
6406
  return cachedConfig36;
6155
6407
  }
6156
- const rawText = readFileSync46(CONFIG_PATH41, "utf-8");
6408
+ const rawText = readFileSync47(CONFIG_PATH42, "utf-8");
6157
6409
  let raw;
6158
6410
  try {
6159
6411
  raw = JSON.parse(rawText);
6160
6412
  } catch (err) {
6161
6413
  const message = err instanceof Error ? err.message : String(err);
6162
- throw new Error(`Failed to parse ${CONFIG_PATH41}: ${message}`);
6414
+ throw new Error(`Failed to parse ${CONFIG_PATH42}: ${message}`);
6163
6415
  }
6164
6416
  const gc = raw.githubClone ?? {};
6165
6417
  cachedConfig36 = {
@@ -6219,7 +6471,7 @@ function cacheKey(owner, repo, ref) {
6219
6471
  }
6220
6472
  function readLinuxBootId() {
6221
6473
  try {
6222
- const bootId = readFileSync46("/proc/sys/kernel/random/boot_id", "utf-8").trim();
6474
+ const bootId = readFileSync47("/proc/sys/kernel/random/boot_id", "utf-8").trim();
6223
6475
  return bootId.length > 0 ? bootId : null;
6224
6476
  } catch {
6225
6477
  return null;
@@ -6244,7 +6496,7 @@ function parseLinuxProcessInfo(stat) {
6244
6496
  }
6245
6497
  function readLinuxProcessInfo(pid) {
6246
6498
  try {
6247
- return parseLinuxProcessInfo(readFileSync46(`/proc/${pid}/stat`, "utf-8"));
6499
+ return parseLinuxProcessInfo(readFileSync47(`/proc/${pid}/stat`, "utf-8"));
6248
6500
  } catch (err) {
6249
6501
  if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
6250
6502
  return { state: "", startTime: null, dead: true };
@@ -6582,7 +6834,7 @@ function resolveWithinRepo(rootPath, relativePath) {
6582
6834
  const rootPrefix = normalizedRoot.endsWith(pathSep) ? normalizedRoot : normalizedRoot + pathSep;
6583
6835
  if (!candidate.startsWith(rootPrefix)) return null;
6584
6836
  }
6585
- if (!existsSync44(candidate)) return candidate;
6837
+ if (!existsSync45(candidate)) return candidate;
6586
6838
  try {
6587
6839
  const realRoot = realpathSync2(normalizedRoot);
6588
6840
  const realCandidate = realpathSync2(candidate);
@@ -6595,7 +6847,7 @@ function resolveWithinRepo(rootPath, relativePath) {
6595
6847
  }
6596
6848
  function readTextFile(path) {
6597
6849
  try {
6598
- return readFileSync46(path, "utf-8");
6850
+ return readFileSync47(path, "utf-8");
6599
6851
  } catch {
6600
6852
  return null;
6601
6853
  }
@@ -6678,9 +6930,9 @@ function readReadme(localPath) {
6678
6930
  const candidates = ["README.md", "readme.md", "README", "README.txt", "README.rst"];
6679
6931
  for (const name of candidates) {
6680
6932
  const readmePath = join6(localPath, name);
6681
- if (existsSync44(readmePath)) {
6933
+ if (existsSync45(readmePath)) {
6682
6934
  try {
6683
- const content = readFileSync46(readmePath, "utf-8");
6935
+ const content = readFileSync47(readmePath, "utf-8");
6684
6936
  return content.length > 8192 ? content.slice(0, 8192) + "\n\n[README truncated at 8K chars]" : content;
6685
6937
  } catch {
6686
6938
  continue;
@@ -6709,7 +6961,7 @@ function generateContent(localPath, info) {
6709
6961
  if (info.type === "tree") {
6710
6962
  const dirPath = info.path || "";
6711
6963
  const fullDirPath = resolveWithinRepo(localPath, dirPath);
6712
- if (!fullDirPath || !existsSync44(fullDirPath)) {
6964
+ if (!fullDirPath || !existsSync45(fullDirPath)) {
6713
6965
  lines.push(`Path \`${dirPath}\` not found in clone. Showing repository root instead.`);
6714
6966
  lines.push("");
6715
6967
  lines.push("## Structure");
@@ -6725,7 +6977,7 @@ function generateContent(localPath, info) {
6725
6977
  if (info.type === "blob") {
6726
6978
  const filePath = info.path || "";
6727
6979
  const fullFilePath = resolveWithinRepo(localPath, filePath);
6728
- if (!fullFilePath || !existsSync44(fullFilePath)) {
6980
+ if (!fullFilePath || !existsSync45(fullFilePath)) {
6729
6981
  lines.push(`Path \`${filePath}\` not found in clone. Showing repository root instead.`);
6730
6982
  lines.push("");
6731
6983
  lines.push("## Structure");
@@ -6887,13 +7139,13 @@ async function extractGitHub(url, signal, forceClone) {
6887
7139
  const title = info.path ? `${owner}/${repo} - ${info.path}` : `${owner}/${repo}`;
6888
7140
  return { url, title, content, error: null };
6889
7141
  }
6890
- var CONFIG_PATH41, BINARY_EXTENSIONS, NOISE_DIRS, MAX_INLINE_FILE_CHARS2, MAX_TREE_ENTRIES2, CLONE_RUNTIME_OWNER_FILENAME, CLONE_RUNTIME_OWNER_VERSION, MAX_CLONE_RUNTIME_OWNER_BYTES, cloneCache, startedCloneRuntimeCleanups, cachedConfig36, cloneRuntime, NON_CODE_SEGMENTS, PROCESS_KILL_GRACE_MS;
7142
+ var CONFIG_PATH42, BINARY_EXTENSIONS, NOISE_DIRS, MAX_INLINE_FILE_CHARS2, MAX_TREE_ENTRIES2, CLONE_RUNTIME_OWNER_FILENAME, CLONE_RUNTIME_OWNER_VERSION, MAX_CLONE_RUNTIME_OWNER_BYTES, cloneCache, startedCloneRuntimeCleanups, cachedConfig36, cloneRuntime, NON_CODE_SEGMENTS, PROCESS_KILL_GRACE_MS;
6891
7143
  var init_github_extract = __esm({
6892
7144
  "github-extract.ts"() {
6893
7145
  init_activity();
6894
7146
  init_github_api();
6895
7147
  init_utils();
6896
- CONFIG_PATH41 = getWebSearchConfigPath();
7148
+ CONFIG_PATH42 = getWebSearchConfigPath();
6897
7149
  BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
6898
7150
  ".png",
6899
7151
  ".jpg",
@@ -7020,25 +7272,25 @@ var init_github_extract = __esm({
7020
7272
 
7021
7273
  // github-issue-pr.ts
7022
7274
  import { execFile as execFile4 } from "node:child_process";
7023
- import { existsSync as existsSync45, readFileSync as readFileSync47 } from "node:fs";
7275
+ import { existsSync as existsSync46, readFileSync as readFileSync48 } from "node:fs";
7024
7276
  function loadConfig37() {
7025
7277
  if (cachedConfig37) return cachedConfig37;
7026
7278
  const defaults2 = { enabled: true };
7027
- if (!existsSync45(CONFIG_PATH42)) {
7279
+ if (!existsSync46(CONFIG_PATH43)) {
7028
7280
  cachedConfig37 = defaults2;
7029
7281
  return cachedConfig37;
7030
7282
  }
7031
7283
  let parsed;
7032
7284
  try {
7033
- parsed = JSON.parse(readFileSync47(CONFIG_PATH42, "utf-8"));
7285
+ parsed = JSON.parse(readFileSync48(CONFIG_PATH43, "utf-8"));
7034
7286
  } catch (err) {
7035
7287
  const message = err instanceof Error ? err.message : String(err);
7036
- throw new Error(`Failed to parse ${CONFIG_PATH42}: ${message}`);
7288
+ throw new Error(`Failed to parse ${CONFIG_PATH43}: ${message}`);
7037
7289
  }
7038
7290
  const root = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
7039
7291
  const value = root.githubPrIssue;
7040
7292
  if (value !== void 0 && (typeof value !== "object" || value === null || Array.isArray(value))) {
7041
- throw new Error(`githubPrIssue in ${CONFIG_PATH42} must be an object`);
7293
+ throw new Error(`githubPrIssue in ${CONFIG_PATH43} must be an object`);
7042
7294
  }
7043
7295
  const enabled = typeof value?.enabled === "boolean" ? value.enabled : true;
7044
7296
  cachedConfig37 = { enabled };
@@ -7348,23 +7600,38 @@ function milestoneTitle(value) {
7348
7600
  if (!value || typeof value !== "object" || Array.isArray(value)) return "none";
7349
7601
  return stringValue(value.title) || "none";
7350
7602
  }
7351
- function truncateText(text4, limit, label, appendix) {
7603
+ function truncateText(text4, limit, label, appendix, tool) {
7352
7604
  if (text4.length <= limit) return text4;
7353
- appendix.push(`## Full ${label}
7605
+ const lastSpace = text4.slice(0, limit + 1).search(/\s\S*$/);
7606
+ const cut = lastSpace > limit * 0.8 ? lastSpace : limit;
7607
+ appendix.push(`## ${label} (continued)
7608
+
7609
+ ${text4.slice(cut)}`);
7610
+ return `${text4.slice(0, cut)}
7354
7611
 
7355
- ${text4}`);
7356
- return `${text4.slice(0, limit)}
7612
+ [${label} truncated; ${tool ? `the rest is stored under "${label} (continued)": use ${tool} findText or offset` : "use the gh escalation commands below for the rest"}]`;
7613
+ }
7614
+ function storeOmitted(appendix, section, items) {
7615
+ if (items.length > 0) appendix.push(`## ${section} (continued)
7357
7616
 
7358
- [${label} truncated; use get_search_content findText or offset for the full text]`;
7617
+ ${items.join("\n")}`);
7618
+ }
7619
+ function omissionMarker(section, noun, shown, fetched, atLeast, tool, gh = "the gh command below") {
7620
+ const stored = fetched > shown && tool ? `${fetched - shown} more stored under "${section} (continued)": use ${tool} findText or offset` : "";
7621
+ if (atLeast !== null) return `[${shown} ${noun} shown from at least ${atLeast}; ${stored ? `${stored}; for the rest ` : ""}use ${gh}]`;
7622
+ if (fetched <= shown) return null;
7623
+ return `[${shown} of ${fetched} ${noun} shown; ${stored ? `${stored}, or ${gh}` : `use ${gh}`}]`;
7359
7624
  }
7360
- function appendLimitedSection(lines, title, items, max, marker) {
7625
+ function appendLimitedSection(lines, title, items, max, marker, appendix, tool) {
7361
7626
  lines.push(`## ${title}`);
7362
7627
  if (items.length === 0) {
7363
7628
  lines.push("none", "");
7364
7629
  return;
7365
7630
  }
7366
7631
  lines.push(...items.slice(0, max));
7367
- if (items.length > max) lines.push(`[${max} of ${items.length} ${marker} shown; use get_search_content offset or the gh command below for more]`);
7632
+ storeOmitted(appendix, title, items.slice(max));
7633
+ const omitted = omissionMarker(title, marker, max, items.length, null, tool);
7634
+ if (omitted) lines.push(omitted);
7368
7635
  lines.push("");
7369
7636
  }
7370
7637
  function objectArray(value) {
@@ -7379,26 +7646,21 @@ function anchorMatches(anchor, comment) {
7379
7646
  const id = commentId(comment);
7380
7647
  return anchor === `issuecomment-${id}` || anchor === `discussion_r${id}`;
7381
7648
  }
7382
- function renderComments(comments, anchor, appendix) {
7649
+ function renderComments(comments, anchor, appendix, tool) {
7383
7650
  const forced = anchor ? comments.find((comment) => anchorMatches(anchor, comment)) : void 0;
7384
7651
  const selected = comments.slice(0, MAX_INLINE_COMMENTS);
7385
7652
  if (forced && !selected.includes(forced)) selected.push(forced);
7386
- const lines = selected.map((comment) => {
7653
+ const render = (comment, inline) => {
7387
7654
  const body = stringValue(comment.body);
7388
- const label = `comment ${commentId(comment) || selected.indexOf(comment) + 1}`;
7655
+ const label = `comment ${commentId(comment) || comments.indexOf(comment) + 1}`;
7656
+ const text4 = inline ? truncateText(body, COMMENT_INLINE_CHARS, label, appendix, tool) : body;
7389
7657
  return `- ${authorLogin(comment.author ?? comment.user)} at ${stringValue(comment.createdAt) || stringValue(comment.created_at)}${forced === comment ? " [anchored]" : ""}:
7390
- ${truncateText(body, COMMENT_INLINE_CHARS, label, appendix).replace(/\n/g, "\n ")}`;
7391
- });
7658
+ ${text4.replace(/\n/g, "\n ")}`;
7659
+ };
7660
+ const lines = selected.map((comment) => render(comment, true));
7661
+ storeOmitted(appendix, "Conversation comments", comments.slice(MAX_INLINE_COMMENTS).filter((comment) => comment !== forced).map((comment) => render(comment, false)));
7392
7662
  return lines;
7393
7663
  }
7394
- function renderCommentMarker(comments, renderedCount, total) {
7395
- const knownTotal = numberValue(total);
7396
- if (knownTotal !== null && knownTotal > comments.length) {
7397
- return `[${renderedCount} comments shown from at least ${knownTotal}; use get_search_content findText or offset, or gh issue view -c]`;
7398
- }
7399
- if (comments.length > renderedCount) return `[${renderedCount} of ${comments.length} comments shown; use get_search_content findText or offset, or gh issue view -c]`;
7400
- return null;
7401
- }
7402
7664
  function commentCountText(view) {
7403
7665
  const comments = objectArray(view.comments).length;
7404
7666
  const total = numberValue(view.commentsCount);
@@ -7412,7 +7674,7 @@ function reviewThreadCountText(comments, total, bounded, unavailable) {
7412
7674
  if (knownTotal !== null && knownTotal > comments.length) return `at least ${knownTotal}`;
7413
7675
  return String(comments.length || knownTotal || 0);
7414
7676
  }
7415
- function renderChecks(value) {
7677
+ function renderChecks(value, appendix, tool) {
7416
7678
  const checks = objectArray(value);
7417
7679
  if (checks.length === 0) return ["No check rollup data available."];
7418
7680
  const rows = checks.map((check) => {
@@ -7421,19 +7683,21 @@ function renderChecks(value) {
7421
7683
  return `- ${name}: ${state}`;
7422
7684
  });
7423
7685
  const failing = rows.filter((row) => !/(success|neutral|skipped|completed)$/i.test(row));
7424
- 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), ...rows.length > MAX_INLINE_CHECKS ? [`[${MAX_INLINE_CHECKS} of ${rows.length} checks shown]`] : []];
7686
+ storeOmitted(appendix, "Checks", rows.slice(MAX_INLINE_CHECKS));
7687
+ const omitted = omissionMarker("Checks", "checks", MAX_INLINE_CHECKS, rows.length, null, tool);
7688
+ 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] : []];
7425
7689
  }
7426
- function renderReviewVerdicts(value, appendix) {
7690
+ function renderReviewVerdicts(value, appendix, tool) {
7427
7691
  const latest = /* @__PURE__ */ new Map();
7428
7692
  for (const review of objectArray(value)) latest.set(authorLogin(review.author ?? review.user), review);
7429
7693
  return [...latest.entries()].map(([author, review]) => {
7430
7694
  const state = stringValue(review.state) || "COMMENTED";
7431
- const body = truncateText(stringValue(review.body), 300, `review by ${author}`, appendix);
7695
+ const body = truncateText(stringValue(review.body), 300, `review by ${author}`, appendix, tool);
7432
7696
  return `- ${author}: ${state}${body ? ` \u2014 ${body.replace(/\n/g, " ")}` : ""}`;
7433
7697
  });
7434
7698
  }
7435
- function renderReviewVerdictsOrUnavailable(view, appendix) {
7436
- const rendered = renderReviewVerdicts(view.reviews, appendix);
7699
+ function renderReviewVerdictsOrUnavailable(view, appendix, tool) {
7700
+ const rendered = renderReviewVerdicts(view.reviews, appendix, tool);
7437
7701
  if (rendered.length > 0) return rendered;
7438
7702
  return view.reviewsUnavailable === true ? ["Unavailable in this GitHub fetch path; use gh for review verdicts."] : [];
7439
7703
  }
@@ -7445,25 +7709,15 @@ function renderFiles(value) {
7445
7709
  return `- ${path} (+${additions}/\u2212${deletions})`;
7446
7710
  });
7447
7711
  }
7448
- function appendFilesSection(lines, view) {
7712
+ function appendFilesSection(lines, view, appendix, tool) {
7449
7713
  lines.push("## Files");
7450
7714
  const files = renderFiles(view.files);
7451
- if (files.length === 0) {
7452
- const total2 = numberValue(view.changedFiles);
7453
- if (total2 !== null && total2 > 0) {
7454
- lines.push(`[0 files shown from at least ${total2}; use get_search_content offset or the gh command below for more]`, "");
7455
- return;
7456
- }
7457
- lines.push("none", "");
7458
- return;
7459
- }
7460
- lines.push(...files.slice(0, MAX_INLINE_FILES));
7461
7715
  const total = numberValue(view.changedFiles);
7462
- if (total !== null && total > files.length) {
7463
- lines.push(`[${Math.min(files.length, MAX_INLINE_FILES)} files shown from at least ${total}; use get_search_content offset or the gh command below for more]`);
7464
- } else if (files.length > MAX_INLINE_FILES) {
7465
- lines.push(`[${MAX_INLINE_FILES} of ${files.length} files shown; use get_search_content offset or the gh command below for more]`);
7466
- }
7716
+ const omitted = omissionMarker("Files", "files", Math.min(files.length, MAX_INLINE_FILES), files.length, total !== null && total > files.length ? total : null, tool);
7717
+ if (files.length === 0 && !omitted) lines.push("none");
7718
+ lines.push(...files.slice(0, MAX_INLINE_FILES));
7719
+ storeOmitted(appendix, "Files", files.slice(MAX_INLINE_FILES));
7720
+ if (omitted) lines.push(omitted);
7467
7721
  lines.push("");
7468
7722
  }
7469
7723
  function renderCommits(value) {
@@ -7486,31 +7740,31 @@ function renderLinkedOrUnavailable(view, field, kind) {
7486
7740
  if (linked.length > 0) return linked;
7487
7741
  return view.linkedReferencesUnavailable === true ? ["Unavailable in this GitHub fetch path; use gh for linked references."] : [];
7488
7742
  }
7489
- function renderReviewThreads(comments, anchor, appendix, total, bounded, unavailable) {
7743
+ function renderReviewThreads(comments, anchor, appendix, tool, total, bounded, unavailable) {
7490
7744
  if (unavailable) return ["Unavailable in this GitHub fetch path; use gh for review thread comments."];
7491
7745
  const forced = anchor ? comments.find((comment) => anchorMatches(anchor, comment)) : void 0;
7492
7746
  const selected = comments.slice(0, MAX_INLINE_REVIEW_THREADS);
7493
7747
  if (forced && !selected.includes(forced)) selected.push(forced);
7494
- const lines = selected.map((comment) => {
7748
+ const render = (comment, inline) => {
7495
7749
  const path = stringValue(comment.path) || "unknown path";
7496
7750
  const line = numberValue(comment.line) ?? numberValue(comment.original_line) ?? numberValue(comment.position) ?? "?";
7497
- const body = truncateText(stringValue(comment.body), COMMENT_INLINE_CHARS, `review thread comment ${commentId(comment) || selected.indexOf(comment) + 1}`, appendix);
7751
+ const text4 = stringValue(comment.body);
7752
+ const body = inline ? truncateText(text4, COMMENT_INLINE_CHARS, `review thread comment ${commentId(comment) || comments.indexOf(comment) + 1}`, appendix, tool) : text4;
7498
7753
  return `- ${path}:${line} \u2014 ${authorLogin(comment.user ?? comment.author)}${forced === comment ? " [anchored]" : ""} (resolution state unknown):
7499
7754
  ${body.replace(/\n/g, "\n ")}`;
7500
- });
7755
+ };
7756
+ const lines = selected.map((comment) => render(comment, true));
7757
+ storeOmitted(appendix, "Review thread comments", comments.slice(MAX_INLINE_REVIEW_THREADS).filter((comment) => comment !== forced).map((comment) => render(comment, false)));
7501
7758
  const knownTotal = numberValue(total);
7502
- if (bounded) {
7503
- lines.push(`[${selected.length} review thread comments shown from at least ${comments.length}; use get_search_content offset, or gh api repos/<owner>/<repo>/pulls/<number>/comments]`);
7504
- } else if (knownTotal !== null && knownTotal > comments.length) {
7505
- 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]`);
7506
- } else if (comments.length > selected.length) {
7507
- 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]`);
7508
- }
7759
+ const atLeast = bounded ? comments.length : knownTotal !== null && knownTotal > comments.length ? knownTotal : null;
7760
+ const omitted = omissionMarker("Review thread comments", "review thread comments", selected.length, comments.length, atLeast, tool, "gh api repos/<owner>/<repo>/pulls/<number>/comments");
7761
+ if (omitted) lines.push(omitted);
7509
7762
  return lines;
7510
7763
  }
7511
7764
  function renderGitHubPrIssue(data) {
7512
7765
  const { view } = data;
7513
7766
  const appendix = [];
7767
+ const tool = data.retrievalTool === void 0 ? "get_search_content" : data.retrievalTool;
7514
7768
  const title = stringValue(view.title) || `${data.owner}/${data.repo}#${data.number}`;
7515
7769
  const number = numberValue(view.number) ?? data.number;
7516
7770
  const stateParts = [stringValue(view.state) || "unknown"];
@@ -7538,45 +7792,48 @@ function renderGitHubPrIssue(data) {
7538
7792
  if (data.anchor) lines.push(`- requested anchor: #${data.anchor}`);
7539
7793
  lines.push("");
7540
7794
  lines.push("## Body");
7541
- lines.push(truncateText(stringValue(view.body) || "(empty)", BODY_INLINE_CHARS, "body", appendix), "");
7795
+ lines.push(truncateText(stringValue(view.body) || "(empty)", BODY_INLINE_CHARS, "body", appendix, tool), "");
7542
7796
  if (data.kind === "pull") {
7543
7797
  lines.push("## Checks");
7544
- lines.push(...renderChecks(view.statusCheckRollup), "");
7545
- appendLimitedSection(lines, "Review verdicts", renderReviewVerdictsOrUnavailable(view, appendix), MAX_INLINE_REVIEWS, "review verdicts");
7546
- appendLimitedSection(lines, "Linked references", renderLinkedOrUnavailable(view, "closingIssuesReferences", "closing"), 20, "linked references");
7547
- appendFilesSection(lines, view);
7548
- appendLimitedSection(lines, "Commits", renderCommitsOrUnavailable(view), MAX_INLINE_COMMITS, "commits");
7798
+ lines.push(...renderChecks(view.statusCheckRollup, appendix, tool), "");
7799
+ appendLimitedSection(lines, "Review verdicts", renderReviewVerdictsOrUnavailable(view, appendix, tool), MAX_INLINE_REVIEWS, "review verdicts", appendix, tool);
7800
+ appendLimitedSection(lines, "Linked references", renderLinkedOrUnavailable(view, "closingIssuesReferences", "closing"), 20, "linked references", appendix, tool);
7801
+ appendFilesSection(lines, view, appendix, tool);
7802
+ appendLimitedSection(lines, "Commits", renderCommitsOrUnavailable(view), MAX_INLINE_COMMITS, "commits", appendix, tool);
7549
7803
  } else {
7550
- appendLimitedSection(lines, "Closed by pull requests", renderLinkedOrUnavailable(view, "closedByPullRequestsReferences", "closedBy"), 20, "pull requests");
7804
+ appendLimitedSection(lines, "Closed by pull requests", renderLinkedOrUnavailable(view, "closedByPullRequestsReferences", "closedBy"), 20, "pull requests", appendix, tool);
7551
7805
  }
7552
7806
  lines.push("## Conversation comments");
7553
- const commentLines = renderComments(objectArray(view.comments), data.anchor, appendix);
7554
- const commentMarker = renderCommentMarker(objectArray(view.comments), commentLines.length, view.commentsCount);
7807
+ const comments = objectArray(view.comments);
7808
+ const commentLines = renderComments(comments, data.anchor, appendix, tool);
7809
+ const knownCommentTotal = numberValue(view.commentsCount);
7810
+ const commentMarker = omissionMarker("Conversation comments", "comments", commentLines.length, comments.length, knownCommentTotal !== null && knownCommentTotal > comments.length ? knownCommentTotal : null, tool, "gh issue view -c");
7555
7811
  if (commentMarker) commentLines.push(commentMarker);
7556
7812
  if (view.anchorUnavailable === true && data.anchor?.startsWith("issuecomment-")) commentLines.push("[anchored comment unavailable for this issue or pull request]");
7557
7813
  lines.push(...commentLines.length > 0 ? commentLines : ["none"], "");
7558
7814
  if (data.kind === "pull") {
7559
7815
  lines.push("## Review thread comments");
7560
- const threadLines = renderReviewThreads(data.reviewThreads, data.anchor, appendix, view.reviewCommentsCount, data.reviewThreadsBounded, data.reviewThreadsUnavailable);
7816
+ const threadLines = renderReviewThreads(data.reviewThreads, data.anchor, appendix, tool, view.reviewCommentsCount, data.reviewThreadsBounded, data.reviewThreadsUnavailable);
7561
7817
  if (view.anchorUnavailable === true && data.anchor?.startsWith("discussion_r")) threadLines.push("[anchored review thread comment unavailable for this pull request]");
7562
7818
  lines.push(...threadLines.length > 0 ? threadLines : ["none"], "");
7563
7819
  }
7564
7820
  if (data.fallbackNotes.length > 0) {
7565
7821
  lines.push("## Availability notes", ...data.fallbackNotes.map((note) => `- ${note}`), "");
7566
7822
  }
7567
- if (appendix.length > 0) lines.push("## Appendix", ...appendix, "");
7568
7823
  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`;
7824
+ const diffCommand = data.kind === "pull" ? `gh pr diff ${data.number} --repo ${data.owner}/${data.repo}` : "";
7569
7825
  lines.push("## Escalation commands");
7570
7826
  lines.push(`- Full view: \`${viewCommand}\``);
7571
- if (data.kind === "pull") lines.push(`- Complete diff: \`gh pr diff ${data.number} --repo ${data.owner}/${data.repo}\``);
7572
- lines.push("- Stored full document: use `get_search_content` with `offset` or `findText`.");
7827
+ if (diffCommand) lines.push(`- Complete diff: \`${diffCommand}\``);
7828
+ if (tool) lines.push(`- Stored full document: use \`${tool}\` with \`offset\` or \`findText\`.`);
7829
+ if (appendix.length > 0) lines.push("", "## Appendix", "", appendix.join("\n\n"));
7573
7830
  const content = lines.join("\n");
7574
7831
  return {
7575
7832
  url: data.url,
7576
7833
  title: `${data.owner}/${data.repo} ${data.kind} #${data.number}: ${title}`,
7577
7834
  content: content.length > MAX_DOC_CHARS ? `${content.slice(0, MAX_DOC_CHARS)}
7578
7835
 
7579
- [GitHub document truncated at ${MAX_DOC_CHARS} chars; use the gh escalation commands for complete data]` : content,
7836
+ [GitHub document truncated at ${MAX_DOC_CHARS} chars; use \`${viewCommand}\`${diffCommand ? ` or \`${diffCommand}\`` : ""} for complete data]` : content,
7580
7837
  error: null
7581
7838
  };
7582
7839
  }
@@ -7585,6 +7842,7 @@ async function extractGitHubIssuePr(url, signal, options) {
7585
7842
  if (!info) return null;
7586
7843
  if (!loadConfig37().enabled) return null;
7587
7844
  if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
7845
+ const retrievalTool = options?.toolNames ? options.toolNames.getSearchContent ?? null : void 0;
7588
7846
  const ghAvailable2 = await checkGhAvailable(signal);
7589
7847
  if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
7590
7848
  if (ghAvailable2) {
@@ -7596,23 +7854,23 @@ async function extractGitHubIssuePr(url, signal, options) {
7596
7854
  if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
7597
7855
  if (threads.anchorUnavailable) viewed.view.anchorUnavailable = true;
7598
7856
  const notes = [...viewed.notes, ...threads.note ? [threads.note] : []];
7599
- 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 });
7857
+ 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 });
7600
7858
  }
7601
7859
  } else {
7602
7860
  showGhHint();
7603
7861
  }
7604
7862
  const fallback = await restFallback(url, info, options, signal);
7605
7863
  if (!fallback) return null;
7606
- if ("data" in fallback) return renderGitHubPrIssue(fallback.data);
7864
+ if ("data" in fallback) return renderGitHubPrIssue({ ...fallback.data, retrievalTool });
7607
7865
  return fallback;
7608
7866
  }
7609
- var CONFIG_PATH42, 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;
7867
+ 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;
7610
7868
  var init_github_issue_pr = __esm({
7611
7869
  "github-issue-pr.ts"() {
7612
7870
  init_github_api();
7613
7871
  init_ssrf_protection();
7614
7872
  init_utils();
7615
- CONFIG_PATH42 = getWebSearchConfigPath();
7873
+ CONFIG_PATH43 = getWebSearchConfigPath();
7616
7874
  GH_TIMEOUT_MS = 1e4;
7617
7875
  GH_TOTAL_TIMEOUT_MS = 2e4;
7618
7876
  MAX_DOC_CHARS = 15e4;
@@ -7698,15 +7956,15 @@ var init_github_issue_pr = __esm({
7698
7956
  });
7699
7957
 
7700
7958
  // feature-config.ts
7701
- import { existsSync as existsSync46, readFileSync as readFileSync48 } from "node:fs";
7959
+ import { existsSync as existsSync47, readFileSync as readFileSync49 } from "node:fs";
7702
7960
  function loadFeatureConfig() {
7703
- if (!existsSync46(CONFIG_PATH43)) return {};
7961
+ if (!existsSync47(CONFIG_PATH44)) return {};
7704
7962
  try {
7705
- const raw = JSON.parse(readFileSync48(CONFIG_PATH43, "utf-8"));
7963
+ const raw = JSON.parse(readFileSync49(CONFIG_PATH44, "utf-8"));
7706
7964
  return raw && typeof raw === "object" ? raw : {};
7707
7965
  } catch (err) {
7708
7966
  const message = err instanceof Error ? err.message : String(err);
7709
- throw new Error(`Failed to parse ${CONFIG_PATH43}: ${message}`);
7967
+ throw new Error(`Failed to parse ${CONFIG_PATH44}: ${message}`);
7710
7968
  }
7711
7969
  }
7712
7970
  function isImageEnabled() {
@@ -7719,17 +7977,17 @@ function canAttachImages() {
7719
7977
  return false;
7720
7978
  }
7721
7979
  }
7722
- var CONFIG_PATH43;
7980
+ var CONFIG_PATH44;
7723
7981
  var init_feature_config = __esm({
7724
7982
  "feature-config.ts"() {
7725
7983
  init_utils();
7726
- CONFIG_PATH43 = getWebSearchConfigPath();
7984
+ CONFIG_PATH44 = getWebSearchConfigPath();
7727
7985
  }
7728
7986
  });
7729
7987
 
7730
7988
  // youtube-extract.ts
7731
7989
  import { execFileSync } from "node:child_process";
7732
- import { existsSync as existsSync47, readFileSync as readFileSync49 } from "node:fs";
7990
+ import { existsSync as existsSync48, readFileSync as readFileSync50 } from "node:fs";
7733
7991
  function errorMessage29(err) {
7734
7992
  return err instanceof Error ? err.message : String(err);
7735
7993
  }
@@ -7750,17 +8008,17 @@ function normalizeEnabled2(value, fallback) {
7750
8008
  }
7751
8009
  function loadYouTubeConfig() {
7752
8010
  if (cachedConfig38) return cachedConfig38;
7753
- if (!existsSync47(CONFIG_PATH44)) {
8011
+ if (!existsSync48(CONFIG_PATH45)) {
7754
8012
  cachedConfig38 = { ...defaults };
7755
8013
  return cachedConfig38;
7756
8014
  }
7757
- const rawText = readFileSync49(CONFIG_PATH44, "utf-8");
8015
+ const rawText = readFileSync50(CONFIG_PATH45, "utf-8");
7758
8016
  let raw;
7759
8017
  try {
7760
8018
  raw = JSON.parse(rawText);
7761
8019
  } catch (err) {
7762
8020
  const message = err instanceof Error ? err.message : String(err);
7763
- throw new Error(`Failed to parse ${CONFIG_PATH44}: ${message}`);
8021
+ throw new Error(`Failed to parse ${CONFIG_PATH45}: ${message}`);
7764
8022
  }
7765
8023
  const yt = raw.youtube ?? {};
7766
8024
  cachedConfig38 = {
@@ -7959,7 +8217,7 @@ ${answer}
7959
8217
  return null;
7960
8218
  }
7961
8219
  }
7962
- var CONFIG_PATH44, YOUTUBE_PROMPT, YOUTUBE_REGEX, defaults, cachedConfig38;
8220
+ var CONFIG_PATH45, YOUTUBE_PROMPT, YOUTUBE_REGEX, defaults, cachedConfig38;
7963
8221
  var init_youtube_extract = __esm({
7964
8222
  "youtube-extract.ts"() {
7965
8223
  init_activity();
@@ -7969,7 +8227,7 @@ var init_youtube_extract = __esm({
7969
8227
  init_perplexity();
7970
8228
  init_extract();
7971
8229
  init_utils();
7972
- CONFIG_PATH44 = getWebSearchConfigPath();
8230
+ CONFIG_PATH45 = getWebSearchConfigPath();
7973
8231
  YOUTUBE_PROMPT = `Extract the complete content of this YouTube video. Include:
7974
8232
  1. Video title, channel name, and duration
7975
8233
  2. A brief summary (2-3 sentences)
@@ -8081,23 +8339,23 @@ URL: `;
8081
8339
  });
8082
8340
 
8083
8341
  // crawl4ai.ts
8084
- import { existsSync as existsSync48, readFileSync as readFileSync50 } from "node:fs";
8342
+ import { existsSync as existsSync49, readFileSync as readFileSync51 } from "node:fs";
8085
8343
  function loadConfig38() {
8086
8344
  if (cachedConfig39) return cachedConfig39;
8087
- if (!existsSync48(CONFIG_PATH45)) {
8345
+ if (!existsSync49(CONFIG_PATH46)) {
8088
8346
  cachedConfig39 = {};
8089
8347
  return cachedConfig39;
8090
8348
  }
8091
- const raw = readFileSync50(CONFIG_PATH45, "utf8");
8349
+ const raw = readFileSync51(CONFIG_PATH46, "utf8");
8092
8350
  let parsed;
8093
8351
  try {
8094
8352
  parsed = JSON.parse(raw);
8095
8353
  } catch (err) {
8096
8354
  const message = err instanceof Error ? err.message : String(err);
8097
- throw new Error(`Failed to parse ${CONFIG_PATH45}: ${message}`);
8355
+ throw new Error(`Failed to parse ${CONFIG_PATH46}: ${message}`);
8098
8356
  }
8099
8357
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
8100
- throw new Error(`Invalid config in ${CONFIG_PATH45}: expected a JSON object`);
8358
+ throw new Error(`Invalid config in ${CONFIG_PATH46}: expected a JSON object`);
8101
8359
  }
8102
8360
  cachedConfig39 = parsed;
8103
8361
  return cachedConfig39;
@@ -8110,13 +8368,13 @@ function normalizeBaseUrl5(value) {
8110
8368
  try {
8111
8369
  parsed = new URL(trimmed);
8112
8370
  } catch {
8113
- throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH45}: expected an HTTP or HTTPS URL`);
8371
+ throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH46}: expected an HTTP or HTTPS URL`);
8114
8372
  }
8115
8373
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
8116
- throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH45}: expected an HTTP or HTTPS URL`);
8374
+ throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH46}: expected an HTTP or HTTPS URL`);
8117
8375
  }
8118
8376
  if (parsed.username || parsed.password) {
8119
- throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH45}: URL credentials are not allowed`);
8377
+ throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH46}: URL credentials are not allowed`);
8120
8378
  }
8121
8379
  parsed.pathname = parsed.pathname.replace(/\/+$/, "");
8122
8380
  parsed.search = "";
@@ -8131,7 +8389,7 @@ function requireBaseUrl4() {
8131
8389
  if (!baseUrl) {
8132
8390
  throw new Error(
8133
8391
  `Crawl4AI base URL not configured. Either:
8134
- 1. Set crawl4aiBaseUrl in ${CONFIG_PATH45}
8392
+ 1. Set crawl4aiBaseUrl in ${CONFIG_PATH46}
8135
8393
  2. Set CRAWL4AI_BASE_URL environment variable`
8136
8394
  );
8137
8395
  }
@@ -8230,14 +8488,14 @@ async function extractWithCrawl4ai(url, signal, options) {
8230
8488
  throw err;
8231
8489
  }
8232
8490
  }
8233
- var CONFIG_PATH45, EXTRACT_TIMEOUT_MS2, MARKDOWN_FILTER, cachedConfig39;
8491
+ var CONFIG_PATH46, EXTRACT_TIMEOUT_MS2, MARKDOWN_FILTER, cachedConfig39;
8234
8492
  var init_crawl4ai = __esm({
8235
8493
  "crawl4ai.ts"() {
8236
8494
  init_activity();
8237
8495
  init_credential_source();
8238
8496
  init_ssrf_protection();
8239
8497
  init_utils();
8240
- CONFIG_PATH45 = getWebSearchConfigPath();
8498
+ CONFIG_PATH46 = getWebSearchConfigPath();
8241
8499
  EXTRACT_TIMEOUT_MS2 = 6e4;
8242
8500
  MARKDOWN_FILTER = "fit";
8243
8501
  cachedConfig39 = null;
@@ -8245,7 +8503,7 @@ var init_crawl4ai = __esm({
8245
8503
  });
8246
8504
 
8247
8505
  // brightdata-unlocker.ts
8248
- import { existsSync as existsSync49, readFileSync as readFileSync51 } from "node:fs";
8506
+ import { existsSync as existsSync50, readFileSync as readFileSync52 } from "node:fs";
8249
8507
  function parseFailureDetail(err) {
8250
8508
  const message = err instanceof Error ? err.message : String(err);
8251
8509
  const position = message.match(/at position \d+(?: \(line \d+ column \d+\))?/);
@@ -8253,19 +8511,19 @@ function parseFailureDetail(err) {
8253
8511
  }
8254
8512
  function loadConfig39() {
8255
8513
  if (cachedConfig40) return cachedConfig40;
8256
- if (!existsSync49(CONFIG_PATH46)) {
8514
+ if (!existsSync50(CONFIG_PATH47)) {
8257
8515
  cachedConfig40 = {};
8258
8516
  return cachedConfig40;
8259
8517
  }
8260
- const raw = readFileSync51(CONFIG_PATH46, "utf8");
8518
+ const raw = readFileSync52(CONFIG_PATH47, "utf8");
8261
8519
  let parsed;
8262
8520
  try {
8263
8521
  parsed = JSON.parse(raw);
8264
8522
  } catch (err) {
8265
- throw new Error(`Failed to parse ${CONFIG_PATH46}: ${parseFailureDetail(err)}`);
8523
+ throw new Error(`Failed to parse ${CONFIG_PATH47}: ${parseFailureDetail(err)}`);
8266
8524
  }
8267
8525
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
8268
- throw new Error(`Invalid config in ${CONFIG_PATH46}: expected a JSON object`);
8526
+ throw new Error(`Invalid config in ${CONFIG_PATH47}: expected a JSON object`);
8269
8527
  }
8270
8528
  cachedConfig40 = parsed;
8271
8529
  return cachedConfig40;
@@ -8280,7 +8538,7 @@ function zoneSetting() {
8280
8538
  const fromEnv = process.env.BRIGHTDATA_UNLOCKER_ZONE;
8281
8539
  if (typeof fromEnv === "string" && fromEnv.trim()) return { raw: fromEnv.trim(), label: "BRIGHTDATA_UNLOCKER_ZONE" };
8282
8540
  const configured = loadConfig39().brightdataUnlockerZone;
8283
- if (typeof configured === "string" && configured.trim()) return { raw: configured.trim(), label: `brightdataUnlockerZone in ${CONFIG_PATH46}` };
8541
+ if (typeof configured === "string" && configured.trim()) return { raw: configured.trim(), label: `brightdataUnlockerZone in ${CONFIG_PATH47}` };
8284
8542
  return null;
8285
8543
  }
8286
8544
  function getZone() {
@@ -8298,7 +8556,7 @@ function requireZone() {
8298
8556
  }
8299
8557
  throw new Error(
8300
8558
  `Bright Data Web Unlocker zone not configured. Either:
8301
- 1. Set brightdataUnlockerZone in ${CONFIG_PATH46}
8559
+ 1. Set brightdataUnlockerZone in ${CONFIG_PATH47}
8302
8560
  2. Set BRIGHTDATA_UNLOCKER_ZONE environment variable
8303
8561
  The zone must be of type "unblocker"; a SERP zone will not serve Web Unlocker requests.`
8304
8562
  );
@@ -8313,7 +8571,7 @@ async function getApiKey27(signal) {
8313
8571
  if (!apiKey) {
8314
8572
  throw new Error(
8315
8573
  `Bright Data API key not found. Either:
8316
- 1. Create ${CONFIG_PATH46} with { "brightdataApiKey": "your-key" }
8574
+ 1. Create ${CONFIG_PATH47} with { "brightdataApiKey": "your-key" }
8317
8575
  2. Set BRIGHTDATA_API_KEY environment variable
8318
8576
  Get a key at https://brightdata.com/cp/setting/users`
8319
8577
  );
@@ -8422,14 +8680,14 @@ async function extractWithBrightDataUnlocker(url, signal, options) {
8422
8680
  if (!content) return null;
8423
8681
  return { url, title: headingTitle(content), content, error: null };
8424
8682
  }
8425
- var CONFIG_PATH46, BRIGHTDATA_REQUEST_URL, EXTRACT_TIMEOUT_MS3, DEFAULT_MAX_REDIRECTS3, REDIRECT_STATUSES3, ZONE_PATTERN2, cachedConfig40;
8683
+ var CONFIG_PATH47, BRIGHTDATA_REQUEST_URL, EXTRACT_TIMEOUT_MS3, DEFAULT_MAX_REDIRECTS3, REDIRECT_STATUSES3, ZONE_PATTERN2, cachedConfig40;
8426
8684
  var init_brightdata_unlocker = __esm({
8427
8685
  "brightdata-unlocker.ts"() {
8428
8686
  init_activity();
8429
8687
  init_credential_source();
8430
8688
  init_ssrf_protection();
8431
8689
  init_utils();
8432
- CONFIG_PATH46 = getWebSearchConfigPath();
8690
+ CONFIG_PATH47 = getWebSearchConfigPath();
8433
8691
  BRIGHTDATA_REQUEST_URL = "https://api.brightdata.com/request";
8434
8692
  EXTRACT_TIMEOUT_MS3 = 6e4;
8435
8693
  DEFAULT_MAX_REDIRECTS3 = 5;
@@ -8441,7 +8699,7 @@ var init_brightdata_unlocker = __esm({
8441
8699
 
8442
8700
  // video-extract.ts
8443
8701
  import { execFileSync as execFileSync2 } from "node:child_process";
8444
- import { existsSync as existsSync50, readFileSync as readFileSync52, readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
8702
+ import { existsSync as existsSync51, readFileSync as readFileSync53, readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
8445
8703
  import { readFile as readFile2 } from "node:fs/promises";
8446
8704
  import { resolve, extname as extname2, basename as basename4, join as join7, dirname as dirname2 } from "node:path";
8447
8705
  function shouldRethrow3(err) {
@@ -8462,17 +8720,17 @@ function normalizeMaxSizeMB(value, fallback) {
8462
8720
  }
8463
8721
  function loadVideoConfig() {
8464
8722
  if (cachedVideoConfig) return cachedVideoConfig;
8465
- if (!existsSync50(CONFIG_PATH47)) {
8723
+ if (!existsSync51(CONFIG_PATH48)) {
8466
8724
  cachedVideoConfig = { ...VIDEO_CONFIG_DEFAULTS };
8467
8725
  return cachedVideoConfig;
8468
8726
  }
8469
- const rawText = readFileSync52(CONFIG_PATH47, "utf-8");
8727
+ const rawText = readFileSync53(CONFIG_PATH48, "utf-8");
8470
8728
  let raw;
8471
8729
  try {
8472
8730
  raw = JSON.parse(rawText);
8473
8731
  } catch (err) {
8474
8732
  const message = err instanceof Error ? err.message : String(err);
8475
- throw new Error(`Failed to parse ${CONFIG_PATH47}: ${message}`);
8733
+ throw new Error(`Failed to parse ${CONFIG_PATH48}: ${message}`);
8476
8734
  }
8477
8735
  const v = raw.video ?? {};
8478
8736
  cachedVideoConfig = {
@@ -8518,10 +8776,10 @@ function isVideoFile(input) {
8518
8776
  }
8519
8777
  function resolveFilePath(filePath) {
8520
8778
  const absolutePath = resolve(filePath);
8521
- if (existsSync50(absolutePath)) return absolutePath;
8779
+ if (existsSync51(absolutePath)) return absolutePath;
8522
8780
  const dir = dirname2(absolutePath);
8523
8781
  const base = basename4(absolutePath);
8524
- if (!existsSync50(dir)) return null;
8782
+ if (!existsSync51(dir)) return null;
8525
8783
  try {
8526
8784
  const normalizedBase = normalizeSpaces(base);
8527
8785
  const match = readdirSync4(dir).find((f) => normalizeSpaces(f) === normalizedBase);
@@ -8679,8 +8937,9 @@ async function uploadToFilesApi(info, apiKey, signal) {
8679
8937
  }
8680
8938
  const uploadUrl = initRes.headers.get("x-goog-upload-url");
8681
8939
  if (!uploadUrl) throw new Error("No upload URL in response headers");
8940
+ const routedUploadUrl = rewriteUploadUrlOrigin(uploadUrl);
8682
8941
  const fileData = await readFile2(info.absolutePath);
8683
- const uploadRes = await fetchGeminiApi(uploadUrl, {
8942
+ const uploadRes = await fetchGeminiApi(routedUploadUrl, {
8684
8943
  method: "PUT",
8685
8944
  headers: {
8686
8945
  "Content-Length": String(info.sizeBytes),
@@ -8719,7 +8978,7 @@ function deleteGeminiFile(fileName, apiKey) {
8719
8978
  function extractVideoTitle(text4, filePath) {
8720
8979
  return extractHeadingTitle(text4) ?? basename4(filePath, extname2(filePath));
8721
8980
  }
8722
- var CONFIG_PATH47, DEFAULT_VIDEO_PROMPT, VIDEO_EXTENSIONS, VIDEO_CONFIG_DEFAULTS, cachedVideoConfig;
8981
+ var CONFIG_PATH48, DEFAULT_VIDEO_PROMPT, VIDEO_EXTENSIONS, VIDEO_CONFIG_DEFAULTS, cachedVideoConfig;
8723
8982
  var init_video_extract = __esm({
8724
8983
  "video-extract.ts"() {
8725
8984
  init_activity();
@@ -8728,7 +8987,7 @@ var init_video_extract = __esm({
8728
8987
  init_gemini_api();
8729
8988
  init_extract();
8730
8989
  init_utils();
8731
- CONFIG_PATH47 = getWebSearchConfigPath();
8990
+ CONFIG_PATH48 = getWebSearchConfigPath();
8732
8991
  DEFAULT_VIDEO_PROMPT = `Extract the complete content of this video. Include:
8733
8992
  1. Video title (infer from content if not explicit), duration
8734
8993
  2. A brief summary (2-3 sentences)
@@ -9213,13 +9472,13 @@ __export(extract_exports, {
9213
9472
  readPDFResponseBuffer: () => readPDFResponseBuffer,
9214
9473
  resolveFetchTimeoutMs: () => resolveFetchTimeoutMs
9215
9474
  });
9216
- import { existsSync as existsSync51, readFileSync as readFileSync53 } from "node:fs";
9475
+ import { existsSync as existsSync52, readFileSync as readFileSync54 } from "node:fs";
9217
9476
  import pLimit from "p-limit";
9218
9477
  function loadFetchTimeoutMs() {
9219
- if (!existsSync51(WEB_SEARCH_CONFIG_PATH3)) return DEFAULT_TIMEOUT_MS3;
9478
+ if (!existsSync52(WEB_SEARCH_CONFIG_PATH3)) return DEFAULT_TIMEOUT_MS4;
9220
9479
  let raw;
9221
9480
  try {
9222
- raw = JSON.parse(readFileSync53(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
9481
+ raw = JSON.parse(readFileSync54(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
9223
9482
  } catch (err) {
9224
9483
  const message = err instanceof Error ? err.message : String(err);
9225
9484
  throw new Error(`Failed to parse ${WEB_SEARCH_CONFIG_PATH3}: ${message}`);
@@ -9228,12 +9487,12 @@ function loadFetchTimeoutMs() {
9228
9487
  throw new Error(`Invalid config in ${WEB_SEARCH_CONFIG_PATH3}: expected a JSON object`);
9229
9488
  }
9230
9489
  const fetchConfig = raw.fetch;
9231
- if (fetchConfig === void 0) return DEFAULT_TIMEOUT_MS3;
9490
+ if (fetchConfig === void 0) return DEFAULT_TIMEOUT_MS4;
9232
9491
  if (!fetchConfig || typeof fetchConfig !== "object" || Array.isArray(fetchConfig)) {
9233
9492
  throw new Error(`fetch in ${WEB_SEARCH_CONFIG_PATH3} must be an object`);
9234
9493
  }
9235
9494
  const value = fetchConfig.timeout;
9236
- if (value === void 0) return DEFAULT_TIMEOUT_MS3;
9495
+ if (value === void 0) return DEFAULT_TIMEOUT_MS4;
9237
9496
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
9238
9497
  throw new Error(`Invalid fetch.timeout in ${WEB_SEARCH_CONFIG_PATH3}: expected a positive finite number of seconds, got ${JSON.stringify(value)}`);
9239
9498
  }
@@ -9294,7 +9553,7 @@ function isAbortException2(err) {
9294
9553
  return err instanceof DOMException && (err.name === "AbortError" || err.name === "TimeoutError");
9295
9554
  }
9296
9555
  function isRedirectPolicyError(message) {
9297
- 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 ");
9556
+ 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 ");
9298
9557
  }
9299
9558
  function isNonRecoverableHttpError(error) {
9300
9559
  return !!error && (NON_RECOVERABLE_ERRORS.some((prefix) => error.startsWith(prefix)) || isRedirectPolicyError(error) || isConfigParseError(error));
@@ -9306,6 +9565,9 @@ function imageGateError() {
9306
9565
  return errorMessage32(err);
9307
9566
  }
9308
9567
  }
9568
+ function redirectPolicyRouteRefusal(url, path) {
9569
+ 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` };
9570
+ }
9309
9571
  async function resolveAuthCookieHeader(url, profile) {
9310
9572
  const parsed = assertAuthFetchUrl(profile, url.toString());
9311
9573
  const result = await getBrowserCookiesForHosts({ hosts: [parsed.hostname], profile: profile.chromeProfile, requestUrl: parsed });
@@ -9324,6 +9586,7 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
9324
9586
  proxy: validationOptions.proxy,
9325
9587
  ...validationOptions.lookup ? { lookup: validationOptions.lookup } : {}
9326
9588
  });
9589
+ const originalOrigin = current.origin;
9327
9590
  let requestInit = init;
9328
9591
  for (let redirects = 0; redirects <= 5; redirects++) {
9329
9592
  const cookieHeader = await resolveAuthCookieHeader(current, profile);
@@ -9334,7 +9597,11 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
9334
9597
  if (!location) return response;
9335
9598
  if (redirects === 5) throw new Error(`Too many redirects fetching ${current.toString()}`);
9336
9599
  const from = current;
9337
- current = await validateRemoteUrl(new URL(location, current), {
9600
+ const next = new URL(location, current);
9601
+ if (validationOptions.redirects === "same-origin" && next.origin !== originalOrigin) {
9602
+ throw new Error(`Refused cross-origin redirect by fetch_content redirect policy: ${originalOrigin} -> ${next.origin}`);
9603
+ }
9604
+ current = await validateRemoteUrl(next, {
9338
9605
  allowRanges: validationOptions.ssrf.allowRanges,
9339
9606
  trustEnvProxy: validationOptions.ssrf.trustEnvProxy,
9340
9607
  domainPolicy: validationOptions.domainPolicy,
@@ -9350,12 +9617,12 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
9350
9617
  throw new Error(`Too many redirects fetching ${current.toString()}`);
9351
9618
  }
9352
9619
  function loadFetchRouting() {
9353
- if (!existsSync51(WEB_SEARCH_CONFIG_PATH3)) {
9620
+ if (!existsSync52(WEB_SEARCH_CONFIG_PATH3)) {
9354
9621
  return { providers: DEFAULT_FETCH_PROVIDER_ORDER, allowRemoteHostedProviders: false };
9355
9622
  }
9356
9623
  let raw;
9357
9624
  try {
9358
- const parsed = JSON.parse(readFileSync53(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
9625
+ const parsed = JSON.parse(readFileSync54(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
9359
9626
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
9360
9627
  throw new Error("expected a JSON object");
9361
9628
  }
@@ -9553,6 +9820,12 @@ async function extractContent(url, signal, options) {
9553
9820
  if (signal?.aborted) {
9554
9821
  return { url, title: "", content: "", error: "Aborted" };
9555
9822
  }
9823
+ let redirectPolicy;
9824
+ try {
9825
+ redirectPolicy = options?.redirects ?? loadFetchContentRedirectPolicy();
9826
+ } catch (err) {
9827
+ return { url, title: "", content: "", error: errorMessage32(err) };
9828
+ }
9556
9829
  let remoteUrl = null;
9557
9830
  try {
9558
9831
  const parsed = new URL(url);
@@ -9563,6 +9836,7 @@ async function extractContent(url, signal, options) {
9563
9836
  try {
9564
9837
  const ssrf = loadSsrfConfig();
9565
9838
  const domainPolicy = loadFetchContentDomainPolicy();
9839
+ loadFetchContentUserAgent();
9566
9840
  await validateRemoteUrl(remoteUrl, {
9567
9841
  allowRanges: ssrf.allowRanges,
9568
9842
  trustEnvProxy: ssrf.trustEnvProxy,
@@ -9581,6 +9855,11 @@ async function extractContent(url, signal, options) {
9581
9855
  return { url, title: "", content: "", error: errorMessage32(err) };
9582
9856
  }
9583
9857
  }
9858
+ if (redirectPolicy) {
9859
+ if (parseGitHubIssuePrUrl(url)) return redirectPolicyRouteRefusal(url, "GitHub issue/PR");
9860
+ if (parseGitHubUrl(url)) return redirectPolicyRouteRefusal(url, "GitHub repository");
9861
+ if (isYouTubeURL(url).isYouTube) return redirectPolicyRouteRefusal(url, "YouTube");
9862
+ }
9584
9863
  if (options?.frames || options?.timestamp) {
9585
9864
  const disabled = imageGateError();
9586
9865
  if (disabled) return { url, title: "", content: "", error: disabled };
@@ -9675,7 +9954,7 @@ async function extractContent(url, signal, options) {
9675
9954
  if ("error" in frame) {
9676
9955
  return { url, title: `Frame at ${options.timestamp}`, content: frame.error, error: frame.error };
9677
9956
  }
9678
- return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame };
9957
+ return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame, mimeType: frame.mimeType };
9679
9958
  }
9680
9959
  const localVideo2 = safeVideoInfo(url);
9681
9960
  if (localVideo2.status === "invalid") {
@@ -9699,7 +9978,7 @@ async function extractContent(url, signal, options) {
9699
9978
  if ("error" in frame) {
9700
9979
  return { url, title: `Frame at ${options.timestamp}`, content: frame.error, error: frame.error };
9701
9980
  }
9702
- return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame };
9981
+ return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame, mimeType: frame.mimeType };
9703
9982
  }
9704
9983
  return { url, title: "", content: "", error: "Timestamp extraction only works with YouTube and local video files" };
9705
9984
  }
@@ -9783,7 +10062,10 @@ async function extractContent(url, signal, options) {
9783
10062
  } catch (err) {
9784
10063
  return { url, title: "", content: "", error: errorMessage32(err) };
9785
10064
  }
9786
- const providerOrder = remoteUrl && !fetchRouting.allowRemoteHostedProviders ? fetchRouting.providers.filter((provider) => !REMOTE_HOSTED_FETCH_PROVIDERS.has(provider)) : fetchRouting.providers;
10065
+ if (redirectPolicy && !fetchRouting.providers.includes("http")) {
10066
+ return redirectPolicyRouteRefusal(url, fetchRouting.providers[0]);
10067
+ }
10068
+ const providerOrder = redirectPolicy ? ["http"] : remoteUrl && !fetchRouting.allowRemoteHostedProviders ? fetchRouting.providers.filter((provider) => !REMOTE_HOSTED_FETCH_PROVIDERS.has(provider)) : fetchRouting.providers;
9787
10069
  if (providerOrder.length === 0) {
9788
10070
  return {
9789
10071
  url,
@@ -10008,6 +10290,7 @@ async function extractContent(url, signal, options) {
10008
10290
  if (finalHttpResult?.status === 404 || finalHttpResult?.status === 410) {
10009
10291
  return { ...finalHttpResult, error: notFoundGuidance(finalHttpResult, options?.toolNames) };
10010
10292
  }
10293
+ if (redirectPolicy && finalHttpResult) return finalHttpResult;
10011
10294
  const searchToolName = options?.toolNames?.webSearch;
10012
10295
  const jinaHint = jinaReaderGuidance(fetchRouting, providerOrder, Boolean(remoteUrl) && !fetchRouting.allowRemoteHostedProviders);
10013
10296
  const guidance = [
@@ -10118,12 +10401,13 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
10118
10401
  try {
10119
10402
  const ssrf = loadSsrfConfig();
10120
10403
  const domainPolicy = loadFetchContentDomainPolicy();
10404
+ const redirects = options?.redirects ?? loadFetchContentRedirectPolicy();
10121
10405
  const authProfile = options?.authFetchProfile;
10122
10406
  const requestInit = {
10123
10407
  signal: controller.signal,
10124
10408
  __proxy: options?.proxy,
10125
10409
  headers: {
10126
- "User-Agent": "OpenAI File Downloader, XaiImageApiFetch/1.0",
10410
+ "User-Agent": loadFetchContentUserAgent(),
10127
10411
  "Accept": preferMarkdown ? MARKDOWN_FIRST_ACCEPT : BROWSER_ACCEPT,
10128
10412
  "Accept-Language": "en-US,en;q=0.9",
10129
10413
  "Cache-Control": "no-cache",
@@ -10134,13 +10418,14 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
10134
10418
  "Upgrade-Insecure-Requests": "1"
10135
10419
  }
10136
10420
  };
10137
- const response = authProfile ? await fetchAuthenticatedRemoteUrl(url, requestInit, { ssrf, domainPolicy, proxy: options?.proxy, ...options?.lookup ? { lookup: options.lookup } : {} }, authProfile) : await fetchRemoteUrl(
10421
+ const response = authProfile ? await fetchAuthenticatedRemoteUrl(url, requestInit, { ssrf, domainPolicy, redirects, proxy: options?.proxy, ...options?.lookup ? { lookup: options.lookup } : {} }, authProfile) : await fetchRemoteUrl(
10138
10422
  url,
10139
10423
  requestInit,
10140
10424
  {
10141
10425
  allowRanges: ssrf.allowRanges,
10142
10426
  trustEnvProxy: ssrf.trustEnvProxy,
10143
10427
  domainPolicy,
10428
+ redirects,
10144
10429
  proxy: options?.proxy,
10145
10430
  ...options?.lookup ? { lookup: options.lookup } : {}
10146
10431
  }
@@ -10180,7 +10465,8 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
10180
10465
  if (options?.mode === "raw") {
10181
10466
  if (!isTextContentType(contentType)) {
10182
10467
  activityMonitor.logComplete(activityId, response.status);
10183
- return { url, title: "", content: "", error: `Unsupported content type in raw mode: ${mimeType || "missing"}`, mimeType, status: response.status };
10468
+ const hint = isPDFContent ? '; retry without mode for Markdown, or with mode "answer" and a prompt' : "";
10469
+ return { url, title: "", content: "", error: `Unsupported content type in raw mode: ${mimeType || "missing"}${hint}`, mimeType, status: response.status };
10184
10470
  }
10185
10471
  const text5 = await readTextResponseWithLimit(response, maxResponseSize);
10186
10472
  activityMonitor.logComplete(activityId, response.status);
@@ -10229,8 +10515,8 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
10229
10515
  title: result.title,
10230
10516
  content: options?.mode === "answer" ? result.content : `PDF extracted and saved to: ${result.outputPath}
10231
10517
 
10232
- Pages: ${result.pages}
10233
- Characters: ${result.chars}`,
10518
+ ${result.pages > 0 ? `Pages: ${result.pages}
10519
+ ` : ""}Characters: ${result.chars}`,
10234
10520
  error: null
10235
10521
  };
10236
10522
  } catch (err) {
@@ -10403,7 +10689,7 @@ async function fetchAllContent(urls, signal, options) {
10403
10689
  return sanitized.omissions.length > 0 ? { ...result, content: sanitized.text } : result;
10404
10690
  });
10405
10691
  }
10406
- var DEFAULT_TIMEOUT_MS3, 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;
10692
+ 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;
10407
10693
  var init_extract = __esm({
10408
10694
  "extract.ts"() {
10409
10695
  init_activity();
@@ -10433,7 +10719,7 @@ var init_extract = __esm({
10433
10719
  init_chrome_cookies();
10434
10720
  init_data_uri_sanitize();
10435
10721
  init_ssrf_protection();
10436
- DEFAULT_TIMEOUT_MS3 = 3e4;
10722
+ DEFAULT_TIMEOUT_MS4 = 3e4;
10437
10723
  MAX_CONFIGURED_TIMEOUT_MS = 2147483647;
10438
10724
  CONCURRENT_LIMIT = 3;
10439
10725
  WEB_SEARCH_CONFIG_PATH3 = getWebSearchConfigPath();
@@ -10459,7 +10745,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
10459
10745
  // package.json
10460
10746
  var package_default = {
10461
10747
  name: "pi-web-access",
10462
- version: "0.38.0",
10748
+ version: "0.41.0",
10463
10749
  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.",
10464
10750
  type: "module",
10465
10751
  bin: {
@@ -19560,7 +19846,7 @@ init_credential_source();
19560
19846
  init_utils();
19561
19847
  var BRAVE_API_BASE_URL = "https://api.search.brave.com/res/v1";
19562
19848
  var CONFIG_PATH6 = getWebSearchConfigPath();
19563
- var SEARCH_TIMEOUT_MS = 3e4;
19849
+ var SEARCH_TIMEOUT_MS2 = 3e4;
19564
19850
  var braveRateLimit = new BraveRateLimitCoordinator();
19565
19851
  var cachedConfig6 = null;
19566
19852
  function loadConfig6() {
@@ -19635,6 +19921,31 @@ function matchesDomainFilters(url, filters) {
19635
19921
  }
19636
19922
  return !filters.blocked.some((domain) => hostMatchesDomain(hostname2, domain));
19637
19923
  }
19924
+ var HTML_ENTITIES = {
19925
+ "&amp;": "&",
19926
+ "&lt;": "<",
19927
+ "&gt;": ">",
19928
+ "&quot;": '"',
19929
+ "&apos;": "'",
19930
+ "&nbsp;": " ",
19931
+ "&mdash;": "\u2014",
19932
+ "&ndash;": "\u2013",
19933
+ "&hellip;": "\u2026",
19934
+ "&rsquo;": "\u2019",
19935
+ "&lsquo;": "\u2018",
19936
+ "&rdquo;": "\u201D",
19937
+ "&ldquo;": "\u201C",
19938
+ "&middot;": "\xB7",
19939
+ "&bull;": "\u2022",
19940
+ "&deg;": "\xB0"
19941
+ };
19942
+ function stripHtml(value) {
19943
+ return value.replace(/<[^>]*>/g, "").replace(/&(?:#(x?)([0-9a-f]+)|[a-z]+);/gi, (entity, hex, digits) => {
19944
+ if (!digits) return HTML_ENTITIES[entity.toLowerCase()] ?? entity;
19945
+ const code = Number.parseInt(digits, hex ? 16 : 10);
19946
+ return code <= 1114111 && (code < 55296 || code > 57343) ? String.fromCodePoint(code) : entity;
19947
+ }).trim();
19948
+ }
19638
19949
  function isBraveAvailable() {
19639
19950
  return hasCredentialSource({
19640
19951
  provider: "Brave",
@@ -19672,7 +19983,7 @@ Get a key at https://brave.com/search/api/`
19672
19983
  if (freshness) params.set("freshness", freshness);
19673
19984
  }
19674
19985
  try {
19675
- const searchDeadline = AbortSignal.timeout(SEARCH_TIMEOUT_MS);
19986
+ const searchDeadline = AbortSignal.timeout(SEARCH_TIMEOUT_MS2);
19676
19987
  const searchSignal = options.signal ? AbortSignal.any([searchDeadline, options.signal]) : searchDeadline;
19677
19988
  const response = await braveRateLimit.run(async () => {
19678
19989
  for (let attempt = 0; attempt < 2; attempt++) {
@@ -19706,9 +20017,9 @@ Get a key at https://brave.com/search/api/`
19706
20017
  for (const item of data.web?.results ?? []) {
19707
20018
  if (!item.url || !matchesDomainFilters(item.url, domainFilters)) continue;
19708
20019
  results.push({
19709
- title: item.title || item.url,
20020
+ title: stripHtml(item.title || "") || item.url,
19710
20021
  url: item.url,
19711
- snippet: item.description || ""
20022
+ snippet: stripHtml(item.description || "")
19712
20023
  });
19713
20024
  if (results.length >= numResults) break;
19714
20025
  }
@@ -19743,7 +20054,7 @@ import { existsSync as existsSync9, readFileSync as readFileSync10 } from "node:
19743
20054
  var OPENAI_RESPONSES_URL = "https://api.openai.com/v1/responses";
19744
20055
  var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
19745
20056
  var CONFIG_PATH7 = getWebSearchConfigPath();
19746
- var SEARCH_TIMEOUT_MS2 = 6e4;
20057
+ var SEARCH_TIMEOUT_MS3 = 6e4;
19747
20058
  var EXCLUDED_MODEL_SEGMENTS = /* @__PURE__ */ new Set(["pro", "ultra"]);
19748
20059
  var MODEL_PREFERENCE = [
19749
20060
  (id) => id.includes("luna"),
@@ -20345,7 +20656,7 @@ async function runOpenAISearch(query, options, auth, ctx) {
20345
20656
  method: "POST",
20346
20657
  headers: requestHeaders,
20347
20658
  body: JSON.stringify(body),
20348
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS2), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS2)
20659
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS3), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS3)
20349
20660
  }, ["Authorization", "x-opencode-session", "x-opencode-client", "chatgpt-account-id", ...Object.keys(auth.headers)]);
20350
20661
  if (!response.ok) {
20351
20662
  activityMonitor.logError(activityId, `HTTP ${response.status}`);
@@ -20416,7 +20727,7 @@ init_utils();
20416
20727
  import { existsSync as existsSync13, readFileSync as readFileSync14 } from "node:fs";
20417
20728
  var SEARCHINFINITY_SEARCH_URL = "https://torchlight.byteintlapi.com/search_api/web_search";
20418
20729
  var CONFIG_PATH12 = getWebSearchConfigPath();
20419
- var SEARCH_TIMEOUT_MS6 = 3e4;
20730
+ var SEARCH_TIMEOUT_MS7 = 3e4;
20420
20731
  var cachedConfig11 = null;
20421
20732
  function loadConfig11() {
20422
20733
  if (cachedConfig11) return cachedConfig11;
@@ -20514,7 +20825,7 @@ async function searchinfinityJsonRequest(apiKey, body, signal) {
20514
20825
  "Content-Type": "application/json"
20515
20826
  },
20516
20827
  body: JSON.stringify(body),
20517
- signal: requestSignal6(signal, SEARCH_TIMEOUT_MS6)
20828
+ signal: requestSignal6(signal, SEARCH_TIMEOUT_MS7)
20518
20829
  });
20519
20830
  } catch (err) {
20520
20831
  const message = errorMessage5(err);
@@ -20595,7 +20906,7 @@ init_utils();
20595
20906
  import { existsSync as existsSync15, readFileSync as readFileSync16 } from "node:fs";
20596
20907
  var TAVILY_API_BASE_URL = "https://api.tavily.com";
20597
20908
  var CONFIG_PATH14 = getWebSearchConfigPath();
20598
- var SEARCH_TIMEOUT_MS8 = 6e4;
20909
+ var SEARCH_TIMEOUT_MS9 = 6e4;
20599
20910
  var cachedConfig13 = null;
20600
20911
  function loadConfig13() {
20601
20912
  if (cachedConfig13) return cachedConfig13;
@@ -20668,7 +20979,7 @@ function mapDomainFilter6(domainFilter) {
20668
20979
  };
20669
20980
  }
20670
20981
  function requestSignal8(signal) {
20671
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS8);
20982
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS9);
20672
20983
  return signal ? AbortSignal.any([signal, timeout]) : timeout;
20673
20984
  }
20674
20985
  function errorMessage7(err) {
@@ -20806,7 +21117,7 @@ init_utils();
20806
21117
  import { existsSync as existsSync16, readFileSync as readFileSync17 } from "node:fs";
20807
21118
  var YOU_SEARCH_URL = "https://ydc-index.io/v1/search";
20808
21119
  var CONFIG_PATH15 = getWebSearchConfigPath();
20809
- var SEARCH_TIMEOUT_MS9 = 6e4;
21120
+ var SEARCH_TIMEOUT_MS10 = 6e4;
20810
21121
  var cachedConfig14 = null;
20811
21122
  function loadConfig14() {
20812
21123
  if (cachedConfig14) return cachedConfig14;
@@ -20881,7 +21192,7 @@ async function searchWithYou(query, options = {}) {
20881
21192
  ...mapDomainFilter7(options.domainFilter)
20882
21193
  };
20883
21194
  const activityId = activityMonitor.logStart({ type: "api", query });
20884
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS9);
21195
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS10);
20885
21196
  let response;
20886
21197
  let entries;
20887
21198
  try {
@@ -20910,7 +21221,7 @@ async function searchWithYou(query, options = {}) {
20910
21221
  }
20911
21222
  const message = errorMessage8(err);
20912
21223
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
20913
- const outgoing = providerTimeout ? new Error(`You.com request timed out after ${Math.round(SEARCH_TIMEOUT_MS9 / 1e3)}s`) : (() => {
21224
+ const outgoing = providerTimeout ? new Error(`You.com request timed out after ${Math.round(SEARCH_TIMEOUT_MS10 / 1e3)}s`) : (() => {
20914
21225
  const redactedMessage = redactCredential(message, apiKey);
20915
21226
  if (redactedMessage === message && err instanceof Error) return err;
20916
21227
  const redactedError = new Error(redactedMessage);
@@ -20956,7 +21267,7 @@ init_utils();
20956
21267
  import { existsSync as existsSync19, readFileSync as readFileSync20 } from "node:fs";
20957
21268
  var JINA_SEARCH_BASE_URL = "https://s.jina.ai/";
20958
21269
  var CONFIG_PATH17 = getWebSearchConfigPath();
20959
- var SEARCH_TIMEOUT_MS11 = 6e4;
21270
+ var SEARCH_TIMEOUT_MS12 = 6e4;
20960
21271
  var cachedConfig16 = null;
20961
21272
  function loadConfig16() {
20962
21273
  if (cachedConfig16) return cachedConfig16;
@@ -21032,7 +21343,7 @@ function buildSearchRequest(query, options, numResults) {
21032
21343
  return { url: url.toString(), filters };
21033
21344
  }
21034
21345
  function requestSignal10(signal) {
21035
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS11);
21346
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS12);
21036
21347
  return {
21037
21348
  timeout,
21038
21349
  signal: signal ? AbortSignal.any([signal, timeout]) : timeout
@@ -21176,7 +21487,7 @@ init_utils();
21176
21487
  import { existsSync as existsSync20, readFileSync as readFileSync21 } from "node:fs";
21177
21488
  var SERPDIVE_API_URL = "https://api.serpdive.com/v1/search";
21178
21489
  var CONFIG_PATH18 = getWebSearchConfigPath();
21179
- var SEARCH_TIMEOUT_MS12 = 6e4;
21490
+ var SEARCH_TIMEOUT_MS13 = 6e4;
21180
21491
  var MODELS = ["krill", "mako", "moby"];
21181
21492
  var DEFAULT_MODEL2 = "krill";
21182
21493
  var cachedConfig17 = null;
@@ -21259,7 +21570,7 @@ function applyRecencyHint(query, recencyFilter) {
21259
21570
  return hint ? `${query} ${hint}` : query;
21260
21571
  }
21261
21572
  function requestSignal11(signal) {
21262
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS12);
21573
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS13);
21263
21574
  return signal ? AbortSignal.any([signal, timeout]) : timeout;
21264
21575
  }
21265
21576
  function errorMessage11(err) {
@@ -21381,7 +21692,7 @@ init_utils();
21381
21692
  import { existsSync as existsSync22, readFileSync as readFileSync23 } from "node:fs";
21382
21693
  var BOCHA_SEARCH_URL = "https://api.bochaai.com/v1/web-search";
21383
21694
  var CONFIG_PATH20 = getWebSearchConfigPath();
21384
- var SEARCH_TIMEOUT_MS14 = 6e4;
21695
+ var SEARCH_TIMEOUT_MS15 = 6e4;
21385
21696
  var cachedConfig19 = null;
21386
21697
  function loadConfig19() {
21387
21698
  if (cachedConfig19) return cachedConfig19;
@@ -21511,7 +21822,7 @@ async function searchWithBocha(query, options = {}) {
21511
21822
  method: "POST",
21512
21823
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "application/json" },
21513
21824
  body: JSON.stringify({ query, count: numResults, freshness: mapFreshness(options.recencyFilter), summary: true }),
21514
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS14), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS14)
21825
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS15), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS15)
21515
21826
  });
21516
21827
  } catch (err) {
21517
21828
  const message = errorMessage13(err);
@@ -21563,7 +21874,7 @@ init_search_result_count_normalization();
21563
21874
  init_utils();
21564
21875
  import { existsSync as existsSync24, readFileSync as readFileSync25 } from "node:fs";
21565
21876
  var CONFIG_PATH22 = getWebSearchConfigPath();
21566
- var SEARCH_TIMEOUT_MS16 = 3e4;
21877
+ var SEARCH_TIMEOUT_MS17 = 3e4;
21567
21878
  var cachedConfig21 = null;
21568
21879
  function loadConfig21() {
21569
21880
  if (cachedConfig21) return cachedConfig21;
@@ -21703,9 +22014,10 @@ async function searchWithSearXNG(query, options = {}) {
21703
22014
  const response = await fetchRemoteUrl(url, {
21704
22015
  method: "GET",
21705
22016
  headers,
21706
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS16), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS16)
22017
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS17), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS17)
21707
22018
  }, {
21708
22019
  ...loadSsrfConfig(),
22020
+ allowLoopback: isLoopbackHostname(url.hostname),
21709
22021
  onRedirect: ({ from, to, init }) => from.origin === to.origin ? init : { ...init, headers: { Accept: "application/json" } }
21710
22022
  });
21711
22023
  if (!response.ok) {
@@ -21750,7 +22062,7 @@ init_utils();
21750
22062
  import { existsSync as existsSync25, readFileSync as readFileSync26 } from "node:fs";
21751
22063
  var CONFIG_PATH23 = getWebSearchConfigPath();
21752
22064
  var DEFAULT_BASE_URL = "https://degoog.org";
21753
- var SEARCH_TIMEOUT_MS17 = 3e4;
22065
+ var SEARCH_TIMEOUT_MS18 = 3e4;
21754
22066
  var cachedConfig22 = null;
21755
22067
  function loadConfig22() {
21756
22068
  if (cachedConfig22) return cachedConfig22;
@@ -21924,7 +22236,7 @@ async function searchWithDegoog(query, options = {}) {
21924
22236
  if (engines.length > 0) body.engines = engines;
21925
22237
  const url = new URL(`${baseUrl}/api/search`);
21926
22238
  const activityId = activityMonitor.logStart({ type: "api", query: searchQuery });
21927
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS17);
22239
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS18);
21928
22240
  let response;
21929
22241
  let entries;
21930
22242
  try {
@@ -21962,7 +22274,7 @@ async function searchWithDegoog(query, options = {}) {
21962
22274
  }
21963
22275
  const message = errorMessage15(err);
21964
22276
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
21965
- const outgoing = providerTimeout ? new Error(`degoog request timed out after ${Math.round(SEARCH_TIMEOUT_MS17 / 1e3)}s`) : (() => {
22277
+ const outgoing = providerTimeout ? new Error(`degoog request timed out after ${Math.round(SEARCH_TIMEOUT_MS18 / 1e3)}s`) : (() => {
21966
22278
  const redactedMessage = redactSecrets(message, secrets);
21967
22279
  if (redactedMessage === message && err instanceof Error) return err;
21968
22280
  const redactedError = new Error(redactedMessage);
@@ -22004,7 +22316,7 @@ init_activity();
22004
22316
  init_domain_filter_normalization();
22005
22317
  init_search_result_count_normalization();
22006
22318
  var SEARCH_URL = "https://html.duckduckgo.com/html/";
22007
- var SEARCH_TIMEOUT_MS18 = 3e4;
22319
+ var SEARCH_TIMEOUT_MS19 = 3e4;
22008
22320
  function normalizeDomainFilters5(domainFilter) {
22009
22321
  const filters = { allowed: [], blocked: [] };
22010
22322
  for (const raw of domainFilter ?? []) {
@@ -22048,7 +22360,7 @@ async function searchWithDuckDuckGo(query, options = {}) {
22048
22360
  Accept: "text/html",
22049
22361
  "User-Agent": "Mozilla/5.0 (compatible; pi-web-access/1.0; +https://github.com/nicobailon/pi-web-access)"
22050
22362
  },
22051
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS18), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS18)
22363
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS19), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS19)
22052
22364
  });
22053
22365
  if (!response.ok) {
22054
22366
  const body = await response.text();
@@ -22056,6 +22368,9 @@ async function searchWithDuckDuckGo(query, options = {}) {
22056
22368
  }
22057
22369
  const { parseHTML } = await import("linkedom");
22058
22370
  const { document } = parseHTML(await response.text());
22371
+ if (response.status === 202 || document.querySelector(".anomaly-modal__box, #challenge-form")) {
22372
+ throw new Error(`DuckDuckGo blocked the request with a bot check (HTTP ${response.status}, rate limited); use another search provider`);
22373
+ }
22059
22374
  const filters = normalizeDomainFilters5(options.domainFilter);
22060
22375
  const results = [];
22061
22376
  let parseableResults = 0;
@@ -22072,7 +22387,7 @@ async function searchWithDuckDuckGo(query, options = {}) {
22072
22387
  results.push({ title, url: resultUrl, snippet });
22073
22388
  if (results.length >= normalizeSearchResultCount(options.numResults)) break;
22074
22389
  }
22075
- if (parseableResults === 0) {
22390
+ if (parseableResults === 0 && !document.querySelector(".no-results__message")) {
22076
22391
  throw new Error("DuckDuckGo returned no parseable results (invalid response)");
22077
22392
  }
22078
22393
  activityMonitor.logComplete(activityId, response.status);
@@ -22096,7 +22411,7 @@ init_utils();
22096
22411
  import { existsSync as existsSync26, readFileSync as readFileSync27 } from "node:fs";
22097
22412
  var ANYSEARCH_API_URL = "https://api.anysearch.com/v1/search";
22098
22413
  var CONFIG_PATH24 = getWebSearchConfigPath();
22099
- var SEARCH_TIMEOUT_MS19 = 3e4;
22414
+ var SEARCH_TIMEOUT_MS20 = 3e4;
22100
22415
  var cachedConfig23 = null;
22101
22416
  function loadConfig23() {
22102
22417
  if (cachedConfig23) return cachedConfig23;
@@ -22181,7 +22496,7 @@ async function searchWithAnySearch(query, options = {}) {
22181
22496
  "Content-Type": "application/json"
22182
22497
  },
22183
22498
  body: JSON.stringify(body),
22184
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS19), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS19)
22499
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS20), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS20)
22185
22500
  });
22186
22501
  } catch (err) {
22187
22502
  const message = errorMessage16(err);
@@ -22236,7 +22551,7 @@ init_utils();
22236
22551
  import { existsSync as existsSync27, readFileSync as readFileSync28 } from "node:fs";
22237
22552
  var XCRAWL_API_URL = "https://run.xcrawl.com/v1/serp";
22238
22553
  var CONFIG_PATH25 = getWebSearchConfigPath();
22239
- var SEARCH_TIMEOUT_MS20 = 6e4;
22554
+ var SEARCH_TIMEOUT_MS21 = 6e4;
22240
22555
  var cachedConfig24 = null;
22241
22556
  function loadConfig24() {
22242
22557
  if (cachedConfig24) return cachedConfig24;
@@ -22356,7 +22671,7 @@ async function searchWithXCrawl(query, options = {}) {
22356
22671
  }
22357
22672
  const body = { engine: "google_search", q: query };
22358
22673
  const activityId = activityMonitor.logStart({ type: "api", query });
22359
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS20);
22674
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS21);
22360
22675
  let response;
22361
22676
  try {
22362
22677
  response = await fetch(XCRAWL_API_URL, {
@@ -22377,7 +22692,7 @@ async function searchWithXCrawl(query, options = {}) {
22377
22692
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
22378
22693
  let outgoing;
22379
22694
  if (providerTimeout) {
22380
- outgoing = new Error(`XCrawl search request timed out after ${Math.round(SEARCH_TIMEOUT_MS20 / 1e3)}s`);
22695
+ outgoing = new Error(`XCrawl search request timed out after ${Math.round(SEARCH_TIMEOUT_MS21 / 1e3)}s`);
22381
22696
  } else {
22382
22697
  const redactedMessage = redactCredential(message, apiKey);
22383
22698
  outgoing = redactedMessage === message && err instanceof Error ? err : new Error(redactedMessage);
@@ -22421,7 +22736,7 @@ init_utils();
22421
22736
  import { existsSync as existsSync28, readFileSync as readFileSync29 } from "node:fs";
22422
22737
  var XAI_RESPONSES_URL = "https://api.x.ai/v1/responses";
22423
22738
  var CONFIG_PATH26 = getWebSearchConfigPath();
22424
- var SEARCH_TIMEOUT_MS21 = 6e4;
22739
+ var SEARCH_TIMEOUT_MS22 = 6e4;
22425
22740
  var WEB_SEARCH_AUTH_MODEL_CANDIDATES = ["grok-4.5", "grok-4.3", "grok-build-0.1"];
22426
22741
  var X_SEARCH_AUTH_MODEL_CANDIDATES = ["grok-4.6", ...WEB_SEARCH_AUTH_MODEL_CANDIDATES];
22427
22742
  var DEFAULT_XAI_SEARCH_TOOLS = ["web_search"];
@@ -22674,7 +22989,7 @@ async function searchWithXai(query, options = {}, ctx) {
22674
22989
  input: buildInput(query, options, tools),
22675
22990
  tools: tools.map((type) => ({ type }))
22676
22991
  }),
22677
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS21), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS21)
22992
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS22), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS22)
22678
22993
  });
22679
22994
  if (!response.ok) {
22680
22995
  activityMonitor.logError(activityId, `HTTP ${response.status}`);
@@ -22721,7 +23036,7 @@ init_utils();
22721
23036
  import { existsSync as existsSync29, readFileSync as readFileSync30 } from "node:fs";
22722
23037
  var BRIGHTDATA_API_URL = "https://api.brightdata.com/request";
22723
23038
  var CONFIG_PATH27 = getWebSearchConfigPath();
22724
- var SEARCH_TIMEOUT_MS22 = 6e4;
23039
+ var SEARCH_TIMEOUT_MS23 = 6e4;
22725
23040
  var ZONE_PATTERN = /^[A-Za-z0-9_-]+$/;
22726
23041
  var RECENCY_TBS = {
22727
23042
  day: "qdr:d",
@@ -22860,7 +23175,7 @@ function passesDomainFilters4(url, filters) {
22860
23175
  return filters.include.some((domain) => domainMatches4(hostname2, domain));
22861
23176
  }
22862
23177
  function requestSignal12(signal) {
22863
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS22);
23178
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS23);
22864
23179
  return signal ? AbortSignal.any([signal, timeout]) : timeout;
22865
23180
  }
22866
23181
  function errorMessage18(err) {
@@ -23018,7 +23333,7 @@ init_utils();
23018
23333
  import { existsSync as existsSync30, readFileSync as readFileSync31 } from "node:fs";
23019
23334
  var SERPBASE_API_URL = "https://api.serpbase.dev/google/search";
23020
23335
  var CONFIG_PATH28 = getWebSearchConfigPath();
23021
- var SEARCH_TIMEOUT_MS23 = 6e4;
23336
+ var SEARCH_TIMEOUT_MS24 = 6e4;
23022
23337
  var RECENCY_TBS2 = {
23023
23338
  day: "qdr:d",
23024
23339
  week: "qdr:w",
@@ -23137,7 +23452,7 @@ async function searchWithSerpBase(query, options = {}) {
23137
23452
  try {
23138
23453
  response = await fetch(url, {
23139
23454
  headers: { Accept: "application/json" },
23140
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS23), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS23)
23455
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS24), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS24)
23141
23456
  });
23142
23457
  } catch (err) {
23143
23458
  const message = errorMessage19(err);
@@ -23187,7 +23502,7 @@ init_utils();
23187
23502
  import { existsSync as existsSync31, readFileSync as readFileSync32 } from "node:fs";
23188
23503
  var SERPAPI_SEARCH_URL = "https://serpapi.com/search.json";
23189
23504
  var CONFIG_PATH29 = getWebSearchConfigPath();
23190
- var SEARCH_TIMEOUT_MS24 = 6e4;
23505
+ var SEARCH_TIMEOUT_MS25 = 6e4;
23191
23506
  var RECENCY_TBS3 = {
23192
23507
  day: "qdr:d",
23193
23508
  week: "qdr:w",
@@ -23292,7 +23607,7 @@ async function searchWithSerpApi(query, options = {}) {
23292
23607
  url.searchParams.set("num", String(requestCount));
23293
23608
  if (options.recencyFilter) url.searchParams.set("tbs", RECENCY_TBS3[options.recencyFilter]);
23294
23609
  const activityId = activityMonitor.logStart({ type: "api", query });
23295
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS24);
23610
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS25);
23296
23611
  let response;
23297
23612
  let entries;
23298
23613
  try {
@@ -23319,7 +23634,7 @@ async function searchWithSerpApi(query, options = {}) {
23319
23634
  }
23320
23635
  const message = errorMessage20(err);
23321
23636
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
23322
- const outgoing = providerTimeout ? new Error(`SerpApi request timed out after ${Math.round(SEARCH_TIMEOUT_MS24 / 1e3)}s`) : (() => {
23637
+ const outgoing = providerTimeout ? new Error(`SerpApi request timed out after ${Math.round(SEARCH_TIMEOUT_MS25 / 1e3)}s`) : (() => {
23323
23638
  const redactedMessage = redactCredential(message, apiKey);
23324
23639
  if (redactedMessage === message && err instanceof Error) return err;
23325
23640
  const redactedError = new Error(redactedMessage);
@@ -23355,7 +23670,7 @@ init_utils();
23355
23670
  import { existsSync as existsSync32, readFileSync as readFileSync33 } from "node:fs";
23356
23671
  var SERPER_SEARCH_URL = "https://google.serper.dev/search";
23357
23672
  var CONFIG_PATH30 = getWebSearchConfigPath();
23358
- var SEARCH_TIMEOUT_MS25 = 6e4;
23673
+ var SEARCH_TIMEOUT_MS26 = 6e4;
23359
23674
  var RECENCY_TBS4 = {
23360
23675
  day: "qdr:d",
23361
23676
  week: "qdr:w",
@@ -23459,7 +23774,7 @@ async function searchWithSerper(query, options = {}) {
23459
23774
  method: "POST",
23460
23775
  headers: { "X-API-KEY": apiKey, "Content-Type": "application/json", Accept: "application/json" },
23461
23776
  body: JSON.stringify({ q: buildQuery4(query, filters), num: requestCount, ...options.recencyFilter ? { tbs: RECENCY_TBS4[options.recencyFilter] } : {} }),
23462
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS25), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS25)
23777
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS26), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS26)
23463
23778
  });
23464
23779
  } catch (err) {
23465
23780
  const message = errorMessage21(err);
@@ -23516,7 +23831,7 @@ init_utils();
23516
23831
  import { existsSync as existsSync33, readFileSync as readFileSync34 } from "node:fs";
23517
23832
  var SERPLY_SEARCH_URL = "https://api.serply.io/v1/search";
23518
23833
  var CONFIG_PATH31 = getWebSearchConfigPath();
23519
- var SEARCH_TIMEOUT_MS26 = 6e4;
23834
+ var SEARCH_TIMEOUT_MS27 = 6e4;
23520
23835
  var RECENCY_TBS5 = {
23521
23836
  day: "qdr:d",
23522
23837
  week: "qdr:w",
@@ -23614,7 +23929,7 @@ async function searchWithSerply(query, options = {}) {
23614
23929
  url.searchParams.set("num", String(requestCount));
23615
23930
  if (options.recencyFilter) url.searchParams.set("tbs", RECENCY_TBS5[options.recencyFilter]);
23616
23931
  const activityId = activityMonitor.logStart({ type: "api", query });
23617
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS26);
23932
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS27);
23618
23933
  let response;
23619
23934
  let entries;
23620
23935
  try {
@@ -23641,7 +23956,7 @@ async function searchWithSerply(query, options = {}) {
23641
23956
  }
23642
23957
  const message = errorMessage22(err);
23643
23958
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
23644
- const outgoing = providerTimeout ? new Error(`Serply request timed out after ${Math.round(SEARCH_TIMEOUT_MS26 / 1e3)}s`) : (() => {
23959
+ const outgoing = providerTimeout ? new Error(`Serply request timed out after ${Math.round(SEARCH_TIMEOUT_MS27 / 1e3)}s`) : (() => {
23645
23960
  const redactedMessage = redactCredential(message, apiKey);
23646
23961
  if (redactedMessage === message && err instanceof Error) return err;
23647
23962
  const redactedError = new Error(redactedMessage);
@@ -23683,7 +23998,7 @@ init_utils();
23683
23998
  import { existsSync as existsSync34, readFileSync as readFileSync35 } from "node:fs";
23684
23999
  import { isIP as isIP2 } from "node:net";
23685
24000
  var MCP_URL = "https://agent-toolkit.app.baizhi.cloud/mcp";
23686
- var SEARCH_TIMEOUT_MS27 = 6e4;
24001
+ var SEARCH_TIMEOUT_MS28 = 6e4;
23687
24002
  var CONFIG_PATH32 = getWebSearchConfigPath();
23688
24003
  function credentialOptions() {
23689
24004
  let config = {};
@@ -23726,7 +24041,7 @@ function searchArguments(query, options) {
23726
24041
  }
23727
24042
  async function searchWithBaizhi(query, options = {}) {
23728
24043
  const args = searchArguments(query, options);
23729
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS27);
24044
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS28);
23730
24045
  const signal = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
23731
24046
  if (signal.aborted) throw new Error("Aborted");
23732
24047
  const apiKey = await resolveCredential({ ...credentialOptions(), signal });
@@ -23754,8 +24069,8 @@ async function searchWithBaizhi(query, options = {}) {
23754
24069
  const client = new Client({ name: "pi-web-access-baizhi", version: "1.0.0" });
23755
24070
  const activityId = activityMonitor.logStart({ type: "api", query });
23756
24071
  try {
23757
- await client.connect(transport2, { signal, timeout: SEARCH_TIMEOUT_MS27 });
23758
- const result = await client.callTool({ name: "websearch_search", arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS27 });
24072
+ await client.connect(transport2, { signal, timeout: SEARCH_TIMEOUT_MS28 });
24073
+ const result = await client.callTool({ name: "websearch_search", arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS28 });
23759
24074
  if (result.isError) throw new Error("Baizhi search tool returned an error");
23760
24075
  const parts = [];
23761
24076
  if (result.structuredContent !== void 0) parts.push(JSON.stringify(result.structuredContent, null, 2));
@@ -23799,7 +24114,7 @@ var MCP_URLS = {
23799
24114
  china: "https://open.bigmodel.cn/api/mcp/web_search_prime/mcp"
23800
24115
  };
23801
24116
  var RECENCY = { day: "oneDay", week: "oneWeek", month: "oneMonth", year: "oneYear" };
23802
- var SEARCH_TIMEOUT_MS28 = 6e4;
24117
+ var SEARCH_TIMEOUT_MS29 = 6e4;
23803
24118
  var CONFIG_PATH33 = getWebSearchConfigPath();
23804
24119
  function loadConfig31() {
23805
24120
  if (!existsSync35(CONFIG_PATH33)) return {};
@@ -23870,7 +24185,7 @@ async function searchWithZai(query, options = {}) {
23870
24185
  const mcpUrl = endpointUrl(config);
23871
24186
  const args = searchArguments2(query, options);
23872
24187
  const limit = normalizeSearchResultCount(options.numResults);
23873
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS28);
24188
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS29);
23874
24189
  const signal = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
23875
24190
  if (signal.aborted) throw new Error("Aborted");
23876
24191
  const apiKey = await resolveCredential({ ...credentialOptions2(config), signal });
@@ -23898,11 +24213,11 @@ async function searchWithZai(query, options = {}) {
23898
24213
  const client = new Client({ name: "pi-web-access-zai", version: "1.0.0" });
23899
24214
  const activityId = activityMonitor.logStart({ type: "api", query });
23900
24215
  try {
23901
- await client.connect(transport2, { signal, timeout: SEARCH_TIMEOUT_MS28 });
23902
- const { tools } = await client.listTools(void 0, { signal, timeout: SEARCH_TIMEOUT_MS28 });
24216
+ await client.connect(transport2, { signal, timeout: SEARCH_TIMEOUT_MS29 });
24217
+ const { tools } = await client.listTools(void 0, { signal, timeout: SEARCH_TIMEOUT_MS29 });
23903
24218
  const toolName = tools.find((tool) => tool.name === "web_search_prime" || tool.name === "webSearchPrime")?.name;
23904
24219
  if (!toolName) throw new Error("Z.ai returned invalid response: web search tool not listed");
23905
- const result = await client.callTool({ name: toolName, arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS28 });
24220
+ const result = await client.callTool({ name: toolName, arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS29 });
23906
24221
  if (result.isError) throw new Error("Z.ai search tool returned an error");
23907
24222
  const text4 = (Array.isArray(result.content) ? result.content : []).find((item) => item.type === "text" && typeof item.text === "string");
23908
24223
  if (!text4) throw new Error("Z.ai returned invalid response: no search text");
@@ -23939,7 +24254,7 @@ init_utils();
23939
24254
  import { existsSync as existsSync36, readFileSync as readFileSync37 } from "node:fs";
23940
24255
  var VALYU_SEARCH_URL = "https://api.valyu.ai/v1/search";
23941
24256
  var CONFIG_PATH34 = getWebSearchConfigPath();
23942
- var SEARCH_TIMEOUT_MS29 = 6e4;
24257
+ var SEARCH_TIMEOUT_MS30 = 6e4;
23943
24258
  var MAX_SNIPPET_CHARS = 2500;
23944
24259
  var MAX_CONTENT_CHARS = 4e3;
23945
24260
  var cachedConfig31 = null;
@@ -24033,7 +24348,7 @@ async function searchWithValyu(query, options = {}) {
24033
24348
  method: "POST",
24034
24349
  headers: { "x-api-key": apiKey, "Content-Type": "application/json", Accept: "application/json" },
24035
24350
  body: JSON.stringify({ query, max_num_results: numResults, ...mapDomainFilter9(options.domainFilter), ...startDate ? { start_date: startDate } : {} }),
24036
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS29), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS29)
24351
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS30), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS30)
24037
24352
  });
24038
24353
  } catch (err) {
24039
24354
  const message = errorMessage23(err);
@@ -24093,7 +24408,7 @@ var KEENABLE_SEARCH_URL = "https://api.keenable.ai/v1/search";
24093
24408
  var KEENABLE_PUBLIC_SEARCH_URL = "https://api.keenable.ai/v1/search/public";
24094
24409
  var KEENABLE_CLIENT_TITLE = "pi-web-access";
24095
24410
  var CONFIG_PATH35 = getWebSearchConfigPath();
24096
- var SEARCH_TIMEOUT_MS30 = 3e4;
24411
+ var SEARCH_TIMEOUT_MS31 = 3e4;
24097
24412
  var MAX_REQUEST_RESULTS = 50;
24098
24413
  var MAX_SNIPPET_CHARS2 = 500;
24099
24414
  var RECENCY_DAYS = {
@@ -24195,7 +24510,7 @@ async function searchWithKeenable(query, options = {}) {
24195
24510
  ...apiKey ? { "X-API-Key": apiKey } : {}
24196
24511
  };
24197
24512
  const activityId = activityMonitor.logStart({ type: "api", query });
24198
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS30);
24513
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS31);
24199
24514
  let response;
24200
24515
  let entries;
24201
24516
  try {
@@ -24225,7 +24540,7 @@ async function searchWithKeenable(query, options = {}) {
24225
24540
  }
24226
24541
  const message = errorMessage24(err);
24227
24542
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
24228
- const outgoing = providerTimeout ? new Error(`Keenable request timed out after ${Math.round(SEARCH_TIMEOUT_MS30 / 1e3)}s`) : (() => {
24543
+ const outgoing = providerTimeout ? new Error(`Keenable request timed out after ${Math.round(SEARCH_TIMEOUT_MS31 / 1e3)}s`) : (() => {
24229
24544
  const redactedMessage = redactCredential(message, apiKey);
24230
24545
  if (redactedMessage === message && err instanceof Error) return err;
24231
24546
  const redactedError = new Error(redactedMessage);
@@ -24272,7 +24587,7 @@ init_utils();
24272
24587
  import { existsSync as existsSync38, readFileSync as readFileSync39 } from "node:fs";
24273
24588
  var CERAMIC_SEARCH_URL = "https://api.ceramic.ai/search";
24274
24589
  var CONFIG_PATH36 = getWebSearchConfigPath();
24275
- var SEARCH_TIMEOUT_MS31 = 3e4;
24590
+ var SEARCH_TIMEOUT_MS32 = 3e4;
24276
24591
  var MAX_REQUEST_RESULTS2 = 20;
24277
24592
  var REQUEST_DESCRIPTION_CHARS = 1e3;
24278
24593
  var MAX_SNIPPET_CHARS3 = 500;
@@ -24376,7 +24691,7 @@ async function searchWithCeramic(query, options = {}) {
24376
24691
  maxDescriptionLength: REQUEST_DESCRIPTION_CHARS
24377
24692
  };
24378
24693
  const activityId = activityMonitor.logStart({ type: "api", query });
24379
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS31);
24694
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS32);
24380
24695
  let response;
24381
24696
  let entries;
24382
24697
  try {
@@ -24409,7 +24724,7 @@ async function searchWithCeramic(query, options = {}) {
24409
24724
  }
24410
24725
  const message = errorMessage25(err);
24411
24726
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
24412
- const outgoing = providerTimeout ? new Error(`Ceramic request timed out after ${Math.round(SEARCH_TIMEOUT_MS31 / 1e3)}s`) : (() => {
24727
+ const outgoing = providerTimeout ? new Error(`Ceramic request timed out after ${Math.round(SEARCH_TIMEOUT_MS32 / 1e3)}s`) : (() => {
24413
24728
  const redactedMessage = redactCredential(message, apiKey);
24414
24729
  if (redactedMessage === message && err instanceof Error) return err;
24415
24730
  const redactedError = new Error(redactedMessage);
@@ -24454,7 +24769,7 @@ init_search_result_count_normalization();
24454
24769
  import { randomUUID as randomUUID2 } from "node:crypto";
24455
24770
  var KIMI_SEARCH_URL = "https://api.kimi.com/coding/v1/search";
24456
24771
  var KIMI_PROVIDERS = ["kimi-coding", "kimi-code"];
24457
- var SEARCH_TIMEOUT_MS32 = 3e4;
24772
+ var SEARCH_TIMEOUT_MS33 = 3e4;
24458
24773
  function buildRequestHeaders(auth) {
24459
24774
  const headers = new Headers();
24460
24775
  for (const [name, value] of Object.entries(auth.headers)) {
@@ -24569,7 +24884,7 @@ async function searchWithKimi(query, options = {}, ctx) {
24569
24884
  throw new Error("Kimi Code web search unavailable. Run /login kimi-coding to authenticate a Kimi Code Plan account.");
24570
24885
  }
24571
24886
  const activityId = activityMonitor.logStart({ type: "api", query });
24572
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS32);
24887
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS33);
24573
24888
  const requestSignal15 = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
24574
24889
  try {
24575
24890
  const response = await fetch(KIMI_SEARCH_URL, {
@@ -24624,7 +24939,7 @@ init_utils();
24624
24939
  import { existsSync as existsSync39, readFileSync as readFileSync40 } from "node:fs";
24625
24940
  var MISTRAL_CONVERSATIONS_URL = "https://api.mistral.ai/v1/conversations";
24626
24941
  var CONFIG_PATH37 = getWebSearchConfigPath();
24627
- var SEARCH_TIMEOUT_MS33 = 6e4;
24942
+ var SEARCH_TIMEOUT_MS34 = 6e4;
24628
24943
  var DEFAULT_SEARCH_MODEL = "mistral-small-latest";
24629
24944
  var DEFAULT_SEARCH_TOOL = "web_search";
24630
24945
  var MAX_RESULTS = 20;
@@ -24800,7 +25115,7 @@ async function searchWithMistral(query, options = {}) {
24800
25115
  const tool = resolveSearchTool(config.mistralSearchTool);
24801
25116
  const numResults = normalizeCount4(options.numResults);
24802
25117
  const apiKey = await getApiKey26(options.signal);
24803
- const requestSignal15 = options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS33), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS33);
25118
+ const requestSignal15 = options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS34), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS34);
24804
25119
  const activityId = activityMonitor.logStart({ type: "api", query });
24805
25120
  try {
24806
25121
  const response = await fetch(MISTRAL_CONVERSATIONS_URL, {
@@ -24985,11 +25300,11 @@ function errorMessage27(err) {
24985
25300
  function isAbortError2(err) {
24986
25301
  return errorMessage27(err).toLowerCase().includes("abort");
24987
25302
  }
24988
- async function tryOpenAIInAuto(query, options, fallbackErrors) {
25303
+ async function tryOpenAIInAuto(query, options, fallbackErrors, take) {
24989
25304
  try {
24990
25305
  if (await isOpenAISearchAvailable(options.extensionContext)) {
24991
25306
  const result = await searchWithOpenAI(query, options, options.extensionContext);
24992
- return { ...result, provider: "openai" };
25307
+ return take(result, "openai");
24993
25308
  }
24994
25309
  } catch (err) {
24995
25310
  if (isAbortError2(err)) throw err;
@@ -25311,168 +25626,58 @@ async function search(query, options = {}) {
25311
25626
  return searchWithConfiguredRouting(query, options, config.searchRouting);
25312
25627
  }
25313
25628
  const fallbackErrors = [];
25629
+ let firstEmpty;
25630
+ const take = (result, provider2) => {
25631
+ if (!result) return null;
25632
+ const response = { ...result, provider: provider2 };
25633
+ if (result.results.length || result.answer.trim()) return response;
25634
+ firstEmpty ??= response;
25635
+ return null;
25636
+ };
25314
25637
  const allowed = new Set(config.allowedProviders ?? RESOLVED_SEARCH_PROVIDERS);
25315
- if (allowed.has("searxng") && isSearXNGAvailable()) {
25638
+ const attempt = async (provider2) => {
25639
+ if (!allowed.has(provider2) || !await isResolvedProviderAvailable(provider2, options)) return null;
25316
25640
  try {
25317
- const result = await searchWithSearXNG(query, options);
25318
- return { ...result, provider: "searxng" };
25641
+ return take(await searchWithResolvedProvider(provider2, query, options), provider2);
25319
25642
  } catch (err) {
25320
25643
  if (isAbortError2(err)) throw err;
25321
- fallbackErrors.push(`SearXNG: ${errorMessage27(err)}`);
25644
+ fallbackErrors.push(`${providerLabel(provider2)}: ${errorMessage27(err)}`);
25645
+ return null;
25322
25646
  }
25323
- }
25647
+ };
25648
+ const searxng = await attempt("searxng");
25649
+ if (searxng) return searxng;
25324
25650
  let triedOpenAI = false;
25325
25651
  if (allowed.has("openai") && (!options.extensionContext || isOpenAISubscriptionModelSelected(options.extensionContext))) {
25326
25652
  triedOpenAI = true;
25327
- const result = await tryOpenAIInAuto(query, options, fallbackErrors);
25653
+ const result = await tryOpenAIInAuto(query, options, fallbackErrors, take);
25328
25654
  if (result) return result;
25329
25655
  }
25330
25656
  if (allowed.has("exa") && isExaAvailable()) {
25331
25657
  try {
25332
- const result = await searchWithExa(query, options);
25333
- if (result) return { ...result, provider: "exa" };
25658
+ const response = take(await searchWithExa(query, options), "exa");
25659
+ if (response) return response;
25334
25660
  } catch (err) {
25335
25661
  if (err instanceof CredentialResolutionError || isAbortError2(err)) throw err;
25336
25662
  fallbackErrors.push(`Exa: ${errorMessage27(err)}`);
25337
25663
  }
25338
25664
  }
25339
25665
  if (allowed.has("openai") && !triedOpenAI) {
25340
- const result = await tryOpenAIInAuto(query, options, fallbackErrors);
25666
+ const result = await tryOpenAIInAuto(query, options, fallbackErrors, take);
25341
25667
  if (result) return result;
25342
25668
  }
25343
- if (allowed.has("brave") && isBraveAvailable()) {
25344
- try {
25345
- const result = await searchWithBrave(query, options);
25346
- return { ...result, provider: "brave" };
25347
- } catch (err) {
25348
- if (isAbortError2(err)) throw err;
25349
- fallbackErrors.push(`Brave: ${errorMessage27(err)}`);
25350
- }
25351
- }
25352
- if (allowed.has("parallel") && isParallelAvailable()) {
25353
- try {
25354
- const result = await searchWithParallel(query, options);
25355
- return { ...result, provider: "parallel" };
25356
- } catch (err) {
25357
- if (isAbortError2(err)) throw err;
25358
- fallbackErrors.push(`Parallel: ${errorMessage27(err)}`);
25359
- }
25360
- }
25361
- if (allowed.has("tinyfish") && isTinyFishAvailable()) {
25362
- try {
25363
- const result = await searchWithTinyFish(query, options);
25364
- return { ...result, provider: "tinyfish" };
25365
- } catch (err) {
25366
- if (isAbortError2(err)) throw err;
25367
- fallbackErrors.push(`TinyFish: ${errorMessage27(err)}`);
25368
- }
25369
- }
25370
- if (allowed.has("search1api") && isSearch1APIAvailable()) {
25371
- try {
25372
- const result = await searchWithSearch1API(query, options);
25373
- return { ...result, provider: "search1api" };
25374
- } catch (err) {
25375
- if (isAbortError2(err)) throw err;
25376
- fallbackErrors.push(`Search1API: ${errorMessage27(err)}`);
25377
- }
25378
- }
25379
- if (allowed.has("searchinfinity") && isSearchinfinityAvailable()) {
25380
- try {
25381
- const result = await searchWithSearchinfinity(query, options);
25382
- return { ...result, provider: "searchinfinity" };
25383
- } catch (err) {
25384
- if (isAbortError2(err)) throw err;
25385
- fallbackErrors.push(`Searchinfinity: ${errorMessage27(err)}`);
25386
- }
25387
- }
25388
- if (allowed.has("querit") && isQueritAvailable()) {
25389
- try {
25390
- const result = await searchWithQuerit(query, options);
25391
- return { ...result, provider: "querit" };
25392
- } catch (err) {
25393
- if (isAbortError2(err)) throw err;
25394
- fallbackErrors.push(`Querit: ${errorMessage27(err)}`);
25395
- }
25396
- }
25397
- if (allowed.has("tavily") && isTavilyAvailable()) {
25398
- try {
25399
- const result = await searchWithTavily(query, options);
25400
- return { ...result, provider: "tavily" };
25401
- } catch (err) {
25402
- if (isAbortError2(err)) throw err;
25403
- fallbackErrors.push(`Tavily: ${errorMessage27(err)}`);
25404
- }
25405
- }
25406
- if (allowed.has("firecrawl") && isFirecrawlAvailable()) {
25407
- try {
25408
- const result = await searchWithFirecrawl(query, options);
25409
- return { ...result, provider: "firecrawl" };
25410
- } catch (err) {
25411
- if (isAbortError2(err)) throw err;
25412
- fallbackErrors.push(`Firecrawl: ${errorMessage27(err)}`);
25413
- }
25414
- }
25415
- if (allowed.has("jina") && isJinaSearchAvailable()) {
25416
- try {
25417
- const result = await searchWithJina(query, options);
25418
- return { ...result, provider: "jina" };
25419
- } catch (err) {
25420
- if (isAbortError2(err)) throw err;
25421
- fallbackErrors.push(`Jina: ${errorMessage27(err)}`);
25422
- }
25423
- }
25424
- if (allowed.has("serpdive") && isSerpdiveAvailable()) {
25425
- try {
25426
- const result = await searchWithSerpdive(query, options);
25427
- return { ...result, provider: "serpdive" };
25428
- } catch (err) {
25429
- if (isAbortError2(err)) throw err;
25430
- fallbackErrors.push(`SERPdive: ${errorMessage27(err)}`);
25431
- }
25432
- }
25433
- if (allowed.has("kagi") && isKagiAvailable()) {
25434
- try {
25435
- const result = await searchWithKagi(query, options);
25436
- return { ...result, provider: "kagi" };
25437
- } catch (err) {
25438
- if (isAbortError2(err)) throw err;
25439
- fallbackErrors.push(`Kagi: ${errorMessage27(err)}`);
25440
- }
25441
- }
25442
- if (allowed.has("bocha") && isBochaAvailable()) {
25443
- try {
25444
- const result = await searchWithBocha(query, options);
25445
- return { ...result, provider: "bocha" };
25446
- } catch (err) {
25447
- if (isAbortError2(err)) throw err;
25448
- fallbackErrors.push(`Bocha: ${errorMessage27(err)}`);
25449
- }
25450
- }
25451
- if (allowed.has("ollama") && isOllamaAvailable()) {
25452
- try {
25453
- const result = await searchWithOllama(query, options);
25454
- return { ...result, provider: "ollama" };
25455
- } catch (err) {
25456
- if (isAbortError2(err)) throw err;
25457
- fallbackErrors.push(`Ollama: ${errorMessage27(err)}`);
25458
- }
25459
- }
25460
- if (allowed.has("perplexity") && isPerplexityAvailable()) {
25461
- try {
25462
- const result = await searchWithPerplexity(query, options);
25463
- return { ...result, provider: "perplexity" };
25464
- } catch (err) {
25465
- if (isAbortError2(err)) throw err;
25466
- fallbackErrors.push(`Perplexity: ${errorMessage27(err)}`);
25467
- }
25669
+ for (const provider2 of ["brave", "parallel", "tinyfish", "search1api", "searchinfinity", "querit", "tavily", "firecrawl", "jina", "serpdive", "kagi", "bocha", "ollama", "perplexity"]) {
25670
+ const response = await attempt(provider2);
25671
+ if (response) return response;
25468
25672
  }
25469
25673
  if (allowed.has("gemini")) try {
25470
- const geminiResult = await searchWithGemini(query, options, false);
25471
- if (geminiResult) return { ...geminiResult, provider: "gemini" };
25674
+ const response = take(await searchWithGemini(query, options, false), "gemini");
25675
+ if (response) return response;
25472
25676
  } catch (err) {
25473
25677
  if (isAbortError2(err)) throw err;
25474
25678
  fallbackErrors.push(`Gemini: ${errorMessage27(err)}`);
25475
25679
  }
25680
+ if (firstEmpty) return firstEmpty;
25476
25681
  if (fallbackErrors.length > 0) {
25477
25682
  throw new Error(`Auto provider search failed:
25478
25683
  - ${fallbackErrors.join("\n - ")}`);
@@ -25757,7 +25962,7 @@ function createMcpServer(core2, info, enabledTools) {
25757
25962
  }
25758
25963
 
25759
25964
  // web-tool-core.ts
25760
- import { existsSync as existsSync52, readFileSync as readFileSync54 } from "node:fs";
25965
+ import { existsSync as existsSync53, readFileSync as readFileSync55 } from "node:fs";
25761
25966
  import pLimit2 from "p-limit";
25762
25967
 
25763
25968
  // fetch-params.ts
@@ -25775,6 +25980,7 @@ function normalizeFetchContentParams(params) {
25775
25980
  const answerModel = normalizeOptionalString(params.answerModel);
25776
25981
  const auth = normalizeAuth(params.auth);
25777
25982
  const proxy = normalizeProxy(params.proxy);
25983
+ const redirects = normalizeRedirects(params.redirects);
25778
25984
  return {
25779
25985
  urlList,
25780
25986
  options: {
@@ -25786,7 +25992,8 @@ function normalizeFetchContentParams(params) {
25786
25992
  ...mode !== void 0 ? { mode } : {},
25787
25993
  ...answerModel !== void 0 ? { answerModel } : {},
25788
25994
  ...auth !== void 0 ? { auth } : {},
25789
- ...proxy !== void 0 ? { proxy } : {}
25995
+ ...proxy !== void 0 ? { proxy } : {},
25996
+ ...redirects !== void 0 ? { redirects } : {}
25790
25997
  }
25791
25998
  };
25792
25999
  }
@@ -25809,6 +26016,11 @@ function normalizeMode(value) {
25809
26016
  if (value === "readable" || value === "raw" || value === "answer") return value;
25810
26017
  throw new Error('mode must be "readable", "raw", or "answer"');
25811
26018
  }
26019
+ function normalizeRedirects(value) {
26020
+ if (value === void 0) return void 0;
26021
+ if (value === "same-origin") return value;
26022
+ throw new Error('redirects must be "same-origin"');
26023
+ }
25812
26024
  function normalizeAuth(value) {
25813
26025
  if (value === void 0 || value === false) return void 0;
25814
26026
  if (value === true) return true;
@@ -26000,7 +26212,7 @@ function findContent(text4, queries, mode) {
26000
26212
  if (contained.length === 0) continue;
26001
26213
  const prefix = range.start > 0 ? "\u2026" : "";
26002
26214
  const suffix = range.end < text4.length ? "\u2026" : "";
26003
- const snippet = `${prefix}${text4.slice(range.start, range.end).replace(/\s+/g, " ").trim()}${suffix}`;
26215
+ const snippet = `${prefix}${text4.slice(range.start, range.end).replace(/[\uD800-\uDFFF]/gu, "\uFFFD").replace(/\s+/g, " ").trim()}${suffix}`;
26004
26216
  const counts = contained.map((result) => `${overflow ? result.id : `"${result.query}"`} \xD7${result.count}`).join(", ");
26005
26217
  sections.push(`${index + 1}. ${counts}
26006
26218
  ${snippet}`);
@@ -26452,8 +26664,8 @@ function parseConfigRoot(raw) {
26452
26664
  return parsed;
26453
26665
  }
26454
26666
  function loadConfig40() {
26455
- if (!existsSync52(WEB_SEARCH_CONFIG_PATH4)) return {};
26456
- return parseConfigRoot(readFileSync54(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
26667
+ if (!existsSync53(WEB_SEARCH_CONFIG_PATH4)) return {};
26668
+ return parseConfigRoot(readFileSync55(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
26457
26669
  }
26458
26670
  var DEFAULT_TOOL_NAMES = {
26459
26671
  webSearch: "web_search",
@@ -26598,7 +26810,7 @@ function fetchStructuredContent(responseId, results) {
26598
26810
  };
26599
26811
  }
26600
26812
  function initialContentSlice(content, maxChars) {
26601
- let endOffset = Math.min(content.length, maxChars);
26813
+ let endOffset = pageEnd(content, 0, Math.min(content.length, maxChars));
26602
26814
  if (endOffset < content.length) {
26603
26815
  const lineBreak = content.lastIndexOf("\n", endOffset);
26604
26816
  if (lineBreak >= Math.floor(maxChars * 0.8)) endOffset = lineBreak + 1;
@@ -26751,7 +26963,8 @@ function boundSearchPresentation(text4, guidance, truncationGuidance, maxChars)
26751
26963
  function registeredFetchToolNames(settings2) {
26752
26964
  return {
26753
26965
  ...settings2.enabledTools.webSearch ? { webSearch: settings2.toolNames.webSearch } : {},
26754
- ...settings2.enabledTools.fetchContent ? { fetchContent: settings2.toolNames.fetchContent } : {}
26966
+ ...settings2.enabledTools.fetchContent ? { fetchContent: settings2.toolNames.fetchContent } : {},
26967
+ ...settings2.enabledTools.getSearchContent ? { getSearchContent: settings2.toolNames.getSearchContent } : {}
26755
26968
  };
26756
26969
  }
26757
26970
  function storedContentSourceNames(settings2) {
@@ -26761,14 +26974,21 @@ function storedContentSourceNames(settings2) {
26761
26974
  ...settings2.enabledTools.fetchContent ? [settings2.toolNames.fetchContent] : []
26762
26975
  ]);
26763
26976
  }
26977
+ function pageEnd(content, offset, end) {
26978
+ if (end <= offset || end >= content.length) return end;
26979
+ const high = content.charCodeAt(end - 1);
26980
+ const low = content.charCodeAt(end);
26981
+ if (high < 55296 || high > 56319 || low < 56320 || low > 57343) return end;
26982
+ return end - 1 > offset ? end - 1 : end + 1;
26983
+ }
26764
26984
  function sliceWithContinuation(content, offset, limit, maxChars, continuationAt) {
26765
- let endOffset = offset + Math.min(limit, content.length - offset);
26985
+ let endOffset = pageEnd(content, offset, offset + Math.min(limit, content.length - offset));
26766
26986
  let continuation = "";
26767
26987
  while (endOffset < content.length) {
26768
26988
  continuation = continuationAt(endOffset);
26769
26989
  const overflow = endOffset - offset + continuation.length - maxChars;
26770
26990
  if (overflow <= 0) break;
26771
- endOffset -= overflow;
26991
+ endOffset = pageEnd(content, offset, endOffset - overflow);
26772
26992
  }
26773
26993
  return { endOffset, text: content.slice(offset, endOffset) + (endOffset < content.length ? continuation : "") };
26774
26994
  }
@@ -26872,8 +27092,12 @@ Full search results are stored as responseId "${searchId}". `;
26872
27092
  return value;
26873
27093
  };
26874
27094
  const presentation = hasApprovedSummary ? { text: unboundedPresentation, truncated: false, originalChars: unboundedPresentation.length, returnedChars: unboundedPresentation.length, omittedChars: 0 } : boundSearchPresentation(unboundedPresentation, buildGuidance(false), buildGuidance(true), maxInlineContentChars);
27095
+ const summaryGuidance = hasApprovedSummary ? buildGuidance(false) : "";
26875
27096
  return {
26876
- content: [{ type: "text", text: presentation.text }],
27097
+ content: [
27098
+ { type: "text", text: presentation.text },
27099
+ ...summaryGuidance ? [{ type: "text", text: summaryGuidance }] : []
27100
+ ],
26877
27101
  structuredContent: searchStructuredContent(searchId, fetchId, opts.results),
26878
27102
  details: {
26879
27103
  queries: opts.queryList,
@@ -27138,7 +27362,7 @@ Full search results are stored as responseId "${searchId}". `;
27138
27362
  const fetchResults = await fetchAllContent2(urlList, signal, fetchOptions(requestOptions, options.proxy));
27139
27363
  const presentedResults = mode === "answer" ? await Promise.all(fetchResults.map(async (result) => {
27140
27364
  if (result.error) return result;
27141
- if (result.thumbnail || result.mimeType?.startsWith("image/")) {
27365
+ if (result.mimeType?.startsWith("image/") || result.frames?.length) {
27142
27366
  return { ...result, error: "Page answer requires textual fetched content" };
27143
27367
  }
27144
27368
  try {
@@ -27184,7 +27408,8 @@ Full search results are stored as responseId "${searchId}". `;
27184
27408
 
27185
27409
  ---
27186
27410
  Showing ${slice.endOffset} of ${fullLength} chars, ${slice.shownBytes} of ${slice.totalBytes} bytes, and ${slice.shownLines} of ${slice.totalLines} lines. `;
27187
- output2 += storedContent ? getSearchContentEnabled ? `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.";
27411
+ if (mode === "answer") output2 += "Stored content is the original source, not the remaining answer. ";
27412
+ 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.";
27188
27413
  }
27189
27414
  const content = [];
27190
27415
  if (result.frames?.length) {
@@ -27196,6 +27421,15 @@ Showing ${slice.endOffset} of ${fullLength} chars, ${slice.shownBytes} of ${slic
27196
27421
  content.push({ type: "image", data: result.thumbnail.data, mimeType: result.thumbnail.mimeType });
27197
27422
  }
27198
27423
  content.push({ type: "text", text: output2 });
27424
+ if (!truncated && storedContent && getSearchContentEnabled) {
27425
+ const storedLabel = mode === "answer" ? "Original source content" : "Full content";
27426
+ content.push({
27427
+ type: "text",
27428
+ text: `
27429
+ ---
27430
+ ${storedLabel} is stored as responseId "${responseId}". Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0, offset: 0 }) to retrieve it.`
27431
+ });
27432
+ }
27199
27433
  const imageCount = (result.frames?.length ?? 0) + (result.thumbnail ? 1 : 0);
27200
27434
  return {
27201
27435
  content,
@@ -27224,19 +27458,33 @@ Showing ${slice.endOffset} of ${fullLength} chars, ${slice.shownBytes} of ${slic
27224
27458
  }
27225
27459
  };
27226
27460
  }
27227
- let output = "## Fetched URLs\n\n";
27461
+ let budget = mode === "answer" ? getMaxInlineContentChars() : 0;
27462
+ let output = mode === "answer" ? "## Page answers\n" : "## Fetched URLs\n\n";
27228
27463
  for (const { url, title, content, error } of presentedResults) {
27229
- if (error) {
27230
- output += `- ${url}: Error - ${error}
27464
+ if (mode !== "answer") {
27465
+ output += error ? `- ${url}: Error - ${error}
27466
+ ` : `- ${title || url} (${content.length} chars)
27467
+ `;
27468
+ } else if (error) {
27469
+ output += `
27470
+ ### ${url}
27471
+ Error: ${error}
27231
27472
  `;
27232
27473
  } else {
27233
- output += `- ${title || url} (${content.length} chars)
27474
+ const shown = content.slice(0, budget);
27475
+ budget -= shown.length;
27476
+ const marker = shown.length === content.length ? "" : `
27477
+ [answer ${shown.length ? "truncated at the output limit;" : "omitted; earlier answers used the output limit,"} fetch fewer URLs per call for complete answers]`;
27478
+ output += `
27479
+ ### ${title || url}
27480
+ ${shown}${marker}
27234
27481
  `;
27235
27482
  }
27236
27483
  }
27484
+ 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.`;
27237
27485
  output += storedContent ? getSearchContentEnabled ? `
27238
27486
  ---
27239
- Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0 }) to retrieve bounded content slices.` : "\n---\nContent retrieval is not registered." : "\n---\nAuthenticated fetch cache is off; repeat the fetch to read content.";
27487
+ ${retrievalHint}` : "\n---\nContent retrieval is not registered." : "\n---\nAuthenticated fetch cache is off; repeat the fetch to read content.";
27240
27488
  return {
27241
27489
  ...successful === 0 ? { isError: true } : {},
27242
27490
  content: [{ type: "text", text: output }],
@@ -27490,7 +27738,7 @@ ${text5}` }],
27490
27738
  details: { error: "Offset out of range", offset, contentLength: urlData.content.length }
27491
27739
  };
27492
27740
  }
27493
- const endOffset = Math.min(offset + limit, urlData.content.length);
27741
+ const endOffset = pageEnd(urlData.content, offset, Math.min(offset + limit, urlData.content.length));
27494
27742
  const contentSlice = urlData.content.slice(offset, endOffset);
27495
27743
  const hasMore = endOffset < urlData.content.length;
27496
27744
  let text4 = `# ${urlData.title || urlData.url}