diff --git a/langgraph/src/agent/enterprise/tools/soc-client.ts b/langgraph/src/agent/enterprise/tools/soc-client.ts index 4ea771b..c5110f2 100644 --- a/langgraph/src/agent/enterprise/tools/soc-client.ts +++ b/langgraph/src/agent/enterprise/tools/soc-client.ts @@ -143,6 +143,7 @@ export async function webSearch(query: string): Promise<{ Authorization: `Bearer ${config.jina.apiKey}`, "Content-Type": "application/json", Accept: "application/json", + "X-Timeout": "15", }; // Step 1: Search @@ -231,16 +232,24 @@ export async function googleSearch(query: string): Promise<{ // --- Jina Web Read (single URL full-text) --- export async function webRead(url: string): Promise<{ content: string; title: string }> { - const resp = await fetch(`https://r.jina.ai/${url}`, { - headers: { - Authorization: `Bearer ${config.jina.apiKey}`, - Accept: "application/json", - }, - signal: AbortSignal.timeout(getToolConfig("web_read").timeoutMs), - }); - if (!resp.ok) throw new Error(`Jina read failed: ${resp.status}`); - const data = await resp.json(); - return { content: data.data?.content ?? "", title: data.data?.title ?? "" }; + try { + const resp = await fetch(`https://r.jina.ai/${url}`, { + headers: { + Authorization: `Bearer ${config.jina.apiKey}`, + Accept: "application/json", + "X-Timeout": "15", + "X-Return-Format": "markdown", + }, + signal: AbortSignal.timeout(getToolConfig("web_read").timeoutMs), + }); + if (!resp.ok) throw new Error(`Jina read failed: ${resp.status}`); + const data = await resp.json(); + return { content: data.data?.content ?? "", title: data.data?.title ?? "" }; + } catch (e) { + // 确保抛出的是 Error 实例,不是其他类型 + if (e instanceof Error) throw e; + throw new Error(String(e)); + } } // --- Jina Rerank ---