@vapi-network/core 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/dist/agent-link.js +73 -7
- package/dist/agent-link.js.map +1 -1
- package/dist/atomic-file.d.ts +1 -0
- package/dist/atomic-file.d.ts.map +1 -1
- package/dist/backup.js +6 -4
- package/dist/backup.js.map +1 -1
- package/dist/cloud-backup.js +79 -11
- package/dist/cloud-backup.js.map +2 -2
- package/dist/index.js +82 -12
- package/dist/index.js.map +2 -2
- package/dist/net-guard.d.ts +17 -0
- package/dist/net-guard.d.ts.map +1 -1
- package/dist/router-client.js +80 -12
- package/dist/router-client.js.map +2 -2
- package/dist/secrets.js +19 -8
- package/dist/secrets.js.map +1 -1
- package/dist/support-report.d.ts +1 -1
- package/dist/tasks.js +77 -9
- package/dist/tasks.js.map +2 -2
- package/package.json +1 -1
package/dist/net-guard.d.ts
CHANGED
|
@@ -10,4 +10,21 @@ export declare function createPublicFetch(options: {
|
|
|
10
10
|
lookup?: LookupFn;
|
|
11
11
|
}): typeof fetch;
|
|
12
12
|
export declare function pinnedLookup(lookup: LookupFn): LookupFunction;
|
|
13
|
+
/**
|
|
14
|
+
* A request the guard refused before connecting. `reason` is `unresolved` when
|
|
15
|
+
* the hostname's DNS lookup failed or timed out, and `blocked` otherwise.
|
|
16
|
+
*/
|
|
17
|
+
export declare class NetworkGuardError extends Error {
|
|
18
|
+
readonly reason: "blocked" | "unresolved";
|
|
19
|
+
constructor(message: string, reason: "blocked" | "unresolved");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Says why a request to `url` never got an answer, in words that are safe to
|
|
23
|
+
* print: the host, and a Node system error code such as `ECONNREFUSED`, never
|
|
24
|
+
* the error's own message. When the proxy variable for the URL's protocol is
|
|
25
|
+
* set it adds how Node.js treats it: the proxy is used only with
|
|
26
|
+
* `NODE_USE_ENV_PROXY=1`, and the host must still resolve on this machine
|
|
27
|
+
* because the guard looks it up first.
|
|
28
|
+
*/
|
|
29
|
+
export declare function describeNetworkFailure(error: unknown, url: URL, env?: NodeJS.ProcessEnv): string;
|
|
13
30
|
//# sourceMappingURL=net-guard.d.ts.map
|
package/dist/net-guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"net-guard.d.ts","sourceRoot":"","sources":["../src/net-guard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAO/D,wBAAsB,eAAe,CACnC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE;IAAE,mBAAmB,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/E,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,GAAG,OAAO,KAAK,CAmDf;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,cAAc,CAoB7D"}
|
|
1
|
+
{"version":3,"file":"net-guard.d.ts","sourceRoot":"","sources":["../src/net-guard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAO/D,wBAAsB,eAAe,CACnC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE;IAAE,mBAAmB,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/E,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,GAAG,OAAO,KAAK,CAmDf;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,cAAc,CAoB7D;AAyHD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAGxC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,YAAY;gBADzC,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,SAAS,GAAG,YAAY;CAK5C;AAgBD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,GAAG,EACR,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CA6BR"}
|
package/dist/router-client.js
CHANGED
|
@@ -36714,12 +36714,12 @@ async function removeStaleLock(path) {
|
|
|
36714
36714
|
const pid = lockOwnerPid(owner);
|
|
36715
36715
|
if (pid !== void 0 && processIsAlive(pid)) return;
|
|
36716
36716
|
await atomicFileTestHooks?.beforeStaleLockBreak?.(path);
|
|
36717
|
-
await removeOwnedLock(path, [owner]);
|
|
36717
|
+
await removeOwnedLock(path, [owner], true);
|
|
36718
36718
|
} catch (error61) {
|
|
36719
36719
|
if (!hasCode(error61, "ENOENT")) throw error61;
|
|
36720
36720
|
}
|
|
36721
36721
|
}
|
|
36722
|
-
async function removeOwnedLock(path, owners) {
|
|
36722
|
+
async function removeOwnedLock(path, owners, staleDeadOwner = false) {
|
|
36723
36723
|
const tombPath = `${path}.stale.${randomBytes2(16).toString("hex")}`;
|
|
36724
36724
|
try {
|
|
36725
36725
|
await rename(path, tombPath);
|
|
@@ -36728,7 +36728,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
36728
36728
|
await removeOwnedTombs(path, owners);
|
|
36729
36729
|
const currentOwner = await readFile(path, "utf8").catch(() => void 0);
|
|
36730
36730
|
if (currentOwner !== void 0 && owners.includes(currentOwner)) {
|
|
36731
|
-
await removeOwnedLock(path, owners);
|
|
36731
|
+
await removeOwnedLock(path, owners, staleDeadOwner);
|
|
36732
36732
|
}
|
|
36733
36733
|
return;
|
|
36734
36734
|
}
|
|
@@ -36737,6 +36737,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
36737
36737
|
let pendingError;
|
|
36738
36738
|
let renamedOwner;
|
|
36739
36739
|
try {
|
|
36740
|
+
await atomicFileTestHooks?.afterLockRename?.(tombPath);
|
|
36740
36741
|
renamedOwner = await readFile(tombPath, "utf8");
|
|
36741
36742
|
if (!owners.includes(renamedOwner) && !lockOwnerReleased(renamedOwner)) {
|
|
36742
36743
|
await atomicFileTestHooks?.afterMismatchedLockRename?.(path);
|
|
@@ -36745,6 +36746,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
36745
36746
|
await atomicFileTestHooks?.afterMismatchedLockRestore?.(path);
|
|
36746
36747
|
}
|
|
36747
36748
|
} catch (error61) {
|
|
36749
|
+
if (hasCode(error61, "ENOENT")) return;
|
|
36748
36750
|
pendingError = error61;
|
|
36749
36751
|
}
|
|
36750
36752
|
try {
|
|
@@ -36753,7 +36755,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
36753
36755
|
} catch (error61) {
|
|
36754
36756
|
if (!tombUnlinkTolerated(
|
|
36755
36757
|
error61,
|
|
36756
|
-
renamedOwner !== void 0 && lockOwnerReleased(renamedOwner) && owners.includes(renamedOwner)
|
|
36758
|
+
renamedOwner !== void 0 && (lockOwnerReleased(renamedOwner) || staleDeadOwner) && owners.includes(renamedOwner)
|
|
36757
36759
|
) && pendingError === void 0) {
|
|
36758
36760
|
pendingError = error61;
|
|
36759
36761
|
}
|
|
@@ -36950,7 +36952,7 @@ async function assertPublicUrl(url2, options) {
|
|
|
36950
36952
|
options.timeoutMs ?? 5e3
|
|
36951
36953
|
);
|
|
36952
36954
|
} catch {
|
|
36953
|
-
throw guardError(url2);
|
|
36955
|
+
throw guardError(url2, "unresolved");
|
|
36954
36956
|
}
|
|
36955
36957
|
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
36956
36958
|
throw guardError(url2);
|
|
@@ -37105,10 +37107,67 @@ function isNonPublicIpv6(hextets) {
|
|
|
37105
37107
|
const isDocumentation = first === 8193 && hextets[1] === 3512;
|
|
37106
37108
|
return isUnspecified || isLoopback || isUniqueLocal || isLinkLocal || isSiteLocal || isMulticast || isDocumentation;
|
|
37107
37109
|
}
|
|
37108
|
-
|
|
37109
|
-
|
|
37110
|
-
|
|
37110
|
+
var NetworkGuardError = class extends Error {
|
|
37111
|
+
constructor(message, reason) {
|
|
37112
|
+
super(message);
|
|
37113
|
+
this.reason = reason;
|
|
37114
|
+
this.name = "NetworkGuardError";
|
|
37115
|
+
}
|
|
37116
|
+
reason;
|
|
37117
|
+
};
|
|
37118
|
+
function guardError(url2, reason = "blocked") {
|
|
37119
|
+
return new NetworkGuardError(
|
|
37120
|
+
`URL hostname ${JSON.stringify(url2.hostname)} is not allowed; private or internal destinations require allowPrivateNetwork true in the vAPI config.`,
|
|
37121
|
+
reason
|
|
37122
|
+
);
|
|
37123
|
+
}
|
|
37124
|
+
var PROXY_VARIABLES = {
|
|
37125
|
+
"https:": ["HTTPS_PROXY", "https_proxy"],
|
|
37126
|
+
"http:": ["HTTP_PROXY", "http_proxy"]
|
|
37127
|
+
};
|
|
37128
|
+
var SYSTEM_ERROR_CODE = /^[A-Z][A-Z0-9_]{1,39}$/u;
|
|
37129
|
+
function describeNetworkFailure(error61, url2, env = process.env) {
|
|
37130
|
+
const host = url2.host;
|
|
37131
|
+
let reason;
|
|
37132
|
+
const guard = guardReason(error61);
|
|
37133
|
+
if (guard !== void 0) {
|
|
37134
|
+
reason = guard === "unresolved" ? `the DNS lookup for ${host} failed` : `${host} is not a public address`;
|
|
37135
|
+
} else if (isTimeout(error61)) {
|
|
37136
|
+
reason = `the connection to ${host} timed out`;
|
|
37137
|
+
} else {
|
|
37138
|
+
const code = systemErrorCode(error61);
|
|
37139
|
+
reason = `could not connect to ${host}${code === void 0 ? "" : ` (${code})`}`;
|
|
37140
|
+
}
|
|
37141
|
+
const proxy = (PROXY_VARIABLES[url2.protocol] ?? []).find(
|
|
37142
|
+
(name) => (env[name] ?? "").trim() !== ""
|
|
37111
37143
|
);
|
|
37144
|
+
let hint = "";
|
|
37145
|
+
if (proxy !== void 0) {
|
|
37146
|
+
if (env.NODE_USE_ENV_PROXY !== "1") {
|
|
37147
|
+
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.`;
|
|
37148
|
+
} else if (guard === "unresolved") {
|
|
37149
|
+
hint = ` vapi looks ${host} up on this machine before it uses the proxy in ${proxy}, so the name must resolve here too.`;
|
|
37150
|
+
} else if (guard === void 0) {
|
|
37151
|
+
hint = ` NODE_USE_ENV_PROXY=1 and ${proxy} are set, so the proxy may have refused the connection.`;
|
|
37152
|
+
}
|
|
37153
|
+
}
|
|
37154
|
+
return `${reason}.${hint}`;
|
|
37155
|
+
}
|
|
37156
|
+
function guardReason(error61) {
|
|
37157
|
+
if (!(error61 instanceof Error) || error61.name !== "NetworkGuardError") return void 0;
|
|
37158
|
+
const reason = error61.reason;
|
|
37159
|
+
return reason === "blocked" || reason === "unresolved" ? reason : void 0;
|
|
37160
|
+
}
|
|
37161
|
+
function isTimeout(error61) {
|
|
37162
|
+
return error61 instanceof Error && (error61.name === "TimeoutError" || error61.name === "AbortError");
|
|
37163
|
+
}
|
|
37164
|
+
function systemErrorCode(error61) {
|
|
37165
|
+
for (let current = error61, depth = 0; current instanceof Error && depth < 3; depth += 1) {
|
|
37166
|
+
const code = current.code;
|
|
37167
|
+
if (typeof code === "string" && SYSTEM_ERROR_CODE.test(code)) return code;
|
|
37168
|
+
current = current.cause;
|
|
37169
|
+
}
|
|
37170
|
+
return void 0;
|
|
37112
37171
|
}
|
|
37113
37172
|
|
|
37114
37173
|
// src/networks.ts
|
|
@@ -37923,16 +37982,25 @@ function withBearer(init, accessToken) {
|
|
|
37923
37982
|
async function safeFetch(fetchImpl, input2, init) {
|
|
37924
37983
|
try {
|
|
37925
37984
|
return await fetchImpl(input2, init);
|
|
37926
|
-
} catch {
|
|
37927
|
-
throw httpError(
|
|
37985
|
+
} catch (error61) {
|
|
37986
|
+
throw httpError(`The vAPI agent link request failed: ${networkFailure(error61, input2)}`);
|
|
37928
37987
|
}
|
|
37929
37988
|
}
|
|
37930
37989
|
async function safeAgentFetch(fetchImpl, input2, init) {
|
|
37931
37990
|
try {
|
|
37932
37991
|
return await fetchImpl(input2, init);
|
|
37992
|
+
} catch (error61) {
|
|
37993
|
+
throw httpError(`The vAPI agent request failed: ${networkFailure(error61, input2)}`);
|
|
37994
|
+
}
|
|
37995
|
+
}
|
|
37996
|
+
function networkFailure(error61, input2) {
|
|
37997
|
+
let url2;
|
|
37998
|
+
try {
|
|
37999
|
+
url2 = new URL(input2 instanceof Request ? input2.url : input2);
|
|
37933
38000
|
} catch {
|
|
37934
|
-
|
|
38001
|
+
return "the request did not reach vAPI.";
|
|
37935
38002
|
}
|
|
38003
|
+
return describeNetworkFailure(error61, url2);
|
|
37936
38004
|
}
|
|
37937
38005
|
function notLinkedError() {
|
|
37938
38006
|
return new AgentLinkError("not_linked", "Run vapi login first.");
|
|
@@ -46796,7 +46864,7 @@ var RunBudgetError = class extends Error {
|
|
|
46796
46864
|
};
|
|
46797
46865
|
|
|
46798
46866
|
// src/support-report.ts
|
|
46799
|
-
var VAPI_CLIENT_VERSION = "0.15.
|
|
46867
|
+
var VAPI_CLIENT_VERSION = "0.15.2";
|
|
46800
46868
|
|
|
46801
46869
|
// src/x402-pay.ts
|
|
46802
46870
|
var X402PaymentError = class extends Error {
|