glaip-sdk 0.0.5b1__py3-none-any.whl → 0.0.6a0__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/branding.py +3 -2
- glaip_sdk/cli/commands/__init__.py +1 -1
- glaip_sdk/cli/commands/agents.py +444 -268
- glaip_sdk/cli/commands/configure.py +12 -11
- glaip_sdk/cli/commands/mcps.py +28 -16
- glaip_sdk/cli/commands/models.py +5 -3
- glaip_sdk/cli/commands/tools.py +109 -102
- glaip_sdk/cli/display.py +38 -16
- 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 +376 -157
- glaip_sdk/cli/validators.py +7 -2
- glaip_sdk/client/agents.py +184 -89
- glaip_sdk/client/base.py +24 -13
- glaip_sdk/client/validators.py +154 -94
- glaip_sdk/config/constants.py +0 -2
- glaip_sdk/models.py +4 -4
- glaip_sdk/utils/__init__.py +7 -7
- glaip_sdk/utils/client_utils.py +144 -78
- glaip_sdk/utils/display.py +4 -2
- glaip_sdk/utils/general.py +8 -6
- glaip_sdk/utils/import_export.py +55 -24
- glaip_sdk/utils/rendering/formatting.py +12 -6
- glaip_sdk/utils/rendering/models.py +1 -1
- glaip_sdk/utils/rendering/renderer/base.py +412 -248
- 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 +3 -1
- glaip_sdk/utils/validation.py +2 -2
- glaip_sdk-0.0.6a0.dist-info/METADATA +183 -0
- glaip_sdk-0.0.6a0.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.6a0.dist-info}/WHEEL +0 -0
- {glaip_sdk-0.0.5b1.dist-info → glaip_sdk-0.0.6a0.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
|
|
|
@@ -157,8 +157,39 @@ def _normalise_field_value(field: str, value: Any) -> Any:
|
|
|
157
157
|
return value
|
|
158
158
|
|
|
159
159
|
|
|
160
|
+
def _get_context_object(ctx: Any) -> dict[str, Any]:
|
|
161
|
+
"""Get context object safely."""
|
|
162
|
+
ctx_obj = getattr(ctx, "obj", {}) if ctx is not None else {}
|
|
163
|
+
return ctx_obj if isinstance(ctx_obj, dict) else {}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _should_output_json(ctx_obj: dict[str, Any]) -> bool:
|
|
167
|
+
"""Check if output should be in JSON format."""
|
|
168
|
+
return ctx_obj.get("view") == "json"
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _build_error_output_data(error: Exception) -> dict[str, Any]:
|
|
172
|
+
"""Build error output data with additional error details."""
|
|
173
|
+
output_data = {"error": str(error)}
|
|
174
|
+
|
|
175
|
+
# Add additional error details if available
|
|
176
|
+
if hasattr(error, "status_code"):
|
|
177
|
+
output_data["status_code"] = error.status_code
|
|
178
|
+
if hasattr(error, "error_type"):
|
|
179
|
+
output_data["error_type"] = error.error_type
|
|
180
|
+
if hasattr(error, "payload"):
|
|
181
|
+
output_data["details"] = error.payload
|
|
182
|
+
|
|
183
|
+
return output_data
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _build_success_output_data(data: Any) -> dict[str, Any]:
|
|
187
|
+
"""Build success output data."""
|
|
188
|
+
return data if data is not None else {"success": True}
|
|
189
|
+
|
|
190
|
+
|
|
160
191
|
def handle_json_output(
|
|
161
|
-
ctx, data: Any = None, error: Exception = None
|
|
192
|
+
ctx: Any, data: Any = None, error: Exception = None
|
|
162
193
|
) -> None: # pragma: no cover - formatting covered via integration tests
|
|
163
194
|
"""Handle JSON output format for CLI commands.
|
|
164
195
|
|
|
@@ -167,27 +198,18 @@ def handle_json_output(
|
|
|
167
198
|
data: Data to output (for successful operations)
|
|
168
199
|
error: Error to output (for failed operations)
|
|
169
200
|
"""
|
|
170
|
-
ctx_obj =
|
|
171
|
-
if not isinstance(ctx_obj, dict):
|
|
172
|
-
ctx_obj = {}
|
|
201
|
+
ctx_obj = _get_context_object(ctx)
|
|
173
202
|
|
|
174
|
-
if ctx_obj
|
|
203
|
+
if _should_output_json(ctx_obj):
|
|
175
204
|
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
|
|
205
|
+
output_data = _build_error_output_data(error)
|
|
184
206
|
else:
|
|
185
|
-
output_data = data
|
|
207
|
+
output_data = _build_success_output_data(data)
|
|
186
208
|
|
|
187
209
|
click.echo(json.dumps(output_data, indent=2, default=str))
|
|
188
210
|
|
|
189
211
|
|
|
190
|
-
def handle_rich_output(ctx, rich_content: Any = None) -> None:
|
|
212
|
+
def handle_rich_output(ctx: Any, rich_content: Any = None) -> None:
|
|
191
213
|
"""Handle Rich output format for CLI commands.
|
|
192
214
|
|
|
193
215
|
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.
|