max first steps
This commit is contained in:
parent
3340c126d6
commit
eed1533cdc
10 changed files with 589 additions and 0 deletions
1
adapter/max/handlers/__init__.py
Normal file
1
adapter/max/handlers/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""MAX surface handlers."""
|
||||
29
adapter/max/handlers/attachments.py
Normal file
29
adapter/max/handlers/attachments.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""Attachment queue handlers for MAX surface."""
|
||||
from adapter.max.store import ChatStore
|
||||
|
||||
|
||||
class AttachmentHandler:
|
||||
def __init__(self, store: ChatStore):
|
||||
self.store = store
|
||||
|
||||
def handle_list(self, max_chat_id: str) -> str:
|
||||
attachments = self.store.get_attachments(max_chat_id)
|
||||
if not attachments:
|
||||
return "Attachment queue is empty."
|
||||
lines = [f" {i+1}. {name}" for i, (_, name) in enumerate(attachments)]
|
||||
return "\n".join(lines)
|
||||
|
||||
def handle_remove(self, max_chat_id: str, index: str) -> str:
|
||||
attachments = self.store.staged_attachments.get(max_chat_id, [])
|
||||
if index.lower() == "all":
|
||||
self.store.staged_attachments[max_chat_id] = []
|
||||
return "All attachments removed from queue."
|
||||
|
||||
try:
|
||||
idx = int(index) - 1
|
||||
if 0 <= idx < len(attachments):
|
||||
removed = attachments.pop(idx)
|
||||
return f"Removed: {removed[1]}"
|
||||
return "Invalid index."
|
||||
except ValueError:
|
||||
return "Usage: !remove <number> or !remove all"
|
||||
48
adapter/max/handlers/chat.py
Normal file
48
adapter/max/handlers/chat.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
"""Chat management handlers for MAX surface."""
|
||||
import uuid
|
||||
from adapter.max.store import ChatStore, RoomMeta
|
||||
|
||||
|
||||
class ChatHandler:
|
||||
def __init__(self, store: ChatStore):
|
||||
self.store = store
|
||||
|
||||
def handle_new(self, max_chat_id: str, user_id: str, agent_id: str, name: str = None) -> str:
|
||||
platform_chat_id = str(uuid.uuid4())
|
||||
room = RoomMeta(
|
||||
platform_chat_id=platform_chat_id,
|
||||
max_chat_id=max_chat_id,
|
||||
name=name or "New Chat",
|
||||
user_id=user_id,
|
||||
agent_id=agent_id,
|
||||
)
|
||||
self.store.add_room(room)
|
||||
return platform_chat_id
|
||||
|
||||
def handle_chats(self, user_id: str) -> str:
|
||||
rooms = self.store.list_rooms_for_user(user_id)
|
||||
if not rooms:
|
||||
return "No active chats."
|
||||
lines = [f" {i+1}. {r.name}" for i, r in enumerate(rooms)]
|
||||
return "\n".join(lines)
|
||||
|
||||
def handle_rename(self, max_chat_id: str, new_name: str) -> str:
|
||||
room = self.store.get_room_by_max_chat_id(max_chat_id)
|
||||
if not room:
|
||||
return "Chat not found."
|
||||
room.name = new_name
|
||||
return f"Chat renamed to: {new_name}"
|
||||
|
||||
def handle_archive(self, max_chat_id: str) -> str:
|
||||
room = self.store.get_room_by_max_chat_id(max_chat_id)
|
||||
if not room:
|
||||
return "Chat not found."
|
||||
self.store.remove_room(max_chat_id)
|
||||
return "Chat archived."
|
||||
|
||||
def handle_clear(self, max_chat_id: str) -> str:
|
||||
room = self.store.get_room_by_max_chat_id(max_chat_id)
|
||||
if not room:
|
||||
return "Chat not found."
|
||||
room.platform_chat_id = str(uuid.uuid4())
|
||||
return "Chat context cleared."
|
||||
26
adapter/max/handlers/help.py
Normal file
26
adapter/max/handlers/help.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"""Help handler for MAX surface."""
|
||||
|
||||
HELP_TEXT = """
|
||||
Available commands:
|
||||
|
||||
Chat management:
|
||||
!new [name] — Create a new chat
|
||||
!chats — List active chats
|
||||
!rename <name> — Rename current chat
|
||||
!archive — Archive current chat
|
||||
!clear / !reset — Reset chat context
|
||||
|
||||
Attachments:
|
||||
!list — Show attachment queue
|
||||
!remove <n> — Remove attachment from queue
|
||||
!remove all — Clear attachment queue
|
||||
|
||||
Actions:
|
||||
!yes — Confirm agent action
|
||||
!no — Cancel agent action
|
||||
!help — Show this help
|
||||
"""
|
||||
|
||||
|
||||
def get_help() -> str:
|
||||
return HELP_TEXT.strip()
|
||||
Loading…
Add table
Add a link
Reference in a new issue