ainative-python 2.0.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.
ainative/__init__.py ADDED
@@ -0,0 +1,46 @@
1
+ """
2
+ AINative Python SDK
3
+
4
+ Official Python SDK for AINative Studio APIs including ZeroDB and Agent Swarm operations.
5
+ """
6
+
7
+ __version__ = "2.0.0"
8
+ __author__ = "AINative Team"
9
+ __email__ = "support@ainative.studio"
10
+
11
+ from .client import AINativeClient
12
+ from .auth import AuthConfig, APIKeyAuth
13
+ from .exceptions import (
14
+ AINativeException,
15
+ AuthenticationError,
16
+ APIError,
17
+ NetworkError,
18
+ ValidationError,
19
+ RateLimitError,
20
+ )
21
+
22
+ # Convenience imports for common operations
23
+ from .zerodb import ZeroDBClient
24
+ from .agent_swarm import AgentSwarmClient
25
+ from .agent_orchestration import AgentOrchestrationClient
26
+ from .agent_coordination import AgentCoordinationClient
27
+ from .agent_learning import AgentLearningClient
28
+ from .agent_state import AgentStateClient
29
+
30
+ __all__ = [
31
+ "AINativeClient",
32
+ "AuthConfig",
33
+ "APIKeyAuth",
34
+ "AINativeException",
35
+ "AuthenticationError",
36
+ "APIError",
37
+ "NetworkError",
38
+ "ValidationError",
39
+ "RateLimitError",
40
+ "ZeroDBClient",
41
+ "AgentSwarmClient",
42
+ "AgentOrchestrationClient",
43
+ "AgentCoordinationClient",
44
+ "AgentLearningClient",
45
+ "AgentStateClient",
46
+ ]
@@ -0,0 +1,249 @@
1
+ """
2
+ Agent Coordination Module for AINative SDK
3
+
4
+ Provides interface for coordinating agent communication and task sequences.
5
+ """
6
+
7
+ from typing import TYPE_CHECKING, List, Dict, Any, Optional
8
+
9
+ if TYPE_CHECKING:
10
+ from .client import AINativeClient
11
+
12
+
13
+ class AgentCoordinationClient:
14
+ """Client for Agent Coordination operations."""
15
+
16
+ def __init__(self, client: "AINativeClient"):
17
+ """
18
+ Initialize Agent Coordination client.
19
+
20
+ Args:
21
+ client: Parent AINative client instance
22
+ """
23
+ self.client = client
24
+ self.base_path = "/agent-coordination"
25
+
26
+ def send_message(
27
+ self,
28
+ from_agent_id: str,
29
+ to_agent_id: str,
30
+ message: str,
31
+ message_type: str = "info",
32
+ metadata: Optional[Dict[str, Any]] = None,
33
+ ) -> Dict[str, Any]:
34
+ """
35
+ Send a message between agents.
36
+
37
+ Args:
38
+ from_agent_id: Sender agent ID
39
+ to_agent_id: Recipient agent ID
40
+ message: Message content
41
+ message_type: Type of message (info, request, response, error)
42
+ metadata: Additional message metadata
43
+
44
+ Returns:
45
+ Message delivery confirmation
46
+ """
47
+ data = {
48
+ "from_agent_id": from_agent_id,
49
+ "to_agent_id": to_agent_id,
50
+ "message": message,
51
+ "message_type": message_type,
52
+ "metadata": metadata or {},
53
+ }
54
+
55
+ return self.client.post(f"{self.base_path}/messages", data=data)
56
+
57
+ def get_messages(
58
+ self,
59
+ agent_id: str,
60
+ direction: str = "received",
61
+ limit: int = 100,
62
+ offset: int = 0,
63
+ ) -> Dict[str, Any]:
64
+ """
65
+ Get messages for an agent.
66
+
67
+ Args:
68
+ agent_id: Agent ID
69
+ direction: Message direction (sent, received, all)
70
+ limit: Maximum number of messages
71
+ offset: Pagination offset
72
+
73
+ Returns:
74
+ List of messages with pagination metadata
75
+ """
76
+ params = {
77
+ "agent_id": agent_id,
78
+ "direction": direction,
79
+ "limit": limit,
80
+ "offset": offset,
81
+ }
82
+
83
+ return self.client.get(f"{self.base_path}/messages", params=params)
84
+
85
+ def create_task_sequence(
86
+ self,
87
+ name: str,
88
+ tasks: List[Dict[str, Any]],
89
+ execution_mode: str = "sequential",
90
+ config: Optional[Dict[str, Any]] = None,
91
+ ) -> Dict[str, Any]:
92
+ """
93
+ Create a task sequence for coordinated execution.
94
+
95
+ Args:
96
+ name: Sequence name
97
+ tasks: List of task definitions
98
+ execution_mode: Execution mode (sequential, parallel, conditional)
99
+ config: Additional sequence configuration
100
+
101
+ Returns:
102
+ Created task sequence details
103
+ """
104
+ data = {
105
+ "name": name,
106
+ "tasks": tasks,
107
+ "execution_mode": execution_mode,
108
+ "config": config or {},
109
+ }
110
+
111
+ return self.client.post(f"{self.base_path}/sequences", data=data)
112
+
113
+ def execute_sequence(
114
+ self,
115
+ sequence_id: str,
116
+ context: Optional[Dict[str, Any]] = None,
117
+ ) -> Dict[str, Any]:
118
+ """
119
+ Execute a task sequence.
120
+
121
+ Args:
122
+ sequence_id: Sequence ID to execute
123
+ context: Execution context data
124
+
125
+ Returns:
126
+ Sequence execution result
127
+ """
128
+ data = {
129
+ "context": context or {},
130
+ }
131
+
132
+ return self.client.post(
133
+ f"{self.base_path}/sequences/{sequence_id}/execute",
134
+ data=data
135
+ )
136
+
137
+ def get_sequence_status(self, sequence_id: str) -> Dict[str, Any]:
138
+ """
139
+ Get task sequence execution status.
140
+
141
+ Args:
142
+ sequence_id: Sequence ID
143
+
144
+ Returns:
145
+ Sequence status and progress details
146
+ """
147
+ return self.client.get(f"{self.base_path}/sequences/{sequence_id}/status")
148
+
149
+ def list_sequences(
150
+ self,
151
+ execution_mode: Optional[str] = None,
152
+ status: Optional[str] = None,
153
+ limit: int = 100,
154
+ offset: int = 0,
155
+ ) -> Dict[str, Any]:
156
+ """
157
+ List task sequences with optional filtering.
158
+
159
+ Args:
160
+ execution_mode: Filter by execution mode
161
+ status: Filter by status
162
+ limit: Maximum number of results
163
+ offset: Pagination offset
164
+
165
+ Returns:
166
+ List of sequences with pagination metadata
167
+ """
168
+ params = {
169
+ "limit": limit,
170
+ "offset": offset,
171
+ }
172
+
173
+ if execution_mode:
174
+ params["execution_mode"] = execution_mode
175
+ if status:
176
+ params["status"] = status
177
+
178
+ return self.client.get(f"{self.base_path}/sequences", params=params)
179
+
180
+ def get_agent_workload(
181
+ self,
182
+ agent_id: Optional[str] = None,
183
+ ) -> Dict[str, Any]:
184
+ """
185
+ Get agent workload statistics.
186
+
187
+ Args:
188
+ agent_id: Optional specific agent ID (if not provided, returns all agents)
189
+
190
+ Returns:
191
+ Workload statistics
192
+ """
193
+ params = {}
194
+ if agent_id:
195
+ params["agent_id"] = agent_id
196
+
197
+ return self.client.get(f"{self.base_path}/agents/workload", params=params)
198
+
199
+ def distribute_workload(
200
+ self,
201
+ tasks: List[str],
202
+ agents: List[str],
203
+ strategy: str = "round_robin",
204
+ ) -> Dict[str, Any]:
205
+ """
206
+ Distribute tasks across multiple agents.
207
+
208
+ Args:
209
+ tasks: List of task IDs to distribute
210
+ agents: List of agent IDs
211
+ strategy: Distribution strategy (round_robin, least_loaded, capability_match)
212
+
213
+ Returns:
214
+ Task distribution plan
215
+ """
216
+ data = {
217
+ "tasks": tasks,
218
+ "agents": agents,
219
+ "strategy": strategy,
220
+ }
221
+
222
+ return self.client.post(f"{self.base_path}/workload/distribute", data=data)
223
+
224
+ def sync_agents(
225
+ self,
226
+ agent_ids: List[str],
227
+ checkpoint: str,
228
+ ) -> Dict[str, Any]:
229
+ """
230
+ Synchronize multiple agents at a checkpoint.
231
+
232
+ Args:
233
+ agent_ids: List of agent IDs to synchronize
234
+ checkpoint: Checkpoint identifier
235
+
236
+ Returns:
237
+ Synchronization result
238
+ """
239
+ data = {
240
+ "agent_ids": agent_ids,
241
+ "checkpoint": checkpoint,
242
+ }
243
+
244
+ return self.client.post(f"{self.base_path}/sync", data=data)
245
+
246
+
247
+ __all__ = [
248
+ "AgentCoordinationClient",
249
+ ]