glaip-sdk 0.0.1b5__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 +12 -0
- glaip_sdk/cli/__init__.py +9 -0
- glaip_sdk/cli/commands/__init__.py +5 -0
- glaip_sdk/cli/commands/agents.py +415 -0
- glaip_sdk/cli/commands/configure.py +316 -0
- glaip_sdk/cli/commands/init.py +168 -0
- glaip_sdk/cli/commands/mcps.py +473 -0
- glaip_sdk/cli/commands/models.py +52 -0
- glaip_sdk/cli/commands/tools.py +309 -0
- glaip_sdk/cli/config.py +592 -0
- glaip_sdk/cli/main.py +298 -0
- glaip_sdk/cli/utils.py +733 -0
- glaip_sdk/client/__init__.py +179 -0
- glaip_sdk/client/agents.py +441 -0
- glaip_sdk/client/base.py +223 -0
- glaip_sdk/client/mcps.py +94 -0
- glaip_sdk/client/tools.py +193 -0
- glaip_sdk/client/validators.py +166 -0
- glaip_sdk/config/constants.py +28 -0
- glaip_sdk/exceptions.py +93 -0
- glaip_sdk/models.py +190 -0
- glaip_sdk/utils/__init__.py +95 -0
- glaip_sdk/utils/run_renderer.py +1009 -0
- glaip_sdk/utils.py +167 -0
- glaip_sdk-0.0.1b5.dist-info/METADATA +633 -0
- glaip_sdk-0.0.1b5.dist-info/RECORD +28 -0
- glaip_sdk-0.0.1b5.dist-info/WHEEL +4 -0
- glaip_sdk-0.0.1b5.dist-info/entry_points.txt +2 -0
glaip_sdk/cli/main.py
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"""Main CLI entry point for AIP SDK.
|
|
2
|
+
|
|
3
|
+
Authors:
|
|
4
|
+
Raymond Christopher (raymond.christopher@gdplabs.id)
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
import click
|
|
10
|
+
|
|
11
|
+
from glaip_sdk.cli.commands.agents import agents_group
|
|
12
|
+
from glaip_sdk.cli.commands.configure import config_group, configure_command
|
|
13
|
+
from glaip_sdk.cli.commands.init import init_command
|
|
14
|
+
from glaip_sdk.cli.commands.mcps import mcps_group
|
|
15
|
+
from glaip_sdk.cli.commands.models import models_group
|
|
16
|
+
from glaip_sdk.cli.commands.tools import tools_group
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@click.group()
|
|
20
|
+
@click.version_option(version="0.1.0", prog_name="aip")
|
|
21
|
+
@click.option("--api-url", envvar="AIP_API_URL", help="AIP API URL")
|
|
22
|
+
@click.option("--api-key", envvar="AIP_API_KEY", help="AIP API Key")
|
|
23
|
+
@click.option("--timeout", default=30.0, help="Request timeout in seconds")
|
|
24
|
+
@click.option(
|
|
25
|
+
"--view",
|
|
26
|
+
"view",
|
|
27
|
+
type=click.Choice(["rich", "plain", "json", "md"]),
|
|
28
|
+
default="rich",
|
|
29
|
+
help="Output view format",
|
|
30
|
+
)
|
|
31
|
+
@click.option("--no-tty", is_flag=True, help="Disable TTY renderer")
|
|
32
|
+
@click.pass_context
|
|
33
|
+
def main(ctx, api_url, api_key, timeout, view, no_tty):
|
|
34
|
+
"""AIP SDK Command Line Interface.
|
|
35
|
+
|
|
36
|
+
A comprehensive CLI for managing AI Agent Platform resources including
|
|
37
|
+
agents, tools, MCPs, and more.
|
|
38
|
+
|
|
39
|
+
Examples:
|
|
40
|
+
aip configure # Configure credentials
|
|
41
|
+
aip agents list # List all agents
|
|
42
|
+
aip tools create my_tool.py # Create a new tool
|
|
43
|
+
aip agents run my-agent "Hello" # Run an agent
|
|
44
|
+
aip init # Initialize configuration
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
# Store configuration in context
|
|
48
|
+
ctx.ensure_object(dict)
|
|
49
|
+
ctx.obj["api_url"] = api_url
|
|
50
|
+
ctx.obj["api_key"] = api_key
|
|
51
|
+
ctx.obj["timeout"] = timeout
|
|
52
|
+
ctx.obj["view"] = view
|
|
53
|
+
|
|
54
|
+
ctx.obj["tty"] = not no_tty
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Add command groups
|
|
58
|
+
main.add_command(agents_group)
|
|
59
|
+
main.add_command(config_group)
|
|
60
|
+
main.add_command(tools_group)
|
|
61
|
+
main.add_command(mcps_group)
|
|
62
|
+
main.add_command(models_group)
|
|
63
|
+
main.add_command(init_command)
|
|
64
|
+
|
|
65
|
+
# Add top-level commands
|
|
66
|
+
main.add_command(configure_command)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# Tip: `--version` is provided by click.version_option above.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@main.command()
|
|
73
|
+
@click.pass_context
|
|
74
|
+
def status(ctx):
|
|
75
|
+
"""Show connection status and basic info."""
|
|
76
|
+
config = {}
|
|
77
|
+
try:
|
|
78
|
+
from rich.console import Console
|
|
79
|
+
from rich.panel import Panel
|
|
80
|
+
from rich.table import Table
|
|
81
|
+
|
|
82
|
+
from glaip_sdk import Client
|
|
83
|
+
from glaip_sdk.cli.commands.configure import load_config
|
|
84
|
+
|
|
85
|
+
console = Console()
|
|
86
|
+
|
|
87
|
+
# Load config from file and merge with context
|
|
88
|
+
file_config = load_config()
|
|
89
|
+
context_config = ctx.obj or {}
|
|
90
|
+
|
|
91
|
+
# Load environment variables (middle priority)
|
|
92
|
+
import os
|
|
93
|
+
|
|
94
|
+
env_config = {}
|
|
95
|
+
if os.getenv("AIP_API_URL"):
|
|
96
|
+
env_config["api_url"] = os.getenv("AIP_API_URL")
|
|
97
|
+
if os.getenv("AIP_API_KEY"):
|
|
98
|
+
env_config["api_key"] = os.getenv("AIP_API_KEY")
|
|
99
|
+
|
|
100
|
+
# Filter out None values from context config to avoid overriding other configs
|
|
101
|
+
filtered_context = {k: v for k, v in context_config.items() if v is not None}
|
|
102
|
+
|
|
103
|
+
# Merge configs: file (low) -> env (mid) -> CLI args (high)
|
|
104
|
+
config = {**file_config, **env_config, **filtered_context}
|
|
105
|
+
|
|
106
|
+
if not config.get("api_url") or not config.get("api_key"):
|
|
107
|
+
console.print(
|
|
108
|
+
Panel(
|
|
109
|
+
"[bold red]❌ Configuration incomplete[/bold red]\n\n"
|
|
110
|
+
f"🔍 Current config:\n"
|
|
111
|
+
f" • API URL: {config.get('api_url', 'Not set')}\n"
|
|
112
|
+
f" • API Key: {'***' + config.get('api_key', '')[-4:] if config.get('api_key') else 'Not set'}\n\n"
|
|
113
|
+
f"💡 To fix this:\n"
|
|
114
|
+
f" • Run 'aip configure' to set up credentials\n"
|
|
115
|
+
f" • Or run 'aip config list' to see current config",
|
|
116
|
+
title="❌ Configuration Error",
|
|
117
|
+
border_style="red",
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
sys.exit(1)
|
|
121
|
+
|
|
122
|
+
# Try to create client
|
|
123
|
+
client = Client(
|
|
124
|
+
api_url=config["api_url"],
|
|
125
|
+
api_key=config["api_key"],
|
|
126
|
+
timeout=config.get("timeout", 30.0),
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# Test connection by listing resources
|
|
130
|
+
try:
|
|
131
|
+
agents = client.list_agents()
|
|
132
|
+
tools = client.list_tools()
|
|
133
|
+
mcps = client.list_mcps()
|
|
134
|
+
|
|
135
|
+
# Create status table
|
|
136
|
+
table = Table(title="🔗 AIP Platform Status")
|
|
137
|
+
table.add_column("Resource", style="cyan", width=15)
|
|
138
|
+
table.add_column("Count", style="green", width=10)
|
|
139
|
+
table.add_column("Status", style="green", width=15)
|
|
140
|
+
|
|
141
|
+
table.add_row("Agents", str(len(agents)), "✅ Available")
|
|
142
|
+
table.add_row("Tools", str(len(tools)), "✅ Available")
|
|
143
|
+
table.add_row("MCPs", str(len(mcps)), "✅ Available")
|
|
144
|
+
|
|
145
|
+
console.print(
|
|
146
|
+
Panel(
|
|
147
|
+
f"[bold green]✅ Connected to AIP Platform[/bold green]\n"
|
|
148
|
+
f"🔗 API URL: {client.api_url}\n"
|
|
149
|
+
f"⏱️ Timeout: {config.get('timeout', 30.0)}s",
|
|
150
|
+
title="🚀 Connection Status",
|
|
151
|
+
border_style="green",
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
console.print(table)
|
|
156
|
+
|
|
157
|
+
except Exception as e:
|
|
158
|
+
console.print(
|
|
159
|
+
Panel(
|
|
160
|
+
f"[bold yellow]⚠️ Connection established but API call failed[/bold yellow]\n"
|
|
161
|
+
f"🔗 API URL: {client.api_url}\n"
|
|
162
|
+
f"❌ Error: {e}\n\n"
|
|
163
|
+
f"💡 This usually means:\n"
|
|
164
|
+
f" • Network connectivity issues\n"
|
|
165
|
+
f" • API permissions problems\n"
|
|
166
|
+
f" • Backend service issues",
|
|
167
|
+
title="⚠️ Partial Connection",
|
|
168
|
+
border_style="yellow",
|
|
169
|
+
)
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
client.close()
|
|
173
|
+
|
|
174
|
+
except Exception as e:
|
|
175
|
+
console.print(
|
|
176
|
+
Panel(
|
|
177
|
+
f"[bold red]❌ Connection failed[/bold red]\n\n"
|
|
178
|
+
f"🔍 Error: {e}\n\n"
|
|
179
|
+
f"💡 Troubleshooting steps:\n"
|
|
180
|
+
f" • Run 'aip config list' to check configuration\n"
|
|
181
|
+
f" • Run 'aip configure' to update credentials\n"
|
|
182
|
+
f" • Verify your API URL and key are correct\n"
|
|
183
|
+
f" • Check network connectivity to {config.get('api_url', 'your API')}",
|
|
184
|
+
title="❌ Connection Error",
|
|
185
|
+
border_style="red",
|
|
186
|
+
)
|
|
187
|
+
)
|
|
188
|
+
sys.exit(1)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@main.command()
|
|
192
|
+
def version():
|
|
193
|
+
"""Show version information."""
|
|
194
|
+
from glaip_sdk.config.constants import SDK_VERSION
|
|
195
|
+
|
|
196
|
+
click.echo(f"aip version {SDK_VERSION}")
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
@main.command()
|
|
200
|
+
@click.option(
|
|
201
|
+
"--check-only", is_flag=True, help="Only check for updates without installing"
|
|
202
|
+
)
|
|
203
|
+
@click.option(
|
|
204
|
+
"--force", is_flag=True, help="Force update even if no new version available"
|
|
205
|
+
)
|
|
206
|
+
def update(check_only: bool, force: bool):
|
|
207
|
+
"""Update AIP SDK to the latest version from PyPI."""
|
|
208
|
+
try:
|
|
209
|
+
import subprocess
|
|
210
|
+
import sys
|
|
211
|
+
|
|
212
|
+
from rich.console import Console
|
|
213
|
+
from rich.panel import Panel
|
|
214
|
+
|
|
215
|
+
console = Console()
|
|
216
|
+
|
|
217
|
+
if check_only:
|
|
218
|
+
console.print(
|
|
219
|
+
Panel(
|
|
220
|
+
"[bold blue]🔍 Checking for updates...[/bold blue]\n\n"
|
|
221
|
+
"💡 To install updates, run: aip update",
|
|
222
|
+
title="📋 Update Check",
|
|
223
|
+
border_style="blue",
|
|
224
|
+
)
|
|
225
|
+
)
|
|
226
|
+
return
|
|
227
|
+
|
|
228
|
+
console.print(
|
|
229
|
+
Panel(
|
|
230
|
+
"[bold blue]🔄 Updating AIP SDK...[/bold blue]\n\n"
|
|
231
|
+
"📦 This will update the package from PyPI\n"
|
|
232
|
+
"💡 Use --check-only to just check for updates",
|
|
233
|
+
title="🚀 Update Process",
|
|
234
|
+
border_style="blue",
|
|
235
|
+
padding=(0, 1),
|
|
236
|
+
)
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
# Update using pip
|
|
240
|
+
try:
|
|
241
|
+
subprocess.run(
|
|
242
|
+
[sys.executable, "-m", "pip", "install", "--upgrade", "glaip-sdk"],
|
|
243
|
+
capture_output=True,
|
|
244
|
+
text=True,
|
|
245
|
+
check=True,
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
console.print(
|
|
249
|
+
Panel(
|
|
250
|
+
"[bold green]✅ Update successful![/bold green]\n\n"
|
|
251
|
+
"🔄 AIP SDK has been updated to the latest version\n"
|
|
252
|
+
"💡 Restart your terminal or run 'aip --version' to verify",
|
|
253
|
+
title="🎉 Update Complete",
|
|
254
|
+
border_style="green",
|
|
255
|
+
padding=(0, 1),
|
|
256
|
+
)
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
# Show new version
|
|
260
|
+
version_result = subprocess.run(
|
|
261
|
+
[sys.executable, "-m", "glaip_sdk.cli.main", "--version"],
|
|
262
|
+
capture_output=True,
|
|
263
|
+
text=True,
|
|
264
|
+
check=True,
|
|
265
|
+
)
|
|
266
|
+
console.print(f"📋 New version: {version_result.stdout.strip()}")
|
|
267
|
+
|
|
268
|
+
except subprocess.CalledProcessError as e:
|
|
269
|
+
console.print(
|
|
270
|
+
Panel(
|
|
271
|
+
f"[bold red]❌ Update failed[/bold red]\n\n"
|
|
272
|
+
f"🔍 Error: {e.stderr}\n\n"
|
|
273
|
+
"💡 Troubleshooting:\n"
|
|
274
|
+
" • Check your internet connection\n"
|
|
275
|
+
" • Try running: pip install --upgrade glaip-sdk\n"
|
|
276
|
+
" • Check if you have write permissions",
|
|
277
|
+
title="❌ Update Error",
|
|
278
|
+
border_style="red",
|
|
279
|
+
padding=(0, 1),
|
|
280
|
+
)
|
|
281
|
+
)
|
|
282
|
+
sys.exit(1)
|
|
283
|
+
|
|
284
|
+
except ImportError:
|
|
285
|
+
console.print(
|
|
286
|
+
Panel(
|
|
287
|
+
"[bold red]❌ Rich library not available[/bold red]\n\n"
|
|
288
|
+
"💡 Install rich: pip install rich\n"
|
|
289
|
+
" Then try: aip update",
|
|
290
|
+
title="❌ Missing Dependency",
|
|
291
|
+
border_style="red",
|
|
292
|
+
)
|
|
293
|
+
)
|
|
294
|
+
sys.exit(1)
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
if __name__ == "__main__":
|
|
298
|
+
main()
|