glaip-sdk 0.1.2__py3-none-any.whl → 0.7.17__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 (217) hide show
  1. glaip_sdk/__init__.py +44 -4
  2. glaip_sdk/_version.py +9 -0
  3. glaip_sdk/agents/__init__.py +27 -0
  4. glaip_sdk/agents/base.py +1413 -0
  5. glaip_sdk/branding.py +126 -2
  6. glaip_sdk/cli/account_store.py +555 -0
  7. glaip_sdk/cli/auth.py +260 -15
  8. glaip_sdk/cli/commands/__init__.py +2 -2
  9. glaip_sdk/cli/commands/accounts.py +746 -0
  10. glaip_sdk/cli/commands/agents/__init__.py +116 -0
  11. glaip_sdk/cli/commands/agents/_common.py +562 -0
  12. glaip_sdk/cli/commands/agents/create.py +155 -0
  13. glaip_sdk/cli/commands/agents/delete.py +64 -0
  14. glaip_sdk/cli/commands/agents/get.py +89 -0
  15. glaip_sdk/cli/commands/agents/list.py +129 -0
  16. glaip_sdk/cli/commands/agents/run.py +264 -0
  17. glaip_sdk/cli/commands/agents/sync_langflow.py +72 -0
  18. glaip_sdk/cli/commands/agents/update.py +112 -0
  19. glaip_sdk/cli/commands/common_config.py +104 -0
  20. glaip_sdk/cli/commands/configure.py +728 -113
  21. glaip_sdk/cli/commands/mcps/__init__.py +94 -0
  22. glaip_sdk/cli/commands/mcps/_common.py +459 -0
  23. glaip_sdk/cli/commands/mcps/connect.py +82 -0
  24. glaip_sdk/cli/commands/mcps/create.py +152 -0
  25. glaip_sdk/cli/commands/mcps/delete.py +73 -0
  26. glaip_sdk/cli/commands/mcps/get.py +212 -0
  27. glaip_sdk/cli/commands/mcps/list.py +69 -0
  28. glaip_sdk/cli/commands/mcps/tools.py +235 -0
  29. glaip_sdk/cli/commands/mcps/update.py +190 -0
  30. glaip_sdk/cli/commands/models.py +12 -8
  31. glaip_sdk/cli/commands/shared/__init__.py +21 -0
  32. glaip_sdk/cli/commands/shared/formatters.py +91 -0
  33. glaip_sdk/cli/commands/tools/__init__.py +69 -0
  34. glaip_sdk/cli/commands/tools/_common.py +80 -0
  35. glaip_sdk/cli/commands/tools/create.py +228 -0
  36. glaip_sdk/cli/commands/tools/delete.py +61 -0
  37. glaip_sdk/cli/commands/tools/get.py +103 -0
  38. glaip_sdk/cli/commands/tools/list.py +69 -0
  39. glaip_sdk/cli/commands/tools/script.py +49 -0
  40. glaip_sdk/cli/commands/tools/update.py +102 -0
  41. glaip_sdk/cli/commands/transcripts/__init__.py +90 -0
  42. glaip_sdk/cli/commands/transcripts/_common.py +9 -0
  43. glaip_sdk/cli/commands/transcripts/clear.py +5 -0
  44. glaip_sdk/cli/commands/transcripts/detail.py +5 -0
  45. glaip_sdk/cli/commands/transcripts_original.py +756 -0
  46. glaip_sdk/cli/commands/update.py +163 -17
  47. glaip_sdk/cli/config.py +49 -4
  48. glaip_sdk/cli/constants.py +38 -0
  49. glaip_sdk/cli/context.py +8 -0
  50. glaip_sdk/cli/core/__init__.py +79 -0
  51. glaip_sdk/cli/core/context.py +124 -0
  52. glaip_sdk/cli/core/output.py +851 -0
  53. glaip_sdk/cli/core/prompting.py +649 -0
  54. glaip_sdk/cli/core/rendering.py +187 -0
  55. glaip_sdk/cli/display.py +41 -20
  56. glaip_sdk/cli/entrypoint.py +20 -0
  57. glaip_sdk/cli/hints.py +57 -0
  58. glaip_sdk/cli/io.py +6 -3
  59. glaip_sdk/cli/main.py +340 -143
  60. glaip_sdk/cli/masking.py +21 -33
  61. glaip_sdk/cli/pager.py +12 -13
  62. glaip_sdk/cli/parsers/__init__.py +1 -3
  63. glaip_sdk/cli/resolution.py +2 -1
  64. glaip_sdk/cli/slash/__init__.py +0 -9
  65. glaip_sdk/cli/slash/accounts_controller.py +580 -0
  66. glaip_sdk/cli/slash/accounts_shared.py +75 -0
  67. glaip_sdk/cli/slash/agent_session.py +62 -21
  68. glaip_sdk/cli/slash/prompt.py +21 -0
  69. glaip_sdk/cli/slash/remote_runs_controller.py +568 -0
  70. glaip_sdk/cli/slash/session.py +1105 -153
  71. glaip_sdk/cli/slash/tui/__init__.py +36 -0
  72. glaip_sdk/cli/slash/tui/accounts.tcss +177 -0
  73. glaip_sdk/cli/slash/tui/accounts_app.py +1853 -0
  74. glaip_sdk/cli/slash/tui/background_tasks.py +72 -0
  75. glaip_sdk/cli/slash/tui/clipboard.py +195 -0
  76. glaip_sdk/cli/slash/tui/context.py +92 -0
  77. glaip_sdk/cli/slash/tui/indicators.py +341 -0
  78. glaip_sdk/cli/slash/tui/keybind_registry.py +235 -0
  79. glaip_sdk/cli/slash/tui/layouts/__init__.py +14 -0
  80. glaip_sdk/cli/slash/tui/layouts/harlequin.py +184 -0
  81. glaip_sdk/cli/slash/tui/loading.py +80 -0
  82. glaip_sdk/cli/slash/tui/remote_runs_app.py +760 -0
  83. glaip_sdk/cli/slash/tui/terminal.py +407 -0
  84. glaip_sdk/cli/slash/tui/theme/__init__.py +15 -0
  85. glaip_sdk/cli/slash/tui/theme/catalog.py +79 -0
  86. glaip_sdk/cli/slash/tui/theme/manager.py +112 -0
  87. glaip_sdk/cli/slash/tui/theme/tokens.py +55 -0
  88. glaip_sdk/cli/slash/tui/toast.py +388 -0
  89. glaip_sdk/cli/transcript/__init__.py +12 -52
  90. glaip_sdk/cli/transcript/cache.py +255 -44
  91. glaip_sdk/cli/transcript/capture.py +66 -1
  92. glaip_sdk/cli/transcript/history.py +815 -0
  93. glaip_sdk/cli/transcript/viewer.py +72 -463
  94. glaip_sdk/cli/tui_settings.py +125 -0
  95. glaip_sdk/cli/update_notifier.py +227 -10
  96. glaip_sdk/cli/validators.py +5 -6
  97. glaip_sdk/client/__init__.py +3 -1
  98. glaip_sdk/client/_schedule_payloads.py +89 -0
  99. glaip_sdk/client/agent_runs.py +147 -0
  100. glaip_sdk/client/agents.py +576 -44
  101. glaip_sdk/client/base.py +26 -0
  102. glaip_sdk/client/hitl.py +136 -0
  103. glaip_sdk/client/main.py +25 -14
  104. glaip_sdk/client/mcps.py +165 -24
  105. glaip_sdk/client/payloads/agent/__init__.py +23 -0
  106. glaip_sdk/client/{_agent_payloads.py → payloads/agent/requests.py} +63 -47
  107. glaip_sdk/client/payloads/agent/responses.py +43 -0
  108. glaip_sdk/client/run_rendering.py +546 -92
  109. glaip_sdk/client/schedules.py +439 -0
  110. glaip_sdk/client/shared.py +21 -0
  111. glaip_sdk/client/tools.py +206 -32
  112. glaip_sdk/config/constants.py +33 -2
  113. glaip_sdk/guardrails/__init__.py +80 -0
  114. glaip_sdk/guardrails/serializer.py +89 -0
  115. glaip_sdk/hitl/__init__.py +48 -0
  116. glaip_sdk/hitl/base.py +64 -0
  117. glaip_sdk/hitl/callback.py +43 -0
  118. glaip_sdk/hitl/local.py +121 -0
  119. glaip_sdk/hitl/remote.py +523 -0
  120. glaip_sdk/mcps/__init__.py +21 -0
  121. glaip_sdk/mcps/base.py +345 -0
  122. glaip_sdk/models/__init__.py +136 -0
  123. glaip_sdk/models/_provider_mappings.py +101 -0
  124. glaip_sdk/models/_validation.py +97 -0
  125. glaip_sdk/models/agent.py +48 -0
  126. glaip_sdk/models/agent_runs.py +117 -0
  127. glaip_sdk/models/common.py +42 -0
  128. glaip_sdk/models/constants.py +141 -0
  129. glaip_sdk/models/mcp.py +33 -0
  130. glaip_sdk/models/model.py +170 -0
  131. glaip_sdk/models/schedule.py +224 -0
  132. glaip_sdk/models/tool.py +33 -0
  133. glaip_sdk/payload_schemas/__init__.py +1 -13
  134. glaip_sdk/payload_schemas/agent.py +1 -0
  135. glaip_sdk/payload_schemas/guardrails.py +34 -0
  136. glaip_sdk/registry/__init__.py +55 -0
  137. glaip_sdk/registry/agent.py +164 -0
  138. glaip_sdk/registry/base.py +139 -0
  139. glaip_sdk/registry/mcp.py +253 -0
  140. glaip_sdk/registry/tool.py +445 -0
  141. glaip_sdk/rich_components.py +58 -2
  142. glaip_sdk/runner/__init__.py +76 -0
  143. glaip_sdk/runner/base.py +84 -0
  144. glaip_sdk/runner/deps.py +115 -0
  145. glaip_sdk/runner/langgraph.py +1055 -0
  146. glaip_sdk/runner/logging_config.py +77 -0
  147. glaip_sdk/runner/mcp_adapter/__init__.py +13 -0
  148. glaip_sdk/runner/mcp_adapter/base_mcp_adapter.py +43 -0
  149. glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +257 -0
  150. glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +116 -0
  151. glaip_sdk/runner/tool_adapter/__init__.py +18 -0
  152. glaip_sdk/runner/tool_adapter/base_tool_adapter.py +44 -0
  153. glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +242 -0
  154. glaip_sdk/schedules/__init__.py +22 -0
  155. glaip_sdk/schedules/base.py +291 -0
  156. glaip_sdk/tools/__init__.py +22 -0
  157. glaip_sdk/tools/base.py +488 -0
  158. glaip_sdk/utils/__init__.py +59 -12
  159. glaip_sdk/utils/a2a/__init__.py +34 -0
  160. glaip_sdk/utils/a2a/event_processor.py +188 -0
  161. glaip_sdk/utils/agent_config.py +8 -2
  162. glaip_sdk/utils/bundler.py +403 -0
  163. glaip_sdk/utils/client.py +111 -0
  164. glaip_sdk/utils/client_utils.py +39 -7
  165. glaip_sdk/utils/datetime_helpers.py +58 -0
  166. glaip_sdk/utils/discovery.py +78 -0
  167. glaip_sdk/utils/display.py +23 -15
  168. glaip_sdk/utils/export.py +143 -0
  169. glaip_sdk/utils/general.py +0 -33
  170. glaip_sdk/utils/import_export.py +12 -7
  171. glaip_sdk/utils/import_resolver.py +524 -0
  172. glaip_sdk/utils/instructions.py +101 -0
  173. glaip_sdk/utils/rendering/__init__.py +115 -1
  174. glaip_sdk/utils/rendering/formatting.py +5 -30
  175. glaip_sdk/utils/rendering/layout/__init__.py +64 -0
  176. glaip_sdk/utils/rendering/{renderer → layout}/panels.py +9 -0
  177. glaip_sdk/utils/rendering/{renderer → layout}/progress.py +70 -1
  178. glaip_sdk/utils/rendering/layout/summary.py +74 -0
  179. glaip_sdk/utils/rendering/layout/transcript.py +606 -0
  180. glaip_sdk/utils/rendering/models.py +1 -0
  181. glaip_sdk/utils/rendering/renderer/__init__.py +9 -47
  182. glaip_sdk/utils/rendering/renderer/base.py +299 -1434
  183. glaip_sdk/utils/rendering/renderer/config.py +1 -5
  184. glaip_sdk/utils/rendering/renderer/debug.py +26 -20
  185. glaip_sdk/utils/rendering/renderer/factory.py +138 -0
  186. glaip_sdk/utils/rendering/renderer/stream.py +4 -33
  187. glaip_sdk/utils/rendering/renderer/summary_window.py +79 -0
  188. glaip_sdk/utils/rendering/renderer/thinking.py +273 -0
  189. glaip_sdk/utils/rendering/renderer/tool_panels.py +442 -0
  190. glaip_sdk/utils/rendering/renderer/transcript_mode.py +162 -0
  191. glaip_sdk/utils/rendering/state.py +204 -0
  192. glaip_sdk/utils/rendering/steps/__init__.py +34 -0
  193. glaip_sdk/utils/rendering/{steps.py → steps/event_processor.py} +53 -440
  194. glaip_sdk/utils/rendering/steps/format.py +176 -0
  195. glaip_sdk/utils/rendering/steps/manager.py +387 -0
  196. glaip_sdk/utils/rendering/timing.py +36 -0
  197. glaip_sdk/utils/rendering/viewer/__init__.py +21 -0
  198. glaip_sdk/utils/rendering/viewer/presenter.py +184 -0
  199. glaip_sdk/utils/resource_refs.py +25 -13
  200. glaip_sdk/utils/runtime_config.py +426 -0
  201. glaip_sdk/utils/serialization.py +18 -0
  202. glaip_sdk/utils/sync.py +162 -0
  203. glaip_sdk/utils/tool_detection.py +301 -0
  204. glaip_sdk/utils/tool_storage_provider.py +140 -0
  205. glaip_sdk/utils/validation.py +16 -24
  206. {glaip_sdk-0.1.2.dist-info → glaip_sdk-0.7.17.dist-info}/METADATA +69 -23
  207. glaip_sdk-0.7.17.dist-info/RECORD +224 -0
  208. {glaip_sdk-0.1.2.dist-info → glaip_sdk-0.7.17.dist-info}/WHEEL +2 -1
  209. glaip_sdk-0.7.17.dist-info/entry_points.txt +2 -0
  210. glaip_sdk-0.7.17.dist-info/top_level.txt +1 -0
  211. glaip_sdk/cli/commands/agents.py +0 -1369
  212. glaip_sdk/cli/commands/mcps.py +0 -1187
  213. glaip_sdk/cli/commands/tools.py +0 -584
  214. glaip_sdk/cli/utils.py +0 -1278
  215. glaip_sdk/models.py +0 -240
  216. glaip_sdk-0.1.2.dist-info/RECORD +0 -82
  217. glaip_sdk-0.1.2.dist-info/entry_points.txt +0 -3
