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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion plugins/browser/firecrawl/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@

_BASE_URL = "https://api.firecrawl.dev"

# Integration tag sent on every browser-session create so Firecrawl can
# attribute Hermes usage. Mirrors FIRECRAWL_INTEGRATION_TAG in the web
# plugin; kept here rather than imported to keep the two firecrawl
# plugins import-independent.
FIRECRAWL_INTEGRATION_TAG = "hermes"


class FirecrawlBrowserProvider(BrowserProvider):
"""Firecrawl (https://firecrawl.dev) cloud browser backend.
Expand Down Expand Up @@ -80,7 +86,10 @@ def _headers(self) -> Dict[str, str]:
def create_session(self, task_id: str) -> Dict[str, object]:
ttl = int(os.environ.get("FIRECRAWL_BROWSER_TTL", "300"))

body: Dict[str, object] = {"ttl": ttl}
body: Dict[str, object] = {
"ttl": ttl,
"integration": FIRECRAWL_INTEGRATION_TAG,
}

try:
response = requests.post(
Expand Down
13 changes: 12 additions & 1 deletion plugins/web/firecrawl/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
logger = logging.getLogger(__name__)


# Integration tag passed to Firecrawl on every call so they can attribute
# usage back to Hermes.
FIRECRAWL_INTEGRATION_TAG = "hermes"


# ---------------------------------------------------------------------------
# Lazy Firecrawl SDK proxy
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -408,7 +413,11 @@ def search(self, query: str, limit: int = 5) -> Dict[str, Any]:
# let it propagate so the dispatcher emits the legacy envelope shape.
client = _get_firecrawl_client()
try:
response = client.search(query=query, limit=limit)
response = client.search(
query=query,
limit=limit,
integration=FIRECRAWL_INTEGRATION_TAG,
)
web_results = _extract_web_search_results(response)
logger.info("Firecrawl: found %d search results", len(web_results))
return {"success": True, "data": {"web": web_results}}
Expand Down Expand Up @@ -487,6 +496,7 @@ async def extract(self, urls: List[str], **kwargs: Any) -> List[Dict[str, Any]]:
_get_firecrawl_client().scrape,
url=url,
formats=formats,
integration=FIRECRAWL_INTEGRATION_TAG,
),
timeout=60,
)
Expand Down Expand Up @@ -623,6 +633,7 @@ async def crawl(self, url: str, **kwargs: Any) -> Dict[str, Any]:
crawl_params = {
"limit": limit,
"scrape_options": {"formats": ["markdown"]},
"integration": FIRECRAWL_INTEGRATION_TAG,
}

# The SDK call is sync; run in a thread so we don't block the
Expand Down
Loading