@dexterai/x402 2.1.0 → 3.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.
@@ -1,9 +1,9 @@
1
- export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-DAVzu4x6.cjs';
1
+ export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-CE7WpV5b.cjs';
2
2
  import { A as AccessPassClientConfig, P as PaymentAccept } from '../types-_iT11DL0.cjs';
3
3
  export { b as AccessPassInfo, a as AccessPassTier, D as DEXTER_FACILITATOR_URL, U as USDC_MINT, X as X402Error } from '../types-_iT11DL0.cjs';
4
4
  import { Keypair } from '@solana/web3.js';
5
- import { S as SolanaWallet, E as EvmWallet } from '../types-D1u7iu8n.cjs';
6
- export { B as BASE_MAINNET, C as ChainAdapter, b as SOLANA_MAINNET, W as WalletSet, a as createEvmAdapter, c as createSolanaAdapter } from '../types-D1u7iu8n.cjs';
5
+ import { S as SolanaWallet, E as EvmWallet } from '../types-C_aQh02s.cjs';
6
+ export { B as BASE_MAINNET, C as ChainAdapter, b as SOLANA_MAINNET, W as WalletSet, a as createEvmAdapter, c as createSolanaAdapter } from '../types-C_aQh02s.cjs';
7
7
  export { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
8
8
 
9
9
  /**
@@ -238,105 +238,226 @@ declare function createEvmKeypairWallet(privateKey: string): Promise<EvmWallet>;
238
238
  declare function isEvmKeypairWallet(wallet: unknown): wallet is EvmWallet;
239
239
 
240
240
  /**
241
- * API Discovery — Find x402 Paid APIs
241
+ * API Discovery — Semantic Capability Search
242
242
  *
243
- * Search the Dexter marketplace for x402-enabled APIs. Discover endpoints
244
- * by category, price range, network, and quality score then pay for them
245
- * with the same SDK.
243
+ * Search the Dexter x402 marketplace for paid APIs using semantic capability
244
+ * search. Queries are embedded with a vector model, filtered by a similarity
245
+ * floor, split into strong and related tiers, and the top strong results are
246
+ * reordered by an LLM cross-encoder. Synonym expansion and alternate phrasing
247
+ * handling happen automatically inside the search backend — pass a natural-
248
+ * language query and let the ranker do the work.
246
249
  *
247
250
  * @example
248
251
  * ```typescript
249
- * import { searchAPIs } from '@dexterai/x402/client';
252
+ * import { capabilitySearch } from '@dexterai/x402/client';
250
253
  *
251
- * const results = await searchAPIs({ query: 'sentiment analysis', maxPrice: 0.10 });
252
- * for (const api of results) {
253
- * console.log(`${api.name}: ${api.price} ${api.description}`);
254
+ * const result = await capabilitySearch({ query: 'get ETH spot price' });
255
+ *
256
+ * // Strong matches: high-confidence capability hits
257
+ * for (const api of result.strongResults) {
258
+ * console.log(`${api.name} (${api.tier}, similarity ${api.similarity}): ${api.why}`);
259
+ * }
260
+ *
261
+ * // Related matches: adjacent services that cleared the similarity floor
262
+ * // but not the strong threshold. Useful as a fallback when strongResults
263
+ * // is empty or sparse.
264
+ * for (const api of result.relatedResults) {
265
+ * console.log(`${api.name} (related): ${api.description}`);
254
266
  * }
255
267
  *
256
268
  * // Then call one with wrapFetch:
257
- * const response = await x402Fetch(results[0].url);
269
+ * const response = await x402Fetch(result.strongResults[0].url);
258
270
  * ```
271
+ *
272
+ * @breaking 3.0.0
273
+ * This module was rewritten to target the capability search endpoint at
274
+ * `/api/x402gle/capability` instead of the legacy substring ranker at
275
+ * `/api/facilitator/marketplace/resources`. The old `searchAPIs()` function
276
+ * and `DiscoveredAPI` type have been removed — replaced by `capabilitySearch()`
277
+ * and `CapabilityAPI`. The response is now tiered (strongResults/relatedResults)
278
+ * and each result carries `tier`, `similarity`, and `why` explainers. Filter
279
+ * parameters like `category`, `network`, `maxPrice`, `verifiedOnly`, and `sort`
280
+ * are gone — the ranker handles these semantically rather than as hard filters.
259
281
  */
260
282
  /**
261
- * Search options for discovering x402 APIs
283
+ * Options for semantic capability search.
284
+ *
285
+ * The new pipeline does NOT accept the old hard-filter params (`category`,
286
+ * `network`, `maxPrice`, `verifiedOnly`, `sort`). Those were removed in 3.0.0
287
+ * because they were the source of silent false-empties: e.g. a query for
288
+ * "ETH price" on `network: 'ethereum'` would return zero results because
289
+ * every ETH-price resource accepts payment on Base (Ethereum gas is too
290
+ * expensive). Search ranks by capability relevance; payment rail is a
291
+ * checkout-time concern the caller handles separately.
262
292
  */
263
- interface SearchAPIsOptions {
264
- /** Search query (e.g., 'sentiment analysis', 'token price', 'image generation') */
265
- query?: string;
266
- /** Filter by category (e.g., 'defi', 'ai', 'data', 'social') */
267
- category?: string;
268
- /** Filter by payment network (e.g., 'solana', 'base', 'polygon') */
269
- network?: string;
270
- /** Maximum price per call in USDC */
271
- maxPrice?: number;
272
- /** Only return verified endpoints (quality score 75+) */
273
- verifiedOnly?: boolean;
274
- /** Sort order */
275
- sort?: 'marketplace' | 'relevance' | 'quality_score' | 'settlements' | 'volume' | 'recent';
276
- /** Maximum results to return (default 20, max 50) */
293
+ interface CapabilitySearchOptions {
294
+ /** Natural-language description of the capability you want. Required. */
295
+ query: string;
296
+ /** Max results across strong + related tiers combined (1-50, default 20) */
277
297
  limit?: number;
278
- /** Marketplace API URL (default: Dexter marketplace) */
279
- marketplaceUrl?: string;
298
+ /** Include unverified resources (default false) */
299
+ unverified?: boolean;
300
+ /** Include testnet-only resources (default false) */
301
+ testnets?: boolean;
302
+ /**
303
+ * Cross-encoder LLM rerank of the top strong results. Default true.
304
+ * Adds ~1s of latency in exchange for meaningfully better top-of-list
305
+ * ordering on ambiguous queries. Set to false for deterministic order
306
+ * or lowest-latency path.
307
+ */
308
+ rerank?: boolean;
309
+ /**
310
+ * Override the capability search endpoint. Defaults to the Dexter-hosted
311
+ * endpoint. Useful for testing against a local dexter-api instance.
312
+ */
313
+ endpoint?: string;
280
314
  }
281
315
  /**
282
- * A discovered x402 API endpoint
316
+ * A single result from capability search.
317
+ *
318
+ * Fields are flat-ish and designed to round-trip cleanly through LLM tool
319
+ * outputs and UI renderers. `tier`, `similarity`, and `why` are the three
320
+ * new fields that the ranker produces: use them to distinguish high-confidence
321
+ * matches from related suggestions.
283
322
  */
284
- interface DiscoveredAPI {
285
- /** API name */
323
+ interface CapabilityAPI {
324
+ /** Internal resource UUID in the Dexter catalog */
325
+ resourceId: string;
326
+ /** Display name (falls back to the URL if the resource is unnamed) */
286
327
  name: string;
287
328
  /** Full resource URL — pass directly to wrapFetch or createX402Client.fetch */
288
329
  url: string;
289
- /** HTTP method */
330
+ /** HTTP method the endpoint expects */
290
331
  method: string;
291
- /** Price per call (formatted, e.g., '$0.05') */
332
+ /**
333
+ * Formatted price label ("$0.05", "$0.0011", "free", or "price on request"
334
+ * when the resource has no advertised price).
335
+ */
292
336
  price: string;
293
- /** Price per call in USDC (raw number, null if free) */
337
+ /** Raw price in USDC as a number (null when the resource has no advertised price) */
294
338
  priceUsdc: number | null;
295
- /** Payment network */
339
+ /** Payment network the price is quoted on (CAIP-2 or canonical name) */
296
340
  network: string | null;
297
341
  /** Human-readable description */
298
342
  description: string;
299
- /** Category (e.g., 'defi', 'ai', 'data') */
343
+ /** Category assigned by the catalog */
300
344
  category: string;
301
- /** Quality score (0-100, null if unscored) */
345
+ /** Quality score 0-100 (null if unscored) */
302
346
  qualityScore: number | null;
303
- /** Whether the endpoint has been verified */
347
+ /** Whether the endpoint passed AI verification (alias for verificationStatus === 'pass') */
304
348
  verified: boolean;
305
- /** Total number of settlements (calls) */
349
+ /** Full verification status: 'pass' | 'fail' | 'inconclusive' | 'skipped' | 'unverified' */
350
+ verificationStatus: string;
351
+ /** Total number of settlements (calls) observed against this resource */
306
352
  totalCalls: number;
307
- /** Total volume in USDC (formatted, e.g., '$1,234.56') */
308
- totalVolume: string | null;
309
- /** Seller name */
310
- seller: string | null;
311
- /** Seller reputation score */
312
- sellerReputation: number | null;
313
- /** Whether authentication is required beyond payment */
314
- authRequired: boolean;
315
- /** Last time someone called this API */
316
- lastActive: string | null;
353
+ /** Total settled volume in USDC */
354
+ totalVolumeUsdc: number;
355
+ /** Icon URL (favicon or seller logo) */
356
+ iconUrl: string | null;
357
+ /** Host label derived from the URL */
358
+ host: string | null;
359
+ /** Gaming/wash-trading flags non-empty array means the resource is suspicious */
360
+ gamingFlags: string[];
361
+ /** True when any gaming flag is set */
362
+ gamingSuspicious: boolean;
363
+ /** Which tier this result fell into — 'strong' (high confidence) or 'related' (adjacent) */
364
+ tier: 'strong' | 'related';
365
+ /** Raw cosine similarity 0-1 between the query embedding and the resource embedding */
366
+ similarity: number;
367
+ /**
368
+ * One-sentence explanation of why this result ranked where it did. Built
369
+ * from the modular ranking factors (semantic similarity, trust, activity,
370
+ * gaming penalty).
371
+ */
372
+ why: string;
373
+ /** Final combined ranking score in [0, 1] */
374
+ score: number;
317
375
  }
318
376
  /**
319
- * Search the Dexter marketplace for x402 paid APIs.
377
+ * Why a response has no strong matches.
378
+ * - 'below_similarity_threshold': no candidates cleared the similarity floor at all
379
+ * - 'below_strong_threshold': candidates cleared the floor but none reached strong
380
+ * - null: strongResults is non-empty
381
+ */
382
+ type NoMatchReason = 'below_similarity_threshold' | 'below_strong_threshold' | null;
383
+ /**
384
+ * Full response from capability search. Tiered shape with telemetry about
385
+ * the ranking pipeline.
386
+ */
387
+ interface CapabilitySearchResult {
388
+ /** The original query string the caller passed */
389
+ query: string;
390
+ /**
391
+ * Strong matches — high-confidence capability hits (similarity >= strong
392
+ * threshold). These are the primary results the caller should surface.
393
+ */
394
+ strongResults: CapabilityAPI[];
395
+ /**
396
+ * Related matches — candidates that cleared the similarity floor but did
397
+ * not reach the strong threshold. Useful as a secondary section when
398
+ * strongResults is empty or sparse.
399
+ */
400
+ relatedResults: CapabilityAPI[];
401
+ /** Count of strong results returned */
402
+ strongCount: number;
403
+ /** Count of related results returned */
404
+ relatedCount: number;
405
+ /** Highest cosine similarity observed across all candidates (null when no candidates) */
406
+ topSimilarity: number | null;
407
+ /** Reason the response has no strong matches (null when strong matches exist) */
408
+ noMatchReason: NoMatchReason;
409
+ /**
410
+ * Cross-encoder rerank telemetry. `applied` is true when the LLM actually
411
+ * reordered the top strong results; `reason` explains any skip.
412
+ */
413
+ rerank: {
414
+ enabled: boolean;
415
+ applied: boolean;
416
+ reason?: string;
417
+ };
418
+ /**
419
+ * The parsed intent the backend extracted. `capabilityText` is the bare
420
+ * capability; `expandedCapabilityText` is the synonym-expanded version that
421
+ * was actually embedded for the vector search.
422
+ */
423
+ intent: {
424
+ capabilityText: string;
425
+ expandedCapabilityText?: string;
426
+ };
427
+ /** Total wall-clock duration of the capability search request in milliseconds */
428
+ durationMs: number;
429
+ }
430
+ /**
431
+ * Search the Dexter x402 marketplace using semantic capability search.
320
432
  *
321
- * Returns a list of discovered endpoints that can be called directly
322
- * with `wrapFetch` or `createX402Client.fetch`.
433
+ * Returns tiered results (strongResults + relatedResults) plus ranking
434
+ * telemetry. Handles synonym expansion and cross-encoder LLM rerank
435
+ * internally — pass the user's natural-language intent directly.
323
436
  *
324
- * @example Find AI APIs under $0.10
437
+ * @example Find an ETH price feed
325
438
  * ```typescript
326
- * const apis = await searchAPIs({ query: 'ai', maxPrice: 0.10 });
439
+ * const result = await capabilitySearch({ query: 'get current ETH spot price' });
440
+ * if (result.strongCount > 0) {
441
+ * const best = result.strongResults[0];
442
+ * console.log(`${best.name}: ${best.price} — ${best.why}`);
443
+ * } else if (result.relatedCount > 0) {
444
+ * console.log(`No exact match. Closest related: ${result.relatedResults[0].name}`);
445
+ * } else {
446
+ * console.log(`No match. Reason: ${result.noMatchReason}`);
447
+ * }
327
448
  * ```
328
449
  *
329
- * @example Browse all verified DeFi tools
450
+ * @example Skip the LLM rerank for lowest latency
330
451
  * ```typescript
331
- * const apis = await searchAPIs({ category: 'defi', verifiedOnly: true });
452
+ * const result = await capabilitySearch({ query: 'token price', rerank: false });
332
453
  * ```
333
454
  *
334
- * @example Find cheapest APIs on Solana
455
+ * @example Include unverified resources (usually omitted)
335
456
  * ```typescript
336
- * const apis = await searchAPIs({ network: 'solana', sort: 'quality_score' });
457
+ * const result = await capabilitySearch({ query: 'image generation', unverified: true });
337
458
  * ```
338
459
  */
339
- declare function searchAPIs(options?: SearchAPIsOptions): Promise<DiscoveredAPI[]>;
460
+ declare function capabilitySearch(options: CapabilitySearchOptions): Promise<CapabilitySearchResult>;
340
461
 
341
462
  /**
342
463
  * Budget Account — Autonomous Agent Spending Controls
@@ -423,4 +544,4 @@ interface BudgetAccount {
423
544
  */
424
545
  declare function createBudgetAccount(config: BudgetAccountConfig): BudgetAccount;
425
546
 
426
- export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, type DiscoveredAPI, KEYPAIR_SYMBOL, type KeypairWallet, type PaymentRecord, type SearchAPIsOptions, type WrapFetchOptions, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, searchAPIs, wrapFetch };
547
+ export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, type CapabilityAPI, type CapabilitySearchOptions, type CapabilitySearchResult, KEYPAIR_SYMBOL, type KeypairWallet, type NoMatchReason, type PaymentRecord, type WrapFetchOptions, capabilitySearch, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, wrapFetch };
@@ -1,9 +1,9 @@
1
- export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-Lxa11w_X.js';
1
+ export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-BVoucsEW.js';
2
2
  import { A as AccessPassClientConfig, P as PaymentAccept } from '../types-_iT11DL0.js';
3
3
  export { b as AccessPassInfo, a as AccessPassTier, D as DEXTER_FACILITATOR_URL, U as USDC_MINT, X as X402Error } from '../types-_iT11DL0.js';
4
4
  import { Keypair } from '@solana/web3.js';
5
- import { S as SolanaWallet, E as EvmWallet } from '../types-YQlJI5E3.js';
6
- export { B as BASE_MAINNET, C as ChainAdapter, b as SOLANA_MAINNET, W as WalletSet, a as createEvmAdapter, c as createSolanaAdapter } from '../types-YQlJI5E3.js';
5
+ import { S as SolanaWallet, E as EvmWallet } from '../types-DBS0XOsH.js';
6
+ export { B as BASE_MAINNET, C as ChainAdapter, b as SOLANA_MAINNET, W as WalletSet, a as createEvmAdapter, c as createSolanaAdapter } from '../types-DBS0XOsH.js';
7
7
  export { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
8
8
 
9
9
  /**
@@ -238,105 +238,226 @@ declare function createEvmKeypairWallet(privateKey: string): Promise<EvmWallet>;
238
238
  declare function isEvmKeypairWallet(wallet: unknown): wallet is EvmWallet;
239
239
 
240
240
  /**
241
- * API Discovery — Find x402 Paid APIs
241
+ * API Discovery — Semantic Capability Search
242
242
  *
243
- * Search the Dexter marketplace for x402-enabled APIs. Discover endpoints
244
- * by category, price range, network, and quality score then pay for them
245
- * with the same SDK.
243
+ * Search the Dexter x402 marketplace for paid APIs using semantic capability
244
+ * search. Queries are embedded with a vector model, filtered by a similarity
245
+ * floor, split into strong and related tiers, and the top strong results are
246
+ * reordered by an LLM cross-encoder. Synonym expansion and alternate phrasing
247
+ * handling happen automatically inside the search backend — pass a natural-
248
+ * language query and let the ranker do the work.
246
249
  *
247
250
  * @example
248
251
  * ```typescript
249
- * import { searchAPIs } from '@dexterai/x402/client';
252
+ * import { capabilitySearch } from '@dexterai/x402/client';
250
253
  *
251
- * const results = await searchAPIs({ query: 'sentiment analysis', maxPrice: 0.10 });
252
- * for (const api of results) {
253
- * console.log(`${api.name}: ${api.price} ${api.description}`);
254
+ * const result = await capabilitySearch({ query: 'get ETH spot price' });
255
+ *
256
+ * // Strong matches: high-confidence capability hits
257
+ * for (const api of result.strongResults) {
258
+ * console.log(`${api.name} (${api.tier}, similarity ${api.similarity}): ${api.why}`);
259
+ * }
260
+ *
261
+ * // Related matches: adjacent services that cleared the similarity floor
262
+ * // but not the strong threshold. Useful as a fallback when strongResults
263
+ * // is empty or sparse.
264
+ * for (const api of result.relatedResults) {
265
+ * console.log(`${api.name} (related): ${api.description}`);
254
266
  * }
255
267
  *
256
268
  * // Then call one with wrapFetch:
257
- * const response = await x402Fetch(results[0].url);
269
+ * const response = await x402Fetch(result.strongResults[0].url);
258
270
  * ```
271
+ *
272
+ * @breaking 3.0.0
273
+ * This module was rewritten to target the capability search endpoint at
274
+ * `/api/x402gle/capability` instead of the legacy substring ranker at
275
+ * `/api/facilitator/marketplace/resources`. The old `searchAPIs()` function
276
+ * and `DiscoveredAPI` type have been removed — replaced by `capabilitySearch()`
277
+ * and `CapabilityAPI`. The response is now tiered (strongResults/relatedResults)
278
+ * and each result carries `tier`, `similarity`, and `why` explainers. Filter
279
+ * parameters like `category`, `network`, `maxPrice`, `verifiedOnly`, and `sort`
280
+ * are gone — the ranker handles these semantically rather than as hard filters.
259
281
  */
260
282
  /**
261
- * Search options for discovering x402 APIs
283
+ * Options for semantic capability search.
284
+ *
285
+ * The new pipeline does NOT accept the old hard-filter params (`category`,
286
+ * `network`, `maxPrice`, `verifiedOnly`, `sort`). Those were removed in 3.0.0
287
+ * because they were the source of silent false-empties: e.g. a query for
288
+ * "ETH price" on `network: 'ethereum'` would return zero results because
289
+ * every ETH-price resource accepts payment on Base (Ethereum gas is too
290
+ * expensive). Search ranks by capability relevance; payment rail is a
291
+ * checkout-time concern the caller handles separately.
262
292
  */
263
- interface SearchAPIsOptions {
264
- /** Search query (e.g., 'sentiment analysis', 'token price', 'image generation') */
265
- query?: string;
266
- /** Filter by category (e.g., 'defi', 'ai', 'data', 'social') */
267
- category?: string;
268
- /** Filter by payment network (e.g., 'solana', 'base', 'polygon') */
269
- network?: string;
270
- /** Maximum price per call in USDC */
271
- maxPrice?: number;
272
- /** Only return verified endpoints (quality score 75+) */
273
- verifiedOnly?: boolean;
274
- /** Sort order */
275
- sort?: 'marketplace' | 'relevance' | 'quality_score' | 'settlements' | 'volume' | 'recent';
276
- /** Maximum results to return (default 20, max 50) */
293
+ interface CapabilitySearchOptions {
294
+ /** Natural-language description of the capability you want. Required. */
295
+ query: string;
296
+ /** Max results across strong + related tiers combined (1-50, default 20) */
277
297
  limit?: number;
278
- /** Marketplace API URL (default: Dexter marketplace) */
279
- marketplaceUrl?: string;
298
+ /** Include unverified resources (default false) */
299
+ unverified?: boolean;
300
+ /** Include testnet-only resources (default false) */
301
+ testnets?: boolean;
302
+ /**
303
+ * Cross-encoder LLM rerank of the top strong results. Default true.
304
+ * Adds ~1s of latency in exchange for meaningfully better top-of-list
305
+ * ordering on ambiguous queries. Set to false for deterministic order
306
+ * or lowest-latency path.
307
+ */
308
+ rerank?: boolean;
309
+ /**
310
+ * Override the capability search endpoint. Defaults to the Dexter-hosted
311
+ * endpoint. Useful for testing against a local dexter-api instance.
312
+ */
313
+ endpoint?: string;
280
314
  }
281
315
  /**
282
- * A discovered x402 API endpoint
316
+ * A single result from capability search.
317
+ *
318
+ * Fields are flat-ish and designed to round-trip cleanly through LLM tool
319
+ * outputs and UI renderers. `tier`, `similarity`, and `why` are the three
320
+ * new fields that the ranker produces: use them to distinguish high-confidence
321
+ * matches from related suggestions.
283
322
  */
284
- interface DiscoveredAPI {
285
- /** API name */
323
+ interface CapabilityAPI {
324
+ /** Internal resource UUID in the Dexter catalog */
325
+ resourceId: string;
326
+ /** Display name (falls back to the URL if the resource is unnamed) */
286
327
  name: string;
287
328
  /** Full resource URL — pass directly to wrapFetch or createX402Client.fetch */
288
329
  url: string;
289
- /** HTTP method */
330
+ /** HTTP method the endpoint expects */
290
331
  method: string;
291
- /** Price per call (formatted, e.g., '$0.05') */
332
+ /**
333
+ * Formatted price label ("$0.05", "$0.0011", "free", or "price on request"
334
+ * when the resource has no advertised price).
335
+ */
292
336
  price: string;
293
- /** Price per call in USDC (raw number, null if free) */
337
+ /** Raw price in USDC as a number (null when the resource has no advertised price) */
294
338
  priceUsdc: number | null;
295
- /** Payment network */
339
+ /** Payment network the price is quoted on (CAIP-2 or canonical name) */
296
340
  network: string | null;
297
341
  /** Human-readable description */
298
342
  description: string;
299
- /** Category (e.g., 'defi', 'ai', 'data') */
343
+ /** Category assigned by the catalog */
300
344
  category: string;
301
- /** Quality score (0-100, null if unscored) */
345
+ /** Quality score 0-100 (null if unscored) */
302
346
  qualityScore: number | null;
303
- /** Whether the endpoint has been verified */
347
+ /** Whether the endpoint passed AI verification (alias for verificationStatus === 'pass') */
304
348
  verified: boolean;
305
- /** Total number of settlements (calls) */
349
+ /** Full verification status: 'pass' | 'fail' | 'inconclusive' | 'skipped' | 'unverified' */
350
+ verificationStatus: string;
351
+ /** Total number of settlements (calls) observed against this resource */
306
352
  totalCalls: number;
307
- /** Total volume in USDC (formatted, e.g., '$1,234.56') */
308
- totalVolume: string | null;
309
- /** Seller name */
310
- seller: string | null;
311
- /** Seller reputation score */
312
- sellerReputation: number | null;
313
- /** Whether authentication is required beyond payment */
314
- authRequired: boolean;
315
- /** Last time someone called this API */
316
- lastActive: string | null;
353
+ /** Total settled volume in USDC */
354
+ totalVolumeUsdc: number;
355
+ /** Icon URL (favicon or seller logo) */
356
+ iconUrl: string | null;
357
+ /** Host label derived from the URL */
358
+ host: string | null;
359
+ /** Gaming/wash-trading flags non-empty array means the resource is suspicious */
360
+ gamingFlags: string[];
361
+ /** True when any gaming flag is set */
362
+ gamingSuspicious: boolean;
363
+ /** Which tier this result fell into — 'strong' (high confidence) or 'related' (adjacent) */
364
+ tier: 'strong' | 'related';
365
+ /** Raw cosine similarity 0-1 between the query embedding and the resource embedding */
366
+ similarity: number;
367
+ /**
368
+ * One-sentence explanation of why this result ranked where it did. Built
369
+ * from the modular ranking factors (semantic similarity, trust, activity,
370
+ * gaming penalty).
371
+ */
372
+ why: string;
373
+ /** Final combined ranking score in [0, 1] */
374
+ score: number;
317
375
  }
318
376
  /**
319
- * Search the Dexter marketplace for x402 paid APIs.
377
+ * Why a response has no strong matches.
378
+ * - 'below_similarity_threshold': no candidates cleared the similarity floor at all
379
+ * - 'below_strong_threshold': candidates cleared the floor but none reached strong
380
+ * - null: strongResults is non-empty
381
+ */
382
+ type NoMatchReason = 'below_similarity_threshold' | 'below_strong_threshold' | null;
383
+ /**
384
+ * Full response from capability search. Tiered shape with telemetry about
385
+ * the ranking pipeline.
386
+ */
387
+ interface CapabilitySearchResult {
388
+ /** The original query string the caller passed */
389
+ query: string;
390
+ /**
391
+ * Strong matches — high-confidence capability hits (similarity >= strong
392
+ * threshold). These are the primary results the caller should surface.
393
+ */
394
+ strongResults: CapabilityAPI[];
395
+ /**
396
+ * Related matches — candidates that cleared the similarity floor but did
397
+ * not reach the strong threshold. Useful as a secondary section when
398
+ * strongResults is empty or sparse.
399
+ */
400
+ relatedResults: CapabilityAPI[];
401
+ /** Count of strong results returned */
402
+ strongCount: number;
403
+ /** Count of related results returned */
404
+ relatedCount: number;
405
+ /** Highest cosine similarity observed across all candidates (null when no candidates) */
406
+ topSimilarity: number | null;
407
+ /** Reason the response has no strong matches (null when strong matches exist) */
408
+ noMatchReason: NoMatchReason;
409
+ /**
410
+ * Cross-encoder rerank telemetry. `applied` is true when the LLM actually
411
+ * reordered the top strong results; `reason` explains any skip.
412
+ */
413
+ rerank: {
414
+ enabled: boolean;
415
+ applied: boolean;
416
+ reason?: string;
417
+ };
418
+ /**
419
+ * The parsed intent the backend extracted. `capabilityText` is the bare
420
+ * capability; `expandedCapabilityText` is the synonym-expanded version that
421
+ * was actually embedded for the vector search.
422
+ */
423
+ intent: {
424
+ capabilityText: string;
425
+ expandedCapabilityText?: string;
426
+ };
427
+ /** Total wall-clock duration of the capability search request in milliseconds */
428
+ durationMs: number;
429
+ }
430
+ /**
431
+ * Search the Dexter x402 marketplace using semantic capability search.
320
432
  *
321
- * Returns a list of discovered endpoints that can be called directly
322
- * with `wrapFetch` or `createX402Client.fetch`.
433
+ * Returns tiered results (strongResults + relatedResults) plus ranking
434
+ * telemetry. Handles synonym expansion and cross-encoder LLM rerank
435
+ * internally — pass the user's natural-language intent directly.
323
436
  *
324
- * @example Find AI APIs under $0.10
437
+ * @example Find an ETH price feed
325
438
  * ```typescript
326
- * const apis = await searchAPIs({ query: 'ai', maxPrice: 0.10 });
439
+ * const result = await capabilitySearch({ query: 'get current ETH spot price' });
440
+ * if (result.strongCount > 0) {
441
+ * const best = result.strongResults[0];
442
+ * console.log(`${best.name}: ${best.price} — ${best.why}`);
443
+ * } else if (result.relatedCount > 0) {
444
+ * console.log(`No exact match. Closest related: ${result.relatedResults[0].name}`);
445
+ * } else {
446
+ * console.log(`No match. Reason: ${result.noMatchReason}`);
447
+ * }
327
448
  * ```
328
449
  *
329
- * @example Browse all verified DeFi tools
450
+ * @example Skip the LLM rerank for lowest latency
330
451
  * ```typescript
331
- * const apis = await searchAPIs({ category: 'defi', verifiedOnly: true });
452
+ * const result = await capabilitySearch({ query: 'token price', rerank: false });
332
453
  * ```
333
454
  *
334
- * @example Find cheapest APIs on Solana
455
+ * @example Include unverified resources (usually omitted)
335
456
  * ```typescript
336
- * const apis = await searchAPIs({ network: 'solana', sort: 'quality_score' });
457
+ * const result = await capabilitySearch({ query: 'image generation', unverified: true });
337
458
  * ```
338
459
  */
339
- declare function searchAPIs(options?: SearchAPIsOptions): Promise<DiscoveredAPI[]>;
460
+ declare function capabilitySearch(options: CapabilitySearchOptions): Promise<CapabilitySearchResult>;
340
461
 
341
462
  /**
342
463
  * Budget Account — Autonomous Agent Spending Controls
@@ -423,4 +544,4 @@ interface BudgetAccount {
423
544
  */
424
545
  declare function createBudgetAccount(config: BudgetAccountConfig): BudgetAccount;
425
546
 
426
- export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, type DiscoveredAPI, KEYPAIR_SYMBOL, type KeypairWallet, type PaymentRecord, type SearchAPIsOptions, type WrapFetchOptions, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, searchAPIs, wrapFetch };
547
+ export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, type CapabilityAPI, type CapabilitySearchOptions, type CapabilitySearchResult, KEYPAIR_SYMBOL, type KeypairWallet, type NoMatchReason, type PaymentRecord, type WrapFetchOptions, capabilitySearch, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, wrapFetch };