@coinbase/agentkit 0.10.3 → 0.10.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 (55) hide show
  1. package/README.md +47 -10
  2. package/dist/action-providers/across/acrossActionProvider.js +2 -4
  3. package/dist/action-providers/across/acrossActionProvider.test.js +10 -5
  4. package/dist/action-providers/baseAccount/baseAccountActionProvider.js +5 -7
  5. package/dist/action-providers/clanker/utils.d.ts +2 -1
  6. package/dist/action-providers/clanker/utils.js +2 -2
  7. package/dist/action-providers/index.d.ts +1 -0
  8. package/dist/action-providers/index.js +1 -0
  9. package/dist/action-providers/jupiter/jupiterActionProvider.js +2 -2
  10. package/dist/action-providers/spl/splActionProvider.js +12 -13
  11. package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.js +2 -2
  12. package/dist/action-providers/sushi/constants.d.ts +35 -0
  13. package/dist/action-providers/sushi/constants.js +7 -0
  14. package/dist/action-providers/sushi/index.d.ts +4 -0
  15. package/dist/action-providers/sushi/index.js +20 -0
  16. package/dist/action-providers/sushi/sushiDataActionProvider.d.ts +32 -0
  17. package/dist/action-providers/sushi/sushiDataActionProvider.js +113 -0
  18. package/dist/action-providers/sushi/sushiDataSchemas.d.ts +11 -0
  19. package/dist/action-providers/sushi/sushiDataSchemas.js +16 -0
  20. package/dist/action-providers/sushi/sushiRouterActionProvider.d.ts +40 -0
  21. package/dist/action-providers/sushi/sushiRouterActionProvider.js +386 -0
  22. package/dist/action-providers/sushi/sushiRouterActionProvider.test.d.ts +1 -0
  23. package/dist/action-providers/sushi/sushiRouterActionProvider.test.js +392 -0
  24. package/dist/action-providers/sushi/sushiRouterSchemas.d.ts +36 -0
  25. package/dist/action-providers/sushi/sushiRouterSchemas.js +55 -0
  26. package/dist/action-providers/vaultsfyi/constants.d.ts +8 -12
  27. package/dist/action-providers/vaultsfyi/constants.js +47 -13
  28. package/dist/action-providers/vaultsfyi/schemas.d.ts +120 -65
  29. package/dist/action-providers/vaultsfyi/schemas.js +72 -38
  30. package/dist/action-providers/vaultsfyi/sdk.d.ts +8 -0
  31. package/dist/action-providers/vaultsfyi/sdk.js +15 -0
  32. package/dist/action-providers/vaultsfyi/utils.d.ts +151 -55
  33. package/dist/action-providers/vaultsfyi/utils.js +29 -75
  34. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.d.ts +55 -16
  35. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.js +413 -217
  36. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.test.js +509 -316
  37. package/dist/action-providers/x402/constants.d.ts +67 -0
  38. package/dist/action-providers/x402/constants.js +37 -0
  39. package/dist/action-providers/x402/schemas.d.ts +45 -5
  40. package/dist/action-providers/x402/schemas.js +81 -11
  41. package/dist/action-providers/x402/utils.d.ts +85 -10
  42. package/dist/action-providers/x402/utils.js +302 -35
  43. package/dist/action-providers/x402/x402ActionProvider.d.ts +15 -1
  44. package/dist/action-providers/x402/x402ActionProvider.js +230 -179
  45. package/dist/action-providers/x402/x402ActionProvider.test.js +222 -262
  46. package/dist/action-providers/zora/zoraActionProvider.js +4 -5
  47. package/package.json +10 -7
  48. package/dist/action-providers/vaultsfyi/api/actions.d.ts +0 -41
  49. package/dist/action-providers/vaultsfyi/api/actions.js +0 -28
  50. package/dist/action-providers/vaultsfyi/api/historicalData.d.ts +0 -31
  51. package/dist/action-providers/vaultsfyi/api/historicalData.js +0 -44
  52. package/dist/action-providers/vaultsfyi/api/types.d.ts +0 -34
  53. package/dist/action-providers/vaultsfyi/api/types.js +0 -2
  54. package/dist/action-providers/vaultsfyi/api/vaults.d.ts +0 -66
  55. package/dist/action-providers/vaultsfyi/api/vaults.js +0 -57
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Known facilitator registry
3
+ */
4
+ export declare const KNOWN_FACILITATORS: {
5
+ readonly cdp: "https://api.cdp.coinbase.com/platform/v2/x402";
6
+ readonly payai: "https://facilitator.payai.network";
7
+ };
8
+ export type KnownFacilitatorName = keyof typeof KNOWN_FACILITATORS;
9
+ export declare const DEFAULT_FACILITATOR: KnownFacilitatorName;
10
+ /**
11
+ * Supported networks for x402 payment protocol
12
+ */
13
+ export declare const SUPPORTED_NETWORKS: readonly ["base-mainnet", "base-sepolia", "solana-mainnet", "solana-devnet"];
14
+ /**
15
+ * USDC token addresses for Solana networks
16
+ */
17
+ export declare const SOLANA_USDC_ADDRESSES: {
18
+ readonly "solana-devnet": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
19
+ readonly "solana-mainnet": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
20
+ };
21
+ /**
22
+ * Network mapping from internal network ID to both v1 and v2 (CAIP-2) formats.
23
+ * Used for filtering discovery results that may contain either format.
24
+ */
25
+ export declare const NETWORK_MAPPINGS: Record<string, string[]>;
26
+ /**
27
+ * x402 protocol version type
28
+ */
29
+ export type X402Version = 1 | 2;
30
+ /**
31
+ * Payment option from discovery API (supports both v1 and v2 formats)
32
+ */
33
+ export interface PaymentOption {
34
+ scheme: string;
35
+ network: string;
36
+ asset: string;
37
+ maxAmountRequired?: string;
38
+ amount?: string;
39
+ price?: string;
40
+ payTo?: string;
41
+ description?: string;
42
+ }
43
+ /**
44
+ * Resource from discovery API
45
+ */
46
+ export interface DiscoveryResource {
47
+ url?: string;
48
+ resource?: string;
49
+ type?: string;
50
+ metadata?: {
51
+ [key: string]: unknown;
52
+ description?: string;
53
+ input?: Record<string, unknown>;
54
+ output?: Record<string, unknown>;
55
+ };
56
+ accepts?: PaymentOption[];
57
+ x402Version?: number;
58
+ lastUpdated?: string;
59
+ }
60
+ /**
61
+ * Simplified resource output for LLM consumption
62
+ */
63
+ export interface SimplifiedResource {
64
+ url: string;
65
+ price: string;
66
+ description: string;
67
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NETWORK_MAPPINGS = exports.SOLANA_USDC_ADDRESSES = exports.SUPPORTED_NETWORKS = exports.DEFAULT_FACILITATOR = exports.KNOWN_FACILITATORS = void 0;
4
+ /**
5
+ * Known facilitator registry
6
+ */
7
+ exports.KNOWN_FACILITATORS = {
8
+ cdp: "https://api.cdp.coinbase.com/platform/v2/x402",
9
+ payai: "https://facilitator.payai.network",
10
+ };
11
+ exports.DEFAULT_FACILITATOR = "cdp";
12
+ /**
13
+ * Supported networks for x402 payment protocol
14
+ */
15
+ exports.SUPPORTED_NETWORKS = [
16
+ "base-mainnet",
17
+ "base-sepolia",
18
+ "solana-mainnet",
19
+ "solana-devnet",
20
+ ];
21
+ /**
22
+ * USDC token addresses for Solana networks
23
+ */
24
+ exports.SOLANA_USDC_ADDRESSES = {
25
+ "solana-devnet": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
26
+ "solana-mainnet": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
27
+ };
28
+ /**
29
+ * Network mapping from internal network ID to both v1 and v2 (CAIP-2) formats.
30
+ * Used for filtering discovery results that may contain either format.
31
+ */
32
+ exports.NETWORK_MAPPINGS = {
33
+ "base-mainnet": ["base", "eip155:8453"],
34
+ "base-sepolia": ["base-sepolia", "eip155:84532"],
35
+ "solana-mainnet": ["solana", "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
36
+ "solana-devnet": ["solana-devnet", "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"],
37
+ };
@@ -1,47 +1,76 @@
1
1
  import { z } from "zod";
2
+ /**
3
+ * Resolves a facilitator name or URL to the actual URL.
4
+ *
5
+ * @param facilitator - Either a known facilitator name ('cdp', 'payai') or a custom URL
6
+ * @returns The facilitator URL
7
+ */
8
+ export declare function resolveFacilitatorUrl(facilitator: string): string;
2
9
  export declare const ListX402ServicesSchema: z.ZodObject<{
10
+ facilitator: z.ZodDefault<z.ZodUnion<[z.ZodEnum<["cdp", "payai"]>, z.ZodString]>>;
3
11
  maxUsdcPrice: z.ZodOptional<z.ZodNumber>;
12
+ x402Versions: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>]>, "many">>;
13
+ keyword: z.ZodOptional<z.ZodString>;
4
14
  }, "strip", z.ZodTypeAny, {
15
+ facilitator: string;
16
+ x402Versions: (1 | 2)[];
5
17
  maxUsdcPrice?: number | undefined;
18
+ keyword?: string | undefined;
6
19
  }, {
20
+ facilitator?: string | undefined;
7
21
  maxUsdcPrice?: number | undefined;
22
+ x402Versions?: (1 | 2)[] | undefined;
23
+ keyword?: string | undefined;
8
24
  }>;
9
25
  export declare const HttpRequestSchema: z.ZodObject<{
10
26
  url: z.ZodString;
11
27
  method: z.ZodDefault<z.ZodNullable<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>>>;
12
28
  headers: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
29
+ queryParams: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
13
30
  body: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
14
31
  }, "strip", z.ZodTypeAny, {
15
32
  method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null;
16
33
  url: string;
17
34
  body?: any;
18
35
  headers?: Record<string, string> | null | undefined;
36
+ queryParams?: Record<string, string> | null | undefined;
19
37
  }, {
20
38
  url: string;
21
39
  method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null | undefined;
22
40
  body?: any;
23
41
  headers?: Record<string, string> | null | undefined;
42
+ queryParams?: Record<string, string> | null | undefined;
24
43
  }>;
25
44
  export declare const RetryWithX402Schema: z.ZodObject<{
26
45
  url: z.ZodString;
27
46
  method: z.ZodDefault<z.ZodNullable<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>>>;
28
47
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
48
+ queryParams: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
29
49
  body: z.ZodOptional<z.ZodAny>;
30
50
  selectedPaymentOption: z.ZodObject<{
31
51
  scheme: z.ZodString;
32
52
  network: z.ZodString;
33
- maxAmountRequired: z.ZodString;
34
53
  asset: z.ZodString;
54
+ maxAmountRequired: z.ZodOptional<z.ZodString>;
55
+ amount: z.ZodOptional<z.ZodString>;
56
+ price: z.ZodOptional<z.ZodString>;
57
+ payTo: z.ZodOptional<z.ZodString>;
35
58
  }, "strip", z.ZodTypeAny, {
36
59
  scheme: string;
37
60
  network: string;
38
61
  asset: string;
39
- maxAmountRequired: string;
62
+ amount?: string | undefined;
63
+ price?: string | undefined;
64
+ maxAmountRequired?: string | undefined;
65
+ payTo?: string | undefined;
40
66
  }, {
41
67
  scheme: string;
42
68
  network: string;
43
69
  asset: string;
44
- maxAmountRequired: string;
70
+ amount?: string | undefined;
71
+ price?: string | undefined;
72
+ maxAmountRequired?: string | undefined;
73
+ payTo?: string | undefined;
45
74
  }>;
46
75
  }, "strip", z.ZodTypeAny, {
47
76
  method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null;
@@ -50,35 +79,46 @@ export declare const RetryWithX402Schema: z.ZodObject<{
50
79
  scheme: string;
51
80
  network: string;
52
81
  asset: string;
53
- maxAmountRequired: string;
82
+ amount?: string | undefined;
83
+ price?: string | undefined;
84
+ maxAmountRequired?: string | undefined;
85
+ payTo?: string | undefined;
54
86
  };
55
87
  body?: any;
56
88
  headers?: Record<string, string> | undefined;
89
+ queryParams?: Record<string, string> | null | undefined;
57
90
  }, {
58
91
  url: string;
59
92
  selectedPaymentOption: {
60
93
  scheme: string;
61
94
  network: string;
62
95
  asset: string;
63
- maxAmountRequired: string;
96
+ amount?: string | undefined;
97
+ price?: string | undefined;
98
+ maxAmountRequired?: string | undefined;
99
+ payTo?: string | undefined;
64
100
  };
65
101
  method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null | undefined;
66
102
  body?: any;
67
103
  headers?: Record<string, string> | undefined;
104
+ queryParams?: Record<string, string> | null | undefined;
68
105
  }>;
69
106
  export declare const DirectX402RequestSchema: z.ZodObject<{
70
107
  url: z.ZodString;
71
108
  method: z.ZodDefault<z.ZodNullable<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>>>;
72
109
  headers: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
110
+ queryParams: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
73
111
  body: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
74
112
  }, "strip", z.ZodTypeAny, {
75
113
  method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null;
76
114
  url: string;
77
115
  body?: any;
78
116
  headers?: Record<string, string> | null | undefined;
117
+ queryParams?: Record<string, string> | null | undefined;
79
118
  }, {
80
119
  url: string;
81
120
  method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | null | undefined;
82
121
  body?: any;
83
122
  headers?: Record<string, string> | null | undefined;
123
+ queryParams?: Record<string, string> | null | undefined;
84
124
  }>;
@@ -1,14 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DirectX402RequestSchema = exports.RetryWithX402Schema = exports.HttpRequestSchema = exports.ListX402ServicesSchema = void 0;
4
+ exports.resolveFacilitatorUrl = resolveFacilitatorUrl;
4
5
  const zod_1 = require("zod");
6
+ const constants_1 = require("./constants");
7
+ /**
8
+ * Resolves a facilitator name or URL to the actual URL.
9
+ *
10
+ * @param facilitator - Either a known facilitator name ('cdp', 'payai') or a custom URL
11
+ * @returns The facilitator URL
12
+ */
13
+ function resolveFacilitatorUrl(facilitator) {
14
+ if (facilitator in constants_1.KNOWN_FACILITATORS) {
15
+ return constants_1.KNOWN_FACILITATORS[facilitator];
16
+ }
17
+ return facilitator;
18
+ }
5
19
  // Schema for listing x402 services
6
20
  exports.ListX402ServicesSchema = zod_1.z
7
21
  .object({
22
+ facilitator: zod_1.z
23
+ .union([zod_1.z.enum(["cdp", "payai"]), zod_1.z.string().url()])
24
+ .default(constants_1.DEFAULT_FACILITATOR)
25
+ .describe("Facilitator to query: 'cdp' (Coinbase CDP), 'payai' (PayAI Network), or a custom facilitator URL."),
8
26
  maxUsdcPrice: zod_1.z
9
27
  .number()
28
+ .positive()
29
+ .finite()
10
30
  .optional()
11
31
  .describe("Optional maximum price in USDC whole units (e.g., 0.1 for 0.10 USDC). Only USDC payment options will be considered when this filter is applied."),
32
+ x402Versions: zod_1.z
33
+ .array(zod_1.z.union([zod_1.z.literal(1), zod_1.z.literal(2)]))
34
+ .default([1, 2])
35
+ .describe("Filter by x402 protocol version (1 or 2). Defaults to accepting both versions."),
36
+ keyword: zod_1.z
37
+ .string()
38
+ .optional()
39
+ .describe("Optional keyword to filter services by description (case-insensitive). Example: 'weather' to find weather-related services."),
12
40
  })
13
41
  .strip()
14
42
  .describe("Parameters for listing x402 services with optional filtering");
@@ -29,14 +57,40 @@ exports.HttpRequestSchema = zod_1.z
29
57
  .optional()
30
58
  .nullable()
31
59
  .describe("Optional headers to include in the request"),
60
+ queryParams: zod_1.z
61
+ .record(zod_1.z.string())
62
+ .optional()
63
+ .nullable()
64
+ .describe("Query parameters to append to the URL as key-value string pairs. " +
65
+ "Use ONLY for GET/DELETE requests. " +
66
+ "For POST/PUT/PATCH, you must use the 'body' parameter instead. " +
67
+ "Example: {location: 'NYC', units: 'metric'} becomes ?location=NYC&units=metric"),
32
68
  body: zod_1.z
33
69
  .any()
34
70
  .optional()
35
71
  .nullable()
36
- .describe("Optional request body for POST/PUT/PATCH requests"),
72
+ .describe("Request body - REQUIRED for POST/PUT/PATCH requests when sending data. " +
73
+ "Always prefer 'body' over 'queryParams' for POST/PUT/PATCH. " +
74
+ "Do NOT use for GET or DELETE, use queryParams instead."),
37
75
  })
