@herbertgao/pi-extensions 2026.10.5 → 2026.10.7

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 (510) hide show
  1. package/README.md +10 -14
  2. package/THIRD_PARTY_NOTICES.md +1 -53
  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 +1 -2
  23. package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -2
  24. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +5 -0
  25. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +22 -0
  26. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/agent-summary/core.ts +2 -3
  27. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +1 -1
  28. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +396 -146
  29. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/reference/index.ts +2 -0
  30. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/reference/subagent.ts +3 -0
  31. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +10 -6
  32. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/token-rate.ts +15 -3
  33. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/working-message.ts +2 -23
  34. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +195 -77
  35. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +23 -471
  36. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +6 -3
  37. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +16 -83
  38. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/hover.ts +1 -1
  39. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +68 -28
  40. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/packets.ts +1 -1
  41. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts +53 -5
  42. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ask-user-question.ts +1 -1
  43. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +467 -0
  44. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/codemode.ts +1 -1
  45. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/ansi-utils.ts +1 -24
  46. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-edit-render.ts +1 -1
  47. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-limits.ts +1 -1
  48. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-text.ts +2 -1
  49. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-write-render.ts +1 -1
  50. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/line-width-safety.ts +1 -1
  51. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +53 -34
  52. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/message-display.ts +1 -1
  53. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +41 -1
  54. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +2 -862
  55. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-io.ts +735 -0
  56. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-state.ts +138 -0
  57. package/node_modules/@herbertgao/pi-cc-extensions/package.json +6 -5
  58. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark.json +1 -1
  59. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light.json +2 -2
  60. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +8 -0
  61. package/node_modules/@herbertgao/pi-subagents/docs/packages.md +211 -0
  62. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +61 -63
  63. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +24 -16
  64. package/node_modules/@herbertgao/pi-subagents/package.json +6 -5
  65. package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +51 -14
  66. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +123 -55
  67. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +144 -13
  68. package/node_modules/@herbertgao/pi-subagents/src/agent-source-badge.ts +78 -0
  69. package/node_modules/@herbertgao/pi-subagents/src/completion-outbox.ts +122 -0
  70. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +171 -79
  71. package/node_modules/@herbertgao/pi-subagents/src/index.ts +597 -296
  72. package/node_modules/@herbertgao/pi-subagents/src/package-resources.ts +724 -0
  73. package/node_modules/@herbertgao/pi-subagents/src/schedule.ts +1 -1
  74. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +66 -0
  75. package/node_modules/@herbertgao/pi-subagents/src/types.ts +26 -4
  76. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +2 -0
  77. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +354 -32
  78. package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +33 -15
  79. package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +6 -0
  80. package/node_modules/@herbertgao/pi-subagents/src/workflow/saved.ts +48 -2
  81. package/node_modules/@herbertgao/sol-pi/README.md +3 -3
  82. package/node_modules/@herbertgao/sol-pi/THIRD_PARTY_NOTICES.md +4 -4
  83. package/node_modules/@herbertgao/sol-pi/agents-install.md +3 -3
  84. package/node_modules/@herbertgao/sol-pi/docs/compatibility.md +1 -1
  85. package/node_modules/@herbertgao/sol-pi/package.json +2 -2
  86. package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +3 -3
  87. package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +89 -39
  88. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/configuration.md +1 -1
  89. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +4 -4
  90. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +56 -23
  91. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/tool-schema.md +6 -3
  92. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/de.json +3 -1
  93. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/en.json +3 -1
  94. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/es.json +3 -1
  95. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/fr.json +3 -1
  96. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt-BR.json +3 -1
  97. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt.json +3 -1
  98. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/ru.json +3 -1
  99. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/uk.json +3 -1
  100. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/zh.json +3 -1
  101. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +5 -2
  102. package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +122 -0
  103. package/node_modules/@juicesharp/rpiv-ask-user-question/rpc-fallback.ts +73 -36
  104. package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +10 -1
  105. package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +15 -13
  106. package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +5 -1
  107. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/derivations.ts +15 -0
  108. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/projections.ts +4 -1
  109. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +29 -18
  110. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +1 -1
  111. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/format-answer.ts +5 -2
  112. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/normalize-params.ts +46 -0
  113. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/response-envelope.ts +19 -8
  114. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/types.ts +9 -2
  115. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/multi-select-view.ts +4 -2
  116. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +56 -25
  117. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-pane.ts +131 -46
  118. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +94 -106
  119. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +51 -0
  120. package/node_modules/@juicesharp/rpiv-ask-user-question/view/scroll-window.ts +73 -0
  121. package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +31 -10
  122. package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts.map +1 -1
  123. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +474 -93
  124. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
  125. package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
  126. package/node_modules/pi-lens/CHANGELOG.md +88 -0
  127. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +3 -1
  128. package/node_modules/pi-lens/dist/{chunk-BJF25SUG.js → chunk-23WOO7TX.js} +11 -10
  129. package/node_modules/pi-lens/dist/{chunk-WATC3IQR.js → chunk-2B73ZPOK.js} +3 -3
  130. package/node_modules/pi-lens/dist/{chunk-N2IRDBZI.js → chunk-2BBLFX75.js} +101 -11
  131. package/node_modules/pi-lens/dist/{chunk-TA5L5KWQ.js → chunk-2CD5RS6M.js} +2 -2
  132. package/node_modules/pi-lens/dist/{chunk-3TTPKMEF.js → chunk-2VUQMUMT.js} +38 -37
  133. package/node_modules/pi-lens/dist/{chunk-5JHXUETW.js → chunk-3EFKIGZN.js} +3 -3
  134. package/node_modules/pi-lens/dist/chunk-3JNKMP3B.js +17 -0
  135. package/node_modules/pi-lens/dist/{chunk-6P54TMWL.js → chunk-3VPVG5SU.js} +6 -6
  136. package/node_modules/pi-lens/dist/{chunk-ZETYB3XG.js → chunk-3W7IEVVL.js} +44 -28
  137. package/node_modules/pi-lens/dist/chunk-3YN6V5TV.js +85 -0
  138. package/node_modules/pi-lens/dist/chunk-466Z26MG.js +30 -0
  139. package/node_modules/pi-lens/dist/{chunk-PCHDGUKT.js → chunk-4UNXBNE2.js} +12 -11
  140. package/node_modules/pi-lens/dist/{chunk-J7WJZ6W7.js → chunk-4W4VLAPJ.js} +12 -11
  141. package/node_modules/pi-lens/dist/{chunk-F5VLZHUW.js → chunk-52FUZI6K.js} +4 -2
  142. package/node_modules/pi-lens/dist/{chunk-H5EV3VMF.js → chunk-5NGR67U5.js} +2 -2
  143. package/node_modules/pi-lens/dist/{chunk-CBD2B5CP.js → chunk-5UCAH366.js} +21 -20
  144. package/node_modules/pi-lens/dist/{chunk-BHWHXMQ2.js → chunk-67WMNWEE.js} +9 -8
  145. package/node_modules/pi-lens/dist/{chunk-USHG4DLH.js → chunk-6C7JWPCP.js} +7 -7
  146. package/node_modules/pi-lens/dist/{chunk-VPWKF3GN.js → chunk-6GFRNVYR.js} +11 -10
  147. package/node_modules/pi-lens/dist/{chunk-3JL6IFD7.js → chunk-6SDEP3AJ.js} +9 -8
  148. package/node_modules/pi-lens/dist/{chunk-NJF2X5XF.js → chunk-6STA6Z7I.js} +19 -17
  149. package/node_modules/pi-lens/dist/{chunk-KJCWXUUS.js → chunk-724UL2TJ.js} +6 -4
  150. package/node_modules/pi-lens/dist/{chunk-MQA2YBAH.js → chunk-76MWC2K6.js} +3 -3
  151. package/node_modules/pi-lens/dist/{chunk-YLN4K6WD.js → chunk-77M37OKR.js} +10 -8
  152. package/node_modules/pi-lens/dist/{chunk-XHSCVSOL.js → chunk-7DYBLXYA.js} +3 -3
  153. package/node_modules/pi-lens/dist/{chunk-OC7LYAU5.js → chunk-AB3YYG6N.js} +24 -10
  154. package/node_modules/pi-lens/dist/{chunk-LD7WFTRX.js → chunk-ACXEQZOU.js} +16 -16
  155. package/node_modules/pi-lens/dist/{chunk-VSMJK3ZJ.js → chunk-AOHZU2BM.js} +1 -1
  156. package/node_modules/pi-lens/dist/{chunk-T4QZ6FEH.js → chunk-AW7R2GWG.js} +65 -8
  157. package/node_modules/pi-lens/dist/{chunk-GAYGGICG.js → chunk-BKE7E7TC.js} +10 -9
  158. package/node_modules/pi-lens/dist/{chunk-EUT3B22Y.js → chunk-BRGDSBJE.js} +13 -12
  159. package/node_modules/pi-lens/dist/{chunk-T54VJRAD.js → chunk-C34ZXZ7O.js} +55 -11
  160. package/node_modules/pi-lens/dist/{chunk-UGSMCQ4D.js → chunk-CHOW74WE.js} +1 -1
  161. package/node_modules/pi-lens/dist/{chunk-H2W2AXD3.js → chunk-CMMHNUZ2.js} +66 -58
  162. package/node_modules/pi-lens/dist/chunk-CSHFH5IN.js +17 -0
  163. package/node_modules/pi-lens/dist/chunk-EC47DWFA.js +56 -0
  164. package/node_modules/pi-lens/dist/{chunk-KJN4IOEJ.js → chunk-EJIUXPBX.js} +1 -1
  165. package/node_modules/pi-lens/dist/{chunk-IQZXOZ7S.js → chunk-EU63SDCG.js} +720 -334
  166. package/node_modules/pi-lens/dist/{chunk-LNOMA3MP.js → chunk-FCSOVF55.js} +107 -3
  167. package/node_modules/pi-lens/dist/{chunk-CFYISHUW.js → chunk-FLKWCIZH.js} +8 -5
  168. package/node_modules/pi-lens/dist/{chunk-OYTMZXRF.js → chunk-FMSO6RDZ.js} +16 -14
  169. package/node_modules/pi-lens/dist/{chunk-IUKPRZER.js → chunk-GAEGEPOC.js} +2 -2
  170. package/node_modules/pi-lens/dist/{chunk-6XX5HCLK.js → chunk-GBPP5P7X.js} +4 -4
  171. package/node_modules/pi-lens/dist/{chunk-TQFBZVCG.js → chunk-GXW6K4YJ.js} +1 -1
  172. package/node_modules/pi-lens/dist/{chunk-ZZUFZUQZ.js → chunk-H6MF6EVN.js} +331 -107
  173. package/node_modules/pi-lens/dist/{chunk-3JSEWUWI.js → chunk-IBGIOBEE.js} +3 -3
  174. package/node_modules/pi-lens/dist/chunk-IZSHAIJ7.js +26 -0
  175. package/node_modules/pi-lens/dist/{chunk-7ELY2CSM.js → chunk-JAU72XNY.js} +16 -14
  176. package/node_modules/pi-lens/dist/chunk-JMYYOTQG.js +77 -0
  177. package/node_modules/pi-lens/dist/{chunk-ELVWJYRV.js → chunk-JSQFTSC6.js} +12 -11
  178. package/node_modules/pi-lens/dist/{chunk-J6DFZDFA.js → chunk-KBG47GHP.js} +4 -4
  179. package/node_modules/pi-lens/dist/chunk-KDERNTCQ.js +28 -0
  180. package/node_modules/pi-lens/dist/chunk-KSX3TXSZ.js +69 -0
  181. package/node_modules/pi-lens/dist/{chunk-XGUL4SLQ.js → chunk-L3BLXZG7.js} +2 -2
  182. package/node_modules/pi-lens/dist/chunk-LOP6GRPH.js +31 -0
  183. package/node_modules/pi-lens/dist/{chunk-MTDRLSI7.js → chunk-M6HSLBWY.js} +1064 -986
  184. package/node_modules/pi-lens/dist/chunk-MQLUAEOC.js +162 -0
  185. package/node_modules/pi-lens/dist/{chunk-3MRXIJ6I.js → chunk-MRXKYPCS.js} +2 -2
  186. package/node_modules/pi-lens/dist/{chunk-D65GOCJB.js → chunk-MXGY6KPT.js} +19 -16
  187. package/node_modules/pi-lens/dist/{chunk-G3RLJYA2.js → chunk-N2H3ZPZY.js} +47 -1
  188. package/node_modules/pi-lens/dist/{chunk-HREZQCT3.js → chunk-N3X6Q4YT.js} +3 -3
  189. package/node_modules/pi-lens/dist/{chunk-HSIRMK2D.js → chunk-OCAGUNBC.js} +15 -15
  190. package/node_modules/pi-lens/dist/{chunk-ZOEYVXSV.js → chunk-OXXKQCSV.js} +6 -6
  191. package/node_modules/pi-lens/dist/{chunk-S6AMWKPC.js → chunk-P7266HLM.js} +2 -2
  192. package/node_modules/pi-lens/dist/{chunk-64LU2OVH.js → chunk-PHDMFAKM.js} +12 -2
  193. package/node_modules/pi-lens/dist/{chunk-IMSQR4WO.js → chunk-PNQDPDRC.js} +1 -1
  194. package/node_modules/pi-lens/dist/{chunk-IUR76K6A.js → chunk-Q7DUK4LX.js} +5 -5
  195. package/node_modules/pi-lens/dist/{chunk-CULQYFLU.js → chunk-QGQ5CCCG.js} +2 -2
  196. package/node_modules/pi-lens/dist/{chunk-UEAHAMEI.js → chunk-QHJ6DQ2R.js} +11 -11
  197. package/node_modules/pi-lens/dist/{chunk-BNKLYOOO.js → chunk-QILIYSJF.js} +1 -1
  198. package/node_modules/pi-lens/dist/{chunk-VYKKMYVT.js → chunk-QOBUHWHX.js} +11 -6
  199. package/node_modules/pi-lens/dist/{chunk-3PNFWVHT.js → chunk-QQNQ7SJW.js} +2 -75
  200. package/node_modules/pi-lens/dist/{chunk-7M4T5N3V.js → chunk-R3PCY3YS.js} +14 -13
  201. package/node_modules/pi-lens/dist/{chunk-MGIWSROG.js → chunk-RPLINGVB.js} +7 -7
  202. package/node_modules/pi-lens/dist/{chunk-CMU4RMJB.js → chunk-RWWYJ623.js} +10 -1
  203. package/node_modules/pi-lens/dist/{chunk-3FERWMCH.js → chunk-RXCOMYPY.js} +27 -26
  204. package/node_modules/pi-lens/dist/{chunk-7BX5DWSA.js → chunk-SAEFPSB6.js} +11 -11
  205. package/node_modules/pi-lens/dist/{chunk-N7YNJE5R.js → chunk-SQ4TVJBR.js} +10 -10
  206. package/node_modules/pi-lens/dist/{chunk-DMS52BEP.js → chunk-SS36ZX4J.js} +9 -7
  207. package/node_modules/pi-lens/dist/{chunk-JONGANYH.js → chunk-T6CPIZNT.js} +32 -30
  208. package/node_modules/pi-lens/dist/{chunk-6UYA642J.js → chunk-TYM6OUIT.js} +13 -12
  209. package/node_modules/pi-lens/dist/{chunk-ALQRYH6O.js → chunk-UXGETRP4.js} +13 -12
  210. package/node_modules/pi-lens/dist/{chunk-FGALODG3.js → chunk-UZ3TUTRV.js} +1 -1
  211. package/node_modules/pi-lens/dist/{chunk-J3FZR3YY.js → chunk-VCHXCQFG.js} +3 -3
  212. package/node_modules/pi-lens/dist/{chunk-3P4PF2BX.js → chunk-VCO24T4L.js} +34 -22
  213. package/node_modules/pi-lens/dist/{chunk-O7HZX7CA.js → chunk-VRZP76YM.js} +1 -1
  214. package/node_modules/pi-lens/dist/{chunk-VZHJS6DR.js → chunk-VSSBEUFT.js} +16 -15
  215. package/node_modules/pi-lens/dist/{chunk-U52SAGRM.js → chunk-VWCXW2E7.js} +1 -1
  216. package/node_modules/pi-lens/dist/{chunk-WW5BLB74.js → chunk-WOA4LN2R.js} +2 -2
  217. package/node_modules/pi-lens/dist/{chunk-ZMOMPX2Z.js → chunk-WU567RSC.js} +11 -10
  218. package/node_modules/pi-lens/dist/{chunk-N77WFUL7.js → chunk-XAGLWMJ4.js} +23 -22
  219. package/node_modules/pi-lens/dist/{chunk-WSEWKCXU.js → chunk-XCJN5IJU.js} +4 -4
  220. package/node_modules/pi-lens/dist/{chunk-IR6XFA5P.js → chunk-XIJZVPD5.js} +16 -14
  221. package/node_modules/pi-lens/dist/{chunk-OYOB3ZFG.js → chunk-XMSXXAHW.js} +2 -2
  222. package/node_modules/pi-lens/dist/{chunk-34OCDWOS.js → chunk-XTMJ7XDT.js} +1 -1
  223. package/node_modules/pi-lens/dist/{chunk-Z6BB4JLQ.js → chunk-XVF2VVXP.js} +5 -3
  224. package/node_modules/pi-lens/dist/{chunk-AFZYMAIV.js → chunk-YIUAVF7E.js} +37 -35
  225. package/node_modules/pi-lens/dist/{chunk-NFXP47RV.js → chunk-YSZNHOBY.js} +85 -31
  226. package/node_modules/pi-lens/dist/{chunk-V5MEBST3.js → chunk-YYOIQFRS.js} +21 -21
  227. package/node_modules/pi-lens/dist/chunk-Z527N6YQ.js +28 -0
  228. package/node_modules/pi-lens/dist/{chunk-D6YF5HKX.js → chunk-ZANLILYD.js} +22 -2
  229. package/node_modules/pi-lens/dist/{chunk-2UMYMRI3.js → chunk-ZGDGW2V3.js} +2 -2
  230. package/node_modules/pi-lens/dist/{chunk-6B5I6ICN.js → chunk-ZHFZWTZV.js} +12 -11
  231. package/node_modules/pi-lens/dist/{chunk-OEX24ECI.js → chunk-ZWFS3OEF.js} +51 -41
  232. package/node_modules/pi-lens/dist/{chunk-AXKPQ6ZI.js → chunk-ZXYDQ3TZ.js} +5 -5
  233. package/node_modules/pi-lens/dist/index.js +73783 -71033
  234. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +18 -8
  235. package/node_modules/pi-lens/dist/mcp/cli.js +48 -37
  236. package/node_modules/pi-lens/dist/mcp/server.js +568 -397
  237. package/node_modules/pi-lens/dist/mcp/worker.js +67 -55
  238. package/node_modules/pi-lens/dist/probes/installer.js +20 -19
  239. package/node_modules/pi-lens/docs/astplayground.md +1 -1
  240. package/node_modules/pi-lens/docs/configuration.md +29 -0
  241. package/node_modules/pi-lens/docs/dependencies.md +3 -0
  242. package/node_modules/pi-lens/docs/features.md +2 -2
  243. package/node_modules/pi-lens/docs/globalconfig.md +2 -0
  244. package/node_modules/pi-lens/docs/language-coverage.md +2 -1
  245. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +29 -7
  246. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +38 -47
  247. package/node_modules/pi-lens/docs/pi-lens-fixer.md +4 -0
  248. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +17 -4
  249. package/node_modules/pi-lens/docs/pi-lens-retro.md +2 -1
  250. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +18 -0
  251. package/node_modules/pi-lens/docs/pi-lens-subagent.md +7 -0
  252. package/node_modules/pi-lens/docs/real-harness.md +17 -0
  253. package/node_modules/pi-lens/docs/schema/pi-lens-config-v1.json +37 -2
  254. package/node_modules/pi-lens/docs/servercapabilities.md +15 -4
  255. package/node_modules/pi-lens/docs/settings.md +2 -1
  256. package/node_modules/pi-lens/package.json +1 -1
  257. package/node_modules/pi-provider-qoder/dist/index.js +30 -2
  258. package/node_modules/pi-provider-qoder/package.json +1 -1
  259. package/node_modules/pi-web-access/CHANGELOG.md +50 -0
  260. package/node_modules/pi-web-access/README.md +13 -7
  261. package/node_modules/pi-web-access/brave.ts +20 -2
  262. package/node_modules/pi-web-access/content-find.ts +2 -1
  263. package/node_modules/pi-web-access/dist/index.js +655 -406
  264. package/node_modules/pi-web-access/dist/mcp-cli.js +653 -416
  265. package/node_modules/pi-web-access/duckduckgo.ts +5 -1
  266. package/node_modules/pi-web-access/endpoint-pdf-extract.ts +225 -0
  267. package/node_modules/pi-web-access/extract.ts +51 -13
  268. package/node_modules/pi-web-access/fetch-params.ts +10 -0
  269. package/node_modules/pi-web-access/gemini-api.ts +15 -0
  270. package/node_modules/pi-web-access/gemini-search.ts +32 -152
  271. package/node_modules/pi-web-access/github-issue-pr.ts +80 -68
  272. package/node_modules/pi-web-access/index.ts +3 -0
  273. package/node_modules/pi-web-access/package.json +1 -1
  274. package/node_modules/pi-web-access/pdf-extract.ts +38 -4
  275. package/node_modules/pi-web-access/perplexity.ts +19 -2
  276. package/node_modules/pi-web-access/ssrf-protection.ts +24 -4
  277. package/node_modules/pi-web-access/summary-review.ts +10 -0
  278. package/node_modules/pi-web-access/tool-arguments.ts +5 -2
  279. package/node_modules/pi-web-access/video-extract.ts +6 -2
  280. package/node_modules/pi-web-access/web-tool-core.ts +53 -13
  281. package/package.json +19 -24
  282. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/show-more-hint.ts +0 -48
  283. package/node_modules/pi-jev-auto-mode/CHANGELOG.md +0 -118
  284. package/node_modules/pi-jev-auto-mode/LICENSE +0 -21
  285. package/node_modules/pi-jev-auto-mode/README.md +0 -292
  286. package/node_modules/pi-jev-auto-mode/SECURITY.md +0 -32
  287. package/node_modules/pi-jev-auto-mode/docs/calibration.md +0 -154
  288. package/node_modules/pi-jev-auto-mode/docs/design.md +0 -164
  289. package/node_modules/pi-jev-auto-mode/docs/security.md +0 -124
  290. package/node_modules/pi-jev-auto-mode/index.ts +0 -1
  291. package/node_modules/pi-jev-auto-mode/package.json +0 -72
  292. package/node_modules/pi-jev-auto-mode/src/call.ts +0 -180
  293. package/node_modules/pi-jev-auto-mode/src/decide.ts +0 -86
  294. package/node_modules/pi-jev-auto-mode/src/extension.ts +0 -881
  295. package/node_modules/pi-jev-auto-mode/src/intent.ts +0 -71
  296. package/node_modules/pi-jev-auto-mode/src/jev/availability.ts +0 -53
  297. package/node_modules/pi-jev-auto-mode/src/jev/criteria.ts +0 -19
  298. package/node_modules/pi-jev-auto-mode/src/jev/decide.ts +0 -187
  299. package/node_modules/pi-jev-auto-mode/src/jev/engine.ts +0 -165
  300. package/node_modules/pi-jev-auto-mode/src/jev/index.ts +0 -20
  301. package/node_modules/pi-jev-auto-mode/src/jev/questions.ts +0 -273
  302. package/node_modules/pi-jev-auto-mode/src/jev/response.ts +0 -64
  303. package/node_modules/pi-jev-auto-mode/src/jev/state.ts +0 -20
  304. package/node_modules/pi-jev-auto-mode/src/jev/transport.ts +0 -117
  305. package/node_modules/pi-jev-auto-mode/src/jev/types.ts +0 -46
  306. package/node_modules/pi-jev-auto-mode/src/policy.ts +0 -558
  307. package/node_modules/pi-jev-auto-mode/src/records.ts +0 -184
  308. package/node_modules/pi-jev-auto-mode/src/settings.ts +0 -349
  309. package/node_modules/pi-jev-auto-mode/src/ui.ts +0 -243
  310. package/node_modules/pi-lens/dist/chunk-2FQ62SPM.js +0 -83
  311. package/node_modules/pi-lens/dist/chunk-7AXO3ZDF.js +0 -30
  312. package/node_modules/pi-lens/dist/chunk-KMGPUKFD.js +0 -25
  313. package/node_modules/pi-lens/dist/chunk-OZJINN4O.js +0 -84
  314. package/node_modules/pi-lens/dist/chunk-RJFED73B.js +0 -79
  315. package/node_modules/pi-lens/dist/chunk-RTQNRM5X.js +0 -27
  316. package/node_modules/pi-lens/dist/chunk-VGEVL5EQ.js +0 -29
  317. package/node_modules/pi-lens/dist/chunk-WPE5FPGR.js +0 -54
  318. package/node_modules/pi-lens/dist/chunk-Z7QQA2KT.js +0 -27
  319. package/node_modules/resume-from/LICENSE +0 -21
  320. package/node_modules/resume-from/README.md +0 -167
  321. package/node_modules/resume-from/dist/adapters/claude-code/adapter.d.ts +0 -20
  322. package/node_modules/resume-from/dist/adapters/claude-code/adapter.js +0 -59
  323. package/node_modules/resume-from/dist/adapters/claude-code/contract.d.ts +0 -8
  324. package/node_modules/resume-from/dist/adapters/claude-code/contract.js +0 -4
  325. package/node_modules/resume-from/dist/adapters/claude-code/entries.d.ts +0 -30
  326. package/node_modules/resume-from/dist/adapters/claude-code/entries.js +0 -107
  327. package/node_modules/resume-from/dist/adapters/claude-code/index.d.ts +0 -3
  328. package/node_modules/resume-from/dist/adapters/claude-code/index.js +0 -2
  329. package/node_modules/resume-from/dist/adapters/claude-code/layout.d.ts +0 -29
  330. package/node_modules/resume-from/dist/adapters/claude-code/layout.js +0 -80
  331. package/node_modules/resume-from/dist/adapters/claude-code/readback.d.ts +0 -9
  332. package/node_modules/resume-from/dist/adapters/claude-code/readback.js +0 -39
  333. package/node_modules/resume-from/dist/adapters/claude-code/reader.d.ts +0 -40
  334. package/node_modules/resume-from/dist/adapters/claude-code/reader.js +0 -436
  335. package/node_modules/resume-from/dist/adapters/claude-code/redaction.d.ts +0 -26
  336. package/node_modules/resume-from/dist/adapters/claude-code/redaction.js +0 -145
  337. package/node_modules/resume-from/dist/adapters/claude-code/validation.d.ts +0 -4
  338. package/node_modules/resume-from/dist/adapters/claude-code/validation.js +0 -39
  339. package/node_modules/resume-from/dist/adapters/claude-code/writer.d.ts +0 -21
  340. package/node_modules/resume-from/dist/adapters/claude-code/writer.js +0 -306
  341. package/node_modules/resume-from/dist/adapters/codex/contract.d.ts +0 -13
  342. package/node_modules/resume-from/dist/adapters/codex/contract.js +0 -4
  343. package/node_modules/resume-from/dist/adapters/codex/index.d.ts +0 -6
  344. package/node_modules/resume-from/dist/adapters/codex/index.js +0 -43
  345. package/node_modules/resume-from/dist/adapters/codex/read.d.ts +0 -44
  346. package/node_modules/resume-from/dist/adapters/codex/read.js +0 -723
  347. package/node_modules/resume-from/dist/adapters/codex/readback.d.ts +0 -9
  348. package/node_modules/resume-from/dist/adapters/codex/readback.js +0 -47
  349. package/node_modules/resume-from/dist/adapters/codex/redaction.d.ts +0 -26
  350. package/node_modules/resume-from/dist/adapters/codex/redaction.js +0 -145
  351. package/node_modules/resume-from/dist/adapters/codex/rollout.d.ts +0 -115
  352. package/node_modules/resume-from/dist/adapters/codex/rollout.js +0 -269
  353. package/node_modules/resume-from/dist/adapters/codex/validation.d.ts +0 -7
  354. package/node_modules/resume-from/dist/adapters/codex/validation.js +0 -78
  355. package/node_modules/resume-from/dist/adapters/codex/write.d.ts +0 -17
  356. package/node_modules/resume-from/dist/adapters/codex/write.js +0 -141
  357. package/node_modules/resume-from/dist/adapters/contract.d.ts +0 -78
  358. package/node_modules/resume-from/dist/adapters/contract.js +0 -4
  359. package/node_modules/resume-from/dist/adapters/pi/adapter.d.ts +0 -15
  360. package/node_modules/resume-from/dist/adapters/pi/adapter.js +0 -213
  361. package/node_modules/resume-from/dist/adapters/pi/contract.d.ts +0 -24
  362. package/node_modules/resume-from/dist/adapters/pi/contract.js +0 -4
  363. package/node_modules/resume-from/dist/adapters/pi/format.d.ts +0 -162
  364. package/node_modules/resume-from/dist/adapters/pi/format.js +0 -223
  365. package/node_modules/resume-from/dist/adapters/pi/index.d.ts +0 -7
  366. package/node_modules/resume-from/dist/adapters/pi/index.js +0 -10
  367. package/node_modules/resume-from/dist/adapters/pi/parse.d.ts +0 -41
  368. package/node_modules/resume-from/dist/adapters/pi/parse.js +0 -371
  369. package/node_modules/resume-from/dist/adapters/pi/redaction.d.ts +0 -26
  370. package/node_modules/resume-from/dist/adapters/pi/redaction.js +0 -145
  371. package/node_modules/resume-from/dist/adapters/pi/serialize.d.ts +0 -20
  372. package/node_modules/resume-from/dist/adapters/pi/serialize.js +0 -87
  373. package/node_modules/resume-from/dist/adapters/pi/validate.d.ts +0 -14
  374. package/node_modules/resume-from/dist/adapters/pi/validate.js +0 -134
  375. package/node_modules/resume-from/dist/bin.d.ts +0 -35
  376. package/node_modules/resume-from/dist/bin.js +0 -135
  377. package/node_modules/resume-from/dist/contract.d.ts +0 -10
  378. package/node_modules/resume-from/dist/contract.js +0 -4
  379. package/node_modules/resume-from/dist/host/agents.d.ts +0 -29
  380. package/node_modules/resume-from/dist/host/agents.js +0 -20
  381. package/node_modules/resume-from/dist/host/cli/args.d.ts +0 -21
  382. package/node_modules/resume-from/dist/host/cli/args.js +0 -187
  383. package/node_modules/resume-from/dist/host/cli/contract.d.ts +0 -27
  384. package/node_modules/resume-from/dist/host/cli/contract.js +0 -4
  385. package/node_modules/resume-from/dist/host/cli/index.d.ts +0 -2
  386. package/node_modules/resume-from/dist/host/cli/index.js +0 -1
  387. package/node_modules/resume-from/dist/host/cli/presentation.d.ts +0 -2
  388. package/node_modules/resume-from/dist/host/cli/presentation.js +0 -11
  389. package/node_modules/resume-from/dist/host/cli/render.d.ts +0 -3
  390. package/node_modules/resume-from/dist/host/cli/render.js +0 -70
  391. package/node_modules/resume-from/dist/host/cli/runner.d.ts +0 -8
  392. package/node_modules/resume-from/dist/host/cli/runner.js +0 -125
  393. package/node_modules/resume-from/dist/host/contract.d.ts +0 -42
  394. package/node_modules/resume-from/dist/host/contract.js +0 -4
  395. package/node_modules/resume-from/dist/host/entry.d.ts +0 -52
  396. package/node_modules/resume-from/dist/host/entry.js +0 -91
  397. package/node_modules/resume-from/dist/host/index.d.ts +0 -11
  398. package/node_modules/resume-from/dist/host/index.js +0 -10
  399. package/node_modules/resume-from/dist/host/pi-extension/command.d.ts +0 -18
  400. package/node_modules/resume-from/dist/host/pi-extension/command.js +0 -126
  401. package/node_modules/resume-from/dist/host/pi-extension/contract.d.ts +0 -34
  402. package/node_modules/resume-from/dist/host/pi-extension/contract.js +0 -4
  403. package/node_modules/resume-from/dist/host/pi-extension/index.d.ts +0 -6
  404. package/node_modules/resume-from/dist/host/pi-extension/index.js +0 -4
  405. package/node_modules/resume-from/dist/host/pi-extension/picker.d.ts +0 -16
  406. package/node_modules/resume-from/dist/host/pi-extension/picker.js +0 -35
  407. package/node_modules/resume-from/dist/host/pi-extension/presentation.d.ts +0 -2
  408. package/node_modules/resume-from/dist/host/pi-extension/presentation.js +0 -11
  409. package/node_modules/resume-from/dist/host/pi-extension/register.d.ts +0 -25
  410. package/node_modules/resume-from/dist/host/pi-extension/register.js +0 -11
  411. package/node_modules/resume-from/dist/host/pi-extension/ui.d.ts +0 -20
  412. package/node_modules/resume-from/dist/host/pi-extension/ui.js +0 -1
  413. package/node_modules/resume-from/dist/host/profile.d.ts +0 -8
  414. package/node_modules/resume-from/dist/host/profile.js +0 -31
  415. package/node_modules/resume-from/dist/host/registry.d.ts +0 -8
  416. package/node_modules/resume-from/dist/host/registry.js +0 -33
  417. package/node_modules/resume-from/dist/host/wiring.d.ts +0 -41
  418. package/node_modules/resume-from/dist/host/wiring.js +0 -66
  419. package/node_modules/resume-from/dist/import/confirmation.d.ts +0 -9
  420. package/node_modules/resume-from/dist/import/confirmation.js +0 -27
  421. package/node_modules/resume-from/dist/import/contract.d.ts +0 -43
  422. package/node_modules/resume-from/dist/import/contract.js +0 -4
  423. package/node_modules/resume-from/dist/import/discovery/contract.d.ts +0 -63
  424. package/node_modules/resume-from/dist/import/discovery/contract.js +0 -4
  425. package/node_modules/resume-from/dist/import/discovery/errors.d.ts +0 -9
  426. package/node_modules/resume-from/dist/import/discovery/errors.js +0 -12
  427. package/node_modules/resume-from/dist/import/discovery/finder.d.ts +0 -11
  428. package/node_modules/resume-from/dist/import/discovery/finder.js +0 -269
  429. package/node_modules/resume-from/dist/import/discovery/homes.d.ts +0 -23
  430. package/node_modules/resume-from/dist/import/discovery/homes.js +0 -83
  431. package/node_modules/resume-from/dist/import/discovery/index.d.ts +0 -2
  432. package/node_modules/resume-from/dist/import/discovery/index.js +0 -2
  433. package/node_modules/resume-from/dist/import/discovery/ordering.d.ts +0 -3
  434. package/node_modules/resume-from/dist/import/discovery/ordering.js +0 -21
  435. package/node_modules/resume-from/dist/import/errors.d.ts +0 -22
  436. package/node_modules/resume-from/dist/import/errors.js +0 -20
  437. package/node_modules/resume-from/dist/import/index.d.ts +0 -3
  438. package/node_modules/resume-from/dist/import/index.js +0 -5
  439. package/node_modules/resume-from/dist/import/landing/contract.d.ts +0 -44
  440. package/node_modules/resume-from/dist/import/landing/contract.js +0 -4
  441. package/node_modules/resume-from/dist/import/landing/errors.d.ts +0 -15
  442. package/node_modules/resume-from/dist/import/landing/errors.js +0 -15
  443. package/node_modules/resume-from/dist/import/landing/handover.d.ts +0 -5
  444. package/node_modules/resume-from/dist/import/landing/handover.js +0 -12
  445. package/node_modules/resume-from/dist/import/landing/index.d.ts +0 -4
  446. package/node_modules/resume-from/dist/import/landing/index.js +0 -4
  447. package/node_modules/resume-from/dist/import/landing/lander.d.ts +0 -7
  448. package/node_modules/resume-from/dist/import/landing/lander.js +0 -133
  449. package/node_modules/resume-from/dist/import/landing/marker.d.ts +0 -9
  450. package/node_modules/resume-from/dist/import/landing/marker.js +0 -46
  451. package/node_modules/resume-from/dist/import/pipeline.d.ts +0 -28
  452. package/node_modules/resume-from/dist/import/pipeline.js +0 -154
  453. package/node_modules/resume-from/dist/import/preview/builder.d.ts +0 -6
  454. package/node_modules/resume-from/dist/import/preview/builder.js +0 -80
  455. package/node_modules/resume-from/dist/import/preview/contract.d.ts +0 -39
  456. package/node_modules/resume-from/dist/import/preview/contract.js +0 -4
  457. package/node_modules/resume-from/dist/import/preview/format.d.ts +0 -19
  458. package/node_modules/resume-from/dist/import/preview/format.js +0 -45
  459. package/node_modules/resume-from/dist/import/preview/index.d.ts +0 -2
  460. package/node_modules/resume-from/dist/import/preview/index.js +0 -1
  461. package/node_modules/resume-from/dist/import/preview/warnings.d.ts +0 -14
  462. package/node_modules/resume-from/dist/import/preview/warnings.js +0 -86
  463. package/node_modules/resume-from/dist/import/transfer/contract.d.ts +0 -48
  464. package/node_modules/resume-from/dist/import/transfer/contract.js +0 -4
  465. package/node_modules/resume-from/dist/import/transfer/index.d.ts +0 -2
  466. package/node_modules/resume-from/dist/import/transfer/index.js +0 -1
  467. package/node_modules/resume-from/dist/import/transfer/rules.d.ts +0 -3
  468. package/node_modules/resume-from/dist/import/transfer/rules.js +0 -228
  469. package/node_modules/resume-from/dist/import/wiring.d.ts +0 -24
  470. package/node_modules/resume-from/dist/import/wiring.js +0 -37
  471. package/node_modules/resume-from/dist/index.d.ts +0 -36
  472. package/node_modules/resume-from/dist/index.js +0 -36
  473. package/node_modules/resume-from/dist/platform/config/contract.d.ts +0 -35
  474. package/node_modules/resume-from/dist/platform/config/contract.js +0 -4
  475. package/node_modules/resume-from/dist/platform/config/defaults.d.ts +0 -16
  476. package/node_modules/resume-from/dist/platform/config/defaults.js +0 -22
  477. package/node_modules/resume-from/dist/platform/config/errors.d.ts +0 -9
  478. package/node_modules/resume-from/dist/platform/config/errors.js +0 -12
  479. package/node_modules/resume-from/dist/platform/config/index.d.ts +0 -5
  480. package/node_modules/resume-from/dist/platform/config/index.js +0 -6
  481. package/node_modules/resume-from/dist/platform/config/loader.d.ts +0 -10
  482. package/node_modules/resume-from/dist/platform/config/loader.js +0 -47
  483. package/node_modules/resume-from/dist/platform/config/paths.d.ts +0 -13
  484. package/node_modules/resume-from/dist/platform/config/paths.js +0 -37
  485. package/node_modules/resume-from/dist/platform/config/validate.d.ts +0 -9
  486. package/node_modules/resume-from/dist/platform/config/validate.js +0 -117
  487. package/node_modules/resume-from/dist/platform/repo/contract.d.ts +0 -36
  488. package/node_modules/resume-from/dist/platform/repo/contract.js +0 -4
  489. package/node_modules/resume-from/dist/platform/repo/git.d.ts +0 -21
  490. package/node_modules/resume-from/dist/platform/repo/git.js +0 -77
  491. package/node_modules/resume-from/dist/platform/repo/index.d.ts +0 -2
  492. package/node_modules/resume-from/dist/platform/repo/index.js +0 -1
  493. package/node_modules/resume-from/dist/platform/repo/reader.d.ts +0 -3
  494. package/node_modules/resume-from/dist/platform/repo/reader.js +0 -170
  495. package/node_modules/resume-from/dist/platform/store/contract.d.ts +0 -31
  496. package/node_modules/resume-from/dist/platform/store/contract.js +0 -4
  497. package/node_modules/resume-from/dist/platform/store/file-committer.d.ts +0 -3
  498. package/node_modules/resume-from/dist/platform/store/file-committer.js +0 -391
  499. package/node_modules/resume-from/dist/platform/store/index.d.ts +0 -2
  500. package/node_modules/resume-from/dist/platform/store/index.js +0 -2
  501. package/node_modules/resume-from/dist/platform/tokens/contract.d.ts +0 -12
  502. package/node_modules/resume-from/dist/platform/tokens/contract.js +0 -4
  503. package/node_modules/resume-from/dist/platform/tokens/estimator.d.ts +0 -12
  504. package/node_modules/resume-from/dist/platform/tokens/estimator.js +0 -111
  505. package/node_modules/resume-from/dist/platform/tokens/index.d.ts +0 -2
  506. package/node_modules/resume-from/dist/platform/tokens/index.js +0 -1
  507. package/node_modules/resume-from/dist/session/contract.d.ts +0 -116
  508. package/node_modules/resume-from/dist/session/contract.js +0 -4
  509. package/node_modules/resume-from/package.json +0 -83
  510. package/node_modules/resume-from/shims/pi/extensions/resume-from.js +0 -118
