@valiron/sdk 0.12.0 → 1.0.1

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.
@@ -216,13 +216,7 @@ interface SandboxResult {
216
216
  tier: MoodysRating; // "AAA" | "AA" | "A" | "BAA" | "BA" | "B" | "CAA" | "CA" | "C"
217
217
  riskLevel: "GREEN" | "YELLOW" | "RED";
218
218
  meetsThreshold: boolean;
219
- testSummary: {
220
- totalRequests: number;
221
- successCount: number;
222
- rateLimitCount: number;
223
- errorCount: number;
224
- avgLatencyMs: number;
225
- };
219
+ testSummary: object; // Opaque test metrics (structure is proprietary)
226
220
  chain: ChainContext;
227
221
  message: string;
228
222
  }
@@ -236,6 +230,41 @@ console.log(result.riskLevel); // "GREEN"
236
230
  console.log(result.meetsThreshold); // true
237
231
  ```
238
232
 
233
+ > **Auto-sandbox:** The middleware (`createValironGate`, `valironFastifyPlugin`, `createValironNextMiddleware`, `valironGateCheck`) automatically triggers `triggerSandboxTest()` in the background for new on-chain agents (those with `totalFeedback === 0`). The agent receives a 403 with `{ error: "Agent pending evaluation", retryAfterMs: 30000 }` while evaluation runs. No manual trigger is needed.
234
+
235
+ ---
236
+
237
+ ### triggerKeyAgentSandbox(agentAddress)
238
+
239
+ Run sandbox tests against a key-based (Web2) agent and compute a trust evaluation. Key agents don't have on-chain endpoints, so this uses the `sandbox_relay` mode internally.
240
+
241
+ ```typescript
242
+ const result = await valiron.triggerKeyAgentSandbox(agentAddress: string): Promise<KeyAgentSandboxResult>;
243
+ ```
244
+
245
+ **Returns**: `KeyAgentSandboxResult`
246
+
247
+ ```typescript
248
+ interface KeyAgentSandboxResult {
249
+ ok: boolean;
250
+ agentAddress: string;
251
+ valironScore: number;
252
+ tier: MoodysRating;
253
+ riskLevel: "GREEN" | "YELLOW" | "RED";
254
+ message: string;
255
+ }
256
+ ```
257
+
258
+ **Example**:
259
+ ```typescript
260
+ const result = await valiron.triggerKeyAgentSandbox("0x1234...abcd");
261
+ console.log(result.tier); // "A"
262
+ console.log(result.riskLevel); // "GREEN"
263
+ console.log(result.valironScore); // 85
264
+ ```
265
+
266
+ > **Auto-sandbox:** The middleware automatically triggers `triggerKeyAgentSandbox()` in the background for new key agents (those with `verified === true` but `score === null`). The agent receives a 403 with `{ error: "Agent pending evaluation", retryAfterMs: 30000 }` while evaluation runs.
267
+
239
268
  ---
240
269
 
241
270
  ### gate(agentId, options?)
@@ -321,22 +350,30 @@ console.log(snapshot.interactionCount); // 15
321
350
 
322
351
  Express-compatible middleware factory. Automatically gates requests based on agent trust.
323
352
 
353
+ Uses the public `getAgentProfile()` endpoint under the hood (not the protected `gate()` endpoint), so it works from any server context — no agent challenge-response auth required.
354
+
355
+ **Express 4 safe**: The returned middleware wraps the async handler with `Promise.resolve(handler(...)).catch(next)` so async rejections are properly forwarded to Express's error handler. This prevents race conditions when chained with other async middleware (e.g. x402's `paymentMiddleware`).
356
+
324
357
  ```typescript
325
358
  import { ValironSDK, createValironGate } from "@valiron/sdk";
326
359
 
327
360
  const gate = createValironGate(config: {
328
361
  sdk: ValironSDK;
329
- ttlMs?: number; // default: 86400000
330
- extractAgentId?: (req: Request) => string | undefined;
362
+ minScore?: number; // default: 65
363
+ cacheTtlMs?: number; // default: 30000 (30s client-side cache)
364
+ extractAgentId?: (req: Request) => string | null;
365
+ extractAgentAddress?: (req: Request) => string | null;
331
366
  onAllow?: (req: Request, result: GateResult) => void;
332
367
  onDeny?: (req: Request, res: Response, result: GateResult) => void;
333
368
  });