38
76
  .strip()
39
77
  .describe("Instructions for making a basic HTTP request");
78
+ // Payment option schema that supports both v1 and v2 formats
79
+ const PaymentOptionSchema = zod_1.z
80
+ .object({
81
+ scheme: zod_1.z.string().describe("Payment scheme (e.g., 'exact')"),
82
+ network: zod_1.z
83
+ .string()
84
+ .describe("Network identifier (v1: 'base-sepolia' or v2 CAIP-2: 'eip155:84532')"),
85
+ asset: zod_1.z.string().describe("Asset address or identifier"),
86
+ // v1 format
87
+ maxAmountRequired: zod_1.z.string().optional().describe("Maximum amount required (v1 format)"),
88
+ // v2 format
89
+ amount: zod_1.z.string().optional().describe("Amount required (v2 format)"),
90
+ price: zod_1.z.string().optional().describe("Price (v2 format, e.g., '$0.01')"),
91
+ payTo: zod_1.z.string().optional().describe("Payment recipient address (v2 format)"),
92
+ })
93
+ .describe("Payment option supporting both v1 and v2 x402 formats");
40
94
  // Schema for retrying a failed request with x402 payment
41
95
  exports.RetryWithX402Schema = zod_1.z
42
96
  .object({
@@ -50,15 +104,21 @@ exports.RetryWithX402Schema = zod_1.z
50
104
  .default("GET")
51
105
  .describe("The HTTP method to use for the request"),
52
106
  headers: zod_1.z.record(zod_1.z.string()).optional().describe("Optional headers to include in the request"),
53
- body: zod_1.z.any().optional().describe("Optional request body for POST/PUT/PATCH requests"),
54
- selectedPaymentOption: zod_1.z
55
- .object({
56
- scheme: zod_1.z.string(),
57
- network: zod_1.z.string(),
58
- maxAmountRequired: zod_1.z.string(),
59
- asset: zod_1.z.string(),
60
- })
61
- .describe("The payment option to use for this request"),
107
+ queryParams: zod_1.z
108
+ .record(zod_1.z.string())
109
+ .optional()
110
+ .nullable()
111
+ .describe("Query parameters to append to the URL as key-value string pairs. " +
112
+ "Use ONLY for GET/DELETE requests. " +
113
+ "For POST/PUT/PATCH, you must use the 'body' parameter instead. " +
114
+ "Example: {location: 'NYC', units: 'metric'} becomes ?location=NYC&units=metric"),
115
+ body: zod_1.z
116
+ .any()
117
+ .optional()
118
+ .describe("Request body - REQUIRED for POST/PUT/PATCH requests when sending data. " +
119
+ "Always prefer 'body' over 'queryParams' for POST/PUT/PATCH. " +
120
+ "Do NOT use for GET or DELETE, use queryParams instead."),
121
+ selectedPaymentOption: PaymentOptionSchema.describe("The payment option to use for this request"),
62
122
  })
