@exulu/backend 1.25.3 → 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 +42 -62
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +42 -62
- 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
|
@@ -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,7 @@ var filesContext = new ExuluContext({
|
|
|
6149
6113
|
});
|
|
6150
6114
|
|
|
6151
6115
|
// src/registry/index.ts
|
|
6116
|
+
var import_winston2 = __toESM(require("winston"), 1);
|
|
6152
6117
|
var isValidPostgresName = (id) => {
|
|
6153
6118
|
const regex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
6154
6119
|
const isValid = regex.test(id);
|
|
@@ -6216,12 +6181,18 @@ var ExuluApp = class {
|
|
|
6216
6181
|
...contextsArray?.length ? contextsArray.map((context) => context.embedder?.queue?.name || null) : []
|
|
6217
6182
|
];
|
|
6218
6183
|
this._queues = [...new Set(queues2.filter((o) => !!o))];
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
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;
|
|
6223
6195
|
}
|
|
6224
|
-
return this._expressApp;
|
|
6225
6196
|
};
|
|
6226
6197
|
get expressApp() {
|
|
6227
6198
|
if (!this._expressApp) {
|
|
@@ -6282,14 +6253,19 @@ var ExuluApp = class {
|
|
|
6282
6253
|
if (this._config?.telemetry?.enabled) {
|
|
6283
6254
|
tracer = import_api4.trace.getTracer("exulu", "1.0.0");
|
|
6284
6255
|
}
|
|
6256
|
+
const transports = this._config?.workers?.logger?.winston?.transports ?? this._config?.logger?.winston?.transports ?? [new import_winston2.default.transports.Console()];
|
|
6285
6257
|
const logger = logger_default({
|
|
6286
|
-
enableOtel: this._config?.workers?.telemetry?.enabled ?? false
|
|
6258
|
+
enableOtel: this._config?.workers?.telemetry?.enabled ?? false,
|
|
6259
|
+
transports
|
|
6287
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(" "));
|
|
6288
6266
|
return await createWorkers(
|
|
6289
6267
|
this._queues,
|
|
6290
|
-
logger,
|
|
6291
6268
|
Object.values(this._contexts ?? {}),
|
|
6292
|
-
this._config?.workers?.logsDir,
|
|
6293
6269
|
tracer
|
|
6294
6270
|
);
|
|
6295
6271
|
}
|
|
@@ -6307,11 +6283,16 @@ var ExuluApp = class {
|
|
|
6307
6283
|
tracer = import_api4.trace.getTracer("exulu", "1.0.0");
|
|
6308
6284
|
}
|
|
6309
6285
|
const logger = logger_default({
|
|
6310
|
-
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()]
|
|
6311
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(" "));
|
|
6312
6294
|
await createExpressRoutes(
|
|
6313
6295
|
app,
|
|
6314
|
-
logger,
|
|
6315
6296
|
this._agents,
|
|
6316
6297
|
this._tools,
|
|
6317
6298
|
Object.values(this._contexts ?? {}),
|
|
@@ -6327,8 +6308,7 @@ var ExuluApp = class {
|
|
|
6327
6308
|
agents: this._agents,
|
|
6328
6309
|
config: this._config,
|
|
6329
6310
|
tools: this._tools,
|
|
6330
|
-
tracer
|
|
6331
|
-
logger
|
|
6311
|
+
tracer
|
|
6332
6312
|
});
|
|
6333
6313
|
await mcp.connect();
|
|
6334
6314
|
}
|
|
@@ -6597,7 +6577,7 @@ var RecursiveRules = class _RecursiveRules {
|
|
|
6597
6577
|
* @param {string} path - The path to the recipe.
|
|
6598
6578
|
* @returns {Promise<RecursiveRules>} The RecursiveRules object.
|
|
6599
6579
|
*/
|
|
6600
|
-
static async fromRecipe(name = "default", lang = "en",
|
|
6580
|
+
static async fromRecipe(name = "default", lang = "en", path) {
|
|
6601
6581
|
throw new Error("Not implemented");
|
|
6602
6582
|
}
|
|
6603
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
|
@@ -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,7 @@ var filesContext = new ExuluContext({
|
|
|
6115
6079
|
});
|
|
6116
6080
|
|
|
6117
6081
|
// src/registry/index.ts
|
|
6082
|
+
import winston2 from "winston";
|
|
6118
6083
|
var isValidPostgresName = (id) => {
|
|
6119
6084
|
const regex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
6120
6085
|
const isValid = regex.test(id);
|
|
@@ -6182,12 +6147,18 @@ var ExuluApp = class {
|
|
|
6182
6147
|
...contextsArray?.length ? contextsArray.map((context) => context.embedder?.queue?.name || null) : []
|
|
6183
6148
|
];
|
|
6184
6149
|
this._queues = [...new Set(queues2.filter((o) => !!o))];
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
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;
|
|
6189
6161
|
}
|
|
6190
|
-
return this._expressApp;
|
|
6191
6162
|
};
|
|
6192
6163
|
get expressApp() {
|
|
6193
6164
|
if (!this._expressApp) {
|
|
@@ -6248,14 +6219,19 @@ var ExuluApp = class {
|
|
|
6248
6219
|
if (this._config?.telemetry?.enabled) {
|
|
6249
6220
|
tracer = trace.getTracer("exulu", "1.0.0");
|
|
6250
6221
|
}
|
|
6222
|
+
const transports = this._config?.workers?.logger?.winston?.transports ?? this._config?.logger?.winston?.transports ?? [new winston2.transports.Console()];
|
|
6251
6223
|
const logger = logger_default({
|
|
6252
|
-
enableOtel: this._config?.workers?.telemetry?.enabled ?? false
|
|
6224
|
+
enableOtel: this._config?.workers?.telemetry?.enabled ?? false,
|
|
6225
|
+
transports
|
|
6253
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(" "));
|
|
6254
6232
|
return await createWorkers(
|
|
6255
6233
|
this._queues,
|
|
6256
|
-
logger,
|
|
6257
6234
|
Object.values(this._contexts ?? {}),
|
|
6258
|
-
this._config?.workers?.logsDir,
|
|
6259
6235
|
tracer
|
|
6260
6236
|
);
|
|
6261
6237
|
}
|
|
@@ -6273,11 +6249,16 @@ var ExuluApp = class {
|
|
|
6273
6249
|
tracer = trace.getTracer("exulu", "1.0.0");
|
|
6274
6250
|
}
|
|
6275
6251
|
const logger = logger_default({
|
|
6276
|
-
enableOtel: this._config?.telemetry?.enabled ?? false
|
|
6252
|
+
enableOtel: this._config?.telemetry?.enabled ?? false,
|
|
6253
|
+
transports: this._config?.logger?.winston?.transports ?? [new winston2.transports.Console()]
|
|
6277
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(" "));
|
|
6278
6260
|
await createExpressRoutes(
|
|
6279
6261
|
app,
|
|
6280
|
-
logger,
|
|
6281
6262
|
this._agents,
|
|
6282
6263
|
this._tools,
|
|
6283
6264
|
Object.values(this._contexts ?? {}),
|
|
@@ -6293,8 +6274,7 @@ var ExuluApp = class {
|
|
|
6293
6274
|
agents: this._agents,
|
|
6294
6275
|
config: this._config,
|
|
6295
6276
|
tools: this._tools,
|
|
6296
|
-
tracer
|
|
6297
|
-
logger
|
|
6277
|
+
tracer
|
|
6298
6278
|
});
|
|
6299
6279
|
await mcp.connect();
|
|
6300
6280
|
}
|
|
@@ -6563,7 +6543,7 @@ var RecursiveRules = class _RecursiveRules {
|
|
|
6563
6543
|
* @param {string} path - The path to the recipe.
|
|
6564
6544
|
* @returns {Promise<RecursiveRules>} The RecursiveRules object.
|
|
6565
6545
|
*/
|
|
6566
|
-
static async fromRecipe(name = "default", lang = "en",
|
|
6546
|
+
static async fromRecipe(name = "default", lang = "en", path) {
|
|
6567
6547
|
throw new Error("Not implemented");
|
|
6568
6548
|
}
|
|
6569
6549
|
};
|