334
369
  ```
335
370
 
336
371
  **Default behavior**:
337
- - Extracts agent ID from `x-agent-id` request header
372
+ - Extracts agent ID from `x-agent-id` header (on-chain) or `x-agent-address` header (key-based)
373
+ - Returns 401 if no agent identity is found (with link to identity skill)
338
374
  - Returns 403 if agent is denied
339
- - Returns 400 if no agent ID is found
375
+ - Returns 503 if the trust gate is unreachable (fail-closed)
376
+ - Caches profiles in memory for 30s to survive x402 retry flows
340
377
 
341
378
  **Example**:
342
379
  ```typescript
@@ -345,10 +382,11 @@ const valiron = new ValironSDK({ chain: "monad" });
345
382
  // Basic gate
346
383
  app.use("/api/paid", createValironGate({ sdk: valiron }));
347
384
 
348
- // Custom TTL
385
+ // Custom threshold + longer cache
349
386
  app.use("/api/premium", createValironGate({
350
387
  sdk: valiron,
351
- ttlMs: 3600_000,
388
+ minScore: 85,
389
+ cacheTtlMs: 60_000, // 60s
352
390
  }));
353
391
 
354
392
  // Custom agent ID extraction
@@ -379,235 +417,332 @@ Call this when shutting down long-running processes.
379
417
 
380
418
  ---
381
419
 
382
- ## Payment Channels (Solana)
420
+ ## Proxy Gateway (Pro)
383
421
 
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.
422
+ Forward requests through Valiron's edge proxy with automatic trust gating, logging, and SSRF protection.
385
423
 
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.
424
+ ### proxy(request)
391
425
 
392
426
  ```typescript
393
- const preflight = await valiron.channelPreflight(
394
- agentId: string,
395
- walletAddress: string,
396
- ): Promise<ChannelPreflightResponse>;
427
+ const result = await valiron.proxy(request: ProxyRequest): Promise<ProxyResponse>;
397
428
  ```
398
429
 
399
- **Returns**: `ChannelPreflightResponse`
430
+ #### ProxyRequest
400
431
 
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
- ```
432
+ | Field | Type | Required | Description |
433
+ |-------|------|----------|-------------|
434
+ | `agentId` | string | yes | Agent to gate |
435
+ | `targetUrl` | string | yes | Your origin URL to forward to |
436
+ | `method` | string | no | HTTP method (default: `GET`) |
437
+ | `headers` | Record<string, string> | no | Headers to forward |
438
+ | `body` | string | no | Request body |
439
+
440
+ #### ProxyResponse
441
+
442
+ | Field | Type | Description |
443
+ |-------|------|-------------|
444
+ | `statusCode` | number | HTTP status from your origin |
445
+ | `responseHeaders` | Record<string, string> | Response headers |
446
+ | `responseBody` | string | Response body |
447
+ | `responseMs` | number | Round-trip latency |
448
+ | `costCharged` | string | USD cost charged |
449
+ | `route` | string | Route decision applied |
450
+ | `tierResolved` | string | Trust tier used |
414
451
 
415
452
  **Example**:
416
453
  ```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)
454
+ const result = await valiron.proxy({
455
+ agentId: "25459",
456
+ targetUrl: "https://your-api.com/data",
457
+ method: "POST",
458
+ headers: { "Content-Type": "application/json" },
459
+ body: JSON.stringify({ query: "example" }),
460
+ });
422
461
  ```
423
462
 
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 |
463
+ > **SSRF Protection:** The proxy blocks requests to private IPs (10.x, 172.16-31.x, 192.168.x), localhost, link-local addresses, and cloud metadata endpoints (169.254.169.254).
434
464
 
435
465
  ---
436
466
 
437
- ### channelOpen(agentId, walletAddress, depositSignature)
467
+ ## Key-Based Agents
438
468
 
439
- Open a payment channel after depositing USDC to the escrow address.
469
+ For Web2 agents that don't have on-chain identities, Valiron supports key-based authentication using EIP-191 challenge-response.
440
470
 
441
- ```typescript
442
- const channel = await valiron.channelOpen(
443
- agentId: string,
444
- walletAddress: string,
445
- depositSignature: string,
446
- ): Promise<ChannelOpenResponse>;
447
- ```
471
+ **How it works:**
472
+ 1. Agent sends a request with `x-agent-address: 0x...` header
473
+ 2. Valiron returns a challenge nonce
474
+ 3. Agent signs the nonce with their private key
475
+ 4. Valiron verifies the signature and creates a `KeyAgentProfile`
476
+
477
+ The SDK auto-detects key-based agents from the `x-agent-address` header. No configuration needed.
478
+
479
+ ### Sandbox Evaluation for Key Agents
448
480
 
449
- **Returns**: `ChannelOpenResponse`
481
+ New key agents (verified but not yet scored) are automatically evaluated when they first hit a gated endpoint. The middleware triggers `triggerKeyAgentSandbox()` in the background and returns 403 with `retryAfterMs: 30000`. After evaluation completes, the agent receives a trust score and can access endpoints normally.
482
+
483
+ You can also trigger evaluation manually:
450
484
 
451
485
  ```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
