@valiron/sdk 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,19 +61,19 @@ console.log(profile.onchainReputation.averageScore); // 92.5
61
61
 
62
62
  The SDK returns one of four routing decisions:
63
63
 
64
- | Route | Meaning | Trust Tiers |
65
- |-------|---------|-------------|
66
- | `prod` | Full access | AAA – BAA |
67
- | `prod_throttled` | Rate-limited access | BA – B |
68
- | `sandbox` | Agent under evaluation | Temporary |
69
- | `sandbox_only` | Access denied | CAA – C |
64
+ | Route | Meaning |
65
+ |-------|--------|
66
+ | `prod` | Full access |
67
+ | `prod_throttled` | Rate-limited access |
68
+ | `sandbox` | Agent under evaluation |
69
+ | `sandbox_only` | Access denied |
70
70
 
71
71
  ### Trust Evaluation
72
72
 
73
73
  Valiron evaluates agents using:
74
74
 
75
75
  1. **On-chain Reputation** — ERC-8004 feedback submitted by other organizations
76
- 2. **Behavioral Analysis** — Sandbox evaluation of rate-limit compliance, error rates, and request patterns
76
+ 2. **Behavioral Analysis** — Proprietary sandbox evaluation of agent behavior
77
77
  3. **Credit Rating** — Moody's-style scoring system (AAA to C)
78
78
 
79
79
  ### Architecture
@@ -163,15 +163,14 @@ const arbProfile = await valiron.getAgentProfile('8348', { chain: 'arbitrum' });
163
163
  tier: MoodysRating,
164
164
  riskLevel: 'GREEN' | 'YELLOW' | 'RED',
165
165
  graduated: boolean,
166
- metrics: BehavioralMetrics,
167
166
  } | null,
168
167
  routing: {
169
168
  finalRoute: RouteDecision,
170
- decision: string, // human-readable explanation
171
- reasons: string[], // array of reasoning steps
169
+ decision: string,
170
+ reasons: string[],
172
171
  signals: {
173
- onchain: { feedbackCount, averageScore, threshold },
174
- local: { exists, graduated, tier, riskLevel, score },
172
+ onchain: { feedbackCount, averageScore, meetsThreshold },
173
+ local: { exists, graduated, tier, riskLevel },
175
174
  },
176
175
  },
177
176
  timestamp: string,
@@ -203,9 +202,6 @@ const result = await valiron.triggerSandboxTest('25459');
203
202
  console.log(result.valironScore); // 95
204
203
  console.log(result.tier); // 'AAA'
205
204
  console.log(result.riskLevel); // 'GREEN'
206
- console.log(result.mode); // 'endpoint-probe' | 'sandbox-relay'
207
- console.log(result.testSummary);
208
- // { totalRequests, successCount, rateLimitCount, errorCount, avgLatencyMs }
209
205
  ```
210
206
 
211
207
  ---
@@ -231,8 +227,6 @@ const result2 = await valiron.gate('8348', {
231
227
 
232
228
  if (result2.allow) {
233
229
  // proceed to payment
234
- } else {
235
- console.log(result2.reasons); // ['Score 42 below threshold 85']
236
230
  }
237
231
  ```
238
232
 
