@vapi-network/sources 0.3.0 → 0.7.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 +27 -2
- package/dist/index.js +110 -50
- package/dist/index.js.map +1 -1
- package/dist/vapi-registry.d.ts +13 -1
- package/dist/vapi-registry.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,5 +10,30 @@ One entry point, `@vapi-network/sources`, exporting `vapiRegistrySource`,
|
|
|
10
10
|
`bazaarSource`, `localFileSource` and `x402scanSource`. The x402scan adapter is
|
|
11
11
|
intentionally a stub until x402scan documents a stable public read API.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
## Exports
|
|
14
|
+
|
|
15
|
+
### Runtime exports
|
|
16
|
+
|
|
17
|
+
| Name | What it is | Since |
|
|
18
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------- |
|
|
19
|
+
| `bazaarSource` | function (facilitatorUrl: string, options: BazaarSourceOptions = {}): Source | 0.5.0 or earlier |
|
|
20
|
+
| `findMarketplaceApiByRef` | function (ref: string, config: VapiRegistryConfig, fetchImpl?: Fetch): Promise<MarketplaceHit \| null> | 0.5.0 or earlier |
|
|
21
|
+
| `localFileSource` | function (path: string): Source | 0.5.0 or earlier |
|
|
22
|
+
| `mapBazaarItem` | function (value: unknown, sourceUrl: string): Listing \| undefined | 0.5.0 or earlier |
|
|
23
|
+
| `resolveServiceEndpoint` | function (id: string, config: VapiRegistryConfig, fetchImpl?: Fetch, endpointName?: string): Promise<DiscoveryEndpoint> | 0.5.0 or earlier |
|
|
24
|
+
| `resolveServiceListing` | function (id: string, config: VapiRegistryConfig, fetchImpl?: Fetch, endpointName?: string): Promise<ResolvedListing> | 0.5.0 or earlier |
|
|
25
|
+
| `searchMarketplace` | function (input: MarketplaceSearchInput, config: VapiRegistryConfig, fetchImpl?: Fetch, options: MarketplaceSearchOptions = {}): Promise<MarketplaceDiscoveryPage> | 0.5.0 or earlier |
|
|
26
|
+
| `vapiRegistrySource` | function (baseUrl: string, options: VapiRegistrySourceOptions = {}): Source | 0.5.0 or earlier |
|
|
27
|
+
| `x402scanSource` | function (): Source | 0.5.0 or earlier |
|
|
28
|
+
|
|
29
|
+
### Types
|
|
30
|
+
|
|
31
|
+
| Name | What it is | Since |
|
|
32
|
+
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
|
|
33
|
+
| `BazaarSourceOptions` | type BazaarSourceOptions = GuardedSourceOptions | 0.5.0 or earlier |
|
|
34
|
+
| `MarketplaceSearchInput` | type MarketplaceSearchInput = { query?: string; kinds?: MarketplaceKind[]; network?: string; limit?: number; cursor?: string; includeUnverified?: boolean; } | 0.5.0 or earlier |
|
|
35
|
+
| `MarketplaceSearchOptions` | type MarketplaceSearchOptions = Readonly<{ searchesPath?: string; now?: Date; nowMs?: () => number; notice?: (message: string) => void; }> | 0.5.0 or earlier |
|
|
36
|
+
| `VapiRegistryConfig` | type VapiRegistryConfig = Readonly<{ discoveryUrl: string; marketplaceDiscoveryUrl: string; registryFallbacks?: ReadonlyArray< Readonly<{ discoveryUrl: string; marketplaceDiscoveryUrl: string }> >; allowPrivateNetwork?: boolean; }> | 0.5.0 or earlier |
|
|
37
|
+
| `VapiRegistrySourceOptions` | type VapiRegistrySourceOptions = GuardedSourceOptions & Readonly<{ discoveryUrl?: string; }> | 0.5.0 or earlier |
|
|
38
|
+
|
|
39
|
+
See the [root README](https://github.com/vAPI-Network/vapi-network/blob/main/docs/call.md) for 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
|
|
|
@@ -20247,7 +20280,18 @@ var NETWORKS = {
|
|
|
20247
20280
|
usdc: CANONICAL_X402_USDC_NETWORKS[BASE_MAINNET_CAIP2].usdc,
|
|
20248
20281
|
gasToken: "ETH",
|
|
20249
20282
|
rpcEnv: "BASE_RPC_URL",
|
|
20250
|
-
publicRpcUrl: "https://mainnet.base.org"
|
|
20283
|
+
publicRpcUrl: "https://mainnet.base.org",
|
|
20284
|
+
explorerUrl: "https://basescan.org"
|
|
20285
|
+
},
|
|
20286
|
+
[ARC_MAINNET_CAIP2]: {
|
|
20287
|
+
family: "evm",
|
|
20288
|
+
chainId: 5042,
|
|
20289
|
+
name: "Arc mainnet",
|
|
20290
|
+
usdc: CANONICAL_X402_USDC_NETWORKS[ARC_MAINNET_CAIP2].usdc,
|
|
20291
|
+
gasToken: "USDC",
|
|
20292
|
+
rpcEnv: "ARC_RPC_URL",
|
|
20293
|
+
publicRpcUrl: "https://rpc.mainnet.arc.io",
|
|
20294
|
+
explorerUrl: "https://explorer.arc.io"
|
|
20251
20295
|
},
|
|
20252
20296
|
[ARC_TESTNET_CAIP2]: {
|
|
20253
20297
|
family: "evm",
|
|
@@ -20340,7 +20384,8 @@ var configSchema = external_exports.object({
|
|
|
20340
20384
|
}).optional()
|
|
20341
20385
|
})
|
|
20342
20386
|
),
|
|
20343
|
-
spendCaps: spendCapsSchema
|
|
20387
|
+
spendCaps: spendCapsSchema,
|
|
20388
|
+
device: external_exports.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/).optional()
|
|
20344
20389
|
}).superRefine((config2, context) => {
|
|
20345
20390
|
for (const [network, configured] of Object.entries(config2.networks)) {
|
|
20346
20391
|
if (isSolanaNetwork(network)) {
|
|
@@ -20354,7 +20399,14 @@ var configSchema = external_exports.object({
|
|
|
20354
20399
|
continue;
|
|
20355
20400
|
}
|
|
20356
20401
|
try {
|
|
20357
|
-
getAddress(configured.usdc);
|
|
20402
|
+
const usdc = getAddress(configured.usdc);
|
|
20403
|
+
if ((network === ARC_MAINNET_CAIP2 || network === ARC_TESTNET_CAIP2) && usdc !== getAddress(NETWORKS[network].usdc)) {
|
|
20404
|
+
context.addIssue({
|
|
20405
|
+
code: "custom",
|
|
20406
|
+
path: ["networks", network, "usdc"],
|
|
20407
|
+
message: "Expected the canonical Arc USDC predeploy."
|
|
20408
|
+
});
|
|
20409
|
+
}
|
|
20358
20410
|
} catch {
|
|
20359
20411
|
context.addIssue({
|
|
20360
20412
|
code: "custom",
|
|
@@ -20367,6 +20419,7 @@ var configSchema = external_exports.object({
|
|
|
20367
20419
|
function getVapiPaths(directory = process.env.VAPI_HOME?.trim() || join(homedir(), ".vapi")) {
|
|
20368
20420
|
return {
|
|
20369
20421
|
directory,
|
|
20422
|
+
agentsDir: join(directory, "agents"),
|
|
20370
20423
|
config: join(directory, "config.json"),
|
|
20371
20424
|
keystore: join(directory, "keystore.json"),
|
|
20372
20425
|
receipts: join(directory, "receipts.jsonl"),
|
|
@@ -20670,7 +20723,8 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
|
|
|
20670
20723
|
kinds: input2.kinds,
|
|
20671
20724
|
network: input2.network,
|
|
20672
20725
|
limit: input2.limit,
|
|
20673
|
-
cursor: input2.cursor
|
|
20726
|
+
cursor: input2.cursor,
|
|
20727
|
+
includeUnverified: input2.includeUnverified
|
|
20674
20728
|
});
|
|
20675
20729
|
const startedAt = options.now ?? /* @__PURE__ */ new Date();
|
|
20676
20730
|
const attempts = [];
|
|
@@ -20689,6 +20743,9 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
|
|
|
20689
20743
|
if (normalized.network !== void 0) url2.searchParams.set("network", normalized.network);
|
|
20690
20744
|
if (normalized.limit !== void 0) url2.searchParams.set("limit", String(normalized.limit));
|
|
20691
20745
|
if (normalized.cursor !== void 0) url2.searchParams.set("cursor", normalized.cursor);
|
|
20746
|
+
if (normalized.includeUnverified === true) {
|
|
20747
|
+
url2.searchParams.set("includeUnverified", "true");
|
|
20748
|
+
}
|
|
20692
20749
|
}
|
|
20693
20750
|
});
|
|
20694
20751
|
const page = marketplaceDiscoveryPageSchema.parse(await response.json());
|
|
@@ -20719,7 +20776,7 @@ async function resolveServiceListing(id, config2, fetchImpl, endpointName) {
|
|
|
20719
20776
|
}
|
|
20720
20777
|
async function findMarketplaceApiByRef(ref, config2, fetchImpl) {
|
|
20721
20778
|
const page = await searchMarketplace(
|
|
20722
|
-
{ query: ref, kinds: ["api"], limit: 50 },
|
|
20779
|
+
{ query: ref, kinds: ["api"], limit: 50, includeUnverified: true },
|
|
20723
20780
|
config2,
|
|
20724
20781
|
fetchImpl
|
|
20725
20782
|
);
|
|
@@ -20734,37 +20791,36 @@ function vapiRegistrySource(baseUrl, options = {}) {
|
|
|
20734
20791
|
const fetchImpl = sourceFetch(options);
|
|
20735
20792
|
return {
|
|
20736
20793
|
id: "vapi",
|
|
20737
|
-
async search(query) {
|
|
20738
|
-
const page = await searchMarketplace(
|
|
20794
|
+
async search(query, searchOptions) {
|
|
20795
|
+
const page = await searchMarketplace(
|
|
20796
|
+
{
|
|
20797
|
+
query,
|
|
20798
|
+
kinds: ["api"],
|
|
20799
|
+
...searchOptions?.includeUnverified === void 0 ? {} : { includeUnverified: searchOptions.includeUnverified }
|
|
20800
|
+
},
|
|
20801
|
+
config2,
|
|
20802
|
+
fetchImpl
|
|
20803
|
+
);
|
|
20739
20804
|
const mapped = await Promise.all(
|
|
20740
20805
|
page.items.map(async (hit) => {
|
|
20741
20806
|
if (hit.kind !== "api") return null;
|
|
20742
20807
|
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
|
-
};
|
|
20808
|
+
return mirroredListing(hit, config2);
|
|
20759
20809
|
}
|
|
20760
20810
|
try {
|
|
20761
20811
|
const endpoint = await resolveServiceEndpoint(hit.ref, config2, fetchImpl);
|
|
20762
|
-
return endpointListing(
|
|
20763
|
-
|
|
20764
|
-
|
|
20765
|
-
|
|
20766
|
-
|
|
20767
|
-
|
|
20812
|
+
return endpointListing(
|
|
20813
|
+
endpoint,
|
|
20814
|
+
hit.ref,
|
|
20815
|
+
config2,
|
|
20816
|
+
{
|
|
20817
|
+
card: hit.card,
|
|
20818
|
+
action: hit.action,
|
|
20819
|
+
execution: hit.execution,
|
|
20820
|
+
registryProvenance: hit.provenance
|
|
20821
|
+
},
|
|
20822
|
+
hit.verification
|
|
20823
|
+
);
|
|
20768
20824
|
} catch (error61) {
|
|
20769
20825
|
if (!(error61 instanceof DiscoveryCatalogError)) throw error61;
|
|
20770
20826
|
return null;
|
|
@@ -20775,31 +20831,20 @@ function vapiRegistrySource(baseUrl, options = {}) {
|
|
|
20775
20831
|
},
|
|
20776
20832
|
async inspect(ref) {
|
|
20777
20833
|
try {
|
|
20778
|
-
const endpoint = await
|
|
20779
|
-
return endpointListing(endpoint, ref, config2);
|
|
20834
|
+
const { endpoint, service } = await resolveServiceListing(ref, config2, fetchImpl);
|
|
20835
|
+
return endpointListing(endpoint, ref, config2, {}, service.verification);
|
|
20780
20836
|
} catch (resolutionError) {
|
|
20781
20837
|
if (!(resolutionError instanceof DiscoveryCatalogError) || resolutionError.code !== "service_not_found") {
|
|
20782
20838
|
throw resolutionError;
|
|
20783
20839
|
}
|
|
20784
|
-
const page = await searchMarketplace(
|
|
20840
|
+
const page = await searchMarketplace(
|
|
20841
|
+
{ query: ref, kinds: ["api"], includeUnverified: true },
|
|
20842
|
+
config2,
|
|
20843
|
+
fetchImpl
|
|
20844
|
+
);
|
|
20785
20845
|
const hit = page.items.find((item) => item.kind === "api" && item.ref === ref);
|
|
20786
20846
|
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
|
-
};
|
|
20847
|
+
return mirroredListing(hit, config2);
|
|
20803
20848
|
}
|
|
20804
20849
|
if (page.items.some((item) => item.kind === "api" && item.ref === ref)) {
|
|
20805
20850
|
throw resolutionError;
|
|
@@ -20816,11 +20861,25 @@ async function fetchCallsDiscovery(query, config2, fetchImpl) {
|
|
|
20816
20861
|
request: fetchImpl,
|
|
20817
20862
|
configureUrl(url2) {
|
|
20818
20863
|
url2.searchParams.set("q", query);
|
|
20864
|
+
url2.searchParams.set("includeUnverified", "true");
|
|
20819
20865
|
}
|
|
20820
20866
|
});
|
|
20821
20867
|
return parseDiscovery(await response.json());
|
|
20822
20868
|
}
|
|
20823
|
-
function
|
|
20869
|
+
function mirroredListing(hit, config2) {
|
|
20870
|
+
return {
|
|
20871
|
+
resource: { url: hit.execution.url, description: hit.card.summary },
|
|
20872
|
+
name: hit.card.title,
|
|
20873
|
+
description: hit.card.summary,
|
|
20874
|
+
...hit.execution.method === null ? {} : { method: hit.execution.method },
|
|
20875
|
+
network: hit.execution.network,
|
|
20876
|
+
...optionalPrice(hit.card.facts),
|
|
20877
|
+
verification: hit.verification,
|
|
20878
|
+
metadata: { card: hit.card, action: hit.action, execution: hit.execution },
|
|
20879
|
+
provenance: [{ source: "vapi", sourceUrl: config2.marketplaceDiscoveryUrl, ref: hit.ref }]
|
|
20880
|
+
};
|
|
20881
|
+
}
|
|
20882
|
+
function endpointListing(endpoint, ref, config2, metadata = {}, verification) {
|
|
20824
20883
|
return {
|
|
20825
20884
|
resource: {
|
|
20826
20885
|
url: endpoint.url,
|
|
@@ -20832,6 +20891,7 @@ function endpointListing(endpoint, ref, config2, metadata = {}) {
|
|
|
20832
20891
|
method: endpoint.method,
|
|
20833
20892
|
...endpoint.payment?.network === void 0 ? {} : { network: endpoint.payment.network },
|
|
20834
20893
|
price: endpoint.price,
|
|
20894
|
+
...verification === void 0 ? {} : { verification },
|
|
20835
20895
|
metadata: {
|
|
20836
20896
|
...metadata,
|
|
20837
20897
|
...endpoint.operationId === void 0 ? {} : { operationId: endpoint.operationId },
|