Skip to content

Self-improving AI Employees for everyone

feat: Add search API nodes (Brave, Serper, Perplexity Sonar)

trohitged4285ad11b9
diff --git a/client/src/Dashboard.tsx b/client/src/Dashboard.tsx
index 882c59b3..2b3f0155 100644
--- a/client/src/Dashboard.tsx
+++ b/client/src/Dashboard.tsx
@@ -31,6 +31,7 @@ import { TOOL_NODE_TYPES } from './nodeDefinitions/toolNodes';
import { SPECIALIZED_AGENT_TYPES } from './nodeDefinitions/specializedAgentNodes';
import { SKILL_NODE_TYPES } from './nodeDefinitions/skillNodes';
import { DOCUMENT_NODE_TYPES } from './nodeDefinitions/documentNodes';
+import { SEARCH_NODE_TYPES } from './nodeDefinitions/searchNodes';
import { SOCIAL_NODE_TYPES } from './nodeDefinitions/socialNodes';
import { APIFY_NODE_TYPES } from './nodeDefinitions/apifyNodes';
import ParameterPanel from './ParameterPanel';
@@ -134,6 +135,9 @@ const createNodeTypes = (): Record<string, React.ComponentType<any>> => {
} else if (APIFY_NODE_TYPES.includes(type)) {
// Apify web scraping nodes use SquareNode component
types[type] = SquareNode;
+ } else if (SEARCH_NODE_TYPES.includes(type)) {
+ // Search API nodes use SquareNode component
+ types[type] = SquareNode;
} else if (SOCIAL_NODE_TYPES.includes(type)) {
// Social nodes use AIAgentNode for multiple output handles support
types[type] = AIAgentNode;
diff --git a/client/src/assets/icons/search/brave.svg b/client/src/assets/icons/search/brave.svg
new file mode 100644
index 00000000..f8f07995
--- /dev/null
+++ b/client/src/assets/icons/search/brave.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FB542B">
+ <path d="M15.68 0l2.096 2.38s1.84-.512 2.709.358c.868.87 1.584 1.638 1.584 1.638l-.562 1.381.715 2.047s-2.104 7.98-2.35 8.955c-.486 1.919-.818 2.66-2.198 3.633-1.38.972-3.884 2.66-4.293 2.916-.409.256-.92.692-1.38.692-.46 0-.97-.436-1.38-.692a185.796 185.796 0 01-4.293-2.916c-1.38-.973-1.712-1.714-2.197-3.633-.247-.975-2.351-8.955-2.351-8.955l.715-2.047-.562-1.381s.716-.768 1.585-1.638c.868-.87 2.708-.358 2.708-.358L8.321 0h7.36zm-3.679 14.936c-.14 0-1.038.317-1.758.69-.72.373-1.242.637-1.409.742-.167.104-.065.301.087.409.152.107 2.194 1.69 2.393 1.866.198.175.489.464.687.464.198 0 .49-.29.688-.464.198-.175 2.24-1.759 2.392-1.866.152-.108.254-.305.087-.41-.167-.104-.689-.368-1.41-.741-.72-.373-1.617-.69-1.757-.69zm0-11.278s-.409.001-1.022.206-1.278.46-1.584.46c-.307 0-2.581-.434-2.581-.434S4.119 7.152 4.119 7.849c0 .697.339.881.68 1.243l2.02 2.149c.192.203.59.511.356 1.066-.235.555-.58 1.26-.196 1.977.384.716 1.042 1.194 1.464 1.115.421-.08 1.412-.598 1.776-.834.364-.237 1.518-1.19 1.518-1.554 0-.365-1.193-1.02-1.413-1.168-.22-.15-1.226-.725-1.247-.95-.02-.227-.012-.293.284-.851.297-.559.831-1.304.742-1.8-.089-.495-.95-.753-1.565-.986-.615-.232-1.799-.671-1.947-.74-.148-.068-.11-.133.339-.175.448-.043 1.719-.212 2.292-.052.573.16 1.552.403 1.632.532.079.13.149.134.067.579-.081.445-.5 2.581-.541 2.96-.04.38-.12.63.288.724.409.094 1.097.256 1.333.256s.924-.162 1.333-.256c.408-.093.329-.344.288-.723-.04-.38-.46-2.516-.541-2.961-.082-.445-.012-.45.067-.579.08-.129 1.059-.372 1.632-.532.573-.16 1.845.009 2.292.052.449.042.487.107.339.175-.148.069-1.332.508-1.947.74-.615.233-1.476.49-1.565.986-.09.496.445 1.241.742 1.8.297.558.304.624.284.85-.02.226-1.026.802-1.247.95-.22.15-1.413.804-1.413 1.169 0 .364 1.154 1.317 1.518 1.554.364.236 1.355.755 1.776.834.422.079 1.08-.4 1.464-1.115.384-.716.039-1.422-.195-1.977-.235-.555.163-.863.355-1.066l2.02-2.149c.341-.362.68-.546.68-1.243 0-.697-2.695-3.96-2.695-3.96s-2.274.436-2.58.436c-.307 0-.972-.256-1.585-.461-.613-.205-1.022-.206-1.022-.206z"/>
+</svg>
diff --git a/client/src/assets/icons/search/google.svg b/client/src/assets/icons/search/google.svg
new file mode 100644
index 00000000..f9ef8738
--- /dev/null
+++ b/client/src/assets/icons/search/google.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#4285F4">
+ <path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"/>
+</svg>
diff --git a/client/src/assets/icons/search/index.ts b/client/src/assets/icons/search/index.ts
new file mode 100644
index 00000000..bdd21b35
--- /dev/null
+++ b/client/src/assets/icons/search/index.ts
@@ -0,0 +1,25 @@
+// Official Search provider icons
+// Based on n8n's implementation using SVG files
+
+import braveSvg from './brave.svg?raw';
+import googleSvg from './google.svg?raw';
+import perplexitySvg from './perplexity.svg?raw';
+
+// Convert SVG to data URI for use in node definitions
+const svgToDataUri = (svg: string): string => {
+ const encoded = encodeURIComponent(svg)
+ .replace(/'/g, '%27')
+ .replace(/"/g, '%22');
+ return `data:image/svg+xml,${encoded}`;
+};
+
+export const BRAVE_SEARCH_ICON = svgToDataUri(braveSvg);
+export const SERPER_ICON = svgToDataUri(googleSvg);
+export const PERPLEXITY_ICON = svgToDataUri(perplexitySvg);
+
+// Export raw SVGs for React component usage
+export const SearchIcons = {
+ brave: braveSvg,
+ serper: googleSvg,
+ perplexity: perplexitySvg,
+};
diff --git a/client/src/assets/icons/search/perplexity.svg b/client/src/assets/icons/search/perplexity.svg
new file mode 100644
index 00000000..3d82e57d
--- /dev/null
+++ b/client/src/assets/icons/search/perplexity.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#20808D">
+ <path d="M22.3977 7.0896h-2.3106V.0676l-7.5094 6.3542V.1577h-1.1554v6.1966L4.4904 0v7.0896H1.6023v10.3976h2.8882V24l6.932-6.3591v6.2005h1.1554v-6.0469l6.9318 6.1807v-6.4879h2.8882V7.0896zm-3.4657-4.531v4.531h-5.355l5.355-4.531zm-13.2862.0676 4.8691 4.4634H5.6458V2.6262zM2.7576 16.332V8.245h7.8476l-6.1149 6.1147v1.9723H2.7576zm2.8882 5.0404v-3.8852h.0001v-2.6488l5.7763-5.7764v7.0111l-5.7764 5.2993zm12.7086.0248-5.7766-5.1509V9.0618l5.7766 5.7766v6.5588zm2.8882-5.0652h-1.733v-1.9723L13.3948 8.245h7.8478v8.087z"/>
+</svg>
diff --git a/client/src/components/CredentialsModal.tsx b/client/src/components/CredentialsModal.tsx
index 8fc21e13..4f4fda03 100644
--- a/client/src/components/CredentialsModal.tsx
+++ b/client/src/components/CredentialsModal.tsx
@@ -25,6 +25,7 @@ import {
OpenAIIcon, ClaudeIcon, GeminiIcon, GroqIcon, OpenRouterIcon, CerebrasIcon,
} from './icons/AIProviderIcons';
import { ApifyIcons } from '../assets/icons/apify';
+import { SearchIcons } from '../assets/icons/search';
// ============================================================================
// SERVICE ICONS
@@ -68,6 +69,24 @@ const ApifyIcon = () => {
);
};
+const BraveSearchIcon = () => {
+ const ref = React.useRef<HTMLDivElement>(null);
+ React.useEffect(() => { if (ref.current) ref.current.innerHTML = SearchIcons.brave; }, []);
+ return <div ref={ref} style={{ width: 20, height: 20 }} />;
+};
+
+const SerperSearchIcon = () => {
+ const ref = React.useRef<HTMLDivElement>(null);
+ React.useEffect(() => { if (ref.current) ref.current.innerHTML = SearchIcons.serper; }, []);
+ return <div ref={ref} style={{ width: 20, height: 20 }} />;
+};
+
+const PerplexitySearchIcon = () => {
+ const ref = React.useRef<HTMLDivElement>(null);
+ React.useEffect(() => { if (ref.current) ref.current.innerHTML = SearchIcons.perplexity; }, []);
+ return <div ref={ref} style={{ width: 20, height: 20 }} />
+};
+
// ============================================================================
// TYPES & DATA
// ============================================================================
@@ -81,7 +100,7 @@ interface CredentialItem {
Icon?: React.FC<{ size?: number }>;
CustomIcon?: React.FC;
isSpecial?: boolean;
- panelType?: 'whatsapp' | 'android' | 'twitter' | 'gmail' | 'google_maps';
+ panelType?: 'whatsapp' | 'android' | 'twitter' | 'gmail' | 'google_maps' | 'search';
}
interface Category {
@@ -119,6 +138,15 @@ const CATEGORIES: Category[] = [
{ id: 'android_remote', name: 'Android Device', placeholder: 'your-api-key...', color: '#3DDC84', desc: 'API key + QR code pairing', CustomIcon: AndroidIcon, isSpecial: true, panelType: 'android' },
],
},
+ {
+ key: 'search',
+ label: 'Search',
+ items: [
+ { id: 'brave_search', name: 'Brave Search', placeholder: 'BSA...', color: '#FB542B', desc: 'Web search via Brave Search API' },
+ { id: 'serper', name: 'Serper', placeholder: '', color: '#4285F4', desc: 'Google search via Serper API' },
+ { id: 'perplexity', name: 'Perplexity', placeholder: 'pplx-...', color: '#20808D', desc: 'AI-powered search with citations' },
+ ],
+ },
{
key: 'services',
label: 'Services',
diff --git a/client/src/components/parameterPanel/InputSection.tsx b/client/src/components/parameterPanel/InputSection.tsx
index 75d7cbb4..6967f4e1 100644
--- a/client/src/components/parameterPanel/InputSection.tsx
+++ b/client/src/components/parameterPanel/InputSection.tsx
@@ -649,6 +649,19 @@ const InputSection: React.FC<InputSectionProps> = ({ nodeId, visible = true }) =
message_type: 'string',
timestamp: 'string'
},
+ // Search node schema (shared by braveSearch, serperSearch, perplexitySearch)
+ search: {
+ query: 'string',
+ results: [{
+ title: 'string',
+ snippet: 'string',
+ url: 'string',
+ }],
+ result_count: 'number',
+ answer: 'string',
+ citations: 'array',
+ provider: 'string',
+ },
// Document processing schemas
httpScraper: {
items: 'array',
@@ -719,6 +732,7 @@ const InputSection: React.FC<InputSectionProps> = ({ nodeId, visible = true }) =
const isGmailSend = nodeType === 'gmailSend';
const isGmailSearch = nodeType === 'gmailSearch';
const isGmailRead = nodeType === 'gmailRead';
+ const isSearchNode = nodeType === 'braveSearch' || nodeType === 'serperSearch' || nodeType === 'perplexitySearch';
// Google Workspace nodes detection
const googleWorkspaceNodeTypes = [
@@ -780,6 +794,7 @@ const InputSection: React.FC<InputSectionProps> = ({ nodeId, visible = true }) =
isSocialReceive ? sampleSchemas.social :
isSocialSend ? sampleSchemas.socialSend :
isApify ? sampleSchemas.apify :
+ isSearchNode ? sampleSchemas.search :
{ data: 'any' };
}
diff --git a/client/src/nodeDefinitions.ts b/client/src/nodeDefinitions.ts
index 031a61ee..7303eff2 100644
--- a/client/src/nodeDefinitions.ts
+++ b/client/src/nodeDefinitions.ts
@@ -25,6 +25,7 @@ import { driveNodes, DRIVE_NODE_TYPES } from './nodeDefinitions/driveNodes';
import { sheetsNodes, SHEETS_NODE_TYPES } from './nodeDefinitions/sheetsNodes';
import { tasksNodes, TASKS_NODE_TYPES } from './nodeDefinitions/tasksNodes';
import { contactsNodes, CONTACTS_NODE_TYPES } from './nodeDefinitions/contactsNodes';
+import { searchNodes, SEARCH_NODE_TYPES } from './nodeDefinitions/searchNodes';
// ============================================================================
// MAIN NODE REGISTRY - Combining all modular definitions
@@ -54,7 +55,8 @@ export const nodeDefinitions: Record<string, INodeTypeDescription> = {
...driveNodes,
...sheetsNodes,
...tasksNodes,
- ...contactsNodes
+ ...contactsNodes,
+ ...searchNodes
};
// ============================================================================
@@ -158,5 +160,9 @@ export const CONTACTS_NODES = [
...CONTACTS_NODE_TYPES
];
+export const SEARCH_NODES = [
+ ...SEARCH_NODE_TYPES
+];
+
// Re-export types and utilities from modular files for external access
export { createBaseChatModel } from './nodeDefinitions/aiModelNodes';
\ No newline at end of file
diff --git a/client/src/nodeDefinitions/searchNodes.ts b/client/src/nodeDefinitions/searchNodes.ts
new file mode 100644
index 00000000..fede275e
--- /dev/null
+++ b/client/src/nodeDefinitions/searchNodes.ts
@@ -0,0 +1,323 @@
+// Search API Node Definitions - Brave Search, Serper, Perplexity Sonar
+// Dual-purpose nodes: work as standalone workflow nodes AND AI Agent tools
+import {
+ INodeTypeDescription,
+ NodeConnectionType
+} from '../types/INodeProperties';
+import { BRAVE_SEARCH_ICON, SERPER_ICON, PERPLEXITY_ICON } from '../assets/icons/search';
+
+// ============================================================================
+// SEARCH NODES
+// ============================================================================
+
+export const searchNodes: Record<string, INodeTypeDescription> = {
+ // Brave Search - Web search via Brave Search API
+ braveSearch: {
+ displayName: 'Brave Search',
+ name: 'braveSearch',
+ icon: BRAVE_SEARCH_ICON,
+ group: ['search', 'tool'],
+ version: 1,
+ subtitle: 'Web Search',
+ description: 'Search the web using Brave Search API. Returns web results with titles, snippets, and URLs.',
+ defaults: { name: 'Brave Search', color: '#FB542B' },
+ inputs: [{
+ name: 'main',
+ displayName: 'Input',
+ type: 'main' as NodeConnectionType,
+ description: 'Search input'
+ }],
+ outputs: [
+ {
+ name: 'main',
+ displayName: 'Output',
+ type: 'main' as NodeConnectionType,
+ description: 'Search results'
+ },
+ {
+ name: 'tool',
+ displayName: 'Tool',
+ type: 'main' as NodeConnectionType,
+ description: 'Connect to AI Agent tool handle'
+ }
+ ],
+ properties: [
+ // ===== TOOL CONFIG =====
+ {
+ displayName: 'Tool Name',
+ name: 'toolName',
+ type: 'string',
+ default: 'brave_search',
+ description: 'Name of this tool when used by AI Agent'
+ },
+ {
+ displayName: 'Tool Description',
+ name: 'toolDescription',
+ type: 'string',
+ default: 'Search the web using Brave Search. Returns web results with titles, snippets, and URLs.',
+ description: 'Description shown to AI Agent'
+ },
+
+ // ===== SEARCH QUERY =====
+ {
+ displayName: 'Search Query',
+ name: 'query',
+ type: 'string',
+ default: '',
+ required: true,
+ placeholder: 'What is the latest news about AI?',
+ description: 'Search query to look up on the web'
+ },
+
+ // ===== RESULT OPTIONS =====
+ {
+ displayName: 'Max Results',
+ name: 'maxResults',
+ type: 'number',
+ default: 10,
+ typeOptions: { minValue: 1, maxValue: 100 },
+ description: 'Maximum number of results to return (1-100)'
+ },
+ {
+ displayName: 'Country',
+ name: 'country',
+ type: 'string',
+ default: '',
+ placeholder: 'US',
+ description: 'Country code for localized results (e.g., US, GB, DE). Leave empty for global.'
+ },
+ {
+ displayName: 'Search Language',
+ name: 'searchLang',
+ type: 'string',
+ default: '',
+ placeholder: 'en',
+ description: 'Language code for results (e.g., en, fr, de). Leave empty for default.'
+ },
+ {
+ displayName: 'Safe Search',
+ name: 'safeSearch',
+ type: 'options',
+ options: [
+ { name: 'Off', value: 'off' },
+ { name: 'Moderate', value: 'moderate' },
+ { name: 'Strict', value: 'strict' }
+ ],
+ default: 'moderate',
+ description: 'Safe search filter level'
+ }
+ ]
+ },
+
+ // Serper Search - Google-powered search via Serper API
+ serperSearch: {
+ displayName: 'Serper Search',
+ name: 'serperSearch',
+ icon: SERPER_ICON,
+ group: ['search', 'tool'],
+ version: 1,
+ subtitle: 'Google Search',
+ description: 'Search the web using Google via Serper API. Returns web results with titles, snippets, and URLs.',
+ defaults: { name: 'Serper Search', color: '#4285F4' },
+ inputs: [{
+ name: 'main',
+ displayName: 'Input',
+ type: 'main' as NodeConnectionType,
+ description: 'Search input'
+ }],
+ outputs: [
+ {
+ name: 'main',
+ displayName: 'Output',
+ type: 'main' as NodeConnectionType,
+ description: 'Search results'
+ },
+ {
+ name: 'tool',
+ displayName: 'Tool',
+ type: 'main' as NodeConnectionType,
+ description: 'Connect to AI Agent tool handle'
+ }
+ ],
+ properties: [
+ // ===== TOOL CONFIG =====
+ {
+ displayName: 'Tool Name',
+ name: 'toolName',
+ type: 'string',
+ default: 'serper_search',
+ description: 'Name of this tool when used by AI Agent'
+ },
+ {
+ displayName: 'Tool Description',
+ name: 'toolDescription',
+ type: 'string',
+ default: 'Search the web using Google via Serper API. Returns web results with titles, snippets, and URLs.',
+ description: 'Description shown to AI Agent'
+ },
+
+ // ===== SEARCH QUERY =====
+ {
+ displayName: 'Search Query',
+ name: 'query',
+ type: 'string',
+ default: '',
+ required: true,
+ placeholder: 'best restaurants in New York',
+ description: 'Search query to look up on Google'
+ },
+
+ // ===== SEARCH TYPE =====
+ {
+ displayName: 'Search Type',
+ name: 'searchType',
+ type: 'options',
+ options: [
+ { name: 'Web Search', value: 'search' },
+ { name: 'News', value: 'news' },
+ { name: 'Images', value: 'images' },
+ { name: 'Places', value: 'places' }
+ ],
+ default: 'search',
+ description: 'Type of search to perform'
+ },
+
+ // ===== RESULT OPTIONS =====
+ {
+ displayName: 'Max Results',
+ name: 'maxResults',
+ type: 'number',
+ default: 10,
+ typeOptions: { minValue: 1, maxValue: 100 },
+ description: 'Maximum number of results to return (1-100)'
+ },
+ {
+ displayName: 'Country',
+ name: 'country',
+ type: 'string',
+ default: '',
+ placeholder: 'us',
+ description: 'Country code for localized results (e.g., us, gb, de). Leave empty for global.'
+ },
+ {
+ displayName: 'Language',
+ name: 'language',
+ type: 'string',
+ default: '',
+ placeholder: 'en',
+ description: 'Language code for results (e.g., en, fr, de). Leave empty for default.'
+ }
+ ]
+ },
+
+ // Perplexity Search - AI-powered search via Perplexity Sonar API
+ perplexitySearch: {
+ displayName: 'Perplexity Search',
+ name: 'perplexitySearch',
+ icon: PERPLEXITY_ICON,
+ group: ['search', 'tool'],
+ version: 1,
+ subtitle: 'AI Search',
+ description: 'Search the web using Perplexity Sonar AI. Returns an AI-generated answer with citations.',
+ defaults: { name: 'Perplexity Search', color: '#20808D' },
+ inputs: [{
+ name: 'main',
+ displayName: 'Input',
+ type: 'main' as NodeConnectionType,
+ description: 'Search input'
+ }],
+ outputs: [
+ {
+ name: 'main',
+ displayName: 'Output',
+ type: 'main' as NodeConnectionType,
+ description: 'AI-powered search results with citations'
+ },
+ {
+ name: 'tool',
+ displayName: 'Tool',
+ type: 'main' as NodeConnectionType,
+ description: 'Connect to AI Agent tool handle'
+ }
+ ],
+ properties: [
+ // ===== TOOL CONFIG =====
+ {
+ displayName: 'Tool Name',
+ name: 'toolName',
+ type: 'string',
+ default: 'perplexity_search',
+ description: 'Name of this tool when used by AI Agent'
+ },
+ {
+ displayName: 'Tool Description',
+ name: 'toolDescription',
+ type: 'string',
+ default: 'Search the web using Perplexity Sonar AI. Returns an AI-generated answer with citations and source URLs.',
+ description: 'Description shown to AI Agent'
+ },
+
+ // ===== SEARCH QUERY =====
+ {
+ displayName: 'Search Query',
+ name: 'query',
+ type: 'string',
+ default: '',
+ required: true,
+ placeholder: 'What are the latest developments in quantum computing?',
+ description: 'Search query to get AI-powered answer with citations'
+ },
+
+ // ===== MODEL =====
+ {
+ displayName: 'Model',
+ name: 'model',
+ type: 'options',
+ options: [
+ { name: 'Sonar (Default)', value: 'sonar' },
+ { name: 'Sonar Pro', value: 'sonar-pro' },
+ { name: 'Sonar Reasoning', value: 'sonar-reasoning' },
+ { name: 'Sonar Reasoning Pro', value: 'sonar-reasoning-pro' }
+ ],
+ default: 'sonar',
+ description: 'Perplexity Sonar model to use'
+ },
+
+ // ===== OPTIONS =====
+ {
+ displayName: 'Search Recency Filter',
+ name: 'searchRecencyFilter',
+ type: 'options',
+ options: [
+ { name: 'None', value: '' },
+ { name: 'Last Month', value: 'month' },
+ { name: 'Last Week', value: 'week' },
+ { name: 'Last Day', value: 'day' },
+ { name: 'Last Hour', value: 'hour' }
+ ],
+ default: '',
+ description: 'Filter results by recency'
+ },
+ {
+ displayName: 'Return Images',
+ name: 'returnImages',
+ type: 'boolean',
+ default: false,
+ description: 'Include images in the response'
+ },
+ {
+ displayName: 'Return Related Questions',
+ name: 'returnRelatedQuestions',
+ type: 'boolean',
+ default: false,
+ description: 'Include related questions in the response'
+ }
+ ]
+ }
+};
+
+// ============================================================================
+// EXPORTS
+// ============================================================================
+
+export const SEARCH_NODE_TYPES = ['braveSearch', 'serperSearch', 'perplexitySearch'];
diff --git a/server/config/pricing.json b/server/config/pricing.json
index 3a8d9210..ef7da28c 100644
--- a/server/config/pricing.json
+++ b/server/config/pricing.json
@@ -213,6 +213,28 @@
"media_metadata": 0.005,
"privacy_update": 0.010,
"mute_delete": 0.005
+ },
+ "brave_search": {
+ "_description": "Brave Search API pricing (per query)",
+ "_source": "https://brave.com/search/api/",
+ "_updated": "2026-02",
+ "web_search": 0.003,
+ "_default": 0.003
+ },
+ "serper": {
+ "_description": "Serper Google Search API pricing (per query)",
+ "_source": "https://serper.dev/pricing",
+ "_updated": "2026-02",
+ "web_search": 0.001,
+ "_default": 0.001
+ },
+ "perplexity": {
+ "_description": "Perplexity Sonar API pricing (per request)",
+ "_source": "https://docs.perplexity.ai/guides/pricing",
+ "_updated": "2026-02",
+ "sonar_search": 0.005,
+ "sonar_pro_search": 0.005,
+ "_default": 0.005
}
},
@@ -300,6 +322,15 @@
"delete": "contact_delete",
"list": "contact_list",
"search": "contact_search"
+ },
+ "brave_search": {
+ "web_search": "web_search"
+ },
+ "serper": {
+ "web_search": "web_search"
+ },
+ "perplexity": {
+ "sonar_search": "sonar_search"
}
},
diff --git a/server/constants.py b/server/constants.py
index 4efa88a2..b3a71063 100644
--- a/server/constants.py
+++ b/server/constants.py
@@ -80,6 +80,23 @@ CONFIG_NODE_TYPES: FrozenSet[str] = (
SKILL_NODE_TYPES # Skill nodes (connect to Zeenie's input-skill)
)
+# =============================================================================
+# SEARCH NODE TYPES
+# =============================================================================
+
+SEARCH_NODE_TYPES: FrozenSet[str] = frozenset([
+ 'braveSearch',
+ 'serperSearch',
+ 'perplexitySearch',
+])
+
+# Dual-purpose search nodes (workflow node + AI tool)
+SEARCH_TOOL_TYPES: FrozenSet[str] = frozenset([
+ 'braveSearch',
+ 'serperSearch',
+ 'perplexitySearch',
+])
+
# =============================================================================
# GOOGLE MAPS NODE TYPES
# =============================================================================
diff --git a/server/services/ai.py b/server/services/ai.py
index 78f4a69f..f2f53365 100644
--- a/server/services/ai.py
+++ b/server/services/ai.py
@@ -2365,6 +2365,9 @@ class AIService:
'whatsappDb': 'whatsapp_db',
'gmaps_locations': 'geocode',
'gmaps_nearby_places': 'nearby_places',
+ 'braveSearch': 'brave_search',
+ 'serperSearch': 'serper_search',
+ 'perplexitySearch': 'perplexity_search',
'taskManager': 'task_manager',
'timer': 'timer',
'cronScheduler': 'cron_scheduler',
@@ -2412,6 +2415,9 @@ class AIService:
'androidTool': 'Control Android device. Available services are determined by connected nodes.',
'whatsappSend': 'Send WhatsApp messages to contacts or groups. Supports text, media, location, and contact messages.',
'whatsappDb': 'Query WhatsApp database - list contacts, search groups, get contact/group info, retrieve chat history.',
+ 'braveSearch': 'Search the web using Brave Search. Returns web results with titles, snippets, and URLs.',
+ 'serperSearch': 'Search the web using Google via Serper API. Returns web results with titles, snippets, and URLs.',
+ 'perplexitySearch': 'Search the web using Perplexity Sonar AI. Returns an AI-generated answer with citations and source URLs.',
'gmaps_locations': 'Geocode addresses to coordinates or reverse geocode coordinates to addresses using Google Maps.',
'gmaps_nearby_places': 'Search for nearby places (restaurants, hospitals, banks, etc.) using Google Maps Places API.',
'taskManager': 'Track delegated sub-agent tasks. Operations: list_tasks (see all tasks), get_task (check specific task status/result), mark_done (cleanup completed tasks).',
@@ -2637,6 +2643,30 @@ class AIService:
return WebSearchSchema
+ # Brave Search tool schema (dual-purpose: workflow node + AI tool)
+ if node_type == 'braveSearch':
+ class BraveSearchSchema(BaseModel):
+ """Search the web using Brave Search API."""
+ query: str = Field(description="Search query to look up on the web")
+
+ return BraveSearchSchema
+
+ # Serper Search tool schema (dual-purpose: workflow node + AI tool)
+ if node_type == 'serperSearch':
+ class SerperSearchSchema(BaseModel):
+ """Search the web using Google via Serper API."""
+ query: str = Field(description="Search query to look up on Google")
+
+ return SerperSearchSchema
+
+ # Perplexity Search tool schema (dual-purpose: workflow node + AI tool)
+ if node_type == 'perplexitySearch':
+ class PerplexitySearchSchema(BaseModel):
+ """Search the web using Perplexity Sonar AI for an answer with citations."""
+ query: str = Field(description="Search query to get AI-powered answer with citations")
+
+ return PerplexitySearchSchema
+
# Timer tool schema (dual-purpose: workflow node + AI tool)
if node_type == 'timer':
class TimerSchema(BaseModel):
diff --git a/server/services/handlers/__init__.py b/server/services/handlers/__init__.py
index 5b378638..2ca03e64 100644
--- a/server/services/handlers/__init__.py
+++ b/server/services/handlers/__init__.py
@@ -97,6 +97,13 @@ from .document import (
handle_vector_store,
)
+# Search handlers
+from .search import (
+ handle_brave_search,
+ handle_serper_search,
+ handle_perplexity_search,
+)
+
# Tool execution handlers (for AI Agent tool calling)
from .tools import (
execute_tool,
@@ -154,6 +161,10 @@ __all__ = [
'handle_text_chunker',
'handle_embedding_generator',
'handle_vector_store',
+ # Search
+ 'handle_brave_search',
+ 'handle_serper_search',
+ 'handle_perplexity_search',
# Tools
'execute_tool',
'handle_task_manager',
diff --git a/server/services/handlers/search.py b/server/services/handlers/search.py
new file mode 100644
index 00000000..06f347fd
--- /dev/null
+++ b/server/services/handlers/search.py
@@ -0,0 +1,385 @@
+"""Search API node handlers - Brave Search, Serper, Perplexity Sonar.
+
+Each handler fetches the API key from the encrypted credentials system
+via auth_service, then calls the provider's API.
+"""
+
+import time
+from typing import Dict, Any
+
+import httpx
+
+from core.logging import get_logger
+from services.pricing import get_pricing_service
+
+logger = get_logger(__name__)
+
+
+async def _track_search_usage(
+ node_id: str,
+ service: str,
+ action: str,
+ resource_count: int = 1,
+ workflow_id: str = None,
+ session_id: str = "default"
+) -> Dict[str, float]:
+ """Track search API usage for cost calculation."""
+ from core.container import container
+
+ pricing = get_pricing_service()
+ cost_data = pricing.calculate_api_cost(service, action, resource_count)
+
+ db = container.database()
+ await db.save_api_usage_metric({
+ 'session_id': session_id,
+ 'node_id': node_id,
+ 'workflow_id': workflow_id,
+ 'service': service,
+ 'operation': cost_data.get('operation', action),
+ 'endpoint': action,
+ 'resource_count': resource_count,
+ 'cost': cost_data.get('total_cost', 0.0)
+ })
+
+ logger.debug(f"[Search] Tracked {service} usage: {action} x{resource_count} = ${cost_data.get('total_cost', 0):.6f}")
+ return cost_data
+
+
+async def _get_api_key(provider: str) -> str:
+ """Get API key from encrypted credentials."""
+ from core.container import container
+ auth_service = container.auth_service()
+ api_key = await auth_service.get_api_key(provider)
+ if not api_key:
+ raise ValueError(
+ f"{provider} API key not configured. "
+ f"Please add it in Credentials > Search."
+ )
+ return api_key
+
+
+# =============================================================================
+# BRAVE SEARCH HANDLER
+# =============================================================================
+
+async def handle_brave_search(
+ node_id: str,
+ node_type: str,
+ parameters: Dict[str, Any],
+ context: Dict[str, Any]
+) -> Dict[str, Any]:
+ """Handle Brave Search API requests.
+
+ API: GET https://api.search.brave.com/res/v1/web/search
+ Auth: X-Subscription-Token header
+ """
+ start_time = time.time()
+
+ query = parameters.get('query', '').strip()
+ if not query:
+ return {"success": False, "error": "Search query is required"}
+
+ max_results = parameters.get('maxResults', 10)
+ country = parameters.get('country', '')
+ search_lang = parameters.get('searchLang', '')
+ safe_search = parameters.get('safeSearch', 'moderate')
+
+ try:
+ api_key = await _get_api_key('brave_search')
+
+ params = {
+ 'q': query,
+ 'count': min(max_results, 100),
+ }
+ if country:
+ params['country'] = country
+ if search_lang:
+ params['search_lang'] = search_lang
+ if safe_search:
+ params['safesearch'] = safe_search
+
+ async with httpx.AsyncClient(timeout=30.0) as client:
+ response = await client.get(
+ 'https://api.search.brave.com/res/v1/web/search',
+ headers={
+ 'X-Subscription-Token': api_key,
+ 'Accept': 'application/json',
+ },
+ params=params,
+ )
+ response.raise_for_status()
+ data = response.json()
+
+ # Extract web results
+ web_results = data.get('web', {}).get('results', [])
+ results = []
+ for item in web_results[:max_results]:
+ results.append({
+ 'title': item.get('title', ''),
+ 'snippet': item.get('description', ''),
+ 'url': item.get('url', ''),
+ })
+
+ execution_time = time.time() - start_time
+
+ # Track usage
+ workflow_id = context.get('workflow_id')
+ session_id = context.get('session_id', 'default')
+ await _track_search_usage(node_id, 'brave_search', 'web_search', 1, workflow_id, session_id)
+
+ return {
+ "success": True,
+ "result": {
+ "query": query,
+ "results": results,
+ "result_count": len(results),
+ "provider": "brave_search",
+ },
+ "execution_time": round(execution_time, 3),
+ }
+
+ except httpx.HTTPStatusError as e:
+ logger.error(f"[BraveSearch] API error: {e.response.status_code} - {e.response.text}")
+ return {"success": False, "error": f"Brave Search API error: {e.response.status_code}"}
+ except ValueError as e:
+ return {"success": False, "error": str(e)}
+ except Exception as e:
+ logger.error(f"[BraveSearch] Error: {e}")
+ return {"success": False, "error": f"Brave Search failed: {str(e)}"}
+
+
+# =============================================================================
+# SERPER SEARCH HANDLER
+# =============================================================================
+
+async def handle_serper_search(
+ node_id: str,
+ node_type: str,
+ parameters: Dict[str, Any],
+ context: Dict[str, Any]
+) -> Dict[str, Any]:
+ """Handle Serper (Google) Search API requests.
+
+ API: POST https://google.serper.dev/search
+ Auth: X-API-KEY header
+ """
+ start_time = time.time()
+
+ query = parameters.get('query', '').strip()
+ if not query:
+ return {"success": False, "error": "Search query is required"}
+
+ max_results = parameters.get('maxResults', 10)
+ search_type = parameters.get('searchType', 'search')
+ country = parameters.get('country', '')
+ language = parameters.get('language', '')
+
+ try:
+ api_key = await _get_api_key('serper')
+
+ body: Dict[str, Any] = {
+ 'q': query,
+ 'num': min(max_results, 100),
+ }
+ if country:
+ body['gl'] = country
+ if language:
+ body['hl'] = language
+
+ # Map search type to endpoint
+ endpoint_map = {
+ 'search': 'https://google.serper.dev/search',
+ 'news': 'https://google.serper.dev/news',
+ 'images': 'https://google.serper.dev/images',
+ 'places': 'https://google.serper.dev/places',
+ }
+ endpoint = endpoint_map.get(search_type, 'https://google.serper.dev/search')
+
+ async with httpx.AsyncClient(timeout=30.0) as client:
+ response = await client.post(
+ endpoint,
+ headers={
+ 'X-API-KEY': api_key,
+ 'Content-Type': 'application/json',
+ },
+ json=body,
+ )
+ response.raise_for_status()
+ data = response.json()
+
+ # Extract results based on search type
+ results = []
+ if search_type == 'search':
+ for item in data.get('organic', [])[:max_results]:
+ results.append({
+ 'title': item.get('title', ''),
+ 'snippet': item.get('snippet', ''),
+ 'url': item.get('link', ''),
+ 'position': item.get('position'),
+ })
+ elif search_type == 'news':
+ for item in data.get('news', [])[:max_results]:
+ results.append({
+ 'title': item.get('title', ''),
+ 'snippet': item.get('snippet', ''),
+ 'url': item.get('link', ''),
+ 'date': item.get('date', ''),
+ 'source': item.get('source', ''),
+ })
+ elif search_type == 'images':
+ for item in data.get('images', [])[:max_results]:
+ results.append({
+ 'title': item.get('title', ''),
+ 'imageUrl': item.get('imageUrl', ''),
+ 'url': item.get('link', ''),
+ })
+ elif search_type == 'places':
+ for item in data.get('places', [])[:max_results]:
+ results.append({
+ 'title': item.get('title', ''),
+ 'address': item.get('address', ''),
+ 'rating': item.get('rating'),
+ 'url': item.get('website', ''),
+ })
+
+ # Include knowledge graph if available
+ knowledge_graph = data.get('knowledgeGraph')
+
+ execution_time = time.time() - start_time
+
+ # Track usage
+ workflow_id = context.get('workflow_id')
+ session_id = context.get('session_id', 'default')
+ await _track_search_usage(node_id, 'serper', 'web_search', 1, workflow_id, session_id)
+
+ result = {
+ "query": query,
+ "results": results,
+ "result_count": len(results),
+ "search_type": search_type,
+ "provider": "serper",
+ }
+ if knowledge_graph:
+ result["knowledge_graph"] = knowledge_graph
+
+ return {
+ "success": True,
+ "result": result,
+ "execution_time": round(execution_time, 3),
+ }
+
+ except httpx.HTTPStatusError as e:
+ logger.error(f"[Serper] API error: {e.response.status_code} - {e.response.text}")
+ return {"success": False, "error": f"Serper API error: {e.response.status_code}"}
+ except ValueError as e:
+ return {"success": False, "error": str(e)}
+ except Exception as e:
+ logger.error(f"[Serper] Error: {e}")
+ return {"success": False, "error": f"Serper search failed: {str(e)}"}
+
+
+# =============================================================================
+# PERPLEXITY SEARCH HANDLER
+# =============================================================================
+
+async def handle_perplexity_search(
+ node_id: str,
+ node_type: str,
+ parameters: Dict[str, Any],
+ context: Dict[str, Any]
+) -> Dict[str, Any]:
+ """Handle Perplexity Sonar AI search requests.
+
+ API: POST https://api.perplexity.ai/chat/completions
+ Auth: Authorization: Bearer header
+ """
+ start_time = time.time()
+
+ query = parameters.get('query', '').strip()
+ if not query:
+ return {"success": False, "error": "Search query is required"}
+
+ model = parameters.get('model', 'sonar')
+ search_recency_filter = parameters.get('searchRecencyFilter', '')
+ return_images = parameters.get('returnImages', False)
+ return_related_questions = parameters.get('returnRelatedQuestions', False)
+
+ try:
+ api_key = await _get_api_key('perplexity')
+
+ body: Dict[str, Any] = {
+ 'model': model,
+ 'messages': [
+ {'role': 'user', 'content': query}
+ ],
+ }
+
+ if search_recency_filter:
+ body['search_recency_filter'] = search_recency_filter
+ if return_images:
+ body['return_images'] = True
+ if return_related_questions:
+ body['return_related_questions'] = True
+
+ async with httpx.AsyncClient(timeout=60.0) as client:
+ response = await client.post(
+ 'https://api.perplexity.ai/chat/completions',
+ headers={
+ 'Authorization': f'Bearer {api_key}',
+ 'Content-Type': 'application/json',
+ },
+ json=body,
+ )
+ response.raise_for_status()
+ data = response.json()
+
+ # Extract answer and citations
+ choices = data.get('choices', [])
+ answer = ''
+ if choices:
+ message = choices[0].get('message', {})
+ answer = message.get('content', '')
+
+ citations = data.get('citations', [])
+ images = data.get('images', [])
+ related_questions = data.get('related_questions', [])
+
+ # Build results from citations
+ results = []
+ for url in citations:
+ results.append({'url': url})
+
+ execution_time = time.time() - start_time
+
+ # Track usage
+ workflow_id = context.get('workflow_id')
+ session_id = context.get('session_id', 'default')
+ await _track_search_usage(node_id, 'perplexity', 'sonar_search', 1, workflow_id, session_id)
+
+ result: Dict[str, Any] = {
+ "query": query,
+ "answer": answer,
+ "citations": citations,
+ "results": results,
+ "model": model,
+ "provider": "perplexity",
+ }
+ if images:
+ result["images"] = images
+ if related_questions:
+ result["related_questions"] = related_questions
+
+ return {
+ "success": True,
+ "result": result,
+ "execution_time": round(execution_time, 3),
+ }
+
+ except httpx.HTTPStatusError as e:
+ logger.error(f"[Perplexity] API error: {e.response.status_code} - {e.response.text}")
+ return {"success": False, "error": f"Perplexity API error: {e.response.status_code}"}
+ except ValueError as e:
+ return {"success": False, "error": str(e)}
+ except Exception as e:
+ logger.error(f"[Perplexity] Error: {e}")
+ return {"success": False, "error": f"Perplexity search failed: {str(e)}"}
diff --git a/server/services/handlers/tools.py b/server/services/handlers/tools.py
index 512c29e7..5a87667f 100644
--- a/server/services/handlers/tools.py
+++ b/server/services/handlers/tools.py
@@ -197,6 +197,18 @@ async def execute_tool(tool_name: str, tool_args: Dict[str, Any],
if node_type in ANDROID_SERVICE_NODE_TYPES:
return await _execute_android_service(tool_args, config)
+ # Brave Search (dual-purpose: workflow node + AI tool)
+ if node_type == 'braveSearch':
+ return await _execute_brave_search_tool(tool_args, config.get('parameters', {}))
+
+ # Serper Search (dual-purpose: workflow node + AI tool)
+ if node_type == 'serperSearch':
+ return await _execute_serper_search_tool(tool_args, config.get('parameters', {}))
+
+ # Perplexity Search (dual-purpose: workflow node + AI tool)
+ if node_type == 'perplexitySearch':
+ return await _execute_perplexity_search_tool(tool_args, config.get('parameters', {}))
+
# Google Maps Geocoding (gmaps_locations node as tool)
if node_type == 'gmaps_locations':
return await _execute_geocoding(tool_args, config.get('parameters', {}))
@@ -2324,3 +2336,49 @@ async def handle_task_manager(
'database': context.get('database')
}
return await _execute_task_manager({}, config)
+
+
+# =============================================================================
+# SEARCH TOOL WRAPPERS (for AI Agent tool calling)
+# =============================================================================
+
+async def _execute_brave_search_tool(args: Dict[str, Any],
+ node_params: Dict[str, Any]) -> Dict[str, Any]:
+ """Execute Brave Search via handler (AI Agent tool wrapper)."""
+ from services.handlers.search import handle_brave_search
+
+ parameters = {**node_params, **args}
+ return await handle_brave_search(
+ node_id="tool_brave_search",
+ node_type="braveSearch",
+ parameters=parameters,
+ context={}
+ )
+
+
+async def _execute_serper_search_tool(args: Dict[str, Any],
+ node_params: Dict[str, Any]) -> Dict[str, Any]:
+ """Execute Serper Search via handler (AI Agent tool wrapper)."""
+ from services.handlers.search import handle_serper_search
+
+ parameters = {**node_params, **args}
+ return await handle_serper_search(
+ node_id="tool_serper_search",
+ node_type="serperSearch",
+ parameters=parameters,
+ context={}
+ )
+
+
+async def _execute_perplexity_search_tool(args: Dict[str, Any],
+ node_params: Dict[str, Any]) -> Dict[str, Any]:
+ """Execute Perplexity Search via handler (AI Agent tool wrapper)."""
+ from services.handlers.search import handle_perplexity_search
+
+ parameters = {**node_params, **args}
+ return await handle_perplexity_search(
+ node_id="tool_perplexity_search",
+ node_type="perplexitySearch",
+ parameters=parameters,
+ context={}
+ )
diff --git a/server/services/node_executor.py b/server/services/node_executor.py
index f098552a..1d9105de 100644
--- a/server/services/node_executor.py
+++ b/server/services/node_executor.py
@@ -38,6 +38,7 @@ from services.handlers import (
handle_task_manager,
handle_twitter_send, handle_twitter_search, handle_twitter_user,
handle_gmail_send, handle_gmail_search, handle_gmail_read,
+ handle_brave_search, handle_serper_search, handle_perplexity_search,
)
from services.handlers.apify import handle_apify_actor
from services.handlers.calendar import (
@@ -188,6 +189,10 @@ class NodeExecutor:
'contactsGet': handle_contacts_get,
'contactsUpdate': handle_contacts_update,
'contactsDelete': handle_contacts_delete,
+ # Search
+ 'braveSearch': handle_brave_search,
+ 'serperSearch': handle_serper_search,
+ 'perplexitySearch': handle_perplexity_search,
# Social (unified messaging)
# Note: socialReceive handled in _dispatch with connected_outputs
'socialSend': handle_social_send,