Skip to content

Self-improving AI Employees for everyone

feat(plugin): Wave 11.B — reference migrations for all 4 node kinds

trohitgefc0c8a3e048
diff --git a/server/credentials/__init__.py b/server/credentials/__init__.py
new file mode 100644
index 00000000..61ed953d
--- /dev/null
+++ b/server/credentials/__init__.py
@@ -0,0 +1,41 @@
+"""Declarative credential types (Wave 11.E).
+
+One file per provider. Each module declares a :class:`Credential`
+subclass (or several, for OAuth + API-key fallback). Auto-discovery
+via :func:`_discover` at import time, same mechanism as
+``server/nodes/__init__.py``. Plugin nodes reference these classes in
+their ``credentials = (...)`` tuple — no string lookups, no registry
+writes from plugin code.
+
+This package is populated incrementally as plugins are migrated in
+11.B/11.C. Existing nodes on the legacy handler path continue calling
+``auth_service.get_api_key(...)`` directly; the shift is opt-in.
+"""
+
+from __future__ import annotations
+
+import importlib
+import pkgutil
+from typing import List
+
+from core.logging import get_logger
+
+logger = get_logger(__name__)
+
+
+def _discover() -> List[str]:
+ imported: List[str] = []
+ for module_info in pkgutil.iter_modules(__path__):
+ name = module_info.name
+ if name.startswith("_"):
+ continue
+ full_name = f"{__name__}.{name}"
+ try:
+ importlib.import_module(full_name)
+ imported.append(name)
+ except Exception:
+ logger.exception("Failed to import credential module %s", full_name)
+ return imported
+
+
+_DISCOVERED = _discover()
diff --git a/server/nodes/brave_search.py b/server/nodes/brave_search.py
new file mode 100644
index 00000000..5be82573
--- /dev/null
+++ b/server/nodes/brave_search.py
@@ -0,0 +1,117 @@
+"""Brave Search — Wave 11.B reference migration.
+
+One file. Declaration + credential + params + output + handler, all
+in the class body. Replaces the Wave 10 metadata-only registration in
+``server/nodes/services.py:braveSearch`` + the imperative handler in
+``server/services/handlers/search.py:handle_brave_search``.
+
+Pure-declarative path isn't quite a fit — the Brave response needs
+per-item projection from ``{title, description, url}`` to our
+``{title, snippet, url}`` wire format, which the ``post_receive``
+strategy set doesn't express yet. So we keep a short imperative
+operation body, but the Connection facade still eliminates the
+api-key fetch + 30 LOC of try/except boilerplate.
+"""
+
+from __future__ import annotations
+
+from typing import List, Literal, Optional
+
+from pydantic import BaseModel, Field
+
+from services.plugin import (
+ ActionNode,
+ ApiKeyCredential,
+ NodeContext,
+ Operation,
+ TaskQueue,
+)
+
+
+class BraveSearchCredential(ApiKeyCredential):
+ id = "brave_search"
+ display_name = "Brave Search"
+ category = "Search"
+ icon = "asset:brave"
+ key_name = "X-Subscription-Token"
+ key_location = "header"
+ docs_url = "https://api.search.brave.com/app/keys"
+
+
+class BraveSearchResult(BaseModel):
+ title: str = ""
+ snippet: str = ""
+ url: str = ""
+
+
+class BraveSearchOutput(BaseModel):
+ query: str
+ results: List[BraveSearchResult] = Field(default_factory=list)
+ result_count: int = 0
+ provider: Literal["brave_search"] = "brave_search"
+
+
+class BraveSearchParams(BaseModel):
+ query: str = Field(..., description="Search query", min_length=1)
+ max_results: int = Field(default=10, alias="maxResults", ge=1, le=20)
+ country: str = Field(default="", description="ISO country code (e.g. US, GB)")
+ search_lang: str = Field(default="en", alias="searchLang")
+ safe_search: Literal["off", "moderate", "strict"] = Field(
+ default="moderate", alias="safeSearch"
+ )
+
+ model_config = {"populate_by_name": True, "extra": "ignore"}
+
+
+class BraveSearchNode(ActionNode):
+ type = "braveSearch"
+ display_name = "Brave Search"
+ subtitle = "Web Search"
+ icon = "asset:brave"
+ color = "#FB542B"
+ group = ("search", "tool")
+ description = "Search the web using Brave Search API"
+ component_kind = "square"
+ handles = (
+ {"name": "input-main", "kind": "input", "position": "left", "label": "Input", "role": "main"},
+ {"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},
+ )
+ credentials = (BraveSearchCredential,)
+ annotations = {"destructive": False, "readonly": True, "open_world": True}
+ task_queue = TaskQueue.REST_API
+ usable_as_tool = True
+
+ Params = BraveSearchParams
+ Output = BraveSearchOutput
+
+ @Operation("search", cost={"service": "brave_search", "action": "web_search", "count": 1})
+ async def search(self, ctx: NodeContext, params: BraveSearchParams) -> BraveSearchOutput:
+ qs: dict = {"q": params.query, "count": min(params.max_results, 20)}
+ if params.country:
+ qs["country"] = params.country
+ if params.search_lang:
+ qs["search_lang"] = params.search_lang
+ if params.safe_search:
+ qs["safesearch"] = params.safe_search
+
+ async with ctx.connection("brave_search") as conn:
+ response = await conn.get(
+ "https://api.search.brave.com/res/v1/web/search",
+ params=qs,
+ headers={"Accept": "application/json"},
+ )
+ response.raise_for_status()
+ data = response.json()
+
+ web_results = (data.get("web") or {}).get("results") or []
+ items = [
+ BraveSearchResult(
+ title=item.get("title", ""),
+ snippet=item.get("description", ""),
+ url=item.get("url", ""),
+ )
+ for item in web_results[: params.max_results]
+ ]
+ return BraveSearchOutput(
+ query=params.query, results=items, result_count=len(items),
+ )
diff --git a/server/nodes/calculator_tool.py b/server/nodes/calculator_tool.py
new file mode 100644
index 00000000..1927063a
--- /dev/null
+++ b/server/nodes/calculator_tool.py
@@ -0,0 +1,87 @@
+"""Calculator tool — Wave 11.B reference migration.
+
+Passive tool node connected to an AI Agent's ``input-tools`` handle.
+Single file; Params drive the LLM-visible schema via
+``ToolNode.as_tool_schema()``. No credentials, no HTTP, no routing —
+the simplest possible plugin shape.
+
+Replaces:
+- ``server/nodes/tools.py:calculatorTool`` metadata-only registration
+- ``server/services/handlers/tools.py:_execute_calculator`` (kept live
+ for LLM tool-call path until 11.D unifies dispatch)
+"""
+
+from __future__ import annotations
+
+import math
+from typing import Literal, Optional
+
+from pydantic import BaseModel, Field
+
+from services.plugin import NodeContext, Operation, ToolNode
+
+
+class CalculatorParams(BaseModel):
+ """LLM-visible schema. Keep field names + descriptions explicit —
+ the function-calling model reads these."""
+
+ operation: Literal[
+ "add", "subtract", "multiply", "divide", "power", "sqrt", "mod", "abs",
+ ] = Field(..., description="Math operation to perform.")
+ a: float = Field(..., description="First operand (or the sole input for sqrt/abs).")
+ b: Optional[float] = Field(
+ default=None,
+ description="Second operand. Required for add/subtract/multiply/divide/power/mod.",
+ )
+
+
+class CalculatorOutput(BaseModel):
+ operation: str
+ a: float
+ b: Optional[float] = None
+ result: float
+
+
+_OPERATIONS = {
+ "add": lambda a, b: a + b,
+ "subtract": lambda a, b: a - b,
+ "multiply": lambda a, b: a * b,
+ "divide": lambda a, b: a / b if b != 0 else float("inf"),
+ "power": lambda a, b: math.pow(a, b),
+ "mod": lambda a, b: a % b if b != 0 else 0,
+ "sqrt": lambda a, _b: math.sqrt(abs(a)),
+ "abs": lambda a, _b: abs(a),
+}
+
+
+class CalculatorToolNode(ToolNode):
+ type = "calculatorTool"
+ display_name = "Calculator"
+ subtitle = "Math Operations"
+ icon = "🔢"
+ color = "#f1fa8c"
+ group = ("tool", "ai")
+ description = "Add, subtract, multiply, divide, power, sqrt, mod, abs"
+ component_kind = "tool"
+ handles = (
+ {"name": "input-main", "kind": "input", "position": "left",
+ "label": "Input", "role": "main"},
+ {"name": "output-tool", "kind": "output", "position": "top",
+ "label": "Tool", "role": "tools"},
+ )
+ ui_hints = {"isToolPanel": True, "hideRunButton": True}
+ annotations = {"destructive": False, "readonly": True, "open_world": False}
+
+ Params = CalculatorParams
+ Output = CalculatorOutput
+
+ @Operation("calculate")
+ async def calculate(
+ self, ctx: NodeContext, params: CalculatorParams,
+ ) -> CalculatorOutput:
+ fn = _OPERATIONS[params.operation]
+ b_value = params.b if params.b is not None else 0.0
+ result = fn(params.a, b_value)
+ return CalculatorOutput(
+ operation=params.operation, a=params.a, b=params.b, result=result,
+ )
diff --git a/server/nodes/gmail.py b/server/nodes/gmail.py
new file mode 100644
index 00000000..d0dfabf9
--- /dev/null
+++ b/server/nodes/gmail.py
@@ -0,0 +1,145 @@
+"""Gmail — Wave 11.B reference migration (multi-op ActionNode).
+
+Demonstrates the ``@Operation`` dispatch pattern: three operations
+(send / search / read) declared as methods, dispatched on
+``parameters.operation`` automatically by :class:`BaseNode._pick_operation`.
+
+Replaces:
+- ``server/nodes/services.py:gmail`` metadata-only registration
+ (removed).
+- Legacy ``node_executor.py`` routes ``gmail`` → plugin handler via
+ the additive plugin registry merge — no code change in the executor.
+
+Per-op bodies delegate to the existing Google-auth + Google-API-client
+code in ``handlers/gmail.py``. 11.E converts to a declarative
+``GoogleCredential`` shared with calendar/drive/sheets.
+
+This migration also keeps the tool-mode path intact —
+``handlers/tools.py`` calls ``handle_google_gmail`` directly for
+AI-agent-invoked gmail operations. 11.D unifies that path.
+"""
+
+from __future__ import annotations
+
+from typing import Any, ClassVar, Dict, List, Literal, Optional
+
+from pydantic import BaseModel, ConfigDict, Field
+
+from services.plugin import ActionNode, NodeContext, Operation, TaskQueue
+
+
+class GmailParams(BaseModel):
+ """All three ops share one Params model — per-field gating via
+ ``displayOptions.show`` hides irrelevant UI rows in the parameter
+ panel, same pattern the legacy ``GmailParams`` uses."""
+
+ operation: Literal["send", "search", "read"] = "send"
+
+ # send
+ to: str = Field(
+ default="",
+ json_schema_extra={"displayOptions": {"show": {"operation": ["send"]}}},
+ )
+ subject: str = Field(
+ default="",
+ json_schema_extra={"displayOptions": {"show": {"operation": ["send"]}}},
+ )
+ body: str = Field(
+ default="",
+ json_schema_extra={
+ "rows": 4,
+ "placeholder": "Write your message...",
+ "displayOptions": {"show": {"operation": ["send"]}},
+ },
+ )
+
+ # search
+ query: str = Field(
+ default="",
+ json_schema_extra={
+ "placeholder": "from:jane subject:meeting",
+ "displayOptions": {"show": {"operation": ["search"]}},
+ },
+ )
+
+ # read
+ message_id: str = Field(
+ default="",
+ alias="messageId",
+ json_schema_extra={"displayOptions": {"show": {"operation": ["read"]}}},
+ )
+
+ model_config = ConfigDict(populate_by_name=True, extra="ignore")
+
+
+class GmailOutput(BaseModel):
+ operation: Optional[str] = None
+ message_id: Optional[str] = None
+ thread_id: Optional[str] = None
+ emails: Optional[list] = None
+ count: Optional[int] = None
+ subject: Optional[str] = None
+ from_: Optional[str] = Field(default=None, alias="from")
+ to: Optional[str] = None
+ date: Optional[str] = None
+ body: Optional[str] = None
+ snippet: Optional[str] = None
+ labels: Optional[list] = None
+
+ model_config = ConfigDict(populate_by_name=True, extra="allow")
+
+
+class GmailNode(ActionNode):
+ type = "gmail"
+ display_name = "Gmail"
+ subtitle = "Email Operations"
+ icon = "asset:gmail"
+ color = "#EA4335"
+ group = ("google", "tool")
+ description = "Google Gmail send / search / read (dual-purpose workflow + AI tool)"
+ component_kind = "square"
+ handles = (
+ {"name": "input-main", "kind": "input", "position": "left",
+ "label": "Input", "role": "main"},
+ {"name": "output-main", "kind": "output", "position": "right",
+ "label": "Output", "role": "main"},
+ )
+ # Google OAuth stays on the legacy ``google_auth`` helper during
+ # thin-delegation phase. 11.E introduces ``GoogleCredential``.
+ credentials = ()
+ annotations = {"destructive": False, "readonly": False, "open_world": True}
+ task_queue = TaskQueue.REST_API
+ usable_as_tool = True
+
+ Params = GmailParams
+ Output = GmailOutput
+
+ @Operation("send", cost={"service": "gmail", "action": "send", "count": 1})
+ async def send(self, ctx: NodeContext, params: GmailParams) -> Dict[str, Any]:
+ from services.handlers.gmail import handle_gmail_send
+ return await self._delegate(handle_gmail_send, ctx, params)
+
+ @Operation("search", cost={"service": "gmail", "action": "search", "count": 1})
+ async def search(self, ctx: NodeContext, params: GmailParams) -> Dict[str, Any]:
+ from services.handlers.gmail import handle_gmail_search
+ return await self._delegate(handle_gmail_search, ctx, params)
+
+ @Operation("read", cost={"service": "gmail", "action": "read", "count": 1})
+ async def read(self, ctx: NodeContext, params: GmailParams) -> Dict[str, Any]:
+ from services.handlers.gmail import handle_gmail_read
+ return await self._delegate(handle_gmail_read, ctx, params)
+
+ async def _delegate(self, handler, ctx: NodeContext, params: GmailParams) -> Any:
+ """Call a legacy handler with the original ``parameters`` dict,
+ unwrap its ``{success, result, ...}`` envelope, return just the
+ ``result`` — :meth:`BaseNode._wrap_success` re-wraps.
+ """
+ payload = params.model_dump(by_alias=True)
+ response = await handler(
+ node_id=ctx.node_id, node_type=self.type,
+ parameters=payload, context=ctx.raw,
+ )
+ if response.get("success"):
+ return response.get("result") or response
+ # Surface failure via the BaseNode error path.
+ raise RuntimeError(response.get("error") or "gmail operation failed")
diff --git a/server/nodes/gmail_receive.py b/server/nodes/gmail_receive.py
new file mode 100644
index 00000000..09c7de44
--- /dev/null
+++ b/server/nodes/gmail_receive.py
@@ -0,0 +1,108 @@
+"""Gmail Receive — Wave 11.B reference migration (polling trigger).
+
+Polls the Gmail API on a configurable interval for new messages
+matching a filter query. Delegates the actual poll loop to the
+existing ``handlers/gmail.handle_gmail_receive`` — 11.B establishes the
+plugin shell + schema; the full loop port lands in 11.C alongside the
+other Google Workspace nodes so it can reuse the Connection facade for
+OAuth refresh.
+
+Replaces:
+- ``server/nodes/triggers.py:gmailReceive`` metadata-only registration.
+ The legacy handler + its entry in ``node_executor.py`` stay — plugin
+ :meth:`execute` delegates to it, which is an explicit thin-wrapper
+ pattern the plan accepts for this sub-wave.
+
+Deployment-mode polling lifecycle (``deployment/manager.py``) is
+unaffected: it checks ``node_type == 'gmailReceive'`` directly.
+"""
+
+from __future__ import annotations
+
+from typing import Any, ClassVar, Dict, Literal, Optional
+
+from pydantic import BaseModel, ConfigDict, Field
+
+from services.plugin import NodeContext, Operation, TaskQueue, TriggerNode
+
+
+class GmailReceiveParams(BaseModel):
+ filter_query: str = Field(
+ default="is:unread",
+ description="Gmail search query (e.g. 'is:unread from:[email protected]')",
+ )
+ label_filter: str = Field(
+ default="INBOX",
+ description="Label to filter by (or 'all' to disable)",
+ )
+ mark_as_read: bool = False
+ poll_interval: int = Field(default=60, ge=10, le=3600)
+
+ model_config = ConfigDict(extra="ignore")
+
+
+class GmailReceiveOutput(BaseModel):
+ message_id: Optional[str] = None
+ thread_id: Optional[str] = None
+ from_: Optional[str] = Field(default=None, alias="from")
+ to: Optional[str] = None
+ subject: Optional[str] = None
+ body: Optional[str] = None
+ snippet: Optional[str] = None
+ date: Optional[str] = None
+ labels: Optional[list] = None
+ attachments: Optional[list] = None
+ is_unread: Optional[bool] = None
+
+ model_config = ConfigDict(populate_by_name=True, extra="allow")
+
+
+class GmailReceiveNode(TriggerNode):
+ type = "gmailReceive"
+ display_name = "Gmail Receive"
+ subtitle = "Inbound Email"
+ icon = "asset:gmail"
+ color = "#EA4335"
+ group = ("google", "trigger")
+ description = "Polling trigger for incoming Gmail emails"
+ component_kind = "trigger"
+ handles = (
+ {"name": "output-main", "kind": "output", "position": "right",
+ "label": "Output", "role": "main"},
+ )
+ # Google OAuth handled by the legacy google_auth helper during the
+ # thin-delegation phase. 11.C converts this to a declarative
+ # GoogleCredential subclass shared with gmail/calendar/drive/…
+ task_queue = TaskQueue.TRIGGERS_POLL
+ mode = "polling"
+ default_poll_interval = 60
+
+ Params = GmailReceiveParams
+ Output = GmailReceiveOutput
+
+ async def execute(
+ self,
+ node_id: str,
+ parameters: Dict[str, Any],
+ context: NodeContext,
+ ) -> Dict[str, Any]:
+ """Delegate to the legacy polling handler. Keeps the 100 LOC
+ poll loop + OAuth refresh intact while this sub-wave proves the
+ plugin shell. 11.C ports the loop into :meth:`poll_once`.
+ """
+ from services.handlers.gmail import handle_gmail_receive
+ return await handle_gmail_receive(
+ node_id=node_id,
+ node_type=self.type,
+ parameters=parameters,
+ context=context.raw,
+ )
+
+ # Declare a no-op operation so the contract invariants are happy.
+ # The :meth:`execute` override above pre-empts dispatch.
+ @Operation("wait")
+ async def wait(self, ctx: NodeContext, params: GmailReceiveParams) -> GmailReceiveOutput:
+ raise NotImplementedError(
+ "gmailReceive uses execute() override (thin delegation). "
+ "Port into poll_once() lands in Wave 11.C."
+ )
diff --git a/server/nodes/services.py b/server/nodes/services.py
index 8ded4b47..dd0f9963 100644
--- a/server/nodes/services.py
+++ b/server/nodes/services.py
@@ -122,7 +122,7 @@ register_node(type="chatHistory", metadata={"displayName": "Chat History",
# 4. Google Workspace (6) — branded blue
# ---------------------------------------------------------------------------
-register_node(type="gmail", metadata={"displayName": "Gmail", "subtitle": "Email Operations", "icon": "asset:gmail", "color": "#EA4335", "group": ["google", "tool"], "componentKind": "square", "handles": _IO, "description": "Gmail send / search / read operations", "version": 1})
+# gmail — migrated to nodes/gmail.py (Wave 11.B class-based plugin).
register_node(type="calendar", metadata={"displayName": "Calendar", "subtitle": "Event Management", "icon": "asset:calendar", "color": "#4285F4", "group": ["google", "tool"], "componentKind": "square", "handles": _IO, "description": "Google Calendar create / list / update / delete events", "version": 1})
register_node(type="drive", metadata={"displayName": "Drive", "subtitle": "File Operations", "icon": "asset:drive", "color": "#0F9D58", "group": ["google", "tool"], "componentKind": "square", "handles": _IO, "description": "Google Drive upload / download / list / share files", "version": 1})
register_node(type="sheets", metadata={"displayName": "Sheets", "subtitle": "Spreadsheet Ops", "icon": "asset:sheets", "color": "#0F9D58", "group": ["google", "tool"], "componentKind": "square", "handles": _IO, "description": "Google Sheets read / write / append spreadsheet data", "version": 1})
@@ -134,7 +134,7 @@ register_node(type="contacts", metadata={"displayName": "Contacts", "subtitle"
# 5. Web — search, browser, scrapers, proxy, location
# ---------------------------------------------------------------------------
-register_node(type="braveSearch", metadata={"displayName": "Brave Search", "subtitle": "Web Search", "icon": "asset:brave", "color": "#FB542B", "group": ["search", "tool"], "componentKind": "square", "handles": _IO, "description": "Search the web using Brave Search API", "version": 1})
+# braveSearch — migrated to nodes/brave_search.py (Wave 11.B class-based plugin).
register_node(type="serperSearch", metadata={"displayName": "Serper Search", "subtitle": "Google SERP", "icon": "asset:google","color": "#ff79c6", "group": ["search", "tool"], "componentKind": "square", "handles": _IO, "description": "Search the web using Google via Serper API (web/news/images/places)", "version": 1})
register_node(type="perplexitySearch", metadata={"displayName": "Perplexity Search","subtitle": "AI Search", "icon": "asset:perplexity", "color": "#ff79c6", "group": ["search", "tool"], "componentKind": "square", "handles": _IO, "description": "AI-powered search using Perplexity Sonar with citations", "version": 1})
diff --git a/server/nodes/tools.py b/server/nodes/tools.py
index 21d7efd4..945bda9a 100644
--- a/server/nodes/tools.py
+++ b/server/nodes/tools.py
@@ -22,21 +22,7 @@ _TOOL_HANDLES: list[dict] = [
]
-register_node(
- type="calculatorTool",
- metadata={
- "displayName": "Calculator",
- "subtitle": "Math Operations",
- "icon": "🔢",
- "color": "#f1fa8c",
- "group": ["tool", "ai"],
- "componentKind": "tool",
- "handles": _TOOL_HANDLES,
- "description": "Add, subtract, multiply, divide, power, sqrt, mod, abs",
- "version": 1,
- "uiHints": {"isToolPanel": True, "hideRunButton": True},
- },
-)
+# calculatorTool — migrated to nodes/calculator_tool.py (Wave 11.B class-based plugin).
register_node(
type="currentTimeTool",
diff --git a/server/nodes/triggers.py b/server/nodes/triggers.py
index b779b73b..69ef9d00 100644
--- a/server/nodes/triggers.py
+++ b/server/nodes/triggers.py
@@ -82,20 +82,7 @@ register_node(
},
)
-register_node(
- type="webhookTrigger",
- metadata={
- "displayName": "Webhook Trigger",
- "subtitle": "HTTP Inbound",
- "icon": "🪝",
- "color": "#ffb86c",
- "group": ["trigger"],
- "componentKind": "trigger",
- "handles": _TRIGGER_OUTPUT_HANDLES,
- "description": "Start workflow when HTTP request is received",
- "version": 1,
- },
-)
+# webhookTrigger — migrated to nodes/webhook_trigger.py (Wave 11.B class-based plugin).
register_node(
type="chatTrigger",
@@ -173,20 +160,7 @@ register_node(
},
)
-register_node(
- type="gmailReceive",
- metadata={
- "displayName": "Gmail Receive",
- "subtitle": "Inbound Email",
- "icon": "asset:gmail",
- "color": "#EA4335",
- "group": ["google", "trigger"],
- "componentKind": "trigger",
- "handles": _TRIGGER_OUTPUT_HANDLES,
- "description": "Polling trigger for incoming Gmail emails",
- "version": 1,
- },
-)
+# gmailReceive — migrated to nodes/gmail_receive.py (Wave 11.B class-based plugin).
register_node(
type="emailReceive",
diff --git a/server/nodes/webhook_trigger.py b/server/nodes/webhook_trigger.py
new file mode 100644
index 00000000..044265bf
--- /dev/null
+++ b/server/nodes/webhook_trigger.py
@@ -0,0 +1,94 @@
+"""Webhook Trigger — Wave 11.B reference migration (event-based trigger).
+
+Listens for inbound HTTP requests dispatched into ``services.event_waiter``
+by ``routers/webhook.py``. Filter narrows to a specific ``path``. No
+credentials, no HTTP egress — the routing layer injects the event.
+
+Replaces:
+- ``server/nodes/triggers.py:webhookTrigger`` metadata-only registration
+ (kept in place in this module is removed; triggers.py entry deleted).
+- Filter builder ``services.event_waiter.build_webhook_filter`` stays
+ wired to ``FILTER_BUILDERS`` because the waiter registers BEFORE
+ ``TriggerNode.build_filter`` is available — 11.F unifies.
+
+Note: ``TRIGGER_REGISTRY`` entry in ``event_waiter.py`` continues to
+own the ``event_type`` mapping. A plugin-class method
+(:meth:`WebhookTriggerNode.event_type`) could eventually claim that,
+but it touches deployment-mode dispatch — deferred to 11.F.
+"""
+
+from __future__ import annotations
+
+from typing import Any, Callable, Dict, Literal, Optional
+
+from pydantic import BaseModel, ConfigDict, Field
+
+from services.plugin import NodeContext, Operation, TriggerNode, TaskQueue
+
+
+class WebhookTriggerParams(BaseModel):
+ path: str = Field(
+ default="",
+ description="URL path fragment — becomes /webhook/{path}",
+ )
+ method: Literal["GET", "POST", "PUT", "DELETE", "ALL"] = "POST"
+ response_mode: Literal["immediate", "responseNode"] = Field(
+ default="immediate", alias="responseMode",
+ )
+ authentication: Literal["none", "header"] = "none"
+ header_name: str = Field(default="X-API-Key", alias="headerName")
+ header_value: str = Field(default="", alias="headerValue")
+
+ model_config = ConfigDict(populate_by_name=True, extra="ignore")
+
+
+class WebhookTriggerOutput(BaseModel):
+ method: Optional[str] = None
+ path: Optional[str] = None
+ headers: Optional[dict] = None
+ query: Optional[dict] = None
+ body: Optional[str] = None
+ json_: Optional[dict] = Field(default=None, alias="json")
+
+ model_config = ConfigDict(populate_by_name=True, extra="allow")
+
+
+class WebhookTriggerNode(TriggerNode):
+ type = "webhookTrigger"
+ display_name = "Webhook Trigger"
+ subtitle = "HTTP Inbound"
+ icon = "🪝"
+ color = "#ffb86c"
+ group = ("trigger",)
+ description = "Start workflow when HTTP request is received"
+ component_kind = "trigger"
+ handles = (
+ {"name": "output-main", "kind": "output", "position": "right",
+ "label": "Output", "role": "main"},
+ )
+ task_queue = TaskQueue.TRIGGERS_EVENT
+ mode = "event"
+ event_type = "webhook_received"
+
+ Params = WebhookTriggerParams
+ Output = WebhookTriggerOutput
+
+ def build_filter(self, params: WebhookTriggerParams) -> Callable[[Dict[str, Any]], bool]:
+ """Narrow dispatched events to this trigger's path."""
+ expected_path = params.path or ""
+
+ def matches(event: Dict[str, Any]) -> bool:
+ if expected_path and event.get("path") != expected_path:
+ return False
+ return True
+
+ return matches
+
+ # Event triggers don't run a body — the base class handles the
+ # ``event_waiter.register()`` + ``await future`` flow. Declare the
+ # stub operation so invariants see it.
+ @Operation("wait")
+ async def wait(self, ctx: NodeContext, params: WebhookTriggerParams) -> WebhookTriggerOutput:
+ raise NotImplementedError(
+ "Event triggers return via TriggerNode.execute, not the op body"
+ )
diff --git a/server/services/node_executor.py b/server/services/node_executor.py
index 90a4a810..5b1ee535 100644
--- a/server/services/node_executor.py
+++ b/server/services/node_executor.py
@@ -37,7 +37,7 @@ from services.handlers import (
handle_text_chunker, handle_embedding_generator, handle_vector_store,
handle_task_manager,
handle_twitter_send, handle_twitter_search, handle_twitter_user,
- handle_brave_search, handle_serper_search, handle_perplexity_search,
+ handle_serper_search, handle_perplexity_search, # handle_brave_search: used only by handlers/tools.py (Wave 11.B)
handle_rlm_agent,
)
from services.handlers.claude_code import handle_claude_code_agent
@@ -178,15 +178,14 @@ class NodeExecutor:
'twitterSearch': handle_twitter_search,
'twitterUser': handle_twitter_user,
# Google Workspace (consolidated with operation dispatchers)
- 'gmail': handle_google_gmail,
+ # gmail: migrated to nodes/gmail.py (Wave 11.B). Plugin handler wins via registry.update.
'gmailReceive': handle_gmail_receive, # Polling-based trigger (custom handler)
'calendar': handle_google_calendar,
'drive': handle_google_drive,
'sheets': handle_google_sheets,
'tasks': handle_google_tasks,
'contacts': handle_google_contacts,
- # Search
- 'braveSearch': handle_brave_search,
+ # Search — braveSearch migrated to nodes/brave_search.py (Wave 11.B)
'serperSearch': handle_serper_search,
'perplexitySearch': handle_perplexity_search,
# Social (unified messaging)