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.

remove unused comps

Ahmed Essamc09be4a77fbd
diff --git a/packages/app/src/builder-ui/components/Base64Encoder.class.ts b/packages/app/src/builder-ui/components/Base64Encoder.class.ts
deleted file mode 100644
index f240bb32..00000000
--- a/packages/app/src/builder-ui/components/Base64Encoder.class.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class Base64Encoder extends Component {
- protected async init() {
- // #region [ Settings config ] ==================
- this.settings = {
- mime: {
- type: 'select',
- label: 'MIME type',
- hint: 'Model name',
- value: 'default',
- options: ['default', 'image/jpeg', 'image/png'],
- },
- };
-
- const dataEntries = ['mime'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
- // #endregion
-
- // #region [ I/O config ] ==================
- this.properties.defaultOutputs = ['Output'];
- this.properties.defaultInputs = ['Data'];
- // #endregion
-
- // #region [ Draw config ] ==================
- this.drawSettings.showSettings = false;
- this.drawSettings.cssClass = '';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addOutputButton = null;
- this.drawSettings.addInputButton = ' + Input';
- this.drawSettings.componentDescription =
- 'Converts a raw data string to base64 encoded string or url';
- // #endregion
- }
-}
diff --git a/packages/app/src/builder-ui/components/DBInsert.class.ts b/packages/app/src/builder-ui/components/DBInsert.class.ts
deleted file mode 100644
index c80b8aaa..00000000
--- a/packages/app/src/builder-ui/components/DBInsert.class.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class DBInsert extends Component {
- protected async init() {
- this.settings = {
- db: {
- type: 'input',
- label: 'DB Connection',
- hint: 'Database Connection string',
- value: '',
- },
- table: {
- type: 'input',
- label: 'Table',
- hint: 'Table name',
- value: '',
- },
- };
- const dataEntries = ['db', 'table'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.outputs = [];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/EmailReader.class.ts b/packages/app/src/builder-ui/components/EmailReader.class.ts
deleted file mode 100644
index 46cdecce..00000000
--- a/packages/app/src/builder-ui/components/EmailReader.class.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class EmailReader extends Component {
- protected async init() {
- this.settings = {
- server: {
- type: 'input',
- label: 'Server',
- value: '',
- },
- username: {
- type: 'select',
- label: 'Username',
- value: ['user1', 'user2'],
- options: ['user1', 'user2', 'user3'],
- attributes: { multiple: true },
- },
- password: {
- type: 'input',
- label: 'Password',
- value: '',
- attributes: { type: 'password' },
- },
- };
-
- const dataEntries = ['server', 'username', 'password'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.inputs = [];
- this.properties.outputs = ['All Content', 'From', 'Subject', 'Body', 'Attachments'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addInputButton = null;
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/EmailSender.class.ts b/packages/app/src/builder-ui/components/EmailSender.class.ts
deleted file mode 100644
index d8f7f7a3..00000000
--- a/packages/app/src/builder-ui/components/EmailSender.class.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class EmailSender extends Component {
- protected async init() {
- this.settings = {
- email: {
- type: 'input',
- label: 'Email',
- value: '',
- },
- };
-
- const dataEntries = ['email'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.outputs = ['Success', 'Error'];
-
- if (this.properties.inputs.length == 0) this.properties.inputs = ['Input'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/FCrypto.class.ts b/packages/app/src/builder-ui/components/FCrypto.class.ts
deleted file mode 100644
index 09bcb55a..00000000
--- a/packages/app/src/builder-ui/components/FCrypto.class.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import { Component } from './Component.class';
-import { delay } from '../utils';
-import { FunctionComponent } from './FunctionComponent.class';
-
-declare var Metro;
-export class FCrypto extends FunctionComponent {
- protected async init() {
- // #region [ Settings config ] ==================
- this.settings = {
- action: {
- type: 'select',
- label: 'Action',
- hint: 'Action to perform',
- value: 'Encode',
- options: ['Encode', 'Decode'],
- },
- function: {
- type: 'select',
- label: 'Function',
- hint: 'Function name',
- value: 'BASE64',
- options: [
- 'BASE64',
- 'MD5',
- 'SHA1',
- 'SHA256',
- 'SHA512',
- 'HMACHex',
- 'HMACBase64',
- 'HMACBase64URL',
- 'HMACBase64URLNoPadding',
- ],
- },
- };
-
- const dataEntries = ['action', 'function'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
- // #endregion
-
- // #region [ Output config ] ==================
- this.outputSettings = {
- ...this.outputSettings,
- description: { type: 'string', default: '', editConfig: { type: 'textarea' } },
- };
- // #endregion
-
- // #region [ I/O config ] ==================
- this.properties.defaultOutputs = ['Output'];
- this.properties.defaultInputs = ['Input'];
-
- // #endregion
-
- // #region [ Draw config ] ==================
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.color = '#329bff';
- // #endregion
-
- this.properties.title = `${this.data.function} ${this.data.action}`;
- this.drawSettings.displayName = 'F:Crypto';
- }
- protected async run() {
- if (!this.domElement.style.width) this.domElement.style.width = '130px';
- this.addEventListener('settingsSaved', async () => {
- this.title = `${this.data.function} ${this.data.action}`;
- this.domElement.querySelector('.title .text').textContent = this.title;
- });
- }
-}
diff --git a/packages/app/src/builder-ui/components/FileExport.class.ts b/packages/app/src/builder-ui/components/FileExport.class.ts
deleted file mode 100644
index d3d37d23..00000000
--- a/packages/app/src/builder-ui/components/FileExport.class.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class FileExport extends Component {
- protected async init() {
- const exportFormat = this.properties.sender?.getAttribute('smt-export-format') || '';
- this.settings = {
- format: {
- type: 'input',
- label: 'Format',
- value: exportFormat,
- attributes: { readonly: 'readonly' },
- },
- };
-
- const dataEntries = ['format'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- if (this.properties.inputs.length == 0) this.properties.inputs = ['Source'];
- this.properties.outputs = ['Output'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addInputButton = null;
- this.drawSettings.addOutputButton = null;
-
- this._ready = true;
- }
-
- public redraw(triggerSettings = true): HTMLDivElement {
- const div = super.redraw(triggerSettings);
-
- const iconClassName =
- this.properties.sender?.querySelector('.icon').className || 'icon mif-file-empty';
- const titleBar = this.domElement.querySelector('.title-bar');
- const icon = titleBar.querySelector('.icon');
- icon.className = iconClassName;
-
- return div;
- }
-}
diff --git a/packages/app/src/builder-ui/components/FormParser.class.ts b/packages/app/src/builder-ui/components/FormParser.class.ts
deleted file mode 100644
index 85e9b6eb..00000000
--- a/packages/app/src/builder-ui/components/FormParser.class.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class FormParser extends Component {
- protected async init() {
- this.settings = {
- prompt: {
- type: 'textarea',
- label: 'Prompt',
- value: 'Use the context to extract the values of corresponding outputs',
- },
- };
-
- const dataEntries = ['prompt'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.inputs = [];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addInputButton = null;
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/GmailReader.class.ts b/packages/app/src/builder-ui/components/GmailReader.class.ts
deleted file mode 100644
index 355c64b1..00000000
--- a/packages/app/src/builder-ui/components/GmailReader.class.ts
+++ /dev/null
@@ -1,158 +0,0 @@
-import { clear } from 'console';
-import { Component } from './Component.class';
-declare var Metro;
-
-export class GmailReader extends Component {
- private authUrl: string = '';
- private _state: string = '';
- private _conCheckInterval: any = null;
- private _conCheckFunction: any;
-
- protected async prepare(): Promise<boolean> {
- //Here we call the backend in order to generate Google OAuth2 authUrl
-
- const state = this._uid + '::' + Date.now();
- const authUrlReq = this.workspace.server + '/oauth2/gmail/authUrl?state=' + state;
- console.log('fetching authUrlReq = ' + authUrlReq);
- const data = await fetch(authUrlReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
-
- this.authUrl = data.authUrl;
- this._state = state;
-
- return true;
- }
-
- protected async init() {
- this.settings = {
- account: {
- type: 'input',
- label: 'Account',
- value: '',
- attributes: { readonly: true },
- },
- token: {
- type: 'password',
- label: 'Token ',
- value: '',
- attributes: { readonly: true },
- },
- connect: {
- type: 'button',
- label: 'Connect',
- attributes: {},
- events: {
- click: (event) => {
- window.open(this.authUrl, '_blank');
- const sender = event.currentTarget;
-
- this._conCheckFunction = () => this.gmailConnectClick(sender, this._state);
-
- window.addEventListener('focus', this._conCheckFunction);
- },
- },
- },
- };
-
- this.dataFields = ['account', 'token'];
- for (let item of this.dataFields) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = [
- 'RawData',
- 'EmailID',
- 'From',
- 'To',
- 'Subject',
- 'Body',
- 'Attachments',
- ];
- this.properties.defaultInputs = [];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addOutputButton = null;
- this.drawSettings.addInputButton = null;
- this.drawSettings.showSettings = true;
- }
-
- protected async run() {
- this.addEventListener('settingsClosed', () => {
- this.cancelGmailConnect();
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- }
- });
-
- this.addEventListener('settingsSaved', () => {
- if (this.data.account && this.data.token) this.domElement.classList.remove('missing-config');
- });
-
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- } else {
- this.domElement.classList.remove('missing-config');
- }
- return true;
- }
-
- private async cancelGmailConnect() {
- clearInterval(this._conCheckInterval);
- }
-
- /**
- * This function is called when the user clicks on the "Connect" button
- * It checks the auth state every 5 seconds until the backend returns the refresh_token
- * The function is canceled if the user clicks on the "Cancel" button
- * @param sender the "Connect" button
- * @param state a unique state string used to identify the auth request
- */
- private async gmailConnectClick(sender, state) {
- console.log('start checking gmail auth state');
- window.removeEventListener('focus', this._conCheckFunction);
-
- const scope =
- 'https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/userinfo.email';
- const authStateReq = `${this.workspace.server}/oauth2/gmail/authState?state=${state}&scope=${scope}`;
-
- let retries = 5;
- this._conCheckInterval = setInterval(async () => {
- console.log('checking gmail auth state');
- const state = await fetch(authStateReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
-
- if (state && state.refresh_token && state.account) {
- clearInterval(this._conCheckInterval);
- sender.parentElement.querySelector('[name="account"]').value = state.account;
- sender.parentElement.querySelector('[name="token"]').value = state.refresh_token;
- }
-
- retries--;
- if (retries == 0) clearInterval(this._conCheckInterval);
- }, 5000);
- }
-}
diff --git a/packages/app/src/builder-ui/components/GmailSender.class.ts b/packages/app/src/builder-ui/components/GmailSender.class.ts
deleted file mode 100644
index 94db23da..00000000
--- a/packages/app/src/builder-ui/components/GmailSender.class.ts
+++ /dev/null
@@ -1,157 +0,0 @@
-import { clear } from 'console';
-import { Component } from './Component.class';
-declare var Metro;
-
-export class GmailSender extends Component {
- private authUrl: string = '';
- private _state: string = '';
- private _conCheckInterval: any = null;
- private _conCheckFunction: any;
-
- protected async prepare(): Promise<boolean> {
- //Here we call the backend in order to generate Google OAuth2 authUrl
-
- const state = this._uid + '::' + Date.now();
- const authUrlReq = this.workspace.server + '/oauth2/gmail/authUrl?state=' + state;
- console.log('fetching authUrlReq = ' + authUrlReq);
- const data = await fetch(authUrlReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
-
- this.authUrl = data.authUrl;
- this._state = state;
-
- return true;
- }
-
- protected async init() {
- this.settings = {
- account: {
- type: 'input',
- label: 'Account',
- value: '',
- attributes: { readonly: true },
- },
- token: {
- type: 'password',
- label: 'Token ',
- value: '',
- attributes: { readonly: true },
- },
- connect: {
- type: 'button',
- label: 'Connect',
- attributes: {},
- events: {
- click: (event) => {
- window.open(this.authUrl, '_blank');
- const sender = event.currentTarget;
-
- this._conCheckFunction = () => this.gmailConnectClick(sender, this._state);
-
- setTimeout(() => {
- window.addEventListener('focus', this._conCheckFunction);
- }, 200);
- },
- },
- },
- };
-
- this.dataFields = ['account', 'token'];
- for (let item of this.dataFields) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Success', 'Error'];
- this.properties.defaultInputs = ['To', 'Subject', 'Body'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addOutputButton = null;
- this.drawSettings.showSettings = true;
-
- this._ready = true;
- }
-
- protected async run() {
- this.addEventListener('settingsClosed', () => {
- this.cancelGmailConnect();
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- }
- });
-
- this.addEventListener('settingsSaved', () => {
- if (this.data.account && this.data.token) this.domElement.classList.remove('missing-config');
- });
-
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- } else {
- this.domElement.classList.remove('missing-config');
- }
- return true;
- }
-
- private async cancelGmailConnect() {
- clearInterval(this._conCheckInterval);
- }
-
- /**
- * This function is called when the user clicks on the "Connect" button
- * It checks the auth state every 5 seconds until the backend returns the refresh_token
- * The function is canceled if the user clicks on the "Cancel" button
- * @param sender the "Connect" button
- * @param state a unique state string used to identify the auth request
- */
- private async gmailConnectClick(sender, state) {
- const parentForm = sender.closest('form');
- console.log('start checking gmail auth state');
- window.removeEventListener('focus', this._conCheckFunction);
-
- const scope =
- 'https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/userinfo.email';
- const authStateReq = `${this.workspace.server}/oauth2/gmail/authState?state=${state}&scope=${scope}`;
-
- let retries = 5;
- const checkAuth = async () => {
- console.log('checking gmail auth state');
- const state = await fetch(authStateReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
-
- if (state && state.refresh_token && state.account) {
- clearInterval(this._conCheckInterval);
- parentForm.querySelector('[name="account"]').value = state.account;
- parentForm.querySelector('[name="token"]').value = state.refresh_token;
- }
-
- retries--;
- if (retries == 0) clearInterval(this._conCheckInterval);
- };
-
- this._conCheckInterval = setInterval(checkAuth, 5000);
- checkAuth();
- }
-}
diff --git a/packages/app/src/builder-ui/components/GoogleSheet.class.ts b/packages/app/src/builder-ui/components/GoogleSheet.class.ts
deleted file mode 100644
index 424f4091..00000000
--- a/packages/app/src/builder-ui/components/GoogleSheet.class.ts
+++ /dev/null
@@ -1,369 +0,0 @@
-import { clear } from 'console';
-import config from '../config';
-import { Component } from './Component.class';
-declare var Metro;
-
-export class GoogleSheet extends Component {
- private authUrl: string = '';
- private _state: string = '';
- private _conCheckInterval: any = null;
- private _conCheckFunction: any;
- private _options: any[] = [];
-
- protected async prepare(): Promise<boolean> {
- //Here we call the backend in order to generate Google OAuth2 authUrl
- if (!this.data.token) {
- const state = this._uid + '::' + Date.now();
- const scope =
- 'https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/gmail.send';
- const encodedScope = encodeURIComponent(scope);
- const authUrlReq = `${this.workspace.server}/oauth2/gmail/authUrl?state=${state}&scope=${encodedScope}`;
- console.log('fetching authUrlReq = ' + authUrlReq);
- const data = await fetch(authUrlReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
-
- this.authUrl = data.authUrl;
- this._state = state;
-
- return true;
- } else {
- if (this.data.url) {
- const reqUrl = `${config.env.UI_SERVER}/api/component/GoogleSheet/getSheetNames`;
- const result = await fetch(reqUrl, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ url: this.data.url, refresh_token: this.data.token }),
- }).then((res) => res.json());
- if (!result.error) {
- const names = result?.map?.((sheet) => sheet?.name);
- this._options = names || [];
- return true;
- }
- }
- }
- }
-
- protected async init() {
- this.settings = {
- model: {
- type: 'select',
- label: 'Model',
- hint: 'Model name',
- value: 'gpt-4-0613',
- options: ['gpt-3.5-turbo-0613', 'gpt-4-0613'],
- },
- prompt: {
- type: 'textarea',
- label: 'Prompt',
- value: 'Summarize the input text\nInput : {{Input}}',
- },
- url: {
- type: 'input',
- label: 'Spreadsheet Url',
- value: '',
- attributes: { required: true },
- events: {
- paste: async (event) => {
- const formValues = this.extractFormNamesAndValues();
- const token = formValues['token'];
- const account = formValues['account'];
- if (token) {
- await this.handlePasteEvent(event, token, account);
- }
- },
- cut: (event) => {
- setTimeout(() => {
- this.handleCutEvent(event);
- }, 200);
- },
- keyup: (event) => {
- if (event.key === 'Delete' || event.key === 'Backspace') {
- this.debouncedHandleCutEvent(event);
- }
- },
- },
- },
- tab_name: {
- type: 'select',
- label: 'Sheet Tab',
- hint: 'Sheet name',
- value: '',
- options: this._options || [],
- },
- headerRange: {
- type: 'input',
- label: 'Header',
- value: '',
- },
- account: {
- type: 'input',
- label: 'Account',
- value: '',
- attributes: { readonly: true },
- },
- token: {
- type: 'password',
- label: 'Token ',
- value: '',
- attributes: { readonly: true },
- },
- connect: {
- type: 'button',
- label: 'Connect',
- attributes: {},
- events: {
- click: (event) => {
- window.open(this.authUrl, '_blank');
- const sender = event.currentTarget;
-
- this._conCheckFunction = () => this.googleSheetConnectClick(sender, this._state);
- setTimeout(() => {
- window.addEventListener('focus', this._conCheckFunction);
- }, 200);
- },
- },
- },
- };
-
- this.dataFields = ['model', 'prompt', 'account', 'token', 'url', 'tab_name', 'headerRange'];
- for (let item of this.dataFields) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Error', 'Response'];
- this.properties.defaultInputs = ['Query'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addOutputButton = ' + out ';
- this.drawSettings.addInputButton = ' + Input';
- this.drawSettings.showSettings = true;
-
- this._ready = true;
- }
-
- public async editSettings() {
- super.editSettings();
-
- setTimeout(() => {
- if (!this.settings.tab_name.value && this._options.length == 0)
- (document.querySelector('[name="tab_name"]') as HTMLSelectElement).setAttribute(
- 'disabled',
- 'true',
- );
- }, 200);
- }
-
- protected async run() {
- this.addEventListener('settingsClosed', () => {
- this.cancelgoogleSheetConnect();
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- }
- });
-
- this.addEventListener('settingsSaved', () => {
- if (this.data.account && this.data.token) this.domElement.classList.remove('missing-config');
- });
-
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- } else {
- this.domElement.classList.remove('missing-config');
- }
- return true;
- }
-
- private async cancelgoogleSheetConnect() {
- clearInterval(this._conCheckInterval);
- }
-
- /**
- * This function is called when the user clicks on the "Connect" button
- * It checks the auth state every 5 seconds until the backend returns the refresh_token
- * The function is canceled if the user clicks on the "Cancel" button
- * @param sender the "Connect" button
- * @param state a unique state string used to identify the auth request
- */
- private async googleSheetConnectClick(sender, state) {
- const parentForm = sender.closest('form');
- console.log('start checking googleSheet auth state');
- window.removeEventListener('focus', this._conCheckFunction);
-
- const scope =
- 'https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive';
- const authStateReq = `${this.workspace.server}/oauth2/gmail/authState?state=${state}&scope=${scope}`;
- let retries = 5;
- const checkAuth = async () => {
- console.log('checking gmail auth state');
- const state = await fetch(authStateReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
- if (state && state.refresh_token && state.account) {
- clearInterval(this._conCheckInterval);
- parentForm.querySelector('[name="account"]').value = state.account;
- parentForm.querySelector('[name="token"]').value = state.refresh_token;
- if (parentForm?.querySelector?.('[name="url"]')?.value) {
- this.data.account = state.account;
- this.data.token = state.refresh_token;
- this.data.url = parentForm?.querySelector?.('[name="url"]')?.value;
- this.data.prompt = parentForm?.querySelector?.('[name="prompt"]')?.value;
- this.data.model = parentForm?.querySelector?.('[name="model"]')?.value;
- this.data.model = parentForm?.querySelector?.('[name="headerRange"]')?.value;
- const reqUrl = `${config.env.UI_SERVER}/api/component/GoogleSheet/getSheetNames`;
- const result = await fetch(reqUrl, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- url: parentForm?.querySelector?.('[name="url"]')?.value,
- refresh_token: state.refresh_token,
- }),
- }).then((res) => res.json());
- const selectElement = document.querySelector('[name="tab_name"]') as HTMLSelectElement;
- if (selectElement && !result.error) {
- const names = result?.map?.((sheet) => sheet?.name);
- this.settings.tab_name.options = [...names];
- this.data.tab_name = names[0];
- this.settings.tab_name.value = names[0];
- this.editSettings();
- }
- console.log('Getting all sheet names api result =>', result);
- }
- }
-
- retries--;
- if (retries == 0) clearInterval(this._conCheckInterval);
- };
-
- this._conCheckInterval = setInterval(checkAuth, 5000);
- checkAuth();
- }
-
- private async handlePasteEvent(event: ClipboardEvent, refresh_token: any, account: any) {
- const pastedData = event.clipboardData?.getData('text');
-
- // Check if the pastedData is a URL and state has a refresh_token
- if (pastedData && this.isValidGoogleSheetUrl(pastedData) && refresh_token) {
- return await this._handlePasteAndGetSheetNames(pastedData, refresh_token, account);
- }
- return null;
- }
-
- private async _handlePasteAndGetSheetNames(url, refresh_token, account) {
- const reqUrl = `${config.env.UI_SERVER}/api/component/GoogleSheet/getSheetNames`;
- const result = await fetch(reqUrl, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ url, refresh_token }),
- }).then((res) => res.json());
-
- const selectElement = document.querySelector('[name="tab_name"]') as HTMLSelectElement;
- if (selectElement && !result.error) {
- const names = result?.map?.((sheet) => sheet?.name);
- const formValues = this.extractFormNamesAndValues();
- this.data.prompt = formValues['prompt'];
- this.data.headerRange = formValues['headerRange'];
- this.data.model = formValues['model'];
- this.data.url = url;
- this.data.token = refresh_token;
- this.data.account = account;
- this.settings.url.value = url;
- this.settings.tab_name.options = [...names];
- this.data.tab_name = names[0];
- this.settings.tab_name.value = names[0];
- this._options = [];
- this.editSettings();
- }
-
- console.log('Getting all sheet names api result =>', result);
- }
-
- private isValidGoogleSheetUrl(url) {
- const regex = /^https:\/\/docs\.google\.com\/spreadsheets\/d\/([^\/]+)\/edit($|[\?#].*)/;
- return regex.test(url);
- }
-
- private handleCutEvent(event) {
- const inputValue = event.target.value.trim();
- const selectElement = document.querySelector('[name="tab_name"]') as HTMLSelectElement;
-
- if (selectElement) {
- if (inputValue === '' || !this.isValidGoogleSheetUrl(inputValue)) {
- const formValues = this.extractFormNamesAndValues();
- this.data.account = formValues['account'];
- this.data.headerRange = formValues['headerRange'];
- this.data.token = formValues['token'];
- this.data.prompt = formValues['prompt'];
- this.data.model = formValues['model'];
- this.settings.url.value = formValues['url'];
- this.data.url = formValues['url'];
- this.settings.tab_name.options = [];
- this.data.tab_name = '';
- this.settings.tab_name.value = '';
- this._options = [];
- this.editSettings();
- }
- }
- }
- private extractFormNamesAndValues(): { [key: string]: string } {
- const groupElements = document.querySelectorAll<HTMLElement>(
- '#right-sidebar .dlg-form .form-group',
- );
- const results: { [key: string]: string } = {};
-
- groupElements.forEach((group: HTMLElement) => {
- const inputElement = group.querySelector<
- HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
- >('input, textarea, select');
- if (inputElement && inputElement.name) {
- results[inputElement.name] = inputElement.value;
- }
- });
-
- return results;
- }
-
- private debounce(func: (...args: any[]) => void, wait: number) {
- let timer: any;
- return (...args: any[]) => {
- const later = () => {
- clearTimeout(timer);
- func(...args);
- };
- clearTimeout(timer);
- timer = setTimeout(later, wait);
- };
- }
-
- private debouncedHandleCutEvent = this.debounce((event: any) => {
- this.handleCutEvent(event);
- }, 300);
-}
diff --git a/packages/app/src/builder-ui/components/Image/BackgroundRemoval.class.ts b/packages/app/src/builder-ui/components/Image/BackgroundRemoval.class.ts
deleted file mode 100644
index afaeaa2a..00000000
--- a/packages/app/src/builder-ui/components/Image/BackgroundRemoval.class.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Component } from '../Component.class';
-import { ImageSettingsConfig } from './imageSettings.config';
-
-export class BackgroundRemoval extends Component {
- protected async init() {
- this.settings = {
- outputFormat: ImageSettingsConfig.outputFormat(),
- outputQuality: ImageSettingsConfig.outputQuality(),
- backgroundColor: ImageSettingsConfig.backgroundColor(),
- ctaButton: ImageSettingsConfig.ctaButton(),
- };
-
- const dataEntries = ['outputFormat', 'outputQuality', 'backgroundColor'];
-
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Output'];
-
- this.properties.defaultInputs = ['InputImage'];
-
- const inputImageProps = this.properties.inputProps?.find((c) => c.name === 'InputImage');
- if (!inputImageProps) {
- this.properties.inputProps.push({ name: 'InputImage', type: 'Binary', optional: false });
- } else {
- inputImageProps.optional = false;
- inputImageProps.type = 'Binary';
- }
-
- this.drawSettings.displayName = 'Background Removal';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this.drawSettings.componentDescription = 'Removes background from image to isolate subject.';
- this.drawSettings.shortDescription = 'Removes background from image to isolate subject.';
- this.drawSettings.color = '#65a698';
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/Image/ImageToImage.class.ts b/packages/app/src/builder-ui/components/Image/ImageToImage.class.ts
deleted file mode 100644
index ea694d29..00000000
--- a/packages/app/src/builder-ui/components/Image/ImageToImage.class.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { LLMFormController } from '../../helpers/LLMFormController.helper';
-import { createBadge } from '../../ui/badges';
-import { Component } from '../Component.class';
-import { ImageSettingsConfig } from './imageSettings.config';
-
-export class ImageToImage extends Component {
- private modelOptions: string[];
- private defaultModel: string;
-
- protected async prepare() {
- const modelOptions = LLMFormController.prepareModelSelectOptionsByFeatures(['image-to-image']);
-
- this.defaultModel = LLMFormController.getDefaultModel(modelOptions);
-
- const model = this.data.model || this.defaultModel;
-
- //prevent losing the previously set model
- if (model && ![...modelOptions.map((item) => item?.value || item)].includes(model)) {
- modelOptions.push({
- text: model + '&nbsp;&nbsp', // Add non-breaking space entities to create visual spacing between model name and badge
- value: model,
- badge: createBadge('Removed', 'text-smyth-red-500 border-smyth-red-500'),
- });
- }
-
- // TODO: set warning if the model is not available
-
- //remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
-
- return true;
- }
-
- protected async init() {
- this.settings = {
- positivePrompt: ImageSettingsConfig.positivePrompt(),
- model: ImageSettingsConfig.model({
- modelOptions: this.modelOptions,
- defaultModel: this.defaultModel,
- docUrl: this.workspace.serverData.docUrl,
- }),
- negativePrompt: ImageSettingsConfig.negativePrompt({ section: 'Advanced' }),
- width: ImageSettingsConfig.width({ section: 'Advanced' }),
- height: ImageSettingsConfig.height({ section: 'Advanced' }),
- outputFormat: ImageSettingsConfig.outputFormat({ section: 'Advanced' }),
- outputQuality: ImageSettingsConfig.outputQuality({ section: 'Advanced' }),
- numberResults: ImageSettingsConfig.numberResults({ section: 'Advanced' }),
- strength: ImageSettingsConfig.strength({ section: 'Advanced' }),
- ctaButton: ImageSettingsConfig.ctaButton(),
- };
-
- const dataEntries = [
- 'model',
- 'positivePrompt',
- 'negativePrompt',
- 'width',
- 'height',
- 'outputFormat',
- 'outputQuality',
- 'numberResults',
- 'strength',
- ];
-
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Output'];
-
- this.properties.defaultInputs = ['InputText', 'SeedImage'];
- const seedImageProps = this.properties.inputProps?.find((c) => c.name === 'SeedImage');
- if (!seedImageProps) {
- this.properties.inputProps.push({ name: 'SeedImage', type: 'Binary', optional: false });
- } else {
- seedImageProps.optional = false;
- seedImageProps.type = 'Binary';
- }
-
- this.drawSettings.displayName = 'Image to Image';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this.drawSettings.componentDescription = 'Blend two images into a new creation.';
- this.drawSettings.shortDescription = 'Blend two images into a new creation.';
- this.drawSettings.color = '#65a698';
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/Image/ImageToText.class.ts b/packages/app/src/builder-ui/components/Image/ImageToText.class.ts
deleted file mode 100644
index e8e55da7..00000000
--- a/packages/app/src/builder-ui/components/Image/ImageToText.class.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Component } from '../Component.class';
-import { ImageSettingsConfig } from './imageSettings.config';
-export class ImageToText extends Component {
- protected async init() {
- this.settings = {
- ctaButton: ImageSettingsConfig.ctaButton(),
- };
-
- const dataEntries = [];
-
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Output'];
-
- this.properties.defaultInputs = ['InputImage'];
- const inputImageProps = this.properties.inputProps?.find((c) => c.name === 'InputImage');
- if (!inputImageProps) {
- this.properties.inputProps.push({ name: 'InputImage', type: 'Binary', optional: false });
- } else {
- inputImageProps.optional = false;
- inputImageProps.type = 'Binary';
- }
-
- this.drawSettings.displayName = 'Image To Text';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this.drawSettings.componentDescription = 'Convert images into text.';
- this.drawSettings.shortDescription = 'Convert images into text.';
- this.drawSettings.color = '#65a698';
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/Image/ImageUpscaling.class.ts b/packages/app/src/builder-ui/components/Image/ImageUpscaling.class.ts
deleted file mode 100644
index e0e4e700..00000000
--- a/packages/app/src/builder-ui/components/Image/ImageUpscaling.class.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Component } from '../Component.class';
-import { ImageSettingsConfig } from './imageSettings.config';
-
-export class ImageUpscaling extends Component {
- protected async init() {
- this.settings = {
- upscaleFactor: ImageSettingsConfig.upscaleFactor({ section: 'Advanced' }),
- outputFormat: ImageSettingsConfig.outputFormat(),
- outputQuality: ImageSettingsConfig.outputQuality(),
- ctaButton: ImageSettingsConfig.ctaButton(),
- };
-
- const dataEntries = ['outputFormat', 'outputQuality', 'upscaleFactor'];
-
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Output'];
-
- this.properties.defaultInputs = ['InputImage'];
- const inputImageProps = this.properties.inputProps?.find((c) => c.name === 'InputImage');
- if (!inputImageProps) {
- this.properties.inputProps.push({ name: 'InputImage', type: 'Binary', optional: false });
- } else {
- inputImageProps.optional = false;
- inputImageProps.type = 'Binary';
- }
-
- this.drawSettings.displayName = 'Image Upscaling';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this.drawSettings.componentDescription =
- 'Enhances image resolution, improving quality and sharpness.';
- this.drawSettings.shortDescription =
- 'Enhances image resolution, improving quality and sharpness.';
- this.drawSettings.color = '#65a698';
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/Image/Inpainting.class.ts b/packages/app/src/builder-ui/components/Image/Inpainting.class.ts
deleted file mode 100644
index 20399ec9..00000000
--- a/packages/app/src/builder-ui/components/Image/Inpainting.class.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import { LLMFormController } from '../../helpers/LLMFormController.helper';
-import { createBadge } from '../../ui/badges';
-import { Component } from '../Component.class';
-import { ImageSettingsConfig } from './imageSettings.config';
-
-export class Inpainting extends Component {
- private modelOptions: string[];
- private defaultModel: string;
-
- protected async prepare() {
- const modelOptions = LLMFormController.prepareModelSelectOptionsByFeatures(['image-inpainting']);
-
- this.defaultModel = LLMFormController.getDefaultModel(modelOptions);
-
- const model = this.data.model || this.defaultModel;
-
- //prevent losing the previously set model
- if (model && ![...modelOptions.map((item) => item?.value || item)].includes(model)) {
- modelOptions.push({
- text: model + '&nbsp;&nbsp', // Add non-breaking space entities to create visual spacing between model name and badge
- value: model,
- badge: createBadge('Removed', 'text-smyth-red-500 border-smyth-red-500'),
- });
- }
-
- // TODO: set warning if the model is not available
-
- //remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
-
- return true;
- }
-
- protected async init() {
- this.settings = {
- model: ImageSettingsConfig.model({
- modelOptions: this.modelOptions,
- defaultModel: this.defaultModel,
- docUrl: this.workspace.serverData.docUrl,
- }),
- outputFormat: ImageSettingsConfig.outputFormat(),
- outputQuality: ImageSettingsConfig.outputQuality(),
- confidence: ImageSettingsConfig.confidence({ section: 'Advanced' }),
- maxDetections: ImageSettingsConfig.maxDetections({ section: 'Advanced' }),
- maskPadding: ImageSettingsConfig.maskPadding({ section: 'Advanced' }),
- maskBlur: ImageSettingsConfig.maskBlur({ section: 'Advanced' }),
- ctaButton: ImageSettingsConfig.ctaButton(),
- };
-
- const dataEntries = [
- 'model',
- 'outputFormat',
- 'outputQuality',
- 'confidence',
- 'maxDetections',
- 'maskPadding',
- 'maskBlur',
- ];
-
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Output'];
-
- this.properties.defaultInputs = ['InputImage'];
- const inputImageProps = this.properties.inputProps?.find((c) => c.name === 'InputImage');
- if (!inputImageProps) {
- this.properties.inputProps.push({ name: 'InputImage', type: 'Binary', optional: false });
- } else {
- inputImageProps.optional = false;
- inputImageProps.type = 'Binary';
- }
-
- this.drawSettings.displayName = 'Inpainting';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this.drawSettings.componentDescription = 'Blend two images into a new creation.';
- this.drawSettings.shortDescription = 'Blend two images into a new creation.';
- this.drawSettings.color = '#65a698';
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/Image/Outpainting.class.ts b/packages/app/src/builder-ui/components/Image/Outpainting.class.ts
deleted file mode 100644
index 4c11c26e..00000000
--- a/packages/app/src/builder-ui/components/Image/Outpainting.class.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-import { LLMFormController } from '../../helpers/LLMFormController.helper';
-import { createBadge } from '../../ui/badges';
-import { Component } from '../Component.class';
-import { ImageSettingsConfig } from './imageSettings.config';
-export class Outpainting extends Component {
- private modelOptions: string[];
- private defaultModel: string;
-
- protected async prepare() {
- const modelOptions = LLMFormController.prepareModelSelectOptionsByFeatures(['image-to-image']);
-
- this.defaultModel = LLMFormController.getDefaultModel(modelOptions);
-
- const model = this.data.model || this.defaultModel;
-
- //prevent losing the previously set model
- if (model && ![...modelOptions.map((item) => item?.value || item)].includes(model)) {
- modelOptions.push({
- text: model + '&nbsp;&nbsp', // Add non-breaking space entities to create visual spacing between model name and badge
- value: model,
- badge: createBadge('Removed', 'text-smyth-red-500 border-smyth-red-500'),
- });
- }
-
- // TODO: set warning if the model is not available
-
- //remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
-
- return true;
- }
-
- protected async init() {
- this.settings = {
- positivePrompt: ImageSettingsConfig.positivePrompt(),
- model: ImageSettingsConfig.model({
- modelOptions: this.modelOptions,
- defaultModel: this.defaultModel,
- docUrl: this.workspace.serverData.docUrl,
- }),
- negativePrompt: ImageSettingsConfig.negativePrompt({ section: 'Advanced' }),
- width: ImageSettingsConfig.width({ section: 'Advanced' }),
- height: ImageSettingsConfig.height({ section: 'Advanced' }),
- outputFormat: ImageSettingsConfig.outputFormat({ section: 'Advanced' }),
- numberResults: ImageSettingsConfig.numberResults({ section: 'Advanced' }),
- strength: ImageSettingsConfig.strength({ section: 'Advanced' }),
- ctaButton: ImageSettingsConfig.ctaButton(),
- };
-
- const dataEntries = [
- 'model',
- 'positivePrompt',
- 'negativePrompt',
- 'width',
- 'height',
- 'outputFormat',
- 'numberResults',
- 'strength',
- ];
-
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Output'];
-
- this.properties.defaultInputs = ['InputText', 'SeedImage'];
- const seedImageProps = this.properties.inputProps?.find((c) => c.name === 'SeedImage');
- if (!seedImageProps) {
- this.properties.inputProps.push({ name: 'SeedImage', type: 'Binary', optional: false });
- } else {
- seedImageProps.optional = false;
- seedImageProps.type = 'Binary';
- }
-
- this.drawSettings.displayName = 'Outpainting';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this.drawSettings.componentDescription = 'Extend your image beyond its original borders.';
- this.drawSettings.shortDescription = 'Extend your image beyond its original borders.';
- this.drawSettings.color = '#65a698';
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/Image/RestyleControlNet.class.ts b/packages/app/src/builder-ui/components/Image/RestyleControlNet.class.ts
deleted file mode 100644
index 442b26eb..00000000
--- a/packages/app/src/builder-ui/components/Image/RestyleControlNet.class.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { Component } from '../Component.class';
-import { ImageSettingsConfig } from './imageSettings.config';
-
-export class RestyleControlNet extends Component {
- protected async init() {
- this.settings = {
- preProcessorType: ImageSettingsConfig.preProcessorType(),
- width: ImageSettingsConfig.width({ section: 'Advanced' }),
- height: ImageSettingsConfig.height({ section: 'Advanced' }),
- outputFormat: ImageSettingsConfig.outputFormat({ section: 'Advanced' }),
- outputQuality: ImageSettingsConfig.outputQuality({ section: 'Advanced' }),
- ctaButton: ImageSettingsConfig.ctaButton(),
- };
-
- const dataEntries = ['width', 'height', 'outputFormat', 'outputQuality', 'preProcessorType'];
-
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Output'];
-
- this.properties.defaultInputs = ['InputImage'];
- const inputImageProps = this.properties.inputProps?.find((c) => c.name === 'InputImage');
- if (!inputImageProps) {
- this.properties.inputProps.push({ name: 'InputImage', type: 'Binary', optional: false });
- } else {
- inputImageProps.optional = false;
- inputImageProps.type = 'Binary';
- }
-
- this.drawSettings.displayName = 'Restyle (ControlNet)';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this.drawSettings.componentDescription =
- 'Generate images with precise control using a reference image and specific conditions.';
- this.drawSettings.shortDescription =
- 'Generate images with precise control using a reference image and specific conditions.';
- this.drawSettings.color = '#65a698';
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/Image/RestyleIPAdapter.class.ts b/packages/app/src/builder-ui/components/Image/RestyleIPAdapter.class.ts
deleted file mode 100644
index 15832a7f..00000000
--- a/packages/app/src/builder-ui/components/Image/RestyleIPAdapter.class.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { LLMFormController } from '../../helpers/LLMFormController.helper';
-import { createBadge } from '../../ui/badges';
-import { Component } from '../Component.class';
-import { ImageSettingsConfig } from './imageSettings.config';
-export class RestyleIPAdapter extends Component {
- private modelOptions: string[];
- private defaultModel: string;
-
- protected async prepare() {
- const modelOptions = LLMFormController.prepareModelSelectOptionsByFeatures(['image-to-image']);
-
- this.defaultModel = LLMFormController.getDefaultModel(modelOptions);
-
- const model = this.data.model || this.defaultModel;
-
- //prevent losing the previously set model
- if (model && ![...modelOptions.map((item) => item?.value || item)].includes(model)) {
- modelOptions.push({
- text: model + '&nbsp;&nbsp', // Add non-breaking space entities to create visual spacing between model name and badge
- value: model,
- badge: createBadge('Removed', 'text-smyth-red-500 border-smyth-red-500'),
- });
- }
-
- // TODO: set warning if the model is not available
-
- //remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
-
- return true;
- }
-
- protected async init() {
- this.settings = {
- positivePrompt: ImageSettingsConfig.positivePrompt(),
- model: ImageSettingsConfig.model({
- modelOptions: this.modelOptions,
- defaultModel: this.defaultModel,
- docUrl: this.workspace.serverData.docUrl,
- }),
- negativePrompt: ImageSettingsConfig.negativePrompt({ section: 'Advanced' }),
- width: ImageSettingsConfig.width({ section: 'Advanced' }),
- height: ImageSettingsConfig.height({ section: 'Advanced' }),
- outputFormat: ImageSettingsConfig.outputFormat({ section: 'Advanced' }),
- outputQuality: ImageSettingsConfig.outputQuality({ section: 'Advanced' }),
- numberResults: ImageSettingsConfig.numberResults({ section: 'Advanced' }),
- strength: ImageSettingsConfig.strength({ section: 'Advanced' }),
- ipAdapters: ImageSettingsConfig.ipAdapters({ section: 'Advanced' }),
- ctaButton: ImageSettingsConfig.ctaButton(),
- };
-
- const dataEntries = [
- 'model',
- 'positivePrompt',
- 'negativePrompt',
- 'width',
- 'height',
- 'outputFormat',
- 'outputQuality',
- 'numberResults',
- 'strength',
- 'ipAdapters',
- ];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Output'];
-
- this.properties.defaultInputs = ['Prompt', 'Image'];
-
- this.drawSettings.displayName = 'Restyle (IP Adapter)';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this.drawSettings.componentDescription =
- 'Generate images by guiding the AI with a reference image.';
- this.drawSettings.shortDescription =
- 'Generate images by guiding the AI with a reference image.';
- this.drawSettings.color = '#65a698';
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/Image/TextToImage.class.ts b/packages/app/src/builder-ui/components/Image/TextToImage.class.ts
deleted file mode 100644
index 65564a7a..00000000
--- a/packages/app/src/builder-ui/components/Image/TextToImage.class.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { LLMFormController } from '../../helpers/LLMFormController.helper';
-import { createBadge } from '../../ui/badges';
-import { Component } from '../Component.class';
-import { ImageSettingsConfig } from './imageSettings.config';
-
-export class TextToImage extends Component {
- private modelOptions: string[];
- private defaultModel: string;
-
- protected async prepare() {
- const modelOptions = LLMFormController.prepareModelSelectOptionsByFeatures(['text-to-image']);
-
- this.defaultModel = LLMFormController.getDefaultModel(modelOptions);
-
- const model = this.data.model || this.defaultModel;
-
- //prevent losing the previously set model
- if (model && ![...modelOptions.map((item) => item?.value || item)].includes(model)) {
- modelOptions.push({
- text: model + '&nbsp;&nbsp', // Add non-breaking space entities to create visual spacing between model name and badge
- value: model,
- badge: createBadge('Removed', 'text-smyth-red-500 border-smyth-red-500'),
- });
- }
-
- // TODO: set warning if the model is not available
-
- //remove undefined models
- this.modelOptions = modelOptions.filter((e) => e);
-
- return true;
- }
-
- protected async init() {
- this.settings = {
- positivePrompt: ImageSettingsConfig.positivePrompt(),
- model: ImageSettingsConfig.model({
- modelOptions: this.modelOptions,
- defaultModel: this.defaultModel,
- docUrl: this.workspace.serverData.docUrl,
- }),
- negativePrompt: ImageSettingsConfig.negativePrompt({ section: 'Advanced' }),
- width: ImageSettingsConfig.width({ section: 'Advanced' }),
- height: ImageSettingsConfig.height({ section: 'Advanced' }),
- outputFormat: ImageSettingsConfig.outputFormat({ section: 'Advanced' }),
- outputQuality: ImageSettingsConfig.outputQuality({ section: 'Advanced' }),
- numberResults: ImageSettingsConfig.numberResults({ section: 'Advanced' }),
- steps: ImageSettingsConfig.steps({ section: 'Advanced' }),
- ctaButton: ImageSettingsConfig.ctaButton(),
- };
-
- const dataEntries = [
- 'model',
- 'positivePrompt',
- 'negativePrompt',
- 'width',
- 'height',
- 'outputFormat',
- 'outputQuality',
- 'numberResults',
- 'steps',
- ];
-
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Output'];
-
- this.properties.defaultInputs = ['InputText'];
- const seedImageProps = this.properties.inputProps?.find((c) => c.name === 'SeedImage');
- if (!seedImageProps) {
- this.properties.inputProps.push({ name: 'SeedImage', type: 'Binary', optional: false });
- } else {
- seedImageProps.optional = false;
- seedImageProps.type = 'Binary';
- }
-
- this.drawSettings.displayName = 'Text to Image';
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
-
- this.drawSettings.componentDescription = 'Generate images from text descriptions.';
- this.drawSettings.shortDescription = 'Generate images from text descriptions.';
- this.drawSettings.color = '#65a698';
-
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/InputSync.class.ts b/packages/app/src/builder-ui/components/InputSync.class.ts
deleted file mode 100644
index 392b50b4..00000000
--- a/packages/app/src/builder-ui/components/InputSync.class.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class InputSync extends Component {
- protected async init() {
- this.settings = {
- inputs: {
- type: 'textarea',
- label: 'Inputs',
- value: '',
- hint: 'Comma separated list of inputs to wait for before triggering the outputs',
- },
- };
-
- const dataEntries = ['inputs'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- if (this.properties.inputs.length == 0) this.properties.inputs = ['Input'];
- this.properties.outputs = [];
-
- this._ready = true;
- }
-
- public redraw(triggerSettings = true): HTMLDivElement {
- const div = super.redraw(triggerSettings);
- div.classList.add(this.constructor.name);
-
- const titleBar = this.domElement.querySelector('.title-bar');
- const icon = titleBar.querySelector('.icon');
- icon.className = 'icon mif-share';
-
- //if (triggerSettings) this.editSettings();
-
- this.domElement.querySelector('.btn-add-output').remove();
-
- return div;
- }
-
- public async addInput(parent, name) {
- const inputEP = await super.addInput(parent, name);
- await super.addOutput(parent.parentElement.querySelector('.output-container'), name);
- return inputEP;
- }
-}
diff --git a/packages/app/src/builder-ui/components/LinkedIn.class.ts b/packages/app/src/builder-ui/components/LinkedIn.class.ts
deleted file mode 100644
index 8cbae509..00000000
--- a/packages/app/src/builder-ui/components/LinkedIn.class.ts
+++ /dev/null
@@ -1,163 +0,0 @@
-import { clear } from 'console';
-import { Component } from './Component.class';
-import { stat } from 'fs';
-declare var Metro;
-
-export class LinkedIn extends Component {
- private authUrl: string = '';
- private _state: string = '';
- private _conCheckInterval: any = null;
- private _conCheckFunction: any;
-
- protected async prepare(): Promise<boolean> {
- //Here we call the backend in order to generate Google OAuth2 authUrl
-
- const state = this._uid + '::' + Date.now();
- const authUrlReq = this.workspace.server + '/oauth2/linkedin/authUrl?state=' + state;
- console.log('fetching authUrlReq = ' + authUrlReq);
- const data = await fetch(authUrlReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
- console.log({ data });
- this.authUrl = data.authUrl;
- this._state = state;
-
- return true;
- }
-
- protected async init() {
- this.settings = {
- account: {
- type: 'input',
- label: 'Account',
- value: '',
- attributes: { readonly: true },
- },
- id: {
- type: 'input',
- label: 'Id',
- value: '',
- attributes: { readonly: true },
- },
- token: {
- type: 'password',
- label: 'Token ',
- value: '',
- attributes: { readonly: true },
- },
- connect: {
- type: 'button',
- label: 'Connect',
- attributes: {},
- events: {
- click: (event) => {
- window.open(this.authUrl, '_blank');
- const sender = event.currentTarget;
-
- this._conCheckFunction = () => this.linkedInConnectClick(sender, this._state);
-
- window.addEventListener('focus', this._conCheckFunction);
- },
- },
- },
- };
-
- this.dataFields = ['account', 'token', 'id'];
- for (let item of this.dataFields) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Success', 'Error'];
- this.properties.defaultInputs = ['Post'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addOutputButton = null;
- this.drawSettings.addInputButton = null;
- this.drawSettings.showSettings = true;
-
- this._ready = true;
- }
-
- protected async run() {
- this.addEventListener('settingsClosed', () => {
- this.cancelLinkedInConnect();
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- }
- });
-
- this.addEventListener('settingsSaved', () => {
- if (this.data.account && this.data.token) this.domElement.classList.remove('missing-config');
- });
-
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- } else {
- this.domElement.classList.remove('missing-config');
- }
- return true;
- }
-
- private async cancelLinkedInConnect() {
- clearInterval(this._conCheckInterval);
- }
-
- /**
- * This function is called when the user clicks on the "Connect" button
- * It checks the auth state every 5 seconds until the backend returns the refresh_token
- * The function is canceled if the user clicks on the "Cancel" button
- * @param sender the "Connect" button
- * @param state a unique state string used to identify the auth request
- */
- private async linkedInConnectClick(sender, state) {
- const parentForm = sender.closest('form');
- console.log('start checking linkedIn auth state');
- window.removeEventListener('focus', this._conCheckFunction);
-
- const scope = 'r_liteprofile r_emailaddress w_member_social';
-
- const authStateReq = `${this.workspace.server}/oauth2/linkedin/authState?state=${state}&scope=${scope}`;
-
- let retries = 5;
- const checkAuth = async () => {
- console.log('checking linkedIn auth state');
- const state = await fetch(authStateReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
-
- if (state && state.access_token && state.account && state.id) {
- clearInterval(this._conCheckInterval);
- parentForm.querySelector('[name="account"]').value = state.account;
- parentForm.querySelector('[name="id"]').value = state.id;
- parentForm.querySelector('[name="token"]').value = state.access_token;
- }
- retries--;
- if (retries == 0) clearInterval(this._conCheckInterval);
- };
-
- this._conCheckInterval = setInterval(checkAuth, 5000);
- checkAuth();
- }
-}
diff --git a/packages/app/src/builder-ui/components/POST_APIEndpoint.class.ts b/packages/app/src/builder-ui/components/POST_APIEndpoint.class.ts
deleted file mode 100644
index a1d0076c..00000000
--- a/packages/app/src/builder-ui/components/POST_APIEndpoint.class.ts
+++ /dev/null
@@ -1,175 +0,0 @@
-import { Component, ComponentList } from './Component.class';
-import { alert } from '../ui/dialogs';
-import { delay } from '../utils';
-import config from '../config';
-declare var Metro;
-export class POST_APIEndpoint extends Component {
- protected async init() {
- this.settings = {
- endpoint: {
- type: 'input',
- label: 'Endpoint',
- value: '',
- validate: `required maxlength=50 custom=isValidEndpoint`,
- validateMessage: `Provide a valid endpoint that only contains 'a-z', 'A-Z', '0-9', '-', '_' , without leading or trailing spaces.`,
- hint: 'Enter endpoint name',
- },
- ai_exposed: {
- type: 'checkbox',
- label: 'Expose to AI',
- value: true,
- hint: 'If checked, the endpoint can be used by AI (e.g. ChatGPT, Chatbot, ...)',
- events: {
- change: this.exposeIAChangeHandler.bind(this),
- },
- },
- description: {
- type: 'textarea',
- label: 'Instructions',
- value: '',
- hint: 'Instructions for AI Agent, Describes how to use this endpoint when exposed to an LLM',
- validate: `maxlength=5000`,
- validateMessage: 'Your text exceeds the 5,000 character limit.',
- },
- summary: {
- type: 'textarea',
- label: 'Description',
- value: '',
- hint: 'Short description of the endpoint, used for documentation',
- validate: `maxlength=1000`,
- validateMessage: 'Your text exceeds the 1,000 character limit.',
- },
- };
- const dataEntries = [/*'domain', */ 'endpoint', 'description', 'ai_exposed', 'summary'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.inputSettings = {
- ...this.inputSettings,
- description: {
- type: 'string',
- label: 'Description',
- default: '',
- editConfig: { type: 'textarea' },
- },
- isFile: {
- type: 'boolean',
- editConfig: { type: 'checkbox', label: 'Binary Input', value: false, cls: 'hidden' },
- },
- };
-
- this.properties.defaultOutputs = ['headers', 'body', 'query'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addOutputButton = 'Request Parts';
- this.drawSettings.addInputButton = 'Parameters';
- this.drawSettings.showSettings = true;
- this.drawSettings.inputMaxConnections = 0;
- this.drawSettings.shortDescription = 'HTTP API Endpoint - Expose your agent as a REST API';
- this.drawSettings.color = '#b700f1';
-
- this._ready = true;
- }
-
- private async exposeIAChangeHandler(e) {
- console.log(e, e.target, e.target.checked);
- const form = e.target.closest('form');
- if (!form) return;
- const description = form.querySelector('.form-box[data-field-name="description"]');
- if (!description) return;
-
- if (e.target.checked) {
- description.classList.remove('hidden');
- } else {
- description.classList.add('hidden');
- }
- }
-
- //override name availability check
- public inputNameExists(name: any): boolean {
- const input = this.inputContainer.querySelector(`.input-endpoint[smt-name="${name}"]`);
- if (input) return true;
- // //find if there is an output with the same name
- const outputEP = this.outputContainer.querySelector(`.output-endpoint[smt-name="${name}"]`);
- if (outputEP) return true;
-
- return false;
- }
-
- public async addInput(parent: any, name: any): Promise<any> {
- if (this.properties.defaultOutputs.includes(name)) return super.addInput(parent, name);
-
- const inputDiv: any = await super.addInput(parent, name);
-
- const outputParent = parent.parentElement.querySelector('.output-container');
- const outputName = `body.${name}`;
- const outputDiv: any = await super.addOutput(outputParent, outputName);
-
- inputDiv.querySelector('.ep').setAttribute('smt-con-thickness', '8');
- inputDiv.querySelector('.ep').setAttribute('smt-con-hide-overlays', 'true');
-
- inputDiv._outputDivElement = outputDiv;
- outputDiv._inputDivElement = inputDiv;
-
- this.repaint();
- return inputDiv;
- }
-
- public async addOutput(parent: any, name: any): Promise<any> {
- if (this.properties.defaultOutputs.includes(name)) return super.addOutput(parent, name);
-
- return null;
- }
-
- public async deleteEndpoint(endpointElement) {
- console.log('deleting');
- super.deleteEndpoint(endpointElement);
- const otherEntry = endpointElement._outputDivElement || endpointElement._inputDivElement;
-
- if (endpointElement._outputDivElement) endpointElement.outputDivElement = null;
- if (endpointElement._inputDivElement) endpointElement.inputDivElement = null;
-
- if (otherEntry) {
- super.deleteEndpoint(otherEntry);
- }
- }
-
- protected async run(): Promise<any> {
- this.addEventListener('settingsOpened', async (sidebar) => {
- await delay(50);
- const description = sidebar.querySelector('.form-box[data-field-name="description"]');
- if (!description) return;
- if (this.data.ai_exposed) {
- description.classList.remove('hidden');
- } else {
- description.classList.add('hidden');
- }
- });
-
- this.addEventListener('endpointChanged', (prop, endPoint, oldName, newName) => {
- if (prop != 'name') return;
- console.log('endpointNameChanged', endPoint, oldName, newName);
- const inputDiv: any = endPoint.classList.contains('input-endpoint')
- ? endPoint
- : endPoint._inputDivElement;
- const outputDiv: any = endPoint.classList.contains('output-endpoint')
- ? endPoint
- : endPoint._outputDivElement;
-
- const inputName = inputDiv.getAttribute('smt-name');
- const outputName = outputDiv.getAttribute('smt-name');
-
- if (inputName != newName) {
- inputDiv.setAttribute('smt-name', newName);
- inputDiv.querySelector('.name').innerText = newName;
- }
-
- if (outputName != newName) {
- const newOutputName = `body.${newName}`;
- outputDiv.setAttribute('smt-name', newOutputName);
- outputDiv.querySelector('.name').innerText = newOutputName;
- }
- });
- }
-}
diff --git a/packages/app/src/builder-ui/components/Redirect.class.ts b/packages/app/src/builder-ui/components/Redirect.class.ts
deleted file mode 100644
index cbc44c02..00000000
--- a/packages/app/src/builder-ui/components/Redirect.class.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class Redirect extends Component {
- protected async init() {
- // #region [ Settings config ] ==================
- this.settings = {
- url: {
- type: 'input',
- label: 'URL',
- validate: `required maxlength=8192 custom=isUrlValid`,
- validateMessage: 'Provide a valid URL',
- attributes: { 'data-template-vars': 'true' },
- },
- };
-
- const dataEntries = ['url'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
- // #endregion
-
- // #region [ I/O config ] ==================
- this.properties.defaultOutputs = [];
- this.properties.defaultInputs = [];
- // #endregion
-
- // #region [ Draw config ] ==================
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addOutputButton = null;
- this.drawSettings.outputMaxConnections = 0;
- this.drawSettings.addOutputButtonLabel = ' ';
- this.drawSettings.color = '#8600f1';
- // #endregion
- }
-}
diff --git a/packages/app/src/builder-ui/components/SMSSender.ts b/packages/app/src/builder-ui/components/SMSSender.ts
deleted file mode 100644
index 5cdc5dec..00000000
--- a/packages/app/src/builder-ui/components/SMSSender.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class SMSSender extends Component {
- protected async init() {
- this.settings = {
- phone: {
- type: 'input',
- label: 'Phone Number',
- value: '',
- hint: '+1 555 555 5555',
- },
- };
-
- const dataEntries = ['phone'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.outputs = ['Success', 'Error'];
-
- if (this.properties.inputs.length == 0) this.properties.inputs = ['Input'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addInputButton = null;
- this._ready = true;
- }
-}
diff --git a/packages/app/src/builder-ui/components/SchedulerEndpoint.class.ts b/packages/app/src/builder-ui/components/SchedulerEndpoint.class.ts
deleted file mode 100644
index bc5147c2..00000000
--- a/packages/app/src/builder-ui/components/SchedulerEndpoint.class.ts
+++ /dev/null
@@ -1,112 +0,0 @@
-import { Component, ComponentList } from './Component.class';
-import { alert } from '../ui/dialogs';
-import { delay } from '../utils';
-import config from '../config';
-import { handleTableEditBtn, createJobBoxes } from '../utils';
-
-declare var Metro;
-export class SchedulerEndpoint extends Component {
- private domains: any = ['[NONE]'];
- private errorLoading = '';
- protected async prepare(): Promise<boolean> {
- //this.updateDomainsList();
- //TODO : exclude used domains
- return true;
- }
-
- protected async init() {
- this.settings = {
- span: {
- type: 'span',
- html: `<span class="">Schedule Job</span>`,
- label: 'Config jobs',
- value: '',
- actions: [
- {
- cls: 'float-right',
- label: 'add',
- id: 'addJobs',
- events: {
- click: handleTableEditBtn.bind(this, 'jobs'),
- },
- },
- ],
- },
- jobs: {
- type: 'hidden',
- value: '',
- },
- };
- const dataEntries = ['jobs', 'span'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.inputSettings = {
- ...this.inputSettings,
- description: { type: 'string', default: '', editConfig: { type: 'textarea' } },
- };
-
- this.properties.defaultOutputs = ['headers', 'body', 'query'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addOutputButton = 'Request Parts';
- this.drawSettings.addInputButton = 'Parameters';
- this.drawSettings.showSettings = true;
- this.drawSettings.inputMaxConnections = 0;
- this.drawSettings.shortDescription = 'Scheduler Endpoint - Run your agent on a schedule';
- this.drawSettings.color = '#b700f1';
-
- this._ready = true;
- }
-
- //TODO : set the schedule on agent save
- protected async run() {
- const isInput = (elm) => elm.classList.contains('input-endpoint');
-
- this.addEventListener('settingsOpened', async (sidebar, component) => {
- if (component != this) return; //check if the sidebar is for this component
-
- console.log('sidebar', sidebar);
- await this.drawSchedulerJobsUI(sidebar);
- });
- this.addEventListener('endpointRemoved', async (name, elm) => {
- if (this.data.jobs !== '' && this.data.jobs !== '{}' && this.data.jobs !== '[]') {
- const _sidebar = document.querySelector('#right-sidebar .form-section');
- const jobBoxesContainer = await createJobBoxes(this, 'job-details');
- _sidebar?.appendChild(jobBoxesContainer);
- }
- });
- this.addEventListener('endpointChanged', async (name, elm, oldValue, newValue) => {
- const jsonArray = JSON?.parse(this.data.jobs) || [];
- if (name === 'name' && isInput(elm)) {
- let newArray =
- jsonArray.length &&
- jsonArray?.map((obj) => {
- if (obj[`${oldValue}`] !== undefined) {
- obj[`${newValue}`] = obj[`${oldValue}`]; // Add new property with the value of the old property
- delete obj[`${oldValue}`]; // Delete the old property
- }
- return obj;
- });
- const dataString = JSON?.stringify(newArray);
- this.data.jobs = dataString;
- this.settings.jobs.value = dataString;
- this.editSettings();
- if (this.data.jobs !== '' && this.data.jobs !== '{}' && this.data.jobs !== '[]') {
- const _sidebar = document.querySelector('#right-sidebar .form-section');
- const jobBoxesContainer = await createJobBoxes(this, 'job-details');
- _sidebar?.appendChild(jobBoxesContainer);
- }
- }
- });
- }
-
- private async drawSchedulerJobsUI(sidebar) {
- if (this.data.jobs !== '' && this.data.jobs !== '{}' && this.data.jobs !== '[]') {
- let _sidebar: any = sidebar?.querySelector('.form-section');
- const jobBoxesContainer = await createJobBoxes(this, 'job-details');
- _sidebar?.appendChild(jobBoxesContainer);
- }
- }
-}
diff --git a/packages/app/src/builder-ui/components/TTS.class.ts b/packages/app/src/builder-ui/components/TTS.class.ts
deleted file mode 100644
index 0fc08afc..00000000
--- a/packages/app/src/builder-ui/components/TTS.class.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Component } from './Component.class';
-declare var Metro;
-export class TTS extends Component {
- protected async init() {
- const provider = this.properties.sender?.getAttribute('provider') || '';
- this.settings = {
- format: {
- type: 'input',
- label: 'Format',
- value: provider,
- attributes: { readonly: 'readonly' },
- },
- };
-
- const dataEntries = ['format'];
- for (let item of dataEntries) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- if (this.properties.inputs.length == 0) this.properties.inputs = ['Text'];
- this.properties.outputs = ['Audio'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addInputButton = null;
- this.drawSettings.addOutputButton = null;
-
- this._ready = true;
- }
-
- public redraw(triggerSettings = true): HTMLDivElement {
- const div = super.redraw(triggerSettings);
-
- const iconClassName =
- this.properties.sender?.querySelector('.icon').className || 'icon mif-file-empty';
- const titleBar = this.domElement.querySelector('.title-bar');
- const icon = titleBar.querySelector('.icon');
- icon.className = iconClassName;
-
- return div;
- }
-}
diff --git a/packages/app/src/builder-ui/components/Twitter.class.ts b/packages/app/src/builder-ui/components/Twitter.class.ts
deleted file mode 100644
index 98d45e80..00000000
--- a/packages/app/src/builder-ui/components/Twitter.class.ts
+++ /dev/null
@@ -1,166 +0,0 @@
-import { clear } from 'console';
-import { Component } from './Component.class';
-import { stat } from 'fs';
-declare var Metro;
-
-export class Twitter extends Component {
- private authUrl: string = '';
- private _state: string = '';
- private _conCheckInterval: any = null;
- private _conCheckFunction: any;
-
- protected async prepare(): Promise<boolean> {
- //Here we call the backend in order to generate Google OAuth2 authUrl
-
- const state = this._uid + '::' + Date.now();
- const authUrlReq = this.workspace.server + '/oauth2/twitter/authUrl?state=' + state;
- //const authUrlReq = this.workspace.server + '/oauth2/twitter/authUrl';
-
- console.log('fetching authUrlReq = ' + authUrlReq);
- const data = await fetch(authUrlReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
- console.log({ data });
- this.authUrl = data.authUrl;
- this._state = state;
-
- return true;
- }
-
- protected async init() {
- this.settings = {
- account: {
- type: 'input',
- label: 'Account',
- value: '',
- attributes: { readonly: true },
- },
- token: {
- type: 'password',
- label: 'Token',
- value: '',
- attributes: { readonly: true },
- },
- secret: {
- type: 'password',
- label: 'Secret',
- value: '',
- attributes: { readonly: true },
- },
- connect: {
- type: 'button',
- label: 'Connect',
- attributes: {},
- events: {
- click: (event) => {
- window.open(this.authUrl, '_blank');
- const sender = event.currentTarget;
-
- this._conCheckFunction = () => this.twitterConnectClick(sender, this._state);
-
- window.addEventListener('focus', this._conCheckFunction);
- },
- },
- },
- };
-
- this.dataFields = ['account', 'token', 'secret'];
- for (let item of this.dataFields) {
- if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
- }
-
- this.properties.defaultOutputs = ['Success', 'Error', 'id'];
- this.properties.defaultInputs = ['message', 'id'];
-
- this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;
- this.drawSettings.addOutputButton = null;
- this.drawSettings.addInputButton = null;
- this.drawSettings.showSettings = true;
-
- this._ready = true;
- }
-
- protected async run() {
- this.addEventListener('settingsClosed', () => {
- this.cancelTwitterConnect();
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- }
- });
-
- this.addEventListener('settingsSaved', () => {
- if (this.data.account && this.data.token) this.domElement.classList.remove('missing-config');
- });
-
- if (!this.data.account || !this.data.token) {
- this.domElement.classList.add('missing-config');
- } else {
- this.domElement.classList.remove('missing-config');
- }
- return true;
- }
-
- private async cancelTwitterConnect() {
- clearInterval(this._conCheckInterval);
- }
-
- /**
- * This function is called when the user clicks on the "Connect" button
- * It checks the auth state every 5 seconds until the backend returns the refresh_token
- * The function is canceled if the user clicks on the "Cancel" button
- * @param sender the "Connect" button
- * @param state a unique state string used to identify the auth request
- */
- private async twitterConnectClick(sender, state) {
- const parentForm = sender.closest('form');
- console.log('start checking twitter auth state');
- window.removeEventListener('focus', this._conCheckFunction);
-
- const scope = 'tweet.read users.read follows.read follows.write tweet.write offline.access';
-
- const authStateReq = `${this.workspace.server}/oauth2/twitter/authState?state=${state}&scope=${scope}`;
-
- let retries = 5;
- const checkAuth = async () => {
- console.log('checking twitter auth state');
- const state = await fetch(authStateReq, {
- method: 'GET',
- headers: { 'Content-Type': 'application/json' },
- })
- .then((response) => {
- if (response.ok) {
- return response.json();
- } else {
- throw new Error('Something went wrong');
- }
- })
- .catch((error) => {
- console.log(error);
- });
-
- if (state && state.access_token && state.access_token_secret && state.account) {
- clearInterval(this._conCheckInterval);
- parentForm.querySelector('[name="account"]').value = state.account;
- parentForm.querySelector('[name="token"]').value = state.access_token;
- parentForm.querySelector('[name="secret"]').value = state.access_token_secret;
- }
-
- retries--;
- if (retries == 0) clearInterval(this._conCheckInterval);
- };
-
- this._conCheckInterval = setInterval(checkAuth, 5000);
- checkAuth();
- }
-}
diff --git a/packages/app/src/builder-ui/components/index.ts b/packages/app/src/builder-ui/components/index.ts
index 411a1b6f..125248be 100644
--- a/packages/app/src/builder-ui/components/index.ts
+++ b/packages/app/src/builder-ui/components/index.ts
@@ -1,20 +1,14 @@
import { plugins, PluginTarget, PluginType } from '@src/react/shared/plugins/Plugins';
-import { AgentCard } from './AgentCard.class';
import { AgentPlugin } from './AgentPlugin.class';
import { APICall } from './APICall.class';
import { APIEndpoint } from './APIEndpoint.class';
import { APIOutput } from './APIOutput.class';
import { Async } from './Async.class';
import { Await } from './Await.class';
-import { Base64Encoder } from './Base64Encoder.class';
import { Classifier } from './Classifier.class';
import { Component } from './Component.class';
-import { DBInsert } from './DBInsert.class';
-import { EmailSender } from './EmailSender.class';
-import { FCrypto } from './FCrypto.class';
import { FEncDec } from './FEncDec.class';
import { FHash } from './FHash.class';
-import { FileExport } from './FileExport.class';
import { FileStore } from './FileStore.class';
import { ForEach } from './ForEach.class';
import { FSign } from './FSign.class';
@@ -23,19 +17,8 @@ import { FTimestamp } from './FTimestamp.class';
import { GenAILLM } from './GenAILLM.class';
import { GPTPlugin } from './GPTPlugin.class';
import { HuggingFace } from './HuggingFace.class';
-import { BackgroundRemoval } from './Image/BackgroundRemoval.class';
-import { ImageToImage } from './Image/ImageToImage.class';
-import { ImageToText } from './Image/ImageToText.class';
-import { ImageUpscaling } from './Image/ImageUpscaling.class';
-import { Inpainting } from './Image/Inpainting.class';
-import { Outpainting } from './Image/Outpainting.class';
-import { RestyleControlNet } from './Image/RestyleControlNet.class';
-import { RestyleIPAdapter } from './Image/RestyleIPAdapter.class';
-import { TextToImage } from './Image/TextToImage.class';
import { ImageGenerator } from './ImageGenerator.class'; // Legacy
-import { InputSync } from './InputSync.class';
import { JSONFilter } from './JSONFilter.class';
-import { LinkedIn } from './LinkedIn.class';
import { LLMAssistant } from './LLMAssistant.class';
import { LogicAND } from './LogicAND.class';
import { LogicAtLeast } from './LogicAtLeast.class';
@@ -49,45 +32,26 @@ import { MemoryWriteKeyVal } from './MemoryWriteKeyVal.class';
import { MemoryWriteObject } from './MemoryWriteObject.class';
import { MultimodalLLM } from './MultimodalLLM.class';
import { Note } from './Note.class';
-import { POST_APIEndpoint } from './POST_APIEndpoint.class';
import { PromptGenerator } from './PromptGenerator.class';
-import { Redirect } from './Redirect.class';
-import { SchedulerEndpoint } from './SchedulerEndpoint.class';
-import { SMSSender } from './SMSSender';
-import { TTS } from './TTS.class';
-import { Twitter } from './Twitter.class';
import { VisionLLM } from './VisionLLM.class';
import { ZapierAction } from './ZapierAction.class';
+import { AgentCard } from './AgentCard.class';
import { GmailTrigger } from './Triggers/GmailTrigger.class';
const baseComponents = {
Component,
Classifier,
PromptGenerator,
- //FormParser,
- InputSync,
- //EmailReader,
GPTPlugin,
- EmailSender,
- FileExport,
- TTS,
- SMSSender,
- DBInsert,
APIEndpoint,
- //GmailReader,
- //GmailSender,
APICall,
- Twitter,
- LinkedIn,
- //GoogleSheet,
APIOutput,
LogicAND,
LogicOR,
LogicXOR,
LogicAtLeast,
LogicAtMost,
- Base64Encoder,
HuggingFace,
AgentPlugin,
ZapierAction,
@@ -96,37 +60,24 @@ const baseComponents = {
MemoryReadKeyVal,
MemoryDeleteKeyVal,
Note,
- SchedulerEndpoint,
JSONFilter,
ForEach,
VisionLLM,
LLMAssistant,
- Redirect,
Async,
- FCrypto,
FHash,
FSign,
FEncDec,
FSleep,
FTimestamp,
Await,
- POST_APIEndpoint,
MultimodalLLM,
GenAILLM,
FileStore,
ImageGenerator,
- TextToImage,
- ImageToImage,
- ImageToText,
- BackgroundRemoval,
- ImageUpscaling,
- RestyleControlNet,
- RestyleIPAdapter,
- Outpainting,
- Inpainting,
- AgentCard,
MCPClient,
GmailTrigger,
+ AgentCard,
};
export const getBuilderComponents = () => {