Refactor to use Environment-runtime agent#6
Merged
wow-miley merged 3 commits intoNov 26, 2025
Conversation
5ac8822 to
fd02c56
Compare
Create EnvironmentService as a facade for EnvironmentOrchestrator, providing:
- Convenient factory methods for creating agent-specific APIs (message, event, meetings)
- Direct access to repositories (meeting, ticket, message, event)
- Start method to initialize all orchestrator services
This service layer simplifies agent interaction with the environment by hiding
the complexity of the orchestrator's internal structure while providing a clean,
agent-focused API.
Usage:
```kotlin
val service = EnvironmentService(orchestrator)
val messageApi = service.createMessageApi("my-agent")
val eventApi = service.createEventApi("my-agent")
val meetingsApi = service.createMeetingsApi("my-agent")
```
39ebf4d to
d3f0d46
Compare
Refactor WatchCommand to properly use the environment classes, centralizing setup logic that would otherwise be duplicated across CLI commands. Changes: - Make eventSerialBus public in EnvironmentOrchestrator to allow external subscriptions - Add event subscription methods to EnvironmentService: * subscribe() - subscribe to a specific event type * subscribeToAll() - subscribe to all event types * eventBus property - direct access to the event bus - Add EnvironmentService.create() factory method for CLI tools * Creates database, EventSerialBus, and EnvironmentOrchestrator * Simplifies setup for CLI commands and tests - Implement WatchCommand.run() to: * Create environment using EnvironmentService.create() * Subscribe to all events with filtering by type/agent * Render events to terminal using EventRenderer * Keep running until interrupted This pattern eliminates duplication - CLI commands no longer need to manually set up database, repositories, factories, and orchestrator. They just call EnvironmentService.create() and use the high-level APIs.
Merge main branch which introduced EventRelayService for Flow-based event streaming, and refactor WatchCommand to use EnvironmentService for simplified setup. Changes: 1. **EnvironmentService** - Integrated EventRelayService: - Added eventRelayService parameter to constructor - Updated create() factory to instantiate EventRelayServiceImpl - Provides access to Flow-based event subscription 2. **WatchCommand** - Refactored to use EnvironmentService: - Replaced manual setup of EventRepository, EventSerialBus, EventRelayServiceImpl - Now uses EnvironmentService.create() for all infrastructure - Accesses EventRelayService via environment.eventRelayService - Maintains all filtering and rendering functionality from main Benefits: - CLI commands get EventRelayService without manual wiring - EnvironmentService provides single point of access to all infrastructure - Consistent setup across different entry points (CLI, tests, etc.) - Preserves Flow-based streaming API from main
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Introduce AgentEnvironment and AgentEnvironmentFactory to encapsulate core infrastructure dependencies (eventBus, repositories, messageApi) in a single object, simplifying constructor signatures and test setup.