idun-agent-schema 0.1.42__py3-none-any.whl → 0.2.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.
Potentially problematic release.
This version of idun-agent-schema might be problematic. Click here for more details.
- idun_agent_schema/__init__.py +10 -10
- idun_agent_schema/engine/__init__.py +11 -11
- idun_agent_schema/engine/agent.py +16 -16
- idun_agent_schema/engine/api.py +29 -29
- idun_agent_schema/engine/config.py +15 -6
- idun_agent_schema/engine/haystack.py +13 -13
- idun_agent_schema/engine/langgraph.py +47 -47
- idun_agent_schema/engine/server.py +15 -15
- idun_agent_schema/manager/__init__.py +53 -50
- idun_agent_schema/manager/api.py +286 -158
- idun_agent_schema/manager/deployments.py +12 -12
- idun_agent_schema/manager/deps.py +14 -14
- idun_agent_schema/manager/domain.py +276 -276
- idun_agent_schema/manager/dto.py +131 -131
- idun_agent_schema/manager/errors.py +22 -22
- idun_agent_schema/manager/settings.py +161 -161
- idun_agent_schema/shared/__init__.py +5 -5
- idun_agent_schema/shared/observability.py +56 -56
- {idun_agent_schema-0.1.42.dist-info → idun_agent_schema-0.2.0.dist-info}/METADATA +1 -1
- idun_agent_schema-0.2.0.dist-info/RECORD +22 -0
- idun_agent_schema-0.1.42.dist-info/RECORD +0 -22
- {idun_agent_schema-0.1.42.dist-info → idun_agent_schema-0.2.0.dist-info}/WHEEL +0 -0
idun_agent_schema/manager/api.py
CHANGED
|
@@ -1,158 +1,286 @@
|
|
|
1
|
-
"""Pydantic schemas for Agent Manager API I/O."""
|
|
2
|
-
|
|
3
|
-
from datetime import datetime
|
|
4
|
-
from typing import Any
|
|
5
|
-
from uuid import UUID
|
|
6
|
-
|
|
7
|
-
from pydantic import BaseModel, Field
|
|
8
|
-
|
|
9
|
-
from .
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
name: str
|
|
27
|
-
description: str | None
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
class
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
class Config:
|
|
106
|
-
"""Pydantic configuration for ORM compatibility."""
|
|
107
|
-
|
|
108
|
-
from_attributes = True
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
class
|
|
112
|
-
"""
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
1
|
+
"""Pydantic schemas for Agent Manager API I/O."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Any
|
|
5
|
+
from uuid import UUID
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, Field, field_validator
|
|
8
|
+
|
|
9
|
+
from ..engine.config import AgentConfig
|
|
10
|
+
from .domain import AgentFramework, AgentStatus
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AgentRunRequest(BaseModel):
|
|
16
|
+
"""Request payload to execute an agent run."""
|
|
17
|
+
|
|
18
|
+
input_data: dict[str, Any]
|
|
19
|
+
trace_id: str | None = Field(None, max_length=100)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AgentResponse(BaseModel):
|
|
23
|
+
"""Response shape for a single agent resource."""
|
|
24
|
+
|
|
25
|
+
id: UUID
|
|
26
|
+
name: str
|
|
27
|
+
description: str | None
|
|
28
|
+
framework: AgentFramework
|
|
29
|
+
status: AgentStatus
|
|
30
|
+
config: dict[str, Any]
|
|
31
|
+
environment_variables: dict[str, str]
|
|
32
|
+
version: str
|
|
33
|
+
tags: list[str]
|
|
34
|
+
tenant_id: UUID
|
|
35
|
+
created_at: datetime
|
|
36
|
+
updated_at: datetime
|
|
37
|
+
deployed_at: datetime | None
|
|
38
|
+
total_runs: int
|
|
39
|
+
success_rate: float | None
|
|
40
|
+
avg_response_time_ms: float | None
|
|
41
|
+
|
|
42
|
+
class Config:
|
|
43
|
+
"""Pydantic configuration for ORM compatibility."""
|
|
44
|
+
|
|
45
|
+
from_attributes = True
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class AgentSummaryResponse(BaseModel):
|
|
49
|
+
"""Reduced agent fields for listing views."""
|
|
50
|
+
|
|
51
|
+
id: UUID
|
|
52
|
+
name: str
|
|
53
|
+
description: str | None
|
|
54
|
+
framework: AgentFramework
|
|
55
|
+
status: AgentStatus
|
|
56
|
+
version: str
|
|
57
|
+
tags: list[str]
|
|
58
|
+
created_at: datetime
|
|
59
|
+
updated_at: datetime
|
|
60
|
+
total_runs: int
|
|
61
|
+
success_rate: float | None
|
|
62
|
+
|
|
63
|
+
class Config:
|
|
64
|
+
"""Pydantic configuration for ORM compatibility."""
|
|
65
|
+
|
|
66
|
+
from_attributes = True
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class AgentRunResponse(BaseModel):
|
|
70
|
+
"""Detailed run record returned after execution."""
|
|
71
|
+
|
|
72
|
+
id: UUID
|
|
73
|
+
agent_id: UUID
|
|
74
|
+
tenant_id: UUID
|
|
75
|
+
input_data: dict[str, Any]
|
|
76
|
+
output_data: dict[str, Any] | None
|
|
77
|
+
status: str
|
|
78
|
+
started_at: datetime
|
|
79
|
+
completed_at: datetime | None
|
|
80
|
+
error_message: str | None
|
|
81
|
+
response_time_ms: float | None
|
|
82
|
+
tokens_used: int | None
|
|
83
|
+
cost_usd: float | None
|
|
84
|
+
trace_id: str | None
|
|
85
|
+
span_id: str | None
|
|
86
|
+
|
|
87
|
+
class Config:
|
|
88
|
+
"""Pydantic configuration for ORM compatibility."""
|
|
89
|
+
|
|
90
|
+
from_attributes = True
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class AgentRunSummaryResponse(BaseModel):
|
|
94
|
+
"""Reduced run fields for list views."""
|
|
95
|
+
|
|
96
|
+
id: UUID
|
|
97
|
+
agent_id: UUID
|
|
98
|
+
status: str
|
|
99
|
+
started_at: datetime
|
|
100
|
+
completed_at: datetime | None
|
|
101
|
+
response_time_ms: float | None
|
|
102
|
+
tokens_used: int | None
|
|
103
|
+
cost_usd: float | None
|
|
104
|
+
|
|
105
|
+
class Config:
|
|
106
|
+
"""Pydantic configuration for ORM compatibility."""
|
|
107
|
+
|
|
108
|
+
from_attributes = True
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class PaginatedResponse(BaseModel):
|
|
112
|
+
"""Base pagination container used by list endpoints."""
|
|
113
|
+
|
|
114
|
+
total: int
|
|
115
|
+
limit: int
|
|
116
|
+
offset: int
|
|
117
|
+
has_more: bool
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class PaginatedAgentsResponse(PaginatedResponse):
|
|
121
|
+
"""Paginated list of agents."""
|
|
122
|
+
|
|
123
|
+
items: list[AgentSummaryResponse]
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class PaginatedRunsResponse(PaginatedResponse):
|
|
127
|
+
"""Paginated list of agent runs."""
|
|
128
|
+
|
|
129
|
+
items: list[AgentRunSummaryResponse]
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class AgentStatsResponse(BaseModel):
|
|
133
|
+
"""Aggregated statistics across all agents."""
|
|
134
|
+
|
|
135
|
+
total_agents: int
|
|
136
|
+
active_agents: int
|
|
137
|
+
total_runs_today: int
|
|
138
|
+
total_runs_this_month: int
|
|
139
|
+
avg_success_rate: float | None
|
|
140
|
+
avg_response_time_ms: float | None
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class AgentCreate(BaseModel):
|
|
144
|
+
"""Schema for creating a new agent.
|
|
145
|
+
|
|
146
|
+
Framework is inferred from config.type (e.g., config.type = "langgraph").
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
name: str = Field(..., min_length=1, max_length=100, description="Agent name")
|
|
150
|
+
description: str | None = Field(
|
|
151
|
+
None, max_length=500, description="Agent description"
|
|
152
|
+
)
|
|
153
|
+
# Use schema's AgentConfig instead of AgentPayload
|
|
154
|
+
config: AgentConfig = Field(
|
|
155
|
+
..., description="Framework-specific agent configuration"
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
@field_validator("name") # noqa: N805 - Pydantic validator uses `cls` by convention
|
|
159
|
+
@classmethod
|
|
160
|
+
def validate_name(cls, v):
|
|
161
|
+
if not v.strip():
|
|
162
|
+
raise ValueError("Name cannot be empty or whitespace only")
|
|
163
|
+
return v.strip()
|
|
164
|
+
|
|
165
|
+
class Config:
|
|
166
|
+
json_schema_extra = {
|
|
167
|
+
"example": {
|
|
168
|
+
"name": "My AI Assistant",
|
|
169
|
+
"description": "A helpful AI assistant for customer support",
|
|
170
|
+
"config": {
|
|
171
|
+
"type": "langgraph",
|
|
172
|
+
"config": {
|
|
173
|
+
"name": "My AI Assistant",
|
|
174
|
+
"graph_definition": "./examples/01_basic_config_file/example_agent.py:app",
|
|
175
|
+
"checkpointer": None,
|
|
176
|
+
"store": None,
|
|
177
|
+
"input_schema_definition": {},
|
|
178
|
+
"output_schema_definition": {},
|
|
179
|
+
"observability": None,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class AgentUpdate(BaseModel):
|
|
187
|
+
"""Schema for updating an existing agent."""
|
|
188
|
+
|
|
189
|
+
name: str | None = Field(
|
|
190
|
+
None, min_length=1, max_length=100, description="Agent name"
|
|
191
|
+
)
|
|
192
|
+
description: str | None = Field(
|
|
193
|
+
None, max_length=500, description="Agent description"
|
|
194
|
+
)
|
|
195
|
+
framework: AgentFramework | None = Field(None, description="Agent framework")
|
|
196
|
+
|
|
197
|
+
@field_validator("name") # noqa: N805
|
|
198
|
+
@classmethod
|
|
199
|
+
def validate_name(cls, v):
|
|
200
|
+
if v is not None and not v.strip():
|
|
201
|
+
raise ValueError("Name cannot be empty or whitespace only")
|
|
202
|
+
return v.strip() if v else v
|
|
203
|
+
|
|
204
|
+
class Config:
|
|
205
|
+
json_schema_extra = {
|
|
206
|
+
"example": {
|
|
207
|
+
"name": "Updated Agent Name",
|
|
208
|
+
"description": "Updated description",
|
|
209
|
+
"framework": "langchain",
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class Agent(BaseModel):
|
|
215
|
+
"""Complete agent model for responses."""
|
|
216
|
+
|
|
217
|
+
id: str = Field(..., description="Unique agent identifier")
|
|
218
|
+
name: str = Field(..., description="Agent name")
|
|
219
|
+
description: str | None = Field(None, description="Agent description")
|
|
220
|
+
framework: AgentFramework = Field(..., description="Agent framework")
|
|
221
|
+
status: AgentStatus = Field(AgentStatus.DRAFT, description="Agent status")
|
|
222
|
+
created_at: datetime = Field(..., description="Creation timestamp")
|
|
223
|
+
updated_at: datetime = Field(..., description="Last update timestamp")
|
|
224
|
+
|
|
225
|
+
class Config:
|
|
226
|
+
json_schema_extra = {
|
|
227
|
+
"example": {
|
|
228
|
+
"id": "550e8400-e29b-41d4-a716-446655440000",
|
|
229
|
+
"name": "My AI Assistant",
|
|
230
|
+
"description": "A helpful AI assistant",
|
|
231
|
+
"framework": "langgraph",
|
|
232
|
+
"status": "draft",
|
|
233
|
+
"created_at": "2024-01-01T00:00:00",
|
|
234
|
+
"updated_at": "2024-01-01T00:00:00",
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class AgentReplace(BaseModel):
|
|
240
|
+
"""Full replacement schema for PUT of an agent.
|
|
241
|
+
|
|
242
|
+
Represents the complete updatable representation of an agent.
|
|
243
|
+
Server-managed fields like id, status, and timestamps are excluded.
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
name: str = Field(..., min_length=1, max_length=100, description="Agent name")
|
|
247
|
+
description: str | None = Field(
|
|
248
|
+
None, max_length=500, description="Agent description"
|
|
249
|
+
)
|
|
250
|
+
config: AgentConfig = Field(
|
|
251
|
+
..., description="Framework-specific agent configuration"
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
@field_validator("name") # noqa: N805
|
|
255
|
+
@classmethod
|
|
256
|
+
def validate_name(cls, v):
|
|
257
|
+
if not v.strip():
|
|
258
|
+
raise ValueError("Name cannot be empty or whitespace only")
|
|
259
|
+
return v.strip()
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class AgentPatch(BaseModel):
|
|
263
|
+
"""Partial update schema for PATCH of an agent.
|
|
264
|
+
|
|
265
|
+
Only provided fields will be updated. If config is provided, the
|
|
266
|
+
framework will be inferred from config.type.
|
|
267
|
+
"""
|
|
268
|
+
|
|
269
|
+
name: str | None = Field(
|
|
270
|
+
None, min_length=1, max_length=100, description="Agent name"
|
|
271
|
+
)
|
|
272
|
+
description: str | None = Field(
|
|
273
|
+
None, max_length=500, description="Agent description"
|
|
274
|
+
)
|
|
275
|
+
config: AgentConfig | None = Field(
|
|
276
|
+
None, description="Framework-specific agent configuration"
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
@field_validator("name") # noqa: N805
|
|
280
|
+
@classmethod
|
|
281
|
+
def validate_name(cls, v):
|
|
282
|
+
if v is not None and not v.strip():
|
|
283
|
+
raise ValueError("Name cannot be empty or whitespace only")
|
|
284
|
+
return v.strip() if v else v
|
|
285
|
+
|
|
286
|
+
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"""Deployment-related enums and schemas."""
|
|
2
|
-
|
|
3
|
-
from enum import Enum
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class DeploymentMode(str, Enum):
|
|
7
|
-
"""Supported deployment modes."""
|
|
8
|
-
|
|
9
|
-
LOCAL = "local"
|
|
10
|
-
AWS = "aws"
|
|
11
|
-
AZURE = "azure"
|
|
12
|
-
GCP = "gcp"
|
|
1
|
+
"""Deployment-related enums and schemas."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DeploymentMode(str, Enum):
|
|
7
|
+
"""Supported deployment modes."""
|
|
8
|
+
|
|
9
|
+
LOCAL = "local"
|
|
10
|
+
AWS = "aws"
|
|
11
|
+
AZURE = "azure"
|
|
12
|
+
GCP = "gcp"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"""Shared dependency models used by FastAPI deps in Manager."""
|
|
2
|
-
|
|
3
|
-
from uuid import UUID
|
|
4
|
-
|
|
5
|
-
from pydantic import BaseModel
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Principal(BaseModel):
|
|
9
|
-
"""Authenticated caller identity and authorization context."""
|
|
10
|
-
|
|
11
|
-
user_id: str
|
|
12
|
-
tenant_id: UUID
|
|
13
|
-
roles: list[str] = []
|
|
14
|
-
workspace_ids: list[UUID] = []
|
|
1
|
+
"""Shared dependency models used by FastAPI deps in Manager."""
|
|
2
|
+
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Principal(BaseModel):
|
|
9
|
+
"""Authenticated caller identity and authorization context."""
|
|
10
|
+
|
|
11
|
+
user_id: str
|
|
12
|
+
tenant_id: UUID
|
|
13
|
+
roles: list[str] = []
|
|
14
|
+
workspace_ids: list[UUID] = []
|