claude-use 9.3.2 → 9.4.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.cjs +197 -168
- package/dist/index.cjs +6 -3
- package/dist/index.mjs +6 -3
- package/dist/types/index.d.ts +26 -0
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -20585,7 +20585,7 @@ var require_snippet = __commonJS({
|
|
|
20585
20585
|
"node_modules/.pnpm/js-yaml@4.3.2/node_modules/js-yaml/lib/snippet.js"(exports2, module2) {
|
|
20586
20586
|
"use strict";
|
|
20587
20587
|
var common = require_common();
|
|
20588
|
-
function getLine(
|
|
20588
|
+
function getLine(buffer2, lineStart, lineEnd, position, maxLineLength) {
|
|
20589
20589
|
let head = "";
|
|
20590
20590
|
let tail = "";
|
|
20591
20591
|
const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
@@ -20598,7 +20598,7 @@ var require_snippet = __commonJS({
|
|
|
20598
20598
|
lineEnd = position + maxHalfLength - tail.length;
|
|
20599
20599
|
}
|
|
20600
20600
|
return {
|
|
20601
|
-
str: head +
|
|
20601
|
+
str: head + buffer2.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
20602
20602
|
pos: position - lineStart + head.length
|
|
20603
20603
|
// relative position
|
|
20604
20604
|
};
|
|
@@ -23828,14 +23828,14 @@ var require_util = __commonJS({
|
|
|
23828
23828
|
}, source);
|
|
23829
23829
|
}
|
|
23830
23830
|
exports2.getPropertyByPath = getPropertyByPath;
|
|
23831
|
-
function decodeFileContent(
|
|
23832
|
-
if (
|
|
23833
|
-
return new TextDecoder("utf-16le").decode(
|
|
23831
|
+
function decodeFileContent(buffer2) {
|
|
23832
|
+
if (buffer2[0] === 255 && buffer2[1] === 254) {
|
|
23833
|
+
return new TextDecoder("utf-16le").decode(buffer2);
|
|
23834
23834
|
}
|
|
23835
|
-
if (
|
|
23836
|
-
return new TextDecoder("utf-16be").decode(
|
|
23835
|
+
if (buffer2[0] === 254 && buffer2[1] === 255) {
|
|
23836
|
+
return new TextDecoder("utf-16be").decode(buffer2);
|
|
23837
23837
|
}
|
|
23838
|
-
return
|
|
23838
|
+
return buffer2.toString("utf-8");
|
|
23839
23839
|
}
|
|
23840
23840
|
exports2.decodeFileContent = decodeFileContent;
|
|
23841
23841
|
function removeUndefinedValuesFromObject(options) {
|
|
@@ -33224,7 +33224,7 @@ var init_package = __esm({
|
|
|
33224
33224
|
"package.json"() {
|
|
33225
33225
|
package_default = {
|
|
33226
33226
|
name: "claude-use",
|
|
33227
|
-
version: "9.
|
|
33227
|
+
version: "9.4.1",
|
|
33228
33228
|
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.",
|
|
33229
33229
|
license: "MIT",
|
|
33230
33230
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -34082,7 +34082,7 @@ function assessIdentity(member, nowMs) {
|
|
|
34082
34082
|
const headroom = overage?.utilization === void 0 ? void 0 : Math.max(0, 1 - overage.utilization);
|
|
34083
34083
|
return { candidate: { ...base, class: "pay-per-use", ...headroom === void 0 ? {} : { headroom }, reasons: [...plan.kind === "pay-per-use" ? planReasons : ["no plan windows reported, so usage bills as extra usage"], ...overageReasons] } };
|
|
34084
34084
|
}
|
|
34085
|
-
const basis = seven?.utilization !== void 0 ? { window: seven, windowMs: SEVEN_DAY_WINDOW_MS } : five?.utilization !== void 0 ? { window: five, windowMs: FIVE_HOUR_WINDOW_MS } : void 0;
|
|
34085
|
+
const basis = seven?.utilization !== void 0 ? { window: seven, windowMs: SEVEN_DAY_WINDOW_MS, name: "sevenDay" } : five?.utilization !== void 0 ? { window: five, windowMs: FIVE_HOUR_WINDOW_MS, name: "fiveHour" } : void 0;
|
|
34086
34086
|
if (basis?.window.utilization === void 0) {
|
|
34087
34087
|
return { candidate: { ...base, class: "unknown", reasons: ["quota windows reported no utilisation", ...windowReasons, ...planReasons] } };
|
|
34088
34088
|
}
|
|
@@ -34096,7 +34096,7 @@ function assessIdentity(member, nowMs) {
|
|
|
34096
34096
|
const sevenUntil = seven?.resetsAtMs === void 0 ? SEVEN_DAY_WINDOW_MS : Math.max(seven.resetsAtMs - nowMs, MS_PER_SECOND3);
|
|
34097
34097
|
const sevenDayBurn = windowBurn(member.records, "sevenDay");
|
|
34098
34098
|
return {
|
|
34099
|
-
candidate: { ...base, class: "scored", score, reasons: [...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
|
|
34099
|
+
candidate: { ...base, class: "scored", score, scoreWindow: basis.name, reasons: [...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
|
|
34100
34100
|
...fiveRemaining === void 0 ? {} : { fiveHour: { remaining: fiveRemaining, untilResetMs: fiveUntil } },
|
|
34101
34101
|
...burn === void 0 ? {} : { burn },
|
|
34102
34102
|
...sevenRemaining === void 0 ? {} : { sevenDay: { remaining: sevenRemaining, untilResetMs: sevenUntil } },
|
|
@@ -35947,11 +35947,11 @@ var require_constants2 = __commonJS({
|
|
|
35947
35947
|
var wellknownHeaderNameBuffers = {};
|
|
35948
35948
|
Object.setPrototypeOf(wellknownHeaderNameBuffers, null);
|
|
35949
35949
|
function getHeaderNameAsBuffer(header) {
|
|
35950
|
-
let
|
|
35951
|
-
if (
|
|
35952
|
-
|
|
35950
|
+
let buffer2 = wellknownHeaderNameBuffers[header];
|
|
35951
|
+
if (buffer2 === void 0) {
|
|
35952
|
+
buffer2 = Buffer.from(header);
|
|
35953
35953
|
}
|
|
35954
|
-
return
|
|
35954
|
+
return buffer2;
|
|
35955
35955
|
}
|
|
35956
35956
|
for (let i10 = 0; i10 < wellknownHeaderNames.length; ++i10) {
|
|
35957
35957
|
const key = wellknownHeaderNames[i10];
|
|
@@ -36382,8 +36382,8 @@ var require_util2 = __commonJS({
|
|
|
36382
36382
|
}
|
|
36383
36383
|
return headers.map((x) => Buffer.from(x));
|
|
36384
36384
|
}
|
|
36385
|
-
function isBuffer(
|
|
36386
|
-
return
|
|
36385
|
+
function isBuffer(buffer2) {
|
|
36386
|
+
return buffer2 instanceof Uint8Array || Buffer.isBuffer(buffer2);
|
|
36387
36387
|
}
|
|
36388
36388
|
function assertRequestHandler(handler, method, upgrade) {
|
|
36389
36389
|
if (!handler || typeof handler !== "object") {
|
|
@@ -38984,14 +38984,14 @@ var require_encoding = __commonJS({
|
|
|
38984
38984
|
"node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/encoding/index.js"(exports2, module2) {
|
|
38985
38985
|
"use strict";
|
|
38986
38986
|
var textDecoder = new TextDecoder();
|
|
38987
|
-
function utf8DecodeBytes(
|
|
38988
|
-
if (
|
|
38987
|
+
function utf8DecodeBytes(buffer2) {
|
|
38988
|
+
if (buffer2.length === 0) {
|
|
38989
38989
|
return "";
|
|
38990
38990
|
}
|
|
38991
|
-
if (
|
|
38992
|
-
|
|
38991
|
+
if (buffer2[0] === 239 && buffer2[1] === 187 && buffer2[2] === 191) {
|
|
38992
|
+
buffer2 = buffer2.subarray(3);
|
|
38993
38993
|
}
|
|
38994
|
-
const output2 = textDecoder.decode(
|
|
38994
|
+
const output2 = textDecoder.decode(buffer2);
|
|
38995
38995
|
return output2;
|
|
38996
38996
|
}
|
|
38997
38997
|
module2.exports = {
|
|
@@ -39042,8 +39042,8 @@ var require_infra = __commonJS({
|
|
|
39042
39042
|
if (/[^+/0-9A-Za-z]/.test(data.length === dataLength ? data : data.substring(0, dataLength))) {
|
|
39043
39043
|
return "failure";
|
|
39044
39044
|
}
|
|
39045
|
-
const
|
|
39046
|
-
return new Uint8Array(
|
|
39045
|
+
const buffer2 = Buffer.from(data, "base64");
|
|
39046
|
+
return new Uint8Array(buffer2.buffer, buffer2.byteOffset, buffer2.byteLength);
|
|
39047
39047
|
}
|
|
39048
39048
|
function isASCIIWhitespace(char) {
|
|
39049
39049
|
return char === 9 || // \t
|
|
@@ -41309,12 +41309,12 @@ var require_formdata_parser = __commonJS({
|
|
|
41309
41309
|
}
|
|
41310
41310
|
return lead === 0 && trail === buf.length - 1 ? buf : buf.subarray(lead, trail + 1);
|
|
41311
41311
|
}
|
|
41312
|
-
function bufferStartsWith(
|
|
41313
|
-
if (
|
|
41312
|
+
function bufferStartsWith(buffer2, start, position) {
|
|
41313
|
+
if (buffer2.length < start.length) {
|
|
41314
41314
|
return false;
|
|
41315
41315
|
}
|
|
41316
41316
|
for (let i10 = 0; i10 < start.length; i10++) {
|
|
41317
|
-
if (start[i10] !==
|
|
41317
|
+
if (start[i10] !== buffer2[position.position + i10]) {
|
|
41318
41318
|
return false;
|
|
41319
41319
|
}
|
|
41320
41320
|
}
|
|
@@ -42739,14 +42739,14 @@ upgrade: ${upgrade}\r
|
|
|
42739
42739
|
if (contentLength != null && contentLength !== body.size) {
|
|
42740
42740
|
throw new RequestContentLengthMismatchError();
|
|
42741
42741
|
}
|
|
42742
|
-
const
|
|
42742
|
+
const buffer2 = Buffer.from(await body.arrayBuffer());
|
|
42743
42743
|
socket.cork();
|
|
42744
42744
|
socket.write(`${header}content-length: ${contentLength}\r
|
|
42745
42745
|
\r
|
|
42746
42746
|
`, "latin1");
|
|
42747
|
-
socket.write(
|
|
42747
|
+
socket.write(buffer2);
|
|
42748
42748
|
socket.uncork();
|
|
42749
|
-
request7.onBodySent(
|
|
42749
|
+
request7.onBodySent(buffer2);
|
|
42750
42750
|
request7.onRequestSent();
|
|
42751
42751
|
if (!expectsPayload && request7.reset !== false) {
|
|
42752
42752
|
socket[kReset] = true;
|
|
@@ -43622,12 +43622,12 @@ var require_client_h2 = __commonJS({
|
|
|
43622
43622
|
if (contentLength != null && contentLength !== body.size) {
|
|
43623
43623
|
throw new RequestContentLengthMismatchError();
|
|
43624
43624
|
}
|
|
43625
|
-
const
|
|
43625
|
+
const buffer2 = Buffer.from(await body.arrayBuffer());
|
|
43626
43626
|
h2stream.cork();
|
|
43627
|
-
h2stream.write(
|
|
43627
|
+
h2stream.write(buffer2);
|
|
43628
43628
|
h2stream.uncork();
|
|
43629
43629
|
h2stream.end();
|
|
43630
|
-
request7.onBodySent(
|
|
43630
|
+
request7.onBodySent(buffer2);
|
|
43631
43631
|
request7.onRequestSent();
|
|
43632
43632
|
if (!expectsPayload) {
|
|
43633
43633
|
socket[kReset] = true;
|
|
@@ -44997,7 +44997,7 @@ var require_socks5_utils = __commonJS({
|
|
|
44997
44997
|
};
|
|
44998
44998
|
}
|
|
44999
44999
|
function parseIPv6(address) {
|
|
45000
|
-
const
|
|
45000
|
+
const buffer2 = Buffer3.alloc(16);
|
|
45001
45001
|
let normalizedAddress = address;
|
|
45002
45002
|
if (address.includes(".")) {
|
|
45003
45003
|
const lastColonIndex = address.lastIndexOf(":");
|
|
@@ -45017,21 +45017,21 @@ var require_socks5_utils = __commonJS({
|
|
|
45017
45017
|
const afterParts = after === "" ? [] : after.split(":");
|
|
45018
45018
|
let bufferIndex = 0;
|
|
45019
45019
|
for (const part of beforeParts) {
|
|
45020
|
-
|
|
45020
|
+
buffer2.writeUInt16BE(parseInt(part, 16), bufferIndex);
|
|
45021
45021
|
bufferIndex += 2;
|
|
45022
45022
|
}
|
|
45023
45023
|
bufferIndex = 16 - afterParts.length * 2;
|
|
45024
45024
|
for (const part of afterParts) {
|
|
45025
|
-
|
|
45025
|
+
buffer2.writeUInt16BE(parseInt(part, 16), bufferIndex);
|
|
45026
45026
|
bufferIndex += 2;
|
|
45027
45027
|
}
|
|
45028
45028
|
} else {
|
|
45029
45029
|
const parts = normalizedAddress.split(":");
|
|
45030
45030
|
for (let i10 = 0; i10 < parts.length; i10++) {
|
|
45031
|
-
|
|
45031
|
+
buffer2.writeUInt16BE(parseInt(parts[i10], 16), i10 * 2);
|
|
45032
45032
|
}
|
|
45033
45033
|
}
|
|
45034
|
-
return
|
|
45034
|
+
return buffer2;
|
|
45035
45035
|
}
|
|
45036
45036
|
function buildAddressBuffer(type2, addressBuffer, port) {
|
|
45037
45037
|
const portBuffer = Buffer3.allocUnsafe(2);
|
|
@@ -45042,42 +45042,42 @@ var require_socks5_utils = __commonJS({
|
|
|
45042
45042
|
portBuffer
|
|
45043
45043
|
]);
|
|
45044
45044
|
}
|
|
45045
|
-
function parseResponseAddress(
|
|
45046
|
-
if (
|
|
45045
|
+
function parseResponseAddress(buffer2, offset = 0) {
|
|
45046
|
+
if (buffer2.length < offset + 1) {
|
|
45047
45047
|
throw new InvalidArgumentError2("Buffer too small to contain address type");
|
|
45048
45048
|
}
|
|
45049
|
-
const addressType =
|
|
45049
|
+
const addressType = buffer2[offset];
|
|
45050
45050
|
let address;
|
|
45051
45051
|
let currentOffset = offset + 1;
|
|
45052
45052
|
switch (addressType) {
|
|
45053
45053
|
case 1: {
|
|
45054
|
-
if (
|
|
45054
|
+
if (buffer2.length < currentOffset + 6) {
|
|
45055
45055
|
throw new InvalidArgumentError2("Buffer too small for IPv4 address");
|
|
45056
45056
|
}
|
|
45057
|
-
address = Array.from(
|
|
45057
|
+
address = Array.from(buffer2.subarray(currentOffset, currentOffset + 4)).join(".");
|
|
45058
45058
|
currentOffset += 4;
|
|
45059
45059
|
break;
|
|
45060
45060
|
}
|
|
45061
45061
|
case 3: {
|
|
45062
|
-
if (
|
|
45062
|
+
if (buffer2.length < currentOffset + 1) {
|
|
45063
45063
|
throw new InvalidArgumentError2("Buffer too small for domain length");
|
|
45064
45064
|
}
|
|
45065
|
-
const domainLength =
|
|
45065
|
+
const domainLength = buffer2[currentOffset];
|
|
45066
45066
|
currentOffset += 1;
|
|
45067
|
-
if (
|
|
45067
|
+
if (buffer2.length < currentOffset + domainLength + 2) {
|
|
45068
45068
|
throw new InvalidArgumentError2("Buffer too small for domain address");
|
|
45069
45069
|
}
|
|
45070
|
-
address =
|
|
45070
|
+
address = buffer2.subarray(currentOffset, currentOffset + domainLength).toString("utf8");
|
|
45071
45071
|
currentOffset += domainLength;
|
|
45072
45072
|
break;
|
|
45073
45073
|
}
|
|
45074
45074
|
case 4: {
|
|
45075
|
-
if (
|
|
45075
|
+
if (buffer2.length < currentOffset + 18) {
|
|
45076
45076
|
throw new InvalidArgumentError2("Buffer too small for IPv6 address");
|
|
45077
45077
|
}
|
|
45078
45078
|
const parts = [];
|
|
45079
45079
|
for (let i10 = 0; i10 < 8; i10++) {
|
|
45080
|
-
const value2 =
|
|
45080
|
+
const value2 = buffer2.readUInt16BE(currentOffset + i10 * 2);
|
|
45081
45081
|
parts.push(value2.toString(16));
|
|
45082
45082
|
}
|
|
45083
45083
|
address = parts.join(":");
|
|
@@ -45087,10 +45087,10 @@ var require_socks5_utils = __commonJS({
|
|
|
45087
45087
|
default:
|
|
45088
45088
|
throw new InvalidArgumentError2(`Invalid address type: ${addressType}`);
|
|
45089
45089
|
}
|
|
45090
|
-
if (
|
|
45090
|
+
if (buffer2.length < currentOffset + 2) {
|
|
45091
45091
|
throw new InvalidArgumentError2("Buffer too small for port");
|
|
45092
45092
|
}
|
|
45093
|
-
const port =
|
|
45093
|
+
const port = buffer2.readUInt16BE(currentOffset);
|
|
45094
45094
|
currentOffset += 2;
|
|
45095
45095
|
return {
|
|
45096
45096
|
address,
|
|
@@ -46803,13 +46803,13 @@ var require_readable = __commonJS({
|
|
|
46803
46803
|
if (chunks.length === 0 || length === 0) {
|
|
46804
46804
|
return "";
|
|
46805
46805
|
}
|
|
46806
|
-
const
|
|
46807
|
-
const bufferLength =
|
|
46808
|
-
const start = bufferLength > 2 &&
|
|
46806
|
+
const buffer2 = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks, length);
|
|
46807
|
+
const bufferLength = buffer2.length;
|
|
46808
|
+
const start = bufferLength > 2 && buffer2[0] === 239 && buffer2[1] === 187 && buffer2[2] === 191 ? 3 : 0;
|
|
46809
46809
|
if (!encoding || encoding === "utf8" || encoding === "utf-8") {
|
|
46810
|
-
return
|
|
46810
|
+
return buffer2.utf8Slice(start, bufferLength);
|
|
46811
46811
|
} else {
|
|
46812
|
-
return
|
|
46812
|
+
return buffer2.subarray(start, bufferLength).toString(encoding);
|
|
46813
46813
|
}
|
|
46814
46814
|
}
|
|
46815
46815
|
function chunksConcat(chunks, length) {
|
|
@@ -46819,14 +46819,14 @@ var require_readable = __commonJS({
|
|
|
46819
46819
|
if (chunks.length === 1) {
|
|
46820
46820
|
return new Uint8Array(chunks[0]);
|
|
46821
46821
|
}
|
|
46822
|
-
const
|
|
46822
|
+
const buffer2 = new Uint8Array(Buffer.allocUnsafeSlow(length).buffer);
|
|
46823
46823
|
let offset = 0;
|
|
46824
46824
|
for (let i10 = 0; i10 < chunks.length; ++i10) {
|
|
46825
46825
|
const chunk = chunks[i10];
|
|
46826
|
-
|
|
46826
|
+
buffer2.set(chunk, offset);
|
|
46827
46827
|
offset += chunk.length;
|
|
46828
46828
|
}
|
|
46829
|
-
return
|
|
46829
|
+
return buffer2;
|
|
46830
46830
|
}
|
|
46831
46831
|
function consumeEnd(consume2, encoding) {
|
|
46832
46832
|
const { type: type2, body, resolve: resolve2, stream, length } = consume2;
|
|
@@ -56525,9 +56525,9 @@ var require_fetch = __commonJS({
|
|
|
56525
56525
|
fetchParams.controller.terminate(bytes);
|
|
56526
56526
|
return;
|
|
56527
56527
|
}
|
|
56528
|
-
const
|
|
56529
|
-
if (
|
|
56530
|
-
fetchParams.controller.controller.enqueue(
|
|
56528
|
+
const buffer2 = new Uint8Array(bytes);
|
|
56529
|
+
if (buffer2.byteLength) {
|
|
56530
|
+
fetchParams.controller.controller.enqueue(buffer2);
|
|
56531
56531
|
}
|
|
56532
56532
|
if (isErrored(stream)) {
|
|
56533
56533
|
fetchParams.controller.terminate();
|
|
@@ -58279,11 +58279,11 @@ var require_util6 = __commonJS({
|
|
|
58279
58279
|
function websocketMessageReceived(handler, type2, data) {
|
|
58280
58280
|
handler.onMessage(type2, data);
|
|
58281
58281
|
}
|
|
58282
|
-
function toArrayBuffer(
|
|
58283
|
-
if (
|
|
58284
|
-
return
|
|
58282
|
+
function toArrayBuffer(buffer2) {
|
|
58283
|
+
if (buffer2.byteLength === buffer2.buffer.byteLength) {
|
|
58284
|
+
return buffer2.buffer;
|
|
58285
58285
|
}
|
|
58286
|
-
return new Uint8Array(
|
|
58286
|
+
return new Uint8Array(buffer2).buffer;
|
|
58287
58287
|
}
|
|
58288
58288
|
function isValidSubprotocol(protocol) {
|
|
58289
58289
|
if (protocol.length === 0) {
|
|
@@ -58399,9 +58399,9 @@ var require_util6 = __commonJS({
|
|
|
58399
58399
|
const fatalDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
58400
58400
|
return fatalDecoder.decode.bind(fatalDecoder);
|
|
58401
58401
|
}
|
|
58402
|
-
return function(
|
|
58403
|
-
if (isUtf8(
|
|
58404
|
-
return
|
|
58402
|
+
return function(buffer2) {
|
|
58403
|
+
if (isUtf8(buffer2)) {
|
|
58404
|
+
return buffer2.toString("utf-8");
|
|
58405
58405
|
}
|
|
58406
58406
|
throw new TypeError("Invalid utf-8 received.");
|
|
58407
58407
|
};
|
|
@@ -58436,20 +58436,20 @@ var require_frame = __commonJS({
|
|
|
58436
58436
|
var { runtimeFeatures } = require_runtime_features();
|
|
58437
58437
|
var { maxUnsigned16Bit, opcodes } = require_constants6();
|
|
58438
58438
|
var BUFFER_SIZE = 8 * 1024;
|
|
58439
|
-
var
|
|
58439
|
+
var buffer2 = null;
|
|
58440
58440
|
var bufIdx = BUFFER_SIZE;
|
|
58441
|
-
var randomFillSync = runtimeFeatures.has("crypto") ? require("node:crypto").randomFillSync : function randomFillSync2(
|
|
58442
|
-
for (let i10 = 0; i10 <
|
|
58443
|
-
|
|
58441
|
+
var randomFillSync = runtimeFeatures.has("crypto") ? require("node:crypto").randomFillSync : function randomFillSync2(buffer3, _offset, _size2) {
|
|
58442
|
+
for (let i10 = 0; i10 < buffer3.length; ++i10) {
|
|
58443
|
+
buffer3[i10] = Math.random() * 255 | 0;
|
|
58444
58444
|
}
|
|
58445
|
-
return
|
|
58445
|
+
return buffer3;
|
|
58446
58446
|
};
|
|
58447
58447
|
function generateMask() {
|
|
58448
58448
|
if (bufIdx === BUFFER_SIZE) {
|
|
58449
58449
|
bufIdx = 0;
|
|
58450
|
-
randomFillSync(
|
|
58450
|
+
randomFillSync(buffer2 ??= Buffer.allocUnsafeSlow(BUFFER_SIZE), 0, BUFFER_SIZE);
|
|
58451
58451
|
}
|
|
58452
|
-
return [
|
|
58452
|
+
return [buffer2[bufIdx++], buffer2[bufIdx++], buffer2[bufIdx++], buffer2[bufIdx++]];
|
|
58453
58453
|
}
|
|
58454
58454
|
var WebsocketFrameSend = class {
|
|
58455
58455
|
/**
|
|
@@ -58471,35 +58471,35 @@ var require_frame = __commonJS({
|
|
|
58471
58471
|
offset += 2;
|
|
58472
58472
|
payloadLength = 126;
|
|
58473
58473
|
}
|
|
58474
|
-
const
|
|
58475
|
-
|
|
58476
|
-
|
|
58477
|
-
|
|
58478
|
-
|
|
58479
|
-
|
|
58480
|
-
|
|
58481
|
-
|
|
58482
|
-
|
|
58474
|
+
const buffer3 = Buffer.allocUnsafe(bodyLength + offset);
|
|
58475
|
+
buffer3[0] = buffer3[1] = 0;
|
|
58476
|
+
buffer3[0] |= 128;
|
|
58477
|
+
buffer3[0] = (buffer3[0] & 240) + opcode;
|
|
58478
|
+
buffer3[offset - 4] = maskKey[0];
|
|
58479
|
+
buffer3[offset - 3] = maskKey[1];
|
|
58480
|
+
buffer3[offset - 2] = maskKey[2];
|
|
58481
|
+
buffer3[offset - 1] = maskKey[3];
|
|
58482
|
+
buffer3[1] = payloadLength;
|
|
58483
58483
|
if (payloadLength === 126) {
|
|
58484
|
-
|
|
58484
|
+
buffer3.writeUInt16BE(bodyLength, 2);
|
|
58485
58485
|
} else if (payloadLength === 127) {
|
|
58486
|
-
|
|
58487
|
-
|
|
58486
|
+
buffer3[2] = buffer3[3] = 0;
|
|
58487
|
+
buffer3.writeUIntBE(bodyLength, 4, 6);
|
|
58488
58488
|
}
|
|
58489
|
-
|
|
58489
|
+
buffer3[1] |= 128;
|
|
58490
58490
|
for (let i10 = 0; i10 < bodyLength; ++i10) {
|
|
58491
|
-
|
|
58491
|
+
buffer3[offset + i10] = frameData[i10] ^ maskKey[i10 & 3];
|
|
58492
58492
|
}
|
|
58493
|
-
return
|
|
58493
|
+
return buffer3;
|
|
58494
58494
|
}
|
|
58495
58495
|
/**
|
|
58496
58496
|
* @param {Uint8Array} buffer
|
|
58497
58497
|
*/
|
|
58498
|
-
static createFastTextFrame(
|
|
58498
|
+
static createFastTextFrame(buffer3) {
|
|
58499
58499
|
const maskKey = generateMask();
|
|
58500
|
-
const bodyLength =
|
|
58500
|
+
const bodyLength = buffer3.length;
|
|
58501
58501
|
for (let i10 = 0; i10 < bodyLength; ++i10) {
|
|
58502
|
-
|
|
58502
|
+
buffer3[i10] ^= maskKey[i10 & 3];
|
|
58503
58503
|
}
|
|
58504
58504
|
let payloadLength = bodyLength;
|
|
58505
58505
|
let offset = 6;
|
|
@@ -58523,7 +58523,7 @@ var require_frame = __commonJS({
|
|
|
58523
58523
|
head[2] = head[3] = 0;
|
|
58524
58524
|
head.writeUIntBE(bodyLength, 4, 6);
|
|
58525
58525
|
}
|
|
58526
|
-
return [head,
|
|
58526
|
+
return [head, buffer3];
|
|
58527
58527
|
}
|
|
58528
58528
|
};
|
|
58529
58529
|
module2.exports = {
|
|
@@ -58851,15 +58851,15 @@ var require_receiver = __commonJS({
|
|
|
58851
58851
|
if (this.#byteOffset < 2) {
|
|
58852
58852
|
return callback();
|
|
58853
58853
|
}
|
|
58854
|
-
const
|
|
58855
|
-
const fin = (
|
|
58856
|
-
const opcode =
|
|
58857
|
-
const masked = (
|
|
58854
|
+
const buffer2 = this.consume(2);
|
|
58855
|
+
const fin = (buffer2[0] & 128) !== 0;
|
|
58856
|
+
const opcode = buffer2[0] & 15;
|
|
58857
|
+
const masked = (buffer2[1] & 128) === 128;
|
|
58858
58858
|
const fragmented = !fin && opcode !== opcodes.CONTINUATION;
|
|
58859
|
-
const payloadLength =
|
|
58860
|
-
const rsv1 =
|
|
58861
|
-
const rsv2 =
|
|
58862
|
-
const rsv3 =
|
|
58859
|
+
const payloadLength = buffer2[1] & 127;
|
|
58860
|
+
const rsv1 = buffer2[0] & 64;
|
|
58861
|
+
const rsv2 = buffer2[0] & 32;
|
|
58862
|
+
const rsv3 = buffer2[0] & 16;
|
|
58863
58863
|
if (!isValidOpcode(opcode)) {
|
|
58864
58864
|
failWebsocketConnection(this.#handler, 1002, "Invalid opcode received");
|
|
58865
58865
|
return callback();
|
|
@@ -58919,8 +58919,8 @@ var require_receiver = __commonJS({
|
|
|
58919
58919
|
if (this.#byteOffset < 2) {
|
|
58920
58920
|
return callback();
|
|
58921
58921
|
}
|
|
58922
|
-
const
|
|
58923
|
-
this.#info.payloadLength =
|
|
58922
|
+
const buffer2 = this.consume(2);
|
|
58923
|
+
this.#info.payloadLength = buffer2.readUInt16BE(0);
|
|
58924
58924
|
this.#state = parserStates.READ_DATA;
|
|
58925
58925
|
if (!this.#validatePayloadLength()) {
|
|
58926
58926
|
return;
|
|
@@ -58929,9 +58929,9 @@ var require_receiver = __commonJS({
|
|
|
58929
58929
|
if (this.#byteOffset < 8) {
|
|
58930
58930
|
return callback();
|
|
58931
58931
|
}
|
|
58932
|
-
const
|
|
58933
|
-
const upper =
|
|
58934
|
-
const lower =
|
|
58932
|
+
const buffer2 = this.consume(8);
|
|
58933
|
+
const upper = buffer2.readUInt32BE(0);
|
|
58934
|
+
const lower = buffer2.readUInt32BE(4);
|
|
58935
58935
|
if (upper !== 0 || lower > 2 ** 31 - 1) {
|
|
58936
58936
|
failWebsocketConnection(this.#handler, 1009, "Received payload length > 2^31 bytes.");
|
|
58937
58937
|
return;
|
|
@@ -59015,23 +59015,23 @@ var require_receiver = __commonJS({
|
|
|
59015
59015
|
return this.#buffers.shift();
|
|
59016
59016
|
} else {
|
|
59017
59017
|
let offset = 0;
|
|
59018
|
-
const
|
|
59018
|
+
const buffer2 = Buffer.allocUnsafeSlow(n10);
|
|
59019
59019
|
while (offset !== n10) {
|
|
59020
59020
|
const next = this.#buffers[0];
|
|
59021
59021
|
const length = next.length;
|
|
59022
59022
|
if (length + offset === n10) {
|
|
59023
|
-
|
|
59023
|
+
buffer2.set(this.#buffers.shift(), offset);
|
|
59024
59024
|
break;
|
|
59025
59025
|
} else if (length + offset > n10) {
|
|
59026
|
-
|
|
59026
|
+
buffer2.set(next.subarray(0, n10 - offset), offset);
|
|
59027
59027
|
this.#buffers[0] = next.subarray(n10 - offset);
|
|
59028
59028
|
break;
|
|
59029
59029
|
} else {
|
|
59030
|
-
|
|
59030
|
+
buffer2.set(this.#buffers.shift(), offset);
|
|
59031
59031
|
offset += length;
|
|
59032
59032
|
}
|
|
59033
59033
|
}
|
|
59034
|
-
return
|
|
59034
|
+
return buffer2;
|
|
59035
59035
|
}
|
|
59036
59036
|
}
|
|
59037
59037
|
writeFragments(fragment) {
|
|
@@ -59052,9 +59052,9 @@ var require_receiver = __commonJS({
|
|
|
59052
59052
|
let offset = 0;
|
|
59053
59053
|
const output2 = Buffer.allocUnsafeSlow(this.#fragmentsBytes);
|
|
59054
59054
|
for (let i10 = 0; i10 < fragments.length; ++i10) {
|
|
59055
|
-
const
|
|
59056
|
-
output2.set(
|
|
59057
|
-
offset +=
|
|
59055
|
+
const buffer2 = fragments[i10];
|
|
59056
|
+
output2.set(buffer2, offset);
|
|
59057
|
+
offset += buffer2.length;
|
|
59058
59058
|
}
|
|
59059
59059
|
this.#fragments = [];
|
|
59060
59060
|
this.#fragmentsBytes = 0;
|
|
@@ -59381,10 +59381,10 @@ var require_websocket = __commonJS({
|
|
|
59381
59381
|
return;
|
|
59382
59382
|
}
|
|
59383
59383
|
if (typeof data === "string") {
|
|
59384
|
-
const
|
|
59385
|
-
this.#bufferedAmount +=
|
|
59386
|
-
this.#sendQueue.add(
|
|
59387
|
-
this.#bufferedAmount -=
|
|
59384
|
+
const buffer2 = Buffer.from(data);
|
|
59385
|
+
this.#bufferedAmount += buffer2.byteLength;
|
|
59386
|
+
this.#sendQueue.add(buffer2, () => {
|
|
59387
|
+
this.#bufferedAmount -= buffer2.byteLength;
|
|
59388
59388
|
}, sendHints.text);
|
|
59389
59389
|
} else if (isArrayBuffer(data)) {
|
|
59390
59390
|
this.#bufferedAmount += data.byteLength;
|
|
@@ -59608,17 +59608,17 @@ var require_websocket = __commonJS({
|
|
|
59608
59608
|
* @param {WebSocket} ws
|
|
59609
59609
|
* @param {Buffer|undefined} buffer
|
|
59610
59610
|
*/
|
|
59611
|
-
static ping(ws,
|
|
59612
|
-
if (Buffer.isBuffer(
|
|
59613
|
-
if (
|
|
59611
|
+
static ping(ws, buffer2) {
|
|
59612
|
+
if (Buffer.isBuffer(buffer2)) {
|
|
59613
|
+
if (buffer2.length > 125) {
|
|
59614
59614
|
throw new TypeError("A PING frame cannot have a body larger than 125 bytes.");
|
|
59615
59615
|
}
|
|
59616
|
-
} else if (
|
|
59616
|
+
} else if (buffer2 !== void 0) {
|
|
59617
59617
|
throw new TypeError("Expected buffer payload");
|
|
59618
59618
|
}
|
|
59619
59619
|
const readyState = ws.#handler.readyState;
|
|
59620
59620
|
if (isEstablished(readyState) && !isClosing(readyState) && !isClosed(readyState)) {
|
|
59621
|
-
const frame = new WebsocketFrameSend(
|
|
59621
|
+
const frame = new WebsocketFrameSend(buffer2);
|
|
59622
59622
|
ws.#handler.socket.write(frame.createFrame(opcodes.PING));
|
|
59623
59623
|
}
|
|
59624
59624
|
}
|
|
@@ -60135,20 +60135,20 @@ var require_eventsource_stream = __commonJS({
|
|
|
60135
60135
|
var EVENT = Buffer.from("event");
|
|
60136
60136
|
var ID2 = Buffer.from("id");
|
|
60137
60137
|
var RETRY = Buffer.from("retry");
|
|
60138
|
-
function isASCIINumberBytes(
|
|
60139
|
-
if (start >=
|
|
60138
|
+
function isASCIINumberBytes(buffer2, start) {
|
|
60139
|
+
if (start >= buffer2.length) {
|
|
60140
60140
|
return false;
|
|
60141
60141
|
}
|
|
60142
|
-
for (let i10 = start; i10 <
|
|
60143
|
-
if (
|
|
60142
|
+
for (let i10 = start; i10 < buffer2.length; i10++) {
|
|
60143
|
+
if (buffer2[i10] < 48 || buffer2[i10] > 57) {
|
|
60144
60144
|
return false;
|
|
60145
60145
|
}
|
|
60146
60146
|
}
|
|
60147
60147
|
return true;
|
|
60148
60148
|
}
|
|
60149
|
-
function isValidLastEventIdBytes(
|
|
60150
|
-
for (let i10 = start; i10 <
|
|
60151
|
-
if (
|
|
60149
|
+
function isValidLastEventIdBytes(buffer2, start) {
|
|
60150
|
+
for (let i10 = start; i10 < buffer2.length; i10++) {
|
|
60151
|
+
if (buffer2[i10] === 0) {
|
|
60152
60152
|
return false;
|
|
60153
60153
|
}
|
|
60154
60154
|
}
|
|
@@ -102668,6 +102668,7 @@ function candidateView(candidate) {
|
|
|
102668
102668
|
identity: candidate.identity,
|
|
102669
102669
|
class: candidate.class,
|
|
102670
102670
|
...candidate.score === void 0 ? {} : { score: candidate.score },
|
|
102671
|
+
...candidate.scoreWindow === void 0 ? {} : { scoreWindow: candidate.scoreWindow },
|
|
102671
102672
|
feasible: candidate.feasible,
|
|
102672
102673
|
...candidate.blockedUntilMs === void 0 ? {} : { blockedUntil: new Date(candidate.blockedUntilMs).toISOString() },
|
|
102673
102674
|
plan: candidate.plan,
|
|
@@ -104431,9 +104432,9 @@ function ipBytes(address) {
|
|
|
104431
104432
|
function keyIdentifier(publicKey) {
|
|
104432
104433
|
return (0, import_node_crypto16.createHash)("sha1").update(publicKey.export({ type: "pkcs1", format: "der" })).digest();
|
|
104433
104434
|
}
|
|
104434
|
-
function readElement(
|
|
104435
|
-
const tag =
|
|
104436
|
-
const first =
|
|
104435
|
+
function readElement(buffer2, offset) {
|
|
104436
|
+
const tag = buffer2[offset];
|
|
104437
|
+
const first = buffer2[offset + 1];
|
|
104437
104438
|
if (tag === void 0 || first === void 0) {
|
|
104438
104439
|
throw new Error("truncated DER");
|
|
104439
104440
|
}
|
|
@@ -104443,7 +104444,7 @@ function readElement(buffer, offset) {
|
|
|
104443
104444
|
const count = first & BASE_128_PAYLOAD_MASK;
|
|
104444
104445
|
length = 0;
|
|
104445
104446
|
for (let index = 0; index < count; index += 1) {
|
|
104446
|
-
length = length * (BYTE_MASK + 1) + (
|
|
104447
|
+
length = length * (BYTE_MASK + 1) + (buffer2[offset + 2 + index] ?? 0);
|
|
104447
104448
|
}
|
|
104448
104449
|
contentStart = offset + 2 + count;
|
|
104449
104450
|
}
|
|
@@ -104999,11 +105000,11 @@ function handleConnect(socket, context) {
|
|
|
104999
105000
|
socket.destroy();
|
|
105000
105001
|
});
|
|
105001
105002
|
context.ledger.accept(socket);
|
|
105002
|
-
let
|
|
105003
|
+
let buffer2 = Buffer.alloc(0);
|
|
105003
105004
|
const onData = (chunk) => {
|
|
105004
|
-
|
|
105005
|
-
const headEnd =
|
|
105006
|
-
if (headEnd === -1 ?
|
|
105005
|
+
buffer2 = Buffer.concat([buffer2, chunk]);
|
|
105006
|
+
const headEnd = buffer2.indexOf(HEAD_TERMINATOR);
|
|
105007
|
+
if (headEnd === -1 ? buffer2.length > MAX_CONNECT_HEAD_BYTES : headEnd > MAX_CONNECT_HEAD_BYTES) {
|
|
105007
105008
|
context.ledger.headReceived(socket);
|
|
105008
105009
|
refuse(socket, REFUSAL.headTooLarge);
|
|
105009
105010
|
return;
|
|
@@ -105014,8 +105015,8 @@ function handleConnect(socket, context) {
|
|
|
105014
105015
|
socket.removeListener("data", onData);
|
|
105015
105016
|
socket.pause();
|
|
105016
105017
|
context.ledger.headReceived(socket);
|
|
105017
|
-
const head =
|
|
105018
|
-
socket.unshift(
|
|
105018
|
+
const head = buffer2.subarray(0, headEnd).toString("utf8");
|
|
105019
|
+
socket.unshift(buffer2.subarray(headEnd + HEAD_TERMINATOR.length));
|
|
105019
105020
|
routeConnect(socket, head, context);
|
|
105020
105021
|
};
|
|
105021
105022
|
socket.on("data", onData);
|
|
@@ -108609,6 +108610,8 @@ var PoolPickCandidateViewSchema = external_exports.strictObject({
|
|
|
108609
108610
|
class: external_exports.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
108610
108611
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
108611
108612
|
score: external_exports.number().optional(),
|
|
108613
|
+
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation; present with `score`. */
|
|
108614
|
+
scoreWindow: external_exports.enum(["sevenDay", "fiveHour"]).optional(),
|
|
108612
108615
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
108613
108616
|
feasible: external_exports.boolean(),
|
|
108614
108617
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
@@ -113312,6 +113315,7 @@ function createLaunchEventPublisher(hub, now) {
|
|
|
113312
113315
|
|
|
113313
113316
|
// src/frontdoor/headroomHop.ts
|
|
113314
113317
|
var http4 = __toESM(require("node:http"), 1);
|
|
113318
|
+
var import_consumers = require("node:stream/consumers");
|
|
113315
113319
|
init_route();
|
|
113316
113320
|
var HTTP_BAD_GATEWAY2 = HTTP_STATUS.badGateway;
|
|
113317
113321
|
function responseHeaders(headers) {
|
|
@@ -113373,9 +113377,31 @@ async function answerBadGateway(response, message) {
|
|
|
113373
113377
|
response.end();
|
|
113374
113378
|
}
|
|
113375
113379
|
var HOP_AGENT = new http4.Agent({ keepAlive: false });
|
|
113380
|
+
var HOP_RESET_RETRIES = 1;
|
|
113381
|
+
var HOP_RESET_CODES = /* @__PURE__ */ new Set(["ECONNRESET", "EPIPE"]);
|
|
113382
|
+
async function collectBody(request7) {
|
|
113383
|
+
try {
|
|
113384
|
+
return await (0, import_consumers.buffer)(request7.body);
|
|
113385
|
+
} catch {
|
|
113386
|
+
return void 0;
|
|
113387
|
+
}
|
|
113388
|
+
}
|
|
113376
113389
|
async function forwardThroughHeadroom(request7, response, target) {
|
|
113390
|
+
const body = await collectBody(request7);
|
|
113391
|
+
if (body === void 0) {
|
|
113392
|
+
response.destroy();
|
|
113393
|
+
return;
|
|
113394
|
+
}
|
|
113395
|
+
for (let retriesLeft = HOP_RESET_RETRIES; ; retriesLeft -= 1) {
|
|
113396
|
+
const outcome = await hopOnce(request7, response, target, body, retriesLeft > 0);
|
|
113397
|
+
if (outcome === "settled") {
|
|
113398
|
+
return;
|
|
113399
|
+
}
|
|
113400
|
+
}
|
|
113401
|
+
}
|
|
113402
|
+
async function hopOnce(request7, response, target, body, mayRetry) {
|
|
113377
113403
|
const { socketPath, headers } = target;
|
|
113378
|
-
await new Promise((resolve2) => {
|
|
113404
|
+
return await new Promise((resolve2) => {
|
|
113379
113405
|
const onUpstreamResponse = (upstreamResponse) => {
|
|
113380
113406
|
response.start(upstreamResponse.statusCode ?? HTTP_BAD_GATEWAY2, responseHeaders(upstreamResponse.headers));
|
|
113381
113407
|
response.flush();
|
|
@@ -113396,12 +113422,18 @@ async function forwardThroughHeadroom(request7, response, target) {
|
|
|
113396
113422
|
}
|
|
113397
113423
|
response.destroy();
|
|
113398
113424
|
}
|
|
113399
|
-
resolve2(
|
|
113425
|
+
resolve2("settled");
|
|
113400
113426
|
};
|
|
113401
113427
|
void stream();
|
|
113402
113428
|
};
|
|
113403
113429
|
const hop = http4.request({ socketPath, method: request7.method, path: request7.url, headers, agent: HOP_AGENT }, onUpstreamResponse);
|
|
113404
113430
|
hop.on("error", (error62) => {
|
|
113431
|
+
const resetCode = "code" in error62 && typeof error62.code === "string" ? error62.code : void 0;
|
|
113432
|
+
if (mayRetry && !response.headersSent && !request7.signal.aborted && resetCode !== void 0 && HOP_RESET_CODES.has(resetCode)) {
|
|
113433
|
+
target.log(`front door: headroom hop to ${socketPath} reset before the response started (${request7.method} ${new URL(request7.url, "http://127.0.0.1").pathname}, ${String(body.length)} request bytes): ${error62.message} ${resetCode}; replaying once`);
|
|
113434
|
+
resolve2("retry");
|
|
113435
|
+
return;
|
|
113436
|
+
}
|
|
113405
113437
|
const phase = response.headersSent ? "mid-stream" : "before the response started";
|
|
113406
113438
|
const code = "code" in error62 && typeof error62.code === "string" ? ` ${error62.code}` : "";
|
|
113407
113439
|
target.log(`front door: headroom hop to ${socketPath} failed (${request7.method} ${new URL(request7.url, "http://127.0.0.1").pathname}, ${phase}): ${error62.message}${code}`);
|
|
@@ -113413,15 +113445,12 @@ async function forwardThroughHeadroom(request7, response, target) {
|
|
|
113413
113445
|
} else {
|
|
113414
113446
|
response.destroy();
|
|
113415
113447
|
}
|
|
113416
|
-
resolve2(
|
|
113448
|
+
resolve2("settled");
|
|
113417
113449
|
});
|
|
113418
113450
|
request7.signal.addEventListener("abort", () => {
|
|
113419
113451
|
hop.destroy();
|
|
113420
113452
|
});
|
|
113421
|
-
|
|
113422
|
-
request7.body.on("error", () => {
|
|
113423
|
-
hop.destroy();
|
|
113424
|
-
});
|
|
113453
|
+
hop.end(body);
|
|
113425
113454
|
});
|
|
113426
113455
|
}
|
|
113427
113456
|
|
|
@@ -113903,7 +113932,7 @@ var CodexErrorEnvelopeSchema = external_exports.looseObject({
|
|
|
113903
113932
|
});
|
|
113904
113933
|
async function* parseSse(body) {
|
|
113905
113934
|
const decoder = new TextDecoder();
|
|
113906
|
-
let
|
|
113935
|
+
let buffer2 = "";
|
|
113907
113936
|
let data = "";
|
|
113908
113937
|
const parsed = function* (raw) {
|
|
113909
113938
|
try {
|
|
@@ -113912,11 +113941,11 @@ async function* parseSse(body) {
|
|
|
113912
113941
|
}
|
|
113913
113942
|
};
|
|
113914
113943
|
for await (const chunk of body) {
|
|
113915
|
-
|
|
113916
|
-
let newline =
|
|
113944
|
+
buffer2 += decoder.decode(chunk, { stream: true });
|
|
113945
|
+
let newline = buffer2.indexOf("\n");
|
|
113917
113946
|
while (newline !== -1) {
|
|
113918
|
-
const line =
|
|
113919
|
-
|
|
113947
|
+
const line = buffer2.slice(0, newline).replace(/\r$/, "");
|
|
113948
|
+
buffer2 = buffer2.slice(newline + 1);
|
|
113920
113949
|
if (line === "") {
|
|
113921
113950
|
if (data !== "") {
|
|
113922
113951
|
yield* parsed(data);
|
|
@@ -113925,10 +113954,10 @@ async function* parseSse(body) {
|
|
|
113925
113954
|
} else if (line.startsWith("data:")) {
|
|
113926
113955
|
data += line.slice("data:".length).trimStart();
|
|
113927
113956
|
}
|
|
113928
|
-
newline =
|
|
113957
|
+
newline = buffer2.indexOf("\n");
|
|
113929
113958
|
}
|
|
113930
113959
|
}
|
|
113931
|
-
const tail = (
|
|
113960
|
+
const tail = (buffer2 + decoder.decode()).replace(/\r$/, "");
|
|
113932
113961
|
if (tail.startsWith("data:")) {
|
|
113933
113962
|
data += tail.slice("data:".length).trimStart();
|
|
113934
113963
|
}
|
|
@@ -117165,7 +117194,7 @@ function isSuccessful4(status) {
|
|
|
117165
117194
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE4;
|
|
117166
117195
|
}
|
|
117167
117196
|
function createSseParser() {
|
|
117168
|
-
let
|
|
117197
|
+
let buffer2 = "";
|
|
117169
117198
|
let eventName;
|
|
117170
117199
|
let eventId;
|
|
117171
117200
|
let dataLines = [];
|
|
@@ -117177,21 +117206,21 @@ function createSseParser() {
|
|
|
117177
117206
|
seenAnyText = true;
|
|
117178
117207
|
incoming = incoming.charCodeAt(0) === SSE_BYTE_ORDER_MARK ? incoming.slice(1) : incoming;
|
|
117179
117208
|
}
|
|
117180
|
-
|
|
117209
|
+
buffer2 += incoming;
|
|
117181
117210
|
const completed = [];
|
|
117182
117211
|
for (; ; ) {
|
|
117183
|
-
const carriage =
|
|
117184
|
-
const lineFeed =
|
|
117212
|
+
const carriage = buffer2.indexOf("\r");
|
|
117213
|
+
const lineFeed = buffer2.indexOf("\n");
|
|
117185
117214
|
const end = carriage === -1 ? lineFeed : lineFeed === -1 ? carriage : carriage < lineFeed ? carriage : lineFeed;
|
|
117186
117215
|
if (end === -1) {
|
|
117187
117216
|
break;
|
|
117188
117217
|
}
|
|
117189
|
-
if (
|
|
117218
|
+
if (buffer2[end] === "\r" && end === buffer2.length - 1) {
|
|
117190
117219
|
break;
|
|
117191
117220
|
}
|
|
117192
|
-
const after =
|
|
117193
|
-
const line =
|
|
117194
|
-
|
|
117221
|
+
const after = buffer2[end] === "\r" && buffer2[end + 1] === "\n" ? end + 2 : end + 1;
|
|
117222
|
+
const line = buffer2.slice(0, end);
|
|
117223
|
+
buffer2 = buffer2.slice(after);
|
|
117195
117224
|
if (line === "") {
|
|
117196
117225
|
if (dataLines.length > 0) {
|
|
117197
117226
|
completed.push({ event: eventName, id: eventId, data: dataLines.join("\n") });
|
|
@@ -118520,7 +118549,7 @@ init_preflight();
|
|
|
118520
118549
|
function formatPoolPick(report, nowMs) {
|
|
118521
118550
|
const head = report.pick === void 0 ? `Pool ${report.pool}: every member is refused right now${report.earliestReturn === void 0 ? "" : `; ${report.earliestReturn.identity} returns at ${report.earliestReturn.at} (in ${formatAge(Date.parse(report.earliestReturn.at) - nowMs)})`}` : `Pool ${report.pool}: a launch from ${report.directory} would run as ${report.pick}`;
|
|
118522
118551
|
const rows = report.candidates.map((candidate, index) => {
|
|
118523
|
-
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}`;
|
|
118552
|
+
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
118524
118553
|
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
118525
118554
|
return ` ${String(index + 1)}. ${candidate.identity} [${candidate.class}${score}]${dry}
|
|
118526
118555
|
${candidate.reasons.join("; ")}`;
|
|
@@ -118997,9 +119026,9 @@ var realUpdatePorts = {
|
|
|
118997
119026
|
throw error62;
|
|
118998
119027
|
}
|
|
118999
119028
|
try {
|
|
119000
|
-
const
|
|
119001
|
-
const read = import_node_fs18.default.readSync(descriptor,
|
|
119002
|
-
return read === 0 ? "" :
|
|
119029
|
+
const buffer2 = Buffer.alloc(length);
|
|
119030
|
+
const read = import_node_fs18.default.readSync(descriptor, buffer2, 0, length, 0);
|
|
119031
|
+
return read === 0 ? "" : buffer2.toString("latin1", 0, read);
|
|
119003
119032
|
} finally {
|
|
119004
119033
|
import_node_fs18.default.closeSync(descriptor);
|
|
119005
119034
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -2649,7 +2649,7 @@ var init_package = __esm({
|
|
|
2649
2649
|
"package.json"() {
|
|
2650
2650
|
package_default = {
|
|
2651
2651
|
name: "claude-use",
|
|
2652
|
-
version: "9.
|
|
2652
|
+
version: "9.4.1",
|
|
2653
2653
|
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.",
|
|
2654
2654
|
license: "MIT",
|
|
2655
2655
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -4645,7 +4645,7 @@ function assessIdentity(member, nowMs) {
|
|
|
4645
4645
|
const headroom = overage?.utilization === void 0 ? void 0 : Math.max(0, 1 - overage.utilization);
|
|
4646
4646
|
return { candidate: { ...base, class: "pay-per-use", ...headroom === void 0 ? {} : { headroom }, reasons: [...plan.kind === "pay-per-use" ? planReasons : ["no plan windows reported, so usage bills as extra usage"], ...overageReasons] } };
|
|
4647
4647
|
}
|
|
4648
|
-
const basis = seven?.utilization !== void 0 ? { window: seven, windowMs: SEVEN_DAY_WINDOW_MS } : five?.utilization !== void 0 ? { window: five, windowMs: FIVE_HOUR_WINDOW_MS } : void 0;
|
|
4648
|
+
const basis = seven?.utilization !== void 0 ? { window: seven, windowMs: SEVEN_DAY_WINDOW_MS, name: "sevenDay" } : five?.utilization !== void 0 ? { window: five, windowMs: FIVE_HOUR_WINDOW_MS, name: "fiveHour" } : void 0;
|
|
4649
4649
|
if (basis?.window.utilization === void 0) {
|
|
4650
4650
|
return { candidate: { ...base, class: "unknown", reasons: ["quota windows reported no utilisation", ...windowReasons, ...planReasons] } };
|
|
4651
4651
|
}
|
|
@@ -4659,7 +4659,7 @@ function assessIdentity(member, nowMs) {
|
|
|
4659
4659
|
const sevenUntil = seven?.resetsAtMs === void 0 ? SEVEN_DAY_WINDOW_MS : Math.max(seven.resetsAtMs - nowMs, MS_PER_SECOND4);
|
|
4660
4660
|
const sevenDayBurn = windowBurn(member.records, "sevenDay");
|
|
4661
4661
|
return {
|
|
4662
|
-
candidate: { ...base, class: "scored", score, reasons: [...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
|
|
4662
|
+
candidate: { ...base, class: "scored", score, scoreWindow: basis.name, reasons: [...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
|
|
4663
4663
|
...fiveRemaining === void 0 ? {} : { fiveHour: { remaining: fiveRemaining, untilResetMs: fiveUntil } },
|
|
4664
4664
|
...burn === void 0 ? {} : { burn },
|
|
4665
4665
|
...sevenRemaining === void 0 ? {} : { sevenDay: { remaining: sevenRemaining, untilResetMs: sevenUntil } },
|
|
@@ -11082,6 +11082,7 @@ function candidateView(candidate) {
|
|
|
11082
11082
|
identity: candidate.identity,
|
|
11083
11083
|
class: candidate.class,
|
|
11084
11084
|
...candidate.score === void 0 ? {} : { score: candidate.score },
|
|
11085
|
+
...candidate.scoreWindow === void 0 ? {} : { scoreWindow: candidate.scoreWindow },
|
|
11085
11086
|
feasible: candidate.feasible,
|
|
11086
11087
|
...candidate.blockedUntilMs === void 0 ? {} : { blockedUntil: new Date(candidate.blockedUntilMs).toISOString() },
|
|
11087
11088
|
plan: candidate.plan,
|
|
@@ -11853,6 +11854,8 @@ var PoolPickCandidateViewSchema = import_zod13.z.strictObject({
|
|
|
11853
11854
|
class: import_zod13.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
11854
11855
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
11855
11856
|
score: import_zod13.z.number().optional(),
|
|
11857
|
+
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation; present with `score`. */
|
|
11858
|
+
scoreWindow: import_zod13.z.enum(["sevenDay", "fiveHour"]).optional(),
|
|
11856
11859
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
11857
11860
|
feasible: import_zod13.z.boolean(),
|
|
11858
11861
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
package/dist/index.mjs
CHANGED
|
@@ -2625,7 +2625,7 @@ var init_package = __esm({
|
|
|
2625
2625
|
"package.json"() {
|
|
2626
2626
|
package_default = {
|
|
2627
2627
|
name: "claude-use",
|
|
2628
|
-
version: "9.
|
|
2628
|
+
version: "9.4.1",
|
|
2629
2629
|
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.",
|
|
2630
2630
|
license: "MIT",
|
|
2631
2631
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -4619,7 +4619,7 @@ function assessIdentity(member, nowMs) {
|
|
|
4619
4619
|
const headroom = overage?.utilization === void 0 ? void 0 : Math.max(0, 1 - overage.utilization);
|
|
4620
4620
|
return { candidate: { ...base, class: "pay-per-use", ...headroom === void 0 ? {} : { headroom }, reasons: [...plan.kind === "pay-per-use" ? planReasons : ["no plan windows reported, so usage bills as extra usage"], ...overageReasons] } };
|
|
4621
4621
|
}
|
|
4622
|
-
const basis = seven?.utilization !== void 0 ? { window: seven, windowMs: SEVEN_DAY_WINDOW_MS } : five?.utilization !== void 0 ? { window: five, windowMs: FIVE_HOUR_WINDOW_MS } : void 0;
|
|
4622
|
+
const basis = seven?.utilization !== void 0 ? { window: seven, windowMs: SEVEN_DAY_WINDOW_MS, name: "sevenDay" } : five?.utilization !== void 0 ? { window: five, windowMs: FIVE_HOUR_WINDOW_MS, name: "fiveHour" } : void 0;
|
|
4623
4623
|
if (basis?.window.utilization === void 0) {
|
|
4624
4624
|
return { candidate: { ...base, class: "unknown", reasons: ["quota windows reported no utilisation", ...windowReasons, ...planReasons] } };
|
|
4625
4625
|
}
|
|
@@ -4633,7 +4633,7 @@ function assessIdentity(member, nowMs) {
|
|
|
4633
4633
|
const sevenUntil = seven?.resetsAtMs === void 0 ? SEVEN_DAY_WINDOW_MS : Math.max(seven.resetsAtMs - nowMs, MS_PER_SECOND4);
|
|
4634
4634
|
const sevenDayBurn = windowBurn(member.records, "sevenDay");
|
|
4635
4635
|
return {
|
|
4636
|
-
candidate: { ...base, class: "scored", score, reasons: [...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
|
|
4636
|
+
candidate: { ...base, class: "scored", score, scoreWindow: basis.name, reasons: [...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
|
|
4637
4637
|
...fiveRemaining === void 0 ? {} : { fiveHour: { remaining: fiveRemaining, untilResetMs: fiveUntil } },
|
|
4638
4638
|
...burn === void 0 ? {} : { burn },
|
|
4639
4639
|
...sevenRemaining === void 0 ? {} : { sevenDay: { remaining: sevenRemaining, untilResetMs: sevenUntil } },
|
|
@@ -10757,6 +10757,7 @@ function candidateView(candidate) {
|
|
|
10757
10757
|
identity: candidate.identity,
|
|
10758
10758
|
class: candidate.class,
|
|
10759
10759
|
...candidate.score === void 0 ? {} : { score: candidate.score },
|
|
10760
|
+
...candidate.scoreWindow === void 0 ? {} : { scoreWindow: candidate.scoreWindow },
|
|
10760
10761
|
feasible: candidate.feasible,
|
|
10761
10762
|
...candidate.blockedUntilMs === void 0 ? {} : { blockedUntil: new Date(candidate.blockedUntilMs).toISOString() },
|
|
10762
10763
|
plan: candidate.plan,
|
|
@@ -11528,6 +11529,8 @@ var PoolPickCandidateViewSchema = z13.strictObject({
|
|
|
11528
11529
|
class: z13.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
11529
11530
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
11530
11531
|
score: z13.number().optional(),
|
|
11532
|
+
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation; present with `score`. */
|
|
11533
|
+
scoreWindow: z13.enum(["sevenDay", "fiveHour"]).optional(),
|
|
11531
11534
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
11532
11535
|
feasible: z13.boolean(),
|
|
11533
11536
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3741,6 +3741,10 @@ declare const CheckReportJsonSchema: z.ZodObject<{
|
|
|
3741
3741
|
ineligible: "ineligible";
|
|
3742
3742
|
}>;
|
|
3743
3743
|
score: z.ZodOptional<z.ZodNumber>;
|
|
3744
|
+
scoreWindow: z.ZodOptional<z.ZodEnum<{
|
|
3745
|
+
fiveHour: "fiveHour";
|
|
3746
|
+
sevenDay: "sevenDay";
|
|
3747
|
+
}>>;
|
|
3744
3748
|
feasible: z.ZodBoolean;
|
|
3745
3749
|
blockedUntil: z.ZodOptional<z.ZodISODateTime>;
|
|
3746
3750
|
plan: z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -4237,6 +4241,10 @@ declare const PoolPickReportSchema: z.ZodObject<{
|
|
|
4237
4241
|
ineligible: "ineligible";
|
|
4238
4242
|
}>;
|
|
4239
4243
|
score: z.ZodOptional<z.ZodNumber>;
|
|
4244
|
+
scoreWindow: z.ZodOptional<z.ZodEnum<{
|
|
4245
|
+
fiveHour: "fiveHour";
|
|
4246
|
+
sevenDay: "sevenDay";
|
|
4247
|
+
}>>;
|
|
4240
4248
|
feasible: z.ZodBoolean;
|
|
4241
4249
|
blockedUntil: z.ZodOptional<z.ZodISODateTime>;
|
|
4242
4250
|
plan: z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -5231,6 +5239,10 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
|
|
|
5231
5239
|
ineligible: "ineligible";
|
|
5232
5240
|
}>;
|
|
5233
5241
|
score: zod.ZodOptional<zod.ZodNumber>;
|
|
5242
|
+
scoreWindow: zod.ZodOptional<zod.ZodEnum<{
|
|
5243
|
+
fiveHour: "fiveHour";
|
|
5244
|
+
sevenDay: "sevenDay";
|
|
5245
|
+
}>>;
|
|
5234
5246
|
feasible: zod.ZodBoolean;
|
|
5235
5247
|
blockedUntil: zod.ZodOptional<zod.ZodISODateTime>;
|
|
5236
5248
|
plan: zod.ZodUnion<readonly [zod.ZodObject<{
|
|
@@ -5552,6 +5564,10 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
|
|
|
5552
5564
|
ineligible: "ineligible";
|
|
5553
5565
|
}>;
|
|
5554
5566
|
score: zod.ZodOptional<zod.ZodNumber>;
|
|
5567
|
+
scoreWindow: zod.ZodOptional<zod.ZodEnum<{
|
|
5568
|
+
fiveHour: "fiveHour";
|
|
5569
|
+
sevenDay: "sevenDay";
|
|
5570
|
+
}>>;
|
|
5555
5571
|
feasible: zod.ZodBoolean;
|
|
5556
5572
|
blockedUntil: zod.ZodOptional<zod.ZodISODateTime>;
|
|
5557
5573
|
plan: zod.ZodUnion<readonly [zod.ZodObject<{
|
|
@@ -5831,6 +5847,10 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
5831
5847
|
ineligible: "ineligible";
|
|
5832
5848
|
}>;
|
|
5833
5849
|
score: zod.ZodOptional<zod.ZodNumber>;
|
|
5850
|
+
scoreWindow: zod.ZodOptional<zod.ZodEnum<{
|
|
5851
|
+
fiveHour: "fiveHour";
|
|
5852
|
+
sevenDay: "sevenDay";
|
|
5853
|
+
}>>;
|
|
5834
5854
|
feasible: zod.ZodBoolean;
|
|
5835
5855
|
blockedUntil: zod.ZodOptional<zod.ZodISODateTime>;
|
|
5836
5856
|
plan: zod.ZodUnion<readonly [zod.ZodObject<{
|
|
@@ -6152,6 +6172,10 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
6152
6172
|
ineligible: "ineligible";
|
|
6153
6173
|
}>;
|
|
6154
6174
|
score: zod.ZodOptional<zod.ZodNumber>;
|
|
6175
|
+
scoreWindow: zod.ZodOptional<zod.ZodEnum<{
|
|
6176
|
+
fiveHour: "fiveHour";
|
|
6177
|
+
sevenDay: "sevenDay";
|
|
6178
|
+
}>>;
|
|
6155
6179
|
feasible: zod.ZodBoolean;
|
|
6156
6180
|
blockedUntil: zod.ZodOptional<zod.ZodISODateTime>;
|
|
6157
6181
|
plan: zod.ZodUnion<readonly [zod.ZodObject<{
|
|
@@ -7176,6 +7200,8 @@ interface Candidate {
|
|
|
7176
7200
|
readonly class: CandidateClass;
|
|
7177
7201
|
/** Plan-size-weighted remaining quota per hour until its reset: higher is more wasted if left unused. Present for `scored` only. */
|
|
7178
7202
|
readonly score?: number;
|
|
7203
|
+
/** The window the score's hours-until-reset come from: the seven-day window, or the five-hour one when the member reports no seven-day utilisation. Present with `score`. */
|
|
7204
|
+
readonly scoreWindow?: "sevenDay" | "fiveHour";
|
|
7179
7205
|
/** False when a quota window would run dry, at the observed pace, before it resets (the five-hour at its own or the rescaled shared pace, the seven-day at its own). A `scored` candidate that is not feasible ranks below every feasible one. */
|
|
7180
7206
|
readonly feasible: boolean;
|
|
7181
7207
|
/** The fraction of the extra-usage allowance still unspent, for a `pay-per-use` member whose only budget is that allowance (an Enterprise account). A member reporting none ranks as having all of it: no cap is known to bind. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-use",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.1",
|
|
4
4
|
"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.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Joseph Mearman <joseph@mearman.co.uk>",
|