arena-bridge 0.20.7 → 0.21.0

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/src/cli.mjs CHANGED
@@ -15,7 +15,16 @@ import { pruneApprovals } from './approvals.mjs';
15
15
  import { startTunnel, isPortOpen, killStaleTunnel, killTunnelsForPort, listenerPid } from './tunnel.mjs';
16
16
  import { readPid, writePid, clearPid, pidAlive, pidArgs, pidParent, stopPid } from './state.mjs';
17
17
  import { spawn, execSync, spawnSync } from 'node:child_process';
18
- import { parseDuration, trustState, openTrust, closeTrust, reconcileTrust } from './trust.mjs';
18
+ // Local duration parser ('30m' | '2h' | '1d' | '90' minutes -> ms).
19
+ // (Previously in trust.mjs; the trust window is removed.)
20
+ function parseDuration(value) {
21
+ if (value === undefined || value === null || value === true) return 60 * 60 * 1000;
22
+ const raw = String(value).trim().toLowerCase();
23
+ const m = /^(\d+(?:\.\d+)?)\s*(s|m|h|d)?$/.exec(raw);
24
+ if (!m) throw new Error(`cannot parse duration: ${value}`);
25
+ const factor = { s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000 }[m[2] || 'm'];
26
+ return Math.round(parseFloat(m[1]) * factor);
27
+ }
19
28
  import { bridgeEvent, tunnelEvent } from './lifecycle.mjs';
20
29
  import { findPeekaboo, permissionStatus } from './mac.mjs';
21
30
  import { coldStartMs, mem, uptimeSec } from './telemetry.mjs';
@@ -150,11 +159,6 @@ Commands:
150
159
  approvals [--json] List approval requests (or: approvals prune [--days 14])
151
160
  approve <id> Approve a pending request (--deny to refuse)
152
161
  rotate Generate a new agent token (--device for the device token)
153
- trust Open a trust window (use --history to see past windows)
154
- --for 2h how long (30m, 2h, 1d)
155
- --tools a,b only these tools (default: all)
156
- --paths p1,p2 only these paths (bash is not covered)
157
- --off | --status | --extend --for 1h
158
162
  audit [-n N] [--tool NAME] [--since DUR] [--from DATE] [--to DATE] [--json] Show the audit log
159
163
  cleanup [--days N] Remove old artifacts + approvals (default 7 days)
160
164
  events [--json] Stream live events (approvals/audit) via SSE /v1/events
@@ -169,7 +173,7 @@ Commands:
169
173
  poll listen for messages in the foreground
170
174
  doctor [--fix] Check the installation and configuration (--fix repairs perms/dirs)
171
175
  permissions [--json] Check macOS Screen Recording and Accessibility for the bridge (exit 3 if missing)
172
- status [--json] One-line runtime status (config, url, trust, approvals, service)
176
+ status [--json] One-line runtime status (config, url, approvals, service)
173
177
  url Print the public URL the agent should use
174
178
  open Open the public URL in the browser
175
179
  version Show the installed version and the latest one on npm
@@ -192,7 +196,7 @@ Common options:
192
196
  --bin PATH tunnel binary to run (default: cloudflared; "ngrok" is supported too)
193
197
  --authtoken TOKEN ngrok authtoken (keeps the same URL on every restart)
194
198
  --domain NAME ngrok reserved domain, e.g. my-machine.ngrok-free.app
195
- --no-approval disable the human approval gate (dangerous)
199
+ --no-approval (deprecated, no-op) approvals are disabled
196
200
  --no-shell disable shell execution entirely
197
201
 
198
202
  Config file: ${CONFIG_DIR}/config.json
@@ -241,10 +245,10 @@ function cmdInit(args) {
241
245
  console.log(`✓ config written to ${path.join(CONFIG_DIR, 'config.json')} (mode=${cfg.mode})`);
242
246
  console.log(` agent token : ${cfg.token}`);
243
247
  console.log(` device token: ${cfg.deviceToken}`);
244
- console.log(` local token : ${cfg.localToken} (local only: approvals and trust, never given to the agent)`);
248
+ console.log(` local token : ${cfg.localToken} (local only: historical approvals, never given to the agent)`);
245
249
  console.log(` device name : ${cfg.device}`);
246
250
  console.log(` roots : ${cfg.roots.join(', ')}`);
247
- console.log(` approval : ${cfg.requireApproval ? 'required for side-effecting tools' : 'DISABLED'}`);
251
+ console.log(` approval : DISABLED (if the service is running, everything is allowed)`);
248
252
  console.log(`\nNext: arena-bridge start (then expose it with a tunnel)`);
249
253
  }
250
254
 
@@ -277,15 +281,6 @@ async function cmdStart(args) {
277
281
  console.error('✗ no token in config — run "arena-bridge init" first');
278
282
  process.exit(1);
279
283
  }
