glaip-sdk 0.0.2__py3-none-any.whl → 0.0.4__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.
Files changed (40) hide show
  1. glaip_sdk/__init__.py +2 -2
  2. glaip_sdk/_version.py +51 -0
  3. glaip_sdk/branding.py +145 -0
  4. glaip_sdk/cli/commands/agents.py +876 -166
  5. glaip_sdk/cli/commands/configure.py +46 -104
  6. glaip_sdk/cli/commands/init.py +43 -118
  7. glaip_sdk/cli/commands/mcps.py +86 -161
  8. glaip_sdk/cli/commands/tools.py +196 -57
  9. glaip_sdk/cli/main.py +43 -29
  10. glaip_sdk/cli/utils.py +258 -27
  11. glaip_sdk/client/__init__.py +54 -2
  12. glaip_sdk/client/agents.py +196 -237
  13. glaip_sdk/client/base.py +62 -2
  14. glaip_sdk/client/mcps.py +63 -20
  15. glaip_sdk/client/tools.py +236 -81
  16. glaip_sdk/config/constants.py +10 -3
  17. glaip_sdk/exceptions.py +13 -0
  18. glaip_sdk/models.py +21 -5
  19. glaip_sdk/utils/__init__.py +116 -18
  20. glaip_sdk/utils/client_utils.py +284 -0
  21. glaip_sdk/utils/rendering/__init__.py +1 -0
  22. glaip_sdk/utils/rendering/formatting.py +211 -0
  23. glaip_sdk/utils/rendering/models.py +53 -0
  24. glaip_sdk/utils/rendering/renderer/__init__.py +38 -0
  25. glaip_sdk/utils/rendering/renderer/base.py +827 -0
  26. glaip_sdk/utils/rendering/renderer/config.py +33 -0
  27. glaip_sdk/utils/rendering/renderer/console.py +54 -0
  28. glaip_sdk/utils/rendering/renderer/debug.py +82 -0
  29. glaip_sdk/utils/rendering/renderer/panels.py +123 -0
  30. glaip_sdk/utils/rendering/renderer/progress.py +118 -0
  31. glaip_sdk/utils/rendering/renderer/stream.py +198 -0
  32. glaip_sdk/utils/rendering/steps.py +168 -0
  33. glaip_sdk/utils/run_renderer.py +22 -1086
  34. {glaip_sdk-0.0.2.dist-info → glaip_sdk-0.0.4.dist-info}/METADATA +8 -36
  35. glaip_sdk-0.0.4.dist-info/RECORD +41 -0
  36. glaip_sdk/cli/config.py +0 -592
  37. glaip_sdk/utils.py +0 -167
  38. glaip_sdk-0.0.2.dist-info/RECORD +0 -28
  39. {glaip_sdk-0.0.2.dist-info → glaip_sdk-0.0.4.dist-info}/WHEEL +0 -0
  40. {glaip_sdk-0.0.2.dist-info → glaip_sdk-0.0.4.dist-info}/entry_points.txt +0 -0
@@ -11,8 +11,12 @@ from pathlib import Path
11
11
  import click
12
12
  import yaml
13
13
  from rich.console import Console
14
- from rich.panel import Panel
15
14
  from rich.table import Table
15
+ from rich.text import Text
16
+
17
+ from glaip_sdk import Client
18
+ from glaip_sdk._version import __version__ as _SDK_VERSION
19
+ from glaip_sdk.branding import AIPBranding
16
20
 
17
21
  console = Console()
18
22
 
@@ -25,8 +29,11 @@ def load_config():
25
29
  if not CONFIG_FILE.exists():
26
30
  return {}
27
31
 
28
- with open(CONFIG_FILE) as f:
29
- return yaml.safe_load(f) or {}
32
+ try:
33
+ with open(CONFIG_FILE) as f:
34
+ return yaml.safe_load(f) or {}
35
+ except yaml.YAMLError:
36
+ return {}
30
37
 
31
38
 
32
39
  def save_config(config):
@@ -49,82 +56,6 @@ def config_group():
49
56
  pass
50
57
 
51
58
 
