SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
oss changes
Ahmed Essam776b067f72cd
diff --git a/.env.compose.example b/.env.compose.examplenew file mode 100644index 00000000..50917135--- /dev/null+++ b/.env.compose.example@@ -0,0 +1,35 @@+NODE_ENV="production"+LOG_LEVEL="debug"+++DATABASE_PROVIDER=mysql+DATABASE_HOST=localhost+DATABASE_USER=smythos_user+DATABASE_PASSWORD=samplepassword111+DATABASE_NAME=smythos-local++# Expansion to build the database url (this entry is MANDATORY for Prisma to work)+DATABASE_URL="$DATABASE_PROVIDER://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST:3306/$DATABASE_NAME?allowPublicKeyRetrieval=true&useSSL=false"+++APP_DOMAIN="localhost"+RUNTIME_DOMAIN="runtime.localhost"+DEFAULT_AGENT_DOMAIN="default.localhost"+PROD_AGENT_DOMAIN="prod.localhost"++MIDDLEWARE_API_PORT="5000"+APP_DEV_SERVER_PORT="4001"+RUNTIME_PORT="5053"+APP_PORT="5050"+OPENAI_API_KEY="openai-api-key"+++REDIS_HOST=redis+REDIS_PORT=6379+REDIS_PASSWORD=redis_password++++EXPOSE_TRAEFIK_PORT="80"+EXPOSE_HTTPS_TRAEFIK_PORT="443"+DATABASE_ROOT_PASSWORD=smythos_root_password # used for creating the database via docker-compose\ No newline at end of filediff --git a/.env.example b/.env.exampleindex 9cf05e7e..ad2679ff 100644--- a/.env.example+++ b/.env.example@@ -1,12 +1,13 @@NODE_ENV="development"+LOG_LEVEL="debug"DATABASE_PROVIDER=mysqlDATABASE_HOST=localhost-DATABASE_USER=smythos_user-DATABASE_PASSWORD=samplepassword111-DATABASE_NAME=smythos-local-DATABASE_ROOT_PASSWORD=smythos_root_password # used for creating the database via docker-compose+DATABASE_USER=root+DATABASE_PASSWORD=smythos_root_pass+DATABASE_NAME=smythos_db+# Expansion to build the database url (this entry is MANDATORY for Prisma to work)DATABASE_URL="$DATABASE_PROVIDER://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST:3306/$DATABASE_NAME?allowPublicKeyRetrieval=true&useSSL=false"@@ -15,17 +16,10 @@ APP_DOMAIN="localhost"RUNTIME_DOMAIN="runtime.localhost"DEFAULT_AGENT_DOMAIN="default.localhost"PROD_AGENT_DOMAIN="prod.localhost"+MIDDLEWARE_API_PORT="5000"APP_DEV_SERVER_PORT="4001"RUNTIME_PORT="5053"APP_PORT="5050"OPENAI_API_KEY="openai-api-key"--REDIS_HOST=redis-REDIS_PORT=6379-REDIS_PASSWORD=redis_password---EXPOSE_TRAEFIK_PORT="80"-EXPOSE_HTTPS_TRAEFIK_PORT="443"\ No newline at end of filediff --git a/.vscode/launch.json b/.vscode/launch.jsonindex eaf23d20..dd9f7fac 100644--- a/.vscode/launch.json+++ b/.vscode/launch.json@@ -11,7 +11,9 @@"outFiles": ["${workspaceFolder}/packages/app/dist/**/*.js"],"sourceMaps": true,"cwd": "${workspaceFolder}/packages/app",- "env": {},+ "env": {+ "LOCAL_MODE": "true"+ },"outputCapture": "std","console": "integratedTerminal"},diff --git a/DOCKER.md b/DOCKER.mdnew file mode 100644index 00000000..1390fd76--- /dev/null+++ b/DOCKER.md@@ -0,0 +1,301 @@+# Docker Setup Guide for SmythOS UI++This guide explains how to run SmythOS UI using Docker, both with the standalone Dockerfile and the complete docker-compose setup.++## Contents++- [Docker Setup Guide for SmythOS UI](#docker-setup-guide-for-smythos-ui)+ - [Contents](#contents)+ - [Prerequisites](#prerequisites)+ - [Quick Start with Docker Compose (Recommended)](#quick-start-with-docker-compose-recommended)+ - [1. Environment Setup](#1-environment-setup)+ - [2. Start All Services](#2-start-all-services)+ - [3. Access the Application](#3-access-the-application)+ - [Docker Compose Architecture](#docker-compose-architecture)+ - [Services Overview](#services-overview)+ - [Network Architecture](#network-architecture)+ - [Volume Management](#volume-management)+ - [Standalone Dockerfile Usage](#standalone-dockerfile-usage)+ - [Building the Image](#building-the-image)+ - [Running the Container](#running-the-container)+ - [Environment Variables](#environment-variables)+ - [Required Variables](#required-variables)+ - [Optional Variables](#optional-variables)+ - [Domain Configuration](#domain-configuration)+ - [Production Deployment](#production-deployment)+ - [SSL/TLS Configuration](#ssltls-configuration)+ - [Security Considerations](#security-considerations)+ - [Development with Docker](#development-with-docker)+ - [Troubleshooting](#troubleshooting)+ - [Common Issues](#common-issues)+ - [Logs and Debugging](#logs-and-debugging)+ - [Maintenance](#maintenance)+ - [Updates](#updates)+ - [Backups](#backups)+ - [Cleanup](#cleanup)++## Prerequisites++- **Docker**: Version 20.10 or newer+- **Docker Compose**: Version 2.0 or newer (included with Docker Desktop)+- **System Requirements**:+ - 4GB RAM minimum (8GB recommended)+ - 10GB free disk space+ - Ports 80, 443, 5050, 5053, 8080 available++## Quick Start with Docker Compose (Recommended)++The docker-compose setup provides a complete production-ready environment with all necessary services.++### 1. Environment Setup++Create your environment file:++```bash+cp .env.example .env+```++(Optional) Edit the `.env` file with your configuration (e.g. changing default passwords, configuring domains, etc.)+++### 2. Start All Services++Launch the complete SmythOS UI stack:++```bash+# Start all services in detached mode+docker-compose up -d++# View logs (optional)+docker-compose logs -f+```++### 3. Access the Application++Once all services are healthy:++- **Main Application**: http://localhost (or your configured APP_DOMAIN)+- **Runtime Server**: http://runtime.localhost (or your configured RUNTIME_DOMAIN)++> **⚠️ Localhost Subdomain Issue**: Only applies when using the default localhost domain configuration. Some operating systems don't automatically route `*.localhost` subdomains to the loopback address. If you can't access the subdomain URLs above, add them to your hosts file:+>+> **Linux/macOS:**+> ```bash+> sudo echo "127.0.0.1 runtime.localhost prod.localhost default.localhost" >> /etc/hosts+> ```+>+> **Windows (as Administrator):**+> ```cmd+> echo 127.0.0.1 runtime.localhost prod.localhost default.localhost >> C:\Windows\System32\drivers\etc\hosts+> ```+>++## Docker Compose Architecture++### Services Overview++| Service | Purpose | Port | Health Check |+|---------|---------|------|--------------|+| **traefik** | Reverse proxy & SSL termination | 80, 443, 8080 | Built-in |+| **mysql** | Database server | 3306 (internal) | mysqladmin ping |+| **redis** | Cache & session store | 6379 (internal) | redis-cli ping |+| **smythos** | Main application | 5050, 5053 | HTTP health endpoints |++### Network Architecture++```+┌─────────────────┐ ┌──────────────────┐+│ Internet │────│ Traefik │+│ │ │ (Port 80/443) │+└─────────────────┘ └──────────────────┘+ │+ ┌───────────┼───────────┐+ │ │ │+ ┌───────▼────┐ ┌────▼────┐ ┌───▼────┐+ │ SmythOS │ │ MySQL │ │ Redis │+ │ (5050/5053)│ │ (3306) │ │ (6379) │+ └────────────┘ └─────────┘ └────────┘+```++### Volume Management++- **mysql_data**: Persistent MySQL database storage+- **redis_data**: Redis persistence and cache+- **smythos_data**: Application data and user uploads+- **traefik_letsencrypt**: SSL certificates storage++## Standalone Dockerfile Usage++For custom deployments or development, you can use the Dockerfile directly.++### Building the Image++```bash+# Build the SmythOS UI image+docker build -t smythos-ui:latest .++# Build with specific tag+docker build -t smythos-ui:v1.0.0 .+```++### Running the Container++```bash+# Run with external database+docker run -d \+ --name smythos-app \+ -p 5050:5050 \+ -p 5053:5053 \+ -e DATABASE_URL="mysql://user:password@host:3306/database" \+ -v smythos_data:/root/smythos-data \+ smythos-ui:latest++# Run with environment file+docker run -d \+ --name smythos-app \+ -p 5050:5050 \+ -p 5053:5053 \+ --env-file .env \+ -v smythos_data:/root/smythos-data \+ smythos-ui:latest+```++## Environment Variables++### Required Variables++| Variable | Description | Example |+|----------|-------------|---------|+| `DATABASE_URL` | MySQL connection string | `mysql://user:pass@host:3306/db` |+++### Domain Configuration++For production deployments with custom domains:++```env+# Your main application domain+APP_DOMAIN=app.yourdomain.com++# Runtime/API domain+RUNTIME_DOMAIN=runtime.yourdomain.com++# Production agents domain+PROD_AGENT_DOMAIN=agents.yourdomain.com++# Development/testing agents domain+DEFAULT_AGENT_DOMAIN=dev-agents.yourdomain.com+```++## Production Deployment++### SSL/TLS Configuration++The docker-compose setup includes automatic SSL certificate generation via Let's Encrypt:++1. **Configure your domains** in `.env`:+ ```env+ APP_DOMAIN=yourdomain.com+ RUNTIME_DOMAIN=runtime.yourdomain.com+ ```++2. **Ensure DNS records** point to your server:+ ```+ yourdomain.com A YOUR_SERVER_IP+ runtime.yourdomain.com A YOUR_SERVER_IP+ *.yourdomain.com A YOUR_SERVER_IP # For subdomains+ ```++3. **Start with SSL enabled**:+ ```bash+ docker-compose up -d+ ```++### Security Considerations++- **Change default passwords** in `.env`+- **Use strong database credentials**+- **Configure firewall** to only allow necessary ports+- **Regular updates** of Docker images+- **Monitor logs** for suspicious activity+++## Troubleshooting++### Common Issues++**1. Can't access subdomain URLs (runtime.localhost, prod.localhost, etc.):**++This only applies when using the default localhost domain configuration. In case you can't access the subdomain URLs above, add them to your hosts file:++**Solution - Add to hosts file:**+```bash+# Linux/macOS+sudo sh -c 'echo "127.0.0.1 runtime.localhost prod.localhost default.localhost" >> /etc/hosts'++# Windows (run as Administrator)+echo 127.0.0.1 runtime.localhost prod.localhost default.localhost >> C:\Windows\System32\drivers\etc\hosts+```++**Alternative - Use direct ports:**+- Main App: http://localhost:5050+- Runtime: http://localhost:5053++**2. Services not starting:**+```bash+# Check service status+docker-compose ps++# View logs for specific service+docker-compose logs mysql+docker-compose logs smythos+```++**3. Database connection errors:**+```bash+# Verify MySQL is healthy+docker-compose exec mysql mysqladmin ping -u root -p++# Check database connectivity from app+docker-compose exec smythos sh -c "mysql -h mysql -u \$DATABASE_USER -p\$DATABASE_PASSWORD -e 'SELECT 1'"+```++**4. Port conflicts:**+```bash+# Check what's using the ports+netstat -tlnp | grep :80+netstat -tlnp | grep :443+++# Either stop any service using 80 and/or 443 OR use different ports in .env (not suitable for production)+EXPOSE_TRAEFIK_PORT=8080+EXPOSE_HTTPS_TRAEFIK_PORT=8443+```++## Maintenance++### Updates++```bash+# Down the services+docker-compose down++# Pull latest images+docker-compose pull++# Rebuild and restart services+docker-compose up -d+```+++## Support++For issues with Docker deployment:++1. Check the [Troubleshooting](#troubleshooting) section+2. Review container logs: `docker-compose logs -f`+3. Verify environment configuration in `.env`+4. Ensure all prerequisites are met++For development setup, see [CONTRIBUTING.md](CONTRIBUTING.md) for the local development environment.diff --git a/docker-compose.yml b/docker-compose.ymlindex 081ef363..499f6996 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -154,14 +154,14 @@ services:- "traefik.http.services.smythos-runtime.loadbalancer.server.port=5053"# PROD_AGENT_DOMAIN routing to port 5053 (Production Agents)- - "traefik.http.routers.smythos-prod-agents.rule=Host(`${PROD_AGENT_DOMAIN:-prod.localhost}`)"+ - "traefik.http.routers.smythos-prod-agents.rule=Host(`${PROD_AGENT_DOMAIN:-prod.localhost}`) || HostRegexp(`^.+\\.${PROD_AGENT_DOMAIN:-prod\\.localhost}$`)"- "traefik.http.routers.smythos-prod-agents.entrypoints=web,websecure"- "traefik.http.routers.smythos-prod-agents.service=smythos-runtime"- "traefik.http.routers.smythos-prod-agents.tls=true"- "traefik.http.routers.smythos-prod-agents.tls.certresolver=le"# DEFAULT_AGENT_DOMAIN routing to port 5053 (Default/Development Agents)- - "traefik.http.routers.smythos-default-agents.rule=Host(`${DEFAULT_AGENT_DOMAIN:-default.localhost}`)"+ - "traefik.http.routers.smythos-default-agents.rule=Host(`${DEFAULT_AGENT_DOMAIN:-default.localhost}`) || HostRegexp(`^.+\\.${DEFAULT_AGENT_DOMAIN:-default\\.localhost}$`)"- "traefik.http.routers.smythos-default-agents.entrypoints=web,websecure"- "traefik.http.routers.smythos-default-agents.service=smythos-runtime"- "traefik.http.routers.smythos-default-agents.tls=true"diff --git a/packages/app/src/backend/middlewares/acl.mw.ts b/packages/app/src/backend/middlewares/acl.mw.tsindex 841b0d03..f0c95cb3 100644--- a/packages/app/src/backend/middlewares/acl.mw.ts+++ b/packages/app/src/backend/middlewares/acl.mw.ts@@ -63,6 +63,8 @@ async function getTeamInfo(req: express.Request | any, isRetry: boolean = false)) {await userData.putUserSettings(token, userSettingKeys.USER_TEAM, '');return getTeamInfo(req, true);+ } else {+ throw new Error('Failed to fetch team info:' + teamInfo.error?.response?.data);}}return teamInfo;@@ -131,7 +133,6 @@ export async function pageACLCheck(if (rule?.access === 'rw' || rule?.access === 'r') {next();} else {- // console.log('Forbidden: No valid access', req.url, rule);return renderErrorPage(res, req, 403, 'Forbidden');}}diff --git a/packages/app/src/backend/services/cache.service.ts b/packages/app/src/backend/services/cache.service.tsindex 18fd663d..751037df 100644--- a/packages/app/src/backend/services/cache.service.ts+++ b/packages/app/src/backend/services/cache.service.ts@@ -28,17 +28,31 @@ export class RedisCache implements ICache {}this.client = new Redis({- ...(config.env.REDIS_SENTINEL_HOSTS ? { sentinels: config.env.REDIS_SENTINEL_HOSTS?.split(',').map((host) => {- const [hostname, port] = host.split(':');- return { host: hostname, port: parseInt(port) };- }),- name: config.env.REDIS_MASTER_NAME,- } : {- host: config.env.REDIS_HOST,- }),+ ...(config.env.REDIS_SENTINEL_HOSTS+ ? {+ sentinels: config.env.REDIS_SENTINEL_HOSTS?.split(',').map((host) => {+ const [hostname, port] = host.split(':');+ return { host: hostname, port: parseInt(port) };+ }),+ name: config.env.REDIS_MASTER_NAME,+ }+ : {+ host: config.env.REDIS_HOST,+ }),port: parseInt(config.env.REDIS_PORT),...(config.env.REDIS_PASSWORD ? { password: config.env.REDIS_PASSWORD } : {}),});++ // try to connect on class creation and check if connection is successful+ this.client+ .ping()+ .then(() => {+ console.log('Redis connection successful');+ })+ .catch((err) => {+ console.error('Redis connection failed', err);+ throw err;+ });}async get(key: string): Promise<string | null> {diff --git a/packages/runtime/src/core/config.ts b/packages/runtime/src/core/config.tsindex fb91c832..2a207a8a 100644--- a/packages/runtime/src/core/config.ts+++ b/packages/runtime/src/core/config.ts@@ -36,7 +36,7 @@ const config = {LOGTO_M2M_APP_ID: process.env.LOGTO_M2M_APP_ID,DEFAULT_AGENT_DOMAIN: process.env?.DEFAULT_AGENT_DOMAIN || 'localagent.stage.smyth.ai',- AGENT_DOMAIN_PORT: process.env?.AGENT_DOMAIN_PORT || process.env.RUNTIME_PORT,+ AGENT_DOMAIN_PORT: process.env?.AGENT_DOMAIN_PORT,PROD_AGENT_DOMAIN: process.env?.PROD_AGENT_DOMAIN,REQ_LIMIT_PER_MINUTE: process.env.REQ_LIMIT_PER_MINUTE || 300,