arena-bridge 0.19.0 → 0.19.1
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 +9 -0
- package/package.json +1 -1
- package/src/config.mjs +26 -6
- package/src/state.mjs +6 -6
- package/src/version.mjs +1 -1
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.19.1
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- Removed the remaining Swift compiler warnings from the macOS app build.
|
|
11
|
+
- Config and runtime state recover a valid temporary atomic-write file after an interrupted replacement.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Node CI now runs on versions 18, 20, and 24 on both Ubuntu and macOS.
|
|
15
|
+
|
|
7
16
|
## 0.19.0
|
|
8
17
|
|
|
9
18
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arena-bridge",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.1",
|
|
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/config.mjs
CHANGED
|
@@ -71,11 +71,31 @@ export function ensureDirs() {
|
|
|
71
71
|
fs.mkdirSync(APPROVALS_DIR, { recursive: true, mode: 0o700 });
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
function readJson(file) {
|
|
75
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Read an atomic file and recover a complete temporary replacement after interruption. */
|
|
79
|
+
export function readJsonWithRecovery(file) {
|
|
80
|
+
try {
|
|
81
|
+
return readJson(file);
|
|
82
|
+
} catch (primaryError) {
|
|
83
|
+
const tmp = `${file}.tmp`;
|
|
84
|
+
try {
|
|
85
|
+
const recovered = readJson(tmp);
|
|
86
|
+
fs.renameSync(tmp, file);
|
|
87
|
+
return recovered;
|
|
88
|
+
} catch {
|
|
89
|
+
throw primaryError;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
74
94
|
export function loadConfig() {
|
|
75
95
|
let fileCfg = {};
|
|
76
|
-
if (fs.existsSync(CONFIG_PATH)) {
|
|
96
|
+
if (fs.existsSync(CONFIG_PATH) || fs.existsSync(`${CONFIG_PATH}.tmp`)) {
|
|
77
97
|
try {
|
|
78
|
-
fileCfg =
|
|
98
|
+
fileCfg = readJsonWithRecovery(CONFIG_PATH);
|
|
79
99
|
} catch (e) {
|
|
80
100
|
throw new Error(`Invalid config file ${CONFIG_PATH}: ${e.message}`);
|
|
81
101
|
}
|
|
@@ -83,8 +103,8 @@ export function loadConfig() {
|
|
|
83
103
|
// Merge state (publicUrl) — state wins if config doesn't have it, for backward compat
|
|
84
104
|
try {
|
|
85
105
|
const statePath = path.join(CONFIG_DIR, 'state.json');
|
|
86
|
-
|
|
87
|
-
|
|
106
|
+
if (fs.existsSync(statePath) || fs.existsSync(`${statePath}.tmp`)) {
|
|
107
|
+
const state = readJsonWithRecovery(statePath);
|
|
88
108
|
if (state.publicUrl && !fileCfg.publicUrl) fileCfg.publicUrl = state.publicUrl;
|
|
89
109
|
// also expose state for debug
|
|
90
110
|
fileCfg._state = state;
|
|
@@ -104,7 +124,7 @@ export function saveConfig(cfg) {
|
|
|
104
124
|
try {
|
|
105
125
|
const statePath = path.join(CONFIG_DIR, 'state.json');
|
|
106
126
|
let state = {};
|
|
107
|
-
try { state =
|
|
127
|
+
try { state = readJsonWithRecovery(statePath); } catch {}
|
|
108
128
|
if (cfg.publicUrl) state.publicUrl = cfg.publicUrl;
|
|
109
129
|
else delete state.publicUrl;
|
|
110
130
|
fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
@@ -114,7 +134,7 @@ export function saveConfig(cfg) {
|
|
|
114
134
|
} catch {}
|
|
115
135
|
}
|
|
116
136
|
let existing = {};
|
|
117
|
-
try { existing =
|
|
137
|
+
try { existing = readJsonWithRecovery(CONFIG_PATH); } catch {}
|
|
118
138
|
const out = { ...existing };
|
|
119
139
|
for (const [k, v] of Object.entries(cfg)) {
|
|
120
140
|
if (k === 'configPath' || k === '_state' || k === 'publicUrl') continue;
|
package/src/state.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { CONFIG_DIR, CONFIG_PATH } from './config.mjs';
|
|
3
|
+
import { CONFIG_DIR, CONFIG_PATH, readJsonWithRecovery } from './config.mjs';
|
|
4
4
|
|
|
5
5
|
export const STATE_PATH = path.join(CONFIG_DIR, 'state.json');
|
|
6
6
|
|
|
7
7
|
export function loadState() {
|
|
8
8
|
try {
|
|
9
|
-
if (fs.existsSync(STATE_PATH)) {
|
|
10
|
-
return
|
|
9
|
+
if (fs.existsSync(STATE_PATH) || fs.existsSync(`${STATE_PATH}.tmp`)) {
|
|
10
|
+
return readJsonWithRecovery(STATE_PATH);
|
|
11
11
|
}
|
|
12
12
|
} catch {}
|
|
13
13
|
return {};
|
|
@@ -15,11 +15,11 @@ export function loadState() {
|
|
|
15
15
|
|
|
16
16
|
export function saveState(patch) {
|
|
17
17
|
let cur = {};
|
|
18
|
-
try { cur =
|
|
18
|
+
try { cur = readJsonWithRecovery(STATE_PATH); } catch {}
|
|
19
19
|
// migrate publicUrl from config.json if present and not in state
|
|
20
20
|
if (!cur.publicUrl && fs.existsSync(CONFIG_PATH)) {
|
|
21
21
|
try {
|
|
22
|
-
const cfg =
|
|
22
|
+
const cfg = readJsonWithRecovery(CONFIG_PATH);
|
|
23
23
|
if (cfg.publicUrl) {
|
|
24
24
|
cur.publicUrl = cfg.publicUrl;
|
|
25
25
|
// remove from config to complete migration (best effort)
|
|
@@ -125,7 +125,7 @@ export function stopPid(pid, waitMs = 3000) {
|
|
|
125
125
|
|
|
126
126
|
export function clearStateKey(key) {
|
|
127
127
|
let cur = {};
|
|
128
|
-
try { cur =
|
|
128
|
+
try { cur = readJsonWithRecovery(STATE_PATH); } catch {}
|
|
129
129
|
if (key in cur) {
|
|
130
130
|
delete cur[key];
|
|
131
131
|
const tmp = STATE_PATH + '.tmp';
|