diff --git a/tee/01_create_agent_on_phala_cloud.png b/tee/01_create_agent_on_phala_cloud.png new file mode 100644 index 00000000..e131fdb8 Binary files /dev/null and b/tee/01_create_agent_on_phala_cloud.png differ diff --git a/tee/02_serial_logs.png b/tee/02_serial_logs.png new file mode 100644 index 00000000..dc245766 Binary files /dev/null and b/tee/02_serial_logs.png differ diff --git a/tee/03_serial_logs.png b/tee/03_serial_logs.png new file mode 100644 index 00000000..4ff0b6ec Binary files /dev/null and b/tee/03_serial_logs.png differ diff --git a/tee/04_swarms_agent_containers.png b/tee/04_swarms_agent_containers.png new file mode 100644 index 00000000..76ffb6f3 Binary files /dev/null and b/tee/04_swarms_agent_containers.png differ diff --git a/tee/05_agent_output.png b/tee/05_agent_output.png new file mode 100644 index 00000000..35d6a5d8 Binary files /dev/null and b/tee/05_agent_output.png differ diff --git a/tee/06_attestation.png b/tee/06_attestation.png new file mode 100644 index 00000000..b3bbf389 Binary files /dev/null and b/tee/06_attestation.png differ diff --git a/tee/README.md b/tee/README.md index 6b3ebe13..1a9b51c4 100644 --- a/tee/README.md +++ b/tee/README.md @@ -1,7 +1,73 @@ -## To run project in Phala TEE +# Running Swarms Agent in Phala TEE -1. Build the docker image and publish it to the docker hub - `docker compose build -t /swarm-agent-node:latest` - `docker push /swarm-agent-node:latest` -2. Deploy to Phala cloud using [tee-cloud-cli](https://github.com/Phala-Network/tee-cloud-cli) or manually with the [Cloud dashboard](https://cloud.phala.network/). -3. Check your agent's TEE proof and verify it on the [TEE Attestation Explorer](https://proof.t16z.com/). +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 + +### 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. Create a new Swarms agent application + ![Creating a Swarms agent on Phala Cloud](./01_create_agent_on_phala_cloud.png) + +### 3. Monitor Your Deployment + +1. Check the initialization logs of your agent + ![Agent initialization logs](./02_serial_logs.png) + ![Detailed initialization logs](./03_serial_logs.png) + +2. Verify your container is running + ![Swarms Agent Container Status](./04_swarms_agent_containers.png) + +3. Monitor your agent's output + ![Swarms Agent Logs](./05_agent_output.png) + +### 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](./06_attestation.png) + +## 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. diff --git a/tee/docker-compose.yaml b/tee/docker-compose.yaml index 7fd3207f..1e1f3709 100644 --- a/tee/docker-compose.yaml +++ b/tee/docker-compose.yaml @@ -1,19 +1,27 @@ 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: