asteroid-odyssey 1.0.2__py3-none-any.whl → 1.1.0__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.
@@ -10,11 +10,12 @@ without modifying any generated files.
10
10
 
11
11
  import time
12
12
  import os
13
+ import logging
13
14
  from typing import Dict, Any, Optional, List, Union, Tuple
14
15
  from .openapi_client import (
15
16
  Configuration,
16
17
  ApiClient,
17
- SDKApi,
18
+ APIApi,
18
19
  ExecutionApi,
19
20
  ExecutionStatusResponse,
20
21
  ExecutionResultResponse,
@@ -55,17 +56,17 @@ class AsteroidClient:
55
56
  )
56
57
 
57
58
  self.api_client = ApiClient(config)
58
- self.sdk_api = SDKApi(self.api_client)
59
+ self.api_api = APIApi(self.api_client)
59
60
  self.execution_api = ExecutionApi(self.api_client)
60
61
 
61
- def execute_agent(self, agent_id: str, execution_data: Dict[str, Any]) -> str:
62
+ def execute_agent(self, agent_id: str, execution_data: Dict[str, Any], agent_profile_id: Optional[str] = None) -> str:
62
63
  """
63
64
  Execute an agent with the provided parameters.
64
65
 
65
66
  Args:
66
67
  agent_id: The ID of the agent to execute
67
- agent_profile_id: The ID of the agent profile
68
68
  execution_data: The execution parameters
69
+ agent_profile_id: Optional ID of the agent profile
69
70
 
70
71
  Returns:
71
72
  The execution ID
@@ -74,11 +75,11 @@ class AsteroidClient:
74
75
  Exception: If the execution request fails
75
76
 
76
77
  Example:
77
- execution_id = client.execute_structured_agent('my-agent-id', 'agent-profile-id', {'input': 'some dynamic value'})
78
+ execution_id = client.execute_agent('my-agent-id', {'input': 'some dynamic value'}, 'agent-profile-id')
78
79
  """
79
- req = StructuredAgentExecutionRequest(dynamic_data=execution_data)
80
+ req = StructuredAgentExecutionRequest(dynamic_data=execution_data, agent_profile_id=agent_profile_id)
80
81
  try:
81
- response = self.sdk_api.execute_agent_structured(agent_id, req)
82
+ response = self.execution_api.execute_agent_structured(agent_id, req)
82
83
  return response.execution_id
83
84
  except ApiException as e:
84
85
  raise Exception(f"Failed to execute agent: {e}")
@@ -101,7 +102,7 @@ class AsteroidClient:
101
102
  print(status.status)
102
103
  """
103
104
  try:
104
- return self.sdk_api.get_execution_status(execution_id)
105
+ return self.execution_api.get_execution_status(execution_id)
105
106
  except ApiException as e:
106
107
  raise Exception(f"Failed to get execution status: {e}")
107
108
 
@@ -123,12 +124,12 @@ class AsteroidClient:
123
124
  print(result)
124
125
  """
125
126
  try:
126
- response = self.sdk_api.get_execution_result(execution_id)
127
+ response = self.execution_api.get_execution_result(execution_id)
127
128
 
128
129
  if response.error:
129
130
  raise Exception(response.error)
130
131
 
131
- return response.result or {}
132
+ return response.execution_result or {}
132
133
  except ApiException as e:
133
134
  raise Exception(f"Failed to get execution result: {e}")
134
135
 
@@ -269,7 +270,7 @@ class AsteroidClient:
269
270
  print(f"Recording available at: {recording_url}")
270
271
  """
271
272
  try:
272
- response = self.sdk_api.get_browser_session_recording(execution_id)
273
+ response = self.execution_api.get_browser_session_recording(execution_id)
273
274
  return response.recording_url
274
275
  except ApiException as e:
275
276
  raise Exception(f"Failed to get browser session recording: {e}")
@@ -278,9 +279,23 @@ class AsteroidClient:
278
279
  """Context manager entry."""
279
280
  return self
280
281
 
281
- def __exit__(self, exc_type, exc_value, traceback):
282
- """Context manager exit."""
283
- pass
282
+ def __exit__(self, exc_type, exc_value, tb):
283
+ """Context manager exit: clean up API client connection pool."""
284
+ try:
285
+ # Try to grab the pool_manager; if any attr is missing, skip
286
+ try:
287
+ pool_manager = self.api_client.rest_client.pool_manager
288
+ except AttributeError:
289
+ pool_manager = None
290
+
291
+ if pool_manager:
292
+ pool_manager.clear()
293
+ except Exception as e:
294
+ # Log but don't mask the original exception (if any)
295
+ logging.warning("Failed to clear connection pool: %s", e)
296
+
297
+ # Returning False allows any exception in the 'with' block to propagate
298
+ return False
284
299
 
285
300
 
286
301
  # Convenience functions that mirror the TypeScript SDK pattern
@@ -302,23 +317,23 @@ def create_client(api_key: str, base_url: Optional[str] = None) -> AsteroidClien
302
317
  """
303
318
  return AsteroidClient(api_key, base_url)
304
319
 
305
- def execute_agent(client: AsteroidClient, agent_id: str, agent_profile_id: str, execution_data: Dict[str, Any]) -> str:
320
+ def execute_agent(client: AsteroidClient, agent_id: str, execution_data: Dict[str, Any], agent_profile_id: Optional[str] = None) -> str:
306
321
  """
307
322
  Execute an agent with the provided parameters.
308
323
 
309
324
  Args:
310
325
  client: The AsteroidClient instance
311
326
  agent_id: The ID of the agent to execute
312
- agent_profile_id: The ID of the agent profile
313
327
  execution_data: The execution parameters
328
+ agent_profile_id: Optional ID of the agent profile
314
329
 
315
330
  Returns:
316
331
  The execution ID
317
332
 
318
333
  Example:
319
- execution_id = execute_agent(client, 'my-agent-id', {'input': 'some dynamic value'})
334
+ execution_id = execute_agent(client, 'my-agent-id', {'input': 'some dynamic value'}, 'agent-profile-id')
320
335
  """
321
- return client.execute_agent(agent_id, agent_profile_id, execution_data)
336
+ return client.execute_agent(agent_id, execution_data, agent_profile_id)
322
337
 
323
338
 
324
339
 
@@ -20,7 +20,6 @@ __version__ = "1.0.0"
20
20
  __all__ = [
21
21
  "APIApi",
22
22
  "ExecutionApi",
23
- "SDKApi",
24
23
  "ApiResponse",
25
24
  "ApiClient",
26
25
  "Configuration",
@@ -46,7 +45,6 @@ __all__ = [
46
45
  # import apis into sdk package
47
46
  from asteroid_odyssey.openapi_client.api.api_api import APIApi as APIApi
48
47
  from asteroid_odyssey.openapi_client.api.execution_api import ExecutionApi as ExecutionApi
49
- from asteroid_odyssey.openapi_client.api.sdk_api import SDKApi as SDKApi
50
48
 
51
49
  # import ApiClient
52
50
  from asteroid_odyssey.openapi_client.api_response import ApiResponse as ApiResponse
@@ -3,5 +3,4 @@
3
3
  # import apis into api package
4
4
  from asteroid_odyssey.openapi_client.api.api_api import APIApi
5
5
  from asteroid_odyssey.openapi_client.api.execution_api import ExecutionApi
6
- from asteroid_odyssey.openapi_client.api.sdk_api import SDKApi
7
6