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.
- hackagent/__init__.py +23 -0
- hackagent/agent.py +193 -0
- hackagent/api/__init__.py +1 -0
- hackagent/api/agent/__init__.py +1 -0
- hackagent/api/agent/agent_create.py +340 -0
- hackagent/api/agent/agent_destroy.py +136 -0
- hackagent/api/agent/agent_list.py +234 -0
- hackagent/api/agent/agent_partial_update.py +354 -0
- hackagent/api/agent/agent_retrieve.py +227 -0
- hackagent/api/agent/agent_update.py +354 -0
- hackagent/api/attack/__init__.py +1 -0
- hackagent/api/attack/attack_create.py +264 -0
- hackagent/api/attack/attack_destroy.py +140 -0
- hackagent/api/attack/attack_list.py +242 -0
- hackagent/api/attack/attack_partial_update.py +278 -0
- hackagent/api/attack/attack_retrieve.py +235 -0
- hackagent/api/attack/attack_update.py +278 -0
- hackagent/api/key/__init__.py +1 -0
- hackagent/api/key/key_create.py +168 -0
- hackagent/api/key/key_destroy.py +97 -0
- hackagent/api/key/key_list.py +158 -0
- hackagent/api/key/key_retrieve.py +150 -0
- hackagent/api/prompt/__init__.py +1 -0
- hackagent/api/prompt/prompt_create.py +160 -0
- hackagent/api/prompt/prompt_destroy.py +98 -0
- hackagent/api/prompt/prompt_list.py +173 -0
- hackagent/api/prompt/prompt_partial_update.py +174 -0
- hackagent/api/prompt/prompt_retrieve.py +151 -0
- hackagent/api/prompt/prompt_update.py +174 -0
- hackagent/api/result/__init__.py +1 -0
- hackagent/api/result/result_create.py +160 -0
- hackagent/api/result/result_destroy.py +98 -0
- hackagent/api/result/result_list.py +233 -0
- hackagent/api/result/result_partial_update.py +178 -0
- hackagent/api/result/result_retrieve.py +151 -0
- hackagent/api/result/result_trace_create.py +178 -0
- hackagent/api/result/result_update.py +174 -0
- hackagent/api/run/__init__.py +1 -0
- hackagent/api/run/run_create.py +172 -0
- hackagent/api/run/run_destroy.py +104 -0
- hackagent/api/run/run_list.py +260 -0
- hackagent/api/run/run_partial_update.py +186 -0
- hackagent/api/run/run_result_create.py +178 -0
- hackagent/api/run/run_retrieve.py +163 -0
- hackagent/api/run/run_run_tests_create.py +172 -0
- hackagent/api/run/run_update.py +186 -0
- hackagent/attacks/AdvPrefix/README.md +7 -0
- hackagent/attacks/AdvPrefix/__init__.py +0 -0
- hackagent/attacks/AdvPrefix/completer.py +438 -0
- hackagent/attacks/AdvPrefix/config.py +59 -0
- hackagent/attacks/AdvPrefix/preprocessing.py +521 -0
- hackagent/attacks/AdvPrefix/scorer.py +259 -0
- hackagent/attacks/AdvPrefix/scorer_parser.py +498 -0
- hackagent/attacks/AdvPrefix/selector.py +246 -0
- hackagent/attacks/AdvPrefix/step1_generate.py +324 -0
- hackagent/attacks/AdvPrefix/step4_compute_ce.py +293 -0
- hackagent/attacks/AdvPrefix/step6_get_completions.py +387 -0
- hackagent/attacks/AdvPrefix/step7_evaluate_responses.py +289 -0
- hackagent/attacks/AdvPrefix/step8_aggregate_evaluations.py +177 -0
- hackagent/attacks/AdvPrefix/step9_select_prefixes.py +59 -0
- hackagent/attacks/AdvPrefix/utils.py +192 -0
- hackagent/attacks/__init__.py +6 -0
- hackagent/attacks/advprefix.py +1136 -0
- hackagent/attacks/base.py +50 -0
- hackagent/attacks/strategies.py +539 -0
- hackagent/branding.py +143 -0
- hackagent/client.py +328 -0
- hackagent/errors.py +31 -0
- hackagent/logger.py +67 -0
- hackagent/models/__init__.py +71 -0
- hackagent/models/agent.py +240 -0
- hackagent/models/agent_request.py +169 -0
- hackagent/models/agent_type_enum.py +12 -0
- hackagent/models/attack.py +154 -0
- hackagent/models/attack_request.py +82 -0
- hackagent/models/evaluation_status_enum.py +14 -0
- hackagent/models/organization_minimal.py +68 -0
- hackagent/models/paginated_agent_list.py +123 -0
- hackagent/models/paginated_attack_list.py +123 -0
- hackagent/models/paginated_prompt_list.py +123 -0
- hackagent/models/paginated_result_list.py +123 -0
- hackagent/models/paginated_run_list.py +123 -0
- hackagent/models/paginated_user_api_key_list.py +123 -0
- hackagent/models/patched_agent_request.py +176 -0
- hackagent/models/patched_attack_request.py +92 -0
- hackagent/models/patched_prompt_request.py +162 -0
- hackagent/models/patched_result_request.py +237 -0
- hackagent/models/patched_run_request.py +138 -0
- hackagent/models/prompt.py +226 -0
- hackagent/models/prompt_request.py +155 -0
- hackagent/models/result.py +294 -0
- hackagent/models/result_list_evaluation_status.py +14 -0
- hackagent/models/result_request.py +232 -0
- hackagent/models/run.py +233 -0
- hackagent/models/run_list_status.py +12 -0
- hackagent/models/run_request.py +133 -0
- hackagent/models/status_enum.py +12 -0
- hackagent/models/step_type_enum.py +14 -0
- hackagent/models/trace.py +121 -0
- hackagent/models/trace_request.py +94 -0
- hackagent/models/user_api_key.py +201 -0
- hackagent/models/user_api_key_request.py +73 -0
- hackagent/models/user_profile_minimal.py +76 -0
- hackagent/py.typed +1 -0
- hackagent/router/__init__.py +11 -0
- hackagent/router/adapters/__init__.py +5 -0
- hackagent/router/adapters/google_adk.py +658 -0
- hackagent/router/adapters/litellm_adapter.py +290 -0
- hackagent/router/base.py +48 -0
- hackagent/router/router.py +753 -0
- hackagent/types.py +46 -0
- hackagent/utils.py +61 -0
- hackagent/vulnerabilities/__init__.py +0 -0
- hackagent-0.1.0.dist-info/LICENSE +202 -0
- hackagent-0.1.0.dist-info/METADATA +173 -0
- hackagent-0.1.0.dist-info/RECORD +117 -0
- hackagent-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from collections.abc import Mapping
|
|
3
|
+
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
from dateutil.parser import isoparse
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from ..models.organization_minimal import OrganizationMinimal
|
|
12
|
+
from ..models.user_profile_minimal import UserProfileMinimal
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
T = TypeVar("T", bound="UserAPIKey")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@_attrs_define
|
|
19
|
+
class UserAPIKey:
|
|
20
|
+
"""Serializer for User API Keys.
|
|
21
|
+
Exposes read-only information about the key, including its prefix.
|
|
22
|
+
The full key is only shown once upon creation by the ViewSet.
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
id (str):
|
|
26
|
+
name (str): A human-readable name for the API key.
|
|
27
|
+
prefix (str):
|
|
28
|
+
created (datetime.datetime):
|
|
29
|
+
revoked (bool): If the API key is revoked, clients cannot use it anymore. (This cannot be undone.)
|
|
30
|
+
expiry_date (Union[None, datetime.datetime]): Once API key expires, clients cannot use it anymore.
|
|
31
|
+
user (int):
|
|
32
|
+
user_detail (Union['UserProfileMinimal', None]):
|
|
33
|
+
organization (UUID):
|
|
34
|
+
organization_detail (Union['OrganizationMinimal', None]):
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
id: str
|
|
38
|
+
name: str
|
|
39
|
+
prefix: str
|
|
40
|
+
created: datetime.datetime
|
|
41
|
+
revoked: bool
|
|
42
|
+
expiry_date: Union[None, datetime.datetime]
|
|
43
|
+
user: int
|
|
44
|
+
user_detail: Union["UserProfileMinimal", None]
|
|
45
|
+
organization: UUID
|
|
46
|
+
organization_detail: Union["OrganizationMinimal", None]
|
|
47
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
48
|
+
|
|
49
|
+
def to_dict(self) -> dict[str, Any]:
|
|
50
|
+
from ..models.organization_minimal import OrganizationMinimal
|
|
51
|
+
from ..models.user_profile_minimal import UserProfileMinimal
|
|
52
|
+
|
|
53
|
+
id = self.id
|
|
54
|
+
|
|
55
|
+
name = self.name
|
|
56
|
+
|
|
57
|
+
prefix = self.prefix
|
|
58
|
+
|
|
59
|
+
created = self.created.isoformat()
|
|
60
|
+
|
|
61
|
+
revoked = self.revoked
|
|
62
|
+
|
|
63
|
+
expiry_date: Union[None, str]
|
|
64
|
+
if isinstance(self.expiry_date, datetime.datetime):
|
|
65
|
+
expiry_date = self.expiry_date.isoformat()
|
|
66
|
+
else:
|
|
67
|
+
expiry_date = self.expiry_date
|
|
68
|
+
|
|
69
|
+
user = self.user
|
|
70
|
+
|
|
71
|
+
user_detail: Union[None, dict[str, Any]]
|
|
72
|
+
if isinstance(self.user_detail, UserProfileMinimal):
|
|
73
|
+
user_detail = self.user_detail.to_dict()
|
|
74
|
+
else:
|
|
75
|
+
user_detail = self.user_detail
|
|
76
|
+
|
|
77
|
+
organization = str(self.organization)
|
|
78
|
+
|
|
79
|
+
organization_detail: Union[None, dict[str, Any]]
|
|
80
|
+
if isinstance(self.organization_detail, OrganizationMinimal):
|
|
81
|
+
organization_detail = self.organization_detail.to_dict()
|
|
82
|
+
else:
|
|
83
|
+
organization_detail = self.organization_detail
|
|
84
|
+
|
|
85
|
+
field_dict: dict[str, Any] = {}
|
|
86
|
+
field_dict.update(self.additional_properties)
|
|
87
|
+
field_dict.update(
|
|
88
|
+
{
|
|
89
|
+
"id": id,
|
|
90
|
+
"name": name,
|
|
91
|
+
"prefix": prefix,
|
|
92
|
+
"created": created,
|
|
93
|
+
"revoked": revoked,
|
|
94
|
+
"expiry_date": expiry_date,
|
|
95
|
+
"user": user,
|
|
96
|
+
"user_detail": user_detail,
|
|
97
|
+
"organization": organization,
|
|
98
|
+
"organization_detail": organization_detail,
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
return field_dict
|
|
103
|
+
|
|
104
|
+
@classmethod
|
|
105
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
106
|
+
from ..models.organization_minimal import OrganizationMinimal
|
|
107
|
+
from ..models.user_profile_minimal import UserProfileMinimal
|
|
108
|
+
|
|
109
|
+
d = dict(src_dict)
|
|
110
|
+
id = d.pop("id")
|
|
111
|
+
|
|
112
|
+
name = d.pop("name")
|
|
113
|
+
|
|
114
|
+
prefix = d.pop("prefix")
|
|
115
|
+
|
|
116
|
+
created = isoparse(d.pop("created"))
|
|
117
|
+
|
|
118
|
+
revoked = d.pop("revoked")
|
|
119
|
+
|
|
120
|
+
def _parse_expiry_date(data: object) -> Union[None, datetime.datetime]:
|
|
121
|
+
if data is None:
|
|
122
|
+
return data
|
|
123
|
+
try:
|
|
124
|
+
if not isinstance(data, str):
|
|
125
|
+
raise TypeError()
|
|
126
|
+
expiry_date_type_0 = isoparse(data)
|
|
127
|
+
|
|
128
|
+
return expiry_date_type_0
|
|
129
|
+
except: # noqa: E722
|
|
130
|
+
pass
|
|
131
|
+
return cast(Union[None, datetime.datetime], data)
|
|
132
|
+
|
|
133
|
+
expiry_date = _parse_expiry_date(d.pop("expiry_date"))
|
|
134
|
+
|
|
135
|
+
user = d.pop("user")
|
|
136
|
+
|
|
137
|
+
def _parse_user_detail(data: object) -> Union["UserProfileMinimal", None]:
|
|
138
|
+
if data is None:
|
|
139
|
+
return data
|
|
140
|
+
try:
|
|
141
|
+
if not isinstance(data, dict):
|
|
142
|
+
raise TypeError()
|
|
143
|
+
user_detail_type_1 = UserProfileMinimal.from_dict(data)
|
|
144
|
+
|
|
145
|
+
return user_detail_type_1
|
|
146
|
+
except: # noqa: E722
|
|
147
|
+
pass
|
|
148
|
+
return cast(Union["UserProfileMinimal", None], data)
|
|
149
|
+
|
|
150
|
+
user_detail = _parse_user_detail(d.pop("user_detail"))
|
|
151
|
+
|
|
152
|
+
organization = UUID(d.pop("organization"))
|
|
153
|
+
|
|
154
|
+
def _parse_organization_detail(
|
|
155
|
+
data: object,
|
|
156
|
+
) -> Union["OrganizationMinimal", None]:
|
|
157
|
+
if data is None:
|
|
158
|
+
return data
|
|
159
|
+
try:
|
|
160
|
+
if not isinstance(data, dict):
|
|
161
|
+
raise TypeError()
|
|
162
|
+
organization_detail_type_1 = OrganizationMinimal.from_dict(data)
|
|
163
|
+
|
|
164
|
+
return organization_detail_type_1
|
|
165
|
+
except: # noqa: E722
|
|
166
|
+
pass
|
|
167
|
+
return cast(Union["OrganizationMinimal", None], data)
|
|
168
|
+
|
|
169
|
+
organization_detail = _parse_organization_detail(d.pop("organization_detail"))
|
|
170
|
+
|
|
171
|
+
user_api_key = cls(
|
|
172
|
+
id=id,
|
|
173
|
+
name=name,
|
|
174
|
+
prefix=prefix,
|
|
175
|
+
created=created,
|
|
176
|
+
revoked=revoked,
|
|
177
|
+
expiry_date=expiry_date,
|
|
178
|
+
user=user,
|
|
179
|
+
user_detail=user_detail,
|
|
180
|
+
organization=organization,
|
|
181
|
+
organization_detail=organization_detail,
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
user_api_key.additional_properties = d
|
|
185
|
+
return user_api_key
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def additional_keys(self) -> list[str]:
|
|
189
|
+
return list(self.additional_properties.keys())
|
|
190
|
+
|
|
191
|
+
def __getitem__(self, key: str) -> Any:
|
|
192
|
+
return self.additional_properties[key]
|
|
193
|
+
|
|
194
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
195
|
+
self.additional_properties[key] = value
|
|
196
|
+
|
|
197
|
+
def __delitem__(self, key: str) -> None:
|
|
198
|
+
del self.additional_properties[key]
|
|
199
|
+
|
|
200
|
+
def __contains__(self, key: str) -> bool:
|
|
201
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar, Union
|
|
3
|
+
|
|
4
|
+
from attrs import define as _attrs_define
|
|
5
|
+
from attrs import field as _attrs_field
|
|
6
|
+
|
|
7
|
+
from ..types import UNSET, Unset
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="UserAPIKeyRequest")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class UserAPIKeyRequest:
|
|
14
|
+
"""Serializer for User API Keys.
|
|
15
|
+
Exposes read-only information about the key, including its prefix.
|
|
16
|
+
The full key is only shown once upon creation by the ViewSet.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
name (str): A human-readable name for the API key.
|
|
20
|
+
key (Union[Unset, str]):
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
name: str
|
|
24
|
+
key: Union[Unset, str] = UNSET
|
|
25
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
26
|
+
|
|
27
|
+
def to_dict(self) -> dict[str, Any]:
|
|
28
|
+
name = self.name
|
|
29
|
+
|
|
30
|
+
key = self.key
|
|
31
|
+
|
|
32
|
+
field_dict: dict[str, Any] = {}
|
|
33
|
+
field_dict.update(self.additional_properties)
|
|
34
|
+
field_dict.update(
|
|
35
|
+
{
|
|
36
|
+
"name": name,
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
if key is not UNSET:
|
|
40
|
+
field_dict["key"] = key
|
|
41
|
+
|
|
42
|
+
return field_dict
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
46
|
+
d = dict(src_dict)
|
|
47
|
+
name = d.pop("name")
|
|
48
|
+
|
|
49
|
+
key = d.pop("key", UNSET)
|
|
50
|
+
|
|
51
|
+
user_api_key_request = cls(
|
|
52
|
+
name=name,
|
|
53
|
+
key=key,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
user_api_key_request.additional_properties = d
|
|
57
|
+
return user_api_key_request
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def additional_keys(self) -> list[str]:
|
|
61
|
+
return list(self.additional_properties.keys())
|
|
62
|
+
|
|
63
|
+
def __getitem__(self, key: str) -> Any:
|
|
64
|
+
return self.additional_properties[key]
|
|
65
|
+
|
|
66
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
67
|
+
self.additional_properties[key] = value
|
|
68
|
+
|
|
69
|
+
def __delitem__(self, key: str) -> None:
|
|
70
|
+
del self.additional_properties[key]
|
|
71
|
+
|
|
72
|
+
def __contains__(self, key: str) -> bool:
|
|
73
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
|
|
5
|
+
from attrs import define as _attrs_define
|
|
6
|
+
from attrs import field as _attrs_field
|
|
7
|
+
|
|
8
|
+
T = TypeVar("T", bound="UserProfileMinimal")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@_attrs_define
|
|
12
|
+
class UserProfileMinimal:
|
|
13
|
+
"""
|
|
14
|
+
Attributes:
|
|
15
|
+
user (int):
|
|
16
|
+
username (str):
|
|
17
|
+
organization (UUID):
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
user: int
|
|
21
|
+
username: str
|
|
22
|
+
organization: UUID
|
|
23
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
24
|
+
|
|
25
|
+
def to_dict(self) -> dict[str, Any]:
|
|
26
|
+
user = self.user
|
|
27
|
+
|
|
28
|
+
username = self.username
|
|
29
|
+
|
|
30
|
+
organization = str(self.organization)
|
|
31
|
+
|
|
32
|
+
field_dict: dict[str, Any] = {}
|
|
33
|
+
field_dict.update(self.additional_properties)
|
|
34
|
+
field_dict.update(
|
|
35
|
+
{
|
|
36
|
+
"user": user,
|
|
37
|
+
"username": username,
|
|
38
|
+
"organization": organization,
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return field_dict
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
46
|
+
d = dict(src_dict)
|
|
47
|
+
user = d.pop("user")
|
|
48
|
+
|
|
49
|
+
username = d.pop("username")
|
|
50
|
+
|
|
51
|
+
organization = UUID(d.pop("organization"))
|
|
52
|
+
|
|
53
|
+
user_profile_minimal = cls(
|
|
54
|
+
user=user,
|
|
55
|
+
username=username,
|
|
56
|
+
organization=organization,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
user_profile_minimal.additional_properties = d
|
|
60
|
+
return user_profile_minimal
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def additional_keys(self) -> list[str]:
|
|
64
|
+
return list(self.additional_properties.keys())
|
|
65
|
+
|
|
66
|
+
def __getitem__(self, key: str) -> Any:
|
|
67
|
+
return self.additional_properties[key]
|
|
68
|
+
|
|
69
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
70
|
+
self.additional_properties[key] = value
|
|
71
|
+
|
|
72
|
+
def __delitem__(self, key: str) -> None:
|
|
73
|
+
del self.additional_properties[key]
|
|
74
|
+
|
|
75
|
+
def __contains__(self, key: str) -> bool:
|
|
76
|
+
return key in self.additional_properties
|
hackagent/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Marker file for PEP 561
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Main router logic for dispatching requests to appropriate agent adapters."""
|
|
2
|
+
|
|
3
|
+
from .router import AgentRouter
|
|
4
|
+
from .adapters import (
|
|
5
|
+
ADKAgentAdapter,
|
|
6
|
+
) # This makes it easy to access adapters via router module
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"AgentRouter",
|
|
10
|
+
"ADKAgentAdapter", # Exporting specific adapters for convenience
|
|
11
|
+
]
|