aip-agents-binary 0.5.25__py3-none-macosx_13_0_arm64.whl → 0.6.8__py3-none-macosx_13_0_arm64.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.
Files changed (109) hide show
  1. aip_agents/agent/__init__.py +44 -4
  2. aip_agents/agent/base_langgraph_agent.py +163 -74
  3. aip_agents/agent/base_langgraph_agent.pyi +3 -2
  4. aip_agents/agent/langgraph_memory_enhancer_agent.py +368 -34
  5. aip_agents/agent/langgraph_memory_enhancer_agent.pyi +3 -2
  6. aip_agents/agent/langgraph_react_agent.py +329 -22
  7. aip_agents/agent/langgraph_react_agent.pyi +41 -2
  8. aip_agents/examples/hello_world_ptc.py +49 -0
  9. aip_agents/examples/hello_world_ptc.pyi +5 -0
  10. aip_agents/examples/hello_world_ptc_custom_tools.py +83 -0
  11. aip_agents/examples/hello_world_ptc_custom_tools.pyi +7 -0
  12. aip_agents/examples/hello_world_tool_output_client.py +9 -0
  13. aip_agents/examples/tools/multiply_tool.py +43 -0
  14. aip_agents/examples/tools/multiply_tool.pyi +18 -0
  15. aip_agents/guardrails/engines/base.py +6 -6
  16. aip_agents/mcp/client/__init__.py +38 -2
  17. aip_agents/mcp/client/connection_manager.py +36 -1
  18. aip_agents/mcp/client/connection_manager.pyi +3 -0
  19. aip_agents/mcp/client/persistent_session.py +318 -68
  20. aip_agents/mcp/client/persistent_session.pyi +9 -0
  21. aip_agents/mcp/client/transports.py +37 -2
  22. aip_agents/mcp/client/transports.pyi +9 -0
  23. aip_agents/memory/adapters/base_adapter.py +98 -0
  24. aip_agents/memory/adapters/base_adapter.pyi +25 -0
  25. aip_agents/ptc/__init__.py +87 -0
  26. aip_agents/ptc/__init__.pyi +14 -0
  27. aip_agents/ptc/custom_tools.py +473 -0
  28. aip_agents/ptc/custom_tools.pyi +184 -0
  29. aip_agents/ptc/custom_tools_payload.py +400 -0
  30. aip_agents/ptc/custom_tools_payload.pyi +31 -0
  31. aip_agents/ptc/custom_tools_templates/__init__.py +1 -0
  32. aip_agents/ptc/custom_tools_templates/__init__.pyi +0 -0
  33. aip_agents/ptc/custom_tools_templates/custom_build_function.py.template +23 -0
  34. aip_agents/ptc/custom_tools_templates/custom_init.py.template +15 -0
  35. aip_agents/ptc/custom_tools_templates/custom_invoke.py.template +60 -0
  36. aip_agents/ptc/custom_tools_templates/custom_registry.py.template +87 -0
  37. aip_agents/ptc/custom_tools_templates/custom_sources_init.py.template +7 -0
  38. aip_agents/ptc/custom_tools_templates/custom_wrapper.py.template +19 -0
  39. aip_agents/ptc/doc_gen.py +122 -0
  40. aip_agents/ptc/doc_gen.pyi +40 -0
  41. aip_agents/ptc/exceptions.py +57 -0
  42. aip_agents/ptc/exceptions.pyi +37 -0
  43. aip_agents/ptc/executor.py +261 -0
  44. aip_agents/ptc/executor.pyi +99 -0
  45. aip_agents/ptc/mcp/__init__.py +45 -0
  46. aip_agents/ptc/mcp/__init__.pyi +7 -0
  47. aip_agents/ptc/mcp/sandbox_bridge.py +668 -0
  48. aip_agents/ptc/mcp/sandbox_bridge.pyi +47 -0
  49. aip_agents/ptc/mcp/templates/__init__.py +1 -0
  50. aip_agents/ptc/mcp/templates/__init__.pyi +0 -0
  51. aip_agents/ptc/mcp/templates/mcp_client.py.template +239 -0
  52. aip_agents/ptc/naming.py +196 -0
  53. aip_agents/ptc/naming.pyi +85 -0
  54. aip_agents/ptc/payload.py +26 -0
  55. aip_agents/ptc/payload.pyi +15 -0
  56. aip_agents/ptc/prompt_builder.py +673 -0
  57. aip_agents/ptc/prompt_builder.pyi +59 -0
  58. aip_agents/ptc/ptc_helper.py +16 -0
  59. aip_agents/ptc/ptc_helper.pyi +1 -0
  60. aip_agents/ptc/sandbox_bridge.py +256 -0
  61. aip_agents/ptc/sandbox_bridge.pyi +38 -0
  62. aip_agents/ptc/template_utils.py +33 -0
  63. aip_agents/ptc/template_utils.pyi +13 -0
  64. aip_agents/ptc/templates/__init__.py +1 -0
  65. aip_agents/ptc/templates/__init__.pyi +0 -0
  66. aip_agents/ptc/templates/ptc_helper.py.template +134 -0
  67. aip_agents/ptc/tool_def_helpers.py +101 -0
  68. aip_agents/ptc/tool_def_helpers.pyi +38 -0
  69. aip_agents/ptc/tool_enrichment.py +163 -0
  70. aip_agents/ptc/tool_enrichment.pyi +60 -0
  71. aip_agents/sandbox/__init__.py +43 -0
  72. aip_agents/sandbox/__init__.pyi +5 -0
  73. aip_agents/sandbox/defaults.py +205 -0
  74. aip_agents/sandbox/defaults.pyi +30 -0
  75. aip_agents/sandbox/e2b_runtime.py +295 -0
  76. aip_agents/sandbox/e2b_runtime.pyi +57 -0
  77. aip_agents/sandbox/template_builder.py +131 -0
  78. aip_agents/sandbox/template_builder.pyi +36 -0
  79. aip_agents/sandbox/types.py +24 -0
  80. aip_agents/sandbox/types.pyi +14 -0
  81. aip_agents/sandbox/validation.py +50 -0
  82. aip_agents/sandbox/validation.pyi +20 -0
  83. aip_agents/sentry/sentry.py +29 -8
  84. aip_agents/sentry/sentry.pyi +3 -2
  85. aip_agents/tools/__init__.py +13 -2
  86. aip_agents/tools/__init__.pyi +3 -1
  87. aip_agents/tools/browser_use/browser_use_tool.py +8 -0
  88. aip_agents/tools/browser_use/streaming.py +2 -0
  89. aip_agents/tools/date_range_tool.py +554 -0
  90. aip_agents/tools/date_range_tool.pyi +21 -0
  91. aip_agents/tools/execute_ptc_code.py +357 -0
  92. aip_agents/tools/execute_ptc_code.pyi +90 -0
  93. aip_agents/tools/memory_search/__init__.py +8 -1
  94. aip_agents/tools/memory_search/__init__.pyi +3 -3
  95. aip_agents/tools/memory_search/mem0.py +114 -1
  96. aip_agents/tools/memory_search/mem0.pyi +11 -1
  97. aip_agents/tools/memory_search/schema.py +33 -0
  98. aip_agents/tools/memory_search/schema.pyi +10 -0
  99. aip_agents/tools/memory_search_tool.py +8 -0
  100. aip_agents/tools/memory_search_tool.pyi +2 -2
  101. aip_agents/utils/langgraph/tool_managers/delegation_tool_manager.py +26 -1
  102. aip_agents/utils/langgraph/tool_output_management.py +80 -0
  103. aip_agents/utils/langgraph/tool_output_management.pyi +37 -0
  104. {aip_agents_binary-0.5.25.dist-info → aip_agents_binary-0.6.8.dist-info}/METADATA +9 -19
  105. {aip_agents_binary-0.5.25.dist-info → aip_agents_binary-0.6.8.dist-info}/RECORD +107 -41
  106. {aip_agents_binary-0.5.25.dist-info → aip_agents_binary-0.6.8.dist-info}/WHEEL +1 -1
  107. aip_agents/examples/demo_memory_recall.py +0 -401
  108. aip_agents/examples/demo_memory_recall.pyi +0 -58
  109. {aip_agents_binary-0.5.25.dist-info → aip_agents_binary-0.6.8.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,99 @@
1
+ from _typeshed import Incomplete
2
+ from aip_agents.mcp.client.base_mcp_client import BaseMCPClient as BaseMCPClient
3
+ from aip_agents.ptc.custom_tools import PTCCustomToolConfig as PTCCustomToolConfig
4
+ from aip_agents.ptc.exceptions import PTCToolError as PTCToolError
5
+ from aip_agents.ptc.payload import SandboxPayload as SandboxPayload
6
+ from aip_agents.ptc.prompt_builder import PromptConfig as PromptConfig
7
+ from aip_agents.ptc.sandbox_bridge import build_sandbox_payload as build_sandbox_payload, wrap_ptc_code as wrap_ptc_code
8
+ from aip_agents.sandbox.defaults import DEFAULT_PTC_PACKAGES as DEFAULT_PTC_PACKAGES, DEFAULT_PTC_TEMPLATE as DEFAULT_PTC_TEMPLATE
9
+ from aip_agents.sandbox.e2b_runtime import E2BSandboxRuntime as E2BSandboxRuntime
10
+ from aip_agents.sandbox.types import SandboxExecutionResult as SandboxExecutionResult
11
+ from aip_agents.utils.logger import get_logger as get_logger
12
+ from dataclasses import dataclass, field
13
+
14
+ logger: Incomplete
15
+
16
+ @dataclass
17
+ class PTCSandboxConfig:
18
+ """Configuration for PTC sandbox executor.
19
+
20
+ Attributes:
21
+ enabled: Whether PTC is enabled. When False, PTC is disabled.
22
+ default_tool_timeout: Default timeout per tool call in seconds.
23
+ sandbox_template: Optional E2B sandbox template ID.
24
+ sandbox_timeout: Sandbox execution timeout in seconds (hard cap/TTL).
25
+ ptc_packages: List of packages to install in sandbox. Defaults to DEFAULT_PTC_PACKAGES.
26
+ prompt: Prompt configuration for PTC usage guidance.
27
+ custom_tools: Configuration for custom LangChain tools in sandbox.
28
+ """
29
+ enabled: bool = ...
30
+ default_tool_timeout: float = ...
31
+ sandbox_template: str | None = ...
32
+ sandbox_timeout: float = ...
33
+ ptc_packages: list[str] | None = field(default_factory=Incomplete)
34
+ prompt: PromptConfig = field(default_factory=PromptConfig)
35
+ custom_tools: PTCCustomToolConfig = field(default_factory=PTCCustomToolConfig)
36
+
37
+ class PTCSandboxExecutor:
38
+ '''Executes PTC code inside an E2B sandbox.
39
+
40
+ This executor is used for LLM-generated code that requires sandboxing.
41
+ It builds a sandbox payload (MCP server config + generated tool modules)
42
+ and executes the code using the E2B runtime.
43
+
44
+ Static bundle caching:
45
+ The executor tracks whether the static bundle (wrappers, registry, sources)
46
+ has been uploaded. On the first run, it uploads the full payload. On subsequent
47
+ runs, it only uploads per-run files (e.g., tools/custom_defaults.json) to
48
+ reduce upload overhead.
49
+
50
+ If the sandbox is destroyed/recreated, call reset_static_bundle() to force
51
+ a full re-upload on the next execution.
52
+
53
+ Thread-safety:
54
+ The static bundle upload is guarded by an asyncio.Lock. Concurrent calls will
55
+ serialize while the initial upload completes. After the bundle is cached,
56
+ executions proceed without locking.
57
+
58
+ Example:
59
+ runtime = E2BSandboxRuntime()
60
+ executor = PTCSandboxExecutor(mcp_client, runtime)
61
+ result = await executor.execute_code("from tools.yfinance import get_stock\\\\nprint(get_stock(\'AAPL\'))")
62
+ '''
63
+ def __init__(self, mcp_client: BaseMCPClient | None, runtime: E2BSandboxRuntime, config: PTCSandboxConfig | None = None) -> None:
64
+ """Initialize PTCSandboxExecutor.
65
+
66
+ Args:
67
+ mcp_client: The MCP client with configured servers. Can be None for custom-only configs.
68
+ runtime: The E2B sandbox runtime instance.
69
+ config: Optional sandbox executor configuration.
70
+
71
+ Raises:
72
+ ImportError: If sandbox dependencies are not available.
73
+ """
74
+ async def execute_code(self, code: str, tool_configs: dict[str, dict] | None = None) -> SandboxExecutionResult:
75
+ """Execute code inside the sandbox with MCP access.
76
+
77
+ This method:
78
+ 1. Builds the sandbox payload (MCP config + generated tool modules + custom tools)
79
+ 2. Wraps the user code with necessary imports and setup
80
+ 3. Executes the code in the E2B sandbox
81
+ 4. Returns the execution result (stdout/stderr/exit_code)
82
+
83
+ Args:
84
+ code: Python code to execute in the sandbox.
85
+ tool_configs: Optional per-tool config values for custom LangChain tools.
86
+ These are merged with agent defaults and written to custom_defaults.json.
87
+
88
+ Returns:
89
+ SandboxExecutionResult with stdout, stderr, and exit_code.
90
+
91
+ Raises:
92
+ PTCToolError: If sandbox execution fails.
93
+ """
94
+ def reset_static_bundle(self) -> None:
95
+ """Reset the static bundle upload state.
96
+
97
+ Call this method when the sandbox is destroyed/recreated to force
98
+ a full re-upload of the static bundle on the next execution.
99
+ """
@@ -0,0 +1,45 @@
1
+ """Programmatic Tool Calling (PTC) module for MCP tools.
2
+
3
+ This module provides programmatic tool calling capabilities for MCP tools,
4
+ allowing code-based tool invocation instead of JSON tool calls.
5
+
6
+ Authors:
7
+ Putu Ravindra Wiguna (putu.r.wiguna@gdplabs.id)
8
+ """
9
+
10
+ from aip_agents.ptc.exceptions import PTCError, PTCToolError
11
+ from aip_agents.ptc.mcp.sandbox_bridge import (
12
+ ServerConfig,
13
+ build_mcp_payload,
14
+ )
15
+ from aip_agents.ptc.naming import (
16
+ json_type_to_python,
17
+ sanitize_function_name,
18
+ sanitize_module_name,
19
+ sanitize_param_name,
20
+ schema_to_params,
21
+ )
22
+ from aip_agents.ptc.payload import SandboxPayload
23
+ from aip_agents.ptc.prompt_builder import (
24
+ build_ptc_prompt,
25
+ compute_ptc_prompt_hash,
26
+ )
27
+
28
+ __all__ = [
29
+ # Exceptions
30
+ "PTCError",
31
+ "PTCToolError",
32
+ # Naming utilities
33
+ "json_type_to_python",
34
+ "sanitize_function_name",
35
+ "sanitize_module_name",
36
+ "sanitize_param_name",
37
+ "schema_to_params",
38
+ # Prompt builder
39
+ "build_ptc_prompt",
40
+ "compute_ptc_prompt_hash",
41
+ # Sandbox Bridge
42
+ "SandboxPayload",
43
+ "ServerConfig",
44
+ "build_mcp_payload",
45
+ ]
@@ -0,0 +1,7 @@
1
+ from aip_agents.ptc.exceptions import PTCError as PTCError, PTCToolError as PTCToolError
2
+ from aip_agents.ptc.mcp.sandbox_bridge import ServerConfig as ServerConfig, build_mcp_payload as build_mcp_payload
3
+ from aip_agents.ptc.naming import json_type_to_python as json_type_to_python, sanitize_function_name as sanitize_function_name, sanitize_module_name as sanitize_module_name, sanitize_param_name as sanitize_param_name, schema_to_params as schema_to_params
4
+ from aip_agents.ptc.payload import SandboxPayload as SandboxPayload
5
+ from aip_agents.ptc.prompt_builder import build_ptc_prompt as build_ptc_prompt, compute_ptc_prompt_hash as compute_ptc_prompt_hash
6
+
7
+ __all__ = ['PTCError', 'PTCToolError', 'json_type_to_python', 'sanitize_function_name', 'sanitize_module_name', 'sanitize_param_name', 'schema_to_params', 'build_ptc_prompt', 'compute_ptc_prompt_hash', 'SandboxPayload', 'ServerConfig', 'build_mcp_payload']