@agirails/sdk 2.5.3 → 2.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/ACTPClient.d.ts +18 -0
  2. package/dist/ACTPClient.d.ts.map +1 -1
  3. package/dist/ACTPClient.js +72 -23
  4. package/dist/ACTPClient.js.map +1 -1
  5. package/dist/adapters/BasicAdapter.d.ts +15 -0
  6. package/dist/adapters/BasicAdapter.d.ts.map +1 -1
  7. package/dist/adapters/BasicAdapter.js +33 -4
  8. package/dist/adapters/BasicAdapter.js.map +1 -1
  9. package/dist/adapters/StandardAdapter.d.ts +20 -3
  10. package/dist/adapters/StandardAdapter.d.ts.map +1 -1
  11. package/dist/adapters/StandardAdapter.js +90 -12
  12. package/dist/adapters/StandardAdapter.js.map +1 -1
  13. package/dist/cli/commands/publish.js +16 -4
  14. package/dist/cli/commands/publish.js.map +1 -1
  15. package/dist/cli/commands/register.js +16 -4
  16. package/dist/cli/commands/register.js.map +1 -1
  17. package/dist/cli/commands/tx.js +31 -3
  18. package/dist/cli/commands/tx.js.map +1 -1
  19. package/dist/config/networks.d.ts +10 -2
  20. package/dist/config/networks.d.ts.map +1 -1
  21. package/dist/config/networks.js +31 -22
  22. package/dist/config/networks.js.map +1 -1
  23. package/dist/level0/request.d.ts.map +1 -1
  24. package/dist/level0/request.js +2 -1
  25. package/dist/level0/request.js.map +1 -1
  26. package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
  27. package/dist/runtime/BlockchainRuntime.js +11 -5
  28. package/dist/runtime/BlockchainRuntime.js.map +1 -1
  29. package/dist/utils/IPFSClient.d.ts +3 -1
  30. package/dist/utils/IPFSClient.d.ts.map +1 -1
  31. package/dist/utils/IPFSClient.js +27 -7
  32. package/dist/utils/IPFSClient.js.map +1 -1
  33. package/dist/wallet/AutoWalletProvider.d.ts +11 -1
  34. package/dist/wallet/AutoWalletProvider.d.ts.map +1 -1
  35. package/dist/wallet/AutoWalletProvider.js +84 -19
  36. package/dist/wallet/AutoWalletProvider.js.map +1 -1
  37. package/dist/wallet/IWalletProvider.d.ts +34 -0
  38. package/dist/wallet/IWalletProvider.d.ts.map +1 -1
  39. package/dist/wallet/SmartWalletRouter.d.ts +128 -0
  40. package/dist/wallet/SmartWalletRouter.d.ts.map +1 -0
  41. package/dist/wallet/SmartWalletRouter.js +248 -0
  42. package/dist/wallet/SmartWalletRouter.js.map +1 -0
  43. package/dist/wallet/aa/DualNonceManager.d.ts +26 -1
  44. package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -1
  45. package/dist/wallet/aa/DualNonceManager.js +140 -6
  46. package/dist/wallet/aa/DualNonceManager.js.map +1 -1
  47. package/package.json +3 -6
  48. package/src/ACTPClient.ts +0 -1579
  49. package/src/abi/ACTPKernel.json +0 -1356
  50. package/src/abi/AgentRegistry.json +0 -915
  51. package/src/abi/ERC20.json +0 -40
  52. package/src/abi/EscrowVault.json +0 -134
  53. package/src/abi/IdentityRegistry.json +0 -316
  54. package/src/adapters/AdapterRegistry.ts +0 -173
  55. package/src/adapters/AdapterRouter.ts +0 -416
  56. package/src/adapters/BaseAdapter.ts +0 -498
  57. package/src/adapters/BasicAdapter.ts +0 -514
  58. package/src/adapters/IAdapter.ts +0 -292
  59. package/src/adapters/StandardAdapter.ts +0 -555
  60. package/src/adapters/X402Adapter.ts +0 -731
  61. package/src/adapters/index.ts +0 -60
  62. package/src/builders/DeliveryProofBuilder.ts +0 -327
  63. package/src/builders/QuoteBuilder.ts +0 -483
  64. package/src/builders/index.ts +0 -17
  65. package/src/cli/commands/balance.ts +0 -110
  66. package/src/cli/commands/batch.ts +0 -487
  67. package/src/cli/commands/config.ts +0 -231
  68. package/src/cli/commands/deploy-check.ts +0 -364
  69. package/src/cli/commands/deploy-env.ts +0 -120
  70. package/src/cli/commands/diff.ts +0 -141
  71. package/src/cli/commands/init.ts +0 -469
  72. package/src/cli/commands/mint.ts +0 -116
  73. package/src/cli/commands/pay.ts +0 -113
  74. package/src/cli/commands/publish.ts +0 -475
  75. package/src/cli/commands/pull.ts +0 -124
  76. package/src/cli/commands/register.ts +0 -247
  77. package/src/cli/commands/simulate.ts +0 -345
  78. package/src/cli/commands/time.ts +0 -302
  79. package/src/cli/commands/tx.ts +0 -448
  80. package/src/cli/commands/watch.ts +0 -211
  81. package/src/cli/index.ts +0 -134
  82. package/src/cli/utils/client.ts +0 -252
  83. package/src/cli/utils/config.ts +0 -389
  84. package/src/cli/utils/output.ts +0 -465
  85. package/src/cli/utils/wallet.ts +0 -109
  86. package/src/config/agirailsmd.ts +0 -262
  87. package/src/config/networks.ts +0 -275
  88. package/src/config/pendingPublish.ts +0 -237
  89. package/src/config/publishPipeline.ts +0 -359
  90. package/src/config/syncOperations.ts +0 -279
  91. package/src/erc8004/ERC8004Bridge.ts +0 -462
  92. package/src/erc8004/ReputationReporter.ts +0 -468
  93. package/src/erc8004/index.ts +0 -61
  94. package/src/errors/index.ts +0 -427
  95. package/src/index.ts +0 -364
  96. package/src/level0/Provider.ts +0 -117
  97. package/src/level0/ServiceDirectory.ts +0 -131
  98. package/src/level0/index.ts +0 -10
  99. package/src/level0/provide.ts +0 -132
  100. package/src/level0/request.ts +0 -432
  101. package/src/level1/Agent.ts +0 -1426
  102. package/src/level1/index.ts +0 -10
  103. package/src/level1/pricing/PriceCalculator.ts +0 -255
  104. package/src/level1/pricing/PricingStrategy.ts +0 -198
  105. package/src/level1/types/Job.ts +0 -179
  106. package/src/level1/types/Options.ts +0 -291
  107. package/src/level1/types/index.ts +0 -8
  108. package/src/protocol/ACTPKernel.ts +0 -808
  109. package/src/protocol/AgentRegistry.ts +0 -559
  110. package/src/protocol/DIDManager.ts +0 -629
  111. package/src/protocol/DIDResolver.ts +0 -554
  112. package/src/protocol/EASHelper.ts +0 -378
  113. package/src/protocol/EscrowVault.ts +0 -255
  114. package/src/protocol/EventMonitor.ts +0 -204
  115. package/src/protocol/MessageSigner.ts +0 -510
  116. package/src/protocol/ProofGenerator.ts +0 -339
  117. package/src/protocol/QuoteBuilder.ts +0 -15
  118. package/src/registry/AgentRegistryClient.ts +0 -202
  119. package/src/runtime/BlockchainRuntime.ts +0 -1015
  120. package/src/runtime/IACTPRuntime.ts +0 -306
  121. package/src/runtime/MockRuntime.ts +0 -1298
  122. package/src/runtime/MockStateManager.ts +0 -577
  123. package/src/runtime/index.ts +0 -25
  124. package/src/runtime/types/MockState.ts +0 -237
  125. package/src/storage/ArchiveBundleBuilder.ts +0 -561
  126. package/src/storage/ArweaveClient.ts +0 -946
  127. package/src/storage/FilebaseClient.ts +0 -790
  128. package/src/storage/index.ts +0 -96
  129. package/src/storage/types.ts +0 -348
  130. package/src/types/adapter.ts +0 -310
  131. package/src/types/agent.ts +0 -79
  132. package/src/types/did.ts +0 -223
  133. package/src/types/eip712.ts +0 -175
  134. package/src/types/erc8004.ts +0 -293
  135. package/src/types/escrow.ts +0 -27
  136. package/src/types/index.ts +0 -17
  137. package/src/types/message.ts +0 -145
  138. package/src/types/state.ts +0 -87
  139. package/src/types/transaction.ts +0 -69
  140. package/src/types/x402.ts +0 -251
  141. package/src/utils/ErrorRecoveryGuide.ts +0 -676
  142. package/src/utils/Helpers.ts +0 -688
  143. package/src/utils/IPFSClient.ts +0 -368
  144. package/src/utils/Logger.ts +0 -484
  145. package/src/utils/NonceManager.ts +0 -591
  146. package/src/utils/RateLimiter.ts +0 -534
  147. package/src/utils/ReceivedNonceTracker.ts +0 -567
  148. package/src/utils/SDKLifecycle.ts +0 -416
  149. package/src/utils/SecureNonce.ts +0 -78
  150. package/src/utils/Semaphore.ts +0 -276
  151. package/src/utils/UsedAttestationTracker.ts +0 -385
  152. package/src/utils/canonicalJson.ts +0 -38
  153. package/src/utils/circuitBreaker.ts +0 -324
  154. package/src/utils/computeTypeHash.ts +0 -48
  155. package/src/utils/fsSafe.ts +0 -80
  156. package/src/utils/index.ts +0 -80
  157. package/src/utils/retry.ts +0 -364
  158. package/src/utils/security.ts +0 -418
  159. package/src/utils/validation.ts +0 -540
  160. package/src/wallet/AutoWalletProvider.ts +0 -299
  161. package/src/wallet/EOAWalletProvider.ts +0 -69
  162. package/src/wallet/IWalletProvider.ts +0 -135
  163. package/src/wallet/aa/BundlerClient.ts +0 -274
  164. package/src/wallet/aa/DualNonceManager.ts +0 -173
  165. package/src/wallet/aa/PaymasterClient.ts +0 -174
  166. package/src/wallet/aa/TransactionBatcher.ts +0 -353
  167. package/src/wallet/aa/UserOpBuilder.ts +0 -246
  168. package/src/wallet/aa/constants.ts +0 -60
  169. package/src/wallet/keystore.ts +0 -240
@@ -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
- }