Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Nick: fixed b sdks

Nicolas0de4cd1bf63e
diff --git a/apps/js-sdk/firecrawl/src/v2/client.ts b/apps/js-sdk/firecrawl/src/v2/client.ts
index 31d5a182c..0de958607 100644
--- a/apps/js-sdk/firecrawl/src/v2/client.ts
+++ b/apps/js-sdk/firecrawl/src/v2/client.ts
@@ -311,8 +311,8 @@ export class FirecrawlClient {
// Browser
/**
* Create a new browser session.
- * @param args Session options (ttlTotal, ttlWithoutActivity, streamWebView).
- * @returns Session id and CDP URL.
+ * @param args Session options (ttl, activityTtl, streamWebView).
+ * @returns Session id, CDP URL, live view URL, and expiration time.
*/
async browser(
args: Parameters<typeof browserMethod>[1] = {}
@@ -322,8 +322,8 @@ export class FirecrawlClient {
/**
* Execute code in a browser session.
* @param sessionId Browser session id.
- * @param args Code and language to execute.
- * @returns Execution result.
+ * @param args Code, language ("python" | "node" | "bash"), and optional timeout.
+ * @returns Execution result including stdout, stderr, exitCode, and killed status.
*/
async browserExecute(
sessionId: string,
diff --git a/apps/js-sdk/firecrawl/src/v2/methods/browser.ts b/apps/js-sdk/firecrawl/src/v2/methods/browser.ts
index f952311bc..a1cb62fd6 100644
--- a/apps/js-sdk/firecrawl/src/v2/methods/browser.ts
+++ b/apps/js-sdk/firecrawl/src/v2/methods/browser.ts
@@ -10,14 +10,14 @@ import { normalizeAxiosError, throwForBadResponse } from "../utils/errorHandler"
export async function browser(
http: HttpClient,
args: {
- ttlTotal?: number;
- ttlWithoutActivity?: number;
+ ttl?: number;
+ activityTtl?: number;
streamWebView?: boolean;
} = {}
): Promise<BrowserCreateResponse> {
const body: Record<string, unknown> = {};
- if (args.ttlTotal != null) body.ttlTotal = args.ttlTotal;
- if (args.ttlWithoutActivity != null) body.ttlWithoutActivity = args.ttlWithoutActivity;
+ if (args.ttl != null) body.ttl = args.ttl;
+ if (args.activityTtl != null) body.activityTtl = args.activityTtl;
if (args.streamWebView != null) body.streamWebView = args.streamWebView;
try {
@@ -35,13 +35,15 @@ export async function browserExecute(
sessionId: string,
args: {
code: string;
- language?: "python" | "js";
+ language?: "python" | "node" | "bash";
+ timeout?: number;
}
): Promise<BrowserExecuteResponse> {
const body: Record<string, unknown> = {
code: args.code,
- language: args.language ?? "python",
+ language: args.language ?? "bash",
};
+ if (args.timeout != null) body.timeout = args.timeout;
try {
const res = await http.post<BrowserExecuteResponse>(
diff --git a/apps/js-sdk/firecrawl/src/v2/types.ts b/apps/js-sdk/firecrawl/src/v2/types.ts
index 709758b08..d706e3aa7 100644
--- a/apps/js-sdk/firecrawl/src/v2/types.ts
+++ b/apps/js-sdk/firecrawl/src/v2/types.ts
@@ -690,17 +690,24 @@ export interface BrowserCreateResponse {
id?: string;
cdpUrl?: string;
liveViewUrl?: string;
+ expiresAt?: string;
error?: string;
}
export interface BrowserExecuteResponse {
success: boolean;
+ stdout?: string;
result?: string;
+ stderr?: string;
+ exitCode?: number;
+ killed?: boolean;
error?: string;
}
export interface BrowserDeleteResponse {
success: boolean;
+ sessionDurationMs?: number;
+ creditsBilled?: number;
error?: string;
}
diff --git a/apps/python-sdk/firecrawl/v2/client.py b/apps/python-sdk/firecrawl/v2/client.py
index fbb040dc7..cf2e6db4e 100644
--- a/apps/python-sdk/firecrawl/v2/client.py
+++ b/apps/python-sdk/firecrawl/v2/client.py
@@ -954,15 +954,15 @@ class FirecrawlClient:
def browser(
self,
*,
- ttl_total: Optional[int] = None,
- ttl_without_activity: Optional[int] = None,
+ ttl: Optional[int] = None,
+ activity_ttl: Optional[int] = None,
stream_web_view: Optional[bool] = None,
):
"""Create a new browser session.
Args:
- ttl_total: Total time-to-live in seconds (30-3600, default 300)
- ttl_without_activity: TTL without activity in seconds (10-3600)
+ ttl: Total time-to-live in seconds (30-3600, default 300)
+ activity_ttl: Inactivity TTL in seconds (10-3600)
stream_web_view: Whether to enable webview streaming
Returns:
@@ -970,8 +970,8 @@ class FirecrawlClient:
"""
return browser_module.browser(
self.http_client,
- ttl_total=ttl_total,
- ttl_without_activity=ttl_without_activity,
+ ttl=ttl,
+ activity_ttl=activity_ttl,
stream_web_view=stream_web_view,
)
@@ -980,14 +980,16 @@ class FirecrawlClient:
session_id: str,
code: str,
*,
- language: Literal["python", "js"] = "python",
+ language: Literal["python", "node", "bash"] = "bash",
+ timeout: Optional[int] = None,
):
"""Execute code in a browser session.
Args:
session_id: Browser session ID
code: Code to execute
- language: Programming language ("python" or "js")
+ language: Programming language ("python", "node", or "bash")
+ timeout: Execution timeout in seconds (1-300, default 30)
Returns:
BrowserExecuteResponse with execution result
@@ -997,6 +999,7 @@ class FirecrawlClient:
session_id,
code,
language=language,
+ timeout=timeout,
)
def delete_browser(self, session_id: str):
diff --git a/apps/python-sdk/firecrawl/v2/client_async.py b/apps/python-sdk/firecrawl/v2/client_async.py
index 7ad422ed8..3caec4efa 100644
--- a/apps/python-sdk/firecrawl/v2/client_async.py
+++ b/apps/python-sdk/firecrawl/v2/client_async.py
@@ -425,15 +425,15 @@ class AsyncFirecrawlClient:
async def browser(
self,
*,
- ttl_total: Optional[int] = None,
- ttl_without_activity: Optional[int] = None,
+ ttl: Optional[int] = None,
+ activity_ttl: Optional[int] = None,
stream_web_view: Optional[bool] = None,
):
"""Create a new browser session.
Args:
- ttl_total: Total time-to-live in seconds (30-3600, default 300)
- ttl_without_activity: TTL without activity in seconds (10-3600)
+ ttl: Total time-to-live in seconds (30-3600, default 300)
+ activity_ttl: Inactivity TTL in seconds (10-3600)
stream_web_view: Whether to enable webview streaming
Returns:
@@ -441,8 +441,8 @@ class AsyncFirecrawlClient:
"""
return await async_browser.browser(
self.async_http_client,
- ttl_total=ttl_total,
- ttl_without_activity=ttl_without_activity,
+ ttl=ttl,
+ activity_ttl=activity_ttl,
stream_web_view=stream_web_view,
)
@@ -451,14 +451,16 @@ class AsyncFirecrawlClient:
session_id: str,
code: str,
*,
- language: Literal["python", "js"] = "python",
+ language: Literal["python", "node", "bash"] = "bash",
+ timeout: Optional[int] = None,
):
"""Execute code in a browser session.
Args:
session_id: Browser session ID
code: Code to execute
- language: Programming language ("python" or "js")
+ language: Programming language ("python", "node", or "bash")
+ timeout: Execution timeout in seconds (1-300, default 30)
Returns:
BrowserExecuteResponse with execution result
@@ -468,6 +470,7 @@ class AsyncFirecrawlClient:
session_id,
code,
language=language,
+ timeout=timeout,
)
async def delete_browser(self, session_id: str):
diff --git a/apps/python-sdk/firecrawl/v2/methods/aio/browser.py b/apps/python-sdk/firecrawl/v2/methods/aio/browser.py
index eb92ed4fd..e9d8e4715 100644
--- a/apps/python-sdk/firecrawl/v2/methods/aio/browser.py
+++ b/apps/python-sdk/firecrawl/v2/methods/aio/browser.py
@@ -21,6 +21,8 @@ def _normalize_browser_create_response(payload: Dict[str, Any]) -> Dict[str, Any
out["cdp_url"] = out["cdpUrl"]
if "liveViewUrl" in out and "live_view_url" not in out:
out["live_view_url"] = out["liveViewUrl"]
+ if "expiresAt" in out and "expires_at" not in out:
+ out["expires_at"] = out["expiresAt"]
return out
@@ -48,26 +50,26 @@ def _normalize_browser_list_response(payload: Dict[str, Any]) -> Dict[str, Any]:
async def browser(
client: AsyncHttpClient,
*,
- ttl_total: Optional[int] = None,
- ttl_without_activity: Optional[int] = None,
+ ttl: Optional[int] = None,
+ activity_ttl: Optional[int] = None,
stream_web_view: Optional[bool] = None,
) -> BrowserCreateResponse:
"""Create a new browser session.
Args:
client: Async HTTP client instance
- ttl_total: Total time-to-live in seconds (30-3600, default 300)
- ttl_without_activity: TTL without activity in seconds (10-3600)
+ ttl: Total time-to-live in seconds (30-3600, default 300)
+ activity_ttl: Inactivity TTL in seconds (10-3600)
stream_web_view: Whether to enable webview streaming
Returns:
BrowserCreateResponse with session id and CDP URL
"""
body: Dict[str, Any] = {}
- if ttl_total is not None:
- body["ttlTotal"] = ttl_total
- if ttl_without_activity is not None:
- body["ttlWithoutActivity"] = ttl_without_activity
+ if ttl is not None:
+ body["ttl"] = ttl
+ if activity_ttl is not None:
+ body["activityTtl"] = activity_ttl
if stream_web_view is not None:
body["streamWebView"] = stream_web_view
@@ -76,12 +78,29 @@ async def browser(
return BrowserCreateResponse(**payload)
+def _normalize_browser_execute_response(payload: Dict[str, Any]) -> Dict[str, Any]:
+ out = dict(payload)
+ if "exitCode" in out and "exit_code" not in out:
+ out["exit_code"] = out["exitCode"]
+ return out
+
+
+def _normalize_browser_delete_response(payload: Dict[str, Any]) -> Dict[str, Any]:
+ out = dict(payload)
+ if "sessionDurationMs" in out and "session_duration_ms" not in out:
+ out["session_duration_ms"] = out["sessionDurationMs"]
+ if "creditsBilled" in out and "credits_billed" not in out:
+ out["credits_billed"] = out["creditsBilled"]
+ return out
+
+
async def browser_execute(
client: AsyncHttpClient,
session_id: str,
code: str,
*,
- language: Literal["python", "js"] = "python",
+ language: Literal["python", "node", "bash"] = "bash",
+ timeout: Optional[int] = None,
) -> BrowserExecuteResponse:
"""Execute code in a browser session.
@@ -89,7 +108,8 @@ async def browser_execute(
client: Async HTTP client instance
session_id: Browser session ID
code: Code to execute
- language: Programming language ("python" or "js")
+ language: Programming language ("python", "node", or "bash")
+ timeout: Execution timeout in seconds (1-300, default 30)
Returns:
BrowserExecuteResponse with execution result
@@ -98,9 +118,12 @@ async def browser_execute(
"code": code,
"language": language,
}
+ if timeout is not None:
+ body["timeout"] = timeout
resp = await client.post(f"/v2/browser/{session_id}/execute", body)
- return BrowserExecuteResponse(**resp.json())
+ payload = _normalize_browser_execute_response(resp.json())
+ return BrowserExecuteResponse(**payload)
async def delete_browser(
@@ -117,7 +140,8 @@ async def delete_browser(
BrowserDeleteResponse
"""
resp = await client.delete(f"/v2/browser/{session_id}")
- return BrowserDeleteResponse(**resp.json())
+ payload = _normalize_browser_delete_response(resp.json())
+ return BrowserDeleteResponse(**payload)
async def list_browsers(
diff --git a/apps/python-sdk/firecrawl/v2/methods/browser.py b/apps/python-sdk/firecrawl/v2/methods/browser.py
index ba945284e..1215be448 100644
--- a/apps/python-sdk/firecrawl/v2/methods/browser.py
+++ b/apps/python-sdk/firecrawl/v2/methods/browser.py
@@ -22,6 +22,8 @@ def _normalize_browser_create_response(payload: Dict[str, Any]) -> Dict[str, Any
out["cdp_url"] = out["cdpUrl"]
if "liveViewUrl" in out and "live_view_url" not in out:
out["live_view_url"] = out["liveViewUrl"]
+ if "expiresAt" in out and "expires_at" not in out:
+ out["expires_at"] = out["expiresAt"]
return out
@@ -49,26 +51,26 @@ def _normalize_browser_list_response(payload: Dict[str, Any]) -> Dict[str, Any]:
def browser(
client: HttpClient,
*,
- ttl_total: Optional[int] = None,
- ttl_without_activity: Optional[int] = None,
+ ttl: Optional[int] = None,
+ activity_ttl: Optional[int] = None,
stream_web_view: Optional[bool] = None,
) -> BrowserCreateResponse:
"""Create a new browser session.
Args:
client: HTTP client instance
- ttl_total: Total time-to-live in seconds (30-3600, default 300)
- ttl_without_activity: TTL without activity in seconds (10-3600)
+ ttl: Total time-to-live in seconds (30-3600, default 300)
+ activity_ttl: Inactivity TTL in seconds (10-3600)
stream_web_view: Whether to enable webview streaming
Returns:
BrowserCreateResponse with session id and CDP URL
"""
body: Dict[str, Any] = {}
- if ttl_total is not None:
- body["ttlTotal"] = ttl_total
- if ttl_without_activity is not None:
- body["ttlWithoutActivity"] = ttl_without_activity
+ if ttl is not None:
+ body["ttl"] = ttl
+ if activity_ttl is not None:
+ body["activityTtl"] = activity_ttl
if stream_web_view is not None:
body["streamWebView"] = stream_web_view
@@ -79,12 +81,20 @@ def browser(
return BrowserCreateResponse(**payload)
+def _normalize_browser_execute_response(payload: Dict[str, Any]) -> Dict[str, Any]:
+ out = dict(payload)
+ if "exitCode" in out and "exit_code" not in out:
+ out["exit_code"] = out["exitCode"]
+ return out
+
+
def browser_execute(
client: HttpClient,
session_id: str,
code: str,
*,
- language: Literal["python", "js"] = "python",
+ language: Literal["python", "node", "bash"] = "bash",
+ timeout: Optional[int] = None,
) -> BrowserExecuteResponse:
"""Execute code in a browser session.
@@ -92,7 +102,8 @@ def browser_execute(
client: HTTP client instance
session_id: Browser session ID
code: Code to execute
- language: Programming language ("python" or "js")
+ language: Programming language ("python", "node", or "bash")
+ timeout: Execution timeout in seconds (1-300, default 30)
Returns:
BrowserExecuteResponse with execution result
@@ -101,11 +112,23 @@ def browser_execute(
"code": code,
"language": language,
}
+ if timeout is not None:
+ body["timeout"] = timeout
resp = client.post(f"/v2/browser/{session_id}/execute", body)
if not resp.ok:
handle_response_error(resp, "execute browser code")
- return BrowserExecuteResponse(**resp.json())
+ payload = _normalize_browser_execute_response(resp.json())
+ return BrowserExecuteResponse(**payload)
+
+
+def _normalize_browser_delete_response(payload: Dict[str, Any]) -> Dict[str, Any]:
+ out = dict(payload)
+ if "sessionDurationMs" in out and "session_duration_ms" not in out:
+ out["session_duration_ms"] = out["sessionDurationMs"]
+ if "creditsBilled" in out and "credits_billed" not in out:
+ out["credits_billed"] = out["creditsBilled"]
+ return out
def delete_browser(
@@ -124,7 +147,8 @@ def delete_browser(
resp = client.delete(f"/v2/browser/{session_id}")
if not resp.ok:
handle_response_error(resp, "delete browser session")
- return BrowserDeleteResponse(**resp.json())
+ payload = _normalize_browser_delete_response(resp.json())
+ return BrowserDeleteResponse(**payload)
def list_browsers(
diff --git a/apps/python-sdk/firecrawl/v2/types.py b/apps/python-sdk/firecrawl/v2/types.py
index b05c6ddbd..b39d92375 100644
--- a/apps/python-sdk/firecrawl/v2/types.py
+++ b/apps/python-sdk/firecrawl/v2/types.py
@@ -818,6 +818,7 @@ class BrowserCreateResponse(BaseModel):
id: Optional[str] = None
cdp_url: Optional[str] = None
live_view_url: Optional[str] = None
+ expires_at: Optional[str] = None
error: Optional[str] = None
@@ -825,7 +826,11 @@ class BrowserExecuteResponse(BaseModel):
"""Response from executing code in a browser session."""
success: bool
+ stdout: Optional[str] = None
result: Optional[str] = None
+ stderr: Optional[str] = None
+ exit_code: Optional[int] = None
+ killed: Optional[bool] = None
error: Optional[str] = None
@@ -833,6 +838,8 @@ class BrowserDeleteResponse(BaseModel):
"""Response from deleting a browser session."""
success: bool
+ session_duration_ms: Optional[int] = None
+ credits_billed: Optional[int] = None
error: Optional[str] = None