acpgram 1.19.5 → 1.19.6

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/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  A Telegram gateway to AI coding agents — **Gemini CLI**, **Claude Code**, **Antigravity CLI** and **OpenAI Codex**. The bot runs the agent as a subprocess on the machine where it is installed and talks to it over the [Agent Client Protocol](https://agentclientprotocol.com) (JSON-RPC over stdin/stdout). You write a task in Telegram; the agent works in the selected project on your server, PC or laptop, and you watch its progress, approve its actions and get the answer right in the chat.
20
20
 
21
- - No npm dependencies — plain Node.js 24 (built-in `node:sqlite`, `fetch`).
21
+ - No runtime npm dependencies — plain Node.js 24 (built-in `node:sqlite`, `fetch`); ESLint is used for development only.
22
22
  - Windows, Linux and macOS. Tested on Windows Server and Linux (Ubuntu in WSL); macOS uses the same code as Linux.
23
23
  - Multi-user: the main admin invites teammates and controls what each of them can do.
24
24
 
@@ -219,6 +219,7 @@ New teammates get only the default engine; the admin grants other engines and ca
219
219
 
220
220
  ```bash
221
221
  npm test # node:test, no dependencies, no Telegram
222
+ npm ci && npm run lint # ESLint (development-only), warnings are errors
222
223
  ```
223
224
 
224
225
  ```
package/README.ru.md CHANGED
@@ -288,6 +288,8 @@ journalctl -u gemini-bot -f
288
288
  npm test
289
289
  ```
290
290
 
291
+ Проверка кода линтером: `npm ci && npm run lint` (ESLint, только для разработки, предупреждения считаются ошибками).
292
+
291
293
  Встроенный `node:test`, без зависимостей и без Telegram: проверка выхода за корень проектов, учёта регистра в путях по правилам ОС, обмена с агентом (фиктивный ACP-агент) и завершения всего дерева его процессов, реестра движков (режимы по уровням доступа, проверка команд при старте), экранов `/start`, `/active` и карточки сотрудника.
292
294
 
293
295
  При старте бот проверяет все движки (`--version`): без движка по умолчанию не запускается, отсутствие остальных — только сообщение в логе.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acpgram",
3
- "version": "1.19.5",
3
+ "version": "1.19.6",
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",
@@ -47,6 +47,12 @@
47
47
  "service:uninstall": "node src/service.mjs uninstall",
48
48
  "service:status": "node src/service.mjs status",
49
49
  "test": "node --test \"test/**/*.test.mjs\"",
50
+ "lint": "eslint . --max-warnings 0",
50
51
  "prepublishOnly": "npm test"
52
+ },
53
+ "devDependencies": {
54
+ "@eslint/js": "^10.0.1",
55
+ "eslint": "^10.15.0",
56
+ "globals": "^17.14.0"
51
57
  }
52
58
  }
package/src/acp.mjs CHANGED
@@ -37,7 +37,9 @@ export function killTree(proc, graceMs = 3000) {
37
37
  const signal = (sig) => {
38
38
  try {
39
39
  process.kill(-proc.pid, sig);
40
- } catch {} // группа уже завершилась
40
+ } catch {
41
+ /* группа уже завершилась */
42
+ }
41
43
  };
42
44
  signal('SIGTERM');
43
45
  setTimeout(() => signal('SIGKILL'), graceMs).unref();
package/src/cli-i18n.mjs CHANGED
@@ -16,7 +16,7 @@ export function langFromLocale(value) {
16
16
  const id = parseInt(lcid[1], 16) & 0x3ff; // основной язык без региона
17
17
  return id === 0x19 ? 'ru' : id === 0x22 ? 'uk' : 'en';
18
18
  }
19
- const m = /^([a-z]{2,3})(?:[_@.\-]|$)/.exec(v);
19
+ const m = /^([a-z]{2,3})(?:[_@.-]|$)/.exec(v);
20
20
  if (!m) return null;
21
21
  return m[1] === 'ru' ? 'ru' : m[1] === 'uk' ? 'uk' : 'en';
22
22
  }
@@ -52,7 +52,9 @@ export function detectLang({ env = process.env, platform = process.platform, reg
52
52
  let v = null;
53
53
  try {
54
54
  v = reg(key, name);
55
- } catch {}
55
+ } catch {
56
+ /* параметра нет в реестре — пробуем следующий */
57
+ }
56
58
  const lang = v && langFromLocale(v.split(/\\0|\s/)[0]);
57
59
  if (lang) return lang;
58
60
  }
package/src/files.mjs CHANGED
@@ -42,6 +42,7 @@ export function describeAttachment(msg) {
42
42
  /** Безопасное имя файла: без путей, управляющих и запрещённых в Windows символов, зарезервированных имён. */
43
43
  export function safeFileName(name, fallback = 'file') {
44
44
  let n = basename(String(name ?? '').replace(/\\/g, '/'))
45
+ // eslint-disable-next-line no-control-regex -- управляющие символы в имени файла нужно заменять намеренно
45
46
  .replace(/[\u0000-\u001f<>:"/\\|?*]/g, '_')
46
47
  .replace(/^\.+/, '')
47
48
  .replace(/[. ]+$/, '')
@@ -87,7 +88,9 @@ export function cleanupOldFiles(root, maxAgeMs, now = Date.now()) {
87
88
  rmSync(p, { recursive: true, force: true });
88
89
  removed++;
89
90
  }
90
- } catch {}
91
+ } catch {
92
+ /* файл исчез или занят — пропускаем */
93
+ }
91
94
  }
92
95
  }
