palisec 0.4.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.
- palisec-0.4.0/.gitignore +26 -0
- palisec-0.4.0/LICENSE +21 -0
- palisec-0.4.0/PKG-INFO +63 -0
- palisec-0.4.0/README.md +42 -0
- palisec-0.4.0/pyproject.toml +37 -0
- palisec-0.4.0/src/palisec/__init__.py +43 -0
- palisec-0.4.0/src/palisec/client.py +492 -0
- palisec-0.4.0/src/palisec/codes.py +44 -0
- palisec-0.4.0/src/palisec/errors.py +69 -0
- palisec-0.4.0/src/palisec/models.py +126 -0
- palisec-0.4.0/src/palisec/py.typed +0 -0
- palisec-0.4.0/src/palisec/web3.py +58 -0
- palisec-0.4.0/src/palisec/webhooks.py +41 -0
- palisec-0.4.0/tests/test_client.py +346 -0
palisec-0.4.0/.gitignore
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
node_modules/
|
|
2
|
+
.next/
|
|
3
|
+
out/
|
|
4
|
+
dist/
|
|
5
|
+
target/
|
|
6
|
+
coverage/
|
|
7
|
+
*.tsbuildinfo
|
|
8
|
+
.env
|
|
9
|
+
.env.*
|
|
10
|
+
!.env.example
|
|
11
|
+
.DS_Store
|
|
12
|
+
# Foundry
|
|
13
|
+
contracts/cache/
|
|
14
|
+
contracts/out/
|
|
15
|
+
|
|
16
|
+
# Built SDK tarball, generated by the web build
|
|
17
|
+
apps/web/public/sdk/*.tgz
|
|
18
|
+
# Released versions are kept so pinned installs keep working; the newest is rebuilt on every deploy.
|
|
19
|
+
!apps/web/public/sdk/palisec-sdk-0.1.0.tgz
|
|
20
|
+
!apps/web/public/sdk/palisec-sdk-0.2.0.tgz
|
|
21
|
+
!apps/web/public/sdk/palisec-sdk-0.3.0.tgz
|
|
22
|
+
!apps/web/public/sdk/palisec-sdk-0.4.0.tgz
|
|
23
|
+
!apps/web/public/sdk/palisec-sdk-0.5.0.tgz
|
|
24
|
+
__pycache__/
|
|
25
|
+
*.pyc
|
|
26
|
+
services/policy-engine/target/
|
palisec-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Palisec
|
|
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.
|
palisec-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: palisec
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Python client for Palisec: ask before every agent transaction, send only on ALLOW.
|
|
5
|
+
Project-URL: Homepage, https://palisec.tech
|
|
6
|
+
Project-URL: Documentation, https://palisec.tech/docs/sdk/python
|
|
7
|
+
Project-URL: Changelog, https://palisec.tech/changelog
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ai-agents,authorization,erc-4337,palisec,robinhood-chain,web3
|
|
11
|
+
Classifier: Framework :: AsyncIO
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# palisec
|
|
23
|
+
|
|
24
|
+
Python client for [Palisec](https://palisec.tech): your agent asks before every transaction and sends only on ALLOW.
|
|
25
|
+
Async, typed, and no third-party dependencies. Python 3.10 or later.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install palisec
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Alternative, straight from palisec.tech: `pip install https://palisec.tech/sdk/palisec-0.4.0-py3-none-any.whl`.
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import os
|
|
35
|
+
from palisec import Palisec, PalisecDeniedError
|
|
36
|
+
|
|
37
|
+
async with Palisec(os.environ["PALISEC_API_KEY"]) as palisec: # server-side only
|
|
38
|
+
try:
|
|
39
|
+
result = await palisec.send_transaction(sender, to=TOKEN, data=calldata, gas_limit=90_000)
|
|
40
|
+
if result.hash is None:
|
|
41
|
+
print("held for a human approver:", result.operation.operation_id)
|
|
42
|
+
except PalisecDeniedError as e:
|
|
43
|
+
print(e.code, e.message) # nothing was sent
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`sender` is the agent's own account. With web3.py:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from web3 import AsyncWeb3, AsyncHTTPProvider
|
|
50
|
+
from eth_account import Account
|
|
51
|
+
from palisec.web3 import Web3Sender
|
|
52
|
+
|
|
53
|
+
w3 = AsyncWeb3(AsyncHTTPProvider("https://rpc.testnet.chain.robinhood.com"))
|
|
54
|
+
sender = Web3Sender(w3, Account.from_key(os.environ["AGENT_KEY"]))
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- `authorize(...)` records a decision: `ALLOW`, `DENY` or `REQUIRES_HUMAN_SIGNATURE`. It does not raise on DENY. Safe to retry: the request ID is the idempotency key.
|
|
58
|
+
- `evaluate(...)` is a dry run that reserves nothing.
|
|
59
|
+
- `wait_for_approval(id)`, `get_operation(id)`, `cancel(id)` (withdraws a pending approval; never retried).
|
|
60
|
+
- Errors are `PalisecError` subclasses with a stable `code` (`PS_…`). Retries happen only for network errors, 429 and 5xx, and only on calls that are safe to repeat.
|
|
61
|
+
- Log events never contain your API key, request bodies or calldata; `redact()` masks keys in any string.
|
|
62
|
+
|
|
63
|
+
Palisec runs on Robinhood Chain mainnet (4663) and testnet (46630); a `ps_live_` key is mainnet, a `ps_test_` key testnet. Agents with a PALISEC smart account are enforced on chain (`execute_with_smart_account`); an agent that sends from a plain key is enforced only in its own process. Docs: https://palisec.tech/docs/sdk/python
|
palisec-0.4.0/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# palisec
|
|
2
|
+
|
|
3
|
+
Python client for [Palisec](https://palisec.tech): your agent asks before every transaction and sends only on ALLOW.
|
|
4
|
+
Async, typed, and no third-party dependencies. Python 3.10 or later.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pip install palisec
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Alternative, straight from palisec.tech: `pip install https://palisec.tech/sdk/palisec-0.4.0-py3-none-any.whl`.
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
import os
|
|
14
|
+
from palisec import Palisec, PalisecDeniedError
|
|
15
|
+
|
|
16
|
+
async with Palisec(os.environ["PALISEC_API_KEY"]) as palisec: # server-side only
|
|
17
|
+
try:
|
|
18
|
+
result = await palisec.send_transaction(sender, to=TOKEN, data=calldata, gas_limit=90_000)
|
|
19
|
+
if result.hash is None:
|
|
20
|
+
print("held for a human approver:", result.operation.operation_id)
|
|
21
|
+
except PalisecDeniedError as e:
|
|
22
|
+
print(e.code, e.message) # nothing was sent
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`sender` is the agent's own account. With web3.py:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from web3 import AsyncWeb3, AsyncHTTPProvider
|
|
29
|
+
from eth_account import Account
|
|
30
|
+
from palisec.web3 import Web3Sender
|
|
31
|
+
|
|
32
|
+
w3 = AsyncWeb3(AsyncHTTPProvider("https://rpc.testnet.chain.robinhood.com"))
|
|
33
|
+
sender = Web3Sender(w3, Account.from_key(os.environ["AGENT_KEY"]))
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- `authorize(...)` records a decision: `ALLOW`, `DENY` or `REQUIRES_HUMAN_SIGNATURE`. It does not raise on DENY. Safe to retry: the request ID is the idempotency key.
|
|
37
|
+
- `evaluate(...)` is a dry run that reserves nothing.
|
|
38
|
+
- `wait_for_approval(id)`, `get_operation(id)`, `cancel(id)` (withdraws a pending approval; never retried).
|
|
39
|
+
- Errors are `PalisecError` subclasses with a stable `code` (`PS_…`). Retries happen only for network errors, 429 and 5xx, and only on calls that are safe to repeat.
|
|
40
|
+
- Log events never contain your API key, request bodies or calldata; `redact()` masks keys in any string.
|
|
41
|
+
|
|
42
|
+
Palisec runs on Robinhood Chain mainnet (4663) and testnet (46630); a `ps_live_` key is mainnet, a `ps_test_` key testnet. Agents with a PALISEC smart account are enforced on chain (`execute_with_smart_account`); an agent that sends from a plain key is enforced only in its own process. Docs: https://palisec.tech/docs/sdk/python
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "palisec"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Python client for Palisec: ask before every agent transaction, send only on ALLOW."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
dependencies = []
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Framework :: AsyncIO",
|
|
17
|
+
"Typing :: Typed",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
]
|
|
23
|
+
keywords = ["palisec", "ai-agents", "authorization", "erc-4337", "robinhood-chain", "web3"]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://palisec.tech"
|
|
27
|
+
Documentation = "https://palisec.tech/docs/sdk/python"
|
|
28
|
+
Changelog = "https://palisec.tech/changelog"
|
|
29
|
+
|
|
30
|
+
[tool.hatch.version]
|
|
31
|
+
path = "src/palisec/__init__.py"
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.targets.wheel]
|
|
34
|
+
packages = ["src/palisec"]
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.sdist]
|
|
37
|
+
include = ["src", "tests", "README.md", "LICENSE", "pyproject.toml"]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Palisec: your agent asks before every transaction and sends only on ALLOW.
|
|
2
|
+
|
|
3
|
+
Docs: https://palisec.tech/docs/sdk/python
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "0.4.0"
|
|
7
|
+
|
|
8
|
+
from .client import DEFAULT_BASE_URL, Palisec, Sender, Transport, redact, safe_op_typed_data, urllib_transport # noqa: E402
|
|
9
|
+
from .codes import REASON_CODES, RETRYABLE # noqa: E402
|
|
10
|
+
from .errors import ( # noqa: E402
|
|
11
|
+
PalisecApprovalError,
|
|
12
|
+
PalisecConfigError,
|
|
13
|
+
PalisecDeniedError,
|
|
14
|
+
PalisecError,
|
|
15
|
+
PalisecTimeoutError,
|
|
16
|
+
)
|
|
17
|
+
from .models import SUPPORTED_CHAINS, Check, Intent, LogEvent, Operation, SendResult # noqa: E402
|
|
18
|
+
from . import webhooks # noqa: E402
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"DEFAULT_BASE_URL",
|
|
22
|
+
"REASON_CODES",
|
|
23
|
+
"RETRYABLE",
|
|
24
|
+
"SUPPORTED_CHAINS",
|
|
25
|
+
"Check",
|
|
26
|
+
"Intent",
|
|
27
|
+
"LogEvent",
|
|
28
|
+
"Operation",
|
|
29
|
+
"Palisec",
|
|
30
|
+
"PalisecApprovalError",
|
|
31
|
+
"PalisecConfigError",
|
|
32
|
+
"PalisecDeniedError",
|
|
33
|
+
"PalisecError",
|
|
34
|
+
"PalisecTimeoutError",
|
|
35
|
+
"Sender",
|
|
36
|
+
"SendResult",
|
|
37
|
+
"Transport",
|
|
38
|
+
"redact",
|
|
39
|
+
"safe_op_typed_data",
|
|
40
|
+
"urllib_transport",
|
|
41
|
+
"webhooks",
|
|
42
|
+
"__version__",
|
|
43
|
+
]
|