Skip to content

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.

pull models from github public repo

Forhad Hosain8f39a4070a5b
diff --git a/packages/runtime/data/models.json b/packages/runtime/data/models.json
deleted file mode 100644
index f0637aef..00000000
--- a/packages/runtime/data/models.json
+++ /dev/null
@@ -1,183 +0,0 @@
-{
- "Echo": {
- "provider": "Echo"
- },
- "gpt-5": {
- "label": "GPT 5",
- "modelId": "gpt-5",
- "provider": "OpenAI",
- "features": ["text", "tools", "image", "reasoning", "search", "document"],
- "tags": ["New", "Personal"],
- "tokens": 400000,
- "completionTokens": 128000,
- "enabled": true,
- "credentials": "vault",
- "interface": "responses"
- },
- "gpt-5-mini": {
- "label": "GPT 5 mini",
- "modelId": "gpt-5-mini",
- "provider": "OpenAI",
- "features": ["text", "tools", "image", "reasoning", "search", "document"],
- "tags": ["New", "Personal"],
- "tokens": 400000,
- "completionTokens": 128000,
- "enabled": true,
- "credentials": "vault",
- "interface": "responses",
- "default": true
- },
- "gpt-5-nano": {
- "label": "GPT 5 nano",
- "modelId": "gpt-5-nano",
- "provider": "OpenAI",
- "features": ["text", "tools", "image", "reasoning", "document"],
- "tags": ["New", "Personal"],
- "tokens": 400000,
- "completionTokens": 128000,
- "enabled": true,
- "credentials": "vault",
- "interface": "responses"
- },
- "gpt-5-chat": {
- "label": "GPT 5 Chat",
- "modelId": "gpt-5-chat-latest",
- "provider": "OpenAI",
- "features": ["text", "image", "document"],
- "tags": ["New", "Personal"],
- "tokens": 400000,
- "completionTokens": 128000,
- "enabled": true,
- "credentials": "vault",
- "interface": "responses"
- },
- "claude-opus-4-1": {
- "label": "Claude Opus 4.1",
- "modelId": "claude-opus-4-1",
- "provider": "Anthropic",
- "features": ["text", "image", "tools", "reasoning"],
- "tags": ["New", "Personal"],
- "tokens": 200000,
- "completionTokens": 32000,
- "maxReasoningTokens": 32000,
- "enabled": true,
- "credentials": "vault"
- },
- "gemini-2.5-pro": {
- "label": "Gemini 2.5 Pro",
- "modelId": "gemini-2.5-pro",
- "provider": "GoogleAI",
- "features": ["text", "image", "audio", "video", "document", "tools", "reasoning"],
- "tags": ["Personal"],
- "tokens": 1048576,
- "completionTokens": 65536,
- "enabled": true,
- "credentials": "vault"
- },
- "gemini-2.5-flash": {
- "label": "Gemini 2.5 Flash",
- "modelId": "gemini-2.5-flash",
- "provider": "GoogleAI",
- "features": ["text", "image", "audio", "video", "document", "tools", "reasoning"],
- "tags": ["New", "Personal"],
- "tokens": 1048576,
- "completionTokens": 65536,
- "enabled": true,
- "credentials": "vault"
- },
- "deepseek-ai/DeepSeek-R1": {
- "label": "DeepSeek - R1",
- "modelId": "deepseek-ai/DeepSeek-R1",
- "provider": "TogetherAI",
- "features": ["text"],
- "tags": ["Personal", "TogetherAI"],
- "tokens": 128000,
- "completionTokens": 32768,
- "enabled": true,
- "baseURL": "https://api.together.xyz/v1",
- "credentials": "vault"
- },
- "deepseek-ai/DeepSeek-V3": {
- "label": "DeepSeek - V3",
- "modelId": "deepseek-ai/DeepSeek-V3",
- "provider": "TogetherAI",
- "features": ["text"],
- "tags": ["Personal", "TogetherAI"],
- "tokens": 131072,
- "completionTokens": 8192,
- "enabled": true,
- "baseURL": "https://api.together.xyz/v1",
- "credentials": "vault"
- },
- "moonshotai/kimi-k2-instruct": {
- "label": "Moonshot - Kimi K2 Instruct Preview",
- "modelId": "moonshotai/kimi-k2-instruct",
- "provider": "Groq",
- "features": ["text", "image", "tools"],
- "tags": ["Personal", "Groq"],
- "tokens": 131072,
- "completionTokens": 16384,
- "enabled": true,
- "credentials": "vault"
- },
- "qwen/qwen3-32b": {
- "label": "Qwen - QWEN3 32b Preview",
- "modelId": "qwen/qwen3-32b",
- "provider": "Groq",
- "features": ["text", "reasoning"],
- "tags": ["Personal", "Groq"],
- "tokens": 131072,
- "completionTokens": 40960,
- "enabled": true,
- "credentials": "vault"
- },
- "grok-4": {
- "label": "Grok 4",
- "modelId": "grok-4-0709",
- "provider": "xAI",
- "features": ["text", "tools", "search"],
- "tags": ["Personal", "xAI"],
- "tokens": 256000,
- "completionTokens": 8192,
- "enabled": true,
- "baseURL": "https://api.x.ai/v1",
- "credentials": "vault"
- },
- "gpt-image-1": {
- "label": "GPT Image 1",
- "modelId": "gpt-image-1",
- "provider": "OpenAI",
- "features": ["image-generation"],
- "tags": ["Personal", "OpenAI"],
- "enabled": true,
- "credentials": "vault"
- },
- "gemini-2.5-flash-image": {
- "label": "Nano Banana",
- "modelId": "gemini-2.5-flash-image-preview",
- "provider": "GoogleAI",
- "features": ["image-generation"],
- "tags": ["New", "Personal", "GoogleAI"],
- "enabled": true,
- "credentials": "vault",
- "interface": "generateContent"
- },
- "imagen-4-ultra": {
- "label": "Imagen 4 Ultra",
- "modelId": "imagen-4.0-ultra-generate-preview-06-06",
- "provider": "GoogleAI",
- "features": ["image-generation"],
- "tags": ["Personal", "GoogleAI"],
- "enabled": true,
- "credentials": "vault"
- },
- "imagen-4": {
- "label": "Imagen 4",
- "modelId": "imagen-4.0-generate-preview-06-06",
- "provider": "GoogleAI",
- "features": ["image-generation"],
- "tags": ["Personal", "GoogleAI"],
- "enabled": true,
- "credentials": "vault"
- }
-}
diff --git a/packages/runtime/package.json b/packages/runtime/package.json
index 331cb841..fa8ceaff 100644
--- a/packages/runtime/package.json
+++ b/packages/runtime/package.json
@@ -68,6 +68,7 @@
"openai": "^4.72.0",
"openapi-to-postmanv2": "^4.24.0",
"pkce-challenge": "^5.0.0",
+ "simple-git": "^3.27.0",
"source-map-support": "^0.5.21",
"swagger-ui-dist": "^5.18.2",
"uuid": "^9.0.1",
diff --git a/packages/runtime/src/core/config/models.config.ts b/packages/runtime/src/core/config/models.config.ts
deleted file mode 100644
index 19f0359c..00000000
--- a/packages/runtime/src/core/config/models.config.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Models Configuration
- *
- * This file provides TypeScript types and loads the models configuration
- * from a JSON file for better maintainability.
- */
-
-import modelsData from '@data/models.json';
-
-// Base interface with all possible fields for non-Echo models
-interface BaseModelConfig {
- label: string;
- modelId: string;
- provider: string;
- features: string[];
- tags: string[];
- tokens: number;
- completionTokens: number;
- enabled: boolean;
- credentials: string;
- interface?: string;
- default?: boolean;
-}
-
-// Echo model configuration (only requires provider)
-interface EchoModelConfig {
- provider: 'Echo';
-}
-
-// Conditional type: if provider is "Echo", use EchoModelConfig, otherwise use BaseModelConfig
-type ModelConfig = EchoModelConfig | BaseModelConfig;
-
-type ModelsConfig = Record<string, ModelConfig>;
-
-// Load models configuration from JSON file
-export const modelsConfig: ModelsConfig = modelsData as ModelsConfig;
diff --git a/packages/runtime/src/core/services/repo-sync.service.ts b/packages/runtime/src/core/services/repo-sync.service.ts
new file mode 100644
index 00000000..f43c220c
--- /dev/null
+++ b/packages/runtime/src/core/services/repo-sync.service.ts
@@ -0,0 +1,195 @@
+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.ts
index f151a5fc..bb659e11 100644
--- a/packages/runtime/src/index.ts
+++ b/packages/runtime/src/index.ts
@@ -13,8 +13,8 @@ import { Logger, SmythRuntime, version } from '@smythos/sre';
// Core imports
import config from '@core/config';
-import { modelsConfig } from '@core/config/models.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';
@@ -100,7 +100,7 @@ const sre = SmythRuntime.Instance.init({
ModelsProvider: {
Connector: 'SmythModelsProvider',
Settings: {
- models: modelsConfig,
+ models: path.join(process.env.SMYTH_PATH, 'models'),
},
},
AgentData: {
@@ -210,6 +210,7 @@ app.use(notFoundHandler);
app.use(errorHandler);
let server: Server | null = null;
+let pubModelsRepoSync: RepoSyncService | null = null;
(async () => {
try {
@@ -220,11 +221,17 @@ let server: Server | 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 services
console.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(config.env.SRE_STORAGE_PATH, 'models')}`);
console.info('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
console.info('✨ SmythOS Runtime is ready!');
} catch (error) {
@@ -242,6 +249,11 @@ 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 exists
if (server) {
server.close(() => {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2737528b..075a40ba 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -667,6 +667,9 @@ importers:
pkce-challenge:
specifier: ^5.0.0
version: 5.0.0
+ simple-git:
+ specifier: ^3.27.0
+ version: 3.30.0
source-map-support:
specifier: ^0.5.21
version: 0.5.21
@@ -2001,6 +2004,12 @@ packages:
'@jridgewell/[email protected]':
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
+ '@kwsites/[email protected]':
+ resolution: {integrity: sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==}
+
+ '@kwsites/[email protected]':
+ resolution: {integrity: sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==}
+
'@microsoft/[email protected]':
resolution: {integrity: sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA==}
@@ -7690,6 +7699,9 @@ packages:
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
engines: {node: '>=14'}
+ resolution: {integrity: sha512-q6lxyDsCmEal/MEGhP1aVyQ3oxnagGlBDOVSIB4XUVLl1iZh0Pah6ebC9V4xBap/RfgP2WlI8EKs0WS0rMEJHg==}
+
resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==}
@@ -10426,6 +10438,14 @@ snapshots:
'@jridgewell/sourcemap-codec': 1.5.4
optional: true
+ '@kwsites/[email protected]':
+ dependencies:
+ debug: 4.4.1([email protected])
+ transitivePeerDependencies:
+ - supports-color
+
+ '@kwsites/[email protected]': {}
+
'@microsoft/[email protected]': {}
'@modelcontextprotocol/[email protected]':
@@ -17599,6 +17619,14 @@ snapshots:
+ dependencies:
+ '@kwsites/file-exists': 1.1.1
+ '@kwsites/promise-deferred': 1.1.1
+ debug: 4.4.1([email protected])
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
is-arrayish: 0.3.2