@tiledesk/tiledesk-tybot-connector 2.1.14 → 2.2.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/logs/app1.log CHANGED
@@ -5140,3 +5140,22 @@ info: [HttpUtils] POST http://127.0.0.1:10001/ext/botID completed in 1.18ms (HTT
5140
5140
  info: [HttpUtils] GET http://127.0.0.1:10002/projectID/integration/name/openrouter completed in 0.96ms (HTTP 200) [keep-alive client: off]
5141
5141
  error: Error: DirAiCondition openrouter integration not resolved: The key provided for openrouter is not valid or undefined
5142
5142
  info: [HttpUtils] POST http://127.0.0.1:10001/exec/botID completed in 1.75ms (HTTP 200) [keep-alive client: off]
5143
+ info: AI_MODELS not defined
5144
+ info: AI Models:
5145
+ info: AI_MODELS not defined
5146
+ info: AI Models:
5147
+ info: Starting tilebot server...
5148
+ info: (Tilebot) Starting Tilebot..
5149
+ info: (Tilebot) settings.API_ENDPOINT:http://127.0.0.1:10002
5150
+ info: (Tilebot) settings.TILEBOT_ENDPOINT:http://127.0.0.1:10001
5151
+ info: (Tilebot) Log Level: info
5152
+ info: (Tilebot) MAX_STEPS: 1000
5153
+ info: (Tilebot) MAX_EXECUTION_TIME: 28800000
5154
+ info: (Tilebot) Starting Tilebot connector v2.1.2
5155
+ info: (Tilebot) Using static bots
5156
+ info: (Tilebot) Connecting Redis...
5157
+ info: (Tilebot) Redis connected
5158
+ info: (Tilebot) Tilebot started
5159
+ info: Tilebot route successfully started.
5160
+ info: Tilebot connector listening on port 10001
5161
+ info: [HttpUtils] HTTP client keep-alive: disabled (default). Set TYBOT_HTTP_KEEP_ALIVE=1|true|yes|on to enable. Verbose logs include round-trip time (ms) and [keep-alive client: off].
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "2.1.14",
3
+ "version": "2.2.0",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -832,8 +832,8 @@ class DirAiPrompt {
832
832
  : {};
833
833
  for (const key of Object.keys(base)) {
834
834
  const v = base[key];
835
- if (v !== undefined && v !== null && typeof v !== 'string') {
836
- base[key] = typeof v === 'object' ? JSON.stringify(v) : String(v);
835
+ if (v !== undefined && v !== null) {
836
+ base[key] = DirAiPrompt.sanitizeHeaderValue(v);
837
837
  }
838
838
  }
839
839
  if (!variables || typeof variables !== 'object' || Array.isArray(variables)) {
@@ -849,7 +849,7 @@ class DirAiPrompt {
849
849
  base[key] = '';
850
850
  continue;
851
851
  }
852
- base[key] = typeof v === 'object' ? JSON.stringify(v) : String(v);
852
+ base[key] = DirAiPrompt.sanitizeHeaderValue(v);
853
853
  } catch (err) {
854
854
  winston.warn("DirAiPrompt mergeHeadersWithVariables skip key:", key, err);
855
855
  }
@@ -857,6 +857,28 @@ class DirAiPrompt {
857
857
  return base;
858
858
  }
859
859
 
860
+ // Header values reject backslash and control chars. Email bodies often
861
+ // arrive with real newlines or literal "\n" sequences in x-last-user-text.
862
+ static sanitizeHeaderValue(value) {
863
+ if (value == null) return '';
864
+ let str;
865
+ try {
866
+ str = typeof value === 'object' ? JSON.stringify(value) : String(value);
867
+ } catch (err) {
868
+ return '';
869
+ }
870
+ return str
871
+ .replace(/\\r\\n/g, ' ')
872
+ .replace(/\\n/g, ' ')
873
+ .replace(/\\r/g, ' ')
874
+ .replace(/\\t/g, ' ')
875
+ .replace(/[\u0000-\u001F\u007F]/g, ' ')
876
+ .replace(/\\/g, '')
877
+ .replace(/[^\t\x20-\x7E\x80-\xFF]/g, '')
878
+ .replace(/ {2,}/g, ' ')
879
+ .trim();
880
+ }
881
+
860
882
  async resolveNativeServerUrls(servers) {
861
883
  if (!Array.isArray(servers)) return null;
862
884