hackagent 0.3.1__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.
Files changed (183) hide show
  1. hackagent/__init__.py +12 -0
  2. hackagent/agent.py +214 -0
  3. hackagent/api/__init__.py +1 -0
  4. hackagent/api/agent/__init__.py +1 -0
  5. hackagent/api/agent/agent_create.py +347 -0
  6. hackagent/api/agent/agent_destroy.py +140 -0
  7. hackagent/api/agent/agent_list.py +242 -0
  8. hackagent/api/agent/agent_partial_update.py +361 -0
  9. hackagent/api/agent/agent_retrieve.py +235 -0
  10. hackagent/api/agent/agent_update.py +361 -0
  11. hackagent/api/apilogs/__init__.py +1 -0
  12. hackagent/api/apilogs/apilogs_list.py +170 -0
  13. hackagent/api/apilogs/apilogs_retrieve.py +162 -0
  14. hackagent/api/attack/__init__.py +1 -0
  15. hackagent/api/attack/attack_create.py +275 -0
  16. hackagent/api/attack/attack_destroy.py +146 -0
  17. hackagent/api/attack/attack_list.py +254 -0
  18. hackagent/api/attack/attack_partial_update.py +289 -0
  19. hackagent/api/attack/attack_retrieve.py +247 -0
  20. hackagent/api/attack/attack_update.py +289 -0
  21. hackagent/api/checkout/__init__.py +1 -0
  22. hackagent/api/checkout/checkout_create.py +225 -0
  23. hackagent/api/generate/__init__.py +1 -0
  24. hackagent/api/generate/generate_create.py +253 -0
  25. hackagent/api/judge/__init__.py +1 -0
  26. hackagent/api/judge/judge_create.py +253 -0
  27. hackagent/api/key/__init__.py +1 -0
  28. hackagent/api/key/key_create.py +179 -0
  29. hackagent/api/key/key_destroy.py +103 -0
  30. hackagent/api/key/key_list.py +170 -0
  31. hackagent/api/key/key_retrieve.py +162 -0
  32. hackagent/api/organization/__init__.py +1 -0
  33. hackagent/api/organization/organization_create.py +208 -0
  34. hackagent/api/organization/organization_destroy.py +104 -0
  35. hackagent/api/organization/organization_list.py +170 -0
  36. hackagent/api/organization/organization_me_retrieve.py +126 -0
  37. hackagent/api/organization/organization_partial_update.py +222 -0
  38. hackagent/api/organization/organization_retrieve.py +163 -0
  39. hackagent/api/organization/organization_update.py +222 -0
  40. hackagent/api/prompt/__init__.py +1 -0
  41. hackagent/api/prompt/prompt_create.py +171 -0
  42. hackagent/api/prompt/prompt_destroy.py +104 -0
  43. hackagent/api/prompt/prompt_list.py +185 -0
  44. hackagent/api/prompt/prompt_partial_update.py +185 -0
  45. hackagent/api/prompt/prompt_retrieve.py +163 -0
  46. hackagent/api/prompt/prompt_update.py +185 -0
  47. hackagent/api/result/__init__.py +1 -0
  48. hackagent/api/result/result_create.py +175 -0
  49. hackagent/api/result/result_destroy.py +106 -0
  50. hackagent/api/result/result_list.py +249 -0
  51. hackagent/api/result/result_partial_update.py +193 -0
  52. hackagent/api/result/result_retrieve.py +167 -0
  53. hackagent/api/result/result_trace_create.py +177 -0
  54. hackagent/api/result/result_update.py +189 -0
  55. hackagent/api/run/__init__.py +1 -0
  56. hackagent/api/run/run_create.py +187 -0
  57. hackagent/api/run/run_destroy.py +112 -0
  58. hackagent/api/run/run_list.py +291 -0
  59. hackagent/api/run/run_partial_update.py +201 -0
  60. hackagent/api/run/run_result_create.py +177 -0
  61. hackagent/api/run/run_retrieve.py +179 -0
  62. hackagent/api/run/run_run_tests_create.py +187 -0
  63. hackagent/api/run/run_update.py +201 -0
  64. hackagent/api/user/__init__.py +1 -0
  65. hackagent/api/user/user_create.py +212 -0
  66. hackagent/api/user/user_destroy.py +106 -0
  67. hackagent/api/user/user_list.py +174 -0
  68. hackagent/api/user/user_me_retrieve.py +126 -0
  69. hackagent/api/user/user_me_update.py +196 -0
  70. hackagent/api/user/user_partial_update.py +226 -0
  71. hackagent/api/user/user_retrieve.py +167 -0
  72. hackagent/api/user/user_update.py +226 -0
  73. hackagent/attacks/AdvPrefix/__init__.py +41 -0
  74. hackagent/attacks/AdvPrefix/completions.py +416 -0
  75. hackagent/attacks/AdvPrefix/config.py +259 -0
  76. hackagent/attacks/AdvPrefix/evaluation.py +745 -0
  77. hackagent/attacks/AdvPrefix/evaluators.py +564 -0
  78. hackagent/attacks/AdvPrefix/generate.py +711 -0
  79. hackagent/attacks/AdvPrefix/utils.py +307 -0
  80. hackagent/attacks/__init__.py +35 -0
  81. hackagent/attacks/advprefix.py +507 -0
  82. hackagent/attacks/base.py +106 -0
  83. hackagent/attacks/strategies.py +906 -0
  84. hackagent/cli/__init__.py +19 -0
  85. hackagent/cli/commands/__init__.py +20 -0
  86. hackagent/cli/commands/agent.py +100 -0
  87. hackagent/cli/commands/attack.py +417 -0
  88. hackagent/cli/commands/config.py +301 -0
  89. hackagent/cli/commands/results.py +327 -0
  90. hackagent/cli/config.py +249 -0
  91. hackagent/cli/main.py +515 -0
  92. hackagent/cli/tui/__init__.py +31 -0
  93. hackagent/cli/tui/actions_logger.py +200 -0
  94. hackagent/cli/tui/app.py +288 -0
  95. hackagent/cli/tui/base.py +137 -0
  96. hackagent/cli/tui/logger.py +318 -0
  97. hackagent/cli/tui/views/__init__.py +33 -0
  98. hackagent/cli/tui/views/agents.py +488 -0
  99. hackagent/cli/tui/views/attacks.py +624 -0
  100. hackagent/cli/tui/views/config.py +244 -0
  101. hackagent/cli/tui/views/dashboard.py +307 -0
  102. hackagent/cli/tui/views/results.py +1210 -0
  103. hackagent/cli/tui/widgets/__init__.py +24 -0
  104. hackagent/cli/tui/widgets/actions.py +346 -0
  105. hackagent/cli/tui/widgets/logs.py +435 -0
  106. hackagent/cli/utils.py +276 -0
  107. hackagent/client.py +286 -0
  108. hackagent/errors.py +37 -0
  109. hackagent/logger.py +83 -0
  110. hackagent/models/__init__.py +109 -0
  111. hackagent/models/agent.py +223 -0
  112. hackagent/models/agent_request.py +129 -0
  113. hackagent/models/api_token_log.py +184 -0
  114. hackagent/models/attack.py +154 -0
  115. hackagent/models/attack_request.py +82 -0
  116. hackagent/models/checkout_session_request_request.py +76 -0
  117. hackagent/models/checkout_session_response.py +59 -0
  118. hackagent/models/choice.py +81 -0
  119. hackagent/models/choice_message.py +67 -0
  120. hackagent/models/evaluation_status_enum.py +14 -0
  121. hackagent/models/generate_error_response.py +59 -0
  122. hackagent/models/generate_request_request.py +212 -0
  123. hackagent/models/generate_success_response.py +115 -0
  124. hackagent/models/generic_error_response.py +70 -0
  125. hackagent/models/message_request.py +67 -0
  126. hackagent/models/organization.py +102 -0
  127. hackagent/models/organization_minimal.py +68 -0
  128. hackagent/models/organization_request.py +71 -0
  129. hackagent/models/paginated_agent_list.py +123 -0
  130. hackagent/models/paginated_api_token_log_list.py +123 -0
  131. hackagent/models/paginated_attack_list.py +123 -0
  132. hackagent/models/paginated_organization_list.py +123 -0
  133. hackagent/models/paginated_prompt_list.py +123 -0
  134. hackagent/models/paginated_result_list.py +123 -0
  135. hackagent/models/paginated_run_list.py +123 -0
  136. hackagent/models/paginated_user_api_key_list.py +123 -0
  137. hackagent/models/paginated_user_profile_list.py +123 -0
  138. hackagent/models/patched_agent_request.py +128 -0
  139. hackagent/models/patched_attack_request.py +92 -0
  140. hackagent/models/patched_organization_request.py +71 -0
  141. hackagent/models/patched_prompt_request.py +125 -0
  142. hackagent/models/patched_result_request.py +237 -0
  143. hackagent/models/patched_run_request.py +138 -0
  144. hackagent/models/patched_user_profile_request.py +99 -0
  145. hackagent/models/prompt.py +220 -0
  146. hackagent/models/prompt_request.py +126 -0
  147. hackagent/models/result.py +294 -0
  148. hackagent/models/result_list_evaluation_status.py +14 -0
  149. hackagent/models/result_request.py +232 -0
  150. hackagent/models/run.py +233 -0
  151. hackagent/models/run_list_status.py +12 -0
  152. hackagent/models/run_request.py +133 -0
  153. hackagent/models/status_enum.py +12 -0
  154. hackagent/models/step_type_enum.py +14 -0
  155. hackagent/models/trace.py +121 -0
  156. hackagent/models/trace_request.py +94 -0
  157. hackagent/models/usage.py +75 -0
  158. hackagent/models/user_api_key.py +201 -0
  159. hackagent/models/user_api_key_request.py +73 -0
  160. hackagent/models/user_profile.py +135 -0
  161. hackagent/models/user_profile_minimal.py +76 -0
  162. hackagent/models/user_profile_request.py +99 -0
  163. hackagent/router/__init__.py +25 -0
  164. hackagent/router/adapters/__init__.py +20 -0
  165. hackagent/router/adapters/base.py +63 -0
  166. hackagent/router/adapters/google_adk.py +671 -0
  167. hackagent/router/adapters/litellm_adapter.py +524 -0
  168. hackagent/router/adapters/openai_adapter.py +426 -0
  169. hackagent/router/router.py +969 -0
  170. hackagent/router/types.py +54 -0
  171. hackagent/tracking/__init__.py +42 -0
  172. hackagent/tracking/context.py +163 -0
  173. hackagent/tracking/decorators.py +299 -0
  174. hackagent/tracking/tracker.py +441 -0
  175. hackagent/types.py +54 -0
  176. hackagent/utils.py +194 -0
  177. hackagent/vulnerabilities/__init__.py +13 -0
  178. hackagent/vulnerabilities/prompts.py +81 -0
  179. hackagent-0.3.1.dist-info/METADATA +122 -0
  180. hackagent-0.3.1.dist-info/RECORD +183 -0
  181. hackagent-0.3.1.dist-info/WHEEL +4 -0
  182. hackagent-0.3.1.dist-info/entry_points.txt +2 -0
  183. hackagent-0.3.1.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,361 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+ from uuid import UUID
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.agent import Agent
10
+ from ...models.patched_agent_request import PatchedAgentRequest
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ id: UUID,
16
+ *,
17
+ body: PatchedAgentRequest,
18
+ ) -> dict[str, Any]:
19
+ headers: dict[str, Any] = {}
20
+
21
+ _kwargs: dict[str, Any] = {
22
+ "method": "patch",
23
+ "url": f"/agent/{id}",
24
+ }
25
+
26
+ _kwargs["json"] = body.to_dict()
27
+
28
+ headers["Content-Type"] = "application/json"
29
+
30
+ _kwargs["headers"] = headers
31
+ return _kwargs
32
+
33
+
34
+ def _parse_response(
35
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
36
+ ) -> Optional[Agent]:
37
+ if response.status_code == 200:
38
+ response_200 = Agent.from_dict(response.json())
39
+
40
+ return response_200
41
+ if client.raise_on_unexpected_status:
42
+ raise errors.UnexpectedStatus(response.status_code, response.content)
43
+ else:
44
+ return None
45
+
46
+
47
+ def _build_response(
48
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
49
+ ) -> Response[Agent]:
50
+ return Response(
51
+ status_code=HTTPStatus(response.status_code),
52
+ content=response.content,
53
+ headers=response.headers,
54
+ parsed=_parse_response(client=client, response=response),
55
+ )
56
+
57
+
58
+ def sync_detailed(
59
+ id: UUID,
60
+ *,
61
+ client: AuthenticatedClient,
62
+ body: PatchedAgentRequest,
63
+ ) -> Response[Agent]:
64
+ """Provides CRUD operations for Agent instances.
65
+
66
+ This ViewSet manages Agent records, ensuring that users can only interact
67
+ with agents based on their permissions and organizational context.
68
+ It filters agent listings for users and handles the logic for creating
69
+ agents, including associating them with the correct organization and owner.
70
+
71
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
72
+ Auth0 authentication is supported as fallback for web dashboard use.
73
+
74
+ Permissions are based on IsAuthenticated, with queryset filtering providing
75
+ row-level access control.
76
+
77
+ Class Attributes:
78
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
79
+ This is further filtered by `get_queryset()`.
80
+ serializer_class (AgentSerializer): The serializer used for validating and
81
+ deserializing input, and for serializing output.
82
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
83
+ permission_classes (list): List of permission classes to use.
84
+ parser_classes (list): List of parser classes for handling request data.
85
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
86
+
87
+ Args:
88
+ id (UUID):
89
+ body (PatchedAgentRequest): Serializes Agent model instances to JSON and validates data
90
+ for creating
91
+ or updating Agent instances.
92
+
93
+ This serializer provides a comprehensive representation of an Agent,
94
+ including its type, endpoint, and nested details for related 'organization'
95
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
96
+ for write operations.
97
+
98
+ Attributes:
99
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
100
+ serializer for the agent's organization. Displays minimal details.
101
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
102
+ for the agent's owner's user profile. Displays minimal details.
103
+ Can be null if the agent has no owner or the owner has no profile.
104
+ agent_type (CharField): The type of the agent as a string
105
+ (e.g., LITELLM, OPENAI_SDK, GOOGLE_ADK).
106
+
107
+ Meta:
108
+ model (Agent): The model class that this serializer works with.
109
+ fields (tuple): The fields to include in the serialized output.
110
+ Includes standard Agent fields like 'endpoint', 'type',
111
+ and the read-only nested details.
112
+ read_only_fields (tuple): Fields that are read-only and cannot be
113
+ set during create/update operations through this serializer.
114
+ This includes 'id', 'created_at', 'updated_at', and the
115
+ nested detail fields.
116
+
117
+ Raises:
118
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
119
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
120
+
121
+ Returns:
122
+ Response[Agent]
123
+ """
124
+
125
+ kwargs = _get_kwargs(
126
+ id=id,
127
+ body=body,
128
+ )
129
+
130
+ response = client.get_httpx_client().request(
131
+ **kwargs,
132
+ )
133
+
134
+ return _build_response(client=client, response=response)
135
+
136
+
137
+ def sync(
138
+ id: UUID,
139
+ *,
140
+ client: AuthenticatedClient,
141
+ body: PatchedAgentRequest,
142
+ ) -> Optional[Agent]:
143
+ """Provides CRUD operations for Agent instances.
144
+
145
+ This ViewSet manages Agent records, ensuring that users can only interact
146
+ with agents based on their permissions and organizational context.
147
+ It filters agent listings for users and handles the logic for creating
148
+ agents, including associating them with the correct organization and owner.
149
+
150
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
151
+ Auth0 authentication is supported as fallback for web dashboard use.
152
+
153
+ Permissions are based on IsAuthenticated, with queryset filtering providing
154
+ row-level access control.
155
+
156
+ Class Attributes:
157
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
158
+ This is further filtered by `get_queryset()`.
159
+ serializer_class (AgentSerializer): The serializer used for validating and
160
+ deserializing input, and for serializing output.
161
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
162
+ permission_classes (list): List of permission classes to use.
163
+ parser_classes (list): List of parser classes for handling request data.
164
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
165
+
166
+ Args:
167
+ id (UUID):
168
+ body (PatchedAgentRequest): Serializes Agent model instances to JSON and validates data
169
+ for creating
170
+ or updating Agent instances.
171
+
172
+ This serializer provides a comprehensive representation of an Agent,
173
+ including its type, endpoint, and nested details for related 'organization'
174
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
175
+ for write operations.
176
+
177
+ Attributes:
178
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
179
+ serializer for the agent's organization. Displays minimal details.
180
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
181
+ for the agent's owner's user profile. Displays minimal details.
182
+ Can be null if the agent has no owner or the owner has no profile.
183
+ agent_type (CharField): The type of the agent as a string
184
+ (e.g., LITELLM, OPENAI_SDK, GOOGLE_ADK).
185
+
186
+ Meta:
187
+ model (Agent): The model class that this serializer works with.
188
+ fields (tuple): The fields to include in the serialized output.
189
+ Includes standard Agent fields like 'endpoint', 'type',
190
+ and the read-only nested details.
191
+ read_only_fields (tuple): Fields that are read-only and cannot be
192
+ set during create/update operations through this serializer.
193
+ This includes 'id', 'created_at', 'updated_at', and the
194
+ nested detail fields.
195
+
196
+ Raises:
197
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
198
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
199
+
200
+ Returns:
201
+ Agent
202
+ """
203
+
204
+ return sync_detailed(
205
+ id=id,
206
+ client=client,
207
+ body=body,
208
+ ).parsed
209
+
210
+
211
+ async def asyncio_detailed(
212
+ id: UUID,
213
+ *,
214
+ client: AuthenticatedClient,
215
+ body: PatchedAgentRequest,
216
+ ) -> Response[Agent]:
217
+ """Provides CRUD operations for Agent instances.
218
+
219
+ This ViewSet manages Agent records, ensuring that users can only interact
220
+ with agents based on their permissions and organizational context.
221
+ It filters agent listings for users and handles the logic for creating
222
+ agents, including associating them with the correct organization and owner.
223
+
224
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
225
+ Auth0 authentication is supported as fallback for web dashboard use.
226
+
227
+ Permissions are based on IsAuthenticated, with queryset filtering providing
228
+ row-level access control.
229
+
230
+ Class Attributes:
231
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
232
+ This is further filtered by `get_queryset()`.
233
+ serializer_class (AgentSerializer): The serializer used for validating and
234
+ deserializing input, and for serializing output.
235
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
236
+ permission_classes (list): List of permission classes to use.
237
+ parser_classes (list): List of parser classes for handling request data.
238
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
239
+
240
+ Args:
241
+ id (UUID):
242
+ body (PatchedAgentRequest): Serializes Agent model instances to JSON and validates data
243
+ for creating
244
+ or updating Agent instances.
245
+
246
+ This serializer provides a comprehensive representation of an Agent,
247
+ including its type, endpoint, and nested details for related 'organization'
248
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
249
+ for write operations.
250
+
251
+ Attributes:
252
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
253
+ serializer for the agent's organization. Displays minimal details.
254
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
255
+ for the agent's owner's user profile. Displays minimal details.
256
+ Can be null if the agent has no owner or the owner has no profile.
257
+ agent_type (CharField): The type of the agent as a string
258
+ (e.g., LITELLM, OPENAI_SDK, GOOGLE_ADK).
259
+
260
+ Meta:
261
+ model (Agent): The model class that this serializer works with.
262
+ fields (tuple): The fields to include in the serialized output.
263
+ Includes standard Agent fields like 'endpoint', 'type',
264
+ and the read-only nested details.
265
+ read_only_fields (tuple): Fields that are read-only and cannot be
266
+ set during create/update operations through this serializer.
267
+ This includes 'id', 'created_at', 'updated_at', and the
268
+ nested detail fields.
269
+
270
+ Raises:
271
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
272
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
273
+
274
+ Returns:
275
+ Response[Agent]
276
+ """
277
+
278
+ kwargs = _get_kwargs(
279
+ id=id,
280
+ body=body,
281
+ )
282
+
283
+ response = await client.get_async_httpx_client().request(**kwargs)
284
+
285
+ return _build_response(client=client, response=response)
286
+
287
+
288
+ async def asyncio(
289
+ id: UUID,
290
+ *,
291
+ client: AuthenticatedClient,
292
+ body: PatchedAgentRequest,
293
+ ) -> Optional[Agent]:
294
+ """Provides CRUD operations for Agent instances.
295
+
296
+ This ViewSet manages Agent records, ensuring that users can only interact
297
+ with agents based on their permissions and organizational context.
298
+ It filters agent listings for users and handles the logic for creating
299
+ agents, including associating them with the correct organization and owner.
300
+
301
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
302
+ Auth0 authentication is supported as fallback for web dashboard use.
303
+
304
+ Permissions are based on IsAuthenticated, with queryset filtering providing
305
+ row-level access control.
306
+
307
+ Class Attributes:
308
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
309
+ This is further filtered by `get_queryset()`.
310
+ serializer_class (AgentSerializer): The serializer used for validating and
311
+ deserializing input, and for serializing output.
312
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
313
+ permission_classes (list): List of permission classes to use.
314
+ parser_classes (list): List of parser classes for handling request data.
315
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
316
+
317
+ Args:
318
+ id (UUID):
319
+ body (PatchedAgentRequest): Serializes Agent model instances to JSON and validates data
320
+ for creating
321
+ or updating Agent instances.
322
+
323
+ This serializer provides a comprehensive representation of an Agent,
324
+ including its type, endpoint, and nested details for related 'organization'
325
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
326
+ for write operations.
327
+
328
+ Attributes:
329
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
330
+ serializer for the agent's organization. Displays minimal details.
331
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
332
+ for the agent's owner's user profile. Displays minimal details.
333
+ Can be null if the agent has no owner or the owner has no profile.
334
+ agent_type (CharField): The type of the agent as a string
335
+ (e.g., LITELLM, OPENAI_SDK, GOOGLE_ADK).
336
+
337
+ Meta:
338
+ model (Agent): The model class that this serializer works with.
339
+ fields (tuple): The fields to include in the serialized output.
340
+ Includes standard Agent fields like 'endpoint', 'type',
341
+ and the read-only nested details.
342
+ read_only_fields (tuple): Fields that are read-only and cannot be
343
+ set during create/update operations through this serializer.
344
+ This includes 'id', 'created_at', 'updated_at', and the
345
+ nested detail fields.
346
+
347
+ Raises:
348
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
349
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
350
+
351
+ Returns:
352
+ Agent
353
+ """
354
+
355
+ return (
356
+ await asyncio_detailed(
357
+ id=id,
358
+ client=client,
359
+ body=body,
360
+ )
361
+ ).parsed
@@ -0,0 +1,235 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+ from uuid import UUID
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.agent import Agent
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs(
14
+ id: UUID,
15
+ ) -> dict[str, Any]:
16
+ _kwargs: dict[str, Any] = {
17
+ "method": "get",
18
+ "url": f"/agent/{id}",
19
+ }
20
+
21
+ return _kwargs
22
+
23
+
24
+ def _parse_response(
25
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
26
+ ) -> Optional[Agent]:
27
+ if response.status_code == 200:
28
+ response_200 = Agent.from_dict(response.json())
29
+
30
+ return response_200
31
+ if client.raise_on_unexpected_status:
32
+ raise errors.UnexpectedStatus(response.status_code, response.content)
33
+ else:
34
+ return None
35
+
36
+
37
+ def _build_response(
38
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
39
+ ) -> Response[Agent]:
40
+ return Response(
41
+ status_code=HTTPStatus(response.status_code),
42
+ content=response.content,
43
+ headers=response.headers,
44
+ parsed=_parse_response(client=client, response=response),
45
+ )
46
+
47
+
48
+ def sync_detailed(
49
+ id: UUID,
50
+ *,
51
+ client: AuthenticatedClient,
52
+ ) -> Response[Agent]:
53
+ """Provides CRUD operations for Agent instances.
54
+
55
+ This ViewSet manages Agent records, ensuring that users can only interact
56
+ with agents based on their permissions and organizational context.
57
+ It filters agent listings for users and handles the logic for creating
58
+ agents, including associating them with the correct organization and owner.
59
+
60
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
61
+ Auth0 authentication is supported as fallback for web dashboard use.
62
+
63
+ Permissions are based on IsAuthenticated, with queryset filtering providing
64
+ row-level access control.
65
+
66
+ Class Attributes:
67
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
68
+ This is further filtered by `get_queryset()`.
69
+ serializer_class (AgentSerializer): The serializer used for validating and
70
+ deserializing input, and for serializing output.
71
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
72
+ permission_classes (list): List of permission classes to use.
73
+ parser_classes (list): List of parser classes for handling request data.
74
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
75
+
76
+ Args:
77
+ id (UUID):
78
+
79
+ Raises:
80
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
81
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
82
+
83
+ Returns:
84
+ Response[Agent]
85
+ """
86
+
87
+ kwargs = _get_kwargs(
88
+ id=id,
89
+ )
90
+
91
+ response = client.get_httpx_client().request(
92
+ **kwargs,
93
+ )
94
+
95
+ return _build_response(client=client, response=response)
96
+
97
+
98
+ def sync(
99
+ id: UUID,
100
+ *,
101
+ client: AuthenticatedClient,
102
+ ) -> Optional[Agent]:
103
+ """Provides CRUD operations for Agent instances.
104
+
105
+ This ViewSet manages Agent records, ensuring that users can only interact
106
+ with agents based on their permissions and organizational context.
107
+ It filters agent listings for users and handles the logic for creating
108
+ agents, including associating them with the correct organization and owner.
109
+
110
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
111
+ Auth0 authentication is supported as fallback for web dashboard use.
112
+
113
+ Permissions are based on IsAuthenticated, with queryset filtering providing
114
+ row-level access control.
115
+
116
+ Class Attributes:
117
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
118
+ This is further filtered by `get_queryset()`.
119
+ serializer_class (AgentSerializer): The serializer used for validating and
120
+ deserializing input, and for serializing output.
121
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
122
+ permission_classes (list): List of permission classes to use.
123
+ parser_classes (list): List of parser classes for handling request data.
124
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
125
+
126
+ Args:
127
+ id (UUID):
128
+
129
+ Raises:
130
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
131
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
132
+
133
+ Returns:
134
+ Agent
135
+ """
136
+
137
+ return sync_detailed(
138
+ id=id,
139
+ client=client,
140
+ ).parsed
141
+
142
+
143
+ async def asyncio_detailed(
144
+ id: UUID,
145
+ *,
146
+ client: AuthenticatedClient,
147
+ ) -> Response[Agent]:
148
+ """Provides CRUD operations for Agent instances.
149
+
150
+ This ViewSet manages Agent records, ensuring that users can only interact
151
+ with agents based on their permissions and organizational context.
152
+ It filters agent listings for users and handles the logic for creating
153
+ agents, including associating them with the correct organization and owner.
154
+
155
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
156
+ Auth0 authentication is supported as fallback for web dashboard use.
157
+
158
+ Permissions are based on IsAuthenticated, with queryset filtering providing
159
+ row-level access control.
160
+
161
+ Class Attributes:
162
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
163
+ This is further filtered by `get_queryset()`.
164
+ serializer_class (AgentSerializer): The serializer used for validating and
165
+ deserializing input, and for serializing output.
166
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
167
+ permission_classes (list): List of permission classes to use.
168
+ parser_classes (list): List of parser classes for handling request data.
169
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
170
+
171
+ Args:
172
+ id (UUID):
173
+
174
+ Raises:
175
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
176
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
177
+
178
+ Returns:
179
+ Response[Agent]
180
+ """
181
+
182
+ kwargs = _get_kwargs(
183
+ id=id,
184
+ )
185
+
186
+ response = await client.get_async_httpx_client().request(**kwargs)
187
+
188
+ return _build_response(client=client, response=response)
189
+
190
+
191
+ async def asyncio(
192
+ id: UUID,
193
+ *,
194
+ client: AuthenticatedClient,
195
+ ) -> Optional[Agent]:
196
+ """Provides CRUD operations for Agent instances.
197
+
198
+ This ViewSet manages Agent records, ensuring that users can only interact
199
+ with agents based on their permissions and organizational context.
200
+ It filters agent listings for users and handles the logic for creating
201
+ agents, including associating them with the correct organization and owner.
202
+
203
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
204
+ Auth0 authentication is supported as fallback for web dashboard use.
205
+
206
+ Permissions are based on IsAuthenticated, with queryset filtering providing
207
+ row-level access control.
208
+
209
+ Class Attributes:
210
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
211
+ This is further filtered by `get_queryset()`.
212
+ serializer_class (AgentSerializer): The serializer used for validating and
213
+ deserializing input, and for serializing output.
214
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
215
+ permission_classes (list): List of permission classes to use.
216
+ parser_classes (list): List of parser classes for handling request data.
217
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
218
+
219
+ Args:
220
+ id (UUID):
221
+
222
+ Raises:
223
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
224
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
225
+
226
+ Returns:
227
+ Agent
228
+ """
229
+
230
+ return (
231
+ await asyncio_detailed(
232
+ id=id,
233
+ client=client,
234
+ )
235
+ ).parsed