arena-bridge 0.7.15 → 0.7.17
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 +14 -0
- package/README.md +12 -7
- package/package.json +1 -1
- package/src/app.mjs +3 -0
- package/src/direct.mjs +1 -1
- package/src/hub.mjs +1 -1
- package/src/mcp.mjs +1 -1
- package/src/service.mjs +45 -6
- package/src/tunnel.mjs +40 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ 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.17
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- The permission list of macOS shows the name of the app and not `node`. The background service now
|
|
11
|
+
starts through a small helper inside the signed app bundle, so macOS gives the screen and the
|
|
12
|
+
accessibility permissions to «Arena Bridge». Without the app the service starts the old way, so the
|
|
13
|
+
command line only installation keeps working.
|
|
14
|
+
|
|
15
|
+
## 0.7.16
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- The tunnel takes the reserved domain back when an old ngrok process still holds it: only the
|
|
19
|
+
ngrok that serves our domain is stopped, the other tunnels of the user are untouched.
|
|
20
|
+
|
|
7
21
|
## 0.7.15
|
|
8
22
|
|
|
9
23
|
### 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">
|
|
@@ -320,10 +320,14 @@ Apple Silicon. Готовые сборки для обеих архитекту
|
|
|
320
320
|
### Разрешения macOS
|
|
321
321
|
|
|
322
322
|
Мосту нужны два разрешения: «Запись экрана» (снимки) и «Управление доступностью» (дерево
|
|
323
|
-
элементов).
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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/...`), а не из временной папки версии
|
|
327
331
|
менеджера, поэтому разрешение само по себе не слетает.
|
|
328
332
|
|
|
329
333
|
### Как переименовать
|
|
@@ -332,12 +336,13 @@ Apple Silicon. Готовые сборки для обеих архитекту
|
|
|
332
336
|
|
|
333
337
|
| Файл | Что там |
|
|
334
338
|
| --- | --- |
|
|
335
|
-
| `src/app.mjs` | `APP_NAME`, `APP_ID`, `SERVICE_LABEL` — для командной строки |
|
|
339
|
+
| `src/app.mjs` | `APP_NAME`, `APP_ID`, `SERVICE_LABEL`, `AGENT_NAME` — для командной строки |
|
|
336
340
|
| `arena_bridge/app.py` | то же самое для Python |
|
|
337
341
|
| `macos/ArenaBridge/Sources/AppInfo.swift` | то же самое для приложения; `build.sh` берёт имя отсюда |
|
|
338
342
|
|
|
339
343
|
Фоновая служба в «Системных настройках → Вход» называется так же, как приложение, а не
|
|
340
|
-
«node» или «python»: запускает её
|
|
344
|
+
«node» или «python»: запускает её помощник внутри бандла приложения, а без приложения — небольшой
|
|
345
|
+
скрипт `~/.arena-bridge/Arena Bridge`.
|
|
341
346
|
|
|
342
347
|
---
|
|
343
348
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arena-bridge",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.17",
|
|
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/app.mjs
CHANGED
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.17' },
|
|
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
|
@@ -4,7 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import { execFileSync } from 'node:child_process';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { CONFIG_DIR, ensureDirs } from './config.mjs';
|
|
7
|
-
import { APP_NAME, SERVICE_LABEL as LABEL } from './app.mjs';
|
|
7
|
+
import { APP_NAME, SERVICE_LABEL as LABEL, AGENT_NAME } from './app.mjs';
|
|
8
8
|
|
|
9
9
|
export function plistPath() {
|
|
10
10
|
return path.join(os.homedir(), 'Library', 'LaunchAgents', `${LABEL}.plist`);
|
|
@@ -18,6 +18,35 @@ export function runnerPath() {
|
|
|
18
18
|
return path.join(CONFIG_DIR, APP_NAME);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* The app bundle that holds the helper. It gives the screen and the accessibility
|
|
23
|
+
* permissions to the app and not to the node binary.
|
|
24
|
+
*/
|
|
25
|
+
export function appBundlePath() {
|
|
26
|
+
const explicit = process.env.ARENA_BRIDGE_APP;
|
|
27
|
+
const candidates = explicit
|
|
28
|
+
? [explicit]
|
|
29
|
+
: [
|
|
30
|
+
path.join('/Applications', `${APP_NAME}.app`),
|
|
31
|
+
path.join(os.homedir(), 'Applications', `${APP_NAME}.app`),
|
|
32
|
+
];
|
|
33
|
+
for (const candidate of candidates) {
|
|
34
|
+
if (candidate && fs.existsSync(path.join(candidate, 'Contents', 'Info.plist'))) return candidate;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The helper inside the bundle starts the bridge. macOS gives the permissions to the
|
|
41
|
+
* app that starts the request, so the system settings show the name of the app.
|
|
42
|
+
*/
|
|
43
|
+
export function agentPath() {
|
|
44
|
+
const bundle = appBundlePath();
|
|
45
|
+
if (!bundle) return null;
|
|
46
|
+
const helper = path.join(bundle, 'Contents', 'Helpers', AGENT_NAME);
|
|
47
|
+
return fs.existsSync(helper) ? helper : null;
|
|
48
|
+
}
|
|
49
|
+
|
|
21
50
|
/**
|
|
22
51
|
* The node of the version manager lives in a folder that every new shell creates and that is
|
|
23
52
|
* deleted afterwards. macOS binds a permission to the exact file, so a service that starts from
|
|
@@ -67,13 +96,25 @@ exec "${stableNode()}" "${cliEntry()}" "$@"
|
|
|
67
96
|
`;
|
|
68
97
|
}
|
|
69
98
|
|
|
70
|
-
|
|
71
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The command the service starts. The helper inside the app bundle gives the screen and the
|
|
101
|
+
* accessibility permissions to the app, so the system settings show its name. Without the app
|
|
102
|
+
* the service starts the wrapper script.
|
|
103
|
+
*/
|
|
104
|
+
export function programArguments({ bin, domain, authtoken, port } = {}) {
|
|
72
105
|
const extra = [];
|
|
73
106
|
if (bin) extra.push('--bin', String(bin));
|
|
74
107
|
if (domain) extra.push('--domain', String(domain));
|
|
75
108
|
if (authtoken) extra.push('--authtoken', String(authtoken));
|
|
76
109
|
if (port) extra.push('--port', String(port));
|
|
110
|
+
const helper = agentPath();
|
|
111
|
+
if (helper) return [helper, stableNode(), cliEntry(), 'tunnel', ...extra];
|
|
112
|
+
return [runnerPath(), 'tunnel', ...extra];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function plistXml(options = {}) {
|
|
116
|
+
const logs = logDir();
|
|
117
|
+
const program = programArguments(options);
|
|
77
118
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
78
119
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
79
120
|
<plist version="1.0">
|
|
@@ -81,9 +122,7 @@ export function plistXml({ bin, domain, authtoken, port } = {}) {
|
|
|
81
122
|
<key>Label</key><string>${LABEL}</string>
|
|
82
123
|
<key>ProgramArguments</key>
|
|
83
124
|
<array>
|
|
84
|
-
<string>${
|
|
85
|
-
<string>tunnel</string>
|
|
86
|
-
${extra.map((a) => ` <string>${a}</string>`).join('\n')}
|
|
125
|
+
${program.map((a) => ` <string>${a}</string>`).join('\n')}
|
|
87
126
|
</array>
|
|
88
127
|
<key>RunAtLoad</key><true/>
|
|
89
128
|
<key>KeepAlive</key><true/>
|
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;
|