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
add new container to sync public models
Forhad Hosainec427aac9ee4
diff --git a/docker-compose.yml b/docker-compose.ymlindex ad2f1f65..f50c36a3 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -1,7 +1,7 @@services:# Traefik Reverse Proxytraefik:- image: traefik:v3.0+ image: traefik:v3.6.2container_name: smythos-traefikrestart: unless-stoppedcommand:@@ -63,7 +63,17 @@ services:- smythos-networkcommand: --default-authentication-plugin=mysql_native_passwordhealthcheck:- test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${DATABASE_USER:-smythos_user}", "-p${DATABASE_PASSWORD:-smythos_password}"]+ test:+ [+ "CMD",+ "mysqladmin",+ "ping",+ "-h",+ "localhost",+ "-u",+ "${DATABASE_USER:-smythos_user}",+ "-p${DATABASE_PASSWORD:-smythos_password}",+ ]interval: 10stimeout: 5sretries: 5@@ -102,6 +112,57 @@ services:retries: 5start_period: 10s+ # Git Sync - Syncs public repository every 5 minutes to SMYTH_PATH+ git-sync:+ image: registry.k8s.io/git-sync/git-sync:v4.2.4+ container_name: smythos-git-sync+ restart: unless-stopped+ env_file:+ - .env+ environment:+ # Repository to sync+ GITSYNC_REPO: ${GIT_SYNC_REPO_URL:-https://github.com/SmythOS/sre-models-pub}+ # Sync every 5 minutes (300 seconds)+ GITSYNC_PERIOD: ${GIT_SYNC_INTERVAL:-300s}+ # Root directory where repo will be synced (models subdirectory)+ # Git-sync will sync repository content directly to /data/models/+ # Since we mount SMYTH_PATH/models:/data/models, this syncs to ${SMYTH_PATH}/models on the host+ # Repository directories from GitHub will be directly accessible at ${SMYTH_PATH}/models/<model directories>+ GITSYNC_ROOT: /data/models+ # Sync continuously (not one-time)+ GITSYNC_ONE_TIME: "false"+ # Sync depth (use shallow clone for performance)+ GITSYNC_DEPTH: ${GIT_SYNC_DEPTH:-1}+ # Branch to sync+ GITSYNC_BRANCH: ${GIT_SYNC_BRANCH:-main}+ # Verbose logging+ GITSYNC_VERBOSE: ${GIT_SYNC_VERBOSE:-2}+ volumes:+ # Bind mount to host path: SMYTH_PATH/models (defaults to $HOME/smythos-data/.smyth if not set)+ # SMYTH_PATH points to the .smyth directory (e.g., /home/user/smythos-data/.smyth)+ # Mounting only the models subdirectory preserves all other .smyth contents+ # Git-sync will sync repository content directly to /data/models in the container+ # Model directories from GitHub will be accessible at ${SMYTH_PATH}/models/<model directories> on the host+ - ${SMYTH_PATH:-$HOME/smythos-data/.smyth}/models:/data/models+ user: "0:0"+ networks:+ - smythos-network+ healthcheck:+ # Check if /data/models directory exists and has repository content+ # Repository content will be synced directly to /data/models/ after first successful clone+ # Increased start_period to allow time for initial repository clone+ test:+ [+ "CMD",+ "sh",+ "-c",+ "test -d /data/models && [ \"$(ls -A /data/models 2>/dev/null | grep -v '^\\.worktrees$' | head -1)\" ]",+ ]+ interval: 30s+ timeout: 10s+ retries: 5+ start_period: 180s+# SmythOS Applicationsmythos:image: smythos/smythos-studio:alpha@@ -123,7 +184,7 @@ services:DOCKER_CONTAINER: "true"labels:- traefik.enable=true-+# APP_DOMAIN routing to port 5050 (UI Server)- "traefik.http.routers.smythos-app.rule=Host(`${APP_DOMAIN:-localhost}`)"- "traefik.http.routers.smythos-app.entrypoints=web,websecure"@@ -132,12 +193,10 @@ services:# TLS configuration (only enable for production with real domains)- "traefik.http.routers.smythos-app.tls=${ENABLE_TLS:-false}"- "traefik.http.routers.smythos-app.tls.certresolver=le"---+# Service definition- "traefik.http.services.smythos-app.loadbalancer.server.port=5050"-+# RUNTIME_DOMAIN routing to port 5053 (Runtime Server)- "traefik.http.routers.smythos-runtime.rule=Host(`${RUNTIME_DOMAIN:-runtime.localhost}`)"- "traefik.http.routers.smythos-runtime.entrypoints=web,websecure"@@ -146,7 +205,7 @@ services:- "traefik.http.routers.smythos-runtime.tls=${ENABLE_TLS:-false}"- "traefik.http.routers.smythos-runtime.tls.certresolver=le"- "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}`) || HostRegexp(`^.+\\.${PROD_AGENT_DOMAIN:-prod\\.localhost}$$`)"- "traefik.http.routers.smythos-prod-agents.entrypoints=web,websecure"@@ -154,7 +213,7 @@ services:# TLS configuration (only enable for production with real domains)- "traefik.http.routers.smythos-prod-agents.tls=${ENABLE_TLS:-false}"- "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}`) || HostRegexp(`^.+\\.${DEFAULT_AGENT_DOMAIN:-default\\.localhost}$$`)"- "traefik.http.routers.smythos-default-agents.entrypoints=web,websecure"@@ -162,7 +221,7 @@ services:# TLS configuration (only enable for production with real domains)- "traefik.http.routers.smythos-default-agents.tls=${ENABLE_TLS:-false}"- "traefik.http.routers.smythos-default-agents.tls.certresolver=le"-+# Security Headers Middleware- "traefik.http.middlewares.smythos.headers.STSSeconds=315360000"- "traefik.http.middlewares.smythos.headers.STSPreload=true"@@ -174,6 +233,20 @@ services:volumes:- smythos_data:/home/node/smythos-data+ # Mount entire .smyth directory from host for application data persistence+ # The .smyth directory contains multiple subdirectories:+ # - models/: Synced by git-sync (public models from GitHub)+ # - .sre/: SRE vault configuration (API keys, secrets)+ # - storage/: Application storage for runtime data+ # Mount as read-write to allow application to create/update .sre, storage, and other directories+ - ${SMYTH_PATH:-$HOME/smythos-data/.smyth}:/home/node/smythos-data/.smyth:rw+ # Override models subdirectory as read-only for security+ # Docker respects more specific mounts, so this overrides the parent :rw mount+ # Benefits:+ # - Prevents accidental modification/deletion of synced models by the application+ # - Single source of truth: only git-sync manages model files+ # - Application can still read models but cannot write to them+ - ${SMYTH_PATH:-$HOME/smythos-data/.smyth}/models:/home/node/smythos-data/.smyth/models:ronetworks:- smythos-networkdepends_on:@@ -182,12 +255,17 @@ services:redis:condition: service_healthyhealthcheck:- test: ["CMD", "sh", "-c", "wget --no-verbose --tries=1 --spider http://127.0.0.1:5050/health && wget --no-verbose --tries=1 --spider http://127.0.0.1:5053/health"]+ test:+ [+ "CMD",+ "sh",+ "-c",+ "wget --no-verbose --tries=1 --spider http://127.0.0.1:5050/health && wget --no-verbose --tries=1 --spider http://127.0.0.1:5053/health",+ ]interval: 30stimeout: 10sretries: 3start_period: 60s-networks:smythos-network:@@ -200,6 +278,7 @@ volumes:driver: localsmythos_data:driver: local+ git_sync_data:+ driver: localtraefik_letsencrypt:driver: local-diff --git a/packages/app/package.json b/packages/app/package.jsonindex 16fff261..497da91a 100644--- a/packages/app/package.json+++ b/packages/app/package.json@@ -69,6 +69,7 @@"file-saver": "^2.0.5","file-type": "3.9.0","flowbite-react": "^0.7.2",+ "form-data": "^4.0.5","formik": "^2.4.5","googleapis": "^121.0.0","he": "^1.2.0",diff --git a/packages/runtime/src/core/services/repo-sync.service.ts b/packages/runtime/src/core/services/repo-sync.service.tsdeleted file mode 100644index f43c220c..00000000--- a/packages/runtime/src/core/services/repo-sync.service.ts+++ /dev/null@@ -1,195 +0,0 @@-import fs from 'fs';-import path from 'path';-import simpleGit, { GitError, SimpleGit } from 'simple-git';--import { Logger } from '@smythos/sre';--const console = Logger('repo-sync');--/**- * Configuration for repository synchronization- */-interface RepoSyncConfig {- /** Base directory where the repository will be stored */- baseDir: string;- /** Repository URL to clone/pull */- repoUrl: string;- /** Local directory name where the repository will be cloned */- localDirName: string;- /** Sync interval in milliseconds (default: 5 minutes) */- syncInterval?: number;-}--/**- * Service to manage periodic synchronization of a git repository- */-export class RepoSyncService {- private config: RepoSyncConfig;- private syncIntervalId: NodeJS.Timeout | null = null;- private isSyncing = false;- private repoPath: string;- private git: SimpleGit;-- constructor(config: RepoSyncConfig) {- this.config = {- ...config,- syncInterval: config.syncInterval || 5 * 60 * 1000, // Default to 5 minutes- };- this.repoPath = path.join(this.config.baseDir, this.config.localDirName);- this.git = simpleGit();- }-- /**- * Start the periodic synchronization service- */- public start(): void {- console.info(`🔄 Starting repository sync service`);- console.info(` Repository: ${this.config.repoUrl}`);- console.info(` Local path: ${this.repoPath}`);- console.info(` Sync interval: ${this.config.syncInterval! / 1000 / 60} minutes`);-- // Perform initial sync- this.sync().catch((error: Error) => {- console.error('Failed initial repository sync:', error);- });-- // Set up periodic sync- this.syncIntervalId = setInterval(() => {- this.sync().catch((error: Error) => {- console.error('Failed periodic repository sync:', error);- });- }, this.config.syncInterval);-- console.info('✅ Repository sync service started');- }-- /**- * Stop the periodic synchronization service- */- public stop(): void {- if (this.syncIntervalId) {- clearInterval(this.syncIntervalId);- this.syncIntervalId = null;- console.info(`🛑 Repository sync service stopped (${this.config.localDirName})`);- }- }-- /**- * Perform a single synchronization operation- */- private async sync(): Promise<void> {- if (this.isSyncing) {- console.warn('Sync already in progress, skipping...');- return;- }-- this.isSyncing = true;-- try {- // Ensure base directory exists- if (!fs.existsSync(this.config.baseDir)) {- fs.mkdirSync(this.config.baseDir, { recursive: true });- console.info(`📁 Created base directory: ${this.config.baseDir}`);- }-- // Check if repository directory exists- if (fs.existsSync(this.repoPath)) {- await this.pullRepository();- } else {- await this.cloneRepository();- }- } catch (error) {- console.error('Sync operation failed:', error);- throw error;- } finally {- this.isSyncing = false;- }- }-- /**- * Clone the repository- */- private async cloneRepository(): Promise<void> {- console.info(`📥 Cloning repository: ${this.config.repoUrl}`);-- try {- await this.git.clone(this.config.repoUrl, this.repoPath);- console.info(`✅ Successfully cloned repository to ${this.repoPath}`);- } catch (error) {- const gitError = error as GitError;- console.error('Failed to clone repository:', gitError.message);- throw new Error(`Repository clone failed: ${gitError.message}`);- }- }-- /**- * Pull latest changes from the repository- */- private async pullRepository(): Promise<void> {- console.info(`🔄 Pulling latest changes from ${this.config.repoUrl}`);-- try {- // Initialize git instance for the repository- const repoGit = simpleGit(this.repoPath);-- // First, check if the directory is a valid git repository- const isRepo = await repoGit.checkIsRepo();-- if (!isRepo) {- console.warn('Directory exists but is not a git repository, removing and re-cloning...');- fs.rmSync(this.repoPath, { recursive: true, force: true });- await this.cloneRepository();- return;- }-- // Perform git pull- const pullResult = await repoGit.pull('origin', 'main');-- if (pullResult.summary.changes === 0 && pullResult.summary.insertions === 0 && pullResult.summary.deletions === 0) {- console.info('📋 Repository is already up to date');- } else {- console.info('✅ Successfully pulled latest changes');- console.info(` Files changed: ${pullResult.summary.changes}`);- console.info(` Insertions: ${pullResult.summary.insertions}`);- console.info(` Deletions: ${pullResult.summary.deletions}`);- }- } catch (error) {- const gitError = error as GitError;- console.error('Failed to pull repository:', gitError.message);- throw new Error(`Repository pull failed: ${gitError.message}`);- }- }-- /**- * Get the local path to the repository- */- public getRepoPath(): string {- return this.repoPath;- }-- /**- * Check if the repository is currently syncing- */- public getIsSyncing(): boolean {- return this.isSyncing;- }-}--/**- * Create and configure the public models repository sync service- *- * @param baseDir - Base directory where the repository will be stored- * @returns RepoSyncService instance configured for public models- *- * @remarks- * This clones the sre-models-pub repository from GitHub into a local directory- * named 'models' to decouple the local directory name from the repository name.- */-export function createPubModelsSync(baseDir: string): RepoSyncService {- return new RepoSyncService({- baseDir,- repoUrl: 'https://github.com/SmythOS/sre-models-pub',- localDirName: 'models', // Local directory name (decoupled from repo name)- syncInterval: 2 * 60 * 1000, // 2 minutes- });-}diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.tsindex 2d6637c0..e1775453 100644--- a/packages/runtime/src/index.ts+++ b/packages/runtime/src/index.ts@@ -14,7 +14,6 @@ import { Logger, SmythRuntime, version } from '@smythos/sre';// Core importsimport config from '@core/config';import { startServers } from '@core/management-router';-import { createPubModelsSync, RepoSyncService } from '@core/services/repo-sync.service';import { requestContext } from '@core/services/request-context';import cors from '@core/middlewares/cors.mw';@@ -204,7 +203,6 @@ app.use(notFoundHandler);app.use(errorHandler);let server: Server | null = null;-let pubModelsRepoSync: RepoSyncService | null = null;(async () => {try {@@ -215,17 +213,12 @@ let pubModelsRepoSync: RepoSyncService | null = null;console.info('⚡ Starting Main Runtime Services...');server = startServers();- // Start the public models repository sync service- console.info('⚡ Starting Public Models Repository Sync...');- pubModelsRepoSync = createPubModelsSync(config.env.SRE_STORAGE_PATH);- pubModelsRepoSync.start();-// Log all running servicesconsole.info('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');console.info('🎯 All Services Running:');console.info(` • Management Server: http://localhost:${config.env.ADMIN_PORT || '5054'}`);console.info(` • Runtime Server: http://localhost:${port}`);- console.info(` • SRE Models Sync: ${path.join(process.env.SMYTH_PATH, 'models')}`);+ console.info(` • SRE Models Sync: Managed by git-sync container`);console.info('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');console.info('✨ SmythOS Runtime is ready!');} catch (error) {@@ -243,11 +236,6 @@ const gracefulShutdown = async (signal: string) => {console.info(`Received ${signal}, shutting down gracefully`);try {- // Stop repository sync service- if (pubModelsRepoSync) {- pubModelsRepoSync.stop();- }-// Close HTTP server if it existsif (server) {server.close(() => {