@agirails/sdk 2.3.0 → 2.3.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 (153) hide show
  1. package/README.md +45 -8
  2. package/dist/ACTPClient.d.ts +35 -1
  3. package/dist/ACTPClient.d.ts.map +1 -1
  4. package/dist/ACTPClient.js +156 -26
  5. package/dist/ACTPClient.js.map +1 -1
  6. package/dist/adapters/AdapterRouter.d.ts.map +1 -1
  7. package/dist/adapters/AdapterRouter.js.map +1 -1
  8. package/dist/adapters/BasicAdapter.d.ts +10 -1
  9. package/dist/adapters/BasicAdapter.d.ts.map +1 -1
  10. package/dist/adapters/BasicAdapter.js +36 -1
  11. package/dist/adapters/BasicAdapter.js.map +1 -1
  12. package/dist/cli/commands/init.d.ts +2 -1
  13. package/dist/cli/commands/init.d.ts.map +1 -1
  14. package/dist/cli/commands/init.js +345 -25
  15. package/dist/cli/commands/init.js.map +1 -1
  16. package/dist/cli/commands/publish.d.ts.map +1 -1
  17. package/dist/cli/commands/publish.js.map +1 -1
  18. package/dist/cli/commands/register.d.ts +16 -0
  19. package/dist/cli/commands/register.d.ts.map +1 -0
  20. package/dist/cli/commands/register.js +211 -0
  21. package/dist/cli/commands/register.js.map +1 -0
  22. package/dist/cli/index.js +3 -0
  23. package/dist/cli/index.js.map +1 -1
  24. package/dist/cli/utils/config.d.ts +20 -0
  25. package/dist/cli/utils/config.d.ts.map +1 -1
  26. package/dist/cli/utils/config.js.map +1 -1
  27. package/dist/config/networks.d.ts +20 -4
  28. package/dist/config/networks.d.ts.map +1 -1
  29. package/dist/config/networks.js +59 -27
  30. package/dist/config/networks.js.map +1 -1
  31. package/dist/config/publishPipeline.d.ts +14 -0
  32. package/dist/config/publishPipeline.d.ts.map +1 -1
  33. package/dist/config/publishPipeline.js +2 -1
  34. package/dist/config/publishPipeline.js.map +1 -1
  35. package/dist/erc8004/ERC8004Bridge.d.ts.map +1 -1
  36. package/dist/erc8004/ERC8004Bridge.js +6 -5
  37. package/dist/erc8004/ERC8004Bridge.js.map +1 -1
  38. package/dist/erc8004/ReputationReporter.d.ts.map +1 -1
  39. package/dist/erc8004/ReputationReporter.js +9 -12
  40. package/dist/erc8004/ReputationReporter.js.map +1 -1
  41. package/dist/index.d.ts +4 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +7 -3
  44. package/dist/index.js.map +1 -1
  45. package/dist/level1/Agent.js +4 -4
  46. package/dist/level1/Agent.js.map +1 -1
  47. package/dist/protocol/ACTPKernel.d.ts +7 -1
  48. package/dist/protocol/ACTPKernel.d.ts.map +1 -1
  49. package/dist/protocol/ACTPKernel.js +13 -10
  50. package/dist/protocol/ACTPKernel.js.map +1 -1
  51. package/dist/protocol/EventMonitor.d.ts +14 -0
  52. package/dist/protocol/EventMonitor.d.ts.map +1 -1
  53. package/dist/protocol/EventMonitor.js +14 -0
  54. package/dist/protocol/EventMonitor.js.map +1 -1
  55. package/dist/runtime/BlockchainRuntime.d.ts +5 -0
  56. package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
  57. package/dist/runtime/BlockchainRuntime.js +1 -1
  58. package/dist/runtime/BlockchainRuntime.js.map +1 -1
  59. package/dist/storage/ArchiveBundleBuilder.d.ts.map +1 -1
  60. package/dist/storage/ArchiveBundleBuilder.js.map +1 -1
  61. package/dist/storage/ArweaveClient.d.ts.map +1 -1
  62. package/dist/storage/ArweaveClient.js +2 -0
  63. package/dist/storage/ArweaveClient.js.map +1 -1
  64. package/dist/storage/FilebaseClient.d.ts.map +1 -1
  65. package/dist/storage/FilebaseClient.js +2 -0
  66. package/dist/storage/FilebaseClient.js.map +1 -1
  67. package/dist/utils/ErrorRecoveryGuide.d.ts.map +1 -1
  68. package/dist/utils/ErrorRecoveryGuide.js +3 -2
  69. package/dist/utils/ErrorRecoveryGuide.js.map +1 -1
  70. package/dist/utils/IPFSClient.d.ts +3 -2
  71. package/dist/utils/IPFSClient.d.ts.map +1 -1
  72. package/dist/utils/IPFSClient.js +7 -5
  73. package/dist/utils/IPFSClient.js.map +1 -1
  74. package/dist/utils/computeTypeHash.js +1 -3
  75. package/dist/utils/computeTypeHash.js.map +1 -1
  76. package/dist/utils/retry.d.ts.map +1 -1
  77. package/dist/utils/retry.js +0 -1
  78. package/dist/utils/retry.js.map +1 -1
  79. package/dist/utils/validation.d.ts +2 -2
  80. package/dist/utils/validation.d.ts.map +1 -1
  81. package/dist/utils/validation.js +2 -2
  82. package/dist/utils/validation.js.map +1 -1
  83. package/dist/wallet/AutoWalletProvider.d.ts +77 -0
  84. package/dist/wallet/AutoWalletProvider.d.ts.map +1 -0
  85. package/dist/wallet/AutoWalletProvider.js +197 -0
  86. package/dist/wallet/AutoWalletProvider.js.map +1 -0
  87. package/dist/wallet/EOAWalletProvider.d.ts +21 -0
  88. package/dist/wallet/EOAWalletProvider.d.ts.map +1 -0
  89. package/dist/wallet/EOAWalletProvider.js +57 -0
  90. package/dist/wallet/EOAWalletProvider.js.map +1 -0
  91. package/dist/wallet/IWalletProvider.d.ts +115 -0
  92. package/dist/wallet/IWalletProvider.d.ts.map +1 -0
  93. package/dist/wallet/IWalletProvider.js +12 -0
  94. package/dist/wallet/IWalletProvider.js.map +1 -0
  95. package/dist/wallet/aa/BundlerClient.d.ts +70 -0
  96. package/dist/wallet/aa/BundlerClient.d.ts.map +1 -0
  97. package/dist/wallet/aa/BundlerClient.js +184 -0
  98. package/dist/wallet/aa/BundlerClient.js.map +1 -0
  99. package/dist/wallet/aa/DualNonceManager.d.ts +56 -0
  100. package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -0
  101. package/dist/wallet/aa/DualNonceManager.js +142 -0
  102. package/dist/wallet/aa/DualNonceManager.js.map +1 -0
  103. package/dist/wallet/aa/PaymasterClient.d.ts +52 -0
  104. package/dist/wallet/aa/PaymasterClient.d.ts.map +1 -0
  105. package/dist/wallet/aa/PaymasterClient.js +116 -0
  106. package/dist/wallet/aa/PaymasterClient.js.map +1 -0
  107. package/dist/wallet/aa/TransactionBatcher.d.ts +87 -0
  108. package/dist/wallet/aa/TransactionBatcher.d.ts.map +1 -0
  109. package/dist/wallet/aa/TransactionBatcher.js +148 -0
  110. package/dist/wallet/aa/TransactionBatcher.js.map +1 -0
  111. package/dist/wallet/aa/UserOpBuilder.d.ts +71 -0
  112. package/dist/wallet/aa/UserOpBuilder.d.ts.map +1 -0
  113. package/dist/wallet/aa/UserOpBuilder.js +196 -0
  114. package/dist/wallet/aa/UserOpBuilder.js.map +1 -0
  115. package/dist/wallet/aa/constants.d.ts +54 -0
  116. package/dist/wallet/aa/constants.d.ts.map +1 -0
  117. package/dist/wallet/aa/constants.js +18 -0
  118. package/dist/wallet/aa/constants.js.map +1 -0
  119. package/package.json +4 -2
  120. package/src/ACTPClient.ts +217 -31
  121. package/src/adapters/AdapterRouter.ts +0 -1
  122. package/src/adapters/BasicAdapter.ts +41 -1
  123. package/src/cli/commands/init.ts +394 -25
  124. package/src/cli/commands/publish.ts +1 -2
  125. package/src/cli/commands/register.ts +233 -0
  126. package/src/cli/index.ts +4 -0
  127. package/src/cli/utils/config.ts +30 -0
  128. package/src/config/networks.ts +82 -27
  129. package/src/config/publishPipeline.ts +2 -2
  130. package/src/erc8004/ERC8004Bridge.ts +6 -5
  131. package/src/erc8004/ReputationReporter.ts +14 -18
  132. package/src/index.ts +12 -0
  133. package/src/level1/Agent.ts +5 -5
  134. package/src/protocol/ACTPKernel.ts +20 -10
  135. package/src/protocol/EventMonitor.ts +14 -0
  136. package/src/runtime/BlockchainRuntime.ts +7 -1
  137. package/src/storage/ArchiveBundleBuilder.ts +0 -2
  138. package/src/storage/ArweaveClient.ts +2 -1
  139. package/src/storage/FilebaseClient.ts +3 -3
  140. package/src/utils/ErrorRecoveryGuide.ts +4 -2
  141. package/src/utils/IPFSClient.ts +9 -7
  142. package/src/utils/computeTypeHash.ts +1 -3
  143. package/src/utils/retry.ts +0 -1
  144. package/src/utils/validation.ts +2 -2
  145. package/src/wallet/AutoWalletProvider.ts +294 -0
  146. package/src/wallet/EOAWalletProvider.ts +69 -0
  147. package/src/wallet/IWalletProvider.ts +133 -0
  148. package/src/wallet/aa/BundlerClient.ts +274 -0
  149. package/src/wallet/aa/DualNonceManager.ts +173 -0
  150. package/src/wallet/aa/PaymasterClient.ts +174 -0
  151. package/src/wallet/aa/TransactionBatcher.ts +240 -0
  152. package/src/wallet/aa/UserOpBuilder.ts +246 -0
  153. package/src/wallet/aa/constants.ts +60 -0
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Register Command — Register agent on AgentRegistry for gas-free transactions.
3
+ *
4
+ * Parses AGIRAILS.md for service descriptors and endpoint, then registers
5
+ * on-chain via a single gasless UserOp (bootstrap-allowed).
6
+ *
7
+ * For testnet: also mints 1000 test USDC in the same UserOp.
8
+ *
9
+ * WARNING: This creates a NEW Smart Wallet address (different from EOA).
10
+ * Old EOA reputation/history does not transfer.
11
+ *
12
+ * @module cli/commands/register
13
+ */
14
+
15
+ import * as fs from 'fs';
16
+ import * as path from 'path';
17
+ import { Command } from 'commander';
18
+ import { Output, ExitCode } from '../utils/output';
19
+ import { loadConfig, updateConfig } from '../utils/config';
20
+ import { resolvePrivateKey } from '../../wallet/keystore';
21
+
22
+ // ============================================================================
23
+ // Command Definition
24
+ // ============================================================================
25
+
26
+ export function createRegisterCommand(): Command {
27
+ const cmd = new Command('register')
28
+ .description('Register agent on AgentRegistry for gas-free transactions')
29
+ .option('--endpoint <url>', 'Service endpoint URL (overrides AGIRAILS.md)')
30
+ .option('--json', 'Output as JSON')
31
+ .option('-q, --quiet', 'Minimal output')
32
+ .action(async (options) => {
33
+ const output = new Output(
34
+ options.json ? 'json' : options.quiet ? 'quiet' : 'human'
35
+ );
36
+
37
+ try {
38
+ await runRegister(options, output);
39
+ } catch (error) {
40
+ output.errorResult({
41
+ code: 'REGISTER_FAILED',
42
+ message: (error as Error).message,
43
+ });
44
+ process.exit(ExitCode.ERROR);
45
+ }
46
+ });
47
+
48
+ return cmd;
49
+ }
50
+
51
+ // ============================================================================
52
+ // Implementation
53
+ // ============================================================================
54
+
55
+ async function runRegister(
56
+ options: { endpoint?: string },
57
+ output: Output
58
+ ): Promise<void> {
59
+ const projectRoot = process.cwd();
60
+
61
+ // Load config
62
+ const config = loadConfig(projectRoot);
63
+ if (!config) {
64
+ throw new Error(
65
+ 'ACTP not initialized. Run "actp init" first.'
66
+ );
67
+ }
68
+
69
+ if (config.mode === 'mock') {
70
+ throw new Error('Registration is not available in mock mode.');
71
+ }
72
+
73
+ // Resolve private key
74
+ const privateKey = await resolvePrivateKey(projectRoot);
75
+ if (!privateKey) {
76
+ throw new Error(
77
+ 'No wallet found. Run "actp init" first to generate a wallet.'
78
+ );
79
+ }
80
+
81
+ // Parse AGIRAILS.md for service descriptors
82
+ const { parseAgirailsMd } = await import('../../config/agirailsmd');
83
+ const { extractRegistrationParams } = await import('../../config/publishPipeline');
84
+
85
+ const agirailsMdPath = path.join(projectRoot, 'AGIRAILS.md');
86
+ let endpoint = options.endpoint || '';
87
+ let serviceDescriptors;
88
+
89
+ if (fs.existsSync(agirailsMdPath)) {
90
+ const content = fs.readFileSync(agirailsMdPath, 'utf-8');
91
+ const parsed = parseAgirailsMd(content);
92
+ const regParams = extractRegistrationParams(parsed.frontmatter);
93
+ endpoint = options.endpoint || regParams.endpoint;
94
+ serviceDescriptors = regParams.serviceDescriptors;
95
+ output.info(`Parsed ${serviceDescriptors.length} service(s) from AGIRAILS.md`);
96
+ } else {
97
+ // No AGIRAILS.md — use minimal defaults
98
+ const { ethers: ethersLib } = await import('ethers');
99
+ const serviceType = 'general';
100
+ serviceDescriptors = [{
101
+ serviceTypeHash: ethersLib.keccak256(ethersLib.toUtf8Bytes(serviceType)),
102
+ serviceType,
103
+ schemaURI: '',
104
+ minPrice: 0n,
105
+ maxPrice: 1_000_000_000n, // 1000 USDC
106
+ avgCompletionTime: 3600,
107
+ metadataCID: '',
108
+ }];
109
+ output.warning('No AGIRAILS.md found. Using default "general" service descriptor.');
110
+ output.info('Create AGIRAILS.md with services to customize registration.');
111
+ }
112
+
113
+ // Dynamic imports
114
+ const { ethers } = await import('ethers');
115
+ const { getNetwork } = await import('../../config/networks');
116
+ const { AutoWalletProvider } = await import('../../wallet/AutoWalletProvider');
117
+ const { buildRegisterAgentBatch, buildTestnetInitBatch } = await import('../../wallet/aa/TransactionBatcher');
118
+
119
+ const network = config.mode === 'testnet' ? 'base-sepolia' : 'base-mainnet';
120
+ const networkConfig = getNetwork(network);
121
+
122
+ if (!networkConfig.aa) {
123
+ throw new Error(
124
+ `AA configuration not available for ${config.mode}. ` +
125
+ 'Smart Wallet registration requires AA support.'
126
+ );
127
+ }
128
+
129
+ if (!networkConfig.contracts.agentRegistry) {
130
+ throw new Error(
131
+ 'AgentRegistry contract not deployed yet. Registration not available.'
132
+ );
133
+ }
134
+
135
+ const rpcUrl = networkConfig.rpcUrl;
136
+ const provider = new ethers.JsonRpcProvider(rpcUrl);
137
+ const signer = new ethers.Wallet(privateKey, provider);
138
+
139
+ output.info('Creating Smart Wallet...');
140
+
141
+ const autoWallet = await AutoWalletProvider.create({
142
+ signer,
143
+ provider,
144
+ chainId: networkConfig.chainId,
145
+ actpKernelAddress: networkConfig.contracts.actpKernel,
146
+ bundler: {
147
+ primaryUrl: networkConfig.aa.bundlerUrls.coinbase,
148
+ backupUrl: networkConfig.aa.bundlerUrls.pimlico,
149
+ },
150
+ paymaster: {
151
+ primaryUrl: networkConfig.aa.paymasterUrls.coinbase,
152
+ backupUrl: networkConfig.aa.paymasterUrls.pimlico,
153
+ },
154
+ });
155
+
156
+ const smartWalletAddress = autoWallet.getAddress();
157
+ output.info(`Smart Wallet: ${smartWalletAddress}`);
158
+
159
+ if (smartWalletAddress.toLowerCase() !== config.address.toLowerCase()) {
160
+ output.warning(
161
+ `This creates a NEW address: ${smartWalletAddress}\n` +
162
+ ` Your current address: ${config.address}\n` +
163
+ ' Old address reputation/history does NOT transfer.'
164
+ );
165
+ }
166
+
167
+ // Build batch — testnet gets register + mint, mainnet gets register only
168
+ let calls;
169
+ if (config.mode === 'testnet') {
170
+ output.info('Testnet mode: will register + mint 1000 test USDC in one UserOp');
171
+ calls = buildTestnetInitBatch({
172
+ agentRegistryAddress: networkConfig.contracts.agentRegistry,
173
+ endpoint,
174
+ serviceDescriptors,
175
+ mockUsdcAddress: networkConfig.contracts.usdc,
176
+ recipient: smartWalletAddress,
177
+ mintAmount: '1000000000', // 1000 USDC
178
+ });
179
+ } else {
180
+ calls = buildRegisterAgentBatch(
181
+ networkConfig.contracts.agentRegistry,
182
+ endpoint,
183
+ serviceDescriptors
184
+ );
185
+ }
186
+
187
+ // Convert SmartWalletCall[] to TransactionRequest[]
188
+ const txRequests = calls.map((c) => ({
189
+ to: c.target,
190
+ data: c.data,
191
+ value: c.value.toString(),
192
+ }));
193
+
194
+ output.info('Submitting registration (gasless UserOp)...');
195
+
196
+ const receipt = await autoWallet.sendBatchTransaction(txRequests);
197
+
198
+ if (!receipt.success) {
199
+ throw new Error(`Registration UserOp failed: ${receipt.hash}`);
200
+ }
201
+
202
+ output.success('Agent registered on AgentRegistry');
203
+ if (config.mode === 'testnet') {
204
+ output.success('Minted 1,000 test USDC to Smart Wallet');
205
+ }
206
+
207
+ // Update config: flip address to Smart Wallet, mark as registered
208
+ updateConfig({
209
+ address: smartWalletAddress.toLowerCase(),
210
+ smartWallet: smartWalletAddress.toLowerCase(),
211
+ registered: true,
212
+ }, projectRoot);
213
+ output.info('Config updated: address set to Smart Wallet');
214
+
215
+ output.blank();
216
+ output.result(
217
+ {
218
+ registered: true,
219
+ smartWallet: smartWalletAddress,
220
+ services: serviceDescriptors.length,
221
+ txHash: receipt.hash,
222
+ ...(config.mode === 'testnet' && { mintedUSDC: '1000' }),
223
+ },
224
+ { quietKey: 'smartWallet' }
225
+ );
226
+
227
+ output.blank();
228
+ output.print('Your agent now has gas-free transactions!');
229
+ output.print(`Smart Wallet address: ${smartWalletAddress}`);
230
+ output.print('');
231
+ output.print('To use gas-free mode, add to your agent config:');
232
+ output.print(' wallet: "auto"');
233
+ }
package/src/cli/index.ts CHANGED
@@ -51,6 +51,7 @@ import { createTimeCommand } from './commands/time';
51
51
  import { createPublishCommand } from './commands/publish';
