@exulu/backend 1.25.3 → 1.25.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/dist/index.cjs +52 -62
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +52 -62
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
## [1.25.
|
|
1
|
+
## [1.25.5](https://github.com/Qventu/exulu-backend/compare/v1.25.4...v1.25.5) (2025-10-08)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* styling of stdout console log winston ([60da8eb](https://github.com/Qventu/exulu-backend/commit/60da8ebfe405215cd6832491b5ba166e77fb56df))
|
package/dist/index.cjs
CHANGED
|
@@ -5171,7 +5171,7 @@ var createRecurringJobs = async () => {
|
|
|
5171
5171
|
);
|
|
5172
5172
|
return queue;
|
|
5173
5173
|
};
|
|
5174
|
-
var createExpressRoutes = async (app,
|
|
5174
|
+
var createExpressRoutes = async (app, agents, tools, contexts, config, tracer, filesContext2) => {
|
|
5175
5175
|
var corsOptions = {
|
|
5176
5176
|
origin: "*",
|
|
5177
5177
|
exposedHeaders: "*",
|
|
@@ -5224,8 +5224,8 @@ var createExpressRoutes = async (app, logger, agents, tools, contexts, config, t
|
|
|
5224
5224
|
import_express4.default.json({ limit: REQUEST_SIZE_LIMIT }),
|
|
5225
5225
|
(0, import_express5.expressMiddleware)(server, {
|
|
5226
5226
|
context: async ({ req }) => {
|
|
5227
|
-
|
|
5228
|
-
|
|
5227
|
+
console.info("================");
|
|
5228
|
+
console.info({
|
|
5229
5229
|
message: "Incoming Request",
|
|
5230
5230
|
method: req.method,
|
|
5231
5231
|
path: req.path,
|
|
@@ -5234,7 +5234,7 @@ var createExpressRoutes = async (app, logger, agents, tools, contexts, config, t
|
|
|
5234
5234
|
userAgent: req.get("User-Agent"),
|
|
5235
5235
|
headers: req.headers
|
|
5236
5236
|
});
|
|
5237
|
-
|
|
5237
|
+
console.info("================");
|
|
5238
5238
|
const authenticationResult = await requestValidators.authenticate(req);
|
|
5239
5239
|
if (!authenticationResult.user?.id) {
|
|
5240
5240
|
throw new Error(authenticationResult.message);
|
|
@@ -5501,10 +5501,10 @@ Mood: friendly and intelligent.
|
|
|
5501
5501
|
},
|
|
5502
5502
|
proxyReqPathResolver: (req) => {
|
|
5503
5503
|
const prefix = `/gateway/anthropic/${req.params.id}`;
|
|
5504
|
-
let
|
|
5505
|
-
if (!
|
|
5506
|
-
console.log("[EXULU] Provider path:",
|
|
5507
|
-
return
|
|
5504
|
+
let path = req.url.startsWith(prefix) ? req.url.slice(prefix.length) : req.url;
|
|
5505
|
+
if (!path.startsWith("/")) path = "/" + path;
|
|
5506
|
+
console.log("[EXULU] Provider path:", path);
|
|
5507
|
+
return path;
|
|
5508
5508
|
},
|
|
5509
5509
|
proxyReqOptDecorator: function(proxyReqOpts, srcReq) {
|
|
5510
5510
|
return new Promise(async (resolve, reject) => {
|
|
@@ -5676,12 +5676,9 @@ var createCustomAnthropicStreamingMessage = (message) => {
|
|
|
5676
5676
|
// src/registry/workers.ts
|
|
5677
5677
|
var import_ioredis = __toESM(require("ioredis"), 1);
|
|
5678
5678
|
var import_bullmq5 = require("bullmq");
|
|
5679
|
-
var fs2 = __toESM(require("fs"), 1);
|
|
5680
|
-
var import_path = __toESM(require("path"), 1);
|
|
5681
5679
|
var import_api2 = require("@opentelemetry/api");
|
|
5682
|
-
var defaultLogsDir = import_path.default.join(process.cwd(), "logs");
|
|
5683
5680
|
var redisConnection;
|
|
5684
|
-
var createWorkers = async (queues2,
|
|
5681
|
+
var createWorkers = async (queues2, contexts, tracer) => {
|
|
5685
5682
|
if (!redisServer.host || !redisServer.port) {
|
|
5686
5683
|
console.error("[EXULU] you are trying to start worker, but no redis server is configured in the environment.");
|
|
5687
5684
|
throw new Error("No redis server configured in the environment, so cannot start worker.");
|
|
@@ -5692,7 +5689,6 @@ var createWorkers = async (queues2, logger, contexts, _logsDir, tracer) => {
|
|
|
5692
5689
|
maxRetriesPerRequest: null
|
|
5693
5690
|
});
|
|
5694
5691
|
}
|
|
5695
|
-
const logsDir = _logsDir || defaultLogsDir;
|
|
5696
5692
|
const workers = queues2.map((queue) => {
|
|
5697
5693
|
console.log(`[EXULU] creating worker for queue ${queue}.`);
|
|
5698
5694
|
const worker = new import_bullmq5.Worker(
|
|
@@ -5745,41 +5741,8 @@ var createWorkers = async (queues2, logger, contexts, _logsDir, tracer) => {
|
|
|
5745
5741
|
});
|
|
5746
5742
|
return worker;
|
|
5747
5743
|
});
|
|
5748
|
-
const logsCleaner = createLogsCleanerWorker(logsDir);
|
|
5749
|
-
workers.push(logsCleaner);
|
|
5750
5744
|
return workers;
|
|
5751
5745
|
};
|
|
5752
|
-
var createLogsCleanerWorker = (logsDir) => {
|
|
5753
|
-
const logsCleaner = new import_bullmq5.Worker(
|
|
5754
|
-
global_queues.logs_cleaner,
|
|
5755
|
-
async (job) => {
|
|
5756
|
-
console.log(`[EXULU] recurring job ${job.id}.`);
|
|
5757
|
-
const folder = fs2.readdirSync(logsDir);
|
|
5758
|
-
const files = folder.filter((file) => file.endsWith(".log"));
|
|
5759
|
-
const now = /* @__PURE__ */ new Date();
|
|
5760
|
-
const daysToKeep = job.data.ttld;
|
|
5761
|
-
const dateToKeep = new Date(now.getTime() - daysToKeep * 24 * 60 * 60 * 1e3);
|
|
5762
|
-
files.forEach((file) => {
|
|
5763
|
-
const filePath = import_path.default.join(logsDir, file);
|
|
5764
|
-
const fileStats = fs2.statSync(filePath);
|
|
5765
|
-
if (fileStats.mtime < dateToKeep) {
|
|
5766
|
-
fs2.unlinkSync(filePath);
|
|
5767
|
-
}
|
|
5768
|
-
});
|
|
5769
|
-
},
|
|
5770
|
-
{ connection: redisConnection }
|
|
5771
|
-
);
|
|
5772
|
-
logsCleaner.on("completed", (job, returnvalue) => {
|
|
5773
|
-
console.log(`[EXULU] completed logs cleaner ${job.id}.`, returnvalue);
|
|
5774
|
-
});
|
|
5775
|
-
logsCleaner.on("failed", (job, error, prev) => {
|
|
5776
|
-
if (job?.id) {
|
|
5777
|
-
console.error(`[EXULU] failed logs cleaner ${job.id}.`);
|
|
5778
|
-
}
|
|
5779
|
-
console.error(`[EXULU] job error logs cleaner.`, error);
|
|
5780
|
-
});
|
|
5781
|
-
return logsCleaner;
|
|
5782
|
-
};
|
|
5783
5746
|
|
|
5784
5747
|
// src/mcp/index.ts
|
|
5785
5748
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
@@ -5796,7 +5759,7 @@ var ExuluMCP = class {
|
|
|
5796
5759
|
express;
|
|
5797
5760
|
constructor() {
|
|
5798
5761
|
}
|
|
5799
|
-
create = async ({ express: express3, contexts, agents, config, tools, tracer
|
|
5762
|
+
create = async ({ express: express3, contexts, agents, config, tools, tracer }) => {
|
|
5800
5763
|
this.express = express3;
|
|
5801
5764
|
if (!this.server) {
|
|
5802
5765
|
console.log("[EXULU] Creating MCP server.");
|
|
@@ -6053,7 +6016,8 @@ var import_api4 = require("@opentelemetry/api");
|
|
|
6053
6016
|
var import_winston_transport = require("@opentelemetry/winston-transport");
|
|
6054
6017
|
var import_winston = __toESM(require("winston"), 1);
|
|
6055
6018
|
var createLogger = ({
|
|
6056
|
-
enableOtel
|
|
6019
|
+
enableOtel,
|
|
6020
|
+
transports
|
|
6057
6021
|
}) => {
|
|
6058
6022
|
const logger = import_winston.default.createLogger({
|
|
6059
6023
|
level: "debug",
|
|
@@ -6070,7 +6034,7 @@ var createLogger = ({
|
|
|
6070
6034
|
environment: process.env.NODE_ENV || "development"
|
|
6071
6035
|
},
|
|
6072
6036
|
transports: [
|
|
6073
|
-
|
|
6037
|
+
...transports,
|
|
6074
6038
|
...enableOtel ? [new import_winston_transport.OpenTelemetryTransportV3()] : []
|
|
6075
6039
|
]
|
|
6076
6040
|
});
|
|
@@ -6149,6 +6113,17 @@ var filesContext = new ExuluContext({
|
|
|
6149
6113
|
});
|
|
6150
6114
|
|
|
6151
6115
|
// src/registry/index.ts
|
|
6116
|
+
var import_winston2 = __toESM(require("winston"), 1);
|
|
6117
|
+
var isDev = process.env.NODE_ENV !== "production";
|
|
6118
|
+
var consoleTransport = new import_winston2.default.transports.Console({
|
|
6119
|
+
format: isDev ? import_winston2.default.format.combine(
|
|
6120
|
+
import_winston2.default.format.colorize(),
|
|
6121
|
+
import_winston2.default.format.timestamp({ format: "HH:mm:ss" }),
|
|
6122
|
+
import_winston2.default.format.printf(({ timestamp, level, message }) => {
|
|
6123
|
+
return `${timestamp} [${level}] ${message}`;
|
|
6124
|
+
})
|
|
6125
|
+
) : import_winston2.default.format.json()
|
|
6126
|
+
});
|
|
6152
6127
|
var isValidPostgresName = (id) => {
|
|
6153
6128
|
const regex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
6154
6129
|
const isValid = regex.test(id);
|
|
@@ -6216,12 +6191,18 @@ var ExuluApp = class {
|
|
|
6216
6191
|
...contextsArray?.length ? contextsArray.map((context) => context.embedder?.queue?.name || null) : []
|
|
6217
6192
|
];
|
|
6218
6193
|
this._queues = [...new Set(queues2.filter((o) => !!o))];
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6194
|
+
console.log("[EXULU] App initialized.");
|
|
6195
|
+
return this;
|
|
6196
|
+
};
|
|
6197
|
+
express = {
|
|
6198
|
+
init: async () => {
|
|
6199
|
+
if (!this._expressApp) {
|
|
6200
|
+
this._expressApp = (0, import_express8.default)();
|
|
6201
|
+
await this.server.express.init();
|
|
6202
|
+
console.log("[EXULU] Express app initialized.");
|
|
6203
|
+
}
|
|
6204
|
+
return this._expressApp;
|
|
6223
6205
|
}
|
|
6224
|
-
return this._expressApp;
|
|
6225
6206
|
};
|
|
6226
6207
|
get expressApp() {
|
|
6227
6208
|
if (!this._expressApp) {
|
|
@@ -6282,14 +6263,19 @@ var ExuluApp = class {
|
|
|
6282
6263
|
if (this._config?.telemetry?.enabled) {
|
|
6283
6264
|
tracer = import_api4.trace.getTracer("exulu", "1.0.0");
|
|
6284
6265
|
}
|
|
6266
|
+
const transports = this._config?.workers?.logger?.winston?.transports ?? this._config?.logger?.winston?.transports ?? [consoleTransport];
|
|
6285
6267
|
const logger = logger_default({
|
|
6286
|
-
enableOtel: this._config?.workers?.telemetry?.enabled ?? false
|
|
6268
|
+
enableOtel: this._config?.workers?.telemetry?.enabled ?? false,
|
|
6269
|
+
transports
|
|
6287
6270
|
});
|
|
6271
|
+
console.log = (...args) => logger.info(args.map(String).join(" "));
|
|
6272
|
+
console.info = (...args) => logger.info(args.map(String).join(" "));
|
|
6273
|
+
console.warn = (...args) => logger.warn(args.map(String).join(" "));
|
|
6274
|
+
console.error = (...args) => logger.error(args.map(String).join(" "));
|
|
6275
|
+
console.debug = (...args) => logger.debug(args.map(String).join(" "));
|
|
6288
6276
|
return await createWorkers(
|
|
6289
6277
|
this._queues,
|
|
6290
|
-
logger,
|
|
6291
6278
|
Object.values(this._contexts ?? {}),
|
|
6292
|
-
this._config?.workers?.logsDir,
|
|
6293
6279
|
tracer
|
|
6294
6280
|
);
|
|
6295
6281
|
}
|
|
@@ -6307,11 +6293,16 @@ var ExuluApp = class {
|
|
|
6307
6293
|
tracer = import_api4.trace.getTracer("exulu", "1.0.0");
|
|
6308
6294
|
}
|
|
6309
6295
|
const logger = logger_default({
|
|
6310
|
-
enableOtel: this._config?.telemetry?.enabled ?? false
|
|
6296
|
+
enableOtel: this._config?.telemetry?.enabled ?? false,
|
|
6297
|
+
transports: this._config?.logger?.winston?.transports ?? [consoleTransport]
|
|
6311
6298
|
});
|
|
6299
|
+
console.log = (...args) => logger.info(args.map(String).join(" "));
|
|
6300
|
+
console.info = (...args) => logger.info(args.map(String).join(" "));
|
|
6301
|
+
console.warn = (...args) => logger.warn(args.map(String).join(" "));
|
|
6302
|
+
console.error = (...args) => logger.error(args.map(String).join(" "));
|
|
6303
|
+
console.debug = (...args) => logger.debug(args.map(String).join(" "));
|
|
6312
6304
|
await createExpressRoutes(
|
|
6313
6305
|
app,
|
|
6314
|
-
logger,
|
|
6315
6306
|
this._agents,
|
|
6316
6307
|
this._tools,
|
|
6317
6308
|
Object.values(this._contexts ?? {}),
|
|
@@ -6327,8 +6318,7 @@ var ExuluApp = class {
|
|
|
6327
6318
|
agents: this._agents,
|
|
6328
6319
|
config: this._config,
|
|
6329
6320
|
tools: this._tools,
|
|
6330
|
-
tracer
|
|
6331
|
-
logger
|
|
6321
|
+
tracer
|
|
6332
6322
|
});
|
|
6333
6323
|
await mcp.connect();
|
|
6334
6324
|
}
|
|
@@ -6597,7 +6587,7 @@ var RecursiveRules = class _RecursiveRules {
|
|
|
6597
6587
|
* @param {string} path - The path to the recipe.
|
|
6598
6588
|
* @returns {Promise<RecursiveRules>} The RecursiveRules object.
|
|
6599
6589
|
*/
|
|
6600
|
-
static async fromRecipe(name = "default", lang = "en",
|
|
6590
|
+
static async fromRecipe(name = "default", lang = "en", path) {
|
|
6601
6591
|
throw new Error("Not implemented");
|
|
6602
6592
|
}
|
|
6603
6593
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,7 @@ import { RedisClientType } from 'redis';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { Tool, LanguageModel, UIMessage } from 'ai';
|
|
7
7
|
import { Express, Response, Request } from 'express';
|
|
8
|
+
import { transport } from 'winston';
|
|
8
9
|
import { Knex } from 'knex';
|
|
9
10
|
import { Tiktoken } from 'tiktoken/lite';
|
|
10
11
|
import models from 'tiktoken/model_to_encoding.json';
|
|
@@ -54,9 +55,18 @@ type ExuluConfig = {
|
|
|
54
55
|
telemetry?: {
|
|
55
56
|
enabled: boolean;
|
|
56
57
|
};
|
|
58
|
+
logger?: {
|
|
59
|
+
winston: {
|
|
60
|
+
transports: transport[];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
57
63
|
workers: {
|
|
58
64
|
enabled: boolean;
|
|
59
|
-
|
|
65
|
+
logger?: {
|
|
66
|
+
winston: {
|
|
67
|
+
transports: transport[];
|
|
68
|
+
};
|
|
69
|
+
};
|
|
60
70
|
telemetry?: {
|
|
61
71
|
enabled: boolean;
|
|
62
72
|
};
|
|
@@ -85,7 +95,10 @@ declare class ExuluApp {
|
|
|
85
95
|
config: ExuluConfig;
|
|
86
96
|
agents?: ExuluAgent[];
|
|
87
97
|
tools?: ExuluTool[];
|
|
88
|
-
}) => Promise<
|
|
98
|
+
}) => Promise<ExuluApp>;
|
|
99
|
+
express: {
|
|
100
|
+
init: () => Promise<Express>;
|
|
101
|
+
};
|
|
89
102
|
get expressApp(): Express;
|
|
90
103
|
tool(id: string): ExuluTool | undefined;
|
|
91
104
|
tools(): ExuluTool[];
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { RedisClientType } from 'redis';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { Tool, LanguageModel, UIMessage } from 'ai';
|
|
7
7
|
import { Express, Response, Request } from 'express';
|
|
8
|
+
import { transport } from 'winston';
|
|
8
9
|
import { Knex } from 'knex';
|
|
9
10
|
import { Tiktoken } from 'tiktoken/lite';
|
|
10
11
|
import models from 'tiktoken/model_to_encoding.json';
|
|
@@ -54,9 +55,18 @@ type ExuluConfig = {
|
|
|
54
55
|
telemetry?: {
|
|
55
56
|
enabled: boolean;
|
|
56
57
|
};
|
|
58
|
+
logger?: {
|
|
59
|
+
winston: {
|
|
60
|
+
transports: transport[];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
57
63
|
workers: {
|
|
58
64
|
enabled: boolean;
|
|
59
|
-
|
|
65
|
+
logger?: {
|
|
66
|
+
winston: {
|
|
67
|
+
transports: transport[];
|
|
68
|
+
};
|
|
69
|
+
};
|
|
60
70
|
telemetry?: {
|
|
61
71
|
enabled: boolean;
|
|
62
72
|
};
|
|
@@ -85,7 +95,10 @@ declare class ExuluApp {
|
|
|
85
95
|
config: ExuluConfig;
|
|
86
96
|
agents?: ExuluAgent[];
|
|
87
97
|
tools?: ExuluTool[];
|
|
88
|
-
}) => Promise<
|
|
98
|
+
}) => Promise<ExuluApp>;
|
|
99
|
+
express: {
|
|
100
|
+
init: () => Promise<Express>;
|
|
101
|
+
};
|
|
89
102
|
get expressApp(): Express;
|
|
90
103
|
tool(id: string): ExuluTool | undefined;
|
|
91
104
|
tools(): ExuluTool[];
|
package/dist/index.js
CHANGED
|
@@ -5137,7 +5137,7 @@ var createRecurringJobs = async () => {
|
|
|
5137
5137
|
);
|
|
5138
5138
|
return queue;
|
|
5139
5139
|
};
|
|
5140
|
-
var createExpressRoutes = async (app,
|
|
5140
|
+
var createExpressRoutes = async (app, agents, tools, contexts, config, tracer, filesContext2) => {
|
|
5141
5141
|
var corsOptions = {
|
|
5142
5142
|
origin: "*",
|
|
5143
5143
|
exposedHeaders: "*",
|
|
@@ -5190,8 +5190,8 @@ var createExpressRoutes = async (app, logger, agents, tools, contexts, config, t
|
|
|
5190
5190
|
express.json({ limit: REQUEST_SIZE_LIMIT }),
|
|
5191
5191
|
expressMiddleware(server, {
|
|
5192
5192
|
context: async ({ req }) => {
|
|
5193
|
-
|
|
5194
|
-
|
|
5193
|
+
console.info("================");
|
|
5194
|
+
console.info({
|
|
5195
5195
|
message: "Incoming Request",
|
|
5196
5196
|
method: req.method,
|
|
5197
5197
|
path: req.path,
|
|
@@ -5200,7 +5200,7 @@ var createExpressRoutes = async (app, logger, agents, tools, contexts, config, t
|
|
|
5200
5200
|
userAgent: req.get("User-Agent"),
|
|
5201
5201
|
headers: req.headers
|
|
5202
5202
|
});
|
|
5203
|
-
|
|
5203
|
+
console.info("================");
|
|
5204
5204
|
const authenticationResult = await requestValidators.authenticate(req);
|
|
5205
5205
|
if (!authenticationResult.user?.id) {
|
|
5206
5206
|
throw new Error(authenticationResult.message);
|
|
@@ -5467,10 +5467,10 @@ Mood: friendly and intelligent.
|
|
|
5467
5467
|
},
|
|
5468
5468
|
proxyReqPathResolver: (req) => {
|
|
5469
5469
|
const prefix = `/gateway/anthropic/${req.params.id}`;
|
|
5470
|
-
let
|
|
5471
|
-
if (!
|
|
5472
|
-
console.log("[EXULU] Provider path:",
|
|
5473
|
-
return
|
|
5470
|
+
let path = req.url.startsWith(prefix) ? req.url.slice(prefix.length) : req.url;
|
|
5471
|
+
if (!path.startsWith("/")) path = "/" + path;
|
|
5472
|
+
console.log("[EXULU] Provider path:", path);
|
|
5473
|
+
return path;
|
|
5474
5474
|
},
|
|
5475
5475
|
proxyReqOptDecorator: function(proxyReqOpts, srcReq) {
|
|
5476
5476
|
return new Promise(async (resolve, reject) => {
|
|
@@ -5642,12 +5642,9 @@ var createCustomAnthropicStreamingMessage = (message) => {
|
|
|
5642
5642
|
// src/registry/workers.ts
|
|
5643
5643
|
import IORedis from "ioredis";
|
|
5644
5644
|
import { Worker } from "bullmq";
|
|
5645
|
-
import * as fs2 from "fs";
|
|
5646
|
-
import path from "path";
|
|
5647
5645
|
import "@opentelemetry/api";
|
|
5648
|
-
var defaultLogsDir = path.join(process.cwd(), "logs");
|
|
5649
5646
|
var redisConnection;
|
|
5650
|
-
var createWorkers = async (queues2,
|
|
5647
|
+
var createWorkers = async (queues2, contexts, tracer) => {
|
|
5651
5648
|
if (!redisServer.host || !redisServer.port) {
|
|
5652
5649
|
console.error("[EXULU] you are trying to start worker, but no redis server is configured in the environment.");
|
|
5653
5650
|
throw new Error("No redis server configured in the environment, so cannot start worker.");
|
|
@@ -5658,7 +5655,6 @@ var createWorkers = async (queues2, logger, contexts, _logsDir, tracer) => {
|
|
|
5658
5655
|
maxRetriesPerRequest: null
|
|
5659
5656
|
});
|
|
5660
5657
|
}
|
|
5661
|
-
const logsDir = _logsDir || defaultLogsDir;
|
|
5662
5658
|
const workers = queues2.map((queue) => {
|
|
5663
5659
|
console.log(`[EXULU] creating worker for queue ${queue}.`);
|
|
5664
5660
|
const worker = new Worker(
|
|
@@ -5711,41 +5707,8 @@ var createWorkers = async (queues2, logger, contexts, _logsDir, tracer) => {
|
|
|
5711
5707
|
});
|
|
5712
5708
|
return worker;
|
|
5713
5709
|
});
|
|
5714
|
-
const logsCleaner = createLogsCleanerWorker(logsDir);
|
|
5715
|
-
workers.push(logsCleaner);
|
|
5716
5710
|
return workers;
|
|
5717
5711
|
};
|
|
5718
|
-
var createLogsCleanerWorker = (logsDir) => {
|
|
5719
|
-
const logsCleaner = new Worker(
|
|
5720
|
-
global_queues.logs_cleaner,
|
|
5721
|
-
async (job) => {
|
|
5722
|
-
console.log(`[EXULU] recurring job ${job.id}.`);
|
|
5723
|
-
const folder = fs2.readdirSync(logsDir);
|
|
5724
|
-
const files = folder.filter((file) => file.endsWith(".log"));
|
|
5725
|
-
const now = /* @__PURE__ */ new Date();
|
|
5726
|
-
const daysToKeep = job.data.ttld;
|
|
5727
|
-
const dateToKeep = new Date(now.getTime() - daysToKeep * 24 * 60 * 60 * 1e3);
|
|
5728
|
-
files.forEach((file) => {
|
|
5729
|
-
const filePath = path.join(logsDir, file);
|
|
5730
|
-
const fileStats = fs2.statSync(filePath);
|
|
5731
|
-
if (fileStats.mtime < dateToKeep) {
|
|
5732
|
-
fs2.unlinkSync(filePath);
|
|
5733
|
-
}
|
|
5734
|
-
});
|
|
5735
|
-
},
|
|
5736
|
-
{ connection: redisConnection }
|
|
5737
|
-
);
|
|
5738
|
-
logsCleaner.on("completed", (job, returnvalue) => {
|
|
5739
|
-
console.log(`[EXULU] completed logs cleaner ${job.id}.`, returnvalue);
|
|
5740
|
-
});
|
|
5741
|
-
logsCleaner.on("failed", (job, error, prev) => {
|
|
5742
|
-
if (job?.id) {
|
|
5743
|
-
console.error(`[EXULU] failed logs cleaner ${job.id}.`);
|
|
5744
|
-
}
|
|
5745
|
-
console.error(`[EXULU] job error logs cleaner.`, error);
|
|
5746
|
-
});
|
|
5747
|
-
return logsCleaner;
|
|
5748
|
-
};
|
|
5749
5712
|
|
|
5750
5713
|
// src/mcp/index.ts
|
|
5751
5714
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -5762,7 +5725,7 @@ var ExuluMCP = class {
|
|
|
5762
5725
|
express;
|
|
5763
5726
|
constructor() {
|
|
5764
5727
|
}
|
|
5765
|
-
create = async ({ express: express3, contexts, agents, config, tools, tracer
|
|
5728
|
+
create = async ({ express: express3, contexts, agents, config, tools, tracer }) => {
|
|
5766
5729
|
this.express = express3;
|
|
5767
5730
|
if (!this.server) {
|
|
5768
5731
|
console.log("[EXULU] Creating MCP server.");
|
|
@@ -6019,7 +5982,8 @@ import { trace } from "@opentelemetry/api";
|
|
|
6019
5982
|
import { OpenTelemetryTransportV3 } from "@opentelemetry/winston-transport";
|
|
6020
5983
|
import winston from "winston";
|
|
6021
5984
|
var createLogger = ({
|
|
6022
|
-
enableOtel
|
|
5985
|
+
enableOtel,
|
|
5986
|
+
transports
|
|
6023
5987
|
}) => {
|
|
6024
5988
|
const logger = winston.createLogger({
|
|
6025
5989
|
level: "debug",
|
|
@@ -6036,7 +6000,7 @@ var createLogger = ({
|
|
|
6036
6000
|
environment: process.env.NODE_ENV || "development"
|
|
6037
6001
|
},
|
|
6038
6002
|
transports: [
|
|
6039
|
-
|
|
6003
|
+
...transports,
|
|
6040
6004
|
...enableOtel ? [new OpenTelemetryTransportV3()] : []
|
|
6041
6005
|
]
|
|
6042
6006
|
});
|
|
@@ -6115,6 +6079,17 @@ var filesContext = new ExuluContext({
|
|
|
6115
6079
|
});
|
|
6116
6080
|
|
|
6117
6081
|
// src/registry/index.ts
|
|
6082
|
+
import winston2 from "winston";
|
|
6083
|
+
var isDev = process.env.NODE_ENV !== "production";
|
|
6084
|
+
var consoleTransport = new winston2.transports.Console({
|
|
6085
|
+
format: isDev ? winston2.format.combine(
|
|
6086
|
+
winston2.format.colorize(),
|
|
6087
|
+
winston2.format.timestamp({ format: "HH:mm:ss" }),
|
|
6088
|
+
winston2.format.printf(({ timestamp, level, message }) => {
|
|
6089
|
+
return `${timestamp} [${level}] ${message}`;
|
|
6090
|
+
})
|
|
6091
|
+
) : winston2.format.json()
|
|
6092
|
+
});
|
|
6118
6093
|
var isValidPostgresName = (id) => {
|
|
6119
6094
|
const regex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
6120
6095
|
const isValid = regex.test(id);
|
|
@@ -6182,12 +6157,18 @@ var ExuluApp = class {
|
|
|
6182
6157
|
...contextsArray?.length ? contextsArray.map((context) => context.embedder?.queue?.name || null) : []
|
|
6183
6158
|
];
|
|
6184
6159
|
this._queues = [...new Set(queues2.filter((o) => !!o))];
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6160
|
+
console.log("[EXULU] App initialized.");
|
|
6161
|
+
return this;
|
|
6162
|
+
};
|
|
6163
|
+
express = {
|
|
6164
|
+
init: async () => {
|
|
6165
|
+
if (!this._expressApp) {
|
|
6166
|
+
this._expressApp = express2();
|
|
6167
|
+
await this.server.express.init();
|
|
6168
|
+
console.log("[EXULU] Express app initialized.");
|
|
6169
|
+
}
|
|
6170
|
+
return this._expressApp;
|
|
6189
6171
|
}
|
|
6190
|
-
return this._expressApp;
|
|
6191
6172
|
};
|
|
6192
6173
|
get expressApp() {
|
|
6193
6174
|
if (!this._expressApp) {
|
|
@@ -6248,14 +6229,19 @@ var ExuluApp = class {
|
|
|
6248
6229
|
if (this._config?.telemetry?.enabled) {
|
|
6249
6230
|
tracer = trace.getTracer("exulu", "1.0.0");
|
|
6250
6231
|
}
|
|
6232
|
+
const transports = this._config?.workers?.logger?.winston?.transports ?? this._config?.logger?.winston?.transports ?? [consoleTransport];
|
|
6251
6233
|
const logger = logger_default({
|
|
6252
|
-
enableOtel: this._config?.workers?.telemetry?.enabled ?? false
|
|
6234
|
+
enableOtel: this._config?.workers?.telemetry?.enabled ?? false,
|
|
6235
|
+
transports
|
|
6253
6236
|
});
|
|
6237
|
+
console.log = (...args) => logger.info(args.map(String).join(" "));
|
|
6238
|
+
console.info = (...args) => logger.info(args.map(String).join(" "));
|
|
6239
|
+
console.warn = (...args) => logger.warn(args.map(String).join(" "));
|
|
6240
|
+
console.error = (...args) => logger.error(args.map(String).join(" "));
|
|
6241
|
+
console.debug = (...args) => logger.debug(args.map(String).join(" "));
|
|
6254
6242
|
return await createWorkers(
|
|
6255
6243
|
this._queues,
|
|
6256
|
-
logger,
|
|
6257
6244
|
Object.values(this._contexts ?? {}),
|
|
6258
|
-
this._config?.workers?.logsDir,
|
|
6259
6245
|
tracer
|
|
6260
6246
|
);
|
|
6261
6247
|
}
|
|
@@ -6273,11 +6259,16 @@ var ExuluApp = class {
|
|
|
6273
6259
|
tracer = trace.getTracer("exulu", "1.0.0");
|
|
6274
6260
|
}
|
|
6275
6261
|
const logger = logger_default({
|
|
6276
|
-
enableOtel: this._config?.telemetry?.enabled ?? false
|
|
6262
|
+
enableOtel: this._config?.telemetry?.enabled ?? false,
|
|
6263
|
+
transports: this._config?.logger?.winston?.transports ?? [consoleTransport]
|
|
6277
6264
|
});
|
|
6265
|
+
console.log = (...args) => logger.info(args.map(String).join(" "));
|
|
6266
|
+
console.info = (...args) => logger.info(args.map(String).join(" "));
|
|
6267
|
+
console.warn = (...args) => logger.warn(args.map(String).join(" "));
|
|
6268
|
+
console.error = (...args) => logger.error(args.map(String).join(" "));
|
|
6269
|
+
console.debug = (...args) => logger.debug(args.map(String).join(" "));
|
|
6278
6270
|
await createExpressRoutes(
|
|
6279
6271
|
app,
|
|
6280
|
-
logger,
|
|
6281
6272
|
this._agents,
|
|
6282
6273
|
this._tools,
|
|
6283
6274
|
Object.values(this._contexts ?? {}),
|
|
@@ -6293,8 +6284,7 @@ var ExuluApp = class {
|
|
|
6293
6284
|
agents: this._agents,
|
|
6294
6285
|
config: this._config,
|
|
6295
6286
|
tools: this._tools,
|
|
6296
|
-
tracer
|
|
6297
|
-
logger
|
|
6287
|
+
tracer
|
|
6298
6288
|
});
|
|
6299
6289
|
await mcp.connect();
|
|
6300
6290
|
}
|
|
@@ -6563,7 +6553,7 @@ var RecursiveRules = class _RecursiveRules {
|
|
|
6563
6553
|
* @param {string} path - The path to the recipe.
|
|
6564
6554
|
* @returns {Promise<RecursiveRules>} The RecursiveRules object.
|
|
6565
6555
|
*/
|
|
6566
|
-
static async fromRecipe(name = "default", lang = "en",
|
|
6556
|
+
static async fromRecipe(name = "default", lang = "en", path) {
|
|
6567
6557
|
throw new Error("Not implemented");
|
|
6568
6558
|
}
|
|
6569
6559
|
};
|