@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.
Files changed (44) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/app.js +6 -35
  3. package/config/native_mcp/native_mcp_servers.json +7 -0
  4. package/controllers/chatbot.controller.js +659 -0
  5. package/controllers/intents.controller.js +139 -0
  6. package/errorCodes.js +2 -1
  7. package/event/botEvent.js +43 -3
  8. package/middleware/errorHandler.js +41 -0
  9. package/models/chatbotTemplates.js +4 -0
  10. package/models/faq.js +10 -0
  11. package/models/faq_kb.js +49 -0
  12. package/package.json +2 -2
  13. package/pubmodules/aiGenerations/README.md +154 -0
  14. package/pubmodules/aiGenerations/index.js +7 -0
  15. package/pubmodules/aiGenerations/listeners.js +96 -0
  16. package/pubmodules/aiGenerations/models/faqKbRevision.js +51 -0
  17. package/pubmodules/aiGenerations/routes/aiGenerations.js +426 -0
  18. package/pubmodules/aiGenerations/services/agentWriter.js +286 -0
  19. package/pubmodules/aiGenerations/services/atomic.js +70 -0
  20. package/pubmodules/aiGenerations/services/references.js +78 -0
  21. package/pubmodules/aiGenerations/services/revisionService.js +169 -0
  22. package/pubmodules/aiGenerations/services/snapshot.js +109 -0
  23. package/pubmodules/aiGenerations/test/aiGenerationsRoute.js +503 -0
  24. package/pubmodules/pubModulesManager.js +17 -0
  25. package/routes/faq.js +10 -3
  26. package/routes/faq_kb.js +716 -411
  27. package/services/chatbotService.js +84 -5
  28. package/services/faqService.js +159 -45
  29. package/services/v3FlowService.js +416 -0
  30. package/template/chatbot/blank.js +21 -3
  31. package/template/chatbot/blank_subagent.js +139 -0
  32. package/template/chatbot/blank_voice.js +21 -4
  33. package/template/chatbot/blank_voice_twilio.js +21 -5
  34. package/template/chatbot/index.js +1 -0
  35. package/template/chatbot/subagent_notes.js +30 -0
  36. package/test/faqRoute.js +83 -0
  37. package/test/faqkbRoute.js +982 -523
  38. package/test/faqkbV3Route.js +436 -0
  39. package/test/fixtures/example-json-with-subagents.txt +1 -0
  40. package/test/nativemcp.test.js +6 -1
  41. package/test/v3FlowService.js +187 -0
  42. package/test/webhookRoute.js +2 -1
  43. package/utils/AppError.js +9 -0
  44. 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": "defaultFallback",
48
- "agents_available": false,
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": 714,
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";