aip-agents-binary 0.4.8__cp312-cp312-win_amd64.whl → 0.5.4__cp312-cp312-win_amd64.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 (208) hide show
  1. aip_agents/__init__.pyi +19 -0
  2. aip_agents/a2a/__init__.pyi +1 -1
  3. aip_agents/a2a/server/base_executor.pyi +6 -6
  4. aip_agents/a2a/server/google_adk_executor.pyi +11 -11
  5. aip_agents/a2a/server/langflow_executor.pyi +43 -0
  6. aip_agents/a2a/server/langgraph_executor.pyi +10 -11
  7. aip_agents/a2a/types.pyi +54 -47
  8. aip_agents/agent/__init__.pyi +3 -1
  9. aip_agents/agent/base_agent.pyi +24 -8
  10. aip_agents/agent/base_langgraph_agent.pyi +67 -25
  11. aip_agents/agent/google_adk_agent.pyi +34 -21
  12. aip_agents/agent/google_adk_constants.pyi +3 -0
  13. aip_agents/agent/hitl/__init__.pyi +6 -0
  14. aip_agents/agent/hitl/config.pyi +15 -0
  15. aip_agents/agent/hitl/langgraph_hitl_mixin.pyi +42 -0
  16. aip_agents/agent/hitl/manager.pyi +199 -0
  17. aip_agents/agent/hitl/models.pyi +3 -0
  18. aip_agents/agent/hitl/prompt/__init__.pyi +4 -0
  19. aip_agents/agent/hitl/prompt/base.pyi +24 -0
  20. aip_agents/agent/hitl/prompt/deferred.pyi +30 -0
  21. aip_agents/agent/interface.pyi +5 -5
  22. aip_agents/agent/interfaces.pyi +44 -0
  23. aip_agents/agent/langflow_agent.pyi +133 -0
  24. aip_agents/agent/langgraph_memory_enhancer_agent.pyi +49 -0
  25. aip_agents/agent/langgraph_react_agent.pyi +50 -57
  26. aip_agents/agent/system_instruction_context.pyi +13 -0
  27. aip_agents/clients/__init__.pyi +4 -0
  28. aip_agents/clients/langflow/__init__.pyi +4 -0
  29. aip_agents/clients/langflow/client.pyi +140 -0
  30. aip_agents/clients/langflow/types.pyi +7 -0
  31. aip_agents/constants.pyi +1 -0
  32. aip_agents/examples/compare_streaming_client.pyi +48 -0
  33. aip_agents/examples/compare_streaming_server.pyi +18 -0
  34. aip_agents/examples/demo_memory_recall.pyi +58 -0
  35. aip_agents/examples/hello_world_a2a_google_adk_client.pyi +2 -2
  36. aip_agents/examples/hello_world_a2a_google_adk_client_agent.pyi +2 -2
  37. aip_agents/examples/hello_world_a2a_google_adk_client_streaming.pyi +2 -2
  38. aip_agents/examples/hello_world_a2a_google_adk_server.pyi +7 -2
  39. aip_agents/examples/hello_world_a2a_langchain_client.pyi +1 -1
  40. aip_agents/examples/hello_world_a2a_langchain_client_agent.pyi +1 -1
  41. aip_agents/examples/hello_world_a2a_langchain_client_lm_invoker.pyi +1 -1
  42. aip_agents/examples/hello_world_a2a_langchain_client_streaming.pyi +1 -1
  43. aip_agents/examples/hello_world_a2a_langchain_reference_client_streaming.pyi +1 -1
  44. aip_agents/examples/hello_world_a2a_langchain_reference_server.pyi +8 -3
  45. aip_agents/examples/hello_world_a2a_langchain_server.pyi +7 -2
  46. aip_agents/examples/hello_world_a2a_langchain_server_lm_invoker.pyi +7 -2
  47. aip_agents/examples/hello_world_a2a_langflow_client.pyi +9 -0
  48. aip_agents/examples/hello_world_a2a_langflow_server.pyi +14 -0
  49. aip_agents/examples/hello_world_a2a_langgraph_artifact_client.pyi +1 -1
  50. aip_agents/examples/hello_world_a2a_langgraph_artifact_client_streaming.pyi +1 -1
  51. aip_agents/examples/hello_world_a2a_langgraph_artifact_server.pyi +7 -2
  52. aip_agents/examples/hello_world_a2a_langgraph_client.pyi +2 -2
  53. aip_agents/examples/hello_world_a2a_langgraph_client_agent.pyi +2 -2
  54. aip_agents/examples/hello_world_a2a_langgraph_client_agent_lm_invoker.pyi +1 -1
  55. aip_agents/examples/hello_world_a2a_langgraph_client_streaming.pyi +3 -3
  56. aip_agents/examples/hello_world_a2a_langgraph_client_streaming_lm_invoker.pyi +1 -1
  57. aip_agents/examples/hello_world_a2a_langgraph_client_streaming_tool_streaming.pyi +1 -1
  58. aip_agents/examples/hello_world_a2a_langgraph_server.pyi +7 -2
  59. aip_agents/examples/hello_world_a2a_langgraph_server_lm_invoker.pyi +7 -2
  60. aip_agents/examples/hello_world_a2a_langgraph_server_tool_streaming.pyi +7 -2
  61. aip_agents/examples/hello_world_a2a_mcp_langgraph.pyi +1 -1
  62. aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_client.pyi +31 -6
  63. aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_server.pyi +33 -5
  64. aip_agents/examples/hello_world_a2a_with_metadata_langchain_client.pyi +1 -1
  65. aip_agents/examples/hello_world_a2a_with_metadata_langchain_server_lm_invoker.pyi +7 -2
  66. aip_agents/examples/hello_world_langchain_mcp_http_interactive.pyi +16 -0
  67. aip_agents/examples/hello_world_langchain_mcp_multi_server.pyi +18 -0
  68. aip_agents/examples/hello_world_langflow_agent.pyi +35 -0
  69. aip_agents/examples/hello_world_model_switch_cli.pyi +18 -3
  70. aip_agents/examples/hello_world_pii_logger.pyi +1 -1
  71. aip_agents/examples/hello_world_sentry.pyi +1 -1
  72. aip_agents/examples/hello_world_step_limits.pyi +17 -0
  73. aip_agents/examples/hello_world_stock_a2a_server.pyi +7 -2
  74. aip_agents/examples/hello_world_tool_output_client.pyi +1 -1
  75. aip_agents/examples/hello_world_tool_output_server.pyi +7 -2
  76. aip_agents/examples/hitl_demo.pyi +67 -0
  77. aip_agents/examples/pii_demo_langgraph_client.pyi +5 -0
  78. aip_agents/examples/pii_demo_langgraph_server.pyi +20 -0
  79. aip_agents/examples/pii_demo_multi_agent_client.pyi +5 -0
  80. aip_agents/examples/pii_demo_multi_agent_server.pyi +40 -0
  81. aip_agents/examples/todolist_planning_a2a_langchain_client.pyi +5 -0
  82. aip_agents/examples/todolist_planning_a2a_langgraph_server.pyi +19 -0
  83. aip_agents/examples/tools/__init__.pyi +3 -1
  84. aip_agents/examples/tools/adk_weather_tool.pyi +1 -1
  85. aip_agents/examples/tools/data_visualization_tool.pyi +2 -0
  86. aip_agents/examples/tools/image_artifact_tool.pyi +2 -0
  87. aip_agents/examples/tools/langchain_arithmetic_tools.pyi +7 -0
  88. aip_agents/examples/tools/langchain_currency_exchange_tool.pyi +0 -1
  89. aip_agents/examples/tools/langchain_graph_artifact_tool.pyi +2 -0
  90. aip_agents/examples/tools/langchain_weather_tool.pyi +1 -1
  91. aip_agents/examples/tools/langgraph_streaming_tool.pyi +1 -1
  92. aip_agents/examples/tools/mock_retrieval_tool.pyi +13 -0
  93. aip_agents/examples/tools/pii_demo_tools.pyi +54 -0
  94. aip_agents/examples/tools/random_chart_tool.pyi +20 -0
  95. aip_agents/examples/tools/stock_tools.pyi +18 -3
  96. aip_agents/mcp/client/__init__.pyi +4 -3
  97. aip_agents/mcp/client/base_mcp_client.pyi +148 -0
  98. aip_agents/mcp/client/connection_manager.pyi +48 -0
  99. aip_agents/mcp/client/google_adk/__init__.pyi +1 -1
  100. aip_agents/mcp/client/google_adk/client.pyi +50 -13
  101. aip_agents/mcp/client/langchain/__init__.pyi +1 -1
  102. aip_agents/mcp/client/langchain/client.pyi +47 -2
  103. aip_agents/mcp/client/persistent_session.pyi +113 -0
  104. aip_agents/mcp/client/session_pool.pyi +101 -0
  105. aip_agents/mcp/client/transports.pyi +123 -0
  106. aip_agents/mcp/utils/__init__.pyi +0 -0
  107. aip_agents/mcp/utils/config_validator.pyi +82 -0
  108. aip_agents/memory/adapters/__init__.pyi +4 -0
  109. aip_agents/memory/adapters/base_adapter.pyi +150 -0
  110. aip_agents/memory/adapters/mem0.pyi +22 -0
  111. aip_agents/memory/base.pyi +3 -3
  112. aip_agents/memory/constants.pyi +9 -0
  113. aip_agents/memory/factory.pyi +1 -1
  114. aip_agents/memory/guidance.pyi +3 -0
  115. aip_agents/middleware/__init__.pyi +5 -0
  116. aip_agents/middleware/base.pyi +71 -0
  117. aip_agents/middleware/manager.pyi +80 -0
  118. aip_agents/middleware/todolist.pyi +125 -0
  119. aip_agents/schema/__init__.pyi +9 -0
  120. aip_agents/schema/a2a.pyi +40 -0
  121. aip_agents/schema/agent.pyi +65 -0
  122. aip_agents/schema/hitl.pyi +89 -0
  123. aip_agents/schema/langgraph.pyi +28 -0
  124. aip_agents/schema/model_id.pyi +54 -0
  125. aip_agents/schema/step_limit.pyi +63 -0
  126. aip_agents/schema/storage.pyi +21 -0
  127. aip_agents/sentry/__init__.pyi +1 -1
  128. aip_agents/sentry/sentry.pyi +2 -2
  129. aip_agents/storage/base.pyi +1 -2
  130. aip_agents/storage/config.pyi +9 -46
  131. aip_agents/storage/providers/base.pyi +2 -3
  132. aip_agents/storage/providers/object_storage.pyi +1 -1
  133. aip_agents/tools/__init__.pyi +1 -1
  134. aip_agents/tools/bosa_tools.pyi +2 -2
  135. aip_agents/tools/constants.pyi +105 -100
  136. aip_agents/tools/memory_search/__init__.pyi +5 -0
  137. aip_agents/tools/memory_search/base.pyi +69 -0
  138. aip_agents/tools/memory_search/mem0.pyi +19 -0
  139. aip_agents/tools/memory_search/schema.pyi +15 -0
  140. aip_agents/tools/memory_search_tool.pyi +3 -0
  141. aip_agents/types/__init__.pyi +19 -3
  142. aip_agents/types/a2a_events.pyi +2 -73
  143. aip_agents/utils/__init__.pyi +7 -2
  144. aip_agents/utils/a2a_connector.pyi +14 -4
  145. aip_agents/utils/artifact_helpers.pyi +26 -2
  146. aip_agents/utils/constants.pyi +10 -0
  147. aip_agents/utils/datetime/__init__.pyi +4 -0
  148. aip_agents/utils/datetime/normalization.pyi +95 -0
  149. aip_agents/utils/datetime/timezone.pyi +48 -0
  150. aip_agents/utils/env_loader.pyi +2 -2
  151. aip_agents/utils/event_handler_registry.pyi +23 -0
  152. aip_agents/utils/final_response_builder.pyi +34 -0
  153. aip_agents/utils/formatter_llm_client.pyi +71 -0
  154. aip_agents/utils/langgraph/converter.pyi +1 -1
  155. aip_agents/utils/langgraph/tool_managers/a2a_tool_manager.pyi +2 -2
  156. aip_agents/utils/langgraph/tool_managers/base_tool_manager.pyi +2 -3
  157. aip_agents/utils/langgraph/tool_managers/delegation_tool_manager.pyi +14 -8
  158. aip_agents/utils/langgraph/tool_output_management.pyi +15 -2
  159. aip_agents/utils/logger.pyi +60 -0
  160. aip_agents/utils/metadata/__init__.pyi +5 -0
  161. aip_agents/utils/metadata/activity_metadata_helper.pyi +25 -0
  162. aip_agents/utils/metadata/activity_narrative/__init__.pyi +7 -0
  163. aip_agents/utils/metadata/activity_narrative/builder.pyi +35 -0
  164. aip_agents/utils/metadata/activity_narrative/constants.pyi +10 -0
  165. aip_agents/utils/metadata/activity_narrative/context.pyi +32 -0
  166. aip_agents/utils/metadata/activity_narrative/formatters.pyi +48 -0
  167. aip_agents/utils/metadata/activity_narrative/utils.pyi +12 -0
  168. aip_agents/utils/metadata/schemas/__init__.pyi +4 -0
  169. aip_agents/utils/metadata/schemas/activity_schema.pyi +18 -0
  170. aip_agents/utils/metadata/schemas/thinking_schema.pyi +20 -0
  171. aip_agents/utils/metadata/thinking_metadata_helper.pyi +4 -0
  172. aip_agents/utils/metadata_helper.pyi +50 -34
  173. aip_agents/utils/name_preprocessor/base_name_preprocessor.pyi +1 -2
  174. aip_agents/utils/name_preprocessor/google_name_preprocessor.pyi +1 -1
  175. aip_agents/utils/name_preprocessor/name_preprocessor.pyi +4 -4
  176. aip_agents/utils/name_preprocessor/openai_name_preprocessor.pyi +1 -1
  177. aip_agents/utils/pii/__init__.pyi +5 -0
  178. aip_agents/utils/pii/pii_handler.pyi +86 -0
  179. aip_agents/utils/pii/pii_helper.pyi +69 -0
  180. aip_agents/utils/pii/uuid_deanonymizer_mapping.pyi +62 -0
  181. aip_agents/utils/reference_helper.pyi +38 -6
  182. aip_agents/utils/sse_chunk_transformer.pyi +166 -0
  183. aip_agents/utils/step_limit_manager.pyi +112 -0
  184. aip_agents/utils/token_usage_helper.pyi +1 -1
  185. aip_agents.cp312-win_amd64.pyd +0 -0
  186. aip_agents.pyi +92 -34
  187. aip_agents_binary-0.5.4.dist-info/METADATA +649 -0
  188. aip_agents_binary-0.5.4.dist-info/RECORD +242 -0
  189. {aip_agents_binary-0.4.8.dist-info → aip_agents_binary-0.5.4.dist-info}/WHEEL +2 -1
  190. aip_agents_binary-0.5.4.dist-info/top_level.txt +1 -0
  191. aip_agents/agent/types.pyi +0 -109
  192. aip_agents/examples/hello_world_a2a_mem0_coordinator_client.pyi +0 -14
  193. aip_agents/examples/hello_world_a2a_mem0_coordinator_server.pyi +0 -10
  194. aip_agents/examples/hello_world_a2a_multi_agent_coordinator_client.pyi +0 -19
  195. aip_agents/examples/hello_world_a2a_multi_agent_coordinator_client_streaming.pyi +0 -9
  196. aip_agents/examples/hello_world_a2a_multi_agent_coordinator_server.pyi +0 -12
  197. aip_agents/examples/hello_world_langgraph_bosa.pyi +0 -5
  198. aip_agents/examples/hello_world_mem0_coordinator.pyi +0 -5
  199. aip_agents/examples/tools/pr_details_bosa_tool.pyi +0 -26
  200. aip_agents/memory/mem0_memory.pyi +0 -94
  201. aip_agents/tools/base.pyi +0 -44
  202. aip_agents/tools/base_bosa_tools.pyi +0 -12
  203. aip_agents/tools/bosa_connector.pyi +0 -30
  204. aip_agents/tools/bosa_tools_interface.pyi +0 -26
  205. aip_agents/utils/logger_manager.pyi +0 -151
  206. aip_agents.build/.gitignore +0 -1
  207. aip_agents_binary-0.4.8.dist-info/METADATA +0 -280
  208. aip_agents_binary-0.4.8.dist-info/RECORD +0 -166