@@ -1,10 +1,15 @@
1
- """Custom Rich components with copy-friendly defaults."""
1
+ """Custom Rich components with copy-friendly defaults.
2
+
3
+ Authors:
4
+ Raymond Christopher (raymond.christopher@gdplabs.id)
5
+ """
2
6
 
3
7
  from __future__ import annotations
4
8
 
5
9
  from rich import box
6
10
  from rich.panel import Panel
7
11
  from rich.table import Table
12
+ from rich.text import Text
8
13
 
9
14
 
10
15
  class AIPPanel(Panel):
@@ -66,4 +71,55 @@ class AIPGrid(Table):
66
71
  )
67
72
 
68
73
 
69
- __all__ = ["AIPPanel", "AIPTable", "AIPGrid"]
74
+ class RemoteRunsTable(AIPTable):
75
+ """Rich Table for displaying remote agent runs with pagination support."""
76
+
77
+ def __init__(self, *args, **kwargs):
78
+ """Initialize RemoteRunsTable with columns for run display.
79
+
80
+ Args:
81
+ *args: Positional arguments passed to AIPTable
82
+ **kwargs: Keyword arguments passed to AIPTable
83
+ """
84
+ kwargs.setdefault("row_styles", ("dim", "none"))
85
+ kwargs.setdefault("show_header", True)
86
+ super().__init__(*args, **kwargs)
87
+ # Add columns for run display
88
+ self.add_column("", width=2, no_wrap=True) # Selection gutter
89
+ self.add_column("Run UUID", style="cyan", width=36, no_wrap=True)
90
+ self.add_column("Type", style="yellow", width=8, no_wrap=True)
91
+ self.add_column("Status", style="magenta", width=12, no_wrap=True)
92
+ self.add_column("Started (UTC)", style="dim", width=20, no_wrap=True)
93
+ self.add_column("Completed (UTC)", style="dim", width=20, no_wrap=True)
94
+ self.add_column("Duration", style="green", width=10, no_wrap=True)
95
+ self.add_column("Input Preview", style="white", width=40, overflow="ellipsis")
96
+
97
+ def add_run_row(
98
+ self,
99
+ run_uuid: str,
100
+ run_type: str,
101
+ status: str,
102
+ started: str,
103
+ completed: str,
104
+ duration: str,
105
+ preview: str,
106
+ *,
107
+ selected: bool = False,
108
+ ) -> None:
109
+ """Append a run row with optional selection styling."""
110
+ gutter = Text("› ", style="bold bright_cyan") if selected else Text(" ")
111
+ row_style = "reverse" if selected else None
112
+ self.add_row(
113
+ gutter,
114
+ run_uuid,
115
+ run_type,
116
+ status,
117
+ started,
118
+ completed,
119
+ duration,
120
+ preview,
121
+ style=row_style,
122
+ )
123
+
124
+
125
+ __all__ = ["AIPPanel", "AIPTable", "AIPGrid", "RemoteRunsTable"]
@@ -0,0 +1,76 @@
1
+ """Local agent execution runners.
2
+
3
+ This module provides runners for executing glaip-sdk agents locally
4
+ without requiring the AIP backend server. The primary runner is
5
+ LangGraphRunner which uses the aip-agents library.
6
+
7
+ To use local execution, install with the [local] extra:
8
+ pip install "glaip-sdk[local]"
9
+
10
+ Authors:
11
+ Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
12
+
13
+ Example:
14
+ >>> from glaip_sdk.runner import get_default_runner
15
+ >>> from glaip_sdk.agents import Agent
16
+ >>>
17
+ >>> agent = Agent(name="my-agent", instruction="You are helpful.")
18
+ >>> runner = get_default_runner()
19
+ >>> result = runner.run(agent, "Hello!")
20
+ """
21
+
22
+ from typing import TYPE_CHECKING, Any
23
+
24
+ from glaip_sdk.runner.deps import (
25
+ LOCAL_RUNTIME_AVAILABLE,
26
+ check_local_runtime_available,
27
+ get_local_runtime_missing_message,
28
+ )
29
+
30
+ # Default runner instance
31
+ _default_runner: Any | None = None
32
+
33
+
34
+ def get_default_runner() -> Any:
35
+ """Get the default runner instance for local agent execution.
36
+
37
+ Returns:
38
+ The default LangGraphRunner instance.
39
+
40
+ Raises:
41
+ RuntimeError: If local runtime dependencies are not available.
42
+ """
43
+ global _default_runner
44
+
45
+ if not check_local_runtime_available():
46
+ raise RuntimeError(get_local_runtime_missing_message())
47
+
48
+ if _default_runner is None:
49
+ # Lazy import to avoid requiring aip-agents when runner is not used
50
+ from glaip_sdk.runner.langgraph import LangGraphRunner # noqa: PLC0415
51
+
52
+ _default_runner = LangGraphRunner()
53
+
54
+ return _default_runner
55
+
56
+
57
+ if TYPE_CHECKING:
58
+ from glaip_sdk.runner.langgraph import LangGraphRunner
59
+
60
+ __all__ = [
61
+ "LOCAL_RUNTIME_AVAILABLE",
62
+ "LangGraphRunner",
63
+ "check_local_runtime_available",
64
+ "get_default_runner",
65
+ "get_local_runtime_missing_message",
66
+ ]
67
+
68
+
69
+ def __getattr__(name: str) -> Any:
70
+ """Lazy import for LangGraphRunner to avoid requiring aip-agents when not used."""
71
+ if name == "LangGraphRunner":
72
+ from glaip_sdk.runner.langgraph import LangGraphRunner # noqa: PLC0415
73
+
74
+ globals()["LangGraphRunner"] = LangGraphRunner
75
+ return LangGraphRunner
76
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -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,115 @@
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
+ try:
35
+ return importlib.util.find_spec("aip_agents") is not None
36
+ except (ImportError, ValueError):
37
+ return False
38
+
39
+
40
+ def check_local_runtime_available() -> bool:
41
+ """Check if the local runtime dependencies are installed and importable.
42
+
43
+ This function probes for the aip_agents module which provides the
44
+ LangGraphReactAgent for local execution. Results are cached for efficiency.
45
+
46
+ Returns:
47
+ True if local runtime is available, False otherwise.
48
+ """
49
+ global _local_runtime_available
50
+
51
+ if _local_runtime_available is None:
52
+ _local_runtime_available = _probe_aip_agents_import()
53
+ if _local_runtime_available:
54
+ logger.debug("Local runtime dependencies (aip-agents) detected")
55
+ else:
56
+ logger.debug("Local runtime dependencies (aip-agents) not available")
57
+
58
+ return _local_runtime_available
59
+
60
+
61
+ # Cached availability flag for use in conditions without function call overhead
62
+ LOCAL_RUNTIME_AVAILABLE: bool = check_local_runtime_available()
63
+
64
+
65
+ def get_local_runtime_missing_message() -> str:
66
+ """Generate an actionable error message when local runtime is not available.
67
+
68
+ Returns:
69
+ A user-friendly message explaining how to install local runtime dependencies
70
+ or how to use server-backed execution as an alternative.
71
+ """
72
+ return (
73
+ "Local runtime dependencies are not installed. "
74
+ "To run agents locally without an AIP server, install with:\n\n"
75
+ ' pip install "glaip-sdk[local]"\n\n'
76
+ "Alternatively, call deploy() to run this agent on the AIP server."
77
+ )
78
+
79
+
80
+ def get_local_mode_not_supported_for_tool_message(tool_ref: str) -> str:
81
+ """Generate an error message for tools that cannot be used in local mode.
82
+
83
+ Args:
84
+ tool_ref: A string identifier for the tool (name, ID, or type description).
85
+
86
+ Returns:
87
+ Error message explaining that the tool type is not supported locally.
88
+ """
89
+ return (
90
+ f"Tool '{tool_ref}' cannot be used in local mode. "
91
+ "Local runtime only supports LangChain-compatible tool classes/instances "
92
+ "and Tool.from_langchain(...) references. "
93
+ "Native platform tools (Tool.from_native()) require server-backed execution "
94
+ "via deploy()."
95
+ )
96
+
97
+
98
+ def get_uuid_not_supported_message(key_type: str, uuid_value: str) -> str:
99
+ """Generate an error message when a UUID is used in local mode.
100
+
101
+ In local mode, runtime_config keys must be tool/agent/MCP objects or names,
102
+ not UUIDs which require platform registry resolution.
103
+
104
+ Args:
105
+ key_type: The type of key (e.g., "tool", "agent", "mcp").
106
+ uuid_value: The UUID that was incorrectly provided.
107
+
108
+ Returns:
109
+ Error message explaining that UUIDs are not supported in local mode.
110
+ """
111
+ return (
112
+ f"UUID-like {key_type} key '{uuid_value}' is not supported in local mode. "
113
+ f"Local runtime cannot resolve {key_type} IDs - pass the {key_type} "
114
+ f"class/instance or name instead."
115
+ )