@delt/claude-alarm 0.8.1 → 0.8.2
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 +53 -7
- package/dist/cli.js.map +1 -1
- package/dist/dashboard/index.html +66 -17
- package/dist/hub/server.js +53 -7
- package/dist/hub/server.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +53 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/dashboard/index.html +66 -17
package/dist/cli.js
CHANGED
|
@@ -378,7 +378,7 @@ var init_telegram = __esm({
|
|
|
378
378
|
init_logger();
|
|
379
379
|
init_constants();
|
|
380
380
|
TELEGRAM_API = "https://api.telegram.org/bot";
|
|
381
|
-
TelegramBot = class {
|
|
381
|
+
TelegramBot = class _TelegramBot {
|
|
382
382
|
config;
|
|
383
383
|
offset = 0;
|
|
384
384
|
polling = false;
|
|
@@ -610,33 +610,45 @@ ${this.mdToHtml(message)}`;
|
|
|
610
610
|
}
|
|
611
611
|
/** Send a permission request with inline buttons */
|
|
612
612
|
async sendPermissionRequest(sessionId2, sessionLabel, requestId, toolName, description, inputPreview) {
|
|
613
|
+
const isNotify = toolName.endsWith("__notify") || toolName === "notify";
|
|
613
614
|
let preview = inputPreview;
|
|
615
|
+
let kind = "code";
|
|
616
|
+
let lang = "";
|
|
614
617
|
let truncated = false;
|
|
615
618
|
try {
|
|
616
619
|
const p = JSON.parse(inputPreview);
|
|
617
|
-
if (p.command)
|
|
618
|
-
|
|
619
|
-
|
|
620
|
+
if (p.command) {
|
|
621
|
+
preview = `$ ${p.command}`;
|
|
622
|
+
lang = "bash";
|
|
623
|
+
} else if (p.title && p.message) {
|
|
624
|
+
preview = p.message;
|
|
625
|
+
kind = "prose";
|
|
626
|
+
} else if (p.file_path) {
|
|
620
627
|
preview = p.file_path;
|
|
628
|
+
lang = this.langOf(p.file_path);
|
|
621
629
|
if (p.content) {
|
|
622
630
|
preview += "\n" + p.content.slice(0, 3e3);
|
|
623
631
|
if (p.content.length > 500) truncated = true;
|
|
624
632
|
}
|
|
625
633
|
} else if (p.content && typeof p.content === "string") {
|
|
626
634
|
preview = p.content.slice(0, 3e3);
|
|
635
|
+
if (isNotify) kind = "prose";
|
|
627
636
|
if (p.content.length > 500) truncated = true;
|
|
628
637
|
}
|
|
629
638
|
} catch {
|
|
630
639
|
truncated = true;
|
|
631
640
|
const cmdMatch = inputPreview.match(/"command"\s*:\s*"((?:[^"\\]|\\.)*)"/);
|
|
632
641
|
const contentMatch = inputPreview.match(/"content"\s*:\s*"((?:[^"\\]|\\.)*)"/);
|
|
633
|
-
if (cmdMatch)
|
|
634
|
-
|
|
642
|
+
if (cmdMatch) {
|
|
643
|
+
preview = `$ ${cmdMatch[1]}`;
|
|
644
|
+
lang = "bash";
|
|
645
|
+
} else if (contentMatch) preview = contentMatch[1].slice(0, 3e3);
|
|
635
646
|
}
|
|
636
647
|
const truncNote = truncated ? "\n\n<i>...truncated</i>" : "";
|
|
637
648
|
const previewSlice = preview.slice(0, 3e3);
|
|
638
649
|
const isShort = !previewSlice.includes("\n") && previewSlice.length < 100;
|
|
639
|
-
const
|
|
650
|
+
const langAttr = lang ? ` class="language-${lang}"` : "";
|
|
651
|
+
const previewHtml = kind === "prose" ? this.mdToHtml(previewSlice) : isShort ? `<code>${this.escHtml(previewSlice)}</code>` : `<pre><code${langAttr}>${this.escHtml(previewSlice)}</code></pre>`;
|
|
640
652
|
let displayTool = toolName;
|
|
641
653
|
if ((toolName.endsWith("__notify") || toolName === "notify") && inputPreview) {
|
|
642
654
|
try {
|
|
@@ -736,6 +748,40 @@ ${label}`);
|
|
|
736
748
|
escHtml(s) {
|
|
737
749
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
738
750
|
}
|
|
751
|
+
static LANG_BY_EXT = {
|
|
752
|
+
js: "javascript",
|
|
753
|
+
mjs: "javascript",
|
|
754
|
+
cjs: "javascript",
|
|
755
|
+
jsx: "javascript",
|
|
756
|
+
ts: "typescript",
|
|
757
|
+
tsx: "typescript",
|
|
758
|
+
py: "python",
|
|
759
|
+
rb: "ruby",
|
|
760
|
+
go: "go",
|
|
761
|
+
java: "java",
|
|
762
|
+
kt: "kotlin",
|
|
763
|
+
rs: "rust",
|
|
764
|
+
php: "php",
|
|
765
|
+
cs: "csharp",
|
|
766
|
+
sh: "bash",
|
|
767
|
+
bash: "bash",
|
|
768
|
+
zsh: "bash",
|
|
769
|
+
ps1: "powershell",
|
|
770
|
+
json: "json",
|
|
771
|
+
yml: "yaml",
|
|
772
|
+
yaml: "yaml",
|
|
773
|
+
xml: "xml",
|
|
774
|
+
sql: "sql",
|
|
775
|
+
md: "markdown",
|
|
776
|
+
html: "html",
|
|
777
|
+
vue: "html",
|
|
778
|
+
css: "css",
|
|
779
|
+
scss: "scss"
|
|
780
|
+
};
|
|
781
|
+
langOf(path7) {
|
|
782
|
+
const m = /\.([a-z0-9]+)$/i.exec(path7 || "");
|
|
783
|
+
return m ? _TelegramBot.LANG_BY_EXT[m[1].toLowerCase()] ?? "" : "";
|
|
784
|
+
}
|
|
739
785
|
/** Convert markdown to Telegram HTML (escape first, then apply formatting) */
|
|
740
786
|
mdToHtml(s) {
|
|
741
787
|
let text = s.replace(
|