@@ -0,0 +1,48 @@
1
+ from _typeshed import Incomplete
2
+ from collections.abc import Callable
3
+
4
+ __all__ = ['ArgsFormatter', 'OutputFormatter', 'SensitiveInfoFilter']
5
+
6
+ JSONScalar = str | int | float | bool | None
7
+
8
+ class SensitiveInfoFilter:
9
+ """Redact sensitive argument/output values before rendering or sending to LLMs."""
10
+ REDACTED: str
11
+ SENSITIVE_KEY_PATTERNS: Incomplete
12
+ def __init__(self) -> None:
13
+ """Initialize the sensitive info filter."""
14
+ def sanitize(self, args: dict[str, JSONValue] | None, output: JSONValue | None, tool_sanitizer: Callable[[dict[str, JSONValue] | None, JSONValue | None], dict[str, JSONValue]] | None = None) -> tuple[dict[str, JSONValue] | None, JSONValue | None]:
15
+ """Return sanitized arguments/output with optional tool overrides.
16
+
17
+ Args:
18
+ args: Raw arguments dictionary emitted by the tool.
19
+ output: Raw tool output which may be nested JSON.
20
+ tool_sanitizer: Optional callable that can override sanitized values.
21
+
22
+ Returns:
23
+ tuple: Sanitized args and output payloads.
24
+ """
25
+
26
+ class ArgsFormatter:
27
+ """Simple formatter that surfaces at most two argument key/value pairs."""
28
+ def format(self, args: dict[str, JSONValue] | None) -> str | None:
29
+ """Format tool arguments into a short excerpt.
30
+
31
+ Args:
32
+ args: Tool arguments dictionary.
33
+
34
+ Returns:
35
+ str | None: Concise representation of up to two key/value pairs.
36
+ """
37
+
38
+ class OutputFormatter:
39
+ """Lightweight formatter that truncates serialized output."""
40
+ def format(self, output: JSONValue | None) -> str | None:
41
+ """Format tool output into a readable excerpt.
42
+
43
+ Args:
44
+ output: Raw tool output.
45
+
46
+ Returns:
47
+ str | None: Truncated representation suitable for logs.
48
+ """
@@ -0,0 +1,12 @@
1
+ __all__ = ['_format_tool_or_subagent_name']
2
+
3
+ def _format_tool_or_subagent_name(name: str, remove_delegate_prefix: bool = False) -> str:
4
+ """Format tool/agent names to 'Camel Case' consistently.
5
+
6
+ Args:
7
+ name: Raw tool or sub-agent identifier.
8
+ remove_delegate_prefix: Whether to strip the ``delegate::`` prefix before formatting.
9
+
10
+ Returns:
11
+ str: Display-friendly tool or agent name.
12
+ """
@@ -0,0 +1,4 @@
1
+ from aip_agents.utils.metadata.schemas.activity_schema import Activity as Activity, ActivityDataType as ActivityDataType
2
+ from aip_agents.utils.metadata.schemas.thinking_schema import Thinking as Thinking
3
+
4
+ __all__ = ['Activity', 'ActivityDataType', 'Thinking']
@@ -0,0 +1,18 @@
1
+ from enum import StrEnum
2
+ from pydantic import BaseModel
3
+
4
+ class ActivityDataType(StrEnum):
5
+ """Enumeration of activity data types."""
6
+ ACTIVITY: str
7
+
8
+ class Activity(BaseModel):
9
+ '''Schema for activity info payload.
10
+
11
+ Fields:
12
+ - data_type: always "activity"
13
+ - id: UUID string identifying this activity event
14
+ - data_value: JSON string with additional info (e.g., {"message": "..."})
15
+ '''
16
+ data_type: ActivityDataType
17
+ id: str
18
+ data_value: str
@@ -0,0 +1,20 @@
1
+ from enum import StrEnum
2
+ from pydantic import BaseModel
3
+
4
+ class ThinkingDataType(StrEnum):
5
+ """Enum for thinking data types."""
6
+ THINKING: str
7
+ THINKING_START: str
8
+ THINKING_END: str
9
+
10
+ class Thinking(BaseModel):
11
+ '''Schema for thinking info payload.
12
+
13
+ Fields:
14
+ - data_type: type of thinking event
15
+ - id: UUID string identifying this thinking event
16
+ - data_value: JSON string with additional info (e.g., {"message": "..."})
17
+ '''
18
+ data_type: ThinkingDataType
19
+ id: str
20
+ data_value: str
@@ -0,0 +1,4 @@
1
+ from _typeshed import Incomplete
2
+ from aip_agents.utils.metadata.schemas.thinking_schema import Thinking as Thinking, ThinkingDataType as ThinkingDataType
3
+
4
+ FINAL_THINKING_INFO: Incomplete
@@ -1,57 +1,73 @@
1
1
  from _typeshed import Incomplete
