import { webSearchTransport } from './web-search.js'; import type { HostContext } from './types.js'; /** * 网页读取传输层:默认委托给搜索的 Chrome 指纹传输(同一底层实现)。 * 独立导出对象而非直接用 webSearchTransport:verify 注入 mock 时替换本对象 * 的 request 属性,不会与搜索回归的 mock 恢复顺序互相踩踏。 */ export declare const webFetchTransport: { request: (request: Parameters[0]) => Promise; }; /** 本 provider 在官方 web seam 注册表中的 id。 */ export declare const ZH_WEB_FETCH_PROVIDER_ID = "dsh-zh-web-fetch"; /** * 目标 URL 闸门:仅 http(s)、拒绝 URL 内嵌凭据(user:pass@)与本机/私网 * 地址字面量(localhost、127/8、10/8、172.16/12、192.168/16、169.254/16、 * ::1、fc00::/7、fe80::/10、0.0.0.0)。转发到免 Key 端点前先挡掉明显不该 * 出网的地址;完整 DNS rebinding 防护不在本层(与智谱 http-fallback 同边界)。 */ export declare function isFetchableUrl(rawUrl: string): boolean; /** * 从 MCP 响应体剥出 text 载荷:JSON body(Parallel)或 SSE `data: {...}` 行 * (Exa)。与 Hermes _parse_mcp_body 同语义:JSON-RPC error 与 isError 结果 * 都抛错;SSE 分割只认 CRLF/CR/LF(splitlines 会把 U+2028 等 CJK 正文里的 * 合法字符当换行,切断 data: 行)。 */ export declare function parseMcpText(body: string): string; export interface FreeFetchOutcome { url: string; title: string; content: string; } /** 清空限流记忆与(测试钩子)。 */ export declare function resetWebFetchEngineState(): void; export interface WebFetchFallbackRecord { at: string; code: string; message: string; /** 触发降级的 URL(主机名部分)。 */ host: string; } export interface WebFetchFallbackState { total: number; last: WebFetchFallbackRecord | undefined; } /** 读取降级运行态(诊断用;绝不影响读取)。 */ export declare function getWebFetchFallbackState(): WebFetchFallbackState; export interface WebFetchInstallDeps { /** 读取 zhWebFetch 开关(dsh-zh 命名空间,默认 true)。 */ isEnabled(): boolean; /** 读取读取后端优先级列表(有序 provider id,空数组 = 不接管)。 */ fetchOrder(): readonly string[]; } export interface WebFetchSelectionRecord { at: string; target: string; channel: 'settings' | 'legacy-field' | 'volatile' | 'none'; outcome: 'pending' | 'ok' | 'error'; error?: string; before: string | null; /** 记录到的接管前原值(null/缺省 = 未知,卸载时走清空/回落)。 */ original?: string | null; } /** 读取最近一次 fetch 选路写入结果(诊断用)。 */ export declare function getWebFetchSelectionState(): WebFetchSelectionRecord | undefined; /** * 把官方 web_fetch 的后端选择切到本插件复合 provider(active=true), * 或恢复为接管前的值(active=false)。语义与 applyWebSearchSelection 一致。 * @returns 本次调用后后端选择是否指向本插件的 provider。 */ export declare function applyWebFetchSelection(ctx: HostContext, active: boolean, order?: readonly string[]): boolean; /** * 注册组合读取 provider。可用性(同步、不发网络请求):开关开启且优先级列表非空。 * @returns 卸载函数;web 服务缺失时返回 undefined。 */ export declare function installWebFetchProvider(ctx: HostContext, deps: WebFetchInstallDeps): (() => void) | undefined; //# sourceMappingURL=web-fetch.d.ts.map