diff --git a/README.md b/README.md index da6819c3d..cc1cbb085 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,10 @@ For more documentation on the CLI [CLICK HERE](https://docs.swarms.world/en/late --- +## TEE + +Head to the [TEE README](./tee/README.md) for more detailed instructions. + # Usage Examples 🤖 Here are some example scripts to get you started. For more comprehensive documentation, visit our [docs](https://docs.swarms.world/en/latest/). diff --git a/docs/swarms_cloud/imgs/01_create_agent_on_phala_cloud.png b/docs/swarms_cloud/imgs/01_create_agent_on_phala_cloud.png new file mode 100644 index 000000000..e131fdb82 Binary files /dev/null and b/docs/swarms_cloud/imgs/01_create_agent_on_phala_cloud.png differ diff --git a/docs/swarms_cloud/imgs/02_serial_logs.png b/docs/swarms_cloud/imgs/02_serial_logs.png new file mode 100644 index 000000000..dc245766f Binary files /dev/null and b/docs/swarms_cloud/imgs/02_serial_logs.png differ diff --git a/docs/swarms_cloud/imgs/03_serial_logs.png b/docs/swarms_cloud/imgs/03_serial_logs.png new file mode 100644 index 000000000..4ff0b6ec2 Binary files /dev/null and b/docs/swarms_cloud/imgs/03_serial_logs.png differ diff --git a/docs/swarms_cloud/imgs/04_swarms_agent_containers.png b/docs/swarms_cloud/imgs/04_swarms_agent_containers.png new file mode 100644 index 000000000..76ffb6f37 Binary files /dev/null and b/docs/swarms_cloud/imgs/04_swarms_agent_containers.png differ diff --git a/docs/swarms_cloud/imgs/05_agent_output.png b/docs/swarms_cloud/imgs/05_agent_output.png new file mode 100644 index 000000000..35d6a5d8a Binary files /dev/null and b/docs/swarms_cloud/imgs/05_agent_output.png differ diff --git a/docs/swarms_cloud/imgs/06_attestation.png b/docs/swarms_cloud/imgs/06_attestation.png new file mode 100644 index 000000000..b3bbf3899 Binary files /dev/null and b/docs/swarms_cloud/imgs/06_attestation.png differ diff --git a/docs/swarms_cloud/phala_deploy.md b/docs/swarms_cloud/phala_deploy.md index 10b43d205..c0cf0de34 100644 --- a/docs/swarms_cloud/phala_deploy.md +++ b/docs/swarms_cloud/phala_deploy.md @@ -6,7 +6,7 @@ This guide will walk you through deploying your project to Phala's Trusted Execu - Docker installed on your system - A DockerHub account -- Access to Phala Cloud dashboard +- Register a [Phala Cloud](https://cloud.phala.network/) account ## 🛡️ TEE Overview @@ -14,55 +14,80 @@ For detailed instructions about Trusted Execution Environment setup, please refe ## 🚀 Deployment Steps -### 1. Build and Publish Docker Image +### 1. Configure Your Environment -```bash -# Build the Docker image -docker compose build -t /swarm-agent-node:latest - -# Push to DockerHub -docker push /swarm-agent-node:latest -``` - -### 2. Deploy to Phala Cloud - -Choose one of these deployment methods: -- Use [tee-cloud-cli](https://github.com/Phala-Network/tee-cloud-cli) (Recommended) -- Deploy manually via the [Phala Cloud Dashboard](https://cloud.phala.network/) - -### 3. Verify TEE Attestation - -Visit the [TEE Attestation Explorer](https://proof.t16z.com/) to check and verify your agent's TEE proof. - -## 📝 Docker Configuration - -Below is a sample Docker Compose configuration for your Swarms agent: +First, prepare your `docker-compose.yaml` file. You can find an example in [docker-compose.yaml](./docker-compose.yaml). Make sure to have your OpenAI API key ready. ```yaml services: swarms-agent-server: - image: swarms-agent-node:latest - platform: linux/amd64 + image: python:3.12-slim volumes: - - /var/run/tappd.sock:/var/run/tappd.sock - swarms:/app restart: always - ports: - - 8000:8000 - command: # Sample MCP Server + environment: + - OPENAI_API_KEY=${OPENAI_API_KEY} + command: # Run swarms agent example - /bin/sh - -c - | - cd /app/mcp_example - python mcp_test.py + # install dependencies + apt update && apt install -y git python3-pip + mkdir -p /app && cd /app + + git clone --depth 1 https://github.com/The-Swarm-Corporation/swarms-examples + cd swarms-examples/ + pip install -r requirements.txt && pip install langchain-community langchain-core + cd examples/agents/ + python o1_preview.py + + # keep container running + sleep infinity + volumes: swarms: ``` -## 📚 Additional Resources +### 2. Deploy to Phala Cloud -For more comprehensive documentation and examples, visit our [Official Documentation](https://docs.swarms.world/en/latest/). +Choose one of these deployment methods: + +- Use [tee-cloud-cli](https://github.com/Phala-Network/tee-cloud-cli) (Recommended) +- Deploy manually via the [Phala Cloud Dashboard](https://cloud.phala.network/) + 1. Click `Deploy` button on the Phala Cloud dashboard. + 2. Choose `docker-compose.yaml` and then click `Advanced` tab to paste the content of your docker-compose.yaml file. + 3. Importantly, make sure to add the `OPENAI_API_KEY` in the `Encrypted Secrets` section with your own OpenAI API key. + 4. Click `Create` button to create a new Swarms agent application. +

+ Creating a Swarms agent on Phala Cloud +

+ +### 3. Monitor Your Deployment + +1. Check the initialization logs of your agent +

+ Agent initialization logs + Detailed initialization logs +

+ +2. Verify your container is running +

+ Swarms Agent Container Status +

+ +3. Monitor your agent's output +

+ Swarms Agent Logs +

+ +### 4. Verify TEE Attestation + +Visit the [TEE Attestation Explorer](https://proof.t16z.com/) to check and verify your agent's TEE proof. ---- +

+TEE Attestation Verification +

-> **Note**: Make sure to replace `` with your actual DockerHub username when building and pushing the image. \ No newline at end of file +## 📚 Additional Resources + +For more comprehensive documentation and examples, visit our [Official Documentation](https://docs.swarms.world/en/latest/). diff --git a/tee/README.md b/tee/README.md new file mode 100644 index 000000000..137e44dc6 --- /dev/null +++ b/tee/README.md @@ -0,0 +1,90 @@ +# Running Swarms Agent in Phala TEE + +Welcome! This guide will walk you through running your Swarms Agent in a Trusted Execution Environment (TEE) using Phala Cloud. This setup ensures your agent runs in a secure, isolated environment. + +## 📋 Prerequisites + +- A Swarms Agent code repository (or docker image) +- A Phala Cloud account +- An OpenAI API key + +## 📝 Step-by-Step Guide + +Firstly, you need to register a [Phala Cloud](https://cloud.phala.network/) account before you can create a new Swarms agent application. + +### 1. ⚙️ Configure Your Environment + +First, prepare your `docker-compose.yaml` file. You can find an example in [docker-compose.yaml](./docker-compose.yaml). Make sure to have your OpenAI API key ready. + +```yaml +services: + swarms-agent-server: + image: python:3.12-slim + volumes: + - swarms:/app + restart: always + environment: + - OPENAI_API_KEY=${OPENAI_API_KEY} + command: # Run swarms agent example + - /bin/sh + - -c + - | + # install dependencies + apt update && apt install -y git python3-pip + mkdir -p /app && cd /app + + git clone --depth 1 https://github.com/The-Swarm-Corporation/swarms-examples + cd swarms-examples/ + pip install -r requirements.txt && pip install langchain-community langchain-core + cd examples/agents/ + python o1_preview.py + + # keep container running + sleep infinity + +volumes: + swarms: +``` + +### 2. 🚀 Deploy Your Agent + +1. Navigate to the [Phala Cloud dashboard](https://cloud.phala.network/dashboard) +2. Click `Deploy` button on the Phala Cloud dashboard. +3. Choose `docker-compose.yaml` and then click `Advanced` tab to paste the content of your docker-compose.yaml file. +4. Importantly, make sure to add the `OPENAI_API_KEY` in the `Encrypted Secrets` section with your own OpenAI API key. +5. Click `Create` button to create a new Swarms agent application. +

+ Creating a Swarms agent on Phala Cloud +

+ +### 3. 📊 Monitor Your Deployment + +1. Check the initialization logs of your agent +

+ Agent initialization logs + Detailed initialization logs +

+ +2. Verify your container is running +

+ Swarms Agent Container Status +

+ +3. Monitor your agent's output +

+ Swarms Agent Logs +

+ +### 4. ✅ Verify TEE Attestation + +Ensure your agent is running in a secure TEE environment by checking the attestation proof on the [TEE Attestation Explorer](https://proof.t16z.com/). + +

+TEE Attestation Verification +

+ +## 🎉 Success! + +You've successfully deployed your Swarms Agent in a secure TEE environment using Phala Cloud. Your agent is now running in an isolated, trusted execution environment, ensuring enhanced security for your AI operations. + +If you have any questions, please reach out to Phala on [Phala Cloud](https://cloud.phala.network/). diff --git a/tee/docker-compose.yaml b/tee/docker-compose.yaml new file mode 100644 index 000000000..1e1f37091 --- /dev/null +++ b/tee/docker-compose.yaml @@ -0,0 +1,27 @@ +services: + swarms-agent-server: + image: python:3.12-slim + volumes: + - swarms:/app + restart: always + environment: + - OPENAI_API_KEY=${OPENAI_API_KEY} + command: # Run swarms agent example + - /bin/sh + - -c + - | + # install dependencies + apt update && apt install -y git python3-pip + mkdir -p /app && cd /app + + git clone --depth 1 https://github.com/The-Swarm-Corporation/swarms-examples + cd swarms-examples/ + pip install -r requirements.txt && pip install langchain-community langchain-core + cd examples/agents/ + python o1_preview.py + + # keep container running + sleep infinity + +volumes: + swarms: