feat: add chat history MCP tools

Adds save/get/list/delete tools for persisting and retrieving agent
chat histories in AMCS.

Changes:
- migrations/018_chat_histories.sql: new chat_histories table with
  indexes on session_id, project_id, channel, agent_id, created_at,
  and FTS over title+summary
- internal/types/extensions.go: ChatMessage and ChatHistory types
- internal/store/chat_histories.go: SaveChatHistory, GetChatHistory,
  GetChatHistoryBySessionID, ListChatHistories, DeleteChatHistory
- internal/tools/chat_history.go: ChatHistoryTool with four handlers
  (save_chat_history, get_chat_history, list_chat_histories,
  delete_chat_history)
- internal/mcpserver/server.go: ChatHistory field in ToolSet,
  registerChatHistoryTools registration function
- internal/app/app.go: wire ChatHistoryTool into ToolSet
This commit is contained in:
sam
2026-04-01 16:06:56 +02:00
parent bb759f4683
commit 741a09017b
6 changed files with 445 additions and 0 deletions

View File

@@ -236,3 +236,24 @@ type AgentGuardrail struct {
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Chat Histories
type ChatMessage struct {
Role string `json:"role"`
Content string `json:"content"`
}
type ChatHistory struct {
ID uuid.UUID `json:"id"`
SessionID string `json:"session_id"`
Title string `json:"title,omitempty"`
Channel string `json:"channel,omitempty"`
AgentID string `json:"agent_id,omitempty"`
ProjectID *uuid.UUID `json:"project_id,omitempty"`
Messages []ChatMessage `json:"messages"`
Summary string `json:"summary,omitempty"`
Metadata map[string]any `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}