@agentxv2/sdk 0.5.1 → 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.
Files changed (36) hide show
  1. package/README.md +63 -20
  2. package/dist/configuration/index.d.mts +31 -0
  3. package/dist/configuration/index.d.ts +31 -0
  4. package/dist/configuration/index.js +155 -0
  5. package/dist/configuration/index.js.map +1 -0
  6. package/dist/configuration/index.mjs +128 -0
  7. package/dist/configuration/index.mjs.map +1 -0
  8. package/dist/core.d.mts +64 -0
  9. package/dist/core.d.ts +64 -0
  10. package/dist/endpoint/index.d.mts +39 -0
  11. package/dist/endpoint/index.d.ts +39 -0
  12. package/dist/endpoint/index.js +193 -0
  13. package/dist/endpoint/index.js.map +1 -0
  14. package/dist/endpoint/index.mjs +166 -0
  15. package/dist/endpoint/index.mjs.map +1 -0
  16. package/dist/index-BlD1-fQt.d.mts +209 -0
  17. package/dist/index-DV-tFsBT.d.ts +209 -0
  18. package/dist/index.d.mts +271 -0
  19. package/dist/index.d.ts +271 -0
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +1 -1
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/react.d.mts +3 -0
  25. package/dist/react.d.ts +3 -0
  26. package/dist/types-2aHUvS4M.d.mts +297 -0
  27. package/dist/types-2aHUvS4M.d.ts +297 -0
  28. package/package.json +2 -2
  29. /package/dist/{core/index.js → core.js} +0 -0
  30. /package/dist/{core/index.js.map → core.js.map} +0 -0
  31. /package/dist/{core/index.mjs → core.mjs} +0 -0
  32. /package/dist/{core/index.mjs.map → core.mjs.map} +0 -0
  33. /package/dist/{react/index.js → react.js} +0 -0
  34. /package/dist/{react/index.js.map → react.js.map} +0 -0
  35. /package/dist/{react/index.mjs → react.mjs} +0 -0
  36. /package/dist/{react/index.mjs.map → react.mjs.map} +0 -0
