tollgate 1.0.4__py3-none-any.whl → 1.0.5__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.
- tollgate/__init__.py +3 -2
- tollgate/grants.py +46 -0
- tollgate/tower.py +2 -1
- {tollgate-1.0.4.dist-info → tollgate-1.0.5.dist-info}/METADATA +1 -1
- {tollgate-1.0.4.dist-info → tollgate-1.0.5.dist-info}/RECORD +7 -7
- {tollgate-1.0.4.dist-info → tollgate-1.0.5.dist-info}/WHEEL +0 -0
- {tollgate-1.0.4.dist-info → tollgate-1.0.5.dist-info}/licenses/LICENSE +0 -0
tollgate/__init__.py
CHANGED
|
@@ -14,7 +14,7 @@ from .exceptions import (
|
|
|
14
14
|
TollgateDenied,
|
|
15
15
|
TollgateError,
|
|
16
16
|
)
|
|
17
|
-
from .grants import InMemoryGrantStore
|
|
17
|
+
from .grants import GrantStore, InMemoryGrantStore
|
|
18
18
|
from .helpers import guard, wrap_tool
|
|
19
19
|
from .policy import PolicyEvaluator, YamlPolicyEvaluator
|
|
20
20
|
from .registry import ToolRegistry
|
|
@@ -33,7 +33,7 @@ from .types import (
|
|
|
33
33
|
ToolRequest,
|
|
34
34
|
)
|
|
35
35
|
|
|
36
|
-
__version__ = "1.0.
|
|
36
|
+
__version__ = "1.0.5"
|
|
37
37
|
|
|
38
38
|
__all__ = [
|
|
39
39
|
"ControlTower",
|
|
@@ -45,6 +45,7 @@ __all__ = [
|
|
|
45
45
|
"DecisionType",
|
|
46
46
|
"Effect",
|
|
47
47
|
"Grant",
|
|
48
|
+
"GrantStore",
|
|
48
49
|
"AuditEvent",
|
|
49
50
|
"Outcome",
|
|
50
51
|
"ApprovalOutcome",
|
tollgate/grants.py
CHANGED
|
@@ -1,9 +1,55 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import time
|
|
3
|
+
from typing import Protocol, runtime_checkable
|
|
3
4
|
|
|
4
5
|
from .types import AgentContext, Grant, ToolRequest
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
@runtime_checkable
|
|
9
|
+
class GrantStore(Protocol):
|
|
10
|
+
"""Protocol for grant storage backends.
|
|
11
|
+
|
|
12
|
+
Implement this protocol to use a custom storage backend (Redis, SQLite, etc.).
|
|
13
|
+
|
|
14
|
+
Example Redis implementation:
|
|
15
|
+
|
|
16
|
+
class RedisGrantStore:
|
|
17
|
+
def __init__(self, redis_client):
|
|
18
|
+
self.redis = redis_client
|
|
19
|
+
|
|
20
|
+
async def create_grant(self, grant: Grant) -> str:
|
|
21
|
+
await self.redis.hset(f"grant:{grant.id}", mapping=grant.to_dict())
|
|
22
|
+
await self.redis.expireat(f"grant:{grant.id}", int(grant.expires_at))
|
|
23
|
+
return grant.id
|
|
24
|
+
|
|
25
|
+
async def find_matching_grant(self, agent_ctx, tool_request) -> Grant | None:
|
|
26
|
+
# Implement matching logic with Redis SCAN or secondary indexes
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
All methods must be async. The InMemoryGrantStore serves as the reference implementation.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
async def create_grant(self, grant: Grant) -> str:
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
async def find_matching_grant(
|
|
36
|
+
self, agent_ctx: AgentContext, tool_request: ToolRequest
|
|
37
|
+
) -> Grant | None:
|
|
38
|
+
...
|
|
39
|
+
|
|
40
|
+
async def revoke_grant(self, grant_id: str) -> bool:
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
async def list_active_grants(self, agent_id: str | None = None) -> list[Grant]:
|
|
44
|
+
...
|
|
45
|
+
|
|
46
|
+
async def cleanup_expired(self) -> int:
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
async def get_usage_count(self, grant_id: str) -> int:
|
|
50
|
+
...
|
|
51
|
+
|
|
52
|
+
|
|
7
53
|
class InMemoryGrantStore:
|
|
8
54
|
"""In-memory store for action grants with thread-safe matching logic."""
|
|
9
55
|
|
tollgate/tower.py
CHANGED
|
@@ -11,6 +11,7 @@ from .exceptions import (
|
|
|
11
11
|
TollgateDeferred,
|
|
12
12
|
TollgateDenied,
|
|
13
13
|
)
|
|
14
|
+
from .grants import GrantStore
|
|
14
15
|
from .policy import PolicyEvaluator
|
|
15
16
|
from .types import (
|
|
16
17
|
AgentContext,
|
|
@@ -32,7 +33,7 @@ class ControlTower:
|
|
|
32
33
|
policy: PolicyEvaluator,
|
|
33
34
|
approver: Approver,
|
|
34
35
|
audit: AuditSink,
|
|
35
|
-
grant_store:
|
|
36
|
+
grant_store: GrantStore | None = None,
|
|
36
37
|
redact_fn: Callable[[dict[str, Any]], dict[str, Any]] | None = None,
|
|
37
38
|
):
|
|
38
39
|
self.policy = policy
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
tollgate/__init__.py,sha256=
|
|
1
|
+
tollgate/__init__.py,sha256=KWxtUI6D0Cm4QHCAaVv5VdEiQIo_krw7jzbXofxW_FM,1441
|
|
2
2
|
tollgate/approvals.py,sha256=lalvun6i5yaZ2EGZ-apQJBrLVmht5OfwgiUFsImPdYE,7814
|
|
3
3
|
tollgate/audit.py,sha256=ugMhuuLoyBNdYD2S_MjGN_ac4nHdtRz15MElqElREIs,1279
|
|
4
4
|
tollgate/exceptions.py,sha256=2yYY3esnHz26dyJlx_Cd_J64ryhexrgc4KliDmiVJSs,882
|
|
5
|
-
tollgate/grants.py,sha256=
|
|
5
|
+
tollgate/grants.py,sha256=H5soShiNcyQiY3gLJRqqP7ffAo2Udmnj3iU15sGi3os,5177
|
|
6
6
|
tollgate/helpers.py,sha256=ZFMi19_ogpTlV_svFtgJ9kkmA1sPte1dmDnHYVdWGyo,1657
|
|
7
7
|
tollgate/policy.py,sha256=1_6HcbdpGfZtwmgqapqeRzItc_wbEg_L-fOA-BVIWNg,6110
|
|
8
8
|
tollgate/registry.py,sha256=ENKT-GnwFq0xXZj6qNlKFhAGYsxxBwtZsAdPZp2qlHM,2031
|
|
9
|
-
tollgate/tower.py,sha256=
|
|
9
|
+
tollgate/tower.py,sha256=rPG2sdVe2GpdGiyHwWz8K4k7EJCL2NqDAGsMUkKlt30,8574
|
|
10
10
|
tollgate/types.py,sha256=Ks3HNawhPzEAggTCab7NLb8zl06777ehEusASJWSj_g,3811
|
|
11
11
|
tollgate/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
tollgate/integrations/mcp.py,sha256=jBy1d64Yc55fO4JSVfhKqiffVCZdBMmmNLRta9SVfDE,1750
|
|
@@ -15,7 +15,7 @@ tollgate/interceptors/__init__.py,sha256=0c3MYyVKGYrBOZ1mMolgrAowrqZrULzAl0vv-s8
|
|
|
15
15
|
tollgate/interceptors/base.py,sha256=uJxHzH0eurcGEVknbk1kQkk_2u2qNtnM--ZRCp52Wyo,1390
|
|
16
16
|
tollgate/interceptors/langchain.py,sha256=_8vXCjWkRKeTlxtXm33a67Gf4po9YiHS7faThMJLohc,2963
|
|
17
17
|
tollgate/interceptors/openai.py,sha256=cHnOQ8keQJRYBm_1RpohKWk3D9Ask22hpuQghm9iahU,3337
|
|
18
|
-
tollgate-1.0.
|
|
19
|
-
tollgate-1.0.
|
|
20
|
-
tollgate-1.0.
|
|
21
|
-
tollgate-1.0.
|
|
18
|
+
tollgate-1.0.5.dist-info/METADATA,sha256=zPDa8CQ7Qqx5GoQ6XojAZgur47ErP6KeWoUCfhTQOXs,7748
|
|
19
|
+
tollgate-1.0.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
20
|
+
tollgate-1.0.5.dist-info/licenses/LICENSE,sha256=EZ9SehMCkcatlggcoT7WV0tx-ku4OsAoQf9LmJZvG1g,10806
|
|
21
|
+
tollgate-1.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|