2
- from aip_agents.utils.logger_manager import LoggerManager as LoggerManager
2
+ from aip_agents.utils.logger import get_logger as get_logger
3
+ from aip_agents.utils.metadata import create_tool_activity_info as create_tool_activity_info
3
4
  from aip_agents.utils.token_usage_helper import STEP_USAGE_KEY as STEP_USAGE_KEY, TOTAL_USAGE_KEY as TOTAL_USAGE_KEY
4
5
  from enum import StrEnum
5
6
  from typing import Any
6
7
 
7
8
  logger: Incomplete
8
- THINKING_DATA_TYPE: str
9
- FINAL_AGENT_THINKING_FINISHED_CONTENT: str
10
- FINAL_THINKING_AND_ACTIVITY_INFO: Incomplete
11
- DEFAULT_THINKING_AND_ACTIVITY_INFO: Incomplete
12
- TOOL_EXECUTION_RUNNING_TEMPLATE: str
13
- TOOL_EXECUTION_COMPLETE_TEMPLATE: str
14
- SUBAGENT_DELEGATION_TEMPLATE: str
15
- SUBAGENT_COMPLETE_TEMPLATE: str
16
- MIXED_EXECUTION_TEMPLATE: str
17
- DELEGATE_PREFIX: str
9
+
10
+ def start_step_counter_scope(start: int = 1) -> None:
11
+ """Begin a step counter scope, resetting only when entering the outermost scope.
12
+
13
+ Args:
14
+ start: Starting step number for the counter. Defaults to 1.
15
+ """
16
+ def end_step_counter_scope() -> None:
17
+ """Exit a step counter scope, maintaining parent scope counters.
18
+
19
+ Decrements the depth counter while preserving the step count for parent scopes.
20
+ """
21
+ def get_next_step_number() -> int:
22
+ """Return the next step number within the active scope.
23
+
24
+ Returns:
25
+ int: The next sequential step number in the current scope.
26
+ """
18
27
 
