@delt/claude-alarm 0.6.12 → 0.6.14

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/dist/cli.js CHANGED
@@ -329,8 +329,8 @@ var init_telegram = __esm({
329
329
  }
330
330
  /** Send a notification message to Telegram */
331
331
  async sendNotification(sessionId2, _sessionLabel, title, message) {
332
- const text = `${title}
333
- ${message}`;
332
+ const text = `<b>${this.escHtml(title)}</b>
333
+ ${this.mdToHtml(message)}`;
334
334
  const result = await this.sendMessage(text);
335
335
  if (result?.message_id) {
336
336
  this.messageSessionMap.set(result.message_id, sessionId2);
@@ -539,11 +539,11 @@ ${sessionList}`);
539
539
  else if (p.file_path) {
540
540
  preview = p.file_path;
541
541
  if (p.content) {
542
- preview += "\n" + p.content.slice(0, 500);
542
+ preview += "\n" + p.content.slice(0, 3e3);
543
543
  if (p.content.length > 500) truncated = true;
544
544
  }
545
545
  } else if (p.content && typeof p.content === "string") {
546
- preview = p.content.slice(0, 500);
546
+ preview = p.content.slice(0, 3e3);
547
547
  if (p.content.length > 500) truncated = true;
548
548
  }
549
549
  } catch {
@@ -551,10 +551,10 @@ ${sessionList}`);
551
551
  const cmdMatch = inputPreview.match(/"command"\s*:\s*"((?:[^"\\]|\\.)*)"/);
552
552
  const contentMatch = inputPreview.match(/"content"\s*:\s*"((?:[^"\\]|\\.)*)"/);
553
553
  if (cmdMatch) preview = `$ ${cmdMatch[1]}`;
554
- else if (contentMatch) preview = contentMatch[1].slice(0, 500);
554
+ else if (contentMatch) preview = contentMatch[1].slice(0, 3e3);
555
555
  }
556
556
  const truncNote = truncated ? "\n\n<i>...truncated</i>" : "";
557
- const previewSlice = preview.slice(0, 800);
557
+ const previewSlice = preview.slice(0, 3e3);
558
558
  const isShort = !previewSlice.includes("\n") && previewSlice.length < 100;
559
559
  const previewHtml = isShort ? `<code>${this.escHtml(previewSlice)}</code>` : this.escHtml(previewSlice);
560
560
  let displayTool = toolName;
@@ -625,6 +625,15 @@ ${label}`);
625
625
  escHtml(s) {
626
626
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
627
627
  }
628
+ /** Convert markdown to Telegram HTML (escape first, then apply formatting) */
629
+ mdToHtml(s) {
630
+ let html = this.escHtml(s);
631
+ html = html.replace(/```(?:\w*)\n?([\s\S]*?)```/g, "<pre>$1</pre>");
632
+ html = html.replace(/`([^`]+)`/g, "<code>$1</code>");
633
+ html = html.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>");
634
+ html = html.replace(/\*(.+?)\*/g, "<i>$1</i>");
635
+ return html;
636
+ }
628
637
  /** Update config (e.g., from dashboard settings) */
629
638
  updateConfig(config2) {
630
639
  const wasPolling = this.polling;
@@ -943,7 +952,7 @@ var init_server = __esm({
943
952
  this.sessions.updateActivity(msg.sessionId);
944
953
  const replySession = this.sessions.get(msg.sessionId);
945
954
  const replyLabel = this.getSessionLabel(replySession);
946
- this.notifier.notifyWithSession(msg.sessionId, replyLabel, `[${replyLabel}] Reply`, msg.content.slice(0, 200), "info");
955
+ this.notifier.notifyWithSession(msg.sessionId, replyLabel, `[${replyLabel}] Reply`, msg.content.slice(0, 3e3), "info");
947
956
  this.broadcastToDashboards({
948
957
  type: "reply_from_session",
949
958
  sessionId: msg.sessionId,