@vapi-network/cli 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +5 -1
- package/dist/cli.js +103 -30
- package/dist/cli.js.map +2 -2
- package/dist/index.js +103 -30
- package/dist/index.js.map +2 -2
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -43924,7 +43924,7 @@ async function assertPublicUrl(url2, options) {
|
|
|
43924
43924
|
options.timeoutMs ?? 5e3
|
|
43925
43925
|
);
|
|
43926
43926
|
} catch {
|
|
43927
|
-
throw guardError(url2);
|
|
43927
|
+
throw guardError(url2, "unresolved");
|
|
43928
43928
|
}
|
|
43929
43929
|
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
43930
43930
|
throw guardError(url2);
|
|
@@ -44079,10 +44079,67 @@ function isNonPublicIpv6(hextets) {
|
|
|
44079
44079
|
const isDocumentation = first === 8193 && hextets[1] === 3512;
|
|
44080
44080
|
return isUnspecified || isLoopback || isUniqueLocal || isLinkLocal || isSiteLocal || isMulticast || isDocumentation;
|
|
44081
44081
|
}
|
|
44082
|
-
|
|
44083
|
-
|
|
44084
|
-
|
|
44082
|
+
var NetworkGuardError = class extends Error {
|
|
44083
|
+
constructor(message, reason) {
|
|
44084
|
+
super(message);
|
|
44085
|
+
this.reason = reason;
|
|
44086
|
+
this.name = "NetworkGuardError";
|
|
44087
|
+
}
|
|
44088
|
+
reason;
|
|
44089
|
+
};
|
|
44090
|
+
function guardError(url2, reason = "blocked") {
|
|
44091
|
+
return new NetworkGuardError(
|
|
44092
|
+
`URL hostname ${JSON.stringify(url2.hostname)} is not allowed; private or internal destinations require allowPrivateNetwork true in the vAPI config.`,
|
|
44093
|
+
reason
|
|
44094
|
+
);
|
|
44095
|
+
}
|
|
44096
|
+
var PROXY_VARIABLES = {
|
|
44097
|
+
"https:": ["HTTPS_PROXY", "https_proxy"],
|
|
44098
|
+
"http:": ["HTTP_PROXY", "http_proxy"]
|
|
44099
|
+
};
|
|
44100
|
+
var SYSTEM_ERROR_CODE = /^[A-Z][A-Z0-9_]{1,39}$/u;
|
|
44101
|
+
function describeNetworkFailure(error61, url2, env = process.env) {
|
|
44102
|
+
const host = url2.host;
|
|
44103
|
+
let reason;
|
|
44104
|
+
const guard = guardReason(error61);
|
|
44105
|
+
if (guard !== void 0) {
|
|
44106
|
+
reason = guard === "unresolved" ? `the DNS lookup for ${host} failed` : `${host} is not a public address`;
|
|
44107
|
+
} else if (isTimeout(error61)) {
|
|
44108
|
+
reason = `the connection to ${host} timed out`;
|
|
44109
|
+
} else {
|
|
44110
|
+
const code = systemErrorCode(error61);
|
|
44111
|
+
reason = `could not connect to ${host}${code === void 0 ? "" : ` (${code})`}`;
|
|
44112
|
+
}
|
|
44113
|
+
const proxy = (PROXY_VARIABLES[url2.protocol] ?? []).find(
|
|
44114
|
+
(name) => (env[name] ?? "").trim() !== ""
|
|
44085
44115
|
);
|
|
44116
|
+
let hint = "";
|
|
44117
|
+
if (proxy !== void 0) {
|
|
44118
|
+
if (env.NODE_USE_ENV_PROXY !== "1") {
|
|
44119
|
+
hint = ` ${proxy} is set, but Node.js uses it only with NODE_USE_ENV_PROXY=1 (Node.js 22.21 or later): run the command again with NODE_USE_ENV_PROXY=1.`;
|
|
44120
|
+
} else if (guard === "unresolved") {
|
|
44121
|
+
hint = ` vapi looks ${host} up on this machine before it uses the proxy in ${proxy}, so the name must resolve here too.`;
|
|
44122
|
+
} else if (guard === void 0) {
|
|
44123
|
+
hint = ` NODE_USE_ENV_PROXY=1 and ${proxy} are set, so the proxy may have refused the connection.`;
|
|
44124
|
+
}
|
|
44125
|
+
}
|
|
44126
|
+
return `${reason}.${hint}`;
|
|
44127
|
+
}
|
|
44128
|
+
function guardReason(error61) {
|
|
44129
|
+
if (!(error61 instanceof Error) || error61.name !== "NetworkGuardError") return void 0;
|
|
44130
|
+
const reason = error61.reason;
|
|
44131
|
+
return reason === "blocked" || reason === "unresolved" ? reason : void 0;
|
|
44132
|
+
}
|
|
44133
|
+
function isTimeout(error61) {
|
|
44134
|
+
return error61 instanceof Error && (error61.name === "TimeoutError" || error61.name === "AbortError");
|
|
44135
|
+
}
|
|
44136
|
+
function systemErrorCode(error61) {
|
|
44137
|
+
for (let current = error61, depth = 0; current instanceof Error && depth < 3; depth += 1) {
|
|
44138
|
+
const code = current.code;
|
|
44139
|
+
if (typeof code === "string" && SYSTEM_ERROR_CODE.test(code)) return code;
|
|
44140
|
+
current = current.cause;
|
|
44141
|
+
}
|
|
44142
|
+
return void 0;
|
|
44086
44143
|
}
|
|
44087
44144
|
|
|
44088
44145
|
// ../core/src/networks.ts
|
|
@@ -47201,12 +47258,12 @@ async function removeStaleLock(path) {
|
|
|
47201
47258
|
const pid = lockOwnerPid(owner);
|
|
47202
47259
|
if (pid !== void 0 && processIsAlive(pid)) return;
|
|
47203
47260
|
await atomicFileTestHooks?.beforeStaleLockBreak?.(path);
|
|
47204
|
-
await removeOwnedLock(path, [owner]);
|
|
47261
|
+
await removeOwnedLock(path, [owner], true);
|
|
47205
47262
|
} catch (error61) {
|
|
47206
47263
|
if (!hasCode(error61, "ENOENT")) throw error61;
|
|
47207
47264
|
}
|
|
47208
47265
|
}
|
|
47209
|
-
async function removeOwnedLock(path, owners) {
|
|
47266
|
+
async function removeOwnedLock(path, owners, staleDeadOwner = false) {
|
|
47210
47267
|
const tombPath = `${path}.stale.${randomBytes2(16).toString("hex")}`;
|
|
47211
47268
|
try {
|
|
47212
47269
|
await rename(path, tombPath);
|
|
@@ -47215,7 +47272,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
47215
47272
|
await removeOwnedTombs(path, owners);
|
|
47216
47273
|
const currentOwner = await readFile(path, "utf8").catch(() => void 0);
|
|
47217
47274
|
if (currentOwner !== void 0 && owners.includes(currentOwner)) {
|
|
47218
|
-
await removeOwnedLock(path, owners);
|
|
47275
|
+
await removeOwnedLock(path, owners, staleDeadOwner);
|
|
47219
47276
|
}
|
|
47220
47277
|
return;
|
|
47221
47278
|
}
|
|
@@ -47224,6 +47281,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
47224
47281
|
let pendingError;
|
|
47225
47282
|
let renamedOwner;
|
|
47226
47283
|
try {
|
|
47284
|
+
await atomicFileTestHooks?.afterLockRename?.(tombPath);
|
|
47227
47285
|
renamedOwner = await readFile(tombPath, "utf8");
|
|
47228
47286
|
if (!owners.includes(renamedOwner) && !lockOwnerReleased(renamedOwner)) {
|
|
47229
47287
|
await atomicFileTestHooks?.afterMismatchedLockRename?.(path);
|
|
@@ -47232,6 +47290,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
47232
47290
|
await atomicFileTestHooks?.afterMismatchedLockRestore?.(path);
|
|
47233
47291
|
}
|
|
47234
47292
|
} catch (error61) {
|
|
47293
|
+
if (hasCode(error61, "ENOENT")) return;
|
|
47235
47294
|
pendingError = error61;
|
|
47236
47295
|
}
|
|
47237
47296
|
try {
|
|
@@ -47240,7 +47299,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
47240
47299
|
} catch (error61) {
|
|
47241
47300
|
if (!tombUnlinkTolerated(
|
|
47242
47301
|
error61,
|
|
47243
|
-
renamedOwner !== void 0 && lockOwnerReleased(renamedOwner) && owners.includes(renamedOwner)
|
|
47302
|
+
renamedOwner !== void 0 && (lockOwnerReleased(renamedOwner) || staleDeadOwner) && owners.includes(renamedOwner)
|
|
47244
47303
|
) && pendingError === void 0) {
|
|
47245
47304
|
pendingError = error61;
|
|
47246
47305
|
}
|
|
@@ -48467,16 +48526,25 @@ function withBearer(init, accessToken) {
|
|
|
48467
48526
|
async function safeFetch(fetchImpl, input2, init) {
|
|
48468
48527
|
try {
|
|
48469
48528
|
return await fetchImpl(input2, init);
|
|
48470
|
-
} catch {
|
|
48471
|
-
throw httpError(
|
|
48529
|
+
} catch (error61) {
|
|
48530
|
+
throw httpError(`The vAPI agent link request failed: ${networkFailure(error61, input2)}`);
|
|
48472
48531
|
}
|
|
48473
48532
|
}
|
|
48474
48533
|
async function safeAgentFetch(fetchImpl, input2, init) {
|
|
48475
48534
|
try {
|
|
48476
48535
|
return await fetchImpl(input2, init);
|
|
48536
|
+
} catch (error61) {
|
|
48537
|
+
throw httpError(`The vAPI agent request failed: ${networkFailure(error61, input2)}`);
|
|
48538
|
+
}
|
|
48539
|
+
}
|
|
48540
|
+
function networkFailure(error61, input2) {
|
|
48541
|
+
let url2;
|
|
48542
|
+
try {
|
|
48543
|
+
url2 = new URL(input2 instanceof Request ? input2.url : input2);
|
|
48477
48544
|
} catch {
|
|
48478
|
-
|
|
48545
|
+
return "the request did not reach vAPI.";
|
|
48479
48546
|
}
|
|
48547
|
+
return describeNetworkFailure(error61, url2);
|
|
48480
48548
|
}
|
|
48481
48549
|
function deviceAuthorizationError(status, payload) {
|
|
48482
48550
|
const error61 = stringField(payload, "error");
|
|
@@ -78589,7 +78657,7 @@ function createRunBudget(args) {
|
|
|
78589
78657
|
import { mkdir as mkdir15, writeFile as writeFile7 } from "node:fs/promises";
|
|
78590
78658
|
import { arch, platform, release } from "node:os";
|
|
78591
78659
|
import { join as join14 } from "node:path";
|
|
78592
|
-
var VAPI_CLIENT_VERSION = "0.15.
|
|
78660
|
+
var VAPI_CLIENT_VERSION = "0.15.2";
|
|
78593
78661
|
async function createSupportReport(options) {
|
|
78594
78662
|
const message = options.message.trim();
|
|
78595
78663
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -102581,7 +102649,7 @@ async function readProcessStdin() {
|
|
|
102581
102649
|
}
|
|
102582
102650
|
|
|
102583
102651
|
// src/version.ts
|
|
102584
|
-
var CLI_VERSION = "0.15.
|
|
102652
|
+
var CLI_VERSION = "0.15.2";
|
|
102585
102653
|
|
|
102586
102654
|
// src/status.ts
|
|
102587
102655
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -106369,6 +106437,10 @@ ${RUN_USAGE}`
|
|
|
106369
106437
|
${RUN_USAGE}`);
|
|
106370
106438
|
}
|
|
106371
106439
|
const environment = getEnvironment(dependencies);
|
|
106440
|
+
const runIo = resultFile === void 0 ? io : {
|
|
106441
|
+
stdout: (message) => io.stdout(redactDetachedRunText(message, environment)),
|
|
106442
|
+
stderr: (message) => io.stderr(redactDetachedRunText(message, environment))
|
|
106443
|
+
};
|
|
106372
106444
|
const configuredRunId = environmentRunId(environment, "VAPI_RUN_ID");
|
|
106373
106445
|
const parentRunId = environmentRunId(environment, "VAPI_PARENT_RUN_ID");
|
|
106374
106446
|
const paths = getVapiPaths();
|
|
@@ -106380,8 +106452,8 @@ ${RUN_USAGE}`);
|
|
|
106380
106452
|
if (resultFile !== void 0) {
|
|
106381
106453
|
await writeJsonAtomic(resultFile, { v: 1, exitCode: 1, result: result2 }, { mode: 384 });
|
|
106382
106454
|
}
|
|
106383
|
-
if (json2)
|
|
106384
|
-
else
|
|
106455
|
+
if (json2) runIo.stdout(JSON.stringify(result2));
|
|
106456
|
+
else runIo.stderr(message);
|
|
106385
106457
|
return 1;
|
|
106386
106458
|
}
|
|
106387
106459
|
const runId = configuredRunId ?? createRunId();
|
|
@@ -106445,42 +106517,48 @@ ${RUN_USAGE}`);
|
|
|
106445
106517
|
...runMeta === void 0 ? {} : { runMeta },
|
|
106446
106518
|
approvals: "tty",
|
|
106447
106519
|
json: json2,
|
|
106448
|
-
io,
|
|
106520
|
+
io: runIo,
|
|
106449
106521
|
dependencies
|
|
106450
106522
|
});
|
|
106451
106523
|
const execute = dependencies.agent?.runAgent ?? runAgent;
|
|
106452
106524
|
const executed = await execute(task, runDependencies);
|
|
106453
106525
|
const result = resultFile === void 0 ? executed : redactAgentRunResult(executed, environment);
|
|
106454
|
-
if (!json2) printAgentRefills(result, io);
|
|
106526
|
+
if (!json2) printAgentRefills(result, runIo, io);
|
|
106455
106527
|
const exitCode = result.stoppedBecause.reason === "finished" ? 0 : 1;
|
|
106456
106528
|
if (resultFile !== void 0) {
|
|
106457
106529
|
await writeJsonAtomic(resultFile, { v: 1, exitCode, result }, { mode: 384 });
|
|
106458
106530
|
}
|
|
106459
106531
|
if (json2) {
|
|
106460
|
-
io.stdout(
|
|
106532
|
+
io.stdout(
|
|
106533
|
+
JSON.stringify(resultFile === void 0 ? result : redactAgentRunResult(result, environment))
|
|
106534
|
+
);
|
|
106461
106535
|
} else if (result.stoppedBecause.reason === "finished") {
|
|
106462
|
-
|
|
106536
|
+
runIo.stdout(result.answer ?? "");
|
|
106463
106537
|
} else {
|
|
106464
|
-
|
|
106538
|
+
runIo.stderr(result.stoppedBecause.detail ?? result.stoppedBecause.reason);
|
|
106465
106539
|
}
|
|
106466
106540
|
return exitCode;
|
|
106467
106541
|
}
|
|
106542
|
+
var SETTLEMENT_HASH = /^0x[0-9a-fA-F]{64}$/u;
|
|
106468
106543
|
function redactAgentRunResult(executed, environment) {
|
|
106469
106544
|
const result = redactDetachedRunValue(executed, environment);
|
|
106470
106545
|
for (const [index2, refill] of (executed.refills ?? []).entries()) {
|
|
106471
106546
|
const transaction2 = refill.receipt.transaction;
|
|
106472
106547
|
const redacted = result.refills?.[index2];
|
|
106473
|
-
if (redacted !== void 0 && transaction2 !== void 0 &&
|
|
106548
|
+
if (redacted !== void 0 && transaction2 !== void 0 && SETTLEMENT_HASH.test(transaction2)) {
|
|
106474
106549
|
redacted.receipt.transaction = transaction2;
|
|
106475
106550
|
}
|
|
106476
106551
|
}
|
|
106477
106552
|
return result;
|
|
106478
106553
|
}
|
|
106479
|
-
function printAgentRefills(result, io) {
|
|
106554
|
+
function printAgentRefills(result, io, settlementHashIo = io) {
|
|
106480
106555
|
for (const refill of result.refills ?? []) {
|
|
106481
106556
|
io.stderr(`Receipt: ${refill.receipt.id}`);
|
|
106482
|
-
|
|
106483
|
-
|
|
106557
|
+
const transaction2 = refill.receipt.transaction;
|
|
106558
|
+
if (transaction2 !== void 0) {
|
|
106559
|
+
const output4 = SETTLEMENT_HASH.test(transaction2) ? settlementHashIo : io;
|
|
106560
|
+
output4.stderr(`Transaction: ${transaction2}`);
|
|
106561
|
+
}
|
|
106484
106562
|
for (const warning of refill.warnings ?? []) io.stderr(warning.message);
|
|
106485
106563
|
}
|
|
106486
106564
|
}
|
|
@@ -111081,12 +111159,7 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
111081
111159
|
exitCode = 0;
|
|
111082
111160
|
break;
|
|
111083
111161
|
case "agent":
|
|
111084
|
-
exitCode = await agentCommand(
|
|
111085
|
-
args.slice(1),
|
|
111086
|
-
json2,
|
|
111087
|
-
args[1] === "run" && args.includes("--bundle-env") ? io : runIo,
|
|
111088
|
-
dependencies
|
|
111089
|
-
);
|
|
111162
|
+
exitCode = await agentCommand(args.slice(1), json2, io, dependencies);
|
|
111090
111163
|
break;
|
|
111091
111164
|
case "dashboard":
|
|
111092
111165
|
await dashboardCommand(args.slice(1), json2, io, dependencies);
|