reasoning-deployment-service 0.2.8__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.

Potentially problematic release.


This version of reasoning-deployment-service might be problematic. Click here for more details.

Files changed (29) hide show
  1. examples/programmatic_usage.py +154 -0
  2. reasoning_deployment_service/__init__.py +25 -0
  3. reasoning_deployment_service/cli_editor/__init__.py +5 -0
  4. reasoning_deployment_service/cli_editor/api_client.py +666 -0
  5. reasoning_deployment_service/cli_editor/cli_runner.py +343 -0
  6. reasoning_deployment_service/cli_editor/config.py +82 -0
  7. reasoning_deployment_service/cli_editor/google_deps.py +29 -0
  8. reasoning_deployment_service/cli_editor/reasoning_engine_creator.py +448 -0
  9. reasoning_deployment_service/gui_editor/__init__.py +5 -0
  10. reasoning_deployment_service/gui_editor/main.py +280 -0
  11. reasoning_deployment_service/gui_editor/requirements_minimal.txt +54 -0
  12. reasoning_deployment_service/gui_editor/run_program.sh +55 -0
  13. reasoning_deployment_service/gui_editor/src/__init__.py +1 -0
  14. reasoning_deployment_service/gui_editor/src/core/__init__.py +1 -0
  15. reasoning_deployment_service/gui_editor/src/core/api_client.py +647 -0
  16. reasoning_deployment_service/gui_editor/src/core/config.py +43 -0
  17. reasoning_deployment_service/gui_editor/src/core/google_deps.py +22 -0
  18. reasoning_deployment_service/gui_editor/src/core/reasoning_engine_creator.py +448 -0
  19. reasoning_deployment_service/gui_editor/src/ui/__init__.py +1 -0
  20. reasoning_deployment_service/gui_editor/src/ui/agent_space_view.py +312 -0
  21. reasoning_deployment_service/gui_editor/src/ui/authorization_view.py +280 -0
  22. reasoning_deployment_service/gui_editor/src/ui/reasoning_engine_view.py +354 -0
  23. reasoning_deployment_service/gui_editor/src/ui/reasoning_engines_view.py +204 -0
  24. reasoning_deployment_service/gui_editor/src/ui/ui_components.py +1221 -0
  25. reasoning_deployment_service/reasoning_deployment_service.py +687 -0
  26. reasoning_deployment_service-0.2.8.dist-info/METADATA +177 -0
  27. reasoning_deployment_service-0.2.8.dist-info/RECORD +29 -0
  28. reasoning_deployment_service-0.2.8.dist-info/WHEEL +5 -0
  29. reasoning_deployment_service-0.2.8.dist-info/top_level.txt +2 -0
