@delt/claude-alarm 0.6.3 → 0.6.5

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
@@ -531,20 +531,38 @@ ${sessionList}`);
531
531
  /** Send a permission request with inline buttons */
532
532
  async sendPermissionRequest(sessionId2, sessionLabel, requestId, toolName, description, inputPreview) {
533
533
  let preview = inputPreview;
534
+ let truncated = false;
534
535
  try {
535
536
  const p = JSON.parse(inputPreview);
536
537
  if (p.command) preview = `$ ${p.command}`;
537
- else if (p.file_path) preview = p.file_path + (p.content ? "\n" + p.content.slice(0, 150) : "");
538
+ else if (p.file_path) {
539
+ preview = p.file_path;
540
+ if (p.content) {
541
+ preview += "\n" + p.content.slice(0, 500);
542
+ if (p.content.length > 500) truncated = true;
543
+ }
544
+ } else if (p.content && typeof p.content === "string") {
545
+ preview = p.content.slice(0, 500);
546
+ if (p.content.length > 500) truncated = true;
547
+ }
538
548
  } catch {
549
+ truncated = true;
539
550
  const cmdMatch = inputPreview.match(/"command"\s*:\s*"((?:[^"\\]|\\.)*)"/);
551
+ const contentMatch = inputPreview.match(/"content"\s*:\s*"((?:[^"\\]|\\.)*)"/);
540
552
  if (cmdMatch) preview = `$ ${cmdMatch[1]}`;
553
+ else if (contentMatch) preview = contentMatch[1].slice(0, 500);
541
554
  }
555
+ const truncNote = truncated ? "\n\n<i>...truncated</i>" : "";
556
+ const previewSlice = preview.slice(0, 800);
557
+ const isShort = !previewSlice.includes("\n") && previewSlice.length < 100;
558
+ const previewHtml = isShort ? `<code>${this.escHtml(previewSlice)}</code>` : this.escHtml(previewSlice);
542
559
  const text = `\u26A0\uFE0F <b>Permission Request</b>
543
560
 
544
561
  \u{1F4C2} <b>${this.escHtml(sessionLabel)}</b>
545
- \u{1F527} <code>${this.escHtml(toolName)}</code> \u2014 ${this.escHtml(description)}
562
+ \u{1F527} <code>${this.escHtml(toolName)}</code>
563
+ ${this.escHtml(description)}
546
564
 
547
- <pre>${this.escHtml(preview.slice(0, 800))}</pre>`;
565
+ ${previewHtml}${truncNote}`;
548
566
  const replyMarkup = {
549
567
  inline_keyboard: [[
550
568
  { text: "\u2705 Allow", callback_data: `perm:allow:${sessionId2}:${requestId}` },