cloudflare-sandbox-sdk

1 posts

cloudflare

Introducing Moltworker: a self-hosted personal AI agent, minus the minis (opens in new tab)

Moltworker adapts the self-hosted Moltbot personal AI assistant to run on Cloudflare without requiring users to buy a dedicated Mac mini. It combines a Cloudflare Worker, Sandbox SDK, Browser Rendering, R2, AI Gateway, and Cloudflare Access to provide a globally available, secured deployment. The result is a managed infrastructure layer around Moltbot’s standard Gateway runtime while preserving its integrations and persistent state. ## Running a Personal Agent on Cloudflare - Cloudflare Workers increasingly supports Node.js APIs natively, reducing the need for compatibility hacks and making it easier to run existing JavaScript and TypeScript packages. - An internal test of the 1,000 most popular NPM packages found that only 15 relevant packages failed to run in Workers. - Although much of Moltbot runs inside a container, improved Workers compatibility is useful for building agent logic closer to users. - Cloudflare’s Developer Platform provides the main infrastructure components: - **Sandboxes** for securely running untrusted code. - **Browser Rendering** for automated headless browser interactions. - **R2** for persistent object storage. - Cloudflare’s global network for scalability and security. ## Moltworker Architecture - Moltworker consists of: - An entrypoint Worker serving as an API router and proxy. - Cloudflare Access protecting the Worker and administration interface. - A Sandbox container running Moltbot’s standard Gateway and integrations. - R2 for persistent storage. - This structure separates the public API and administrative layer from the isolated environment where the agent executes. ## AI Gateway Integration - Cloudflare AI Gateway proxies requests between Moltbot and AI providers. - It provides: - Centralized request visibility. - Cost monitoring, logs, and analytics. - Provider and model switching without changing Moltbot code. - Fallback providers or models for improved reliability. - Secrets can be managed through: - **Bring Your Own Key (BYOK)**, where provider credentials are stored centrally. - **Unified Billing**, where users purchase credits and Cloudflare handles provider billing. - Integration requires creating an AI Gateway instance, enabling a provider such as Anthropic, and setting `ANTHROPIC_BASE_URL`; Moltbot itself does not need code changes. ## Sandbox-Based Execution - The Sandbox SDK runs agent code in isolated environments built on Cloudflare Containers. - It provides simplified APIs for: - Executing commands. - Managing files and directories. - Running background processes. - Exposing services. - Executing code in contexts such as Python. - The SDK abstracts container lifecycle, networking, filesystem, and process-management concerns behind TypeScript APIs. Moltworker offers a way to run a capable personal AI agent online with managed security, storage, browser automation, and model access—without maintaining dedicated hardware.