- Warning removal.
Some checks failed
GBCI / build (push) Failing after 11s

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-09-24 15:20:32 -03:00
parent 904a33a409
commit 023b83aacf
13 changed files with 25598 additions and 35786 deletions

25475
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -59,12 +59,12 @@
"dependencies": {
"@azure/cognitiveservices-computervision": "8.2.0",
"@azure/ms-rest-js": "2.7.0",
"@azure/msal-node": "^3.7.3",
"@azure/msal-node": "3.7.3",
"@azure/openai": "2.0.0",
"@azure/search-documents": "12.1.0",
"@azure/storage-blob": "12.28.0",
"@google-cloud/pubsub": "^5.2.0",
"@google-cloud/translate": "^9.2.0",
"@google-cloud/pubsub": "5.2.0",
"@google-cloud/translate": "9.2.0",
"@koa/cors": "5.0.0",
"@koa/router": "14.0.0",
"@langchain/anthropic": "0.3.27",
@ -78,6 +78,7 @@
"@push-rpc/websocket": "1.9.3",
"@sequelize/core": "7.0.0-alpha.46",
"@sequelize/postgres": "7.0.0-alpha.46",
"@sequelize/sqlite3": "^7.0.0-alpha.46",
"@types/validator": "13.15.3",
"adm-zip": "0.5.16",
"alasql": "4.6.6",
@ -92,11 +93,10 @@
"bluebird": "3.7.2",
"body-parser": "2.2.0",
"botbuilder": "4.23.3",
"botbuilder-adapter-facebook": "1.0.12",
"botbuilder-ai": "4.23.3",
"botbuilder-dialogs": "4.23.3",
"botframework-connector": "4.23.3",
"botlib-legacy": "5.1.1",
"botlib-legacy": "5.2.0",
"cd": "0.3.3",
"chalk-animation": "2.0.3",
"chrome-remote-interface": "0.33.3",
@ -107,24 +107,23 @@
"csv-database": "0.9.2",
"data-forge": "1.10.4",
"date-diff": "1.0.2",
"docximager": "^0.0.4",
"docxtemplater": "^3.66.3",
"docximager": "0.0.4",
"docxtemplater": "3.66.3",
"dotenv-extended": "2.9.0",
"exceljs": "^4.4.0",
"express": "5.1.0",
"exceljs": "4.4.0",
"express": "^4.21.2",
"express-remove-route": "1.0.0",
"facebook-nodejs-business-sdk": "23.0.1",
"ffmpeg-static": "5.2.0",
"final-stream": "^2.0.4",
"final-stream": "2.0.4",
"formidable": "3.5.4",
"get-image-colors": "^4.0.1",
"glob": "11.0.3",
"google-libphonenumber": "3.2.42",
"googleapis": "^159.0.0",
"googleapis": "159.0.0",
"hnswlib-node": "3.0.0",
"html-to-md": "0.8.8",
"http-proxy": "1.18.1",
"ibm-watson": "^11.0.0",
"ibm-watson": "11.0.0",
"icojs": "0.19.5",
"iso-639-1": "3.1.5",
"isomorphic-fetch": "3.0.0",
@ -145,20 +144,21 @@
"luxon": "3.7.2",
"mammoth": "1.10.0",
"mariadb": "3.4.5",
"marked": "16.3.0",
"mime-types": "3.0.1",
"minio": "8.0.6",
"moment": "2.30.1",
"ms-rest-azure": "^3.0.2",
"mysql": "2.18.1",
"node-cron": "4.2.1",
"node-gyp": "^11.4.2",
"node-html-parser": "7.0.1",
"node-nlp": "^4.27.0",
"node-nlp": "4.27.0",
"nodemailer": "7.0.6",
"nodemon": "3.1.10",
"npm": "11.6.0",
"office-text-extractor": "^3.0.3",
"office-text-extractor": "3.0.3",
"open": "10.2.0",
"open-docxtemplater-image-module": "^1.0.3",
"open-docxtemplater-image-module": "1.0.3",
"openai": "4.62.1",
"pdf-extraction": "1.0.2",
"pdf-parse": "1.1.1",
@ -172,6 +172,8 @@
"public-ip": "7.0.1",
"punycode": "2.3.1",
"puppeteer": "24.20.0",
"puppeteer-extra": "^3.3.6",
"puppeteer-extra-plugin-stealth": "^2.11.2",
"qr-scanner": "1.4.2",
"qrcode": "1.5.4",
"qrcode-reader": "1.0.4",
@ -186,29 +188,27 @@
"sequelize-typescript": "2.1.6",
"simple-git": "3.28.0",
"speakingurl": "14.0.1",
"sqlite3": "^5.1.7",
"strict-password-generator": "1.1.2",
"stripe": "18.5.0",
"super-strong-password-generator": "2.0.2",
"super-strong-password-generator-es": "2.0.2",
"svg2img": "^1.0.0-beta.2",
"swagger-client": "3.35.6",
"swagger-ui-dist": "5.29.0",
"tabulator-tables": "6.3.1",
"tedious": "18.6.1",
"textract": "^2.5.0",
"twilio": "5.9.0",
"twitter-api-v2": "1.27.0",
"typeorm": "0.3.26",
"typescript": "5.9.2",
"url-join": "^5.0.0",
"url-join": "5.0.0",
"vhost": "3.0.2",
"vm2": "github:n8n-io/vm2",
"walk-promise": "0.2.0",
"washyourmouthoutwithsoap": "1.0.2",
"webdav-server": "2.6.2",
"webp-converter": "^2.3.3",
"webp-converter": "2.3.3",
"whatsapp-cloud-api": "0.3.1",
"whatsapp-web.js": "^1.34.1",
"whatsapp-web.js": "1.34.1",
"ws": "8.18.3",
"yaml": "2.8.1",
"yarn": "1.22.22",
@ -319,37 +319,33 @@
"overrides": {
"lodash.trimend": "npm:lodash@4.17.21",
"lodash.isequal": "npm:lodash@4.17.21",
"node-domexception": "npm:whatwg-url@^11.0.0",
"node-domexception": "npm:whatwg-url@11.0.0",
"csv-database": {
"fast-csv": "4.3.6"
},
"sequelize-typescript": {
"glob": "~9.0.0"
},
"botbuilder-adapter-facebook": {
"node-domexception": "npm:whatwg-url@^11.0.0"
},
"tough-cookie": "4.1.3",
"phin": "3.7.1",
"xmldom": "npm:@xmldom/xmldom@^0.8.10",
"xmldom": "npm:@xmldom/xmldom@0.8.10",
"form-data": "2.5.5",
"uuid": "9.0.1",
"har-validator": "5.1.5",
"request": "2.88.2",
"yaeti": "npm:events@^3.3.0",
"text-encoding": "npm:text-encoder-lite@^1.0.1",
"yaeti": "npm:events@3.3.0",
"text-encoding": "npm:text-encoder-lite@1.0.1",
"docximager": {
"xml2js": "^0.5.0"
"xml2js": "0.5.0"
},
"tar-fs": "3.1.0",
"ws": "8.18.3",
"xml2js": "^0.6.2",
"inflight": "npm:lru-cache@^10.2.0",
"xml2js": "0.6.2",
"inflight": "npm:lru-cache@10.2.0",
"rimraf": "6.0.1",
"glob": "11.0.3",
"fstream": "npm:fs-extra@^11.0.0",
"fstream": "npm:fs-extra@11.0.0",
"puppeteer": "24.20.0",
"fluent-ffmpeg": "npm:ffmpeg-static@^5.0.0",
"fluent-ffmpeg": "npm:ffmpeg-static@5.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
"@nlpjs/xtables": {
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"

View file

@ -64,13 +64,13 @@ import { GBUtil } from '../../../src/util.js';
let msRestAzure: any = null;
try {
const msRestAzure = await import('ms-rest-azure');
const msRestAzure = require('ms-rest-azure');
} catch (error) {}
let AuthenticationContext: any = null;
try {
const adal = await import('adal-node');
const adal = require('adal-node');
AuthenticationContext = adal.AuthenticationContext;
} catch (error) {}

View file

@ -22,7 +22,7 @@
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.com.br. |
| The licensing of the program under the AGPLv3 does not imply a |
The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
@ -39,10 +39,8 @@ import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
import { ScheduleServices } from './ScheduleServices.js';
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
import urlJoin from 'url-join';
import { NodeVM, VMScript } from 'vm2';
import { createVm2Pool } from './vm2-process/index.js';
import { watch } from 'fs';
import textract from 'textract';
import walkPromise from 'walk-promise';
import child_process from 'child_process';
import path from 'path';
@ -56,6 +54,21 @@ import { Sequelize, SequelizeOptions } from 'sequelize-typescript';
import { z } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';
import { GBUtil } from '../../../src/util.js';
import { createRequire } from 'module';
// Use .catch() instead of try/catch for dynamic imports
const vm2 = await import('vm2' as string).catch(error => {
console.log('vm2 not available, running in limited mode');
return null;
});
const NodeVM = vm2?.NodeVM;
const VMScript = vm2?.VMScript;
let textract: any = null;
try {
const textractModule = require('textract');
textract = textractModule.default || textractModule;
} catch {}
/**
* @fileoverview Decision was to priorize security(isolation) and debugging,
@ -931,6 +944,11 @@ export class GBVMService extends GBService {
* Executes the converted JavaScript from BASIC code inside execution context.
*/
public static async callVM(text: string, min: GBMinInstance, step, pid, debug: boolean = false, params = []) {
if (!vm2) {
GBLogEx.info(0, 'VM is disabled.');
return;
}
// Creates a class DialogKeywords which is the *this* pointer
// in BASIC.

View file

@ -12,7 +12,7 @@ import { GBUtil } from '../../../../src/util.js';
let finalStream: any = null;
try {
finalStream = await import('final-stream');
finalStream = require('final-stream');
} catch {}
const waitUntil = condition => {

View file

@ -1,7 +1,13 @@
import { VMScript, NodeVM } from 'vm2';
import crypto1 from 'crypto';
import net1 from 'net';
let NodeVM, VMScript;
try {
const NodeVM = require('vm2').NodeVM;
const VMScript = require('vm2').VMScript;
} catch {}
const evaluate = async (script, scope) => {
const vm = new NodeVM({
allowAsync: true,
@ -26,13 +32,12 @@ const server = net1.createServer(socket => {
const buffer = [];
const sync = async () => {
const request = buffer.join('').toString();
console.log(request);
if (request.includes('\n')) {
try {
const { code, scope } = JSON.parse(request);
const result = await evaluate(code, {
...scope,
module: null
@ -49,11 +54,9 @@ const server = net1.createServer(socket => {
}
};
socket.on('error', err => {
console.log(err);
});
socket.on('data', data => {
buffer.push(data);
sync();

View file

@ -555,7 +555,7 @@ export class GBConversationalService {
var renderer = new marked.Renderer();
renderer['oldImage'] = renderer.image;
renderer.image = function (href, title, text) {
renderer.image = ({ href, title, text, tokens }) => {
var videos = ['webm', 'mp4', 'mov'];
var filetype = href.split('.').pop();
if (videos.indexOf(filetype) > -1) {

View file

@ -34,7 +34,6 @@
'use strict';
import { createRpcServer } from '@push-rpc/core';
import AuthenticationContext from 'adal-node';
import arrayBufferToBuffer from 'arraybuffer-to-buffer';
import { Semaphore } from 'async-mutex';
import { AccessToken } from 'livekit-server-sdk';
@ -49,7 +48,7 @@ import {
TurnContext,
UserState
} from 'botbuilder';
import { FacebookAdapter } from 'botbuilder-adapter-facebook';
import {
AttachmentPrompt,
ConfirmPrompt,
@ -108,6 +107,20 @@ import { GBLogEx } from './GBLogEx.js';
import { GBSSR } from './GBSSR.js';
import Stripe from 'stripe';
let AuthenticationContext: any = null;
try {
const adal = require('adal-node');
AuthenticationContext = adal.AuthenticationContext;
} catch (error) {}
let FacebookAdapter: any = null;
try {
const facebook = require('botbuilder-adapter-facebook');
FacebookAdapter = facebook.FacebookAdapter;
} catch (error) {}
/**
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
*/
@ -457,106 +470,52 @@ export class GBMinService {
this.createCheckHealthAddress(GBServer.globals.server, min, min.instance);
GBServer.globals.server
.all(`/${min.instance.botId}/paymentSuccess`, async (req, res) => {
try {
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
GBLogEx.info(min, `Payment success webhook received for bot ${min.instance.botId}`);
if (process.env.WHATSAPP_ENABLED) {
GBServer.globals.server
.all(`/${min.instance.botId}/whatsapp`, async (req, res) => {
const challenge = (min.core['getParam'] as any)(min.instance, `Meta Challenge`, null, true);
const sessionId = req.query.session_id;
if (!sessionId) {
GBLogEx.info(min, 'No session_id parameter found in payment success callback');
return res.status(400).json({ success: false, error: 'Missing session_id parameter' });
const status = req.body?.entry?.[0]?.changes?.[0]?.value?.statuses?.[0];
if (status) {
GBLogEx.info(min, `WhatsApp: ${status.recipient_id} ${status.status}`);
return;
}
const session = await stripe.checkout.sessions.retrieve(sessionId);
if (req.query['hub.mode'] === 'subscribe') {
const val = req.query['hub.verify_token'];
if (session.payment_status === 'paid') {
GBLogEx.info(min, `Payment confirmed for session ${sessionId}`);
if (challenge && val === challenge) {
res.send(req.query['hub.challenge']);
res.status(200);
} else {
res.status(401);
}
res.end();
// Only for successful payment - send HTML to close window
res.send(`
<!DOCTYPE html>
<html>
<head>
<title>Payment Successful</title>
<script>
// Close the window after a short delay
setTimeout(() => {
window.close();
}, 1000);
</script>
</head>
<body style="text-align: center; padding: 40px; font-family: Arial;">
<h1 style="color: #4CAF50;">Payment Successful!</h1>
<p>General Bots: Your transaction was completed successfully.</p>
</body>
</html>
`);
} else {
GBLogEx.info(min, `Payment not completed for session ${sessionId}`);
res.status(402).json({
success: false,
error: 'Payment not completed',
sessionId: sessionId
});
return;
}
} catch (error) {
GBLogEx.error(min, `Error processing payment success: ${error.message}`);
res.status(500).json({
success: false,
error: error.message
});
}
})
.bind(min);
// Setups official handler for WhatsApp.
GBServer.globals.server
.all(`/${min.instance.botId}/whatsapp`, async (req, res) => {
const challenge = (min.core['getParam'] as any)(min.instance, `Meta Challenge`, null, true);
let whatsAppDirectLine = min.whatsAppDirectLine;
const status = req.body?.entry?.[0]?.changes?.[0]?.value?.statuses?.[0];
// Not meta, multiples bots on root bot.
if (status) {
GBLogEx.info(min, `WhatsApp: ${status.recipient_id} ${status.status}`);
return;
}
if (req.query['hub.mode'] === 'subscribe') {
const val = req.query['hub.verify_token'];
if (challenge && val === challenge) {
res.send(req.query['hub.challenge']);
res.status(200);
} else {
res.status(401);
if (!req.body.object) {
if (req.body.To) {
const to = req.body.To.replace(/whatsapp\:\+/gi, '');
whatsAppDirectLine = WhatsappDirectLine.botsByNumber[to];
} else {
const minBoot = GBServer.globals.minBoot as GBMinInstance;
whatsAppDirectLine = minBoot.whatsAppDirectLine;
}
}
res.end();
return;
}
let whatsAppDirectLine = min.whatsAppDirectLine;
// Not meta, multiples bots on root bot.
if (!req.body.object) {
if (req.body.To) {
const to = req.body.To.replace(/whatsapp\:\+/gi, '');
whatsAppDirectLine = WhatsappDirectLine.botsByNumber[to];
} else {
const minBoot = GBServer.globals.minBoot as GBMinInstance;
whatsAppDirectLine = minBoot.whatsAppDirectLine;
if (whatsAppDirectLine) {
await whatsAppDirectLine.WhatsAppCallback(req, res, whatsAppDirectLine.botId);
}
}
if (whatsAppDirectLine) {
await whatsAppDirectLine.WhatsAppCallback(req, res, whatsAppDirectLine.botId);
}
})
.bind(min);
})
.bind(min);
}
GBServer.globals.server.all(`/${min.instance.botId}/meeting-token`, async (req, res) => {
try {
// Add to your route handler

View file

@ -49,7 +49,6 @@ import { EPubLoader } from '@langchain/community/document_loaders/fs/epub';
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';
import isICO from 'icojs';
import getColors from 'get-image-colors';
import { Document } from 'langchain/document';
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
import puppeteer, { executablePath, Page } from 'puppeteer';
@ -87,24 +86,24 @@ import { exec } from 'child_process';
let webp: any = null;
try {
webp = await import('webp-converter');
webp = require('webp-converter');
} catch {}
let svg2img: any = null;
try {
const svg2imgModule = await import('svg2img');
const svg2imgModule = require('svg2img');
svg2img = svg2imgModule.default || svg2imgModule;
} catch {}
let getColors: any = null;
try {
const getColorsModule = await import('get-image-colors');
const getColorsModule = require('get-image-colors');
getColors = getColorsModule.default || getColorsModule;
} catch {}
let textract: any = null;
try {
const textractModule = await import('textract');
const textractModule = require('textract');
textract = textractModule.default || textractModule;
} catch {}

File diff suppressed because one or more lines are too long

View file

@ -1,9 +1,12 @@
npm install \
c3-chart-maker@0.2.8 \
botbuilder-adapter-facebook@1.0.12 \
ms-rest-azure@3.0.2 \
open-docxtemplater-image-module@1.0.3 \
svg2img@1.0.0-beta.2 \
get-image-colors@4.0.1 \
textract \
textract@2.5.0 \
webp-converter \
final-stream
final-stream \
@sequelize/sqlite3 \
vm2@3.9.11