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/index.mjs
CHANGED
|
@@ -8205,6 +8205,20 @@ function createDoorLookup(io) {
|
|
|
8205
8205
|
});
|
|
8206
8206
|
};
|
|
8207
8207
|
}
|
|
8208
|
+
function sourcePortClassifier(platform) {
|
|
8209
|
+
const classify = (error) => {
|
|
8210
|
+
const attempts = Reflect.get(error, "errors");
|
|
8211
|
+
if (Array.isArray(attempts) && attempts.length > 0) {
|
|
8212
|
+
const kinds = attempts.map((attempt) => attempt instanceof Error ? classify(attempt) : void 0);
|
|
8213
|
+
return kinds.includes("excluded") ? "excluded" : kinds.includes("held") ? "held" : void 0;
|
|
8214
|
+
}
|
|
8215
|
+
if (error.code === "EADDRINUSE" || error.code === "EADDRNOTAVAIL") {
|
|
8216
|
+
return "held";
|
|
8217
|
+
}
|
|
8218
|
+
return platform === "win32" && error.code === "EACCES" && error.syscall === "bind" ? "excluded" : void 0;
|
|
8219
|
+
};
|
|
8220
|
+
return classify;
|
|
8221
|
+
}
|
|
8208
8222
|
function doorDial(io, target, ports) {
|
|
8209
8223
|
const dialOnce = (options) => new Promise((resolve) => {
|
|
8210
8224
|
const socket = io.connect(options);
|
|
@@ -8217,12 +8231,15 @@ function doorDial(io, target, ports) {
|
|
|
8217
8231
|
if (error.message === "" && Array.isArray(attempts) && attempts.length > 0) {
|
|
8218
8232
|
const flattened = new Error(attempts.map((attempt) => withoutLocalEnd(attempt instanceof Error ? attempt.message : String(attempt))).join("; "));
|
|
8219
8233
|
flattened.code = error.code;
|
|
8234
|
+
flattened.syscall = error.syscall;
|
|
8235
|
+
Object.defineProperty(flattened, "errors", { value: attempts });
|
|
8220
8236
|
resolve({ error: flattened, socket });
|
|
8221
8237
|
return;
|
|
8222
8238
|
}
|
|
8223
8239
|
if (withoutLocalEnd(error.message) !== error.message) {
|
|
8224
8240
|
const trimmed = new Error(withoutLocalEnd(error.message));
|
|
8225
8241
|
trimmed.code = error.code;
|
|
8242
|
+
trimmed.syscall = error.syscall;
|
|
8226
8243
|
resolve({ error: trimmed, socket });
|
|
8227
8244
|
return;
|
|
8228
8245
|
}
|
|
@@ -8232,17 +8249,35 @@ function doorDial(io, target, ports) {
|
|
|
8232
8249
|
if (io.isIP(target.host) !== 0) {
|
|
8233
8250
|
return dialOnce({ host: target.host, port: target.port });
|
|
8234
8251
|
}
|
|
8235
|
-
const attemptFrom = (attempt
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8252
|
+
const attemptFrom = (attempt, refused2) => {
|
|
8253
|
+
const port = ports.take();
|
|
8254
|
+
return dialOnce({ host: target.host, port: target.port, localPort: port, lookup: io.lookup }).then((outcome) => {
|
|
8255
|
+
if (outcome.error === null) {
|
|
8256
|
+
return outcome;
|
|
8257
|
+
}
|
|
8258
|
+
const failure = io.sourcePortFailure(outcome.error);
|
|
8259
|
+
if (failure === void 0) {
|
|
8260
|
+
return outcome;
|
|
8261
|
+
}
|
|
8262
|
+
if (failure === "excluded") {
|
|
8263
|
+
ports.exclude(port);
|
|
8264
|
+
}
|
|
8265
|
+
const refusedSoFar = failure === "excluded" ? refused2 + 1 : refused2;
|
|
8266
|
+
if (attempt < ports.count - 1) {
|
|
8267
|
+
return attemptFrom(attempt + 1, refusedSoFar);
|
|
8268
|
+
}
|
|
8269
|
+
if (refusedSoFar === 0) {
|
|
8270
|
+
return outcome;
|
|
8271
|
+
}
|
|
8272
|
+
const scope = refusedSoFar === ports.count ? "every source port" : `${String(refusedSoFar)} of its ${String(ports.count)} source ports (the rest were held by other sockets)`;
|
|
8273
|
+
const refusal2 = new Error(
|
|
8274
|
+
`${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\``
|
|
8275
|
+
);
|
|
8276
|
+
refusal2.code = refusedSoFar === ports.count ? "EACCES" : outcome.error.code;
|
|
8277
|
+
return { error: refusal2, socket: outcome.socket };
|
|
8278
|
+
});
|
|
8279
|
+
};
|
|
8280
|
+
return attemptFrom(0, 0);
|
|
8246
8281
|
}
|
|
8247
8282
|
function probeAccept(dial, timeoutMs, startTimer) {
|
|
8248
8283
|
return new Promise((resolve) => {
|
|
@@ -8277,7 +8312,7 @@ function runAcceptProbe(deps, data, startTimer) {
|
|
|
8277
8312
|
const lookup2 = deps.createDoorLookup({ isIP: deps.net.isIP, resolve4: (name, callback) => {
|
|
8278
8313
|
deps.dns.resolve4(name, callback);
|
|
8279
8314
|
} });
|
|
8280
|
-
const io = { connect: (options) => deps.net.connect(options), lookup: lookup2, isIP: deps.net.isIP };
|
|
8315
|
+
const io = { connect: (options) => deps.net.connect(options), lookup: lookup2, isIP: deps.net.isIP, sourcePortFailure: deps.sourcePortClassifier(data.platform) };
|
|
8281
8316
|
return deps.probeAccept(() => deps.doorDial(io, { host: data.host, port: data.port }, new deps.SourcePortRange(data.portStart, data.portEnd, data.portFirst)), data.timeoutMs, startTimer);
|
|
8282
8317
|
}
|
|
8283
8318
|
var init_doorDial = __esm({
|
|
@@ -8295,14 +8330,17 @@ import * as tls from "node:tls";
|
|
|
8295
8330
|
function isSuccessful2(status) {
|
|
8296
8331
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE2;
|
|
8297
8332
|
}
|
|
8333
|
+
function realDoorDialIo(platform = process.platform, connect3 = (options) => net2.connect(options)) {
|
|
8334
|
+
return { connect: connect3, lookup: realAddressLookup, isIP: net2.isIP, sourcePortFailure: sourcePortClassifier(platform) };
|
|
8335
|
+
}
|
|
8298
8336
|
function dialTarget(options, defaultPort) {
|
|
8299
8337
|
return { host: typeof options.host === "string" ? options.host : "", port: typeof options.port === "number" ? options.port : defaultPort };
|
|
8300
8338
|
}
|
|
8301
8339
|
function literalDial(target) {
|
|
8302
8340
|
return net2.connect({ host: target.host, port: target.port });
|
|
8303
8341
|
}
|
|
8304
|
-
async function reservedDial(target, ports) {
|
|
8305
|
-
return await doorDial(
|
|
8342
|
+
async function reservedDial(target, ports, io) {
|
|
8343
|
+
return await doorDial(io, target, ports);
|
|
8306
8344
|
}
|
|
8307
8345
|
function requestServername(options, fallback) {
|
|
8308
8346
|
return "servername" in options && typeof options.servername === "string" && options.servername !== "" ? options.servername : fallback;
|
|
@@ -8442,9 +8480,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
8442
8480
|
}
|
|
8443
8481
|
};
|
|
8444
8482
|
}
|
|
8445
|
-
function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
8446
|
-
const plainAgent = new ExemptHttpAgent(ports);
|
|
8447
|
-
const tlsAgent = new ExemptTlsAgent(ports);
|
|
8483
|
+
function realConnectEffects(ports = DOOR_SOURCE_PORTS, io = realDoorDialIo()) {
|
|
8484
|
+
const plainAgent = new ExemptHttpAgent(ports, io);
|
|
8485
|
+
const tlsAgent = new ExemptTlsAgent(ports, io);
|
|
8448
8486
|
const listenOnce = async (target, onSocket) => await new Promise((resolve, reject) => {
|
|
8449
8487
|
const accepted = /* @__PURE__ */ new Set();
|
|
8450
8488
|
const server = net2.createServer((socket) => {
|
|
@@ -8576,7 +8614,7 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
8576
8614
|
};
|
|
8577
8615
|
},
|
|
8578
8616
|
connectTlsUpstream: async (host, port, clientAlpn) => {
|
|
8579
|
-
const dialled = await reservedDial({ host, port }, ports);
|
|
8617
|
+
const dialled = await reservedDial({ host, port }, ports, io);
|
|
8580
8618
|
if (dialled.error !== null) {
|
|
8581
8619
|
throw dialled.error;
|
|
8582
8620
|
}
|
|
@@ -8657,7 +8695,7 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
8657
8695
|
}
|
|
8658
8696
|
};
|
|
8659
8697
|
}
|
|
8660
|
-
var 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,
|
|
8698
|
+
var 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;
|
|
8661
8699
|
var init_connectEffects = __esm({
|
|
8662
8700
|
"src/frontdoor/connectEffects.ts"() {
|
|
8663
8701
|
"use strict";
|
|
@@ -8674,13 +8712,28 @@ var init_connectEffects = __esm({
|
|
|
8674
8712
|
this.end = end;
|
|
8675
8713
|
this.count = end - start + 1;
|
|
8676
8714
|
this.next = first;
|
|
8715
|
+
this.excluded = /* @__PURE__ */ new Set();
|
|
8677
8716
|
}
|
|
8678
|
-
/**
|
|
8717
|
+
/**
|
|
8718
|
+
* 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.
|
|
8719
|
+
*/
|
|
8679
8720
|
take() {
|
|
8721
|
+
for (let skipped = 0; skipped < this.count; skipped += 1) {
|
|
8722
|
+
const port2 = this.next;
|
|
8723
|
+
this.next = this.next === this.end ? this.start : this.next + 1;
|
|
8724
|
+
if (!this.excluded.has(port2)) {
|
|
8725
|
+
return port2;
|
|
8726
|
+
}
|
|
8727
|
+
}
|
|
8728
|
+
this.excluded.clear();
|
|
8680
8729
|
const port = this.next;
|
|
8681
8730
|
this.next = this.next === this.end ? this.start : this.next + 1;
|
|
8682
8731
|
return port;
|
|
8683
8732
|
}
|
|
8733
|
+
/** 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. */
|
|
8734
|
+
exclude(port) {
|
|
8735
|
+
this.excluded.add(port);
|
|
8736
|
+
}
|
|
8684
8737
|
};
|
|
8685
8738
|
DOOR_SOURCE_PORT_START = 47900;
|
|
8686
8739
|
DOOR_SOURCE_PORT_COUNT = 1e3;
|
|
@@ -8692,39 +8745,42 @@ var init_connectEffects = __esm({
|
|
|
8692
8745
|
realAddressLookup = createDoorLookup({ isIP: net2.isIP, resolve4: (host, callback) => {
|
|
8693
8746
|
dns.resolve4(host, callback);
|
|
8694
8747
|
} });
|
|
8695
|
-
realDialIo = { connect: (options) => net2.connect(options), lookup: realAddressLookup, isIP: net2.isIP };
|
|
8696
8748
|
HTTP_PORT = 80;
|
|
8697
8749
|
ExemptHttpAgent = class extends http.Agent {
|
|
8698
|
-
constructor(ports = DOOR_SOURCE_PORTS) {
|
|
8750
|
+
constructor(ports = DOOR_SOURCE_PORTS, io = realDoorDialIo()) {
|
|
8699
8751
|
super(POOLING);
|
|
8700
8752
|
this.ports = ports;
|
|
8753
|
+
this.io = io;
|
|
8701
8754
|
}
|
|
8702
8755
|
ports;
|
|
8756
|
+
io;
|
|
8703
8757
|
// 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.
|
|
8704
8758
|
createConnection(options, oncreate) {
|
|
8705
8759
|
const target = dialTarget(options, HTTP_PORT);
|
|
8706
8760
|
if (net2.isIP(target.host) !== 0) {
|
|
8707
8761
|
return literalDial(target);
|
|
8708
8762
|
}
|
|
8709
|
-
void reservedDial(target, this.ports).then((outcome) => {
|
|
8763
|
+
void reservedDial(target, this.ports, this.io).then((outcome) => {
|
|
8710
8764
|
oncreate?.(outcome.error, outcome.socket);
|
|
8711
8765
|
});
|
|
8712
8766
|
return void 0;
|
|
8713
8767
|
}
|
|
8714
8768
|
};
|
|
8715
8769
|
ExemptTlsAgent = class extends https2.Agent {
|
|
8716
|
-
constructor(ports = DOOR_SOURCE_PORTS) {
|
|
8770
|
+
constructor(ports = DOOR_SOURCE_PORTS, io = realDoorDialIo()) {
|
|
8717
8771
|
super(POOLING);
|
|
8718
8772
|
this.ports = ports;
|
|
8773
|
+
this.io = io;
|
|
8719
8774
|
}
|
|
8720
8775
|
ports;
|
|
8776
|
+
io;
|
|
8721
8777
|
// 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.
|
|
8722
8778
|
createConnection(options, oncreate) {
|
|
8723
8779
|
const target = dialTarget(options, HTTPS_PORT);
|
|
8724
8780
|
if (net2.isIP(target.host) !== 0) {
|
|
8725
8781
|
return tls.connect({ socket: literalDial(target), servername: requestServername(options, target.host), ...tlsFacts(options) });
|
|
8726
8782
|
}
|
|
8727
|
-
void reservedDial(target, this.ports).then((outcome) => {
|
|
8783
|
+
void reservedDial(target, this.ports, this.io).then((outcome) => {
|
|
8728
8784
|
if (outcome.error !== null) {
|
|
8729
8785
|
oncreate?.(outcome.error, outcome.socket);
|
|
8730
8786
|
return;
|
|
@@ -10774,6 +10830,9 @@ function reportableAllowlistFileProblem(allowlistFile, ports, served) {
|
|
|
10774
10830
|
return problem?.repairable === false || served ? problem : void 0;
|
|
10775
10831
|
}
|
|
10776
10832
|
function verifyAllowlistFile(allowlistFile, ports) {
|
|
10833
|
+
if (platformRefusal(ports.platform) !== void 0) {
|
|
10834
|
+
return void 0;
|
|
10835
|
+
}
|
|
10777
10836
|
const uid = ports.currentUid();
|
|
10778
10837
|
const directories = pathDirectories(allowlistFile, ports);
|
|
10779
10838
|
if (typeof directories === "string") {
|
|
@@ -11844,7 +11903,10 @@ var init_realPorts = __esm({
|
|
|
11844
11903
|
};
|
|
11845
11904
|
SOCKET_PERMISSION_BITS = 4095;
|
|
11846
11905
|
realHeadroomSocketTrust = {
|
|
11847
|
-
platform
|
|
11906
|
+
// Read at each use, not fixed when the module loads, so what the checks do for a platform is testable through the real wiring.
|
|
11907
|
+
get platform() {
|
|
11908
|
+
return process.platform;
|
|
11909
|
+
},
|
|
11848
11910
|
currentUid: () => {
|
|
11849
11911
|
if (process.getuid === void 0) {
|
|
11850
11912
|
throw new Error(`no POSIX user id on ${process.platform}`);
|
|
@@ -13787,7 +13849,7 @@ var init_package = __esm({
|
|
|
13787
13849
|
"package.json"() {
|
|
13788
13850
|
package_default = {
|
|
13789
13851
|
name: "claude-use",
|
|
13790
|
-
version: "14.0.
|
|
13852
|
+
version: "14.0.3",
|
|
13791
13853
|
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.",
|
|
13792
13854
|
license: "MIT",
|
|
13793
13855
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -15066,7 +15128,7 @@ function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS, workers =
|
|
|
15066
15128
|
}
|
|
15067
15129
|
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
15068
15130
|
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
15069
|
-
return workers.start(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END }, timeoutMs).verdict();
|
|
15131
|
+
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();
|
|
15070
15132
|
}
|
|
15071
15133
|
function startAddressProbes(targets, workers = realProbeWorkers, portBase) {
|
|
15072
15134
|
refuseToBlockInRole("a synchronous probe of a provider's address");
|
|
@@ -15091,7 +15153,7 @@ function startAddressProbes(targets, workers = realProbeWorkers, portBase) {
|
|
|
15091
15153
|
}
|
|
15092
15154
|
const portFirst = DOOR_SOURCE_PORT_START + (base + index * stride) % DOOR_SOURCE_PORT_COUNT;
|
|
15093
15155
|
try {
|
|
15094
|
-
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);
|
|
15156
|
+
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);
|
|
15095
15157
|
running.push({ key: targetKey(target), verdict: started.verdict, cancel: started.cancel });
|
|
15096
15158
|
} catch (error) {
|
|
15097
15159
|
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -15265,15 +15327,16 @@ request.end();
|
|
|
15265
15327
|
ACCEPT_PROBE_SOURCE = probeWorkerSource(`
|
|
15266
15328
|
const net = require("node:net");
|
|
15267
15329
|
const dns = require("node:dns");
|
|
15268
|
-
const { host, port, portStart, portEnd, portFirst, timeoutMs, ok, failed } = workerData;
|
|
15330
|
+
const { host, port, portStart, portEnd, portFirst, platform, timeoutMs, ok, failed } = workerData;
|
|
15269
15331
|
const finish = finishProbe;
|
|
15270
15332
|
const SourcePortRange = ${SourcePortRange.toString()};
|
|
15271
15333
|
const createDoorLookup = ${createDoorLookup.toString()};
|
|
15334
|
+
const sourcePortClassifier = ${sourcePortClassifier.toString()};
|
|
15272
15335
|
const doorDial = ${doorDial.toString()};
|
|
15273
15336
|
const probeAccept = ${probeAccept.toString()};
|
|
15274
15337
|
const runAcceptProbe = ${runAcceptProbe.toString()};
|
|
15275
15338
|
const startTimer = (callback, ms) => { const timer = setTimeout(callback, ms); return () => { clearTimeout(timer); }; };
|
|
15276
|
-
runAcceptProbe({ net, dns, createDoorLookup, doorDial, probeAccept, SourcePortRange }, { host, port, portStart, portEnd, portFirst, timeoutMs }, startTimer).then((verdict) => {
|
|
15339
|
+
runAcceptProbe({ net, dns, createDoorLookup, doorDial, probeAccept, SourcePortRange, sourcePortClassifier }, { host, port, portStart, portEnd, portFirst, platform, timeoutMs }, startTimer).then((verdict) => {
|
|
15277
15340
|
finish(verdict.ok ? ok : failed, verdict.ok ? "" : verdict.reason);
|
|
15278
15341
|
});
|
|
15279
15342
|
`);
|