Skip to content

feat: entity channel connectors (Telegram, Discord)#4164

Draft
balegas wants to merge 1 commit intomainfrom
vbalegas/entity-channel-connectors
Draft

feat: entity channel connectors (Telegram, Discord)#4164
balegas wants to merge 1 commit intomainfrom
vbalegas/entity-channel-connectors

Conversation

@balegas
Copy link
Copy Markdown
Contributor

@balegas balegas commented Apr 24, 2026

Summary

  • Adds design spec and implementation plan for connecting entities to external messaging platforms (Telegram, Discord) with bidirectional communication
  • Entities gain a channels property in defineEntity() that declares platform bindings
  • Inbound platform messages auto-spawn entity instances and wake them with normalized channel_message events
  • Agent output is implicitly forwarded back to the originating chat (with streaming edit-in-place support)

Design

  • Spec: docs/superpowers/specs/2026-04-24-entity-channel-connectors-design.md
  • Plan: docs/superpowers/plans/2026-04-24-entity-channel-connectors.md

Key decisions

  • Composable PlatformAdapter interface (inspired by OpenClaw) — gateway, outbound, streaming?, threading?, groups?
  • Normalized ChannelMessageWakeEvent with channelData escape hatch for platform-specific fields
  • DraftStreamLoop for throttled edit-in-place streaming on both platforms
  • HealthMonitor with exponential backoff and auto-restart
  • Auto-spawn entity instances on first inbound message (URL: /{type}/{platform}-{chatId})
  • Global server-level credentials via env vars, entity definitions reference platforms by name

Implementation plan (13 tasks)

  1. Channel types & config factories (agents-runtime)
  2. Extend EntityDefinition and HandlerContext
  3. Package exports
  4. Database schema — channels column
  5. DraftStreamLoop
  6. HealthMonitor
  7. TelegramAdapter (webhook)
  8. DiscordAdapter (Gateway WebSocket)
  9. ChannelManager
  10. Server wiring
  11. Agent output forwarding in wake processing
  12. Integration tests
  13. Final verification

Test plan

  • Unit tests for config factories (telegram/discord validation)
  • Unit tests for DraftStreamLoop (throttling, edit-in-place, fallback)
  • Unit tests for HealthMonitor (grace period, backoff, max attempts)
  • Unit tests for TelegramAdapter (send, edit, webhook handling)
  • Unit tests for DiscordAdapter (send, edit, gateway events)
  • Integration tests for ChannelManager (routing, auto-spawn, multi-platform, forwarding)
  • Existing test suites pass with no regressions

🤖 Generated with Claude Code

…ectors

Adds the ability to connect entities to external messaging platforms
(Telegram, Discord, etc.) with bidirectional communication configured
at the entity type definition level.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.11%. Comparing base (3cef0ca) to head (002ad27).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4164      +/-   ##
==========================================
+ Coverage   68.08%   68.11%   +0.02%     
==========================================
  Files         130      134       +4     
  Lines       16211    16596     +385     
  Branches     3912     4027     +115     
==========================================
+ Hits        11037    11304     +267     
- Misses       5170     5288     +118     
  Partials        4        4              
Flag Coverage Δ
packages/agents 47.33% <ø> (+8.94%) ⬆️
packages/agents-runtime 81.34% <ø> (ø)
packages/agents-server 65.55% <ø> (ø)
packages/agents-server-ui 0.00% <ø> (ø)
packages/electric-ax 30.46% <ø> (ø)
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/start 82.83% <ø> (ø)
packages/typescript-client 94.30% <ø> (ø)
packages/y-electric 56.05% <ø> (ø)
typescript 68.11% <ø> (+0.02%) ⬆️
unit-tests 68.11% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant