@exulu/backend 1.25.2 → 1.25.4
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 +44 -63
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +44 -63
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
## [1.25.
|
|
1
|
+
## [1.25.4](https://github.com/Qventu/exulu-backend/compare/v1.25.3...v1.25.4) (2025-10-08)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
* add
|
|
6
|
+
* seperate exulu init from server init and add option to provide custom winston transports ([f4a1595](https://github.com/Qventu/exulu-backend/commit/f4a15951df7501e866b7148a1ff8e22bd5bbe956))
|
package/dist/index.cjs
CHANGED
|
@@ -58,7 +58,8 @@ var import_redis = require("redis");
|
|
|
58
58
|
// src/bullmq/server.ts
|
|
59
59
|
var redisServer = {
|
|
60
60
|
host: `${process.env.REDIS_HOST}`,
|
|
61
|
-
port: process.env.REDIS_PORT
|
|
61
|
+
port: process.env.REDIS_PORT,
|
|
62
|
+
password: process.env.REDIS_PASSWORD || void 0
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
// src/redis/client.ts
|
|
@@ -5170,7 +5171,7 @@ var createRecurringJobs = async () => {
|
|
|
5170
5171
|
);
|
|
5171
5172
|
return queue;
|
|
5172
5173
|
};
|
|
5173
|
-
var createExpressRoutes = async (app,
|
|
5174
|
+
var createExpressRoutes = async (app, agents, tools, contexts, config, tracer, filesContext2) => {
|
|
5174
5175
|
var corsOptions = {
|
|
5175
5176
|
origin: "*",
|
|
5176
5177
|
exposedHeaders: "*",
|
|
@@ -5223,8 +5224,8 @@ var createExpressRoutes = async (app, logger, agents, tools, contexts, config, t
|
|
|
5223
5224
|
import_express4.default.json({ limit: REQUEST_SIZE_LIMIT }),
|
|
5224
5225
|
(0, import_express5.expressMiddleware)(server, {
|
|
5225
5226
|
context: async ({ req }) => {
|
|
5226
|
-
|
|
5227
|
-
|
|
5227
|
+
console.info("================");
|
|
5228
|
+
console.info({
|
|
5228
5229
|
message: "Incoming Request",
|
|
5229
5230
|
method: req.method,
|
|
5230
5231
|
path: req.path,
|
|
@@ -5233,7 +5234,7 @@ var createExpressRoutes = async (app, logger, agents, tools, contexts, config, t
|
|
|
5233
5234
|
userAgent: req.get("User-Agent"),
|
|
5234
5235
|
headers: req.headers
|
|
5235
5236
|
});
|
|
5236
|
-
|
|
5237
|
+
console.info("================");
|
|
5237
5238
|
const authenticationResult = await requestValidators.authenticate(req);
|
|
5238
5239
|
if (!authenticationResult.user?.id) {
|
|
5239
5240
|
throw new Error(authenticationResult.message);
|
|
@@ -5500,10 +5501,10 @@ Mood: friendly and intelligent.
|
|
|
5500
5501
|
},
|
|
5501
5502
|
proxyReqPathResolver: (req) => {
|
|
5502
5503
|
const prefix = `/gateway/anthropic/${req.params.id}`;
|
|
5503
|
-
let
|
|
5504
|
-
if (!
|
|
5505
|
-
console.log("[EXULU] Provider path:",
|
|
5506
|
-
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;
|
|
5507
5508
|
},
|
|
5508
5509
|
proxyReqOptDecorator: function(proxyReqOpts, srcReq) {
|
|
5509
5510
|
return new Promise(async (resolve, reject) => {
|
|
@@ -5675,12 +5676,9 @@ var createCustomAnthropicStreamingMessage = (message) => {
|
|
|
5675
5676
|
// src/registry/workers.ts
|
|
5676
5677
|
var import_ioredis = __toESM(require("ioredis"), 1);
|
|
5677
5678
|
var import_bullmq5 = require("bullmq");
|
|
5678
|
-
var fs2 = __toESM(require("fs"), 1);
|
|
5679
|
-
var import_path = __toESM(require("path"), 1);
|
|
5680
5679
|
var import_api2 = require("@opentelemetry/api");
|
|
5681
|
-
var defaultLogsDir = import_path.default.join(process.cwd(), "logs");
|
|
5682
5680
|
var redisConnection;
|
|
5683
|
-
var createWorkers = async (queues2,
|
|
5681
|
+
var createWorkers = async (queues2, contexts, tracer) => {
|
|
5684
5682
|
if (!redisServer.host || !redisServer.port) {
|
|
5685
5683
|
console.error("[EXULU] you are trying to start worker, but no redis server is configured in the environment.");
|
|
5686
5684
|
throw new Error("No redis server configured in the environment, so cannot start worker.");
|
|
@@ -5691,7 +5689,6 @@ var createWorkers = async (queues2, logger, contexts, _logsDir, tracer) => {
|
|
|
5691
5689
|
maxRetriesPerRequest: null
|
|
5692
5690
|
});
|
|
5693
5691
|
}
|
|
5694
|
-
const logsDir = _logsDir || defaultLogsDir;
|
|
5695
5692
|
const workers = queues2.map((queue) => {
|
|
5696
5693
|
console.log(`[EXULU] creating worker for queue ${queue}.`);
|
|
5697
5694
|
const worker = new import_bullmq5.Worker(
|
|
@@ -5744,41 +5741,8 @@ var createWorkers = async (queues2, logger, contexts, _logsDir, tracer) => {
|
|
|
5744
5741
|
});
|
|
5745
5742
|
return worker;
|
|
5746
5743
|
});
|
|
5747
|
-
const logsCleaner = createLogsCleanerWorker(logsDir);
|
|
5748
|
-
workers.push(logsCleaner);
|
|
5749
5744
|
return workers;
|
|
5750
5745
|
};
|
|
5751
|
-
var createLogsCleanerWorker = (logsDir) => {
|
|
5752
|
-
const logsCleaner = new import_bullmq5.Worker(
|
|
5753
|
-
global_queues.logs_cleaner,
|
|
5754
|
-
async (job) => {
|
|
5755
|
-
console.log(`[EXULU] recurring job ${job.id}.`);
|
|
5756
|
-
const folder = fs2.readdirSync(logsDir);
|
|
5757
|
-
const files = folder.filter((file) => file.endsWith(".log"));
|
|
5758
|
-
const now = /* @__PURE__ */ new Date();
|
|
5759
|
-
const daysToKeep = job.data.ttld;
|
|
5760
|
-
const dateToKeep = new Date(now.getTime() - daysToKeep * 24 * 60 * 60 * 1e3);
|
|
5761
|
-
files.forEach((file) => {
|
|
5762
|
-
const filePath = import_path.default.join(logsDir, file);
|
|
5763
|
-
const fileStats = fs2.statSync(filePath);
|
|
5764
|
-
if (fileStats.mtime < dateToKeep) {
|
|
5765
|
-
fs2.unlinkSync(filePath);
|
|
5766
|
-
}
|
|
5767
|
-
});
|
|
5768
|
-
},
|
|
5769
|
-
{ connection: redisConnection }
|
|
5770
|
-
);
|
|
5771
|
-
logsCleaner.on("completed", (job, returnvalue) => {
|
|
5772
|
-
console.log(`[EXULU] completed logs cleaner ${job.id}.`, returnvalue);
|
|
5773
|
-
});
|
|
5774
|
-
logsCleaner.on("failed", (job, error, prev) => {
|
|
5775
|
-
if (job?.id) {
|
|
5776
|
-
console.error(`[EXULU] failed logs cleaner ${job.id}.`);
|
|
5777
|
-
}
|
|
5778
|
-
console.error(`[EXULU] job error logs cleaner.`, error);
|
|
5779
|
-
});
|
|
5780
|
-
return logsCleaner;
|
|
5781
|
-
};
|
|
5782
5746
|
|
|
5783
5747
|
// src/mcp/index.ts
|
|
5784
5748
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
@@ -5795,7 +5759,7 @@ var ExuluMCP = class {
|
|
|
5795
5759
|
express;
|
|
5796
5760
|
constructor() {
|
|
5797
5761
|
}
|
|
5798
|
-
create = async ({ express: express3, contexts, agents, config, tools, tracer
|
|
5762
|
+
create = async ({ express: express3, contexts, agents, config, tools, tracer }) => {
|
|
5799
5763
|
this.express = express3;
|
|
5800
5764
|
if (!this.server) {
|
|
5801
5765
|
console.log("[EXULU] Creating MCP server.");
|
|
@@ -6052,7 +6016,8 @@ var import_api4 = require("@opentelemetry/api");
|
|
|
6052
6016
|
var import_winston_transport = require("@opentelemetry/winston-transport");
|
|
6053
6017
|
var import_winston = __toESM(require("winston"), 1);
|
|
6054
6018
|
var createLogger = ({
|
|
6055
|
-
enableOtel
|
|
6019
|
+
enableOtel,
|
|
6020
|
+
transports
|
|
6056
6021
|
}) => {
|
|
6057
6022
|
const logger = import_winston.default.createLogger({
|
|
6058
6023
|
level: "debug",
|
|
@@ -6069,7 +6034,7 @@ var createLogger = ({
|
|
|
6069
6034
|
environment: process.env.NODE_ENV || "development"
|
|
6070
6035
|
},
|
|
6071
6036
|
transports: [
|
|
6072
|
-
|
|
6037
|
+
...transports,
|
|
6073
6038
|
...enableOtel ? [new import_winston_transport.OpenTelemetryTransportV3()] : []
|
|
6074
6039
|
]
|
|
6075
6040
|
});
|
|
@@ -6148,6 +6113,7 @@ var filesContext = new ExuluContext({
|
|
|
6148
6113
|
});
|
|
6149
6114
|
|
|
6150
6115
|
// src/registry/index.ts
|
|
6116
|
+
var import_winston2 = __toESM(require("winston"), 1);
|
|
6151
6117
|
var isValidPostgresName = (id) => {
|
|
6152
6118
|
const regex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
6153
6119
|
const isValid = regex.test(id);
|
|
@@ -6215,12 +6181,18 @@ var ExuluApp = class {
|
|
|
6215
6181
|
...contextsArray?.length ? contextsArray.map((context) => context.embedder?.queue?.name || null) : []
|
|
6216
6182
|
];
|
|
6217
6183
|
this._queues = [...new Set(queues2.filter((o) => !!o))];
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6184
|
+
console.log("[EXULU] App initialized.");
|
|
6185
|
+
return this;
|
|
6186
|
+
};
|
|
6187
|
+
express = {
|
|
6188
|
+
init: async () => {
|
|
6189
|
+
if (!this._expressApp) {
|
|
6190
|
+
this._expressApp = (0, import_express8.default)();
|
|
6191
|
+
await this.server.express.init();
|
|
6192
|
+
console.log("[EXULU] Express app initialized.");
|
|
6193
|
+
}
|
|
6194
|
+
return this._expressApp;
|
|
6222
6195
|
}
|
|
6223
|
-
return this._expressApp;
|
|
6224
6196
|
};
|
|
6225
6197
|
get expressApp() {
|
|
6226
6198
|
if (!this._expressApp) {
|
|
@@ -6281,14 +6253,19 @@ var ExuluApp = class {
|
|
|
6281
6253
|
if (this._config?.telemetry?.enabled) {
|
|
6282
6254
|
tracer = import_api4.trace.getTracer("exulu", "1.0.0");
|
|
6283
6255
|
}
|
|
6256
|
+
const transports = this._config?.workers?.logger?.winston?.transports ?? this._config?.logger?.winston?.transports ?? [new import_winston2.default.transports.Console()];
|
|
6284
6257
|
const logger = logger_default({
|
|
6285
|
-
enableOtel: this._config?.workers?.telemetry?.enabled ?? false
|
|
6258
|
+
enableOtel: this._config?.workers?.telemetry?.enabled ?? false,
|
|
6259
|
+
transports
|
|
6286
6260
|
});
|
|
6261
|
+
console.log = (...args) => logger.info(args.map(String).join(" "));
|
|
6262
|
+
console.info = (...args) => logger.info(args.map(String).join(" "));
|
|
6263
|
+
console.warn = (...args) => logger.warn(args.map(String).join(" "));
|
|
6264
|
+
console.error = (...args) => logger.error(args.map(String).join(" "));
|
|
6265
|
+
console.debug = (...args) => logger.debug(args.map(String).join(" "));
|
|
6287
6266
|
return await createWorkers(
|
|
6288
6267
|
this._queues,
|
|
6289
|
-
logger,
|
|
6290
6268
|
Object.values(this._contexts ?? {}),
|
|
6291
|
-
this._config?.workers?.logsDir,
|
|
6292
6269
|
tracer
|
|
6293
6270
|
);
|
|
6294
6271
|
}
|
|
@@ -6306,11 +6283,16 @@ var ExuluApp = class {
|
|
|
6306
6283
|
tracer = import_api4.trace.getTracer("exulu", "1.0.0");
|
|
6307
6284
|
}
|
|
6308
6285
|
const logger = logger_default({
|
|
6309
|
-
enableOtel: this._config?.telemetry?.enabled ?? false
|
|
6286
|
+
enableOtel: this._config?.telemetry?.enabled ?? false,
|
|
6287
|
+
transports: this._config?.logger?.winston?.transports ?? [new import_winston2.default.transports.Console()]
|
|
6310
6288
|
});
|
|
6289
|
+
console.log = (...args) => logger.info(args.map(String).join(" "));
|
|
6290
|
+
console.info = (...args) => logger.info(args.map(String).join(" "));
|
|
6291
|
+
console.warn = (...args) => logger.warn(args.map(String).join(" "));
|
|
6292
|
+
console.error = (...args) => logger.error(args.map(String).join(" "));
|
|
6293
|
+
console.debug = (...args) => logger.debug(args.map(String).join(" "));
|
|
6311
6294
|
await createExpressRoutes(
|
|
6312
6295
|
app,
|
|
6313
|
-
logger,
|
|
6314
6296
|
this._agents,
|
|
6315
6297
|
this._tools,
|
|
6316
6298
|
Object.values(this._contexts ?? {}),
|
|
@@ -6326,8 +6308,7 @@ var ExuluApp = class {
|
|
|
6326
6308
|
agents: this._agents,
|
|
6327
6309
|
config: this._config,
|
|
6328
6310
|
tools: this._tools,
|
|
6329
|
-
tracer
|
|
6330
|
-
logger
|
|
6311
|
+
tracer
|
|
6331
6312
|
});
|
|
6332
6313
|
await mcp.connect();
|
|
6333
6314
|
}
|
|
@@ -6596,7 +6577,7 @@ var RecursiveRules = class _RecursiveRules {
|
|
|
6596
6577
|
* @param {string} path - The path to the recipe.
|
|
6597
6578
|
* @returns {Promise<RecursiveRules>} The RecursiveRules object.
|
|
6598
6579
|
*/
|
|
6599
|
-
static async fromRecipe(name = "default", lang = "en",
|
|
6580
|
+
static async fromRecipe(name = "default", lang = "en", path) {
|
|
6600
6581
|
throw new Error("Not implemented");
|
|
6601
6582
|
}
|
|
6602
6583
|
};
|
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
|
@@ -7,7 +7,8 @@ import { createClient } from "redis";
|
|
|
7
7
|
// src/bullmq/server.ts
|
|
8
8
|
var redisServer = {
|
|
9
9
|
host: `${process.env.REDIS_HOST}`,
|
|
10
|
-
port: process.env.REDIS_PORT
|
|
10
|
+
port: process.env.REDIS_PORT,
|
|
11
|
+
password: process.env.REDIS_PASSWORD || void 0
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
// src/redis/client.ts
|
|
@@ -5136,7 +5137,7 @@ var createRecurringJobs = async () => {
|
|
|
5136
5137
|
);
|
|
5137
5138
|
return queue;
|
|
5138
5139
|
};
|
|
5139
|
-
var createExpressRoutes = async (app,
|
|
5140
|
+
var createExpressRoutes = async (app, agents, tools, contexts, config, tracer, filesContext2) => {
|
|
5140
5141
|
var corsOptions = {
|
|
5141
5142
|
origin: "*",
|
|
5142
5143
|
exposedHeaders: "*",
|
|
@@ -5189,8 +5190,8 @@ var createExpressRoutes = async (app, logger, agents, tools, contexts, config, t
|
|
|
5189
5190
|
express.json({ limit: REQUEST_SIZE_LIMIT }),
|
|
5190
5191
|
expressMiddleware(server, {
|
|
5191
5192
|
context: async ({ req }) => {
|
|
5192
|
-
|
|
5193
|
-
|
|
5193
|
+
console.info("================");
|
|
5194
|
+
console.info({
|
|
5194
5195
|
message: "Incoming Request",
|
|
5195
5196
|
method: req.method,
|
|
5196
5197
|
path: req.path,
|
|
@@ -5199,7 +5200,7 @@ var createExpressRoutes = async (app, logger, agents, tools, contexts, config, t
|
|
|
5199
5200
|
userAgent: req.get("User-Agent"),
|
|
5200
5201
|
headers: req.headers
|
|
5201
5202
|
});
|
|
5202
|
-
|
|
5203
|
+
console.info("================");
|
|
5203
5204
|
const authenticationResult = await requestValidators.authenticate(req);
|
|
5204
5205
|
if (!authenticationResult.user?.id) {
|
|
5205
5206
|
throw new Error(authenticationResult.message);
|
|
@@ -5466,10 +5467,10 @@ Mood: friendly and intelligent.
|
|
|
5466
5467
|
},
|
|
5467
5468
|
proxyReqPathResolver: (req) => {
|
|
5468
5469
|
const prefix = `/gateway/anthropic/${req.params.id}`;
|
|
5469
|
-
let
|
|
5470
|
-
if (!
|
|
5471
|
-
console.log("[EXULU] Provider path:",
|
|
5472
|
-
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;
|
|
5473
5474
|
},
|
|
5474
5475
|
proxyReqOptDecorator: function(proxyReqOpts, srcReq) {
|
|
5475
5476
|
return new Promise(async (resolve, reject) => {
|
|
@@ -5641,12 +5642,9 @@ var createCustomAnthropicStreamingMessage = (message) => {
|
|
|
5641
5642
|
// src/registry/workers.ts
|
|
5642
5643
|
import IORedis from "ioredis";
|
|
5643
5644
|
import { Worker } from "bullmq";
|
|
5644
|
-
import * as fs2 from "fs";
|
|
5645
|
-
import path from "path";
|
|
5646
5645
|
import "@opentelemetry/api";
|
|
5647
|
-
var defaultLogsDir = path.join(process.cwd(), "logs");
|
|
5648
5646
|
var redisConnection;
|
|
5649
|
-
var createWorkers = async (queues2,
|
|
5647
|
+
var createWorkers = async (queues2, contexts, tracer) => {
|
|
5650
5648
|
if (!redisServer.host || !redisServer.port) {
|
|
5651
5649
|
console.error("[EXULU] you are trying to start worker, but no redis server is configured in the environment.");
|
|
5652
5650
|
throw new Error("No redis server configured in the environment, so cannot start worker.");
|
|
@@ -5657,7 +5655,6 @@ var createWorkers = async (queues2, logger, contexts, _logsDir, tracer) => {
|
|
|
5657
5655
|
maxRetriesPerRequest: null
|
|
5658
5656
|
});
|
|
5659
5657
|
}
|
|
5660
|
-
const logsDir = _logsDir || defaultLogsDir;
|
|
5661
5658
|
const workers = queues2.map((queue) => {
|
|
5662
5659
|
console.log(`[EXULU] creating worker for queue ${queue}.`);
|
|
5663
5660
|
const worker = new Worker(
|
|
@@ -5710,41 +5707,8 @@ var createWorkers = async (queues2, logger, contexts, _logsDir, tracer) => {
|
|
|
5710
5707
|
});
|
|
5711
5708
|
return worker;
|
|
5712
5709
|
});
|
|
5713
|
-
const logsCleaner = createLogsCleanerWorker(logsDir);
|
|
5714
|
-
workers.push(logsCleaner);
|
|
5715
5710
|
return workers;
|
|
5716
5711
|
};
|
|
5717
|
-
var createLogsCleanerWorker = (logsDir) => {
|
|
5718
|
-
const logsCleaner = new Worker(
|
|
5719
|
-
global_queues.logs_cleaner,
|
|
5720
|
-
async (job) => {
|
|
5721
|
-
console.log(`[EXULU] recurring job ${job.id}.`);
|
|
5722
|
-
const folder = fs2.readdirSync(logsDir);
|
|
5723
|
-
const files = folder.filter((file) => file.endsWith(".log"));
|
|
5724
|
-
const now = /* @__PURE__ */ new Date();
|
|
5725
|
-
const daysToKeep = job.data.ttld;
|
|
5726
|
-
const dateToKeep = new Date(now.getTime() - daysToKeep * 24 * 60 * 60 * 1e3);
|
|
5727
|
-
files.forEach((file) => {
|
|
5728
|
-
const filePath = path.join(logsDir, file);
|
|
5729
|
-
const fileStats = fs2.statSync(filePath);
|
|
5730
|
-
if (fileStats.mtime < dateToKeep) {
|
|
5731
|
-
fs2.unlinkSync(filePath);
|
|
5732
|
-
}
|
|
5733
|
-
});
|
|
5734
|
-
},
|
|
5735
|
-
{ connection: redisConnection }
|
|
5736
|
-
);
|
|
5737
|
-
logsCleaner.on("completed", (job, returnvalue) => {
|
|
5738
|
-
console.log(`[EXULU] completed logs cleaner ${job.id}.`, returnvalue);
|
|
5739
|
-
});
|
|
5740
|
-
logsCleaner.on("failed", (job, error, prev) => {
|
|
5741
|
-
if (job?.id) {
|
|
5742
|
-
console.error(`[EXULU] failed logs cleaner ${job.id}.`);
|
|
5743
|
-
}
|
|
5744
|
-
console.error(`[EXULU] job error logs cleaner.`, error);
|
|
5745
|
-
});
|
|
5746
|
-
return logsCleaner;
|
|
5747
|
-
};
|
|
5748
5712
|
|
|
5749
5713
|
// src/mcp/index.ts
|
|
5750
5714
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -5761,7 +5725,7 @@ var ExuluMCP = class {
|
|
|
5761
5725
|
express;
|
|
5762
5726
|
constructor() {
|
|
5763
5727
|
}
|
|
5764
|
-
create = async ({ express: express3, contexts, agents, config, tools, tracer
|
|
5728
|
+
create = async ({ express: express3, contexts, agents, config, tools, tracer }) => {
|
|
5765
5729
|
this.express = express3;
|
|
5766
5730
|
if (!this.server) {
|
|
5767
5731
|
console.log("[EXULU] Creating MCP server.");
|
|
@@ -6018,7 +5982,8 @@ import { trace } from "@opentelemetry/api";
|
|
|
6018
5982
|
import { OpenTelemetryTransportV3 } from "@opentelemetry/winston-transport";
|
|
6019
5983
|
import winston from "winston";
|
|
6020
5984
|
var createLogger = ({
|
|
6021
|
-
enableOtel
|
|
5985
|
+
enableOtel,
|
|
5986
|
+
transports
|
|
6022
5987
|
}) => {
|
|
6023
5988
|
const logger = winston.createLogger({
|
|
6024
5989
|
level: "debug",
|
|
@@ -6035,7 +6000,7 @@ var createLogger = ({
|
|
|
6035
6000
|
environment: process.env.NODE_ENV || "development"
|
|
6036
6001
|
},
|
|
6037
6002
|
transports: [
|
|
6038
|
-
|
|
6003
|
+
...transports,
|
|
6039
6004
|
...enableOtel ? [new OpenTelemetryTransportV3()] : []
|
|
6040
6005
|
]
|
|
6041
6006
|
});
|
|
@@ -6114,6 +6079,7 @@ var filesContext = new ExuluContext({
|
|
|
6114
6079
|
});
|
|
6115
6080
|
|
|
6116
6081
|
// src/registry/index.ts
|
|
6082
|
+
import winston2 from "winston";
|
|
6117
6083
|
var isValidPostgresName = (id) => {
|
|
6118
6084
|
const regex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
6119
6085
|
const isValid = regex.test(id);
|
|
@@ -6181,12 +6147,18 @@ var ExuluApp = class {
|
|
|
6181
6147
|
...contextsArray?.length ? contextsArray.map((context) => context.embedder?.queue?.name || null) : []
|
|
6182
6148
|
];
|
|
6183
6149
|
this._queues = [...new Set(queues2.filter((o) => !!o))];
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6150
|
+
console.log("[EXULU] App initialized.");
|
|
6151
|
+
return this;
|
|
6152
|
+
};
|
|
6153
|
+
express = {
|
|
6154
|
+
init: async () => {
|
|
6155
|
+
if (!this._expressApp) {
|
|
6156
|
+
this._expressApp = express2();
|
|
6157
|
+
await this.server.express.init();
|
|
6158
|
+
console.log("[EXULU] Express app initialized.");
|
|
6159
|
+
}
|
|
6160
|
+
return this._expressApp;
|
|
6188
6161
|
}
|
|
6189
|
-
return this._expressApp;
|
|
6190
6162
|
};
|
|
6191
6163
|
get expressApp() {
|
|
6192
6164
|
if (!this._expressApp) {
|
|
@@ -6247,14 +6219,19 @@ var ExuluApp = class {
|
|
|
6247
6219
|
if (this._config?.telemetry?.enabled) {
|
|
6248
6220
|
tracer = trace.getTracer("exulu", "1.0.0");
|
|
6249
6221
|
}
|
|
6222
|
+
const transports = this._config?.workers?.logger?.winston?.transports ?? this._config?.logger?.winston?.transports ?? [new winston2.transports.Console()];
|
|
6250
6223
|
const logger = logger_default({
|
|
6251
|
-
enableOtel: this._config?.workers?.telemetry?.enabled ?? false
|
|
6224
|
+
enableOtel: this._config?.workers?.telemetry?.enabled ?? false,
|
|
6225
|
+
transports
|
|
6252
6226
|
});
|
|
6227
|
+
console.log = (...args) => logger.info(args.map(String).join(" "));
|
|
6228
|
+
console.info = (...args) => logger.info(args.map(String).join(" "));
|
|
6229
|
+
console.warn = (...args) => logger.warn(args.map(String).join(" "));
|
|
6230
|
+
console.error = (...args) => logger.error(args.map(String).join(" "));
|
|
6231
|
+
console.debug = (...args) => logger.debug(args.map(String).join(" "));
|
|
6253
6232
|
return await createWorkers(
|
|
6254
6233
|
this._queues,
|
|
6255
|
-
logger,
|
|
6256
6234
|
Object.values(this._contexts ?? {}),
|
|
6257
|
-
this._config?.workers?.logsDir,
|
|
6258
6235
|
tracer
|
|
6259
6236
|
);
|
|
6260
6237
|
}
|
|
@@ -6272,11 +6249,16 @@ var ExuluApp = class {
|
|
|
6272
6249
|
tracer = trace.getTracer("exulu", "1.0.0");
|
|
6273
6250
|
}
|
|
6274
6251
|
const logger = logger_default({
|
|
6275
|
-
enableOtel: this._config?.telemetry?.enabled ?? false
|
|
6252
|
+
enableOtel: this._config?.telemetry?.enabled ?? false,
|
|
6253
|
+
transports: this._config?.logger?.winston?.transports ?? [new winston2.transports.Console()]
|
|
6276
6254
|
});
|
|
6255
|
+
console.log = (...args) => logger.info(args.map(String).join(" "));
|
|
6256
|
+
console.info = (...args) => logger.info(args.map(String).join(" "));
|
|
6257
|
+
console.warn = (...args) => logger.warn(args.map(String).join(" "));
|
|
6258
|
+
console.error = (...args) => logger.error(args.map(String).join(" "));
|
|
6259
|
+
console.debug = (...args) => logger.debug(args.map(String).join(" "));
|
|
6277
6260
|
await createExpressRoutes(
|
|
6278
6261
|
app,
|
|
6279
|
-
logger,
|
|
6280
6262
|
this._agents,
|
|
6281
6263
|
this._tools,
|
|
6282
6264
|
Object.values(this._contexts ?? {}),
|
|
@@ -6292,8 +6274,7 @@ var ExuluApp = class {
|
|
|
6292
6274
|
agents: this._agents,
|
|
6293
6275
|
config: this._config,
|
|
6294
6276
|
tools: this._tools,
|
|
6295
|
-
tracer
|
|
6296
|
-
logger
|
|
6277
|
+
tracer
|
|
6297
6278
|
});
|
|
6298
6279
|
await mcp.connect();
|
|
6299
6280
|
}
|
|
@@ -6562,7 +6543,7 @@ var RecursiveRules = class _RecursiveRules {
|
|
|
6562
6543
|
* @param {string} path - The path to the recipe.
|
|
6563
6544
|
* @returns {Promise<RecursiveRules>} The RecursiveRules object.
|
|
6564
6545
|
*/
|
|
6565
|
-
static async fromRecipe(name = "default", lang = "en",
|
|
6546
|
+
static async fromRecipe(name = "default", lang = "en", path) {
|
|
6566
6547
|
throw new Error("Not implemented");
|
|
6567
6548
|
}
|
|
6568
6549
|
};
|