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 +46 -0
- ainative/agent_coordination.py +249 -0
- ainative/agent_identity_system.py +1566 -0
- ainative/agent_learning.py +239 -0
- ainative/agent_orchestration.py +202 -0
- ainative/agent_state.py +231 -0
- ainative/agent_swarm/__init__.py +510 -0
- ainative/auth.py +113 -0
- ainative/cli.py +698 -0
- ainative/cli_utils/__init__.py +13 -0
- ainative/cli_utils/diff.py +292 -0
- ainative/cli_utils/formatters.py +227 -0
- ainative/client.py +272 -0
- ainative/commands/__init__.py +28 -0
- ainative/commands/agents.py +238 -0
- ainative/commands/coordination.py +108 -0
- ainative/commands/inspect.py +483 -0
- ainative/commands/learning.py +119 -0
- ainative/commands/local.py +544 -0
- ainative/commands/state.py +144 -0
- ainative/commands/swarm.py +184 -0
- ainative/commands/sync.py +157 -0
- ainative/commands/tasks.py +191 -0
- ainative/exceptions.py +87 -0
- ainative/zerodb/__init__.py +89 -0
- ainative/zerodb/analytics.py +232 -0
- ainative/zerodb/memory.py +260 -0
- ainative/zerodb/projects.py +224 -0
- ainative/zerodb/tables.py +362 -0
- ainative/zerodb/vectors.py +231 -0
- ainative_python-2.0.0.dist-info/METADATA +550 -0
- ainative_python-2.0.0.dist-info/RECORD +35 -0
- ainative_python-2.0.0.dist-info/WHEEL +5 -0
- ainative_python-2.0.0.dist-info/entry_points.txt +2 -0
- ainative_python-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent Learning Module for AINative SDK
|
|
3
|
+
|
|
4
|
+
Provides interface for agent learning, feedback, and performance tracking.
|
|
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 AgentLearningClient:
|
|
14
|
+
"""Client for Agent Learning operations."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, client: "AINativeClient"):
|
|
17
|
+
"""
|
|
18
|
+
Initialize Agent Learning client.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
client: Parent AINative client instance
|
|
22
|
+
"""
|
|
23
|
+
self.client = client
|
|
24
|
+
self.base_path = "/agent-learning"
|
|
25
|
+
|
|
26
|
+
def record_interaction(
|
|
27
|
+
self,
|
|
28
|
+
agent_id: str,
|
|
29
|
+
interaction_type: str,
|
|
30
|
+
input_data: Dict[str, Any],
|
|
31
|
+
output_data: Dict[str, Any],
|
|
32
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
33
|
+
) -> Dict[str, Any]:
|
|
34
|
+
"""
|
|
35
|
+
Record an agent interaction for learning.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
agent_id: Agent ID
|
|
39
|
+
interaction_type: Type of interaction
|
|
40
|
+
input_data: Input data for the interaction
|
|
41
|
+
output_data: Output/response data
|
|
42
|
+
metadata: Additional metadata
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
Recorded interaction details
|
|
46
|
+
"""
|
|
47
|
+
data = {
|
|
48
|
+
"agent_id": agent_id,
|
|
49
|
+
"interaction_type": interaction_type,
|
|
50
|
+
"input_data": input_data,
|
|
51
|
+
"output_data": output_data,
|
|
52
|
+
"metadata": metadata or {},
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return self.client.post(f"{self.base_path}/interactions", data=data)
|
|
56
|
+
|
|
57
|
+
def get_interactions(
|
|
58
|
+
self,
|
|
59
|
+
agent_id: str,
|
|
60
|
+
interaction_type: Optional[str] = None,
|
|
61
|
+
limit: int = 100,
|
|
62
|
+
offset: int = 0,
|
|
63
|
+
) -> Dict[str, Any]:
|
|
64
|
+
"""
|
|
65
|
+
Get agent interactions.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
agent_id: Agent ID
|
|
69
|
+
interaction_type: Filter by interaction type
|
|
70
|
+
limit: Maximum number of results
|
|
71
|
+
offset: Pagination offset
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
List of interactions with pagination metadata
|
|
75
|
+
"""
|
|
76
|
+
params = {
|
|
77
|
+
"agent_id": agent_id,
|
|
78
|
+
"limit": limit,
|
|
79
|
+
"offset": offset,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if interaction_type:
|
|
83
|
+
params["interaction_type"] = interaction_type
|
|
84
|
+
|
|
85
|
+
return self.client.get(f"{self.base_path}/interactions", params=params)
|
|
86
|
+
|
|
87
|
+
def submit_feedback(
|
|
88
|
+
self,
|
|
89
|
+
agent_id: str,
|
|
90
|
+
interaction_id: str,
|
|
91
|
+
rating: int,
|
|
92
|
+
feedback_type: str = "quality",
|
|
93
|
+
comments: Optional[str] = None,
|
|
94
|
+
) -> Dict[str, Any]:
|
|
95
|
+
"""
|
|
96
|
+
Submit feedback for an agent interaction.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
agent_id: Agent ID
|
|
100
|
+
interaction_id: Interaction ID
|
|
101
|
+
rating: Feedback rating (1-5)
|
|
102
|
+
feedback_type: Type of feedback (quality, accuracy, speed, helpfulness)
|
|
103
|
+
comments: Optional feedback comments
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
Feedback submission confirmation
|
|
107
|
+
"""
|
|
108
|
+
data = {
|
|
109
|
+
"agent_id": agent_id,
|
|
110
|
+
"interaction_id": interaction_id,
|
|
111
|
+
"rating": rating,
|
|
112
|
+
"feedback_type": feedback_type,
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if comments:
|
|
116
|
+
data["comments"] = comments
|
|
117
|
+
|
|
118
|
+
return self.client.post(f"{self.base_path}/feedback", data=data)
|
|
119
|
+
|
|
120
|
+
def get_feedback_summary(
|
|
121
|
+
self,
|
|
122
|
+
agent_id: str,
|
|
123
|
+
time_range: str = "7d",
|
|
124
|
+
) -> Dict[str, Any]:
|
|
125
|
+
"""
|
|
126
|
+
Get feedback summary for an agent.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
agent_id: Agent ID
|
|
130
|
+
time_range: Time range (1d, 7d, 30d, 90d, all)
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
Feedback summary statistics
|
|
134
|
+
"""
|
|
135
|
+
params = {
|
|
136
|
+
"agent_id": agent_id,
|
|
137
|
+
"time_range": time_range,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return self.client.get(f"{self.base_path}/feedback/summary", params=params)
|
|
141
|
+
|
|
142
|
+
def get_performance_metrics(
|
|
143
|
+
self,
|
|
144
|
+
agent_id: str,
|
|
145
|
+
metric_types: Optional[List[str]] = None,
|
|
146
|
+
time_range: str = "7d",
|
|
147
|
+
) -> Dict[str, Any]:
|
|
148
|
+
"""
|
|
149
|
+
Get agent performance metrics.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
agent_id: Agent ID
|
|
153
|
+
metric_types: Specific metric types to retrieve
|
|
154
|
+
time_range: Time range (1d, 7d, 30d, 90d, all)
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
Performance metrics data
|
|
158
|
+
"""
|
|
159
|
+
params = {
|
|
160
|
+
"agent_id": agent_id,
|
|
161
|
+
"time_range": time_range,
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if metric_types:
|
|
165
|
+
params["metric_types"] = ",".join(metric_types)
|
|
166
|
+
|
|
167
|
+
return self.client.get(f"{self.base_path}/performance", params=params)
|
|
168
|
+
|
|
169
|
+
def compare_agents(
|
|
170
|
+
self,
|
|
171
|
+
agent_ids: List[str],
|
|
172
|
+
metrics: List[str],
|
|
173
|
+
time_range: str = "7d",
|
|
174
|
+
) -> Dict[str, Any]:
|
|
175
|
+
"""
|
|
176
|
+
Compare performance metrics across multiple agents.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
agent_ids: List of agent IDs to compare
|
|
180
|
+
metrics: List of metrics to compare
|
|
181
|
+
time_range: Time range for comparison
|
|
182
|
+
|
|
183
|
+
Returns:
|
|
184
|
+
Comparative performance data
|
|
185
|
+
"""
|
|
186
|
+
data = {
|
|
187
|
+
"agent_ids": agent_ids,
|
|
188
|
+
"metrics": metrics,
|
|
189
|
+
"time_range": time_range,
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return self.client.post(f"{self.base_path}/compare", data=data)
|
|
193
|
+
|
|
194
|
+
def get_learning_progress(
|
|
195
|
+
self,
|
|
196
|
+
agent_id: str,
|
|
197
|
+
) -> Dict[str, Any]:
|
|
198
|
+
"""
|
|
199
|
+
Get agent learning progress and improvement trends.
|
|
200
|
+
|
|
201
|
+
Args:
|
|
202
|
+
agent_id: Agent ID
|
|
203
|
+
|
|
204
|
+
Returns:
|
|
205
|
+
Learning progress data
|
|
206
|
+
"""
|
|
207
|
+
return self.client.get(f"{self.base_path}/agents/{agent_id}/progress")
|
|
208
|
+
|
|
209
|
+
def export_learning_data(
|
|
210
|
+
self,
|
|
211
|
+
agent_id: str,
|
|
212
|
+
format: str = "json",
|
|
213
|
+
include_raw_data: bool = False,
|
|
214
|
+
) -> Dict[str, Any]:
|
|
215
|
+
"""
|
|
216
|
+
Export agent learning data.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
agent_id: Agent ID
|
|
220
|
+
format: Export format (json, csv, parquet)
|
|
221
|
+
include_raw_data: Include raw interaction data
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
Export data or download URL
|
|
225
|
+
"""
|
|
226
|
+
params = {
|
|
227
|
+
"format": format,
|
|
228
|
+
"include_raw_data": str(include_raw_data).lower(),
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return self.client.get(
|
|
232
|
+
f"{self.base_path}/agents/{agent_id}/export",
|
|
233
|
+
params=params
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
__all__ = [
|
|
238
|
+
"AgentLearningClient",
|
|
239
|
+
]
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent Orchestration Module for AINative SDK
|
|
3
|
+
|
|
4
|
+
Provides interface for orchestrating AI agent instances and tasks.
|
|
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 AgentOrchestrationClient:
|
|
14
|
+
"""Client for Agent Orchestration operations."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, client: "AINativeClient"):
|
|
17
|
+
"""
|
|
18
|
+
Initialize Agent Orchestration client.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
client: Parent AINative client instance
|
|
22
|
+
"""
|
|
23
|
+
self.client = client
|
|
24
|
+
self.base_path = "/agent-orchestration"
|
|
25
|
+
|
|
26
|
+
def create_agent_instance(
|
|
27
|
+
self,
|
|
28
|
+
name: str,
|
|
29
|
+
agent_type: str,
|
|
30
|
+
capabilities: List[str],
|
|
31
|
+
config: Optional[Dict[str, Any]] = None,
|
|
32
|
+
) -> Dict[str, Any]:
|
|
33
|
+
"""
|
|
34
|
+
Create a new agent instance.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
name: Agent instance name
|
|
38
|
+
agent_type: Type of agent (researcher, coder, reviewer, etc.)
|
|
39
|
+
capabilities: List of agent capabilities
|
|
40
|
+
config: Additional agent configuration
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
Created agent instance details
|
|
44
|
+
"""
|
|
45
|
+
data = {
|
|
46
|
+
"name": name,
|
|
47
|
+
"agent_type": agent_type,
|
|
48
|
+
"capabilities": capabilities,
|
|
49
|
+
"config": config or {},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return self.client.post(f"{self.base_path}/agents", data=data)
|
|
53
|
+
|
|
54
|
+
def list_agent_instances(
|
|
55
|
+
self,
|
|
56
|
+
agent_type: Optional[str] = None,
|
|
57
|
+
status: Optional[str] = None,
|
|
58
|
+
limit: int = 100,
|
|
59
|
+
offset: int = 0,
|
|
60
|
+
) -> Dict[str, Any]:
|
|
61
|
+
"""
|
|
62
|
+
List agent instances with optional filtering.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
agent_type: Filter by agent type
|
|
66
|
+
status: Filter by status (active, idle, error)
|
|
67
|
+
limit: Maximum number of results
|
|
68
|
+
offset: Pagination offset
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
List of agent instances with pagination metadata
|
|
72
|
+
"""
|
|
73
|
+
params = {
|
|
74
|
+
"limit": limit,
|
|
75
|
+
"offset": offset,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if agent_type:
|
|
79
|
+
params["agent_type"] = agent_type
|
|
80
|
+
if status:
|
|
81
|
+
params["status"] = status
|
|
82
|
+
|
|
83
|
+
return self.client.get(f"{self.base_path}/agents", params=params)
|
|
84
|
+
|
|
85
|
+
def get_agent_instance(self, agent_id: str) -> Dict[str, Any]:
|
|
86
|
+
"""
|
|
87
|
+
Get details of a specific agent instance.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
agent_id: Agent instance ID
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
Agent instance details
|
|
94
|
+
"""
|
|
95
|
+
return self.client.get(f"{self.base_path}/agents/{agent_id}")
|
|
96
|
+
|
|
97
|
+
def create_task(
|
|
98
|
+
self,
|
|
99
|
+
agent_id: str,
|
|
100
|
+
task_type: str,
|
|
101
|
+
description: str,
|
|
102
|
+
context: Optional[Dict[str, Any]] = None,
|
|
103
|
+
priority: str = "medium",
|
|
104
|
+
) -> Dict[str, Any]:
|
|
105
|
+
"""
|
|
106
|
+
Create a new task for an agent instance.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
agent_id: Agent instance ID
|
|
110
|
+
task_type: Type of task
|
|
111
|
+
description: Task description
|
|
112
|
+
context: Task context data
|
|
113
|
+
priority: Task priority (low, medium, high, critical)
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
Created task details
|
|
117
|
+
"""
|
|
118
|
+
data = {
|
|
119
|
+
"agent_id": agent_id,
|
|
120
|
+
"task_type": task_type,
|
|
121
|
+
"description": description,
|
|
122
|
+
"context": context or {},
|
|
123
|
+
"priority": priority,
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return self.client.post(f"{self.base_path}/tasks", data=data)
|
|
127
|
+
|
|
128
|
+
def execute_task(
|
|
129
|
+
self,
|
|
130
|
+
task_id: str,
|
|
131
|
+
agent_id: Optional[str] = None,
|
|
132
|
+
) -> Dict[str, Any]:
|
|
133
|
+
"""
|
|
134
|
+
Execute a task.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
task_id: Task ID to execute
|
|
138
|
+
agent_id: Optional specific agent to use
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
Task execution result
|
|
142
|
+
"""
|
|
143
|
+
data = {}
|
|
144
|
+
if agent_id:
|
|
145
|
+
data["agent_id"] = agent_id
|
|
146
|
+
|
|
147
|
+
return self.client.post(
|
|
148
|
+
f"{self.base_path}/tasks/{task_id}/execute",
|
|
149
|
+
data=data
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
def get_task_status(self, task_id: str) -> Dict[str, Any]:
|
|
153
|
+
"""
|
|
154
|
+
Get task execution status.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
task_id: Task ID
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
Task status and progress details
|
|
161
|
+
"""
|
|
162
|
+
return self.client.get(f"{self.base_path}/tasks/{task_id}/status")
|
|
163
|
+
|
|
164
|
+
def list_tasks(
|
|
165
|
+
self,
|
|
166
|
+
agent_id: Optional[str] = None,
|
|
167
|
+
status: Optional[str] = None,
|
|
168
|
+
task_type: Optional[str] = None,
|
|
169
|
+
limit: int = 100,
|
|
170
|
+
offset: int = 0,
|
|
171
|
+
) -> Dict[str, Any]:
|
|
172
|
+
"""
|
|
173
|
+
List tasks with optional filtering.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
agent_id: Filter by agent instance
|
|
177
|
+
status: Filter by status (pending, running, completed, failed)
|
|
178
|
+
task_type: Filter by task type
|
|
179
|
+
limit: Maximum number of results
|
|
180
|
+
offset: Pagination offset
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
List of tasks with pagination metadata
|
|
184
|
+
"""
|
|
185
|
+
params = {
|
|
186
|
+
"limit": limit,
|
|
187
|
+
"offset": offset,
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if agent_id:
|
|
191
|
+
params["agent_id"] = agent_id
|
|
192
|
+
if status:
|
|
193
|
+
params["status"] = status
|
|
194
|
+
if task_type:
|
|
195
|
+
params["task_type"] = task_type
|
|
196
|
+
|
|
197
|
+
return self.client.get(f"{self.base_path}/tasks", params=params)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
__all__ = [
|
|
201
|
+
"AgentOrchestrationClient",
|
|
202
|
+
]
|
ainative/agent_state.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent State Module for AINative SDK
|
|
3
|
+
|
|
4
|
+
Provides interface for agent state management, checkpoints, and recovery.
|
|
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 AgentStateClient:
|
|
14
|
+
"""Client for Agent State operations."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, client: "AINativeClient"):
|
|
17
|
+
"""
|
|
18
|
+
Initialize Agent State client.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
client: Parent AINative client instance
|
|
22
|
+
"""
|
|
23
|
+
self.client = client
|
|
24
|
+
self.base_path = "/agent-state"
|
|
25
|
+
|
|
26
|
+
def create_state(
|
|
27
|
+
self,
|
|
28
|
+
agent_id: str,
|
|
29
|
+
state_data: Dict[str, Any],
|
|
30
|
+
state_type: str = "working",
|
|
31
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
32
|
+
) -> Dict[str, Any]:
|
|
33
|
+
"""
|
|
34
|
+
Create or update agent state.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
agent_id: Agent ID
|
|
38
|
+
state_data: State data to store
|
|
39
|
+
state_type: Type of state (working, checkpoint, snapshot)
|
|
40
|
+
metadata: Additional metadata
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
Created state details
|
|
44
|
+
"""
|
|
45
|
+
data = {
|
|
46
|
+
"agent_id": agent_id,
|
|
47
|
+
"state_data": state_data,
|
|
48
|
+
"state_type": state_type,
|
|
49
|
+
"metadata": metadata or {},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return self.client.post(f"{self.base_path}/states", data=data)
|
|
53
|
+
|
|
54
|
+
def get_state(
|
|
55
|
+
self,
|
|
56
|
+
agent_id: str,
|
|
57
|
+
state_id: Optional[str] = None,
|
|
58
|
+
) -> Dict[str, Any]:
|
|
59
|
+
"""
|
|
60
|
+
Get agent state.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
agent_id: Agent ID
|
|
64
|
+
state_id: Optional specific state ID (if not provided, returns latest)
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
Agent state data
|
|
68
|
+
"""
|
|
69
|
+
if state_id:
|
|
70
|
+
return self.client.get(f"{self.base_path}/states/{state_id}")
|
|
71
|
+
else:
|
|
72
|
+
params = {"agent_id": agent_id}
|
|
73
|
+
return self.client.get(f"{self.base_path}/states/latest", params=params)
|
|
74
|
+
|
|
75
|
+
def update_state(
|
|
76
|
+
self,
|
|
77
|
+
state_id: str,
|
|
78
|
+
state_data: Dict[str, Any],
|
|
79
|
+
) -> Dict[str, Any]:
|
|
80
|
+
"""
|
|
81
|
+
Update existing agent state.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
state_id: State ID
|
|
85
|
+
state_data: Updated state data
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
Updated state details
|
|
89
|
+
"""
|
|
90
|
+
data = {
|
|
91
|
+
"state_data": state_data,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return self.client.put(f"{self.base_path}/states/{state_id}", data=data)
|
|
95
|
+
|
|
96
|
+
def delete_state(
|
|
97
|
+
self,
|
|
98
|
+
state_id: str,
|
|
99
|
+
) -> Dict[str, Any]:
|
|
100
|
+
"""
|
|
101
|
+
Delete agent state.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
state_id: State ID to delete
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
Deletion confirmation
|
|
108
|
+
"""
|
|
109
|
+
return self.client.delete(f"{self.base_path}/states/{state_id}")
|
|
110
|
+
|
|
111
|
+
def list_states(
|
|
112
|
+
self,
|
|
113
|
+
agent_id: str,
|
|
114
|
+
state_type: Optional[str] = None,
|
|
115
|
+
limit: int = 100,
|
|
116
|
+
offset: int = 0,
|
|
117
|
+
) -> Dict[str, Any]:
|
|
118
|
+
"""
|
|
119
|
+
List agent states.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
agent_id: Agent ID
|
|
123
|
+
state_type: Filter by state type
|
|
124
|
+
limit: Maximum number of results
|
|
125
|
+
offset: Pagination offset
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
List of states with pagination metadata
|
|
129
|
+
"""
|
|
130
|
+
params = {
|
|
131
|
+
"agent_id": agent_id,
|
|
132
|
+
"limit": limit,
|
|
133
|
+
"offset": offset,
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if state_type:
|
|
137
|
+
params["state_type"] = state_type
|
|
138
|
+
|
|
139
|
+
return self.client.get(f"{self.base_path}/states", params=params)
|
|
140
|
+
|
|
141
|
+
def create_checkpoint(
|
|
142
|
+
self,
|
|
143
|
+
agent_id: str,
|
|
144
|
+
checkpoint_name: str,
|
|
145
|
+
state_data: Dict[str, Any],
|
|
146
|
+
description: Optional[str] = None,
|
|
147
|
+
) -> Dict[str, Any]:
|
|
148
|
+
"""
|
|
149
|
+
Create a state checkpoint for recovery.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
agent_id: Agent ID
|
|
153
|
+
checkpoint_name: Checkpoint name
|
|
154
|
+
state_data: State data to checkpoint
|
|
155
|
+
description: Optional checkpoint description
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
Created checkpoint details
|
|
159
|
+
"""
|
|
160
|
+
data = {
|
|
161
|
+
"agent_id": agent_id,
|
|
162
|
+
"checkpoint_name": checkpoint_name,
|
|
163
|
+
"state_data": state_data,
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if description:
|
|
167
|
+
data["description"] = description
|
|
168
|
+
|
|
169
|
+
return self.client.post(f"{self.base_path}/checkpoints", data=data)
|
|
170
|
+
|
|
171
|
+
def restore_checkpoint(
|
|
172
|
+
self,
|
|
173
|
+
checkpoint_id: str,
|
|
174
|
+
) -> Dict[str, Any]:
|
|
175
|
+
"""
|
|
176
|
+
Restore agent state from a checkpoint.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
checkpoint_id: Checkpoint ID to restore
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
Restored state data
|
|
183
|
+
"""
|
|
184
|
+
return self.client.post(
|
|
185
|
+
f"{self.base_path}/checkpoints/{checkpoint_id}/restore"
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
def list_checkpoints(
|
|
189
|
+
self,
|
|
190
|
+
agent_id: str,
|
|
191
|
+
limit: int = 100,
|
|
192
|
+
offset: int = 0,
|
|
193
|
+
) -> Dict[str, Any]:
|
|
194
|
+
"""
|
|
195
|
+
List agent checkpoints.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
agent_id: Agent ID
|
|
199
|
+
limit: Maximum number of results
|
|
200
|
+
offset: Pagination offset
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
List of checkpoints with pagination metadata
|
|
204
|
+
"""
|
|
205
|
+
params = {
|
|
206
|
+
"agent_id": agent_id,
|
|
207
|
+
"limit": limit,
|
|
208
|
+
"offset": offset,
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return self.client.get(f"{self.base_path}/checkpoints", params=params)
|
|
212
|
+
|
|
213
|
+
def delete_checkpoint(
|
|
214
|
+
self,
|
|
215
|
+
checkpoint_id: str,
|
|
216
|
+
) -> Dict[str, Any]:
|
|
217
|
+
"""
|
|
218
|
+
Delete a checkpoint.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
checkpoint_id: Checkpoint ID to delete
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
Deletion confirmation
|
|
225
|
+
"""
|
|
226
|
+
return self.client.delete(f"{self.base_path}/checkpoints/{checkpoint_id}")
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
__all__ = [
|
|
230
|
+
"AgentStateClient",
|
|
231
|
+
]
|