@ducci/jarvis 1.0.71 → 1.0.72

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.
@@ -56,6 +56,7 @@ There are two types of responses depending on whether you need to use tools:
56
56
  }
57
57
 
58
58
  The `response` value must be a string — never an array or object. Use HTML formatting tags for readability — only these Telegram-supported tags are allowed: <b>bold</b>, <i>italic</i>, <u>underline</u>, <s>strikethrough</s>, <code>inline code</code>, <pre>code block</pre>, <blockquote>quote</blockquote>, <a href="URL">link</a>. For line breaks use actual newlines (\n), never <br>. Never use Markdown formatting (no **, __, `, or ```). Always escape literal `<`, `>`, and `&` characters as `&lt;`, `&gt;`, and `&amp;` — this applies everywhere including inside `<code>` and `<pre>` blocks (e.g. HTML snippets, shell redirects, comparisons like `x &lt; 5`, generics like `List&lt;String&gt;`). In `<a href="">` URLs, escape `&` in query parameters as `&amp;` (e.g. `?foo=1&amp;bar=2`). Unescaped characters cause Telegram to reject the message entirely. If you need to present structured data (e.g. a list of items), format it as text within the string value.
59
+ ❌ Never use heading or layout tags: <h1> <h2> <h3> <h4> <h5> <h6> <ul> <ol> <li> <div> <span> <p> <hr> — they are not supported by Telegram and will break the message.
59
60
 
60
61
  Never include markdown code fences, preamble, or any text outside this JSON object. If you cannot complete a task, explain why in the `response` field — still as valid JSON.
61
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ducci/jarvis",
3
- "version": "1.0.71",
3
+ "version": "1.0.72",
4
4
  "description": "A fully automated agent system that lives on a server.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -25,6 +25,21 @@ function escapeHtml(str) {
25
25
  }
26
26
 
27
27
  function markdownToHtml(text) {
28
+ // 0. Sanitize unsupported Telegram HTML tags
29
+ // Headings → <b>
30
+ text = text.replace(/<h[1-6](\s[^>]*)?>/gi, '<b>');
31
+ text = text.replace(/<\/h[1-6]>/gi, '</b>');
32
+ // List items → bullet prefix (strip both opening and closing tags)
33
+ text = text.replace(/<li(\s[^>]*)?>/gi, '• ');
34
+ text = text.replace(/<\/li>/gi, '');
35
+ // Block layout tags → newlines (strip tags, keep content)
36
+ text = text.replace(/<\/?(ul|ol|div|p)(\s[^>]*)?>/gi, '\n');
37
+ // Inline layout tags → strip
38
+ text = text.replace(/<\/?(span)(\s[^>]*)?>/gi, '');
39
+ // <hr> → strip entirely
40
+ text = text.replace(/<hr(\s[^>]*)?\/?>/gi, '');
41
+ // Collapse 3+ consecutive newlines to 2
42
+ text = text.replace(/\n{3,}/g, '\n\n');
28
43
  // 1. Block fences: ```[lang]\ncontent\n``` → <pre>content</pre>
29
44
  text = text.replace(/```[\w]*\n([\s\S]*?)\n?```/g, (_, content) => {
30
45
  return `<pre>${escapeHtml(content)}</pre>`;