acpgram 1.19.1 → 1.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acpgram",
3
- "version": "1.19.1",
3
+ "version": "1.19.2",
4
4
  "type": "module",
5
5
  "description": "Telegram gateway to AI coding agents (Gemini CLI, Claude Code, Antigravity CLI, Codex) over the Agent Client Protocol",
6
6
  "license": "MIT",
package/src/i18n.mjs CHANGED
@@ -213,6 +213,16 @@ const M = {
213
213
  'ses.list': { en: 'Sessions of project {p}.\nChoose which one to return to:', ru: 'Сессии проекта {p}.\nВыберите, к какой вернуться:', uk: 'Сесії проєкту {p}.\nОберіть, до якої повернутися:' },
214
214
  'ses.reqs': { en: '{n} req.', ru: '{n} запр.', uk: '{n} запит.' },
215
215
  'ses.alreadyActive': { en: 'This session is already active', ru: 'Эта сессия уже активна', uk: 'Ця сесія вже активна' },
216
+ 'ses.movedAway': {
217
+ en: '↪️ This session was continued in another dialog, so it was closed here. The next request here starts a new session.',
218
+ ru: '↪️ Эту сессию продолжили в другом диалоге, поэтому здесь она закрыта. Следующий запрос здесь начнёт новую сессию.',
219
+ uk: '↪️ Цю сесію продовжили в іншому діалозі, тому тут її закрито. Наступний запит тут почне нову сесію.',
220
+ },
221
+ 'ses.busyElsewhere': {
222
+ en: '⏳ This session is answering a request in another dialog right now. Wait for the answer or /stop it there, then try again.',
223
+ ru: '⏳ Эта сессия сейчас отвечает на запрос в другом диалоге. Дождитесь ответа или остановите его там (/stop) и повторите.',
224
+ uk: '⏳ Ця сесія зараз відповідає на запит в іншому діалозі. Дочекайтеся відповіді або зупиніть його там (/stop) і повторіть.',
225
+ },
216
226
  'ses.notFound': { en: 'The session was not found or belongs to another project. Run /sessions again.', ru: 'Сессия не найдена или относится к другому проекту. Вызовите /sessions заново.', uk: 'Сесію не знайдено або вона належить іншому проєкту. Викличте /sessions знову.' },
217
227
  'ses.engineDown': { en: '{engine} is unavailable on the server right now — the session cannot be resumed.', ru: '{engine} сейчас недоступен на сервере — сессию не возобновить.', uk: '{engine} зараз недоступний на сервері — сесію не відновити.' },
218
228
  'ses.engineOff': { en: 'The {engine} engine is not granted to you right now — the session cannot be resumed. Contact the administrator.', ru: 'Движок {engine} вам сейчас не выдан — сессию не возобновить. Обратитесь к администратору.', uk: 'Рушій {engine} вам зараз не видано — сесію не відновити. Зверніться до адміністратора.' },
package/src/state.mjs CHANGED
@@ -256,7 +256,33 @@ export async function ensureAgent(st, { resume } = {}) {
256
256
  }
257
257
  }
258
258
 
259
+ /**
260
+ * Одна сессия агента — в одном диалоге. Перед возобновлением сессии sessionId в диалоге st она закрывается во всех
261
+ * других диалогах пользователя (General, другие темы): иначе два процесса агента писали бы в одну историю.
262
+ * Там, где сессия работала, — короткое сообщение; там, где она только ждала возобновления, — тихо забываем.
263
+ * Занятый запросом диалог не трогаем: LimitError — пусть сначала закончит или будет остановлен.
264
+ */
265
+ export function releaseSessionElsewhere(st, sessionId) {
266
+ if (!sessionId) return;
267
+ const lang = langOf(st.userId);
268
+ for (const other of statesOf(st.userId)) {
269
+ if (other === st) continue;
270
+ const live = other.agent && !other.agent.closed && other.agent.sessionId === sessionId;
271
+ if (live) {
272
+ if (other.busy) throw new LimitError(t('ses.busyElsewhere', lang));
273
+ dropPermissions(other);
274
+ endAgent(other, 'moved');
275
+ log('сессия', sessionId, 'перенесена в другой диалог и закрыта здесь | пользователь', st.userId, '| тема', other.topic);
276
+ say(other.to, t('ses.movedAway', lang));
277
+ } else if (other.resumeId === sessionId) {
278
+ other.resumeId = null;
279
+ if (other.topic) db.saveTopic(other.userId, other.topic, { acpSessionId: '' });
280
+ }
281
+ }
282
+ }
283
+
259
284
  async function startAgent(st, { resume } = {}) {
285
+ releaseSessionElsewhere(st, resume);
260
286
  reserveSlot(st);
261
287
  const engine = engineOf(st);
262
288
  const allowed = modeFor(st.userId, engine);