claude-b 0.5.0 → 0.5.1
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/index.js +1 -1
- package/dist/daemon/index.js +77 -20
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -160,7 +160,7 @@ var DaemonClient = class extends EventEmitter {
|
|
|
160
160
|
// package.json
|
|
161
161
|
var package_default = {
|
|
162
162
|
name: "claude-b",
|
|
163
|
-
version: "0.5.
|
|
163
|
+
version: "0.5.1",
|
|
164
164
|
description: "Background-capable Claude Code with async workflows and REST API",
|
|
165
165
|
type: "module",
|
|
166
166
|
main: "dist/cli/index.js",
|
package/dist/daemon/index.js
CHANGED
|
@@ -3765,39 +3765,96 @@ var ClaudeBTelegramBot = class extends EventEmitter8 {
|
|
|
3765
3765
|
const duration = notification.durationMs ? `${(notification.durationMs / 1e3).toFixed(1)}s` : "";
|
|
3766
3766
|
const cost = notification.costUsd ? ` \xB7 $${notification.costUsd.toFixed(4)}` : "";
|
|
3767
3767
|
const escHtml = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
3768
|
-
const
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3768
|
+
const header = `${icon} <b>${escHtml(name)}</b> ${status}${duration ? ` (${duration}${cost})` : ""}`;
|
|
3769
|
+
const pwdLine = notification.goal ? `PWD: ${escHtml(notification.goal)}` : "";
|
|
3770
|
+
const footer = `Reply to follow up, or /select ${notification.sessionId.slice(0, 8)}`;
|
|
3771
|
+
const RAW_CHUNK_BUDGET = 2800;
|
|
3772
|
+
const HARD_LIMIT = 4096;
|
|
3773
|
+
const rawBody = notification.resultPreview || "";
|
|
3774
|
+
const rawChunks = [];
|
|
3775
|
+
if (rawBody) {
|
|
3776
|
+
const inLines = rawBody.split("\n");
|
|
3777
|
+
let cur = "";
|
|
3778
|
+
const flush = () => {
|
|
3779
|
+
if (cur) {
|
|
3780
|
+
rawChunks.push(cur);
|
|
3781
|
+
cur = "";
|
|
3782
|
+
}
|
|
3783
|
+
};
|
|
3784
|
+
for (const ln of inLines) {
|
|
3785
|
+
let remaining = ln;
|
|
3786
|
+
while (remaining.length > RAW_CHUNK_BUDGET) {
|
|
3787
|
+
flush();
|
|
3788
|
+
rawChunks.push(remaining.slice(0, RAW_CHUNK_BUDGET));
|
|
3789
|
+
remaining = remaining.slice(RAW_CHUNK_BUDGET);
|
|
3790
|
+
}
|
|
3791
|
+
if (cur.length + remaining.length + 1 > RAW_CHUNK_BUDGET) flush();
|
|
3792
|
+
cur += (cur ? "\n" : "") + remaining;
|
|
3793
|
+
}
|
|
3794
|
+
flush();
|
|
3776
3795
|
}
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3796
|
+
const total = Math.max(1, rawChunks.length);
|
|
3797
|
+
const buildMessage = (idx) => {
|
|
3798
|
+
const parts = [];
|
|
3799
|
+
const tag = total > 1 ? ` (${idx + 1}/${total})` : "";
|
|
3800
|
+
if (idx === 0) {
|
|
3801
|
+
parts.push(`${header}${tag}`);
|
|
3802
|
+
if (pwdLine) parts.push(pwdLine);
|
|
3803
|
+
if (rawChunks[0]) {
|
|
3804
|
+
parts.push("");
|
|
3805
|
+
parts.push(markdownToTelegramHtml(rawChunks[0]));
|
|
3806
|
+
}
|
|
3807
|
+
} else {
|
|
3808
|
+
parts.push(`\u{1F4C4} <b>${escHtml(name)}</b> continued${tag}`);
|
|
3809
|
+
parts.push("");
|
|
3810
|
+
parts.push(markdownToTelegramHtml(rawChunks[idx]));
|
|
3811
|
+
}
|
|
3812
|
+
if (idx === total - 1) {
|
|
3813
|
+
parts.push("");
|
|
3814
|
+
parts.push(footer);
|
|
3815
|
+
}
|
|
3816
|
+
let text = parts.join("\n");
|
|
3817
|
+
if (text.length > HARD_LIMIT) {
|
|
3818
|
+
text = text.slice(0, HARD_LIMIT - 24) + "\n\u2026 [truncated]";
|
|
3819
|
+
}
|
|
3820
|
+
return text;
|
|
3821
|
+
};
|
|
3822
|
+
const sendOne = async (text) => {
|
|
3781
3823
|
const opts = { parse_mode: "HTML" };
|
|
3782
|
-
let sent;
|
|
3783
3824
|
try {
|
|
3784
|
-
|
|
3825
|
+
return await this.bot.sendMessage(chatId, text, opts);
|
|
3785
3826
|
} catch {
|
|
3786
|
-
|
|
3827
|
+
let plain = text.replace(/<[^>]+>/g, "");
|
|
3828
|
+
if (plain.length > HARD_LIMIT) plain = plain.slice(0, HARD_LIMIT - 24) + "\n\u2026 [truncated]";
|
|
3829
|
+
try {
|
|
3830
|
+
return await this.bot.sendMessage(chatId, plain);
|
|
3831
|
+
} catch {
|
|
3832
|
+
return void 0;
|
|
3833
|
+
}
|
|
3787
3834
|
}
|
|
3788
|
-
|
|
3835
|
+
};
|
|
3836
|
+
try {
|
|
3837
|
+
const firstSent = await sendOne(buildMessage(0));
|
|
3838
|
+
if (!firstSent) return void 0;
|
|
3839
|
+
await this.configManager.mapMessage(String(firstSent.message_id), notification.sessionId);
|
|
3789
3840
|
if (this.voicePipeline && notification.resultPreview) {
|
|
3790
|
-
this.configManager.storeResult(String(
|
|
3841
|
+
this.configManager.storeResult(String(firstSent.message_id), notification.resultPreview);
|
|
3791
3842
|
try {
|
|
3792
3843
|
await this.bot.editMessageReplyMarkup({
|
|
3793
3844
|
inline_keyboard: [[
|
|
3794
|
-
{ text: "\u{1F50A} Listen", callback_data: `listen:${
|
|
3845
|
+
{ text: "\u{1F50A} Listen", callback_data: `listen:${firstSent.message_id}` }
|
|
3795
3846
|
]]
|
|
3796
|
-
}, { chat_id: chatId, message_id:
|
|
3847
|
+
}, { chat_id: chatId, message_id: firstSent.message_id });
|
|
3797
3848
|
} catch {
|
|
3798
3849
|
}
|
|
3799
3850
|
}
|
|
3800
|
-
|
|
3851
|
+
for (let i = 1; i < total; i++) {
|
|
3852
|
+
const cont = await sendOne(buildMessage(i));
|
|
3853
|
+
if (cont) {
|
|
3854
|
+
await this.configManager.mapMessage(String(cont.message_id), notification.sessionId);
|
|
3855
|
+
}
|
|
3856
|
+
}
|
|
3857
|
+
return firstSent.message_id;
|
|
3801
3858
|
} catch (err) {
|
|
3802
3859
|
this.emit("error", err);
|
|
3803
3860
|
return void 0;
|