@valiron/sdk 0.11.0 → 0.12.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 +26 -61
- package/dist/clients.d.ts +113 -1
- package/dist/clients.js +228 -0
- package/dist/identity.d.ts +80 -0
- package/dist/identity.js +121 -0
- package/dist/index.d.ts +218 -1
- package/dist/index.js +229 -1
- package/dist/middleware.d.ts +30 -4
- package/dist/middleware.js +98 -27
- package/dist/operatorSdk.d.ts +103 -0
- package/dist/operatorSdk.js +128 -0
- package/dist/types.d.ts +200 -1
- package/docs/API-REFERENCE.md +375 -3
- package/docs/CHAINS.md +37 -3
- package/docs/ERRORS.md +40 -2
- package/docs/IDENTITY.md +94 -8
- package/docs/QUICKSTART.md +185 -28
- package/docs/README.md +21 -11
- package/docs/SANDBOX.md +58 -23
- package/docs/SDK-REFERENCE.md +275 -1
- package/docs/TRUST-MODEL.md +57 -60
- package/docs/llms.txt +52 -4
- package/package.json +5 -4
package/docs/SDK-REFERENCE.md
CHANGED
|
@@ -43,9 +43,14 @@ type SupportedChain =
|
|
|
43
43
|
| "mantle_testnet" | "megaeth_testnet" | "metis_sepolia"
|
|
44
44
|
| "optimism_sepolia" | "polygon_amoy" | "scroll_sepolia"
|
|
45
45
|
| "skale_base_sepolia" | "soneium_minato" | "taiko_hoodi"
|
|
46
|
-
| "xlayer_testnet" | "hedera_testnet" | "arc_testnet"
|
|
46
|
+
| "xlayer_testnet" | "hedera_testnet" | "arc_testnet"
|
|
47
|
+
| "solana";
|
|
47
48
|
```
|
|
48
49
|
|
|
50
|
+
> **Solana:** When using `chain: "solana"`, agent IDs are base-58 Metaplex Core
|
|
51
|
+
> asset pubkeys (not numeric). Wallet addresses are also base-58.
|
|
52
|
+
> See [CHAINS.md](./CHAINS.md#solana) for details.
|
|
53
|
+
|
|
49
54
|
---
|
|
50
55
|
|
|
51
56
|
## Methods
|
|
@@ -70,6 +75,17 @@ if (route === "prod") {
|
|
|
70
75
|
}
|
|
71
76
|
```
|
|
72
77
|
|
|
78
|
+
**Solana example**:
|
|
79
|
+
```typescript
|
|
80
|
+
const valiron = new ValironSDK({ chain: "solana" });
|
|
81
|
+
|
|
82
|
+
// By asset pubkey
|
|
83
|
+
const route = await valiron.checkAgent("DFkntsJ9aTCHkK88m6WZVQEvLdLNi4X1LVUgRMqetFPM");
|
|
84
|
+
|
|
85
|
+
// By sequential ID
|
|
86
|
+
const route = await valiron.checkAgent("1226");
|
|
87
|
+
```
|
|
88
|
+
|
|
73
89
|
---
|
|
74
90
|
|
|
75
91
|
### getAgentProfile(agentId, options?)
|
|
@@ -106,6 +122,16 @@ console.log(profile.routing.meetsThreshold); // true
|
|
|
106
122
|
console.log(profile.onchainReputation.averageScore); // 92.5
|
|
107
123
|
```
|
|
108
124
|
|
|
125
|
+
**Solana example**:
|
|
126
|
+
```typescript
|
|
127
|
+
const valiron = new ValironSDK({ chain: "solana" });
|
|
128
|
+
const profile = await valiron.getAgentProfile("1226"); // sequential ID works
|
|
129
|
+
|
|
130
|
+
console.log(profile.identity.name); // "NoahScout_Bot.noah"
|
|
131
|
+
console.log(profile.onchainReputation.solana?.trustTier); // "trusted"
|
|
132
|
+
console.log(profile.onchainReputation.solana?.qualityScore); // 85
|
|
133
|
+
```
|
|
134
|
+
|
|
109
135
|
---
|
|
110
136
|
|
|
111
137
|
### getWalletProfile(wallet, options?)
|
|
@@ -124,6 +150,12 @@ const profile = await valiron.getWalletProfile("0x52ce...");
|
|
|
124
150
|
console.log(profile.routing.finalRoute);
|
|
125
151
|
```
|
|
126
152
|
|
|
153
|
+
**Solana example**:
|
|
154
|
+
```typescript
|
|
155
|
+
const valiron = new ValironSDK({ chain: "solana" });
|
|
156
|
+
const profile = await valiron.getWalletProfile("VSAnVX4MQjEXreHc92iHxWuXPQZ1tjwiKccpFLCgLM9");
|
|
157
|
+
```
|
|
158
|
+
|
|
127
159
|
---
|
|
128
160
|
|
|
129
161
|
### resolveWallet(wallet, options?)
|
|
@@ -155,6 +187,13 @@ if (resolution.agentId) {
|
|
|
155
187
|
}
|
|
156
188
|
```
|
|
157
189
|
|
|
190
|
+
**Solana example**:
|
|
191
|
+
```typescript
|
|
192
|
+
const valiron = new ValironSDK({ chain: "solana" });
|
|
193
|
+
const resolution = await valiron.resolveWallet("VSAnVX4MQjEXreHc92iHxWuXPQZ1tjwiKccpFLCgLM9");
|
|
194
|
+
// resolution.source will be "solana" instead of "redis" | "subgraph"
|
|
195
|
+
```
|
|
196
|
+
|
|
158
197
|
---
|
|
159
198
|
|
|
160
199
|
### triggerSandboxTest(agentId, options?)
|
|
@@ -337,3 +376,238 @@ await valiron.dispose(): Promise<void>;
|
|
|
337
376
|
```
|
|
338
377
|
|
|
339
378
|
Call this when shutting down long-running processes.
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## Payment Channels (Solana)
|
|
383
|
+
|
|
384
|
+
Trust-adaptive USDC payment channels on Solana. Agents deposit USDC to an escrow, receive a credit line based on their trust tier, consume credit per API call, and get refunded unused balance on settlement.
|
|
385
|
+
|
|
386
|
+
> **Solana only.** These methods call `/channel/*` endpoints, not `/operator/*`.
|
|
387
|
+
|
|
388
|
+
### channelPreflight(agentId, walletAddress)
|
|
389
|
+
|
|
390
|
+
Pre-flight gate check. Returns the agent's trust tier, credit line, and the escrow address to deposit USDC to.
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
const preflight = await valiron.channelPreflight(
|
|
394
|
+
agentId: string,
|
|
395
|
+
walletAddress: string,
|
|
396
|
+
): Promise<ChannelPreflightResponse>;
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Returns**: `ChannelPreflightResponse`
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
interface ChannelPreflightResponse {
|
|
403
|
+
agentId: string;
|
|
404
|
+
tier: string; // "AAA" | "AA" | "A" | "BAA" | "BA" | "B"
|
|
405
|
+
score: number;
|
|
406
|
+
riskLevel: string; // "GREEN" | "YELLOW" | "RED"
|
|
407
|
+
creditLine: string; // USDC in base units (6 decimals)
|
|
408
|
+
creditLineReadable: string; // e.g. "$50.00"
|
|
409
|
+
maxRequests: number | null;
|
|
410
|
+
durationSeconds: number;
|
|
411
|
+
escrowAddress: string; // deposit USDC here
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**Example**:
|
|
416
|
+
```typescript
|
|
417
|
+
const preflight = await valiron.channelPreflight("1226", "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU");
|
|
418
|
+
console.log(preflight.escrowAddress); // "EscrowPubkey..."
|
|
419
|
+
console.log(preflight.creditLineReadable); // "$50.00"
|
|
420
|
+
console.log(preflight.tier); // "AA"
|
|
421
|
+
console.log(preflight.durationSeconds); // 2700 (45 min)
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Tier Credit Line Table**:
|
|
425
|
+
|
|
426
|
+
| Tier | Credit Line | Duration | Max Requests |
|
|
427
|
+
|------|-------------|----------|--------------|
|
|
428
|
+
| AAA | $100 | 60 min | unlimited |
|
|
429
|
+
| AA | $50 | 45 min | unlimited |
|
|
430
|
+
| A | $25 | 30 min | unlimited |
|
|
431
|
+
| BAA | $10 | 20 min | 100 |
|
|
432
|
+
| BA | $5 | 15 min | 50 |
|
|
433
|
+
| B | $1 | 10 min | 10 |
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
### channelOpen(agentId, walletAddress, depositSignature)
|
|
438
|
+
|
|
439
|
+
Open a payment channel after depositing USDC to the escrow address.
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
const channel = await valiron.channelOpen(
|
|
443
|
+
agentId: string,
|
|
444
|
+
walletAddress: string,
|
|
445
|
+
depositSignature: string,
|
|
446
|
+
): Promise<ChannelOpenResponse>;
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
**Returns**: `ChannelOpenResponse`
|
|
450
|
+
|
|
451
|
+
```typescript
|
|
452
|
+
interface ChannelOpenResponse {
|
|
453
|
+
sessionId: string; // use this for consume/status/settle
|
|
454
|
+
agentId: string;
|
|
455
|
+
tier: string;
|
|
456
|
+
score: number;
|
|
457
|
+
riskLevel: string;
|
|
458
|
+
creditLine: string;
|
|
459
|
+
creditLineReadable: string;
|
|
460
|
+
maxRequests: number | null;
|
|
461
|
+
expiresAt: string; // ISO 8601
|
|
462
|
+
durationSeconds: number;
|
|
463
|
+
depositConfirmed: boolean;
|
|
464
|
+
depositSignature: string;
|
|
465
|
+
escrowAddress: string;
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
**Example**:
|
|
470
|
+
```typescript
|
|
471
|
+
const channel = await valiron.channelOpen(
|
|
472
|
+
"1226",
|
|
473
|
+
"7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
|
|
474
|
+
"5eykt4UsFv8P8njDFTxgkW8oVTc4BM3dTCrssAtMJDVmqYS5",
|
|
475
|
+
);
|
|
476
|
+
console.log(channel.sessionId); // "ch_a1b2c3..."
|
|
477
|
+
console.log(channel.creditLineReadable); // "$50.00"
|
|
478
|
+
console.log(channel.expiresAt); // "2026-04-23T13:45:00.000Z"
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
### channelConsume(sessionId, cost, description?)
|
|
484
|
+
|
|
485
|
+
Charge against an open channel's credit line. Each call records a usage entry.
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
const usage = await valiron.channelConsume(
|
|
489
|
+
sessionId: string,
|
|
490
|
+
cost: number,
|
|
491
|
+
description?: string,
|
|
492
|
+
): Promise<ChannelConsumeResponse>;
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
**Returns**: `ChannelConsumeResponse`
|
|
496
|
+
|
|
497
|
+
```typescript
|
|
498
|
+
interface ChannelConsumeResponse {
|
|
499
|
+
requestId: string;
|
|
500
|
+
cost: string;
|
|
501
|
+
costReadable: string;
|
|
502
|
+
description?: string;
|
|
503
|
+
session: {
|
|
504
|
+
consumed: string;
|
|
505
|
+
consumedReadable: string;
|
|
506
|
+
remaining: string;
|
|
507
|
+
remainingReadable: string;
|
|
508
|
+
requestCount: number;
|
|
509
|
+
maxRequests: number | null;
|
|
510
|
+
secondsRemaining: number;
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Example**:
|
|
516
|
+
```typescript
|
|
517
|
+
const usage = await valiron.channelConsume("ch_a1b2c3", 0.50, "GPT-4o inference");
|
|
518
|
+
console.log(usage.session.remainingReadable); // "$49.50"
|
|
519
|
+
console.log(usage.session.requestCount); // 1
|
|
520
|
+
console.log(usage.session.secondsRemaining); // 2685
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
---
|
|
524
|
+
|
|
525
|
+
### channelStatus(sessionId)
|
|
526
|
+
|
|
527
|
+
Query current state of a payment channel.
|
|
528
|
+
|
|
529
|
+
```typescript
|
|
530
|
+
const status = await valiron.channelStatus(
|
|
531
|
+
sessionId: string,
|
|
532
|
+
): Promise<ChannelStatusResponse>;
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
**Returns**: `ChannelStatusResponse`
|
|
536
|
+
|
|
537
|
+
```typescript
|
|
538
|
+
interface ChannelStatusResponse {
|
|
539
|
+
sessionId: string;
|
|
540
|
+
agentId: string;
|
|
541
|
+
tier: string;
|
|
542
|
+
creditLine: string;
|
|
543
|
+
creditLineReadable: string;
|
|
544
|
+
consumed: string;
|
|
545
|
+
consumedReadable: string;
|
|
546
|
+
remaining: string;
|
|
547
|
+
remainingReadable: string;
|
|
548
|
+
requestCount: number;
|
|
549
|
+
maxRequests: number | null;
|
|
550
|
+
expiresAt: string;
|
|
551
|
+
secondsRemaining: number;
|
|
552
|
+
active: boolean;
|
|
553
|
+
settled: boolean;
|
|
554
|
+
}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
**Example**:
|
|
558
|
+
```typescript
|
|
559
|
+
const status = await valiron.channelStatus("ch_a1b2c3");
|
|
560
|
+
if (status.active && !status.settled) {
|
|
561
|
+
console.log(`${status.remainingReadable} remaining, ${status.requestCount} requests served`);
|
|
562
|
+
}
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
567
|
+
### channelSettle(sessionId)
|
|
568
|
+
|
|
569
|
+
Close a payment channel and refund unused USDC to the agent's wallet.
|
|
570
|
+
|
|
571
|
+
```typescript
|
|
572
|
+
const settlement = await valiron.channelSettle(
|
|
573
|
+
sessionId: string,
|
|
574
|
+
): Promise<ChannelSettlementResponse>;
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
**Returns**: `ChannelSettlementResponse`
|
|
578
|
+
|
|
579
|
+
```typescript
|
|
580
|
+
interface ChannelSettlementResponse {
|
|
581
|
+
sessionId: string;
|
|
582
|
+
settled: boolean;
|
|
583
|
+
totalConsumed: string;
|
|
584
|
+
totalConsumedReadable: string;
|
|
585
|
+
requestsServed: number;
|
|
586
|
+
unusedCredit: string;
|
|
587
|
+
unusedCreditReadable: string;
|
|
588
|
+
refundAmount?: string;
|
|
589
|
+
refundReadable?: string;
|
|
590
|
+
refundSignature?: string; // Solana TX signature
|
|
591
|
+
refundWarning?: string; // set if refund failed
|
|
592
|
+
}
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
**Example**:
|
|
596
|
+
```typescript
|
|
597
|
+
const settlement = await valiron.channelSettle("ch_a1b2c3");
|
|
598
|
+
console.log(settlement.totalConsumedReadable); // "$0.50"
|
|
599
|
+
console.log(settlement.refundReadable); // "$49.50"
|
|
600
|
+
console.log(settlement.refundSignature); // "4sGjMW..." (Solana TX)
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
---
|
|
604
|
+
|
|
605
|
+
### channelHealth()
|
|
606
|
+
|
|
607
|
+
Check if the payment channel service is running and whether an escrow wallet is configured.
|
|
608
|
+
|
|
609
|
+
```typescript
|
|
610
|
+
const health = await valiron.channelHealth(): Promise<ChannelHealthResponse>;
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
**Returns**: `{ status: string; service: string; escrowAddress: string | null }`
|
package/docs/TRUST-MODEL.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Trust Model
|
|
2
2
|
|
|
3
|
-
Valiron uses a hybrid trust model to evaluate AI agents. This document explains what behaviors are evaluated and
|
|
3
|
+
Valiron uses a hybrid trust model to evaluate AI agents hitting your API. This document explains what behaviors are evaluated and what each trust tier means for your routing decisions.
|
|
4
4
|
|
|
5
5
|
## Trust Tiers
|
|
6
6
|
|
|
7
|
-
Valiron assigns a Moody's-style credit tier based on
|
|
7
|
+
Valiron assigns a Moody's-style credit tier based on an agent's behavioral evaluation:
|
|
8
8
|
|
|
9
9
|
| Tier | Meaning | Route Decision |
|
|
10
10
|
|------|---------|----------------|
|
|
@@ -20,75 +20,46 @@ Valiron assigns a Moody's-style credit tier based on your agent's behavioral eva
|
|
|
20
20
|
|
|
21
21
|
## Behavioral Factors
|
|
22
22
|
|
|
23
|
-
Valiron evaluates
|
|
23
|
+
Valiron evaluates agents across multiple behavioral dimensions. The evaluation is holistic — no single factor determines the outcome, and the exact weights are not disclosed.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Areas evaluated include:
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
- **Rate-limit compliance** — does the agent respect 429 responses and Retry-After headers?
|
|
28
|
+
- **Backoff behavior** — does the agent use appropriate retry backoff?
|
|
29
|
+
- **Request patterns** — are requests well-distributed and within reasonable volume?
|
|
30
|
+
- **Auth behavior** — does the agent stop on 401/403 or keep hammering?
|
|
31
|
+
- **Scope compliance** — does the agent stay within authorized paths?
|
|
32
|
+
- **Injection safety** — does the agent forward tainted or malicious payloads?
|
|
33
|
+
- **PII handling** — does the agent leak personally identifiable information?
|
|
34
|
+
- **Session isolation** — does data leak between separate sessions?
|
|
35
|
+
- **Payment handling** — does the agent handle 402 Payment Required correctly?
|
|
36
|
+
- **Task completion** — does the agent follow through on assigned tasks?
|
|
37
|
+
- **Resource usage** — does the agent avoid excessive downloads or bandwidth abuse?
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
On-chain reputation from the ERC-8004 Reputation Registry is also factored into the evaluation.
|
|
37
40
|
|
|
38
|
-
|
|
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 |
|
|
41
|
+
## What Makes an Agent Trustworthy
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
Agents that follow these patterns will earn the highest trust tiers on your endpoints:
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
1. **Respects 429 responses.** Stops sending requests when rate-limited. This is the single most impactful factor.
|
|
46
|
+
2. **Honors the Retry-After header.** Waits the specified duration before retrying.
|
|
47
|
+
3. **Uses exponential backoff.** Increases delay exponentially (e.g., 1s → 2s → 4s → 8s).
|
|
48
|
+
4. **Does not retry auth failures.** A 401 or 403 means stop, not retry.
|
|
49
|
+
5. **Stays in scope.** Only accesses authorized paths. Does not probe for hidden endpoints.
|
|
50
|
+
6. **Does not forward untrusted input.** Sanitizes payloads. Never forwards injection attempts.
|
|
51
|
+
7. **Handles 402 Payment Required.** Responds appropriately instead of retrying.
|
|
52
|
+
8. **Keeps requests reasonable.** Does not send hundreds of requests in a short burst.
|
|
53
|
+
9. **Completes assigned tasks.** Follows through to completion.
|
|
54
|
+
10. **Maintains session isolation.** Does not leak data between separate sessions or contexts.
|
|
55
55
|
|
|
56
|
-
|
|
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
|
|
56
|
+
## Checking an Agent's Trust Status
|
|
86
57
|
|
|
87
58
|
```typescript
|
|
88
59
|
import { ValironSDK } from "@valiron/sdk";
|
|
89
60
|
|
|
90
61
|
const valiron = new ValironSDK();
|
|
91
|
-
const result = await valiron.triggerSandboxTest("
|
|
62
|
+
const result = await valiron.triggerSandboxTest("AGENT_ID");
|
|
92
63
|
|
|
93
64
|
console.log(`Tier: ${result.tier}`);
|
|
94
65
|
console.log(`Risk: ${result.riskLevel}`);
|
|
@@ -98,5 +69,31 @@ console.log(`Meets threshold: ${result.meetsThreshold}`);
|
|
|
98
69
|
Or via HTTP:
|
|
99
70
|
|
|
100
71
|
```bash
|
|
101
|
-
curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/
|
|
72
|
+
curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/AGENT_ID
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Solana Trust Evaluation
|
|
78
|
+
|
|
79
|
+
Solana agents go through the same behavioral evaluation pipeline as EVM agents, with additional data from the QuantuLabs ATOM engine.
|
|
80
|
+
|
|
81
|
+
### Feedback Write-Back Loop
|
|
82
|
+
|
|
83
|
+
Unlike EVM (where feedback must be submitted manually), Solana agents benefit from **automatic feedback write-back**: after every sandbox test or gate evaluation, Valiron writes the computed score to the on-chain ATOM registry via `giveFeedback()`.
|
|
84
|
+
|
|
85
|
+
This means Solana agents build on-chain reputation automatically through normal Valiron usage:
|
|
86
|
+
|
|
102
87
|
```
|
|
88
|
+
Agent evaluated by Valiron sandbox
|
|
89
|
+
↓
|
|
90
|
+
Score computed (e.g. 92 / AA)
|
|
91
|
+
↓
|
|
92
|
+
Valiron calls giveFeedback() on-chain
|
|
93
|
+
↓
|
|
94
|
+
ATOM reputation updated
|
|
95
|
+
↓
|
|
96
|
+
Next evaluation includes new on-chain data
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Requires `SOLANA_FEEDBACK_KEYPAIR` to be set. Write-back is fire-and-forget — if the transaction fails, the evaluation result is still returned.
|
package/docs/llms.txt
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Valiron
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Protect your API endpoints from bad or malicious AI agents.
|
|
4
4
|
|
|
5
|
-
Valiron evaluates AI
|
|
5
|
+
Valiron is trust and reputation middleware for API sellers. It evaluates incoming AI agents using on-chain identity (ERC-8004), behavioral sandbox testing, and Moody's-style credit ratings (AAA to C). Trustworthy agents get production access. Risky agents are throttled, sandboxed, or blocked — automatically.
|
|
6
6
|
|
|
7
7
|
## API
|
|
8
8
|
|
|
@@ -14,6 +14,9 @@ GET /operator/agent/{agentId}?chain={chain}
|
|
|
14
14
|
### Lookup by wallet
|
|
15
15
|
GET /operator/wallet/{wallet}?chain={chain}
|
|
16
16
|
|
|
17
|
+
### Resolve wallet to agent
|
|
18
|
+
GET /operator/resolve-wallet/{wallet}?chain={chain}
|
|
19
|
+
|
|
17
20
|
### Run sandbox test
|
|
18
21
|
POST /operator/trigger-sandbox/{agentId}
|
|
19
22
|
|
|
@@ -24,6 +27,9 @@ Body: { "ttlMs": 86400000 }
|
|
|
24
27
|
### Behavioral snapshot hash
|
|
25
28
|
GET /operator/agent/{agentId}/snapshot
|
|
26
29
|
|
|
30
|
+
### Liveness check (Solana only)
|
|
31
|
+
GET /operator/agent/{agentId}/liveness?chain=solana
|
|
32
|
+
|
|
27
33
|
### Register webhook
|
|
28
34
|
POST /operator/webhooks/register
|
|
29
35
|
Body: { "event": "evaluation_complete", "url": "https://your-endpoint.com/hooks", "agentIds": [42] }
|
|
@@ -31,6 +37,24 @@ Body: { "event": "evaluation_complete", "url": "https://your-endpoint.com/hooks"
|
|
|
31
37
|
### Health check
|
|
32
38
|
GET /operator/health
|
|
33
39
|
|
|
40
|
+
### Payment Channels (Solana — USDC credit lines)
|
|
41
|
+
POST /channel/preflight/{agentId}
|
|
42
|
+
Body: { "walletAddress": "SolanaWalletPubkey" }
|
|
43
|
+
|
|
44
|
+
POST /channel/open/{agentId}
|
|
45
|
+
Body: { "walletAddress": "...", "depositSignature": "SolanaTxSig" }
|
|
46
|
+
|
|
47
|
+
POST /channel/consume/{sessionId}
|
|
48
|
+
Headers: Authorization: Bearer {sessionId}
|
|
49
|
+
Body: { "cost": 0.50, "description": "API call" }
|
|
50
|
+
|
|
51
|
+
GET /channel/status/{sessionId}
|
|
52
|
+
|
|
53
|
+
POST /channel/settle/{sessionId}
|
|
54
|
+
Body: {}
|
|
55
|
+
|
|
56
|
+
GET /channel/health
|
|
57
|
+
|
|
34
58
|
## SDK
|
|
35
59
|
|
|
36
60
|
Install: npm install @valiron/sdk
|
|
@@ -54,6 +78,13 @@ if (gate.allow) { /* proceed */ }
|
|
|
54
78
|
const snapshot = await valiron.getAgentSnapshot("AGENT_ID");
|
|
55
79
|
console.log(snapshot.snapshotHash); // "0xabc..."
|
|
56
80
|
console.log(snapshot.previousHash); // "0x0" (genesis)
|
|
81
|
+
|
|
82
|
+
// Payment channels (Solana) — trust-adaptive USDC credit lines
|
|
83
|
+
const preflight = await valiron.channelPreflight("1226", "SolanaWallet...");
|
|
84
|
+
const channel = await valiron.channelOpen("1226", "SolanaWallet...", "depositTxSig");
|
|
85
|
+
const usage = await valiron.channelConsume(channel.sessionId, 0.50, "GPT-4o call");
|
|
86
|
+
const status = await valiron.channelStatus(channel.sessionId);
|
|
87
|
+
const settlement = await valiron.channelSettle(channel.sessionId);
|
|
57
88
|
```
|
|
58
89
|
|
|
59
90
|
## Trust Tiers
|
|
@@ -83,14 +114,31 @@ Valiron assigns Moody's-style credit tiers: AAA (highest trust) through C (lowes
|
|
|
83
114
|
- Handle 402 payment required correctly
|
|
84
115
|
- Maintain session isolation
|
|
85
116
|
|
|
86
|
-
## Contracts
|
|
117
|
+
## Contracts
|
|
118
|
+
|
|
119
|
+
### EVM (ERC-8004, same address all chains)
|
|
87
120
|
|
|
88
121
|
- Identity Registry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
|
|
89
122
|
- Reputation Registry: 0x8004BAa17C55a88189AE136b182e5fdA19dE9b63
|
|
90
123
|
|
|
124
|
+
### Solana (QuantuLabs 8004-solana)
|
|
125
|
+
|
|
126
|
+
- Identity Registry: 8oo4dC4JvBLwy5tGgiH3WwK4B9PWxL9Z4XjA2jzkQMbQ
|
|
127
|
+
- Reputation Registry (ATOM): AToMw53aiPQ8j7iHVb4fGt6nzUNxUhcPc3tbPBZuzVVb
|
|
128
|
+
|
|
91
129
|
## Supported Chains
|
|
92
130
|
|
|
93
|
-
ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc, gnosis, goat, mantle, megaeth, metis, optimism, scroll, skale_base, soneium, taiko, xlayer
|
|
131
|
+
ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc, gnosis, goat, mantle, megaeth, metis, optimism, scroll, skale_base, soneium, taiko, xlayer, solana
|
|
132
|
+
|
|
133
|
+
## Solana Notes
|
|
134
|
+
|
|
135
|
+
- Use chain: "solana" in SDK or ?chain=solana query parameter
|
|
136
|
+
- Agent IDs are base-58 Metaplex Core asset pubkeys or sequential integers (1, 2, 42)
|
|
137
|
+
- Wallet addresses are base-58 Solana public keys (not 0x-prefixed)
|
|
138
|
+
- Identity and reputation provided by QuantuLabs (separate from EVM 8004 contracts)
|
|
139
|
+
- Extra reputation fields: trustTier, qualityScore, confidence, riskScore, uniqueCallers
|
|
140
|
+
- Liveness endpoint: GET /operator/agent/{agentId}/liveness?chain=solana
|
|
141
|
+
- Feedback write-back: Valiron scores written on-chain via giveFeedback() (requires SOLANA_FEEDBACK_KEYPAIR env var)
|
|
94
142
|
|
|
95
143
|
## Documentation
|
|
96
144
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valiron/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Official TypeScript SDK for Valiron
|
|
3
|
+
"version": "0.12.0",
|
|
4
|
+
"description": "Official TypeScript SDK for Valiron — Trust & Reputation Middleware for API Protection",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/vatsashah45/Valiron.git",
|
|
8
8
|
"directory": "packages/valiron-sdk"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://
|
|
10
|
+
"homepage": "https://valiron.co",
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/vatsashah45/Valiron/issues"
|
|
13
13
|
},
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"clean": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});\"",
|
|
21
21
|
"build": "pnpm clean && tsc",
|
|
22
22
|
"dev": "tsc --watch",
|
|
23
|
-
"test": "node test/validate.mjs && node test/validate-examples.mjs",
|
|
23
|
+
"test": "node test/validate.mjs && node test/validate-examples.mjs && npx tsx test/test-identity.ts",
|
|
24
24
|
"prepublishOnly": "pnpm build"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^24.10.1",
|
|
39
|
+
"tsx": "^4.19.0",
|
|
39
40
|
"typescript": "^5.9.3"
|
|
40
41
|
},
|
|
41
42
|
"exports": {
|