feat(04-02): add matrix context management commands
- add save/load/reset/context handlers and matrix interception flows - persist current session and last token usage in prototype state
This commit is contained in:
parent
da0b76882e
commit
b52fdc4670
7 changed files with 638 additions and 21 deletions
|
|
@ -7,6 +7,12 @@ from adapter.matrix.handlers.chat import (
|
|||
make_handle_rename,
|
||||
)
|
||||
from adapter.matrix.handlers.confirm import make_handle_cancel, make_handle_confirm
|
||||
from adapter.matrix.handlers.context_commands import (
|
||||
make_handle_context,
|
||||
make_handle_load,
|
||||
make_handle_reset,
|
||||
make_handle_save,
|
||||
)
|
||||
from adapter.matrix.handlers.settings import (
|
||||
handle_help,
|
||||
handle_settings,
|
||||
|
|
@ -23,7 +29,14 @@ from core.handler import EventDispatcher
|
|||
from core.protocol import IncomingCallback, IncomingCommand
|
||||
|
||||
|
||||
def register_matrix_handlers(dispatcher: EventDispatcher, client=None, store=None) -> None:
|
||||
def register_matrix_handlers(
|
||||
dispatcher: EventDispatcher,
|
||||
client=None,
|
||||
store=None,
|
||||
agent_api=None,
|
||||
prototype_state=None,
|
||||
agent_base_url: str = "http://127.0.0.1:8000",
|
||||
) -> None:
|
||||
dispatcher.register(IncomingCommand, "new", make_handle_new_chat(client, store))
|
||||
dispatcher.register(IncomingCommand, "chats", handle_list_chats)
|
||||
dispatcher.register(IncomingCommand, "rename", make_handle_rename(client, store))
|
||||
|
|
@ -41,3 +54,9 @@ def register_matrix_handlers(dispatcher: EventDispatcher, client=None, store=Non
|
|||
dispatcher.register(IncomingCallback, "confirm", make_handle_confirm(store))
|
||||
dispatcher.register(IncomingCallback, "cancel", make_handle_cancel(store))
|
||||
dispatcher.register(IncomingCallback, "toggle_skill", handle_toggle_skill)
|
||||
|
||||
if agent_api is not None and prototype_state is not None:
|
||||
dispatcher.register(IncomingCommand, "save", make_handle_save(agent_api, store, prototype_state))
|
||||
dispatcher.register(IncomingCommand, "load", make_handle_load(store, prototype_state))
|
||||
dispatcher.register(IncomingCommand, "reset", make_handle_reset(store, agent_base_url))
|
||||
dispatcher.register(IncomingCommand, "context", make_handle_context(store, prototype_state))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue