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.
- hackagent/__init__.py +12 -0
- hackagent/agent.py +214 -0
- hackagent/api/__init__.py +1 -0
- hackagent/api/agent/__init__.py +1 -0
- hackagent/api/agent/agent_create.py +347 -0
- hackagent/api/agent/agent_destroy.py +140 -0
- hackagent/api/agent/agent_list.py +242 -0
- hackagent/api/agent/agent_partial_update.py +361 -0
- hackagent/api/agent/agent_retrieve.py +235 -0
- hackagent/api/agent/agent_update.py +361 -0
- hackagent/api/apilogs/__init__.py +1 -0
- hackagent/api/apilogs/apilogs_list.py +170 -0
- hackagent/api/apilogs/apilogs_retrieve.py +162 -0
- hackagent/api/attack/__init__.py +1 -0
- hackagent/api/attack/attack_create.py +275 -0
- hackagent/api/attack/attack_destroy.py +146 -0
- hackagent/api/attack/attack_list.py +254 -0
- hackagent/api/attack/attack_partial_update.py +289 -0
- hackagent/api/attack/attack_retrieve.py +247 -0
- hackagent/api/attack/attack_update.py +289 -0
- hackagent/api/checkout/__init__.py +1 -0
- hackagent/api/checkout/checkout_create.py +225 -0
- hackagent/api/generate/__init__.py +1 -0
- hackagent/api/generate/generate_create.py +253 -0
- hackagent/api/judge/__init__.py +1 -0
- hackagent/api/judge/judge_create.py +253 -0
- hackagent/api/key/__init__.py +1 -0
- hackagent/api/key/key_create.py +179 -0
- hackagent/api/key/key_destroy.py +103 -0
- hackagent/api/key/key_list.py +170 -0
- hackagent/api/key/key_retrieve.py +162 -0
- hackagent/api/organization/__init__.py +1 -0
- hackagent/api/organization/organization_create.py +208 -0
- hackagent/api/organization/organization_destroy.py +104 -0
- hackagent/api/organization/organization_list.py +170 -0
- hackagent/api/organization/organization_me_retrieve.py +126 -0
- hackagent/api/organization/organization_partial_update.py +222 -0
- hackagent/api/organization/organization_retrieve.py +163 -0
- hackagent/api/organization/organization_update.py +222 -0
- hackagent/api/prompt/__init__.py +1 -0
- hackagent/api/prompt/prompt_create.py +171 -0
- hackagent/api/prompt/prompt_destroy.py +104 -0
- hackagent/api/prompt/prompt_list.py +185 -0
- hackagent/api/prompt/prompt_partial_update.py +185 -0
- hackagent/api/prompt/prompt_retrieve.py +163 -0
- hackagent/api/prompt/prompt_update.py +185 -0
- hackagent/api/result/__init__.py +1 -0
- hackagent/api/result/result_create.py +175 -0
- hackagent/api/result/result_destroy.py +106 -0
- hackagent/api/result/result_list.py +249 -0
- hackagent/api/result/result_partial_update.py +193 -0
- hackagent/api/result/result_retrieve.py +167 -0
- hackagent/api/result/result_trace_create.py +177 -0
- hackagent/api/result/result_update.py +189 -0
- hackagent/api/run/__init__.py +1 -0
- hackagent/api/run/run_create.py +187 -0
- hackagent/api/run/run_destroy.py +112 -0
- hackagent/api/run/run_list.py +291 -0
- hackagent/api/run/run_partial_update.py +201 -0
- hackagent/api/run/run_result_create.py +177 -0
- hackagent/api/run/run_retrieve.py +179 -0
- hackagent/api/run/run_run_tests_create.py +187 -0
- hackagent/api/run/run_update.py +201 -0
- hackagent/api/user/__init__.py +1 -0
- hackagent/api/user/user_create.py +212 -0
- hackagent/api/user/user_destroy.py +106 -0
- hackagent/api/user/user_list.py +174 -0
- hackagent/api/user/user_me_retrieve.py +126 -0
- hackagent/api/user/user_me_update.py +196 -0
- hackagent/api/user/user_partial_update.py +226 -0
- hackagent/api/user/user_retrieve.py +167 -0
- hackagent/api/user/user_update.py +226 -0
- hackagent/attacks/AdvPrefix/__init__.py +41 -0
- hackagent/attacks/AdvPrefix/completions.py +416 -0
- hackagent/attacks/AdvPrefix/config.py +259 -0
- hackagent/attacks/AdvPrefix/evaluation.py +745 -0
- hackagent/attacks/AdvPrefix/evaluators.py +564 -0
- hackagent/attacks/AdvPrefix/generate.py +711 -0
- hackagent/attacks/AdvPrefix/utils.py +307 -0
- hackagent/attacks/__init__.py +35 -0
- hackagent/attacks/advprefix.py +507 -0
- hackagent/attacks/base.py +106 -0
- hackagent/attacks/strategies.py +906 -0
- hackagent/cli/__init__.py +19 -0
- hackagent/cli/commands/__init__.py +20 -0
- hackagent/cli/commands/agent.py +100 -0
- hackagent/cli/commands/attack.py +417 -0
- hackagent/cli/commands/config.py +301 -0
- hackagent/cli/commands/results.py +327 -0
- hackagent/cli/config.py +249 -0
- hackagent/cli/main.py +515 -0
- hackagent/cli/tui/__init__.py +31 -0
- hackagent/cli/tui/actions_logger.py +200 -0
- hackagent/cli/tui/app.py +288 -0
- hackagent/cli/tui/base.py +137 -0
- hackagent/cli/tui/logger.py +318 -0
- hackagent/cli/tui/views/__init__.py +33 -0
- hackagent/cli/tui/views/agents.py +488 -0
- hackagent/cli/tui/views/attacks.py +624 -0
- hackagent/cli/tui/views/config.py +244 -0
- hackagent/cli/tui/views/dashboard.py +307 -0
- hackagent/cli/tui/views/results.py +1210 -0
- hackagent/cli/tui/widgets/__init__.py +24 -0
- hackagent/cli/tui/widgets/actions.py +346 -0
- hackagent/cli/tui/widgets/logs.py +435 -0
- hackagent/cli/utils.py +276 -0
- hackagent/client.py +286 -0
- hackagent/errors.py +37 -0
- hackagent/logger.py +83 -0
- hackagent/models/__init__.py +109 -0
- hackagent/models/agent.py +223 -0
- hackagent/models/agent_request.py +129 -0
- hackagent/models/api_token_log.py +184 -0
- hackagent/models/attack.py +154 -0
- hackagent/models/attack_request.py +82 -0
- hackagent/models/checkout_session_request_request.py +76 -0
- hackagent/models/checkout_session_response.py +59 -0
- hackagent/models/choice.py +81 -0
- hackagent/models/choice_message.py +67 -0
- hackagent/models/evaluation_status_enum.py +14 -0
- hackagent/models/generate_error_response.py +59 -0
- hackagent/models/generate_request_request.py +212 -0
- hackagent/models/generate_success_response.py +115 -0
- hackagent/models/generic_error_response.py +70 -0
- hackagent/models/message_request.py +67 -0
- hackagent/models/organization.py +102 -0
- hackagent/models/organization_minimal.py +68 -0
- hackagent/models/organization_request.py +71 -0
- hackagent/models/paginated_agent_list.py +123 -0
- hackagent/models/paginated_api_token_log_list.py +123 -0
- hackagent/models/paginated_attack_list.py +123 -0
- hackagent/models/paginated_organization_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/paginated_user_profile_list.py +123 -0
- hackagent/models/patched_agent_request.py +128 -0
- hackagent/models/patched_attack_request.py +92 -0
- hackagent/models/patched_organization_request.py +71 -0
- hackagent/models/patched_prompt_request.py +125 -0
- hackagent/models/patched_result_request.py +237 -0
- hackagent/models/patched_run_request.py +138 -0
- hackagent/models/patched_user_profile_request.py +99 -0
- hackagent/models/prompt.py +220 -0
- hackagent/models/prompt_request.py +126 -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/usage.py +75 -0
- hackagent/models/user_api_key.py +201 -0
- hackagent/models/user_api_key_request.py +73 -0
- hackagent/models/user_profile.py +135 -0
- hackagent/models/user_profile_minimal.py +76 -0
- hackagent/models/user_profile_request.py +99 -0
- hackagent/router/__init__.py +25 -0
- hackagent/router/adapters/__init__.py +20 -0
- hackagent/router/adapters/base.py +63 -0
- hackagent/router/adapters/google_adk.py +671 -0
- hackagent/router/adapters/litellm_adapter.py +524 -0
- hackagent/router/adapters/openai_adapter.py +426 -0
- hackagent/router/router.py +969 -0
- hackagent/router/types.py +54 -0
- hackagent/tracking/__init__.py +42 -0
- hackagent/tracking/context.py +163 -0
- hackagent/tracking/decorators.py +299 -0
- hackagent/tracking/tracker.py +441 -0
- hackagent/types.py +54 -0
- hackagent/utils.py +194 -0
- hackagent/vulnerabilities/__init__.py +13 -0
- hackagent/vulnerabilities/prompts.py +81 -0
- hackagent-0.3.1.dist-info/METADATA +122 -0
- hackagent-0.3.1.dist-info/RECORD +183 -0
- hackagent-0.3.1.dist-info/WHEEL +4 -0
- hackagent-0.3.1.dist-info/entry_points.txt +2 -0
- hackagent-0.3.1.dist-info/licenses/LICENSE +202 -0
|
@@ -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
|
|
@@ -0,0 +1,99 @@
|
|
|
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 .. import types
|
|
8
|
+
from ..types import UNSET, Unset
|
|
9
|
+
|
|
10
|
+
T = TypeVar("T", bound="UserProfileRequest")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@_attrs_define
|
|
14
|
+
class UserProfileRequest:
|
|
15
|
+
"""
|
|
16
|
+
Attributes:
|
|
17
|
+
email (Union[Unset, str]):
|
|
18
|
+
first_name (Union[Unset, str]):
|
|
19
|
+
last_name (Union[Unset, str]):
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
email: Union[Unset, str] = UNSET
|
|
23
|
+
first_name: Union[Unset, str] = UNSET
|
|
24
|
+
last_name: 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
|
+
email = self.email
|
|
29
|
+
|
|
30
|
+
first_name = self.first_name
|
|
31
|
+
|
|
32
|
+
last_name = self.last_name
|
|
33
|
+
|
|
34
|
+
field_dict: dict[str, Any] = {}
|
|
35
|
+
field_dict.update(self.additional_properties)
|
|
36
|
+
field_dict.update({})
|
|
37
|
+
if email is not UNSET:
|
|
38
|
+
field_dict["email"] = email
|
|
39
|
+
if first_name is not UNSET:
|
|
40
|
+
field_dict["first_name"] = first_name
|
|
41
|
+
if last_name is not UNSET:
|
|
42
|
+
field_dict["last_name"] = last_name
|
|
43
|
+
|
|
44
|
+
return field_dict
|
|
45
|
+
|
|
46
|
+
def to_multipart(self) -> types.RequestFiles:
|
|
47
|
+
files: types.RequestFiles = []
|
|
48
|
+
|
|
49
|
+
if not isinstance(self.email, Unset):
|
|
50
|
+
files.append(("email", (None, str(self.email).encode(), "text/plain")))
|
|
51
|
+
|
|
52
|
+
if not isinstance(self.first_name, Unset):
|
|
53
|
+
files.append(
|
|
54
|
+
("first_name", (None, str(self.first_name).encode(), "text/plain"))
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if not isinstance(self.last_name, Unset):
|
|
58
|
+
files.append(
|
|
59
|
+
("last_name", (None, str(self.last_name).encode(), "text/plain"))
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
for prop_name, prop in self.additional_properties.items():
|
|
63
|
+
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
|
64
|
+
|
|
65
|
+
return files
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
69
|
+
d = dict(src_dict)
|
|
70
|
+
email = d.pop("email", UNSET)
|
|
71
|
+
|
|
72
|
+
first_name = d.pop("first_name", UNSET)
|
|
73
|
+
|
|
74
|
+
last_name = d.pop("last_name", UNSET)
|
|
75
|
+
|
|
76
|
+
user_profile_request = cls(
|
|
77
|
+
email=email,
|
|
78
|
+
first_name=first_name,
|
|
79
|
+
last_name=last_name,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
user_profile_request.additional_properties = d
|
|
83
|
+
return user_profile_request
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def additional_keys(self) -> list[str]:
|
|
87
|
+
return list(self.additional_properties.keys())
|
|
88
|
+
|
|
89
|
+
def __getitem__(self, key: str) -> Any:
|
|
90
|
+
return self.additional_properties[key]
|
|
91
|
+
|
|
92
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
93
|
+
self.additional_properties[key] = value
|
|
94
|
+
|
|
95
|
+
def __delitem__(self, key: str) -> None:
|
|
96
|
+
del self.additional_properties[key]
|
|
97
|
+
|
|
98
|
+
def __contains__(self, key: str) -> bool:
|
|
99
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright 2025 - AI4I. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Main router logic for dispatching requests to appropriate agent adapters."""
|
|
16
|
+
|
|
17
|
+
from .adapters import (
|
|
18
|
+
ADKAgentAdapter,
|
|
19
|
+
) # This makes it easy to access adapters via router module
|
|
20
|
+
from .router import AgentRouter
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"AgentRouter",
|
|
24
|
+
"ADKAgentAdapter", # Exporting specific adapters for convenience
|
|
25
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Copyright 2025 - AI4I. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from .google_adk import ADKAgentAdapter # noqa F401
|
|
16
|
+
from .litellm_adapter import LiteLLMAgentAdapter # noqa F401
|
|
17
|
+
from .openai_adapter import OpenAIAgentAdapter # noqa F401
|
|
18
|
+
from .base import Agent # Added re-export
|
|
19
|
+
|
|
20
|
+
__all__ = ["ADKAgentAdapter", "LiteLLMAgentAdapter", "OpenAIAgentAdapter", "Agent"]
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Copyright 2025 - AI4I. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from abc import ABC, abstractmethod
|
|
17
|
+
from typing import Any, Dict
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Agent(ABC):
|
|
21
|
+
"""
|
|
22
|
+
Abstract Base Class for all agent implementations.
|
|
23
|
+
It defines a common interface for the router to interact with various agents.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def __init__(self, id: str, config: Dict[str, Any]):
|
|
28
|
+
"""
|
|
29
|
+
Initializes the agent.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
id: A unique identifier for this specific agent instance or type.
|
|
33
|
+
config: Configuration specific to this agent (e.g., API keys, model names).
|
|
34
|
+
"""
|
|
35
|
+
self.id = id
|
|
36
|
+
self.config = config
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def handle_request(self, request_data: Dict[str, Any]) -> Dict[str, Any]:
|
|
41
|
+
"""
|
|
42
|
+
Processes an incoming request and returns a standardized response.
|
|
43
|
+
The response should be suitable for storage via the API and should ideally
|
|
44
|
+
include enough information to reconstruct the interaction.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
request_data: The data for the agent to process. This might include
|
|
48
|
+
the prompt, session information, user details, etc.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
A dictionary containing the standardized response. This could include:
|
|
52
|
+
- 'raw_request': The original request sent to the underlying agent.
|
|
53
|
+
- 'raw_response': The original response received from the underlying agent.
|
|
54
|
+
- 'processed_response': The key information extracted/processed from the raw response.
|
|
55
|
+
- 'status_code': If applicable, the HTTP status code of the interaction.
|
|
56
|
+
- 'error_message': Any error message encountered.
|
|
57
|
+
- 'metadata': Any other relevant metadata.
|
|
58
|
+
"""
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
def get_identifier(self) -> str:
|
|
62
|
+
"""Returns the unique identifier for this agent instance or type."""
|
|
63
|
+
return self.id
|