omnikey-cli 1.5.8 → 1.6.0
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/backend-dist/__tests__/ai-client.nemotron.test.js +127 -0
- package/backend-dist/agent/agentPrompts.js +4 -3
- package/backend-dist/agent/utils.js +6 -5
- package/backend-dist/ai-client.js +151 -16
- package/backend-dist/config.js +16 -1
- package/backend-dist/db.js +5 -1
- package/backend-dist/mcpServerRoutes.js +16 -4
- package/backend-dist/scheduledJobRoutes.js +5 -2
- package/dist/index.js +1 -1
- package/dist/onboard.js +38 -0
- package/dist/telegramClient.js +1 -1
- package/dist/telegramDaemon.js +6 -4
- package/package.json +8 -6
- package/src/index.ts +1 -1
- package/src/onboard.ts +38 -0
- package/src/telegramClient.ts +1 -1
- package/src/telegramDaemon.ts +6 -8
- package/telegram-client-dist/{dist/agentClient.js → agentClient.js} +69 -75
- package/telegram-client-dist/{dist/config.js → config.js} +10 -12
- package/telegram-client-dist/{dist/index.js → index.js} +23 -23
- package/telegram-client-dist/{dist/notifyTelegram.js → notifyTelegram.js} +177 -191
- package/telegram-client-dist/{dist/omnikeyAuth.js → omnikeyAuth.js} +8 -13
|
@@ -12,10 +12,10 @@ const winston_1 = __importDefault(require("winston"));
|
|
|
12
12
|
const zod_1 = require("zod");
|
|
13
13
|
const notifyTelegram_1 = require("./notifyTelegram");
|
|
14
14
|
exports.logger = winston_1.default.createLogger({
|
|
15
|
-
level: process.env.LOG_LEVEL ||
|
|
15
|
+
level: process.env.LOG_LEVEL || 'info',
|
|
16
16
|
defaultMeta: { conId: (0, crypto_1.randomUUID)() },
|
|
17
17
|
format: winston_1.default.format.combine(winston_1.default.format.colorize(), winston_1.default.format.timestamp(), winston_1.default.format.printf(({ timestamp, level, message, ...meta }) => {
|
|
18
|
-
const metaString = Object.keys(meta).length ? JSON.stringify(meta) :
|
|
18
|
+
const metaString = Object.keys(meta).length ? JSON.stringify(meta) : '';
|
|
19
19
|
const date = new Date(timestamp).toLocaleString();
|
|
20
20
|
return `[${date}] ${level}: ${message} ${metaString}`;
|
|
21
21
|
})),
|
|
@@ -23,37 +23,37 @@ exports.logger = winston_1.default.createLogger({
|
|
|
23
23
|
});
|
|
24
24
|
const app = (0, express_1.default)();
|
|
25
25
|
const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 6666;
|
|
26
|
-
const botToken = process.env.TELEGRAM_BOT_TOKEN ??
|
|
26
|
+
const botToken = process.env.TELEGRAM_BOT_TOKEN ?? '';
|
|
27
27
|
if (botToken) {
|
|
28
28
|
try {
|
|
29
29
|
const bot = (0, notifyTelegram_1.initTelegram)(botToken);
|
|
30
|
-
exports.logger.info(
|
|
30
|
+
exports.logger.info('Telegram bot initialized', {
|
|
31
31
|
botTokenSet: !!botToken,
|
|
32
32
|
bot: !!bot,
|
|
33
33
|
});
|
|
34
34
|
(0, notifyTelegram_1.setupMessageListener)(exports.logger, bot);
|
|
35
35
|
}
|
|
36
36
|
catch (e) {
|
|
37
|
-
exports.logger.error(
|
|
37
|
+
exports.logger.error('Failed to init telegram:', e);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
app.use(express_1.default.json());
|
|
41
41
|
const sendBodySchema = zod_1.z.object({
|
|
42
|
-
message: zod_1.z.string().min(1,
|
|
43
|
-
parseMode: zod_1.z.enum([
|
|
42
|
+
message: zod_1.z.string().min(1, 'message must not be empty'),
|
|
43
|
+
parseMode: zod_1.z.enum(['Markdown', 'MarkdownV2', 'HTML']).optional(),
|
|
44
44
|
});
|
|
45
|
-
app.get(
|
|
46
|
-
res.send(
|
|
45
|
+
app.get('/', (req, res) => {
|
|
46
|
+
res.send('Telegram bot service (TypeScript)');
|
|
47
47
|
});
|
|
48
|
-
app.post(
|
|
49
|
-
exports.logger.defaultMeta = { conId:
|
|
48
|
+
app.post('/telegram/send', async (req, res) => {
|
|
49
|
+
exports.logger.defaultMeta = { conId: 'sending notification' };
|
|
50
50
|
const parsed = sendBodySchema.safeParse(req.body);
|
|
51
51
|
if (!parsed.success) {
|
|
52
|
-
exports.logger.warn(
|
|
52
|
+
exports.logger.warn('Invalid /telegram/send body', {
|
|
53
53
|
issues: parsed.error.issues,
|
|
54
54
|
});
|
|
55
55
|
return res.status(400).json({
|
|
56
|
-
message:
|
|
56
|
+
message: 'Invalid request body',
|
|
57
57
|
issues: parsed.error.issues,
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -61,16 +61,16 @@ app.post("/telegram/send", async (req, res) => {
|
|
|
61
61
|
try {
|
|
62
62
|
await (0, notifyTelegram_1.notify)(exports.logger, message, { parseMode });
|
|
63
63
|
return res.json({
|
|
64
|
-
message:
|
|
65
|
-
parseMode: parseMode ??
|
|
64
|
+
message: 'Message sent',
|
|
65
|
+
parseMode: parseMode ?? 'Markdown',
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
catch (e) {
|
|
69
|
-
exports.logger.error(
|
|
70
|
-
const description = e?.response?.body
|
|
71
|
-
|
|
69
|
+
exports.logger.error('Failed to send message:', e);
|
|
70
|
+
const description = e?.response?.body?.description ??
|
|
71
|
+
e.message;
|
|
72
72
|
return res.status(502).json({
|
|
73
|
-
message:
|
|
73
|
+
message: 'Failed to deliver message to Telegram',
|
|
74
74
|
error: description,
|
|
75
75
|
});
|
|
76
76
|
}
|
|
@@ -78,11 +78,11 @@ app.post("/telegram/send", async (req, res) => {
|
|
|
78
78
|
app.listen(port, () => {
|
|
79
79
|
exports.logger.info(`Server listening on http://localhost:${port}`);
|
|
80
80
|
});
|
|
81
|
-
process.on(
|
|
82
|
-
exports.logger.info(
|
|
81
|
+
process.on('SIGINT', () => {
|
|
82
|
+
exports.logger.info('Received SIGINT. Exiting...');
|
|
83
83
|
process.exit(0);
|
|
84
84
|
});
|
|
85
|
-
process.on(
|
|
86
|
-
exports.logger.info(
|
|
85
|
+
process.on('SIGTERM', () => {
|
|
86
|
+
exports.logger.info('Received SIGTERM. Exiting...');
|
|
87
87
|
process.exit(0);
|
|
88
88
|
});
|