@vapi-network/sources 0.2.3 → 0.5.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,8 +1,14 @@
1
1
  # `@vapi-network/sources`
2
2
 
3
- Discovery adapters for the vAPI registry, the x402 Bazaar, and local JSON files.
4
- Results implement the `Source` and `Listing` contracts from `@vapi-network/core`
5
- and retain their source provenance.
3
+ Discovery adapters for [vAPI Network](https://github.com/vAPI-Network/vapi-network):
4
+ the vAPI Registry, the Coinbase Bazaar `/discovery/resources` catalogue, and
5
+ local JSON files. Results implement the `Source` and `Listing` contracts from
6
+ `@vapi-network/core` and keep their source provenance, so a caller never needs
7
+ a source-specific branch.
6
8
 
7
- The x402scan adapter is intentionally a stub until x402scan documents a stable
8
- public read API.
9
+ One entry point, `@vapi-network/sources`, exporting `vapiRegistrySource`,
10
+ `bazaarSource`, `localFileSource` and `x402scanSource`. The x402scan adapter is
11
+ intentionally a stub until x402scan documents a stable public read API.
12
+
13
+ See the [root README](https://github.com/vAPI-Network/vapi-network#readme) for
14
+ how the client merges and de-duplicates sources.
package/dist/index.js CHANGED
@@ -19696,9 +19696,35 @@ var listingFeeSchema = external_exports.looseObject({
19696
19696
  bps: external_exports.number().int().min(0),
19697
19697
  label: external_exports.string()
19698
19698
  });
19699
+ var LISTING_VERIFICATIONS = ["none", "requested", "verified"];
19700
+ var listingVerificationSchema = external_exports.enum(LISTING_VERIFICATIONS);
19701
+ var listingVerificationFieldSchema = listingVerificationSchema.default("none").catch("none");
19702
+ var listingLivenessSchema = external_exports.looseObject({
19703
+ uptime7d: external_exports.number().min(0).max(1),
19704
+ latencyP50Ms: external_exports.number().nonnegative().nullable(),
19705
+ latencyP95Ms: external_exports.number().nonnegative().nullable(),
19706
+ checks7d: external_exports.number().int().nonnegative()
19707
+ });
19708
+ var listingConformanceSchema = external_exports.looseObject({
19709
+ declaredVersion: external_exports.union([external_exports.literal(1), external_exports.literal(2)]).nullable(),
19710
+ versionConformant: external_exports.boolean(),
19711
+ offerTransport: external_exports.enum(["body", "header", "both"]),
19712
+ issues: external_exports.array(external_exports.string())
19713
+ });
19714
+ var listingIdentitySchema = external_exports.looseObject({
19715
+ erc8004Id: external_exports.string().trim().min(1),
19716
+ reputation: external_exports.looseObject({
19717
+ score: external_exports.number().finite(),
19718
+ count: external_exports.number().int().nonnegative()
19719
+ }).optional().catch(void 0)
19720
+ });
19699
19721
  var listingDisclosureShape = {
19700
19722
  group: listingGroupSchema.optional(),
19701
- fee: listingFeeSchema.optional()
19723
+ fee: listingFeeSchema.optional(),
19724
+ verification: listingVerificationFieldSchema,
19725
+ liveness: listingLivenessSchema.optional().catch(void 0),
19726
+ conformance: listingConformanceSchema.optional().catch(void 0),
19727
+ identity: listingIdentitySchema.optional().catch(void 0)
19702
19728
  };
19703
19729
  var marketplaceBadgeCodeSchema = external_exports.enum([
19704
19730
  "live_x402",
@@ -20005,6 +20031,7 @@ init_getAddress();
20005
20031
 
20006
20032
  // ../core/src/x402-networks.ts
20007
20033
  var BASE_MAINNET_CAIP2 = "eip155:8453";
20034
+ var ARC_MAINNET_CAIP2 = "eip155:5042";
20008
20035
  var ARC_TESTNET_CAIP2 = "eip155:5042002";
20009
20036
  var SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
20010
20037
  var X402_SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
@@ -20023,8 +20050,13 @@ var arcTestnetUsdc = canonicalIdentity("0x36000000000000000000000000000000000000
20023
20050
  name: "USDC",
20024
20051
  version: "2"
20025
20052
  });
20053
+ var arcMainnetUsdc = canonicalIdentity("0x3600000000000000000000000000000000000000", {
20054
+ name: "USDC",
20055
+ version: "2"
20056
+ });
20026
20057
  var CANONICAL_X402_USDC_NETWORKS = Object.freeze({
20027
20058
  [BASE_MAINNET_CAIP2]: baseMainnetUsdc,
20059
+ [ARC_MAINNET_CAIP2]: arcMainnetUsdc,
20028
20060
  [ARC_TESTNET_CAIP2]: arcTestnetUsdc
20029
20061
  });
20030
20062
  function browserNetwork(identity) {
@@ -20036,6 +20068,7 @@ function browserNetwork(identity) {
20036
20068
  }
20037
20069
  var BROWSER_ENABLED_X402_NETWORK_CONFIG = Object.freeze({
20038
20070
  [BASE_MAINNET_CAIP2]: browserNetwork(baseMainnetUsdc),
20071
+ [ARC_MAINNET_CAIP2]: browserNetwork(arcMainnetUsdc),
20039
20072
  [ARC_TESTNET_CAIP2]: browserNetwork(arcTestnetUsdc)
20040
20073
  });
20041
20074
 
@@ -20249,6 +20282,16 @@ var NETWORKS = {
20249
20282
  rpcEnv: "BASE_RPC_URL",
20250
20283
  publicRpcUrl: "https://mainnet.base.org"
20251
20284
  },
20285
+ [ARC_MAINNET_CAIP2]: {
20286
+ family: "evm",
20287
+ chainId: 5042,
20288
+ name: "Arc mainnet",
20289
+ usdc: CANONICAL_X402_USDC_NETWORKS[ARC_MAINNET_CAIP2].usdc,
20290
+ gasToken: "USDC",
20291
+ rpcEnv: "ARC_RPC_URL",
20292
+ publicRpcUrl: "https://rpc.mainnet.arc.io",
20293
+ explorerUrl: "https://explorer.arc.io"
20294
+ },
20252
20295
  [ARC_TESTNET_CAIP2]: {
20253
20296
  family: "evm",
20254
20297
  chainId: 5042002,
@@ -20354,7 +20397,14 @@ var configSchema = external_exports.object({
20354
20397
  continue;
20355
20398
  }
20356
20399
  try {
20357
- getAddress(configured.usdc);
20400
+ const usdc = getAddress(configured.usdc);
20401
+ if ((network === ARC_MAINNET_CAIP2 || network === ARC_TESTNET_CAIP2) && usdc !== getAddress(NETWORKS[network].usdc)) {
20402
+ context.addIssue({
20403
+ code: "custom",
20404
+ path: ["networks", network, "usdc"],
20405
+ message: "Expected the canonical Arc USDC predeploy."
20406
+ });
20407
+ }
20358
20408
  } catch {
20359
20409
  context.addIssue({
20360
20410
  code: "custom",
@@ -20367,6 +20417,7 @@ var configSchema = external_exports.object({
20367
20417
  function getVapiPaths(directory = process.env.VAPI_HOME?.trim() || join(homedir(), ".vapi")) {
20368
20418
  return {
20369
20419
  directory,
20420
+ agentsDir: join(directory, "agents"),
20370
20421
  config: join(directory, "config.json"),
20371
20422
  keystore: join(directory, "keystore.json"),
20372
20423
  receipts: join(directory, "receipts.jsonl"),
@@ -20670,7 +20721,8 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
20670
20721
  kinds: input2.kinds,
20671
20722
  network: input2.network,
20672
20723
  limit: input2.limit,
20673
- cursor: input2.cursor
20724
+ cursor: input2.cursor,
20725
+ includeUnverified: input2.includeUnverified
20674
20726
  });
20675
20727
  const startedAt = options.now ?? /* @__PURE__ */ new Date();
20676
20728
  const attempts = [];
@@ -20689,6 +20741,9 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
20689
20741
  if (normalized.network !== void 0) url2.searchParams.set("network", normalized.network);
20690
20742
  if (normalized.limit !== void 0) url2.searchParams.set("limit", String(normalized.limit));
20691
20743
  if (normalized.cursor !== void 0) url2.searchParams.set("cursor", normalized.cursor);
20744
+ if (normalized.includeUnverified === true) {
20745
+ url2.searchParams.set("includeUnverified", "true");
20746
+ }
20692
20747
  }
20693
20748
  });
20694
20749
  const page = marketplaceDiscoveryPageSchema.parse(await response.json());
@@ -20719,7 +20774,7 @@ async function resolveServiceListing(id, config2, fetchImpl, endpointName) {
20719
20774
  }
20720
20775
  async function findMarketplaceApiByRef(ref, config2, fetchImpl) {
20721
20776
  const page = await searchMarketplace(
20722
- { query: ref, kinds: ["api"], limit: 50 },
20777
+ { query: ref, kinds: ["api"], limit: 50, includeUnverified: true },
20723
20778
  config2,
20724
20779
  fetchImpl
20725
20780
  );
@@ -20734,37 +20789,36 @@ function vapiRegistrySource(baseUrl, options = {}) {
20734
20789
  const fetchImpl = sourceFetch(options);
20735
20790
  return {
20736
20791
  id: "vapi",
20737
- async search(query) {
20738
- const page = await searchMarketplace({ query, kinds: ["api"] }, config2, fetchImpl);
20792
+ async search(query, searchOptions) {
20793
+ const page = await searchMarketplace(
20794
+ {
20795
+ query,
20796
+ kinds: ["api"],
20797
+ ...searchOptions?.includeUnverified === void 0 ? {} : { includeUnverified: searchOptions.includeUnverified }
20798
+ },
20799
+ config2,
20800
+ fetchImpl
20801
+ );
20739
20802
  const mapped = await Promise.all(
20740
20803
  page.items.map(async (hit) => {
20741
20804
  if (hit.kind !== "api") return null;
20742
20805
  if (hit.provenance === "indexed") {
20743
- return {
20744
- resource: { url: hit.execution.url, description: hit.card.summary },
20745
- name: hit.card.title,
20746
- description: hit.card.summary,
20747
- ...hit.execution.method === null ? {} : { method: hit.execution.method },
20748
- network: hit.execution.network,
20749
- ...optionalPrice(hit.card.facts),
20750
- metadata: { card: hit.card, action: hit.action, execution: hit.execution },
20751
- provenance: [
20752
- {
20753
- source: "vapi",
20754
- sourceUrl: config2.marketplaceDiscoveryUrl,
20755
- ref: hit.ref
20756
- }
20757
- ]
20758
- };
20806
+ return mirroredListing(hit, config2);
20759
20807
  }
20760
20808
  try {
20761
20809
  const endpoint = await resolveServiceEndpoint(hit.ref, config2, fetchImpl);
20762
- return endpointListing(endpoint, hit.ref, config2, {
20763
- card: hit.card,
20764
- action: hit.action,
20765
- execution: hit.execution,
20766
- registryProvenance: hit.provenance
20767
- });
20810
+ return endpointListing(
20811
+ endpoint,
20812
+ hit.ref,
20813
+ config2,
20814
+ {
20815
+ card: hit.card,
20816
+ action: hit.action,
20817
+ execution: hit.execution,
20818
+ registryProvenance: hit.provenance
20819
+ },
20820
+ hit.verification
20821
+ );
20768
20822
  } catch (error61) {
20769
20823
  if (!(error61 instanceof DiscoveryCatalogError)) throw error61;
20770
20824
  return null;
@@ -20775,31 +20829,20 @@ function vapiRegistrySource(baseUrl, options = {}) {
20775
20829
  },
20776
20830
  async inspect(ref) {
20777
20831
  try {
20778
- const endpoint = await resolveServiceEndpoint(ref, config2, fetchImpl);
20779
- return endpointListing(endpoint, ref, config2);
20832
+ const { endpoint, service } = await resolveServiceListing(ref, config2, fetchImpl);
20833
+ return endpointListing(endpoint, ref, config2, {}, service.verification);
20780
20834
  } catch (resolutionError) {
20781
20835
  if (!(resolutionError instanceof DiscoveryCatalogError) || resolutionError.code !== "service_not_found") {
20782
20836
  throw resolutionError;
20783
20837
  }
20784
- const page = await searchMarketplace({ query: ref, kinds: ["api"] }, config2, fetchImpl);
20838
+ const page = await searchMarketplace(
20839
+ { query: ref, kinds: ["api"], includeUnverified: true },
20840
+ config2,
20841
+ fetchImpl
20842
+ );
20785
20843
  const hit = page.items.find((item) => item.kind === "api" && item.ref === ref);
20786
20844
  if (hit?.kind === "api" && hit.provenance === "indexed") {
20787
- return {
20788
- resource: { url: hit.execution.url, description: hit.card.summary },
20789
- name: hit.card.title,
20790
- description: hit.card.summary,
20791
- ...hit.execution.method === null ? {} : { method: hit.execution.method },
20792
- network: hit.execution.network,
20793
- ...optionalPrice(hit.card.facts),
20794
- metadata: { card: hit.card, action: hit.action, execution: hit.execution },
20795
- provenance: [
20796
- {
20797
- source: "vapi",
20798
- sourceUrl: config2.marketplaceDiscoveryUrl,
20799
- ref: hit.ref
20800
- }
20801
- ]
20802
- };
20845
+ return mirroredListing(hit, config2);
20803
20846
  }
20804
20847
  if (page.items.some((item) => item.kind === "api" && item.ref === ref)) {
20805
20848
  throw resolutionError;
@@ -20816,11 +20859,25 @@ async function fetchCallsDiscovery(query, config2, fetchImpl) {
20816
20859
  request: fetchImpl,
20817
20860
  configureUrl(url2) {
20818
20861
  url2.searchParams.set("q", query);
20862
+ url2.searchParams.set("includeUnverified", "true");
20819
20863
  }
20820
20864
  });
20821
20865
  return parseDiscovery(await response.json());
20822
20866
  }
20823
- function endpointListing(endpoint, ref, config2, metadata = {}) {
20867
+ function mirroredListing(hit, config2) {
20868
+ return {
20869
+ resource: { url: hit.execution.url, description: hit.card.summary },
20870
+ name: hit.card.title,
20871
+ description: hit.card.summary,
20872
+ ...hit.execution.method === null ? {} : { method: hit.execution.method },
20873
+ network: hit.execution.network,
20874
+ ...optionalPrice(hit.card.facts),
20875
+ verification: hit.verification,
20876
+ metadata: { card: hit.card, action: hit.action, execution: hit.execution },
20877
+ provenance: [{ source: "vapi", sourceUrl: config2.marketplaceDiscoveryUrl, ref: hit.ref }]
20878
+ };
20879
+ }
20880
+ function endpointListing(endpoint, ref, config2, metadata = {}, verification) {
20824
20881
  return {
20825
20882
  resource: {
20826
20883
  url: endpoint.url,
@@ -20832,6 +20889,7 @@ function endpointListing(endpoint, ref, config2, metadata = {}) {
20832
20889
  method: endpoint.method,
20833
20890
  ...endpoint.payment?.network === void 0 ? {} : { network: endpoint.payment.network },
20834
20891
  price: endpoint.price,
20892
+ ...verification === void 0 ? {} : { verification },
20835
20893
  metadata: {
20836
20894
  ...metadata,
20837
20895
  ...endpoint.operationId === void 0 ? {} : { operationId: endpoint.operationId },