19
28
  class DefaultStepMessages(StrEnum):
20
29
  """Constants for default step indicator messages."""
21
- EN = 'Performing agent tasks'
22
- ID = 'Melakukan tugas agen'
30
+ EN: str
31
+ ID: str
23
32
 
24
33
  class Kind(StrEnum):
25
34
  """Constants for metadata kind values."""
26
- AGENT_STEP = 'agent_step'
27
- AGENT_THINKING_STEP = 'agent_thinking_step'
28
- FINAL_RESPONSE = 'final_response'
29
- FINAL_THINKING_STEP = 'final_agent_thinking_step'
30
- AGENT_DEFAULT = 'agent_default'
35
+ AGENT_STEP: str
36
+ AGENT_THINKING_STEP: str
37
+ FINAL_RESPONSE: str
38
+ FINAL_THINKING_STEP: str
39
+ AGENT_DEFAULT: str
40
+ TOKEN: str
31
41
 
32
42
  class Status(StrEnum):
33
43
  """Constants for metadata status values."""
34
- RUNNING = 'running'
35
- FINISHED = 'finished'
36
- STOPPED = 'stopped'
44
+ RUNNING: str
45
+ FINISHED: str
46
+ STOPPED: str
37
47
 
38
48
  class MetadataFieldKeys(StrEnum):