- }
486
+ const result = await valiron.triggerKeyAgentSandbox("0x1234...abcd");
467
487
  ```
468
488
 
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"
489
+ Or via HTTP:
490
+
491
+ ```bash
492
+ curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox-key/0x1234...abcd
479
493
  ```
480
494
 
495
+ ### KeyAgentProfile
496
+
497
+ | Field | Type | Description |
498
+ |-------|------|-------------|
499
+ | `address` | string | Ethereum address |
500
+ | `isKeyAgent` | boolean | Always `true` |
501
+ | `tier` | string | Trust tier (starts at C, can improve) |
502
+ | `riskLevel` | string | GREEN / YELLOW / RED |
503
+ | `route` | string | Route decision |
504
+ | `firstSeen` | string | ISO timestamp of first interaction |
505
+ | `totalRequests` | number | Lifetime request count |
506
+
481
507
  ---
482
508
 
483
- ### channelConsume(sessionId, cost, description?)
509
+ ## World ID Methods
484
510
 
485
- Charge against an open channel's credit line. Each call records a usage entry.
511
+ Verify agent-human linkage via Worldcoin's zero-knowledge proof system.
486
512
 
487
- ```typescript
488
- const usage = await valiron.channelConsume(
489
- sessionId: string,
490
- cost: number,
491
- description?: string,
492
- ): Promise<ChannelConsumeResponse>;
493
- ```
513
+ ### verifyWorldId(agentId, proof, options?)
494
514
 
495
- **Returns**: `ChannelConsumeResponse`
515
+ Submit a World ID proof for verification.
496
516
 
497
517
  ```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
- }
518
+ const result = await valiron.verifyWorldId(agentId: string, proof: WorldIdProof, options?: {
519
+ chain?: SupportedChain;
520
+ }): Promise<WorldIdVerificationResult>;
513
521
  ```
514
522
 
515
523
  **Example**:
516
524
  ```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
525
+ const result = await valiron.verifyWorldId("25459", {
526
+ merkle_root: "0x...",
527
+ nullifier_hash: "0x...",
528
+ proof: "0x...",
529
+ signal: "0x...",
530
+ });
521
531
  ```
522
532
 
523
- ---
524
-
525
- ### channelStatus(sessionId)
533
+ ### getWorldIdStatus(agentId, options?)
526
534
 
527
- Query current state of a payment channel.
535
+ Check if an agent has a verified World ID.
528
536
 
529
537
  ```typescript
530
- const status = await valiron.channelStatus(
531
- sessionId: string,
532
- ): Promise<ChannelStatusResponse>;
538
+ const status = await valiron.getWorldIdStatus(agentId: string, options?: {
539
+ chain?: SupportedChain;
540
+ }): Promise<WorldIdStatus>;
541
+ // { verified: true, verifiedAt: "2025-01-15T...", level: "orb" }
533
542
  ```
534
543
 
535
- **Returns**: `ChannelStatusResponse`
544
+ ### getWorldIdProfile(agentId, options?)
545
+
546
+ Get full World ID profile including verification details.
536
547
 
537
548
  ```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
- }
549
+ const profile = await valiron.getWorldIdProfile(agentId: string, options?: {
550
+ chain?: SupportedChain;
551
+ }): Promise<WorldIdAgentProfile>;
555
552
  ```
556
553
 
554
+ ---
555
+
556
+ ## Telemetry
557
+
558
+ The SDK optionally collects anonymous usage metrics (gate calls, latency, error rates). Telemetry is opt-in and can be fully disabled.
559
+
560
+ ### TelemetryConfig
561
+
562
+ | Field | Type | Default | Description |
563
+ |-------|------|---------|-------------|
564
+ | `enabled` | boolean | `true` | Enable/disable telemetry |
565
+ | `sampleRate` | number | `1.0` | Fraction of events to sample (0–1) |
566
+ | `handler` | function | — | Custom event handler |
567
+
557
568
  **Example**:
558
569
  ```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
- }
570
+ const valiron = new ValironSDK({
571
+ telemetry: {
572
+ enabled: false, // Disable entirely
573
+ },
574
+ });
575
+
576
+ // Or with custom sampling and handler
577
+ const valiron = new ValironSDK({
578
+ telemetry: {
579
+ sampleRate: 0.1, // Sample 10% of events
580
+ handler: (event) => { // Custom handler
581
+ myAnalytics.track(event);
582
+ },
583
+ },
584
+ });
563
585
  ```
564
586
 
565
587
  ---
566
588
 
567
- ### channelSettle(sessionId)
589
+ ## Middleware
590
+
591
+ All middleware adapters use `getAgentProfile()` (public endpoint) rather than
592
+ `gate()` (protected endpoint), so they work from any server context without
593
+ agent challenge-response auth. Results are cached client-side (default 30s)
594
+ to survive x402's two-request payment flow and avoid cold-start failures.
595
+
596
+ ### createValironGate(config) — Express
597
+
598
+ See above for full documentation.
568
599
 
569
- Close a payment channel and refund unused USDC to the agent's wallet.
600
+ **Express 4 note**: The returned middleware uses a synchronous wrapper
601
+ (`Promise.resolve().catch(next)`) to ensure async errors are properly caught.
602
+ You do NOT need to wrap it yourself — it's safe to use directly with
603
+ `app.use()` even on Express 4.
604
+
605
+ ### valironFastifyPlugin — Fastify
570
606
 
571
607
  ```typescript
572
- const settlement = await valiron.channelSettle(
573
- sessionId: string,
574
- ): Promise<ChannelSettlementResponse>;
608
+ import { ValironSDK, valironFastifyPlugin } from "@valiron/sdk";
609
+
610
+ const valiron = new ValironSDK({ chain: "monad" });
611
+
612
+ fastify.register(valironFastifyPlugin, {
613
+ sdk: valiron,
614
+ prefix: "/api/paid",
615
+ });
575
616
  ```
576
617
 
577
- **Returns**: `ChannelSettlementResponse`
618
+ ### createValironNextMiddleware — Next.js
578
619
 
579
620
  ```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
- }
621
+ import { ValironSDK, createValironNextMiddleware } from "@valiron/sdk";
622
+
623
+ const valiron = new ValironSDK();
624
+ export default createValironNextMiddleware({
625
+ sdk: valiron,
626
+ paths: ["/api/paid"],
627
+ });
593
628
  ```
594
629
 
595
- **Example**:
630
+ ### valironGateCheck — Generic (Hono, Koa, etc.)
631
+
596
632
  ```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)
633
+ import { ValironSDK, valironGateCheck } from "@valiron/sdk";
634
+
635
+ const valiron = new ValironSDK();
636
+
637
+ app.use(async (c, next) => {
638
+ const gate = await valironGateCheck(valiron, {
639
+ agentId: c.req.header("x-agent-id") ?? null,
640
+ agentAddress: c.req.header("x-agent-address") ?? null,
641
+ });
642
+ if (!gate.allow) return c.json(gate.body, gate.status);
643
+ c.set("valiron", gate.result);
644
+ await next();
645
+ });
601
646
  ```
602
647
 
648
+ ### Client-Side Caching
649
+
650
+ All middleware adapters include a built-in in-memory cache (default TTL: 30 seconds).
651
+ This is important for payment protocols like x402 that make two requests per payment
652
+ (discover 402 → retry with payment). Without caching, the second trust check can fail
653
+ due to cold-start latency on the edge proxy.
654
+
655
+ The Express gate exposes `cacheTtlMs` to override this TTL; set it to `0` to disable
656
+ caching for that middleware instance. `createValironNextMiddleware` and
657
+ `valironGateCheck` also accept `cacheTtlMs`.
658
+
659
+ ### Middleware Error Responses
660
+
661
+ All middleware variants return consistent error responses:
662
+
663
+ | Status | When | Body |
664
+ |--------|------|------|
665
+ | 401 | No agent ID found in request | `{ error: "No agent identity provided" }` |
666
+ | 403 | Agent denied by trust gate | `{ error: "Access denied", tier, riskLevel, route }` |
667
+ | 403 | New agent pending evaluation | `{ error: "Agent pending evaluation", retryAfterMs: 30000 }` |
668
+ | 503 | Valiron service unavailable | `{ error: "Trust evaluation unavailable" }` |
669
+
670
+ > **Fail-closed:** When the Valiron service is unreachable, middleware returns 503 — it never fails open and never allows unverified agents through.
671
+
603
672
  ---
604
673
 
605
- ### channelHealth()
674
+ ## Response Types
675
+
676
+ ### GateResult
677
+
678
+ Returned by `gate()` and middleware.
679
+
680
+ | Field | Type | Description |
681
+ |-------|------|-------------|
682
+ | `allow` | boolean | Whether the agent is allowed access |
683
+ | `tier` | string | Trust tier (AAA–C) |
684
+ | `riskLevel` | string | GREEN / YELLOW / RED |
685
+ | `route` | string | `prod` / `prod_throttled` / `sandbox` / `sandbox_only` |
686
+ | `meetsThreshold` | boolean | Whether the agent meets the minimum trust threshold |
687
+ | `agentId` | string | The evaluated agent ID |
688
+ | `wallet` | string | Agent's wallet address |
689
+ | `chain` | object | Chain context |
690
+ | `sandboxRan` | boolean | Whether sandbox was executed |
691
+ | `cached` | boolean | Whether the result was served from cache |
692
+
693
+ ### AgentProfile
694
+
695
+ Returned by `getAgentProfile()`.
696
+
697
+ | Field | Type | Description |
698
+ |-------|------|-------------|
699
+ | `agentId` | string | ERC-8004 token ID |
700
+ | `identity` | object | On-chain identity (name, wallet, endpoints, trustModels) |
701
+ | `onchainReputation` | object | Feedback count, average score, Solana ATOM metrics |
702
+ | `routing` | object | `{ finalRoute, meetsThreshold }` |
703
+ | `chain` | object | `{ name, chainId }` |
704
+ | `timestamp` | string | ISO timestamp |
606
705
 
607
- Check if the payment channel service is running and whether an escrow wallet is configured.
706
+ ### Request Headers
707
+
708
+ Headers attached to proxied/gated requests:
709
+
710
+ | Header | Description |
711
+ |--------|-------------|
712
+ | `x-agent-id` | The agent's ERC-8004 token ID |
713
+ | `x-agent-address` | The agent's wallet address (key-based agents) |
714
+ | `x-valiron-tier` | Resolved trust tier |
715
+ | `x-valiron-route` | Route decision |
716
+ | `x-valiron-risk` | Risk level |
717
+
718
+ ### All Exports
608
719
 
609
720
  ```typescript
610
- const health = await valiron.channelHealth(): Promise<ChannelHealthResponse>;
721
+ import {
722
+ ValironSDK,
723
+ ValironOperator,
724
+ ValironClient,
725
+ createValironGate,
726
+ valironFastifyPlugin,
727
+ createValironNextMiddleware,
728
+ valironGateCheck,
729
+ isValidAddress,
730
+ generateChallenge,
731
+ } from "@valiron/sdk";
611
732
  ```
612
733
 
613
- **Returns**: `{ status: string; service: string; escrowAddress: string | null }`
734
+ ---
735
+
736
+ ## Plans & Limits
737
+
738
+ | Feature | Free | Pro |
739
+ |---------|------|-----|
740
+ | Gated endpoints | 3 | Unlimited |
741
+ | Sandbox tests / day | 5 | Unlimited |
742
+ | Webhooks | — | ✓ |
743
+ | Proxy gateway | — | ✓ |
744
+ | Analytics & logs | — | ✓ |
745
+ | Evaluation history | — | ✓ |
746
+ | Custom tier thresholds | — | ✓ |
747
+
748
+ Pro plan requires an operator API key (`val_op_` prefix) from the [Operator Dashboard](./DASHBOARD.md).
@@ -20,38 +20,13 @@ Valiron assigns a Moody's-style credit tier based on an agent's behavioral evalu
20
20
 
21
21
  ## Behavioral Factors
22
22
 
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
-
25
- Areas evaluated include:
26
-
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?
23
+ Valiron evaluates agents across multiple behavioral dimensions. The evaluation is holistic — no single factor determines the outcome. The specific factors evaluated and their weights are proprietary and not disclosed.
38
24
 
39
25
  On-chain reputation from the ERC-8004 Reputation Registry is also factored into the evaluation.
40
26
 
41
27
  ## What Makes an Agent Trustworthy
42
28
 
43
- Agents that follow these patterns will earn the highest trust tiers on your endpoints:
44
-
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.
29
+ Agents that demonstrate responsible API usage patterns will earn the highest trust tiers. The specific behaviors that contribute to trust scoring are proprietary. In general, agents that are well-behaved, respect API boundaries, and handle errors gracefully will score highly.
55
30
 
56
31
  ## Checking an Agent's Trust Status
57
32