Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(society): keep a public login username visible and report which login fields were filled (#1111)
Ruben Lütkee09cd63b32cb
diff --git a/dodaios/society/browser/live_runner.py b/dodaios/society/browser/live_runner.pyindex 26efa4ee50..be18c5097f 100644--- a/dodaios/society/browser/live_runner.py+++ b/dodaios/society/browser/live_runner.py@@ -117,6 +117,7 @@ async def probe() -> None:class Worker:def __init__(self) -> None:+ self.logins_typed: list[str] = []self.pending: dict[str, asyncio.Future] = {}self.context: Any = Noneself.browser: Any = None@@ -862,7 +863,20 @@ class Worker:finally:worker.visual_action = Falseif typed_secret(proposal):- await worker.hide_typed_value()+ typed = str(result.extracted_content or "")+ if result.error is None and typed.startswith("Typed ") and typed != (+ "Typed sensitive data"+ ):+ worker.logins_typed.append(typed.removeprefix("Typed ").strip())+ await worker.hide_typed_value()+ elif result.error is None:+ # The placeholder stayed literal: this page is not the login's site.+ result = ActionResult(+ error=(+ "The stored login was not filled in: it is typed only on its "+ "own website over HTTPS. Check the page address."+ )+ )emit("action_result", id=answer["permit"], result=result.model_dump(mode="json"))return result@@ -877,6 +891,7 @@ class Worker:register_window_actions(tools, self, ActionResult)started = time.monotonic()secrets = args.get("sensitive_data") or None+ self.logins_typed = []self.agent = Agent(task=args["task"],# Stored website logins: the model writes <secret>name</secret>, the@@ -935,6 +950,7 @@ class Worker:"error": None if successful else "Browser task did not complete successfully",# One SDK owns downloads; a second Playwright save would duplicate files."artifacts": sorted(set(self.browser.downloaded_files) - previous_downloads),+ "logins_typed": list(dict.fromkeys(self.logins_typed)),})finally:self.agent = Nonediff --git a/dodaios/society/credentials.py b/dodaios/society/credentials.pyindex 3405bbbeec..cb9cb28fe8 100644--- a/dodaios/society/credentials.py+++ b/dodaios/society/credentials.py@@ -287,6 +287,16 @@ def login_site(raw: Any) -> tuple[str, str]:return f"https://{host}{path}"[:300], domain+def username_is_private(username: str) -> bool:+ """An email address is private; a site username is public on its own profile.++ A public username is shown to the agent and typed as it is: hiding it+ would mask every mention of that name (often the project's own name) in+ the chat and in every page the browser reads.+ """+ return "@" in username++def _login_field(value: Any, what: str, *, strip: bool) -> str:text = str(value if isinstance(value, str) else "")if strip:@@ -546,7 +556,8 @@ class CredentialVault:self._logins[agent_id] = loginsneedles = [(value, env) for env, value in loaded.items()]for key, (username, password) in logins.items():- needles.append((username, f"{key} username"))+ if username_is_private(username):+ needles.append((username, f"{key} username"))needles.append((password, f"{key} password"))self._masks[agent_id] = sorted(((form, name) for value, name in needles for form in _encodings(value)),@@ -687,11 +698,21 @@ class CredentialVault:if info is None:continueuser_name, pass_name = info.placeholders- out.setdefault(info.domain_pattern, {}).update(- {user_name: username, pass_name: password}- )+ scoped = out.setdefault(info.domain_pattern, {})+ scoped[pass_name] = password+ if username_is_private(username):+ scoped[user_name] = usernamereturn out+ def public_username(self, agent_id: str, key: str) -> str | None:+ """The login's username when it is not private, else ``None``."""+ self.values(agent_id)+ with self._lock:+ pair = self._logins.get(agent_id, {}).get(key)+ if pair is None or username_is_private(pair[0]):+ return None+ return pair[0]+def is_loaded(self, agent_id: str) -> bool:return agent_id in self._valuesdiff --git a/dodaios/society/login_tool.py b/dodaios/society/login_tool.pyindex 55cdf32296..d1979fec0a 100644--- a/dodaios/society/login_tool.py+++ b/dodaios/society/login_tool.py@@ -40,15 +40,24 @@ __all__ = ["LOGIN_TOOL_NAME", "RequestLoginTool", "login_usage_note"]LOGIN_TOOL_NAME: Final[str] = "society_request_login"-def login_usage_note(info: LoginInfo) -> str:- """How the agent uses a stored login without ever seeing it."""- user, password = info.placeholders+def username_hint(info: LoginInfo, username: str | None) -> str:+ """What the agent types as the username: the name itself or its placeholder."""+ return username if username else f"<secret>{info.placeholders[0]}</secret>"+++def login_usage_note(info: LoginInfo, username: str | None = None) -> str:+ """How the agent uses a stored login without ever seeing the password."""+ password = info.placeholders[1]return (- f"Sign in with society_browser on {info.domain}. In the browser task write the "- f"placeholders literally: username <secret>{user}</secret>, password "- f"<secret>{password}</secret>. The browser types the real values only on "- f"{info.domain} and its subdomains; you never see them. Never ask the user to type "- "the login in the chat and never try to read the typed values back."+ f"Sign in with society_browser on {info.domain}. In the browser task give the " # noqa: S608+ f"username {username_hint(info, username)} and the password "+ f"<secret>{password}</secret>, written literally. The browser types the secret "+ f"values only on {info.domain} and its subdomains; you never see them. Use the "+ "page's sign-in form, not a create-account form. The browser result lists the "+ "secret fields it really filled under logins_typed. If the site rejects the login, "+ "ask again with replace only when the sign-in form was used and the password is in "+ "logins_typed; otherwise retry the sign-in once. Never ask the user to type the "+ "login in the chat and never try to read the typed values back.")@@ -227,16 +236,16 @@ class RequestLoginTool:info = next((row for row in vault.list_logins(self._agent_id) if row.key == key), None)if info is None:return ToolResult(success=False, output=None, error="The login was not stored.")- user, password = info.placeholders+ username = vault.public_username(self._agent_id, key)return ToolResult(success=True,output={"status": status,"site": info.label,"domain": info.domain,- "username_placeholder": f"<secret>{user}</secret>",- "password_placeholder": f"<secret>{password}</secret>",- "note": login_usage_note(info),+ "username": username_hint(info, username),+ "password_placeholder": f"<secret>{info.placeholders[1]}</secret>",+ "note": login_usage_note(info, username),},)diff --git a/dodaios/society/surface.py b/dodaios/society/surface.pyindex 334c503a3f..7f928c01df 100644--- a/dodaios/society/surface.py+++ b/dodaios/society/surface.py@@ -926,9 +926,15 @@ async def _credential_line(rt: Any, agent_id: str) -> str:f"never shown to you): {names}.")if logins:+ from .login_tool import username_hint++ users = {+ info.key: await asyncio.to_thread(vault.public_username, agent_id, info.key)+ for info in logins+ }sites = "; ".join(- f"{info.label} on {info.domain}: <secret>{info.placeholders[0]}</secret> / "- f"<secret>{info.placeholders[1]}</secret>"+ f"{info.label} on {info.domain}: username {username_hint(info, users[info.key])}, "+ f"password <secret>{info.placeholders[1]}</secret>"for info in logins)line += (diff --git a/tests/unit/society/test_agent_logins.py b/tests/unit/society/test_agent_logins.pyindex 64c12621b2..0055056a54 100644--- a/tests/unit/society/test_agent_logins.py+++ b/tests/unit/society/test_agent_logins.py@@ -291,3 +291,35 @@ async def test_a_restored_connect_card_still_checks_the_connection(assert save is not Nonewith pytest.raises(CredentialError):await save("connected")+++def test_a_public_username_is_typed_as_is_and_never_masked(vault: CredentialVault) -> None:+ # A site username such as the project's own name is public; masking it+ # would rewrite every mention of the project in the chat and the pages.+ vault.store_login("ada", "hacker_news", "dodaios", PASSWORD, url="news.ycombinator.com")+ assert vault.browser_secrets("ada") == {+ "*.ycombinator.com": {"hacker_news_password": PASSWORD}+ }+ assert vault.public_username("ada", "hacker_news") == "dodaios"+ text = "mcp__dodaios__society_ask_user posts for Dodaios/dodaios"+ assert vault.redact("ada", text) == text+ assert vault.redact("ada", f"pw={PASSWORD}") == "pw=[credential hacker_news password]"+++def test_an_email_username_stays_a_placeholder(vault: CredentialVault) -> None:+ vault.store_login("ada", "reddit", USER, PASSWORD, url="reddit.com")+ assert vault.public_username("ada", "reddit") is None+ assert set(vault.browser_secrets("ada")["*.reddit.com"]) == {+ "reddit_username", "reddit_password"+ }+++async def test_the_agent_gets_a_public_username_in_plain_text(tmp_path: Path, vault) -> None:+ vault.store_login("ada", "hacker_news", "dodaios", PASSWORD, url="news.ycombinator.com")+ tool = RequestLoginTool(_runtime(None), "ada", session_id=SID)+ result = await tool.execute(+ {"site": "Hacker News", "url": "news.ycombinator.com/login", "description": "why"}, None+ )+ assert result.output["status"] == "available"+ assert result.output["username"] == "dodaios"+ assert "logins_typed" in result.output["note"] and PASSWORD not in json.dumps(result.output)