@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.
Files changed (172) hide show
  1. package/dist/ACTPClient.d.ts +18 -0
  2. package/dist/ACTPClient.d.ts.map +1 -1
  3. package/dist/ACTPClient.js +67 -22
  4. package/dist/ACTPClient.js.map +1 -1
  5. package/dist/adapters/BasicAdapter.d.ts +12 -0
  6. package/dist/adapters/BasicAdapter.d.ts.map +1 -1
  7. package/dist/adapters/BasicAdapter.js +30 -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 +45 -11
  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/cli/utils/client.d.ts.map +1 -1
  20. package/dist/cli/utils/client.js +1 -0
  21. package/dist/cli/utils/client.js.map +1 -1
  22. package/dist/config/networks.d.ts +2 -2
  23. package/dist/config/networks.d.ts.map +1 -1
  24. package/dist/config/networks.js +27 -22
  25. package/dist/config/networks.js.map +1 -1
  26. package/dist/level0/request.d.ts.map +1 -1
  27. package/dist/level0/request.js +2 -1
  28. package/dist/level0/request.js.map +1 -1
  29. package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
  30. package/dist/runtime/BlockchainRuntime.js +11 -5
  31. package/dist/runtime/BlockchainRuntime.js.map +1 -1
  32. package/dist/runtime/MockStateManager.d.ts.map +1 -1
  33. package/dist/runtime/MockStateManager.js +2 -1
  34. package/dist/runtime/MockStateManager.js.map +1 -1
  35. package/dist/utils/IPFSClient.d.ts +3 -1
  36. package/dist/utils/IPFSClient.d.ts.map +1 -1
  37. package/dist/utils/IPFSClient.js +27 -7
  38. package/dist/utils/IPFSClient.js.map +1 -1
  39. package/dist/wallet/AutoWalletProvider.d.ts.map +1 -1
  40. package/dist/wallet/AutoWalletProvider.js +52 -18
  41. package/dist/wallet/AutoWalletProvider.js.map +1 -1
  42. package/dist/wallet/SmartWalletRouter.d.ts +116 -0
  43. package/dist/wallet/SmartWalletRouter.d.ts.map +1 -0
  44. package/dist/wallet/SmartWalletRouter.js +212 -0
  45. package/dist/wallet/SmartWalletRouter.js.map +1 -0
  46. package/dist/wallet/aa/DualNonceManager.d.ts +19 -0
  47. package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -1
  48. package/dist/wallet/aa/DualNonceManager.js +100 -5
  49. package/dist/wallet/aa/DualNonceManager.js.map +1 -1
  50. package/package.json +3 -6
  51. package/src/ACTPClient.ts +0 -1579
  52. package/src/abi/ACTPKernel.json +0 -1356
  53. package/src/abi/AgentRegistry.json +0 -915
  54. package/src/abi/ERC20.json +0 -40
  55. package/src/abi/EscrowVault.json +0 -134
  56. package/src/abi/IdentityRegistry.json +0 -316
  57. package/src/adapters/AdapterRegistry.ts +0 -173
  58. package/src/adapters/AdapterRouter.ts +0 -416
  59. package/src/adapters/BaseAdapter.ts +0 -498
  60. package/src/adapters/BasicAdapter.ts +0 -514
  61. package/src/adapters/IAdapter.ts +0 -292
  62. package/src/adapters/StandardAdapter.ts +0 -555
  63. package/src/adapters/X402Adapter.ts +0 -731
  64. package/src/adapters/index.ts +0 -60
  65. package/src/builders/DeliveryProofBuilder.ts +0 -327
  66. package/src/builders/QuoteBuilder.ts +0 -483
  67. package/src/builders/index.ts +0 -17
  68. package/src/cli/commands/balance.ts +0 -110
  69. package/src/cli/commands/batch.ts +0 -487
  70. package/src/cli/commands/config.ts +0 -231
  71. package/src/cli/commands/deploy-check.ts +0 -364
  72. package/src/cli/commands/deploy-env.ts +0 -120
  73. package/src/cli/commands/diff.ts +0 -141
  74. package/src/cli/commands/init.ts +0 -469
  75. package/src/cli/commands/mint.ts +0 -116
  76. package/src/cli/commands/pay.ts +0 -113
  77. package/src/cli/commands/publish.ts +0 -475
  78. package/src/cli/commands/pull.ts +0 -124
  79. package/src/cli/commands/register.ts +0 -247
  80. package/src/cli/commands/simulate.ts +0 -345
  81. package/src/cli/commands/time.ts +0 -302
  82. package/src/cli/commands/tx.ts +0 -448
  83. package/src/cli/commands/watch.ts +0 -211
  84. package/src/cli/index.ts +0 -134
  85. package/src/cli/utils/client.ts +0 -251
  86. package/src/cli/utils/config.ts +0 -389
  87. package/src/cli/utils/output.ts +0 -465
  88. package/src/cli/utils/wallet.ts +0 -109
  89. package/src/config/agirailsmd.ts +0 -262
  90. package/src/config/networks.ts +0 -275
  91. package/src/config/pendingPublish.ts +0 -237
  92. package/src/config/publishPipeline.ts +0 -359
  93. package/src/config/syncOperations.ts +0 -279
  94. package/src/erc8004/ERC8004Bridge.ts +0 -462
  95. package/src/erc8004/ReputationReporter.ts +0 -468
  96. package/src/erc8004/index.ts +0 -61
  97. package/src/errors/index.ts +0 -427
  98. package/src/index.ts +0 -364
  99. package/src/level0/Provider.ts +0 -117
  100. package/src/level0/ServiceDirectory.ts +0 -131
  101. package/src/level0/index.ts +0 -10
  102. package/src/level0/provide.ts +0 -132
  103. package/src/level0/request.ts +0 -432
  104. package/src/level1/Agent.ts +0 -1426
  105. package/src/level1/index.ts +0 -10
  106. package/src/level1/pricing/PriceCalculator.ts +0 -255
  107. package/src/level1/pricing/PricingStrategy.ts +0 -198
  108. package/src/level1/types/Job.ts +0 -179
  109. package/src/level1/types/Options.ts +0 -291
  110. package/src/level1/types/index.ts +0 -8
  111. package/src/protocol/ACTPKernel.ts +0 -808
  112. package/src/protocol/AgentRegistry.ts +0 -559
  113. package/src/protocol/DIDManager.ts +0 -629
  114. package/src/protocol/DIDResolver.ts +0 -554
  115. package/src/protocol/EASHelper.ts +0 -378
  116. package/src/protocol/EscrowVault.ts +0 -255
  117. package/src/protocol/EventMonitor.ts +0 -204
  118. package/src/protocol/MessageSigner.ts +0 -510
  119. package/src/protocol/ProofGenerator.ts +0 -339
  120. package/src/protocol/QuoteBuilder.ts +0 -15
  121. package/src/registry/AgentRegistryClient.ts +0 -202
  122. package/src/runtime/BlockchainRuntime.ts +0 -1015
  123. package/src/runtime/IACTPRuntime.ts +0 -306
  124. package/src/runtime/MockRuntime.ts +0 -1298
  125. package/src/runtime/MockStateManager.ts +0 -576
  126. package/src/runtime/index.ts +0 -25
  127. package/src/runtime/types/MockState.ts +0 -237
  128. package/src/storage/ArchiveBundleBuilder.ts +0 -561
  129. package/src/storage/ArweaveClient.ts +0 -946
  130. package/src/storage/FilebaseClient.ts +0 -790
  131. package/src/storage/index.ts +0 -96
  132. package/src/storage/types.ts +0 -348
  133. package/src/types/adapter.ts +0 -310
  134. package/src/types/agent.ts +0 -79
  135. package/src/types/did.ts +0 -223
  136. package/src/types/eip712.ts +0 -175
  137. package/src/types/erc8004.ts +0 -293
  138. package/src/types/escrow.ts +0 -27
  139. package/src/types/index.ts +0 -17
  140. package/src/types/message.ts +0 -145
  141. package/src/types/state.ts +0 -87
  142. package/src/types/transaction.ts +0 -69
  143. package/src/types/x402.ts +0 -251
  144. package/src/utils/ErrorRecoveryGuide.ts +0 -676
  145. package/src/utils/Helpers.ts +0 -688
  146. package/src/utils/IPFSClient.ts +0 -368
  147. package/src/utils/Logger.ts +0 -484
  148. package/src/utils/NonceManager.ts +0 -591
  149. package/src/utils/RateLimiter.ts +0 -534
  150. package/src/utils/ReceivedNonceTracker.ts +0 -567
  151. package/src/utils/SDKLifecycle.ts +0 -416
  152. package/src/utils/SecureNonce.ts +0 -78
  153. package/src/utils/Semaphore.ts +0 -276
  154. package/src/utils/UsedAttestationTracker.ts +0 -385
  155. package/src/utils/canonicalJson.ts +0 -38
  156. package/src/utils/circuitBreaker.ts +0 -324
  157. package/src/utils/computeTypeHash.ts +0 -48
  158. package/src/utils/fsSafe.ts +0 -80
  159. package/src/utils/index.ts +0 -80
  160. package/src/utils/retry.ts +0 -364
  161. package/src/utils/security.ts +0 -418
  162. package/src/utils/validation.ts +0 -540
  163. package/src/wallet/AutoWalletProvider.ts +0 -299
  164. package/src/wallet/EOAWalletProvider.ts +0 -69
  165. package/src/wallet/IWalletProvider.ts +0 -135
  166. package/src/wallet/aa/BundlerClient.ts +0 -274
  167. package/src/wallet/aa/DualNonceManager.ts +0 -173
  168. package/src/wallet/aa/PaymasterClient.ts +0 -174
  169. package/src/wallet/aa/TransactionBatcher.ts +0 -353
  170. package/src/wallet/aa/UserOpBuilder.ts +0 -246
  171. package/src/wallet/aa/constants.ts +0 -60
  172. package/src/wallet/keystore.ts +0 -240
