@agirails/sdk 2.5.2 → 2.5.4
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/dist/ACTPClient.d.ts +18 -0
- package/dist/ACTPClient.d.ts.map +1 -1
- package/dist/ACTPClient.js +67 -22
- package/dist/ACTPClient.js.map +1 -1
- package/dist/adapters/BasicAdapter.d.ts +12 -0
- package/dist/adapters/BasicAdapter.d.ts.map +1 -1
- package/dist/adapters/BasicAdapter.js +30 -4
- package/dist/adapters/BasicAdapter.js.map +1 -1
- package/dist/adapters/StandardAdapter.d.ts +20 -3
- package/dist/adapters/StandardAdapter.d.ts.map +1 -1
- package/dist/adapters/StandardAdapter.js +45 -11
- package/dist/adapters/StandardAdapter.js.map +1 -1
- package/dist/cli/commands/publish.js +16 -4
- package/dist/cli/commands/publish.js.map +1 -1
- package/dist/cli/commands/register.js +16 -4
- package/dist/cli/commands/register.js.map +1 -1
- package/dist/cli/commands/tx.js +31 -3
- package/dist/cli/commands/tx.js.map +1 -1
- package/dist/cli/utils/client.d.ts.map +1 -1
- package/dist/cli/utils/client.js +1 -0
- package/dist/cli/utils/client.js.map +1 -1
- package/dist/config/networks.d.ts +2 -2
- package/dist/config/networks.d.ts.map +1 -1
- package/dist/config/networks.js +27 -22
- package/dist/config/networks.js.map +1 -1
- package/dist/level0/request.d.ts.map +1 -1
- package/dist/level0/request.js +2 -1
- package/dist/level0/request.js.map +1 -1
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
- package/dist/runtime/BlockchainRuntime.js +11 -5
- package/dist/runtime/BlockchainRuntime.js.map +1 -1
- package/dist/runtime/MockStateManager.d.ts.map +1 -1
- package/dist/runtime/MockStateManager.js +2 -1
- package/dist/runtime/MockStateManager.js.map +1 -1
- package/dist/utils/IPFSClient.d.ts +3 -1
- package/dist/utils/IPFSClient.d.ts.map +1 -1
- package/dist/utils/IPFSClient.js +27 -7
- package/dist/utils/IPFSClient.js.map +1 -1
- package/dist/wallet/AutoWalletProvider.d.ts.map +1 -1
- package/dist/wallet/AutoWalletProvider.js +52 -18
- package/dist/wallet/AutoWalletProvider.js.map +1 -1
- package/dist/wallet/SmartWalletRouter.d.ts +116 -0
- package/dist/wallet/SmartWalletRouter.d.ts.map +1 -0
- package/dist/wallet/SmartWalletRouter.js +212 -0
- package/dist/wallet/SmartWalletRouter.js.map +1 -0
- package/dist/wallet/aa/DualNonceManager.d.ts +19 -0
- package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -1
- package/dist/wallet/aa/DualNonceManager.js +100 -5
- package/dist/wallet/aa/DualNonceManager.js.map +1 -1
- package/package.json +3 -6
- package/src/ACTPClient.ts +0 -1579
- package/src/abi/ACTPKernel.json +0 -1356
- package/src/abi/AgentRegistry.json +0 -915
- package/src/abi/ERC20.json +0 -40
- package/src/abi/EscrowVault.json +0 -134
- package/src/abi/IdentityRegistry.json +0 -316
- package/src/adapters/AdapterRegistry.ts +0 -173
- package/src/adapters/AdapterRouter.ts +0 -416
- package/src/adapters/BaseAdapter.ts +0 -498
- package/src/adapters/BasicAdapter.ts +0 -514
- package/src/adapters/IAdapter.ts +0 -292
- package/src/adapters/StandardAdapter.ts +0 -555
- package/src/adapters/X402Adapter.ts +0 -731
- package/src/adapters/index.ts +0 -60
- package/src/builders/DeliveryProofBuilder.ts +0 -327
- package/src/builders/QuoteBuilder.ts +0 -483
- package/src/builders/index.ts +0 -17
- package/src/cli/commands/balance.ts +0 -110
- package/src/cli/commands/batch.ts +0 -487
- package/src/cli/commands/config.ts +0 -231
- package/src/cli/commands/deploy-check.ts +0 -364
- package/src/cli/commands/deploy-env.ts +0 -120
- package/src/cli/commands/diff.ts +0 -141
- package/src/cli/commands/init.ts +0 -469
- package/src/cli/commands/mint.ts +0 -116
- package/src/cli/commands/pay.ts +0 -113
- package/src/cli/commands/publish.ts +0 -475
- package/src/cli/commands/pull.ts +0 -124
- package/src/cli/commands/register.ts +0 -247
- package/src/cli/commands/simulate.ts +0 -345
- package/src/cli/commands/time.ts +0 -302
- package/src/cli/commands/tx.ts +0 -448
- package/src/cli/commands/watch.ts +0 -211
- package/src/cli/index.ts +0 -134
- package/src/cli/utils/client.ts +0 -251
- package/src/cli/utils/config.ts +0 -389
- package/src/cli/utils/output.ts +0 -465
- package/src/cli/utils/wallet.ts +0 -109
- package/src/config/agirailsmd.ts +0 -262
- package/src/config/networks.ts +0 -275
- package/src/config/pendingPublish.ts +0 -237
- package/src/config/publishPipeline.ts +0 -359
- package/src/config/syncOperations.ts +0 -279
- package/src/erc8004/ERC8004Bridge.ts +0 -462
- package/src/erc8004/ReputationReporter.ts +0 -468
- package/src/erc8004/index.ts +0 -61
- package/src/errors/index.ts +0 -427
- package/src/index.ts +0 -364
- package/src/level0/Provider.ts +0 -117
- package/src/level0/ServiceDirectory.ts +0 -131
- package/src/level0/index.ts +0 -10
- package/src/level0/provide.ts +0 -132
- package/src/level0/request.ts +0 -432
- package/src/level1/Agent.ts +0 -1426
- package/src/level1/index.ts +0 -10
- package/src/level1/pricing/PriceCalculator.ts +0 -255
- package/src/level1/pricing/PricingStrategy.ts +0 -198
- package/src/level1/types/Job.ts +0 -179
- package/src/level1/types/Options.ts +0 -291
- package/src/level1/types/index.ts +0 -8
- package/src/protocol/ACTPKernel.ts +0 -808
- package/src/protocol/AgentRegistry.ts +0 -559
- package/src/protocol/DIDManager.ts +0 -629
- package/src/protocol/DIDResolver.ts +0 -554
- package/src/protocol/EASHelper.ts +0 -378
- package/src/protocol/EscrowVault.ts +0 -255
- package/src/protocol/EventMonitor.ts +0 -204
- package/src/protocol/MessageSigner.ts +0 -510
- package/src/protocol/ProofGenerator.ts +0 -339
- package/src/protocol/QuoteBuilder.ts +0 -15
- package/src/registry/AgentRegistryClient.ts +0 -202
- package/src/runtime/BlockchainRuntime.ts +0 -1015
- package/src/runtime/IACTPRuntime.ts +0 -306
- package/src/runtime/MockRuntime.ts +0 -1298
- package/src/runtime/MockStateManager.ts +0 -576
- package/src/runtime/index.ts +0 -25
- package/src/runtime/types/MockState.ts +0 -237
- package/src/storage/ArchiveBundleBuilder.ts +0 -561
- package/src/storage/ArweaveClient.ts +0 -946
- package/src/storage/FilebaseClient.ts +0 -790
- package/src/storage/index.ts +0 -96
- package/src/storage/types.ts +0 -348
- package/src/types/adapter.ts +0 -310
- package/src/types/agent.ts +0 -79
- package/src/types/did.ts +0 -223
- package/src/types/eip712.ts +0 -175
- package/src/types/erc8004.ts +0 -293
- package/src/types/escrow.ts +0 -27
- package/src/types/index.ts +0 -17
- package/src/types/message.ts +0 -145
- package/src/types/state.ts +0 -87
- package/src/types/transaction.ts +0 -69
- package/src/types/x402.ts +0 -251
- package/src/utils/ErrorRecoveryGuide.ts +0 -676
- package/src/utils/Helpers.ts +0 -688
- package/src/utils/IPFSClient.ts +0 -368
- package/src/utils/Logger.ts +0 -484
- package/src/utils/NonceManager.ts +0 -591
- package/src/utils/RateLimiter.ts +0 -534
- package/src/utils/ReceivedNonceTracker.ts +0 -567
- package/src/utils/SDKLifecycle.ts +0 -416
- package/src/utils/SecureNonce.ts +0 -78
- package/src/utils/Semaphore.ts +0 -276
- package/src/utils/UsedAttestationTracker.ts +0 -385
- package/src/utils/canonicalJson.ts +0 -38
- package/src/utils/circuitBreaker.ts +0 -324
- package/src/utils/computeTypeHash.ts +0 -48
- package/src/utils/fsSafe.ts +0 -80
- package/src/utils/index.ts +0 -80
- package/src/utils/retry.ts +0 -364
- package/src/utils/security.ts +0 -418
- package/src/utils/validation.ts +0 -540
- package/src/wallet/AutoWalletProvider.ts +0 -299
- package/src/wallet/EOAWalletProvider.ts +0 -69
- package/src/wallet/IWalletProvider.ts +0 -135
- package/src/wallet/aa/BundlerClient.ts +0 -274
- package/src/wallet/aa/DualNonceManager.ts +0 -173
- package/src/wallet/aa/PaymasterClient.ts +0 -174
- package/src/wallet/aa/TransactionBatcher.ts +0 -353
- package/src/wallet/aa/UserOpBuilder.ts +0 -246
- package/src/wallet/aa/constants.ts +0 -60
- package/src/wallet/keystore.ts +0 -240
package/src/adapters/IAdapter.ts
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IAdapter - Common interface for all payment adapters.
|
|
3
|
-
*
|
|
4
|
-
* This interface defines the contract that all payment adapters must implement,
|
|
5
|
-
* enabling the AdapterRouter to select and use any adapter interchangeably.
|
|
6
|
-
*
|
|
7
|
-
* CRITICAL ACTP COMPLIANCE:
|
|
8
|
-
* - pay() creates transaction + locks escrow -> state = COMMITTED
|
|
9
|
-
* - Caller must transition to IN_PROGRESS before work
|
|
10
|
-
* - Caller must transition to DELIVERED with proof after work
|
|
11
|
-
* - Caller must call release() to settle (NO auto-settle)
|
|
12
|
-
*
|
|
13
|
-
* @module adapters/IAdapter
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
AdapterMetadata,
|
|
18
|
-
UnifiedPayParams,
|
|
19
|
-
UnifiedPayResult,
|
|
20
|
-
} from '../types/adapter';
|
|
21
|
-
|
|
22
|
-
// ============================================================================
|
|
23
|
-
// TransactionStatus - Adapter-agnostic status
|
|
24
|
-
// ============================================================================
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Valid transaction states across all adapters.
|
|
28
|
-
*/
|
|
29
|
-
export type AdapterTransactionState =
|
|
30
|
-
| 'INITIATED'
|
|
31
|
-
| 'COMMITTED'
|
|
32
|
-
| 'IN_PROGRESS'
|
|
33
|
-
| 'DELIVERED'
|
|
34
|
-
| 'SETTLED'
|
|
35
|
-
| 'DISPUTED'
|
|
36
|
-
| 'CANCELLED';
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Transaction status returned by getStatus().
|
|
40
|
-
*
|
|
41
|
-
* Provides a consistent view of transaction state across different
|
|
42
|
-
* adapter implementations with action hints for what can be done next.
|
|
43
|
-
*/
|
|
44
|
-
export interface TransactionStatus {
|
|
45
|
-
/** Current transaction state */
|
|
46
|
-
state: AdapterTransactionState;
|
|
47
|
-
|
|
48
|
-
/** Can provider start work? (COMMITTED -> IN_PROGRESS) */
|
|
49
|
-
canStartWork: boolean;
|
|
50
|
-
|
|
51
|
-
/** Can provider mark as delivered? (IN_PROGRESS -> DELIVERED) */
|
|
52
|
-
canDeliver: boolean;
|
|
53
|
-
|
|
54
|
-
/** Can escrow be released? (DELIVERED + dispute window expired) */
|
|
55
|
-
canRelease: boolean;
|
|
56
|
-
|
|
57
|
-
/** Can requester dispute? (DELIVERED, within dispute window) */
|
|
58
|
-
canDispute: boolean;
|
|
59
|
-
|
|
60
|
-
/** Transaction amount (formatted string) */
|
|
61
|
-
amount: string;
|
|
62
|
-
|
|
63
|
-
/** Deadline as ISO 8601 string (optional) */
|
|
64
|
-
deadline?: string;
|
|
65
|
-
|
|
66
|
-
/** Dispute window end as ISO 8601 string (optional) */
|
|
67
|
-
disputeWindowEnds?: string;
|
|
68
|
-
|
|
69
|
-
/** Provider address */
|
|
70
|
-
provider: string;
|
|
71
|
-
|
|
72
|
-
/** Requester address */
|
|
73
|
-
requester: string;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ============================================================================
|
|
77
|
-
// IAdapter Interface
|
|
78
|
-
// ============================================================================
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Common interface for all payment adapters.
|
|
82
|
-
*
|
|
83
|
-
* Implementations include:
|
|
84
|
-
* - BasicAdapter: High-level, opinionated API
|
|
85
|
-
* - StandardAdapter: Balanced control API
|
|
86
|
-
* - X402Adapter: HTTP 402 Payment Required protocol (Phase 1 Step 2)
|
|
87
|
-
* - ERC8004Adapter: Identity-based payments (Phase 1 Step 3)
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* class CustomAdapter implements IAdapter {
|
|
92
|
-
* readonly metadata: AdapterMetadata = {
|
|
93
|
-
* id: 'custom',
|
|
94
|
-
* name: 'Custom Adapter',
|
|
95
|
-
* usesEscrow: true,
|
|
96
|
-
* supportsDisputes: true,
|
|
97
|
-
* requiresIdentity: false,
|
|
98
|
-
* settlementMode: 'explicit',
|
|
99
|
-
* priority: 50,
|
|
100
|
-
* };
|
|
101
|
-
*
|
|
102
|
-
* async pay(params: UnifiedPayParams): Promise<UnifiedPayResult> {
|
|
103
|
-
* // Implementation...
|
|
104
|
-
* }
|
|
105
|
-
*
|
|
106
|
-
* canHandle(params: UnifiedPayParams): boolean {
|
|
107
|
-
* return true; // Can handle all params
|
|
108
|
-
* }
|
|
109
|
-
*
|
|
110
|
-
* validate(params: UnifiedPayParams): void {
|
|
111
|
-
* // Throw if invalid
|
|
112
|
-
* }
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
export interface IAdapter {
|
|
117
|
-
/**
|
|
118
|
-
* Adapter metadata describing capabilities.
|
|
119
|
-
*
|
|
120
|
-
* Used by AdapterRouter for selection and by developers
|
|
121
|
-
* to understand adapter behavior.
|
|
122
|
-
*/
|
|
123
|
-
readonly metadata: AdapterMetadata;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Execute payment through this adapter.
|
|
127
|
-
*
|
|
128
|
-
* IMPORTANT: Returns with state=COMMITTED, NOT settled.
|
|
129
|
-
* Caller must follow ACTP lifecycle:
|
|
130
|
-
* 1. pay() -> COMMITTED
|
|
131
|
-
* 2. startWork() -> IN_PROGRESS
|
|
132
|
-
* 3. deliver() -> DELIVERED
|
|
133
|
-
* 4. release() -> SETTLED (explicit!)
|
|
134
|
-
*
|
|
135
|
-
* @param params - Unified payment parameters
|
|
136
|
-
* @returns Promise resolving to payment result
|
|
137
|
-
* @throws {ValidationError} If params are invalid
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* const result = await adapter.pay({
|
|
142
|
-
* to: '0xProvider...',
|
|
143
|
-
* amount: '100',
|
|
144
|
-
* deadline: '+24h',
|
|
145
|
-
* });
|
|
146
|
-
* console.log(result.state); // 'COMMITTED'
|
|
147
|
-
* console.log(result.releaseRequired); // true
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
pay(params: UnifiedPayParams): Promise<UnifiedPayResult>;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Check if this adapter can handle the given parameters.
|
|
154
|
-
*
|
|
155
|
-
* Used by AdapterRouter to filter adapters that are capable
|
|
156
|
-
* of processing a specific payment request.
|
|
157
|
-
*
|
|
158
|
-
* @param params - Payment parameters to check
|
|
159
|
-
* @returns True if adapter can handle these params
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```typescript
|
|
163
|
-
* if (adapter.canHandle({ to: 'https://api.example.com', amount: '10' })) {
|
|
164
|
-
* // This adapter supports HTTP endpoints
|
|
165
|
-
* }
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
canHandle(params: UnifiedPayParams): boolean;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Validate parameters before execution.
|
|
172
|
-
*
|
|
173
|
-
* Called by AdapterRouter before routing to ensure
|
|
174
|
-
* parameters are valid for this specific adapter.
|
|
175
|
-
*
|
|
176
|
-
* @param params - Parameters to validate
|
|
177
|
-
* @throws {ValidationError} If params are invalid
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* try {
|
|
182
|
-
* adapter.validate(params);
|
|
183
|
-
* } catch (error) {
|
|
184
|
-
* console.error('Invalid params:', error.message);
|
|
185
|
-
* }
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
validate(params: UnifiedPayParams): void;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Get transaction status by ID.
|
|
192
|
-
*
|
|
193
|
-
* Returns current state plus action hints indicating
|
|
194
|
-
* what operations are available.
|
|
195
|
-
*
|
|
196
|
-
* @param txId - Transaction ID
|
|
197
|
-
* @returns Promise resolving to transaction status
|
|
198
|
-
* @throws {Error} If transaction not found
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ```typescript
|
|
202
|
-
* const status = await adapter.getStatus(txId);
|
|
203
|
-
* if (status.canRelease) {
|
|
204
|
-
* await adapter.release(escrowId);
|
|
205
|
-
* }
|
|
206
|
-
* ```
|
|
207
|
-
*/
|
|
208
|
-
getStatus(txId: string): Promise<TransactionStatus>;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Transition to IN_PROGRESS state (provider starts work).
|
|
212
|
-
*
|
|
213
|
-
* Must be called by provider after accepting the transaction.
|
|
214
|
-
* ACTP requires this explicit transition.
|
|
215
|
-
*
|
|
216
|
-
* @param txId - Transaction ID
|
|
217
|
-
* @throws {Error} If transaction not found or wrong state
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* ```typescript
|
|
221
|
-
* // Provider acknowledges and starts work
|
|
222
|
-
* await adapter.startWork(txId);
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
225
|
-
startWork(txId: string): Promise<void>;
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Transition to DELIVERED state (provider completes work).
|
|
229
|
-
*
|
|
230
|
-
* @param txId - Transaction ID
|
|
231
|
-
* @param proof - Delivery proof (ABI-encoded dispute window)
|
|
232
|
-
* @throws {Error} If transaction not found or wrong state
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* ```typescript
|
|
236
|
-
* // Provider marks work as delivered with 2-hour dispute window
|
|
237
|
-
* const proof = ethers.AbiCoder.defaultAbiCoder().encode(['uint256'], [7200]);
|
|
238
|
-
* await adapter.deliver(txId, proof);
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
deliver(txId: string, proof: string): Promise<void>;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Release escrow funds (EXPLICIT settlement).
|
|
245
|
-
*
|
|
246
|
-
* MUST be called after dispute window expires or requester approves.
|
|
247
|
-
* This is the ONLY way to settle - NO auto-settle.
|
|
248
|
-
*
|
|
249
|
-
* @param escrowId - Escrow ID (usually same as txId)
|
|
250
|
-
* @param attestationUID - Optional attestation UID for verification
|
|
251
|
-
* @throws {Error} If escrow not found or dispute window active
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```typescript
|
|
255
|
-
* // After dispute window expires
|
|
256
|
-
* await adapter.release(result.escrowId);
|
|
257
|
-
* // Transaction is now SETTLED
|
|
258
|
-
* ```
|
|
259
|
-
*/
|
|
260
|
-
release(escrowId: string, attestationUID?: string): Promise<void>;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// ============================================================================
|
|
264
|
-
// Type Guards
|
|
265
|
-
// ============================================================================
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Type guard to check if an object implements IAdapter.
|
|
269
|
-
*
|
|
270
|
-
* @param obj - Object to check
|
|
271
|
-
* @returns True if object implements IAdapter
|
|
272
|
-
*/
|
|
273
|
-
export function isAdapter(obj: unknown): obj is IAdapter {
|
|
274
|
-
if (!obj || typeof obj !== 'object') {
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const adapter = obj as Partial<IAdapter>;
|
|
279
|
-
|
|
280
|
-
return (
|
|
281
|
-
typeof adapter.metadata === 'object' &&
|
|
282
|
-
adapter.metadata !== null &&
|
|
283
|
-
typeof adapter.metadata.id === 'string' &&
|
|
284
|
-
typeof adapter.pay === 'function' &&
|
|
285
|
-
typeof adapter.canHandle === 'function' &&
|
|
286
|
-
typeof adapter.validate === 'function' &&
|
|
287
|
-
typeof adapter.getStatus === 'function' &&
|
|
288
|
-
typeof adapter.startWork === 'function' &&
|
|
289
|
-
typeof adapter.deliver === 'function' &&
|
|
290
|
-
typeof adapter.release === 'function'
|
|
291
|
-
);
|
|
292
|
-
}
|