@agether/sdk 1.0.0

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 (42) hide show
  1. package/README.md +480 -0
  2. package/dist/cli.d.mts +2 -0
  3. package/dist/cli.d.ts +19 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +2149 -0
  6. package/dist/cli.mjs +0 -0
  7. package/dist/clients/AgentIdentityClient.d.ts +163 -0
  8. package/dist/clients/AgentIdentityClient.d.ts.map +1 -0
  9. package/dist/clients/AgentIdentityClient.js +293 -0
  10. package/dist/clients/AgetherClient.d.ts +101 -0
  11. package/dist/clients/AgetherClient.d.ts.map +1 -0
  12. package/dist/clients/AgetherClient.js +272 -0
  13. package/dist/clients/ScoringClient.d.ts +138 -0
  14. package/dist/clients/ScoringClient.d.ts.map +1 -0
  15. package/dist/clients/ScoringClient.js +135 -0
  16. package/dist/clients/VaultClient.d.ts +62 -0
  17. package/dist/clients/VaultClient.d.ts.map +1 -0
  18. package/dist/clients/VaultClient.js +157 -0
  19. package/dist/clients/WalletClient.d.ts +73 -0
  20. package/dist/clients/WalletClient.d.ts.map +1 -0
  21. package/dist/clients/WalletClient.js +174 -0
  22. package/dist/clients/X402Client.d.ts +61 -0
  23. package/dist/clients/X402Client.d.ts.map +1 -0
  24. package/dist/clients/X402Client.js +303 -0
  25. package/dist/index.d.mts +932 -0
  26. package/dist/index.d.ts +932 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +1680 -0
  29. package/dist/index.mjs +1610 -0
  30. package/dist/types/index.d.ts +220 -0
  31. package/dist/types/index.d.ts.map +1 -0
  32. package/dist/types/index.js +52 -0
  33. package/dist/utils/abis.d.ts +21 -0
  34. package/dist/utils/abis.d.ts.map +1 -0
  35. package/dist/utils/abis.js +134 -0
  36. package/dist/utils/config.d.ts +31 -0
  37. package/dist/utils/config.d.ts.map +1 -0
  38. package/dist/utils/config.js +117 -0
  39. package/dist/utils/format.d.ts +44 -0
  40. package/dist/utils/format.d.ts.map +1 -0
  41. package/dist/utils/format.js +75 -0
  42. package/package.json +57 -0
