vapi-network 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -8
- package/dist/cli.js +460 -87
- package/dist/cli.js.map +3 -3
- package/dist/index.js +478 -91
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -39357,8 +39357,10 @@ var listingIdentitySchema = external_exports.looseObject({
|
|
|
39357
39357
|
}).optional().catch(void 0)
|
|
39358
39358
|
});
|
|
39359
39359
|
var listingDisclosureShape = {
|
|
39360
|
-
|
|
39361
|
-
fee
|
|
39360
|
+
// Presentation metadata must not make an otherwise executable row vanish
|
|
39361
|
+
// when the registry adds a new group or changes the fee display shape.
|
|
39362
|
+
group: listingGroupSchema.optional().catch(void 0),
|
|
39363
|
+
fee: listingFeeSchema.optional().catch(void 0),
|
|
39362
39364
|
verification: listingVerificationFieldSchema,
|
|
39363
39365
|
liveness: listingLivenessSchema.optional().catch(void 0),
|
|
39364
39366
|
conformance: listingConformanceSchema.optional().catch(void 0),
|
|
@@ -39366,11 +39368,13 @@ var listingDisclosureShape = {
|
|
|
39366
39368
|
};
|
|
39367
39369
|
var marketplaceBadgeCodeSchema = external_exports.enum([
|
|
39368
39370
|
"live_x402",
|
|
39371
|
+
"mpp",
|
|
39369
39372
|
"partner",
|
|
39370
39373
|
"payout_wallet_confirmed",
|
|
39371
39374
|
"vapi_verified",
|
|
39372
39375
|
"external_catalog",
|
|
39373
|
-
"approved_vendor"
|
|
39376
|
+
"approved_vendor",
|
|
39377
|
+
"unverified"
|
|
39374
39378
|
]);
|
|
39375
39379
|
var marketplaceBadgeSchema = external_exports.looseObject({
|
|
39376
39380
|
code: marketplaceBadgeCodeSchema,
|
|
@@ -39389,7 +39393,13 @@ var marketplaceCardSchema = external_exports.looseObject({
|
|
|
39389
39393
|
summary: external_exports.string().trim().min(1).max(1e3),
|
|
39390
39394
|
byline: external_exports.string().trim().min(1).max(160).optional(),
|
|
39391
39395
|
bylineHref: marketplaceHrefSchema.optional(),
|
|
39392
|
-
badges: external_exports.
|
|
39396
|
+
badges: external_exports.preprocess(
|
|
39397
|
+
(badges) => Array.isArray(badges) ? badges.flatMap((badge) => {
|
|
39398
|
+
const parsed = marketplaceBadgeSchema.safeParse(badge);
|
|
39399
|
+
return parsed.success ? [parsed.data] : [];
|
|
39400
|
+
}) : badges,
|
|
39401
|
+
external_exports.array(marketplaceBadgeSchema).max(8)
|
|
39402
|
+
),
|
|
39393
39403
|
facts: external_exports.array(marketplacePublicFactSchema).max(12)
|
|
39394
39404
|
});
|
|
39395
39405
|
var marketplaceHitBase = {
|
|
@@ -44870,9 +44880,9 @@ function createPublicFetch(options) {
|
|
|
44870
44880
|
});
|
|
44871
44881
|
});
|
|
44872
44882
|
}
|
|
44873
|
-
function pinnedLookup(
|
|
44883
|
+
function pinnedLookup(lookup2) {
|
|
44874
44884
|
return (hostname3, dnsOptions, callback) => {
|
|
44875
|
-
void
|
|
44885
|
+
void lookup2(normalizeHostname(hostname3)).then((addresses) => {
|
|
44876
44886
|
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
44877
44887
|
callback(guardError(new URL(`https://${hostname3}`)), "");
|
|
44878
44888
|
return;
|
|
@@ -46010,9 +46020,9 @@ function isRecord2(value) {
|
|
|
46010
46020
|
var CALLABLE_CATEGORIES = ["ai", "data", "crypto", "compute", "search"];
|
|
46011
46021
|
var callableCategorySchema = external_exports.enum(CALLABLE_CATEGORIES);
|
|
46012
46022
|
var DISCOVERY_CATEGORIES = [...CALLABLE_CATEGORIES, "other"];
|
|
46013
|
-
var discoveryCategorySchema = external_exports.
|
|
46023
|
+
var discoveryCategorySchema = external_exports.string().trim().min(1);
|
|
46014
46024
|
var CALLABLE_CATEGORY_SET = new Set(CALLABLE_CATEGORIES);
|
|
46015
|
-
var serviceTierSchema = external_exports.
|
|
46025
|
+
var serviceTierSchema = external_exports.string().trim().min(1);
|
|
46016
46026
|
var discoveryEndpointSchema = external_exports.looseObject({
|
|
46017
46027
|
name: external_exports.string(),
|
|
46018
46028
|
method: external_exports.string(),
|
|
@@ -46042,6 +46052,24 @@ var discoveryEndpointSchema = external_exports.looseObject({
|
|
|
46042
46052
|
asset: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
|
|
46043
46053
|
payTo: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
|
|
46044
46054
|
checkedAt: external_exports.iso.datetime()
|
|
46055
|
+
}),
|
|
46056
|
+
external_exports.looseObject({
|
|
46057
|
+
protocol: external_exports.literal("mpp"),
|
|
46058
|
+
intent: external_exports.enum(["charge", "authorize", "subscription"]).nullable(),
|
|
46059
|
+
method: external_exports.string().trim().min(1).max(40).nullable(),
|
|
46060
|
+
checkedAt: external_exports.iso.datetime(),
|
|
46061
|
+
// Keep common x402 properties readable on the union while making it
|
|
46062
|
+
// impossible for MPP metadata to masquerade as executable x402 terms.
|
|
46063
|
+
network: external_exports.never().optional(),
|
|
46064
|
+
payTo: external_exports.never().optional()
|
|
46065
|
+
}),
|
|
46066
|
+
external_exports.looseObject({
|
|
46067
|
+
// Future payment protocols remain visible to callers so the payment
|
|
46068
|
+
// layer can refuse them explicitly instead of discovery losing the row.
|
|
46069
|
+
protocol: external_exports.string().trim().min(1).max(40),
|
|
46070
|
+
checkedAt: external_exports.iso.datetime(),
|
|
46071
|
+
network: external_exports.never().optional(),
|
|
46072
|
+
payTo: external_exports.never().optional()
|
|
46045
46073
|
})
|
|
46046
46074
|
]).optional()
|
|
46047
46075
|
});
|
|
@@ -46135,7 +46163,7 @@ function resolveTarget(service, endpointName) {
|
|
|
46135
46163
|
}
|
|
46136
46164
|
if (targets.size !== 1) {
|
|
46137
46165
|
const paymentNetworks = service.endpoints.flatMap(
|
|
46138
|
-
(endpoint) => endpoint.payment ? [endpoint.payment.network] : []
|
|
46166
|
+
(endpoint) => typeof endpoint.payment?.network === "string" ? [endpoint.payment.network] : []
|
|
46139
46167
|
);
|
|
46140
46168
|
throw new DiscoveryCatalogError(
|
|
46141
46169
|
"ambiguous_default",
|
|
@@ -47110,7 +47138,8 @@ function getVapiPaths(directory = process.env.VAPI_HOME?.trim() || join2(homedir
|
|
|
47110
47138
|
keystore: join2(directory, "keystore.json"),
|
|
47111
47139
|
receipts: join2(directory, "receipts.jsonl"),
|
|
47112
47140
|
searches: join2(directory, "searches.jsonl"),
|
|
47113
|
-
ledger: join2(directory, "spend-ledger.json")
|
|
47141
|
+
ledger: join2(directory, "spend-ledger.json"),
|
|
47142
|
+
updateCheck: join2(directory, "update-check.json")
|
|
47114
47143
|
};
|
|
47115
47144
|
}
|
|
47116
47145
|
var getAgentCashPaths = getVapiPaths;
|
|
@@ -70374,7 +70403,7 @@ function windowsDataProtectionStore(platform2, run, env, installed) {
|
|
|
70374
70403
|
};
|
|
70375
70404
|
}
|
|
70376
70405
|
function libsecretStore(platform2, run, installed) {
|
|
70377
|
-
const
|
|
70406
|
+
const lookup2 = async (name) => {
|
|
70378
70407
|
const result = await run(SECRET_TOOL_BINARY, [
|
|
70379
70408
|
"lookup",
|
|
70380
70409
|
"service",
|
|
@@ -70393,9 +70422,9 @@ function libsecretStore(platform2, run, installed) {
|
|
|
70393
70422
|
available: installed(SECRET_TOOL_BINARY),
|
|
70394
70423
|
platform: platform2,
|
|
70395
70424
|
description: "the libsecret keyring",
|
|
70396
|
-
get:
|
|
70425
|
+
get: lookup2,
|
|
70397
70426
|
async has(name) {
|
|
70398
|
-
return await
|
|
70427
|
+
return await lookup2(name) !== void 0;
|
|
70399
70428
|
},
|
|
70400
70429
|
async set(name, passphrase) {
|
|
70401
70430
|
requirePassphrase(passphrase);
|
|
@@ -70417,7 +70446,7 @@ function libsecretStore(platform2, run, installed) {
|
|
|
70417
70446
|
requireSuccess(result, `store the passphrase of ${name} in the secret service`);
|
|
70418
70447
|
},
|
|
70419
70448
|
async remove(name) {
|
|
70420
|
-
const existed = await
|
|
70449
|
+
const existed = await lookup2(name) !== void 0;
|
|
70421
70450
|
const result = await run(SECRET_TOOL_BINARY, [
|
|
70422
70451
|
"clear",
|
|
70423
70452
|
"service",
|
|
@@ -71480,6 +71509,8 @@ var VAULT_KEY_ACCOUNT = "vault-key";
|
|
|
71480
71509
|
var VAULT_SESSION_ACCOUNT = "vault-session";
|
|
71481
71510
|
var DEVICE_KEY_LENGTH = 32;
|
|
71482
71511
|
var DEFAULT_SESSION_HOURS = 8;
|
|
71512
|
+
var RESTORE_GAP_LIMIT = 5;
|
|
71513
|
+
var MAX_RESTORE_ACCOUNTS = 1e4;
|
|
71483
71514
|
var BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;
|
|
71484
71515
|
var deviceKeyOperations = Promise.resolve();
|
|
71485
71516
|
var sessionSchema = external_exports.object({
|
|
@@ -71629,26 +71660,41 @@ async function restoreVault(args) {
|
|
|
71629
71660
|
throw new VaultError("corrupt", "That recovery phrase is not valid.", { cause: error61 });
|
|
71630
71661
|
}
|
|
71631
71662
|
let seed;
|
|
71632
|
-
|
|
71663
|
+
if (args.accountCount !== void 0 && (!Number.isSafeInteger(args.accountCount) || args.accountCount < 1 || args.accountCount > MAX_RESTORE_ACCOUNTS)) {
|
|
71664
|
+
throw new VaultError(
|
|
71665
|
+
"corrupt",
|
|
71666
|
+
`Account count must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
71667
|
+
);
|
|
71668
|
+
}
|
|
71669
|
+
let discoveredAccounts = args.accountCount ?? 0;
|
|
71670
|
+
let scannedAddresses = 0;
|
|
71633
71671
|
try {
|
|
71634
71672
|
seed = phraseToSeed(phrase);
|
|
71635
71673
|
} catch (error61) {
|
|
71636
71674
|
throw asVaultError2(error61, "Unable to derive an account while restoring the vault.");
|
|
71637
71675
|
}
|
|
71638
71676
|
try {
|
|
71639
|
-
for (let index2 = 0; ; index2 += 1) {
|
|
71677
|
+
for (let index2 = 0, emptyRun = 0; args.accountCount === void 0; index2 += 1) {
|
|
71640
71678
|
let address4;
|
|
71641
71679
|
try {
|
|
71642
71680
|
address4 = privateKeyToAccount(deriveEvmPrivateKey(seed, `m/44'/60'/0'/0/${index2}`)).address;
|
|
71643
71681
|
} catch (error61) {
|
|
71644
71682
|
throw asVaultError2(error61, "Unable to derive an account while restoring the vault.");
|
|
71645
71683
|
}
|
|
71646
|
-
|
|
71647
|
-
|
|
71684
|
+
const funded = await args.probe(address4);
|
|
71685
|
+
scannedAddresses += 1;
|
|
71686
|
+
if (funded) {
|
|
71687
|
+
discoveredAccounts = index2 + 1;
|
|
71688
|
+
emptyRun = 0;
|
|
71689
|
+
} else {
|
|
71690
|
+
emptyRun += 1;
|
|
71691
|
+
if (emptyRun === RESTORE_GAP_LIMIT) break;
|
|
71692
|
+
}
|
|
71648
71693
|
}
|
|
71649
71694
|
} finally {
|
|
71650
71695
|
seed.fill(0);
|
|
71651
71696
|
}
|
|
71697
|
+
args.onScanComplete?.(scannedAddresses);
|
|
71652
71698
|
let vault;
|
|
71653
71699
|
try {
|
|
71654
71700
|
vault = await createVault({ path: args.path, key: args.key, phrase, now: args.now });
|
|
@@ -72137,6 +72183,26 @@ var WalletStore = class _WalletStore {
|
|
|
72137
72183
|
}
|
|
72138
72184
|
);
|
|
72139
72185
|
}
|
|
72186
|
+
/** Checks a cached signer's current vault session without decrypting its account again. */
|
|
72187
|
+
async assertSigningAuthority(name) {
|
|
72188
|
+
const stored = await this.readVaultUnlocked();
|
|
72189
|
+
if (!stored?.protected || !stored.accounts.some((account) => account.name === name)) return;
|
|
72190
|
+
try {
|
|
72191
|
+
const key2 = await unlockProtectedVault({
|
|
72192
|
+
path: this.vaultPath,
|
|
72193
|
+
secrets: this.secrets,
|
|
72194
|
+
env: this.environment,
|
|
72195
|
+
now: () => this.now()
|
|
72196
|
+
});
|
|
72197
|
+
key2.fill(0);
|
|
72198
|
+
} catch (error61) {
|
|
72199
|
+
this.dropVaultCache();
|
|
72200
|
+
if (error61 instanceof VaultError && error61.code === "password_required") {
|
|
72201
|
+
throw new KeystoreError(VAULT_LOCKED_MESSAGE, { cause: error61 });
|
|
72202
|
+
}
|
|
72203
|
+
throw error61;
|
|
72204
|
+
}
|
|
72205
|
+
}
|
|
72140
72206
|
/** Returns one wallet's vault signer, migrating its legacy keystore if needed. */
|
|
72141
72207
|
async unlock(name, passphrase) {
|
|
72142
72208
|
const wallet = this.resolve({ name });
|
|
@@ -77523,7 +77589,7 @@ function createRunBudget(args) {
|
|
|
77523
77589
|
import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
|
|
77524
77590
|
import { arch, platform, release } from "node:os";
|
|
77525
77591
|
import { join as join13 } from "node:path";
|
|
77526
|
-
var VAPI_CLIENT_VERSION = "0.9.
|
|
77592
|
+
var VAPI_CLIENT_VERSION = "0.9.4";
|
|
77527
77593
|
async function createSupportReport(options) {
|
|
77528
77594
|
const message = options.message.trim();
|
|
77529
77595
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -77796,7 +77862,7 @@ async function completeX402Payment(args) {
|
|
|
77796
77862
|
let paidAttempt;
|
|
77797
77863
|
const requestStarted = nowMs();
|
|
77798
77864
|
try {
|
|
77799
|
-
paidAttempt = await args.send(paidRequest);
|
|
77865
|
+
paidAttempt = await args.send(paidRequest, quote);
|
|
77800
77866
|
} catch (error61) {
|
|
77801
77867
|
if (trace) trace.phases.requestMs = elapsed(nowMs, requestStarted);
|
|
77802
77868
|
throw settlementUnknown(
|
|
@@ -77814,7 +77880,7 @@ async function completeX402Payment(args) {
|
|
|
77814
77880
|
const settleStarted = nowMs();
|
|
77815
77881
|
const settlement = parseSettlementResponse(paidResponse.headers);
|
|
77816
77882
|
const settlementOutcome = classifySettlement(settlement);
|
|
77817
|
-
const receiptSettlement =
|
|
77883
|
+
const receiptSettlement = sanitizeReturnedValue(settlement, receiptSecrets);
|
|
77818
77884
|
if (trace) {
|
|
77819
77885
|
const transaction2 = settlementTransaction(receiptSettlement);
|
|
77820
77886
|
const explorerUrl = transaction2 ? explorerTransactionUrl(quote.accepted.network, transaction2) : void 0;
|
|
@@ -77891,6 +77957,7 @@ async function completeX402Payment(args) {
|
|
|
77891
77957
|
trace.phases.requestMs = (trace.phases.requestMs ?? 0) + elapsed(nowMs, bodyStarted);
|
|
77892
77958
|
}
|
|
77893
77959
|
}
|
|
77960
|
+
body = sanitizeReturnedValue(body, receiptSecrets);
|
|
77894
77961
|
}
|
|
77895
77962
|
const result = {
|
|
77896
77963
|
response: paidResponse,
|
|
@@ -77899,7 +77966,11 @@ async function completeX402Payment(args) {
|
|
|
77899
77966
|
quote,
|
|
77900
77967
|
payer,
|
|
77901
77968
|
...payment.paymentId ? { paymentId: payment.paymentId } : {},
|
|
77902
|
-
|
|
77969
|
+
paymentProof: sanitizeReturnedValue(
|
|
77970
|
+
paidResponse.headers.get("x-vapi-payment-proof"),
|
|
77971
|
+
receiptSecrets
|
|
77972
|
+
),
|
|
77973
|
+
settlement: receiptSettlement,
|
|
77903
77974
|
settlementOutcome
|
|
77904
77975
|
};
|
|
77905
77976
|
if (settlementOutcome === "succeeded" && args.ceilingSweep) {
|
|
@@ -78036,19 +78107,70 @@ function sanitizeThrownError(error61, secrets) {
|
|
|
78036
78107
|
}
|
|
78037
78108
|
return new Error(message, cause === void 0 ? void 0 : { cause });
|
|
78038
78109
|
}
|
|
78039
|
-
function
|
|
78110
|
+
function sanitizeReturnedValue(value, secrets) {
|
|
78040
78111
|
if (typeof value === "string") return redactKnownSecrets(value, secrets);
|
|
78041
|
-
if (value
|
|
78042
|
-
|
|
78043
|
-
|
|
78044
|
-
|
|
78112
|
+
if (!isPlainReturnedContainer(value)) return value;
|
|
78113
|
+
const nodes = /* @__PURE__ */ new WeakMap();
|
|
78114
|
+
const ordered = [];
|
|
78115
|
+
const nodeFor = (source) => {
|
|
78116
|
+
const existing = nodes.get(source);
|
|
78117
|
+
if (existing) return existing;
|
|
78118
|
+
const copy = Array.isArray(source) ? new Array(source.length) : Object.create(Object.getPrototypeOf(source));
|
|
78119
|
+
const node2 = { source, copy, parents: /* @__PURE__ */ new Set(), changed: false };
|
|
78120
|
+
nodes.set(source, node2);
|
|
78121
|
+
ordered.push(node2);
|
|
78122
|
+
return node2;
|
|
78123
|
+
};
|
|
78124
|
+
const root = nodeFor(value);
|
|
78125
|
+
for (let index2 = 0; index2 < ordered.length; index2 += 1) {
|
|
78126
|
+
const node2 = ordered[index2];
|
|
78127
|
+
for (const [key2, item] of Object.entries(node2.source)) {
|
|
78128
|
+
const safeKey = Array.isArray(node2.source) ? key2 : redactKnownSecrets(key2, secrets);
|
|
78129
|
+
if (safeKey !== key2) node2.changed = true;
|
|
78130
|
+
if (typeof item === "string") {
|
|
78131
|
+
const safeItem = redactKnownSecrets(item, secrets);
|
|
78132
|
+
defineReturnedProperty(node2.copy, safeKey, safeItem);
|
|
78133
|
+
if (safeItem !== item) node2.changed = true;
|
|
78134
|
+
} else if (isPlainReturnedContainer(item)) {
|
|
78135
|
+
const child = nodeFor(item);
|
|
78136
|
+
child.parents.add(node2);
|
|
78137
|
+
defineReturnedProperty(node2.copy, safeKey, child.copy);
|
|
78138
|
+
} else {
|
|
78139
|
+
defineReturnedProperty(node2.copy, safeKey, item);
|
|
78140
|
+
}
|
|
78141
|
+
}
|
|
78045
78142
|
}
|
|
78046
|
-
|
|
78047
|
-
|
|
78048
|
-
|
|
78049
|
-
|
|
78050
|
-
|
|
78051
|
-
|
|
78143
|
+
const changed = ordered.filter((node2) => node2.changed);
|
|
78144
|
+
for (let index2 = 0; index2 < changed.length; index2 += 1) {
|
|
78145
|
+
for (const parent of changed[index2].parents) {
|
|
78146
|
+
if (parent.changed) continue;
|
|
78147
|
+
parent.changed = true;
|
|
78148
|
+
changed.push(parent);
|
|
78149
|
+
}
|
|
78150
|
+
}
|
|
78151
|
+
for (const node2 of ordered) {
|
|
78152
|
+
for (const [key2, item] of Object.entries(node2.source)) {
|
|
78153
|
+
if (!isPlainReturnedContainer(item)) continue;
|
|
78154
|
+
const safeKey = Array.isArray(node2.source) ? key2 : redactKnownSecrets(key2, secrets);
|
|
78155
|
+
const child = nodes.get(item);
|
|
78156
|
+
defineReturnedProperty(node2.copy, safeKey, child.changed ? child.copy : item);
|
|
78157
|
+
}
|
|
78158
|
+
}
|
|
78159
|
+
return root.changed ? root.copy : value;
|
|
78160
|
+
}
|
|
78161
|
+
function defineReturnedProperty(target, key2, value) {
|
|
78162
|
+
Object.defineProperty(target, key2, {
|
|
78163
|
+
value,
|
|
78164
|
+
enumerable: true,
|
|
78165
|
+
configurable: true,
|
|
78166
|
+
writable: true
|
|
78167
|
+
});
|
|
78168
|
+
}
|
|
78169
|
+
function isPlainReturnedContainer(value) {
|
|
78170
|
+
if (Array.isArray(value)) return true;
|
|
78171
|
+
if (value === null || typeof value !== "object") return false;
|
|
78172
|
+
const prototype = Object.getPrototypeOf(value);
|
|
78173
|
+
return prototype === Object.prototype || prototype === null;
|
|
78052
78174
|
}
|
|
78053
78175
|
function redactKnownSecrets(value, secrets) {
|
|
78054
78176
|
let redacted = value;
|
|
@@ -78083,9 +78205,7 @@ function possibleSettlement(quote, payment, payer, receipt) {
|
|
|
78083
78205
|
payTo: quote.accepted.payTo,
|
|
78084
78206
|
payer,
|
|
78085
78207
|
...payment.paymentId ? { paymentId: payment.paymentId } : {},
|
|
78086
|
-
...isSvmPaymentRequirements(quote.accepted) ? {
|
|
78087
|
-
authorizationTransaction: "transaction" in payment.payload.payload ? payment.payload.payload.transaction : ""
|
|
78088
|
-
} : "authorization" in payment.payload.payload ? {
|
|
78208
|
+
...isSvmPaymentRequirements(quote.accepted) ? {} : "authorization" in payment.payload.payload ? {
|
|
78089
78209
|
authorizationNonce: payment.payload.payload.authorization.nonce,
|
|
78090
78210
|
authorizationExpiresAt: payment.payload.payload.authorization.validBefore
|
|
78091
78211
|
} : {},
|
|
@@ -78463,13 +78583,22 @@ async function sendRouterChat(deps, routerBaseUrl, routerKey, request, keyUsed)
|
|
|
78463
78583
|
}
|
|
78464
78584
|
const body = await responseText(response);
|
|
78465
78585
|
if (!response.ok) {
|
|
78466
|
-
if (
|
|
78586
|
+
if (/budget (?:has been )?exceeded|exceededbudget/iu.test(body)) {
|
|
78467
78587
|
throw new RouterClientError(
|
|
78468
78588
|
"budget_exhausted",
|
|
78469
78589
|
"The Router key has no remaining budget.",
|
|
78470
78590
|
response.status
|
|
78471
78591
|
);
|
|
78472
78592
|
}
|
|
78593
|
+
if (response.status === 429) {
|
|
78594
|
+
const retryAfter = response.headers.get("retry-after")?.trim();
|
|
78595
|
+
const retrySeconds = retryAfter !== void 0 && /^\d+$/u.test(retryAfter) ? Number(retryAfter) : void 0;
|
|
78596
|
+
throw new RouterClientError(
|
|
78597
|
+
"rate_limited",
|
|
78598
|
+
`The vAPI Router is rate limited. ${retrySeconds !== void 0 && Number.isFinite(retrySeconds) ? `Retry after ${retrySeconds} seconds.` : "Wait and retry shortly."}`,
|
|
78599
|
+
response.status
|
|
78600
|
+
);
|
|
78601
|
+
}
|
|
78473
78602
|
if (response.status === 401) {
|
|
78474
78603
|
throw new RouterClientError(
|
|
78475
78604
|
"no_router_key",
|
|
@@ -87746,12 +87875,13 @@ var BODY_HEADER_NAMES = [
|
|
|
87746
87875
|
"content-type"
|
|
87747
87876
|
];
|
|
87748
87877
|
async function callService(args) {
|
|
87878
|
+
validateTimeoutSeconds(args.input.timeoutSeconds);
|
|
87749
87879
|
const trace = createCallTrace(args);
|
|
87750
87880
|
let execution;
|
|
87751
87881
|
try {
|
|
87752
87882
|
execution = await executeCallService(args, trace);
|
|
87753
87883
|
} catch (error61) {
|
|
87754
|
-
if (!(error61 instanceof VapiCallError && error61.code === "unsupported_network")) {
|
|
87884
|
+
if (!(error61 instanceof VapiCallError && (error61.code === "unsupported_network" || error61.code === "unsupported_payment"))) {
|
|
87755
87885
|
await recordCallError(args, error61, trace).catch(() => void 0);
|
|
87756
87886
|
}
|
|
87757
87887
|
throw error61;
|
|
@@ -87865,6 +87995,8 @@ async function executeCallService(args, trace) {
|
|
|
87865
87995
|
body: method === "GET" || method === "HEAD" ? void 0 : requestBody
|
|
87866
87996
|
});
|
|
87867
87997
|
const request = createRequest(headers);
|
|
87998
|
+
const probeTimeoutMs = input2.timeoutSeconds === void 0 ? args.timeoutMs ?? 3e4 : Math.min(input2.timeoutSeconds, 30) * 1e3;
|
|
87999
|
+
let requestTimeoutMs = probeTimeoutMs;
|
|
87868
88000
|
const fetchWithGuardedRedirects = async (candidateRequest, followRedirects = true) => {
|
|
87869
88001
|
let currentRequest = candidateRequest;
|
|
87870
88002
|
let followedRedirects = 0;
|
|
@@ -87872,7 +88004,7 @@ async function executeCallService(args, trace) {
|
|
|
87872
88004
|
const attempt = await fetchAttempt(
|
|
87873
88005
|
fetchImpl,
|
|
87874
88006
|
new Request(currentRequest.clone(), { redirect: "manual" }),
|
|
87875
|
-
|
|
88007
|
+
requestTimeoutMs
|
|
87876
88008
|
);
|
|
87877
88009
|
const response = attempt.response;
|
|
87878
88010
|
if (!isRedirectStatus2(response.status)) {
|
|
@@ -88027,7 +88159,12 @@ async function executeCallService(args, trace) {
|
|
|
88027
88159
|
account,
|
|
88028
88160
|
caps: args.spendCaps ?? config2.spendCaps,
|
|
88029
88161
|
config: payableConfig(config2, account),
|
|
88030
|
-
send: async (paidRequest) => {
|
|
88162
|
+
send: async (paidRequest, quote) => {
|
|
88163
|
+
requestTimeoutMs = paidRequestTimeoutMs(
|
|
88164
|
+
input2.timeoutSeconds,
|
|
88165
|
+
args.timeoutMs,
|
|
88166
|
+
quote.accepted.maxTimeoutSeconds
|
|
88167
|
+
);
|
|
88031
88168
|
paidAttempt = await fetchWithGuardedRedirects(paidRequest, false);
|
|
88032
88169
|
return paidAttempt;
|
|
88033
88170
|
},
|
|
@@ -88066,7 +88203,7 @@ async function executeCallService(args, trace) {
|
|
|
88066
88203
|
asset: completed.quote.accepted.asset,
|
|
88067
88204
|
payTo: completed.quote.accepted.payTo,
|
|
88068
88205
|
settlement: settlementWithExplorer2(completed.settlement, completed.quote.accepted.network),
|
|
88069
|
-
proof: completed.
|
|
88206
|
+
proof: completed.paymentProof
|
|
88070
88207
|
},
|
|
88071
88208
|
...verificationFor(endpoint),
|
|
88072
88209
|
...expectedRequestFor(endpoint, completed.response.status)
|
|
@@ -88313,8 +88450,16 @@ async function resolveCallEndpoint(id2, endpointName, marketplaceHit, config2, f
|
|
|
88313
88450
|
);
|
|
88314
88451
|
}
|
|
88315
88452
|
function registeredEndpoint(listing, verification) {
|
|
88453
|
+
const { payment, ...endpoint } = listing.endpoint;
|
|
88454
|
+
if (payment && (typeof payment.protocol === "string" || typeof payment.network !== "string")) {
|
|
88455
|
+
throw new VapiCallError(
|
|
88456
|
+
"unsupported_payment",
|
|
88457
|
+
`Payment protocol ${payment.protocol} is not supported. This client pays x402 exact USDC endpoints only.`
|
|
88458
|
+
);
|
|
88459
|
+
}
|
|
88316
88460
|
return {
|
|
88317
|
-
...
|
|
88461
|
+
...endpoint,
|
|
88462
|
+
...payment ? { payment: { network: payment.network, payTo: payment.payTo } } : {},
|
|
88318
88463
|
verification: verification ?? listing.service.verification,
|
|
88319
88464
|
serviceNetworks: listing.service.networks,
|
|
88320
88465
|
registered: true,
|
|
@@ -88476,7 +88621,7 @@ async function readResponseBody2(response) {
|
|
|
88476
88621
|
async function fetchAttempt(fetchImpl, request, timeoutMs) {
|
|
88477
88622
|
const controller = new AbortController();
|
|
88478
88623
|
let rejectTimeout = null;
|
|
88479
|
-
const timeoutError = new Error(`API request timed out after ${timeoutMs}
|
|
88624
|
+
const timeoutError = new Error(`API request timed out after ${timeoutMs / 1e3} seconds.`);
|
|
88480
88625
|
const timedOut = new Promise((_resolve, reject) => {
|
|
88481
88626
|
rejectTimeout = reject;
|
|
88482
88627
|
});
|
|
@@ -88516,6 +88661,19 @@ async function fetchAttempt(fetchImpl, request, timeoutMs) {
|
|
|
88516
88661
|
throw error61;
|
|
88517
88662
|
}
|
|
88518
88663
|
}
|
|
88664
|
+
function validateTimeoutSeconds(timeoutSeconds) {
|
|
88665
|
+
if (timeoutSeconds !== void 0 && (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1 || timeoutSeconds > 300)) {
|
|
88666
|
+
throw new Error("call timeoutSeconds must be an integer from 1 to 300 seconds.");
|
|
88667
|
+
}
|
|
88668
|
+
}
|
|
88669
|
+
function paidRequestTimeoutMs(timeoutSeconds, internalTimeoutMs, offerTimeoutSeconds) {
|
|
88670
|
+
const usableOfferTimeout = Number.isInteger(offerTimeoutSeconds) && offerTimeoutSeconds > 0 ? offerTimeoutSeconds : void 0;
|
|
88671
|
+
if (timeoutSeconds !== void 0) {
|
|
88672
|
+
return Math.min(timeoutSeconds, usableOfferTimeout ?? timeoutSeconds) * 1e3;
|
|
88673
|
+
}
|
|
88674
|
+
if (internalTimeoutMs !== void 0) return internalTimeoutMs;
|
|
88675
|
+
return usableOfferTimeout === void 0 ? 12e4 : Math.min(12e4, Math.max(3e4, usableOfferTimeout * 1e3));
|
|
88676
|
+
}
|
|
88519
88677
|
function mapX402PaymentError(error61, resumeId) {
|
|
88520
88678
|
if (!(error61 instanceof X402PaymentError)) return error61;
|
|
88521
88679
|
if (error61.code === "payment_rejected") {
|
|
@@ -88531,9 +88689,10 @@ function mapX402PaymentError(error61, resumeId) {
|
|
|
88531
88689
|
});
|
|
88532
88690
|
}
|
|
88533
88691
|
const resume = resumeId !== void 0 && error61.possibleSettlement?.authorizationNonce ? ` Check whether it settled with \`vapi pay --resume ${resumeId}\` before paying again.` : "";
|
|
88692
|
+
const timeoutDetail = error61.cause instanceof Error && error61.cause.message.startsWith("API request timed out after ") ? `${error61.cause.message} ` : "";
|
|
88534
88693
|
return new VapiCallError(
|
|
88535
88694
|
"settlement_unknown",
|
|
88536
|
-
`${error61.message}${resume}`,
|
|
88695
|
+
`${timeoutDetail}${error61.message}${resume}`,
|
|
88537
88696
|
error61.possibleSettlement,
|
|
88538
88697
|
{ cause: error61.cause }
|
|
88539
88698
|
);
|
|
@@ -88665,13 +88824,7 @@ var inspectToolResultSchema = external_exports.object({
|
|
|
88665
88824
|
liveness: listingLivenessSchema.optional(),
|
|
88666
88825
|
conformance: listingConformanceSchema.optional(),
|
|
88667
88826
|
identity: listingIdentitySchema.optional(),
|
|
88668
|
-
payment:
|
|
88669
|
-
scheme: external_exports.literal("exact"),
|
|
88670
|
-
network: external_exports.string(),
|
|
88671
|
-
asset: external_exports.string(),
|
|
88672
|
-
payTo: external_exports.string(),
|
|
88673
|
-
checkedAt: external_exports.string()
|
|
88674
|
-
}).nullable()
|
|
88827
|
+
payment: discoveryEndpointSchema.shape.payment.unwrap().nullable()
|
|
88675
88828
|
});
|
|
88676
88829
|
var callSearchInputSchema = external_exports.object({
|
|
88677
88830
|
query: external_exports.string().trim().max(200).optional().describe("Capability, API, service, or request."),
|
|
@@ -88700,7 +88853,10 @@ var callPayInputSchema = external_exports.object({
|
|
|
88700
88853
|
(value) => /^0x[0-9a-fA-F]{40}$/.test(value) || isSolanaAddress(value),
|
|
88701
88854
|
"Expected an EVM or Solana address."
|
|
88702
88855
|
).optional(),
|
|
88703
|
-
maxPriceUsd: external_exports.union([external_exports.number().nonnegative(), external_exports.string().regex(/^\d+(?:\.\d{1,6})?$/)]).optional()
|
|
88856
|
+
maxPriceUsd: external_exports.union([external_exports.number().nonnegative(), external_exports.string().regex(/^\d+(?:\.\d{1,6})?$/)]).optional(),
|
|
88857
|
+
timeoutSeconds: external_exports.number().int().min(1).max(300).optional().describe(
|
|
88858
|
+
"Seconds to wait for the paid response. Default: the provider's maxTimeoutSeconds, at most 120."
|
|
88859
|
+
)
|
|
88704
88860
|
});
|
|
88705
88861
|
var callSearch = defineAction({
|
|
88706
88862
|
name: "call.search",
|
|
@@ -88963,7 +89119,7 @@ async function readResult(response, signal, secrets = []) {
|
|
|
88963
89119
|
return {
|
|
88964
89120
|
status: response.status,
|
|
88965
89121
|
contentType: contentType === null ? null : redactKnownSecrets2(contentType, secrets),
|
|
88966
|
-
body:
|
|
89122
|
+
body: sanitizeReturnedValue2(await readResponseBody3(response, contentType, signal), secrets)
|
|
88967
89123
|
};
|
|
88968
89124
|
}
|
|
88969
89125
|
async function readResponseBody3(response, contentType, signal) {
|
|
@@ -89008,17 +89164,17 @@ function isJsonContentType2(value) {
|
|
|
89008
89164
|
const mediaType = value?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
89009
89165
|
return mediaType === "application/json" || mediaType.endsWith("+json");
|
|
89010
89166
|
}
|
|
89011
|
-
function
|
|
89167
|
+
function sanitizeReturnedValue2(value, secrets, depth = 0) {
|
|
89012
89168
|
if (typeof value === "string") return redactKnownSecrets2(value, secrets);
|
|
89013
89169
|
if (value === null || typeof value !== "object") return value;
|
|
89014
89170
|
if (depth >= 16) return "[redacted nested response value]";
|
|
89015
89171
|
if (Array.isArray(value)) {
|
|
89016
|
-
return value.map((item) =>
|
|
89172
|
+
return value.map((item) => sanitizeReturnedValue2(item, secrets, depth + 1));
|
|
89017
89173
|
}
|
|
89018
89174
|
return Object.fromEntries(
|
|
89019
89175
|
Object.entries(value).map(([key2, item]) => [
|
|
89020
89176
|
redactKnownSecrets2(key2, secrets),
|
|
89021
|
-
|
|
89177
|
+
sanitizeReturnedValue2(item, secrets, depth + 1)
|
|
89022
89178
|
])
|
|
89023
89179
|
);
|
|
89024
89180
|
}
|
|
@@ -94524,7 +94680,13 @@ function toolError(error61) {
|
|
|
94524
94680
|
{
|
|
94525
94681
|
error: error61.message,
|
|
94526
94682
|
code: error61.code,
|
|
94527
|
-
...error61.possibleSettlement ? {
|
|
94683
|
+
...error61.possibleSettlement ? {
|
|
94684
|
+
possibleSettlement: Object.fromEntries(
|
|
94685
|
+
Object.entries(error61.possibleSettlement).filter(
|
|
94686
|
+
([key2]) => key2 !== "authorizationTransaction"
|
|
94687
|
+
)
|
|
94688
|
+
)
|
|
94689
|
+
} : {},
|
|
94528
94690
|
...error61.paymentRejection ? { paymentRejection: error61.paymentRejection } : {},
|
|
94529
94691
|
...error61.confirmedSettlement ? { confirmedSettlement: error61.confirmedSettlement } : {}
|
|
94530
94692
|
},
|
|
@@ -98018,7 +98180,7 @@ async function readProcessStdin() {
|
|
|
98018
98180
|
}
|
|
98019
98181
|
|
|
98020
98182
|
// ../cli/src/version.ts
|
|
98021
|
-
var CLI_VERSION = "0.9.
|
|
98183
|
+
var CLI_VERSION = "0.9.4";
|
|
98022
98184
|
|
|
98023
98185
|
// ../cli/src/status.ts
|
|
98024
98186
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -101520,7 +101682,7 @@ function createLocalRuntime(options) {
|
|
|
101520
101682
|
const processCommand = options.processCommand ?? defaultProcessCommand;
|
|
101521
101683
|
const ownsProcess = (handle, pid) => processCommand(pid)?.includes(runResultPath(home, handle.runId)) === true;
|
|
101522
101684
|
const closeFd = options.closeFd ?? closeSync2;
|
|
101523
|
-
const
|
|
101685
|
+
const readFile30 = options.readFile ?? nodeReadFile;
|
|
101524
101686
|
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
101525
101687
|
const openLog = options.openLog ?? ((path) => {
|
|
101526
101688
|
mkdirSync2(runsDirectory(home), { recursive: true, mode: 448 });
|
|
@@ -101575,7 +101737,7 @@ function createLocalRuntime(options) {
|
|
|
101575
101737
|
return handle;
|
|
101576
101738
|
},
|
|
101577
101739
|
async status(handle) {
|
|
101578
|
-
const result = await readResultFile(
|
|
101740
|
+
const result = await readResultFile(readFile30, runResultPath(home, handle.runId));
|
|
101579
101741
|
if (result !== void 0) return result;
|
|
101580
101742
|
const pid = localPid(handle);
|
|
101581
101743
|
if (pid === void 0 || handle.kind !== "local") {
|
|
@@ -101678,10 +101840,10 @@ function childArguments(member, run) {
|
|
|
101678
101840
|
...run.drawUsd ? ["--draw", run.drawUsd] : []
|
|
101679
101841
|
];
|
|
101680
101842
|
}
|
|
101681
|
-
async function readResultFile(
|
|
101843
|
+
async function readResultFile(readFile30, path) {
|
|
101682
101844
|
let text;
|
|
101683
101845
|
try {
|
|
101684
|
-
text = await
|
|
101846
|
+
text = await readFile30(path, "utf8");
|
|
101685
101847
|
} catch (error61) {
|
|
101686
101848
|
if (hasCode3(error61, "ENOENT")) return void 0;
|
|
101687
101849
|
return { state: "failed", detail: "unreadable result file" };
|
|
@@ -102531,7 +102693,7 @@ function isMcpInstallApp(value) {
|
|
|
102531
102693
|
function serverEntry(home, registry2) {
|
|
102532
102694
|
return {
|
|
102533
102695
|
command: "npx",
|
|
102534
|
-
args: ["-y", "vapi-network", "mcp"],
|
|
102696
|
+
args: ["-y", "vapi-network@latest", "mcp"],
|
|
102535
102697
|
env: { VAPI_HOME: home, VAPI_REGISTRY_URL: registry2 }
|
|
102536
102698
|
};
|
|
102537
102699
|
}
|
|
@@ -102580,7 +102742,7 @@ function tomlConfig(existing, entry) {
|
|
|
102580
102742
|
const block = [
|
|
102581
102743
|
"[mcp_servers.vapi]",
|
|
102582
102744
|
'command = "npx"',
|
|
102583
|
-
'args = ["-y", "vapi-network", "mcp"]',
|
|
102745
|
+
'args = ["-y", "vapi-network@latest", "mcp"]',
|
|
102584
102746
|
`env = { VAPI_HOME = "${escapeToml(entry.env.VAPI_HOME)}", VAPI_REGISTRY_URL = "${escapeToml(entry.env.VAPI_REGISTRY_URL)}" }`,
|
|
102585
102747
|
""
|
|
102586
102748
|
].join("\n");
|
|
@@ -102747,13 +102909,13 @@ async function sendConfig(dependencies) {
|
|
|
102747
102909
|
// ../cli/src/setup.ts
|
|
102748
102910
|
import { rm as rm5 } from "node:fs/promises";
|
|
102749
102911
|
import { join as join26 } from "node:path";
|
|
102750
|
-
var SETUP_ARGUMENT_ERROR =
|
|
102912
|
+
var SETUP_ARGUMENT_ERROR = `vapi setup accepts only --no-cloud-backup and --accounts <n> (1-${MAX_RESTORE_ACCOUNTS}); a recovery phrase is typed at the prompt, never passed on the command line.`;
|
|
102751
102913
|
var VAULT_CHOICE = "Create a new vault, or restore one from a recovery phrase? [new/restore] ";
|
|
102752
102914
|
async function setupCommand(argv, json2, io, dependencies) {
|
|
102753
102915
|
let parsed;
|
|
102754
102916
|
try {
|
|
102755
102917
|
parsed = parseArguments(argv, {
|
|
102756
|
-
valueOptions: /* @__PURE__ */ new Set(),
|
|
102918
|
+
valueOptions: /* @__PURE__ */ new Set(["--accounts"]),
|
|
102757
102919
|
booleanOptions: /* @__PURE__ */ new Set(["--no-cloud-backup"]),
|
|
102758
102920
|
maximumPositionals: 0
|
|
102759
102921
|
});
|
|
@@ -102764,6 +102926,7 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
102764
102926
|
const paths = getVapiPaths();
|
|
102765
102927
|
const steps = [];
|
|
102766
102928
|
const humanIo = json2 ? stderrIo(io) : io;
|
|
102929
|
+
const accountCount = parseAccountCount(parsed.one("--accounts"));
|
|
102767
102930
|
if (!await fileExists2(paths.config)) {
|
|
102768
102931
|
await writeDefaultConfig(paths.config, process.env, { networks: ["base"] });
|
|
102769
102932
|
steps.push("config");
|
|
@@ -102774,6 +102937,7 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
102774
102937
|
let changedVault = false;
|
|
102775
102938
|
let changedAccount = false;
|
|
102776
102939
|
let changedLink = false;
|
|
102940
|
+
let scannedAddresses;
|
|
102777
102941
|
if (!await fileExists2(join26(paths.directory, "vault.json"))) {
|
|
102778
102942
|
const choice = await vaultChoice(dependencies);
|
|
102779
102943
|
if (choice === "restore") {
|
|
@@ -102781,12 +102945,14 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
102781
102945
|
throw new Error("Restoring needs a terminal to type the phrase.");
|
|
102782
102946
|
}
|
|
102783
102947
|
const readSecret = dependencies.prompts?.secret ?? promptForSecret;
|
|
102784
|
-
await restoreVaultFromPhrase(
|
|
102948
|
+
const restored = await restoreVaultFromPhrase(
|
|
102785
102949
|
await readSecret("Recovery phrase: "),
|
|
102786
102950
|
config2,
|
|
102787
102951
|
humanIo,
|
|
102788
|
-
dependencies
|
|
102952
|
+
dependencies,
|
|
102953
|
+
accountCount
|
|
102789
102954
|
);
|
|
102955
|
+
scannedAddresses = restored.scannedAddresses;
|
|
102790
102956
|
store = await WalletStore.open(paths.directory, {
|
|
102791
102957
|
secrets: getSecretStore(dependencies),
|
|
102792
102958
|
env: dependencies.env ?? process.env,
|
|
@@ -102839,22 +103005,35 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
102839
103005
|
}
|
|
102840
103006
|
if (json2) {
|
|
102841
103007
|
io.stdout(
|
|
102842
|
-
JSON.stringify({
|
|
103008
|
+
JSON.stringify({
|
|
103009
|
+
vault,
|
|
103010
|
+
account,
|
|
103011
|
+
address: address4,
|
|
103012
|
+
linked,
|
|
103013
|
+
steps,
|
|
103014
|
+
cloudBackup,
|
|
103015
|
+
...scannedAddresses === void 0 ? {} : { scannedAddresses }
|
|
103016
|
+
})
|
|
102843
103017
|
);
|
|
102844
103018
|
}
|
|
102845
103019
|
}
|
|
102846
|
-
async function restoreVaultFromPhrase(phrase, config2, io, dependencies) {
|
|
103020
|
+
async function restoreVaultFromPhrase(phrase, config2, io, dependencies, accountCount) {
|
|
102847
103021
|
const paths = getVapiPaths();
|
|
102848
103022
|
const validatedPhrase = validateRecoveryPhrase(phrase);
|
|
102849
103023
|
const readBalance3 = baseUsdcBalanceReader(config2, dependencies);
|
|
102850
103024
|
const key2 = await loadOrCreateDeviceKey({ secrets: getSecretStore(dependencies) });
|
|
102851
103025
|
let names;
|
|
103026
|
+
let scannedAddresses = 0;
|
|
102852
103027
|
try {
|
|
102853
103028
|
const restored = await restoreVault({
|
|
102854
103029
|
path: join26(paths.directory, "vault.json"),
|
|
102855
103030
|
key: key2,
|
|
102856
103031
|
phrase: validatedPhrase,
|
|
102857
103032
|
probe: async (address4) => await readBalance3(address4) > 0n,
|
|
103033
|
+
...accountCount === void 0 ? {} : { accountCount },
|
|
103034
|
+
onScanComplete: (count) => {
|
|
103035
|
+
scannedAddresses = count;
|
|
103036
|
+
},
|
|
102858
103037
|
...dependencies.now === void 0 ? {} : { now: dependencies.now }
|
|
102859
103038
|
});
|
|
102860
103039
|
names = restored.accounts().map((account) => account.name);
|
|
@@ -102866,8 +103045,25 @@ async function restoreVaultFromPhrase(phrase, config2, io, dependencies) {
|
|
|
102866
103045
|
...names[0] === void 0 ? {} : { wallet: names[0] },
|
|
102867
103046
|
detail: `${names.length} account(s)`
|
|
102868
103047
|
});
|
|
102869
|
-
io.stdout(
|
|
102870
|
-
|
|
103048
|
+
io.stdout(
|
|
103049
|
+
`Vault restored with ${names.length} account(s): ${names.join(", ")}. ${scannedAddresses} address(es) scanned.`
|
|
103050
|
+
);
|
|
103051
|
+
return { names, scannedAddresses };
|
|
103052
|
+
}
|
|
103053
|
+
function parseAccountCount(value) {
|
|
103054
|
+
if (value === void 0) return void 0;
|
|
103055
|
+
if (!/^\d+$/u.test(value)) {
|
|
103056
|
+
throw new UsageError(
|
|
103057
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
103058
|
+
);
|
|
103059
|
+
}
|
|
103060
|
+
const count = Number(value);
|
|
103061
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > MAX_RESTORE_ACCOUNTS) {
|
|
103062
|
+
throw new UsageError(
|
|
103063
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
103064
|
+
);
|
|
103065
|
+
}
|
|
103066
|
+
return count;
|
|
102871
103067
|
}
|
|
102872
103068
|
async function vaultChoice(dependencies) {
|
|
102873
103069
|
const answer = dependencies.prompts?.line === void 0 ? isInteractive(dependencies) ? await promptForLine(VAULT_CHOICE) : "" : await dependencies.prompts.line(VAULT_CHOICE);
|
|
@@ -104975,6 +105171,7 @@ async function referencedSleep(milliseconds, signal) {
|
|
|
104975
105171
|
// ../cli/src/vault.ts
|
|
104976
105172
|
import { join as join27 } from "node:path";
|
|
104977
105173
|
var VAULT_USAGE = "Usage: vapi vault protect|unprotect|lock|unlock|status [--json]";
|
|
105174
|
+
var RESTORE_USAGE = "Usage: vapi restore [--accounts <n> | --from-owner [--owner <0x\u2026>]] [--json]";
|
|
104978
105175
|
var LEGACY_PASSWORD_NOTICE = "VAPI_KEYSTORE_PASSWORD is deprecated for vault passwords; use VAPI_VAULT_PASSWORD instead.";
|
|
104979
105176
|
async function vaultCommand(argv, json2, io, dependencies) {
|
|
104980
105177
|
const subcommand = argv[0];
|
|
@@ -105004,9 +105201,17 @@ async function restoreCommand(argv, json2, io, dependencies) {
|
|
|
105004
105201
|
await restoreFromOwnerCommand(argv, json2, io, dependencies);
|
|
105005
105202
|
return;
|
|
105006
105203
|
}
|
|
105007
|
-
|
|
105008
|
-
|
|
105204
|
+
let parsed;
|
|
105205
|
+
try {
|
|
105206
|
+
parsed = parseArguments(argv, {
|
|
105207
|
+
valueOptions: /* @__PURE__ */ new Set(["--accounts"]),
|
|
105208
|
+
maximumPositionals: 0
|
|
105209
|
+
});
|
|
105210
|
+
} catch (error61) {
|
|
105211
|
+
if (error61 instanceof UsageError) throw new UsageError(RESTORE_USAGE);
|
|
105212
|
+
throw error61;
|
|
105009
105213
|
}
|
|
105214
|
+
const accountCount = parseRestoreAccountCount(parsed.one("--accounts"));
|
|
105010
105215
|
const paths = getVapiPaths();
|
|
105011
105216
|
const path = join27(paths.directory, "vault.json");
|
|
105012
105217
|
if (await fileExists2(path)) {
|
|
@@ -105020,13 +105225,39 @@ async function restoreCommand(argv, json2, io, dependencies) {
|
|
|
105020
105225
|
const config2 = await readConfig(paths.config, json2 ? quietIo(io) : io);
|
|
105021
105226
|
const phrase = isStdinInteractive(dependencies) ? await getPrompts(dependencies).secret("Recovery phrase: ") : await (dependencies.readStdin ?? readProcessStdin3)();
|
|
105022
105227
|
const restoreIo = json2 ? quietIo(io) : io;
|
|
105023
|
-
const { names } = await restoreVaultFromPhrase(
|
|
105228
|
+
const { names, scannedAddresses } = await restoreVaultFromPhrase(
|
|
105229
|
+
phrase.trim(),
|
|
105230
|
+
config2,
|
|
105231
|
+
restoreIo,
|
|
105232
|
+
dependencies,
|
|
105233
|
+
accountCount
|
|
105234
|
+
);
|
|
105024
105235
|
if (json2) {
|
|
105025
|
-
output3(
|
|
105236
|
+
output3(
|
|
105237
|
+
io,
|
|
105238
|
+
true,
|
|
105239
|
+
{ command: "restore", vault: "restored", accounts: names, scannedAddresses },
|
|
105240
|
+
""
|
|
105241
|
+
);
|
|
105026
105242
|
return;
|
|
105027
105243
|
}
|
|
105028
105244
|
io.stdout(`Run vapi setup to link ${names[0]}.`);
|
|
105029
105245
|
}
|
|
105246
|
+
function parseRestoreAccountCount(value) {
|
|
105247
|
+
if (value === void 0) return void 0;
|
|
105248
|
+
if (!/^\d+$/u.test(value)) {
|
|
105249
|
+
throw new UsageError(
|
|
105250
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
105251
|
+
);
|
|
105252
|
+
}
|
|
105253
|
+
const count = Number(value);
|
|
105254
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > MAX_RESTORE_ACCOUNTS) {
|
|
105255
|
+
throw new UsageError(
|
|
105256
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
105257
|
+
);
|
|
105258
|
+
}
|
|
105259
|
+
return count;
|
|
105260
|
+
}
|
|
105030
105261
|
async function protectCommand(argv, json2, io, dependencies) {
|
|
105031
105262
|
requireNoArguments(argv);
|
|
105032
105263
|
const env = getEnvironment(dependencies);
|
|
@@ -105156,8 +105387,8 @@ var HELP_HEADING = "vAPI Network";
|
|
|
105156
105387
|
var HELP = `${HELP_HEADING}
|
|
105157
105388
|
|
|
105158
105389
|
Usage:
|
|
105159
|
-
vapi init [--networks <base,arc
|
|
105160
|
-
vapi setup [--no-cloud-backup] [--json]
|
|
105390
|
+
vapi init [--networks <base,arc>] [--json]
|
|
105391
|
+
vapi setup [--no-cloud-backup] [--accounts <n>] [--json]
|
|
105161
105392
|
vapi accounts [--all] [--json]
|
|
105162
105393
|
vapi accounts add <name> [--label <text>] [--no-link] [--json]
|
|
105163
105394
|
vapi accounts import <name> [--keystore <path> | --key-file <path>] [--label <text>] [--json]
|
|
@@ -105187,7 +105418,7 @@ Usage:
|
|
|
105187
105418
|
vapi docs read <url-or-path> [--json]
|
|
105188
105419
|
vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--json]
|
|
105189
105420
|
vapi inspect <id> [--endpoint <name>] [--json]
|
|
105190
|
-
vapi pay <id-or-url> [--method <method>] [--endpoint <name>] [--body <json>] [--content-type <type>] [--network <caip2>] [--expected-pay-to <address>] [--max <amount>] [--account <name>] [--json]
|
|
105421
|
+
vapi pay <id-or-url> [--method <method>] [--endpoint <name>] [--body <json>] [--content-type <type>] [--network <caip2>] [--expected-pay-to <address>] [--max <amount>] [--timeout <seconds>] [--account <name>] [--json]
|
|
105191
105422
|
vapi pay --resume <receipt-id> [--json]
|
|
105192
105423
|
vapi check <url> [--method <method>] [--json]
|
|
105193
105424
|
vapi balance [--account <name>] [--json]
|
|
@@ -105233,8 +105464,8 @@ Usage:
|
|
|
105233
105464
|
vapi task status <id> [--account <name>] [--json]
|
|
105234
105465
|
vapi export-key [--network <caip2>] [--account <name>] [--json]
|
|
105235
105466
|
vapi backup [--account <name>] [--cloud [off]] [--json]
|
|
105236
|
-
vapi restore [--from-owner [--owner <0x\u2026>]] [--json]
|
|
105237
|
-
vapi import (--phrase | --key) [--account <name>] [--networks <base,arc
|
|
105467
|
+
vapi restore [--accounts <n> | --from-owner [--owner <0x\u2026>]] [--json]
|
|
105468
|
+
vapi import (--phrase | --key) [--account <name>] [--networks <base,arc>] [--replace] [--force] [--json]
|
|
105238
105469
|
vapi passphrase [--account <name>] [--json]
|
|
105239
105470
|
vapi vault protect [--json]
|
|
105240
105471
|
vapi vault unprotect [--json]
|
|
@@ -105262,6 +105493,8 @@ Every command that touches a wallet takes \`--account <name>\`, falls back to \`
|
|
|
105262
105493
|
|
|
105263
105494
|
\`vapi search\` answers with vAPI-verified listings plus the mirrored external catalogs. \`--include-unverified\` also returns self-listed APIs that passed vAPI's automated x402 probe but were never reviewed; every result is tagged \`[verified]\`, \`[requested]\`, \`[unverified]\` or \`[external]\`.
|
|
105264
105495
|
|
|
105496
|
+
Solana listings remain searchable; inspect and pay return \`unsupported_network\`. Solana keys are not part of the device vault yet.
|
|
105497
|
+
|
|
105265
105498
|
\`vapi docs\` asks the public vAPI documentation assistant; \`vapi docs search\` searches documentation excerpts and \`vapi docs read\` reads one Markdown page. They need no account, wallet or payment.
|
|
105266
105499
|
|
|
105267
105500
|
\`vapi task --help\` lists task options and availability. Task exit codes: 0 ok, 1 error, 2 policy refusal (JSON ok:false with a policy. reason) or invalid usage (JSON error), 3 approval needed in non-interactive mode. Posting moves no money; the current create-order contract does not store amount, deadline, intake, max awards or webhook yet.
|
|
@@ -105274,7 +105507,7 @@ Every command that touches a wallet takes \`--account <name>\`, falls back to \`
|
|
|
105274
105507
|
|
|
105275
105508
|
\`vapi vault protect\` adds a password to the device vault. \`vapi vault unlock\` opens it on this device for 8 hours; for unattended use, set \`VAPI_VAULT_PASSWORD\`. \`vapi unlock\` and \`vapi lock\` remain aliases for one release.
|
|
105276
105509
|
|
|
105277
|
-
\`vapi backup\` and \`vapi export-key\` print a secret, so they run only on a real terminal, never for an agent, and ask you to type the wallet name first. \`vapi backup --cloud\` keeps an encrypted vault copy that only the owner can approve for recovery. \`vapi restore\` rebuilds the vault from the phrase and re-derives accounts until
|
|
105510
|
+
\`vapi backup\` and \`vapi export-key\` print a secret, so they run only on a real terminal, never for an agent, and ask you to type the wallet name first. \`vapi backup --cloud\` keeps an encrypted vault copy that only the owner can approve for recovery. \`vapi restore\` rebuilds the vault from the phrase and re-derives accounts until five consecutive addresses have no Base USDC, and reports the number scanned. Use \`--accounts <n>\` with restore or setup to recover a fixed count without querying balances. Set \`VAPI_NO_SECRETS=1\` to switch exports off entirely. Every export and every wallet change is logged to ~/.vapi/audit.log.
|
|
105278
105511
|
|
|
105279
105512
|
\`vapi publish <url>\` lists an API you own. vAPI probes the URL \u2014 an origin, one endpoint, or an OpenAPI document \u2014 you choose which endpoints to list, and your wallet signs one line naming where the payouts go. Listing is permissionless: a listing that passed the probe goes live with \`vapi publish activate <slug>\`, and \`vapi publish verify-request <slug>\` asks for the review that puts it in the default search. Deploying the FeeSplitter that receives the payouts is a wallet transaction and stays in the console. A catalog of more than 20 endpoints is listed as several listings of up to 20, with one result line per endpoint; \`--resume\` skips every endpoint this key already lists.
|
|
105280
105513
|
|
|
@@ -106063,7 +106296,7 @@ async function inspectCommand(argv, json2, io, dependencies) {
|
|
|
106063
106296
|
);
|
|
106064
106297
|
output3(io, json2, result, formatInspect(result));
|
|
106065
106298
|
}
|
|
106066
|
-
var PAY_USAGE = "Usage: vapi pay <id-or-url> [--method <method>] [--endpoint <name>] [--body <json>] [--content-type <type>] [--network <caip2>] [--expected-pay-to <address>] [--max <amount>] [--account <name>] [--json]";
|
|
106299
|
+
var PAY_USAGE = "Usage: vapi pay <id-or-url> [--method <method>] [--endpoint <name>] [--body <json>] [--content-type <type>] [--network <caip2>] [--expected-pay-to <address>] [--max <amount>] [--timeout <seconds>] [--account <name>] [--json]";
|
|
106067
106300
|
async function payCommand(argv, json2, io, dependencies) {
|
|
106068
106301
|
if (argv.includes(RESUME_OPTION)) {
|
|
106069
106302
|
await payResumeCommand(argv, json2, io, dependencies);
|
|
@@ -106079,11 +106312,13 @@ async function payCommand(argv, json2, io, dependencies) {
|
|
|
106079
106312
|
"--expected-pay-to",
|
|
106080
106313
|
"--max",
|
|
106081
106314
|
"--max-price-usd",
|
|
106315
|
+
"--timeout",
|
|
106082
106316
|
WALLET_OPTION5
|
|
106083
106317
|
]),
|
|
106084
106318
|
maximumPositionals: 1
|
|
106085
106319
|
});
|
|
106086
106320
|
const target = requiredPositional(parsed.positionals[0], "<id-or-url>", PAY_USAGE);
|
|
106321
|
+
const timeoutSeconds = optionalBoundedInteger(parsed.one("--timeout"), "--timeout", 1, 300);
|
|
106087
106322
|
const paths = getVapiPaths();
|
|
106088
106323
|
const config2 = await readConfig(paths.config, io);
|
|
106089
106324
|
const wallet = await targetWallet(parsed, dependencies);
|
|
@@ -106099,7 +106334,8 @@ async function payCommand(argv, json2, io, dependencies) {
|
|
|
106099
106334
|
...parsed.one("--content-type") ? { contentType: parsed.one("--content-type") } : {},
|
|
106100
106335
|
...parsed.one("--network") ? { network: parsed.one("--network") } : {},
|
|
106101
106336
|
...parsed.one("--expected-pay-to") ? { expectedPayTo: parsed.one("--expected-pay-to") } : {},
|
|
106102
|
-
...maxPriceUsd ? { maxPriceUsd } : {}
|
|
106337
|
+
...maxPriceUsd ? { maxPriceUsd } : {},
|
|
106338
|
+
...timeoutSeconds === void 0 ? {} : { timeoutSeconds }
|
|
106103
106339
|
};
|
|
106104
106340
|
const call2 = createCallPort({
|
|
106105
106341
|
config: config2,
|
|
@@ -107774,7 +108010,7 @@ function buildNextSteps(address4) {
|
|
|
107774
108010
|
formatNextStep("Pay", "vapi pay <ref> --max 0.02"),
|
|
107775
108011
|
formatNextStep(
|
|
107776
108012
|
"Agent",
|
|
107777
|
-
'add {"command":"npx","args":["-y","vapi-network","mcp"]} to your MCP config'
|
|
108013
|
+
'add {"command":"npx","args":["-y","vapi-network@latest","mcp"]} to your MCP config'
|
|
107778
108014
|
)
|
|
107779
108015
|
];
|
|
107780
108016
|
}
|
|
@@ -107955,6 +108191,17 @@ function optionalPositiveInteger(value, option) {
|
|
|
107955
108191
|
if (result === 0) throw new UsageError(`${option} must be a positive integer.`);
|
|
107956
108192
|
return result;
|
|
107957
108193
|
}
|
|
108194
|
+
function optionalBoundedInteger(value, option, minimum, maximum) {
|
|
108195
|
+
if (value === void 0) return void 0;
|
|
108196
|
+
if (!/^\d+$/.test(value)) {
|
|
108197
|
+
throw new UsageError(`${option} must be an integer from ${minimum} to ${maximum}.`);
|
|
108198
|
+
}
|
|
108199
|
+
const parsed = Number(value);
|
|
108200
|
+
if (!Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
|
|
108201
|
+
throw new UsageError(`${option} must be an integer from ${minimum} to ${maximum}.`);
|
|
108202
|
+
}
|
|
108203
|
+
return parsed;
|
|
108204
|
+
}
|
|
107958
108205
|
function optionalUsdAmount(value, option) {
|
|
107959
108206
|
if (value === void 0) return void 0;
|
|
107960
108207
|
if (!/^\d+(?:\.\d{1,2})?$/.test(value)) {
|
|
@@ -108015,12 +108262,138 @@ function parseInitNetworks(value) {
|
|
|
108015
108262
|
}
|
|
108016
108263
|
for (const network of networks) {
|
|
108017
108264
|
if (network !== "base" && network !== "arc" && network !== "solana") {
|
|
108018
|
-
throw new UsageError("--networks supports base
|
|
108265
|
+
throw new UsageError("--networks supports base and arc; Solana vault setup is unavailable.");
|
|
108019
108266
|
}
|
|
108020
108267
|
}
|
|
108021
108268
|
return networks;
|
|
108022
108269
|
}
|
|
108023
108270
|
|
|
108271
|
+
// ../cli/src/update-check.ts
|
|
108272
|
+
import { lookup } from "node:dns/promises";
|
|
108273
|
+
import { mkdir as mkdir21, readFile as readFile29, writeFile as writeFile12 } from "node:fs/promises";
|
|
108274
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
108275
|
+
var CHECK_TIMEOUT_MS = 1500;
|
|
108276
|
+
var LATEST_URL = "https://registry.npmjs.org/vapi-network/latest";
|
|
108277
|
+
async function runCliWithUpdateCheck(argv = process.argv.slice(2), io = {
|
|
108278
|
+
stdout: (message) => console.log(message),
|
|
108279
|
+
stderr: (message) => console.error(message)
|
|
108280
|
+
}, dependencies = {}, options = {}) {
|
|
108281
|
+
const notice = checkForUpdate({ ...options, env: options.env ?? dependencies.env, argv });
|
|
108282
|
+
const code = await runCli(argv, io, dependencies);
|
|
108283
|
+
const message = await notice;
|
|
108284
|
+
if (message) io.stderr(message);
|
|
108285
|
+
return code;
|
|
108286
|
+
}
|
|
108287
|
+
async function checkForUpdate(options = {}) {
|
|
108288
|
+
const env = options.env ?? process.env;
|
|
108289
|
+
const argv = options.argv ?? process.argv.slice(2);
|
|
108290
|
+
if (!(options.stderrIsTTY ?? process.stderr.isTTY) || argv.includes("--json") || argv[0] === "mcp" && argv[1] !== "install" || env.VAPI_NO_UPDATE_CHECK === "1" || env.CI !== void 0) {
|
|
108291
|
+
return void 0;
|
|
108292
|
+
}
|
|
108293
|
+
const controller = new AbortController();
|
|
108294
|
+
let timer;
|
|
108295
|
+
try {
|
|
108296
|
+
return await Promise.race([
|
|
108297
|
+
latestNotice(options, env, controller.signal),
|
|
108298
|
+
new Promise((resolve2) => {
|
|
108299
|
+
timer = setTimeout(() => {
|
|
108300
|
+
controller.abort();
|
|
108301
|
+
resolve2(void 0);
|
|
108302
|
+
}, CHECK_TIMEOUT_MS);
|
|
108303
|
+
})
|
|
108304
|
+
]);
|
|
108305
|
+
} catch {
|
|
108306
|
+
return void 0;
|
|
108307
|
+
} finally {
|
|
108308
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
108309
|
+
controller.abort();
|
|
108310
|
+
}
|
|
108311
|
+
}
|
|
108312
|
+
async function latestNotice(options, env, signal) {
|
|
108313
|
+
const paths = getVapiPaths(options.home ?? (env.VAPI_HOME?.trim() || void 0));
|
|
108314
|
+
const now = (options.nowMs ?? Date.now)();
|
|
108315
|
+
let cached2;
|
|
108316
|
+
try {
|
|
108317
|
+
const value = JSON.parse(await readFile29(paths.updateCheck, "utf8"));
|
|
108318
|
+
if (isRecord12(value) && typeof value.checkedAt === "number" && Number.isFinite(value.checkedAt) && typeof value.latest === "string" && parseVersion(value.latest)) {
|
|
108319
|
+
cached2 = { checkedAt: value.checkedAt, latest: value.latest };
|
|
108320
|
+
}
|
|
108321
|
+
} catch {
|
|
108322
|
+
}
|
|
108323
|
+
signal.throwIfAborted();
|
|
108324
|
+
let latest = cached2?.latest ?? CLI_VERSION;
|
|
108325
|
+
if (cached2 === void 0 || now - cached2.checkedAt >= CHECK_INTERVAL_MS || now < cached2.checkedAt) {
|
|
108326
|
+
await mkdir21(paths.directory, { recursive: true });
|
|
108327
|
+
signal.throwIfAborted();
|
|
108328
|
+
await writeFile12(paths.updateCheck, JSON.stringify({ checkedAt: now, latest }), { mode: 384 });
|
|
108329
|
+
signal.throwIfAborted();
|
|
108330
|
+
const fetchImpl = options.fetchImpl ?? createPublicFetch({
|
|
108331
|
+
allowPrivateNetwork: false,
|
|
108332
|
+
lookup: async (hostname3) => {
|
|
108333
|
+
let onAbort;
|
|
108334
|
+
const aborted2 = new Promise((_resolve, reject) => {
|
|
108335
|
+
onAbort = () => reject(signal.reason);
|
|
108336
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
108337
|
+
});
|
|
108338
|
+
try {
|
|
108339
|
+
signal.throwIfAborted();
|
|
108340
|
+
const addresses = await Promise.race([lookup(hostname3, { all: true }), aborted2]);
|
|
108341
|
+
return addresses.map(({ address: address4 }) => address4);
|
|
108342
|
+
} finally {
|
|
108343
|
+
signal.removeEventListener("abort", onAbort);
|
|
108344
|
+
}
|
|
108345
|
+
}
|
|
108346
|
+
});
|
|
108347
|
+
const response = await fetchImpl(LATEST_URL, { signal, redirect: "error" });
|
|
108348
|
+
if (!response.ok) return void 0;
|
|
108349
|
+
const body = await response.json();
|
|
108350
|
+
signal.throwIfAborted();
|
|
108351
|
+
if (!isRecord12(body) || typeof body.version !== "string" || !parseVersion(body.version)) {
|
|
108352
|
+
return void 0;
|
|
108353
|
+
}
|
|
108354
|
+
latest = body.version;
|
|
108355
|
+
await writeFile12(paths.updateCheck, JSON.stringify({ checkedAt: now, latest }), { mode: 384 });
|
|
108356
|
+
}
|
|
108357
|
+
signal.throwIfAborted();
|
|
108358
|
+
return isNewerVersion(latest, CLI_VERSION) ? `vapi-network ${latest} is available (you have ${CLI_VERSION}). Update: npm i -g vapi-network@latest` : void 0;
|
|
108359
|
+
}
|
|
108360
|
+
function isRecord12(value) {
|
|
108361
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
108362
|
+
}
|
|
108363
|
+
function parseVersion(version5) {
|
|
108364
|
+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-zA-Z.-]+))?(?:\+[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?$/.exec(
|
|
108365
|
+
version5
|
|
108366
|
+
);
|
|
108367
|
+
if (!match) return void 0;
|
|
108368
|
+
const prerelease = match[4]?.split(".");
|
|
108369
|
+
if (prerelease?.some((part) => part === "" || /^\d+$/.test(part) && /^0\d/.test(part))) {
|
|
108370
|
+
return void 0;
|
|
108371
|
+
}
|
|
108372
|
+
return { core: match.slice(1, 4).map(BigInt), prerelease };
|
|
108373
|
+
}
|
|
108374
|
+
function isNewerVersion(latest, current) {
|
|
108375
|
+
const next = parseVersion(latest);
|
|
108376
|
+
const running = parseVersion(current);
|
|
108377
|
+
for (let index2 = 0; index2 < 3; index2 += 1) {
|
|
108378
|
+
if (next.core[index2] !== running.core[index2]) return next.core[index2] > running.core[index2];
|
|
108379
|
+
}
|
|
108380
|
+
if (running.prerelease === void 0) return false;
|
|
108381
|
+
if (next.prerelease === void 0) return true;
|
|
108382
|
+
for (let index2 = 0; index2 < Math.max(next.prerelease.length, running.prerelease.length); index2 += 1) {
|
|
108383
|
+
const a = next.prerelease[index2];
|
|
108384
|
+
const b = running.prerelease[index2];
|
|
108385
|
+
if (a === b) continue;
|
|
108386
|
+
if (a === void 0) return false;
|
|
108387
|
+
if (b === void 0) return true;
|
|
108388
|
+
const aNumeric = /^\d+$/.test(a);
|
|
108389
|
+
const bNumeric = /^\d+$/.test(b);
|
|
108390
|
+
if (aNumeric && bNumeric) return BigInt(a) > BigInt(b);
|
|
108391
|
+
if (aNumeric !== bNumeric) return !aNumeric;
|
|
108392
|
+
return a > b;
|
|
108393
|
+
}
|
|
108394
|
+
return false;
|
|
108395
|
+
}
|
|
108396
|
+
|
|
108024
108397
|
// src/cli.ts
|
|
108025
|
-
process.exitCode = await
|
|
108398
|
+
process.exitCode = await runCliWithUpdateCheck();
|
|
108026
108399
|
//# sourceMappingURL=cli.js.map
|