Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

Refactor AgentSession into modular session managers

8 months ago

385dea4
Authored
mweinbach2/22/2026, 8:08:54 PM
Split the session monolith into focused modules and keep AgentSession as a composition root/facade.

- Move AgentSession to src/server/session/AgentSession.ts
- Introduce shared SessionContext and SessionRuntimeState types
- Promote HistoryManager, McpManager, and TurnExecutionManager from pass-through wrappers
- Extract SkillManager, SessionMetadataManager, SessionBackupController, and SessionAdminManager
- Keep websocket protocol/handlers unchanged (startServer only updates AgentSession import path)
- Add targeted manager seam tests in test/session.managers.test.ts

Validated with:
- bun test test/session.managers.test.ts test/session.test.ts test/session.stream-pipeline.test.ts test/server.test.ts test/server.toolstream.test.ts

Co-authored-by: Codex <noreply@openai.com>

Parent9c7f4d7

14 files changed
  • src/server/session.ts+0−2080
  • src/server/session/AgentSession.ts+706−0
  • src/server/session/HistoryManager.ts+20−8
  • src/server/session/McpManager.ts+458−30
  • src/server/session/SessionAdminManager.ts+108−0
  • src/server/session/SessionBackupController.ts+209−0
  • src/server/session/SessionContext.ts+108−2
  • src/server/session/SessionMetadataManager.ts
+207
−0
  • src/server/session/SkillManager.ts+231−0
  • src/server/session/TurnExecutionManager.ts+278−10
  • src/server/startServer.ts+1−1
  • test/session.managers.test.ts+146−0
  • test/session.stream-pipeline.test.ts+1−1
  • test/session.test.ts+1−1