claude-use 11.58.0 → 11.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.cjs +492 -230
- package/dist/index.cjs +42 -8
- package/dist/index.mjs +42 -8
- package/dist/types/index.d.ts +572 -22
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -634,14 +634,14 @@ function codePointLength(str) {
|
|
|
634
634
|
const units = str.length;
|
|
635
635
|
if (!highSurrogate.test(str))
|
|
636
636
|
return units;
|
|
637
|
-
let
|
|
637
|
+
let count2 = units;
|
|
638
638
|
for (let i10 = 0; i10 < units - 1; i10++) {
|
|
639
639
|
if ((str.charCodeAt(i10) & 64512) === 55296 && (str.charCodeAt(i10 + 1) & 64512) === 56320) {
|
|
640
|
-
|
|
640
|
+
count2--;
|
|
641
641
|
i10++;
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
|
-
return
|
|
644
|
+
return count2;
|
|
645
645
|
}
|
|
646
646
|
function getLengthableOrigin(input2) {
|
|
647
647
|
if (Array.isArray(input2))
|
|
@@ -2265,13 +2265,13 @@ function isValidBase64URL(data) {
|
|
|
2265
2265
|
function isLuhnAlgo(digits) {
|
|
2266
2266
|
let length = digits.length;
|
|
2267
2267
|
let bit = 1;
|
|
2268
|
-
let
|
|
2268
|
+
let sum2 = 0;
|
|
2269
2269
|
while (length) {
|
|
2270
2270
|
const value2 = digits.charCodeAt(--length) - 48;
|
|
2271
2271
|
bit ^= 1;
|
|
2272
|
-
|
|
2272
|
+
sum2 += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value2] : value2;
|
|
2273
2273
|
}
|
|
2274
|
-
return
|
|
2274
|
+
return sum2 % 10 === 0;
|
|
2275
2275
|
}
|
|
2276
2276
|
function isValidCreditCard(input2) {
|
|
2277
2277
|
if (!creditCard.test(input2))
|
|
@@ -5104,8 +5104,8 @@ var init_az = __esm({
|
|
|
5104
5104
|
});
|
|
5105
5105
|
|
|
5106
5106
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/be.js
|
|
5107
|
-
function getBelarusianPlural(
|
|
5108
|
-
const absCount = Math.abs(
|
|
5107
|
+
function getBelarusianPlural(count2, one2, few, many) {
|
|
5108
|
+
const absCount = Math.abs(count2);
|
|
5109
5109
|
const lastDigit = absCount % 10;
|
|
5110
5110
|
const lastTwoDigits = absCount % 100;
|
|
5111
5111
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -7878,8 +7878,8 @@ var init_hu = __esm({
|
|
|
7878
7878
|
});
|
|
7879
7879
|
|
|
7880
7880
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/hy.js
|
|
7881
|
-
function getArmenianPlural(
|
|
7882
|
-
return Math.abs(
|
|
7881
|
+
function getArmenianPlural(count2, one2, many) {
|
|
7882
|
+
return Math.abs(count2) === 1 ? one2 : many;
|
|
7883
7883
|
}
|
|
7884
7884
|
function withDefiniteArticle(word) {
|
|
7885
7885
|
if (!word)
|
|
@@ -10754,8 +10754,8 @@ var init_ro = __esm({
|
|
|
10754
10754
|
});
|
|
10755
10755
|
|
|
10756
10756
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/ru.js
|
|
10757
|
-
function getRussianPlural(
|
|
10758
|
-
const absCount = Math.abs(
|
|
10757
|
+
function getRussianPlural(count2, one2, few, many) {
|
|
10758
|
+
const absCount = Math.abs(count2);
|
|
10759
10759
|
const lastDigit = absCount % 10;
|
|
10760
10760
|
const lastTwoDigits = absCount % 100;
|
|
10761
10761
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -20523,9 +20523,9 @@ var require_common = __commonJS({
|
|
|
20523
20523
|
}
|
|
20524
20524
|
return target;
|
|
20525
20525
|
}
|
|
20526
|
-
function repeat(string4,
|
|
20526
|
+
function repeat(string4, count2) {
|
|
20527
20527
|
let result = "";
|
|
20528
|
-
for (let cycle = 0; cycle <
|
|
20528
|
+
for (let cycle = 0; cycle < count2; cycle += 1) {
|
|
20529
20529
|
result += string4;
|
|
20530
20530
|
}
|
|
20531
20531
|
return result;
|
|
@@ -21894,11 +21894,11 @@ var require_loader = __commonJS({
|
|
|
21894
21894
|
}
|
|
21895
21895
|
return false;
|
|
21896
21896
|
}
|
|
21897
|
-
function writeFoldedLines(state,
|
|
21898
|
-
if (
|
|
21897
|
+
function writeFoldedLines(state, count2) {
|
|
21898
|
+
if (count2 === 1) {
|
|
21899
21899
|
state.result += " ";
|
|
21900
|
-
} else if (
|
|
21901
|
-
state.result += common.repeat("\n",
|
|
21900
|
+
} else if (count2 > 1) {
|
|
21901
|
+
state.result += common.repeat("\n", count2 - 1);
|
|
21902
21902
|
}
|
|
21903
21903
|
}
|
|
21904
21904
|
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
@@ -25353,27 +25353,41 @@ function distinctList(member) {
|
|
|
25353
25353
|
function isSingleVisibleGrapheme(text5) {
|
|
25354
25354
|
return graphemesOf(text5).length === 1 && stringWidth(text5) === 1 && !/[\p{C}\p{Z}]/u.test(text5) && !drawsNothing(text5);
|
|
25355
25355
|
}
|
|
25356
|
+
function unsettable(setting) {
|
|
25357
|
+
return setting.unwrap().nullable().optional().describe(`${setting.description ?? ""} ${UNSET_NOTE}`);
|
|
25358
|
+
}
|
|
25356
25359
|
function isPlainObject2(value2) {
|
|
25357
25360
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
25358
25361
|
}
|
|
25359
25362
|
function mergeStatuslineSettings(base, over) {
|
|
25360
|
-
if (!isPlainObject2(
|
|
25363
|
+
if (!isPlainObject2(over)) {
|
|
25361
25364
|
return over === void 0 ? base : over;
|
|
25362
25365
|
}
|
|
25363
|
-
const merged = { ...base };
|
|
25366
|
+
const merged = isPlainObject2(base) ? { ...base } : {};
|
|
25364
25367
|
for (const [key, value2] of Object.entries(over)) {
|
|
25365
|
-
|
|
25368
|
+
if (value2 === null) {
|
|
25369
|
+
Reflect.deleteProperty(merged, key);
|
|
25370
|
+
} else {
|
|
25371
|
+
merged[key] = mergeStatuslineSettings(merged[key], value2);
|
|
25372
|
+
}
|
|
25366
25373
|
}
|
|
25367
25374
|
return merged;
|
|
25368
25375
|
}
|
|
25376
|
+
function contextBands({ bands, context }) {
|
|
25377
|
+
return { warnAt: context.warnAt ?? bands.warnAt, criticalAt: context.criticalAt ?? bands.criticalAt };
|
|
25378
|
+
}
|
|
25369
25379
|
function resolveStatusline(settings2) {
|
|
25370
25380
|
const resolved = ResolvedStatuslineSchema.parse(mergeStatuslineSettings(STATUSLINE_DEFAULTS, settings2));
|
|
25371
25381
|
if (resolved.bands.warnAt >= resolved.bands.criticalAt) {
|
|
25372
25382
|
throw new RangeError(`statusline bands.warnAt (${String(resolved.bands.warnAt)}) must be below bands.criticalAt (${String(resolved.bands.criticalAt)})`);
|
|
25373
25383
|
}
|
|
25384
|
+
const forContext = contextBands(resolved);
|
|
25385
|
+
if (forContext.warnAt >= forContext.criticalAt) {
|
|
25386
|
+
throw new RangeError(`statusline context.warnAt (${String(forContext.warnAt)}) must be below context.criticalAt (${String(forContext.criticalAt)}), each following bands while it is unset`);
|
|
25387
|
+
}
|
|
25374
25388
|
return resolved;
|
|
25375
25389
|
}
|
|
25376
|
-
var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_ROWS, STATUSLINE_SESSION_TIME_PARTS, PROMPT_CACHE_TTL_SECONDS, STATUSLINE_COLOUR_NAMES, DEFAULT_HEADER_SEGMENTS, DEFAULT_ROWS, STATUSLINE_PATH_LEVELS, STATUSLINE_USAGE_VALUES, STATUSLINE_TIME_FORMATS, STATUSLINE_HOUR_CYCLES, MAX_PERCENT, MAX_STATUSLINE_PALETTE_INDEX, MAX_STATUSLINE_LABEL_COLUMNS, MAX_BAR_CELLS, MAX_ACCOUNT_USER_CHARS, MAX_DISPLAY_TEXT_CHARS, LABEL_RE2, OPTIONAL_LABEL_RE, colourValue, barCharacter, labelText, overrideText, wholePercent, thresholdPercent, SHAPES, StatuslineSchema, ResolvedStatuslineSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
|
|
25390
|
+
var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_ROWS, STATUSLINE_SESSION_TIME_PARTS, PROMPT_CACHE_TTL_SECONDS, STATUSLINE_COLOUR_NAMES, DEFAULT_HEADER_SEGMENTS, DEFAULT_ROWS, STATUSLINE_PATH_LEVELS, STATUSLINE_USAGE_VALUES, STATUSLINE_TIME_FORMATS, STATUSLINE_HOUR_CYCLES, MAX_PERCENT, MAX_STATUSLINE_PALETTE_INDEX, MAX_STATUSLINE_LABEL_COLUMNS, MAX_BAR_CELLS, MAX_ACCOUNT_USER_CHARS, MAX_DISPLAY_TEXT_CHARS, LABEL_RE2, OPTIONAL_LABEL_RE, colourValue, barCharacter, STATUSLINE_CONTEXT_VALUES, STATUSLINE_CONTEXT_ESTIMATES, AUTOCOMPACT_RESERVE_FRACTION, AUTOCOMPACT_RESERVE_RAMP_START, AUTOCOMPACT_RESERVE_RAMP_END, labelText, overrideText, wholePercent, thresholdPercent, SHAPES, UNSET_NOTE, StatuslineSchema, ResolvedStatuslineSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
|
|
25377
25391
|
var init_statusline = __esm({
|
|
25378
25392
|
"src/config/statusline.ts"() {
|
|
25379
25393
|
"use strict";
|
|
@@ -25382,7 +25396,7 @@ var init_statusline = __esm({
|
|
|
25382
25396
|
init_blank();
|
|
25383
25397
|
init_graphemes();
|
|
25384
25398
|
STATUSLINE_HEADER_SEGMENTS = ["model", "provider", "route", "account", "identity", "headroom", "project", "vcs", "effort", "advisor", "version", "outputStyle", "cost", "dailyCost", "sessionName", "duration", "speed"];
|
|
25385
|
-
STATUSLINE_ROWS = ["context", "quota", "addedDirs", "gitFiles", "memory", "environment", "sessionTime", "promptCache", "compactions"];
|
|
25399
|
+
STATUSLINE_ROWS = ["context", "quota", "addedDirs", "gitFiles", "memory", "environment", "sessionTime", "promptCache", "compactions", "tokens"];
|
|
25386
25400
|
STATUSLINE_SESSION_TIME_PARTS = ["started", "lastReply"];
|
|
25387
25401
|
PROMPT_CACHE_TTL_SECONDS = { fiveMinutes: 300, oneHour: 3600 };
|
|
25388
25402
|
STATUSLINE_COLOUR_NAMES = [
|
|
@@ -25421,6 +25435,11 @@ var init_statusline = __esm({
|
|
|
25421
25435
|
OPTIONAL_LABEL_RE = /^(?:[^\p{C}\p{Z}]+(?: [^\p{C}\p{Z}]+)*)?$/u;
|
|
25422
25436
|
colourValue = external_exports.union([external_exports.enum(STATUSLINE_COLOUR_NAMES), external_exports.number().int().min(0).max(MAX_STATUSLINE_PALETTE_INDEX), external_exports.string().regex(/^#[0-9a-fA-F]{6}$/, "must be a colour name, a palette index from 0 to 255 or #rrggbb")]);
|
|
25423
25437
|
barCharacter = external_exports.string().refine(isSingleVisibleGrapheme, "must be a single visible character that takes one terminal column");
|
|
25438
|
+
STATUSLINE_CONTEXT_VALUES = ["both", "percent", "tokens", "remaining"];
|
|
25439
|
+
STATUSLINE_CONTEXT_ESTIMATES = ["never", "raw", "buffered"];
|
|
25440
|
+
AUTOCOMPACT_RESERVE_FRACTION = 0.165;
|
|
25441
|
+
AUTOCOMPACT_RESERVE_RAMP_START = 0.05;
|
|
25442
|
+
AUTOCOMPACT_RESERVE_RAMP_END = 0.5;
|
|
25424
25443
|
labelText = external_exports.string().refine((text5) => stringWidth(text5) <= MAX_STATUSLINE_LABEL_COLUMNS, `must take no more than ${String(MAX_STATUSLINE_LABEL_COLUMNS)} terminal columns`).refine((text5) => !drawsNothing(text5), "must show something: a label of only combining marks or blank characters draws nothing").regex(LABEL_RE2, "must be visible text without control characters");
|
|
25425
25444
|
overrideText = external_exports.string().max(MAX_DISPLAY_TEXT_CHARS).regex(OPTIONAL_LABEL_RE, "must be visible text without control characters");
|
|
25426
25445
|
wholePercent = external_exports.number().int().min(1).max(MAX_PERCENT);
|
|
@@ -25448,6 +25467,15 @@ var init_statusline = __esm({
|
|
|
25448
25467
|
advisor: {
|
|
25449
25468
|
override: overrideText.describe("A name to show for the advisor model in place of the one the session's transcript records; empty shows the transcript's, prettified.")
|
|
25450
25469
|
},
|
|
25470
|
+
context: {
|
|
25471
|
+
bar: external_exports.enum(["shown", "hidden"]).describe("Whether the context row draws its bar, or only its figures on one line of text."),
|
|
25472
|
+
value: external_exports.enum(STATUSLINE_CONTEXT_VALUES).describe("The context figure: both (the tokens held against the window, then the percentage), percent, tokens, or remaining (the percentage of the window left)."),
|
|
25473
|
+
warnAt: wholePercent.optional().describe("The whole percentage of the context window at which the context bar turns yellow; while it is unset the context bar follows bands.warnAt."),
|
|
25474
|
+
criticalAt: wholePercent.optional().describe("The whole percentage of the context window at which the context bar turns red and, with context.breakdown set to critical, the token breakdown appears; while it is unset the context bar follows bands.criticalAt."),
|
|
25475
|
+
autoCompactWindow: external_exports.number().int().positive().optional().describe("A window in tokens to measure the context against instead of the model's, matching the figure /context gives once Claude Code compacts before the window is full. While it is set, the row draws nothing until the client reports the tokens held, since without them there is nothing to measure against it; while it is unset the model's own window is used."),
|
|
25476
|
+
estimate: external_exports.enum(STATUSLINE_CONTEXT_ESTIMATES).describe(`What to draw when the client reports no percentage of the window in use, or reports 0 while tokens are already held (which is how a client says it has not worked it out yet): never (nothing is estimated: a percentage reported, 0 included, is drawn as it is, and none reported draws nothing), raw (the tokens held over the window), or buffered (that, plus the ${String(AUTOCOMPACT_RESERVE_FRACTION * MAX_PERCENT)}% of the window Claude Code reserves for compaction, rising from nothing at ${String(AUTOCOMPACT_RESERVE_RAMP_START * MAX_PERCENT)}% of the window held to the whole reserve at ${String(AUTOCOMPACT_RESERVE_RAMP_END * MAX_PERCENT)}%).`),
|
|
25477
|
+
breakdown: external_exports.enum(["never", "critical"]).describe("Whether to add the input and cache tokens of the last request to the context row once its use reaches context.criticalAt.")
|
|
25478
|
+
},
|
|
25451
25479
|
bands: {
|
|
25452
25480
|
warnAt: wholePercent.describe("The whole percentage of use at which a bar turns yellow; it must be below criticalAt."),
|
|
25453
25481
|
criticalAt: wholePercent.describe("The whole percentage of use at which a bar turns red.")
|
|
@@ -25519,6 +25547,7 @@ var init_statusline = __esm({
|
|
|
25519
25547
|
showConflicts: external_exports.boolean().describe("Whether the segment shows !conflict when the working-copy commit has an unresolved conflict.")
|
|
25520
25548
|
}
|
|
25521
25549
|
};
|
|
25550
|
+
UNSET_NOTE = "A layer may write null to return it to unset when a shallower layer sets it.";
|
|
25522
25551
|
StatuslineSchema = external_exports.strictObject({
|
|
25523
25552
|
layout: external_exports.strictObject(SHAPES.layout).partial().optional(),
|
|
25524
25553
|
model: external_exports.strictObject(SHAPES.model).partial().optional(),
|
|
@@ -25526,6 +25555,7 @@ var init_statusline = __esm({
|
|
|
25526
25555
|
account: external_exports.strictObject(SHAPES.account).partial().optional(),
|
|
25527
25556
|
effort: external_exports.strictObject(SHAPES.effort).partial().optional(),
|
|
25528
25557
|
advisor: external_exports.strictObject(SHAPES.advisor).partial().optional(),
|
|
25558
|
+
context: external_exports.strictObject({ ...SHAPES.context, warnAt: unsettable(SHAPES.context.warnAt), criticalAt: unsettable(SHAPES.context.criticalAt), autoCompactWindow: unsettable(SHAPES.context.autoCompactWindow) }).partial().optional(),
|
|
25529
25559
|
bands: external_exports.strictObject(SHAPES.bands).partial().optional(),
|
|
25530
25560
|
labels: external_exports.strictObject(SHAPES.labels).partial().optional(),
|
|
25531
25561
|
bar: external_exports.strictObject(SHAPES.bar).partial().optional(),
|
|
@@ -25547,6 +25577,7 @@ var init_statusline = __esm({
|
|
|
25547
25577
|
account: external_exports.strictObject(SHAPES.account),
|
|
25548
25578
|
effort: external_exports.strictObject(SHAPES.effort),
|
|
25549
25579
|
advisor: external_exports.strictObject(SHAPES.advisor),
|
|
25580
|
+
context: external_exports.strictObject(SHAPES.context),
|
|
25550
25581
|
bands: external_exports.strictObject(SHAPES.bands),
|
|
25551
25582
|
labels: external_exports.strictObject(SHAPES.labels),
|
|
25552
25583
|
bar: external_exports.strictObject(SHAPES.bar),
|
|
@@ -25568,6 +25599,7 @@ var init_statusline = __esm({
|
|
|
25568
25599
|
account: { parts: ["user", "organisation", "plan"], userLength: 0 },
|
|
25569
25600
|
effort: { format: "full" },
|
|
25570
25601
|
advisor: { override: "" },
|
|
25602
|
+
context: { bar: "shown", value: "both", estimate: "never", breakdown: "never" },
|
|
25571
25603
|
bands: { warnAt: 70, criticalAt: 90 },
|
|
25572
25604
|
labels: { fiveHour: "5h", sevenDay: "Wk" },
|
|
25573
25605
|
bar: { width: 10, filled: "\u2588", empty: "\u2591" },
|
|
@@ -29502,11 +29534,11 @@ function realIsFrontDoorSupervisor(pid) {
|
|
|
29502
29534
|
return result.status === 0 && parseFrontDoorSupervisorPids(result.stdout).includes(pid);
|
|
29503
29535
|
}
|
|
29504
29536
|
function leadingContinuationBytes(bytes) {
|
|
29505
|
-
let
|
|
29506
|
-
while (
|
|
29507
|
-
|
|
29537
|
+
let count2 = 0;
|
|
29538
|
+
while (count2 < bytes.length && (bytes.readUInt8(count2) & UTF8_CONTINUATION_MASK) === UTF8_CONTINUATION_BITS) {
|
|
29539
|
+
count2 += 1;
|
|
29508
29540
|
}
|
|
29509
|
-
return
|
|
29541
|
+
return count2;
|
|
29510
29542
|
}
|
|
29511
29543
|
function realFileSize(filePath) {
|
|
29512
29544
|
try {
|
|
@@ -30395,12 +30427,12 @@ var require_src = __commonJS({
|
|
|
30395
30427
|
else if (y10 > 0) ret += `${CSI2}${y10}B`;
|
|
30396
30428
|
return ret;
|
|
30397
30429
|
},
|
|
30398
|
-
up: (
|
|
30399
|
-
down: (
|
|
30400
|
-
forward: (
|
|
30401
|
-
backward: (
|
|
30402
|
-
nextLine: (
|
|
30403
|
-
prevLine: (
|
|
30430
|
+
up: (count2 = 1) => `${CSI2}${count2}A`,
|
|
30431
|
+
down: (count2 = 1) => `${CSI2}${count2}B`,
|
|
30432
|
+
forward: (count2 = 1) => `${CSI2}${count2}C`,
|
|
30433
|
+
backward: (count2 = 1) => `${CSI2}${count2}D`,
|
|
30434
|
+
nextLine: (count2 = 1) => `${CSI2}E`.repeat(count2),
|
|
30435
|
+
prevLine: (count2 = 1) => `${CSI2}F`.repeat(count2),
|
|
30404
30436
|
left: `${CSI2}G`,
|
|
30405
30437
|
hide: `${CSI2}?25l`,
|
|
30406
30438
|
show: `${CSI2}?25h`,
|
|
@@ -30408,21 +30440,21 @@ var require_src = __commonJS({
|
|
|
30408
30440
|
restore: `${ESC2}8`
|
|
30409
30441
|
};
|
|
30410
30442
|
var scroll = {
|
|
30411
|
-
up: (
|
|
30412
|
-
down: (
|
|
30443
|
+
up: (count2 = 1) => `${CSI2}S`.repeat(count2),
|
|
30444
|
+
down: (count2 = 1) => `${CSI2}T`.repeat(count2)
|
|
30413
30445
|
};
|
|
30414
30446
|
var erase3 = {
|
|
30415
30447
|
screen: `${CSI2}2J`,
|
|
30416
|
-
up: (
|
|
30417
|
-
down: (
|
|
30448
|
+
up: (count2 = 1) => `${CSI2}1J`.repeat(count2),
|
|
30449
|
+
down: (count2 = 1) => `${CSI2}J`.repeat(count2),
|
|
30418
30450
|
line: `${CSI2}2K`,
|
|
30419
30451
|
lineEnd: `${CSI2}K`,
|
|
30420
30452
|
lineStart: `${CSI2}1K`,
|
|
30421
|
-
lines(
|
|
30453
|
+
lines(count2) {
|
|
30422
30454
|
let clear = "";
|
|
30423
|
-
for (let i10 = 0; i10 <
|
|
30424
|
-
clear += this.line + (i10 <
|
|
30425
|
-
if (
|
|
30455
|
+
for (let i10 = 0; i10 < count2; i10++)
|
|
30456
|
+
clear += this.line + (i10 < count2 - 1 ? cursor3.up() : "");
|
|
30457
|
+
if (count2)
|
|
30426
30458
|
clear += cursor3.left;
|
|
30427
30459
|
return clear;
|
|
30428
30460
|
}
|
|
@@ -30769,16 +30801,16 @@ var require_scan = __commonJS({
|
|
|
30769
30801
|
let token = { value: "", depth: 0, isGlob: false };
|
|
30770
30802
|
const eos = () => index >= length;
|
|
30771
30803
|
const peek = () => str.charCodeAt(index + 1);
|
|
30772
|
-
const
|
|
30804
|
+
const advance3 = () => {
|
|
30773
30805
|
prev = code;
|
|
30774
30806
|
return str.charCodeAt(++index);
|
|
30775
30807
|
};
|
|
30776
30808
|
while (index < length) {
|
|
30777
|
-
code =
|
|
30809
|
+
code = advance3();
|
|
30778
30810
|
let next;
|
|
30779
30811
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30780
30812
|
backslashes = token.backslashes = true;
|
|
30781
|
-
code =
|
|
30813
|
+
code = advance3();
|
|
30782
30814
|
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
30783
30815
|
braceEscaped = true;
|
|
30784
30816
|
}
|
|
@@ -30786,17 +30818,17 @@ var require_scan = __commonJS({
|
|
|
30786
30818
|
}
|
|
30787
30819
|
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
30788
30820
|
braces++;
|
|
30789
|
-
while (eos() !== true && (code =
|
|
30821
|
+
while (eos() !== true && (code = advance3())) {
|
|
30790
30822
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30791
30823
|
backslashes = token.backslashes = true;
|
|
30792
|
-
|
|
30824
|
+
advance3();
|
|
30793
30825
|
continue;
|
|
30794
30826
|
}
|
|
30795
30827
|
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
30796
30828
|
braces++;
|
|
30797
30829
|
continue;
|
|
30798
30830
|
}
|
|
30799
|
-
if (braceEscaped !== true && code === CHAR_DOT && (code =
|
|
30831
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance3()) === CHAR_DOT) {
|
|
30800
30832
|
isBrace = token.isBrace = true;
|
|
30801
30833
|
isGlob = token.isGlob = true;
|
|
30802
30834
|
finished = true;
|
|
@@ -30852,10 +30884,10 @@ var require_scan = __commonJS({
|
|
|
30852
30884
|
}
|
|
30853
30885
|
if (scanToEnd === true) {
|
|
30854
30886
|
let parens = 0;
|
|
30855
|
-
while (eos() !== true && (code =
|
|
30887
|
+
while (eos() !== true && (code = advance3())) {
|
|
30856
30888
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30857
30889
|
backslashes = token.backslashes = true;
|
|
30858
|
-
|
|
30890
|
+
advance3();
|
|
30859
30891
|
continue;
|
|
30860
30892
|
}
|
|
30861
30893
|
if (code === CHAR_LEFT_PARENTHESES) {
|
|
@@ -30890,10 +30922,10 @@ var require_scan = __commonJS({
|
|
|
30890
30922
|
break;
|
|
30891
30923
|
}
|
|
30892
30924
|
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
30893
|
-
while (eos() !== true && (next =
|
|
30925
|
+
while (eos() !== true && (next = advance3())) {
|
|
30894
30926
|
if (next === CHAR_BACKWARD_SLASH) {
|
|
30895
30927
|
backslashes = token.backslashes = true;
|
|
30896
|
-
|
|
30928
|
+
advance3();
|
|
30897
30929
|
continue;
|
|
30898
30930
|
}
|
|
30899
30931
|
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
@@ -30917,10 +30949,10 @@ var require_scan = __commonJS({
|
|
|
30917
30949
|
isGlob = token.isGlob = true;
|
|
30918
30950
|
if (scanToEnd === true) {
|
|
30919
30951
|
let parens = 1;
|
|
30920
|
-
while (eos() !== true && (code =
|
|
30952
|
+
while (eos() !== true && (code = advance3())) {
|
|
30921
30953
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30922
30954
|
backslashes = token.backslashes = true;
|
|
30923
|
-
|
|
30955
|
+
advance3();
|
|
30924
30956
|
continue;
|
|
30925
30957
|
}
|
|
30926
30958
|
if (code === CHAR_LEFT_PARENTHESES) {
|
|
@@ -31356,7 +31388,7 @@ var require_parse = __commonJS({
|
|
|
31356
31388
|
let value2;
|
|
31357
31389
|
const eos = () => state.index === len - 1;
|
|
31358
31390
|
const peek = state.peek = (n10 = 1) => input2[state.index + n10];
|
|
31359
|
-
const
|
|
31391
|
+
const advance3 = state.advance = () => input2[++state.index] || "";
|
|
31360
31392
|
const remaining = () => input2.slice(state.index + 1);
|
|
31361
31393
|
const consume = (value3 = "", num = 0) => {
|
|
31362
31394
|
state.consumed += value3;
|
|
@@ -31367,13 +31399,13 @@ var require_parse = __commonJS({
|
|
|
31367
31399
|
consume(token.value);
|
|
31368
31400
|
};
|
|
31369
31401
|
const negate = () => {
|
|
31370
|
-
let
|
|
31402
|
+
let count2 = 1;
|
|
31371
31403
|
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
31372
|
-
|
|
31404
|
+
advance3();
|
|
31373
31405
|
state.start++;
|
|
31374
|
-
|
|
31406
|
+
count2++;
|
|
31375
31407
|
}
|
|
31376
|
-
if (
|
|
31408
|
+
if (count2 % 2 === 0) {
|
|
31377
31409
|
return false;
|
|
31378
31410
|
}
|
|
31379
31411
|
state.negated = true;
|
|
@@ -31423,7 +31455,7 @@ var require_parse = __commonJS({
|
|
|
31423
31455
|
const output2 = (opts.capture ? "(" : "") + token.open;
|
|
31424
31456
|
increment("parens");
|
|
31425
31457
|
push({ type: type2, value: value3, output: state.output ? "" : ONE_CHAR });
|
|
31426
|
-
push({ type: "paren", extglob: true, value:
|
|
31458
|
+
push({ type: "paren", extglob: true, value: advance3(), output: output2 });
|
|
31427
31459
|
extglobs.push(token);
|
|
31428
31460
|
};
|
|
31429
31461
|
const extglobClose = (token) => {
|
|
@@ -31512,7 +31544,7 @@ var require_parse = __commonJS({
|
|
|
31512
31544
|
return state;
|
|
31513
31545
|
}
|
|
31514
31546
|
while (!eos()) {
|
|
31515
|
-
value2 =
|
|
31547
|
+
value2 = advance3();
|
|
31516
31548
|
if (value2 === "\0") {
|
|
31517
31549
|
continue;
|
|
31518
31550
|
}
|
|
@@ -31539,9 +31571,9 @@ var require_parse = __commonJS({
|
|
|
31539
31571
|
}
|
|
31540
31572
|
}
|
|
31541
31573
|
if (opts.unescape === true) {
|
|
31542
|
-
value2 =
|
|
31574
|
+
value2 = advance3();
|
|
31543
31575
|
} else {
|
|
31544
|
-
value2 +=
|
|
31576
|
+
value2 += advance3();
|
|
31545
31577
|
}
|
|
31546
31578
|
if (state.brackets === 0) {
|
|
31547
31579
|
push({ type: "text", value: value2 });
|
|
@@ -31561,7 +31593,7 @@ var require_parse = __commonJS({
|
|
|
31561
31593
|
if (posix) {
|
|
31562
31594
|
prev.value = pre2 + posix;
|
|
31563
31595
|
state.backtrack = true;
|
|
31564
|
-
|
|
31596
|
+
advance3();
|
|
31565
31597
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
31566
31598
|
bos.output = ONE_CHAR;
|
|
31567
31599
|
}
|
|
@@ -31897,7 +31929,7 @@ var require_parse = __commonJS({
|
|
|
31897
31929
|
prev.value += value2;
|
|
31898
31930
|
state.output += prior.output + prev.output;
|
|
31899
31931
|
state.globstar = true;
|
|
31900
|
-
consume(value2 +
|
|
31932
|
+
consume(value2 + advance3());
|
|
31901
31933
|
push({ type: "slash", value: "/", output: "" });
|
|
31902
31934
|
continue;
|
|
31903
31935
|
}
|
|
@@ -31907,7 +31939,7 @@ var require_parse = __commonJS({
|
|
|
31907
31939
|
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
31908
31940
|
state.output = prev.output;
|
|
31909
31941
|
state.globstar = true;
|
|
31910
|
-
consume(value2 +
|
|
31942
|
+
consume(value2 + advance3());
|
|
31911
31943
|
push({ type: "slash", value: "/", output: "" });
|
|
31912
31944
|
continue;
|
|
31913
31945
|
}
|
|
@@ -32462,8 +32494,10 @@ function valueAt(source, path72) {
|
|
|
32462
32494
|
}
|
|
32463
32495
|
return current;
|
|
32464
32496
|
}
|
|
32465
|
-
function keyOf(path72,
|
|
32466
|
-
const
|
|
32497
|
+
function keyOf(path72, declared) {
|
|
32498
|
+
const optional2 = declared instanceof external_exports.ZodOptional;
|
|
32499
|
+
const leaf = optional2 ? declared.unwrap() : declared;
|
|
32500
|
+
const common = { path: path72.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path72), optional: optional2 };
|
|
32467
32501
|
if (leaf instanceof external_exports.ZodNumber) {
|
|
32468
32502
|
return { ...common, kind: "integer", choices: [] };
|
|
32469
32503
|
}
|
|
@@ -32493,7 +32527,7 @@ function statuslineKeys() {
|
|
|
32493
32527
|
function formatStatuslineKeys(keys) {
|
|
32494
32528
|
return keys.map((key) => {
|
|
32495
32529
|
const takes = key.kind === "choice" || key.kind === "list" || key.kind === "colour" ? `${key.kind} of ${key.choices.join(", ")}` : key.kind;
|
|
32496
|
-
return `${key.path} (${takes}; default ${JSON.stringify(key.defaultValue)})
|
|
32530
|
+
return `${key.path} (${takes}; ${key.optional ? "no default; none unsets it over shallower layers" : `default ${JSON.stringify(key.defaultValue)}`})
|
|
32497
32531
|
${key.description}`;
|
|
32498
32532
|
}).join("\n");
|
|
32499
32533
|
}
|
|
@@ -32521,6 +32555,9 @@ function parseStatuslineAssignment(text5) {
|
|
|
32521
32555
|
const path72 = text5.slice(0, split);
|
|
32522
32556
|
const raw = text5.slice(split + 1);
|
|
32523
32557
|
const key = keyNamed(path72);
|
|
32558
|
+
if (key.optional && raw === UNSET_WORD) {
|
|
32559
|
+
return { path: path72, value: null };
|
|
32560
|
+
}
|
|
32524
32561
|
switch (key.kind) {
|
|
32525
32562
|
case "integer": {
|
|
32526
32563
|
const number6 = Number(raw);
|
|
@@ -32592,12 +32629,14 @@ function applyStatuslineChange(existing, change) {
|
|
|
32592
32629
|
}
|
|
32593
32630
|
return Object.keys(result.data).length === 0 ? void 0 : result.data;
|
|
32594
32631
|
}
|
|
32632
|
+
var UNSET_WORD;
|
|
32595
32633
|
var init_change = __esm({
|
|
32596
32634
|
"src/statusline/change.ts"() {
|
|
32597
32635
|
"use strict";
|
|
32598
32636
|
init_cliError();
|
|
32599
32637
|
init_statusline();
|
|
32600
32638
|
init_keys();
|
|
32639
|
+
UNSET_WORD = "none";
|
|
32601
32640
|
}
|
|
32602
32641
|
});
|
|
32603
32642
|
|
|
@@ -33281,15 +33320,15 @@ function parseDuration(value2) {
|
|
|
33281
33320
|
if (parts === null) {
|
|
33282
33321
|
throw new Error(`"${value2}" is not a valid duration. Expected a count followed by ms, s, m, h, d, or w.`);
|
|
33283
33322
|
}
|
|
33284
|
-
const [,
|
|
33285
|
-
if (
|
|
33323
|
+
const [, count2, unit] = parts;
|
|
33324
|
+
if (count2 === void 0 || unit === void 0) {
|
|
33286
33325
|
throw new Error(`"${value2}" is not a valid duration.`);
|
|
33287
33326
|
}
|
|
33288
33327
|
const multiplier = MILLISECONDS_PER_UNIT[unit];
|
|
33289
33328
|
if (multiplier === void 0) {
|
|
33290
33329
|
throw new Error(`"${value2}" is not a valid duration.`);
|
|
33291
33330
|
}
|
|
33292
|
-
return Number(
|
|
33331
|
+
return Number(count2) * multiplier;
|
|
33293
33332
|
}
|
|
33294
33333
|
function windowValues(prefix, windows) {
|
|
33295
33334
|
const values = {};
|
|
@@ -35765,12 +35804,12 @@ function readElement(buffer2, offset) {
|
|
|
35765
35804
|
let length = first;
|
|
35766
35805
|
let contentStart = offset + 2;
|
|
35767
35806
|
if ((first & HIGH_BIT) !== 0) {
|
|
35768
|
-
const
|
|
35807
|
+
const count2 = first & BASE_128_PAYLOAD_MASK;
|
|
35769
35808
|
length = 0;
|
|
35770
|
-
for (let index = 0; index <
|
|
35809
|
+
for (let index = 0; index < count2; index += 1) {
|
|
35771
35810
|
length = length * (BYTE_MASK + 1) + (buffer2[offset + 2 + index] ?? 0);
|
|
35772
35811
|
}
|
|
35773
|
-
contentStart = offset + 2 +
|
|
35812
|
+
contentStart = offset + 2 + count2;
|
|
35774
35813
|
}
|
|
35775
35814
|
return { tag, start: offset, contentStart, end: contentStart + length };
|
|
35776
35815
|
}
|
|
@@ -36818,7 +36857,7 @@ var init_package = __esm({
|
|
|
36818
36857
|
"package.json"() {
|
|
36819
36858
|
package_default = {
|
|
36820
36859
|
name: "claude-use",
|
|
36821
|
-
version: "11.
|
|
36860
|
+
version: "11.59.0",
|
|
36822
36861
|
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.",
|
|
36823
36862
|
license: "MIT",
|
|
36824
36863
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -37556,7 +37595,7 @@ function utilisationPerBilledToken(records) {
|
|
|
37556
37595
|
if (first === void 0 || last === void 0 || last.utilization <= first.utilization) {
|
|
37557
37596
|
return void 0;
|
|
37558
37597
|
}
|
|
37559
|
-
const billed = current.slice(1).reduce((
|
|
37598
|
+
const billed = current.slice(1).reduce((sum2, point) => sum2 + point.billed, 0);
|
|
37560
37599
|
return billed > 0 ? (last.utilization - first.utilization) / billed : void 0;
|
|
37561
37600
|
}
|
|
37562
37601
|
function windowRatio(records) {
|
|
@@ -37920,7 +37959,7 @@ function summariseUsage(records) {
|
|
|
37920
37959
|
modelCounts.set(record2.model, (modelCounts.get(record2.model) ?? 0) + 1);
|
|
37921
37960
|
}
|
|
37922
37961
|
}
|
|
37923
|
-
const
|
|
37962
|
+
const sum2 = (field) => group.reduce((total, record2) => total + (record2.usage?.[field] ?? 0), 0);
|
|
37924
37963
|
return [
|
|
37925
37964
|
{
|
|
37926
37965
|
identity: first.identity,
|
|
@@ -37932,10 +37971,10 @@ function summariseUsage(records) {
|
|
|
37932
37971
|
"quota-exhausted": group.filter((record2) => record2.limit?.kind === "quota-exhausted").length
|
|
37933
37972
|
},
|
|
37934
37973
|
tokens: {
|
|
37935
|
-
inputTokens:
|
|
37936
|
-
outputTokens:
|
|
37937
|
-
cacheCreationInputTokens:
|
|
37938
|
-
cacheReadInputTokens:
|
|
37974
|
+
inputTokens: sum2("inputTokens"),
|
|
37975
|
+
outputTokens: sum2("outputTokens"),
|
|
37976
|
+
cacheCreationInputTokens: sum2("cacheCreationInputTokens"),
|
|
37977
|
+
cacheReadInputTokens: sum2("cacheReadInputTokens")
|
|
37939
37978
|
},
|
|
37940
37979
|
firstAt: first.at,
|
|
37941
37980
|
lastAt: last.at,
|
|
@@ -64567,15 +64606,15 @@ ${value2}`;
|
|
|
64567
64606
|
pos = 0;
|
|
64568
64607
|
}
|
|
64569
64608
|
}
|
|
64570
|
-
discardLeadingBytes(
|
|
64571
|
-
while (
|
|
64609
|
+
discardLeadingBytes(count2) {
|
|
64610
|
+
while (count2 > 0 && this.lineChunkIndex < this.chunks.length) {
|
|
64572
64611
|
const chunk2 = this.chunks[this.lineChunkIndex];
|
|
64573
64612
|
const remaining = chunk2.length - this.linePos;
|
|
64574
|
-
if (
|
|
64575
|
-
this.linePos +=
|
|
64576
|
-
|
|
64613
|
+
if (count2 < remaining) {
|
|
64614
|
+
this.linePos += count2;
|
|
64615
|
+
count2 = 0;
|
|
64577
64616
|
} else {
|
|
64578
|
-
|
|
64617
|
+
count2 -= remaining;
|
|
64579
64618
|
this.lineChunkIndex++;
|
|
64580
64619
|
this.linePos = 0;
|
|
64581
64620
|
}
|
|
@@ -66746,7 +66785,7 @@ function routingRows(facts) {
|
|
|
66746
66785
|
];
|
|
66747
66786
|
}
|
|
66748
66787
|
function farmRow(links, builtDirectories, adopted) {
|
|
66749
|
-
const counted2 = (
|
|
66788
|
+
const counted2 = (count2, singular, plural2) => `${String(count2)} ${count2 === 1 ? singular : plural2}`;
|
|
66750
66789
|
const parts = [counted2(links, "link", "links"), counted2(builtDirectories, "built directory", "built directories"), ...adopted === 0 ? [] : [`${String(adopted)} adopted`]];
|
|
66751
66790
|
return { label: "farm", value: "resynced", detail: parts.join(", ") };
|
|
66752
66791
|
}
|
|
@@ -105291,20 +105330,20 @@ var require_resolve = __commonJS({
|
|
|
105291
105330
|
return false;
|
|
105292
105331
|
}
|
|
105293
105332
|
function countKeys(schema) {
|
|
105294
|
-
let
|
|
105333
|
+
let count2 = 0;
|
|
105295
105334
|
for (const key in schema) {
|
|
105296
105335
|
if (key === "$ref")
|
|
105297
105336
|
return Infinity;
|
|
105298
|
-
|
|
105337
|
+
count2++;
|
|
105299
105338
|
if (SIMPLE_INLINED.has(key))
|
|
105300
105339
|
continue;
|
|
105301
105340
|
if (typeof schema[key] == "object") {
|
|
105302
|
-
(0, util_1.eachItem)(schema[key], (sch) =>
|
|
105341
|
+
(0, util_1.eachItem)(schema[key], (sch) => count2 += countKeys(sch));
|
|
105303
105342
|
}
|
|
105304
|
-
if (
|
|
105343
|
+
if (count2 === Infinity)
|
|
105305
105344
|
return Infinity;
|
|
105306
105345
|
}
|
|
105307
|
-
return
|
|
105346
|
+
return count2;
|
|
105308
105347
|
}
|
|
105309
105348
|
function getFullPath(resolver, id2 = "", normalize) {
|
|
105310
105349
|
if (normalize !== false)
|
|
@@ -108786,8 +108825,8 @@ var require_contains = __commonJS({
|
|
|
108786
108825
|
cxt.result(valid, () => cxt.reset());
|
|
108787
108826
|
function validateItemsWithCount() {
|
|
108788
108827
|
const schValid = gen.name("_valid");
|
|
108789
|
-
const
|
|
108790
|
-
validateItems(schValid, () => gen.if(schValid, () => checkLimits(
|
|
108828
|
+
const count2 = gen.let("count", 0);
|
|
108829
|
+
validateItems(schValid, () => gen.if(schValid, () => checkLimits(count2)));
|
|
108791
108830
|
}
|
|
108792
108831
|
function validateItems(_valid, block2) {
|
|
108793
108832
|
gen.forRange("i", 0, len, (i10) => {
|
|
@@ -108800,16 +108839,16 @@ var require_contains = __commonJS({
|
|
|
108800
108839
|
block2();
|
|
108801
108840
|
});
|
|
108802
108841
|
}
|
|
108803
|
-
function checkLimits(
|
|
108804
|
-
gen.code((0, codegen_1._)`${
|
|
108842
|
+
function checkLimits(count2) {
|
|
108843
|
+
gen.code((0, codegen_1._)`${count2}++`);
|
|
108805
108844
|
if (max === void 0) {
|
|
108806
|
-
gen.if((0, codegen_1._)`${
|
|
108845
|
+
gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true).break());
|
|
108807
108846
|
} else {
|
|
108808
|
-
gen.if((0, codegen_1._)`${
|
|
108847
|
+
gen.if((0, codegen_1._)`${count2} > ${max}`, () => gen.assign(valid, false).break());
|
|
108809
108848
|
if (min === 1)
|
|
108810
108849
|
gen.assign(valid, true);
|
|
108811
108850
|
else
|
|
108812
|
-
gen.if((0, codegen_1._)`${
|
|
108851
|
+
gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true));
|
|
108813
108852
|
}
|
|
108814
108853
|
}
|
|
108815
108854
|
}
|
|
@@ -118532,9 +118571,9 @@ function observationOf(records) {
|
|
|
118532
118571
|
const completed = records.filter((record2) => record2.outcome === "completed");
|
|
118533
118572
|
const latencies = completed.map((record2) => record2.latencyMs);
|
|
118534
118573
|
const usage = records.flatMap((record2) => record2.usage === void 0 ? [] : [record2.usage]);
|
|
118535
|
-
const input2 = usage.reduce((
|
|
118536
|
-
const output2 = usage.reduce((
|
|
118537
|
-
const cacheRead = usage.reduce((
|
|
118574
|
+
const input2 = usage.reduce((sum2, entry) => sum2 + (entry.inputTokens ?? 0), 0);
|
|
118575
|
+
const output2 = usage.reduce((sum2, entry) => sum2 + (entry.outputTokens ?? 0), 0);
|
|
118576
|
+
const cacheRead = usage.reduce((sum2, entry) => sum2 + (entry.cacheReadInputTokens ?? 0), 0);
|
|
118538
118577
|
return {
|
|
118539
118578
|
latencyMs: median(latencies),
|
|
118540
118579
|
successRate: records.length === 0 ? void 0 : completed.length / records.length,
|
|
@@ -119465,13 +119504,13 @@ function usageOf(record2) {
|
|
|
119465
119504
|
if (!isRecord10(raw)) {
|
|
119466
119505
|
return void 0;
|
|
119467
119506
|
}
|
|
119468
|
-
const
|
|
119507
|
+
const totalTokens2 = numberField(raw, "total_tokens");
|
|
119469
119508
|
const toolUses = numberField(raw, "tool_uses");
|
|
119470
119509
|
const durationMs = numberField(raw, "duration_ms");
|
|
119471
|
-
if (
|
|
119510
|
+
if (totalTokens2 === void 0 && toolUses === void 0 && durationMs === void 0) {
|
|
119472
119511
|
return void 0;
|
|
119473
119512
|
}
|
|
119474
|
-
return { ...
|
|
119513
|
+
return { ...totalTokens2 === void 0 ? {} : { totalTokens: totalTokens2 }, ...toolUses === void 0 ? {} : { toolUses }, ...durationMs === void 0 ? {} : { durationMs } };
|
|
119475
119514
|
}
|
|
119476
119515
|
function overlay(base, fields) {
|
|
119477
119516
|
const defined = Object.fromEntries(Object.entries(fields).filter(([, value2]) => value2 !== void 0));
|
|
@@ -136605,7 +136644,9 @@ init_probe();
|
|
|
136605
136644
|
var DOOR_STALL_BOUND_MS = 2 * FRONTDOOR_PROBE_ATTEMPTS * PROBE_TIMEOUT_MS;
|
|
136606
136645
|
var DOOR_AWAIT_PID_ENV = "AGENT_SHIM_FRONTDOOR_AWAIT_PID";
|
|
136607
136646
|
var DOOR_RESPAWN_GENERATION_ENV = "AGENT_SHIM_FRONTDOOR_RESPAWN_GENERATION";
|
|
136647
|
+
var DOOR_RESPAWN_DELAY_ENV = "AGENT_SHIM_FRONTDOOR_RESPAWN_DELAY_MS";
|
|
136608
136648
|
var DOOR_RESPAWN_MAX_GENERATIONS = 3;
|
|
136649
|
+
var DOOR_RESPAWN_COOLDOWN_CAP_MS = DOOR_STALL_BOUND_MS * DOOR_RESPAWN_MAX_GENERATIONS;
|
|
136609
136650
|
var CHECKS_PER_PROBE_DEADLINE = 2;
|
|
136610
136651
|
var DOOR_WATCHDOG_CHECK_MS = PROBE_TIMEOUT_MS / CHECKS_PER_PROBE_DEADLINE;
|
|
136611
136652
|
var WATCHDOG_SOURCE = `
|
|
@@ -136613,7 +136654,7 @@ const { workerData, parentPort } = require("node:worker_threads");
|
|
|
136613
136654
|
const fs = require("node:fs");
|
|
136614
136655
|
const os = require("node:os");
|
|
136615
136656
|
const inspector = require("node:inspector");
|
|
136616
|
-
const { shared, boundMs, checkEveryMs, pauseWaitMs, stateFile, ownPid, action, logFile, respawn, respawnGeneration, respawnMaxGeneration, startLockFile, awaitPidEnv, respawnGenerationEnv } = workerData;
|
|
136657
|
+
const { shared, boundMs, checkEveryMs, pauseWaitMs, stateFile, ownPid, action, logFile, respawn, respawnGeneration, respawnMaxGeneration, cooldownStepMs, cooldownCapMs, startLockFile, awaitPidEnv, respawnGenerationEnv, delayEnv, nativeSample } = workerData;
|
|
136617
136658
|
const counter = new Int32Array(shared);
|
|
136618
136659
|
let lastValue = Atomics.load(counter, 0);
|
|
136619
136660
|
let lastChangeAt = Date.now();
|
|
@@ -136710,10 +136751,8 @@ const claimStartLock = (holder) => {
|
|
|
136710
136751
|
};
|
|
136711
136752
|
const spawnReplacement = () => {
|
|
136712
136753
|
if (respawn === undefined || logFile === undefined) return;
|
|
136713
|
-
|
|
136714
|
-
|
|
136715
|
-
return;
|
|
136716
|
-
}
|
|
136754
|
+
const nextGeneration = respawnGeneration + 1;
|
|
136755
|
+
const cooldownMs = Math.min(Math.max(0, nextGeneration - respawnMaxGeneration) * cooldownStepMs, cooldownCapMs);
|
|
136717
136756
|
const startingBy = liveLockHolder();
|
|
136718
136757
|
if (startingBy !== undefined) {
|
|
136719
136758
|
log("not starting a replacement: process " + String(startingBy) + " holds the start lock, so a door is already being started and a second one would race it for the sticky ports");
|
|
@@ -136721,7 +136760,7 @@ const spawnReplacement = () => {
|
|
|
136721
136760
|
}
|
|
136722
136761
|
try {
|
|
136723
136762
|
const out = fs.openSync(logFile, "a");
|
|
136724
|
-
const child = require("node:child_process").spawn(respawn.command, respawn.args, { detached: true, stdio: ["ignore", out, out], env: Object.assign({}, respawn.env, { [awaitPidEnv]: String(ownPid), [respawnGenerationEnv]: String(
|
|
136763
|
+
const child = require("node:child_process").spawn(respawn.command, respawn.args, { detached: true, stdio: ["ignore", out, out], env: Object.assign({}, respawn.env, { [awaitPidEnv]: String(ownPid), [respawnGenerationEnv]: String(nextGeneration), [delayEnv]: String(cooldownMs) }) });
|
|
136725
136764
|
child.unref();
|
|
136726
136765
|
fs.closeSync(out);
|
|
136727
136766
|
if (!claimStartLock(child.pid)) {
|
|
@@ -136730,11 +136769,33 @@ const spawnReplacement = () => {
|
|
|
136730
136769
|
log("withdrew replacement door " + String(child.pid) + ": a launcher took the start lock first and its door is the one starting");
|
|
136731
136770
|
return;
|
|
136732
136771
|
}
|
|
136733
|
-
log("started replacement door " + String(child.pid) + " of generation " + String(
|
|
136772
|
+
log("started replacement door " + String(child.pid) + " of generation " + String(nextGeneration) + ", which binds once this process is gone" + (cooldownMs > 0 ? " and a " + String(cooldownMs) + "ms cooldown has passed, since the stall has recurred through " + String(respawnMaxGeneration) + " consecutive replacements" : ""));
|
|
136734
136773
|
} catch (error) {
|
|
136735
136774
|
log("could not start a replacement door: " + (error instanceof Error ? error.message : String(error)));
|
|
136736
136775
|
}
|
|
136737
136776
|
};
|
|
136777
|
+
// Captures where a main thread that could not be paused is held natively, with the platform's own sampler, so a stall the inspector cannot name still leaves a stack to read. The wait is bounded by the sampling time plus its start-up, and the capture never delays the process ending beyond that.
|
|
136778
|
+
const takeNativeSample = () => new Promise((resolve) => {
|
|
136779
|
+
if (nativeSample === undefined) { resolve(); return; }
|
|
136780
|
+
try {
|
|
136781
|
+
fs.mkdirSync(nativeSample.directory, { recursive: true });
|
|
136782
|
+
const file = require("node:path").join(nativeSample.directory, String(ownPid) + ".txt");
|
|
136783
|
+
const args = nativeSample.args.map((arg) => arg.replace("{pid}", String(ownPid)).replace("{seconds}", String(nativeSample.seconds)).replace("{file}", file));
|
|
136784
|
+
const child = require("node:child_process").spawn(nativeSample.command, args, { stdio: "ignore" });
|
|
136785
|
+
const giveUp = setTimeout(() => { child.kill(); log("the native sampler did not finish in time"); resolve(); }, (nativeSample.seconds + 2) * 1000);
|
|
136786
|
+
child.once("error", (error) => { clearTimeout(giveUp); log("could not sample the main thread natively: " + error.message); resolve(); });
|
|
136787
|
+
child.once("close", () => {
|
|
136788
|
+
clearTimeout(giveUp);
|
|
136789
|
+
log("native stack of the blocked main thread written to " + file);
|
|
136790
|
+
const kept = fs.readdirSync(nativeSample.directory).filter((name) => name.endsWith(".txt")).map((name) => ({ name, at: fs.statSync(require("node:path").join(nativeSample.directory, name)).mtimeMs })).sort((a, b) => b.at - a.at);
|
|
136791
|
+
for (const old of kept.slice(nativeSample.keep)) fs.rmSync(require("node:path").join(nativeSample.directory, old.name), { force: true });
|
|
136792
|
+
resolve();
|
|
136793
|
+
});
|
|
136794
|
+
} catch (error) {
|
|
136795
|
+
log("could not sample the main thread natively: " + (error instanceof Error ? error.message : String(error)));
|
|
136796
|
+
resolve();
|
|
136797
|
+
}
|
|
136798
|
+
});
|
|
136738
136799
|
const timer = setInterval(() => {
|
|
136739
136800
|
if (stopped) return;
|
|
136740
136801
|
const now = Date.now();
|
|
@@ -136755,8 +136816,9 @@ const timer = setInterval(() => {
|
|
|
136755
136816
|
const [oneMinute, fiveMinutes, fifteenMinutes] = os.loadavg();
|
|
136756
136817
|
log("machine load at the stall: " + oneMinute.toFixed(1) + " (1m), " + fiveMinutes.toFixed(1) + " (5m), " + fifteenMinutes.toFixed(1) + " (15m) across " + String(os.cpus().length) + " cpus");
|
|
136757
136818
|
spawnReplacement();
|
|
136758
|
-
describeMainThread(pauseWaitMs, action !== "kill-process").then((where) => {
|
|
136819
|
+
describeMainThread(pauseWaitMs, action !== "kill-process").then(async (where) => {
|
|
136759
136820
|
log(where);
|
|
136821
|
+
if (where.startsWith("the main thread could not be paused")) await takeNativeSample();
|
|
136760
136822
|
if (action === "kill-process") {
|
|
136761
136823
|
process.kill(ownPid, "SIGKILL");
|
|
136762
136824
|
} else {
|
|
@@ -136778,7 +136840,7 @@ function startThreadWatchdog(params) {
|
|
|
136778
136840
|
const counter = new Int32Array(shared);
|
|
136779
136841
|
const worker = new import_node_worker_threads2.Worker(WATCHDOG_SOURCE, {
|
|
136780
136842
|
eval: true,
|
|
136781
|
-
workerData: { shared, boundMs: params.boundMs, checkEveryMs: params.checkEveryMs, pauseWaitMs: params.pauseWaitMs, stateFile: params.stateFile, ownPid: params.ownPid, action: params.action, logFile: params.logFile, respawn: params.respawn, respawnGeneration: params.respawnGeneration, respawnMaxGeneration: params.respawnMaxGeneration, startLockFile: params.startLockFile, awaitPidEnv: DOOR_AWAIT_PID_ENV, respawnGenerationEnv: DOOR_RESPAWN_GENERATION_ENV }
|
|
136843
|
+
workerData: { shared, boundMs: params.boundMs, checkEveryMs: params.checkEveryMs, pauseWaitMs: params.pauseWaitMs, stateFile: params.stateFile, ownPid: params.ownPid, action: params.action, logFile: params.logFile, respawn: params.respawn, respawnGeneration: params.respawnGeneration, respawnMaxGeneration: params.respawnMaxGeneration, cooldownStepMs: params.cooldownStepMs, cooldownCapMs: params.cooldownCapMs, startLockFile: params.startLockFile, awaitPidEnv: DOOR_AWAIT_PID_ENV, respawnGenerationEnv: DOOR_RESPAWN_GENERATION_ENV, delayEnv: DOOR_RESPAWN_DELAY_ENV, nativeSample: params.nativeSample }
|
|
136782
136844
|
});
|
|
136783
136845
|
worker.unref();
|
|
136784
136846
|
worker.on("message", (message) => {
|
|
@@ -136911,6 +136973,12 @@ function createRealQuotaRefresher(params) {
|
|
|
136911
136973
|
|
|
136912
136974
|
// src/frontdoor/commands.ts
|
|
136913
136975
|
init_store2();
|
|
136976
|
+
var MACOS_SAMPLER = "/usr/bin/sample";
|
|
136977
|
+
var MS_PER_SECOND16 = 1e3;
|
|
136978
|
+
function readRespawnDelayMs() {
|
|
136979
|
+
const delay = Number(process.env[DOOR_RESPAWN_DELAY_ENV]);
|
|
136980
|
+
return Number.isInteger(delay) && delay > 0 ? delay : 0;
|
|
136981
|
+
}
|
|
136914
136982
|
function readRespawnGeneration() {
|
|
136915
136983
|
const generation = Number(process.env[DOOR_RESPAWN_GENERATION_ENV]);
|
|
136916
136984
|
return Number.isInteger(generation) && generation > 0 ? generation : 0;
|
|
@@ -137378,7 +137446,10 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, retire, trackTun
|
|
|
137378
137446
|
respawn: respawnInvocation(paths),
|
|
137379
137447
|
respawnGeneration,
|
|
137380
137448
|
respawnMaxGeneration: DOOR_RESPAWN_MAX_GENERATIONS,
|
|
137381
|
-
|
|
137449
|
+
cooldownStepMs: DOOR_STALL_BOUND_MS,
|
|
137450
|
+
cooldownCapMs: DOOR_RESPAWN_COOLDOWN_CAP_MS,
|
|
137451
|
+
startLockFile: paths.frontdoorLockFile,
|
|
137452
|
+
...process.platform === "darwin" ? { nativeSample: { command: MACOS_SAMPLER, args: ["{pid}", "{seconds}", "-file", "{file}"], directory: import_node_path54.default.join(import_node_path54.default.dirname(paths.frontdoorLogPath), "stall-samples"), seconds: Math.max(1, Math.ceil(DOOR_WATCHDOG_CHECK_MS / MS_PER_SECOND16)), keep: DOOR_RESPAWN_MAX_GENERATIONS + 1 } } : {}
|
|
137382
137453
|
}),
|
|
137383
137454
|
// The launch lifecycle publisher over the same backbone the typed API serves: the tick's registry facts go in here, and the door's own register, prune and end moments come out as source-tagged events.
|
|
137384
137455
|
observeLaunchRegistry: createLaunchEventPublisher(doorEvents, () => Date.now()).observe,
|
|
@@ -137432,12 +137503,14 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
137432
137503
|
const idleShutdownMinutes = readGlobalConfig(paths)?.frontdoor?.idleShutdownMinutes ?? FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES;
|
|
137433
137504
|
const awaited = Number(process.env[DOOR_AWAIT_PID_ENV]);
|
|
137434
137505
|
const respawnGeneration = readRespawnGeneration();
|
|
137506
|
+
const respawnDelayMs = readRespawnDelayMs();
|
|
137435
137507
|
Reflect.deleteProperty(process.env, DOOR_AWAIT_PID_ENV);
|
|
137436
137508
|
Reflect.deleteProperty(process.env, DOOR_RESPAWN_GENERATION_ENV);
|
|
137509
|
+
Reflect.deleteProperty(process.env, DOOR_RESPAWN_DELAY_ENV);
|
|
137437
137510
|
const retire = new AbortController();
|
|
137438
137511
|
let openTunnels = () => 0;
|
|
137439
|
-
const supervisorPorts = realFrontDoorSupervisorPorts(paths, respawnGeneration, retire.signal, (
|
|
137440
|
-
openTunnels =
|
|
137512
|
+
const supervisorPorts = realFrontDoorSupervisorPorts(paths, respawnGeneration, retire.signal, (count2) => {
|
|
137513
|
+
openTunnels = count2;
|
|
137441
137514
|
});
|
|
137442
137515
|
const ownPid = process.pid;
|
|
137443
137516
|
process.on("exit", (code) => {
|
|
@@ -137461,6 +137534,10 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
137461
137534
|
const waitedMs = await awaitPidExit(awaited, supervisorPorts);
|
|
137462
137535
|
supervisorPorts.log(`frontdoor ${String(ownPid)}: stalled door ${String(awaited)} released the sticky ports after ${String(waitedMs)}ms`);
|
|
137463
137536
|
}
|
|
137537
|
+
if (respawnDelayMs > 0) {
|
|
137538
|
+
supervisorPorts.log(`frontdoor ${String(ownPid)}: waiting ${String(respawnDelayMs)}ms before binding, since the stall has recurred through every immediate replacement`);
|
|
137539
|
+
await supervisorPorts.sleep(respawnDelayMs);
|
|
137540
|
+
}
|
|
137464
137541
|
declareThisProcessTheFrontDoor();
|
|
137465
137542
|
deps.exit(await runFrontDoorSupervisor(idleShutdownMinutes, supervisorPorts));
|
|
137466
137543
|
});
|
|
@@ -137574,7 +137651,7 @@ var realHeadroomGet = async (target, requestPath, timeoutMs) => {
|
|
|
137574
137651
|
// src/statusline/enrich.ts
|
|
137575
137652
|
init_quota();
|
|
137576
137653
|
var FULL_PERCENT2 = 100;
|
|
137577
|
-
var
|
|
137654
|
+
var MS_PER_SECOND17 = 1e3;
|
|
137578
137655
|
function identityOf(env) {
|
|
137579
137656
|
const headers = env.ANTHROPIC_CUSTOM_HEADERS;
|
|
137580
137657
|
if (headers !== void 0) {
|
|
@@ -137638,7 +137715,7 @@ function payloadWindow(rateLimits, key) {
|
|
|
137638
137715
|
const resetsAt = window.resets_at;
|
|
137639
137716
|
return {
|
|
137640
137717
|
used: Math.min(FULL_PERCENT2, Math.max(0, window.used_percentage)),
|
|
137641
|
-
resetAt: typeof resetsAt === "number" && Number.isFinite(resetsAt) ? new Date(resetsAt *
|
|
137718
|
+
resetAt: typeof resetsAt === "number" && Number.isFinite(resetsAt) ? new Date(resetsAt * MS_PER_SECOND17).toISOString() : void 0
|
|
137642
137719
|
};
|
|
137643
137720
|
}
|
|
137644
137721
|
function payloadWindowsOf(payload) {
|
|
@@ -137666,7 +137743,7 @@ function antigravityQuotaMapOf(payload) {
|
|
|
137666
137743
|
function bucketView(bucket, nowMs) {
|
|
137667
137744
|
return {
|
|
137668
137745
|
used: bucket?.remaining_fraction === void 0 || !Number.isFinite(bucket.remaining_fraction) ? void 0 : (1 - Math.min(1, Math.max(0, bucket.remaining_fraction))) * FULL_PERCENT2,
|
|
137669
|
-
resetAt: bucket?.reset_in_seconds === void 0 || !Number.isFinite(bucket.reset_in_seconds) ? void 0 : new Date(nowMs + bucket.reset_in_seconds *
|
|
137746
|
+
resetAt: bucket?.reset_in_seconds === void 0 || !Number.isFinite(bucket.reset_in_seconds) ? void 0 : new Date(nowMs + bucket.reset_in_seconds * MS_PER_SECOND17).toISOString()
|
|
137670
137747
|
};
|
|
137671
137748
|
}
|
|
137672
137749
|
function antigravityWindowsOf(payload, nowMs) {
|
|
@@ -137742,7 +137819,7 @@ function enrichStatuslinePayload(params) {
|
|
|
137742
137819
|
window.measures,
|
|
137743
137820
|
{
|
|
137744
137821
|
remaining_fraction: 1 - window.utilization,
|
|
137745
|
-
...window.resetsAt === void 0 ? {} : { reset_in_seconds: (Date.parse(window.resetsAt) - params.nowMs) /
|
|
137822
|
+
...window.resetsAt === void 0 ? {} : { reset_in_seconds: (Date.parse(window.resetsAt) - params.nowMs) / MS_PER_SECOND17 }
|
|
137746
137823
|
}
|
|
137747
137824
|
])
|
|
137748
137825
|
);
|
|
@@ -138367,7 +138444,7 @@ function recordDailySpend(ports, nowMs, sessionId, cost) {
|
|
|
138367
138444
|
const entry = parseEntry3(ports.readText(import_node_path57.default.join(todayDirectory, name)));
|
|
138368
138445
|
return entry === void 0 ? [] : [entry];
|
|
138369
138446
|
});
|
|
138370
|
-
return entries.length === 0 ? void 0 : entries.reduce((
|
|
138447
|
+
return entries.length === 0 ? void 0 : entries.reduce((sum2, entry) => sum2 + (entry.totalUsd - entry.baselineUsd), 0);
|
|
138371
138448
|
}
|
|
138372
138449
|
|
|
138373
138450
|
// src/statusline/elements/header/cost.ts
|
|
@@ -138384,12 +138461,12 @@ function dailyCostSegment(context) {
|
|
|
138384
138461
|
}
|
|
138385
138462
|
|
|
138386
138463
|
// src/statusline/elements/sessionFormat.ts
|
|
138387
|
-
var
|
|
138464
|
+
var MS_PER_SECOND18 = 1e3;
|
|
138388
138465
|
var SECONDS_PER_MINUTE2 = 60;
|
|
138389
138466
|
var MINUTES_PER_HOUR4 = 60;
|
|
138390
138467
|
var HOURS_PER_DAY9 = 24;
|
|
138391
138468
|
function formatElapsed(ms2) {
|
|
138392
|
-
const minutes = Math.floor(ms2 / (
|
|
138469
|
+
const minutes = Math.floor(ms2 / (MS_PER_SECOND18 * SECONDS_PER_MINUTE2));
|
|
138393
138470
|
if (minutes < 1) {
|
|
138394
138471
|
return "<1m";
|
|
138395
138472
|
}
|
|
@@ -138398,14 +138475,14 @@ function formatElapsed(ms2) {
|
|
|
138398
138475
|
}
|
|
138399
138476
|
return `${String(Math.floor(minutes / MINUTES_PER_HOUR4))}h ${String(minutes % MINUTES_PER_HOUR4)}m`;
|
|
138400
138477
|
}
|
|
138401
|
-
function twoUnits(
|
|
138402
|
-
return smaller > 0 ? `${String(
|
|
138478
|
+
function twoUnits(larger2, smaller, largerUnit, smallerUnit) {
|
|
138479
|
+
return smaller > 0 ? `${String(larger2)}${largerUnit} ${String(smaller)}${smallerUnit}` : `${String(larger2)}${largerUnit}`;
|
|
138403
138480
|
}
|
|
138404
138481
|
function formatAgo(ms2) {
|
|
138405
138482
|
if (ms2 < 0) {
|
|
138406
138483
|
return "just now";
|
|
138407
138484
|
}
|
|
138408
|
-
const seconds = Math.floor(ms2 /
|
|
138485
|
+
const seconds = Math.floor(ms2 / MS_PER_SECOND18);
|
|
138409
138486
|
if (seconds < SECONDS_PER_MINUTE2) {
|
|
138410
138487
|
return `${String(seconds)}s ago`;
|
|
138411
138488
|
}
|
|
@@ -138755,8 +138832,8 @@ var RETENTION_DAYS = 30;
|
|
|
138755
138832
|
var HOURS_PER_DAY10 = 24;
|
|
138756
138833
|
var MINUTES_PER_HOUR6 = 60;
|
|
138757
138834
|
var SECONDS_PER_MINUTE4 = 60;
|
|
138758
|
-
var
|
|
138759
|
-
var CACHE_RETENTION_MS = RETENTION_DAYS * HOURS_PER_DAY10 * MINUTES_PER_HOUR6 * SECONDS_PER_MINUTE4 *
|
|
138835
|
+
var MS_PER_SECOND19 = 1e3;
|
|
138836
|
+
var CACHE_RETENTION_MS = RETENTION_DAYS * HOURS_PER_DAY10 * MINUTES_PER_HOUR6 * SECONDS_PER_MINUTE4 * MS_PER_SECOND19;
|
|
138760
138837
|
function pruneCache(ports, cutoffMs) {
|
|
138761
138838
|
const directory = cacheDirectory(ports);
|
|
138762
138839
|
const names = ports.listDirectory(directory);
|
|
@@ -138799,7 +138876,7 @@ var MIN_SPEED_GAP_MS = 500;
|
|
|
138799
138876
|
var TRANSCRIPT_BYTES_PER_TOKEN = 4;
|
|
138800
138877
|
var SpeedSampleSchema = external_exports.strictObject({ at: external_exports.number(), outputTokens: external_exports.number().optional(), transcriptBytes: external_exports.number().optional() });
|
|
138801
138878
|
var CACHE_KIND = "speed";
|
|
138802
|
-
var
|
|
138879
|
+
var MS_PER_SECOND20 = 1e3;
|
|
138803
138880
|
function tokensOf(sample, basis) {
|
|
138804
138881
|
const value2 = sample[basis];
|
|
138805
138882
|
return basis === "transcriptBytes" && value2 !== void 0 ? value2 / TRANSCRIPT_BYTES_PER_TOKEN : value2;
|
|
@@ -138821,7 +138898,7 @@ function speedBetween(previous, current) {
|
|
|
138821
138898
|
if (gapMs < MIN_SPEED_GAP_MS) {
|
|
138822
138899
|
return { tokensPerSecond: void 0, remember: false };
|
|
138823
138900
|
}
|
|
138824
|
-
return { tokensPerSecond: (now - before) / (gapMs /
|
|
138901
|
+
return { tokensPerSecond: (now - before) / (gapMs / MS_PER_SECOND20), remember: true };
|
|
138825
138902
|
}
|
|
138826
138903
|
function trackSpeed(ports, transcriptPath, current) {
|
|
138827
138904
|
const file2 = cacheFileFor(ports, CACHE_KIND, transcriptPath);
|
|
@@ -139136,6 +139213,9 @@ function compactionsRow(context) {
|
|
|
139136
139213
|
return { kind: "text", lines: [context.palette.paint("label", `Compactions: ${String(transcript.session.compactions)}${transcript.complete ? "" : "+"}`)] };
|
|
139137
139214
|
}
|
|
139138
139215
|
|
|
139216
|
+
// src/statusline/elements/rows/context.ts
|
|
139217
|
+
init_statusline();
|
|
139218
|
+
|
|
139139
139219
|
// src/statusline/elements/context.ts
|
|
139140
139220
|
function barStyleOf({ settings: settings2, palette }, okRole) {
|
|
139141
139221
|
return { bands: settings2.bands, palette, okRole, filled: settings2.bar.filled, empty: settings2.bar.empty };
|
|
@@ -139157,19 +139237,87 @@ function cacheShareText(view, style) {
|
|
|
139157
139237
|
}
|
|
139158
139238
|
return "";
|
|
139159
139239
|
}
|
|
139240
|
+
function windowTokensOf({ settings: settings2, view }) {
|
|
139241
|
+
return settings2.context.autoCompactWindow ?? view.contextWindowTokens;
|
|
139242
|
+
}
|
|
139243
|
+
function bufferedPercent(tokens, windowTokens) {
|
|
139244
|
+
const held = tokens / windowTokens;
|
|
139245
|
+
const ramp = Math.max(0, Math.min(1, (held - AUTOCOMPACT_RESERVE_RAMP_START) / (AUTOCOMPACT_RESERVE_RAMP_END - AUTOCOMPACT_RESERVE_RAMP_START)));
|
|
139246
|
+
return Math.min(FULL_PERCENT3, (held + AUTOCOMPACT_RESERVE_FRACTION * ramp) * FULL_PERCENT3);
|
|
139247
|
+
}
|
|
139248
|
+
function usedPercentOf(context) {
|
|
139249
|
+
const { settings: settings2, view } = context;
|
|
139250
|
+
const tokens = view.contextTotalTokens;
|
|
139251
|
+
const windowTokens = windowTokensOf(context);
|
|
139252
|
+
if (settings2.context.autoCompactWindow !== void 0) {
|
|
139253
|
+
return tokens === void 0 ? void 0 : Math.min(FULL_PERCENT3, tokens / settings2.context.autoCompactWindow * FULL_PERCENT3);
|
|
139254
|
+
}
|
|
139255
|
+
const estimated = settings2.context.estimate === "never" || tokens === void 0 || windowTokens === void 0 || windowTokens <= 0 ? void 0 : estimateOf(settings2.context.estimate, tokens, windowTokens);
|
|
139256
|
+
const reported = view.contextUsedPercentage;
|
|
139257
|
+
const reportedUnworked = reported === 0 && tokens !== void 0 && tokens > 0;
|
|
139258
|
+
return reported === void 0 || reportedUnworked && estimated !== void 0 ? estimated : reported;
|
|
139259
|
+
}
|
|
139260
|
+
function estimateOf(kind, tokens, windowTokens) {
|
|
139261
|
+
return kind === "buffered" ? bufferedPercent(tokens, windowTokens) : Math.min(FULL_PERCENT3, tokens / windowTokens * FULL_PERCENT3);
|
|
139262
|
+
}
|
|
139263
|
+
function breakdownText({ payload }) {
|
|
139264
|
+
const usage = payload.context_window?.current_usage;
|
|
139265
|
+
if (usage === void 0) {
|
|
139266
|
+
return void 0;
|
|
139267
|
+
}
|
|
139268
|
+
const cached2 = (usage.cache_creation_input_tokens ?? 0) + (usage.cache_read_input_tokens ?? 0);
|
|
139269
|
+
return ` (in: ${formatTokens(usage.input_tokens ?? 0)}, cache: ${formatTokens(cached2)})`;
|
|
139270
|
+
}
|
|
139160
139271
|
function contextRow(context) {
|
|
139161
|
-
const { view, palette } = context;
|
|
139272
|
+
const { view, palette, settings: settings2 } = context;
|
|
139273
|
+
const percent2 = usedPercentOf(context);
|
|
139274
|
+
if (percent2 === void 0) {
|
|
139275
|
+
return settings2.context.bar === "shown" ? { kind: "bars", cells: [] } : { kind: "text", lines: [] };
|
|
139276
|
+
}
|
|
139162
139277
|
const style = barStyleOf(context, "context");
|
|
139163
|
-
const
|
|
139164
|
-
|
|
139165
|
-
|
|
139166
|
-
|
|
139167
|
-
|
|
139168
|
-
|
|
139169
|
-
|
|
139170
|
-
|
|
139278
|
+
const bands = contextBands(settings2);
|
|
139279
|
+
const fraction = Math.max(0, Math.min(1, percent2 / FULL_PERCENT3));
|
|
139280
|
+
const color = statusColor(fraction, true, { ...style, bands });
|
|
139281
|
+
const windowTokens = windowTokensOf(context);
|
|
139282
|
+
const tokens = view.contextTotalTokens;
|
|
139283
|
+
const heldAgainstWindow = tokens === void 0 || windowTokens === void 0 ? void 0 : `${formatTokens(tokens)}/${formatTokens(windowTokens)}`;
|
|
139284
|
+
const percentText = withColor(color, `${percent2.toFixed(1)}%`);
|
|
139285
|
+
const beforeBar = [];
|
|
139286
|
+
const afterBar = [];
|
|
139287
|
+
switch (settings2.context.value) {
|
|
139288
|
+
case "both":
|
|
139289
|
+
if (heldAgainstWindow !== void 0) {
|
|
139290
|
+
beforeBar.push(heldAgainstWindow);
|
|
139291
|
+
}
|
|
139292
|
+
afterBar.push(percentText);
|
|
139293
|
+
break;
|
|
139294
|
+
case "percent":
|
|
139295
|
+
afterBar.push(percentText);
|
|
139296
|
+
break;
|
|
139297
|
+
case "tokens": {
|
|
139298
|
+
const held = heldAgainstWindow ?? (tokens === void 0 ? void 0 : formatTokens(tokens));
|
|
139299
|
+
if (held !== void 0) {
|
|
139300
|
+
afterBar.push(withColor(color, held));
|
|
139301
|
+
}
|
|
139302
|
+
break;
|
|
139303
|
+
}
|
|
139304
|
+
case "remaining":
|
|
139305
|
+
afterBar.push(withColor(color, `${Math.max(0, FULL_PERCENT3 - percent2).toFixed(1)}%`));
|
|
139306
|
+
break;
|
|
139307
|
+
default:
|
|
139308
|
+
return settings2.context.value;
|
|
139171
139309
|
}
|
|
139172
|
-
|
|
139310
|
+
const high = settings2.context.breakdown === "critical" && percent2 >= bands.criticalAt ? breakdownText(context) : void 0;
|
|
139311
|
+
if (settings2.context.bar === "hidden" && afterBar.length === 0) {
|
|
139312
|
+
return { kind: "text", lines: [] };
|
|
139313
|
+
}
|
|
139314
|
+
const trailer = `${cacheShareText(view, style)}${high === void 0 ? "" : palette.paint("label", high)}`;
|
|
139315
|
+
const label2 = ["Ctx", ...beforeBar].join(" ");
|
|
139316
|
+
if (settings2.context.bar === "shown") {
|
|
139317
|
+
const suffix = afterBar.length === 0 ? trailer : ` ${afterBar.join(" ")}${trailer}`;
|
|
139318
|
+
return { kind: "bars", cells: [barCell(palette.paint("label", `${label2} `), suffix, fraction, { ...style, bands })] };
|
|
139319
|
+
}
|
|
139320
|
+
return { kind: "text", lines: [`${[palette.paint("label", label2), ...afterBar].join(" ")}${trailer}`] };
|
|
139173
139321
|
}
|
|
139174
139322
|
|
|
139175
139323
|
// src/statusline/elements/rows/gitFiles.ts
|
|
@@ -139274,7 +139422,7 @@ function countRules(ports, root) {
|
|
|
139274
139422
|
if (names === void 0) {
|
|
139275
139423
|
return 0;
|
|
139276
139424
|
}
|
|
139277
|
-
let
|
|
139425
|
+
let count2 = 0;
|
|
139278
139426
|
for (const name of names) {
|
|
139279
139427
|
if (entries >= MAX_RULE_ENTRIES) {
|
|
139280
139428
|
break;
|
|
@@ -139283,16 +139431,16 @@ function countRules(ports, root) {
|
|
|
139283
139431
|
const entry = import_node_path61.default.join(real, name);
|
|
139284
139432
|
const kind = followedKind(ports, entry);
|
|
139285
139433
|
if (kind === "directory") {
|
|
139286
|
-
|
|
139434
|
+
count2 += walk3(entry);
|
|
139287
139435
|
} else if (kind === "other" && name.endsWith(".md")) {
|
|
139288
139436
|
const target = ports.realPath(entry);
|
|
139289
139437
|
if (target !== void 0 && !visited.has(target)) {
|
|
139290
139438
|
visited.add(target);
|
|
139291
|
-
|
|
139439
|
+
count2 += 1;
|
|
139292
139440
|
}
|
|
139293
139441
|
}
|
|
139294
139442
|
}
|
|
139295
|
-
return
|
|
139443
|
+
return count2;
|
|
139296
139444
|
};
|
|
139297
139445
|
return walk3(root);
|
|
139298
139446
|
}
|
|
@@ -139356,7 +139504,7 @@ function justify(texts, maxWidth, separator) {
|
|
|
139356
139504
|
return texts.join(separator);
|
|
139357
139505
|
}
|
|
139358
139506
|
const separatorLength = visibleLength(separator);
|
|
139359
|
-
const total = texts.reduce((
|
|
139507
|
+
const total = texts.reduce((sum2, text5) => sum2 + visibleLength(text5), 0) + separatorLength * (texts.length - 1);
|
|
139360
139508
|
const spare = maxWidth - total;
|
|
139361
139509
|
if (spare <= 0) {
|
|
139362
139510
|
return texts.join(separator);
|
|
@@ -139405,8 +139553,8 @@ function layoutHeader(texts, maxWidth, separator) {
|
|
|
139405
139553
|
}
|
|
139406
139554
|
|
|
139407
139555
|
// src/statusline/elements/rows/environment.ts
|
|
139408
|
-
function counted(
|
|
139409
|
-
return
|
|
139556
|
+
function counted(count2, singular, plural2) {
|
|
139557
|
+
return count2 === 0 ? void 0 : `${String(count2)} ${count2 === 1 ? singular : plural2}`;
|
|
139410
139558
|
}
|
|
139411
139559
|
function environmentRow(context) {
|
|
139412
139560
|
const { payload, settings: settings2, palette, ports } = context;
|
|
@@ -139459,7 +139607,7 @@ function formatWallClock(atMs, nowMs, clock, settings2) {
|
|
|
139459
139607
|
}
|
|
139460
139608
|
|
|
139461
139609
|
// src/statusline/elements/rows/promptCache.ts
|
|
139462
|
-
var
|
|
139610
|
+
var MS_PER_SECOND21 = 1e3;
|
|
139463
139611
|
var MIN_WARNING_SECONDS = 60;
|
|
139464
139612
|
var WARNING_FRACTION_DENOMINATOR = 5;
|
|
139465
139613
|
function warningSecondsOf(ttlSeconds) {
|
|
@@ -139472,13 +139620,13 @@ function promptCacheRow(context) {
|
|
|
139472
139620
|
}
|
|
139473
139621
|
const { palette, nowMs, settings: settings2 } = context;
|
|
139474
139622
|
const ttlSeconds = cache.ttlSeconds ?? settings2.promptCache.ttlSeconds;
|
|
139475
|
-
const expiresAtMs = cache.anchorAtMs + ttlSeconds *
|
|
139623
|
+
const expiresAtMs = cache.anchorAtMs + ttlSeconds * MS_PER_SECOND21;
|
|
139476
139624
|
const remainingMs = expiresAtMs - nowMs;
|
|
139477
139625
|
const name = palette.paint("label", "Cache");
|
|
139478
139626
|
if (remainingMs <= 0) {
|
|
139479
139627
|
return { kind: "text", lines: [`${name} ${palette.paint("label", "\u23F1 expired")}`] };
|
|
139480
139628
|
}
|
|
139481
|
-
const role = remainingMs <= warningSecondsOf(ttlSeconds) *
|
|
139629
|
+
const role = remainingMs <= warningSecondsOf(ttlSeconds) * MS_PER_SECOND21 ? "warning" : "context";
|
|
139482
139630
|
return { kind: "text", lines: [`${name} ${palette.paint(role, `\u23F1 until ${formatWallClock(expiresAtMs, nowMs, context.ports.clock, settings2.clock)}`)}`] };
|
|
139483
139631
|
}
|
|
139484
139632
|
|
|
@@ -139617,6 +139765,77 @@ function sessionTimeRow(context) {
|
|
|
139617
139765
|
return { kind: "text", lines: parts.length === 0 ? [] : [parts.join(` ${palette.paint("label", "\u2502")} `)] };
|
|
139618
139766
|
}
|
|
139619
139767
|
|
|
139768
|
+
// src/statusline/transcript/tokens.ts
|
|
139769
|
+
init_zod();
|
|
139770
|
+
var tokenCount = external_exports.number().nonnegative();
|
|
139771
|
+
var SessionTokensSchema = external_exports.strictObject({ inputTokens: tokenCount, outputTokens: tokenCount, cacheCreationTokens: tokenCount, cacheReadTokens: tokenCount });
|
|
139772
|
+
var TokenStateSchema = external_exports.strictObject({
|
|
139773
|
+
totals: SessionTokensSchema,
|
|
139774
|
+
open: external_exports.strictObject({ key: external_exports.string(), usage: SessionTokensSchema }).optional()
|
|
139775
|
+
});
|
|
139776
|
+
var NO_TOKENS = { inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
139777
|
+
var EMPTY_TOKEN_STATE = { totals: NO_TOKENS };
|
|
139778
|
+
function totalTokens(tokens) {
|
|
139779
|
+
return tokens.inputTokens + tokens.outputTokens + tokens.cacheCreationTokens + tokens.cacheReadTokens;
|
|
139780
|
+
}
|
|
139781
|
+
function increase(from, to2) {
|
|
139782
|
+
return {
|
|
139783
|
+
inputTokens: Math.max(0, to2.inputTokens - from.inputTokens),
|
|
139784
|
+
outputTokens: Math.max(0, to2.outputTokens - from.outputTokens),
|
|
139785
|
+
cacheCreationTokens: Math.max(0, to2.cacheCreationTokens - from.cacheCreationTokens),
|
|
139786
|
+
cacheReadTokens: Math.max(0, to2.cacheReadTokens - from.cacheReadTokens)
|
|
139787
|
+
};
|
|
139788
|
+
}
|
|
139789
|
+
function sum(left, right) {
|
|
139790
|
+
return {
|
|
139791
|
+
inputTokens: left.inputTokens + right.inputTokens,
|
|
139792
|
+
outputTokens: left.outputTokens + right.outputTokens,
|
|
139793
|
+
cacheCreationTokens: left.cacheCreationTokens + right.cacheCreationTokens,
|
|
139794
|
+
cacheReadTokens: left.cacheReadTokens + right.cacheReadTokens
|
|
139795
|
+
};
|
|
139796
|
+
}
|
|
139797
|
+
function larger(left, right) {
|
|
139798
|
+
return {
|
|
139799
|
+
inputTokens: Math.max(left.inputTokens, right.inputTokens),
|
|
139800
|
+
outputTokens: Math.max(left.outputTokens, right.outputTokens),
|
|
139801
|
+
cacheCreationTokens: Math.max(left.cacheCreationTokens, right.cacheCreationTokens),
|
|
139802
|
+
cacheReadTokens: Math.max(left.cacheReadTokens, right.cacheReadTokens)
|
|
139803
|
+
};
|
|
139804
|
+
}
|
|
139805
|
+
function foldTokens(state, record2) {
|
|
139806
|
+
const usage = record2.message?.usage;
|
|
139807
|
+
if (record2.type !== "assistant" || usage === void 0) {
|
|
139808
|
+
return state;
|
|
139809
|
+
}
|
|
139810
|
+
const counts = {
|
|
139811
|
+
inputTokens: usage.input_tokens ?? 0,
|
|
139812
|
+
outputTokens: usage.output_tokens ?? 0,
|
|
139813
|
+
cacheCreationTokens: usage.cache_creation_input_tokens ?? 0,
|
|
139814
|
+
cacheReadTokens: usage.cache_read_input_tokens ?? 0
|
|
139815
|
+
};
|
|
139816
|
+
const key = record2.message?.id ?? `${String(counts.inputTokens)}|${String(counts.outputTokens)}|${String(counts.cacheCreationTokens)}|${String(counts.cacheReadTokens)}`;
|
|
139817
|
+
if (state.open?.key === key) {
|
|
139818
|
+
return { totals: sum(state.totals, increase(state.open.usage, counts)), open: { key, usage: larger(state.open.usage, counts) } };
|
|
139819
|
+
}
|
|
139820
|
+
return { totals: sum(state.totals, counts), open: { key, usage: counts } };
|
|
139821
|
+
}
|
|
139822
|
+
|
|
139823
|
+
// src/statusline/elements/rows/tokens.ts
|
|
139824
|
+
function tokensRow({ palette, transcript }) {
|
|
139825
|
+
const facts = transcript();
|
|
139826
|
+
const total = facts === void 0 ? 0 : totalTokens(facts.tokens);
|
|
139827
|
+
if (facts === void 0 || total === 0) {
|
|
139828
|
+
return { kind: "text", lines: [] };
|
|
139829
|
+
}
|
|
139830
|
+
const { tokens } = facts;
|
|
139831
|
+
const parts = [`in: ${formatTokens(tokens.inputTokens)}`, `out: ${formatTokens(tokens.outputTokens)}`];
|
|
139832
|
+
const cached2 = tokens.cacheCreationTokens + tokens.cacheReadTokens;
|
|
139833
|
+
if (cached2 > 0) {
|
|
139834
|
+
parts.push(`cache: ${formatTokens(cached2)}`);
|
|
139835
|
+
}
|
|
139836
|
+
return { kind: "text", lines: [palette.paint("label", `Tokens ${formatTokens(total)}${facts.complete ? "" : "+"} (${parts.join(", ")})`)] };
|
|
139837
|
+
}
|
|
139838
|
+
|
|
139620
139839
|
// src/statusline/elements/registry.ts
|
|
139621
139840
|
var HEADER_ROLES = {
|
|
139622
139841
|
model: "model",
|
|
@@ -139657,7 +139876,7 @@ var ELEMENTS = {
|
|
|
139657
139876
|
duration: durationSegment,
|
|
139658
139877
|
speed: speedSegment
|
|
139659
139878
|
},
|
|
139660
|
-
rows: { context: contextRow, quota: quotaRow, addedDirs: addedDirsRow, gitFiles: gitFilesRow, memory: memoryRow, environment: environmentRow, sessionTime: sessionTimeRow, promptCache: promptCacheRow, compactions: compactionsRow }
|
|
139879
|
+
rows: { context: contextRow, quota: quotaRow, addedDirs: addedDirsRow, gitFiles: gitFilesRow, memory: memoryRow, environment: environmentRow, sessionTime: sessionTimeRow, promptCache: promptCacheRow, compactions: compactionsRow, tokens: tokensRow }
|
|
139661
139880
|
};
|
|
139662
139881
|
|
|
139663
139882
|
// src/statusline/identityTranscript.ts
|
|
@@ -139758,6 +139977,7 @@ init_zod();
|
|
|
139758
139977
|
init_zod();
|
|
139759
139978
|
var text4 = external_exports.string().optional().catch(void 0);
|
|
139760
139979
|
var number5 = external_exports.number().optional().catch(void 0);
|
|
139980
|
+
var count = external_exports.number().nonnegative().optional().catch(void 0);
|
|
139761
139981
|
var ContentBlockSchema2 = external_exports.looseObject({ type: text4, text: text4 });
|
|
139762
139982
|
var TranscriptRecordSchema = external_exports.looseObject({
|
|
139763
139983
|
type: text4,
|
|
@@ -139773,8 +139993,14 @@ var TranscriptRecordSchema = external_exports.looseObject({
|
|
|
139773
139993
|
/** Shared by the records one API request produced. */
|
|
139774
139994
|
requestId: text4,
|
|
139775
139995
|
message: external_exports.looseObject({
|
|
139996
|
+
/** The API response the record belongs to; the records of one response share it. */
|
|
139997
|
+
id: external_exports.string().min(1).optional().catch(void 0),
|
|
139776
139998
|
content: external_exports.union([external_exports.string(), external_exports.array(ContentBlockSchema2)]).optional().catch(void 0),
|
|
139777
139999
|
usage: external_exports.looseObject({
|
|
140000
|
+
input_tokens: count,
|
|
140001
|
+
output_tokens: count,
|
|
140002
|
+
cache_creation_input_tokens: count,
|
|
140003
|
+
cache_read_input_tokens: count,
|
|
139778
140004
|
cache_creation: external_exports.looseObject({ ephemeral_5m_input_tokens: number5, ephemeral_1h_input_tokens: number5 }).optional().catch(void 0)
|
|
139779
140005
|
}).optional().catch(void 0)
|
|
139780
140006
|
}).optional().catch(void 0)
|
|
@@ -139809,18 +140035,22 @@ var PromptCacheClockSchema = external_exports.strictObject({
|
|
|
139809
140035
|
/** The time of a request that has been sent and not yet answered: it has already refreshed the cache. */
|
|
139810
140036
|
pendingAtMs: external_exports.number().optional()
|
|
139811
140037
|
});
|
|
139812
|
-
var
|
|
140038
|
+
var CumulativeStateSchema = external_exports.strictObject({
|
|
139813
140039
|
startedAtMs: external_exports.number().optional(),
|
|
139814
140040
|
/** True once the start of the transcript was read and held no timestamp, so a timestamp met later is not the session's start. */
|
|
139815
140041
|
startUnknown: external_exports.literal(true).optional(),
|
|
140042
|
+
compactions: external_exports.number().int().nonnegative()
|
|
140043
|
+
});
|
|
140044
|
+
var LatestStateSchema = external_exports.strictObject({
|
|
139816
140045
|
lastAssistantAtMs: external_exports.number().optional(),
|
|
139817
|
-
compactions: external_exports.number().int().nonnegative(),
|
|
139818
140046
|
customTitle: external_exports.string().optional(),
|
|
139819
140047
|
slug: external_exports.string().optional(),
|
|
139820
140048
|
aiTitle: external_exports.string().optional(),
|
|
139821
140049
|
cache: PromptCacheClockSchema
|
|
139822
140050
|
});
|
|
139823
|
-
var
|
|
140051
|
+
var SessionStateSchema2 = external_exports.strictObject({ cumulative: CumulativeStateSchema, latest: LatestStateSchema });
|
|
140052
|
+
var EMPTY_SESSION_STATE = { cumulative: { compactions: 0 }, latest: { cache: {} } };
|
|
140053
|
+
var EMPTY_LATEST_STATE = EMPTY_SESSION_STATE.latest;
|
|
139824
140054
|
var LOCAL_ONLY_USER_TEXT_PREFIXES = ["<command-name>", "<command-message>", "<local-command-", "[Request interrupted by user"];
|
|
139825
140055
|
function isLocalOnlyUserText(text5) {
|
|
139826
140056
|
return LOCAL_ONLY_USER_TEXT_PREFIXES.some((prefix) => text5.startsWith(prefix));
|
|
@@ -139859,7 +140089,18 @@ function foldPromptCache(cache, record2, atMs) {
|
|
|
139859
140089
|
}
|
|
139860
140090
|
return { ...next, previousMainAtMs: atMs };
|
|
139861
140091
|
}
|
|
139862
|
-
function
|
|
140092
|
+
function foldCumulative(state, record2) {
|
|
140093
|
+
const atMs = recordTimeMs(record2);
|
|
140094
|
+
const next = { ...state };
|
|
140095
|
+
if (record2.type === "system" && record2.subtype === "compact_boundary" && atMs !== void 0) {
|
|
140096
|
+
next.compactions += 1;
|
|
140097
|
+
}
|
|
140098
|
+
if (atMs !== void 0 && next.startedAtMs === void 0 && next.startUnknown !== true) {
|
|
140099
|
+
next.startedAtMs = atMs;
|
|
140100
|
+
}
|
|
140101
|
+
return next;
|
|
140102
|
+
}
|
|
140103
|
+
function foldLatest(state, record2) {
|
|
139863
140104
|
const atMs = recordTimeMs(record2);
|
|
139864
140105
|
const next = { ...state };
|
|
139865
140106
|
if (record2.type === "custom-title" && record2.customTitle !== void 0) {
|
|
@@ -139869,12 +140110,6 @@ function foldSession(state, record2) {
|
|
|
139869
140110
|
} else if (record2.slug !== void 0) {
|
|
139870
140111
|
next.slug = record2.slug;
|
|
139871
140112
|
}
|
|
139872
|
-
if (record2.type === "system" && record2.subtype === "compact_boundary" && atMs !== void 0) {
|
|
139873
|
-
next.compactions += 1;
|
|
139874
|
-
}
|
|
139875
|
-
if (atMs !== void 0 && next.startedAtMs === void 0 && next.startUnknown !== true) {
|
|
139876
|
-
next.startedAtMs = atMs;
|
|
139877
|
-
}
|
|
139878
140113
|
if (record2.type === "assistant" && atMs !== void 0) {
|
|
139879
140114
|
next.lastAssistantAtMs = atMs;
|
|
139880
140115
|
}
|
|
@@ -139883,14 +140118,22 @@ function foldSession(state, record2) {
|
|
|
139883
140118
|
}
|
|
139884
140119
|
return next;
|
|
139885
140120
|
}
|
|
139886
|
-
function
|
|
139887
|
-
|
|
140121
|
+
function foldSession(state, record2) {
|
|
140122
|
+
return { cumulative: foldCumulative(state.cumulative, record2), latest: foldLatest(state.latest, record2) };
|
|
140123
|
+
}
|
|
140124
|
+
function hasRequest(cache) {
|
|
140125
|
+
return cache.anchorAtMs !== void 0 || cache.pendingAtMs !== void 0;
|
|
140126
|
+
}
|
|
140127
|
+
function sessionFactsOf(state, newer) {
|
|
140128
|
+
const { cumulative } = state;
|
|
140129
|
+
const latest = newer === void 0 ? state.latest : { ...state.latest, ...newer, cache: hasRequest(newer.cache) ? { ...newer.cache, ttlSeconds: newer.cache.ttlSeconds ?? state.latest.cache.ttlSeconds } : state.latest.cache };
|
|
140130
|
+
const { cache } = latest;
|
|
139888
140131
|
const anchorAtMs = cache.pendingAtMs !== void 0 && (cache.anchorAtMs === void 0 || cache.pendingAtMs > cache.anchorAtMs) ? cache.pendingAtMs : cache.anchorAtMs;
|
|
139889
140132
|
return {
|
|
139890
|
-
title: [
|
|
139891
|
-
startedAtMs:
|
|
139892
|
-
lastResponseAtMs:
|
|
139893
|
-
compactions:
|
|
140133
|
+
title: [latest.customTitle, latest.slug, latest.aiTitle].flatMap((name) => name === void 0 ? [] : visibleDisplayText(name)).find((name) => name !== ""),
|
|
140134
|
+
startedAtMs: cumulative.startedAtMs,
|
|
140135
|
+
lastResponseAtMs: latest.lastAssistantAtMs,
|
|
140136
|
+
compactions: cumulative.compactions,
|
|
139894
140137
|
promptCache: anchorAtMs === void 0 ? void 0 : { anchorAtMs, ttlSeconds: cache.ttlSeconds }
|
|
139895
140138
|
};
|
|
139896
140139
|
}
|
|
@@ -139900,88 +140143,107 @@ var MAX_TRANSCRIPT_READ_BYTES = 4194304;
|
|
|
139900
140143
|
var FINGERPRINT_BYTES = 4096;
|
|
139901
140144
|
var NEWLINE2 = 10;
|
|
139902
140145
|
var CACHE_KIND2 = "transcript";
|
|
139903
|
-
var CACHE_VERSION =
|
|
140146
|
+
var CACHE_VERSION = 5;
|
|
139904
140147
|
var TranscriptCacheSchema = external_exports.strictObject({
|
|
139905
140148
|
version: external_exports.literal(CACHE_VERSION),
|
|
139906
140149
|
/** A digest of the transcript's first line when this was written: another file at the same path has another one. */
|
|
139907
140150
|
fingerprint: external_exports.string(),
|
|
139908
|
-
/** How far into the transcript the state has been folded:
|
|
140151
|
+
/** How far into the transcript the state has been folded: the start of a line, except while `skipping`. */
|
|
139909
140152
|
offset: external_exports.number().int().nonnegative(),
|
|
139910
|
-
/** False once
|
|
140153
|
+
/** False once a line was skipped without being folded, so the state is missing what it said for good. */
|
|
139911
140154
|
complete: external_exports.boolean(),
|
|
139912
|
-
|
|
139913
|
-
|
|
139914
|
-
|
|
140155
|
+
/** True while the offset lies inside a line that was too big to read, which is passed a window at a time until its end. */
|
|
140156
|
+
skipping: external_exports.literal(true).optional(),
|
|
140157
|
+
session: SessionStateSchema2,
|
|
140158
|
+
tokens: TokenStateSchema,
|
|
140159
|
+
/** While the cumulative facts are being caught up, the latest-state facts folded from the end of the transcript, and where that fold has read to. Absent once the cumulative fold has reached the end, when it holds them itself. */
|
|
140160
|
+
newer: external_exports.strictObject({ offset: external_exports.number().int().nonnegative(), state: LatestStateSchema }).optional()
|
|
140161
|
+
});
|
|
140162
|
+
function eachRecord(bytes, visit2) {
|
|
139915
140163
|
const end = bytes.lastIndexOf(NEWLINE2) + 1;
|
|
139916
|
-
let folded = state;
|
|
139917
140164
|
for (const line of new TextDecoder().decode(bytes.subarray(0, end)).split("\n")) {
|
|
139918
140165
|
const record2 = line === "" ? void 0 : parseTranscriptRecord(line);
|
|
139919
140166
|
if (record2 !== void 0) {
|
|
139920
|
-
|
|
140167
|
+
visit2(record2);
|
|
139921
140168
|
}
|
|
139922
140169
|
}
|
|
139923
|
-
return
|
|
140170
|
+
return end;
|
|
139924
140171
|
}
|
|
139925
|
-
function
|
|
139926
|
-
|
|
139927
|
-
|
|
139928
|
-
|
|
139929
|
-
|
|
139930
|
-
|
|
139931
|
-
|
|
139932
|
-
|
|
139933
|
-
if (atMs !== void 0) {
|
|
139934
|
-
return atMs;
|
|
139935
|
-
}
|
|
139936
|
-
from = lineEnd + 1;
|
|
139937
|
-
}
|
|
139938
|
-
return void 0;
|
|
140172
|
+
function foldLines(state, bytes) {
|
|
140173
|
+
let session = state.session;
|
|
140174
|
+
let tokens = state.tokens;
|
|
140175
|
+
const consumed = eachRecord(bytes, (record2) => {
|
|
140176
|
+
session = foldSession(session, record2);
|
|
140177
|
+
tokens = foldTokens(tokens, record2);
|
|
140178
|
+
});
|
|
140179
|
+
return { session, tokens, consumed };
|
|
139939
140180
|
}
|
|
139940
140181
|
function fingerprintOf(head) {
|
|
139941
140182
|
const newline = head.subarray(0, FINGERPRINT_BYTES).indexOf(NEWLINE2);
|
|
139942
140183
|
return (0, import_node_crypto27.createHash)("sha256").update(head.subarray(0, newline === -1 ? FINGERPRINT_BYTES : newline + 1)).digest("hex");
|
|
139943
140184
|
}
|
|
139944
|
-
function
|
|
139945
|
-
|
|
139946
|
-
const range2 = ports.readRange(file2, from, MAX_TRANSCRIPT_READ_BYTES + 1);
|
|
139947
|
-
if (range2 === void 0) {
|
|
139948
|
-
return void 0;
|
|
139949
|
-
}
|
|
139950
|
-
const firstLine = from === 0 ? 0 : range2.bytes.indexOf(NEWLINE2) + 1;
|
|
139951
|
-
return firstLine === 0 && from > 0 ? void 0 : { bytes: range2.bytes.subarray(firstLine), offset: from + firstLine };
|
|
139952
|
-
}
|
|
139953
|
-
function factsOf(range2, cache) {
|
|
139954
|
-
return { bytes: range2.size, complete: cache.complete, session: sessionFactsOf(cache.session) };
|
|
140185
|
+
function factsOf(size, cache, reachedEnd) {
|
|
140186
|
+
return { bytes: size, complete: cache.complete && reachedEnd, session: sessionFactsOf(cache.session, cache.newer?.state), tokens: cache.tokens.totals };
|
|
139955
140187
|
}
|
|
139956
140188
|
var START_UNKNOWN = { startUnknown: true };
|
|
140189
|
+
function advance2(cache, window, reachedEnd) {
|
|
140190
|
+
let offset = cache.offset;
|
|
140191
|
+
let bytes = window;
|
|
140192
|
+
if (cache.skipping === true) {
|
|
140193
|
+
const lineEnd = bytes.indexOf(NEWLINE2);
|
|
140194
|
+
if (lineEnd === -1) {
|
|
140195
|
+
return { ...cache, offset: offset + bytes.length };
|
|
140196
|
+
}
|
|
140197
|
+
offset += lineEnd + 1;
|
|
140198
|
+
bytes = bytes.subarray(lineEnd + 1);
|
|
140199
|
+
}
|
|
140200
|
+
const { session: folded, tokens, consumed } = foldLines(cache, bytes);
|
|
140201
|
+
if (consumed === 0 && bytes.length > 0 && !reachedEnd) {
|
|
140202
|
+
const { cumulative } = cache.session;
|
|
140203
|
+
const session = cumulative.startedAtMs === void 0 ? { ...cache.session, cumulative: { ...cumulative, ...START_UNKNOWN } } : cache.session;
|
|
140204
|
+
return { ...cache, offset: offset + bytes.length, complete: false, skipping: true, session };
|
|
140205
|
+
}
|
|
140206
|
+
return { version: cache.version, fingerprint: cache.fingerprint, offset: offset + consumed, complete: cache.complete, session: folded, tokens };
|
|
140207
|
+
}
|
|
139957
140208
|
function readTranscript(ports, transcriptPath, nowMs) {
|
|
139958
140209
|
const file2 = cacheFileFor(ports, CACHE_KIND2, transcriptPath);
|
|
139959
140210
|
const loaded = loadCache(ports, file2, TranscriptCacheSchema);
|
|
139960
140211
|
const head = loaded === void 0 ? void 0 : ports.readRange(transcriptPath, 0, FINGERPRINT_BYTES);
|
|
139961
140212
|
const cached2 = loaded !== void 0 && head !== void 0 && head.size >= loaded.offset && fingerprintOf(head.bytes) === loaded.fingerprint ? loaded : void 0;
|
|
139962
140213
|
const from = cached2?.offset ?? 0;
|
|
139963
|
-
const
|
|
139964
|
-
if (
|
|
140214
|
+
const window = ports.readRange(transcriptPath, from, MAX_TRANSCRIPT_READ_BYTES);
|
|
140215
|
+
if (window === void 0) {
|
|
139965
140216
|
return void 0;
|
|
139966
140217
|
}
|
|
139967
|
-
const base = cached2 ?? { version: CACHE_VERSION, fingerprint: "", offset: 0, complete: true, session: EMPTY_SESSION_STATE };
|
|
139968
|
-
const
|
|
139969
|
-
|
|
139970
|
-
|
|
140218
|
+
const { newer: previousNewer, ...base } = cached2 ?? { version: CACHE_VERSION, fingerprint: "", offset: 0, complete: true, session: EMPTY_SESSION_STATE, tokens: EMPTY_TOKEN_STATE };
|
|
140219
|
+
const reachedEnd = window.size - from <= MAX_TRANSCRIPT_READ_BYTES;
|
|
140220
|
+
const advanced = advance2(base, window.bytes, reachedEnd);
|
|
140221
|
+
const newer = reachedEnd ? void 0 : newerFrom(ports, transcriptPath, window.size, previousNewer);
|
|
140222
|
+
const next = { ...advanced, ...newer === void 0 ? {} : { newer } };
|
|
140223
|
+
if (next.offset > base.offset) {
|
|
140224
|
+
saveCache(ports, file2, { ...next, fingerprint: cached2 === void 0 ? fingerprintOf(window.bytes) : base.fingerprint }, nowMs);
|
|
139971
140225
|
}
|
|
139972
|
-
|
|
139973
|
-
const unread = { ...base, complete: false, session: startedAtMs === void 0 ? { ...base.session, ...START_UNKNOWN } : { ...base.session, startedAtMs } };
|
|
139974
|
-
const tail = readTail(ports, transcriptPath, first.size);
|
|
139975
|
-
return tail === void 0 ? factsOf(first, unread) : foldInto({ ...fold, base: unread, source: tail });
|
|
140226
|
+
return factsOf(window.size, next, reachedEnd);
|
|
139976
140227
|
}
|
|
139977
|
-
function
|
|
139978
|
-
|
|
139979
|
-
|
|
139980
|
-
|
|
139981
|
-
|
|
139982
|
-
|
|
140228
|
+
function newerFrom(ports, transcriptPath, size, previous) {
|
|
140229
|
+
if (previous !== void 0 && previous.offset <= size && size - previous.offset <= MAX_TRANSCRIPT_READ_BYTES) {
|
|
140230
|
+
const appended = ports.readRange(transcriptPath, previous.offset, MAX_TRANSCRIPT_READ_BYTES);
|
|
140231
|
+
return appended === void 0 ? void 0 : foldNewer(previous.state, appended.bytes, previous.offset);
|
|
140232
|
+
}
|
|
140233
|
+
const from = Math.max(0, size - MAX_TRANSCRIPT_READ_BYTES - 1);
|
|
140234
|
+
const tail = ports.readRange(transcriptPath, from, MAX_TRANSCRIPT_READ_BYTES + 1);
|
|
140235
|
+
if (tail === void 0) {
|
|
140236
|
+
return void 0;
|
|
139983
140237
|
}
|
|
139984
|
-
|
|
140238
|
+
const firstLine = from === 0 ? 0 : tail.bytes.indexOf(NEWLINE2) + 1;
|
|
140239
|
+
return firstLine === 0 && from > 0 ? void 0 : foldNewer(EMPTY_LATEST_STATE, tail.bytes.subarray(firstLine), from + firstLine);
|
|
140240
|
+
}
|
|
140241
|
+
function foldNewer(state, bytes, offset) {
|
|
140242
|
+
let folded = state;
|
|
140243
|
+
const consumed = eachRecord(bytes, (record2) => {
|
|
140244
|
+
folded = foldLatest(folded, record2);
|
|
140245
|
+
});
|
|
140246
|
+
return { offset: offset + consumed, state: folded };
|
|
139985
140247
|
}
|
|
139986
140248
|
|
|
139987
140249
|
// src/statusline/render.ts
|
|
@@ -140167,7 +140429,7 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
140167
140429
|
}
|
|
140168
140430
|
function registerStatuslineKeys(statusline) {
|
|
140169
140431
|
withExamples(
|
|
140170
|
-
statusline.command("keys").description("List every setting of the built-in statusline with its kind, its default and what it does.").option("--json", "Print the settings as JSON."),
|
|
140432
|
+
statusline.command("keys").description("List every setting of the built-in statusline with its kind, its default (if it has one) and what it does.").option("--json", "Print the settings as JSON."),
|
|
140171
140433
|
["agent-shim statusline keys", "agent-shim statusline keys --json"]
|
|
140172
140434
|
).action((options) => {
|
|
140173
140435
|
if (options.json === true) {
|
|
@@ -149040,7 +149302,7 @@ var ExperimentalMcpServerTasks = class {
|
|
|
149040
149302
|
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_supports-color@7.2.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
|
|
149041
149303
|
init_zod();
|
|
149042
149304
|
function toolInputElementCount(value2, max) {
|
|
149043
|
-
let
|
|
149305
|
+
let count2 = 0;
|
|
149044
149306
|
const stack = [value2];
|
|
149045
149307
|
while (stack.length > 0) {
|
|
149046
149308
|
const node2 = stack.pop();
|
|
@@ -149048,8 +149310,8 @@ function toolInputElementCount(value2, max) {
|
|
|
149048
149310
|
continue;
|
|
149049
149311
|
if (Array.isArray(node2)) {
|
|
149050
149312
|
for (const child of node2) {
|
|
149051
|
-
if (++
|
|
149052
|
-
return
|
|
149313
|
+
if (++count2 > max)
|
|
149314
|
+
return count2;
|
|
149053
149315
|
if (child !== null && typeof child === "object")
|
|
149054
149316
|
stack.push(child);
|
|
149055
149317
|
}
|
|
@@ -149057,15 +149319,15 @@ function toolInputElementCount(value2, max) {
|
|
|
149057
149319
|
for (const key in node2) {
|
|
149058
149320
|
if (!Object.prototype.hasOwnProperty.call(node2, key))
|
|
149059
149321
|
continue;
|
|
149060
|
-
if (++
|
|
149061
|
-
return
|
|
149322
|
+
if (++count2 > max)
|
|
149323
|
+
return count2;
|
|
149062
149324
|
const child = node2[key];
|
|
149063
149325
|
if (child !== null && typeof child === "object")
|
|
149064
149326
|
stack.push(child);
|
|
149065
149327
|
}
|
|
149066
149328
|
}
|
|
149067
149329
|
}
|
|
149068
|
-
return
|
|
149330
|
+
return count2;
|
|
149069
149331
|
}
|
|
149070
149332
|
function resolveMaxToolInputElements(value2) {
|
|
149071
149333
|
if (value2 === void 0 || value2 === Infinity)
|
|
@@ -152624,7 +152886,7 @@ function triggerReason(input2) {
|
|
|
152624
152886
|
return void 0;
|
|
152625
152887
|
}
|
|
152626
152888
|
const remaining = Math.max(0, 1 - five.utilization);
|
|
152627
|
-
const cost = input2.sessions.reduce((
|
|
152889
|
+
const cost = input2.sessions.reduce((sum2, session) => sum2 + (session.state?.contextTokens ?? 0), 0) * perToken;
|
|
152628
152890
|
return remaining < cost ? `the 5h window has ${asPercent(remaining)} left, and compacting every session on this member would use about ${asPercent(cost)}` : void 0;
|
|
152629
152891
|
}
|
|
152630
152892
|
function decideCompaction(input2) {
|
|
@@ -152633,11 +152895,11 @@ function decideCompaction(input2) {
|
|
|
152633
152895
|
if (tokens === void 0) {
|
|
152634
152896
|
return { compact: false, reason: "the session is mid-turn, has no context recorded yet, or was already compacted on this member" };
|
|
152635
152897
|
}
|
|
152636
|
-
const
|
|
152898
|
+
const larger2 = input2.sessions.some((session) => {
|
|
152637
152899
|
const other = compactableTokens(session.state);
|
|
152638
152900
|
return session.sessionId !== input2.sessionId && other !== void 0 && (other > tokens || other === tokens && session.sessionId < input2.sessionId);
|
|
152639
152901
|
});
|
|
152640
|
-
if (
|
|
152902
|
+
if (larger2) {
|
|
152641
152903
|
return { compact: false, reason: "a larger session on this member compacts first" };
|
|
152642
152904
|
}
|
|
152643
152905
|
const reason = triggerReason(input2);
|