mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
627b673a5c
* refactor: restructure memory into multi-provider adapters, remove manifest.json dependency - Rename internal/memory/provider to internal/memory/adapters with per-provider subdirectories (builtin, mem0, openviking) - Replace manifest.json-based delete/update with scan-based index from daily files - Add mem0 and openviking provider adapters with HTTP client, chat hooks, MCP tools, and CRUD - Wire provider lifecycle into registry (auto-instantiate on create, evict on update/delete) - Split docker-compose into base stack + optional overlays (qdrant, browser, mem0, openviking) - Update admin UI to support dynamic provider config schema rendering * chore(lint): fix all golangci-lint issues for clean CI * refactor(docker): replace compose overlay files with profiles * feat(memory): add built-in memory multi modes * fix(ci): golangci lint * feat(memory): edit built-in memory sparse design
48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
package adapters
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/memohai/memoh/internal/mcp"
|
|
)
|
|
|
|
// Provider is the unified interface for memory systems. Each provider type
|
|
// (builtin, mem0, openviking, etc.) implements this independently with its
|
|
// own storage, retrieval, and tool logic.
|
|
type Provider interface {
|
|
// Type returns the provider type identifier (e.g. "builtin", "mem0").
|
|
Type() string
|
|
|
|
// --- Conversation Hooks ---
|
|
|
|
OnBeforeChat(ctx context.Context, req BeforeChatRequest) (*BeforeChatResult, error)
|
|
OnAfterChat(ctx context.Context, req AfterChatRequest) error
|
|
|
|
// --- MCP Tools ---
|
|
|
|
ListTools(ctx context.Context, session mcp.ToolSessionContext) ([]mcp.ToolDescriptor, error)
|
|
CallTool(ctx context.Context, session mcp.ToolSessionContext, toolName string, arguments map[string]any) (map[string]any, error)
|
|
|
|
// --- CRUD ---
|
|
|
|
Add(ctx context.Context, req AddRequest) (SearchResponse, error)
|
|
Search(ctx context.Context, req SearchRequest) (SearchResponse, error)
|
|
GetAll(ctx context.Context, req GetAllRequest) (SearchResponse, error)
|
|
Update(ctx context.Context, req UpdateRequest) (MemoryItem, error)
|
|
Delete(ctx context.Context, memoryID string) (DeleteResponse, error)
|
|
DeleteBatch(ctx context.Context, memoryIDs []string) (DeleteResponse, error)
|
|
DeleteAll(ctx context.Context, req DeleteAllRequest) (DeleteResponse, error)
|
|
|
|
// --- Lifecycle ---
|
|
|
|
Compact(ctx context.Context, filters map[string]any, ratio float64, decayDays int) (CompactResult, error)
|
|
Usage(ctx context.Context, filters map[string]any) (UsageResponse, error)
|
|
}
|
|
|
|
// SourceSyncProvider is implemented by providers that can report runtime status
|
|
// and rebuild derived storage from a canonical source of truth.
|
|
type SourceSyncProvider interface {
|
|
Status(ctx context.Context, botID string) (MemoryStatusResponse, error)
|
|
Rebuild(ctx context.Context, botID string) (RebuildResult, error)
|
|
}
|