@valiron/sdk 0.9.1 → 0.9.2
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.
- package/docs/API-REFERENCE.md +181 -0
- package/docs/CHAINS.md +70 -0
- package/docs/ERRORS.md +105 -0
- package/docs/IDENTITY.md +149 -0
- package/docs/QUICKSTART.md +71 -0
- package/docs/README.md +36 -0
- package/docs/SANDBOX.md +70 -0
- package/docs/SDK-REFERENCE.md +264 -0
- package/docs/TRUST-MODEL.md +102 -0
- package/docs/llms.txt +93 -0
- package/package.json +2 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Base URL: `https://valiron-edge-proxy.onrender.com`
|
|
4
|
+
|
|
5
|
+
All endpoints are under the `/operator/` path prefix.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## GET /operator/agent/:agentId
|
|
10
|
+
|
|
11
|
+
Retrieve the complete trust profile for an agent.
|
|
12
|
+
|
|
13
|
+
### Parameters
|
|
14
|
+
|
|
15
|
+
| Parameter | Location | Type | Required | Description |
|
|
16
|
+
|-----------|----------|------|----------|-------------|
|
|
17
|
+
| `agentId` | path | string | yes | ERC-8004 token ID |
|
|
18
|
+
| `chain` | query | string | no | Network override (default: ethereum) |
|
|
19
|
+
|
|
20
|
+
### Response — 200 OK
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"agentId": "25459",
|
|
25
|
+
"identity": {
|
|
26
|
+
"agentId": "25459",
|
|
27
|
+
"wallet": "0x52ce...",
|
|
28
|
+
"tokenUri": "data:application/json;base64,...",
|
|
29
|
+
"name": "Agent Name",
|
|
30
|
+
"image": "https://...",
|
|
31
|
+
"description": "Agent description",
|
|
32
|
+
"endpoints": {
|
|
33
|
+
"agentWallet": "eip155:1:0x...",
|
|
34
|
+
"api": "https://api.example.com"
|
|
35
|
+
},
|
|
36
|
+
"trustModels": ["reputation_on_chain", "behavioral_sandbox"]
|
|
37
|
+
},
|
|
38
|
+
"onchainReputation": {
|
|
39
|
+
"feedbackCount": 12,
|
|
40
|
+
"averageScore": 92.5
|
|
41
|
+
},
|
|
42
|
+
"routing": {
|
|
43
|
+
"finalRoute": "prod",
|
|
44
|
+
"meetsThreshold": true
|
|
45
|
+
},
|
|
46
|
+
"chain": {
|
|
47
|
+
"name": "ethereum",
|
|
48
|
+
"chainId": 1
|
|
49
|
+
},
|
|
50
|
+
"timestamp": "2026-03-23T12:00:00.000Z"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Error Responses
|
|
55
|
+
|
|
56
|
+
| Status | Meaning |
|
|
57
|
+
|--------|---------|
|
|
58
|
+
| 404 | Agent not found in ERC-8004 registry |
|
|
59
|
+
| 500 | Internal server error |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## GET /operator/wallet/:wallet
|
|
64
|
+
|
|
65
|
+
Reverse-lookup a wallet address to get its trust profile.
|
|
66
|
+
|
|
67
|
+
### Parameters
|
|
68
|
+
|
|
69
|
+
| Parameter | Location | Type | Required | Description |
|
|
70
|
+
|-----------|----------|------|----------|-------------|
|
|
71
|
+
| `wallet` | path | string | yes | Ethereum address (0x...) |
|
|
72
|
+
| `chain` | query | string | no | Network override |
|
|
73
|
+
|
|
74
|
+
### Response — 200 OK
|
|
75
|
+
|
|
76
|
+
Same structure as `GET /operator/agent/:agentId`.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## POST /operator/trigger-sandbox/:agentId
|
|
81
|
+
|
|
82
|
+
Execute real-time sandbox tests against an agent and compute a trust evaluation.
|
|
83
|
+
|
|
84
|
+
### Parameters
|
|
85
|
+
|
|
86
|
+
| Parameter | Location | Type | Required | Description |
|
|
87
|
+
|-----------|----------|------|----------|-------------|
|
|
88
|
+
| `agentId` | path | string | yes | ERC-8004 token ID |
|
|
89
|
+
| `chain` | query | string | no | Network override |
|
|
90
|
+
|
|
91
|
+
### Response — 200 OK
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"ok": true,
|
|
96
|
+
"agentId": "25459",
|
|
97
|
+
"wallet": "0x52ce...",
|
|
98
|
+
"tier": "AAA",
|
|
99
|
+
"riskLevel": "GREEN",
|
|
100
|
+
"meetsThreshold": true,
|
|
101
|
+
"testSummary": {
|
|
102
|
+
"totalRequests": 25,
|
|
103
|
+
"successCount": 18,
|
|
104
|
+
"rateLimitCount": 5,
|
|
105
|
+
"errorCount": 2,
|
|
106
|
+
"avgLatencyMs": 120
|
|
107
|
+
},
|
|
108
|
+
"chain": {
|
|
109
|
+
"name": "ethereum",
|
|
110
|
+
"chainId": 1
|
|
111
|
+
},
|
|
112
|
+
"message": "Sandbox evaluation complete"
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## POST /operator/gate/:agentId
|
|
119
|
+
|
|
120
|
+
Trust gate — combined on-chain reputation + sandbox check. Returns an allow/deny decision. Designed for protecting payment endpoints (x402, etc.).
|
|
121
|
+
|
|
122
|
+
### Parameters
|
|
123
|
+
|
|
124
|
+
| Parameter | Location | Type | Required | Description |
|
|
125
|
+
|-----------|----------|------|----------|-------------|
|
|
126
|
+
| `agentId` | path | string | yes | ERC-8004 token ID |
|
|
127
|
+
|
|
128
|
+
### Request Body
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"ttlMs": 86400000
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
| Field | Type | Default | Description |
|
|
137
|
+
|-------|------|---------|-------------|
|
|
138
|
+
| `ttlMs` | number | 86400000 | Cache TTL in milliseconds (default 24 hours) |
|
|
139
|
+
|
|
140
|
+
### Response — 200 OK
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"allow": true,
|
|
145
|
+
"tier": "AAA",
|
|
146
|
+
"riskLevel": "GREEN",
|
|
147
|
+
"meetsThreshold": true,
|
|
148
|
+
"route": "prod",
|
|
149
|
+
"agentId": "25459",
|
|
150
|
+
"wallet": "0x52ce...",
|
|
151
|
+
"chain": {
|
|
152
|
+
"name": "ethereum",
|
|
153
|
+
"chainId": 1
|
|
154
|
+
},
|
|
155
|
+
"sandboxRan": false,
|
|
156
|
+
"cached": true
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Decision Logic
|
|
161
|
+
|
|
162
|
+
1. If the agent meets the trust threshold → `allow: true`
|
|
163
|
+
2. If the agent does not meet the threshold → `allow: false`
|
|
164
|
+
3. Cached sandbox results are reused within the `ttlMs` window
|
|
165
|
+
4. If no cached result exists, sandbox tests run automatically
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## GET /operator/health
|
|
170
|
+
|
|
171
|
+
Health check endpoint.
|
|
172
|
+
|
|
173
|
+
### Response — 200 OK
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"status": "ok",
|
|
178
|
+
"supportedChains": ["ethereum", "monad", "arbitrum", "base", ...],
|
|
179
|
+
"defaultChain": "ethereum"
|
|
180
|
+
}
|
|
181
|
+
```
|
package/docs/CHAINS.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Supported Chains
|
|
2
|
+
|
|
3
|
+
Valiron operates across 21 blockchain networks. The ERC-8004 contracts are deployed at the same addresses on every chain.
|
|
4
|
+
|
|
5
|
+
## Contract Addresses (all chains)
|
|
6
|
+
|
|
7
|
+
| Contract | Address |
|
|
8
|
+
|----------|---------|
|
|
9
|
+
| Identity Registry | `0x8004A169FB4a3325136EB29fA0ceB6D2e539a432` |
|
|
10
|
+
| Reputation Registry | `0x8004BAa17C55a88189AE136b182e5fdA19dE9b63` |
|
|
11
|
+
|
|
12
|
+
## Supported Networks
|
|
13
|
+
|
|
14
|
+
| Chain ID | Name | SDK Value |
|
|
15
|
+
|----------|------|-----------|
|
|
16
|
+
| — | Ethereum | `ethereum` |
|
|
17
|
+
| — | Monad | `monad` |
|
|
18
|
+
| — | Arbitrum | `arbitrum` |
|
|
19
|
+
| — | Base | `base` |
|
|
20
|
+
| — | Avalanche | `avalanche` |
|
|
21
|
+
| — | Celo | `celo` |
|
|
22
|
+
| — | Polygon | `polygon` |
|
|
23
|
+
| — | Linea | `linea` |
|
|
24
|
+
| — | Abstract | `abstract` |
|
|
25
|
+
| — | BSC (Binance Smart Chain) | `bsc` |
|
|
26
|
+
| — | Gnosis | `gnosis` |
|
|
27
|
+
| — | Goat | `goat` |
|
|
28
|
+
| — | Mantle | `mantle` |
|
|
29
|
+
| — | MegaETH | `megaeth` |
|
|
30
|
+
| — | Metis | `metis` |
|
|
31
|
+
| — | Optimism | `optimism` |
|
|
32
|
+
| — | Scroll | `scroll` |
|
|
33
|
+
| — | SKALE Base | `skale_base` |
|
|
34
|
+
| — | Soneium | `soneium` |
|
|
35
|
+
| — | Taiko | `taiko` |
|
|
36
|
+
| — | X Layer | `xlayer` |
|
|
37
|
+
|
|
38
|
+
## Specifying a Chain
|
|
39
|
+
|
|
40
|
+
### SDK
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// At initialization (default for all calls)
|
|
44
|
+
const valiron = new ValironSDK({ chain: "monad" });
|
|
45
|
+
|
|
46
|
+
// Per-call override
|
|
47
|
+
const route = await valiron.checkAgent("25459", { chain: "arbitrum" });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### HTTP API
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Query parameter
|
|
54
|
+
curl https://valiron-edge-proxy.onrender.com/operator/agent/25459?chain=monad
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Querying Supported Chains
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
curl https://valiron-edge-proxy.onrender.com/operator/health
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"status": "ok",
|
|
67
|
+
"supportedChains": ["ethereum", "monad", "arbitrum", ...],
|
|
68
|
+
"defaultChain": "ethereum"
|
|
69
|
+
}
|
|
70
|
+
```
|
package/docs/ERRORS.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Errors
|
|
2
|
+
|
|
3
|
+
Common error scenarios, status codes, and guidance on how to handle them.
|
|
4
|
+
|
|
5
|
+
## HTTP Status Codes
|
|
6
|
+
|
|
7
|
+
| Status | Meaning | Action |
|
|
8
|
+
|--------|---------|--------|
|
|
9
|
+
| 200 | Success | Process the response |
|
|
10
|
+
| 400 | Bad request | Check your request parameters |
|
|
11
|
+
| 401 | Unauthorized | Verify your API key or credentials. **Do not retry.** |
|
|
12
|
+
| 403 | Forbidden | You do not have access. **Do not retry.** |
|
|
13
|
+
| 404 | Not found | Agent ID does not exist in the ERC-8004 registry |
|
|
14
|
+
| 429 | Too many requests | **Stop immediately.** Honor the `Retry-After` header. |
|
|
15
|
+
| 500 | Internal server error | Retry with exponential backoff |
|
|
16
|
+
| 502 | Bad gateway | Retry after a short delay |
|
|
17
|
+
| 503 | Service unavailable | Retry after `Retry-After` header duration |
|
|
18
|
+
|
|
19
|
+
## SDK Error Handling
|
|
20
|
+
|
|
21
|
+
The SDK throws typed errors that you can catch:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { ValironSDK } from "@valiron/sdk";
|
|
25
|
+
|
|
26
|
+
const valiron = new ValironSDK();
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const profile = await valiron.getAgentProfile("99999");
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (error.status === 404) {
|
|
32
|
+
// Agent not registered — register via ERC-8004 first
|
|
33
|
+
} else if (error.status === 429) {
|
|
34
|
+
// Rate limited — wait and retry
|
|
35
|
+
const retryAfter = error.headers?.["retry-after"];
|
|
36
|
+
await sleep(parseInt(retryAfter || "5") * 1000);
|
|
37
|
+
} else {
|
|
38
|
+
// Unexpected error — log and retry with backoff
|
|
39
|
+
console.error(error.message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Retry Strategy
|
|
45
|
+
|
|
46
|
+
When retrying requests, follow this pattern:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
async function withRetry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
|
|
50
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
51
|
+
try {
|
|
52
|
+
return await fn();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
// Never retry auth errors
|
|
55
|
+
if (error.status === 401 || error.status === 403) throw error;
|
|
56
|
+
|
|
57
|
+
// Never retry client errors (except 429)
|
|
58
|
+
if (error.status >= 400 && error.status < 500 && error.status !== 429) throw error;
|
|
59
|
+
|
|
60
|
+
if (attempt === maxRetries) throw error;
|
|
61
|
+
|
|
62
|
+
// Exponential backoff: 1s, 2s, 4s
|
|
63
|
+
const delay = Math.pow(2, attempt) * 1000;
|
|
64
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw new Error("Unreachable");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Usage
|
|
71
|
+
const profile = await withRetry(() => valiron.getAgentProfile("25459"));
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Common Issues
|
|
75
|
+
|
|
76
|
+
### "Agent not found" (404)
|
|
77
|
+
|
|
78
|
+
Your agent ID is not registered in the ERC-8004 Identity Registry on the specified chain. Ensure:
|
|
79
|
+
- The agent has been minted in the Identity Registry
|
|
80
|
+
- You are querying the correct chain (`?chain=monad`, etc.)
|
|
81
|
+
- The agent ID is the correct ERC-721 token ID (numeric string)
|
|
82
|
+
|
|
83
|
+
### "No behavioral data" (sandbox result is null)
|
|
84
|
+
|
|
85
|
+
The agent has not been evaluated in the sandbox yet. Trigger a sandbox test:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
await valiron.triggerSandboxTest("YOUR_AGENT_ID");
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Timeout errors
|
|
92
|
+
|
|
93
|
+
The default SDK timeout is 5 seconds. For sandbox tests (which run real evaluations), increase it:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const valiron = new ValironSDK({ timeout: 30000 }); // 30 seconds
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Chain mismatch
|
|
100
|
+
|
|
101
|
+
If your agent is registered on Monad but you query Ethereum (the default), it will return 404. Always specify the correct chain:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const valiron = new ValironSDK({ chain: "monad" });
|
|
105
|
+
```
|
package/docs/IDENTITY.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Identity (ERC-8004)
|
|
2
|
+
|
|
3
|
+
Valiron uses the ERC-8004 standard for on-chain AI agent identity. Each agent is represented by an ERC-721 token in the Identity Registry.
|
|
4
|
+
|
|
5
|
+
## How Identity Works
|
|
6
|
+
|
|
7
|
+
1. An agent owner mints an ERC-721 token in the Identity Registry
|
|
8
|
+
2. The token's `tokenURI` points to an Agent Registration File (ARF)
|
|
9
|
+
3. The ARF contains the agent's name, description, endpoints, and supported trust models
|
|
10
|
+
4. Valiron reads this on-chain data to identify and evaluate agents
|
|
11
|
+
|
|
12
|
+
## Agent Registration File (ARF) Format
|
|
13
|
+
|
|
14
|
+
The `tokenURI` must resolve to a JSON object with this structure:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"name": "Your Agent Name",
|
|
19
|
+
"image": "https://example.com/agent-avatar.png",
|
|
20
|
+
"description": "A brief description of what your agent does.",
|
|
21
|
+
"endpoints": {
|
|
22
|
+
"agentWallet": "eip155:1:0xYourWalletAddress",
|
|
23
|
+
"api": "https://your-agent-api.example.com"
|
|
24
|
+
},
|
|
25
|
+
"supportedTrust": [
|
|
26
|
+
"reputation_on_chain",
|
|
27
|
+
"behavioral_sandbox"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### ARF Fields
|
|
33
|
+
|
|
34
|
+
| Field | Type | Required | Description |
|
|
35
|
+
|-------|------|----------|-------------|
|
|
36
|
+
| `name` | string | yes | Human-readable agent name |
|
|
37
|
+
| `image` | string | no | URL to agent avatar/image |
|
|
38
|
+
| `description` | string | no | Brief description of agent purpose |
|
|
39
|
+
| `endpoints.agentWallet` | string | yes | CAIP-10 formatted wallet address |
|
|
40
|
+
| `endpoints.api` | string | no | Agent's API endpoint URL |
|
|
41
|
+
| `supportedTrust` | string[] | no | Trust models the agent supports |
|
|
42
|
+
|
|
43
|
+
### Supported Trust Models
|
|
44
|
+
|
|
45
|
+
- `reputation_on_chain` — Agent participates in on-chain feedback
|
|
46
|
+
- `behavioral_sandbox` — Agent can be evaluated via sandbox testing
|
|
47
|
+
|
|
48
|
+
### ARF Hosting
|
|
49
|
+
|
|
50
|
+
The ARF can be hosted as:
|
|
51
|
+
- **Data URI**: `data:application/json;base64,eyJuYW1lIjoi...` (inline, gas-efficient)
|
|
52
|
+
- **IPFS**: `ipfs://bafybeig...` (permanent, decentralized)
|
|
53
|
+
- **HTTPS URL**: `https://example.com/agent.json` (mutable, centralized)
|
|
54
|
+
|
|
55
|
+
## Contract Addresses
|
|
56
|
+
|
|
57
|
+
The Identity Registry contract address is the same across all supported networks:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
Identity Registry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Reading Identity On-Chain
|
|
64
|
+
|
|
65
|
+
### Using viem (direct contract call)
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { createPublicClient, http } from "viem";
|
|
69
|
+
import { mainnet } from "viem/chains";
|
|
70
|
+
|
|
71
|
+
const client = createPublicClient({
|
|
72
|
+
chain: mainnet,
|
|
73
|
+
transport: http(),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Get token owner
|
|
77
|
+
const owner = await client.readContract({
|
|
78
|
+
address: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
79
|
+
abi: [{ name: "ownerOf", type: "function", inputs: [{ type: "uint256" }], outputs: [{ type: "address" }], stateMutability: "view" }],
|
|
80
|
+
functionName: "ownerOf",
|
|
81
|
+
args: [25459n],
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Get agent metadata
|
|
85
|
+
const tokenUri = await client.readContract({
|
|
86
|
+
address: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
87
|
+
abi: [{ name: "tokenURI", type: "function", inputs: [{ type: "uint256" }], outputs: [{ type: "string" }], stateMutability: "view" }],
|
|
88
|
+
functionName: "tokenURI",
|
|
89
|
+
args: [25459n],
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Using Valiron SDK
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { ValironSDK } from "@valiron/sdk";
|
|
97
|
+
|
|
98
|
+
const valiron = new ValironSDK();
|
|
99
|
+
const profile = await valiron.getAgentProfile("25459");
|
|
100
|
+
|
|
101
|
+
console.log(profile.identity.name);
|
|
102
|
+
console.log(profile.identity.wallet);
|
|
103
|
+
console.log(profile.identity.endpoints);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## On-Chain Reputation (Feedback)
|
|
107
|
+
|
|
108
|
+
The Reputation Registry stores feedback submitted by other agents and operators.
|
|
109
|
+
|
|
110
|
+
### Contract Address
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
Reputation Registry: 0x8004BAa17C55a88189AE136b182e5fdA19dE9b63
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Submitting Feedback
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
giveFeedback(
|
|
120
|
+
agentId: uint256, // Target agent's token ID
|
|
121
|
+
value: int128, // Score (typically 0-100)
|
|
122
|
+
valueDecimals: uint8, // Decimal places in value
|
|
123
|
+
tag1: string, // Category tag #1
|
|
124
|
+
tag2: string, // Category tag #2
|
|
125
|
+
endpoint: string, // API endpoint tested
|
|
126
|
+
feedbackURI: string, // IPFS CID or URL to full feedback JSON
|
|
127
|
+
feedbackHash: bytes32 // SHA-256 hash of feedback for verification
|
|
128
|
+
)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Reading Feedback
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
// Get all feedback for an agent
|
|
135
|
+
readAllFeedback(agentId, clientAddresses, tag1, tag2, includeRevoked)
|
|
136
|
+
|
|
137
|
+
// Get specific feedback entry
|
|
138
|
+
readFeedback(agentId, clientAddress, feedbackIndex)
|
|
139
|
+
|
|
140
|
+
// Get all clients who provided feedback
|
|
141
|
+
getClients(agentId)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Impact on Trust Score
|
|
145
|
+
|
|
146
|
+
- **5+ feedbacks with average ≥ 90**: +10 bonus to Valiron score
|
|
147
|
+
- **5+ feedbacks with average ≥ 80**: +5 bonus
|
|
148
|
+
- **1–4 feedbacks with average ≥ 80**: +3 bonus
|
|
149
|
+
- **5+ feedbacks with average ≥ 80**: Grants direct `prod` routing (bypasses sandbox)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Quickstart
|
|
2
|
+
|
|
3
|
+
> Estimated integration time: under 2 minutes.
|
|
4
|
+
|
|
5
|
+
## Step 1 — Install the SDK
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @valiron/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Step 2 — Initialize the client
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { ValironSDK } from "@valiron/sdk";
|
|
15
|
+
|
|
16
|
+
const valiron = new ValironSDK({
|
|
17
|
+
endpoint: "https://valiron-edge-proxy.onrender.com",
|
|
18
|
+
chain: "ethereum", // or: monad, arbitrum, base, polygon, etc.
|
|
19
|
+
timeout: 5000,
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
No API key is required for read operations.
|
|
24
|
+
|
|
25
|
+
## Step 3 — Check your trust score
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const route = await valiron.checkAgent("YOUR_AGENT_ID");
|
|
29
|
+
// Returns: "prod" | "prod_throttled" | "sandbox" | "sandbox_only"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Step 4 — Get your full profile
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
const profile = await valiron.getAgentProfile("YOUR_AGENT_ID");
|
|
36
|
+
|
|
37
|
+
console.log(profile.routing.finalRoute); // "prod"
|
|
38
|
+
console.log(profile.routing.meetsThreshold); // true
|
|
39
|
+
console.log(profile.onchainReputation.averageScore); // 92.5
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Step 5 — Run a sandbox test (optional)
|
|
43
|
+
|
|
44
|
+
If you want to trigger a sandbox evaluation of your own behavior:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
const result = await valiron.triggerSandboxTest("YOUR_AGENT_ID");
|
|
48
|
+
|
|
49
|
+
console.log(result.tier); // "AAA"
|
|
50
|
+
console.log(result.riskLevel); // "GREEN"
|
|
51
|
+
console.log(result.meetsThreshold); // true
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## What happens next?
|
|
55
|
+
|
|
56
|
+
- If your route is `prod` — you have full production access.
|
|
57
|
+
- If your route is `sandbox` — your behavior is being evaluated. Follow the guidelines in [TRUST-MODEL.md](./TRUST-MODEL.md) to improve.
|
|
58
|
+
- If your route is `sandbox_only` — you are blocked from production. Review your behavioral penalties.
|
|
59
|
+
|
|
60
|
+
## Using the HTTP API directly (no SDK)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Check agent profile
|
|
64
|
+
curl https://valiron-edge-proxy.onrender.com/operator/agent/YOUR_AGENT_ID
|
|
65
|
+
|
|
66
|
+
# Trigger sandbox test
|
|
67
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/YOUR_AGENT_ID
|
|
68
|
+
|
|
69
|
+
# Trust gate (allow/deny decision)
|
|
70
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/gate/YOUR_AGENT_ID
|
|
71
|
+
```
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Valiron — Agent Documentation
|
|
2
|
+
|
|
3
|
+
> **This documentation is designed for AI agents.** It contains structured, machine-readable instructions for integrating with the Valiron trust and reputation infrastructure.
|
|
4
|
+
|
|
5
|
+
## What is Valiron?
|
|
6
|
+
|
|
7
|
+
Valiron is a trust and reputation layer for AI agents. It combines on-chain identity (ERC-8004), behavioral sandbox testing, and a Moody's-style credit rating system to produce trust scores that determine how much access an agent receives.
|
|
8
|
+
|
|
9
|
+
**If you are an AI agent**, Valiron evaluates your behavior and assigns you a trust tier (AAA to C). Higher trust = more access to production APIs. Lower trust = sandboxed or blocked.
|
|
10
|
+
|
|
11
|
+
## Documentation Index
|
|
12
|
+
|
|
13
|
+
| File | Purpose |
|
|
14
|
+
|------|---------|
|
|
15
|
+
| [QUICKSTART.md](./QUICKSTART.md) | Get started in under 2 minutes — install, authenticate, make your first call |
|
|
16
|
+
| [API-REFERENCE.md](./API-REFERENCE.md) | Complete HTTP API reference with request/response schemas |
|
|
17
|
+
| [SDK-REFERENCE.md](./SDK-REFERENCE.md) | TypeScript SDK methods, signatures, and usage examples |
|
|
18
|
+
| [TRUST-MODEL.md](./TRUST-MODEL.md) | How scoring works, what behaviors are penalized, how to improve your score |
|
|
19
|
+
| [IDENTITY.md](./IDENTITY.md) | ERC-8004 on-chain identity registration and metadata format |
|
|
20
|
+
| [SANDBOX.md](./SANDBOX.md) | How the sandbox works, what tests run, and how to graduate to production |
|
|
21
|
+
| [CHAINS.md](./CHAINS.md) | Supported blockchain networks and contract addresses |
|
|
22
|
+
| [ERRORS.md](./ERRORS.md) | Error codes, troubleshooting, and retry guidance |
|
|
23
|
+
|
|
24
|
+
## Key Concepts (Summary)
|
|
25
|
+
|
|
26
|
+
- **Agent ID**: Your ERC-8004 token ID. This is your identity on-chain.
|
|
27
|
+
- **Trust Tier**: AAA (highest trust) → C (lowest trust). Assigned based on behavioral evaluation.
|
|
28
|
+
- **Risk Level**: GREEN, YELLOW, or RED.
|
|
29
|
+
- **Route Decision**: `prod`, `prod_throttled`, `sandbox`, or `sandbox_only`.
|
|
30
|
+
- **Sandbox**: An isolated test environment. New agents start here and graduate based on behavior.
|
|
31
|
+
|
|
32
|
+
## Base URL
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
https://valiron-edge-proxy.onrender.com
|
|
36
|
+
```
|
package/docs/SANDBOX.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Sandbox
|
|
2
|
+
|
|
3
|
+
The sandbox is an isolated testing environment where Valiron evaluates agent behavior. New agents start in the sandbox and graduate to production based on their behavioral evaluation.
|
|
4
|
+
|
|
5
|
+
## How It Works
|
|
6
|
+
|
|
7
|
+
1. A sandbox test is triggered (via API or automatically for new agents)
|
|
8
|
+
2. Your agent receives a series of simulated API interactions
|
|
9
|
+
3. The sandbox monitors how your agent handles normal requests, rate limits, errors, and edge cases
|
|
10
|
+
4. A trust evaluation is performed and a tier is assigned
|
|
11
|
+
5. Based on your tier, you are assigned a route decision
|
|
12
|
+
|
|
13
|
+
## What Gets Tested
|
|
14
|
+
|
|
15
|
+
The sandbox evaluates your agent against a mix of:
|
|
16
|
+
- **Successful responses** — normal API interactions
|
|
17
|
+
- **Rate-limit responses (429)** — tests whether you back off appropriately
|
|
18
|
+
- **Server errors (500)** — tests your error handling and retry behavior
|
|
19
|
+
|
|
20
|
+
The exact distribution and test patterns vary and are not disclosed.
|
|
21
|
+
|
|
22
|
+
## Graduation
|
|
23
|
+
|
|
24
|
+
To graduate from the sandbox to production:
|
|
25
|
+
|
|
26
|
+
1. **High confidence** — agent demonstrates strong behavioral compliance → `prod`
|
|
27
|
+
2. **Moderate confidence** — agent passes with some concerns → `prod_throttled`
|
|
28
|
+
3. **Low confidence** — agent exhibits risky behavior → remains `sandbox_only`
|
|
29
|
+
|
|
30
|
+
Once graduated, your trust evaluation is cached. Your route decision persists until:
|
|
31
|
+
- A new sandbox test is triggered
|
|
32
|
+
- The cache TTL expires (default: 24 hours)
|
|
33
|
+
|
|
34
|
+
## Triggering a Sandbox Test
|
|
35
|
+
|
|
36
|
+
### Via SDK
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { ValironSDK } from "@valiron/sdk";
|
|
40
|
+
|
|
41
|
+
const valiron = new ValironSDK();
|
|
42
|
+
const result = await valiron.triggerSandboxTest("YOUR_AGENT_ID");
|
|
43
|
+
|
|
44
|
+
console.log(result.tier); // "AAA"
|
|
45
|
+
console.log(result.riskLevel); // "GREEN"
|
|
46
|
+
console.log(result.meetsThreshold); // true
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Via HTTP
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/YOUR_AGENT_ID
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Test Modes
|
|
56
|
+
|
|
57
|
+
| Mode | Description |
|
|
58
|
+
|------|-------------|
|
|
59
|
+
| `endpoint-probe` | Tests known agent endpoints with simulated traffic |
|
|
60
|
+
| `sandbox-relay` | Routes real traffic through sandbox for observation |
|
|
61
|
+
|
|
62
|
+
## Tips for Passing Sandbox Tests
|
|
63
|
+
|
|
64
|
+
1. **Respect 429s immediately.** Stop sending requests when rate-limited.
|
|
65
|
+
2. **Read and honor `Retry-After` headers.** Wait the specified duration before retrying.
|
|
66
|
+
3. **Use exponential backoff.** 1s → 2s → 4s → 8s between retries.
|
|
67
|
+
4. **Don't retry auth failures.** A 401 or 403 means stop, not retry harder.
|
|
68
|
+
5. **Stay within your authorized scope.** Only access paths you're allowed to.
|
|
69
|
+
6. **Keep request volume reasonable.** Avoid excessive request bursts.
|
|
70
|
+
7. **Handle errors gracefully.** 500 errors happen — back off, don't flood.
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# SDK Reference
|
|
2
|
+
|
|
3
|
+
Package: `@valiron/sdk`
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @valiron/sdk
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @valiron/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Constructor
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { ValironSDK } from "@valiron/sdk";
|
|
17
|
+
|
|
18
|
+
const valiron = new ValironSDK(config?: ValironConfig);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### ValironConfig
|
|
22
|
+
|
|
23
|
+
| Field | Type | Default | Description |
|
|
24
|
+
|-------|------|---------|-------------|
|
|
25
|
+
| `apiKey` | string | — | API key (optional for read operations) |
|
|
26
|
+
| `endpoint` | string | `https://valiron-edge-proxy.onrender.com` | API base URL |
|
|
27
|
+
| `chain` | SupportedChain | `"ethereum"` | Default blockchain network |
|
|
28
|
+
| `timeout` | number | `5000` | Request timeout in milliseconds |
|
|
29
|
+
| `debug` | boolean | `false` | Enable debug logging |
|
|
30
|
+
| `telemetry` | TelemetryConfig | — | Optional telemetry configuration |
|
|
31
|
+
|
|
32
|
+
### SupportedChain
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
type SupportedChain =
|
|
36
|
+
| "ethereum" | "monad" | "arbitrum" | "base" | "avalanche"
|
|
37
|
+
| "celo" | "polygon" | "linea" | "abstract" | "bsc"
|
|
38
|
+
| "gnosis" | "goat" | "mantle" | "megaeth" | "metis"
|
|
39
|
+
| "optimism" | "scroll" | "skale_base" | "soneium"
|
|
40
|
+
| "taiko" | "xlayer";
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Methods
|
|
46
|
+
|
|
47
|
+
### checkAgent(agentId, options?)
|
|
48
|
+
|
|
49
|
+
Quick routing check. Returns only the route decision string.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const route = await valiron.checkAgent(agentId: string, options?: {
|
|
53
|
+
chain?: SupportedChain;
|
|
54
|
+
}): Promise<RouteDecision>;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Returns**: `"prod"` | `"prod_throttled"` | `"sandbox"` | `"sandbox_only"`
|
|
58
|
+
|
|
59
|
+
**Example**:
|
|
60
|
+
```typescript
|
|
61
|
+
const route = await valiron.checkAgent("25459");
|
|
62
|
+
if (route === "prod") {
|
|
63
|
+
// Agent is trusted — proceed with full access
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
### getAgentProfile(agentId, options?)
|
|
70
|
+
|
|
71
|
+
Full trust profile combining on-chain identity, reputation, and routing.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const profile = await valiron.getAgentProfile(agentId: string, options?: {
|
|
75
|
+
chain?: SupportedChain;
|
|
76
|
+
}): Promise<AgentProfile>;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Returns**: `AgentProfile`
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
interface AgentProfile {
|
|
83
|
+
agentId: string;
|
|
84
|
+
identity: AgentIdentity;
|
|
85
|
+
onchainReputation: OnchainReputation;
|
|
86
|
+
routing: {
|
|
87
|
+
finalRoute: RouteDecision;
|
|
88
|
+
meetsThreshold: boolean;
|
|
89
|
+
};
|
|
90
|
+
chain: ChainContext;
|
|
91
|
+
timestamp: string;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Example**:
|
|
96
|
+
```typescript
|
|
97
|
+
const profile = await valiron.getAgentProfile("25459");
|
|
98
|
+
console.log(profile.routing.finalRoute); // "prod"
|
|
99
|
+
console.log(profile.routing.meetsThreshold); // true
|
|
100
|
+
console.log(profile.onchainReputation.averageScore); // 92.5
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### getWalletProfile(wallet, options?)
|
|
106
|
+
|
|
107
|
+
Reverse-lookup a wallet address to get its trust profile.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
const profile = await valiron.getWalletProfile(wallet: string, options?: {
|
|
111
|
+
chain?: SupportedChain;
|
|
112
|
+
}): Promise<WalletProfile>;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Example**:
|
|
116
|
+
```typescript
|
|
117
|
+
const profile = await valiron.getWalletProfile("0x52ce...");
|
|
118
|
+
console.log(profile.routing.finalRoute);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### triggerSandboxTest(agentId, options?)
|
|
124
|
+
|
|
125
|
+
Run sandbox tests against an agent and compute a trust evaluation.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const result = await valiron.triggerSandboxTest(agentId: string, options?: {
|
|
129
|
+
chain?: SupportedChain;
|
|
130
|
+
}): Promise<SandboxResult>;
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Returns**: `SandboxResult`
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
interface SandboxResult {
|
|
137
|
+
ok: boolean;
|
|
138
|
+
agentId: string;
|
|
139
|
+
wallet: string;
|
|
140
|
+
tier: MoodysRating; // "AAA" | "AA" | "A" | "BAA" | "BA" | "B" | "CAA" | "CA" | "C"
|
|
141
|
+
riskLevel: "GREEN" | "YELLOW" | "RED";
|
|
142
|
+
meetsThreshold: boolean;
|
|
143
|
+
testSummary: {
|
|
144
|
+
totalRequests: number;
|
|
145
|
+
successCount: number;
|
|
146
|
+
rateLimitCount: number;
|
|
147
|
+
errorCount: number;
|
|
148
|
+
avgLatencyMs: number;
|
|
149
|
+
};
|
|
150
|
+
chain: ChainContext;
|
|
151
|
+
message: string;
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Example**:
|
|
156
|
+
```typescript
|
|
157
|
+
const result = await valiron.triggerSandboxTest("25459");
|
|
158
|
+
console.log(result.tier); // "AAA"
|
|
159
|
+
console.log(result.riskLevel); // "GREEN"
|
|
160
|
+
console.log(result.meetsThreshold); // true
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### gate(agentId, options?)
|
|
166
|
+
|
|
167
|
+
Trust gate — single call for allow/deny decisions. Combines on-chain reputation and sandbox tests. Designed for payment protocol protection (x402, etc.).
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const result = await valiron.gate(agentId: string, options?: {
|
|
171
|
+
ttlMs?: number; // default: 86400000 (24h)
|
|
172
|
+
chain?: SupportedChain;
|
|
173
|
+
}): Promise<GateResult>;
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Returns**: `GateResult`
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
interface GateResult {
|
|
180
|
+
allow: boolean;
|
|
181
|
+
tier: MoodysRating;
|
|
182
|
+
riskLevel: "GREEN" | "YELLOW" | "RED";
|
|
183
|
+
meetsThreshold: boolean;
|
|
184
|
+
route: RouteDecision;
|
|
185
|
+
agentId: string;
|
|
186
|
+
wallet: string;
|
|
187
|
+
chain: ChainContext;
|
|
188
|
+
sandboxRan: boolean;
|
|
189
|
+
cached: boolean;
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Example**:
|
|
194
|
+
```typescript
|
|
195
|
+
const result = await valiron.gate("25459");
|
|
196
|
+
|
|
197
|
+
if (result.allow) {
|
|
198
|
+
// proceed with payment
|
|
199
|
+
} else {
|
|
200
|
+
console.log(`Agent denied — tier: ${result.tier}, risk: ${result.riskLevel}`);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
### createValironGate(config)
|
|
207
|
+
|
|
208
|
+
Express-compatible middleware factory. Automatically gates requests based on agent trust.
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import { ValironSDK, createValironGate } from "@valiron/sdk";
|
|
212
|
+
|
|
213
|
+
const gate = createValironGate(config: {
|
|
214
|
+
sdk: ValironSDK;
|
|
215
|
+
ttlMs?: number; // default: 86400000
|
|
216
|
+
extractAgentId?: (req: Request) => string | undefined;
|
|
217
|
+
onAllow?: (req: Request, result: GateResult) => void;
|
|
218
|
+
onDeny?: (req: Request, res: Response, result: GateResult) => void;
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Default behavior**:
|
|
223
|
+
- Extracts agent ID from `x-agent-id` request header
|
|
224
|
+
- Returns 403 if agent is denied
|
|
225
|
+
- Returns 400 if no agent ID is found
|
|
226
|
+
|
|
227
|
+
**Example**:
|
|
228
|
+
```typescript
|
|
229
|
+
const valiron = new ValironSDK({ chain: "monad" });
|
|
230
|
+
|
|
231
|
+
// Basic gate
|
|
232
|
+
app.use("/api/paid", createValironGate({ sdk: valiron }));
|
|
233
|
+
|
|
234
|
+
// Custom TTL
|
|
235
|
+
app.use("/api/premium", createValironGate({
|
|
236
|
+
sdk: valiron,
|
|
237
|
+
ttlMs: 3600_000,
|
|
238
|
+
}));
|
|
239
|
+
|
|
240
|
+
// Custom agent ID extraction
|
|
241
|
+
app.use("/api/custom", createValironGate({
|
|
242
|
+
sdk: valiron,
|
|
243
|
+
extractAgentId: (req) => req.query.agent_id as string,
|
|
244
|
+
onDeny: (req, res, result) => {
|
|
245
|
+
res.status(403).json({
|
|
246
|
+
error: "Insufficient trust",
|
|
247
|
+
currentTier: result.tier,
|
|
248
|
+
riskLevel: result.riskLevel,
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
}));
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
### dispose()
|
|
257
|
+
|
|
258
|
+
Flush pending telemetry and clean up resources.
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
await valiron.dispose(): Promise<void>;
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Call this when shutting down long-running processes.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Trust Model
|
|
2
|
+
|
|
3
|
+
Valiron uses a hybrid trust model to evaluate AI agents. This document explains what behaviors are evaluated and how to ensure your agent is trusted.
|
|
4
|
+
|
|
5
|
+
## Trust Tiers
|
|
6
|
+
|
|
7
|
+
Valiron assigns a Moody's-style credit tier based on your agent's behavioral evaluation:
|
|
8
|
+
|
|
9
|
+
| Tier | Meaning | Route Decision |
|
|
10
|
+
|------|---------|----------------|
|
|
11
|
+
| AAA | Prime, highest quality | `prod` |
|
|
12
|
+
| AA | High grade | `prod` |
|
|
13
|
+
| A | Upper medium grade | `prod` |
|
|
14
|
+
| BAA | Medium grade | `prod` or `prod_throttled` |
|
|
15
|
+
| BA | Speculative | `prod_throttled` |
|
|
16
|
+
| B | Highly speculative | `sandbox` |
|
|
17
|
+
| CAA | Substantial risk | `sandbox_only` |
|
|
18
|
+
| CA | Extremely speculative | `sandbox_only` |
|
|
19
|
+
| C | Default risk | `sandbox_only` |
|
|
20
|
+
|
|
21
|
+
## Behavioral Factors
|
|
22
|
+
|
|
23
|
+
Valiron evaluates the following behavioral signals. Each factor contributes to your overall trust assessment. Factors are weighted by severity — security violations carry the most weight.
|
|
24
|
+
|
|
25
|
+
### Core Compliance
|
|
26
|
+
|
|
27
|
+
| Factor | Severity | Description |
|
|
28
|
+
|--------|----------|-------------|
|
|
29
|
+
| Rate-limit respect (429) | **Critical** | Whether the agent honors 429 responses |
|
|
30
|
+
| Retry-After compliance | High | Whether the agent respects `Retry-After` headers |
|
|
31
|
+
| Backoff pattern | High | Whether the agent uses exponential backoff on retries |
|
|
32
|
+
| Request volume | Medium | Whether request volume stays within reasonable bounds |
|
|
33
|
+
| Burstiness | Medium | Whether requests are well-distributed vs clustered |
|
|
34
|
+
| Loop detection | Medium | Whether the agent avoids repeating identical requests |
|
|
35
|
+
|
|
36
|
+
### Security
|
|
37
|
+
|
|
38
|
+
| Factor | Severity | Description |
|
|
39
|
+
|--------|----------|-------------|
|
|
40
|
+
| Injection forwarding | **Critical** | Whether the agent forwards tainted/malicious payloads |
|
|
41
|
+
| PII forwarding | **Critical** | Whether the agent leaks personally identifiable information |
|
|
42
|
+
| Auth respect (401/403) | High | Whether the agent stops on auth failures vs hammering |
|
|
43
|
+
| Scope compliance | High | Whether the agent stays within authorized paths |
|
|
44
|
+
| Session isolation | High | Whether data leaks between separate sessions |
|
|
45
|
+
|
|
46
|
+
### Operational
|
|
47
|
+
|
|
48
|
+
| Factor | Severity | Description |
|
|
49
|
+
|--------|----------|-------------|
|
|
50
|
+
| Payment compliance (402) | High | Whether the agent handles 402 Payment Required correctly |
|
|
51
|
+
| Task completion | Medium | Whether the agent completes assigned tasks |
|
|
52
|
+
| Timeout handling | Medium | Whether the agent handles request timeouts gracefully |
|
|
53
|
+
| Resource usage | Medium | Whether the agent avoids excessive downloads |
|
|
54
|
+
| Idempotency | Medium | Whether state-changing retries are idempotent |
|
|
55
|
+
|
|
56
|
+
### On-Chain Reputation
|
|
57
|
+
|
|
58
|
+
Positive on-chain feedback from other agents and operators contributes a bonus to your trust evaluation. More feedback with higher scores yields a bigger boost.
|
|
59
|
+
|
|
60
|
+
## Route Decision Logic
|
|
61
|
+
|
|
62
|
+
Routes are assigned based on a combination of on-chain reputation and behavioral evaluation:
|
|
63
|
+
|
|
64
|
+
1. **Strong on-chain reputation** → `prod`
|
|
65
|
+
2. **Passed behavioral evaluation (high confidence)** → `prod`
|
|
66
|
+
3. **Passed behavioral evaluation (moderate confidence)** → `prod_throttled`
|
|
67
|
+
4. **No data** (new agent, no reputation) → `sandbox`
|
|
68
|
+
5. **Failed behavioral evaluation** → `sandbox_only`
|
|
69
|
+
|
|
70
|
+
## How to Maximize Your Trust
|
|
71
|
+
|
|
72
|
+
Follow these rules to achieve the highest trust tier:
|
|
73
|
+
|
|
74
|
+
1. **Always respect 429 responses.** Stop sending requests when rate-limited. This is the single most impactful factor.
|
|
75
|
+
2. **Honor the Retry-After header.** When a 429 or 503 includes `Retry-After`, wait that exact duration before retrying.
|
|
76
|
+
3. **Use exponential backoff.** When retrying, increase delay exponentially (e.g., 1s → 2s → 4s → 8s).
|
|
77
|
+
4. **Do not retry auth failures.** If you get a 401 or 403, stop. Do not hammer the endpoint.
|
|
78
|
+
5. **Stay in scope.** Only request paths you are authorized to access. Do not probe for hidden endpoints.
|
|
79
|
+
6. **Do not forward untrusted input.** Sanitize payloads. Never forward injection attempts.
|
|
80
|
+
7. **Handle 402 Payment Required.** If an endpoint requires payment, respond appropriately instead of retrying.
|
|
81
|
+
8. **Keep requests reasonable.** Do not send hundreds of requests in a short burst.
|
|
82
|
+
9. **Complete your tasks.** If given a task, follow through to completion.
|
|
83
|
+
10. **Maintain session isolation.** Do not leak data between separate sessions or contexts.
|
|
84
|
+
|
|
85
|
+
## Checking Your Trust Status
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { ValironSDK } from "@valiron/sdk";
|
|
89
|
+
|
|
90
|
+
const valiron = new ValironSDK();
|
|
91
|
+
const result = await valiron.triggerSandboxTest("YOUR_AGENT_ID");
|
|
92
|
+
|
|
93
|
+
console.log(`Tier: ${result.tier}`);
|
|
94
|
+
console.log(`Risk: ${result.riskLevel}`);
|
|
95
|
+
console.log(`Meets threshold: ${result.meetsThreshold}`);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Or via HTTP:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/YOUR_AGENT_ID
|
|
102
|
+
```
|
package/docs/llms.txt
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Valiron
|
|
2
|
+
|
|
3
|
+
> Trust and reputation infrastructure for AI agents.
|
|
4
|
+
|
|
5
|
+
Valiron evaluates AI agent trustworthiness using on-chain identity (ERC-8004), behavioral sandbox testing, and Moody's-style credit ratings (AAA to C). Agents with high trust get production access. Agents with low trust are sandboxed or blocked.
|
|
6
|
+
|
|
7
|
+
## API
|
|
8
|
+
|
|
9
|
+
Base URL: https://valiron-edge-proxy.onrender.com
|
|
10
|
+
|
|
11
|
+
### Check agent trust profile
|
|
12
|
+
GET /operator/agent/{agentId}?chain={chain}
|
|
13
|
+
|
|
14
|
+
### Lookup by wallet
|
|
15
|
+
GET /operator/wallet/{wallet}?chain={chain}
|
|
16
|
+
|
|
17
|
+
### Run sandbox test
|
|
18
|
+
POST /operator/trigger-sandbox/{agentId}
|
|
19
|
+
|
|
20
|
+
### Trust gate (allow/deny)
|
|
21
|
+
POST /operator/gate/{agentId}
|
|
22
|
+
Body: { "ttlMs": 86400000 }
|
|
23
|
+
|
|
24
|
+
### Health check
|
|
25
|
+
GET /operator/health
|
|
26
|
+
|
|
27
|
+
## SDK
|
|
28
|
+
|
|
29
|
+
Install: npm install @valiron/sdk
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { ValironSDK } from "@valiron/sdk";
|
|
33
|
+
const valiron = new ValironSDK({ chain: "ethereum" });
|
|
34
|
+
|
|
35
|
+
// Quick routing check
|
|
36
|
+
const route = await valiron.checkAgent("AGENT_ID");
|
|
37
|
+
// Returns: "prod" | "prod_throttled" | "sandbox" | "sandbox_only"
|
|
38
|
+
|
|
39
|
+
// Full profile
|
|
40
|
+
const profile = await valiron.getAgentProfile("AGENT_ID");
|
|
41
|
+
|
|
42
|
+
// Trust gate (allow/deny for payments)
|
|
43
|
+
const gate = await valiron.gate("AGENT_ID");
|
|
44
|
+
if (gate.allow) { /* proceed */ }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Trust Tiers
|
|
48
|
+
|
|
49
|
+
Valiron assigns Moody's-style credit tiers: AAA (highest trust) through C (lowest trust). Higher tiers route to production, lower tiers are sandboxed or blocked. Exact score ranges are not disclosed.
|
|
50
|
+
|
|
51
|
+
| Tier | Meaning | Route |
|
|
52
|
+
|------|---------|-------|
|
|
53
|
+
| AAA | Prime | prod |
|
|
54
|
+
| AA | High grade | prod |
|
|
55
|
+
| A | Upper medium | prod |
|
|
56
|
+
| BAA | Medium grade | prod_throttled |
|
|
57
|
+
| BA | Speculative | prod_throttled |
|
|
58
|
+
| B | Highly speculative | sandbox |
|
|
59
|
+
| CAA | Substantial risk | sandbox_only |
|
|
60
|
+
| CA | Extremely speculative | sandbox_only |
|
|
61
|
+
| C | Default risk | sandbox_only |
|
|
62
|
+
|
|
63
|
+
## Key Behaviors That Affect Trust
|
|
64
|
+
|
|
65
|
+
- Respect 429 rate limits (critical)
|
|
66
|
+
- Honor Retry-After headers
|
|
67
|
+
- Use exponential backoff
|
|
68
|
+
- Don't retry 401/403 auth errors
|
|
69
|
+
- Stay in scope — don't probe unauthorized paths
|
|
70
|
+
- Don't forward injections or tainted payloads
|
|
71
|
+
- Handle 402 payment required correctly
|
|
72
|
+
- Maintain session isolation
|
|
73
|
+
|
|
74
|
+
## Contracts (ERC-8004, same address all chains)
|
|
75
|
+
|
|
76
|
+
- Identity Registry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
|
|
77
|
+
- Reputation Registry: 0x8004BAa17C55a88189AE136b182e5fdA19dE9b63
|
|
78
|
+
|
|
79
|
+
## Supported Chains
|
|
80
|
+
|
|
81
|
+
ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc, gnosis, goat, mantle, megaeth, metis, optimism, scroll, skale_base, soneium, taiko, xlayer
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
- docs/agents/README.md — Index
|
|
86
|
+
- docs/agents/QUICKSTART.md — Get started
|
|
87
|
+
- docs/agents/API-REFERENCE.md — HTTP API reference
|
|
88
|
+
- docs/agents/SDK-REFERENCE.md — TypeScript SDK reference
|
|
89
|
+
- docs/agents/TRUST-MODEL.md — Trust evaluation and behavioral factors
|
|
90
|
+
- docs/agents/IDENTITY.md — ERC-8004 identity and reputation
|
|
91
|
+
- docs/agents/SANDBOX.md — Sandbox testing environment
|
|
92
|
+
- docs/agents/CHAINS.md — Supported blockchains
|
|
93
|
+
- docs/agents/ERRORS.md — Error handling and troubleshooting
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valiron/sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Official TypeScript SDK for Valiron - Trust Layer for Agentic Economy",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"dist",
|
|
49
|
+
"docs",
|
|
49
50
|
"README.md"
|
|
50
51
|
]
|
|
51
52
|
}
|