Skip to content

Refactor to use Environment-runtime agent#6

Merged
wow-miley merged 3 commits into
mainfrom
claude/refactor-environment-agent-01Tri4v7dnVx7Yz7wmYre7KN
Nov 26, 2025
Merged

Refactor to use Environment-runtime agent#6
wow-miley merged 3 commits into
mainfrom
claude/refactor-environment-agent-01Tri4v7dnVx7Yz7wmYre7KN

Conversation

@wow-miley

Copy link
Copy Markdown
Contributor

Introduce AgentEnvironment and AgentEnvironmentFactory to encapsulate core infrastructure dependencies (eventBus, repositories, messageApi) in a single object, simplifying constructor signatures and test setup.

  • Add AgentEnvironment class with factory methods for per-agent APIs
  • Add AgentEnvironmentFactory for easy environment creation
  • Refactor MeetingParticipationHandler to use AgentEnvironment
  • Refactor MeetingOrchestrator to use AgentEnvironment
  • Update all tests to use AgentEnvironmentFactory pattern

@wow-miley wow-miley force-pushed the claude/refactor-environment-agent-01Tri4v7dnVx7Yz7wmYre7KN branch from 5ac8822 to fd02c56 Compare November 23, 2025 02:43
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")
```
@wow-miley wow-miley force-pushed the claude/refactor-environment-agent-01Tri4v7dnVx7Yz7wmYre7KN branch from 39ebf4d to d3f0d46 Compare November 26, 2025 06:57
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
@wow-miley wow-miley merged commit 25dc51a into main Nov 26, 2025
1 check passed
@wow-miley wow-miley deleted the claude/refactor-environment-agent-01Tri4v7dnVx7Yz7wmYre7KN branch November 26, 2025 07:20
@wow-miley wow-miley self-assigned this Nov 28, 2025
@wow-miley wow-miley removed this from Ampere CLI Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants