@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,96 +0,0 @@
1
- /**
2
- * Storage Module - Hybrid Storage Architecture (AIP-7 §4)
3
- *
4
- * Two-tier storage model:
5
- * - Tier 1: IPFS (Filebase) for hot storage
6
- * - Tier 2: Arweave (Irys) for permanent archive
7
- *
8
- * @module storage
9
- *
10
- * @example
11
- * ```typescript
12
- * import {
13
- * FilebaseClient,
14
- * ArweaveClient,
15
- * ArchiveBundleBuilder
16
- * } from '@agirails/sdk/storage';
17
- *
18
- * // IPFS hot storage
19
- * const ipfs = new FilebaseClient({
20
- * accessKey: process.env.FILEBASE_ACCESS_KEY!,
21
- * secretKey: process.env.FILEBASE_SECRET_KEY!
22
- * });
23
- *
24
- * // Arweave permanent storage
25
- * const arweave = await ArweaveClient.create({
26
- * privateKey: process.env.ARCHIVE_KEY!,
27
- * rpcUrl: process.env.BASE_RPC!
28
- * });
29
- *
30
- * // Build archive bundle
31
- * const bundle = new ArchiveBundleBuilder()
32
- * .setTransactionId(txId)
33
- * .setChainId(8453)
34
- * // ... other fields
35
- * .build();
36
- *
37
- * // Upload to Arweave
38
- * const result = await arweave.uploadBundle(bundle);
39
- * console.log('Archived at:', result.txId);
40
- * ```
41
- */
42
-
43
- // ============================================================================
44
- // Clients
45
- // ============================================================================
46
-
47
- export { FilebaseClient } from './FilebaseClient';
48
- export { ArweaveClient } from './ArweaveClient';
49
-
50
- // ============================================================================
51
- // Builders
52
- // ============================================================================
53
-
54
- export {
55
- ArchiveBundleBuilder,
56
- computeContentHash,
57
- validateArchiveBundle
58
- } from './ArchiveBundleBuilder';
59
-
60
- // ============================================================================
61
- // Types
62
- // ============================================================================
63
-
64
- export type {
65
- // Filebase
66
- FilebaseConfig,
67
-
68
- // Arweave
69
- ArweaveConfig,
70
- IrysCurrency,
71
- IrysNetwork,
72
-
73
- // Archive Bundle
74
- ArchiveBundle,
75
- ArchiveChainId,
76
- ArchiveFinalState,
77
- ArchiveParticipants,
78
- ArchiveReferences,
79
- ArchiveHashes,
80
- ArchiveSignatures,
81
- ArchiveAttestation,
82
- ArchiveSettlement,
83
- EscrowRelease,
84
- ArchiveTags,
85
-
86
- // Results
87
- IPFSUploadResult,
88
- ArweaveUploadResult,
89
- DownloadResult
90
- } from './types';
91
-
92
- // ============================================================================
93
- // Constants
94
- // ============================================================================
95
-
96
- export { ARCHIVE_BUNDLE_TYPE } from './types';
@@ -1,348 +0,0 @@
1
- /**
2
- * Storage Types (AIP-7 §4)
3
- *
4
- * Type definitions for the AGIRAILS hybrid storage architecture:
5
- * - Tier 1: IPFS (Filebase) for hot storage
6
- * - Tier 2: Arweave (Irys) for permanent archive
7
- */
8
-
9
- // ============================================================================
10
- // Filebase Configuration
11
- // ============================================================================
12
-
13
- /**
14
- * Configuration for Filebase S3-compatible IPFS client
15
- */
16
- export interface FilebaseConfig {
17
- /**
18
- * Filebase access key ID
19
- * Get from: https://console.filebase.com/keys
20
- */
21
- accessKey: string;
22
-
23
- /**
24
- * Filebase secret access key
25
- * SECURITY: Store in environment variable, never in code
26
- */
27
- secretKey: string;
28
-
29
- /**
30
- * Filebase bucket name
31
- * @default 'agirails-storage'
32
- */
33
- bucket?: string;
34
-
35
- /**
36
- * Filebase S3 endpoint
37
- * @default 'https://s3.filebase.com'
38
- */
39
- endpoint?: string;
40
-
41
- /**
42
- * IPFS gateway URL for retrieval
43
- * @default 'https://ipfs.filebase.io/ipfs/'
44
- */
45
- gatewayUrl?: string;
46
-
47
- /**
48
- * Request timeout in milliseconds
49
- * @default 30000 (30 seconds)
50
- */
51
- timeout?: number;
52
-
53
- /**
54
- * Maximum file size in bytes for uploads
55
- * @default 104857600 (100MB)
56
- */
57
- maxFileSize?: number;
58
-
59
- /**
60
- * Maximum download size in bytes (P1-1: DoS protection)
61
- * Downloads exceeding this limit will be rejected
62
- * @default 52428800 (50MB)
63
- */
64
- maxDownloadSize?: number;
65
-
66
- /**
67
- * Circuit breaker configuration for gateway health tracking
68
- * When enabled, tracks gateway failures and temporarily blocks
69
- * requests to unhealthy gateways (retry amplification protection)
70
- */
71
- circuitBreaker?: {
72
- /** Enable circuit breaker (default: true) */
73
- enabled?: boolean;
74
- /** Number of failures before opening circuit (default: 5) */
75
- failureThreshold?: number;
76
- /** Cooldown period in ms before attempting reset (default: 60000) */
77
- resetTimeoutMs?: number;
78
- /** Time window in ms for counting failures (default: 300000) */
79
- failureWindowMs?: number;
80
- /** Number of successes in half-open to close circuit (default: 2) */
81
- successThreshold?: number;
82
- };
83
- }
84
-
85
- // ============================================================================
86
- // Arweave Configuration
87
- // ============================================================================
88
-
89
- /**
90
- * Supported Irys payment tokens
91
- * @see https://docs.irys.xyz/build/d/features/supported-tokens
92
- */
93
- export type IrysCurrency =
94
- | 'base-eth' // RECOMMENDED: Base ETH (native to AGIRAILS)
95
- | 'ethereum' // Ethereum mainnet ETH
96
- | 'matic' // Polygon MATIC
97
- | 'arbitrum' // Arbitrum ETH
98
- | 'usdc-eth' // USDC on Ethereum
99
- | 'usdc-polygon'; // USDC on Polygon
100
-
101
- /**
102
- * Irys network
103
- */
104
- export type IrysNetwork = 'mainnet' | 'devnet';
105
-
106
- /**
107
- * Configuration for Arweave client via Irys
108
- */
109
- export interface ArweaveConfig {
110
- /**
111
- * Private key for signing transactions
112
- * SECURITY: Store in environment variable, never in code
113
- */
114
- privateKey: string;
115
-
116
- /**
117
- * RPC URL for the payment chain
118
- * Required for blockchain operations
119
- */
120
- rpcUrl: string;
121
-
122
- /**
123
- * Payment currency/token
124
- * @default 'base-eth'
125
- */
126
- currency?: IrysCurrency;
127
-
128
- /**
129
- * Irys network (mainnet or devnet)
130
- * @default 'mainnet'
131
- */
132
- network?: IrysNetwork;
133
-
134
- /**
135
- * Request timeout in milliseconds
136
- * @default 60000 (60 seconds)
137
- */
138
- timeout?: number;
139
-
140
- /**
141
- * Circuit breaker configuration for gateway health tracking
142
- * When enabled, tracks gateway failures and temporarily blocks
143
- * requests to unhealthy gateways (retry amplification protection)
144
- */
145
- circuitBreaker?: {
146
- /** Enable circuit breaker (default: true) */
147
- enabled?: boolean;
148
- /** Number of failures before opening circuit (default: 5) */
149
- failureThreshold?: number;
150
- /** Cooldown period in ms before attempting reset (default: 60000) */
151
- resetTimeoutMs?: number;
152
- /** Time window in ms for counting failures (default: 300000) */
153
- failureWindowMs?: number;
154
- /** Number of successes in half-open to close circuit (default: 2) */
155
- successThreshold?: number;
156
- };
157
- }
158
-
159
- // ============================================================================
160
- // Archive Bundle Types (AIP-7 §4.4)
161
- // ============================================================================
162
-
163
- /**
164
- * Archive bundle type identifier
165
- */
166
- export const ARCHIVE_BUNDLE_TYPE = 'actp.archive.v1.minimal' as const;
167
-
168
- /**
169
- * Supported chain IDs for archive bundles
170
- */
171
- export type ArchiveChainId = 8453 | 84532; // Base Mainnet | Base Sepolia
172
-
173
- /**
174
- * Final transaction states that can be archived
175
- */
176
- export type ArchiveFinalState = 'SETTLED' | 'CANCELLED';
177
-
178
- /**
179
- * Transaction participants (addresses only, not full profiles)
180
- */
181
- export interface ArchiveParticipants {
182
- /** Requester Ethereum address */
183
- requester: string;
184
- /** Provider Ethereum address */
185
- provider: string;
186
- }
187
-
188
- /**
189
- * IPFS CID references to full content
190
- */
191
- export interface ArchiveReferences {
192
- /** IPFS CID of AIP-1 request metadata */
193
- requestCID: string;
194
- /** IPFS CID of AIP-4 delivery proof */
195
- deliveryCID: string;
196
- /** IPFS CID of actual result/output (optional) */
197
- resultCID?: string;
198
- }
199
-
200
- /**
201
- * Cryptographic hashes for verification
202
- */
203
- export interface ArchiveHashes {
204
- /** keccak256 of canonical request metadata JSON */
205
- requestHash: string;
206
- /** keccak256 of canonical delivery proof JSON */
207
- deliveryHash: string;
208
- /** serviceHash from ACTPKernel transaction */
209
- serviceHash: string;
210
- }
211
-
212
- /**
213
- * Cryptographic signatures for self-verification
214
- */
215
- export interface ArchiveSignatures {
216
- /** EIP-712 signature by provider over deliveryHash */
217
- providerDeliverySignature: string;
218
- /** Optional: requester signature authorizing settlement */
219
- requesterSettlementSignature?: string;
220
- }
221
-
222
- /**
223
- * EAS attestation reference
224
- */
225
- export interface ArchiveAttestation {
226
- /** Ethereum Attestation Service UID */
227
- easUID: string;
228
- /** EAS schema UID used for attestation (optional) */
229
- schemaUID?: string;
230
- }
231
-
232
- /**
233
- * Escrow release details
234
- */
235
- export interface EscrowRelease {
236
- /** Recipient address (provider or requester) */
237
- to: string;
238
- /** Released amount (USDC base units, string for BigInt safety) */
239
- amount: string;
240
- }
241
-
242
- /**
243
- * Settlement information
244
- */
245
- export interface ArchiveSettlement {
246
- /** Settlement timestamp (Unix seconds) */
247
- settledAt: number;
248
- /** Final transaction state */
249
- finalState: ArchiveFinalState;
250
- /** Escrow release details */
251
- escrowReleased: EscrowRelease;
252
- /** Platform fee collected (USDC base units) */
253
- platformFee: string;
254
- /** Whether transaction went through dispute */
255
- wasDisputed: boolean;
256
- }
257
-
258
- /**
259
- * Archive Bundle (AIP-7 §4.4 - Minimal Hash-First)
260
- *
261
- * Contains minimal metadata with cryptographic hashes and references.
262
- * Full content (request metadata, delivery proof) remains on IPFS.
263
- */
264
- export interface ArchiveBundle {
265
- /** AGIRAILS protocol version (e.g., "1.0.0") */
266
- protocolVersion: string;
267
- /** Archive bundle schema version (e.g., "1.0.0") */
268
- archiveSchemaVersion: string;
269
- /** Archive bundle type identifier */
270
- type: typeof ARCHIVE_BUNDLE_TYPE;
271
- /** ACTP transaction ID (bytes32) */
272
- txId: string;
273
- /** Blockchain network chain ID */
274
- chainId: ArchiveChainId;
275
- /** Archive timestamp (Unix seconds) */
276
- archivedAt: number;
277
- /** Transaction participants (addresses only) */
278
- participants: ArchiveParticipants;
279
- /** IPFS CID references to full content */
280
- references: ArchiveReferences;
281
- /** Cryptographic hashes for verification */
282
- hashes: ArchiveHashes;
283
- /** Cryptographic signatures */
284
- signatures: ArchiveSignatures;
285
- /** EAS attestation reference (optional for cancelled transactions) */
286
- attestation?: ArchiveAttestation;
287
- /** Settlement information */
288
- settlement: ArchiveSettlement;
289
- }
290
-
291
- // ============================================================================
292
- // Upload/Download Results
293
- // ============================================================================
294
-
295
- /**
296
- * Result of uploading to IPFS
297
- */
298
- export interface IPFSUploadResult {
299
- /** IPFS CID (CIDv1, base32) */
300
- cid: string;
301
- /** Size of uploaded content in bytes */
302
- size: number;
303
- /** Upload timestamp */
304
- uploadedAt: Date;
305
- }
306
-
307
- /**
308
- * Result of uploading to Arweave
309
- */
310
- export interface ArweaveUploadResult {
311
- /** Arweave transaction ID */
312
- txId: string;
313
- /** Size of uploaded content in bytes */
314
- size: number;
315
- /** Upload timestamp */
316
- uploadedAt: Date;
317
- /** Cost in the payment currency (wei for ETH) */
318
- cost: string;
319
- }
320
-
321
- /**
322
- * Result of downloading content
323
- */
324
- export interface DownloadResult<T = unknown> {
325
- /** Downloaded and parsed content */
326
- data: T;
327
- /** Size of downloaded content in bytes */
328
- size: number;
329
- /** Download timestamp */
330
- downloadedAt: Date;
331
- }
332
-
333
- // ============================================================================
334
- // Irys Tags
335
- // ============================================================================
336
-
337
- /**
338
- * Arweave/Irys tags for archive bundles
339
- */
340
- export interface ArchiveTags {
341
- 'Content-Type': 'application/json';
342
- Protocol: 'AGIRAILS';
343
- Version: string;
344
- Schema: string;
345
- Type: typeof ARCHIVE_BUNDLE_TYPE;
346
- ChainId: string;
347
- TxId: string;
348
- }