jarvisclaw 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.
- jarvisclaw-0.1.0/PKG-INFO +77 -0
- jarvisclaw-0.1.0/README.md +64 -0
- jarvisclaw-0.1.0/jarvisclaw/__init__.py +4 -0
- jarvisclaw-0.1.0/jarvisclaw/client.py +153 -0
- jarvisclaw-0.1.0/jarvisclaw.egg-info/PKG-INFO +77 -0
- jarvisclaw-0.1.0/jarvisclaw.egg-info/SOURCES.txt +9 -0
- jarvisclaw-0.1.0/jarvisclaw.egg-info/dependency_links.txt +1 -0
- jarvisclaw-0.1.0/jarvisclaw.egg-info/requires.txt +3 -0
- jarvisclaw-0.1.0/jarvisclaw.egg-info/top_level.txt +1 -0
- jarvisclaw-0.1.0/pyproject.toml +20 -0
- jarvisclaw-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jarvisclaw
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: JarvisClaw AI & Prediction Market SDK — x402 machine payments
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://jarvisclaw.ai
|
|
7
|
+
Project-URL: Documentation, https://api.jarvisclaw.ai/docs
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: requests>=2.28
|
|
11
|
+
Requires-Dist: eth-account>=0.10
|
|
12
|
+
Requires-Dist: eth-abi>=4.0
|
|
13
|
+
|
|
14
|
+
# JarvisClaw SDK
|
|
15
|
+
|
|
16
|
+
Python SDK for JarvisClaw AI & Prediction Market APIs with x402 machine payments.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install jarvisclaw
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
### AI Agent (x402 direct payment — no API key needed)
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from jarvisclaw import JarvisClawClient
|
|
30
|
+
|
|
31
|
+
# Your agent's wallet (needs USDC on Base chain)
|
|
32
|
+
client = JarvisClawClient(private_key="0x<your-wallet-private-key>")
|
|
33
|
+
|
|
34
|
+
# AI model call — SDK handles 402 → sign → retry automatically
|
|
35
|
+
response = client.post("/v1/chat/completions", json={
|
|
36
|
+
"model": "openai/gpt-5.4-nano",
|
|
37
|
+
"messages": [{"role": "user", "content": "Hello!"}]
|
|
38
|
+
})
|
|
39
|
+
print(response["choices"][0]["message"]["content"])
|
|
40
|
+
|
|
41
|
+
# Prediction market data
|
|
42
|
+
markets = client.get("/v1/prediction/polymarket/markets", params={"limit": 10})
|
|
43
|
+
print(markets)
|
|
44
|
+
|
|
45
|
+
# Sports betting odds
|
|
46
|
+
sports = client.get("/v1/prediction/sports/markets", params={"category": "soccer"})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### API Key (traditional — for human users)
|
|
50
|
+
|
|
51
|
+
If you have an API key, you don't need this SDK. Just use the standard OpenAI SDK:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from openai import OpenAI
|
|
55
|
+
|
|
56
|
+
client = OpenAI(
|
|
57
|
+
base_url="https://api.jarvisclaw.ai/v1",
|
|
58
|
+
api_key="sk-your-api-key"
|
|
59
|
+
)
|
|
60
|
+
response = client.chat.completions.create(
|
|
61
|
+
model="auto",
|
|
62
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Requirements
|
|
67
|
+
|
|
68
|
+
- Python >= 3.9
|
|
69
|
+
- Wallet with USDC on Base chain (Chain ID 8453)
|
|
70
|
+
- No ETH needed (facilitator pays gas)
|
|
71
|
+
|
|
72
|
+
## Pricing
|
|
73
|
+
|
|
74
|
+
- AI models: per-token (see https://api.jarvisclaw.ai/pricing)
|
|
75
|
+
- Prediction GET: $0.001/request
|
|
76
|
+
- Prediction POST: $0.005/request
|
|
77
|
+
- Zero markup on upstream costs
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# JarvisClaw SDK
|
|
2
|
+
|
|
3
|
+
Python SDK for JarvisClaw AI & Prediction Market APIs with x402 machine payments.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install jarvisclaw
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### AI Agent (x402 direct payment — no API key needed)
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from jarvisclaw import JarvisClawClient
|
|
17
|
+
|
|
18
|
+
# Your agent's wallet (needs USDC on Base chain)
|
|
19
|
+
client = JarvisClawClient(private_key="0x<your-wallet-private-key>")
|
|
20
|
+
|
|
21
|
+
# AI model call — SDK handles 402 → sign → retry automatically
|
|
22
|
+
response = client.post("/v1/chat/completions", json={
|
|
23
|
+
"model": "openai/gpt-5.4-nano",
|
|
24
|
+
"messages": [{"role": "user", "content": "Hello!"}]
|
|
25
|
+
})
|
|
26
|
+
print(response["choices"][0]["message"]["content"])
|
|
27
|
+
|
|
28
|
+
# Prediction market data
|
|
29
|
+
markets = client.get("/v1/prediction/polymarket/markets", params={"limit": 10})
|
|
30
|
+
print(markets)
|
|
31
|
+
|
|
32
|
+
# Sports betting odds
|
|
33
|
+
sports = client.get("/v1/prediction/sports/markets", params={"category": "soccer"})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### API Key (traditional — for human users)
|
|
37
|
+
|
|
38
|
+
If you have an API key, you don't need this SDK. Just use the standard OpenAI SDK:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from openai import OpenAI
|
|
42
|
+
|
|
43
|
+
client = OpenAI(
|
|
44
|
+
base_url="https://api.jarvisclaw.ai/v1",
|
|
45
|
+
api_key="sk-your-api-key"
|
|
46
|
+
)
|
|
47
|
+
response = client.chat.completions.create(
|
|
48
|
+
model="auto",
|
|
49
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
50
|
+
)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Requirements
|
|
54
|
+
|
|
55
|
+
- Python >= 3.9
|
|
56
|
+
- Wallet with USDC on Base chain (Chain ID 8453)
|
|
57
|
+
- No ETH needed (facilitator pays gas)
|
|
58
|
+
|
|
59
|
+
## Pricing
|
|
60
|
+
|
|
61
|
+
- AI models: per-token (see https://api.jarvisclaw.ai/pricing)
|
|
62
|
+
- Prediction GET: $0.001/request
|
|
63
|
+
- Prediction POST: $0.005/request
|
|
64
|
+
- Zero markup on upstream costs
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""
|
|
2
|
+
JarvisClaw SDK — x402 Machine Payment Client
|
|
3
|
+
|
|
4
|
+
Handles the full x402 payment flow:
|
|
5
|
+
1. Send request → receive 402 + payment requirements
|
|
6
|
+
2. Sign payment with wallet private key (EIP-712)
|
|
7
|
+
3. Retry request with PAYMENT-SIGNATURE header
|
|
8
|
+
"""
|
|
9
|
+
import base64
|
|
10
|
+
import json
|
|
11
|
+
import time
|
|
12
|
+
from typing import Any, Optional
|
|
13
|
+
|
|
14
|
+
import requests
|
|
15
|
+
from eth_account import Account
|
|
16
|
+
from eth_account.messages import encode_typed_data
|
|
17
|
+
|
|
18
|
+
DEFAULT_BASE_URL = "https://api.jarvisclaw.ai"
|
|
19
|
+
DEFAULT_NETWORK = "eip155:8453"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class JarvisClawClient:
|
|
23
|
+
"""x402-enabled HTTP client for JarvisClaw APIs.
|
|
24
|
+
|
|
25
|
+
Usage:
|
|
26
|
+
client = JarvisClawClient(private_key="0x...")
|
|
27
|
+
|
|
28
|
+
# AI model call
|
|
29
|
+
resp = client.post("/v1/chat/completions", json={
|
|
30
|
+
"model": "openai/gpt-5.4-nano",
|
|
31
|
+
"messages": [{"role": "user", "content": "Hello"}]
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
# Prediction market data
|
|
35
|
+
markets = client.get("/v1/prediction/polymarket/markets")
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
private_key: str,
|
|
41
|
+
base_url: str = DEFAULT_BASE_URL,
|
|
42
|
+
network: str = DEFAULT_NETWORK,
|
|
43
|
+
timeout: int = 60,
|
|
44
|
+
max_retries: int = 1,
|
|
45
|
+
):
|
|
46
|
+
self.account = Account.from_key(private_key)
|
|
47
|
+
self.base_url = base_url.rstrip("/")
|
|
48
|
+
self.network = network
|
|
49
|
+
self.timeout = timeout
|
|
50
|
+
self.max_retries = max_retries
|
|
51
|
+
self.session = requests.Session()
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def address(self) -> str:
|
|
55
|
+
return self.account.address
|
|
56
|
+
|
|
57
|
+
def get(self, path: str, **kwargs) -> Any:
|
|
58
|
+
return self._request("GET", path, **kwargs)
|
|
59
|
+
|
|
60
|
+
def post(self, path: str, **kwargs) -> Any:
|
|
61
|
+
return self._request("POST", path, **kwargs)
|
|
62
|
+
|
|
63
|
+
def _request(self, method: str, path: str, **kwargs) -> Any:
|
|
64
|
+
url = self.base_url + path
|
|
65
|
+
kwargs.setdefault("timeout", self.timeout)
|
|
66
|
+
|
|
67
|
+
resp = self.session.request(method, url, **kwargs)
|
|
68
|
+
|
|
69
|
+
if resp.status_code != 402:
|
|
70
|
+
resp.raise_for_status()
|
|
71
|
+
return resp.json()
|
|
72
|
+
|
|
73
|
+
# Handle x402 payment
|
|
74
|
+
payment_req = self._parse_payment_required(resp)
|
|
75
|
+
signature = self._sign_payment(payment_req, url)
|
|
76
|
+
|
|
77
|
+
headers = kwargs.pop("headers", {}) or {}
|
|
78
|
+
headers["PAYMENT-SIGNATURE"] = signature
|
|
79
|
+
|
|
80
|
+
retry_resp = self.session.request(method, url, headers=headers, **kwargs)
|
|
81
|
+
retry_resp.raise_for_status()
|
|
82
|
+
return retry_resp.json()
|
|
83
|
+
|
|
84
|
+
def _parse_payment_required(self, resp: requests.Response) -> dict:
|
|
85
|
+
header = resp.headers.get("payment-required", "")
|
|
86
|
+
if header:
|
|
87
|
+
return json.loads(header)
|
|
88
|
+
return resp.json()
|
|
89
|
+
|
|
90
|
+
def _sign_payment(self, payment_req: dict, resource_url: str) -> str:
|
|
91
|
+
pay_to = payment_req.get("payTo", "")
|
|
92
|
+
amount = payment_req.get("maxAmountRequired", "0")
|
|
93
|
+
network = payment_req.get("network", self.network)
|
|
94
|
+
max_timeout = payment_req.get("maxTimeoutSeconds", 300)
|
|
95
|
+
description = payment_req.get("description", "")
|
|
96
|
+
|
|
97
|
+
# Build x402 payment payload
|
|
98
|
+
payload = {
|
|
99
|
+
"x402Version": 1,
|
|
100
|
+
"scheme": "exact",
|
|
101
|
+
"network": network,
|
|
102
|
+
"payload": {
|
|
103
|
+
"signature": "",
|
|
104
|
+
"authorization": {
|
|
105
|
+
"from": self.account.address,
|
|
106
|
+
"to": pay_to,
|
|
107
|
+
"value": amount,
|
|
108
|
+
"validAfter": str(int(time.time()) - 60),
|
|
109
|
+
"validBefore": str(int(time.time()) + max_timeout),
|
|
110
|
+
"nonce": self._generate_nonce(),
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
"resource": resource_url,
|
|
114
|
+
"description": description,
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
# Sign the authorization with EIP-712
|
|
118
|
+
auth = payload["payload"]["authorization"]
|
|
119
|
+
domain = {
|
|
120
|
+
"name": "USD Coin",
|
|
121
|
+
"version": "2",
|
|
122
|
+
"chainId": int(network.split(":")[1]) if ":" in network else 8453,
|
|
123
|
+
"verifyingContract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
124
|
+
}
|
|
125
|
+
types = {
|
|
126
|
+
"TransferWithAuthorization": [
|
|
127
|
+
{"name": "from", "type": "address"},
|
|
128
|
+
{"name": "to", "type": "address"},
|
|
129
|
+
{"name": "value", "type": "uint256"},
|
|
130
|
+
{"name": "validAfter", "type": "uint256"},
|
|
131
|
+
{"name": "validBefore", "type": "uint256"},
|
|
132
|
+
{"name": "nonce", "type": "bytes32"},
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
message = {
|
|
136
|
+
"from": auth["from"],
|
|
137
|
+
"to": auth["to"],
|
|
138
|
+
"value": int(auth["value"]),
|
|
139
|
+
"validAfter": int(auth["validAfter"]),
|
|
140
|
+
"validBefore": int(auth["validBefore"]),
|
|
141
|
+
"nonce": bytes.fromhex(auth["nonce"][2:]) if auth["nonce"].startswith("0x") else bytes.fromhex(auth["nonce"]),
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
signable = encode_typed_data(domain, types, message)
|
|
145
|
+
signed = self.account.sign_message(signable)
|
|
146
|
+
payload["payload"]["signature"] = signed.signature.hex()
|
|
147
|
+
|
|
148
|
+
payload_json = json.dumps(payload, separators=(",", ":"))
|
|
149
|
+
return base64.b64encode(payload_json.encode()).decode()
|
|
150
|
+
|
|
151
|
+
def _generate_nonce(self) -> str:
|
|
152
|
+
import os
|
|
153
|
+
return "0x" + os.urandom(32).hex()
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jarvisclaw
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: JarvisClaw AI & Prediction Market SDK — x402 machine payments
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://jarvisclaw.ai
|
|
7
|
+
Project-URL: Documentation, https://api.jarvisclaw.ai/docs
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: requests>=2.28
|
|
11
|
+
Requires-Dist: eth-account>=0.10
|
|
12
|
+
Requires-Dist: eth-abi>=4.0
|
|
13
|
+
|
|
14
|
+
# JarvisClaw SDK
|
|
15
|
+
|
|
16
|
+
Python SDK for JarvisClaw AI & Prediction Market APIs with x402 machine payments.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install jarvisclaw
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
### AI Agent (x402 direct payment — no API key needed)
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from jarvisclaw import JarvisClawClient
|
|
30
|
+
|
|
31
|
+
# Your agent's wallet (needs USDC on Base chain)
|
|
32
|
+
client = JarvisClawClient(private_key="0x<your-wallet-private-key>")
|
|
33
|
+
|
|
34
|
+
# AI model call — SDK handles 402 → sign → retry automatically
|
|
35
|
+
response = client.post("/v1/chat/completions", json={
|
|
36
|
+
"model": "openai/gpt-5.4-nano",
|
|
37
|
+
"messages": [{"role": "user", "content": "Hello!"}]
|
|
38
|
+
})
|
|
39
|
+
print(response["choices"][0]["message"]["content"])
|
|
40
|
+
|
|
41
|
+
# Prediction market data
|
|
42
|
+
markets = client.get("/v1/prediction/polymarket/markets", params={"limit": 10})
|
|
43
|
+
print(markets)
|
|
44
|
+
|
|
45
|
+
# Sports betting odds
|
|
46
|
+
sports = client.get("/v1/prediction/sports/markets", params={"category": "soccer"})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### API Key (traditional — for human users)
|
|
50
|
+
|
|
51
|
+
If you have an API key, you don't need this SDK. Just use the standard OpenAI SDK:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from openai import OpenAI
|
|
55
|
+
|
|
56
|
+
client = OpenAI(
|
|
57
|
+
base_url="https://api.jarvisclaw.ai/v1",
|
|
58
|
+
api_key="sk-your-api-key"
|
|
59
|
+
)
|
|
60
|
+
response = client.chat.completions.create(
|
|
61
|
+
model="auto",
|
|
62
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Requirements
|
|
67
|
+
|
|
68
|
+
- Python >= 3.9
|
|
69
|
+
- Wallet with USDC on Base chain (Chain ID 8453)
|
|
70
|
+
- No ETH needed (facilitator pays gas)
|
|
71
|
+
|
|
72
|
+
## Pricing
|
|
73
|
+
|
|
74
|
+
- AI models: per-token (see https://api.jarvisclaw.ai/pricing)
|
|
75
|
+
- Prediction GET: $0.001/request
|
|
76
|
+
- Prediction POST: $0.005/request
|
|
77
|
+
- Zero markup on upstream costs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
jarvisclaw
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "jarvisclaw"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "JarvisClaw AI & Prediction Market SDK — x402 machine payments"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"requests>=2.28",
|
|
14
|
+
"eth-account>=0.10",
|
|
15
|
+
"eth-abi>=4.0",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://jarvisclaw.ai"
|
|
20
|
+
Documentation = "https://api.jarvisclaw.ai/docs"
|