Skip to content

Platform abstraction layer — AgentCore + web adapter#144

Merged
rz1989s merged 5 commits intomainfrom
feat/platform-abstraction
Apr 10, 2026
Merged

Platform abstraction layer — AgentCore + web adapter#144
rz1989s merged 5 commits intomainfrom
feat/platform-abstraction

Conversation

@rz1989s
Copy link
Copy Markdown
Member

@rz1989s rz1989s commented Apr 10, 2026

Summary

Extracts a platform-agnostic AgentCore class so Sipher can serve web, X DMs, and Telegram from the same conversation engine.

  • MsgContext — unified inbound message type (platform, userId, message, metadata)
  • AgentCore — owns the full cycle: session → conversation load → LLM → tool execution → persist → response
  • Web adapter — maps Express req/res to MsgContext, replaces 3 inline route handlers (~100 lines removed)
  • Dead code removedroutes/command.ts deleted (replaced by adapter)

Architecture after this PR:

MsgContext → AgentCore → { Web | Telegram | X } Adapter

New files

  • packages/agent/src/core/types.ts — Platform, MsgContext, ResponseChunk, AgentResponse
  • packages/agent/src/core/agent-core.ts — AgentCore class
  • packages/agent/src/adapters/web.ts — createWebAdapter()
  • packages/agent/tests/core/agent-core.test.ts — 4 tests
  • packages/agent/tests/adapters/web.test.ts — 12 tests

Test plan

  • 497 root tests passing
  • 16 new agent tests passing (4 core + 12 adapter)
  • tsc --noEmit clean
  • app build clean
  • Deploy + verify chat/stream/command on live

rz1989s added 5 commits April 10, 2026 09:06
Adds AgentCore class with processMessage() and streamMessage() methods
that wrap the existing chat/chatStream functions with session resolution,
conversation persistence, and SSE-to-ResponseChunk mapping. Any platform
adapter (web, Telegram, X) can now construct a MsgContext and hand it to
AgentCore without knowing about the LLM layer.

4 tests covering: text response, tool extraction, streaming chunks,
and repeated session resolution.
Three handlers (handleCommand, handleChat, handleChatStream) translate
HTTP requests into MsgContext and AgentCore responses back to JSON/SSE.
Includes chunkToSSE mapping, message validation, and abort tracking.
@rz1989s rz1989s merged commit dcaed80 into main Apr 10, 2026
1 check passed
@rz1989s rz1989s deleted the feat/platform-abstraction branch April 10, 2026 04:04
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