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,12 +12,12 @@ let cachedExpiresAtMs = null;
|
|
|
12
12
|
// Renew JWTs a few minutes before expiry to avoid mid-WebSocket failures.
|
|
13
13
|
const RENEW_BEFORE_MS = 60 * 1000;
|
|
14
14
|
function decodeJwtExpiry(token) {
|
|
15
|
-
const parts = token.split(
|
|
15
|
+
const parts = token.split('.');
|
|
16
16
|
if (parts.length < 2)
|
|
17
17
|
return null;
|
|
18
18
|
try {
|
|
19
|
-
const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g,
|
|
20
|
-
return typeof payload.exp ===
|
|
19
|
+
const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString('utf8'));
|
|
20
|
+
return typeof payload.exp === 'number' ? payload.exp * 1000 : null;
|
|
21
21
|
}
|
|
22
22
|
catch {
|
|
23
23
|
return null;
|
|
@@ -25,25 +25,20 @@ function decodeJwtExpiry(token) {
|
|
|
25
25
|
}
|
|
26
26
|
async function fetchJwtToken(logger, force = false) {
|
|
27
27
|
const now = Date.now();
|
|
28
|
-
if (!force &&
|
|
29
|
-
cachedToken &&
|
|
30
|
-
cachedExpiresAtMs &&
|
|
31
|
-
cachedExpiresAtMs - RENEW_BEFORE_MS > now) {
|
|
28
|
+
if (!force && cachedToken && cachedExpiresAtMs && cachedExpiresAtMs - RENEW_BEFORE_MS > now) {
|
|
32
29
|
return cachedToken;
|
|
33
30
|
}
|
|
34
31
|
const url = `${(0, config_1.omnikeyBaseUrl)()}/api/subscription/activate`;
|
|
35
|
-
logger.info(
|
|
32
|
+
logger.info('Requesting JWT from omnikey-ai', { url });
|
|
36
33
|
const resp = await axios_1.default.post(url, {}, { timeout: 10000 });
|
|
37
34
|
if (!resp.data?.token) {
|
|
38
|
-
throw new Error(
|
|
35
|
+
throw new Error('activate endpoint returned no token');
|
|
39
36
|
}
|
|
40
37
|
cachedToken = resp.data.token;
|
|
41
38
|
cachedExpiresAtMs = decodeJwtExpiry(cachedToken);
|
|
42
|
-
logger.info(
|
|
39
|
+
logger.info('Received JWT from omnikey-ai', {
|
|
43
40
|
subscriptionStatus: resp.data.subscriptionStatus,
|
|
44
|
-
expiresAt: cachedExpiresAtMs
|
|
45
|
-
? new Date(cachedExpiresAtMs).toISOString()
|
|
46
|
-
: null,
|
|
41
|
+
expiresAt: cachedExpiresAtMs ? new Date(cachedExpiresAtMs).toISOString() : null,
|
|
47
42
|
});
|
|
48
43
|
return cachedToken;
|
|
49
44
|
}
|