52
- @config_group.command()
53
- def configure():
54
- """Configure AIP CLI credentials and settings interactively."""
55
-
56
- console.print(
57
- Panel(
58
- "[bold cyan]AIP Configuration[/bold cyan]\nConfigure your AIP CLI settings.",
59
- title="🔧 Configuration Setup",
60
- border_style="cyan",
61
- )
62
- )
63
-
64
- # Load existing config
65
- config = load_config()
66
-
67
- console.print("\n[bold]Enter your AIP configuration:[/bold]")
68
- console.print("(Leave blank to keep current values)")
69
- console.print("─" * 50)
70
-
71
- # API URL
72
- current_url = config.get("api_url", "")
73
- console.print(
74
- f"\n[cyan]AIP API URL[/cyan] {f'(current: {current_url})' if current_url else ''}:"
75
- )
76
- new_url = input("> ").strip()
77
- if new_url:
78
- config["api_url"] = new_url
79
- elif not current_url:
80
- config["api_url"] = "https://your-aip-instance.com"
81
-
82
- # API Key
83
- current_key_masked = (
84
- "***" + config.get("api_key", "")[-4:] if config.get("api_key") else ""
85
- )
86
- console.print(
87
- f"\n[cyan]AIP API Key[/cyan] {f'(current: {current_key_masked})' if current_key_masked else ''}:"
88
- )
89
- new_key = getpass.getpass("> ")
90
- if new_key:
91
- config["api_key"] = new_key
92
-
93
- # Save configuration
94
- save_config(config)
95
-
96
- console.print(f"\n✅ Configuration saved to: {CONFIG_FILE}")
97
-
98
- # Test the new configuration
99
- console.print("\n🔌 Testing connection...")
100
- try:
101
- from glaip_sdk import Client
102
-
103
- # Create client with new config
104
- client = Client(api_url=config["api_url"], api_key=config["api_key"])
105
-
106
- # Try to list resources to test connection
107
- try:
108
- agents = client.list_agents()
109
- console.print(f"✅ Connection successful! Found {len(agents)} agents")
110
- except Exception as e:
111
- console.print(f"⚠️ Connection established but API call failed: {e}")
112
- console.print(
113
- " You may need to check your API permissions or network access"
114
- )
115
-
116
- client.close()
117
-
118
- except Exception as e:
119
- console.print(f"❌ Connection failed: {e}")
120
- console.print(" Please check your API URL and key")
121
- console.print(" You can run 'aip status' later to test again")
122
-
123
- console.print("\n💡 You can now use AIP CLI commands!")
124
- console.print(" • Run 'aip status' to check connection")
125
- console.print(" • Run 'aip agents list' to see your agents")
126
-
127
-
128
59
  @config_group.command("list")
129
60
  def list_config():
130
61
  """List current configuration."""
@@ -150,7 +81,7 @@ def list_config():
150
81
  table.add_row(key, str(value))
151
82
 
152
83
  console.print(table)
153
- console.print(f"\n📁 Config file: {CONFIG_FILE}")
84
+ console.print(Text(f"\n📁 Config file: {CONFIG_FILE}"))
154
85
 
155
86
 
156
87
  @config_group.command("set")
@@ -173,9 +104,9 @@ def set_config(key, value):
173
104
 
174
105
  if key == "api_key":
175
106
  masked_value = "***" + value[-4:] if len(value) > 4 else "***"
176
- console.print(f"✅ Set {key} = {masked_value}")
107
+ console.print(Text(f"✅ Set {key} = {masked_value}"))
177
108
  else:
178
- console.print(f"✅ Set {key} = {value}")
109
+ console.print(Text(f"✅ Set {key} = {value}"))
179
110
 
180
111
 
181
112
  @config_group.command("get")
@@ -186,7 +117,7 @@ def get_config(key):
186
117
  config = load_config()
187
118
 
188
119
  if key not in config:
189
- console.print(f"[yellow]Configuration key '{key}' not found.[/yellow]")
120
+ console.print(Text(f"[yellow]Configuration key '{key}' not found.[/yellow]"))
190
121
  raise click.ClickException(f"Configuration key not found: {key}")
191
122
 
