Removes blocking readFileSync, writeFileSync, and mkdirSync calls from the agent spawn hot path, replacing them with async fs/promises equivalents to avoid stalling the Node.js event loop during credential operations.
16 lines
514 B
TypeScript
16 lines
514 B
TypeScript
import { mkdir, writeFile } from 'node:fs/promises';
|
|
import { join } from 'node:path';
|
|
|
|
export async function setupAccountConfigDir(
|
|
configDir: string,
|
|
extracted: { configJson: object; credentials: string },
|
|
): Promise<void> {
|
|
await mkdir(configDir, { recursive: true });
|
|
|
|
// Write .claude.json
|
|
await writeFile(join(configDir, '.claude.json'), JSON.stringify(extracted.configJson, null, 2));
|
|
|
|
// Write .credentials.json
|
|
await writeFile(join(configDir, '.credentials.json'), extracted.credentials);
|
|
}
|