appback-remoteagent 0.13.17 → 0.13.19

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/index.js CHANGED
@@ -161,7 +161,11 @@ async function startManualPollingScheduler(bots) {
161
161
  }
162
162
  while (true) {
163
163
  const now = Date.now();
164
+ let activePolls = [...runtimeStates.values()].filter((state) => state.inFlight).length;
164
165
  for (const bot of pollingBots) {
166
+ if (activePolls >= config.telegramPollingMaxConcurrency) {
167
+ break;
168
+ }
165
169
  const botId = String(bot.botInfo.id);
166
170
  const runtime = runtimeStates.get(botId);
167
171
  if (!runtime || runtime.inFlight) {
@@ -177,6 +181,7 @@ async function startManualPollingScheduler(bots) {
177
181
  continue;
178
182
  }
179
183
  runtime.inFlight = true;
184
+ activePolls += 1;
180
185
  void pollTelegramBot(bot, runtime, {
181
186
  isMain,
182
187
  totalBots: pollingBots.length,
@@ -1,5 +1,6 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import { randomUUID } from "node:crypto";
3
4
  const DEFAULT_STATE = {
4
5
  version: 1,
5
6
  updatedAt: "",
@@ -128,7 +129,7 @@ export class BotPollingStateService {
128
129
  async writeNow() {
129
130
  const state = await this.read();
130
131
  state.updatedAt = new Date().toISOString();
131
- const tmpPath = `${this.filePath}.${process.pid}.${Date.now()}.tmp`;
132
+ const tmpPath = `${this.filePath}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`;
132
133
  this.writeInFlight = this.writeInFlight.then(async () => {
133
134
  await fs.mkdir(path.dirname(this.filePath), { recursive: true });
134
135
  await fs.writeFile(tmpPath, `${JSON.stringify(state, null, 2)}\n`, "utf8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appback-remoteagent",
3
- "version": "0.13.17",
3
+ "version": "0.13.19",
4
4
  "description": "Personal installable session server for continuing local AI work across PC and Telegram",
5
5
  "license": "MIT",
6
6
  "type": "module",