vapi-network 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -8
- package/dist/cli.js +460 -87
- package/dist/cli.js.map +3 -3
- package/dist/index.js +478 -91
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10123,6 +10123,7 @@ __export(src_exports4, {
|
|
|
10123
10123
|
parseRuntimeKind: () => parseRuntimeKind,
|
|
10124
10124
|
resolveRuntime: () => resolveRuntime,
|
|
10125
10125
|
runCli: () => runCli,
|
|
10126
|
+
runCliWithUpdateCheck: () => runCliWithUpdateCheck,
|
|
10126
10127
|
runtimeForKind: () => runtimeForKind
|
|
10127
10128
|
});
|
|
10128
10129
|
|
|
@@ -10185,6 +10186,7 @@ __export(src_exports, {
|
|
|
10185
10186
|
MARKETPLACE_EXECUTION_METHODS: () => MARKETPLACE_EXECUTION_METHODS,
|
|
10186
10187
|
MARKETPLACE_KINDS: () => MARKETPLACE_KINDS,
|
|
10187
10188
|
MARKETPLACE_RANKING_VERSION: () => MARKETPLACE_RANKING_VERSION,
|
|
10189
|
+
MAX_RESTORE_ACCOUNTS: () => MAX_RESTORE_ACCOUNTS,
|
|
10188
10190
|
MovementError: () => MovementError,
|
|
10189
10191
|
NETWORKS: () => NETWORKS2,
|
|
10190
10192
|
ONRAMP_FALLBACK_INSTRUCTIONS: () => ONRAMP_FALLBACK_INSTRUCTIONS,
|
|
@@ -10192,6 +10194,7 @@ __export(src_exports, {
|
|
|
10192
10194
|
PASSPHRASE_ENVIRONMENT_VARIABLE: () => PASSPHRASE_ENVIRONMENT_VARIABLE,
|
|
10193
10195
|
PROVENANCES: () => PROVENANCES,
|
|
10194
10196
|
RELAY_MAX_PER_TRANSFER_ATOMIC: () => RELAY_MAX_PER_TRANSFER_ATOMIC,
|
|
10197
|
+
RESTORE_GAP_LIMIT: () => RESTORE_GAP_LIMIT,
|
|
10195
10198
|
ROUTER_TOPUP_TIERS: () => ROUTER_TOPUP_TIERS,
|
|
10196
10199
|
RUN_ID_PATTERN: () => RUN_ID_PATTERN,
|
|
10197
10200
|
RunBudgetError: () => RunBudgetError,
|
|
@@ -39714,8 +39717,10 @@ var listingIdentitySchema = external_exports.looseObject({
|
|
|
39714
39717
|
}).optional().catch(void 0)
|
|
39715
39718
|
});
|
|
39716
39719
|
var listingDisclosureShape = {
|
|
39717
|
-
|
|
39718
|
-
fee
|
|
39720
|
+
// Presentation metadata must not make an otherwise executable row vanish
|
|
39721
|
+
// when the registry adds a new group or changes the fee display shape.
|
|
39722
|
+
group: listingGroupSchema.optional().catch(void 0),
|
|
39723
|
+
fee: listingFeeSchema.optional().catch(void 0),
|
|
39719
39724
|
verification: listingVerificationFieldSchema,
|
|
39720
39725
|
liveness: listingLivenessSchema.optional().catch(void 0),
|
|
39721
39726
|
conformance: listingConformanceSchema.optional().catch(void 0),
|
|
@@ -39723,11 +39728,13 @@ var listingDisclosureShape = {
|
|
|
39723
39728
|
};
|
|
39724
39729
|
var marketplaceBadgeCodeSchema = external_exports.enum([
|
|
39725
39730
|
"live_x402",
|
|
39731
|
+
"mpp",
|
|
39726
39732
|
"partner",
|
|
39727
39733
|
"payout_wallet_confirmed",
|
|
39728
39734
|
"vapi_verified",
|
|
39729
39735
|
"external_catalog",
|
|
39730
|
-
"approved_vendor"
|
|
39736
|
+
"approved_vendor",
|
|
39737
|
+
"unverified"
|
|
39731
39738
|
]);
|
|
39732
39739
|
var marketplaceBadgeSchema = external_exports.looseObject({
|
|
39733
39740
|
code: marketplaceBadgeCodeSchema,
|
|
@@ -39746,7 +39753,13 @@ var marketplaceCardSchema = external_exports.looseObject({
|
|
|
39746
39753
|
summary: external_exports.string().trim().min(1).max(1e3),
|
|
39747
39754
|
byline: external_exports.string().trim().min(1).max(160).optional(),
|
|
39748
39755
|
bylineHref: marketplaceHrefSchema.optional(),
|
|
39749
|
-
badges: external_exports.
|
|
39756
|
+
badges: external_exports.preprocess(
|
|
39757
|
+
(badges) => Array.isArray(badges) ? badges.flatMap((badge) => {
|
|
39758
|
+
const parsed = marketplaceBadgeSchema.safeParse(badge);
|
|
39759
|
+
return parsed.success ? [parsed.data] : [];
|
|
39760
|
+
}) : badges,
|
|
39761
|
+
external_exports.array(marketplaceBadgeSchema).max(8)
|
|
39762
|
+
),
|
|
39750
39763
|
facts: external_exports.array(marketplacePublicFactSchema).max(12)
|
|
39751
39764
|
});
|
|
39752
39765
|
var marketplaceHitBase = {
|
|
@@ -45227,9 +45240,9 @@ function createPublicFetch(options) {
|
|
|
45227
45240
|
});
|
|
45228
45241
|
});
|
|
45229
45242
|
}
|
|
45230
|
-
function pinnedLookup(
|
|
45243
|
+
function pinnedLookup(lookup2) {
|
|
45231
45244
|
return (hostname4, dnsOptions, callback) => {
|
|
45232
|
-
void
|
|
45245
|
+
void lookup2(normalizeHostname(hostname4)).then((addresses) => {
|
|
45233
45246
|
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
45234
45247
|
callback(guardError(new URL(`https://${hostname4}`)), "");
|
|
45235
45248
|
return;
|
|
@@ -46368,7 +46381,7 @@ var CALLABLE_KIND = "agent";
|
|
|
46368
46381
|
var CALLABLE_CATEGORIES = ["ai", "data", "crypto", "compute", "search"];
|
|
46369
46382
|
var callableCategorySchema = external_exports.enum(CALLABLE_CATEGORIES);
|
|
46370
46383
|
var DISCOVERY_CATEGORIES = [...CALLABLE_CATEGORIES, "other"];
|
|
46371
|
-
var discoveryCategorySchema = external_exports.
|
|
46384
|
+
var discoveryCategorySchema = external_exports.string().trim().min(1);
|
|
46372
46385
|
var CALLABLE_CATEGORY_LABELS = {
|
|
46373
46386
|
ai: { catalog: "AI / LLM", publish: "AI and models" },
|
|
46374
46387
|
data: { catalog: "Data", publish: "Data" },
|
|
@@ -46380,7 +46393,7 @@ var CALLABLE_CATEGORY_SET = new Set(CALLABLE_CATEGORIES);
|
|
|
46380
46393
|
function isCallableListing(kind, category) {
|
|
46381
46394
|
return kind === CALLABLE_KIND && CALLABLE_CATEGORY_SET.has(category);
|
|
46382
46395
|
}
|
|
46383
|
-
var serviceTierSchema = external_exports.
|
|
46396
|
+
var serviceTierSchema = external_exports.string().trim().min(1);
|
|
46384
46397
|
var discoveryEndpointSchema = external_exports.looseObject({
|
|
46385
46398
|
name: external_exports.string(),
|
|
46386
46399
|
method: external_exports.string(),
|
|
@@ -46410,6 +46423,24 @@ var discoveryEndpointSchema = external_exports.looseObject({
|
|
|
46410
46423
|
asset: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
|
|
46411
46424
|
payTo: external_exports.string().refine(isSolanaAddress, "Expected a Solana base58 address."),
|
|
46412
46425
|
checkedAt: external_exports.iso.datetime()
|
|
46426
|
+
}),
|
|
46427
|
+
external_exports.looseObject({
|
|
46428
|
+
protocol: external_exports.literal("mpp"),
|
|
46429
|
+
intent: external_exports.enum(["charge", "authorize", "subscription"]).nullable(),
|
|
46430
|
+
method: external_exports.string().trim().min(1).max(40).nullable(),
|
|
46431
|
+
checkedAt: external_exports.iso.datetime(),
|
|
46432
|
+
// Keep common x402 properties readable on the union while making it
|
|
46433
|
+
// impossible for MPP metadata to masquerade as executable x402 terms.
|
|
46434
|
+
network: external_exports.never().optional(),
|
|
46435
|
+
payTo: external_exports.never().optional()
|
|
46436
|
+
}),
|
|
46437
|
+
external_exports.looseObject({
|
|
46438
|
+
// Future payment protocols remain visible to callers so the payment
|
|
46439
|
+
// layer can refuse them explicitly instead of discovery losing the row.
|
|
46440
|
+
protocol: external_exports.string().trim().min(1).max(40),
|
|
46441
|
+
checkedAt: external_exports.iso.datetime(),
|
|
46442
|
+
network: external_exports.never().optional(),
|
|
46443
|
+
payTo: external_exports.never().optional()
|
|
46413
46444
|
})
|
|
46414
46445
|
]).optional()
|
|
46415
46446
|
});
|
|
@@ -46505,7 +46536,7 @@ function resolveTarget(service, endpointName) {
|
|
|
46505
46536
|
}
|
|
46506
46537
|
if (targets.size !== 1) {
|
|
46507
46538
|
const paymentNetworks = service.endpoints.flatMap(
|
|
46508
|
-
(endpoint) => endpoint.payment ? [endpoint.payment.network] : []
|
|
46539
|
+
(endpoint) => typeof endpoint.payment?.network === "string" ? [endpoint.payment.network] : []
|
|
46509
46540
|
);
|
|
46510
46541
|
throw new DiscoveryCatalogError(
|
|
46511
46542
|
"ambiguous_default",
|
|
@@ -47483,7 +47514,8 @@ function getVapiPaths(directory = process.env.VAPI_HOME?.trim() || join2(homedir
|
|
|
47483
47514
|
keystore: join2(directory, "keystore.json"),
|
|
47484
47515
|
receipts: join2(directory, "receipts.jsonl"),
|
|
47485
47516
|
searches: join2(directory, "searches.jsonl"),
|
|
47486
|
-
ledger: join2(directory, "spend-ledger.json")
|
|
47517
|
+
ledger: join2(directory, "spend-ledger.json"),
|
|
47518
|
+
updateCheck: join2(directory, "update-check.json")
|
|
47487
47519
|
};
|
|
47488
47520
|
}
|
|
47489
47521
|
var getAgentCashPaths = getVapiPaths;
|
|
@@ -70913,7 +70945,7 @@ function windowsDataProtectionStore(platform2, run, env, installed) {
|
|
|
70913
70945
|
};
|
|
70914
70946
|
}
|
|
70915
70947
|
function libsecretStore(platform2, run, installed) {
|
|
70916
|
-
const
|
|
70948
|
+
const lookup2 = async (name) => {
|
|
70917
70949
|
const result = await run(SECRET_TOOL_BINARY, [
|
|
70918
70950
|
"lookup",
|
|
70919
70951
|
"service",
|
|
@@ -70932,9 +70964,9 @@ function libsecretStore(platform2, run, installed) {
|
|
|
70932
70964
|
available: installed(SECRET_TOOL_BINARY),
|
|
70933
70965
|
platform: platform2,
|
|
70934
70966
|
description: "the libsecret keyring",
|
|
70935
|
-
get:
|
|
70967
|
+
get: lookup2,
|
|
70936
70968
|
async has(name) {
|
|
70937
|
-
return await
|
|
70969
|
+
return await lookup2(name) !== void 0;
|
|
70938
70970
|
},
|
|
70939
70971
|
async set(name, passphrase) {
|
|
70940
70972
|
requirePassphrase(passphrase);
|
|
@@ -70956,7 +70988,7 @@ function libsecretStore(platform2, run, installed) {
|
|
|
70956
70988
|
requireSuccess(result, `store the passphrase of ${name} in the secret service`);
|
|
70957
70989
|
},
|
|
70958
70990
|
async remove(name) {
|
|
70959
|
-
const existed = await
|
|
70991
|
+
const existed = await lookup2(name) !== void 0;
|
|
70960
70992
|
const result = await run(SECRET_TOOL_BINARY, [
|
|
70961
70993
|
"clear",
|
|
70962
70994
|
"service",
|
|
@@ -72022,6 +72054,8 @@ var VAULT_KEY_ACCOUNT = "vault-key";
|
|
|
72022
72054
|
var VAULT_SESSION_ACCOUNT = "vault-session";
|
|
72023
72055
|
var DEVICE_KEY_LENGTH = 32;
|
|
72024
72056
|
var DEFAULT_SESSION_HOURS = 8;
|
|
72057
|
+
var RESTORE_GAP_LIMIT = 5;
|
|
72058
|
+
var MAX_RESTORE_ACCOUNTS = 1e4;
|
|
72025
72059
|
var BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;
|
|
72026
72060
|
var deviceKeyOperations = Promise.resolve();
|
|
72027
72061
|
var sessionSchema = external_exports.object({
|
|
@@ -72171,26 +72205,41 @@ async function restoreVault(args) {
|
|
|
72171
72205
|
throw new VaultError("corrupt", "That recovery phrase is not valid.", { cause: error61 });
|
|
72172
72206
|
}
|
|
72173
72207
|
let seed;
|
|
72174
|
-
|
|
72208
|
+
if (args.accountCount !== void 0 && (!Number.isSafeInteger(args.accountCount) || args.accountCount < 1 || args.accountCount > MAX_RESTORE_ACCOUNTS)) {
|
|
72209
|
+
throw new VaultError(
|
|
72210
|
+
"corrupt",
|
|
72211
|
+
`Account count must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
72212
|
+
);
|
|
72213
|
+
}
|
|
72214
|
+
let discoveredAccounts = args.accountCount ?? 0;
|
|
72215
|
+
let scannedAddresses = 0;
|
|
72175
72216
|
try {
|
|
72176
72217
|
seed = phraseToSeed(phrase);
|
|
72177
72218
|
} catch (error61) {
|
|
72178
72219
|
throw asVaultError2(error61, "Unable to derive an account while restoring the vault.");
|
|
72179
72220
|
}
|
|
72180
72221
|
try {
|
|
72181
|
-
for (let index2 = 0; ; index2 += 1) {
|
|
72222
|
+
for (let index2 = 0, emptyRun = 0; args.accountCount === void 0; index2 += 1) {
|
|
72182
72223
|
let address4;
|
|
72183
72224
|
try {
|
|
72184
72225
|
address4 = privateKeyToAccount(deriveEvmPrivateKey(seed, `m/44'/60'/0'/0/${index2}`)).address;
|
|
72185
72226
|
} catch (error61) {
|
|
72186
72227
|
throw asVaultError2(error61, "Unable to derive an account while restoring the vault.");
|
|
72187
72228
|
}
|
|
72188
|
-
|
|
72189
|
-
|
|
72229
|
+
const funded = await args.probe(address4);
|
|
72230
|
+
scannedAddresses += 1;
|
|
72231
|
+
if (funded) {
|
|
72232
|
+
discoveredAccounts = index2 + 1;
|
|
72233
|
+
emptyRun = 0;
|
|
72234
|
+
} else {
|
|
72235
|
+
emptyRun += 1;
|
|
72236
|
+
if (emptyRun === RESTORE_GAP_LIMIT) break;
|
|
72237
|
+
}
|
|
72190
72238
|
}
|
|
72191
72239
|
} finally {
|
|
72192
72240
|
seed.fill(0);
|
|
72193
72241
|
}
|
|
72242
|
+
args.onScanComplete?.(scannedAddresses);
|
|
72194
72243
|
let vault;
|
|
72195
72244
|
try {
|
|
72196
72245
|
vault = await createVault({ path: args.path, key: args.key, phrase, now: args.now });
|
|
@@ -72679,6 +72728,26 @@ var WalletStore = class _WalletStore {
|
|
|
72679
72728
|
}
|
|
72680
72729
|
);
|
|
72681
72730
|
}
|
|
72731
|
+
/** Checks a cached signer's current vault session without decrypting its account again. */
|
|
72732
|
+
async assertSigningAuthority(name) {
|
|
72733
|
+
const stored = await this.readVaultUnlocked();
|
|
72734
|
+
if (!stored?.protected || !stored.accounts.some((account) => account.name === name)) return;
|
|
72735
|
+
try {
|
|
72736
|
+
const key2 = await unlockProtectedVault({
|
|
72737
|
+
path: this.vaultPath,
|
|
72738
|
+
secrets: this.secrets,
|
|
72739
|
+
env: this.environment,
|
|
72740
|
+
now: () => this.now()
|
|
72741
|
+
});
|
|
72742
|
+
key2.fill(0);
|
|
72743
|
+
} catch (error61) {
|
|
72744
|
+
this.dropVaultCache();
|
|
72745
|
+
if (error61 instanceof VaultError && error61.code === "password_required") {
|
|
72746
|
+
throw new KeystoreError(VAULT_LOCKED_MESSAGE, { cause: error61 });
|
|
72747
|
+
}
|
|
72748
|
+
throw error61;
|
|
72749
|
+
}
|
|
72750
|
+
}
|
|
72682
72751
|
/** Returns one wallet's vault signer, migrating its legacy keystore if needed. */
|
|
72683
72752
|
async unlock(name, passphrase) {
|
|
72684
72753
|
const wallet = this.resolve({ name });
|
|
@@ -78065,7 +78134,7 @@ function createRunBudget(args) {
|
|
|
78065
78134
|
import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
|
|
78066
78135
|
import { arch, platform, release } from "node:os";
|
|
78067
78136
|
import { join as join13 } from "node:path";
|
|
78068
|
-
var VAPI_CLIENT_VERSION = "0.9.
|
|
78137
|
+
var VAPI_CLIENT_VERSION = "0.9.4";
|
|
78069
78138
|
async function createSupportReport(options) {
|
|
78070
78139
|
const message = options.message.trim();
|
|
78071
78140
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -78338,7 +78407,7 @@ async function completeX402Payment(args) {
|
|
|
78338
78407
|
let paidAttempt;
|
|
78339
78408
|
const requestStarted = nowMs();
|
|
78340
78409
|
try {
|
|
78341
|
-
paidAttempt = await args.send(paidRequest);
|
|
78410
|
+
paidAttempt = await args.send(paidRequest, quote);
|
|
78342
78411
|
} catch (error61) {
|
|
78343
78412
|
if (trace) trace.phases.requestMs = elapsed(nowMs, requestStarted);
|
|
78344
78413
|
throw settlementUnknown(
|
|
@@ -78356,7 +78425,7 @@ async function completeX402Payment(args) {
|
|
|
78356
78425
|
const settleStarted = nowMs();
|
|
78357
78426
|
const settlement = parseSettlementResponse(paidResponse.headers);
|
|
78358
78427
|
const settlementOutcome = classifySettlement(settlement);
|
|
78359
|
-
const receiptSettlement =
|
|
78428
|
+
const receiptSettlement = sanitizeReturnedValue(settlement, receiptSecrets);
|
|
78360
78429
|
if (trace) {
|
|
78361
78430
|
const transaction2 = settlementTransaction(receiptSettlement);
|
|
78362
78431
|
const explorerUrl = transaction2 ? explorerTransactionUrl(quote.accepted.network, transaction2) : void 0;
|
|
@@ -78433,6 +78502,7 @@ async function completeX402Payment(args) {
|
|
|
78433
78502
|
trace.phases.requestMs = (trace.phases.requestMs ?? 0) + elapsed(nowMs, bodyStarted);
|
|
78434
78503
|
}
|
|
78435
78504
|
}
|
|
78505
|
+
body = sanitizeReturnedValue(body, receiptSecrets);
|
|
78436
78506
|
}
|
|
78437
78507
|
const result = {
|
|
78438
78508
|
response: paidResponse,
|
|
@@ -78441,7 +78511,11 @@ async function completeX402Payment(args) {
|
|
|
78441
78511
|
quote,
|
|
78442
78512
|
payer,
|
|
78443
78513
|
...payment.paymentId ? { paymentId: payment.paymentId } : {},
|
|
78444
|
-
|
|
78514
|
+
paymentProof: sanitizeReturnedValue(
|
|
78515
|
+
paidResponse.headers.get("x-vapi-payment-proof"),
|
|
78516
|
+
receiptSecrets
|
|
78517
|
+
),
|
|
78518
|
+
settlement: receiptSettlement,
|
|
78445
78519
|
settlementOutcome
|
|
78446
78520
|
};
|
|
78447
78521
|
if (settlementOutcome === "succeeded" && args.ceilingSweep) {
|
|
@@ -78578,19 +78652,70 @@ function sanitizeThrownError(error61, secrets) {
|
|
|
78578
78652
|
}
|
|
78579
78653
|
return new Error(message, cause === void 0 ? void 0 : { cause });
|
|
78580
78654
|
}
|
|
78581
|
-
function
|
|
78655
|
+
function sanitizeReturnedValue(value, secrets) {
|
|
78582
78656
|
if (typeof value === "string") return redactKnownSecrets(value, secrets);
|
|
78583
|
-
if (value
|
|
78584
|
-
|
|
78585
|
-
|
|
78586
|
-
|
|
78657
|
+
if (!isPlainReturnedContainer(value)) return value;
|
|
78658
|
+
const nodes = /* @__PURE__ */ new WeakMap();
|
|
78659
|
+
const ordered = [];
|
|
78660
|
+
const nodeFor = (source) => {
|
|
78661
|
+
const existing = nodes.get(source);
|
|
78662
|
+
if (existing) return existing;
|
|
78663
|
+
const copy = Array.isArray(source) ? new Array(source.length) : Object.create(Object.getPrototypeOf(source));
|
|
78664
|
+
const node2 = { source, copy, parents: /* @__PURE__ */ new Set(), changed: false };
|
|
78665
|
+
nodes.set(source, node2);
|
|
78666
|
+
ordered.push(node2);
|
|
78667
|
+
return node2;
|
|
78668
|
+
};
|
|
78669
|
+
const root = nodeFor(value);
|
|
78670
|
+
for (let index2 = 0; index2 < ordered.length; index2 += 1) {
|
|
78671
|
+
const node2 = ordered[index2];
|
|
78672
|
+
for (const [key2, item] of Object.entries(node2.source)) {
|
|
78673
|
+
const safeKey = Array.isArray(node2.source) ? key2 : redactKnownSecrets(key2, secrets);
|
|
78674
|
+
if (safeKey !== key2) node2.changed = true;
|
|
78675
|
+
if (typeof item === "string") {
|
|
78676
|
+
const safeItem = redactKnownSecrets(item, secrets);
|
|
78677
|
+
defineReturnedProperty(node2.copy, safeKey, safeItem);
|
|
78678
|
+
if (safeItem !== item) node2.changed = true;
|
|
78679
|
+
} else if (isPlainReturnedContainer(item)) {
|
|
78680
|
+
const child = nodeFor(item);
|
|
78681
|
+
child.parents.add(node2);
|
|
78682
|
+
defineReturnedProperty(node2.copy, safeKey, child.copy);
|
|
78683
|
+
} else {
|
|
78684
|
+
defineReturnedProperty(node2.copy, safeKey, item);
|
|
78685
|
+
}
|
|
78686
|
+
}
|
|
78587
78687
|
}
|
|
78588
|
-
|
|
78589
|
-
|
|
78590
|
-
|
|
78591
|
-
|
|
78592
|
-
|
|
78593
|
-
|
|
78688
|
+
const changed = ordered.filter((node2) => node2.changed);
|
|
78689
|
+
for (let index2 = 0; index2 < changed.length; index2 += 1) {
|
|
78690
|
+
for (const parent of changed[index2].parents) {
|
|
78691
|
+
if (parent.changed) continue;
|
|
78692
|
+
parent.changed = true;
|
|
78693
|
+
changed.push(parent);
|
|
78694
|
+
}
|
|
78695
|
+
}
|
|
78696
|
+
for (const node2 of ordered) {
|
|
78697
|
+
for (const [key2, item] of Object.entries(node2.source)) {
|
|
78698
|
+
if (!isPlainReturnedContainer(item)) continue;
|
|
78699
|
+
const safeKey = Array.isArray(node2.source) ? key2 : redactKnownSecrets(key2, secrets);
|
|
78700
|
+
const child = nodes.get(item);
|
|
78701
|
+
defineReturnedProperty(node2.copy, safeKey, child.changed ? child.copy : item);
|
|
78702
|
+
}
|
|
78703
|
+
}
|
|
78704
|
+
return root.changed ? root.copy : value;
|
|
78705
|
+
}
|
|
78706
|
+
function defineReturnedProperty(target, key2, value) {
|
|
78707
|
+
Object.defineProperty(target, key2, {
|
|
78708
|
+
value,
|
|
78709
|
+
enumerable: true,
|
|
78710
|
+
configurable: true,
|
|
78711
|
+
writable: true
|
|
78712
|
+
});
|
|
78713
|
+
}
|
|
78714
|
+
function isPlainReturnedContainer(value) {
|
|
78715
|
+
if (Array.isArray(value)) return true;
|
|
78716
|
+
if (value === null || typeof value !== "object") return false;
|
|
78717
|
+
const prototype = Object.getPrototypeOf(value);
|
|
78718
|
+
return prototype === Object.prototype || prototype === null;
|
|
78594
78719
|
}
|
|
78595
78720
|
function redactKnownSecrets(value, secrets) {
|
|
78596
78721
|
let redacted = value;
|
|
@@ -78625,9 +78750,7 @@ function possibleSettlement(quote, payment, payer, receipt) {
|
|
|
78625
78750
|
payTo: quote.accepted.payTo,
|
|
78626
78751
|
payer,
|
|
78627
78752
|
...payment.paymentId ? { paymentId: payment.paymentId } : {},
|
|
78628
|
-
...isSvmPaymentRequirements(quote.accepted) ? {
|
|
78629
|
-
authorizationTransaction: "transaction" in payment.payload.payload ? payment.payload.payload.transaction : ""
|
|
78630
|
-
} : "authorization" in payment.payload.payload ? {
|
|
78753
|
+
...isSvmPaymentRequirements(quote.accepted) ? {} : "authorization" in payment.payload.payload ? {
|
|
78631
78754
|
authorizationNonce: payment.payload.payload.authorization.nonce,
|
|
78632
78755
|
authorizationExpiresAt: payment.payload.payload.authorization.validBefore
|
|
78633
78756
|
} : {},
|
|
@@ -79005,13 +79128,22 @@ async function sendRouterChat(deps, routerBaseUrl, routerKey, request, keyUsed)
|
|
|
79005
79128
|
}
|
|
79006
79129
|
const body = await responseText(response);
|
|
79007
79130
|
if (!response.ok) {
|
|
79008
|
-
if (
|
|
79131
|
+
if (/budget (?:has been )?exceeded|exceededbudget/iu.test(body)) {
|
|
79009
79132
|
throw new RouterClientError(
|
|
79010
79133
|
"budget_exhausted",
|
|
79011
79134
|
"The Router key has no remaining budget.",
|
|
79012
79135
|
response.status
|
|
79013
79136
|
);
|
|
79014
79137
|
}
|
|
79138
|
+
if (response.status === 429) {
|
|
79139
|
+
const retryAfter = response.headers.get("retry-after")?.trim();
|
|
79140
|
+
const retrySeconds = retryAfter !== void 0 && /^\d+$/u.test(retryAfter) ? Number(retryAfter) : void 0;
|
|
79141
|
+
throw new RouterClientError(
|
|
79142
|
+
"rate_limited",
|
|
79143
|
+
`The vAPI Router is rate limited. ${retrySeconds !== void 0 && Number.isFinite(retrySeconds) ? `Retry after ${retrySeconds} seconds.` : "Wait and retry shortly."}`,
|
|
79144
|
+
response.status
|
|
79145
|
+
);
|
|
79146
|
+
}
|
|
79015
79147
|
if (response.status === 401) {
|
|
79016
79148
|
throw new RouterClientError(
|
|
79017
79149
|
"no_router_key",
|
|
@@ -88984,12 +89116,13 @@ var BODY_HEADER_NAMES = [
|
|
|
88984
89116
|
"content-type"
|
|
88985
89117
|
];
|
|
88986
89118
|
async function callService(args) {
|
|
89119
|
+
validateTimeoutSeconds(args.input.timeoutSeconds);
|
|
88987
89120
|
const trace = createCallTrace(args);
|
|
88988
89121
|
let execution;
|
|
88989
89122
|
try {
|
|
88990
89123
|
execution = await executeCallService(args, trace);
|
|
88991
89124
|
} catch (error61) {
|
|
88992
|
-
if (!(error61 instanceof VapiCallError && error61.code === "unsupported_network")) {
|
|
89125
|
+
if (!(error61 instanceof VapiCallError && (error61.code === "unsupported_network" || error61.code === "unsupported_payment"))) {
|
|
88993
89126
|
await recordCallError(args, error61, trace).catch(() => void 0);
|
|
88994
89127
|
}
|
|
88995
89128
|
throw error61;
|
|
@@ -89103,6 +89236,8 @@ async function executeCallService(args, trace) {
|
|
|
89103
89236
|
body: method === "GET" || method === "HEAD" ? void 0 : requestBody
|
|
89104
89237
|
});
|
|
89105
89238
|
const request = createRequest(headers);
|
|
89239
|
+
const probeTimeoutMs = input2.timeoutSeconds === void 0 ? args.timeoutMs ?? 3e4 : Math.min(input2.timeoutSeconds, 30) * 1e3;
|
|
89240
|
+
let requestTimeoutMs = probeTimeoutMs;
|
|
89106
89241
|
const fetchWithGuardedRedirects = async (candidateRequest, followRedirects = true) => {
|
|
89107
89242
|
let currentRequest = candidateRequest;
|
|
89108
89243
|
let followedRedirects = 0;
|
|
@@ -89110,7 +89245,7 @@ async function executeCallService(args, trace) {
|
|
|
89110
89245
|
const attempt = await fetchAttempt(
|
|
89111
89246
|
fetchImpl,
|
|
89112
89247
|
new Request(currentRequest.clone(), { redirect: "manual" }),
|
|
89113
|
-
|
|
89248
|
+
requestTimeoutMs
|
|
89114
89249
|
);
|
|
89115
89250
|
const response = attempt.response;
|
|
89116
89251
|
if (!isRedirectStatus2(response.status)) {
|
|
@@ -89265,7 +89400,12 @@ async function executeCallService(args, trace) {
|
|
|
89265
89400
|
account,
|
|
89266
89401
|
caps: args.spendCaps ?? config2.spendCaps,
|
|
89267
89402
|
config: payableConfig(config2, account),
|
|
89268
|
-
send: async (paidRequest) => {
|
|
89403
|
+
send: async (paidRequest, quote) => {
|
|
89404
|
+
requestTimeoutMs = paidRequestTimeoutMs(
|
|
89405
|
+
input2.timeoutSeconds,
|
|
89406
|
+
args.timeoutMs,
|
|
89407
|
+
quote.accepted.maxTimeoutSeconds
|
|
89408
|
+
);
|
|
89269
89409
|
paidAttempt = await fetchWithGuardedRedirects(paidRequest, false);
|
|
89270
89410
|
return paidAttempt;
|
|
89271
89411
|
},
|
|
@@ -89304,7 +89444,7 @@ async function executeCallService(args, trace) {
|
|
|
89304
89444
|
asset: completed.quote.accepted.asset,
|
|
89305
89445
|
payTo: completed.quote.accepted.payTo,
|
|
89306
89446
|
settlement: settlementWithExplorer2(completed.settlement, completed.quote.accepted.network),
|
|
89307
|
-
proof: completed.
|
|
89447
|
+
proof: completed.paymentProof
|
|
89308
89448
|
},
|
|
89309
89449
|
...verificationFor(endpoint),
|
|
89310
89450
|
...expectedRequestFor(endpoint, completed.response.status)
|
|
@@ -89551,8 +89691,16 @@ async function resolveCallEndpoint(id2, endpointName, marketplaceHit, config2, f
|
|
|
89551
89691
|
);
|
|
89552
89692
|
}
|
|
89553
89693
|
function registeredEndpoint(listing, verification) {
|
|
89694
|
+
const { payment, ...endpoint } = listing.endpoint;
|
|
89695
|
+
if (payment && (typeof payment.protocol === "string" || typeof payment.network !== "string")) {
|
|
89696
|
+
throw new VapiCallError(
|
|
89697
|
+
"unsupported_payment",
|
|
89698
|
+
`Payment protocol ${payment.protocol} is not supported. This client pays x402 exact USDC endpoints only.`
|
|
89699
|
+
);
|
|
89700
|
+
}
|
|
89554
89701
|
return {
|
|
89555
|
-
...
|
|
89702
|
+
...endpoint,
|
|
89703
|
+
...payment ? { payment: { network: payment.network, payTo: payment.payTo } } : {},
|
|
89556
89704
|
verification: verification ?? listing.service.verification,
|
|
89557
89705
|
serviceNetworks: listing.service.networks,
|
|
89558
89706
|
registered: true,
|
|
@@ -89714,7 +89862,7 @@ async function readResponseBody2(response) {
|
|
|
89714
89862
|
async function fetchAttempt(fetchImpl, request, timeoutMs) {
|
|
89715
89863
|
const controller = new AbortController();
|
|
89716
89864
|
let rejectTimeout = null;
|
|
89717
|
-
const timeoutError = new Error(`API request timed out after ${timeoutMs}
|
|
89865
|
+
const timeoutError = new Error(`API request timed out after ${timeoutMs / 1e3} seconds.`);
|
|
89718
89866
|
const timedOut = new Promise((_resolve, reject) => {
|
|
89719
89867
|
rejectTimeout = reject;
|
|
89720
89868
|
});
|
|
@@ -89754,6 +89902,19 @@ async function fetchAttempt(fetchImpl, request, timeoutMs) {
|
|
|
89754
89902
|
throw error61;
|
|
89755
89903
|
}
|
|
89756
89904
|
}
|
|
89905
|
+
function validateTimeoutSeconds(timeoutSeconds) {
|
|
89906
|
+
if (timeoutSeconds !== void 0 && (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1 || timeoutSeconds > 300)) {
|
|
89907
|
+
throw new Error("call timeoutSeconds must be an integer from 1 to 300 seconds.");
|
|
89908
|
+
}
|
|
89909
|
+
}
|
|
89910
|
+
function paidRequestTimeoutMs(timeoutSeconds, internalTimeoutMs, offerTimeoutSeconds) {
|
|
89911
|
+
const usableOfferTimeout = Number.isInteger(offerTimeoutSeconds) && offerTimeoutSeconds > 0 ? offerTimeoutSeconds : void 0;
|
|
89912
|
+
if (timeoutSeconds !== void 0) {
|
|
89913
|
+
return Math.min(timeoutSeconds, usableOfferTimeout ?? timeoutSeconds) * 1e3;
|
|
89914
|
+
}
|
|
89915
|
+
if (internalTimeoutMs !== void 0) return internalTimeoutMs;
|
|
89916
|
+
return usableOfferTimeout === void 0 ? 12e4 : Math.min(12e4, Math.max(3e4, usableOfferTimeout * 1e3));
|
|
89917
|
+
}
|
|
89757
89918
|
function mapX402PaymentError(error61, resumeId) {
|
|
89758
89919
|
if (!(error61 instanceof X402PaymentError)) return error61;
|
|
89759
89920
|
if (error61.code === "payment_rejected") {
|
|
@@ -89769,9 +89930,10 @@ function mapX402PaymentError(error61, resumeId) {
|
|
|
89769
89930
|
});
|
|
89770
89931
|
}
|
|
89771
89932
|
const resume = resumeId !== void 0 && error61.possibleSettlement?.authorizationNonce ? ` Check whether it settled with \`vapi pay --resume ${resumeId}\` before paying again.` : "";
|
|
89933
|
+
const timeoutDetail = error61.cause instanceof Error && error61.cause.message.startsWith("API request timed out after ") ? `${error61.cause.message} ` : "";
|
|
89772
89934
|
return new VapiCallError(
|
|
89773
89935
|
"settlement_unknown",
|
|
89774
|
-
`${error61.message}${resume}`,
|
|
89936
|
+
`${timeoutDetail}${error61.message}${resume}`,
|
|
89775
89937
|
error61.possibleSettlement,
|
|
89776
89938
|
{ cause: error61.cause }
|
|
89777
89939
|
);
|
|
@@ -89903,13 +90065,7 @@ var inspectToolResultSchema = external_exports.object({
|
|
|
89903
90065
|
liveness: listingLivenessSchema.optional(),
|
|
89904
90066
|
conformance: listingConformanceSchema.optional(),
|
|
89905
90067
|
identity: listingIdentitySchema.optional(),
|
|
89906
|
-
payment:
|
|
89907
|
-
scheme: external_exports.literal("exact"),
|
|
89908
|
-
network: external_exports.string(),
|
|
89909
|
-
asset: external_exports.string(),
|
|
89910
|
-
payTo: external_exports.string(),
|
|
89911
|
-
checkedAt: external_exports.string()
|
|
89912
|
-
}).nullable()
|
|
90068
|
+
payment: discoveryEndpointSchema.shape.payment.unwrap().nullable()
|
|
89913
90069
|
});
|
|
89914
90070
|
var callSearchInputSchema = external_exports.object({
|
|
89915
90071
|
query: external_exports.string().trim().max(200).optional().describe("Capability, API, service, or request."),
|
|
@@ -89938,7 +90094,10 @@ var callPayInputSchema = external_exports.object({
|
|
|
89938
90094
|
(value) => /^0x[0-9a-fA-F]{40}$/.test(value) || isSolanaAddress(value),
|
|
89939
90095
|
"Expected an EVM or Solana address."
|
|
89940
90096
|
).optional(),
|
|
89941
|
-
maxPriceUsd: external_exports.union([external_exports.number().nonnegative(), external_exports.string().regex(/^\d+(?:\.\d{1,6})?$/)]).optional()
|
|
90097
|
+
maxPriceUsd: external_exports.union([external_exports.number().nonnegative(), external_exports.string().regex(/^\d+(?:\.\d{1,6})?$/)]).optional(),
|
|
90098
|
+
timeoutSeconds: external_exports.number().int().min(1).max(300).optional().describe(
|
|
90099
|
+
"Seconds to wait for the paid response. Default: the provider's maxTimeoutSeconds, at most 120."
|
|
90100
|
+
)
|
|
89942
90101
|
});
|
|
89943
90102
|
var callSearch = defineAction({
|
|
89944
90103
|
name: "call.search",
|
|
@@ -90201,7 +90360,7 @@ async function readResult(response, signal, secrets = []) {
|
|
|
90201
90360
|
return {
|
|
90202
90361
|
status: response.status,
|
|
90203
90362
|
contentType: contentType === null ? null : redactKnownSecrets2(contentType, secrets),
|
|
90204
|
-
body:
|
|
90363
|
+
body: sanitizeReturnedValue2(await readResponseBody3(response, contentType, signal), secrets)
|
|
90205
90364
|
};
|
|
90206
90365
|
}
|
|
90207
90366
|
async function readResponseBody3(response, contentType, signal) {
|
|
@@ -90246,17 +90405,17 @@ function isJsonContentType2(value) {
|
|
|
90246
90405
|
const mediaType = value?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
90247
90406
|
return mediaType === "application/json" || mediaType.endsWith("+json");
|
|
90248
90407
|
}
|
|
90249
|
-
function
|
|
90408
|
+
function sanitizeReturnedValue2(value, secrets, depth = 0) {
|
|
90250
90409
|
if (typeof value === "string") return redactKnownSecrets2(value, secrets);
|
|
90251
90410
|
if (value === null || typeof value !== "object") return value;
|
|
90252
90411
|
if (depth >= 16) return "[redacted nested response value]";
|
|
90253
90412
|
if (Array.isArray(value)) {
|
|
90254
|
-
return value.map((item) =>
|
|
90413
|
+
return value.map((item) => sanitizeReturnedValue2(item, secrets, depth + 1));
|
|
90255
90414
|
}
|
|
90256
90415
|
return Object.fromEntries(
|
|
90257
90416
|
Object.entries(value).map(([key2, item]) => [
|
|
90258
90417
|
redactKnownSecrets2(key2, secrets),
|
|
90259
|
-
|
|
90418
|
+
sanitizeReturnedValue2(item, secrets, depth + 1)
|
|
90260
90419
|
])
|
|
90261
90420
|
);
|
|
90262
90421
|
}
|
|
@@ -95768,7 +95927,13 @@ function toolError(error61) {
|
|
|
95768
95927
|
{
|
|
95769
95928
|
error: error61.message,
|
|
95770
95929
|
code: error61.code,
|
|
95771
|
-
...error61.possibleSettlement ? {
|
|
95930
|
+
...error61.possibleSettlement ? {
|
|
95931
|
+
possibleSettlement: Object.fromEntries(
|
|
95932
|
+
Object.entries(error61.possibleSettlement).filter(
|
|
95933
|
+
([key2]) => key2 !== "authorizationTransaction"
|
|
95934
|
+
)
|
|
95935
|
+
)
|
|
95936
|
+
} : {},
|
|
95772
95937
|
...error61.paymentRejection ? { paymentRejection: error61.paymentRejection } : {},
|
|
95773
95938
|
...error61.confirmedSettlement ? { confirmedSettlement: error61.confirmedSettlement } : {}
|
|
95774
95939
|
},
|
|
@@ -99262,7 +99427,7 @@ async function readProcessStdin() {
|
|
|
99262
99427
|
}
|
|
99263
99428
|
|
|
99264
99429
|
// ../cli/src/version.ts
|
|
99265
|
-
var CLI_VERSION = "0.9.
|
|
99430
|
+
var CLI_VERSION = "0.9.4";
|
|
99266
99431
|
|
|
99267
99432
|
// ../cli/src/status.ts
|
|
99268
99433
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -102764,7 +102929,7 @@ function createLocalRuntime(options) {
|
|
|
102764
102929
|
const processCommand = options.processCommand ?? defaultProcessCommand;
|
|
102765
102930
|
const ownsProcess = (handle, pid) => processCommand(pid)?.includes(runResultPath(home, handle.runId)) === true;
|
|
102766
102931
|
const closeFd = options.closeFd ?? closeSync2;
|
|
102767
|
-
const
|
|
102932
|
+
const readFile31 = options.readFile ?? nodeReadFile;
|
|
102768
102933
|
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
102769
102934
|
const openLog = options.openLog ?? ((path) => {
|
|
102770
102935
|
mkdirSync2(runsDirectory(home), { recursive: true, mode: 448 });
|
|
@@ -102819,7 +102984,7 @@ function createLocalRuntime(options) {
|
|
|
102819
102984
|
return handle;
|
|
102820
102985
|
},
|
|
102821
102986
|
async status(handle) {
|
|
102822
|
-
const result = await readResultFile(
|
|
102987
|
+
const result = await readResultFile(readFile31, runResultPath(home, handle.runId));
|
|
102823
102988
|
if (result !== void 0) return result;
|
|
102824
102989
|
const pid = localPid(handle);
|
|
102825
102990
|
if (pid === void 0 || handle.kind !== "local") {
|
|
@@ -102922,10 +103087,10 @@ function childArguments(member, run) {
|
|
|
102922
103087
|
...run.drawUsd ? ["--draw", run.drawUsd] : []
|
|
102923
103088
|
];
|
|
102924
103089
|
}
|
|
102925
|
-
async function readResultFile(
|
|
103090
|
+
async function readResultFile(readFile31, path) {
|
|
102926
103091
|
let text;
|
|
102927
103092
|
try {
|
|
102928
|
-
text = await
|
|
103093
|
+
text = await readFile31(path, "utf8");
|
|
102929
103094
|
} catch (error61) {
|
|
102930
103095
|
if (hasCode3(error61, "ENOENT")) return void 0;
|
|
102931
103096
|
return { state: "failed", detail: "unreadable result file" };
|
|
@@ -103775,7 +103940,7 @@ function isMcpInstallApp(value) {
|
|
|
103775
103940
|
function serverEntry(home, registry2) {
|
|
103776
103941
|
return {
|
|
103777
103942
|
command: "npx",
|
|
103778
|
-
args: ["-y", "vapi-network", "mcp"],
|
|
103943
|
+
args: ["-y", "vapi-network@latest", "mcp"],
|
|
103779
103944
|
env: { VAPI_HOME: home, VAPI_REGISTRY_URL: registry2 }
|
|
103780
103945
|
};
|
|
103781
103946
|
}
|
|
@@ -103824,7 +103989,7 @@ function tomlConfig(existing, entry) {
|
|
|
103824
103989
|
const block = [
|
|
103825
103990
|
"[mcp_servers.vapi]",
|
|
103826
103991
|
'command = "npx"',
|
|
103827
|
-
'args = ["-y", "vapi-network", "mcp"]',
|
|
103992
|
+
'args = ["-y", "vapi-network@latest", "mcp"]',
|
|
103828
103993
|
`env = { VAPI_HOME = "${escapeToml(entry.env.VAPI_HOME)}", VAPI_REGISTRY_URL = "${escapeToml(entry.env.VAPI_REGISTRY_URL)}" }`,
|
|
103829
103994
|
""
|
|
103830
103995
|
].join("\n");
|
|
@@ -103991,13 +104156,13 @@ async function sendConfig(dependencies) {
|
|
|
103991
104156
|
// ../cli/src/setup.ts
|
|
103992
104157
|
import { rm as rm5 } from "node:fs/promises";
|
|
103993
104158
|
import { join as join26 } from "node:path";
|
|
103994
|
-
var SETUP_ARGUMENT_ERROR =
|
|
104159
|
+
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.`;
|
|
103995
104160
|
var VAULT_CHOICE = "Create a new vault, or restore one from a recovery phrase? [new/restore] ";
|
|
103996
104161
|
async function setupCommand(argv, json2, io, dependencies) {
|
|
103997
104162
|
let parsed;
|
|
103998
104163
|
try {
|
|
103999
104164
|
parsed = parseArguments(argv, {
|
|
104000
|
-
valueOptions: /* @__PURE__ */ new Set(),
|
|
104165
|
+
valueOptions: /* @__PURE__ */ new Set(["--accounts"]),
|
|
104001
104166
|
booleanOptions: /* @__PURE__ */ new Set(["--no-cloud-backup"]),
|
|
104002
104167
|
maximumPositionals: 0
|
|
104003
104168
|
});
|
|
@@ -104008,6 +104173,7 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
104008
104173
|
const paths = getVapiPaths();
|
|
104009
104174
|
const steps = [];
|
|
104010
104175
|
const humanIo = json2 ? stderrIo(io) : io;
|
|
104176
|
+
const accountCount = parseAccountCount(parsed.one("--accounts"));
|
|
104011
104177
|
if (!await fileExists2(paths.config)) {
|
|
104012
104178
|
await writeDefaultConfig(paths.config, process.env, { networks: ["base"] });
|
|
104013
104179
|
steps.push("config");
|
|
@@ -104018,6 +104184,7 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
104018
104184
|
let changedVault = false;
|
|
104019
104185
|
let changedAccount = false;
|
|
104020
104186
|
let changedLink = false;
|
|
104187
|
+
let scannedAddresses;
|
|
104021
104188
|
if (!await fileExists2(join26(paths.directory, "vault.json"))) {
|
|
104022
104189
|
const choice = await vaultChoice(dependencies);
|
|
104023
104190
|
if (choice === "restore") {
|
|
@@ -104025,12 +104192,14 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
104025
104192
|
throw new Error("Restoring needs a terminal to type the phrase.");
|
|
104026
104193
|
}
|
|
104027
104194
|
const readSecret = dependencies.prompts?.secret ?? promptForSecret;
|
|
104028
|
-
await restoreVaultFromPhrase(
|
|
104195
|
+
const restored = await restoreVaultFromPhrase(
|
|
104029
104196
|
await readSecret("Recovery phrase: "),
|
|
104030
104197
|
config2,
|
|
104031
104198
|
humanIo,
|
|
104032
|
-
dependencies
|
|
104199
|
+
dependencies,
|
|
104200
|
+
accountCount
|
|
104033
104201
|
);
|
|
104202
|
+
scannedAddresses = restored.scannedAddresses;
|
|
104034
104203
|
store = await WalletStore.open(paths.directory, {
|
|
104035
104204
|
secrets: getSecretStore(dependencies),
|
|
104036
104205
|
env: dependencies.env ?? process.env,
|
|
@@ -104083,22 +104252,35 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
104083
104252
|
}
|
|
104084
104253
|
if (json2) {
|
|
104085
104254
|
io.stdout(
|
|
104086
|
-
JSON.stringify({
|
|
104255
|
+
JSON.stringify({
|
|
104256
|
+
vault,
|
|
104257
|
+
account,
|
|
104258
|
+
address: address4,
|
|
104259
|
+
linked,
|
|
104260
|
+
steps,
|
|
104261
|
+
cloudBackup,
|
|
104262
|
+
...scannedAddresses === void 0 ? {} : { scannedAddresses }
|
|
104263
|
+
})
|
|
104087
104264
|
);
|
|
104088
104265
|
}
|
|
104089
104266
|
}
|
|
104090
|
-
async function restoreVaultFromPhrase(phrase, config2, io, dependencies) {
|
|
104267
|
+
async function restoreVaultFromPhrase(phrase, config2, io, dependencies, accountCount) {
|
|
104091
104268
|
const paths = getVapiPaths();
|
|
104092
104269
|
const validatedPhrase = validateRecoveryPhrase(phrase);
|
|
104093
104270
|
const readBalance3 = baseUsdcBalanceReader(config2, dependencies);
|
|
104094
104271
|
const key2 = await loadOrCreateDeviceKey({ secrets: getSecretStore(dependencies) });
|
|
104095
104272
|
let names;
|
|
104273
|
+
let scannedAddresses = 0;
|
|
104096
104274
|
try {
|
|
104097
104275
|
const restored = await restoreVault({
|
|
104098
104276
|
path: join26(paths.directory, "vault.json"),
|
|
104099
104277
|
key: key2,
|
|
104100
104278
|
phrase: validatedPhrase,
|
|
104101
104279
|
probe: async (address4) => await readBalance3(address4) > 0n,
|
|
104280
|
+
...accountCount === void 0 ? {} : { accountCount },
|
|
104281
|
+
onScanComplete: (count) => {
|
|
104282
|
+
scannedAddresses = count;
|
|
104283
|
+
},
|
|
104102
104284
|
...dependencies.now === void 0 ? {} : { now: dependencies.now }
|
|
104103
104285
|
});
|
|
104104
104286
|
names = restored.accounts().map((account) => account.name);
|
|
@@ -104110,8 +104292,25 @@ async function restoreVaultFromPhrase(phrase, config2, io, dependencies) {
|
|
|
104110
104292
|
...names[0] === void 0 ? {} : { wallet: names[0] },
|
|
104111
104293
|
detail: `${names.length} account(s)`
|
|
104112
104294
|
});
|
|
104113
|
-
io.stdout(
|
|
104114
|
-
|
|
104295
|
+
io.stdout(
|
|
104296
|
+
`Vault restored with ${names.length} account(s): ${names.join(", ")}. ${scannedAddresses} address(es) scanned.`
|
|
104297
|
+
);
|
|
104298
|
+
return { names, scannedAddresses };
|
|
104299
|
+
}
|
|
104300
|
+
function parseAccountCount(value) {
|
|
104301
|
+
if (value === void 0) return void 0;
|
|
104302
|
+
if (!/^\d+$/u.test(value)) {
|
|
104303
|
+
throw new UsageError(
|
|
104304
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
104305
|
+
);
|
|
104306
|
+
}
|
|
104307
|
+
const count = Number(value);
|
|
104308
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > MAX_RESTORE_ACCOUNTS) {
|
|
104309
|
+
throw new UsageError(
|
|
104310
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
104311
|
+
);
|
|
104312
|
+
}
|
|
104313
|
+
return count;
|
|
104115
104314
|
}
|
|
104116
104315
|
async function vaultChoice(dependencies) {
|
|
104117
104316
|
const answer = dependencies.prompts?.line === void 0 ? isInteractive(dependencies) ? await promptForLine(VAULT_CHOICE) : "" : await dependencies.prompts.line(VAULT_CHOICE);
|
|
@@ -106219,6 +106418,7 @@ async function referencedSleep(milliseconds, signal) {
|
|
|
106219
106418
|
// ../cli/src/vault.ts
|
|
106220
106419
|
import { join as join27 } from "node:path";
|
|
106221
106420
|
var VAULT_USAGE = "Usage: vapi vault protect|unprotect|lock|unlock|status [--json]";
|
|
106421
|
+
var RESTORE_USAGE = "Usage: vapi restore [--accounts <n> | --from-owner [--owner <0x\u2026>]] [--json]";
|
|
106222
106422
|
var LEGACY_PASSWORD_NOTICE = "VAPI_KEYSTORE_PASSWORD is deprecated for vault passwords; use VAPI_VAULT_PASSWORD instead.";
|
|
106223
106423
|
async function vaultCommand(argv, json2, io, dependencies) {
|
|
106224
106424
|
const subcommand = argv[0];
|
|
@@ -106248,9 +106448,17 @@ async function restoreCommand(argv, json2, io, dependencies) {
|
|
|
106248
106448
|
await restoreFromOwnerCommand(argv, json2, io, dependencies);
|
|
106249
106449
|
return;
|
|
106250
106450
|
}
|
|
106251
|
-
|
|
106252
|
-
|
|
106451
|
+
let parsed;
|
|
106452
|
+
try {
|
|
106453
|
+
parsed = parseArguments(argv, {
|
|
106454
|
+
valueOptions: /* @__PURE__ */ new Set(["--accounts"]),
|
|
106455
|
+
maximumPositionals: 0
|
|
106456
|
+
});
|
|
106457
|
+
} catch (error61) {
|
|
106458
|
+
if (error61 instanceof UsageError) throw new UsageError(RESTORE_USAGE);
|
|
106459
|
+
throw error61;
|
|
106253
106460
|
}
|
|
106461
|
+
const accountCount = parseRestoreAccountCount(parsed.one("--accounts"));
|
|
106254
106462
|
const paths = getVapiPaths();
|
|
106255
106463
|
const path = join27(paths.directory, "vault.json");
|
|
106256
106464
|
if (await fileExists2(path)) {
|
|
@@ -106264,13 +106472,39 @@ async function restoreCommand(argv, json2, io, dependencies) {
|
|
|
106264
106472
|
const config2 = await readConfig(paths.config, json2 ? quietIo(io) : io);
|
|
106265
106473
|
const phrase = isStdinInteractive(dependencies) ? await getPrompts(dependencies).secret("Recovery phrase: ") : await (dependencies.readStdin ?? readProcessStdin3)();
|
|
106266
106474
|
const restoreIo = json2 ? quietIo(io) : io;
|
|
106267
|
-
const { names } = await restoreVaultFromPhrase(
|
|
106475
|
+
const { names, scannedAddresses } = await restoreVaultFromPhrase(
|
|
106476
|
+
phrase.trim(),
|
|
106477
|
+
config2,
|
|
106478
|
+
restoreIo,
|
|
106479
|
+
dependencies,
|
|
106480
|
+
accountCount
|
|
106481
|
+
);
|
|
106268
106482
|
if (json2) {
|
|
106269
|
-
output3(
|
|
106483
|
+
output3(
|
|
106484
|
+
io,
|
|
106485
|
+
true,
|
|
106486
|
+
{ command: "restore", vault: "restored", accounts: names, scannedAddresses },
|
|
106487
|
+
""
|
|
106488
|
+
);
|
|
106270
106489
|
return;
|
|
106271
106490
|
}
|
|
106272
106491
|
io.stdout(`Run vapi setup to link ${names[0]}.`);
|
|
106273
106492
|
}
|
|
106493
|
+
function parseRestoreAccountCount(value) {
|
|
106494
|
+
if (value === void 0) return void 0;
|
|
106495
|
+
if (!/^\d+$/u.test(value)) {
|
|
106496
|
+
throw new UsageError(
|
|
106497
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
106498
|
+
);
|
|
106499
|
+
}
|
|
106500
|
+
const count = Number(value);
|
|
106501
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > MAX_RESTORE_ACCOUNTS) {
|
|
106502
|
+
throw new UsageError(
|
|
106503
|
+
`--accounts must be a positive integer no greater than ${MAX_RESTORE_ACCOUNTS}.`
|
|
106504
|
+
);
|
|
106505
|
+
}
|
|
106506
|
+
return count;
|
|
106507
|
+
}
|
|
106274
106508
|
async function protectCommand(argv, json2, io, dependencies) {
|
|
106275
106509
|
requireNoArguments(argv);
|
|
106276
106510
|
const env = getEnvironment(dependencies);
|
|
@@ -106400,8 +106634,8 @@ var HELP_HEADING = "vAPI Network";
|
|
|
106400
106634
|
var HELP = `${HELP_HEADING}
|
|
106401
106635
|
|
|
106402
106636
|
Usage:
|
|
106403
|
-
vapi init [--networks <base,arc
|
|
106404
|
-
vapi setup [--no-cloud-backup] [--json]
|
|
106637
|
+
vapi init [--networks <base,arc>] [--json]
|
|
106638
|
+
vapi setup [--no-cloud-backup] [--accounts <n>] [--json]
|
|
106405
106639
|
vapi accounts [--all] [--json]
|
|
106406
106640
|
vapi accounts add <name> [--label <text>] [--no-link] [--json]
|
|
106407
106641
|
vapi accounts import <name> [--keystore <path> | --key-file <path>] [--label <text>] [--json]
|
|
@@ -106431,7 +106665,7 @@ Usage:
|
|
|
106431
106665
|
vapi docs read <url-or-path> [--json]
|
|
106432
106666
|
vapi search [query] [--kind <kind>] [--network <caip2>] [--limit <n>] [--cursor <cursor>] [--include-unverified] [--json]
|
|
106433
106667
|
vapi inspect <id> [--endpoint <name>] [--json]
|
|
106434
|
-
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]
|
|
106668
|
+
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]
|
|
106435
106669
|
vapi pay --resume <receipt-id> [--json]
|
|
106436
106670
|
vapi check <url> [--method <method>] [--json]
|
|
106437
106671
|
vapi balance [--account <name>] [--json]
|
|
@@ -106477,8 +106711,8 @@ Usage:
|
|
|
106477
106711
|
vapi task status <id> [--account <name>] [--json]
|
|
106478
106712
|
vapi export-key [--network <caip2>] [--account <name>] [--json]
|
|
106479
106713
|
vapi backup [--account <name>] [--cloud [off]] [--json]
|
|
106480
|
-
vapi restore [--from-owner [--owner <0x\u2026>]] [--json]
|
|
106481
|
-
vapi import (--phrase | --key) [--account <name>] [--networks <base,arc
|
|
106714
|
+
vapi restore [--accounts <n> | --from-owner [--owner <0x\u2026>]] [--json]
|
|
106715
|
+
vapi import (--phrase | --key) [--account <name>] [--networks <base,arc>] [--replace] [--force] [--json]
|
|
106482
106716
|
vapi passphrase [--account <name>] [--json]
|
|
106483
106717
|
vapi vault protect [--json]
|
|
106484
106718
|
vapi vault unprotect [--json]
|
|
@@ -106506,6 +106740,8 @@ Every command that touches a wallet takes \`--account <name>\`, falls back to \`
|
|
|
106506
106740
|
|
|
106507
106741
|
\`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]\`.
|
|
106508
106742
|
|
|
106743
|
+
Solana listings remain searchable; inspect and pay return \`unsupported_network\`. Solana keys are not part of the device vault yet.
|
|
106744
|
+
|
|
106509
106745
|
\`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.
|
|
106510
106746
|
|
|
106511
106747
|
\`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.
|
|
@@ -106518,7 +106754,7 @@ Every command that touches a wallet takes \`--account <name>\`, falls back to \`
|
|
|
106518
106754
|
|
|
106519
106755
|
\`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.
|
|
106520
106756
|
|
|
106521
|
-
\`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
|
|
106757
|
+
\`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.
|
|
106522
106758
|
|
|
106523
106759
|
\`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.
|
|
106524
106760
|
|
|
@@ -107307,7 +107543,7 @@ async function inspectCommand(argv, json2, io, dependencies) {
|
|
|
107307
107543
|
);
|
|
107308
107544
|
output3(io, json2, result, formatInspect(result));
|
|
107309
107545
|
}
|
|
107310
|
-
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]";
|
|
107546
|
+
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]";
|
|
107311
107547
|
async function payCommand(argv, json2, io, dependencies) {
|
|
107312
107548
|
if (argv.includes(RESUME_OPTION)) {
|
|
107313
107549
|
await payResumeCommand(argv, json2, io, dependencies);
|
|
@@ -107323,11 +107559,13 @@ async function payCommand(argv, json2, io, dependencies) {
|
|
|
107323
107559
|
"--expected-pay-to",
|
|
107324
107560
|
"--max",
|
|
107325
107561
|
"--max-price-usd",
|
|
107562
|
+
"--timeout",
|
|
107326
107563
|
WALLET_OPTION5
|
|
107327
107564
|
]),
|
|
107328
107565
|
maximumPositionals: 1
|
|
107329
107566
|
});
|
|
107330
107567
|
const target = requiredPositional(parsed.positionals[0], "<id-or-url>", PAY_USAGE);
|
|
107568
|
+
const timeoutSeconds = optionalBoundedInteger(parsed.one("--timeout"), "--timeout", 1, 300);
|
|
107331
107569
|
const paths = getVapiPaths();
|
|
107332
107570
|
const config2 = await readConfig(paths.config, io);
|
|
107333
107571
|
const wallet = await targetWallet(parsed, dependencies);
|
|
@@ -107343,7 +107581,8 @@ async function payCommand(argv, json2, io, dependencies) {
|
|
|
107343
107581
|
...parsed.one("--content-type") ? { contentType: parsed.one("--content-type") } : {},
|
|
107344
107582
|
...parsed.one("--network") ? { network: parsed.one("--network") } : {},
|
|
107345
107583
|
...parsed.one("--expected-pay-to") ? { expectedPayTo: parsed.one("--expected-pay-to") } : {},
|
|
107346
|
-
...maxPriceUsd ? { maxPriceUsd } : {}
|
|
107584
|
+
...maxPriceUsd ? { maxPriceUsd } : {},
|
|
107585
|
+
...timeoutSeconds === void 0 ? {} : { timeoutSeconds }
|
|
107347
107586
|
};
|
|
107348
107587
|
const call2 = createCallPort({
|
|
107349
107588
|
config: config2,
|
|
@@ -109018,7 +109257,7 @@ function buildNextSteps(address4) {
|
|
|
109018
109257
|
formatNextStep("Pay", "vapi pay <ref> --max 0.02"),
|
|
109019
109258
|
formatNextStep(
|
|
109020
109259
|
"Agent",
|
|
109021
|
-
'add {"command":"npx","args":["-y","vapi-network","mcp"]} to your MCP config'
|
|
109260
|
+
'add {"command":"npx","args":["-y","vapi-network@latest","mcp"]} to your MCP config'
|
|
109022
109261
|
)
|
|
109023
109262
|
];
|
|
109024
109263
|
}
|
|
@@ -109199,6 +109438,17 @@ function optionalPositiveInteger(value, option) {
|
|
|
109199
109438
|
if (result === 0) throw new UsageError(`${option} must be a positive integer.`);
|
|
109200
109439
|
return result;
|
|
109201
109440
|
}
|
|
109441
|
+
function optionalBoundedInteger(value, option, minimum, maximum) {
|
|
109442
|
+
if (value === void 0) return void 0;
|
|
109443
|
+
if (!/^\d+$/.test(value)) {
|
|
109444
|
+
throw new UsageError(`${option} must be an integer from ${minimum} to ${maximum}.`);
|
|
109445
|
+
}
|
|
109446
|
+
const parsed = Number(value);
|
|
109447
|
+
if (!Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
|
|
109448
|
+
throw new UsageError(`${option} must be an integer from ${minimum} to ${maximum}.`);
|
|
109449
|
+
}
|
|
109450
|
+
return parsed;
|
|
109451
|
+
}
|
|
109202
109452
|
function optionalUsdAmount(value, option) {
|
|
109203
109453
|
if (value === void 0) return void 0;
|
|
109204
109454
|
if (!/^\d+(?:\.\d{1,2})?$/.test(value)) {
|
|
@@ -109259,12 +109509,138 @@ function parseInitNetworks(value) {
|
|
|
109259
109509
|
}
|
|
109260
109510
|
for (const network of networks) {
|
|
109261
109511
|
if (network !== "base" && network !== "arc" && network !== "solana") {
|
|
109262
|
-
throw new UsageError("--networks supports base
|
|
109512
|
+
throw new UsageError("--networks supports base and arc; Solana vault setup is unavailable.");
|
|
109263
109513
|
}
|
|
109264
109514
|
}
|
|
109265
109515
|
return networks;
|
|
109266
109516
|
}
|
|
109267
109517
|
|
|
109518
|
+
// ../cli/src/update-check.ts
|
|
109519
|
+
import { lookup } from "node:dns/promises";
|
|
109520
|
+
import { mkdir as mkdir21, readFile as readFile30, writeFile as writeFile12 } from "node:fs/promises";
|
|
109521
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
109522
|
+
var CHECK_TIMEOUT_MS = 1500;
|
|
109523
|
+
var LATEST_URL = "https://registry.npmjs.org/vapi-network/latest";
|
|
109524
|
+
async function runCliWithUpdateCheck(argv = process.argv.slice(2), io = {
|
|
109525
|
+
stdout: (message) => console.log(message),
|
|
109526
|
+
stderr: (message) => console.error(message)
|
|
109527
|
+
}, dependencies = {}, options = {}) {
|
|
109528
|
+
const notice = checkForUpdate({ ...options, env: options.env ?? dependencies.env, argv });
|
|
109529
|
+
const code = await runCli(argv, io, dependencies);
|
|
109530
|
+
const message = await notice;
|
|
109531
|
+
if (message) io.stderr(message);
|
|
109532
|
+
return code;
|
|
109533
|
+
}
|
|
109534
|
+
async function checkForUpdate(options = {}) {
|
|
109535
|
+
const env = options.env ?? process.env;
|
|
109536
|
+
const argv = options.argv ?? process.argv.slice(2);
|
|
109537
|
+
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) {
|
|
109538
|
+
return void 0;
|
|
109539
|
+
}
|
|
109540
|
+
const controller = new AbortController();
|
|
109541
|
+
let timer;
|
|
109542
|
+
try {
|
|
109543
|
+
return await Promise.race([
|
|
109544
|
+
latestNotice(options, env, controller.signal),
|
|
109545
|
+
new Promise((resolve3) => {
|
|
109546
|
+
timer = setTimeout(() => {
|
|
109547
|
+
controller.abort();
|
|
109548
|
+
resolve3(void 0);
|
|
109549
|
+
}, CHECK_TIMEOUT_MS);
|
|
109550
|
+
})
|
|
109551
|
+
]);
|
|
109552
|
+
} catch {
|
|
109553
|
+
return void 0;
|
|
109554
|
+
} finally {
|
|
109555
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
109556
|
+
controller.abort();
|
|
109557
|
+
}
|
|
109558
|
+
}
|
|
109559
|
+
async function latestNotice(options, env, signal) {
|
|
109560
|
+
const paths = getVapiPaths(options.home ?? (env.VAPI_HOME?.trim() || void 0));
|
|
109561
|
+
const now = (options.nowMs ?? Date.now)();
|
|
109562
|
+
let cached2;
|
|
109563
|
+
try {
|
|
109564
|
+
const value = JSON.parse(await readFile30(paths.updateCheck, "utf8"));
|
|
109565
|
+
if (isRecord12(value) && typeof value.checkedAt === "number" && Number.isFinite(value.checkedAt) && typeof value.latest === "string" && parseVersion(value.latest)) {
|
|
109566
|
+
cached2 = { checkedAt: value.checkedAt, latest: value.latest };
|
|
109567
|
+
}
|
|
109568
|
+
} catch {
|
|
109569
|
+
}
|
|
109570
|
+
signal.throwIfAborted();
|
|
109571
|
+
let latest = cached2?.latest ?? CLI_VERSION;
|
|
109572
|
+
if (cached2 === void 0 || now - cached2.checkedAt >= CHECK_INTERVAL_MS || now < cached2.checkedAt) {
|
|
109573
|
+
await mkdir21(paths.directory, { recursive: true });
|
|
109574
|
+
signal.throwIfAborted();
|
|
109575
|
+
await writeFile12(paths.updateCheck, JSON.stringify({ checkedAt: now, latest }), { mode: 384 });
|
|
109576
|
+
signal.throwIfAborted();
|
|
109577
|
+
const fetchImpl = options.fetchImpl ?? createPublicFetch({
|
|
109578
|
+
allowPrivateNetwork: false,
|
|
109579
|
+
lookup: async (hostname4) => {
|
|
109580
|
+
let onAbort;
|
|
109581
|
+
const aborted2 = new Promise((_resolve, reject) => {
|
|
109582
|
+
onAbort = () => reject(signal.reason);
|
|
109583
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
109584
|
+
});
|
|
109585
|
+
try {
|
|
109586
|
+
signal.throwIfAborted();
|
|
109587
|
+
const addresses = await Promise.race([lookup(hostname4, { all: true }), aborted2]);
|
|
109588
|
+
return addresses.map(({ address: address4 }) => address4);
|
|
109589
|
+
} finally {
|
|
109590
|
+
signal.removeEventListener("abort", onAbort);
|
|
109591
|
+
}
|
|
109592
|
+
}
|
|
109593
|
+
});
|
|
109594
|
+
const response = await fetchImpl(LATEST_URL, { signal, redirect: "error" });
|
|
109595
|
+
if (!response.ok) return void 0;
|
|
109596
|
+
const body = await response.json();
|
|
109597
|
+
signal.throwIfAborted();
|
|
109598
|
+
if (!isRecord12(body) || typeof body.version !== "string" || !parseVersion(body.version)) {
|
|
109599
|
+
return void 0;
|
|
109600
|
+
}
|
|
109601
|
+
latest = body.version;
|
|
109602
|
+
await writeFile12(paths.updateCheck, JSON.stringify({ checkedAt: now, latest }), { mode: 384 });
|
|
109603
|
+
}
|
|
109604
|
+
signal.throwIfAborted();
|
|
109605
|
+
return isNewerVersion(latest, CLI_VERSION) ? `vapi-network ${latest} is available (you have ${CLI_VERSION}). Update: npm i -g vapi-network@latest` : void 0;
|
|
109606
|
+
}
|
|
109607
|
+
function isRecord12(value) {
|
|
109608
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
109609
|
+
}
|
|
109610
|
+
function parseVersion(version5) {
|
|
109611
|
+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-zA-Z.-]+))?(?:\+[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?$/.exec(
|
|
109612
|
+
version5
|
|
109613
|
+
);
|
|
109614
|
+
if (!match) return void 0;
|
|
109615
|
+
const prerelease = match[4]?.split(".");
|
|
109616
|
+
if (prerelease?.some((part) => part === "" || /^\d+$/.test(part) && /^0\d/.test(part))) {
|
|
109617
|
+
return void 0;
|
|
109618
|
+
}
|
|
109619
|
+
return { core: match.slice(1, 4).map(BigInt), prerelease };
|
|
109620
|
+
}
|
|
109621
|
+
function isNewerVersion(latest, current) {
|
|
109622
|
+
const next = parseVersion(latest);
|
|
109623
|
+
const running = parseVersion(current);
|
|
109624
|
+
for (let index2 = 0; index2 < 3; index2 += 1) {
|
|
109625
|
+
if (next.core[index2] !== running.core[index2]) return next.core[index2] > running.core[index2];
|
|
109626
|
+
}
|
|
109627
|
+
if (running.prerelease === void 0) return false;
|
|
109628
|
+
if (next.prerelease === void 0) return true;
|
|
109629
|
+
for (let index2 = 0; index2 < Math.max(next.prerelease.length, running.prerelease.length); index2 += 1) {
|
|
109630
|
+
const a = next.prerelease[index2];
|
|
109631
|
+
const b = running.prerelease[index2];
|
|
109632
|
+
if (a === b) continue;
|
|
109633
|
+
if (a === void 0) return false;
|
|
109634
|
+
if (b === void 0) return true;
|
|
109635
|
+
const aNumeric = /^\d+$/.test(a);
|
|
109636
|
+
const bNumeric = /^\d+$/.test(b);
|
|
109637
|
+
if (aNumeric && bNumeric) return BigInt(a) > BigInt(b);
|
|
109638
|
+
if (aNumeric !== bNumeric) return !aNumeric;
|
|
109639
|
+
return a > b;
|
|
109640
|
+
}
|
|
109641
|
+
return false;
|
|
109642
|
+
}
|
|
109643
|
+
|
|
109268
109644
|
// src/client.ts
|
|
109269
109645
|
import { homedir as homedir3 } from "node:os";
|
|
109270
109646
|
import { join as join29 } from "node:path";
|
|
@@ -109299,10 +109675,18 @@ async function createVapiClient(options = {}) {
|
|
|
109299
109675
|
}
|
|
109300
109676
|
const address4 = storedAddress;
|
|
109301
109677
|
let accountPromise;
|
|
109302
|
-
const account = () => {
|
|
109303
|
-
if (injected !== void 0) return
|
|
109304
|
-
|
|
109305
|
-
|
|
109678
|
+
const account = async () => {
|
|
109679
|
+
if (injected !== void 0) return injected;
|
|
109680
|
+
try {
|
|
109681
|
+
if (accountPromise !== void 0 && !env.VAPI_VAULT_PASSWORD?.trim()) {
|
|
109682
|
+
await wallets.assertSigningAuthority(selected.name);
|
|
109683
|
+
}
|
|
109684
|
+
accountPromise ??= unlockOnce();
|
|
109685
|
+
return await accountPromise;
|
|
109686
|
+
} catch (error61) {
|
|
109687
|
+
accountPromise = void 0;
|
|
109688
|
+
throw error61;
|
|
109689
|
+
}
|
|
109306
109690
|
};
|
|
109307
109691
|
const unlockOnce = async () => {
|
|
109308
109692
|
if (await wallets.hasVaultAccount(selected.name)) {
|
|
@@ -109449,7 +109833,10 @@ async function createVapiClient(options = {}) {
|
|
|
109449
109833
|
account: await account(),
|
|
109450
109834
|
wallet: selected.name,
|
|
109451
109835
|
spendCaps,
|
|
109452
|
-
currentSpendCaps
|
|
109836
|
+
currentSpendCaps: async () => {
|
|
109837
|
+
await account();
|
|
109838
|
+
return await currentSpendCaps();
|
|
109839
|
+
},
|
|
109453
109840
|
chat: async (request) => await routerChat(deps, request),
|
|
109454
109841
|
approve: runOptions.approve ?? (async () => false),
|
|
109455
109842
|
...runOptions.onEvent === void 0 ? {} : { onEvent: runOptions.onEvent },
|