@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.
- package/README.md +63 -20
- 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
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { E as EncryptedPayload, g as AgentPayload, P as PackResult } from './types-2aHUvS4M.js';
|
|
2
|
+
import { Address, PublicClient, WalletClient, Hash } from 'viem';
|
|
3
|
+
|
|
4
|
+
interface IPFSFetcherConfig {
|
|
5
|
+
/** Primary IPFS gateway (default: ipfs.io) */
|
|
6
|
+
gateway?: string;
|
|
7
|
+
/** Fallback gateways in order of preference */
|
|
8
|
+
fallbackGateways?: string[];
|
|
9
|
+
/** Request timeout in ms (default: 10_000) */
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
/** Max cached entries (LRU-like eviction, default: 200) */
|
|
12
|
+
maxCache?: number;
|
|
13
|
+
}
|
|
14
|
+
declare class IPFSFetcher {
|
|
15
|
+
private gateway;
|
|
16
|
+
private fallbackGateways;
|
|
17
|
+
private timeoutMs;
|
|
18
|
+
private cache;
|
|
19
|
+
private maxCache;
|
|
20
|
+
private pending;
|
|
21
|
+
private failed;
|
|
22
|
+
constructor(config?: IPFSFetcherConfig);
|
|
23
|
+
/** Fetch JSON from a single IPFS CID. */
|
|
24
|
+
fetchJSON<T = unknown>(cid: string): Promise<T>;
|
|
25
|
+
/** Fetch encrypted agent payload (validates algorithm). */
|
|
26
|
+
fetchEncryptedPayload(cid: string): Promise<EncryptedPayload>;
|
|
27
|
+
/** Batch fetch multiple CIDs with concurrency control. */
|
|
28
|
+
fetchBatch<T = unknown>(cids: string[], concurrency?: number): Promise<Map<string, T>>;
|
|
29
|
+
/** Check if a string looks like a valid IPFS CID. */
|
|
30
|
+
isValidCID(cid: string): boolean;
|
|
31
|
+
/** Clear cache (optionally for a specific CID). */
|
|
32
|
+
clearCache(cid?: string): void;
|
|
33
|
+
/** Number of cached entries. */
|
|
34
|
+
get cacheSize(): number;
|
|
35
|
+
private _doFetch;
|
|
36
|
+
private _fetchFrom;
|
|
37
|
+
private _cacheSet;
|
|
38
|
+
}
|
|
39
|
+
/** Singleton-friendly default instance. */
|
|
40
|
+
declare const defaultIPFSFetcher: IPFSFetcher;
|
|
41
|
+
|
|
42
|
+
/** Minimal on-chain reader interface — implement with viem. */
|
|
43
|
+
interface OnChainReader {
|
|
44
|
+
/** Read tokenURI from IdentityRegistry by tokenId. */
|
|
45
|
+
getTokenURI(agentId: number): Promise<string>;
|
|
46
|
+
/** Get agent metadata attributes (returned as key-value pairs). */
|
|
47
|
+
getAttributes(agentId: number): Promise<Record<string, string>>;
|
|
48
|
+
/** Check if `address` has an active subscription for `agentId`. */
|
|
49
|
+
hasActiveSubscription(address: string, agentId: number): Promise<boolean>;
|
|
50
|
+
}
|
|
51
|
+
/** Minimal wallet signer interface — implement with wagmi/viem. */
|
|
52
|
+
interface WalletSigner {
|
|
53
|
+
/** Sign a message (for authentication to MCP servers). */
|
|
54
|
+
signMessage(message: string): Promise<string>;
|
|
55
|
+
/** Get the current wallet address. */
|
|
56
|
+
getAddress(): Promise<string>;
|
|
57
|
+
/** Get the wallet's ECDSA private key (required for ECIES decryption). */
|
|
58
|
+
getPrivateKey?(): Promise<string>;
|
|
59
|
+
}
|
|
60
|
+
interface AgentRunnerConfig {
|
|
61
|
+
/** On-chain data reader (injected from viem/wagmi). */
|
|
62
|
+
reader: OnChainReader;
|
|
63
|
+
/** Wallet signer (injected from wagmi). */
|
|
64
|
+
wallet: WalletSigner;
|
|
65
|
+
/** IPFS fetcher instance (creates default if omitted). */
|
|
66
|
+
ipfsFetcher?: IPFSFetcher;
|
|
67
|
+
/** IPFS gateway list (overrides IPFSFetcher defaults). */
|
|
68
|
+
ipfsGateways?: string[];
|
|
69
|
+
}
|
|
70
|
+
interface AgentRunContext {
|
|
71
|
+
/** Agent NFT token ID */
|
|
72
|
+
agentId: number;
|
|
73
|
+
/** System prompt — inject into LLM conversation */
|
|
74
|
+
prompt: string;
|
|
75
|
+
/** All skills with execution metadata */
|
|
76
|
+
skills: RunnableSkill[];
|
|
77
|
+
/** MCP connection info */
|
|
78
|
+
mcp: {
|
|
79
|
+
type: string;
|
|
80
|
+
url?: string;
|
|
81
|
+
toolFilter?: string[];
|
|
82
|
+
};
|
|
83
|
+
/** Subscription expiry timestamp (0 = unknown) */
|
|
84
|
+
subscriptionExpiry: number;
|
|
85
|
+
}
|
|
86
|
+
interface RunnableSkill {
|
|
87
|
+
name: string;
|
|
88
|
+
description: string;
|
|
89
|
+
inputSchema: Record<string, unknown>;
|
|
90
|
+
outputSchema?: Record<string, unknown>;
|
|
91
|
+
/** Execution mode */
|
|
92
|
+
mode: 'open' | 'mcp' | 'a2a';
|
|
93
|
+
/** If mode='a2a', the on-chain Agent ID being delegated to */
|
|
94
|
+
a2aTargetAgentId?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Execute this skill with the given input.
|
|
97
|
+
* - Open: runs locally (caller provides implementation)
|
|
98
|
+
* - MCP: POSTs to the publisher's MCP server
|
|
99
|
+
* - A2A: loads target Agent context (prompt+skills) via AgentRunner
|
|
100
|
+
*/
|
|
101
|
+
execute(input: Record<string, unknown>): Promise<unknown>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Standard return type for A2A skill execution.
|
|
105
|
+
* The calling LLM receives the sub-Agent's prompt and skills
|
|
106
|
+
* and can inject them into the conversation.
|
|
107
|
+
*/
|
|
108
|
+
interface A2ASkillResult {
|
|
109
|
+
/** On-chain Agent ID that was delegated to */
|
|
110
|
+
agentId: number;
|
|
111
|
+
/** Sub-Agent's decrypted system prompt */
|
|
112
|
+
prompt: string;
|
|
113
|
+
/** Sub-Agent's skills (name + description + schema only, no execute) */
|
|
114
|
+
skills: {
|
|
115
|
+
name: string;
|
|
116
|
+
description: string;
|
|
117
|
+
inputSchema: Record<string, unknown>;
|
|
118
|
+
}[];
|
|
119
|
+
/** The original input passed by the caller */
|
|
120
|
+
callerInput: Record<string, unknown>;
|
|
121
|
+
}
|
|
122
|
+
declare class AgentRunner {
|
|
123
|
+
private reader;
|
|
124
|
+
private wallet;
|
|
125
|
+
private ipfs;
|
|
126
|
+
constructor(config: AgentRunnerConfig);
|
|
127
|
+
/**
|
|
128
|
+
* Load and decrypt an Agent, returning a run context ready to inject
|
|
129
|
+
* into any LLM conversation.
|
|
130
|
+
*
|
|
131
|
+
* Steps:
|
|
132
|
+
* 1. Verify on-chain subscription (frontend check)
|
|
133
|
+
* 2. Fetch metadata → get encryptedPayloadCid + eciesEncryptedKey
|
|
134
|
+
* 3. IPFS fetch encrypted payload
|
|
135
|
+
* 4. ECIES decrypt AES key (using wallet private key)
|
|
136
|
+
* 5. AES-256-GCM decrypt payload → { prompt, skills, mcp }
|
|
137
|
+
* 6. Build RunnableSkill wrappers (Open: local stub, Closed: MCP remote)
|
|
138
|
+
*/
|
|
139
|
+
useAgent(agentId: number): Promise<AgentRunContext>;
|
|
140
|
+
/**
|
|
141
|
+
* Pack an AgentPayload for publishing (encryption only, no IPFS upload).
|
|
142
|
+
* Caller is responsible for IPFS upload and on-chain registration.
|
|
143
|
+
*/
|
|
144
|
+
packForPublish(payload: AgentPayload, publicKey: string): PackResult;
|
|
145
|
+
/** Wrap a SkillDef into a RunnableSkill with execute(). */
|
|
146
|
+
private _wrapSkill;
|
|
147
|
+
/** Call a tool on the publisher's MCP server (Closed skill). */
|
|
148
|
+
private _executeMCPTool;
|
|
149
|
+
/**
|
|
150
|
+
* Execute an A2A skill — delegate to another AgentX Agent.
|
|
151
|
+
*
|
|
152
|
+
* Standard Interface:
|
|
153
|
+
* Input: { task, ...taskSpecificParams }
|
|
154
|
+
* Output: { agentId, prompt, skills[] }
|
|
155
|
+
*
|
|
156
|
+
* The caller (LLM) receives the sub-Agent's prompt + skill list.
|
|
157
|
+
* The LLM then decides how to use the sub-Agent — typically by
|
|
158
|
+
* injecting the sub-Agent's system prompt and calling its skills.
|
|
159
|
+
*/
|
|
160
|
+
private _executeA2ASkill;
|
|
161
|
+
private _getPrivateKey;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface ChainConfig {
|
|
165
|
+
chainId: number;
|
|
166
|
+
contracts: {
|
|
167
|
+
identityRegistry: Address;
|
|
168
|
+
subscriptionManager: Address;
|
|
169
|
+
paymentGateway: Address;
|
|
170
|
+
a2aProtocolRegistry: Address;
|
|
171
|
+
reputationRegistry: Address;
|
|
172
|
+
configurationRegistry: Address;
|
|
173
|
+
multiEndpointRegistry: Address;
|
|
174
|
+
};
|
|
175
|
+
ipfsGateways: string[];
|
|
176
|
+
rpcUrl?: string;
|
|
177
|
+
}
|
|
178
|
+
declare const KNOWN_CHAINS: Record<number, ChainConfig>;
|
|
179
|
+
interface ConfigRegistryOpts {
|
|
180
|
+
contractAddress: Address;
|
|
181
|
+
publicClient: PublicClient;
|
|
182
|
+
walletClient: WalletClient;
|
|
183
|
+
}
|
|
184
|
+
declare class ConfigurationRegistry {
|
|
185
|
+
private address;
|
|
186
|
+
private publicClient;
|
|
187
|
+
private walletClient;
|
|
188
|
+
constructor(opts: ConfigRegistryOpts);
|
|
189
|
+
private get account();
|
|
190
|
+
set(key: string, value: string): Promise<Hash>;
|
|
191
|
+
get(key: string): Promise<string>;
|
|
192
|
+
getAll(): Promise<Record<string, string>>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
interface UseAgentRunnerConfig {
|
|
196
|
+
agentId: number;
|
|
197
|
+
chainConfig?: ChainConfig;
|
|
198
|
+
ipfsGateways?: string[];
|
|
199
|
+
}
|
|
200
|
+
interface UseAgentRunnerResult {
|
|
201
|
+
ctx: AgentRunContext | null;
|
|
202
|
+
isLoading: boolean;
|
|
203
|
+
error: Error | null;
|
|
204
|
+
/** Re-trigger the load (e.g. after connecting wallet or subscribing) */
|
|
205
|
+
refetch: () => void;
|
|
206
|
+
}
|
|
207
|
+
declare function useAgentRunner(config: UseAgentRunnerConfig): UseAgentRunnerResult;
|
|
208
|
+
|
|
209
|
+
export { type A2ASkillResult as A, type ChainConfig as C, IPFSFetcher as I, KNOWN_CHAINS as K, type OnChainReader as O, type RunnableSkill as R, type UseAgentRunnerConfig as U, type WalletSigner as W, type AgentRunContext as a, AgentRunner as b, type AgentRunnerConfig as c, type ConfigRegistryOpts as d, ConfigurationRegistry as e, type IPFSFetcherConfig as f, type UseAgentRunnerResult as g, defaultIPFSFetcher as h, useAgentRunner as u };
|
package/dist/index.d.mts
ADDED
|
@@ -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.mjs';
|
|
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.mjs';
|
|
3
|
+
export { aesDecrypt, aesEncrypt, decryptPayload, eciesDecrypt, eciesEncrypt, encryptPayload, generateAesKey, generateKeyPair, getPublicKey, packAgentForPublish, randomBytes, unpackAgent } from './core/index.mjs';
|
|
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-BlD1-fQt.mjs';
|
|
5
|
+
export { EndpointRecord, MultiEndpointClient, MultiEndpointConfig } from './endpoint/index.mjs';
|
|
6
|
+
export { ConfigEntry, ConfigurationClient, ConfigurationConfig } from './configuration/index.mjs';
|
|
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 };
|