arena-bridge 0.7.17 → 0.7.18

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/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ All notable changes to this project are documented here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/) and the project uses
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## 0.7.18
8
+
9
+ ### Fixed
10
+ - Service reinstall is queued as an independent one-shot launchd job, so stopping the bridge does not kill its own installer. Submission errors are reported, and reload outcome is recorded separately.
11
+ - Native helper forwards SIGINT as SIGINT and SIGTERM as SIGTERM; signal handling and child exit status verified on macOS.
12
+
13
+ ### Documentation
14
+ - Clarified permission names, update caveats and screen-capture verification; recorded service lifecycle follow-up plan.
15
+
7
16
  ## 0.7.17
8
17
 
9
18
  ### Fixed
package/README.md CHANGED
@@ -319,16 +319,37 @@ Apple Silicon. Готовые сборки для обеих архитекту
319
319
 
320
320
  ### Разрешения macOS
321
321
 
322
- Мосту нужны два разрешения: «Запись экрана» (снимки) и «Управление доступностью» (дерево
323
- элементов). macOS записывает разрешение на того, кто запросил его сверху, поэтому служба моста
324
- стартует через маленький помощник внутри подписанного бандла приложения
325
- (`Arena Bridge.app/Contents/Helpers/arena-bridge-agent`). В списке «Запись экрана» такая строка
326
- называется как приложение — «Arena Bridge», а не `node`.
327
-
328
- Строку `node`, если она осталась от прежней установки, можно удалить кнопкой «−»: новая запись
329
- придёт под именем приложения, и её нужно один раз включить в настройках. Служба моста запускается
330
- из постоянных папок (`~/.local/share/fnm/node-versions/...`), а не из временной папки версии
331
- менеджера, поэтому разрешение само по себе не слетает.
322
+ Мосту нужны два разрешения в «Конфиденциальность и безопасность»:
323
+
324
+ - **Запись экрана и системного аудио** → включите **Arena Bridge**.
325
+ - **Универсальный доступ (Accessibility)** → включите **arena-bridge-agent**.
326
+
327
+ Это части одного приложения. После изменения разрешений может потребоваться перезапуск службы.
328
+ Старую запись `node` удаляйте только после проверки снимков и дерева элементов (`mac_see`).
329
+ Успешное сохранение PNG ещё не доказывает доступ: на снимке должно быть содержимое окон,
330
+ а не только обои. Без Accessibility снимок может работать, но дерево элементов будет пустым.
331
+
332
+ После установки приложения переустановите службу (`arena-bridge service install` с прежними
333
+ параметрами туннеля), чтобы она использовала помощник внутри бандла
334
+ (`Contents/Helpers/arena-bridge-agent`). Без приложения CLI продолжает работать, но названия
335
+ записей разрешений могут отличаться.
336
+
337
+ Стабильный путь к интерпретатору снижает риск потери разрешений, но не гарантирует их сохранение
338
+ после изменения подписи, пути или обновления приложения. Проверяйте разрешения для реально
339
+ запущенной установки. В частности, обновление ad-hoc-подписанного помощника может оставить
340
+ переключатели включёнными, но фактически лишить процесс доступа: выключите и снова включите
341
+ **Arena Bridge** в записи экрана и **arena-bridge-agent** в Accessibility, затем перезапустите службу.
342
+ Если это не помогло, удалите только эти две записи кнопкой «−» и добавьте заново через «+»:
343
+ `/Applications/Arena Bridge.app` и
344
+ `/Applications/Arena Bridge.app/Contents/Helpers/arena-bridge-agent` соответственно.
345
+ Не храните резервные сборки с тем же bundle id как зарегистрированные `.app`:
346
+ это затрудняет выбор нужной установки.
347
+
348
+ Переустановка службы выполняется отдельным одноразовым системным заданием через несколько
349
+ секунд после команды. Это позволяет переустанавливать мост через сам мост. `scheduled` означает
350
+ только постановку задания, не успешный запуск. Результат загрузки службы — в
351
+ `~/.arena-bridge/service-reload.status`, ошибки — в `~/.arena-bridge/logs/service-reload.err.log`.
352
+ Проверяйте также `arena-bridge service status` и `/health`: `loaded` ещё не гарантирует работу туннеля.
332
353
 
333
354
  ### Как переименовать
334
355
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arena-bridge",
3
- "version": "0.7.17",
3
+ "version": "0.7.18",
4
4
  "description": "Give a cloud AI agent (Arena.ai Agent Mode, Claude, Cursor, ...) controlled access to your own machine over HTTP/MCP: files, shell, Chrome and the macOS desktop, with an approval gate, trust windows and an audit log.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,9 +19,9 @@
