glaip-sdk 0.6.15b2__py3-none-any.whl → 0.6.16__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.
Files changed (154) hide show
  1. glaip_sdk/agents/__init__.py +27 -0
  2. glaip_sdk/agents/base.py +1196 -0
  3. glaip_sdk/cli/__init__.py +9 -0
  4. glaip_sdk/cli/account_store.py +540 -0
  5. glaip_sdk/cli/agent_config.py +78 -0
  6. glaip_sdk/cli/auth.py +699 -0
  7. glaip_sdk/cli/commands/__init__.py +5 -0
  8. glaip_sdk/cli/commands/accounts.py +746 -0
  9. glaip_sdk/cli/commands/agents.py +1509 -0
  10. glaip_sdk/cli/commands/common_config.py +104 -0
  11. glaip_sdk/cli/commands/configure.py +896 -0
  12. glaip_sdk/cli/commands/mcps.py +1356 -0
  13. glaip_sdk/cli/commands/models.py +69 -0
  14. glaip_sdk/cli/commands/tools.py +576 -0
  15. glaip_sdk/cli/commands/transcripts.py +755 -0
  16. glaip_sdk/cli/commands/update.py +61 -0
  17. glaip_sdk/cli/config.py +95 -0
  18. glaip_sdk/cli/constants.py +38 -0
  19. glaip_sdk/cli/context.py +150 -0
  20. glaip_sdk/cli/core/__init__.py +79 -0
  21. glaip_sdk/cli/core/context.py +124 -0
  22. glaip_sdk/cli/core/output.py +851 -0
  23. glaip_sdk/cli/core/prompting.py +649 -0
  24. glaip_sdk/cli/core/rendering.py +187 -0
  25. glaip_sdk/cli/display.py +355 -0
  26. glaip_sdk/cli/hints.py +57 -0
  27. glaip_sdk/cli/io.py +112 -0
  28. glaip_sdk/cli/main.py +615 -0
  29. glaip_sdk/cli/masking.py +136 -0
  30. glaip_sdk/cli/mcp_validators.py +287 -0
  31. glaip_sdk/cli/pager.py +266 -0
  32. glaip_sdk/cli/parsers/__init__.py +7 -0
  33. glaip_sdk/cli/parsers/json_input.py +177 -0
  34. glaip_sdk/cli/resolution.py +67 -0
  35. glaip_sdk/cli/rich_helpers.py +27 -0
  36. glaip_sdk/cli/slash/__init__.py +15 -0
  37. glaip_sdk/cli/slash/accounts_controller.py +578 -0
  38. glaip_sdk/cli/slash/accounts_shared.py +75 -0
  39. glaip_sdk/cli/slash/agent_session.py +285 -0
  40. glaip_sdk/cli/slash/prompt.py +256 -0
  41. glaip_sdk/cli/slash/remote_runs_controller.py +566 -0
  42. glaip_sdk/cli/slash/session.py +1708 -0
  43. glaip_sdk/cli/slash/tui/__init__.py +9 -0
  44. glaip_sdk/cli/slash/tui/accounts_app.py +876 -0
  45. glaip_sdk/cli/slash/tui/background_tasks.py +72 -0
  46. glaip_sdk/cli/slash/tui/loading.py +58 -0
  47. glaip_sdk/cli/slash/tui/remote_runs_app.py +628 -0
  48. glaip_sdk/cli/transcript/__init__.py +31 -0
  49. glaip_sdk/cli/transcript/cache.py +536 -0
  50. glaip_sdk/cli/transcript/capture.py +329 -0
  51. glaip_sdk/cli/transcript/export.py +38 -0
  52. glaip_sdk/cli/transcript/history.py +815 -0
  53. glaip_sdk/cli/transcript/launcher.py +77 -0
  54. glaip_sdk/cli/transcript/viewer.py +374 -0
  55. glaip_sdk/cli/update_notifier.py +290 -0
  56. glaip_sdk/cli/utils.py +263 -0
  57. glaip_sdk/cli/validators.py +238 -0
  58. glaip_sdk/client/__init__.py +11 -0
  59. glaip_sdk/client/_agent_payloads.py +520 -0
  60. glaip_sdk/client/agent_runs.py +147 -0
  61. glaip_sdk/client/agents.py +1335 -0
  62. glaip_sdk/client/base.py +502 -0
  63. glaip_sdk/client/main.py +249 -0
  64. glaip_sdk/client/mcps.py +370 -0
  65. glaip_sdk/client/run_rendering.py +700 -0
  66. glaip_sdk/client/shared.py +21 -0
  67. glaip_sdk/client/tools.py +661 -0
  68. glaip_sdk/client/validators.py +198 -0
  69. glaip_sdk/config/constants.py +52 -0
  70. glaip_sdk/mcps/__init__.py +21 -0
  71. glaip_sdk/mcps/base.py +345 -0
  72. glaip_sdk/models/__init__.py +90 -0
  73. glaip_sdk/models/agent.py +47 -0
  74. glaip_sdk/models/agent_runs.py +116 -0
  75. glaip_sdk/models/common.py +42 -0
  76. glaip_sdk/models/mcp.py +33 -0
  77. glaip_sdk/models/tool.py +33 -0
  78. glaip_sdk/payload_schemas/__init__.py +7 -0
  79. glaip_sdk/payload_schemas/agent.py +85 -0
  80. glaip_sdk/registry/__init__.py +55 -0
  81. glaip_sdk/registry/agent.py +164 -0
  82. glaip_sdk/registry/base.py +139 -0
  83. glaip_sdk/registry/mcp.py +253 -0
  84. glaip_sdk/registry/tool.py +232 -0
  85. glaip_sdk/runner/__init__.py +59 -0
  86. glaip_sdk/runner/base.py +84 -0
  87. glaip_sdk/runner/deps.py +112 -0
  88. glaip_sdk/runner/langgraph.py +782 -0
  89. glaip_sdk/runner/mcp_adapter/__init__.py +13 -0
  90. glaip_sdk/runner/mcp_adapter/base_mcp_adapter.py +43 -0
  91. glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +257 -0
  92. glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +95 -0
  93. glaip_sdk/runner/tool_adapter/__init__.py +18 -0
  94. glaip_sdk/runner/tool_adapter/base_tool_adapter.py +44 -0
  95. glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +219 -0
  96. glaip_sdk/tools/__init__.py +22 -0
  97. glaip_sdk/tools/base.py +435 -0
  98. glaip_sdk/utils/__init__.py +86 -0
  99. glaip_sdk/utils/a2a/__init__.py +34 -0
  100. glaip_sdk/utils/a2a/event_processor.py +188 -0
  101. glaip_sdk/utils/agent_config.py +194 -0
  102. glaip_sdk/utils/bundler.py +267 -0
  103. glaip_sdk/utils/client.py +111 -0
  104. glaip_sdk/utils/client_utils.py +486 -0
  105. glaip_sdk/utils/datetime_helpers.py +58 -0
  106. glaip_sdk/utils/discovery.py +78 -0
  107. glaip_sdk/utils/display.py +135 -0
  108. glaip_sdk/utils/export.py +143 -0
  109. glaip_sdk/utils/general.py +61 -0
  110. glaip_sdk/utils/import_export.py +168 -0
  111. glaip_sdk/utils/import_resolver.py +492 -0
  112. glaip_sdk/utils/instructions.py +101 -0
  113. glaip_sdk/utils/rendering/__init__.py +115 -0
  114. glaip_sdk/utils/rendering/formatting.py +264 -0
  115. glaip_sdk/utils/rendering/layout/__init__.py +64 -0
  116. glaip_sdk/utils/rendering/layout/panels.py +156 -0
  117. glaip_sdk/utils/rendering/layout/progress.py +202 -0
  118. glaip_sdk/utils/rendering/layout/summary.py +74 -0
  119. glaip_sdk/utils/rendering/layout/transcript.py +606 -0
  120. glaip_sdk/utils/rendering/models.py +85 -0
  121. glaip_sdk/utils/rendering/renderer/__init__.py +55 -0
  122. glaip_sdk/utils/rendering/renderer/base.py +1024 -0
  123. glaip_sdk/utils/rendering/renderer/config.py +27 -0
  124. glaip_sdk/utils/rendering/renderer/console.py +55 -0
  125. glaip_sdk/utils/rendering/renderer/debug.py +178 -0
  126. glaip_sdk/utils/rendering/renderer/factory.py +138 -0
  127. glaip_sdk/utils/rendering/renderer/stream.py +202 -0
  128. glaip_sdk/utils/rendering/renderer/summary_window.py +79 -0
  129. glaip_sdk/utils/rendering/renderer/thinking.py +273 -0
  130. glaip_sdk/utils/rendering/renderer/toggle.py +182 -0
  131. glaip_sdk/utils/rendering/renderer/tool_panels.py +442 -0
  132. glaip_sdk/utils/rendering/renderer/transcript_mode.py +162 -0
  133. glaip_sdk/utils/rendering/state.py +204 -0
  134. glaip_sdk/utils/rendering/step_tree_state.py +100 -0
  135. glaip_sdk/utils/rendering/steps/__init__.py +34 -0
  136. glaip_sdk/utils/rendering/steps/event_processor.py +778 -0
  137. glaip_sdk/utils/rendering/steps/format.py +176 -0
  138. glaip_sdk/utils/rendering/steps/manager.py +387 -0
  139. glaip_sdk/utils/rendering/timing.py +36 -0
  140. glaip_sdk/utils/rendering/viewer/__init__.py +21 -0
  141. glaip_sdk/utils/rendering/viewer/presenter.py +184 -0
  142. glaip_sdk/utils/resource_refs.py +195 -0
  143. glaip_sdk/utils/run_renderer.py +41 -0
  144. glaip_sdk/utils/runtime_config.py +425 -0
  145. glaip_sdk/utils/serialization.py +424 -0
  146. glaip_sdk/utils/sync.py +142 -0
  147. glaip_sdk/utils/tool_detection.py +33 -0
  148. glaip_sdk/utils/validation.py +264 -0
  149. {glaip_sdk-0.6.15b2.dist-info → glaip_sdk-0.6.16.dist-info}/METADATA +4 -5
  150. glaip_sdk-0.6.16.dist-info/RECORD +160 -0
  151. glaip_sdk-0.6.15b2.dist-info/RECORD +0 -12
  152. {glaip_sdk-0.6.15b2.dist-info → glaip_sdk-0.6.16.dist-info}/WHEEL +0 -0
  153. {glaip_sdk-0.6.15b2.dist-info → glaip_sdk-0.6.16.dist-info}/entry_points.txt +0 -0
  154. {glaip_sdk-0.6.15b2.dist-info → glaip_sdk-0.6.16.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,84 @@
1
+ """Abstract base class for agent execution runners.
2
+
3
+ Authors:
4
+ Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from abc import ABC, abstractmethod
10
+ from typing import TYPE_CHECKING, Any
11
+
12
+ if TYPE_CHECKING:
13
+ from glaip_sdk.agents.base import Agent
14
+
15
+
16
+ class BaseRunner(ABC):
17
+ """Abstract base class for agent execution runners.
18
+
19
+ Runners are responsible for executing glaip-sdk Agent instances
20
+ and returning results. Different runner implementations may use
21
+ different execution backends (LangGraph, Google ADK, etc.).
22
+ """
23
+
24
+ @abstractmethod
25
+ def run(
26
+ self,
27
+ agent: Agent,
28
+ message: str,
29
+ verbose: bool = False,
30
+ runtime_config: dict[str, Any] | None = None,
31
+ chat_history: list[dict[str, str]] | None = None,
32
+ **kwargs: Any,
33
+ ) -> str:
34
+ """Execute agent synchronously and return final response text.
35
+
36
+ Args:
37
+ agent: The glaip_sdk Agent to execute.
38
+ message: The user message to send to the agent.
39
+ verbose: If True, emit debug trace output during execution.
40
+ Defaults to False.
41
+ runtime_config: Optional runtime configuration for tools, MCPs, etc.
42
+ Defaults to None.
43
+ chat_history: Optional list of prior conversation messages.
44
+ Defaults to None.
45
+ **kwargs: Additional keyword arguments passed to the backend.
46
+
47
+ Returns:
48
+ The final response text from the agent.
49
+
50
+ Raises:
51
+ RuntimeError: If execution fails.
52
+ """
53
+ ...
54
+
55
+ @abstractmethod
56
+ async def arun(
57
+ self,
58
+ agent: Agent,
59
+ message: str,
60
+ verbose: bool = False,
61
+ runtime_config: dict[str, Any] | None = None,
62
+ chat_history: list[dict[str, str]] | None = None,
63
+ **kwargs: Any,
64
+ ) -> str:
65
+ """Execute agent asynchronously and return final response text.
66
+
67
+ Args:
68
+ agent: The glaip_sdk Agent to execute.
69
+ message: The user message to send to the agent.
70
+ verbose: If True, emit debug trace output during execution.
71
+ Defaults to False.
72
+ runtime_config: Optional runtime configuration for tools, MCPs, etc.
73
+ Defaults to None.
74
+ chat_history: Optional list of prior conversation messages.
75
+ Defaults to None.
76
+ **kwargs: Additional keyword arguments passed to the backend.
77
+
78
+ Returns:
79
+ The final response text from the agent.
80
+
81
+ Raises:
82
+ RuntimeError: If execution fails.
83
+ """
84
+ ...
@@ -0,0 +1,112 @@
1
+ """Dependency detection utilities for the runner module.
2
+
3
+ This module provides helpers to detect whether the local runtime dependencies
4
+ (aip-agents) are installed and to generate actionable error messages when they
5
+ are not available.
6
+
7
+ Authors:
8
+ Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
9
+
10
+ Example:
11
+ >>> from glaip_sdk.runner.deps import check_local_runtime_available
12
+ >>> if not check_local_runtime_available():
13
+ ... print(get_local_runtime_missing_message())
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import importlib.util
19
+
20
+ from gllm_core.utils import LoggerManager
21
+
22
+ logger = LoggerManager().get_logger(__name__)
23
+
24
+ # Module-level cache for import availability check
25
+ _local_runtime_available: bool | None = None
26
+
27
+
28
+ def _probe_aip_agents_import() -> bool:
29
+ """Check if aip_agents is available without importing it.
30
+
31
+ Returns:
32
+ True if aip_agents appears importable, False otherwise.
33
+ """
34
+ return importlib.util.find_spec("aip_agents") is not None
35
+
36
+
37
+ def check_local_runtime_available() -> bool:
38
+ """Check if the local runtime dependencies are installed and importable.
39
+
40
+ This function probes for the aip_agents module which provides the
41
+ LangGraphReactAgent for local execution. Results are cached for efficiency.
42
+
43
+ Returns:
44
+ True if local runtime is available, False otherwise.
45
+ """
46
+ global _local_runtime_available
47
+
48
+ if _local_runtime_available is None:
49
+ _local_runtime_available = _probe_aip_agents_import()
50
+ if _local_runtime_available:
51
+ logger.debug("Local runtime dependencies (aip-agents) detected")
52
+ else:
53
+ logger.debug("Local runtime dependencies (aip-agents) not available")
54
+
55
+ return _local_runtime_available
56
+
57
+
58
+ # Cached availability flag for use in conditions without function call overhead
59
+ LOCAL_RUNTIME_AVAILABLE: bool = check_local_runtime_available()
60
+
61
+
62
+ def get_local_runtime_missing_message() -> str:
63
+ """Generate an actionable error message when local runtime is not available.
64
+
65
+ Returns:
66
+ A user-friendly message explaining how to install local runtime dependencies
67
+ or how to use server-backed execution as an alternative.
68
+ """
69
+ return (
70
+ "Local runtime dependencies are not installed. "
71
+ "To run agents locally without an AIP server, install with:\n\n"
72
+ ' pip install "glaip-sdk[local]"\n\n'
73
+ "Alternatively, call deploy() to run this agent on the AIP server."
74
+ )
75
+
76
+
77
+ def get_local_mode_not_supported_for_tool_message(tool_ref: str) -> str:
78
+ """Generate an error message for tools that cannot be used in local mode.
79
+
80
+ Args:
81
+ tool_ref: A string identifier for the tool (name, ID, or type description).
82
+
83
+ Returns:
84
+ Error message explaining that the tool type is not supported locally.
85
+ """
86
+ return (
87
+ f"Tool '{tool_ref}' cannot be used in local mode. "
88
+ "Local runtime only supports LangChain-compatible tool classes/instances "
89
+ "and Tool.from_langchain(...) references. "
90
+ "Native platform tools (Tool.from_native()) require server-backed execution "
91
+ "via deploy()."
92
+ )
93
+
94
+
95
+ def get_uuid_not_supported_message(key_type: str, uuid_value: str) -> str:
96
+ """Generate an error message when a UUID is used in local mode.
97
+
98
+ In local mode, runtime_config keys must be tool/agent/MCP objects or names,
99
+ not UUIDs which require platform registry resolution.
100
+
101
+ Args:
102
+ key_type: The type of key (e.g., "tool", "agent", "mcp").
103
+ uuid_value: The UUID that was incorrectly provided.
104
+
105
+ Returns:
106
+ Error message explaining that UUIDs are not supported in local mode.
107
+ """
108
+ return (
109
+ f"UUID-like {key_type} key '{uuid_value}' is not supported in local mode. "
110
+ f"Local runtime cannot resolve {key_type} IDs - pass the {key_type} "
111
+ f"class/instance or name instead."
112
+ )