vapi-network 0.9.2 → 0.9.5
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 +17 -9
- package/dist/cli.js +694 -176
- package/dist/cli.js.map +3 -3
- package/dist/index.js +712 -180
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9442,13 +9442,13 @@ var init_getCallError = __esm({
|
|
|
9442
9442
|
|
|
9443
9443
|
// ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/promise/withResolvers.js
|
|
9444
9444
|
function withResolvers() {
|
|
9445
|
-
let
|
|
9445
|
+
let resolve3 = () => void 0;
|
|
9446
9446
|
let reject = () => void 0;
|
|
9447
9447
|
const promise2 = new Promise((resolve_, reject_) => {
|
|
9448
|
-
|
|
9448
|
+
resolve3 = resolve_;
|
|
9449
9449
|
reject = reject_;
|
|
9450
9450
|
});
|
|
9451
|
-
return { promise: promise2, resolve:
|
|
9451
|
+
return { promise: promise2, resolve: resolve3, reject };
|
|
9452
9452
|
}
|
|
9453
9453
|
var init_withResolvers = __esm({
|
|
9454
9454
|
"../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/promise/withResolvers.js"() {
|
|
@@ -9467,8 +9467,8 @@ function createBatchScheduler({ fn, id: id2, shouldSplitBatch, wait: wait2 = 0,
|
|
|
9467
9467
|
if (sort && Array.isArray(data))
|
|
9468
9468
|
data.sort(sort);
|
|
9469
9469
|
for (let i = 0; i < scheduler.length; i++) {
|
|
9470
|
-
const { resolve:
|
|
9471
|
-
|
|
9470
|
+
const { resolve: resolve3 } = scheduler[i];
|
|
9471
|
+
resolve3?.([data[i], data]);
|
|
9472
9472
|
}
|
|
9473
9473
|
}).catch((err) => {
|
|
9474
9474
|
for (let i = 0; i < scheduler.length; i++) {
|
|
@@ -9484,16 +9484,16 @@ function createBatchScheduler({ fn, id: id2, shouldSplitBatch, wait: wait2 = 0,
|
|
|
9484
9484
|
return {
|
|
9485
9485
|
flush,
|
|
9486
9486
|
async schedule(args) {
|
|
9487
|
-
const { promise: promise2, resolve:
|
|
9487
|
+
const { promise: promise2, resolve: resolve3, reject } = withResolvers();
|
|
9488
9488
|
const split2 = shouldSplitBatch?.([...getBatchedArgs(), args]);
|
|
9489
9489
|
if (split2)
|
|
9490
9490
|
exec();
|
|
9491
9491
|
const hasActiveScheduler = getScheduler().length > 0;
|
|
9492
9492
|
if (hasActiveScheduler) {
|
|
9493
|
-
setScheduler({ args, resolve:
|
|
9493
|
+
setScheduler({ args, resolve: resolve3, reject });
|
|
9494
9494
|
return promise2;
|
|
9495
9495
|
}
|
|
9496
|
-
setScheduler({ args, resolve:
|
|
9496
|
+
setScheduler({ args, resolve: resolve3, reject });
|
|
9497
9497
|
setTimeout(exec, wait2);
|
|
9498
9498
|
return promise2;
|
|
9499
9499
|
}
|
|
@@ -30775,7 +30775,7 @@ function observe(observerId, callbacks, fn) {
|
|
|
30775
30775
|
// ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/wait.js
|
|
30776
30776
|
init_utils3();
|
|
30777
30777
|
async function wait(time3, { signal } = {}) {
|
|
30778
|
-
return new Promise((
|
|
30778
|
+
return new Promise((resolve3, reject) => {
|
|
30779
30779
|
if (signal?.aborted) {
|
|
30780
30780
|
reject(getAbortError(signal));
|
|
30781
30781
|
return;
|
|
@@ -30783,7 +30783,7 @@ async function wait(time3, { signal } = {}) {
|
|
|
30783
30783
|
const cleanup = () => signal?.removeEventListener("abort", onAbort);
|
|
30784
30784
|
const timeout = setTimeout(() => {
|
|
30785
30785
|
cleanup();
|
|
30786
|
-
|
|
30786
|
+
resolve3();
|
|
30787
30787
|
}, time3);
|
|
30788
30788
|
const onAbort = () => {
|
|
30789
30789
|
clearTimeout(timeout);
|
|
@@ -31359,7 +31359,7 @@ init_withResolvers();
|
|
|
31359
31359
|
// ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/promise/withRetry.js
|
|
31360
31360
|
init_utils3();
|
|
31361
31361
|
function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shouldRetry2 = () => true, signal } = {}) {
|
|
31362
|
-
return new Promise((
|
|
31362
|
+
return new Promise((resolve3, reject) => {
|
|
31363
31363
|
const attemptRetry = async ({ count = 0 } = {}) => {
|
|
31364
31364
|
if (signal?.aborted) {
|
|
31365
31365
|
reject(getAbortError(signal));
|
|
@@ -31379,7 +31379,7 @@ function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shoul
|
|
|
31379
31379
|
};
|
|
31380
31380
|
try {
|
|
31381
31381
|
const data = await fn();
|
|
31382
|
-
|
|
31382
|
+
resolve3(data);
|
|
31383
31383
|
} catch (err) {
|
|
31384
31384
|
if (signal?.aborted) {
|
|
31385
31385
|
reject(getAbortError(signal));
|
|
@@ -31530,7 +31530,7 @@ async function sendCalls(client, parameters) {
|
|
|
31530
31530
|
results.push({ reason, status: "rejected" });
|
|
31531
31531
|
}
|
|
31532
31532
|
if (experimental_fallbackDelay > 0)
|
|
31533
|
-
await new Promise((
|
|
31533
|
+
await new Promise((resolve3) => setTimeout(resolve3, experimental_fallbackDelay));
|
|
31534
31534
|
}
|
|
31535
31535
|
if (results.every((r) => r.status === "rejected"))
|
|
31536
31536
|
throw results[0].reason;
|
|
@@ -31633,9 +31633,9 @@ async function waitForCallsStatus(client, parameters) {
|
|
|
31633
31633
|
throwOnFailure = false
|
|
31634
31634
|
} = parameters;
|
|
31635
31635
|
const observerId = stringify(["waitForCallsStatus", client.uid, id2]);
|
|
31636
|
-
const { promise: promise2, resolve:
|
|
31636
|
+
const { promise: promise2, resolve: resolve3, reject } = withResolvers();
|
|
31637
31637
|
let timer;
|
|
31638
|
-
const unobserve = observe(observerId, { resolve:
|
|
31638
|
+
const unobserve = observe(observerId, { resolve: resolve3, reject }, (emit) => {
|
|
31639
31639
|
const unpoll = poll(async () => {
|
|
31640
31640
|
const done = (fn) => {
|
|
31641
31641
|
clearTimeout(timer);
|
|
@@ -32017,13 +32017,13 @@ async function isImageUri(uri) {
|
|
|
32017
32017
|
}
|
|
32018
32018
|
if (!Object.hasOwn(globalThis, "Image"))
|
|
32019
32019
|
return false;
|
|
32020
|
-
return new Promise((
|
|
32020
|
+
return new Promise((resolve3) => {
|
|
32021
32021
|
const img = new Image();
|
|
32022
32022
|
img.onload = () => {
|
|
32023
|
-
|
|
32023
|
+
resolve3(true);
|
|
32024
32024
|
};
|
|
32025
32025
|
img.onerror = () => {
|
|
32026
|
-
|
|
32026
|
+
resolve3(false);
|
|
32027
32027
|
};
|
|
32028
32028
|
img.src = uri;
|
|
32029
32029
|
});
|
|
@@ -33486,7 +33486,7 @@ init_utils3();
|
|
|
33486
33486
|
// ../../node_modules/.pnpm/viem@2.56.1_typescript@6.0.3_zod@4.5.4/node_modules/viem/_esm/utils/promise/withTimeout.js
|
|
33487
33487
|
init_utils3();
|
|
33488
33488
|
function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, signal }) {
|
|
33489
|
-
return new Promise((
|
|
33489
|
+
return new Promise((resolve3, reject) => {
|
|
33490
33490
|
;
|
|
33491
33491
|
(async () => {
|
|
33492
33492
|
let timeoutId;
|
|
@@ -33501,7 +33501,7 @@ function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, sign
|
|
|
33501
33501
|
}
|
|
33502
33502
|
}, timeout);
|
|
33503
33503
|
}
|
|
33504
|
-
|
|
33504
|
+
resolve3(await fn({ signal: controller?.signal || null }));
|
|
33505
33505
|
} catch (err) {
|
|
33506
33506
|
if (controller?.signal.aborted && isAbortError(err)) {
|
|
33507
33507
|
reject(errorInstance);
|
|
@@ -37481,13 +37481,13 @@ async function waitForTransactionReceipt(client, parameters) {
|
|
|
37481
37481
|
let retrying = false;
|
|
37482
37482
|
let _unobserve;
|
|
37483
37483
|
let _unwatch;
|
|
37484
|
-
const { promise: promise2, resolve:
|
|
37484
|
+
const { promise: promise2, resolve: resolve3, reject } = withResolvers();
|
|
37485
37485
|
const timer = timeout ? setTimeout(() => {
|
|
37486
37486
|
_unwatch?.();
|
|
37487
37487
|
_unobserve?.();
|
|
37488
37488
|
reject(new WaitForTransactionReceiptTimeoutError({ hash: hash5 }));
|
|
37489
37489
|
}, timeout) : void 0;
|
|
37490
|
-
_unobserve = observe(observerId, { onReplaced, resolve:
|
|
37490
|
+
_unobserve = observe(observerId, { onReplaced, resolve: resolve3, reject }, async (emit) => {
|
|
37491
37491
|
receipt = await getAction(client, getTransactionReceipt, "getTransactionReceipt")({ hash: hash5 }).catch(() => void 0);
|
|
37492
37492
|
if (receipt && confirmations <= 1) {
|
|
37493
37493
|
clearTimeout(timer);
|
|
@@ -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 = {
|
|
@@ -43436,7 +43446,7 @@ function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
|
|
|
43436
43446
|
coalescedRequest.numConsumers++;
|
|
43437
43447
|
if (signal) {
|
|
43438
43448
|
const responsePromise = coalescedRequest.responsePromise;
|
|
43439
|
-
return await new Promise((
|
|
43449
|
+
return await new Promise((resolve3, reject) => {
|
|
43440
43450
|
const handleAbort = (e22) => {
|
|
43441
43451
|
signal.removeEventListener("abort", handleAbort);
|
|
43442
43452
|
coalescedRequest.numConsumers -= 1;
|
|
@@ -43449,7 +43459,7 @@ function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
|
|
|
43449
43459
|
reject(e22.target.reason);
|
|
43450
43460
|
};
|
|
43451
43461
|
signal.addEventListener("abort", handleAbort);
|
|
43452
|
-
responsePromise.then(
|
|
43462
|
+
responsePromise.then(resolve3).catch(reject).finally(() => {
|
|
43453
43463
|
signal.removeEventListener("abort", handleAbort);
|
|
43454
43464
|
});
|
|
43455
43465
|
});
|
|
@@ -44832,7 +44842,7 @@ function createPublicFetch(options) {
|
|
|
44832
44842
|
});
|
|
44833
44843
|
const normalized = new Request(input2, init);
|
|
44834
44844
|
const bytes = normalized.body ? Buffer.from(await normalized.arrayBuffer()) : null;
|
|
44835
|
-
return await new Promise((
|
|
44845
|
+
return await new Promise((resolve3, reject) => {
|
|
44836
44846
|
const requestOptions2 = {
|
|
44837
44847
|
method: normalized.method,
|
|
44838
44848
|
headers: Object.fromEntries(normalized.headers),
|
|
@@ -44857,7 +44867,7 @@ function createPublicFetch(options) {
|
|
|
44857
44867
|
{ status, statusText: incoming.statusMessage, headers }
|
|
44858
44868
|
);
|
|
44859
44869
|
Object.defineProperty(response, "url", { value: url2.toString() });
|
|
44860
|
-
|
|
44870
|
+
resolve3(response);
|
|
44861
44871
|
} catch (error61) {
|
|
44862
44872
|
incoming.destroy();
|
|
44863
44873
|
reject(error61);
|
|
@@ -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;
|
|
@@ -45626,8 +45636,8 @@ var svmFetchQueue = Promise.resolve();
|
|
|
45626
45636
|
async function withGuardedSvmFetch(fetchImpl, operation) {
|
|
45627
45637
|
const previous = svmFetchQueue;
|
|
45628
45638
|
let release2;
|
|
45629
|
-
svmFetchQueue = new Promise((
|
|
45630
|
-
release2 =
|
|
45639
|
+
svmFetchQueue = new Promise((resolve3) => {
|
|
45640
|
+
release2 = resolve3;
|
|
45631
45641
|
});
|
|
45632
45642
|
await previous;
|
|
45633
45643
|
const originalFetch = globalThis.fetch;
|
|
@@ -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",
|
|
@@ -46822,7 +46850,7 @@ async function withFileLock(lockPath, fn, options = {}) {
|
|
|
46822
46850
|
if (Date.now() >= deadline) {
|
|
46823
46851
|
throw new FileLockedError(options.lockedMessage);
|
|
46824
46852
|
}
|
|
46825
|
-
await new Promise((
|
|
46853
|
+
await new Promise((resolve3) => setTimeout(resolve3, LOCK_RETRY_MS));
|
|
46826
46854
|
continue;
|
|
46827
46855
|
}
|
|
46828
46856
|
handle = candidate;
|
|
@@ -46837,7 +46865,7 @@ async function withFileLock(lockPath, fn, options = {}) {
|
|
|
46837
46865
|
if (Date.now() >= deadline) {
|
|
46838
46866
|
throw new FileLockedError(options.lockedMessage);
|
|
46839
46867
|
}
|
|
46840
|
-
await new Promise((
|
|
46868
|
+
await new Promise((resolve3) => setTimeout(resolve3, LOCK_RETRY_MS));
|
|
46841
46869
|
}
|
|
46842
46870
|
}
|
|
46843
46871
|
const ownedHandle = handle;
|
|
@@ -46958,7 +46986,7 @@ async function restoreRenamedLock(path, tombPath) {
|
|
|
46958
46986
|
} catch (error61) {
|
|
46959
46987
|
if (hasCode(error61, "ENOENT")) return;
|
|
46960
46988
|
if (!hasCode(error61, "EEXIST")) throw error61;
|
|
46961
|
-
await new Promise((
|
|
46989
|
+
await new Promise((resolve3) => setTimeout(resolve3, LOCK_RETRY_MS));
|
|
46962
46990
|
}
|
|
46963
46991
|
}
|
|
46964
46992
|
}
|
|
@@ -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;
|
|
@@ -47956,7 +47985,7 @@ async function withAgentCredentialLock(wallets, clientId, operation) {
|
|
|
47956
47985
|
if (Date.now() >= deadline) {
|
|
47957
47986
|
throw httpError("Timed out waiting to update the agent credentials.");
|
|
47958
47987
|
}
|
|
47959
|
-
await new Promise((
|
|
47988
|
+
await new Promise((resolve3) => setTimeout(resolve3, 20));
|
|
47960
47989
|
}
|
|
47961
47990
|
}
|
|
47962
47991
|
try {
|
|
@@ -48109,7 +48138,7 @@ function splitScopes(scope) {
|
|
|
48109
48138
|
return scope.split(/\s+/u).filter(Boolean);
|
|
48110
48139
|
}
|
|
48111
48140
|
async function sleepFor(milliseconds) {
|
|
48112
|
-
await new Promise((
|
|
48141
|
+
await new Promise((resolve3) => setTimeout(resolve3, milliseconds));
|
|
48113
48142
|
}
|
|
48114
48143
|
|
|
48115
48144
|
// ../core/src/keystore.ts
|
|
@@ -69587,7 +69616,7 @@ function decryptWithKey(key2, sealed) {
|
|
|
69587
69616
|
return Buffer.concat([decipher.update(sealed.ciphertext), decipher.final()]);
|
|
69588
69617
|
}
|
|
69589
69618
|
async function deriveScryptKey(passphrase, salt) {
|
|
69590
|
-
return await new Promise((
|
|
69619
|
+
return await new Promise((resolve3, reject) => {
|
|
69591
69620
|
scrypt(
|
|
69592
69621
|
passphrase,
|
|
69593
69622
|
salt,
|
|
@@ -69603,7 +69632,7 @@ async function deriveScryptKey(passphrase, salt) {
|
|
|
69603
69632
|
reject(error61);
|
|
69604
69633
|
return;
|
|
69605
69634
|
}
|
|
69606
|
-
|
|
69635
|
+
resolve3(derivedKey);
|
|
69607
69636
|
}
|
|
69608
69637
|
);
|
|
69609
69638
|
});
|
|
@@ -69927,7 +69956,7 @@ async function promptForSecret(prompt, noTerminalHint) {
|
|
|
69927
69956
|
stdin.setRawMode(true);
|
|
69928
69957
|
stdin.resume();
|
|
69929
69958
|
stdin.setEncoding("utf8");
|
|
69930
|
-
return await new Promise((
|
|
69959
|
+
return await new Promise((resolve3, reject) => {
|
|
69931
69960
|
let value = "";
|
|
69932
69961
|
const cleanup = () => {
|
|
69933
69962
|
stdin.off("data", onData);
|
|
@@ -69944,7 +69973,7 @@ async function promptForSecret(prompt, noTerminalHint) {
|
|
|
69944
69973
|
}
|
|
69945
69974
|
if (character === "\r" || character === "\n") {
|
|
69946
69975
|
cleanup();
|
|
69947
|
-
|
|
69976
|
+
resolve3(value);
|
|
69948
69977
|
return;
|
|
69949
69978
|
}
|
|
69950
69979
|
if (character === "\x7F" || character === "\b") {
|
|
@@ -70006,7 +70035,7 @@ async function withAccountMovementLock(home, account, timeoutMs, operation, sign
|
|
|
70006
70035
|
if (!(error61 instanceof Error && "code" in error61 && error61.code === "EEXIST")) throw error61;
|
|
70007
70036
|
await removeStaleLock2(path);
|
|
70008
70037
|
if (Date.now() >= deadline) throw new AccountMovementLockedError(account);
|
|
70009
|
-
await new Promise((
|
|
70038
|
+
await new Promise((resolve3) => setTimeout(resolve3, 20));
|
|
70010
70039
|
}
|
|
70011
70040
|
}
|
|
70012
70041
|
const ownedHandle = handle;
|
|
@@ -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",
|
|
@@ -70477,14 +70506,14 @@ function requireSuccess(result, what) {
|
|
|
70477
70506
|
function withoutTrailingNewline(value) {
|
|
70478
70507
|
return value.replace(/\r?\n$/u, "");
|
|
70479
70508
|
}
|
|
70480
|
-
var spawnRunner = async (file2, args, input2) => await new Promise((
|
|
70509
|
+
var spawnRunner = async (file2, args, input2) => await new Promise((resolve3) => {
|
|
70481
70510
|
let stdout = "";
|
|
70482
70511
|
let stderr2 = "";
|
|
70483
70512
|
let settled = false;
|
|
70484
70513
|
const finish = (outcome) => {
|
|
70485
70514
|
if (settled) return;
|
|
70486
70515
|
settled = true;
|
|
70487
|
-
|
|
70516
|
+
resolve3(outcome);
|
|
70488
70517
|
};
|
|
70489
70518
|
const child = spawn(file2, [...args], {
|
|
70490
70519
|
detached: true,
|
|
@@ -71447,7 +71476,7 @@ async function withVaultLock(path, operation) {
|
|
|
71447
71476
|
if (Date.now() >= deadline) {
|
|
71448
71477
|
throw new VaultError("corrupt", "Timed out waiting for the vault lock.");
|
|
71449
71478
|
}
|
|
71450
|
-
await new Promise((
|
|
71479
|
+
await new Promise((resolve3) => setTimeout(resolve3, 20));
|
|
71451
71480
|
}
|
|
71452
71481
|
}
|
|
71453
71482
|
try {
|
|
@@ -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 });
|
|
@@ -73143,7 +73209,7 @@ async function withRegistryLock(path, operation) {
|
|
|
73143
73209
|
if (Date.now() >= deadline) {
|
|
73144
73210
|
throw new KeystoreError("Timed out waiting for the wallet registry lock.");
|
|
73145
73211
|
}
|
|
73146
|
-
await new Promise((
|
|
73212
|
+
await new Promise((resolve3) => setTimeout(resolve3, 20));
|
|
73147
73213
|
}
|
|
73148
73214
|
}
|
|
73149
73215
|
try {
|
|
@@ -73489,11 +73555,11 @@ function publicErrorMessage(error61, fallback, sensitiveValues = []) {
|
|
|
73489
73555
|
return error61 instanceof Error ? message : fallback;
|
|
73490
73556
|
}
|
|
73491
73557
|
async function unrefSleep(milliseconds, signal) {
|
|
73492
|
-
await new Promise((
|
|
73558
|
+
await new Promise((resolve3) => {
|
|
73493
73559
|
const finish = () => {
|
|
73494
73560
|
clearTimeout(timer);
|
|
73495
73561
|
signal?.removeEventListener("abort", finish);
|
|
73496
|
-
|
|
73562
|
+
resolve3();
|
|
73497
73563
|
};
|
|
73498
73564
|
const timer = setTimeout(finish, milliseconds);
|
|
73499
73565
|
timer.unref();
|
|
@@ -74030,7 +74096,7 @@ async function withLedgerLock(path, operation) {
|
|
|
74030
74096
|
if (Date.now() >= deadline) {
|
|
74031
74097
|
throw new Error("Timed out waiting for the spend ledger lock.");
|
|
74032
74098
|
}
|
|
74033
|
-
await new Promise((
|
|
74099
|
+
await new Promise((resolve3) => setTimeout(resolve3, 20));
|
|
74034
74100
|
}
|
|
74035
74101
|
}
|
|
74036
74102
|
try {
|
|
@@ -74664,7 +74730,7 @@ async function withTransferLock(context, nonce, operation) {
|
|
|
74664
74730
|
if (Date.now() >= deadline) {
|
|
74665
74731
|
throw new Error("Timed out waiting for the transfer lock.");
|
|
74666
74732
|
}
|
|
74667
|
-
await new Promise((
|
|
74733
|
+
await new Promise((resolve3) => setTimeout(resolve3, 20));
|
|
74668
74734
|
}
|
|
74669
74735
|
}
|
|
74670
74736
|
try {
|
|
@@ -76382,8 +76448,8 @@ async function sweepAllAboveCeiling(args) {
|
|
|
76382
76448
|
}
|
|
76383
76449
|
var pendingCeilingSweeps = /* @__PURE__ */ new Set();
|
|
76384
76450
|
function scheduleCeilingSweep(hook) {
|
|
76385
|
-
const task = new Promise((
|
|
76386
|
-
setTimeout(
|
|
76451
|
+
const task = new Promise((resolve3) => {
|
|
76452
|
+
setTimeout(resolve3, 0);
|
|
76387
76453
|
}).then(async () => {
|
|
76388
76454
|
const timeoutMs = hook.timeoutMs ?? CEILING_SWEEP_TIMEOUT_MS;
|
|
76389
76455
|
const controller = new AbortController();
|
|
@@ -76423,8 +76489,8 @@ async function drainCeilingSweeps(timeoutMs = CEILING_SWEEP_TIMEOUT_MS) {
|
|
|
76423
76489
|
try {
|
|
76424
76490
|
await Promise.race([
|
|
76425
76491
|
Promise.allSettled(pending),
|
|
76426
|
-
new Promise((
|
|
76427
|
-
timeout = setTimeout(
|
|
76492
|
+
new Promise((resolve3) => {
|
|
76493
|
+
timeout = setTimeout(resolve3, timeoutMs);
|
|
76428
76494
|
})
|
|
76429
76495
|
]);
|
|
76430
76496
|
} finally {
|
|
@@ -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.5";
|
|
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",
|
|
@@ -81166,7 +81295,7 @@ var authorizationTypes = {
|
|
|
81166
81295
|
function createTasksChain(options) {
|
|
81167
81296
|
const { account, client, pending, rpcFor } = options;
|
|
81168
81297
|
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
81169
|
-
const sleep = options.sleep ?? ((ms) => new Promise((
|
|
81298
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms)));
|
|
81170
81299
|
const randomBytes17 = options.randomBytes ?? cryptoRandomBytes2;
|
|
81171
81300
|
const confirmations = options.confirmations ?? 2;
|
|
81172
81301
|
if (!Number.isSafeInteger(confirmations) || confirmations < 1)
|
|
@@ -81971,7 +82100,7 @@ async function waitForMilestone(client, input2) {
|
|
|
81971
82100
|
throw new RangeError("The milestone wait timeout must be non-negative and finite.");
|
|
81972
82101
|
if (!Number.isFinite(intervalMs) || intervalMs <= 0)
|
|
81973
82102
|
throw new RangeError("The milestone wait interval must be positive and finite.");
|
|
81974
|
-
const sleep = input2.sleep ?? ((ms) => new Promise((
|
|
82103
|
+
const sleep = input2.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms)));
|
|
81975
82104
|
const now = input2.now ?? (() => /* @__PURE__ */ new Date());
|
|
81976
82105
|
const started = now().getTime();
|
|
81977
82106
|
const deadline = started + timeoutMs;
|
|
@@ -86573,10 +86702,10 @@ async function buildStatus(deps) {
|
|
|
86573
86702
|
const timers = deps.timers ?? { setTimeout, clearTimeout };
|
|
86574
86703
|
const controller = new AbortController();
|
|
86575
86704
|
let timeout;
|
|
86576
|
-
const deadline = new Promise((
|
|
86705
|
+
const deadline = new Promise((resolve3) => {
|
|
86577
86706
|
timeout = timers.setTimeout(() => {
|
|
86578
86707
|
controller.abort(new Error("Status request deadline exceeded."));
|
|
86579
|
-
|
|
86708
|
+
resolve3();
|
|
86580
86709
|
}, deps.timeoutMs ?? STATUS_TIMEOUT_MS);
|
|
86581
86710
|
});
|
|
86582
86711
|
try {
|
|
@@ -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
|
},
|
|
@@ -94706,6 +94868,9 @@ function rgbToAnsi256(red, green, blue) {
|
|
|
94706
94868
|
import { readFile as readFile24, stat as stat14 } from "node:fs/promises";
|
|
94707
94869
|
import { join as join21 } from "node:path";
|
|
94708
94870
|
|
|
94871
|
+
// ../cli/src/dashboard.ts
|
|
94872
|
+
import { resolve as resolve2 } from "node:path";
|
|
94873
|
+
|
|
94709
94874
|
// ../cli/src/publish-client.ts
|
|
94710
94875
|
var LISTING_CATEGORIES = ["ai", "data", "crypto", "compute", "search"];
|
|
94711
94876
|
var PROBE_MODES = ["origin", "endpoint", "openapi"];
|
|
@@ -95026,7 +95191,8 @@ async function runLoginFlow(argv, json2, io, dependencies, options = {}) {
|
|
|
95026
95191
|
booleanOptions: /* @__PURE__ */ new Set(["--publish", "--no-browser"]),
|
|
95027
95192
|
maximumPositionals: 0
|
|
95028
95193
|
});
|
|
95029
|
-
const
|
|
95194
|
+
const paths = getVapiPaths(options.home);
|
|
95195
|
+
const target = await targetWallet(parsed, dependencies, paths.directory);
|
|
95030
95196
|
const { account } = await unlockTarget(target, dependencies);
|
|
95031
95197
|
const label = parsed.one("--label") ?? target.name;
|
|
95032
95198
|
const scopes = [
|
|
@@ -95035,13 +95201,13 @@ async function runLoginFlow(argv, json2, io, dependencies, options = {}) {
|
|
|
95035
95201
|
"tasks:write",
|
|
95036
95202
|
...parsed.has("--publish") ? ["call.publish"] : []
|
|
95037
95203
|
];
|
|
95038
|
-
const config2 = await loadConfig(
|
|
95039
|
-
const apiBase = registryBaseUrl(config2);
|
|
95204
|
+
const config2 = await loadConfig(paths.config, process.env, { notice: io.stderr });
|
|
95205
|
+
const apiBase = options.apiBase ?? registryBaseUrl(config2);
|
|
95040
95206
|
const fetchImpl = dependencies.fetchImpl ?? createPublicFetch({ allowPrivateNetwork: false });
|
|
95041
95207
|
const secrets = getSecretStore(dependencies);
|
|
95042
95208
|
const device = await ensureDeviceName({
|
|
95043
95209
|
env: getEnvironment(dependencies),
|
|
95044
|
-
configPath:
|
|
95210
|
+
configPath: paths.config,
|
|
95045
95211
|
...dependencies.hostname === void 0 ? {} : { hostname: dependencies.hostname() }
|
|
95046
95212
|
});
|
|
95047
95213
|
const bearer = await trustedLinkBearer({
|
|
@@ -95295,6 +95461,87 @@ function shortAddress(address4) {
|
|
|
95295
95461
|
return address4.length <= 12 ? address4 : `${address4.slice(0, 6)}\u2026${address4.slice(-4)}`;
|
|
95296
95462
|
}
|
|
95297
95463
|
|
|
95464
|
+
// ../cli/src/dashboard.ts
|
|
95465
|
+
function dashboardUrl(apiBase) {
|
|
95466
|
+
return `${apiBase.replace(/\/+$/u, "")}/agents`;
|
|
95467
|
+
}
|
|
95468
|
+
async function offerDashboardLink({
|
|
95469
|
+
name,
|
|
95470
|
+
json: json2,
|
|
95471
|
+
noLink = false,
|
|
95472
|
+
io,
|
|
95473
|
+
dependencies,
|
|
95474
|
+
home = getVapiPaths().directory,
|
|
95475
|
+
apiBase
|
|
95476
|
+
}) {
|
|
95477
|
+
const otherHome = resolve2(home) !== resolve2(getVapiPaths().directory);
|
|
95478
|
+
const command = `${otherHome ? `VAPI_HOME=${shellQuote(home)} ` : ""}${apiBase === void 0 ? "" : `VAPI_REGISTRY_URL=${shellQuote(apiBase)} `}vapi login --account ${name}`;
|
|
95479
|
+
const unlinked = {
|
|
95480
|
+
linked: false,
|
|
95481
|
+
next: [{ kind: "link", account: name, command }]
|
|
95482
|
+
};
|
|
95483
|
+
const hint = () => {
|
|
95484
|
+
if (!json2) io.stdout(`Run \`${command}\` to see this wallet on your dashboard.`);
|
|
95485
|
+
return unlinked;
|
|
95486
|
+
};
|
|
95487
|
+
try {
|
|
95488
|
+
const store = await WalletStore.open(home, {
|
|
95489
|
+
secrets: getSecretStore(dependencies),
|
|
95490
|
+
env: getEnvironment(dependencies)
|
|
95491
|
+
});
|
|
95492
|
+
if (store.entry(name)?.link !== void 0) return { linked: true };
|
|
95493
|
+
if (noLink || json2 || !isInteractive(dependencies) || activeAgentMarker(getEnvironment(dependencies)) !== void 0) {
|
|
95494
|
+
return hint();
|
|
95495
|
+
}
|
|
95496
|
+
const answer = (await getLinePrompt(dependencies)(`Link ${name} to your vAPI dashboard? [Y/n] `)).trim();
|
|
95497
|
+
if (!/^(?:y|yes)?$/iu.test(answer)) return hint();
|
|
95498
|
+
await runLoginFlow(["--account", name, "--label", name], false, io, dependencies, {
|
|
95499
|
+
home,
|
|
95500
|
+
...apiBase === void 0 ? {} : { apiBase }
|
|
95501
|
+
});
|
|
95502
|
+
await store.reload();
|
|
95503
|
+
const link3 = store.entry(name)?.link;
|
|
95504
|
+
if (link3 === void 0) return hint();
|
|
95505
|
+
io.stdout(`See it on your dashboard: ${dashboardUrl(link3.apiBase)}`);
|
|
95506
|
+
return { linked: true };
|
|
95507
|
+
} catch (error61) {
|
|
95508
|
+
if (!json2) {
|
|
95509
|
+
io.stderr(`Link not completed: ${error61 instanceof Error ? error61.message : String(error61)}`);
|
|
95510
|
+
}
|
|
95511
|
+
return hint();
|
|
95512
|
+
}
|
|
95513
|
+
}
|
|
95514
|
+
async function dashboardCommand(argv, json2, io, dependencies) {
|
|
95515
|
+
const parsed = parseArguments(argv, {
|
|
95516
|
+
valueOptions: /* @__PURE__ */ new Set(["--wallet"]),
|
|
95517
|
+
booleanOptions: /* @__PURE__ */ new Set(["--no-browser", "--no-link"]),
|
|
95518
|
+
maximumPositionals: 0
|
|
95519
|
+
});
|
|
95520
|
+
const target = await targetWallet(parsed, dependencies);
|
|
95521
|
+
let status = { linked: true };
|
|
95522
|
+
if (target.entry.link === void 0) {
|
|
95523
|
+
if (!json2) io.stdout(`${target.name} is not linked to your vAPI dashboard yet.`);
|
|
95524
|
+
status = await offerDashboardLink({
|
|
95525
|
+
name: target.name,
|
|
95526
|
+
json: json2,
|
|
95527
|
+
noLink: parsed.has("--no-link"),
|
|
95528
|
+
io,
|
|
95529
|
+
dependencies: parsed.has("--no-browser") ? { ...dependencies, openUrl: () => false } : dependencies
|
|
95530
|
+
});
|
|
95531
|
+
}
|
|
95532
|
+
await target.store.reload();
|
|
95533
|
+
const apiBase = target.store.entry(target.name)?.link?.apiBase ?? registryBaseUrl(await readConfig(getVapiPaths().config, io));
|
|
95534
|
+
const url2 = dashboardUrl(apiBase);
|
|
95535
|
+
let opened = false;
|
|
95536
|
+
if (status.linked && !parsed.has("--no-browser") && (dependencies.interactive ?? Boolean(process.stdout.isTTY)) && activeAgentMarker(getEnvironment(dependencies)) === void 0) {
|
|
95537
|
+
opened = (dependencies.openUrl ?? openInBrowser)(url2);
|
|
95538
|
+
}
|
|
95539
|
+
io.stdout(json2 ? JSON.stringify({ account: target.name, url: url2, ...status, opened }) : url2);
|
|
95540
|
+
}
|
|
95541
|
+
function shellQuote(value) {
|
|
95542
|
+
return /^[a-zA-Z0-9_./-]+$/u.test(value) ? value : `'${value.replace(/'/gu, "'\\''")}'`;
|
|
95543
|
+
}
|
|
95544
|
+
|
|
95298
95545
|
// ../cli/src/status.ts
|
|
95299
95546
|
import { stat as stat13 } from "node:fs/promises";
|
|
95300
95547
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -97680,10 +97927,10 @@ function apiEndpoint2(apiBase, path) {
|
|
|
97680
97927
|
}
|
|
97681
97928
|
async function sleepFor2(milliseconds, signal) {
|
|
97682
97929
|
if (signal?.aborted === true) throw signal.reason;
|
|
97683
|
-
await new Promise((
|
|
97930
|
+
await new Promise((resolve3, reject) => {
|
|
97684
97931
|
const finish = () => {
|
|
97685
97932
|
signal?.removeEventListener("abort", abort);
|
|
97686
|
-
|
|
97933
|
+
resolve3();
|
|
97687
97934
|
};
|
|
97688
97935
|
const timeout = setTimeout(finish, milliseconds);
|
|
97689
97936
|
const abort = () => {
|
|
@@ -98018,7 +98265,7 @@ async function readProcessStdin() {
|
|
|
98018
98265
|
}
|
|
98019
98266
|
|
|
98020
98267
|
// ../cli/src/version.ts
|
|
98021
|
-
var CLI_VERSION = "0.9.
|
|
98268
|
+
var CLI_VERSION = "0.9.5";
|
|
98022
98269
|
|
|
98023
98270
|
// ../cli/src/status.ts
|
|
98024
98271
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -98162,10 +98409,10 @@ async function runStatusSweep(args) {
|
|
|
98162
98409
|
timeoutMs,
|
|
98163
98410
|
...args.warn === void 0 ? {} : { warn: args.warn }
|
|
98164
98411
|
}),
|
|
98165
|
-
new Promise((
|
|
98412
|
+
new Promise((resolve3) => {
|
|
98166
98413
|
timeout = setTimeout(() => {
|
|
98167
98414
|
controller.abort();
|
|
98168
|
-
|
|
98415
|
+
resolve3();
|
|
98169
98416
|
}, timeoutMs);
|
|
98170
98417
|
timeout.unref();
|
|
98171
98418
|
})
|
|
@@ -98394,7 +98641,7 @@ async function siblingsFetchImpl(dependencies) {
|
|
|
98394
98641
|
function shortAddress3(address4) {
|
|
98395
98642
|
return address4.length <= 12 ? address4 : `${address4.slice(0, 6)}\u2026${address4.slice(-4)}`;
|
|
98396
98643
|
}
|
|
98397
|
-
async function accountsAddCommand(argv, json2, io, dependencies) {
|
|
98644
|
+
async function accountsAddCommand(argv, json2, io, dependencies, options = { link: "always" }) {
|
|
98398
98645
|
const parsed = parseArguments(argv, {
|
|
98399
98646
|
valueOptions: /* @__PURE__ */ new Set(["--label"]),
|
|
98400
98647
|
booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
|
|
@@ -98411,6 +98658,18 @@ async function accountsAddCommand(argv, json2, io, dependencies) {
|
|
|
98411
98658
|
});
|
|
98412
98659
|
await recordAudit(dependencies, "wallet.create", { wallet: created.account });
|
|
98413
98660
|
const address4 = created.address;
|
|
98661
|
+
if (options.link === "offer") {
|
|
98662
|
+
if (!json2) io.stdout(`Account ${created.account} derived: ${address4}`);
|
|
98663
|
+
const link3 = await offerDashboardLink({
|
|
98664
|
+
name: created.account,
|
|
98665
|
+
json: json2,
|
|
98666
|
+
noLink: parsed.has("--no-link"),
|
|
98667
|
+
io,
|
|
98668
|
+
dependencies
|
|
98669
|
+
});
|
|
98670
|
+
if (json2) io.stdout(JSON.stringify({ account: created.account, address: address4, ...link3 }));
|
|
98671
|
+
return;
|
|
98672
|
+
}
|
|
98414
98673
|
if (parsed.has("--no-link")) {
|
|
98415
98674
|
output2(
|
|
98416
98675
|
io,
|
|
@@ -99226,10 +99485,10 @@ async function autoUploadBackup(io, json2, dependencies) {
|
|
|
99226
99485
|
const timeoutMs = dependencies.cloudBackup?.uploadTimeoutMs ?? DEFAULT_UPLOAD_TIMEOUT_MS;
|
|
99227
99486
|
const controller = new AbortController();
|
|
99228
99487
|
let timer;
|
|
99229
|
-
const timeout = new Promise((
|
|
99488
|
+
const timeout = new Promise((resolve3) => {
|
|
99230
99489
|
timer = setTimeout(() => {
|
|
99231
99490
|
controller.abort();
|
|
99232
|
-
|
|
99491
|
+
resolve3({ status: "skipped", reason: "timeout" });
|
|
99233
99492
|
}, timeoutMs);
|
|
99234
99493
|
timer.unref();
|
|
99235
99494
|
});
|
|
@@ -100453,7 +100712,7 @@ var HTTP_NOT_FOUND_PATTERN = /\b404\b/u;
|
|
|
100453
100712
|
var OTHER_SCOPE_PATTERN = /\b(?:project|environment|service|workspace|team|token|user|account|volume|deployment|command|file|directory|module|package)s?\b/iu;
|
|
100454
100713
|
var SIDECAR_SUFFIX = ".railway.json";
|
|
100455
100714
|
var MINIMUM_SECRET_LENGTH = 8;
|
|
100456
|
-
var defaultRailwayExec = (file2, args) => new Promise((
|
|
100715
|
+
var defaultRailwayExec = (file2, args) => new Promise((resolve3, reject) => {
|
|
100457
100716
|
const child = spawn2(file2, [...args], {
|
|
100458
100717
|
stdio: ["ignore", "pipe", "pipe"],
|
|
100459
100718
|
env: process.env,
|
|
@@ -100468,7 +100727,7 @@ var defaultRailwayExec = (file2, args) => new Promise((resolve2, reject) => {
|
|
|
100468
100727
|
stderr2 += chunk;
|
|
100469
100728
|
});
|
|
100470
100729
|
child.once("error", reject);
|
|
100471
|
-
child.once("close", (code) =>
|
|
100730
|
+
child.once("close", (code) => resolve3({ code, stdout, stderr: stderr2 }));
|
|
100472
100731
|
});
|
|
100473
100732
|
function parseSandboxId(stdout) {
|
|
100474
100733
|
const trimmed = stdout.trim();
|
|
@@ -100601,8 +100860,8 @@ function createRailwayRuntime(options) {
|
|
|
100601
100860
|
const readyAttempts = options.readyAttempts ?? DEFAULT_RAILWAY_READY_ATTEMPTS;
|
|
100602
100861
|
const readyIntervalMs = options.readyIntervalMs ?? DEFAULT_RAILWAY_READY_INTERVAL_MS;
|
|
100603
100862
|
const signalDestroyTimeoutMs = options.signalDestroyTimeoutMs ?? DEFAULT_RAILWAY_SIGNAL_DESTROY_TIMEOUT_MS;
|
|
100604
|
-
const sleep = options.sleep ?? ((milliseconds) => new Promise((
|
|
100605
|
-
setTimeout(
|
|
100863
|
+
const sleep = options.sleep ?? ((milliseconds) => new Promise((resolve3) => {
|
|
100864
|
+
setTimeout(resolve3, milliseconds);
|
|
100606
100865
|
}));
|
|
100607
100866
|
let secrets = options.secrets;
|
|
100608
100867
|
const getSecrets = () => secrets ??= secretStore();
|
|
@@ -101520,7 +101779,7 @@ function createLocalRuntime(options) {
|
|
|
101520
101779
|
const processCommand = options.processCommand ?? defaultProcessCommand;
|
|
101521
101780
|
const ownsProcess = (handle, pid) => processCommand(pid)?.includes(runResultPath(home, handle.runId)) === true;
|
|
101522
101781
|
const closeFd = options.closeFd ?? closeSync2;
|
|
101523
|
-
const
|
|
101782
|
+
const readFile30 = options.readFile ?? nodeReadFile;
|
|
101524
101783
|
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
101525
101784
|
const openLog = options.openLog ?? ((path) => {
|
|
101526
101785
|
mkdirSync2(runsDirectory(home), { recursive: true, mode: 448 });
|
|
@@ -101575,7 +101834,7 @@ function createLocalRuntime(options) {
|
|
|
101575
101834
|
return handle;
|
|
101576
101835
|
},
|
|
101577
101836
|
async status(handle) {
|
|
101578
|
-
const result = await readResultFile(
|
|
101837
|
+
const result = await readResultFile(readFile30, runResultPath(home, handle.runId));
|
|
101579
101838
|
if (result !== void 0) return result;
|
|
101580
101839
|
const pid = localPid(handle);
|
|
101581
101840
|
if (pid === void 0 || handle.kind !== "local") {
|
|
@@ -101678,10 +101937,10 @@ function childArguments(member, run) {
|
|
|
101678
101937
|
...run.drawUsd ? ["--draw", run.drawUsd] : []
|
|
101679
101938
|
];
|
|
101680
101939
|
}
|
|
101681
|
-
async function readResultFile(
|
|
101940
|
+
async function readResultFile(readFile30, path) {
|
|
101682
101941
|
let text;
|
|
101683
101942
|
try {
|
|
101684
|
-
text = await
|
|
101943
|
+
text = await readFile30(path, "utf8");
|
|
101685
101944
|
} catch (error61) {
|
|
101686
101945
|
if (hasCode3(error61, "ENOENT")) return void 0;
|
|
101687
101946
|
return { state: "failed", detail: "unreadable result file" };
|
|
@@ -102455,7 +102714,7 @@ function usd(value, minimumDecimals = 0) {
|
|
|
102455
102714
|
import { mkdir as mkdir20, readFile as readFile27, writeFile as writeFile11 } from "node:fs/promises";
|
|
102456
102715
|
import { homedir as systemHomedir } from "node:os";
|
|
102457
102716
|
import { dirname as dirname14, posix, win32 as win322 } from "node:path";
|
|
102458
|
-
var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--json]";
|
|
102717
|
+
var MCP_INSTALL_USAGE = "Usage: vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]";
|
|
102459
102718
|
var APPS = /* @__PURE__ */ new Set(["claude", "cursor", "codex"]);
|
|
102460
102719
|
var NEXT_STEP = {
|
|
102461
102720
|
claude: 'Restart Claude Desktop, then ask it: "Search vAPI for a weather API."',
|
|
@@ -102496,6 +102755,7 @@ function mcpInstallTarget(app, context) {
|
|
|
102496
102755
|
async function mcpInstallCommand(argv, json2, io, dependencies) {
|
|
102497
102756
|
const parsed = parseArguments(argv, {
|
|
102498
102757
|
valueOptions: /* @__PURE__ */ new Set(["--home", "--registry"]),
|
|
102758
|
+
booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
|
|
102499
102759
|
maximumPositionals: 1
|
|
102500
102760
|
});
|
|
102501
102761
|
const appValue = parsed.positionals[0];
|
|
@@ -102517,13 +102777,39 @@ ${MCP_INSTALL_USAGE}`
|
|
|
102517
102777
|
});
|
|
102518
102778
|
const entry = serverEntry(home, registry2);
|
|
102519
102779
|
const created = await writeMcpConfig(target, entry);
|
|
102780
|
+
const name = await unlinkedDefaultAccount(home, dependencies);
|
|
102781
|
+
const offerLink = (name2) => offerDashboardLink({
|
|
102782
|
+
name: name2,
|
|
102783
|
+
json: json2,
|
|
102784
|
+
noLink: parsed.has("--no-link"),
|
|
102785
|
+
io,
|
|
102786
|
+
dependencies,
|
|
102787
|
+
home,
|
|
102788
|
+
apiBase: parsed.one("--registry")
|
|
102789
|
+
});
|
|
102790
|
+
const link3 = json2 && name !== void 0 ? await offerLink(name) : {};
|
|
102520
102791
|
output3(
|
|
102521
102792
|
io,
|
|
102522
102793
|
json2,
|
|
102523
|
-
{ command: "mcp install", app: appValue, path: target.path, created, home, registry: registry2 },
|
|
102794
|
+
{ ...link3, command: "mcp install", app: appValue, path: target.path, created, home, registry: registry2 },
|
|
102524
102795
|
`${created ? "Wrote" : "Updated"} ${target.path}.`
|
|
102525
102796
|
);
|
|
102526
|
-
if (!json2)
|
|
102797
|
+
if (!json2) {
|
|
102798
|
+
io.stdout(NEXT_STEP[appValue]);
|
|
102799
|
+
if (name !== void 0) await offerLink(name);
|
|
102800
|
+
}
|
|
102801
|
+
}
|
|
102802
|
+
async function unlinkedDefaultAccount(home, dependencies) {
|
|
102803
|
+
try {
|
|
102804
|
+
const store = await WalletStore.open(home, {
|
|
102805
|
+
secrets: getSecretStore(dependencies),
|
|
102806
|
+
env: getEnvironment(dependencies)
|
|
102807
|
+
});
|
|
102808
|
+
const name = store.defaultName;
|
|
102809
|
+
if (name !== void 0 && store.resolve({ name }).entry.link === void 0) return name;
|
|
102810
|
+
} catch {
|
|
102811
|
+
}
|
|
102812
|
+
return void 0;
|
|
102527
102813
|
}
|
|
102528
102814
|
function isMcpInstallApp(value) {
|
|
102529
102815
|
return APPS.has(value);
|
|
@@ -102531,7 +102817,7 @@ function isMcpInstallApp(value) {
|
|
|
102531
102817
|
function serverEntry(home, registry2) {
|
|
102532
102818
|
return {
|
|
102533
102819
|
command: "npx",
|
|
102534
|
-
args: ["-y", "vapi-network", "mcp"],
|
|
102820
|
+
args: ["-y", "vapi-network@latest", "mcp"],
|
|
102535
102821
|
env: { VAPI_HOME: home, VAPI_REGISTRY_URL: registry2 }
|
|
102536
102822
|
};
|
|
102537
102823
|
}
|
|
@@ -102580,7 +102866,7 @@ function tomlConfig(existing, entry) {
|
|
|
102580
102866
|
const block = [
|
|
102581
102867
|
"[mcp_servers.vapi]",
|
|
102582
102868
|
'command = "npx"',
|
|
102583
|
-
'args = ["-y", "vapi-network", "mcp"]',
|
|
102869
|
+
'args = ["-y", "vapi-network@latest", "mcp"]',
|
|
102584
102870
|
`env = { VAPI_HOME = "${escapeToml(entry.env.VAPI_HOME)}", VAPI_REGISTRY_URL = "${escapeToml(entry.env.VAPI_REGISTRY_URL)}" }`,
|
|
102585
102871
|
""
|
|
102586
102872
|
].join("\n");
|
|
@@ -102747,13 +103033,13 @@ async function sendConfig(dependencies) {
|
|
|
102747
103033
|
// ../cli/src/setup.ts
|
|
102748
103034
|
import { rm as rm5 } from "node:fs/promises";
|
|
102749
103035
|
import { join as join26 } from "node:path";
|
|
102750
|
-
var SETUP_ARGUMENT_ERROR =
|
|
103036
|
+
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
103037
|
var VAULT_CHOICE = "Create a new vault, or restore one from a recovery phrase? [new/restore] ";
|
|
102752
103038
|
async function setupCommand(argv, json2, io, dependencies) {
|
|
102753
103039
|
let parsed;
|
|
102754
103040
|
try {
|
|
102755
103041
|
parsed = parseArguments(argv, {
|
|
102756
|
-
valueOptions: /* @__PURE__ */ new Set(),
|
|
103042
|
+
valueOptions: /* @__PURE__ */ new Set(["--accounts"]),
|
|
102757
103043
|
booleanOptions: /* @__PURE__ */ new Set(["--no-cloud-backup"]),
|
|
102758
103044
|
maximumPositionals: 0
|
|
102759
103045
|
});
|
|
@@ -102764,6 +103050,7 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
102764
103050
|
const paths = getVapiPaths();
|
|
102765
103051
|
const steps = [];
|
|
102766
103052
|
const humanIo = json2 ? stderrIo(io) : io;
|
|
103053
|
+
const accountCount = parseAccountCount(parsed.one("--accounts"));
|
|
102767
103054
|
if (!await fileExists2(paths.config)) {
|
|
102768
103055
|
await writeDefaultConfig(paths.config, process.env, { networks: ["base"] });
|
|
102769
103056
|
steps.push("config");
|
|
@@ -102774,6 +103061,7 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
102774
103061
|
let changedVault = false;
|
|
102775
103062
|
let changedAccount = false;
|
|
102776
103063
|
let changedLink = false;
|
|
103064
|
+
let scannedAddresses;
|
|
102777
103065
|
if (!await fileExists2(join26(paths.directory, "vault.json"))) {
|
|
102778
103066
|
const choice = await vaultChoice(dependencies);
|
|
102779
103067
|
if (choice === "restore") {
|
|
@@ -102781,12 +103069,14 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
102781
103069
|
throw new Error("Restoring needs a terminal to type the phrase.");
|
|
102782
103070
|
}
|
|
102783
103071
|
const readSecret = dependencies.prompts?.secret ?? promptForSecret;
|
|
102784
|
-
await restoreVaultFromPhrase(
|
|
103072
|
+
const restored = await restoreVaultFromPhrase(
|
|
102785
103073
|
await readSecret("Recovery phrase: "),
|
|
102786
103074
|
config2,
|
|
102787
103075
|
humanIo,
|
|
102788
|
-
dependencies
|
|
103076
|
+
dependencies,
|
|
103077
|
+
accountCount
|
|
102789
103078
|
);
|
|
103079
|
+
scannedAddresses = restored.scannedAddresses;
|
|
102790
103080
|
store = await WalletStore.open(paths.directory, {
|
|
102791
103081
|
secrets: getSecretStore(dependencies),
|
|
102792
103082
|
env: dependencies.env ?? process.env,
|
|
@@ -102839,22 +103129,35 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
102839
103129
|
}
|
|
102840
103130
|
if (json2) {
|
|
102841
103131
|
io.stdout(
|
|
102842
|
-
JSON.stringify({
|
|
103132
|
+
JSON.stringify({
|
|
103133
|
+
vault,
|
|
103134
|
+
account,
|
|
103135
|
+
address: address4,
|
|
103136
|
+
linked,
|
|
103137
|
+
steps,
|
|
103138
|
+
cloudBackup,
|
|
103139
|
+
...scannedAddresses === void 0 ? {} : { scannedAddresses }
|
|
103140
|
+
})
|
|
102843
103141
|
);
|
|
102844
103142
|
}
|
|
102845
103143
|
}
|
|
102846
|
-
async function restoreVaultFromPhrase(phrase, config2, io, dependencies) {
|
|
103144
|
+
async function restoreVaultFromPhrase(phrase, config2, io, dependencies, accountCount) {
|
|
102847
103145
|
const paths = getVapiPaths();
|
|
102848
103146
|
const validatedPhrase = validateRecoveryPhrase(phrase);
|
|
102849
103147
|
const readBalance3 = baseUsdcBalanceReader(config2, dependencies);
|
|
102850
103148
|
const key2 = await loadOrCreateDeviceKey({ secrets: getSecretStore(dependencies) });
|
|
102851
103149
|
let names;
|
|
103150
|
+
let scannedAddresses = 0;
|
|
102852
103151
|
try {
|
|
102853
103152
|
const restored = await restoreVault({
|
|
102854
103153
|
path: join26(paths.directory, "vault.json"),
|
|
102855
103154
|
key: key2,
|
|
102856
103155
|
phrase: validatedPhrase,
|
|
102857
103156
|
probe: async (address4) => await readBalance3(address4) > 0n,
|
|
103157
|
+
...accountCount === void 0 ? {} : { accountCount },
|
|
103158
|
+
onScanComplete: (count) => {
|
|
103159
|
+
scannedAddresses = count;
|
|
103160
|
+
},
|
|
102858
103161
|
...dependencies.now === void 0 ? {} : { now: dependencies.now }
|
|
102859
103162
|
});
|
|
102860
103163
|
names = restored.accounts().map((account) => account.name);
|
|
@@ -102866,8 +103169,25 @@ async function restoreVaultFromPhrase(phrase, config2, io, dependencies) {
|
|
|
102866
103169
|
...names[0] === void 0 ? {} : { wallet: names[0] },
|
|
102867
103170
|
detail: `${names.length} account(s)`
|
|
102868
103171
|
});
|
|
102869
|
-
io.stdout(
|
|
102870
|
-
|
|
103172
|
+
io.stdout(
|
|
103173
|
+
`Vault restored with ${names.length} account(s): ${names.join(", ")}. ${scannedAddresses} address(es) scanned.`
|
|
103174
|
+
);
|
|
103175
|
+
return { names, scannedAddresses };
|
|
103176
|
+
}
|
|
103177
|
+
function parseAccountCount(value) {
|
|
103178
|
+
if (value === void 0) return void 0;
|
|
103179
|
+
if (!/^\d+$/u.test(value)) {
|
|
103180
|
+
throw new UsageError(
|
|
103181
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
103182
|
+
);
|
|
103183
|
+
}
|
|
103184
|
+
const count = Number(value);
|
|
103185
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > MAX_RESTORE_ACCOUNTS) {
|
|
103186
|
+
throw new UsageError(
|
|
103187
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
103188
|
+
);
|
|
103189
|
+
}
|
|
103190
|
+
return count;
|
|
102871
103191
|
}
|
|
102872
103192
|
async function vaultChoice(dependencies) {
|
|
102873
103193
|
const answer = dependencies.prompts?.line === void 0 ? isInteractive(dependencies) ? await promptForLine(VAULT_CHOICE) : "" : await dependencies.prompts.line(VAULT_CHOICE);
|
|
@@ -103159,7 +103479,7 @@ async function taskContext(parsed, io, dependencies, publicOnly = false) {
|
|
|
103159
103479
|
pending,
|
|
103160
103480
|
randomUUID: dependencies.tasks?.randomUUID ?? randomUUID6,
|
|
103161
103481
|
signInHint: "Run vapi login for the acting wallet.",
|
|
103162
|
-
sleep: dependencies.tasks?.sleep ?? ((milliseconds) => new Promise((
|
|
103482
|
+
sleep: dependencies.tasks?.sleep ?? ((milliseconds) => new Promise((resolve3) => setTimeout(resolve3, milliseconds)))
|
|
103163
103483
|
};
|
|
103164
103484
|
}
|
|
103165
103485
|
async function taskRequest2(verb, route, operation) {
|
|
@@ -104959,11 +105279,11 @@ ${usage}`);
|
|
|
104959
105279
|
}
|
|
104960
105280
|
}
|
|
104961
105281
|
async function referencedSleep(milliseconds, signal) {
|
|
104962
|
-
await new Promise((
|
|
105282
|
+
await new Promise((resolve3) => {
|
|
104963
105283
|
const finish = () => {
|
|
104964
105284
|
clearTimeout(timer);
|
|
104965
105285
|
signal?.removeEventListener("abort", finish);
|
|
104966
|
-
|
|
105286
|
+
resolve3();
|
|
104967
105287
|
};
|
|
104968
105288
|
const timer = setTimeout(finish, milliseconds);
|
|
104969
105289
|
if (signal === void 0) return;
|
|
@@ -104975,6 +105295,7 @@ async function referencedSleep(milliseconds, signal) {
|
|
|
104975
105295
|
// ../cli/src/vault.ts
|
|
104976
105296
|
import { join as join27 } from "node:path";
|
|
104977
105297
|
var VAULT_USAGE = "Usage: vapi vault protect|unprotect|lock|unlock|status [--json]";
|
|
105298
|
+
var RESTORE_USAGE = "Usage: vapi restore [--accounts <n> | --from-owner [--owner <0x\u2026>]] [--json]";
|
|
104978
105299
|
var LEGACY_PASSWORD_NOTICE = "VAPI_KEYSTORE_PASSWORD is deprecated for vault passwords; use VAPI_VAULT_PASSWORD instead.";
|
|
104979
105300
|
async function vaultCommand(argv, json2, io, dependencies) {
|
|
104980
105301
|
const subcommand = argv[0];
|
|
@@ -105004,9 +105325,17 @@ async function restoreCommand(argv, json2, io, dependencies) {
|
|
|
105004
105325
|
await restoreFromOwnerCommand(argv, json2, io, dependencies);
|
|
105005
105326
|
return;
|
|
105006
105327
|
}
|
|
105007
|
-
|
|
105008
|
-
|
|
105328
|
+
let parsed;
|
|
105329
|
+
try {
|
|
105330
|
+
parsed = parseArguments(argv, {
|
|
105331
|
+
valueOptions: /* @__PURE__ */ new Set(["--accounts"]),
|
|
105332
|
+
maximumPositionals: 0
|
|
105333
|
+
});
|
|
105334
|
+
} catch (error61) {
|
|
105335
|
+
if (error61 instanceof UsageError) throw new UsageError(RESTORE_USAGE);
|
|
105336
|
+
throw error61;
|
|
105009
105337
|
}
|
|
105338
|
+
const accountCount = parseRestoreAccountCount(parsed.one("--accounts"));
|
|
105010
105339
|
const paths = getVapiPaths();
|
|
105011
105340
|
const path = join27(paths.directory, "vault.json");
|
|
105012
105341
|
if (await fileExists2(path)) {
|
|
@@ -105020,13 +105349,39 @@ async function restoreCommand(argv, json2, io, dependencies) {
|
|
|
105020
105349
|
const config2 = await readConfig(paths.config, json2 ? quietIo(io) : io);
|
|
105021
105350
|
const phrase = isStdinInteractive(dependencies) ? await getPrompts(dependencies).secret("Recovery phrase: ") : await (dependencies.readStdin ?? readProcessStdin3)();
|
|
105022
105351
|
const restoreIo = json2 ? quietIo(io) : io;
|
|
105023
|
-
const { names } = await restoreVaultFromPhrase(
|
|
105352
|
+
const { names, scannedAddresses } = await restoreVaultFromPhrase(
|
|
105353
|
+
phrase.trim(),
|
|
105354
|
+
config2,
|
|
105355
|
+
restoreIo,
|
|
105356
|
+
dependencies,
|
|
105357
|
+
accountCount
|
|
105358
|
+
);
|
|
105024
105359
|
if (json2) {
|
|
105025
|
-
output3(
|
|
105360
|
+
output3(
|
|
105361
|
+
io,
|
|
105362
|
+
true,
|
|
105363
|
+
{ command: "restore", vault: "restored", accounts: names, scannedAddresses },
|
|
105364
|
+
""
|
|
105365
|
+
);
|
|
105026
105366
|
return;
|
|
105027
105367
|
}
|
|
105028
105368
|
io.stdout(`Run vapi setup to link ${names[0]}.`);
|
|
105029
105369
|
}
|
|
105370
|
+
function parseRestoreAccountCount(value) {
|
|
105371
|
+
if (value === void 0) return void 0;
|
|
105372
|
+
if (!/^\d+$/u.test(value)) {
|
|
105373
|
+
throw new UsageError(
|
|
105374
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
105375
|
+
);
|
|
105376
|
+
}
|
|
105377
|
+
const count = Number(value);
|
|
105378
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > MAX_RESTORE_ACCOUNTS) {
|
|
105379
|
+
throw new UsageError(
|
|
105380
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
105381
|
+
);
|
|
105382
|
+
}
|
|
105383
|
+
return count;
|
|
105384
|
+
}
|
|
105030
105385
|
async function protectCommand(argv, json2, io, dependencies) {
|
|
105031
105386
|
requireNoArguments(argv);
|
|
105032
105387
|
const env = getEnvironment(dependencies);
|
|
@@ -105156,8 +105511,8 @@ var HELP_HEADING = "vAPI Network";
|
|
|
105156
105511
|
var HELP = `${HELP_HEADING}
|
|
105157
105512
|
|
|
105158
105513
|
Usage:
|
|
105159
|
-
vapi init [--networks <base,arc
|
|
105160
|
-
vapi setup [--no-cloud-backup] [--json]
|
|
105514
|
+
vapi init [--networks <base,arc>] [--no-link] [--json]
|
|
105515
|
+
vapi setup [--no-cloud-backup] [--accounts <n>] [--json]
|
|
105161
105516
|
vapi accounts [--all] [--json]
|
|
105162
105517
|
vapi accounts add <name> [--label <text>] [--no-link] [--json]
|
|
105163
105518
|
vapi accounts import <name> [--keystore <path> | --key-file <path>] [--label <text>] [--json]
|
|
@@ -105187,7 +105542,7 @@ Usage:
|
|
|
105187
105542
|
vapi docs read <url-or-path> [--json]
|
|
105188
105543
|
vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--json]
|
|
105189
105544
|
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]
|
|
105545
|
+
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
105546
|
vapi pay --resume <receipt-id> [--json]
|
|
105192
105547
|
vapi check <url> [--method <method>] [--json]
|
|
105193
105548
|
vapi balance [--account <name>] [--json]
|
|
@@ -105203,6 +105558,7 @@ Usage:
|
|
|
105203
105558
|
vapi agent pause <name> [--json]
|
|
105204
105559
|
vapi agent resume <name> [--json]
|
|
105205
105560
|
vapi agent revoke <name> [--json]
|
|
105561
|
+
vapi dashboard [--account <name>] [--no-browser] [--json]
|
|
105206
105562
|
vapi login [--account <name>] [--label <name>] [--publish] [--no-browser] [--json]
|
|
105207
105563
|
vapi logout [--account <name>] [--json]
|
|
105208
105564
|
vapi whoami [--account <name>] [--json]
|
|
@@ -105233,8 +105589,8 @@ Usage:
|
|
|
105233
105589
|
vapi task status <id> [--account <name>] [--json]
|
|
105234
105590
|
vapi export-key [--network <caip2>] [--account <name>] [--json]
|
|
105235
105591
|
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
|
|
105592
|
+
vapi restore [--accounts <n> | --from-owner [--owner <0x\u2026>]] [--json]
|
|
105593
|
+
vapi import (--phrase | --key) [--account <name>] [--networks <base,arc>] [--replace] [--force] [--json]
|
|
105238
105594
|
vapi passphrase [--account <name>] [--json]
|
|
105239
105595
|
vapi vault protect [--json]
|
|
105240
105596
|
vapi vault unprotect [--json]
|
|
@@ -105253,15 +105609,19 @@ Usage:
|
|
|
105253
105609
|
vapi publish list [--json]
|
|
105254
105610
|
vapi claim <origin> [--account <name>] [--json]
|
|
105255
105611
|
vapi mcp [--account <name>] [--json]
|
|
105256
|
-
vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--json]
|
|
105612
|
+
vapi mcp install <claude|cursor|codex> [--home <dir>] [--registry <url>] [--no-link] [--json]
|
|
105257
105613
|
vapi serve [--json]
|
|
105258
105614
|
vapi version [--json]
|
|
105259
105615
|
vapi help [--json]
|
|
105260
105616
|
|
|
105617
|
+
\`vapi init\`, \`vapi wallet create\` and \`vapi mcp install\` offer to link the wallet to your vAPI dashboard. Use \`--no-link\` to skip the prompt.
|
|
105618
|
+
|
|
105261
105619
|
Every command that touches a wallet takes \`--account <name>\`, falls back to \`VAPI_WALLET\`, then to the default account set by \`vapi accounts use\`, and names the wallet it used on its first line.
|
|
105262
105620
|
|
|
105263
105621
|
\`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
105622
|
|
|
105623
|
+
Solana listings remain searchable; inspect and pay return \`unsupported_network\`. Solana keys are not part of the device vault yet.
|
|
105624
|
+
|
|
105265
105625
|
\`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
105626
|
|
|
105267
105627
|
\`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 +105634,7 @@ Every command that touches a wallet takes \`--account <name>\`, falls back to \`
|
|
|
105274
105634
|
|
|
105275
105635
|
\`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
105636
|
|
|
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
|
|
105637
|
+
\`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
105638
|
|
|
105279
105639
|
\`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
105640
|
|
|
@@ -105320,8 +105680,8 @@ var ACCOUNT_OPTION2 = "--account";
|
|
|
105320
105680
|
var WALLET_OPTION_DEPRECATION = "--wallet is now --account; --wallet keeps working for one release.";
|
|
105321
105681
|
var SOLANA_VAULT_UNAVAILABLE2 = "Solana keys are not part of the device vault yet.";
|
|
105322
105682
|
var INCLUDE_UNVERIFIED_OPTION = "--include-unverified";
|
|
105323
|
-
async function openWalletStore(dependencies) {
|
|
105324
|
-
return await WalletStore.open(
|
|
105683
|
+
async function openWalletStore(dependencies, home = getVapiPaths().directory) {
|
|
105684
|
+
return await WalletStore.open(home, {
|
|
105325
105685
|
secrets: getSecretStore(dependencies),
|
|
105326
105686
|
env: getEnvironment(dependencies),
|
|
105327
105687
|
...dependencies.now === void 0 ? {} : { now: dependencies.now }
|
|
@@ -105336,8 +105696,8 @@ async function selectWallet(store, parsed, dependencies) {
|
|
|
105336
105696
|
const address4 = await store.readAddress(resolved.name);
|
|
105337
105697
|
return { store, ...resolved, ...address4 === void 0 ? {} : { address: address4 } };
|
|
105338
105698
|
}
|
|
105339
|
-
async function targetWallet(parsed, dependencies) {
|
|
105340
|
-
return await selectWallet(await openWalletStore(dependencies), parsed, dependencies);
|
|
105699
|
+
async function targetWallet(parsed, dependencies, home = getVapiPaths().directory) {
|
|
105700
|
+
return await selectWallet(await openWalletStore(dependencies, home), parsed, dependencies);
|
|
105341
105701
|
}
|
|
105342
105702
|
function getSecretStore(dependencies) {
|
|
105343
105703
|
return dependencies.secretStore ?? secretStore();
|
|
@@ -105516,6 +105876,10 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
105516
105876
|
case "agent":
|
|
105517
105877
|
exitCode = await agentCommand(args.slice(1), json2, runIo, dependencies);
|
|
105518
105878
|
break;
|
|
105879
|
+
case "dashboard":
|
|
105880
|
+
await dashboardCommand(args.slice(1), json2, io, dependencies);
|
|
105881
|
+
exitCode = 0;
|
|
105882
|
+
break;
|
|
105519
105883
|
case "login":
|
|
105520
105884
|
await loginCommand(args.slice(1), json2, io, dependencies);
|
|
105521
105885
|
exitCode = 0;
|
|
@@ -105730,6 +106094,7 @@ function shouldAutoUploadAfterFailure(args) {
|
|
|
105730
106094
|
async function initCommand(argv, json2, io, dependencies) {
|
|
105731
106095
|
const parsed = parseArguments(argv, {
|
|
105732
106096
|
valueOptions: /* @__PURE__ */ new Set(["--networks"]),
|
|
106097
|
+
booleanOptions: /* @__PURE__ */ new Set(["--no-link"]),
|
|
105733
106098
|
maximumPositionals: 0
|
|
105734
106099
|
});
|
|
105735
106100
|
const networks = parseInitNetworks(parsed.one("--networks") ?? "base");
|
|
@@ -105777,7 +106142,14 @@ async function initCommand(argv, json2, io, dependencies) {
|
|
|
105777
106142
|
nextSteps: buildNextSteps(account.address)
|
|
105778
106143
|
};
|
|
105779
106144
|
if (json2) {
|
|
105780
|
-
|
|
106145
|
+
const link3 = await offerDashboardLink({
|
|
106146
|
+
name: created.name,
|
|
106147
|
+
json: json2,
|
|
106148
|
+
noLink: parsed.has("--no-link"),
|
|
106149
|
+
io,
|
|
106150
|
+
dependencies
|
|
106151
|
+
});
|
|
106152
|
+
io.stdout(JSON.stringify({ ...result, ...link3 }));
|
|
105781
106153
|
return;
|
|
105782
106154
|
}
|
|
105783
106155
|
if (configRewrites.length > 0) io.stdout(formatLegacyRegistryRewrites(configRewrites));
|
|
@@ -105798,6 +106170,13 @@ async function initCommand(argv, json2, io, dependencies) {
|
|
|
105798
106170
|
io.stdout(formatAccounts(accounts));
|
|
105799
106171
|
io.stdout("");
|
|
105800
106172
|
io.stdout(result.nextSteps.join("\n"));
|
|
106173
|
+
await offerDashboardLink({
|
|
106174
|
+
name: created.name,
|
|
106175
|
+
json: json2,
|
|
106176
|
+
noLink: parsed.has("--no-link"),
|
|
106177
|
+
io,
|
|
106178
|
+
dependencies
|
|
106179
|
+
});
|
|
105801
106180
|
}
|
|
105802
106181
|
var INIT_ALREADY_DONE = "This machine already has a wallet, so vapi init created nothing.";
|
|
105803
106182
|
async function reportExistingWallets(store, json2, io, dependencies) {
|
|
@@ -105833,12 +106212,11 @@ async function walletCommand(argv, json2, io, dependencies) {
|
|
|
105833
106212
|
`Unknown wallet subcommand ${JSON.stringify(subcommand)}. ${WALLET_USAGE}`
|
|
105834
106213
|
);
|
|
105835
106214
|
}
|
|
105836
|
-
|
|
105837
|
-
|
|
105838
|
-
|
|
105839
|
-
|
|
105840
|
-
|
|
105841
|
-
);
|
|
106215
|
+
if (subcommand === "create") {
|
|
106216
|
+
await accountsAddCommand(rest, json2, io, dependencies, { link: "offer" });
|
|
106217
|
+
return;
|
|
106218
|
+
}
|
|
106219
|
+
await accountsCommand([mapped2, ...rest], json2, io, dependencies);
|
|
105842
106220
|
}
|
|
105843
106221
|
async function unlockedWallets(walletsStore, wallets, dependencies) {
|
|
105844
106222
|
const secrets = getSecretStore(dependencies);
|
|
@@ -106063,7 +106441,7 @@ async function inspectCommand(argv, json2, io, dependencies) {
|
|
|
106063
106441
|
);
|
|
106064
106442
|
output3(io, json2, result, formatInspect(result));
|
|
106065
106443
|
}
|
|
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]";
|
|
106444
|
+
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
106445
|
async function payCommand(argv, json2, io, dependencies) {
|
|
106068
106446
|
if (argv.includes(RESUME_OPTION)) {
|
|
106069
106447
|
await payResumeCommand(argv, json2, io, dependencies);
|
|
@@ -106079,11 +106457,13 @@ async function payCommand(argv, json2, io, dependencies) {
|
|
|
106079
106457
|
"--expected-pay-to",
|
|
106080
106458
|
"--max",
|
|
106081
106459
|
"--max-price-usd",
|
|
106460
|
+
"--timeout",
|
|
106082
106461
|
WALLET_OPTION5
|
|
106083
106462
|
]),
|
|
106084
106463
|
maximumPositionals: 1
|
|
106085
106464
|
});
|
|
106086
106465
|
const target = requiredPositional(parsed.positionals[0], "<id-or-url>", PAY_USAGE);
|
|
106466
|
+
const timeoutSeconds = optionalBoundedInteger(parsed.one("--timeout"), "--timeout", 1, 300);
|
|
106087
106467
|
const paths = getVapiPaths();
|
|
106088
106468
|
const config2 = await readConfig(paths.config, io);
|
|
106089
106469
|
const wallet = await targetWallet(parsed, dependencies);
|
|
@@ -106099,7 +106479,8 @@ async function payCommand(argv, json2, io, dependencies) {
|
|
|
106099
106479
|
...parsed.one("--content-type") ? { contentType: parsed.one("--content-type") } : {},
|
|
106100
106480
|
...parsed.one("--network") ? { network: parsed.one("--network") } : {},
|
|
106101
106481
|
...parsed.one("--expected-pay-to") ? { expectedPayTo: parsed.one("--expected-pay-to") } : {},
|
|
106102
|
-
...maxPriceUsd ? { maxPriceUsd } : {}
|
|
106482
|
+
...maxPriceUsd ? { maxPriceUsd } : {},
|
|
106483
|
+
...timeoutSeconds === void 0 ? {} : { timeoutSeconds }
|
|
106103
106484
|
};
|
|
106104
106485
|
const call2 = createCallPort({
|
|
106105
106486
|
config: config2,
|
|
@@ -106377,8 +106758,8 @@ async function fetchNetworkStats(dependencies) {
|
|
|
106377
106758
|
})();
|
|
106378
106759
|
let timeout;
|
|
106379
106760
|
try {
|
|
106380
|
-
const timedOut = new Promise((
|
|
106381
|
-
timeout = setTimeout(() =>
|
|
106761
|
+
const timedOut = new Promise((resolve3) => {
|
|
106762
|
+
timeout = setTimeout(() => resolve3(null), NETWORK_STATS_REQUEST_TIMEOUT_MS);
|
|
106382
106763
|
});
|
|
106383
106764
|
return await Promise.race([request, timedOut]);
|
|
106384
106765
|
} finally {
|
|
@@ -107774,7 +108155,7 @@ function buildNextSteps(address4) {
|
|
|
107774
108155
|
formatNextStep("Pay", "vapi pay <ref> --max 0.02"),
|
|
107775
108156
|
formatNextStep(
|
|
107776
108157
|
"Agent",
|
|
107777
|
-
'add {"command":"npx","args":["-y","vapi-network","mcp"]} to your MCP config'
|
|
108158
|
+
'add {"command":"npx","args":["-y","vapi-network@latest","mcp"]} to your MCP config'
|
|
107778
108159
|
)
|
|
107779
108160
|
];
|
|
107780
108161
|
}
|
|
@@ -107955,6 +108336,17 @@ function optionalPositiveInteger(value, option) {
|
|
|
107955
108336
|
if (result === 0) throw new UsageError(`${option} must be a positive integer.`);
|
|
107956
108337
|
return result;
|
|
107957
108338
|
}
|
|
108339
|
+
function optionalBoundedInteger(value, option, minimum, maximum) {
|
|
108340
|
+
if (value === void 0) return void 0;
|
|
108341
|
+
if (!/^\d+$/.test(value)) {
|
|
108342
|
+
throw new UsageError(`${option} must be an integer from ${minimum} to ${maximum}.`);
|
|
108343
|
+
}
|
|
108344
|
+
const parsed = Number(value);
|
|
108345
|
+
if (!Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
|
|
108346
|
+
throw new UsageError(`${option} must be an integer from ${minimum} to ${maximum}.`);
|
|
108347
|
+
}
|
|
108348
|
+
return parsed;
|
|
108349
|
+
}
|
|
107958
108350
|
function optionalUsdAmount(value, option) {
|
|
107959
108351
|
if (value === void 0) return void 0;
|
|
107960
108352
|
if (!/^\d+(?:\.\d{1,2})?$/.test(value)) {
|
|
@@ -108015,12 +108407,138 @@ function parseInitNetworks(value) {
|
|
|
108015
108407
|
}
|
|
108016
108408
|
for (const network of networks) {
|
|
108017
108409
|
if (network !== "base" && network !== "arc" && network !== "solana") {
|
|
108018
|
-
throw new UsageError("--networks supports base
|
|
108410
|
+
throw new UsageError("--networks supports base and arc; Solana vault setup is unavailable.");
|
|
108019
108411
|
}
|
|
108020
108412
|
}
|
|
108021
108413
|
return networks;
|
|
108022
108414
|
}
|
|
108023
108415
|
|
|
108416
|
+
// ../cli/src/update-check.ts
|
|
108417
|
+
import { lookup } from "node:dns/promises";
|
|
108418
|
+
import { mkdir as mkdir21, readFile as readFile29, writeFile as writeFile12 } from "node:fs/promises";
|
|
108419
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
108420
|
+
var CHECK_TIMEOUT_MS = 1500;
|
|
108421
|
+
var LATEST_URL = "https://registry.npmjs.org/vapi-network/latest";
|
|
108422
|
+
async function runCliWithUpdateCheck(argv = process.argv.slice(2), io = {
|
|
108423
|
+
stdout: (message) => console.log(message),
|
|
108424
|
+
stderr: (message) => console.error(message)
|
|
108425
|
+
}, dependencies = {}, options = {}) {
|
|
108426
|
+
const notice = checkForUpdate({ ...options, env: options.env ?? dependencies.env, argv });
|
|
108427
|
+
const code = await runCli(argv, io, dependencies);
|
|
108428
|
+
const message = await notice;
|
|
108429
|
+
if (message) io.stderr(message);
|
|
108430
|
+
return code;
|
|
108431
|
+
}
|
|
108432
|
+
async function checkForUpdate(options = {}) {
|
|
108433
|
+
const env = options.env ?? process.env;
|
|
108434
|
+
const argv = options.argv ?? process.argv.slice(2);
|
|
108435
|
+
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) {
|
|
108436
|
+
return void 0;
|
|
108437
|
+
}
|
|
108438
|
+
const controller = new AbortController();
|
|
108439
|
+
let timer;
|
|
108440
|
+
try {
|
|
108441
|
+
return await Promise.race([
|
|
108442
|
+
latestNotice(options, env, controller.signal),
|
|
108443
|
+
new Promise((resolve3) => {
|
|
108444
|
+
timer = setTimeout(() => {
|
|
108445
|
+
controller.abort();
|
|
108446
|
+
resolve3(void 0);
|
|
108447
|
+
}, CHECK_TIMEOUT_MS);
|
|
108448
|
+
})
|
|
108449
|
+
]);
|
|
108450
|
+
} catch {
|
|
108451
|
+
return void 0;
|
|
108452
|
+
} finally {
|
|
108453
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
108454
|
+
controller.abort();
|
|
108455
|
+
}
|
|
108456
|
+
}
|
|
108457
|
+
async function latestNotice(options, env, signal) {
|
|
108458
|
+
const paths = getVapiPaths(options.home ?? (env.VAPI_HOME?.trim() || void 0));
|
|
108459
|
+
const now = (options.nowMs ?? Date.now)();
|
|
108460
|
+
let cached2;
|
|
108461
|
+
try {
|
|
108462
|
+
const value = JSON.parse(await readFile29(paths.updateCheck, "utf8"));
|
|
108463
|
+
if (isRecord12(value) && typeof value.checkedAt === "number" && Number.isFinite(value.checkedAt) && typeof value.latest === "string" && parseVersion(value.latest)) {
|
|
108464
|
+
cached2 = { checkedAt: value.checkedAt, latest: value.latest };
|
|
108465
|
+
}
|
|
108466
|
+
} catch {
|
|
108467
|
+
}
|
|
108468
|
+
signal.throwIfAborted();
|
|
108469
|
+
let latest = cached2?.latest ?? CLI_VERSION;
|
|
108470
|
+
if (cached2 === void 0 || now - cached2.checkedAt >= CHECK_INTERVAL_MS || now < cached2.checkedAt) {
|
|
108471
|
+
await mkdir21(paths.directory, { recursive: true });
|
|
108472
|
+
signal.throwIfAborted();
|
|
108473
|
+
await writeFile12(paths.updateCheck, JSON.stringify({ checkedAt: now, latest }), { mode: 384 });
|
|
108474
|
+
signal.throwIfAborted();
|
|
108475
|
+
const fetchImpl = options.fetchImpl ?? createPublicFetch({
|
|
108476
|
+
allowPrivateNetwork: false,
|
|
108477
|
+
lookup: async (hostname3) => {
|
|
108478
|
+
let onAbort;
|
|
108479
|
+
const aborted2 = new Promise((_resolve, reject) => {
|
|
108480
|
+
onAbort = () => reject(signal.reason);
|
|
108481
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
108482
|
+
});
|
|
108483
|
+
try {
|
|
108484
|
+
signal.throwIfAborted();
|
|
108485
|
+
const addresses = await Promise.race([lookup(hostname3, { all: true }), aborted2]);
|
|
108486
|
+
return addresses.map(({ address: address4 }) => address4);
|
|
108487
|
+
} finally {
|
|
108488
|
+
signal.removeEventListener("abort", onAbort);
|
|
108489
|
+
}
|
|
108490
|
+
}
|
|
108491
|
+
});
|
|
108492
|
+
const response = await fetchImpl(LATEST_URL, { signal, redirect: "error" });
|
|
108493
|
+
if (!response.ok) return void 0;
|
|
108494
|
+
const body = await response.json();
|
|
108495
|
+
signal.throwIfAborted();
|
|
108496
|
+
if (!isRecord12(body) || typeof body.version !== "string" || !parseVersion(body.version)) {
|
|
108497
|
+
return void 0;
|
|
108498
|
+
}
|
|
108499
|
+
latest = body.version;
|
|
108500
|
+
await writeFile12(paths.updateCheck, JSON.stringify({ checkedAt: now, latest }), { mode: 384 });
|
|
108501
|
+
}
|
|
108502
|
+
signal.throwIfAborted();
|
|
108503
|
+
return isNewerVersion(latest, CLI_VERSION) ? `vapi-network ${latest} is available (you have ${CLI_VERSION}). Update: npm i -g vapi-network@latest` : void 0;
|
|
108504
|
+
}
|
|
108505
|
+
function isRecord12(value) {
|
|
108506
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
108507
|
+
}
|
|
108508
|
+
function parseVersion(version5) {
|
|
108509
|
+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-zA-Z.-]+))?(?:\+[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?$/.exec(
|
|
108510
|
+
version5
|
|
108511
|
+
);
|
|
108512
|
+
if (!match) return void 0;
|
|
108513
|
+
const prerelease = match[4]?.split(".");
|
|
108514
|
+
if (prerelease?.some((part) => part === "" || /^\d+$/.test(part) && /^0\d/.test(part))) {
|
|
108515
|
+
return void 0;
|
|
108516
|
+
}
|
|
108517
|
+
return { core: match.slice(1, 4).map(BigInt), prerelease };
|
|
108518
|
+
}
|
|
108519
|
+
function isNewerVersion(latest, current) {
|
|
108520
|
+
const next = parseVersion(latest);
|
|
108521
|
+
const running = parseVersion(current);
|
|
108522
|
+
for (let index2 = 0; index2 < 3; index2 += 1) {
|
|
108523
|
+
if (next.core[index2] !== running.core[index2]) return next.core[index2] > running.core[index2];
|
|
108524
|
+
}
|
|
108525
|
+
if (running.prerelease === void 0) return false;
|
|
108526
|
+
if (next.prerelease === void 0) return true;
|
|
108527
|
+
for (let index2 = 0; index2 < Math.max(next.prerelease.length, running.prerelease.length); index2 += 1) {
|
|
108528
|
+
const a = next.prerelease[index2];
|
|
108529
|
+
const b = running.prerelease[index2];
|
|
108530
|
+
if (a === b) continue;
|
|
108531
|
+
if (a === void 0) return false;
|
|
108532
|
+
if (b === void 0) return true;
|
|
108533
|
+
const aNumeric = /^\d+$/.test(a);
|
|
108534
|
+
const bNumeric = /^\d+$/.test(b);
|
|
108535
|
+
if (aNumeric && bNumeric) return BigInt(a) > BigInt(b);
|
|
108536
|
+
if (aNumeric !== bNumeric) return !aNumeric;
|
|
108537
|
+
return a > b;
|
|
108538
|
+
}
|
|
108539
|
+
return false;
|
|
108540
|
+
}
|
|
108541
|
+
|
|
108024
108542
|
// src/cli.ts
|
|
108025
|
-
process.exitCode = await
|
|
108543
|
+
process.exitCode = await runCliWithUpdateCheck();
|
|
108026
108544
|
//# sourceMappingURL=cli.js.map
|