@@ -247,11 +241,10 @@ if (result2.allow) {
247
241
  ```typescript
248
242
  {
249
243
  allow: boolean, // allow or deny
250
- score: number, // combined Valiron score (0–110)
244
+ score: number, // combined Valiron score
251
245
  tier: MoodysRating, // 'AAA' | 'AA' | ... | 'C'
252
246
  riskLevel: RiskLevel, // 'GREEN' | 'YELLOW' | 'RED'
253
247
  route: RouteDecision, // 'prod' | 'prod_throttled' | 'sandbox' | 'sandbox_only'
254
- reasons: string[], // human-readable explanation
255
248
  agentId: string,
256
249
  wallet: string,
257
250
  sandboxRan: boolean, // whether sandbox was freshly executed
@@ -340,19 +333,30 @@ await valiron3.getAgentProfile('8348', { chain: 'monad' }); // Monad override
340
333
 
341
334
  All SDK methods accept an optional `CallOptions` object with a `chain` field.
342
335
 
343
- ## Telemetry (Optional)
336
+ ## Telemetry
344
337
 
345
- Valiron SDK now supports opt-in telemetry for adoption, usage, route outcomes, and stability.
338
+ Valiron SDK collects anonymous usage telemetry by default (opt-out) to help track adoption, usage, route outcomes, and stability. No personally identifiable information is collected; geo data is derived server-side from the request IP (coarse country/region only).
339
+
340
+ To **disable** telemetry:
341
+
342
+ ```ts
343
+ const valiron = new ValironSDK({
344
+ telemetry: {
345
+ enabled: false,
346
+ },
347
+ });
348
+ ```
349
+
350
+ You can also customise the telemetry behaviour:
346
351
 
347
352
  ```ts
348
353
  const valiron = new ValironSDK({
349
354
  telemetry: {
350
- enabled: true,
351
355
  appId: "my-app",
352
356
  workspaceId: "ws_123",
353
357
  env: "prod",
354
358
  // Optional: custom ingest endpoint (defaults to `${endpoint}/telemetry/sdk`)
355
- // where the endpoint is: "https://my-collector.example.com/events",
359
+ // endpoint: "https://my-collector.example.com/events",
356
360
  },
357
361
  });
358
362
  ```
@@ -465,17 +469,17 @@ app.get('/api/premium/data', trustGate, x402PaymentCheck, (req, res) => {
465
469
 
466
470
  ## Moody's Credit Rating Tiers
467
471
 
468
- | Tier | Score Range | Risk | Access Level |
469
- |------|-------------|------|--------------|
470
- | AAA | 98-110 | Prime | Full production |
471
- | AA | 92-97 | High grade | Full production |
472
- | A | 85-91 | Upper medium | Full production |
473
- | BAA | 75-84 | Medium | Full production (monitored) |
474
- | BA | 65-74 | Speculative | Throttled |
475
- | B | 50-64 | Highly speculative | Throttled |
476
- | CAA | 35-49 | Substantial risk | Sandbox only |
477
- | CA | 20-34 | Extremely speculative | Sandbox only |
478
- | C | 0-19 | Default risk | Sandbox only |
472
+ | Tier | Risk | Access Level |
473
+ |------|------|--------------|
474
+ | AAA | Prime | Full production |
475
+ | AA | High grade | Full production |
476
+ | A | Upper medium | Full production |
477
+ | BAA | Medium | Full production (monitored) |
478
+ | BA | Speculative | Throttled |
479
+ | B | Highly speculative | Throttled |
480
+ | CAA | Substantial risk | Sandbox only |
481
+ | CA | Extremely speculative | Sandbox only |
482
+ | C | Default risk | Sandbox only |
479
483
 
480
484
  ## TypeScript Types
481
485
 
@@ -498,7 +502,6 @@ import {
498
502
  OnchainReputation,
499
503
  LocalReputation,
500
504
  RoutingExplanation,
501
- BehavioralMetrics,
502
505
  FeedbackEntry,
503
506
  ValironError,
504
507
  ValironClient,
package/dist/clients.d.ts CHANGED
@@ -50,9 +50,10 @@ export declare class ValironClient {
50
50
  * `POST /operator/gate/:agentId`
51
51
  */
52
52
  gate(agentId: string, options?: GateOptions): Promise<GateResult>;
53
+ /** Flush any pending telemetry events and clean up resources. */
54
+ dispose(): Promise<void>;
53
55
  private buildHeaders;
54
56
  private get;
55
57
  private post;
56
58
  private extractMethodName;
57
59
  }
58
- //# sourceMappingURL=clients.d.ts.map
package/dist/clients.js CHANGED
@@ -35,6 +35,11 @@ class ValironClient {
35
35
  async getAgentProfile(agentId, options) {
36
36
  const chain = this.resolveChain(options);
37
37
  const profile = await this.get(`/operator/agent/${agentId}`, chain);
38
+ // Strip internal fields that the API returns but SDK consumers should not see
39
+ if (profile?.localReputation) {
40
+ delete profile.localReputation.metrics;
41
+ delete profile.localReputation.ipfsCid;
42
+ }
38
43
  const totalFeedback = Number(profile?.onchainReputation?.totalFeedback || 0);
39
44
  const avgScore = Number(profile?.onchainReputation?.averageScore || 0);
40
45
  const feedbackBucket = totalFeedback === 0 ? "0" : totalFeedback <= 5 ? "1-5" : totalFeedback <= 20 ? "6-20" : "20+";
@@ -55,7 +60,13 @@ class ValironClient {
55
60
  * `GET /operator/wallet/:wallet`
56
61
  */
57
62
  async getWalletProfile(wallet, options) {
58
- return this.get(`/operator/wallet/${wallet}`, this.resolveChain(options));
63
+ const profile = await this.get(`/operator/wallet/${wallet}`, this.resolveChain(options));
64
+ // Strip internal fields from local reputation
65
+ if (profile?.localReputation) {
66
+ delete profile.localReputation.metrics;
67
+ delete profile.localReputation.ipfsCid;
68
+ }
69
+ return profile;
59
70
  }
60
71
  /**
61
72
  * Trigger real sandbox testing for an agent.
@@ -67,7 +78,12 @@ class ValironClient {
67
78
  * `POST /operator/trigger-sandbox/:agentId`
68
79
  */
69
80
  async triggerSandboxTest(agentId, options) {
70
- return this.post(`/operator/trigger-sandbox/${agentId}`, undefined, this.resolveChain(options));
81
+ const result = await this.post(`/operator/trigger-sandbox/${agentId}`, undefined, this.resolveChain(options));
82
+ // Strip internal behavioral metrics and execution details from sandbox response
83
+ delete result.metrics;
84
+ delete result.testSummary;
85
+ delete result.mode;
86
+ return result;
71
87
  }
72
88
  /**
73
89
  * Trust gate — single call combining on-chain reputation + sandbox tests.
@@ -80,7 +96,14 @@ class ValironClient {
80
96
  */
81
97
  async gate(agentId, options) {
82
98
  const { chain, ...body } = options || {};
83
- return this.post(`/operator/gate/${agentId}`, Object.keys(body).length > 0 ? body : undefined, chain ?? this.defaultChain);
99
+ const result = await this.post(`/operator/gate/${agentId}`, Object.keys(body).length > 0 ? body : undefined, chain ?? this.defaultChain);
100
+ // Strip detailed scoring reasons — SDK consumers get allow/deny + tier only
101
+ delete result.reasons;
102
+ return result;
103
+ }
104
+ /** Flush any pending telemetry events and clean up resources. */
105
+ async dispose() {
106
+ await this.telemetry.dispose();
84
107
  }
85
108
  // ─── HTTP helpers ───────────────────────────────────────────────────────
86
109
  buildHeaders() {
@@ -190,10 +213,14 @@ class ValironClient {
190
213
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
191
214
  const start = Date.now();
192
215
  try {
216
+ const headers = this.buildHeaders();
217
+ const hasBody = body !== undefined && body !== null;
218
+ if (!hasBody)
219
+ delete headers["Content-Type"];
193
220
  const response = await fetch(url.toString(), {
194
221
  method: "POST",
195
- headers: this.buildHeaders(),
196
- body: body ? JSON.stringify(body) : undefined,
222
+ headers,
223
+ body: hasBody ? JSON.stringify(body) : undefined,
197
224
  signal: controller.signal,
198
225
  });
199
226
  clearTimeout(timeoutId);
@@ -280,4 +307,3 @@ class ValironClient {
280
307
  }
281
308
  }
282
309
  exports.ValironClient = ValironClient;
283
- //# sourceMappingURL=clients.js.map
package/dist/index.d.ts CHANGED
@@ -148,9 +148,27 @@ export declare class ValironSDK {
148
148
  * ```
149
149
  */
150
150
  gate(agentId: string, options?: GateOptions): Promise<GateResult>;
151
+ /**
152
+ * Flush any pending telemetry events and release resources.
153
+ *
154
+ * Call this when you are done using the SDK in long-running processes
155
+ * to ensure all queued telemetry is sent before shutdown. In short-lived
156
+ * scripts the SDK flushes automatically on process exit; calling dispose
157
+ * is optional but recommended for deterministic cleanup.
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * const valiron = new ValironSDK();
162
+ * try {
163
+ * const profile = await valiron.getAgentProfile('25459');
164
+ * } finally {
165
+ * await valiron.dispose();
166
+ * }
167
+ * ```
168
+ */
169
+ dispose(): Promise<void>;
151
170
  }
