@bman654/clodex 2.13.0 → 2.13.1
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/cli.js +15 -8
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -382,7 +382,7 @@ import { join } from "path";
|
|
|
382
382
|
// package.json
|
|
383
383
|
var package_default = {
|
|
384
384
|
name: "@bman654/clodex",
|
|
385
|
-
version: "2.13.
|
|
385
|
+
version: "2.13.1",
|
|
386
386
|
publishConfig: {
|
|
387
387
|
access: "public"
|
|
388
388
|
},
|
|
@@ -8183,17 +8183,17 @@ function proxyUrlTargetsListener(proxyUrl, listenerHost, listenerPort, localAddr
|
|
|
8183
8183
|
return isWildcard(boundHost) && (isWildcard(proxyHost) || localAddresses.has(proxyHost));
|
|
8184
8184
|
}
|
|
8185
8185
|
var dispatcherInstalled = false;
|
|
8186
|
-
async function
|
|
8186
|
+
async function installOutboundDispatcher() {
|
|
8187
8187
|
if (dispatcherInstalled) return true;
|
|
8188
|
-
if (!hasOutboundProxyEnv()) return false;
|
|
8189
8188
|
try {
|
|
8190
|
-
const { EnvHttpProxyAgent, setGlobalDispatcher } = await import("undici");
|
|
8191
|
-
|
|
8189
|
+
const { Agent: Agent3, EnvHttpProxyAgent, setGlobalDispatcher } = await import("undici");
|
|
8190
|
+
const dispatcher = hasOutboundProxyEnv() ? new EnvHttpProxyAgent({ allowH2: false }) : new Agent3({ allowH2: false });
|
|
8191
|
+
setGlobalDispatcher(dispatcher);
|
|
8192
8192
|
dispatcherInstalled = true;
|
|
8193
8193
|
return true;
|
|
8194
8194
|
} catch (err) {
|
|
8195
8195
|
console.error(
|
|
8196
|
-
`clodex:
|
|
8196
|
+
`clodex: installing the outbound fetch dispatcher failed; continuing with Node's existing dispatcher (${err instanceof Error ? err.message : String(err)})`
|
|
8197
8197
|
);
|
|
8198
8198
|
return false;
|
|
8199
8199
|
}
|
|
@@ -11904,7 +11904,13 @@ function anthropicUpstreamHeaders(apiKey, stream = false, inboundBeta, authType,
|
|
|
11904
11904
|
}
|
|
11905
11905
|
var UpstreamUnreachableError = class extends Error {
|
|
11906
11906
|
constructor(cause) {
|
|
11907
|
-
|
|
11907
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
11908
|
+
const directCode = cause !== null && typeof cause === "object" ? cause.code : void 0;
|
|
11909
|
+
const nestedCause = cause instanceof Error ? cause.cause : void 0;
|
|
11910
|
+
const nestedCode = nestedCause !== null && typeof nestedCause === "object" ? nestedCause.code : void 0;
|
|
11911
|
+
const code = typeof directCode === "string" ? directCode : typeof nestedCode === "string" ? nestedCode : void 0;
|
|
11912
|
+
const detailWithCode = code && !detail.includes(code) ? detail ? `${detail} (${code})` : code : detail;
|
|
11913
|
+
super(`Upstream unreachable: ${detailWithCode}`, { cause });
|
|
11908
11914
|
this.name = "UpstreamUnreachableError";
|
|
11909
11915
|
}
|
|
11910
11916
|
};
|
|
@@ -20371,6 +20377,7 @@ async function startHttpProxy(options) {
|
|
|
20371
20377
|
mitmServer.emit("connection", clientSocket);
|
|
20372
20378
|
return;
|
|
20373
20379
|
}
|
|
20380
|
+
clientSocket.once("error", () => clientSocket.destroy());
|
|
20374
20381
|
const target = authorityParts(req.url ?? "");
|
|
20375
20382
|
if (!target) {
|
|
20376
20383
|
clientSocket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
|
|
@@ -22606,7 +22613,7 @@ Error: ${launchPlan.error}
|
|
|
22606
22613
|
return exitCode;
|
|
22607
22614
|
}
|
|
22608
22615
|
async function main(args = process.argv.slice(2)) {
|
|
22609
|
-
await
|
|
22616
|
+
await installOutboundDispatcher();
|
|
22610
22617
|
const parsed = parseArgs(args);
|
|
22611
22618
|
if (parsed.error) {
|
|
22612
22619
|
console.error(pc13.red(`
|