39
49
  """Enumeration of standard metadata field keys used in A2A events."""
40
- KIND = 'kind'
41
- STATUS = 'status'
42
- TIME = 'time'
43
- MESSAGE = 'message'
44
- TOOL_INFO = 'tool_info'
45
- REFERENCES = 'references'
46
- THINKING_AND_ACTIVITY_INFO = 'thinking_and_activity_info'
50
+ KIND: str
51
+ STATUS: str
52
+ TIME: str
53
+ MESSAGE: str
54
+ TOOL_INFO: str
55
+ REFERENCES: str
56
+ THINKING_AND_ACTIVITY_INFO: str
57
+ HITL: str
47
58
  STEP_USAGE = STEP_USAGE_KEY
48
59
  TOTAL_USAGE = TOTAL_USAGE_KEY
60
+ TOKEN_STREAMING: str
61
+ PII_MAPPING: str
49
62
 
50
63
  class MetadataTimeTracker:
51
64
  """Tracks cumulative execution time across agent steps for final response metadata.
52
65
 
53
66
  This class provides a clean way to accumulate execution times from individual
54
67
  agent steps and apply the total time to final response metadata.
68
+
69
+ Attributes:
70
+ FLOAT_EPSILON: Epsilon value for floating point comparisons to avoid precision issues.
55
71
  """
56
72
  FLOAT_EPSILON: float
57
73
  def __init__(self) -> None:
@@ -60,11 +76,11 @@ class MetadataTimeTracker:
60
76
  """Update response metadata with accumulated time tracking.
61
77
 
62
78
  Args:
63
- response: Response dictionary containing metadata
79
+ response: Response dictionary containing metadata to update.
64
80
 
65
81
  Returns:
66
- Response with updated metadata for final responses. If any error occurs,
67
- returns the original response unchanged.
82
+ dict[str, Any]: Response with updated metadata for final responses. If any error occurs,
83
+ returns the original response unchanged.
68
84
  """
69
85
 
70
86
  def create_metadata(content: str = '', status: Status = ..., is_final: bool = False, existing_metadata: dict[str, Any] | None = None) -> dict[str, Any]:
