Skip to content

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.

1.1 KB
Raw Blame
"""Disambiguate an internal addressee from an external messaging connector."""

from __future__ import annotations

import re
from collections.abc import Iterable


def is_internal_message_request(text: str, agent_names: Iterable[str]) -> bool:
    """Require both a message request and a named teammate, not just 'Gmail'."""
    norm = text.casefold()
    if not re.search(
        r"\b(message|nachricht|testnachricht|mensaje|mensagem|mensagens)\w*\b",  # i18n-allow
        norm,
    ):
        return False
    if not re.search(
        r"\b(send|write|tell|schreib\w*|sende?\w*|schick\w*|env[ií]\w*|escrib\w*|"
        r"escrev\w*|manda\w*|diz)\b",  # i18n-allow: speech-input vocabulary
        norm,
    ):
        return False
    for name in agent_names:
        words = re.findall(r"\w+", name.casefold())
        if not words:
            continue
        pattern = r"\s+".join(
            r"agent(?:en|s|e)?" if word == "agent" else re.escape(word) for word in words
        )
        if re.search(r"\b" + pattern + r"\b", norm):
            return True
    return False