vapi-network 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/README.md +1 -1
- package/SKILL.md +1 -1
- package/dist/cli.js +103 -30
- package/dist/cli.js.map +2 -2
- package/dist/index.js +105 -30
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10194,6 +10194,7 @@ __export(src_exports, {
|
|
|
10194
10194
|
NATIVE_ETH_FEE_MARGIN_PERCENT: () => NATIVE_ETH_FEE_MARGIN_PERCENT,
|
|
10195
10195
|
NATIVE_ETH_L1_FEE_FALLBACK_WEI: () => NATIVE_ETH_L1_FEE_FALLBACK_WEI,
|
|
10196
10196
|
NETWORKS: () => NETWORKS,
|
|
10197
|
+
NetworkGuardError: () => NetworkGuardError,
|
|
10197
10198
|
ONRAMP_FALLBACK_INSTRUCTIONS: () => ONRAMP_FALLBACK_INSTRUCTIONS,
|
|
10198
10199
|
ONRAMP_NETWORK: () => ONRAMP_NETWORK,
|
|
10199
10200
|
PASSPHRASE_ENVIRONMENT_VARIABLE: () => PASSPHRASE_ENVIRONMENT_VARIABLE,
|
|
@@ -10300,6 +10301,7 @@ __export(src_exports, {
|
|
|
10300
10301
|
deleteSwarmFile: () => deleteSwarmFile,
|
|
10301
10302
|
deriveEvmPrivateKey: () => deriveEvmPrivateKey,
|
|
10302
10303
|
deriveSolanaPrivateKey: () => deriveSolanaPrivateKey,
|
|
10304
|
+
describeNetworkFailure: () => describeNetworkFailure,
|
|
10303
10305
|
deviceName: () => deviceName,
|
|
10304
10306
|
discardBody: () => discardBody,
|
|
10305
10307
|
discover: () => discover,
|
|
@@ -44313,7 +44315,7 @@ async function assertPublicUrl(url2, options) {
|
|
|
44313
44315
|
options.timeoutMs ?? 5e3
|
|
44314
44316
|
);
|
|
44315
44317
|
} catch {
|
|
44316
|
-
throw guardError(url2);
|
|
44318
|
+
throw guardError(url2, "unresolved");
|
|
44317
44319
|
}
|
|
44318
44320
|
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
44319
44321
|
throw guardError(url2);
|
|
@@ -44468,10 +44470,67 @@ function isNonPublicIpv6(hextets) {
|
|
|
44468
44470
|
const isDocumentation = first === 8193 && hextets[1] === 3512;
|
|
44469
44471
|
return isUnspecified || isLoopback || isUniqueLocal || isLinkLocal || isSiteLocal || isMulticast || isDocumentation;
|
|
44470
44472
|
}
|
|
44471
|
-
|
|
44472
|
-
|
|
44473
|
-
|
|
44473
|
+
var NetworkGuardError = class extends Error {
|
|
44474
|
+
constructor(message, reason) {
|
|
44475
|
+
super(message);
|
|
44476
|
+
this.reason = reason;
|
|
44477
|
+
this.name = "NetworkGuardError";
|
|
44478
|
+
}
|
|
44479
|
+
reason;
|
|
44480
|
+
};
|
|
44481
|
+
function guardError(url2, reason = "blocked") {
|
|
44482
|
+
return new NetworkGuardError(
|
|
44483
|
+
`URL hostname ${JSON.stringify(url2.hostname)} is not allowed; private or internal destinations require allowPrivateNetwork true in the vAPI config.`,
|
|
44484
|
+
reason
|
|
44485
|
+
);
|
|
44486
|
+
}
|
|
44487
|
+
var PROXY_VARIABLES = {
|
|
44488
|
+
"https:": ["HTTPS_PROXY", "https_proxy"],
|
|
44489
|
+
"http:": ["HTTP_PROXY", "http_proxy"]
|
|
44490
|
+
};
|
|
44491
|
+
var SYSTEM_ERROR_CODE = /^[A-Z][A-Z0-9_]{1,39}$/u;
|
|
44492
|
+
function describeNetworkFailure(error61, url2, env = process.env) {
|
|
44493
|
+
const host = url2.host;
|
|
44494
|
+
let reason;
|
|
44495
|
+
const guard = guardReason(error61);
|
|
44496
|
+
if (guard !== void 0) {
|
|
44497
|
+
reason = guard === "unresolved" ? `the DNS lookup for ${host} failed` : `${host} is not a public address`;
|
|
44498
|
+
} else if (isTimeout(error61)) {
|
|
44499
|
+
reason = `the connection to ${host} timed out`;
|
|
44500
|
+
} else {
|
|
44501
|
+
const code = systemErrorCode(error61);
|
|
44502
|
+
reason = `could not connect to ${host}${code === void 0 ? "" : ` (${code})`}`;
|
|
44503
|
+
}
|
|
44504
|
+
const proxy = (PROXY_VARIABLES[url2.protocol] ?? []).find(
|
|
44505
|
+
(name) => (env[name] ?? "").trim() !== ""
|
|
44474
44506
|
);
|
|
44507
|
+
let hint = "";
|
|
44508
|
+
if (proxy !== void 0) {
|
|
44509
|
+
if (env.NODE_USE_ENV_PROXY !== "1") {
|
|
44510
|
+
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.`;
|
|
44511
|
+
} else if (guard === "unresolved") {
|
|
44512
|
+
hint = ` vapi looks ${host} up on this machine before it uses the proxy in ${proxy}, so the name must resolve here too.`;
|
|
44513
|
+
} else if (guard === void 0) {
|
|
44514
|
+
hint = ` NODE_USE_ENV_PROXY=1 and ${proxy} are set, so the proxy may have refused the connection.`;
|
|
44515
|
+
}
|
|
44516
|
+
}
|
|
44517
|
+
return `${reason}.${hint}`;
|
|
44518
|
+
}
|
|
44519
|
+
function guardReason(error61) {
|
|
44520
|
+
if (!(error61 instanceof Error) || error61.name !== "NetworkGuardError") return void 0;
|
|
44521
|
+
const reason = error61.reason;
|
|
44522
|
+
return reason === "blocked" || reason === "unresolved" ? reason : void 0;
|
|
44523
|
+
}
|
|
44524
|
+
function isTimeout(error61) {
|
|
44525
|
+
return error61 instanceof Error && (error61.name === "TimeoutError" || error61.name === "AbortError");
|
|
44526
|
+
}
|
|
44527
|
+
function systemErrorCode(error61) {
|
|
44528
|
+
for (let current = error61, depth = 0; current instanceof Error && depth < 3; depth += 1) {
|
|
44529
|
+
const code = current.code;
|
|
44530
|
+
if (typeof code === "string" && SYSTEM_ERROR_CODE.test(code)) return code;
|
|
44531
|
+
current = current.cause;
|
|
44532
|
+
}
|
|
44533
|
+
return void 0;
|
|
44475
44534
|
}
|
|
44476
44535
|
|
|
44477
44536
|
// ../core/src/networks.ts
|
|
@@ -47606,12 +47665,12 @@ async function removeStaleLock(path) {
|
|
|
47606
47665
|
const pid = lockOwnerPid(owner);
|
|
47607
47666
|
if (pid !== void 0 && processIsAlive(pid)) return;
|
|
47608
47667
|
await atomicFileTestHooks?.beforeStaleLockBreak?.(path);
|
|
47609
|
-
await removeOwnedLock(path, [owner]);
|
|
47668
|
+
await removeOwnedLock(path, [owner], true);
|
|
47610
47669
|
} catch (error61) {
|
|
47611
47670
|
if (!hasCode(error61, "ENOENT")) throw error61;
|
|
47612
47671
|
}
|
|
47613
47672
|
}
|
|
47614
|
-
async function removeOwnedLock(path, owners) {
|
|
47673
|
+
async function removeOwnedLock(path, owners, staleDeadOwner = false) {
|
|
47615
47674
|
const tombPath = `${path}.stale.${randomBytes2(16).toString("hex")}`;
|
|
47616
47675
|
try {
|
|
47617
47676
|
await rename(path, tombPath);
|
|
@@ -47620,7 +47679,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
47620
47679
|
await removeOwnedTombs(path, owners);
|
|
47621
47680
|
const currentOwner = await readFile(path, "utf8").catch(() => void 0);
|
|
47622
47681
|
if (currentOwner !== void 0 && owners.includes(currentOwner)) {
|
|
47623
|
-
await removeOwnedLock(path, owners);
|
|
47682
|
+
await removeOwnedLock(path, owners, staleDeadOwner);
|
|
47624
47683
|
}
|
|
47625
47684
|
return;
|
|
47626
47685
|
}
|
|
@@ -47629,6 +47688,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
47629
47688
|
let pendingError;
|
|
47630
47689
|
let renamedOwner;
|
|
47631
47690
|
try {
|
|
47691
|
+
await atomicFileTestHooks?.afterLockRename?.(tombPath);
|
|
47632
47692
|
renamedOwner = await readFile(tombPath, "utf8");
|
|
47633
47693
|
if (!owners.includes(renamedOwner) && !lockOwnerReleased(renamedOwner)) {
|
|
47634
47694
|
await atomicFileTestHooks?.afterMismatchedLockRename?.(path);
|
|
@@ -47637,6 +47697,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
47637
47697
|
await atomicFileTestHooks?.afterMismatchedLockRestore?.(path);
|
|
47638
47698
|
}
|
|
47639
47699
|
} catch (error61) {
|
|
47700
|
+
if (hasCode(error61, "ENOENT")) return;
|
|
47640
47701
|
pendingError = error61;
|
|
47641
47702
|
}
|
|
47642
47703
|
try {
|
|
@@ -47645,7 +47706,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
47645
47706
|
} catch (error61) {
|
|
47646
47707
|
if (!tombUnlinkTolerated(
|
|
47647
47708
|
error61,
|
|
47648
|
-
renamedOwner !== void 0 && lockOwnerReleased(renamedOwner) && owners.includes(renamedOwner)
|
|
47709
|
+
renamedOwner !== void 0 && (lockOwnerReleased(renamedOwner) || staleDeadOwner) && owners.includes(renamedOwner)
|
|
47649
47710
|
) && pendingError === void 0) {
|
|
47650
47711
|
pendingError = error61;
|
|
47651
47712
|
}
|
|
@@ -48940,16 +49001,25 @@ function withBearer(init, accessToken) {
|
|
|
48940
49001
|
async function safeFetch(fetchImpl, input2, init) {
|
|
48941
49002
|
try {
|
|
48942
49003
|
return await fetchImpl(input2, init);
|
|
48943
|
-
} catch {
|
|
48944
|
-
throw httpError(
|
|
49004
|
+
} catch (error61) {
|
|
49005
|
+
throw httpError(`The vAPI agent link request failed: ${networkFailure(error61, input2)}`);
|
|
48945
49006
|
}
|
|
48946
49007
|
}
|
|
48947
49008
|
async function safeAgentFetch(fetchImpl, input2, init) {
|
|
48948
49009
|
try {
|
|
48949
49010
|
return await fetchImpl(input2, init);
|
|
49011
|
+
} catch (error61) {
|
|
49012
|
+
throw httpError(`The vAPI agent request failed: ${networkFailure(error61, input2)}`);
|
|
49013
|
+
}
|
|
49014
|
+
}
|
|
49015
|
+
function networkFailure(error61, input2) {
|
|
49016
|
+
let url2;
|
|
49017
|
+
try {
|
|
49018
|
+
url2 = new URL(input2 instanceof Request ? input2.url : input2);
|
|
48950
49019
|
} catch {
|
|
48951
|
-
|
|
49020
|
+
return "the request did not reach vAPI.";
|
|
48952
49021
|
}
|
|
49022
|
+
return describeNetworkFailure(error61, url2);
|
|
48953
49023
|
}
|
|
48954
49024
|
function deviceAuthorizationError(status, payload) {
|
|
48955
49025
|
const error61 = stringField(payload, "error");
|
|
@@ -79164,7 +79234,7 @@ function createRunBudget(args) {
|
|
|
79164
79234
|
import { mkdir as mkdir15, writeFile as writeFile7 } from "node:fs/promises";
|
|
79165
79235
|
import { arch, platform, release } from "node:os";
|
|
79166
79236
|
import { join as join14 } from "node:path";
|
|
79167
|
-
var VAPI_CLIENT_VERSION = "0.15.
|
|
79237
|
+
var VAPI_CLIENT_VERSION = "0.15.2";
|
|
79168
79238
|
async function createSupportReport(options) {
|
|
79169
79239
|
const message = options.message.trim();
|
|
79170
79240
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -103971,7 +104041,7 @@ async function readProcessStdin() {
|
|
|
103971
104041
|
}
|
|
103972
104042
|
|
|
103973
104043
|
// ../cli/src/version.ts
|
|
103974
|
-
var CLI_VERSION = "0.15.
|
|
104044
|
+
var CLI_VERSION = "0.15.2";
|
|
103975
104045
|
|
|
103976
104046
|
// ../cli/src/status.ts
|
|
103977
104047
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -107759,6 +107829,10 @@ ${RUN_USAGE}`
|
|
|
107759
107829
|
${RUN_USAGE}`);
|
|
107760
107830
|
}
|
|
107761
107831
|
const environment = getEnvironment(dependencies);
|
|
107832
|
+
const runIo = resultFile === void 0 ? io : {
|
|
107833
|
+
stdout: (message) => io.stdout(redactDetachedRunText(message, environment)),
|
|
107834
|
+
stderr: (message) => io.stderr(redactDetachedRunText(message, environment))
|
|
107835
|
+
};
|
|
107762
107836
|
const configuredRunId = environmentRunId(environment, "VAPI_RUN_ID");
|
|
107763
107837
|
const parentRunId = environmentRunId(environment, "VAPI_PARENT_RUN_ID");
|
|
107764
107838
|
const paths = getVapiPaths();
|
|
@@ -107770,8 +107844,8 @@ ${RUN_USAGE}`);
|
|
|
107770
107844
|
if (resultFile !== void 0) {
|
|
107771
107845
|
await writeJsonAtomic(resultFile, { v: 1, exitCode: 1, result: result2 }, { mode: 384 });
|
|
107772
107846
|
}
|
|
107773
|
-
if (json2)
|
|
107774
|
-
else
|
|
107847
|
+
if (json2) runIo.stdout(JSON.stringify(result2));
|
|
107848
|
+
else runIo.stderr(message);
|
|
107775
107849
|
return 1;
|
|
107776
107850
|
}
|
|
107777
107851
|
const runId = configuredRunId ?? createRunId();
|
|
@@ -107835,42 +107909,48 @@ ${RUN_USAGE}`);
|
|
|
107835
107909
|
...runMeta === void 0 ? {} : { runMeta },
|
|
107836
107910
|
approvals: "tty",
|
|
107837
107911
|
json: json2,
|
|
107838
|
-
io,
|
|
107912
|
+
io: runIo,
|
|
107839
107913
|
dependencies
|
|
107840
107914
|
});
|
|
107841
107915
|
const execute = dependencies.agent?.runAgent ?? runAgent;
|
|
107842
107916
|
const executed = await execute(task, runDependencies);
|
|
107843
107917
|
const result = resultFile === void 0 ? executed : redactAgentRunResult(executed, environment);
|
|
107844
|
-
if (!json2) printAgentRefills(result, io);
|
|
107918
|
+
if (!json2) printAgentRefills(result, runIo, io);
|
|
107845
107919
|
const exitCode = result.stoppedBecause.reason === "finished" ? 0 : 1;
|
|
107846
107920
|
if (resultFile !== void 0) {
|
|
107847
107921
|
await writeJsonAtomic(resultFile, { v: 1, exitCode, result }, { mode: 384 });
|
|
107848
107922
|
}
|
|
107849
107923
|
if (json2) {
|
|
107850
|
-
io.stdout(
|
|
107924
|
+
io.stdout(
|
|
107925
|
+
JSON.stringify(resultFile === void 0 ? result : redactAgentRunResult(result, environment))
|
|
107926
|
+
);
|
|
107851
107927
|
} else if (result.stoppedBecause.reason === "finished") {
|
|
107852
|
-
|
|
107928
|
+
runIo.stdout(result.answer ?? "");
|
|
107853
107929
|
} else {
|
|
107854
|
-
|
|
107930
|
+
runIo.stderr(result.stoppedBecause.detail ?? result.stoppedBecause.reason);
|
|
107855
107931
|
}
|
|
107856
107932
|
return exitCode;
|
|
107857
107933
|
}
|
|
107934
|
+
var SETTLEMENT_HASH = /^0x[0-9a-fA-F]{64}$/u;
|
|
107858
107935
|
function redactAgentRunResult(executed, environment) {
|
|
107859
107936
|
const result = redactDetachedRunValue(executed, environment);
|
|
107860
107937
|
for (const [index2, refill] of (executed.refills ?? []).entries()) {
|
|
107861
107938
|
const transaction2 = refill.receipt.transaction;
|
|
107862
107939
|
const redacted = result.refills?.[index2];
|
|
107863
|
-
if (redacted !== void 0 && transaction2 !== void 0 &&
|
|
107940
|
+
if (redacted !== void 0 && transaction2 !== void 0 && SETTLEMENT_HASH.test(transaction2)) {
|
|
107864
107941
|
redacted.receipt.transaction = transaction2;
|
|
107865
107942
|
}
|
|
107866
107943
|
}
|
|
107867
107944
|
return result;
|
|
107868
107945
|
}
|
|
107869
|
-
function printAgentRefills(result, io) {
|
|
107946
|
+
function printAgentRefills(result, io, settlementHashIo = io) {
|
|
107870
107947
|
for (const refill of result.refills ?? []) {
|
|
107871
107948
|
io.stderr(`Receipt: ${refill.receipt.id}`);
|
|
107872
|
-
|
|
107873
|
-
|
|
107949
|
+
const transaction2 = refill.receipt.transaction;
|
|
107950
|
+
if (transaction2 !== void 0) {
|
|
107951
|
+
const output4 = SETTLEMENT_HASH.test(transaction2) ? settlementHashIo : io;
|
|
107952
|
+
output4.stderr(`Transaction: ${transaction2}`);
|
|
107953
|
+
}
|
|
107874
107954
|
for (const warning of refill.warnings ?? []) io.stderr(warning.message);
|
|
107875
107955
|
}
|
|
107876
107956
|
}
|
|
@@ -112471,12 +112551,7 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
112471
112551
|
exitCode = 0;
|
|
112472
112552
|
break;
|
|
112473
112553
|
case "agent":
|
|
112474
|
-
exitCode = await agentCommand(
|
|
112475
|
-
args.slice(1),
|
|
112476
|
-
json2,
|
|
112477
|
-
args[1] === "run" && args.includes("--bundle-env") ? io : runIo,
|
|
112478
|
-
dependencies
|
|
112479
|
-
);
|
|
112554
|
+
exitCode = await agentCommand(args.slice(1), json2, io, dependencies);
|
|
112480
112555
|
break;
|
|
112481
112556
|
case "dashboard":
|
|
112482
112557
|
await dashboardCommand(args.slice(1), json2, io, dependencies);
|