refactor: establish Brain-centered architecture and frontend/backend separation foundations#1536
refactor: establish Brain-centered architecture and frontend/backend separation foundations#1536
Conversation
bytecii
left a comment
There was a problem hiding this comment.
In general the design is ok. But IMO we should refactor and put things to different PRs, otherwise it's hard to review.
| has_browser: bool = False | ||
| """browser hand: can control CDP browser""" | ||
|
|
||
| filesystem_scope: str = "full" |
There was a problem hiding this comment.
Maybe make full etc as the strenum types?
| """workspace root path""" | ||
|
|
||
| deployment_type: str = "local" | ||
| """deployment type (for logging): local | cloud_vm | sandbox | docker""" |
There was a problem hiding this comment.
what's the cloud vm? just curious
| if in_docker: | ||
| logger.info("Brain running in Docker, using limited capabilities") | ||
| deployment = "docker" | ||
| caps = BrainCapabilities( |
There was a problem hiding this comment.
QQ should this be the HandCapabilities instead? for example browser is hand's capability?
| from app.hands.interface import IHands | ||
|
|
||
| # Terminal command allowlist for sandbox | ||
| SANDBOX_TERMINAL_ALLOWLIST = frozenset( |
There was a problem hiding this comment.
Seems that this is unused?
| @abstractmethod | ||
| async def acquire( | ||
| self, | ||
| resource_type: str, |
There was a problem hiding this comment.
Make resource type to string enum?
| from app.hands.interface import IHands | ||
|
|
||
|
|
||
| class RemoteHands(IHands): |
There was a problem hiding this comment.
Maybe we can put all Hands to a hands subfolder and import it to the hands/init.py
|
|
||
|
|
||
| class IHardwareBridge(ABC): | ||
| """Hardware capability bridge. Only Desktop has implementation, others use NullBridge""" |
There was a problem hiding this comment.
So should we implement this for the desktop?
| from app.hands.capabilities import detect_capabilities | ||
| from app.hands.environment_hands import EnvironmentHands | ||
|
|
||
| logger = logging.getLogger("hands.resolver") |
There was a problem hiding this comment.
Let's use the following
| logger = logging.getLogger("hands.resolver") | |
| logger = logging.getLogger(__name__) |
| # TODO(multi-tenant): os.environ is global – concurrent sessions overwrite | ||
| # each other's API keys, file paths, and browser ports. Pass these values | ||
| # through Chat / request context instead of mutating the process environment. | ||
| os.environ["file_save_path"] = data.file_save_path() |
There was a problem hiding this comment.
to my understanding as the brain in the server, will it has some problems if we set env as previously just in desktop?
There was a problem hiding this comment.
Yes, It need redesign if we deploy the brain in the server, can use S3 instead of it.
Related Issue
Closes #
Description
This PR delivers the current Brain + Web separation milestone.
It continues the ongoing refactor toward a Brain-centered architecture, where runtime capabilities are determined by the Brain environment rather than by client type. The goal of this phase is to preserve the existing Desktop experience while making
Web + Local Braina supported path built on shared, Brain-facing abstractions instead of Electron-specific assumptions.Within that scope, this PR has three primary outcomes:
Concretely, this PR moves the codebase further toward the target architecture described in the refactor work:
Notable user-facing improvements included in this PR:
Browser > CDP Browser Connectionnow works indev:webby using Brain APIs in web modeThis PR should be reviewed as a refactor milestone rather than as a collection of isolated bug fixes. The fixes included here are intentionally integrated into the Brain/Web separation work so the resulting behavior stays aligned with the target architecture.
Out of scope for this PR:
Testing Evidence (REQUIRED)
What is the purpose of this pull request?
Contribution Guidelines Acknowledgement