63
123
  .strip()
64
124
  .describe("Instructions for retrying a request with x402 payment after receiving a 402 response");
@@ -79,11 +139,21 @@ exports.DirectX402RequestSchema = zod_1.z
79
139
  .optional()
80
140
  .nullable()
81
141
  .describe("Optional headers to include in the request"),
142
+ queryParams: zod_1.z
143
+ .record(zod_1.z.string())
144
+ .optional()
145
+ .nullable()
146
+ .describe("Query parameters to append to the URL as key-value string pairs. " +
147
+ "Use ONLY for GET/DELETE requests. " +
148
+ "For POST/PUT/PATCH, use the 'body' parameter instead. " +
149
+ "Example: {location: 'NYC', units: 'metric'} becomes ?location=NYC&units=metric"),
82
150
  body: zod_1.z
83
151
  .any()
84
152
  .optional()
85
153
  .nullable()
86
- .describe("Optional request body for POST/PUT/PATCH requests"),
154
+ .describe("Request body - REQUIRED for POST/PUT/PATCH requests when sending data. " +
155
+ "Always prefer 'body' over 'queryParams' for POST/PUT/PATCH. " +
156
+ "Do NOT use for GET or DELETE, use queryParams instead."),
87
157
  })
88
158
  .strip()
89
159
  .describe("Instructions for making an HTTP request with automatic x402 payment handling. WARNING: This bypasses user confirmation - only use when explicitly told to skip confirmation!");
