AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(blocks): add DataForB2B provider (B2B data & enrichment) (#13383)
claude-dev-codec92a003fe82d
diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/__init__.py b/autogpt_platform/backend/backend/blocks/dataforb2b/__init__.pynew file mode 100644index 0000000000..947e4a446b--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/__init__.py@@ -0,0 +1,7 @@+"""DataForB2B blocks for the AutoGPT platform.++B2B data API for searching and enriching companies and professional (LinkedIn)+profiles: people search, company search, natural-language reasoning search,+filter typeahead, and profile/company enrichment (work email, personal email,+phone, GitHub).+"""diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/_api.py b/autogpt_platform/backend/backend/blocks/dataforb2b/_api.pynew file mode 100644index 0000000000..92a9daa800--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/_api.py@@ -0,0 +1,70 @@+from typing import Any++from backend.blocks.dataforb2b._config import DataForB2BCredentials+from backend.util.request import Requests+++class DataForB2BClient:+ """Client for the DataForB2B API (https://api.dataforb2b.ai)."""++ API_URL = "https://api.dataforb2b.ai"++ def __init__(self, credentials: DataForB2BCredentials):+ self.credentials = credentials+ self.requests = Requests()++ def _get_headers(self) -> dict[str, str]:+ return {+ "api_key": self.credentials.api_key.get_secret_value(),+ "Content-Type": "application/json",+ }++ async def _post(self, path: str, payload: dict[str, Any]) -> dict:+ response = await self.requests.post(+ f"{self.API_URL}{path}",+ headers=self._get_headers(),+ json=payload,+ )+ return response.json()++ async def _get(self, path: str, params: dict[str, Any]) -> dict:+ response = await self.requests.get(+ f"{self.API_URL}{path}",+ headers=self._get_headers(),+ params=params,+ )+ return response.json()++ # --- Search -----------------------------------------------------------++ async def search_people(self, payload: dict[str, Any]) -> dict:+ """POST /search/people — find professional profiles by filters."""+ return await self._post("/search/people", payload)++ async def search_companies(self, payload: dict[str, Any]) -> dict:+ """POST /search/companies — find companies by filters."""+ return await self._post("/search/companies", payload)++ async def reasoning_search(self, payload: dict[str, Any]) -> dict:+ """POST /search/reasoning — natural-language search.++ May return ``status == "needs_input"`` with clarifying questions; in+ that case re-call with ``session_id`` + ``answers``.+ """+ return await self._post("/search/reasoning", payload)++ async def typeahead(self, type_: str, q: str, limit: int = 20) -> dict:+ """GET /typeahead — resolve the exact stored value for a free-text filter."""+ return await self._get("/typeahead", {"type": type_, "q": q, "limit": limit})++ # --- Enrich -----------------------------------------------------------++ async def enrich_profile(self, payload: dict[str, Any]) -> dict:+ """POST /enrich/profile — enrich a profile; ≥1 enrich_* flag required."""+ return await self._post("/enrich/profile", payload)++ async def enrich_company(self, company_identifier: str) -> dict:+ """POST /enrich/company — enrich a company by domain/name/identifier."""+ return await self._post(+ "/enrich/company", {"company_identifier": company_identifier}+ )diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/_config.py b/autogpt_platform/backend/backend/blocks/dataforb2b/_config.pynew file mode 100644index 0000000000..31d20429c2--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/_config.py@@ -0,0 +1,44 @@+"""Shared provider and credential configuration for DataForB2B blocks."""++from backend.sdk import (+ APIKeyCredentials,+ BlockCostType,+ CredentialsMetaInput,+ ProviderBuilder,+ ProviderName,+ SecretStr,+)++# DataForB2B is a metered, credit-consuming API and the "enrich_live" paths+# cost more credits upstream than the cached ones. 1 cr/RUN is a conservative+# interim floor that keeps every call billed, matching the agent_mail+# precedent. Revisit with per-endpoint / enrich_live-aware pricing once real+# DataForB2B usage costs are known.+dataforb2b = (+ ProviderBuilder("dataforb2b")+ .with_description(+ "B2B data API — search leads, enrich profiles (from a LinkedIn URL), find work "+ "emails and phone numbers for prospecting and outreach."+ )+ .with_api_key("DATAFORB2B_API_KEY", "DataForB2B API Key")+ .with_base_cost(1, BlockCostType.RUN)+ .build()+)++DataForB2BCredentials = APIKeyCredentials+DataForB2BCredentialsInput = CredentialsMetaInput++TEST_CREDENTIALS = APIKeyCredentials(+ id="01234567-89ab-cdef-0123-456789abcdef",+ provider="dataforb2b",+ api_key=SecretStr("mock-dataforb2b-api-key"),+ title="Mock DataForB2B API key",+ expires_at=None,+)+TEST_CREDENTIALS_META_INPUT = DataForB2BCredentialsInput(+ provider=ProviderName("dataforb2b"),+ id=TEST_CREDENTIALS.id,+ type=TEST_CREDENTIALS.type,+ title=TEST_CREDENTIALS.title,+)+TEST_CREDENTIALS_INPUT = TEST_CREDENTIALS_META_INPUT.model_dump(mode="json")diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/_enums.py b/autogpt_platform/backend/backend/blocks/dataforb2b/_enums.pynew file mode 100644index 0000000000..944380c07b--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/_enums.py@@ -0,0 +1,135 @@+"""Canonical filter enums for DataForB2B search blocks.++Source of truth: the DataForB2B search column spec. Using these as block input+field types makes the columns/operators render as dropdowns in the builder.+"""++from enum import Enum+++class FilterOperator(str, Enum):+ EQUALS = "="+ NOT_EQUALS = "!="+ LIKE = "like"+ NOT_LIKE = "not_like"+ IN = "in"+ NOT_IN = "not_in"+ GREATER_THAN = ">"+ GREATER_OR_EQUAL = ">="+ LESS_THAN = "<"+ LESS_OR_EQUAL = "<="+ BETWEEN = "between"+++class PeopleColumn(str, Enum):+ # Profile+ first_name = "first_name"+ last_name = "last_name"+ profile_location = "profile_location"+ profile_country = "profile_country"+ profile_industry = "profile_industry"+ follower_count = "follower_count"+ keyword = "keyword"+ # Current job+ current_company = "current_company"+ current_title = "current_title"+ current_job_location = "current_job_location"+ current_company_industry = "current_company_industry"+ current_company_category = "current_company_category"+ current_company_size = "current_company_size"+ current_company_id = "current_company_id"+ current_employment_type = "current_employment_type"+ years_in_current_position = "years_in_current_position"+ years_at_current_company = "years_at_current_company"+ current_company_has_funding = "current_company_has_funding"+ current_company_funding_stage = "current_company_funding_stage"+ current_company_investor = "current_company_investor"+ # Past jobs+ past_company = "past_company"+ past_title = "past_title"+ past_job_location = "past_job_location"+ past_company_industry = "past_company_industry"+ past_company_size = "past_company_size"+ past_company_id = "past_company_id"+ past_employment_type = "past_employment_type"+ years_at_past_company = "years_at_past_company"+ # Skills / education / languages / certifications / experience+ skill = "skill"+ school = "school"+ degree = "degree"+ degree_level = "degree_level"+ field_of_study = "field_of_study"+ language = "language"+ language_iso = "language_iso"+ language_proficiency = "language_proficiency"+ certification = "certification"+ certification_authority = "certification_authority"+ years_of_experience = "years_of_experience"+ num_total_jobs = "num_total_jobs"+ is_currently_employed = "is_currently_employed"+++class CompanyColumn(str, Enum):+ # Basic+ # Member is named `company_name` (rather than `name`) for a clearer,+ # unambiguous dropdown label; the value is the DataForB2B API's actual+ # column identifier ("name") and must not change.+ company_name = "name"+ tagline = "tagline"+ description = "description"+ domain = "domain"+ universal_name = "universal_name"+ keyword = "keyword"+ industry = "industry"+ # Size+ employee_count = "employee_count"+ # HQ / offices+ country_iso_code = "country_iso_code"+ city = "city"+ region = "region"+ office_country = "office_country"+ office_city = "office_city"+ office_region = "office_region"+ # Growth+ employee_growth_1m = "employee_growth_1m"+ employee_growth_6m = "employee_growth_6m"+ employee_growth_12m = "employee_growth_12m"+ recent_hires_count = "recent_hires_count"+ # Metadata+ founded_year = "founded_year"+ company_type = "company_type"+ follower_count = "follower_count"+ page_verified = "page_verified"+ category = "category"+ # Funding+ last_funding_amount_usd = "last_funding_amount_usd"+ last_funding_date = "last_funding_date"+ funding_stage_normalized = "funding_stage_normalized"+ has_funding = "has_funding"+++class TypeaheadType(str, Enum):+ """Closed set of resolvable filter-value categories for the typeahead+ endpoint. Using an enum (rather than free text) prevents silent+ no-result typos and renders as a dropdown in the builder."""++ # Mirrors the `type` enum accepted by GET /typeahead. Industry is split+ # per-side upstream — people and company industries are separate+ # taxonomies with differently-cased values — and there is no bare+ # "industry" type; sending one is a 422.+ COMPANY = "company"+ PEOPLE_INDUSTRY = "people_industry"+ COMPANY_INDUSTRY = "company_industry"+ TITLE = "title"+ SKILL = "skill"+ SCHOOL = "school"+ INVESTOR = "investor"+ LOCATION = "location"+ CITY = "city"+ REGION = "region"+ CATEGORY = "category"+++class SearchCategory(str, Enum):+ PEOPLE = "people"+ COMPANY = "company"diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/_filters.py b/autogpt_platform/backend/backend/blocks/dataforb2b/_filters.pynew file mode 100644index 0000000000..489f161696--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/_filters.py@@ -0,0 +1,95 @@+"""Filter-building helpers for DataForB2B search blocks.++A search filter is ``{op, conditions: [{column, type, value, value2?}]}``.+"""++from enum import Enum+from typing import Any, Optional+++def _to_str(x: Any) -> str:+ """Return an enum member's value, or the stringified value otherwise."""+ if isinstance(x, Enum):+ return str(x.value)+ return str(x)+++def coerce_scalar(value: Any) -> Any:+ """Coerce a filter value string into bool/number when it clearly is one."""+ if isinstance(value, (int, float, bool)):+ return value+ s = str(value).strip()+ low = s.lower()+ if low == "true":+ return True+ if low == "false":+ return False+ try:+ f = float(s)+ return int(f) if f.is_integer() else f+ except (TypeError, ValueError):+ return s+++def build_slot_condition(column: Any, operator: Any, raw: Any) -> Optional[dict]:+ """Build one filter condition from a (column, operator, value) slot.++ Returns None when the slot is empty.+ - ``in``/``not_in`` -> value is a comma-separated list+ - ``between`` -> value is "min,max"+ - ``like`` -> raw string kept as-is (text pattern)+ - others -> single value, coerced to bool/number when applicable+ """+ if not column or raw is None or str(raw).strip() == "":+ return None+ column = _to_str(column)+ op = (_to_str(operator).strip() if operator else "=") or "="++ if op in ("in", "not_in"):+ items = [x.strip() for x in str(raw).split(",") if x.strip()]+ if not items:+ return None+ return {+ "column": column,+ "type": op,+ "value": [coerce_scalar(x) for x in items],+ }++ if op == "between":+ parts = [x.strip() for x in str(raw).split(",") if x.strip()]+ if len(parts) != 2:+ raise ValueError(+ f"Operator 'between' on '{column}' needs exactly two "+ f"comma-separated values, e.g. 3,7 (got {len(parts)})"+ )+ return {+ "column": column,+ "type": "between",+ "value": coerce_scalar(parts[0]),+ "value2": coerce_scalar(parts[1]),+ }++ if op == "like":+ return {"column": column, "type": "like", "value": str(raw)}++ return {"column": column, "type": op, "value": coerce_scalar(raw)}+++def finalize_filters(conditions: list, match: Any, advanced: Any) -> Optional[dict]:+ """Combine slot conditions (with AND/OR) and optional advanced JSON filters."""+ op = str(match).strip().lower() if match else "and"+ if op not in ("and", "or"):+ op = "and"++ group = {"op": op, "conditions": conditions} if conditions else None++ if advanced:+ if isinstance(advanced, dict) and "conditions" in advanced:+ adv = advanced+ elif isinstance(advanced, list):+ adv = {"op": "and", "conditions": advanced}+ else: # a single bare condition dict+ adv = {"op": "and", "conditions": [advanced]}+ return {"op": "and", "conditions": [group, adv]} if group else adv++ return groupdiff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/_filters_test.py b/autogpt_platform/backend/backend/blocks/dataforb2b/_filters_test.pynew file mode 100644index 0000000000..53d7a3017e--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/_filters_test.py@@ -0,0 +1,151 @@+"""Tests for DataForB2B filter-building helpers (coerce_scalar, build_slot_condition,+finalize_filters)."""++import pytest++from backend.blocks.dataforb2b._enums import FilterOperator+from backend.blocks.dataforb2b._filters import (+ build_slot_condition,+ coerce_scalar,+ finalize_filters,+)+++def test_coerce_scalar_bool():+ assert coerce_scalar("true") is True+ assert coerce_scalar("False") is False+ assert coerce_scalar(True) is True+++def test_coerce_scalar_number():+ assert coerce_scalar("42") == 42+ assert isinstance(coerce_scalar("42"), int)+ assert coerce_scalar("3.5") == 3.5+ assert isinstance(coerce_scalar("3.5"), float)+++def test_coerce_scalar_passthrough_string():+ assert coerce_scalar("software engineer") == "software engineer"+++def test_build_slot_condition_empty_returns_none():+ assert build_slot_condition(None, FilterOperator.EQUALS, "x") is None+ assert build_slot_condition("industry", FilterOperator.EQUALS, None) is None+ assert build_slot_condition("industry", FilterOperator.EQUALS, " ") is None+++def test_build_slot_condition_default_operator():+ cond = build_slot_condition("industry", None, "software")+ assert cond == {"column": "industry", "type": "=", "value": "software"}+++def test_build_slot_condition_in_operator():+ cond = build_slot_condition(+ "industry", FilterOperator.IN, "software, finance, , retail"+ )+ assert cond == {+ "column": "industry",+ "type": "in",+ "value": ["software", "finance", "retail"],+ }+++def test_build_slot_condition_not_in_operator():+ cond = build_slot_condition("industry", FilterOperator.NOT_IN, "software, finance")+ assert cond == {+ "column": "industry",+ "type": "not_in",+ "value": ["software", "finance"],+ }+++def test_build_slot_condition_in_operator_empty_returns_none():+ assert build_slot_condition("industry", FilterOperator.IN, " , , ") is None+++def test_build_slot_condition_between_operator():+ cond = build_slot_condition("employee_count", FilterOperator.BETWEEN, "10,50")+ assert cond == {+ "column": "employee_count",+ "type": "between",+ "value": 10,+ "value2": 50,+ }+++def test_build_slot_condition_between_operator_wrong_count_raises():+ """Thread ED7c/DxBb: 'between' with != 2 values must raise, not silently drop."""+ with pytest.raises(ValueError, match="exactly two"):+ build_slot_condition("employee_count", FilterOperator.BETWEEN, "10,50,90")++ with pytest.raises(ValueError, match="exactly two"):+ build_slot_condition("employee_count", FilterOperator.BETWEEN, "10")+++def test_build_slot_condition_like_operator_keeps_raw_string():+ cond = build_slot_condition("company_name", FilterOperator.LIKE, "acme corp")+ assert cond == {"column": "company_name", "type": "like", "value": "acme corp"}+++def test_build_slot_condition_coerces_scalar_for_other_operators():+ cond = build_slot_condition("employee_count", FilterOperator.GREATER_THAN, "100")+ assert cond == {"column": "employee_count", "type": ">", "value": 100}+++def test_finalize_filters_none_when_no_conditions_or_advanced():+ assert finalize_filters([], "and", None) is None+++def test_finalize_filters_conditions_only():+ conditions = [{"column": "industry", "type": "=", "value": "software"}]+ assert finalize_filters(conditions, "and", None) == {+ "op": "and",+ "conditions": conditions,+ }+++def test_finalize_filters_invalid_match_defaults_to_and():+ conditions = [{"column": "industry", "type": "=", "value": "software"}]+ assert finalize_filters(conditions, "invalid", None)["op"] == "and"+++def test_finalize_filters_or_match():+ conditions = [{"column": "industry", "type": "=", "value": "software"}]+ assert finalize_filters(conditions, "or", None) == {+ "op": "or",+ "conditions": conditions,+ }+++def test_finalize_filters_advanced_only_dict_with_conditions():+ advanced = {"op": "and", "conditions": [{"column": "x", "type": "=", "value": 1}]}+ assert finalize_filters([], "and", advanced) == advanced+++def test_finalize_filters_advanced_only_list():+ advanced = [{"column": "x", "type": "=", "value": 1}]+ assert finalize_filters([], "and", advanced) == {+ "op": "and",+ "conditions": advanced,+ }+++def test_finalize_filters_advanced_only_bare_condition_dict():+ advanced = {"column": "x", "type": "=", "value": 1}+ assert finalize_filters([], "and", advanced) == {+ "op": "and",+ "conditions": [advanced],+ }+++def test_finalize_filters_merges_slots_and_advanced_with_and():+ conditions = [{"column": "industry", "type": "=", "value": "software"}]+ advanced = {"column": "x", "type": "=", "value": 1}+ result = finalize_filters(conditions, "and", advanced)+ assert result == {+ "op": "and",+ "conditions": [+ {"op": "and", "conditions": conditions},+ {"op": "and", "conditions": [advanced]},+ ],+ }diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/conftest.py b/autogpt_platform/backend/backend/blocks/dataforb2b/conftest.pynew file mode 100644index 0000000000..f3e4fba99b--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/conftest.py@@ -0,0 +1,15 @@+"""Keep DataForB2B unit tests independent of platform services."""++from collections.abc import AsyncIterator++import pytest_asyncio+++@pytest_asyncio.fixture(scope="session", loop_scope="session")+async def server() -> None:+ return None+++@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True)+async def graph_cleanup() -> AsyncIterator[None]:+ yielddiff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/enrich.py b/autogpt_platform/backend/backend/blocks/dataforb2b/enrich.pynew file mode 100644index 0000000000..f9a96814c5--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/enrich.py@@ -0,0 +1,174 @@+from backend.blocks.dataforb2b._api import DataForB2BClient+from backend.blocks.dataforb2b._config import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_INPUT,+ DataForB2BCredentials,+ DataForB2BCredentialsInput,+ dataforb2b,+)+from backend.sdk import (+ Block,+ BlockCategory,+ BlockOutput,+ BlockSchemaInput,+ BlockSchemaOutput,+ SchemaField,+)++ENRICH_FLAGS = (+ "enrich_profile",+ "enrich_work_email",+ "enrich_personal_email",+ "enrich_github",+)+++class ProfileEnrichmentBlock(Block):+ """Enrich a LinkedIn profile with DataForB2B (full profile + email, phone, GitHub)."""++ class Input(BlockSchemaInput):+ profile_identifier: str = SchemaField(+ description="LinkedIn profile URL (or profile id) to enrich",+ advanced=False,+ )+ enrich_profile: bool = SchemaField(+ description="Return the full LinkedIn profile (role, experience, skills)",+ default=True,+ advanced=False,+ )+ enrich_work_email: bool = SchemaField(+ description="Find the professional / work email",+ default=False,+ advanced=False,+ )+ enrich_personal_email: bool = SchemaField(+ description="Find the personal email", default=False, advanced=False+ )+ enrich_github: bool = SchemaField(+ description="Find the GitHub profile", default=False, advanced=True+ )+ credentials: DataForB2BCredentialsInput = dataforb2b.credentials_field(+ description="DataForB2B API key"+ )++ class Output(BlockSchemaOutput):+ result: dict = SchemaField(description="Full enrichment response")++ def __init__(self):+ super().__init__(+ id="6b5eaff2-aded-47c4-9acc-e2047c76e72e",+ description=(+ "Look up and enrich a professional profile from a LinkedIn URL using "+ "DataForB2B's B2B database — returns the full profile (current role, "+ "experience and skills) plus work email, personal email and GitHub. "+ "Works as an email finder for lead enrichment, contact enrichment, "+ "cold outreach and CRM. Disable enrich_profile if you only need the "+ "email/GitHub lookups."+ ),+ categories={BlockCategory.SOCIAL, BlockCategory.DATA, BlockCategory.CRM},+ input_schema=ProfileEnrichmentBlock.Input,+ output_schema=ProfileEnrichmentBlock.Output,+ test_credentials=TEST_CREDENTIALS,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "profile_identifier": "https://www.linkedin.com/in/johndoe",+ "enrich_profile": True,+ "enrich_work_email": True,+ },+ test_output=[+ (+ "result",+ {"profile": {"name": "John Doe"}, "work_email": "[email protected]"},+ ),+ ],+ test_mock={+ "fetch_profile": lambda payload, credentials: {+ "profile": {"name": "John Doe"},+ "work_email": "[email protected]",+ }+ },+ )++ @staticmethod+ async def fetch_profile(payload: dict, credentials: DataForB2BCredentials) -> dict:+ client = DataForB2BClient(credentials)+ return await client.enrich_profile(payload)++ async def run(+ self, input_data: Input, *, credentials: DataForB2BCredentials, **kwargs+ ) -> BlockOutput:+ profile_identifier = input_data.profile_identifier.strip()+ if not profile_identifier:+ raise ValueError("'profile_identifier' is required.")++ payload: dict = {"profile_identifier": profile_identifier}+ any_flag = False+ for flag in ENRICH_FLAGS:+ value = bool(getattr(input_data, flag, False))+ payload[flag] = value+ any_flag = any_flag or value+ if not any_flag:+ payload["enrich_profile"] = True++ result = await self.fetch_profile(payload, credentials)+ yield "result", result+++class CompanyEnrichmentBlock(Block):+ """Enrich a company with DataForB2B (firmographics from domain/name/LinkedIn URL)."""++ class Input(BlockSchemaInput):+ company_identifier: str = SchemaField(+ description="Company domain, name, or LinkedIn URL to enrich",+ advanced=False,+ )+ credentials: DataForB2BCredentialsInput = dataforb2b.credentials_field(+ description="DataForB2B API key"+ )++ class Output(BlockSchemaOutput):+ result: dict = SchemaField(description="Full company enrichment response")++ def __init__(self):+ super().__init__(+ id="32f80b6c-02e2-455f-af93-493514a19903",+ description=(+ "Look up and enrich a company using DataForB2B's B2B database — "+ "firmographics, headcount/size, industry, domain and social profiles "+ "from a company domain, name or LinkedIn URL. Account enrichment for "+ "B2B sales and CRM."+ ),+ categories={BlockCategory.SOCIAL, BlockCategory.DATA, BlockCategory.CRM},+ input_schema=CompanyEnrichmentBlock.Input,+ output_schema=CompanyEnrichmentBlock.Output,+ test_credentials=TEST_CREDENTIALS,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "company_identifier": "google.com",+ },+ test_output=[+ ("result", {"name": "Google", "domain": "google.com"}),+ ],+ test_mock={+ "fetch_company": lambda company_identifier, credentials: {+ "name": "Google",+ "domain": "google.com",+ }+ },+ )++ @staticmethod+ async def fetch_company(+ company_identifier: str, credentials: DataForB2BCredentials+ ) -> dict:+ client = DataForB2BClient(credentials)+ return await client.enrich_company(company_identifier)++ async def run(+ self, input_data: Input, *, credentials: DataForB2BCredentials, **kwargs+ ) -> BlockOutput:+ company_identifier = input_data.company_identifier.strip()+ if not company_identifier:+ raise ValueError("'company_identifier' is required.")+ result = await self.fetch_company(company_identifier, credentials)+ yield "result", resultdiff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/enrich_test.py b/autogpt_platform/backend/backend/blocks/dataforb2b/enrich_test.pynew file mode 100644index 0000000000..40f87f2996--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/enrich_test.py@@ -0,0 +1,137 @@+"""Tests for the enrichment blocks: whitespace-only identifier validation,+the any_flag fallback to enrich_profile, and error surfacing."""++from unittest.mock import AsyncMock, patch++import pytest++from backend.blocks.dataforb2b._config import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_META_INPUT,+)+from backend.blocks.dataforb2b.enrich import (+ CompanyEnrichmentBlock,+ ProfileEnrichmentBlock,+)+++async def _run_and_capture_payload(input_data):+ """Run the block with a mocked client, returning the payload sent to the API."""+ block = ProfileEnrichmentBlock()+ with patch.object(+ ProfileEnrichmentBlock,+ "fetch_profile",+ new=AsyncMock(return_value={"profile": {"name": "John Doe"}}),+ ) as mock_enrich:+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+ return mock_enrich.await_args.args[0]+++async def test_whitespace_only_identifier_raises_value_error():+ """Thread ED7l/DxBk: a whitespace-only profile_identifier must be rejected,+ not passed through as if it were a real value."""+ block = ProfileEnrichmentBlock()+ input_data = ProfileEnrichmentBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ profile_identifier=" ",+ )+ with pytest.raises(ValueError, match="profile_identifier"):+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+++async def test_identifier_is_stripped():+ input_data = ProfileEnrichmentBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ profile_identifier=" https://www.linkedin.com/in/johndoe ",+ enrich_profile=True,+ )+ payload = await _run_and_capture_payload(input_data)+ assert payload["profile_identifier"] == "https://www.linkedin.com/in/johndoe"+++async def test_no_flags_set_falls_back_to_enrich_profile():+ """Thread ED6c: when none of the enrich_* flags are set, the block must still+ request the profile rather than sending an all-False payload."""+ input_data = ProfileEnrichmentBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ profile_identifier="https://www.linkedin.com/in/johndoe",+ enrich_profile=False,+ enrich_work_email=False,+ enrich_personal_email=False,+ enrich_github=False,+ )+ payload = await _run_and_capture_payload(input_data)+ assert payload["enrich_profile"] is True+++async def test_explicit_flag_is_respected_without_fallback():+ input_data = ProfileEnrichmentBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ profile_identifier="https://www.linkedin.com/in/johndoe",+ enrich_profile=False,+ enrich_work_email=True,+ )+ payload = await _run_and_capture_payload(input_data)+ assert payload["enrich_profile"] is False+ assert payload["enrich_work_email"] is True+++async def _run_company_and_capture_identifier(input_data):+ """Run CompanyEnrichmentBlock with a mocked client, returning the identifier sent."""+ block = CompanyEnrichmentBlock()+ with patch.object(+ CompanyEnrichmentBlock,+ "fetch_company",+ new=AsyncMock(return_value={"name": "Google"}),+ ) as mock_enrich:+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+ return mock_enrich.await_args.args[0]+++async def test_company_whitespace_only_identifier_raises_value_error():+ """A whitespace-only company_identifier must be rejected, not sent as-is."""+ block = CompanyEnrichmentBlock()+ input_data = CompanyEnrichmentBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ company_identifier=" ",+ )+ with pytest.raises(ValueError, match="company_identifier"):+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+++async def test_company_identifier_is_stripped():+ input_data = CompanyEnrichmentBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ company_identifier=" google.com ",+ )+ identifier = await _run_company_and_capture_identifier(input_data)+ assert identifier == "google.com"+++async def test_company_upstream_error_propagates_to_error_output():+ """The docs promise client/server errors surface via the framework 'error'+ output; that contract relies on run() letting the exception escape."""+ block = CompanyEnrichmentBlock()+ input_data = CompanyEnrichmentBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ company_identifier="google.com",+ )+ with patch.object(+ CompanyEnrichmentBlock,+ "fetch_company",+ new=AsyncMock(side_effect=RuntimeError("upstream 500")),+ ):+ with pytest.raises(RuntimeError, match="upstream 500"):+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ passdiff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/reasoning.py b/autogpt_platform/backend/backend/blocks/dataforb2b/reasoning.pynew file mode 100644index 0000000000..2a2ae236e8--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/reasoning.py@@ -0,0 +1,178 @@+from backend.blocks.dataforb2b._api import DataForB2BClient+from backend.blocks.dataforb2b._config import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_INPUT,+ DataForB2BCredentials,+ DataForB2BCredentialsInput,+ dataforb2b,+)+from backend.blocks.dataforb2b._enums import SearchCategory+from backend.sdk import (+ Block,+ BlockCategory,+ BlockOutput,+ BlockSchemaInput,+ BlockSchemaOutput,+ SchemaField,+)++# Conservative safety ceiling for `max_results`, mirroring search.py's MAX_COUNT.+MAX_RESULTS = 100+++class SmartSearchBlock(Block):+ """Natural-language LinkedIn people & company search with DataForB2B."""++ class Input(BlockSchemaInput):+ query: str = SchemaField(+ description="Plain-English LinkedIn search / ICP (e.g. 'marketing directors at Series A SaaS startups in France')",+ default="",+ advanced=False,+ )+ category: SearchCategory = SchemaField(+ description="What to search for: 'people' or 'company'",+ default=SearchCategory.PEOPLE,+ advanced=False,+ )+ session_id: str = SchemaField(+ description="Session id to resolve a previous 'needs_input' turn",+ default="",+ advanced=True,+ )+ answers: dict = SchemaField(+ description="Answers to clarifying questions {question_id: answer}",+ default_factory=dict,+ advanced=True,+ )+ max_results: int = SchemaField(+ description=f"Maximum results to return (1-{MAX_RESULTS})",+ default=25,+ advanced=False,+ )+ enrich_live: bool = SchemaField(+ description="Fetch fresh live data (uses more credits)",+ default=False,+ advanced=True,+ )+ credentials: DataForB2BCredentialsInput = dataforb2b.credentials_field(+ description="DataForB2B API key"+ )++ class Output(BlockSchemaOutput):+ result: dict = SchemaField(description="Full reasoning-search response")+ status: str = SchemaField(description="'complete' or 'needs_input'", default="")+ results: list = SchemaField(+ description="Matching results when status is complete",+ default_factory=list,+ )+ questions: list = SchemaField(+ description="Clarifying questions when status is needs_input",+ default_factory=list,+ )+ session_id: str = SchemaField(+ description="Session id to continue the search", default=""+ )+ applied_filters: dict = SchemaField(+ description=(+ "The structured filters the search applied. Feed this into "+ "People Search or Company Search 'filters_json' with an offset to "+ "paginate beyond the first page."+ ),+ default_factory=dict,+ )+ category: str = SchemaField(+ description="Category searched ('people' or 'company', echoed from the input) — route pagination to the matching search block",+ default="",+ )++ def __init__(self):+ super().__init__(+ id="3a835db4-e60d-4e5f-aa7b-3b1ef14ff4a6",+ description=(+ "Natural-language search for people, leads or companies using DataForB2B's "+ "B2B database — describe your ideal lead or ICP in plain English and get "+ "matching profiles. Handles clarifying questions."+ ),+ categories={BlockCategory.SEARCH, BlockCategory.SOCIAL, BlockCategory.AI},+ input_schema=SmartSearchBlock.Input,+ output_schema=SmartSearchBlock.Output,+ test_credentials=TEST_CREDENTIALS,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "query": "software engineers in Paris",+ "category": "people",+ "max_results": 1,+ },+ test_output=[+ (+ "result",+ {+ "status": "complete",+ "total": 1,+ "count": 1,+ "results": [{"id": "1"}],+ },+ ),+ ("status", "complete"),+ ("results", [{"id": "1"}]),+ ("questions", []),+ ("session_id", ""),+ ("applied_filters", {}),+ ("category", "people"),+ ],+ test_mock={+ "reasoning_search": lambda payload, credentials: {+ "status": "complete",+ "total": 1,+ "count": 1,+ "results": [{"id": "1"}],+ }+ },+ )++ @staticmethod+ async def reasoning_search(+ payload: dict, credentials: DataForB2BCredentials+ ) -> dict:+ client = DataForB2BClient(credentials)+ return await client.reasoning_search(payload)++ async def run(+ self, input_data: Input, *, credentials: DataForB2BCredentials, **kwargs+ ) -> BlockOutput:+ query = input_data.query.strip()+ session_id = input_data.session_id.strip()+ has_continuation_data = bool(session_id or input_data.answers)+ if has_continuation_data:+ if query or not session_id or not input_data.answers:+ raise ValueError(+ "Provide either 'query' or both 'session_id' and 'answers'."+ )+ elif not query:+ raise ValueError(+ "Provide 'query' (first call) or 'session_id' + 'answers' (to "+ "resolve a needs_input turn)."+ )++ category = input_data.category+ max_results = max(1, min(int(input_data.max_results), MAX_RESULTS))+ payload: dict = {+ "category": category.value,+ "max_results": max_results,+ "enrich_live": bool(input_data.enrich_live),+ }+ if query:+ payload["query"] = query+ if session_id:+ payload["session_id"] = session_id+ if input_data.answers:+ payload["answers"] = input_data.answers++ data = await self.reasoning_search(payload, credentials)+ yield "result", data+ yield "status", data.get("status", "")+ yield "results", data.get("results", []) or []+ yield "questions", data.get("questions", []) or []+ yield "session_id", data.get("session_id", "") or ""+ yield "applied_filters", data.get("applied_filters", {}) or {}+ yield "category", category.valuediff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/reasoning_test.py b/autogpt_platform/backend/backend/blocks/dataforb2b/reasoning_test.pynew file mode 100644index 0000000000..9caf22f0b4--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/reasoning_test.py@@ -0,0 +1,169 @@+"""Tests for SmartSearchBlock: needs_input continuation flow and initial-vs-+continuation input validation."""++import json+from unittest.mock import AsyncMock, patch++import pytest+from pytest_snapshot.plugin import Snapshot++from backend.blocks.dataforb2b._config import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_META_INPUT,+)+from backend.blocks.dataforb2b.reasoning import MAX_RESULTS, SmartSearchBlock+++async def _run_and_collect(input_data, response=None):+ block = SmartSearchBlock()+ outputs = {}+ if response is None:+ response = {+ "status": "needs_input",+ "session_id": "sess-1",+ "questions": [{"id": "q1", "text": "Which region?"}],+ }+ with patch.object(+ SmartSearchBlock,+ "reasoning_search",+ new=AsyncMock(return_value=response),+ ) as mock_search:+ async for name, value in block.run(input_data, credentials=TEST_CREDENTIALS):+ outputs[name] = value+ return outputs, mock_search+++async def test_needs_input_status_surfaces_questions_and_session_id(+ snapshot: Snapshot,+):+ """Thread ED6Z: the needs_input turn must surface status/questions/session_id+ so a caller can resolve it in a follow-up call."""+ input_data = SmartSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ query="marketing directors",+ category="people",+ )+ outputs, _ = await _run_and_collect(input_data)+ assert outputs["status"] == "needs_input"+ assert outputs["session_id"] == "sess-1"+ assert outputs["questions"] == [{"id": "q1", "text": "Which region?"}]+ assert outputs["results"] == []+ snapshot.snapshot_dir = "snapshots"+ snapshot.assert_match(+ json.dumps(outputs, indent=2, sort_keys=True),+ "smart_search_needs_input_outputs",+ )+++async def test_continuation_call_with_session_id_and_answers():+ """A follow-up call resolving a needs_input turn omits 'query' and supplies+ 'session_id' + 'answers' instead."""+ input_data = SmartSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ session_id="sess-1",+ answers={"q1": "Europe"},+ )+ outputs, mock_search = await _run_and_collect(input_data)+ payload = mock_search.await_args.args[0]+ assert payload["session_id"] == "sess-1"+ assert payload["answers"] == {"q1": "Europe"}+ assert "query" not in payload+ assert outputs["status"] == "needs_input"+++async def test_missing_query_and_continuation_data_raises():+ """Thread ED7X/DxBo: initial calls need 'query'; continuation calls need both+ 'session_id' and 'answers'. Neither present must raise."""+ block = SmartSearchBlock()+ input_data = SmartSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ )+ with pytest.raises(ValueError):+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+++async def test_session_id_without_answers_raises():+ """Thread ED7X/DxBo: partial continuation data (only session_id, no answers)+ must raise rather than silently proceeding."""+ block = SmartSearchBlock()+ input_data = SmartSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ session_id="sess-1",+ )+ with pytest.raises(ValueError):+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+++async def test_query_and_continuation_data_together_raises():+ """Thread ED7X/DxBo: providing 'query' together with 'session_id'/'answers'+ is ambiguous and must raise rather than picking one silently."""+ block = SmartSearchBlock()+ input_data = SmartSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ query="marketing directors",+ session_id="sess-1",+ answers={"q1": "Europe"},+ )+ with pytest.raises(ValueError):+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+++async def test_max_results_clamped_to_upper_bound():+ """Thread ED6B: max_results above MAX_RESULTS must be clamped."""+ input_data = SmartSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ query="engineers",+ max_results=999999,+ )+ _, mock_search = await _run_and_collect(input_data)+ assert mock_search.await_args.args[0]["max_results"] == MAX_RESULTS+++async def test_category_output_echoes_normalized_input_category():+ """Thread ED7H/ED57: category output must echo the (validated) input+ category, not raw API response data."""+ input_data = SmartSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ query="engineers",+ category="company",+ )+ outputs, _ = await _run_and_collect(input_data)+ assert outputs["category"] == "company"+++async def test_max_results_clamped_to_lower_bound():+ """max_results of 0 (or negative) must clamp up to 1, not reach the API as 0."""+ input_data = SmartSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ query="engineers",+ max_results=0,+ )+ _, mock_search = await _run_and_collect(input_data)+ assert mock_search.await_args.args[0]["max_results"] == 1+++async def test_success_status_is_passed_through_verbatim():+ """The live API returns status='complete' on success, not 'ok'. Verified+ against api.dataforb2b.ai on 2026-08-17. Graph authors branch on this+ value, so it must reach them unaltered rather than being normalized."""+ input_data = SmartSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ query="marketing directors",+ )+ outputs, _ = await _run_and_collect(+ input_data,+ response={"status": "complete", "total": 121, "results": [{"id": "1"}]},+ )+ assert outputs["status"] == "complete"diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/search.py b/autogpt_platform/backend/backend/blocks/dataforb2b/search.pynew file mode 100644index 0000000000..f492c9fc24--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/search.py@@ -0,0 +1,492 @@+from typing import Optional++from backend.blocks.dataforb2b._api import DataForB2BClient+from backend.blocks.dataforb2b._config import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_INPUT,+ DataForB2BCredentials,+ DataForB2BCredentialsInput,+ dataforb2b,+)+from backend.blocks.dataforb2b._enums import CompanyColumn, FilterOperator, PeopleColumn+from backend.blocks.dataforb2b._filters import build_slot_condition, finalize_filters+from backend.sdk import (+ Block,+ BlockCategory,+ BlockOutput,+ BlockSchemaInput,+ BlockSchemaOutput,+ SchemaField,+)++NUM_SLOTS = 5++# Conservative safety ceiling for `count`. DataForB2B's documented API limits+# are not verifiable from this repo, so this bounds memory/response size+# without blocking legitimate use — callers needing more results should+# paginate with `offset` instead of raising this cap.+MAX_COUNT = 100++# Shown as shadow text in the first filter slot so the expected shape of a value+# is obvious without opening the docs.+PEOPLE_VALUE_PLACEHOLDER = "e.g. Marketing Director"+COMPANY_VALUE_PLACEHOLDER = "e.g. software development"++TEXT_OPERATORS = {+ FilterOperator.EQUALS,+ FilterOperator.NOT_EQUALS,+ FilterOperator.LIKE,+ FilterOperator.NOT_LIKE,+ FilterOperator.IN,+ FilterOperator.NOT_IN,+}+SCALAR_OPERATORS = {+ FilterOperator.EQUALS,+ FilterOperator.NOT_EQUALS,+ FilterOperator.IN,+ FilterOperator.NOT_IN,+ FilterOperator.GREATER_THAN,+ FilterOperator.GREATER_OR_EQUAL,+ FilterOperator.LESS_THAN,+ FilterOperator.LESS_OR_EQUAL,+ FilterOperator.BETWEEN,+}+BOOLEAN_OPERATORS = {+ FilterOperator.EQUALS,+ FilterOperator.NOT_EQUALS,+ FilterOperator.IN,+ FilterOperator.NOT_IN,+}+NUMERIC_COLUMNS = {+ PeopleColumn.follower_count,+ PeopleColumn.current_company_size,+ PeopleColumn.years_in_current_position,+ PeopleColumn.years_at_current_company,+ PeopleColumn.past_company_size,+ PeopleColumn.years_at_past_company,+ PeopleColumn.years_of_experience,+ PeopleColumn.num_total_jobs,+ CompanyColumn.employee_count,+ CompanyColumn.employee_growth_1m,+ CompanyColumn.employee_growth_6m,+ CompanyColumn.employee_growth_12m,+ CompanyColumn.recent_hires_count,+ CompanyColumn.founded_year,+ CompanyColumn.follower_count,+ CompanyColumn.last_funding_amount_usd,+ CompanyColumn.last_funding_date,+}+BOOLEAN_COLUMNS = {+ PeopleColumn.current_company_has_funding,+ PeopleColumn.is_currently_employed,+ CompanyColumn.page_verified,+ CompanyColumn.has_funding,+}+++class _CommonSearchFields:+ """Fields shared by both search blocks (besides the column dropdowns)."""++ filters_json: dict = SchemaField(+ description=(+ "Escape hatch for filter shapes the slots cannot express, such as nested "+ "and/or groups. Paste 'applied_filters' from Smart Search here with an "+ "'offset' to paginate its results. Used alone, or merged (AND) with the "+ "filter slots above."+ ),+ default_factory=dict,+ advanced=True,+ )+ match: str = SchemaField(+ description="Combine slot conditions with 'and' or 'or'",+ default="and",+ advanced=True,+ )+ count: int = SchemaField(+ description=f"Number of results to return (1-{MAX_COUNT})",+ default=25,+ advanced=False,+ )+ offset: int = SchemaField(+ description="Pagination offset — 0 for page 1, then 25, 50, … to page through results",+ default=0,+ advanced=True,+ )+ enrich_live: bool = SchemaField(+ description="Fetch fresh live data (uses more credits)",+ default=False,+ advanced=True,+ )+++class _PeopleFilterFields(_CommonSearchFields):+ """Filter slots for people search — column is a PeopleColumn dropdown."""++ filter_1_column: Optional[PeopleColumn] = SchemaField(+ title="Filter 1 Column",+ description="Filter 1 column",+ default=None,+ advanced=False,+ )+ filter_1_operator: FilterOperator = SchemaField(+ title="Filter 1 Operator",+ description="Filter 1 operator",+ default=FilterOperator.EQUALS,+ advanced=False,+ )+ filter_1_value: str = SchemaField(+ title="Filter 1 Value",+ description=(+ "Filter 1 value. Search matches stored values exactly, so resolve it with "+ "Search Filter Typeahead rather than guessing"+ ),+ default="",+ placeholder=PEOPLE_VALUE_PLACEHOLDER,+ advanced=False,+ )+ filter_2_column: Optional[PeopleColumn] = SchemaField(+ title="Filter 2 Column",+ description="Filter 2 column",+ default=None,+ advanced=True,+ )+ filter_2_operator: FilterOperator = SchemaField(+ title="Filter 2 Operator",+ description="Filter 2 operator",+ default=FilterOperator.EQUALS,+ advanced=True,+ )+ filter_2_value: str = SchemaField(+ title="Filter 2 Value", description="Filter 2 value", default="", advanced=True+ )+ filter_3_column: Optional[PeopleColumn] = SchemaField(+ title="Filter 3 Column",+ description="Filter 3 column",+ default=None,+ advanced=True,+ )+ filter_3_operator: FilterOperator = SchemaField(+ title="Filter 3 Operator",+ description="Filter 3 operator",+ default=FilterOperator.EQUALS,+ advanced=True,+ )+ filter_3_value: str = SchemaField(+ title="Filter 3 Value", description="Filter 3 value", default="", advanced=True+ )+ filter_4_column: Optional[PeopleColumn] = SchemaField(+ title="Filter 4 Column",+ description="Filter 4 column",+ default=None,+ advanced=True,+ )+ filter_4_operator: FilterOperator = SchemaField(+ title="Filter 4 Operator",+ description="Filter 4 operator",+ default=FilterOperator.EQUALS,+ advanced=True,+ )+ filter_4_value: str = SchemaField(+ title="Filter 4 Value", description="Filter 4 value", default="", advanced=True+ )+ filter_5_column: Optional[PeopleColumn] = SchemaField(+ title="Filter 5 Column",+ description="Filter 5 column",+ default=None,+ advanced=True,+ )+ filter_5_operator: FilterOperator = SchemaField(+ title="Filter 5 Operator",+ description="Filter 5 operator",+ default=FilterOperator.EQUALS,+ advanced=True,+ )+ filter_5_value: str = SchemaField(+ title="Filter 5 Value", description="Filter 5 value", default="", advanced=True+ )+++class _CompanyFilterFields(_CommonSearchFields):+ """Filter slots for company search — column is a CompanyColumn dropdown."""++ filter_1_column: Optional[CompanyColumn] = SchemaField(+ title="Filter 1 Column",+ description="Filter 1 column",+ default=None,+ advanced=False,+ )+ filter_1_operator: FilterOperator = SchemaField(+ title="Filter 1 Operator",+ description="Filter 1 operator",+ default=FilterOperator.EQUALS,+ advanced=False,+ )+ filter_1_value: str = SchemaField(+ title="Filter 1 Value",+ description=(+ "Filter 1 value. Search matches stored values exactly, so resolve it with "+ "Search Filter Typeahead rather than guessing"+ ),+ default="",+ placeholder=COMPANY_VALUE_PLACEHOLDER,+ advanced=False,+ )+ filter_2_column: Optional[CompanyColumn] = SchemaField(+ title="Filter 2 Column",+ description="Filter 2 column",+ default=None,+ advanced=True,+ )+ filter_2_operator: FilterOperator = SchemaField(+ title="Filter 2 Operator",+ description="Filter 2 operator",+ default=FilterOperator.EQUALS,+ advanced=True,+ )+ filter_2_value: str = SchemaField(+ title="Filter 2 Value", description="Filter 2 value", default="", advanced=True+ )+ filter_3_column: Optional[CompanyColumn] = SchemaField(+ title="Filter 3 Column",+ description="Filter 3 column",+ default=None,+ advanced=True,+ )+ filter_3_operator: FilterOperator = SchemaField(+ title="Filter 3 Operator",+ description="Filter 3 operator",+ default=FilterOperator.EQUALS,+ advanced=True,+ )+ filter_3_value: str = SchemaField(+ title="Filter 3 Value", description="Filter 3 value", default="", advanced=True+ )+ filter_4_column: Optional[CompanyColumn] = SchemaField(+ title="Filter 4 Column",+ description="Filter 4 column",+ default=None,+ advanced=True,+ )+ filter_4_operator: FilterOperator = SchemaField(+ title="Filter 4 Operator",+ description="Filter 4 operator",+ default=FilterOperator.EQUALS,+ advanced=True,+ )+ filter_4_value: str = SchemaField(+ title="Filter 4 Value", description="Filter 4 value", default="", advanced=True+ )+ filter_5_column: Optional[CompanyColumn] = SchemaField(+ title="Filter 5 Column",+ description="Filter 5 column",+ default=None,+ advanced=True,+ )+ filter_5_operator: FilterOperator = SchemaField(+ title="Filter 5 Operator",+ description="Filter 5 operator",+ default=FilterOperator.EQUALS,+ advanced=True,+ )+ filter_5_value: str = SchemaField(+ title="Filter 5 Value", description="Filter 5 value", default="", advanced=True+ )+++def _validate_operator(+ column: Optional[PeopleColumn | CompanyColumn],+ operator: Optional[FilterOperator],+) -> None:+ if not column:+ return++ normalized_operator = operator or FilterOperator.EQUALS+ if column in BOOLEAN_COLUMNS:+ allowed = BOOLEAN_OPERATORS+ elif column in NUMERIC_COLUMNS:+ allowed = SCALAR_OPERATORS+ else:+ allowed = TEXT_OPERATORS++ if normalized_operator not in allowed:+ raise ValueError(+ f"Operator '{normalized_operator.value}' is not valid for column "+ f"'{column.value}'. Allowed operators: "+ f"{', '.join(sorted(op.value for op in allowed))}."+ )+++def _build_filters(input_data: _PeopleFilterFields | _CompanyFilterFields) -> dict:+ conditions: list[dict] = []+ for i in range(1, NUM_SLOTS + 1):+ column = getattr(input_data, f"filter_{i}_column")+ operator = getattr(input_data, f"filter_{i}_operator")+ value = getattr(input_data, f"filter_{i}_value")+ if column and value is not None and str(value).strip():+ _validate_operator(column, operator)+ cond = build_slot_condition(column, operator, value)+ if cond:+ conditions.append(cond)++ advanced = input_data.filters_json or None+ filters = finalize_filters(conditions, input_data.match, advanced)+ if not filters:+ raise ValueError(+ "Provide at least one filter slot (column + value) or filters_json."+ )+ return filters+++def _bounded_count_offset(input_data: _CommonSearchFields) -> tuple[int, int]:+ """Clamp count/offset to sane, non-negative bounds before calling the API."""+ count = max(1, min(int(input_data.count), MAX_COUNT))+ offset = max(0, int(input_data.offset))+ return count, offset+++class PeopleSearchBlock(Block):+ """Search LinkedIn people / B2B leads by structured filters with DataForB2B."""++ class Input(BlockSchemaInput, _PeopleFilterFields):+ credentials: DataForB2BCredentialsInput = dataforb2b.credentials_field(+ description="DataForB2B API key"+ )++ class Output(BlockSchemaOutput):+ result: dict = SchemaField(+ description="Full search response (total, count, results)"+ )+ results: list = SchemaField(+ description="List of matching LinkedIn people / leads", default_factory=list+ )+ total: int = SchemaField(description="Total number of matches", default=0)++ def __init__(self):+ super().__init__(+ id="91ded371-fe9f-432b-b0bd-d3788af485f8",+ description=(+ "Search people and B2B leads by structured filters — job title, company, "+ "location, industry, seniority, skills — using DataForB2B's database. "+ "Find employees at a company, people by job title, who works where, "+ "decision-makers and key contacts (owners, founders, C-suite, VPs, "+ "directors), and build a prospect or lead list. Accepts LinkedIn URLs as "+ "identifiers. The lead-sourcing step of a prospecting or outreach workflow."+ ),+ categories={BlockCategory.SEARCH, BlockCategory.SOCIAL, BlockCategory.CRM},+ input_schema=PeopleSearchBlock.Input,+ output_schema=PeopleSearchBlock.Output,+ test_credentials=TEST_CREDENTIALS,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "filter_1_column": PeopleColumn.current_title,+ "filter_1_operator": FilterOperator.LIKE,+ "filter_1_value": "software engineer",+ "count": 1,+ },+ test_output=[+ ("result", {"total": 1, "count": 1, "results": [{"id": "1"}]}),+ ("results", [{"id": "1"}]),+ ("total", 1),+ ],+ test_mock={+ "search_people": lambda payload, credentials: {+ "total": 1,+ "count": 1,+ "results": [{"id": "1"}],+ }+ },+ )++ @staticmethod+ async def search_people(payload: dict, credentials: DataForB2BCredentials) -> dict:+ client = DataForB2BClient(credentials)+ return await client.search_people(payload)++ async def run(+ self, input_data: Input, *, credentials: DataForB2BCredentials, **kwargs+ ) -> BlockOutput:+ count, offset = _bounded_count_offset(input_data)+ payload = {+ "filters": _build_filters(input_data),+ "count": count,+ "offset": offset,+ "enrich_live": bool(input_data.enrich_live),+ }+ data = await self.search_people(payload, credentials)+ yield "result", data+ yield "results", data.get("results", []) or []+ yield "total", data.get("total", 0)+++class CompanySearchBlock(Block):+ """Search LinkedIn companies by structured filters with DataForB2B."""++ class Input(BlockSchemaInput, _CompanyFilterFields):+ credentials: DataForB2BCredentialsInput = dataforb2b.credentials_field(+ description="DataForB2B API key"+ )++ class Output(BlockSchemaOutput):+ result: dict = SchemaField(+ description="Full search response (total, count, results)"+ )+ results: list = SchemaField(+ description="List of matching companies", default_factory=list+ )+ total: int = SchemaField(description="Total number of matches", default=0)++ def __init__(self):+ super().__init__(+ id="4041c618-b7b8-4b74-aa3d-5b7cb07d6b1d",+ description=(+ "Search companies and accounts by structured filters — industry, "+ "headcount/size, location, funding, keywords — using DataForB2B's "+ "database. Build target-account lists for B2B sales and account-based "+ "marketing. Accepts LinkedIn URLs as identifiers."+ ),+ categories={BlockCategory.SEARCH, BlockCategory.SOCIAL, BlockCategory.CRM},+ input_schema=CompanySearchBlock.Input,+ output_schema=CompanySearchBlock.Output,+ test_credentials=TEST_CREDENTIALS,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "filter_1_column": CompanyColumn.industry,+ "filter_1_operator": FilterOperator.LIKE,+ "filter_1_value": "software",+ "count": 1,+ },+ test_output=[+ ("result", {"total": 1, "count": 1, "results": [{"id": "1"}]}),+ ("results", [{"id": "1"}]),+ ("total", 1),+ ],+ test_mock={+ "search_companies": lambda payload, credentials: {+ "total": 1,+ "count": 1,+ "results": [{"id": "1"}],+ }+ },+ )++ @staticmethod+ async def search_companies(+ payload: dict, credentials: DataForB2BCredentials+ ) -> dict:+ client = DataForB2BClient(credentials)+ return await client.search_companies(payload)++ async def run(+ self, input_data: Input, *, credentials: DataForB2BCredentials, **kwargs+ ) -> BlockOutput:+ count, offset = _bounded_count_offset(input_data)+ payload = {+ "filters": _build_filters(input_data),+ "count": count,+ "offset": offset,+ "enrich_live": bool(input_data.enrich_live),+ }+ data = await self.search_companies(payload, credentials)+ yield "result", data+ yield "results", data.get("results", []) or []+ yield "total", data.get("total", 0)diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/search_test.py b/autogpt_platform/backend/backend/blocks/dataforb2b/search_test.pynew file mode 100644index 0000000000..2810e32be8--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/search_test.py@@ -0,0 +1,249 @@+"""Tests for PeopleSearchBlock / CompanySearchBlock: filter+validation and count/offset clamping, with mock assertions on the actual+payload sent to the API (not just the returned block outputs)."""++from unittest.mock import AsyncMock, patch++import pytest++from backend.blocks.dataforb2b._config import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_META_INPUT,+)+from backend.blocks.dataforb2b._enums import CompanyColumn, FilterOperator, PeopleColumn+from backend.blocks.dataforb2b.search import (+ MAX_COUNT,+ CompanySearchBlock,+ PeopleSearchBlock,+ _build_filters,+)+++async def test_build_filters_raises_without_slots_or_advanced_json():+ """Thread ED6T: no filter slots and no filters_json must raise a clear+ ValueError instead of sending an empty/invalid filter payload to the API."""+ block = PeopleSearchBlock()+ input_data = PeopleSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ )+ with pytest.raises(ValueError, match="at least one filter"):+ _build_filters(input_data)++ with pytest.raises(ValueError, match="at least one filter"):+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+++async def test_people_search_sends_full_filters_payload_to_api():+ """Thread ED6P: assert on the actual outgoing payload (filters/count/offset/+ enrich_live), not just the mocked return value."""+ block = PeopleSearchBlock()+ input_data = PeopleSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_1_column=PeopleColumn.current_title,+ filter_1_operator=FilterOperator.LIKE,+ filter_1_value="software engineer",+ count=5,+ offset=10,+ enrich_live=True,+ )+ with patch.object(+ PeopleSearchBlock,+ "search_people",+ new=AsyncMock(return_value={"total": 1, "count": 1, "results": [{"id": "1"}]}),+ ) as mock_search:+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass++ payload = mock_search.await_args.args[0]+ assert payload == {+ "filters": {+ "op": "and",+ "conditions": [+ {+ "column": "current_title",+ "type": "like",+ "value": "software engineer",+ }+ ],+ },+ "count": 5,+ "offset": 10,+ "enrich_live": True,+ }+++async def test_people_search_count_clamped_to_max():+ """Thread ED5-/DxBr: count above MAX_COUNT must be clamped, not sent raw."""+ block = PeopleSearchBlock()+ input_data = PeopleSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_1_column=PeopleColumn.current_title,+ filter_1_operator=FilterOperator.LIKE,+ filter_1_value="engineer",+ count=99999,+ )+ with patch.object(+ PeopleSearchBlock,+ "search_people",+ new=AsyncMock(return_value={"total": 0, "count": 0, "results": []}),+ ) as mock_search:+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+ assert mock_search.await_args.args[0]["count"] == MAX_COUNT+++async def test_people_search_offset_clamped_to_non_negative():+ block = PeopleSearchBlock()+ input_data = PeopleSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_1_column=PeopleColumn.current_title,+ filter_1_operator=FilterOperator.LIKE,+ filter_1_value="engineer",+ offset=-5,+ )+ with patch.object(+ PeopleSearchBlock,+ "search_people",+ new=AsyncMock(return_value={"total": 0, "count": 0, "results": []}),+ ) as mock_search:+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+ assert mock_search.await_args.args[0]["offset"] == 0+++async def test_company_search_raises_without_filters():+ """Thread ED6T (also applies to company search): same negative-path guard."""+ block = CompanySearchBlock()+ input_data = CompanySearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ )+ with pytest.raises(ValueError, match="at least one filter"):+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+++async def test_company_search_sends_full_filters_payload_to_api():+ block = CompanySearchBlock()+ input_data = CompanySearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_1_column=CompanyColumn.industry,+ filter_1_operator=FilterOperator.LIKE,+ filter_1_value="software",+ count=1,+ )+ with patch.object(+ CompanySearchBlock,+ "search_companies",+ new=AsyncMock(return_value={"total": 1, "count": 1, "results": [{"id": "1"}]}),+ ) as mock_search:+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+ payload = mock_search.await_args.args[0]+ assert payload["filters"] == {+ "op": "and",+ "conditions": [{"column": "industry", "type": "like", "value": "software"}],+ }+ assert payload["count"] == 1+ assert payload["offset"] == 0+ assert payload["enrich_live"] is False+++async def test_filters_json_alone_satisfies_filter_requirement():+ block = PeopleSearchBlock()+ input_data = PeopleSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filters_json={+ "op": "and",+ "conditions": [{"column": "x", "type": "=", "value": 1}],+ },+ )+ with patch.object(+ PeopleSearchBlock,+ "search_people",+ new=AsyncMock(return_value={"total": 0, "count": 0, "results": []}),+ ) as mock_search:+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+ assert mock_search.await_args.args[0]["filters"] == {+ "op": "and",+ "conditions": [{"column": "x", "type": "=", "value": 1}],+ }+++def test_empty_slot_does_not_validate_default_operator():+ input_data = PeopleSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_1_column=PeopleColumn.years_of_experience,+ filters_json={+ "op": "and",+ "conditions": [{"column": "current_title", "type": "like", "value": "cto"}],+ },+ )++ assert _build_filters(input_data) == input_data.filters_json+++ ("column", "operator"),+ [+ (PeopleColumn.is_currently_employed, FilterOperator.LIKE),+ (PeopleColumn.years_of_experience, FilterOperator.LIKE),+ (PeopleColumn.current_title, FilterOperator.GREATER_THAN),+ ],+)+def test_people_search_rejects_incompatible_column_operators(column, operator):+ input_data = PeopleSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_1_column=column,+ filter_1_operator=operator,+ filter_1_value="1",+ )++ with pytest.raises(ValueError, match="not valid for column"):+ _build_filters(input_data)+++ ("column", "operator"),+ [+ (CompanyColumn.page_verified, FilterOperator.LIKE),+ (CompanyColumn.employee_count, FilterOperator.LIKE),+ (CompanyColumn.industry, FilterOperator.BETWEEN),+ ],+)+def test_company_search_rejects_incompatible_column_operators(column, operator):+ input_data = CompanySearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_1_column=column,+ filter_1_operator=operator,+ filter_1_value="1",+ )++ with pytest.raises(ValueError, match="not valid for column"):+ _build_filters(input_data)+++def test_search_accepts_operator_compatible_with_column():+ input_data = PeopleSearchBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_1_column=PeopleColumn.years_of_experience,+ filter_1_operator=FilterOperator.BETWEEN,+ filter_1_value="3,7",+ )++ assert _build_filters(input_data)["conditions"] == [+ {+ "column": "years_of_experience",+ "type": "between",+ "value": 3,+ "value2": 7,+ }+ ]diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/typeahead.py b/autogpt_platform/backend/backend/blocks/dataforb2b/typeahead.pynew file mode 100644index 0000000000..96c5dc3f97--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/typeahead.py@@ -0,0 +1,102 @@+from backend.blocks.dataforb2b._api import DataForB2BClient+from backend.blocks.dataforb2b._config import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_INPUT,+ DataForB2BCredentials,+ DataForB2BCredentialsInput,+ dataforb2b,+)+from backend.blocks.dataforb2b._enums import TypeaheadType+from backend.sdk import (+ Block,+ BlockCategory,+ BlockOutput,+ BlockSchemaInput,+ BlockSchemaOutput,+ SchemaField,+)++# DataForB2B caps typeahead suggestions at 20 per call.+MAX_LIMIT = 20+++class SearchFilterTypeaheadBlock(Block):+ """Resolve the exact filter value for LinkedIn searches with DataForB2B."""++ class Input(BlockSchemaInput):+ filter_type: TypeaheadType = SchemaField(+ title="Filter Type",+ description="Filter type to resolve. Industry is split per-side: use people_industry for People Search and company_industry for Company Search",+ advanced=False,+ )+ q: str = SchemaField(description="Free-text query to resolve", advanced=False)+ limit: int = SchemaField(+ description=f"Max suggestions (1-{MAX_LIMIT})",+ default=MAX_LIMIT,+ advanced=False,+ )+ credentials: DataForB2BCredentialsInput = dataforb2b.credentials_field(+ description="DataForB2B API key"+ )++ class Output(BlockSchemaOutput):+ result: dict = SchemaField(description="Full typeahead response")+ results: list[dict] = SchemaField(+ description="List of suggestions", default_factory=list+ )+ values: list[str] = SchemaField(+ description="Resolved stored values", default_factory=list+ )++ def __init__(self):+ super().__init__(+ id="554b0945-a2f7-4ee0-bee5-1ffb298a2e30",+ description=(+ "Resolve the exact filter value (company, industry, job title, skill, "+ "school, investor, location, category) for people and company searches "+ "with DataForB2B."+ ),+ categories={BlockCategory.SEARCH, BlockCategory.SOCIAL},+ input_schema=SearchFilterTypeaheadBlock.Input,+ output_schema=SearchFilterTypeaheadBlock.Output,+ test_credentials=TEST_CREDENTIALS,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "filter_type": "company",+ "q": "google",+ "limit": 3,+ },+ test_output=[+ ("result", {"results": [{"value": "Google"}]}),+ ("results", [{"value": "Google"}]),+ ("values", ["Google"]),+ ],+ test_mock={+ "typeahead": lambda type_, q, limit, credentials: {+ "results": [{"value": "Google"}]+ }+ },+ )++ @staticmethod+ async def typeahead(+ type_: str, q: str, limit: int, credentials: DataForB2BCredentials+ ) -> dict:+ client = DataForB2BClient(credentials)+ return await client.typeahead(type_, q, limit)++ async def run(+ self, input_data: Input, *, credentials: DataForB2BCredentials, **kwargs+ ) -> BlockOutput:+ query = input_data.q.strip()+ if not query:+ raise ValueError("'q' (query) is required.")++ limit = max(1, min(int(input_data.limit), MAX_LIMIT))+ data = await self.typeahead(+ input_data.filter_type.value, query, limit, credentials+ )+ results = data.get("results", []) or []+ yield "result", data+ yield "results", results+ yield "values", [r.get("value") for r in results if r.get("value")]diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/typeahead_test.py b/autogpt_platform/backend/backend/blocks/dataforb2b/typeahead_test.pynew file mode 100644index 0000000000..4df7eb7a6a--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/typeahead_test.py@@ -0,0 +1,135 @@+"""Tests for SearchFilterTypeaheadBlock.run() input validation and limit clamping."""++import json+from unittest.mock import AsyncMock, patch++import pytest+from pytest_snapshot.plugin import Snapshot++from backend.blocks.dataforb2b._config import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_META_INPUT,+)+from backend.blocks.dataforb2b._enums import TypeaheadType+from backend.blocks.dataforb2b.typeahead import SearchFilterTypeaheadBlock+++async def _run_and_capture(block: SearchFilterTypeaheadBlock, input_data):+ """Run the block with a mocked client, returning (outputs, call_args)."""+ outputs = {}+ with patch.object(+ SearchFilterTypeaheadBlock,+ "typeahead",+ new=AsyncMock(return_value={"results": [{"value": "Google"}]}),+ ) as mock_typeahead:+ async for name, value in block.run(input_data, credentials=TEST_CREDENTIALS):+ outputs[name] = value+ return outputs, mock_typeahead+++async def test_missing_query_raises_value_error():+ """Thread ED6e: missing 'q' should raise a clear ValueError, not an API 400."""+ block = SearchFilterTypeaheadBlock()+ input_data = SearchFilterTypeaheadBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_type=TypeaheadType.COMPANY,+ q="",+ limit=5,+ )+ with pytest.raises(ValueError, match="'q'"):+ async for _ in block.run(input_data, credentials=TEST_CREDENTIALS):+ pass+++async def test_limit_clamped_to_upper_bound(snapshot: Snapshot):+ """Thread ED6e: limit above 20 must be clamped, not passed through raw."""+ block = SearchFilterTypeaheadBlock()+ input_data = SearchFilterTypeaheadBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_type=TypeaheadType.COMPANY,+ q="google",+ limit=999,+ )+ outputs, mock_typeahead = await _run_and_capture(block, input_data)+ assert mock_typeahead.await_args.args[2] == 20+ assert outputs["values"] == ["Google"]+ snapshot.snapshot_dir = "snapshots"+ snapshot.assert_match(+ json.dumps(outputs, indent=2, sort_keys=True),+ "typeahead_outputs",+ )+++async def test_limit_clamped_to_lower_bound():+ """Thread ED6e: limit of 0 or negative must be clamped up to at least 1."""+ block = SearchFilterTypeaheadBlock()+ input_data = SearchFilterTypeaheadBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_type=TypeaheadType.COMPANY,+ q="google",+ limit=0,+ )+ _, mock_typeahead = await _run_and_capture(block, input_data)+ assert mock_typeahead.await_args.args[2] == 1+++async def test_type_is_validated_enum():+ """Thread ED7M/ED64: 'type' is a closed enum, invalid values are rejected."""+ with pytest.raises(ValueError):+ SearchFilterTypeaheadBlock.Input.model_validate(+ {+ "credentials": TEST_CREDENTIALS_META_INPUT,+ "filter_type": "not-a-real-type",+ "q": "google",+ }+ )+++async def test_results_without_value_are_excluded_from_values():+ """'values' is the caller-facing list of resolved strings, so malformed+ suggestions missing 'value' must be dropped rather than yielding None."""+ block = SearchFilterTypeaheadBlock()+ input_data = SearchFilterTypeaheadBlock.Input(+ credentials=TEST_CREDENTIALS_META_INPUT,+ filter_type=TypeaheadType.COMPANY,+ q="google",+ limit=5,+ )+ outputs = {}+ with patch.object(+ SearchFilterTypeaheadBlock,+ "typeahead",+ new=AsyncMock(+ return_value={"results": [{"value": "Google"}, {"label": "no value here"}]}+ ),+ ):+ async for name, value in block.run(input_data, credentials=TEST_CREDENTIALS):+ outputs[name] = value++ assert outputs["values"] == ["Google"]+ assert len(outputs["results"]) == 2+++def test_filter_type_enum_matches_api_accepted_values():+ """The /typeahead `type` enum is a closed server-side set; sending a value+ outside it is a 422, not an empty result. Verified against the live API on+ 2026-08-17 — `industry` was in this enum and is NOT accepted upstream, so+ pin the set rather than trusting the dropdown to stay plausible."""+ assert {t.value for t in TypeaheadType} == {+ "company",+ "people_industry",+ "company_industry",+ "category",+ "location",+ "city",+ "region",+ "school",+ "title",+ "skill",+ "investor",+ }diff --git a/autogpt_platform/backend/scripts/generate_block_docs.py b/autogpt_platform/backend/scripts/generate_block_docs.pyindex baefffaa4b..fa82712594 100644--- a/autogpt_platform/backend/scripts/generate_block_docs.py+++ b/autogpt_platform/backend/scripts/generate_block_docs.py@@ -232,6 +232,7 @@ def file_path_to_title(file_path: str) -> str:"Linkedin": "LinkedIn","Tiktok": "TikTok","Youtube": "YouTube",+ "Dataforb2B": "DataForB2B",}def apply_fixes(text: str) -> str:diff --git a/autogpt_platform/backend/snapshots/smart_search_needs_input_outputs b/autogpt_platform/backend/snapshots/smart_search_needs_input_outputsnew file mode 100644index 0000000000..e3885d4dfc--- /dev/null+++ b/autogpt_platform/backend/snapshots/smart_search_needs_input_outputs@@ -0,0 +1,23 @@+{+ "applied_filters": {},+ "category": "people",+ "questions": [+ {+ "id": "q1",+ "text": "Which region?"+ }+ ],+ "result": {+ "questions": [+ {+ "id": "q1",+ "text": "Which region?"+ }+ ],+ "session_id": "sess-1",+ "status": "needs_input"+ },+ "results": [],+ "session_id": "sess-1",+ "status": "needs_input"+}\ No newline at end of filediff --git a/autogpt_platform/backend/snapshots/typeahead_outputs b/autogpt_platform/backend/snapshots/typeahead_outputsnew file mode 100644index 0000000000..f5fcb79bbd--- /dev/null+++ b/autogpt_platform/backend/snapshots/typeahead_outputs@@ -0,0 +1,17 @@+{+ "result": {+ "results": [+ {+ "value": "Google"+ }+ ]+ },+ "results": [+ {+ "value": "Google"+ }+ ],+ "values": [+ "Google"+ ]+}\ No newline at end of filediff --git a/docs/integrations/README.md b/docs/integrations/README.mdindex 3e3900df74..00c9e58211 100644--- a/docs/integrations/README.md+++ b/docs/integrations/README.md@@ -237,6 +237,7 @@ Below is a comprehensive list of all available blocks, categorized by their prim| [Perplexity](block-integrations/llm.md#perplexity) | Query Perplexity's sonar models with real-time web search capabilities and receive annotated responses with source citations || [Replicate Flux Advanced Model](block-integrations/replicate/flux_advanced.md#replicate-flux-advanced-model) | This block runs Flux models on Replicate with advanced settings || [Replicate Model](block-integrations/replicate/replicate_block.md#replicate-model) | Run Replicate models synchronously |+| [Smart Search](block-integrations/dataforb2b/reasoning.md#smart-search) | Natural-language search for people, leads or companies using DataForB2B's B2B database — describe your ideal lead or ICP in plain English and get matching profiles || [Stagehand Act](block-integrations/stagehand/blocks.md#stagehand-act) | Interact with a web page by performing actions on a web page || [Stagehand Extract](block-integrations/stagehand/blocks.md#stagehand-extract) | Extract structured data from a webpage || [Stagehand Observe](block-integrations/stagehand/blocks.md#stagehand-observe) | Find suggested actions for your workflows |@@ -295,6 +296,7 @@ Below is a comprehensive list of all available blocks, categorized by their prim| [Get Person Detail](block-integrations/apollo/person.md#get-person-detail) | Get detailed person data with Apollo API, including email reveal || [Get Wikipedia Summary](block-integrations/search.md#get-wikipedia-summary) | This block fetches the summary of a given topic from Wikipedia || [Google Maps Search](block-integrations/search.md#google-maps-search) | This block searches for local businesses using Google Maps API |+| [Search Filter Typeahead](block-integrations/dataforb2b/typeahead.md#search-filter-typeahead) | Resolve the exact filter value (company, industry, job title, skill, school, investor, location, category) for people and company searches with DataForB2B || [Search Organizations](block-integrations/apollo/organization.md#search-organizations) | Search for organizations in Apollo || [Search People](block-integrations/apollo/people.md#search-people) | Search for people in Apollo || [Search The Web](block-integrations/jina/search.md#search-the-web) | This block searches the internet for the given search query |@@ -631,9 +633,13 @@ Below is a comprehensive list of all available blocks, categorized by their prim| Block Name | Description ||------------|-------------|| [Add Lead To Campaign](block-integrations/smartlead/campaign.md#add-lead-to-campaign) | Add a lead to a campaign in SmartLead |+| [Company Enrichment](block-integrations/dataforb2b/enrich.md#company-enrichment) | Look up and enrich a company using DataForB2B's B2B database — firmographics, headcount/size, industry, domain and social profiles from a company domain, name or LinkedIn URL |+| [Company Search](block-integrations/dataforb2b/search.md#company-search) | Search companies and accounts by structured filters — industry, headcount/size, location, funding, keywords — using DataForB2B's database || [Create Campaign](block-integrations/smartlead/campaign.md#create-campaign) | Create a campaign in SmartLead || [Hub Spot Company](block-integrations/hubspot/company.md#hub-spot-company) | Manages HubSpot companies - create, update, and retrieve company information || [Hub Spot Contact](block-integrations/hubspot/contact.md#hub-spot-contact) | Manages HubSpot contacts - create, update, and retrieve contact information |+| [People Search](block-integrations/dataforb2b/search.md#people-search) | Search people and B2B leads by structured filters — job title, company, location, industry, seniority, skills — using DataForB2B's database |+| [Profile Enrichment](block-integrations/dataforb2b/enrich.md#profile-enrichment) | Look up and enrich a professional profile from a LinkedIn URL using DataForB2B's B2B database — returns the full profile (current role, experience and skills) plus work email, personal email and GitHub || [Save Campaign Sequences](block-integrations/smartlead/campaign.md#save-campaign-sequences) | Save sequences within a campaign |## AI Safetydiff --git a/docs/integrations/SUMMARY.md b/docs/integrations/SUMMARY.mdindex b3a3a73bb1..efcfaa00cf 100644--- a/docs/integrations/SUMMARY.md+++ b/docs/integrations/SUMMARY.md@@ -41,6 +41,10 @@* [Basic](block-integrations/basic.md)* [Compass Triggers](block-integrations/compass/triggers.md)* [Data](block-integrations/data.md)+* [DataForB2B Enrich](block-integrations/dataforb2b/enrich.md)+* [DataForB2B Reasoning](block-integrations/dataforb2b/reasoning.md)+* [DataForB2B Search](block-integrations/dataforb2b/search.md)+* [DataForB2B Typeahead](block-integrations/dataforb2b/typeahead.md)* [Dataforseo Keyword Suggestions](block-integrations/dataforseo/keyword_suggestions.md)* [Dataforseo Related Keywords](block-integrations/dataforseo/related_keywords.md)* [Discord Bot Blocks](block-integrations/discord/bot_blocks.md)diff --git a/docs/integrations/block-integrations/dataforb2b/enrich.md b/docs/integrations/block-integrations/dataforb2b/enrich.mdnew file mode 100644index 0000000000..e69d2dd41c--- /dev/null+++ b/docs/integrations/block-integrations/dataforb2b/enrich.md@@ -0,0 +1,76 @@+# DataForB2B Enrich+<!-- MANUAL: file_description -->+Blocks for enriching companies and LinkedIn profiles using DataForB2B's B2B database — firmographics, headcount, work/personal email, phone, and GitHub discovery.+<!-- END MANUAL -->++## Company Enrichment++### What it is+Look up and enrich a company using DataForB2B's B2B database — firmographics, headcount/size, industry, domain and social profiles from a company domain, name or LinkedIn URL. Account enrichment for B2B sales and CRM.++### How it works+<!-- MANUAL: how_it_works -->+The block trims the provided `company_identifier` and rejects empty values before sending it to DataForB2B's company enrichment endpoint. The API resolves the identifier (domain, name, or LinkedIn company URL) against its B2B database and returns firmographic data such as industry, headcount, funding, and social profiles. Client and server errors from the API are caught and surfaced via the `error` output instead of raising an exception; identifiers that cannot be resolved may return an empty result.+<!-- END MANUAL -->++### Inputs++| Input | Description | Type | Required |+|-------|-------------|------|----------|+| company_identifier | Company domain, name, or LinkedIn URL to enrich | str | Yes |++### Outputs++| Output | Description | Type |+|--------|-------------|------|+| error | Error message if the operation failed | str |+| result | Full company enrichment response | Dict[str, Any] |++### Possible use case+<!-- MANUAL: use_case -->+**Account Enrichment**: Enrich inbound leads or CRM records with firmographic data before routing them to sales.++**Target Account Research**: Pull company size, industry, and funding stage to qualify accounts for an ABM campaign.++**CRM Cleanup**: Resolve a company domain or LinkedIn URL into current firmographic data before deduplicating records.+<!-- END MANUAL -->++---++## Profile Enrichment++### What it is+Look up and enrich a professional profile from a LinkedIn URL using DataForB2B's B2B database — returns the full profile (current role, experience and skills) plus work email, personal email and GitHub. Works as an email finder for lead enrichment, contact enrichment, cold outreach and CRM. Disable enrich_profile if you only need the email/GitHub lookups.++### How it works+<!-- MANUAL: how_it_works -->+The block trims the provided `profile_identifier` (a LinkedIn profile URL or id) and rejects empty values before sending it to DataForB2B's profile enrichment endpoint along with the requested `enrich_*` flags. `enrich_profile` is enabled by default and returns the full profile; when every flag is false, the block enables `enrich_profile` so the API still receives a valid request. Client and server errors from the API are caught and surfaced via the `error` output instead of raising an exception; unavailable contact fields may be absent from the result.+<!-- END MANUAL -->++### Inputs++| Input | Description | Type | Required |+|-------|-------------|------|----------|+| profile_identifier | LinkedIn profile URL (or profile id) to enrich | str | Yes |+| enrich_profile | Return the full LinkedIn profile (role, experience, skills) | bool | No |+| enrich_work_email | Find the professional / work email | bool | No |+| enrich_personal_email | Find the personal email | bool | No |+| enrich_github | Find the GitHub profile | bool | No |++### Outputs++| Output | Description | Type |+|--------|-------------|------|+| error | Error message if the operation failed | str |+| result | Full enrichment response | Dict[str, Any] |++### Possible use case+<!-- MANUAL: use_case -->+**Email Finder**: Resolve a work or personal email address from a LinkedIn profile URL for cold outreach.++**Lead Enrichment**: Enrich a prospect list with current role, experience, and skills pulled straight from LinkedIn.++**Contact Verification**: Refresh a saved contact from a LinkedIn profile URL before routing it into an outreach sequence.+<!-- END MANUAL -->++---diff --git a/docs/integrations/block-integrations/dataforb2b/reasoning.md b/docs/integrations/block-integrations/dataforb2b/reasoning.mdnew file mode 100644index 0000000000..0fcb4a828e--- /dev/null+++ b/docs/integrations/block-integrations/dataforb2b/reasoning.md@@ -0,0 +1,49 @@+# DataForB2B Reasoning+<!-- MANUAL: file_description -->+Natural-language, LLM-friendly search over DataForB2B's B2B database — describe the people or companies you're looking for in plain English instead of building structured filters by hand.+<!-- END MANUAL -->++## Smart Search++### What it is+Natural-language search for people, leads or companies using DataForB2B's B2B database — describe your ideal lead or ICP in plain English and get matching profiles. Handles clarifying questions.++### How it works+<!-- MANUAL: how_it_works -->+The block sends either a natural-language `query` or a continuation pair of `session_id` and `answers` to DataForB2B's reasoning-search endpoint; mixed or incomplete request modes are rejected. The API translates the query into structured filters and may return `status: needs_input` with `questions` and a `session_id` for a follow-up call. On success, copy `applied_filters` into People Search or Company Search's `filters_json` input and set `offset` to paginate beyond the first page; a `complete` response may still contain an empty `results` list. Client and server errors are caught and surfaced via the `error` output instead of raising an exception.+<!-- END MANUAL -->++### Inputs++| Input | Description | Type | Required |+|-------|-------------|------|----------|+| query | Plain-English LinkedIn search / ICP (e.g. 'marketing directors at Series A SaaS startups in France') | str | No |+| category | What to search for: 'people' or 'company' | "people" \| "company" | No |+| session_id | Session id to resolve a previous 'needs_input' turn | str | No |+| answers | Answers to clarifying questions {question_id: answer} | Dict[str, Any] | No |+| max_results | Maximum results to return (1-100) | int | No |+| enrich_live | Fetch fresh live data (uses more credits) | bool | No |++### Outputs++| Output | Description | Type |+|--------|-------------|------|+| error | Error message if the operation failed | str |+| result | Full reasoning-search response | Dict[str, Any] |+| status | 'complete' or 'needs_input' | str |+| results | Matching results when status is complete | List[Any] |+| questions | Clarifying questions when status is needs_input | List[Any] |+| session_id | Session id to continue the search | str |+| applied_filters | The structured filters the search applied. Feed this into People Search or Company Search 'filters_json' with an offset to paginate beyond the first page. | Dict[str, Any] |+| category | Category searched ('people' or 'company', echoed from the input) — route pagination to the matching search block | str |++### Possible use case+<!-- MANUAL: use_case -->+**Conversational Lead Sourcing**: Let an agent describe an ICP in plain English (e.g. "marketing directors at Series A SaaS startups in France") and resolve it into a structured search without manually building filters.++**Multi-Turn Refinement**: Handle ambiguous requests by answering clarifying questions returned by the API, then continue the same session to completion.++**Search Handoff**: Reuse `applied_filters` in People Search or Company Search to paginate a natural-language result set.+<!-- END MANUAL -->++---diff --git a/docs/integrations/block-integrations/dataforb2b/search.md b/docs/integrations/block-integrations/dataforb2b/search.mdnew file mode 100644index 0000000000..749d74c20b--- /dev/null+++ b/docs/integrations/block-integrations/dataforb2b/search.md@@ -0,0 +1,114 @@+# DataForB2B Search+<!-- MANUAL: file_description -->+Blocks for searching companies and people by structured filters using DataForB2B's B2B database — build target-account and prospect lists for sales, recruiting, and account-based marketing.+<!-- END MANUAL -->++## Company Search++### What it is+Search companies and accounts by structured filters — industry, headcount/size, location, funding, keywords — using DataForB2B's database. Build target-account lists for B2B sales and account-based marketing. Accepts LinkedIn URLs as identifiers.++### How it works+<!-- MANUAL: how_it_works -->+Up to five filter slots (`filter_1_column`/`filter_1_operator`/`filter_1_value` through `filter_5_*`) are validated and combined with `and`/`or` per `match`, or you can pass a raw `filters_json` (optionally the `applied_filters` output from Smart Search) which is merged with the slot filters via AND. Filter values are matched against stored taxonomy values, so resolve them with Search Filter Typeahead rather than guessing: `industry` is `software development`, not `software`. Numeric, boolean, and text columns reject incompatible operators (`=` is accepted on every column, which is why it is the default); `between` requires exactly two comma-separated values. Results are paginated with `count` (clamped to 1-100) and non-negative `offset`. Client and server errors are surfaced via `error`, while a valid search with no matches returns an empty `results` list.+<!-- END MANUAL -->++### Inputs++| Input | Description | Type | Required |+|-------|-------------|------|----------|+| filters_json | Escape hatch for filter shapes the slots cannot express, such as nested and/or groups. Paste 'applied_filters' from Smart Search here with an 'offset' to paginate its results. Used alone, or merged (AND) with the filter slots above. | Dict[str, Any] | No |+| match | Combine slot conditions with 'and' or 'or' | str | No |+| count | Number of results to return (1-100) | int | No |+| offset | Pagination offset — 0 for page 1, then 25, 50, … to page through results | int | No |+| enrich_live | Fetch fresh live data (uses more credits) | bool | No |+| filter_1_column | Filter 1 column | "name" \| "tagline" \| "description" \| "domain" \| "universal_name" \| "keyword" \| "industry" \| "employee_count" \| "country_iso_code" \| "city" \| "region" \| "office_country" \| "office_city" \| "office_region" \| "employee_growth_1m" \| "employee_growth_6m" \| "employee_growth_12m" \| "recent_hires_count" \| "founded_year" \| "company_type" \| "follower_count" \| "page_verified" \| "category" \| "last_funding_amount_usd" \| "last_funding_date" \| "funding_stage_normalized" \| "has_funding" | No |+| filter_1_operator | Filter 1 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_1_value | Filter 1 value. Search matches stored values exactly, so resolve it with Search Filter Typeahead rather than guessing | str | No |+| filter_2_column | Filter 2 column | "name" \| "tagline" \| "description" \| "domain" \| "universal_name" \| "keyword" \| "industry" \| "employee_count" \| "country_iso_code" \| "city" \| "region" \| "office_country" \| "office_city" \| "office_region" \| "employee_growth_1m" \| "employee_growth_6m" \| "employee_growth_12m" \| "recent_hires_count" \| "founded_year" \| "company_type" \| "follower_count" \| "page_verified" \| "category" \| "last_funding_amount_usd" \| "last_funding_date" \| "funding_stage_normalized" \| "has_funding" | No |+| filter_2_operator | Filter 2 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_2_value | Filter 2 value | str | No |+| filter_3_column | Filter 3 column | "name" \| "tagline" \| "description" \| "domain" \| "universal_name" \| "keyword" \| "industry" \| "employee_count" \| "country_iso_code" \| "city" \| "region" \| "office_country" \| "office_city" \| "office_region" \| "employee_growth_1m" \| "employee_growth_6m" \| "employee_growth_12m" \| "recent_hires_count" \| "founded_year" \| "company_type" \| "follower_count" \| "page_verified" \| "category" \| "last_funding_amount_usd" \| "last_funding_date" \| "funding_stage_normalized" \| "has_funding" | No |+| filter_3_operator | Filter 3 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_3_value | Filter 3 value | str | No |+| filter_4_column | Filter 4 column | "name" \| "tagline" \| "description" \| "domain" \| "universal_name" \| "keyword" \| "industry" \| "employee_count" \| "country_iso_code" \| "city" \| "region" \| "office_country" \| "office_city" \| "office_region" \| "employee_growth_1m" \| "employee_growth_6m" \| "employee_growth_12m" \| "recent_hires_count" \| "founded_year" \| "company_type" \| "follower_count" \| "page_verified" \| "category" \| "last_funding_amount_usd" \| "last_funding_date" \| "funding_stage_normalized" \| "has_funding" | No |+| filter_4_operator | Filter 4 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_4_value | Filter 4 value | str | No |+| filter_5_column | Filter 5 column | "name" \| "tagline" \| "description" \| "domain" \| "universal_name" \| "keyword" \| "industry" \| "employee_count" \| "country_iso_code" \| "city" \| "region" \| "office_country" \| "office_city" \| "office_region" \| "employee_growth_1m" \| "employee_growth_6m" \| "employee_growth_12m" \| "recent_hires_count" \| "founded_year" \| "company_type" \| "follower_count" \| "page_verified" \| "category" \| "last_funding_amount_usd" \| "last_funding_date" \| "funding_stage_normalized" \| "has_funding" | No |+| filter_5_operator | Filter 5 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_5_value | Filter 5 value | str | No |++### Outputs++| Output | Description | Type |+|--------|-------------|------|+| error | Error message if the operation failed | str |+| result | Full search response (total, count, results) | Dict[str, Any] |+| results | List of matching companies | List[Any] |+| total | Total number of matches | int |++### Possible use case+<!-- MANUAL: use_case -->+**Target Account Lists**: Build a list of companies matching industry, size, and location criteria for account-based marketing.++**Market Sizing**: Estimate the number of companies matching a given ICP before launching an outbound campaign.++**Funding Research**: Find companies at a particular funding stage or backed by a target investor.+<!-- END MANUAL -->++---++## People Search++### What it is+Search people and B2B leads by structured filters — job title, company, location, industry, seniority, skills — using DataForB2B's database. Find employees at a company, people by job title, who works where, decision-makers and key contacts (owners, founders, C-suite, VPs, directors), and build a prospect or lead list. Accepts LinkedIn URLs as identifiers. The lead-sourcing step of a prospecting or outreach workflow.++### How it works+<!-- MANUAL: how_it_works -->+Up to five filter slots (`filter_1_column`/`filter_1_operator`/`filter_1_value` through `filter_5_*`) are validated and combined with `and`/`or` per `match`, or you can pass a raw `filters_json` (optionally the `applied_filters` output from Smart Search) which is merged with the slot filters via AND. Filter values are matched against stored taxonomy values, so resolve them with Search Filter Typeahead rather than guessing: `industry` is `software development`, not `software`. Numeric, boolean, and text columns reject incompatible operators (`=` is accepted on every column, which is why it is the default); `between` requires exactly two comma-separated values. Results are paginated with `count` (clamped to 1-100) and non-negative `offset`. Client and server errors are surfaced via `error`, while a valid search with no matches returns an empty `results` list.+<!-- END MANUAL -->++### Inputs++| Input | Description | Type | Required |+|-------|-------------|------|----------|+| filters_json | Escape hatch for filter shapes the slots cannot express, such as nested and/or groups. Paste 'applied_filters' from Smart Search here with an 'offset' to paginate its results. Used alone, or merged (AND) with the filter slots above. | Dict[str, Any] | No |+| match | Combine slot conditions with 'and' or 'or' | str | No |+| count | Number of results to return (1-100) | int | No |+| offset | Pagination offset — 0 for page 1, then 25, 50, … to page through results | int | No |+| enrich_live | Fetch fresh live data (uses more credits) | bool | No |+| filter_1_column | Filter 1 column | "first_name" \| "last_name" \| "profile_location" \| "profile_country" \| "profile_industry" \| "follower_count" \| "keyword" \| "current_company" \| "current_title" \| "current_job_location" \| "current_company_industry" \| "current_company_category" \| "current_company_size" \| "current_company_id" \| "current_employment_type" \| "years_in_current_position" \| "years_at_current_company" \| "current_company_has_funding" \| "current_company_funding_stage" \| "current_company_investor" \| "past_company" \| "past_title" \| "past_job_location" \| "past_company_industry" \| "past_company_size" \| "past_company_id" \| "past_employment_type" \| "years_at_past_company" \| "skill" \| "school" \| "degree" \| "degree_level" \| "field_of_study" \| "language" \| "language_iso" \| "language_proficiency" \| "certification" \| "certification_authority" \| "years_of_experience" \| "num_total_jobs" \| "is_currently_employed" | No |+| filter_1_operator | Filter 1 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_1_value | Filter 1 value. Search matches stored values exactly, so resolve it with Search Filter Typeahead rather than guessing | str | No |+| filter_2_column | Filter 2 column | "first_name" \| "last_name" \| "profile_location" \| "profile_country" \| "profile_industry" \| "follower_count" \| "keyword" \| "current_company" \| "current_title" \| "current_job_location" \| "current_company_industry" \| "current_company_category" \| "current_company_size" \| "current_company_id" \| "current_employment_type" \| "years_in_current_position" \| "years_at_current_company" \| "current_company_has_funding" \| "current_company_funding_stage" \| "current_company_investor" \| "past_company" \| "past_title" \| "past_job_location" \| "past_company_industry" \| "past_company_size" \| "past_company_id" \| "past_employment_type" \| "years_at_past_company" \| "skill" \| "school" \| "degree" \| "degree_level" \| "field_of_study" \| "language" \| "language_iso" \| "language_proficiency" \| "certification" \| "certification_authority" \| "years_of_experience" \| "num_total_jobs" \| "is_currently_employed" | No |+| filter_2_operator | Filter 2 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_2_value | Filter 2 value | str | No |+| filter_3_column | Filter 3 column | "first_name" \| "last_name" \| "profile_location" \| "profile_country" \| "profile_industry" \| "follower_count" \| "keyword" \| "current_company" \| "current_title" \| "current_job_location" \| "current_company_industry" \| "current_company_category" \| "current_company_size" \| "current_company_id" \| "current_employment_type" \| "years_in_current_position" \| "years_at_current_company" \| "current_company_has_funding" \| "current_company_funding_stage" \| "current_company_investor" \| "past_company" \| "past_title" \| "past_job_location" \| "past_company_industry" \| "past_company_size" \| "past_company_id" \| "past_employment_type" \| "years_at_past_company" \| "skill" \| "school" \| "degree" \| "degree_level" \| "field_of_study" \| "language" \| "language_iso" \| "language_proficiency" \| "certification" \| "certification_authority" \| "years_of_experience" \| "num_total_jobs" \| "is_currently_employed" | No |+| filter_3_operator | Filter 3 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_3_value | Filter 3 value | str | No |+| filter_4_column | Filter 4 column | "first_name" \| "last_name" \| "profile_location" \| "profile_country" \| "profile_industry" \| "follower_count" \| "keyword" \| "current_company" \| "current_title" \| "current_job_location" \| "current_company_industry" \| "current_company_category" \| "current_company_size" \| "current_company_id" \| "current_employment_type" \| "years_in_current_position" \| "years_at_current_company" \| "current_company_has_funding" \| "current_company_funding_stage" \| "current_company_investor" \| "past_company" \| "past_title" \| "past_job_location" \| "past_company_industry" \| "past_company_size" \| "past_company_id" \| "past_employment_type" \| "years_at_past_company" \| "skill" \| "school" \| "degree" \| "degree_level" \| "field_of_study" \| "language" \| "language_iso" \| "language_proficiency" \| "certification" \| "certification_authority" \| "years_of_experience" \| "num_total_jobs" \| "is_currently_employed" | No |+| filter_4_operator | Filter 4 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_4_value | Filter 4 value | str | No |+| filter_5_column | Filter 5 column | "first_name" \| "last_name" \| "profile_location" \| "profile_country" \| "profile_industry" \| "follower_count" \| "keyword" \| "current_company" \| "current_title" \| "current_job_location" \| "current_company_industry" \| "current_company_category" \| "current_company_size" \| "current_company_id" \| "current_employment_type" \| "years_in_current_position" \| "years_at_current_company" \| "current_company_has_funding" \| "current_company_funding_stage" \| "current_company_investor" \| "past_company" \| "past_title" \| "past_job_location" \| "past_company_industry" \| "past_company_size" \| "past_company_id" \| "past_employment_type" \| "years_at_past_company" \| "skill" \| "school" \| "degree" \| "degree_level" \| "field_of_study" \| "language" \| "language_iso" \| "language_proficiency" \| "certification" \| "certification_authority" \| "years_of_experience" \| "num_total_jobs" \| "is_currently_employed" | No |+| filter_5_operator | Filter 5 operator | "=" \| "!=" \| "like" \| "not_like" \| "in" \| "not_in" \| ">" \| ">=" \| "<" \| "<=" \| "between" | No |+| filter_5_value | Filter 5 value | str | No |++### Outputs++| Output | Description | Type |+|--------|-------------|------|+| error | Error message if the operation failed | str |+| result | Full search response (total, count, results) | Dict[str, Any] |+| results | List of matching LinkedIn people / leads | List[Any] |+| total | Total number of matches | int |++### Possible use case+<!-- MANUAL: use_case -->+**Prospecting**: Find employees at target companies by job title, seniority, or skill for outbound sales.++**Recruiting**: Search for candidates with a specific title, location, or company background.++**Org Mapping**: Identify decision-makers and key contacts across selected target accounts.+<!-- END MANUAL -->++---diff --git a/docs/integrations/block-integrations/dataforb2b/typeahead.md b/docs/integrations/block-integrations/dataforb2b/typeahead.mdnew file mode 100644index 0000000000..cd820efa76--- /dev/null+++ b/docs/integrations/block-integrations/dataforb2b/typeahead.md@@ -0,0 +1,42 @@+# DataForB2B Typeahead+<!-- MANUAL: file_description -->+Resolve free-text queries into the exact filter values DataForB2B's search endpoints expect, so structured search filters match real records instead of failing silently on typos or near-misses.+<!-- END MANUAL -->++## Search Filter Typeahead++### What it is+Resolve the exact filter value (company, industry, job title, skill, school, investor, location, category) for people and company searches with DataForB2B.++### How it works+<!-- MANUAL: how_it_works -->+The block trims and validates the free-text query `q`, then sends it with `filter_type` to DataForB2B's typeahead endpoint. Use the returned `values` as a People Search or Company Search filter rather than guessing at exact spellings — the search endpoints match on stored taxonomy values, so a plausible-looking guess silently returns zero results (`industry` is `software development`, not `software`). Industry is split per-side upstream: resolve `people_industry` for People Search and `company_industry` for Company Search, since the two taxonomies differ in both membership and casing. `limit` is clamped to 1-20, client and server errors are surfaced via `error`, and a valid query with no match returns empty `results` and `values` lists.+<!-- END MANUAL -->++### Inputs++| Input | Description | Type | Required |+|-------|-------------|------|----------|+| filter_type | Filter type to resolve. Industry is split per-side: use people_industry for People Search and company_industry for Company Search | "company" \| "people_industry" \| "company_industry" \| "title" \| "skill" \| "school" \| "investor" \| "location" \| "city" \| "region" \| "category" | Yes |+| q | Free-text query to resolve | str | Yes |+| limit | Max suggestions (1-20) | int | No |++### Outputs++| Output | Description | Type |+|--------|-------------|------|+| error | Error message if the operation failed | str |+| result | Full typeahead response | Dict[str, Any] |+| results | List of suggestions | List[Dict[str, Any]] |+| values | Resolved stored values | List[str] |++### Possible use case+<!-- MANUAL: use_case -->+**Filter Autocomplete**: Resolve a user-typed company or industry name to the exact stored value before running a structured People/Company Search.++**Search Validation**: Confirm a job title or location exists in DataForB2B's taxonomy before building a filter around it.++**Query Normalization**: Convert user-entered company, school, or skill names into canonical values for repeatable searches.+<!-- END MANUAL -->++---diff --git a/docs/integrations/block-integrations/misc.md b/docs/integrations/block-integrations/misc.mdindex 4ac469cc06..b53abcbbc9 100644--- a/docs/integrations/block-integrations/misc.md+++ b/docs/integrations/block-integrations/misc.md@@ -58,7 +58,7 @@ Tool and block identifiers provided in `tools` and `blocks` are validated at run| system_context | Optional additional context prepended to the prompt. Use this to constrain autopilot behavior, provide domain context, or set output format requirements. | str | No || session_id | Session ID to continue an existing autopilot conversation. Leave empty to start a new session. Use the session_id output from a previous run to continue. | str | No || max_recursion_depth | Maximum nesting depth when the autopilot calls this block recursively (sub-agent pattern). Prevents infinite loops. | int | No |-| tools | Tool names to filter. Works with tools_exclude to form an allow-list or deny-list. Leave empty to apply no tool filter. | List["add_understanding" \| "bash_exec" \| "browser_act" \| "browser_navigate" \| "browser_screenshot" \| "connect_integration" \| "continue_run_block" \| "create_agent" \| "create_feature_request" \| "create_folder" \| "customize_agent" \| "decompose_goal" \| "delete_folder" \| "delete_preset" \| "delete_schedule" \| "delete_skill" \| "delete_workspace_file" \| "edit_agent" \| "enter_agent_building_mode" \| "find_agent" \| "find_block" \| "find_library_agent" \| "fix_agent_graph" \| "get_agent_building_guide" \| "get_doc_page" \| "get_mcp_guide" \| "get_platform_info" \| "get_sub_session_result" \| "list_agent_triggers" \| "list_chat_platform_channels" \| "list_folders" \| "list_presets" \| "list_schedules" \| "list_skills" \| "list_workspace_files" \| "memory_forget_confirm" \| "memory_forget_search" \| "memory_search" \| "memory_store" \| "move_agents_to_folder" \| "move_folder" \| "post_to_chat_platform" \| "read_skill" \| "read_workspace_file" \| "run_agent" \| "run_block" \| "run_mcp_tool" \| "run_sub_session" \| "schedule_followup" \| "search_docs" \| "search_feature_requests" \| "setup_agent_webhook_trigger" \| "store_skill" \| "update_folder" \| "update_preset" \| "validate_agent_graph" \| "view_agent_output" \| "web_fetch" \| "web_search" \| "write_workspace_file" \| "Agent" \| "Edit" \| "Glob" \| "Grep" \| "Read" \| "Task" \| "TodoWrite" \| "WebSearch" \| "Write"] | No |+| tools | Tool names to filter. Works with tools_exclude to form an allow-list or deny-list. Leave empty to apply no tool filter. | List["add_understanding" \| "bash_exec" \| "browser_act" \| "browser_navigate" \| "browser_screenshot" \| "confirm_expert_soul_update" \| "connect_integration" \| "continue_run_block" \| "create_agent" \| "create_feature_request" \| "create_folder" \| "customize_agent" \| "decompose_goal" \| "delete_folder" \| "delete_preset" \| "delete_schedule" \| "delete_skill" \| "delete_workspace_file" \| "edit_agent" \| "enter_agent_building_mode" \| "find_agent" \| "find_block" \| "find_library_agent" \| "fix_agent_graph" \| "get_agent_building_guide" \| "get_doc_page" \| "get_mcp_guide" \| "get_platform_info" \| "get_sub_session_result" \| "list_agent_triggers" \| "list_chat_platform_channels" \| "list_folders" \| "list_presets" \| "list_schedules" \| "list_skills" \| "list_workspace_files" \| "memory_forget_confirm" \| "memory_forget_search" \| "memory_search" \| "memory_store" \| "move_agents_to_folder" \| "move_folder" \| "post_to_chat_platform" \| "read_skill" \| "read_workspace_file" \| "run_agent" \| "run_block" \| "run_mcp_tool" \| "run_sub_session" \| "schedule_followup" \| "search_docs" \| "search_feature_requests" \| "setup_agent_webhook_trigger" \| "store_skill" \| "update_expert_soul" \| "update_folder" \| "update_preset" \| "validate_agent_graph" \| "view_agent_output" \| "web_fetch" \| "web_search" \| "write_workspace_file" \| "Agent" \| "Edit" \| "Glob" \| "Grep" \| "Read" \| "Task" \| "TodoWrite" \| "WebSearch" \| "Write"] | No || tools_exclude | Controls how the 'tools' list is interpreted. True (default): 'tools' is a deny-list — listed tools are blocked, all others are allowed. An empty 'tools' list means allow everything. False: 'tools' is an allow-list — only listed tools are permitted. | bool | No || blocks | Block identifiers to filter when the copilot uses run_block. Each entry can be: a block name (e.g. 'HTTP Request'), a full block UUID, or the first 8 hex characters of the UUID (e.g. 'c069dc6b'). Works with blocks_exclude. Leave empty to apply no block filter. | List[str] | No || blocks_exclude | Controls how the 'blocks' list is interpreted. True (default): 'blocks' is a deny-list — listed blocks are blocked, all others are allowed. An empty 'blocks' list means allow everything. False: 'blocks' is an allow-list — only listed blocks are permitted. | bool | No |