192
123
  value = config[key]
@@ -207,13 +138,13 @@ def unset_config(key):
207
138
  config = load_config()
208
139
 
209
140
  if key not in config:
210
- console.print(f"[yellow]Configuration key '{key}' not found.[/yellow]")
141
+ console.print(Text(f"[yellow]Configuration key '{key}' not found.[/yellow]"))
211
142
  return
212
143
 
213
144
  del config[key]
214
145
  save_config(config)
215
146
 
216
- console.print(f"✅ Removed {key} from configuration")
147
+ console.print(Text(f"✅ Removed {key} from configuration"))
217
148
 
218
149
 
219
150
  @config_group.command("reset")
@@ -237,20 +168,13 @@ def reset_config(force):
237
168
  console.print("[yellow]No configuration found to reset.[/yellow]")
238
169
 
239
170
 
240
- # Note: The config command group should be registered in main.py
241
-
242
-
243
- @click.command()
244
- def configure_command():
245
- """Configure AIP CLI credentials and settings interactively."""
246
-
247
- console.print(
248
- Panel(
249
- "[bold cyan]AIP Configuration[/bold cyan]\nConfigure your AIP CLI settings.",
250
- title="🔧 Configuration Setup",
251
- border_style="cyan",
252
- )
171
+ def _configure_interactive():
172
+ """Shared configuration logic for both configure commands."""
173
+ # Display AIP welcome banner
174
+ branding = AIPBranding.create_from_sdk(
175
+ sdk_version=_SDK_VERSION, package_name="glaip-sdk"
253
176
  )
177
+ branding.display_welcome_panel(title="🔧 AIP Configuration")
254
178
 
255
179
  # Load existing config
256
180
  config = load_config()
@@ -284,22 +208,20 @@ def configure_command():
284
208
  # Save configuration
285
209
  save_config(config)
286
210
 
287
- console.print(f"\n✅ Configuration saved to: {CONFIG_FILE}")
211
+ console.print(Text(f"\n✅ Configuration saved to: {CONFIG_FILE}"))
288
212
 
289
213
  # Test the new configuration
290
214
  console.print("\n🔌 Testing connection...")
291
215
  try:
292
- from glaip_sdk import Client
293
-
294
216
  # Create client with new config
295
217
  client = Client(api_url=config["api_url"], api_key=config["api_key"])
296
218
 
297
219
  # Try to list resources to test connection
298
220
  try:
299
221
  agents = client.list_agents()
300
- console.print(f"✅ Connection successful! Found {len(agents)} agents")
222
+ console.print(Text(f"✅ Connection successful! Found {len(agents)} agents"))
301
223
  except Exception as e:
302
- console.print(f"⚠️ Connection established but API call failed: {e}")
224
+ console.print(Text(f"⚠️ Connection established but API call failed: {e}"))
303
225
  console.print(
304
226
  " You may need to check your API permissions or network access"
305
227
  )
@@ -307,10 +229,30 @@ def configure_command():
307
229
  client.close()
308
230
 
309
231
  except Exception as e:
310
- console.print(f"❌ Connection failed: {e}")
232
+ console.print(Text(f"❌ Connection failed: {e}"))
311
233
  console.print(" Please check your API URL and key")
312
234
  console.print(" You can run 'aip status' later to test again")
313
235
 
314
236
  console.print("\n💡 You can now use AIP CLI commands!")
315
237
  console.print(" • Run 'aip status' to check connection")
316
238
  console.print(" • Run 'aip agents list' to see your agents")
239
+
240
+
241
+ @config_group.command()
242
+ def configure():
243
+ """Configure AIP CLI credentials and settings interactively."""
244
+ _configure_interactive()
245
+
246
+
247
+ # Alias command for backward compatibility
248
+ @click.command()
249
+ def configure_command():
250
+ """Configure AIP CLI credentials and settings interactively.
251
+
252
+ This is an alias for 'aip config configure' for backward compatibility.
253
+ """
254
+ # Delegate to the shared function
255
+ _configure_interactive()
256
+
257
+
258
+ # Note: The config command group should be registered in main.py
@@ -11,30 +11,28 @@ from pathlib import Path
11
11
  import click
12
12
  import yaml
13
13
  from rich.console import Console
14
- from rich.panel import Panel
14
+ from rich.text import Text
15
+
16
+ from glaip_sdk import Client
17
+ from glaip_sdk._version import __version__ as _SDK_VERSION
18
+ from glaip_sdk.branding import AIPBranding
15
19
 
16
20
  console = Console()
17
21
 
18
22
 
19
23
  @click.command()
20
- @click.option("--no-scaffold", is_flag=True, help="Skip creating sample agent and tool")
21
- @click.option("--no-demo", is_flag=True, help="Don't launch interactive demo")
22
- def init_command(no_scaffold, no_demo):
24
+ def init_command():
23
25
  """Initialize AIP project configuration."""
24
-
25
- console.print(
26
- Panel(
27
- "[bold cyan]Welcome to AIP![/bold cyan]\nLet's set up your project.",
28
- title="🚀 AIP Initialization",
29
- border_style="cyan",
30
- )
26
+ # Display AIP welcome banner
27
+ branding = AIPBranding.create_from_sdk(
28
+ sdk_version=_SDK_VERSION, package_name="glaip-sdk"
31
29
  )
30
+ branding.display_welcome_panel(title="🚀 AIP Initialization")
32
31
 
33
- # Get configuration with better formatting
34
- console.print("\n[bold]Step 1:[/bold] API Configuration")
32
+ # Get configuration
33
+ console.print("\n[bold]API Configuration[/bold]")
35
34
  console.print("─" * 50)
36
35
 
37
- # Use built-in input for better control
38
36
  console.print(
39
37
  "\n[cyan]AIP API URL[/cyan] (default: https://your-aip-instance.com):"
40
38
  )
@@ -42,127 +40,54 @@ def init_command(no_scaffold, no_demo):
42
40
  if not api_url:
43
41
  api_url = "https://your-aip-instance.com"
44
42
 
45
- console.print() # Add spacing
46
- console.print("[cyan]AIP API Key[/cyan]:")
43
+ console.print("\n[cyan]AIP API Key[/cyan]:")
47
44
  api_key = getpass.getpass("> ")
48
45
 
49
- # Project configuration removed - not needed for AIP CLI
50
-
51
46
  # Create config directory
52
47
  config_dir = Path.home() / ".aip"
53
- config_dir.mkdir(exist_ok=True)
48
+ try:
49
+ config_dir.mkdir(exist_ok=True)
50
+ except Exception as e:
51
+ console.print(Text(f"⚠️ Warning: Could not create config directory: {e}"))
52
+ return
54
53
 
55
54
  # Save configuration
56
55
  config = {"api_url": api_url, "api_key": api_key}
57
-
58
56
  config_file = config_dir / "config.yaml"
59
- with open(config_file, "w") as f:
60
- yaml.dump(config, f, default_flow_style=False)
57
+ try:
58
+ with open(config_file, "w") as f:
59
+ yaml.dump(config, f, default_flow_style=False)
60
+ except Exception as e:
61
+ console.print(Text(f"⚠️ Warning: Could not save configuration: {e}"))
62
+ return
61
63
 
62
64
  # Set secure file permissions (0600) - best effort on all platforms
63
65
  try:
64
66
  os.chmod(config_file, 0o600)
65
67
  except Exception:
66
- # Best effort - may fail on Windows or other non-POSIX systems
67
- pass
68
-
69
- console.print(f"\n✅ Configuration saved to: {config_file}")
70
-
71
- # Create sample agent and tool if requested
72
- if not no_scaffold:
73
- console.print("\n[bold]Step 2:[/bold] Sample Resources")
74
- console.print("─" * 50)
75
-
76
- console.print("\n[cyan]Create sample agent & tool?[/cyan] (Y/n):")
77
- create_sample_resources = input("> ").strip().lower()
78
- if create_sample_resources in ["", "y", "yes"]:
79
- try:
80
- from glaip_sdk import Client
81
-
82
- # Set environment variables
83
- os.environ["AIP_API_URL"] = api_url
84
- os.environ["AIP_API_KEY"] = api_key
85
-
86
- client = Client()
87
-
88
- # Create sample agent
89
- agent = client.create_agent(
90
- name="hello-world",
91
- instruction="You are a helpful AI assistant that says hello",
92
- )
93
- console.print(f"✅ Created sample agent: {agent.name} (id: {agent.id})")
94
-
95
- # Create sample tool
96
- tool_content = '''def hello_tool(name="World"):
97
- """A simple hello tool."""
98
- return f"Hello, {name}!"
99
- '''
100
- with open("greeting_tool.py", "w") as f:
101
- f.write(tool_content)
102
-
103
- tool = client.create_tool("greeting_tool.py", framework="langchain")
104
- console.print(f"✅ Created sample tool: {tool.name} (id: {tool.id})")
105
-
106
- except Exception as e:
107
- console.print(f"⚠️ Warning: Could not create sample resources: {e}")
108
-
109
- # Launch interactive demo if requested
110
- if not no_demo:
111
- console.print("\n[bold]Step 3:[/bold] Interactive Demo")
112
- console.print("─" * 50)
113
-
114
- console.print("\n[cyan]Start an interactive demo now?[/cyan] (Y/n):")
115
- launch_demo = input("> ").strip().lower()
116
- if launch_demo in ["", "y", "yes"]:
117
- launch_interactive_demo()
118
-
119
- console.print("\n🎉 [bold green]AIP initialization complete![/bold green]")
120
- console.print(f"📁 Configuration: {config_file}")
121
- console.print("💡 Next steps:")
122
- console.print(" • Run 'aip agents list' to see your agents")
123
- console.print(" • Run 'aip tools list' to see your tools")
124
- console.print(" • Run 'aip status' to check connection")
68
+ pass # Ignore permission errors
125
69
 
70
+ console.print(Text(f"\n✅ Configuration saved to: {config_file}"))
126
71
 
127
- def launch_interactive_demo():
128
- """Launch interactive demo with sample agent."""
72
+ # Test the new configuration
73
+ console.print("\n🔌 Testing connection...")
129
74
  try:
130
- from glaip_sdk import Client
131
-
132
- console.print(
133
- Panel(
134
- "[bold green]Interactive Demo[/bold green]\nType to talk to hello-world. Ctrl+C to exit.",
135
- title="🎮 Demo Mode",
136
- border_style="green",
137
- )
138
- )
75
+ # Set environment variables
76
+ os.environ["AIP_API_URL"] = api_url
77
+ os.environ["AIP_API_KEY"] = api_key
139
78
 
140
79
  client = Client()
141
- agents = client.find_agents(name="hello-world")
142
- if not agents:
143
- console.print("❌ Sample agent not found")
144
- return
145
-
146
- agent = agents[0] # Use the first (and should be only) agent
147
-
148
- while True:
149
- try:
150
- console.print("\n> ", end="")
151
- user_input = input().strip()
152
- if user_input.lower() in ["exit", "quit", "bye"]:
153
- break
154
-
155
- response = agent.run(user_input)
156
- console.print(f"🤖 {response}")
157
-
158
- except KeyboardInterrupt:
159
- break
160
- except Exception as e:
161
- console.print(f"❌ Error: {e}")
162
-
80
+ agents = client.list_agents()
81
+ console.print(Text(f"✅ Connection successful! Found {len(agents)} agents"))
163
82
  except Exception as e:
164
- console.print(f"⚠️ Could not launch demo: {e}")
165
-
83
+ console.print(Text(f"⚠️ Connection established but API call failed: {e}"))
84
+ console.print(
85
+ Text(" You may need to check your API permissions or network access")
86
+ )
166
87
 
167
- # Note: The init command should be registered in main.py, not here
168
- # This prevents circular imports
88
+ console.print("\n🎉 [bold green]AIP initialization complete![/bold green]")
89
+ console.print(f"📁 Configuration: {config_file}")
90
+ console.print("💡 Next steps:")
91
+ console.print(" • Run 'aip agents list' to see your agents")
92
+ console.print(" • Run 'aip tools list' to see your tools")
93
+ console.print(" • Run 'aip status' to check connection")