@@ -2075,6 +2075,16 @@ function getVersionedApiBase() {
2075
2075
  function getUploadBase() {
2076
2076
  return `${getApiHost()}/upload/${API_VERSION}`;
2077
2077
  }
2078
+ function rewriteUploadUrlOrigin(url) {
2079
+ try {
2080
+ const parsed = new URL(url);
2081
+ const base = getApiHost();
2082
+ if (parsed.origin === new URL(base).origin) return url;
2083
+ return `${base}${parsed.pathname}${parsed.search}`;
2084
+ } catch {
2085
+ return url;
2086
+ }
2087
+ }
2078
2088
  function getLegacyCloudflareApiKey() {
2079
2089
  return normalizeApiKey(process.env.CLOUDFLARE_API_KEY) ?? normalizeApiKey(loadConfig2().cloudflareApiKey);
2080
2090
  }
@@ -3403,6 +3413,9 @@ async function postPerplexity(url, body, options) {
3403
3413
  windowMs: RATE_LIMIT.windowMs
3404
3414
  });
3405
3415
  const apiKey = await getApiKey2(options.signal);
3416
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS);
3417
+ const timedOut = () => timeout.aborted && !options.signal?.aborted;
3418
+ const timeoutError = () => new Error("Perplexity API error 408: request timed out");
3406
3419
  let response;
