feat(tavily): add X-Client-Source attribution header

Add optional extraHeaders param to postTrustedWebToolsJson and use it
to send X-Client-Source: openclaw on all Tavily API requests (search
and extract), matching the Tavily Python SDK's client_source mechanism.
This commit is contained in:
Lakshya Agarwal 2026-03-20 12:44:21 -04:00
parent aa78a0c00e
commit 28b748f74d
2 changed files with 4 additions and 0 deletions

View File

@ -119,6 +119,7 @@ export async function runTavilySearch(
apiKey,
body,
errorLabel: "Tavily Search",
extraHeaders: { "X-Client-Source": "openclaw" },
},
async (response) => (await response.json()) as Record<string, unknown>,
);
@ -200,6 +201,7 @@ export async function runTavilyExtract(
apiKey,
body,
errorLabel: "Tavily Extract",
extraHeaders: { "X-Client-Source": "openclaw" },
},
async (response) => (await response.json()) as Record<string, unknown>,
);

View File

@ -100,6 +100,7 @@ export async function postTrustedWebToolsJson<T>(
body: Record<string, unknown>;
errorLabel: string;
maxErrorBytes?: number;
extraHeaders?: Record<string, string>;
},
parseResponse: (response: Response) => Promise<T>,
): Promise<T> {
@ -110,6 +111,7 @@ export async function postTrustedWebToolsJson<T>(
init: {
method: "POST",
headers: {
...params.extraHeaders,
Accept: "application/json",
Authorization: `Bearer ${params.apiKey}`,
"Content-Type": "application/json",