agentshield-gateway-sdk 0.1.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.
- agentshield_gateway_sdk-0.1.0/LICENSE +21 -0
- agentshield_gateway_sdk-0.1.0/PKG-INFO +87 -0
- agentshield_gateway_sdk-0.1.0/README.md +71 -0
- agentshield_gateway_sdk-0.1.0/__init__.py +3 -0
- agentshield_gateway_sdk-0.1.0/agentshield_gateway_sdk.egg-info/PKG-INFO +87 -0
- agentshield_gateway_sdk-0.1.0/agentshield_gateway_sdk.egg-info/SOURCES.txt +12 -0
- agentshield_gateway_sdk-0.1.0/agentshield_gateway_sdk.egg-info/dependency_links.txt +1 -0
- agentshield_gateway_sdk-0.1.0/agentshield_gateway_sdk.egg-info/requires.txt +1 -0
- agentshield_gateway_sdk-0.1.0/agentshield_gateway_sdk.egg-info/top_level.txt +1 -0
- agentshield_gateway_sdk-0.1.0/client.py +65 -0
- agentshield_gateway_sdk-0.1.0/pyproject.toml +31 -0
- agentshield_gateway_sdk-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentShield
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentshield-gateway-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for the AgentShield Tool Security Gateway
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Keywords: agentshield,ai-security,ai-agents,gateway,authorization
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Security
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: requests<3,>=2.31
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# agentshield-gateway-sdk
|
|
18
|
+
|
|
19
|
+
Python client for the AgentShield Tool Security Gateway. Call `evaluate()` from
|
|
20
|
+
inside your agent's tool-calling loop before it actually runs a tool, and act on
|
|
21
|
+
the decision AgentShield returns.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
Once published to PyPI, anyone can install it with no local files at all:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install agentshield-gateway-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Until then (or for local development), install from a local checkout of the
|
|
32
|
+
AgentShield repo:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install /path/to/agentshield/sdk
|
|
36
|
+
# or, for local development (picks up edits without reinstalling):
|
|
37
|
+
pip install -e /path/to/agentshield/sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or from git, without cloning first:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install "git+https://github.com/<org>/<repo>.git#subdirectory=sdk"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
All three install the same distribution, `agentshield-gateway-sdk`, which
|
|
47
|
+
provides the importable module `sdk` (matching the code snippet shown in the
|
|
48
|
+
dashboard's "Get gateway credentials" step) - the import is identical no matter
|
|
49
|
+
which install method you used.
|
|
50
|
+
|
|
51
|
+
## Get a credential first
|
|
52
|
+
|
|
53
|
+
The client needs a gateway credential for the specific agent it's acting on
|
|
54
|
+
behalf of. Get one from the dashboard: **Add Agent → Connect its tools → Get
|
|
55
|
+
gateway credentials** (step 6 of onboarding), or via the API:
|
|
56
|
+
`POST /v1/agents/{id}/credentials`. The token is shown only once - store it
|
|
57
|
+
securely (e.g. an environment variable), not in source control.
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import os
|
|
63
|
+
from sdk.client import AgentShieldClient
|
|
64
|
+
# or: from sdk import AgentShieldClient
|
|
65
|
+
|
|
66
|
+
shield = AgentShieldClient(
|
|
67
|
+
base_url="https://your-agentshield-host",
|
|
68
|
+
credential=os.environ["AGENTSHIELD_CREDENTIAL"],
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
result = shield.evaluate(
|
|
72
|
+
tool="email.send",
|
|
73
|
+
action="send",
|
|
74
|
+
target="customer@example.com",
|
|
75
|
+
data_classification="confidential",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
if result.allowed:
|
|
79
|
+
... # actually send the email
|
|
80
|
+
else:
|
|
81
|
+
print(f"{result.decision}: {result.reason}")
|
|
82
|
+
# handle BLOCK / REQUIRE_APPROVAL / QUARANTINE - do not proceed
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`evaluate()` returns an `EvaluationResult` with `decision`, `risk_score`,
|
|
86
|
+
`risk_breakdown`, `policy`, `reason`, and the `allowed` convenience property
|
|
87
|
+
(`True` only when `decision == "ALLOW"`).
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# agentshield-gateway-sdk
|
|
2
|
+
|
|
3
|
+
Python client for the AgentShield Tool Security Gateway. Call `evaluate()` from
|
|
4
|
+
inside your agent's tool-calling loop before it actually runs a tool, and act on
|
|
5
|
+
the decision AgentShield returns.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Once published to PyPI, anyone can install it with no local files at all:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install agentshield-gateway-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Until then (or for local development), install from a local checkout of the
|
|
16
|
+
AgentShield repo:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install /path/to/agentshield/sdk
|
|
20
|
+
# or, for local development (picks up edits without reinstalling):
|
|
21
|
+
pip install -e /path/to/agentshield/sdk
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or from git, without cloning first:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install "git+https://github.com/<org>/<repo>.git#subdirectory=sdk"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
All three install the same distribution, `agentshield-gateway-sdk`, which
|
|
31
|
+
provides the importable module `sdk` (matching the code snippet shown in the
|
|
32
|
+
dashboard's "Get gateway credentials" step) - the import is identical no matter
|
|
33
|
+
which install method you used.
|
|
34
|
+
|
|
35
|
+
## Get a credential first
|
|
36
|
+
|
|
37
|
+
The client needs a gateway credential for the specific agent it's acting on
|
|
38
|
+
behalf of. Get one from the dashboard: **Add Agent → Connect its tools → Get
|
|
39
|
+
gateway credentials** (step 6 of onboarding), or via the API:
|
|
40
|
+
`POST /v1/agents/{id}/credentials`. The token is shown only once - store it
|
|
41
|
+
securely (e.g. an environment variable), not in source control.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import os
|
|
47
|
+
from sdk.client import AgentShieldClient
|
|
48
|
+
# or: from sdk import AgentShieldClient
|
|
49
|
+
|
|
50
|
+
shield = AgentShieldClient(
|
|
51
|
+
base_url="https://your-agentshield-host",
|
|
52
|
+
credential=os.environ["AGENTSHIELD_CREDENTIAL"],
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
result = shield.evaluate(
|
|
56
|
+
tool="email.send",
|
|
57
|
+
action="send",
|
|
58
|
+
target="customer@example.com",
|
|
59
|
+
data_classification="confidential",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
if result.allowed:
|
|
63
|
+
... # actually send the email
|
|
64
|
+
else:
|
|
65
|
+
print(f"{result.decision}: {result.reason}")
|
|
66
|
+
# handle BLOCK / REQUIRE_APPROVAL / QUARANTINE - do not proceed
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`evaluate()` returns an `EvaluationResult` with `decision`, `risk_score`,
|
|
70
|
+
`risk_breakdown`, `policy`, `reason`, and the `allowed` convenience property
|
|
71
|
+
(`True` only when `decision == "ALLOW"`).
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentshield-gateway-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for the AgentShield Tool Security Gateway
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Keywords: agentshield,ai-security,ai-agents,gateway,authorization
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Security
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: requests<3,>=2.31
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# agentshield-gateway-sdk
|
|
18
|
+
|
|
19
|
+
Python client for the AgentShield Tool Security Gateway. Call `evaluate()` from
|
|
20
|
+
inside your agent's tool-calling loop before it actually runs a tool, and act on
|
|
21
|
+
the decision AgentShield returns.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
Once published to PyPI, anyone can install it with no local files at all:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install agentshield-gateway-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Until then (or for local development), install from a local checkout of the
|
|
32
|
+
AgentShield repo:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install /path/to/agentshield/sdk
|
|
36
|
+
# or, for local development (picks up edits without reinstalling):
|
|
37
|
+
pip install -e /path/to/agentshield/sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or from git, without cloning first:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install "git+https://github.com/<org>/<repo>.git#subdirectory=sdk"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
All three install the same distribution, `agentshield-gateway-sdk`, which
|
|
47
|
+
provides the importable module `sdk` (matching the code snippet shown in the
|
|
48
|
+
dashboard's "Get gateway credentials" step) - the import is identical no matter
|
|
49
|
+
which install method you used.
|
|
50
|
+
|
|
51
|
+
## Get a credential first
|
|
52
|
+
|
|
53
|
+
The client needs a gateway credential for the specific agent it's acting on
|
|
54
|
+
behalf of. Get one from the dashboard: **Add Agent → Connect its tools → Get
|
|
55
|
+
gateway credentials** (step 6 of onboarding), or via the API:
|
|
56
|
+
`POST /v1/agents/{id}/credentials`. The token is shown only once - store it
|
|
57
|
+
securely (e.g. an environment variable), not in source control.
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import os
|
|
63
|
+
from sdk.client import AgentShieldClient
|
|
64
|
+
# or: from sdk import AgentShieldClient
|
|
65
|
+
|
|
66
|
+
shield = AgentShieldClient(
|
|
67
|
+
base_url="https://your-agentshield-host",
|
|
68
|
+
credential=os.environ["AGENTSHIELD_CREDENTIAL"],
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
result = shield.evaluate(
|
|
72
|
+
tool="email.send",
|
|
73
|
+
action="send",
|
|
74
|
+
target="customer@example.com",
|
|
75
|
+
data_classification="confidential",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
if result.allowed:
|
|
79
|
+
... # actually send the email
|
|
80
|
+
else:
|
|
81
|
+
print(f"{result.decision}: {result.reason}")
|
|
82
|
+
# handle BLOCK / REQUIRE_APPROVAL / QUARANTINE - do not proceed
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`evaluate()` returns an `EvaluationResult` with `decision`, `risk_score`,
|
|
86
|
+
`risk_breakdown`, `policy`, `reason`, and the `allowed` convenience property
|
|
87
|
+
(`True` only when `decision == "ALLOW"`).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
__init__.py
|
|
4
|
+
client.py
|
|
5
|
+
pyproject.toml
|
|
6
|
+
./__init__.py
|
|
7
|
+
./client.py
|
|
8
|
+
agentshield_gateway_sdk.egg-info/PKG-INFO
|
|
9
|
+
agentshield_gateway_sdk.egg-info/SOURCES.txt
|
|
10
|
+
agentshield_gateway_sdk.egg-info/dependency_links.txt
|
|
11
|
+
agentshield_gateway_sdk.egg-info/requires.txt
|
|
12
|
+
agentshield_gateway_sdk.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests<3,>=2.31
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sdk
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Minimal Python SDK for calling the AgentShield Tool Security Gateway from inside
|
|
3
|
+
an agent's tool-calling loop (blueprint section 5). Authenticates with the
|
|
4
|
+
gateway credential issued in step 6 of onboarding (POST /v1/agents/{id}/credentials).
|
|
5
|
+
|
|
6
|
+
from sdk.client import AgentShieldClient
|
|
7
|
+
|
|
8
|
+
shield = AgentShieldClient(base_url="http://localhost:8000", credential="ash_...")
|
|
9
|
+
result = shield.evaluate(tool="email.send", action="send", target="ext@example.com",
|
|
10
|
+
data_classification="confidential")
|
|
11
|
+
if result.decision != "ALLOW":
|
|
12
|
+
raise PermissionError(f"{result.decision}: {result.reason}")
|
|
13
|
+
"""
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
|
|
16
|
+
import requests
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class EvaluationResult:
|
|
21
|
+
action_id: str
|
|
22
|
+
decision: str
|
|
23
|
+
risk_score: int
|
|
24
|
+
risk_breakdown: dict
|
|
25
|
+
policy: str | None
|
|
26
|
+
reason: str
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def allowed(self) -> bool:
|
|
30
|
+
return self.decision == "ALLOW"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class AgentShieldClient:
|
|
34
|
+
def __init__(self, base_url: str, credential: str, timeout: float = 5.0):
|
|
35
|
+
self.base_url = base_url.rstrip("/")
|
|
36
|
+
self.credential = credential
|
|
37
|
+
self.timeout = timeout
|
|
38
|
+
|
|
39
|
+
def evaluate(
|
|
40
|
+
self,
|
|
41
|
+
*,
|
|
42
|
+
tool: str,
|
|
43
|
+
action: str,
|
|
44
|
+
target: str | None = None,
|
|
45
|
+
destination: str | None = None,
|
|
46
|
+
data_classification: str | None = None,
|
|
47
|
+
amount: float | None = None,
|
|
48
|
+
raw_input: str | None = None,
|
|
49
|
+
) -> EvaluationResult:
|
|
50
|
+
response = requests.post(
|
|
51
|
+
f"{self.base_url}/v1/actions/evaluate",
|
|
52
|
+
headers={"Authorization": f"Bearer {self.credential}"},
|
|
53
|
+
json={
|
|
54
|
+
"tool": tool,
|
|
55
|
+
"action": action,
|
|
56
|
+
"target": target,
|
|
57
|
+
"destination": destination,
|
|
58
|
+
"data_classification": data_classification,
|
|
59
|
+
"amount": amount,
|
|
60
|
+
"raw_input": raw_input,
|
|
61
|
+
},
|
|
62
|
+
timeout=self.timeout,
|
|
63
|
+
)
|
|
64
|
+
response.raise_for_status()
|
|
65
|
+
return EvaluationResult(**response.json())
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agentshield-gateway-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python client for the AgentShield Tool Security Gateway"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
keywords = ["agentshield", "ai-security", "ai-agents", "gateway", "authorization"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Topic :: Security",
|
|
19
|
+
]
|
|
20
|
+
dependencies = [
|
|
21
|
+
"requests>=2.31,<3",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[tool.setuptools]
|
|
25
|
+
# The distribution is named "agentshield-gateway-sdk" (what you `pip install`), but
|
|
26
|
+
# the importable module stays "sdk" (what you `import`) - matching the snippet
|
|
27
|
+
# shown in the dashboard's "Get gateway credentials" step.
|
|
28
|
+
packages = ["sdk"]
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.package-dir]
|
|
31
|
+
sdk = "."
|