@hmawla/co-assistant 1.0.7 → 1.0.8
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 +28 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/heartbeats/email-reply-check.heartbeat.md +13 -14
- package/package.json +1 -1
- package/plugins/gmail/index.compiled.mjs +146 -10
- package/plugins/gmail/plugin.json +1 -1
- package/plugins/gmail/tools.ts +240 -11
package/dist/index.js
CHANGED
|
@@ -2516,6 +2516,19 @@ function splitMessage(text, maxLength = 4096) {
|
|
|
2516
2516
|
}
|
|
2517
2517
|
return chunks.filter((c) => c.length > 0);
|
|
2518
2518
|
}
|
|
2519
|
+
async function safeSendMarkdown(sendFn, text, extra = {}) {
|
|
2520
|
+
try {
|
|
2521
|
+
await sendFn(text, { parse_mode: "Markdown", ...extra });
|
|
2522
|
+
} catch (err) {
|
|
2523
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2524
|
+
if (msg.includes("can't parse entities")) {
|
|
2525
|
+
const plain = text.replace(/[*_`]/g, "");
|
|
2526
|
+
await sendFn(plain, extra);
|
|
2527
|
+
} else {
|
|
2528
|
+
throw err;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2519
2532
|
function createMessageHandler(deps) {
|
|
2520
2533
|
const { sessionManager: sessionManager2, conversationRepo } = deps;
|
|
2521
2534
|
return async (ctx, text) => {
|
|
@@ -3137,7 +3150,11 @@ ${state.processedIds.map((id) => `- ${id}`).join("\n")}` : "No previously proces
|
|
|
3137
3150
|
`;
|
|
3138
3151
|
const chunks = splitMessage(header + clean);
|
|
3139
3152
|
for (const chunk of chunks) {
|
|
3140
|
-
await
|
|
3153
|
+
await safeSendMarkdown(
|
|
3154
|
+
(text, extra) => ctx.reply(text, extra),
|
|
3155
|
+
chunk,
|
|
3156
|
+
replyOpts
|
|
3157
|
+
);
|
|
3141
3158
|
}
|
|
3142
3159
|
}
|
|
3143
3160
|
} catch (err) {
|
|
@@ -3228,7 +3245,10 @@ ${state.processedIds.map((id) => `- ${id}`).join("\n")}` : "No previously proces
|
|
|
3228
3245
|
const fullMessage = header + response;
|
|
3229
3246
|
const chunks = splitMessage(fullMessage);
|
|
3230
3247
|
for (const chunk of chunks) {
|
|
3231
|
-
await
|
|
3248
|
+
await safeSendMarkdown(
|
|
3249
|
+
(text, extra) => bot.getBot().telegram.sendMessage(chatId, text, extra),
|
|
3250
|
+
chunk
|
|
3251
|
+
);
|
|
3232
3252
|
}
|
|
3233
3253
|
} catch (err) {
|
|
3234
3254
|
this.logger.error({ err, eventName }, "Failed to send heartbeat response via Telegram");
|