appback-remoteagent 0.13.1 → 0.13.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/bot.js CHANGED
@@ -1030,12 +1030,11 @@ function sanitizeLoggedTelegramText(text) {
1030
1030
  async function runWithPendingAnimation(botToken, chatId, task) {
1031
1031
  let typingStopped = false;
1032
1032
  let typingTimer;
1033
- const typingStartedAt = Date.now();
1034
- const pulseTyping = () => {
1033
+ const pulseTyping = async () => {
1035
1034
  if (typingStopped) {
1036
1035
  return;
1037
1036
  }
1038
- void sendTelegramChatAction(botToken, chatId, "typing").catch((error) => {
1037
+ await sendTelegramChatAction(botToken, chatId, "typing").catch((error) => {
1039
1038
  if (isTelegramForbiddenError(error)) {
1040
1039
  console.warn(`[telegram-delivery] chat=${chatId} skipped typing action: ${error instanceof Error ? error.message : String(error)}`);
1041
1040
  typingStopped = true;
@@ -1043,12 +1042,14 @@ async function runWithPendingAnimation(botToken, chatId, task) {
1043
1042
  }
1044
1043
  console.warn(`[telegram-chat-action] chat=${chatId} failed: ${error instanceof Error ? error.message : String(error)}`);
1045
1044
  });
1046
- const elapsedMs = Date.now() - typingStartedAt;
1047
- const nextDelayMs = elapsedMs < 60_000 ? 4_000 : 30_000;
1048
- typingTimer = setTimeout(pulseTyping, nextDelayMs);
1045
+ typingTimer = setTimeout(() => {
1046
+ void pulseTyping();
1047
+ }, config.telegramTypingIntervalMs);
1049
1048
  typingTimer.unref?.();
1050
1049
  };
1051
- pulseTyping();
1050
+ await withTimeout(pulseTyping(), 1500).catch((error) => {
1051
+ console.warn(`[telegram-chat-action] chat=${chatId} initial typing action was not confirmed: ${error instanceof Error ? error.message : String(error)}`);
1052
+ });
1052
1053
  try {
1053
1054
  const helpers = {
1054
1055
  reportProgress: async (chunks, parseMode) => {
@@ -1470,6 +1471,23 @@ function formatProviderTimeoutFinalMessage(message) {
1470
1471
  async function sleep(ms) {
1471
1472
  await new Promise((resolve) => setTimeout(resolve, ms));
1472
1473
  }
1474
+ async function withTimeout(promise, timeoutMs) {
1475
+ let timer;
1476
+ try {
1477
+ return await Promise.race([
1478
+ promise,
1479
+ new Promise((_, reject) => {
1480
+ timer = setTimeout(() => reject(new Error(`Timed out after ${timeoutMs}ms`)), timeoutMs);
1481
+ timer.unref?.();
1482
+ }),
1483
+ ]);
1484
+ }
1485
+ finally {
1486
+ if (timer) {
1487
+ clearTimeout(timer);
1488
+ }
1489
+ }
1490
+ }
1473
1491
  async function ensureOwnerControlAccess(ctx) {
1474
1492
  if (ctx.chat?.type !== "private") {
1475
1493
  throw new Error("This command is available only in private 1:1 chats.");
package/dist/config.js CHANGED
@@ -136,6 +136,7 @@ export const config = {
136
136
  telegramPollingMaxConcurrency: readTimeout("TELEGRAM_POLLING_MAX_CONCURRENCY", 3),
137
137
  telegramOwnerId: readOptional("TELEGRAM_OWNER_ID"),
138
138
  telegramMessageBatchMs: readNonNegativeTimeout("TELEGRAM_MESSAGE_BATCH_MS", 1500),
139
+ telegramTypingIntervalMs: readTimeout("TELEGRAM_TYPING_INTERVAL_MS", 4_000),
139
140
  telegramAutoProgressMaxTurns: readOptionalNonNegativeInteger("TELEGRAM_AUTO_PROGRESS_MAX_TURNS") ?? 6,
140
141
  telegramEmptyResponseRetries: readOptionalNonNegativeInteger("TELEGRAM_EMPTY_RESPONSE_RETRIES") ?? 1,
141
142
  telegramRetryableErrorRetries: readOptionalNonNegativeInteger("TELEGRAM_RETRYABLE_ERROR_RETRIES") ?? 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appback-remoteagent",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "Personal installable session server for continuing local AI work across PC and Telegram",
5
5
  "license": "MIT",
6
6
  "type": "module",