aip-agents-binary 0.6.1__py3-none-any.whl → 0.6.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aip_agents/examples/hello_world_ptc.py +1 -3
- aip_agents/tools/execute_ptc_code.py +19 -16
- {aip_agents_binary-0.6.1.dist-info → aip_agents_binary-0.6.2.dist-info}/METADATA +1 -1
- {aip_agents_binary-0.6.1.dist-info → aip_agents_binary-0.6.2.dist-info}/RECORD +6 -304
- aip_agents/__init__.pyi +0 -19
- aip_agents/a2a/__init__.pyi +0 -3
- aip_agents/a2a/server/__init__.pyi +0 -4
- aip_agents/a2a/server/base_executor.pyi +0 -73
- aip_agents/a2a/server/google_adk_executor.pyi +0 -51
- aip_agents/a2a/server/langflow_executor.pyi +0 -43
- aip_agents/a2a/server/langgraph_executor.pyi +0 -47
- aip_agents/a2a/types.pyi +0 -132
- aip_agents/agent/__init__.pyi +0 -9
- aip_agents/agent/base_agent.pyi +0 -221
- aip_agents/agent/base_langgraph_agent.pyi +0 -233
- aip_agents/agent/google_adk_agent.pyi +0 -141
- aip_agents/agent/google_adk_constants.pyi +0 -3
- aip_agents/agent/hitl/__init__.pyi +0 -6
- aip_agents/agent/hitl/config.pyi +0 -15
- aip_agents/agent/hitl/langgraph_hitl_mixin.pyi +0 -42
- aip_agents/agent/hitl/manager.pyi +0 -200
- aip_agents/agent/hitl/models.pyi +0 -3
- aip_agents/agent/hitl/prompt/__init__.pyi +0 -4
- aip_agents/agent/hitl/prompt/base.pyi +0 -24
- aip_agents/agent/hitl/prompt/deferred.pyi +0 -30
- aip_agents/agent/hitl/registry.pyi +0 -101
- aip_agents/agent/interface.pyi +0 -81
- aip_agents/agent/interfaces.pyi +0 -44
- aip_agents/agent/langflow_agent.pyi +0 -133
- aip_agents/agent/langgraph_memory_enhancer_agent.pyi +0 -49
- aip_agents/agent/langgraph_react_agent.pyi +0 -170
- aip_agents/agent/system_instruction_context.pyi +0 -13
- aip_agents/clients/__init__.pyi +0 -4
- aip_agents/clients/langflow/__init__.pyi +0 -4
- aip_agents/clients/langflow/client.pyi +0 -140
- aip_agents/clients/langflow/types.pyi +0 -7
- aip_agents/constants.pyi +0 -7
- aip_agents/examples/__init__.pyi +0 -0
- aip_agents/examples/compare_streaming_client.pyi +0 -48
- aip_agents/examples/compare_streaming_server.pyi +0 -18
- aip_agents/examples/demo_memory_recall.pyi +0 -58
- aip_agents/examples/hello_world_a2a_google_adk_client.pyi +0 -9
- aip_agents/examples/hello_world_a2a_google_adk_client_agent.pyi +0 -9
- aip_agents/examples/hello_world_a2a_google_adk_client_streaming.pyi +0 -9
- aip_agents/examples/hello_world_a2a_google_adk_server.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langchain_client.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_client_agent.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_client_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_client_streaming.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_reference_client_streaming.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langchain_reference_server.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langchain_server.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langchain_server_lm_invoker.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langflow_client.pyi +0 -9
- aip_agents/examples/hello_world_a2a_langflow_server.pyi +0 -14
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client_streaming.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langgraph_artifact_server.pyi +0 -16
- aip_agents/examples/hello_world_a2a_langgraph_client.pyi +0 -9
- aip_agents/examples/hello_world_a2a_langgraph_client_agent.pyi +0 -9
- aip_agents/examples/hello_world_a2a_langgraph_client_agent_lm_invoker.pyi +0 -2
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming.pyi +0 -9
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_tool_streaming.pyi +0 -5
- aip_agents/examples/hello_world_a2a_langgraph_server.pyi +0 -14
- aip_agents/examples/hello_world_a2a_langgraph_server_lm_invoker.pyi +0 -15
- aip_agents/examples/hello_world_a2a_langgraph_server_tool_streaming.pyi +0 -15
- aip_agents/examples/hello_world_a2a_mcp_langgraph.pyi +0 -48
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_client.pyi +0 -48
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_server.pyi +0 -45
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_client.pyi +0 -5
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_server_lm_invoker.pyi +0 -15
- aip_agents/examples/hello_world_google_adk.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_http.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_http_stream.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_sse.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_sse_stream.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_stdio.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_mcp_stdio_stream.pyi +0 -5
- aip_agents/examples/hello_world_google_adk_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain.pyi +0 -5
- aip_agents/examples/hello_world_langchain_lm_invoker.pyi +0 -2
- aip_agents/examples/hello_world_langchain_mcp_http.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_http_interactive.pyi +0 -16
- aip_agents/examples/hello_world_langchain_mcp_http_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_multi_server.pyi +0 -18
- aip_agents/examples/hello_world_langchain_mcp_sse.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_sse_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_stdio.pyi +0 -5
- aip_agents/examples/hello_world_langchain_mcp_stdio_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain_stream.pyi +0 -5
- aip_agents/examples/hello_world_langchain_stream_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_langflow_agent.pyi +0 -35
- aip_agents/examples/hello_world_langgraph.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_gl_connector_twitter.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_http.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_http_stream.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_sse.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_sse_stream.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_stdio.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_mcp_stdio_stream.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_stream.pyi +0 -5
- aip_agents/examples/hello_world_langgraph_stream_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_model_switch_cli.pyi +0 -30
- aip_agents/examples/hello_world_multi_agent_adk.pyi +0 -6
- aip_agents/examples/hello_world_multi_agent_langchain.pyi +0 -5
- aip_agents/examples/hello_world_multi_agent_langgraph.pyi +0 -5
- aip_agents/examples/hello_world_multi_agent_langgraph_lm_invoker.pyi +0 -5
- aip_agents/examples/hello_world_pii_logger.pyi +0 -5
- aip_agents/examples/hello_world_ptc.pyi +0 -5
- aip_agents/examples/hello_world_sentry.pyi +0 -21
- aip_agents/examples/hello_world_step_limits.pyi +0 -17
- aip_agents/examples/hello_world_stock_a2a_server.pyi +0 -17
- aip_agents/examples/hello_world_tool_output_client.pyi +0 -5
- aip_agents/examples/hello_world_tool_output_server.pyi +0 -19
- aip_agents/examples/hitl_demo.pyi +0 -67
- aip_agents/examples/pii_demo_langgraph_client.pyi +0 -5
- aip_agents/examples/pii_demo_langgraph_server.pyi +0 -20
- aip_agents/examples/pii_demo_multi_agent_client.pyi +0 -5
- aip_agents/examples/pii_demo_multi_agent_server.pyi +0 -40
- aip_agents/examples/todolist_planning_a2a_langchain_client.pyi +0 -5
- aip_agents/examples/todolist_planning_a2a_langgraph_server.pyi +0 -19
- aip_agents/examples/tools/__init__.pyi +0 -9
- aip_agents/examples/tools/adk_arithmetic_tools.pyi +0 -24
- aip_agents/examples/tools/adk_weather_tool.pyi +0 -18
- aip_agents/examples/tools/data_generator_tool.pyi +0 -15
- aip_agents/examples/tools/data_visualization_tool.pyi +0 -19
- aip_agents/examples/tools/image_artifact_tool.pyi +0 -26
- aip_agents/examples/tools/langchain_arithmetic_tools.pyi +0 -17
- aip_agents/examples/tools/langchain_currency_exchange_tool.pyi +0 -20
- aip_agents/examples/tools/langchain_graph_artifact_tool.pyi +0 -25
- aip_agents/examples/tools/langchain_weather_tool.pyi +0 -19
- aip_agents/examples/tools/langgraph_streaming_tool.pyi +0 -43
- aip_agents/examples/tools/mock_retrieval_tool.pyi +0 -13
- aip_agents/examples/tools/pii_demo_tools.pyi +0 -54
- aip_agents/examples/tools/random_chart_tool.pyi +0 -20
- aip_agents/examples/tools/serper_tool.pyi +0 -16
- aip_agents/examples/tools/stock_tools.pyi +0 -36
- aip_agents/examples/tools/table_generator_tool.pyi +0 -22
- aip_agents/examples/tools/time_tool.pyi +0 -15
- aip_agents/examples/tools/weather_forecast_tool.pyi +0 -14
- aip_agents/guardrails/__init__.pyi +0 -6
- aip_agents/guardrails/engines/__init__.pyi +0 -4
- aip_agents/guardrails/engines/base.pyi +0 -61
- aip_agents/guardrails/engines/nemo.pyi +0 -46
- aip_agents/guardrails/engines/phrase_matcher.pyi +0 -48
- aip_agents/guardrails/exceptions.pyi +0 -23
- aip_agents/guardrails/manager.pyi +0 -42
- aip_agents/guardrails/middleware.pyi +0 -87
- aip_agents/guardrails/schemas.pyi +0 -43
- aip_agents/guardrails/utils.pyi +0 -19
- aip_agents/mcp/__init__.pyi +0 -0
- aip_agents/mcp/client/__init__.pyi +0 -5
- aip_agents/mcp/client/base_mcp_client.pyi +0 -148
- aip_agents/mcp/client/connection_manager.pyi +0 -51
- aip_agents/mcp/client/google_adk/__init__.pyi +0 -3
- aip_agents/mcp/client/google_adk/client.pyi +0 -75
- aip_agents/mcp/client/langchain/__init__.pyi +0 -3
- aip_agents/mcp/client/langchain/client.pyi +0 -48
- aip_agents/mcp/client/persistent_session.pyi +0 -122
- aip_agents/mcp/client/session_pool.pyi +0 -101
- aip_agents/mcp/client/transports.pyi +0 -132
- aip_agents/mcp/utils/__init__.pyi +0 -0
- aip_agents/mcp/utils/config_validator.pyi +0 -82
- aip_agents/memory/__init__.pyi +0 -5
- aip_agents/memory/adapters/__init__.pyi +0 -4
- aip_agents/memory/adapters/base_adapter.pyi +0 -150
- aip_agents/memory/adapters/mem0.pyi +0 -22
- aip_agents/memory/base.pyi +0 -60
- aip_agents/memory/constants.pyi +0 -25
- aip_agents/memory/factory.pyi +0 -24
- aip_agents/memory/guidance.pyi +0 -3
- aip_agents/memory/simple_memory.pyi +0 -23
- aip_agents/middleware/__init__.pyi +0 -5
- aip_agents/middleware/base.pyi +0 -75
- aip_agents/middleware/manager.pyi +0 -84
- aip_agents/middleware/todolist.pyi +0 -125
- aip_agents/ptc/__init__.pyi +0 -10
- aip_agents/ptc/doc_gen.pyi +0 -40
- aip_agents/ptc/exceptions.pyi +0 -22
- aip_agents/ptc/executor.pyi +0 -73
- aip_agents/ptc/mcp/__init__.pyi +0 -7
- aip_agents/ptc/mcp/sandbox_bridge.pyi +0 -47
- aip_agents/ptc/mcp/templates/__init__.pyi +0 -0
- aip_agents/ptc/naming.pyi +0 -76
- aip_agents/ptc/payload.pyi +0 -15
- aip_agents/ptc/prompt_builder.pyi +0 -55
- aip_agents/ptc/ptc_helper.pyi +0 -1
- aip_agents/ptc/sandbox_bridge.pyi +0 -25
- aip_agents/ptc/template_utils.pyi +0 -13
- aip_agents/ptc/templates/__init__.pyi +0 -0
- aip_agents/sandbox/__init__.pyi +0 -5
- aip_agents/sandbox/defaults.pyi +0 -2
- aip_agents/sandbox/e2b_runtime.pyi +0 -51
- aip_agents/sandbox/template_builder.pyi +0 -36
- aip_agents/sandbox/types.pyi +0 -14
- aip_agents/sandbox/validation.pyi +0 -20
- aip_agents/schema/__init__.pyi +0 -9
- aip_agents/schema/a2a.pyi +0 -40
- aip_agents/schema/agent.pyi +0 -65
- aip_agents/schema/hitl.pyi +0 -89
- aip_agents/schema/langgraph.pyi +0 -28
- aip_agents/schema/model_id.pyi +0 -54
- aip_agents/schema/step_limit.pyi +0 -63
- aip_agents/schema/storage.pyi +0 -21
- aip_agents/sentry/__init__.pyi +0 -3
- aip_agents/sentry/sentry.pyi +0 -48
- aip_agents/storage/__init__.pyi +0 -8
- aip_agents/storage/base.pyi +0 -58
- aip_agents/storage/clients/__init__.pyi +0 -3
- aip_agents/storage/clients/minio_client.pyi +0 -137
- aip_agents/storage/config.pyi +0 -29
- aip_agents/storage/providers/__init__.pyi +0 -5
- aip_agents/storage/providers/base.pyi +0 -88
- aip_agents/storage/providers/memory.pyi +0 -79
- aip_agents/storage/providers/object_storage.pyi +0 -98
- aip_agents/tools/__init__.pyi +0 -10
- aip_agents/tools/browser_use/__init__.pyi +0 -14
- aip_agents/tools/browser_use/action_parser.pyi +0 -18
- aip_agents/tools/browser_use/browser_use_tool.pyi +0 -50
- aip_agents/tools/browser_use/llm_config.pyi +0 -52
- aip_agents/tools/browser_use/minio_storage.pyi +0 -109
- aip_agents/tools/browser_use/schemas.pyi +0 -32
- aip_agents/tools/browser_use/session.pyi +0 -4
- aip_agents/tools/browser_use/session_errors.pyi +0 -53
- aip_agents/tools/browser_use/steel_session_recording.pyi +0 -63
- aip_agents/tools/browser_use/streaming.pyi +0 -81
- aip_agents/tools/browser_use/structured_data_parser.pyi +0 -86
- aip_agents/tools/browser_use/structured_data_recovery.pyi +0 -43
- aip_agents/tools/browser_use/types.pyi +0 -45
- aip_agents/tools/code_sandbox/__init__.pyi +0 -3
- aip_agents/tools/code_sandbox/constant.pyi +0 -4
- aip_agents/tools/code_sandbox/e2b_cloud_sandbox_extended.pyi +0 -102
- aip_agents/tools/code_sandbox/e2b_sandbox_tool.pyi +0 -29
- aip_agents/tools/constants.pyi +0 -138
- aip_agents/tools/document_loader/__init__.pyi +0 -7
- aip_agents/tools/document_loader/base_reader.pyi +0 -75
- aip_agents/tools/document_loader/docx_reader_tool.pyi +0 -10
- aip_agents/tools/document_loader/excel_reader_tool.pyi +0 -26
- aip_agents/tools/document_loader/pdf_reader_tool.pyi +0 -11
- aip_agents/tools/document_loader/pdf_splitter.pyi +0 -18
- aip_agents/tools/execute_ptc_code.pyi +0 -87
- aip_agents/tools/gl_connector/__init__.pyi +0 -3
- aip_agents/tools/gl_connector/tool.pyi +0 -74
- aip_agents/tools/gl_connector_tools.pyi +0 -39
- aip_agents/tools/memory_search/__init__.pyi +0 -5
- aip_agents/tools/memory_search/base.pyi +0 -69
- aip_agents/tools/memory_search/mem0.pyi +0 -19
- aip_agents/tools/memory_search/schema.pyi +0 -15
- aip_agents/tools/memory_search_tool.pyi +0 -3
- aip_agents/tools/time_tool.pyi +0 -16
- aip_agents/tools/tool_config_injector.pyi +0 -26
- aip_agents/tools/web_search/__init__.pyi +0 -3
- aip_agents/tools/web_search/serper_tool.pyi +0 -19
- aip_agents/types/__init__.pyi +0 -36
- aip_agents/types/a2a_events.pyi +0 -3
- aip_agents/utils/__init__.pyi +0 -11
- aip_agents/utils/a2a_connector.pyi +0 -146
- aip_agents/utils/artifact_helpers.pyi +0 -203
- aip_agents/utils/constants.pyi +0 -10
- aip_agents/utils/datetime/__init__.pyi +0 -4
- aip_agents/utils/datetime/normalization.pyi +0 -95
- aip_agents/utils/datetime/timezone.pyi +0 -48
- aip_agents/utils/env_loader.pyi +0 -10
- aip_agents/utils/event_handler_registry.pyi +0 -23
- aip_agents/utils/file_prompt_utils.pyi +0 -21
- aip_agents/utils/final_response_builder.pyi +0 -34
- aip_agents/utils/formatter_llm_client.pyi +0 -71
- aip_agents/utils/langgraph/__init__.pyi +0 -3
- aip_agents/utils/langgraph/converter.pyi +0 -49
- aip_agents/utils/langgraph/tool_managers/__init__.pyi +0 -5
- aip_agents/utils/langgraph/tool_managers/a2a_tool_manager.pyi +0 -35
- aip_agents/utils/langgraph/tool_managers/base_tool_manager.pyi +0 -48
- aip_agents/utils/langgraph/tool_managers/delegation_tool_manager.pyi +0 -56
- aip_agents/utils/langgraph/tool_output_management.pyi +0 -329
- aip_agents/utils/logger.pyi +0 -60
- aip_agents/utils/metadata/__init__.pyi +0 -5
- aip_agents/utils/metadata/activity_metadata_helper.pyi +0 -25
- aip_agents/utils/metadata/activity_narrative/__init__.pyi +0 -7
- aip_agents/utils/metadata/activity_narrative/builder.pyi +0 -35
- aip_agents/utils/metadata/activity_narrative/constants.pyi +0 -10
- aip_agents/utils/metadata/activity_narrative/context.pyi +0 -32
- aip_agents/utils/metadata/activity_narrative/formatters.pyi +0 -48
- aip_agents/utils/metadata/activity_narrative/utils.pyi +0 -12
- aip_agents/utils/metadata/schemas/__init__.pyi +0 -4
- aip_agents/utils/metadata/schemas/activity_schema.pyi +0 -18
- aip_agents/utils/metadata/schemas/thinking_schema.pyi +0 -20
- aip_agents/utils/metadata/thinking_metadata_helper.pyi +0 -4
- aip_agents/utils/metadata_helper.pyi +0 -117
- aip_agents/utils/name_preprocessor/__init__.pyi +0 -6
- aip_agents/utils/name_preprocessor/base_name_preprocessor.pyi +0 -52
- aip_agents/utils/name_preprocessor/google_name_preprocessor.pyi +0 -38
- aip_agents/utils/name_preprocessor/name_preprocessor.pyi +0 -41
- aip_agents/utils/name_preprocessor/openai_name_preprocessor.pyi +0 -34
- aip_agents/utils/pii/__init__.pyi +0 -5
- aip_agents/utils/pii/pii_handler.pyi +0 -96
- aip_agents/utils/pii/pii_helper.pyi +0 -78
- aip_agents/utils/pii/uuid_deanonymizer_mapping.pyi +0 -73
- aip_agents/utils/reference_helper.pyi +0 -81
- aip_agents/utils/sse_chunk_transformer.pyi +0 -166
- aip_agents/utils/step_limit_manager.pyi +0 -112
- aip_agents/utils/token_usage_helper.pyi +0 -60
- {aip_agents_binary-0.6.1.dist-info → aip_agents_binary-0.6.2.dist-info}/WHEEL +0 -0
- {aip_agents_binary-0.6.1.dist-info → aip_agents_binary-0.6.2.dist-info}/top_level.txt +0 -0
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from aip_agents.mcp.client.connection_manager import MCPConnectionManager as MCPConnectionManager
|
|
3
|
-
from aip_agents.mcp.utils.config_validator import validate_allowed_tools_list as validate_allowed_tools_list
|
|
4
|
-
from aip_agents.utils.logger import get_logger as get_logger
|
|
5
|
-
from collections.abc import Awaitable as Awaitable
|
|
6
|
-
from gllm_tools.mcp.client.config import MCPConfiguration
|
|
7
|
-
from mcp import ClientSession
|
|
8
|
-
from mcp.types import CallToolResult, Tool as Tool
|
|
9
|
-
from typing import Any
|
|
10
|
-
|
|
11
|
-
logger: Incomplete
|
|
12
|
-
|
|
13
|
-
class PersistentMCPSession:
|
|
14
|
-
"""Persistent MCP session that reuses connections.
|
|
15
|
-
|
|
16
|
-
This session wrapper manages the connection lifecycle and caches tools
|
|
17
|
-
to avoid repeated initialization overhead. It provides automatic reconnection
|
|
18
|
-
and thread-safe operations.
|
|
19
|
-
|
|
20
|
-
Tool Filtering:
|
|
21
|
-
When allowed_tools is configured, tools are filtered inline during list_tools()
|
|
22
|
-
and permission checked in call_tool() using set lookup.
|
|
23
|
-
"""
|
|
24
|
-
server_name: Incomplete
|
|
25
|
-
config: Incomplete
|
|
26
|
-
connection_manager: Incomplete
|
|
27
|
-
client_session: ClientSession | None
|
|
28
|
-
tools: list[Tool]
|
|
29
|
-
def __init__(self, server_name: str, config: MCPConfiguration, allowed_tools: list[str] | None = None) -> None:
|
|
30
|
-
"""Initialize persistent session.
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
server_name: Name of the MCP server
|
|
34
|
-
config: MCP server configuration
|
|
35
|
-
allowed_tools: Optional list of tool names to allow. None or empty means all tools allowed.
|
|
36
|
-
"""
|
|
37
|
-
async def initialize(self) -> None:
|
|
38
|
-
"""Initialize session once and cache tools.
|
|
39
|
-
|
|
40
|
-
This method is idempotent and can be called multiple times safely.
|
|
41
|
-
|
|
42
|
-
Raises:
|
|
43
|
-
Exception: If session initialization fails
|
|
44
|
-
"""
|
|
45
|
-
async def call_tool(self, name: str, arguments: dict[str, Any]) -> CallToolResult:
|
|
46
|
-
"""Call MCP tool using persistent session.
|
|
47
|
-
|
|
48
|
-
Args:
|
|
49
|
-
name (str): Tool name
|
|
50
|
-
arguments (dict[str, Any]): Tool arguments
|
|
51
|
-
|
|
52
|
-
Returns:
|
|
53
|
-
CallToolResult: Tool call result
|
|
54
|
-
|
|
55
|
-
Raises:
|
|
56
|
-
Exception: If tool call fails
|
|
57
|
-
"""
|
|
58
|
-
async def read_resource(self, uri: str) -> Any:
|
|
59
|
-
"""Read an MCP resource using persistent session.
|
|
60
|
-
|
|
61
|
-
Args:
|
|
62
|
-
uri (str): The URI of the resource to read
|
|
63
|
-
|
|
64
|
-
Returns:
|
|
65
|
-
Any: The resource content
|
|
66
|
-
|
|
67
|
-
Raises:
|
|
68
|
-
Exception: If resource reading fails
|
|
69
|
-
"""
|
|
70
|
-
async def list_tools(self) -> list[Tool]:
|
|
71
|
-
"""Get cached tools list with allowed tools filtering applied.
|
|
72
|
-
|
|
73
|
-
Returns:
|
|
74
|
-
list[Tool]: a copy of list of available tools, filtered to only allowed tools if configured
|
|
75
|
-
"""
|
|
76
|
-
def get_tools_count(self) -> int:
|
|
77
|
-
"""Get count of allowed tools.
|
|
78
|
-
|
|
79
|
-
Returns:
|
|
80
|
-
Count of allowed tools
|
|
81
|
-
"""
|
|
82
|
-
async def ensure_connected(self) -> None:
|
|
83
|
-
"""Ensure connection is healthy, reconnect if needed.
|
|
84
|
-
|
|
85
|
-
This method provides automatic reconnection capability.
|
|
86
|
-
|
|
87
|
-
Raises:
|
|
88
|
-
Exception: If reconnection fails
|
|
89
|
-
"""
|
|
90
|
-
async def disconnect(self) -> None:
|
|
91
|
-
"""Disconnect session gracefully.
|
|
92
|
-
|
|
93
|
-
This method cleans up all resources and connections.
|
|
94
|
-
Always succeeds, even if the session was already in an error state.
|
|
95
|
-
"""
|
|
96
|
-
@property
|
|
97
|
-
def is_initialized(self) -> bool:
|
|
98
|
-
"""Check if session is initialized.
|
|
99
|
-
|
|
100
|
-
Returns:
|
|
101
|
-
bool: True if initialized and connected, False otherwise
|
|
102
|
-
"""
|
|
103
|
-
@property
|
|
104
|
-
def allowed_tools(self) -> list[str] | None:
|
|
105
|
-
"""Return the configured allowed tools, sorted if present.
|
|
106
|
-
|
|
107
|
-
Returns:
|
|
108
|
-
Sorted list of allowed tool names, or None if unrestricted.
|
|
109
|
-
"""
|
|
110
|
-
def update_allowed_tools(self, allowed_tools: list[str] | None) -> bool:
|
|
111
|
-
"""Update the list of allowed tools for this session.
|
|
112
|
-
|
|
113
|
-
Args:
|
|
114
|
-
allowed_tools: New list of allowed tool names or None for no restriction.
|
|
115
|
-
None and empty list both mean 'no restrictions, allow all tools'.
|
|
116
|
-
|
|
117
|
-
Returns:
|
|
118
|
-
bool: True if the configuration changed, False otherwise.
|
|
119
|
-
|
|
120
|
-
Raises:
|
|
121
|
-
ValueError: If allowed_tools contains invalid entries.
|
|
122
|
-
"""
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from aip_agents.mcp.client.persistent_session import PersistentMCPSession as PersistentMCPSession
|
|
3
|
-
from aip_agents.mcp.utils.config_validator import validate_allowed_tools_config as validate_allowed_tools_config, validate_allowed_tools_list as validate_allowed_tools_list
|
|
4
|
-
from aip_agents.utils.logger import get_logger as get_logger
|
|
5
|
-
from gllm_tools.mcp.client.config import MCPConfiguration
|
|
6
|
-
from mcp.types import Tool as Tool
|
|
7
|
-
|
|
8
|
-
logger: Incomplete
|
|
9
|
-
|
|
10
|
-
class MCPSessionPool:
|
|
11
|
-
"""Manages pool of persistent MCP sessions.
|
|
12
|
-
|
|
13
|
-
This pool provides centralized management of MCP sessions, including
|
|
14
|
-
initialization, tool collection, and resource cleanup. Sessions are
|
|
15
|
-
reused across the agent lifecycle.
|
|
16
|
-
"""
|
|
17
|
-
sessions: dict[str, PersistentMCPSession]
|
|
18
|
-
def __init__(self) -> None:
|
|
19
|
-
"""Initialize empty session pool."""
|
|
20
|
-
async def get_or_create_session(self, server_name: str, config: MCPConfiguration, allowed_tools: list[str] | None = None) -> PersistentMCPSession:
|
|
21
|
-
"""Get existing session or create new one.
|
|
22
|
-
|
|
23
|
-
Args:
|
|
24
|
-
server_name (str): Name of the MCP server
|
|
25
|
-
config (MCPConfiguration): MCP server configuration
|
|
26
|
-
allowed_tools (list[str] | None): Optional list of tool names to allow. None means all tools allowed.
|
|
27
|
-
|
|
28
|
-
Returns:
|
|
29
|
-
PersistentMCPSession: Persistent MCP session
|
|
30
|
-
|
|
31
|
-
Raises:
|
|
32
|
-
Exception: If session creation fails
|
|
33
|
-
"""
|
|
34
|
-
async def initialize_all_sessions(self, server_configs: dict[str, MCPConfiguration]) -> None:
|
|
35
|
-
"""Initialize all sessions and cache tools.
|
|
36
|
-
|
|
37
|
-
This method initializes all configured MCP servers concurrently
|
|
38
|
-
for better performance.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
server_configs (dict[str, MCPConfiguration]): Dictionary of server configurations
|
|
42
|
-
|
|
43
|
-
Raises:
|
|
44
|
-
Exception: If any session initialization fails
|
|
45
|
-
"""
|
|
46
|
-
def get_all_active_sessions(self) -> dict[str, PersistentMCPSession]:
|
|
47
|
-
"""Get all active sessions.
|
|
48
|
-
|
|
49
|
-
Returns:
|
|
50
|
-
dict[str, PersistentMCPSession]: Dictionary of active sessions by server name
|
|
51
|
-
"""
|
|
52
|
-
@property
|
|
53
|
-
def active_sessions(self) -> list[str]:
|
|
54
|
-
"""Get list of active session names.
|
|
55
|
-
|
|
56
|
-
Returns:
|
|
57
|
-
list[str]: List of active session names
|
|
58
|
-
"""
|
|
59
|
-
async def get_all_tools(self) -> list[Tool]:
|
|
60
|
-
"""Get all cached tools from all active sessions.
|
|
61
|
-
|
|
62
|
-
Returns:
|
|
63
|
-
list[Tool]: List of all available tools across all sessions
|
|
64
|
-
"""
|
|
65
|
-
async def close_session(self, server_name: str) -> None:
|
|
66
|
-
"""Close specific session.
|
|
67
|
-
|
|
68
|
-
Args:
|
|
69
|
-
server_name (str): Name of the server session to close
|
|
70
|
-
"""
|
|
71
|
-
async def close_all_sessions(self) -> None:
|
|
72
|
-
"""Close all sessions gracefully.
|
|
73
|
-
|
|
74
|
-
This method ensures all resources are cleaned up properly.
|
|
75
|
-
"""
|
|
76
|
-
@property
|
|
77
|
-
def is_initialized(self) -> bool:
|
|
78
|
-
"""Check if session pool is initialized.
|
|
79
|
-
|
|
80
|
-
Returns:
|
|
81
|
-
bool: True if initialized, False otherwise
|
|
82
|
-
"""
|
|
83
|
-
@property
|
|
84
|
-
def session_count(self) -> int:
|
|
85
|
-
"""Get number of active sessions.
|
|
86
|
-
|
|
87
|
-
Returns:
|
|
88
|
-
int: Number of active sessions
|
|
89
|
-
"""
|
|
90
|
-
def get_session(self, server_name: str) -> PersistentMCPSession:
|
|
91
|
-
"""Get specific session by name.
|
|
92
|
-
|
|
93
|
-
Args:
|
|
94
|
-
server_name (str): Name of the server
|
|
95
|
-
|
|
96
|
-
Returns:
|
|
97
|
-
PersistentMCPSession: The requested session
|
|
98
|
-
|
|
99
|
-
Raises:
|
|
100
|
-
KeyError: If session doesn't exist
|
|
101
|
-
"""
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from abc import ABC, abstractmethod
|
|
3
|
-
from aip_agents.utils.logger import get_logger as get_logger
|
|
4
|
-
from collections.abc import AsyncIterator as AsyncIterator
|
|
5
|
-
from enum import StrEnum
|
|
6
|
-
from gllm_tools.mcp.client.config import MCPConfiguration
|
|
7
|
-
from typing import Any, Protocol
|
|
8
|
-
|
|
9
|
-
class TransportContext(Protocol):
|
|
10
|
-
"""Protocol defining the interface for async context managers used in MCP transport connections."""
|
|
11
|
-
async def __aenter__(self) -> None:
|
|
12
|
-
"""Enter the async context, establishing the connection and returning read/write streams."""
|
|
13
|
-
async def __aexit__(self, _exc_type, _exc_val, _exc_tb) -> None:
|
|
14
|
-
"""Exit the async context, performing cleanup and closing the connection.
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
_exc_type: Exception type if an exception occurred.
|
|
18
|
-
_exc_val: Exception value if an exception occurred.
|
|
19
|
-
_exc_tb: Exception traceback if an exception occurred.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
logger: Incomplete
|
|
23
|
-
DEFAULT_TIMEOUT: float
|
|
24
|
-
|
|
25
|
-
class TransportType(StrEnum):
|
|
26
|
-
"""Enum for supported MCP transport types."""
|
|
27
|
-
HTTP: str
|
|
28
|
-
SSE: str
|
|
29
|
-
STDIO: str
|
|
30
|
-
|
|
31
|
-
class Transport(ABC):
|
|
32
|
-
"""Abstract base class for MCP transports."""
|
|
33
|
-
server_name: Incomplete
|
|
34
|
-
config: Incomplete
|
|
35
|
-
ctx: Any
|
|
36
|
-
def __init__(self, server_name: str, config: MCPConfiguration) -> None:
|
|
37
|
-
"""Initialize the transport.
|
|
38
|
-
|
|
39
|
-
Args:
|
|
40
|
-
server_name (str): Name of the MCP server.
|
|
41
|
-
config (MCPConfiguration): Configuration for the transport.
|
|
42
|
-
"""
|
|
43
|
-
@abstractmethod
|
|
44
|
-
async def connect(self) -> tuple[AsyncIterator[bytes], AsyncIterator[bytes], TransportContext]:
|
|
45
|
-
"""Establish connection and return read/write streams and context manager.
|
|
46
|
-
|
|
47
|
-
Returns:
|
|
48
|
-
tuple[AsyncIterator[bytes], AsyncIterator[bytes], Any]:
|
|
49
|
-
(read_stream, write_stream, ctx)
|
|
50
|
-
Where:
|
|
51
|
-
- read_stream: AsyncIterator[bytes] for reading from the server.
|
|
52
|
-
- write_stream: AsyncIterator[bytes] for writing to the server.
|
|
53
|
-
- ctx: The async context manager instance for cleanup via __aexit__.
|
|
54
|
-
|
|
55
|
-
Raises:
|
|
56
|
-
ValueError: If required config (e.g., URL or command) is missing.
|
|
57
|
-
ConnectionError: If connection establishment fails.
|
|
58
|
-
"""
|
|
59
|
-
async def close(self) -> None:
|
|
60
|
-
"""Clean up the transport connection."""
|
|
61
|
-
|
|
62
|
-
class SSETransport(Transport):
|
|
63
|
-
"""SSE transport handler."""
|
|
64
|
-
ctx: Incomplete
|
|
65
|
-
async def connect(self) -> tuple[AsyncIterator[bytes], AsyncIterator[bytes], TransportContext]:
|
|
66
|
-
"""Connect using SSE transport.
|
|
67
|
-
|
|
68
|
-
Builds SSE URL from config, initializes client with timeout, and enters context.
|
|
69
|
-
|
|
70
|
-
Returns:
|
|
71
|
-
tuple[AsyncIterator[bytes], AsyncIterator[bytes], Any]: (read_stream, write_stream, ctx)
|
|
72
|
-
|
|
73
|
-
Raises:
|
|
74
|
-
ValueError: If URL is missing.
|
|
75
|
-
ConnectionError: If SSE connection fails.
|
|
76
|
-
"""
|
|
77
|
-
|
|
78
|
-
class HTTPTransport(Transport):
|
|
79
|
-
"""Streamable HTTP transport handler."""
|
|
80
|
-
def __init__(self, server_name: str, config: MCPConfiguration) -> None:
|
|
81
|
-
"""Initialize the HTTP transport.
|
|
82
|
-
|
|
83
|
-
Args:
|
|
84
|
-
server_name (str): Name of the MCP server.
|
|
85
|
-
config (MCPConfiguration): Configuration for the transport.
|
|
86
|
-
"""
|
|
87
|
-
async def close(self) -> None:
|
|
88
|
-
"""Clean up the transport connection and any owned HTTP client."""
|
|
89
|
-
ctx: Incomplete
|
|
90
|
-
async def connect(self) -> tuple[AsyncIterator[bytes], AsyncIterator[bytes], TransportContext]:
|
|
91
|
-
"""Connect using streamable HTTP transport.
|
|
92
|
-
|
|
93
|
-
Builds MCP URL from config, initializes client with timeout, and enters context.
|
|
94
|
-
|
|
95
|
-
Returns:
|
|
96
|
-
tuple[AsyncIterator[bytes], AsyncIterator[bytes], Any]: (read_stream, write_stream, ctx)
|
|
97
|
-
|
|
98
|
-
Raises:
|
|
99
|
-
ValueError: If URL is missing.
|
|
100
|
-
ConnectionError: If HTTP connection fails.
|
|
101
|
-
"""
|
|
102
|
-
|
|
103
|
-
class StdioTransport(Transport):
|
|
104
|
-
"""STDIO transport handler."""
|
|
105
|
-
ctx: Incomplete
|
|
106
|
-
async def connect(self) -> tuple[AsyncIterator[bytes], AsyncIterator[bytes], TransportContext]:
|
|
107
|
-
"""Connect using STDIO transport.
|
|
108
|
-
|
|
109
|
-
Initializes stdio client from command/args/env in config and enters context.
|
|
110
|
-
|
|
111
|
-
Returns:
|
|
112
|
-
tuple[AsyncIterator[bytes], AsyncIterator[bytes], Any]: (read_stream, write_stream, ctx)
|
|
113
|
-
|
|
114
|
-
Raises:
|
|
115
|
-
ValueError: If command is missing.
|
|
116
|
-
ConnectionError: If STDIO connection fails.
|
|
117
|
-
"""
|
|
118
|
-
|
|
119
|
-
def create_transport(server_name: str, config: MCPConfiguration, transport_type: TransportType | str) -> Transport:
|
|
120
|
-
"""Factory to create the appropriate transport instance.
|
|
121
|
-
|
|
122
|
-
Args:
|
|
123
|
-
server_name (str): Server name
|
|
124
|
-
config (MCPConfiguration): Config
|
|
125
|
-
transport_type (str): Transport type ('http', 'sse', 'stdio')
|
|
126
|
-
|
|
127
|
-
Returns:
|
|
128
|
-
Transport: Concrete transport instance
|
|
129
|
-
|
|
130
|
-
Raises:
|
|
131
|
-
ValueError: If transport_type is unsupported.
|
|
132
|
-
"""
|
|
File without changes
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from aip_agents.utils.logger import get_logger as get_logger
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
logger: Incomplete
|
|
6
|
-
|
|
7
|
-
def validate_allowed_tools_list(allowed_tools: list[str] | None, context: str) -> list[str] | None:
|
|
8
|
-
'''Validate that allowed_tools is a list of strings or None.
|
|
9
|
-
|
|
10
|
-
This function validates the type and contents of allowed_tools parameter.
|
|
11
|
-
It can be used to validate allowed_tools from any source (config dict, function parameter, etc).
|
|
12
|
-
|
|
13
|
-
Args:
|
|
14
|
-
allowed_tools: The allowed_tools value to validate (can be any type)
|
|
15
|
-
context: Context string for error messages (e.g., "Server \'my_server\'", "\'allowed_tools\' parameter")
|
|
16
|
-
|
|
17
|
-
Returns:
|
|
18
|
-
Validated list of allowed tool names, or None if allowed_tools is None or empty.
|
|
19
|
-
None/empty means no restriction (all tools allowed).
|
|
20
|
-
|
|
21
|
-
Raises:
|
|
22
|
-
ValueError: If allowed_tools is not None/list or contains non-string elements
|
|
23
|
-
|
|
24
|
-
Examples:
|
|
25
|
-
>>> validate_allowed_tools_list(None, "test")
|
|
26
|
-
None
|
|
27
|
-
>>> validate_allowed_tools_list([], "test")
|
|
28
|
-
None
|
|
29
|
-
>>> validate_allowed_tools_list(["tool1", "tool2"], "test")
|
|
30
|
-
[\'tool1\', \'tool2\']
|
|
31
|
-
>>> validate_allowed_tools_list("invalid", "test") # doctest: +SKIP
|
|
32
|
-
ValueError: test: \'allowed_tools\' must be a list of strings, got str
|
|
33
|
-
'''
|
|
34
|
-
def validate_allowed_tools_config(config: dict[str, Any], server_name: str) -> list[str] | None:
|
|
35
|
-
'''Validate and extract allowed_tools configuration from server config.
|
|
36
|
-
|
|
37
|
-
This function validates that the allowed_tools field, if present, is a list of strings.
|
|
38
|
-
It returns a normalized list of allowed tool names, or None if not specified/empty.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
config: Server configuration dictionary that may contain \'allowed_tools\' field
|
|
42
|
-
server_name: Name of the server (for error messages)
|
|
43
|
-
|
|
44
|
-
Returns:
|
|
45
|
-
List of allowed tool names, or None if allowed_tools is not specified or is empty.
|
|
46
|
-
None means no restriction (all tools allowed).
|
|
47
|
-
|
|
48
|
-
Raises:
|
|
49
|
-
ValueError: If allowed_tools is present but not a list
|
|
50
|
-
ValueError: If allowed_tools contains non-string elements
|
|
51
|
-
|
|
52
|
-
Examples:
|
|
53
|
-
>>> validate_allowed_tools_config({"url": "..."}, "my_server")
|
|
54
|
-
None
|
|
55
|
-
>>> validate_allowed_tools_config({"url": "...", "allowed_tools": []}, "my_server")
|
|
56
|
-
None
|
|
57
|
-
>>> validate_allowed_tools_config({"url": "...", "allowed_tools": ["tool1", "tool2"]}, "my_server")
|
|
58
|
-
[\'tool1\', \'tool2\']
|
|
59
|
-
'''
|
|
60
|
-
def validate_mcp_server_config(config: dict[str, Any], server_name: str) -> dict[str, Any]:
|
|
61
|
-
'''Validate complete MCP server configuration including allowed_tools.
|
|
62
|
-
|
|
63
|
-
This function performs comprehensive validation on an MCP server configuration,
|
|
64
|
-
ensuring all required fields are present and allowed_tools (if present) is valid.
|
|
65
|
-
Unknown configuration fields (such as any leftover disabled_tools) are silently ignored.
|
|
66
|
-
|
|
67
|
-
Args:
|
|
68
|
-
config: Server configuration dictionary
|
|
69
|
-
server_name: Name of the server (for error messages)
|
|
70
|
-
|
|
71
|
-
Returns:
|
|
72
|
-
Validated configuration dictionary (same as input, after validation)
|
|
73
|
-
|
|
74
|
-
Raises:
|
|
75
|
-
ValueError: If configuration is invalid
|
|
76
|
-
|
|
77
|
-
Examples:
|
|
78
|
-
>>> validate_mcp_server_config({"url": "http://localhost:8080"}, "my_server")
|
|
79
|
-
{\'url\': \'http://localhost:8080\'}
|
|
80
|
-
>>> validate_mcp_server_config({"command": "python", "args": ["server.py"]}, "my_server")
|
|
81
|
-
{\'command\': \'python\', \'args\': [\'server.py\']}
|
|
82
|
-
'''
|
aip_agents/memory/__init__.pyi
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from aip_agents.memory.base import BaseMemory as BaseMemory
|
|
3
|
-
from aip_agents.memory.constants import MemoryDefaults as MemoryDefaults
|
|
4
|
-
from aip_agents.types import ChatMessage as ChatMessage
|
|
5
|
-
from aip_agents.utils.datetime import format_created_updated_label as format_created_updated_label
|
|
6
|
-
from aip_agents.utils.logger import get_logger as get_logger
|
|
7
|
-
from concurrent.futures import Future
|
|
8
|
-
from dataclasses import dataclass
|
|
9
|
-
from gllm_memory import MemoryManager
|
|
10
|
-
from gllm_memory.enums import MemoryScope
|
|
11
|
-
from typing import Any, ClassVar
|
|
12
|
-
|
|
13
|
-
MemoryManager = Any
|
|
14
|
-
MemoryScope = Any
|
|
15
|
-
logger: Incomplete
|
|
16
|
-
DEFAULT_SCOPE: ClassVar[set[MemoryScope]]
|
|
17
|
-
|
|
18
|
-
@dataclass(frozen=True)
|
|
19
|
-
class _RetrieveOptions:
|
|
20
|
-
user_id: str
|
|
21
|
-
top_k: int
|
|
22
|
-
metadata: dict[str, str] | None
|
|
23
|
-
keywords: Any
|
|
24
|
-
page: int
|
|
25
|
-
categories: list[str] | None
|
|
26
|
-
|
|
27
|
-
class _AsyncRunner:
|
|
28
|
-
"""Runs async coroutines on a dedicated background event loop."""
|
|
29
|
-
def __init__(self) -> None: ...
|
|
30
|
-
def run(self, awaitable: Any) -> Any:
|
|
31
|
-
"""Execute an awaitable on the background loop and block for the result.
|
|
32
|
-
|
|
33
|
-
Args:
|
|
34
|
-
awaitable: The coroutine to execute.
|
|
35
|
-
|
|
36
|
-
Returns:
|
|
37
|
-
The result of the coroutine execution.
|
|
38
|
-
"""
|
|
39
|
-
def shutdown(self, timeout: float | None = 5.0) -> None:
|
|
40
|
-
"""Gracefully stop the event loop thread.
|
|
41
|
-
|
|
42
|
-
Args:
|
|
43
|
-
timeout: Maximum time to wait for the thread to stop.
|
|
44
|
-
"""
|
|
45
|
-
def __del__(self) -> None: ...
|
|
46
|
-
|
|
47
|
-
class BaseMemoryAdapter(BaseMemory):
|
|
48
|
-
"""Provider-agnostic long-term memory adapter backed by gllm_memory."""
|
|
49
|
-
agent_id: Incomplete
|
|
50
|
-
namespace: Incomplete
|
|
51
|
-
limit: Incomplete
|
|
52
|
-
max_chars: Incomplete
|
|
53
|
-
def __init__(self, *, agent_id: str, manager: MemoryManager, namespace: str | None = None, limit: int = ..., max_chars: int = ...) -> None:
|
|
54
|
-
"""Initialize the GLLM memory adapter.
|
|
55
|
-
|
|
56
|
-
Args:
|
|
57
|
-
agent_id: Unique identifier for the agent using this memory.
|
|
58
|
-
manager: Configured gllm_memory MemoryManager instance.
|
|
59
|
-
namespace: Optional namespace for organizing memories.
|
|
60
|
-
limit: Maximum number of memories to retrieve in search operations.
|
|
61
|
-
max_chars: Maximum character length for text content.
|
|
62
|
-
"""
|
|
63
|
-
@classmethod
|
|
64
|
-
def validate_env(cls) -> None:
|
|
65
|
-
"""Base adapter does not enforce environment validation."""
|
|
66
|
-
def get_messages(self) -> list[ChatMessage]:
|
|
67
|
-
"""Retrieve all stored chat messages.
|
|
68
|
-
|
|
69
|
-
Returns:
|
|
70
|
-
An empty list as GLLM adapter doesn't support message retrieval.
|
|
71
|
-
"""
|
|
72
|
-
def add_message(self, message: ChatMessage) -> None:
|
|
73
|
-
"""Best-effort single-message persistence for API parity.
|
|
74
|
-
|
|
75
|
-
Args:
|
|
76
|
-
message: The chat message to add to memory.
|
|
77
|
-
"""
|
|
78
|
-
def clear(self) -> None:
|
|
79
|
-
"""Clear all stored memories.
|
|
80
|
-
|
|
81
|
-
Raises:
|
|
82
|
-
NotImplementedError: This method is not implemented for GLLM adapter.
|
|
83
|
-
"""
|
|
84
|
-
def search(self, query: str, *, user_id: str, limit: int | None = None, filters: dict[str, Any] | None = None) -> list[dict[str, Any]]:
|
|
85
|
-
"""Search for memories using a text query.
|
|
86
|
-
|
|
87
|
-
Args:
|
|
88
|
-
query: The search query string.
|
|
89
|
-
user_id: User identifier for the search scope.
|
|
90
|
-
limit: Maximum number of results to return.
|
|
91
|
-
filters: Optional filters to apply to the search.
|
|
92
|
-
|
|
93
|
-
Returns:
|
|
94
|
-
List of memory hits matching the search criteria.
|
|
95
|
-
"""
|
|
96
|
-
def retrieve(self, *, query: str | None, user_id: str, limit: int | None = None, filters: dict[str, Any] | None = None, page: int | None = None) -> list[dict[str, Any]]:
|
|
97
|
-
"""Retrieve memories with optional search query and filters.
|
|
98
|
-
|
|
99
|
-
Args:
|
|
100
|
-
query: Optional search query string. If None, retrieves all memories.
|
|
101
|
-
user_id: User identifier for the retrieval scope.
|
|
102
|
-
limit: Maximum number of results to return.
|
|
103
|
-
filters: Optional filters to apply to the retrieval.
|
|
104
|
-
page: Page number for pagination.
|
|
105
|
-
|
|
106
|
-
Returns:
|
|
107
|
-
List of memory hits matching the criteria.
|
|
108
|
-
"""
|
|
109
|
-
def save_interaction(self, *, user_text: str, ai_text: str, user_id: str) -> None:
|
|
110
|
-
"""Save a user-AI interaction as memories.
|
|
111
|
-
|
|
112
|
-
Args:
|
|
113
|
-
user_text: The user's input text.
|
|
114
|
-
ai_text: The AI's response text.
|
|
115
|
-
user_id: User identifier for the memory storage.
|
|
116
|
-
"""
|
|
117
|
-
def save_interaction_async(self, *, user_text: str, ai_text: str, user_id: str) -> Future[Any]:
|
|
118
|
-
"""Schedule save_interaction without blocking the caller.
|
|
119
|
-
|
|
120
|
-
Args:
|
|
121
|
-
user_text: The user's input text to save.
|
|
122
|
-
ai_text: The AI's response text to save.
|
|
123
|
-
user_id: User identifier for the memory storage.
|
|
124
|
-
"""
|
|
125
|
-
def format_hits(self, hits: list[dict[str, Any]], max_items: int = ..., with_tag: bool = True) -> str:
|
|
126
|
-
"""Format memory hits into a readable string.
|
|
127
|
-
|
|
128
|
-
Args:
|
|
129
|
-
hits: List of memory hit dictionaries to format.
|
|
130
|
-
max_items: Maximum number of hits to include in the output.
|
|
131
|
-
with_tag: Whether to wrap the output with memory tags.
|
|
132
|
-
|
|
133
|
-
Returns:
|
|
134
|
-
Formatted string representation of the memory hits.
|
|
135
|
-
"""
|
|
136
|
-
def flush_pending_writes(self, timeout: float | None = None) -> None:
|
|
137
|
-
"""Block until current async writes complete.
|
|
138
|
-
|
|
139
|
-
Args:
|
|
140
|
-
timeout: Maximum time to wait for pending writes to complete.
|
|
141
|
-
"""
|
|
142
|
-
def close(self, *, wait: bool = True, timeout: float | None = None) -> None:
|
|
143
|
-
"""Release background resources and optionally wait for pending saves.
|
|
144
|
-
|
|
145
|
-
Args:
|
|
146
|
-
wait: Whether to wait for pending async operations to complete.
|
|
147
|
-
timeout: Maximum time to wait when wait=True.
|
|
148
|
-
"""
|
|
149
|
-
def __del__(self) -> None:
|
|
150
|
-
"""Clean up resources when the adapter is garbage collected."""
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from aip_agents.memory.adapters.base_adapter import BaseMemoryAdapter as BaseMemoryAdapter
|
|
2
|
-
from aip_agents.memory.constants import MemoryDefaults as MemoryDefaults
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
MemoryManager = Any
|
|
6
|
-
|
|
7
|
-
class Mem0Memory(BaseMemoryAdapter):
|
|
8
|
-
"""Mem0-backed long-term memory adapter using the gllm_memory SDK."""
|
|
9
|
-
def __init__(self, *, agent_id: str, namespace: str | None = None, limit: int = ..., max_chars: int = ..., host: str | None = None, instruction: str | None = None) -> None:
|
|
10
|
-
"""Initialize the Mem0 memory adapter.
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
agent_id: Unique identifier for the agent using this memory.
|
|
14
|
-
namespace: Optional namespace for organizing memories.
|
|
15
|
-
limit: Maximum number of memories to retrieve in search operations.
|
|
16
|
-
max_chars: Maximum character length for text content.
|
|
17
|
-
host: Optional host URL for the Mem0 service.
|
|
18
|
-
instruction: Optional instruction text for memory operations.
|
|
19
|
-
"""
|
|
20
|
-
@classmethod
|
|
21
|
-
def validate_env(cls) -> None:
|
|
22
|
-
"""Ensure the Mem0 API key is available."""
|