@agirails/sdk 2.2.3 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -31
- package/dist/ACTPClient.d.ts +42 -1
- package/dist/ACTPClient.d.ts.map +1 -1
- package/dist/ACTPClient.js +207 -22
- package/dist/ACTPClient.js.map +1 -1
- package/dist/abi/AgentRegistry.json +133 -0
- package/dist/adapters/AdapterRouter.d.ts.map +1 -1
- package/dist/adapters/AdapterRouter.js.map +1 -1
- package/dist/adapters/BasicAdapter.d.ts +10 -1
- package/dist/adapters/BasicAdapter.d.ts.map +1 -1
- package/dist/adapters/BasicAdapter.js +36 -1
- package/dist/adapters/BasicAdapter.js.map +1 -1
- package/dist/adapters/X402Adapter.d.ts +34 -7
- package/dist/adapters/X402Adapter.d.ts.map +1 -1
- package/dist/adapters/X402Adapter.js +36 -8
- package/dist/adapters/X402Adapter.js.map +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/cli/commands/diff.d.ts +11 -0
- package/dist/cli/commands/diff.d.ts.map +1 -0
- package/dist/cli/commands/diff.js +115 -0
- package/dist/cli/commands/diff.js.map +1 -0
- package/dist/cli/commands/init.d.ts +1 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +260 -19
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/publish.d.ts +11 -0
- package/dist/cli/commands/publish.d.ts.map +1 -0
- package/dist/cli/commands/publish.js +170 -0
- package/dist/cli/commands/publish.js.map +1 -0
- package/dist/cli/commands/pull.d.ts +12 -0
- package/dist/cli/commands/pull.d.ts.map +1 -0
- package/dist/cli/commands/pull.js +99 -0
- package/dist/cli/commands/pull.js.map +1 -0
- package/dist/cli/commands/register.d.ts +16 -0
- package/dist/cli/commands/register.d.ts.map +1 -0
- package/dist/cli/commands/register.js +211 -0
- package/dist/cli/commands/register.js.map +1 -0
- package/dist/cli/index.js +10 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/config.d.ts +6 -0
- package/dist/cli/utils/config.d.ts.map +1 -1
- package/dist/cli/utils/config.js.map +1 -1
- package/dist/config/agirailsmd.d.ts +94 -0
- package/dist/config/agirailsmd.d.ts.map +1 -0
- package/dist/config/agirailsmd.js +209 -0
- package/dist/config/agirailsmd.js.map +1 -0
- package/dist/config/networks.d.ts +22 -4
- package/dist/config/networks.d.ts.map +1 -1
- package/dist/config/networks.js +64 -26
- package/dist/config/networks.js.map +1 -1
- package/dist/config/publishPipeline.d.ts +75 -0
- package/dist/config/publishPipeline.d.ts.map +1 -0
- package/dist/config/publishPipeline.js +193 -0
- package/dist/config/publishPipeline.js.map +1 -0
- package/dist/config/syncOperations.d.ts +67 -0
- package/dist/config/syncOperations.d.ts.map +1 -0
- package/dist/config/syncOperations.js +208 -0
- package/dist/config/syncOperations.js.map +1 -0
- package/dist/erc8004/ERC8004Bridge.d.ts.map +1 -1
- package/dist/erc8004/ERC8004Bridge.js +6 -5
- package/dist/erc8004/ERC8004Bridge.js.map +1 -1
- package/dist/erc8004/ReputationReporter.d.ts.map +1 -1
- package/dist/erc8004/ReputationReporter.js +9 -12
- package/dist/erc8004/ReputationReporter.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/level0/request.d.ts.map +1 -1
- package/dist/level0/request.js +23 -86
- package/dist/level0/request.js.map +1 -1
- package/dist/level1/Agent.d.ts +0 -11
- package/dist/level1/Agent.d.ts.map +1 -1
- package/dist/level1/Agent.js +19 -36
- package/dist/level1/Agent.js.map +1 -1
- package/dist/protocol/ACTPKernel.d.ts +7 -1
- package/dist/protocol/ACTPKernel.d.ts.map +1 -1
- package/dist/protocol/ACTPKernel.js +13 -10
- package/dist/protocol/ACTPKernel.js.map +1 -1
- package/dist/protocol/EventMonitor.d.ts +14 -0
- package/dist/protocol/EventMonitor.d.ts.map +1 -1
- package/dist/protocol/EventMonitor.js +14 -0
- package/dist/protocol/EventMonitor.js.map +1 -1
- package/dist/registry/AgentRegistryClient.d.ts +75 -0
- package/dist/registry/AgentRegistryClient.d.ts.map +1 -0
- package/dist/registry/AgentRegistryClient.js +160 -0
- package/dist/registry/AgentRegistryClient.js.map +1 -0
- package/dist/runtime/BlockchainRuntime.d.ts +5 -0
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
- package/dist/runtime/BlockchainRuntime.js +1 -1
- package/dist/runtime/BlockchainRuntime.js.map +1 -1
- package/dist/storage/ArchiveBundleBuilder.d.ts.map +1 -1
- package/dist/storage/ArchiveBundleBuilder.js.map +1 -1
- package/dist/storage/ArweaveClient.d.ts.map +1 -1
- package/dist/storage/ArweaveClient.js +2 -0
- package/dist/storage/ArweaveClient.js.map +1 -1
- package/dist/storage/FilebaseClient.d.ts.map +1 -1
- package/dist/storage/FilebaseClient.js +2 -0
- package/dist/storage/FilebaseClient.js.map +1 -1
- package/dist/types/adapter.d.ts +39 -0
- package/dist/types/adapter.d.ts.map +1 -1
- package/dist/types/adapter.js +7 -0
- package/dist/types/adapter.js.map +1 -1
- package/dist/types/x402.d.ts +23 -0
- package/dist/types/x402.d.ts.map +1 -1
- package/dist/types/x402.js.map +1 -1
- package/dist/utils/ErrorRecoveryGuide.d.ts.map +1 -1
- package/dist/utils/ErrorRecoveryGuide.js +3 -2
- package/dist/utils/ErrorRecoveryGuide.js.map +1 -1
- package/dist/utils/IPFSClient.d.ts +3 -2
- package/dist/utils/IPFSClient.d.ts.map +1 -1
- package/dist/utils/IPFSClient.js +7 -5
- package/dist/utils/IPFSClient.js.map +1 -1
- package/dist/utils/computeTypeHash.js +1 -3
- package/dist/utils/computeTypeHash.js.map +1 -1
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +0 -1
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/validation.d.ts +2 -2
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +2 -2
- package/dist/utils/validation.js.map +1 -1
- package/dist/wallet/AutoWalletProvider.d.ts +77 -0
- package/dist/wallet/AutoWalletProvider.d.ts.map +1 -0
- package/dist/wallet/AutoWalletProvider.js +197 -0
- package/dist/wallet/AutoWalletProvider.js.map +1 -0
- package/dist/wallet/EOAWalletProvider.d.ts +21 -0
- package/dist/wallet/EOAWalletProvider.d.ts.map +1 -0
- package/dist/wallet/EOAWalletProvider.js +57 -0
- package/dist/wallet/EOAWalletProvider.js.map +1 -0
- package/dist/wallet/IWalletProvider.d.ts +115 -0
- package/dist/wallet/IWalletProvider.d.ts.map +1 -0
- package/dist/wallet/IWalletProvider.js +12 -0
- package/dist/wallet/IWalletProvider.js.map +1 -0
- package/dist/wallet/aa/BundlerClient.d.ts +70 -0
- package/dist/wallet/aa/BundlerClient.d.ts.map +1 -0
- package/dist/wallet/aa/BundlerClient.js +183 -0
- package/dist/wallet/aa/BundlerClient.js.map +1 -0
- package/dist/wallet/aa/DualNonceManager.d.ts +55 -0
- package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -0
- package/dist/wallet/aa/DualNonceManager.js +131 -0
- package/dist/wallet/aa/DualNonceManager.js.map +1 -0
- package/dist/wallet/aa/PaymasterClient.d.ts +52 -0
- package/dist/wallet/aa/PaymasterClient.d.ts.map +1 -0
- package/dist/wallet/aa/PaymasterClient.js +115 -0
- package/dist/wallet/aa/PaymasterClient.js.map +1 -0
- package/dist/wallet/aa/TransactionBatcher.d.ts +87 -0
- package/dist/wallet/aa/TransactionBatcher.d.ts.map +1 -0
- package/dist/wallet/aa/TransactionBatcher.js +148 -0
- package/dist/wallet/aa/TransactionBatcher.js.map +1 -0
- package/dist/wallet/aa/UserOpBuilder.d.ts +71 -0
- package/dist/wallet/aa/UserOpBuilder.d.ts.map +1 -0
- package/dist/wallet/aa/UserOpBuilder.js +196 -0
- package/dist/wallet/aa/UserOpBuilder.js.map +1 -0
- package/dist/wallet/aa/constants.d.ts +54 -0
- package/dist/wallet/aa/constants.d.ts.map +1 -0
- package/dist/wallet/aa/constants.js +18 -0
- package/dist/wallet/aa/constants.js.map +1 -0
- package/dist/wallet/keystore.d.ts +16 -0
- package/dist/wallet/keystore.d.ts.map +1 -0
- package/dist/wallet/keystore.js +132 -0
- package/dist/wallet/keystore.js.map +1 -0
- package/package.json +5 -2
- package/src/ACTPClient.ts +275 -27
- package/src/abi/AgentRegistry.json +133 -0
- package/src/adapters/AdapterRouter.ts +0 -1
- package/src/adapters/BasicAdapter.ts +41 -1
- package/src/adapters/X402Adapter.ts +94 -16
- package/src/adapters/index.ts +9 -1
- package/src/cli/commands/diff.ts +141 -0
- package/src/cli/commands/init.ts +311 -22
- package/src/cli/commands/publish.ts +208 -0
- package/src/cli/commands/pull.ts +124 -0
- package/src/cli/commands/register.ts +233 -0
- package/src/cli/index.ts +12 -0
- package/src/cli/utils/config.ts +9 -0
- package/src/config/agirailsmd.ts +262 -0
- package/src/config/networks.ts +89 -26
- package/src/config/publishPipeline.ts +276 -0
- package/src/config/syncOperations.ts +279 -0
- package/src/erc8004/ERC8004Bridge.ts +6 -5
- package/src/erc8004/ReputationReporter.ts +14 -18
- package/src/index.ts +15 -0
- package/src/level0/request.ts +27 -88
- package/src/level1/Agent.ts +21 -37
- package/src/protocol/ACTPKernel.ts +20 -10
- package/src/protocol/EventMonitor.ts +14 -0
- package/src/registry/AgentRegistryClient.ts +202 -0
- package/src/runtime/BlockchainRuntime.ts +7 -1
- package/src/storage/ArchiveBundleBuilder.ts +0 -2
- package/src/storage/ArweaveClient.ts +2 -1
- package/src/storage/FilebaseClient.ts +3 -3
- package/src/types/adapter.ts +14 -0
- package/src/types/x402.ts +32 -0
- package/src/utils/ErrorRecoveryGuide.ts +4 -2
- package/src/utils/IPFSClient.ts +9 -7
- package/src/utils/computeTypeHash.ts +1 -3
- package/src/utils/retry.ts +0 -1
- package/src/utils/validation.ts +2 -2
- package/src/wallet/AutoWalletProvider.ts +294 -0
- package/src/wallet/EOAWalletProvider.ts +69 -0
- package/src/wallet/IWalletProvider.ts +133 -0
- package/src/wallet/aa/BundlerClient.ts +273 -0
- package/src/wallet/aa/DualNonceManager.ts +163 -0
- package/src/wallet/aa/PaymasterClient.ts +173 -0
- package/src/wallet/aa/TransactionBatcher.ts +240 -0
- package/src/wallet/aa/UserOpBuilder.ts +246 -0
- package/src/wallet/aa/constants.ts +60 -0
- package/src/wallet/keystore.ts +119 -0
package/src/config/networks.ts
CHANGED
|
@@ -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
|
*/
|
|
@@ -32,9 +42,11 @@ export interface NetworkConfig {
|
|
|
32
42
|
agentRegistry?: string; // AIP-7 Agent Registry (optional until deployed)
|
|
33
43
|
identityRegistry?: string; // AIP-7 ERC-1056 DID Registry (optional until deployed)
|
|
34
44
|
archiveTreasury?: string; // AIP-7 Archive Treasury for Arweave funding (optional until deployed)
|
|
45
|
+
x402Relay?: string; // X402Relay for atomic payment fee splitting (optional until deployed)
|
|
35
46
|
};
|
|
36
47
|
eas: {
|
|
37
48
|
deliverySchemaUID: string; // AIP-4 delivery proof schema
|
|
49
|
+
configSnapshotSchemaUID?: string; // AGIRAILS.md config snapshot schema
|
|
38
50
|
};
|
|
39
51
|
gasSettings: {
|
|
40
52
|
maxFeePerGas: bigint;
|
|
@@ -47,6 +59,27 @@ export interface NetworkConfig {
|
|
|
47
59
|
* Set to undefined for no limit (testnet only).
|
|
48
60
|
*/
|
|
49
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
|
+
};
|
|
50
83
|
}
|
|
51
84
|
|
|
52
85
|
/**
|
|
@@ -58,36 +91,44 @@ export const BASE_SEPOLIA: NetworkConfig = {
|
|
|
58
91
|
rpcUrl: BASE_SEPOLIA_RPC_URL,
|
|
59
92
|
blockExplorer: 'https://sepolia.basescan.org',
|
|
60
93
|
contracts: {
|
|
61
|
-
// Redeployed 2026-02-06 with agentId support
|
|
62
94
|
actpKernel: '0x469CBADbACFFE096270594F0a31f0EEC53753411',
|
|
63
95
|
escrowVault: '0x57f888261b629bB380dfb983f5DA6c70Ff2D49E5',
|
|
64
96
|
usdc: '0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb', // MockUSDC
|
|
65
|
-
// EAS contracts (Base native deployment)
|
|
66
97
|
eas: '0x4200000000000000000000000000000000000021',
|
|
67
98
|
easSchemaRegistry: '0x4200000000000000000000000000000000000020',
|
|
68
|
-
|
|
69
|
-
agentRegistry: '0xFed6914Aa70c0a53E9c7Cc4d2Ae159e4748fb09D',
|
|
70
|
-
// AIP-7 Identity Registry - ERC-1056 DID Registry (deployed 2026-01-09)
|
|
99
|
+
agentRegistry: '0xDd6D66924B43419F484aE981F174b803487AF25A',
|
|
71
100
|
identityRegistry: '0xF64F748C7802a68Cb936a9213881fE74e83FDA97',
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
archiveTreasury: '0xeB75DE7cF5ce77ab15BB0fFa3a2A79e6aaa554B0',
|
|
102
|
+
x402Relay: '0x4DCD02b276Dbeab57c265B72435e90507b6Ac81A',
|
|
74
103
|
},
|
|
75
104
|
eas: {
|
|
76
|
-
// Deployed 2025-11-23 - AIP-4 delivery proof schema
|
|
77
105
|
deliverySchemaUID: '0x1b0ebdf0bd20c28ec9d5362571ce8715a55f46e81c3de2f9b0d8e1b95fb5ffce'
|
|
78
106
|
},
|
|
79
107
|
gasSettings: {
|
|
80
108
|
maxFeePerGas: ethers.parseUnits('2', 'gwei'),
|
|
81
109
|
maxPriorityFeePerGas: ethers.parseUnits('1', 'gwei')
|
|
82
|
-
}
|
|
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
|
+
},
|
|
83
128
|
};
|
|
84
129
|
|
|
85
130
|
/**
|
|
86
131
|
* Base Mainnet Configuration
|
|
87
|
-
*
|
|
88
|
-
* WARNING: Mainnet contracts are NOT YET DEPLOYED.
|
|
89
|
-
* Using 'base-mainnet' will throw an error until contracts are deployed.
|
|
90
|
-
* Use 'base-sepolia' for testnet development.
|
|
91
132
|
*/
|
|
92
133
|
export const BASE_MAINNET: NetworkConfig = {
|
|
93
134
|
name: 'Base Mainnet',
|
|
@@ -95,19 +136,16 @@ export const BASE_MAINNET: NetworkConfig = {
|
|
|
95
136
|
rpcUrl: BASE_MAINNET_RPC_URL,
|
|
96
137
|
blockExplorer: 'https://basescan.org',
|
|
97
138
|
contracts: {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // Official USDC on Base
|
|
102
|
-
// EAS contracts (Base native deployment)
|
|
139
|
+
actpKernel: '0x132B9eB321dBB57c828B083844287171BDC92d29',
|
|
140
|
+
escrowVault: '0x6aAF45882c4b0dD34130ecC790bb5Ec6be7fFb99',
|
|
141
|
+
usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
103
142
|
eas: '0x4200000000000000000000000000000000000021',
|
|
104
143
|
easSchemaRegistry: '0x4200000000000000000000000000000000000020',
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
144
|
+
agentRegistry: '0x6fB222CF3DDdf37Bcb248EE7BBBA42Fb41901de8',
|
|
145
|
+
archiveTreasury: '0x0516C411C0E8d75D17A768022819a0a4FB3cA2f2',
|
|
146
|
+
x402Relay: '0x81DFb954A3D58FEc24Fc9c946aC2C71a911609F8',
|
|
108
147
|
},
|
|
109
148
|
eas: {
|
|
110
|
-
// Registered 2026-02-03
|
|
111
149
|
deliverySchemaUID: '0x166501e7476e2fcf9214c4c5144533c2957d56fe59d639effc1719a0658d9c9a'
|
|
112
150
|
},
|
|
113
151
|
gasSettings: {
|
|
@@ -119,7 +157,22 @@ export const BASE_MAINNET: NetworkConfig = {
|
|
|
119
157
|
* This limits exposure in case of undiscovered vulnerabilities.
|
|
120
158
|
* Will be removed/increased after formal security audit.
|
|
121
159
|
*/
|
|
122
|
-
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
|
+
},
|
|
123
176
|
};
|
|
124
177
|
|
|
125
178
|
/**
|
|
@@ -158,15 +211,25 @@ export function getNetwork(network: string): NetworkConfig {
|
|
|
158
211
|
easSchemaRegistry: config.contracts.easSchemaRegistry,
|
|
159
212
|
agentRegistry: config.contracts.agentRegistry,
|
|
160
213
|
identityRegistry: config.contracts.identityRegistry,
|
|
161
|
-
archiveTreasury: config.contracts.archiveTreasury
|
|
214
|
+
archiveTreasury: config.contracts.archiveTreasury,
|
|
215
|
+
x402Relay: config.contracts.x402Relay
|
|
162
216
|
},
|
|
163
217
|
eas: {
|
|
164
|
-
deliverySchemaUID: config.eas.deliverySchemaUID
|
|
218
|
+
deliverySchemaUID: config.eas.deliverySchemaUID,
|
|
219
|
+
configSnapshotSchemaUID: config.eas.configSnapshotSchemaUID
|
|
165
220
|
},
|
|
166
221
|
gasSettings: {
|
|
167
222
|
maxFeePerGas: config.gasSettings.maxFeePerGas,
|
|
168
223
|
maxPriorityFeePerGas: config.gasSettings.maxPriorityFeePerGas
|
|
169
|
-
}
|
|
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
|
+
} : {}),
|
|
170
233
|
};
|
|
171
234
|
}
|
|
172
235
|
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publish Pipeline - AGIRAILS.md → IPFS → Arweave → On-Chain
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the full publish flow:
|
|
5
|
+
* 1. Read AGIRAILS.md → parse → compute configHash
|
|
6
|
+
* 2. Upload to Filebase (IPFS pinning)
|
|
7
|
+
* 3. Upload to Arweave (permanent storage) [optional]
|
|
8
|
+
* 4. Call AgentRegistry.publishConfig(cid, hash) on-chain
|
|
9
|
+
* 5. Update AGIRAILS.md frontmatter with config_hash and published_at
|
|
10
|
+
*
|
|
11
|
+
* @module config/publishPipeline
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
15
|
+
import { Signer, keccak256, toUtf8Bytes } from 'ethers';
|
|
16
|
+
import { parseAgirailsMd, computeConfigHash, serializeAgirailsMd } from './agirailsmd';
|
|
17
|
+
import { AgentRegistryClient } from '../registry/AgentRegistryClient';
|
|
18
|
+
import { AgentRegistry } from '../protocol/AgentRegistry';
|
|
19
|
+
import { FilebaseClient } from '../storage/FilebaseClient';
|
|
20
|
+
import { ArweaveClient } from '../storage/ArweaveClient';
|
|
21
|
+
import { ServiceDescriptor } from '../types';
|
|
22
|
+
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Types
|
|
25
|
+
// ============================================================================
|
|
26
|
+
|
|
27
|
+
export interface PublishOptions {
|
|
28
|
+
/** Path to AGIRAILS.md file */
|
|
29
|
+
path: string;
|
|
30
|
+
/** Network name (for registry address lookup) */
|
|
31
|
+
network: string;
|
|
32
|
+
/** AgentRegistry contract address */
|
|
33
|
+
registryAddress: string;
|
|
34
|
+
/** Signer for on-chain transactions */
|
|
35
|
+
signer: Signer;
|
|
36
|
+
/** Filebase client for IPFS upload */
|
|
37
|
+
filebaseClient: FilebaseClient;
|
|
38
|
+
/** Arweave client for permanent storage (optional) */
|
|
39
|
+
arweaveClient?: ArweaveClient;
|
|
40
|
+
/** Skip Arweave upload (dev mode) */
|
|
41
|
+
skipArweave?: boolean;
|
|
42
|
+
/** Dry run - compute and show but don't execute */
|
|
43
|
+
dryRun?: boolean;
|
|
44
|
+
/** Gas settings */
|
|
45
|
+
gasSettings?: {
|
|
46
|
+
maxFeePerGas?: bigint;
|
|
47
|
+
maxPriorityFeePerGas?: bigint;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PublishResult {
|
|
52
|
+
/** IPFS CID of the uploaded AGIRAILS.md */
|
|
53
|
+
cid: string;
|
|
54
|
+
/** Canonical config hash (bytes32) */
|
|
55
|
+
configHash: string;
|
|
56
|
+
/** On-chain transaction hash */
|
|
57
|
+
txHash?: string;
|
|
58
|
+
/** Arweave transaction ID (if uploaded) */
|
|
59
|
+
arweaveTxId?: string;
|
|
60
|
+
/** Whether this was a dry run */
|
|
61
|
+
dryRun: boolean;
|
|
62
|
+
/** Whether the agent was auto-registered during this publish */
|
|
63
|
+
registered?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// Registration Helpers
|
|
68
|
+
// ============================================================================
|
|
69
|
+
|
|
70
|
+
export const PENDING_ENDPOINT = 'https://pending.agirails.io';
|
|
71
|
+
|
|
72
|
+
/** Default values for capabilities-to-services conversion */
|
|
73
|
+
const SERVICE_DEFAULTS = {
|
|
74
|
+
schemaURI: '',
|
|
75
|
+
minPrice: 0n,
|
|
76
|
+
maxPrice: 1_000_000_000n, // 1000 USDC
|
|
77
|
+
avgCompletionTime: 3600, // 1 hour
|
|
78
|
+
metadataCID: '',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/** Max safe USDC value before BigInt conversion loses precision */
|
|
82
|
+
const MAX_SAFE_USDC = Math.floor(Number.MAX_SAFE_INTEGER / 1_000_000);
|
|
83
|
+
|
|
84
|
+
/** Validate service type format (must match contract requirements) */
|
|
85
|
+
function validateServiceType(serviceType: string, source: string): void {
|
|
86
|
+
if (!serviceType) {
|
|
87
|
+
throw new Error(`Empty service type in ${source}`);
|
|
88
|
+
}
|
|
89
|
+
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(serviceType)) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Invalid service type "${serviceType}" in ${source}. ` +
|
|
92
|
+
'Must be lowercase alphanumeric with hyphens (e.g., "text-generation").'
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Convert human-readable USDC to 6-decimal base units with overflow check */
|
|
98
|
+
function usdcToBaseUnits(value: number, fieldName: string): bigint {
|
|
99
|
+
if (value < 0) throw new Error(`${fieldName} cannot be negative`);
|
|
100
|
+
if (value > MAX_SAFE_USDC) throw new Error(`${fieldName} exceeds maximum safe value (${MAX_SAFE_USDC} USDC)`);
|
|
101
|
+
return BigInt(Math.round(value * 1_000_000));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Extract registration params from AGIRAILS.md frontmatter.
|
|
106
|
+
*
|
|
107
|
+
* Supports two formats:
|
|
108
|
+
* - `services`: full ServiceDescriptor objects with pricing
|
|
109
|
+
* - `capabilities`: simple string list, auto-converted with defaults
|
|
110
|
+
*
|
|
111
|
+
* @throws Error if neither services nor capabilities are present
|
|
112
|
+
*/
|
|
113
|
+
export function extractRegistrationParams(
|
|
114
|
+
frontmatter: Record<string, unknown>
|
|
115
|
+
): { endpoint: string; serviceDescriptors: ServiceDescriptor[] } {
|
|
116
|
+
// Endpoint: use frontmatter field or placeholder
|
|
117
|
+
const endpoint = typeof frontmatter.endpoint === 'string' && frontmatter.endpoint
|
|
118
|
+
? frontmatter.endpoint
|
|
119
|
+
: PENDING_ENDPOINT;
|
|
120
|
+
|
|
121
|
+
// Try explicit services first
|
|
122
|
+
if (Array.isArray(frontmatter.services) && frontmatter.services.length > 0) {
|
|
123
|
+
const serviceDescriptors = (frontmatter.services as Record<string, unknown>[]).map(svc => {
|
|
124
|
+
const serviceType = String(svc.type || svc.service_type || '').trim().toLowerCase();
|
|
125
|
+
validateServiceType(serviceType, 'services');
|
|
126
|
+
|
|
127
|
+
// Parse price range: "1.0-100.0" or separate min/max
|
|
128
|
+
let minPrice = SERVICE_DEFAULTS.minPrice;
|
|
129
|
+
let maxPrice = SERVICE_DEFAULTS.maxPrice;
|
|
130
|
+
if (typeof svc.price === 'string' && svc.price.includes('-')) {
|
|
131
|
+
const [min, max] = svc.price.split('-').map(Number);
|
|
132
|
+
minPrice = usdcToBaseUnits(min, 'min_price');
|
|
133
|
+
maxPrice = usdcToBaseUnits(max, 'max_price');
|
|
134
|
+
} else {
|
|
135
|
+
if (svc.min_price !== undefined) minPrice = usdcToBaseUnits(Number(svc.min_price), 'min_price');
|
|
136
|
+
if (svc.max_price !== undefined) maxPrice = usdcToBaseUnits(Number(svc.max_price), 'max_price');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
serviceTypeHash: keccak256(toUtf8Bytes(serviceType)),
|
|
141
|
+
serviceType,
|
|
142
|
+
schemaURI: String(svc.schema_uri || svc.schemaURI || SERVICE_DEFAULTS.schemaURI),
|
|
143
|
+
minPrice,
|
|
144
|
+
maxPrice,
|
|
145
|
+
avgCompletionTime: Number(svc.avg_completion_time || svc.avgCompletionTime || SERVICE_DEFAULTS.avgCompletionTime),
|
|
146
|
+
metadataCID: String(svc.metadata_cid || svc.metadataCID || SERVICE_DEFAULTS.metadataCID),
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
return { endpoint, serviceDescriptors };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Fallback: convert capabilities list to services with defaults
|
|
153
|
+
if (Array.isArray(frontmatter.capabilities) && frontmatter.capabilities.length > 0) {
|
|
154
|
+
const serviceDescriptors = (frontmatter.capabilities as string[]).map(cap => {
|
|
155
|
+
const serviceType = String(cap).trim().toLowerCase();
|
|
156
|
+
validateServiceType(serviceType, 'capabilities');
|
|
157
|
+
return {
|
|
158
|
+
serviceTypeHash: keccak256(toUtf8Bytes(serviceType)),
|
|
159
|
+
serviceType,
|
|
160
|
+
schemaURI: SERVICE_DEFAULTS.schemaURI,
|
|
161
|
+
minPrice: SERVICE_DEFAULTS.minPrice,
|
|
162
|
+
maxPrice: SERVICE_DEFAULTS.maxPrice,
|
|
163
|
+
avgCompletionTime: SERVICE_DEFAULTS.avgCompletionTime,
|
|
164
|
+
metadataCID: SERVICE_DEFAULTS.metadataCID,
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
return { endpoint, serviceDescriptors };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
throw new Error(
|
|
171
|
+
'AGIRAILS.md must have "services" or "capabilities" in frontmatter for agent registration.\n' +
|
|
172
|
+
'Add at least one, e.g.:\n' +
|
|
173
|
+
' capabilities:\n' +
|
|
174
|
+
' - text-generation\n'
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ============================================================================
|
|
179
|
+
// Pipeline
|
|
180
|
+
// ============================================================================
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Execute the full publish pipeline.
|
|
184
|
+
*
|
|
185
|
+
* @param options - Publish configuration
|
|
186
|
+
* @returns Publish result with CID, hash, and transaction hashes
|
|
187
|
+
*/
|
|
188
|
+
export async function publishAgirailsMd(options: PublishOptions): Promise<PublishResult> {
|
|
189
|
+
const {
|
|
190
|
+
path,
|
|
191
|
+
registryAddress,
|
|
192
|
+
signer,
|
|
193
|
+
filebaseClient,
|
|
194
|
+
arweaveClient,
|
|
195
|
+
skipArweave = false,
|
|
196
|
+
dryRun = false,
|
|
197
|
+
gasSettings,
|
|
198
|
+
} = options;
|
|
199
|
+
|
|
200
|
+
// Step 1: Read and parse
|
|
201
|
+
const content = readFileSync(path, 'utf-8');
|
|
202
|
+
const { frontmatter, body } = parseAgirailsMd(content);
|
|
203
|
+
const { configHash } = computeConfigHash(content);
|
|
204
|
+
|
|
205
|
+
if (dryRun) {
|
|
206
|
+
return {
|
|
207
|
+
cid: '(dry-run)',
|
|
208
|
+
configHash,
|
|
209
|
+
dryRun: true,
|
|
210
|
+
registered: false,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Step 2: Upload raw AGIRAILS.md to IPFS via Filebase
|
|
215
|
+
// Upload the actual markdown file (not a JSON wrapper) so CID points to the real file
|
|
216
|
+
const ipfsResult = await filebaseClient.uploadBinary(
|
|
217
|
+
Buffer.from(content, 'utf-8'),
|
|
218
|
+
'text/markdown',
|
|
219
|
+
{ metadata: { type: 'agirails-config', version: '1.0' } }
|
|
220
|
+
);
|
|
221
|
+
const cid = ipfsResult.cid;
|
|
222
|
+
|
|
223
|
+
// Step 3: Upload to Arweave (optional)
|
|
224
|
+
// Arweave stores the JSON-structured form for archival querying.
|
|
225
|
+
// uploadJSON already sets Content-Type: application/json and Protocol: AGIRAILS as defaults.
|
|
226
|
+
let arweaveTxId: string | undefined;
|
|
227
|
+
if (!skipArweave && arweaveClient) {
|
|
228
|
+
const arweaveResult = await arweaveClient.uploadJSON(
|
|
229
|
+
{ frontmatter, body, _format: 'agirails.md.v1' },
|
|
230
|
+
[
|
|
231
|
+
{ name: 'Type', value: 'agent-config' },
|
|
232
|
+
{ name: 'ConfigHash', value: configHash },
|
|
233
|
+
{ name: 'IPFS-CID', value: cid },
|
|
234
|
+
]
|
|
235
|
+
);
|
|
236
|
+
arweaveTxId = arweaveResult.txId;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Step 4: Auto-register if needed, then publish on-chain
|
|
240
|
+
const registry = new AgentRegistry(registryAddress, signer, gasSettings);
|
|
241
|
+
const registryClient = new AgentRegistryClient(registryAddress, signer, gasSettings);
|
|
242
|
+
let registered = false;
|
|
243
|
+
|
|
244
|
+
const signerAddress = await signer.getAddress();
|
|
245
|
+
const profile = await registry.getAgent(signerAddress);
|
|
246
|
+
|
|
247
|
+
if (!profile) {
|
|
248
|
+
// Not registered — extract params from frontmatter and auto-register
|
|
249
|
+
const regParams = extractRegistrationParams(frontmatter);
|
|
250
|
+
await registry.registerAgent(regParams);
|
|
251
|
+
registered = true;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const { txHash } = await registryClient.publishConfig(cid, configHash);
|
|
255
|
+
|
|
256
|
+
// Step 5: Update frontmatter with publish metadata
|
|
257
|
+
const updatedFrontmatter = {
|
|
258
|
+
...frontmatter,
|
|
259
|
+
config_hash: configHash,
|
|
260
|
+
published_at: new Date().toISOString(),
|
|
261
|
+
config_cid: cid,
|
|
262
|
+
...(arweaveTxId ? { arweave_tx: arweaveTxId } : {}),
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const updatedContent = serializeAgirailsMd(updatedFrontmatter, body);
|
|
266
|
+
writeFileSync(path, updatedContent, 'utf-8');
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
cid,
|
|
270
|
+
configHash,
|
|
271
|
+
txHash,
|
|
272
|
+
arweaveTxId,
|
|
273
|
+
dryRun: false,
|
|
274
|
+
registered,
|
|
275
|
+
};
|
|
276
|
+
}
|