@@ -0,0 +1,271 @@
1
+ import { A as AgentSubscription, a as A2AAgentCard, b as A2ATask, M as McpConnection, c as AgentReview, d as AgentReputation } from './types-2aHUvS4M.js';
2
+ export { e as A2ASkillExecution, f as A2ATaskStatus, g as AgentPayload, h as AgentPricing, i as AgentPrivatePayload, j as AgentPublicPayload, k as AgentSearchQuery, l as AgentSearchResult, m as AgentXConfig, n as AgentXContracts, o as AgentXError, p as AgentXErrorCode, E as EncryptedPayload, J as JSONSchema, q as JSONSchemaProperty, r as McpTransport, O as OnChainAgentMetadata, P as PackResult, s as PricingType, R as RegisteredAgent, S as SkillDef, t as SkillExecutionMode, u as SkillExecutionRemote, v as SubscriptionRequired, w as SubscriptionStatus, U as UnpackResult } from './types-2aHUvS4M.js';
3
+ export { aesDecrypt, aesEncrypt, decryptPayload, eciesDecrypt, eciesEncrypt, encryptPayload, generateAesKey, generateKeyPair, getPublicKey, packAgentForPublish, randomBytes, unpackAgent } from './core/index.js';
4
+ export { A as A2ASkillResult, a as AgentRunContext, b as AgentRunner, c as AgentRunnerConfig, C as ChainConfig, d as ConfigRegistryOpts, e as ConfigurationRegistry, I as IPFSFetcher, f as IPFSFetcherConfig, K as KNOWN_CHAINS, O as OnChainReader, R as RunnableSkill, U as UseAgentRunnerConfig, g as UseAgentRunnerResult, W as WalletSigner, h as defaultIPFSFetcher, u as useAgentRunner } from './index-DV-tFsBT.js';
5
+ export { EndpointRecord, MultiEndpointClient, MultiEndpointConfig } from './endpoint/index.js';
6
+ export { ConfigEntry, ConfigurationClient, ConfigurationConfig } from './configuration/index.js';
7
+ import { Address, PublicClient, WalletClient, Hash } from 'viem';
8
+ export { bytesToHex, hexToBytes } from '@noble/ciphers/utils.js';
9
+
10
+ interface AgentRegistryConfig {
11
+ /** IdentityRegistry contract address */
12
+ contractAddress: Address;
13
+ /** viem PublicClient for read calls */
14
+ publicClient: PublicClient;
15
+ /** viem WalletClient for write calls */
16
+ walletClient: WalletClient;
17
+ }
18
+ declare class AgentRegistry {
19
+ private address;
20
+ private publicClient;
21
+ private walletClient;
22
+ constructor(config: AgentRegistryConfig);
23
+ /**
24
+ * Register a new Agent NFT on-chain.
25
+ *
26
+ * @param tokenURI IPFS URI of the public metadata (ipfs://...)
27
+ * @param metadata Key-value metadata (encryptedPayloadCid, eciesEncryptedKey, etc.)
28
+ * @param valueWei Optional: native currency to send with registration
29
+ * @returns { agentId: number, txHash: Hash }
30
+ */
31
+ register(tokenURI: string, metadata: {
32
+ key: string;
33
+ value: string;
34
+ }[], valueWei?: bigint): Promise<{
35
+ agentId: number;
36
+ txHash: Hash;
37
+ }>;
38
+ /**
39
+ * Simple register — just a tokenURI, no extra metadata.
40
+ */
41
+ registerSimple(tokenURI: string, valueWei?: bigint): Promise<{
42
+ agentId: number;
43
+ txHash: Hash;
44
+ }>;
45
+ /** Get all agent IDs owned by an address. */
46
+ getAgentsByOwner(owner: Address): Promise<number[]>;
47
+ /** Get the current total agent count. */
48
+ getCurrentAgentId(): Promise<number>;
49
+ /** Check if an agent exists. */
50
+ agentExists(agentId: number): Promise<boolean>;
51
+ /** Get the tokenURI for an agent. */
52
+ tokenURI(agentId: number): Promise<string>;
53
+ /** Get all metadata attributes for an agent as key-value pairs. */
54
+ getAttributes(agentId: number): Promise<Record<string, string>>;
55
+ /** Extract tokenId from the Transfer event in the receipt. */
56
+ private _parseAgentIdFromReceipt;
57
+ }
58
+ /** Extract IPFS CID from an ipfs:// URI. */
59
+ declare function cidFromURI(uri: string): string;
60
+
61
+ declare const REGISTRY_VERSION = "0.1.0";
62
+
63
+ interface SubscriptionConfig {
64
+ contractAddress: Address;
65
+ publicClient: PublicClient;
66
+ walletClient: WalletClient;
67
+ }
68
+ interface PlanDetail {
69
+ planId: number;
70
+ agentId: number;
71
+ creator: Address;
72
+ price: bigint;
73
+ period: string;
74
+ active: boolean;
75
+ payToken: Address;
76
+ trialDays: number;
77
+ }
78
+ interface SubscriptionDetail {
79
+ subscriptionId: number;
80
+ subscriber: Address;
81
+ agentId: number;
82
+ status: number;
83
+ startedAt: number;
84
+ expiresAt: number;
85
+ period: string;
86
+ payToken: Address;
87
+ amountPaid: bigint;
88
+ trialActive: boolean;
89
+ trialEndsAt: number;
90
+ fundsReleased: boolean;
91
+ }
92
+ declare class SubscriptionManager {
93
+ private address;
94
+ private publicClient;
95
+ private walletClient;
96
+ constructor(config: SubscriptionConfig);
97
+ /** Get current platform fee in basis points (e.g. 250 = 2.5%). */
98
+ getPlatformFeeBps(): Promise<number>;
99
+ /** Check if a token is whitelisted for payments. */
100
+ isTokenWhitelisted(token: Address): Promise<boolean>;
101
+ /** Get full plan details with v2 fields. */
102
+ getPlan(planId: number): Promise<PlanDetail>;
103
+ /**
104
+ * Subscribe to a plan.
105
+ * For ETH plans: pass valueWei = plan.price.
106
+ * For ERC20 plans: auto-detects from plan.payToken, calls approve + subscribe.
107
+ * User must have approved this contract for plan.price tokens.
108
+ */
109
+ subscribe(planId: number, opts?: {
110
+ valueWei?: bigint;
111
+ approveTokenFirst?: boolean;
112
+ }): Promise<{
113
+ subscriptionId: number;
114
+ txHash: Hash;
115
+ }>;
116
+ /** Release escrowed funds to creator after trial window ends. */
117
+ releaseFunds(subscriptionId: number): Promise<Hash>;
118
+ /** Cancel subscription (trial refund if within window). */
119
+ cancel(subscriptionId: number): Promise<Hash>;
120
+ hasActiveSubscription(subscriber: Address, agentId: number): Promise<boolean>;
121
+ getSubscription(subscriber: Address, agentId: number): Promise<AgentSubscription | null>;
122
+ /** Get full subscription detail with v2 fields (trial, payToken, fundsReleased). */
123
+ getSubscriptionDetail(subscriptionId: number): Promise<SubscriptionDetail>;
124
+ getUserSubscriptions(user: Address): Promise<number[]>;
125
+ }
126
+ declare function guardSubscription(manager: SubscriptionManager, user: Address, agentId: number): Promise<AgentSubscription>;
127
+
128
+ interface AgentX402Config {
129
+ subscriptionManagerAddress: Address;
130
+ publicClient: PublicClient;
131
+ walletClient: WalletClient;
132
+ }
133
+ declare class AgentX402 {
134
+ private config;
135
+ constructor(config: AgentX402Config);
136
+ /**
137
+ * Require active subscription — or throw with auto-pay info.
138
+ *
139
+ * Usage:
140
+ * await x402.requireSubscription(agentId, address, { planIds: [1,2,3] })
141
+ *
142
+ * On success, returns silently.
143
+ * On failure, throws AgentXError with paymentInfo populated
144
+ * so the caller can auto-pay via wallet/X402.
145
+ */
146
+ requireSubscription(agentId: number, address: Address, opts?: {
147
+ planIds?: number[];
148
+ }): Promise<void>;
149
+ /**
150
+ * Subscribe to a plan + wait for receipt.
151
+ * Returns subscriptionId from the Subscribed event.
152
+ *
153
+ * NOTE: For ERC20 plans, the caller must approve token spending
154
+ * BEFORE calling this method. Use X402 SDK or wagmi's useWriteContract
155
+ * for the approve step.
156
+ */
157
+ subscribeAndWait(planId: number, price: bigint, payToken: Address): Promise<number>;
158
+ }
159
+
160
+ declare const SUBSCRIPTION_VERSION = "0.2.0";
161
+
162
+ interface A2AConfig {
163
+ contractAddress: Address;
164
+ publicClient: PublicClient;
165
+ walletClient: WalletClient;
166
+ }
167
+ declare class A2AProtocol {
168
+ private address;
169
+ private publicClient;
170
+ private walletClient;
171
+ constructor(config: A2AConfig);
172
+ private get account();
173
+ createAgentCard(agentId: number, card: {
174
+ name: string;
175
+ description: string;
176
+ version: string;
177
+ capabilities: string[];
178
+ supportedTasks: string[];
179
+ commProtocol?: string;
180
+ authMethod?: string;
181
+ cardURI?: string;
182
+ }): Promise<{
183
+ cardId: number;
184
+ txHash: Hash;
185
+ }>;
186
+ getAgentCard(agentId: number): Promise<A2AAgentCard | null>;
187
+ createTask(agentId: number, taskType: string, input: Record<string, unknown>): Promise<{
188
+ taskId: number;
189
+ txHash: Hash;
190
+ }>;
191
+ completeTask(taskId: number, output: unknown): Promise<Hash>;
192
+ getTask(taskId: number): Promise<A2ATask | null>;
193
+ getUserTasks(user: Address): Promise<number[]>;
194
+ private _parseUintFromLog;
195
+ }
196
+
197
+ declare const A2A_VERSION = "0.1.0";
198
+
199
+ interface MCPTool {
200
+ name: string;
201
+ description?: string;
202
+ inputSchema: Record<string, unknown>;
203
+ }
204
+ interface MCPCallResult {
205
+ content: {
206
+ type: string;
207
+ text?: string;
208
+ data?: string;
209
+ }[];
210
+ isError?: boolean;
211
+ }
212
+ interface MCPConnectorConfig {
213
+ /** MCP server base URL */
214
+ url: string;
215
+ /** Transport type */
216
+ transport?: 'http' | 'sse';
217
+ /** Auth header value (e.g. "Bearer xxx") */
218
+ authHeader?: string;
219
+ /** Request timeout in ms (default: 30_000) */
220
+ timeoutMs?: number;
221
+ /** Optional: subscriber address for subscription-gated MCP servers */
222
+ subscriberAddress?: string;
223
+ /** Optional: wallet signature for authentication */
224
+ signature?: string;
225
+ timestamp?: number;
226
+ }
227
+ declare class MCPConnector {
228
+ private config;
229
+ constructor(config: MCPConnectorConfig);
230
+ /** Create from an Agent's McpConnection. */
231
+ static fromAgent(mcp: McpConnection, opts?: Partial<MCPConnectorConfig>): MCPConnector;
232
+ /** List available tools from the MCP server. */
233
+ listTools(): Promise<MCPTool[]>;
234
+ /** Call a tool on the MCP server. */
235
+ callTool(name: string, args?: Record<string, unknown>): Promise<MCPCallResult>;
236
+ listResources(): Promise<unknown[]>;
237
+ readResource(uri: string): Promise<unknown>;
238
+ private _request;
239
+ }
240
+
241
+ declare const MCP_VERSION = "0.1.0";
242
+
243
+ interface ReputationConfig {
244
+ contractAddress: Address;
245
+ publicClient: PublicClient;
246
+ walletClient: WalletClient;
247
+ }
248
+ declare class ReputationRegistry {
249
+ private address;
250
+ private publicClient;
251
+ private walletClient;
252
+ constructor(config: ReputationConfig);
253
+ private get account();
254
+ /** Submit a rating (1-5) with optional comment. */
255
+ rate(agentId: number, rating: number, comment?: string): Promise<Hash>;
256
+ /** Get average rating and total count. */
257
+ getRating(agentId: number): Promise<{
258
+ averageRating: number;
259
+ totalRatings: number;
260
+ }>;
261
+ /** Get all reviews for an agent. */
262
+ getReviews(agentId: number): Promise<AgentReview[]>;
263
+ /** Get full reputation summary. */
264
+ getReputation(agentId: number): Promise<AgentReputation>;
265
+ }
266
+
267
+ declare const REPUTATION_VERSION = "0.1.0";
268
+
269
+ declare const CONFIG_VERSION = "0.1.0";
270
+
271
+ export { A2AAgentCard, type A2AConfig, A2AProtocol, A2ATask, A2A_VERSION, AgentRegistry, type AgentRegistryConfig, AgentReputation, AgentReview, AgentSubscription, AgentX402, type AgentX402Config, CONFIG_VERSION, type MCPCallResult, MCPConnector, type MCPConnectorConfig, type MCPTool, MCP_VERSION, McpConnection, type PlanDetail, REGISTRY_VERSION, REPUTATION_VERSION, type ReputationConfig, ReputationRegistry, SUBSCRIPTION_VERSION, type SubscriptionConfig, type SubscriptionDetail, SubscriptionManager, cidFromURI, guardSubscription };
package/dist/index.js CHANGED
@@ -2369,7 +2369,7 @@ var MultiEndpointClient = class {
2369
2369
  const endpoints = await this.getActiveEndpoints(agentId);
2370
2370
  if (endpoints.length === 0) return null;
2371
2371
  const http = endpoints.find((e) => e.protocol === "HTTP");
2372
- return http ?? endpoints[0];
2372
+ return http ?? endpoints[0] ?? null;
2373
2373
  }
2374
2374
  /** Pick any active endpoint URL — for MCP connector */
2375
2375
  async getBestMCPUrl(agentId) {