arena-bridge 0.7.14 → 0.7.16
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 +15 -0
- package/README.md +10 -1
- package/package.json +1 -1
- package/src/direct.mjs +1 -1
- package/src/hub.mjs +1 -1
- package/src/mcp.mjs +1 -1
- package/src/service.mjs +34 -2
- package/src/tunnel.mjs +40 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ 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.16
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- The tunnel takes the reserved domain back when an old ngrok process still holds it: only the
|
|
11
|
+
ngrok that serves our domain is stopped, the other tunnels of the user are untouched.
|
|
12
|
+
|
|
13
|
+
## 0.7.15
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- The background service starts from permanent folders only. The version manager keeps node in a
|
|
17
|
+
folder that every new shell creates and that is deleted afterwards, and macOS binds the
|
|
18
|
+
permission to the exact file: the service lost the screen recording permission when that
|
|
19
|
+
folder disappeared. The node of the permanent installation and the folder of the user are used
|
|
20
|
+
now, so the permission stays.
|
|
21
|
+
|
|
7
22
|
## 0.7.14
|
|
8
23
|
|
|
9
24
|
### Fixed
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="license">
|
|
13
13
|
<img src="https://img.shields.io/badge/node-%3E%3D18-green.svg?style=flat-square" alt="node">
|
|
14
14
|
<img src="https://img.shields.io/badge/dependencies-0-brightgreen.svg?style=flat-square" alt="dependencies">
|
|
15
|
-
<img src="https://img.shields.io/badge/tests-
|
|
15
|
+
<img src="https://img.shields.io/badge/tests-163%20passed-brightgreen.svg?style=flat-square" alt="tests">
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
18
|
<p align="center">
|
|
@@ -317,6 +317,15 @@ Apple Silicon. Готовые сборки для обеих архитекту
|
|
|
317
317
|
Иконка приложения лежит в `macos/ArenaBridge/Resources/AppIcon.png`; `build.sh` сам собирает
|
|
318
318
|
из неё `.icns` и кладёт в бандл. Вокруг знака прозрачно — на светлом фоне иконка не белая.
|
|
319
319
|
|
|
320
|
+
### Разрешения macOS
|
|
321
|
+
|
|
322
|
+
Мосту нужны два разрешения: «Запись экрана» (снимки) и «Управление доступностью» (дерево
|
|
323
|
+
элементов). В списке «Запись экрана» они выглядят как `node` и `daemon-*.sock` — так macOS
|
|
324
|
+
показывает программы без своего значка. Строку `node` можно удалить кнопкой «−», но вернётся
|
|
325
|
+
она, когда Peekaboo снова попросит экран: он написан на node. Служба моста запускается из
|
|
326
|
+
постоянных папок (`~/.local/share/fnm/node-versions/...`), а не из временной папки версии
|
|
327
|
+
менеджера, поэтому разрешение само по себе не слетает.
|
|
328
|
+
|
|
320
329
|
### Как переименовать
|
|
321
330
|
|
|
322
331
|
Имя приложения лежит в трёх местах, и тесты следят, чтобы они совпадали:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arena-bridge",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.16",
|
|
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": {
|
package/src/direct.mjs
CHANGED
package/src/hub.mjs
CHANGED
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.
|
|
51
|
+
serverInfo: { name: 'arena-bridge', version: '0.7.16' },
|
|
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
|
@@ -18,6 +18,38 @@ export function runnerPath() {
|
|
|
18
18
|
return path.join(CONFIG_DIR, APP_NAME);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* The node of the version manager lives in a folder that every new shell creates and that is
|
|
23
|
+
* deleted afterwards. macOS binds a permission to the exact file, so a service that starts from
|
|
24
|
+
* such a folder loses its screen recording permission. The service always uses the permanent
|
|
25
|
+
* installation instead.
|
|
26
|
+
*/
|
|
27
|
+
export function stableNode() {
|
|
28
|
+
const exec = process.execPath;
|
|
29
|
+
if (!exec.includes('fnm_multishells')) return exec;
|
|
30
|
+
const versions = path.join(os.homedir(), '.local', 'share', 'fnm', 'node-versions');
|
|
31
|
+
try {
|
|
32
|
+
const dirs = fs.readdirSync(versions)
|
|
33
|
+
.map((d) => path.join(versions, d))
|
|
34
|
+
.filter((d) => fs.existsSync(path.join(d, 'installation', 'bin', 'node')))
|
|
35
|
+
.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs);
|
|
36
|
+
if (dirs[0]) return path.join(dirs[0], 'installation', 'bin', 'node');
|
|
37
|
+
} catch {
|
|
38
|
+
/* keep the current one */
|
|
39
|
+
}
|
|
40
|
+
return exec;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The PATH of the service: permanent folders only. */
|
|
44
|
+
export function servicePath() {
|
|
45
|
+
const parts = (process.env.PATH || '/usr/local/bin:/usr/bin:/bin')
|
|
46
|
+
.split(':')
|
|
47
|
+
.filter((p) => p && !p.includes('fnm_multishells'));
|
|
48
|
+
const home = path.join(os.homedir(), '.local', 'bin');
|
|
49
|
+
const nodeBin = path.dirname(stableNode());
|
|
50
|
+
return [home, nodeBin, ...parts.filter((p) => p !== home && p !== nodeBin)].join(':');
|
|
51
|
+
}
|
|
52
|
+
|
|
21
53
|
export function logDir() {
|
|
22
54
|
return path.join(CONFIG_DIR, 'logs');
|
|
23
55
|
}
|
|
@@ -31,7 +63,7 @@ function cliEntry() {
|
|
|
31
63
|
function runnerScript() {
|
|
32
64
|
return `#!/bin/sh
|
|
33
65
|
# ${APP_NAME}: the background service of the bridge.
|
|
34
|
-
exec "${
|
|
66
|
+
exec "${stableNode()}" "${cliEntry()}" "$@"
|
|
35
67
|
`;
|
|
36
68
|
}
|
|
37
69
|
|
|
@@ -59,7 +91,7 @@ ${extra.map((a) => ` <string>${a}</string>`).join('\n')}
|
|
|
59
91
|
<key>StandardErrorPath</key><string>${path.join(logs, 'bridge.err.log')}</string>
|
|
60
92
|
<key>EnvironmentVariables</key>
|
|
61
93
|
<dict>
|
|
62
|
-
<key>PATH</key><string>${
|
|
94
|
+
<key>PATH</key><string>${servicePath()}</string>
|
|
63
95
|
</dict>
|
|
64
96
|
</dict>
|
|
65
97
|
</plist>
|
package/src/tunnel.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
1
|
+
import { spawn, execFileSync } from 'node:child_process';
|
|
2
2
|
import net from 'node:net';
|
|
3
3
|
|
|
4
4
|
const URL_RE = /https:\/\/[a-z0-9-]+\.trycloudflare\.com/i;
|
|
@@ -9,6 +9,40 @@ const NGROK_URL_RE = /https:\/\/[a-z0-9-]+\.ngrok(?:-free)?\.(?:app|io|dev)/i;
|
|
|
9
9
|
* cloudflared: QUIC (UDP/7844) is blocked on many networks, so we default to http2 over TCP/443.
|
|
10
10
|
* ngrok: an authtoken and an optional reserved domain give the same URL on every restart.
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* An old ngrok process keeps the reserved domain, and the new one cannot take it. Only the
|
|
14
|
+
* processes that serve our domain are stopped, never the other tunnels of the user.
|
|
15
|
+
*/
|
|
16
|
+
export function killStaleNgrok(domain) {
|
|
17
|
+
if (!domain) return [];
|
|
18
|
+
const killed = [];
|
|
19
|
+
let pids = [];
|
|
20
|
+
try {
|
|
21
|
+
pids = execFileSync('pgrep', ['-x', 'ngrok'], { encoding: 'utf8' })
|
|
22
|
+
.split('\n')
|
|
23
|
+
.map((s) => s.trim())
|
|
24
|
+
.filter(Boolean);
|
|
25
|
+
} catch {
|
|
26
|
+
return killed;
|
|
27
|
+
}
|
|
28
|
+
for (const pid of pids) {
|
|
29
|
+
let args = '';
|
|
30
|
+
try {
|
|
31
|
+
args = execFileSync('ps', ['-o', 'args=', '-p', pid], { encoding: 'utf8' });
|
|
32
|
+
} catch {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (!args.includes(domain)) continue;
|
|
36
|
+
try {
|
|
37
|
+
process.kill(Number(pid), 'SIGTERM');
|
|
38
|
+
killed.push(Number(pid));
|
|
39
|
+
} catch {
|
|
40
|
+
/* already gone */
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return killed;
|
|
44
|
+
}
|
|
45
|
+
|
|
12
46
|
export function startTunnel(
|
|
13
47
|
cfg,
|
|
14
48
|
{ port, protocol = 'http2', bin = 'cloudflared', authtoken, domain, restarts = 20, delay = 2000 } = {},
|
|
@@ -64,6 +98,11 @@ export function startTunnel(
|
|
|
64
98
|
});
|
|
65
99
|
child.on('exit', (code) => {
|
|
66
100
|
if (!settled) {
|
|
101
|
+
if (isNgrok && attempt++ < restarts) {
|
|
102
|
+
killStaleNgrok(domain);
|
|
103
|
+
setTimeout(spawnChild, delay);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
67
106
|
settled = true;
|
|
68
107
|
rejectUrl(new Error(`${bin} exited with code ${code} before the tunnel URL appeared`));
|
|
69
108
|
return;
|