agentguardproxy 0.3.0__tar.gz → 0.4.0__tar.gz

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 (19) hide show
  1. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/PKG-INFO +1 -1
  2. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguard/__init__.py +10 -1
  3. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguard/adapters/mcp.py +1 -1
  4. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguardproxy.egg-info/PKG-INFO +1 -1
  5. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/pyproject.toml +1 -1
  6. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/tests/test_guard.py +36 -0
  7. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/README.md +0 -0
  8. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguard/adapters/__init__.py +0 -0
  9. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguard/adapters/browseruse.py +0 -0
  10. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguard/adapters/crewai.py +0 -0
  11. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguard/adapters/langchain.py +0 -0
  12. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguardproxy.egg-info/SOURCES.txt +0 -0
  13. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguardproxy.egg-info/dependency_links.txt +0 -0
  14. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguardproxy.egg-info/requires.txt +0 -0
  15. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/agentguardproxy.egg-info/top_level.txt +0 -0
  16. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/setup.cfg +0 -0
  17. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/tests/test_adapters.py +0 -0
  18. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/tests/test_decorator.py +0 -0
  19. {agentguardproxy-0.3.0 → agentguardproxy-0.4.0}/tests/test_integration.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentguardproxy
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Python SDK for AgentGuard — the firewall for AI agents
5
5
  Author: AgentGuard Contributors
6
6
  License-Expression: Apache-2.0
@@ -68,10 +68,11 @@ class CheckResult:
68
68
  class Guard:
69
69
  """Client for the AgentGuard proxy."""
70
70
 
71
- def __init__(self, base_url: str = "", agent_id: str = "", timeout: int = DEFAULT_TIMEOUT):
71
+ def __init__(self, base_url: str = "", agent_id: str = "", timeout: int = DEFAULT_TIMEOUT, api_key: str = ""):
72
72
  self.base_url = (base_url or os.environ.get("AGENTGUARD_URL", DEFAULT_BASE_URL)).rstrip("/")
73
73
  self.agent_id = agent_id
74
74
  self.timeout = timeout
75
+ self.api_key = api_key or os.environ.get("AGENTGUARD_API_KEY", "")
75
76
 
76
77
  def check(
77
78
  self,
@@ -140,10 +141,17 @@ class Guard:
140
141
  reason=f"AgentGuard unreachable: {e}",
141
142
  )
142
143
 
144
+ def _auth_headers(self) -> dict:
145
+ """Return Authorization header if api_key is set."""
146
+ if self.api_key:
147
+ return {"Authorization": f"Bearer {self.api_key}"}
148
+ return {}
149
+
143
150
  def approve(self, approval_id: str) -> bool:
144
151
  """Approve a pending action."""
145
152
  req = request.Request(
146
153
  f"{self.base_url}{ENDPOINT_APPROVE}{approval_id}",
154
+ headers=self._auth_headers(),
147
155
  method="POST",
148
156
  )
149
157
  try:
@@ -156,6 +164,7 @@ class Guard:
156
164
  """Deny a pending action."""
157
165
  req = request.Request(
158
166
  f"{self.base_url}{ENDPOINT_DENY}{approval_id}",
167
+ headers=self._auth_headers(),
159
168
  method="POST",
160
169
  )
161
170
  try:
@@ -39,7 +39,7 @@ from agentguard import Guard, CheckResult, DEFAULT_BASE_URL
39
39
 
40
40
  # MCP protocol constants
41
41
  MCP_PROTOCOL_VERSION = "2024-11-05"
42
- SDK_VERSION = "0.3.0"
42
+ SDK_VERSION = "0.4.0"
43
43
 
44
44
 
45
45
  class ToolDefinition:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentguardproxy
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Python SDK for AgentGuard — the firewall for AI agents
5
5
  Author: AgentGuard Contributors
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "agentguardproxy"
7
- version = "0.3.0"
7
+ version = "0.4.0"
8
8
  description = "Python SDK for AgentGuard — the firewall for AI agents"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -169,3 +169,39 @@ class TestGuardActions:
169
169
  def test_deny_unreachable(self):
170
170
  g = Guard("http://127.0.0.1:1", timeout=1)
171
171
  assert g.deny("ap_123") is False
172
+
173
+
174
+ # ---------------------------------------------------------------------------
175
+ # Auth header tests (H9)
176
+ # ---------------------------------------------------------------------------
177
+
178
+ class TestGuardAuth:
179
+ def test_approve_sends_auth_header(self, mock_server):
180
+ g = Guard(mock_server, api_key="my-secret")
181
+ g.approve("ap_123")
182
+ assert MockAgentGuardHandler.last_request_headers is not None
183
+ assert MockAgentGuardHandler.last_request_headers.get("Authorization") == "Bearer my-secret"
184
+
185
+ def test_deny_sends_auth_header(self, mock_server):
186
+ g = Guard(mock_server, api_key="my-secret")
187
+ g.deny("ap_123")
188
+ assert MockAgentGuardHandler.last_request_headers is not None
189
+ assert MockAgentGuardHandler.last_request_headers.get("Authorization") == "Bearer my-secret"
190
+
191
+ def test_approve_no_auth_header_without_key(self, mock_server):
192
+ g = Guard(mock_server)
193
+ g.approve("ap_123")
194
+ assert MockAgentGuardHandler.last_request_headers is not None
195
+ assert MockAgentGuardHandler.last_request_headers.get("Authorization") is None
196
+
197
+ def test_api_key_from_env(self, mock_server, monkeypatch):
198
+ monkeypatch.setenv("AGENTGUARD_API_KEY", "env-secret")
199
+ g = Guard(mock_server)
200
+ g.approve("ap_123")
201
+ assert MockAgentGuardHandler.last_request_headers.get("Authorization") == "Bearer env-secret"
202
+
203
+ def test_explicit_key_overrides_env(self, mock_server, monkeypatch):
204
+ monkeypatch.setenv("AGENTGUARD_API_KEY", "env-secret")
205
+ g = Guard(mock_server, api_key="explicit-secret")
206
+ g.approve("ap_123")
207
+ assert MockAgentGuardHandler.last_request_headers.get("Authorization") == "Bearer explicit-secret"