@@ -0,0 +1,343 @@
1
+ import argparse, os
2
+
3
+ try:
4
+ from dotenv import load_dotenv
5
+ except ImportError:
6
+ load_dotenv = None
7
+
8
+ try:
9
+ from config import Config, loadenv
10
+ from api_client import ApiClient
11
+ except ImportError as e:
12
+ from .config import Config, loadenv
13
+ from .api_client import ApiClient
14
+
15
+
16
+ class CLIRunner:
17
+ def __init__(self):
18
+ """Initialize the CLI runner."""
19
+ print("šŸš€ Agent Space Deployment Service CLI")
20
+ print("=" * 50)
21
+
22
+ self.parser = argparse.ArgumentParser(description="CLI for interacting with Agent Space and Reasoning Engines")
23
+ self._setup_arguments()
24
+ self._show_available_commands()
25
+ self.last_engines_list = [] # Cache the last engine list for position-based deletion
26
+ self.last_agents_list = [] # Cache the last agents list for position-based deletion
27
+ self.last_auth_list = [] # Cache the last authorization list for position-based deletion
28
+
29
+ def _setup_arguments(self):
30
+ subparsers = self.parser.add_subparsers(dest="command")
31
+ # List reasoning engines
32
+ subparsers.add_parser("list-engines", help="List all reasoning engines in the project")
33
+ # Delete reasoning engine
34
+ delete_engine_parser = subparsers.add_parser("delete-engine", help="Delete a reasoning engine by list position")
35
+ delete_engine_parser.add_argument("position", help="Position number from the list (e.g., 1, 2, 3...)")
36
+
37
+ # Agent space commands
38
+ subparsers.add_parser("list-agents", help="List all agents in the agent space")
39
+ delete_agent_parser = subparsers.add_parser("delete-agent", help="Delete an agent from agent space by list position")
40
+ delete_agent_parser.add_argument("position", help="Position number from the list (e.g., 1, 2, 3...)")
41
+
42
+ # Authorization commands
43
+ subparsers.add_parser("list-authorizations", help="List all authorizations in the project")
44
+ delete_auth_parser = subparsers.add_parser("delete-authorization", help="Delete an authorization by list position")
45
+ delete_auth_parser.add_argument("position", help="Position number from the list (e.g., 1, 2, 3...)")
46
+
47
+ def run(self):
48
+ # Load environment variables from .env.agent file (same as GUI editor)
49
+ env_agent_path = ".env.agent"
50
+ if os.path.exists(env_agent_path):
51
+ try:
52
+ loadenv(env_agent_path)
53
+ print(f"āœ… Loaded environment from {env_agent_path}")
54
+ except Exception as e:
55
+ print(f"āš ļø Warning: Could not load {env_agent_path}: {e}")
56
+ else:
57
+ print(f"āš ļø No {env_agent_path} file found. Please create one with your environment variables.")
58
+
59
+ # Try DEV first, then PROD, then fallback to legacy variables
60
+ config_dev = Config("DEV")
61
+ config_prod = Config("PROD")
62
+
63
+ if config_dev.is_configured:
64
+ config = config_dev
65
+ print("āœ… Using DEV environment configuration")
66
+ elif config_prod.is_configured:
67
+ config = config_prod
68
+ print("āœ… Using PROD environment configuration")
69
+ else:
70
+ # Fallback to legacy environment variables
71
+ config = Config("DEV") # This will use legacy fallbacks
72
+ print("āš ļø Using legacy environment variables (consider upgrading to DEV_/PROD_ prefixed variables)")
73
+
74
+ if not config.is_configured:
75
+ print("\nāŒ Error: Required configuration values are missing.")
76
+ print("Please ensure your .env.agent file contains the required variables:")
77
+ print(" - DEV_PROJECT_ID or PROD_PROJECT_ID")
78
+ print(" - DEV_PROJECT_NUMBER or PROD_PROJECT_NUMBER")
79
+ print(" - DEV_PROJECT_LOCATION or PROD_PROJECT_LOCATION")
80
+ print(" - DEV_AGENT_SPACE_ENGINE or PROD_AGENT_SPACE_ENGINE")
81
+ return
82
+
83
+ self.api_client = ApiClient(
84
+ project_id=config.project_id,
85
+ project_number=config.project_number,
86
+ location=config.location,
87
+ engine_name=config.engine_name,
88
+ staging_bucket=config.staging_bucket,
89
+ oauth_client_id=config.oauth_client_id,
90
+ oauth_client_secret=config.oauth_client_secret,
91
+ agent_import=config.agent_import,
92
+ mode="live" # or "mock" for testing
93
+ )
94
+
95
+ while True:
96
+ try:
97
+ command = input("\nEnter a command (or 'exit' to quit): ").strip()
98
+ if command.lower() == "exit":
99
+ print("Exiting CLI. Goodbye!")
100
+ break
101
+
102
+ args = self.parser.parse_args(command.split())
103
+
104
+ if args.command == "list-engines":
105
+ self._list_engines()
106
+ elif args.command == "delete-engine":
107
+ self._delete_engine(args.position)
108
+ elif args.command == "list-agents":
109
+ self._list_agents()
110
+ elif args.command == "delete-agent":
111
+ self._delete_agent(args.position)
112
+ elif args.command == "list-authorizations":
113
+ self._list_authorizations()
114
+ elif args.command == "delete-authorization":
115
+ self._delete_authorization(args.position)
116
+ else:
117
+ self.parser.print_help()
118
+ except SystemExit:
119
+ # Catch argparse's SystemExit to prevent CLI from closing
120
+ print("Invalid command. Please try again.")
121
+ except Exception as e:
122
+ print(f"An error occurred: {e}")
123
+ print("\nAvailable commands:")
124
+ print(" list-engines List all reasoning engines in the project")
125
+ print(" delete-engine <pos> Delete a reasoning engine by list position")
126
+ print(" list-agents List all agents in the agent space")
127
+ print(" delete-agent <pos> Delete an agent from agent space by list position")
128
+ print(" list-authorizations List all authorizations in the project")
129
+ print(" delete-authorization <pos> Delete an authorization by list position")
130
+ print(" exit Quit the CLI")
131
+
132
+ def _show_available_commands(self):
133
+ """Show available commands."""
134
+ print("\nAvailable commands:")
135
+ print(" list-engines List all reasoning engines in the project")
136
+ print(" delete-engine <pos> Delete a reasoning engine by list position")
137
+ print(" list-agents List all agents in the agent space")
138
+ print(" delete-agent <pos> Delete an agent from agent space by list position")
139
+ print(" list-authorizations List all authorizations in the project")
140
+ print(" delete-authorization <pos> Delete an authorization by list position")
141
+ print(" exit Quit the CLI")
142
+
143
+ # Removed deploy/create operations
144
+
145
+ def _list_engines(self):
146
+ """List reasoning engines."""
147
+ print("šŸ“‹ Listing reasoning engines...")
148
+ try:
149
+ engines = self.api_client.list_reasoning_engines()
150
+ self.last_engines_list = engines # Cache for position-based deletion
151
+ if not engines:
152
+ print("No reasoning engines found.")
153
+ self._show_available_commands()
154
+ return
155
+ for idx, engine in enumerate(engines, start=1):
156
+ print(f"[{idx}] ID: {engine['id']}")
157
+ print(f" Display Name: {engine['display_name']}")
158
+ print(f" Resource Name: {engine['resource_name']}")
159
+ print(f" Create Time: {engine['create_time']}")
160
+ print(" ---")
161
+ self._show_available_commands()
162
+ except Exception as e:
163
+ error_msg = str(e)
164
+ if "api_mode" in error_msg or "Failed to register API methods" in error_msg:
165
+ print("āš ļø Vertex AI API registration warning suppressed.")
166
+ print("Continuing with engine listing...")
167
+ # Try to continue anyway - the error might not be fatal
168
+ print("No reasoning engines found or list unavailable due to API registration.")
169
+ else:
170
+ print(f"āŒ Error listing engines: {e}")
171
+ self._show_available_commands()
172
+
173
+ def _delete_engine(self, position):
174
+ """Delete a reasoning engine by list position."""
175
+ try:
176
+ pos = int(position)
177
+ except ValueError:
178
+ print(f"āŒ Invalid position: {position}. Please provide a number (e.g., 1, 2, 3...)")
179
+ return
180
+
181
+ if not self.last_engines_list:
182
+ print("āŒ No engines list available. Please run 'list-engines' first.")
183
+ return
184
+
185
+ if pos < 1 or pos > len(self.last_engines_list):
186
+ print(f"āŒ Invalid position: {pos}. Available positions: 1-{len(self.last_engines_list)}")
187
+ return
188
+
189
+ # Get the engine at the specified position (convert to 0-based index)
190
+ selected_engine = self.last_engines_list[pos - 1]
191
+
192
+ # Show confirmation prompt
193
+ print(f"\nšŸ—‘ļø About to delete engine:")
194
+ print(f" Position: [{pos}]")
195
+ print(f" ID: {selected_engine['id']}")
196
+ print(f" Display Name: {selected_engine['display_name']}")
197
+ print(f" Resource Name: {selected_engine['resource_name']}")
198
+
199
+ confirmation = input(f"\nAre you sure you want to delete this engine? (yes/no): ").strip().lower()
200
+
201
+ if confirmation not in ['yes', 'y']:
202
+ print("āŒ Deletion canceled.")
203
+ return
204
+
205
+ print(f"šŸ—‘ļø Deleting engine at position {pos}...")
206
+ try:
207
+ status, message = self.api_client.delete_reasoning_engine_by_id(selected_engine['resource_name'])
208
+ print(f"āœ… Status: {status}, Message: {message}")
209
+
210
+ # Remove from cached list
211
+ self.last_engines_list.pop(pos - 1)
212
+ print("šŸ’” Tip: Run 'list-engines' to see the updated list.")
213
+ except Exception as e:
214
+ print(f"āŒ Error deleting engine: {e}")
215
+
216
+ def _list_agents(self):
217
+ """List agent space agents."""
218
+ print("šŸ‘„ Listing agent space agents...")
219
+ try:
220
+ agents = self.api_client.list_agent_space_agents()
221
+ self.last_agents_list = agents # Cache for position-based deletion
222
+ if not agents:
223
+ print("No agents found in agent space.")
224
+ self._show_available_commands()
225
+ return
226
+ for idx, agent in enumerate(agents, start=1):
227
+ print(f"[{idx}] ID: {agent['id']}")
228
+ print(f" Display Name: {agent['display_name']}")
229
+ print(f" Authorization ID: {agent['authorization_id']}")
230
+ print(f" Engine ID: {agent['engine_id']}")
231
+ print(f" Full Name: {agent['full_name']}")
232
+ print(" ---")
233
+ self._show_available_commands()
234
+ except Exception as e:
235
+ print(f"āŒ Error listing agents: {e}")
236
+ self._show_available_commands()
237
+
238
+ def _delete_agent(self, position):
239
+ """Delete an agent from agent space by list position."""
240
+ try:
241
+ pos = int(position)
242
+ except ValueError:
243
+ print(f"āŒ Invalid position: {position}. Please provide a number (e.g., 1, 2, 3...)")
244
+ return
245
+
246
+ if not self.last_agents_list:
247
+ print("āŒ No agents list available. Please run 'list-agents' first.")
248
+ return
249
+
250
+ if pos < 1 or pos > len(self.last_agents_list):
251
+ print(f"āŒ Invalid position: {pos}. Available positions: 1-{len(self.last_agents_list)}")
252
+ return
253
+
254
+ # Get the agent at the specified position (convert to 0-based index)
255
+ selected_agent = self.last_agents_list[pos - 1]
256
+
257
+ # Show confirmation prompt
258
+ print(f"\nšŸ—‘ļø About to delete agent:")
259
+ print(f" Position: [{pos}]")
260
+ print(f" ID: {selected_agent['id']}")
261
+ print(f" Display Name: {selected_agent['display_name']}")
262
+ print(f" Full Name: {selected_agent['full_name']}")
263
+
264
+ confirmation = input(f"\nAre you sure you want to delete this agent? (yes/no): ").strip().lower()
265
+
266
+ if confirmation not in ['yes', 'y']:
267
+ print("āŒ Deletion canceled.")
268
+ return
269
+
270
+ print(f"šŸ—‘ļø Deleting agent at position {pos}...")
271
+ try:
272
+ status, message = self.api_client.delete_agent_from_space(selected_agent['full_name'])
273
+ print(f"āœ… Status: {status}, Message: {message}")
274
+
275
+ # Remove from cached list
276
+ self.last_agents_list.pop(pos - 1)
277
+ print("šŸ’” Tip: Run 'list-agents' to see the updated list.")
278
+ except Exception as e:
279
+ print(f"āŒ Error deleting agent: {e}")
280
+
281
+ def _list_authorizations(self):
282
+ """List authorizations."""
283
+ print("šŸ” Listing authorizations...")
284
+ try:
285
+ authorizations = self.api_client.list_authorizations()
286
+ self.last_auth_list = authorizations # Cache for position-based deletion
287
+ if not authorizations:
288
+ print("No authorizations found.")
289
+ self._show_available_commands()
290
+ return
291
+ for idx, auth in enumerate(authorizations, start=1):
292
+ print(f"[{idx}] ID: {auth['id']}")
293
+ print(f" Name: {auth['name']}")
294
+ print(" ---")
295
+ self._show_available_commands()
296
+ except Exception as e:
297
+ print(f"āŒ Error listing authorizations: {e}")
298
+ self._show_available_commands()
299
+
300
+ def _delete_authorization(self, position):
301
+ """Delete an authorization by list position."""
302
+ try:
303
+ pos = int(position)
304
+ except ValueError:
305
+ print(f"āŒ Invalid position: {position}. Please provide a number (e.g., 1, 2, 3...)")
306
+ return
307
+
308
+ if not self.last_auth_list:
309
+ print("āŒ No authorizations list available. Please run 'list-authorizations' first.")
310
+ return
311
+
312
+ if pos < 1 or pos > len(self.last_auth_list):
313
+ print(f"āŒ Invalid position: {pos}. Available positions: 1-{len(self.last_auth_list)}")
314
+ return
315
+
316
+ # Get the authorization at the specified position (convert to 0-based index)
317
+ selected_auth = self.last_auth_list[pos - 1]
318
+
319
+ # Show confirmation prompt
320
+ print(f"\nšŸ—‘ļø About to delete authorization:")
321
+ print(f" Position: [{pos}]")
322
+ print(f" ID: {selected_auth['id']}")
323
+ print(f" Name: {selected_auth['name']}")
324
+
325
+ confirmation = input(f"\nAre you sure you want to delete this authorization? (yes/no): ").strip().lower()
326
+
327
+ if confirmation not in ['yes', 'y']:
328
+ print("āŒ Deletion canceled.")
329
+ return
330
+
331
+ print(f"šŸ—‘ļø Deleting authorization at position {pos}...")
332
+ try:
333
+ status, message = self.api_client.delete_authorization(selected_auth['id'])
334
+ print(f"āœ… Status: {status}, Message: {message}")
335
+
336
+ # Remove from cached list
337
+ self.last_auth_list.pop(pos - 1)
338
+ print("šŸ’” Tip: Run 'list-authorizations' to see the updated list.")
339
+ except Exception as e:
340
+ print(f"āŒ Error deleting authorization: {e}")
341
+
342
+ if __name__ == "__main__":
343
+ CLIRunner().run()
@@ -0,0 +1,82 @@
1
+ """Configuration management for Agent Space Deployment Service."""
2
+ import os
3
+ from typing import Dict, Any
4
+ try:
5
+ import dotenv
6
+ except ImportError:
7
+ dotenv = None
8
+
9
+
10
+ class Config:
11
+ """Configuration class to manage environment variables and defaults."""
12
+
13
+ def __init__(self, environment: str = "DEV"):
14
+ """Initialize config with environment selection (DEV or PROD)."""
15
+ self.environment = environment.upper()
16
+
17
+ # Load from environment-specific variables (same as GUI editor)
18
+ self.project_id = os.getenv(f"{self.environment}_PROJECT_ID")
19
+ self.project_number = os.getenv(f"{self.environment}_PROJECT_NUMBER")
20
+ self.location = os.getenv(f"{self.environment}_PROJECT_LOCATION")
21
+ self.agent_space = os.getenv(f"{self.environment}_AGENT_SPACE_ENGINE")
22
+ self.staging_bucket = os.getenv(f"{self.environment}_STAGING_BUCKET")
23
+ self.oauth_client_id = os.getenv(f"{self.environment}_OAUTH_CLIENT_ID")
24
+ self.oauth_client_secret = os.getenv(f"{self.environment}_OAUTH_CLIENT_SECRET")
25
+
26
+ # Alias for compatibility
27
+ self.engine_name = self.agent_space
28
+
29
+ # Legacy fallbacks for backward compatibility
30
+ if not self.project_id:
31
+ self.project_id = os.getenv("PROJECT_ID") or "your-project-id"
32
+ if not self.project_number:
33
+ self.project_number = os.getenv("PROJECT_NUMBER") or "000000000000"
34
+ if not self.location:
35
+ self.location = os.getenv("GCP_LOCATION", "us-central1")
36
+ if not self.agent_space:
37
+ self.agent_space = os.getenv("AGENT_SPACE_ENGINE") or "your-engine"
38
+ self.engine_name = self.agent_space
39
+ if not self.staging_bucket:
40
+ self.staging_bucket = os.getenv("GCS_STAGING_BUCKET", "gs://your-staging")
41
+ if not self.oauth_client_id:
42
+ self.oauth_client_id = os.getenv("OAUTH_CLIENT_ID", "")
43
+ if not self.oauth_client_secret:
44
+ self.oauth_client_secret = os.getenv("OAUTH_CLIENT_SECRET", "")
45
+
46
+ self.agent_import = os.getenv("AGENT_IMPORT", "") # e.g. "your.module:root_agent"
47
+
48
+ def to_dict(self) -> Dict[str, Any]:
49
+ """Convert config to dictionary for API client initialization."""
50
+ return {
51
+ "project_id": self.project_id,
52
+ "project_number": self.project_number,
53
+ "location": self.location,
54
+ "engine_name": self.engine_name,
55
+ "agent_space": self.agent_space,
56
+ "staging_bucket": self.staging_bucket,
57
+ "oauth_client_id": self.oauth_client_id,
58
+ "oauth_client_secret": self.oauth_client_secret,
59
+ "agent_import": self.agent_import,
60
+ }
61
+
62
+ @property
63
+ def is_configured(self) -> bool:
64
+ """Check if minimum required configuration is available."""
65
+ return all([
66
+ self.project_id and self.project_id != "your-project-id",
67
+ self.project_number and self.project_number != "000000000000",
68
+ self.location,
69
+ self.agent_space and self.agent_space != "your-engine"
70
+ ])
71
+
72
+
73
+ def loadenv(env_path: str):
74
+ """Load environment variables from the specified file."""
75
+ if not dotenv:
76
+ print("āš ļø python-dotenv not available. Please install it or set environment variables manually.")
77
+ return
78
+
79
+ if not os.path.exists(env_path):
80
+ raise FileNotFoundError(f"Environment file not found: {env_path}")
81
+ dotenv.load_dotenv(env_path)
82
+ print(f"Environment variables loaded from {env_path}")
@@ -0,0 +1,29 @@
1
+ """Google Cloud dependencies check and imports."""
2
+ import warnings
3
+ import os
4
+
5
+ # Suppress Vertex AI API registration warnings
6
+ warnings.filterwarnings("ignore", message=".*Failed to register API methods.*")
7
+ warnings.filterwarnings("ignore", message=".*api_mode.*")
8
+ os.environ.setdefault("GOOGLE_CLOUD_DISABLE_GRPC_LOGS", "true")
9
+
10
+ HAS_GOOGLE = True
11
+ try:
12
+ import requests
13
+ import google.auth
14
+ from google.auth.transport.requests import Request as GoogleAuthRequest
15
+ import vertexai
16
+ from vertexai.preview import reasoning_engines
17
+ from vertexai import agent_engines
18
+ except Exception:
19
+ HAS_GOOGLE = False
20
+
21
+ __all__ = [
22
+ "HAS_GOOGLE",
23
+ "requests",
24
+ "google",
25
+ "GoogleAuthRequest",
26
+ "vertexai",
27
+ "reasoning_engines",
28
+ "agent_engines"
29
+ ]