Platform abstraction layer — AgentCore + web adapter#144
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extracts a platform-agnostic
AgentCoreclass 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 → responseroutes/command.tsdeleted (replaced by adapter)Architecture after this PR:
New files
packages/agent/src/core/types.ts— Platform, MsgContext, ResponseChunk, AgentResponsepackages/agent/src/core/agent-core.ts— AgentCore classpackages/agent/src/adapters/web.ts— createWebAdapter()packages/agent/tests/core/agent-core.test.ts— 4 testspackages/agent/tests/adapters/web.test.ts— 12 testsTest plan
tsc --noEmitcleanapp buildclean