@@ -78,7 +94,7 @@ def create_metadata(content: str = '', status: Status = ..., is_final: bool = Fa
78
94
  takes precedence over generated metadata for conflicting keys.
79
95
 
80
96
  Returns:
81
- The metadata for the content, merged with existing metadata if provided.
97
+ dict[str, Any]: The metadata for the content, merged with existing metadata if provided.
82
98
  """
83
99
  def create_tool_processing_metadata(original_metadata: dict[str, Any] | None = None) -> dict[str, Any]:
84
100
  """Create metadata for tool processing events (tool_call and tool_result).
@@ -87,7 +103,7 @@ def create_tool_processing_metadata(original_metadata: dict[str, Any] | None = N
87
103
  original_metadata: Optional original metadata to merge with.
88
104
 
89
105
  Returns:
90
- Metadata dictionary with agent_thinking_step kind and no message/time/status.
106
+ dict[str, Any]: Metadata dictionary with agent_thinking_step kind and no message/time/status.
91
107
  """
92
108
  def create_status_update_metadata(content: str, custom_metadata: dict[str, Any] | None = None) -> dict[str, Any]:
93
109
  """Create metadata for status update events with content-based rules.
@@ -97,5 +113,5 @@ def create_status_update_metadata(content: str, custom_metadata: dict[str, Any]
97
113
  custom_metadata: Optional custom metadata to merge with.
98
114
 
99
115
  Returns:
100
- Metadata dictionary following the specific rules for different content types.
116
+ dict[str, Any]: Metadata dictionary following the specific rules for different content types.
101
117
  """
@@ -1,7 +1,6 @@
1
- import abc
2
1
  from abc import ABC, abstractmethod
3
2
 
4
- class BaseNamePreprocessor(ABC, metaclass=abc.ABCMeta):
3
+ class BaseNamePreprocessor(ABC):
5
4
  """Base class for name preprocessing.
6
5
 
7
6
  It contains the common methods for name preprocessing.
@@ -1,5 +1,5 @@
1
1
  from _typeshed import Incomplete
2
- from aip_agents.utils.logger_manager import LoggerManager as LoggerManager
2
+ from aip_agents.utils.logger import get_logger as get_logger
3
3
  from aip_agents.utils.name_preprocessor import BaseNamePreprocessor as BaseNamePreprocessor
4
4
 
5
5
  logger: Incomplete
@@ -1,8 +1,8 @@
1
- from .base_name_preprocessor import BaseNamePreprocessor as BaseNamePreprocessor
2
- from .google_name_preprocessor import GoogleNamePreprocessor as GoogleNamePreprocessor
3
- from .openai_name_preprocessor import OpenAINamePreprocessor as OpenAINamePreprocessor
4
1
  from _typeshed import Incomplete
5
- from aip_agents.utils.logger_manager import LoggerManager as LoggerManager
2
+ from aip_agents.utils.logger import get_logger as get_logger
3
+ from aip_agents.utils.name_preprocessor.base_name_preprocessor import BaseNamePreprocessor as BaseNamePreprocessor
4
+ from aip_agents.utils.name_preprocessor.google_name_preprocessor import GoogleNamePreprocessor as GoogleNamePreprocessor
5
+ from aip_agents.utils.name_preprocessor.openai_name_preprocessor import OpenAINamePreprocessor as OpenAINamePreprocessor
6
6
 
7
7
  logger: Incomplete
8
8
 
@@ -1,5 +1,5 @@
1
1
  from _typeshed import Incomplete
2
- from aip_agents.utils.logger_manager import LoggerManager as LoggerManager
2
+ from aip_agents.utils.logger import get_logger as get_logger
3
3
  from aip_agents.utils.name_preprocessor import BaseNamePreprocessor as BaseNamePreprocessor
4
4
 
5
5
  logger: Incomplete
@@ -0,0 +1,5 @@
1
+ from aip_agents.utils.pii.pii_handler import ToolPIIHandler as ToolPIIHandler
2
+ from aip_agents.utils.pii.pii_helper import add_pii_mappings as add_pii_mappings, anonymize_final_response_content as anonymize_final_response_content, deanonymize_final_response_content as deanonymize_final_response_content, extract_pii_mapping_from_agent_response as extract_pii_mapping_from_agent_response
3
+ from aip_agents.utils.pii.uuid_deanonymizer_mapping import UUIDDeanonymizerMapping as UUIDDeanonymizerMapping
4
+
5
+ __all__ = ['ToolPIIHandler', 'add_pii_mappings', 'anonymize_final_response_content', 'deanonymize_final_response_content', 'extract_pii_mapping_from_agent_response', 'UUIDDeanonymizerMapping']
@@ -0,0 +1,86 @@
1
+ from _typeshed import Incomplete
2
+ from aip_agents.utils.logger import LoggerManager as LoggerManager
3
+ from aip_agents.utils.pii.uuid_deanonymizer_mapping import UUIDDeanonymizerMapping as UUIDDeanonymizerMapping
4
+ from enum import Enum
5
+ from gllm_privacy.pii_detector import TextAnalyzer, TextAnonymizer
6
+ from typing import Any
7
+
8
+ TextAnalyzer = Any
9
+ TextAnonymizer = Any
10
+ GDPLabsNerApiRemoteRecognizer = Any
11
+
12
+ class _Operation(str, Enum):
13
+ ANONYMIZE: str
14
+ DEANONYMIZE: str
15
+
16
+ logger: Incomplete
17
+ NER_API_URL_ENV_VAR: str
18
+ NER_API_KEY_ENV_VAR: str
19
+ NER_API_TIMEOUT: int
20
+ EXCLUDED_ENTITIES: Incomplete
21
+ DEFAULT_SUPPORTED_ENTITIES: Incomplete
22
+
23
+ class ToolPIIHandler:
24
+ """Handles PII masking/demasking for tool calling.
25
+
26
+ Tag replacement based on runner-provided mappings always works. Optional
27
+ NER-powered masking/de-masking is only enabled when NER_API_URL and
28
+ NER_API_KEY environment variables are set.
29
+
30
+ Attributes:
31
+ flat_pii_mapping: Flat mapping from runner service (tag → value)
32
+ text_analyzer: GLLM Privacy TextAnalyzer instance
33
+ text_anonymizer: GLLM Privacy TextAnonymizer instance
34
+ enable_ner: Whether NER is enabled
35
+ """
36
+ flat_pii_mapping: dict[str, str]
37
+ enable_ner: bool
38
+ text_analyzer: TextAnalyzer | None
39
+ text_anonymizer: TextAnonymizer | None
40
+ def __init__(self, pii_mapping: dict[str, str] | None = None, ner_api_url: str | None = None, ner_api_key: str | None = None) -> None:
41
+ """Initialize PII handler (private - use create_if_enabled() instead).
42
+
43
+ Initializes GLLM Privacy components (TextAnalyzer, TextAnonymizer) if NER credentials
44
+ are provided. Creates dual recognizers for Indonesian and English languages.
45
+ Pre-loads any existing PII mappings into the anonymizer's internal state.
46
+
47
+ Args:
48
+ pii_mapping: Existing PII mapping from runner service (flat format: tag -> value)
49
+ ner_api_url: NER API endpoint URL
50
+ ner_api_key: NER API authentication key
51
+ """
52
+ @classmethod
53
+ def create_if_enabled(cls, pii_mapping: dict[str, str] | None = None) -> ToolPIIHandler | None:
54
+ """Create ToolPIIHandler when mappings or NER configuration exist.
55
+
56
+ Args:
57
+ pii_mapping: Existing PII mapping from runner service
58
+
59
+ Returns:
60
+ ToolPIIHandler instance when mapping or NER config is available, None otherwise
61
+ """
62
+ def deanonymize_tool_args(self, args: dict[str, Any]) -> dict[str, Any]:
63
+ """Replace PII tags in tool arguments with real values.
64
+
65
+ Recursively processes dictionaries, lists, and strings to replace all PII tags
66
+ (e.g., '<EMAIL_1>') with their corresponding real values from flat_pii_mapping.
67
+
68
+ Args:
69
+ args: Tool arguments that may contain PII tags
70
+
71
+ Returns:
72
+ Arguments with tags replaced by real values
73
+ """
74
+ def anonymize_tool_output(self, output: Any) -> tuple[Any, dict[str, str]]:
75
+ """Mask PII values in tool output.
76
+
77
+ Handles string and dictionary outputs. For strings, uses two-phase anonymization:
78
+ first masks known PII, then detects new PII via NER. For dictionaries, recursively
79
+ processes all string values. Returns updated mapping with any newly discovered PII.
80
+
81
+ Args:
82
+ output: Tool output that may contain PII values (string, dict, or other)
83
+
84
+ Returns:
85
+ Tuple of (anonymized_output, updated_flat_pii_mapping)
86
+ """
@@ -0,0 +1,69 @@
1
+ from _typeshed import Incomplete
2
+ from aip_agents.utils.logger import LoggerManager as LoggerManager
3
+ from typing import Any
4
+
5
+ logger: Incomplete
6
+
7
+ def add_pii_mappings(left: dict[str, str] | None, right: dict[str, str] | None) -> dict[str, str]:
8
+ """Reducer function to merge PII mappings from multiple sources.
9
+
10
+ This is a LangGraph reducer function that merges PII mappings from:
11
+ - Parent agent's initial mapping
12
+ - Tool outputs with newly discovered PII
13
+ - Subagent responses with their discovered PII
14
+
15
+ Args:
16
+ left: Existing PII mapping (or None)
17
+ right: New PII mapping to merge (or None)
18
+
19
+ Returns:
20
+ Merged PII mapping dictionary
21
+
22
+ Note:
23
+ - Right (new) mappings take precedence over left (existing)
24
+ - Handles None/non-dict cases gracefully
25
+ - Preserves all unique PII tags
26
+ - Returns empty dict if both inputs are None/empty
27
+ """
28
+ def extract_pii_mapping_from_agent_response(result: Any) -> dict[str, str] | None:
29
+ """Extract PII mapping from subagent response.
30
+
31
+ Used by DelegationToolManager to propagate PII mappings from subagents
32
+ back to parent agents.
33
+
34
+ Args:
35
+ result: The result returned by the delegated agent
36
+
37
+ Returns:
38
+ PII mapping dictionary if found, None otherwise
39
+
40
+ Note:
41
+ - Checks if result is a dict
42
+ - Extracts 'full_final_state' from result
43
+ - Extracts 'pii_mapping' from full_final_state
44
+ - Validates mapping is a non-empty dict
45
+ - Returns None if any step fails
46
+ """
47
+ def deanonymize_final_response_content(content: str, is_final_response: bool, metadata: dict[str, Any] | None) -> str:
48
+ """Deanonymize final response content using PII mapping from metadata.
49
+
50
+ Args:
51
+ content: Final response content that may contain PII tags.
52
+ is_final_response: Flag indicating whether this message is a final response.
53
+ metadata: Optional metadata dict (or event payload containing ``metadata``) with
54
+ ``pii_mapping`` tag-to-value mapping.
55
+
56
+ Returns:
57
+ Content string with PII tags replaced by real values when applicable.
58
+ """
59
+ def anonymize_final_response_content(content: str, metadata: dict[str, Any] | None) -> str:
60
+ """Anonymize final response content using PII mapping from metadata.
61
+
62
+ Args:
63
+ content: Final response content that may contain real PII values.
64
+ metadata: Metadata dict (or event payload containing ``metadata``) with
65
+ ``pii_mapping`` tag-to-value mapping.
66
+
67
+ Returns:
68
+ Content string with real PII values replaced by their PII tags when mapping is present.
69
+ """
@@ -0,0 +1,62 @@
1
+ from aip_agents.utils.constants import DEFAULT_PII_TAG_NAMESPACE as DEFAULT_PII_TAG_NAMESPACE
2
+ from dataclasses import dataclass
3
+ from gllm_privacy.pii_detector.utils.deanonymizer_mapping import DeanonymizerMapping, MappingDataType
4
+ from typing import Any
5
+
6
+ MappingDataType = dict[str, dict[str, str]]
7
+
8
+ class DeanonymizerMapping:
9
+ """Fallback deanonymizer mapping when optional dependency is missing.
10
+
11
+ This class exists only to keep the module importable when `gllm-privacy`
12
+ is not installed.
13
+ """
14
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
15
+ """Initialize the mapping.
16
+
17
+ Raises:
18
+ ImportError: Always raised because `gllm-privacy` is required.
19
+ """
20
+
21
+ def format_operator_with_uuid(operator_name: str, uuid_suffix: str) -> str:
22
+ """Format the operator name with a UUID suffix.
23
+
24
+ Args:
25
+ operator_name: The operator name.
26
+ uuid_suffix: The UUID suffix to append.
27
+
28
+ Returns:
29
+ The formatted operator name with UUID suffix.
30
+ """
31
+
32
+ @dataclass
33
+ class UUIDDeanonymizerMapping(DeanonymizerMapping):
34
+ """Class to store the deanonymizer mapping with UUID suffixes.
35
+
36
+ This class extends DeanonymizerMapping to use UUID suffixes instead of
37
+ sequential numbers for differentiating multiple entities of the same type.
38
+
39
+ Attributes:
40
+ mapping: The deanonymizer mapping.
41
+ skip_format_duplicates: Whether to skip formatting duplicated operators.
42
+ uuid_length: The length of the UUID suffix to use (default: 8).
43
+ """
44
+ uuid_length: int = ...
45
+ def update(self, new_mapping: MappingDataType, use_uuid_suffix: bool | None = None) -> None:
46
+ """Update the deanonymizer mapping with new values using UUID suffixes.
47
+
48
+ Duplicated values will not be added. If there are multiple entities of the same type,
49
+ the mapping will include a UUID suffix to differentiate them. For example, if there are
50
+ two names in the input text, the mapping will include NAME_<uuid1> and NAME_<uuid2>.
51
+
52
+ Args:
53
+ new_mapping: The new mapping to be added to the existing deanonymizer mapping.
54
+ use_uuid_suffix: Whether to apply UUID suffixes to keys.
55
+ If True, keys will always be formatted with UUID suffixes.
56
+ If False, keys will be used as-is without UUID formatting.
57
+ If None, behavior falls back to the instance configuration via
58
+ skip_format_duplicates (preserving existing behavior).
59
+
60
+ Returns:
61
+ None
62
+ """
@@ -1,20 +1,52 @@
1
1
  from _typeshed import Incomplete
2
+ from aip_agents.utils.logger import get_logger as get_logger
3
+ from aip_agents.utils.metadata_helper import MetadataFieldKeys as MetadataFieldKeys
2
4
  from gllm_core.schema import Chunk
5
+ from langgraph.types import Command
3
6
  from typing import Any
4
7
 
5
8
  logger: Incomplete
9
+ SAVE_OUTPUT_HISTORY_ATTR: str
10
+ FORMAT_AGENT_REFERENCE: str
6
11
 
7
- def validate_references(references: list[Any]) -> list[Chunk]:
8
- """Deduplicate reference data from agent state.
12
+ def extract_references_from_tool(tool: Any, tool_output: Any) -> list[Chunk]:
13
+ """Extract reference data from tools that support it.
14
+
15
+ Extraction priority:
16
+ 1. Direct tool references via _format_agent_reference (preferred)
17
+ 2. Command.update references (fallback for delegation tools)
18
+
19
+ Args:
20
+ tool: The tool instance to extract references from
21
+ tool_output: The output from the tool execution
22
+ Returns:
23
+ List of deduplicated Chunk objects containing reference data
24
+
25
+ Note:
26
+ - Never raises exceptions; logs warnings for issues
27
+ - Direct tool references take precedence over Command references
28
+ """
29
+ def extract_references_from_command_update(command: Command) -> list[Any]:
30
+ """Extract references from a Command object's update dictionary.
9
31
 
10
- Since the reducer function (add_references_chunks) already filters for valid Chunk objects,
11
- this function focuses on deduplication by content.
32
+ Args:
33
+ command: A Command object potentially containing references in its update dict.
34
+
35
+ Returns:
36
+ List of reference data (not yet validated/deduplicated)
37
+
38
+ Note:
39
+ - Never raises exceptions; logs warnings for malformed data
40
+ - Skips non-Chunk items with warning log
41
+ """
42
+ def validate_references(references: list[Any]) -> list[Chunk]:
43
+ """Validate and deduplicate reference data.
12
44
 
13
45
  Args:
14
- references: List of reference data from agent state (expected to be Chunk objects).
46
+ references: List of reference data (expected to be Chunk objects).
15
47
 
16
48
  Returns:
17
- List of deduplicated Chunk objects by content.
49
+ List of validated, deduplicated Chunk objects by content.
18
50
  """
19
51
  def serialize_references_for_metadata(references: list[Any]) -> list[dict[str, Any]]:
20
52
  """Serialize references for inclusion in A2A metadata.