52
52
  import { createPullCommand } from './commands/pull';
53
53
  import { createDiffCommand } from './commands/diff';
54
+ import { createRegisterCommand } from './commands/register';
54
55
 
55
56
  // ============================================================================
56
57
  // Program Setup
@@ -100,6 +101,9 @@ program.addCommand(createPublishCommand());
100
101
  program.addCommand(createPullCommand());
101
102
  program.addCommand(createDiffCommand());
102
103
 
104
+ // AIP-12: Gas-free registration
105
+ program.addCommand(createRegisterCommand());
106
+
103
107
  // ============================================================================
104
108
  // Error Handling
105
109
  // ============================================================================
@@ -35,8 +35,38 @@ export interface CLIConfig {
35
35
  /** Optional: RPC URL override */
36
36
  rpcUrl?: string;
37
37
 
38
+ /** AIP-12: Wallet type — 'auto' (Smart Wallet, gasless) or 'eoa' (traditional) */
39
+ wallet?: 'auto' | 'eoa';
40
+
41
+ /** AIP-12: Smart Wallet address (set when wallet=auto, used by `actp register`) */
42
+ smartWallet?: string;
43
+
44
+ /** AIP-12: Whether agent is registered on AgentRegistry */
45
+ registered?: boolean;
46
+
38
47
  /** Configuration version for migrations */
39
48
  version: string;
49
+
50
+ /** Agent name from AGIRAILS.md */
51
+ agentName?: string;
52
+
53
+ /** Agent intent: earn, pay, or both */
54
+ intent?: 'earn' | 'pay' | 'both';
55
+
56
+ /** Service capabilities from AGIRAILS.md */
57
+ capabilities?: string[];
58
+
59
+ /** Base price in USDC */
60
+ price?: number;
61
+
62
+ /** Max concurrent jobs */
63
+ concurrency?: number;
64
+
65
+ /** Payment mode: actp, x402, or both */
66
+ paymentMode?: 'actp' | 'x402' | 'both';
67
+
68
+ /** Budget cap in USDC */
69
+ budget?: number;
40
70
  }
