@valiron/sdk 1.0.0 → 1.0.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.
@@ -1,5 +1,5 @@
1
1
  import { ValironSDK } from "./index.js";
2
- import type { SupportedChain } from "./types.js";
2
+ import type { SupportedChain, TrustSignal } from "./types.js";
3
3
  /**
4
4
  * Configuration for the Valiron Operator SDK.
5
5
  */
@@ -23,8 +23,21 @@ export interface PaywallConfig {
23
23
  pricePerCall: number;
24
24
  /** Minimum trust score to allow (default: 45). */
25
25
  minTrustScore?: number;
26
- /** TTL for cached trust results in ms (default: 86400000 = 24h). */
26
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+icebreaker. */
27
+ trustSignals?: TrustSignal[];
28
+ /**
29
+ * Server-side gate result TTL in ms (default: 86400000 = 24h).
30
+ * @deprecated Use `cacheTtlMs` for client-side cache control.
31
+ * This field is kept for backward compatibility and
32
+ * maps to `cacheTtlMs` if `cacheTtlMs` is not set.
33
+ */
27
34
  ttlMs?: number;
35
+ /**
36
+ * Client-side profile cache TTL in ms (default: 30000 = 30s).
37
+ * Controls how long gate results are cached in memory to absorb
38
+ * x402 retry flows. Set to `0` to disable caching.
39
+ */
40
+ cacheTtlMs?: number;
28
41
  /** Custom handler when an agent is denied. */
29
42
  onDeny?: (req: any, res: any, result: any) => void;
30
43
  /** Hook called after an agent is allowed. */
@@ -55,7 +68,15 @@ export declare class ValironOperator {
55
68
  private sdk;
56
69
  private apiKey;
57
70
  private debug;
71
+ private endpoint;
58
72
  constructor(config: ValironOperatorConfig);
73
+ private buildAnalyticsUrl;
74
+ private recordUsage;
75
+ private extractHeader;
76
+ private expressPath;
77
+ private expressIp;
78
+ private fastifyPath;
79
+ private normalizeTrustSignals;
59
80
  /**
60
81
  * Create Express/Connect middleware that gates access + tracks usage.
61
82
  *
@@ -76,7 +97,7 @@ export declare class ValironOperator {
76
97
  * });
77
98
  * ```
78
99
  */
79
- paywall(config: PaywallConfig): (req: any, res: any, next: any) => Promise<any>;
100
+ paywall(config: PaywallConfig): (req: any, res: any, next: any) => void;
80
101
  /**
81
102
  * Create a Fastify plugin that gates access + tracks usage.
82
103
  *
@@ -31,6 +31,7 @@ class ValironOperator {
31
31
  }
32
32
  this.apiKey = config.apiKey;
33
33
  this.debug = config.debug || false;
34
+ this.endpoint = config.endpoint || "https://valiron-edge-proxy.onrender.com";
34
35
  this.sdk = new index_js_1.ValironSDK({
35
36
  apiKey: config.apiKey,
36
37
  chain: config.chain,
@@ -39,6 +40,65 @@ class ValironOperator {
39
40
  debug: config.debug,
40
41
  });
41
42
  }
43
+ buildAnalyticsUrl() {
44
+ return new URL("/operator/analytics/ingest", this.endpoint).toString();
45
+ }
46
+ recordUsage(entry) {
47
+ const trustSignals = this.normalizeTrustSignals(entry.trustSignals);
48
+ const body = {
49
+ agent_id: entry.agentId || undefined,
50
+ agent_label: entry.agentLabel || undefined,
51
+ session_id: entry.sessionId || undefined,
52
+ chain: entry.chain || undefined,
53
+ path: entry.path,
54
+ method: entry.method,
55
+ status_code: entry.statusCode,
56
+ price_charged: entry.priceCharged,
57
+ response_ms: entry.responseMs,
58
+ user_agent: entry.userAgent || undefined,
59
+ ip_address: entry.ipAddress || undefined,
60
+ error_message: entry.errorMessage || undefined,
61
+ trust_signals: trustSignals,
62
+ trust_signal_count: trustSignals.length,
63
+ scoring_mode: trustSignals.length ? trustSignals.join("+") : undefined,
64
+ erc8004_included: trustSignals.includes("8004"),
65
+ sandbox_included: trustSignals.includes("sandbox"),
66
+ world_included: trustSignals.includes("world"),
67
+ icebreaker_included: trustSignals.includes("icebreaker"),
68
+ };
69
+ void fetch(this.buildAnalyticsUrl(), {
70
+ method: "POST",
71
+ headers: {
72
+ "Content-Type": "application/json",
73
+ Authorization: `Bearer ${this.apiKey}`,
74
+ },
75
+ body: JSON.stringify(body),
76
+ })
77
+ .then((response) => response.arrayBuffer().catch(() => response.body?.cancel()))
78
+ .catch(() => {
79
+ // Best-effort usage analytics: never affect seller request handling.
80
+ });
81
+ }
82
+ extractHeader(source, name) {
83
+ const headers = source?.headers ?? {};
84
+ if (typeof headers.get === "function")
85
+ return headers.get(name);
86
+ const direct = headers[name] ?? headers[name.toLowerCase()];
87
+ return Array.isArray(direct) ? direct[0] : direct ?? null;
88
+ }
89
+ expressPath(req) {
90
+ return req.originalUrl || req.url || req.path || "/";
91
+ }
92
+ expressIp(req) {
93
+ const forwarded = this.extractHeader(req, "x-forwarded-for")?.split(",")[0]?.trim();
94
+ return forwarded || this.extractHeader(req, "x-real-ip") || req.ip || req.socket?.remoteAddress || null;
95
+ }
96
+ fastifyPath(req) {
97
+ return req.url || req.routerPath || "/";
98
+ }
99
+ normalizeTrustSignals(signals) {
100
+ return signals?.length ? [...signals].sort() : [];
101
+ }
42
102
  /**
43
103
  * Create Express/Connect middleware that gates access + tracks usage.
44
104
  *
@@ -63,7 +123,8 @@ class ValironOperator {
63
123
  const gateConfig = {
64
124
  sdk: this.sdk,
65
125
  minScore: config.minTrustScore ?? 45,
66
- ttlMs: config.ttlMs,
126
+ trustSignals: config.trustSignals,
127
+ cacheTtlMs: config.cacheTtlMs ?? config.ttlMs,
67
128
  onDeny: config.onDeny,
68
129
  onAllow: (req, result) => {
69
130
  // Enrich the gate result with pricing
@@ -74,13 +135,55 @@ class ValironOperator {
74
135
  },
75
136
  };
76
137
  const middleware = (0, middleware_js_1.createValironGate)(gateConfig);
138
+ const withUsageLogging = (req, res, next) => {
139
+ const startedAt = Date.now();
140
+ let logged = false;
141
+ const logOnce = () => {
142
+ if (logged)
143
+ return;
144
+ logged = true;
145
+ const gate = req.valiron;
146
+ const statusCode = res.statusCode;
147
+ const allowed = Boolean(gate?.allow);
148
+ const chargeable = allowed && statusCode >= 200 && statusCode < 400;
149
+ const errorMessage = !allowed
150
+ ? "gate_denied"
151
+ : statusCode >= 400
152
+ ? `downstream_${statusCode}`
153
+ : undefined;
154
+ const agentId = gate?.agentId ||
155
+ this.extractHeader(req, "x-agent-id") ||
156
+ this.extractHeader(req, "x-agent-address") ||
157
+ this.extractHeader(req, "x-agent-key-hash");
158
+ this.recordUsage({
159
+ agentId,
160
+ agentLabel: gate?.tier ? `${gate.tier}:${gate.route}` : undefined,
161
+ sessionId: this.extractHeader(req, "x-valiron-session-id") || this.extractHeader(req, "x-request-id"),
162
+ chain: gate?.chain?.network || this.extractHeader(req, "x-chain"),
163
+ path: this.expressPath(req).split("?")[0] || "/",
164
+ method: req.method || "GET",
165
+ statusCode,
166
+ priceCharged: chargeable ? config.pricePerCall : 0,
167
+ responseMs: Date.now() - startedAt,
168
+ userAgent: this.extractHeader(req, "user-agent"),
169
+ ipAddress: this.expressIp(req),
170
+ errorMessage,
171
+ trustSignals: config.trustSignals,
172
+ });
173
+ };
174
+ if (typeof res.once === "function") {
175
+ res.once("finish", logOnce);
176
+ res.once("close", logOnce);
177
+ }
178
+ return middleware(req, res, next);
179
+ };
77
180
  if (this.debug) {
78
181
  return async (req, res, next) => {
79
182
  console.log(`[ValironOperator] Gate check for ${req.headers?.["x-agent-id"] || "unknown"} @ $${config.pricePerCall}/call`);
80
- return middleware(req, res, next);
183
+ return withUsageLogging(req, res, next);
81
184
  };
82
185
  }
83
- return middleware;
186
+ return withUsageLogging;
84
187
  }
85
188
  /**
86
189
  * Create a Fastify plugin that gates access + tracks usage.
@@ -98,7 +201,8 @@ class ValironOperator {
98
201
  const pluginConfig = {
99
202
  sdk: this.sdk,
100
203
  minScore: config.minTrustScore ?? 45,
101
- ttlMs: config.ttlMs,
204
+ trustSignals: config.trustSignals,
205
+ cacheTtlMs: config.cacheTtlMs ?? config.ttlMs,
102
206
  prefix: config.prefix,
103
207
  onDeny: config.onDeny,
104
208
  onAllow: (req, result) => {
@@ -109,7 +213,51 @@ class ValironOperator {
109
213
  },
110
214
  };
111
215
  return (fastify, opts, done) => {
112
- (0, middleware_js_1.valironFastifyPlugin)(fastify, { ...pluginConfig, ...opts }).then(() => done()).catch(done);
216
+ fastify.addHook?.("onRequest", async (request) => {
217
+ request.valironUsageStartedAt = Date.now();
218
+ });
219
+ (0, middleware_js_1.valironFastifyPlugin)(fastify, { ...pluginConfig, ...opts }).then(() => {
220
+ fastify.addHook?.("onResponse", async (request, reply) => {
221
+ const rawUrl = request.url || "";
222
+ if (config.prefix) {
223
+ const pathname = rawUrl.split("?")[0];
224
+ const prefix = config.prefix.endsWith("/") && config.prefix !== "/"
225
+ ? config.prefix.slice(0, -1)
226
+ : config.prefix;
227
+ if (pathname !== prefix && !pathname.startsWith(prefix + "/"))
228
+ return;
229
+ }
230
+ const gate = request.valiron;
231
+ const statusCode = reply.statusCode;
232
+ const allowed = Boolean(gate?.allow);
233
+ const chargeable = allowed && statusCode >= 200 && statusCode < 400;
234
+ const errorMessage = !allowed
235
+ ? "gate_denied"
236
+ : statusCode >= 400
237
+ ? `downstream_${statusCode}`
238
+ : undefined;
239
+ const agentId = gate?.agentId ||
240
+ this.extractHeader(request, "x-agent-id") ||
241
+ this.extractHeader(request, "x-agent-address") ||
242
+ this.extractHeader(request, "x-agent-key-hash");
243
+ this.recordUsage({
244
+ agentId,
245
+ agentLabel: gate?.tier ? `${gate.tier}:${gate.route}` : undefined,
246
+ sessionId: this.extractHeader(request, "x-valiron-session-id") || this.extractHeader(request, "x-request-id"),
247
+ chain: gate?.chain?.network || this.extractHeader(request, "x-chain"),
248
+ path: this.fastifyPath(request).split("?")[0] || "/",
249
+ method: request.method || "GET",
250
+ statusCode,
251
+ priceCharged: chargeable ? config.pricePerCall : 0,
252
+ responseMs: Date.now() - (request.valironUsageStartedAt || Date.now()),
253
+ userAgent: this.extractHeader(request, "user-agent"),
254
+ ipAddress: request.ip || this.extractHeader(request, "x-forwarded-for")?.split(",")[0]?.trim() || null,
255
+ errorMessage,
256
+ trustSignals: config.trustSignals,
257
+ });
258
+ });
259
+ done();
260
+ }).catch(done);
113
261
  };
114
262
  }
115
263
  /**
package/dist/telemetry.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TelemetryClient = void 0;
4
- const SDK_VERSION = "0.5.0";
4
+ const SDK_VERSION = "1.0.2";
5
5
  function detectRuntime() {
6
6
  return typeof globalThis.window === "undefined" ? "node" : "browser";
7
7
  }
package/dist/types.d.ts CHANGED
@@ -9,6 +9,7 @@ export type SupportedChain = "ethereum" | "monad" | "arbitrum" | "base" | "avala
9
9
  export type RouteDecision = "prod" | "prod_throttled" | "sandbox" | "sandbox_only";
10
10
  export type RiskLevel = "GREEN" | "YELLOW" | "RED";
11
11
  export type MoodysRating = "AAA" | "AA" | "A" | "BAA" | "BA" | "B" | "CAA" | "CA" | "C";
12
+ export type TrustSignal = "8004" | "sandbox" | "world" | "icebreaker";
12
13
  export interface AgentIdentity {
13
14
  agentId: string;
14
15
  wallet: string;
@@ -152,6 +153,20 @@ export interface SandboxResult {
152
153
  chain: ChainContext;
153
154
  message: string;
154
155
  }
156
+ /**
157
+ * Response from `POST /operator/trigger-sandbox-key/:agentAddress`
158
+ *
159
+ * Same scoring as on-chain agents, but keyed by agent address instead of
160
+ * on-chain agent ID.
161
+ */
162
+ export interface KeyAgentSandboxResult {
163
+ ok: boolean;
164
+ agentAddress: string;
165
+ valironScore: number;
166
+ tier: MoodysRating;
167
+ riskLevel: RiskLevel;
168
+ message: string;
169
+ }
155
170
  /**
156
171
  * Response from `GET /operator/agent/:agentId/snapshot`
157
172
  *
@@ -178,6 +193,8 @@ export interface GateOptions {
178
193
  minScore?: number;
179
194
  /** TTL in ms for cached sandbox results. Stale results trigger re-testing (default: 86400000 = 24 h). */
180
195
  ttlMs?: number;
196
+ /** Customer-selected scoring signals. Free plans support 8004+sandbox; Pro adds world+icebreaker. */
197
+ trustSignals?: TrustSignal[];
181
198
  /** Override the blockchain network for this call. */
182
199
  chain?: SupportedChain;
183
200
  }
@@ -340,7 +357,7 @@ export interface KeyAgentProfile {
340
357
  agentAddress: string;
341
358
  /** Whether identity has been verified via challenge-response */
342
359
  verified: boolean;
343
- /** Behavioral score (0-110) — same scoring as ERC-8004 agents */
360
+ /** Behavioral score (0-100) — same scoring as ERC-8004 agents */
344
361
  score: number | null;
345
362
  /** Moody's-style tier (AAA → C) */
346
363
  tier: MoodysRating | null;
@@ -362,6 +379,8 @@ export interface CallOptions {
362
379
  * Takes precedence over the default chain set in the constructor.
363
380
  */
364
381
  chain?: SupportedChain;
382
+ /** Customer-selected scoring signals for profile/routing calls. */
383
+ trustSignals?: TrustSignal[];
365
384
  }
366
385
  export type TelemetryEnvironment = "prod" | "staging" | "dev";
367
386
  export interface TelemetryEventBase {
@@ -404,7 +423,9 @@ export interface ValironConfig {
404
423
  */
405
424
  chain?: SupportedChain;
406
425
  /**
407
- * Request timeout in milliseconds (default: 5000)
426
+ * Request timeout in milliseconds. When omitted, the SDK uses method-aware
427
+ * defaults: 10s generally, 15s for gate/proxy calls, and 30s for sandbox
428
+ * triggers. When set, this value overrides all method-aware defaults.
408
429
  */
409
430
  timeout?: number;
410
431
  /**
@@ -146,7 +146,7 @@ Execute real-time sandbox tests against an agent and compute a trust evaluation.
146
146
 
147
147
  ## POST /operator/gate/:agentId
148
148
 
149
- Trust gate — combined on-chain reputation + sandbox check. Returns an allow/deny decision. Designed for protecting payment endpoints (x402, etc.).
149
+ Trust gate — selected trust signals scored on a normalized `0-100` scale. Returns an allow/deny decision. Designed for protecting payment endpoints (x402, etc.).
150
150
 
151
151
  ### Parameters
152
152
 
@@ -158,12 +158,16 @@ Trust gate — combined on-chain reputation + sandbox check. Returns an allow/de
158
158
 
159
159
  ```json
160
160
  {
161
+ "minScore": 65,
162
+ "trustSignals": ["8004", "sandbox"],
161
163
  "ttlMs": 86400000
162
164
  }
163
165
  ```
164
166
 
165
167
  | Field | Type | Default | Description |
166
168
  |-------|------|---------|-------------|
169
+ | `minScore` | number | 65 | Minimum normalized trust score required to allow. Must be between 0 and 100. |
170
+ | `trustSignals` | string[] | auto | Optional selected signals: `8004`, `sandbox`, `world`, `icebreaker`. Free plans support `8004` + `sandbox`; Pro adds `world` + `icebreaker`. |
167
171
  | `ttlMs` | number | 86400000 | Cache TTL in milliseconds (default 24 hours) |
168
172
 
169
173
  ### Response — 200 OK
package/docs/ERRORS.md CHANGED
@@ -94,7 +94,7 @@ First-time agents that haven't been sandbox-tested yet receive provisional score
94
94
 
95
95
  ### Timeout errors
96
96
 
97
- The default SDK timeout is 5 seconds. For sandbox tests (which run real evaluations), increase it:
97
+ The SDK uses method-aware default timeouts: 10 seconds generally, 15 seconds for `gate()`/`proxy()`, and 30 seconds for sandbox triggers. To force a single timeout for all calls, configure it explicitly:
98
98
 
99
99
  ```typescript
100
100
  const valiron = new ValironSDK({ timeout: 30000 }); // 30 seconds
@@ -26,7 +26,7 @@ import { ValironSDK } from "@valiron/sdk";
26
26
  const valiron = new ValironSDK({
27
27
  endpoint: "https://valiron-edge-proxy.onrender.com",
28
28
  chain: "ethereum", // or: monad, arbitrum, base, polygon, solana, etc.
29
- timeout: 5000,
29
+ // timeout: 30000, // optional override for all calls
30
30
  });
31
31
  ```
32
32
 
@@ -66,19 +66,34 @@ import { createValironGate } from "@valiron/sdk";
66
66
  app.use("/api/paid", createValironGate({ sdk: valiron }));
67
67
  ```
68
68
 
69
- This reads `x-agent-id` from the request header and returns 403 for untrusted agents.
69
+ This reads `x-agent-id` from the request header, checks trust via the public agent profile endpoint, and returns 403 for untrusted agents. It's safe with Express 4 (async errors are handled) and includes a 30-second client-side cache for x402 compatibility.
70
70
 
71
- Or use `gate()` directly for custom logic:
71
+ You can also choose which trust signals an endpoint uses:
72
72
 
73
73
  ```typescript
74
- const gate = await valiron.gate("INCOMING_AGENT_ID");
75
- if (gate.allow) {
74
+ app.use("/api/paid", createValironGate({
75
+ sdk: valiron,
76
+ trustSignals: ["8004", "sandbox"], // Free
77
+ minScore: 70,
78
+ }));
79
+ ```
80
+
81
+ Free plans support `8004` and `sandbox`. Pro plans can also include `world` and `icebreaker`.
82
+
83
+ Or use `getAgentProfile()` directly for custom logic:
84
+
85
+ ```typescript
86
+ const profile = await valiron.getAgentProfile("INCOMING_AGENT_ID");
87
+ const { finalRoute, decision } = profile.routing;
88
+ if (finalRoute === "prod" || finalRoute === "prod_throttled") {
76
89
  // Serve the request — agent is trusted
77
90
  } else {
78
- // Block — agent is untrusted (tier: gate.tier, risk: gate.riskLevel)
91
+ // Block — agent is untrusted (tier: profile.localReputation?.tier)
79
92
  }
80
93
  ```
81
94
 
95
+ > **Note**: The `gate()` method calls a protected endpoint that requires agent challenge-response auth. Use the middleware (`createValironGate`) or `getAgentProfile()` for server-side trust checks.
96
+
82
97
  ## What happens next?
83
98
 
84
99
  Based on the route decision, your API should:
@@ -93,13 +108,20 @@ Based on the route decision, your API should:
93
108
  Proactively evaluate an agent before they hit your endpoints:
94
109
 
95
110
  ```typescript
111
+ // On-chain agents
96
112
  const result = await valiron.triggerSandboxTest("AGENT_ID");
97
113
 
98
114
  console.log(result.tier); // "AAA"
99
115
  console.log(result.riskLevel); // "GREEN"
100
116
  console.log(result.meetsThreshold); // true
117
+
118
+ // Key-based (Web2) agents
119
+ const keyResult = await valiron.triggerKeyAgentSandbox("0x1234...abcd");
120
+ console.log(keyResult.tier); // "A"
101
121
  ```
102
122
 
123
+ > **Auto-sandbox:** You usually don't need to call these manually. When a new agent (on-chain with `totalFeedback === 0`, or key-based with no score yet) hits a gated endpoint, the middleware automatically triggers sandbox evaluation in the background. The agent receives a `403` with `{ error: "Agent pending evaluation", retryAfterMs: 30000 }` — they should retry after 30 seconds.
124
+
103
125
  ## Step 7 — Register a webhook (optional)
104
126
 
105
127
  Get notified whenever Valiron evaluates an agent calling your API:
@@ -128,6 +150,9 @@ curl https://valiron-edge-proxy.onrender.com/operator/agent/AGENT_ID
128
150
  # Trigger sandbox evaluation
129
151
  curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/AGENT_ID
130
152
 
153
+ # Trigger sandbox for key-based agent
154
+ curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox-key/0x1234...abcd
155
+
131
156
  # Gate decision (allow/deny)
132
157
  curl -X POST https://valiron-edge-proxy.onrender.com/operator/gate/AGENT_ID
133
158
 
package/docs/SANDBOX.md CHANGED
@@ -26,7 +26,7 @@ Once graduated, the trust evaluation is cached. The route decision persists unti
26
26
 
27
27
  ## Triggering a Sandbox Test
28
28
 
29
- You can proactively evaluate agents before they hit your production endpoints.
29
+ You can proactively evaluate agents before they hit your production endpoints, or let the middleware handle it automatically (see Auto-Sandbox below).
30
30
 
31
31
  ### Via SDK
32
32
 
@@ -34,17 +34,67 @@ You can proactively evaluate agents before they hit your production endpoints.
34
34
  import { ValironSDK } from "@valiron/sdk";
35
35
 
36
36
  const valiron = new ValironSDK();
37
+
38
+ // On-chain agent
37
39
  const result = await valiron.triggerSandboxTest("YOUR_AGENT_ID");
38
40
 
39
41
  console.log(result.tier); // "AAA"
40
42
  console.log(result.riskLevel); // "GREEN"
41
43
  console.log(result.meetsThreshold); // true
44
+
45
+ // Key-based agent
46
+ const keyResult = await valiron.triggerKeyAgentSandbox("0x1234...abcd");
47
+ console.log(keyResult.tier); // "A"
42
48
  ```
43
49
 
44
50
  ### Via HTTP
45
51
 
46
52
  ```bash
53
+ # On-chain agent
47
54
  curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/YOUR_AGENT_ID
55
+
56
+ # Key-based agent
57
+ curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox-key/0x1234...abcd
58
+ ```
59
+
60
+ ## Auto-Sandbox
61
+
62
+ When a new agent hits a gated endpoint for the first time, the middleware automatically triggers sandbox evaluation in the background. No manual trigger is needed.
63
+
64
+ ### On-Chain Agents (ERC-8004)
65
+
66
+ New on-chain agents are detected by `totalFeedback === 0` in their reputation profile. The middleware calls `triggerSandboxTest()` as a fire-and-forget background task and returns:
67
+
68
+ ```json
69
+ { "error": "Agent pending evaluation", "retryAfterMs": 30000 }
70
+ ```
71
+
72
+ The agent should retry after 30 seconds. Once evaluation completes, subsequent requests are gated normally.
73
+
74
+ ### Key-Based Agents (Web2)
75
+
76
+ New key agents are detected by `verified === true` but `score === null`. The middleware calls `triggerKeyAgentSandbox()` in the background and returns the same 403 pending response.
77
+
78
+ Key agents don't have on-chain endpoints, so sandbox evaluation uses `sandbox_relay` mode — a conservative set of behavioral metrics are computed without probing endpoints.
79
+
80
+ #### Via SDK
81
+
82
+ ```typescript
83
+ // On-chain agent
84
+ const result = await valiron.triggerSandboxTest("YOUR_AGENT_ID");
85
+
86
+ // Key-based agent
87
+ const result = await valiron.triggerKeyAgentSandbox("0x1234...abcd");
88
+ ```
89
+
90
+ #### Via HTTP
91
+
92
+ ```bash
93
+ # On-chain agent
94
+ curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/YOUR_AGENT_ID
95
+
96
+ # Key-based agent
97
+ curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox-key/0x1234...abcd
48
98
  ```
49
99
 
50
100
  ## Tips for Passing Sandbox Tests