refactor(tavily): remove internal export seams (#107540)

This commit is contained in:
Peter Steinberger
2026-07-14 06:17:36 -07:00
committed by GitHub
parent a9316bc65f
commit 3ac26b4593
3 changed files with 7 additions and 19 deletions

View File

@@ -8,8 +8,8 @@ import {
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
export const DEFAULT_TAVILY_BASE_URL = "https://api.tavily.com";
export const DEFAULT_TAVILY_SEARCH_TIMEOUT_SECONDS = 30;
export const DEFAULT_TAVILY_EXTRACT_TIMEOUT_SECONDS = 60;
const DEFAULT_TAVILY_SEARCH_TIMEOUT_SECONDS = 30;
const DEFAULT_TAVILY_EXTRACT_TIMEOUT_SECONDS = 60;
type TavilySearchConfig =
| {
@@ -25,7 +25,7 @@ type PluginEntryConfig = {
};
};
export function resolveTavilySearchConfig(cfg?: OpenClawConfig): TavilySearchConfig {
function resolveTavilySearchConfig(cfg?: OpenClawConfig): TavilySearchConfig {
const pluginConfig = cfg?.plugins?.entries?.tavily?.config as PluginEntryConfig;
const pluginWebSearch = pluginConfig?.webSearch;
if (pluginWebSearch && typeof pluginWebSearch === "object" && !Array.isArray(pluginWebSearch)) {

View File

@@ -5,12 +5,9 @@ import { createTestPluginApi } from "openclaw/plugin-sdk/plugin-test-api";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import {
DEFAULT_TAVILY_BASE_URL,
DEFAULT_TAVILY_EXTRACT_TIMEOUT_SECONDS,
DEFAULT_TAVILY_SEARCH_TIMEOUT_SECONDS,
resolveTavilyApiKey,
resolveTavilyBaseUrl,
resolveTavilyExtractTimeoutSeconds,
resolveTavilySearchConfig,
resolveTavilySearchTimeoutSeconds,
} from "./config.js";
@@ -408,10 +405,6 @@ describe("tavily tools", () => {
},
} as OpenClawConfig;
expect(resolveTavilySearchConfig(cfg)).toEqual({
apiKey: "plugin-key",
baseUrl: "https://plugin.tavily.test",
});
expect(resolveTavilyApiKey(cfg)).toBe("plugin-key");
expect(resolveTavilyBaseUrl(cfg)).toBe("https://plugin.tavily.test");
});
@@ -423,8 +416,8 @@ describe("tavily tools", () => {
expect(resolveTavilyApiKey()).toBe("env-key");
expect(resolveTavilyBaseUrl()).toBe("https://env.tavily.test");
expect(resolveTavilyBaseUrl({} as OpenClawConfig)).not.toBe(DEFAULT_TAVILY_BASE_URL);
expect(resolveTavilySearchTimeoutSeconds()).toBe(DEFAULT_TAVILY_SEARCH_TIMEOUT_SECONDS);
expect(resolveTavilyExtractTimeoutSeconds()).toBe(DEFAULT_TAVILY_EXTRACT_TIMEOUT_SECONDS);
expect(resolveTavilySearchTimeoutSeconds()).toBe(30);
expect(resolveTavilyExtractTimeoutSeconds()).toBe(60);
});
it("accepts positive numeric timeout overrides and floors them", () => {
@@ -432,10 +425,8 @@ describe("tavily tools", () => {
expect(resolveTavilyExtractTimeoutSeconds(42.7)).toBe(42);
expect(resolveTavilySearchTimeoutSeconds(0.5)).toBe(1);
expect(resolveTavilyExtractTimeoutSeconds(0.5)).toBe(1);
expect(resolveTavilySearchTimeoutSeconds(0)).toBe(DEFAULT_TAVILY_SEARCH_TIMEOUT_SECONDS);
expect(resolveTavilyExtractTimeoutSeconds(Number.NaN)).toBe(
DEFAULT_TAVILY_EXTRACT_TIMEOUT_SECONDS,
);
expect(resolveTavilySearchTimeoutSeconds(0)).toBe(30);
expect(resolveTavilyExtractTimeoutSeconds(Number.NaN)).toBe(60);
});
it("appends endpoints to reverse-proxy base urls", () => {

View File

@@ -180,9 +180,6 @@ export const KNIP_UNUSED_EXPORT_BASELINE = [
"extensions/synology-chat/src/channel.ts: createSynologyChatPlugin",
"extensions/synology-chat/src/client.ts: fetchChatUsers (synologyClient)",
"extensions/synology-chat/src/webhook-handler.ts: clearSynologyWebhookRateLimiterStateForTest",
"extensions/tavily/src/config.ts: DEFAULT_TAVILY_EXTRACT_TIMEOUT_SECONDS",
"extensions/tavily/src/config.ts: DEFAULT_TAVILY_SEARCH_TIMEOUT_SECONDS",
"extensions/tavily/src/config.ts: resolveTavilySearchConfig",
"extensions/telegram/src/account-throttler.ts: clearAccountThrottlersForTest",
"extensions/telegram/src/account-throttler.ts: createTelegramAccountThrottler",
"extensions/telegram/src/bot-info-cache.ts: setTelegramBotInfoCacheStoreForTest",