41
71
 
42
72
  /**
@@ -15,6 +15,16 @@ import { ethers } from 'ethers';
15
15
  const BASE_SEPOLIA_RPC_URL = process.env.BASE_SEPOLIA_RPC || 'https://sepolia.base.org';
16
16
  const BASE_MAINNET_RPC_URL = process.env.BASE_MAINNET_RPC || 'https://mainnet.base.org';
17
17
 
18
+ // AGIRAILS CDP Client API Key — safe to embed, cannot access funds/portfolios.
19
+ // Developers can override with their own key via CDP_API_KEY env var.
20
+ // Paymaster policy restricts sponsorship to AGIRAILS contracts only.
21
+ const CDP_CLIENT_KEY = process.env.CDP_API_KEY || '2txciN85t41erCjveqgNnXYyHRcoo5xP';
22
+
23
+ // Pimlico failover — bundler/paymaster backup if Coinbase CDP is down.
24
+ // Safe to embed: restricted by contract allowlist (AGIRAILS contracts only).
25
+ // Developers can override with their own key via PIMLICO_API_KEY env var.
26
+ const PIMLICO_KEY = process.env.PIMLICO_API_KEY || 'pim_YiHmeAijzTPUvo1UMmXUiN';
27
+
18
28
  /**
19
29
  * Network configuration
20
30
  */
