feat(deploy): finalize MVP deployment and file transfer approach
This commit is contained in:
parent
6369721876
commit
0f79494fbe
43 changed files with 3078 additions and 645 deletions
|
|
@ -48,7 +48,9 @@ def _chat_id_from_room(room: object, existing_meta: dict | None) -> str | None:
|
|||
return None
|
||||
|
||||
|
||||
def _space_id_for_room(room: object, rooms_by_id: dict[str, object], existing_meta: dict | None) -> str | None:
|
||||
def _space_id_for_room(
|
||||
room: object, rooms_by_id: dict[str, object], existing_meta: dict | None
|
||||
) -> str | None:
|
||||
existing_space_id = (existing_meta or {}).get("space_id")
|
||||
if isinstance(existing_space_id, str) and existing_space_id:
|
||||
return existing_space_id
|
||||
|
|
@ -69,7 +71,9 @@ def _space_id_for_room(room: object, rooms_by_id: dict[str, object], existing_me
|
|||
return None
|
||||
|
||||
|
||||
def _matrix_user_id_for_room(room: object, bot_user_id: str | None, existing_meta: dict | None) -> str | None:
|
||||
def _matrix_user_id_for_room(
|
||||
room: object, bot_user_id: str | None, existing_meta: dict | None
|
||||
) -> str | None:
|
||||
existing_user_id = (existing_meta or {}).get("matrix_user_id")
|
||||
if isinstance(existing_user_id, str) and existing_user_id:
|
||||
return existing_user_id
|
||||
|
|
@ -128,11 +132,26 @@ async def reconcile_startup_state(client: object, runtime: object) -> Reconcilia
|
|||
if not room_meta.get("agent_id"):
|
||||
registry = getattr(runtime, "registry", 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
|
||||
if agent_id:
|
||||
room_meta["agent_id"] = agent_id
|
||||
assignment = registry.resolve_agent_for_user(matrix_user_id)
|
||||
if assignment.agent_id:
|
||||
room_meta["agent_id"] = assignment.agent_id
|
||||
room_meta["agent_assignment"] = assignment.source
|
||||
else:
|
||||
registry = getattr(runtime, "registry", None)
|
||||
if registry is not None:
|
||||
assignment = registry.resolve_agent_for_user(matrix_user_id)
|
||||
if assignment.source == "configured" and (
|
||||
room_meta.get("agent_id") != assignment.agent_id
|
||||
or room_meta.get("agent_assignment") != "configured"
|
||||
):
|
||||
room_meta["agent_id"] = assignment.agent_id
|
||||
room_meta["agent_assignment"] = "configured"
|
||||
elif (
|
||||
assignment.source == "default"
|
||||
and room_meta.get("agent_id") == assignment.agent_id
|
||||
and not room_meta.get("agent_assignment")
|
||||
):
|
||||
room_meta["agent_assignment"] = "default"
|
||||
|
||||
if existing_meta is None:
|
||||
result.recovered_rooms += 1
|
||||
|
|
@ -153,7 +172,9 @@ async def reconcile_startup_state(client: object, runtime: object) -> Reconcilia
|
|||
user_meta = dict(await get_user_meta(runtime.store, matrix_user_id) or {})
|
||||
user_meta["space_id"] = user_meta.get("space_id") or recovered_space_id
|
||||
next_chat_index = max_chat_index_by_user[matrix_user_id] + 1
|
||||
user_meta["next_chat_index"] = max(int(user_meta.get("next_chat_index", 1)), next_chat_index)
|
||||
user_meta["next_chat_index"] = max(
|
||||
int(user_meta.get("next_chat_index", 1)), next_chat_index
|
||||
)
|
||||
await set_user_meta(runtime.store, matrix_user_id, user_meta)
|
||||
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue