@agentxv2/sdk 0.5.2 → 0.5.3
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/configuration/index.d.mts +31 -0
- package/dist/configuration/index.d.ts +31 -0
- package/dist/configuration/index.js +155 -0
- package/dist/configuration/index.js.map +1 -0
- package/dist/configuration/index.mjs +128 -0
- package/dist/configuration/index.mjs.map +1 -0
- package/dist/core.d.mts +64 -0
- package/dist/core.d.ts +64 -0
- package/dist/endpoint/index.d.mts +39 -0
- package/dist/endpoint/index.d.ts +39 -0
- package/dist/endpoint/index.js +193 -0
- package/dist/endpoint/index.js.map +1 -0
- package/dist/endpoint/index.mjs +166 -0
- package/dist/endpoint/index.mjs.map +1 -0
- package/dist/index-BlD1-fQt.d.mts +209 -0
- package/dist/index-DV-tFsBT.d.ts +209 -0
- package/dist/index.d.mts +271 -0
- package/dist/index.d.ts +271 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +3 -0
- package/dist/react.d.ts +3 -0
- package/dist/types-2aHUvS4M.d.mts +297 -0
- package/dist/types-2aHUvS4M.d.ts +297 -0
- package/package.json +2 -2
- /package/dist/{core/index.js → core.js} +0 -0
- /package/dist/{core/index.js.map → core.js.map} +0 -0
- /package/dist/{core/index.mjs → core.mjs} +0 -0
- /package/dist/{core/index.mjs.map → core.mjs.map} +0 -0
- /package/dist/{react/index.js → react.js} +0 -0
- /package/dist/{react/index.js.map → react.js.map} +0 -0
- /package/dist/{react/index.mjs → react.mjs} +0 -0
- /package/dist/{react/index.mjs.map → react.mjs.map} +0 -0
package/dist/react.d.mts
ADDED
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
interface JSONSchema {
|
|
2
|
+
type: 'object' | 'array' | 'string' | 'number' | 'boolean' | 'integer' | 'null';
|
|
3
|
+
properties?: Record<string, JSONSchemaProperty>;
|
|
4
|
+
required?: string[];
|
|
5
|
+
description?: string;
|
|
6
|
+
items?: JSONSchema;
|
|
7
|
+
enum?: (string | number | boolean | null)[];
|
|
8
|
+
}
|
|
9
|
+
interface JSONSchemaProperty {
|
|
10
|
+
type?: JSONSchema['type'] | JSONSchema['type'][];
|
|
11
|
+
description?: string;
|
|
12
|
+
properties?: Record<string, JSONSchemaProperty>;
|
|
13
|
+
required?: string[];
|
|
14
|
+
items?: JSONSchema;
|
|
15
|
+
enum?: (string | number | boolean | null)[];
|
|
16
|
+
format?: string;
|
|
17
|
+
default?: unknown;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A single skill module that an Agent exposes.
|
|
21
|
+
* `inputSchema` and `outputSchema` follow MCP Tool JSON Schema conventions.
|
|
22
|
+
*/
|
|
23
|
+
interface SkillDef {
|
|
24
|
+
/** Unique skill name (e.g. "solidity_audit") */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Human-readable description shown in the marketplace */
|
|
27
|
+
description: string;
|
|
28
|
+
/** Semantic version of this skill */
|
|
29
|
+
version: string;
|
|
30
|
+
/** JSON Schema for the tool's input parameters */
|
|
31
|
+
inputSchema: JSONSchema;
|
|
32
|
+
/** JSON Schema for the tool's output return value */
|
|
33
|
+
outputSchema?: JSONSchema;
|
|
34
|
+
/**
|
|
35
|
+
* Execution mode.
|
|
36
|
+
* - undefined / "open": Source is in the encrypted payload, runs locally.
|
|
37
|
+
* - { type: "mcp", toolName: "..." }: Source lives on the publisher's
|
|
38
|
+
* MCP server. Subscriber only gets Schema + remote execution endpoint.
|
|
39
|
+
* MCP server verifies on-chain subscription on every call.
|
|
40
|
+
* - { type: "a2a", targetAgentId: 42 }: Delegates to another AgentX Agent.
|
|
41
|
+
* The caller's AgentRunner loads + decrypts the target Agent, injects
|
|
42
|
+
* its prompt into the LLM context, and exposes its skills as callable
|
|
43
|
+
* tools. This is the core Agent Composition primitive.
|
|
44
|
+
*/
|
|
45
|
+
execution?: SkillExecutionRemote | A2ASkillExecution;
|
|
46
|
+
}
|
|
47
|
+
/** Where the skill code actually runs. */
|
|
48
|
+
type SkillExecutionMode = 'open' | 'mcp' | 'a2a';
|
|
49
|
+
interface SkillExecutionRemote {
|
|
50
|
+
type: 'mcp';
|
|
51
|
+
/** MCP tool name on the publisher's server (e.g. "run_strategy_abc123") */
|
|
52
|
+
toolName: string;
|
|
53
|
+
/** Optional: explicit MCP endpoint override */
|
|
54
|
+
endpoint?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A2A Skill Execution — delegate to another AgentX Agent.
|
|
58
|
+
*
|
|
59
|
+
* Example: A "trading" Agent has a skill:
|
|
60
|
+
* execution: { type: "a2a", targetAgentId: 42 }
|
|
61
|
+
* → When LLM calls this skill, AgentRunner loads Agent #42,
|
|
62
|
+
* decrypts its prompt+skills, and the sub-Agent runs in the
|
|
63
|
+
* same LLM conversation with its own system prompt.
|
|
64
|
+
*/
|
|
65
|
+
interface A2ASkillExecution {
|
|
66
|
+
type: 'a2a';
|
|
67
|
+
/** On-chain Agent ID to delegate to */
|
|
68
|
+
targetAgentId: number;
|
|
69
|
+
/** Optional: restrict which of the target Agent's skills are exposed */
|
|
70
|
+
skillFilter?: string[];
|
|
71
|
+
/** Optional: custom system prompt override for the sub-Agent */
|
|
72
|
+
promptOverride?: string;
|
|
73
|
+
}
|
|
74
|
+
type McpTransport = 'http' | 'sse' | 'stdio';
|
|
75
|
+
interface McpConnection {
|
|
76
|
+
/** Transport type */
|
|
77
|
+
type: McpTransport;
|
|
78
|
+
/** MCP server URL (required for http/sse) */
|
|
79
|
+
url?: string;
|
|
80
|
+
/** Optional: limit which tools the Agent exposes to users */
|
|
81
|
+
toolFilter?: string[];
|
|
82
|
+
/** Optional: MCP server authentication header / key */
|
|
83
|
+
authHeader?: string;
|
|
84
|
+
}
|
|
85
|
+
type PricingType = 'subscription' | 'pay_per_use' | 'free';
|
|
86
|
+
interface AgentPricing {
|
|
87
|
+
type: PricingType;
|
|
88
|
+
/** Amount in native unit (e.g. "0.01" for 0.01 ETH) */
|
|
89
|
+
amount: string;
|
|
90
|
+
/** ERC20 token address, or empty for native currency */
|
|
91
|
+
currency: string;
|
|
92
|
+
/** Billing period for subscriptions (e.g. "month", "year", "day") */
|
|
93
|
+
period?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The complete Agent definition.
|
|
97
|
+
*
|
|
98
|
+
* - Fields above "--- private payload ---" are public (IPFS publicPayloadCid).
|
|
99
|
+
* - Fields below are encrypted with AES-256-GCM and stored at encryptedPayloadCid.
|
|
100
|
+
*/
|
|
101
|
+
interface AgentPayload {
|
|
102
|
+
name: string;
|
|
103
|
+
description: string;
|
|
104
|
+
image?: string;
|
|
105
|
+
version: string;
|
|
106
|
+
tags: string[];
|
|
107
|
+
capabilities: string[];
|
|
108
|
+
supportedTasks: string[];
|
|
109
|
+
communicationProtocol: 'mcp' | 'a2a';
|
|
110
|
+
authenticationMethod: 'ecdsa';
|
|
111
|
+
pricing: AgentPricing;
|
|
112
|
+
prompt: string;
|
|
113
|
+
skills: SkillDef[];
|
|
114
|
+
mcp: McpConnection;
|
|
115
|
+
}
|
|
116
|
+
/** Subset of AgentPayload that is publicly visible */
|
|
117
|
+
type AgentPublicPayload = Omit<AgentPayload, 'prompt' | 'skills' | 'mcp'>;
|
|
118
|
+
/** Fields that must be encrypted before IPFS upload */
|
|
119
|
+
type AgentPrivatePayload = Pick<AgentPayload, 'prompt' | 'skills' | 'mcp'>;
|
|
120
|
+
interface EncryptedPayload {
|
|
121
|
+
encrypted: true;
|
|
122
|
+
algorithm: 'AES-256-GCM';
|
|
123
|
+
/** base64(iv + ciphertext + authTag) */
|
|
124
|
+
data: string;
|
|
125
|
+
}
|
|
126
|
+
interface OnChainAgentMetadata {
|
|
127
|
+
tokenURI: string;
|
|
128
|
+
attributes: {
|
|
129
|
+
name: string;
|
|
130
|
+
description: string;
|
|
131
|
+
/** CID of the AES-256-GCM encrypted payload on IPFS */
|
|
132
|
+
encryptedPayloadCid: string;
|
|
133
|
+
/** ECIES-encrypted AES key (secp256k1, hex string) */
|
|
134
|
+
eciesEncryptedKey: string;
|
|
135
|
+
/** CID of the public metadata on IPFS */
|
|
136
|
+
publicPayloadCid: string;
|
|
137
|
+
capabilities: string[];
|
|
138
|
+
skills: string[];
|
|
139
|
+
mcpEndpoint: string;
|
|
140
|
+
version: string;
|
|
141
|
+
tags: string[];
|
|
142
|
+
pricingType: PricingType;
|
|
143
|
+
pricingAmount: string;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
interface RegisteredAgent {
|
|
147
|
+
/** ERC-721 token ID (= agentId) */
|
|
148
|
+
agentId: number;
|
|
149
|
+
/** Owner wallet address */
|
|
150
|
+
owner: string;
|
|
151
|
+
/** Creator wallet address */
|
|
152
|
+
creator: string;
|
|
153
|
+
/** Full on-chain metadata */
|
|
154
|
+
metadata: OnChainAgentMetadata;
|
|
155
|
+
/** Block number where agent was registered */
|
|
156
|
+
registeredAt: number;
|
|
157
|
+
/** IPFS CID of the full public payload (resolved from tokenURI) */
|
|
158
|
+
publicPayloadCid: string;
|
|
159
|
+
}
|
|
160
|
+
interface AgentSearchQuery {
|
|
161
|
+
keyword?: string;
|
|
162
|
+
capabilities?: string[];
|
|
163
|
+
tags?: string[];
|
|
164
|
+
pricingType?: PricingType;
|
|
165
|
+
maxPrice?: string;
|
|
166
|
+
owner?: string;
|
|
167
|
+
sortBy?: 'latest' | 'reputation' | 'price_asc' | 'price_desc';
|
|
168
|
+
page?: number;
|
|
169
|
+
pageSize?: number;
|
|
170
|
+
}
|
|
171
|
+
interface AgentSearchResult {
|
|
172
|
+
agents: RegisteredAgent[];
|
|
173
|
+
total: number;
|
|
174
|
+
page: number;
|
|
175
|
+
pageSize: number;
|
|
176
|
+
}
|
|
177
|
+
type SubscriptionStatus = 'active' | 'expired' | 'cancelled' | 'pending';
|
|
178
|
+
interface AgentSubscription {
|
|
179
|
+
subscriptionId: number;
|
|
180
|
+
subscriber: string;
|
|
181
|
+
agentId: number;
|
|
182
|
+
status: SubscriptionStatus;
|
|
183
|
+
startedAt: number;
|
|
184
|
+
expiresAt: number;
|
|
185
|
+
period: string;
|
|
186
|
+
}
|
|
187
|
+
type A2ATaskStatus = 'created' | 'accepted' | 'in_progress' | 'completed' | 'failed';
|
|
188
|
+
interface A2AAgentCard {
|
|
189
|
+
agentId: number;
|
|
190
|
+
name: string;
|
|
191
|
+
capabilities: string[];
|
|
192
|
+
supportedTasks: string[];
|
|
193
|
+
/** MCP endpoint URL for direct agent-to-agent communication */
|
|
194
|
+
endpoint: string;
|
|
195
|
+
/** Public key for ECDSA authentication */
|
|
196
|
+
publicKey: string;
|
|
197
|
+
}
|
|
198
|
+
interface A2ATask {
|
|
199
|
+
taskId: number;
|
|
200
|
+
/** Agent that created the task */
|
|
201
|
+
creator: string;
|
|
202
|
+
/** Target agent to execute the task */
|
|
203
|
+
targetAgentId: number;
|
|
204
|
+
/** Task type (must be in target's supportedTasks) */
|
|
205
|
+
taskType: string;
|
|
206
|
+
/** JSON input payload */
|
|
207
|
+
input: string;
|
|
208
|
+
status: A2ATaskStatus;
|
|
209
|
+
result?: string;
|
|
210
|
+
createdAt: number;
|
|
211
|
+
completedAt?: number;
|
|
212
|
+
}
|
|
213
|
+
interface AgentReputation {
|
|
214
|
+
agentId: number;
|
|
215
|
+
averageRating: number;
|
|
216
|
+
totalRatings: number;
|
|
217
|
+
reviews: AgentReview[];
|
|
218
|
+
}
|
|
219
|
+
interface AgentReview {
|
|
220
|
+
reviewer: string;
|
|
221
|
+
rating: number;
|
|
222
|
+
comment: string;
|
|
223
|
+
timestamp: number;
|
|
224
|
+
}
|
|
225
|
+
interface AgentXConfig {
|
|
226
|
+
/** Chain ID (e.g. 11155111 for Sepolia) */
|
|
227
|
+
chainId: number;
|
|
228
|
+
/** RPC endpoint override (uses viem's default if omitted) */
|
|
229
|
+
rpcUrl?: string;
|
|
230
|
+
/** Contract addresses for the current chain */
|
|
231
|
+
contracts: AgentXContracts;
|
|
232
|
+
/** IPFS gateway URLs (ordered by priority) */
|
|
233
|
+
ipfsGateways: string[];
|
|
234
|
+
/** Default IPFS pinning service */
|
|
235
|
+
pinningService?: 'pinata';
|
|
236
|
+
pinataJwt?: string;
|
|
237
|
+
}
|
|
238
|
+
interface AgentXContracts {
|
|
239
|
+
identityRegistry: `0x${string}`;
|
|
240
|
+
subscriptionManager: `0x${string}`;
|
|
241
|
+
paymentGateway: `0x${string}`;
|
|
242
|
+
a2aProtocolRegistry: `0x${string}`;
|
|
243
|
+
reputationRegistry: `0x${string}`;
|
|
244
|
+
configurationRegistry: `0x${string}`;
|
|
245
|
+
}
|
|
246
|
+
interface PackResult {
|
|
247
|
+
/** CID of AES-256-GCM encrypted payload on IPFS */
|
|
248
|
+
encryptedCid: string;
|
|
249
|
+
/** CID of public metadata on IPFS */
|
|
250
|
+
publicCid: string;
|
|
251
|
+
/** Raw AES key (hex) — DO NOT share or upload this */
|
|
252
|
+
aesKeyHex: string;
|
|
253
|
+
/** ECIES-encrypted AES key (hex), safe to store on-chain */
|
|
254
|
+
eciesEncryptedKeyHex: string;
|
|
255
|
+
}
|
|
256
|
+
interface UnpackResult {
|
|
257
|
+
/** Decrypted AgentPayload */
|
|
258
|
+
agent: AgentPayload;
|
|
259
|
+
/** CID where the encrypted payload was fetched from */
|
|
260
|
+
encryptedCid: string;
|
|
261
|
+
/** CID of the public metadata */
|
|
262
|
+
publicCid: string;
|
|
263
|
+
}
|
|
264
|
+
declare enum AgentXErrorCode {
|
|
265
|
+
NOT_SUBSCRIBED = "NOT_SUBSCRIBED",
|
|
266
|
+
SUBSCRIPTION_EXPIRED = "SUBSCRIPTION_EXPIRED",
|
|
267
|
+
DECRYPTION_FAILED = "DECRYPTION_FAILED",
|
|
268
|
+
IPFS_FETCH_FAILED = "IPFS_FETCH_FAILED",
|
|
269
|
+
AGENT_NOT_FOUND = "AGENT_NOT_FOUND",
|
|
270
|
+
INVALID_SCHEMA = "INVALID_SCHEMA",
|
|
271
|
+
TX_FAILED = "TX_FAILED",
|
|
272
|
+
WALLET_NOT_CONNECTED = "WALLET_NOT_CONNECTED"
|
|
273
|
+
}
|
|
274
|
+
declare class AgentXError extends Error {
|
|
275
|
+
code: AgentXErrorCode;
|
|
276
|
+
/** If NOT_SUBSCRIBED, carry enough info for wallet/X402 auto-payment */
|
|
277
|
+
paymentInfo?: SubscriptionRequired;
|
|
278
|
+
constructor(code: AgentXErrorCode, message: string);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Structured info for wallet/X402 auto-subscription.
|
|
282
|
+
* Thrown by AgentRunner.useAgent() when the user/Agent has no
|
|
283
|
+
* active subscription.
|
|
284
|
+
*/
|
|
285
|
+
interface SubscriptionRequired {
|
|
286
|
+
agentId: number;
|
|
287
|
+
/** Plan IDs available for this Agent (on-chain query) */
|
|
288
|
+
plans?: {
|
|
289
|
+
planId: number;
|
|
290
|
+
price: bigint;
|
|
291
|
+
period: string;
|
|
292
|
+
payToken: string;
|
|
293
|
+
trialDays: number;
|
|
294
|
+
}[];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export { type AgentSubscription as A, type EncryptedPayload as E, type JSONSchema as J, type McpConnection as M, type OnChainAgentMetadata as O, type PackResult as P, type RegisteredAgent as R, type SkillDef as S, type UnpackResult as U, type A2AAgentCard as a, type A2ATask as b, type AgentReview as c, type AgentReputation as d, type A2ASkillExecution as e, type A2ATaskStatus as f, type AgentPayload as g, type AgentPricing as h, type AgentPrivatePayload as i, type AgentPublicPayload as j, type AgentSearchQuery as k, type AgentSearchResult as l, type AgentXConfig as m, type AgentXContracts as n, AgentXError as o, AgentXErrorCode as p, type JSONSchemaProperty as q, type McpTransport as r, type PricingType as s, type SkillExecutionMode as t, type SkillExecutionRemote as u, type SubscriptionRequired as v, type SubscriptionStatus as w };
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
interface JSONSchema {
|
|
2
|
+
type: 'object' | 'array' | 'string' | 'number' | 'boolean' | 'integer' | 'null';
|
|
3
|
+
properties?: Record<string, JSONSchemaProperty>;
|
|
4
|
+
required?: string[];
|
|
5
|
+
description?: string;
|
|
6
|
+
items?: JSONSchema;
|
|
7
|
+
enum?: (string | number | boolean | null)[];
|
|
8
|
+
}
|
|
9
|
+
interface JSONSchemaProperty {
|
|
10
|
+
type?: JSONSchema['type'] | JSONSchema['type'][];
|
|
11
|
+
description?: string;
|
|
12
|
+
properties?: Record<string, JSONSchemaProperty>;
|
|
13
|
+
required?: string[];
|
|
14
|
+
items?: JSONSchema;
|
|
15
|
+
enum?: (string | number | boolean | null)[];
|
|
16
|
+
format?: string;
|
|
17
|
+
default?: unknown;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A single skill module that an Agent exposes.
|
|
21
|
+
* `inputSchema` and `outputSchema` follow MCP Tool JSON Schema conventions.
|
|
22
|
+
*/
|
|
23
|
+
interface SkillDef {
|
|
24
|
+
/** Unique skill name (e.g. "solidity_audit") */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Human-readable description shown in the marketplace */
|
|
27
|
+
description: string;
|
|
28
|
+
/** Semantic version of this skill */
|
|
29
|
+
version: string;
|
|
30
|
+
/** JSON Schema for the tool's input parameters */
|
|
31
|
+
inputSchema: JSONSchema;
|
|
32
|
+
/** JSON Schema for the tool's output return value */
|
|
33
|
+
outputSchema?: JSONSchema;
|
|
34
|
+
/**
|
|
35
|
+
* Execution mode.
|
|
36
|
+
* - undefined / "open": Source is in the encrypted payload, runs locally.
|
|
37
|
+
* - { type: "mcp", toolName: "..." }: Source lives on the publisher's
|
|
38
|
+
* MCP server. Subscriber only gets Schema + remote execution endpoint.
|
|
39
|
+
* MCP server verifies on-chain subscription on every call.
|
|
40
|
+
* - { type: "a2a", targetAgentId: 42 }: Delegates to another AgentX Agent.
|
|
41
|
+
* The caller's AgentRunner loads + decrypts the target Agent, injects
|
|
42
|
+
* its prompt into the LLM context, and exposes its skills as callable
|
|
43
|
+
* tools. This is the core Agent Composition primitive.
|
|
44
|
+
*/
|
|
45
|
+
execution?: SkillExecutionRemote | A2ASkillExecution;
|
|
46
|
+
}
|
|
47
|
+
/** Where the skill code actually runs. */
|
|
48
|
+
type SkillExecutionMode = 'open' | 'mcp' | 'a2a';
|
|
49
|
+
interface SkillExecutionRemote {
|
|
50
|
+
type: 'mcp';
|
|
51
|
+
/** MCP tool name on the publisher's server (e.g. "run_strategy_abc123") */
|
|
52
|
+
toolName: string;
|
|
53
|
+
/** Optional: explicit MCP endpoint override */
|
|
54
|
+
endpoint?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A2A Skill Execution — delegate to another AgentX Agent.
|
|
58
|
+
*
|
|
59
|
+
* Example: A "trading" Agent has a skill:
|
|
60
|
+
* execution: { type: "a2a", targetAgentId: 42 }
|
|
61
|
+
* → When LLM calls this skill, AgentRunner loads Agent #42,
|
|
62
|
+
* decrypts its prompt+skills, and the sub-Agent runs in the
|
|
63
|
+
* same LLM conversation with its own system prompt.
|
|
64
|
+
*/
|
|
65
|
+
interface A2ASkillExecution {
|
|
66
|
+
type: 'a2a';
|
|
67
|
+
/** On-chain Agent ID to delegate to */
|
|
68
|
+
targetAgentId: number;
|
|
69
|
+
/** Optional: restrict which of the target Agent's skills are exposed */
|
|
70
|
+
skillFilter?: string[];
|
|
71
|
+
/** Optional: custom system prompt override for the sub-Agent */
|
|
72
|
+
promptOverride?: string;
|
|
73
|
+
}
|
|
74
|
+
type McpTransport = 'http' | 'sse' | 'stdio';
|
|
75
|
+
interface McpConnection {
|
|
76
|
+
/** Transport type */
|
|
77
|
+
type: McpTransport;
|
|
78
|
+
/** MCP server URL (required for http/sse) */
|
|
79
|
+
url?: string;
|
|
80
|
+
/** Optional: limit which tools the Agent exposes to users */
|
|
81
|
+
toolFilter?: string[];
|
|
82
|
+
/** Optional: MCP server authentication header / key */
|
|
83
|
+
authHeader?: string;
|
|
84
|
+
}
|
|
85
|
+
type PricingType = 'subscription' | 'pay_per_use' | 'free';
|
|
86
|
+
interface AgentPricing {
|
|
87
|
+
type: PricingType;
|
|
88
|
+
/** Amount in native unit (e.g. "0.01" for 0.01 ETH) */
|
|
89
|
+
amount: string;
|
|
90
|
+
/** ERC20 token address, or empty for native currency */
|
|
91
|
+
currency: string;
|
|
92
|
+
/** Billing period for subscriptions (e.g. "month", "year", "day") */
|
|
93
|
+
period?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The complete Agent definition.
|
|
97
|
+
*
|
|
98
|
+
* - Fields above "--- private payload ---" are public (IPFS publicPayloadCid).
|
|
99
|
+
* - Fields below are encrypted with AES-256-GCM and stored at encryptedPayloadCid.
|
|
100
|
+
*/
|
|
101
|
+
interface AgentPayload {
|
|
102
|
+
name: string;
|
|
103
|
+
description: string;
|
|
104
|
+
image?: string;
|
|
105
|
+
version: string;
|
|
106
|
+
tags: string[];
|
|
107
|
+
capabilities: string[];
|
|
108
|
+
supportedTasks: string[];
|
|
109
|
+
communicationProtocol: 'mcp' | 'a2a';
|
|
110
|
+
authenticationMethod: 'ecdsa';
|
|
111
|
+
pricing: AgentPricing;
|
|
112
|
+
prompt: string;
|
|
113
|
+
skills: SkillDef[];
|
|
114
|
+
mcp: McpConnection;
|
|
115
|
+
}
|
|
116
|
+
/** Subset of AgentPayload that is publicly visible */
|
|
117
|
+
type AgentPublicPayload = Omit<AgentPayload, 'prompt' | 'skills' | 'mcp'>;
|
|
118
|
+
/** Fields that must be encrypted before IPFS upload */
|
|
119
|
+
type AgentPrivatePayload = Pick<AgentPayload, 'prompt' | 'skills' | 'mcp'>;
|
|
120
|
+
interface EncryptedPayload {
|
|
121
|
+
encrypted: true;
|
|
122
|
+
algorithm: 'AES-256-GCM';
|
|
123
|
+
/** base64(iv + ciphertext + authTag) */
|
|
124
|
+
data: string;
|
|
125
|
+
}
|
|
126
|
+
interface OnChainAgentMetadata {
|
|
127
|
+
tokenURI: string;
|
|
128
|
+
attributes: {
|
|
129
|
+
name: string;
|
|
130
|
+
description: string;
|
|
131
|
+
/** CID of the AES-256-GCM encrypted payload on IPFS */
|
|
132
|
+
encryptedPayloadCid: string;
|
|
133
|
+
/** ECIES-encrypted AES key (secp256k1, hex string) */
|
|
134
|
+
eciesEncryptedKey: string;
|
|
135
|
+
/** CID of the public metadata on IPFS */
|
|
136
|
+
publicPayloadCid: string;
|
|
137
|
+
capabilities: string[];
|
|
138
|
+
skills: string[];
|
|
139
|
+
mcpEndpoint: string;
|
|
140
|
+
version: string;
|
|
141
|
+
tags: string[];
|
|
142
|
+
pricingType: PricingType;
|
|
143
|
+
pricingAmount: string;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
interface RegisteredAgent {
|
|
147
|
+
/** ERC-721 token ID (= agentId) */
|
|
148
|
+
agentId: number;
|
|
149
|
+
/** Owner wallet address */
|
|
150
|
+
owner: string;
|
|
151
|
+
/** Creator wallet address */
|
|
152
|
+
creator: string;
|
|
153
|
+
/** Full on-chain metadata */
|
|
154
|
+
metadata: OnChainAgentMetadata;
|
|
155
|
+
/** Block number where agent was registered */
|
|
156
|
+
registeredAt: number;
|
|
157
|
+
/** IPFS CID of the full public payload (resolved from tokenURI) */
|
|
158
|
+
publicPayloadCid: string;
|
|
159
|
+
}
|
|
160
|
+
interface AgentSearchQuery {
|
|
161
|
+
keyword?: string;
|
|
162
|
+
capabilities?: string[];
|
|
163
|
+
tags?: string[];
|
|
164
|
+
pricingType?: PricingType;
|
|
165
|
+
maxPrice?: string;
|
|
166
|
+
owner?: string;
|
|
167
|
+
sortBy?: 'latest' | 'reputation' | 'price_asc' | 'price_desc';
|
|
168
|
+
page?: number;
|
|
169
|
+
pageSize?: number;
|
|
170
|
+
}
|
|
171
|
+
interface AgentSearchResult {
|
|
172
|
+
agents: RegisteredAgent[];
|
|
173
|
+
total: number;
|
|
174
|
+
page: number;
|
|
175
|
+
pageSize: number;
|
|
176
|
+
}
|
|
177
|
+
type SubscriptionStatus = 'active' | 'expired' | 'cancelled' | 'pending';
|
|
178
|
+
interface AgentSubscription {
|
|
179
|
+
subscriptionId: number;
|
|
180
|
+
subscriber: string;
|
|
181
|
+
agentId: number;
|
|
182
|
+
status: SubscriptionStatus;
|
|
183
|
+
startedAt: number;
|
|
184
|
+
expiresAt: number;
|
|
185
|
+
period: string;
|
|
186
|
+
}
|
|
187
|
+
type A2ATaskStatus = 'created' | 'accepted' | 'in_progress' | 'completed' | 'failed';
|
|
188
|
+
interface A2AAgentCard {
|
|
189
|
+
agentId: number;
|
|
190
|
+
name: string;
|
|
191
|
+
capabilities: string[];
|
|
192
|
+
supportedTasks: string[];
|
|
193
|
+
/** MCP endpoint URL for direct agent-to-agent communication */
|
|
194
|
+
endpoint: string;
|
|
195
|
+
/** Public key for ECDSA authentication */
|
|
196
|
+
publicKey: string;
|
|
197
|
+
}
|
|
198
|
+
interface A2ATask {
|
|
199
|
+
taskId: number;
|
|
200
|
+
/** Agent that created the task */
|
|
201
|
+
creator: string;
|
|
202
|
+
/** Target agent to execute the task */
|
|
203
|
+
targetAgentId: number;
|
|
204
|
+
/** Task type (must be in target's supportedTasks) */
|
|
205
|
+
taskType: string;
|
|
206
|
+
/** JSON input payload */
|
|
207
|
+
input: string;
|
|
208
|
+
status: A2ATaskStatus;
|
|
209
|
+
result?: string;
|
|
210
|
+
createdAt: number;
|
|
211
|
+
completedAt?: number;
|
|
212
|
+
}
|
|
213
|
+
interface AgentReputation {
|
|
214
|
+
agentId: number;
|
|
215
|
+
averageRating: number;
|
|
216
|
+
totalRatings: number;
|
|
217
|
+
reviews: AgentReview[];
|
|
218
|
+
}
|
|
219
|
+
interface AgentReview {
|
|
220
|
+
reviewer: string;
|
|
221
|
+
rating: number;
|
|
222
|
+
comment: string;
|
|
223
|
+
timestamp: number;
|
|
224
|
+
}
|
|
225
|
+
interface AgentXConfig {
|
|
226
|
+
/** Chain ID (e.g. 11155111 for Sepolia) */
|
|
227
|
+
chainId: number;
|
|
228
|
+
/** RPC endpoint override (uses viem's default if omitted) */
|
|
229
|
+
rpcUrl?: string;
|
|
230
|
+
/** Contract addresses for the current chain */
|
|
231
|
+
contracts: AgentXContracts;
|
|
232
|
+
/** IPFS gateway URLs (ordered by priority) */
|
|
233
|
+
ipfsGateways: string[];
|
|
234
|
+
/** Default IPFS pinning service */
|
|
235
|
+
pinningService?: 'pinata';
|
|
236
|
+
pinataJwt?: string;
|
|
237
|
+
}
|
|
238
|
+
interface AgentXContracts {
|
|
239
|
+
identityRegistry: `0x${string}`;
|
|
240
|
+
subscriptionManager: `0x${string}`;
|
|
241
|
+
paymentGateway: `0x${string}`;
|
|
242
|
+
a2aProtocolRegistry: `0x${string}`;
|
|
243
|
+
reputationRegistry: `0x${string}`;
|
|
244
|
+
configurationRegistry: `0x${string}`;
|
|
245
|
+
}
|
|
246
|
+
interface PackResult {
|
|
247
|
+
/** CID of AES-256-GCM encrypted payload on IPFS */
|
|
248
|
+
encryptedCid: string;
|
|
249
|
+
/** CID of public metadata on IPFS */
|
|
250
|
+
publicCid: string;
|
|
251
|
+
/** Raw AES key (hex) — DO NOT share or upload this */
|
|
252
|
+
aesKeyHex: string;
|
|
253
|
+
/** ECIES-encrypted AES key (hex), safe to store on-chain */
|
|
254
|
+
eciesEncryptedKeyHex: string;
|
|
255
|
+
}
|
|
256
|
+
interface UnpackResult {
|
|
257
|
+
/** Decrypted AgentPayload */
|
|
258
|
+
agent: AgentPayload;
|
|
259
|
+
/** CID where the encrypted payload was fetched from */
|
|
260
|
+
encryptedCid: string;
|
|
261
|
+
/** CID of the public metadata */
|
|
262
|
+
publicCid: string;
|
|
263
|
+
}
|
|
264
|
+
declare enum AgentXErrorCode {
|
|
265
|
+
NOT_SUBSCRIBED = "NOT_SUBSCRIBED",
|
|
266
|
+
SUBSCRIPTION_EXPIRED = "SUBSCRIPTION_EXPIRED",
|
|
267
|
+
DECRYPTION_FAILED = "DECRYPTION_FAILED",
|
|
268
|
+
IPFS_FETCH_FAILED = "IPFS_FETCH_FAILED",
|
|
269
|
+
AGENT_NOT_FOUND = "AGENT_NOT_FOUND",
|
|
270
|
+
INVALID_SCHEMA = "INVALID_SCHEMA",
|
|
271
|
+
TX_FAILED = "TX_FAILED",
|
|
272
|
+
WALLET_NOT_CONNECTED = "WALLET_NOT_CONNECTED"
|
|
273
|
+
}
|
|
274
|
+
declare class AgentXError extends Error {
|
|
275
|
+
code: AgentXErrorCode;
|
|
276
|
+
/** If NOT_SUBSCRIBED, carry enough info for wallet/X402 auto-payment */
|
|
277
|
+
paymentInfo?: SubscriptionRequired;
|
|
278
|
+
constructor(code: AgentXErrorCode, message: string);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Structured info for wallet/X402 auto-subscription.
|
|
282
|
+
* Thrown by AgentRunner.useAgent() when the user/Agent has no
|
|
283
|
+
* active subscription.
|
|
284
|
+
*/
|
|
285
|
+
interface SubscriptionRequired {
|
|
286
|
+
agentId: number;
|
|
287
|
+
/** Plan IDs available for this Agent (on-chain query) */
|
|
288
|
+
plans?: {
|
|
289
|
+
planId: number;
|
|
290
|
+
price: bigint;
|
|
291
|
+
period: string;
|
|
292
|
+
payToken: string;
|
|
293
|
+
trialDays: number;
|
|
294
|
+
}[];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export { type AgentSubscription as A, type EncryptedPayload as E, type JSONSchema as J, type McpConnection as M, type OnChainAgentMetadata as O, type PackResult as P, type RegisteredAgent as R, type SkillDef as S, type UnpackResult as U, type A2AAgentCard as a, type A2ATask as b, type AgentReview as c, type AgentReputation as d, type A2ASkillExecution as e, type A2ATaskStatus as f, type AgentPayload as g, type AgentPricing as h, type AgentPrivatePayload as i, type AgentPublicPayload as j, type AgentSearchQuery as k, type AgentSearchResult as l, type AgentXConfig as m, type AgentXContracts as n, AgentXError as o, AgentXErrorCode as p, type JSONSchemaProperty as q, type McpTransport as r, type PricingType as s, type SkillExecutionMode as t, type SkillExecutionRemote as u, type SubscriptionRequired as v, type SubscriptionStatus as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentxv2/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "AgentX — Decentralized AI Agent SDK with ECIES + AES-256-GCM encryption",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"README.md"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "tsup src/index.ts src/core/index.ts src/react/index.ts --format cjs,esm --dts --clean --sourcemap --splitting false --out-dir dist && node /tmp/postbuild.js",
|
|
30
|
+
"build": "tsup src/index.ts src/core/index.ts src/react/index.ts src/endpoint/index.ts src/configuration/index.ts --format cjs,esm --dts --clean --sourcemap --splitting false --out-dir dist && node /tmp/postbuild.js",
|
|
31
31
|
"test": "vitest run",
|
|
32
32
|
"typecheck": "tsc --noEmit"
|
|
33
33
|
},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|