@valiron/sdk 0.1.0
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/README.md +499 -0
- package/dist/clients.d.ts +90 -0
- package/dist/clients.d.ts.map +1 -0
- package/dist/clients.js +186 -0
- package/dist/clients.js.map +1 -0
- package/dist/index.d.ts +132 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +126 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +18 -0
- package/dist/types.js.map +1 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
# @valiron/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for **Valiron** - Trust Infrastructure for AI Agent Systems
|
|
4
|
+
|
|
5
|
+
Valiron verifies AI agent trustworthiness using on-chain reputation (ERC-8004) and behavioral analysis. This SDK provides routing decisions based on agent trust scores, enabling you to protect infrastructure while maintaining service availability for verified agents.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @valiron/sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add @valiron/sdk
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @valiron/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Getting Started
|
|
18
|
+
|
|
19
|
+
1. **Initialize the SDK:**
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { ValironSDK } from '@valiron/sdk';
|
|
23
|
+
|
|
24
|
+
// Simple initialization (uses default production endpoint)
|
|
25
|
+
const valiron = new ValironSDK();
|
|
26
|
+
|
|
27
|
+
// Or with custom configuration
|
|
28
|
+
const valiron = new ValironSDK({
|
|
29
|
+
endpoint: 'https://valiron-edge-proxy.onrender.com', // default
|
|
30
|
+
timeout: 5000, // optional
|
|
31
|
+
debug: false // optional
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> **Note:** API key authentication is not yet enforced. The `apiKey` field is
|
|
36
|
+
> reserved for future use when authentication is implemented.
|
|
37
|
+
|
|
38
|
+
2. **Check agent trust before processing requests:**
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const decision = await valiron.checkAgent('417');
|
|
42
|
+
|
|
43
|
+
if (decision.route === 'prod') {
|
|
44
|
+
return handleRequest();
|
|
45
|
+
} else {
|
|
46
|
+
return denyRequest();
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Core Concepts
|
|
51
|
+
|
|
52
|
+
### Route Decisions
|
|
53
|
+
|
|
54
|
+
The SDK returns one of four routing decisions:
|
|
55
|
+
|
|
56
|
+
- **`prod`** - Full access (trust tiers: AAA to BAA)
|
|
57
|
+
- **`prod_throttled`** - Rate-limited access (trust tiers: BA to B)
|
|
58
|
+
- **`sandbox`** - Agent under evaluation (temporary state)
|
|
59
|
+
- **`sandbox_only`** - Access denied (trust tiers: CAA to C)
|
|
60
|
+
|
|
61
|
+
### Trust Evaluation
|
|
62
|
+
|
|
63
|
+
Valiron evaluates agents using:
|
|
64
|
+
|
|
65
|
+
1. **On-chain Reputation** - ERC-8004 feedback submitted by other organizations
|
|
66
|
+
2. **Behavioral Analysis** - Sandbox evaluation of rate-limit compliance, error rates, and request patterns
|
|
67
|
+
3. **Credit Rating** - Moody's-style scoring system (AAA to C tiers)
|
|
68
|
+
|
|
69
|
+
### Architecture
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
Request → SDK.checkAgent() → Valiron API → Route Decision → Application
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The SDK queries Valiron's trust infrastructure, which evaluates on-chain reputation and behavioral metrics to return a routing decision. Your application implements access control based on this decision.
|
|
76
|
+
|
|
77
|
+
## API Reference
|
|
78
|
+
|
|
79
|
+
### Constructor
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
new ValironSDK(config: ValironConfig)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Config Options:**
|
|
86
|
+
|
|
87
|
+
| Option | Type | Required | Default | Description |
|
|
88
|
+
|--------|------|----------|---------|-------------|
|
|
89
|
+
| `apiKey` | string | No | - | API key (reserved for future use) |
|
|
90
|
+
| `endpoint` | string | No | `https://valiron-edge-proxy.onrender.com` | API endpoint URL |
|
|
91
|
+
| `timeout` | number | No | `5000` | Request timeout (ms) |
|
|
92
|
+
| `debug` | boolean | No | `false` | Enable debug logging |
|
|
93
|
+
|
|
94
|
+
### Methods
|
|
95
|
+
|
|
96
|
+
#### `checkAgent(agentId: string): Promise<RoutingResponse>`
|
|
97
|
+
|
|
98
|
+
Check routing decision for an ERC-8004 agent.
|
|
99
|
+
|
|
100
|
+
**Returns:**
|
|
101
|
+
```typescript
|
|
102
|
+
{
|
|
103
|
+
route: 'prod' | 'prod_throttled' | 'sandbox' | 'sandbox_only',
|
|
104
|
+
reason: string,
|
|
105
|
+
explanation: string,
|
|
106
|
+
onChainData?: {
|
|
107
|
+
feedbackCount: number,
|
|
108
|
+
averageScore: number,
|
|
109
|
+
agentId: string
|
|
110
|
+
},
|
|
111
|
+
localReputation?: {
|
|
112
|
+
score: number,
|
|
113
|
+
tier: MoodysRating,
|
|
114
|
+
riskLevel: 'GREEN' | 'YELLOW' | 'RED',
|
|
115
|
+
graduated: boolean
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Example:**
|
|
121
|
+
```typescript
|
|
122
|
+
const decision = await valiron.checkAgent('417');
|
|
123
|
+
console.log(decision.route); // 'prod'
|
|
124
|
+
console.log(decision.localReputation?.tier); // 'AAA'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
#### `checkWallet(wallet: string): Promise<RoutingResponse>`
|
|
130
|
+
|
|
131
|
+
Check routing decision for a wallet address (legacy method).
|
|
132
|
+
|
|
133
|
+
**Example:**
|
|
134
|
+
```typescript
|
|
135
|
+
const decision = await valiron.checkWallet('0x742d35Cc...');
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
#### `getAgentProfile(agentId: string): Promise<AgentProfile>`
|
|
141
|
+
|
|
142
|
+
Get complete trust profile for an agent.
|
|
143
|
+
|
|
144
|
+
**Returns:**
|
|
145
|
+
```typescript
|
|
146
|
+
{
|
|
147
|
+
agentId: string,
|
|
148
|
+
identity: {
|
|
149
|
+
wallet: string,
|
|
150
|
+
name: string,
|
|
151
|
+
description: string,
|
|
152
|
+
image: string,
|
|
153
|
+
endpoints: string[]
|
|
154
|
+
},
|
|
155
|
+
onchainReputation: {
|
|
156
|
+
count: number,
|
|
157
|
+
averageScore: number,
|
|
158
|
+
feedbackEntries: FeedbackEntry[]
|
|
159
|
+
},
|
|
160
|
+
localReputation: {
|
|
161
|
+
score: number,
|
|
162
|
+
tier: MoodysRating,
|
|
163
|
+
riskLevel: 'GREEN' | 'YELLOW' | 'RED',
|
|
164
|
+
metrics: BehavioralMetrics
|
|
165
|
+
},
|
|
166
|
+
routing: {
|
|
167
|
+
finalRoute: RouteDecision,
|
|
168
|
+
decision: string,
|
|
169
|
+
reasons: string[]
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Example:**
|
|
175
|
+
```typescript
|
|
176
|
+
const profile = await valiron.getAgentProfile('417');
|
|
177
|
+
console.log(`Score: ${profile.localReputation.score}/100`);
|
|
178
|
+
console.log(`Tier: ${profile.localReputation.tier}`);
|
|
179
|
+
console.log(`On-chain feedback: ${profile.onchainReputation.count} entries`);
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
#### `submitFeedback(params: SubmitFeedbackParams): Promise<{ success: boolean; txHash?: string }>`
|
|
185
|
+
|
|
186
|
+
Submit feedback about an agent's behavior. Valiron handles IPFS storage and on-chain submission automatically.
|
|
187
|
+
|
|
188
|
+
**Parameters:**
|
|
189
|
+
```typescript
|
|
190
|
+
{
|
|
191
|
+
agentId: string,
|
|
192
|
+
score: number, // 0-100
|
|
193
|
+
outcome: 'success' | 'failure',
|
|
194
|
+
metadata?: { // Custom metadata
|
|
195
|
+
[key: string]: any
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Example:**
|
|
201
|
+
```typescript
|
|
202
|
+
await valiron.submitFeedback({
|
|
203
|
+
agentId: '417',
|
|
204
|
+
score: 95,
|
|
205
|
+
outcome: 'success',
|
|
206
|
+
metadata: {
|
|
207
|
+
taskType: 'data_processing',
|
|
208
|
+
duration: 2340,
|
|
209
|
+
recordsProcessed: 10000
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
#### `triggerSandboxTest(params: SandboxTestParams): Promise<{ success: boolean; message: string }>`
|
|
217
|
+
|
|
218
|
+
Manually trigger sandbox testing for an agent.
|
|
219
|
+
|
|
220
|
+
**Example:**
|
|
221
|
+
```typescript
|
|
222
|
+
await valiron.triggerSandboxTest({
|
|
223
|
+
agentId: '417',
|
|
224
|
+
behaviorType: 'good'
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Integration Examples
|
|
231
|
+
|
|
232
|
+
### Express.js Middleware
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
import { ValironSDK } from '@valiron/sdk';
|
|
236
|
+
import express from 'express';
|
|
237
|
+
|
|
238
|
+
const app = express();
|
|
239
|
+
const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY! });
|
|
240
|
+
|
|
241
|
+
async function valironMiddleware(req, res, next) {
|
|
242
|
+
const agentId = req.headers['x-agent-id'];
|
|
243
|
+
|
|
244
|
+
const decision = await valiron.checkAgent(agentId);
|
|
245
|
+
|
|
246
|
+
if (decision.route === 'prod' || decision.route === 'prod_throttled') {
|
|
247
|
+
return next();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return res.status(403).json({
|
|
251
|
+
error: 'Access denied',
|
|
252
|
+
reason: decision.reason
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
app.use('/api/protected/*', valironMiddleware);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Next.js Middleware
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
// middleware.ts
|
|
263
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
264
|
+
import { ValironSDK } from '@valiron/sdk';
|
|
265
|
+
|
|
266
|
+
const valiron = new ValironSDK({ apiKey: process.env.VALIRON_API_KEY! });
|
|
267
|
+
|
|
268
|
+
export async function middleware(request: NextRequest) {
|
|
269
|
+
const agentId = request.headers.get('x-agent-id');
|
|
270
|
+
const decision = await valiron.checkAgent(agentId!);
|
|
271
|
+
|
|
272
|
+
if (decision.route === 'prod' || decision.route === 'prod_throttled') {
|
|
273
|
+
return NextResponse.next();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return NextResponse.json(
|
|
277
|
+
{ error: 'Access denied' },
|
|
278
|
+
{ status: 403 }
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export const config = {
|
|
283
|
+
matcher: '/api/protected/:path*'
|
|
284
|
+
};
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Simple API Gateway
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
import { ValironSDK } from '@valiron/sdk';
|
|
291
|
+
|
|
292
|
+
const valiron = new ValironSDK({ apiKey: 'vln_xxx' });
|
|
293
|
+
|
|
294
|
+
async function handleRequest(agentId: string) {
|
|
295
|
+
const decision = await valiron.checkAgent(agentId);
|
|
296
|
+
|
|
297
|
+
switch (decision.route) {
|
|
298
|
+
case 'prod':
|
|
299
|
+
return processRequest({ rateLimit: null });
|
|
300
|
+
|
|
301
|
+
case 'prod_throttled':
|
|
302
|
+
return processRequest({ rateLimit: '100/hour' });
|
|
303
|
+
|
|
304
|
+
case 'sandbox':
|
|
305
|
+
return { error: 'Agent under evaluation', retryAfter: 30 };
|
|
306
|
+
|
|
307
|
+
case 'sandbox_only':
|
|
308
|
+
return { error: 'Access denied', reason: decision.reason };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Integration with x402 Payment APIs
|
|
314
|
+
|
|
315
|
+
Valiron integrates with **x402** payment-gated APIs (e.g., [Orthogonal](https://www.orth.sh/)). Verify trust before processing payments to prevent malicious agents from accessing paid endpoints.
|
|
316
|
+
|
|
317
|
+
#### Server-Side: Validate Trust + Payment
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
import { ValironSDK } from '@valiron/sdk';
|
|
321
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
322
|
+
import { getAddress } from 'viem';
|
|
323
|
+
import { exact } from 'x402/schemes'; // Real x402 package
|
|
324
|
+
|
|
325
|
+
const valiron = new ValironSDK();
|
|
326
|
+
|
|
327
|
+
async function trustThenPayment(req, res, next) {
|
|
328
|
+
const agentId = req.headers['x-agent-id'];
|
|
329
|
+
const paymentHeader = req.headers['x-payment'];
|
|
330
|
+
|
|
331
|
+
// Step 1: Verify trust before payment
|
|
332
|
+
const { route, localReputation } = await valiron.checkAgent(agentId);
|
|
333
|
+
|
|
334
|
+
if (route === 'sandbox_only') {
|
|
335
|
+
return res.status(403).json({
|
|
336
|
+
error: 'Agent banned',
|
|
337
|
+
reason: 'Failed behavioral trust requirements'
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (route === 'sandbox') {
|
|
342
|
+
return res.status(403).json({
|
|
343
|
+
error: 'Agent under evaluation',
|
|
344
|
+
retryAfter: 30
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Step 2: Verify payment (trusted agents only)
|
|
349
|
+
if (!paymentHeader) {
|
|
350
|
+
// Dynamic pricing based on trust tier
|
|
351
|
+
const pricing = {
|
|
352
|
+
'AAA': 5, 'AA': 5, 'A': 8, 'BAA': 10,
|
|
353
|
+
'BA': 25, 'B': 50, 'CAA': 100, 'CA': 100, 'C': 100
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
return res.status(402).json({
|
|
357
|
+
error: 'Payment Required',
|
|
358
|
+
accepts: [{
|
|
359
|
+
scheme: 'exact',
|
|
360
|
+
network: 'base',
|
|
361
|
+
maxAmountRequired: pricing[localReputation?.tier || 'B'],
|
|
362
|
+
asset: '0x...',
|
|
363
|
+
payTo: '0x...',
|
|
364
|
+
// ... x402 payment requirements
|
|
365
|
+
}]
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Verify payment (use x402 library)
|
|
370
|
+
const valid = await exact.evm.verifyPayment(paymentHeader);
|
|
371
|
+
if (!valid) {
|
|
372
|
+
return res.status(402).json({ error: 'Invalid payment' });
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Step 3: Apply trust-based rate limits
|
|
376
|
+
req.rateLimit = route === 'prod' ? 1000 : 100; // requests/hour
|
|
377
|
+
next();
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
app.get('/api/premium/weather', trustThenPayment, handler);
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
#### Client-Side: Make Trusted Payments
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
import { ValironSDK } from '@valiron/sdk';
|
|
387
|
+
import { exact } from 'x402/schemes';
|
|
388
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
389
|
+
|
|
390
|
+
const valiron = new ValironSDK();
|
|
391
|
+
const account = privateKeyToAccount(process.env.PRIVATE_KEY);
|
|
392
|
+
|
|
393
|
+
async function fetchPaidAPI(agentId: string, url: string) {
|
|
394
|
+
// Optional: Verify own trust status
|
|
395
|
+
const { route } = await valiron.checkAgent(agentId);
|
|
396
|
+
if (route === 'sandbox_only') {
|
|
397
|
+
throw new Error('Agent access denied');
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Get payment requirements
|
|
401
|
+
const res = await fetch(url);
|
|
402
|
+
const { accepts } = await res.json();
|
|
403
|
+
|
|
404
|
+
// Create x402 payment header
|
|
405
|
+
const paymentHeader = await exact.evm.createPaymentHeader(
|
|
406
|
+
account,
|
|
407
|
+
1,
|
|
408
|
+
accepts[0]
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
// Retry with payment
|
|
412
|
+
const data = await fetch(url, {
|
|
413
|
+
headers: { 'X-PAYMENT': paymentHeader }
|
|
414
|
+
}).then(r => r.json());
|
|
415
|
+
|
|
416
|
+
return data;
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**Trust + Payment Benefits:**
|
|
421
|
+
- Reject untrusted agents before payment verification
|
|
422
|
+
- Implement dynamic pricing based on trust tier
|
|
423
|
+
- Reduce transaction overhead by filtering banned agents
|
|
424
|
+
- Mitigate DDoS attacks from paid malicious requests
|
|
425
|
+
|
|
426
|
+
**Compatible with:**
|
|
427
|
+
- [Orthogonal](https://www.orth.sh/) x402 API marketplace
|
|
428
|
+
- Any HTTP 402 Payment Required API
|
|
429
|
+
|
|
430
|
+
See [examples/x402-integration.ts](examples/x402-integration.ts) for complete implementation.
|
|
431
|
+
|
|
432
|
+
## TypeScript Types
|
|
433
|
+
|
|
434
|
+
The SDK is fully typed. Import types as needed:
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
import {
|
|
438
|
+
ValironSDK,
|
|
439
|
+
RouteDecision,
|
|
440
|
+
MoodysRating,
|
|
441
|
+
AgentProfile,
|
|
442
|
+
RoutingResponse,
|
|
443
|
+
ValironError
|
|
444
|
+
} from '@valiron/sdk';
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
## Moody's Credit Rating Tiers
|
|
448
|
+
|
|
449
|
+
| Tier | Score Range | Risk | Access Level |
|
|
450
|
+
|------|-------------|------|--------------|
|
|
451
|
+
| AAA | 98-110 | Prime | Full production |
|
|
452
|
+
| AA | 92-97 | High grade | Full production |
|
|
453
|
+
| A | 85-91 | Upper medium | Full production |
|
|
454
|
+
| BAA | 75-84 | Medium | Full production (monitored) |
|
|
455
|
+
| BA | 65-74 | Speculative | Throttled |
|
|
456
|
+
| B | 50-64 | Highly speculative | Throttled |
|
|
457
|
+
| CAA | 35-49 | Substantial risk | Sandbox only |
|
|
458
|
+
| CA | 20-34 | Extremely speculative | Sandbox only |
|
|
459
|
+
| C | 0-19 | Default risk | Sandbox only |
|
|
460
|
+
|
|
461
|
+
## Error Handling
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
import { ValironError } from '@valiron/sdk';
|
|
465
|
+
|
|
466
|
+
try {
|
|
467
|
+
const decision = await valiron.checkAgent('123');
|
|
468
|
+
} catch (error) {
|
|
469
|
+
if (error instanceof ValironError) {
|
|
470
|
+
console.error('Code:', error.code);
|
|
471
|
+
console.error('Message:', error.message);
|
|
472
|
+
console.error('Status:', error.statusCode);
|
|
473
|
+
|
|
474
|
+
switch (error.code) {
|
|
475
|
+
case 'TIMEOUT_ERROR':
|
|
476
|
+
// Handle timeout
|
|
477
|
+
break;
|
|
478
|
+
case 'NETWORK_ERROR':
|
|
479
|
+
// Handle network issues
|
|
480
|
+
break;
|
|
481
|
+
case 'API_ERROR':
|
|
482
|
+
// Handle API errors
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
## Additional Resources
|
|
490
|
+
|
|
491
|
+
- [ERC-8004 Standard](https://eips.ethereum.org/EIPS/eip-8004)
|
|
492
|
+
|
|
493
|
+
## Support
|
|
494
|
+
|
|
495
|
+
- **Email**: founders@valiron.io
|
|
496
|
+
|
|
497
|
+
## License
|
|
498
|
+
|
|
499
|
+
MIT © Valiron
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ValironConfig, RoutingResponse, AgentProfile, WalletProfile, SubmitFeedbackParams, SandboxTestParams } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Base client for making HTTP requests to Valiron API
|
|
4
|
+
*/
|
|
5
|
+
export declare class BaseClient {
|
|
6
|
+
protected endpoint: string;
|
|
7
|
+
protected apiKey?: string;
|
|
8
|
+
protected timeout: number;
|
|
9
|
+
protected debug: boolean;
|
|
10
|
+
constructor(config?: ValironConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Build headers for API requests
|
|
13
|
+
*/
|
|
14
|
+
private buildHeaders;
|
|
15
|
+
/**
|
|
16
|
+
* Make a GET request to Valiron API
|
|
17
|
+
*/
|
|
18
|
+
protected get<T>(path: string, params?: Record<string, string>): Promise<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Make a POST request to Valiron API
|
|
21
|
+
*/
|
|
22
|
+
protected post<T>(path: string, body?: any): Promise<T>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Client for agent trust and routing operations
|
|
26
|
+
*/
|
|
27
|
+
export declare class TrustClient extends BaseClient {
|
|
28
|
+
/**
|
|
29
|
+
* Check agent routing decision
|
|
30
|
+
*
|
|
31
|
+
* This is the primary method for determining how to route requests from an agent.
|
|
32
|
+
* The Valiron system will automatically handle sandbox testing if needed.
|
|
33
|
+
*
|
|
34
|
+
* @param agentId - The ERC-8004 agent ID
|
|
35
|
+
* @returns Routing decision with explanation
|
|
36
|
+
*/
|
|
37
|
+
checkAgent(agentId: string): Promise<RoutingResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Check wallet routing decision (legacy support)
|
|
40
|
+
*
|
|
41
|
+
* @param wallet - The wallet address
|
|
42
|
+
* @returns Routing decision with explanation
|
|
43
|
+
*/
|
|
44
|
+
checkWallet(wallet: string): Promise<RoutingResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Get complete agent trust profile
|
|
47
|
+
*
|
|
48
|
+
* Returns combined on-chain and off-chain reputation data
|
|
49
|
+
*
|
|
50
|
+
* @param agentId - The ERC-8004 agent ID
|
|
51
|
+
* @returns Complete agent profile
|
|
52
|
+
*/
|
|
53
|
+
getAgentProfile(agentId: string): Promise<AgentProfile>;
|
|
54
|
+
/**
|
|
55
|
+
* Get wallet profile
|
|
56
|
+
*
|
|
57
|
+
* @param wallet - The wallet address
|
|
58
|
+
* @returns Wallet profile with routing info
|
|
59
|
+
*/
|
|
60
|
+
getWalletProfile(wallet: string): Promise<WalletProfile>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Client for reputation feedback operations
|
|
64
|
+
*/
|
|
65
|
+
export declare class ReputationClient extends BaseClient {
|
|
66
|
+
/**
|
|
67
|
+
* Submit feedback about an agent's behavior
|
|
68
|
+
*
|
|
69
|
+
* Note: This submits feedback to Valiron, which then handles
|
|
70
|
+
* IPFS upload and on-chain submission on your behalf.
|
|
71
|
+
*
|
|
72
|
+
* @param params - Feedback parameters
|
|
73
|
+
*/
|
|
74
|
+
submitFeedback(params: SubmitFeedbackParams): Promise<{
|
|
75
|
+
success: boolean;
|
|
76
|
+
txHash?: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Manually trigger sandbox testing for an agent
|
|
80
|
+
*
|
|
81
|
+
* Useful for testing or re-evaluation scenarios.
|
|
82
|
+
*
|
|
83
|
+
* @param params - Sandbox test parameters
|
|
84
|
+
*/
|
|
85
|
+
triggerSandboxTest(params: SandboxTestParams): Promise<{
|
|
86
|
+
success: boolean;
|
|
87
|
+
message: string;
|
|
88
|
+
}>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,iBAAiB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GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAGpG"}
|
package/dist/clients.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReputationClient = exports.TrustClient = exports.BaseClient = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
/**
|
|
6
|
+
* Base client for making HTTP requests to Valiron API
|
|
7
|
+
*/
|
|
8
|
+
class BaseClient {
|
|
9
|
+
constructor(config = {}) {
|
|
10
|
+
this.endpoint = config.endpoint || 'https://valiron-edge-proxy.onrender.com';
|
|
11
|
+
this.apiKey = config.apiKey;
|
|
12
|
+
this.timeout = config.timeout || 5000;
|
|
13
|
+
this.debug = config.debug || false;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Build headers for API requests
|
|
17
|
+
*/
|
|
18
|
+
buildHeaders() {
|
|
19
|
+
const headers = {
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
};
|
|
22
|
+
// Only include Authorization header if apiKey is provided
|
|
23
|
+
if (this.apiKey) {
|
|
24
|
+
headers['Authorization'] = `Bearer ${this.apiKey}`;
|
|
25
|
+
}
|
|
26
|
+
return headers;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Make a GET request to Valiron API
|
|
30
|
+
*/
|
|
31
|
+
async get(path, params) {
|
|
32
|
+
const url = new URL(path, this.endpoint);
|
|
33
|
+
if (params) {
|
|
34
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
35
|
+
url.searchParams.append(key, value);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (this.debug) {
|
|
39
|
+
console.log(`[Valiron SDK] GET ${url.toString()}`);
|
|
40
|
+
}
|
|
41
|
+
const controller = new AbortController();
|
|
42
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
43
|
+
try {
|
|
44
|
+
const response = await fetch(url.toString(), {
|
|
45
|
+
method: 'GET',
|
|
46
|
+
headers: this.buildHeaders(),
|
|
47
|
+
signal: controller.signal,
|
|
48
|
+
});
|
|
49
|
+
clearTimeout(timeoutId);
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
52
|
+
throw new types_1.ValironError(error.message || `Request failed: ${response.statusText}`, error.code || 'API_ERROR', response.status);
|
|
53
|
+
}
|
|
54
|
+
const data = await response.json();
|
|
55
|
+
if (this.debug) {
|
|
56
|
+
console.log(`[Valiron SDK] Response:`, data);
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
clearTimeout(timeoutId);
|
|
62
|
+
if (error.name === 'AbortError') {
|
|
63
|
+
throw new types_1.ValironError(`Request timeout after ${this.timeout}ms`, 'TIMEOUT_ERROR');
|
|
64
|
+
}
|
|
65
|
+
if (error instanceof types_1.ValironError) {
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
throw new types_1.ValironError(error.message || 'Network error', 'NETWORK_ERROR');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Make a POST request to Valiron API
|
|
73
|
+
*/
|
|
74
|
+
async post(path, body) {
|
|
75
|
+
const url = new URL(path, this.endpoint);
|
|
76
|
+
if (this.debug) {
|
|
77
|
+
console.log(`[Valiron SDK] POST ${url.toString()}`, body);
|
|
78
|
+
}
|
|
79
|
+
const controller = new AbortController();
|
|
80
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
81
|
+
try {
|
|
82
|
+
const response = await fetch(url.toString(), {
|
|
83
|
+
method: 'POST',
|
|
84
|
+
headers: this.buildHeaders(),
|
|
85
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
86
|
+
signal: controller.signal,
|
|
87
|
+
});
|
|
88
|
+
clearTimeout(timeoutId);
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
91
|
+
throw new types_1.ValironError(error.message || `Request failed: ${response.statusText}`, error.code || 'API_ERROR', response.status);
|
|
92
|
+
}
|
|
93
|
+
const data = await response.json();
|
|
94
|
+
if (this.debug) {
|
|
95
|
+
console.log(`[Valiron SDK] Response:`, data);
|
|
96
|
+
}
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
clearTimeout(timeoutId);
|
|
101
|
+
if (error.name === 'AbortError') {
|
|
102
|
+
throw new types_1.ValironError(`Request timeout after ${this.timeout}ms`, 'TIMEOUT_ERROR');
|
|
103
|
+
}
|
|
104
|
+
if (error instanceof types_1.ValironError) {
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
throw new types_1.ValironError(error.message || 'Network error', 'NETWORK_ERROR');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.BaseClient = BaseClient;
|
|
112
|
+
/**
|
|
113
|
+
* Client for agent trust and routing operations
|
|
114
|
+
*/
|
|
115
|
+
class TrustClient extends BaseClient {
|
|
116
|
+
/**
|
|
117
|
+
* Check agent routing decision
|
|
118
|
+
*
|
|
119
|
+
* This is the primary method for determining how to route requests from an agent.
|
|
120
|
+
* The Valiron system will automatically handle sandbox testing if needed.
|
|
121
|
+
*
|
|
122
|
+
* @param agentId - The ERC-8004 agent ID
|
|
123
|
+
* @returns Routing decision with explanation
|
|
124
|
+
*/
|
|
125
|
+
async checkAgent(agentId) {
|
|
126
|
+
return this.get('/route', { agentId });
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Check wallet routing decision (legacy support)
|
|
130
|
+
*
|
|
131
|
+
* @param wallet - The wallet address
|
|
132
|
+
* @returns Routing decision with explanation
|
|
133
|
+
*/
|
|
134
|
+
async checkWallet(wallet) {
|
|
135
|
+
return this.get('/route', { wallet });
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get complete agent trust profile
|
|
139
|
+
*
|
|
140
|
+
* Returns combined on-chain and off-chain reputation data
|
|
141
|
+
*
|
|
142
|
+
* @param agentId - The ERC-8004 agent ID
|
|
143
|
+
* @returns Complete agent profile
|
|
144
|
+
*/
|
|
145
|
+
async getAgentProfile(agentId) {
|
|
146
|
+
return this.get(`/agent/${agentId}`);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get wallet profile
|
|
150
|
+
*
|
|
151
|
+
* @param wallet - The wallet address
|
|
152
|
+
* @returns Wallet profile with routing info
|
|
153
|
+
*/
|
|
154
|
+
async getWalletProfile(wallet) {
|
|
155
|
+
return this.get(`/wallet/${wallet}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.TrustClient = TrustClient;
|
|
159
|
+
/**
|
|
160
|
+
* Client for reputation feedback operations
|
|
161
|
+
*/
|
|
162
|
+
class ReputationClient extends BaseClient {
|
|
163
|
+
/**
|
|
164
|
+
* Submit feedback about an agent's behavior
|
|
165
|
+
*
|
|
166
|
+
* Note: This submits feedback to Valiron, which then handles
|
|
167
|
+
* IPFS upload and on-chain submission on your behalf.
|
|
168
|
+
*
|
|
169
|
+
* @param params - Feedback parameters
|
|
170
|
+
*/
|
|
171
|
+
async submitFeedback(params) {
|
|
172
|
+
return this.post('/feedback', params);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Manually trigger sandbox testing for an agent
|
|
176
|
+
*
|
|
177
|
+
* Useful for testing or re-evaluation scenarios.
|
|
178
|
+
*
|
|
179
|
+
* @param params - Sandbox test parameters
|
|
180
|
+
*/
|
|
181
|
+
async triggerSandboxTest(params) {
|
|
182
|
+
return this.post('/sandbox/trigger', params);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.ReputationClient = ReputationClient;
|
|
186
|
+
//# sourceMappingURL=clients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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;;;;;OAKG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAc;QACnC,OAAO,IAAI,CAAC,GAAG,CAAgB,WAAW,MAAM,EAAE,CAAC,CAAC;IACtD,CAAC;CACF;AA7CD,kCA6CC;AAED;;GAEG;AACH,MAAa,gBAAiB,SAAQ,UAAU;IAC9C;;;;;;;OAOG;IACH,KAAK,CAAC,cAAc,CAAC,MAA4B;QAC/C,OAAO,IAAI,CAAC,IAAI,CAAwC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,kBAAkB,CAAC,MAAyB;QAChD,OAAO,IAAI,CAAC,IAAI,CAAwC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACtF,CAAC;CACF;AAvBD,4CAuBC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { ValironConfig, RoutingResponse, AgentProfile, WalletProfile, SubmitFeedbackParams, SandboxTestParams } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Valiron SDK - Official TypeScript SDK for the Trust Layer for Agentic Economy
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { ValironSDK } from '@valiron/sdk';
|
|
8
|
+
*
|
|
9
|
+
* const valiron = new ValironSDK({
|
|
10
|
+
* apiKey: 'vln_your_api_key'
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* // Check if agent can access production
|
|
14
|
+
* const decision = await valiron.checkAgent('123');
|
|
15
|
+
* if (decision.route === 'prod') {
|
|
16
|
+
* // Allow full production access
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class ValironSDK {
|
|
21
|
+
private trustClient;
|
|
22
|
+
private reputationClient;
|
|
23
|
+
constructor(config: ValironConfig);
|
|
24
|
+
/**
|
|
25
|
+
* Check agent routing decision
|
|
26
|
+
*
|
|
27
|
+
* This is the primary method for determining how to route requests from an agent.
|
|
28
|
+
* Valiron automatically handles sandbox testing if the agent hasn't been evaluated.
|
|
29
|
+
*
|
|
30
|
+
* @param agentId - The ERC-8004 agent ID
|
|
31
|
+
* @returns Routing decision with detailed explanation
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const result = await valiron.checkAgent('417');
|
|
36
|
+
*
|
|
37
|
+
* switch (result.route) {
|
|
38
|
+
* case 'prod':
|
|
39
|
+
* return handleProductionRequest();
|
|
40
|
+
* case 'prod_throttled':
|
|
41
|
+
* return handleThrottledRequest();
|
|
42
|
+
* case 'sandbox':
|
|
43
|
+
* case 'sandbox_only':
|
|
44
|
+
* return rejectRequest();
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
checkAgent(agentId: string): Promise<RoutingResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Check wallet routing decision
|
|
51
|
+
*
|
|
52
|
+
* Legacy method for wallet-based routing. Prefer `checkAgent()` for ERC-8004 agents.
|
|
53
|
+
*
|
|
54
|
+
* @param wallet - The wallet address
|
|
55
|
+
* @returns Routing decision
|
|
56
|
+
*/
|
|
57
|
+
checkWallet(wallet: string): Promise<RoutingResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Get complete agent trust profile
|
|
60
|
+
*
|
|
61
|
+
* Returns comprehensive trust data including on-chain reputation,
|
|
62
|
+
* behavioral analysis scores, and routing logic.
|
|
63
|
+
*
|
|
64
|
+
* @param agentId - The ERC-8004 agent ID
|
|
65
|
+
* @returns Complete agent profile
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const profile = await valiron.getAgentProfile('417');
|
|
70
|
+
* console.log(`Agent score: ${profile.localReputation?.score}`);
|
|
71
|
+
* console.log(`Tier: ${profile.localReputation?.tier}`);
|
|
72
|
+
* console.log(`On-chain feedback: ${profile.onchainReputation.count} entries`);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
getAgentProfile(agentId: string): Promise<AgentProfile>;
|
|
76
|
+
/**
|
|
77
|
+
* Get wallet profile
|
|
78
|
+
*
|
|
79
|
+
* @param wallet - The wallet address
|
|
80
|
+
* @returns Wallet profile with routing info
|
|
81
|
+
*/
|
|
82
|
+
getWalletProfile(wallet: string): Promise<WalletProfile>;
|
|
83
|
+
/**
|
|
84
|
+
* Submit feedback about an agent's behavior
|
|
85
|
+
*
|
|
86
|
+
* This allows you to report an agent's behavior to Valiron.
|
|
87
|
+
* Valiron handles IPFS storage and on-chain submission automatically.
|
|
88
|
+
*
|
|
89
|
+
* @param params - Feedback parameters
|
|
90
|
+
* @returns Submission result with transaction hash
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* await valiron.submitFeedback({
|
|
95
|
+
* agentId: '417',
|
|
96
|
+
* score: 95,
|
|
97
|
+
* outcome: 'success',
|
|
98
|
+
* metadata: {
|
|
99
|
+
* taskType: 'data_processing',
|
|
100
|
+
* duration: 1234
|
|
101
|
+
* }
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
submitFeedback(params: SubmitFeedbackParams): Promise<{
|
|
106
|
+
success: boolean;
|
|
107
|
+
txHash?: string;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Manually trigger sandbox testing
|
|
111
|
+
*
|
|
112
|
+
* Useful for re-evaluating an agent or testing specific scenarios.
|
|
113
|
+
*
|
|
114
|
+
* @param params - Sandbox test parameters
|
|
115
|
+
* @returns Test trigger result
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* await valiron.triggerSandboxTest({
|
|
120
|
+
* agentId: '417',
|
|
121
|
+
* behaviorType: 'good'
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
triggerSandboxTest(params: SandboxTestParams): Promise<{
|
|
126
|
+
success: boolean;
|
|
127
|
+
message: string;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
|
130
|
+
export * from './types';
|
|
131
|
+
export * from './clients';
|
|
132
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,MAAM,EAAE,aAAa;IAKjC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAI3D;;;;;;;OAOG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAI3D;;;;;;;;;;;;;;;;OAgBG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI7D;;;;;OAKG;IACG,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAI9D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAIlG;;;;;;;;;;;;;;;OAeG;IACG,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAGpG;AAGD,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ValironSDK = void 0;
|
|
18
|
+
const clients_1 = require("./clients");
|
|
19
|
+
/**
|
|
20
|
+
* Valiron SDK - Official TypeScript SDK for the Trust Layer for Agentic Economy
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { ValironSDK } from '@valiron/sdk';
|
|
25
|
+
*
|
|
26
|
+
* const valiron = new ValironSDK({
|
|
27
|
+
* apiKey: 'vln_your_api_key'
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Check if agent can access production
|
|
31
|
+
* const decision = await valiron.checkAgent('123');
|
|
32
|
+
* if (decision.route === 'prod') {
|
|
33
|
+
* // Allow full production access
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
class ValironSDK {
|
|
38
|
+
constructor(config) {
|
|
39
|
+
this.trustClient = new clients_1.TrustClient(config);
|
|
40
|
+
this.reputationClient = new clients_1.ReputationClient(config);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check agent routing decision
|
|
44
|
+
*
|
|
45
|
+
* This is the primary method for determining how to route requests from an agent.
|
|
46
|
+
* Valiron automatically handles sandbox testing if the agent hasn't been evaluated.
|
|
47
|
+
*
|
|
48
|
+
* @param agentId - The ERC-8004 agent ID
|
|
49
|
+
* @returns Routing decision with detailed explanation
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const result = await valiron.checkAgent('417');
|
|
54
|
+
*
|
|
55
|
+
* switch (result.route) {
|
|
56
|
+
* case 'prod':
|
|
57
|
+
* return handleProductionRequest();
|
|
58
|
+
* case 'prod_throttled':
|
|
59
|
+
* return handleThrottledRequest();
|
|
60
|
+
* case 'sandbox':
|
|
61
|
+
* case 'sandbox_only':
|
|
62
|
+
* return rejectRequest();
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
async checkAgent(agentId) {
|
|
67
|
+
return this.trustClient.checkAgent(agentId);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check wallet routing decision
|
|
71
|
+
*
|
|
72
|
+
* Legacy method for wallet-based routing. Prefer `checkAgent()` for ERC-8004 agents.
|
|
73
|
+
*
|
|
74
|
+
* @param wallet - The wallet address
|
|
75
|
+
* @returns Routing decision
|
|
76
|
+
*/
|
|
77
|
+
async checkWallet(wallet) {
|
|
78
|
+
return this.trustClient.checkWallet(wallet);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get complete agent trust profile
|
|
82
|
+
*
|
|
83
|
+
* Returns comprehensive trust data including on-chain reputation,
|
|
84
|
+
* behavioral analysis scores, and routing logic.
|
|
85
|
+
*
|
|
86
|
+
* @param agentId - The ERC-8004 agent ID
|
|
87
|
+
* @returns Complete agent profile
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const profile = await valiron.getAgentProfile('417');
|
|
92
|
+
* console.log(`Agent score: ${profile.localReputation?.score}`);
|
|
93
|
+
* console.log(`Tier: ${profile.localReputation?.tier}`);
|
|
94
|
+
* console.log(`On-chain feedback: ${profile.onchainReputation.count} entries`);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
async getAgentProfile(agentId) {
|
|
98
|
+
return this.trustClient.getAgentProfile(agentId);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get wallet profile
|
|
102
|
+
*
|
|
103
|
+
* @param wallet - The wallet address
|
|
104
|
+
* @returns Wallet profile with routing info
|
|
105
|
+
*/
|
|
106
|
+
async getWalletProfile(wallet) {
|
|
107
|
+
return this.trustClient.getWalletProfile(wallet);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Submit feedback about an agent's behavior
|
|
111
|
+
*
|
|
112
|
+
* This allows you to report an agent's behavior to Valiron.
|
|
113
|
+
* Valiron handles IPFS storage and on-chain submission automatically.
|
|
114
|
+
*
|
|
115
|
+
* @param params - Feedback parameters
|
|
116
|
+
* @returns Submission result with transaction hash
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* await valiron.submitFeedback({
|
|
121
|
+
* agentId: '417',
|
|
122
|
+
* score: 95,
|
|
123
|
+
* outcome: 'success',
|
|
124
|
+
* metadata: {
|
|
125
|
+
* taskType: 'data_processing',
|
|
126
|
+
* duration: 1234
|
|
127
|
+
* }
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
async submitFeedback(params) {
|
|
132
|
+
return this.reputationClient.submitFeedback(params);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Manually trigger sandbox testing
|
|
136
|
+
*
|
|
137
|
+
* Useful for re-evaluating an agent or testing specific scenarios.
|
|
138
|
+
*
|
|
139
|
+
* @param params - Sandbox test parameters
|
|
140
|
+
* @returns Test trigger result
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* await valiron.triggerSandboxTest({
|
|
145
|
+
* agentId: '417',
|
|
146
|
+
* behaviorType: 'good'
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
async triggerSandboxTest(params) {
|
|
151
|
+
return this.reputationClient.triggerSandboxTest(params);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.ValironSDK = ValironSDK;
|
|
155
|
+
// Export everything
|
|
156
|
+
__exportStar(require("./types"), exports);
|
|
157
|
+
__exportStar(require("./clients"), exports);
|
|
158
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAA0D;AAU1D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,UAAU;IAIrB,YAAY,MAAqB;QAC/B,IAAI,CAAC,WAAW,GAAG,IAAI,qBAAW,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,gBAAgB,GAAG,IAAI,0BAAgB,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CAAC,MAAc;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,eAAe,CAAC,OAAe;QACnC,OAAO,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAc;QACnC,OAAO,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,cAAc,CAAC,MAA4B;QAC/C,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,kBAAkB,CAAC,MAAyB;QAChD,OAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF;AA7HD,gCA6HC;AAED,oBAAoB;AACpB,0CAAwB;AACxB,4CAA0B"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Valiron SDK Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the Valiron Trust Layer API
|
|
5
|
+
*/
|
|
6
|
+
export type RouteDecision = 'prod' | 'prod_throttled' | 'sandbox' | 'sandbox_only';
|
|
7
|
+
export type RiskLevel = 'GREEN' | 'YELLOW' | 'RED';
|
|
8
|
+
export type MoodysRating = 'AAA' | 'AA' | 'A' | 'BAA' | 'BA' | 'B' | 'CAA' | 'CA' | 'C';
|
|
9
|
+
export interface OnChainReputation {
|
|
10
|
+
feedbackCount: number;
|
|
11
|
+
averageScore: number;
|
|
12
|
+
agentId?: string;
|
|
13
|
+
wallet?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface LocalReputation {
|
|
16
|
+
score: number;
|
|
17
|
+
tier: MoodysRating;
|
|
18
|
+
riskLevel: RiskLevel;
|
|
19
|
+
graduated?: boolean;
|
|
20
|
+
metrics?: BehavioralMetrics;
|
|
21
|
+
ipfsCid?: string;
|
|
22
|
+
updatedAt?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface BehavioralMetrics {
|
|
25
|
+
loops?: number;
|
|
26
|
+
totalRequests?: number;
|
|
27
|
+
respected429?: boolean;
|
|
28
|
+
errorRate?: number;
|
|
29
|
+
averageLatency?: number;
|
|
30
|
+
burstiness?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface RoutingResponse {
|
|
33
|
+
route: RouteDecision;
|
|
34
|
+
reason: string;
|
|
35
|
+
onChainData?: OnChainReputation;
|
|
36
|
+
localReputation?: LocalReputation;
|
|
37
|
+
explanation: string;
|
|
38
|
+
}
|
|
39
|
+
export interface AgentIdentity {
|
|
40
|
+
agentId: string;
|
|
41
|
+
wallet: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
image?: string;
|
|
45
|
+
endpoints?: string[];
|
|
46
|
+
externalUri?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface FeedbackEntry {
|
|
49
|
+
clientAddress: string;
|
|
50
|
+
score: number;
|
|
51
|
+
timestamp: number;
|
|
52
|
+
tag1?: string;
|
|
53
|
+
tag2?: string;
|
|
54
|
+
endpoint?: string;
|
|
55
|
+
feedbackURI?: string;
|
|
56
|
+
feedbackHash?: string;
|
|
57
|
+
revoked?: boolean;
|
|
58
|
+
response?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface AgentProfile {
|
|
61
|
+
agentId: string;
|
|
62
|
+
identity: AgentIdentity;
|
|
63
|
+
onchainReputation: {
|
|
64
|
+
count: number;
|
|
65
|
+
averageScore: number;
|
|
66
|
+
feedbackEntries: FeedbackEntry[];
|
|
67
|
+
};
|
|
68
|
+
localReputation?: LocalReputation;
|
|
69
|
+
routing: {
|
|
70
|
+
finalRoute: RouteDecision;
|
|
71
|
+
decision: string;
|
|
72
|
+
reasons: string[];
|
|
73
|
+
signals: {
|
|
74
|
+
onChainQualifies: boolean;
|
|
75
|
+
hasLocalReputation: boolean;
|
|
76
|
+
localRiskLevel?: RiskLevel;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export interface WalletProfile {
|
|
81
|
+
wallet: string;
|
|
82
|
+
agentId?: string;
|
|
83
|
+
route: RouteDecision;
|
|
84
|
+
score?: number;
|
|
85
|
+
tier?: MoodysRating;
|
|
86
|
+
onChainData?: OnChainReputation;
|
|
87
|
+
localReputation?: LocalReputation;
|
|
88
|
+
}
|
|
89
|
+
export interface ValironConfig {
|
|
90
|
+
/**
|
|
91
|
+
* Your Valiron API key.
|
|
92
|
+
*
|
|
93
|
+
* Note: Authentication is not yet enforced by the Valiron edge proxy,
|
|
94
|
+
* so this field is currently optional and not validated. It is kept
|
|
95
|
+
* for future compatibility when API key validation is implemented.
|
|
96
|
+
*/
|
|
97
|
+
apiKey?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Valiron API endpoint (defaults to production)
|
|
100
|
+
*/
|
|
101
|
+
endpoint?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Request timeout in milliseconds (default: 5000)
|
|
104
|
+
*/
|
|
105
|
+
timeout?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Enable debug logging
|
|
108
|
+
*/
|
|
109
|
+
debug?: boolean;
|
|
110
|
+
}
|
|
111
|
+
export interface SubmitFeedbackParams {
|
|
112
|
+
agentId: string;
|
|
113
|
+
score: number;
|
|
114
|
+
outcome: 'success' | 'failure';
|
|
115
|
+
metadata?: Record<string, any>;
|
|
116
|
+
}
|
|
117
|
+
export interface SandboxTestParams {
|
|
118
|
+
agentId: string;
|
|
119
|
+
behaviorType?: 'good' | 'moderate' | 'bad';
|
|
120
|
+
}
|
|
121
|
+
export declare class ValironError extends Error {
|
|
122
|
+
code: string;
|
|
123
|
+
statusCode?: number | undefined;
|
|
124
|
+
constructor(message: string, code: string, statusCode?: number | undefined);
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG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Y,CAAC;IACpB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;CAC5C;AAED,qBAAa,YAAa,SAAQ,KAAK;IAG5B,IAAI,EAAE,MAAM;IACZ,UAAU,CAAC,EAAE,MAAM;gBAF1B,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,YAAA;CAK7B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Valiron SDK Types
|
|
4
|
+
*
|
|
5
|
+
* Type definitions for the Valiron Trust Layer API
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ValironError = void 0;
|
|
9
|
+
class ValironError extends Error {
|
|
10
|
+
constructor(message, code, statusCode) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.statusCode = statusCode;
|
|
14
|
+
this.name = 'ValironError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ValironError = ValironError;
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA+IH,MAAa,YAAa,SAAQ,KAAK;IACrC,YACE,OAAe,EACR,IAAY,EACZ,UAAmB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAS;QAG1B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AATD,oCASC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@valiron/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official TypeScript SDK for Valiron - Trust Layer for Agentic Economy",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18.0.0"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"test": "node test/validate.mjs && node test/validate-examples.mjs",
|
|
14
|
+
"prepublishOnly": "pnpm build"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"valiron",
|
|
18
|
+
"ai-agents",
|
|
19
|
+
"trust",
|
|
20
|
+
"reputation",
|
|
21
|
+
"erc8004",
|
|
22
|
+
"blockchain",
|
|
23
|
+
"web3"
|
|
24
|
+
],
|
|
25
|
+
"author": "Valiron",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^24.10.1",
|
|
29
|
+
"typescript": "^5.9.3"
|
|
30
|
+
},
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md"
|
|
40
|
+
]
|
|
41
|
+
}
|