152
171
  export * from "./types";
153
172
  export { ValironClient } from "./clients";
154
173
  export { createValironGate } from "./middleware";
155
174
  export type { ValironGateConfig } from "./middleware";
156
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -177,6 +177,27 @@ class ValironSDK {
177
177
  async gate(agentId, options) {
178
178
  return this.client.gate(agentId, options);
179
179
  }
180
+ /**
181
+ * Flush any pending telemetry events and release resources.
182
+ *
183
+ * Call this when you are done using the SDK in long-running processes
184
+ * to ensure all queued telemetry is sent before shutdown. In short-lived
185
+ * scripts the SDK flushes automatically on process exit; calling dispose
186
+ * is optional but recommended for deterministic cleanup.
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const valiron = new ValironSDK();
191
+ * try {
192
+ * const profile = await valiron.getAgentProfile('25459');
193
+ * } finally {
194
+ * await valiron.dispose();
195
+ * }
196
+ * ```
197
+ */
198
+ dispose() {
199
+ return this.client.dispose();
200
+ }
180
201
  }
181
202
  exports.ValironSDK = ValironSDK;
182
203
  // Re-export everything
@@ -185,4 +206,3 @@ var clients_2 = require("./clients");
185
206
  Object.defineProperty(exports, "ValironClient", { enumerable: true, get: function () { return clients_2.ValironClient; } });
