hackagent 0.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.
Files changed (117) hide show
  1. hackagent/__init__.py +23 -0
  2. hackagent/agent.py +193 -0
  3. hackagent/api/__init__.py +1 -0
  4. hackagent/api/agent/__init__.py +1 -0
  5. hackagent/api/agent/agent_create.py +340 -0
  6. hackagent/api/agent/agent_destroy.py +136 -0
  7. hackagent/api/agent/agent_list.py +234 -0
  8. hackagent/api/agent/agent_partial_update.py +354 -0
  9. hackagent/api/agent/agent_retrieve.py +227 -0
  10. hackagent/api/agent/agent_update.py +354 -0
  11. hackagent/api/attack/__init__.py +1 -0
  12. hackagent/api/attack/attack_create.py +264 -0
  13. hackagent/api/attack/attack_destroy.py +140 -0
  14. hackagent/api/attack/attack_list.py +242 -0
  15. hackagent/api/attack/attack_partial_update.py +278 -0
  16. hackagent/api/attack/attack_retrieve.py +235 -0
  17. hackagent/api/attack/attack_update.py +278 -0
  18. hackagent/api/key/__init__.py +1 -0
  19. hackagent/api/key/key_create.py +168 -0
  20. hackagent/api/key/key_destroy.py +97 -0
  21. hackagent/api/key/key_list.py +158 -0
  22. hackagent/api/key/key_retrieve.py +150 -0
  23. hackagent/api/prompt/__init__.py +1 -0
  24. hackagent/api/prompt/prompt_create.py +160 -0
  25. hackagent/api/prompt/prompt_destroy.py +98 -0
  26. hackagent/api/prompt/prompt_list.py +173 -0
  27. hackagent/api/prompt/prompt_partial_update.py +174 -0
  28. hackagent/api/prompt/prompt_retrieve.py +151 -0
  29. hackagent/api/prompt/prompt_update.py +174 -0
  30. hackagent/api/result/__init__.py +1 -0
  31. hackagent/api/result/result_create.py +160 -0
  32. hackagent/api/result/result_destroy.py +98 -0
  33. hackagent/api/result/result_list.py +233 -0
  34. hackagent/api/result/result_partial_update.py +178 -0
  35. hackagent/api/result/result_retrieve.py +151 -0
  36. hackagent/api/result/result_trace_create.py +178 -0
  37. hackagent/api/result/result_update.py +174 -0
  38. hackagent/api/run/__init__.py +1 -0
  39. hackagent/api/run/run_create.py +172 -0
  40. hackagent/api/run/run_destroy.py +104 -0
  41. hackagent/api/run/run_list.py +260 -0
  42. hackagent/api/run/run_partial_update.py +186 -0
  43. hackagent/api/run/run_result_create.py +178 -0
  44. hackagent/api/run/run_retrieve.py +163 -0
  45. hackagent/api/run/run_run_tests_create.py +172 -0
  46. hackagent/api/run/run_update.py +186 -0
  47. hackagent/attacks/AdvPrefix/README.md +7 -0
  48. hackagent/attacks/AdvPrefix/__init__.py +0 -0
  49. hackagent/attacks/AdvPrefix/completer.py +438 -0
  50. hackagent/attacks/AdvPrefix/config.py +59 -0
  51. hackagent/attacks/AdvPrefix/preprocessing.py +521 -0
  52. hackagent/attacks/AdvPrefix/scorer.py +259 -0
  53. hackagent/attacks/AdvPrefix/scorer_parser.py +498 -0
  54. hackagent/attacks/AdvPrefix/selector.py +246 -0
  55. hackagent/attacks/AdvPrefix/step1_generate.py +324 -0
  56. hackagent/attacks/AdvPrefix/step4_compute_ce.py +293 -0
  57. hackagent/attacks/AdvPrefix/step6_get_completions.py +387 -0
  58. hackagent/attacks/AdvPrefix/step7_evaluate_responses.py +289 -0
  59. hackagent/attacks/AdvPrefix/step8_aggregate_evaluations.py +177 -0
  60. hackagent/attacks/AdvPrefix/step9_select_prefixes.py +59 -0
  61. hackagent/attacks/AdvPrefix/utils.py +192 -0
  62. hackagent/attacks/__init__.py +6 -0
  63. hackagent/attacks/advprefix.py +1136 -0
  64. hackagent/attacks/base.py +50 -0
  65. hackagent/attacks/strategies.py +539 -0
  66. hackagent/branding.py +143 -0
  67. hackagent/client.py +328 -0
  68. hackagent/errors.py +31 -0
  69. hackagent/logger.py +67 -0
  70. hackagent/models/__init__.py +71 -0
  71. hackagent/models/agent.py +240 -0
  72. hackagent/models/agent_request.py +169 -0
  73. hackagent/models/agent_type_enum.py +12 -0
  74. hackagent/models/attack.py +154 -0
  75. hackagent/models/attack_request.py +82 -0
  76. hackagent/models/evaluation_status_enum.py +14 -0
  77. hackagent/models/organization_minimal.py +68 -0
  78. hackagent/models/paginated_agent_list.py +123 -0
  79. hackagent/models/paginated_attack_list.py +123 -0
  80. hackagent/models/paginated_prompt_list.py +123 -0
  81. hackagent/models/paginated_result_list.py +123 -0
  82. hackagent/models/paginated_run_list.py +123 -0
  83. hackagent/models/paginated_user_api_key_list.py +123 -0
  84. hackagent/models/patched_agent_request.py +176 -0
  85. hackagent/models/patched_attack_request.py +92 -0
  86. hackagent/models/patched_prompt_request.py +162 -0
  87. hackagent/models/patched_result_request.py +237 -0
  88. hackagent/models/patched_run_request.py +138 -0
  89. hackagent/models/prompt.py +226 -0
  90. hackagent/models/prompt_request.py +155 -0
  91. hackagent/models/result.py +294 -0
  92. hackagent/models/result_list_evaluation_status.py +14 -0
  93. hackagent/models/result_request.py +232 -0
  94. hackagent/models/run.py +233 -0
  95. hackagent/models/run_list_status.py +12 -0
  96. hackagent/models/run_request.py +133 -0
  97. hackagent/models/status_enum.py +12 -0
  98. hackagent/models/step_type_enum.py +14 -0
  99. hackagent/models/trace.py +121 -0
  100. hackagent/models/trace_request.py +94 -0
  101. hackagent/models/user_api_key.py +201 -0
  102. hackagent/models/user_api_key_request.py +73 -0
  103. hackagent/models/user_profile_minimal.py +76 -0
  104. hackagent/py.typed +1 -0
  105. hackagent/router/__init__.py +11 -0
  106. hackagent/router/adapters/__init__.py +5 -0
  107. hackagent/router/adapters/google_adk.py +658 -0
  108. hackagent/router/adapters/litellm_adapter.py +290 -0
  109. hackagent/router/base.py +48 -0
  110. hackagent/router/router.py +753 -0
  111. hackagent/types.py +46 -0
  112. hackagent/utils.py +61 -0
  113. hackagent/vulnerabilities/__init__.py +0 -0
  114. hackagent-0.1.0.dist-info/LICENSE +202 -0
  115. hackagent-0.1.0.dist-info/METADATA +173 -0
  116. hackagent-0.1.0.dist-info/RECORD +117 -0
  117. hackagent-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,136 @@
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 ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ id: UUID,
14
+ ) -> dict[str, Any]:
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "delete",
17
+ "url": f"/api/agent/{id}",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
25
+ ) -> Optional[Any]:
26
+ if response.status_code == 204:
27
+ return None
28
+ if client.raise_on_unexpected_status:
29
+ raise errors.UnexpectedStatus(response.status_code, response.content)
30
+ else:
31
+ return None
32
+
33
+
34
+ def _build_response(
35
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
36
+ ) -> Response[Any]:
37
+ return Response(
38
+ status_code=HTTPStatus(response.status_code),
39
+ content=response.content,
40
+ headers=response.headers,
41
+ parsed=_parse_response(client=client, response=response),
42
+ )
43
+
44
+
45
+ def sync_detailed(
46
+ id: UUID,
47
+ *,
48
+ client: AuthenticatedClient,
49
+ ) -> Response[Any]:
50
+ """Provides CRUD operations for Agent instances.
51
+
52
+ This ViewSet manages Agent records, ensuring that users can only interact
53
+ with agents based on their permissions and organizational context.
54
+ It filters agent listings for users and handles the logic for creating
55
+ agents, including associating them with the correct organization and owner.
56
+
57
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
58
+ Permissions are based on IsAuthenticated, with queryset filtering providing
59
+ row-level access control.
60
+
61
+ Class Attributes:
62
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
63
+ This is further filtered by `get_queryset()`.
64
+ serializer_class (AgentSerializer): The serializer used for validating and
65
+ deserializing input, and for serializing output.
66
+ authentication_classes (list): List of authentication classes to use.
67
+ permission_classes (list): List of permission classes to use.
68
+ parser_classes (list): List of parser classes for handling request data.
69
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
70
+
71
+ Args:
72
+ id (UUID):
73
+
74
+ Raises:
75
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
76
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
77
+
78
+ Returns:
79
+ Response[Any]
80
+ """
81
+
82
+ kwargs = _get_kwargs(
83
+ id=id,
84
+ )
85
+
86
+ response = client.get_httpx_client().request(
87
+ **kwargs,
88
+ )
89
+
90
+ return _build_response(client=client, response=response)
91
+
92
+
93
+ async def asyncio_detailed(
94
+ id: UUID,
95
+ *,
96
+ client: AuthenticatedClient,
97
+ ) -> Response[Any]:
98
+ """Provides CRUD operations for Agent instances.
99
+
100
+ This ViewSet manages Agent records, ensuring that users can only interact
101
+ with agents based on their permissions and organizational context.
102
+ It filters agent listings for users and handles the logic for creating
103
+ agents, including associating them with the correct organization and owner.
104
+
105
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
106
+ Permissions are based on IsAuthenticated, with queryset filtering providing
107
+ row-level access control.
108
+
109
+ Class Attributes:
110
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
111
+ This is further filtered by `get_queryset()`.
112
+ serializer_class (AgentSerializer): The serializer used for validating and
113
+ deserializing input, and for serializing output.
114
+ authentication_classes (list): List of authentication classes to use.
115
+ permission_classes (list): List of permission classes to use.
116
+ parser_classes (list): List of parser classes for handling request data.
117
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
118
+
119
+ Args:
120
+ id (UUID):
121
+
122
+ Raises:
123
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
124
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
125
+
126
+ Returns:
127
+ Response[Any]
128
+ """
129
+
130
+ kwargs = _get_kwargs(
131
+ id=id,
132
+ )
133
+
134
+ response = await client.get_async_httpx_client().request(**kwargs)
135
+
136
+ return _build_response(client=client, response=response)
@@ -0,0 +1,234 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.paginated_agent_list import PaginatedAgentList
9
+ from ...types import UNSET, Response, Unset
10
+
11
+
12
+ def _get_kwargs(
13
+ *,
14
+ page: Union[Unset, int] = UNSET,
15
+ ) -> dict[str, Any]:
16
+ params: dict[str, Any] = {}
17
+
18
+ params["page"] = page
19
+
20
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
21
+
22
+ _kwargs: dict[str, Any] = {
23
+ "method": "get",
24
+ "url": "/api/agent",
25
+ "params": params,
26
+ }
27
+
28
+ return _kwargs
29
+
30
+
31
+ def _parse_response(
32
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
33
+ ) -> Optional[PaginatedAgentList]:
34
+ if response.status_code == 200:
35
+ response_200 = PaginatedAgentList.from_dict(response.json())
36
+
37
+ return response_200
38
+ if client.raise_on_unexpected_status:
39
+ raise errors.UnexpectedStatus(response.status_code, response.content)
40
+ else:
41
+ return None
42
+
43
+
44
+ def _build_response(
45
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
46
+ ) -> Response[PaginatedAgentList]:
47
+ return Response(
48
+ status_code=HTTPStatus(response.status_code),
49
+ content=response.content,
50
+ headers=response.headers,
51
+ parsed=_parse_response(client=client, response=response),
52
+ )
53
+
54
+
55
+ def sync_detailed(
56
+ *,
57
+ client: AuthenticatedClient,
58
+ page: Union[Unset, int] = UNSET,
59
+ ) -> Response[PaginatedAgentList]:
60
+ """Provides CRUD operations for Agent instances.
61
+
62
+ This ViewSet manages Agent records, ensuring that users can only interact
63
+ with agents based on their permissions and organizational context.
64
+ It filters agent listings for users and handles the logic for creating
65
+ agents, including associating them with the correct organization and owner.
66
+
67
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
68
+ Permissions are based on IsAuthenticated, with queryset filtering providing
69
+ row-level access control.
70
+
71
+ Class Attributes:
72
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
73
+ This is further filtered by `get_queryset()`.
74
+ serializer_class (AgentSerializer): The serializer used for validating and
75
+ deserializing input, and for serializing output.
76
+ authentication_classes (list): List of authentication classes to use.
77
+ permission_classes (list): List of permission classes to use.
78
+ parser_classes (list): List of parser classes for handling request data.
79
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
80
+
81
+ Args:
82
+ page (Union[Unset, int]):
83
+
84
+ Raises:
85
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
86
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
87
+
88
+ Returns:
89
+ Response[PaginatedAgentList]
90
+ """
91
+
92
+ kwargs = _get_kwargs(
93
+ page=page,
94
+ )
95
+
96
+ response = client.get_httpx_client().request(
97
+ **kwargs,
98
+ )
99
+
100
+ return _build_response(client=client, response=response)
101
+
102
+
103
+ def sync(
104
+ *,
105
+ client: AuthenticatedClient,
106
+ page: Union[Unset, int] = UNSET,
107
+ ) -> Optional[PaginatedAgentList]:
108
+ """Provides CRUD operations for Agent instances.
109
+
110
+ This ViewSet manages Agent records, ensuring that users can only interact
111
+ with agents based on their permissions and organizational context.
112
+ It filters agent listings for users and handles the logic for creating
113
+ agents, including associating them with the correct organization and owner.
114
+
115
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
116
+ Permissions are based on IsAuthenticated, with queryset filtering providing
117
+ row-level access control.
118
+
119
+ Class Attributes:
120
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
121
+ This is further filtered by `get_queryset()`.
122
+ serializer_class (AgentSerializer): The serializer used for validating and
123
+ deserializing input, and for serializing output.
124
+ authentication_classes (list): List of authentication classes to use.
125
+ permission_classes (list): List of permission classes to use.
126
+ parser_classes (list): List of parser classes for handling request data.
127
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
128
+
129
+ Args:
130
+ page (Union[Unset, int]):
131
+
132
+ Raises:
133
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
135
+
136
+ Returns:
137
+ PaginatedAgentList
138
+ """
139
+
140
+ return sync_detailed(
141
+ client=client,
142
+ page=page,
143
+ ).parsed
144
+
145
+
146
+ async def asyncio_detailed(
147
+ *,
148
+ client: AuthenticatedClient,
149
+ page: Union[Unset, int] = UNSET,
150
+ ) -> Response[PaginatedAgentList]:
151
+ """Provides CRUD operations for Agent instances.
152
+
153
+ This ViewSet manages Agent records, ensuring that users can only interact
154
+ with agents based on their permissions and organizational context.
155
+ It filters agent listings for users and handles the logic for creating
156
+ agents, including associating them with the correct organization and owner.
157
+
158
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
159
+ Permissions are based on IsAuthenticated, with queryset filtering providing
160
+ row-level access control.
161
+
162
+ Class Attributes:
163
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
164
+ This is further filtered by `get_queryset()`.
165
+ serializer_class (AgentSerializer): The serializer used for validating and
166
+ deserializing input, and for serializing output.
167
+ authentication_classes (list): List of authentication classes to use.
168
+ permission_classes (list): List of permission classes to use.
169
+ parser_classes (list): List of parser classes for handling request data.
170
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
171
+
172
+ Args:
173
+ page (Union[Unset, int]):
174
+
175
+ Raises:
176
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
177
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
178
+
179
+ Returns:
180
+ Response[PaginatedAgentList]
181
+ """
182
+
183
+ kwargs = _get_kwargs(
184
+ page=page,
185
+ )
186
+
187
+ response = await client.get_async_httpx_client().request(**kwargs)
188
+
189
+ return _build_response(client=client, response=response)
190
+
191
+
192
+ async def asyncio(
193
+ *,
194
+ client: AuthenticatedClient,
195
+ page: Union[Unset, int] = UNSET,
196
+ ) -> Optional[PaginatedAgentList]:
197
+ """Provides CRUD operations for Agent instances.
198
+
199
+ This ViewSet manages Agent records, ensuring that users can only interact
200
+ with agents based on their permissions and organizational context.
201
+ It filters agent listings for users and handles the logic for creating
202
+ agents, including associating them with the correct organization and owner.
203
+
204
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
205
+ Permissions are based on IsAuthenticated, with queryset filtering providing
206
+ row-level access control.
207
+
208
+ Class Attributes:
209
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
210
+ This is further filtered by `get_queryset()`.
211
+ serializer_class (AgentSerializer): The serializer used for validating and
212
+ deserializing input, and for serializing output.
213
+ authentication_classes (list): List of authentication classes to use.
214
+ permission_classes (list): List of permission classes to use.
215
+ parser_classes (list): List of parser classes for handling request data.
216
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
217
+
218
+ Args:
219
+ page (Union[Unset, int]):
220
+
221
+ Raises:
222
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
223
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
224
+
225
+ Returns:
226
+ PaginatedAgentList
227
+ """
228
+
229
+ return (
230
+ await asyncio_detailed(
231
+ client=client,
232
+ page=page,
233
+ )
234
+ ).parsed