3407
3420
  try {
3408
3421
  response = await fetch(url, {
@@ -3412,9 +3425,13 @@ async function postPerplexity(url, body, options) {
3412
3425
  "Content-Type": "application/json"
3413
3426
  },
3414
3427
  body: JSON.stringify(body),
3415
- ...options.signal ? { signal: options.signal } : {}
3428
+ signal: options.signal ? AbortSignal.any([options.signal, timeout]) : timeout
3416
3429
  });
3417
3430
  } catch (err) {
3431
+ if (timedOut()) {
3432
+ activityMonitor.logError(activityId, "request timed out");
3433
+ throw timeoutError();
3434
+ }
3418
3435
  const message = err instanceof Error ? err.message : String(err);
3419
3436
  const redactedMessage = redactCredential(message, apiKey);
3420
3437
  if (redactedMessage.toLowerCase().includes("abort")) {
@@ -3429,12 +3446,19 @@ async function postPerplexity(url, body, options) {
3429
3446
  }
3430
3447
  activityMonitor.logComplete(activityId, response.status);
3431
3448
  if (!response.ok) {
3432
- const errorText = redactCredential(await response.text(), apiKey);
3449
+ let errorText;
3450
+ try {
3451
+ errorText = redactCredential(await response.text(), apiKey);
3452
+ } catch (err) {
3453
+ if (timedOut()) throw timeoutError();
3454
+ throw err;
3455
+ }
3433
3456
  throw new Error(`Perplexity API error ${response.status}: ${errorText}`);
3434
3457
  }
3435
3458
  try {
3436
3459
  return await response.json();
3437
3460
  } catch (err) {
3461
+ if (timedOut()) throw timeoutError();
3438
3462
  const message = err instanceof Error ? err.message : String(err);
3439
3463
  throw new Error(`Perplexity API returned invalid JSON: ${message}`);
3440
3464
  }
@@ -3479,7 +3503,7 @@ async function askPerplexity(prompt, options = {}) {
3479
3503
  const content = data.choices?.[0]?.message?.content;
3480
3504
  return typeof content === "string" ? content : "";
3481
3505
  }
3482
- var PERPLEXITY_SEARCH_URL, PERPLEXITY_CHAT_URL, CONFIG_PATH5, RATE_LIMIT, requestTimestamps, cachedConfig5;
3506
+ var PERPLEXITY_SEARCH_URL, PERPLEXITY_CHAT_URL, CONFIG_PATH5, SEARCH_TIMEOUT_MS, RATE_LIMIT, requestTimestamps, cachedConfig5;
3483
3507
  var init_perplexity = __esm({
3484
3508
  "perplexity.ts"() {
3485
3509
  init_activity();
@@ -3489,6 +3513,7 @@ var init_perplexity = __esm({
3489
3513
  PERPLEXITY_SEARCH_URL = "https://api.perplexity.ai/search";
3490
3514
  PERPLEXITY_CHAT_URL = "https://api.perplexity.ai/chat/completions";
3491
3515
  CONFIG_PATH5 = getWebSearchConfigPath();
3516
+ SEARCH_TIMEOUT_MS = 3e4;
3492
3517
  RATE_LIMIT = {
3493
3518
  maxRequests: 10,
3494
3519
  windowMs: 60 * 1e3
@@ -3601,7 +3626,7 @@ function isParallelAvailable() {
3601
3626
  return hasParallelApiKey();
3602
3627
  }
3603
3628
  function requestSignal2(signal) {
3604
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS3);
3629
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS4);
3605
3630
  return signal ? AbortSignal.any([signal, timeout]) : timeout;
3606
3631
  }
3607
3632
  function errorMessage(err) {
@@ -3795,7 +3820,7 @@ async function parallelFetch(url, body, signal) {
3795
3820
  throw new Error(`Parallel API returned invalid JSON: ${errorMessage(err)}`);
3796
3821
  }
3797
3822
  }
3798
- var PARALLEL_SEARCH_URL, PARALLEL_EXTRACT_URL, CONFIG_PATH9, MIN_PARALLEL_API_KEY_LENGTH, MIN_USEFUL_CONTENT, SEARCH_TIMEOUT_MS3, PLACEHOLDER_API_KEY_DENYLIST, cachedConfig9;
3823
+ var PARALLEL_SEARCH_URL, PARALLEL_EXTRACT_URL, CONFIG_PATH9, MIN_PARALLEL_API_KEY_LENGTH, MIN_USEFUL_CONTENT, SEARCH_TIMEOUT_MS4, PLACEHOLDER_API_KEY_DENYLIST, cachedConfig9;
3799
3824
  var init_parallel = __esm({
3800
3825
  "parallel.ts"() {
3801
3826
  init_activity();
@@ -3807,7 +3832,7 @@ var init_parallel = __esm({
3807
3832
  CONFIG_PATH9 = getWebSearchConfigPath();
3808
3833
  MIN_PARALLEL_API_KEY_LENGTH = 8;
3809
3834
  MIN_USEFUL_CONTENT = 500;
3810
- SEARCH_TIMEOUT_MS3 = 6e4;
3835
+ SEARCH_TIMEOUT_MS4 = 6e4;
3811
3836
  PLACEHOLDER_API_KEY_DENYLIST = /* @__PURE__ */ new Set([
3812
3837
  "replace_with_your_parallel_api_key",
3813
3838
  "parallel_api_key",
@@ -4237,7 +4262,7 @@ async function searchWithTinyFish(query, options = {}) {
4237
4262
  buildSearchUrl(query, options, page),
4238
4263
  apiKey,
4239
4264
  { method: "GET" },
4240
- SEARCH_TIMEOUT_MS4,
4265
+ SEARCH_TIMEOUT_MS5,
4241
4266
  options.signal
4242
4267
  );
4243
4268
  if (!Array.isArray(data.results)) throw new Error("TinyFish Search API returned an unexpected response shape");
@@ -4295,7 +4320,7 @@ async function extractWithTinyFish(url, signal, options = {}) {
4295
4320
  throw redactedError;
4296
4321
  }
4297
4322
  }
4298
- var TINYFISH_SEARCH_URL, TINYFISH_FETCH_URL, CONFIG_PATH11, SEARCH_TIMEOUT_MS4, FETCH_TIMEOUT_MS, MAX_FETCH_URLS, MAX_FETCH_PER_URL_TIMEOUT_MS, cachedConfig10;
4323
+ var TINYFISH_SEARCH_URL, TINYFISH_FETCH_URL, CONFIG_PATH11, SEARCH_TIMEOUT_MS5, FETCH_TIMEOUT_MS, MAX_FETCH_URLS, MAX_FETCH_PER_URL_TIMEOUT_MS, cachedConfig10;
4299
4324
  var init_tinyfish = __esm({
4300
4325
  "tinyfish.ts"() {
4301
4326
  init_activity();
@@ -4307,7 +4332,7 @@ var init_tinyfish = __esm({
4307
4332
  TINYFISH_SEARCH_URL = "https://api.search.tinyfish.ai";
4308
4333
  TINYFISH_FETCH_URL = "https://api.fetch.tinyfish.ai";
4309
4334
  CONFIG_PATH11 = getWebSearchConfigPath();
4310
- SEARCH_TIMEOUT_MS4 = 6e4;
4335
+ SEARCH_TIMEOUT_MS5 = 6e4;
4311
4336
  FETCH_TIMEOUT_MS = 15e4;
4312
4337
  MAX_FETCH_URLS = 10;
4313
4338
  MAX_FETCH_PER_URL_TIMEOUT_MS = 11e4;
@@ -4457,7 +4482,7 @@ async function searchWithSearch1API(query, options = {}) {
4457
4482
  SEARCH1API_SEARCH_URL,
4458
4483
  apiKey,
4459
4484
  buildSearchBody(query, options),
4460
- SEARCH_TIMEOUT_MS5,
4485
+ SEARCH_TIMEOUT_MS6,
4461
4486
  options.signal
4462
4487
  );
4463
4488
  const results = mapSearchResults3(data.results);
@@ -4518,7 +4543,7 @@ async function extractWithSearch1API(url, signal, options = {}) {
4518
4543
  throw redactedError;
4519
4544
  }
4520
4545
  }
4521
- var SEARCH1API_SEARCH_URL, SEARCH1API_CRAWL_URL, CONFIG_PATH12, SEARCH_TIMEOUT_MS5, CRAWL_TIMEOUT_MS, cachedConfig11;
4546
+ var SEARCH1API_SEARCH_URL, SEARCH1API_CRAWL_URL, CONFIG_PATH12, SEARCH_TIMEOUT_MS6, CRAWL_TIMEOUT_MS, cachedConfig11;
4522
4547
  var init_search1api = __esm({
4523
4548
  "search1api.ts"() {
4524
4549
  init_activity();
@@ -4530,7 +4555,7 @@ var init_search1api = __esm({
4530
4555
  SEARCH1API_SEARCH_URL = "https://api.search1api.com/search";
4531
4556
  SEARCH1API_CRAWL_URL = "https://api.search1api.com/crawl";
4532
4557
  CONFIG_PATH12 = getWebSearchConfigPath();
4533
- SEARCH_TIMEOUT_MS5 = 6e4;
4558
+ SEARCH_TIMEOUT_MS6 = 6e4;
4534
4559
  CRAWL_TIMEOUT_MS = 6e4;
4535
4560
  cachedConfig11 = null;
4536
4561
  }
@@ -4760,7 +4785,7 @@ async function searchWithQuerit(query, options = {}) {
4760
4785
  QUERIT_SEARCH_URL,
4761
4786
  apiKey,
4762
4787
  buildSearchBody3(query, options),
4763
- SEARCH_TIMEOUT_MS7,
4788
+ SEARCH_TIMEOUT_MS8,
4764
4789
  options.signal
4765
4790
  );
4766
4791
  assertApiSuccess("Search", data);
@@ -4810,7 +4835,7 @@ async function extractWithQuerit(url, signal, options = {}) {
4810
4835
  throw redactedError;
4811
4836
  }
4812
4837
  }
4813
- var QUERIT_SEARCH_URL, QUERIT_CONTENTS_URL, CONFIG_PATH14, SEARCH_TIMEOUT_MS7, CONTENTS_TIMEOUT_MS, MAX_CONTENT_URLS, cachedConfig13;
4838
+ var QUERIT_SEARCH_URL, QUERIT_CONTENTS_URL, CONFIG_PATH14, SEARCH_TIMEOUT_MS8, CONTENTS_TIMEOUT_MS, MAX_CONTENT_URLS, cachedConfig13;
4814
4839
  var init_querit = __esm({
4815
4840
  "querit.ts"() {
4816
4841
  init_activity();
@@ -4822,7 +4847,7 @@ var init_querit = __esm({
4822
4847
  QUERIT_SEARCH_URL = "https://api.querit.ai/v1/search";
4823
4848
  QUERIT_CONTENTS_URL = "https://api.querit.ai/v1/contents";
4824
4849
  CONFIG_PATH14 = getWebSearchConfigPath();
4825
- SEARCH_TIMEOUT_MS7 = 6e4;
4850
+ SEARCH_TIMEOUT_MS8 = 6e4;
4826
4851
  CONTENTS_TIMEOUT_MS = 6e4;
4827
4852
  MAX_CONTENT_URLS = 10;
4828
4853
  cachedConfig13 = null;
@@ -4860,15 +4885,26 @@ function loadConfigRoot() {
4860
4885
  cachedConfigRoot = { signature, value };
4861
4886
  return value;
4862
4887
  }
4863
- function loadFetchContentDomainPolicy() {
4888
+ function loadFetchContentConfig() {
4864
4889
  const parsed = loadConfigRoot();
4865
- if (!parsed) return { ...DEFAULT_DOMAIN_POLICY };
4890
+ if (!parsed) return void 0;
4866
4891
  const fetchContent = parsed.fetchContent;
4867
- if (fetchContent === void 0 || fetchContent === null) return { ...DEFAULT_DOMAIN_POLICY };
4892
+ if (fetchContent === void 0 || fetchContent === null) return void 0;
4868
4893
  if (typeof fetchContent !== "object" || Array.isArray(fetchContent)) {
4869
4894
  throw new Error(`fetchContent in ${WEB_SEARCH_CONFIG_PATH} must be an object`);
4870
4895
  }
4871
- const policy = fetchContent.domainPolicy;
4896
+ return fetchContent;
4897
+ }
4898
+ function loadFetchContentRedirectPolicy() {
4899
+ const redirects = loadFetchContentConfig()?.redirects;
4900
+ if (redirects === void 0 || redirects === null) return void 0;
4901
+ if (redirects !== "same-origin") {
4902
+ throw new Error(`fetchContent.redirects in ${WEB_SEARCH_CONFIG_PATH} must be "same-origin"`);
4903
+ }
4904
+ return redirects;
4905
+ }
4906
+ function loadFetchContentDomainPolicy() {
4907
+ const policy = loadFetchContentConfig()?.domainPolicy;
4872
4908
  if (policy === void 0 || policy === null) return { ...DEFAULT_DOMAIN_POLICY };
4873
4909
  if (typeof policy !== "object" || Array.isArray(policy)) {
4874
4910
  throw new Error(`fetchContent.domainPolicy in ${WEB_SEARCH_CONFIG_PATH} must be an object`);
@@ -4982,6 +5018,9 @@ async function fetchRemoteUrl(url, init = {}, options = {}) {
4982
5018
  if (redirects === maxRedirects) throw new Error(`Too many redirects fetching ${current.toString()}`);
4983
5019
  const from = current;
4984
5020
  const next = new URL(location, current);
5021
+ if (options.redirects === "same-origin" && next.origin !== configuredOrigin) {
5022
+ throw new Error(`Refused cross-origin redirect by fetch_content redirect policy: ${configuredOrigin} -> ${next.origin}`);
5023
+ }
4985
5024
  current = await validateRemoteUrl(next, next.origin === configuredOrigin ? options : { ...options, allowLoopback: false });
4986
5025
  if (response.status === 303 || (response.status === 301 || response.status === 302) && requestInit.method?.toUpperCase() === "POST") {
4987
5026
  const { body: _body, ...nextInit } = requestInit;
@@ -5523,7 +5562,7 @@ async function searchWithFirecrawl(query, options = {}) {
5523
5562
  "search",
5524
5563
  searchBody(query, options, numResults, filters),
5525
5564
  options.signal,
5526
- { ...options, timeoutMs: options.timeoutMs ?? SEARCH_TIMEOUT_MS10 },
5565
+ { ...options, timeoutMs: options.timeoutMs ?? SEARCH_TIMEOUT_MS11 },
5527
5566
  "search",
5528
5567
  { type: "api", query }
5529
5568
  );
@@ -5550,7 +5589,7 @@ async function extractWithFirecrawl(url, signal, options) {
5550
5589
  const title = typeof metadataTitle === "string" && metadataTitle.trim() ? metadataTitle.trim() : typeof scrape.title === "string" ? scrape.title.trim() : "";
5551
5590
  return { url, title, content: withPdfTruncationNotice(content, scrape.metadata), error: null };
5552
5591
  }
5553
- var CONFIG_PATH17, DEFAULT_API_VERSION, EXTRACT_TIMEOUT_MS, SEARCH_TIMEOUT_MS10, DEFAULT_MAX_REDIRECTS2, REDIRECT_STATUSES2, SUPPORTED_API_VERSIONS, cachedConfig16;
5592
+ var CONFIG_PATH17, DEFAULT_API_VERSION, EXTRACT_TIMEOUT_MS, SEARCH_TIMEOUT_MS11, DEFAULT_MAX_REDIRECTS2, REDIRECT_STATUSES2, SUPPORTED_API_VERSIONS, cachedConfig16;
5554
5593
  var init_firecrawl = __esm({
5555
5594
  "firecrawl.ts"() {
5556
5595
  init_activity();
@@ -5563,7 +5602,7 @@ var init_firecrawl = __esm({
5563
5602
  CONFIG_PATH17 = getWebSearchConfigPath();
5564
5603
  DEFAULT_API_VERSION = "v2";
5565
5604
  EXTRACT_TIMEOUT_MS = 6e4;
5566
- SEARCH_TIMEOUT_MS10 = 6e4;
5605
+ SEARCH_TIMEOUT_MS11 = 6e4;
5567
5606
  DEFAULT_MAX_REDIRECTS2 = 5;
5568
5607
  REDIRECT_STATUSES2 = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
5569
5608
  SUPPORTED_API_VERSIONS = ["v1", "v2"];
@@ -5697,7 +5736,7 @@ async function searchWithKagi(query, options = {}) {
5697
5736
  method: "POST",
5698
5737
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "application/json" },
5699
5738
  body: JSON.stringify({ query, limit: numResults }),
5700
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS13), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS13)
5739
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS14), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS14)
5701
5740
  });
5702
5741
  } catch (err) {
5703
5742
  const message = errorMessage12(err);
@@ -5752,7 +5791,7 @@ async function extractWithKagi(url, signal, options = {}) {
5752
5791
  method: "POST",
5753
5792
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "application/json" },
5754
5793
  body: JSON.stringify({ pages: [{ url }] }),
5755
- signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS13), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS13)
5794
+ signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS14), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS14)
5756
5795
  }, {
5757
5796
  allowRanges: ssrf.allowRanges,
5758
5797
  trustEnvProxy: ssrf.trustEnvProxy,
@@ -5785,7 +5824,7 @@ async function extractWithKagi(url, signal, options = {}) {
5785
5824
  activityMonitor.logComplete(activityId, response.status);
5786
5825
  return parsed;
5787
5826
  }
5788
- var KAGI_SEARCH_URL, KAGI_EXTRACT_URL, CONFIG_PATH20, SEARCH_TIMEOUT_MS13, cachedConfig19;
5827
+ var KAGI_SEARCH_URL, KAGI_EXTRACT_URL, CONFIG_PATH20, SEARCH_TIMEOUT_MS14, cachedConfig19;
5789
5828
  var init_kagi = __esm({
5790
5829
  "kagi.ts"() {
5791
5830
  init_activity();
@@ -5797,7 +5836,7 @@ var init_kagi = __esm({
5797
5836
  KAGI_SEARCH_URL = "https://kagi.com/api/v1/search";
5798
5837
  KAGI_EXTRACT_URL = "https://kagi.com/api/v1/extract";
5799
5838
  CONFIG_PATH20 = getWebSearchConfigPath();
5800
- SEARCH_TIMEOUT_MS13 = 6e4;
5839
+ SEARCH_TIMEOUT_MS14 = 6e4;
5801
5840
  cachedConfig19 = null;
5802
5841
  }
5803
5842
  });
@@ -5889,7 +5928,7 @@ async function searchWithOllama(query, options = {}) {
5889
5928
  method: "POST",
5890
5929
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
5891
5930
  body: JSON.stringify({ query, max_results: numResults }),
5892
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS15), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS15)
5931
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS16), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS16)
5893
5932
  });
5894
5933
  } catch (err) {
5895
5934
  const message = errorMessage14(err);
@@ -5943,7 +5982,7 @@ async function extractWithOllama(url, signal, options = {}) {
5943
5982
  method: "POST",
5944
5983
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
5945
5984
  body: JSON.stringify({ url }),
5946
- signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS15), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS15)
5985
+ signal: signal ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS16), signal]) : AbortSignal.timeout(options.timeoutMs ?? SEARCH_TIMEOUT_MS16)
5947
5986
  }, {
5948
5987
  allowRanges: ssrf.allowRanges,
5949
5988
  trustEnvProxy: ssrf.trustEnvProxy,
@@ -5978,7 +6017,7 @@ async function extractWithOllama(url, signal, options = {}) {
5978
6017
  if (!content) return null;
5979
6018
  return { url, title: data.title, content, error: null };
5980
6019
  }
5981
- var OLLAMA_SEARCH_URL, OLLAMA_FETCH_URL, CONFIG_PATH22, SEARCH_TIMEOUT_MS15, cachedConfig21;
6020
+ var OLLAMA_SEARCH_URL, OLLAMA_FETCH_URL, CONFIG_PATH22, SEARCH_TIMEOUT_MS16, cachedConfig21;
5982
6021
  var init_ollama = __esm({
5983
6022
  "ollama.ts"() {
5984
6023
  init_activity();
@@ -5989,7 +6028,7 @@ var init_ollama = __esm({
5989
6028
  OLLAMA_SEARCH_URL = "https://ollama.com/api/web_search";
5990
6029
  OLLAMA_FETCH_URL = "https://ollama.com/api/web_fetch";
5991
6030
  CONFIG_PATH22 = getWebSearchConfigPath();
5992
- SEARCH_TIMEOUT_MS15 = 6e4;
6031
+ SEARCH_TIMEOUT_MS16 = 6e4;
5993
6032
  cachedConfig21 = null;
5994
6033
  }
5995
6034
  });
@@ -6823,6 +6862,181 @@ var init_datalab_pdf_extract = __esm({
6823
6862
  }
6824
6863
  });
6825
6864
 
6865
+ // endpoint-pdf-extract.ts
6866
+ import { existsSync as existsSync45, readFileSync as readFileSync47 } from "node:fs";
6867
+ import { setTimeout as sleep2 } from "node:timers/promises";
6868
+ function pdfSection() {
6869
+ if (!existsSync45(CONFIG_PATH41)) return {};
6870
+ let parsed;
6871
+ try {
6872
+ parsed = JSON.parse(readFileSync47(CONFIG_PATH41, "utf-8"));
6873
+ } catch (err) {
6874
+ const message = err instanceof Error ? err.message : String(err);
6875
+ throw new Error(`Failed to parse ${CONFIG_PATH41}: ${message}`);
6876
+ }
6877
+ const pdf = parsed?.pdf;
6878
+ return pdf && typeof pdf === "object" ? pdf : {};
6879
+ }
6880
+ function normalizeString2(value) {
6881
+ if (typeof value !== "string") return null;
6882
+ const normalized = value.trim();
6883
+ return normalized.length > 0 ? normalized : null;
6884
+ }
6885
+ function getEndpointUrl() {
6886
+ const configured = normalizeString2(process.env.PDF_ENDPOINT_URL) ?? normalizeString2(pdfSection().endpointUrl);
6887
+ if (!configured) return null;
6888
+ const protocol = URL.parse(configured)?.protocol;
6889
+ if (protocol !== "http:" && protocol !== "https:") {
6890
+ throw new Error(
6891
+ `Failed to parse pdf.endpointUrl: expected an absolute http(s) URL, got "${configured}"`
6892
+ );
6893
+ }
6894
+ return configured.replace(/\/+$/, "");
6895
+ }
6896
+ function getEndpointTimeoutMs() {
6897
+ const configured = pdfSection().endpointTimeoutMs;
6898
+ if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) {
6899
+ return Math.min(configured, 3e5);
6900
+ }
6901
+ return DEFAULT_TIMEOUT_MS2;
6902
+ }
6903
+ function isEndpointApiAvailable() {
6904
+ try {
6905
+ return getEndpointUrl() !== null;
6906
+ } catch {
6907
+ return true;
6908
+ }
6909
+ }
6910
+ async function readCapped(response, maxBytes, overflowThrows) {
6911
+ const reader = response.body?.getReader();
6912
+ if (!reader) return "";
6913
+ const decoder = new TextDecoder();
6914
+ let text4 = "";
6915
+ let received = 0;
6916
+ for (; ; ) {
6917
+ const { done, value } = await reader.read();
6918
+ if (done) return text4 + decoder.decode();
6919
+ const room = maxBytes - received;
6920
+ received += value.byteLength;
6921
+ if (received >= maxBytes) {
6922
+ await reader.cancel();
6923
+ if (overflowThrows && received > maxBytes) {
6924
+ throw new Error("PDF parser endpoint returned an oversized response");
6925
+ }
6926
+ return text4 + decoder.decode(value.subarray(0, room));
6927
+ }
6928
+ text4 += decoder.decode(value, { stream: true });
6929
+ }
6930
+ }
6931
+ async function readJson(response) {
6932
+ const text4 = await readCapped(response, MAX_RESPONSE_BYTES2, true);
6933
+ try {
6934
+ const parsed = JSON.parse(text4);
6935
+ if (parsed && typeof parsed === "object") return parsed;
6936
+ } catch {
6937
+ }
6938
+ throw new Error("PDF parser endpoint returned a non-JSON response");
6939
+ }
6940
+ async function errorBody(response) {
6941
+ try {
6942
+ const text4 = await readCapped(response, MAX_ERROR_BODY_BYTES2, false);
6943
+ return text4 ? `: ${text4}` : "";
6944
+ } catch {
6945
+ return "";
6946
+ }
6947
+ }
6948
+ function markdownResult(payload) {
6949
+ const markdown = typeof payload.markdown === "string" ? payload.markdown.replaceAll("\0", "") : "";
6950
+ if (markdown.trim().length === 0) {
6951
+ const error = normalizeString2(payload.error);
6952
+ throw new Error(
6953
+ error ? `PDF parser endpoint failed: ${error}` : "PDF parser endpoint returned no markdown"
6954
+ );
6955
+ }
6956
+ return { markdown, pages: typeof payload.pages === "number" ? payload.pages : void 0 };
6957
+ }
6958
+ async function extractPDFViaEndpoint(buffer, options) {
6959
+ options.signal?.throwIfAborted();
6960
+ const endpointUrl2 = getEndpointUrl();
6961
+ if (!endpointUrl2) {
6962
+ throw new Error("PDF endpoint extraction requires a configured pdf.endpointUrl");
6963
+ }
6964
+ const ssrf = loadSsrfConfig();
6965
+ const guard = {
6966
+ allowRanges: ssrf.allowRanges,
6967
+ trustEnvProxy: ssrf.trustEnvProxy,
6968
+ allowLoopback: isLoopbackHostname(new URL(endpointUrl2).hostname),
6969
+ ...options.lookup ? { lookup: options.lookup } : {}
6970
+ };
6971
+ const engine = normalizeString2(pdfSection().endpointEngine);
6972
+ const form = new FormData();
6973
+ form.append("file", new Blob([buffer], { type: "application/pdf" }), "document.pdf");
6974
+ if (engine) form.append("engine", engine);
6975
+ form.append("max_pages", String(options.maxPages));
6976
+ const timeoutMs = options.timeoutMs ?? getEndpointTimeoutMs();
6977
+ const deadline = Date.now() + timeoutMs;
6978
+ const signal = options.signal;
6979
+ const timeout = AbortSignal.timeout(timeoutMs);
6980
+ const combined = signal ? AbortSignal.any([signal, timeout]) : timeout;
6981
+ const response = await fetchRemoteUrl(
6982
+ endpointUrl2,
6983
+ { method: "POST", body: form, signal: combined },
6984
+ guard
6985
+ );
6986
+ if (!response.ok) {
6987
+ throw new Error(
6988
+ `PDF parser endpoint returned HTTP ${response.status}${await errorBody(response)}`
6989
+ );
6990
+ }
6991
+ let payload = await readJson(response);
6992
+ const jobId = normalizeString2(payload.job_id);
6993
+ if (typeof payload.markdown === "string" || !jobId) {
6994
+ return markdownResult(payload);
6995
+ }
6996
+ const jobsUrl = new URL(`jobs/${encodeURIComponent(jobId)}`, endpointUrl2).toString();
6997
+ for (let interval = 1e3; Date.now() < deadline; interval = Math.min(interval * 2, MAX_POLL_INTERVAL_MS)) {
6998
+ await sleep2(Math.min(interval, deadline - Date.now()), void 0, { signal });
6999
+ const poll = await fetchRemoteUrl(jobsUrl, { signal: combined }, guard);
7000
+ if (!poll.ok) {
7001
+ throw new Error(
7002
+ `PDF parser job status returned HTTP ${poll.status}${await errorBody(poll)}`
7003
+ );
7004
+ }
7005
+ payload = await readJson(poll);
7006
+ const status = normalizeString2(payload.status)?.toLowerCase();
7007
+ if (status === "error" || status === "failed") {
7008
+ const error = normalizeString2(payload.error) ?? "unknown parser error";
7009
+ throw new Error(`PDF parser endpoint job failed: ${error}`);
7010
+ }
7011
+ if (status === "done") {
7012
+ let result = payload.result;
7013
+ if (typeof result === "string") {
7014
+ const raw = result;
7015
+ try {
7016
+ result = JSON.parse(raw);
7017
+ } catch {
7018
+ return { markdown: raw.replaceAll("\0", "") };
7019
+ }
7020
+ }
7021
+ if (result && typeof result === "object") return markdownResult(result);
7022
+ throw new Error("PDF parser endpoint job completed without a result");
7023
+ }
7024
+ }
7025
+ throw new Error("PDF parser endpoint job timed out");
7026
+ }
7027
+ var DEFAULT_TIMEOUT_MS2, MAX_POLL_INTERVAL_MS, MAX_RESPONSE_BYTES2, MAX_ERROR_BODY_BYTES2, CONFIG_PATH41;
7028
+ var init_endpoint_pdf_extract = __esm({
7029
+ "endpoint-pdf-extract.ts"() {
7030
+ init_ssrf_protection();
7031
+ init_utils();
7032
+ DEFAULT_TIMEOUT_MS2 = 12e4;
7033
+ MAX_POLL_INTERVAL_MS = 3e3;
7034
+ MAX_RESPONSE_BYTES2 = 4 * 1024 * 1024;
7035
+ MAX_ERROR_BODY_BYTES2 = 300;
7036
+ CONFIG_PATH41 = getWebSearchConfigPath();
7037
+ }
7038
+ });
7039
+
6826
7040
  // gemini-pdf-extract.ts
6827
7041
  import { Buffer as Buffer2 } from "node:buffer";
6828
7042
  async function extractPDFViaGemini(buffer, options) {
@@ -6834,7 +7048,7 @@ async function extractPDFViaGemini(buffer, options) {
6834
7048
  PDF_MIME_TYPE,
6835
7049
  {
6836
7050
  signal: options.signal,
6837
- timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS2
7051
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS3
6838
7052
  }
6839
7053
  );
6840
7054
  if (result.blockReason) {
@@ -6898,23 +7112,23 @@ function removeDuplicateInitialTitle(markdown, title) {
6898
7112
  function normalizeTitle(value) {
6899
7113
  return value.normalize("NFKC").toLocaleLowerCase().replace(/[`*_~]/g, "").replace(/[\p{P}\p{S}\s]+/gu, "");
6900
7114
  }
6901
- var PDF_MIME_TYPE, DEFAULT_TIMEOUT_MS2, PAGE_MARKER_PATTERN;
7115
+ var PDF_MIME_TYPE, DEFAULT_TIMEOUT_MS3, PAGE_MARKER_PATTERN;
6902
7116
  var init_gemini_pdf_extract = __esm({
6903
7117
  "gemini-pdf-extract.ts"() {
6904
7118
  init_gemini_api();
6905
7119
  PDF_MIME_TYPE = "application/pdf";
6906
- DEFAULT_TIMEOUT_MS2 = 12e4;
7120
+ DEFAULT_TIMEOUT_MS3 = 12e4;
6907
7121
  PAGE_MARKER_PATTERN = /^<!-- Page (\d+) -->$/gm;
6908
7122
  }
6909
7123
  });
6910
7124
 
6911
7125
  // pdf-extract.ts
6912
- import { existsSync as existsSync45, readFileSync as readFileSync47 } from "node:fs";
7126
+ import { existsSync as existsSync46, readFileSync as readFileSync48 } from "node:fs";
6913
7127
  import { writeFile as writeFile2, mkdir } from "node:fs/promises";
6914
7128
  import { join as join6, basename as basename3 } from "node:path";
6915
7129
  import { tmpdir as tmpdir3 } from "node:os";
6916
7130
  function loadPDFConfig() {
6917
- if (!existsSync45(CONFIG_PATH41)) {
7131
+ if (!existsSync46(CONFIG_PATH42)) {
6918
7132
  return {
6919
7133
  enabled: true,
6920
7134
  maxSizeMB: DEFAULT_PDF_MAX_SIZE_MB,
@@ -6924,13 +7138,13 @@ function loadPDFConfig() {
6924
7138
  datalabTimeoutMs: DEFAULT_DATALAB_TIMEOUT_MS
6925
7139
  };
6926
7140
  }
6927
- const rawText = readFileSync47(CONFIG_PATH41, "utf-8");
7141
+ const rawText = readFileSync48(CONFIG_PATH42, "utf-8");
6928
7142
  let raw;
6929
7143
  try {
6930
7144
  raw = JSON.parse(rawText);
6931
7145
  } catch (err) {
6932
7146
  const message = err instanceof Error ? err.message : String(err);
6933
- throw new Error(`Failed to parse ${CONFIG_PATH41}: ${message}`);
7147
+ throw new Error(`Failed to parse ${CONFIG_PATH42}: ${message}`);
6934
7148
  }
6935
7149
  const root = raw && typeof raw === "object" ? raw : {};
6936
7150
  const pdf = root.pdf && typeof root.pdf === "object" ? root.pdf : {};
@@ -6976,6 +7190,31 @@ async function extractPDFToMarkdown(buffer, url, options = {}) {
6976
7190
  const safeMaxPages = maxPages === void 0 ? pdfConfig.maxPages : Number.isFinite(maxPages) ? Math.max(1, Math.floor(maxPages)) : DEFAULT_MAX_PAGES;
6977
7191
  const urlTitle = extractTitleFromURL(url);
6978
7192
  const provider = pdfConfig.provider;
7193
+ if (provider === "auto" || provider === "endpoint") {
7194
+ if (provider === "endpoint" && !isEndpointApiAvailable()) {
7195
+ throw new Error(
7196
+ 'PDF provider "endpoint" requires a configured pdf.endpointUrl'
7197
+ );
7198
+ }
7199
+ try {
7200
+ if (isEndpointApiAvailable()) {
7201
+ const result = await extractPDFViaEndpoint(buffer, {
7202
+ maxPages: safeMaxPages,
7203
+ ...signal ? { signal } : {}
7204
+ });
7205
+ return writeMarkdownResult({
7206
+ markdownBody: result.markdown,
7207
+ title: urlTitle,
7208
+ pages: result.pages ?? countPageMarkers2(result.markdown),
7209
+ outputDir,
7210
+ filename,
7211
+ url
7212
+ });
7213
+ }
7214
+ } catch (err) {
7215
+ if (shouldRethrowExtractionError(err, signal)) throw err;
7216
+ }
7217
+ }
6979
7218
  if (provider === "auto" || provider === "datalab") {
6980
7219
  try {
6981
7220
  if (isDatalabApiAvailable()) {
@@ -7070,9 +7309,11 @@ async function writeMarkdownResult(options) {
7070
7309
  lines.push(`# ${options.title}`);
7071
7310
  lines.push("");
7072
7311
  lines.push(`> Source: ${options.url}`);
7073
- lines.push(
7074
- `> Pages: ${options.pages}${options.truncated ? ` (extracted first ${options.pagesToExtract})` : ""}`
7075
- );
7312
+ if (options.pages > 0) {
7313
+ lines.push(
7314
+ `> Pages: ${options.pages}${options.truncated ? ` (extracted first ${options.pagesToExtract})` : ""}`
7315
+ );
7316
+ }
7076
7317
  if (options.metaAuthor) lines.push(`> Author: ${options.metaAuthor}`);
7077
7318
  lines.push("");
7078
7319
  lines.push("---");
@@ -7139,16 +7380,18 @@ function isPDF(url, contentType) {
7139
7380
  return false;
7140
7381
  }
7141
7382
  }
7142
- var PDF_PROVIDER_VALUES, DEFAULT_PDF_MAX_SIZE_MB, MAX_PDF_MAX_SIZE_MB, MAX_DATALAB_TIMEOUT_MS, DEFAULT_MAX_PAGES, DEFAULT_OUTPUT_DIR, CONFIG_PATH41, PAGE_MARKER_PATTERN2;
7383
+ var PDF_PROVIDER_VALUES, DEFAULT_PDF_MAX_SIZE_MB, MAX_PDF_MAX_SIZE_MB, MAX_DATALAB_TIMEOUT_MS, DEFAULT_MAX_PAGES, DEFAULT_OUTPUT_DIR, CONFIG_PATH42, PAGE_MARKER_PATTERN2;
7143
7384
  var init_pdf_extract = __esm({
7144
7385
  "pdf-extract.ts"() {
7145
7386
  init_credential_source();
7146
7387
  init_datalab_pdf_extract();
7147
7388
  init_gemini_api();
7389
+ init_endpoint_pdf_extract();
7148
7390
  init_gemini_pdf_extract();
7149
7391
  init_utils();
7150
7392
  PDF_PROVIDER_VALUES = /* @__PURE__ */ new Set([
7151
7393
  "auto",
7394
+ "endpoint",
7152
7395
  "gemini",
7153
7396
  "datalab",
7154
7397
  "unpdf"
@@ -7158,32 +7401,32 @@ var init_pdf_extract = __esm({
7158
7401
  MAX_DATALAB_TIMEOUT_MS = 3e5;
7159
7402
  DEFAULT_MAX_PAGES = 100;
7160
7403
  DEFAULT_OUTPUT_DIR = join6(tmpdir3(), "pi-web-pdf");
7161
- CONFIG_PATH41 = getWebSearchConfigPath();
7404
+ CONFIG_PATH42 = getWebSearchConfigPath();
7162
7405
  PAGE_MARKER_PATTERN2 = /^<!-- Page (\d+) -->$/gm;
7163
7406
  }
7164
7407
  });
7165
7408
 
7166
7409
  // github-issue-pr.ts
7167
7410
  import { execFile as execFile4 } from "node:child_process";
7168
- import { existsSync as existsSync46, readFileSync as readFileSync48 } from "node:fs";
7411
+ import { existsSync as existsSync47, readFileSync as readFileSync49 } from "node:fs";
7169
7412
  function loadConfig37() {
7170
7413
  if (cachedConfig37) return cachedConfig37;
7171
7414
  const defaults2 = { enabled: true };
7172
- if (!existsSync46(CONFIG_PATH42)) {
7415
+ if (!existsSync47(CONFIG_PATH43)) {
7173
7416
  cachedConfig37 = defaults2;
7174
7417
  return cachedConfig37;
7175
7418
  }
7176
7419
  let parsed;
7177
7420
  try {
7178
- parsed = JSON.parse(readFileSync48(CONFIG_PATH42, "utf-8"));
7421
+ parsed = JSON.parse(readFileSync49(CONFIG_PATH43, "utf-8"));
7179
7422
  } catch (err) {
7180
7423
  const message = err instanceof Error ? err.message : String(err);
7181
- throw new Error(`Failed to parse ${CONFIG_PATH42}: ${message}`);
7424
+ throw new Error(`Failed to parse ${CONFIG_PATH43}: ${message}`);
7182
7425
  }
7183
7426
  const root = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
7184
7427
  const value = root.githubPrIssue;
7185
7428
  if (value !== void 0 && (typeof value !== "object" || value === null || Array.isArray(value))) {
7186
- throw new Error(`githubPrIssue in ${CONFIG_PATH42} must be an object`);
7429
+ throw new Error(`githubPrIssue in ${CONFIG_PATH43} must be an object`);
7187
7430
  }
7188
7431
  const enabled = typeof value?.enabled === "boolean" ? value.enabled : true;
7189
7432
  cachedConfig37 = { enabled };
@@ -7493,23 +7736,38 @@ function milestoneTitle(value) {
7493
7736
  if (!value || typeof value !== "object" || Array.isArray(value)) return "none";
7494
7737
  return stringValue(value.title) || "none";
7495
7738
  }
7496
- function truncateText(text4, limit, label, appendix) {
7739
+ function truncateText(text4, limit, label, appendix, tool) {
7497
7740
  if (text4.length <= limit) return text4;
7498
- appendix.push(`## Full ${label}
7741
+ const lastSpace = text4.slice(0, limit + 1).search(/\s\S*$/);
7742
+ const cut = lastSpace > limit * 0.8 ? lastSpace : limit;
7743
+ appendix.push(`## ${label} (continued)
7499
7744
 
7500
- ${text4}`);
7501
- return `${text4.slice(0, limit)}
7745
+ ${text4.slice(cut)}`);
7746
+ return `${text4.slice(0, cut)}
7502
7747
 
7503
- [${label} truncated; use get_search_content findText or offset for the full text]`;
7748
+ [${label} truncated; ${tool ? `the rest is stored under "${label} (continued)": use ${tool} findText or offset` : "use the gh escalation commands below for the rest"}]`;
7504
7749
  }
7505
- function appendLimitedSection(lines, title, items, max, marker) {
7750
+ function storeOmitted(appendix, section, items) {
7751
+ if (items.length > 0) appendix.push(`## ${section} (continued)
7752
+
7753
+ ${items.join("\n")}`);
7754
+ }
7755
+ function omissionMarker(section, noun, shown, fetched, atLeast, tool, gh = "the gh command below") {
7756
+ const stored = fetched > shown && tool ? `${fetched - shown} more stored under "${section} (continued)": use ${tool} findText or offset` : "";
7757
+ if (atLeast !== null) return `[${shown} ${noun} shown from at least ${atLeast}; ${stored ? `${stored}; for the rest ` : ""}use ${gh}]`;
7758
+ if (fetched <= shown) return null;
7759
+ return `[${shown} of ${fetched} ${noun} shown; ${stored ? `${stored}, or ${gh}` : `use ${gh}`}]`;
7760
+ }
7761
+ function appendLimitedSection(lines, title, items, max, marker, appendix, tool) {
7506
7762
  lines.push(`## ${title}`);
7507
7763
  if (items.length === 0) {
7508
7764
  lines.push("none", "");
7509
7765
  return;
7510
7766
  }
7511
7767
  lines.push(...items.slice(0, max));
7512
- if (items.length > max) lines.push(`[${max} of ${items.length} ${marker} shown; use get_search_content offset or the gh command below for more]`);
7768
+ storeOmitted(appendix, title, items.slice(max));
7769
+ const omitted = omissionMarker(title, marker, max, items.length, null, tool);
7770
+ if (omitted) lines.push(omitted);
7513
7771
  lines.push("");
7514
7772
  }
7515
7773
  function objectArray(value) {
@@ -7524,26 +7782,21 @@ function anchorMatches(anchor, comment) {
7524
7782
  const id = commentId(comment);
7525
7783
  return anchor === `issuecomment-${id}` || anchor === `discussion_r${id}`;
7526
7784
  }
7527
- function renderComments(comments, anchor, appendix) {
7785
+ function renderComments(comments, anchor, appendix, tool) {
7528
7786
  const forced = anchor ? comments.find((comment) => anchorMatches(anchor, comment)) : void 0;
7529
7787
  const selected = comments.slice(0, MAX_INLINE_COMMENTS);
7530
7788
  if (forced && !selected.includes(forced)) selected.push(forced);
7531
- const lines = selected.map((comment) => {
7789
+ const render = (comment, inline) => {
7532
7790
  const body = stringValue(comment.body);
7533
- const label = `comment ${commentId(comment) || selected.indexOf(comment) + 1}`;
7791
+ const label = `comment ${commentId(comment) || comments.indexOf(comment) + 1}`;
7792
+ const text4 = inline ? truncateText(body, COMMENT_INLINE_CHARS, label, appendix, tool) : body;
7534
7793
  return `- ${authorLogin(comment.author ?? comment.user)} at ${stringValue(comment.createdAt) || stringValue(comment.created_at)}${forced === comment ? " [anchored]" : ""}:
7535
- ${truncateText(body, COMMENT_INLINE_CHARS, label, appendix).replace(/\n/g, "\n ")}`;
7536
- });
7794
+ ${text4.replace(/\n/g, "\n ")}`;
7795
+ };
7796
+ const lines = selected.map((comment) => render(comment, true));
7797
+ storeOmitted(appendix, "Conversation comments", comments.slice(MAX_INLINE_COMMENTS).filter((comment) => comment !== forced).map((comment) => render(comment, false)));
7537
7798
  return lines;
7538
7799
  }
7539
- function renderCommentMarker(comments, renderedCount, total) {
7540
- const knownTotal = numberValue(total);
7541
- if (knownTotal !== null && knownTotal > comments.length) {
7542
- return `[${renderedCount} comments shown from at least ${knownTotal}; use get_search_content findText or offset, or gh issue view -c]`;
7543
- }
7544
- if (comments.length > renderedCount) return `[${renderedCount} of ${comments.length} comments shown; use get_search_content findText or offset, or gh issue view -c]`;
7545
- return null;
7546
- }
7547
7800
  function commentCountText(view) {
7548
7801
  const comments = objectArray(view.comments).length;
7549
7802
  const total = numberValue(view.commentsCount);
@@ -7557,7 +7810,7 @@ function reviewThreadCountText(comments, total, bounded, unavailable) {
7557
7810
  if (knownTotal !== null && knownTotal > comments.length) return `at least ${knownTotal}`;
7558
7811
  return String(comments.length || knownTotal || 0);
7559
7812
  }
7560
- function renderChecks(value) {
7813
+ function renderChecks(value, appendix, tool) {
7561
7814
  const checks = objectArray(value);
7562
7815
  if (checks.length === 0) return ["No check rollup data available."];
7563
7816
  const rows = checks.map((check) => {
@@ -7566,19 +7819,21 @@ function renderChecks(value) {
7566
7819
  return `- ${name}: ${state}`;
7567
7820
  });
7568
7821
  const failing = rows.filter((row) => !/(success|neutral|skipped|completed)$/i.test(row));
7569
- 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]`] : []];
7822
+ storeOmitted(appendix, "Checks", rows.slice(MAX_INLINE_CHECKS));
7823
+ const omitted = omissionMarker("Checks", "checks", MAX_INLINE_CHECKS, rows.length, null, tool);
7824
+ return [`Rollup: ${failing.length === 0 ? "no failing checks in shown data" : `${failing.length} non-passing checks in shown data`}`, ...rows.slice(0, MAX_INLINE_CHECKS), ...omitted ? [omitted] : []];
7570
7825
  }
7571
- function renderReviewVerdicts(value, appendix) {
7826
+ function renderReviewVerdicts(value, appendix, tool) {
7572
7827
  const latest = /* @__PURE__ */ new Map();
7573
7828
  for (const review of objectArray(value)) latest.set(authorLogin(review.author ?? review.user), review);
7574
7829
  return [...latest.entries()].map(([author, review]) => {
7575
7830
  const state = stringValue(review.state) || "COMMENTED";
7576
- const body = truncateText(stringValue(review.body), 300, `review by ${author}`, appendix);
7831
+ const body = truncateText(stringValue(review.body), 300, `review by ${author}`, appendix, tool);
7577
7832
  return `- ${author}: ${state}${body ? ` \u2014 ${body.replace(/\n/g, " ")}` : ""}`;
7578
7833
  });
7579
7834
  }
7580
- function renderReviewVerdictsOrUnavailable(view, appendix) {
7581
- const rendered = renderReviewVerdicts(view.reviews, appendix);
7835
+ function renderReviewVerdictsOrUnavailable(view, appendix, tool) {
7836
+ const rendered = renderReviewVerdicts(view.reviews, appendix, tool);
7582
7837
  if (rendered.length > 0) return rendered;
7583
7838
  return view.reviewsUnavailable === true ? ["Unavailable in this GitHub fetch path; use gh for review verdicts."] : [];
7584
7839
  }
@@ -7590,25 +7845,15 @@ function renderFiles(value) {
7590
7845
  return `- ${path} (+${additions}/\u2212${deletions})`;
7591
7846
  });
7592
7847
  }
7593
- function appendFilesSection(lines, view) {
7848
+ function appendFilesSection(lines, view, appendix, tool) {
7594
7849
  lines.push("## Files");
7595
7850
  const files = renderFiles(view.files);
7596
- if (files.length === 0) {
7597
- const total2 = numberValue(view.changedFiles);
7598
- if (total2 !== null && total2 > 0) {
7599
- lines.push(`[0 files shown from at least ${total2}; use get_search_content offset or the gh command below for more]`, "");
7600
- return;
7601
- }
7602
- lines.push("none", "");
7603
- return;
7604
- }
7605
- lines.push(...files.slice(0, MAX_INLINE_FILES));
7606
7851
  const total = numberValue(view.changedFiles);
7607
- if (total !== null && total > files.length) {
7608
- 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]`);
7609
- } else if (files.length > MAX_INLINE_FILES) {
7610
- lines.push(`[${MAX_INLINE_FILES} of ${files.length} files shown; use get_search_content offset or the gh command below for more]`);
7611
- }
7852
+ const omitted = omissionMarker("Files", "files", Math.min(files.length, MAX_INLINE_FILES), files.length, total !== null && total > files.length ? total : null, tool);
7853
+ if (files.length === 0 && !omitted) lines.push("none");
7854
+ lines.push(...files.slice(0, MAX_INLINE_FILES));
7855
+ storeOmitted(appendix, "Files", files.slice(MAX_INLINE_FILES));
7856
+ if (omitted) lines.push(omitted);
7612
7857
  lines.push("");
7613
7858
  }
7614
7859
  function renderCommits(value) {
@@ -7631,31 +7876,31 @@ function renderLinkedOrUnavailable(view, field, kind) {
7631
7876
  if (linked.length > 0) return linked;
7632
7877
  return view.linkedReferencesUnavailable === true ? ["Unavailable in this GitHub fetch path; use gh for linked references."] : [];
7633
7878
  }
7634
- function renderReviewThreads(comments, anchor, appendix, total, bounded, unavailable) {
7879
+ function renderReviewThreads(comments, anchor, appendix, tool, total, bounded, unavailable) {
7635
7880
  if (unavailable) return ["Unavailable in this GitHub fetch path; use gh for review thread comments."];
7636
7881
  const forced = anchor ? comments.find((comment) => anchorMatches(anchor, comment)) : void 0;
7637
7882
  const selected = comments.slice(0, MAX_INLINE_REVIEW_THREADS);
7638
7883
  if (forced && !selected.includes(forced)) selected.push(forced);
7639
- const lines = selected.map((comment) => {
7884
+ const render = (comment, inline) => {
7640
7885
  const path = stringValue(comment.path) || "unknown path";
7641
7886
  const line = numberValue(comment.line) ?? numberValue(comment.original_line) ?? numberValue(comment.position) ?? "?";
7642
- const body = truncateText(stringValue(comment.body), COMMENT_INLINE_CHARS, `review thread comment ${commentId(comment) || selected.indexOf(comment) + 1}`, appendix);
7887
+ const text4 = stringValue(comment.body);
7888
+ const body = inline ? truncateText(text4, COMMENT_INLINE_CHARS, `review thread comment ${commentId(comment) || comments.indexOf(comment) + 1}`, appendix, tool) : text4;
7643
7889
  return `- ${path}:${line} \u2014 ${authorLogin(comment.user ?? comment.author)}${forced === comment ? " [anchored]" : ""} (resolution state unknown):
7644
7890
  ${body.replace(/\n/g, "\n ")}`;
7645
- });
7891
+ };
7892
+ const lines = selected.map((comment) => render(comment, true));
7893
+ storeOmitted(appendix, "Review thread comments", comments.slice(MAX_INLINE_REVIEW_THREADS).filter((comment) => comment !== forced).map((comment) => render(comment, false)));
7646
7894
  const knownTotal = numberValue(total);
7647
- if (bounded) {
7648
- 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]`);
7649
- } else if (knownTotal !== null && knownTotal > comments.length) {
7650
- lines.push(`[${selected.length} review thread comments shown from at least ${knownTotal}; use get_search_content offset, or gh api repos/<owner>/<repo>/pulls/<number>/comments]`);
7651
- } else if (comments.length > selected.length) {
7652
- lines.push(`[${selected.length} of ${comments.length} review thread comments shown; use get_search_content offset, or gh api repos/<owner>/<repo>/pulls/<number>/comments]`);
7653
- }
7895
+ const atLeast = bounded ? comments.length : knownTotal !== null && knownTotal > comments.length ? knownTotal : null;
7896
+ const omitted = omissionMarker("Review thread comments", "review thread comments", selected.length, comments.length, atLeast, tool, "gh api repos/<owner>/<repo>/pulls/<number>/comments");
7897
+ if (omitted) lines.push(omitted);
7654
7898
  return lines;
7655
7899
  }
7656
7900
  function renderGitHubPrIssue(data) {
7657
7901
  const { view } = data;
7658
7902
  const appendix = [];
7903
+ const tool = data.retrievalTool === void 0 ? "get_search_content" : data.retrievalTool;
7659
7904
  const title = stringValue(view.title) || `${data.owner}/${data.repo}#${data.number}`;
7660
7905
  const number = numberValue(view.number) ?? data.number;
7661
7906
  const stateParts = [stringValue(view.state) || "unknown"];
@@ -7683,45 +7928,48 @@ function renderGitHubPrIssue(data) {
7683
7928
  if (data.anchor) lines.push(`- requested anchor: #${data.anchor}`);
7684
7929
  lines.push("");
7685
7930
  lines.push("## Body");
7686
- lines.push(truncateText(stringValue(view.body) || "(empty)", BODY_INLINE_CHARS, "body", appendix), "");
7931
+ lines.push(truncateText(stringValue(view.body) || "(empty)", BODY_INLINE_CHARS, "body", appendix, tool), "");
7687
7932
  if (data.kind === "pull") {
7688
7933
  lines.push("## Checks");
7689
- lines.push(...renderChecks(view.statusCheckRollup), "");
7690
- appendLimitedSection(lines, "Review verdicts", renderReviewVerdictsOrUnavailable(view, appendix), MAX_INLINE_REVIEWS, "review verdicts");
7691
- appendLimitedSection(lines, "Linked references", renderLinkedOrUnavailable(view, "closingIssuesReferences", "closing"), 20, "linked references");
7692
- appendFilesSection(lines, view);
7693
- appendLimitedSection(lines, "Commits", renderCommitsOrUnavailable(view), MAX_INLINE_COMMITS, "commits");
7934
+ lines.push(...renderChecks(view.statusCheckRollup, appendix, tool), "");
7935
+ appendLimitedSection(lines, "Review verdicts", renderReviewVerdictsOrUnavailable(view, appendix, tool), MAX_INLINE_REVIEWS, "review verdicts", appendix, tool);
7936
+ appendLimitedSection(lines, "Linked references", renderLinkedOrUnavailable(view, "closingIssuesReferences", "closing"), 20, "linked references", appendix, tool);
7937
+ appendFilesSection(lines, view, appendix, tool);
7938
+ appendLimitedSection(lines, "Commits", renderCommitsOrUnavailable(view), MAX_INLINE_COMMITS, "commits", appendix, tool);
7694
7939
  } else {
7695
- appendLimitedSection(lines, "Closed by pull requests", renderLinkedOrUnavailable(view, "closedByPullRequestsReferences", "closedBy"), 20, "pull requests");
7940
+ appendLimitedSection(lines, "Closed by pull requests", renderLinkedOrUnavailable(view, "closedByPullRequestsReferences", "closedBy"), 20, "pull requests", appendix, tool);
7696
7941
  }
7697
7942
  lines.push("## Conversation comments");
7698
- const commentLines = renderComments(objectArray(view.comments), data.anchor, appendix);
7699
- const commentMarker = renderCommentMarker(objectArray(view.comments), commentLines.length, view.commentsCount);
7943
+ const comments = objectArray(view.comments);
7944
+ const commentLines = renderComments(comments, data.anchor, appendix, tool);
7945
+ const knownCommentTotal = numberValue(view.commentsCount);
7946
+ const commentMarker = omissionMarker("Conversation comments", "comments", commentLines.length, comments.length, knownCommentTotal !== null && knownCommentTotal > comments.length ? knownCommentTotal : null, tool, "gh issue view -c");
7700
7947
  if (commentMarker) commentLines.push(commentMarker);
7701
7948
  if (view.anchorUnavailable === true && data.anchor?.startsWith("issuecomment-")) commentLines.push("[anchored comment unavailable for this issue or pull request]");
7702
7949
  lines.push(...commentLines.length > 0 ? commentLines : ["none"], "");
7703
7950
  if (data.kind === "pull") {
7704
7951
  lines.push("## Review thread comments");
7705
- const threadLines = renderReviewThreads(data.reviewThreads, data.anchor, appendix, view.reviewCommentsCount, data.reviewThreadsBounded, data.reviewThreadsUnavailable);
7952
+ const threadLines = renderReviewThreads(data.reviewThreads, data.anchor, appendix, tool, view.reviewCommentsCount, data.reviewThreadsBounded, data.reviewThreadsUnavailable);
7706
7953
  if (view.anchorUnavailable === true && data.anchor?.startsWith("discussion_r")) threadLines.push("[anchored review thread comment unavailable for this pull request]");
7707
7954
  lines.push(...threadLines.length > 0 ? threadLines : ["none"], "");
7708
7955
  }
7709
7956
  if (data.fallbackNotes.length > 0) {
7710
7957
  lines.push("## Availability notes", ...data.fallbackNotes.map((note) => `- ${note}`), "");
7711
7958
  }
7712
- if (appendix.length > 0) lines.push("## Appendix", ...appendix, "");
7713
7959
  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`;
7960
+ const diffCommand = data.kind === "pull" ? `gh pr diff ${data.number} --repo ${data.owner}/${data.repo}` : "";
7714
7961
  lines.push("## Escalation commands");
7715
7962
  lines.push(`- Full view: \`${viewCommand}\``);
7716
- if (data.kind === "pull") lines.push(`- Complete diff: \`gh pr diff ${data.number} --repo ${data.owner}/${data.repo}\``);
7717
- lines.push("- Stored full document: use `get_search_content` with `offset` or `findText`.");
7963
+ if (diffCommand) lines.push(`- Complete diff: \`${diffCommand}\``);
7964
+ if (tool) lines.push(`- Stored full document: use \`${tool}\` with \`offset\` or \`findText\`.`);
7965
+ if (appendix.length > 0) lines.push("", "## Appendix", "", appendix.join("\n\n"));
7718
7966
  const content = lines.join("\n");
7719
7967
  return {
7720
7968
  url: data.url,
7721
7969
  title: `${data.owner}/${data.repo} ${data.kind} #${data.number}: ${title}`,
7722
7970
  content: content.length > MAX_DOC_CHARS ? `${content.slice(0, MAX_DOC_CHARS)}
7723
7971
 
7724
- [GitHub document truncated at ${MAX_DOC_CHARS} chars; use the gh escalation commands for complete data]` : content,
7972
+ [GitHub document truncated at ${MAX_DOC_CHARS} chars; use \`${viewCommand}\`${diffCommand ? ` or \`${diffCommand}\`` : ""} for complete data]` : content,
7725
7973
  error: null
7726
7974
  };
7727
7975
  }
@@ -7730,6 +7978,7 @@ async function extractGitHubIssuePr(url, signal, options) {
7730
7978
  if (!info) return null;
7731
7979
  if (!loadConfig37().enabled) return null;
7732
7980
  if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
7981
+ const retrievalTool = options?.toolNames ? options.toolNames.getSearchContent ?? null : void 0;
7733
7982
  const ghAvailable2 = await checkGhAvailable(signal);
7734
7983
  if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
7735
7984
  if (ghAvailable2) {
@@ -7741,23 +7990,23 @@ async function extractGitHubIssuePr(url, signal, options) {
7741
7990
  if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
7742
7991
  if (threads.anchorUnavailable) viewed.view.anchorUnavailable = true;
7743
7992
  const notes = [...viewed.notes, ...threads.note ? [threads.note] : []];
7744
- return renderGitHubPrIssue({ url, owner: info.owner, repo: info.repo, kind: info.kind, number: info.number, anchor: info.anchor, view: viewed.view, reviewThreads: threads.comments, reviewThreadsBounded: threads.bounded, reviewThreadsUnavailable: threads.unavailable, fallbackNotes: notes });
7993
+ return renderGitHubPrIssue({ url, owner: info.owner, repo: info.repo, kind: info.kind, number: info.number, anchor: info.anchor, view: viewed.view, reviewThreads: threads.comments, reviewThreadsBounded: threads.bounded, reviewThreadsUnavailable: threads.unavailable, fallbackNotes: notes, retrievalTool });
7745
7994
  }
7746
7995
  } else {
7747
7996
  showGhHint();
7748
7997
  }
7749
7998
  const fallback = await restFallback(url, info, options, signal);
7750
7999
  if (!fallback) return null;
7751
- if ("data" in fallback) return renderGitHubPrIssue(fallback.data);
8000
+ if ("data" in fallback) return renderGitHubPrIssue({ ...fallback.data, retrievalTool });
7752
8001
  return fallback;
7753
8002
  }
7754
- 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;
8003
+ var CONFIG_PATH43, GH_TIMEOUT_MS, GH_TOTAL_TIMEOUT_MS, MAX_DOC_CHARS, BODY_INLINE_CHARS, COMMENT_INLINE_CHARS, MAX_INLINE_COMMENTS, MAX_INLINE_REVIEWS, MAX_INLINE_CHECKS, MAX_INLINE_FILES, MAX_INLINE_COMMITS, MAX_INLINE_REVIEW_THREADS, REST_HEADERS, PR_SUBPATHS, PR_FIELDS, PR_CORE_FIELDS, ISSUE_FIELDS, ISSUE_CORE_FIELDS, cachedConfig37;
7755
8004
  var init_github_issue_pr = __esm({
7756
8005
  "github-issue-pr.ts"() {
7757
8006
  init_github_api();
7758
8007
  init_ssrf_protection();
7759
8008
  init_utils();
7760
- CONFIG_PATH42 = getWebSearchConfigPath();
8009
+ CONFIG_PATH43 = getWebSearchConfigPath();
7761
8010
  GH_TIMEOUT_MS = 1e4;
7762
8011
  GH_TOTAL_TIMEOUT_MS = 2e4;
7763
8012
  MAX_DOC_CHARS = 15e4;
@@ -7843,15 +8092,15 @@ var init_github_issue_pr = __esm({
7843
8092
  });
7844
8093
 
7845
8094
  // feature-config.ts
7846
- import { existsSync as existsSync47, readFileSync as readFileSync49 } from "node:fs";
8095
+ import { existsSync as existsSync48, readFileSync as readFileSync50 } from "node:fs";
7847
8096
  function loadFeatureConfig() {
7848
- if (!existsSync47(CONFIG_PATH43)) return {};
8097
+ if (!existsSync48(CONFIG_PATH44)) return {};
7849
8098
  try {
7850
- const raw = JSON.parse(readFileSync49(CONFIG_PATH43, "utf-8"));
8099
+ const raw = JSON.parse(readFileSync50(CONFIG_PATH44, "utf-8"));
7851
8100
  return raw && typeof raw === "object" ? raw : {};
7852
8101
  } catch (err) {
7853
8102
  const message = err instanceof Error ? err.message : String(err);
7854
- throw new Error(`Failed to parse ${CONFIG_PATH43}: ${message}`);
8103
+ throw new Error(`Failed to parse ${CONFIG_PATH44}: ${message}`);
7855
8104
  }
7856
8105
  }
7857
8106
  function isImageEnabled() {
@@ -7864,17 +8113,17 @@ function canAttachImages() {
7864
8113
  return false;
7865
8114
  }
7866
8115
  }
7867
- var CONFIG_PATH43;
8116
+ var CONFIG_PATH44;
7868
8117
  var init_feature_config = __esm({
7869
8118
  "feature-config.ts"() {
7870
8119
  init_utils();
7871
- CONFIG_PATH43 = getWebSearchConfigPath();
8120
+ CONFIG_PATH44 = getWebSearchConfigPath();
7872
8121
  }
7873
8122
  });
7874
8123
 
7875
8124
  // youtube-extract.ts
7876
8125
  import { execFileSync } from "node:child_process";
7877
- import { existsSync as existsSync48, readFileSync as readFileSync50 } from "node:fs";
8126
+ import { existsSync as existsSync49, readFileSync as readFileSync51 } from "node:fs";
7878
8127
  function errorMessage29(err) {
7879
8128
  return err instanceof Error ? err.message : String(err);
7880
8129
  }
@@ -7895,17 +8144,17 @@ function normalizeEnabled2(value, fallback) {
7895
8144
  }
7896
8145
  function loadYouTubeConfig() {
7897
8146
  if (cachedConfig38) return cachedConfig38;
7898
- if (!existsSync48(CONFIG_PATH44)) {
8147
+ if (!existsSync49(CONFIG_PATH45)) {
7899
8148
  cachedConfig38 = { ...defaults };
7900
8149
  return cachedConfig38;
7901
8150
  }
7902
- const rawText = readFileSync50(CONFIG_PATH44, "utf-8");
8151
+ const rawText = readFileSync51(CONFIG_PATH45, "utf-8");
7903
8152
  let raw;
7904
8153
  try {
7905
8154
  raw = JSON.parse(rawText);
7906
8155
  } catch (err) {
7907
8156
  const message = err instanceof Error ? err.message : String(err);
7908
- throw new Error(`Failed to parse ${CONFIG_PATH44}: ${message}`);
8157
+ throw new Error(`Failed to parse ${CONFIG_PATH45}: ${message}`);
7909
8158
  }
7910
8159
  const yt = raw.youtube ?? {};
7911
8160
  cachedConfig38 = {
@@ -8104,7 +8353,7 @@ ${answer}
8104
8353
  return null;
8105
8354
  }
8106
8355
  }
8107
- var CONFIG_PATH44, YOUTUBE_PROMPT, YOUTUBE_REGEX, defaults, cachedConfig38;
8356
+ var CONFIG_PATH45, YOUTUBE_PROMPT, YOUTUBE_REGEX, defaults, cachedConfig38;
8108
8357
  var init_youtube_extract = __esm({
8109
8358
  "youtube-extract.ts"() {
8110
8359
  init_activity();
@@ -8114,7 +8363,7 @@ var init_youtube_extract = __esm({
8114
8363
  init_perplexity();
8115
8364
  init_extract();
8116
8365
  init_utils();
8117
- CONFIG_PATH44 = getWebSearchConfigPath();
8366
+ CONFIG_PATH45 = getWebSearchConfigPath();
8118
8367
  YOUTUBE_PROMPT = `Extract the complete content of this YouTube video. Include:
8119
8368
  1. Video title, channel name, and duration
8120
8369
  2. A brief summary (2-3 sentences)
@@ -8226,23 +8475,23 @@ URL: `;
8226
8475
  });
8227
8476
 
8228
8477
  // crawl4ai.ts
8229
- import { existsSync as existsSync49, readFileSync as readFileSync51 } from "node:fs";
8478
+ import { existsSync as existsSync50, readFileSync as readFileSync52 } from "node:fs";
8230
8479
  function loadConfig38() {
8231
8480
  if (cachedConfig39) return cachedConfig39;
8232
- if (!existsSync49(CONFIG_PATH45)) {
8481
+ if (!existsSync50(CONFIG_PATH46)) {
8233
8482
  cachedConfig39 = {};
8234
8483
  return cachedConfig39;
8235
8484
  }
8236
- const raw = readFileSync51(CONFIG_PATH45, "utf8");
8485
+ const raw = readFileSync52(CONFIG_PATH46, "utf8");
8237
8486
  let parsed;
8238
8487
  try {
8239
8488
  parsed = JSON.parse(raw);
8240
8489
  } catch (err) {
8241
8490
  const message = err instanceof Error ? err.message : String(err);
8242
- throw new Error(`Failed to parse ${CONFIG_PATH45}: ${message}`);
8491
+ throw new Error(`Failed to parse ${CONFIG_PATH46}: ${message}`);
8243
8492
  }
8244
8493
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
8245
- throw new Error(`Invalid config in ${CONFIG_PATH45}: expected a JSON object`);
8494
+ throw new Error(`Invalid config in ${CONFIG_PATH46}: expected a JSON object`);
8246
8495
  }
8247
8496
  cachedConfig39 = parsed;
8248
8497
  return cachedConfig39;
@@ -8255,13 +8504,13 @@ function normalizeBaseUrl5(value) {
8255
8504
  try {
8256
8505
  parsed = new URL(trimmed);
8257
8506
  } catch {
8258
- throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH45}: expected an HTTP or HTTPS URL`);
8507
+ throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH46}: expected an HTTP or HTTPS URL`);
8259
8508
  }
8260
8509
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
8261
- throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH45}: expected an HTTP or HTTPS URL`);
8510
+ throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH46}: expected an HTTP or HTTPS URL`);
8262
8511
  }
8263
8512
  if (parsed.username || parsed.password) {
8264
- throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH45}: URL credentials are not allowed`);
8513
+ throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH46}: URL credentials are not allowed`);
8265
8514
  }
8266
8515
  parsed.pathname = parsed.pathname.replace(/\/+$/, "");
8267
8516
  parsed.search = "";
@@ -8276,7 +8525,7 @@ function requireBaseUrl4() {
8276
8525
  if (!baseUrl) {
8277
8526
  throw new Error(
8278
8527
  `Crawl4AI base URL not configured. Either:
8279
- 1. Set crawl4aiBaseUrl in ${CONFIG_PATH45}
8528
+ 1. Set crawl4aiBaseUrl in ${CONFIG_PATH46}
8280
8529
  2. Set CRAWL4AI_BASE_URL environment variable`
8281
8530
  );
8282
8531
  }
@@ -8375,14 +8624,14 @@ async function extractWithCrawl4ai(url, signal, options) {
8375
8624
  throw err;
8376
8625
  }
8377
8626
  }
8378
- var CONFIG_PATH45, EXTRACT_TIMEOUT_MS2, MARKDOWN_FILTER, cachedConfig39;
8627
+ var CONFIG_PATH46, EXTRACT_TIMEOUT_MS2, MARKDOWN_FILTER, cachedConfig39;
8379
8628
  var init_crawl4ai = __esm({
8380
8629
  "crawl4ai.ts"() {
8381
8630
  init_activity();
8382
8631
  init_credential_source();
8383
8632
  init_ssrf_protection();
8384
8633
  init_utils();
8385
- CONFIG_PATH45 = getWebSearchConfigPath();
8634
+ CONFIG_PATH46 = getWebSearchConfigPath();
8386
8635
  EXTRACT_TIMEOUT_MS2 = 6e4;
8387
8636
  MARKDOWN_FILTER = "fit";
8388
8637
  cachedConfig39 = null;
@@ -8390,7 +8639,7 @@ var init_crawl4ai = __esm({
8390
8639
  });
8391
8640
 
8392
8641
  // brightdata-unlocker.ts
8393
- import { existsSync as existsSync50, readFileSync as readFileSync52 } from "node:fs";
8642
+ import { existsSync as existsSync51, readFileSync as readFileSync53 } from "node:fs";
8394
8643
  function parseFailureDetail(err) {
8395
8644
  const message = err instanceof Error ? err.message : String(err);
8396
8645
  const position = message.match(/at position \d+(?: \(line \d+ column \d+\))?/);
@@ -8398,19 +8647,19 @@ function parseFailureDetail(err) {
8398
8647
  }
8399
8648
  function loadConfig39() {
8400
8649
  if (cachedConfig40) return cachedConfig40;
8401
- if (!existsSync50(CONFIG_PATH46)) {
8650
+ if (!existsSync51(CONFIG_PATH47)) {
8402
8651
  cachedConfig40 = {};
8403
8652
  return cachedConfig40;
8404
8653
  }
8405
- const raw = readFileSync52(CONFIG_PATH46, "utf8");
8654
+ const raw = readFileSync53(CONFIG_PATH47, "utf8");
8406
8655
  let parsed;
8407
8656
  try {
8408
8657
  parsed = JSON.parse(raw);
8409
8658
  } catch (err) {
8410
- throw new Error(`Failed to parse ${CONFIG_PATH46}: ${parseFailureDetail(err)}`);
8659
+ throw new Error(`Failed to parse ${CONFIG_PATH47}: ${parseFailureDetail(err)}`);
8411
8660
  }
8412
8661
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
8413
- throw new Error(`Invalid config in ${CONFIG_PATH46}: expected a JSON object`);
8662
+ throw new Error(`Invalid config in ${CONFIG_PATH47}: expected a JSON object`);
8414
8663
  }
8415
8664
  cachedConfig40 = parsed;
8416
8665
  return cachedConfig40;
@@ -8425,7 +8674,7 @@ function zoneSetting() {
8425
8674
  const fromEnv = process.env.BRIGHTDATA_UNLOCKER_ZONE;
8426
8675
  if (typeof fromEnv === "string" && fromEnv.trim()) return { raw: fromEnv.trim(), label: "BRIGHTDATA_UNLOCKER_ZONE" };
8427
8676
  const configured = loadConfig39().brightdataUnlockerZone;
8428
- if (typeof configured === "string" && configured.trim()) return { raw: configured.trim(), label: `brightdataUnlockerZone in ${CONFIG_PATH46}` };
8677
+ if (typeof configured === "string" && configured.trim()) return { raw: configured.trim(), label: `brightdataUnlockerZone in ${CONFIG_PATH47}` };
8429
8678
  return null;
8430
8679
  }
8431
8680
  function getZone() {
@@ -8443,7 +8692,7 @@ function requireZone() {
8443
8692
  }
8444
8693
  throw new Error(
8445
8694
  `Bright Data Web Unlocker zone not configured. Either:
8446
- 1. Set brightdataUnlockerZone in ${CONFIG_PATH46}
8695
+ 1. Set brightdataUnlockerZone in ${CONFIG_PATH47}
8447
8696
  2. Set BRIGHTDATA_UNLOCKER_ZONE environment variable
8448
8697
  The zone must be of type "unblocker"; a SERP zone will not serve Web Unlocker requests.`
8449
8698
  );
@@ -8458,7 +8707,7 @@ async function getApiKey27(signal) {
8458
8707
  if (!apiKey) {
8459
8708
  throw new Error(
8460
8709
  `Bright Data API key not found. Either:
8461
- 1. Create ${CONFIG_PATH46} with { "brightdataApiKey": "your-key" }
8710
+ 1. Create ${CONFIG_PATH47} with { "brightdataApiKey": "your-key" }
8462
8711
  2. Set BRIGHTDATA_API_KEY environment variable
8463
8712
  Get a key at https://brightdata.com/cp/setting/users`
8464
8713
  );
@@ -8567,14 +8816,14 @@ async function extractWithBrightDataUnlocker(url, signal, options) {
8567
8816
  if (!content) return null;
8568
8817
  return { url, title: headingTitle(content), content, error: null };
8569
8818
  }
8570
- var CONFIG_PATH46, BRIGHTDATA_REQUEST_URL, EXTRACT_TIMEOUT_MS3, DEFAULT_MAX_REDIRECTS3, REDIRECT_STATUSES3, ZONE_PATTERN2, cachedConfig40;
8819
+ var CONFIG_PATH47, BRIGHTDATA_REQUEST_URL, EXTRACT_TIMEOUT_MS3, DEFAULT_MAX_REDIRECTS3, REDIRECT_STATUSES3, ZONE_PATTERN2, cachedConfig40;
8571
8820
  var init_brightdata_unlocker = __esm({
8572
8821
  "brightdata-unlocker.ts"() {
8573
8822
  init_activity();
8574
8823
  init_credential_source();
8575
8824
  init_ssrf_protection();
8576
8825
  init_utils();
8577
- CONFIG_PATH46 = getWebSearchConfigPath();
8826
+ CONFIG_PATH47 = getWebSearchConfigPath();
8578
8827
  BRIGHTDATA_REQUEST_URL = "https://api.brightdata.com/request";
8579
8828
  EXTRACT_TIMEOUT_MS3 = 6e4;
8580
8829
  DEFAULT_MAX_REDIRECTS3 = 5;
@@ -8586,7 +8835,7 @@ var init_brightdata_unlocker = __esm({
8586
8835
 
8587
8836
  // video-extract.ts
8588
8837
  import { execFileSync as execFileSync2 } from "node:child_process";
8589
- import { existsSync as existsSync51, readFileSync as readFileSync53, readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
8838
+ import { existsSync as existsSync52, readFileSync as readFileSync54, readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
8590
8839
  import { readFile as readFile2 } from "node:fs/promises";
8591
8840
  import { resolve, extname as extname2, basename as basename4, join as join7, dirname as dirname2 } from "node:path";
8592
8841
  function shouldRethrow3(err) {
@@ -8607,17 +8856,17 @@ function normalizeMaxSizeMB(value, fallback) {
8607
8856
  }
8608
8857
  function loadVideoConfig() {
8609
8858
  if (cachedVideoConfig) return cachedVideoConfig;
8610
- if (!existsSync51(CONFIG_PATH47)) {
8859
+ if (!existsSync52(CONFIG_PATH48)) {
8611
8860
  cachedVideoConfig = { ...VIDEO_CONFIG_DEFAULTS };
8612
8861
  return cachedVideoConfig;
8613
8862
  }
8614
- const rawText = readFileSync53(CONFIG_PATH47, "utf-8");
8863
+ const rawText = readFileSync54(CONFIG_PATH48, "utf-8");
8615
8864
  let raw;
8616
8865
  try {
8617
8866
  raw = JSON.parse(rawText);
8618
8867
  } catch (err) {
8619
8868
  const message = err instanceof Error ? err.message : String(err);
8620
- throw new Error(`Failed to parse ${CONFIG_PATH47}: ${message}`);
8869
+ throw new Error(`Failed to parse ${CONFIG_PATH48}: ${message}`);
8621
8870
  }
8622
8871
  const v = raw.video ?? {};
8623
8872
  cachedVideoConfig = {
@@ -8663,10 +8912,10 @@ function isVideoFile(input) {
8663
8912
  }
8664
8913
  function resolveFilePath(filePath) {
8665
8914
  const absolutePath = resolve(filePath);
8666
- if (existsSync51(absolutePath)) return absolutePath;
8915
+ if (existsSync52(absolutePath)) return absolutePath;
8667
8916
  const dir = dirname2(absolutePath);
8668
8917
  const base = basename4(absolutePath);
8669
- if (!existsSync51(dir)) return null;
8918
+ if (!existsSync52(dir)) return null;
8670
8919
  try {
8671
8920
  const normalizedBase = normalizeSpaces(base);
8672
8921
  const match = readdirSync4(dir).find((f) => normalizeSpaces(f) === normalizedBase);
@@ -8824,8 +9073,9 @@ async function uploadToFilesApi(info, apiKey, signal) {
8824
9073
  }
8825
9074
  const uploadUrl = initRes.headers.get("x-goog-upload-url");
8826
9075
  if (!uploadUrl) throw new Error("No upload URL in response headers");
9076
+ const routedUploadUrl = rewriteUploadUrlOrigin(uploadUrl);
8827
9077
  const fileData = await readFile2(info.absolutePath);
8828
- const uploadRes = await fetchGeminiApi(uploadUrl, {
9078
+ const uploadRes = await fetchGeminiApi(routedUploadUrl, {
8829
9079
  method: "PUT",
8830
9080
  headers: {
8831
9081
  "Content-Length": String(info.sizeBytes),
@@ -8864,7 +9114,7 @@ function deleteGeminiFile(fileName, apiKey) {
8864
9114
  function extractVideoTitle(text4, filePath) {
8865
9115
  return extractHeadingTitle(text4) ?? basename4(filePath, extname2(filePath));
8866
9116
  }
8867
- var CONFIG_PATH47, DEFAULT_VIDEO_PROMPT, VIDEO_EXTENSIONS, VIDEO_CONFIG_DEFAULTS, cachedVideoConfig;
9117
+ var CONFIG_PATH48, DEFAULT_VIDEO_PROMPT, VIDEO_EXTENSIONS, VIDEO_CONFIG_DEFAULTS, cachedVideoConfig;
8868
9118
  var init_video_extract = __esm({
8869
9119
  "video-extract.ts"() {
8870
9120
  init_activity();
@@ -8873,7 +9123,7 @@ var init_video_extract = __esm({
8873
9123
  init_gemini_api();
8874
9124
  init_extract();
8875
9125
  init_utils();
8876
- CONFIG_PATH47 = getWebSearchConfigPath();
9126
+ CONFIG_PATH48 = getWebSearchConfigPath();
8877
9127
  DEFAULT_VIDEO_PROMPT = `Extract the complete content of this video. Include:
8878
9128
  1. Video title (infer from content if not explicit), duration
8879
9129
  2. A brief summary (2-3 sentences)
@@ -9358,13 +9608,13 @@ __export(extract_exports, {
9358
9608
  readPDFResponseBuffer: () => readPDFResponseBuffer,
9359
9609
  resolveFetchTimeoutMs: () => resolveFetchTimeoutMs
9360
9610
  });
9361
- import { existsSync as existsSync52, readFileSync as readFileSync54 } from "node:fs";
9611
+ import { existsSync as existsSync53, readFileSync as readFileSync55 } from "node:fs";
9362
9612
  import pLimit from "p-limit";
9363
9613
  function loadFetchTimeoutMs() {
9364
- if (!existsSync52(WEB_SEARCH_CONFIG_PATH3)) return DEFAULT_TIMEOUT_MS3;
9614
+ if (!existsSync53(WEB_SEARCH_CONFIG_PATH3)) return DEFAULT_TIMEOUT_MS4;
9365
9615
  let raw;
9366
9616
  try {
9367
- raw = JSON.parse(readFileSync54(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
9617
+ raw = JSON.parse(readFileSync55(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
9368
9618
  } catch (err) {
9369
9619
  const message = err instanceof Error ? err.message : String(err);
9370
9620
  throw new Error(`Failed to parse ${WEB_SEARCH_CONFIG_PATH3}: ${message}`);
@@ -9373,12 +9623,12 @@ function loadFetchTimeoutMs() {
9373
9623
  throw new Error(`Invalid config in ${WEB_SEARCH_CONFIG_PATH3}: expected a JSON object`);
9374
9624
  }
9375
9625
  const fetchConfig = raw.fetch;
9376
- if (fetchConfig === void 0) return DEFAULT_TIMEOUT_MS3;
9626
+ if (fetchConfig === void 0) return DEFAULT_TIMEOUT_MS4;
9377
9627
  if (!fetchConfig || typeof fetchConfig !== "object" || Array.isArray(fetchConfig)) {
9378
9628
  throw new Error(`fetch in ${WEB_SEARCH_CONFIG_PATH3} must be an object`);
9379
9629
  }
9380
9630
  const value = fetchConfig.timeout;
9381
- if (value === void 0) return DEFAULT_TIMEOUT_MS3;
9631
+ if (value === void 0) return DEFAULT_TIMEOUT_MS4;
9382
9632
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
9383
9633
  throw new Error(`Invalid fetch.timeout in ${WEB_SEARCH_CONFIG_PATH3}: expected a positive finite number of seconds, got ${JSON.stringify(value)}`);
9384
9634
  }
@@ -9439,7 +9689,7 @@ function isAbortException2(err) {
9439
9689
  return err instanceof DOMException && (err.name === "AbortError" || err.name === "TimeoutError");
9440
9690
  }
9441
9691
  function isRedirectPolicyError(message) {
9442
- return message.startsWith("Authenticated fetch refused cross-origin redirect") || message.startsWith("Blocked internal ") || message.startsWith("Blocked hostname by fetch_content domain policy") || message.startsWith("Hostname not allowed by fetch_content domain policy") || message.startsWith("Too many redirects fetching ") || message === "Only HTTP and HTTPS URLs can be fetched remotely" || message === "URL must include a hostname" || message.startsWith("Failed to resolve ");
9692
+ return message.startsWith("Authenticated fetch refused cross-origin redirect") || message.startsWith("Refused cross-origin redirect by fetch_content redirect policy") || message.startsWith("Blocked internal ") || message.startsWith("Blocked hostname by fetch_content domain policy") || message.startsWith("Hostname not allowed by fetch_content domain policy") || message.startsWith("Too many redirects fetching ") || message === "Only HTTP and HTTPS URLs can be fetched remotely" || message === "URL must include a hostname" || message.startsWith("Failed to resolve ");
9443
9693
  }
9444
9694
  function isNonRecoverableHttpError(error) {
9445
9695
  return !!error && (NON_RECOVERABLE_ERRORS.some((prefix) => error.startsWith(prefix)) || isRedirectPolicyError(error) || isConfigParseError(error));
@@ -9451,6 +9701,9 @@ function imageGateError() {
9451
9701
  return errorMessage32(err);
9452
9702
  }
9453
9703
  }
9704
+ function redirectPolicyRouteRefusal(url, path) {
9705
+ 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` };
9706
+ }
9454
9707
  async function resolveAuthCookieHeader(url, profile) {
9455
9708
  const parsed = assertAuthFetchUrl(profile, url.toString());
9456
9709
  const result = await getBrowserCookiesForHosts({ hosts: [parsed.hostname], profile: profile.chromeProfile, requestUrl: parsed });
@@ -9469,6 +9722,7 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
9469
9722
  proxy: validationOptions.proxy,
9470
9723
  ...validationOptions.lookup ? { lookup: validationOptions.lookup } : {}
9471
9724
  });
9725
+ const originalOrigin = current.origin;
9472
9726
  let requestInit = init;
9473
9727
  for (let redirects = 0; redirects <= 5; redirects++) {
9474
9728
  const cookieHeader = await resolveAuthCookieHeader(current, profile);
@@ -9479,7 +9733,11 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
9479
9733
  if (!location) return response;
9480
9734
  if (redirects === 5) throw new Error(`Too many redirects fetching ${current.toString()}`);
9481
9735
  const from = current;
9482
- current = await validateRemoteUrl(new URL(location, current), {
9736
+ const next = new URL(location, current);
9737
+ if (validationOptions.redirects === "same-origin" && next.origin !== originalOrigin) {
9738
+ throw new Error(`Refused cross-origin redirect by fetch_content redirect policy: ${originalOrigin} -> ${next.origin}`);
9739
+ }
9740
+ current = await validateRemoteUrl(next, {
9483
9741
  allowRanges: validationOptions.ssrf.allowRanges,
9484
9742
  trustEnvProxy: validationOptions.ssrf.trustEnvProxy,
9485
9743
  domainPolicy: validationOptions.domainPolicy,
@@ -9495,12 +9753,12 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
9495
9753
  throw new Error(`Too many redirects fetching ${current.toString()}`);
9496
9754
  }
9497
9755
  function loadFetchRouting() {
9498
- if (!existsSync52(WEB_SEARCH_CONFIG_PATH3)) {
9756
+ if (!existsSync53(WEB_SEARCH_CONFIG_PATH3)) {
9499
9757
  return { providers: DEFAULT_FETCH_PROVIDER_ORDER, allowRemoteHostedProviders: false };
9500
9758
  }
9501
9759
  let raw;
9502
9760
  try {
9503
- const parsed = JSON.parse(readFileSync54(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
9761
+ const parsed = JSON.parse(readFileSync55(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
9504
9762
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
9505
9763
  throw new Error("expected a JSON object");
9506
9764
  }
@@ -9698,6 +9956,12 @@ async function extractContent(url, signal, options) {
9698
9956
  if (signal?.aborted) {
9699
9957
  return { url, title: "", content: "", error: "Aborted" };
9700
9958
  }
9959
+ let redirectPolicy;
9960
+ try {
9961
+ redirectPolicy = options?.redirects ?? loadFetchContentRedirectPolicy();
9962
+ } catch (err) {
9963
+ return { url, title: "", content: "", error: errorMessage32(err) };
9964
+ }
9701
9965
  let remoteUrl = null;
9702
9966
  try {
9703
9967
  const parsed = new URL(url);
@@ -9726,6 +9990,11 @@ async function extractContent(url, signal, options) {
9726
9990
  return { url, title: "", content: "", error: errorMessage32(err) };
9727
9991
  }
9728
9992
  }
9993
+ if (redirectPolicy) {
9994
+ if (parseGitHubIssuePrUrl(url)) return redirectPolicyRouteRefusal(url, "GitHub issue/PR");
9995
+ if (parseGitHubUrl(url)) return redirectPolicyRouteRefusal(url, "GitHub repository");
9996
+ if (isYouTubeURL(url).isYouTube) return redirectPolicyRouteRefusal(url, "YouTube");
9997
+ }
9729
9998
  if (options?.frames || options?.timestamp) {
9730
9999
  const disabled = imageGateError();
9731
10000
  if (disabled) return { url, title: "", content: "", error: disabled };
@@ -9820,7 +10089,7 @@ async function extractContent(url, signal, options) {
9820
10089
  if ("error" in frame) {
9821
10090
  return { url, title: `Frame at ${options.timestamp}`, content: frame.error, error: frame.error };
9822
10091
  }
9823
- return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame };
10092
+ return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame, mimeType: frame.mimeType };
9824
10093
  }
9825
10094
  const localVideo2 = safeVideoInfo(url);
9826
10095
  if (localVideo2.status === "invalid") {
@@ -9844,7 +10113,7 @@ async function extractContent(url, signal, options) {
9844
10113
  if ("error" in frame) {
9845
10114
  return { url, title: `Frame at ${options.timestamp}`, content: frame.error, error: frame.error };
9846
10115
  }
9847
- return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame };
10116
+ return { url, title: `Frame at ${options.timestamp}`, content: `Video frame at ${options.timestamp}`, error: null, thumbnail: frame, mimeType: frame.mimeType };
9848
10117
  }
9849
10118
  return { url, title: "", content: "", error: "Timestamp extraction only works with YouTube and local video files" };
9850
10119
  }
@@ -9928,7 +10197,10 @@ async function extractContent(url, signal, options) {
9928
10197
  } catch (err) {
9929
10198
  return { url, title: "", content: "", error: errorMessage32(err) };
9930
10199
  }
9931
- const providerOrder = remoteUrl && !fetchRouting.allowRemoteHostedProviders ? fetchRouting.providers.filter((provider) => !REMOTE_HOSTED_FETCH_PROVIDERS.has(provider)) : fetchRouting.providers;
10200
+ if (redirectPolicy && !fetchRouting.providers.includes("http")) {
10201
+ return redirectPolicyRouteRefusal(url, fetchRouting.providers[0]);
10202
+ }
10203
+ const providerOrder = redirectPolicy ? ["http"] : remoteUrl && !fetchRouting.allowRemoteHostedProviders ? fetchRouting.providers.filter((provider) => !REMOTE_HOSTED_FETCH_PROVIDERS.has(provider)) : fetchRouting.providers;
9932
10204
  if (providerOrder.length === 0) {
9933
10205
  return {
9934
10206
  url,
@@ -10153,6 +10425,7 @@ async function extractContent(url, signal, options) {
10153
10425
  if (finalHttpResult?.status === 404 || finalHttpResult?.status === 410) {
10154
10426
  return { ...finalHttpResult, error: notFoundGuidance(finalHttpResult, options?.toolNames) };
10155
10427
  }
10428
+ if (redirectPolicy && finalHttpResult) return finalHttpResult;
10156
10429
  const searchToolName = options?.toolNames?.webSearch;
10157
10430
  const jinaHint = jinaReaderGuidance(fetchRouting, providerOrder, Boolean(remoteUrl) && !fetchRouting.allowRemoteHostedProviders);
10158
10431
  const guidance = [
@@ -10263,6 +10536,7 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
10263
10536
  try {
10264
10537
  const ssrf = loadSsrfConfig();
10265
10538
  const domainPolicy = loadFetchContentDomainPolicy();
10539
+ const redirects = options?.redirects ?? loadFetchContentRedirectPolicy();
10266
10540
  const authProfile = options?.authFetchProfile;
10267
10541
  const requestInit = {
10268
10542
  signal: controller.signal,
@@ -10279,13 +10553,14 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
10279
10553
  "Upgrade-Insecure-Requests": "1"
10280
10554
  }
10281
10555
  };
10282
- const response = authProfile ? await fetchAuthenticatedRemoteUrl(url, requestInit, { ssrf, domainPolicy, proxy: options?.proxy, ...options?.lookup ? { lookup: options.lookup } : {} }, authProfile) : await fetchRemoteUrl(
10556
+ const response = authProfile ? await fetchAuthenticatedRemoteUrl(url, requestInit, { ssrf, domainPolicy, redirects, proxy: options?.proxy, ...options?.lookup ? { lookup: options.lookup } : {} }, authProfile) : await fetchRemoteUrl(
10283
10557
  url,
10284
10558
  requestInit,
10285
10559
  {
10286
10560
  allowRanges: ssrf.allowRanges,
10287
10561
  trustEnvProxy: ssrf.trustEnvProxy,
10288
10562
  domainPolicy,
10563
+ redirects,
10289
10564
  proxy: options?.proxy,
10290
10565
  ...options?.lookup ? { lookup: options.lookup } : {}
10291
10566
  }
@@ -10325,7 +10600,8 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
10325
10600
  if (options?.mode === "raw") {
10326
10601
  if (!isTextContentType(contentType)) {
10327
10602
  activityMonitor.logComplete(activityId, response.status);
10328
- return { url, title: "", content: "", error: `Unsupported content type in raw mode: ${mimeType || "missing"}`, mimeType, status: response.status };
10603
+ const hint = isPDFContent ? '; retry without mode for Markdown, or with mode "answer" and a prompt' : "";
10604
+ return { url, title: "", content: "", error: `Unsupported content type in raw mode: ${mimeType || "missing"}${hint}`, mimeType, status: response.status };
10329
10605
  }
10330
10606
  const text5 = await readTextResponseWithLimit(response, maxResponseSize);
10331
10607
  activityMonitor.logComplete(activityId, response.status);
@@ -10374,8 +10650,8 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
10374
10650
  title: result.title,
10375
10651
  content: options?.mode === "answer" ? result.content : `PDF extracted and saved to: ${result.outputPath}
10376
10652
 
10377
- Pages: ${result.pages}
10378
- Characters: ${result.chars}`,
10653
+ ${result.pages > 0 ? `Pages: ${result.pages}
10654
+ ` : ""}Characters: ${result.chars}`,
10379
10655
  error: null
10380
10656
  };
10381
10657
  } catch (err) {
@@ -10548,7 +10824,7 @@ async function fetchAllContent(urls, signal, options) {
10548
10824
  return sanitized.omissions.length > 0 ? { ...result, content: sanitized.text } : result;
10549
10825
  });
10550
10826
  }
10551
- 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;
10827
+ var DEFAULT_TIMEOUT_MS4, MAX_CONFIGURED_TIMEOUT_MS, CONCURRENT_LIMIT, WEB_SEARCH_CONFIG_PATH3, NON_RECOVERABLE_ERRORS, MIN_USEFUL_CONTENT2, SUPPORTED_IMAGE_TYPES, FETCH_PROVIDERS, DEFAULT_FETCH_PROVIDER_ORDER, REMOTE_HOSTED_FETCH_PROVIDERS, REDIRECT_STATUSES4, turndownInstance, fetchLimit, JINA_READER_BASE, DEFAULT_RANGE_FRAMES, MIN_FRAME_INTERVAL, BROWSER_ACCEPT, MARKDOWN_FIRST_ACCEPT;
10552
10828
  var init_extract = __esm({
10553
10829
  "extract.ts"() {
10554
10830
  init_activity();
@@ -10578,7 +10854,7 @@ var init_extract = __esm({
10578
10854
  init_chrome_cookies();
10579
10855
  init_data_uri_sanitize();
10580
10856
  init_ssrf_protection();
10581
- DEFAULT_TIMEOUT_MS3 = 3e4;
10857
+ DEFAULT_TIMEOUT_MS4 = 3e4;
10582
10858
  MAX_CONFIGURED_TIMEOUT_MS = 2147483647;
10583
10859
  CONCURRENT_LIMIT = 3;
10584
10860
  WEB_SEARCH_CONFIG_PATH3 = getWebSearchConfigPath();
@@ -10617,6 +10893,7 @@ function normalizeFetchContentParams(params) {
10617
10893
  const answerModel = normalizeOptionalString(params.answerModel);
10618
10894
  const auth = normalizeAuth(params.auth);
10619
10895
  const proxy = normalizeProxy(params.proxy);
10896
+ const redirects = normalizeRedirects(params.redirects);
10620
10897
  return {
10621
10898
  urlList,
10622
10899
  options: {
@@ -10628,7 +10905,8 @@ function normalizeFetchContentParams(params) {
10628
10905
  ...mode !== void 0 ? { mode } : {},
10629
10906
  ...answerModel !== void 0 ? { answerModel } : {},
10630
10907
  ...auth !== void 0 ? { auth } : {},
10631
- ...proxy !== void 0 ? { proxy } : {}
10908
+ ...proxy !== void 0 ? { proxy } : {},
10909
+ ...redirects !== void 0 ? { redirects } : {}
10632
10910
  }
10633
10911
  };
10634
10912
  }
@@ -10651,6 +10929,11 @@ function normalizeMode(value) {
10651
10929
  if (value === "readable" || value === "raw" || value === "answer") return value;
10652
10930
  throw new Error('mode must be "readable", "raw", or "answer"');
10653
10931
  }
10932
+ function normalizeRedirects(value) {
10933
+ if (value === void 0) return void 0;
10934
+ if (value === "same-origin") return value;
10935
+ throw new Error('redirects must be "same-origin"');
10936
+ }
10654
10937
  function normalizeAuth(value) {
10655
10938
  if (value === void 0 || value === false) return void 0;
10656
10939
  if (value === true) return true;
@@ -11409,7 +11692,7 @@ init_credential_source();
11409
11692
  init_utils();
11410
11693
  var BRAVE_API_BASE_URL = "https://api.search.brave.com/res/v1";
11411
11694
  var CONFIG_PATH7 = getWebSearchConfigPath();
11412
- var SEARCH_TIMEOUT_MS = 3e4;
11695
+ var SEARCH_TIMEOUT_MS2 = 3e4;
11413
11696
  var braveRateLimit = new BraveRateLimitCoordinator();
11414
11697
  var cachedConfig7 = null;
11415
11698
  function loadConfig6() {
@@ -11484,6 +11767,31 @@ function matchesDomainFilters(url, filters) {
11484
11767
  }
11485
11768
  return !filters.blocked.some((domain) => hostMatchesDomain(hostname2, domain));
11486
11769
  }
11770
+ var HTML_ENTITIES = {
11771
+ "&amp;": "&",
11772
+ "&lt;": "<",
11773
+ "&gt;": ">",
11774
+ "&quot;": '"',
11775
+ "&apos;": "'",
11776
+ "&nbsp;": " ",
11777
+ "&mdash;": "\u2014",
11778
+ "&ndash;": "\u2013",
11779
+ "&hellip;": "\u2026",
11780
+ "&rsquo;": "\u2019",
11781
+ "&lsquo;": "\u2018",
11782
+ "&rdquo;": "\u201D",
11783
+ "&ldquo;": "\u201C",
11784
+ "&middot;": "\xB7",
11785
+ "&bull;": "\u2022",
11786
+ "&deg;": "\xB0"
11787
+ };
11788
+ function stripHtml(value) {
11789
+ return value.replace(/<[^>]*>/g, "").replace(/&(?:#(x?)([0-9a-f]+)|[a-z]+);/gi, (entity, hex, digits) => {
11790
+ if (!digits) return HTML_ENTITIES[entity.toLowerCase()] ?? entity;
11791
+ const code = Number.parseInt(digits, hex ? 16 : 10);
11792
+ return code <= 1114111 && (code < 55296 || code > 57343) ? String.fromCodePoint(code) : entity;
11793
+ }).trim();
11794
+ }
11487
11795
  function isBraveAvailable() {
11488
11796
  return hasCredentialSource({
11489
11797
  provider: "Brave",
@@ -11521,7 +11829,7 @@ Get a key at https://brave.com/search/api/`
11521
11829
  if (freshness) params.set("freshness", freshness);
11522
11830
  }
11523
11831
  try {
11524
- const searchDeadline = AbortSignal.timeout(SEARCH_TIMEOUT_MS);
11832
+ const searchDeadline = AbortSignal.timeout(SEARCH_TIMEOUT_MS2);
11525
11833
  const searchSignal = options.signal ? AbortSignal.any([searchDeadline, options.signal]) : searchDeadline;
11526
11834
  const response = await braveRateLimit.run(async () => {
11527
11835
  for (let attempt = 0; attempt < 2; attempt++) {
@@ -11555,9 +11863,9 @@ Get a key at https://brave.com/search/api/`
11555
11863
  for (const item of data.web?.results ?? []) {
11556
11864
  if (!item.url || !matchesDomainFilters(item.url, domainFilters)) continue;
11557
11865
  results.push({
11558
- title: item.title || item.url,
11866
+ title: stripHtml(item.title || "") || item.url,
11559
11867
  url: item.url,
11560
- snippet: item.description || ""
11868
+ snippet: stripHtml(item.description || "")
11561
11869
  });
11562
11870
  if (results.length >= numResults) break;
11563
11871
  }
@@ -11592,7 +11900,7 @@ import { existsSync as existsSync11, readFileSync as readFileSync12 } from "node
11592
11900
  var OPENAI_RESPONSES_URL = "https://api.openai.com/v1/responses";
11593
11901
  var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
11594
11902
  var CONFIG_PATH8 = getWebSearchConfigPath();
11595
- var SEARCH_TIMEOUT_MS2 = 6e4;
11903
+ var SEARCH_TIMEOUT_MS3 = 6e4;
11596
11904
  var EXCLUDED_MODEL_SEGMENTS = /* @__PURE__ */ new Set(["pro", "ultra"]);
11597
11905
  var MODEL_PREFERENCE = [
11598
11906
  (id) => id.includes("luna"),
@@ -12194,7 +12502,7 @@ async function runOpenAISearch(query, options, auth, ctx) {
12194
12502
  method: "POST",
12195
12503
  headers: requestHeaders,
12196
12504
  body: JSON.stringify(body),
12197
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS2), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS2)
12505
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS3), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS3)
12198
12506
  }, ["Authorization", "x-opencode-session", "x-opencode-client", "chatgpt-account-id", ...Object.keys(auth.headers)]);
12199
12507
  if (!response.ok) {
12200
12508
  activityMonitor.logError(activityId, `HTTP ${response.status}`);
@@ -12265,7 +12573,7 @@ init_utils();
12265
12573
  import { existsSync as existsSync15, readFileSync as readFileSync16 } from "node:fs";
12266
12574
  var SEARCHINFINITY_SEARCH_URL = "https://torchlight.byteintlapi.com/search_api/web_search";
12267
12575
  var CONFIG_PATH13 = getWebSearchConfigPath();
12268
- var SEARCH_TIMEOUT_MS6 = 3e4;
12576
+ var SEARCH_TIMEOUT_MS7 = 3e4;
12269
12577
  var cachedConfig12 = null;
12270
12578
  function loadConfig11() {
12271
12579
  if (cachedConfig12) return cachedConfig12;
@@ -12363,7 +12671,7 @@ async function searchinfinityJsonRequest(apiKey, body, signal) {
12363
12671
  "Content-Type": "application/json"
12364
12672
  },
12365
12673
  body: JSON.stringify(body),
12366
- signal: requestSignal6(signal, SEARCH_TIMEOUT_MS6)
12674
+ signal: requestSignal6(signal, SEARCH_TIMEOUT_MS7)
12367
12675
  });
12368
12676
  } catch (err) {
12369
12677
  const message = errorMessage5(err);
@@ -12444,7 +12752,7 @@ init_utils();
12444
12752
  import { existsSync as existsSync17, readFileSync as readFileSync18 } from "node:fs";
12445
12753
  var TAVILY_API_BASE_URL = "https://api.tavily.com";
12446
12754
  var CONFIG_PATH15 = getWebSearchConfigPath();
12447
- var SEARCH_TIMEOUT_MS8 = 6e4;
12755
+ var SEARCH_TIMEOUT_MS9 = 6e4;
12448
12756
  var cachedConfig14 = null;
12449
12757
  function loadConfig13() {
12450
12758
  if (cachedConfig14) return cachedConfig14;
@@ -12517,7 +12825,7 @@ function mapDomainFilter6(domainFilter) {
12517
12825
  };
12518
12826
  }
12519
12827
  function requestSignal8(signal) {
12520
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS8);
12828
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS9);
12521
12829
  return signal ? AbortSignal.any([signal, timeout]) : timeout;
12522
12830
  }
12523
12831
  function errorMessage7(err) {
@@ -12655,7 +12963,7 @@ init_utils();
12655
12963
  import { existsSync as existsSync18, readFileSync as readFileSync19 } from "node:fs";
12656
12964
  var YOU_SEARCH_URL = "https://ydc-index.io/v1/search";
12657
12965
  var CONFIG_PATH16 = getWebSearchConfigPath();
12658
- var SEARCH_TIMEOUT_MS9 = 6e4;
12966
+ var SEARCH_TIMEOUT_MS10 = 6e4;
12659
12967
  var cachedConfig15 = null;
12660
12968
  function loadConfig14() {
12661
12969
  if (cachedConfig15) return cachedConfig15;
@@ -12730,7 +13038,7 @@ async function searchWithYou(query, options = {}) {
12730
13038
  ...mapDomainFilter7(options.domainFilter)
12731
13039
  };
12732
13040
  const activityId = activityMonitor.logStart({ type: "api", query });
12733
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS9);
13041
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS10);
12734
13042
  let response;
12735
13043
  let entries;
12736
13044
  try {
@@ -12759,7 +13067,7 @@ async function searchWithYou(query, options = {}) {
12759
13067
  }
12760
13068
  const message = errorMessage8(err);
12761
13069
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
12762
- const outgoing = providerTimeout ? new Error(`You.com request timed out after ${Math.round(SEARCH_TIMEOUT_MS9 / 1e3)}s`) : (() => {
13070
+ const outgoing = providerTimeout ? new Error(`You.com request timed out after ${Math.round(SEARCH_TIMEOUT_MS10 / 1e3)}s`) : (() => {
12763
13071
  const redactedMessage = redactCredential(message, apiKey);
12764
13072
  if (redactedMessage === message && err instanceof Error) return err;
12765
13073
  const redactedError = new Error(redactedMessage);
@@ -12805,7 +13113,7 @@ init_utils();
12805
13113
  import { existsSync as existsSync21, readFileSync as readFileSync22 } from "node:fs";
12806
13114
  var JINA_SEARCH_BASE_URL = "https://s.jina.ai/";
12807
13115
  var CONFIG_PATH18 = getWebSearchConfigPath();
12808
- var SEARCH_TIMEOUT_MS11 = 6e4;
13116
+ var SEARCH_TIMEOUT_MS12 = 6e4;
12809
13117
  var cachedConfig17 = null;
12810
13118
  function loadConfig16() {
12811
13119
  if (cachedConfig17) return cachedConfig17;
@@ -12881,7 +13189,7 @@ function buildSearchRequest(query, options, numResults) {
12881
13189
  return { url: url.toString(), filters };
12882
13190
  }
12883
13191
  function requestSignal10(signal) {
12884
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS11);
13192
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS12);
12885
13193
  return {
12886
13194
  timeout,
12887
13195
  signal: signal ? AbortSignal.any([signal, timeout]) : timeout
@@ -13025,7 +13333,7 @@ init_utils();
13025
13333
  import { existsSync as existsSync22, readFileSync as readFileSync23 } from "node:fs";
13026
13334
  var SERPDIVE_API_URL = "https://api.serpdive.com/v1/search";
13027
13335
  var CONFIG_PATH19 = getWebSearchConfigPath();
13028
- var SEARCH_TIMEOUT_MS12 = 6e4;
13336
+ var SEARCH_TIMEOUT_MS13 = 6e4;
13029
13337
  var MODELS = ["krill", "mako", "moby"];
13030
13338
  var DEFAULT_MODEL2 = "krill";
13031
13339
  var cachedConfig18 = null;
@@ -13108,7 +13416,7 @@ function applyRecencyHint(query, recencyFilter) {
13108
13416
  return hint ? `${query} ${hint}` : query;
13109
13417
  }
13110
13418
  function requestSignal11(signal) {
13111
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS12);
13419
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS13);
13112
13420
  return signal ? AbortSignal.any([signal, timeout]) : timeout;
13113
13421
  }
13114
13422
  function errorMessage11(err) {
@@ -13230,7 +13538,7 @@ init_utils();
13230
13538
  import { existsSync as existsSync24, readFileSync as readFileSync25 } from "node:fs";
13231
13539
  var BOCHA_SEARCH_URL = "https://api.bochaai.com/v1/web-search";
13232
13540
  var CONFIG_PATH21 = getWebSearchConfigPath();
13233
- var SEARCH_TIMEOUT_MS14 = 6e4;
13541
+ var SEARCH_TIMEOUT_MS15 = 6e4;
13234
13542
  var cachedConfig20 = null;
13235
13543
  function loadConfig19() {
13236
13544
  if (cachedConfig20) return cachedConfig20;
@@ -13360,7 +13668,7 @@ async function searchWithBocha(query, options = {}) {
13360
13668
  method: "POST",
13361
13669
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", Accept: "application/json" },
13362
13670
  body: JSON.stringify({ query, count: numResults, freshness: mapFreshness(options.recencyFilter), summary: true }),
13363
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS14), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS14)
13671
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS15), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS15)
13364
13672
  });
13365
13673
  } catch (err) {
13366
13674
  const message = errorMessage13(err);
@@ -13412,7 +13720,7 @@ init_search_result_count_normalization();
13412
13720
  init_utils();
13413
13721
  import { existsSync as existsSync26, readFileSync as readFileSync27 } from "node:fs";
13414
13722
  var CONFIG_PATH23 = getWebSearchConfigPath();
13415
- var SEARCH_TIMEOUT_MS16 = 3e4;
13723
+ var SEARCH_TIMEOUT_MS17 = 3e4;
13416
13724
  var cachedConfig22 = null;
13417
13725
  function loadConfig21() {
13418
13726
  if (cachedConfig22) return cachedConfig22;
@@ -13552,7 +13860,7 @@ async function searchWithSearXNG(query, options = {}) {
13552
13860
  const response = await fetchRemoteUrl(url, {
13553
13861
  method: "GET",
13554
13862
  headers,
13555
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS16), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS16)
13863
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS17), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS17)
13556
13864
  }, {
13557
13865
  ...loadSsrfConfig(),
13558
13866
  onRedirect: ({ from, to, init }) => from.origin === to.origin ? init : { ...init, headers: { Accept: "application/json" } }
@@ -13599,7 +13907,7 @@ init_utils();
13599
13907
  import { existsSync as existsSync27, readFileSync as readFileSync28 } from "node:fs";
13600
13908
  var CONFIG_PATH24 = getWebSearchConfigPath();
13601
13909
  var DEFAULT_BASE_URL = "https://degoog.org";
13602
- var SEARCH_TIMEOUT_MS17 = 3e4;
13910
+ var SEARCH_TIMEOUT_MS18 = 3e4;
13603
13911
  var cachedConfig23 = null;
13604
13912
  function loadConfig22() {
13605
13913
  if (cachedConfig23) return cachedConfig23;
@@ -13773,7 +14081,7 @@ async function searchWithDegoog(query, options = {}) {
13773
14081
  if (engines.length > 0) body.engines = engines;
13774
14082
  const url = new URL(`${baseUrl}/api/search`);
13775
14083
  const activityId = activityMonitor.logStart({ type: "api", query: searchQuery });
13776
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS17);
14084
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS18);
13777
14085
  let response;
13778
14086
  let entries;
13779
14087
  try {
@@ -13811,7 +14119,7 @@ async function searchWithDegoog(query, options = {}) {
13811
14119
  }
13812
14120
  const message = errorMessage15(err);
13813
14121
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
13814
- const outgoing = providerTimeout ? new Error(`degoog request timed out after ${Math.round(SEARCH_TIMEOUT_MS17 / 1e3)}s`) : (() => {
14122
+ const outgoing = providerTimeout ? new Error(`degoog request timed out after ${Math.round(SEARCH_TIMEOUT_MS18 / 1e3)}s`) : (() => {
13815
14123
  const redactedMessage = redactSecrets(message, secrets);
13816
14124
  if (redactedMessage === message && err instanceof Error) return err;
13817
14125
  const redactedError = new Error(redactedMessage);
@@ -13853,7 +14161,7 @@ init_activity();
13853
14161
  init_domain_filter_normalization();
13854
14162
  init_search_result_count_normalization();
13855
14163
  var SEARCH_URL = "https://html.duckduckgo.com/html/";
13856
- var SEARCH_TIMEOUT_MS18 = 3e4;
14164
+ var SEARCH_TIMEOUT_MS19 = 3e4;
13857
14165
  function normalizeDomainFilters5(domainFilter) {
13858
14166
  const filters = { allowed: [], blocked: [] };
13859
14167
  for (const raw of domainFilter ?? []) {
@@ -13897,7 +14205,7 @@ async function searchWithDuckDuckGo(query, options = {}) {
13897
14205
  Accept: "text/html",
13898
14206
  "User-Agent": "Mozilla/5.0 (compatible; pi-web-access/1.0; +https://github.com/nicobailon/pi-web-access)"
13899
14207
  },
13900
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS18), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS18)
14208
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS19), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS19)
13901
14209
  });
13902
14210
  if (!response.ok) {
13903
14211
  const body = await response.text();
@@ -13905,6 +14213,9 @@ async function searchWithDuckDuckGo(query, options = {}) {
13905
14213
  }
13906
14214
  const { parseHTML } = await import("linkedom");
13907
14215
  const { document } = parseHTML(await response.text());
14216
+ if (response.status === 202 || document.querySelector(".anomaly-modal__box, #challenge-form")) {
14217
+ throw new Error(`DuckDuckGo blocked the request with a bot check (HTTP ${response.status}, rate limited); use another search provider`);
14218
+ }
13908
14219
  const filters = normalizeDomainFilters5(options.domainFilter);
13909
14220
  const results = [];
13910
14221
  let parseableResults = 0;
@@ -13921,7 +14232,7 @@ async function searchWithDuckDuckGo(query, options = {}) {
13921
14232
  results.push({ title, url: resultUrl, snippet });
13922
14233
  if (results.length >= normalizeSearchResultCount(options.numResults)) break;
13923
14234
  }
13924
- if (parseableResults === 0) {
14235
+ if (parseableResults === 0 && !document.querySelector(".no-results__message")) {
13925
14236
  throw new Error("DuckDuckGo returned no parseable results (invalid response)");
13926
14237
  }
13927
14238
  activityMonitor.logComplete(activityId, response.status);
@@ -13945,7 +14256,7 @@ init_utils();
13945
14256
  import { existsSync as existsSync28, readFileSync as readFileSync29 } from "node:fs";
13946
14257
  var ANYSEARCH_API_URL = "https://api.anysearch.com/v1/search";
13947
14258
  var CONFIG_PATH25 = getWebSearchConfigPath();
13948
- var SEARCH_TIMEOUT_MS19 = 3e4;
14259
+ var SEARCH_TIMEOUT_MS20 = 3e4;
13949
14260
  var cachedConfig24 = null;
13950
14261
  function loadConfig23() {
13951
14262
  if (cachedConfig24) return cachedConfig24;
@@ -14030,7 +14341,7 @@ async function searchWithAnySearch(query, options = {}) {
14030
14341
  "Content-Type": "application/json"
14031
14342
  },
14032
14343
  body: JSON.stringify(body),
14033
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS19), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS19)
14344
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS20), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS20)
14034
14345
  });
14035
14346
  } catch (err) {
14036
14347
  const message = errorMessage16(err);
@@ -14085,7 +14396,7 @@ init_utils();
14085
14396
  import { existsSync as existsSync29, readFileSync as readFileSync30 } from "node:fs";
14086
14397
  var XCRAWL_API_URL = "https://run.xcrawl.com/v1/serp";
14087
14398
  var CONFIG_PATH26 = getWebSearchConfigPath();
14088
- var SEARCH_TIMEOUT_MS20 = 6e4;
14399
+ var SEARCH_TIMEOUT_MS21 = 6e4;
14089
14400
  var cachedConfig25 = null;
14090
14401
  function loadConfig24() {
14091
14402
  if (cachedConfig25) return cachedConfig25;
@@ -14205,7 +14516,7 @@ async function searchWithXCrawl(query, options = {}) {
14205
14516
  }
14206
14517
  const body = { engine: "google_search", q: query };
14207
14518
  const activityId = activityMonitor.logStart({ type: "api", query });
14208
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS20);
14519
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS21);
14209
14520
  let response;
14210
14521
  try {
14211
14522
  response = await fetch(XCRAWL_API_URL, {
@@ -14226,7 +14537,7 @@ async function searchWithXCrawl(query, options = {}) {
14226
14537
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
14227
14538
  let outgoing;
14228
14539
  if (providerTimeout) {
14229
- outgoing = new Error(`XCrawl search request timed out after ${Math.round(SEARCH_TIMEOUT_MS20 / 1e3)}s`);
14540
+ outgoing = new Error(`XCrawl search request timed out after ${Math.round(SEARCH_TIMEOUT_MS21 / 1e3)}s`);
14230
14541
  } else {
14231
14542
  const redactedMessage = redactCredential(message, apiKey);
14232
14543
  outgoing = redactedMessage === message && err instanceof Error ? err : new Error(redactedMessage);
@@ -14270,7 +14581,7 @@ init_utils();
14270
14581
  import { existsSync as existsSync30, readFileSync as readFileSync31 } from "node:fs";
14271
14582
  var XAI_RESPONSES_URL = "https://api.x.ai/v1/responses";
14272
14583
  var CONFIG_PATH27 = getWebSearchConfigPath();
14273
- var SEARCH_TIMEOUT_MS21 = 6e4;
14584
+ var SEARCH_TIMEOUT_MS22 = 6e4;
14274
14585
  var WEB_SEARCH_AUTH_MODEL_CANDIDATES = ["grok-4.5", "grok-4.3", "grok-build-0.1"];
14275
14586
  var X_SEARCH_AUTH_MODEL_CANDIDATES = ["grok-4.6", ...WEB_SEARCH_AUTH_MODEL_CANDIDATES];
14276
14587
  var DEFAULT_XAI_SEARCH_TOOLS = ["web_search"];
@@ -14523,7 +14834,7 @@ async function searchWithXai(query, options = {}, ctx) {
14523
14834
  input: buildInput(query, options, tools),
14524
14835
  tools: tools.map((type) => ({ type }))
14525
14836
  }),
14526
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS21), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS21)
14837
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS22), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS22)
14527
14838
  });
14528
14839
  if (!response.ok) {
14529
14840
  activityMonitor.logError(activityId, `HTTP ${response.status}`);
@@ -14570,7 +14881,7 @@ init_utils();
14570
14881
  import { existsSync as existsSync31, readFileSync as readFileSync32 } from "node:fs";
14571
14882
  var BRIGHTDATA_API_URL = "https://api.brightdata.com/request";
14572
14883
  var CONFIG_PATH28 = getWebSearchConfigPath();
14573
- var SEARCH_TIMEOUT_MS22 = 6e4;
14884
+ var SEARCH_TIMEOUT_MS23 = 6e4;
14574
14885
  var ZONE_PATTERN = /^[A-Za-z0-9_-]+$/;
14575
14886
  var RECENCY_TBS = {
14576
14887
  day: "qdr:d",
@@ -14709,7 +15020,7 @@ function passesDomainFilters4(url, filters) {
14709
15020
  return filters.include.some((domain) => domainMatches4(hostname2, domain));
14710
15021
  }
14711
15022
  function requestSignal12(signal) {
14712
- const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS22);
15023
+ const timeout = AbortSignal.timeout(SEARCH_TIMEOUT_MS23);
14713
15024
  return signal ? AbortSignal.any([signal, timeout]) : timeout;
14714
15025
  }
14715
15026
  function errorMessage18(err) {
@@ -14867,7 +15178,7 @@ init_utils();
14867
15178
  import { existsSync as existsSync32, readFileSync as readFileSync33 } from "node:fs";
14868
15179
  var SERPBASE_API_URL = "https://api.serpbase.dev/google/search";
14869
15180
  var CONFIG_PATH29 = getWebSearchConfigPath();
14870
- var SEARCH_TIMEOUT_MS23 = 6e4;
15181
+ var SEARCH_TIMEOUT_MS24 = 6e4;
14871
15182
  var RECENCY_TBS2 = {
14872
15183
  day: "qdr:d",
14873
15184
  week: "qdr:w",
@@ -14986,7 +15297,7 @@ async function searchWithSerpBase(query, options = {}) {
14986
15297
  try {
14987
15298
  response = await fetch(url, {
14988
15299
  headers: { Accept: "application/json" },
14989
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS23), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS23)
15300
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS24), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS24)
14990
15301
  });
14991
15302
  } catch (err) {
14992
15303
  const message = errorMessage19(err);
@@ -15036,7 +15347,7 @@ init_utils();
15036
15347
  import { existsSync as existsSync33, readFileSync as readFileSync34 } from "node:fs";
15037
15348
  var SERPAPI_SEARCH_URL = "https://serpapi.com/search.json";
15038
15349
  var CONFIG_PATH30 = getWebSearchConfigPath();
15039
- var SEARCH_TIMEOUT_MS24 = 6e4;
15350
+ var SEARCH_TIMEOUT_MS25 = 6e4;
15040
15351
  var RECENCY_TBS3 = {
15041
15352
  day: "qdr:d",
15042
15353
  week: "qdr:w",
@@ -15141,7 +15452,7 @@ async function searchWithSerpApi(query, options = {}) {
15141
15452
  url.searchParams.set("num", String(requestCount));
15142
15453
  if (options.recencyFilter) url.searchParams.set("tbs", RECENCY_TBS3[options.recencyFilter]);
15143
15454
  const activityId = activityMonitor.logStart({ type: "api", query });
15144
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS24);
15455
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS25);
15145
15456
  let response;
15146
15457
  let entries;
15147
15458
  try {
@@ -15168,7 +15479,7 @@ async function searchWithSerpApi(query, options = {}) {
15168
15479
  }
15169
15480
  const message = errorMessage20(err);
15170
15481
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
15171
- const outgoing = providerTimeout ? new Error(`SerpApi request timed out after ${Math.round(SEARCH_TIMEOUT_MS24 / 1e3)}s`) : (() => {
15482
+ const outgoing = providerTimeout ? new Error(`SerpApi request timed out after ${Math.round(SEARCH_TIMEOUT_MS25 / 1e3)}s`) : (() => {
15172
15483
  const redactedMessage = redactCredential(message, apiKey);
15173
15484
  if (redactedMessage === message && err instanceof Error) return err;
15174
15485
  const redactedError = new Error(redactedMessage);
@@ -15204,7 +15515,7 @@ init_utils();
15204
15515
  import { existsSync as existsSync34, readFileSync as readFileSync35 } from "node:fs";
15205
15516
  var SERPER_SEARCH_URL = "https://google.serper.dev/search";
15206
15517
  var CONFIG_PATH31 = getWebSearchConfigPath();
15207
- var SEARCH_TIMEOUT_MS25 = 6e4;
15518
+ var SEARCH_TIMEOUT_MS26 = 6e4;
15208
15519
  var RECENCY_TBS4 = {
15209
15520
  day: "qdr:d",
15210
15521
  week: "qdr:w",
@@ -15308,7 +15619,7 @@ async function searchWithSerper(query, options = {}) {
15308
15619
  method: "POST",
15309
15620
  headers: { "X-API-KEY": apiKey, "Content-Type": "application/json", Accept: "application/json" },
15310
15621
  body: JSON.stringify({ q: buildQuery4(query, filters), num: requestCount, ...options.recencyFilter ? { tbs: RECENCY_TBS4[options.recencyFilter] } : {} }),
15311
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS25), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS25)
15622
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS26), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS26)
15312
15623
  });
15313
15624
  } catch (err) {
15314
15625
  const message = errorMessage21(err);
@@ -15365,7 +15676,7 @@ init_utils();
15365
15676
  import { existsSync as existsSync35, readFileSync as readFileSync36 } from "node:fs";
15366
15677
  var SERPLY_SEARCH_URL = "https://api.serply.io/v1/search";
15367
15678
  var CONFIG_PATH32 = getWebSearchConfigPath();
15368
- var SEARCH_TIMEOUT_MS26 = 6e4;
15679
+ var SEARCH_TIMEOUT_MS27 = 6e4;
15369
15680
  var RECENCY_TBS5 = {
15370
15681
  day: "qdr:d",
15371
15682
  week: "qdr:w",
@@ -15463,7 +15774,7 @@ async function searchWithSerply(query, options = {}) {
15463
15774
  url.searchParams.set("num", String(requestCount));
15464
15775
  if (options.recencyFilter) url.searchParams.set("tbs", RECENCY_TBS5[options.recencyFilter]);
15465
15776
  const activityId = activityMonitor.logStart({ type: "api", query });
15466
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS26);
15777
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS27);
15467
15778
  let response;
15468
15779
  let entries;
15469
15780
  try {
@@ -15490,7 +15801,7 @@ async function searchWithSerply(query, options = {}) {
15490
15801
  }
15491
15802
  const message = errorMessage22(err);
15492
15803
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
15493
- const outgoing = providerTimeout ? new Error(`Serply request timed out after ${Math.round(SEARCH_TIMEOUT_MS26 / 1e3)}s`) : (() => {
15804
+ const outgoing = providerTimeout ? new Error(`Serply request timed out after ${Math.round(SEARCH_TIMEOUT_MS27 / 1e3)}s`) : (() => {
15494
15805
  const redactedMessage = redactCredential(message, apiKey);
15495
15806
  if (redactedMessage === message && err instanceof Error) return err;
15496
15807
  const redactedError = new Error(redactedMessage);
@@ -15532,7 +15843,7 @@ init_utils();
15532
15843
  import { existsSync as existsSync36, readFileSync as readFileSync37 } from "node:fs";
15533
15844
  import { isIP as isIP2 } from "node:net";
15534
15845
  var MCP_URL = "https://agent-toolkit.app.baizhi.cloud/mcp";
15535
- var SEARCH_TIMEOUT_MS27 = 6e4;
15846
+ var SEARCH_TIMEOUT_MS28 = 6e4;
15536
15847
  var CONFIG_PATH33 = getWebSearchConfigPath();
15537
15848
  function credentialOptions() {
15538
15849
  let config = {};
@@ -15575,7 +15886,7 @@ function searchArguments(query, options) {
15575
15886
  }
15576
15887
  async function searchWithBaizhi(query, options = {}) {
15577
15888
  const args = searchArguments(query, options);
15578
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS27);
15889
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS28);
15579
15890
  const signal = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
15580
15891
  if (signal.aborted) throw new Error("Aborted");
15581
15892
  const apiKey = await resolveCredential({ ...credentialOptions(), signal });
@@ -15603,8 +15914,8 @@ async function searchWithBaizhi(query, options = {}) {
15603
15914
  const client = new Client({ name: "pi-web-access-baizhi", version: "1.0.0" });
15604
15915
  const activityId = activityMonitor.logStart({ type: "api", query });
15605
15916
  try {
15606
- await client.connect(transport, { signal, timeout: SEARCH_TIMEOUT_MS27 });
15607
- const result = await client.callTool({ name: "websearch_search", arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS27 });
15917
+ await client.connect(transport, { signal, timeout: SEARCH_TIMEOUT_MS28 });
15918
+ const result = await client.callTool({ name: "websearch_search", arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS28 });
15608
15919
  if (result.isError) throw new Error("Baizhi search tool returned an error");
15609
15920
  const parts = [];
15610
15921
  if (result.structuredContent !== void 0) parts.push(JSON.stringify(result.structuredContent, null, 2));
@@ -15648,7 +15959,7 @@ var MCP_URLS = {
15648
15959
  china: "https://open.bigmodel.cn/api/mcp/web_search_prime/mcp"
15649
15960
  };
15650
15961
  var RECENCY = { day: "oneDay", week: "oneWeek", month: "oneMonth", year: "oneYear" };
15651
- var SEARCH_TIMEOUT_MS28 = 6e4;
15962
+ var SEARCH_TIMEOUT_MS29 = 6e4;
15652
15963
  var CONFIG_PATH34 = getWebSearchConfigPath();
15653
15964
  function loadConfig31() {
15654
15965
  if (!existsSync37(CONFIG_PATH34)) return {};
@@ -15719,7 +16030,7 @@ async function searchWithZai(query, options = {}) {
15719
16030
  const mcpUrl = endpointUrl(config);
15720
16031
  const args = searchArguments2(query, options);
15721
16032
  const limit = normalizeSearchResultCount(options.numResults);
15722
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS28);
16033
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS29);
15723
16034
  const signal = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
15724
16035
  if (signal.aborted) throw new Error("Aborted");
15725
16036
  const apiKey = await resolveCredential({ ...credentialOptions2(config), signal });
@@ -15747,11 +16058,11 @@ async function searchWithZai(query, options = {}) {
15747
16058
  const client = new Client({ name: "pi-web-access-zai", version: "1.0.0" });
15748
16059
  const activityId = activityMonitor.logStart({ type: "api", query });
15749
16060
  try {
15750
- await client.connect(transport, { signal, timeout: SEARCH_TIMEOUT_MS28 });
15751
- const { tools } = await client.listTools(void 0, { signal, timeout: SEARCH_TIMEOUT_MS28 });
16061
+ await client.connect(transport, { signal, timeout: SEARCH_TIMEOUT_MS29 });
16062
+ const { tools } = await client.listTools(void 0, { signal, timeout: SEARCH_TIMEOUT_MS29 });
15752
16063
  const toolName = tools.find((tool) => tool.name === "web_search_prime" || tool.name === "webSearchPrime")?.name;
15753
16064
  if (!toolName) throw new Error("Z.ai returned invalid response: web search tool not listed");
15754
- const result = await client.callTool({ name: toolName, arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS28 });
16065
+ const result = await client.callTool({ name: toolName, arguments: args }, void 0, { signal, timeout: SEARCH_TIMEOUT_MS29 });
15755
16066
  if (result.isError) throw new Error("Z.ai search tool returned an error");
15756
16067
  const text4 = (Array.isArray(result.content) ? result.content : []).find((item) => item.type === "text" && typeof item.text === "string");
15757
16068
  if (!text4) throw new Error("Z.ai returned invalid response: no search text");
@@ -15788,7 +16099,7 @@ init_utils();
15788
16099
  import { existsSync as existsSync38, readFileSync as readFileSync39 } from "node:fs";
15789
16100
  var VALYU_SEARCH_URL = "https://api.valyu.ai/v1/search";
15790
16101
  var CONFIG_PATH35 = getWebSearchConfigPath();
15791
- var SEARCH_TIMEOUT_MS29 = 6e4;
16102
+ var SEARCH_TIMEOUT_MS30 = 6e4;
15792
16103
  var MAX_SNIPPET_CHARS = 2500;
15793
16104
  var MAX_CONTENT_CHARS = 4e3;
15794
16105
  var cachedConfig32 = null;
@@ -15882,7 +16193,7 @@ async function searchWithValyu(query, options = {}) {
15882
16193
  method: "POST",
15883
16194
  headers: { "x-api-key": apiKey, "Content-Type": "application/json", Accept: "application/json" },
15884
16195
  body: JSON.stringify({ query, max_num_results: numResults, ...mapDomainFilter9(options.domainFilter), ...startDate ? { start_date: startDate } : {} }),
15885
- signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS29), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS29)
16196
+ signal: options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS30), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS30)
15886
16197
  });
15887
16198
  } catch (err) {
15888
16199
  const message = errorMessage23(err);
@@ -15942,7 +16253,7 @@ var KEENABLE_SEARCH_URL = "https://api.keenable.ai/v1/search";
15942
16253
  var KEENABLE_PUBLIC_SEARCH_URL = "https://api.keenable.ai/v1/search/public";
15943
16254
  var KEENABLE_CLIENT_TITLE = "pi-web-access";
15944
16255
  var CONFIG_PATH36 = getWebSearchConfigPath();
15945
- var SEARCH_TIMEOUT_MS30 = 3e4;
16256
+ var SEARCH_TIMEOUT_MS31 = 3e4;
15946
16257
  var MAX_REQUEST_RESULTS = 50;
15947
16258
  var MAX_SNIPPET_CHARS2 = 500;
15948
16259
  var RECENCY_DAYS = {
@@ -16044,7 +16355,7 @@ async function searchWithKeenable(query, options = {}) {
16044
16355
  ...apiKey ? { "X-API-Key": apiKey } : {}
16045
16356
  };
16046
16357
  const activityId = activityMonitor.logStart({ type: "api", query });
16047
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS30);
16358
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS31);
16048
16359
  let response;
16049
16360
  let entries;
16050
16361
  try {
@@ -16074,7 +16385,7 @@ async function searchWithKeenable(query, options = {}) {
16074
16385
  }
16075
16386
  const message = errorMessage24(err);
16076
16387
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
16077
- const outgoing = providerTimeout ? new Error(`Keenable request timed out after ${Math.round(SEARCH_TIMEOUT_MS30 / 1e3)}s`) : (() => {
16388
+ const outgoing = providerTimeout ? new Error(`Keenable request timed out after ${Math.round(SEARCH_TIMEOUT_MS31 / 1e3)}s`) : (() => {
16078
16389
  const redactedMessage = redactCredential(message, apiKey);
16079
16390
  if (redactedMessage === message && err instanceof Error) return err;
16080
16391
  const redactedError = new Error(redactedMessage);
@@ -16121,7 +16432,7 @@ init_utils();
16121
16432
  import { existsSync as existsSync40, readFileSync as readFileSync41 } from "node:fs";
16122
16433
  var CERAMIC_SEARCH_URL = "https://api.ceramic.ai/search";
16123
16434
  var CONFIG_PATH37 = getWebSearchConfigPath();
16124
- var SEARCH_TIMEOUT_MS31 = 3e4;
16435
+ var SEARCH_TIMEOUT_MS32 = 3e4;
16125
16436
  var MAX_REQUEST_RESULTS2 = 20;
16126
16437
  var REQUEST_DESCRIPTION_CHARS = 1e3;
16127
16438
  var MAX_SNIPPET_CHARS3 = 500;
@@ -16225,7 +16536,7 @@ async function searchWithCeramic(query, options = {}) {
16225
16536
  maxDescriptionLength: REQUEST_DESCRIPTION_CHARS
16226
16537
  };
16227
16538
  const activityId = activityMonitor.logStart({ type: "api", query });
16228
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS31);
16539
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS32);
16229
16540
  let response;
16230
16541
  let entries;
16231
16542
  try {
@@ -16258,7 +16569,7 @@ async function searchWithCeramic(query, options = {}) {
16258
16569
  }
16259
16570
  const message = errorMessage25(err);
16260
16571
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
16261
- const outgoing = providerTimeout ? new Error(`Ceramic request timed out after ${Math.round(SEARCH_TIMEOUT_MS31 / 1e3)}s`) : (() => {
16572
+ const outgoing = providerTimeout ? new Error(`Ceramic request timed out after ${Math.round(SEARCH_TIMEOUT_MS32 / 1e3)}s`) : (() => {
16262
16573
  const redactedMessage = redactCredential(message, apiKey);
16263
16574
  if (redactedMessage === message && err instanceof Error) return err;
16264
16575
  const redactedError = new Error(redactedMessage);
@@ -16303,7 +16614,7 @@ init_search_result_count_normalization();
16303
16614
  import { randomUUID as randomUUID2 } from "node:crypto";
16304
16615
  var KIMI_SEARCH_URL = "https://api.kimi.com/coding/v1/search";
16305
16616
  var KIMI_PROVIDERS = ["kimi-coding", "kimi-code"];
16306
- var SEARCH_TIMEOUT_MS32 = 3e4;
16617
+ var SEARCH_TIMEOUT_MS33 = 3e4;
16307
16618
  function buildRequestHeaders(auth) {
16308
16619
  const headers = new Headers();
16309
16620
  for (const [name, value] of Object.entries(auth.headers)) {
@@ -16418,7 +16729,7 @@ async function searchWithKimi(query, options = {}, ctx) {
16418
16729
  throw new Error("Kimi Code web search unavailable. Run /login kimi-coding to authenticate a Kimi Code Plan account.");
16419
16730
  }
16420
16731
  const activityId = activityMonitor.logStart({ type: "api", query });
16421
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS32);
16732
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS33);
16422
16733
  const requestSignal15 = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
16423
16734
  try {
16424
16735
  const response = await fetch(KIMI_SEARCH_URL, {
@@ -16473,7 +16784,7 @@ init_utils();
16473
16784
  import { existsSync as existsSync41, readFileSync as readFileSync42 } from "node:fs";
16474
16785
  var MISTRAL_CONVERSATIONS_URL = "https://api.mistral.ai/v1/conversations";
16475
16786
  var CONFIG_PATH38 = getWebSearchConfigPath();
16476
- var SEARCH_TIMEOUT_MS33 = 6e4;
16787
+ var SEARCH_TIMEOUT_MS34 = 6e4;
16477
16788
  var DEFAULT_SEARCH_MODEL = "mistral-small-latest";
16478
16789
  var DEFAULT_SEARCH_TOOL = "web_search";
16479
16790
  var MAX_RESULTS = 20;
@@ -16649,7 +16960,7 @@ async function searchWithMistral(query, options = {}) {
16649
16960
  const tool = resolveSearchTool(config.mistralSearchTool);
16650
16961
  const numResults = normalizeCount4(options.numResults);
16651
16962
  const apiKey = await getApiKey26(options.signal);
16652
- const requestSignal15 = options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS33), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS33);
16963
+ const requestSignal15 = options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS34), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS34);
16653
16964
  const activityId = activityMonitor.logStart({ type: "api", query });
16654
16965
  try {
16655
16966
  const response = await fetch(MISTRAL_CONVERSATIONS_URL, {
@@ -16838,11 +17149,11 @@ function errorMessage27(err) {
16838
17149
  function isAbortError2(err) {
16839
17150
  return errorMessage27(err).toLowerCase().includes("abort");
16840
17151
  }
16841
- async function tryOpenAIInAuto(query, options, fallbackErrors) {
17152
+ async function tryOpenAIInAuto(query, options, fallbackErrors, take) {
16842
17153
  try {
16843
17154
  if (await isOpenAISearchAvailable(options.extensionContext)) {
16844
17155
  const result = await searchWithOpenAI(query, options, options.extensionContext);
16845
- return { ...result, provider: "openai" };
17156
+ return take(result, "openai");
16846
17157
  }
16847
17158
  } catch (err) {
16848
17159
  if (isAbortError2(err)) throw err;
@@ -17164,168 +17475,58 @@ async function search(query, options = {}) {
17164
17475
  return searchWithConfiguredRouting(query, options, config.searchRouting);
17165
17476
  }
17166
17477
  const fallbackErrors = [];
17478
+ let firstEmpty;
17479
+ const take = (result, provider2) => {
17480
+ if (!result) return null;
17481
+ const response = { ...result, provider: provider2 };
17482
+ if (result.results.length || result.answer.trim()) return response;
17483
+ firstEmpty ??= response;
17484
+ return null;
17485
+ };
17167
17486
  const allowed = new Set(config.allowedProviders ?? RESOLVED_SEARCH_PROVIDERS);
17168
- if (allowed.has("searxng") && isSearXNGAvailable()) {
17487
+ const attempt = async (provider2) => {
17488
+ if (!allowed.has(provider2) || !await isResolvedProviderAvailable(provider2, options)) return null;
17169
17489
  try {
17170
- const result = await searchWithSearXNG(query, options);
17171
- return { ...result, provider: "searxng" };
17490
+ return take(await searchWithResolvedProvider(provider2, query, options), provider2);
17172
17491
  } catch (err) {
17173
17492
  if (isAbortError2(err)) throw err;
17174
- fallbackErrors.push(`SearXNG: ${errorMessage27(err)}`);
17493
+ fallbackErrors.push(`${providerLabel(provider2)}: ${errorMessage27(err)}`);
17494
+ return null;
17175
17495
  }
17176
- }
17496
+ };
17497
+ const searxng = await attempt("searxng");
17498
+ if (searxng) return searxng;
17177
17499
  let triedOpenAI = false;
17178
17500
  if (allowed.has("openai") && (!options.extensionContext || isOpenAISubscriptionModelSelected(options.extensionContext))) {
17179
17501
  triedOpenAI = true;
17180
- const result = await tryOpenAIInAuto(query, options, fallbackErrors);
17502
+ const result = await tryOpenAIInAuto(query, options, fallbackErrors, take);
17181
17503
  if (result) return result;
17182
17504
  }
17183
17505
  if (allowed.has("exa") && isExaAvailable()) {
17184
17506
  try {
17185
- const result = await searchWithExa(query, options);
17186
- if (result) return { ...result, provider: "exa" };
17507
+ const response = take(await searchWithExa(query, options), "exa");
17508
+ if (response) return response;
17187
17509
  } catch (err) {
17188
17510
  if (err instanceof CredentialResolutionError || isAbortError2(err)) throw err;
17189
17511
  fallbackErrors.push(`Exa: ${errorMessage27(err)}`);
17190
17512
  }
17191
17513
  }
17192
17514
  if (allowed.has("openai") && !triedOpenAI) {
17193
- const result = await tryOpenAIInAuto(query, options, fallbackErrors);
17515
+ const result = await tryOpenAIInAuto(query, options, fallbackErrors, take);
17194
17516
  if (result) return result;
17195
17517
  }
17196
- if (allowed.has("brave") && isBraveAvailable()) {
17197
- try {
17198
- const result = await searchWithBrave(query, options);
17199
- return { ...result, provider: "brave" };
17200
- } catch (err) {
17201
- if (isAbortError2(err)) throw err;
17202
- fallbackErrors.push(`Brave: ${errorMessage27(err)}`);
17203
- }
17204
- }
17205
- if (allowed.has("parallel") && isParallelAvailable()) {
17206
- try {
17207
- const result = await searchWithParallel(query, options);
17208
- return { ...result, provider: "parallel" };
17209
- } catch (err) {
17210
- if (isAbortError2(err)) throw err;
17211
- fallbackErrors.push(`Parallel: ${errorMessage27(err)}`);
17212
- }
17213
- }
17214
- if (allowed.has("tinyfish") && isTinyFishAvailable()) {
17215
- try {
17216
- const result = await searchWithTinyFish(query, options);
17217
- return { ...result, provider: "tinyfish" };
17218
- } catch (err) {
17219
- if (isAbortError2(err)) throw err;
17220
- fallbackErrors.push(`TinyFish: ${errorMessage27(err)}`);
17221
- }
17222
- }
17223
- if (allowed.has("search1api") && isSearch1APIAvailable()) {
17224
- try {
17225
- const result = await searchWithSearch1API(query, options);
17226
- return { ...result, provider: "search1api" };
17227
- } catch (err) {
17228
- if (isAbortError2(err)) throw err;
17229
- fallbackErrors.push(`Search1API: ${errorMessage27(err)}`);
17230
- }
17231
- }
17232
- if (allowed.has("searchinfinity") && isSearchinfinityAvailable()) {
17233
- try {
17234
- const result = await searchWithSearchinfinity(query, options);
17235
- return { ...result, provider: "searchinfinity" };
17236
- } catch (err) {
17237
- if (isAbortError2(err)) throw err;
17238
- fallbackErrors.push(`Searchinfinity: ${errorMessage27(err)}`);
17239
- }
17240
- }
17241
- if (allowed.has("querit") && isQueritAvailable()) {
17242
- try {
17243
- const result = await searchWithQuerit(query, options);
17244
- return { ...result, provider: "querit" };
17245
- } catch (err) {
17246
- if (isAbortError2(err)) throw err;
17247
- fallbackErrors.push(`Querit: ${errorMessage27(err)}`);
17248
- }
17249
- }
17250
- if (allowed.has("tavily") && isTavilyAvailable()) {
17251
- try {
17252
- const result = await searchWithTavily(query, options);
17253
- return { ...result, provider: "tavily" };
17254
- } catch (err) {
17255
- if (isAbortError2(err)) throw err;
17256
- fallbackErrors.push(`Tavily: ${errorMessage27(err)}`);
17257
- }
17258
- }
17259
- if (allowed.has("firecrawl") && isFirecrawlAvailable()) {
17260
- try {
17261
- const result = await searchWithFirecrawl(query, options);
17262
- return { ...result, provider: "firecrawl" };
17263
- } catch (err) {
17264
- if (isAbortError2(err)) throw err;
17265
- fallbackErrors.push(`Firecrawl: ${errorMessage27(err)}`);
17266
- }
17267
- }
17268
- if (allowed.has("jina") && isJinaSearchAvailable()) {
17269
- try {
17270
- const result = await searchWithJina(query, options);
17271
- return { ...result, provider: "jina" };
17272
- } catch (err) {
17273
- if (isAbortError2(err)) throw err;
17274
- fallbackErrors.push(`Jina: ${errorMessage27(err)}`);
17275
- }
17276
- }
17277
- if (allowed.has("serpdive") && isSerpdiveAvailable()) {
17278
- try {
17279
- const result = await searchWithSerpdive(query, options);
17280
- return { ...result, provider: "serpdive" };
17281
- } catch (err) {
17282
- if (isAbortError2(err)) throw err;
17283
- fallbackErrors.push(`SERPdive: ${errorMessage27(err)}`);
17284
- }
17285
- }
17286
- if (allowed.has("kagi") && isKagiAvailable()) {
17287
- try {
17288
- const result = await searchWithKagi(query, options);
17289
- return { ...result, provider: "kagi" };
17290
- } catch (err) {
17291
- if (isAbortError2(err)) throw err;
17292
- fallbackErrors.push(`Kagi: ${errorMessage27(err)}`);
17293
- }
17294
- }
17295
- if (allowed.has("bocha") && isBochaAvailable()) {
17296
- try {
17297
- const result = await searchWithBocha(query, options);
17298
- return { ...result, provider: "bocha" };
17299
- } catch (err) {
17300
- if (isAbortError2(err)) throw err;
17301
- fallbackErrors.push(`Bocha: ${errorMessage27(err)}`);
17302
- }
17303
- }
17304
- if (allowed.has("ollama") && isOllamaAvailable()) {
17305
- try {
17306
- const result = await searchWithOllama(query, options);
17307
- return { ...result, provider: "ollama" };
17308
- } catch (err) {
17309
- if (isAbortError2(err)) throw err;
17310
- fallbackErrors.push(`Ollama: ${errorMessage27(err)}`);
17311
- }
17312
- }
17313
- if (allowed.has("perplexity") && isPerplexityAvailable()) {
17314
- try {
17315
- const result = await searchWithPerplexity(query, options);
17316
- return { ...result, provider: "perplexity" };
17317
- } catch (err) {
17318
- if (isAbortError2(err)) throw err;
17319
- fallbackErrors.push(`Perplexity: ${errorMessage27(err)}`);
17320
- }
17518
+ for (const provider2 of ["brave", "parallel", "tinyfish", "search1api", "searchinfinity", "querit", "tavily", "firecrawl", "jina", "serpdive", "kagi", "bocha", "ollama", "perplexity"]) {
17519
+ const response = await attempt(provider2);
17520
+ if (response) return response;
17321
17521
  }
17322
17522
  if (allowed.has("gemini")) try {
17323
- const geminiResult = await searchWithGemini(query, options, false);
17324
- if (geminiResult) return { ...geminiResult, provider: "gemini" };
17523
+ const response = take(await searchWithGemini(query, options, false), "gemini");
17524
+ if (response) return response;
17325
17525
  } catch (err) {
17326
17526
  if (isAbortError2(err)) throw err;
17327
17527
  fallbackErrors.push(`Gemini: ${errorMessage27(err)}`);
17328
17528
  }
17529
+ if (firstEmpty) return firstEmpty;
17329
17530
  if (fallbackErrors.length > 0) {
17330
17531
  throw new Error(`Auto provider search failed:
17331
17532
  - ${fallbackErrors.join("\n - ")}`);
@@ -22175,9 +22376,17 @@ Error: ${result.error}`;
22175
22376
  return lines.join("\n");
22176
22377
  }
22177
22378
  lines.push("Sources:");
22379
+ const [perSource, perQuery] = result.answer?.trim() ? [200, 3e3] : [600, 12e3];
22380
+ let budgetLeft = perQuery;
22178
22381
  for (let i = 0; i < result.results.length; i++) {
22179
22382
  const source = result.results[i];
22180
22383
  lines.push(`${i + 1}. ${source.title} \u2014 ${source.url}`);
22384
+ const text4 = (source.snippet ?? "").replace(/\s+/g, " ").trim();
22385
+ const limit = Math.min(perSource, budgetLeft);
22386
+ if (!text4 || limit <= 0) continue;
22387
+ const snippet = text4.length <= limit ? text4 : `${text4.slice(0, limit - 1)}\u2026`;
22388
+ budgetLeft -= snippet.length;
22389
+ lines.push(` ${snippet}`);
22181
22390
  }
22182
22391
  return lines.join("\n");
22183
22392
  }
@@ -22499,7 +22708,7 @@ import { randomUUID as randomUUID3 } from "node:crypto";
22499
22708
  import { execFileSync as execFileSync3, spawn as spawn3 } from "node:child_process";
22500
22709
  import { createRequire } from "node:module";
22501
22710
  import { platform } from "node:os";
22502
- import { existsSync as existsSync54, readFileSync as readFileSync56, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "node:fs";
22711
+ import { existsSync as existsSync55, readFileSync as readFileSync57, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "node:fs";
22503
22712
  import { join as join8 } from "node:path";
22504
22713
  init_gemini_api();
22505
22714
  init_gemini_web();
@@ -22522,6 +22731,7 @@ function parseStringifiedArrays(args, keys) {
22522
22731
  output[key] = parsed;
22523
22732
  }
22524
22733
  } catch {
22734
+ throw new Error(`${key} must be an array of strings; the given value is not valid JSON`);
22525
22735
  }
22526
22736
  }
22527
22737
  return output ?? args;
@@ -22775,7 +22985,7 @@ function registerWebToolActivation(pi, tools, mode) {
22775
22985
  }
22776
22986
 
22777
22987
  // web-tool-core.ts
22778
- import { existsSync as existsSync53, readFileSync as readFileSync55 } from "node:fs";
22988
+ import { existsSync as existsSync54, readFileSync as readFileSync56 } from "node:fs";
22779
22989
  import pLimit2 from "p-limit";
22780
22990
  init_auth_fetch();
22781
22991
 
@@ -22944,7 +23154,7 @@ function findContent(text4, queries, mode) {
22944
23154
  if (contained.length === 0) continue;
22945
23155
  const prefix = range.start > 0 ? "\u2026" : "";
22946
23156
  const suffix = range.end < text4.length ? "\u2026" : "";
22947
- const snippet = `${prefix}${text4.slice(range.start, range.end).replace(/\s+/g, " ").trim()}${suffix}`;
23157
+ const snippet = `${prefix}${text4.slice(range.start, range.end).replace(/[\uD800-\uDFFF]/gu, "\uFFFD").replace(/\s+/g, " ").trim()}${suffix}`;
22948
23158
  const counts = contained.map((result) => `${overflow ? result.id : `"${result.query}"`} \xD7${result.count}`).join(", ");
22949
23159
  sections.push(`${index + 1}. ${counts}
22950
23160
  ${snippet}`);
@@ -23172,8 +23382,8 @@ function parseConfigRoot(raw) {
23172
23382
  return parsed;
23173
23383
  }
23174
23384
  function loadConfig40() {
23175
- if (!existsSync53(WEB_SEARCH_CONFIG_PATH4)) return {};
23176
- return parseConfigRoot(readFileSync55(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
23385
+ if (!existsSync54(WEB_SEARCH_CONFIG_PATH4)) return {};
23386
+ return parseConfigRoot(readFileSync56(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
23177
23387
  }
23178
23388
  var DEFAULT_TOOL_NAMES = {
23179
23389
  webSearch: "web_search",
@@ -23318,7 +23528,7 @@ function fetchStructuredContent(responseId, results) {
23318
23528
  };
23319
23529
  }
23320
23530
  function initialContentSlice(content, maxChars) {
23321
- let endOffset = Math.min(content.length, maxChars);
23531
+ let endOffset = pageEnd(content, 0, Math.min(content.length, maxChars));
23322
23532
  if (endOffset < content.length) {
23323
23533
  const lineBreak = content.lastIndexOf("\n", endOffset);
23324
23534
  if (lineBreak >= Math.floor(maxChars * 0.8)) endOffset = lineBreak + 1;
@@ -23471,7 +23681,8 @@ function boundSearchPresentation(text4, guidance, truncationGuidance, maxChars)
23471
23681
  function registeredFetchToolNames(settings) {
23472
23682
  return {
23473
23683
  ...settings.enabledTools.webSearch ? { webSearch: settings.toolNames.webSearch } : {},
23474
- ...settings.enabledTools.fetchContent ? { fetchContent: settings.toolNames.fetchContent } : {}
23684
+ ...settings.enabledTools.fetchContent ? { fetchContent: settings.toolNames.fetchContent } : {},
23685
+ ...settings.enabledTools.getSearchContent ? { getSearchContent: settings.toolNames.getSearchContent } : {}
23475
23686
  };
23476
23687
  }
23477
23688
  function storedContentSourceNames(settings) {
@@ -23481,14 +23692,21 @@ function storedContentSourceNames(settings) {
23481
23692
  ...settings.enabledTools.fetchContent ? [settings.toolNames.fetchContent] : []
23482
23693
  ]);
23483
23694
  }
23695
+ function pageEnd(content, offset, end) {
23696
+ if (end <= offset || end >= content.length) return end;
23697
+ const high = content.charCodeAt(end - 1);
23698
+ const low = content.charCodeAt(end);
23699
+ if (high < 55296 || high > 56319 || low < 56320 || low > 57343) return end;
23700
+ return end - 1 > offset ? end - 1 : end + 1;
23701
+ }
23484
23702
  function sliceWithContinuation(content, offset, limit, maxChars, continuationAt) {
23485
- let endOffset = offset + Math.min(limit, content.length - offset);
23703
+ let endOffset = pageEnd(content, offset, offset + Math.min(limit, content.length - offset));
23486
23704
  let continuation = "";
23487
23705
  while (endOffset < content.length) {
23488
23706
  continuation = continuationAt(endOffset);
23489
23707
  const overflow = endOffset - offset + continuation.length - maxChars;
23490
23708
  if (overflow <= 0) break;
23491
- endOffset -= overflow;
23709
+ endOffset = pageEnd(content, offset, endOffset - overflow);
23492
23710
  }
23493
23711
  return { endOffset, text: content.slice(offset, endOffset) + (endOffset < content.length ? continuation : "") };
23494
23712
  }
@@ -23592,8 +23810,12 @@ Full search results are stored as responseId "${searchId}". `;
23592
23810
  return value;
23593
23811
  };
23594
23812
  const presentation = hasApprovedSummary ? { text: unboundedPresentation, truncated: false, originalChars: unboundedPresentation.length, returnedChars: unboundedPresentation.length, omittedChars: 0 } : boundSearchPresentation(unboundedPresentation, buildGuidance(false), buildGuidance(true), maxInlineContentChars);
23813
+ const summaryGuidance = hasApprovedSummary ? buildGuidance(false) : "";
23595
23814
  return {
23596
- content: [{ type: "text", text: presentation.text }],
23815
+ content: [
23816
+ { type: "text", text: presentation.text },
23817
+ ...summaryGuidance ? [{ type: "text", text: summaryGuidance }] : []
23818
+ ],
23597
23819
  structuredContent: searchStructuredContent(searchId, fetchId, opts.results),
23598
23820
  details: {
23599
23821
  queries: opts.queryList,
@@ -23858,7 +24080,7 @@ Full search results are stored as responseId "${searchId}". `;
23858
24080
  const fetchResults = await fetchAllContent2(urlList, signal, fetchOptions(requestOptions, options.proxy));
23859
24081
  const presentedResults = mode === "answer" ? await Promise.all(fetchResults.map(async (result) => {
23860
24082
  if (result.error) return result;
23861
- if (result.thumbnail || result.mimeType?.startsWith("image/")) {
24083
+ if (result.mimeType?.startsWith("image/") || result.frames?.length) {
23862
24084
  return { ...result, error: "Page answer requires textual fetched content" };
23863
24085
  }
23864
24086
  try {
@@ -23904,7 +24126,8 @@ Full search results are stored as responseId "${searchId}". `;
23904
24126
 
23905
24127
  ---
23906
24128
  Showing ${slice.endOffset} of ${fullLength} chars, ${slice.shownBytes} of ${slice.totalBytes} bytes, and ${slice.shownLines} of ${slice.totalLines} lines. `;
23907
- 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.";
24129
+ if (mode === "answer") output2 += "Stored content is the original source, not the remaining answer. ";
24130
+ output2 += storedContent ? getSearchContentEnabled ? mode === "answer" ? `Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0, offset: 0 }) to read the original source from the beginning.` : `Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0, offset: ${slice.endOffset} }) for the next slice.` : "Content retrieval is not registered." : "Authenticated fetch cache is off; repeat the fetch to read more.";
23908
24131
  }
23909
24132
  const content = [];
23910
24133
  if (result.frames?.length) {
@@ -23916,6 +24139,15 @@ Showing ${slice.endOffset} of ${fullLength} chars, ${slice.shownBytes} of ${slic
23916
24139
  content.push({ type: "image", data: result.thumbnail.data, mimeType: result.thumbnail.mimeType });
23917
24140
  }
23918
24141
  content.push({ type: "text", text: output2 });
24142
+ if (!truncated && storedContent && getSearchContentEnabled) {
24143
+ const storedLabel = mode === "answer" ? "Original source content" : "Full content";
24144
+ content.push({
24145
+ type: "text",
24146
+ text: `
24147
+ ---
24148
+ ${storedLabel} is stored as responseId "${responseId}". Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0, offset: 0 }) to retrieve it.`
24149
+ });
24150
+ }
23919
24151
  const imageCount = (result.frames?.length ?? 0) + (result.thumbnail ? 1 : 0);
23920
24152
  return {
23921
24153
  content,
@@ -23944,19 +24176,33 @@ Showing ${slice.endOffset} of ${fullLength} chars, ${slice.shownBytes} of ${slic
23944
24176
  }
23945
24177
  };
23946
24178
  }
23947
- let output = "## Fetched URLs\n\n";
24179
+ let budget = mode === "answer" ? getMaxInlineContentChars() : 0;
24180
+ let output = mode === "answer" ? "## Page answers\n" : "## Fetched URLs\n\n";
23948
24181
  for (const { url, title, content, error } of presentedResults) {
23949
- if (error) {
23950
- output += `- ${url}: Error - ${error}
24182
+ if (mode !== "answer") {
24183
+ output += error ? `- ${url}: Error - ${error}
24184
+ ` : `- ${title || url} (${content.length} chars)
24185
+ `;
24186
+ } else if (error) {
24187
+ output += `
24188
+ ### ${url}
24189
+ Error: ${error}
23951
24190
  `;
23952
24191
  } else {
23953
- output += `- ${title || url} (${content.length} chars)
24192
+ const shown = content.slice(0, budget);
24193
+ budget -= shown.length;
24194
+ const marker = shown.length === content.length ? "" : `
24195
+ [answer ${shown.length ? "truncated at the output limit;" : "omitted; earlier answers used the output limit,"} fetch fewer URLs per call for complete answers]`;
24196
+ output += `
24197
+ ### ${title || url}
24198
+ ${shown}${marker}
23954
24199
  `;
23955
24200
  }
23956
24201
  }
24202
+ const retrievalHint = mode === "answer" ? `Stored content is the original source pages, not the answers. Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0, offset: 0 }) to read the first source; urlIndex follows the order above.` : `Use ${toolNames.getSearchContent}({ responseId: "${responseId}", urlIndex: 0 }) to retrieve bounded content slices.`;
23957
24203
  output += storedContent ? getSearchContentEnabled ? `
23958
24204
  ---
23959
- 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.";
24205
+ ${retrievalHint}` : "\n---\nContent retrieval is not registered." : "\n---\nAuthenticated fetch cache is off; repeat the fetch to read content.";
23960
24206
  return {
23961
24207
  ...successful === 0 ? { isError: true } : {},
23962
24208
  content: [{ type: "text", text: output }],
@@ -24210,7 +24456,7 @@ ${text5}` }],
24210
24456
  details: { error: "Offset out of range", offset, contentLength: urlData.content.length }
24211
24457
  };
24212
24458
  }
24213
- const endOffset = Math.min(offset + limit, urlData.content.length);
24459
+ const endOffset = pageEnd(urlData.content, offset, Math.min(offset + limit, urlData.content.length));
24214
24460
  const contentSlice = urlData.content.slice(offset, endOffset);
24215
24461
  const hasMore = endOffset < urlData.content.length;
24216
24462
  let text4 = `# ${urlData.title || urlData.url}
@@ -24308,12 +24554,12 @@ function renderSearchErrorPlan(plan, expanded, theme) {
24308
24554
  }
24309
24555
  function saveConfig(updates) {
24310
24556
  let config = {};
24311
- if (existsSync54(WEB_SEARCH_CONFIG_PATH4)) {
24312
- config = parseConfigRoot(readFileSync56(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
24557
+ if (existsSync55(WEB_SEARCH_CONFIG_PATH4)) {
24558
+ config = parseConfigRoot(readFileSync57(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
24313
24559
  }
24314
24560
  Object.assign(config, updates);
24315
24561
  const dir = getWebSearchConfigDir();
24316
- if (!existsSync54(dir)) mkdirSync3(dir, { recursive: true });
24562
+ if (!existsSync55(dir)) mkdirSync3(dir, { recursive: true });
24317
24563
  writeFileSync3(WEB_SEARCH_CONFIG_PATH4, JSON.stringify(config, null, 2) + "\n");
24318
24564
  }
24319
24565
  var TOOL_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
@@ -24599,7 +24845,7 @@ function findGlimpseMjs() {
24599
24845
  try {
24600
24846
  const globalRoot = execFileSync3("npm", ["root", "-g"], { encoding: "utf-8" }).trim();
24601
24847
  const entry = join8(globalRoot, "glimpseui", "src", "glimpse.mjs");
24602
- if (existsSync54(entry)) return entry;
24848
+ if (existsSync55(entry)) return entry;
24603
24849
  } catch {
24604
24850
  }
24605
24851
  return null;
@@ -25841,6 +26087,9 @@ Open manually: ${handle.url}` }],
25841
26087
  })),
25842
26088
  proxy: Type2.Optional(Type2.String({
25843
26089
  description: "http(s) or socks proxy URL (e.g. http://host:port or socks5h://host:port) used for this fetch. Needed when the target is unreachable directly; localhost and NO_PROXY hosts always bypass the proxy. Empty string forces direct access."
26090
+ })),
26091
+ redirects: Type2.Optional(StringEnum(["same-origin"], {
26092
+ description: "Refuse cross-origin redirects: every redirect target must match the requested URL's scheme, hostname and effective port, and extraction paths whose redirect chain cannot be observed are refused instead of used."
25844
26093
  }))
25845
26094
  }),
25846
26095
  outputSchema: fetchContentOutputSchema,