@@ -49,6 +59,27 @@ export interface NetworkConfig {
49
59
  * Set to undefined for no limit (testnet only).
50
60
  */
51
61
  maxTransactionAmount?: number;
62
+
63
+ /**
64
+ * AIP-12: Account Abstraction (AA) configuration.
65
+ * EntryPoint v0.6 + CoinbaseSmartWallet.
66
+ */
67
+ aa?: {
68
+ /** ERC-4337 EntryPoint v0.6 address */
69
+ entryPoint: string;
70
+ /** CoinbaseSmartWallet factory address */
71
+ smartWalletFactory: string;
72
+ /** Bundler RPC URLs */
73
+ bundlerUrls: {
74
+ coinbase: string;
75
+ pimlico?: string;
76
+ };
77
+ /** Paymaster RPC URLs (ERC-7677) */
78
+ paymasterUrls: {
79
+ coinbase: string;
80
+ pimlico?: string;
81
+ };
82
+ };
52
83
  }
53
84
 
54
85
  /**
@@ -60,38 +91,44 @@ export const BASE_SEPOLIA: NetworkConfig = {
60
91
  rpcUrl: BASE_SEPOLIA_RPC_URL,
61
92
  blockExplorer: 'https://sepolia.basescan.org',
62
93
  contracts: {
63
- // Redeployed 2026-02-06 with agentId support
64
94
  actpKernel: '0x469CBADbACFFE096270594F0a31f0EEC53753411',
65
95
  escrowVault: '0x57f888261b629bB380dfb983f5DA6c70Ff2D49E5',
66
96
  usdc: '0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb', // MockUSDC
67
- // EAS contracts (Base native deployment)
68
97
  eas: '0x4200000000000000000000000000000000000021',
69
98
  easSchemaRegistry: '0x4200000000000000000000000000000000000020',
70
- // AIP-7 Agent Registry (deployed 2025-12-11)
71
- agentRegistry: '0xFed6914Aa70c0a53E9c7Cc4d2Ae159e4748fb09D',
72
- // AIP-7 Identity Registry - ERC-1056 DID Registry (deployed 2026-01-09)
99
+ agentRegistry: '0xDd6D66924B43419F484aE981F174b803487AF25A',
73
100
  identityRegistry: '0xF64F748C7802a68Cb936a9213881fE74e83FDA97',
74
- // AIP-7 Archive Treasury - Arweave funding (deployed 2026-01-09)
75
101
  archiveTreasury: '0xeB75DE7cF5ce77ab15BB0fFa3a2A79e6aaa554B0',
76
- // X402Relay - atomic payment fee splitting (TODO: deploy and set address)
77
- // x402Relay: '0x...',
102
+ x402Relay: '0x4DCD02b276Dbeab57c265B72435e90507b6Ac81A',
78
103
  },
79
104
  eas: {
80
- // Deployed 2025-11-23 - AIP-4 delivery proof schema
81
105
  deliverySchemaUID: '0x1b0ebdf0bd20c28ec9d5362571ce8715a55f46e81c3de2f9b0d8e1b95fb5ffce'
82
106
  },
83
107
  gasSettings: {
84
108
  maxFeePerGas: ethers.parseUnits('2', 'gwei'),
85
109
  maxPriorityFeePerGas: ethers.parseUnits('1', 'gwei')
86
- }
110
+ },
111
+ // AIP-12: Account Abstraction
112
+ aa: {
113
+ entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
114
+ smartWalletFactory: '0xBA5ED110eFDBa3D005bfC882d75358ACBbB85842',
115
+ bundlerUrls: {
116
+ // Coinbase CDP bundler — set CDP_API_KEY env var
117
+ coinbase: process.env.CDP_BUNDLER_URL || `https://api.developer.coinbase.com/rpc/v1/base-sepolia/${CDP_CLIENT_KEY}`,
118
+ // Pimlico backup bundler — set PIMLICO_API_KEY env var
119
+ pimlico: process.env.PIMLICO_BUNDLER_URL || `https://api.pimlico.io/v2/84532/rpc?apikey=${PIMLICO_KEY}`,
120
+ },
121
+ paymasterUrls: {
122
+ // Coinbase CDP paymaster — same endpoint as bundler
123
+ coinbase: process.env.CDP_PAYMASTER_URL || `https://api.developer.coinbase.com/rpc/v1/base-sepolia/${CDP_CLIENT_KEY}`,
124
+ // Pimlico failover paymaster
125
+ pimlico: process.env.PIMLICO_PAYMASTER_URL || `https://api.pimlico.io/v2/84532/rpc?apikey=${PIMLICO_KEY}`,
126
+ },
127
+ },
87
128
  };
88
129
 
89
130
  /**
90
131
  * Base Mainnet Configuration
91
- *
92
- * WARNING: Mainnet contracts are NOT YET DEPLOYED.
93
- * Using 'base-mainnet' will throw an error until contracts are deployed.
94
- * Use 'base-sepolia' for testnet development.
95
132
  */
