Add siteName.

This commit is contained in:
Bob 2026-01-26 17:28:37 +08:00
parent b4a76884e3
commit ca828ba064

View File

@ -4,6 +4,7 @@ import type { MoltbotConfig } from "../../config/config.js";
import { formatCliCommand } from "../../cli/command-format.js"; import { formatCliCommand } from "../../cli/command-format.js";
import type { AnyAgentTool } from "./common.js"; import type { AnyAgentTool } from "./common.js";
import { jsonResult, readNumberParam, readStringParam } from "./common.js"; import { jsonResult, readNumberParam, readStringParam } from "./common.js";
import { logDebug } from "../../logger.js";
import { import {
CacheEntry, CacheEntry,
DEFAULT_CACHE_TTL_MINUTES, DEFAULT_CACHE_TTL_MINUTES,
@ -108,6 +109,7 @@ type QueritSearchResult = {
title?: string; title?: string;
url?: string; url?: string;
snippet?: string; snippet?: string;
site_name?: string;
}; };
type QueritSearchResponse = { type QueritSearchResponse = {
@ -343,7 +345,7 @@ async function runQueritSearch(params: {
query: string; query: string;
apiKey: string; apiKey: string;
timeoutSeconds: number; timeoutSeconds: number;
}): Promise<Array<{ title: string; url: string; snippet: string }>> { }): Promise<Array<{ title: string; url: string; snippet: string; siteName: string }>> {
const res = await fetch(QUERIT_SEARCH_ENDPOINT, { const res = await fetch(QUERIT_SEARCH_ENDPOINT, {
method: "POST", method: "POST",
headers: { headers: {
@ -373,6 +375,7 @@ async function runQueritSearch(params: {
title: entry.title ?? "", title: entry.title ?? "",
url: entry.url ?? "", url: entry.url ?? "",
snippet: entry.snippet ?? "", snippet: entry.snippet ?? "",
siteName: entry.site_name ?? resolveSiteName(entry.url) ?? "",
})); }));
} }
@ -432,7 +435,7 @@ async function runWebSearch(params: {
title: entry.title, title: entry.title,
url: entry.url, url: entry.url,
description: entry.snippet, description: entry.snippet,
siteName: resolveSiteName(entry.url), siteName: entry.siteName,
})); }));
const payload = { const payload = {