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
13 changes: 10 additions & 3 deletions src/server/parallel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ export interface WebConfig {
parallelApiKey?: string;
}
export function webSearchProvider(value?: string): WebSearchProvider {
if (!value) return 'parallel';
if (value === 'parallel' || value === 'browser' || value === 'disabled')
return value;
// Tolerate surrounding whitespace from .env files, matching the other
// environment parsers; a blank value falls back to the default.
const normalized = value?.trim();
if (!normalized) return 'parallel';
if (
normalized === 'parallel' ||
normalized === 'browser' ||
normalized === 'disabled'
)
return normalized;
throw new Error(
'WEB_SEARCH_PROVIDER must be parallel, browser, or disabled.',
);
Expand Down
5 changes: 5 additions & 0 deletions tests/parallel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ describe('Parallel research', () => {
expect(webSearchProvider('disabled')).toBe('disabled');
expect(() => webSearchProvider('other')).toThrow('WEB_SEARCH_PROVIDER');
});
it('tolerates surrounding whitespace from .env values', () => {
expect(webSearchProvider(' browser ')).toBe('browser');
expect(webSearchProvider('disabled\n')).toBe('disabled');
expect(webSearchProvider(' ')).toBe('parallel');
});
it('searches, extracts and grounds a topic-only brief without a browser', async () => {
mcp.callTool
.mockResolvedValueOnce(result(page(), page('https://example.org')))
Expand Down