@@ -0,0 +1,932 @@
1
+ import { Signer } from 'ethers';
2
+
3
+ /**
4
+ * Agether SDK Types v2
5
+ *
6
+ * Account-based credit model:
7
+ * - Agent registers via ERC-8004 → gets agentId
8
+ * - AccountFactory creates AgentAccount (smart wallet) per agent
9
+ * - ReputationCredit: undercollateralized credit (LP-funded, Bayesian scoring)
10
+ * - MorphoCredit: overcollateralized credit (Morpho Blue)
11
+ * - Apply/approve pipeline: agent applies → scoring evaluates → admin approves/rejects on-chain
12
+ */
13
+ declare enum CreditStatus {
14
+ None = 0,
15
+ Pending = 1,
16
+ Active = 2,
17
+ Frozen = 3,
18
+ Closed = 4,
19
+ Defaulted = 5
20
+ }
21
+ declare enum ChainId {
22
+ Ethereum = 1,
23
+ Base = 8453,
24
+ BaseSepolia = 84532,
25
+ Sepolia = 11155111,
26
+ Hardhat = 31337
27
+ }
28
+ /** ICreditProvider.CreditInfo view struct */
29
+ interface CreditInfo {
30
+ limit: bigint;
31
+ used: bigint;
32
+ available: bigint;
33
+ accruedInterest: bigint;
34
+ aprBps: bigint;
35
+ isActive: boolean;
36
+ requiresCollateral: boolean;
37
+ }
38
+ /** ReputationCredit full credit line details */
39
+ interface CreditLine {
40
+ agentId: bigint;
41
+ limit: bigint;
42
+ used: bigint;
43
+ aprBps: bigint;
44
+ accruedInterest: bigint;
45
+ requestedLimit: bigint;
46
+ createdAt: bigint;
47
+ lastActivityAt: bigint;
48
+ status: CreditStatus;
49
+ }
50
+ /** Credit application request */
51
+ interface CreditApplication {
52
+ agentId: bigint;
53
+ requestedLimit: bigint;
54
+ }
55
+ /** Scored credit preview */
56
+ interface ScoredLimitPreview {
57
+ limit: bigint;
58
+ score: bigint;
59
+ eligible: boolean;
60
+ }
61
+ /** AgentReputation data */
62
+ interface AgentReputation {
63
+ totalBorrowed: bigint;
64
+ totalRepaid: bigint;
65
+ totalInterestPaid: bigint;
66
+ onTimePayments: bigint;
67
+ latePayments: bigint;
68
+ missedPayments: bigint;
69
+ peakUtilization: bigint;
70
+ avgUtilization: bigint;
71
+ utilizationSamples: bigint;
72
+ firstActivityAt: bigint;
73
+ lastActivityAt: bigint;
74
+ lastScoreUpdate: bigint;
75
+ creditScore: bigint;
76
+ creditLinesOpened: bigint;
77
+ lastCreditOpenedAt: bigint;
78
+ currentOutstanding: bigint;
79
+ currentLimit: bigint;
80
+ totalDeposits: bigint;
81
+ totalWithdrawals: bigint;
82
+ }
83
+ /** Loan position tracked by AgentReputation (OCCR model) */
84
+ interface LoanPosition {
85
+ amount: bigint;
86
+ collateral: bigint;
87
+ ltvBps: bigint;
88
+ timestamp: bigint;
89
+ liquidated: boolean;
90
+ repaid: boolean;
91
+ active: boolean;
92
+ }
93
+ /** OCCR score explanation (5 subscores + raw/decayed) */
94
+ interface ScoreExplanation {
95
+ historical: bigint;
96
+ currentRisk: bigint;
97
+ utilization: bigint;
98
+ onChainTx: bigint;
99
+ newCredit: bigint;
100
+ rawScore: bigint;
101
+ decayedScore: bigint;
102
+ }
103
+ /** Bayesian score result */
104
+ interface BayesianScore {
105
+ combinedScore: bigint;
106
+ confidence: bigint;
107
+ }
108
+ interface ScoringRequest {
109
+ agentId: bigint;
110
+ requestedLimit: bigint;
111
+ codeHash?: string;
112
+ }
113
+ interface ScoringResult {
114
+ approved: boolean;
115
+ limit: bigint;
116
+ aprBps: number;
117
+ riskScore: number;
118
+ bayesianScore: number;
119
+ confidence: number;
120
+ reason?: string;
121
+ }
122
+ interface DrawRequest {
123
+ account: string;
124
+ amount: bigint;
125
+ }
126
+ interface RepayRequest {
127
+ account: string;
128
+ amount: bigint;
129
+ }
130
+ interface TransactionResult {
131
+ txHash: string;
132
+ blockNumber: number;
133
+ status: 'success' | 'failed';
134
+ gasUsed: bigint;
135
+ }
136
+ interface X402PaymentRequest {
137
+ service: string;
138
+ amount: bigint;
139
+ asset: string;
140
+ chain: ChainId;
141
+ recipient: string;
142
+ }
143
+ interface X402PaymentResult {
144
+ paymentId: string;
145
+ txHash: string;
146
+ amount: bigint;
147
+ chain: ChainId;
148
+ status: 'pending' | 'confirmed' | 'failed';
149
+ }
150
+ interface VaultStats {
151
+ totalAssets: bigint;
152
+ totalBorrowed: bigint;
153
+ availableLiquidity: bigint;
154
+ utilizationRate: number;
155
+ sharePrice: bigint;
156
+ }
157
+ interface LPPosition {
158
+ shares: bigint;
159
+ assets: bigint;
160
+ pendingYield: bigint;
161
+ }
162
+ interface AgetherConfig {
163
+ chainId: ChainId;
164
+ rpcUrl: string;
165
+ contracts: ContractAddresses;
166
+ scoringEndpoint?: string;
167
+ kyaEndpoint?: string;
168
+ }
169
+ interface ContractAddresses {
170
+ accountFactory: string;
171
+ reputationCredit: string;
172
+ lpVault: string;
173
+ validationRegistry: string;
174
+ usdc: string;
175
+ identityRegistry: string;
176
+ morphoCredit?: string;
177
+ agentReputation?: string;
178
+ }
179
+ interface CreditAppliedEvent {
180
+ agentId: bigint;
181
+ account: string;
182
+ requestedLimit: bigint;
183
+ timestamp: number;
184
+ }
185
+ interface CreditApprovedEvent {
186
+ account: string;
187
+ limit: bigint;
188
+ aprBps: bigint;
189
+ timestamp: number;
190
+ }
191
+ interface CreditRejectedEvent {
192
+ account: string;
193
+ reason: string;
194
+ timestamp: number;
195
+ }
196
+ interface CreditDrawnEvent {
197
+ account: string;
198
+ amount: bigint;
199
+ totalUsed: bigint;
200
+ timestamp: number;
201
+ }
202
+ interface CreditRepaidEvent {
203
+ account: string;
204
+ amount: bigint;
205
+ totalUsed: bigint;
206
+ timestamp: number;
207
+ }
208
+ declare class AgetherError extends Error {
209
+ code: string;
210
+ details?: Record<string, unknown> | undefined;
211
+ constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
212
+ }
213
+ declare class InsufficientCreditError extends AgetherError {
214
+ constructor(available: bigint, requested: bigint);
215
+ }
216
+ declare class ScoringRejectedError extends AgetherError {
217
+ constructor(riskScore: number, reason?: string);
218
+ }
219
+ declare class CreditNotActiveError extends AgetherError {
220
+ constructor(account: string, status: CreditStatus);
221
+ }
222
+
223
+ interface AgetherClientOptions {
224
+ config: AgetherConfig;
225
+ signer: Signer;
226
+ agentId: bigint;
227
+ }
228
+ declare class AgetherClient {
229
+ private config;
230
+ private signer;
231
+ private agentId;
232
+ private accountFactory;
233
+ private reputationCredit;
234
+ private accountAddress?;
235
+ /**
236
+ * Undercollateralized credit is disabled for now.
237
+ * All credit operations go through MorphoCredit (overcollateralized).
238
+ */
239
+ private _requireUndercollateralizedEnabled;
240
+ constructor(options: AgetherClientOptions);
241
+ /**
242
+ * Create client from private key.
243
+ *
244
+ * Simplest usage — only needs key, agentId, and chainId:
245
+ * AgetherClient.fromPrivateKey(key, 42n, ChainId.Sepolia)
246
+ *
247
+ * All contract addresses and RPC URLs are resolved automatically.
248
+ */
249
+ static fromPrivateKey(privateKey: string, agentId: bigint, chainIdOrConfig: ChainId | AgetherConfig): AgetherClient;
250
+ /**
251
+ * Create an AgentAccount (smart wallet) for this agent.
252
+ * Returns the account address.
253
+ */
254
+ createAccount(): Promise<string>;
255
+ /**
256
+ * Get the AgentAccount address for this agent.
257
+ */
258
+ getAccountAddress(): Promise<string>;
259
+ /**
260
+ * Check if an account already exists.
261
+ */
262
+ accountExists(): Promise<boolean>;
263
+ /**
264
+ * Apply for a credit line.
265
+ * @deprecated Undercollateralized credit is not available yet. Use MorphoCredit.
266
+ */
267
+ apply(_limitOrApplication: bigint | CreditApplication): Promise<string>;
268
+ /**
269
+ * Get full credit line details from ReputationCredit.
270
+ */
271
+ getCreditLine(): Promise<CreditLine>;
272
+ /**
273
+ * Get ICreditProvider.CreditInfo view.
274
+ */
275
+ getCreditInfo(): Promise<CreditInfo>;
276
+ /**
277
+ * Get credit line status.
278
+ */
279
+ getStatus(): Promise<CreditStatus>;
280
+ /**
281
+ * Get available credit.
282
+ */
283
+ getAvailableCredit(): Promise<bigint>;
284
+ /**
285
+ * Get total debt (principal + interest).
286
+ */
287
+ getTotalDebt(): Promise<bigint>;
288
+ /**
289
+ * Check if agent is eligible for credit.
290
+ */
291
+ isEligible(): Promise<boolean>;
292
+ /**
293
+ * Draw funds from credit line via AgentAccount.
294
+ * @deprecated Undercollateralized credit is not available yet. Use MorphoCredit.
295
+ */
296
+ draw(_amountOrRequest: bigint | DrawRequest): Promise<TransactionResult>;
297
+ /**
298
+ * Repay credit line debt via AgentAccount.
299
+ * @deprecated Undercollateralized credit is not available yet. Use MorphoCredit.
300
+ */
301
+ repay(_amountOrRequest: bigint | RepayRequest): Promise<TransactionResult>;
302
+ /**
303
+ * Repay full debt.
304
+ * @deprecated Undercollateralized credit is not available yet. Use MorphoCredit.
305
+ */
306
+ repayFull(): Promise<TransactionResult>;
307
+ /**
308
+ * Request a limit increase on-chain.
309
+ * @deprecated Undercollateralized credit is not available yet. Use MorphoCredit.
310
+ */
311
+ requestLimitIncrease(_newLimit: bigint): Promise<string>;
312
+ /**
313
+ * Pay for a service using credit line.
314
+ * @deprecated Undercollateralized credit is not available yet. Use MorphoCredit.
315
+ */
316
+ pay(_service: string, _amount: bigint, _asset?: string): Promise<TransactionResult>;
317
+ get chainId(): ChainId;
318
+ get contracts(): ContractAddresses;
319
+ get currentAccountAddress(): string | undefined;
320
+ /** Get the underlying signer */
321
+ getSigner(): Signer;
322
+ }
323
+
324
+ /**
325
+ * ScoringClient - Client for the Agether backend scoring API (v2)
326
+ *
327
+ * Connects to backend service at /credit/* and /admin/* endpoints.
328
+ * The backend evaluates agents based on:
329
+ * - On-chain reputation (AgentReputation contract, Bayesian scoring)
330
+ * - Code audit status (ValidationRegistry)
331
+ * - Default history
332
+ * - Risk model
333
+ *
334
+ * v2: account-based (not creditLineId-based)
335
+ */
336
+
337
+ interface ScoringContext {
338
+ purpose?: string;
339
+ reasoningTrace?: string[];
340
+ runtimeEnv?: string;
341
+ }
342
+ interface RiskCheckResponse {
343
+ riskScore: number;
344
+ level: 'low' | 'medium' | 'high';
345
+ wouldApprove: boolean;
346
+ factors: RiskFactor[];
347
+ }
348
+ interface RiskFactor {
349
+ name: string;
350
+ score: number;
351
+ weight: number;
352
+ description: string;
353
+ }
354
+ interface GraduationStatus {
355
+ eligible: boolean;
356
+ reason: string;
357
+ stats: {
358
+ onTimeRepayments: number;
359
+ totalVolume: string;
360
+ creditScore: number;
361
+ };
362
+ }
363
+ declare class ScoringClient {
364
+ private client;
365
+ constructor(endpoint: string, apiKey?: string);
366
+ /**
367
+ * Evaluate a credit application (does not submit on-chain)
368
+ * Backend endpoint: POST /credit/evaluate
369
+ */
370
+ evaluateCredit(request: ScoringRequest): Promise<ScoringResult>;
371
+ /**
372
+ * Process a credit application (evaluate + on-chain approve/reject)
373
+ * Backend endpoint: POST /admin/credit/process
374
+ *
375
+ * Requires the credit application to be in Pending status on-chain
376
+ * (agent must have called applyForCredit first).
377
+ */
378
+ processApplication(agentId: bigint, requestedLimit: bigint, codeHash?: string): Promise<{
379
+ success: boolean;
380
+ txHash?: string;
381
+ error?: string;
382
+ }>;
383
+ /**
384
+ * Get credit score for an agent
385
+ * Backend endpoint: GET /credit/score/:agentId
386
+ */
387
+ getCreditScore(agentId: bigint): Promise<{
388
+ agentId: string;
389
+ creditScore: number;
390
+ bayesianScore: number;
391
+ confidence: number;
392
+ }>;
393
+ /**
394
+ * Preview scored limit for an agent
395
+ * Backend endpoint: GET /credit/preview/:agentId
396
+ */
397
+ previewScoredLimit(agentId: bigint): Promise<{
398
+ limit: string;
399
+ score: string;
400
+ eligible: boolean;
401
+ }>;
402
+ /**
403
+ * Get credit line info for an agent
404
+ * Backend endpoint: GET /credit/agent/:agentId
405
+ */
406
+ getAgentCredit(agentId: bigint): Promise<{
407
+ agentId: string;
408
+ account: string;
409
+ creditInfo: Record<string, unknown>;
410
+ creditLine: Record<string, unknown>;
411
+ }>;
412
+ /**
413
+ * Get protocol info
414
+ * Backend endpoint: GET /credit/protocol-info
415
+ */
416
+ getProtocolInfo(): Promise<{
417
+ dailyDrawLimit: string;
418
+ totalBorrowed: string;
419
+ asset: string;
420
+ }>;
421
+ /**
422
+ * Get backend service status
423
+ * Backend endpoint: GET /status
424
+ */
425
+ getStatus(): Promise<{
426
+ status: string;
427
+ version: string;
428
+ signer: string;
429
+ contracts: {
430
+ healthy: boolean;
431
+ };
432
+ }>;
433
+ /**
434
+ * Get full OCCR score explanation with subscores, decay, and loan positions
435
+ * Backend endpoint: GET /agents/:agentId/score-explanation
436
+ */
437
+ getScoreExplanation(agentId: bigint): Promise<{
438
+ agentId: string;
439
+ subscores: {
440
+ historical: number;
441
+ currentRisk: number;
442
+ utilization: number;
443
+ onChainTx: number;
444
+ newCredit: number;
445
+ };
446
+ rawScore: number;
447
+ decayedScore: number;
448
+ stressMultiplier: number;
449
+ decayPeriod: number;
450
+ loanPositions: Array<{
451
+ amount: string;
452
+ collateral: string;
453
+ ltvBps: number;
454
+ timestamp: number;
455
+ liquidated: boolean;
456
+ repaid: boolean;
457
+ active: boolean;
458
+ }>;
459
+ }>;
460
+ }
461
+
462
+ /**
463
+ * VaultClient - Client for liquidity providers
464
+ */
465
+
466
+ interface VaultClientOptions {
467
+ config: AgetherConfig;
468
+ signer: Signer;
469
+ }
470
+ declare class VaultClient {
471
+ private config;
472
+ private signer;
473
+ private vault;
474
+ private asset?;
475
+ constructor(options: VaultClientOptions);
476
+ /**
477
+ * Deposit assets to vault
478
+ */
479
+ deposit(amount: bigint): Promise<TransactionResult>;
480
+ /**
481
+ * Withdraw assets from vault
482
+ */
483
+ withdraw(amount: bigint): Promise<TransactionResult>;
484
+ /**
485
+ * Redeem shares for assets
486
+ */
487
+ redeem(shares: bigint): Promise<TransactionResult>;
488
+ /**
489
+ * Get vault statistics
490
+ */
491
+ getStats(): Promise<VaultStats>;
492
+ /**
493
+ * Get LP position
494
+ */
495
+ getPosition(address?: string): Promise<LPPosition>;
496
+ /**
497
+ * Preview deposit (how many shares for assets)
498
+ */
499
+ previewDeposit(assets: bigint): Promise<bigint>;
500
+ /**
501
+ * Preview withdraw (how many assets for shares)
502
+ */
503
+ previewRedeem(shares: bigint): Promise<bigint>;
504
+ /**
505
+ * Check if withdrawal is allowed (sufficient liquidity)
506
+ */
507
+ canWithdraw(assets: bigint): Promise<boolean>;
508
+ /**
509
+ * Get current APY estimate
510
+ */
511
+ estimateAPY(): Promise<number>;
512
+ private getAsset;
513
+ /**
514
+ * Get underlying asset address
515
+ */
516
+ getAssetAddress(): Promise<string>;
517
+ /**
518
+ * Get vault share token address
519
+ */
520
+ getVaultAddress(): string;
521
+ }
522
+
523
+ /**
524
+ * AgentIdentityClient - Integration with ag0 (ERC-8004)
525
+ *
526
+ * ERC-8004 Contract Addresses:
527
+ * - Sepolia IdentityRegistry: 0x8004A818BFB912233c491871b3d84c89A494BD9e
528
+ * - Sepolia ReputationRegistry: 0x8004B663056A597Dffe9eCcC1965A193B7388713
529
+ *
530
+ * SDKs:
531
+ * - TypeScript: https://github.com/agent0lab/agent0-ts
532
+ * - Python: https://github.com/agent0lab/agent0-py
533
+ *
534
+ * Docs: https://sdk.ag0.xyz/docs
535
+ */
536
+
537
+ interface AgentIdentityClientOptions {
538
+ config: AgetherConfig;
539
+ signer: Signer;
540
+ /** Optional: Use ag0 TypeScript SDK instead of direct contracts */
541
+ useAg0SDK?: boolean;
542
+ }
543
+ interface AgentMetadata {
544
+ name: string;
545
+ description: string;
546
+ image?: string;
547
+ endpoints?: {
548
+ name: string;
549
+ endpoint: string;
550
+ version?: string;
551
+ }[];
552
+ x402Support?: boolean;
553
+ active?: boolean;
554
+ }
555
+ interface FeedbackInput {
556
+ agentId: bigint;
557
+ value: number;
558
+ decimals?: number;
559
+ tag1?: string;
560
+ tag2?: string;
561
+ endpoint?: string;
562
+ feedbackURI?: string;
563
+ }
564
+ interface ReputationSummary {
565
+ count: number;
566
+ totalValue: number;
567
+ averageValue: number;
568
+ clients: string[];
569
+ }
570
+ declare class AgentIdentityClient {
571
+ readonly config: AgetherConfig;
572
+ private signer;
573
+ private identityRegistry;
574
+ private reputationRegistry;
575
+ constructor(options: AgentIdentityClientOptions);
576
+ /**
577
+ * Register a new agent (minimal - no metadata)
578
+ */
579
+ register(): Promise<{
580
+ agentId: bigint;
581
+ txHash: string;
582
+ }>;
583
+ /**
584
+ * Register agent with IPFS/HTTP URI to metadata JSON
585
+ * @param agentURI URI pointing to agent metadata (ipfs:// or https://)
586
+ */
587
+ registerWithURI(agentURI: string): Promise<{
588
+ agentId: bigint;
589
+ txHash: string;
590
+ }>;
591
+ /**
592
+ * Check if the signer already owns an ERC-8004 identity token.
593
+ * Returns true if balanceOf > 0, false otherwise.
594
+ * Note: Cannot determine the specific agentId without enumeration —
595
+ * use agether init <pk> --agent-id <id> if you know your agentId.
596
+ */
597
+ hasExistingIdentity(): Promise<boolean>;
598
+ /**
599
+ * Register only if no identity exists; otherwise throw.
600
+ * Prevents accidental double-registration.
601
+ */
602
+ registerOrGet(): Promise<{
603
+ agentId: bigint;
604
+ txHash: string | null;
605
+ existing: boolean;
606
+ }>;
607
+ /**
608
+ * Register with URI only if no identity exists; otherwise throw.
609
+ * Prevents accidental double-registration.
610
+ */
611
+ registerOrGetWithURI(agentURI: string): Promise<{
612
+ agentId: bigint;
613
+ txHash: string | null;
614
+ existing: boolean;
615
+ }>;
616
+ /**
617
+ * Register agent with URI and on-chain metadata
618
+ */
619
+ registerWithMetadata(agentURI: string, metadata: {
620
+ key: string;
621
+ value: string;
622
+ }[]): Promise<{
623
+ agentId: bigint;
624
+ txHash: string;
625
+ }>;
626
+ /**
627
+ * Get agent owner address
628
+ */
629
+ getOwner(agentId: bigint): Promise<string>;
630
+ /**
631
+ * Get agent URI (metadata JSON location)
632
+ */
633
+ getAgentURI(agentId: bigint): Promise<string>;
634
+ /**
635
+ * Update agent URI
636
+ */
637
+ setAgentURI(agentId: bigint, newURI: string): Promise<string>;
638
+ /**
639
+ * Set on-chain metadata (key-value)
640
+ */
641
+ setMetadata(agentId: bigint, key: string, value: string): Promise<string>;
642
+ /**
643
+ * Get on-chain metadata
644
+ */
645
+ getMetadata(agentId: bigint, key: string): Promise<string>;
646
+ /**
647
+ * Transfer agent to new owner
648
+ */
649
+ transfer(agentId: bigint, to: string): Promise<string>;
650
+ /**
651
+ * Fetch and parse agent metadata from URI
652
+ */
653
+ fetchAgentMetadata(agentId: bigint): Promise<AgentMetadata | null>;
654
+ /**
655
+ * Give feedback to an agent
656
+ */
657
+ giveFeedback(input: FeedbackInput): Promise<string>;
658
+ /**
659
+ * Give positive feedback (shorthand)
660
+ */
661
+ givePosisitiveFeedback(agentId: bigint, value?: number, tags?: {
662
+ tag1?: string;
663
+ tag2?: string;
664
+ }): Promise<string>;
665
+ /**
666
+ * Give negative feedback (e.g., for defaults)
667
+ */
668
+ giveNegativeFeedback(agentId: bigint, value?: number, tags?: {
669
+ tag1?: string;
670
+ tag2?: string;
671
+ }): Promise<string>;
672
+ /**
673
+ * Record credit default in reputation system
674
+ */
675
+ recordCreditDefault(agentId: bigint, creditLineId: bigint): Promise<string>;
676
+ /**
677
+ * Get reputation summary for an agent
678
+ */
679
+ getReputation(agentId: bigint, tag1?: string, tag2?: string): Promise<ReputationSummary>;
680
+ /**
681
+ * Check if agent has negative credit reputation
682
+ */
683
+ hasNegativeCreditReputation(agentId: bigint): Promise<boolean>;
684
+ /**
685
+ * Verify agent is eligible for Agether credit
686
+ * Checks:
687
+ * 1. Agent exists in ERC-8004 registry
688
+ * 2. Agent has no negative credit reputation
689
+ */
690
+ verifyForCredit(agentId: bigint): Promise<{
691
+ eligible: boolean;
692
+ reason?: string;
693
+ owner?: string;
694
+ reputation?: ReputationSummary;
695
+ }>;
696
+ private parseAgentIdFromReceipt;
697
+ /**
698
+ * Get contract addresses
699
+ */
700
+ getContractAddresses(): {
701
+ identity: string;
702
+ reputation: string;
703
+ };
704
+ }
705
+
706
+ /**
707
+ * x402 HTTP Client — Make paid API calls via the x402 protocol (v2)
708
+ *
709
+ * Implements the Coinbase x402 spec:
710
+ * https://github.com/coinbase/x402
711
+ *
712
+ * Flow:
713
+ * 1. Client → Resource Server (normal request)
714
+ * 2. Resource Server → 402 with PaymentRequired JSON body
715
+ * Body: { x402Version, error, resource, accepts: [PaymentRequirements…] }
716
+ * 3. Client picks a PaymentRequirements from `accepts`,
717
+ * signs an EIP-3009 transferWithAuthorization (EIP-712 typed data),
718
+ * builds a PaymentPayload, base64-encodes it as PAYMENT-SIGNATURE header
719
+ * 4. Client → Resource Server (retries with PAYMENT-SIGNATURE)
720
+ * 5. Resource Server forwards to Facilitator /verify → /settle
721
+ * 6. Resource Server → 200 + data (or error)
722
+ *
723
+ * Chain support: Base (8453), Ethereum (1), and Hardhat fork (31337).
724
+ * USDC domain is resolved per-chain from USDC_DOMAINS map.
725
+ */
726
+ interface X402Config {
727
+ privateKey: string;
728
+ rpcUrl: string;
729
+ backendUrl: string;
730
+ agentId?: string;
731
+ accountAddress?: string;
732
+ }
733
+ interface X402Response<T = unknown> {
734
+ success: boolean;
735
+ data?: T;
736
+ error?: string;
737
+ paymentInfo?: {
738
+ amount: string;
739
+ asset: string;
740
+ network: string;
741
+ txHash?: string;
742
+ };
743
+ }
744
+ /** One item inside the `accepts` array returned by the resource server */
745
+ interface PaymentRequirements {
746
+ scheme: string;
747
+ network: string;
748
+ amount: string;
749
+ asset: string;
750
+ payTo: string;
751
+ maxTimeoutSeconds: number;
752
+ extra?: Record<string, unknown>;
753
+ }
754
+ declare class X402Client {
755
+ private wallet;
756
+ private config;
757
+ constructor(config: X402Config);
758
+ get<T = unknown>(url: string, opts?: RequestInit): Promise<X402Response<T>>;
759
+ post<T = unknown>(url: string, body?: unknown, opts?: RequestInit): Promise<X402Response<T>>;
760
+ getAddress(): string;
761
+ private request;
762
+ private parsePaymentRequired;
763
+ private buildPaymentPayload;
764
+ private riskCheck;
765
+ }
766
+
767
+ /**
768
+ * WalletClient - SDK for AgentAccount (smart wallet) operations (v2)
769
+ *
770
+ * Handles:
771
+ * - Account creation and lookup via AccountFactory
772
+ * - Funding and withdrawing tokens
773
+ * - Drawing/repaying credit via AgentAccount
774
+ * - Token balance queries
775
+ */
776
+ interface WalletInfo {
777
+ address: string;
778
+ agentId: bigint;
779
+ owner: string;
780
+ ethBalance: bigint;
781
+ usdcBalance: bigint;
782
+ }
783
+ interface ProviderStatus {
784
+ provider: string;
785
+ isEligible: boolean;
786
+ totalDebt: bigint;
787
+ maxDrawable: bigint;
788
+ }
789
+ interface MorphoMarketParams {
790
+ loanToken: string;
791
+ collateralToken: string;
792
+ oracle: string;
793
+ irm: string;
794
+ lltv: bigint;
795
+ }
796
+ interface PaymentProof {
797
+ recipient: string;
798
+ amount: bigint;
799
+ nonce: bigint;
800
+ deadline: bigint;
801
+ signature: string;
802
+ }
803
+ interface WalletClientConfig {
804
+ rpcUrl: string;
805
+ chainId: number;
806
+ factoryAddress: string;
807
+ usdcAddress?: string;
808
+ privateKey?: string;
809
+ }
810
+ declare class WalletClient {
811
+ private provider;
812
+ private privateKey;
813
+ private factoryAddress;
814
+ private usdcAddress;
815
+ private chainId;
816
+ private rpcUrl;
817
+ constructor(config: WalletClientConfig);
818
+ /**
819
+ * Create a fresh signer to avoid nonce caching issues
820
+ */
821
+ private getFreshSigner;
822
+ private getFactoryContract;
823
+ private getAccountContract;
824
+ getChainId(): number;
825
+ accountExists(agentId: bigint): Promise<boolean>;
826
+ getAccount(agentId: bigint): Promise<string | null>;
827
+ predictAddress(agentId: bigint): Promise<string>;
828
+ createAccount(agentId: bigint): Promise<string>;
829
+ totalAccounts(): Promise<bigint>;
830
+ getWalletInfo(accountAddress: string): Promise<WalletInfo>;
831
+ getProviderStatus(accountAddress: string, creditProvider: string): Promise<ProviderStatus>;
832
+ fundAccount(accountAddress: string, tokenAddress: string, amount: bigint): Promise<string>;
833
+ withdraw(accountAddress: string, tokenAddress: string, amount: bigint, to?: string): Promise<string>;
834
+ drawCredit(accountAddress: string, creditProvider: string, amount: bigint): Promise<string>;
835
+ repayCredit(accountAddress: string, creditProvider: string, amount: bigint): Promise<string>;
836
+ execute(accountAddress: string, target: string, value: bigint, data: string): Promise<string>;
837
+ generatePaymentMessageHash(accountAddress: string, recipient: string, amount: bigint, nonce: bigint, deadline: bigint, chainId: number): string;
838
+ }
839
+
840
+ /**
841
+ * Formatting utilities
842
+ */
843
+ /**
844
+ * Parse units (e.g., "100" USDC -> 100000000n)
845
+ */
846
+ declare function parseUnits(value: string, decimals?: number): bigint;
847
+ /**
848
+ * Format units (e.g., 100000000n -> "100.00" USDC)
849
+ */
850
+ declare function formatUnits(value: bigint, decimals?: number): string;
851
+ /**
852
+ * Format USD value
853
+ */
854
+ declare function formatUSD(value: bigint, decimals?: number): string;
855
+ /**
856
+ * Format percentage
857
+ */
858
+ declare function formatPercent(bps: number): string;
859
+ /**
860
+ * Format APR from basis points
861
+ */
862
+ declare function formatAPR(bps: bigint): string;
863
+ /**
864
+ * Calculate health factor display
865
+ */
866
+ declare function formatHealthFactor(factor: bigint): string;
867
+ /**
868
+ * Format address (truncate)
869
+ */
870
+ declare function formatAddress(address: string): string;
871
+ /**
872
+ * Format timestamp to date
873
+ */
874
+ declare function formatTimestamp(timestamp: bigint): string;
875
+ /**
876
+ * Convert basis points to decimal rate
877
+ */
878
+ declare function bpsToRate(bps: bigint): number;
879
+ /**
880
+ * Convert decimal rate to basis points
881
+ */
882
+ declare function rateToBps(rate: number): bigint;
883
+
884
+ /**
885
+ * Network configurations (v2)
886
+ *
887
+ * v2 contract architecture:
888
+ * - AccountFactory + AgentAccount (smart wallets)
889
+ * - ReputationCredit (ICreditProvider, undercollateralized)
890
+ * - LPVault (ERC-4626)
891
+ * - ValidationRegistry (KYA)
892
+ * - AgentReputation (Bayesian scoring)
893
+ * - ERC-8004 IdentityRegistry
894
+ *
895
+ * All contract addresses are baked in — agents only need to specify chainId.
896
+ */
897
+
898
+ /**
899
+ * Get default config for a chain — includes all addresses, RPC, and scoring endpoint.
900
+ */
901
+ declare function getDefaultConfig(chainId: ChainId): AgetherConfig;
902
+ /**
903
+ * Create custom config (override any defaults)
904
+ */
905
+ declare function createConfig(chainId: ChainId, options?: Partial<AgetherConfig>): AgetherConfig;
906
+ /**
907
+ * Get USDC address for chain
908
+ */
909
+ declare function getUSDCAddress(chainId: ChainId): string;
910
+
911
+ /**
912
+ * Contract ABIs v2 (minimal for SDK)
913
+ *
914
+ * v2 architecture:
915
+ * - AccountFactory + AgentAccount (smart wallets)
916
+ * - ReputationCredit (undercollateralized, ICreditProvider)
917
+ * - MorphoCredit (overcollateralized, ICreditProvider)
918
+ * - LPVault (ERC-4626)
919
+ * - ValidationRegistry (KYA)
920
+ * - AgentReputation (Bayesian scoring)
921
+ */
922
+ declare const IDENTITY_REGISTRY_ABI: string[];
923
+ declare const ACCOUNT_FACTORY_ABI: string[];
924
+ declare const AGENT_ACCOUNT_ABI: string[];
925
+ declare const CREDIT_PROVIDER_ABI: string[];
926
+ declare const REPUTATION_CREDIT_ABI: string[];
927
+ declare const LP_VAULT_ABI: string[];
928
+ declare const AGENT_REPUTATION_ABI: string[];
929
+ declare const VALIDATION_REGISTRY_ABI: string[];
930
+ declare const ERC20_ABI: string[];
931
+
932
+ export { ACCOUNT_FACTORY_ABI, AGENT_ACCOUNT_ABI, AGENT_REPUTATION_ABI, AgentIdentityClient, type AgentIdentityClientOptions, type AgentReputation, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type BayesianScore, CREDIT_PROVIDER_ABI, ChainId, type ContractAddresses, type CreditApplication, type CreditAppliedEvent, type CreditApprovedEvent, type CreditDrawnEvent, type CreditInfo, type CreditLine, CreditNotActiveError, type CreditRejectedEvent, type CreditRepaidEvent, CreditStatus, type DrawRequest, ERC20_ABI, type GraduationStatus, IDENTITY_REGISTRY_ABI, InsufficientCreditError, type LPPosition, LP_VAULT_ABI, type LoanPosition, type MorphoMarketParams, type PaymentProof, type PaymentRequirements, type ProviderStatus, REPUTATION_CREDIT_ABI, type RepayRequest, type RiskCheckResponse, type RiskFactor, type ScoreExplanation, type ScoredLimitPreview, ScoringClient, type ScoringContext, ScoringRejectedError, type ScoringRequest, type ScoringResult, type TransactionResult, VALIDATION_REGISTRY_ABI, VaultClient, type VaultClientOptions, type VaultStats, WalletClient, type WalletClientConfig, type WalletInfo, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getDefaultConfig, getUSDCAddress, parseUnits, rateToBps };