From 1efecaef1f867cb218366e2b4ab4b901fdd2835f Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sat, 4 Jul 2026 14:54:45 +0900 Subject: 途中経過コミット MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mcp/tools/common/context.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/mcp/tools/common/context.c') diff --git a/src/mcp/tools/common/context.c b/src/mcp/tools/common/context.c index d79b5de..e833f70 100644 --- a/src/mcp/tools/common/context.c +++ b/src/mcp/tools/common/context.c @@ -43,10 +43,12 @@ tiny_mcp_tools_context_new(tiny_store_t *store) context->store = store; context->search_index = tiny_mcp_tools_build_search_index(store); context->history_index = tiny_history_index_build(store); - if (!context->search_index || !context->history_index) + context->memory_index = tiny_memory_index_build(store); + if (!context->search_index || !context->history_index || !context->memory_index) { tiny_search_index_free(context->search_index); tiny_history_index_free(context->history_index); + tiny_memory_index_free(context->memory_index); free(context); return NULL; } @@ -62,9 +64,39 @@ tiny_mcp_tools_context_free(tiny_mcp_tools_context_t *context) } tiny_search_index_free(context->search_index); tiny_history_index_free(context->history_index); + tiny_memory_index_free(context->memory_index); free(context); } +bool +tiny_mcp_tools_ensure_memory_index(tiny_mcp_tools_context_t *context) +{ + if (!context) + { + return false; + } + if (!context->memory_index) + { + context->memory_index = tiny_memory_index_build(context->store); + } + return context->memory_index != NULL; +} + +void +tiny_mcp_tools_invalidate_indexes(tiny_mcp_tools_context_t *context) +{ + if (!context) + { + return; + } + tiny_search_index_free(context->search_index); + tiny_history_index_free(context->history_index); + tiny_memory_index_free(context->memory_index); + context->search_index = NULL; + context->history_index = NULL; + context->memory_index = NULL; +} + bool tiny_mcp_tools_context_activate(tiny_mcp_tools_context_t *context) { -- cgit v1.2.3