@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,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
- }