@valiron/sdk 0.9.2 → 0.10.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/dist/types.d.ts CHANGED
@@ -102,6 +102,25 @@ export interface WalletProfile {
102
102
  localReputation: LocalReputation | null;
103
103
  routing: RoutingExplanation;
104
104
  chain: ChainContext;
105
+ /** How the wallet was resolved to an agentId. */
106
+ resolutionSource?: "redis" | "subgraph" | "cache" | "none";
107
+ timestamp: string;
108
+ }
109
+ /**
110
+ * Response from `GET /operator/resolve-wallet/:wallet`
111
+ *
112
+ * Lightweight wallet → agentId resolution without the full trust profile.
113
+ */
114
+ export type ResolutionSource = "redis" | "subgraph" | "cache" | "none";
115
+ export interface WalletResolution {
116
+ wallet: string;
117
+ agentId: string | null;
118
+ /** How the wallet was resolved. */
119
+ source: ResolutionSource;
120
+ /** Chain ID of the resolved agent (from subgraph), if available */
121
+ chainId?: number | null;
122
+ /** Agent name (from subgraph), if available */
123
+ agentName?: string | null;
105
124
  timestamp: string;
106
125
  }
107
126
  /**
@@ -117,6 +136,26 @@ export interface SandboxResult {
117
136
  chain: ChainContext;
118
137
  message: string;
119
138
  }
139
+ /**
140
+ * Response from `GET /operator/agent/:agentId/snapshot`
141
+ *
142
+ * Opaque behavioral snapshot hash for hash-chain commitments.
143
+ * Contains no raw metrics — only the deterministic hash, the previous
144
+ * hash in the chain, and metadata.
145
+ */
146
+ export interface AgentSnapshotSummary {
147
+ agentId: string;
148
+ /** Deterministic SHA-256 hash of the behavioral evaluation. Opaque — cannot be reversed to raw metrics. */
149
+ snapshotHash: string;
150
+ /** Hash of the prior snapshot, or "0x0" for the first evaluation. */
151
+ previousHash: string;
152
+ /** IPFS CID of the encrypted full snapshot data, or null if unavailable. */
153
+ encryptedDataUri: string | null;
154
+ /** ISO 8601 timestamp of when the evaluation was performed. */
155
+ timestamp: string | null;
156
+ /** Total number of interactions in the evaluation window. */
157
+ interactionCount: number;
158
+ }
120
159
  /** Options for `gate()` call. */
