agentic-contract 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.
- agentic_contract-0.1.0/PKG-INFO +19 -0
- agentic_contract-0.1.0/pyproject.toml +28 -0
- agentic_contract-0.1.0/setup.cfg +4 -0
- agentic_contract-0.1.0/src/agentic_contract/__init__.py +86 -0
- agentic_contract-0.1.0/src/agentic_contract.egg-info/PKG-INFO +19 -0
- agentic_contract-0.1.0/src/agentic_contract.egg-info/SOURCES.txt +8 -0
- agentic_contract-0.1.0/src/agentic_contract.egg-info/dependency_links.txt +1 -0
- agentic_contract-0.1.0/src/agentic_contract.egg-info/requires.txt +4 -0
- agentic_contract-0.1.0/src/agentic_contract.egg-info/top_level.txt +1 -0
- agentic_contract-0.1.0/tests/test_contract_engine.py +28 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentic-contract
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Policy engine for AI agents
|
|
5
|
+
Author-email: Agentra Labs <contact@agentralabs.tech>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://agentralabs.tech
|
|
8
|
+
Project-URL: Repository, https://github.com/agentralabs/agentic-contract
|
|
9
|
+
Keywords: ai,agents,contract,policy,governance
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agentic-contract"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Policy engine for AI agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = "Agentra Labs", email = "contact@agentralabs.tech"}]
|
|
13
|
+
keywords = ["ai", "agents", "contract", "policy", "governance"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Topic :: Software Development :: Libraries",
|
|
20
|
+
]
|
|
21
|
+
dependencies = []
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
dev = ["pytest>=7.0", "pytest-cov>=4.0"]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://agentralabs.tech"
|
|
28
|
+
Repository = "https://github.com/agentralabs/agentic-contract"
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""AgenticContract — Policy engine for AI agents.
|
|
2
|
+
|
|
3
|
+
This Python SDK wraps the `acon` CLI binary via subprocess.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import subprocess
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any, Optional
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ContractEngine:
|
|
18
|
+
"""High-level wrapper around the acon CLI."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, path: Optional[str] = None, binary: str = "acon"):
|
|
21
|
+
self._binary = binary
|
|
22
|
+
self._path = path or str(
|
|
23
|
+
Path.home() / ".agentic" / "contract.acon"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
def _run(self, *args: str) -> str:
|
|
27
|
+
"""Run an acon CLI command and return stdout."""
|
|
28
|
+
cmd = [self._binary, "--path", self._path, *args]
|
|
29
|
+
result = subprocess.run(
|
|
30
|
+
cmd, capture_output=True, text=True, timeout=30
|
|
31
|
+
)
|
|
32
|
+
if result.returncode != 0:
|
|
33
|
+
raise RuntimeError(
|
|
34
|
+
f"acon failed (exit {result.returncode}): {result.stderr.strip()}"
|
|
35
|
+
)
|
|
36
|
+
return result.stdout.strip()
|
|
37
|
+
|
|
38
|
+
def stats(self) -> dict[str, Any]:
|
|
39
|
+
"""Get contract statistics."""
|
|
40
|
+
output = self._run("stats")
|
|
41
|
+
return json.loads(output)
|
|
42
|
+
|
|
43
|
+
def policy_add(
|
|
44
|
+
self,
|
|
45
|
+
label: str,
|
|
46
|
+
scope: str = "global",
|
|
47
|
+
action: str = "deny",
|
|
48
|
+
description: Optional[str] = None,
|
|
49
|
+
) -> str:
|
|
50
|
+
"""Add a policy and return its ID."""
|
|
51
|
+
args = ["policy", "add", label, "--scope", scope, "--action", action]
|
|
52
|
+
if description:
|
|
53
|
+
args.extend(["--description", description])
|
|
54
|
+
output = self._run(*args)
|
|
55
|
+
# Output: "Created policy: <uuid>"
|
|
56
|
+
return output.split(": ", 1)[-1]
|
|
57
|
+
|
|
58
|
+
def policy_check(self, action_type: str, scope: str = "global") -> str:
|
|
59
|
+
"""Check if an action is allowed. Returns the decision string."""
|
|
60
|
+
output = self._run("policy", "check", action_type, "--scope", scope)
|
|
61
|
+
return output
|
|
62
|
+
|
|
63
|
+
def risk_limit_set(
|
|
64
|
+
self,
|
|
65
|
+
label: str,
|
|
66
|
+
max_value: float,
|
|
67
|
+
limit_type: str = "threshold",
|
|
68
|
+
) -> str:
|
|
69
|
+
"""Set a risk limit and return its ID."""
|
|
70
|
+
output = self._run(
|
|
71
|
+
"limit", "set", label, "--max", str(max_value), "--type", limit_type
|
|
72
|
+
)
|
|
73
|
+
return output.split(": ", 1)[-1]
|
|
74
|
+
|
|
75
|
+
def violation_report(
|
|
76
|
+
self,
|
|
77
|
+
description: str,
|
|
78
|
+
severity: str = "warning",
|
|
79
|
+
actor: str = "unknown",
|
|
80
|
+
) -> str:
|
|
81
|
+
"""Report a violation and return its ID."""
|
|
82
|
+
output = self._run(
|
|
83
|
+
"violation", "report", description,
|
|
84
|
+
"--severity", severity, "--actor", actor,
|
|
85
|
+
)
|
|
86
|
+
return output.split(": ", 1)[-1]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentic-contract
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Policy engine for AI agents
|
|
5
|
+
Author-email: Agentra Labs <contact@agentralabs.tech>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://agentralabs.tech
|
|
8
|
+
Project-URL: Repository, https://github.com/agentralabs/agentic-contract
|
|
9
|
+
Keywords: ai,agents,contract,policy,governance
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pyproject.toml
|
|
2
|
+
src/agentic_contract/__init__.py
|
|
3
|
+
src/agentic_contract.egg-info/PKG-INFO
|
|
4
|
+
src/agentic_contract.egg-info/SOURCES.txt
|
|
5
|
+
src/agentic_contract.egg-info/dependency_links.txt
|
|
6
|
+
src/agentic_contract.egg-info/requires.txt
|
|
7
|
+
src/agentic_contract.egg-info/top_level.txt
|
|
8
|
+
tests/test_contract_engine.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agentic_contract
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Basic tests for the AgenticContract Python SDK."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from agentic_contract import ContractEngine
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_import():
|
|
9
|
+
"""Verify the module imports correctly."""
|
|
10
|
+
assert ContractEngine is not None
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_version():
|
|
14
|
+
"""Verify version is set."""
|
|
15
|
+
import agentic_contract
|
|
16
|
+
assert agentic_contract.__version__ == "0.1.0"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_engine_init():
|
|
20
|
+
"""Verify engine can be instantiated."""
|
|
21
|
+
engine = ContractEngine(path="/tmp/test.acon")
|
|
22
|
+
assert engine._path == "/tmp/test.acon"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_engine_custom_binary():
|
|
26
|
+
"""Verify engine accepts custom binary path."""
|
|
27
|
+
engine = ContractEngine(binary="/usr/local/bin/acon")
|
|
28
|
+
assert engine._binary == "/usr/local/bin/acon"
|