refactor: add recovery mode + shared JSON/error/fetch utilities

- GroupQueue recovery mode: limit to 3 concurrent agents for 60s after restart
  to prevent API rate-limit storms (configurable via env vars)
- getErrorMessage: replace 14 occurrences of instanceof Error pattern
- readJsonFile/writeJsonFile: replace 19 occurrences of JSON+fs pattern
- fetchWithTimeout: replace 3 occurrences of AbortController pattern

354/354 tests passing
This commit is contained in:
Eyejoker
2026-03-25 07:08:49 +09:00
parent a576d623a1
commit b6d3f879ef
11 changed files with 123 additions and 37 deletions

View File

@@ -49,5 +49,9 @@ export function writeGroupsSnapshot(
fs.mkdirSync(groupIpcDir, { recursive: true });
const visibleGroups = isMain ? groups : [];
const groupsFile = path.join(groupIpcDir, 'available_groups.json');
writeJsonFile(groupsFile, { groups: visibleGroups, lastSync: new Date().toISOString() }, true);
writeJsonFile(
groupsFile,
{ groups: visibleGroups, lastSync: new Date().toISOString() },
true,
);
}