@@ -1,306 +0,0 @@
1
- /**
2
- * Runtime interface for ACTP protocol operations.
3
- *
4
- * Implemented by:
5
- * - MockRuntime (for local development and testing)
6
- * - BlockchainRuntime (future, for real blockchain)
7
- *
8
- * This abstraction allows adapters to work with any runtime implementation,
9
- * enabling seamless transition from mock mode to production blockchain mode.
10
- *
11
- * @module runtime/IACTPRuntime
12
- */
13
-
14
- import { MockTransaction, TransactionState } from './types/MockState';
15
-
16
- /**
17
- * Parameters for creating a new transaction.
18
- */
19
- export interface CreateTransactionParams {
20
- /** Provider's Ethereum address */
21
- provider: string;
22
- /** Requester's Ethereum address */
23
- requester: string;
24
- /** Transaction amount in USDC wei (string for BigNumber precision) */
25
- amount: string;
26
- /** Unix timestamp deadline for transaction acceptance */
27
- deadline: number;
28
- /** Dispute window duration in seconds (default: 172800 = 2 days) */
29
- disputeWindow?: number;
30
- /** Service description or metadata hash */
31
- serviceDescription?: string;
32
- /**
33
- * ERC-8004 agent ID (optional).
34
- * If set, enables reputation reporting after settlement.
35
- * Stored in transaction for later use by ReputationReporter.
36
- */
37
- agentId?: string;
38
- }
39
-
40
- /**
41
- * Runtime interface for ACTP protocol operations.
42
- *
43
- * Defines the contract that all runtime implementations must follow,
44
- * enabling adapters to work with both mock and real blockchain backends.
45
- *
46
- * @example
47
- * ```typescript
48
- * // Using with MockRuntime
49
- * const runtime: IACTPRuntime = new MockRuntime();
50
- *
51
- * // Using with BlockchainRuntime (future)
52
- * const runtime: IACTPRuntime = new BlockchainRuntime({
53
- * provider: ethersProvider,
54
- * kernelAddress: '0x...',
55
- * });
56
- *
57
- * // Adapters work with either implementation
58
- * const adapter = new BasicAdapter(runtime, requesterAddress);
59
- * ```
60
- */
61
- export interface IACTPRuntime {
62
- /**
63
- * Creates a new transaction.
64
- *
65
- * @param params - Transaction creation parameters
66
- * @returns Promise resolving to the transaction ID (bytes32 hex string)
67
- *
68
- * @throws {DeadlinePassedError} If deadline is in the past
69
- * @throws {InvalidAmountError} If amount is zero or negative
70
- *
71
- * @example
72
- * ```typescript
73
- * const txId = await runtime.createTransaction({
74
- * provider: '0xProvider',
75
- * requester: '0xRequester',
76
- * amount: '1000000', // 1 USDC
77
- * deadline: Math.floor(Date.now() / 1000) + 86400,
78
- * });
79
- * ```
80
- */
81
- createTransaction(params: CreateTransactionParams): Promise<string>;
82
-
83
- /**
84
- * Links an escrow to a transaction and locks funds.
85
- *
86
- * Automatically transitions INITIATED or QUOTED → COMMITTED (per ACTP spec).
87
- *
88
- * @param txId - Transaction ID
89
- * @param amount - Amount to lock (must match transaction amount)
90
- * @returns Promise resolving to the escrow ID
91
- *
92
- * @throws {TransactionNotFoundError} If transaction doesn't exist
93
- * @throws {InvalidStateTransitionError} If not in INITIATED or QUOTED state
94
- * @throws {InsufficientBalanceError} If requester has insufficient funds
95
- *
96
- * @example
97
- * ```typescript
98
- * const escrowId = await runtime.linkEscrow(txId, '1000000');
99
- * ```
100
- */
101
- linkEscrow(txId: string, amount: string): Promise<string>;
102
-
103
- /**
104
- * Transitions a transaction to a new state.
105
- *
106
- * Validates the transition against the ACTP 8-state machine.
107
- *
108
- * SECURITY FIX (PROOF-PARAM): Added optional proof parameter for DELIVERED state.
109
- * The kernel contract uses proof data for dispute window configuration and
110
- * delivery verification. Without proof, default dispute window applies.
111
- *
112
- * @param txId - Transaction ID
113
- * @param newState - Target state
114
- * @param proof - Optional proof data (required for DELIVERED, used for DISPUTED/SETTLED)
115
- *
116
- * @throws {TransactionNotFoundError} If transaction doesn't exist
117
- * @throws {InvalidStateTransitionError} If transition is not valid
118
- * @throws {DeadlinePassedError} If deadline passed (for CANCELLED transition)
119
- *
120
- * @example
121
- * ```typescript
122
- * // Simple transition
123
- * await runtime.transitionState(txId, 'DELIVERED');
124
- *
125
- * // With delivery proof
126
- * await runtime.transitionState(txId, 'DELIVERED', deliveryProofBytes);
127
- * ```
128
- */
129
- transitionState(txId: string, newState: TransactionState, proof?: string): Promise<void>;
130
-
131
- /**
132
- * Gets a transaction by ID.
133
- *
134
- * @param txId - Transaction ID
135
- * @returns Promise resolving to the transaction or null if not found
136
- *
137
- * @example
138
- * ```typescript
139
- * const tx = await runtime.getTransaction(txId);
140
- * if (tx) {
141
- * console.log('State:', tx.state);
142
- * }
143
- * ```
144
- */
145
- getTransaction(txId: string): Promise<MockTransaction | null>;
146
-
147
- /**
148
- * Gets all transactions.
149
- *
150
- * @returns Promise resolving to array of all transactions
151
- *
152
- * @example
153
- * ```typescript
154
- * const transactions = await runtime.getAllTransactions();
155
- * for (const tx of transactions) {
156
- * console.log(tx.id, tx.state);
157
- * }
158
- * ```
159
- */
160
- getAllTransactions(): Promise<MockTransaction[]>;
161
-
162
- /**
163
- * Releases escrow funds to the provider and settles the transaction.
164
- *
165
- * Can only be called when transaction is in DELIVERED state
166
- * and dispute window has expired.
167
- *
168
- * @param escrowId - Escrow ID
169
- *
170
- * @throws {EscrowNotFoundError} If escrow doesn't exist
171
- * @throws {TransactionNotFoundError} If linked transaction doesn't exist
172
- * @throws {InvalidStateTransitionError} If transaction not in DELIVERED state
173
- * @throws {DisputeWindowActiveError} If dispute window still active
174
- *
175
- * @example
176
- * ```typescript
177
- * await runtime.releaseEscrow(escrowId);
178
- * ```
179
- */
180
- releaseEscrow(escrowId: string, attestationUID?: string): Promise<void>;
181
-
182
- /**
183
- * Gets the balance of an escrow.
184
- *
185
- * @param escrowId - Escrow ID
186
- * @returns Promise resolving to the balance as string
187
- *
188
- * @throws {EscrowNotFoundError} If escrow doesn't exist
189
- *
190
- * @example
191
- * ```typescript
192
- * const balance = await runtime.getEscrowBalance(escrowId);
193
- * console.log('Escrow balance:', balance);
194
- * ```
195
- */
196
- getEscrowBalance(escrowId: string): Promise<string>;
197
-
198
- /**
199
- * Time management interface.
200
- *
201
- * Provides access to current blockchain time and time manipulation
202
- * (for testing in mock mode).
203
- */
204
- time: {
205
- /** Get current timestamp in seconds */
206
- now(): number;
207
- };
208
-
209
- /**
210
- * Maximum transaction amount in USDC (human-readable, e.g., 100 = $100).
211
- *
212
- * SECURITY: Limits exposure on unaudited contracts.
213
- * Returns undefined if no limit is enforced (testnet/mock mode).
214
- *
215
- * @example
216
- * ```typescript
217
- * const limit = runtime.maxTransactionAmount;
218
- * if (limit && amount > limit) {
219
- * throw new Error(`Amount exceeds limit of $${limit}`);
220
- * }
221
- * ```
222
- */
223
- maxTransactionAmount?: number;
224
- }
225
-
226
- /**
227
- * Extended runtime interface for mock mode.
228
- *
229
- * Includes testing utilities not available in production runtimes.
230
- * Only implemented by MockRuntime, not by blockchain runtimes.
231
- *
232
- * @example
233
- * ```typescript
234
- * // Type guard to check if runtime is MockRuntime
235
- * function isMockRuntime(runtime: IACTPRuntime): runtime is IMockRuntime {
236
- * return 'reset' in runtime;
237
- * }
238
- *
239
- * // Safe usage
240
- * if (isMockRuntime(client.runtime)) {
241
- * await client.runtime.reset();
242
- * client.runtime.time.advanceTime(3600);
243
- * }
244
- * ```
245
- */
246
- export interface IMockRuntime extends IACTPRuntime {
247
- /**
248
- * Reset state to default.
249
- *
250
- * Clears all transactions, escrows, balances, and events.
251
- * Only available in mock mode for testing.
252
- *
253
- * @example
254
- * ```typescript
255
- * await mockRuntime.reset();
256
- * ```
257
- */
258
- reset(): Promise<void>;
259
-
260
- /**
261
- * Mint tokens to an address.
262
- *
263
- * Only available in mock mode. Useful for funding test accounts.
264
- *
265
- * @param address - Address to mint tokens to
266
- * @param amount - Amount to mint in USDC wei
267
- *
268
- * @example
269
- * ```typescript
270
- * await mockRuntime.mintTokens('0x123...', '1000000000'); // 1000 USDC
271
- * ```
272
- */
273
- mintTokens(address: string, amount: string): Promise<void>;
274
-
275
- /**
276
- * Get balance of an address.
277
- *
278
- * @param address - Address to check
279
- * @returns Promise resolving to balance in USDC wei
280
- *
281
- * @example
282
- * ```typescript
283
- * const balance = await mockRuntime.getBalance('0x123...');
284
- * ```
285
- */
286
- getBalance(address: string): Promise<string>;
287
-
288
- /**
289
- * Extended time interface with manipulation methods.
290
- *
291
- * Provides time control for testing scenarios.
292
- *
293
- * SECURITY NOTE: All time-modifying methods are async and use
294
- * file locking to prevent race conditions in concurrent access.
295
- */
296
- time: {
297
- /** Get current timestamp in seconds */
298
- now(): number;
299
- /** Advance time by specified seconds (async for locking) */
300
- advanceTime(seconds: number): Promise<void>;
301
- /** Advance time by specified blocks (async for locking) */
302
- advanceBlocks(blocks: number): Promise<void>;
303
- /** Set exact timestamp (must be >= current time) (async for locking) */
304
- setTime(timestamp: number): Promise<void>;
305
- };
306
- }