feat: add dynamic user-agent version updater

- Add user-agent-updater.js to automatically fetch latest factory-cli version
- Fetch version from https://downloads.factory.ai/factory-cli/LATEST on startup
- Automatically refresh version every hour
- Implement retry mechanism: max 3 retries with 1-minute intervals on failure
- Use user_agent from config.json as fallback value
- Update config.js to use dynamic user-agent
- Initialize updater in server.js startup sequence
This commit is contained in:
1eon
2025-11-16 16:10:55 +08:00
parent 3c0e922cbd
commit c31b680d95
3 changed files with 120 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { logInfo } from './logger.js';
import { getCurrentUserAgent } from './user-agent-updater.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@@ -64,8 +65,7 @@ export function getModelReasoning(modelId) {
}
export function getUserAgent() {
const cfg = getConfig();
return cfg.user_agent || 'factory-cli/0.19.3';
return getCurrentUserAgent();
}
export function getProxyConfigs() {