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.

Merge branch 'dev' into runtime

Forhad Hosain31a2541ef607
diff --cc packages/app/src/react/features/ai-chat/pages/ai-chat.tsx
index eef3a839,3445aeb6..2e6d7ce9
--- a/packages/app/src/react/features/ai-chat/pages/ai-chat.tsx
+++ b/packages/app/src/react/features/ai-chat/pages/ai-chat.tsx
@@@ -87,17 -58,12 +58,15 @@@ const AIChat = () =>
clearError,
isUploadInProgress,
clearFiles,
- } = useFileUpload();
+ } = useFileUpload({
+ agentId: agentId || '',
+ chatId: agentSettingsData?.settings?.lastConversationId,
+ });
- const dropzoneRef = useDragAndDrop({ onDrop: handleFileDrop });
-
const {
- chatHistoryMessages,
+ messagesHistory,
isGenerating,
- isQueryInputProcessing,
+ isInputProcessing,
isRetrying,
sendMessage,
retryLastMessage,
diff --cc packages/runtime/src/core/connectors/SmythOSSAgentDataConnector.class.ts
index 84766b1d,33f8ab2c..765709a2
--- a/packages/runtime/src/core/connectors/SmythOSSAgentDataConnector.class.ts
+++ b/packages/runtime/src/core/connectors/SmythOSSAgentDataConnector.class.ts
@@@ -1,12 -1,11 +1,12 @@@
import axios, { AxiosInstance } from 'axios';
--import { AgentDataConnector, OAuthConfig } from '@smythos/sre';
++import { AgentDataConnector, Logger, OAuthConfig } from '@smythos/sre';
- import { getM2MToken } from '@core/helpers/logto.helper';
import { SmythConfigs } from '@core/types/general.types';
++const console = Logger('Connector: SmythOSSAgentData');
export class SmythOSSAgentDataConnector extends AgentDataConnector {
- public name: string = 'SmythOSSAgentData';
+ public name = 'SmythOSSAgentData';
private oAuthAppId: string;
private oAuthAppSecret: string;
private oAuthBaseUrl: string;
@@@ -45,17 -46,18 +45,18 @@@
const response = await this.smythAPI.get(`/v1/ai-agent/${agentId}?include=team.subscription`, {
headers: await this.getSmythRequestHeaders(),
});
- // eslint-disable-next-line prefer-const
- let agentObj = response.data.agent;
- agentObj = response.data.agent;
- const authData = agentObj.data.auth; //use most up to date auth data
++ const agentObj = response.data.agent;
+ const authData = agentObj.data.auth; // use most up to date auth data
// const tasksResponse = await mwSysAPI.get(`/quota/team/${agentObj.teamId}/tasks/subscription`, includeAuth(token));
- const tasksResponse = await this.smythAPI.get(`/v1/quota/team/${agentObj.teamId}/tasks/subscription`, {
- headers: await this.getSmythRequestHeaders(),
- });
- agentObj.taskData = tasksResponse.data;
+
+ agentObj.taskData = {
+ tasks: 0,
+ maxTasks: Infinity,
+ isFreeUser: false,
+ };
- agentObj.data.debugSessionEnabled = agentObj?.data?.debugSessionEnabled && agentObj?.isLocked; //disable debug session if agent is not locked (locked agent means that it's open in the Agent builder)
+ agentObj.data.debugSessionEnabled = agentObj?.data?.debugSessionEnabled && agentObj?.isLocked; // disable debug session if agent is not locked (locked agent means that it's open in the Agent builder)
if (version) {
// const deploymentsList = await mwSysAPI.get(`/ai-agent/${agentID}/deployments`, includeAuth(token));
@@@ -214,10 -210,10 +209,10 @@@
private migrateAgentData(data) {
if (!data.version) {
- // console.log(`Agent [${data.name}] has an old schema. Migrating to latest version...`);
+ console.log(`Agent [${data.name}] has an old schema. Migrating to latest version...`);
// version 0 ===> migrate from receptors/connectors to inputs/outputs
const newData = JSON.parse(JSON.stringify(data));
- for (let component of newData.components) {
+ for (const component of newData.components) {
component.outputs = component.connectors;
component.inputs = component.receptors;
component.outputProps = component.connectorProps;
diff --cc packages/runtime/src/core/helpers/agent.helper.ts
index b84ef970,5a1a7b00..4662399c
--- a/packages/runtime/src/core/helpers/agent.helper.ts
+++ b/packages/runtime/src/core/helpers/agent.helper.ts
@@@ -1,7 -1,7 +1,7 @@@
import axios from 'axios';
import config from '../config';
- import { Logger, AccessCandidate, ConnectorService } from '@smythos/sre';
-import { Logger } from '@smythos/sre';
++import { AccessCandidate, ConnectorService, Logger } from '@smythos/sre';
import { includeAuth, mwSysAPI } from '../services/smythAPIReq';
import { getM2MToken } from './logto.helper';
@@@ -157,7 -158,7 +157,8 @@@ function migrateAgentData(data)
if (data.version === '1.0.0') {
if (data.description && !data.behavior) {
-- data.behavior = data.description;
++ const newData = { ...data, behavior: data.description };
++ return newData;
}
}
@@@ -168,14 -169,21 +169,19 @@@ export async function getAgentDataById(
try {
const token = (await getM2MToken('https://api.smyth.ai')) as string;
-- let agentObj;
--
const response = await mwSysAPI.get(`/ai-agent/${agentID}?include=team.subscription`, includeAuth(token));
-- agentObj = response.data.agent;
++ const agentObj = response.data.agent;
const authData = agentObj.data.auth;
- const tasksResponse = await mwSysAPI.get(`/quota/team/${agentObj.teamId}/tasks/subscription`, includeAuth(token));
- agentObj.taskData = tasksResponse.data;
+ // const tasksResponse = await mwSysAPI.get(
+ // `/quota/team/${agentObj.teamId}/tasks/subscription`,
+ // includeAuth(token)
+ // );
+ agentObj.taskData = {
+ tasks: 0,
+ maxTasks: Infinity,
+ isFreeUser: false,
+ };
agentObj.data.debugSessionEnabled = agentObj?.data?.debugSessionEnabled && agentObj?.isLocked;
@@@ -213,10 -221,10 +219,10 @@@ export function addDefaultComponentsAnd
async function fetchAgentAuthData(agentId: string) {
const accountConnector = ConnectorService.getAccountConnector();
-- return await accountConnector.user(AccessCandidate.agent(agentId)).getAgentSetting(AGENT_AUTH_SETTINGS_KEY);
++ return accountConnector.user(AccessCandidate.agent(agentId)).getAgentSetting(AGENT_AUTH_SETTINGS_KEY);
}
-export async function getAgentAuthData(agentId: string) {
+async function getAgentAuthData(agentId: string) {
const freshSettings = await fetchAgentAuthData(agentId);
return JSON.parse(freshSettings || '{}');
}
diff --cc packages/runtime/src/core/helpers/logto.helper.ts
index 37b1c68f,1905bdf9..97eeb550
--- a/packages/runtime/src/core/helpers/logto.helper.ts
+++ b/packages/runtime/src/core/helpers/logto.helper.ts
@@@ -1,47 -1,8 +1,5 @@@
- import axios from 'axios';
- import qs from 'querystring';
- import config from '../config';
- // M2M test
- const postData = {
- 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 tokenData = {
- access_token: null,
- };
export function getM2MToken(resource?, scope?) {
- return new Promise((resolve, reject) => {
- resolve('M2M_TOKEN'); // static 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 });
- });
++ resolve('M2M_TOKEN'); // static token
+ });
}
-
-
diff --cc packages/runtime/src/index.ts
index 7625ee82,802a34ce..04d7cf27
--- a/packages/runtime/src/index.ts
+++ b/packages/runtime/src/index.ts
@@@ -1,14 -1,15 +1,17 @@@
--import { Logger, SmythRuntime, version } from '@smythos/sre';
import compression from 'compression';
import cookieParser from 'cookie-parser';
import crypto from 'crypto';
import express from 'express';
import session from 'express-session';
+ import fs from 'fs';
import { Server } from 'http';
+ import os from 'os';
import path from 'path';
+import 'source-map-support/register.js';
import url from 'url';
++import { Logger, SmythRuntime, version } from '@smythos/sre';
++
// Core imports
import config from '@core/config';
import { modelsConfig } from '@core/config/models.config';
@@@ -71,12 -96,7 +102,7 @@@ const sre = SmythRuntime.Instance.init(
Settings: {
agentStageDomain: config.env.DEFAULT_AGENT_DOMAIN || '',
agentProdDomain: config.env.PROD_AGENT_DOMAIN || '',
- oAuthAppID: config.env.LOGTO_M2M_APP_ID,
- oAuthAppSecret: config.env.LOGTO_M2M_APP_SECRET,
- oAuthBaseUrl: `${config.env.LOGTO_SERVER}/oidc/token`,
- oAuthResource: config.env.LOGTO_API_RESOURCE,
- oAuthScope: '',
- smythAPIBaseUrl: config.env.MIDDLEWARE_API_BASE_URL + '/_sysapi',
+ smythAPIBaseUrl: `${config.env.MIDDLEWARE_API_BASE_URL}/_sysapi`,
},
},
Log: {