open source is social v-it.org
at main 39 lines 1.1 kB view raw
1// SPDX-License-Identifier: MIT 2// Copyright (c) 2026 sol pbc 3 4import { existsSync, readFileSync } from 'node:fs'; 5import { join } from 'node:path'; 6import { vitDir } from './vit-dir.js'; 7 8const ACCEPT_FILE = 'dangerous-accept'; 9 10/** 11 * Check if dangerous-accept flag is active. 12 * Returns { accepted: true } or { accepted: false }. 13 * No TTL — once set, it's permanent until deleted. 14 */ 15export function checkDangerousAccept() { 16 const p = join(vitDir(), ACCEPT_FILE); 17 if (!existsSync(p)) return { accepted: false }; 18 try { 19 JSON.parse(readFileSync(p, 'utf-8')); 20 return { accepted: true }; 21 } catch { 22 return { accepted: false }; 23 } 24} 25 26/** 27 * Check if the vet gate should be bypassed. 28 * Returns { bypass: true, reason } or { bypass: false }. 29 * 30 * Bypass condition: dangerous-accept flag is active. 31 * Caller checks trusted.jsonl before calling this. 32 */ 33export function shouldBypassVet() { 34 const accept = checkDangerousAccept(); 35 if (accept.accepted) { 36 return { bypass: true, reason: 'dangerous-accept' }; 37 } 38 return { bypass: false }; 39}