glaip-sdk 0.1.3__py3-none-any.whl → 0.6.19__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 +44 -4
- glaip_sdk/_version.py +9 -0
- glaip_sdk/agents/__init__.py +27 -0
- glaip_sdk/agents/base.py +1196 -0
- glaip_sdk/branding.py +13 -0
- glaip_sdk/cli/account_store.py +540 -0
- glaip_sdk/cli/auth.py +254 -15
- glaip_sdk/cli/commands/__init__.py +2 -2
- glaip_sdk/cli/commands/accounts.py +746 -0
- glaip_sdk/cli/commands/agents.py +213 -73
- glaip_sdk/cli/commands/common_config.py +104 -0
- glaip_sdk/cli/commands/configure.py +729 -113
- glaip_sdk/cli/commands/mcps.py +241 -72
- glaip_sdk/cli/commands/models.py +11 -5
- glaip_sdk/cli/commands/tools.py +49 -57
- glaip_sdk/cli/commands/transcripts.py +755 -0
- glaip_sdk/cli/config.py +48 -4
- glaip_sdk/cli/constants.py +38 -0
- glaip_sdk/cli/context.py +8 -0
- glaip_sdk/cli/core/__init__.py +79 -0
- glaip_sdk/cli/core/context.py +124 -0
- glaip_sdk/cli/core/output.py +851 -0
- glaip_sdk/cli/core/prompting.py +649 -0
- glaip_sdk/cli/core/rendering.py +187 -0
- glaip_sdk/cli/display.py +35 -19
- glaip_sdk/cli/hints.py +57 -0
- glaip_sdk/cli/io.py +6 -3
- glaip_sdk/cli/main.py +241 -121
- glaip_sdk/cli/masking.py +21 -33
- glaip_sdk/cli/pager.py +9 -10
- glaip_sdk/cli/parsers/__init__.py +1 -3
- glaip_sdk/cli/slash/__init__.py +0 -9
- glaip_sdk/cli/slash/accounts_controller.py +578 -0
- glaip_sdk/cli/slash/accounts_shared.py +75 -0
- glaip_sdk/cli/slash/agent_session.py +62 -21
- glaip_sdk/cli/slash/prompt.py +21 -0
- glaip_sdk/cli/slash/remote_runs_controller.py +566 -0
- glaip_sdk/cli/slash/session.py +771 -140
- glaip_sdk/cli/slash/tui/__init__.py +9 -0
- glaip_sdk/cli/slash/tui/accounts.tcss +86 -0
- glaip_sdk/cli/slash/tui/accounts_app.py +876 -0
- glaip_sdk/cli/slash/tui/background_tasks.py +72 -0
- glaip_sdk/cli/slash/tui/loading.py +58 -0
- glaip_sdk/cli/slash/tui/remote_runs_app.py +628 -0
- glaip_sdk/cli/transcript/__init__.py +12 -52
- glaip_sdk/cli/transcript/cache.py +255 -44
- glaip_sdk/cli/transcript/capture.py +27 -1
- glaip_sdk/cli/transcript/history.py +815 -0
- glaip_sdk/cli/transcript/viewer.py +72 -499
- glaip_sdk/cli/update_notifier.py +14 -5
- glaip_sdk/cli/utils.py +243 -1252
- glaip_sdk/cli/validators.py +5 -6
- glaip_sdk/client/__init__.py +2 -1
- glaip_sdk/client/_agent_payloads.py +45 -9
- glaip_sdk/client/agent_runs.py +147 -0
- glaip_sdk/client/agents.py +291 -35
- glaip_sdk/client/base.py +1 -0
- glaip_sdk/client/main.py +19 -10
- glaip_sdk/client/mcps.py +122 -12
- glaip_sdk/client/run_rendering.py +466 -89
- glaip_sdk/client/shared.py +21 -0
- glaip_sdk/client/tools.py +155 -10
- glaip_sdk/config/constants.py +11 -0
- glaip_sdk/hitl/__init__.py +15 -0
- glaip_sdk/hitl/local.py +151 -0
- glaip_sdk/mcps/__init__.py +21 -0
- glaip_sdk/mcps/base.py +345 -0
- glaip_sdk/models/__init__.py +90 -0
- glaip_sdk/models/agent.py +47 -0
- glaip_sdk/models/agent_runs.py +116 -0
- glaip_sdk/models/common.py +42 -0
- glaip_sdk/models/mcp.py +33 -0
- glaip_sdk/models/tool.py +33 -0
- glaip_sdk/payload_schemas/__init__.py +1 -13
- glaip_sdk/registry/__init__.py +55 -0
- glaip_sdk/registry/agent.py +164 -0
- glaip_sdk/registry/base.py +139 -0
- glaip_sdk/registry/mcp.py +253 -0
- glaip_sdk/registry/tool.py +232 -0
- glaip_sdk/rich_components.py +58 -2
- glaip_sdk/runner/__init__.py +59 -0
- glaip_sdk/runner/base.py +84 -0
- glaip_sdk/runner/deps.py +112 -0
- glaip_sdk/runner/langgraph.py +870 -0
- glaip_sdk/runner/mcp_adapter/__init__.py +13 -0
- glaip_sdk/runner/mcp_adapter/base_mcp_adapter.py +43 -0
- glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +257 -0
- glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +95 -0
- glaip_sdk/runner/tool_adapter/__init__.py +18 -0
- glaip_sdk/runner/tool_adapter/base_tool_adapter.py +44 -0
- glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +219 -0
- glaip_sdk/tools/__init__.py +22 -0
- glaip_sdk/tools/base.py +435 -0
- glaip_sdk/utils/__init__.py +58 -12
- glaip_sdk/utils/a2a/__init__.py +34 -0
- glaip_sdk/utils/a2a/event_processor.py +188 -0
- glaip_sdk/utils/bundler.py +267 -0
- glaip_sdk/utils/client.py +111 -0
- glaip_sdk/utils/client_utils.py +39 -7
- glaip_sdk/utils/datetime_helpers.py +58 -0
- glaip_sdk/utils/discovery.py +78 -0
- glaip_sdk/utils/display.py +23 -15
- glaip_sdk/utils/export.py +143 -0
- glaip_sdk/utils/general.py +0 -33
- glaip_sdk/utils/import_export.py +12 -7
- glaip_sdk/utils/import_resolver.py +492 -0
- glaip_sdk/utils/instructions.py +101 -0
- glaip_sdk/utils/rendering/__init__.py +115 -1
- glaip_sdk/utils/rendering/formatting.py +5 -30
- glaip_sdk/utils/rendering/layout/__init__.py +64 -0
- glaip_sdk/utils/rendering/{renderer → layout}/panels.py +9 -0
- glaip_sdk/utils/rendering/{renderer → layout}/progress.py +70 -1
- glaip_sdk/utils/rendering/layout/summary.py +74 -0
- glaip_sdk/utils/rendering/layout/transcript.py +606 -0
- glaip_sdk/utils/rendering/models.py +1 -0
- glaip_sdk/utils/rendering/renderer/__init__.py +9 -47
- glaip_sdk/utils/rendering/renderer/base.py +275 -1476
- glaip_sdk/utils/rendering/renderer/debug.py +26 -20
- glaip_sdk/utils/rendering/renderer/factory.py +138 -0
- glaip_sdk/utils/rendering/renderer/stream.py +4 -12
- glaip_sdk/utils/rendering/renderer/thinking.py +273 -0
- glaip_sdk/utils/rendering/renderer/tool_panels.py +442 -0
- glaip_sdk/utils/rendering/renderer/transcript_mode.py +162 -0
- glaip_sdk/utils/rendering/state.py +204 -0
- glaip_sdk/utils/rendering/steps/__init__.py +34 -0
- glaip_sdk/utils/rendering/{steps.py → steps/event_processor.py} +53 -440
- glaip_sdk/utils/rendering/steps/format.py +176 -0
- glaip_sdk/utils/rendering/steps/manager.py +387 -0
- glaip_sdk/utils/rendering/timing.py +36 -0
- glaip_sdk/utils/rendering/viewer/__init__.py +21 -0
- glaip_sdk/utils/rendering/viewer/presenter.py +184 -0
- glaip_sdk/utils/resource_refs.py +25 -13
- glaip_sdk/utils/runtime_config.py +425 -0
- glaip_sdk/utils/serialization.py +18 -0
- glaip_sdk/utils/sync.py +142 -0
- glaip_sdk/utils/tool_detection.py +33 -0
- glaip_sdk/utils/tool_storage_provider.py +140 -0
- glaip_sdk/utils/validation.py +16 -24
- {glaip_sdk-0.1.3.dist-info → glaip_sdk-0.6.19.dist-info}/METADATA +56 -21
- glaip_sdk-0.6.19.dist-info/RECORD +163 -0
- {glaip_sdk-0.1.3.dist-info → glaip_sdk-0.6.19.dist-info}/WHEEL +2 -1
- glaip_sdk-0.6.19.dist-info/entry_points.txt +2 -0
- glaip_sdk-0.6.19.dist-info/top_level.txt +1 -0
- glaip_sdk/models.py +0 -240
- glaip_sdk-0.1.3.dist-info/RECORD +0 -83
- glaip_sdk-0.1.3.dist-info/entry_points.txt +0 -3
glaip_sdk/cli/config.py
CHANGED
|
@@ -5,21 +5,65 @@ Authors:
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
|
+
from copy import deepcopy
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
from typing import Any
|
|
10
11
|
|
|
11
12
|
import yaml
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
_ENV_CONFIG_DIR = os.getenv("AIP_CONFIG_DIR")
|
|
15
|
+
# Detect pytest environment: check for pytest markers or test session
|
|
16
|
+
# This provides automatic test isolation even if conftest.py doesn't set AIP_CONFIG_DIR
|
|
17
|
+
# Note: conftest.py sets AIP_CONFIG_DIR before imports, which takes precedence
|
|
18
|
+
_TEST_ENV = os.getenv("PYTEST_CURRENT_TEST") or os.getenv("PYTEST_XDIST_WORKER") or os.getenv("_PYTEST_RAISE")
|
|
19
|
+
|
|
20
|
+
if _ENV_CONFIG_DIR:
|
|
21
|
+
# Explicit override via environment variable (highest priority)
|
|
22
|
+
# This is set by conftest.py before imports, ensuring test isolation
|
|
23
|
+
CONFIG_DIR = Path(_ENV_CONFIG_DIR)
|
|
24
|
+
elif _TEST_ENV:
|
|
25
|
+
# Isolate test runs (including xdist workers) from the real user config directory
|
|
26
|
+
# Use a per-process unique temp directory to avoid conflicts in parallel test runs
|
|
27
|
+
import tempfile
|
|
28
|
+
import uuid
|
|
29
|
+
|
|
30
|
+
# Create a unique temp dir per test process to avoid conflicts
|
|
31
|
+
temp_base = Path(tempfile.gettempdir())
|
|
32
|
+
test_config_dir = temp_base / f"aip-test-config-{os.getpid()}-{uuid.uuid4().hex[:8]}"
|
|
33
|
+
CONFIG_DIR = test_config_dir
|
|
34
|
+
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
35
|
+
else: # pragma: no cover - default path used outside test runs
|
|
36
|
+
CONFIG_DIR = Path.home() / ".aip"
|
|
37
|
+
|
|
14
38
|
CONFIG_FILE = CONFIG_DIR / "config.yaml"
|
|
15
|
-
_ALLOWED_KEYS = {
|
|
39
|
+
_ALLOWED_KEYS = {
|
|
40
|
+
"api_url",
|
|
41
|
+
"api_key",
|
|
42
|
+
"timeout",
|
|
43
|
+
"history_default_limit",
|
|
44
|
+
}
|
|
45
|
+
# Keys that must be preserved for multi-account support
|
|
46
|
+
_PRESERVE_KEYS = {
|
|
47
|
+
"version",
|
|
48
|
+
"active_account",
|
|
49
|
+
"accounts",
|
|
50
|
+
}
|
|
16
51
|
|
|
17
52
|
|
|
18
53
|
def _sanitize_config(data: dict[str, Any] | None) -> dict[str, Any]:
|
|
19
|
-
"""Return config filtered to allowed keys only."""
|
|
54
|
+
"""Return config filtered to allowed keys only, preserving multi-account keys."""
|
|
20
55
|
if not data:
|
|
21
56
|
return {}
|
|
22
|
-
|
|
57
|
+
result: dict[str, Any] = {}
|
|
58
|
+
# Preserve multi-account structure (defensively copy to avoid callers mutating source)
|
|
59
|
+
for key in _PRESERVE_KEYS:
|
|
60
|
+
if key in data:
|
|
61
|
+
result[key] = deepcopy(data[key])
|
|
62
|
+
# Add allowed legacy keys (copied to avoid side effects)
|
|
63
|
+
for key in _ALLOWED_KEYS:
|
|
64
|
+
if key in data:
|
|
65
|
+
result[key] = deepcopy(data[key])
|
|
66
|
+
return result
|
|
23
67
|
|
|
24
68
|
|
|
25
69
|
def load_config() -> dict[str, Any]:
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""CLI-specific constants for glaip-sdk.
|
|
2
|
+
|
|
3
|
+
Authors:
|
|
4
|
+
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
# Minimum length that forces multiline YAML strings to be rendered using the literal
|
|
8
|
+
# block style. This prevents long prompts and instructions from being inlined.
|
|
9
|
+
LITERAL_STRING_THRESHOLD = 200
|
|
10
|
+
|
|
11
|
+
# Masking configuration
|
|
12
|
+
MASKING_ENABLED = True
|
|
13
|
+
MASK_SENSITIVE_FIELDS = {
|
|
14
|
+
"api_key",
|
|
15
|
+
"apikey",
|
|
16
|
+
"token",
|
|
17
|
+
"access_token",
|
|
18
|
+
"secret",
|
|
19
|
+
"client_secret",
|
|
20
|
+
"password",
|
|
21
|
+
"private_key",
|
|
22
|
+
"bearer",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Table + pager behaviour
|
|
26
|
+
TABLE_SORT_ENABLED = True
|
|
27
|
+
PAGER_MODE = "auto" # valid values: "auto", "on", "off"
|
|
28
|
+
PAGER_WRAP_LINES = False
|
|
29
|
+
PAGER_HEADER_ENABLED = True
|
|
30
|
+
|
|
31
|
+
# Update notification toggle
|
|
32
|
+
UPDATE_CHECK_ENABLED = True
|
|
33
|
+
|
|
34
|
+
# Agent instruction preview defaults
|
|
35
|
+
DEFAULT_AGENT_INSTRUCTION_PREVIEW_LIMIT = 800
|
|
36
|
+
|
|
37
|
+
# Remote runs defaults
|
|
38
|
+
DEFAULT_REMOTE_RUNS_PAGE_LIMIT = 20
|
glaip_sdk/cli/context.py
CHANGED
|
@@ -106,6 +106,14 @@ def output_flags() -> Callable[[Callable[..., Any]], Callable[..., Any]]:
|
|
|
106
106
|
"""
|
|
107
107
|
|
|
108
108
|
def decorator(f: Callable[..., Any]) -> Callable[..., Any]:
|
|
109
|
+
"""Apply output flags to a click command.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
f: Click command function to decorate.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
Decorated command function.
|
|
116
|
+
"""
|
|
109
117
|
f = click.option(
|
|
110
118
|
"--json",
|
|
111
119
|
"json_mode",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""CLI core modules for glaip-sdk.
|
|
2
|
+
|
|
3
|
+
This package contains focused modules extracted from the monolithic cli/utils.py:
|
|
4
|
+
- context: Click context helpers, config loading, credential resolution
|
|
5
|
+
- prompting: prompt_toolkit + questionary wrappers, validators
|
|
6
|
+
- rendering: Rich console helpers, viewer launchers, renderer builders
|
|
7
|
+
- output: Table/console output utilities, list rendering
|
|
8
|
+
|
|
9
|
+
Authors:
|
|
10
|
+
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
11
|
+
Putu Ravindra Wiguna (putu.r.wiguna@gdplabs.id)
|
|
12
|
+
""" # pylint: disable=duplicate-code
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# Re-export all public APIs from submodules for convenience
|
|
17
|
+
from glaip_sdk.cli.core.context import (
|
|
18
|
+
bind_slash_session_context,
|
|
19
|
+
get_client,
|
|
20
|
+
handle_best_effort_check,
|
|
21
|
+
restore_slash_session_context,
|
|
22
|
+
)
|
|
23
|
+
from glaip_sdk.cli.core.output import (
|
|
24
|
+
coerce_to_row,
|
|
25
|
+
detect_export_format,
|
|
26
|
+
fetch_resource_for_export,
|
|
27
|
+
format_datetime_fields,
|
|
28
|
+
format_size,
|
|
29
|
+
handle_resource_export,
|
|
30
|
+
output_list,
|
|
31
|
+
output_result,
|
|
32
|
+
parse_json_line,
|
|
33
|
+
resolve_resource,
|
|
34
|
+
handle_ambiguous_resource,
|
|
35
|
+
sdk_version,
|
|
36
|
+
)
|
|
37
|
+
from glaip_sdk.cli.core.prompting import (
|
|
38
|
+
_fuzzy_pick_for_resources,
|
|
39
|
+
prompt_export_choice_questionary,
|
|
40
|
+
questionary_safe_ask,
|
|
41
|
+
)
|
|
42
|
+
from glaip_sdk.cli.core.rendering import (
|
|
43
|
+
build_renderer,
|
|
44
|
+
spinner_context,
|
|
45
|
+
stop_spinner,
|
|
46
|
+
update_spinner,
|
|
47
|
+
with_client_and_spinner,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
__all__ = [
|
|
51
|
+
# Context
|
|
52
|
+
"bind_slash_session_context",
|
|
53
|
+
"get_client",
|
|
54
|
+
"handle_best_effort_check",
|
|
55
|
+
"restore_slash_session_context",
|
|
56
|
+
# Prompting
|
|
57
|
+
"_fuzzy_pick_for_resources",
|
|
58
|
+
"prompt_export_choice_questionary",
|
|
59
|
+
"questionary_safe_ask",
|
|
60
|
+
# Rendering
|
|
61
|
+
"build_renderer",
|
|
62
|
+
"spinner_context",
|
|
63
|
+
"stop_spinner",
|
|
64
|
+
"update_spinner",
|
|
65
|
+
"with_client_and_spinner",
|
|
66
|
+
# Output
|
|
67
|
+
"coerce_to_row",
|
|
68
|
+
"detect_export_format",
|
|
69
|
+
"fetch_resource_for_export",
|
|
70
|
+
"format_datetime_fields",
|
|
71
|
+
"format_size",
|
|
72
|
+
"handle_resource_export",
|
|
73
|
+
"output_list",
|
|
74
|
+
"output_result",
|
|
75
|
+
"parse_json_line",
|
|
76
|
+
"resolve_resource",
|
|
77
|
+
"handle_ambiguous_resource",
|
|
78
|
+
"sdk_version",
|
|
79
|
+
]
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""CLI context helpers, config loading, and credential resolution.
|
|
2
|
+
|
|
3
|
+
Authors:
|
|
4
|
+
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
5
|
+
Putu Ravindra Wiguna (putu.r.wiguna@gdplabs.id)
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import importlib
|
|
11
|
+
import os
|
|
12
|
+
from collections.abc import Mapping
|
|
13
|
+
from contextlib import contextmanager
|
|
14
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
15
|
+
|
|
16
|
+
import click
|
|
17
|
+
|
|
18
|
+
from glaip_sdk.cli.config import load_config
|
|
19
|
+
from glaip_sdk.cli.hints import command_hint
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING: # pragma: no cover - import-only during type checking
|
|
22
|
+
from glaip_sdk import Client
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@contextmanager
|
|
26
|
+
def bind_slash_session_context(ctx: Any, session: Any) -> Any:
|
|
27
|
+
"""Temporarily attach a slash session to the Click context.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
ctx: Click context object.
|
|
31
|
+
session: SlashSession instance to bind.
|
|
32
|
+
|
|
33
|
+
Yields:
|
|
34
|
+
None - context manager for use in with statement.
|
|
35
|
+
"""
|
|
36
|
+
ctx_obj = getattr(ctx, "obj", None)
|
|
37
|
+
has_context = isinstance(ctx_obj, dict)
|
|
38
|
+
previous_session = ctx_obj.get("_slash_session") if has_context else None
|
|
39
|
+
if has_context:
|
|
40
|
+
ctx_obj["_slash_session"] = session
|
|
41
|
+
try:
|
|
42
|
+
yield
|
|
43
|
+
finally:
|
|
44
|
+
if has_context:
|
|
45
|
+
if previous_session is None:
|
|
46
|
+
ctx_obj.pop("_slash_session", None)
|
|
47
|
+
else:
|
|
48
|
+
ctx_obj["_slash_session"] = previous_session
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def restore_slash_session_context(ctx_obj: dict[str, Any], previous_session: Any | None) -> None:
|
|
52
|
+
"""Restore slash session context after operation.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
ctx_obj: Click context obj dictionary.
|
|
56
|
+
previous_session: Previous session to restore, or None to remove.
|
|
57
|
+
"""
|
|
58
|
+
if previous_session is None:
|
|
59
|
+
ctx_obj.pop("_slash_session", None)
|
|
60
|
+
else:
|
|
61
|
+
ctx_obj["_slash_session"] = previous_session
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def handle_best_effort_check(
|
|
65
|
+
check_func: Any,
|
|
66
|
+
) -> None:
|
|
67
|
+
"""Handle best-effort duplicate/existence checks with proper exception handling.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
check_func: Function that performs the check and raises ClickException if duplicate found.
|
|
71
|
+
"""
|
|
72
|
+
try:
|
|
73
|
+
check_func()
|
|
74
|
+
except click.ClickException:
|
|
75
|
+
raise
|
|
76
|
+
except Exception:
|
|
77
|
+
# Non-fatal: best-effort duplicate check
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def get_client(ctx: Any) -> Client: # pragma: no cover
|
|
82
|
+
"""Get configured client from context and account store (ctx > account)."""
|
|
83
|
+
# Import here to avoid circular import
|
|
84
|
+
from glaip_sdk.cli.auth import resolve_credentials # noqa: PLC0415
|
|
85
|
+
|
|
86
|
+
module = importlib.import_module("glaip_sdk")
|
|
87
|
+
client_class = cast("type[Client]", module.Client)
|
|
88
|
+
context_config_obj = getattr(ctx, "obj", None)
|
|
89
|
+
context_config = context_config_obj if isinstance(context_config_obj, Mapping) else {}
|
|
90
|
+
|
|
91
|
+
account_name = context_config.get("account_name")
|
|
92
|
+
api_url, api_key, _ = resolve_credentials(
|
|
93
|
+
account_name=account_name,
|
|
94
|
+
api_url=context_config.get("api_url"),
|
|
95
|
+
api_key=context_config.get("api_key"),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if not api_url or not api_key:
|
|
99
|
+
configure_hint = command_hint("accounts add", slash_command="login", ctx=ctx)
|
|
100
|
+
actions: list[str] = []
|
|
101
|
+
if configure_hint:
|
|
102
|
+
actions.append(f"Run `{configure_hint}` to add an account profile")
|
|
103
|
+
else:
|
|
104
|
+
actions.append("add an account with 'aip accounts add'")
|
|
105
|
+
raise click.ClickException(f"Missing api_url/api_key. {' or '.join(actions)}.")
|
|
106
|
+
|
|
107
|
+
# Get timeout from context or config
|
|
108
|
+
timeout = context_config.get("timeout")
|
|
109
|
+
if timeout is None:
|
|
110
|
+
raw_timeout = os.getenv("AIP_TIMEOUT", "0") or "0"
|
|
111
|
+
try:
|
|
112
|
+
timeout = float(raw_timeout) if raw_timeout != "0" else None
|
|
113
|
+
except ValueError:
|
|
114
|
+
timeout = None
|
|
115
|
+
if timeout is None:
|
|
116
|
+
# Fallback to legacy config
|
|
117
|
+
file_config = load_config() or {}
|
|
118
|
+
timeout = file_config.get("timeout")
|
|
119
|
+
|
|
120
|
+
return client_class(
|
|
121
|
+
api_url=api_url,
|
|
122
|
+
api_key=api_key,
|
|
123
|
+
timeout=float(timeout or 30.0),
|
|
124
|
+
)
|