feat(deploy): platform handoff — agent routing, persistence, docs cleanup
Agent routing: - Remove !agent command and manual agent selection flow - Registry auto-assigns agent from user_agents mapping (fallback: agents[0]) - provision_workspace_chat and !new both write agent_id to room_meta - Reconciliation backfills agent_id from registry on cold start - Fix duplicate agent_id block in auth.py Deployment stability: - Add bot-state named volume to persist lambda_matrix.db and matrix_store - Fix docker-compose.prod.yml duplicate environment: key (was silently losing all Matrix credentials) - Fix MATRIX_AGENT_REGISTRY_PATH to use absolute container path /app/config/... - Add bot-state volume declaration to docker-compose.fullstack.yml Docs and config: - Rewrite README.md for platform handoff (deploy table, working commands only) - Rewrite docs/matrix-prototype.md (remove stale commands and mock descriptions) - Remove !save/!load/!context/!agent from help text and welcome message - Add !clear, !list, !remove, !yes/!no to help text - Clean up .env.example (remove Telegram token, internal vars, real URLs) - Update config/matrix-agents.example.yaml with user_agents section and comments - Add explanatory comment to Dockerfile for --ignore-requires-python - Remove silent uv sync fallbacks in Dockerfile
This commit is contained in:
parent
380961d6e9
commit
b1aaa210a1
21 changed files with 311 additions and 937 deletions
|
|
@ -6,6 +6,7 @@ import structlog
|
|||
from nio.api import RoomVisibility
|
||||
from nio.responses import RoomCreateError
|
||||
|
||||
from adapter.matrix.agent_registry import AgentRegistry
|
||||
from adapter.matrix.store import (
|
||||
get_user_meta,
|
||||
next_platform_chat_id,
|
||||
|
|
@ -30,6 +31,7 @@ async def provision_workspace_chat(
|
|||
auth_mgr,
|
||||
chat_mgr,
|
||||
room_name_override: str | None = None,
|
||||
registry: AgentRegistry | None = None,
|
||||
) -> dict:
|
||||
user = await platform.get_or_create_user(
|
||||
external_id=matrix_user_id,
|
||||
|
|
@ -64,6 +66,13 @@ async def provision_workspace_chat(
|
|||
chat_id = f"C{next_chat_index}"
|
||||
platform_chat_id = await next_platform_chat_id(store)
|
||||
room_name = room_name_override or _default_room_name(chat_id)
|
||||
|
||||
agent_id = None
|
||||
if registry is not None:
|
||||
agent_id = registry.get_agent_id_for_user(matrix_user_id)
|
||||
if agent_id is None and registry.agents:
|
||||
agent_id = registry.agents[0].agent_id
|
||||
|
||||
chat_resp = await client.room_create(
|
||||
name=room_name,
|
||||
visibility=RoomVisibility.private,
|
||||
|
|
@ -100,6 +109,7 @@ async def provision_workspace_chat(
|
|||
"matrix_user_id": matrix_user_id,
|
||||
"space_id": space_id,
|
||||
"platform_chat_id": platform_chat_id,
|
||||
"agent_id": agent_id,
|
||||
},
|
||||
)
|
||||
await chat_mgr.get_or_create(
|
||||
|
|
@ -127,6 +137,7 @@ async def handle_invite(
|
|||
store,
|
||||
auth_mgr,
|
||||
chat_mgr,
|
||||
registry: AgentRegistry | None = None,
|
||||
) -> None:
|
||||
matrix_user_id = getattr(event, "sender", "")
|
||||
display_name = getattr(room, "display_name", None) or matrix_user_id
|
||||
|
|
@ -147,6 +158,7 @@ async def handle_invite(
|
|||
auth_mgr,
|
||||
chat_mgr,
|
||||
room_name_override="Чат 1",
|
||||
registry=registry,
|
||||
)
|
||||
except RuntimeError as exc:
|
||||
logger.error("invite_workspace_provision_failed", user=matrix_user_id, error=str(exc))
|
||||
|
|
@ -154,7 +166,7 @@ async def handle_invite(
|
|||
|
||||
welcome = (
|
||||
f"Привет, {created['user'].display_name or matrix_user_id}! Пиши — я здесь.\n\n"
|
||||
"Команды: !new · !chats · !rename · !archive · !context · !save · !load · !help"
|
||||
"Команды: !new · !chats · !rename · !archive · !clear · !help"
|
||||
)
|
||||
await client.room_send(
|
||||
created["chat_room_id"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue