@valiron/sdk 0.11.1 → 1.0.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.
@@ -2,11 +2,16 @@
2
2
 
3
3
  Base URL: `https://valiron-edge-proxy.onrender.com`
4
4
 
5
- All endpoints are under the `/operator/` path prefix.
5
+ Endpoints are organized into two groups:
6
+
7
+ - **Trust evaluation** (`/operator/agent/*`, `/operator/gate/*`, etc.) — No authentication required. Used by the SDK to evaluate agents.
8
+ - **Dashboard** (`/operator/register`, `/operator/login`, `/operator/endpoints`, etc.) — JWT-authenticated. Used by the Operator Dashboard. See [DASHBOARD.md](./DASHBOARD.md) for the UI guide.
6
9
 
7
10
  ---
8
11
 
9
- ## GET /operator/agent/:agentId
12
+ ## Trust Evaluation Endpoints
13
+
14
+ ### GET /operator/agent/:agentId
10
15
 
11
16
  Retrieve the complete trust profile for an agent.
12
17
 
@@ -126,13 +131,7 @@ Execute real-time sandbox tests against an agent and compute a trust evaluation.
126
131
  "tier": "AAA",
127
132
  "riskLevel": "GREEN",
128
133
  "meetsThreshold": true,
129
- "testSummary": {
130
- "totalRequests": 25,
131
- "successCount": 18,
132
- "rateLimitCount": 5,
133
- "errorCount": 2,
134
- "avgLatencyMs": 120
135
- },
134
+ "testSummary": {},
136
135
  "chain": {
137
136
  "name": "ethereum",
138
137
  "chainId": 1
@@ -141,6 +140,8 @@ Execute real-time sandbox tests against an agent and compute a trust evaluation.
141
140
  }
142
141
  ```
143
142
 
143
+ > **Note:** The `testSummary` object contains opaque test metrics. Its internal structure is proprietary and may change without notice.
144
+
144
145
  ---
145
146
 
146
147
  ## POST /operator/gate/:agentId
@@ -268,6 +269,10 @@ When an evaluation completes, Valiron POSTs the following to your registered URL
268
269
  {
269
270
  "event": "evaluation_complete",
270
271
  "agentId": "25459",
272
+ "tier": "AAA",
273
+ "riskLevel": "GREEN",
274
+ "route": "prod",
275
+ "meetsThreshold": true,
271
276
  "snapshotHash": "0x3a7f2b...",
272
277
  "previousHash": "0x8b2c1a...",
273
278
  "encryptedDataUri": null,
@@ -276,6 +281,210 @@ When an evaluation completes, Valiron POSTs the following to your registered URL
276
281
  }
277
282
  ```
278
283
 
284
+ #### Webhook Payload Fields
285
+
286
+ | Field | Type | Description |
287
+ |-------|------|-------------|
288
+ | `event` | string | Always `"evaluation_complete"` |
289
+ | `agentId` | string | The evaluated agent ID |
290
+ | `tier` | string | Moody's-style trust tier (AAA–C) |
291
+ | `riskLevel` | string | GREEN / YELLOW / RED |
292
+ | `route` | string | Route decision (`prod`, `prod_throttled`, `sandbox`, `sandbox_only`) |
293
+ | `meetsThreshold` | boolean | Whether the agent passed the trust gate |
294
+ | `snapshotHash` | string | Deterministic hash of the behavioral evaluation |
295
+ | `previousHash` | string | Hash from the prior evaluation |
296
+ | `encryptedDataUri` | string\|null | IPFS CID of encrypted snapshot data |
297
+ | `timestamp` | string | ISO 8601 timestamp |
298
+ | `interactionCount` | number | Total interactions in the evaluation window |
299
+
300
+ #### Webhook Limitations
301
+
302
+ - **Maximum registrations:** 1,000 per operator
303
+ - **Delivery:** Fire-and-forget — no retries on failure
304
+ - **Timeout:** 10 seconds — your endpoint must respond within 10s
305
+ - **Signatures:** Webhooks are not signed — verify via IP allowlisting or shared secrets if needed
306
+ - **Events:** Only `evaluation_complete` is currently supported
307
+
308
+ ---
309
+
310
+ ## POST /operator/proxy/:agentId (Pro)
311
+
312
+ Forward a request through Valiron's edge proxy with automatic trust gating, logging, and SSRF protection.
313
+
314
+ ### Parameters
315
+
316
+ | Parameter | Location | Type | Required | Description |
317
+ |-----------|----------|------|----------|-------------|
318
+ | `agentId` | path | string | yes | Agent to gate |
319
+
320
+ ### Request Body
321
+
322
+ ```json
323
+ {
324
+ "targetUrl": "https://your-api.com/data",
325
+ "method": "POST",
326
+ "headers": { "Content-Type": "application/json" },
327
+ "body": "{\"query\": \"example\"}"
328
+ }
329
+ ```
330
+
331
+ | Field | Type | Required | Description |
332
+ |-------|------|----------|-------------|
333
+ | `targetUrl` | string | yes | Your origin URL to forward to |
334
+ | `method` | string | no | HTTP method (default: `GET`) |
335
+ | `headers` | object | no | Headers to forward |
336
+ | `body` | string | no | Request body |
337
+
338
+ ### Response — 200 OK
339
+
340
+ ```json
341
+ {
342
+ "statusCode": 200,
343
+ "responseHeaders": {},
344
+ "responseBody": "...",
345
+ "responseMs": 145,
346
+ "costCharged": "0.0500",
347
+ "route": "prod",
348
+ "tierResolved": "AA"
349
+ }
350
+ ```
351
+
352
+ > **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).
353
+
354
+ ---
355
+
356
+ ## Key-Based Agent Endpoints
357
+
358
+ For Web2 agents that don't have on-chain identities, Valiron supports key-based authentication using EIP-191 challenge-response.
359
+
360
+ ### GET /operator/key/:agentAddress/challenge
361
+
362
+ Get a challenge nonce for key-based authentication.
363
+
364
+ | Parameter | Location | Type | Required | Description |
365
+ |-----------|----------|------|----------|-------------|
366
+ | `agentAddress` | path | string | yes | Ethereum address (0x...) |
367
+
368
+ #### Response — 200 OK
369
+
370
+ ```json
371
+ {
372
+ "challenge": "valiron-challenge-abc123...",
373
+ "expiresAt": "2026-04-01T12:05:00.000Z"
374
+ }
375
+ ```
376
+
377
+ ### POST /operator/key/verify
378
+
379
+ Verify a signed challenge to authenticate a key-based agent.
380
+
381
+ #### Request Body
382
+
383
+ ```json
384
+ {
385
+ "address": "0x...",
386
+ "signature": "0x..."
387
+ }
388
+ ```
389
+
390
+ #### Response — 200 OK
391
+
392
+ ```json
393
+ {
394
+ "verified": true,
395
+ "address": "0x...",
396
+ "isKeyAgent": true,
397
+ "tier": "C",
398
+ "riskLevel": "YELLOW",
399
+ "route": "sandbox"
400
+ }
401
+ ```
402
+
403
+ ### GET /operator/key/:agentAddress
404
+
405
+ Get the profile of a key-based agent.
406
+
407
+ #### Response — 200 OK
408
+
409
+ ```json
410
+ {
411
+ "address": "0x...",
412
+ "isKeyAgent": true,
413
+ "tier": "C",
414
+ "riskLevel": "YELLOW",
415
+ "route": "sandbox",
416
+ "firstSeen": "2026-04-01T12:00:00.000Z",
417
+ "totalRequests": 42
418
+ }
419
+ ```
420
+
421
+ ---
422
+
423
+ ## World ID Endpoints
424
+
425
+ Verify agent-human linkage via Worldcoin's zero-knowledge proof system.
426
+
427
+ ### POST /operator/world-id/verify/:agentId
428
+
429
+ Submit a World ID proof for verification.
430
+
431
+ | Parameter | Location | Type | Required | Description |
432
+ |-----------|----------|------|----------|-------------|
433
+ | `agentId` | path | string | yes | ERC-8004 token ID |
434
+
435
+ #### Request Body
436
+
437
+ ```json
438
+ {
439
+ "merkle_root": "0x...",
440
+ "nullifier_hash": "0x...",
441
+ "proof": "0x...",
442
+ "signal": "0x..."
443
+ }
444
+ ```
445
+
446
+ #### Response — 200 OK
447
+
448
+ ```json
449
+ {
450
+ "verified": true,
451
+ "agentId": "25459",
452
+ "level": "orb",
453
+ "verifiedAt": "2026-04-01T12:00:00.000Z"
454
+ }
455
+ ```
456
+
457
+ ### GET /operator/world-id/status/:agentId
458
+
459
+ Check if an agent has a verified World ID.
460
+
461
+ #### Response — 200 OK
462
+
463
+ ```json
464
+ {
465
+ "verified": true,
466
+ "verifiedAt": "2026-04-01T12:00:00.000Z",
467
+ "level": "orb"
468
+ }
469
+ ```
470
+
471
+ ### GET /operator/world-id/profile/:agentId
472
+
473
+ Get full World ID profile including verification details.
474
+
475
+ #### Response — 200 OK
476
+
477
+ ```json
478
+ {
479
+ "agentId": "25459",
480
+ "worldId": {
481
+ "verified": true,
482
+ "level": "orb",
483
+ "verifiedAt": "2026-04-01T12:00:00.000Z"
484
+ }
485
+ }
486
+ ```
487
+
279
488
  ---
