From b962c53e785c4139ebe2ecc0f40ddebc2c256e86 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 17 Jun 2026 16:53:46 +0800 Subject: [PATCH] refactor(web): trim runtime helper exports --- src/web-fetch/runtime.ts | 15 +++----------- src/web-search/runtime.test.ts | 36 +--------------------------------- src/web-search/runtime.ts | 27 ++----------------------- 3 files changed, 6 insertions(+), 72 deletions(-) diff --git a/src/web-fetch/runtime.ts b/src/web-fetch/runtime.ts index 87e157508182..c2f75f2444b5 100644 --- a/src/web-fetch/runtime.ts +++ b/src/web-fetch/runtime.ts @@ -29,7 +29,7 @@ type WebFetchConfig = NonNullable["web"] extends infer : undefined : undefined; -export type ResolveWebFetchDefinitionParams = { +type ResolveWebFetchDefinitionParams = { config?: OpenClawConfig; sandboxed?: boolean; runtimeWebFetch?: RuntimeWebFetchMetadata; @@ -38,7 +38,7 @@ export type ResolveWebFetchDefinitionParams = { }; /** Resolves whether web_fetch is enabled for the current config/sandbox. */ -export function resolveWebFetchEnabled(params: { +function resolveWebFetchEnabled(params: { fetch?: WebFetchConfig; sandboxed?: boolean; }): boolean { @@ -102,17 +102,8 @@ export function listWebFetchProviders(params?: { }); } -/** Lists plugin-configured web_fetch providers. */ -export function listConfiguredWebFetchProviders(params?: { - config?: OpenClawConfig; -}): PluginWebFetchProviderEntry[] { - return resolvePluginWebFetchProviders({ - config: params?.config, - }); -} - /** Resolves the configured or auto-detected web_fetch provider id. */ -export function resolveWebFetchProviderId(params: { +function resolveWebFetchProviderId(params: { fetch?: WebFetchConfig; config?: OpenClawConfig; providers?: PluginWebFetchProviderEntry[]; diff --git a/src/web-search/runtime.test.ts b/src/web-search/runtime.test.ts index 25991b7d7342..5a9dc5c1bad5 100644 --- a/src/web-search/runtime.test.ts +++ b/src/web-search/runtime.test.ts @@ -165,14 +165,13 @@ function createDuckDuckGoSearchProvider( describe("web search runtime", () => { let runWebSearch: typeof import("./runtime.js").runWebSearch; - let resolveWebSearchDefinition: typeof import("./runtime.js").resolveWebSearchDefinition; let activateSecretsRuntimeSnapshot: typeof import("../secrets/runtime.js").activateSecretsRuntimeSnapshot; let clearSecretsRuntimeSnapshot: typeof import("../secrets/runtime.js").clearSecretsRuntimeSnapshot; let setRuntimeConfigSnapshot: typeof import("../config/config.js").setRuntimeConfigSnapshot; const tempDirs: string[] = []; beforeAll(async () => { - ({ resolveWebSearchDefinition, runWebSearch } = await import("./runtime.js")); + ({ runWebSearch } = await import("./runtime.js")); ({ activateSecretsRuntimeSnapshot, clearSecretsRuntimeSnapshot } = await import("../secrets/runtime.js")); ({ setRuntimeConfigSnapshot } = await import("../config/config.js")); @@ -591,16 +590,6 @@ describe("web search runtime", () => { ).rejects.toThrow("web_search is disabled or no provider is available."); }); - it("does not resolve a keyless provider definition when no provider is configured", () => { - resolvePluginWebSearchProvidersMock.mockReturnValue([createDuckDuckGoSearchProvider()]); - - const resolved = resolveWebSearchDefinition({ - config: {}, - }); - - expect(resolved).toBeNull(); - }); - it("uses a keyless provider when the user explicitly selects it", async () => { resolveRuntimeWebSearchProvidersMock.mockReturnValue([createDuckDuckGoSearchProvider()]); @@ -774,29 +763,6 @@ describe("web search runtime", () => { expect(createTool).not.toHaveBeenCalled(); }); - it("ignores auto-detected keyless runtime metadata when resolving a provider definition", () => { - resolvePluginWebSearchProvidersMock.mockReturnValue([ - createWebSearchTestProvider({ - pluginId: "parallel", - id: "parallel-free", - credentialPath: "", - autoDetectOrder: 76, - requiresCredential: false, - }), - ]); - - const resolved = resolveWebSearchDefinition({ - config: {}, - runtimeWebSearch: { - providerSource: "auto-detect", - selectedProvider: "parallel-free", - diagnostics: [], - }, - }); - - expect(resolved).toBeNull(); - }); - it("falls back to another provider when auto-selected search execution fails", async () => { resolveRuntimeWebSearchProvidersMock.mockReturnValue([ createGoogleSearchProvider({ diff --git a/src/web-search/runtime.ts b/src/web-search/runtime.ts index 0395a2feb151..482891762d4f 100644 --- a/src/web-search/runtime.ts +++ b/src/web-search/runtime.ts @@ -39,18 +39,6 @@ import type { RuntimeWebSearchConfig as WebSearchConfig, } from "./runtime-types.js"; -// Runtime provider selection and execution for web_search. This keeps plugin, -// runtime, and explicit provider selections aligned before a tool executes. -export type { - ListWebSearchProvidersParams, - ResolveWebSearchDefinitionParams, - RunWebSearchParams, - RunWebSearchResult, - RuntimeWebSearchConfig, - RuntimeWebSearchProviderEntry, - RuntimeWebSearchToolDefinition, -} from "./runtime-types.js"; - function resolveSearchConfig(cfg?: OpenClawConfig): WebSearchConfig { return resolveWebProviderConfig(cfg, "search") as NonNullable | undefined; } @@ -70,7 +58,7 @@ function resolveWebSearchRuntimeConfig(params?: { } /** Resolves whether web_search is enabled for the current config/sandbox. */ -export function resolveWebSearchEnabled(params: { +function resolveWebSearchEnabled(params: { search?: WebSearchConfig; sandboxed?: boolean; }): boolean { @@ -383,7 +371,7 @@ function loadSortedWebSearchProviders( } /** Resolves the executable web_search provider tool definition. */ -export function resolveWebSearchDefinition( +function resolveWebSearchDefinition( options?: ResolveWebSearchDefinitionParams, ): { provider: PluginWebSearchProviderEntry; definition: WebSearchProviderToolDefinition } | null { const { config, search, runtimeWebSearch } = resolveWebSearchRequestContext(options); @@ -603,14 +591,3 @@ export async function runWebSearch(params: RunWebSearchParams): Promise