@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/README.md
CHANGED
|
@@ -3,18 +3,24 @@
|
|
|
3
3
|
[](https://www.typescriptlang.org/)
|
|
4
4
|
[](https://nodejs.org/)
|
|
5
5
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
6
|
-
[]()
|
|
7
7
|
|
|
8
8
|
The official TypeScript SDK for the **Agent Commerce Transaction Protocol (ACTP)** - enabling AI agents to transact with each other through blockchain-based escrow.
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
12
|
- **Three-tier API**: Basic, Standard, and Advanced levels for different use cases
|
|
13
|
+
- **Adapter Routing**: `0x...` addresses route to ACTP, `https://` to x402, agent IDs to ERC-8004
|
|
14
|
+
- **x402 Payments**: HTTP-native micropayments via x402 protocol with optional relay fee splitting
|
|
15
|
+
- **ERC-8004 Bridge**: Read-only resolution of agent IDs to wallet addresses for payments
|
|
16
|
+
- **ERC-8004 Reputation**: Post-settlement feedback reporting to on-chain reputation registry
|
|
17
|
+
- **AGIRAILS.md**: Agent config as source of truth with publish/pull/diff CLI and drift detection
|
|
13
18
|
- **Mock Runtime**: Full local testing without blockchain connection
|
|
14
19
|
- **Type-safe**: Complete TypeScript types with strict mode support
|
|
15
20
|
- **Async/Await**: Promise-based API for modern async workflows
|
|
16
|
-
- **Comprehensive Errors**: Structured exception types with error codes
|
|
21
|
+
- **Comprehensive Errors**: Structured exception types with error codes and recovery guidance
|
|
17
22
|
- **Security Built-in**: EIP-712 signing, replay protection, safe nonce management
|
|
23
|
+
- **Configurable Confirmations**: Block confirmation depth configurable per-network (default: 2)
|
|
18
24
|
|
|
19
25
|
## Installation
|
|
20
26
|
|
|
@@ -38,26 +44,21 @@ Get started with real transactions on Base Sepolia testnet:
|
|
|
38
44
|
# Install CLI globally
|
|
39
45
|
npm install -g @agirails/sdk
|
|
40
46
|
|
|
41
|
-
#
|
|
42
|
-
actp init
|
|
43
|
-
|
|
44
|
-
# Set your private key (or use PRIVATE_KEY env var)
|
|
45
|
-
actp config set private-key YOUR_PRIVATE_KEY
|
|
46
|
-
|
|
47
|
-
# Note: mint is mock mode only. For testnet/mainnet, bridge real USDC via bridge.base.org
|
|
48
|
-
# In mock mode:
|
|
49
|
-
actp mint --amount 1000 # Mint 1000 test USDC (mock mode only)
|
|
47
|
+
# One-time setup: generates encrypted keystore at .actp/keystore.json
|
|
48
|
+
ACTP_KEY_PASSWORD=your-password actp init -m testnet
|
|
50
49
|
|
|
51
50
|
# Check your balance
|
|
52
|
-
actp balance
|
|
51
|
+
ACTP_KEY_PASSWORD=your-password actp balance
|
|
53
52
|
|
|
54
53
|
# Make a payment
|
|
55
|
-
actp pay 0xProviderAddress 100 --deadline 24h
|
|
54
|
+
ACTP_KEY_PASSWORD=your-password actp pay 0xProviderAddress 100 --deadline 24h
|
|
56
55
|
|
|
57
56
|
# Watch transaction status
|
|
58
57
|
actp watch TX_ID
|
|
59
58
|
```
|
|
60
59
|
|
|
60
|
+
> **Alternative**: Set `ACTP_PRIVATE_KEY` env var to use a raw private key instead of the keystore.
|
|
61
|
+
|
|
61
62
|
### Basic API - Simple Payments
|
|
62
63
|
|
|
63
64
|
The simplest way to make a payment - just specify who, how much, and go:
|
|
@@ -95,10 +96,10 @@ import { ACTPClient } from '@agirails/sdk';
|
|
|
95
96
|
import { ethers } from 'ethers';
|
|
96
97
|
|
|
97
98
|
async function main() {
|
|
99
|
+
// No wallet param needed — auto-detects .actp/keystore.json
|
|
98
100
|
const client = await ACTPClient.create({
|
|
99
101
|
mode: 'testnet', // or 'mainnet' for production
|
|
100
102
|
requesterAddress: '0x1111111111111111111111111111111111111111',
|
|
101
|
-
privateKey: process.env.PRIVATE_KEY,
|
|
102
103
|
});
|
|
103
104
|
|
|
104
105
|
// Step 1: Create transaction (no funds locked yet)
|
|
@@ -197,19 +198,17 @@ const client = await ACTPClient.create({
|
|
|
197
198
|
stateDirectory: '.actp' // Optional: persist state to disk
|
|
198
199
|
});
|
|
199
200
|
|
|
200
|
-
// Testnet mode - Base Sepolia
|
|
201
|
+
// Testnet mode - Base Sepolia (auto-detects keystore or ACTP_PRIVATE_KEY)
|
|
201
202
|
const client = await ACTPClient.create({
|
|
202
203
|
mode: 'testnet',
|
|
203
204
|
requesterAddress: '0x1111111111111111111111111111111111111111',
|
|
204
|
-
privateKey: '0x...',
|
|
205
205
|
rpcUrl: 'https://sepolia.base.org' // Optional: custom RPC
|
|
206
206
|
});
|
|
207
207
|
|
|
208
|
-
// Mainnet mode - Base
|
|
208
|
+
// Mainnet mode - Base (auto-detects keystore or ACTP_PRIVATE_KEY)
|
|
209
209
|
const client = await ACTPClient.create({
|
|
210
210
|
mode: 'mainnet',
|
|
211
211
|
requesterAddress: '0x1111111111111111111111111111111111111111',
|
|
212
|
-
privateKey: '0x...'
|
|
213
212
|
});
|
|
214
213
|
```
|
|
215
214
|
|
|
@@ -329,10 +328,30 @@ actp simulate pay <provider> <amount>
|
|
|
329
328
|
actp simulate fee <amount>
|
|
330
329
|
```
|
|
331
330
|
|
|
331
|
+
### AGIRAILS.md Config Management
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
# Publish agent config to on-chain registry
|
|
335
|
+
actp publish [--dry-run]
|
|
336
|
+
|
|
337
|
+
# Pull config from on-chain registry
|
|
338
|
+
actp pull <agent-id>
|
|
339
|
+
|
|
340
|
+
# Compare local config vs on-chain
|
|
341
|
+
actp diff <agent-id>
|
|
342
|
+
|
|
343
|
+
# Register agent on AgentRegistry
|
|
344
|
+
actp register
|
|
345
|
+
```
|
|
346
|
+
|
|
332
347
|
### Configuration
|
|
333
348
|
|
|
334
349
|
```bash
|
|
335
|
-
#
|
|
350
|
+
# Initialize keystore (one-time setup)
|
|
351
|
+
ACTP_KEY_PASSWORD=your-password actp init -m testnet # or mainnet
|
|
352
|
+
ACTP_KEY_PASSWORD=your-password actp init -m mainnet
|
|
353
|
+
|
|
354
|
+
# General config
|
|
336
355
|
actp config set <key> <value>
|
|
337
356
|
actp config get <key>
|
|
338
357
|
actp config list
|
|
@@ -341,7 +360,6 @@ actp config reset
|
|
|
341
360
|
# Available config keys:
|
|
342
361
|
# network: base-sepolia | base-mainnet | mock
|
|
343
362
|
# rpc-url: RPC endpoint URL
|
|
344
|
-
# private-key: Wallet private key (or use PRIVATE_KEY env)
|
|
345
363
|
# state-directory: Directory for mock state persistence
|
|
346
364
|
```
|
|
347
365
|
|
|
@@ -434,11 +452,11 @@ const providers = directory.find({ capabilities: ['gpt-4'] });
|
|
|
434
452
|
```typescript
|
|
435
453
|
import { Agent, AgentConfig } from '@agirails/sdk';
|
|
436
454
|
|
|
437
|
-
// Create an agent
|
|
455
|
+
// Create an agent (auto-detects keystore, no wallet param needed)
|
|
438
456
|
const agent = new Agent({
|
|
439
457
|
name: 'my-agent',
|
|
440
|
-
|
|
441
|
-
services: ['text-generation']
|
|
458
|
+
network: 'testnet',
|
|
459
|
+
services: ['text-generation'],
|
|
442
460
|
});
|
|
443
461
|
|
|
444
462
|
// Handle jobs
|
|
@@ -461,7 +479,10 @@ This TypeScript SDK maintains **full parity** with the Python SDK:
|
|
|
461
479
|
| EIP-712 Signing | Full support | Full support |
|
|
462
480
|
| Level0 API | Full ACTP flow | Full ACTP flow |
|
|
463
481
|
| Level1 Agent API | Complete | Complete |
|
|
464
|
-
| CLI Commands | watch, batch, simulate | watch, batch, simulate |
|
|
482
|
+
| CLI Commands | watch, batch, simulate, publish, pull, diff | watch, batch, simulate |
|
|
483
|
+
| Adapter Routing | ACTP + x402 + ERC-8004 | ACTP only |
|
|
484
|
+
| ERC-8004 Bridge | Identity + Reputation | Not yet |
|
|
485
|
+
| AGIRAILS.md Config | publish/pull/diff/drift detection | Not yet |
|
|
465
486
|
| Nonce Tracking | SecureNonce, ReceivedNonceTracker | SecureNonce, ReceivedNonceTracker |
|
|
466
487
|
| Attestation Tracking | UsedAttestationTracker | UsedAttestationTracker |
|
|
467
488
|
|
|
@@ -472,7 +493,7 @@ This TypeScript SDK maintains **full parity** with the Python SDK:
|
|
|
472
493
|
| Network | Chain ID | Status |
|
|
473
494
|
|---------|----------|--------|
|
|
474
495
|
| Base Sepolia | 84532 | ✅ Active (Testnet) |
|
|
475
|
-
| Base Mainnet | 8453 |
|
|
496
|
+
| Base Mainnet | 8453 | ✅ Active |
|
|
476
497
|
|
|
477
498
|
## Fee Structure
|
|
478
499
|
|
|
@@ -485,8 +506,13 @@ This TypeScript SDK maintains **full parity** with the Python SDK:
|
|
|
485
506
|
- **Replay Protection**: Nonce management prevents transaction replay
|
|
486
507
|
- **Non-custodial Escrow**: 2-of-2 release pattern
|
|
487
508
|
- **EAS Integration**: Ethereum Attestation Service for delivery proofs
|
|
509
|
+
- **ERC-8004 Reputation**: On-chain settlement/dispute feedback after ACTP transactions
|
|
488
510
|
- **Input Validation**: All user inputs validated before processing
|
|
489
511
|
|
|
512
|
+
### Transaction Confirmations
|
|
513
|
+
|
|
514
|
+
All state-changing operations in ACTPKernel wait for block confirmations before events are emitted. The default is 2 confirmations (~4-6s on Base L2's ~2s blocks), configurable via `BlockchainRuntimeConfig.confirmations`. The SDK's `EventMonitor` receives already-confirmed events; no additional confirmation handling is needed at the application layer.
|
|
515
|
+
|
|
490
516
|
## Decentralized Identifiers (DIDs)
|
|
491
517
|
|
|
492
518
|
AGIRAILS uses **did:ethr** DIDs based on the [ERC-1056](https://eips.ethereum.org/EIPS/eip-1056) standard for identity management.
|
|
@@ -604,19 +630,27 @@ DIDs are used internally for:
|
|
|
604
630
|
## Environment Variables
|
|
605
631
|
|
|
606
632
|
```bash
|
|
607
|
-
#
|
|
608
|
-
|
|
633
|
+
# Wallet resolution (checked in order):
|
|
634
|
+
ACTP_PRIVATE_KEY=0x... # Raw private key (takes priority if set)
|
|
635
|
+
ACTP_KEY_PASSWORD=... # Decrypts .actp/keystore.json (recommended)
|
|
609
636
|
|
|
610
637
|
# Optional
|
|
611
|
-
BASE_SEPOLIA_RPC
|
|
612
|
-
|
|
638
|
+
BASE_SEPOLIA_RPC=... # Custom RPC for Base Sepolia
|
|
639
|
+
BASE_MAINNET_RPC=... # Custom RPC for Base Mainnet
|
|
640
|
+
CDP_API_KEY=... # Coinbase Developer Platform API key
|
|
641
|
+
PIMLICO_API_KEY=... # Pimlico bundler/paymaster API key
|
|
642
|
+
IPFS_GATEWAY=... # Custom IPFS gateway URL
|
|
613
643
|
```
|
|
614
644
|
|
|
615
645
|
## Requirements
|
|
616
646
|
|
|
617
|
-
- Node.js 18+
|
|
647
|
+
- Node.js 18+ (required for global `fetch` and `AbortController`)
|
|
618
648
|
- TypeScript 5.0+ (for development)
|
|
619
|
-
- Dependencies: ethers, viem
|
|
649
|
+
- Dependencies: ethers, viem, permissionless
|
|
650
|
+
|
|
651
|
+
### Module Format
|
|
652
|
+
|
|
653
|
+
The SDK ships as **CommonJS only**. It works with `require()` and with bundlers (webpack, esbuild, Rollup) that support CJS. If you are using ESM (`import` syntax), Node.js will auto-interop with CJS modules — no additional configuration is needed.
|
|
620
654
|
|
|
621
655
|
## License
|
|
622
656
|
|
package/dist/ACTPClient.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ import { IAdapter, TransactionStatus } from './adapters/IAdapter';
|
|
|
41
41
|
import { UnifiedPayParams, UnifiedPayResult } from './types/adapter';
|
|
42
42
|
import { EASHelper, EASConfig } from './protocol/EASHelper';
|
|
43
43
|
import { ReputationReporter } from './erc8004/ReputationReporter';
|
|
44
|
+
import { IWalletProvider } from './wallet/IWalletProvider';
|
|
44
45
|
/**
|
|
45
46
|
* Supported modes for ACTPClient.
|
|
46
47
|
*
|
|
@@ -67,9 +68,23 @@ export interface ACTPClientConfig {
|
|
|
67
68
|
* This address is used as the "from" address for all transactions
|
|
68
69
|
* created through this client instance.
|
|
69
70
|
*
|
|
71
|
+
* When wallet is 'auto', this is auto-derived from the Smart Wallet
|
|
72
|
+
* and does NOT need to be provided.
|
|
73
|
+
*
|
|
70
74
|
* @example '0x1111111111111111111111111111111111111111'
|
|
71
75
|
*/
|
|
72
|
-
requesterAddress
|
|
76
|
+
requesterAddress?: string;
|
|
77
|
+
/**
|
|
78
|
+
* AIP-12: Wallet mode.
|
|
79
|
+
*
|
|
80
|
+
* - 'auto': CoinbaseSmartWallet + gas sponsorship (Tier 1, recommended).
|
|
81
|
+
* Requires CDP_API_KEY env var. Agent address = Smart Wallet address.
|
|
82
|
+
* - undefined: EOA wallet from privateKey (Tier 2, backward compatible).
|
|
83
|
+
*
|
|
84
|
+
* When 'auto', requesterAddress is derived from the Smart Wallet
|
|
85
|
+
* and does not need to be provided.
|
|
86
|
+
*/
|
|
87
|
+
wallet?: 'auto';
|
|
73
88
|
/**
|
|
74
89
|
* Optional: Project root directory for mock state file storage.
|
|
75
90
|
*
|
|
@@ -152,6 +167,7 @@ export interface ACTPClientConfig {
|
|
|
152
167
|
actpKernel?: string;
|
|
153
168
|
escrowVault?: string;
|
|
154
169
|
usdc?: string;
|
|
170
|
+
agentRegistry?: string;
|
|
155
171
|
};
|
|
156
172
|
/**
|
|
157
173
|
* Optional: Gas settings for blockchain transactions.
|
|
@@ -203,6 +219,8 @@ export interface ACTPClientInfo {
|
|
|
203
219
|
address: string;
|
|
204
220
|
/** State directory (mock mode only) */
|
|
205
221
|
stateDirectory?: string;
|
|
222
|
+
/** Wallet tier ('auto' = Smart Wallet, 'eoa' = EOA, undefined = mock) */
|
|
223
|
+
walletTier?: 'auto' | 'eoa';
|
|
206
224
|
}
|
|
207
225
|
/**
|
|
208
226
|
* ACTPClient - Main entry point for AGIRAILS SDK.
|
|
@@ -334,6 +352,12 @@ export declare class ACTPClient {
|
|
|
334
352
|
* @internal
|
|
335
353
|
*/
|
|
336
354
|
private readonly reputationReporter?;
|
|
355
|
+
/**
|
|
356
|
+
* AIP-12: Wallet provider (Tier 1 Auto or Tier 2 EOA).
|
|
357
|
+
* Only set in testnet/mainnet modes.
|
|
358
|
+
* @internal
|
|
359
|
+
*/
|
|
360
|
+
private readonly walletProvider?;
|
|
337
361
|
/**
|
|
338
362
|
* Private constructor - use ACTPClient.create() factory method.
|
|
339
363
|
*/
|
|
@@ -671,5 +695,22 @@ export declare class ACTPClient {
|
|
|
671
695
|
* ```
|
|
672
696
|
*/
|
|
673
697
|
getReputationReporter(): ReputationReporter | undefined;
|
|
698
|
+
/**
|
|
699
|
+
* AIP-12: Get the wallet provider instance.
|
|
700
|
+
*
|
|
701
|
+
* Only available in testnet/mainnet modes.
|
|
702
|
+
* Returns undefined in mock mode.
|
|
703
|
+
*
|
|
704
|
+
* Use this for advanced operations like checking wallet info,
|
|
705
|
+
* or sending custom batched transactions.
|
|
706
|
+
*/
|
|
707
|
+
getWalletProvider(): IWalletProvider | undefined;
|
|
708
|
+
/**
|
|
709
|
+
* Non-blocking drift detection for AGIRAILS.md config.
|
|
710
|
+
* Checks if local AGIRAILS.md matches on-chain config hash.
|
|
711
|
+
* Logs warnings but never blocks agent operation.
|
|
712
|
+
* @internal
|
|
713
|
+
*/
|
|
714
|
+
private checkConfigDrift;
|
|
674
715
|
}
|
|
675
716
|
//# sourceMappingURL=ACTPClient.d.ts.map
|
package/dist/ACTPClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ACTPClient.d.ts","sourceRoot":"","sources":["../src/ACTPClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AASH,OAAO,EAAE,YAAY,EAAgB,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,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;IAKzD;;;;;;;;;;;;;;OAcG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBzE;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCvE;;;;;;;;;;;;;OAaG;IACH,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAIxC;;;;;;;;;;OAUG;IACH,qBAAqB,IAAI,MAAM,EAAE;IAIjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,qBAAqB,IAAI,kBAAkB,GAAG,SAAS;IAIvD;;;;;;;;OAQG;IACH,iBAAiB,IAAI,eAAe,GAAG,SAAS;IAIhD;;;;;OAKG;YACW,gBAAgB;CA8C/B"}
|
package/dist/ACTPClient.js
CHANGED
|
@@ -74,6 +74,9 @@ const AdapterRouter_1 = require("./adapters/AdapterRouter");
|
|
|
74
74
|
const ERC8004Bridge_1 = require("./erc8004/ERC8004Bridge");
|
|
75
75
|
const ReputationReporter_1 = require("./erc8004/ReputationReporter");
|
|
76
76
|
const networks_1 = require("./config/networks");
|
|
77
|
+
const EOAWalletProvider_1 = require("./wallet/EOAWalletProvider");
|
|
78
|
+
const AutoWalletProvider_1 = require("./wallet/AutoWalletProvider");
|
|
79
|
+
const Logger_1 = require("./utils/Logger");
|
|
77
80
|
// ============================================================================
|
|
78
81
|
// Security: Path Validation
|
|
79
82
|
// ============================================================================
|
|
@@ -88,6 +91,24 @@ const networks_1 = require("./config/networks");
|
|
|
88
91
|
* @param stateDirectory - The directory path to validate
|
|
89
92
|
* @throws Error if path is unsafe
|
|
90
93
|
*/
|
|
94
|
+
/**
|
|
95
|
+
* Check if an agent is registered on AgentRegistry.
|
|
96
|
+
* Lightweight read-only check — no signer needed.
|
|
97
|
+
*
|
|
98
|
+
* Uses minimal ABI fragment to avoid importing the full AgentRegistry class.
|
|
99
|
+
* Checks registeredAt field of AgentProfile struct (> 0 means registered).
|
|
100
|
+
*/
|
|
101
|
+
async function checkRegistration(provider, registryAddress, agentAddress) {
|
|
102
|
+
const contract = new ethers_1.ethers.Contract(registryAddress, [
|
|
103
|
+
'function getAgent(address agentAddress) view returns ' +
|
|
104
|
+
'(tuple(address agentAddress, string did, string endpoint, bytes32[] serviceTypes, ' +
|
|
105
|
+
'uint256 stakedAmount, uint256 reputationScore, uint256 totalTransactions, ' +
|
|
106
|
+
'uint256 disputedTransactions, uint256 totalVolumeUSDC, uint256 registeredAt, ' +
|
|
107
|
+
'uint256 updatedAt, bool isActive, bytes32 configHash, string configCID, bool listed))',
|
|
108
|
+
], provider);
|
|
109
|
+
const profile = await contract.getAgent(agentAddress);
|
|
110
|
+
return profile.registeredAt > 0n;
|
|
111
|
+
}
|
|
91
112
|
function validateStateDirectory(stateDirectory) {
|
|
92
113
|
// Check for path traversal characters
|
|
93
114
|
if (stateDirectory.includes('..')) {
|
|
@@ -203,12 +224,13 @@ class ACTPClient {
|
|
|
203
224
|
/**
|
|
204
225
|
* Private constructor - use ACTPClient.create() factory method.
|
|
205
226
|
*/
|
|
206
|
-
constructor(runtime, requesterAddress, info, easHelper, erc8004Bridge, reputationReporter) {
|
|
227
|
+
constructor(runtime, requesterAddress, info, easHelper, erc8004Bridge, reputationReporter, walletProvider, contractAddresses) {
|
|
207
228
|
this.runtime = runtime;
|
|
208
229
|
this.info = info;
|
|
209
230
|
this.easHelper = easHelper;
|
|
210
231
|
this.reputationReporter = reputationReporter;
|
|
211
|
-
this.
|
|
232
|
+
this.walletProvider = walletProvider;
|
|
233
|
+
this.basic = new BasicAdapter_1.BasicAdapter(runtime, requesterAddress, easHelper, walletProvider, contractAddresses);
|
|
212
234
|
this.standard = new StandardAdapter_1.StandardAdapter(runtime, requesterAddress, easHelper);
|
|
213
235
|
// Initialize registry and router
|
|
214
236
|
this.registry = new AdapterRegistry_1.AdapterRegistry();
|
|
@@ -254,27 +276,40 @@ class ACTPClient {
|
|
|
254
276
|
* ```
|
|
255
277
|
*/
|
|
256
278
|
static async create(config) {
|
|
257
|
-
// Validate requester address
|
|
258
|
-
if (!config.requesterAddress) {
|
|
259
|
-
throw new Error('requesterAddress is required');
|
|
260
|
-
}
|
|
261
|
-
if (!/^0x[a-fA-F0-9]{40}$/.test(config.requesterAddress)) {
|
|
262
|
-
throw new Error(`Invalid requesterAddress: "${config.requesterAddress}". ` +
|
|
263
|
-
'Must be a valid Ethereum address (0x-prefixed, 40 hex chars)');
|
|
264
|
-
}
|
|
265
279
|
let runtime;
|
|
266
280
|
let stateDirectory;
|
|
267
281
|
let easHelper;
|
|
268
282
|
let erc8004Bridge;
|
|
269
283
|
let reputationReporter;
|
|
284
|
+
let walletProvider;
|
|
285
|
+
let requesterAddress;
|
|
286
|
+
let contractAddresses;
|
|
270
287
|
// If custom runtime provided, use it directly
|
|
271
288
|
if (config.runtime) {
|
|
289
|
+
// Custom runtime: requesterAddress is mandatory
|
|
290
|
+
if (!config.requesterAddress) {
|
|
291
|
+
throw new Error('requesterAddress is required when providing a custom runtime');
|
|
292
|
+
}
|
|
293
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(config.requesterAddress)) {
|
|
294
|
+
throw new Error(`Invalid requesterAddress: "${config.requesterAddress}". ` +
|
|
295
|
+
'Must be a valid Ethereum address (0x-prefixed, 40 hex chars)');
|
|
296
|
+
}
|
|
297
|
+
requesterAddress = config.requesterAddress;
|
|
272
298
|
runtime = config.runtime;
|
|
273
299
|
}
|
|
274
300
|
else {
|
|
275
301
|
// Initialize runtime based on mode
|
|
276
302
|
switch (config.mode) {
|
|
277
303
|
case 'mock': {
|
|
304
|
+
// Mock mode: requesterAddress is mandatory
|
|
305
|
+
if (!config.requesterAddress) {
|
|
306
|
+
throw new Error('requesterAddress is required for mock mode');
|
|
307
|
+
}
|
|
308
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(config.requesterAddress)) {
|
|
309
|
+
throw new Error(`Invalid requesterAddress: "${config.requesterAddress}". ` +
|
|
310
|
+
'Must be a valid Ethereum address (0x-prefixed, 40 hex chars)');
|
|
311
|
+
}
|
|
312
|
+
requesterAddress = config.requesterAddress;
|
|
278
313
|
// SECURITY FIX: Enhanced path validation to prevent path traversal attacks
|
|
279
314
|
if (config.stateDirectory) {
|
|
280
315
|
validateStateDirectory(config.stateDirectory);
|
|
@@ -294,18 +329,97 @@ class ACTPClient {
|
|
|
294
329
|
}
|
|
295
330
|
// Map mode to network config
|
|
296
331
|
const network = config.mode === 'testnet' ? 'base-sepolia' : 'base-mainnet';
|
|
332
|
+
const networkConfig = (0, networks_1.getNetwork)(network);
|
|
297
333
|
// Default RPC URL from network config if not provided
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
// Optional persistent state directory can be used for:
|
|
301
|
-
// - mock mode state (mock-state.json)
|
|
302
|
-
// - blockchain mode safety state (e.g., used-attestation replay protection)
|
|
334
|
+
const rpcUrl = config.rpcUrl ?? networkConfig.rpcUrl;
|
|
335
|
+
// Optional persistent state directory
|
|
303
336
|
if (config.stateDirectory) {
|
|
304
337
|
validateStateDirectory(config.stateDirectory);
|
|
305
338
|
}
|
|
306
339
|
// Create ethers provider and signer
|
|
307
340
|
const provider = new ethers_1.ethers.JsonRpcProvider(rpcUrl);
|
|
308
341
|
const signer = new ethers_1.ethers.Wallet(config.privateKey, provider);
|
|
342
|
+
// ====================================================================
|
|
343
|
+
// AIP-12: Wallet Provider Selection
|
|
344
|
+
// ====================================================================
|
|
345
|
+
if (config.wallet === 'auto') {
|
|
346
|
+
// Tier 1: CoinbaseSmartWallet + gasless transactions
|
|
347
|
+
if (!networkConfig.aa) {
|
|
348
|
+
throw new Error(`AA configuration not available for ${config.mode} mode. ` +
|
|
349
|
+
'Check that networks.ts has aa config for this network.');
|
|
350
|
+
}
|
|
351
|
+
// Validate that bundler/paymaster URLs have actual API keys
|
|
352
|
+
const cdpBundlerUrl = networkConfig.aa.bundlerUrls.coinbase;
|
|
353
|
+
const hasPimlico = !!networkConfig.aa.bundlerUrls.pimlico;
|
|
354
|
+
if (cdpBundlerUrl.endsWith('/') && !hasPimlico) {
|
|
355
|
+
throw new Error('CDP_API_KEY is required for gas-sponsored transactions.\n\n' +
|
|
356
|
+
'Set up your API key:\n' +
|
|
357
|
+
' 1. Visit https://portal.cdp.coinbase.com/\n' +
|
|
358
|
+
' 2. Create a new API key\n' +
|
|
359
|
+
' 3. export CDP_API_KEY="your-key-here"\n\n' +
|
|
360
|
+
'Or set PIMLICO_API_KEY as an alternative bundler/paymaster.\n' +
|
|
361
|
+
'Or use wallet: undefined for traditional EOA transactions (requires ETH for gas).');
|
|
362
|
+
}
|
|
363
|
+
const autoWallet = await AutoWalletProvider_1.AutoWalletProvider.create({
|
|
364
|
+
signer,
|
|
365
|
+
provider,
|
|
366
|
+
chainId: networkConfig.chainId,
|
|
367
|
+
actpKernelAddress: config.contracts?.actpKernel ?? networkConfig.contracts.actpKernel,
|
|
368
|
+
bundler: {
|
|
369
|
+
primaryUrl: networkConfig.aa.bundlerUrls.coinbase,
|
|
370
|
+
backupUrl: networkConfig.aa.bundlerUrls.pimlico,
|
|
371
|
+
},
|
|
372
|
+
paymaster: {
|
|
373
|
+
primaryUrl: networkConfig.aa.paymasterUrls.coinbase,
|
|
374
|
+
backupUrl: networkConfig.aa.paymasterUrls.pimlico,
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
// Check AgentRegistry — gasless only for registered agents
|
|
378
|
+
const smartWalletAddress = autoWallet.getAddress();
|
|
379
|
+
const agentRegistryAddress = config.contracts?.agentRegistry
|
|
380
|
+
?? networkConfig.contracts.agentRegistry;
|
|
381
|
+
let isRegistered = false;
|
|
382
|
+
if (agentRegistryAddress) {
|
|
383
|
+
try {
|
|
384
|
+
isRegistered = await checkRegistration(provider, agentRegistryAddress, smartWalletAddress);
|
|
385
|
+
}
|
|
386
|
+
catch {
|
|
387
|
+
// Registry check failed (e.g. RPC down) — allow AA anyway.
|
|
388
|
+
// Rationale: don't punish legit registered agents for infra issues.
|
|
389
|
+
// Paymaster contract allowlist + rate limits prevent abuse.
|
|
390
|
+
isRegistered = true;
|
|
391
|
+
Logger_1.sdkLogger.warn('AgentRegistry check failed, proceeding with AA wallet');
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
// No registry deployed — skip check (early testnet)
|
|
396
|
+
isRegistered = true;
|
|
397
|
+
}
|
|
398
|
+
if (isRegistered) {
|
|
399
|
+
walletProvider = autoWallet;
|
|
400
|
+
requesterAddress = smartWalletAddress;
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
// Not registered — fall back to EOA with warning
|
|
404
|
+
Logger_1.sdkLogger.warn('Agent not registered on AgentRegistry. ' +
|
|
405
|
+
'Falling back to EOA wallet (gas not sponsored). ' +
|
|
406
|
+
'Run "actp register" for gas-free transactions.');
|
|
407
|
+
walletProvider = new EOAWalletProvider_1.EOAWalletProvider(signer, networkConfig.chainId);
|
|
408
|
+
// Force signer.address — config.requesterAddress may be the Smart Wallet
|
|
409
|
+
// address (set by `actp init --wallet auto`), which would be wrong for EOA.
|
|
410
|
+
requesterAddress = signer.address;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
// Tier 2: EOA Wallet (backward compatible)
|
|
415
|
+
walletProvider = new EOAWalletProvider_1.EOAWalletProvider(signer, networkConfig.chainId);
|
|
416
|
+
requesterAddress = config.requesterAddress ?? signer.address;
|
|
417
|
+
}
|
|
418
|
+
// Validate derived/provided address
|
|
419
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(requesterAddress)) {
|
|
420
|
+
throw new Error(`Invalid requesterAddress: "${requesterAddress}". ` +
|
|
421
|
+
'Must be a valid Ethereum address (0x-prefixed, 40 hex chars)');
|
|
422
|
+
}
|
|
309
423
|
const requireAttestation = config.requireAttestation ?? Boolean(config.easConfig);
|
|
310
424
|
// Create BlockchainRuntime
|
|
311
425
|
const blockchainRuntime = new BlockchainRuntime_1.BlockchainRuntime({
|
|
@@ -327,18 +441,22 @@ class ACTPClient {
|
|
|
327
441
|
easHelper = blockchainRuntime.getEASHelper();
|
|
328
442
|
}
|
|
329
443
|
// ERC-8004 INTEGRATION: Create bridge for agent ID resolution
|
|
330
|
-
// Maps network to ERC8004Network ('base-sepolia' or 'base')
|
|
331
444
|
const erc8004Network = config.mode === 'testnet' ? 'base-sepolia' : 'base';
|
|
332
445
|
erc8004Bridge = new ERC8004Bridge_1.ERC8004Bridge({
|
|
333
446
|
network: erc8004Network,
|
|
334
447
|
rpcUrl,
|
|
335
448
|
});
|
|
336
449
|
// ERC-8004 REPUTATION: Create reporter for settlement outcome reporting
|
|
337
|
-
// Reports successful settlements and dispute outcomes to Reputation Registry
|
|
338
450
|
reputationReporter = new ReputationReporter_1.ReputationReporter({
|
|
339
451
|
network: erc8004Network,
|
|
340
452
|
signer,
|
|
341
453
|
});
|
|
454
|
+
// AIP-12: Contract addresses for AA batched payments
|
|
455
|
+
contractAddresses = {
|
|
456
|
+
usdc: config.contracts?.usdc ?? networkConfig.contracts.usdc,
|
|
457
|
+
actpKernel: config.contracts?.actpKernel ?? networkConfig.contracts.actpKernel,
|
|
458
|
+
escrowVault: config.contracts?.escrowVault ?? networkConfig.contracts.escrowVault,
|
|
459
|
+
};
|
|
342
460
|
break;
|
|
343
461
|
}
|
|
344
462
|
default:
|
|
@@ -347,15 +465,22 @@ class ACTPClient {
|
|
|
347
465
|
}
|
|
348
466
|
}
|
|
349
467
|
// Normalize address to lowercase for consistency
|
|
350
|
-
const normalizedAddress =
|
|
468
|
+
const normalizedAddress = requesterAddress.toLowerCase();
|
|
351
469
|
const info = {
|
|
352
470
|
mode: config.mode,
|
|
353
471
|
address: normalizedAddress,
|
|
354
472
|
stateDirectory,
|
|
473
|
+
walletTier: walletProvider?.getWalletInfo().tier,
|
|
355
474
|
};
|
|
356
|
-
//
|
|
357
|
-
|
|
358
|
-
|
|
475
|
+
// Pass wallet provider and contract addresses to constructor
|
|
476
|
+
const client = new ACTPClient(runtime, normalizedAddress, info, easHelper, erc8004Bridge, reputationReporter, walletProvider, contractAddresses);
|
|
477
|
+
// Drift detection: non-blocking check for AGIRAILS.md sync status
|
|
478
|
+
if (config.mode !== 'mock') {
|
|
479
|
+
client.checkConfigDrift(config).catch(() => {
|
|
480
|
+
// Silently ignore drift check errors — non-critical
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
return client;
|
|
359
484
|
}
|
|
360
485
|
// ==========================================================================
|
|
361
486
|
// Public Methods
|
|
@@ -700,7 +825,7 @@ class ACTPClient {
|
|
|
700
825
|
})
|
|
701
826
|
.then((result) => {
|
|
702
827
|
if (result) {
|
|
703
|
-
|
|
828
|
+
Logger_1.sdkLogger.info(`[ERC8004] Settlement reported for agent ${agentId}: ${result.txHash}`);
|
|
704
829
|
}
|
|
705
830
|
})
|
|
706
831
|
.catch(() => {
|
|
@@ -763,6 +888,66 @@ class ACTPClient {
|
|
|
763
888
|
getReputationReporter() {
|
|
764
889
|
return this.reputationReporter;
|
|
765
890
|
}
|
|
891
|
+
/**
|
|
892
|
+
* AIP-12: Get the wallet provider instance.
|
|
893
|
+
*
|
|
894
|
+
* Only available in testnet/mainnet modes.
|
|
895
|
+
* Returns undefined in mock mode.
|
|
896
|
+
*
|
|
897
|
+
* Use this for advanced operations like checking wallet info,
|
|
898
|
+
* or sending custom batched transactions.
|
|
899
|
+
*/
|
|
900
|
+
getWalletProvider() {
|
|
901
|
+
return this.walletProvider;
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Non-blocking drift detection for AGIRAILS.md config.
|
|
905
|
+
* Checks if local AGIRAILS.md matches on-chain config hash.
|
|
906
|
+
* Logs warnings but never blocks agent operation.
|
|
907
|
+
* @internal
|
|
908
|
+
*/
|
|
909
|
+
async checkConfigDrift(config) {
|
|
910
|
+
try {
|
|
911
|
+
const { existsSync, readFileSync } = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
912
|
+
const { join } = await Promise.resolve().then(() => __importStar(require('path')));
|
|
913
|
+
// Look for AGIRAILS.md in cwd
|
|
914
|
+
const agirailsMdPath = join(process.cwd(), 'AGIRAILS.md');
|
|
915
|
+
if (!existsSync(agirailsMdPath)) {
|
|
916
|
+
return; // No local file — nothing to check
|
|
917
|
+
}
|
|
918
|
+
const network = config.mode === 'testnet' ? 'base-sepolia' : 'base-mainnet';
|
|
919
|
+
const networkConfig = (0, networks_1.getNetwork)(network);
|
|
920
|
+
if (!networkConfig.contracts.agentRegistry) {
|
|
921
|
+
return; // No registry on this network
|
|
922
|
+
}
|
|
923
|
+
const content = readFileSync(agirailsMdPath, 'utf-8');
|
|
924
|
+
const { computeConfigHash } = await Promise.resolve().then(() => __importStar(require('./config/agirailsmd')));
|
|
925
|
+
const { configHash: localHash } = computeConfigHash(content);
|
|
926
|
+
const { AgentRegistryClient } = await Promise.resolve().then(() => __importStar(require('./registry/AgentRegistryClient')));
|
|
927
|
+
const provider = new ethers_1.ethers.JsonRpcProvider(networkConfig.rpcUrl);
|
|
928
|
+
const registryClient = AgentRegistryClient.readOnly(networkConfig.contracts.agentRegistry, provider);
|
|
929
|
+
// Detect template vs published state from frontmatter
|
|
930
|
+
const { parseAgirailsMd: parseMd } = await Promise.resolve().then(() => __importStar(require('./config/agirailsmd')));
|
|
931
|
+
const { frontmatter } = parseMd(content);
|
|
932
|
+
const isTemplate = !frontmatter.config_hash;
|
|
933
|
+
const onChainState = await registryClient.getConfig(config.requesterAddress ?? this.info.address);
|
|
934
|
+
const ZERO_HASH = '0x' + '0'.repeat(64);
|
|
935
|
+
if (onChainState.configHash === ZERO_HASH) {
|
|
936
|
+
if (isTemplate) {
|
|
937
|
+
Logger_1.sdkLogger.info('[AGIRAILS] AGIRAILS.md loaded (template mode). Run "actp publish" to register and sync on-chain.');
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
Logger_1.sdkLogger.warn('[AGIRAILS] Config not published on-chain. Run: actp publish');
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
else if (onChainState.configHash !== localHash) {
|
|
944
|
+
Logger_1.sdkLogger.warn('[AGIRAILS] Local AGIRAILS.md differs from on-chain. Run: actp diff');
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
catch {
|
|
948
|
+
// Silently ignore — drift detection is best-effort
|
|
949
|
+
}
|
|
950
|
+
}
|
|
766
951
|
}
|
|
767
952
|
exports.ACTPClient = ACTPClient;
|
|
768
953
|
//# sourceMappingURL=ACTPClient.js.map
|