Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: CI Checks

on:
push:
branches: ["**"]
pull_request:
branches: ["**"]

Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ repos:
args: [--fix]
# Run the formatter.
- id: ruff-format

- repo: local
hooks:
- id: pytest
name: pytest
entry: poetry run pytest
language: system
types: [python]
pass_filenames: false
always_run: true
17 changes: 0 additions & 17 deletions CHANGELOG.md

This file was deleted.

10 changes: 5 additions & 5 deletions hackagent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ def _resolve_api_token(
else:
logger.debug("No .env file found to load.")

api_token_resolved = os.getenv("HACKAGENT_API_TOKEN")
api_token_resolved = os.getenv("HACKAGENT_API_KEY")

if not api_token_resolved:
error_message = (
"API token not provided via 'api_key' parameter, "
"and not found in HACKAGENT_API_TOKEN environment variable "
"and not found in HACKAGENT_API_KEY environment variable "
"(after attempting to load .env)."
)
raise ValueError(error_message)
logger.debug("Using API token from HACKAGENT_API_TOKEN environment variable.")
logger.debug("Using API token from HACKAGENT_API_KEY environment variable.")
return api_token_resolved

async def hack(
def hack(
self,
attack_config: Dict[str, Any],
run_config_override: Optional[Dict[str, Any]] = None,
Expand Down Expand Up @@ -172,7 +172,7 @@ async def hack(
f"Using Victim Backend Agent ID: {backend_agent.id} for '{backend_agent.name}'"
)

return await strategy.execute(
return strategy.execute(
attack_config=attack_config,
run_config_override=run_config_override,
fail_on_run_error=fail_on_run_error,
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/agent/agent_destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def _get_kwargs(
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": f"/api/agent/{id}",
"url": "/api/agent/{id}".format(
id=id,
),
}

return _kwargs
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/agent/agent_partial_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def _get_kwargs(

_kwargs: dict[str, Any] = {
"method": "patch",
"url": f"/api/agent/{id}",
"url": "/api/agent/{id}".format(
id=id,
),
}

_body = body.to_dict()
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/agent/agent_retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def _get_kwargs(
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/api/agent/{id}",
"url": "/api/agent/{id}".format(
id=id,
),
}

return _kwargs
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/agent/agent_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def _get_kwargs(

_kwargs: dict[str, Any] = {
"method": "put",
"url": f"/api/agent/{id}",
"url": "/api/agent/{id}".format(
id=id,
),
}

_body = body.to_dict()
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/attack/attack_destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def _get_kwargs(
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": f"/api/attack/{id}",
"url": "/api/attack/{id}".format(
id=id,
),
}

return _kwargs
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/attack/attack_partial_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def _get_kwargs(

_kwargs: dict[str, Any] = {
"method": "patch",
"url": f"/api/attack/{id}",
"url": "/api/attack/{id}".format(
id=id,
),
}

_body = body.to_dict()
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/attack/attack_retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def _get_kwargs(
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/api/attack/{id}",
"url": "/api/attack/{id}".format(
id=id,
),
}

return _kwargs
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/attack/attack_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def _get_kwargs(

_kwargs: dict[str, Any] = {
"method": "put",
"url": f"/api/attack/{id}",
"url": "/api/attack/{id}".format(
id=id,
),
}

_body = body.to_dict()
Expand Down
1 change: 1 addition & 0 deletions hackagent/api/generator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
99 changes: 99 additions & 0 deletions hackagent/api/generator/generator_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from http import HTTPStatus
from typing import Any, Optional, Union

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...types import Response


def _get_kwargs() -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/api/generator",
}

return _kwargs


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Any]:
if response.status_code == 200:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Any]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
*,
client: AuthenticatedClient,
) -> Response[Any]:
r"""Proxies POST requests to the configured OpenRouter generator model.
Requires a valid User API Key for access.
The client should send a POST request with a JSON body in the same format
as expected by LiteLLM or OpenRouter's /chat/completions endpoint,
including a \"model\" field.
Note: The \"model\" field provided by the client in the request body will be
overridden by the server-configured generator model ID for the actual call to OpenRouter.
e.g., {\"model\": \"client_specified_model_name\", \"messages\": [{\"role\": \"user\", \"content\":
\"Hello!\"}], \"stream\": False}

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
"""

kwargs = _get_kwargs()

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


async def asyncio_detailed(
*,
client: AuthenticatedClient,
) -> Response[Any]:
r"""Proxies POST requests to the configured OpenRouter generator model.
Requires a valid User API Key for access.
The client should send a POST request with a JSON body in the same format
as expected by LiteLLM or OpenRouter's /chat/completions endpoint,
including a \"model\" field.
Note: The \"model\" field provided by the client in the request body will be
overridden by the server-configured generator model ID for the actual call to OpenRouter.
e.g., {\"model\": \"client_specified_model_name\", \"messages\": [{\"role\": \"user\", \"content\":
\"Hello!\"}], \"stream\": False}

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
"""

kwargs = _get_kwargs()

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)
1 change: 1 addition & 0 deletions hackagent/api/judge/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
99 changes: 99 additions & 0 deletions hackagent/api/judge/judge_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from http import HTTPStatus
from typing import Any, Optional, Union

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...types import Response


def _get_kwargs() -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/api/judge",
}

return _kwargs


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Any]:
if response.status_code == 200:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Any]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
*,
client: AuthenticatedClient,
) -> Response[Any]:
r"""Proxies POST requests to the configured OpenRouter judge model.
Requires a valid User API Key for access.
The client should send a POST request with a JSON body in the same format
as expected by LiteLLM or OpenRouter's /chat/completions endpoint,
including a \"model\" field.
Note: The \"model\" field provided by the client in the request body will be
overridden by the server-configured judge model ID for the actual call to OpenRouter.
e.g., {\"model\": \"client_specified_model_name\", \"messages\": [{\"role\": \"user\", \"content\":
\"Is this good?\"}], \"stream\": False}

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
"""

kwargs = _get_kwargs()

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


async def asyncio_detailed(
*,
client: AuthenticatedClient,
) -> Response[Any]:
r"""Proxies POST requests to the configured OpenRouter judge model.
Requires a valid User API Key for access.
The client should send a POST request with a JSON body in the same format
as expected by LiteLLM or OpenRouter's /chat/completions endpoint,
including a \"model\" field.
Note: The \"model\" field provided by the client in the request body will be
overridden by the server-configured judge model ID for the actual call to OpenRouter.
e.g., {\"model\": \"client_specified_model_name\", \"messages\": [{\"role\": \"user\", \"content\":
\"Is this good?\"}], \"stream\": False}

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any]
"""

kwargs = _get_kwargs()

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)
4 changes: 3 additions & 1 deletion hackagent/api/key/key_destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def _get_kwargs(
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": f"/api/key/{prefix}",
"url": "/api/key/{prefix}".format(
prefix=prefix,
),
}

return _kwargs
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/key/key_retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def _get_kwargs(
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/api/key/{prefix}",
"url": "/api/key/{prefix}".format(
prefix=prefix,
),
}

return _kwargs
Expand Down
4 changes: 3 additions & 1 deletion hackagent/api/prompt/prompt_destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def _get_kwargs(
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": f"/api/prompt/{id}",
"url": "/api/prompt/{id}".format(
id=id,
),
}

return _kwargs
Expand Down
Loading
Loading