Skip to content

feat(middleware): implement ChannelBridge orchestrator#33

Merged
alexey-pelykh merged 2 commits intomainfrom
feat/channel-bridge
Feb 26, 2026
Merged

feat(middleware): implement ChannelBridge orchestrator#33
alexey-pelykh merged 2 commits intomainfrom
feat/channel-bridge

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

  • Implement ChannelBridge class — the central orchestrator connecting incoming channel messages to CLI agent execution and delivery
  • Single entry point handle() wires together all previously implemented middleware components: runtime factory, session map, error classifier, delivery adapter, system prompt builder, and MCP side effects
  • Event stream wrapper (captureResult) extracts AgentRunResult from the done event while passing events through to DeliveryAdapter
  • Session key maps ChannelMessage fields to SessionKey for SessionMap integration, with composite string formatting for MCP env vars
  • Error classification maps categories to errorSubtype on the result (with context_overflow"context_window" mapping per spec)
  • Temp invocation directory per call with cleanup in finally block

Closes #32

Test plan

  • 34 unit tests covering: orchestration flow, streaming callbacks, session lifecycle, MCP config assembly, error handling paths, temp directory cleanup, constructor defaults, buildSessionKey helper
  • pnpm build passes
  • pnpm check passes (format + typecheck + lint)
  • Security guard test (temp-path-guard) passes (uses mkdtemp instead of Math.random)
  • CI build and test jobs pass

🤖 Generated with Claude Code

alexey-pelykh and others added 2 commits February 26, 2026 09:48
Central orchestrator connecting incoming channel messages to CLI agent
execution and delivery. Single entry point handle() wires together
runtime factory, session map, error classifier, delivery adapter,
system prompt builder, and MCP side effects.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Use `import type` for SessionMap (type-only usage)
- Add comment explaining context_overflow → context_window mapping
- Use Partial<ChannelBridgeOptions> for test helper type safety
- Simplify temp dir cleanup tests (remove fragile tmpdir scan)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

Implement ChannelBridge orchestrator

1 participant