glaip-sdk 0.0.5b1__py3-none-any.whl → 0.0.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 +1 -1
- glaip_sdk/_version.py +42 -19
- glaip_sdk/branding.py +3 -2
- glaip_sdk/cli/commands/__init__.py +1 -1
- glaip_sdk/cli/commands/agents.py +452 -285
- glaip_sdk/cli/commands/configure.py +14 -13
- glaip_sdk/cli/commands/mcps.py +30 -20
- glaip_sdk/cli/commands/models.py +5 -3
- glaip_sdk/cli/commands/tools.py +111 -106
- glaip_sdk/cli/display.py +48 -27
- glaip_sdk/cli/io.py +1 -1
- glaip_sdk/cli/main.py +26 -5
- glaip_sdk/cli/resolution.py +5 -4
- glaip_sdk/cli/utils.py +437 -188
- glaip_sdk/cli/validators.py +7 -2
- glaip_sdk/client/agents.py +276 -153
- glaip_sdk/client/base.py +69 -27
- glaip_sdk/client/tools.py +44 -26
- glaip_sdk/client/validators.py +154 -94
- glaip_sdk/config/constants.py +0 -2
- glaip_sdk/models.py +5 -4
- glaip_sdk/utils/__init__.py +7 -7
- glaip_sdk/utils/client_utils.py +191 -101
- glaip_sdk/utils/display.py +4 -2
- glaip_sdk/utils/general.py +8 -6
- glaip_sdk/utils/import_export.py +58 -25
- glaip_sdk/utils/rendering/formatting.py +12 -6
- glaip_sdk/utils/rendering/models.py +1 -1
- glaip_sdk/utils/rendering/renderer/base.py +523 -332
- glaip_sdk/utils/rendering/renderer/console.py +6 -5
- glaip_sdk/utils/rendering/renderer/debug.py +94 -52
- glaip_sdk/utils/rendering/renderer/stream.py +93 -48
- glaip_sdk/utils/rendering/steps.py +103 -39
- glaip_sdk/utils/rich_utils.py +1 -1
- glaip_sdk/utils/run_renderer.py +1 -1
- glaip_sdk/utils/serialization.py +9 -3
- glaip_sdk/utils/validation.py +2 -2
- glaip_sdk-0.0.7.dist-info/METADATA +183 -0
- glaip_sdk-0.0.7.dist-info/RECORD +55 -0
- glaip_sdk-0.0.5b1.dist-info/METADATA +0 -645
- glaip_sdk-0.0.5b1.dist-info/RECORD +0 -55
- {glaip_sdk-0.0.5b1.dist-info → glaip_sdk-0.0.7.dist-info}/WHEEL +0 -0
- {glaip_sdk-0.0.5b1.dist-info → glaip_sdk-0.0.7.dist-info}/entry_points.txt +0 -0
glaip_sdk/cli/display.py
CHANGED
|
@@ -21,7 +21,7 @@ console = Console()
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def display_creation_success(
|
|
24
|
-
resource_type: str, resource_name: str, resource_id: str, **additional_fields
|
|
24
|
+
resource_type: str, resource_name: str, resource_id: str, **additional_fields: Any
|
|
25
25
|
) -> Panel:
|
|
26
26
|
"""Create standardized success message for resource creation.
|
|
27
27
|
|
|
@@ -134,17 +134,18 @@ _MISSING = object()
|
|
|
134
134
|
def build_resource_result_data(resource: Any, fields: list[str]) -> dict[str, Any]:
|
|
135
135
|
"""Return a normalized mapping of ``fields`` extracted from ``resource``."""
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
result: dict[str, Any] = {}
|
|
138
|
+
for field in fields:
|
|
139
|
+
try:
|
|
140
|
+
value = getattr(resource, field)
|
|
141
|
+
except AttributeError:
|
|
142
|
+
value = _MISSING
|
|
143
|
+
except Exception:
|
|
144
|
+
value = _MISSING
|
|
141
145
|
|
|
146
|
+
result[field] = _normalise_field_value(field, value)
|
|
142
147
|
|
|
143
|
-
|
|
144
|
-
try:
|
|
145
|
-
return getattr(resource, field, _MISSING)
|
|
146
|
-
except Exception:
|
|
147
|
-
return _MISSING
|
|
148
|
+
return result
|
|
148
149
|
|
|
149
150
|
|
|
150
151
|
def _normalise_field_value(field: str, value: Any) -> Any:
|
|
@@ -157,9 +158,38 @@ def _normalise_field_value(field: str, value: Any) -> Any:
|
|
|
157
158
|
return value
|
|
158
159
|
|
|
159
160
|
|
|
160
|
-
def
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
def _get_context_object(ctx: Any) -> dict[str, Any]:
|
|
162
|
+
"""Get context object safely."""
|
|
163
|
+
ctx_obj = getattr(ctx, "obj", {}) if ctx is not None else {}
|
|
164
|
+
return ctx_obj if isinstance(ctx_obj, dict) else {}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _should_output_json(ctx_obj: dict[str, Any]) -> bool:
|
|
168
|
+
"""Check if output should be in JSON format."""
|
|
169
|
+
return ctx_obj.get("view") == "json"
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def _build_error_output_data(error: Exception) -> dict[str, Any]:
|
|
173
|
+
"""Build error output data with additional error details."""
|
|
174
|
+
output_data = {"error": str(error)}
|
|
175
|
+
|
|
176
|
+
# Add additional error details if available
|
|
177
|
+
if hasattr(error, "status_code"):
|
|
178
|
+
output_data["status_code"] = error.status_code
|
|
179
|
+
if hasattr(error, "error_type"):
|
|
180
|
+
output_data["error_type"] = error.error_type
|
|
181
|
+
if hasattr(error, "payload"):
|
|
182
|
+
output_data["details"] = error.payload
|
|
183
|
+
|
|
184
|
+
return output_data
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _build_success_output_data(data: Any) -> dict[str, Any]:
|
|
188
|
+
"""Build success output data."""
|
|
189
|
+
return data if data is not None else {"success": True}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def handle_json_output(ctx: Any, data: Any = None, error: Exception = None) -> None:
|
|
163
193
|
"""Handle JSON output format for CLI commands.
|
|
164
194
|
|
|
165
195
|
Args:
|
|
@@ -167,27 +197,18 @@ def handle_json_output(
|
|
|
167
197
|
data: Data to output (for successful operations)
|
|
168
198
|
error: Error to output (for failed operations)
|
|
169
199
|
"""
|
|
170
|
-
ctx_obj =
|
|
171
|
-
if not isinstance(ctx_obj, dict):
|
|
172
|
-
ctx_obj = {}
|
|
200
|
+
ctx_obj = _get_context_object(ctx)
|
|
173
201
|
|
|
174
|
-
if ctx_obj
|
|
202
|
+
if _should_output_json(ctx_obj):
|
|
175
203
|
if error:
|
|
176
|
-
output_data =
|
|
177
|
-
# Add additional error details if available
|
|
178
|
-
if hasattr(error, "status_code"):
|
|
179
|
-
output_data["status_code"] = error.status_code
|
|
180
|
-
if hasattr(error, "error_type"):
|
|
181
|
-
output_data["error_type"] = error.error_type
|
|
182
|
-
if hasattr(error, "payload"):
|
|
183
|
-
output_data["details"] = error.payload
|
|
204
|
+
output_data = _build_error_output_data(error)
|
|
184
205
|
else:
|
|
185
|
-
output_data = data
|
|
206
|
+
output_data = _build_success_output_data(data)
|
|
186
207
|
|
|
187
208
|
click.echo(json.dumps(output_data, indent=2, default=str))
|
|
188
209
|
|
|
189
210
|
|
|
190
|
-
def handle_rich_output(ctx, rich_content: Any = None) -> None:
|
|
211
|
+
def handle_rich_output(ctx: Any, rich_content: Any = None) -> None:
|
|
191
212
|
"""Handle Rich output format for CLI commands.
|
|
192
213
|
|
|
193
214
|
Args:
|
glaip_sdk/cli/io.py
CHANGED
|
@@ -65,7 +65,7 @@ def export_resource_to_file_with_validation(
|
|
|
65
65
|
raise click.ClickException(f"Failed to export resource: {e}")
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
def fetch_raw_resource_details(client, resource, resource_type: str):
|
|
68
|
+
def fetch_raw_resource_details(client: Any, resource: Any, resource_type: str) -> Any:
|
|
69
69
|
"""Fetch raw resource details directly from API to preserve ALL fields.
|
|
70
70
|
|
|
71
71
|
Args:
|
glaip_sdk/cli/main.py
CHANGED
|
@@ -7,6 +7,7 @@ Authors:
|
|
|
7
7
|
import os
|
|
8
8
|
import subprocess
|
|
9
9
|
import sys
|
|
10
|
+
from typing import Any
|
|
10
11
|
|
|
11
12
|
import click
|
|
12
13
|
from rich.console import Console
|
|
@@ -41,7 +42,14 @@ from glaip_sdk.rich_components import AIPPanel, AIPTable
|
|
|
41
42
|
)
|
|
42
43
|
@click.option("--no-tty", is_flag=True, help="Disable TTY renderer")
|
|
43
44
|
@click.pass_context
|
|
44
|
-
def main(
|
|
45
|
+
def main(
|
|
46
|
+
ctx: Any,
|
|
47
|
+
api_url: str | None,
|
|
48
|
+
api_key: str | None,
|
|
49
|
+
timeout: float | None,
|
|
50
|
+
view: str | None,
|
|
51
|
+
no_tty: bool,
|
|
52
|
+
) -> None:
|
|
45
53
|
"""GL AIP SDK Command Line Interface.
|
|
46
54
|
|
|
47
55
|
A comprehensive CLI for managing GL AIP resources including
|
|
@@ -81,7 +89,7 @@ main.add_command(configure_command)
|
|
|
81
89
|
|
|
82
90
|
@main.command()
|
|
83
91
|
@click.pass_context
|
|
84
|
-
def status(ctx):
|
|
92
|
+
def status(ctx: Any) -> None:
|
|
85
93
|
"""Show connection status and basic info."""
|
|
86
94
|
config = {}
|
|
87
95
|
try:
|
|
@@ -91,7 +99,12 @@ def status(ctx):
|
|
|
91
99
|
branding = AIPBranding.create_from_sdk(
|
|
92
100
|
sdk_version=_SDK_VERSION, package_name="glaip-sdk"
|
|
93
101
|
)
|
|
94
|
-
branding.
|
|
102
|
+
branding.display_welcome_panel(title="🚀 AIP Status")
|
|
103
|
+
|
|
104
|
+
# Show AIP Ready status
|
|
105
|
+
console.print(
|
|
106
|
+
f"\n[bold green]✅ AIP - Ready[/bold green] (SDK v{_SDK_VERSION})"
|
|
107
|
+
)
|
|
95
108
|
|
|
96
109
|
# Load config from file and merge with context
|
|
97
110
|
file_config = load_config()
|
|
@@ -125,6 +138,9 @@ def status(ctx):
|
|
|
125
138
|
border_style="red",
|
|
126
139
|
)
|
|
127
140
|
)
|
|
141
|
+
console.print(
|
|
142
|
+
f"\n[bold green]✅ AIP - Ready[/bold green] (SDK v{_SDK_VERSION}) - Configure to connect"
|
|
143
|
+
)
|
|
128
144
|
sys.exit(1)
|
|
129
145
|
|
|
130
146
|
# Try to create client
|
|
@@ -163,6 +179,11 @@ def status(ctx):
|
|
|
163
179
|
console.print(table)
|
|
164
180
|
|
|
165
181
|
except Exception as e:
|
|
182
|
+
# Show AIP Ready status even if connection fails
|
|
183
|
+
console.print(
|
|
184
|
+
f"\n[bold green]✅ AIP - Ready[/bold green] (SDK v{_SDK_VERSION})"
|
|
185
|
+
)
|
|
186
|
+
|
|
166
187
|
console.print(
|
|
167
188
|
AIPPanel(
|
|
168
189
|
f"[bold yellow]⚠️ Connection established but API call failed[/bold yellow]\n"
|
|
@@ -197,7 +218,7 @@ def status(ctx):
|
|
|
197
218
|
|
|
198
219
|
|
|
199
220
|
@main.command()
|
|
200
|
-
def version():
|
|
221
|
+
def version() -> None:
|
|
201
222
|
"""Show version information."""
|
|
202
223
|
branding = AIPBranding.create_from_sdk(
|
|
203
224
|
sdk_version=_SDK_VERSION, package_name="glaip-sdk"
|
|
@@ -214,7 +235,7 @@ def version():
|
|
|
214
235
|
is_flag=True,
|
|
215
236
|
help="Force reinstall even if already up-to-date (adds --force-reinstall)",
|
|
216
237
|
)
|
|
217
|
-
def update(check_only: bool, force: bool):
|
|
238
|
+
def update(check_only: bool, force: bool) -> None:
|
|
218
239
|
"""Update AIP SDK to the latest version from PyPI."""
|
|
219
240
|
try:
|
|
220
241
|
console = Console()
|
glaip_sdk/cli/resolution.py
CHANGED
|
@@ -8,6 +8,7 @@ Authors:
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
from collections.abc import Callable
|
|
11
|
+
from typing import Any
|
|
11
12
|
|
|
12
13
|
import click
|
|
13
14
|
|
|
@@ -15,16 +16,16 @@ from glaip_sdk.cli.utils import resolve_resource
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
def resolve_resource_reference(
|
|
18
|
-
ctx,
|
|
19
|
-
_client,
|
|
19
|
+
ctx: Any,
|
|
20
|
+
_client: Any,
|
|
20
21
|
reference: str,
|
|
21
22
|
resource_type: str,
|
|
22
23
|
get_by_id_func: Callable,
|
|
23
24
|
find_by_name_func: Callable,
|
|
24
25
|
label: str,
|
|
25
|
-
select: int = None,
|
|
26
|
+
select: int | None = None,
|
|
26
27
|
interface_preference: str | None = None,
|
|
27
|
-
):
|
|
28
|
+
) -> Any | None:
|
|
28
29
|
"""Resolve resource reference (ID or name) with ambiguity handling.
|
|
29
30
|
|
|
30
31
|
This is a common pattern used across all resource types.
|