@auteng/agent-utils 0.1.0 → 0.1.1

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 (2) hide show
  1. package/README.md +82 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @auteng/agent-utils
2
+
3
+ Utility belt for autonomous AI agents — wallet, compute, and x402 payments.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @auteng/agent-utils
9
+ ```
10
+
11
+ ## Wallet
12
+
13
+ Create a crypto wallet (USDC on Base) so your agent can pay for x402 services:
14
+
15
+ ```typescript
16
+ import { wallet } from '@auteng/agent-utils';
17
+
18
+ await wallet.create();
19
+ console.log(wallet.address); // 0xABC...
20
+ ```
21
+
22
+ This generates an EVM keypair and stores it at `.auteng/wallet.json`. If a wallet already exists, it loads it.
23
+
24
+ ### Check balance
25
+
26
+ ```typescript
27
+ const balance = await wallet.checkBalance();
28
+ // Returns USDC balance in minor units (6 decimals)
29
+ // e.g., 10_000000n = $10.00
30
+ ```
31
+
32
+ ### Wait for funding
33
+
34
+ ```typescript
35
+ await wallet.waitForFunding(10_000000n);
36
+ // Polls every 10s until >= 10 USDC is available
37
+ ```
38
+
39
+ ### x402 fetch
40
+
41
+ Drop-in `fetch()` replacement that handles x402 payments automatically:
42
+
43
+ ```typescript
44
+ const res = await wallet.fetch('https://x402.auteng.ai/api/x402/compute', {
45
+ method: 'POST',
46
+ body: JSON.stringify({ code: 'print("hi")', stack: 'python', size: 'small' }),
47
+ });
48
+ ```
49
+
50
+ If the server returns `402 Payment Required`, the library signs an EIP-3009 authorization and retries with payment headers.
51
+
52
+ ## Compute
53
+
54
+ Run sandboxed code via AutEng's x402 compute endpoint:
55
+
56
+ ```typescript
57
+ import { compute } from '@auteng/agent-utils';
58
+
59
+ const result = await compute.run({
60
+ code: 'print("hello world")',
61
+ stack: 'python', // 'python' | 'node'
62
+ size: 'small', // 'small' | 'med' | 'large'
63
+ });
64
+ console.log(result.stdout); // "hello world\n"
65
+ ```
66
+
67
+ ### Pricing
68
+
69
+ ```typescript
70
+ compute.pricing();
71
+ // { small: { base_price_usd: 0.002, ... }, med: { ... }, large: { ... } }
72
+ ```
73
+
74
+ | Size | vCPU | RAM | Base price | Per second |
75
+ |-------|------|------|-----------|------------|
76
+ | small | 2 | 1 GB | $0.002 | $0.00005 |
77
+ | med | 4 | 4 GB | $0.008 | $0.00012 |
78
+ | large | 8 | 16 GB| $0.03 | $0.00025 |
79
+
80
+ ## License
81
+
82
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auteng/agent-utils",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Utility belt for autonomous AI agents — wallet, compute, and more",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -13,7 +13,8 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "README.md"
17
18
  ],
18
19
  "scripts": {
19
20
  "build": "tsup",