@tiledesk/tiledesk-server 3.0.1 → 3.2.1
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/.circleci/config.yml +1 -1
- package/CHANGELOG.md +47 -0
- package/Dockerfile +3 -2
- package/Dockerfile-en +3 -2
- package/Dockerfile-jobs +3 -2
- package/Dockerfile-profiler +3 -2
- package/README.md +15 -0
- package/app.js +12 -1
- package/bin/quota-reset +68 -0
- package/bin/quota-restore +86 -0
- package/channels/chat21/chat21Handler.js +50 -34
- package/channels/chat21/chat21JoinTracker.js +43 -0
- package/config/database.js +5 -5
- package/config/native_mcp/native_mcp_servers.json +1 -0
- package/controllers/chatbot.controller.js +80 -27
- package/controllers/intents.controller.js +42 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-chat21-ionic.md +468 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-design-studio.md +1349 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-server.md +1694 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-tybot.md +789 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-server.md +83 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-tybot.md +76 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-chat21-ionic.md +97 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-design-studio.md +72 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-server.md +223 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-tybot.md +121 -0
- package/docs/superpowers/plans/2026-09-29-hitl-pre-branch-ports.md +65 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-design-studio.md +88 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-server.md +103 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-tybot.md +43 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-design-studio.md +80 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-runtime.md +39 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-server.md +106 -0
- package/docs/superpowers/specs/2026-09-15-webhook-chatbot-hitl-design.md +715 -0
- package/docs/superpowers/specs/2026-09-30-flow-start-points-design.md +156 -0
- package/docs/superpowers/specs/2026-10-01-scheduled-start-point-design.md +303 -0
- package/docs/superpowers/todo/2026-09-14-webhook-chatbot-shared-code-fixes.md +191 -0
- package/event/botEvent.js +12 -1
- package/event/emailEvent.js +3 -0
- package/event/messageEvent.js +44 -0
- package/jobs.js +10 -0
- package/jobsManager.js +19 -0
- package/middleware/errorHandler.js +6 -2
- package/models/analyticResult.js +1 -1
- package/models/channelConstants.js +3 -2
- package/models/dataTable.js +16 -0
- package/models/location.js +6 -12
- package/models/quotaUsage.js +71 -0
- package/models/request.js +71 -61
- package/models/requestSnapshot.js +12 -0
- package/models/routerLogger.js +1 -1
- package/models/webhook.js +44 -0
- package/package.json +9 -7
- package/pubmodules/emailNotification/requestNotification.js +14 -22
- package/pubmodules/events/test/eventRoute.js +7 -6
- package/pubmodules/rules/conciergeBot.js +9 -4
- package/routes/auth.js +1 -12
- package/routes/campaigns.js +0 -13
- package/routes/dataTable.js +23 -3
- package/routes/faq_kb.js +12 -1
- package/routes/messagesRoot.js +0 -1
- package/routes/quotes.js +38 -1
- package/routes/request.js +81 -5
- package/routes/users.js +0 -1
- package/routes/webhook.js +160 -8
- package/routes/webhooks.js +276 -6
- package/routes/widgetLoader.js +6 -3
- package/services/QuoteManager.js +77 -16
- package/services/aiService.js +1 -1
- package/services/chatbotService.js +55 -1
- package/services/dataTableService.js +436 -42
- package/services/departmentService.js +60 -43
- package/services/dolphinSchedulerClient.js +116 -0
- package/services/emailService.js +6 -1
- package/services/hitlParticipantListener.js +260 -0
- package/services/participantInviteService.js +302 -0
- package/services/participantRemoveService.js +79 -0
- package/services/quotaSnapshotService.js +1167 -0
- package/services/requestService.js +102 -144
- package/services/scheduledStart/dolphinBackend.js +246 -0
- package/services/scheduledStart/schedulerBackend.js +101 -0
- package/services/scheduledStart/schedulerServiceClient.js +41 -0
- package/services/scheduledStartPublishListener.js +186 -0
- package/services/scheduledStartRules.js +173 -0
- package/services/scheduledStartService.js +130 -0
- package/services/startPointCleanupListener.js +30 -0
- package/services/startPointService.js +158 -0
- package/services/testWsService.js +1 -4
- package/services/updateRequestSnapshotQueued.js +8 -9
- package/services/webhookConversationService.js +185 -0
- package/services/webhookSettingsValidator.js +61 -0
- package/template/email/checkpointReachedEmail.html +5 -0
- package/test/agentPromptsRoute.test.js +3 -2
- package/test/agentTokensQuota.js +237 -0
- package/test/botEventHitlFallback.js +19 -0
- package/test/chat21HandlerJoinWiring.js +59 -0
- package/test/dataTablesRoute.test.js +649 -2
- package/test/dateUtils.test.js +0 -3
- package/test/departmentService.js +8 -12
- package/test/{fileRoute.js → deprecated/_deprecated_fileRoute} +2 -2
- package/test/{kbsettingsRoute.js → deprecated/_deprecated_kbsettingsRoute} +3 -3
- package/test/faqRoute.js +6 -1
- package/test/faqkbRoute.js +14 -10
- package/test/faqkbV3Route.js +1 -1
- package/test/filepRoute.js +4 -50
- package/test/hitlParticipantListener.js +446 -0
- package/test/hitlQueueWiring.js +191 -0
- package/test/hitlWaitingReset.js +124 -0
- package/test/inviteParticipantsRoute.js +492 -0
- package/test/kbRoute.js +1 -1
- package/test/messageRoute.js +33 -21
- package/test/nativemcp.test.js +7 -1
- package/test/openaiRoute.js +2 -8
- package/test/publishFailLoud.test.js +414 -0
- package/test/quotaSnapshots.js +1044 -0
- package/test/removeParticipantsRoute.js +186 -0
- package/test/requestService.js +24 -16
- package/test/requestServiceRemoveParticipant.js +144 -0
- package/test/requestVisibility.test.js +186 -0
- package/test/scheduledStartFacade.js +184 -0
- package/test/scheduledStartHandover.js +95 -0
- package/test/scheduledStartPublish.js +320 -0
- package/test/scheduledStartRoute.js +163 -0
- package/test/scheduledStartRules.js +177 -0
- package/test/scheduledStartRun.js +299 -0
- package/test/scheduledStartSchedulerBackend.js +116 -0
- package/test/scheduledStartService.js +290 -0
- package/test/startPointsCleanup.js +69 -0
- package/test/startPointsRegression.js +169 -0
- package/test/startPointsRoute.js +158 -0
- package/test/webhookConversationRoute.js +347 -0
- package/test/webhookConversationService.js +261 -0
- package/test/webhookConversationTestUtils.js +55 -0
- package/utils/aiUtils.js +95 -1
- package/utils/dataTableUtils.js +99 -9
- package/utils/intentFieldNames.js +192 -0
- package/utils/quotaCliUtil.js +43 -0
- package/utils/requestVisibility.js +355 -0
- package/websocket/webSocketServer.js +36 -31
- /package/test/{imageRoute.js → deprecated/_deprecated_imageRoute} +0 -0
|
@@ -7,7 +7,6 @@ var Request = require("../models/request");
|
|
|
7
7
|
var Message = require("../models/message");
|
|
8
8
|
var Faq_kb = require("../models/faq_kb");
|
|
9
9
|
const WebSocket = require('ws');
|
|
10
|
-
var url = require('url');
|
|
11
10
|
var validtoken = require('../middleware/valid-token');
|
|
12
11
|
var messageEvent = require("../event/messageEvent");
|
|
13
12
|
var eventEvent = require("../pubmodules/events/eventEvent");
|
|
@@ -25,6 +24,7 @@ var mongoose = require('mongoose');
|
|
|
25
24
|
const requestConstants = require("../models/requestConstants");
|
|
26
25
|
var RoleConstants = require('../models/roleConstants');
|
|
27
26
|
var projectUserService = require("../services/projectUserService");
|
|
27
|
+
var requestVisibility = require("../utils/requestVisibility");
|
|
28
28
|
|
|
29
29
|
let configSecretOrPubicKay = process.env.GLOBAL_SECRET || config.secret;
|
|
30
30
|
|
|
@@ -102,9 +102,12 @@ class WebSocketServer {
|
|
|
102
102
|
verifyClient: function (info, cb) {
|
|
103
103
|
//console.log('info.req', info.req);
|
|
104
104
|
// var token = info.req.headers.Authorization
|
|
105
|
-
let
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
let queryParameter;
|
|
106
|
+
try {
|
|
107
|
+
queryParameter = Object.fromEntries(new URL(info.req.url, 'http://localhost').searchParams);
|
|
108
|
+
} catch (err) {
|
|
109
|
+
return cb(false, 401, 'Unauthorized');
|
|
110
|
+
}
|
|
108
111
|
winston.debug('queryParameter', queryParameter);
|
|
109
112
|
|
|
110
113
|
var token = queryParameter.token;
|
|
@@ -276,7 +279,7 @@ class WebSocketServer {
|
|
|
276
279
|
winston.debug('queryRequest admin: ' + JSON.stringify(queryRequest));
|
|
277
280
|
}
|
|
278
281
|
else if (projectuser.hasPermissionOrRole('request_read_group', ["agent"])) {
|
|
279
|
-
queryRequest["$or"] =
|
|
282
|
+
queryRequest["$or"] = requestVisibility.visibilityOr(req.user.id, projectuser.createdAt)
|
|
280
283
|
} else {
|
|
281
284
|
winston.debug('queryRequest agent: ' + JSON.stringify(queryRequest));
|
|
282
285
|
queryRequest["participants"] = req.user.id;
|
|
@@ -358,7 +361,7 @@ class WebSocketServer {
|
|
|
358
361
|
if (projectuser.hasPermissionOrRole('request_read_all', ["owner", "admin"])) {
|
|
359
362
|
winston.debug('ws requests query admin: ' + JSON.stringify(query));
|
|
360
363
|
} else if (projectuser.hasPermissionOrRole('request_read_group', ["agent"])) {
|
|
361
|
-
query["$or"] =
|
|
364
|
+
query["$or"] = requestVisibility.visibilityOr(req.user.id, projectuser.createdAt);
|
|
362
365
|
winston.debug('ws requests query agent: ' + JSON.stringify(query));
|
|
363
366
|
} else {
|
|
364
367
|
query["participants"] = req.user.id;
|
|
@@ -416,12 +419,11 @@ class WebSocketServer {
|
|
|
416
419
|
}
|
|
417
420
|
|
|
418
421
|
// attento qui
|
|
419
|
-
if (request.snapshot
|
|
420
|
-
var
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
request.snapshot.agents = agentsnew;
|
|
422
|
+
if (request.snapshot) {
|
|
423
|
+
var agentsForClient = requestVisibility.agentsForClient(request.snapshot);
|
|
424
|
+
if (agentsForClient) {
|
|
425
|
+
request.snapshot.agents = agentsForClient;
|
|
426
|
+
}
|
|
425
427
|
}
|
|
426
428
|
|
|
427
429
|
|
|
@@ -660,7 +662,7 @@ class WebSocketServer {
|
|
|
660
662
|
winston.debug('query admin: ' + JSON.stringify(query));
|
|
661
663
|
} else if (projectuser.hasPermissionOrRole('request_read_group', ["agent"])) {
|
|
662
664
|
|
|
663
|
-
query["$or"] =
|
|
665
|
+
query["$or"] = requestVisibility.visibilityOr(req.user.id, projectuser.createdAt)
|
|
664
666
|
|
|
665
667
|
}
|
|
666
668
|
// else if (projectuser.hasPermissionOrRole('request_read_mine', ["????"])) {
|
|
@@ -773,13 +775,16 @@ class WebSocketServer {
|
|
|
773
775
|
winston.debug('snapshotAgents', snapshotAgents);
|
|
774
776
|
// requestJSON.snapshot.agents = snapshotAgents;
|
|
775
777
|
|
|
776
|
-
if (snapshotAgents
|
|
777
|
-
var
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
|
|
778
|
+
if (snapshotAgents && snapshotAgents.snapshot) {
|
|
779
|
+
var agentsForClient = requestVisibility.agentsForClient(snapshotAgents.snapshot);
|
|
780
|
+
if (agentsForClient) {
|
|
781
|
+
requestJSON.snapshot.agents = agentsForClient;
|
|
782
|
+
}
|
|
783
|
+
if (snapshotAgents.snapshot.visibility) {
|
|
784
|
+
requestJSON.snapshot.visibility = snapshotAgents.snapshot.visibility;
|
|
785
|
+
requestJSON.snapshot.visibilitySince = snapshotAgents.snapshot.visibilitySince;
|
|
786
|
+
requestJSON.snapshot.agentIds = snapshotAgents.snapshot.agentIds;
|
|
787
|
+
}
|
|
783
788
|
}
|
|
784
789
|
winston.debug('requestJSON', requestJSON);
|
|
785
790
|
} catch (e) {
|
|
@@ -827,13 +832,16 @@ class WebSocketServer {
|
|
|
827
832
|
winston.debug('snapshotAgents', snapshotAgents);
|
|
828
833
|
// requestJSON.snapshot.agents = snapshotAgents;
|
|
829
834
|
|
|
830
|
-
if (snapshotAgents
|
|
831
|
-
var
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
|
|
835
|
+
if (snapshotAgents && snapshotAgents.snapshot) {
|
|
836
|
+
var agentsForClient = requestVisibility.agentsForClient(snapshotAgents.snapshot);
|
|
837
|
+
if (agentsForClient) {
|
|
838
|
+
requestJSON.snapshot.agents = agentsForClient;
|
|
839
|
+
}
|
|
840
|
+
if (snapshotAgents.snapshot.visibility) {
|
|
841
|
+
requestJSON.snapshot.visibility = snapshotAgents.snapshot.visibility;
|
|
842
|
+
requestJSON.snapshot.visibilitySince = snapshotAgents.snapshot.visibilitySince;
|
|
843
|
+
requestJSON.snapshot.agentIds = snapshotAgents.snapshot.agentIds;
|
|
844
|
+
}
|
|
837
845
|
}
|
|
838
846
|
winston.debug('requestJSON', requestJSON);
|
|
839
847
|
|
|
@@ -950,10 +958,7 @@ class WebSocketServer {
|
|
|
950
958
|
// winston.debug('ws connection. req.url)', req.url);
|
|
951
959
|
// //console.log('ws connection. req', req);
|
|
952
960
|
|
|
953
|
-
// let
|
|
954
|
-
// winston.debug('urlParsed', urlParsed);
|
|
955
|
-
|
|
956
|
-
// var queryParameter = urlParsed.query;
|
|
961
|
+
// let queryParameter = Object.fromEntries(new URL(req.url, 'http://localhost').searchParams);
|
|
957
962
|
// winston.debug('queryParameter', queryParameter);
|
|
958
963
|
|
|
959
964
|
// var id_project = queryParameter.id_project;
|
|
File without changes
|