@valiron/sdk 0.1.1 → 0.3.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/README.md +177 -316
- package/dist/clients.d.ts +30 -74
- package/dist/clients.d.ts.map +1 -1
- package/dist/clients.js +75 -122
- package/dist/clients.js.map +1 -1
- package/dist/index.d.ts +68 -83
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +74 -85
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +120 -73
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -2
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/clients.d.ts
CHANGED
|
@@ -1,90 +1,46 @@
|
|
|
1
|
-
import { ValironConfig,
|
|
1
|
+
import { ValironConfig, AgentProfile, WalletProfile, SandboxResult, CallOptions } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* HTTP client for the Valiron Operator API.
|
|
4
|
+
*
|
|
5
|
+
* All methods map 1-to-1 to the /operator/* endpoints exposed by the
|
|
6
|
+
* Valiron edge-proxy service.
|
|
4
7
|
*/
|
|
5
|
-
export declare class
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
export declare class ValironClient {
|
|
9
|
+
private endpoint;
|
|
10
|
+
private apiKey?;
|
|
11
|
+
private defaultChain?;
|
|
12
|
+
private timeout;
|
|
13
|
+
private debug;
|
|
10
14
|
constructor(config?: ValironConfig);
|
|
15
|
+
/** Resolve the effective chain: per-call override > constructor default > undefined (server default). */
|
|
16
|
+
private resolveChain;
|
|
11
17
|
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
private buildHeaders;
|
|
15
|
-
/**
|
|
16
|
-
* Make a GET request to Valiron API
|
|
17
|
-
*/
|
|
18
|
-
protected get<T>(path: string, params?: Record<string, string>, extraHeaders?: Record<string, string>): Promise<T>;
|
|
19
|
-
/**
|
|
20
|
-
* Make a POST request to Valiron API
|
|
21
|
-
*/
|
|
22
|
-
protected post<T>(path: string, body?: any): Promise<T>;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Client for agent trust and routing operations
|
|
26
|
-
*/
|
|
27
|
-
export declare class TrustClient extends BaseClient {
|
|
28
|
-
/**
|
|
29
|
-
* Check agent routing decision
|
|
18
|
+
* Get the complete trust profile for an agent.
|
|
30
19
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
20
|
+
* Combines ERC-8004 on-chain identity, on-chain reputation, local
|
|
21
|
+
* behavioral reputation, and a hybrid routing decision.
|
|
33
22
|
*
|
|
34
|
-
*
|
|
35
|
-
* @returns Routing decision with explanation
|
|
23
|
+
* `GET /operator/agent/:agentId`
|
|
36
24
|
*/
|
|
37
|
-
|
|
25
|
+
getAgentProfile(agentId: string, options?: CallOptions): Promise<AgentProfile>;
|
|
38
26
|
/**
|
|
39
|
-
*
|
|
27
|
+
* Get a trust profile by wallet address (reverse lookup).
|
|
40
28
|
*
|
|
41
|
-
*
|
|
42
|
-
* @returns Routing decision with explanation
|
|
29
|
+
* `GET /operator/wallet/:wallet`
|
|
43
30
|
*/
|
|
44
|
-
|
|
31
|
+
getWalletProfile(wallet: string, options?: CallOptions): Promise<WalletProfile>;
|
|
45
32
|
/**
|
|
46
|
-
*
|
|
33
|
+
* Trigger real sandbox testing for an agent.
|
|
47
34
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @returns Complete agent profile
|
|
52
|
-
*/
|
|
53
|
-
getAgentProfile(agentId: string): Promise<AgentProfile>;
|
|
54
|
-
/**
|
|
55
|
-
* Get wallet profile
|
|
35
|
+
* Sends test requests against the agent's HTTP endpoint (if one is
|
|
36
|
+
* registered on-chain) or through the sandbox-api relay, then computes
|
|
37
|
+
* a Valiron score and stores the result.
|
|
56
38
|
*
|
|
57
|
-
*
|
|
58
|
-
* @returns Wallet profile with routing info
|
|
39
|
+
* `POST /operator/trigger-sandbox/:agentId`
|
|
59
40
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
export declare class ReputationClient extends BaseClient {
|
|
66
|
-
/**
|
|
67
|
-
* Submit feedback about an agent's behavior
|
|
68
|
-
*
|
|
69
|
-
* Note: This submits feedback to Valiron, which then handles
|
|
70
|
-
* IPFS upload and on-chain submission on your behalf.
|
|
71
|
-
*
|
|
72
|
-
* @param params - Feedback parameters
|
|
73
|
-
*/
|
|
74
|
-
submitFeedback(params: SubmitFeedbackParams): Promise<{
|
|
75
|
-
success: boolean;
|
|
76
|
-
txHash?: string;
|
|
77
|
-
}>;
|
|
78
|
-
/**
|
|
79
|
-
* Manually trigger sandbox testing for an agent
|
|
80
|
-
*
|
|
81
|
-
* Useful for testing or re-evaluation scenarios.
|
|
82
|
-
*
|
|
83
|
-
* @param params - Sandbox test parameters
|
|
84
|
-
*/
|
|
85
|
-
triggerSandboxTest(params: SandboxTestParams): Promise<{
|
|
86
|
-
success: boolean;
|
|
87
|
-
message: string;
|
|
88
|
-
}>;
|
|
41
|
+
triggerSandboxTest(agentId: string, options?: CallOptions): Promise<SandboxResult>;
|
|
42
|
+
private buildHeaders;
|
|
43
|
+
private get;
|
|
44
|
+
private post;
|
|
89
45
|
}
|
|
90
46
|
//# sourceMappingURL=clients.d.ts.map
|
package/dist/clients.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EAGZ,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,YAAY,CAAC,CAAiB;IACtC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAU;gBAEX,MAAM,GAAE,aAAkB;IAWtC,yGAAyG;IACzG,OAAO,CAAC,YAAY;IAIpB;;;;;;;OAOG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAIpF;;;;OAIG;IACG,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAIrF;;;;;;;;OAQG;IACG,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAMxF,OAAO,CAAC,YAAY;YAUN,GAAG;YAkDH,IAAI;CAkDnB"}
|
package/dist/clients.js
CHANGED
|
@@ -1,44 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ValironClient = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* HTTP client for the Valiron Operator API.
|
|
7
|
+
*
|
|
8
|
+
* All methods map 1-to-1 to the /operator/* endpoints exposed by the
|
|
9
|
+
* Valiron edge-proxy service.
|
|
7
10
|
*/
|
|
8
|
-
class
|
|
11
|
+
class ValironClient {
|
|
9
12
|
constructor(config = {}) {
|
|
10
|
-
this.endpoint =
|
|
13
|
+
this.endpoint =
|
|
14
|
+
config.endpoint || "https://valiron-edge-proxy.onrender.com";
|
|
11
15
|
this.apiKey = config.apiKey;
|
|
16
|
+
this.defaultChain = config.chain;
|
|
12
17
|
this.timeout = config.timeout || 5000;
|
|
13
18
|
this.debug = config.debug || false;
|
|
14
19
|
}
|
|
20
|
+
// ─── Public API ─────────────────────────────────────────────────────────
|
|
21
|
+
/** Resolve the effective chain: per-call override > constructor default > undefined (server default). */
|
|
22
|
+
resolveChain(options) {
|
|
23
|
+
return options?.chain ?? this.defaultChain;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the complete trust profile for an agent.
|
|
27
|
+
*
|
|
28
|
+
* Combines ERC-8004 on-chain identity, on-chain reputation, local
|
|
29
|
+
* behavioral reputation, and a hybrid routing decision.
|
|
30
|
+
*
|
|
31
|
+
* `GET /operator/agent/:agentId`
|
|
32
|
+
*/
|
|
33
|
+
async getAgentProfile(agentId, options) {
|
|
34
|
+
return this.get(`/operator/agent/${agentId}`, this.resolveChain(options));
|
|
35
|
+
}
|
|
15
36
|
/**
|
|
16
|
-
*
|
|
37
|
+
* Get a trust profile by wallet address (reverse lookup).
|
|
38
|
+
*
|
|
39
|
+
* `GET /operator/wallet/:wallet`
|
|
17
40
|
*/
|
|
18
|
-
|
|
41
|
+
async getWalletProfile(wallet, options) {
|
|
42
|
+
return this.get(`/operator/wallet/${wallet}`, this.resolveChain(options));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Trigger real sandbox testing for an agent.
|
|
46
|
+
*
|
|
47
|
+
* Sends test requests against the agent's HTTP endpoint (if one is
|
|
48
|
+
* registered on-chain) or through the sandbox-api relay, then computes
|
|
49
|
+
* a Valiron score and stores the result.
|
|
50
|
+
*
|
|
51
|
+
* `POST /operator/trigger-sandbox/:agentId`
|
|
52
|
+
*/
|
|
53
|
+
async triggerSandboxTest(agentId, options) {
|
|
54
|
+
return this.post(`/operator/trigger-sandbox/${agentId}`, undefined, this.resolveChain(options));
|
|
55
|
+
}
|
|
56
|
+
// ─── HTTP helpers ───────────────────────────────────────────────────────
|
|
57
|
+
buildHeaders() {
|
|
19
58
|
const headers = {
|
|
20
|
-
|
|
59
|
+
"Content-Type": "application/json",
|
|
21
60
|
};
|
|
22
|
-
// Only include Authorization header if apiKey is provided
|
|
23
61
|
if (this.apiKey) {
|
|
24
|
-
headers[
|
|
25
|
-
}
|
|
26
|
-
// Merge extra headers
|
|
27
|
-
if (extraHeaders) {
|
|
28
|
-
Object.assign(headers, extraHeaders);
|
|
62
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
29
63
|
}
|
|
30
64
|
return headers;
|
|
31
65
|
}
|
|
32
|
-
|
|
33
|
-
* Make a GET request to Valiron API
|
|
34
|
-
*/
|
|
35
|
-
async get(path, params, extraHeaders) {
|
|
66
|
+
async get(path, chain) {
|
|
36
67
|
const url = new URL(path, this.endpoint);
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
url.searchParams.append(key, value);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
68
|
+
if (chain)
|
|
69
|
+
url.searchParams.set("chain", chain);
|
|
42
70
|
if (this.debug) {
|
|
43
71
|
console.log(`[Valiron SDK] GET ${url.toString()}`);
|
|
44
72
|
}
|
|
@@ -46,37 +74,36 @@ class BaseClient {
|
|
|
46
74
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
47
75
|
try {
|
|
48
76
|
const response = await fetch(url.toString(), {
|
|
49
|
-
method:
|
|
50
|
-
headers: this.buildHeaders(
|
|
77
|
+
method: "GET",
|
|
78
|
+
headers: this.buildHeaders(),
|
|
51
79
|
signal: controller.signal,
|
|
52
80
|
});
|
|
53
81
|
clearTimeout(timeoutId);
|
|
54
82
|
if (!response.ok) {
|
|
55
|
-
const
|
|
56
|
-
|
|
83
|
+
const body = await response
|
|
84
|
+
.json()
|
|
85
|
+
.catch(() => ({ message: response.statusText }));
|
|
86
|
+
throw new types_1.ValironError(body.error || body.message || `Request failed: ${response.statusText}`, "API_ERROR", response.status);
|
|
57
87
|
}
|
|
58
88
|
const data = await response.json();
|
|
59
|
-
if (this.debug)
|
|
89
|
+
if (this.debug)
|
|
60
90
|
console.log(`[Valiron SDK] Response:`, data);
|
|
61
|
-
}
|
|
62
91
|
return data;
|
|
63
92
|
}
|
|
64
93
|
catch (error) {
|
|
65
94
|
clearTimeout(timeoutId);
|
|
66
|
-
if (error.name ===
|
|
67
|
-
throw new types_1.ValironError(`Request timeout after ${this.timeout}ms`,
|
|
95
|
+
if (error.name === "AbortError") {
|
|
96
|
+
throw new types_1.ValironError(`Request timeout after ${this.timeout}ms`, "TIMEOUT_ERROR");
|
|
68
97
|
}
|
|
69
|
-
if (error instanceof types_1.ValironError)
|
|
98
|
+
if (error instanceof types_1.ValironError)
|
|
70
99
|
throw error;
|
|
71
|
-
|
|
72
|
-
throw new types_1.ValironError(error.message || 'Network error', 'NETWORK_ERROR');
|
|
100
|
+
throw new types_1.ValironError(error.message || "Network error", "NETWORK_ERROR");
|
|
73
101
|
}
|
|
74
102
|
}
|
|
75
|
-
|
|
76
|
-
* Make a POST request to Valiron API
|
|
77
|
-
*/
|
|
78
|
-
async post(path, body) {
|
|
103
|
+
async post(path, body, chain) {
|
|
79
104
|
const url = new URL(path, this.endpoint);
|
|
105
|
+
if (chain)
|
|
106
|
+
url.searchParams.set("chain", chain);
|
|
80
107
|
if (this.debug) {
|
|
81
108
|
console.log(`[Valiron SDK] POST ${url.toString()}`, body);
|
|
82
109
|
}
|
|
@@ -84,107 +111,33 @@ class BaseClient {
|
|
|
84
111
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
85
112
|
try {
|
|
86
113
|
const response = await fetch(url.toString(), {
|
|
87
|
-
method:
|
|
114
|
+
method: "POST",
|
|
88
115
|
headers: this.buildHeaders(),
|
|
89
116
|
body: body ? JSON.stringify(body) : undefined,
|
|
90
117
|
signal: controller.signal,
|
|
91
118
|
});
|
|
92
119
|
clearTimeout(timeoutId);
|
|
93
120
|
if (!response.ok) {
|
|
94
|
-
const
|
|
95
|
-
|
|
121
|
+
const respBody = await response
|
|
122
|
+
.json()
|
|
123
|
+
.catch(() => ({ message: response.statusText }));
|
|
124
|
+
throw new types_1.ValironError(respBody.error || respBody.message || `Request failed: ${response.statusText}`, "API_ERROR", response.status);
|
|
96
125
|
}
|
|
97
126
|
const data = await response.json();
|
|
98
|
-
if (this.debug)
|
|
127
|
+
if (this.debug)
|
|
99
128
|
console.log(`[Valiron SDK] Response:`, data);
|
|
100
|
-
}
|
|
101
129
|
return data;
|
|
102
130
|
}
|
|
103
131
|
catch (error) {
|
|
104
132
|
clearTimeout(timeoutId);
|
|
105
|
-
if (error.name ===
|
|
106
|
-
throw new types_1.ValironError(`Request timeout after ${this.timeout}ms`,
|
|
133
|
+
if (error.name === "AbortError") {
|
|
134
|
+
throw new types_1.ValironError(`Request timeout after ${this.timeout}ms`, "TIMEOUT_ERROR");
|
|
107
135
|
}
|
|
108
|
-
if (error instanceof types_1.ValironError)
|
|
136
|
+
if (error instanceof types_1.ValironError)
|
|
109
137
|
throw error;
|
|
110
|
-
|
|
111
|
-
throw new types_1.ValironError(error.message || 'Network error', 'NETWORK_ERROR');
|
|
138
|
+
throw new types_1.ValironError(error.message || "Network error", "NETWORK_ERROR");
|
|
112
139
|
}
|
|
113
140
|
}
|
|
114
141
|
}
|
|
115
|
-
exports.
|
|
116
|
-
/**
|
|
117
|
-
* Client for agent trust and routing operations
|
|
118
|
-
*/
|
|
119
|
-
class TrustClient extends BaseClient {
|
|
120
|
-
/**
|
|
121
|
-
* Check agent routing decision
|
|
122
|
-
*
|
|
123
|
-
* This is the primary method for determining how to route requests from an agent.
|
|
124
|
-
* The Valiron system will automatically handle sandbox testing if needed.
|
|
125
|
-
*
|
|
126
|
-
* @param agentId - The ERC-8004 agent ID
|
|
127
|
-
* @returns Routing decision with explanation
|
|
128
|
-
*/
|
|
129
|
-
async checkAgent(agentId) {
|
|
130
|
-
return this.get('/route', undefined, { 'x-agent-id': agentId });
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Check wallet routing decision (legacy support)
|
|
134
|
-
*
|
|
135
|
-
* @param wallet - The wallet address
|
|
136
|
-
* @returns Routing decision with explanation
|
|
137
|
-
*/
|
|
138
|
-
async checkWallet(wallet) {
|
|
139
|
-
return this.get('/route', undefined, { 'x-payment-address': wallet });
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Get complete agent trust profile
|
|
143
|
-
*
|
|
144
|
-
* Returns combined on-chain and off-chain reputation data
|
|
145
|
-
*
|
|
146
|
-
* @param agentId - The ERC-8004 agent ID
|
|
147
|
-
* @returns Complete agent profile
|
|
148
|
-
*/
|
|
149
|
-
async getAgentProfile(agentId) {
|
|
150
|
-
return this.get(`/agent/${agentId}`);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Get wallet profile
|
|
154
|
-
*
|
|
155
|
-
* @param wallet - The wallet address
|
|
156
|
-
* @returns Wallet profile with routing info
|
|
157
|
-
*/
|
|
158
|
-
async getWalletProfile(wallet) {
|
|
159
|
-
return this.get(`/wallet/${wallet}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
exports.TrustClient = TrustClient;
|
|
163
|
-
/**
|
|
164
|
-
* Client for reputation feedback operations
|
|
165
|
-
*/
|
|
166
|
-
class ReputationClient extends BaseClient {
|
|
167
|
-
/**
|
|
168
|
-
* Submit feedback about an agent's behavior
|
|
169
|
-
*
|
|
170
|
-
* Note: This submits feedback to Valiron, which then handles
|
|
171
|
-
* IPFS upload and on-chain submission on your behalf.
|
|
172
|
-
*
|
|
173
|
-
* @param params - Feedback parameters
|
|
174
|
-
*/
|
|
175
|
-
async submitFeedback(params) {
|
|
176
|
-
return this.post('/feedback', params);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Manually trigger sandbox testing for an agent
|
|
180
|
-
*
|
|
181
|
-
* Useful for testing or re-evaluation scenarios.
|
|
182
|
-
*
|
|
183
|
-
* @param params - Sandbox test parameters
|
|
184
|
-
*/
|
|
185
|
-
async triggerSandboxTest(params) {
|
|
186
|
-
return this.post('/sandbox/trigger', params);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
exports.ReputationClient = ReputationClient;
|
|
142
|
+
exports.ValironClient = ValironClient;
|
|
190
143
|
//# sourceMappingURL=clients.js.map
|
package/dist/clients.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":";;;AAAA,mCAQiB;AAEjB
|
|
1
|
+
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":";;;AAAA,mCAQiB;AAEjB;;;;;GAKG;AACH,MAAa,aAAa;IAOxB,YAAY,SAAwB,EAAE;QACpC,IAAI,CAAC,QAAQ;YACX,MAAM,CAAC,QAAQ,IAAI,yCAAyC,CAAC;QAC/D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;IACrC,CAAC;IAED,2EAA2E;IAE3E,yGAAyG;IACjG,YAAY,CAAC,OAAqB;QACxC,OAAO,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC;IAC7C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,OAAqB;QAC1D,OAAO,IAAI,CAAC,GAAG,CAAe,mBAAmB,OAAO,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAc,EAAE,OAAqB;QAC1D,OAAO,IAAI,CAAC,GAAG,CAAgB,oBAAoB,MAAM,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,kBAAkB,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CAAC,CAAC;YACxB,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAChC,MAAM,IAAI,oBAAY,CACpB,yBAAyB,IAAI,CAAC,OAAO,IAAI,EACzC,eAAe,CAChB,CAAC;YACJ,CAAC;YACD,IAAI,KAAK,YAAY,oBAAY;gBAAE,MAAM,KAAK,CAAC;YAC/C,MAAM,IAAI,oBAAY,CACpB,KAAK,CAAC,OAAO,IAAI,eAAe,EAChC,eAAe,CAChB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAzKD,sCAyKC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,132 +1,117 @@
|
|
|
1
|
-
import { ValironConfig,
|
|
1
|
+
import { ValironConfig, CallOptions, AgentProfile, WalletProfile, SandboxResult, RouteDecision } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
* Valiron SDK
|
|
3
|
+
* Valiron SDK – Official TypeScript SDK for the Trust Layer for Agentic Economy
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```typescript
|
|
7
7
|
* import { ValironSDK } from '@valiron/sdk';
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* });
|
|
9
|
+
* // Default chain (ethereum)
|
|
10
|
+
* const valiron = new ValironSDK();
|
|
12
11
|
*
|
|
13
|
-
* //
|
|
14
|
-
* const
|
|
15
|
-
*
|
|
12
|
+
* // Or set a default chain at construction
|
|
13
|
+
* const monadValiron = new ValironSDK({ chain: 'monad' });
|
|
14
|
+
*
|
|
15
|
+
* // Get full trust profile (identity + reputation + routing)
|
|
16
|
+
* const profile = await valiron.getAgentProfile('25459');
|
|
17
|
+
*
|
|
18
|
+
* // Override chain per-call
|
|
19
|
+
* const monadProfile = await valiron.getAgentProfile('8348', { chain: 'monad' });
|
|
20
|
+
*
|
|
21
|
+
* if (profile.routing.finalRoute === 'prod') {
|
|
16
22
|
* // Allow full production access
|
|
17
23
|
* }
|
|
18
24
|
* ```
|
|
19
25
|
*/
|
|
20
26
|
export declare class ValironSDK {
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
constructor(config: ValironConfig);
|
|
27
|
+
private client;
|
|
28
|
+
constructor(config?: ValironConfig);
|
|
24
29
|
/**
|
|
25
|
-
*
|
|
30
|
+
* Get the complete trust profile for an ERC-8004 agent.
|
|
26
31
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
32
|
+
* Returns on-chain identity, on-chain reputation (feedback count,
|
|
33
|
+
* average score, individual entries), local behavioral reputation
|
|
34
|
+
* (Valiron sandbox metrics), and a hybrid routing decision.
|
|
29
35
|
*
|
|
30
36
|
* @param agentId - The ERC-8004 agent ID
|
|
31
|
-
* @
|
|
37
|
+
* @param options - Optional overrides (e.g. `{ chain: 'monad' }`)
|
|
38
|
+
* @returns Full agent trust profile
|
|
32
39
|
*
|
|
33
40
|
* @example
|
|
34
41
|
* ```typescript
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* switch (result.route) {
|
|
38
|
-
* case 'prod':
|
|
39
|
-
* return handleProductionRequest();
|
|
40
|
-
* case 'prod_throttled':
|
|
41
|
-
* return handleThrottledRequest();
|
|
42
|
-
* case 'sandbox':
|
|
43
|
-
* case 'sandbox_only':
|
|
44
|
-
* return rejectRequest();
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
checkAgent(agentId: string): Promise<RoutingResponse>;
|
|
49
|
-
/**
|
|
50
|
-
* Check wallet routing decision
|
|
42
|
+
* // Uses default chain
|
|
43
|
+
* const profile = await valiron.getAgentProfile('25459');
|
|
51
44
|
*
|
|
52
|
-
*
|
|
45
|
+
* // Explicit Monad chain
|
|
46
|
+
* const monadProfile = await valiron.getAgentProfile('8348', { chain: 'monad' });
|
|
53
47
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
48
|
+
* console.log(profile.routing.finalRoute); // 'prod'
|
|
49
|
+
* console.log(profile.routing.decision); // human-readable explanation
|
|
50
|
+
* console.log(profile.localReputation?.tier); // 'AAA'
|
|
51
|
+
* console.log(profile.onchainReputation.averageScore); // 92.5
|
|
52
|
+
* ```
|
|
56
53
|
*/
|
|
57
|
-
|
|
54
|
+
getAgentProfile(agentId: string, options?: CallOptions): Promise<AgentProfile>;
|
|
58
55
|
/**
|
|
59
|
-
*
|
|
56
|
+
* Convenience helper – get just the routing decision for an agent.
|
|
60
57
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
58
|
+
* This calls `getAgentProfile` under the hood and extracts the
|
|
59
|
+
* `routing.finalRoute` field.
|
|
63
60
|
*
|
|
64
61
|
* @param agentId - The ERC-8004 agent ID
|
|
65
|
-
* @
|
|
62
|
+
* @param options - Optional overrides (e.g. `{ chain: 'monad' }`)
|
|
63
|
+
* @returns The route decision string
|
|
66
64
|
*
|
|
67
65
|
* @example
|
|
68
66
|
* ```typescript
|
|
69
|
-
* const
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
67
|
+
* const route = await valiron.checkAgent('25459');
|
|
68
|
+
* const monadRoute = await valiron.checkAgent('8348', { chain: 'monad' });
|
|
69
|
+
* if (route === 'prod' || route === 'prod_throttled') {
|
|
70
|
+
* return handleRequest();
|
|
71
|
+
* }
|
|
73
72
|
* ```
|
|
74
73
|
*/
|
|
75
|
-
|
|
74
|
+
checkAgent(agentId: string, options?: CallOptions): Promise<RouteDecision>;
|
|
76
75
|
/**
|
|
77
|
-
* Get wallet
|
|
76
|
+
* Get a trust profile by wallet address (reverse lookup).
|
|
78
77
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
getWalletProfile(wallet: string): Promise<WalletProfile>;
|
|
83
|
-
/**
|
|
84
|
-
* Submit feedback about an agent's behavior
|
|
85
|
-
*
|
|
86
|
-
* This allows you to report an agent's behavior to Valiron.
|
|
87
|
-
* Valiron handles IPFS storage and on-chain submission automatically.
|
|
78
|
+
* If the wallet has an associated agent ID in local state, the full
|
|
79
|
+
* profile (identity + on-chain reputation) is included. Otherwise
|
|
80
|
+
* only local behavioral data is returned.
|
|
88
81
|
*
|
|
89
|
-
* @param
|
|
90
|
-
* @
|
|
82
|
+
* @param wallet - Ethereum wallet address
|
|
83
|
+
* @param options - Optional overrides (e.g. `{ chain: 'monad' }`)
|
|
84
|
+
* @returns Wallet trust profile
|
|
91
85
|
*
|
|
92
86
|
* @example
|
|
93
87
|
* ```typescript
|
|
94
|
-
* await valiron.
|
|
95
|
-
*
|
|
96
|
-
* score: 95,
|
|
97
|
-
* outcome: 'success',
|
|
98
|
-
* metadata: {
|
|
99
|
-
* taskType: 'data_processing',
|
|
100
|
-
* duration: 1234
|
|
101
|
-
* }
|
|
102
|
-
* });
|
|
88
|
+
* const profile = await valiron.getWalletProfile('0x52ce…');
|
|
89
|
+
* console.log(profile.routing.finalRoute);
|
|
103
90
|
* ```
|
|
104
91
|
*/
|
|
105
|
-
|
|
106
|
-
success: boolean;
|
|
107
|
-
txHash?: string;
|
|
108
|
-
}>;
|
|
92
|
+
getWalletProfile(wallet: string, options?: CallOptions): Promise<WalletProfile>;
|
|
109
93
|
/**
|
|
110
|
-
*
|
|
94
|
+
* Trigger real sandbox testing for an agent.
|
|
111
95
|
*
|
|
112
|
-
*
|
|
96
|
+
* Sends a series of test requests against the agent's HTTP endpoint
|
|
97
|
+
* (if registered on-chain) or through the sandbox relay, then computes
|
|
98
|
+
* a Valiron behavioral score and stores the result.
|
|
113
99
|
*
|
|
114
|
-
* @param
|
|
115
|
-
* @
|
|
100
|
+
* @param agentId - The ERC-8004 agent ID
|
|
101
|
+
* @param options - Optional overrides (e.g. `{ chain: 'monad' }`)
|
|
102
|
+
* @returns Sandbox test results including score, tier, and metrics
|
|
116
103
|
*
|
|
117
104
|
* @example
|
|
118
105
|
* ```typescript
|
|
119
|
-
* await valiron.triggerSandboxTest(
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
106
|
+
* const result = await valiron.triggerSandboxTest('25459');
|
|
107
|
+
* console.log(result.valironScore); // 95
|
|
108
|
+
* console.log(result.tier); // 'AAA'
|
|
109
|
+
* console.log(result.riskLevel); // 'GREEN'
|
|
110
|
+
* console.log(result.testSummary); // { totalRequests, successCount, … }
|
|
123
111
|
* ```
|
|
124
112
|
*/
|
|
125
|
-
triggerSandboxTest(
|
|
126
|
-
success: boolean;
|
|
127
|
-
message: string;
|
|
128
|
-
}>;
|
|
113
|
+
triggerSandboxTest(agentId: string, options?: CallOptions): Promise<SandboxResult>;
|
|
129
114
|
}
|
|
130
|
-
export * from
|
|
131
|
-
export
|
|
115
|
+
export * from "./types";
|
|
116
|
+
export { ValironClient } from "./clients";
|
|
132
117
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,GAAE,aAAkB;IAItC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAIpF;;;;;;;;;;;;;;;;;;OAkBG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAKhF;;;;;;;;;;;;;;;;OAgBG;IACG,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAIrF;;;;;;;;;;;;;;;;;;;OAmBG;IACG,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAGzF;AAGD,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|