93
96
  return removed;
@@ -208,6 +211,7 @@ export function splitCode(text) {
208
211
 
209
212
  /** Заглушка на месте метки: туда потом встаёт сам файл (блок rich-сообщения). Символы \u0000 в ответе агента не встречаются. */
210
213
  export const filePlaceholder = (i) => `\u0000${i}\u0000`;
214
+ // eslint-disable-next-line no-control-regex -- \u0000 — служебная метка места файла в тексте ответа
211
215
  export const FILE_PLACEHOLDER = /\u0000(\d+)\u0000/g;
212
216
 
213
217
  /**
@@ -279,6 +283,7 @@ export function attachFiles(text, paths, { cwd, outbox, failText, onSkip = () =>
279
283
  };
280
284
  // заглушки, идущие подряд, вместе с пробелами и переводами строк вокруг → блоки через пустую строку;
281
285
  // остальной текст (и код в нём) не трогаем
286
+ // eslint-disable-next-line no-control-regex -- \u0000 — служебная метка места файла в тексте ответа
282
287
  const out = String(text ?? '').replace(/[ \t]*\n*(?:\u0000\d+\u0000[ \t]*\n*)+/g, (run) => {
283
288
  const blocks = [...run.matchAll(FILE_PLACEHOLDER)].map((m) => place(m[1])).filter(Boolean);
284
289
  return blocks.length ? `\n\n${blocks.join('\n\n')}\n\n` : '\n\n';
package/src/service.mjs CHANGED
@@ -6,7 +6,7 @@ import { homedir, userInfo } from 'node:os';
6
6
  import { join, posix } from 'node:path';
7
7
  import { spawnSync } from 'node:child_process';
8
8
  import { pathToFileURL } from 'node:url';
9
- import { APP, APP_DIR, DATA_DIR, HOME_DIR, MAIN_PATH } from './app.mjs';
9
+ import { APP, DATA_DIR, HOME_DIR, MAIN_PATH } from './app.mjs';
10
10
  import { tc } from './cli-i18n.mjs';
11
11
  import { decodeOutput, deleteFlagArgs, diagnoseCreate, findOnPath, isGarbled, parseDeleteFlag, parseOemCp, parseTasklistPid, serviceErrorCode, serviceExists, serviceState } from './winsvc.mjs';
12
12
 
package/src/setup.mjs CHANGED
@@ -7,7 +7,7 @@ import { dirname, isAbsolute, join, resolve } from 'node:path';
7
7
  import { spawnSync } from 'node:child_process';
8
8
  import { pathToFileURL } from 'node:url';
9
9
  import { parseEnv } from 'node:util';
10
- import { APP, APP_DIR, DATA_DIR, ENV_PATH, HOME_DIR } from './app.mjs';
10
+ import { APP, DATA_DIR, ENV_PATH, HOME_DIR } from './app.mjs';
11
11
  import { getCliLang, tc } from './cli-i18n.mjs';
12
12
  import { ENGINES, checkEngines } from './engines.mjs';
13
13
  import { prompter } from './prompt.mjs';
package/src/state.mjs CHANGED
@@ -328,7 +328,7 @@ async function startAgent(st, { resume } = {}) {
328
328
  if (closedByUser) throw new ClosedError();
329
329
  if (e.code === 'START_TIMEOUT') {
330
330
  log(`⚠️ ${engine.label} не запустился за ${START_TIMEOUT_MS / 1000} с — процесс завершён | пользователь`, st.userId);
331
- throw new Error(t('state.startTimeout', langOf(st.userId), { engine: engine.label, sec: START_TIMEOUT_MS / 1000 }));
331
+ throw new Error(t('state.startTimeout', langOf(st.userId), { engine: engine.label, sec: START_TIMEOUT_MS / 1000 }), { cause: e });
332
332
  }
333
333
  throw e;
334
334
  }
package/src/telegram.mjs CHANGED
@@ -43,7 +43,7 @@ export async function callApi(method, makeInit, { timeoutMs = TIMEOUT_MS, retrie
43
43
  const res = await fetchImpl(`${BASE}/${method}`, { method: 'POST', ...(await makeInit()), signal: signal ? AbortSignal.any([signal, limit]) : limit });
44
44
  data = await res.json();
45
45
  } catch (e) {
46
- if (limit.aborted && !signal?.aborted) throw new Error(`Telegram ${method}: нет ответа за ${Math.round(timeoutMs / 1000)} с`);
46
+ if (limit.aborted && !signal?.aborted) throw new Error(`Telegram ${method}: нет ответа за ${Math.round(timeoutMs / 1000)} с`, { cause: e });
47
47
  throw e;
48
48
  }
49
49
  if (data.ok) return data.result;
package/src/winsvc.mjs CHANGED
@@ -89,7 +89,7 @@ export function decodeOutput(buf, oemcp = 0) {
89
89
  const b = Buffer.from(buf);
90
90
  let zeroOdd = 0;
91
91
  for (let i = 1; i < b.length; i += 2) if (b[i] === 0) zeroOdd++;
92
- if (b.length >= 4 && zeroOdd >= b.length / 4) return b.toString('utf16le').replace(/^/, '');
92
+ if (b.length >= 4 && zeroOdd >= b.length / 4) return b.toString('utf16le').replace(/^\uFEFF/, '');
93
93
  const plain = b.includes(0) ? Buffer.from(b.filter((x) => x !== 0)) : b;
94
94
  try {
95
95
  return new TextDecoder('utf-8', { fatal: true }).decode(plain);