runtimeai-aep 1.0.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.
runtimeai_aep/client.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""RuntimeAI AEP Python SDK — zero external dependencies (stdlib only)."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import urllib.request
|
|
5
|
+
import urllib.error
|
|
6
|
+
from typing import Any, Dict, Optional
|
|
7
|
+
|
|
8
|
+
SDK_VERSION = "1.0.0"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AEPError(Exception):
|
|
12
|
+
def __init__(self, status_code: int, body: str):
|
|
13
|
+
self.status_code = status_code
|
|
14
|
+
self.body = body
|
|
15
|
+
super().__init__(f"AEP API error {status_code}: {body}")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AEPClient:
|
|
19
|
+
"""Client for the RuntimeAI Agentic Enablement Platform API.
|
|
20
|
+
|
|
21
|
+
Usage::
|
|
22
|
+
|
|
23
|
+
client = AEPClient("https://api.runtimeai.com", api_key="your-key")
|
|
24
|
+
agent = client.register_agent(tenant_id="acme", name="billing-agent")
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, base_url: str, *, api_key: str = "", auth_token: str = "", timeout: int = 30):
|
|
28
|
+
self.base_url = base_url.rstrip("/")
|
|
29
|
+
self.api_key = api_key
|
|
30
|
+
self.auth_token = auth_token
|
|
31
|
+
self.timeout = timeout
|
|
32
|
+
|
|
33
|
+
def _request(self, method: str, path: str, body: Optional[Dict] = None) -> Any:
|
|
34
|
+
url = self.base_url + path
|
|
35
|
+
data = json.dumps(body).encode() if body is not None else None
|
|
36
|
+
req = urllib.request.Request(url, data=data, method=method)
|
|
37
|
+
req.add_header("Content-Type", "application/json")
|
|
38
|
+
req.add_header("X-AEP-SDK-Version", SDK_VERSION)
|
|
39
|
+
if self.api_key:
|
|
40
|
+
req.add_header("X-API-Key", self.api_key)
|
|
41
|
+
if self.auth_token:
|
|
42
|
+
req.add_header("Authorization", f"Bearer {self.auth_token}")
|
|
43
|
+
try:
|
|
44
|
+
with urllib.request.urlopen(req, timeout=self.timeout) as resp:
|
|
45
|
+
return json.loads(resp.read())
|
|
46
|
+
except urllib.error.HTTPError as e:
|
|
47
|
+
raise AEPError(e.code, e.read().decode()) from e
|
|
48
|
+
|
|
49
|
+
# ── KYA (Know Your Agent) ─────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
def register_agent(self, *, tenant_id: str, name: str, description: str = "", metadata: Optional[Dict] = None) -> Dict:
|
|
52
|
+
return self._request("POST", "/api/v1/kya/agents", {
|
|
53
|
+
"tenant_id": tenant_id,
|
|
54
|
+
"name": name,
|
|
55
|
+
"description": description,
|
|
56
|
+
"metadata": metadata or {},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
def get_agent(self, agent_id: str) -> Dict:
|
|
60
|
+
return self._request("GET", f"/api/v1/kya/agents/{agent_id}")
|
|
61
|
+
|
|
62
|
+
# ── Cost Control ──────────────────────────────────────────────────────
|
|
63
|
+
|
|
64
|
+
def set_budget_policy(self, *, agent_id: str, tenant_id: str, limit_usd: float, period_days: int = 30) -> None:
|
|
65
|
+
self._request("POST", "/api/v1/cost-control/policies", {
|
|
66
|
+
"agent_id": agent_id,
|
|
67
|
+
"tenant_id": tenant_id,
|
|
68
|
+
"limit_usd": limit_usd,
|
|
69
|
+
"period_days": period_days,
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
# ── PII Shield ────────────────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
def tokenize_pii(self, *, tenant_id: str, text: str) -> Dict:
|
|
75
|
+
"""Returns {"tokenized_text": ..., "mapping": {...}}."""
|
|
76
|
+
return self._request("POST", "/api/v1/pii-shield/tokenize", {
|
|
77
|
+
"tenant_id": tenant_id,
|
|
78
|
+
"text": text,
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
# ── Fraud Shield ──────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
def check_fraud(self, *, agent_id: str, tenant_id: str, action: str, context: Optional[Dict] = None) -> Dict:
|
|
84
|
+
"""Returns {"risk": "low|medium|high|blocked", "score": float, "blocked": bool}."""
|
|
85
|
+
return self._request("POST", "/api/v1/fraud-shield/check", {
|
|
86
|
+
"agent_id": agent_id,
|
|
87
|
+
"tenant_id": tenant_id,
|
|
88
|
+
"action": action,
|
|
89
|
+
"context": context or {},
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
# ── Audit Black Box ───────────────────────────────────────────────────
|
|
93
|
+
|
|
94
|
+
def log_audit_event(self, *, agent_id: str, tenant_id: str, action: str, payload: Optional[Dict] = None) -> None:
|
|
95
|
+
self._request("POST", "/api/v1/audit/events", {
|
|
96
|
+
"agent_id": agent_id,
|
|
97
|
+
"tenant_id": tenant_id,
|
|
98
|
+
"action": action,
|
|
99
|
+
"payload": payload or {},
|
|
100
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: runtimeai-aep
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: RuntimeAI AEP SDK — Agentic Enablement Platform client for Python
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://runtimeai.com/products/aep
|
|
7
|
+
Project-URL: Documentation, https://docs.runtimeai.com/sdks/python
|
|
8
|
+
Project-URL: Repository, https://github.com/runtimeai/aep-sdk-python
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
+
Classifier: Topic :: Security
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
runtimeai_aep/__init__.py,sha256=NnmjZtBPA9STEehs1GpGEhl0-CL3qbb-i1TKGyyl9gQ,77
|
|
2
|
+
runtimeai_aep/client.py,sha256=b9MCOzCep-tOC_c7UvubI-lIkD9t-fJwhL3Q1Fg8hZo,4459
|
|
3
|
+
runtimeai_aep-1.0.0.dist-info/METADATA,sha256=4Q-Gp-84gAFqUdHka02o4zi99l0HOkU8flsQ2brlMtU,653
|
|
4
|
+
runtimeai_aep-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
runtimeai_aep-1.0.0.dist-info/top_level.txt,sha256=iSM-vU3VW5572sXj-0lXC8WgiokKX4L9-wvYh8YpzuM,14
|
|
6
|
+
runtimeai_aep-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
runtimeai_aep
|