feat: add external browser sandbox support via connect_url#1
Closed
feat: add external browser sandbox support via connect_url#1
Conversation
- **Added Fireworks base URL constant** (`src/config.rs`): - Added `FIREWORKS_PROVIDER_BASE_URL` constant set to `https://api.fireworks.ai/v1` - **Added Fireworks provider registration** (`src/config.rs`): - Registered Fireworks provider in `load_from_env()` function (environment variable loading) - Registered Fireworks provider in `from_toml()` function (TOML config file loading) - Both use `ApiType::OpenAiCompletions` API type and the Fireworks base URL
Co-authored-by: Sam <78718829+the-snesler@users.noreply.github.com>
Convert markdown output to Telegram-compatible HTML before sending, so bold, italic, code, links, headers, blockquotes and code blocks render properly instead of showing raw markdown characters. Every send path (text, rich messages, thread replies, streaming edits, captions, ephemeral, scheduled, broadcast) now goes through `send_formatted` which sets `ParseMode::Html` and automatically falls back to plain text if the API rejects the HTML. Only the Telegram adapter is touched — Discord and Slack are unaffected.
If Telegram rejects the HTML caption the file was silently lost. Now retry with the raw caption text so the document is always delivered.
remove obsolete plan document from spacedriveapp#58
…build-errors-upstream fix(build): restore compile after security middleware + URL validation changes
…fix-upstream-clean fix(telegram): render markdown as Telegram HTML with safe, telegram-only fallbacks
Fix Fireworks
…nt Communication Graph - Introduced a comprehensive plan to enhance cron reliability by addressing timezone configuration, deletion behavior, and visibility of cron states. - Established a communication graph model for agent interactions, allowing for structured messaging and delegation between agents, enhancing coordination and context sharing.
6437122 to
49213f1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
connect_urltoBrowserConfigso each agent can be pointed at an externalchromedp/headless-shellcontainer instead of (or in addition to) launching a local Chrome process viaspacebot:full.Motivation
Running Chromium inside the Spacebot container (
spacebot:full, ~800 MB) couples the browser lifecycle to the main process. A browser crash takes down the whole container. A sidecar model (spacebot:slim+chromedp/headless-shell) gives independent restarts, smaller main image, and per-agent resource limits via compose.Design Decisions
Container choice:
chromedp/headless-shellchromedp/headless-shellexposes raw CDP on port 9222 with standard/json/versiondiscovery.Browser::connect("http://browser:9222")works directly with chromiumoxide 0.8. Apache 2.0 license, ~200 MB, no auth/session management — Docker network isolation is the security boundary.browserless/chromiumwas ruled out (SSPL — commercial use requires a paid license).Concurrency model: shared container per agent, tab-per-worker
Each agent gets one browser sandbox. All workers spawned by that agent share the same Chrome process; each opens its own tab via
new_page(). Workers from different agents use different containers. This gives agent-level process isolation without any Docker API dependency or dynamic container lifecycle management.Known limitation: a Chrome crash kills all tabs for the affected agent. Acceptable for agent-controlled browsing; not suitable for untrusted user content. Documented in
docs/docker.md.handle_close()bug fix: do not callbrowser.close()for connected browsersbrowser.close()sends CDPBrowser.close, which terminates the remote Chrome process — killing the shared sandbox and all other workers' tabs. For connected browsers the correct disconnect is to drop theBrowserstruct (chromiumoxide sends no CDP command when there is no child process). A newconnected: boolfield onBrowserStatetracks which path to take.fetch_targets()— not called after connectingchromiumoxide's
fetch_targets()afterBrowser::connect()would expose tabs opened by other workers. Each worker only interacts with tabs it creates vianew_page(), which sendsTarget.createTargetindependently of any existing target knowledge.Config: three-layer resolution, empty string as unset
Follows the existing
hardcoded default → [defaults.browser] → [[agents]].browserpattern.connect_url = Nonein the hardcoded default preserves existing behaviour (local launch). An empty stringconnect_url = ""is treated as unset and falls through to local launch, allowing a per-agent override to opt back out of a globalconnect_url.SPACEBOT_BROWSER_CONNECT_URLenv var overrides[defaults.browser]but not per-agent configs (consistent withenv > DB > defaultresolution order).Changes
src/config.rs—connect_url: Option<String>added toBrowserConfigandTomlBrowserConfig; both merge sites updated;SPACEBOT_BROWSER_CONNECT_URLenv var applied after defaults constructionsrc/tools/browser.rs—BrowserState.connected: booladded;handle_launch()branches onconnect_url(warns ifexecutable_path/non-headless are also set);handle_close()dispatches onconnected— drops without CDP for external,browser.close()for localdocs/docker.md— new "Browser Sandbox (Recommended for Production)" section with single-sandbox and per-agent compose examples, hardening flags, and env var referenceBackward Compatibility
connect_url = None(default): behaviour unchanged — local Chrome is launched as beforeheadless,executable_path,spacebot:fullall continue to work whenconnect_urlis not set