@vapi-network/mcp 0.9.0 → 0.9.2
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/dist/actions/call.d.ts +3 -3
- package/dist/actions/register.d.ts +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1172 -835
- package/dist/index.js.map +3 -3
- package/dist/server.d.ts +0 -1
- package/dist/tools/call.d.ts +12 -2
- package/dist/tools/tasks.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28903,365 +28903,6 @@ function date4(params) {
|
|
|
28903
28903
|
return _coercedDate(ZodDate, params);
|
|
28904
28904
|
}
|
|
28905
28905
|
|
|
28906
|
-
// ../core/src/marketplace-contracts.ts
|
|
28907
|
-
var MARKETPLACE_DISCOVERY_PROTOCOL = "vapi.marketplace.discovery/1";
|
|
28908
|
-
var MARKETPLACE_RANKING_VERSION = "marketplace-ranking-v1";
|
|
28909
|
-
var MARKETPLACE_KINDS = ["api", "service_offer", "open_request"];
|
|
28910
|
-
var MARKETPLACE_EXECUTION_METHODS = [
|
|
28911
|
-
"GET",
|
|
28912
|
-
"HEAD",
|
|
28913
|
-
"POST",
|
|
28914
|
-
"PUT",
|
|
28915
|
-
"PATCH",
|
|
28916
|
-
"DELETE"
|
|
28917
|
-
];
|
|
28918
|
-
var marketplaceExecutionMethodSchema = external_exports.enum(MARKETPLACE_EXECUTION_METHODS);
|
|
28919
|
-
var marketplaceKindSchema = external_exports.enum(MARKETPLACE_KINDS);
|
|
28920
|
-
var EXECUTION_MODES = ["direct", "gateway"];
|
|
28921
|
-
var executionModeSchema = external_exports.enum(EXECUTION_MODES);
|
|
28922
|
-
var PROVENANCES = ["indexed", "self_listed", "partner"];
|
|
28923
|
-
var provenanceSchema = external_exports.enum(PROVENANCES);
|
|
28924
|
-
var FIRST_PARTY_PROVENANCES = ["self_listed", "partner"];
|
|
28925
|
-
var firstPartyProvenanceSchema = external_exports.enum(FIRST_PARTY_PROVENANCES);
|
|
28926
|
-
var LISTING_GROUPS = ["vapi", "added", "partner", "external"];
|
|
28927
|
-
var listingGroupSchema = external_exports.enum(LISTING_GROUPS);
|
|
28928
|
-
var listingFeeSchema = external_exports.looseObject({
|
|
28929
|
-
bps: external_exports.number().int().min(0),
|
|
28930
|
-
label: external_exports.string()
|
|
28931
|
-
});
|
|
28932
|
-
var LISTING_VERIFICATIONS = ["none", "requested", "verified"];
|
|
28933
|
-
var listingVerificationSchema = external_exports.enum(LISTING_VERIFICATIONS);
|
|
28934
|
-
var listingVerificationFieldSchema = listingVerificationSchema.default("none").catch("none");
|
|
28935
|
-
var listingLivenessSchema = external_exports.looseObject({
|
|
28936
|
-
uptime7d: external_exports.number().min(0).max(1),
|
|
28937
|
-
latencyP50Ms: external_exports.number().nonnegative().nullable(),
|
|
28938
|
-
latencyP95Ms: external_exports.number().nonnegative().nullable(),
|
|
28939
|
-
checks7d: external_exports.number().int().nonnegative()
|
|
28940
|
-
});
|
|
28941
|
-
var listingConformanceSchema = external_exports.looseObject({
|
|
28942
|
-
declaredVersion: external_exports.union([external_exports.literal(1), external_exports.literal(2)]).nullable(),
|
|
28943
|
-
versionConformant: external_exports.boolean(),
|
|
28944
|
-
offerTransport: external_exports.enum(["body", "header", "both"]),
|
|
28945
|
-
issues: external_exports.array(external_exports.string())
|
|
28946
|
-
});
|
|
28947
|
-
var listingIdentitySchema = external_exports.looseObject({
|
|
28948
|
-
erc8004Id: external_exports.string().trim().min(1),
|
|
28949
|
-
reputation: external_exports.looseObject({
|
|
28950
|
-
score: external_exports.number().finite(),
|
|
28951
|
-
count: external_exports.number().int().nonnegative()
|
|
28952
|
-
}).optional().catch(void 0)
|
|
28953
|
-
});
|
|
28954
|
-
var listingDisclosureShape = {
|
|
28955
|
-
group: listingGroupSchema.optional(),
|
|
28956
|
-
fee: listingFeeSchema.optional(),
|
|
28957
|
-
verification: listingVerificationFieldSchema,
|
|
28958
|
-
liveness: listingLivenessSchema.optional().catch(void 0),
|
|
28959
|
-
conformance: listingConformanceSchema.optional().catch(void 0),
|
|
28960
|
-
identity: listingIdentitySchema.optional().catch(void 0)
|
|
28961
|
-
};
|
|
28962
|
-
var marketplaceBadgeCodeSchema = external_exports.enum([
|
|
28963
|
-
"live_x402",
|
|
28964
|
-
"partner",
|
|
28965
|
-
"payout_wallet_confirmed",
|
|
28966
|
-
"vapi_verified",
|
|
28967
|
-
"external_catalog",
|
|
28968
|
-
"approved_vendor"
|
|
28969
|
-
]);
|
|
28970
|
-
var marketplaceBadgeSchema = external_exports.looseObject({
|
|
28971
|
-
code: marketplaceBadgeCodeSchema,
|
|
28972
|
-
label: external_exports.string().trim().min(1).max(80)
|
|
28973
|
-
});
|
|
28974
|
-
var marketplacePublicFactSchema = external_exports.looseObject({
|
|
28975
|
-
label: external_exports.string().trim().min(1).max(80),
|
|
28976
|
-
value: external_exports.string().trim().min(1).max(160)
|
|
28977
|
-
});
|
|
28978
|
-
var marketplaceHrefSchema = external_exports.union([
|
|
28979
|
-
external_exports.string().trim().min(1).max(2048).regex(/^\/(?!\/)/),
|
|
28980
|
-
external_exports.url().max(2048).regex(/^https:\/\//)
|
|
28981
|
-
]);
|
|
28982
|
-
var marketplaceCardSchema = external_exports.looseObject({
|
|
28983
|
-
title: external_exports.string().trim().min(1).max(160),
|
|
28984
|
-
summary: external_exports.string().trim().min(1).max(1e3),
|
|
28985
|
-
byline: external_exports.string().trim().min(1).max(160).optional(),
|
|
28986
|
-
bylineHref: marketplaceHrefSchema.optional(),
|
|
28987
|
-
badges: external_exports.array(marketplaceBadgeSchema).max(8),
|
|
28988
|
-
facts: external_exports.array(marketplacePublicFactSchema).max(12)
|
|
28989
|
-
});
|
|
28990
|
-
var marketplaceHitBase = {
|
|
28991
|
-
ref: external_exports.string().trim().min(1).max(512),
|
|
28992
|
-
card: marketplaceCardSchema,
|
|
28993
|
-
...listingDisclosureShape
|
|
28994
|
-
};
|
|
28995
|
-
var invokeApiActionSchema = external_exports.looseObject({
|
|
28996
|
-
type: external_exports.literal("invoke_api"),
|
|
28997
|
-
href: marketplaceHrefSchema
|
|
28998
|
-
});
|
|
28999
|
-
var firstPartyApiMarketplaceHitSchema = external_exports.looseObject({
|
|
29000
|
-
...marketplaceHitBase,
|
|
29001
|
-
kind: external_exports.literal("api"),
|
|
29002
|
-
provenance: firstPartyProvenanceSchema,
|
|
29003
|
-
execution: external_exports.looseObject({
|
|
29004
|
-
mode: executionModeSchema
|
|
29005
|
-
}),
|
|
29006
|
-
action: invokeApiActionSchema
|
|
29007
|
-
});
|
|
29008
|
-
var mirroredApiMarketplaceHitSchema = external_exports.looseObject({
|
|
29009
|
-
...marketplaceHitBase,
|
|
29010
|
-
kind: external_exports.literal("api"),
|
|
29011
|
-
provenance: external_exports.literal("indexed"),
|
|
29012
|
-
execution: external_exports.looseObject({
|
|
29013
|
-
mode: external_exports.literal("direct"),
|
|
29014
|
-
url: external_exports.url().max(2048).regex(/^https:\/\/(?![^/?#]*@)/),
|
|
29015
|
-
method: marketplaceExecutionMethodSchema.nullable(),
|
|
29016
|
-
network: external_exports.string().trim().max(160).regex(/^eip155:[1-9]\d*$/)
|
|
29017
|
-
}),
|
|
29018
|
-
action: invokeApiActionSchema
|
|
29019
|
-
});
|
|
29020
|
-
var apiMarketplaceHitSchema = external_exports.discriminatedUnion("provenance", [
|
|
29021
|
-
firstPartyApiMarketplaceHitSchema,
|
|
29022
|
-
mirroredApiMarketplaceHitSchema
|
|
29023
|
-
]);
|
|
29024
|
-
var serviceOfferMarketplaceHitSchema = external_exports.looseObject({
|
|
29025
|
-
...marketplaceHitBase,
|
|
29026
|
-
kind: external_exports.literal("service_offer"),
|
|
29027
|
-
action: external_exports.looseObject({
|
|
29028
|
-
type: external_exports.literal("start_engagement"),
|
|
29029
|
-
href: marketplaceHrefSchema
|
|
29030
|
-
})
|
|
29031
|
-
});
|
|
29032
|
-
var openRequestMarketplaceHitSchema = external_exports.looseObject({
|
|
29033
|
-
...marketplaceHitBase,
|
|
29034
|
-
kind: external_exports.literal("open_request"),
|
|
29035
|
-
action: external_exports.looseObject({
|
|
29036
|
-
type: external_exports.literal("propose_to_request"),
|
|
29037
|
-
href: marketplaceHrefSchema
|
|
29038
|
-
})
|
|
29039
|
-
});
|
|
29040
|
-
var marketplaceHitSchema = external_exports.union([
|
|
29041
|
-
apiMarketplaceHitSchema,
|
|
29042
|
-
serviceOfferMarketplaceHitSchema,
|
|
29043
|
-
openRequestMarketplaceHitSchema
|
|
29044
|
-
]);
|
|
29045
|
-
var marketplaceDiscoveryInputSchema = external_exports.strictObject({
|
|
29046
|
-
q: external_exports.string().trim().max(200).optional(),
|
|
29047
|
-
kinds: external_exports.array(marketplaceKindSchema).min(1).max(MARKETPLACE_KINDS.length).optional(),
|
|
29048
|
-
network: external_exports.string().trim().min(1).max(160).optional(),
|
|
29049
|
-
cursor: external_exports.string().trim().min(1).max(4096).optional(),
|
|
29050
|
-
limit: external_exports.number().int().min(1).max(50).optional(),
|
|
29051
|
-
includeUnverified: external_exports.boolean().optional()
|
|
29052
|
-
}).superRefine((input2, context) => {
|
|
29053
|
-
if (input2.kinds && new Set(input2.kinds).size !== input2.kinds.length) {
|
|
29054
|
-
context.addIssue({
|
|
29055
|
-
code: "custom",
|
|
29056
|
-
path: ["kinds"],
|
|
29057
|
-
message: "Marketplace kinds must be unique"
|
|
29058
|
-
});
|
|
29059
|
-
}
|
|
29060
|
-
});
|
|
29061
|
-
function isMirroredHit(hit) {
|
|
29062
|
-
return hit.kind === "api" && hit.provenance === "indexed";
|
|
29063
|
-
}
|
|
29064
|
-
var marketplaceDiscoveryPageSchema = external_exports.looseObject({
|
|
29065
|
-
protocol: external_exports.literal(MARKETPLACE_DISCOVERY_PROTOCOL),
|
|
29066
|
-
items: external_exports.array(marketplaceHitSchema),
|
|
29067
|
-
nextCursor: external_exports.string().min(1).max(4096).nullable(),
|
|
29068
|
-
unavailableKinds: external_exports.array(marketplaceKindSchema).max(MARKETPLACE_KINDS.length),
|
|
29069
|
-
rankingVersion: external_exports.literal(MARKETPLACE_RANKING_VERSION)
|
|
29070
|
-
});
|
|
29071
|
-
|
|
29072
|
-
// ../core/src/call-contracts-wire.ts
|
|
29073
|
-
var CALLABLE_CATEGORIES = ["ai", "data", "crypto", "compute", "search"];
|
|
29074
|
-
var callableCategorySchema = external_exports.enum(CALLABLE_CATEGORIES);
|
|
29075
|
-
var DISCOVERY_CATEGORIES = [...CALLABLE_CATEGORIES, "other"];
|
|
29076
|
-
var discoveryCategorySchema = external_exports.enum(DISCOVERY_CATEGORIES);
|
|
29077
|
-
var CALLABLE_CATEGORY_SET = new Set(CALLABLE_CATEGORIES);
|
|
29078
|
-
var serviceTierSchema = external_exports.enum(["listed", "verified", "partner"]);
|
|
29079
|
-
var discoveryEndpointSchema = external_exports.looseObject({
|
|
29080
|
-
name: external_exports.string(),
|
|
29081
|
-
method: external_exports.string(),
|
|
29082
|
-
url: external_exports.url(),
|
|
29083
|
-
price: external_exports.string(),
|
|
29084
|
-
description: external_exports.string(),
|
|
29085
|
-
operationId: external_exports.string().trim().min(1).optional(),
|
|
29086
|
-
requestContentType: external_exports.string().trim().min(1).optional(),
|
|
29087
|
-
requestSchema: external_exports.json().optional(),
|
|
29088
|
-
responseContentType: external_exports.string().trim().min(1).optional(),
|
|
29089
|
-
pathTemplate: external_exports.string().trim().min(1).optional(),
|
|
29090
|
-
pathParameters: external_exports.array(external_exports.string().trim().min(1)).optional(),
|
|
29091
|
-
payment: external_exports.looseObject({
|
|
29092
|
-
scheme: external_exports.literal("exact"),
|
|
29093
|
-
network: external_exports.string().regex(/^eip155:\d+$/),
|
|
29094
|
-
asset: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
29095
|
-
payTo: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
29096
|
-
checkedAt: external_exports.iso.datetime()
|
|
29097
|
-
}).optional()
|
|
29098
|
-
});
|
|
29099
|
-
var serviceSummarySchema = external_exports.looseObject({
|
|
29100
|
-
id: external_exports.string(),
|
|
29101
|
-
name: external_exports.string(),
|
|
29102
|
-
description: external_exports.string(),
|
|
29103
|
-
category: discoveryCategorySchema,
|
|
29104
|
-
tier: serviceTierSchema,
|
|
29105
|
-
...listingDisclosureShape,
|
|
29106
|
-
verified: external_exports.boolean(),
|
|
29107
|
-
wrapped: external_exports.boolean(),
|
|
29108
|
-
price: external_exports.string(),
|
|
29109
|
-
networks: external_exports.array(external_exports.string()),
|
|
29110
|
-
endpoints: external_exports.array(discoveryEndpointSchema)
|
|
29111
|
-
});
|
|
29112
|
-
var searchServicesResponseSchema = external_exports.looseObject({
|
|
29113
|
-
services: external_exports.array(serviceSummarySchema)
|
|
29114
|
-
});
|
|
29115
|
-
var discoveryResponseSchema = searchServicesResponseSchema;
|
|
29116
|
-
|
|
29117
|
-
// ../core/src/call-contracts.ts
|
|
29118
|
-
var DiscoveryCatalogError = class extends Error {
|
|
29119
|
-
name = "DiscoveryCatalogError";
|
|
29120
|
-
code;
|
|
29121
|
-
serviceId;
|
|
29122
|
-
constructor(code, message, serviceId) {
|
|
29123
|
-
super(message);
|
|
29124
|
-
this.code = code;
|
|
29125
|
-
this.serviceId = serviceId;
|
|
29126
|
-
}
|
|
29127
|
-
};
|
|
29128
|
-
function parseDiscovery(raw) {
|
|
29129
|
-
const parsed = discoveryResponseSchema.safeParse(raw);
|
|
29130
|
-
if (!parsed.success) {
|
|
29131
|
-
const malformedUrl = parsed.error.issues.find(
|
|
29132
|
-
(issue2) => issue2.path.at(-1) === "url" && issue2.path.includes("endpoints")
|
|
29133
|
-
);
|
|
29134
|
-
if (malformedUrl) {
|
|
29135
|
-
const serviceIndex = pathIndexAfter(malformedUrl.path, "services");
|
|
29136
|
-
const serviceId = rawServiceId(raw, serviceIndex);
|
|
29137
|
-
throw new DiscoveryCatalogError(
|
|
29138
|
-
"malformed_url",
|
|
29139
|
-
`Service ${JSON.stringify(serviceId ?? "unknown")} has a malformed endpoint URL.`,
|
|
29140
|
-
serviceId
|
|
29141
|
-
);
|
|
29142
|
-
}
|
|
29143
|
-
throw new DiscoveryCatalogError("invalid_discovery", "Discovery response is malformed.");
|
|
29144
|
-
}
|
|
29145
|
-
for (const service of parsed.data.services) {
|
|
29146
|
-
buildTargets(service);
|
|
29147
|
-
}
|
|
29148
|
-
const resolveListing = (serviceId, endpointName) => {
|
|
29149
|
-
const service = parsed.data.services.find((candidate) => candidate.id === serviceId);
|
|
29150
|
-
if (!service) {
|
|
29151
|
-
throw new DiscoveryCatalogError(
|
|
29152
|
-
"service_not_found",
|
|
29153
|
-
`No payable endpoint found for service ${JSON.stringify(serviceId)}.`,
|
|
29154
|
-
serviceId
|
|
29155
|
-
);
|
|
29156
|
-
}
|
|
29157
|
-
return { service, endpoint: resolveTarget(service, endpointName) };
|
|
29158
|
-
};
|
|
29159
|
-
return {
|
|
29160
|
-
services: parsed.data.services,
|
|
29161
|
-
resolve: (serviceId, endpointName) => resolveListing(serviceId, endpointName).endpoint,
|
|
29162
|
-
resolveListing
|
|
29163
|
-
};
|
|
29164
|
-
}
|
|
29165
|
-
function resolveTarget(service, endpointName) {
|
|
29166
|
-
const { targets, targetsByName } = buildTargets(service);
|
|
29167
|
-
if (endpointName !== void 0) {
|
|
29168
|
-
const selected = targetsByName.get(endpointName.trim());
|
|
29169
|
-
if (!selected) {
|
|
29170
|
-
throw new DiscoveryCatalogError(
|
|
29171
|
-
"endpoint_not_found",
|
|
29172
|
-
`Service ${JSON.stringify(service.id)} has no endpoint ${JSON.stringify(endpointName)}. Available endpoints: ${[...targetsByName.keys()].join(", ")}.`,
|
|
29173
|
-
service.id
|
|
29174
|
-
);
|
|
29175
|
-
}
|
|
29176
|
-
return { ...selected };
|
|
29177
|
-
}
|
|
29178
|
-
if (targets.size !== 1) {
|
|
29179
|
-
throw new DiscoveryCatalogError(
|
|
29180
|
-
"ambiguous_default",
|
|
29181
|
-
`Service ${JSON.stringify(service.id)} has ${targets.size} distinct payable endpoints. Choose one with endpoint: ${[...targetsByName.keys()].join(", ")}.`,
|
|
29182
|
-
service.id
|
|
29183
|
-
);
|
|
29184
|
-
}
|
|
29185
|
-
return targets.values().next().value;
|
|
29186
|
-
}
|
|
29187
|
-
function buildTargets(service) {
|
|
29188
|
-
if (service.endpoints.length === 0) {
|
|
29189
|
-
throw new DiscoveryCatalogError(
|
|
29190
|
-
"no_endpoint",
|
|
29191
|
-
`Service ${JSON.stringify(service.id)} has no payable endpoint.`,
|
|
29192
|
-
service.id
|
|
29193
|
-
);
|
|
29194
|
-
}
|
|
29195
|
-
const namedEndpoints = [...service.endpoints].sort(
|
|
29196
|
-
(left, right) => compareNames(left.name.trim(), right.name.trim())
|
|
29197
|
-
);
|
|
29198
|
-
const names = /* @__PURE__ */ new Set();
|
|
29199
|
-
const targets = /* @__PURE__ */ new Map();
|
|
29200
|
-
const targetsByName = /* @__PURE__ */ new Map();
|
|
29201
|
-
for (const endpoint of namedEndpoints) {
|
|
29202
|
-
const name = endpoint.name.trim();
|
|
29203
|
-
if (!name) {
|
|
29204
|
-
throw new DiscoveryCatalogError(
|
|
29205
|
-
"invalid_endpoint_name",
|
|
29206
|
-
`Service ${JSON.stringify(service.id)} has a blank endpoint name.`,
|
|
29207
|
-
service.id
|
|
29208
|
-
);
|
|
29209
|
-
}
|
|
29210
|
-
if (names.has(name)) {
|
|
29211
|
-
throw new DiscoveryCatalogError(
|
|
29212
|
-
"duplicate_endpoint_name",
|
|
29213
|
-
`Service ${JSON.stringify(service.id)} has duplicate endpoint name ${JSON.stringify(name)}.`,
|
|
29214
|
-
service.id
|
|
29215
|
-
);
|
|
29216
|
-
}
|
|
29217
|
-
names.add(name);
|
|
29218
|
-
const method = endpoint.method.trim().toUpperCase();
|
|
29219
|
-
if (!method) {
|
|
29220
|
-
throw new DiscoveryCatalogError(
|
|
29221
|
-
"blank_method",
|
|
29222
|
-
`Service ${JSON.stringify(service.id)} has a blank endpoint method.`,
|
|
29223
|
-
service.id
|
|
29224
|
-
);
|
|
29225
|
-
}
|
|
29226
|
-
const url2 = new URL(endpoint.url);
|
|
29227
|
-
if (url2.protocol !== "http:" && url2.protocol !== "https:") {
|
|
29228
|
-
throw new DiscoveryCatalogError(
|
|
29229
|
-
"malformed_url",
|
|
29230
|
-
`Service ${JSON.stringify(service.id)} has a non-HTTP endpoint URL.`,
|
|
29231
|
-
service.id
|
|
29232
|
-
);
|
|
29233
|
-
}
|
|
29234
|
-
const transportKey = `${method}\0${endpoint.url}`;
|
|
29235
|
-
const normalized = { ...endpoint, name, method };
|
|
29236
|
-
targetsByName.set(name, normalized);
|
|
29237
|
-
if (!targets.has(transportKey)) targets.set(transportKey, normalized);
|
|
29238
|
-
}
|
|
29239
|
-
return { targets, targetsByName };
|
|
29240
|
-
}
|
|
29241
|
-
function compareNames(left, right) {
|
|
29242
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
29243
|
-
}
|
|
29244
|
-
function pathIndexAfter(path, key2) {
|
|
29245
|
-
const keyIndex = path.indexOf(key2);
|
|
29246
|
-
const candidate = path[keyIndex + 1];
|
|
29247
|
-
return typeof candidate === "number" ? candidate : void 0;
|
|
29248
|
-
}
|
|
29249
|
-
function rawServiceId(raw, serviceIndex) {
|
|
29250
|
-
if (serviceIndex === void 0 || typeof raw !== "object" || raw === null) {
|
|
29251
|
-
return void 0;
|
|
29252
|
-
}
|
|
29253
|
-
const services = Reflect.get(raw, "services");
|
|
29254
|
-
if (!Array.isArray(services)) {
|
|
29255
|
-
return void 0;
|
|
29256
|
-
}
|
|
29257
|
-
const service = services[serviceIndex];
|
|
29258
|
-
if (typeof service !== "object" || service === null) {
|
|
29259
|
-
return void 0;
|
|
29260
|
-
}
|
|
29261
|
-
const id2 = Reflect.get(service, "id");
|
|
29262
|
-
return typeof id2 === "string" ? id2 : void 0;
|
|
29263
|
-
}
|
|
29264
|
-
|
|
29265
28906
|
// ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/index.js
|
|
29266
28907
|
init_exports();
|
|
29267
28908
|
|
|
@@ -38299,6 +37940,7 @@ var ARC_MAINNET_CAIP2 = "eip155:5042";
|
|
|
38299
37940
|
var ARC_TESTNET_CAIP2 = "eip155:5042002";
|
|
38300
37941
|
var SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
38301
37942
|
var X402_SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
37943
|
+
var SOLANA_DEVNET_CAIP2 = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
38302
37944
|
var SOLANA_MAINNET_USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
38303
37945
|
function canonicalIdentity(usdc, eip712Domain) {
|
|
38304
37946
|
return Object.freeze({
|
|
@@ -38342,374 +37984,184 @@ var BROWSER_ENABLED_X402_NETWORK_CONFIG = Object.freeze({
|
|
|
38342
37984
|
[ARC_TESTNET_CAIP2]: browserNetwork(arcTestnetUsdc)
|
|
38343
37985
|
});
|
|
38344
37986
|
|
|
38345
|
-
// ../core/src/
|
|
38346
|
-
|
|
38347
|
-
|
|
38348
|
-
|
|
38349
|
-
|
|
38350
|
-
|
|
38351
|
-
|
|
38352
|
-
|
|
38353
|
-
|
|
37987
|
+
// ../core/src/marketplace-contracts.ts
|
|
37988
|
+
var MARKETPLACE_DISCOVERY_PROTOCOL = "vapi.marketplace.discovery/1";
|
|
37989
|
+
var MARKETPLACE_RANKING_VERSION = "marketplace-ranking-v1";
|
|
37990
|
+
var MARKETPLACE_KINDS = ["api", "service_offer", "open_request"];
|
|
37991
|
+
var MARKETPLACE_EXECUTION_METHODS = [
|
|
37992
|
+
"GET",
|
|
37993
|
+
"HEAD",
|
|
37994
|
+
"POST",
|
|
37995
|
+
"PUT",
|
|
37996
|
+
"PATCH",
|
|
37997
|
+
"DELETE"
|
|
37998
|
+
];
|
|
37999
|
+
var marketplaceExecutionMethodSchema = external_exports.enum(MARKETPLACE_EXECUTION_METHODS);
|
|
38000
|
+
var marketplaceKindSchema = external_exports.enum(MARKETPLACE_KINDS);
|
|
38001
|
+
var EXECUTION_MODES = ["direct", "gateway"];
|
|
38002
|
+
var executionModeSchema = external_exports.enum(EXECUTION_MODES);
|
|
38003
|
+
var PROVENANCES = ["indexed", "self_listed", "partner"];
|
|
38004
|
+
var provenanceSchema = external_exports.enum(PROVENANCES);
|
|
38005
|
+
var FIRST_PARTY_PROVENANCES = ["self_listed", "partner"];
|
|
38006
|
+
var firstPartyProvenanceSchema = external_exports.enum(FIRST_PARTY_PROVENANCES);
|
|
38007
|
+
var LISTING_GROUPS = ["vapi", "added", "partner", "external"];
|
|
38008
|
+
var listingGroupSchema = external_exports.enum(LISTING_GROUPS);
|
|
38009
|
+
var listingFeeSchema = external_exports.looseObject({
|
|
38010
|
+
bps: external_exports.number().int().min(0),
|
|
38011
|
+
label: external_exports.string()
|
|
38012
|
+
});
|
|
38013
|
+
var LISTING_VERIFICATIONS = ["none", "requested", "verified"];
|
|
38014
|
+
var listingVerificationSchema = external_exports.enum(LISTING_VERIFICATIONS);
|
|
38015
|
+
var listingVerificationFieldSchema = listingVerificationSchema.default("none").catch("none");
|
|
38016
|
+
var listingLivenessSchema = external_exports.looseObject({
|
|
38017
|
+
uptime7d: external_exports.number().min(0).max(1),
|
|
38018
|
+
latencyP50Ms: external_exports.number().nonnegative().nullable(),
|
|
38019
|
+
latencyP95Ms: external_exports.number().nonnegative().nullable(),
|
|
38020
|
+
checks7d: external_exports.number().int().nonnegative()
|
|
38021
|
+
});
|
|
38022
|
+
var listingConformanceSchema = external_exports.looseObject({
|
|
38023
|
+
declaredVersion: external_exports.union([external_exports.literal(1), external_exports.literal(2)]).nullable(),
|
|
38024
|
+
versionConformant: external_exports.boolean(),
|
|
38025
|
+
offerTransport: external_exports.enum(["body", "header", "both"]),
|
|
38026
|
+
issues: external_exports.array(external_exports.string())
|
|
38027
|
+
});
|
|
38028
|
+
var listingIdentitySchema = external_exports.looseObject({
|
|
38029
|
+
erc8004Id: external_exports.string().trim().min(1),
|
|
38030
|
+
reputation: external_exports.looseObject({
|
|
38031
|
+
score: external_exports.number().finite(),
|
|
38032
|
+
count: external_exports.number().int().nonnegative()
|
|
38033
|
+
}).optional().catch(void 0)
|
|
38034
|
+
});
|
|
38035
|
+
var listingDisclosureShape = {
|
|
38036
|
+
group: listingGroupSchema.optional(),
|
|
38037
|
+
fee: listingFeeSchema.optional(),
|
|
38038
|
+
verification: listingVerificationFieldSchema,
|
|
38039
|
+
liveness: listingLivenessSchema.optional().catch(void 0),
|
|
38040
|
+
conformance: listingConformanceSchema.optional().catch(void 0),
|
|
38041
|
+
identity: listingIdentitySchema.optional().catch(void 0)
|
|
38354
38042
|
};
|
|
38355
|
-
|
|
38356
|
-
|
|
38357
|
-
|
|
38358
|
-
|
|
38359
|
-
|
|
38360
|
-
|
|
38361
|
-
|
|
38362
|
-
|
|
38363
|
-
|
|
38364
|
-
|
|
38365
|
-
|
|
38366
|
-
|
|
38367
|
-
|
|
38368
|
-
|
|
38369
|
-
|
|
38370
|
-
|
|
38371
|
-
|
|
38372
|
-
|
|
38373
|
-
|
|
38374
|
-
|
|
38375
|
-
|
|
38376
|
-
|
|
38377
|
-
|
|
38378
|
-
|
|
38379
|
-
|
|
38380
|
-
|
|
38381
|
-
|
|
38382
|
-
|
|
38383
|
-
|
|
38384
|
-
|
|
38385
|
-
|
|
38386
|
-
|
|
38387
|
-
}
|
|
38388
|
-
}
|
|
38389
|
-
function createPublicFetch(options) {
|
|
38390
|
-
const lookupFn = options.lookup ?? defaultLookup;
|
|
38391
|
-
return (async (input2, init) => {
|
|
38392
|
-
const url2 = new URL(input2 instanceof Request ? input2.url : input2);
|
|
38393
|
-
await assertPublicUrl(url2, {
|
|
38394
|
-
allowPrivateNetwork: options.allowPrivateNetwork,
|
|
38395
|
-
lookup: lookupFn,
|
|
38396
|
-
timeoutMs: 5e3
|
|
38397
|
-
});
|
|
38398
|
-
const normalized = new Request(input2, init);
|
|
38399
|
-
const bytes = normalized.body ? Buffer.from(await normalized.arrayBuffer()) : null;
|
|
38400
|
-
return await new Promise((resolve, reject) => {
|
|
38401
|
-
const requestOptions = {
|
|
38402
|
-
method: normalized.method,
|
|
38403
|
-
headers: Object.fromEntries(normalized.headers),
|
|
38404
|
-
signal: normalized.signal,
|
|
38405
|
-
...options.allowPrivateNetwork ? {} : { lookup: pinnedLookup(lookupFn) }
|
|
38406
|
-
};
|
|
38407
|
-
const onResponse = (incoming) => {
|
|
38408
|
-
try {
|
|
38409
|
-
const headers = new Headers();
|
|
38410
|
-
for (const [name, value] of Object.entries(incoming.headers)) {
|
|
38411
|
-
if (Array.isArray(value)) {
|
|
38412
|
-
for (const item of value) headers.append(name, item);
|
|
38413
|
-
} else if (value !== void 0) {
|
|
38414
|
-
headers.set(name, value);
|
|
38415
|
-
}
|
|
38416
|
-
}
|
|
38417
|
-
const status = incoming.statusCode ?? 500;
|
|
38418
|
-
const bodyForbidden = normalized.method === "HEAD" || [204, 205, 304].includes(status);
|
|
38419
|
-
if (bodyForbidden) incoming.resume();
|
|
38420
|
-
const response = new Response(
|
|
38421
|
-
bodyForbidden ? null : Readable.toWeb(incoming),
|
|
38422
|
-
{ status, statusText: incoming.statusMessage, headers }
|
|
38423
|
-
);
|
|
38424
|
-
Object.defineProperty(response, "url", { value: url2.toString() });
|
|
38425
|
-
resolve(response);
|
|
38426
|
-
} catch (error61) {
|
|
38427
|
-
incoming.destroy();
|
|
38428
|
-
reject(error61);
|
|
38429
|
-
}
|
|
38430
|
-
};
|
|
38431
|
-
const request = url2.protocol === "https:" ? httpsRequest(url2, requestOptions, onResponse) : httpRequest(url2, requestOptions, onResponse);
|
|
38432
|
-
request.on("error", reject);
|
|
38433
|
-
if (bytes) request.write(bytes);
|
|
38434
|
-
request.end();
|
|
38435
|
-
});
|
|
38436
|
-
});
|
|
38437
|
-
}
|
|
38438
|
-
function pinnedLookup(lookup) {
|
|
38439
|
-
return (hostname3, dnsOptions, callback) => {
|
|
38440
|
-
void lookup(normalizeHostname(hostname3)).then((addresses) => {
|
|
38441
|
-
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
38442
|
-
callback(guardError(new URL(`https://${hostname3}`)), "");
|
|
38443
|
-
return;
|
|
38444
|
-
}
|
|
38445
|
-
const address4 = addresses[0];
|
|
38446
|
-
const family = isIP(address4);
|
|
38447
|
-
callback(
|
|
38448
|
-
null,
|
|
38449
|
-
dnsOptions.all ? [{ address: address4, family }] : address4,
|
|
38450
|
-
dnsOptions.all ? void 0 : family
|
|
38451
|
-
);
|
|
38452
|
-
}).catch(
|
|
38453
|
-
(error61) => callback(error61 instanceof Error ? error61 : new Error("DNS lookup failed."), "")
|
|
38454
|
-
);
|
|
38455
|
-
};
|
|
38456
|
-
}
|
|
38457
|
-
async function withTimeout2(operation, timeoutMs) {
|
|
38458
|
-
let timeout;
|
|
38459
|
-
try {
|
|
38460
|
-
return await Promise.race([
|
|
38461
|
-
operation,
|
|
38462
|
-
new Promise((_resolve, reject) => {
|
|
38463
|
-
timeout = setTimeout(() => reject(new Error("DNS lookup timed out.")), timeoutMs);
|
|
38464
|
-
})
|
|
38465
|
-
]);
|
|
38466
|
-
} finally {
|
|
38467
|
-
if (timeout) clearTimeout(timeout);
|
|
38468
|
-
}
|
|
38469
|
-
}
|
|
38470
|
-
function normalizeHostname(hostname3) {
|
|
38471
|
-
const unbracketed = hostname3.startsWith("[") && hostname3.endsWith("]") ? hostname3.slice(1, -1) : hostname3;
|
|
38472
|
-
return unbracketed.endsWith(".") ? unbracketed.slice(0, -1) : unbracketed;
|
|
38473
|
-
}
|
|
38474
|
-
function isNonPublicAddress(address4) {
|
|
38475
|
-
const normalized = normalizeHostname(address4);
|
|
38476
|
-
const version5 = isIP(normalized);
|
|
38477
|
-
if (version5 === 4) {
|
|
38478
|
-
return isNonPublicIpv4(parseIpv4(normalized));
|
|
38479
|
-
}
|
|
38480
|
-
if (version5 === 6) {
|
|
38481
|
-
return isNonPublicIpv6(parseIpv6(normalized));
|
|
38482
|
-
}
|
|
38483
|
-
return true;
|
|
38484
|
-
}
|
|
38485
|
-
function parseIpv4(address4) {
|
|
38486
|
-
const octets = address4.split(".").map(Number);
|
|
38487
|
-
return [octets[0], octets[1], octets[2], octets[3]];
|
|
38488
|
-
}
|
|
38489
|
-
function isNonPublicIpv4([first, second, third]) {
|
|
38490
|
-
return first === 0 || first === 10 || first === 100 && second >= 64 && second <= 127 || first === 127 || first === 169 && second === 254 || first === 172 && second >= 16 && second <= 31 || first === 192 && second === 0 && (third === 0 || third === 2) || first === 192 && second === 168 || first === 198 && second >= 18 && second <= 19 || first === 198 && second === 51 && third === 100 || first === 203 && second === 0 && third === 113 || first >= 224;
|
|
38491
|
-
}
|
|
38492
|
-
function parseIpv6(address4) {
|
|
38493
|
-
let normalized = address4.toLowerCase();
|
|
38494
|
-
const lastColon = normalized.lastIndexOf(":");
|
|
38495
|
-
const dottedTail = normalized.slice(lastColon + 1);
|
|
38496
|
-
if (dottedTail.includes(".")) {
|
|
38497
|
-
const [first, second, third, fourth] = parseIpv4(dottedTail);
|
|
38498
|
-
normalized = `${normalized.slice(0, lastColon + 1)}${(first << 8 | second).toString(16)}:${(third << 8 | fourth).toString(16)}`;
|
|
38499
|
-
}
|
|
38500
|
-
const halves = normalized.split("::");
|
|
38501
|
-
const left = halves[0] ? halves[0].split(":").map(parseHex) : [];
|
|
38502
|
-
const right = halves[1] ? halves[1].split(":").map(parseHex) : [];
|
|
38503
|
-
const omittedCount = 8 - left.length - right.length;
|
|
38504
|
-
return halves.length === 2 ? [...left, ...Array.from({ length: omittedCount }, () => 0), ...right] : left;
|
|
38505
|
-
}
|
|
38506
|
-
function parseHex(value) {
|
|
38507
|
-
return Number.parseInt(value, 16);
|
|
38508
|
-
}
|
|
38509
|
-
function isNonPublicIpv6(hextets) {
|
|
38510
|
-
if (hextets.slice(0, 5).every((hextet) => hextet === 0) && hextets[5] === 65535) {
|
|
38511
|
-
const embeddedIpv4 = [
|
|
38512
|
-
hextets[6] >> 8,
|
|
38513
|
-
hextets[6] & 255,
|
|
38514
|
-
hextets[7] >> 8,
|
|
38515
|
-
hextets[7] & 255
|
|
38516
|
-
];
|
|
38517
|
-
return isNonPublicIpv4(embeddedIpv4);
|
|
38518
|
-
}
|
|
38519
|
-
if (hextets.slice(0, 6).every((hextet) => hextet === 0)) {
|
|
38520
|
-
const compatibleIpv4 = [
|
|
38521
|
-
hextets[6] >> 8,
|
|
38522
|
-
hextets[6] & 255,
|
|
38523
|
-
hextets[7] >> 8,
|
|
38524
|
-
hextets[7] & 255
|
|
38525
|
-
];
|
|
38526
|
-
if (isNonPublicIpv4(compatibleIpv4)) return true;
|
|
38527
|
-
}
|
|
38528
|
-
const isUnspecified = hextets.every((hextet) => hextet === 0);
|
|
38529
|
-
const isLoopback = hextets.slice(0, 7).every((hextet) => hextet === 0) && hextets[7] === 1;
|
|
38530
|
-
const first = hextets[0];
|
|
38531
|
-
const isUniqueLocal = first >= 64512 && first <= 65023;
|
|
38532
|
-
const isLinkLocal = first >= 65152 && first <= 65215;
|
|
38533
|
-
const isSiteLocal = first >= 65216 && first <= 65279;
|
|
38534
|
-
const isMulticast = first >= 65280;
|
|
38535
|
-
const isDocumentation = first === 8193 && hextets[1] === 3512;
|
|
38536
|
-
return isUnspecified || isLoopback || isUniqueLocal || isLinkLocal || isSiteLocal || isMulticast || isDocumentation;
|
|
38537
|
-
}
|
|
38538
|
-
function guardError(url2) {
|
|
38539
|
-
return new Error(
|
|
38540
|
-
`URL hostname ${JSON.stringify(url2.hostname)} is not allowed; private or internal destinations require allowPrivateNetwork true in the vAPI config.`
|
|
38541
|
-
);
|
|
38542
|
-
}
|
|
38543
|
-
|
|
38544
|
-
// ../core/src/networks.ts
|
|
38545
|
-
var USDC_DECIMALS = 6;
|
|
38546
|
-
var NETWORKS = {
|
|
38547
|
-
[BASE_MAINNET_CAIP2]: {
|
|
38548
|
-
family: "evm",
|
|
38549
|
-
chainId: 8453,
|
|
38550
|
-
name: "Base mainnet",
|
|
38551
|
-
usdc: CANONICAL_X402_USDC_NETWORKS[BASE_MAINNET_CAIP2].usdc,
|
|
38552
|
-
gasToken: "ETH",
|
|
38553
|
-
rpcEnv: "BASE_RPC_URL",
|
|
38554
|
-
publicRpcUrl: "https://mainnet.base.org",
|
|
38555
|
-
explorerUrl: "https://basescan.org"
|
|
38556
|
-
},
|
|
38557
|
-
[ARC_MAINNET_CAIP2]: {
|
|
38558
|
-
family: "evm",
|
|
38559
|
-
chainId: 5042,
|
|
38560
|
-
name: "Arc mainnet",
|
|
38561
|
-
usdc: CANONICAL_X402_USDC_NETWORKS[ARC_MAINNET_CAIP2].usdc,
|
|
38562
|
-
gasToken: "USDC",
|
|
38563
|
-
rpcEnv: "ARC_RPC_URL",
|
|
38564
|
-
publicRpcUrl: "https://rpc.mainnet.arc.io",
|
|
38565
|
-
explorerUrl: "https://explorer.arc.io"
|
|
38566
|
-
},
|
|
38567
|
-
[ARC_TESTNET_CAIP2]: {
|
|
38568
|
-
family: "evm",
|
|
38569
|
-
chainId: 5042002,
|
|
38570
|
-
name: "Arc testnet",
|
|
38571
|
-
usdc: CANONICAL_X402_USDC_NETWORKS[ARC_TESTNET_CAIP2].usdc,
|
|
38572
|
-
gasToken: "USDC",
|
|
38573
|
-
rpcEnv: "ARC_TESTNET_RPC_URL"
|
|
38574
|
-
},
|
|
38575
|
-
[SOLANA_MAINNET_CAIP2]: {
|
|
38576
|
-
family: "svm",
|
|
38577
|
-
name: "Solana mainnet",
|
|
38578
|
-
usdc: SOLANA_MAINNET_USDC,
|
|
38579
|
-
gasToken: "SOL",
|
|
38580
|
-
rpcEnv: "SOLANA_RPC_URL",
|
|
38581
|
-
publicRpcUrl: "https://api.mainnet-beta.solana.com"
|
|
38582
|
-
},
|
|
38583
|
-
[X402_SOLANA_MAINNET_CAIP2]: {
|
|
38584
|
-
family: "svm",
|
|
38585
|
-
name: "Solana mainnet",
|
|
38586
|
-
usdc: SOLANA_MAINNET_USDC,
|
|
38587
|
-
gasToken: "SOL",
|
|
38588
|
-
rpcEnv: "SOLANA_RPC_URL",
|
|
38589
|
-
publicRpcUrl: "https://api.mainnet-beta.solana.com"
|
|
38590
|
-
}
|
|
38043
|
+
var marketplaceBadgeCodeSchema = external_exports.enum([
|
|
38044
|
+
"live_x402",
|
|
38045
|
+
"partner",
|
|
38046
|
+
"payout_wallet_confirmed",
|
|
38047
|
+
"vapi_verified",
|
|
38048
|
+
"external_catalog",
|
|
38049
|
+
"approved_vendor"
|
|
38050
|
+
]);
|
|
38051
|
+
var marketplaceBadgeSchema = external_exports.looseObject({
|
|
38052
|
+
code: marketplaceBadgeCodeSchema,
|
|
38053
|
+
label: external_exports.string().trim().min(1).max(80)
|
|
38054
|
+
});
|
|
38055
|
+
var marketplacePublicFactSchema = external_exports.looseObject({
|
|
38056
|
+
label: external_exports.string().trim().min(1).max(80),
|
|
38057
|
+
value: external_exports.string().trim().min(1).max(160)
|
|
38058
|
+
});
|
|
38059
|
+
var marketplaceHrefSchema = external_exports.union([
|
|
38060
|
+
external_exports.string().trim().min(1).max(2048).regex(/^\/(?!\/)/),
|
|
38061
|
+
external_exports.url().max(2048).regex(/^https:\/\//)
|
|
38062
|
+
]);
|
|
38063
|
+
var marketplaceCardSchema = external_exports.looseObject({
|
|
38064
|
+
title: external_exports.string().trim().min(1).max(160),
|
|
38065
|
+
summary: external_exports.string().trim().min(1).max(1e3),
|
|
38066
|
+
byline: external_exports.string().trim().min(1).max(160).optional(),
|
|
38067
|
+
bylineHref: marketplaceHrefSchema.optional(),
|
|
38068
|
+
badges: external_exports.array(marketplaceBadgeSchema).max(8),
|
|
38069
|
+
facts: external_exports.array(marketplacePublicFactSchema).max(12)
|
|
38070
|
+
});
|
|
38071
|
+
var marketplaceHitBase = {
|
|
38072
|
+
ref: external_exports.string().trim().min(1).max(512),
|
|
38073
|
+
card: marketplaceCardSchema,
|
|
38074
|
+
...listingDisclosureShape
|
|
38591
38075
|
};
|
|
38592
|
-
|
|
38593
|
-
|
|
38594
|
-
|
|
38595
|
-
|
|
38596
|
-
|
|
38597
|
-
|
|
38598
|
-
|
|
38599
|
-
|
|
38600
|
-
|
|
38601
|
-
|
|
38602
|
-
}
|
|
38603
|
-
|
|
38604
|
-
|
|
38605
|
-
|
|
38606
|
-
|
|
38607
|
-
|
|
38608
|
-
|
|
38609
|
-
|
|
38610
|
-
|
|
38611
|
-
|
|
38612
|
-
|
|
38613
|
-
|
|
38614
|
-
|
|
38615
|
-
|
|
38616
|
-
|
|
38617
|
-
|
|
38618
|
-
|
|
38619
|
-
|
|
38620
|
-
|
|
38621
|
-
|
|
38622
|
-
|
|
38623
|
-
|
|
38624
|
-
|
|
38625
|
-
|
|
38626
|
-
|
|
38627
|
-
|
|
38628
|
-
|
|
38629
|
-
|
|
38630
|
-
|
|
38631
|
-
|
|
38632
|
-
|
|
38633
|
-
|
|
38634
|
-
|
|
38635
|
-
|
|
38636
|
-
|
|
38637
|
-
}
|
|
38638
|
-
|
|
38639
|
-
|
|
38640
|
-
|
|
38641
|
-
|
|
38642
|
-
|
|
38643
|
-
|
|
38644
|
-
|
|
38645
|
-
|
|
38646
|
-
|
|
38647
|
-
|
|
38648
|
-
|
|
38649
|
-
|
|
38650
|
-
|
|
38651
|
-
|
|
38652
|
-
|
|
38653
|
-
|
|
38654
|
-
|
|
38655
|
-
|
|
38656
|
-
|
|
38657
|
-
|
|
38658
|
-
|
|
38659
|
-
|
|
38660
|
-
|
|
38661
|
-
|
|
38662
|
-
|
|
38663
|
-
|
|
38664
|
-
|
|
38665
|
-
|
|
38666
|
-
const rpcUrl = envUrl || configured.rpcUrl.trim();
|
|
38667
|
-
if (rpcUrl) {
|
|
38668
|
-
return rpcUrl;
|
|
38669
|
-
}
|
|
38670
|
-
if (network === ARC_TESTNET_CAIP2) {
|
|
38671
|
-
throw new Error(
|
|
38672
|
-
"Arc testnet RPC is required. Set ARC_TESTNET_RPC_URL or add rpcUrl for eip155:5042002 in config.json."
|
|
38673
|
-
);
|
|
38674
|
-
}
|
|
38675
|
-
throw new Error(`RPC URL is required for ${network}.`);
|
|
38676
|
-
}
|
|
38677
|
-
function createChain(network, rpcUrl) {
|
|
38678
|
-
const definition = getNetworkDefinition(network);
|
|
38679
|
-
if (definition.family !== "evm" || definition.chainId === void 0) {
|
|
38680
|
-
throw new Error(`Network ${network} is not an EVM chain.`);
|
|
38076
|
+
var invokeApiActionSchema = external_exports.looseObject({
|
|
38077
|
+
type: external_exports.literal("invoke_api"),
|
|
38078
|
+
href: marketplaceHrefSchema
|
|
38079
|
+
});
|
|
38080
|
+
var firstPartyApiMarketplaceHitSchema = external_exports.looseObject({
|
|
38081
|
+
...marketplaceHitBase,
|
|
38082
|
+
kind: external_exports.literal("api"),
|
|
38083
|
+
provenance: firstPartyProvenanceSchema,
|
|
38084
|
+
execution: external_exports.looseObject({
|
|
38085
|
+
mode: executionModeSchema
|
|
38086
|
+
}),
|
|
38087
|
+
action: invokeApiActionSchema
|
|
38088
|
+
});
|
|
38089
|
+
var mirroredApiMarketplaceHitSchema = external_exports.looseObject({
|
|
38090
|
+
...marketplaceHitBase,
|
|
38091
|
+
kind: external_exports.literal("api"),
|
|
38092
|
+
provenance: external_exports.literal("indexed"),
|
|
38093
|
+
execution: external_exports.looseObject({
|
|
38094
|
+
mode: external_exports.literal("direct"),
|
|
38095
|
+
url: external_exports.url().max(2048).regex(/^https:\/\/(?![^/?#]*@)/),
|
|
38096
|
+
method: marketplaceExecutionMethodSchema.nullable(),
|
|
38097
|
+
network: external_exports.string().trim().max(160).transform((network) => {
|
|
38098
|
+
if (network === "solana") return X402_SOLANA_MAINNET_CAIP2;
|
|
38099
|
+
if (network === "solana-devnet") return SOLANA_DEVNET_CAIP2;
|
|
38100
|
+
return network;
|
|
38101
|
+
}).pipe(
|
|
38102
|
+
external_exports.union([
|
|
38103
|
+
external_exports.string().regex(/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$/),
|
|
38104
|
+
// Persisted mainnet configs also use the full genesis hash.
|
|
38105
|
+
external_exports.literal(SOLANA_MAINNET_CAIP2)
|
|
38106
|
+
])
|
|
38107
|
+
)
|
|
38108
|
+
}),
|
|
38109
|
+
action: invokeApiActionSchema
|
|
38110
|
+
});
|
|
38111
|
+
var apiMarketplaceHitSchema = external_exports.discriminatedUnion("provenance", [
|
|
38112
|
+
firstPartyApiMarketplaceHitSchema,
|
|
38113
|
+
mirroredApiMarketplaceHitSchema
|
|
38114
|
+
]);
|
|
38115
|
+
var serviceOfferMarketplaceHitSchema = external_exports.looseObject({
|
|
38116
|
+
...marketplaceHitBase,
|
|
38117
|
+
kind: external_exports.literal("service_offer"),
|
|
38118
|
+
action: external_exports.looseObject({
|
|
38119
|
+
type: external_exports.literal("start_engagement"),
|
|
38120
|
+
href: marketplaceHrefSchema
|
|
38121
|
+
})
|
|
38122
|
+
});
|
|
38123
|
+
var openRequestMarketplaceHitSchema = external_exports.looseObject({
|
|
38124
|
+
...marketplaceHitBase,
|
|
38125
|
+
kind: external_exports.literal("open_request"),
|
|
38126
|
+
action: external_exports.looseObject({
|
|
38127
|
+
type: external_exports.literal("propose_to_request"),
|
|
38128
|
+
href: marketplaceHrefSchema
|
|
38129
|
+
})
|
|
38130
|
+
});
|
|
38131
|
+
var marketplaceHitSchema = external_exports.union([
|
|
38132
|
+
apiMarketplaceHitSchema,
|
|
38133
|
+
serviceOfferMarketplaceHitSchema,
|
|
38134
|
+
openRequestMarketplaceHitSchema
|
|
38135
|
+
]);
|
|
38136
|
+
var marketplaceDiscoveryInputSchema = external_exports.strictObject({
|
|
38137
|
+
q: external_exports.string().trim().max(200).optional(),
|
|
38138
|
+
kinds: external_exports.array(marketplaceKindSchema).min(1).max(MARKETPLACE_KINDS.length).optional(),
|
|
38139
|
+
network: external_exports.string().trim().min(1).max(160).optional(),
|
|
38140
|
+
cursor: external_exports.string().trim().min(1).max(4096).optional(),
|
|
38141
|
+
limit: external_exports.number().int().min(1).max(50).optional(),
|
|
38142
|
+
includeUnverified: external_exports.boolean().optional()
|
|
38143
|
+
}).superRefine((input2, context) => {
|
|
38144
|
+
if (input2.kinds && new Set(input2.kinds).size !== input2.kinds.length) {
|
|
38145
|
+
context.addIssue({
|
|
38146
|
+
code: "custom",
|
|
38147
|
+
path: ["kinds"],
|
|
38148
|
+
message: "Marketplace kinds must be unique"
|
|
38149
|
+
});
|
|
38681
38150
|
}
|
|
38682
|
-
|
|
38683
|
-
|
|
38684
|
-
|
|
38685
|
-
nativeCurrency: definition.gasToken === "USDC" ? { name: "USDC", symbol: "USDC", decimals: USDC_DECIMALS } : { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
38686
|
-
rpcUrls: {
|
|
38687
|
-
default: { http: [rpcUrl] }
|
|
38688
|
-
},
|
|
38689
|
-
...definition.explorerUrl ? {
|
|
38690
|
-
blockExplorers: {
|
|
38691
|
-
default: { name: `${definition.name} explorer`, url: definition.explorerUrl }
|
|
38692
|
-
}
|
|
38693
|
-
} : {}
|
|
38694
|
-
});
|
|
38695
|
-
}
|
|
38696
|
-
function createNetworkPublicClient(network, configured, options = {}) {
|
|
38697
|
-
const rpcUrl = requireRpcUrl(network, configured);
|
|
38698
|
-
return createPublicClient({
|
|
38699
|
-
chain: createChain(network, rpcUrl),
|
|
38700
|
-
transport: createNetworkHttpTransport(rpcUrl, options)
|
|
38701
|
-
});
|
|
38702
|
-
}
|
|
38703
|
-
function createNetworkHttpTransport(rpcUrl, options = {}) {
|
|
38704
|
-
const fetchFn = options.fetch ?? createPublicFetch({
|
|
38705
|
-
allowPrivateNetwork: options.allowPrivateNetwork ?? false,
|
|
38706
|
-
...options.lookup ? { lookup: options.lookup } : {}
|
|
38707
|
-
});
|
|
38708
|
-
return http(rpcUrl, { fetchFn, fetchOptions: { redirect: "manual" } });
|
|
38709
|
-
}
|
|
38710
|
-
function formatUsdc(amountAtomic2) {
|
|
38711
|
-
return formatUnits(amountAtomic2, USDC_DECIMALS);
|
|
38151
|
+
});
|
|
38152
|
+
function isMirroredHit(hit) {
|
|
38153
|
+
return hit.kind === "api" && hit.provenance === "indexed";
|
|
38712
38154
|
}
|
|
38155
|
+
var marketplaceDiscoveryEnvelopeSchema = external_exports.looseObject({
|
|
38156
|
+
protocol: external_exports.literal(MARKETPLACE_DISCOVERY_PROTOCOL),
|
|
38157
|
+
items: external_exports.array(external_exports.unknown()),
|
|
38158
|
+
nextCursor: external_exports.string().min(1).max(4096).nullable(),
|
|
38159
|
+
unavailableKinds: external_exports.array(marketplaceKindSchema).max(MARKETPLACE_KINDS.length),
|
|
38160
|
+
rankingVersion: external_exports.literal(MARKETPLACE_RANKING_VERSION)
|
|
38161
|
+
});
|
|
38162
|
+
var marketplaceDiscoveryPageSchema = marketplaceDiscoveryEnvelopeSchema.extend({
|
|
38163
|
+
items: external_exports.array(marketplaceHitSchema)
|
|
38164
|
+
});
|
|
38713
38165
|
|
|
38714
38166
|
// ../../node_modules/.pnpm/@solana+errors@5.5.1_typescript@6.0.3/node_modules/@solana/errors/dist/index.node.mjs
|
|
38715
38167
|
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
|
|
@@ -43329,16 +42781,16 @@ var DEFAULT_COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1;
|
|
|
43329
42781
|
var DEFAULT_COMPUTE_UNIT_LIMIT = 2e4;
|
|
43330
42782
|
var MAX_MEMO_BYTES = 256;
|
|
43331
42783
|
var SOLANA_MAINNET_CAIP22 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
43332
|
-
var
|
|
42784
|
+
var SOLANA_DEVNET_CAIP22 = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
43333
42785
|
var SOLANA_TESTNET_CAIP2 = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";
|
|
43334
42786
|
var V1_TO_V2_NETWORK_MAP = {
|
|
43335
42787
|
solana: SOLANA_MAINNET_CAIP22,
|
|
43336
|
-
"solana-devnet":
|
|
42788
|
+
"solana-devnet": SOLANA_DEVNET_CAIP22,
|
|
43337
42789
|
"solana-testnet": SOLANA_TESTNET_CAIP2
|
|
43338
42790
|
};
|
|
43339
42791
|
function normalizeNetwork(network) {
|
|
43340
42792
|
if (network.includes(":")) {
|
|
43341
|
-
const supported = [SOLANA_MAINNET_CAIP22,
|
|
42793
|
+
const supported = [SOLANA_MAINNET_CAIP22, SOLANA_DEVNET_CAIP22, SOLANA_TESTNET_CAIP2];
|
|
43342
42794
|
if (!supported.includes(network)) {
|
|
43343
42795
|
throw new Error(`Unsupported SVM network: ${network}`);
|
|
43344
42796
|
}
|
|
@@ -43386,7 +42838,7 @@ var DEFAULT_ASSETS = {
|
|
|
43386
42838
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS2
|
|
43387
42839
|
}
|
|
43388
42840
|
],
|
|
43389
|
-
[
|
|
42841
|
+
[SOLANA_DEVNET_CAIP22]: [
|
|
43390
42842
|
{
|
|
43391
42843
|
asset: USDC_DEVNET_ADDRESS,
|
|
43392
42844
|
decimals: 6,
|
|
@@ -43441,7 +42893,7 @@ var findDefaultAsset = (asset, network) => {
|
|
|
43441
42893
|
function createRpcClient(network, customRpcUrl) {
|
|
43442
42894
|
const caip2Network = normalizeNetwork(network);
|
|
43443
42895
|
switch (caip2Network) {
|
|
43444
|
-
case
|
|
42896
|
+
case SOLANA_DEVNET_CAIP22: {
|
|
43445
42897
|
const url2 = customRpcUrl || DEVNET_RPC_URL;
|
|
43446
42898
|
return createSolanaRpc(devnet(url2));
|
|
43447
42899
|
}
|
|
@@ -43639,6 +43091,375 @@ var ExactSvmScheme = class {
|
|
|
43639
43091
|
var addressEncoder = getAddressEncoder();
|
|
43640
43092
|
var compiledMessageDecoder = getCompiledTransactionMessageDecoder();
|
|
43641
43093
|
|
|
43094
|
+
// ../core/src/net-guard.ts
|
|
43095
|
+
import { lookup as dnsLookup } from "node:dns/promises";
|
|
43096
|
+
import { request as httpRequest } from "node:http";
|
|
43097
|
+
import { request as httpsRequest } from "node:https";
|
|
43098
|
+
import { isIP } from "node:net";
|
|
43099
|
+
import { Readable } from "node:stream";
|
|
43100
|
+
var defaultLookup = async (hostname3) => {
|
|
43101
|
+
const addresses = await dnsLookup(hostname3, { all: true });
|
|
43102
|
+
return addresses.map(({ address: address4 }) => address4);
|
|
43103
|
+
};
|
|
43104
|
+
async function assertPublicUrl(url2, options) {
|
|
43105
|
+
if (url2.username || url2.password) {
|
|
43106
|
+
throw guardError(url2);
|
|
43107
|
+
}
|
|
43108
|
+
if (url2.protocol !== "http:" && url2.protocol !== "https:") {
|
|
43109
|
+
throw guardError(url2);
|
|
43110
|
+
}
|
|
43111
|
+
if (options.allowPrivateNetwork) {
|
|
43112
|
+
return;
|
|
43113
|
+
}
|
|
43114
|
+
const hostname3 = normalizeHostname(url2.hostname);
|
|
43115
|
+
const lowercaseHostname = hostname3.toLowerCase();
|
|
43116
|
+
if (!lowercaseHostname || lowercaseHostname === "localhost" || lowercaseHostname.endsWith(".localhost") || lowercaseHostname.endsWith(".local") || lowercaseHostname.endsWith(".internal")) {
|
|
43117
|
+
throw guardError(url2);
|
|
43118
|
+
}
|
|
43119
|
+
if (isIP(hostname3)) {
|
|
43120
|
+
if (isNonPublicAddress(hostname3)) {
|
|
43121
|
+
throw guardError(url2);
|
|
43122
|
+
}
|
|
43123
|
+
return;
|
|
43124
|
+
}
|
|
43125
|
+
let addresses;
|
|
43126
|
+
try {
|
|
43127
|
+
addresses = await withTimeout2(
|
|
43128
|
+
(options.lookup ?? defaultLookup)(hostname3),
|
|
43129
|
+
options.timeoutMs ?? 5e3
|
|
43130
|
+
);
|
|
43131
|
+
} catch {
|
|
43132
|
+
throw guardError(url2);
|
|
43133
|
+
}
|
|
43134
|
+
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
43135
|
+
throw guardError(url2);
|
|
43136
|
+
}
|
|
43137
|
+
}
|
|
43138
|
+
function createPublicFetch(options) {
|
|
43139
|
+
const lookupFn = options.lookup ?? defaultLookup;
|
|
43140
|
+
return (async (input2, init) => {
|
|
43141
|
+
const url2 = new URL(input2 instanceof Request ? input2.url : input2);
|
|
43142
|
+
await assertPublicUrl(url2, {
|
|
43143
|
+
allowPrivateNetwork: options.allowPrivateNetwork,
|
|
43144
|
+
lookup: lookupFn,
|
|
43145
|
+
timeoutMs: 5e3
|
|
43146
|
+
});
|
|
43147
|
+
const normalized = new Request(input2, init);
|
|
43148
|
+
const bytes = normalized.body ? Buffer.from(await normalized.arrayBuffer()) : null;
|
|
43149
|
+
return await new Promise((resolve, reject) => {
|
|
43150
|
+
const requestOptions = {
|
|
43151
|
+
method: normalized.method,
|
|
43152
|
+
headers: Object.fromEntries(normalized.headers),
|
|
43153
|
+
signal: normalized.signal,
|
|
43154
|
+
...options.allowPrivateNetwork ? {} : { lookup: pinnedLookup(lookupFn) }
|
|
43155
|
+
};
|
|
43156
|
+
const onResponse = (incoming) => {
|
|
43157
|
+
try {
|
|
43158
|
+
const headers = new Headers();
|
|
43159
|
+
for (const [name, value] of Object.entries(incoming.headers)) {
|
|
43160
|
+
if (Array.isArray(value)) {
|
|
43161
|
+
for (const item of value) headers.append(name, item);
|
|
43162
|
+
} else if (value !== void 0) {
|
|
43163
|
+
headers.set(name, value);
|
|
43164
|
+
}
|
|
43165
|
+
}
|
|
43166
|
+
const status = incoming.statusCode ?? 500;
|
|
43167
|
+
const bodyForbidden = normalized.method === "HEAD" || [204, 205, 304].includes(status);
|
|
43168
|
+
if (bodyForbidden) incoming.resume();
|
|
43169
|
+
const response = new Response(
|
|
43170
|
+
bodyForbidden ? null : Readable.toWeb(incoming),
|
|
43171
|
+
{ status, statusText: incoming.statusMessage, headers }
|
|
43172
|
+
);
|
|
43173
|
+
Object.defineProperty(response, "url", { value: url2.toString() });
|
|
43174
|
+
resolve(response);
|
|
43175
|
+
} catch (error61) {
|
|
43176
|
+
incoming.destroy();
|
|
43177
|
+
reject(error61);
|
|
43178
|
+
}
|
|
43179
|
+
};
|
|
43180
|
+
const request = url2.protocol === "https:" ? httpsRequest(url2, requestOptions, onResponse) : httpRequest(url2, requestOptions, onResponse);
|
|
43181
|
+
request.on("error", reject);
|
|
43182
|
+
if (bytes) request.write(bytes);
|
|
43183
|
+
request.end();
|
|
43184
|
+
});
|
|
43185
|
+
});
|
|
43186
|
+
}
|
|
43187
|
+
function pinnedLookup(lookup) {
|
|
43188
|
+
return (hostname3, dnsOptions, callback) => {
|
|
43189
|
+
void lookup(normalizeHostname(hostname3)).then((addresses) => {
|
|
43190
|
+
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
43191
|
+
callback(guardError(new URL(`https://${hostname3}`)), "");
|
|
43192
|
+
return;
|
|
43193
|
+
}
|
|
43194
|
+
const address4 = addresses[0];
|
|
43195
|
+
const family = isIP(address4);
|
|
43196
|
+
callback(
|
|
43197
|
+
null,
|
|
43198
|
+
dnsOptions.all ? [{ address: address4, family }] : address4,
|
|
43199
|
+
dnsOptions.all ? void 0 : family
|
|
43200
|
+
);
|
|
43201
|
+
}).catch(
|
|
43202
|
+
(error61) => callback(error61 instanceof Error ? error61 : new Error("DNS lookup failed."), "")
|
|
43203
|
+
);
|
|
43204
|
+
};
|
|
43205
|
+
}
|
|
43206
|
+
async function withTimeout2(operation, timeoutMs) {
|
|
43207
|
+
let timeout;
|
|
43208
|
+
try {
|
|
43209
|
+
return await Promise.race([
|
|
43210
|
+
operation,
|
|
43211
|
+
new Promise((_resolve, reject) => {
|
|
43212
|
+
timeout = setTimeout(() => reject(new Error("DNS lookup timed out.")), timeoutMs);
|
|
43213
|
+
})
|
|
43214
|
+
]);
|
|
43215
|
+
} finally {
|
|
43216
|
+
if (timeout) clearTimeout(timeout);
|
|
43217
|
+
}
|
|
43218
|
+
}
|
|
43219
|
+
function normalizeHostname(hostname3) {
|
|
43220
|
+
const unbracketed = hostname3.startsWith("[") && hostname3.endsWith("]") ? hostname3.slice(1, -1) : hostname3;
|
|
43221
|
+
return unbracketed.endsWith(".") ? unbracketed.slice(0, -1) : unbracketed;
|
|
43222
|
+
}
|
|
43223
|
+
function isNonPublicAddress(address4) {
|
|
43224
|
+
const normalized = normalizeHostname(address4);
|
|
43225
|
+
const version5 = isIP(normalized);
|
|
43226
|
+
if (version5 === 4) {
|
|
43227
|
+
return isNonPublicIpv4(parseIpv4(normalized));
|
|
43228
|
+
}
|
|
43229
|
+
if (version5 === 6) {
|
|
43230
|
+
return isNonPublicIpv6(parseIpv6(normalized));
|
|
43231
|
+
}
|
|
43232
|
+
return true;
|
|
43233
|
+
}
|
|
43234
|
+
function parseIpv4(address4) {
|
|
43235
|
+
const octets = address4.split(".").map(Number);
|
|
43236
|
+
return [octets[0], octets[1], octets[2], octets[3]];
|
|
43237
|
+
}
|
|
43238
|
+
function isNonPublicIpv4([first, second, third]) {
|
|
43239
|
+
return first === 0 || first === 10 || first === 100 && second >= 64 && second <= 127 || first === 127 || first === 169 && second === 254 || first === 172 && second >= 16 && second <= 31 || first === 192 && second === 0 && (third === 0 || third === 2) || first === 192 && second === 168 || first === 198 && second >= 18 && second <= 19 || first === 198 && second === 51 && third === 100 || first === 203 && second === 0 && third === 113 || first >= 224;
|
|
43240
|
+
}
|
|
43241
|
+
function parseIpv6(address4) {
|
|
43242
|
+
let normalized = address4.toLowerCase();
|
|
43243
|
+
const lastColon = normalized.lastIndexOf(":");
|
|
43244
|
+
const dottedTail = normalized.slice(lastColon + 1);
|
|
43245
|
+
if (dottedTail.includes(".")) {
|
|
43246
|
+
const [first, second, third, fourth] = parseIpv4(dottedTail);
|
|
43247
|
+
normalized = `${normalized.slice(0, lastColon + 1)}${(first << 8 | second).toString(16)}:${(third << 8 | fourth).toString(16)}`;
|
|
43248
|
+
}
|
|
43249
|
+
const halves = normalized.split("::");
|
|
43250
|
+
const left = halves[0] ? halves[0].split(":").map(parseHex) : [];
|
|
43251
|
+
const right = halves[1] ? halves[1].split(":").map(parseHex) : [];
|
|
43252
|
+
const omittedCount = 8 - left.length - right.length;
|
|
43253
|
+
return halves.length === 2 ? [...left, ...Array.from({ length: omittedCount }, () => 0), ...right] : left;
|
|
43254
|
+
}
|
|
43255
|
+
function parseHex(value) {
|
|
43256
|
+
return Number.parseInt(value, 16);
|
|
43257
|
+
}
|
|
43258
|
+
function isNonPublicIpv6(hextets) {
|
|
43259
|
+
if (hextets.slice(0, 5).every((hextet) => hextet === 0) && hextets[5] === 65535) {
|
|
43260
|
+
const embeddedIpv4 = [
|
|
43261
|
+
hextets[6] >> 8,
|
|
43262
|
+
hextets[6] & 255,
|
|
43263
|
+
hextets[7] >> 8,
|
|
43264
|
+
hextets[7] & 255
|
|
43265
|
+
];
|
|
43266
|
+
return isNonPublicIpv4(embeddedIpv4);
|
|
43267
|
+
}
|
|
43268
|
+
if (hextets.slice(0, 6).every((hextet) => hextet === 0)) {
|
|
43269
|
+
const compatibleIpv4 = [
|
|
43270
|
+
hextets[6] >> 8,
|
|
43271
|
+
hextets[6] & 255,
|
|
43272
|
+
hextets[7] >> 8,
|
|
43273
|
+
hextets[7] & 255
|
|
43274
|
+
];
|
|
43275
|
+
if (isNonPublicIpv4(compatibleIpv4)) return true;
|
|
43276
|
+
}
|
|
43277
|
+
const isUnspecified = hextets.every((hextet) => hextet === 0);
|
|
43278
|
+
const isLoopback = hextets.slice(0, 7).every((hextet) => hextet === 0) && hextets[7] === 1;
|
|
43279
|
+
const first = hextets[0];
|
|
43280
|
+
const isUniqueLocal = first >= 64512 && first <= 65023;
|
|
43281
|
+
const isLinkLocal = first >= 65152 && first <= 65215;
|
|
43282
|
+
const isSiteLocal = first >= 65216 && first <= 65279;
|
|
43283
|
+
const isMulticast = first >= 65280;
|
|
43284
|
+
const isDocumentation = first === 8193 && hextets[1] === 3512;
|
|
43285
|
+
return isUnspecified || isLoopback || isUniqueLocal || isLinkLocal || isSiteLocal || isMulticast || isDocumentation;
|
|
43286
|
+
}
|
|
43287
|
+
function guardError(url2) {
|
|
43288
|
+
return new Error(
|
|
43289
|
+
`URL hostname ${JSON.stringify(url2.hostname)} is not allowed; private or internal destinations require allowPrivateNetwork true in the vAPI config.`
|
|
43290
|
+
);
|
|
43291
|
+
}
|
|
43292
|
+
|
|
43293
|
+
// ../core/src/networks.ts
|
|
43294
|
+
var USDC_DECIMALS = 6;
|
|
43295
|
+
var NETWORKS2 = {
|
|
43296
|
+
[BASE_MAINNET_CAIP2]: {
|
|
43297
|
+
family: "evm",
|
|
43298
|
+
chainId: 8453,
|
|
43299
|
+
name: "Base mainnet",
|
|
43300
|
+
usdc: CANONICAL_X402_USDC_NETWORKS[BASE_MAINNET_CAIP2].usdc,
|
|
43301
|
+
gasToken: "ETH",
|
|
43302
|
+
rpcEnv: "BASE_RPC_URL",
|
|
43303
|
+
publicRpcUrl: "https://mainnet.base.org",
|
|
43304
|
+
explorerUrl: "https://basescan.org"
|
|
43305
|
+
},
|
|
43306
|
+
[ARC_MAINNET_CAIP2]: {
|
|
43307
|
+
family: "evm",
|
|
43308
|
+
chainId: 5042,
|
|
43309
|
+
name: "Arc mainnet",
|
|
43310
|
+
usdc: CANONICAL_X402_USDC_NETWORKS[ARC_MAINNET_CAIP2].usdc,
|
|
43311
|
+
gasToken: "USDC",
|
|
43312
|
+
rpcEnv: "ARC_RPC_URL",
|
|
43313
|
+
publicRpcUrl: "https://rpc.mainnet.arc.io",
|
|
43314
|
+
explorerUrl: "https://explorer.arc.io"
|
|
43315
|
+
},
|
|
43316
|
+
[ARC_TESTNET_CAIP2]: {
|
|
43317
|
+
family: "evm",
|
|
43318
|
+
chainId: 5042002,
|
|
43319
|
+
name: "Arc testnet",
|
|
43320
|
+
usdc: CANONICAL_X402_USDC_NETWORKS[ARC_TESTNET_CAIP2].usdc,
|
|
43321
|
+
gasToken: "USDC",
|
|
43322
|
+
rpcEnv: "ARC_TESTNET_RPC_URL"
|
|
43323
|
+
},
|
|
43324
|
+
[SOLANA_MAINNET_CAIP2]: {
|
|
43325
|
+
family: "svm",
|
|
43326
|
+
name: "Solana mainnet",
|
|
43327
|
+
usdc: SOLANA_MAINNET_USDC,
|
|
43328
|
+
gasToken: "SOL",
|
|
43329
|
+
rpcEnv: "SOLANA_RPC_URL",
|
|
43330
|
+
publicRpcUrl: "https://api.mainnet-beta.solana.com"
|
|
43331
|
+
},
|
|
43332
|
+
[X402_SOLANA_MAINNET_CAIP2]: {
|
|
43333
|
+
family: "svm",
|
|
43334
|
+
name: "Solana mainnet",
|
|
43335
|
+
usdc: SOLANA_MAINNET_USDC,
|
|
43336
|
+
gasToken: "SOL",
|
|
43337
|
+
rpcEnv: "SOLANA_RPC_URL",
|
|
43338
|
+
publicRpcUrl: "https://api.mainnet-beta.solana.com"
|
|
43339
|
+
}
|
|
43340
|
+
};
|
|
43341
|
+
function parseEip155ChainId(network) {
|
|
43342
|
+
const match = /^eip155:(\d+)$/.exec(network);
|
|
43343
|
+
if (!match) {
|
|
43344
|
+
throw new Error(`Unsupported network ${network}; expected eip155:<chainId>.`);
|
|
43345
|
+
}
|
|
43346
|
+
const chainId = Number(match[1]);
|
|
43347
|
+
if (!Number.isSafeInteger(chainId) || chainId <= 0) {
|
|
43348
|
+
throw new Error(`Invalid EVM chain ID in network ${network}.`);
|
|
43349
|
+
}
|
|
43350
|
+
return chainId;
|
|
43351
|
+
}
|
|
43352
|
+
function isSolanaNetwork(network) {
|
|
43353
|
+
return network === SOLANA_MAINNET_CAIP2 || network === X402_SOLANA_MAINNET_CAIP2;
|
|
43354
|
+
}
|
|
43355
|
+
function usesUsdcGas(network) {
|
|
43356
|
+
try {
|
|
43357
|
+
return getNetworkDefinition(network).gasToken === "USDC";
|
|
43358
|
+
} catch {
|
|
43359
|
+
return false;
|
|
43360
|
+
}
|
|
43361
|
+
}
|
|
43362
|
+
function explorerTransactionUrl(network, hash5) {
|
|
43363
|
+
try {
|
|
43364
|
+
const explorerUrl = getNetworkDefinition(network).explorerUrl;
|
|
43365
|
+
return explorerUrl ? `${explorerUrl}/tx/${hash5}` : void 0;
|
|
43366
|
+
} catch {
|
|
43367
|
+
return void 0;
|
|
43368
|
+
}
|
|
43369
|
+
}
|
|
43370
|
+
function explorerAddressUrl(network, address4) {
|
|
43371
|
+
try {
|
|
43372
|
+
const explorerUrl = getNetworkDefinition(network).explorerUrl;
|
|
43373
|
+
return explorerUrl ? `${explorerUrl}/address/${address4}` : void 0;
|
|
43374
|
+
} catch {
|
|
43375
|
+
return void 0;
|
|
43376
|
+
}
|
|
43377
|
+
}
|
|
43378
|
+
function areSamePaymentNetwork(left, right) {
|
|
43379
|
+
return left === right || isSolanaNetwork(left) && isSolanaNetwork(right);
|
|
43380
|
+
}
|
|
43381
|
+
function isSupportedPaymentNetwork(network) {
|
|
43382
|
+
if (isSolanaNetwork(network)) return true;
|
|
43383
|
+
try {
|
|
43384
|
+
parseEip155ChainId(network);
|
|
43385
|
+
return true;
|
|
43386
|
+
} catch {
|
|
43387
|
+
return false;
|
|
43388
|
+
}
|
|
43389
|
+
}
|
|
43390
|
+
function configuredNetworkFor(networks, network) {
|
|
43391
|
+
const configured = networks[network];
|
|
43392
|
+
if (configured) return configured;
|
|
43393
|
+
if (network === X402_SOLANA_MAINNET_CAIP2) return networks[SOLANA_MAINNET_CAIP2];
|
|
43394
|
+
if (network === SOLANA_MAINNET_CAIP2) return networks[X402_SOLANA_MAINNET_CAIP2];
|
|
43395
|
+
return void 0;
|
|
43396
|
+
}
|
|
43397
|
+
function getNetworkDefinition(network) {
|
|
43398
|
+
const known = NETWORKS2[network];
|
|
43399
|
+
if (known) {
|
|
43400
|
+
return known;
|
|
43401
|
+
}
|
|
43402
|
+
const chainId = parseEip155ChainId(network);
|
|
43403
|
+
return {
|
|
43404
|
+
family: "evm",
|
|
43405
|
+
chainId,
|
|
43406
|
+
name: network,
|
|
43407
|
+
usdc: getAddress("0x0000000000000000000000000000000000000000"),
|
|
43408
|
+
gasToken: "ETH",
|
|
43409
|
+
rpcEnv: ""
|
|
43410
|
+
};
|
|
43411
|
+
}
|
|
43412
|
+
function requireRpcUrl(network, configured) {
|
|
43413
|
+
const definition = getNetworkDefinition(network);
|
|
43414
|
+
const envUrl = definition.rpcEnv ? process.env[definition.rpcEnv]?.trim() : void 0;
|
|
43415
|
+
const rpcUrl = envUrl || configured.rpcUrl.trim();
|
|
43416
|
+
if (rpcUrl) {
|
|
43417
|
+
return rpcUrl;
|
|
43418
|
+
}
|
|
43419
|
+
if (network === ARC_TESTNET_CAIP2) {
|
|
43420
|
+
throw new Error(
|
|
43421
|
+
"Arc testnet RPC is required. Set ARC_TESTNET_RPC_URL or add rpcUrl for eip155:5042002 in config.json."
|
|
43422
|
+
);
|
|
43423
|
+
}
|
|
43424
|
+
throw new Error(`RPC URL is required for ${network}.`);
|
|
43425
|
+
}
|
|
43426
|
+
function createChain(network, rpcUrl) {
|
|
43427
|
+
const definition = getNetworkDefinition(network);
|
|
43428
|
+
if (definition.family !== "evm" || definition.chainId === void 0) {
|
|
43429
|
+
throw new Error(`Network ${network} is not an EVM chain.`);
|
|
43430
|
+
}
|
|
43431
|
+
return defineChain({
|
|
43432
|
+
id: definition.chainId,
|
|
43433
|
+
name: definition.name,
|
|
43434
|
+
nativeCurrency: definition.gasToken === "USDC" ? { name: "USDC", symbol: "USDC", decimals: USDC_DECIMALS } : { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
43435
|
+
rpcUrls: {
|
|
43436
|
+
default: { http: [rpcUrl] }
|
|
43437
|
+
},
|
|
43438
|
+
...definition.explorerUrl ? {
|
|
43439
|
+
blockExplorers: {
|
|
43440
|
+
default: { name: `${definition.name} explorer`, url: definition.explorerUrl }
|
|
43441
|
+
}
|
|
43442
|
+
} : {}
|
|
43443
|
+
});
|
|
43444
|
+
}
|
|
43445
|
+
function createNetworkPublicClient(network, configured, options = {}) {
|
|
43446
|
+
const rpcUrl = requireRpcUrl(network, configured);
|
|
43447
|
+
return createPublicClient({
|
|
43448
|
+
chain: createChain(network, rpcUrl),
|
|
43449
|
+
transport: createNetworkHttpTransport(rpcUrl, options)
|
|
43450
|
+
});
|
|
43451
|
+
}
|
|
43452
|
+
function createNetworkHttpTransport(rpcUrl, options = {}) {
|
|
43453
|
+
const fetchFn = options.fetch ?? createPublicFetch({
|
|
43454
|
+
allowPrivateNetwork: options.allowPrivateNetwork ?? false,
|
|
43455
|
+
...options.lookup ? { lookup: options.lookup } : {}
|
|
43456
|
+
});
|
|
43457
|
+
return http(rpcUrl, { fetchFn, fetchOptions: { redirect: "manual" } });
|
|
43458
|
+
}
|
|
43459
|
+
function formatUsdc(amountAtomic2) {
|
|
43460
|
+
return formatUnits(amountAtomic2, USDC_DECIMALS);
|
|
43461
|
+
}
|
|
43462
|
+
|
|
43642
43463
|
// ../core/src/x402.ts
|
|
43643
43464
|
var MAX_CHALLENGE_BYTES = 1048576;
|
|
43644
43465
|
var MAX_UINT256 = (1n << 256n) - 1n;
|
|
@@ -44396,6 +44217,224 @@ function isRecord2(value) {
|
|
|
44396
44217
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44397
44218
|
}
|
|
44398
44219
|
|
|
44220
|
+
// ../core/src/call-contracts-wire.ts
|
|
44221
|
+
var CALLABLE_CATEGORIES = ["ai", "data", "crypto", "compute", "search"];
|
|
44222
|
+
var callableCategorySchema = external_exports.enum(CALLABLE_CATEGORIES);
|
|
44223
|
+
var DISCOVERY_CATEGORIES = [...CALLABLE_CATEGORIES, "other"];
|
|
44224
|
+
var discoveryCategorySchema = external_exports.enum(DISCOVERY_CATEGORIES);
|
|
44225
|
+
var CALLABLE_CATEGORY_SET = new Set(CALLABLE_CATEGORIES);
|
|
44226
|
+
var serviceTierSchema = external_exports.enum(["listed", "verified", "partner"]);
|
|
44227
|
+
var discoveryEndpointSchema = external_exports.looseObject({
|
|
44228
|
+
name: external_exports.string(),
|
|
44229
|
+
method: external_exports.string(),
|
|
44230
|
+
url: external_exports.url(),
|
|
44231
|
+
price: external_exports.string(),
|
|
44232
|
+
description: external_exports.string(),
|
|
44233
|
+
operationId: external_exports.string().trim().min(1).optional(),
|
|
44234
|
+
requestContentType: external_exports.string().trim().min(1).optional(),
|
|
44235
|
+
requestSchema: external_exports.json().optional(),
|
|
44236
|
+
responseContentType: external_exports.string().trim().min(1).optional(),
|
|
44237
|
+
pathTemplate: external_exports.string().trim().min(1).optional(),
|
|
44238
|
+
pathParameters: external_exports.array(external_exports.string().trim().min(1)).optional(),
|
|
44239
|
+
payment: external_exports.union([
|
|
44240
|
+
external_exports.looseObject({
|
|
44241
|
+
scheme: external_exports.literal("exact"),
|
|
44242
|
+
network: external_exports.string().regex(/^eip155:\d+$/),
|
|
44243
|
+
asset: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
44244
|
+
payTo: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
44245
|
+
checkedAt: external_exports.iso.datetime()
|
|
44246
|
+
}),
|
|
44247
|
+
external_exports.looseObject({
|
|
44248
|
+
scheme: external_exports.literal("exact"),
|
|
44249
|
+
network: external_exports.union([
|
|
44250
|
+
external_exports.string().regex(/^solana:[-_a-zA-Z0-9]{1,32}$/),
|
|
44251
|
+
external_exports.literal(SOLANA_MAINNET_CAIP2)
|
|
44252
|
+
]),
|
|
44253
|
+
asset: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
|
|
44254
|
+
payTo: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
|
|
44255
|
+
checkedAt: external_exports.iso.datetime()
|
|
44256
|
+
})
|
|
44257
|
+
]).optional()
|
|
44258
|
+
});
|
|
44259
|
+
var serviceSummarySchema = external_exports.looseObject({
|
|
44260
|
+
id: external_exports.string(),
|
|
44261
|
+
name: external_exports.string(),
|
|
44262
|
+
description: external_exports.string(),
|
|
44263
|
+
category: discoveryCategorySchema,
|
|
44264
|
+
tier: serviceTierSchema,
|
|
44265
|
+
...listingDisclosureShape,
|
|
44266
|
+
verified: external_exports.boolean(),
|
|
44267
|
+
wrapped: external_exports.boolean(),
|
|
44268
|
+
price: external_exports.string(),
|
|
44269
|
+
networks: external_exports.array(external_exports.string()),
|
|
44270
|
+
endpoints: external_exports.array(discoveryEndpointSchema)
|
|
44271
|
+
});
|
|
44272
|
+
var searchServicesResponseSchema = external_exports.looseObject({
|
|
44273
|
+
services: external_exports.array(serviceSummarySchema)
|
|
44274
|
+
});
|
|
44275
|
+
var discoveryResponseSchema = searchServicesResponseSchema;
|
|
44276
|
+
|
|
44277
|
+
// ../core/src/call-contracts.ts
|
|
44278
|
+
var DiscoveryCatalogError = class extends Error {
|
|
44279
|
+
constructor(code, message, serviceId, paymentNetworks) {
|
|
44280
|
+
super(message);
|
|
44281
|
+
this.paymentNetworks = paymentNetworks;
|
|
44282
|
+
this.code = code;
|
|
44283
|
+
this.serviceId = serviceId;
|
|
44284
|
+
}
|
|
44285
|
+
paymentNetworks;
|
|
44286
|
+
name = "DiscoveryCatalogError";
|
|
44287
|
+
code;
|
|
44288
|
+
serviceId;
|
|
44289
|
+
};
|
|
44290
|
+
function isDiscoveryCatalogError(error61) {
|
|
44291
|
+
if (!(error61 instanceof Error) || error61.name !== "DiscoveryCatalogError" || !("code" in error61) || typeof error61.code !== "string") {
|
|
44292
|
+
return false;
|
|
44293
|
+
}
|
|
44294
|
+
const networks = Reflect.get(error61, "paymentNetworks");
|
|
44295
|
+
return networks === void 0 || Array.isArray(networks) && networks.every((network) => typeof network === "string");
|
|
44296
|
+
}
|
|
44297
|
+
function parseDiscovery(raw) {
|
|
44298
|
+
const parsed = discoveryResponseSchema.safeParse(raw);
|
|
44299
|
+
if (!parsed.success) {
|
|
44300
|
+
const malformedUrl = parsed.error.issues.find(
|
|
44301
|
+
(issue2) => issue2.path.at(-1) === "url" && issue2.path.includes("endpoints")
|
|
44302
|
+
);
|
|
44303
|
+
if (malformedUrl) {
|
|
44304
|
+
const serviceIndex = pathIndexAfter(malformedUrl.path, "services");
|
|
44305
|
+
const serviceId = rawServiceId(raw, serviceIndex);
|
|
44306
|
+
throw new DiscoveryCatalogError(
|
|
44307
|
+
"malformed_url",
|
|
44308
|
+
`Service ${JSON.stringify(serviceId ?? "unknown")} has a malformed endpoint URL.`,
|
|
44309
|
+
serviceId
|
|
44310
|
+
);
|
|
44311
|
+
}
|
|
44312
|
+
throw new DiscoveryCatalogError("invalid_discovery", "Discovery response is malformed.");
|
|
44313
|
+
}
|
|
44314
|
+
for (const service of parsed.data.services) {
|
|
44315
|
+
buildTargets(service);
|
|
44316
|
+
}
|
|
44317
|
+
const resolveListing = (serviceId, endpointName) => {
|
|
44318
|
+
const service = parsed.data.services.find((candidate) => candidate.id === serviceId);
|
|
44319
|
+
if (!service) {
|
|
44320
|
+
throw new DiscoveryCatalogError(
|
|
44321
|
+
"service_not_found",
|
|
44322
|
+
`No payable endpoint found for service ${JSON.stringify(serviceId)}.`,
|
|
44323
|
+
serviceId
|
|
44324
|
+
);
|
|
44325
|
+
}
|
|
44326
|
+
return { service, endpoint: resolveTarget(service, endpointName) };
|
|
44327
|
+
};
|
|
44328
|
+
return {
|
|
44329
|
+
services: parsed.data.services,
|
|
44330
|
+
resolve: (serviceId, endpointName) => resolveListing(serviceId, endpointName).endpoint,
|
|
44331
|
+
resolveListing
|
|
44332
|
+
};
|
|
44333
|
+
}
|
|
44334
|
+
function resolveTarget(service, endpointName) {
|
|
44335
|
+
const { targets, targetsByName } = buildTargets(service);
|
|
44336
|
+
if (endpointName !== void 0) {
|
|
44337
|
+
const selected = targetsByName.get(endpointName.trim());
|
|
44338
|
+
if (!selected) {
|
|
44339
|
+
throw new DiscoveryCatalogError(
|
|
44340
|
+
"endpoint_not_found",
|
|
44341
|
+
`Service ${JSON.stringify(service.id)} has no endpoint ${JSON.stringify(endpointName)}. Available endpoints: ${[...targetsByName.keys()].join(", ")}.`,
|
|
44342
|
+
service.id
|
|
44343
|
+
);
|
|
44344
|
+
}
|
|
44345
|
+
return { ...selected };
|
|
44346
|
+
}
|
|
44347
|
+
if (targets.size !== 1) {
|
|
44348
|
+
const paymentNetworks = service.endpoints.flatMap(
|
|
44349
|
+
(endpoint) => endpoint.payment ? [endpoint.payment.network] : []
|
|
44350
|
+
);
|
|
44351
|
+
throw new DiscoveryCatalogError(
|
|
44352
|
+
"ambiguous_default",
|
|
44353
|
+
`Service ${JSON.stringify(service.id)} has ${targets.size} distinct payable endpoints. Choose one with endpoint: ${[...targetsByName.keys()].join(", ")}.`,
|
|
44354
|
+
service.id,
|
|
44355
|
+
paymentNetworks.length === service.endpoints.length ? paymentNetworks : void 0
|
|
44356
|
+
);
|
|
44357
|
+
}
|
|
44358
|
+
return targets.values().next().value;
|
|
44359
|
+
}
|
|
44360
|
+
function buildTargets(service) {
|
|
44361
|
+
if (service.endpoints.length === 0) {
|
|
44362
|
+
throw new DiscoveryCatalogError(
|
|
44363
|
+
"no_endpoint",
|
|
44364
|
+
`Service ${JSON.stringify(service.id)} has no payable endpoint.`,
|
|
44365
|
+
service.id
|
|
44366
|
+
);
|
|
44367
|
+
}
|
|
44368
|
+
const namedEndpoints = [...service.endpoints].sort(
|
|
44369
|
+
(left, right) => compareNames(left.name.trim(), right.name.trim())
|
|
44370
|
+
);
|
|
44371
|
+
const names = /* @__PURE__ */ new Set();
|
|
44372
|
+
const targets = /* @__PURE__ */ new Map();
|
|
44373
|
+
const targetsByName = /* @__PURE__ */ new Map();
|
|
44374
|
+
for (const endpoint of namedEndpoints) {
|
|
44375
|
+
const name = endpoint.name.trim();
|
|
44376
|
+
if (!name) {
|
|
44377
|
+
throw new DiscoveryCatalogError(
|
|
44378
|
+
"invalid_endpoint_name",
|
|
44379
|
+
`Service ${JSON.stringify(service.id)} has a blank endpoint name.`,
|
|
44380
|
+
service.id
|
|
44381
|
+
);
|
|
44382
|
+
}
|
|
44383
|
+
if (names.has(name)) {
|
|
44384
|
+
throw new DiscoveryCatalogError(
|
|
44385
|
+
"duplicate_endpoint_name",
|
|
44386
|
+
`Service ${JSON.stringify(service.id)} has duplicate endpoint name ${JSON.stringify(name)}.`,
|
|
44387
|
+
service.id
|
|
44388
|
+
);
|
|
44389
|
+
}
|
|
44390
|
+
names.add(name);
|
|
44391
|
+
const method = endpoint.method.trim().toUpperCase();
|
|
44392
|
+
if (!method) {
|
|
44393
|
+
throw new DiscoveryCatalogError(
|
|
44394
|
+
"blank_method",
|
|
44395
|
+
`Service ${JSON.stringify(service.id)} has a blank endpoint method.`,
|
|
44396
|
+
service.id
|
|
44397
|
+
);
|
|
44398
|
+
}
|
|
44399
|
+
const url2 = new URL(endpoint.url);
|
|
44400
|
+
if (url2.protocol !== "http:" && url2.protocol !== "https:") {
|
|
44401
|
+
throw new DiscoveryCatalogError(
|
|
44402
|
+
"malformed_url",
|
|
44403
|
+
`Service ${JSON.stringify(service.id)} has a non-HTTP endpoint URL.`,
|
|
44404
|
+
service.id
|
|
44405
|
+
);
|
|
44406
|
+
}
|
|
44407
|
+
const transportKey = `${method}\0${endpoint.url}`;
|
|
44408
|
+
const normalized = { ...endpoint, name, method };
|
|
44409
|
+
targetsByName.set(name, normalized);
|
|
44410
|
+
if (!targets.has(transportKey)) targets.set(transportKey, normalized);
|
|
44411
|
+
}
|
|
44412
|
+
return { targets, targetsByName };
|
|
44413
|
+
}
|
|
44414
|
+
function compareNames(left, right) {
|
|
44415
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
44416
|
+
}
|
|
44417
|
+
function pathIndexAfter(path, key2) {
|
|
44418
|
+
const keyIndex = path.indexOf(key2);
|
|
44419
|
+
const candidate = path[keyIndex + 1];
|
|
44420
|
+
return typeof candidate === "number" ? candidate : void 0;
|
|
44421
|
+
}
|
|
44422
|
+
function rawServiceId(raw, serviceIndex) {
|
|
44423
|
+
if (serviceIndex === void 0 || typeof raw !== "object" || raw === null) {
|
|
44424
|
+
return void 0;
|
|
44425
|
+
}
|
|
44426
|
+
const services = Reflect.get(raw, "services");
|
|
44427
|
+
if (!Array.isArray(services)) {
|
|
44428
|
+
return void 0;
|
|
44429
|
+
}
|
|
44430
|
+
const service = services[serviceIndex];
|
|
44431
|
+
if (typeof service !== "object" || service === null) {
|
|
44432
|
+
return void 0;
|
|
44433
|
+
}
|
|
44434
|
+
const id2 = Reflect.get(service, "id");
|
|
44435
|
+
return typeof id2 === "string" ? id2 : void 0;
|
|
44436
|
+
}
|
|
44437
|
+
|
|
44399
44438
|
// ../core/src/sweep.ts
|
|
44400
44439
|
var ERC20_ABI = [
|
|
44401
44440
|
{
|
|
@@ -45110,7 +45149,7 @@ var configSchema = external_exports.object({
|
|
|
45110
45149
|
}
|
|
45111
45150
|
for (const [network, configured] of Object.entries(config2.networks)) {
|
|
45112
45151
|
if (isSolanaNetwork(network)) {
|
|
45113
|
-
if (configured.usdc !==
|
|
45152
|
+
if (configured.usdc !== NETWORKS2[SOLANA_MAINNET_CAIP2].usdc) {
|
|
45114
45153
|
context.addIssue({
|
|
45115
45154
|
code: "custom",
|
|
45116
45155
|
path: ["networks", network, "usdc"],
|
|
@@ -45121,7 +45160,7 @@ var configSchema = external_exports.object({
|
|
|
45121
45160
|
}
|
|
45122
45161
|
try {
|
|
45123
45162
|
const usdc = getAddress(configured.usdc);
|
|
45124
|
-
if ((network === ARC_MAINNET_CAIP2 || network === ARC_TESTNET_CAIP2) && usdc !== getAddress(
|
|
45163
|
+
if ((network === ARC_MAINNET_CAIP2 || network === ARC_TESTNET_CAIP2) && usdc !== getAddress(NETWORKS2[network].usdc)) {
|
|
45125
45164
|
context.addIssue({
|
|
45126
45165
|
code: "custom",
|
|
45127
45166
|
path: ["networks", network, "usdc"],
|
|
@@ -45260,15 +45299,15 @@ function getDefaultConfig(source = process.env, options = {}) {
|
|
|
45260
45299
|
const tasksEscrowFactoryOverrides = tasksFactoryOverridesFromEnv(source);
|
|
45261
45300
|
if (requested.has("base") || requested.has(BASE_MAINNET_CAIP2)) {
|
|
45262
45301
|
networks[BASE_MAINNET_CAIP2] = {
|
|
45263
|
-
rpcUrl: source.BASE_RPC_URL?.trim() ||
|
|
45264
|
-
usdc:
|
|
45302
|
+
rpcUrl: source.BASE_RPC_URL?.trim() || NETWORKS2[BASE_MAINNET_CAIP2].publicRpcUrl,
|
|
45303
|
+
usdc: NETWORKS2[BASE_MAINNET_CAIP2].usdc
|
|
45265
45304
|
};
|
|
45266
45305
|
}
|
|
45267
45306
|
const arcMainnetRpcUrl = source.ARC_RPC_URL?.trim();
|
|
45268
45307
|
if (arcMainnetRpcUrl || requested.has("arc") || requested.has(ARC_MAINNET_CAIP2)) {
|
|
45269
45308
|
networks[ARC_MAINNET_CAIP2] = {
|
|
45270
|
-
rpcUrl: arcMainnetRpcUrl ||
|
|
45271
|
-
usdc:
|
|
45309
|
+
rpcUrl: arcMainnetRpcUrl || NETWORKS2[ARC_MAINNET_CAIP2].publicRpcUrl,
|
|
45310
|
+
usdc: NETWORKS2[ARC_MAINNET_CAIP2].usdc
|
|
45272
45311
|
};
|
|
45273
45312
|
}
|
|
45274
45313
|
const arcTestnetRpcUrl = source.ARC_TESTNET_RPC_URL?.trim();
|
|
@@ -45280,14 +45319,14 @@ function getDefaultConfig(source = process.env, options = {}) {
|
|
|
45280
45319
|
}
|
|
45281
45320
|
networks[ARC_TESTNET_CAIP2] = {
|
|
45282
45321
|
rpcUrl: arcTestnetRpcUrl,
|
|
45283
|
-
usdc:
|
|
45322
|
+
usdc: NETWORKS2[ARC_TESTNET_CAIP2].usdc
|
|
45284
45323
|
};
|
|
45285
45324
|
}
|
|
45286
45325
|
const solanaRpcUrl = source.SOLANA_RPC_URL?.trim();
|
|
45287
45326
|
if (solanaRpcUrl || requested.has("solana") || requested.has(SOLANA_MAINNET_CAIP2)) {
|
|
45288
45327
|
networks[SOLANA_MAINNET_CAIP2] = {
|
|
45289
|
-
rpcUrl: solanaRpcUrl ||
|
|
45290
|
-
usdc:
|
|
45328
|
+
rpcUrl: solanaRpcUrl || NETWORKS2[SOLANA_MAINNET_CAIP2].publicRpcUrl,
|
|
45329
|
+
usdc: NETWORKS2[SOLANA_MAINNET_CAIP2].usdc
|
|
45291
45330
|
};
|
|
45292
45331
|
}
|
|
45293
45332
|
return {
|
|
@@ -45345,21 +45384,21 @@ Run vapi init to write the new URLs to ${path}.`
|
|
|
45345
45384
|
if (arcMainnetRpcUrl) {
|
|
45346
45385
|
const existing = config2.networks[ARC_MAINNET_CAIP2];
|
|
45347
45386
|
config2.networks[ARC_MAINNET_CAIP2] = {
|
|
45348
|
-
...existing ?? { usdc:
|
|
45387
|
+
...existing ?? { usdc: NETWORKS2[ARC_MAINNET_CAIP2].usdc },
|
|
45349
45388
|
rpcUrl: arcMainnetRpcUrl
|
|
45350
45389
|
};
|
|
45351
45390
|
}
|
|
45352
45391
|
if (arcTestnetRpcUrl) {
|
|
45353
45392
|
const existing = config2.networks[ARC_TESTNET_CAIP2];
|
|
45354
45393
|
config2.networks[ARC_TESTNET_CAIP2] = {
|
|
45355
|
-
...existing ?? { usdc:
|
|
45394
|
+
...existing ?? { usdc: NETWORKS2[ARC_TESTNET_CAIP2].usdc },
|
|
45356
45395
|
rpcUrl: arcTestnetRpcUrl
|
|
45357
45396
|
};
|
|
45358
45397
|
}
|
|
45359
45398
|
if (solanaRpcUrl) {
|
|
45360
45399
|
config2.networks[SOLANA_MAINNET_CAIP2] = {
|
|
45361
45400
|
rpcUrl: solanaRpcUrl,
|
|
45362
|
-
usdc: config2.networks[SOLANA_MAINNET_CAIP2]?.usdc ??
|
|
45401
|
+
usdc: config2.networks[SOLANA_MAINNET_CAIP2]?.usdc ?? NETWORKS2[SOLANA_MAINNET_CAIP2].usdc
|
|
45363
45402
|
};
|
|
45364
45403
|
}
|
|
45365
45404
|
if (registryUrl) {
|
|
@@ -45372,7 +45411,7 @@ Run vapi init to write the new URLs to ${path}.`
|
|
|
45372
45411
|
for (const [network, configured] of Object.entries(config2.networks)) {
|
|
45373
45412
|
configured.rpcUrl = configured.rpcUrl.trim();
|
|
45374
45413
|
configured.usdc = configured.usdc.trim();
|
|
45375
|
-
if (isSolanaNetwork(network) && configured.usdc !==
|
|
45414
|
+
if (isSolanaNetwork(network) && configured.usdc !== NETWORKS2[SOLANA_MAINNET_CAIP2].usdc) {
|
|
45376
45415
|
throw new Error(`Network ${network} must use canonical Solana mainnet USDC.`);
|
|
45377
45416
|
}
|
|
45378
45417
|
if (!configured.rpcUrl) delete config2.networks[network];
|
|
@@ -72999,7 +73038,7 @@ function createRunBudget(args) {
|
|
|
72999
73038
|
import { mkdir as mkdir13, writeFile as writeFile7 } from "node:fs/promises";
|
|
73000
73039
|
import { arch, platform, release } from "node:os";
|
|
73001
73040
|
import { join as join11 } from "node:path";
|
|
73002
|
-
var VAPI_CLIENT_VERSION = "0.9.
|
|
73041
|
+
var VAPI_CLIENT_VERSION = "0.9.2";
|
|
73003
73042
|
async function createSupportReport(options) {
|
|
73004
73043
|
const message = options.message.trim();
|
|
73005
73044
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -74448,6 +74487,7 @@ var missingTasksChain = {
|
|
|
74448
74487
|
|
|
74449
74488
|
// ../core/src/tasks/types.ts
|
|
74450
74489
|
var uuidSchema = external_exports.uuid();
|
|
74490
|
+
var profileIdSchema = external_exports.string().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/);
|
|
74451
74491
|
var isoDateTimeSchema = external_exports.iso.datetime();
|
|
74452
74492
|
var addressSchema5 = external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/).transform((value) => value.toLowerCase());
|
|
74453
74493
|
var bytes32Schema = external_exports.string().regex(/^0x[0-9a-fA-F]{64}$/).transform((value) => value.toLowerCase());
|
|
@@ -74785,7 +74825,7 @@ var deliveryResponseSchema = external_exports.looseObject({
|
|
|
74785
74825
|
version: external_exports.number().int().positive(),
|
|
74786
74826
|
manifest: manifestResponseSchema,
|
|
74787
74827
|
manifestHash: bytes32Schema,
|
|
74788
|
-
submittedByProfileId:
|
|
74828
|
+
submittedByProfileId: profileIdSchema,
|
|
74789
74829
|
createdAt: isoDateTimeSchema
|
|
74790
74830
|
});
|
|
74791
74831
|
var orderDeliveryResponseSchema = external_exports.looseObject({
|
|
@@ -74891,7 +74931,7 @@ var reviewResponseSchema = external_exports.looseObject({
|
|
|
74891
74931
|
id: uuidSchema,
|
|
74892
74932
|
workOrderId: uuidSchema,
|
|
74893
74933
|
clientAddress: addressSchema5,
|
|
74894
|
-
vendorProfileId:
|
|
74934
|
+
vendorProfileId: profileIdSchema,
|
|
74895
74935
|
rating: external_exports.number().int().min(1).max(5),
|
|
74896
74936
|
body: external_exports.string(),
|
|
74897
74937
|
subRatings: external_exports.json().nullable(),
|
|
@@ -75434,12 +75474,15 @@ function createTasksClient(options) {
|
|
|
75434
75474
|
const parsed2 = serverErrorSchema.safeParse(errorBody);
|
|
75435
75475
|
const server = parsed2.success ? parsed2.data : void 0;
|
|
75436
75476
|
const nested = typeof server?.error === "object" ? server.error : void 0;
|
|
75437
|
-
const
|
|
75477
|
+
const serverCode = nested?.code ?? server?.code;
|
|
75478
|
+
const serverMessage = (typeof server?.error === "string" ? server.error : nested?.message) || server?.message;
|
|
75479
|
+
const fallback = response.statusText || `HTTP ${response.status}`;
|
|
75480
|
+
const message = response.status === 401 || response.status === 403 ? serverCode ?? fallback : serverMessage || (errorBody === void 0 && raw.trim() ? raw.replace(/\s+/gu, " ").trim().slice(0, 300) : fallback);
|
|
75438
75481
|
throw new TasksClientError(
|
|
75439
75482
|
"http",
|
|
75440
75483
|
message,
|
|
75441
75484
|
response.status,
|
|
75442
|
-
|
|
75485
|
+
serverCode,
|
|
75443
75486
|
response.headers.get("Retry-After") ?? void 0
|
|
75444
75487
|
);
|
|
75445
75488
|
}
|
|
@@ -75842,9 +75885,10 @@ function safeTasksChainError(cause, broadcast, authorizationExposed, txHash) {
|
|
|
75842
75885
|
let message = "Task chain operation failed.";
|
|
75843
75886
|
if (cause instanceof TasksValidationError || cause instanceof TasksChainError)
|
|
75844
75887
|
message = cause.message;
|
|
75845
|
-
else if (cause instanceof TasksClientError)
|
|
75846
|
-
|
|
75847
|
-
|
|
75888
|
+
else if (cause instanceof TasksClientError) {
|
|
75889
|
+
const code = cause.serverCode ?? (cause.status ? `http_${cause.status}` : cause.code);
|
|
75890
|
+
message = cause.status === 401 || cause.status === 403 ? `${code} (status ${cause.status})` : `${code}: ${cause.message}`;
|
|
75891
|
+
} else if (cause instanceof Error) {
|
|
75848
75892
|
const short = "shortMessage" in cause && typeof cause.shortMessage === "string" ? cause.shortMessage : void 0;
|
|
75849
75893
|
let statusCode;
|
|
75850
75894
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -76630,6 +76674,44 @@ function createTasksChain(options) {
|
|
|
76630
76674
|
return idempotencyKey;
|
|
76631
76675
|
});
|
|
76632
76676
|
}
|
|
76677
|
+
async function prepareOrResume(prepare, expected, idempotencyKey, kind, steps, authorizationExposed = false, beforeSign) {
|
|
76678
|
+
let prepared;
|
|
76679
|
+
let resumedFromServer = false;
|
|
76680
|
+
try {
|
|
76681
|
+
prepared = await prepare();
|
|
76682
|
+
} catch (error61) {
|
|
76683
|
+
if (!uncertainPreparation(error61)) throw error61;
|
|
76684
|
+
const fresh = await order(expected.milestone.workOrderId);
|
|
76685
|
+
const matches = fresh.milestones.filter((item) => item.id === expected.milestone.id);
|
|
76686
|
+
if (matches.length !== 1 || matches[0].workOrderId !== fresh.id)
|
|
76687
|
+
throw new TasksValidationError("The task milestone does not match its parent order.");
|
|
76688
|
+
const selected = matches[0];
|
|
76689
|
+
const operation = selected.chainOperation;
|
|
76690
|
+
if (expected.verb === "deliver" && selected.delivery && !operation)
|
|
76691
|
+
throw new TasksValidationError(
|
|
76692
|
+
"The server recorded this delivery but has no chain operation for it; open the task in the console to continue."
|
|
76693
|
+
);
|
|
76694
|
+
if (!operation || operation.kind !== kind || !(typeof steps === "string" ? [steps] : steps).includes(operation.step) || !["prepared", "submitted", "confirmed"].includes(operation.state))
|
|
76695
|
+
throw error61;
|
|
76696
|
+
if (expected.verb === "deliver" && selected.delivery && selected.delivery.manifestHash !== expected.manifestHash)
|
|
76697
|
+
throw new TasksValidationError(
|
|
76698
|
+
"The server recorded a different delivery manifest; refusing to continue."
|
|
76699
|
+
);
|
|
76700
|
+
prepared = {
|
|
76701
|
+
operation,
|
|
76702
|
+
milestone: { id: selected.id, workOrderId: selected.workOrderId }
|
|
76703
|
+
};
|
|
76704
|
+
resumedFromServer = true;
|
|
76705
|
+
}
|
|
76706
|
+
const result = await execute(
|
|
76707
|
+
prepared,
|
|
76708
|
+
expected,
|
|
76709
|
+
idempotencyKey,
|
|
76710
|
+
authorizationExposed,
|
|
76711
|
+
beforeSign
|
|
76712
|
+
);
|
|
76713
|
+
return resumedFromServer ? { ...result, resumedFromServer: true } : result;
|
|
76714
|
+
}
|
|
76633
76715
|
async function verifyReceipt(operation, expected, hash5) {
|
|
76634
76716
|
const rpc = rpcFor(expected.deployment.chainId);
|
|
76635
76717
|
const receipt = await rpc.waitForTransactionReceipt({ hash: hash5, confirmations });
|
|
@@ -76671,6 +76753,7 @@ function createTasksChain(options) {
|
|
|
76671
76753
|
throw new TasksValidationError(
|
|
76672
76754
|
"The RPC transaction input does not match the verified task plan."
|
|
76673
76755
|
);
|
|
76756
|
+
return receipt.blockNumber.toString();
|
|
76674
76757
|
}
|
|
76675
76758
|
async function retryConflict(call2) {
|
|
76676
76759
|
let waited = 0;
|
|
@@ -76698,6 +76781,7 @@ function createTasksChain(options) {
|
|
|
76698
76781
|
current = { ...initial, operation: live };
|
|
76699
76782
|
let broadcast = current.operation.state === "submitted";
|
|
76700
76783
|
let txHash = current.operation.transactionHash ?? void 0;
|
|
76784
|
+
let blockNumber;
|
|
76701
76785
|
const operationId = initial.operation.id;
|
|
76702
76786
|
function checkTransition(previous, next) {
|
|
76703
76787
|
if (previous !== next && !(previous === "approve-usdc" && next === afterApproval))
|
|
@@ -76733,7 +76817,7 @@ function createTasksChain(options) {
|
|
|
76733
76817
|
if (!operation.transactionHash)
|
|
76734
76818
|
throw new TasksValidationError("The confirmed task operation has no transaction hash.");
|
|
76735
76819
|
if (!checkpoint) {
|
|
76736
|
-
await verifyReceipt(operation, expected, operation.transactionHash);
|
|
76820
|
+
blockNumber = await verifyReceipt(operation, expected, operation.transactionHash);
|
|
76737
76821
|
await pending.complete(operation.id, operation.step, current);
|
|
76738
76822
|
}
|
|
76739
76823
|
const fresh = await order(expected.milestone.workOrderId);
|
|
@@ -76742,7 +76826,12 @@ function createTasksChain(options) {
|
|
|
76742
76826
|
);
|
|
76743
76827
|
if (!resultMilestone)
|
|
76744
76828
|
throw new TasksValidationError("The reconciled task milestone is unavailable.");
|
|
76745
|
-
return {
|
|
76829
|
+
return {
|
|
76830
|
+
txHash: operation.transactionHash,
|
|
76831
|
+
operation,
|
|
76832
|
+
milestone: resultMilestone,
|
|
76833
|
+
blockNumber
|
|
76834
|
+
};
|
|
76746
76835
|
}
|
|
76747
76836
|
const rpc = rpcFor(expected.deployment.chainId);
|
|
76748
76837
|
if (operation.state === "prepared") {
|
|
@@ -76938,7 +77027,7 @@ function createTasksChain(options) {
|
|
|
76938
77027
|
}
|
|
76939
77028
|
if (operation.state !== "submitted" || !operation.transactionHash)
|
|
76940
77029
|
throw new TasksValidationError("The task operation has no submitted transaction.");
|
|
76941
|
-
await verifyReceipt(operation, expected, operation.transactionHash);
|
|
77030
|
+
blockNumber = await verifyReceipt(operation, expected, operation.transactionHash);
|
|
76942
77031
|
const reconciled = await retryConflict(
|
|
76943
77032
|
() => client.reconcileOperation(
|
|
76944
77033
|
operation.id,
|
|
@@ -76961,6 +77050,7 @@ function createTasksChain(options) {
|
|
|
76961
77050
|
if (reconciled.operation.state !== "confirmed" && !(operation.step === "approve-usdc" && reconciled.operation.state === "prepared" && reconciled.operation.step === afterApproval))
|
|
76962
77051
|
throw new TasksValidationError("The task transaction was not reconciled.");
|
|
76963
77052
|
await pending.complete(operation.id, operation.step, reconciled);
|
|
77053
|
+
if (reconciled.operation.step !== operation.step) blockNumber = void 0;
|
|
76964
77054
|
current = reconciled;
|
|
76965
77055
|
}
|
|
76966
77056
|
throw new TasksValidationError("The task operation exceeded its allowed step transitions.");
|
|
@@ -76995,14 +77085,16 @@ function createTasksChain(options) {
|
|
|
76995
77085
|
);
|
|
76996
77086
|
const prepareKey = await preparation(input2, verb, { evidenceHash: input2.evidenceHash });
|
|
76997
77087
|
const call2 = verb === "dispute" ? client.disputeEscrow.bind(client) : client.counterEvidenceEscrow.bind(client);
|
|
76998
|
-
return await
|
|
76999
|
-
|
|
77088
|
+
return await prepareOrResume(
|
|
77089
|
+
() => call2(
|
|
77000
77090
|
input2.escrowId,
|
|
77001
77091
|
{ evidenceHash: input2.evidenceHash },
|
|
77002
77092
|
{ idempotencyKey: prepareKey }
|
|
77003
77093
|
),
|
|
77004
77094
|
{ ...expected, evidenceHash: input2.evidenceHash },
|
|
77005
77095
|
prepareKey,
|
|
77096
|
+
verb === "dispute" ? "escrow-dispute" : "escrow-counter-evidence",
|
|
77097
|
+
expected.steps,
|
|
77006
77098
|
exposed,
|
|
77007
77099
|
input2.beforeSign
|
|
77008
77100
|
);
|
|
@@ -77022,11 +77114,34 @@ function createTasksChain(options) {
|
|
|
77022
77114
|
await options.bindings.put(binding);
|
|
77023
77115
|
},
|
|
77024
77116
|
createEscrow: (input2) => safe(async () => {
|
|
77025
|
-
|
|
77117
|
+
let workOrder = await order(input2.orderId);
|
|
77026
77118
|
const ready = await deployment();
|
|
77027
|
-
|
|
77028
|
-
|
|
77029
|
-
|
|
77119
|
+
let prepared;
|
|
77120
|
+
let resumedFromServer = false;
|
|
77121
|
+
try {
|
|
77122
|
+
prepared = await client.createEscrow(input2.orderId, {
|
|
77123
|
+
idempotencyKey: input2.idempotencyKey
|
|
77124
|
+
});
|
|
77125
|
+
} catch (error61) {
|
|
77126
|
+
if (!uncertainPreparation(error61)) throw error61;
|
|
77127
|
+
const fresh = await order(input2.orderId);
|
|
77128
|
+
const candidates = fresh.milestones.filter((item) => {
|
|
77129
|
+
const previous = workOrder.milestones.find((prior) => prior.id === item.id);
|
|
77130
|
+
const operation = item.chainOperation;
|
|
77131
|
+
return item.workOrderId === input2.orderId && previous && operation && operation.kind === "escrow-create" && operation.step === "create-escrow" && (previous.escrowState === null || previous.chainOperation?.id === operation.id);
|
|
77132
|
+
});
|
|
77133
|
+
if (candidates.length !== 1) throw error61;
|
|
77134
|
+
const selected2 = candidates[0];
|
|
77135
|
+
prepared = {
|
|
77136
|
+
operation: selected2.chainOperation,
|
|
77137
|
+
milestone: {
|
|
77138
|
+
id: selected2.id,
|
|
77139
|
+
workOrderId: selected2.workOrderId
|
|
77140
|
+
}
|
|
77141
|
+
};
|
|
77142
|
+
workOrder = fresh;
|
|
77143
|
+
resumedFromServer = true;
|
|
77144
|
+
}
|
|
77030
77145
|
const selected = workOrder.milestones.find((item) => item.id === prepared.milestone.id);
|
|
77031
77146
|
if (!selected || selected.workOrderId !== input2.orderId)
|
|
77032
77147
|
throw new TasksValidationError(
|
|
@@ -77036,11 +77151,12 @@ function createTasksChain(options) {
|
|
|
77036
77151
|
{ escrowId: selected.id, idempotencyKey: input2.idempotencyKey },
|
|
77037
77152
|
"createEscrow"
|
|
77038
77153
|
);
|
|
77039
|
-
|
|
77154
|
+
const result = await execute(
|
|
77040
77155
|
prepared,
|
|
77041
77156
|
await expectation(selected, ready, "createEscrow", ["create-escrow"], input2.counterparty),
|
|
77042
77157
|
prepareKey
|
|
77043
77158
|
);
|
|
77159
|
+
return resumedFromServer ? { ...result, resumedFromServer: true } : result;
|
|
77044
77160
|
}),
|
|
77045
77161
|
async fund(input2) {
|
|
77046
77162
|
let exposed = true;
|
|
@@ -77128,10 +77244,14 @@ function createTasksChain(options) {
|
|
|
77128
77244
|
}
|
|
77129
77245
|
exposed = true;
|
|
77130
77246
|
await pending.markExposure(selected.id);
|
|
77131
|
-
|
|
77132
|
-
idempotencyKey: prepareKey
|
|
77133
|
-
|
|
77134
|
-
|
|
77247
|
+
return await prepareOrResume(
|
|
77248
|
+
() => client.fundEscrow(input2.escrowId, body, { idempotencyKey: prepareKey }),
|
|
77249
|
+
expected,
|
|
77250
|
+
prepareKey,
|
|
77251
|
+
"escrow-funding",
|
|
77252
|
+
expected.steps,
|
|
77253
|
+
exposed
|
|
77254
|
+
);
|
|
77135
77255
|
} catch (cause) {
|
|
77136
77256
|
throw chainError(cause, false, exposed);
|
|
77137
77257
|
}
|
|
@@ -77156,22 +77276,26 @@ function createTasksChain(options) {
|
|
|
77156
77276
|
manifest: frozen.manifest,
|
|
77157
77277
|
note: input2.note
|
|
77158
77278
|
});
|
|
77159
|
-
|
|
77160
|
-
|
|
77161
|
-
|
|
77162
|
-
|
|
77163
|
-
|
|
77164
|
-
|
|
77165
|
-
|
|
77166
|
-
|
|
77167
|
-
|
|
77168
|
-
|
|
77169
|
-
|
|
77279
|
+
return await prepareOrResume(
|
|
77280
|
+
async () => {
|
|
77281
|
+
const prepared = await client.deliverEscrow(
|
|
77282
|
+
input2.escrowId,
|
|
77283
|
+
{ fileIds: frozen.manifest.files.map((file2) => file2.fileId), note: input2.note },
|
|
77284
|
+
{ idempotencyKey: prepareKey }
|
|
77285
|
+
);
|
|
77286
|
+
if (prepared.delivery.manifestHash !== frozen.manifestHash)
|
|
77287
|
+
throw new TasksValidationError(
|
|
77288
|
+
"The server task delivery manifest hash does not match the local manifest."
|
|
77289
|
+
);
|
|
77290
|
+
return prepared;
|
|
77291
|
+
},
|
|
77170
77292
|
{
|
|
77171
77293
|
...expected,
|
|
77172
77294
|
manifestHash: frozen.manifestHash
|
|
77173
77295
|
},
|
|
77174
|
-
prepareKey
|
|
77296
|
+
prepareKey,
|
|
77297
|
+
"escrow-delivery",
|
|
77298
|
+
"submit-delivery"
|
|
77175
77299
|
);
|
|
77176
77300
|
}),
|
|
77177
77301
|
release: (input2) => safe(async () => {
|
|
@@ -77185,10 +77309,12 @@ function createTasksChain(options) {
|
|
|
77185
77309
|
input2.counterparty
|
|
77186
77310
|
);
|
|
77187
77311
|
const prepareKey = await preparation(input2, "release");
|
|
77188
|
-
return await
|
|
77189
|
-
|
|
77312
|
+
return await prepareOrResume(
|
|
77313
|
+
() => client.releaseEscrow(input2.escrowId, { idempotencyKey: prepareKey }),
|
|
77190
77314
|
expected,
|
|
77191
|
-
prepareKey
|
|
77315
|
+
prepareKey,
|
|
77316
|
+
"escrow-release",
|
|
77317
|
+
"release-funds"
|
|
77192
77318
|
);
|
|
77193
77319
|
}),
|
|
77194
77320
|
refund: (input2) => safe(async () => {
|
|
@@ -77202,10 +77328,12 @@ function createTasksChain(options) {
|
|
|
77202
77328
|
input2.counterparty
|
|
77203
77329
|
);
|
|
77204
77330
|
const prepareKey = await preparation(input2, "refund");
|
|
77205
|
-
return await
|
|
77206
|
-
|
|
77331
|
+
return await prepareOrResume(
|
|
77332
|
+
() => client.refundEscrow(input2.escrowId, { idempotencyKey: prepareKey }),
|
|
77207
77333
|
expected,
|
|
77208
|
-
prepareKey
|
|
77334
|
+
prepareKey,
|
|
77335
|
+
"escrow-release",
|
|
77336
|
+
"refund-buyer"
|
|
77209
77337
|
);
|
|
77210
77338
|
}),
|
|
77211
77339
|
disputeFee: (input2) => safe(async () => {
|
|
@@ -77233,16 +77361,21 @@ function createTasksChain(options) {
|
|
|
77233
77361
|
input2.counterparty
|
|
77234
77362
|
);
|
|
77235
77363
|
const prepareKey = await preparation(input2, "resolve-unmatched");
|
|
77236
|
-
return
|
|
77237
|
-
|
|
77364
|
+
return prepareOrResume(
|
|
77365
|
+
() => client.resolveUnmatchedEscrow(input2.escrowId, { idempotencyKey: prepareKey }),
|
|
77238
77366
|
expected,
|
|
77239
|
-
prepareKey
|
|
77367
|
+
prepareKey,
|
|
77368
|
+
"escrow-unmatched-resolution",
|
|
77369
|
+
"resolve-unmatched-dispute"
|
|
77240
77370
|
);
|
|
77241
77371
|
}),
|
|
77242
77372
|
signScopeMessage: (message) => safe(() => account.signMessage({ message }))
|
|
77243
77373
|
};
|
|
77244
77374
|
}
|
|
77245
77375
|
var chainError = safeTasksChainError;
|
|
77376
|
+
function uncertainPreparation(error61) {
|
|
77377
|
+
return error61 instanceof TasksClientError && ((error61.status ?? 0) >= 400 || error61.code === "network" || error61.code === "timeout");
|
|
77378
|
+
}
|
|
77246
77379
|
function retryDelay(header, now) {
|
|
77247
77380
|
if (/^\d+(?:\.\d+)?$/u.test(header.trim())) return Math.max(1, Math.ceil(Number(header) * 1e3));
|
|
77248
77381
|
const date5 = Date.parse(header);
|
|
@@ -77259,6 +77392,60 @@ function alreadySent(error61) {
|
|
|
77259
77392
|
return error61 instanceof Error && /already known|known transaction|nonce (?:is )?too low/iu.test(error61.message);
|
|
77260
77393
|
}
|
|
77261
77394
|
|
|
77395
|
+
// ../core/src/tasks/wait.ts
|
|
77396
|
+
async function waitForMilestone(client, input2) {
|
|
77397
|
+
const timeoutMs = input2.timeoutMs ?? 12e4;
|
|
77398
|
+
const intervalMs = input2.intervalMs ?? 3e3;
|
|
77399
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 0)
|
|
77400
|
+
throw new RangeError("The milestone wait timeout must be non-negative and finite.");
|
|
77401
|
+
if (!Number.isFinite(intervalMs) || intervalMs <= 0)
|
|
77402
|
+
throw new RangeError("The milestone wait interval must be positive and finite.");
|
|
77403
|
+
const sleep = input2.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
77404
|
+
const now = input2.now ?? (() => /* @__PURE__ */ new Date());
|
|
77405
|
+
const started = now().getTime();
|
|
77406
|
+
const deadline = started + timeoutMs;
|
|
77407
|
+
let polls = 0;
|
|
77408
|
+
let milestone;
|
|
77409
|
+
function result(reached) {
|
|
77410
|
+
return { reached, milestone, polls, elapsedMs: now().getTime() - started };
|
|
77411
|
+
}
|
|
77412
|
+
for (; ; ) {
|
|
77413
|
+
const remaining = deadline - now().getTime();
|
|
77414
|
+
if (remaining <= 0) return result(false);
|
|
77415
|
+
const controller = new AbortController();
|
|
77416
|
+
const timer = setTimeout(() => controller.abort(), remaining);
|
|
77417
|
+
let response;
|
|
77418
|
+
polls++;
|
|
77419
|
+
try {
|
|
77420
|
+
response = await client.getOrder(input2.orderId, { signal: controller.signal });
|
|
77421
|
+
} catch (error61) {
|
|
77422
|
+
if (controller.signal.aborted) return result(false);
|
|
77423
|
+
throw error61;
|
|
77424
|
+
} finally {
|
|
77425
|
+
clearTimeout(timer);
|
|
77426
|
+
}
|
|
77427
|
+
if (controller.signal.aborted || now().getTime() >= deadline) return result(false);
|
|
77428
|
+
const { workOrder } = response;
|
|
77429
|
+
milestone = workOrder.id === input2.orderId && workOrder.version === "work-order-view-v1" ? workOrder.milestones.find(
|
|
77430
|
+
(item) => item.id === input2.milestoneId && item.workOrderId === input2.orderId
|
|
77431
|
+
) : void 0;
|
|
77432
|
+
if (milestone && reachedTarget(milestone, input2.target)) return result(true);
|
|
77433
|
+
await sleep(Math.min(intervalMs, deadline - now().getTime()));
|
|
77434
|
+
}
|
|
77435
|
+
}
|
|
77436
|
+
function reachedTarget(milestone, target) {
|
|
77437
|
+
switch (target) {
|
|
77438
|
+
case "created":
|
|
77439
|
+
return milestone.escrowState !== null;
|
|
77440
|
+
case "locked":
|
|
77441
|
+
return ["locked", "submitted", "disputed", "resolved"].includes(milestone.escrowState ?? "");
|
|
77442
|
+
case "delivered":
|
|
77443
|
+
return ["submitted", "disputed", "resolved"].includes(milestone.escrowState ?? "");
|
|
77444
|
+
case "released":
|
|
77445
|
+
return milestone.escrowState === "resolved";
|
|
77446
|
+
}
|
|
77447
|
+
}
|
|
77448
|
+
|
|
77262
77449
|
// ../core/src/tasks/rpc.ts
|
|
77263
77450
|
function createTasksRpcFor(config2, options = {}) {
|
|
77264
77451
|
const clients = /* @__PURE__ */ new Map();
|
|
@@ -78372,7 +78559,10 @@ async function taskRequest(verb, route, operation, options) {
|
|
|
78372
78559
|
"not_signed_in",
|
|
78373
78560
|
`${verb} needs sign-in. ${options.signInHint}`
|
|
78374
78561
|
);
|
|
78375
|
-
throw new TaskOperationError(
|
|
78562
|
+
throw new TaskOperationError(
|
|
78563
|
+
error61.serverCode ?? (error61.status ? `http_${error61.status}` : error61.code),
|
|
78564
|
+
error61.message
|
|
78565
|
+
);
|
|
78376
78566
|
}
|
|
78377
78567
|
throw error61;
|
|
78378
78568
|
}
|
|
@@ -78493,7 +78683,8 @@ function proposalTerms(id2, address4, deployment, terms) {
|
|
|
78493
78683
|
return {
|
|
78494
78684
|
version: "work-proposal-v1",
|
|
78495
78685
|
workOrderId: id2,
|
|
78496
|
-
|
|
78686
|
+
// The server lowercases addresses before canonicalizing the signed payload.
|
|
78687
|
+
providerAddress: address4.toLowerCase(),
|
|
78497
78688
|
pricingModel: "fixed",
|
|
78498
78689
|
milestones: [
|
|
78499
78690
|
{
|
|
@@ -78880,6 +79071,55 @@ async function showTask(context, input2) {
|
|
|
78880
79071
|
};
|
|
78881
79072
|
}
|
|
78882
79073
|
async function taskStatus(context, input2) {
|
|
79074
|
+
if (input2.signedIn) {
|
|
79075
|
+
const chainState = await taskRequest(
|
|
79076
|
+
"status",
|
|
79077
|
+
"chainState",
|
|
79078
|
+
async () => {
|
|
79079
|
+
try {
|
|
79080
|
+
return await context.client.chainState(input2.id);
|
|
79081
|
+
} catch (error61) {
|
|
79082
|
+
if (error61 instanceof TasksClientError && error61.status === 404) {
|
|
79083
|
+
if (isMissingTaskEntity(error61.serverCode, error61.message))
|
|
79084
|
+
throw new TaskOperationError("not_found", error61.message);
|
|
79085
|
+
throw new TaskOperationError(
|
|
79086
|
+
"not_available",
|
|
79087
|
+
"GET /v1/work-orders/:id/chain-state is not available on this server."
|
|
79088
|
+
);
|
|
79089
|
+
}
|
|
79090
|
+
throw error61;
|
|
79091
|
+
}
|
|
79092
|
+
},
|
|
79093
|
+
context
|
|
79094
|
+
);
|
|
79095
|
+
if (chainState.workOrderId !== input2.id)
|
|
79096
|
+
throw new TaskOperationError("invalid_response", "The response belongs to a different task.");
|
|
79097
|
+
const page = await taskRequest(
|
|
79098
|
+
"status",
|
|
79099
|
+
"events",
|
|
79100
|
+
async () => {
|
|
79101
|
+
try {
|
|
79102
|
+
return await context.client.events(input2.id, { wait: 0 });
|
|
79103
|
+
} catch (error61) {
|
|
79104
|
+
if (error61 instanceof TasksClientError && error61.status === 404) {
|
|
79105
|
+
if (isMissingTaskEntity(error61.serverCode, error61.message)) return null;
|
|
79106
|
+
throw new TaskOperationError(
|
|
79107
|
+
"not_available",
|
|
79108
|
+
"GET /v1/work-orders/:id/events is not available on this server."
|
|
79109
|
+
);
|
|
79110
|
+
}
|
|
79111
|
+
throw error61;
|
|
79112
|
+
}
|
|
79113
|
+
},
|
|
79114
|
+
context
|
|
79115
|
+
);
|
|
79116
|
+
return {
|
|
79117
|
+
task: { id: input2.id },
|
|
79118
|
+
chainState,
|
|
79119
|
+
events: page ? [...page.events].sort((a, b) => a.sequence - b.sequence) : null,
|
|
79120
|
+
nextAfter: page?.nextAfter ?? null
|
|
79121
|
+
};
|
|
79122
|
+
}
|
|
78883
79123
|
const task = await taskRequest(
|
|
78884
79124
|
"status",
|
|
78885
79125
|
"publicTask",
|
|
@@ -79235,6 +79475,7 @@ var searchEventSchema = external_exports.strictObject({
|
|
|
79235
79475
|
source: external_exports.string().min(1),
|
|
79236
79476
|
latencyMs: external_exports.number().nonnegative().finite(),
|
|
79237
79477
|
count: external_exports.number().int().nonnegative(),
|
|
79478
|
+
dropped: external_exports.number().int().nonnegative().optional(),
|
|
79238
79479
|
error: external_exports.string().optional()
|
|
79239
79480
|
})
|
|
79240
79481
|
),
|
|
@@ -81954,11 +82195,28 @@ async function searchMarketplace(input2, config2, fetchImpl, options = {}) {
|
|
|
81954
82195
|
}
|
|
81955
82196
|
}
|
|
81956
82197
|
});
|
|
81957
|
-
const
|
|
81958
|
-
|
|
82198
|
+
const envelope = marketplaceDiscoveryEnvelopeSchema.parse(await response.json());
|
|
82199
|
+
const items = [];
|
|
82200
|
+
let dropped = 0;
|
|
82201
|
+
for (const [index2, rawItem] of envelope.items.entries()) {
|
|
82202
|
+
const parsed = marketplaceHitSchema.safeParse(rawItem);
|
|
82203
|
+
if (parsed.success) {
|
|
82204
|
+
items.push(parsed.data);
|
|
82205
|
+
continue;
|
|
82206
|
+
}
|
|
82207
|
+
dropped += 1;
|
|
82208
|
+
try {
|
|
82209
|
+
options.debug?.(`vAPI marketplace discovery dropped invalid row at index ${index2}.`);
|
|
82210
|
+
} catch {
|
|
82211
|
+
}
|
|
82212
|
+
}
|
|
82213
|
+
mergedCount = items.length;
|
|
81959
82214
|
const attempt = attempts.at(-1);
|
|
81960
|
-
if (attempt)
|
|
81961
|
-
|
|
82215
|
+
if (attempt) {
|
|
82216
|
+
attempt.count = mergedCount;
|
|
82217
|
+
if (dropped > 0) attempt.dropped = dropped;
|
|
82218
|
+
}
|
|
82219
|
+
return { ...envelope, items };
|
|
81962
82220
|
} finally {
|
|
81963
82221
|
if (options.searchesPath) {
|
|
81964
82222
|
await appendSearchEvent(
|
|
@@ -82087,6 +82345,34 @@ var VapiCallError = class extends Error {
|
|
|
82087
82345
|
paymentRejection;
|
|
82088
82346
|
confirmedSettlement;
|
|
82089
82347
|
};
|
|
82348
|
+
var SOLANA_PAYMENTS_UNSUPPORTED_MESSAGE = "Solana payments are not supported in this version of vAPI yet; they arrive in a later release.";
|
|
82349
|
+
function isSolanaCaip2(network) {
|
|
82350
|
+
return network.startsWith("solana:");
|
|
82351
|
+
}
|
|
82352
|
+
function listingPaymentNetwork(endpointNetwork, serviceNetworks) {
|
|
82353
|
+
if (endpointNetwork !== void 0) return endpointNetwork;
|
|
82354
|
+
return serviceNetworks?.length && serviceNetworks.every(isSolanaCaip2) ? serviceNetworks[0] : void 0;
|
|
82355
|
+
}
|
|
82356
|
+
function assertSupportedListingNetwork(network) {
|
|
82357
|
+
if (network !== void 0 && isSolanaCaip2(network)) {
|
|
82358
|
+
throw new VapiCallError(
|
|
82359
|
+
"unsupported_network",
|
|
82360
|
+
`${SOLANA_PAYMENTS_UNSUPPORTED_MESSAGE} This listing pays on ${network}.`
|
|
82361
|
+
);
|
|
82362
|
+
}
|
|
82363
|
+
}
|
|
82364
|
+
function assertSupportedListingResolution(error61) {
|
|
82365
|
+
if (isDiscoveryCatalogError(error61) && error61.code === "ambiguous_default" && error61.paymentNetworks?.length && error61.paymentNetworks.every(isSolanaCaip2)) {
|
|
82366
|
+
assertSupportedListingNetwork(error61.paymentNetworks[0]);
|
|
82367
|
+
}
|
|
82368
|
+
}
|
|
82369
|
+
function payableConfig(config2, account) {
|
|
82370
|
+
if (account.solana !== void 0) return config2;
|
|
82371
|
+
const networks = Object.fromEntries(
|
|
82372
|
+
Object.entries(config2.networks).filter(([network]) => !isSolanaCaip2(network))
|
|
82373
|
+
);
|
|
82374
|
+
return { ...config2, networks };
|
|
82375
|
+
}
|
|
82090
82376
|
var MAX_RESPONSE_BYTES = 1048576;
|
|
82091
82377
|
var BODY_HEADER_NAMES = [
|
|
82092
82378
|
"content-encoding",
|
|
@@ -82101,7 +82387,9 @@ async function callService(args) {
|
|
|
82101
82387
|
try {
|
|
82102
82388
|
execution = await executeCallService(args, trace);
|
|
82103
82389
|
} catch (error61) {
|
|
82104
|
-
|
|
82390
|
+
if (!(error61 instanceof VapiCallError && error61.code === "unsupported_network")) {
|
|
82391
|
+
await recordCallError(args, error61, trace).catch(() => void 0);
|
|
82392
|
+
}
|
|
82105
82393
|
throw error61;
|
|
82106
82394
|
}
|
|
82107
82395
|
try {
|
|
@@ -82149,10 +82437,16 @@ async function executeCallService(args, trace) {
|
|
|
82149
82437
|
config2,
|
|
82150
82438
|
fetchImpl
|
|
82151
82439
|
);
|
|
82440
|
+
} catch (error61) {
|
|
82441
|
+
assertSupportedListingResolution(error61);
|
|
82442
|
+
throw error61;
|
|
82152
82443
|
} finally {
|
|
82153
82444
|
trace.phases.discoverMs = elapsed2(trace, discoverStarted);
|
|
82154
82445
|
}
|
|
82155
82446
|
}
|
|
82447
|
+
assertSupportedListingNetwork(
|
|
82448
|
+
listingPaymentNetwork(endpoint?.payment?.network, endpoint?.serviceNetworks)
|
|
82449
|
+
);
|
|
82156
82450
|
const requestedNetwork = normalizeRequiredNetwork(input2.network);
|
|
82157
82451
|
const listingNetwork = endpoint?.payment?.network;
|
|
82158
82452
|
if (requestedNetwork && listingNetwork && !areSamePaymentNetwork(requestedNetwork, listingNetwork)) {
|
|
@@ -82368,7 +82662,7 @@ async function executeCallService(args, trace) {
|
|
|
82368
82662
|
challenge: challengeAttempt,
|
|
82369
82663
|
account,
|
|
82370
82664
|
caps: args.spendCaps ?? config2.spendCaps,
|
|
82371
|
-
config: config2,
|
|
82665
|
+
config: payableConfig(config2, account),
|
|
82372
82666
|
send: async (paidRequest) => {
|
|
82373
82667
|
paidAttempt = await fetchWithGuardedRedirects(paidRequest, false);
|
|
82374
82668
|
return paidAttempt;
|
|
@@ -82618,7 +82912,7 @@ async function resolveCallEndpoint(id2, endpointName, marketplaceHit, config2, f
|
|
|
82618
82912
|
try {
|
|
82619
82913
|
return registeredEndpoint(await resolveServiceListing(id2, config2, fetchImpl, endpointName));
|
|
82620
82914
|
} catch (error61) {
|
|
82621
|
-
if (!(error61
|
|
82915
|
+
if (!isDiscoveryCatalogError(error61) || error61.code !== "service_not_found") {
|
|
82622
82916
|
throw error61;
|
|
82623
82917
|
}
|
|
82624
82918
|
const discovered = await findMarketplaceApiByRef(id2, config2, fetchImpl);
|
|
@@ -82658,6 +82952,7 @@ function registeredEndpoint(listing, verification) {
|
|
|
82658
82952
|
return {
|
|
82659
82953
|
...listing.endpoint,
|
|
82660
82954
|
verification: verification ?? listing.service.verification,
|
|
82955
|
+
serviceNetworks: listing.service.networks,
|
|
82661
82956
|
registered: true,
|
|
82662
82957
|
resolvedListing: true
|
|
82663
82958
|
};
|
|
@@ -82896,14 +83191,17 @@ async function inspectService(input2, config2, fetchImpl) {
|
|
|
82896
83191
|
try {
|
|
82897
83192
|
listing = await resolveServiceListing(input2.id, config2, fetchImpl, input2.endpoint);
|
|
82898
83193
|
} catch (error61) {
|
|
82899
|
-
|
|
83194
|
+
assertSupportedListingResolution(error61);
|
|
83195
|
+
if (input2.endpoint || !isDiscoveryCatalogError(error61) || error61.code !== "service_not_found") {
|
|
82900
83196
|
throw error61;
|
|
82901
83197
|
}
|
|
82902
83198
|
const hit = await findMarketplaceApiByRef(input2.id, config2, fetchImpl);
|
|
82903
83199
|
if (!hit || hit.kind !== "api" || hit.provenance !== "indexed") throw error61;
|
|
83200
|
+
assertSupportedListingNetwork(hit.execution.network);
|
|
82904
83201
|
return inspectIndexedHit(hit);
|
|
82905
83202
|
}
|
|
82906
83203
|
const { endpoint, service } = listing;
|
|
83204
|
+
assertSupportedListingNetwork(listingPaymentNetwork(endpoint.payment?.network, service.networks));
|
|
82907
83205
|
return {
|
|
82908
83206
|
name: endpoint.name,
|
|
82909
83207
|
method: endpoint.method,
|
|
@@ -86676,6 +86974,7 @@ var moneyParticipant = {
|
|
|
86676
86974
|
"Checksummed 0x address of the other party, taken from tasks.show (the poster's clientAddress when you are the worker; the accepted proposal's providerAddress when you are the poster). The human must supply it; it is compared with the signed scope and stored as local consent. Without it tasks.sign refuses and no local party binding is created, so tasks.fund/deliver/release cannot run from this machine."
|
|
86677
86975
|
).optional()
|
|
86678
86976
|
};
|
|
86977
|
+
var waitForIndexer = external_exports.boolean().default(true).describe("Wait up to 60 seconds for vAPI to index the chain result before returning.");
|
|
86679
86978
|
var cursor = external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
86680
86979
|
function usdWithinEscrow(value, positive = false) {
|
|
86681
86980
|
try {
|
|
@@ -86722,7 +87021,10 @@ var tasksPostTool = descriptor(
|
|
|
86722
87021
|
deadline: external_exports.string(),
|
|
86723
87022
|
intake: external_exports.enum(["proposals", "submissions"]).optional(),
|
|
86724
87023
|
maxAwards: external_exports.number().int().min(TASK_LIMITS.maxAwardsMin).max(TASK_LIMITS.maxAwardsMax).optional(),
|
|
86725
|
-
webhookUrl: httpsUrl.optional()
|
|
87024
|
+
webhookUrl: httpsUrl.optional(),
|
|
87025
|
+
vendor: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/u).describe(
|
|
87026
|
+
"Optional 0x address of a vendor to invite directly; the task is addressed to that wallet and shows up for them. Anyone may still propose."
|
|
87027
|
+
).optional()
|
|
86726
87028
|
}
|
|
86727
87029
|
);
|
|
86728
87030
|
var tasksProposeTool = descriptor(
|
|
@@ -86747,42 +87049,43 @@ var tasksAwardTool = descriptor(
|
|
|
86747
87049
|
{ ...participant, proposalId: id }
|
|
86748
87050
|
);
|
|
86749
87051
|
var tasksSignTool = descriptor(
|
|
86750
|
-
"
|
|
86751
|
-
moneyParticipant
|
|
87052
|
+
"Signs the user's own task scope locally with the user's vault wallet after the human confirms the money direction via counterparty; a worker may also create the unfunded escrow; nothing is custodial. Does not move money. Waits up to 60 seconds for vAPI to index a created escrow by default.",
|
|
87053
|
+
{ ...moneyParticipant, wait: waitForIndexer }
|
|
86752
87054
|
);
|
|
86753
87055
|
var tasksFundTool = descriptor(
|
|
86754
|
-
"
|
|
86755
|
-
moneyParticipant
|
|
87056
|
+
"Executes the user's own funding of this task from the user's vault wallet, within the spend policy the user configured; nothing is custodial. MCP cannot grant human approval; amounts above the approval threshold are refused with approval:true. Waits up to 60 seconds for vAPI to index the locked escrow by default.",
|
|
87057
|
+
{ ...moneyParticipant, wait: waitForIndexer }
|
|
86756
87058
|
);
|
|
86757
87059
|
var tasksDeliverTool = descriptor(
|
|
86758
|
-
"Does not move money. Upload local delivery files, freeze the manifest and record delivery with the local vault wallet.",
|
|
87060
|
+
"Does not move money. Upload local delivery files, freeze the manifest and record delivery with the local vault wallet. Waits up to 60 seconds for vAPI to index the delivery by default.",
|
|
86759
87061
|
{
|
|
86760
87062
|
...moneyParticipant,
|
|
87063
|
+
wait: waitForIndexer,
|
|
86761
87064
|
files: external_exports.array(localPath).min(TASK_LIMITS.deliveryFilesMin).max(TASK_LIMITS.deliveryFilesMax),
|
|
86762
87065
|
note: external_exports.string().max(TASK_LIMITS.deliveryNoteMax).refine((value) => value.trim().length > 0)
|
|
86763
87066
|
}
|
|
86764
87067
|
);
|
|
86765
87068
|
var tasksReleaseTool = descriptor(
|
|
86766
|
-
"
|
|
86767
|
-
moneyParticipant
|
|
87069
|
+
"Executes the user's own payment to the worker from task escrow with the user's vault wallet; nothing is custodial. Returns gross \xB7 fee \xB7 net using the deployed fee. Waits up to 60 seconds for vAPI to index the release by default.",
|
|
87070
|
+
{ ...moneyParticipant, wait: waitForIndexer }
|
|
86768
87071
|
);
|
|
86769
87072
|
var tasksRefundTool = descriptor(
|
|
86770
|
-
"
|
|
87073
|
+
"Executes the user's own refund of escrowed USDC to the poster with the user's vault wallet; nothing is custodial. Returns gross \xB7 fee \xB7 net using the deployed fee.",
|
|
86771
87074
|
moneyParticipant
|
|
86772
87075
|
);
|
|
86773
87076
|
var tasksDisputeTool = descriptor(
|
|
86774
|
-
"
|
|
87077
|
+
"Executes the user's own approval of the verified dispute fee and raises a dispute with the user's vault wallet; nothing is custodial. Applies task and daily caps; MCP refuses human approval with approval:true. Accepts a precomputed evidence hash.",
|
|
86775
87078
|
{
|
|
86776
87079
|
...moneyParticipant,
|
|
86777
87080
|
evidenceHash: external_exports.string().regex(TASK_LIMITS.disputeEvidenceHash)
|
|
86778
87081
|
}
|
|
86779
87082
|
);
|
|
86780
87083
|
var tasksCounterEvidenceTool = descriptor(
|
|
86781
|
-
"
|
|
87084
|
+
"Executes the user's own counter-evidence submission and approval of the verified dispute fee with the user's vault wallet as the non-opener before the onchain deadline; nothing is custodial. Applies task and daily caps; MCP refuses human approval with approval:true.",
|
|
86782
87085
|
{ ...moneyParticipant, evidenceHash: external_exports.string().regex(TASK_LIMITS.disputeEvidenceHash) }
|
|
86783
87086
|
);
|
|
86784
87087
|
var tasksResolveUnmatchedTool = descriptor(
|
|
86785
|
-
"
|
|
87088
|
+
"Executes the user's own resolution of an unmatched dispute with the user's vault wallet after the onchain counter-evidence deadline when no counter-evidence was submitted; nothing is custodial.",
|
|
86786
87089
|
moneyParticipant
|
|
86787
87090
|
);
|
|
86788
87091
|
var tasksMessageTool = descriptor(
|
|
@@ -86806,8 +87109,8 @@ var tasksWatchTool = descriptor(
|
|
|
86806
87109
|
}
|
|
86807
87110
|
);
|
|
86808
87111
|
var tasksStatusTool = descriptor(
|
|
86809
|
-
"Does not move money. Read the public task card
|
|
86810
|
-
|
|
87112
|
+
"Does not move money. Read signed-in chain state and participant events, or the public task card without sign-in.",
|
|
87113
|
+
participant
|
|
86811
87114
|
);
|
|
86812
87115
|
var signInHint = "Call auth.link for the acting wallet.";
|
|
86813
87116
|
function lazyTasksChain(factory, pending) {
|
|
@@ -86947,6 +87250,22 @@ function createTasksTools(options) {
|
|
|
86947
87250
|
};
|
|
86948
87251
|
};
|
|
86949
87252
|
}
|
|
87253
|
+
async function waitAfterChain(ctx, orderId, milestoneId, target) {
|
|
87254
|
+
return await taskRequest(
|
|
87255
|
+
target,
|
|
87256
|
+
"getOrder",
|
|
87257
|
+
() => waitForMilestone(ctx.client, {
|
|
87258
|
+
orderId,
|
|
87259
|
+
milestoneId,
|
|
87260
|
+
target,
|
|
87261
|
+
timeoutMs: 6e4,
|
|
87262
|
+
intervalMs: 3e3,
|
|
87263
|
+
...options.sleep === void 0 ? {} : { sleep: options.sleep },
|
|
87264
|
+
now
|
|
87265
|
+
}),
|
|
87266
|
+
ctx
|
|
87267
|
+
);
|
|
87268
|
+
}
|
|
86950
87269
|
async function feeAction(verb, input2) {
|
|
86951
87270
|
const ctx = await acting(input2.wallet);
|
|
86952
87271
|
const policy = await taskPolicyForWallet({
|
|
@@ -86989,7 +87308,12 @@ function createTasksTools(options) {
|
|
|
86989
87308
|
throw new TaskInputError("deadline must be at least 10 minutes from now.");
|
|
86990
87309
|
const ctx = await acting(input2.wallet);
|
|
86991
87310
|
const outcome = await postTask(ctx, {
|
|
86992
|
-
order: {
|
|
87311
|
+
order: {
|
|
87312
|
+
title: input2.title,
|
|
87313
|
+
description: input2.brief,
|
|
87314
|
+
policyFamily: "general-digital",
|
|
87315
|
+
...input2.vendor === void 0 ? {} : { invitedProviderAddress: input2.vendor }
|
|
87316
|
+
},
|
|
86993
87317
|
amount: parseUsdToBaseUnits(input2.amountUsd),
|
|
86994
87318
|
deadlineAt: new Date(postedAt.getTime() + deadlineDuration).toISOString(),
|
|
86995
87319
|
...input2.intake === void 0 ? {} : { intake: input2.intake },
|
|
@@ -87047,15 +87371,15 @@ function createTasksTools(options) {
|
|
|
87047
87371
|
const ctx = await acting(input2.wallet);
|
|
87048
87372
|
const signerAddress = (await options.session.addressesFor(ctx.selected.name)).address;
|
|
87049
87373
|
try {
|
|
87050
|
-
|
|
87051
|
-
|
|
87052
|
-
|
|
87053
|
-
|
|
87054
|
-
|
|
87055
|
-
|
|
87056
|
-
|
|
87057
|
-
|
|
87058
|
-
);
|
|
87374
|
+
const outcome = await signTaskScope(ctx, {
|
|
87375
|
+
id: input2.id,
|
|
87376
|
+
counterparty: input2.counterparty,
|
|
87377
|
+
signerAddress,
|
|
87378
|
+
bindings: createScopeBindings(home),
|
|
87379
|
+
signMessage: async (message) => (await unlock(ctx.selected.name)()).signMessage(message)
|
|
87380
|
+
});
|
|
87381
|
+
const wait2 = input2.wait && outcome.escrowCreation ? await waitAfterChain(ctx, input2.id, outcome.escrowCreation.milestone.id, "created") : null;
|
|
87382
|
+
return taskResult({ ...outcome, wait: wait2 });
|
|
87059
87383
|
} catch (error61) {
|
|
87060
87384
|
if (!(error61 instanceof TasksScopeCreationError)) throw error61;
|
|
87061
87385
|
try {
|
|
@@ -87091,28 +87415,31 @@ function createTasksTools(options) {
|
|
|
87091
87415
|
// Stdio has no human approval channel. Model arguments cannot grant approval.
|
|
87092
87416
|
approval: { granted: false }
|
|
87093
87417
|
});
|
|
87094
|
-
|
|
87418
|
+
const wait2 = input2.wait && outcome.ok ? await waitAfterChain(ctx, input2.id, outcome.result.milestone.id, "locked") : null;
|
|
87419
|
+
return taskResult({ ...outcome, wait: wait2 }, !outcome.ok);
|
|
87095
87420
|
},
|
|
87096
87421
|
async deliver(input2) {
|
|
87097
87422
|
const files = (await Promise.all(input2.files.map(readTaskFile))).map(
|
|
87098
87423
|
({ fileName: name, bytes, contentType }) => ({ name, bytes, contentType })
|
|
87099
87424
|
);
|
|
87100
|
-
|
|
87101
|
-
|
|
87102
|
-
|
|
87103
|
-
|
|
87104
|
-
|
|
87105
|
-
|
|
87106
|
-
|
|
87107
|
-
);
|
|
87425
|
+
const ctx = await acting(input2.wallet);
|
|
87426
|
+
const outcome = await deliverTaskOperation(ctx, {
|
|
87427
|
+
id: input2.id,
|
|
87428
|
+
...input2.counterparty === void 0 ? {} : { counterparty: input2.counterparty },
|
|
87429
|
+
files,
|
|
87430
|
+
note: input2.note
|
|
87431
|
+
});
|
|
87432
|
+
const wait2 = input2.wait ? await waitAfterChain(ctx, input2.id, outcome.result.milestone.id, "delivered") : null;
|
|
87433
|
+
return taskResult({ ...outcome, wait: wait2 });
|
|
87108
87434
|
},
|
|
87109
87435
|
async release(input2) {
|
|
87110
|
-
|
|
87111
|
-
|
|
87112
|
-
|
|
87113
|
-
|
|
87114
|
-
|
|
87115
|
-
);
|
|
87436
|
+
const ctx = await acting(input2.wallet);
|
|
87437
|
+
const outcome = await releaseTaskOperation(ctx, {
|
|
87438
|
+
id: input2.id,
|
|
87439
|
+
...input2.counterparty === void 0 ? {} : { counterparty: input2.counterparty }
|
|
87440
|
+
});
|
|
87441
|
+
const wait2 = input2.wait ? await waitAfterChain(ctx, input2.id, outcome.result.milestone.id, "released") : null;
|
|
87442
|
+
return taskResult({ ...outcome, wait: wait2 });
|
|
87116
87443
|
},
|
|
87117
87444
|
async refund(input2) {
|
|
87118
87445
|
return taskResult(
|
|
@@ -87179,7 +87506,11 @@ function createTasksTools(options) {
|
|
|
87179
87506
|
}
|
|
87180
87507
|
},
|
|
87181
87508
|
async status(input2) {
|
|
87182
|
-
|
|
87509
|
+
await options.wallets?.reload();
|
|
87510
|
+
const publicOnly = input2.wallet === void 0 && options.session.activeName === void 0 && options.wallets !== void 0 && options.wallets.names().length === 0;
|
|
87511
|
+
const candidate = await context(input2.wallet, publicOnly);
|
|
87512
|
+
const ctx = candidate.token || publicOnly ? candidate : await context(void 0, true);
|
|
87513
|
+
return taskResult(await taskStatus(ctx, { id: input2.id, signedIn: Boolean(ctx.token) }));
|
|
87183
87514
|
}
|
|
87184
87515
|
};
|
|
87185
87516
|
}
|
|
@@ -87936,6 +88267,11 @@ var statsToolResultSchema = external_exports.object({
|
|
|
87936
88267
|
)
|
|
87937
88268
|
})
|
|
87938
88269
|
});
|
|
88270
|
+
function objectOutputSchema(schema) {
|
|
88271
|
+
if (!schema) return {};
|
|
88272
|
+
const json2 = external_exports.toJSONSchema(schema);
|
|
88273
|
+
return json2.type === "object" ? { outputSchema: json2 } : {};
|
|
88274
|
+
}
|
|
87939
88275
|
var VapiMcpServer = class {
|
|
87940
88276
|
#tools = /* @__PURE__ */ new Map();
|
|
87941
88277
|
#onClose;
|
|
@@ -87959,7 +88295,7 @@ var VapiMcpServer = class {
|
|
|
87959
88295
|
name,
|
|
87960
88296
|
...tool.description ? { description: tool.description } : {},
|
|
87961
88297
|
inputSchema: external_exports.toJSONSchema(tool.inputSchema),
|
|
87962
|
-
...
|
|
88298
|
+
...objectOutputSchema(tool.outputSchema)
|
|
87963
88299
|
}))
|
|
87964
88300
|
};
|
|
87965
88301
|
}
|
|
@@ -88852,6 +89188,7 @@ export {
|
|
|
88852
89188
|
STARTING_RECONCILIATION_TIMEOUT_MS,
|
|
88853
89189
|
SwarmRunError,
|
|
88854
89190
|
UNTRUSTED_NOTICE,
|
|
89191
|
+
VapiCallError,
|
|
88855
89192
|
WalletSession,
|
|
88856
89193
|
accountsSend,
|
|
88857
89194
|
accountsSendInputSchema,
|