@@ -1,26 +1,93 @@
1
1
  import { Network } from "../../network";
2
- import { AxiosError } from "axios";
3
2
  import { WalletProvider } from "../../wallet-providers";
3
+ import { type DiscoveryResource, type SimplifiedResource, type X402Version } from "./constants";
4
4
  /**
5
- * Supported network types for x402 protocol
5
+ * Returns array of matching network identifiers (both v1 and v2 CAIP-2 formats).
6
+ * Used for filtering discovery results that may contain either format.
7
+ *
8
+ * @param network - The network object
9
+ * @returns Array of network identifiers that match the wallet's network
10
+ */
11
+ export declare function getX402Networks(network: Network): string[];
12
+ /**
13
+ * Gets network ID from a CAIP-2 or v1 network identifier.
14
+ *
15
+ * @param network - The x402 network identifier (e.g., "eip155:8453" for v2 or "base" for v1)
16
+ * @returns The network ID (e.g., "base-mainnet") or the original if not found
17
+ */
18
+ export declare function getNetworkId(network: string): string;
19
+ /**
20
+ * Fetches all resources from the discovery API with pagination.
21
+ *
22
+ * @param discoveryUrl - The base URL for discovery
23
+ * @param pageSize - Number of resources per page (default 100)
24
+ * @returns Array of all discovered resources
25
+ */
26
+ export declare function fetchAllDiscoveryResources(discoveryUrl: string, pageSize?: number): Promise<DiscoveryResource[]>;
27
+ /**
28
+ * Filters resources by network compatibility.
29
+ * Matches resources that accept any of the wallet's network identifiers (v1 or v2 format).
30
+ *
31
+ * @param resources - Array of discovery resources
32
+ * @param walletNetworks - Array of network identifiers to match
33
+ * @returns Filtered array of resources
34
+ */
35
+ export declare function filterByNetwork(resources: DiscoveryResource[], walletNetworks: string[]): DiscoveryResource[];
36
+ /**
37
+ * Filters resources by having a valid description.
38
+ * Removes resources with empty or default descriptions.
39
+ * Supports both v1 (accepts[].description) and v2 (metadata.description) formats.
40
+ *
41
+ * @param resources - Array of discovery resources
42
+ * @returns Filtered array of resources with valid descriptions
6
43
  */
