appback-remoteagent 0.13.15 → 0.13.16

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 (2) hide show
  1. package/dist/bot.js +23 -3
  2. package/package.json +1 -1
package/dist/bot.js CHANGED
@@ -1375,7 +1375,7 @@ function renderTelegramHtml(text) {
1375
1375
  for (const line of lines) {
1376
1376
  if (/^```\w*\s*$/.test(line.trim())) {
1377
1377
  if (codeFence) {
1378
- rendered.push(`<pre>${escapeTelegramHtml(codeFence.join("\n"))}</pre>`);
1378
+ rendered.push(renderTelegramCodeFenceHtml(codeFence.join("\n")));
1379
1379
  codeFence = undefined;
1380
1380
  }
1381
1381
  else {
@@ -1390,25 +1390,45 @@ function renderTelegramHtml(text) {
1390
1390
  rendered.push(renderTelegramInlineHtml(line));
1391
1391
  }
1392
1392
  if (codeFence) {
1393
- rendered.push(`<pre>${escapeTelegramHtml(codeFence.join("\n"))}</pre>`);
1393
+ rendered.push(renderTelegramCodeFenceHtml(codeFence.join("\n")));
1394
1394
  }
1395
1395
  return rendered.join("\n");
1396
1396
  }
1397
+ function renderTelegramCodeFenceHtml(content) {
1398
+ if (containsUrl(content)) {
1399
+ return content.split(/\r?\n/).map((line) => renderTelegramInlineHtml(line)).join("\n");
1400
+ }
1401
+ return `<pre>${escapeTelegramHtml(content)}</pre>`;
1402
+ }
1397
1403
  function renderTelegramInlineHtml(line) {
1398
1404
  const parts = line.split(/(`[^`\n]+`)/g);
1399
1405
  return parts.map((part) => {
1400
1406
  if (part.startsWith("`") && part.endsWith("`") && part.length >= 2) {
1401
1407
  return `<code>${escapeTelegramHtml(part.slice(1, -1))}</code>`;
1402
1408
  }
1403
- return escapeTelegramHtml(part);
1409
+ return renderTelegramTextLinks(part);
1404
1410
  }).join("");
1405
1411
  }
1412
+ function renderTelegramTextLinks(value) {
1413
+ return value.replace(/https?:\/\/[^\s<>"']+/g, (url) => {
1414
+ const trailingMatch = /[),.;!?]+$/.exec(url);
1415
+ const trailing = trailingMatch?.[0] ?? "";
1416
+ const cleanUrl = trailing ? url.slice(0, -trailing.length) : url;
1417
+ return `<a href="${escapeTelegramHtmlAttribute(cleanUrl)}">${escapeTelegramHtml(cleanUrl)}</a>${escapeTelegramHtml(trailing)}`;
1418
+ });
1419
+ }
1420
+ function containsUrl(value) {
1421
+ return /https?:\/\/[^\s<>"']+/.test(value);
1422
+ }
1406
1423
  function escapeTelegramHtml(value) {
1407
1424
  return value
1408
1425
  .replace(/&/g, "&amp;")
1409
1426
  .replace(/</g, "&lt;")
1410
1427
  .replace(/>/g, "&gt;");
1411
1428
  }
1429
+ function escapeTelegramHtmlAttribute(value) {
1430
+ return escapeTelegramHtml(value).replace(/"/g, "&quot;");
1431
+ }
1412
1432
  function looksLikeUntaggedIntentOnlyResponse(text) {
1413
1433
  const normalized = text.trim();
1414
1434
  if (!normalized) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appback-remoteagent",
3
- "version": "0.13.15",
3
+ "version": "0.13.16",
4
4
  "description": "Personal installable session server for continuing local AI work across PC and Telegram",
5
5
  "license": "MIT",
6
6
  "type": "module",