19
19
  "node": ">=18"
20
20
  },
21
21
  "scripts": {
22
- "test": "node test/smoke.mjs && node test/browser.test.mjs && node test/mac.test.mjs",
23
- "test:node": "node test/smoke.mjs && node test/browser.test.mjs && node test/mac.test.mjs",
24
- "test:python": "python3 test/test_bridge.py && python3 test/test_browser.py && python3 test/test_mac.py",
22
+ "test": "node test/smoke.mjs && node test/browser.test.mjs && node test/mac.test.mjs && node test/service.test.mjs",
23
+ "test:node": "node test/smoke.mjs && node test/browser.test.mjs && node test/mac.test.mjs && node test/service.test.mjs",
24
+ "test:python": "python3 test/test_bridge.py && python3 test/test_browser.py && python3 test/test_mac.py && python3 test/test_service.py",
25
25
  "pack:check": "npm pack --dry-run"
26
26
  },
27
27
  "repository": {
package/src/cli.mjs CHANGED
@@ -495,7 +495,9 @@ function cmdService(args) {
495
495
  authtoken: args.flags.authtoken,
496
496
  port: args.flags.port,
497
497
  });
498
+ if (!res.ok) throw new Error(res.detail);
498
499
  console.log(`\u2713 service installed: ${res.plist}`);
500
+ console.log(' reload scheduled in 3 seconds; check: arena-bridge service status');
499
501
  console.log(' the bridge now starts with the system and keeps a public URL alive');
500
502
  console.log(' current URL: arena-bridge url');
501
503
  return;
package/src/direct.mjs CHANGED
@@ -73,7 +73,7 @@ export function createDirectServer(cfg, engine) {
73
73
  ok: true,
74
74
  mode: 'direct',
75
75
  device: cfg.device,
76
- version: '0.7.17',
76
+ version: '0.7.18',
77
77
  uptime_sec: Math.round(process.uptime()),
78
78
  });
79
79
  }
package/src/hub.mjs CHANGED
@@ -90,7 +90,7 @@ export function createHubServer(cfg) {
90
90
  return sendJson(res, 200, {
91
91
  ok: true,
92
92
  mode: 'hub',
93
- version: '0.7.17',
93
+ version: '0.7.18',
94
94
  devices: [...devices.keys()],
95
95
  });
96
96
  }
