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

@@ -3,6 +3,7 @@ import { loadConfig, isDevMode, getPort } from './config.js';
import { logInfo, logError } from './logger.js';
import router from './routes.js';
import { initializeAuth } from './auth.js';
import { initializeUserAgentUpdater } from './user-agent-updater.js';
const app = express();
@@ -112,6 +113,9 @@ app.use((err, req, res, next) => {
logInfo('Configuration loaded successfully');
logInfo(`Dev mode: ${isDevMode()}`);
// Initialize User-Agent version updater
initializeUserAgentUpdater();
// Initialize auth system (load and setup API key if needed)
// This won't throw error if no auth config is found - will use client auth
await initializeAuth();