@agentxv2/sdk 0.5.0 → 0.5.1
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/index.js +296 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +294 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{react.js → react/index.js} +4 -2
- package/dist/{react.js.map → react/index.js.map} +1 -1
- package/dist/{react.mjs → react/index.mjs} +4 -2
- package/dist/{react.mjs.map → react/index.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/core.d.mts +0 -64
- package/dist/core.d.ts +0 -64
- package/dist/index-DhXVi_ub.d.ts +0 -208
- package/dist/index-eQO4iaOr.d.mts +0 -208
- package/dist/index.d.mts +0 -269
- package/dist/index.d.ts +0 -269
- package/dist/react.d.mts +0 -3
- package/dist/react.d.ts +0 -3
- package/dist/types-2aHUvS4M.d.mts +0 -297
- package/dist/types-2aHUvS4M.d.ts +0 -297
- /package/dist/{core.js → core/index.js} +0 -0
- /package/dist/{core.js.map → core/index.js.map} +0 -0
- /package/dist/{core.mjs → core/index.mjs} +0 -0
- /package/dist/{core.mjs.map → core/index.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -2082,7 +2082,8 @@ var KNOWN_CHAINS = {
|
|
|
2082
2082
|
paymentGateway: "0x59eA58c0089314C0fCc86A4ff646fb6dAE571C96",
|
|
2083
2083
|
a2aProtocolRegistry: "0xEdb0022c250B38e281B3EF1418037889fC5C6092",
|
|
2084
2084
|
reputationRegistry: "0xeb6B410ea71b8d9dA0c96f6A91d35027CE143DC9",
|
|
2085
|
-
configurationRegistry: "0x68DcE00e4C9077c94BC68016cD14B09557faEA6c"
|
|
2085
|
+
configurationRegistry: "0x68DcE00e4C9077c94BC68016cD14B09557faEA6c",
|
|
2086
|
+
multiEndpointRegistry: "0xEB5e866f186d4B73F97aa0d70B86f2C6e2e21Cb7"
|
|
2086
2087
|
},
|
|
2087
2088
|
ipfsGateways: ["ipfs.io", "gateway.pinata.cloud", "dweb.link", "cf-ipfs.com"]
|
|
2088
2089
|
},
|
|
@@ -2100,7 +2101,8 @@ var KNOWN_CHAINS = {
|
|
|
2100
2101
|
paymentGateway: "0x0000000000000000000000000000000000000000",
|
|
2101
2102
|
a2aProtocolRegistry: "0x61b7E7Eed21F013e35a90FC5de5c352780ec5169",
|
|
2102
2103
|
reputationRegistry: "0x6a18C2664E1b42063860d864b6448b824d7B843F",
|
|
2103
|
-
configurationRegistry: "0x07280674ccc2898Fd038A9e3C22005CA83ffD2F8"
|
|
2104
|
+
configurationRegistry: "0x07280674ccc2898Fd038A9e3C22005CA83ffD2F8",
|
|
2105
|
+
multiEndpointRegistry: "0xB361d04F49000013FC131D3C59C41c8486C64f8c"
|
|
2104
2106
|
},
|
|
2105
2107
|
ipfsGateways: ["ipfs.io", "gateway.pinata.cloud", "dweb.link", "cf-ipfs.com"],
|
|
2106
2108
|
rpcUrl: "http://43.156.99.215:18545"
|
|
@@ -2158,6 +2160,294 @@ var ConfigurationRegistry = class {
|
|
|
2158
2160
|
// src/config/index.ts
|
|
2159
2161
|
var CONFIG_VERSION = "0.1.0";
|
|
2160
2162
|
|
|
2163
|
+
// src/endpoint/multi-endpoint.ts
|
|
2164
|
+
var ABI = [
|
|
2165
|
+
{
|
|
2166
|
+
name: "getActiveAgentEndpoints",
|
|
2167
|
+
type: "function",
|
|
2168
|
+
stateMutability: "view",
|
|
2169
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
2170
|
+
outputs: [{
|
|
2171
|
+
type: "tuple[]",
|
|
2172
|
+
components: [
|
|
2173
|
+
{ name: "endpointId", type: "uint256" },
|
|
2174
|
+
{ name: "agentId", type: "uint256" },
|
|
2175
|
+
{ name: "name", type: "string" },
|
|
2176
|
+
{ name: "endpointType", type: "string" },
|
|
2177
|
+
{ name: "protocol", type: "string" },
|
|
2178
|
+
{ name: "url", type: "string" },
|
|
2179
|
+
{ name: "description", type: "string" },
|
|
2180
|
+
{ name: "isActive", type: "bool" },
|
|
2181
|
+
{ name: "createdAt", type: "uint256" },
|
|
2182
|
+
{ name: "updatedAt", type: "uint256" },
|
|
2183
|
+
{ name: "createdBy", type: "address" }
|
|
2184
|
+
]
|
|
2185
|
+
}]
|
|
2186
|
+
},
|
|
2187
|
+
{
|
|
2188
|
+
name: "getAgentEndpoints",
|
|
2189
|
+
type: "function",
|
|
2190
|
+
stateMutability: "view",
|
|
2191
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
2192
|
+
outputs: [{
|
|
2193
|
+
type: "tuple[]",
|
|
2194
|
+
components: [
|
|
2195
|
+
{ name: "endpointId", type: "uint256" },
|
|
2196
|
+
{ name: "agentId", type: "uint256" },
|
|
2197
|
+
{ name: "name", type: "string" },
|
|
2198
|
+
{ name: "endpointType", type: "string" },
|
|
2199
|
+
{ name: "protocol", type: "string" },
|
|
2200
|
+
{ name: "url", type: "string" },
|
|
2201
|
+
{ name: "description", type: "string" },
|
|
2202
|
+
{ name: "isActive", type: "bool" },
|
|
2203
|
+
{ name: "createdAt", type: "uint256" },
|
|
2204
|
+
{ name: "updatedAt", type: "uint256" },
|
|
2205
|
+
{ name: "createdBy", type: "address" }
|
|
2206
|
+
]
|
|
2207
|
+
}]
|
|
2208
|
+
},
|
|
2209
|
+
{
|
|
2210
|
+
name: "createEndpoint",
|
|
2211
|
+
type: "function",
|
|
2212
|
+
stateMutability: "nonpayable",
|
|
2213
|
+
inputs: [
|
|
2214
|
+
{ name: "agentId", type: "uint256" },
|
|
2215
|
+
{ name: "name", type: "string" },
|
|
2216
|
+
{ name: "endpointType", type: "string" },
|
|
2217
|
+
{ name: "protocol", type: "string" },
|
|
2218
|
+
{ name: "url", type: "string" },
|
|
2219
|
+
{ name: "description", type: "string" }
|
|
2220
|
+
],
|
|
2221
|
+
outputs: [{ name: "endpointId", type: "uint256" }]
|
|
2222
|
+
},
|
|
2223
|
+
{
|
|
2224
|
+
name: "getEndpoint",
|
|
2225
|
+
type: "function",
|
|
2226
|
+
stateMutability: "view",
|
|
2227
|
+
inputs: [{ name: "endpointId", type: "uint256" }],
|
|
2228
|
+
outputs: [{
|
|
2229
|
+
type: "tuple",
|
|
2230
|
+
components: [
|
|
2231
|
+
{ name: "endpointId", type: "uint256" },
|
|
2232
|
+
{ name: "agentId", type: "uint256" },
|
|
2233
|
+
{ name: "name", type: "string" },
|
|
2234
|
+
{ name: "endpointType", type: "string" },
|
|
2235
|
+
{ name: "protocol", type: "string" },
|
|
2236
|
+
{ name: "url", type: "string" },
|
|
2237
|
+
{ name: "description", type: "string" },
|
|
2238
|
+
{ name: "isActive", type: "bool" },
|
|
2239
|
+
{ name: "createdAt", type: "uint256" },
|
|
2240
|
+
{ name: "updatedAt", type: "uint256" },
|
|
2241
|
+
{ name: "createdBy", type: "address" }
|
|
2242
|
+
]
|
|
2243
|
+
}]
|
|
2244
|
+
},
|
|
2245
|
+
{
|
|
2246
|
+
name: "getSupportedProtocols",
|
|
2247
|
+
type: "function",
|
|
2248
|
+
stateMutability: "view",
|
|
2249
|
+
inputs: [],
|
|
2250
|
+
outputs: [{ type: "string[]" }]
|
|
2251
|
+
},
|
|
2252
|
+
{
|
|
2253
|
+
name: "getAgentEndpointStats",
|
|
2254
|
+
type: "function",
|
|
2255
|
+
stateMutability: "view",
|
|
2256
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
2257
|
+
outputs: [
|
|
2258
|
+
{ name: "totalEndpoints", type: "uint256" },
|
|
2259
|
+
{ name: "activeEndpoints", type: "uint256" },
|
|
2260
|
+
{ name: "httpEndpoints", type: "uint256" },
|
|
2261
|
+
{ name: "websocketEndpoints", type: "uint256" },
|
|
2262
|
+
{ name: "grpcEndpoints", type: "uint256" }
|
|
2263
|
+
]
|
|
2264
|
+
}
|
|
2265
|
+
];
|
|
2266
|
+
var MultiEndpointClient = class {
|
|
2267
|
+
address;
|
|
2268
|
+
publicClient;
|
|
2269
|
+
constructor(config, publicClient) {
|
|
2270
|
+
this.address = config.address;
|
|
2271
|
+
this.publicClient = publicClient ?? null;
|
|
2272
|
+
}
|
|
2273
|
+
setPublicClient(client) {
|
|
2274
|
+
this.publicClient = client;
|
|
2275
|
+
}
|
|
2276
|
+
async getActiveEndpoints(agentId) {
|
|
2277
|
+
if (!this.publicClient) throw new Error("publicClient not set");
|
|
2278
|
+
return await this.publicClient.readContract({
|
|
2279
|
+
address: this.address,
|
|
2280
|
+
abi: ABI,
|
|
2281
|
+
functionName: "getActiveAgentEndpoints",
|
|
2282
|
+
args: [agentId]
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
async getAllEndpoints(agentId) {
|
|
2286
|
+
if (!this.publicClient) throw new Error("publicClient not set");
|
|
2287
|
+
return await this.publicClient.readContract({
|
|
2288
|
+
address: this.address,
|
|
2289
|
+
abi: ABI,
|
|
2290
|
+
functionName: "getAgentEndpoints",
|
|
2291
|
+
args: [agentId]
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
async getEndpoint(endpointId) {
|
|
2295
|
+
if (!this.publicClient) throw new Error("publicClient not set");
|
|
2296
|
+
return await this.publicClient.readContract({
|
|
2297
|
+
address: this.address,
|
|
2298
|
+
abi: ABI,
|
|
2299
|
+
functionName: "getEndpoint",
|
|
2300
|
+
args: [endpointId]
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
async getStats(agentId) {
|
|
2304
|
+
if (!this.publicClient) throw new Error("publicClient not set");
|
|
2305
|
+
return await this.publicClient.readContract({
|
|
2306
|
+
address: this.address,
|
|
2307
|
+
abi: ABI,
|
|
2308
|
+
functionName: "getAgentEndpointStats",
|
|
2309
|
+
args: [agentId]
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
/** Pick best active endpoint for the agent — prefer HTTP, take first active */
|
|
2313
|
+
async pickBestEndpoint(agentId) {
|
|
2314
|
+
const endpoints = await this.getActiveEndpoints(agentId);
|
|
2315
|
+
if (endpoints.length === 0) return null;
|
|
2316
|
+
const http = endpoints.find((e) => e.protocol === "HTTP");
|
|
2317
|
+
return http ?? endpoints[0];
|
|
2318
|
+
}
|
|
2319
|
+
/** Pick any active endpoint URL — for MCP connector */
|
|
2320
|
+
async getBestMCPUrl(agentId) {
|
|
2321
|
+
const best = await this.pickBestEndpoint(agentId);
|
|
2322
|
+
return best?.url ?? null;
|
|
2323
|
+
}
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
// src/configuration/configuration.ts
|
|
2327
|
+
var ABI2 = [
|
|
2328
|
+
{
|
|
2329
|
+
name: "getConfig",
|
|
2330
|
+
type: "function",
|
|
2331
|
+
stateMutability: "view",
|
|
2332
|
+
inputs: [
|
|
2333
|
+
{ name: "agentId", type: "uint256" },
|
|
2334
|
+
{ name: "configKey", type: "string" }
|
|
2335
|
+
],
|
|
2336
|
+
outputs: [{
|
|
2337
|
+
type: "tuple",
|
|
2338
|
+
components: [
|
|
2339
|
+
{ name: "agentId", type: "uint256" },
|
|
2340
|
+
{ name: "key", type: "string" },
|
|
2341
|
+
{ name: "value", type: "string" },
|
|
2342
|
+
{ name: "dataType", type: "string" },
|
|
2343
|
+
{ name: "updatedAt", type: "uint256" },
|
|
2344
|
+
{ name: "updatedBy", type: "address" }
|
|
2345
|
+
]
|
|
2346
|
+
}]
|
|
2347
|
+
},
|
|
2348
|
+
{
|
|
2349
|
+
name: "getAgentConfigs",
|
|
2350
|
+
type: "function",
|
|
2351
|
+
stateMutability: "view",
|
|
2352
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
2353
|
+
outputs: [{
|
|
2354
|
+
type: "tuple[]",
|
|
2355
|
+
components: [
|
|
2356
|
+
{ name: "agentId", type: "uint256" },
|
|
2357
|
+
{ name: "key", type: "string" },
|
|
2358
|
+
{ name: "value", type: "string" },
|
|
2359
|
+
{ name: "dataType", type: "string" },
|
|
2360
|
+
{ name: "updatedAt", type: "uint256" },
|
|
2361
|
+
{ name: "updatedBy", type: "address" }
|
|
2362
|
+
]
|
|
2363
|
+
}]
|
|
2364
|
+
},
|
|
2365
|
+
{
|
|
2366
|
+
name: "getConfigKeys",
|
|
2367
|
+
type: "function",
|
|
2368
|
+
stateMutability: "view",
|
|
2369
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
2370
|
+
outputs: [{ type: "string[]" }]
|
|
2371
|
+
},
|
|
2372
|
+
{
|
|
2373
|
+
name: "getConfigCount",
|
|
2374
|
+
type: "function",
|
|
2375
|
+
stateMutability: "view",
|
|
2376
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
2377
|
+
outputs: [{ type: "uint256" }]
|
|
2378
|
+
},
|
|
2379
|
+
{
|
|
2380
|
+
name: "configExists",
|
|
2381
|
+
type: "function",
|
|
2382
|
+
stateMutability: "view",
|
|
2383
|
+
inputs: [
|
|
2384
|
+
{ name: "agentId", type: "uint256" },
|
|
2385
|
+
{ name: "configKey", type: "string" }
|
|
2386
|
+
],
|
|
2387
|
+
outputs: [{ type: "bool" }]
|
|
2388
|
+
}
|
|
2389
|
+
];
|
|
2390
|
+
var ConfigurationClient = class {
|
|
2391
|
+
address;
|
|
2392
|
+
publicClient;
|
|
2393
|
+
constructor(config, publicClient) {
|
|
2394
|
+
this.address = config.address;
|
|
2395
|
+
this.publicClient = publicClient ?? null;
|
|
2396
|
+
}
|
|
2397
|
+
setPublicClient(client) {
|
|
2398
|
+
this.publicClient = client;
|
|
2399
|
+
}
|
|
2400
|
+
async get(agentId, key) {
|
|
2401
|
+
if (!this.publicClient) throw new Error("publicClient not set");
|
|
2402
|
+
try {
|
|
2403
|
+
return await this.publicClient.readContract({
|
|
2404
|
+
address: this.address,
|
|
2405
|
+
abi: ABI2,
|
|
2406
|
+
functionName: "getConfig",
|
|
2407
|
+
args: [agentId, key]
|
|
2408
|
+
});
|
|
2409
|
+
} catch {
|
|
2410
|
+
return null;
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
async getAll(agentId) {
|
|
2414
|
+
if (!this.publicClient) throw new Error("publicClient not set");
|
|
2415
|
+
return await this.publicClient.readContract({
|
|
2416
|
+
address: this.address,
|
|
2417
|
+
abi: ABI2,
|
|
2418
|
+
functionName: "getAgentConfigs",
|
|
2419
|
+
args: [agentId]
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
async getKeys(agentId) {
|
|
2423
|
+
if (!this.publicClient) throw new Error("publicClient not set");
|
|
2424
|
+
return await this.publicClient.readContract({
|
|
2425
|
+
address: this.address,
|
|
2426
|
+
abi: ABI2,
|
|
2427
|
+
functionName: "getConfigKeys",
|
|
2428
|
+
args: [agentId]
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
async getCount(agentId) {
|
|
2432
|
+
if (!this.publicClient) throw new Error("publicClient not set");
|
|
2433
|
+
return await this.publicClient.readContract({
|
|
2434
|
+
address: this.address,
|
|
2435
|
+
abi: ABI2,
|
|
2436
|
+
functionName: "getConfigCount",
|
|
2437
|
+
args: [agentId]
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2440
|
+
async exists(agentId, key) {
|
|
2441
|
+
if (!this.publicClient) throw new Error("publicClient not set");
|
|
2442
|
+
return await this.publicClient.readContract({
|
|
2443
|
+
address: this.address,
|
|
2444
|
+
abi: ABI2,
|
|
2445
|
+
functionName: "configExists",
|
|
2446
|
+
args: [agentId, key]
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
|
|
2161
2451
|
// src/react/useAgentRunner.ts
|
|
2162
2452
|
import { useState, useEffect, useRef } from "react";
|
|
2163
2453
|
import { usePublicClient, useWalletClient } from "wagmi";
|
|
@@ -2332,11 +2622,13 @@ export {
|
|
|
2332
2622
|
AgentXError,
|
|
2333
2623
|
AgentXErrorCode,
|
|
2334
2624
|
CONFIG_VERSION,
|
|
2625
|
+
ConfigurationClient,
|
|
2335
2626
|
ConfigurationRegistry,
|
|
2336
2627
|
IPFSFetcher,
|
|
2337
2628
|
KNOWN_CHAINS,
|
|
2338
2629
|
MCPConnector,
|
|
2339
2630
|
MCP_VERSION,
|
|
2631
|
+
MultiEndpointClient,
|
|
2340
2632
|
REGISTRY_VERSION,
|
|
2341
2633
|
REPUTATION_VERSION,
|
|
2342
2634
|
ReputationRegistry,
|