claude-use 14.0.2 → 14.0.3
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.cjs +94 -31
- package/dist/index.cjs +94 -31
- package/dist/index.mjs +94 -31
- package/dist/types/index.d.ts +917 -891
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -32306,6 +32306,9 @@ function reportableAllowlistFileProblem(allowlistFile, ports, served) {
|
|
|
32306
32306
|
return problem?.repairable === false || served ? problem : void 0;
|
|
32307
32307
|
}
|
|
32308
32308
|
function verifyAllowlistFile(allowlistFile, ports) {
|
|
32309
|
+
if (platformRefusal(ports.platform) !== void 0) {
|
|
32310
|
+
return void 0;
|
|
32311
|
+
}
|
|
32309
32312
|
const uid = ports.currentUid();
|
|
32310
32313
|
const directories = pathDirectories(allowlistFile, ports);
|
|
32311
32314
|
if (typeof directories === "string") {
|
|
@@ -33595,7 +33598,10 @@ var init_realPorts = __esm({
|
|
|
33595
33598
|
};
|
|
33596
33599
|
SOCKET_PERMISSION_BITS = 4095;
|
|
33597
33600
|
realHeadroomSocketTrust = {
|
|
33598
|
-
platform
|
|
33601
|
+
// Read at each use, not fixed when the module loads, so what the checks do for a platform is testable through the real wiring.
|
|
33602
|
+
get platform() {
|
|
33603
|
+
return process.platform;
|
|
33604
|
+
},
|
|
33599
33605
|
currentUid: () => {
|
|
33600
33606
|
if (process.getuid === void 0) {
|
|
33601
33607
|
throw new Error(`no POSIX user id on ${process.platform}`);
|
|
@@ -45026,6 +45032,20 @@ function createDoorLookup(io) {
|
|
|
45026
45032
|
});
|
|
45027
45033
|
};
|
|
45028
45034
|
}
|
|
45035
|
+
function sourcePortClassifier(platform) {
|
|
45036
|
+
const classify = (error63) => {
|
|
45037
|
+
const attempts = Reflect.get(error63, "errors");
|
|
45038
|
+
if (Array.isArray(attempts) && attempts.length > 0) {
|
|
45039
|
+
const kinds = attempts.map((attempt) => attempt instanceof Error ? classify(attempt) : void 0);
|
|
45040
|
+
return kinds.includes("excluded") ? "excluded" : kinds.includes("held") ? "held" : void 0;
|
|
45041
|
+
}
|
|
45042
|
+
if (error63.code === "EADDRINUSE" || error63.code === "EADDRNOTAVAIL") {
|
|
45043
|
+
return "held";
|
|
45044
|
+
}
|
|
45045
|
+
return platform === "win32" && error63.code === "EACCES" && error63.syscall === "bind" ? "excluded" : void 0;
|
|
45046
|
+
};
|
|
45047
|
+
return classify;
|
|
45048
|
+
}
|
|
45029
45049
|
function doorDial(io, target, ports) {
|
|
45030
45050
|
const dialOnce = (options) => new Promise((resolve3) => {
|
|
45031
45051
|
const socket = io.connect(options);
|
|
@@ -45038,12 +45058,15 @@ function doorDial(io, target, ports) {
|
|
|
45038
45058
|
if (error63.message === "" && Array.isArray(attempts) && attempts.length > 0) {
|
|
45039
45059
|
const flattened = new Error(attempts.map((attempt) => withoutLocalEnd(attempt instanceof Error ? attempt.message : String(attempt))).join("; "));
|
|
45040
45060
|
flattened.code = error63.code;
|
|
45061
|
+
flattened.syscall = error63.syscall;
|
|
45062
|
+
Object.defineProperty(flattened, "errors", { value: attempts });
|
|
45041
45063
|
resolve3({ error: flattened, socket });
|
|
45042
45064
|
return;
|
|
45043
45065
|
}
|
|
45044
45066
|
if (withoutLocalEnd(error63.message) !== error63.message) {
|
|
45045
45067
|
const trimmed = new Error(withoutLocalEnd(error63.message));
|
|
45046
45068
|
trimmed.code = error63.code;
|
|
45069
|
+
trimmed.syscall = error63.syscall;
|
|
45047
45070
|
resolve3({ error: trimmed, socket });
|
|
45048
45071
|
return;
|
|
45049
45072
|
}
|
|
@@ -45053,17 +45076,35 @@ function doorDial(io, target, ports) {
|
|
|
45053
45076
|
if (io.isIP(target.host) !== 0) {
|
|
45054
45077
|
return dialOnce({ host: target.host, port: target.port });
|
|
45055
45078
|
}
|
|
45056
|
-
const attemptFrom = (attempt
|
|
45057
|
-
|
|
45058
|
-
|
|
45059
|
-
|
|
45060
|
-
|
|
45061
|
-
|
|
45062
|
-
|
|
45063
|
-
|
|
45064
|
-
|
|
45065
|
-
|
|
45066
|
-
|
|
45079
|
+
const attemptFrom = (attempt, refused2) => {
|
|
45080
|
+
const port = ports.take();
|
|
45081
|
+
return dialOnce({ host: target.host, port: target.port, localPort: port, lookup: io.lookup }).then((outcome) => {
|
|
45082
|
+
if (outcome.error === null) {
|
|
45083
|
+
return outcome;
|
|
45084
|
+
}
|
|
45085
|
+
const failure2 = io.sourcePortFailure(outcome.error);
|
|
45086
|
+
if (failure2 === void 0) {
|
|
45087
|
+
return outcome;
|
|
45088
|
+
}
|
|
45089
|
+
if (failure2 === "excluded") {
|
|
45090
|
+
ports.exclude(port);
|
|
45091
|
+
}
|
|
45092
|
+
const refusedSoFar = failure2 === "excluded" ? refused2 + 1 : refused2;
|
|
45093
|
+
if (attempt < ports.count - 1) {
|
|
45094
|
+
return attemptFrom(attempt + 1, refusedSoFar);
|
|
45095
|
+
}
|
|
45096
|
+
if (refusedSoFar === 0) {
|
|
45097
|
+
return outcome;
|
|
45098
|
+
}
|
|
45099
|
+
const scope = refusedSoFar === ports.count ? "every source port" : `${String(refusedSoFar)} of its ${String(ports.count)} source ports (the rest were held by other sockets)`;
|
|
45100
|
+
const refusal2 = new Error(
|
|
45101
|
+
`${scope} of the door's reserved range (${String(ports.start)} to ${String(ports.end)}) could not be bound: Windows refuses a port inside an excluded range with EACCES (Hyper-V, WSL2 and Docker Desktop reserve blocks of ports). List the excluded ranges with \`netsh int ipv4 show excludedportrange protocol=tcp\``
|
|
45102
|
+
);
|
|
45103
|
+
refusal2.code = refusedSoFar === ports.count ? "EACCES" : outcome.error.code;
|
|
45104
|
+
return { error: refusal2, socket: outcome.socket };
|
|
45105
|
+
});
|
|
45106
|
+
};
|
|
45107
|
+
return attemptFrom(0, 0);
|
|
45067
45108
|
}
|
|
45068
45109
|
function probeAccept(dial, timeoutMs, startTimer) {
|
|
45069
45110
|
return new Promise((resolve3) => {
|
|
@@ -45098,7 +45139,7 @@ function runAcceptProbe(deps, data, startTimer) {
|
|
|
45098
45139
|
const lookup2 = deps.createDoorLookup({ isIP: deps.net.isIP, resolve4: (name, callback) => {
|
|
45099
45140
|
deps.dns.resolve4(name, callback);
|
|
45100
45141
|
} });
|
|
45101
|
-
const io = { connect: (options) => deps.net.connect(options), lookup: lookup2, isIP: deps.net.isIP };
|
|
45142
|
+
const io = { connect: (options) => deps.net.connect(options), lookup: lookup2, isIP: deps.net.isIP, sourcePortFailure: deps.sourcePortClassifier(data.platform) };
|
|
45102
45143
|
return deps.probeAccept(() => deps.doorDial(io, { host: data.host, port: data.port }, new deps.SourcePortRange(data.portStart, data.portEnd, data.portFirst)), data.timeoutMs, startTimer);
|
|
45103
45144
|
}
|
|
45104
45145
|
var init_doorDial = __esm({
|
|
@@ -45111,14 +45152,17 @@ var init_doorDial = __esm({
|
|
|
45111
45152
|
function isSuccessful2(status) {
|
|
45112
45153
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE2;
|
|
45113
45154
|
}
|
|
45155
|
+
function realDoorDialIo(platform = process.platform, connect3 = (options) => net3.connect(options)) {
|
|
45156
|
+
return { connect: connect3, lookup: realAddressLookup, isIP: net3.isIP, sourcePortFailure: sourcePortClassifier(platform) };
|
|
45157
|
+
}
|
|
45114
45158
|
function dialTarget(options, defaultPort) {
|
|
45115
45159
|
return { host: typeof options.host === "string" ? options.host : "", port: typeof options.port === "number" ? options.port : defaultPort };
|
|
45116
45160
|
}
|
|
45117
45161
|
function literalDial(target) {
|
|
45118
45162
|
return net3.connect({ host: target.host, port: target.port });
|
|
45119
45163
|
}
|
|
45120
|
-
async function reservedDial(target, ports) {
|
|
45121
|
-
return await doorDial(
|
|
45164
|
+
async function reservedDial(target, ports, io) {
|
|
45165
|
+
return await doorDial(io, target, ports);
|
|
45122
45166
|
}
|
|
45123
45167
|
function requestServername(options, fallback) {
|
|
45124
45168
|
return "servername" in options && typeof options.servername === "string" && options.servername !== "" ? options.servername : fallback;
|
|
@@ -45258,9 +45302,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
45258
45302
|
}
|
|
45259
45303
|
};
|
|
45260
45304
|
}
|
|
45261
|
-
function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
45262
|
-
const plainAgent = new ExemptHttpAgent(ports);
|
|
45263
|
-
const tlsAgent = new ExemptTlsAgent(ports);
|
|
45305
|
+
function realConnectEffects(ports = DOOR_SOURCE_PORTS, io = realDoorDialIo()) {
|
|
45306
|
+
const plainAgent = new ExemptHttpAgent(ports, io);
|
|
45307
|
+
const tlsAgent = new ExemptTlsAgent(ports, io);
|
|
45264
45308
|
const listenOnce = async (target, onSocket) => await new Promise((resolve3, reject) => {
|
|
45265
45309
|
const accepted = /* @__PURE__ */ new Set();
|
|
45266
45310
|
const server = net3.createServer((socket) => {
|
|
@@ -45392,7 +45436,7 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
45392
45436
|
};
|
|
45393
45437
|
},
|
|
45394
45438
|
connectTlsUpstream: async (host, port, clientAlpn) => {
|
|
45395
|
-
const dialled = await reservedDial({ host, port }, ports);
|
|
45439
|
+
const dialled = await reservedDial({ host, port }, ports, io);
|
|
45396
45440
|
if (dialled.error !== null) {
|
|
45397
45441
|
throw dialled.error;
|
|
45398
45442
|
}
|
|
@@ -45473,7 +45517,7 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
45473
45517
|
}
|
|
45474
45518
|
};
|
|
45475
45519
|
}
|
|
45476
|
-
var import_node_dns, http2, https3, net3, tls, SUCCESS_STATUS_MAX_EXCLUSIVE2, SourcePortRange, DOOR_SOURCE_PORT_START, DOOR_SOURCE_PORT_COUNT, DOOR_SOURCE_PORT_END, DOOR_SOURCE_PORTS, POOLED_SOCKET_IDLE_MS, POOLED_SOCKETS_KEPT_IDLE, POOLING, realAddressLookup,
|
|
45520
|
+
var import_node_dns, http2, https3, net3, tls, SUCCESS_STATUS_MAX_EXCLUSIVE2, SourcePortRange, DOOR_SOURCE_PORT_START, DOOR_SOURCE_PORT_COUNT, DOOR_SOURCE_PORT_END, DOOR_SOURCE_PORTS, POOLED_SOCKET_IDLE_MS, POOLED_SOCKETS_KEPT_IDLE, POOLING, realAddressLookup, HTTP_PORT, ExemptHttpAgent, ExemptTlsAgent, NO_CHUNKS;
|
|
45477
45521
|
var init_connectEffects = __esm({
|
|
45478
45522
|
"src/frontdoor/connectEffects.ts"() {
|
|
45479
45523
|
"use strict";
|
|
@@ -45495,13 +45539,28 @@ var init_connectEffects = __esm({
|
|
|
45495
45539
|
this.end = end;
|
|
45496
45540
|
this.count = end - start + 1;
|
|
45497
45541
|
this.next = first;
|
|
45542
|
+
this.excluded = /* @__PURE__ */ new Set();
|
|
45498
45543
|
}
|
|
45499
|
-
/**
|
|
45544
|
+
/**
|
|
45545
|
+
* The next port in rotation, wrapping from the end back to the start, skipping every port the system has refused to bind (`exclude`) so a dial does not walk a refused block again. A cycle that finds nothing else forgets the refusals and starts over: the exclusions of a host can change while the door runs, and a range refused throughout is then tried again, one pass, not skipped for ever. The memory is a set of ports of the range, so it holds at most `count` entries.
|
|
45546
|
+
*/
|
|
45500
45547
|
take() {
|
|
45548
|
+
for (let skipped = 0; skipped < this.count; skipped += 1) {
|
|
45549
|
+
const port2 = this.next;
|
|
45550
|
+
this.next = this.next === this.end ? this.start : this.next + 1;
|
|
45551
|
+
if (!this.excluded.has(port2)) {
|
|
45552
|
+
return port2;
|
|
45553
|
+
}
|
|
45554
|
+
}
|
|
45555
|
+
this.excluded.clear();
|
|
45501
45556
|
const port = this.next;
|
|
45502
45557
|
this.next = this.next === this.end ? this.start : this.next + 1;
|
|
45503
45558
|
return port;
|
|
45504
45559
|
}
|
|
45560
|
+
/** Remembers that the system refuses to bind `port`, so `take` skips it. Only an exclusion belongs here: a port a sibling holds is free again when the sibling closes. */
|
|
45561
|
+
exclude(port) {
|
|
45562
|
+
this.excluded.add(port);
|
|
45563
|
+
}
|
|
45505
45564
|
};
|
|
45506
45565
|
DOOR_SOURCE_PORT_START = 47900;
|
|
45507
45566
|
DOOR_SOURCE_PORT_COUNT = 1e3;
|
|
@@ -45513,39 +45572,42 @@ var init_connectEffects = __esm({
|
|
|
45513
45572
|
realAddressLookup = createDoorLookup({ isIP: net3.isIP, resolve4: (host, callback) => {
|
|
45514
45573
|
import_node_dns.default.resolve4(host, callback);
|
|
45515
45574
|
} });
|
|
45516
|
-
realDialIo = { connect: (options) => net3.connect(options), lookup: realAddressLookup, isIP: net3.isIP };
|
|
45517
45575
|
HTTP_PORT = 80;
|
|
45518
45576
|
ExemptHttpAgent = class extends http2.Agent {
|
|
45519
|
-
constructor(ports = DOOR_SOURCE_PORTS) {
|
|
45577
|
+
constructor(ports = DOOR_SOURCE_PORTS, io = realDoorDialIo()) {
|
|
45520
45578
|
super(POOLING);
|
|
45521
45579
|
this.ports = ports;
|
|
45580
|
+
this.io = io;
|
|
45522
45581
|
}
|
|
45523
45582
|
ports;
|
|
45583
|
+
io;
|
|
45524
45584
|
// A reserved-port dial that has to retry cannot produce its socket synchronously, so it settles first and arrives through the callback (node's documented asynchronous createConnection form); a literal dial has nothing to retry and keeps node's own synchronous shape.
|
|
45525
45585
|
createConnection(options, oncreate) {
|
|
45526
45586
|
const target = dialTarget(options, HTTP_PORT);
|
|
45527
45587
|
if (net3.isIP(target.host) !== 0) {
|
|
45528
45588
|
return literalDial(target);
|
|
45529
45589
|
}
|
|
45530
|
-
void reservedDial(target, this.ports).then((outcome) => {
|
|
45590
|
+
void reservedDial(target, this.ports, this.io).then((outcome) => {
|
|
45531
45591
|
oncreate?.(outcome.error, outcome.socket);
|
|
45532
45592
|
});
|
|
45533
45593
|
return void 0;
|
|
45534
45594
|
}
|
|
45535
45595
|
};
|
|
45536
45596
|
ExemptTlsAgent = class extends https3.Agent {
|
|
45537
|
-
constructor(ports = DOOR_SOURCE_PORTS) {
|
|
45597
|
+
constructor(ports = DOOR_SOURCE_PORTS, io = realDoorDialIo()) {
|
|
45538
45598
|
super(POOLING);
|
|
45539
45599
|
this.ports = ports;
|
|
45600
|
+
this.io = io;
|
|
45540
45601
|
}
|
|
45541
45602
|
ports;
|
|
45603
|
+
io;
|
|
45542
45604
|
// The same split as the plain sibling: a literal dial wraps TLS around the socket node's own agent would have returned, a reserved dial settles (retries included) first and arrives through the callback, which is exactly where node's own agent wraps its own dials.
|
|
45543
45605
|
createConnection(options, oncreate) {
|
|
45544
45606
|
const target = dialTarget(options, HTTPS_PORT);
|
|
45545
45607
|
if (net3.isIP(target.host) !== 0) {
|
|
45546
45608
|
return tls.connect({ socket: literalDial(target), servername: requestServername(options, target.host), ...tlsFacts(options) });
|
|
45547
45609
|
}
|
|
45548
|
-
void reservedDial(target, this.ports).then((outcome) => {
|
|
45610
|
+
void reservedDial(target, this.ports, this.io).then((outcome) => {
|
|
45549
45611
|
if (outcome.error !== null) {
|
|
45550
45612
|
oncreate?.(outcome.error, outcome.socket);
|
|
45551
45613
|
return;
|
|
@@ -45579,7 +45641,7 @@ function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS, workers =
|
|
|
45579
45641
|
}
|
|
45580
45642
|
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
45581
45643
|
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
45582
|
-
return workers.start(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END }, timeoutMs).verdict();
|
|
45644
|
+
return workers.start(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, platform: process.platform }, timeoutMs).verdict();
|
|
45583
45645
|
}
|
|
45584
45646
|
function startAddressProbes(targets, workers = realProbeWorkers, portBase) {
|
|
45585
45647
|
refuseToBlockInRole("a synchronous probe of a provider's address");
|
|
@@ -45604,7 +45666,7 @@ function startAddressProbes(targets, workers = realProbeWorkers, portBase) {
|
|
|
45604
45666
|
}
|
|
45605
45667
|
const portFirst = DOOR_SOURCE_PORT_START + (base + index * stride) % DOOR_SOURCE_PORT_COUNT;
|
|
45606
45668
|
try {
|
|
45607
|
-
const started = workers.start(ACCEPT_PROBE_SOURCE, { host: target.host, port: target.port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, portFirst }, target.timeoutMs);
|
|
45669
|
+
const started = workers.start(ACCEPT_PROBE_SOURCE, { host: target.host, port: target.port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, portFirst, platform: process.platform }, target.timeoutMs);
|
|
45608
45670
|
running.push({ key: targetKey(target), verdict: started.verdict, cancel: started.cancel });
|
|
45609
45671
|
} catch (error63) {
|
|
45610
45672
|
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error63 instanceof Error ? error63.message : String(error63)}`;
|
|
@@ -45779,15 +45841,16 @@ request.end();
|
|
|
45779
45841
|
ACCEPT_PROBE_SOURCE = probeWorkerSource(`
|
|
45780
45842
|
const net = require("node:net");
|
|
45781
45843
|
const dns = require("node:dns");
|
|
45782
|
-
const { host, port, portStart, portEnd, portFirst, timeoutMs, ok, failed } = workerData;
|
|
45844
|
+
const { host, port, portStart, portEnd, portFirst, platform, timeoutMs, ok, failed } = workerData;
|
|
45783
45845
|
const finish = finishProbe;
|
|
45784
45846
|
const SourcePortRange = ${SourcePortRange.toString()};
|
|
45785
45847
|
const createDoorLookup = ${createDoorLookup.toString()};
|
|
45848
|
+
const sourcePortClassifier = ${sourcePortClassifier.toString()};
|
|
45786
45849
|
const doorDial = ${doorDial.toString()};
|
|
45787
45850
|
const probeAccept = ${probeAccept.toString()};
|
|
45788
45851
|
const runAcceptProbe = ${runAcceptProbe.toString()};
|
|
45789
45852
|
const startTimer = (callback, ms) => { const timer = setTimeout(callback, ms); return () => { clearTimeout(timer); }; };
|
|
45790
|
-
runAcceptProbe({ net, dns, createDoorLookup, doorDial, probeAccept, SourcePortRange }, { host, port, portStart, portEnd, portFirst, timeoutMs }, startTimer).then((verdict) => {
|
|
45853
|
+
runAcceptProbe({ net, dns, createDoorLookup, doorDial, probeAccept, SourcePortRange, sourcePortClassifier }, { host, port, portStart, portEnd, portFirst, platform, timeoutMs }, startTimer).then((verdict) => {
|
|
45791
45854
|
finish(verdict.ok ? ok : failed, verdict.ok ? "" : verdict.reason);
|
|
45792
45855
|
});
|
|
45793
45856
|
`);
|
|
@@ -74381,7 +74444,7 @@ var init_package = __esm({
|
|
|
74381
74444
|
"package.json"() {
|
|
74382
74445
|
package_default = {
|
|
74383
74446
|
name: "claude-use",
|
|
74384
|
-
version: "14.0.
|
|
74447
|
+
version: "14.0.3",
|
|
74385
74448
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
74386
74449
|
license: "MIT",
|
|
74387
74450
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
package/dist/index.cjs
CHANGED
|
@@ -8230,6 +8230,20 @@ function createDoorLookup(io) {
|
|
|
8230
8230
|
});
|
|
8231
8231
|
};
|
|
8232
8232
|
}
|
|
8233
|
+
function sourcePortClassifier(platform) {
|
|
8234
|
+
const classify = (error) => {
|
|
8235
|
+
const attempts = Reflect.get(error, "errors");
|
|
8236
|
+
if (Array.isArray(attempts) && attempts.length > 0) {
|
|
8237
|
+
const kinds = attempts.map((attempt) => attempt instanceof Error ? classify(attempt) : void 0);
|
|
8238
|
+
return kinds.includes("excluded") ? "excluded" : kinds.includes("held") ? "held" : void 0;
|
|
8239
|
+
}
|
|
8240
|
+
if (error.code === "EADDRINUSE" || error.code === "EADDRNOTAVAIL") {
|
|
8241
|
+
return "held";
|
|
8242
|
+
}
|
|
8243
|
+
return platform === "win32" && error.code === "EACCES" && error.syscall === "bind" ? "excluded" : void 0;
|
|
8244
|
+
};
|
|
8245
|
+
return classify;
|
|
8246
|
+
}
|
|
8233
8247
|
function doorDial(io, target, ports) {
|
|
8234
8248
|
const dialOnce = (options) => new Promise((resolve) => {
|
|
8235
8249
|
const socket = io.connect(options);
|
|
@@ -8242,12 +8256,15 @@ function doorDial(io, target, ports) {
|
|
|
8242
8256
|
if (error.message === "" && Array.isArray(attempts) && attempts.length > 0) {
|
|
8243
8257
|
const flattened = new Error(attempts.map((attempt) => withoutLocalEnd(attempt instanceof Error ? attempt.message : String(attempt))).join("; "));
|
|
8244
8258
|
flattened.code = error.code;
|
|
8259
|
+
flattened.syscall = error.syscall;
|
|
8260
|
+
Object.defineProperty(flattened, "errors", { value: attempts });
|
|
8245
8261
|
resolve({ error: flattened, socket });
|
|
8246
8262
|
return;
|
|
8247
8263
|
}
|
|
8248
8264
|
if (withoutLocalEnd(error.message) !== error.message) {
|
|
8249
8265
|
const trimmed = new Error(withoutLocalEnd(error.message));
|
|
8250
8266
|
trimmed.code = error.code;
|
|
8267
|
+
trimmed.syscall = error.syscall;
|
|
8251
8268
|
resolve({ error: trimmed, socket });
|
|
8252
8269
|
return;
|
|
8253
8270
|
}
|
|
@@ -8257,17 +8274,35 @@ function doorDial(io, target, ports) {
|
|
|
8257
8274
|
if (io.isIP(target.host) !== 0) {
|
|
8258
8275
|
return dialOnce({ host: target.host, port: target.port });
|
|
8259
8276
|
}
|
|
8260
|
-
const attemptFrom = (attempt
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8277
|
+
const attemptFrom = (attempt, refused2) => {
|
|
8278
|
+
const port = ports.take();
|
|
8279
|
+
return dialOnce({ host: target.host, port: target.port, localPort: port, lookup: io.lookup }).then((outcome) => {
|
|
8280
|
+
if (outcome.error === null) {
|
|
8281
|
+
return outcome;
|
|
8282
|
+
}
|
|
8283
|
+
const failure = io.sourcePortFailure(outcome.error);
|
|
8284
|
+
if (failure === void 0) {
|
|
8285
|
+
return outcome;
|
|
8286
|
+
}
|
|
8287
|
+
if (failure === "excluded") {
|
|
8288
|
+
ports.exclude(port);
|
|
8289
|
+
}
|
|
8290
|
+
const refusedSoFar = failure === "excluded" ? refused2 + 1 : refused2;
|
|
8291
|
+
if (attempt < ports.count - 1) {
|
|
8292
|
+
return attemptFrom(attempt + 1, refusedSoFar);
|
|
8293
|
+
}
|
|
8294
|
+
if (refusedSoFar === 0) {
|
|
8295
|
+
return outcome;
|
|
8296
|
+
}
|
|
8297
|
+
const scope = refusedSoFar === ports.count ? "every source port" : `${String(refusedSoFar)} of its ${String(ports.count)} source ports (the rest were held by other sockets)`;
|
|
8298
|
+
const refusal2 = new Error(
|
|
8299
|
+
`${scope} of the door's reserved range (${String(ports.start)} to ${String(ports.end)}) could not be bound: Windows refuses a port inside an excluded range with EACCES (Hyper-V, WSL2 and Docker Desktop reserve blocks of ports). List the excluded ranges with \`netsh int ipv4 show excludedportrange protocol=tcp\``
|
|
8300
|
+
);
|
|
8301
|
+
refusal2.code = refusedSoFar === ports.count ? "EACCES" : outcome.error.code;
|
|
8302
|
+
return { error: refusal2, socket: outcome.socket };
|
|
8303
|
+
});
|
|
8304
|
+
};
|
|
8305
|
+
return attemptFrom(0, 0);
|
|
8271
8306
|
}
|
|
8272
8307
|
function probeAccept(dial, timeoutMs, startTimer) {
|
|
8273
8308
|
return new Promise((resolve) => {
|
|
@@ -8302,7 +8337,7 @@ function runAcceptProbe(deps, data, startTimer) {
|
|
|
8302
8337
|
const lookup2 = deps.createDoorLookup({ isIP: deps.net.isIP, resolve4: (name, callback) => {
|
|
8303
8338
|
deps.dns.resolve4(name, callback);
|
|
8304
8339
|
} });
|
|
8305
|
-
const io = { connect: (options) => deps.net.connect(options), lookup: lookup2, isIP: deps.net.isIP };
|
|
8340
|
+
const io = { connect: (options) => deps.net.connect(options), lookup: lookup2, isIP: deps.net.isIP, sourcePortFailure: deps.sourcePortClassifier(data.platform) };
|
|
8306
8341
|
return deps.probeAccept(() => deps.doorDial(io, { host: data.host, port: data.port }, new deps.SourcePortRange(data.portStart, data.portEnd, data.portFirst)), data.timeoutMs, startTimer);
|
|
8307
8342
|
}
|
|
8308
8343
|
var init_doorDial = __esm({
|
|
@@ -8315,14 +8350,17 @@ var init_doorDial = __esm({
|
|
|
8315
8350
|
function isSuccessful2(status) {
|
|
8316
8351
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE2;
|
|
8317
8352
|
}
|
|
8353
|
+
function realDoorDialIo(platform = process.platform, connect3 = (options) => net2.connect(options)) {
|
|
8354
|
+
return { connect: connect3, lookup: realAddressLookup, isIP: net2.isIP, sourcePortFailure: sourcePortClassifier(platform) };
|
|
8355
|
+
}
|
|
8318
8356
|
function dialTarget(options, defaultPort) {
|
|
8319
8357
|
return { host: typeof options.host === "string" ? options.host : "", port: typeof options.port === "number" ? options.port : defaultPort };
|
|
8320
8358
|
}
|
|
8321
8359
|
function literalDial(target) {
|
|
8322
8360
|
return net2.connect({ host: target.host, port: target.port });
|
|
8323
8361
|
}
|
|
8324
|
-
async function reservedDial(target, ports) {
|
|
8325
|
-
return await doorDial(
|
|
8362
|
+
async function reservedDial(target, ports, io) {
|
|
8363
|
+
return await doorDial(io, target, ports);
|
|
8326
8364
|
}
|
|
8327
8365
|
function requestServername(options, fallback) {
|
|
8328
8366
|
return "servername" in options && typeof options.servername === "string" && options.servername !== "" ? options.servername : fallback;
|
|
@@ -8462,9 +8500,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
8462
8500
|
}
|
|
8463
8501
|
};
|
|
8464
8502
|
}
|
|
8465
|
-
function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
8466
|
-
const plainAgent = new ExemptHttpAgent(ports);
|
|
8467
|
-
const tlsAgent = new ExemptTlsAgent(ports);
|
|
8503
|
+
function realConnectEffects(ports = DOOR_SOURCE_PORTS, io = realDoorDialIo()) {
|
|
8504
|
+
const plainAgent = new ExemptHttpAgent(ports, io);
|
|
8505
|
+
const tlsAgent = new ExemptTlsAgent(ports, io);
|
|
8468
8506
|
const listenOnce = async (target, onSocket) => await new Promise((resolve, reject) => {
|
|
8469
8507
|
const accepted = /* @__PURE__ */ new Set();
|
|
8470
8508
|
const server = net2.createServer((socket) => {
|
|
@@ -8596,7 +8634,7 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
8596
8634
|
};
|
|
8597
8635
|
},
|
|
8598
8636
|
connectTlsUpstream: async (host, port, clientAlpn) => {
|
|
8599
|
-
const dialled = await reservedDial({ host, port }, ports);
|
|
8637
|
+
const dialled = await reservedDial({ host, port }, ports, io);
|
|
8600
8638
|
if (dialled.error !== null) {
|
|
8601
8639
|
throw dialled.error;
|
|
8602
8640
|
}
|
|
@@ -8677,7 +8715,7 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
8677
8715
|
}
|
|
8678
8716
|
};
|
|
8679
8717
|
}
|
|
8680
|
-
var import_node_dns, http, https2, net2, tls, SUCCESS_STATUS_MAX_EXCLUSIVE2, SourcePortRange, DOOR_SOURCE_PORT_START, DOOR_SOURCE_PORT_COUNT, DOOR_SOURCE_PORT_END, DOOR_SOURCE_PORTS, POOLED_SOCKET_IDLE_MS, POOLED_SOCKETS_KEPT_IDLE, POOLING, realAddressLookup,
|
|
8718
|
+
var import_node_dns, http, https2, net2, tls, SUCCESS_STATUS_MAX_EXCLUSIVE2, SourcePortRange, DOOR_SOURCE_PORT_START, DOOR_SOURCE_PORT_COUNT, DOOR_SOURCE_PORT_END, DOOR_SOURCE_PORTS, POOLED_SOCKET_IDLE_MS, POOLED_SOCKETS_KEPT_IDLE, POOLING, realAddressLookup, HTTP_PORT, ExemptHttpAgent, ExemptTlsAgent, NO_CHUNKS;
|
|
8681
8719
|
var init_connectEffects = __esm({
|
|
8682
8720
|
"src/frontdoor/connectEffects.ts"() {
|
|
8683
8721
|
"use strict";
|
|
@@ -8699,13 +8737,28 @@ var init_connectEffects = __esm({
|
|
|
8699
8737
|
this.end = end;
|
|
8700
8738
|
this.count = end - start + 1;
|
|
8701
8739
|
this.next = first;
|
|
8740
|
+
this.excluded = /* @__PURE__ */ new Set();
|
|
8702
8741
|
}
|
|
8703
|
-
/**
|
|
8742
|
+
/**
|
|
8743
|
+
* The next port in rotation, wrapping from the end back to the start, skipping every port the system has refused to bind (`exclude`) so a dial does not walk a refused block again. A cycle that finds nothing else forgets the refusals and starts over: the exclusions of a host can change while the door runs, and a range refused throughout is then tried again, one pass, not skipped for ever. The memory is a set of ports of the range, so it holds at most `count` entries.
|
|
8744
|
+
*/
|
|
8704
8745
|
take() {
|
|
8746
|
+
for (let skipped = 0; skipped < this.count; skipped += 1) {
|
|
8747
|
+
const port2 = this.next;
|
|
8748
|
+
this.next = this.next === this.end ? this.start : this.next + 1;
|
|
8749
|
+
if (!this.excluded.has(port2)) {
|
|
8750
|
+
return port2;
|
|
8751
|
+
}
|
|
8752
|
+
}
|
|
8753
|
+
this.excluded.clear();
|
|
8705
8754
|
const port = this.next;
|
|
8706
8755
|
this.next = this.next === this.end ? this.start : this.next + 1;
|
|
8707
8756
|
return port;
|
|
8708
8757
|
}
|
|
8758
|
+
/** Remembers that the system refuses to bind `port`, so `take` skips it. Only an exclusion belongs here: a port a sibling holds is free again when the sibling closes. */
|
|
8759
|
+
exclude(port) {
|
|
8760
|
+
this.excluded.add(port);
|
|
8761
|
+
}
|
|
8709
8762
|
};
|
|
8710
8763
|
DOOR_SOURCE_PORT_START = 47900;
|
|
8711
8764
|
DOOR_SOURCE_PORT_COUNT = 1e3;
|
|
@@ -8717,39 +8770,42 @@ var init_connectEffects = __esm({
|
|
|
8717
8770
|
realAddressLookup = createDoorLookup({ isIP: net2.isIP, resolve4: (host, callback) => {
|
|
8718
8771
|
import_node_dns.default.resolve4(host, callback);
|
|
8719
8772
|
} });
|
|
8720
|
-
realDialIo = { connect: (options) => net2.connect(options), lookup: realAddressLookup, isIP: net2.isIP };
|
|
8721
8773
|
HTTP_PORT = 80;
|
|
8722
8774
|
ExemptHttpAgent = class extends http.Agent {
|
|
8723
|
-
constructor(ports = DOOR_SOURCE_PORTS) {
|
|
8775
|
+
constructor(ports = DOOR_SOURCE_PORTS, io = realDoorDialIo()) {
|
|
8724
8776
|
super(POOLING);
|
|
8725
8777
|
this.ports = ports;
|
|
8778
|
+
this.io = io;
|
|
8726
8779
|
}
|
|
8727
8780
|
ports;
|
|
8781
|
+
io;
|
|
8728
8782
|
// A reserved-port dial that has to retry cannot produce its socket synchronously, so it settles first and arrives through the callback (node's documented asynchronous createConnection form); a literal dial has nothing to retry and keeps node's own synchronous shape.
|
|
8729
8783
|
createConnection(options, oncreate) {
|
|
8730
8784
|
const target = dialTarget(options, HTTP_PORT);
|
|
8731
8785
|
if (net2.isIP(target.host) !== 0) {
|
|
8732
8786
|
return literalDial(target);
|
|
8733
8787
|
}
|
|
8734
|
-
void reservedDial(target, this.ports).then((outcome) => {
|
|
8788
|
+
void reservedDial(target, this.ports, this.io).then((outcome) => {
|
|
8735
8789
|
oncreate?.(outcome.error, outcome.socket);
|
|
8736
8790
|
});
|
|
8737
8791
|
return void 0;
|
|
8738
8792
|
}
|
|
8739
8793
|
};
|
|
8740
8794
|
ExemptTlsAgent = class extends https2.Agent {
|
|
8741
|
-
constructor(ports = DOOR_SOURCE_PORTS) {
|
|
8795
|
+
constructor(ports = DOOR_SOURCE_PORTS, io = realDoorDialIo()) {
|
|
8742
8796
|
super(POOLING);
|
|
8743
8797
|
this.ports = ports;
|
|
8798
|
+
this.io = io;
|
|
8744
8799
|
}
|
|
8745
8800
|
ports;
|
|
8801
|
+
io;
|
|
8746
8802
|
// The same split as the plain sibling: a literal dial wraps TLS around the socket node's own agent would have returned, a reserved dial settles (retries included) first and arrives through the callback, which is exactly where node's own agent wraps its own dials.
|
|
8747
8803
|
createConnection(options, oncreate) {
|
|
8748
8804
|
const target = dialTarget(options, HTTPS_PORT);
|
|
8749
8805
|
if (net2.isIP(target.host) !== 0) {
|
|
8750
8806
|
return tls.connect({ socket: literalDial(target), servername: requestServername(options, target.host), ...tlsFacts(options) });
|
|
8751
8807
|
}
|
|
8752
|
-
void reservedDial(target, this.ports).then((outcome) => {
|
|
8808
|
+
void reservedDial(target, this.ports, this.io).then((outcome) => {
|
|
8753
8809
|
if (outcome.error !== null) {
|
|
8754
8810
|
oncreate?.(outcome.error, outcome.socket);
|
|
8755
8811
|
return;
|
|
@@ -10800,6 +10856,9 @@ function reportableAllowlistFileProblem(allowlistFile, ports, served) {
|
|
|
10800
10856
|
return problem?.repairable === false || served ? problem : void 0;
|
|
10801
10857
|
}
|
|
10802
10858
|
function verifyAllowlistFile(allowlistFile, ports) {
|
|
10859
|
+
if (platformRefusal(ports.platform) !== void 0) {
|
|
10860
|
+
return void 0;
|
|
10861
|
+
}
|
|
10803
10862
|
const uid = ports.currentUid();
|
|
10804
10863
|
const directories = pathDirectories(allowlistFile, ports);
|
|
10805
10864
|
if (typeof directories === "string") {
|
|
@@ -11871,7 +11930,10 @@ var init_realPorts = __esm({
|
|
|
11871
11930
|
};
|
|
11872
11931
|
SOCKET_PERMISSION_BITS = 4095;
|
|
11873
11932
|
realHeadroomSocketTrust = {
|
|
11874
|
-
platform
|
|
11933
|
+
// Read at each use, not fixed when the module loads, so what the checks do for a platform is testable through the real wiring.
|
|
11934
|
+
get platform() {
|
|
11935
|
+
return process.platform;
|
|
11936
|
+
},
|
|
11875
11937
|
currentUid: () => {
|
|
11876
11938
|
if (process.getuid === void 0) {
|
|
11877
11939
|
throw new Error(`no POSIX user id on ${process.platform}`);
|
|
@@ -13814,7 +13876,7 @@ var init_package = __esm({
|
|
|
13814
13876
|
"package.json"() {
|
|
13815
13877
|
package_default = {
|
|
13816
13878
|
name: "claude-use",
|
|
13817
|
-
version: "14.0.
|
|
13879
|
+
version: "14.0.3",
|
|
13818
13880
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
13819
13881
|
license: "MIT",
|
|
13820
13882
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -15094,7 +15156,7 @@ function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS, workers =
|
|
|
15094
15156
|
}
|
|
15095
15157
|
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
15096
15158
|
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
15097
|
-
return workers.start(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END }, timeoutMs).verdict();
|
|
15159
|
+
return workers.start(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, platform: process.platform }, timeoutMs).verdict();
|
|
15098
15160
|
}
|
|
15099
15161
|
function startAddressProbes(targets, workers = realProbeWorkers, portBase) {
|
|
15100
15162
|
refuseToBlockInRole("a synchronous probe of a provider's address");
|
|
@@ -15119,7 +15181,7 @@ function startAddressProbes(targets, workers = realProbeWorkers, portBase) {
|
|
|
15119
15181
|
}
|
|
15120
15182
|
const portFirst = DOOR_SOURCE_PORT_START + (base + index * stride) % DOOR_SOURCE_PORT_COUNT;
|
|
15121
15183
|
try {
|
|
15122
|
-
const started = workers.start(ACCEPT_PROBE_SOURCE, { host: target.host, port: target.port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, portFirst }, target.timeoutMs);
|
|
15184
|
+
const started = workers.start(ACCEPT_PROBE_SOURCE, { host: target.host, port: target.port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, portFirst, platform: process.platform }, target.timeoutMs);
|
|
15123
15185
|
running.push({ key: targetKey(target), verdict: started.verdict, cancel: started.cancel });
|
|
15124
15186
|
} catch (error) {
|
|
15125
15187
|
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -15294,15 +15356,16 @@ request.end();
|
|
|
15294
15356
|
ACCEPT_PROBE_SOURCE = probeWorkerSource(`
|
|
15295
15357
|
const net = require("node:net");
|
|
15296
15358
|
const dns = require("node:dns");
|
|
15297
|
-
const { host, port, portStart, portEnd, portFirst, timeoutMs, ok, failed } = workerData;
|
|
15359
|
+
const { host, port, portStart, portEnd, portFirst, platform, timeoutMs, ok, failed } = workerData;
|
|
15298
15360
|
const finish = finishProbe;
|
|
15299
15361
|
const SourcePortRange = ${SourcePortRange.toString()};
|
|
15300
15362
|
const createDoorLookup = ${createDoorLookup.toString()};
|
|
15363
|
+
const sourcePortClassifier = ${sourcePortClassifier.toString()};
|
|
15301
15364
|
const doorDial = ${doorDial.toString()};
|
|
15302
15365
|
const probeAccept = ${probeAccept.toString()};
|
|
15303
15366
|
const runAcceptProbe = ${runAcceptProbe.toString()};
|
|
15304
15367
|
const startTimer = (callback, ms) => { const timer = setTimeout(callback, ms); return () => { clearTimeout(timer); }; };
|
|
15305
|
-
runAcceptProbe({ net, dns, createDoorLookup, doorDial, probeAccept, SourcePortRange }, { host, port, portStart, portEnd, portFirst, timeoutMs }, startTimer).then((verdict) => {
|
|
15368
|
+
runAcceptProbe({ net, dns, createDoorLookup, doorDial, probeAccept, SourcePortRange, sourcePortClassifier }, { host, port, portStart, portEnd, portFirst, platform, timeoutMs }, startTimer).then((verdict) => {
|
|
15306
15369
|
finish(verdict.ok ? ok : failed, verdict.ok ? "" : verdict.reason);
|
|
15307
15370
|
});
|
|
15308
15371
|
`);
|