@tiledesk/tiledesk-server 2.28.2 → 3.0.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/CHANGELOG.md +20 -0
- package/app.js +6 -35
- package/config/native_mcp/native_mcp_servers.json +7 -0
- package/controllers/chatbot.controller.js +659 -0
- package/controllers/intents.controller.js +139 -0
- package/errorCodes.js +2 -1
- package/event/botEvent.js +43 -3
- package/middleware/errorHandler.js +41 -0
- package/models/chatbotTemplates.js +4 -0
- package/models/faq.js +10 -0
- package/models/faq_kb.js +49 -0
- package/package.json +2 -2
- package/pubmodules/aiGenerations/README.md +154 -0
- package/pubmodules/aiGenerations/index.js +7 -0
- package/pubmodules/aiGenerations/listeners.js +96 -0
- package/pubmodules/aiGenerations/models/faqKbRevision.js +51 -0
- package/pubmodules/aiGenerations/routes/aiGenerations.js +426 -0
- package/pubmodules/aiGenerations/services/agentWriter.js +286 -0
- package/pubmodules/aiGenerations/services/atomic.js +70 -0
- package/pubmodules/aiGenerations/services/references.js +78 -0
- package/pubmodules/aiGenerations/services/revisionService.js +169 -0
- package/pubmodules/aiGenerations/services/snapshot.js +109 -0
- package/pubmodules/aiGenerations/test/aiGenerationsRoute.js +503 -0
- package/pubmodules/pubModulesManager.js +17 -0
- package/routes/faq.js +10 -3
- package/routes/faq_kb.js +716 -411
- package/services/chatbotService.js +84 -5
- package/services/faqService.js +159 -45
- package/services/v3FlowService.js +416 -0
- package/template/chatbot/blank.js +21 -3
- package/template/chatbot/blank_subagent.js +139 -0
- package/template/chatbot/blank_voice.js +21 -4
- package/template/chatbot/blank_voice_twilio.js +21 -5
- package/template/chatbot/index.js +1 -0
- package/template/chatbot/subagent_notes.js +30 -0
- package/test/faqRoute.js +83 -0
- package/test/faqkbRoute.js +982 -523
- package/test/faqkbV3Route.js +436 -0
- package/test/fixtures/example-json-with-subagents.txt +1 -0
- package/test/nativemcp.test.js +6 -1
- package/test/v3FlowService.js +187 -0
- package/test/webhookRoute.js +2 -1
- package/utils/AppError.js +9 -0
- package/utils/asyncHandler.js +10 -0
|
@@ -3,6 +3,7 @@ const uuidv4 = require('uuid/v4');
|
|
|
3
3
|
module.exports = function generateTemplate(options) {
|
|
4
4
|
|
|
5
5
|
const custom_intent_id = uuidv4();
|
|
6
|
+
const default_fallback_intent_id = uuidv4();
|
|
6
7
|
|
|
7
8
|
return [
|
|
8
9
|
{
|
|
@@ -26,6 +27,22 @@ module.exports = function generateTemplate(options) {
|
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
{
|
|
30
|
+
"webhook_enabled": false,
|
|
31
|
+
"enabled": true,
|
|
32
|
+
"actions": [],
|
|
33
|
+
"intent_display_name": "defaultFallback",
|
|
34
|
+
"attributes": {
|
|
35
|
+
"position": {
|
|
36
|
+
"x": 714,
|
|
37
|
+
"y": 528
|
|
38
|
+
},
|
|
39
|
+
"nextBlockAction": {
|
|
40
|
+
"_tdActionId": "5b689996-317b-4761-9bc0-cc78d1f390cb",
|
|
41
|
+
"_tdActionType": "intent",
|
|
42
|
+
"intentName": "#" + default_fallback_intent_id
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
29
46
|
"webhook_enabled": false,
|
|
30
47
|
"enabled": true,
|
|
31
48
|
"actions": [{
|
|
@@ -39,17 +56,16 @@ module.exports = function generateTemplate(options) {
|
|
|
39
56
|
"type": "message",
|
|
40
57
|
"message": {
|
|
41
58
|
"type": "text",
|
|
42
|
-
"text": "I didn't understand. Can you rephrase your question?"
|
|
59
|
+
"text": "I didn't understand. Can you rephrase your question?"
|
|
43
60
|
}
|
|
44
61
|
}]
|
|
45
62
|
}
|
|
46
63
|
}],
|
|
47
|
-
"intent_display_name": "
|
|
48
|
-
"
|
|
64
|
+
"intent_display_name": "untitled_block_2",
|
|
65
|
+
"intent_id": default_fallback_intent_id,
|
|
49
66
|
"attributes": {
|
|
50
|
-
"readonly": true,
|
|
51
67
|
"position": {
|
|
52
|
-
"x":
|
|
68
|
+
"x": 1114,
|
|
53
69
|
"y": 528
|
|
54
70
|
}
|
|
55
71
|
}
|
|
@@ -3,6 +3,7 @@ module.exports = {
|
|
|
3
3
|
blank: require('./blank'),
|
|
4
4
|
blank_webhook: require('./blank_webhook'),
|
|
5
5
|
blank_copilot: require('./blank_copilot'),
|
|
6
|
+
blank_subagent: require('./blank_subagent'),
|
|
6
7
|
official_copilot: require('./official_copilot'),
|
|
7
8
|
blank_voice: require('./blank_voice'),
|
|
8
9
|
blank_voice_twilio: require('./blank_voice_twilio'),
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"notes": [
|
|
3
|
+
{
|
|
4
|
+
"id_faq_kb": "6a70ab21cb52270013040601",
|
|
5
|
+
"note_id": "fda256bb-d34a-4bd6-b0d0-018360500318",
|
|
6
|
+
"x": 675.106,
|
|
7
|
+
"y": 202,
|
|
8
|
+
"type": "rect",
|
|
9
|
+
"text": "",
|
|
10
|
+
"width": 130,
|
|
11
|
+
"height": 42,
|
|
12
|
+
"createdAt": "2026-08-03T15:51:49.143Z",
|
|
13
|
+
"backgroundColor": "rgba(75, 79, 82, 100)",
|
|
14
|
+
"borderColor": "rgba(67, 140, 181, 1)",
|
|
15
|
+
"borderWidth": 0,
|
|
16
|
+
"isNew": true,
|
|
17
|
+
"backgroundOpacity": 100,
|
|
18
|
+
"borderOpacity": 100,
|
|
19
|
+
"boxShadow": true,
|
|
20
|
+
"fontSize": "0.96em",
|
|
21
|
+
"fontFamily": "Open Sans, sans-serif",
|
|
22
|
+
"rotation": 0,
|
|
23
|
+
"scale": [
|
|
24
|
+
1.74501,
|
|
25
|
+
1.70771
|
|
26
|
+
],
|
|
27
|
+
"title": "<p><span class=\"ql-color-ffffff\">Replace this block with your subagent logic</span></p>"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
package/test/faqRoute.js
CHANGED
|
@@ -356,6 +356,89 @@ describe('FaqKBRoute', () => {
|
|
|
356
356
|
}).timeout(20000);
|
|
357
357
|
|
|
358
358
|
|
|
359
|
+
it('Get faqs without the bot in every row (populate=false)', (done) => {
|
|
360
|
+
|
|
361
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
|
362
|
+
var pwd = "pwd";
|
|
363
|
+
|
|
364
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
|
365
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
|
366
|
+
chai.request(server)
|
|
367
|
+
.post('/' + savedProject._id + '/faq_kb')
|
|
368
|
+
.auth(email, pwd)
|
|
369
|
+
.send({ "name": "testbot", type: "tilebot", language: 'en', template: 'blank' })
|
|
370
|
+
.end((err, res) => {
|
|
371
|
+
|
|
372
|
+
if (err) { console.error("err: ", err); }
|
|
373
|
+
if (log) { console.log("res.body", res.body); }
|
|
374
|
+
|
|
375
|
+
res.should.have.status(200);
|
|
376
|
+
let id_faq_kb = res.body._id;
|
|
377
|
+
|
|
378
|
+
// as always: every block carries the bot
|
|
379
|
+
chai.request(server)
|
|
380
|
+
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
|
381
|
+
.auth(email, pwd)
|
|
382
|
+
.end((err, res) => {
|
|
383
|
+
|
|
384
|
+
if (err) { console.error("err: ", err); }
|
|
385
|
+
if (log) { console.log("res.body", res.body); }
|
|
386
|
+
|
|
387
|
+
res.should.have.status(200);
|
|
388
|
+
res.body.should.be.a('array');
|
|
389
|
+
expect(res.body.length).to.be.above(0);
|
|
390
|
+
const blocks = res.body.length;
|
|
391
|
+
res.body.forEach((faq) => {
|
|
392
|
+
expect(faq.faq_kb).to.be.a('array');
|
|
393
|
+
expect(faq.faq_kb[0]._id).to.equal(id_faq_kb);
|
|
394
|
+
expect(faq.faq_kb[0].name).to.equal("testbot");
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// populate=false: the same blocks, without the bot
|
|
398
|
+
chai.request(server)
|
|
399
|
+
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb + '&populate=false')
|
|
400
|
+
.auth(email, pwd)
|
|
401
|
+
.end((err, res) => {
|
|
402
|
+
|
|
403
|
+
if (err) { console.error("err: ", err); }
|
|
404
|
+
if (log) { console.log("res.body", res.body); }
|
|
405
|
+
|
|
406
|
+
res.should.have.status(200);
|
|
407
|
+
res.body.should.be.a('array');
|
|
408
|
+
expect(res.body.length).to.equal(blocks);
|
|
409
|
+
res.body.forEach((faq) => {
|
|
410
|
+
expect(faq.faq_kb).to.equal(undefined);
|
|
411
|
+
expect(faq.id_faq_kb).to.equal(id_faq_kb);
|
|
412
|
+
expect(faq.intent_display_name).to.be.a('string');
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// any other value: as always
|
|
416
|
+
chai.request(server)
|
|
417
|
+
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb + '&populate=true')
|
|
418
|
+
.auth(email, pwd)
|
|
419
|
+
.end((err, res) => {
|
|
420
|
+
|
|
421
|
+
if (err) { console.error("err: ", err); }
|
|
422
|
+
if (log) { console.log("res.body", res.body); }
|
|
423
|
+
|
|
424
|
+
res.should.have.status(200);
|
|
425
|
+
expect(res.body.length).to.equal(blocks);
|
|
426
|
+
res.body.forEach((faq) => {
|
|
427
|
+
expect(faq.faq_kb).to.be.a('array');
|
|
428
|
+
expect(faq.faq_kb[0]._id).to.equal(id_faq_kb);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
done();
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
}).timeout(20000);
|
|
440
|
+
|
|
441
|
+
|
|
359
442
|
it('searchFaqs', (done) => {
|
|
360
443
|
|
|
361
444
|
var email = "test-signup-" + Date.now() + "@email.com";
|