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.

Revert "run agent with localhost"

Forhad Hosainf503abcd488a
diff --git a/packages/runtime/src/core/config.ts b/packages/runtime/src/core/config.ts
index fa0a304e..039df130 100644
--- a/packages/runtime/src/core/config.ts
+++ b/packages/runtime/src/core/config.ts
@@ -17,7 +17,7 @@ const config = {
LOGTO_M2M_APP_ID: process.env.LOGTO_M2M_APP_ID,
- DEFAULT_AGENT_DOMAIN: process.env?.DEFAULT_AGENT_DOMAIN,
+ AGENT_DOMAIN: process.env?.AGENT_DOMAIN,
PROD_AGENT_DOMAIN: process.env?.PROD_AGENT_DOMAIN,
AGENT_DOMAIN_PORT: process.env?.AGENT_DOMAIN_PORT,
diff --git a/packages/runtime/src/core/helpers/agent.helper.ts b/packages/runtime/src/core/helpers/agent.helper.ts
index f5b80380..8bbde22a 100644
--- a/packages/runtime/src/core/helpers/agent.helper.ts
+++ b/packages/runtime/src/core/helpers/agent.helper.ts
@@ -57,7 +57,7 @@ export async function getAgentDomainById(agentId: string) {
if (deployed) {
return `${agentId}.${config.env.PROD_AGENT_DOMAIN}`;
} else {
- return `${agentId}.${config.env.DEFAULT_AGENT_DOMAIN}`;
+ return `${agentId}.${config.env.AGENT_DOMAIN}`;
}
}
return domain;
@@ -126,14 +126,12 @@ export async function getAgentEmbodiments(agentID) {
export async function getAgentIdByDomain(domain = "") {
let agentId;
//first check if this is the internal wildcard agents domain
- const isStageWildcardDomain = domain.includes(
- config.env.DEFAULT_AGENT_DOMAIN
- );
+ const isStageWildcardDomain = domain.includes(config.env.AGENT_DOMAIN);
const isProdWildcardDomain = domain.includes(config.env.PROD_AGENT_DOMAIN);
if (isStageWildcardDomain || isProdWildcardDomain) {
agentId = domain.split(".")[0];
if (
- `${agentId}.${config.env.DEFAULT_AGENT_DOMAIN}` !== domain &&
+ `${agentId}.${config.env.AGENT_DOMAIN}` !== domain &&
`${agentId}.${config.env.PROD_AGENT_DOMAIN}` !== domain
) {
throw new Error(`Invalid agent domain: ${domain}`);
diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts
index c565a529..a84f7a6e 100644
--- a/packages/runtime/src/index.ts
+++ b/packages/runtime/src/index.ts
@@ -80,7 +80,7 @@ const sre = SmythRuntime.Instance.init({
AgentData: {
Connector: "SmythOSSAgentData",
Settings: {
- agentStageDomain: config.env.DEFAULT_AGENT_DOMAIN || "",
+ agentStageDomain: config.env.AGENT_DOMAIN || "",
agentProdDomain: config.env.PROD_AGENT_DOMAIN || "",
oAuthAppID: config.env.LOGTO_M2M_APP_ID,
oAuthAppSecret: config.env.LOGTO_M2M_APP_SECRET,
@@ -150,9 +150,7 @@ app.use(
return req.sessionID;
}
const domain = req.hostname;
- const isTestDomain = domain.includes(
- `.${config.env.DEFAULT_AGENT_DOMAIN}`
- );
+ const isTestDomain = domain.includes(`.${config.env.AGENT_DOMAIN}`);
const prefix = isTestDomain ? "test-" : "";
const formattedDate = getCurrentFormattedDate();
const randomString = crypto.randomBytes(8).toString("hex");
@@ -168,7 +166,7 @@ app.use(express.urlencoded({ extended: false, limit: "100kb" }));
// Health endpoint
app.get("/health", (req: any, res) => {
- let agent_domain = config.env.DEFAULT_AGENT_DOMAIN;
+ let agent_domain = config.env.AGENT_DOMAIN;
if (config.env.AGENT_DOMAIN_PORT)
agent_domain += `:${config.env.AGENT_DOMAIN_PORT}`;
diff --git a/packages/runtime/src/modules/agent-runner/middlewares/agentLoader.mw.ts b/packages/runtime/src/modules/agent-runner/middlewares/agentLoader.mw.ts
index 2a520d0c..330e0e8e 100644
--- a/packages/runtime/src/modules/agent-runner/middlewares/agentLoader.mw.ts
+++ b/packages/runtime/src/modules/agent-runner/middlewares/agentLoader.mw.ts
@@ -46,7 +46,7 @@ export default async function agentLoader(req, res, next) {
console.error("Error calling getAgentIdByDomain:", error);
}
agentDomain = domain;
- if (agentId && domain.includes(config.env.DEFAULT_AGENT_DOMAIN)) {
+ if (agentId && domain.includes(config.env.AGENT_DOMAIN)) {
isTestDomain = true;
}
}
diff --git a/packages/runtime/src/modules/debugger/middlewares/agentLoader.mw.ts b/packages/runtime/src/modules/debugger/middlewares/agentLoader.mw.ts
index 9763dc69..ff1c8a87 100644
--- a/packages/runtime/src/modules/debugger/middlewares/agentLoader.mw.ts
+++ b/packages/runtime/src/modules/debugger/middlewares/agentLoader.mw.ts
@@ -51,7 +51,7 @@ export default async function agentLoader(req, res, next) {
}
}
agentDomain = domain;
- if (agentId && domain.includes(config.env.DEFAULT_AGENT_DOMAIN)) {
+ if (agentId && domain.includes(config.env.AGENT_DOMAIN)) {
isTestDomain = true;
}
if (agentId) {
diff --git a/packages/runtime/src/modules/embodiment/helpers/openapi-adapter.helper.ts b/packages/runtime/src/modules/embodiment/helpers/openapi-adapter.helper.ts
index b6aa295e..751141b6 100644
--- a/packages/runtime/src/modules/embodiment/helpers/openapi-adapter.helper.ts
+++ b/packages/runtime/src/modules/embodiment/helpers/openapi-adapter.helper.ts
@@ -79,13 +79,13 @@ function constructServerUrl(domain: string): string {
const server_url_scheme =
config.env.NODE_ENV === "development" &&
config.env.AGENT_DOMAIN_PORT &&
- domain.includes(config.env.DEFAULT_AGENT_DOMAIN)
+ domain.includes(config.env.AGENT_DOMAIN)
? "http"
: "https";
const server_url_port =
config.env.NODE_ENV === "development" &&
config.env.AGENT_DOMAIN_PORT &&
- domain.includes(config.env.DEFAULT_AGENT_DOMAIN)
+ domain.includes(config.env.AGENT_DOMAIN)
? `:${config.env.AGENT_DOMAIN_PORT}`
: "";
return `${server_url_scheme}://${domain}${server_url_port}`;
diff --git a/packages/runtime/src/modules/embodiment/middlewares/agentLoader.mw.ts b/packages/runtime/src/modules/embodiment/middlewares/agentLoader.mw.ts
index 910ea40e..f34f69e6 100644
--- a/packages/runtime/src/modules/embodiment/middlewares/agentLoader.mw.ts
+++ b/packages/runtime/src/modules/embodiment/middlewares/agentLoader.mw.ts
@@ -61,7 +61,7 @@ export default async function agentLoader(req, res, next) {
console.error("Error calling getAgentIdByDomain:", error);
}
agentDomain = domain;
- if (agentId && domain.includes(config.env.DEFAULT_AGENT_DOMAIN)) {
+ if (agentId && domain.includes(config.env.AGENT_DOMAIN)) {
isTestDomain = true;
}
}
diff --git a/packages/runtime/src/modules/embodiment/modules/agentChat/routes/router.ts b/packages/runtime/src/modules/embodiment/modules/agentChat/routes/router.ts
index 118473d9..be528ed8 100644
--- a/packages/runtime/src/modules/embodiment/modules/agentChat/routes/router.ts
+++ b/packages/runtime/src/modules/embodiment/modules/agentChat/routes/router.ts
@@ -56,7 +56,7 @@ const validations = {
router.post("/stream", async (req, res) => {
let streamStarted = false;
- const isLocalAgent = req.hostname.includes("localhost");
+ const isLocalAgent = req.hostname.includes("localagent");
const agentId = req._agent?.id;
const agentVersion = req._agent?.version;
let verifiedKey = null;
@@ -142,9 +142,7 @@ router.post("/stream", async (req, res) => {
router.post("/new", async (req, res) => {
const { conversation = {} } = req.body;
- const isTestDomain = req.hostname.includes(
- `.${config.env.DEFAULT_AGENT_DOMAIN}`
- );
+ const isTestDomain = req.hostname.includes(`.${config.env.AGENT_DOMAIN}`);
let agentId = req.header("X-AGENT-ID");
const teamDetails = requestContext.get(`team_info:${agentId}`);
diff --git a/packages/runtime/src/modules/embodiment/modules/chatbot/routes/router.ts b/packages/runtime/src/modules/embodiment/modules/chatbot/routes/router.ts
index 9946eec0..53fc1a42 100644
--- a/packages/runtime/src/modules/embodiment/modules/chatbot/routes/router.ts
+++ b/packages/runtime/src/modules/embodiment/modules/chatbot/routes/router.ts
@@ -90,7 +90,7 @@ initDebug('${config.env.UI_SERVER}', '${agent.id}');
logo: '${logo}',
introMessage: '${introMessage}',
allowAttachments: ${allowAttachments},
- //domain:'${agent.id}.${config.env.DEFAULT_AGENT_DOMAIN}',
+ //domain:'${agent.id}.${config.env.AGENT_DOMAIN}',
colors: ${JSON.stringify(colors, null, 2)},
isChatOnly: true,
containerId: 'smyth-chatbot-page',
@@ -126,7 +126,7 @@ router.get("/chat-configs", async (req: any, res) => {
router.post("/chat-stream", async (req, res) => {
let streamStarted = false;
- const isLocalAgent = req.hostname.includes("localhost");
+ const isLocalAgent = req.hostname.includes("localagent");
const agentId = req._agent?.id;
const agentVersion = req._agent?.version;
const isDebugSession = req._agent.debugSessionEnabled;
@@ -276,7 +276,7 @@ router.get("/params", async (req, res) => {
// If chatbot properties exist, append the 'chatbotEnabled' flag
if (chatbotProperties) {
- const isLocalAgent = req.hostname.includes("localhost");
+ const isLocalAgent = req.hostname.includes("localagent");
const agentId = agent?.id;
const chatbotName =
agent.agentSettings?.embodiments.get(EMBODIMENT_TYPES.ChatBot, "name") ||
@@ -324,9 +324,7 @@ router.get("/params", async (req, res) => {
//* Note: chatbot conversations are not created in db table, it is just a uid created on the fly
//* On the other hand, Agent Chat conversations are created in db table and can be retrieved from db
- const isTestDomain = req.hostname.includes(
- `.${config.env.DEFAULT_AGENT_DOMAIN}`
- );
+ const isTestDomain = req.hostname.includes(`.${config.env.AGENT_DOMAIN}`);
const conversationId = buildConversationId(undefined, isTestDomain);
chatbotProperties.headers = {
@@ -424,7 +422,7 @@ async function exchangeCodeForToken(
domain: string,
authInfo: any
): Promise<any> {
- const isLocalAgent = domain.includes("localhost");
+ const isLocalAgent = domain.includes("localagent");
const baseUrl = isLocalAgent
? `http://${domain}:${config.env.PORT}`
: `https://${domain}`;
diff --git a/packages/runtime/src/modules/embodiment/modules/formPreview/routes/router.ts b/packages/runtime/src/modules/embodiment/modules/formPreview/routes/router.ts
index 39891be1..f6792626 100644
--- a/packages/runtime/src/modules/embodiment/modules/formPreview/routes/router.ts
+++ b/packages/runtime/src/modules/embodiment/modules/formPreview/routes/router.ts
@@ -41,7 +41,7 @@ router.get("/params", async (req, res) => {
await Promise.all(promises);
- const isLocalAgent = req.hostname.includes("localhost");
+ const isLocalAgent = req.hostname.includes("localagent");
const agentId = agent?.id;
const port = isLocalAgent ? config.env.AGENT_DOMAIN_PORT : undefined;