// The Pterodactyl panel the test rigs run on, shared by rig.js and console.js. // // Nothing here is shipped: tools/ is developer scaffolding (docs/runicnpc/PLAN.md ยง9, stage 0). // Where the panel is and which servers are the rigs is local knowledge, so it lives in // tools/rigs.json (git-ignored; copy tools/rigs.example.json). The panel's client API key is read // at call time from the file rigs.json names, and is never printed. const fs = require('fs') const path = require('path') const CONFIG = path.join(__dirname, 'rigs.json') function load() { if (!fs.existsSync(CONFIG)) { console.error(`No ${CONFIG}. Copy tools/rigs.example.json to tools/rigs.json and fill it in.`) process.exit(2) } const config = JSON.parse(fs.readFileSync(CONFIG, 'utf8')) // The key file holds `name: value` lines; the panel's client key is `user`. const keys = Object.fromEntries( fs .readFileSync(config.tokenFile, 'utf8') .split(/\r?\n/) .filter((l) => l.includes(':')) .map((l) => [l.slice(0, l.indexOf(':')).trim(), l.slice(l.indexOf(':') + 1).trim()]) ) if (!keys.user) { console.error(`${config.tokenFile} has no "user:" line (the panel's client API key).`) process.exit(2) } return { panel: config.panel.replace(/\/+$/, ''), rigs: config.rigs, key: keys.user } } /** The server id of a rig by name, or exit with the names there are. */ function serverId(config, rig) { const id = config.rigs[rig] if (!id) { console.error(`Unknown rig "${rig}". Known: ${Object.keys(config.rigs).join(', ')}`) process.exit(2) } return id } // Git Bash (MSYS) rewrites an argument starting with / into C:/Program Files/Git/...; undo it, so // a mangled path never reaches the server. On 2026-09-29 every rig file call failed this way and // looked like an outage of the panel's file API. const unmsys = (x) => typeof x === 'string' ? x.replace(/^[A-Za-z]:\/Program Files\/Git(?=\/|$)/, '') || '/' : x module.exports = { load, serverId, unmsys }