fix: add Jina X-Timeout header + ensure webRead always throws Error instances
Trigger auto deployment for soc-langgraph / build-and-deploy (push) Failing after 28s
Deploy LangGraph UI to Azure Static Web Apps / build-and-deploy (push) Failing after 36s

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gongzhiyong
2026-04-13 00:49:58 +08:00
co-authored by Claude Opus 4.6
parent 51bf279ac6
commit bd7f227b11
@@ -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 }> {
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 ---