Skip to content

Commit b962c53

Browse files
committed
refactor(web): trim runtime helper exports
1 parent 4ae94d1 commit b962c53

3 files changed

Lines changed: 6 additions & 72 deletions

File tree

src/web-fetch/runtime.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type WebFetchConfig = NonNullable<OpenClawConfig["tools"]>["web"] extends infer
2929
: undefined
3030
: undefined;
3131

32-
export type ResolveWebFetchDefinitionParams = {
32+
type ResolveWebFetchDefinitionParams = {
3333
config?: OpenClawConfig;
3434
sandboxed?: boolean;
3535
runtimeWebFetch?: RuntimeWebFetchMetadata;
@@ -38,7 +38,7 @@ export type ResolveWebFetchDefinitionParams = {
3838
};
3939

4040
/** Resolves whether web_fetch is enabled for the current config/sandbox. */
41-
export function resolveWebFetchEnabled(params: {
41+
function resolveWebFetchEnabled(params: {
4242
fetch?: WebFetchConfig;
4343
sandboxed?: boolean;
4444
}): boolean {
@@ -102,17 +102,8 @@ export function listWebFetchProviders(params?: {
102102
});
103103
}
104104

105-
/** Lists plugin-configured web_fetch providers. */
106-
export function listConfiguredWebFetchProviders(params?: {
107-
config?: OpenClawConfig;
108-
}): PluginWebFetchProviderEntry[] {
109-
return resolvePluginWebFetchProviders({
110-
config: params?.config,
111-
});
112-
}
113-
114105
/** Resolves the configured or auto-detected web_fetch provider id. */
115-
export function resolveWebFetchProviderId(params: {
106+
function resolveWebFetchProviderId(params: {
116107
fetch?: WebFetchConfig;
117108
config?: OpenClawConfig;
118109
providers?: PluginWebFetchProviderEntry[];

src/web-search/runtime.test.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,13 @@ function createDuckDuckGoSearchProvider(
165165

166166
describe("web search runtime", () => {
167167
let runWebSearch: typeof import("./runtime.js").runWebSearch;
168-
let resolveWebSearchDefinition: typeof import("./runtime.js").resolveWebSearchDefinition;
169168
let activateSecretsRuntimeSnapshot: typeof import("../secrets/runtime.js").activateSecretsRuntimeSnapshot;
170169
let clearSecretsRuntimeSnapshot: typeof import("../secrets/runtime.js").clearSecretsRuntimeSnapshot;
171170
let setRuntimeConfigSnapshot: typeof import("../config/config.js").setRuntimeConfigSnapshot;
172171
const tempDirs: string[] = [];
173172

174173
beforeAll(async () => {
175-
({ resolveWebSearchDefinition, runWebSearch } = await import("./runtime.js"));
174+
({ runWebSearch } = await import("./runtime.js"));
176175
({ activateSecretsRuntimeSnapshot, clearSecretsRuntimeSnapshot } =
177176
await import("../secrets/runtime.js"));
178177
({ setRuntimeConfigSnapshot } = await import("../config/config.js"));
@@ -591,16 +590,6 @@ describe("web search runtime", () => {
591590
).rejects.toThrow("web_search is disabled or no provider is available.");
592591
});
593592

594-
it("does not resolve a keyless provider definition when no provider is configured", () => {
595-
resolvePluginWebSearchProvidersMock.mockReturnValue([createDuckDuckGoSearchProvider()]);
596-
597-
const resolved = resolveWebSearchDefinition({
598-
config: {},
599-
});
600-
601-
expect(resolved).toBeNull();
602-
});
603-
604593
it("uses a keyless provider when the user explicitly selects it", async () => {
605594
resolveRuntimeWebSearchProvidersMock.mockReturnValue([createDuckDuckGoSearchProvider()]);
606595

@@ -774,29 +763,6 @@ describe("web search runtime", () => {
774763
expect(createTool).not.toHaveBeenCalled();
775764
});
776765

777-
it("ignores auto-detected keyless runtime metadata when resolving a provider definition", () => {
778-
resolvePluginWebSearchProvidersMock.mockReturnValue([
779-
createWebSearchTestProvider({
780-
pluginId: "parallel",
781-
id: "parallel-free",
782-
credentialPath: "",
783-
autoDetectOrder: 76,
784-
requiresCredential: false,
785-
}),
786-
]);
787-
788-
const resolved = resolveWebSearchDefinition({
789-
config: {},
790-
runtimeWebSearch: {
791-
providerSource: "auto-detect",
792-
selectedProvider: "parallel-free",
793-
diagnostics: [],
794-
},
795-
});
796-
797-
expect(resolved).toBeNull();
798-
});
799-
800766
it("falls back to another provider when auto-selected search execution fails", async () => {
801767
resolveRuntimeWebSearchProvidersMock.mockReturnValue([
802768
createGoogleSearchProvider({

src/web-search/runtime.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ import type {
3939
RuntimeWebSearchConfig as WebSearchConfig,
4040
} from "./runtime-types.js";
4141

42-
// Runtime provider selection and execution for web_search. This keeps plugin,
43-
// runtime, and explicit provider selections aligned before a tool executes.
44-
export type {
45-
ListWebSearchProvidersParams,
46-
ResolveWebSearchDefinitionParams,
47-
RunWebSearchParams,
48-
RunWebSearchResult,
49-
RuntimeWebSearchConfig,
50-
RuntimeWebSearchProviderEntry,
51-
RuntimeWebSearchToolDefinition,
52-
} from "./runtime-types.js";
53-
5442
function resolveSearchConfig(cfg?: OpenClawConfig): WebSearchConfig {
5543
return resolveWebProviderConfig(cfg, "search") as NonNullable<WebSearchConfig> | undefined;
5644
}
@@ -70,7 +58,7 @@ function resolveWebSearchRuntimeConfig(params?: {
7058
}
7159

7260
/** Resolves whether web_search is enabled for the current config/sandbox. */
73-
export function resolveWebSearchEnabled(params: {
61+
function resolveWebSearchEnabled(params: {
7462
search?: WebSearchConfig;
7563
sandboxed?: boolean;
7664
}): boolean {
@@ -383,7 +371,7 @@ function loadSortedWebSearchProviders(
383371
}
384372

385373
/** Resolves the executable web_search provider tool definition. */
386-
export function resolveWebSearchDefinition(
374+
function resolveWebSearchDefinition(
387375
options?: ResolveWebSearchDefinitionParams,
388376
): { provider: PluginWebSearchProviderEntry; definition: WebSearchProviderToolDefinition } | null {
389377
const { config, search, runtimeWebSearch } = resolveWebSearchRequestContext(options);
@@ -603,14 +591,3 @@ export async function runWebSearch(params: RunWebSearchParams): Promise<RunWebSe
603591
}
604592
throw lastError instanceof Error ? lastError : new Error(String(lastError));
605593
}
606-
607-
export const testing = {
608-
resolveSearchConfig,
609-
resolveSearchProvider: resolveWebSearchProviderId,
610-
resolveWebSearchProviderId,
611-
resolveWebSearchCandidates,
612-
resolveExplicitWebSearchProviderId,
613-
resolveExplicitWebSearchProviderPluginIds,
614-
hasExplicitWebSearchSelection,
615-
};
616-
export { testing as __testing };

0 commit comments

Comments
 (0)