121
160
  export interface GateOptions {
122
161
  /** Minimum Valiron score to allow (default: 65 = BA tier). */
@@ -144,6 +183,8 @@ export interface GateResult {
144
183
  sandboxRan: boolean;
145
184
  /** Whether cached results were used. */
146
185
  cached: boolean;
186
+ /** Whether the score is from a micro-sandbox (fast, limited coverage). When true, a full deep test is running in the background and will update the cached score. */
187
+ provisional?: boolean;
147
188
  }
148
189
  /** Options that can be passed to individual SDK method calls. */
149
190
  export interface CallOptions {
@@ -77,6 +77,34 @@ Same structure as `GET /operator/agent/:agentId`.
77
77
 
78
78
  ---
79
79
 
80
+ ## GET /operator/resolve-wallet/:wallet
81
+
82
+ Lightweight wallet → agentId resolution. Returns just the agent ID and how it was resolved, without the full trust profile.
83
+
84
+ Resolution chain: Redis → Agent0 subgraph → null.
85
+
86
+ ### Parameters
87
+
88
+ | Parameter | Location | Type | Required | Description |
89
+ |-----------|----------|------|----------|-------------|
90
+ | `wallet` | path | string | yes | Ethereum address (0x...) |
91
+ | `chain` | query | string | no | Network override (default: ethereum) |
92
+
93
+ ### Response — 200 OK
94
+
95
+ ```json
96
+ {
97
+ "wallet": "0x52ce...",
98
+ "agentId": "25459",
99
+ "source": "subgraph",
100
+ "chainId": 1,
101
+ "agentName": "MyAgent",
102
+ "timestamp": "2024-01-01T00:00:00.000Z"
103
+ }
104
+ ```
105
+
106
+ ---
107
+
80
108
  ## POST /operator/trigger-sandbox/:agentId
81
109
 
82
110
  Execute real-time sandbox tests against an agent and compute a trust evaluation.
@@ -166,6 +194,90 @@ Trust gate — combined on-chain reputation + sandbox check. Returns an allow/de
166
194
 
167
195
  ---
168
196
 
197
+ ## GET /operator/agent/:agentId/snapshot
198
+
199
+ Get the latest behavioral snapshot hash for an agent. Returns an opaque hash suitable for on-chain commitment systems.
200
+
201
+ ### Parameters
202
+
203
+ | Parameter | Location | Type | Required | Description |
204
+ |-----------|----------|------|----------|-------------|
205
+ | `agentId` | path | string | yes | ERC-8004 token ID |
206
+ | `chain` | query | string | no | Network override |
207
+
208
+ ### Response — 200 OK
209
+
210
+ ```json
211
+ {
212
+ "agentId": "25459",
213
+ "snapshotHash": "0x3a7f2b...",
214
+ "previousHash": "0x0",
215
+ "encryptedDataUri": null,
216
+ "timestamp": "2026-04-01T12:00:00.000Z",
217
+ "interactionCount": 15
218
+ }
219
+ ```
220
+
221
+ ### Error Responses
222
+
223
+ | Status | Meaning |
224
+ |--------|---------|
225
+ | 400 | Invalid agentId |
226
+ | 404 | Agent not found or no snapshot available (trigger a sandbox evaluation first) |
227
+ | 500 | Internal server error |
228
+
229
+ ---
230
+
231
+ ## POST /operator/webhooks/register
232
+
233
+ Register a webhook URL to receive `evaluation_complete` events whenever Valiron evaluates an agent.
234
+
235
+ ### Request Body
236
+
237
+ ```json
238
+ {
239
+ "event": "evaluation_complete",
240
+ "url": "https://your-endpoint.com/hooks/valiron",
241
+ "agentIds": [42, 43]
242
+ }
243
+ ```
244
+
245
+ | Field | Type | Required | Description |
246
+ |-------|------|----------|-------------|
247
+ | `event` | string | yes | Must be `"evaluation_complete"` |
248
+ | `url` | string | yes | HTTPS endpoint to receive webhook POST requests |
249
+ | `agentIds` | number[] | no | Filter to specific agent IDs. Omit for all agents. |
250
+
251
+ ### Response — 201 Created
252
+
253
+ ```json
254
+ {
255
+ "id": "a1b2c3d4-...",
256
+ "event": "evaluation_complete",
257
+ "url": "https://your-endpoint.com/hooks/valiron",
258
+ "agentIds": [42, 43],
259
+ "createdAt": "2026-04-01T12:00:00.000Z"
260
+ }
261
+ ```
262
+
263
+ ### Webhook Payload
264
+
265
+ When an evaluation completes, Valiron POSTs the following to your registered URL:
266
+
267
+ ```json
268
+ {
269
+ "event": "evaluation_complete",
270
+ "agentId": "25459",
271
+ "snapshotHash": "0x3a7f2b...",
272
+ "previousHash": "0x8b2c1a...",
273
+ "encryptedDataUri": null,
274
+ "timestamp": "2026-04-01T12:05:00.000Z",
275
+ "interactionCount": 16
276
+ }
277
+ ```
278
+
279
+ ---
280
+
169
281
  ## GET /operator/health
170
282
 
171
283
  Health check endpoint.
@@ -57,6 +57,28 @@ console.log(result.meetsThreshold); // true
57
57
  - If your route is `sandbox` — your behavior is being evaluated. Follow the guidelines in [TRUST-MODEL.md](./TRUST-MODEL.md) to improve.
58
58
  - If your route is `sandbox_only` — you are blocked from production. Review your behavioral penalties.
59
59
 
60
+ ## Step 6 — Get a behavioral snapshot (optional)
61
+
62
+ If you're building on top of Valiron (e.g. hash-chain commitment systems), you can retrieve an opaque snapshot hash:
63
+
64
+ ```typescript
65
+ const snapshot = await valiron.getAgentSnapshot("YOUR_AGENT_ID");
66
+
67
+ console.log(snapshot.snapshotHash); // "0x3a7f..." (opaque hash of behavioral evaluation)
68
+ console.log(snapshot.previousHash); // "0x0" (genesis) or previous hash
69
+ console.log(snapshot.interactionCount); // 15
70
+ ```
71
+
72
+ ## Step 7 — Register a webhook (optional)
73
+
74
+ Get notified whenever Valiron evaluates an agent:
75
+
76
+ ```bash
77
+ curl -X POST https://valiron-edge-proxy.onrender.com/operator/webhooks/register \
78
+ -H "Content-Type: application/json" \
79
+ -d '{"event": "evaluation_complete", "url": "https://your-endpoint.com/hooks/valiron"}'
80
+ ```
81
+
60
82
  ## Using the HTTP API directly (no SDK)
61
83
 
62
84
  ```bash
@@ -68,4 +90,12 @@ curl -X POST https://valiron-edge-proxy.onrender.com/operator/trigger-sandbox/YO
68
90
 
69
91
  # Trust gate (allow/deny decision)
70
92
  curl -X POST https://valiron-edge-proxy.onrender.com/operator/gate/YOUR_AGENT_ID
93
+
94
+ # Behavioral snapshot hash
95
+ curl https://valiron-edge-proxy.onrender.com/operator/agent/YOUR_AGENT_ID/snapshot
96
+
97
+ # Register webhook
98
+ curl -X POST https://valiron-edge-proxy.onrender.com/operator/webhooks/register \
99
+ -H "Content-Type: application/json" \
100
+ -d '{"event": "evaluation_complete", "url": "https://your-endpoint.com/hooks"}'
71
101
  ```
@@ -120,6 +120,37 @@ console.log(profile.routing.finalRoute);
120
120
 
121
121
  ---
122
122
 
123
+ ### resolveWallet(wallet, options?)
124
+
125
+ Lightweight wallet → agentId resolution without the full trust profile. Useful when you only need to know which agent owns a wallet (e.g. after extracting a wallet from an x402 payment header).
126
+
127
+ Resolution chain: Redis → in-memory cache → Agent0 subgraph → null.
128
+
129
+ Signature: `resolveWallet(wallet: string, options?: { chain?: SupportedChain }): Promise<WalletResolution>`
130
+
131
+ **Returns**: `WalletResolution`
132
+
133
+ ```typescript
134
+ interface WalletResolution {
135
+ wallet: string;
136
+ agentId: string | null;
137
+ source: "redis" | "subgraph" | "cache" | "none";
138
+ chainId?: number | null;
139
+ agentName?: string | null;
140
+ timestamp: string;
141
+ }
142
+ ```
143
+
144
+ **Example**:
145
+ ```typescript
146
+ const resolution = await valiron.resolveWallet("0x52ce...");
147
+ if (resolution.agentId) {
148
+ const profile = await valiron.getAgentProfile(resolution.agentId);
149
+ }
150
+ ```
151
+
152
+ ---
153
+
123
154
  ### triggerSandboxTest(agentId, options?)
124
155
 
125
156
  Run sandbox tests against an agent and compute a trust evaluation.
@@ -203,6 +234,44 @@ if (result.allow) {
203
234
 
204
235
  ---
205
236
 
237
+ ### getAgentSnapshot(agentId, options?)
238
+
239
+ Get the latest behavioral snapshot hash for an agent. Returns an opaque hash of the most recent behavioral evaluation — designed for hash-chain commitment systems that need to commit behavioral state on-chain without accessing raw metrics.
240
+
241
+ ```typescript
242
+ const snapshot = await valiron.getAgentSnapshot(agentId: string, options?: {
243
+ chain?: SupportedChain;
244
+ }): Promise<AgentSnapshotSummary>;
245
+ ```
246
+
247
+ **Returns**: `AgentSnapshotSummary`
248
+
249
+ ```typescript
250
+ interface AgentSnapshotSummary {
251
+ agentId: string;
252
+ snapshotHash: string; // deterministic SHA-256 hash of behavioral evaluation (opaque)
253
+ previousHash: string; // hash from prior evaluation, or "0x0" for first
254
+ encryptedDataUri: string | null; // IPFS CID of encrypted snapshot data, if available
255
+ timestamp: string | null; // ISO 8601 timestamp of evaluation
256
+ interactionCount: number; // total interactions in the evaluation window
257
+ }
258
+ ```
259
+
260
+ **Example**:
261
+ ```typescript
262
+ const snapshot = await valiron.getAgentSnapshot("25459");
263
+ console.log(snapshot.snapshotHash); // "0x3a7f..."
264
+ console.log(snapshot.previousHash); // "0x0" (genesis) or "0x8b2c..."
265
+ console.log(snapshot.interactionCount); // 15
266
+ ```
267
+
268
+ **Notes**:
269
+ - The `snapshotHash` is computed internally by Valiron from behavioral metrics. It is opaque — you cannot reverse it to raw metrics.
270
+ - Each hash references the `previousHash`, forming a chain. First evaluation gets `"0x0"`.
271
+ - Trigger a sandbox evaluation first if no snapshot exists (returns 404 otherwise).
272
+
273
+ ---
274
+
206
275
  ### createValironGate(config)
207
276
 
208
277
  Express-compatible middleware factory. Automatically gates requests based on agent trust.
package/docs/llms.txt CHANGED
@@ -21,6 +21,13 @@ POST /operator/trigger-sandbox/{agentId}
21
21
  POST /operator/gate/{agentId}
22
22
  Body: { "ttlMs": 86400000 }
23
23
 
24
+ ### Behavioral snapshot hash
25
+ GET /operator/agent/{agentId}/snapshot
26
+
27
+ ### Register webhook
28
+ POST /operator/webhooks/register
29
+ Body: { "event": "evaluation_complete", "url": "https://your-endpoint.com/hooks", "agentIds": [42] }
30
+
24
31
  ### Health check
25
32
  GET /operator/health
26
33
 
@@ -42,6 +49,11 @@ const profile = await valiron.getAgentProfile("AGENT_ID");
42
49
  // Trust gate (allow/deny for payments)
43
50
  const gate = await valiron.gate("AGENT_ID");
44
51
  if (gate.allow) { /* proceed */ }
52
+
53
+ // Behavioral snapshot (for hash-chain commitments)
54
+ const snapshot = await valiron.getAgentSnapshot("AGENT_ID");
55
+ console.log(snapshot.snapshotHash); // "0xabc..."
56
+ console.log(snapshot.previousHash); // "0x0" (genesis)
45
57
  ```
46
58
 
47
59
  ## Trust Tiers
@@ -82,6 +94,7 @@ ethereum, monad, arbitrum, base, avalanche, celo, polygon, linea, abstract, bsc,
82
94
 
83
95
  ## Documentation
84
96
 
97
+ - [Full documentation (llms-full.txt)](https://valiron.co/llms-full.txt) — Complete AI-optimized documentation in a single file
85
98
  - docs/agents/README.md — Index
86
99
  - docs/agents/QUICKSTART.md — Get started
87
100
  - docs/agents/API-REFERENCE.md — HTTP API reference
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valiron/sdk",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "description": "Official TypeScript SDK for Valiron - Trust Layer for Agentic Economy",
5
5
  "repository": {
6
6
  "type": "git",