@dexterai/x402 3.0.0 → 3.1.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.
@@ -4,6 +4,7 @@ export { b as AccessPassInfo, a as AccessPassTier, D as DEXTER_FACILITATOR_URL,
4
4
  import { Keypair } from '@solana/web3.js';
5
5
  import { S as SolanaWallet, E as EvmWallet } from '../types-C_aQh02s.cjs';
6
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
+ export { FormattedResource as CapabilityAPI, CapabilitySearchOptions, CapabilitySearchResult, NoMatchReason, capabilitySearch } from '@dexterai/x402-core';
7
8
  export { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
8
9
 
9
10
  /**
@@ -237,228 +238,6 @@ declare function createEvmKeypairWallet(privateKey: string): Promise<EvmWallet>;
237
238
  */
238
239
  declare function isEvmKeypairWallet(wallet: unknown): wallet is EvmWallet;
239
240
 
240
- /**
241
- * API Discovery — Semantic Capability Search
242
- *
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.
249
- *
250
- * @example
251
- * ```typescript
252
- * import { capabilitySearch } from '@dexterai/x402/client';
253
- *
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}`);
266
- * }
267
- *
268
- * // Then call one with wrapFetch:
269
- * const response = await x402Fetch(result.strongResults[0].url);
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.
281
- */
282
- /**
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.
292
- */
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) */
297
- limit?: number;
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;
314
- }
315
- /**
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.
322
- */
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) */
327
- name: string;
328
- /** Full resource URL — pass directly to wrapFetch or createX402Client.fetch */
329
- url: string;
330
- /** HTTP method the endpoint expects */
331
- method: string;
332
- /**
333
- * Formatted price label ("$0.05", "$0.0011", "free", or "price on request"
334
- * when the resource has no advertised price).
335
- */
336
- price: string;
337
- /** Raw price in USDC as a number (null when the resource has no advertised price) */
338
- priceUsdc: number | null;
339
- /** Payment network the price is quoted on (CAIP-2 or canonical name) */
340
- network: string | null;
341
- /** Human-readable description */
342
- description: string;
343
- /** Category assigned by the catalog */
344
- category: string;
345
- /** Quality score 0-100 (null if unscored) */
346
- qualityScore: number | null;
347
- /** Whether the endpoint passed AI verification (alias for verificationStatus === 'pass') */
348
- verified: boolean;
349
- /** Full verification status: 'pass' | 'fail' | 'inconclusive' | 'skipped' | 'unverified' */
350
- verificationStatus: string;
351
- /** Total number of settlements (calls) observed against this resource */
352
- totalCalls: number;
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;
375
- }
376
- /**
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.
432
- *
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.
436
- *
437
- * @example Find an ETH price feed
438
- * ```typescript
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
- * }
448
- * ```
449
- *
450
- * @example Skip the LLM rerank for lowest latency
451
- * ```typescript
452
- * const result = await capabilitySearch({ query: 'token price', rerank: false });
453
- * ```
454
- *
455
- * @example Include unverified resources (usually omitted)
456
- * ```typescript
457
- * const result = await capabilitySearch({ query: 'image generation', unverified: true });
458
- * ```
459
- */
460
- declare function capabilitySearch(options: CapabilitySearchOptions): Promise<CapabilitySearchResult>;
461
-
462
241
  /**
463
242
  * Budget Account — Autonomous Agent Spending Controls
464
243
  *
@@ -544,4 +323,4 @@ interface BudgetAccount {
544
323
  */
545
324
  declare function createBudgetAccount(config: BudgetAccountConfig): BudgetAccount;
546
325
 
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 };
326
+ export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, KEYPAIR_SYMBOL, type KeypairWallet, type PaymentRecord, type WrapFetchOptions, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, wrapFetch };
@@ -4,6 +4,7 @@ export { b as AccessPassInfo, a as AccessPassTier, D as DEXTER_FACILITATOR_URL,
4
4
  import { Keypair } from '@solana/web3.js';
5
5
  import { S as SolanaWallet, E as EvmWallet } from '../types-DBS0XOsH.js';
6
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
+ export { FormattedResource as CapabilityAPI, CapabilitySearchOptions, CapabilitySearchResult, NoMatchReason, capabilitySearch } from '@dexterai/x402-core';
7
8
  export { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
8
9
 
9
10
  /**
@@ -237,228 +238,6 @@ declare function createEvmKeypairWallet(privateKey: string): Promise<EvmWallet>;
237
238
  */
238
239
  declare function isEvmKeypairWallet(wallet: unknown): wallet is EvmWallet;
239
240
 
240
- /**
241
- * API Discovery — Semantic Capability Search
242
- *
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.
249
- *
250
- * @example
251
- * ```typescript
252
- * import { capabilitySearch } from '@dexterai/x402/client';
253
- *
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}`);
266
- * }
267
- *
268
- * // Then call one with wrapFetch:
269
- * const response = await x402Fetch(result.strongResults[0].url);
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.
281
- */
282
- /**
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.
292
- */
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) */
297
- limit?: number;
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;
314
- }
315
- /**
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.
322
- */
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) */
327
- name: string;
328
- /** Full resource URL — pass directly to wrapFetch or createX402Client.fetch */
329
- url: string;
330
- /** HTTP method the endpoint expects */
331
- method: string;
332
- /**
333
- * Formatted price label ("$0.05", "$0.0011", "free", or "price on request"
334
- * when the resource has no advertised price).
335
- */
336
- price: string;
337
- /** Raw price in USDC as a number (null when the resource has no advertised price) */
338
- priceUsdc: number | null;
339
- /** Payment network the price is quoted on (CAIP-2 or canonical name) */
340
- network: string | null;
341
- /** Human-readable description */
342
- description: string;
343
- /** Category assigned by the catalog */
344
- category: string;
345
- /** Quality score 0-100 (null if unscored) */
346
- qualityScore: number | null;
347
- /** Whether the endpoint passed AI verification (alias for verificationStatus === 'pass') */
348
- verified: boolean;
349
- /** Full verification status: 'pass' | 'fail' | 'inconclusive' | 'skipped' | 'unverified' */
350
- verificationStatus: string;
351
- /** Total number of settlements (calls) observed against this resource */
352
- totalCalls: number;
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;
375
- }
376
- /**
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.
432
- *
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.
436
- *
437
- * @example Find an ETH price feed
438
- * ```typescript
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
- * }
448
- * ```
449
- *
450
- * @example Skip the LLM rerank for lowest latency
451
- * ```typescript
452
- * const result = await capabilitySearch({ query: 'token price', rerank: false });
453
- * ```
454
- *
455
- * @example Include unverified resources (usually omitted)
456
- * ```typescript
457
- * const result = await capabilitySearch({ query: 'image generation', unverified: true });
458
- * ```
459
- */
460
- declare function capabilitySearch(options: CapabilitySearchOptions): Promise<CapabilitySearchResult>;
461
-
462
241
  /**
463
242
  * Budget Account — Autonomous Agent Spending Controls
464
243
  *
@@ -544,4 +323,4 @@ interface BudgetAccount {
544
323
  */
545
324
  declare function createBudgetAccount(config: BudgetAccountConfig): BudgetAccount;
546
325
 
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 };
326
+ export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, KEYPAIR_SYMBOL, type KeypairWallet, type PaymentRecord, type WrapFetchOptions, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, wrapFetch };