feat(usage): add xAI quota reporting #2628
feat(usage): add xAI quota reporting
This commit is contained in:
@@ -25,16 +25,19 @@ function readAuthFile() {
|
||||
function writeAuthFile(auth) {
|
||||
try {
|
||||
if (!fs.existsSync(OPENCODE_DATA_DIR)) {
|
||||
fs.mkdirSync(OPENCODE_DATA_DIR, { recursive: true });
|
||||
fs.mkdirSync(OPENCODE_DATA_DIR, { recursive: true, mode: 0o700 });
|
||||
}
|
||||
if (process.platform !== 'win32') fs.chmodSync(OPENCODE_DATA_DIR, 0o700);
|
||||
|
||||
if (fs.existsSync(AUTH_FILE)) {
|
||||
const backupFile = `${AUTH_FILE}.openchamber.backup`;
|
||||
fs.copyFileSync(AUTH_FILE, backupFile);
|
||||
if (process.platform !== 'win32') fs.chmodSync(backupFile, 0o600);
|
||||
console.log(`Created auth backup: ${backupFile}`);
|
||||
}
|
||||
|
||||
fs.writeFileSync(AUTH_FILE, JSON.stringify(auth, null, 2), 'utf8');
|
||||
fs.writeFileSync(AUTH_FILE, JSON.stringify(auth, null, 2), { encoding: 'utf8', mode: 0o600 });
|
||||
if (process.platform !== 'win32') fs.chmodSync(AUTH_FILE, 0o600);
|
||||
console.log('Successfully wrote auth file');
|
||||
} catch (error) {
|
||||
console.error('Failed to write auth file:', error);
|
||||
|
||||
Reference in New Issue
Block a user