neuroalpha 0.5.14 → 0.5.15
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neuroalpha",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.15",
|
|
4
4
|
"description": "НейроАльфа — ИИ-автопилот для рынка акций Мосбиржи: эмбеддинги акций, самообучение правил, коннекторы Т-Банк / БКС / Финам / Алор и боты Telegram / MAX",
|
|
5
5
|
"author": "Roman A. Perepelkin",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import crypto from 'node:crypto';
|
|
8
8
|
import { db } from '../db.js';
|
|
9
9
|
import { getUserById, effectivePlan, ensureApiKey } from '../auth/index.js';
|
|
10
|
-
import { notifyUser, registerInstanceActionHandler } from '../notify/index.js';
|
|
10
|
+
import { notifyUser, registerInstanceActionHandler, registerInstanceChatRelay } from '../notify/index.js';
|
|
11
11
|
import { signToken, centralPublicKeyPem } from './signing.js';
|
|
12
12
|
import { PAAS_DRIVER, provisioningEnabled, provisionApply, provisionDelete } from './provision.js';
|
|
13
13
|
|
|
@@ -419,6 +419,7 @@ export function queueInstanceChatCommand(userId, text, channel = 'tg') {
|
|
|
419
419
|
const online = Boolean(inst.last_seen && Date.now() - inst.last_seen < 3 * 60000);
|
|
420
420
|
return { instanceId: inst.id, online };
|
|
421
421
|
}
|
|
422
|
+
registerInstanceChatRelay(queueInstanceChatCommand);
|
|
422
423
|
|
|
423
424
|
// Команды для машины: отдаются в каждой лицензии, пока машина не подтвердит выполнение (ack)
|
|
424
425
|
function pendingCommands(instId, acked = []) {
|
package/server/notify/index.js
CHANGED
|
@@ -5,9 +5,8 @@ import { TRUSTED_CA } from '../tls-ca.js';
|
|
|
5
5
|
import { IS_INSTANCE } from '../role.js';
|
|
6
6
|
import { getIdentity } from '../instance/identity.js';
|
|
7
7
|
import { relayNotifyToCentral } from '../instance/agent.js';
|
|
8
|
-
import { db, kvGet, kvSet } from '../db.js';
|
|
9
|
-
import { encryptSecret, decryptSecret, getUserById, runWithUser, generateApiKey, hashPassword, ensureApiKey, effectivePlan
|
|
10
|
-
import { queueInstanceChatCommand } from '../instance/central.js';
|
|
8
|
+
import { db, kvGet, kvSet, countUserChatToday } from '../db.js';
|
|
9
|
+
import { encryptSecret, decryptSecret, getUserById, runWithUser, generateApiKey, hashPassword, ensureApiKey, effectivePlan } from '../auth/index.js';
|
|
11
10
|
import { round } from '../util.js';
|
|
12
11
|
|
|
13
12
|
let actionHandlers = { execute: null, reject: null };
|
|
@@ -16,6 +15,9 @@ export function registerBrokerHandlers(h) { actionHandlers = h; }
|
|
|
16
15
|
let chatHandlers = { ask: null, resolve: null };
|
|
17
16
|
export function registerChatHandlers(h) { chatHandlers = h; }
|
|
18
17
|
|
|
18
|
+
let instanceChatRelay = null;
|
|
19
|
+
export function registerInstanceChatRelay(fn) { instanceChatRelay = fn; }
|
|
20
|
+
|
|
19
21
|
// Надёжный HTTP-клиент для platform-api2.max.ru (поддерживает сертификат НУЦ Минцифры РФ)
|
|
20
22
|
const maxCa = TRUSTED_CA;
|
|
21
23
|
|
|
@@ -270,8 +272,8 @@ async function handleMessengerChat(text, channel, chatId, sendFn) {
|
|
|
270
272
|
const hasLocalAccounts = Boolean(
|
|
271
273
|
db.prepare('SELECT 1 FROM broker_accounts WHERE user_id = ? LIMIT 1').get(u.id),
|
|
272
274
|
);
|
|
273
|
-
if (!hasLocalAccounts && u.role !== 'admin') {
|
|
274
|
-
const relayed =
|
|
275
|
+
if (!hasLocalAccounts && u.role !== 'admin' && instanceChatRelay) {
|
|
276
|
+
const relayed = instanceChatRelay(u.id, text, channel);
|
|
275
277
|
if (relayed) {
|
|
276
278
|
await sendFn(relayed.online
|
|
277
279
|
? '⏳ Запрос передан Стратегу на вашу машину — ответ придёт сюда через несколько секунд…'
|