280
489
 
281
490
  ## GET /operator/health
@@ -409,3 +618,354 @@ curl -X POST "https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/G
409
618
  | `SOLANA_CLUSTER` | `mainnet-beta` | Solana cluster (`mainnet-beta` or `devnet`) |
410
619
  | `SOLANA_RPC_URL` | Public RPC | Custom Solana RPC endpoint |
411
620
  | `SOLANA_FEEDBACK_KEYPAIR` | — | JSON array secret key (e.g. `[1,2,...,64]`) for feedback write-back. When set, Valiron scores are written on-chain after evaluation. |
621
+
622
+ ---
623
+
624
+ ## Dashboard Endpoints (JWT-Authenticated)
625
+
626
+ All dashboard endpoints require a `Authorization: Bearer <jwt>` header. Get a JWT by calling `POST /operator/login`.
627
+
628
+ ---
629
+
630
+ ### POST /operator/register
631
+
632
+ Create a new operator account.
633
+
634
+ #### Request Body
635
+
636
+ ```json
637
+ {
638
+ "email": "you@example.com",
639
+ "password": "SecurePass123!",
640
+ "name": "Your Name"
641
+ }
642
+ ```
643
+
644
+ #### Response — 200 OK
645
+
646
+ ```json
647
+ {
648
+ "operator": { "id": "uuid", "email": "you@example.com", "name": "Your Name", "role": "operator" },
649
+ "apiKey": "val_op_xxxx..."
650
+ }
651
+ ```
652
+
653
+ > **Important:** The `apiKey` is shown once. Copy it immediately.
654
+
655
+ ---
656
+
657
+ ### POST /operator/login
658
+
659
+ Authenticate and receive a JWT token.
660
+
661
+ #### Request Body
662
+
663
+ ```json
664
+ {
665
+ "email": "you@example.com",
666
+ "password": "SecurePass123!"
667
+ }
668
+ ```
669
+
670
+ #### Response — 200 OK
671
+
672
+ ```json
673
+ {
674
+ "operator": { "id": "uuid", "email": "you@example.com", "name": "Your Name", "role": "operator" },
675
+ "token": "eyJhbGciOi..."
676
+ }
677
+ ```
678
+
679
+ ---
680
+
681
+ ### GET /operator/me
682
+
683
+ Get the current operator's profile. Requires JWT.
684
+
685
+ #### Response — 200 OK
686
+
687
+ ```json
688
+ {
689
+ "ok": true,
690
+ "operator": {
691
+ "id": "uuid",
692
+ "email": "you@example.com",
693
+ "name": "Your Name",
694
+ "role": "operator",
695
+ "plan": "standard",
696
+ "fee_rate": "0.03",
697
+ "created_at": "2026-01-01T00:00:00.000Z",
698
+ "updated_at": "2026-01-01T00:00:00.000Z"
699
+ }
700
+ }
701
+ ```
702
+
703
+ ---
704
+
705
+ ### PATCH /operator/me
706
+
707
+ Update operator name. Requires JWT.
708
+
709
+ #### Request Body
710
+
711
+ ```json
712
+ {
713
+ "name": "New Name"
714
+ }
715
+ ```
716
+
717
+ ---
718
+
719
+ ### GET /operator/keys
720
+
721
+ List all API keys for the current operator. Requires JWT.
722
+
723
+ #### Response — 200 OK
724
+
725
+ ```json
726
+ [
727
+ {
728
+ "id": "uuid",
729
+ "keyPrefix": "val_op_c010...",
730
+ "label": null,
731
+ "revoked": false,
732
+ "lastUsed": "2026-04-01T00:00:00.000Z",
733
+ "createdAt": "2026-01-01T00:00:00.000Z"
734
+ }
735
+ ]
736
+ ```
737
+
738
+ ---
739
+
740
+ ### POST /operator/keys/rotate
741
+
742
+ Generate a new API key. Requires JWT.
743
+
744
+ #### Request Body (optional)
745
+
746
+ ```json
747
+ {
748
+ "label": "production-key"
749
+ }
750
+ ```
751
+
752
+ #### Response — 200 OK
753
+
754
+ ```json
755
+ {
756
+ "key": "val_op_xxxx...",
757
+ "id": "uuid",
758
+ "label": "production-key"
759
+ }
760
+ ```
761
+
762
+ > **Important:** The full key is shown once. Copy it immediately.
763
+
764
+ ---
765
+
766
+ ### DELETE /operator/keys/:keyId
767
+
768
+ Revoke an API key. Requires JWT.
769
+
770
+ ---
771
+
772
+ ### GET /operator/endpoints
773
+
774
+ List all registered endpoints for the current operator. Requires JWT.
775
+
776
+ #### Response — 200 OK
777
+
778
+ ```json
779
+ [
780
+ {
781
+ "id": "uuid",
782
+ "path": "/api/v1/weather",
783
+ "method": "GET",
784
+ "pricePerCall": "0.050000",
785
+ "description": "Returns weather data",
786
+ "rateLimit": 60,
787
+ "active": true,
788
+ "createdAt": "2026-01-01T00:00:00.000Z"
789
+ }
790
+ ]
791
+ ```
792
+
793
+ ---
794
+
795
+ ### POST /operator/endpoints
796
+
797
+ Register a new priced endpoint. Requires JWT.
798
+
799
+ #### Request Body
800
+
801
+ ```json
802
+ {
803
+ "path": "/api/v1/weather",
804
+ "method": "GET",
805
+ "pricePerCall": 0.05,
806
+ "description": "Returns weather data",
807
+ "rateLimit": 60,
808
+ "targetUrl": "https://myapi.com"
809
+ }
810
+ ```
811
+
812
+ | Field | Type | Required | Description |
813
+ |-------|------|----------|-------------|
814
+ | `path` | string | yes | API path (e.g. `/api/v1/weather`) |
815
+ | `method` | string | no | HTTP method (default: `GET`) |
816
+ | `pricePerCall` | number | yes | Price in USD per call (must be ≥ 0) |
817
+ | `description` | string | no | Endpoint description |
818
+ | `rateLimit` | number | no | Max requests/min per agent (null = unlimited) |
819
+ | `targetUrl` | string | no | Backend base URL (e.g. `https://myapi.com`). Must be HTTPS. Private/internal addresses are blocked. When set, the playground forwards requests to this URL + path. |
820
+
821
+ ---
822
+
823
+ ### DELETE /operator/endpoints/:endpointId
824
+
825
+ Deactivate an endpoint (soft delete). Requires JWT.
826
+
827
+ ---
828
+
829
+ ### GET /operator/analytics/stats
830
+
831
+ Aggregate stats for the current operator. Requires JWT.
832
+
833
+ #### Response — 200 OK
834
+
835
+ ```json
836
+ {
837
+ "totalCalls": 1250,
838
+ "totalRevenue": "62.50",
839
+ "uniqueAgents": 18,
840
+ "avgResponseMs": 145,
841
+ "errorRate": "0.024",
842
+ "callsToday": 42,
843
+ "revenueToday": "2.10"
844
+ }
845
+ ```
846
+
847
+ ---
848
+
849
+ ### GET /operator/analytics/revenue?days=30
850
+
851
+ Daily revenue time series. Requires JWT.
852
+
853
+ #### Response — 200 OK
854
+
855
+ ```json
856
+ [
857
+ { "date": "2026-04-01", "revenue": "3.50", "calls": 70 },
858
+ { "date": "2026-04-02", "revenue": "4.25", "calls": 85 }
859
+ ]
860
+ ```
861
+
862
+ ---
863
+
864
+ ### GET /operator/analytics/top-endpoints?limit=10
865
+
866
+ Top endpoints ranked by call volume. Requires JWT.
867
+
868
+ ---
869
+
870
+ ### GET /operator/analytics/agents?sortBy=lastSeen&limit=50&offset=0
871
+
872
+ Paginated agent summaries. Requires JWT.
873
+
874
+ | Parameter | Type | Default | Description |
875
+ |-----------|------|---------|-------------|
876
+ | `sortBy` | string | `lastSeen` | Sort by: `lastSeen`, `calls`, `spent`, `errors` |
877
+ | `limit` | number | 50 | Page size |
878
+ | `offset` | number | 0 | Offset |
879
+
880
+ ---
881
+
882
+ ### GET /operator/analytics/agents/:agentId
883
+
884
+ Detailed view of a single agent. Requires JWT. Returns summary stats, endpoint breakdown, and recent call log.
885
+
886
+ ---
887
+
888
+ ### GET /operator/analytics/logs
889
+
890
+ Paginated call logs. Requires JWT.
891
+
892
+ | Parameter | Type | Default | Description |
893
+ |-----------|------|---------|-------------|
894
+ | `limit` | number | 50 | Page size |
895
+ | `offset` | number | 0 | Offset |
896
+ | `days` | number | — | Filter to last N days |
897
+ | `agentId` | string | — | Filter by agent |
898
+ | `endpointId` | string | — | Filter by endpoint |
899
+
900
+ ---
901
+
902
+ ### POST /operator/playground
903
+
904
+ Execute a test request through the edge proxy as a simulated agent. Requires JWT. See [DASHBOARD.md — API Playground](./DASHBOARD.md#api-playground).
905
+
906
+ #### Request Body
907
+
908
+ ```json
909
+ {
910
+ "method": "GET",
911
+ "path": "/api/v1/weather?city=NYC",
912
+ "headers": { "Content-Type": "application/json" },
913
+ "body": null,
914
+ "agentId": "25459",
915
+ "chain": "ethereum",
916
+ "dryRun": false
917
+ }
918
+ ```
919
+
920
+ | Field | Type | Required | Description |
921
+ |-------|------|----------|-------------|
922
+ | `path` | string | yes | Target path or absolute URL |
923
+ | `agentId` | string | yes | ERC-8004 agent ID to simulate |
924
+ | `method` | string | no | HTTP method (default: `GET`) |
925
+ | `headers` | object | no | Custom request headers |
926
+ | `body` | string | no | Request body (for POST/PUT/PATCH) |
927
+ | `chain` | string | no | Chain (default: `ethereum`) |
928
+ | `dryRun` | boolean | no | If `true`, returns trust evaluation without logging the call |
929
+
930
+ #### Response — 200 OK (standard mode)
931
+
932
+ ```json
933
+ {
934
+ "ok": true,
935
+ "statusCode": 200,
936
+ "statusText": "OK",
937
+ "responseHeaders": {},
938
+ "responseBody": "<downstream response body or trust evaluation JSON>",
939
+ "responseMs": 145,
940
+ "costCharged": "0.0500",
941
+ "route": "prod",
942
+ "tierResolved": "AA"
943
+ }
944
+ ```
945
+
946
+ #### Response — 200 OK (dry-run mode)
947
+
948
+ ```json
949
+ {
950
+ "ok": true,
951
+ "statusCode": null,
952
+ "statusText": null,
953
+ "responseHeaders": {},
954
+ "responseBody": "{\"dryRun\":true,\"message\":\"Routing and pricing validated — request was not forwarded to your backend\",\"agentId\":\"25459\",\"chain\":\"ethereum\",\"tier\":\"AA\",\"route\":\"prod\",\"pricePerCall\":\"0.0500\",\"endpointRegistered\":true,\"trustProfile\":{\"onchainScore\":92.5,\"feedbackCount\":\"12\",\"routingDecision\":null}}",
955
+ "responseMs": null,
956
+ "costCharged": "0.0500",
957
+ "route": "prod",
958
+ "tierResolved": "AA"
959
+ }
960
+ ```
961
+
962
+ ---
963
+
964
+ ### Admin Endpoints (require `role: "admin"`)
965
+
966
+ | Endpoint | Method | Description |
967
+ |----------|--------|-------------|
968
+ | `/operator/admin/stats` | GET | Platform-wide stats |
969
+ | `/operator/admin/operators` | GET | List all operators with aggregate stats |
970
+ | `/operator/admin/operators/:id` | GET | Full operator detail (keys, endpoints, agents, revenue) |
971
+ | `/operator/admin/operators/:id/logs` | GET | Call logs for a specific operator |