@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,75 @@
1
+ /**
2
+ * Formatting utilities
3
+ */
4
+ /**
5
+ * Parse units (e.g., "100" USDC -> 100000000n)
6
+ */
7
+ export function parseUnits(value, decimals = 6) {
8
+ const [integer, fraction = ''] = value.split('.');
9
+ const paddedFraction = fraction.padEnd(decimals, '0').slice(0, decimals);
10
+ return BigInt(integer + paddedFraction);
11
+ }
12
+ /**
13
+ * Format units (e.g., 100000000n -> "100.00" USDC)
14
+ */
15
+ export function formatUnits(value, decimals = 6) {
16
+ const str = value.toString().padStart(decimals + 1, '0');
17
+ const integer = str.slice(0, -decimals) || '0';
18
+ const fraction = str.slice(-decimals);
19
+ return `${integer}.${fraction}`;
20
+ }
21
+ /**
22
+ * Format USD value
23
+ */
24
+ export function formatUSD(value, decimals = 6) {
25
+ const num = Number(formatUnits(value, decimals));
26
+ return new Intl.NumberFormat('en-US', {
27
+ style: 'currency',
28
+ currency: 'USD',
29
+ }).format(num);
30
+ }
31
+ /**
32
+ * Format percentage
33
+ */
34
+ export function formatPercent(bps) {
35
+ return `${(bps / 100).toFixed(2)}%`;
36
+ }
37
+ /**
38
+ * Format APR from basis points
39
+ */
40
+ export function formatAPR(bps) {
41
+ return formatPercent(Number(bps));
42
+ }
43
+ /**
44
+ * Calculate health factor display
45
+ */
46
+ export function formatHealthFactor(factor) {
47
+ const num = Number(factor) / 1e18;
48
+ if (num >= 100)
49
+ return '∞';
50
+ return num.toFixed(2);
51
+ }
52
+ /**
53
+ * Format address (truncate)
54
+ */
55
+ export function formatAddress(address) {
56
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
57
+ }
58
+ /**
59
+ * Format timestamp to date
60
+ */
61
+ export function formatTimestamp(timestamp) {
62
+ return new Date(Number(timestamp) * 1000).toISOString();
63
+ }
64
+ /**
65
+ * Convert basis points to decimal rate
66
+ */
67
+ export function bpsToRate(bps) {
68
+ return Number(bps) / 10000;
69
+ }
70
+ /**
71
+ * Convert decimal rate to basis points
72
+ */
73
+ export function rateToBps(rate) {
74
+ return BigInt(Math.round(rate * 10000));
75
+ }
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@agether/sdk",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript SDK for Agether - autonomous credit for AI agents on Base",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "agether": "./dist/cli.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsup src/index.ts --format cjs,esm --dts && tsup src/cli.ts --format cjs --no-dts --target node20",
23
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
24
+ "test": "vitest",
25
+ "test:coverage": "vitest --coverage",
26
+ "lint": "eslint src/",
27
+ "typecheck": "tsc --noEmit",
28
+ "clean": "rm -rf dist"
29
+ },
30
+ "dependencies": {
31
+ "axios": "^1.6.0",
32
+ "ethers": "^6.9.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^20.10.0",
36
+ "@typescript-eslint/eslint-plugin": "^6.13.0",
37
+ "@typescript-eslint/parser": "^6.13.0",
38
+ "eslint": "^8.55.0",
39
+ "tsup": "^8.0.0",
40
+ "tsx": "^4.21.0",
41
+ "typescript": "^5.3.0",
42
+ "vitest": "^1.0.0"
43
+ },
44
+ "keywords": [
45
+ "agether",
46
+ "ai-agents",
47
+ "credit",
48
+ "ethereum",
49
+ "x402",
50
+ "defi"
51
+ ],
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "https://gitlab.sre.ideasoft.io/rdinternal/agent-credit-protocol"
55
+ },
56
+ "license": "MIT"
57
+ }