Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10,038 changes: 10,038 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@phosphor-icons/react": "^2.1.10",
"@radix-ui/react-tooltip": "^1.2.8",
"@tailwindcss/typography": "^0.5.12",
"@tavily/core": "^0.6.4",
"@toolsycc/json-repair": "^0.1.22",
"axios": "^1.8.3",
"better-sqlite3": "^11.9.1",
Expand Down
9 changes: 8 additions & 1 deletion src/lib/agents/search/researcher/actions/webSearch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import z from 'zod';
import { ResearchAction } from '../../types';
import { searchSearxng } from '@/lib/searxng';
import { searchTavily } from '@/lib/tavily';
import { getSearchProvider } from '@/lib/config/serverRegistry';
import { Chunk, SearchResultsResearchBlock } from '@/lib/types';

const actionSchema = z.object({
Expand Down Expand Up @@ -114,8 +116,13 @@ const webSearchAction: ResearchAction<typeof actionSchema> = {

let results: Chunk[] = [];

const searchProvider = getSearchProvider();

const search = async (q: string) => {
const res = await searchSearxng(q);
const res =
searchProvider === 'tavily'
? await searchTavily(q)
: await searchSearxng(q);

const resultChunks: Chunk[] = res.results.map((r) => ({
content: r.content || r.title,
Expand Down
33 changes: 33 additions & 0 deletions src/lib/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class ConfigManager {
modelProviders: [],
search: {
searxngURL: '',
tavilyAPIKey: '',
searchProvider: 'searxng',
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: SEARCH_PROVIDER is effectively ignored because searchProvider is initialized with a truthy default, preventing env-based initialization.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/config/index.ts, line 22:

<comment>`SEARCH_PROVIDER` is effectively ignored because `searchProvider` is initialized with a truthy default, preventing env-based initialization.</comment>

<file context>
@@ -18,6 +18,8 @@ class ConfigManager {
     search: {
       searxngURL: '',
+      tavilyAPIKey: '',
+      searchProvider: 'searxng',
     },
   };
</file context>
Suggested change
searchProvider: 'searxng',
searchProvider: '',
Fix with Cubic

},
};
uiConfigSections: UIConfigSections = {
Expand Down Expand Up @@ -102,6 +104,26 @@ class ConfigManager {
],
modelProviders: [],
search: [
{
name: 'Search Provider',
key: 'searchProvider',
type: 'select',
options: [
{
name: 'SearXNG',
value: 'searxng',
},
{
name: 'Tavily',
value: 'tavily',
},
],
required: false,
description: 'Select the web search provider to use.',
default: 'searxng',
scope: 'server',
env: 'SEARCH_PROVIDER',
},
{
name: 'SearXNG URL',
key: 'searxngURL',
Expand All @@ -113,6 +135,17 @@ class ConfigManager {
scope: 'server',
env: 'SEARXNG_API_URL',
},
{
name: 'Tavily API Key',
key: 'tavilyAPIKey',
type: 'password',
required: false,
description: 'API key for Tavily search (required when search provider is Tavily)',
placeholder: 'tvly-...',
default: '',
scope: 'server',
env: 'TAVILY_API_KEY',
},
],
};

Expand Down
6 changes: 6 additions & 0 deletions src/lib/config/serverRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ export const getConfiguredModelProviderById = (

export const getSearxngURL = () =>
configManager.getConfig('search.searxngURL', '');

export const getTavilyAPIKey = (): string =>
configManager.getConfig('search.tavilyAPIKey', '');

export const getSearchProvider = (): 'searxng' | 'tavily' =>
configManager.getConfig('search.searchProvider', 'searxng');
36 changes: 36 additions & 0 deletions src/lib/tavily.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { tavily } from '@tavily/core';
import { getTavilyAPIKey } from './config/serverRegistry';

interface TavilySearchResult {
title: string;
url: string;
content?: string;
}

export const searchTavily = async (query: string) => {
const apiKey = getTavilyAPIKey();

if (!apiKey) {
throw new Error(
'Tavily API key is not configured. Please set TAVILY_API_KEY.',
);
}

const client = tavily({ apiKey });

const response = await client.search(query, {
maxResults: 10,
searchDepth: 'basic',
topic: 'general',
});

const results: TavilySearchResult[] = (response.results || []).map((r) => ({
title: r.title,
url: r.url,
content: r.content,
}));

const suggestions: string[] = [];

return { results, suggestions };
};
1 change: 1 addition & 0 deletions tsconfig.tsbuildinfo

Large diffs are not rendered by default.

Loading