7
- export type X402Network = "base" | "base-sepolia" | "solana" | "solana-devnet";
44
+ export declare function filterByDescription(resources: DiscoveryResource[]): DiscoveryResource[];
8
45
  /**
9
- * Converts the internal network ID to the format expected by the x402 protocol.
46
+ * Filters resources by x402 protocol version.
47
+ * Uses the x402Version field on the resource.
10
48
  *
11
- * @param network - The network to convert
12
- * @returns The network ID in x402 format
13
- * @throws Error if the network is not supported
49
+ * @param resources - Array of discovery resources
50
+ * @param allowedVersions - Array of allowed versions (default: [1, 2])
51
+ * @returns Filtered array of resources matching the allowed versions
14
52
  */
15
- export declare function getX402Network(network: Network): X402Network | string | undefined;
53
+ export declare function filterByX402Version(resources: DiscoveryResource[], allowedVersions?: X402Version[]): DiscoveryResource[];
54
+ /**
55
+ * Filters resources by keyword appearing in description or URL.
56
+ * Case-insensitive search.
57
+ * Supports both v1 (accepts[].description) and v2 (metadata.description) formats.
58
+ *
59
+ * @param resources - Array of discovery resources
60
+ * @param keyword - The keyword to search for in descriptions and URLs
61
+ * @returns Filtered array of resources with matching descriptions or URLs
62
+ */
63
+ export declare function filterByKeyword(resources: DiscoveryResource[], keyword: string): DiscoveryResource[];
64
+ /**
65
+ * Filters resources by maximum USDC price.
66
+ *
67
+ * @param resources - Array of discovery resources
68
+ * @param maxUsdcPrice - Maximum price in whole USDC units
69
+ * @param walletProvider - Wallet provider for asset identification
70
+ * @param walletNetworks - Array of network identifiers to match
71
+ * @returns Filtered array of resources within price limit
72
+ */
73
+ export declare function filterByMaxPrice(resources: DiscoveryResource[], maxUsdcPrice: number, walletProvider: WalletProvider, walletNetworks: string[]): Promise<DiscoveryResource[]>;
74
+ /**
75
+ * Formats resources into simplified output for LLM consumption.
76
+ *
77
+ * @param resources - Array of discovery resources
78
+ * @param walletNetworks - Array of network identifiers to match for price extraction
79
+ * @param walletProvider - Wallet provider for formatting
80
+ * @returns Array of simplified resources with url, price, description
81
+ */
82
+ export declare function formatSimplifiedResources(resources: DiscoveryResource[], walletNetworks: string[], walletProvider: WalletProvider): Promise<SimplifiedResource[]>;
16
83
  /**
17
84
  * Helper method to handle HTTP errors consistently.
18
85
  *
19
- * @param error - The axios error to handle
86
+ * @param error - The error to handle
20
87
  * @param url - The URL that was being accessed when the error occurred
21
88
  * @returns A JSON string containing formatted error details
22
89
  */
23
- export declare function handleHttpError(error: AxiosError, url: string): string;
90
+ export declare function handleHttpError(error: unknown, url: string): string;
24
91
  /**
25
92
  * Formats a payment option into a human-readable string.
26
93
  *
@@ -53,3 +120,11 @@ export declare function isUsdcAsset(asset: string, walletProvider: WalletProvide
53
120
  * @returns The amount in atomic units as a string, or null if conversion fails
54
121
  */
55
122
  export declare function convertWholeUnitsToAtomic(wholeUnits: number, asset: string, walletProvider: WalletProvider): Promise<string | null>;
123
+ /**
124
+ * Builds a URL with query parameters appended.
125
+ *
126
+ * @param baseUrl - The base URL
127
+ * @param queryParams - Optional query parameters to append
128
+ * @returns URL string with query parameters
129
+ */
130
+ export declare function buildUrlWithParams(baseUrl: string, queryParams?: Record<string, string> | null): string;