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