@auteng/agent-utils 0.3.0 → 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.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @auteng/agent-utils
2
2
 
3
- Give your AI agent its own crypto wallets. Create purpose-specific wallets funded with USDC on Base, then let the agent spend autonomously on x402-enabled services like sandboxed compute. No accounts, no KYC just wallet addresses and USDC.
3
+ x402 payments and sandboxed compute for autonomous AI agents. Discover, probe, and pay for x402-enabled services, and run sandboxed compute — all with USDC on Base.
4
+
5
+ > **Wallet management** has moved to [`@auteng/pocket-money`](https://www.npmjs.com/package/@auteng/pocket-money). This package focuses on x402 protocol tools and compute. Agents can use any wallet — pocket-money, Coinbase Agentic Wallet, viem, ethers, or raw key management.
4
6
 
5
7
  ## Install
6
8
 
@@ -11,93 +13,68 @@ npm install @auteng/agent-utils
11
13
  ## Quick Start
12
14
 
13
15
  ```typescript
14
- import { wallet, compute } from '@auteng/agent-utils';
15
-
16
- // 1. Create a wallet for this task
17
- const w = await wallet.create({ name: "my-task" });
18
- console.log(`Fund me: send USDC on Base to ${w.address}`);
16
+ import { x402, compute } from '@auteng/agent-utils';
19
17
 
20
- // 2. Wait for funding
21
- await w.waitForFunding(5_000000n); // wait for $5 USDC
22
-
23
- // 3. Run sandboxed code (payment handled automatically)
24
- const result = await compute.run({
25
- code: 'print("hello from the sandbox")',
26
- stack: 'python',
27
- wallet: w,
28
- });
29
- console.log(result.stdout);
18
+ // Probe any URL to check if it's x402-enabled
19
+ const info = await x402.probe('https://api.example.com/generate');
20
+ console.log(info.price); // "$0.05 USDC on Base"
30
21
  ```
31
22
 
32
- ## Wallets
23
+ ## x402 — Discover & Inspect Services
33
24
 
34
- Each wallet is an independent keypair with its own address and balance. Create as many as you need — one per task, one per month, one per budget.
25
+ Standalone functions for working with x402 services.
35
26
 
36
- ```typescript
37
- import { wallet } from '@auteng/agent-utils';
27
+ ### Probe a URL
38
28
 
39
- const monthly = await wallet.create({ name: "feb-2026" });
40
- const task = await wallet.create({ name: "data-pipeline" });
41
- const dev = await wallet.create({ name: "testnet", network: "base-sepolia" });
42
- ```
43
-
44
- Wallets are persisted at `.auteng/wallets/<name>.json`. Creating a wallet that already exists loads it from disk.
45
-
46
- ### Check balance
29
+ Check if a URL is x402-enabled and see what it costs:
47
30
 
48
31
  ```typescript
49
- const balance = await monthly.checkBalance();
50
- // Returns USDC in minor units (6 decimals)
51
- // 10_000000n = $10.00 USDC
52
- ```
32
+ import { x402 } from '@auteng/agent-utils';
53
33
 
54
- ### Wait for funding
55
-
56
- ```typescript
57
- await monthly.waitForFunding(10_000000n);
58
- // Polls Base every 10s until >= $10 USDC is available
34
+ const info = await x402.probe('https://api.example.com/generate');
35
+ if (info.enabled) {
36
+ console.log(info.price); // "$0.05 USDC on Base"
37
+ console.log(info.paymentRequired.accepts[0]); // full payment details
38
+ console.log(info.paymentRequired.resource); // what you're paying for
39
+ }
59
40
  ```
60
41
 
61
- ### x402 fetch
42
+ ### Discover services
62
43
 
63
- Drop-in `fetch()` replacement that handles x402 payments automatically:
44
+ Browse the [Bazaar](https://www.x402.org/) registry to find x402 services:
64
45
 
65
46
  ```typescript
66
- const res = await monthly.fetch('https://x402.auteng.ai/api/x402/compute', {
67
- method: 'POST',
68
- headers: { 'Content-Type': 'application/json' },
69
- body: JSON.stringify({ code: 'print("hi")', stack: 'python', size: 'small' }),
70
- });
47
+ const { services, total } = await x402.discover({ limit: 10 });
48
+ for (const svc of services) {
49
+ console.log(`${svc.description} ${svc.price}`);
50
+ console.log(` ${svc.url}`);
51
+ }
71
52
  ```
72
53
 
73
- If the server returns `402 Payment Required`, the library signs an EIP-3009 authorization and retries with payment headers. No gas needed.
54
+ ### Format prices
74
55
 
75
- ### Retrieve and list wallets
56
+ Convert raw x402 amounts to human-readable strings:
76
57
 
77
58
  ```typescript
78
- const w = wallet.get("feb-2026"); // load by name
79
- const all = wallet.list(); // list all wallets
59
+ x402.formatPrice("2000", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "eip155:8453");
60
+ // "$0.002 USDC on Base"
80
61
 
81
- for (const w of all) {
82
- const bal = await w.checkBalance();
83
- console.log(`${w.name}: ${w.address} — ${bal} USDC`);
84
- }
62
+ x402.formatPrice("2000", "0x833589f...", "eip155:8453", { short: true });
63
+ // "$0.002 USDC"
85
64
  ```
86
65
 
87
- ## Compute
66
+ ## Compute (AutEng)
88
67
 
89
- Run sandboxed code via AutEng's x402 compute endpoint. Pass a wallet to pay for execution:
68
+ Convenience wrapper for AutEng's x402 sandboxed compute service. Accepts any object with a `fetch()` method as the wallet:
90
69
 
91
70
  ```typescript
92
- import { wallet, compute } from '@auteng/agent-utils';
93
-
94
- const w = await wallet.create({ name: "compute-budget" });
71
+ import { compute } from '@auteng/agent-utils';
95
72
 
96
73
  const result = await compute.run({
97
74
  code: 'print("hello world")',
98
75
  stack: 'python', // 'python' | 'node'
99
76
  size: 'small', // 'small' | 'med' | 'large'
100
- wallet: w,
77
+ wallet: myWallet, // any object with fetch()
101
78
  });
102
79
  console.log(result.stdout); // "hello world\n"
103
80
  ```
@@ -114,73 +91,12 @@ console.log(result.stdout); // "hello world\n"
114
91
  compute.pricing(); // returns full pricing table
115
92
  ```
116
93
 
117
- ## Demo
118
-
119
- Run the included demo to see everything in action — wallet creation, funding, and autonomous compute:
120
-
121
- ```bash
122
- node demo.mjs
123
- ```
124
-
125
- ```
126
- ────────────────────────────────────────────────────────
127
- POCKET MONEY DEMO — autonomous compute with x402
128
- ────────────────────────────────────────────────────────
129
-
130
- Compute pricing:
131
- small → $0.002 base + $0.00005/s (2 vCPU, 1GB RAM)
132
- med → $0.008 base + $0.00012/s (4 vCPU, 4GB RAM)
133
- large → $0.03 base + $0.00025/s (8 vCPU, 16GB RAM)
134
-
135
- Wallet: "demo-compute"
136
- Address: 0x9cc8...e18
137
- Balance: $0.0000
138
- ────────────────────────────────────────────────────────
139
-
140
- This wallet needs at least $1.0000 USDC to run the demo.
141
-
142
- Please send USDC on **Base** to:
143
- 0x9cc8...e18
144
-
145
- Waiting for funds...
146
- Funded! New balance: $1.0000
147
- ────────────────────────────────────────────────────────
148
-
149
- Running compute jobs...
150
-
151
- ▸ Python — Fibonacci
152
- fib(10) = 55
153
- fib(20) = 6765
154
- fib(30) = 832040
155
- fib(40) = 102334155
156
- fib(50) = 12586269025
157
-
158
- ▸ Python — System info
159
- Python 3.12.12
160
- OS: Linux 6.1.158
161
- Arch: x86_64
162
- CPUs: 2
163
-
164
- ▸ Node — UUID generation
165
- f8b260ec-2dea-401b-b807-544f366a8588
166
- 8eb115bb-e943-455b-b675-a177ed2c5e81
167
- ...
168
-
169
- Starting balance: $1.0000
170
- Final balance: $0.9980
171
- Spent: $0.0020
172
- ────────────────────────────────────────────────────────
173
- Done!
174
- ```
175
-
176
- The demo creates a wallet, waits for you to fund it with $1 USDC on Base, then runs three sandboxed compute jobs (Python + Node) — all paid automatically via x402. Total cost: ~$0.002.
177
-
178
94
  ## Development
179
95
 
180
96
  ```bash
181
97
  npm install # install dependencies
182
98
  npm run build # build CJS/ESM/DTS to dist/
183
- npm test # run unit + integration tests
99
+ npm test # run tests
184
100
  npm run test:watch # run tests in watch mode
185
101
  ```
186
102
 
package/dist/index.d.mts CHANGED
@@ -1,82 +1,16 @@
1
- import { PrivateKeyAccount } from 'viem';
2
-
3
- type Network = "base" | "base-sepolia";
4
- interface CreateWalletOptions {
5
- /** Wallet identifier. Default: "default" */
6
- name?: string;
7
- /** Network to use. Default: `base` */
8
- network?: Network;
9
- /** Custom RPC endpoint. Default: public Base RPC */
10
- rpcUrl?: string;
11
- /** Base directory for wallet storage. Default: ".auteng/wallets" */
12
- walletsDir?: string;
13
- }
14
- /** @deprecated Use CreateWalletOptions instead */
15
- type WalletConfig = CreateWalletOptions;
16
- interface WaitForFundingOptions {
17
- /** Poll interval in milliseconds. Default: 10000 (10s) */
18
- pollInterval?: number;
19
- /** Timeout in milliseconds. Default: none (waits forever) */
20
- timeout?: number;
21
- }
22
-
23
- declare class Wallet {
24
- readonly name: string;
25
- readonly address: `0x${string}`;
26
- readonly network: Network;
27
- private _account;
28
- private _privateKey;
29
- private _rpcUrl;
30
- private _paymentFetch;
31
- constructor(params: {
32
- name: string;
33
- account: PrivateKeyAccount;
34
- privateKey: `0x${string}`;
35
- network: Network;
36
- rpcUrl?: string;
37
- paymentFetch: typeof globalThis.fetch;
38
- });
39
- /** Check USDC balance on Base. Returns balance in minor units (6 decimals). */
40
- checkBalance(): Promise<bigint>;
41
- /**
42
- * Poll until USDC balance >= minAmount.
43
- * @param minAmount - minimum USDC balance in minor units (6 decimals)
44
- */
45
- waitForFunding(minAmount: bigint, opts?: WaitForFundingOptions): Promise<void>;
46
- /**
47
- * Drop-in `fetch()` replacement that handles x402 payments automatically.
48
- * If the server returns 402, the library signs an EIP-3009 authorization
49
- * and retries the request with payment headers.
50
- */
51
- fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
52
- }
53
-
54
- declare const wallet: {
55
- /**
56
- * Create a new named wallet or load an existing one from disk.
57
- * Idempotent: if a wallet with this name already exists, returns it.
58
- */
59
- create(opts?: CreateWalletOptions): Promise<Wallet>;
60
- /**
61
- * Retrieve a previously-created wallet by name.
62
- * Loads from disk if not in memory. Throws if not found.
63
- */
64
- get(name: string): Wallet;
65
- /** List all persisted wallets. */
66
- list(): Wallet[];
67
- /** @internal Clear in-memory cache and reset wallets dir. For testing only. */
68
- _reset(): void;
69
- };
70
-
71
1
  type Stack = "python" | "node";
72
2
  type Size = "small" | "med" | "large";
3
+ /** Any object with a fetch method — pocket-money Wallet, custom wrapper, etc. */
4
+ interface ComputeWallet {
5
+ fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
6
+ }
73
7
  interface ComputeRequest {
74
8
  /** The code to execute */
75
9
  code: string;
76
10
  /** Runtime stack: 'python' (3.14) or 'node' (24 LTS) */
77
11
  stack: Stack;
78
- /** The wallet to pay from */
79
- wallet: Wallet;
12
+ /** The wallet to pay from — any object with a fetch() method */
13
+ wallet: ComputeWallet;
80
14
  /** Sandbox size. Default: 'small' */
81
15
  size?: Size;
82
16
  /** Execution timeout in seconds. Default: per-size default */
@@ -114,4 +48,121 @@ declare const compute: {
114
48
  setEndpoint(url: string): void;
115
49
  };
116
50
 
117
- export { type ComputeRequest, type ComputeResponse, type CreateWalletOptions, type Network, type PricingTier, type Size, type Stack, type WaitForFundingOptions, Wallet, type WalletConfig, compute, wallet };
51
+ type Network = "base" | "base-sepolia";
52
+ /** A single accepted payment option from a 402 response. */
53
+ interface PaymentOption {
54
+ scheme: string;
55
+ network: string;
56
+ asset: string;
57
+ /** Raw amount in minor units (e.g. "2000" = $0.002 USDC). */
58
+ amount: string;
59
+ payTo: string;
60
+ maxTimeoutSeconds: number;
61
+ extra?: Record<string, unknown>;
62
+ }
63
+ /** Normalized 402 response (works across v1 and v2). */
64
+ interface PaymentRequiredResponse {
65
+ x402Version: number;
66
+ resource: {
67
+ url: string;
68
+ description?: string;
69
+ mimeType?: string;
70
+ };
71
+ accepts: PaymentOption[];
72
+ extensions?: Record<string, unknown>;
73
+ }
74
+ /** Result of probing a URL for x402 payment requirements. */
75
+ interface ProbeResult {
76
+ /** Whether the URL returned 402 Payment Required. */
77
+ enabled: boolean;
78
+ /** The URL that was probed. */
79
+ url: string;
80
+ /** HTTP status code returned. */
81
+ status: number;
82
+ /** Human-readable price summary, e.g. "$0.002 USDC on Base". Null if not x402. */
83
+ price: string | null;
84
+ /** The parsed 402 response body. Null if not x402. */
85
+ paymentRequired: PaymentRequiredResponse | null;
86
+ }
87
+ interface ProbeOptions {
88
+ /** HTTP method to use. Default: "GET". */
89
+ method?: string;
90
+ /** Request headers to include. */
91
+ headers?: Record<string, string>;
92
+ /** Request body (for POST endpoints). */
93
+ body?: string;
94
+ /** Abort signal for timeout control. */
95
+ signal?: AbortSignal;
96
+ }
97
+ /** A service listed in the Bazaar registry. */
98
+ interface BazaarService {
99
+ /** The service endpoint URL. */
100
+ url: string;
101
+ /** Service description. */
102
+ description: string | null;
103
+ /** Human-readable price of the cheapest accept option. */
104
+ price: string;
105
+ /** All accepted payment options. */
106
+ accepts: PaymentOption[];
107
+ /** Raw metadata from the Bazaar. */
108
+ metadata: Record<string, unknown>;
109
+ }
110
+ interface DiscoverResult {
111
+ services: BazaarService[];
112
+ total: number;
113
+ }
114
+ interface DiscoverOptions {
115
+ /** Max results to return. Default: 20. */
116
+ limit?: number;
117
+ /** Pagination offset. Default: 0. */
118
+ offset?: number;
119
+ /** Bazaar API base URL. Override for testing. */
120
+ bazaarUrl?: string;
121
+ /** Abort signal for timeout control. */
122
+ signal?: AbortSignal;
123
+ }
124
+ interface FormatPriceOptions {
125
+ /** If true, omit the network suffix (e.g. "$0.002 USDC" instead of "$0.002 USDC on Base"). */
126
+ short?: boolean;
127
+ }
128
+
129
+ /**
130
+ * Check if a URL is x402-enabled and see what it costs, without paying.
131
+ *
132
+ * Sends a request to the URL. If the server returns 402 Payment Required,
133
+ * parses the payment requirements and returns a structured result with
134
+ * human-readable pricing. Non-402 responses return `{ enabled: false }`.
135
+ *
136
+ * No wallet needed — this is a read-only inspection.
137
+ */
138
+ declare function probe(url: string, options?: ProbeOptions): Promise<ProbeResult>;
139
+
140
+ /**
141
+ * Query the Bazaar registry to find available x402 services.
142
+ *
143
+ * Fetches from the Coinbase CDP Bazaar discovery endpoint and returns
144
+ * a normalized list of services with human-readable pricing.
145
+ *
146
+ * No wallet or authentication needed.
147
+ */
148
+ declare function discover(options?: DiscoverOptions): Promise<DiscoverResult>;
149
+
150
+ /**
151
+ * Format a raw x402 price into a human-readable string.
152
+ *
153
+ * Knows about common assets (USDC on Base = 6 decimals, $-prefixed)
154
+ * and falls back to raw display for unknown assets.
155
+ *
156
+ * @example
157
+ * formatPrice("2000", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "eip155:8453")
158
+ * // → "$0.002 USDC on Base"
159
+ */
160
+ declare function formatPrice(amount: string, asset: string, network: string, options?: FormatPriceOptions): string;
161
+
162
+ declare const x402: {
163
+ probe: typeof probe;
164
+ discover: typeof discover;
165
+ formatPrice: typeof formatPrice;
166
+ };
167
+
168
+ export { type BazaarService, type ComputeRequest, type ComputeResponse, type ComputeWallet, type DiscoverOptions, type DiscoverResult, type FormatPriceOptions, type Network, type PaymentOption, type PaymentRequiredResponse, type PricingTier, type ProbeOptions, type ProbeResult, type Size, type Stack, compute, x402 };
package/dist/index.d.ts CHANGED
@@ -1,82 +1,16 @@
1
- import { PrivateKeyAccount } from 'viem';
2
-
3
- type Network = "base" | "base-sepolia";
4
- interface CreateWalletOptions {
5
- /** Wallet identifier. Default: "default" */
6
- name?: string;
7
- /** Network to use. Default: `base` */
8
- network?: Network;
9
- /** Custom RPC endpoint. Default: public Base RPC */
10
- rpcUrl?: string;
11
- /** Base directory for wallet storage. Default: ".auteng/wallets" */
12
- walletsDir?: string;
13
- }
14
- /** @deprecated Use CreateWalletOptions instead */
15
- type WalletConfig = CreateWalletOptions;
16
- interface WaitForFundingOptions {
17
- /** Poll interval in milliseconds. Default: 10000 (10s) */
18
- pollInterval?: number;
19
- /** Timeout in milliseconds. Default: none (waits forever) */
20
- timeout?: number;
21
- }
22
-
23
- declare class Wallet {
24
- readonly name: string;
25
- readonly address: `0x${string}`;
26
- readonly network: Network;
27
- private _account;
28
- private _privateKey;
29
- private _rpcUrl;
30
- private _paymentFetch;
31
- constructor(params: {
32
- name: string;
33
- account: PrivateKeyAccount;
34
- privateKey: `0x${string}`;
35
- network: Network;
36
- rpcUrl?: string;
37
- paymentFetch: typeof globalThis.fetch;
38
- });
39
- /** Check USDC balance on Base. Returns balance in minor units (6 decimals). */
40
- checkBalance(): Promise<bigint>;
41
- /**
42
- * Poll until USDC balance >= minAmount.
43
- * @param minAmount - minimum USDC balance in minor units (6 decimals)
44
- */
45
- waitForFunding(minAmount: bigint, opts?: WaitForFundingOptions): Promise<void>;
46
- /**
47
- * Drop-in `fetch()` replacement that handles x402 payments automatically.
48
- * If the server returns 402, the library signs an EIP-3009 authorization
49
- * and retries the request with payment headers.
50
- */
51
- fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
52
- }
53
-
54
- declare const wallet: {
55
- /**
56
- * Create a new named wallet or load an existing one from disk.
57
- * Idempotent: if a wallet with this name already exists, returns it.
58
- */
59
- create(opts?: CreateWalletOptions): Promise<Wallet>;
60
- /**
61
- * Retrieve a previously-created wallet by name.
62
- * Loads from disk if not in memory. Throws if not found.
63
- */
64
- get(name: string): Wallet;
65
- /** List all persisted wallets. */
66
- list(): Wallet[];
67
- /** @internal Clear in-memory cache and reset wallets dir. For testing only. */
68
- _reset(): void;
69
- };
70
-
71
1
  type Stack = "python" | "node";
72
2
  type Size = "small" | "med" | "large";
3
+ /** Any object with a fetch method — pocket-money Wallet, custom wrapper, etc. */
4
+ interface ComputeWallet {
5
+ fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
6
+ }
73
7
  interface ComputeRequest {
74
8
  /** The code to execute */
75
9
  code: string;
76
10
  /** Runtime stack: 'python' (3.14) or 'node' (24 LTS) */
77
11
  stack: Stack;
78
- /** The wallet to pay from */
79
- wallet: Wallet;
12
+ /** The wallet to pay from — any object with a fetch() method */
13
+ wallet: ComputeWallet;
80
14
  /** Sandbox size. Default: 'small' */
81
15
  size?: Size;
82
16
  /** Execution timeout in seconds. Default: per-size default */
@@ -114,4 +48,121 @@ declare const compute: {
114
48
  setEndpoint(url: string): void;
115
49
  };
116
50
 
117
- export { type ComputeRequest, type ComputeResponse, type CreateWalletOptions, type Network, type PricingTier, type Size, type Stack, type WaitForFundingOptions, Wallet, type WalletConfig, compute, wallet };
51
+ type Network = "base" | "base-sepolia";
52
+ /** A single accepted payment option from a 402 response. */
53
+ interface PaymentOption {
54
+ scheme: string;
55
+ network: string;
56
+ asset: string;
57
+ /** Raw amount in minor units (e.g. "2000" = $0.002 USDC). */
58
+ amount: string;
59
+ payTo: string;
60
+ maxTimeoutSeconds: number;
61
+ extra?: Record<string, unknown>;
62
+ }
63
+ /** Normalized 402 response (works across v1 and v2). */
64
+ interface PaymentRequiredResponse {
65
+ x402Version: number;
66
+ resource: {
67
+ url: string;
68
+ description?: string;
69
+ mimeType?: string;
70
+ };
71
+ accepts: PaymentOption[];
72
+ extensions?: Record<string, unknown>;
73
+ }
74
+ /** Result of probing a URL for x402 payment requirements. */
75
+ interface ProbeResult {
76
+ /** Whether the URL returned 402 Payment Required. */
77
+ enabled: boolean;
78
+ /** The URL that was probed. */
79
+ url: string;
80
+ /** HTTP status code returned. */
81
+ status: number;
82
+ /** Human-readable price summary, e.g. "$0.002 USDC on Base". Null if not x402. */
83
+ price: string | null;
84
+ /** The parsed 402 response body. Null if not x402. */
85
+ paymentRequired: PaymentRequiredResponse | null;
86
+ }
87
+ interface ProbeOptions {
88
+ /** HTTP method to use. Default: "GET". */
89
+ method?: string;
90
+ /** Request headers to include. */
91
+ headers?: Record<string, string>;
92
+ /** Request body (for POST endpoints). */
93
+ body?: string;
94
+ /** Abort signal for timeout control. */
95
+ signal?: AbortSignal;
96
+ }
97
+ /** A service listed in the Bazaar registry. */
98
+ interface BazaarService {
99
+ /** The service endpoint URL. */
100
+ url: string;
101
+ /** Service description. */
102
+ description: string | null;
103
+ /** Human-readable price of the cheapest accept option. */
104
+ price: string;
105
+ /** All accepted payment options. */
106
+ accepts: PaymentOption[];
107
+ /** Raw metadata from the Bazaar. */
108
+ metadata: Record<string, unknown>;
109
+ }
110
+ interface DiscoverResult {
111
+ services: BazaarService[];
112
+ total: number;
113
+ }
114
+ interface DiscoverOptions {
115
+ /** Max results to return. Default: 20. */
116
+ limit?: number;
117
+ /** Pagination offset. Default: 0. */
118
+ offset?: number;
119
+ /** Bazaar API base URL. Override for testing. */
120
+ bazaarUrl?: string;
121
+ /** Abort signal for timeout control. */
122
+ signal?: AbortSignal;
123
+ }
124
+ interface FormatPriceOptions {
125
+ /** If true, omit the network suffix (e.g. "$0.002 USDC" instead of "$0.002 USDC on Base"). */
126
+ short?: boolean;
127
+ }
128
+
129
+ /**
130
+ * Check if a URL is x402-enabled and see what it costs, without paying.
131
+ *
132
+ * Sends a request to the URL. If the server returns 402 Payment Required,
133
+ * parses the payment requirements and returns a structured result with
134
+ * human-readable pricing. Non-402 responses return `{ enabled: false }`.
135
+ *
136
+ * No wallet needed — this is a read-only inspection.
137
+ */
138
+ declare function probe(url: string, options?: ProbeOptions): Promise<ProbeResult>;
139
+
140
+ /**
141
+ * Query the Bazaar registry to find available x402 services.
142
+ *
143
+ * Fetches from the Coinbase CDP Bazaar discovery endpoint and returns
144
+ * a normalized list of services with human-readable pricing.
145
+ *
146
+ * No wallet or authentication needed.
147
+ */
148
+ declare function discover(options?: DiscoverOptions): Promise<DiscoverResult>;
149
+
150
+ /**
151
+ * Format a raw x402 price into a human-readable string.
152
+ *
153
+ * Knows about common assets (USDC on Base = 6 decimals, $-prefixed)
154
+ * and falls back to raw display for unknown assets.
155
+ *
156
+ * @example
157
+ * formatPrice("2000", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "eip155:8453")
158
+ * // → "$0.002 USDC on Base"
159
+ */
160
+ declare function formatPrice(amount: string, asset: string, network: string, options?: FormatPriceOptions): string;
161
+
162
+ declare const x402: {
163
+ probe: typeof probe;
164
+ discover: typeof discover;
165
+ formatPrice: typeof formatPrice;
166
+ };
167
+
168
+ export { type BazaarService, type ComputeRequest, type ComputeResponse, type ComputeWallet, type DiscoverOptions, type DiscoverResult, type FormatPriceOptions, type Network, type PaymentOption, type PaymentRequiredResponse, type PricingTier, type ProbeOptions, type ProbeResult, type Size, type Stack, compute, x402 };