wingbot 3.76.13 → 3.76.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/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const Plugins = require('./src/Plugins');
|
|
|
25
25
|
const NotificationsStorage = require('./src/notifications/NotificationsStorage');
|
|
26
26
|
const Notifications = require('./src/notifications/Notifications');
|
|
27
27
|
const MemoryBotConfigStorage = require('./src/tools/MemoryBotConfigStorage');
|
|
28
|
+
const MemoryChatLogStorage = require('./src/tools/MemoryChatLogStorage');
|
|
28
29
|
const routeToEvents = require('./src/tools/routeToEvents');
|
|
29
30
|
const GraphApi = require('./src/graphApi/GraphApi');
|
|
30
31
|
const validateBotApi = require('./src/graphApi/validateBotApi');
|
|
@@ -91,6 +92,7 @@ module.exports = {
|
|
|
91
92
|
bufferloader,
|
|
92
93
|
asserts,
|
|
93
94
|
MemoryStateStorage,
|
|
95
|
+
MemoryChatLogStorage,
|
|
94
96
|
CallbackAuditLog,
|
|
95
97
|
MemoryBotConfigStorage,
|
|
96
98
|
CachedModel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wingbot",
|
|
3
|
-
"version": "3.76.
|
|
3
|
+
"version": "3.76.15",
|
|
4
4
|
"description": "Enterprise Messaging Bot Conversation Engine",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"cpy-cli": "^5.0.0",
|
|
44
44
|
"eslint": "^8.56.0",
|
|
45
45
|
"eslint-config-airbnb": "^19.0.4",
|
|
46
|
-
"eslint-
|
|
46
|
+
"eslint-import-resolver-node": "^0.4.0",
|
|
47
|
+
"eslint-plugin-import": "^2.32.0",
|
|
47
48
|
"eslint-plugin-jsdoc": "^48.0.2",
|
|
48
49
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
49
50
|
"eslint-plugin-mocha": "^10.2.0",
|
|
@@ -69,11 +70,15 @@
|
|
|
69
70
|
"jsonwebtoken": "^9.0.2",
|
|
70
71
|
"node-fetch": "^2.6.7",
|
|
71
72
|
"path-to-regexp": "^6.3.0",
|
|
72
|
-
"uuid": "^
|
|
73
|
+
"uuid": "^14.0.2",
|
|
73
74
|
"webalize": "^0.1.0"
|
|
74
75
|
},
|
|
75
76
|
"optionalDependencies": {
|
|
76
77
|
"axios": "^1.6.4",
|
|
77
78
|
"handlebars": "^4.0.0"
|
|
79
|
+
},
|
|
80
|
+
"allowScripts": {
|
|
81
|
+
"fsevents@2.3.2": true,
|
|
82
|
+
"mongodb-memory-server@11.0.1": true
|
|
78
83
|
}
|
|
79
|
-
}
|
|
84
|
+
}
|
package/src/BuildRouter.js
CHANGED
|
@@ -206,6 +206,19 @@ const DUMMY_ROUTE = { id: 0, path: null, resolvers: [] };
|
|
|
206
206
|
* @prop {string|number} [resolverId] - only for text messages with random characters
|
|
207
207
|
*/
|
|
208
208
|
|
|
209
|
+
/**
|
|
210
|
+
* @typedef {object} Logger
|
|
211
|
+
* @prop {Function} log
|
|
212
|
+
* @prop {Function} error
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @typedef {object} RunningReq
|
|
217
|
+
* @prop {unknown[]} args
|
|
218
|
+
* @prop {Promise} promise
|
|
219
|
+
* @prop {number} started
|
|
220
|
+
*/
|
|
221
|
+
|
|
209
222
|
/**
|
|
210
223
|
* @template {BaseConfiguration} [C=object]
|
|
211
224
|
* @typedef {BotContextExtention & BuildRouterContext<C>} BotContext
|
|
@@ -300,10 +313,14 @@ class BuildRouter extends Router {
|
|
|
300
313
|
? context.then((c) => c.configStorage)
|
|
301
314
|
: context.configStorage;
|
|
302
315
|
|
|
316
|
+
/** @type {RunningReq[]} */
|
|
303
317
|
this._runningReqs = [];
|
|
304
318
|
|
|
305
319
|
this._configTs = 0;
|
|
306
320
|
|
|
321
|
+
/** @type {number} */
|
|
322
|
+
this.runningReqTimeout = 20000;
|
|
323
|
+
|
|
307
324
|
/**
|
|
308
325
|
* Timeout, when the router is not checking for new configuration
|
|
309
326
|
*
|
|
@@ -325,6 +342,20 @@ class BuildRouter extends Router {
|
|
|
325
342
|
}
|
|
326
343
|
}
|
|
327
344
|
|
|
345
|
+
/**
|
|
346
|
+
* @returns {Logger}
|
|
347
|
+
*/
|
|
348
|
+
get _logger () {
|
|
349
|
+
const logger = this._resolvedContext?.log
|
|
350
|
+
// @ts-ignore
|
|
351
|
+
|| this._resolvedContext?.configuration?.log;
|
|
352
|
+
|
|
353
|
+
if (typeof logger?.log === 'function') {
|
|
354
|
+
return logger;
|
|
355
|
+
}
|
|
356
|
+
return console;
|
|
357
|
+
}
|
|
358
|
+
|
|
328
359
|
get snapshot () {
|
|
329
360
|
return this._snapshot;
|
|
330
361
|
}
|
|
@@ -373,15 +404,35 @@ class BuildRouter extends Router {
|
|
|
373
404
|
await this.preload();
|
|
374
405
|
|
|
375
406
|
let runningRequest;
|
|
407
|
+
let timeout;
|
|
376
408
|
try {
|
|
377
409
|
const reducePromise = super.reduce(...args);
|
|
378
410
|
|
|
379
|
-
|
|
380
|
-
|
|
411
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
412
|
+
timeout = setTimeout(() => {
|
|
413
|
+
timeout = null;
|
|
414
|
+
this._logger.error('BuildRouter EXPIRE', { args });
|
|
415
|
+
this._runningReqs = this._runningReqs
|
|
416
|
+
.filter((rr) => rr !== runningRequest);
|
|
417
|
+
resolve();
|
|
418
|
+
}, this.runningReqTimeout);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
runningRequest = {
|
|
422
|
+
args,
|
|
423
|
+
promise: Promise.race([
|
|
424
|
+
reducePromise,
|
|
425
|
+
timeoutPromise
|
|
426
|
+
]).catch(() => { /* mute fails */ }),
|
|
427
|
+
started: Date.now()
|
|
428
|
+
};
|
|
381
429
|
this._runningReqs.push(runningRequest);
|
|
382
430
|
|
|
383
431
|
return await reducePromise;
|
|
384
432
|
} finally {
|
|
433
|
+
if (timeout) {
|
|
434
|
+
clearTimeout(timeout);
|
|
435
|
+
}
|
|
385
436
|
if (runningRequest) {
|
|
386
437
|
this._runningReqs = this._runningReqs
|
|
387
438
|
.filter((rr) => rr !== runningRequest);
|
|
@@ -471,7 +522,18 @@ class BuildRouter extends Router {
|
|
|
471
522
|
}
|
|
472
523
|
|
|
473
524
|
// wait for running request
|
|
474
|
-
|
|
525
|
+
const threshold = Date.now() - this.runningReqTimeout;
|
|
526
|
+
await Promise.all(
|
|
527
|
+
this._runningReqs
|
|
528
|
+
.filter((req) => {
|
|
529
|
+
if (req.started < threshold) {
|
|
530
|
+
this._logger.error('BuildRouter EXPIRE filter', req);
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
return true;
|
|
534
|
+
})
|
|
535
|
+
.map((req) => req.promise)
|
|
536
|
+
);
|
|
475
537
|
|
|
476
538
|
this.buildWithSnapshot(
|
|
477
539
|
snapshot.blocks,
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
const uuid = require('uuid');
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* @typedef {object} Tag
|
|
10
8
|
* @prop {string} tag
|
|
@@ -120,7 +118,7 @@ class NotificationsStorage {
|
|
|
120
118
|
* @param {object} tasks
|
|
121
119
|
* @returns {Promise<Task[]>}
|
|
122
120
|
*/
|
|
123
|
-
pushTasks (tasks) {
|
|
121
|
+
async pushTasks (tasks) {
|
|
124
122
|
|
|
125
123
|
// upsert through unique KEY (only single sliding campaign in queue)
|
|
126
124
|
// [campaignId,senderId,pageId,sent]
|
|
@@ -152,6 +150,9 @@ class NotificationsStorage {
|
|
|
152
150
|
return override;
|
|
153
151
|
});
|
|
154
152
|
|
|
153
|
+
// eslint-disable-next-line import/no-unresolved
|
|
154
|
+
const uuid = await import('uuid');
|
|
155
|
+
|
|
155
156
|
const insert = tasks.map((t) => ({
|
|
156
157
|
...t,
|
|
157
158
|
id: uuid.v4(),
|
|
@@ -162,7 +163,7 @@ class NotificationsStorage {
|
|
|
162
163
|
this._tasks.push(...insert);
|
|
163
164
|
|
|
164
165
|
this._tasks.sort((a, b) => a.enqueue - b.enqueue);
|
|
165
|
-
return
|
|
166
|
+
return ret;
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
popTasks (limit, until = Date.now()) {
|
|
@@ -306,6 +307,8 @@ class NotificationsStorage {
|
|
|
306
307
|
async upsertCampaign (campaign, updateCampaign = null) {
|
|
307
308
|
let insert = campaign;
|
|
308
309
|
if (!insert.id) {
|
|
310
|
+
// eslint-disable-next-line import/no-unresolved
|
|
311
|
+
const uuid = await import('uuid');
|
|
309
312
|
insert = { ...insert, id: uuid.v4() };
|
|
310
313
|
}
|
|
311
314
|
if (!this._campaigns.has(insert.id)) {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash(npx mocha:*)",
|
|
5
|
-
"Bash(npx tsc *)",
|
|
6
|
-
"Bash(npm test *)",
|
|
7
|
-
"Bash(node -e \"const p = require\\('./bot/plugins/BTMLLM'\\); console.log\\('factory type:', typeof p\\); console.log\\('factory name:', p.name\\);\")",
|
|
8
|
-
"Bash(grep -n \"prompt\\\\`\\\\|tagged\\\\|render\\\\|compile\\\\|hbs\" /Users/ondrejveres/Wingbot/wingbot-llm/src/prompt.js)"
|
|
9
|
-
]
|
|
10
|
-
}
|
|
11
|
-
}
|