File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Tavily helper module supports config behavior.
22import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts" ;
33import { resolvePositiveTimeoutSeconds } from "openclaw/plugin-sdk/provider-web-search" ;
4- import {
5- normalizeResolvedSecretInputString ,
6- normalizeSecretInput ,
7- } from "openclaw/plugin-sdk/secret-input" ;
4+ import { normalizeSecretInput , resolveSecretInputString } from "openclaw/plugin-sdk/secret-input" ;
85import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime" ;
96
107export const DEFAULT_TAVILY_BASE_URL = "https://api.tavily.com" ;
@@ -35,12 +32,12 @@ export function resolveTavilySearchConfig(cfg?: OpenClawConfig): TavilySearchCon
3532}
3633
3734function normalizeConfiguredSecret ( value : unknown , path : string ) : string | undefined {
38- return normalizeSecretInput (
39- normalizeResolvedSecretInputString ( {
40- value ,
41- path ,
42- } ) ,
43- ) ;
35+ const resolved = resolveSecretInputString ( {
36+ value ,
37+ path ,
38+ mode : "configured_unavailable" ,
39+ } ) ;
40+ return resolved . status === "available" ? normalizeSecretInput ( resolved . value ) : undefined ;
4441}
4542
4643export function resolveTavilyApiKey ( cfg ?: OpenClawConfig ) : string | undefined {
Original file line number Diff line number Diff line change @@ -427,6 +427,30 @@ describe("tavily tools", () => {
427427 expect ( resolveTavilyExtractTimeoutSeconds ( ) ) . toBe ( DEFAULT_TAVILY_EXTRACT_TIMEOUT_SECONDS ) ;
428428 } ) ;
429429
430+ it ( "falls back to process.env when the configured apiKey is an unresolved SecretRef" , ( ) => {
431+ vi . stubEnv ( "TAVILY_API_KEY" , "env-key" ) ;
432+
433+ const cfg = {
434+ plugins : {
435+ entries : {
436+ tavily : {
437+ config : {
438+ webSearch : {
439+ apiKey : {
440+ source : "env" ,
441+ provider : "default" ,
442+ id : "TAVILY_API_KEY" ,
443+ } ,
444+ } ,
445+ } ,
446+ } ,
447+ } ,
448+ } ,
449+ } as OpenClawConfig ;
450+
451+ expect ( resolveTavilyApiKey ( cfg ) ) . toBe ( "env-key" ) ;
452+ } ) ;
453+
430454 it ( "accepts positive numeric timeout overrides and floors them" , ( ) => {
431455 expect ( resolveTavilySearchTimeoutSeconds ( 19.9 ) ) . toBe ( 19 ) ;
432456 expect ( resolveTavilyExtractTimeoutSeconds ( 42.7 ) ) . toBe ( 42 ) ;
You can’t perform that action at this time.
0 commit comments