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
apply standard order in module imports
Forhad Hosainc6ac2b8c448e
diff --git a/packages/runtime/src/core/connectors/ConnectorRegistry.ts b/packages/runtime/src/core/connectors/ConnectorRegistry.tsindex da62feb3..ab330359 100644--- a/packages/runtime/src/core/connectors/ConnectorRegistry.ts+++ b/packages/runtime/src/core/connectors/ConnectorRegistry.ts@@ -3,6 +3,7 @@ import {JSONModelsProvider,TConnectorService,} from "@smythos/sre";+import { SmythOSSAccount } from "./SmythOSSAccount.class";import { SmythOSSAgentDataConnector } from "./SmythOSSAgentDataConnector.class";import { SmythOSSVault } from "./SmythOSSVault.class";diff --git a/packages/runtime/src/core/connectors/SmythOSSAccount.class.ts b/packages/runtime/src/core/connectors/SmythOSSAccount.class.tsindex 48972569..eea9908a 100644--- a/packages/runtime/src/core/connectors/SmythOSSAccount.class.ts+++ b/packages/runtime/src/core/connectors/SmythOSSAccount.class.ts@@ -1,5 +1,5 @@-import { getM2MToken } from "@/core/helpers/logto.helper";-import { SmythConfigs } from "@core/types/general.types";+import axios, { AxiosInstance } from "axios";+import {AccessRequest,AccountConnector,@@ -12,7 +12,9 @@ import {TAccessLevel,TAccessRole,} from "@smythos/sre";-import axios, { AxiosInstance } from "axios";++import { getM2MToken } from "@core/helpers/logto.helper";+import { SmythConfigs } from "@core/types/general.types";const console = Logger("SmythOSSAccount");export class SmythOSSAccount extends AccountConnector {diff --git a/packages/runtime/src/core/connectors/SmythOSSAgentDataConnector.class.ts b/packages/runtime/src/core/connectors/SmythOSSAgentDataConnector.class.tsindex a1602775..07aa94df 100644--- a/packages/runtime/src/core/connectors/SmythOSSAgentDataConnector.class.ts+++ b/packages/runtime/src/core/connectors/SmythOSSAgentDataConnector.class.ts@@ -1,7 +1,10 @@-import { getM2MToken } from "@/core/helpers/logto.helper";-import { SmythConfigs } from "@core/types/general.types";-import { AgentDataConnector, OAuthConfig } from "@smythos/sre";import axios, { AxiosInstance } from "axios";++import { AgentDataConnector, OAuthConfig } from "@smythos/sre";++import { getM2MToken } from "@core/helpers/logto.helper";+import { SmythConfigs } from "@core/types/general.types";+export class SmythOSSAgentDataConnector extends AgentDataConnector {public name: string = "SmythOSSAgentData";private oAuthAppId: string;diff --git a/packages/runtime/src/core/connectors/SmythOSSVault.class.ts b/packages/runtime/src/core/connectors/SmythOSSVault.class.tsindex 3aeaad64..b3eca2b2 100644--- a/packages/runtime/src/core/connectors/SmythOSSVault.class.ts+++ b/packages/runtime/src/core/connectors/SmythOSSVault.class.ts@@ -1,4 +1,5 @@-import { getM2MToken } from "@/core/helpers/logto.helper";+import axios, { AxiosInstance } from "axios";+import {AccessRequest,ACL,@@ -11,7 +12,8 @@ import {TAccessRole,VaultConnector,} from "@smythos/sre";-import axios, { AxiosInstance } from "axios";++import { getM2MToken } from "@core/helpers/logto.helper";export type SmythVaultConfig = {vaultAPIBaseUrl: string;diff --git a/packages/runtime/src/core/router-config.ts b/packages/runtime/src/core/router-config.tsindex f73ada83..d31c35f0 100644--- a/packages/runtime/src/core/router-config.ts+++ b/packages/runtime/src/core/router-config.ts@@ -1,4 +1,19 @@import { Express } from "express";++import { uploadHandler } from "@core/middlewares/uploadHandler.mw";++import agentRunnerOauthRouter from "@agent-runner/routes/_oauth/router";+import agentRunnerAgentLoader from "@agent-runner/middlewares/agentLoader.mw";+import { processAgentRequest as agentRunnerProcessAgentRequest } from "@agent-runner/services/agent-request-handler";++import debuggerAgentLoader from "@debugger/middlewares/agentLoader.mw";+import modelsRouter from "@debugger/routes/models/router";+import {+ createSseConnection as debuggerCreateSseConnection,+ getDebugSession as debuggerGetDebugSession,+ processAgentRequest as debuggerProcessAgentRequest,+} from "@debugger/services/agent-request-handler";+import {RuntimeConfig,loadRuntimeConfig,@@ -10,25 +25,6 @@ import {} from "./shared-agent-router";import { createConfiguredSmartRouter } from "./smart-agent-router";-// Debugger imports-import debuggerAgentLoader from "@debugger/middlewares/agentLoader.mw";-import {- createSseConnection as debuggerCreateSseConnection,- getDebugSession as debuggerGetDebugSession,- processAgentRequest as debuggerProcessAgentRequest,-} from "@debugger/services/agent-request-handler";--// Agent-runner imports-import agentRunnerAgentLoader from "@agent-runner/middlewares/agentLoader.mw";-import { processAgentRequest as agentRunnerProcessAgentRequest } from "@agent-runner/services/agent-request-handler";-import { uploadHandler } from "@core/middlewares/uploadHandler.mw";--// Route imports for service-specific endpoints-import agentRunnerOauthRouter from "@agent-runner/routes/_oauth/router";--// Common route imports - available for all server configurations-import modelsRouter from "@debugger/routes/models/router";-/*** Configures and mounts agent routers based on runtime configuration* Designed for future server extraction without code changesdiff --git a/packages/runtime/src/core/types/declarations/smythos.express.d.ts b/packages/runtime/src/core/types/declarations/smythos.express.d.tsindex 18db9715..acc7b55f 100644--- a/packages/runtime/src/core/types/declarations/smythos.express.d.ts+++ b/packages/runtime/src/core/types/declarations/smythos.express.d.ts@@ -1,8 +1,9 @@import multer from "multer";-import Chatbot from "@embodiment/modules/chatbot/services/Chatbot.class";import { Agent } from "@smythos/sre";+import Chatbot from "@embodiment/modules/chatbot/services/Chatbot.class";+declare global {namespace Express {interface Request {diff --git a/packages/runtime/src/modules/agent-runner/middlewares/agentLoader.mw.ts b/packages/runtime/src/modules/agent-runner/middlewares/agentLoader.mw.tsindex 02d2cad8..cad6b5fe 100644--- a/packages/runtime/src/modules/agent-runner/middlewares/agentLoader.mw.ts+++ b/packages/runtime/src/modules/agent-runner/middlewares/agentLoader.mw.ts@@ -1,14 +1,13 @@-import { ConnectorService } from "@smythos/sre";--import { DEFAULT_FILE_PARSING_ENDPOINT } from "@agent-runner/constants";-import config from "@core/config";+import { ConnectorService, Logger } from "@smythos/sre";import {addDefaultComponentsAndConnections,extractAgentVerionsAndPath,getAgentDomainById,} from "@core/helpers/agent.helper";-import { Logger } from "@smythos/sre";+import config from "@core/config";++import { DEFAULT_FILE_PARSING_ENDPOINT } from "@agent-runner/constants";const console = Logger("(Agent Runner) Middleware: Agent Loader");diff --git a/packages/runtime/src/modules/agent-runner/routes/agent/router.ts b/packages/runtime/src/modules/agent-runner/routes/agent/router.tsindex eae29268..1741c258 100644--- a/packages/runtime/src/modules/agent-runner/routes/agent/router.ts+++ b/packages/runtime/src/modules/agent-runner/routes/agent/router.ts@@ -1,5 +1,6 @@import agentLoader from "@agent-runner/middlewares/agentLoader.mw";import { processAgentRequest } from "@agent-runner/services/agent-request-handler";+import { uploadHandler } from "@core/middlewares/uploadHandler.mw";import { createAgentRunnerRouter } from "@core/shared-agent-router";diff --git a/packages/runtime/src/modules/agent-runner/services/logto-helper.ts b/packages/runtime/src/modules/agent-runner/services/logto-helper.tsindex ccbf06e0..04d107f4 100644--- a/packages/runtime/src/modules/agent-runner/services/logto-helper.ts+++ b/packages/runtime/src/modules/agent-runner/services/logto-helper.ts@@ -1,69 +1,69 @@-import axios from 'axios';-import qs from 'querystring';+import axios from "axios";+import qs from "querystring";-import config from '@agent-runner/config';+import config from "@agent-runner/config";//M2M testconst postData = {- grant_type: 'client_credentials',- resource: 'https://default.logto.app/api',- scope: 'all',+ grant_type: "client_credentials",+ resource: "https://default.logto.app/api",+ scope: "all",};-const base64Credentials = Buffer.from(`${config.env.LOGTO_M2M_APP_ID}:${config.env.LOGTO_M2M_APP_SECRET}`, 'utf8').toString('base64');+const base64Credentials = Buffer.from(+ `${config.env.LOGTO_M2M_APP_ID}:${config.env.LOGTO_M2M_APP_SECRET}`,+ "utf8"+).toString("base64");let tokenData = {- access_token: null,+ access_token: null,};export function getM2MToken(resource?, scope?) {- return new Promise((resolve, reject) => {- if (tokenData.access_token) {- return resolve(tokenData.access_token);- }+ return new Promise((resolve, reject) => {+ if (tokenData.access_token) {+ return resolve(tokenData.access_token);+ }- const body = {- grant_type: 'client_credentials',- resource: resource || config.env.LOGTO_API_RESOURCE,- scope: scope || '',- };- axios({- method: 'post',- url: `${config.env.LOGTO_SERVER}/oidc/token`,- headers: {- Authorization: 'Basic ' + base64Credentials,- 'Content-Type': 'application/x-www-form-urlencoded',- },- data: qs.stringify(body),- })- .then((response) => {- tokenData.access_token = response.data.access_token;- setTimeout(- () => {- tokenData.access_token = null;- },- (response.data.expires_in - 100) * 1000,- );- resolve(tokenData.access_token);- })- .catch((error) => {- reject({ error: error.response.data });- });- });+ const body = {+ grant_type: "client_credentials",+ resource: resource || config.env.LOGTO_API_RESOURCE,+ scope: scope || "",+ };+ axios({+ method: "post",+ url: `${config.env.LOGTO_SERVER}/oidc/token`,+ headers: {+ Authorization: "Basic " + base64Credentials,+ "Content-Type": "application/x-www-form-urlencoded",+ },+ data: qs.stringify(body),+ })+ .then((response) => {+ tokenData.access_token = response.data.access_token;+ setTimeout(() => {+ tokenData.access_token = null;+ }, (response.data.expires_in - 100) * 1000);+ resolve(tokenData.access_token);+ })+ .catch((error) => {+ reject({ error: error.response.data });+ });+ });}export async function getUserInfo(userId: string) {- const token = await getM2MToken('https://default.logto.app/api', 'all');+ const token = await getM2MToken("https://default.logto.app/api", "all");- const response: any = await axios({- method: 'get',- url: `${config.env.LOGTO_SERVER}/api/users/${userId}`,- headers: {- Authorization: `Bearer ${token}`,- },- }).catch((error) => ({ error }));+ const response: any = await axios({+ method: "get",+ url: `${config.env.LOGTO_SERVER}/api/users/${userId}`,+ headers: {+ Authorization: `Bearer ${token}`,+ },+ }).catch((error) => ({ error }));- if (response.error) {- return null;- }+ if (response.error) {+ return null;+ }- return response.data;+ return response.data;}diff --git a/packages/runtime/src/modules/agent-runner/services/smythAPIReq.ts b/packages/runtime/src/modules/agent-runner/services/smythAPIReq.tsindex 9e185c18..722d275e 100644--- a/packages/runtime/src/modules/agent-runner/services/smythAPIReq.ts+++ b/packages/runtime/src/modules/agent-runner/services/smythAPIReq.ts@@ -1,15 +1,15 @@-import axios from 'axios';+import axios from "axios";-import config from '@agent-runner/config';+import config from "@agent-runner/config";//middleware sys APIexport const mwSysAPI = axios.create({- baseURL: `${config.env.SMYTH_API_BASE_URL}/_sysapi/v1`,+ baseURL: `${config.env.SMYTH_API_BASE_URL}/_sysapi/v1`,});export function includeAuth(token: string) {- return {- headers: {- Authorization: `Bearer ${token}`,- },- };+ return {+ headers: {+ Authorization: `Bearer ${token}`,+ },+ };}diff --git a/packages/runtime/src/modules/debugger/middlewares/agentLoader.mw.ts b/packages/runtime/src/modules/debugger/middlewares/agentLoader.mw.tsindex 2c581241..ea5235ed 100644--- a/packages/runtime/src/modules/debugger/middlewares/agentLoader.mw.ts+++ b/packages/runtime/src/modules/debugger/middlewares/agentLoader.mw.ts@@ -1,11 +1,11 @@import { ConnectorService, Logger } from "@smythos/sre";+import config from "@core/config";import {addDefaultComponentsAndConnections,extractAgentVerionsAndPath,getAgentDomainById,-} from "@/core/helpers/agent.helper";-import config from "@core/config";+} from "@core/helpers/agent.helper";const console = Logger("[Debugger] Middleware: agentLoader");diff --git a/packages/runtime/src/modules/debugger/services/agent-request-handler.ts b/packages/runtime/src/modules/debugger/services/agent-request-handler.tsindex eaae7f07..fc2bde32 100644--- a/packages/runtime/src/modules/debugger/services/agent-request-handler.ts+++ b/packages/runtime/src/modules/debugger/services/agent-request-handler.ts@@ -1,10 +1,9 @@import axios from "axios";import { Request } from "express";-import { Logger } from "@smythos/sre";+import { AgentProcess, Logger } from "@smythos/sre";-import { getMockData } from "@/core/helpers/agent.helper";-import { AgentProcess } from "@smythos/sre";+import { getMockData } from "@core/helpers/agent.helper";const console = Logger("Service: Agent Request Handler");diff --git a/packages/runtime/src/modules/embodiment/helpers/openapi-adapter.helper.ts b/packages/runtime/src/modules/embodiment/helpers/openapi-adapter.helper.tsindex b9905f20..83d7c1f1 100644--- a/packages/runtime/src/modules/embodiment/helpers/openapi-adapter.helper.ts+++ b/packages/runtime/src/modules/embodiment/helpers/openapi-adapter.helper.ts@@ -1,11 +1,12 @@-import config from "@/core/config";+import { AgentDataConnector, Logger } from "@smythos/sre";++import config from "@core/config";import {addDefaultComponentsAndConnections,getAgentDataById,getAgentIdByDomain,} from "@core/helpers/agent.helper";import type { AgentData, OpenAPISpec } from "@core/types/openapi.types";-import { AgentDataConnector, Logger } from "@smythos/sre";const console = Logger("openapi-adapter.helper.ts");diff --git a/packages/runtime/src/modules/embodiment/middlewares/agentLoader.mw.ts b/packages/runtime/src/modules/embodiment/middlewares/agentLoader.mw.tsindex eb0ad53d..3f408484 100644--- a/packages/runtime/src/modules/embodiment/middlewares/agentLoader.mw.ts+++ b/packages/runtime/src/modules/embodiment/middlewares/agentLoader.mw.ts@@ -1,11 +1,3 @@-import config from "@core/config";-import {- extractAgentVerionsAndPath,- getAgentDomainById,- getAgentIdAndVersion,-} from "../helpers/agent.helper";--import { addDefaultComponentsAndConnections } from "@/core/helpers/agent.helper";import {Agent,AgentRequest,@@ -14,6 +6,15 @@ import {Logger,} from "@smythos/sre";+import config from "@core/config";+import { addDefaultComponentsAndConnections } from "@core/helpers/agent.helper";++import {+ extractAgentVerionsAndPath,+ getAgentDomainById,+ getAgentIdAndVersion,+} from "@embodiment/helpers/agent.helper";+const console = Logger("[Embodiment] Middleware: Agent Loader");export default async function agentLoader(req, res, next) {diff --git a/packages/runtime/src/modules/embodiment/modules/chatbot/services/FsChatbotContextStore.class/index.ts b/packages/runtime/src/modules/embodiment/modules/chatbot/services/FsChatbotContextStore.class/index.tsindex bea9e29c..310fb946 100644--- a/packages/runtime/src/modules/embodiment/modules/chatbot/services/FsChatbotContextStore.class/index.ts+++ b/packages/runtime/src/modules/embodiment/modules/chatbot/services/FsChatbotContextStore.class/index.ts@@ -1,8 +1,11 @@-import { EStorageTypes } from "@/modules/embodiment/types/fileStorage.types";-import { fsExists } from "@core/utils/general.utils";-import type { ILLMContextStore } from "@smythos/sre";import fs from "fs";import path from "path";++import type { ILLMContextStore } from "@smythos/sre";++import { fsExists } from "@core/utils/general.utils";++import { EStorageTypes } from "@/modules/embodiment/types/fileStorage.types";import { FsChatbotContextExporter } from "./FsChatbotContextExporter.class";export class FsChatbotContextStore implements ILLMContextStore {diff --git a/packages/runtime/src/modules/embodiment/routes/index.ts b/packages/runtime/src/modules/embodiment/routes/index.tsindex b11fa345..0bba7ae5 100644--- a/packages/runtime/src/modules/embodiment/routes/index.ts+++ b/packages/runtime/src/modules/embodiment/routes/index.ts@@ -1,8 +1,8 @@import { Router } from "express";-import swaggerUi from "swagger-ui-express";import config from "@core/config";+import { agentChatRouter } from "@embodiment/modules/agentChat/routes/router";import { alexaRouter } from "@embodiment/modules/alexa/routes/router";import { apiRouter } from "@embodiment/modules/API/routes/router";diff --git a/packages/runtime/src/modules/embodiment/services/Chatbot.class.ts b/packages/runtime/src/modules/embodiment/services/Chatbot.class.tsindex 283c0eb9..58bb5d15 100644--- a/packages/runtime/src/modules/embodiment/services/Chatbot.class.ts+++ b/packages/runtime/src/modules/embodiment/services/Chatbot.class.ts@@ -1,15 +1,16 @@-import { Agent, AgentLogger, Conversation } from "@smythos/sre";import { Request } from "express";+import { Agent, AgentLogger, Conversation } from "@smythos/sre";+import config from "@core/config";import { EMBODIMENT_TYPES } from "@core/constants";import { getOpenAPIJSONForAI } from "../helpers/openapi-adapter.helper";-import { FsChatbotContextStore } from "../services/FsChatbotContextStore.class";+import { FsChatbotContextStore } from "./FsChatbotContextStore.class";+import { ConversationStreamYield } from "./FsChatbotContextStore.class/FsChatbotContextExporter.class";import { ChatConversationsEnv } from "../utils/chat.utils";import { delay } from "../utils/date-time.utils";import { adaptModel } from "../utils/llm.utils";-import { ConversationStreamYield } from "./FsChatbotContextStore.class/FsChatbotContextExporter.class";type Headers = {"x-conversation-id": string;@@ -91,7 +92,7 @@ export default class Chatbot {this.modelInfo = {modelId: this.model,tokens: this.contextWindow,- completionTokens: this.maxOutputTokens+ completionTokens: this.maxOutputTokens,};// Keep original model ID