agentic-contract 0.1.0__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.
@@ -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,5 @@
1
+ agentic_contract/__init__.py,sha256=ZO-_7orJkgMNLfuvtdpLMg4rtCuCMtLkGNHeCL67050,2626
2
+ agentic_contract-0.1.0.dist-info/METADATA,sha256=TFWXol1-a0ouHaiULqt2wQ0DcxnoCHQAb-yoQ7k4_y8,747
3
+ agentic_contract-0.1.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
4
+ agentic_contract-0.1.0.dist-info/top_level.txt,sha256=J4l0c2oNo9uSRCHr-XxJzW330l1fbQznyqizt4ham6g,17
5
+ agentic_contract-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ agentic_contract