package/src/mcp.mjs CHANGED
@@ -48,7 +48,7 @@ export async function handleMcp(req, res, ctx) {
48
48
  mcpResponse(id, {
49
49
  protocolVersion: PROTOCOL_VERSION,
50
50
  capabilities: { tools: { listChanged: false } },
51
- serverInfo: { name: 'arena-bridge', version: '0.7.17' },
51
+ serverInfo: { name: 'arena-bridge', version: '0.7.18' },
52
52
  instructions:
53
53
  'Tools operate the user\'s own machine. Dangerous operations may return ' +
54
54
  'PROTECTED and require a local human approval.',
package/src/service.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import fs from 'node:fs';
2
+ import { randomUUID } from 'node:crypto';
2
3
  import os from 'node:os';
3
4
  import path from 'node:path';
4
5
  import { execFileSync } from 'node:child_process';
@@ -44,7 +45,10 @@ export function agentPath() {
44
45
  const bundle = appBundlePath();
45
46
  if (!bundle) return null;
46
47
  const helper = path.join(bundle, 'Contents', 'Helpers', AGENT_NAME);
47
- return fs.existsSync(helper) ? helper : null;
48
+ try {
49
+ fs.accessSync(helper, fs.constants.X_OK);
50
+ return fs.statSync(helper).isFile() ? helper : null;
51
+ } catch { return null; }
48
52
  }
49
53
 
50
54
  /**
@@ -112,6 +116,10 @@ export function programArguments({ bin, domain, authtoken, port } = {}) {
112
116
  return [runnerPath(), 'tunnel', ...extra];
113
117
  }
114
118
 
119
+ function xml(value) {
120
+ return String(value).replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
121
+ }
122
+
115
123
  export function plistXml(options = {}) {
116
124
  const logs = logDir();
117
125
  const program = programArguments(options);
@@ -122,15 +130,15 @@ export function plistXml(options = {}) {
122
130
  <key>Label</key><string>${LABEL}</string>
123
131
  <key>ProgramArguments</key>
124
132
  <array>
125
- ${program.map((a) => ` <string>${a}</string>`).join('\n')}
133
+ ${program.map((a) => ` <string>${xml(a)}</string>`).join('\n')}
126
134
  </array>
127
135
  <key>RunAtLoad</key><true/>
128
136
  <key>KeepAlive</key><true/>
129
- <key>StandardOutPath</key><string>${path.join(logs, 'bridge.log')}</string>
130
- <key>StandardErrorPath</key><string>${path.join(logs, 'bridge.err.log')}</string>
137
+ <key>StandardOutPath</key><string>${xml(path.join(logs, 'bridge.log'))}</string>
138
+ <key>StandardErrorPath</key><string>${xml(path.join(logs, 'bridge.err.log'))}</string>
131
139
  <key>EnvironmentVariables</key>
132
140
  <dict>
133
- <key>PATH</key><string>${servicePath()}</string>
141
+ <key>PATH</key><string>${xml(servicePath())}</string>
134
142
  </dict>
135
143
  </dict>
136
144
  </plist>
@@ -152,18 +160,32 @@ export function serviceStatus() {
152
160
  return { installed, running, plist: plistPath(), detail: out.trim().slice(0, 600) };
153
161
  }
154
162
 
163
+ export const reloadScript = "#!/bin/sh\nset -eu\nTARGET=$1\nPLIST=$2\nSTATUS=$3\nJOB=$4\nDOMAIN=${TARGET%/*}\nfinish() {\n code=$?\n trap - EXIT\n if [ \"$code\" -eq 0 ]; then printf 'loaded\\n' > \"$STATUS\"; else printf 'failed (%s)\\n' \"$code\" > \"$STATUS\"; fi\n rm -f \"$0\"\n /bin/launchctl remove \"$JOB\" >/dev/null 2>&1 || true\n exit \"$code\"\n}\ntrap finish EXIT\nprintf 'scheduled\\n' > \"$STATUS\"\nsleep 3\n/bin/launchctl enable \"$TARGET\"\nif /bin/launchctl print \"$TARGET\" >/dev/null 2>&1; then\n /bin/launchctl bootout \"$TARGET\"\nfi\nattempt=0\nuntil /bin/launchctl bootstrap \"$DOMAIN\" \"$PLIST\"; do\n attempt=$((attempt + 1))\n [ \"$attempt\" -lt 10 ] || exit 1\n sleep 1\ndone\n/bin/launchctl print \"$TARGET\" >/dev/null\n";
164
+
155
165
  export function serviceInstall(options = {}) {
156
166
  ensureDirs();
157
167
  fs.mkdirSync(logDir(), { recursive: true });
158
- const dir = path.dirname(plistPath());
159
- fs.mkdirSync(dir, { recursive: true });
168
+ fs.mkdirSync(path.dirname(plistPath()), { recursive: true });
160
169
  fs.writeFileSync(runnerPath(), runnerScript(), { mode: 0o755 });
161
170
  fs.chmodSync(runnerPath(), 0o755);
162
- fs.writeFileSync(plistPath(), plistXml(options));
163
- launchctl(['bootout', `gui/${process.getuid()}/${LABEL}`], { quiet: true });
164
- const out = launchctl(['bootstrap', `gui/${process.getuid()}`, plistPath()], { quiet: true });
165
- launchctl(['enable', `gui/${process.getuid()}/${LABEL}`], { quiet: true });
166
- return { ok: true, plist: plistPath(), detail: (out || '').trim().slice(0, 400) };
171
+ const plist = plistPath();
172
+ fs.writeFileSync(`${plist}.tmp`, plistXml(options), { mode: 0o600 });
173
+ fs.renameSync(`${plist}.tmp`, plist);
174
+ const job = `${LABEL}.reload.${randomUUID()}`;
175
+ const script = path.join(CONFIG_DIR, `${job}.sh`);
176
+ const status = path.join(CONFIG_DIR, 'service-reload.status');
177
+ fs.writeFileSync(script, reloadScript, { mode: 0o700 });
178
+ fs.writeFileSync(status, 'scheduled\n', { mode: 0o600 });
179
+ try {
180
+ execFileSync('launchctl', ['submit', '-l', job, '-o', path.join(logDir(), 'service-reload.log'),
181
+ '-e', path.join(logDir(), 'service-reload.err.log'), '--', '/bin/sh', script,
182
+ `gui/${process.getuid()}/${LABEL}`, plist, status, job], { encoding: 'utf8', timeout: 20000 });
183
+ } catch (e) {
184
+ fs.rmSync(script, { force: true });
185
+ fs.writeFileSync(status, 'submission failed\n');
186
+ return { ok: false, plist, detail: String(e.stderr || e.message).slice(0, 400) };
187
+ }
188
+ return { ok: true, scheduled: true, plist, status, detail: 'reload scheduled; check service status and service-reload.status' };
167
189
  }
168
190
 
169
191
  export function serviceUninstall() {