96
133
  export const BASE_MAINNET: NetworkConfig = {
97
134
  name: 'Base Mainnet',
@@ -99,21 +136,16 @@ export const BASE_MAINNET: NetworkConfig = {
99
136
  rpcUrl: BASE_MAINNET_RPC_URL,
100
137
  blockExplorer: 'https://basescan.org',
101
138
  contracts: {
102
- // Deployed 2026-02-03
103
- actpKernel: '0xeaE4D6925510284dbC45C8C64bb8104a079D4c60',
104
- escrowVault: '0xb7bCadF7F26f0761995d95105DFb2346F81AF02D',
105
- usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // Official USDC on Base
106
- // EAS contracts (Base native deployment)
139
+ actpKernel: '0x132B9eB321dBB57c828B083844287171BDC92d29',
140
+ escrowVault: '0x6aAF45882c4b0dD34130ecC790bb5Ec6be7fFb99',
141
+ usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
107
142
  eas: '0x4200000000000000000000000000000000000021',
108
143
  easSchemaRegistry: '0x4200000000000000000000000000000000000020',
109
- // AIP-7 contracts
110
- agentRegistry: '0xbf9Aa0FC291A06A4dFA943c3E0Ad41E7aE20DF02',
111
- archiveTreasury: '0x64B8f93fef2D2E749F5E88586753343F73246012',
112
- // X402Relay - atomic payment fee splitting (TODO: deploy and set address)
113
- // x402Relay: '0x...',
144
+ agentRegistry: '0x6fB222CF3DDdf37Bcb248EE7BBBA42Fb41901de8',
145
+ archiveTreasury: '0x0516C411C0E8d75D17A768022819a0a4FB3cA2f2',
146
+ x402Relay: '0x81DFb954A3D58FEc24Fc9c946aC2C71a911609F8',
114
147
  },
115
148
  eas: {
116
- // Registered 2026-02-03
117
149
  deliverySchemaUID: '0x166501e7476e2fcf9214c4c5144533c2957d56fe59d639effc1719a0658d9c9a'
118
150
  },
119
151
  gasSettings: {
@@ -125,7 +157,22 @@ export const BASE_MAINNET: NetworkConfig = {
125
157
  * This limits exposure in case of undiscovered vulnerabilities.
126
158
  * Will be removed/increased after formal security audit.
127
159
  */
128
- maxTransactionAmount: 1000
160
+ maxTransactionAmount: 1000,
161
+ // AIP-12: Account Abstraction
162
+ aa: {
163
+ entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
164
+ smartWalletFactory: '0xBA5ED110eFDBa3D005bfC882d75358ACBbB85842',
165
+ bundlerUrls: {
166
+ coinbase: process.env.CDP_BUNDLER_URL || `https://api.developer.coinbase.com/rpc/v1/base/${CDP_CLIENT_KEY}`,
167
+ // Pimlico backup bundler — set PIMLICO_API_KEY env var
168
+ pimlico: process.env.PIMLICO_BUNDLER_URL || `https://api.pimlico.io/v2/8453/rpc?apikey=${PIMLICO_KEY}`,
169
+ },
170
+ paymasterUrls: {
171
+ coinbase: process.env.CDP_PAYMASTER_URL || `https://api.developer.coinbase.com/rpc/v1/base/${CDP_CLIENT_KEY}`,
172
+ // Pimlico failover paymaster
173
+ pimlico: process.env.PIMLICO_PAYMASTER_URL || `https://api.pimlico.io/v2/8453/rpc?apikey=${PIMLICO_KEY}`,
174
+ },
175
+ },
129
176
  };
130
177
 
131
178
  /**
@@ -174,7 +221,15 @@ export function getNetwork(network: string): NetworkConfig {
174
221
  gasSettings: {
175
222
  maxFeePerGas: config.gasSettings.maxFeePerGas,
176
223
  maxPriorityFeePerGas: config.gasSettings.maxPriorityFeePerGas
177
- }
224
+ },
225
+ ...(config.aa ? {
226
+ aa: {
227
+ entryPoint: config.aa.entryPoint,
228
+ smartWalletFactory: config.aa.smartWalletFactory,
229
+ bundlerUrls: { ...config.aa.bundlerUrls },
230
+ paymasterUrls: { ...config.aa.paymasterUrls },
231
+ }
232
+ } : {}),
178
233
  };
179
234
  }
180
235
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  import { readFileSync, writeFileSync } from 'fs';
15
15
  import { Signer, keccak256, toUtf8Bytes } from 'ethers';
16
- import { parseAgirailsMd, computeConfigHash, computeConfigHashFromParts, serializeAgirailsMd } from './agirailsmd';
16
+ import { parseAgirailsMd, computeConfigHash, serializeAgirailsMd } from './agirailsmd';
17
17
  import { AgentRegistryClient } from '../registry/AgentRegistryClient';
18
18
  import { AgentRegistry } from '../protocol/AgentRegistry';
19
19
  import { FilebaseClient } from '../storage/FilebaseClient';
@@ -110,7 +110,7 @@ function usdcToBaseUnits(value: number, fieldName: string): bigint {
110
110
  *
111
111
  * @throws Error if neither services nor capabilities are present
112
112
  */
113
- function extractRegistrationParams(
113
+ export function extractRegistrationParams(
114
114
  frontmatter: Record<string, unknown>
115
115
  ): { endpoint: string; serviceDescriptors: ServiceDescriptor[] } {
116
116
  // Endpoint: use frontmatter field or placeholder
@@ -38,6 +38,7 @@ import {
38
38
  ERC8004_IDENTITY_ABI,
39
39
  ERC8004_DEFAULT_RPC,
40
40
  } from '../types/erc8004';
41
+ import { sdkLogger } from '../utils/Logger';
41
42
 
42
43
  // ============================================================================
43
44
  // Types
@@ -137,7 +138,7 @@ export class ERC8004Bridge {
137
138
  config.registryAddress ?? ERC8004_IDENTITY_REGISTRY[config.network];
138
139
 
139
140
  if (registryAddress === ethers.ZeroAddress) {
140
- console.warn(
141
+ sdkLogger.warn(
141
142
  `[ERC8004] Registry not deployed on ${config.network}. Using zero address.`
142
143
  );
143
144
  }
@@ -327,7 +328,7 @@ export class ERC8004Bridge {
327
328
 
328
329
  return agentIds;
329
330
  } catch (error) {
330
- console.warn(`[ERC8004] Failed to get agents for owner ${owner}:`, error);
331
+ sdkLogger.warn(`[ERC8004] Failed to get agents for owner ${owner}: ${error instanceof Error ? error.message : error}`);
331
332
  return [];
332
333
  }
333
334
  }
@@ -417,7 +418,7 @@ export class ERC8004Bridge {
417
418
 
418
419
  // Validate URL
419
420
  if (!url.startsWith('http://') && !url.startsWith('https://')) {
420
- console.warn(`[ERC8004] Invalid agentURI scheme for ${agentId}: ${url}`);
421
+ sdkLogger.warn(`[ERC8004] Invalid agentURI scheme for ${agentId}: ${url}`);
421
422
  return undefined;
422
423
  }
423
424
 
@@ -434,7 +435,7 @@ export class ERC8004Bridge {
434
435
  clearTimeout(timeoutId);
435
436
 
436
437
  if (!response.ok) {
437
- console.warn(
438
+ sdkLogger.warn(
438
439
  `[ERC8004] Metadata fetch failed for ${agentId}: HTTP ${response.status}`
439
440
  );
440
441
  return undefined;
@@ -454,7 +455,7 @@ export class ERC8004Bridge {
454
455
  : error.message
455
456
  : 'unknown error';
456
457
 
457
- console.warn(`[ERC8004] Metadata fetch failed for ${agentId}: ${errorMessage}`);
458
+ sdkLogger.warn(`[ERC8004] Metadata fetch failed for ${agentId}: ${errorMessage}`);
458
459
  return undefined;
459
460
  }
460
461
  }
@@ -50,6 +50,7 @@ import {
50
50
  ERC8004_REPUTATION_ABI,
51
51
  ACTP_FEEDBACK_TAGS,
52
52
  } from '../types/erc8004';
53
+ import { sdkLogger } from '../utils/Logger';
53
54
 
54
55
  // ============================================================================
55
56
  // Types
@@ -214,9 +215,8 @@ export class ReputationReporter {
214
215
  config.registryAddress ?? ERC8004_REPUTATION_REGISTRY[config.network];
215
216
 
216
217
  if (registryAddress === ethers.ZeroAddress) {
217
- console.warn(
218
- `[ERC8004] Reputation Registry not deployed on ${config.network}. ` +
219
- 'Reports will fail.'
218
+ sdkLogger.warn(
219
+ `[ERC8004] Reputation Registry not deployed on ${config.network}. Reports will fail.`
220
220
  );
221
221
  }
222
222
 
@@ -257,7 +257,7 @@ export class ReputationReporter {
257
257
 
258
258
  // Local dedup check
259
259
  if (this.reportedTxIds.has(txId)) {
260
- console.warn(`[ERC8004] Already reported txId in this session: ${txId}`);
260
+ sdkLogger.warn(`[ERC8004] Already reported txId in this session: ${txId}`);
261
261
  return null;
262
262
  }
263
263
 
@@ -322,7 +322,7 @@ export class ReputationReporter {
322
322
 
323
323
  // Local dedup check
324
324
  if (this.reportedTxIds.has(txId)) {
325
- console.warn(`[ERC8004] Already reported txId in this session: ${txId}`);
325
+ sdkLogger.warn(`[ERC8004] Already reported txId in this session: ${txId}`);
326
326
  return null;
327
327
  }
328
328
 
@@ -392,9 +392,8 @@ export class ReputationReporter {
392
392
  score: Number(summaryValue),
393
393
  };
394
394
  } catch (error) {
395
- console.error(
396
- `[ERC8004] getAgentReputation failed for ${agentId}:`,
397
- error instanceof Error ? error.message : error
395
+ sdkLogger.error(
396
+ `[ERC8004] getAgentReputation failed for ${agentId}: ${error instanceof Error ? error.message : error}`
398
397
  );
399
398
  return null;
400
399
  }
@@ -449,23 +448,20 @@ export class ReputationReporter {
449
448
 
450
449
  // Check for common error cases
451
450
  if (errorMessage.includes('insufficient funds')) {
452
- console.error(
453
- `[ERC8004] ${method} failed for agent ${agentId}: ` +
454
- 'Insufficient funds for gas. Signer needs ETH/native token.'
451
+ sdkLogger.error(
452
+ `[ERC8004] ${method} failed for agent ${agentId}: Insufficient funds for gas. Signer needs ETH/native token.`
455
453
  );
456
454
  } else if (errorMessage.includes('cannot be the agent owner')) {
457
- console.error(
458
- `[ERC8004] ${method} failed for agent ${agentId}: ` +
459
- 'Caller is agent owner. ERC-8004 requires different address.'
455
+ sdkLogger.error(
456
+ `[ERC8004] ${method} failed for agent ${agentId}: Caller is agent owner. ERC-8004 requires different address.`
460
457
  );
461
458
  } else if (errorMessage.includes('user rejected')) {
462
- console.warn(
459
+ sdkLogger.warn(
463
460
  `[ERC8004] ${method} cancelled by user for agent ${agentId}`
464
461
  );
465
462
  } else {
466
- console.error(
467
- `[ERC8004] ${method} failed for agent ${agentId} (tx: ${txId}): ` +
468
- errorMessage
463
+ sdkLogger.error(
464
+ `[ERC8004] ${method} failed for agent ${agentId} (tx: ${txId}): ${errorMessage}`
469
465
  );
470
466
  }
471
467
  }
package/src/index.ts CHANGED
@@ -178,6 +178,18 @@ export {
178
178
 
179
179
  // Wallet
180
180
  export { resolvePrivateKey, getCachedAddress } from './wallet/keystore';
181
+ export type {
182
+ IWalletProvider,
183
+ TransactionRequest as WalletTransactionRequest,
184
+ TransactionReceipt as WalletTransactionReceipt,
185
+ WalletInfo,
186
+ WalletTier,
187
+ BatchedPayParams,
188
+ BatchedPayResult,
189
+ } from './wallet/IWalletProvider';
190
+ export { EOAWalletProvider } from './wallet/EOAWalletProvider';
191
+ export { AutoWalletProvider } from './wallet/AutoWalletProvider';
192
+ export type { AutoWalletConfig } from './wallet/AutoWalletProvider';
181
193
 
182
194
  // Helper utilities
183
195
  export {
@@ -19,7 +19,7 @@ import { RequestOptions, RequestResult, NetworkOption } from './types/Options';
19
19
  import { PricingStrategy } from './pricing/PricingStrategy';
20
20
  import { AgentLifecycleError, ServiceConfigError, ValidationError } from '../errors';
21
21
  import { validateServiceName, validatePath, LRUCache } from '../utils/security';
22
- import { Logger } from '../utils/Logger';
22
+ import { Logger, sdkLogger } from '../utils/Logger';
23
23
  import { ServiceHash } from '../utils/Helpers';
24
24
  import { Semaphore } from '../utils/Semaphore';
25
25
  import { ProofGenerator } from '../protocol/ProofGenerator';
@@ -1311,21 +1311,21 @@ export class Agent extends EventEmitter {
1311
1311
  log: {
1312
1312
  debug: (message: string, meta?: any) => {
1313
1313
  if (agent.config.logging?.level === 'debug') {
1314
- console.debug(`[${job.id}] ${message}`, meta);
1314
+ sdkLogger.debug(`[${job.id}] ${message}`, meta);
1315
1315
  }
1316
1316
  },
1317
1317
  info: (message: string, meta?: any) => {
1318
1318
  if (['debug', 'info'].includes(agent.config.logging?.level || 'info')) {
1319
- console.info(`[${job.id}] ${message}`, meta);
1319
+ sdkLogger.info(`[${job.id}] ${message}`, meta);
1320
1320
  }
1321
1321
  },
1322
1322
  warn: (message: string, meta?: any) => {
1323
1323
  if (['debug', 'info', 'warn'].includes(agent.config.logging?.level || 'info')) {
1324
- console.warn(`[${job.id}] ${message}`, meta);
1324
+ sdkLogger.warn(`[${job.id}] ${message}`, meta);
1325
1325
  }
1326
1326
  },
1327
1327
  error: (message: string, meta?: any) => {
1328
- console.error(`[${job.id}] ${message}`, meta);
1328
+ sdkLogger.error(`[${job.id}] ${message}`, meta);
1329
1329
  },
1330
1330
  },
1331
1331