oceanalt-aml 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.
- oceanalt_aml-0.1.0/PKG-INFO +32 -0
- oceanalt_aml-0.1.0/README.md +20 -0
- oceanalt_aml-0.1.0/oceanalt_aml/__init__.py +107 -0
- oceanalt_aml-0.1.0/oceanalt_aml.egg-info/PKG-INFO +32 -0
- oceanalt_aml-0.1.0/oceanalt_aml.egg-info/SOURCES.txt +7 -0
- oceanalt_aml-0.1.0/oceanalt_aml.egg-info/dependency_links.txt +1 -0
- oceanalt_aml-0.1.0/oceanalt_aml.egg-info/top_level.txt +1 -0
- oceanalt_aml-0.1.0/pyproject.toml +17 -0
- oceanalt_aml-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: oceanalt-aml
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OceanAlt pre-payment check for AI agents: allow, review or decline before your agent pays. Includes an Amazon Bedrock AgentCore pre_sign_policy.
|
|
5
|
+
Author-email: OceanAlt <business@oceanalt.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://oceanalt.com
|
|
8
|
+
Project-URL: Documentation, https://oceanalt.com/en/api-docs
|
|
9
|
+
Keywords: oceanalt,ai-agents,agent-payments,x402,pre-payment,mcp,agentcore
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# oceanalt-aml
|
|
14
|
+
|
|
15
|
+
OceanAlt pre-payment check for AI agents: before your agent pays, ask whether the payment should proceed. Returns `allow`, `review` or `decline` with reasons and evidence.
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from oceanalt_aml import decide
|
|
19
|
+
r = decide("0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", network="ethereum")
|
|
20
|
+
print(r["decision"]) # decline: a known mixer
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Amazon Bedrock AgentCore payments
|
|
24
|
+
|
|
25
|
+
Use it as the `pre_sign_policy` of your payments integration config. It returns `True` only when every payee in the payment request gets `allow`. A decline, a review, a timeout or a request it cannot read returns `False`, so the payment is not signed. Reads x402 v1 bodies and the x402 v2 `Payment-Required` header.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from oceanalt_aml import agentcore_pre_sign_policy
|
|
29
|
+
# config = <your AgentCore payments integration config>(..., pre_sign_policy=agentcore_pre_sign_policy)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Free, no key, no dependencies. Docs: https://oceanalt.com/en/api-docs · Hosted MCP server: https://oceanalt.com/api/mcp
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# oceanalt-aml
|
|
2
|
+
|
|
3
|
+
OceanAlt pre-payment check for AI agents: before your agent pays, ask whether the payment should proceed. Returns `allow`, `review` or `decline` with reasons and evidence.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from oceanalt_aml import decide
|
|
7
|
+
r = decide("0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", network="ethereum")
|
|
8
|
+
print(r["decision"]) # decline: a known mixer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Amazon Bedrock AgentCore payments
|
|
12
|
+
|
|
13
|
+
Use it as the `pre_sign_policy` of your payments integration config. It returns `True` only when every payee in the payment request gets `allow`. A decline, a review, a timeout or a request it cannot read returns `False`, so the payment is not signed. Reads x402 v1 bodies and the x402 v2 `Payment-Required` header.
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from oceanalt_aml import agentcore_pre_sign_policy
|
|
17
|
+
# config = <your AgentCore payments integration config>(..., pre_sign_policy=agentcore_pre_sign_policy)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Free, no key, no dependencies. Docs: https://oceanalt.com/en/api-docs · Hosted MCP server: https://oceanalt.com/api/mcp
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""OceanAlt pre-payment check: ask whether a payment should proceed before your agent pays.
|
|
2
|
+
|
|
3
|
+
from oceanalt_aml import decide
|
|
4
|
+
result = decide("0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", network="ethereum")
|
|
5
|
+
result["decision"] # "allow", "review" or "decline"
|
|
6
|
+
|
|
7
|
+
Amazon Bedrock AgentCore payments: pass ``agentcore_pre_sign_policy`` as the
|
|
8
|
+
``pre_sign_policy`` of your payments integration config. It returns True only when
|
|
9
|
+
OceanAlt answers ``allow`` for every payee in the payment request; anything else,
|
|
10
|
+
including a timeout or a request it cannot read, blocks signing.
|
|
11
|
+
|
|
12
|
+
Free, no key. Docs: https://oceanalt.com/en/api-docs
|
|
13
|
+
Hosted MCP server: https://oceanalt.com/api/mcp
|
|
14
|
+
"""
|
|
15
|
+
import base64
|
|
16
|
+
import json
|
|
17
|
+
import urllib.parse
|
|
18
|
+
import urllib.request
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.0"
|
|
21
|
+
BASE_URL = "https://oceanalt.com"
|
|
22
|
+
_UA = "oceanalt-aml-python/" + __version__
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def decide(to, network=None, timeout=10.0, base_url=BASE_URL):
|
|
26
|
+
"""Return OceanAlt's pre-payment decision for a payee address as a dict.
|
|
27
|
+
|
|
28
|
+
Anything other than decision == "allow" means do not pay without review.
|
|
29
|
+
Network or HTTP errors raise; treat them as not cleared.
|
|
30
|
+
"""
|
|
31
|
+
params = {"to": str(to)}
|
|
32
|
+
if network:
|
|
33
|
+
params["network"] = str(network)
|
|
34
|
+
url = base_url.rstrip("/") + "/api/decide?" + urllib.parse.urlencode(params)
|
|
35
|
+
req = urllib.request.Request(url, headers={"accept": "application/json", "user-agent": _UA})
|
|
36
|
+
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
|
37
|
+
return json.loads(resp.read().decode("utf-8"))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _b64json(text):
|
|
41
|
+
s = str(text).strip()
|
|
42
|
+
s = s + "=" * (-len(s) % 4)
|
|
43
|
+
for dec in (base64.b64decode, base64.urlsafe_b64decode):
|
|
44
|
+
try:
|
|
45
|
+
return json.loads(dec(s).decode("utf-8"))
|
|
46
|
+
except Exception:
|
|
47
|
+
continue
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _header(headers, name):
|
|
52
|
+
if not isinstance(headers, dict):
|
|
53
|
+
return None
|
|
54
|
+
for k, v in headers.items():
|
|
55
|
+
if str(k).lower() == name.lower():
|
|
56
|
+
return v
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def payees_from_request(request):
|
|
61
|
+
"""Extract (payTo, network) pairs from an AgentCore payment-required request.
|
|
62
|
+
|
|
63
|
+
Handles x402 v1 (dict or JSON-string body with ``accepts``) and x402 v2
|
|
64
|
+
(base64 JSON in the ``Payment-Required`` header). Returns [] when nothing
|
|
65
|
+
can be read, which the policy treats as a block.
|
|
66
|
+
"""
|
|
67
|
+
if not isinstance(request, dict):
|
|
68
|
+
return []
|
|
69
|
+
docs = []
|
|
70
|
+
body = request.get("body")
|
|
71
|
+
if isinstance(body, str):
|
|
72
|
+
try:
|
|
73
|
+
body = json.loads(body)
|
|
74
|
+
except Exception:
|
|
75
|
+
body = None
|
|
76
|
+
if isinstance(body, dict):
|
|
77
|
+
docs.append(body)
|
|
78
|
+
hdr = _header(request.get("headers"), "Payment-Required")
|
|
79
|
+
if hdr:
|
|
80
|
+
decoded = _b64json(hdr)
|
|
81
|
+
if isinstance(decoded, dict):
|
|
82
|
+
docs.append(decoded)
|
|
83
|
+
out = []
|
|
84
|
+
for doc in docs:
|
|
85
|
+
for acc in doc.get("accepts") or []:
|
|
86
|
+
if isinstance(acc, dict) and acc.get("payTo"):
|
|
87
|
+
out.append((str(acc["payTo"]), str(acc.get("network") or "") or None))
|
|
88
|
+
return out
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def agentcore_pre_sign_policy(request, timeout=8.0, base_url=BASE_URL):
|
|
92
|
+
"""``pre_sign_policy`` for Amazon Bedrock AgentCore payments.
|
|
93
|
+
|
|
94
|
+
True only if every payee offered in the request gets ``allow``. A request
|
|
95
|
+
that cannot be read (for example MPP), a timeout, an error or any other
|
|
96
|
+
decision returns False, so the payment is not signed.
|
|
97
|
+
"""
|
|
98
|
+
try:
|
|
99
|
+
payees = payees_from_request(request)
|
|
100
|
+
if not payees:
|
|
101
|
+
return False
|
|
102
|
+
for pay_to, network in payees:
|
|
103
|
+
if decide(pay_to, network=network, timeout=timeout, base_url=base_url).get("decision") != "allow":
|
|
104
|
+
return False
|
|
105
|
+
return True
|
|
106
|
+
except Exception:
|
|
107
|
+
return False
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: oceanalt-aml
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OceanAlt pre-payment check for AI agents: allow, review or decline before your agent pays. Includes an Amazon Bedrock AgentCore pre_sign_policy.
|
|
5
|
+
Author-email: OceanAlt <business@oceanalt.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://oceanalt.com
|
|
8
|
+
Project-URL: Documentation, https://oceanalt.com/en/api-docs
|
|
9
|
+
Keywords: oceanalt,ai-agents,agent-payments,x402,pre-payment,mcp,agentcore
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# oceanalt-aml
|
|
14
|
+
|
|
15
|
+
OceanAlt pre-payment check for AI agents: before your agent pays, ask whether the payment should proceed. Returns `allow`, `review` or `decline` with reasons and evidence.
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from oceanalt_aml import decide
|
|
19
|
+
r = decide("0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", network="ethereum")
|
|
20
|
+
print(r["decision"]) # decline: a known mixer
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Amazon Bedrock AgentCore payments
|
|
24
|
+
|
|
25
|
+
Use it as the `pre_sign_policy` of your payments integration config. It returns `True` only when every payee in the payment request gets `allow`. A decline, a review, a timeout or a request it cannot read returns `False`, so the payment is not signed. Reads x402 v1 bodies and the x402 v2 `Payment-Required` header.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from oceanalt_aml import agentcore_pre_sign_policy
|
|
29
|
+
# config = <your AgentCore payments integration config>(..., pre_sign_policy=agentcore_pre_sign_policy)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Free, no key, no dependencies. Docs: https://oceanalt.com/en/api-docs · Hosted MCP server: https://oceanalt.com/api/mcp
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
oceanalt_aml
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "oceanalt-aml"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "OceanAlt pre-payment check for AI agents: allow, review or decline before your agent pays. Includes an Amazon Bedrock AgentCore pre_sign_policy."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [{ name = "OceanAlt", email = "business@oceanalt.com" }]
|
|
13
|
+
keywords = ["oceanalt", "ai-agents", "agent-payments", "x402", "pre-payment", "mcp", "agentcore"]
|
|
14
|
+
|
|
15
|
+
[project.urls]
|
|
16
|
+
Homepage = "https://oceanalt.com"
|
|
17
|
+
Documentation = "https://oceanalt.com/en/api-docs"
|