186
207
  var middleware_1 = require("./middleware");
187
208
  Object.defineProperty(exports, "createValironGate", { enumerable: true, get: function () { return middleware_1.createValironGate; } });
188
- //# sourceMappingURL=index.js.map
@@ -47,4 +47,3 @@ export interface ValironGateConfig {
47
47
  * ```
48
48
  */
49
49
  export declare function createValironGate(config: ValironGateConfig): (req: any, res: any, next: any) => Promise<any>;
50
- //# sourceMappingURL=middleware.d.ts.map
@@ -59,4 +59,3 @@ function createValironGate(config) {
59
59
  }
60
60
  };
61
61
  }
62
- //# sourceMappingURL=middleware.js.map
@@ -13,10 +13,12 @@ export declare class TelemetryClient {
13
13
  private queue;
14
14
  private flushTimer?;
15
15
  private latencyByKey;
16
+ private beforeExitHandler?;
17
+ /** Returns the Node.js process object when running in Node, undefined otherwise. */
18
+ private getNodeProcess;
16
19
  constructor(config: TelemetryConfig | undefined, apiEndpoint: string);
17
- dispose(): void;
20
+ dispose(): Promise<void>;
18
21
  emit(event: string, payload: Record<string, unknown>): void;
19
22
  recordLatency(method: string, chain: string, durationMs: number): void;
20
23
  private flush;
21
24
  }
22
- //# sourceMappingURL=telemetry.d.ts.map
package/dist/telemetry.js CHANGED
@@ -13,10 +13,16 @@ function percentile(values, p) {
13
13
  return sorted[idx] ?? 0;
14
14
  }
15
15
  class TelemetryClient {
16
+ /** Returns the Node.js process object when running in Node, undefined otherwise. */
17
+ getNodeProcess() {
18
+ if (this.runtime !== "node")
19
+ return undefined;
20
+ return globalThis.process;
21
+ }
16
22
  constructor(config, apiEndpoint) {
17
23
  this.queue = [];
18
24
  this.latencyByKey = new Map();
19
- this.enabled = config?.enabled ?? false;
25
+ this.enabled = config?.enabled ?? true;
20
26
  this.endpoint = config?.endpoint || `${apiEndpoint.replace(/\/$/, "")}/telemetry/sdk`;
21
27
  this.appId = config?.appId;
22
28
  this.workspaceId = config?.workspaceId;
@@ -30,13 +36,28 @@ class TelemetryClient {
30
36
  this.flushTimer = setInterval(() => {
31
37
  void this.flush();
32
38
  }, this.flushIntervalMs);
39
+ // Prevent the timer from keeping the Node.js event loop alive when
40
+ // telemetry is running silently in the background (e.g., CLI scripts).
41
+ this.flushTimer.unref?.();
42
+ // In Node.js, flush any pending events when the process is about to
43
+ // exit naturally. This ensures that telemetry emitted in short-lived
44
+ // scripts (where the flush interval never fires) is still reported.
45
+ const nodeProcess = this.getNodeProcess();
46
+ if (nodeProcess?.on) {
47
+ this.beforeExitHandler = () => { void this.flush(); };
48
+ nodeProcess.on("beforeExit", this.beforeExitHandler);
49
+ }
33
50
  this.emit("sdk_initialized", {});
34
51
  }
35
52
  }
36
- dispose() {
53
+ async dispose() {
37
54
  if (this.flushTimer)
38
55
  clearInterval(this.flushTimer);
39
- void this.flush();
56
+ if (this.beforeExitHandler) {
57
+ this.getNodeProcess()?.off?.("beforeExit", this.beforeExitHandler);
58
+ this.beforeExitHandler = undefined;
59
+ }
60
+ await this.flush();
40
61
  }
41
62
  emit(event, payload) {
42
63
  if (!this.enabled)
@@ -91,4 +112,3 @@ class TelemetryClient {
91
112
  }
92
113
  }
93
114
  exports.TelemetryClient = TelemetryClient;
94
- //# sourceMappingURL=telemetry.js.map
package/dist/types.d.ts CHANGED
@@ -27,13 +27,14 @@ export interface FeedbackEntry {
27
27
  score: number;
28
28
  tag1: string;
29
29
  tag2: string;
30
- uri: string;
31
- hash: string;
32
- blockNumber: string;
33
- transactionHash: string;
30
+ uri?: string;
31
+ hash?: string;
32
+ blockNumber?: string;
33
+ transactionHash?: string;
34
34
  feedbackIndex?: string;
35
35
  indexedTag1?: string;
36
36
  endpoint?: string;
37
+ isRevoked?: boolean;
37
38
  }
38
39
  export interface OnchainReputation {
39
40
  count: string;
@@ -42,26 +43,14 @@ export interface OnchainReputation {
42
43
  totalFeedback: number;
43
44
  error?: string;
44
45
  }
45
- export interface BehavioralMetrics {
46
- loops?: number;
47
- totalRequests?: number;
48
- respected429?: boolean;
49
- errorRate?: number;
50
- averageLatency?: number;
51
- burstiness?: number;
52
- onChainFeedbackCount?: number;
53
- onChainAverageScore?: number;
54
- }
55
46
  export interface LocalReputation {
56
47
  exists: boolean;
57
48
  score?: number;
58
49
  tier?: MoodysRating | string;
59
50
  riskLevel?: RiskLevel | string;
60
51
  graduated?: boolean;
61
- metrics?: BehavioralMetrics;
62
- ipfsCid?: string | null;
63
- agentId?: string | null;
64
52
  lastUpdated?: string | null;
53
+ agentId?: string | null;
65
54
  message?: string;
66
55
  error?: string;
67
56
  }
@@ -69,14 +58,13 @@ export interface RoutingSignals {
69
58
  onchain: {
70
59
  feedbackCount: number;
71
60
  averageScore: number;
72
- threshold: string;
61
+ meetsThreshold: boolean;
73
62
  };
74
63
  local: {
75
64
  exists: boolean;
76
65
  graduated: boolean;
77
66
  tier: string;
78
67
  riskLevel: string;
79
- score: number;
80
68
  };
81
69
  }
82
70
  export interface RoutingExplanation {
@@ -116,13 +104,6 @@ export interface WalletProfile {
116
104
  chain: ChainContext;
117
105
  timestamp: string;
118
106
  }
119
- export interface SandboxTestSummary {
120
- totalRequests: number;
121
- successCount: number;
122
- rateLimitCount: number;
123
- errorCount: number;
124
- avgLatencyMs: number;
125
- }
126
107
  /**
127
108
  * Response from `POST /operator/trigger-sandbox/:agentId`
128
109
  */
@@ -130,12 +111,9 @@ export interface SandboxResult {
130
111
  ok: boolean;
131
112
  agentId: string;
132
113
  wallet: string;
133
- mode: "endpoint-probe" | "sandbox-relay";
134
- metrics: BehavioralMetrics;
135
114
  valironScore: number;
136
115
  tier: MoodysRating;
137
116
  riskLevel: RiskLevel;
138
- testSummary: SandboxTestSummary;
139
117
  chain: ChainContext;
140
118
  message: string;
141
119
  }
@@ -159,7 +137,6 @@ export interface GateResult {
159
137
  tier: MoodysRating;
160
138
  riskLevel: RiskLevel;
161
139
  route: RouteDecision;
162
- reasons: string[];
163
140
  agentId: string;
164
141
  wallet: string;
165
142
  chain: ChainContext;
@@ -234,4 +211,3 @@ export declare class ValironError extends Error {
234
211
  statusCode?: number | undefined;
235
212
  constructor(message: string, code: string, statusCode?: number | undefined);
236
213
  }
237
- //# sourceMappingURL=types.d.ts.map
package/dist/types.js CHANGED
@@ -17,4 +17,3 @@ class ValironError extends Error {
17
17
  }
18
18
  }
19
19
  exports.ValironError = ValironError;
20
- //# sourceMappingURL=types.js.map
@@ -0,0 +1,181 @@
1
+ # API Reference
2
+
3
+ Base URL: `https://valiron-edge-proxy.onrender.com`
4
+
5
+ All endpoints are under the `/operator/` path prefix.
6
+
7
+ ---
8
+
9
+ ## GET /operator/agent/:agentId
10
+
11
+ Retrieve the complete trust profile for an agent.
12
+
13
+ ### Parameters
14
+
15
+ | Parameter | Location | Type | Required | Description |
16
+ |-----------|----------|------|----------|-------------|
17
+ | `agentId` | path | string | yes | ERC-8004 token ID |
18
+ | `chain` | query | string | no | Network override (default: ethereum) |
19
+
20
+ ### Response — 200 OK
21
+
22
+ ```json
23
+ {
24
+ "agentId": "25459",
25
+ "identity": {
26
+ "agentId": "25459",
27
+ "wallet": "0x52ce...",
28
+ "tokenUri": "data:application/json;base64,...",
29
+ "name": "Agent Name",
30
+ "image": "https://...",
31
+ "description": "Agent description",
32
+ "endpoints": {
33
+ "agentWallet": "eip155:1:0x...",
34
+ "api": "https://api.example.com"
35
+ },
36
+ "trustModels": ["reputation_on_chain", "behavioral_sandbox"]
37
+ },
38
+ "onchainReputation": {
39
+ "feedbackCount": 12,
40
+ "averageScore": 92.5
41
+ },
42
+ "routing": {
43
+ "finalRoute": "prod",
44
+ "meetsThreshold": true
45
+ },
46
+ "chain": {
47
+ "name": "ethereum",
48
+ "chainId": 1
49
+ },
50
+ "timestamp": "2026-03-23T12:00:00.000Z"
51
+ }
52
+ ```
53
+
54
+ ### Error Responses
55
+
56
+ | Status | Meaning |
57
+ |--------|---------|
58
+ | 404 | Agent not found in ERC-8004 registry |
59
+ | 500 | Internal server error |
60
+
61
+ ---
62
+
63
+ ## GET /operator/wallet/:wallet
64
+
65
+ Reverse-lookup a wallet address to get its trust profile.
66
+
67
+ ### Parameters
68
+
69
+ | Parameter | Location | Type | Required | Description |
70
+ |-----------|----------|------|----------|-------------|
71
+ | `wallet` | path | string | yes | Ethereum address (0x...) |
72
+ | `chain` | query | string | no | Network override |
73
+
74
+ ### Response — 200 OK
75
+
76
+ Same structure as `GET /operator/agent/:agentId`.
77
+
78
+ ---
79
+
80
+ ## POST /operator/trigger-sandbox/:agentId
81
+
82
+ Execute real-time sandbox tests against an agent and compute a trust evaluation.
83
+
84
+ ### Parameters
85
+
86
+ | Parameter | Location | Type | Required | Description |
87
+ |-----------|----------|------|----------|-------------|
88
+ | `agentId` | path | string | yes | ERC-8004 token ID |
89
+ | `chain` | query | string | no | Network override |
90
+
91
+ ### Response — 200 OK
92
+
93
+ ```json
94
+ {
95
+ "ok": true,
96
+ "agentId": "25459",
97
+ "wallet": "0x52ce...",
98
+ "tier": "AAA",
99
+ "riskLevel": "GREEN",
100
+ "meetsThreshold": true,
101
+ "testSummary": {
102
+ "totalRequests": 25,
103
+ "successCount": 18,
104
+ "rateLimitCount": 5,
105
+ "errorCount": 2,
106
+ "avgLatencyMs": 120
107
+ },
108
+ "chain": {
109
+ "name": "ethereum",
110
+ "chainId": 1
111
+ },
112
+ "message": "Sandbox evaluation complete"
113
+ }
114
+ ```
115
+
116
+ ---
117
+
118
+ ## POST /operator/gate/:agentId
119
+
120
+ Trust gate — combined on-chain reputation + sandbox check. Returns an allow/deny decision. Designed for protecting payment endpoints (x402, etc.).
121
+
122
+ ### Parameters
123
+
124
+ | Parameter | Location | Type | Required | Description |
125
+ |-----------|----------|------|----------|-------------|
126
+ | `agentId` | path | string | yes | ERC-8004 token ID |
127
+
128
+ ### Request Body
129
+
130
+ ```json
131
+ {
132
+ "ttlMs": 86400000
133
+ }
134
+ ```
135
+
136
+ | Field | Type | Default | Description |
137
+ |-------|------|---------|-------------|
138
+ | `ttlMs` | number | 86400000 | Cache TTL in milliseconds (default 24 hours) |
139
+
140
+ ### Response — 200 OK
141
+
142
+ ```json
143
+ {
144
+ "allow": true,
145
+ "tier": "AAA",
146
+ "riskLevel": "GREEN",
147
+ "meetsThreshold": true,
148
+ "route": "prod",
149
+ "agentId": "25459",
150
+ "wallet": "0x52ce...",
151
+ "chain": {
152
+ "name": "ethereum",
153
+ "chainId": 1
154
+ },
155
+ "sandboxRan": false,
156
+ "cached": true
157
+ }
158
+ ```
159
+
160
+ ### Decision Logic
161
+
162
+ 1. If the agent meets the trust threshold → `allow: true`
163
+ 2. If the agent does not meet the threshold → `allow: false`
164
+ 3. Cached sandbox results are reused within the `ttlMs` window
165
+ 4. If no cached result exists, sandbox tests run automatically
166
+
167
+ ---
168
+
169
+ ## GET /operator/health
170
+
171
+ Health check endpoint.
172
+
173
+ ### Response — 200 OK
174
+
175
+ ```json
176
+ {
177
+ "status": "ok",
178
+ "supportedChains": ["ethereum", "monad", "arbitrum", "base", ...],
179
+ "defaultChain": "ethereum"
180
+ }
181
+ ```