Files
vocero-client/s2s-reasoning-engine/settings.js
T

115 lines
4.3 KiB
JavaScript

/**
* Node-RED 5.0 settings for s2s-reasoning-engine — local installation.
* File: <project_root>/s2s-reasoning-engine/.node-red/settings.js
* or <project_root>/s2s-reasoning-engine/settings.js (source)
*
* start.sh copies this into .node-red/ when missing or older than the source.
*/
const path = require("path");
const fs = require("fs");
// start.sh uses <s2s-reasoning-engine>/.node-red as its local user directory.
const ENGINE_ROOT = path.resolve(__dirname, "..");
const LOCAL_NODE_MODULES = path.join(ENGINE_ROOT, "node_modules");
const USERDIR_NODE_MODULES = path.join(__dirname, "node_modules");
// Fix the editor's "tslib.es6.js 404 / net::ERR_ABORTED" error.
// Flat npm installations place tslib in the root node_modules/tslib directory
// rather than @node-red/editor-client/node_modules/tslib. The Node-RED 5 editor
// loads /tslib.es6.js from the HTTP root. Refresh the editor's public files at
// startup so the workaround survives dependency reinstallation.
(function _installTslibVendor() {
try {
const tslibRoot = path.join(LOCAL_NODE_MODULES, "tslib");
if (!fs.existsSync(path.join(tslibRoot, "tslib.es6.js"))) return;
const pub = path.join(LOCAL_NODE_MODULES, "@node-red", "editor-client", "public");
if (!fs.existsSync(pub)) return;
for (const f of ["tslib.es6.js", "tslib.js", "tslib.mjs"]) {
const src = path.join(tslibRoot, f);
const dst = path.join(pub, f);
if (!fs.existsSync(src)) continue;
try {
const s = fs.statSync(src);
const d = fs.existsSync(dst) ? fs.statSync(dst) : null;
if (!d || d.size !== s.size || d.mtimeMs < s.mtimeMs) {
fs.copyFileSync(src, dst);
}
} catch (e) { /* ignore */ }
}
} catch (e) { /* no-op */ }
})();
module.exports = {
uiPort: process.env.PORT || process.env.NODE_RED_PORT || 1881,
uiHost: "0.0.0.0",
httpRequestTimeout: 120000,
httpRequestLegacyMsgOverrides: true,
// Native HTTP helpers for function nodes, without externalModules.
// functionExternalModules can stall palette loading in Node-RED 5.
// Load core Node.js modules here before startup and expose them through
// functionGlobalContext, accessed with global.get("_core_https") etc.
functionModuleRequireAllowList: ["https","http","url","path","util","fs","os","buffer","zlib","stream","crypto"],
functionGlobalContext: {
_core_https: require("https"),
_core_http: require("http"),
_core_url: require("url"),
},
// adminAuth: {...} // Uncomment and configure for production.
// HTTPS (optional for production).
// https: {
// key: require("fs").readFileSync(path.join(__dirname, "privkey.pem")),
// cert: require("fs").readFileSync(path.join(__dirname, "fullchain.pem"))
// },
flowFile: process.env.FLOWS || path.join(__dirname, "flows.json"),
flowFilePretty: true,
credentialSecret: process.env.NODE_RED_CREDENTIAL_SECRET || "s2s-reasoning-local-dev",
httpNodeCors: {
origin: "*",
methods: "GET,PUT,POST,DELETE,OPTIONS",
credentials: true,
},
csrf: false,
// Additional node loading: Node-RED 5 looks for plugins in:
// 1) {userDir}/node_modules (our .node-red/node_modules)
// 2) {nodesDir} (the project-root installation)
// 3) npm global
// Set nodesDir so packages installed at the project root are discovered.
nodesDir: LOCAL_NODE_MODULES,
externalModules: {
autoInstall: true, // Install missing nodes at startup.
autoInstallRetry: 3,
palette: {
allowInstall: true, // Allow installation from the editor.
allowUpload: true,
modules: ["node-red-contrib-openai", "node-red-contrib-cache", "node-red-node-rbe"],
allowList: ["node-red-contrib-*", "node-red-node-*"],
denyList: []
}
},
editorTheme: { projects: { enabled: false } },
logging: {
console: {
level: process.env.NODE_RED_LOG_LEVEL || process.env.LOG_LEVEL || "info",
metrics: false,
audit: false,
timestamp: true,
}
},
contextStorage: {
default: { module: "memory" },
file: { module: "localfilesystem" }
},
};