glaip-sdk 0.6.5b6__py3-none-any.whl → 0.7.7__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.
- glaip_sdk/__init__.py +42 -5
- glaip_sdk/agents/base.py +156 -32
- glaip_sdk/cli/auth.py +14 -8
- glaip_sdk/cli/commands/accounts.py +1 -1
- glaip_sdk/cli/commands/agents/__init__.py +119 -0
- glaip_sdk/cli/commands/agents/_common.py +561 -0
- glaip_sdk/cli/commands/agents/create.py +151 -0
- glaip_sdk/cli/commands/agents/delete.py +64 -0
- glaip_sdk/cli/commands/agents/get.py +89 -0
- glaip_sdk/cli/commands/agents/list.py +129 -0
- glaip_sdk/cli/commands/agents/run.py +264 -0
- glaip_sdk/cli/commands/agents/sync_langflow.py +72 -0
- glaip_sdk/cli/commands/agents/update.py +112 -0
- glaip_sdk/cli/commands/common_config.py +15 -12
- glaip_sdk/cli/commands/configure.py +2 -3
- glaip_sdk/cli/commands/mcps/__init__.py +94 -0
- glaip_sdk/cli/commands/mcps/_common.py +459 -0
- glaip_sdk/cli/commands/mcps/connect.py +82 -0
- glaip_sdk/cli/commands/mcps/create.py +152 -0
- glaip_sdk/cli/commands/mcps/delete.py +73 -0
- glaip_sdk/cli/commands/mcps/get.py +212 -0
- glaip_sdk/cli/commands/mcps/list.py +69 -0
- glaip_sdk/cli/commands/mcps/tools.py +235 -0
- glaip_sdk/cli/commands/mcps/update.py +190 -0
- glaip_sdk/cli/commands/models.py +2 -4
- glaip_sdk/cli/commands/shared/__init__.py +21 -0
- glaip_sdk/cli/commands/shared/formatters.py +91 -0
- glaip_sdk/cli/commands/tools/__init__.py +69 -0
- glaip_sdk/cli/commands/tools/_common.py +80 -0
- glaip_sdk/cli/commands/tools/create.py +228 -0
- glaip_sdk/cli/commands/tools/delete.py +61 -0
- glaip_sdk/cli/commands/tools/get.py +103 -0
- glaip_sdk/cli/commands/tools/list.py +69 -0
- glaip_sdk/cli/commands/tools/script.py +49 -0
- glaip_sdk/cli/commands/tools/update.py +102 -0
- glaip_sdk/cli/commands/transcripts/__init__.py +90 -0
- glaip_sdk/cli/commands/transcripts/_common.py +9 -0
- glaip_sdk/cli/commands/transcripts/clear.py +5 -0
- glaip_sdk/cli/commands/transcripts/detail.py +5 -0
- glaip_sdk/cli/commands/{transcripts.py → transcripts_original.py} +2 -1
- glaip_sdk/cli/commands/update.py +163 -17
- glaip_sdk/cli/core/output.py +12 -7
- glaip_sdk/cli/entrypoint.py +20 -0
- glaip_sdk/cli/main.py +127 -39
- glaip_sdk/cli/pager.py +3 -3
- glaip_sdk/cli/resolution.py +2 -1
- glaip_sdk/cli/slash/accounts_controller.py +112 -32
- glaip_sdk/cli/slash/agent_session.py +5 -2
- glaip_sdk/cli/slash/prompt.py +11 -0
- glaip_sdk/cli/slash/remote_runs_controller.py +1 -1
- glaip_sdk/cli/slash/session.py +58 -13
- glaip_sdk/cli/slash/tui/__init__.py +26 -1
- glaip_sdk/cli/slash/tui/accounts.tcss +7 -5
- glaip_sdk/cli/slash/tui/accounts_app.py +70 -9
- glaip_sdk/cli/slash/tui/clipboard.py +147 -0
- glaip_sdk/cli/slash/tui/context.py +59 -0
- glaip_sdk/cli/slash/tui/keybind_registry.py +235 -0
- glaip_sdk/cli/slash/tui/terminal.py +402 -0
- glaip_sdk/cli/slash/tui/theme/__init__.py +15 -0
- glaip_sdk/cli/slash/tui/theme/catalog.py +79 -0
- glaip_sdk/cli/slash/tui/theme/manager.py +86 -0
- glaip_sdk/cli/slash/tui/theme/tokens.py +55 -0
- glaip_sdk/cli/slash/tui/toast.py +123 -0
- glaip_sdk/cli/transcript/history.py +1 -1
- glaip_sdk/cli/transcript/viewer.py +5 -3
- glaip_sdk/cli/update_notifier.py +215 -7
- glaip_sdk/cli/validators.py +1 -1
- glaip_sdk/client/__init__.py +2 -1
- glaip_sdk/client/_schedule_payloads.py +89 -0
- glaip_sdk/client/agents.py +50 -8
- glaip_sdk/client/hitl.py +136 -0
- glaip_sdk/client/main.py +7 -1
- glaip_sdk/client/mcps.py +44 -13
- glaip_sdk/client/payloads/agent/__init__.py +23 -0
- glaip_sdk/client/{_agent_payloads.py → payloads/agent/requests.py} +22 -47
- glaip_sdk/client/payloads/agent/responses.py +43 -0
- glaip_sdk/client/run_rendering.py +367 -3
- glaip_sdk/client/schedules.py +439 -0
- glaip_sdk/client/tools.py +57 -26
- glaip_sdk/hitl/__init__.py +48 -0
- glaip_sdk/hitl/base.py +64 -0
- glaip_sdk/hitl/callback.py +43 -0
- glaip_sdk/hitl/local.py +121 -0
- glaip_sdk/hitl/remote.py +523 -0
- glaip_sdk/models/__init__.py +17 -0
- glaip_sdk/models/agent_runs.py +2 -1
- glaip_sdk/models/schedule.py +224 -0
- glaip_sdk/registry/tool.py +273 -59
- glaip_sdk/runner/__init__.py +20 -3
- glaip_sdk/runner/deps.py +5 -8
- glaip_sdk/runner/langgraph.py +317 -42
- glaip_sdk/runner/logging_config.py +77 -0
- glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +104 -5
- glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +72 -7
- glaip_sdk/schedules/__init__.py +22 -0
- glaip_sdk/schedules/base.py +291 -0
- glaip_sdk/tools/base.py +44 -11
- glaip_sdk/utils/__init__.py +1 -0
- glaip_sdk/utils/bundler.py +138 -2
- glaip_sdk/utils/import_resolver.py +43 -11
- glaip_sdk/utils/rendering/renderer/base.py +58 -0
- glaip_sdk/utils/runtime_config.py +15 -12
- glaip_sdk/utils/sync.py +31 -11
- glaip_sdk/utils/tool_detection.py +274 -6
- glaip_sdk/utils/tool_storage_provider.py +140 -0
- {glaip_sdk-0.6.5b6.dist-info → glaip_sdk-0.7.7.dist-info}/METADATA +47 -37
- glaip_sdk-0.7.7.dist-info/RECORD +213 -0
- {glaip_sdk-0.6.5b6.dist-info → glaip_sdk-0.7.7.dist-info}/WHEEL +2 -1
- glaip_sdk-0.7.7.dist-info/entry_points.txt +2 -0
- glaip_sdk-0.7.7.dist-info/top_level.txt +1 -0
- glaip_sdk/cli/commands/agents.py +0 -1509
- glaip_sdk/cli/commands/mcps.py +0 -1356
- glaip_sdk/cli/commands/tools.py +0 -576
- glaip_sdk/cli/utils.py +0 -263
- glaip_sdk-0.6.5b6.dist-info/RECORD +0 -159
- glaip_sdk-0.6.5b6.dist-info/entry_points.txt +0 -3
glaip_sdk/__init__.py
CHANGED
|
@@ -4,12 +4,49 @@ Authors:
|
|
|
4
4
|
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import importlib
|
|
10
|
+
from typing import TYPE_CHECKING, Any
|
|
11
|
+
|
|
7
12
|
from glaip_sdk._version import __version__
|
|
8
|
-
from glaip_sdk.client import Client
|
|
9
|
-
from glaip_sdk.exceptions import AIPError
|
|
10
|
-
from glaip_sdk.agents import Agent
|
|
11
|
-
from glaip_sdk.tools import Tool
|
|
12
|
-
from glaip_sdk.mcps import MCP
|
|
13
13
|
|
|
14
|
+
if TYPE_CHECKING: # pragma: no cover - import only for type checking
|
|
15
|
+
from glaip_sdk.agents import Agent
|
|
16
|
+
from glaip_sdk.client import Client
|
|
17
|
+
from glaip_sdk.exceptions import AIPError
|
|
18
|
+
from glaip_sdk.mcps import MCP
|
|
19
|
+
from glaip_sdk.tools import Tool
|
|
14
20
|
|
|
15
21
|
__all__ = ["Client", "Agent", "Tool", "MCP", "AIPError", "__version__"]
|
|
22
|
+
|
|
23
|
+
_LAZY_IMPORTS: dict[str, tuple[str, str]] = {
|
|
24
|
+
"Client": ("glaip_sdk.client", "Client"),
|
|
25
|
+
"Agent": ("glaip_sdk.agents", "Agent"),
|
|
26
|
+
"Tool": ("glaip_sdk.tools", "Tool"),
|
|
27
|
+
"MCP": ("glaip_sdk.mcps", "MCP"),
|
|
28
|
+
"AIPError": ("glaip_sdk.exceptions", "AIPError"),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def __getattr__(name: str) -> Any:
|
|
33
|
+
"""Lazy attribute access for public SDK symbols to defer heavy imports."""
|
|
34
|
+
if name == "__version__":
|
|
35
|
+
# Import __version__ when accessed via __getattr__
|
|
36
|
+
# This ensures coverage even if __version__ was removed from __dict__ for testing
|
|
37
|
+
from glaip_sdk._version import __version__ as version # noqa: PLC0415
|
|
38
|
+
|
|
39
|
+
globals()["__version__"] = version
|
|
40
|
+
return version
|
|
41
|
+
if name in _LAZY_IMPORTS:
|
|
42
|
+
module_path, attr_name = _LAZY_IMPORTS[name]
|
|
43
|
+
module = importlib.import_module(module_path)
|
|
44
|
+
attr = getattr(module, attr_name)
|
|
45
|
+
globals()[name] = attr
|
|
46
|
+
return attr
|
|
47
|
+
raise AttributeError(f"module 'glaip_sdk' has no attribute {name!r}")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def __dir__() -> list[str]:
|
|
51
|
+
"""Return module attributes for dir()."""
|
|
52
|
+
return sorted(__all__)
|
glaip_sdk/agents/base.py
CHANGED
|
@@ -50,16 +50,10 @@ from pathlib import Path
|
|
|
50
50
|
from typing import TYPE_CHECKING, Any
|
|
51
51
|
|
|
52
52
|
from glaip_sdk.registry import get_agent_registry, get_mcp_registry, get_tool_registry
|
|
53
|
-
from glaip_sdk.runner import get_default_runner
|
|
54
|
-
from glaip_sdk.runner.deps import (
|
|
55
|
-
check_local_runtime_available,
|
|
56
|
-
get_local_runtime_missing_message,
|
|
57
|
-
)
|
|
58
|
-
from glaip_sdk.utils.discovery import find_agent
|
|
59
53
|
from glaip_sdk.utils.resource_refs import is_uuid
|
|
60
|
-
from glaip_sdk.utils.runtime_config import normalize_runtime_config_keys
|
|
61
54
|
|
|
62
55
|
if TYPE_CHECKING:
|
|
56
|
+
from glaip_sdk.client.schedules import AgentScheduleManager
|
|
63
57
|
from glaip_sdk.models import AgentResponse
|
|
64
58
|
from glaip_sdk.registry import AgentRegistry, MCPRegistry, ToolRegistry
|
|
65
59
|
|
|
@@ -518,6 +512,8 @@ class Agent:
|
|
|
518
512
|
from glaip_sdk.utils.client import get_client # noqa: PLC0415
|
|
519
513
|
|
|
520
514
|
client = get_client()
|
|
515
|
+
from glaip_sdk.utils.discovery import find_agent # noqa: PLC0415
|
|
516
|
+
|
|
521
517
|
response = self._create_or_update_agent(config, client, find_agent)
|
|
522
518
|
|
|
523
519
|
# Update self with deployed info
|
|
@@ -847,6 +843,36 @@ class Agent:
|
|
|
847
843
|
self._client = client
|
|
848
844
|
return self
|
|
849
845
|
|
|
846
|
+
@property
|
|
847
|
+
def schedule(self) -> AgentScheduleManager:
|
|
848
|
+
"""Get the schedule manager for this agent.
|
|
849
|
+
|
|
850
|
+
Provides a convenient interface for managing schedules scoped to this agent.
|
|
851
|
+
|
|
852
|
+
Returns:
|
|
853
|
+
AgentScheduleManager for schedule operations
|
|
854
|
+
|
|
855
|
+
Raises:
|
|
856
|
+
ValueError: If agent is not deployed
|
|
857
|
+
RuntimeError: If agent is not bound to a client
|
|
858
|
+
|
|
859
|
+
Example:
|
|
860
|
+
>>> agent = client.get_agent_by_id("agent-id")
|
|
861
|
+
>>> schedules = agent.schedule.list()
|
|
862
|
+
>>> new_schedule = agent.schedule.create(
|
|
863
|
+
... input="Daily task",
|
|
864
|
+
... schedule="0 9 * * 1-5"
|
|
865
|
+
... )
|
|
866
|
+
"""
|
|
867
|
+
if not self.id:
|
|
868
|
+
raise ValueError(_AGENT_NOT_DEPLOYED_MSG)
|
|
869
|
+
if not self._client:
|
|
870
|
+
raise RuntimeError(_CLIENT_NOT_AVAILABLE_MSG)
|
|
871
|
+
|
|
872
|
+
from glaip_sdk.client.schedules import AgentScheduleManager # noqa: PLC0415
|
|
873
|
+
|
|
874
|
+
return AgentScheduleManager(self, self._client.schedules)
|
|
875
|
+
|
|
850
876
|
def _prepare_run_kwargs(
|
|
851
877
|
self,
|
|
852
878
|
message: str,
|
|
@@ -869,7 +895,7 @@ class Agent:
|
|
|
869
895
|
ValueError: If the agent hasn't been deployed yet.
|
|
870
896
|
RuntimeError: If client is not available.
|
|
871
897
|
"""
|
|
872
|
-
if not self.id:
|
|
898
|
+
if not self.id: # pragma: no cover - defensive: called only when self.id is truthy
|
|
873
899
|
raise ValueError(_AGENT_NOT_DEPLOYED_MSG)
|
|
874
900
|
if not self._client:
|
|
875
901
|
raise RuntimeError(_CLIENT_NOT_AVAILABLE_MSG)
|
|
@@ -883,6 +909,10 @@ class Agent:
|
|
|
883
909
|
}
|
|
884
910
|
|
|
885
911
|
if runtime_config is not None:
|
|
912
|
+
from glaip_sdk.utils.runtime_config import ( # noqa: PLC0415
|
|
913
|
+
normalize_runtime_config_keys,
|
|
914
|
+
)
|
|
915
|
+
|
|
886
916
|
call_kwargs["runtime_config"] = normalize_runtime_config_keys(
|
|
887
917
|
runtime_config,
|
|
888
918
|
tool_registry=get_tool_registry(),
|
|
@@ -893,10 +923,68 @@ class Agent:
|
|
|
893
923
|
call_kwargs.update(kwargs)
|
|
894
924
|
return agent_client, call_kwargs
|
|
895
925
|
|
|
926
|
+
def _get_local_runner_or_raise(self) -> Any:
|
|
927
|
+
"""Get the local runner if available, otherwise raise ValueError.
|
|
928
|
+
|
|
929
|
+
Returns:
|
|
930
|
+
The default local runner instance.
|
|
931
|
+
|
|
932
|
+
Raises:
|
|
933
|
+
ValueError: If local runtime is not available.
|
|
934
|
+
"""
|
|
935
|
+
from glaip_sdk.runner import get_default_runner # noqa: PLC0415
|
|
936
|
+
from glaip_sdk.runner.deps import ( # noqa: PLC0415
|
|
937
|
+
check_local_runtime_available,
|
|
938
|
+
get_local_runtime_missing_message,
|
|
939
|
+
)
|
|
940
|
+
|
|
941
|
+
if check_local_runtime_available():
|
|
942
|
+
return get_default_runner()
|
|
943
|
+
|
|
944
|
+
# If agent is not deployed, it *must* use local runtime
|
|
945
|
+
if not self.id:
|
|
946
|
+
raise ValueError(f"{_AGENT_NOT_DEPLOYED_MSG}\n\n{get_local_runtime_missing_message()}")
|
|
947
|
+
|
|
948
|
+
# If agent IS deployed but local execution was forced (local=True)
|
|
949
|
+
raise ValueError(
|
|
950
|
+
f"Local execution override was requested, but local runtime is missing.\n\n"
|
|
951
|
+
f"{get_local_runtime_missing_message()}"
|
|
952
|
+
)
|
|
953
|
+
|
|
954
|
+
def _prepare_local_runner_kwargs(
|
|
955
|
+
self,
|
|
956
|
+
message: str,
|
|
957
|
+
verbose: bool,
|
|
958
|
+
runtime_config: dict[str, Any] | None,
|
|
959
|
+
chat_history: list[dict[str, str]] | None,
|
|
960
|
+
**kwargs: Any,
|
|
961
|
+
) -> dict[str, Any]:
|
|
962
|
+
"""Prepare kwargs for local runner execution.
|
|
963
|
+
|
|
964
|
+
Args:
|
|
965
|
+
message: The message to send to the agent.
|
|
966
|
+
verbose: If True, print streaming output to console.
|
|
967
|
+
runtime_config: Optional runtime configuration.
|
|
968
|
+
chat_history: Optional list of prior conversation messages.
|
|
969
|
+
**kwargs: Additional arguments.
|
|
970
|
+
|
|
971
|
+
Returns:
|
|
972
|
+
Dictionary of prepared kwargs for runner.run() or runner.arun().
|
|
973
|
+
"""
|
|
974
|
+
return {
|
|
975
|
+
"agent": self,
|
|
976
|
+
"message": message,
|
|
977
|
+
"verbose": verbose,
|
|
978
|
+
"runtime_config": runtime_config,
|
|
979
|
+
"chat_history": chat_history,
|
|
980
|
+
**kwargs,
|
|
981
|
+
}
|
|
982
|
+
|
|
896
983
|
def run(
|
|
897
984
|
self,
|
|
898
985
|
message: str,
|
|
899
986
|
verbose: bool = False,
|
|
987
|
+
local: bool = False,
|
|
900
988
|
runtime_config: dict[str, Any] | None = None,
|
|
901
989
|
chat_history: list[dict[str, str]] | None = None,
|
|
902
990
|
**kwargs: Any,
|
|
@@ -909,9 +997,13 @@ class Agent:
|
|
|
909
997
|
- **Local**: When the agent is not deployed and glaip-sdk[local] is installed,
|
|
910
998
|
execution happens locally via aip-agents (no server required).
|
|
911
999
|
|
|
1000
|
+
You can force local execution for a deployed agent by passing `local=True`.
|
|
1001
|
+
|
|
912
1002
|
Args:
|
|
913
1003
|
message: The message to send to the agent.
|
|
914
1004
|
verbose: If True, print streaming output to console. Defaults to False.
|
|
1005
|
+
local: If True, force local execution even if the agent is deployed.
|
|
1006
|
+
Defaults to False.
|
|
915
1007
|
runtime_config: Optional runtime configuration for tools, MCPs, and agents.
|
|
916
1008
|
Keys can be SDK objects, UUIDs, or names. Example:
|
|
917
1009
|
{
|
|
@@ -933,42 +1025,47 @@ class Agent:
|
|
|
933
1025
|
RuntimeError: If server-backed execution fails due to client issues.
|
|
934
1026
|
"""
|
|
935
1027
|
# Backend routing: deployed agents use server, undeployed use local (if available)
|
|
936
|
-
if self.id:
|
|
1028
|
+
if self.id and not local:
|
|
937
1029
|
# Server-backed execution path (agent is deployed)
|
|
938
1030
|
agent_client, call_kwargs = self._prepare_run_kwargs(
|
|
939
|
-
message,
|
|
1031
|
+
message,
|
|
1032
|
+
verbose,
|
|
1033
|
+
runtime_config or kwargs.get("runtime_config"),
|
|
1034
|
+
**kwargs,
|
|
940
1035
|
)
|
|
941
1036
|
if chat_history is not None:
|
|
942
1037
|
call_kwargs["chat_history"] = chat_history
|
|
943
1038
|
return agent_client.run_agent(**call_kwargs)
|
|
944
1039
|
|
|
945
|
-
# Local execution path (agent is not deployed)
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
agent=self,
|
|
950
|
-
message=message,
|
|
951
|
-
verbose=verbose,
|
|
952
|
-
runtime_config=runtime_config,
|
|
953
|
-
chat_history=chat_history,
|
|
954
|
-
**kwargs,
|
|
955
|
-
)
|
|
956
|
-
|
|
957
|
-
# Neither deployed nor local runtime available - provide actionable error
|
|
958
|
-
raise ValueError(f"{_AGENT_NOT_DEPLOYED_MSG}\n\n{get_local_runtime_missing_message()}")
|
|
1040
|
+
# Local execution path (agent is not deployed OR local=True)
|
|
1041
|
+
runner = self._get_local_runner_or_raise()
|
|
1042
|
+
local_kwargs = self._prepare_local_runner_kwargs(message, verbose, runtime_config, chat_history, **kwargs)
|
|
1043
|
+
return runner.run(**local_kwargs)
|
|
959
1044
|
|
|
960
1045
|
async def arun(
|
|
961
1046
|
self,
|
|
962
1047
|
message: str,
|
|
963
1048
|
verbose: bool = False,
|
|
1049
|
+
local: bool = False,
|
|
964
1050
|
runtime_config: dict[str, Any] | None = None,
|
|
1051
|
+
chat_history: list[dict[str, str]] | None = None,
|
|
965
1052
|
**kwargs: Any,
|
|
966
1053
|
) -> AsyncGenerator[dict, None]:
|
|
967
1054
|
"""Run the agent asynchronously with streaming output.
|
|
968
1055
|
|
|
1056
|
+
Supports two execution modes:
|
|
1057
|
+
- **Server-backed**: When the agent is deployed (has an ID), execution
|
|
1058
|
+
happens via the AIP backend server with streaming.
|
|
1059
|
+
- **Local**: When the agent is not deployed and glaip-sdk[local] is installed,
|
|
1060
|
+
execution happens locally via aip-agents (no server required).
|
|
1061
|
+
|
|
1062
|
+
You can force local execution for a deployed agent by passing `local=True`.
|
|
1063
|
+
|
|
969
1064
|
Args:
|
|
970
1065
|
message: The message to send to the agent.
|
|
971
|
-
verbose: If True, print streaming output to console.
|
|
1066
|
+
verbose: If True, print streaming output to console. Defaults to False.
|
|
1067
|
+
local: If True, force local execution even if the agent is deployed.
|
|
1068
|
+
Defaults to False.
|
|
972
1069
|
runtime_config: Optional runtime configuration for tools, MCPs, and agents.
|
|
973
1070
|
Keys can be SDK objects, UUIDs, or names. Example:
|
|
974
1071
|
{
|
|
@@ -976,20 +1073,47 @@ class Agent:
|
|
|
976
1073
|
"mcp_configs": {"mcp-id": {"setting": "on"}},
|
|
977
1074
|
"agent_config": {"planning": True},
|
|
978
1075
|
}
|
|
1076
|
+
Defaults to None.
|
|
1077
|
+
chat_history: Optional list of prior conversation messages for context.
|
|
1078
|
+
Each message is a dict with "role" and "content" keys.
|
|
1079
|
+
Defaults to None.
|
|
979
1080
|
**kwargs: Additional arguments to pass to the run API.
|
|
980
1081
|
|
|
981
1082
|
Yields:
|
|
982
1083
|
Streaming response chunks from the agent.
|
|
983
1084
|
|
|
984
1085
|
Raises:
|
|
985
|
-
ValueError: If the agent
|
|
986
|
-
RuntimeError: If
|
|
1086
|
+
ValueError: If the agent is not deployed and local runtime is not available.
|
|
1087
|
+
RuntimeError: If server-backed execution fails due to client issues.
|
|
987
1088
|
"""
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1089
|
+
# Backend routing: deployed agents use server, undeployed use local (if available)
|
|
1090
|
+
if self.id and not local:
|
|
1091
|
+
# Server-backed execution path (agent is deployed)
|
|
1092
|
+
agent_client, call_kwargs = self._prepare_run_kwargs(
|
|
1093
|
+
message,
|
|
1094
|
+
verbose,
|
|
1095
|
+
runtime_config or kwargs.get("runtime_config"),
|
|
1096
|
+
**kwargs,
|
|
1097
|
+
)
|
|
1098
|
+
if chat_history is not None:
|
|
1099
|
+
call_kwargs["chat_history"] = chat_history
|
|
1100
|
+
|
|
1101
|
+
async for chunk in agent_client.arun_agent(**call_kwargs):
|
|
1102
|
+
yield chunk
|
|
1103
|
+
return
|
|
1104
|
+
|
|
1105
|
+
# Local execution path (agent is not deployed OR local=True)
|
|
1106
|
+
runner = self._get_local_runner_or_raise()
|
|
1107
|
+
local_kwargs = self._prepare_local_runner_kwargs(message, verbose, runtime_config, chat_history, **kwargs)
|
|
1108
|
+
result = await runner.arun(**local_kwargs)
|
|
1109
|
+
# Yield a final_response event for consistency with server-backed execution
|
|
1110
|
+
# Include event_type for A2A event shape parity
|
|
1111
|
+
yield {
|
|
1112
|
+
"event_type": "final_response",
|
|
1113
|
+
"metadata": {"kind": "final_response"},
|
|
1114
|
+
"content": result,
|
|
1115
|
+
"is_final": True,
|
|
1116
|
+
}
|
|
993
1117
|
|
|
994
1118
|
def update(self, **kwargs: Any) -> Agent:
|
|
995
1119
|
"""Update the deployed agent with new configuration.
|
glaip_sdk/cli/auth.py
CHANGED
|
@@ -19,8 +19,7 @@ from rich.console import Console
|
|
|
19
19
|
|
|
20
20
|
from glaip_sdk.branding import HINT_PREFIX_STYLE, WARNING_STYLE
|
|
21
21
|
from glaip_sdk.cli.account_store import AccountNotFoundError, AccountStoreError, get_account_store
|
|
22
|
-
from glaip_sdk.cli.hints import format_command_hint
|
|
23
|
-
from glaip_sdk.cli.utils import command_hint
|
|
22
|
+
from glaip_sdk.cli.hints import command_hint, format_command_hint
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
def prepare_authentication_export(
|
|
@@ -526,12 +525,19 @@ def resolve_api_url_from_context(
|
|
|
526
525
|
elif hasattr(ctx, "obj") and isinstance(ctx.obj, dict):
|
|
527
526
|
account_name = ctx.obj.get("account_name")
|
|
528
527
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
528
|
+
if isinstance(api_url, str) and api_url.strip():
|
|
529
|
+
return api_url.strip()
|
|
530
|
+
|
|
531
|
+
try:
|
|
532
|
+
resolved_url, _, _ = resolve_credentials(
|
|
533
|
+
account_name=account_name,
|
|
534
|
+
api_url=None,
|
|
535
|
+
api_key=None,
|
|
536
|
+
ignore_env_creds=True,
|
|
537
|
+
)
|
|
538
|
+
except Exception:
|
|
539
|
+
return None
|
|
540
|
+
|
|
535
541
|
return resolved_url
|
|
536
542
|
|
|
537
543
|
|
|
@@ -33,7 +33,7 @@ from glaip_sdk.cli.commands.common_config import check_connection, render_brandi
|
|
|
33
33
|
from glaip_sdk.cli.hints import format_command_hint
|
|
34
34
|
from glaip_sdk.cli.masking import mask_api_key_display
|
|
35
35
|
from glaip_sdk.cli.slash.accounts_shared import env_credentials_present
|
|
36
|
-
from glaip_sdk.cli.
|
|
36
|
+
from glaip_sdk.cli.hints import command_hint
|
|
37
37
|
from glaip_sdk.icons import ICON_TOOL
|
|
38
38
|
from glaip_sdk.rich_components import AIPPanel, AIPTable
|
|
39
39
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Agent CLI commands package.
|
|
2
|
+
|
|
3
|
+
This package contains agent management commands split by operation.
|
|
4
|
+
The package is the canonical import surface.
|
|
5
|
+
|
|
6
|
+
Authors:
|
|
7
|
+
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# pylint: disable=duplicate-code
|
|
11
|
+
# Import from submodules
|
|
12
|
+
from glaip_sdk.cli.commands.agents._common import ( # noqa: E402
|
|
13
|
+
AGENT_NOT_FOUND_ERROR,
|
|
14
|
+
_get_agent_for_update,
|
|
15
|
+
_resolve_agent,
|
|
16
|
+
agents_group,
|
|
17
|
+
_coerce_mapping_candidate,
|
|
18
|
+
_display_agent_details,
|
|
19
|
+
_emit_verbose_guidance,
|
|
20
|
+
_fetch_full_agent_details,
|
|
21
|
+
_get_agent_model_name,
|
|
22
|
+
_get_language_model_display_name,
|
|
23
|
+
_model_from_config,
|
|
24
|
+
_prepare_agent_output,
|
|
25
|
+
_resolve_resources_by_name,
|
|
26
|
+
console,
|
|
27
|
+
)
|
|
28
|
+
from glaip_sdk.cli.commands.agents.create import create # noqa: E402
|
|
29
|
+
from glaip_sdk.cli.commands.agents.delete import delete # noqa: E402
|
|
30
|
+
from glaip_sdk.cli.commands.agents.get import get # noqa: E402
|
|
31
|
+
from glaip_sdk.cli.commands.agents.list import list_agents # noqa: E402
|
|
32
|
+
from glaip_sdk.cli.commands.agents.run import run, _maybe_attach_transcript_toggle # noqa: E402
|
|
33
|
+
from glaip_sdk.cli.commands.agents.sync_langflow import sync_langflow # noqa: E402
|
|
34
|
+
from glaip_sdk.cli.commands.agents.update import update # noqa: E402
|
|
35
|
+
|
|
36
|
+
# Import core functions for test compatibility
|
|
37
|
+
from glaip_sdk.cli.core.context import get_client # noqa: E402
|
|
38
|
+
from glaip_sdk.cli.core.rendering import with_client_and_spinner # noqa: E402
|
|
39
|
+
|
|
40
|
+
# Import display functions for test compatibility
|
|
41
|
+
from glaip_sdk.cli.display import ( # noqa: E402
|
|
42
|
+
handle_json_output,
|
|
43
|
+
handle_rich_output,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# Import core output functions for test compatibility
|
|
47
|
+
from glaip_sdk.cli.core.output import ( # noqa: E402
|
|
48
|
+
handle_resource_export,
|
|
49
|
+
output_list,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# Import rendering functions for test compatibility
|
|
53
|
+
from glaip_sdk.cli.core.rendering import ( # noqa: E402
|
|
54
|
+
build_renderer,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Import display functions for test compatibility
|
|
58
|
+
from glaip_sdk.cli.display import ( # noqa: E402
|
|
59
|
+
display_agent_run_suggestions,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Import rich helpers for test compatibility
|
|
63
|
+
from glaip_sdk.cli.rich_helpers import ( # noqa: E402
|
|
64
|
+
markup_text,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# Import transcript functions for test compatibility
|
|
68
|
+
from glaip_sdk.cli.transcript import ( # noqa: E402
|
|
69
|
+
maybe_launch_post_run_viewer,
|
|
70
|
+
store_transcript_for_session,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
# Import IO functions for test compatibility
|
|
74
|
+
from glaip_sdk.cli.io import ( # noqa: E402
|
|
75
|
+
fetch_raw_resource_details,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Import utils for test compatibility
|
|
79
|
+
from glaip_sdk.utils import ( # noqa: E402
|
|
80
|
+
is_uuid,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
__all__ = [
|
|
84
|
+
"AGENT_NOT_FOUND_ERROR",
|
|
85
|
+
"agents_group",
|
|
86
|
+
"create",
|
|
87
|
+
"delete",
|
|
88
|
+
"get",
|
|
89
|
+
"list_agents",
|
|
90
|
+
"run",
|
|
91
|
+
"sync_langflow",
|
|
92
|
+
"update",
|
|
93
|
+
"_get_agent_for_update",
|
|
94
|
+
"_resolve_agent",
|
|
95
|
+
"_coerce_mapping_candidate",
|
|
96
|
+
"_display_agent_details",
|
|
97
|
+
"_emit_verbose_guidance",
|
|
98
|
+
"_fetch_full_agent_details",
|
|
99
|
+
"_get_agent_model_name",
|
|
100
|
+
"_get_language_model_display_name",
|
|
101
|
+
"_model_from_config",
|
|
102
|
+
"_prepare_agent_output",
|
|
103
|
+
"_resolve_resources_by_name",
|
|
104
|
+
"_maybe_attach_transcript_toggle",
|
|
105
|
+
"get_client",
|
|
106
|
+
"with_client_and_spinner",
|
|
107
|
+
"console",
|
|
108
|
+
"handle_json_output",
|
|
109
|
+
"handle_rich_output",
|
|
110
|
+
"output_list",
|
|
111
|
+
"handle_resource_export",
|
|
112
|
+
"build_renderer",
|
|
113
|
+
"display_agent_run_suggestions",
|
|
114
|
+
"markup_text",
|
|
115
|
+
"maybe_launch_post_run_viewer",
|
|
116
|
+
"store_transcript_for_session",
|
|
117
|
+
"fetch_raw_resource_details",
|
|
118
|
+
"is_uuid",
|
|
119
|
+
]
|