280
- try {
281
- const { trustState, openTrust } = await import('./trust.mjs');
282
- const st = trustState();
283
- if (!st.active) {
284
- const now = Date.now();
285
- openTrust({ until: now + 3 * 3600 * 1000, tools: [], paths: [], createdAt: now }, { via: 'launch', source: { channel: 'local' } });
286
- console.log('✓ trust window auto-opened for 3 h (all tools, any agent) — no approvals needed');
287
- }
288
- } catch {}
289
284
  const engine = new Engine(cfg, { base: cfg.roots?.[0] || os.homedir() });
290
285
  const server = createDirectServer(cfg, engine);
291
286
  server.on('error', (e) => {
@@ -336,17 +331,6 @@ async function cmdTunnel(args) {
336
331
  const domain = (args.flags.domain !== undefined ? String(args.flags.domain) : cfg.tunnel?.domain) || undefined;
337
332
  const engine = new Engine(cfg, { base: cfg.roots?.[0] || os.homedir() });
338
333
 
339
- // Auto-open blanket trust window on start (3h, all tools, any agent) per user request
340
- try {
341
- const { trustState, openTrust } = await import('./trust.mjs');
342
- const st = trustState();
343
- if (!st.active) {
344
- const now = Date.now();
345
- openTrust({ until: now + 3 * 3600 * 1000, tools: [], paths: [], createdAt: now }, { via: 'launch', source: { channel: 'local' } });
346
- console.log('✓ trust window auto-opened for 3 h (all tools, any agent) — no approvals needed');
347
- }
348
- } catch {}
349
-
350
334
  let server = null;
351
335
  let tunnel = null;
352
336
  let publicUrl = null;
@@ -547,72 +531,6 @@ function cmdApprove(args) {
547
531
  console.log(`✓ ${r.approval.tool} ${r.approval.status} (${id})`);
548
532
  }
549
533
 
550
- function cmdTrust(args) {
551
- const state = trustState();
552
- reconcileTrust();
553
- const via = /^[a-z]{1,20}$/.test(String(args.flags.source || '')) ? args.flags.source : 'cli';
554
- const source = { channel: 'cli' };
555
- if (args.flags.extend || args.flags.extend) {
556
- const cur = trustState();
557
- if (!cur.active) { console.error('no active trust window to extend — use arena-bridge trust --for 2h'); process.exit(1); }
558
- const ms = parseDuration(args.flags.for || args.flags.extend || '1h');
559
- const saved = openTrust({ ...cur, until: cur.until + ms, createdAt: cur.createdAt || Date.now() }, { via, source });
560
- console.log(`✓ trust window extended: until ${new Date(saved.until).toLocaleString()} (+${Math.round(ms/60000)} min)`);
561
- return;
562
- }
563
- if (args.flags.history) {
564
- try {
565
- const hist = path.join(CONFIG_DIR, 'trust.history.json');
566
- if (!fs.existsSync(hist)) { console.log('no trust history yet'); return; }
567
- const data = JSON.parse(fs.readFileSync(hist,'utf8'));
568
- if (args.flags.json) console.log(JSON.stringify(data, null, 2));
569
- else { for (const h of data.slice(-20)) console.log(`${new Date(h.until).toLocaleString()} ${h.tools.length? h.tools.join(','):'all'} ${h.paths.length? h.paths.join(','):''} ${h.by||''}`); }
570
- } catch (e) { console.error(e.message); }
571
- return;
572
- }
573
- if (args.flags.off) {
574
- closeTrust({ via, source });
575
- console.log('✓ trust window cleared — every side-effecting action needs approval again');
576
- return;
577
- }
578
- if (args.flags.status || (!args.flags.for && !args.flags.tools && !args.flags.paths)) {
579
- if (args.flags.json) {
580
- const remaining = state && state.active ? Math.max(0, Math.round((state.until - Date.now()) / 1000)) : 0;
581
- console.log(
582
- JSON.stringify({
583
- enabled: !!(state && state.active),
584
- until: state && state.active ? state.until : null,
585
- remaining_sec: remaining,
586
- tools: state ? state.tools : [],
587
- paths: state ? state.paths : [],
588
- }),
589
- );
590
- return;
591
- }
592
- if (!state || !state.active) {
593
- console.log('no active trust window (every side-effecting action needs approval)');
594
- } else {
595
- console.log(`✓ trust window active until ${new Date(state.until).toLocaleString()}`);
596
- console.log(` tools: ${state.tools.length ? state.tools.join(', ') : 'all side-effecting tools'}`);
597
- console.log(` paths: ${state.paths.length ? state.paths.join(', ') : 'no path restriction'}`);
598
- }
599
- return;
600
- }
601
- const ms = parseDuration(args.flags.for);
602
- const list = (v) =>
603
- String(v || '')
604
- .split(',')
605
- .map((s) => s.trim())
606
- .filter(Boolean);
607
- const tools = list(args.flags.tools);
608
- const paths = list(args.flags.paths).map((p) => path.resolve(p.replace(/^~/, os.homedir())));
609
- const saved = openTrust({ until: Date.now() + ms, tools, paths, createdAt: Date.now() }, { via, source });
610
- console.log(`✓ trust window: until ${new Date(saved.until).toLocaleString()} (${Math.round(ms / 60000)} min)`);
611
- console.log(` tools: ${tools.length ? tools.join(', ') : 'all side-effecting tools'}`);
612
- console.log(` paths: ${paths.length ? paths.join(', ') : 'no path restriction'}`);
613
- console.log(' the agent can now act without asking; run "arena-bridge trust --off" to stop');
614
- }
615
-
616
534
  function cmdAudit(args) {
617
535
  const what = args._[1];
618
536
  if (what === 'dir') {
@@ -743,10 +661,6 @@ function cmdStatus(args) {
743
661
  checks.push({ name: 'config', ok: hasConfig, detail: hasConfig ? CONFIG_DIR : 'missing — run arena-bridge init' });
744
662
  checks.push({ name: 'token', ok: !!cfg.token, detail: cfg.token ? 'present' : 'MISSING' });
745
663
  checks.push({ name: 'publicUrl', ok: !!cfg.publicUrl, detail: cfg.publicUrl || 'not set — run arena-bridge tunnel' });
746
- try {
747
- const st = trustState();
748
- checks.push({ name: 'trust window', ok: !!st.active, detail: st.active ? `active until ${new Date(st.until).toLocaleString()}` : 'none (approvals required)' });
749
- } catch {}
750
664
  try {
751
665
  const pending = listApprovals().filter(a => a.status==='pending').length;
752
666
  checks.push({ name: 'pending approvals', ok: true, detail: `${pending} pending` });
@@ -759,7 +673,7 @@ function cmdStatus(args) {
759
673
  if (isJson) {
760
674
  console.log(JSON.stringify({ ok: checks.every(c=>c.ok && c.name!=='pending approvals' && c.name!=='API port'), checks, version: cfg._state?.version || undefined, publicUrl: cfg.publicUrl || null }, null, 2));
761
675
  } else {
762
- for (const c of checks) console.log(`${c.ok ? '✓' : (c.name==='trust window' || c.name==='publicUrl' ? '○' : '✗')} ${c.name.padEnd(18)} ${c.detail}`);
676
+ for (const c of checks) console.log(`${c.ok ? '✓' : (c.name==='publicUrl' ? '○' : '✗')} ${c.name.padEnd(18)} ${c.detail}`);
763
677
  console.log(`\nPublic URL: ${cfg.publicUrl || '(not set)'}`);
764
678
  if (!cfg.publicUrl) console.log('Run: arena-bridge tunnel or arena-bridge service install');
765
679
  }
@@ -1197,7 +1111,7 @@ function cmdDoctor(args) {
1197
1111
  checks.push({ name: 'device token', code: 'device_token', passed: !!cfg.deviceToken, detail: cfg.deviceToken ? 'present' : 'MISSING', hint: 'run arena-bridge init' });
1198
1112
  checks.push({ name: 'mode', code: 'mode', passed: !!cfg.mode, detail: cfg.mode, hint: '' });
1199
1113
  checks.push({ name: 'filesystem paths', code: 'filesystem_paths', passed: true, detail: 'not restricted by configured roots', hint: '' });
1200
- checks.push({ name: 'approval gate', code: 'approval_gate', passed: cfg.requireApproval !== false, detail: cfg.requireApproval ? 'on' : 'OFF (dangerous)', hint: 'set requireApproval=true in config' });
1114
+ checks.push({ name: 'approval gate', code: 'approval_gate', passed: true, detail: 'disabled — if the service is running, everything is allowed' });
1201
1115
  checks.push({ name: 'shell', code: 'shell', passed: cfg.allowShell !== false, detail: cfg.allowShell ? 'on' : 'off', hint: '' });
1202
1116
  checks.push({ name: 'protected paths', code: 'protected', passed: (cfg.protected || []).length > 0, detail: `${(cfg.protected || []).length} entries`, hint: '' });
1203
1117
  // config validate as doctor checks
@@ -1287,8 +1201,6 @@ export async function main(argv = process.argv.slice(2)) {
1287
1201
  return cmdTelegram(args);
1288
1202
  case 'rotate':
1289
1203
  return cmdRotate(args);
1290
- case 'trust':
1291
- return cmdTrust(args);
1292
1204
  case 'doctor':
1293
1205
  return cmdDoctor(args);
1294
1206
  case 'permissions':
@@ -6,8 +6,8 @@ export const COMPLETION_BASH = `# arena-bridge bash completion
6
6
  _arena_bridge_complete() {
7
7
  local cur prev words cword
8
8
  _init_completion || return
9
- local cmds="setup init start tunnel hub connect prompt tools approvals approve rotate trust audit config telegram doctor url version update service browser completion help"
10
- local flags="--mode --device --root --port --host --hub --public-url --protocol --bin --authtoken --domain --no-approval --no-shell --for --tools --paths --off --status --json --help"
9
+ local cmds="setup init start tunnel hub connect prompt tools approvals approve rotate audit config telegram doctor url version update service browser completion help"
10
+ local flags="--mode --device --root --port --host --hub --public-url --protocol --bin --authtoken --domain --no-approval --no-shell --status --json --help"
11
11
  if [[ $cword == 1 ]]; then
12
12
  COMPREPLY=( $(compgen -W "$cmds" -- "$cur") )
13
13
  return
@@ -15,7 +15,6 @@ _arena_bridge_complete() {
15
15
  local cmd="\${words[1]}"
16
16
  case "$cmd" in
17
17
  config) COMPREPLY=( $(compgen -W "list get set edit" -- "$cur") ) ;;
18
- trust) COMPREPLY=( $(compgen -W "--for --tools --paths --off --status --json" -- "$cur") ) ;;
19
18
  telegram) COMPREPLY=( $(compgen -W "setup test status inbox poll" -- "$cur") ) ;;
20
19
  service) COMPREPLY=( $(compgen -W "install uninstall status" -- "$cur") ) ;;
21
20
  browser) COMPREPLY=( $(compgen -W "list login close open" -- "$cur") ) ;;
@@ -48,7 +47,6 @@ _arena_bridge() {
48
47
  "tools:Print tool catalog"
49
48
  "approvals:List pending approvals"
50
49
  "approve:Approve a pending request"
51
- "trust:Manage trust window"
52
50
  "audit:Show audit log"
53
51
  "config:Manage configuration"
54
52
  "telegram:Telegram integration"
@@ -65,7 +63,6 @@ _arena_bridge() {
65
63
  args)
66
64
  case "$words[1]" in
67
65
  config) _describe -t subcmd 'config' '(list get set edit)' ;;
68
- trust) _arguments "--for[duration]" "--tools[tools]" "--paths[paths]" "--off" "--status" "--json" ;;
69
66
  telegram) _describe -t subcmd 'telegram' '(setup test status inbox poll)' ;;
70
67
  service) _describe -t subcmd 'service' '(install uninstall status)' ;;
71
68
  browser) _describe -t subcmd 'browser' '(list login close open)' ;;
@@ -89,7 +86,6 @@ complete -c arena-bridge -n "__fish_use_subcommand" -a prompt -d "Agent instruct
89
86
  complete -c arena-bridge -n "__fish_use_subcommand" -a tools -d "Tool catalog"
90
87
  complete -c arena-bridge -n "__fish_use_subcommand" -a approvals -d "List approvals"
91
88
  complete -c arena-bridge -n "__fish_use_subcommand" -a approve -d "Approve request"
92
- complete -c arena-bridge -n "__fish_use_subcommand" -a trust -d "Trust window"
93
89
  complete -c arena-bridge -n "__fish_use_subcommand" -a audit -d "Audit log"
94
90
  complete -c arena-bridge -n "__fish_use_subcommand" -a config -d "Manage config"
95
91
  complete -c arena-bridge -n "__fish_use_subcommand" -a telegram -d "Telegram"
package/src/config.mjs CHANGED
@@ -41,7 +41,7 @@ export const DEFAULTS = {
41
41
  '~/.mozilla',
42
42
  ],
43
43
  allowShell: true,
44
- requireApproval: true, // dangerous tools need a local human approval
44
+ requireApproval: false, // no approval gate: if the service is running, everything is allowed
45
45
  approvalWaitSec: 45, // how long the agent blocks waiting for a human
46
46
  approvalTtlSec: 900, // how long an approval request stays valid
47
47
  peekabooPath: null, // explicit path to the peekaboo binary (macOS desktop control)
package/src/direct.mjs CHANGED
@@ -9,7 +9,6 @@ import { listApprovals, decide, settle } from './approvals.mjs';
9
9
  import { checkPath } from './policy.mjs';
10
10
  import { loadConfig, CONFIG_DIR } from './config.mjs';
11
11
  import { tailAudit, readArtifact, auditDir, audit, auditPage, findEntry, lean, headCursor, LEVELS, pruneAudit, pruneArtifacts } from './audit.mjs';
12
- import { reconcileTrust } from './trust.mjs';
13
12
  import { describeSource, sourceOf, admitUnauthorized } from './source.mjs';
14
13
  import { errorResponse } from './errors.mjs';
15
14
  import { startPoller, parseCommand, sendTelegram, answerCallback, editMessageText } from './telegram.mjs';
@@ -46,20 +45,16 @@ export function createDirectServer(cfg, engine, runtime = null) {
46
45
  const handleTelegramCallback = async (cb) => {
47
46
  const current = loadConfig();
48
47
  const [action, id] = String(cb.data || '').split(':');
49
- if (!id || !['approve', 'approve3h', 'deny'].includes(action)) {
48
+ if (!id || !['approve', 'deny'].includes(action)) {
50
49
  await answerCallback(current, cb.callback_id, 'Unknown action');
51
50
  return;
52
51
  }
53
- const trustSec = action === 'approve3h' ? 3 * 3600 : 0;
54
- const res = settle(id, action === 'deny' ? 'deny' : 'approve', 'telegram', { trustSec });
55
- const tool = res.approval?.tool || 'the tool';
52
+ const res = settle(id, action === 'deny' ? 'deny' : 'approve', 'telegram');
56
53
  const text = !res.ok
57
54
  ? `Cannot ${action}: ${res.error || 'unknown error'}`
58
55
  : action === 'deny'
59
56
  ? `Denied ${id}`
60
- : trustSec
61
- ? `Approved ${id} — ${tool} is trusted for the next 3 hours`
62
- : `Approved ${id}`;
57
+ : `Approved ${id}`;
63
58
  await answerCallback(current, cb.callback_id, res.ok ? 'Done' : 'Error');
64
59
  await editMessageText(current, { chatId: cb.chat_id, messageId: cb.message_id, text });
65
60
  };
@@ -76,9 +71,8 @@ export function createDirectServer(cfg, engine, runtime = null) {
76
71
  try {
77
72
  if (p === '/health') {
78
73
  const expose = cfg.exposeDeviceInHealth !== false;
79
- let pending = 0, trustActive = false, auditCount = 0, logSize = 0;
74
+ let pending = 0, auditCount = 0, logSize = 0;
80
75
  try { pending = listApprovals().filter(a => a.status === 'pending').length; } catch {}
81
- try { const { trustState } = await import('./trust.mjs'); trustActive = !!trustState().active; } catch {}
82
76
  try { const { tailAudit } = await import('./audit.mjs'); auditCount = tailAudit(500).length; } catch {}
83
77
  try { const fs2 = await import('node:fs'); const p2 = path.join(CONFIG_DIR, 'logs', 'bridge.log'); if (fs2.existsSync(p2)) logSize = fs2.statSync(p2).size; } catch {}
84
78
  return sendJson(res, 200, {
@@ -88,7 +82,6 @@ export function createDirectServer(cfg, engine, runtime = null) {
88
82
  version: VERSION,
89
83
  uptime_sec: Math.round(process.uptime()),
90
84
  pending_approvals: pending,
91
- trust_active: trustActive,
92
85
  audit_count: auditCount,
93
86
  log_size: logSize,
94
87
  has_public_url: runtime ? !!runtime().public_url : !!cfg.publicUrl,
@@ -180,7 +173,7 @@ export function createDirectServer(cfg, engine, runtime = null) {
180
173
  }
181
174
 
182
175
  if (req.method === 'POST' && p === '/log/event') {
183
- // Interface steps only: trust and service events are written by their own modules.
176
+ // Interface steps only: service events are written by their own modules.
184
177
  const body = await readJson(req, 16 * 1024);
185
178
  const tool = typeof body.tool === 'string' ? body.tool : 'gui';
186
179
  const level = body.level ?? 'notice';
@@ -276,21 +269,7 @@ export function createDirectServer(cfg, engine, runtime = null) {
276
269
  audit({ tool: toolName, args: { path: target }, status: 'error', error: chk.error, via: 'files_api', actor, source });
277
270
  return sendJson(res, 403, { ok: false, error: chk.error, reason: chk.reason });
278
271
  }
279
- // PUT/DELETE must go through the approval gate and audit, like the tools
280
- if (req.method !== 'GET') {
281
- const { authorize } = await import('./gate.mjs');
282
- const resAuth = await authorize(toolName, { path: target }, cfgNow, source, actor);
283
- if (!resAuth.ok) {
284
- const status = resAuth.status || 'denied';
285
- const pending = resAuth.pending;
286
- return sendJson(res, pending ? 202 : 403, {
287
- ok: false,
288
- error: pending ? 'APPROVAL_PENDING' : 'APPROVAL_DENIED',
289
- status,
290
- approval_id: resAuth.approval_id || null,
291
- });
292
- }
293
- }
272
+ // No approval gate: if the service is running, everything is allowed.
294
273
  try {
295
274
  if (req.method === 'GET') {
296
275
  const buf = await fsp.readFile(chk.abs);
@@ -376,8 +355,8 @@ export function createDirectServer(cfg, engine, runtime = null) {
376
355
  });
377
356
 
378
357
  const poller = startPoller(cfg, { onMessage: handleTelegramMessage, onCallback: handleTelegramCallback });
379
- try { reconcileTrust(); pruneAudit(); pruneArtifacts(); } catch {}
380
- const maint = setInterval(() => { try { reconcileTrust(); } catch {} }, 5000);
358
+ try { pruneAudit(); pruneArtifacts(); } catch {}
359
+ const maint = setInterval(() => { try { pruneAudit(); pruneArtifacts(); } catch {} }, 3600000);
381
360
  const sweep = setInterval(() => { try { pruneAudit(); pruneArtifacts(); } catch {} }, 3600000);
382
361
  maint.unref();
383
362
  sweep.unref();
package/src/engine.mjs CHANGED
@@ -4,11 +4,9 @@ import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { checkPath, resolveTarget, isInside } from './policy.mjs';
6
6
  import { audit, saveArtifact, tailAudit, readArtifact, auditDir } from './audit.mjs';
7
- import { requestApproval } from './approvals.mjs';
8
7
  import { loadConfig, CONFIG_PATH } from './config.mjs';
9
8
  import { BrowserManager, cleanupOrphanChromes } from './browser.mjs';
10
9
  import { macTools } from './mac.mjs';
11
- import { trustState, trustAllows } from './trust.mjs';
12
10
  import { errorResponse } from './errors.mjs';
13
11
  import { validateArgs } from './schema.mjs';
14
12
  import { telegramTools } from './telegram.mjs';
@@ -79,7 +77,6 @@ export class Engine {
79
77
  return errorResponse('INVALID_ARGS', { message: valid.message, field: valid.field });
80
78
  }
81
79
  const started = Date.now();
82
- let approval = null;
83
80
  const entryId = `${new Date().toISOString().replace(/[:.]/g, '-')}-${String(name).replace(/[^\w.-]/g, '_')}-${Math.random()
84
81
  .toString(36)
85
82
  .slice(2, 8)}`;
@@ -93,43 +90,13 @@ export class Engine {
93
90
  return saved;
94
91
  };
95
92
 
96
- let needApproval = tool.approvalFor ? !!tool.approvalFor(args, this) : !!tool.approval;
97
- if (this.cfg.requireApproval === false) needApproval = false;
98
- if (requireApproval === true) needApproval = true;
99
- else if (requireApproval === false) needApproval = false;
93
+ // No approval gate: if the service is running, everything is allowed.
94
+ // The requireApproval option is kept for backwards compatibility and ignored.
95
+ void requireApproval;
100
96
 
101
97
  const artifactsOf = () => (ctx.artifacts.length ? ctx.artifacts : undefined);
102
98
 
103
- if (needApproval) {
104
- const trust = trustState();
105
- if (trustAllows(trust, tool.name, args, this.cfg)) {
106
- const res = await tool.handler(args, ctx);
107
- record({ id: entryId, status: res.ok ? 'ok' : 'error', duration_ms: Date.now() - started, via: 'trust_window', exit_code: res.exit_code, error: res.ok ? undefined : res.error, artifacts: artifactsOf() });
108
- return res;
109
- }
110
- approval = await requestApproval(tool.name, args, this.cfg);
111
- if (!approval.approved) {
112
- const status = approval.rec?.status || 'denied';
113
- const pending = status === 'pending' || status === 'timeout' || status === 'expired';
114
- const code = pending ? 'APPROVAL_PENDING' : 'APPROVAL_DENIED';
115
- record({ id: entryId, status: 'approval_denied', approval_status: status, error: code, via: 'approval', duration_ms: Date.now() - started });
116
- return {
117
- ok: false,
118
- error: code,
119
- status,
120
- pending,
121
- reason: pending
122
- ? `approval wait ended (${status}) for tool "${tool.name}"; this request is closed`
123
- : `human ${status} tool "${tool.name}"`,
124
- approval_id: approval.rec?.id || null,
125
- hint: pending
126
- ? 'This approval_id is closed and cannot be approved. Ask the user to open a trust window: arena-bridge trust --for 1h. Then retry the call once, or arrange a fresh call for approval while it is waiting.'
127
- : 'The user declined this action. Do not retry it; ask what to do instead.',
128
- };
129
- }
130
- }
131
-
132
- const via = approval ? 'approval' : 'direct';
99
+ const via = 'direct';
133
100
  try {
134
101
  const res = await tool.handler(args, ctx);
135
102
  record({
package/src/errors.mjs CHANGED
@@ -8,9 +8,9 @@ export const ERROR_CODES = {
8
8
  IS_DIR: { message: 'path is a directory, expected file', hint: 'use list_dir for directories', retryable: false },
9
9
  NOT_DIR: { message: 'not a directory', hint: 'check path is directory', retryable: false },
10
10
  APPROVAL_DENIED: { message: 'human denied the action', hint: 'do not retry, ask user what to do', retryable: false },
11
- APPROVAL_PENDING: { message: 'approval wait ended without decision', hint: 'open trust window: arena-bridge trust --for 1h, then retry once', retryable: true },
11
+ APPROVAL_PENDING: { message: 'approval wait ended without decision', hint: 'approvals are disabled — if the service is running, everything is allowed', retryable: true },
12
12
  UNAUTHORIZED: { message: 'missing or invalid Authorization Bearer token', hint: 'use Authorization: Bearer <token> header', retryable: false },
13
- FORBIDDEN: { message: 'forbidden', hint: 'approvals require local token', retryable: false },
13
+ FORBIDDEN: { message: 'forbidden', hint: 'historical approvals require local token', retryable: false },
14
14
  TIMEOUT: { message: 'command timed out', hint: 'increase timeout_sec or check process', retryable: true },
15
15
  PAYLOAD_TOO_LARGE: { message: 'payload exceeds maxUploadBytes', hint: 'reduce file size or increase limit', retryable: false },
16
16
  INVALID_JSON: { message: 'invalid JSON body', hint: 'check JSON syntax', retryable: false },
package/src/gate.mjs CHANGED
@@ -1,19 +1,10 @@
1
- import { trustState, trustAllows } from './trust.mjs';
2
- import { requestApproval } from './approvals.mjs';
3
- import { audit } from './audit.mjs';
4
-
1
+ /**
2
+ * Authorization gate.
3
+ *
4
+ * There is no approval gate and no trust window: if the service is running,
5
+ * everything is allowed. Kept as a single always-allow entry point so that
6
+ * PUT/DELETE /files and POST /call share one code path.
7
+ */
5
8
  export async function authorize(tool, args, cfg, source = null, actor = 'agent') {
6
- const trust = trustState();
7
- let needApproval = true;
8
- if (trustAllows(trust, tool, args, cfg)) needApproval = false;
9
- else if (cfg.requireApproval === false) needApproval = false;
10
- if (!needApproval) return { ok: true };
11
- const approval = await requestApproval(tool, args, cfg);
12
- if (!approval.approved) {
13
- const status = approval.rec?.status || "denied";
14
- const pending = status === "pending" || status === "timeout" || status === "expired";
15
- try { audit({ tool, args, status: "approval_denied", approval_status: status, via: "approval", actor, source, error: pending ? "APPROVAL_PENDING" : "APPROVAL_DENIED" }); } catch {}
16
- return { ok: false, status, approval_id: approval.rec?.id || null, pending };
17
- }
18
9
  return { ok: true };
19
10
  }
package/src/hub.mjs CHANGED
@@ -14,7 +14,6 @@ import path from 'node:path';
14
14
  import { audit, auditPage, auditDir, findEntry, headCursor, lean, readArtifact, tailAudit } from './audit.mjs';
15
15
  import { sourceOf, describeSource, admitUnauthorized } from './source.mjs';
16
16
  import { errorResponse } from './errors.mjs';
17
- import { trustState } from './trust.mjs';
18
17
 
19
18
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
20
19
  const MAX_QUEUED_PER_DEVICE = 100;
@@ -123,7 +122,6 @@ export function createHubServer(cfg) {
123
122
  device: current.device,
124
123
  uptime_sec: Math.round(process.uptime()),
125
124
  pending_approvals: pending,
126
- trust_active: !!trustState().active,
127
125
  audit_count: auditCount,
128
126
  log_size: logSize,
129
127
  has_public_url: !!current.publicUrl,
package/src/mac.mjs CHANGED
@@ -330,7 +330,7 @@ export function macTools(cfg = {}) {
330
330
  {
331
331
  name: 'mac_click',
332
332
  description: 'Click on the screen: an element id from mac_see, a visible text, or coordinates.',
333
- approval: true,
333
+ approval: false,
334
334
  schema: S(
335
335
  {
336
336
  on: { type: 'string', description: 'element id from mac_see' },
@@ -369,7 +369,7 @@ export function macTools(cfg = {}) {
369
369
  {
370
370
  name: 'mac_type',
371
371
  description: 'Type text into the focused element of an app window.',
372
- approval: true,
372
+ approval: false,
373
373
  schema: S(
374
374
  {
375
375
  text: { type: 'string' },
@@ -401,7 +401,7 @@ export function macTools(cfg = {}) {
401
401
  {
402
402
  name: 'mac_key',
403
403
  description: 'Press a key or a chord in an app: Return, Tab, Escape, cmd+s, cmd+shift+p, arrows, etc.',
404
- approval: true,
404
+ approval: false,
405
405
  schema: S(
406
406
  {
407
407
  key: { type: 'string', description: 'key name or chord, e.g. "cmd+s"' },
@@ -431,7 +431,7 @@ export function macTools(cfg = {}) {
431
431
  {
432
432
  name: 'mac_scroll',
433
433
  description: 'Scroll up/down in the focused app or on a given element.',
434
- approval: true,
434
+ approval: false,
435
435
  schema: S(
436
436
  {
437
437
  direction: { type: 'string', description: 'up or down' },
@@ -464,7 +464,7 @@ export function macTools(cfg = {}) {
464
464
  {
465
465
  name: 'mac_move',
466
466
  description: 'Move the mouse pointer to coordinates (no click).',
467
- approval: true,
467
+ approval: false,
468
468
  schema: S({ x: { type: 'number' }, y: { type: 'number' } }, ['x', 'y']),
469
469
  required: ['x', 'y'],
470
470
  handler: async (args) => {
@@ -484,7 +484,7 @@ export function macTools(cfg = {}) {
484
484
  {
485
485
  name: 'mac_drag',
486
486
  description: 'Drag from one point to another (sliders, files, text selection).',
487
- approval: true,
487
+ approval: false,
488
488
  schema: S({ from_x: { type: 'number' }, from_y: { type: 'number' }, to_x: { type: 'number' }, to_y: { type: 'number' } }),
489
489
  required: ['from_x', 'from_y', 'to_x', 'to_y'],
490
490
  handler: async (args) => {
@@ -560,7 +560,7 @@ export function macTools(cfg = {}) {
560
560
  {
561
561
  name: 'mac_app_launch',
562
562
  description: 'Launch an application by name.',
563
- approval: true,
563
+ approval: false,
564
564
  schema: S({ name: { type: 'string' } }, ['name']),
565
565
  required: ['name'],
566
566
  handler: async (args) => {
@@ -580,7 +580,7 @@ export function macTools(cfg = {}) {
580
580
  {
581
581
  name: 'mac_app_focus',
582
582
  description: 'Bring an application to the front.',
583
- approval: true,
583
+ approval: false,
584
584
  schema: S({ name: { type: 'string' } }, ['name']),
585
585
  required: ['name'],
586
586
  handler: async (args) => {
@@ -600,7 +600,7 @@ export function macTools(cfg = {}) {
600
600
  {
601
601
  name: 'mac_app_quit',
602
602
  description: 'Quit an application.',
603
- approval: true,
603
+ approval: false,
604
604
  schema: S({ name: { type: 'string' } }, ['name']),
605
605
  required: ['name'],
606
606
  handler: async (args) => {
@@ -659,7 +659,7 @@ export function macTools(cfg = {}) {
659
659
  name: 'mac_set',
660
660
  description:
661
661
  'Set the value of an element directly through the accessibility API — fills a field without focusing the window and without simulated keystrokes.',
662
- approval: true,
662
+ approval: false,
663
663
  schema: S(
664
664
  {
665
665
  on: { type: 'string', description: 'element id from mac_see / mac_element' },
@@ -723,7 +723,7 @@ export function macTools(cfg = {}) {
723
723
  name: 'mac_menu_click',
724
724
  description:
725
725
  'Trigger a menu item by name (e.g. "Save", "Copy Link") or a nested path ("File > Export") — no pointer, no coordinates.',
726
- approval: true,
726
+ approval: false,
727
727
  schema: S(
728
728
  {
729
729
  item: { type: 'string', description: 'name of the menu item' },
@@ -795,7 +795,7 @@ export function macTools(cfg = {}) {
795
795
  name: 'mac_space_switch',
796
796
  description:
797
797
  'Move to another Space so the agent works on a separate virtual desktop and the user keeps the screen they are on.',
798
- approval: true,
798
+ approval: false,
799
799
  schema: S({ to: { type: 'string', description: 'space id or index from mac_spaces' } }, ['to']),
800
800
  required: ['to'],
801
801
  handler: async (args, ctx) => {
package/src/mcp.mjs CHANGED
@@ -55,7 +55,7 @@ export async function handleMcp(req, res, ctx) {
55
55
  serverInfo: { name: 'arena-bridge', version: VERSION },
56
56
  instructions:
57
57
  'Tools operate the user\'s own machine. Dangerous operations may return ' +
58
- 'PROTECTED and require a local human approval.',
58
+ 'PROTECTED.',
59
59
  }),
60
60
  );
61
61
  break;