omnikey-cli 1.5.7 → 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} +91 -75
- package/telegram-client-dist/{dist/config.js → config.js} +10 -12
- package/telegram-client-dist/{dist/index.js → index.js} +23 -32
- package/telegram-client-dist/{dist/notifyTelegram.js → notifyTelegram.js} +193 -194
- package/telegram-client-dist/{dist/omnikeyAuth.js → omnikeyAuth.js} +8 -13
- package/telegram-client-dist/dist/db.js +0 -78
|
@@ -11,12 +11,11 @@ const crypto_1 = require("crypto");
|
|
|
11
11
|
const winston_1 = __importDefault(require("winston"));
|
|
12
12
|
const zod_1 = require("zod");
|
|
13
13
|
const notifyTelegram_1 = require("./notifyTelegram");
|
|
14
|
-
const db_1 = require("./db");
|
|
15
14
|
exports.logger = winston_1.default.createLogger({
|
|
16
|
-
level: process.env.LOG_LEVEL ||
|
|
15
|
+
level: process.env.LOG_LEVEL || 'info',
|
|
17
16
|
defaultMeta: { conId: (0, crypto_1.randomUUID)() },
|
|
18
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 }) => {
|
|
19
|
-
const metaString = Object.keys(meta).length ? JSON.stringify(meta) :
|
|
18
|
+
const metaString = Object.keys(meta).length ? JSON.stringify(meta) : '';
|
|
20
19
|
const date = new Date(timestamp).toLocaleString();
|
|
21
20
|
return `[${date}] ${level}: ${message} ${metaString}`;
|
|
22
21
|
})),
|
|
@@ -24,43 +23,37 @@ exports.logger = winston_1.default.createLogger({
|
|
|
24
23
|
});
|
|
25
24
|
const app = (0, express_1.default)();
|
|
26
25
|
const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 6666;
|
|
27
|
-
|
|
28
|
-
(0, db_1.initDb)(exports.logger);
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
exports.logger.error("Failed to open omnikey SQLite database:", e);
|
|
32
|
-
}
|
|
33
|
-
const botToken = process.env.TELEGRAM_BOT_TOKEN ?? "";
|
|
26
|
+
const botToken = process.env.TELEGRAM_BOT_TOKEN ?? '';
|
|
34
27
|
if (botToken) {
|
|
35
28
|
try {
|
|
36
29
|
const bot = (0, notifyTelegram_1.initTelegram)(botToken);
|
|
37
|
-
exports.logger.info(
|
|
30
|
+
exports.logger.info('Telegram bot initialized', {
|
|
38
31
|
botTokenSet: !!botToken,
|
|
39
32
|
bot: !!bot,
|
|
40
33
|
});
|
|
41
34
|
(0, notifyTelegram_1.setupMessageListener)(exports.logger, bot);
|
|
42
35
|
}
|
|
43
36
|
catch (e) {
|
|
44
|
-
exports.logger.error(
|
|
37
|
+
exports.logger.error('Failed to init telegram:', e);
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
40
|
app.use(express_1.default.json());
|
|
48
41
|
const sendBodySchema = zod_1.z.object({
|
|
49
|
-
message: zod_1.z.string().min(1,
|
|
50
|
-
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(),
|
|
51
44
|
});
|
|
52
|
-
app.get(
|
|
53
|
-
res.send(
|
|
45
|
+
app.get('/', (req, res) => {
|
|
46
|
+
res.send('Telegram bot service (TypeScript)');
|
|
54
47
|
});
|
|
55
|
-
app.post(
|
|
56
|
-
exports.logger.defaultMeta = { conId:
|
|
48
|
+
app.post('/telegram/send', async (req, res) => {
|
|
49
|
+
exports.logger.defaultMeta = { conId: 'sending notification' };
|
|
57
50
|
const parsed = sendBodySchema.safeParse(req.body);
|
|
58
51
|
if (!parsed.success) {
|
|
59
|
-
exports.logger.warn(
|
|
52
|
+
exports.logger.warn('Invalid /telegram/send body', {
|
|
60
53
|
issues: parsed.error.issues,
|
|
61
54
|
});
|
|
62
55
|
return res.status(400).json({
|
|
63
|
-
message:
|
|
56
|
+
message: 'Invalid request body',
|
|
64
57
|
issues: parsed.error.issues,
|
|
65
58
|
});
|
|
66
59
|
}
|
|
@@ -68,16 +61,16 @@ app.post("/telegram/send", async (req, res) => {
|
|
|
68
61
|
try {
|
|
69
62
|
await (0, notifyTelegram_1.notify)(exports.logger, message, { parseMode });
|
|
70
63
|
return res.json({
|
|
71
|
-
message:
|
|
72
|
-
parseMode: parseMode ??
|
|
64
|
+
message: 'Message sent',
|
|
65
|
+
parseMode: parseMode ?? 'Markdown',
|
|
73
66
|
});
|
|
74
67
|
}
|
|
75
68
|
catch (e) {
|
|
76
|
-
exports.logger.error(
|
|
77
|
-
const description = e?.response?.body
|
|
78
|
-
|
|
69
|
+
exports.logger.error('Failed to send message:', e);
|
|
70
|
+
const description = e?.response?.body?.description ??
|
|
71
|
+
e.message;
|
|
79
72
|
return res.status(502).json({
|
|
80
|
-
message:
|
|
73
|
+
message: 'Failed to deliver message to Telegram',
|
|
81
74
|
error: description,
|
|
82
75
|
});
|
|
83
76
|
}
|
|
@@ -85,13 +78,11 @@ app.post("/telegram/send", async (req, res) => {
|
|
|
85
78
|
app.listen(port, () => {
|
|
86
79
|
exports.logger.info(`Server listening on http://localhost:${port}`);
|
|
87
80
|
});
|
|
88
|
-
process.on(
|
|
89
|
-
exports.logger.info(
|
|
90
|
-
(0, db_1.closeDb)(exports.logger);
|
|
81
|
+
process.on('SIGINT', () => {
|
|
82
|
+
exports.logger.info('Received SIGINT. Exiting...');
|
|
91
83
|
process.exit(0);
|
|
92
84
|
});
|
|
93
|
-
process.on(
|
|
94
|
-
exports.logger.info(
|
|
95
|
-
(0, db_1.closeDb)(exports.logger);
|
|
85
|
+
process.on('SIGTERM', () => {
|
|
86
|
+
exports.logger.info('Received SIGTERM. Exiting...');
|
|
96
87
|
process.exit(0);
|
|
97
88
|
});
|