-
Notifications
You must be signed in to change notification settings - Fork 581
Add automation scheduler service #837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| 2026-03-01T20:55:55.690Z | ||
|
|
||
| [object Object] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,13 @@ import { createEventHistoryRoutes } from './routes/event-history/index.js'; | |
| import { getEventHistoryService } from './services/event-history-service.js'; | ||
| import { getTestRunnerService } from './services/test-runner-service.js'; | ||
| import { createProjectsRoutes } from './routes/projects/index.js'; | ||
| import { createAutomationRoutes } from './routes/automation/index.js'; | ||
| import { | ||
| initializeAutomationSchedulerService, | ||
| shutdownAutomationSchedulerService, | ||
| } from './services/automation-scheduler-service.js'; | ||
| import { AutomationRuntimeEngine } from './services/automation-runtime-engine.js'; | ||
| import { getAutomationVariableService } from './services/automation-variable-service.js'; | ||
|
|
||
| // Load environment variables | ||
| dotenv.config(); | ||
|
|
@@ -370,6 +377,13 @@ testRunnerService.setEventEmitter(events); | |
| // Initialize Event Hook Service for custom event triggers (with history storage) | ||
| eventHookService.initialize(events, settingsService, eventHistoryService, featureLoader); | ||
|
|
||
| // Initialize Automation Runtime Engine and Scheduler Service | ||
| // Pass settingsService so AI prompt steps can access credentials for Claude API authentication | ||
| const automationRuntimeEngine = AutomationRuntimeEngine.create(DATA_DIR, settingsService); | ||
| let automationSchedulerService: Awaited< | ||
| ReturnType<typeof initializeAutomationSchedulerService> | ||
| > | null = null; | ||
|
|
||
| // Initialize services | ||
| (async () => { | ||
| // Migrate settings from legacy Electron userData location if needed | ||
|
|
@@ -461,6 +475,68 @@ eventHookService.initialize(events, settingsService, eventHistoryService, featur | |
| void codexModelCacheService.getModels().catch((err) => { | ||
| logger.error('Failed to bootstrap Codex model cache:', err); | ||
| }); | ||
|
|
||
| // Initialize Automation Scheduler Service | ||
| try { | ||
| automationSchedulerService = await initializeAutomationSchedulerService( | ||
| DATA_DIR, | ||
| events, | ||
| automationRuntimeEngine | ||
| ); | ||
|
|
||
| // Set up auto mode operations for automation steps | ||
| automationSchedulerService.setAutoModeOperations({ | ||
| start: async (projectPath, branchName, maxConcurrency) => { | ||
| const resolvedMaxConcurrency = await autoModeService.startAutoLoopForProject( | ||
| projectPath, | ||
| branchName ?? null, | ||
| maxConcurrency | ||
| ); | ||
| return { | ||
| success: true, | ||
| maxConcurrency: resolvedMaxConcurrency, | ||
| message: `Auto mode started with max ${resolvedMaxConcurrency} concurrent features`, | ||
| }; | ||
| }, | ||
| stop: async (projectPath, branchName) => { | ||
| const runningCount = await autoModeService.stopAutoLoopForProject( | ||
| projectPath, | ||
| branchName ?? null | ||
| ); | ||
| return { | ||
| success: true, | ||
| runningFeaturesCount: runningCount, | ||
| message: 'Auto mode stopped', | ||
| }; | ||
| }, | ||
| getStatus: async (projectPath, branchName) => { | ||
| const status = await autoModeService.getStatusForProject(projectPath, branchName ?? null); | ||
| return { | ||
| isRunning: status.runningCount > 0, | ||
| isAutoLoopRunning: status.isAutoLoopRunning, | ||
| runningFeatures: status.runningFeatures, | ||
| runningCount: status.runningCount, | ||
| maxConcurrency: status.maxConcurrency, | ||
| }; | ||
| }, | ||
| setConcurrency: async (projectPath, maxConcurrency, branchName) => { | ||
| // Start/restart auto mode with new concurrency | ||
| const resolvedMaxConcurrency = await autoModeService.startAutoLoopForProject( | ||
| projectPath, | ||
| branchName ?? null, | ||
| maxConcurrency | ||
| ); | ||
| return { | ||
| success: true, | ||
| maxConcurrency: resolvedMaxConcurrency, | ||
| }; | ||
| }, | ||
| }); | ||
|
|
||
| logger.info('Automation scheduler service initialized'); | ||
| } catch (err) { | ||
| logger.error('Failed to initialize automation scheduler service:', err); | ||
| } | ||
| })(); | ||
|
|
||
| // Run stale validation cleanup every hour to prevent memory leaks from crashed validations | ||
|
|
@@ -522,6 +598,26 @@ app.use( | |
| createProjectsRoutes(featureLoader, autoModeService, settingsService, notificationService) | ||
| ); | ||
|
|
||
| // Automation routes (with null check for scheduler service) | ||
| app.use( | ||
| '/api/automation', | ||
| (req, res, next) => { | ||
| if (!automationSchedulerService) { | ||
| res.status(503).json({ success: false, error: 'Automation scheduler not initialized' }); | ||
| return; | ||
| } | ||
| next(); | ||
| }, | ||
| (req, res, next) => { | ||
| const variableService = getAutomationVariableService(); | ||
| createAutomationRoutes(automationSchedulerService!, automationRuntimeEngine, variableService)( | ||
| req, | ||
| res, | ||
| next | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| // Create HTTP server | ||
| const server = createServer(app); | ||
|
|
||
|
|
@@ -840,6 +936,7 @@ terminalWss.on('connection', (ws: WebSocket, req: import('http').IncomingMessage | |
| // Start server with error handling for port conflicts | ||
| const startServer = (port: number, host: string) => { | ||
| server.listen(port, host, () => { | ||
| logger.info('Gemini test - Hello World'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| const terminalStatus = isTerminalEnabled() | ||
| ? isTerminalPasswordRequired() | ||
| ? 'enabled (password protected)' | ||
|
|
@@ -962,6 +1059,9 @@ const gracefulShutdown = async (signal: string) => { | |
| // Note: markAllRunningFeaturesInterrupted handles errors internally and never rejects | ||
| await autoModeService.markAllRunningFeaturesInterrupted(`${signal} signal received`); | ||
|
|
||
| // Shutdown automation scheduler service | ||
| await shutdownAutomationSchedulerService(); | ||
|
|
||
| terminalService.cleanup(); | ||
| server.close(() => { | ||
| clearTimeout(forceExitTimeout); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file appears to have been accidentally committed. It contains
[object Object], which often indicates an object was incorrectly stringified during development. This file should be removed from the pull request.