Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,343 changes: 3,802 additions & 3,541 deletions agent/api_server.py

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions agent/src/platforms/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from src.platforms.base import BasePlatformAdapter, IncomingMessage
from src.platforms.feishu import FeishuAdapter
from src.platforms.manager import PlatformManager

__all__ = ["BasePlatformAdapter", "IncomingMessage", "FeishuAdapter", "PlatformManager"]
60 changes: 60 additions & 0 deletions agent/src/platforms/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Any, Dict, Optional


@dataclass
class IncomingMessage:
"""Standardized representation of an incoming message from any platform."""
platform: str
chat_id: str
message_id: str
content: str
sender_id: str
timestamp: float
raw_payload: Dict[str, Any] = field(default_factory=dict)


class BasePlatformAdapter(ABC):
"""Abstract Base Class for all messaging platform adapters (Feishu, Telegram, DingTalk, etc.)."""

@property
@abstractmethod
def platform_name(self) -> str:
"""The identifier name of the platform (e.g. 'feishu')."""
pass

@abstractmethod
async def initialize(self, manager: Any) -> None:
"""Initialize connection, start listeners or webhooks, register platform manager reference."""
pass

@abstractmethod
async def send_message(
self,
chat_id: str,
content: str,
title: Optional[str] = None,
) -> str:
"""Send a message to a specific chat channel.

Returns:
The platform-specific message ID.
"""
pass

@abstractmethod
async def update_message(
self,
chat_id: str,
message_id: str,
content: str,
title: Optional[str] = None,
) -> None:
"""Update an existing message (if supported by the platform, such as Feishu message cards)."""
pass

@abstractmethod
async def close(self) -> None:
"""Clean up connections, threads, and socket clients."""
pass
Loading