Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/narada-pyodide/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[project]
name = "narada-pyodide"
version = "0.0.57"
version = "0.0.58"
description = "Pyodide-compatible Python client SDK for Narada"
license = "Apache-2.0"
readme = "README.md"
Expand Down
10 changes: 9 additions & 1 deletion packages/narada-pyodide/src/narada/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,19 @@ async def open_and_initialize_cloud_browser_window(
user_id=self._user_id,
env=self._env,
)
request_body = {
request_body: dict[str, Any] = {
"session_name": session_name,
"session_timeout": session_timeout,
"require_extension": require_extension,
}
initiator_remote_dispatch_request_id = os.environ.get(
"NARADA_INITIATOR_REMOTE_DISPATCH_REQUEST_ID", ""
).strip()
Comment thread
volodymyr-narada marked this conversation as resolved.
if not initiator_remote_dispatch_request_id:
raise ValueError("NARADA_INITIATOR_REMOTE_DISPATCH_REQUEST_ID is required")
request_body["initiator_remote_dispatch_request_id"] = (
initiator_remote_dispatch_request_id
)

response = None
max_attempts = 3
Expand Down
53 changes: 53 additions & 0 deletions packages/narada-pyodide/tests/test_cloud_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def new() -> SimpleNamespace:
async def test_open_and_initialize_cloud_browser_window_maps_response(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv(
"NARADA_INITIATOR_REMOTE_DISPATCH_REQUEST_ID", "request-maps-123"
)
pyfetch = AsyncMock(
return_value=_FakeResponse(
json_data={
Expand Down Expand Up @@ -132,6 +135,53 @@ async def test_open_and_initialize_cloud_browser_window_maps_response(
"session_name": "demo",
"session_timeout": 321,
"require_extension": False,
"initiator_remote_dispatch_request_id": "request-maps-123",
}


@pytest.mark.asyncio
async def test_open_and_initialize_cloud_browser_window_requires_initiator_env(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.delenv("NARADA_INITIATOR_REMOTE_DISPATCH_REQUEST_ID", raising=False)
pyfetch = AsyncMock()
narada_pkg, _, _ = _import_pyodide_narada(monkeypatch, pyfetch=pyfetch)

client = narada_pkg.Narada(api_key="test-api-key")
with pytest.raises(ValueError, match="NARADA_INITIATOR_REMOTE_DISPATCH_REQUEST_ID"):
await client.open_and_initialize_cloud_browser_window()

pyfetch.assert_not_awaited()


@pytest.mark.asyncio
async def test_open_and_initialize_cloud_browser_window_includes_initiator_request(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv(
"NARADA_INITIATOR_REMOTE_DISPATCH_REQUEST_ID", " request-local-123 "
)
pyfetch = AsyncMock(
return_value=_FakeResponse(
json_data={
"session_id": "session-123",
"session_name": "demo",
"browser_window_id": "browser-window-123",
}
)
)
narada_pkg, _, _ = _import_pyodide_narada(monkeypatch, pyfetch=pyfetch)

client = narada_pkg.Narada(api_key="test-api-key")
await client.open_and_initialize_cloud_browser_window()

call = pyfetch.await_args
assert call is not None
assert json.loads(call.kwargs["body"]) == {
"session_name": None,
"session_timeout": None,
"require_extension": True,
"initiator_remote_dispatch_request_id": "request-local-123",
}


Expand All @@ -142,6 +192,9 @@ async def test_open_and_initialize_cloud_browser_window_supports_frontend_bearer
monkeypatch.delenv("NARADA_API_KEY", raising=False)
monkeypatch.setenv("NARADA_USER_ID", "user-123")
monkeypatch.setenv("NARADA_ENV", "dev")
monkeypatch.setenv(
"NARADA_INITIATOR_REMOTE_DISPATCH_REQUEST_ID", "request-bearer-123"
)

pyfetch = AsyncMock(
side_effect=[
Expand Down
4 changes: 2 additions & 2 deletions packages/narada/src/narada/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
from narada_core.actions.critic import run_critic
from narada_core.actions.models import (
DEFAULT_HITL_TIMEOUT_SECONDS,
AgenticMouseAction,
AgenticMouseActionRequest,
AgenticMatchingSelectorsFinderRequest,
AgenticMatchingSelectorsFinderResponse,
AgenticMouseAction,
AgenticMouseActionRequest,
AgenticSelectorAction,
AgenticSelectorRequest,
AgenticSelectorResponse,
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading