init: surfaces-bot — Telegram & Matrix prototype

- Surface Protocol: unified IncomingMessage/OutgoingUI/ChatContext
- Telegram: Forum Topics (group + topics per chat)
- Matrix: Space + rooms per chat
- MockPlatformClient with PlatformClient Protocol
- docs: surface-protocol, telegram/matrix specs, api-contract, claude-code-guide
- project scaffold: src/, tests/, pyproject.toml

Co-Authored-By: Claude Sonnet 4-6 <noreply@anthropic.com>
This commit is contained in:
Mikhail Putilovskij 2026-03-27 00:35:42 +03:00
commit b6df29bd9b
29 changed files with 2504 additions and 0 deletions

68
docs/user-flow.md Normal file
View file

@ -0,0 +1,68 @@
# User Flow — Lambda Bot
> **Статус:** ШАБЛОН — заполняет @architect после исследований
> **Зависит от:** docs/research/telegram-flows.md, docs/research/competitor-ux.md
---
## Основной сценарий (happy path)
```mermaid
sequenceDiagram
actor User
participant Bot as Telegram/Matrix Bot
participant Platform as Lambda Platform
User->>Bot: /start
Bot->>Platform: GET /users/{tg_id}?platform=telegram
Platform-->>Bot: {user_id, is_new}
alt Новый пользователь
Bot->>User: Приветствие + инструкция
else Существующий пользователь
Bot->>User: Добро пожаловать обратно
end
User->>Bot: Любое сообщение
Bot->>Platform: POST /sessions (создаём сессию)
Platform-->>Bot: {session_id, agent_id}
loop Диалог
User->>Bot: Сообщение
Bot->>Platform: POST /sessions/{id}/messages
Platform-->>Bot: {response}
Bot->>User: Ответ агента
end
User->>Bot: /end или таймаут
Bot->>Platform: DELETE /sessions/{id}
Bot->>User: Сессия завершена
```
---
## Состояния FSM (Telegram)
```mermaid
stateDiagram-v2
[*] --> Idle: /start
Idle --> InSession: любое сообщение
InSession --> InSession: сообщение пользователя
InSession --> Idle: /end
InSession --> Error: ошибка платформы
Error --> Idle: /start
Error --> InSession: retry
```
---
## Открытые вопросы
> Заполняет @researcher и @architect после исследований
- [ ] Как выглядит онбординг новых пользователей у конкурентов?
- [ ] Нужна ли кнопка "Новая сессия" или сессия стартует автоматически?
- [ ] Что показываем пока агент думает (typing indicator)?
- [ ] Как обрабатываем timeout ответа от платформы?