agent-ecosystem/src/main/http/index.ts
iliya 81ac59e46b feat: enhance team control API with retry logic and fallback mechanisms
- Introduced a new method to resolve multiple control base URLs, allowing for better handling of API requests.
- Implemented retryable error handling for control API requests, improving robustness against transient failures.
- Updated provisioning and runtime state retrieval functions to utilize the new fallback logic.
- Enhanced tests to validate the new behavior, ensuring proper functionality under various scenarios.
- Added utility functions for managing retryable errors and control API state, improving code clarity and maintainability.
2026-03-12 19:23:48 +02:00

69 lines
2.3 KiB
TypeScript

/**
* HTTP Route Registration Orchestrator.
*
* Registers all domain-specific route handlers on a Fastify instance.
* Each route file mirrors the corresponding IPC handler.
*/
import { createLogger } from '@shared/utils/logger';
import { registerConfigRoutes } from './config';
import { registerEventRoutes } from './events';
import { registerNotificationRoutes } from './notifications';
import { registerProjectRoutes } from './projects';
import { registerSearchRoutes } from './search';
import { registerSessionRoutes } from './sessions';
import { registerSshRoutes } from './ssh';
import { registerSubagentRoutes } from './subagents';
import { registerTeamRoutes } from './teams';
import { registerUpdaterRoutes } from './updater';
import { registerUtilityRoutes } from './utility';
import { registerValidationRoutes } from './validation';
import type {
ChunkBuilder,
DataCache,
ProjectScanner,
SessionParser,
SubagentResolver,
UpdaterService,
} from '../services';
import type { SshConnectionManager } from '../services/infrastructure/SshConnectionManager';
import type { TeamProvisioningService } from '../services/team/TeamProvisioningService';
import type { FastifyInstance } from 'fastify';
const logger = createLogger('HTTP:routes');
export interface HttpServices {
projectScanner: ProjectScanner;
sessionParser: SessionParser;
subagentResolver: SubagentResolver;
chunkBuilder: ChunkBuilder;
dataCache: DataCache;
updaterService: UpdaterService;
sshConnectionManager: SshConnectionManager;
teamProvisioningService?: TeamProvisioningService;
}
export function registerHttpRoutes(
app: FastifyInstance,
services: HttpServices,
sshModeSwitchCallback: (mode: 'local' | 'ssh') => Promise<void>
): void {
registerProjectRoutes(app, services);
registerSessionRoutes(app, services);
registerSearchRoutes(app, services);
registerSubagentRoutes(app, services);
if (services.teamProvisioningService) {
registerTeamRoutes(app, services);
}
registerNotificationRoutes(app);
registerConfigRoutes(app);
registerValidationRoutes(app);
registerUtilityRoutes(app);
registerSshRoutes(app, services.sshConnectionManager, sshModeSwitchCallback);
registerUpdaterRoutes(app, services);
registerEventRoutes(app);
logger.info('All HTTP routes registered');
}