claude-use 11.64.1 → 11.65.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +888 -553
- package/dist/index.cjs +264 -129
- package/dist/index.mjs +257 -124
- package/dist/types/index.d.ts +1605 -886
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -318,10 +318,10 @@ function mergeDefs(...defs) {
|
|
|
318
318
|
function cloneDef(schema) {
|
|
319
319
|
return mergeDefs(schema._zod.def);
|
|
320
320
|
}
|
|
321
|
-
function getElementAtPath(obj,
|
|
322
|
-
if (!
|
|
321
|
+
function getElementAtPath(obj, path72) {
|
|
322
|
+
if (!path72)
|
|
323
323
|
return obj;
|
|
324
|
-
return
|
|
324
|
+
return path72.reduce((acc, key) => acc?.[key], obj);
|
|
325
325
|
}
|
|
326
326
|
function promiseAllObject(promisesObj) {
|
|
327
327
|
const keys = Object.keys(promisesObj);
|
|
@@ -580,11 +580,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
580
580
|
}
|
|
581
581
|
return false;
|
|
582
582
|
}
|
|
583
|
-
function prefixIssues(
|
|
583
|
+
function prefixIssues(path72, issues) {
|
|
584
584
|
return issues.map((iss) => {
|
|
585
585
|
var _a4;
|
|
586
586
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
587
|
-
iss.path.unshift(
|
|
587
|
+
iss.path.unshift(path72);
|
|
588
588
|
return iss;
|
|
589
589
|
});
|
|
590
590
|
}
|
|
@@ -1105,16 +1105,16 @@ function flattenError(error63, mapper = (issue2) => issue2.message) {
|
|
|
1105
1105
|
}
|
|
1106
1106
|
function formatError(error63, mapper = (issue2) => issue2.message) {
|
|
1107
1107
|
const fieldErrors = { _errors: [] };
|
|
1108
|
-
const processError = (error64,
|
|
1108
|
+
const processError = (error64, path72 = []) => {
|
|
1109
1109
|
for (const issue2 of error64.issues) {
|
|
1110
1110
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1111
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1111
|
+
issue2.errors.map((issues) => processError({ issues }, [...path72, ...issue2.path]));
|
|
1112
1112
|
} else if (issue2.code === "invalid_key") {
|
|
1113
|
-
processError({ issues: issue2.issues }, [...
|
|
1113
|
+
processError({ issues: issue2.issues }, [...path72, ...issue2.path]);
|
|
1114
1114
|
} else if (issue2.code === "invalid_element") {
|
|
1115
|
-
processError({ issues: issue2.issues }, [...
|
|
1115
|
+
processError({ issues: issue2.issues }, [...path72, ...issue2.path]);
|
|
1116
1116
|
} else {
|
|
1117
|
-
const fullpath = [...
|
|
1117
|
+
const fullpath = [...path72, ...issue2.path];
|
|
1118
1118
|
if (fullpath.length === 0) {
|
|
1119
1119
|
fieldErrors._errors.push(mapper(issue2));
|
|
1120
1120
|
} else {
|
|
@@ -1153,17 +1153,17 @@ function formatError(error63, mapper = (issue2) => issue2.message) {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
function treeifyError(error63, mapper = (issue2) => issue2.message) {
|
|
1155
1155
|
const result = { errors: [] };
|
|
1156
|
-
const processError = (error64,
|
|
1156
|
+
const processError = (error64, path72 = []) => {
|
|
1157
1157
|
var _a4;
|
|
1158
1158
|
for (const issue2 of error64.issues) {
|
|
1159
1159
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1160
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1160
|
+
issue2.errors.map((issues) => processError({ issues }, [...path72, ...issue2.path]));
|
|
1161
1161
|
} else if (issue2.code === "invalid_key") {
|
|
1162
|
-
processError({ issues: issue2.issues }, [...
|
|
1162
|
+
processError({ issues: issue2.issues }, [...path72, ...issue2.path]);
|
|
1163
1163
|
} else if (issue2.code === "invalid_element") {
|
|
1164
|
-
processError({ issues: issue2.issues }, [...
|
|
1164
|
+
processError({ issues: issue2.issues }, [...path72, ...issue2.path]);
|
|
1165
1165
|
} else {
|
|
1166
|
-
const fullpath = [...
|
|
1166
|
+
const fullpath = [...path72, ...issue2.path];
|
|
1167
1167
|
if (fullpath.length === 0) {
|
|
1168
1168
|
result.errors.push(mapper(issue2));
|
|
1169
1169
|
continue;
|
|
@@ -1202,8 +1202,8 @@ function treeifyError(error63, mapper = (issue2) => issue2.message) {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
function toDotPath(_path) {
|
|
1204
1204
|
const segs = [];
|
|
1205
|
-
const
|
|
1206
|
-
for (const seg of
|
|
1205
|
+
const path72 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1206
|
+
for (const seg of path72) {
|
|
1207
1207
|
if (typeof seg === "number")
|
|
1208
1208
|
segs.push(`[${seg}]`);
|
|
1209
1209
|
else if (typeof seg === "symbol")
|
|
@@ -19199,13 +19199,13 @@ function resolveRef(ref, ctx) {
|
|
|
19199
19199
|
if (!ref.startsWith("#")) {
|
|
19200
19200
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19201
19201
|
}
|
|
19202
|
-
const
|
|
19203
|
-
if (
|
|
19202
|
+
const path72 = ref.slice(1).split("/").filter(Boolean);
|
|
19203
|
+
if (path72.length === 0) {
|
|
19204
19204
|
return ctx.rootSchema;
|
|
19205
19205
|
}
|
|
19206
19206
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
19207
|
-
if (
|
|
19208
|
-
const key =
|
|
19207
|
+
if (path72[0] === defsKey) {
|
|
19208
|
+
const key = path72[1] === void 0 ? void 0 : decodeJSONPointerSegment(path72[1]);
|
|
19209
19209
|
if (!key || !ctx.defs[key]) {
|
|
19210
19210
|
throw new Error(`Reference not found: ${ref}`);
|
|
19211
19211
|
}
|
|
@@ -23712,42 +23712,42 @@ var require_defaults = __commonJS({
|
|
|
23712
23712
|
var require_env_paths = __commonJS({
|
|
23713
23713
|
"node_modules/.pnpm/env-paths@2.2.1/node_modules/env-paths/index.js"(exports2, module2) {
|
|
23714
23714
|
"use strict";
|
|
23715
|
-
var
|
|
23715
|
+
var path72 = require("path");
|
|
23716
23716
|
var os14 = require("os");
|
|
23717
23717
|
var homedir = os14.homedir();
|
|
23718
23718
|
var tmpdir = os14.tmpdir();
|
|
23719
23719
|
var { env } = process;
|
|
23720
23720
|
var macos = (name) => {
|
|
23721
|
-
const library =
|
|
23721
|
+
const library = path72.join(homedir, "Library");
|
|
23722
23722
|
return {
|
|
23723
|
-
data:
|
|
23724
|
-
config:
|
|
23725
|
-
cache:
|
|
23726
|
-
log:
|
|
23727
|
-
temp:
|
|
23723
|
+
data: path72.join(library, "Application Support", name),
|
|
23724
|
+
config: path72.join(library, "Preferences", name),
|
|
23725
|
+
cache: path72.join(library, "Caches", name),
|
|
23726
|
+
log: path72.join(library, "Logs", name),
|
|
23727
|
+
temp: path72.join(tmpdir, name)
|
|
23728
23728
|
};
|
|
23729
23729
|
};
|
|
23730
23730
|
var windows = (name) => {
|
|
23731
|
-
const appData = env.APPDATA ||
|
|
23732
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
23731
|
+
const appData = env.APPDATA || path72.join(homedir, "AppData", "Roaming");
|
|
23732
|
+
const localAppData = env.LOCALAPPDATA || path72.join(homedir, "AppData", "Local");
|
|
23733
23733
|
return {
|
|
23734
23734
|
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
23735
|
-
data:
|
|
23736
|
-
config:
|
|
23737
|
-
cache:
|
|
23738
|
-
log:
|
|
23739
|
-
temp:
|
|
23735
|
+
data: path72.join(localAppData, name, "Data"),
|
|
23736
|
+
config: path72.join(appData, name, "Config"),
|
|
23737
|
+
cache: path72.join(localAppData, name, "Cache"),
|
|
23738
|
+
log: path72.join(localAppData, name, "Log"),
|
|
23739
|
+
temp: path72.join(tmpdir, name)
|
|
23740
23740
|
};
|
|
23741
23741
|
};
|
|
23742
23742
|
var linux = (name) => {
|
|
23743
|
-
const username =
|
|
23743
|
+
const username = path72.basename(homedir);
|
|
23744
23744
|
return {
|
|
23745
|
-
data:
|
|
23746
|
-
config:
|
|
23747
|
-
cache:
|
|
23745
|
+
data: path72.join(env.XDG_DATA_HOME || path72.join(homedir, ".local", "share"), name),
|
|
23746
|
+
config: path72.join(env.XDG_CONFIG_HOME || path72.join(homedir, ".config"), name),
|
|
23747
|
+
cache: path72.join(env.XDG_CACHE_HOME || path72.join(homedir, ".cache"), name),
|
|
23748
23748
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
23749
|
-
log:
|
|
23750
|
-
temp:
|
|
23749
|
+
log: path72.join(env.XDG_STATE_HOME || path72.join(homedir, ".local", "state"), name),
|
|
23750
|
+
temp: path72.join(tmpdir, username, name)
|
|
23751
23751
|
};
|
|
23752
23752
|
};
|
|
23753
23753
|
var envPaths = (name, options) => {
|
|
@@ -23815,11 +23815,11 @@ var require_util = __commonJS({
|
|
|
23815
23815
|
return result;
|
|
23816
23816
|
}
|
|
23817
23817
|
exports2.emplace = emplace;
|
|
23818
|
-
function getPropertyByPath(source,
|
|
23819
|
-
if (typeof
|
|
23820
|
-
return source[
|
|
23818
|
+
function getPropertyByPath(source, path72) {
|
|
23819
|
+
if (typeof path72 === "string" && Object.prototype.hasOwnProperty.call(source, path72)) {
|
|
23820
|
+
return source[path72];
|
|
23821
23821
|
}
|
|
23822
|
-
const parsedPath = typeof
|
|
23822
|
+
const parsedPath = typeof path72 === "string" ? path72.split(".") : path72;
|
|
23823
23823
|
return parsedPath.reduce((previous, key) => {
|
|
23824
23824
|
if (previous === void 0) {
|
|
23825
23825
|
return previous;
|
|
@@ -23842,9 +23842,9 @@ var require_util = __commonJS({
|
|
|
23842
23842
|
return Object.fromEntries(Object.entries(options).filter(([, value2]) => value2 !== void 0));
|
|
23843
23843
|
}
|
|
23844
23844
|
exports2.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
|
|
23845
|
-
async function isDirectory(
|
|
23845
|
+
async function isDirectory(path72) {
|
|
23846
23846
|
try {
|
|
23847
|
-
const stat = await fs_1.promises.stat(
|
|
23847
|
+
const stat = await fs_1.promises.stat(path72);
|
|
23848
23848
|
return stat.isDirectory();
|
|
23849
23849
|
} catch (e14) {
|
|
23850
23850
|
if (e14.code === "ENOENT") {
|
|
@@ -23854,9 +23854,9 @@ var require_util = __commonJS({
|
|
|
23854
23854
|
}
|
|
23855
23855
|
}
|
|
23856
23856
|
exports2.isDirectory = isDirectory;
|
|
23857
|
-
function isDirectorySync(
|
|
23857
|
+
function isDirectorySync(path72) {
|
|
23858
23858
|
try {
|
|
23859
|
-
const stat = fs_1.default.statSync(
|
|
23859
|
+
const stat = fs_1.default.statSync(path72);
|
|
23860
23860
|
return stat.isDirectory();
|
|
23861
23861
|
} catch (e14) {
|
|
23862
23862
|
if (e14.code === "ENOENT") {
|
|
@@ -23954,7 +23954,7 @@ var require_ExplorerBase = __commonJS({
|
|
|
23954
23954
|
const idx = importStack.indexOf(fullPath);
|
|
23955
23955
|
if (idx !== -1) {
|
|
23956
23956
|
throw new Error(`Circular import detected:
|
|
23957
|
-
${[...importStack, fullPath].map((
|
|
23957
|
+
${[...importStack, fullPath].map((path72, i10) => `${i10 + 1}. ${path72}`).join("\n")} (same as ${idx + 1}.)`);
|
|
23958
23958
|
}
|
|
23959
23959
|
}
|
|
23960
23960
|
}
|
|
@@ -24142,9 +24142,9 @@ var require_Explorer = __commonJS({
|
|
|
24142
24142
|
throw error63;
|
|
24143
24143
|
}
|
|
24144
24144
|
}
|
|
24145
|
-
async #fileExists(
|
|
24145
|
+
async #fileExists(path72) {
|
|
24146
24146
|
try {
|
|
24147
|
-
await promises_1.default.stat(
|
|
24147
|
+
await promises_1.default.stat(path72);
|
|
24148
24148
|
return true;
|
|
24149
24149
|
} catch (e14) {
|
|
24150
24150
|
return false;
|
|
@@ -24304,9 +24304,9 @@ var require_ExplorerSync = __commonJS({
|
|
|
24304
24304
|
throw error63;
|
|
24305
24305
|
}
|
|
24306
24306
|
}
|
|
24307
|
-
#fileExists(
|
|
24307
|
+
#fileExists(path72) {
|
|
24308
24308
|
try {
|
|
24309
|
-
fs_1.default.statSync(
|
|
24309
|
+
fs_1.default.statSync(path72);
|
|
24310
24310
|
return true;
|
|
24311
24311
|
} catch (e14) {
|
|
24312
24312
|
return false;
|
|
@@ -24430,7 +24430,7 @@ var require_dist = __commonJS({
|
|
|
24430
24430
|
};
|
|
24431
24431
|
}
|
|
24432
24432
|
function getResolvedSearchPlaces(moduleName, toolDefinedSearchPlaces, userConfiguredOptions) {
|
|
24433
|
-
const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((
|
|
24433
|
+
const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path72) => path72.replace("{name}", moduleName));
|
|
24434
24434
|
if (userConfiguredOptions.mergeSearchPlaces) {
|
|
24435
24435
|
return [...userConfiguredSearchPlaces ?? [], ...toolDefinedSearchPlaces];
|
|
24436
24436
|
}
|
|
@@ -24560,7 +24560,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
24560
24560
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
24561
24561
|
}
|
|
24562
24562
|
function describeIgnoredKeys(filePath, ignored) {
|
|
24563
|
-
const places = ignored.map(({ path:
|
|
24563
|
+
const places = ignored.map(({ path: path72, keys }) => `${path72.length === 0 ? "" : `${path72.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
24564
24564
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
24565
24565
|
}
|
|
24566
24566
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -24582,9 +24582,9 @@ function restoreIgnoredKeys(filePath, value2) {
|
|
|
24582
24582
|
return value2;
|
|
24583
24583
|
}
|
|
24584
24584
|
const restored = structuredClone(value2);
|
|
24585
|
-
for (const { path:
|
|
24585
|
+
for (const { path: path72, values } of ignored) {
|
|
24586
24586
|
let holder = restored;
|
|
24587
|
-
for (const step2 of
|
|
24587
|
+
for (const step2 of path72) {
|
|
24588
24588
|
holder = isRecord(holder) ? holder[step2] : void 0;
|
|
24589
24589
|
}
|
|
24590
24590
|
if (isRecord(holder)) {
|
|
@@ -24812,10 +24812,6 @@ function spawnSyncBlocking(operation, command, args, options) {
|
|
|
24812
24812
|
refuseToBlockInRole(operation);
|
|
24813
24813
|
return (0, import_node_child_process2.spawnSync)(command, args, options ?? {});
|
|
24814
24814
|
}
|
|
24815
|
-
function execFileSyncBlocking(operation, file2, args, options) {
|
|
24816
|
-
refuseToBlockInRole(operation);
|
|
24817
|
-
return (0, import_node_child_process2.execFileSync)(file2, args, options ?? {});
|
|
24818
|
-
}
|
|
24819
24815
|
var import_node_child_process2;
|
|
24820
24816
|
var init_blockingSpawn = __esm({
|
|
24821
24817
|
"src/blockingSpawn.ts"() {
|
|
@@ -25391,18 +25387,37 @@ var init_string_width = __esm({
|
|
|
25391
25387
|
function drawsNothing(text5) {
|
|
25392
25388
|
return stringWidth(text5.replace(BLANK_CELLS, "")) === 0;
|
|
25393
25389
|
}
|
|
25394
|
-
var BLANK_CELLS;
|
|
25390
|
+
var BLANK_CELLS, BLANK_CELLS_BUT_SPACE;
|
|
25395
25391
|
var init_blank = __esm({
|
|
25396
25392
|
"src/statusline/blank.ts"() {
|
|
25397
25393
|
"use strict";
|
|
25398
25394
|
init_string_width();
|
|
25399
25395
|
BLANK_CELLS = /[\p{Zs}\u2800\u3164\uFFA0]/gu;
|
|
25396
|
+
BLANK_CELLS_BUT_SPACE = new RegExp(`[${BLANK_CELLS.source}--[ ]]`, "gv");
|
|
25400
25397
|
}
|
|
25401
25398
|
});
|
|
25402
25399
|
|
|
25403
25400
|
// src/statusline/graphemes.ts
|
|
25401
|
+
function* graphemeStream(text5) {
|
|
25402
|
+
for (const part of SEGMENTER.segment(text5)) {
|
|
25403
|
+
yield part.segment;
|
|
25404
|
+
}
|
|
25405
|
+
}
|
|
25404
25406
|
function graphemesOf(text5) {
|
|
25405
|
-
return Array.from(
|
|
25407
|
+
return Array.from(graphemeStream(text5));
|
|
25408
|
+
}
|
|
25409
|
+
function leadingGraphemes(text5, count2) {
|
|
25410
|
+
const taken = [];
|
|
25411
|
+
if (count2 <= 0) {
|
|
25412
|
+
return taken;
|
|
25413
|
+
}
|
|
25414
|
+
for (const grapheme of graphemeStream(text5)) {
|
|
25415
|
+
taken.push(grapheme);
|
|
25416
|
+
if (taken.length >= count2) {
|
|
25417
|
+
break;
|
|
25418
|
+
}
|
|
25419
|
+
}
|
|
25420
|
+
return taken;
|
|
25406
25421
|
}
|
|
25407
25422
|
var SEGMENTER;
|
|
25408
25423
|
var init_graphemes = __esm({
|
|
@@ -25480,7 +25495,7 @@ function resolveStatusline(settings2) {
|
|
|
25480
25495
|
}
|
|
25481
25496
|
return resolved;
|
|
25482
25497
|
}
|
|
25483
|
-
var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_ROWS, STATUSLINE_SESSION_TIME_PARTS, PROMPT_CACHE_TTL_SECONDS, STATUSLINE_COLOUR_NAMES, DEFAULT_HEADER_SEGMENTS, DEFAULT_ROWS, STATUSLINE_PRESETS, GIT_WITH_DIRTY_MARKER, JJ_OFF, PRESET_BUNDLES, STATUSLINE_PATH_LEVELS, STATUSLINE_USAGE_VALUES, STATUSLINE_TIME_FORMATS, STATUSLINE_HOUR_CYCLES, MAX_PERCENT, MAX_STATUSLINE_PALETTE_INDEX, MAX_STATUSLINE_LABEL_COLUMNS, MIN_STATUSLINE_COLUMNS, MAX_STATUSLINE_COLUMNS, MAX_BAR_CELLS, MAX_ACCOUNT_USER_CHARS, MAX_DISPLAY_TEXT_CHARS, LABEL_RE2, OPTIONAL_LABEL_RE, mergeGroups, colourValue, barCharacter, STATUSLINE_CONTEXT_VALUES, STATUSLINE_CONTEXT_ESTIMATES, AUTOCOMPACT_RESERVE_FRACTION, AUTOCOMPACT_RESERVE_RAMP_START, AUTOCOMPACT_RESERVE_RAMP_END, labelWithinColumns, labelWithinColumnsMessage, labelShowsSomething, labelShowsSomethingMessage, labelIsPlainText, labelIsPlainTextMessage, windowLabel, overrideText, wholePercent, thresholdPercent, SHAPES, UNSET_NOTE, LANGUAGE_DESCRIPTION, LANGUAGE_TAGS, LANGUAGE_ALIASES, TOP_LEVEL, StatuslineSchema, ResolvedStatuslineSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
|
|
25498
|
+
var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_ROWS, STATUSLINE_SESSION_TIME_PARTS, PROMPT_CACHE_TTL_SECONDS, ORANGE_PALETTE_INDEX, STATUSLINE_COLOUR_NAMES, DEFAULT_HEADER_SEGMENTS, DEFAULT_ROWS, STATUSLINE_PRESETS, GIT_WITH_DIRTY_MARKER, JJ_OFF, PRESET_BUNDLES, STATUSLINE_PATH_LEVELS, STATUSLINE_USAGE_VALUES, STATUSLINE_TIME_FORMATS, STATUSLINE_HOUR_CYCLES, MAX_PERCENT, MAX_STATUSLINE_PALETTE_INDEX, MAX_STATUSLINE_LABEL_COLUMNS, MIN_STATUSLINE_COLUMNS, MAX_STATUSLINE_COLUMNS, MAX_BAR_CELLS, MAX_ACCOUNT_USER_CHARS, MAX_DISPLAY_TEXT_CHARS, MAX_EXTRA_COMMAND_ARGUMENTS, MAX_EXTRA_COMMAND_ARGUMENT_CHARS, STATUSLINE_EXTRA_GROUP, commandArgument, LABEL_RE2, OPTIONAL_LABEL_RE, mergeGroups, colourValue, barCharacter, STATUSLINE_CONTEXT_VALUES, STATUSLINE_CONTEXT_ESTIMATES, AUTOCOMPACT_RESERVE_FRACTION, AUTOCOMPACT_RESERVE_RAMP_START, AUTOCOMPACT_RESERVE_RAMP_END, labelWithinColumns, labelWithinColumnsMessage, labelShowsSomething, labelShowsSomethingMessage, labelIsPlainText, labelIsPlainTextMessage, windowLabel, overrideText, wholePercent, thresholdPercent, SHAPES, UNSET_NOTE, LANGUAGE_DESCRIPTION, LANGUAGE_TAGS, LANGUAGE_ALIASES, TOP_LEVEL, StatuslineSchema, ResolvedStatuslineSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
|
|
25484
25499
|
var init_statusline = __esm({
|
|
25485
25500
|
"src/config/statusline.ts"() {
|
|
25486
25501
|
"use strict";
|
|
@@ -25489,10 +25504,11 @@ var init_statusline = __esm({
|
|
|
25489
25504
|
init_blank();
|
|
25490
25505
|
init_graphemes();
|
|
25491
25506
|
init_languages();
|
|
25492
|
-
STATUSLINE_HEADER_SEGMENTS = ["model", "provider", "route", "account", "identity", "headroom", "project", "vcs", "effort", "advisor", "version", "outputStyle", "cost", "dailyCost", "sessionName", "duration", "speed"];
|
|
25507
|
+
STATUSLINE_HEADER_SEGMENTS = ["model", "provider", "route", "account", "identity", "headroom", "project", "vcs", "effort", "advisor", "version", "outputStyle", "cost", "dailyCost", "sessionName", "duration", "speed", "extra"];
|
|
25493
25508
|
STATUSLINE_ROWS = ["context", "quota", "addedDirs", "gitFiles", "memory", "environment", "sessionTime", "promptCache", "compactions", "tokens", "tools", "skills", "mcp", "agents", "todos"];
|
|
25494
25509
|
STATUSLINE_SESSION_TIME_PARTS = ["started", "lastReply"];
|
|
25495
25510
|
PROMPT_CACHE_TTL_SECONDS = { fiveMinutes: 300, oneHour: 3600 };
|
|
25511
|
+
ORANGE_PALETTE_INDEX = 208;
|
|
25496
25512
|
STATUSLINE_COLOUR_NAMES = [
|
|
25497
25513
|
"default",
|
|
25498
25514
|
"dim",
|
|
@@ -25521,14 +25537,14 @@ var init_statusline = __esm({
|
|
|
25521
25537
|
PRESET_BUNDLES = {
|
|
25522
25538
|
standard: { layout: { header: DEFAULT_HEADER_SEGMENTS, rows: DEFAULT_ROWS }, git: GIT_WITH_DIRTY_MARKER, jj: JJ_OFF, usage: { resetLabel: false }, context: { breakdown: "never" } },
|
|
25523
25539
|
full: {
|
|
25524
|
-
layout: { header: ["model", "project", "vcs", "effort", "advisor", "version", "outputStyle", "cost", "sessionName", "duration"], rows: ["context", "quota", "addedDirs", "memory", "environment", "tools", "skills", "mcp", "agents", "todos", "promptCache", "compactions", "tokens"] },
|
|
25540
|
+
layout: { header: ["model", "project", "vcs", "effort", "advisor", "version", "extra", "outputStyle", "cost", "sessionName", "duration"], rows: ["context", "quota", "addedDirs", "memory", "environment", "tools", "skills", "mcp", "agents", "todos", "promptCache", "compactions", "tokens"] },
|
|
25525
25541
|
git: GIT_WITH_DIRTY_MARKER,
|
|
25526
25542
|
jj: { enabled: true, showDirty: true, showConflicts: true },
|
|
25527
25543
|
usage: { resetLabel: true },
|
|
25528
25544
|
context: { breakdown: "critical" }
|
|
25529
25545
|
},
|
|
25530
|
-
essential: { layout: { header: ["model", "project", "vcs", "duration"], rows: ["context", "addedDirs", "tools", "agents", "todos"] }, git: GIT_WITH_DIRTY_MARKER, jj: JJ_OFF, usage: { resetLabel: true }, context: { breakdown: "never" } },
|
|
25531
|
-
minimal: { layout: { header: ["model", "project", "vcs"], rows: ["context", "addedDirs"] }, git: GIT_WITH_DIRTY_MARKER, jj: JJ_OFF, usage: { resetLabel: true }, context: { breakdown: "never" } }
|
|
25546
|
+
essential: { layout: { header: ["model", "project", "vcs", "extra", "duration"], rows: ["context", "addedDirs", "tools", "agents", "todos"] }, git: GIT_WITH_DIRTY_MARKER, jj: JJ_OFF, usage: { resetLabel: true }, context: { breakdown: "never" } },
|
|
25547
|
+
minimal: { layout: { header: ["model", "project", "vcs", "extra"], rows: ["context", "addedDirs"] }, git: GIT_WITH_DIRTY_MARKER, jj: JJ_OFF, usage: { resetLabel: true }, context: { breakdown: "never" } }
|
|
25532
25548
|
};
|
|
25533
25549
|
STATUSLINE_PATH_LEVELS = ["1", "2", "3", "full"];
|
|
25534
25550
|
STATUSLINE_USAGE_VALUES = ["used", "remaining"];
|
|
@@ -25542,6 +25558,10 @@ var init_statusline = __esm({
|
|
|
25542
25558
|
MAX_BAR_CELLS = 40;
|
|
25543
25559
|
MAX_ACCOUNT_USER_CHARS = 254;
|
|
25544
25560
|
MAX_DISPLAY_TEXT_CHARS = 80;
|
|
25561
|
+
MAX_EXTRA_COMMAND_ARGUMENTS = 16;
|
|
25562
|
+
MAX_EXTRA_COMMAND_ARGUMENT_CHARS = 1024;
|
|
25563
|
+
STATUSLINE_EXTRA_GROUP = "extra";
|
|
25564
|
+
commandArgument = external_exports.string().max(MAX_EXTRA_COMMAND_ARGUMENT_CHARS).refine((argument) => !argument.includes("\0"), "must not contain a NUL character");
|
|
25545
25565
|
LABEL_RE2 = /^[^\p{C}\p{Z}]+(?: [^\p{C}\p{Z}]+)*$/u;
|
|
25546
25566
|
OPTIONAL_LABEL_RE = /^(?:[^\p{C}\p{Z}]+(?: [^\p{C}\p{Z}]+)*)?$/u;
|
|
25547
25567
|
mergeGroups = external_exports.array(distinctList(external_exports.enum(STATUSLINE_ROWS)).min(2)).refine((groups) => {
|
|
@@ -25604,6 +25624,15 @@ var init_statusline = __esm({
|
|
|
25604
25624
|
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)}%).`),
|
|
25605
25625
|
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.")
|
|
25606
25626
|
},
|
|
25627
|
+
customLine: {
|
|
25628
|
+
text: overrideText.describe(`A line of your own text to draw, in colours.custom; empty draws nothing. It is refused when longer than ${String(MAX_DISPLAY_TEXT_CHARS)} characters or when it holds control, format or separator characters, and words are separated by single spaces. A character that passes but draws nothing, such as a braille blank, is removed, and the line is cut to the usable width.`),
|
|
25629
|
+
position: external_exports.enum(["first", "last"]).describe("Where the custom line sits: first draws it above the header, and last below the last row, as a line of its own in either layout mode.")
|
|
25630
|
+
},
|
|
25631
|
+
extra: {
|
|
25632
|
+
command: external_exports.array(commandArgument).max(MAX_EXTRA_COMMAND_ARGUMENTS).refine((command) => command[0]?.startsWith("-") !== true, "the program, the first item, must not start with a dash, which the system would read as an option: name it by an absolute path").describe(
|
|
25633
|
+
`The program and arguments the extra segment runs, as a list and not a shell string (for example ["git", "describe", "--tags"]). The first line of its standard output that shows something, or the label of a JSON object it prints, is the segment; a line with nothing a person could see in it, such as spaces, zero-width characters or an escape sequence alone, is skipped. Escape sequences are removed from the whole output first, so an operating system command with no terminator removes everything up to the next escape character or the end of the output, line breaks included. A command that fails or prints nothing draws nothing. It is refused when it has more than ${String(MAX_EXTRA_COMMAND_ARGUMENTS)} arguments (the program included), when an argument is longer than ${String(MAX_EXTRA_COMMAND_ARGUMENT_CHARS)} characters or holds a NUL, and when the program starts with a dash. It runs on every refresh with your privileges and the statusline's whole environment. Its output is written to a file the system limits in size. That limit applies to every file it writes and every process it starts, so a program that writes a large cache is stopped and draws nothing, and so does one whose output reaches the limit. A process it starts is left running when it is killed for outrunning its time limit or when a newer update cancels the refresh. Because it runs a program with your privileges, only your own configuration may set it. That means the global config, a profile in your config-profiles directory, a directory rule or a command-line assignment. A project file such as .agent-shim.json is refused, though it may select one of your profiles by name, and a config write through the door's API (an MCP agent or the web client with the writes grant) is refused the extra settings for the same reason.`
|
|
25634
|
+
)
|
|
25635
|
+
},
|
|
25607
25636
|
bands: {
|
|
25608
25637
|
warnAt: wholePercent.describe("The whole percentage of use at which a bar turns yellow; it must be below criticalAt."),
|
|
25609
25638
|
criticalAt: wholePercent.describe("The whole percentage of use at which a bar turns red.")
|
|
@@ -25660,7 +25689,8 @@ var init_statusline = __esm({
|
|
|
25660
25689
|
git: colourValue.describe("The colour of the version control segment's wrapper text (`git:(` and `)`)."),
|
|
25661
25690
|
gitBranch: colourValue.describe("The colour of the branch or bookmark and its ahead, behind and dirty markers."),
|
|
25662
25691
|
activity: colourValue.describe("The colour of the names of the tools, skills and MCP servers the tools, skills and mcp rows draw. Their running markers take colours.warning and their finished markers colours.context."),
|
|
25663
|
-
agent: colourValue.describe("The colour of an agent's type in the agents row.")
|
|
25692
|
+
agent: colourValue.describe("The colour of an agent's type in the agents row."),
|
|
25693
|
+
custom: colourValue.describe("The colour of the custom line.")
|
|
25664
25694
|
},
|
|
25665
25695
|
project: {
|
|
25666
25696
|
pathLevels: external_exports.enum(STATUSLINE_PATH_LEVELS).describe("How many trailing directories of the working directory the project segment shows: 1, 2 or 3, or full for the whole absolute path."),
|
|
@@ -25687,7 +25717,7 @@ var init_statusline = __esm({
|
|
|
25687
25717
|
LANGUAGE_ALIASES = { zh: "zh-Hans", "zh-TW": "zh-Hant" };
|
|
25688
25718
|
TOP_LEVEL = {
|
|
25689
25719
|
language: external_exports.enum(STATUSLINE_LANGUAGES).describe(LANGUAGE_DESCRIPTION),
|
|
25690
|
-
preset: external_exports.enum(STATUSLINE_PRESETS).describe("A named bundle of settings (layout.header, layout.rows, git.enabled, git.showDirty, git.showAheadBehind, git.showLineDiff, jj.enabled, jj.showDirty, jj.showConflicts, usage.resetLabel and context.breakdown) that this layer sets beneath the keys it names itself and above everything the shallower layers set: standard is the statusline's own; full, essential and minimal are claude-hud's presets. Each draws the model, project and version control segments and the context row; full adds the effort, advisor, version, output style, cost, session name and duration segments and the quota, added directories, memory, environment, tools, skills, mcp, agents, todos, prompt cache, compactions and session tokens rows, with the token breakdown at high use, essential adds the duration, the added directories row and the tools, agents and todos rows, and minimal adds the added directories row alone.")
|
|
25720
|
+
preset: external_exports.enum(STATUSLINE_PRESETS).describe("A named bundle of settings (layout.header, layout.rows, git.enabled, git.showDirty, git.showAheadBehind, git.showLineDiff, jj.enabled, jj.showDirty, jj.showConflicts, usage.resetLabel and context.breakdown) that this layer sets beneath the keys it names itself and above everything the shallower layers set: standard is the statusline's own; full, essential and minimal are claude-hud's presets. Each draws the model, project and version control segments, the extra segment once extra.command is set, and the context row; full adds the effort, advisor, version, output style, cost, session name and duration segments and the quota, added directories, memory, environment, tools, skills, mcp, agents, todos, prompt cache, compactions and session tokens rows, with the token breakdown at high use, essential adds the duration, the added directories row and the tools, agents and todos rows, and minimal adds the added directories row alone.")
|
|
25691
25721
|
};
|
|
25692
25722
|
StatuslineSchema = external_exports.strictObject({
|
|
25693
25723
|
language: external_exports.enum(LANGUAGE_TAGS).transform(canonicalLanguage).describe(LANGUAGE_DESCRIPTION).optional(),
|
|
@@ -25699,6 +25729,8 @@ var init_statusline = __esm({
|
|
|
25699
25729
|
effort: external_exports.strictObject(SHAPES.effort).partial().optional(),
|
|
25700
25730
|
advisor: external_exports.strictObject(SHAPES.advisor).partial().optional(),
|
|
25701
25731
|
context: external_exports.strictObject({ ...SHAPES.context, warnAt: unsettable(SHAPES.context.warnAt), criticalAt: unsettable(SHAPES.context.criticalAt), autoCompactWindow: unsettable(SHAPES.context.autoCompactWindow) }).partial().optional(),
|
|
25732
|
+
customLine: external_exports.strictObject(SHAPES.customLine).partial().optional(),
|
|
25733
|
+
extra: external_exports.strictObject(SHAPES.extra).partial().optional(),
|
|
25702
25734
|
bands: external_exports.strictObject(SHAPES.bands).partial().optional(),
|
|
25703
25735
|
labels: external_exports.strictObject(SHAPES.labels).partial().optional(),
|
|
25704
25736
|
bar: external_exports.strictObject(SHAPES.bar).partial().optional(),
|
|
@@ -25724,6 +25756,8 @@ var init_statusline = __esm({
|
|
|
25724
25756
|
effort: external_exports.strictObject(SHAPES.effort),
|
|
25725
25757
|
advisor: external_exports.strictObject(SHAPES.advisor),
|
|
25726
25758
|
context: external_exports.strictObject(SHAPES.context),
|
|
25759
|
+
customLine: external_exports.strictObject(SHAPES.customLine),
|
|
25760
|
+
extra: external_exports.strictObject(SHAPES.extra),
|
|
25727
25761
|
bands: external_exports.strictObject(SHAPES.bands),
|
|
25728
25762
|
labels: external_exports.strictObject(SHAPES.labels),
|
|
25729
25763
|
bar: external_exports.strictObject(SHAPES.bar),
|
|
@@ -25749,6 +25783,8 @@ var init_statusline = __esm({
|
|
|
25749
25783
|
effort: { format: "full" },
|
|
25750
25784
|
advisor: { override: "" },
|
|
25751
25785
|
context: { bar: "shown", value: "both", estimate: "never", breakdown: "never" },
|
|
25786
|
+
customLine: { text: "", position: "last" },
|
|
25787
|
+
extra: { command: [] },
|
|
25752
25788
|
bands: { warnAt: 70, criticalAt: 90 },
|
|
25753
25789
|
labels: { fiveHour: "", sevenDay: "" },
|
|
25754
25790
|
bar: { width: 10, filled: "\u2588", empty: "\u2591" },
|
|
@@ -25772,7 +25808,8 @@ var init_statusline = __esm({
|
|
|
25772
25808
|
git: "magenta",
|
|
25773
25809
|
gitBranch: "cyan",
|
|
25774
25810
|
activity: "cyan",
|
|
25775
|
-
agent: "magenta"
|
|
25811
|
+
agent: "magenta",
|
|
25812
|
+
custom: ORANGE_PALETTE_INDEX
|
|
25776
25813
|
},
|
|
25777
25814
|
project: { pathLevels: "1", addedDirsLayout: "inline" },
|
|
25778
25815
|
git: { enabled: true, showDirty: true, showAheadBehind: false, showLineDiff: false, branchOverflow: "truncate", pushWarnAt: 0, pushCriticalAt: 0 },
|
|
@@ -28148,6 +28185,10 @@ var init_schema = __esm({
|
|
|
28148
28185
|
configProfile: FileNameSchema.optional(),
|
|
28149
28186
|
identity: IdentitySelectorSchema.optional(),
|
|
28150
28187
|
when: WhenSchema.optional()
|
|
28188
|
+
}).superRefine((config2, context) => {
|
|
28189
|
+
if (config2.launch?.statusline?.[STATUSLINE_EXTRA_GROUP] !== void 0) {
|
|
28190
|
+
context.addIssue({ code: "custom", path: ["launch", "statusline", STATUSLINE_EXTRA_GROUP], message: "a project file cannot set the statusline's extra command: it runs a program, so only your own configuration (the global config, a profile, a directory rule) may set it" });
|
|
28191
|
+
}
|
|
28151
28192
|
});
|
|
28152
28193
|
HEADROOM_MODES = ["cache", "token"];
|
|
28153
28194
|
HEADROOM_CCR_MODES = ["default", "lossless", "none"];
|
|
@@ -28345,28 +28386,38 @@ function recordOf(details) {
|
|
|
28345
28386
|
}
|
|
28346
28387
|
function writeFrontDoorSession(fs31, sessionsDir, session) {
|
|
28347
28388
|
fs31.mkdirPrivate(sessionsDir);
|
|
28348
|
-
fs31.writeFilePrivate(import_node_path6.default.join(sessionsDir,
|
|
28389
|
+
fs31.writeFilePrivate(import_node_path6.default.join(sessionsDir, sessionRecordName(session.pid)), `${JSON.stringify(session, null, 2)}
|
|
28349
28390
|
`);
|
|
28350
28391
|
}
|
|
28392
|
+
function sessionRecordName(pid) {
|
|
28393
|
+
return `${String(pid)}.json`;
|
|
28394
|
+
}
|
|
28395
|
+
function isSessionRecordName(name) {
|
|
28396
|
+
return name.endsWith(".json");
|
|
28397
|
+
}
|
|
28398
|
+
function summaryOf(session) {
|
|
28399
|
+
return { pid: session.pid, startedAt: session.startedAt, ...session.supervisorPid === void 0 ? {} : { supervisorPid: session.supervisorPid } };
|
|
28400
|
+
}
|
|
28401
|
+
function readFrontDoorSessionRecord(fs31, sessionsDir, name) {
|
|
28402
|
+
try {
|
|
28403
|
+
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs31.readFileUtf8(import_node_path6.default.join(sessionsDir, name)) ?? ""));
|
|
28404
|
+
return parsed.success ? parsed.data : void 0;
|
|
28405
|
+
} catch {
|
|
28406
|
+
return void 0;
|
|
28407
|
+
}
|
|
28408
|
+
}
|
|
28351
28409
|
function listFrontDoorSessions(fs31, sessionsDir) {
|
|
28352
28410
|
const sessions = [];
|
|
28353
28411
|
for (const name of fs31.readdir(sessionsDir)) {
|
|
28354
|
-
|
|
28355
|
-
|
|
28356
|
-
|
|
28357
|
-
try {
|
|
28358
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs31.readFileUtf8(import_node_path6.default.join(sessionsDir, name)) ?? ""));
|
|
28359
|
-
if (parsed.success) {
|
|
28360
|
-
sessions.push({ pid: parsed.data.pid, startedAt: parsed.data.startedAt, ...parsed.data.supervisorPid === void 0 ? {} : { supervisorPid: parsed.data.supervisorPid } });
|
|
28361
|
-
}
|
|
28362
|
-
} catch {
|
|
28363
|
-
continue;
|
|
28412
|
+
const record2 = isSessionRecordName(name) ? readFrontDoorSessionRecord(fs31, sessionsDir, name) : void 0;
|
|
28413
|
+
if (record2 !== void 0) {
|
|
28414
|
+
sessions.push(summaryOf(record2));
|
|
28364
28415
|
}
|
|
28365
28416
|
}
|
|
28366
28417
|
return sessions.sort((a10, b) => a10.pid - b.pid);
|
|
28367
28418
|
}
|
|
28368
28419
|
function removeFrontDoorSession(fs31, sessionsDir, pid) {
|
|
28369
|
-
fs31.removeRecursive(import_node_path6.default.join(sessionsDir,
|
|
28420
|
+
fs31.removeRecursive(import_node_path6.default.join(sessionsDir, sessionRecordName(pid)));
|
|
28370
28421
|
}
|
|
28371
28422
|
function pruneDeadFrontDoorSessions(fs31, sessionsDir, listed, isRunning) {
|
|
28372
28423
|
const removed = [];
|
|
@@ -28378,39 +28429,6 @@ function pruneDeadFrontDoorSessions(fs31, sessionsDir, listed, isRunning) {
|
|
|
28378
28429
|
}
|
|
28379
28430
|
return removed;
|
|
28380
28431
|
}
|
|
28381
|
-
function liveSessionTokens(fs31, sessionsDir) {
|
|
28382
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
28383
|
-
for (const name of fs31.readdir(sessionsDir)) {
|
|
28384
|
-
if (!name.endsWith(".json")) {
|
|
28385
|
-
continue;
|
|
28386
|
-
}
|
|
28387
|
-
try {
|
|
28388
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs31.readFileUtf8(import_node_path6.default.join(sessionsDir, name)) ?? ""));
|
|
28389
|
-
if (parsed.success) {
|
|
28390
|
-
tokens.add(parsed.data.token);
|
|
28391
|
-
}
|
|
28392
|
-
} catch {
|
|
28393
|
-
continue;
|
|
28394
|
-
}
|
|
28395
|
-
}
|
|
28396
|
-
return tokens;
|
|
28397
|
-
}
|
|
28398
|
-
function readFrontDoorSessionModels(fs31, sessionsDir, sessionId) {
|
|
28399
|
-
for (const name of fs31.readdir(sessionsDir)) {
|
|
28400
|
-
if (!name.endsWith(".json")) {
|
|
28401
|
-
continue;
|
|
28402
|
-
}
|
|
28403
|
-
try {
|
|
28404
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs31.readFileUtf8(import_node_path6.default.join(sessionsDir, name)) ?? ""));
|
|
28405
|
-
if (parsed.success && parsed.data.sessionId === sessionId) {
|
|
28406
|
-
return parsed.data.models;
|
|
28407
|
-
}
|
|
28408
|
-
} catch {
|
|
28409
|
-
continue;
|
|
28410
|
-
}
|
|
28411
|
-
}
|
|
28412
|
-
return void 0;
|
|
28413
|
-
}
|
|
28414
28432
|
var import_node_path6, FRONT_DOOR_PROTOCOL, FRONT_DOOR_HANDOVER_PROTOCOL, FrontDoorSessionSchema, FrontDoorStateSchema, MAX_TCP_PORT, FrontDoorDirectRecordSchema, RECORD_TEMPORARY_FILE;
|
|
28415
28433
|
var init_state = __esm({
|
|
28416
28434
|
"src/frontdoor/state.ts"() {
|
|
@@ -30874,8 +30892,8 @@ var require_utils = __commonJS({
|
|
|
30874
30892
|
}
|
|
30875
30893
|
return output2;
|
|
30876
30894
|
};
|
|
30877
|
-
exports2.basename = (
|
|
30878
|
-
const segs =
|
|
30895
|
+
exports2.basename = (path72, { windows } = {}) => {
|
|
30896
|
+
const segs = path72.split(windows ? /[\\/]/ : "/");
|
|
30879
30897
|
const last = segs[segs.length - 1];
|
|
30880
30898
|
if (last === "") {
|
|
30881
30899
|
return segs[segs.length - 2];
|
|
@@ -32655,9 +32673,9 @@ var init_identity = __esm({
|
|
|
32655
32673
|
});
|
|
32656
32674
|
|
|
32657
32675
|
// src/statusline/keys.ts
|
|
32658
|
-
function valueAt(source,
|
|
32676
|
+
function valueAt(source, path72) {
|
|
32659
32677
|
let current = source;
|
|
32660
|
-
for (const part of
|
|
32678
|
+
for (const part of path72) {
|
|
32661
32679
|
if (!isPlainObject2(current)) {
|
|
32662
32680
|
return void 0;
|
|
32663
32681
|
}
|
|
@@ -32665,10 +32683,10 @@ function valueAt(source, path71) {
|
|
|
32665
32683
|
}
|
|
32666
32684
|
return current;
|
|
32667
32685
|
}
|
|
32668
|
-
function keyOf(
|
|
32686
|
+
function keyOf(path72, declared) {
|
|
32669
32687
|
const optional2 = declared instanceof external_exports.ZodOptional;
|
|
32670
32688
|
const leaf = optional2 ? declared.unwrap() : declared;
|
|
32671
|
-
const common = { path:
|
|
32689
|
+
const common = { path: path72.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path72), optional: optional2 };
|
|
32672
32690
|
if (leaf instanceof external_exports.ZodNumber) {
|
|
32673
32691
|
return { ...common, kind: "integer", choices: [] };
|
|
32674
32692
|
}
|
|
@@ -32690,7 +32708,10 @@ function keyOf(path71, declared) {
|
|
|
32690
32708
|
if (leaf instanceof external_exports.ZodArray && leaf.element instanceof external_exports.ZodArray && leaf.element.element instanceof external_exports.ZodEnum) {
|
|
32691
32709
|
return { ...common, kind: "groups", choices: Object.values(leaf.element.element.enum).map(String) };
|
|
32692
32710
|
}
|
|
32693
|
-
|
|
32711
|
+
if (leaf instanceof external_exports.ZodArray && leaf.element instanceof external_exports.ZodString) {
|
|
32712
|
+
return { ...common, kind: "textList", choices: [] };
|
|
32713
|
+
}
|
|
32714
|
+
throw new TypeError(`statusline setting ${path72.join(".")} has a kind the key listing does not describe`);
|
|
32694
32715
|
}
|
|
32695
32716
|
function walk(shape, prefix) {
|
|
32696
32717
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof external_exports.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -32714,52 +32735,69 @@ var init_keys = __esm({
|
|
|
32714
32735
|
});
|
|
32715
32736
|
|
|
32716
32737
|
// src/statusline/change.ts
|
|
32717
|
-
function keyNamed(
|
|
32718
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
32738
|
+
function keyNamed(path72) {
|
|
32739
|
+
const found = statuslineKeys().find((key) => key.path === path72);
|
|
32719
32740
|
if (found === void 0) {
|
|
32720
|
-
throw new UsageError(`"${
|
|
32741
|
+
throw new UsageError(`"${path72}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
32721
32742
|
}
|
|
32722
32743
|
return found;
|
|
32723
32744
|
}
|
|
32745
|
+
function textListOf(path72, raw) {
|
|
32746
|
+
if (raw === "") {
|
|
32747
|
+
return [];
|
|
32748
|
+
}
|
|
32749
|
+
let parsed;
|
|
32750
|
+
try {
|
|
32751
|
+
parsed = JSON.parse(raw);
|
|
32752
|
+
} catch {
|
|
32753
|
+
throw new UsageError(`${path72}: "${raw}" is not a JSON array of strings such as ["git","describe"].`);
|
|
32754
|
+
}
|
|
32755
|
+
if (!Array.isArray(parsed) || parsed.some((item) => typeof item !== "string")) {
|
|
32756
|
+
throw new UsageError(`${path72}: "${raw}" is not a JSON array of strings such as ["git","describe"].`);
|
|
32757
|
+
}
|
|
32758
|
+
return parsed;
|
|
32759
|
+
}
|
|
32724
32760
|
function parseStatuslineAssignment(text5) {
|
|
32725
32761
|
const split = text5.indexOf("=");
|
|
32726
32762
|
if (split < 1) {
|
|
32727
32763
|
throw new UsageError(`"${text5}" is not <setting>=<value>.`);
|
|
32728
32764
|
}
|
|
32729
|
-
const
|
|
32765
|
+
const path72 = text5.slice(0, split);
|
|
32730
32766
|
const raw = text5.slice(split + 1);
|
|
32731
|
-
const key = keyNamed(
|
|
32767
|
+
const key = keyNamed(path72);
|
|
32732
32768
|
if (key.optional && raw === UNSET_WORD) {
|
|
32733
|
-
return { path:
|
|
32769
|
+
return { path: path72, value: null };
|
|
32734
32770
|
}
|
|
32735
32771
|
switch (key.kind) {
|
|
32736
32772
|
case "integer": {
|
|
32737
32773
|
const number6 = Number(raw);
|
|
32738
32774
|
if (raw.trim() === "" || !Number.isFinite(number6)) {
|
|
32739
|
-
throw new UsageError(`${
|
|
32775
|
+
throw new UsageError(`${path72}: "${raw}" is not a number.`);
|
|
32740
32776
|
}
|
|
32741
|
-
return { path:
|
|
32777
|
+
return { path: path72, value: number6 };
|
|
32742
32778
|
}
|
|
32743
32779
|
case "boolean":
|
|
32744
32780
|
if (raw !== "true" && raw !== "false") {
|
|
32745
|
-
throw new UsageError(`${
|
|
32781
|
+
throw new UsageError(`${path72}: "${raw}" is not true or false.`);
|
|
32746
32782
|
}
|
|
32747
|
-
return { path:
|
|
32783
|
+
return { path: path72, value: raw === "true" };
|
|
32748
32784
|
case "text":
|
|
32749
32785
|
case "choice":
|
|
32750
|
-
return { path:
|
|
32786
|
+
return { path: path72, value: raw };
|
|
32751
32787
|
case "colour":
|
|
32752
|
-
return { path:
|
|
32788
|
+
return { path: path72, value: /^\d+$/.test(raw) ? Number(raw) : raw };
|
|
32753
32789
|
case "list":
|
|
32754
|
-
return { path:
|
|
32790
|
+
return { path: path72, value: raw === "" ? [] : raw.split(",") };
|
|
32755
32791
|
case "groups":
|
|
32756
|
-
return { path:
|
|
32792
|
+
return { path: path72, value: raw === "" ? [] : raw.split(";").map((group) => group.split(",")) };
|
|
32793
|
+
case "textList":
|
|
32794
|
+
return { path: path72, value: textListOf(path72, raw) };
|
|
32757
32795
|
default:
|
|
32758
32796
|
return key.kind;
|
|
32759
32797
|
}
|
|
32760
32798
|
}
|
|
32761
|
-
function setAt(target,
|
|
32762
|
-
const [head, ...rest] =
|
|
32799
|
+
function setAt(target, path72, value2) {
|
|
32800
|
+
const [head, ...rest] = path72;
|
|
32763
32801
|
if (head === void 0) {
|
|
32764
32802
|
return;
|
|
32765
32803
|
}
|
|
@@ -32772,8 +32810,8 @@ function setAt(target, path71, value2) {
|
|
|
32772
32810
|
target[head] = next;
|
|
32773
32811
|
setAt(next, rest, value2);
|
|
32774
32812
|
}
|
|
32775
|
-
function removeAt(target,
|
|
32776
|
-
const [head, ...rest] =
|
|
32813
|
+
function removeAt(target, path72) {
|
|
32814
|
+
const [head, ...rest] = path72;
|
|
32777
32815
|
if (head === void 0) {
|
|
32778
32816
|
return;
|
|
32779
32817
|
}
|
|
@@ -32791,13 +32829,13 @@ function removeAt(target, path71) {
|
|
|
32791
32829
|
}
|
|
32792
32830
|
function applyStatuslineChange(existing, change) {
|
|
32793
32831
|
const draft = structuredClone(existing ?? {});
|
|
32794
|
-
for (const [
|
|
32795
|
-
keyNamed(
|
|
32796
|
-
setAt(draft,
|
|
32832
|
+
for (const [path72, value2] of Object.entries(change.set ?? {})) {
|
|
32833
|
+
keyNamed(path72);
|
|
32834
|
+
setAt(draft, path72.split("."), value2);
|
|
32797
32835
|
}
|
|
32798
|
-
for (const
|
|
32799
|
-
keyNamed(
|
|
32800
|
-
removeAt(draft,
|
|
32836
|
+
for (const path72 of change.unset ?? []) {
|
|
32837
|
+
keyNamed(path72);
|
|
32838
|
+
removeAt(draft, path72.split("."));
|
|
32801
32839
|
}
|
|
32802
32840
|
const result = StatuslineSchema.safeParse(draft);
|
|
32803
32841
|
if (!result.success) {
|
|
@@ -36287,11 +36325,11 @@ function identifyRequest(headers) {
|
|
|
36287
36325
|
function directOrigin2(port) {
|
|
36288
36326
|
return `http://127.0.0.1:${String(port)}`;
|
|
36289
36327
|
}
|
|
36290
|
-
function parseProviderPath(
|
|
36291
|
-
if (!
|
|
36328
|
+
function parseProviderPath(path72) {
|
|
36329
|
+
if (!path72.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
36292
36330
|
return void 0;
|
|
36293
36331
|
}
|
|
36294
|
-
const tail =
|
|
36332
|
+
const tail = path72.slice(PROVIDER_PATH_PREFIX.length);
|
|
36295
36333
|
const slash = tail.indexOf("/");
|
|
36296
36334
|
if (slash <= 0) {
|
|
36297
36335
|
return void 0;
|
|
@@ -36518,9 +36556,10 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
36518
36556
|
return FRONTDOOR_SUPERVISOR_STILL_RUNNING;
|
|
36519
36557
|
}
|
|
36520
36558
|
ticks += 1;
|
|
36521
|
-
const listed =
|
|
36559
|
+
const listed = ports.registry.rescan();
|
|
36522
36560
|
const running = await ports.runningAmong(listed.map((session) => session.pid));
|
|
36523
36561
|
const pruned = pruneDeadFrontDoorSessions(fs31, paths.frontdoorSessionsDir, listed, (pid) => running.has(pid));
|
|
36562
|
+
ports.registry.forget(pruned);
|
|
36524
36563
|
ports.observeLaunchRegistry(listed, pruned);
|
|
36525
36564
|
ports.checkQuotaExpiry();
|
|
36526
36565
|
const prunedPids = new Set(pruned);
|
|
@@ -36591,8 +36630,8 @@ function parseConnectTarget(authority) {
|
|
|
36591
36630
|
}
|
|
36592
36631
|
return { host, port };
|
|
36593
36632
|
}
|
|
36594
|
-
function servedByPipeline(
|
|
36595
|
-
return
|
|
36633
|
+
function servedByPipeline(path72) {
|
|
36634
|
+
return path72?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
36596
36635
|
}
|
|
36597
36636
|
function forwardableHeaders(headers) {
|
|
36598
36637
|
const connectionTokens = new Set(
|
|
@@ -37084,7 +37123,7 @@ var init_package = __esm({
|
|
|
37084
37123
|
"package.json"() {
|
|
37085
37124
|
package_default = {
|
|
37086
37125
|
name: "claude-use",
|
|
37087
|
-
version: "11.
|
|
37126
|
+
version: "11.65.1",
|
|
37088
37127
|
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.",
|
|
37089
37128
|
license: "MIT",
|
|
37090
37129
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -37607,12 +37646,12 @@ function decoderFor(encoding) {
|
|
|
37607
37646
|
return void 0;
|
|
37608
37647
|
}
|
|
37609
37648
|
}
|
|
37610
|
-
function destinationOf(
|
|
37611
|
-
const scoped = parseProviderPath(
|
|
37649
|
+
function destinationOf(path72, sessionProvider) {
|
|
37650
|
+
const scoped = parseProviderPath(path72);
|
|
37612
37651
|
if (scoped !== void 0) {
|
|
37613
37652
|
return { provider: scoped.provider, endpoint: scoped.rest };
|
|
37614
37653
|
}
|
|
37615
|
-
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint:
|
|
37654
|
+
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint: path72 };
|
|
37616
37655
|
}
|
|
37617
37656
|
function modelChoiceOf(event, servedModel, provider) {
|
|
37618
37657
|
if (event.modelChoice !== void 0) return event.modelChoice;
|
|
@@ -40635,14 +40674,14 @@ var require_util2 = __commonJS({
|
|
|
40635
40674
|
}
|
|
40636
40675
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
40637
40676
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
40638
|
-
let
|
|
40677
|
+
let path72 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
40639
40678
|
if (origin[origin.length - 1] === "/") {
|
|
40640
40679
|
origin = origin.slice(0, origin.length - 1);
|
|
40641
40680
|
}
|
|
40642
|
-
if (
|
|
40643
|
-
|
|
40681
|
+
if (path72 && path72[0] !== "/") {
|
|
40682
|
+
path72 = `/${path72}`;
|
|
40644
40683
|
}
|
|
40645
|
-
return new URL(`${origin}${
|
|
40684
|
+
return new URL(`${origin}${path72}`);
|
|
40646
40685
|
}
|
|
40647
40686
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
40648
40687
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -41463,9 +41502,9 @@ var require_diagnostics = __commonJS({
|
|
|
41463
41502
|
"undici:client:sendHeaders",
|
|
41464
41503
|
(evt) => {
|
|
41465
41504
|
const {
|
|
41466
|
-
request: { method, path:
|
|
41505
|
+
request: { method, path: path72, origin }
|
|
41467
41506
|
} = evt;
|
|
41468
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
41507
|
+
debugLog("sending request to %s %s%s", method, origin, path72);
|
|
41469
41508
|
}
|
|
41470
41509
|
);
|
|
41471
41510
|
}
|
|
@@ -41483,14 +41522,14 @@ var require_diagnostics = __commonJS({
|
|
|
41483
41522
|
"undici:request:headers",
|
|
41484
41523
|
(evt) => {
|
|
41485
41524
|
const {
|
|
41486
|
-
request: { method, path:
|
|
41525
|
+
request: { method, path: path72, origin },
|
|
41487
41526
|
response: { statusCode }
|
|
41488
41527
|
} = evt;
|
|
41489
41528
|
debugLog(
|
|
41490
41529
|
"received response to %s %s%s - HTTP %d",
|
|
41491
41530
|
method,
|
|
41492
41531
|
origin,
|
|
41493
|
-
|
|
41532
|
+
path72,
|
|
41494
41533
|
statusCode
|
|
41495
41534
|
);
|
|
41496
41535
|
}
|
|
@@ -41499,23 +41538,23 @@ var require_diagnostics = __commonJS({
|
|
|
41499
41538
|
"undici:request:trailers",
|
|
41500
41539
|
(evt) => {
|
|
41501
41540
|
const {
|
|
41502
|
-
request: { method, path:
|
|
41541
|
+
request: { method, path: path72, origin }
|
|
41503
41542
|
} = evt;
|
|
41504
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
41543
|
+
debugLog("trailers received from %s %s%s", method, origin, path72);
|
|
41505
41544
|
}
|
|
41506
41545
|
);
|
|
41507
41546
|
diagnosticsChannel.subscribe(
|
|
41508
41547
|
"undici:request:error",
|
|
41509
41548
|
(evt) => {
|
|
41510
41549
|
const {
|
|
41511
|
-
request: { method, path:
|
|
41550
|
+
request: { method, path: path72, origin },
|
|
41512
41551
|
error: error63
|
|
41513
41552
|
} = evt;
|
|
41514
41553
|
debugLog(
|
|
41515
41554
|
"request to %s %s%s errored - %s",
|
|
41516
41555
|
method,
|
|
41517
41556
|
origin,
|
|
41518
|
-
|
|
41557
|
+
path72,
|
|
41519
41558
|
error63.message
|
|
41520
41559
|
);
|
|
41521
41560
|
}
|
|
@@ -41630,7 +41669,7 @@ var require_request = __commonJS({
|
|
|
41630
41669
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
41631
41670
|
var Request2 = class {
|
|
41632
41671
|
constructor(origin, {
|
|
41633
|
-
path:
|
|
41672
|
+
path: path72,
|
|
41634
41673
|
method,
|
|
41635
41674
|
body,
|
|
41636
41675
|
headers,
|
|
@@ -41647,11 +41686,11 @@ var require_request = __commonJS({
|
|
|
41647
41686
|
maxRedirections,
|
|
41648
41687
|
typeOfService
|
|
41649
41688
|
}, handler) {
|
|
41650
|
-
if (typeof
|
|
41689
|
+
if (typeof path72 !== "string") {
|
|
41651
41690
|
throw new InvalidArgumentError2("path must be a string");
|
|
41652
|
-
} else if (
|
|
41691
|
+
} else if (path72[0] !== "/" && !(path72.startsWith("http://") || path72.startsWith("https://")) && method !== "CONNECT") {
|
|
41653
41692
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
41654
|
-
} else if (invalidPathRegex.test(
|
|
41693
|
+
} else if (invalidPathRegex.test(path72)) {
|
|
41655
41694
|
throw new InvalidArgumentError2("invalid request path");
|
|
41656
41695
|
}
|
|
41657
41696
|
if (typeof method !== "string") {
|
|
@@ -41726,7 +41765,7 @@ var require_request = __commonJS({
|
|
|
41726
41765
|
this.completed = false;
|
|
41727
41766
|
this.aborted = false;
|
|
41728
41767
|
this.upgrade = upgrade || null;
|
|
41729
|
-
this.path = query ? serializePathWithQuery(
|
|
41768
|
+
this.path = query ? serializePathWithQuery(path72, query) : path72;
|
|
41730
41769
|
this.origin = origin;
|
|
41731
41770
|
this.protocol = getProtocolFromUrlString(origin);
|
|
41732
41771
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -46908,7 +46947,7 @@ var require_client_h1 = __commonJS({
|
|
|
46908
46947
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
46909
46948
|
}
|
|
46910
46949
|
function writeH1(client, request7) {
|
|
46911
|
-
const { method, path:
|
|
46950
|
+
const { method, path: path72, host, upgrade, blocking, reset } = request7;
|
|
46912
46951
|
let { body, headers, contentLength } = request7;
|
|
46913
46952
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
46914
46953
|
if (util2.isFormDataLike(body)) {
|
|
@@ -46986,7 +47025,7 @@ var require_client_h1 = __commonJS({
|
|
|
46986
47025
|
if (socket.setTypeOfService) {
|
|
46987
47026
|
socket.setTypeOfService(request7.typeOfService);
|
|
46988
47027
|
}
|
|
46989
|
-
let header = `${method} ${
|
|
47028
|
+
let header = `${method} ${path72} HTTP/1.1\r
|
|
46990
47029
|
`;
|
|
46991
47030
|
if (typeof host === "string") {
|
|
46992
47031
|
header += `host: ${host}\r
|
|
@@ -47665,7 +47704,7 @@ var require_client_h2 = __commonJS({
|
|
|
47665
47704
|
const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
|
|
47666
47705
|
const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
|
|
47667
47706
|
const session = client[kHTTP2Session];
|
|
47668
|
-
const { method, path:
|
|
47707
|
+
const { method, path: path72, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
|
|
47669
47708
|
let { body } = request7;
|
|
47670
47709
|
if (upgrade != null && upgrade !== "websocket") {
|
|
47671
47710
|
util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -47734,7 +47773,7 @@ var require_client_h2 = __commonJS({
|
|
|
47734
47773
|
}
|
|
47735
47774
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
47736
47775
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
47737
|
-
headers[HTTP2_HEADER_PATH] =
|
|
47776
|
+
headers[HTTP2_HEADER_PATH] = path72;
|
|
47738
47777
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
47739
47778
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
47740
47779
|
} else {
|
|
@@ -47776,7 +47815,7 @@ var require_client_h2 = __commonJS({
|
|
|
47776
47815
|
stream.setTimeout(headersTimeout);
|
|
47777
47816
|
return true;
|
|
47778
47817
|
}
|
|
47779
|
-
headers[HTTP2_HEADER_PATH] =
|
|
47818
|
+
headers[HTTP2_HEADER_PATH] = path72;
|
|
47780
47819
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
47781
47820
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
47782
47821
|
if (body && typeof body.read === "function") {
|
|
@@ -50128,10 +50167,10 @@ var require_proxy_agent = __commonJS({
|
|
|
50128
50167
|
};
|
|
50129
50168
|
const {
|
|
50130
50169
|
origin,
|
|
50131
|
-
path:
|
|
50170
|
+
path: path72 = "/",
|
|
50132
50171
|
headers = {}
|
|
50133
50172
|
} = opts;
|
|
50134
|
-
opts.path = origin +
|
|
50173
|
+
opts.path = origin + path72;
|
|
50135
50174
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
50136
50175
|
const { host } = new URL(origin);
|
|
50137
50176
|
headers.host = host;
|
|
@@ -52240,20 +52279,20 @@ var require_mock_utils = __commonJS({
|
|
|
52240
52279
|
}
|
|
52241
52280
|
return normalizedQp;
|
|
52242
52281
|
}
|
|
52243
|
-
function safeUrl(
|
|
52244
|
-
if (typeof
|
|
52245
|
-
return
|
|
52282
|
+
function safeUrl(path72) {
|
|
52283
|
+
if (typeof path72 !== "string") {
|
|
52284
|
+
return path72;
|
|
52246
52285
|
}
|
|
52247
|
-
const pathSegments =
|
|
52286
|
+
const pathSegments = path72.split("?", 3);
|
|
52248
52287
|
if (pathSegments.length !== 2) {
|
|
52249
|
-
return
|
|
52288
|
+
return path72;
|
|
52250
52289
|
}
|
|
52251
52290
|
const qp2 = new URLSearchParams(pathSegments.pop());
|
|
52252
52291
|
qp2.sort();
|
|
52253
52292
|
return [...pathSegments, qp2.toString()].join("?");
|
|
52254
52293
|
}
|
|
52255
|
-
function matchKey(mockDispatch2, { path:
|
|
52256
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
52294
|
+
function matchKey(mockDispatch2, { path: path72, method, body, headers }) {
|
|
52295
|
+
const pathMatch = matchValue(mockDispatch2.path, path72);
|
|
52257
52296
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
52258
52297
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
52259
52298
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -52278,8 +52317,8 @@ var require_mock_utils = __commonJS({
|
|
|
52278
52317
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
52279
52318
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
52280
52319
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
52281
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
52282
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
52320
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path72, ignoreTrailingSlash }) => {
|
|
52321
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path72)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path72), resolvedPath);
|
|
52283
52322
|
});
|
|
52284
52323
|
if (matchedMockDispatches.length === 0) {
|
|
52285
52324
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -52318,19 +52357,19 @@ var require_mock_utils = __commonJS({
|
|
|
52318
52357
|
mockDispatches.splice(index, 1);
|
|
52319
52358
|
}
|
|
52320
52359
|
}
|
|
52321
|
-
function removeTrailingSlash(
|
|
52322
|
-
while (
|
|
52323
|
-
|
|
52360
|
+
function removeTrailingSlash(path72) {
|
|
52361
|
+
while (path72.endsWith("/")) {
|
|
52362
|
+
path72 = path72.slice(0, -1);
|
|
52324
52363
|
}
|
|
52325
|
-
if (
|
|
52326
|
-
|
|
52364
|
+
if (path72.length === 0) {
|
|
52365
|
+
path72 = "/";
|
|
52327
52366
|
}
|
|
52328
|
-
return
|
|
52367
|
+
return path72;
|
|
52329
52368
|
}
|
|
52330
52369
|
function buildKey(opts) {
|
|
52331
|
-
const { path:
|
|
52370
|
+
const { path: path72, method, body, headers, query } = opts;
|
|
52332
52371
|
return {
|
|
52333
|
-
path:
|
|
52372
|
+
path: path72,
|
|
52334
52373
|
method,
|
|
52335
52374
|
body,
|
|
52336
52375
|
headers,
|
|
@@ -53020,10 +53059,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
53020
53059
|
}
|
|
53021
53060
|
format(pendingInterceptors) {
|
|
53022
53061
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
53023
|
-
({ method, path:
|
|
53062
|
+
({ method, path: path72, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
53024
53063
|
Method: method,
|
|
53025
53064
|
Origin: origin,
|
|
53026
|
-
Path:
|
|
53065
|
+
Path: path72,
|
|
53027
53066
|
"Status code": statusCode,
|
|
53028
53067
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
53029
53068
|
Invocations: timesInvoked,
|
|
@@ -53105,9 +53144,9 @@ var require_mock_agent = __commonJS({
|
|
|
53105
53144
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
53106
53145
|
const dispatchOpts = { ...opts };
|
|
53107
53146
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
53108
|
-
const [
|
|
53147
|
+
const [path72, searchParams] = dispatchOpts.path.split("?");
|
|
53109
53148
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
53110
|
-
dispatchOpts.path = `${
|
|
53149
|
+
dispatchOpts.path = `${path72}?${normalizedSearchParams}`;
|
|
53111
53150
|
}
|
|
53112
53151
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
53113
53152
|
}
|
|
@@ -53508,12 +53547,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53508
53547
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
53509
53548
|
*/
|
|
53510
53549
|
async loadSnapshots(filePath) {
|
|
53511
|
-
const
|
|
53512
|
-
if (!
|
|
53550
|
+
const path72 = filePath || this.#snapshotPath;
|
|
53551
|
+
if (!path72) {
|
|
53513
53552
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
53514
53553
|
}
|
|
53515
53554
|
try {
|
|
53516
|
-
const data = await readFile(resolve2(
|
|
53555
|
+
const data = await readFile(resolve2(path72), "utf8");
|
|
53517
53556
|
const parsed = JSON.parse(data);
|
|
53518
53557
|
if (Array.isArray(parsed)) {
|
|
53519
53558
|
this.#snapshots.clear();
|
|
@@ -53527,7 +53566,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53527
53566
|
if (error63.code === "ENOENT") {
|
|
53528
53567
|
this.#snapshots.clear();
|
|
53529
53568
|
} else {
|
|
53530
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
53569
|
+
throw new UndiciError(`Failed to load snapshots from ${path72}`, { cause: error63 });
|
|
53531
53570
|
}
|
|
53532
53571
|
}
|
|
53533
53572
|
}
|
|
@@ -53538,11 +53577,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53538
53577
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
53539
53578
|
*/
|
|
53540
53579
|
async saveSnapshots(filePath) {
|
|
53541
|
-
const
|
|
53542
|
-
if (!
|
|
53580
|
+
const path72 = filePath || this.#snapshotPath;
|
|
53581
|
+
if (!path72) {
|
|
53543
53582
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
53544
53583
|
}
|
|
53545
|
-
const resolvedPath = resolve2(
|
|
53584
|
+
const resolvedPath = resolve2(path72);
|
|
53546
53585
|
await mkdir(dirname3(resolvedPath), { recursive: true });
|
|
53547
53586
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
53548
53587
|
hash: hash2,
|
|
@@ -54174,15 +54213,15 @@ var require_redirect_handler = __commonJS({
|
|
|
54174
54213
|
return;
|
|
54175
54214
|
}
|
|
54176
54215
|
const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
54177
|
-
const
|
|
54178
|
-
const redirectUrlString = `${origin}${
|
|
54216
|
+
const path72 = search ? `${pathname}${search}` : pathname;
|
|
54217
|
+
const redirectUrlString = `${origin}${path72}`;
|
|
54179
54218
|
for (const historyUrl of this.history) {
|
|
54180
54219
|
if (historyUrl.toString() === redirectUrlString) {
|
|
54181
54220
|
throw new InvalidArgumentError2(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
|
|
54182
54221
|
}
|
|
54183
54222
|
}
|
|
54184
54223
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
54185
|
-
this.opts.path =
|
|
54224
|
+
this.opts.path = path72;
|
|
54186
54225
|
this.opts.origin = origin;
|
|
54187
54226
|
this.opts.query = null;
|
|
54188
54227
|
}
|
|
@@ -55942,10 +55981,10 @@ var require_cache_handler = __commonJS({
|
|
|
55942
55981
|
}
|
|
55943
55982
|
return locationUrl.pathname + locationUrl.search;
|
|
55944
55983
|
}
|
|
55945
|
-
function deleteCachedUri(store, cacheKey,
|
|
55984
|
+
function deleteCachedUri(store, cacheKey, path72) {
|
|
55946
55985
|
deleteCachedValue(store, {
|
|
55947
55986
|
...cacheKey,
|
|
55948
|
-
path:
|
|
55987
|
+
path: path72
|
|
55949
55988
|
});
|
|
55950
55989
|
for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
|
|
55951
55990
|
const method = util2.safeHTTPMethods[i10];
|
|
@@ -55953,7 +55992,7 @@ var require_cache_handler = __commonJS({
|
|
|
55953
55992
|
deleteCachedValue(store, {
|
|
55954
55993
|
...cacheKey,
|
|
55955
55994
|
method,
|
|
55956
|
-
path:
|
|
55995
|
+
path: path72
|
|
55957
55996
|
});
|
|
55958
55997
|
}
|
|
55959
55998
|
}
|
|
@@ -55964,9 +56003,9 @@ var require_cache_handler = __commonJS({
|
|
|
55964
56003
|
}
|
|
55965
56004
|
const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
|
|
55966
56005
|
for (let i10 = 0; i10 < values.length; i10++) {
|
|
55967
|
-
const
|
|
55968
|
-
if (
|
|
55969
|
-
deleteCachedUri(store, cacheKey,
|
|
56006
|
+
const path72 = getSameOriginPath(cacheKey, values[i10]);
|
|
56007
|
+
if (path72 !== void 0) {
|
|
56008
|
+
deleteCachedUri(store, cacheKey, path72);
|
|
55970
56009
|
}
|
|
55971
56010
|
}
|
|
55972
56011
|
}
|
|
@@ -60966,11 +61005,11 @@ var require_fetch = __commonJS({
|
|
|
60966
61005
|
function dispatch({ body }) {
|
|
60967
61006
|
const url2 = requestCurrentURL(request7);
|
|
60968
61007
|
const agent = fetchParams.controller.dispatcher;
|
|
60969
|
-
const
|
|
61008
|
+
const path72 = url2.pathname + url2.search;
|
|
60970
61009
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
60971
61010
|
return new Promise((resolve2, reject) => agent.dispatch(
|
|
60972
61011
|
{
|
|
60973
|
-
path: hasTrailingQuestionMark ? `${
|
|
61012
|
+
path: hasTrailingQuestionMark ? `${path72}?` : path72,
|
|
60974
61013
|
origin: url2.origin,
|
|
60975
61014
|
method: request7.method,
|
|
60976
61015
|
body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
|
|
@@ -61917,9 +61956,9 @@ var require_util5 = __commonJS({
|
|
|
61917
61956
|
}
|
|
61918
61957
|
}
|
|
61919
61958
|
}
|
|
61920
|
-
function validateCookiePath(
|
|
61921
|
-
for (let i10 = 0; i10 <
|
|
61922
|
-
const code =
|
|
61959
|
+
function validateCookiePath(path72) {
|
|
61960
|
+
for (let i10 = 0; i10 < path72.length; ++i10) {
|
|
61961
|
+
const code = path72.charCodeAt(i10);
|
|
61923
61962
|
if (code < 32 || // exclude CTLs (0-31)
|
|
61924
61963
|
code > 126 || // exclude DEL and non-ascii
|
|
61925
61964
|
code === 59) {
|
|
@@ -65267,11 +65306,11 @@ var require_undici = __commonJS({
|
|
|
65267
65306
|
if (typeof opts.path !== "string") {
|
|
65268
65307
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
65269
65308
|
}
|
|
65270
|
-
let
|
|
65309
|
+
let path72 = opts.path;
|
|
65271
65310
|
if (!opts.path.startsWith("/")) {
|
|
65272
|
-
|
|
65311
|
+
path72 = `/${path72}`;
|
|
65273
65312
|
}
|
|
65274
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
65313
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path72);
|
|
65275
65314
|
} else {
|
|
65276
65315
|
if (!opts) {
|
|
65277
65316
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -106646,8 +106685,8 @@ var require_utils3 = __commonJS({
|
|
|
106646
106685
|
}
|
|
106647
106686
|
return ind;
|
|
106648
106687
|
}
|
|
106649
|
-
function removeDotSegments(
|
|
106650
|
-
let input2 =
|
|
106688
|
+
function removeDotSegments(path72) {
|
|
106689
|
+
let input2 = path72;
|
|
106651
106690
|
const output2 = [];
|
|
106652
106691
|
let nextSlash = -1;
|
|
106653
106692
|
let len = 0;
|
|
@@ -107056,8 +107095,8 @@ var require_schemes = __commonJS({
|
|
|
107056
107095
|
}
|
|
107057
107096
|
if (wsComponent.resourceName) {
|
|
107058
107097
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
107059
|
-
const
|
|
107060
|
-
wsComponent.path =
|
|
107098
|
+
const path72 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
107099
|
+
wsComponent.path = path72 && path72 !== "/" ? path72 : void 0;
|
|
107061
107100
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
107062
107101
|
wsComponent.resourceName = void 0;
|
|
107063
107102
|
}
|
|
@@ -110584,7 +110623,7 @@ var require_dist2 = __commonJS({
|
|
|
110584
110623
|
});
|
|
110585
110624
|
|
|
110586
110625
|
// src/cli.ts
|
|
110587
|
-
var
|
|
110626
|
+
var import_node_path71 = __toESM(require("node:path"), 1);
|
|
110588
110627
|
|
|
110589
110628
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
110590
110629
|
var CommanderError = class extends Error {
|
|
@@ -113697,9 +113736,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
113697
113736
|
* @param {string} [path]
|
|
113698
113737
|
* @return {(string|null|Command)}
|
|
113699
113738
|
*/
|
|
113700
|
-
executableDir(
|
|
113701
|
-
if (
|
|
113702
|
-
this._executableDir =
|
|
113739
|
+
executableDir(path72) {
|
|
113740
|
+
if (path72 === void 0) return this._executableDir;
|
|
113741
|
+
this._executableDir = path72;
|
|
113703
113742
|
return this;
|
|
113704
113743
|
}
|
|
113705
113744
|
/**
|
|
@@ -115175,19 +115214,19 @@ function writePools(paths, pools) {
|
|
|
115175
115214
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
115176
115215
|
}
|
|
115177
115216
|
function poolCycleOf(pools, name) {
|
|
115178
|
-
const walk3 = (current,
|
|
115217
|
+
const walk3 = (current, path72) => {
|
|
115179
115218
|
for (const entry of pools[current]?.identities ?? []) {
|
|
115180
115219
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
115181
115220
|
if (nested === void 0) {
|
|
115182
115221
|
continue;
|
|
115183
115222
|
}
|
|
115184
115223
|
if (nested === name) {
|
|
115185
|
-
return [...
|
|
115224
|
+
return [...path72, nested];
|
|
115186
115225
|
}
|
|
115187
|
-
if (
|
|
115226
|
+
if (path72.includes(nested)) {
|
|
115188
115227
|
continue;
|
|
115189
115228
|
}
|
|
115190
|
-
const found = walk3(nested, [...
|
|
115229
|
+
const found = walk3(nested, [...path72, nested]);
|
|
115191
115230
|
if (found !== void 0) {
|
|
115192
115231
|
return found;
|
|
115193
115232
|
}
|
|
@@ -116388,7 +116427,7 @@ function statuslineChangeOf(options) {
|
|
|
116388
116427
|
return void 0;
|
|
116389
116428
|
}
|
|
116390
116429
|
const assignments = (options.statusline ?? []).map(parseStatuslineAssignment);
|
|
116391
|
-
return { set: Object.fromEntries(assignments.map(({ path:
|
|
116430
|
+
return { set: Object.fromEntries(assignments.map(({ path: path72, value: value2 }) => [path72, value2])), unset: options.unsetStatusline ?? [] };
|
|
116392
116431
|
}
|
|
116393
116432
|
function registerProfileCommand(program2, deps) {
|
|
116394
116433
|
const { paths } = deps;
|
|
@@ -116425,7 +116464,7 @@ function registerProfileCommand(program2, deps) {
|
|
|
116425
116464
|
withExamples(
|
|
116426
116465
|
profile.command("set <name>").description(
|
|
116427
116466
|
"Update a configuration profile's categories, entries, extends list, description or launch settings. With no options on a terminal, walks through its categories."
|
|
116428
|
-
).option("--category <category=bool>", "Share (true) or hide (false) a whole category (repeatable).", collectBoolPair).option("--entry <path=bool>", "Share (true) or hide (false) one <category>/<path> entry (repeatable).", collectBoolPair).option("--extends <profile>", "Replace the extends list with these profiles (repeatable, in order).", collectRepeated).option("--no-extends", "Clear the extends list.").option("--description <text>", "Replace the description.").option("--no-description", "Clear the description.").option("--launch-skip-permissions", "Launches under this profile skip permission prompts.").option("--no-launch-skip-permissions", "Launches under this profile keep permission prompts.").option("--launch-remote-control", "Launches under this profile enable Remote Control.").option("--no-launch-remote-control", "Launches under this profile leave Remote Control off.").option("--launch-headroom", "Launches under this profile route through headroom.").option("--no-launch-headroom", "Launches under this profile route direct.").option("--launch-track-usage", "Launches under this profile route through the front door so their requests and quota are recorded, with no headroom needed.").option("--no-launch-track-usage", "Launches under this profile are not recorded unless a provider or headroom routes them anyway.").option("--launch-provider <provider>", "Launches under this profile route through this provider.").option("--no-launch-provider", "Clear this profile's provider selection.").option("--launch-claude-version <version>", "Launches under this profile run exactly this installed Claude Code version (such as 2.1.220); a version that is not installed fails the launch.").option("--no-launch-claude-version", "Clear this profile's Claude Code version pin.").option("--launch-delay <duration>", "Launches under this profile wait this long (such as 5s) after the launcher's own output before starting claude, so the output can be read.", parseDurationLiteral).option("--no-launch-delay", "Clear this profile's launch delay.").option("--launch-pause", "Launches under this profile wait for a key press after the launcher's own output before starting claude.").option("--no-launch-pause", "Launches under this profile start claude without waiting for a key press.").option("--launch-explain", "Launches under this profile that pick from a pool list every member the pick ranked and why, in the launcher's report.").option("--no-launch-explain", "Launches under this profile name only the member a pool pick chose.").option("--launch-proxy-bypass <host>", "Launches under this profile keep this host off the front door by adding it to NO_PROXY, so its traffic goes direct (repeatable; replaces the profile's list).", collectRepeated).option("--no-launch-proxy-bypass", "Clear this profile's list of hosts kept off the front door.").option("--statusline <setting=value>", "Set one statusline setting for launches under this profile (repeatable; `agent-shim statusline keys` lists them; a list is comma-separated, a list of groups such as layout.merge is groups separated by semicolons with commas inside each group, and an empty value is the empty list).", collectRepeated).option("--unset-statusline <setting>", "Remove one statusline setting from this profile so the shallower layers or the default apply again (repeatable).", collectRepeated).option("--json", "Print the result as JSON.").action(async (name, allOptions) => {
|
|
116467
|
+
).option("--category <category=bool>", "Share (true) or hide (false) a whole category (repeatable).", collectBoolPair).option("--entry <path=bool>", "Share (true) or hide (false) one <category>/<path> entry (repeatable).", collectBoolPair).option("--extends <profile>", "Replace the extends list with these profiles (repeatable, in order).", collectRepeated).option("--no-extends", "Clear the extends list.").option("--description <text>", "Replace the description.").option("--no-description", "Clear the description.").option("--launch-skip-permissions", "Launches under this profile skip permission prompts.").option("--no-launch-skip-permissions", "Launches under this profile keep permission prompts.").option("--launch-remote-control", "Launches under this profile enable Remote Control.").option("--no-launch-remote-control", "Launches under this profile leave Remote Control off.").option("--launch-headroom", "Launches under this profile route through headroom.").option("--no-launch-headroom", "Launches under this profile route direct.").option("--launch-track-usage", "Launches under this profile route through the front door so their requests and quota are recorded, with no headroom needed.").option("--no-launch-track-usage", "Launches under this profile are not recorded unless a provider or headroom routes them anyway.").option("--launch-provider <provider>", "Launches under this profile route through this provider.").option("--no-launch-provider", "Clear this profile's provider selection.").option("--launch-claude-version <version>", "Launches under this profile run exactly this installed Claude Code version (such as 2.1.220); a version that is not installed fails the launch.").option("--no-launch-claude-version", "Clear this profile's Claude Code version pin.").option("--launch-delay <duration>", "Launches under this profile wait this long (such as 5s) after the launcher's own output before starting claude, so the output can be read.", parseDurationLiteral).option("--no-launch-delay", "Clear this profile's launch delay.").option("--launch-pause", "Launches under this profile wait for a key press after the launcher's own output before starting claude.").option("--no-launch-pause", "Launches under this profile start claude without waiting for a key press.").option("--launch-explain", "Launches under this profile that pick from a pool list every member the pick ranked and why, in the launcher's report.").option("--no-launch-explain", "Launches under this profile name only the member a pool pick chose.").option("--launch-proxy-bypass <host>", "Launches under this profile keep this host off the front door by adding it to NO_PROXY, so its traffic goes direct (repeatable; replaces the profile's list).", collectRepeated).option("--no-launch-proxy-bypass", "Clear this profile's list of hosts kept off the front door.").option("--statusline <setting=value>", "Set one statusline setting for launches under this profile (repeatable; `agent-shim statusline keys` lists them; a list is comma-separated, a list of groups such as layout.merge is groups separated by semicolons with commas inside each group, a list of free text such as extra.command is a JSON array of strings, and an empty value is the empty list).", collectRepeated).option("--unset-statusline <setting>", "Remove one statusline setting from this profile so the shallower layers or the default apply again (repeatable).", collectRepeated).option("--json", "Print the result as JSON.").action(async (name, allOptions) => {
|
|
116429
116468
|
const { json: json2, ...options } = allOptions;
|
|
116430
116469
|
requireProfileExists(paths, name);
|
|
116431
116470
|
if (Object.entries(allOptions).every(([key, value2]) => key === "json" || value2 === void 0)) {
|
|
@@ -118179,7 +118218,7 @@ function registerCodexCommand(program2, deps) {
|
|
|
118179
118218
|
|
|
118180
118219
|
// src/frontdoor/commands.ts
|
|
118181
118220
|
var import_node_crypto25 = require("node:crypto");
|
|
118182
|
-
var
|
|
118221
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
118183
118222
|
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
118184
118223
|
init_commandDeps();
|
|
118185
118224
|
init_configProfilesStore();
|
|
@@ -119712,7 +119751,6 @@ function createHeadroomDecision(setting) {
|
|
|
119712
119751
|
}
|
|
119713
119752
|
|
|
119714
119753
|
// src/frontdoor/commands.ts
|
|
119715
|
-
init_capability();
|
|
119716
119754
|
init_capture();
|
|
119717
119755
|
init_connect();
|
|
119718
119756
|
|
|
@@ -120055,11 +120093,11 @@ function createRcSessionTracker(deps) {
|
|
|
120055
120093
|
};
|
|
120056
120094
|
const observeExchange = (request7) => {
|
|
120057
120095
|
const method = (request7.method ?? "").toUpperCase();
|
|
120058
|
-
const
|
|
120059
|
-
if (!
|
|
120096
|
+
const path72 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
|
|
120097
|
+
if (!path72.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
120060
120098
|
return void 0;
|
|
120061
120099
|
}
|
|
120062
|
-
const tail =
|
|
120100
|
+
const tail = path72.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
120063
120101
|
const facts = {
|
|
120064
120102
|
oauthAuthorization: oauthAuthorizationOf(request7.headers),
|
|
120065
120103
|
anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
|
|
@@ -120176,7 +120214,7 @@ function createRcSessionTracker(deps) {
|
|
|
120176
120214
|
}
|
|
120177
120215
|
};
|
|
120178
120216
|
};
|
|
120179
|
-
const
|
|
120217
|
+
const summaryOf2 = ({ id: id2, createdAt, lastSeenAt }) => ({ id: id2, createdAt, lastSeenAt });
|
|
120180
120218
|
const pendingSummaryOf = ({ sessionId, requestId, type: type2, summary, observedAt: observedAt2 }) => ({ sessionId, requestId, type: type2, summary, observedAt: observedAt2 });
|
|
120181
120219
|
const sortedEntries = () => [...entries.values()].sort((left, right) => left.createdAt - right.createdAt || (left.id < right.id ? -1 : 1));
|
|
120182
120220
|
const pendingSorted = (entry) => [...entry.pending.values()].sort((left, right) => left.observedAt - right.observedAt || (left.requestId < right.requestId ? -1 : 1)).map(pendingSummaryOf);
|
|
@@ -120184,11 +120222,11 @@ function createRcSessionTracker(deps) {
|
|
|
120184
120222
|
observeExchange,
|
|
120185
120223
|
list: () => {
|
|
120186
120224
|
sweep();
|
|
120187
|
-
return sortedEntries().map(
|
|
120225
|
+
return sortedEntries().map(summaryOf2);
|
|
120188
120226
|
},
|
|
120189
120227
|
statusOf: (sessionId) => {
|
|
120190
120228
|
sweep();
|
|
120191
|
-
return sortedEntries().filter((entry) => sessionId === void 0 || entry.id === sessionId).map((entry) => ({ ...
|
|
120229
|
+
return sortedEntries().filter((entry) => sessionId === void 0 || entry.id === sessionId).map((entry) => ({ ...summaryOf2(entry), workerState: entry.workerState, workerIdleSeconds: entry.workerIdleSeconds, pending: pendingSorted(entry) }));
|
|
120192
120230
|
},
|
|
120193
120231
|
pendingOf: (sessionId) => {
|
|
120194
120232
|
sweep();
|
|
@@ -120428,8 +120466,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
120428
120466
|
function isRcReadFileEncoding(value2) {
|
|
120429
120467
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value2);
|
|
120430
120468
|
}
|
|
120431
|
-
function buildRcReadFilePayload(requestId,
|
|
120432
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
120469
|
+
function buildRcReadFilePayload(requestId, path72, options) {
|
|
120470
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path72, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
120433
120471
|
}
|
|
120434
120472
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
120435
120473
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -120531,15 +120569,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
120531
120569
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
120532
120570
|
return result.ok ? { ...result, requestId } : result;
|
|
120533
120571
|
}
|
|
120534
|
-
async function readRcSessionFile(deps, sessionId,
|
|
120535
|
-
if (
|
|
120572
|
+
async function readRcSessionFile(deps, sessionId, path72, options) {
|
|
120573
|
+
if (path72 === "") {
|
|
120536
120574
|
return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
|
|
120537
120575
|
}
|
|
120538
120576
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
120539
120577
|
return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
|
|
120540
120578
|
}
|
|
120541
120579
|
const requestId = deps.newUuid();
|
|
120542
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
120580
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path72, options), `read ${path72} from session ${sessionId}`);
|
|
120543
120581
|
return result.ok ? { ...result, requestId } : result;
|
|
120544
120582
|
}
|
|
120545
120583
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -120711,11 +120749,11 @@ function createRcControlHandler(deps) {
|
|
|
120711
120749
|
path: "read-file",
|
|
120712
120750
|
read: (body) => {
|
|
120713
120751
|
const session = bodyString(body, "session");
|
|
120714
|
-
const
|
|
120752
|
+
const path72 = bodyString(body, "path");
|
|
120715
120753
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
120716
120754
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
120717
|
-
const refused2 = session === void 0 ||
|
|
120718
|
-
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session,
|
|
120755
|
+
const refused2 = session === void 0 || path72 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
120756
|
+
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path72, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
120719
120757
|
}
|
|
120720
120758
|
},
|
|
120721
120759
|
{
|
|
@@ -121025,9 +121063,9 @@ function requestIdOfBody(body) {
|
|
|
121025
121063
|
}
|
|
121026
121064
|
function frontDoorRcControl(transport, token) {
|
|
121027
121065
|
const headers = { authorization: `Bearer ${token}` };
|
|
121028
|
-
const listAnswerOf = async (
|
|
121066
|
+
const listAnswerOf = async (path72, what) => {
|
|
121029
121067
|
try {
|
|
121030
|
-
return await transport.request({ method: "GET", path:
|
|
121068
|
+
return await transport.request({ method: "GET", path: path72, headers });
|
|
121031
121069
|
} catch (error63) {
|
|
121032
121070
|
throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
|
|
121033
121071
|
}
|
|
@@ -121099,10 +121137,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
121099
121137
|
}
|
|
121100
121138
|
return pending;
|
|
121101
121139
|
};
|
|
121102
|
-
const writeOf = async (
|
|
121140
|
+
const writeOf = async (path72, body, describeFailure2) => {
|
|
121103
121141
|
let answer;
|
|
121104
121142
|
try {
|
|
121105
|
-
answer = await transport.request({ method: "POST", path:
|
|
121143
|
+
answer = await transport.request({ method: "POST", path: path72, headers: { ...headers, "content-type": "application/json" }, body });
|
|
121106
121144
|
} catch (error63) {
|
|
121107
121145
|
return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
|
|
121108
121146
|
}
|
|
@@ -121133,10 +121171,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
121133
121171
|
endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
121134
121172
|
getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
121135
121173
|
getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
121136
|
-
readFile: async (sessionId,
|
|
121174
|
+
readFile: async (sessionId, path72, options) => await writeOf(
|
|
121137
121175
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
121138
|
-
JSON.stringify({ session: sessionId, path:
|
|
121139
|
-
(status, message) => `reading ${
|
|
121176
|
+
JSON.stringify({ session: sessionId, path: path72, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
121177
|
+
(status, message) => `reading ${path72} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
121140
121178
|
),
|
|
121141
121179
|
fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
121142
121180
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -121523,12 +121561,12 @@ function tlsFacts(options) {
|
|
|
121523
121561
|
}
|
|
121524
121562
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
121525
121563
|
const agent = new ExemptTlsAgent();
|
|
121526
|
-
const post = async (
|
|
121564
|
+
const post = async (path72, headers, body) => await new Promise((resolve2, reject) => {
|
|
121527
121565
|
const options = {
|
|
121528
121566
|
host: target.host,
|
|
121529
121567
|
port: target.port,
|
|
121530
121568
|
method: "POST",
|
|
121531
|
-
path:
|
|
121569
|
+
path: path72,
|
|
121532
121570
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
121533
121571
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
121534
121572
|
agent
|
|
@@ -121593,12 +121631,12 @@ function lateRcStreamDial(resolve2) {
|
|
|
121593
121631
|
}
|
|
121594
121632
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
121595
121633
|
const agent = new ExemptTlsAgent();
|
|
121596
|
-
const request7 = async (method,
|
|
121634
|
+
const request7 = async (method, path72, headers, body, signal) => await new Promise((resolve2, reject) => {
|
|
121597
121635
|
const options = {
|
|
121598
121636
|
host: target.host,
|
|
121599
121637
|
port: target.port,
|
|
121600
121638
|
method,
|
|
121601
|
-
path:
|
|
121639
|
+
path: path72,
|
|
121602
121640
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
121603
121641
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
121604
121642
|
agent,
|
|
@@ -121640,9 +121678,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
121640
121678
|
return { status, body: await readAll(response) };
|
|
121641
121679
|
},
|
|
121642
121680
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
121643
|
-
const
|
|
121681
|
+
const path72 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
121644
121682
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
121645
|
-
const { status, response } = await request7("GET",
|
|
121683
|
+
const { status, response } = await request7("GET", path72, streamHeaders, void 0, signal);
|
|
121646
121684
|
if (!isSuccessful2(status)) {
|
|
121647
121685
|
await readAll(response);
|
|
121648
121686
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -123076,11 +123114,11 @@ function tryOrUndefined(fn2) {
|
|
|
123076
123114
|
return void 0;
|
|
123077
123115
|
}
|
|
123078
123116
|
}
|
|
123079
|
-
function pathToHttpPath(
|
|
123080
|
-
return `/${
|
|
123117
|
+
function pathToHttpPath(path72) {
|
|
123118
|
+
return `/${path72.map(safeEncodeURIComponent).join("/")}`;
|
|
123081
123119
|
}
|
|
123082
|
-
function normalizeHttpPath(
|
|
123083
|
-
const paths =
|
|
123120
|
+
function normalizeHttpPath(path72) {
|
|
123121
|
+
const paths = path72.split("/");
|
|
123084
123122
|
if (paths.at(0) === "") {
|
|
123085
123123
|
paths.shift();
|
|
123086
123124
|
}
|
|
@@ -123265,9 +123303,9 @@ function isPlainObject3(value2) {
|
|
|
123265
123303
|
function getOwn(object3, key) {
|
|
123266
123304
|
return Object.hasOwn(object3, key) ? object3[key] : void 0;
|
|
123267
123305
|
}
|
|
123268
|
-
function get(object3,
|
|
123306
|
+
function get(object3, path72) {
|
|
123269
123307
|
let current = object3;
|
|
123270
|
-
for (const key of
|
|
123308
|
+
for (const key of path72) {
|
|
123271
123309
|
if (!isTypescriptObject(current)) {
|
|
123272
123310
|
return void 0;
|
|
123273
123311
|
}
|
|
@@ -124490,7 +124528,7 @@ function resolveClientRest(rest) {
|
|
|
124490
124528
|
// rest[1] can be undefined if all fields of FriendlyClientOptions are optional
|
|
124491
124529
|
];
|
|
124492
124530
|
}
|
|
124493
|
-
function createORPCClient(link, { path:
|
|
124531
|
+
function createORPCClient(link, { path: path72 = [], ...options } = {}) {
|
|
124494
124532
|
const procedureClient = (...rest) => {
|
|
124495
124533
|
const [input2, callOptions] = resolveClientRest(rest);
|
|
124496
124534
|
const interceptors = [
|
|
@@ -124499,7 +124537,7 @@ function createORPCClient(link, { path: path71 = [], ...options } = {}) {
|
|
|
124499
124537
|
];
|
|
124500
124538
|
return intercept(
|
|
124501
124539
|
interceptors,
|
|
124502
|
-
{ ...callOptions, input: input2, path:
|
|
124540
|
+
{ ...callOptions, input: input2, path: path72 },
|
|
124503
124541
|
({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
|
|
124504
124542
|
);
|
|
124505
124543
|
};
|
|
@@ -124513,7 +124551,7 @@ function createORPCClient(link, { path: path71 = [], ...options } = {}) {
|
|
|
124513
124551
|
if (client === void 0) {
|
|
124514
124552
|
client = createORPCClient(link, {
|
|
124515
124553
|
...options,
|
|
124516
|
-
path: [...
|
|
124554
|
+
path: [...path72, key],
|
|
124517
124555
|
scoped: options.scoped?.[key]
|
|
124518
124556
|
});
|
|
124519
124557
|
cache.set(key, client);
|
|
@@ -124535,24 +124573,24 @@ var BracketNotationSerializer = class {
|
|
|
124535
124573
|
this.internalSerialize(data, "", true, result);
|
|
124536
124574
|
return result;
|
|
124537
124575
|
}
|
|
124538
|
-
internalSerialize(data,
|
|
124576
|
+
internalSerialize(data, path72, isRoot, result) {
|
|
124539
124577
|
if (Array.isArray(data)) {
|
|
124540
124578
|
data.forEach((item, i10) => {
|
|
124541
|
-
this.internalSerialize(item, isRoot ? i10.toString() : `${
|
|
124579
|
+
this.internalSerialize(item, isRoot ? i10.toString() : `${path72}[${i10}]`, false, result);
|
|
124542
124580
|
});
|
|
124543
124581
|
} else if (isPlainObject3(data)) {
|
|
124544
124582
|
for (const key of Object.keys(data)) {
|
|
124545
|
-
this.internalSerialize(data[key], isRoot ? key : `${
|
|
124583
|
+
this.internalSerialize(data[key], isRoot ? key : `${path72}[${key}]`, false, result);
|
|
124546
124584
|
}
|
|
124547
124585
|
} else {
|
|
124548
|
-
result.push([
|
|
124586
|
+
result.push([path72, data]);
|
|
124549
124587
|
}
|
|
124550
124588
|
}
|
|
124551
124589
|
deserialize(serialized) {
|
|
124552
124590
|
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
124553
124591
|
const root = new NullProtoObj();
|
|
124554
|
-
for (const [
|
|
124555
|
-
const segments = this.parsePath(
|
|
124592
|
+
for (const [path72, value2] of serialized) {
|
|
124593
|
+
const segments = this.parsePath(path72);
|
|
124556
124594
|
let currentRef = root;
|
|
124557
124595
|
let nextSegment = segments[0];
|
|
124558
124596
|
for (let i10 = 1; i10 < segments.length; i10++) {
|
|
@@ -124603,13 +124641,13 @@ var BracketNotationSerializer = class {
|
|
|
124603
124641
|
}
|
|
124604
124642
|
return result;
|
|
124605
124643
|
}
|
|
124606
|
-
parsePath(
|
|
124644
|
+
parsePath(path72) {
|
|
124607
124645
|
const segments = [];
|
|
124608
124646
|
let inBrackets = false;
|
|
124609
124647
|
let currentSegment = "";
|
|
124610
|
-
for (let i10 = 0; i10 <
|
|
124611
|
-
const char =
|
|
124612
|
-
const nextChar =
|
|
124648
|
+
for (let i10 = 0; i10 < path72.length; i10++) {
|
|
124649
|
+
const char = path72[i10];
|
|
124650
|
+
const nextChar = path72[i10 + 1];
|
|
124613
124651
|
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
|
|
124614
124652
|
if (nextChar === void 0) {
|
|
124615
124653
|
inBrackets = false;
|
|
@@ -124625,7 +124663,7 @@ var BracketNotationSerializer = class {
|
|
|
124625
124663
|
currentSegment += char;
|
|
124626
124664
|
}
|
|
124627
124665
|
}
|
|
124628
|
-
return inBrackets || segments.length === 0 ? [
|
|
124666
|
+
return inBrackets || segments.length === 0 ? [path72] : segments;
|
|
124629
124667
|
}
|
|
124630
124668
|
};
|
|
124631
124669
|
var INTEGER_PATTERN = /^0$|^[1-9]\d*$/;
|
|
@@ -125198,11 +125236,11 @@ var OpenAPISerializer = class {
|
|
|
125198
125236
|
return json2;
|
|
125199
125237
|
}
|
|
125200
125238
|
const form = new FormData();
|
|
125201
|
-
for (const [
|
|
125239
|
+
for (const [path72, value22] of this.bracketNotation.serialize(json2)) {
|
|
125202
125240
|
if (value22 instanceof Blob) {
|
|
125203
|
-
form.append(
|
|
125241
|
+
form.append(path72, value22);
|
|
125204
125242
|
} else if (value22 !== void 0 && value22 !== null) {
|
|
125205
|
-
form.append(
|
|
125243
|
+
form.append(path72, String(value22));
|
|
125206
125244
|
}
|
|
125207
125245
|
}
|
|
125208
125246
|
return form;
|
|
@@ -125240,30 +125278,30 @@ function isBodylessMethod(method) {
|
|
|
125240
125278
|
return method === "GET" || method === "HEAD";
|
|
125241
125279
|
}
|
|
125242
125280
|
var PARAMETER_NAME_REGEX = /^[\w-]+$/;
|
|
125243
|
-
function getDynamicPathParams(
|
|
125244
|
-
if (!
|
|
125281
|
+
function getDynamicPathParams(path72) {
|
|
125282
|
+
if (!path72.includes("{")) {
|
|
125245
125283
|
return void 0;
|
|
125246
125284
|
}
|
|
125247
|
-
const len =
|
|
125285
|
+
const len = path72.length;
|
|
125248
125286
|
let params;
|
|
125249
125287
|
let index = 1;
|
|
125250
125288
|
while (index < len) {
|
|
125251
125289
|
const segmentStart = index;
|
|
125252
|
-
const slashPos =
|
|
125290
|
+
const slashPos = path72.indexOf("/", index);
|
|
125253
125291
|
const segmentEnd = slashPos === -1 ? len : slashPos;
|
|
125254
|
-
if (segmentEnd > segmentStart &&
|
|
125292
|
+
if (segmentEnd > segmentStart && path72.charCodeAt(segmentStart) === 123 && path72.charCodeAt(segmentEnd - 1) === 125) {
|
|
125255
125293
|
let parameterStart = segmentStart + 1;
|
|
125256
125294
|
let allowsSlash = false;
|
|
125257
|
-
const operator =
|
|
125295
|
+
const operator = path72.charCodeAt(parameterStart);
|
|
125258
125296
|
if (operator === 43) {
|
|
125259
125297
|
allowsSlash = true;
|
|
125260
125298
|
parameterStart++;
|
|
125261
125299
|
}
|
|
125262
|
-
const parameterName =
|
|
125300
|
+
const parameterName = path72.slice(parameterStart, segmentEnd - 1);
|
|
125263
125301
|
if (PARAMETER_NAME_REGEX.test(parameterName)) {
|
|
125264
125302
|
params ??= [];
|
|
125265
125303
|
params.push({
|
|
125266
|
-
segment:
|
|
125304
|
+
segment: path72.slice(segmentStart, segmentEnd),
|
|
125267
125305
|
startIndex: segmentStart,
|
|
125268
125306
|
parameterName,
|
|
125269
125307
|
allowsSlash
|
|
@@ -125306,8 +125344,8 @@ openapi.method = (method) => ({
|
|
|
125306
125344
|
...openapi({ method }),
|
|
125307
125345
|
name: "~openapi/method"
|
|
125308
125346
|
});
|
|
125309
|
-
openapi.path = (
|
|
125310
|
-
...openapi({ path:
|
|
125347
|
+
openapi.path = (path72) => ({
|
|
125348
|
+
...openapi({ path: path72 }),
|
|
125311
125349
|
name: "~openapi/path"
|
|
125312
125350
|
});
|
|
125313
125351
|
openapi.spec = (spec) => ({
|
|
@@ -126168,22 +126206,22 @@ function visitJsonSchemaRefs(value2, visit2, schemaLevel = true, seen = /* @__PU
|
|
|
126168
126206
|
}
|
|
126169
126207
|
}
|
|
126170
126208
|
}
|
|
126171
|
-
function mapJsonSchemaRefs(value2, map2, schemaLevel = true,
|
|
126209
|
+
function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path72 = []) {
|
|
126172
126210
|
if (!value2 || typeof value2 !== "object") {
|
|
126173
126211
|
return value2;
|
|
126174
126212
|
}
|
|
126175
126213
|
if (Array.isArray(value2)) {
|
|
126176
|
-
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...
|
|
126214
|
+
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path72, index]));
|
|
126177
126215
|
}
|
|
126178
126216
|
const result = {};
|
|
126179
126217
|
for (const key of Object.keys(value2)) {
|
|
126180
126218
|
const val = value2[key];
|
|
126181
126219
|
if (key === "$ref" && typeof val === "string") {
|
|
126182
|
-
setOwn(result, key, map2(val, [...
|
|
126220
|
+
setOwn(result, key, map2(val, [...path72, key]));
|
|
126183
126221
|
} else if (!schemaLevel) {
|
|
126184
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...
|
|
126222
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path72, key]));
|
|
126185
126223
|
} else if (JSON_SCHEMA_LOGIC_KEYWORDS.has(key) || JSON_SCHEMA_RECORD_KEYWORDS.has(key)) {
|
|
126186
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...
|
|
126224
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path72, key]));
|
|
126187
126225
|
} else {
|
|
126188
126226
|
setOwn(result, key, val);
|
|
126189
126227
|
}
|
|
@@ -126713,7 +126751,7 @@ function unlazy(maybeLazy) {
|
|
|
126713
126751
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
126714
126752
|
const options = resolveMaybeOptionalOptions(rest);
|
|
126715
126753
|
return async (...[input2, callerOptions]) => {
|
|
126716
|
-
const
|
|
126754
|
+
const path72 = toArray(options.path);
|
|
126717
126755
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
126718
126756
|
const clientContext = callerOptions?.context ?? {};
|
|
126719
126757
|
const context = await value(options.context, clientContext) ?? {};
|
|
@@ -126726,7 +126764,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
126726
126764
|
};
|
|
126727
126765
|
try {
|
|
126728
126766
|
const output2 = await runWithSpan("call_procedure", (span) => {
|
|
126729
|
-
span?.setAttribute("procedure.path",
|
|
126767
|
+
span?.setAttribute("procedure.path", path72);
|
|
126730
126768
|
return intercept(
|
|
126731
126769
|
options.interceptors,
|
|
126732
126770
|
{
|
|
@@ -126734,7 +126772,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
126734
126772
|
// input can be optional if it is undefinable
|
|
126735
126773
|
input: input2,
|
|
126736
126774
|
errors,
|
|
126737
|
-
path:
|
|
126775
|
+
path: path72,
|
|
126738
126776
|
procedure,
|
|
126739
126777
|
signal: callerOptions?.signal,
|
|
126740
126778
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -126985,10 +127023,10 @@ function augmentRouter(router, options) {
|
|
|
126985
127023
|
}
|
|
126986
127024
|
return enhanced;
|
|
126987
127025
|
}
|
|
126988
|
-
function getRouter(router,
|
|
127026
|
+
function getRouter(router, path72) {
|
|
126989
127027
|
let current = router;
|
|
126990
|
-
for (let i10 = 0; i10 <
|
|
126991
|
-
const segment =
|
|
127028
|
+
for (let i10 = 0; i10 < path72.length; i10++) {
|
|
127029
|
+
const segment = path72[i10];
|
|
126992
127030
|
if (!isTypescriptObject(current)) {
|
|
126993
127031
|
return void 0;
|
|
126994
127032
|
}
|
|
@@ -127000,7 +127038,7 @@ function getRouter(router, path71) {
|
|
|
127000
127038
|
continue;
|
|
127001
127039
|
}
|
|
127002
127040
|
const lazied = current;
|
|
127003
|
-
const rest =
|
|
127041
|
+
const rest = path72.slice(i10);
|
|
127004
127042
|
return new Lazy({
|
|
127005
127043
|
...lazied["~orpc"],
|
|
127006
127044
|
async loader() {
|
|
@@ -127015,40 +127053,40 @@ function getRouter(router, path71) {
|
|
|
127015
127053
|
}
|
|
127016
127054
|
return current;
|
|
127017
127055
|
}
|
|
127018
|
-
function walkProcedureContractsSync(router, callback,
|
|
127056
|
+
function walkProcedureContractsSync(router, callback, path72 = []) {
|
|
127019
127057
|
const lazyResults = [];
|
|
127020
|
-
walkProcedureContractsSyncInternal(router, callback,
|
|
127058
|
+
walkProcedureContractsSyncInternal(router, callback, path72.slice(), lazyResults);
|
|
127021
127059
|
return lazyResults;
|
|
127022
127060
|
}
|
|
127023
|
-
function walkProcedureContractsSyncInternal(router, callback,
|
|
127061
|
+
function walkProcedureContractsSyncInternal(router, callback, path72, lazyResults) {
|
|
127024
127062
|
const hiddenContract = getHiddenRouterContract(router);
|
|
127025
127063
|
if (hiddenContract !== void 0) {
|
|
127026
127064
|
router = hiddenContract;
|
|
127027
127065
|
}
|
|
127028
127066
|
if (router instanceof ProcedureContract) {
|
|
127029
|
-
callback(router,
|
|
127067
|
+
callback(router, path72.slice());
|
|
127030
127068
|
return;
|
|
127031
127069
|
}
|
|
127032
127070
|
if (!isTypescriptObject(router)) {
|
|
127033
127071
|
return;
|
|
127034
127072
|
}
|
|
127035
127073
|
for (const [key, value2] of Object.entries(router)) {
|
|
127036
|
-
|
|
127074
|
+
path72.push(key);
|
|
127037
127075
|
if (value2 instanceof Lazy) {
|
|
127038
|
-
lazyResults.push({ router: value2, path:
|
|
127076
|
+
lazyResults.push({ router: value2, path: path72.slice() });
|
|
127039
127077
|
} else {
|
|
127040
|
-
walkProcedureContractsSyncInternal(value2, callback,
|
|
127078
|
+
walkProcedureContractsSyncInternal(value2, callback, path72, lazyResults);
|
|
127041
127079
|
}
|
|
127042
|
-
|
|
127080
|
+
path72.pop();
|
|
127043
127081
|
}
|
|
127044
127082
|
}
|
|
127045
|
-
async function walkProcedureContractsAsync(router, callback,
|
|
127083
|
+
async function walkProcedureContractsAsync(router, callback, path72 = []) {
|
|
127046
127084
|
const hiddenContract = getHiddenRouterContract(router);
|
|
127047
127085
|
if (hiddenContract !== void 0) {
|
|
127048
127086
|
router = hiddenContract;
|
|
127049
127087
|
}
|
|
127050
127088
|
if (router instanceof ProcedureContract) {
|
|
127051
|
-
await callback(router,
|
|
127089
|
+
await callback(router, path72);
|
|
127052
127090
|
return;
|
|
127053
127091
|
}
|
|
127054
127092
|
if (!isTypescriptObject(router)) {
|
|
@@ -127057,9 +127095,9 @@ async function walkProcedureContractsAsync(router, callback, path71 = []) {
|
|
|
127057
127095
|
for (const [key, value2] of Object.entries(router)) {
|
|
127058
127096
|
if (value2 instanceof Lazy) {
|
|
127059
127097
|
const { default: router2 } = await unlazy(value2);
|
|
127060
|
-
await walkProcedureContractsAsync(router2, callback, [...
|
|
127098
|
+
await walkProcedureContractsAsync(router2, callback, [...path72, key]);
|
|
127061
127099
|
} else {
|
|
127062
|
-
await walkProcedureContractsAsync(value2, callback, [...
|
|
127100
|
+
await walkProcedureContractsAsync(value2, callback, [...path72, key]);
|
|
127063
127101
|
}
|
|
127064
127102
|
}
|
|
127065
127103
|
}
|
|
@@ -127545,18 +127583,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
|
|
|
127545
127583
|
}
|
|
127546
127584
|
var OpenAPIGeneratorError = class extends TypeError {
|
|
127547
127585
|
};
|
|
127548
|
-
function toOpenAPIPath(
|
|
127586
|
+
function toOpenAPIPath(path72, dynamicPathParams) {
|
|
127549
127587
|
if (!dynamicPathParams?.length) {
|
|
127550
|
-
return
|
|
127588
|
+
return path72;
|
|
127551
127589
|
}
|
|
127552
127590
|
let normalized = "";
|
|
127553
127591
|
let currentIndex = 0;
|
|
127554
127592
|
for (const param of dynamicPathParams) {
|
|
127555
|
-
normalized +=
|
|
127593
|
+
normalized += path72.slice(currentIndex, param.startIndex);
|
|
127556
127594
|
normalized += `{${param.parameterName}}`;
|
|
127557
127595
|
currentIndex = param.startIndex + param.segment.length;
|
|
127558
127596
|
}
|
|
127559
|
-
normalized +=
|
|
127597
|
+
normalized += path72.slice(currentIndex);
|
|
127560
127598
|
return normalized;
|
|
127561
127599
|
}
|
|
127562
127600
|
function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
|
|
@@ -127990,8 +128028,8 @@ var OpenAPIGenerator = class {
|
|
|
127990
128028
|
customErrorResponseBodySchema: options.customErrorResponseBodySchema
|
|
127991
128029
|
};
|
|
127992
128030
|
const errors = [];
|
|
127993
|
-
await walkProcedureContractsAsync(router, (contract,
|
|
127994
|
-
if (value(options.filter, contract,
|
|
128031
|
+
await walkProcedureContractsAsync(router, (contract, path72) => {
|
|
128032
|
+
if (value(options.filter, contract, path72) === false) {
|
|
127995
128033
|
return;
|
|
127996
128034
|
}
|
|
127997
128035
|
try {
|
|
@@ -128003,7 +128041,7 @@ var OpenAPIGenerator = class {
|
|
|
128003
128041
|
`QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
|
|
128004
128042
|
);
|
|
128005
128043
|
}
|
|
128006
|
-
const postPath = meta3?.path ?? pathToHttpPath(
|
|
128044
|
+
const postPath = meta3?.path ?? pathToHttpPath(path72);
|
|
128007
128045
|
const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
|
|
128008
128046
|
const dynamicPathParams = getDynamicPathParams(httpPath);
|
|
128009
128047
|
const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
|
|
@@ -128012,7 +128050,7 @@ var OpenAPIGenerator = class {
|
|
|
128012
128050
|
operation = meta3.spec;
|
|
128013
128051
|
} else {
|
|
128014
128052
|
operation = {
|
|
128015
|
-
operationId: meta3?.operationId ??
|
|
128053
|
+
operationId: meta3?.operationId ?? path72.join("."),
|
|
128016
128054
|
summary: meta3?.summary,
|
|
128017
128055
|
description: meta3?.description,
|
|
128018
128056
|
deprecated: meta3?.deprecated,
|
|
@@ -128032,7 +128070,7 @@ var OpenAPIGenerator = class {
|
|
|
128032
128070
|
if (!(e14 instanceof OpenAPIGeneratorError)) {
|
|
128033
128071
|
throw e14;
|
|
128034
128072
|
}
|
|
128035
|
-
errors.push(`Procedure at ${
|
|
128073
|
+
errors.push(`Procedure at ${path72.join(".") || "(root)"}: ${e14.message}`);
|
|
128036
128074
|
}
|
|
128037
128075
|
});
|
|
128038
128076
|
if (errors.length) {
|
|
@@ -128879,16 +128917,16 @@ var StandardLink = class {
|
|
|
128879
128917
|
/**
|
|
128880
128918
|
* @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
|
|
128881
128919
|
*/
|
|
128882
|
-
call(
|
|
128883
|
-
return runWithSpan(`${ORPC_NAME}.${
|
|
128920
|
+
call(path72, input2, options) {
|
|
128921
|
+
return runWithSpan(`${ORPC_NAME}.${path72.join("/")}`, (span) => {
|
|
128884
128922
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
128885
|
-
span?.setAttribute("rpc.method",
|
|
128923
|
+
span?.setAttribute("rpc.method", path72.join("."));
|
|
128886
128924
|
if (getTracer() && isAsyncIteratorObject(input2)) {
|
|
128887
128925
|
input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
|
|
128888
128926
|
} else if (getTracer() && input2 instanceof ReadableStream) {
|
|
128889
128927
|
input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
|
|
128890
128928
|
}
|
|
128891
|
-
return intercept(this.interceptors, { ...options, path:
|
|
128929
|
+
return intercept(this.interceptors, { ...options, path: path72, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
128892
128930
|
const tracer = getTracer();
|
|
128893
128931
|
const activeSpan = tracer?.getActiveSpan() ?? span;
|
|
128894
128932
|
let request7 = await runWithSpan(
|
|
@@ -128945,18 +128983,18 @@ var RPCLinkCodec = class {
|
|
|
128945
128983
|
this.headers = options.headers ?? {};
|
|
128946
128984
|
this.serializer = options.serializer ?? new RPCSerializer();
|
|
128947
128985
|
}
|
|
128948
|
-
async encodeInput(input2,
|
|
128949
|
-
let headers = toResolvedStandardHeaders(await value(this.headers, options,
|
|
128986
|
+
async encodeInput(input2, path72, options) {
|
|
128987
|
+
let headers = toResolvedStandardHeaders(await value(this.headers, options, path72, input2));
|
|
128950
128988
|
if (options.lastEventId !== void 0) {
|
|
128951
128989
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
128952
128990
|
}
|
|
128953
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
128954
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
128991
|
+
const expectedMethod = await value(this.expectedMethod, options, path72, input2);
|
|
128992
|
+
const baseUrl = await value(this.baseUrl, options, path72, input2);
|
|
128955
128993
|
const [pathname, search, hash2] = parseStandardUrl(baseUrl);
|
|
128956
|
-
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(
|
|
128994
|
+
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path72)}`;
|
|
128957
128995
|
const serialized = this.serializer.serialize(input2);
|
|
128958
128996
|
if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
128959
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
128997
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path72, input2);
|
|
128960
128998
|
const mergedSearch = new URLSearchParams(search);
|
|
128961
128999
|
mergedSearch.append("data", stringifyJSON(serialized) ?? "");
|
|
128962
129000
|
const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
|
|
@@ -129041,8 +129079,8 @@ var FetchLinkTransport = class {
|
|
|
129041
129079
|
this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
|
|
129042
129080
|
this.toFetchRequestOptions = options.toFetchRequest;
|
|
129043
129081
|
}
|
|
129044
|
-
async send(standardRequest,
|
|
129045
|
-
let origin = await value(this.origin, options,
|
|
129082
|
+
async send(standardRequest, path72, options) {
|
|
129083
|
+
let origin = await value(this.origin, options, path72);
|
|
129046
129084
|
if (origin?.endsWith("/")) {
|
|
129047
129085
|
origin = origin.slice(0, -1);
|
|
129048
129086
|
}
|
|
@@ -129062,7 +129100,7 @@ var FetchLinkTransport = class {
|
|
|
129062
129100
|
}
|
|
129063
129101
|
}
|
|
129064
129102
|
const fetch3 = this.fetch;
|
|
129065
|
-
const response = await fetch3(url2, init, options,
|
|
129103
|
+
const response = await fetch3(url2, init, options, path72);
|
|
129066
129104
|
const standardResponse = toStandardLazyResponse(response);
|
|
129067
129105
|
return standardResponse;
|
|
129068
129106
|
}
|
|
@@ -129453,14 +129491,14 @@ var StandardHandler = class {
|
|
|
129453
129491
|
span?.setAttribute("url.path", request22.url);
|
|
129454
129492
|
return { matched: false };
|
|
129455
129493
|
}
|
|
129456
|
-
const { path:
|
|
129457
|
-
span?.updateName(`${ORPC_NAME}.${
|
|
129494
|
+
const { path: path72, procedure, decodeInput } = matchedOrNot;
|
|
129495
|
+
span?.updateName(`${ORPC_NAME}.${path72.join("/")}`);
|
|
129458
129496
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
129459
|
-
span?.setAttribute("rpc.method",
|
|
129497
|
+
span?.setAttribute("rpc.method", path72.join("."));
|
|
129460
129498
|
try {
|
|
129461
129499
|
const response = await intercept(
|
|
129462
129500
|
this.interceptors,
|
|
129463
|
-
{ context: context2, prefix: prefix2, request: request22, path:
|
|
129501
|
+
{ context: context2, prefix: prefix2, request: request22, path: path72, procedure, decodeInput },
|
|
129464
129502
|
async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
|
|
129465
129503
|
step2 = "decode_input";
|
|
129466
129504
|
let input2 = await runWithSpan("decode_input", decodeInput2);
|
|
@@ -129494,7 +129532,7 @@ var StandardHandler = class {
|
|
|
129494
129532
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
129495
129533
|
cause: e14
|
|
129496
129534
|
}) : toORPCError(e14);
|
|
129497
|
-
const response = await this.codec.encodeError(error63, procedure,
|
|
129535
|
+
const response = await this.codec.encodeError(error63, procedure, path72, { context: context2, prefix: prefix2 });
|
|
129498
129536
|
return { matched: true, response };
|
|
129499
129537
|
}
|
|
129500
129538
|
}
|
|
@@ -129600,7 +129638,7 @@ var RPCMatcher = class {
|
|
|
129600
129638
|
this.rootRouter = router;
|
|
129601
129639
|
this.index(router);
|
|
129602
129640
|
}
|
|
129603
|
-
index(router,
|
|
129641
|
+
index(router, path72 = []) {
|
|
129604
129642
|
const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
|
|
129605
129643
|
if (!value(this.filter, procedure, procedurePath)) {
|
|
129606
129644
|
return;
|
|
@@ -129611,7 +129649,7 @@ var RPCMatcher = class {
|
|
|
129611
129649
|
// contract-first entries have no implementation yet, resolveProcedure fills it in on demand
|
|
129612
129650
|
procedure: procedure instanceof Procedure ? procedure : void 0
|
|
129613
129651
|
});
|
|
129614
|
-
},
|
|
129652
|
+
}, path72);
|
|
129615
129653
|
for (const result of lazyResults) {
|
|
129616
129654
|
this.pendingLazyRouters.set(pathToHttpPath(result.path), result);
|
|
129617
129655
|
}
|
|
@@ -129743,10 +129781,10 @@ var RPCHandlerCodec = class {
|
|
|
129743
129781
|
}
|
|
129744
129782
|
};
|
|
129745
129783
|
}
|
|
129746
|
-
encodeOutput(output2, procedure,
|
|
129784
|
+
encodeOutput(output2, procedure, path72, options) {
|
|
129747
129785
|
return {
|
|
129748
129786
|
headers: {},
|
|
129749
|
-
status: value(this.outputStatus, output2, procedure,
|
|
129787
|
+
status: value(this.outputStatus, output2, procedure, path72, options) ?? DEFAULT_SUCCESS_STATUS,
|
|
129750
129788
|
body: this.serializer.serialize(output2)
|
|
129751
129789
|
};
|
|
129752
129790
|
}
|
|
@@ -129800,39 +129838,39 @@ function createRouter() {
|
|
|
129800
129838
|
static: new NullProtoObj2()
|
|
129801
129839
|
};
|
|
129802
129840
|
}
|
|
129803
|
-
function scanFirstGroup(
|
|
129841
|
+
function scanFirstGroup(path72) {
|
|
129804
129842
|
let i10 = 0;
|
|
129805
129843
|
let depth = 0;
|
|
129806
|
-
for (; i10 <
|
|
129807
|
-
const c10 =
|
|
129844
|
+
for (; i10 < path72.length; i10++) {
|
|
129845
|
+
const c10 = path72.charCodeAt(i10);
|
|
129808
129846
|
if (c10 === 92) i10++;
|
|
129809
129847
|
else if (c10 === 40) depth++;
|
|
129810
129848
|
else if (c10 === 41 && depth > 0) depth--;
|
|
129811
129849
|
else if (c10 === 123 && depth === 0) break;
|
|
129812
129850
|
}
|
|
129813
|
-
if (i10 >=
|
|
129851
|
+
if (i10 >= path72.length) return;
|
|
129814
129852
|
let j10 = i10 + 1;
|
|
129815
129853
|
depth = 0;
|
|
129816
|
-
for (; j10 <
|
|
129817
|
-
const c10 =
|
|
129854
|
+
for (; j10 < path72.length; j10++) {
|
|
129855
|
+
const c10 = path72.charCodeAt(j10);
|
|
129818
129856
|
if (c10 === 92) j10++;
|
|
129819
129857
|
else if (c10 === 40) depth++;
|
|
129820
129858
|
else if (c10 === 41 && depth > 0) depth--;
|
|
129821
129859
|
else if (c10 === 125 && depth === 0) break;
|
|
129822
129860
|
}
|
|
129823
|
-
if (j10 >=
|
|
129824
|
-
const mod =
|
|
129861
|
+
if (j10 >= path72.length) return;
|
|
129862
|
+
const mod = path72[j10 + 1];
|
|
129825
129863
|
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
129826
129864
|
return [
|
|
129827
|
-
|
|
129828
|
-
|
|
129829
|
-
|
|
129865
|
+
path72.slice(0, i10),
|
|
129866
|
+
path72.slice(i10 + 1, j10),
|
|
129867
|
+
path72.slice(j10 + (hasMod ? 2 : 1)),
|
|
129830
129868
|
hasMod ? mod : void 0
|
|
129831
129869
|
];
|
|
129832
129870
|
}
|
|
129833
|
-
function expandGroupDelimiters(
|
|
129834
|
-
if (!
|
|
129835
|
-
const group = scanFirstGroup(
|
|
129871
|
+
function expandGroupDelimiters(path72) {
|
|
129872
|
+
if (!path72.includes("{")) return;
|
|
129873
|
+
const group = scanFirstGroup(path72);
|
|
129836
129874
|
if (!group) return;
|
|
129837
129875
|
const [pre2, body, suf, mod] = group;
|
|
129838
129876
|
if (!mod) return [pre2 + body + suf];
|
|
@@ -129902,9 +129940,9 @@ function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGr
|
|
|
129902
129940
|
}
|
|
129903
129941
|
return [replaced, nextIndex];
|
|
129904
129942
|
}
|
|
129905
|
-
function encodeEscapes(
|
|
129906
|
-
if (!
|
|
129907
|
-
return
|
|
129943
|
+
function encodeEscapes(path72) {
|
|
129944
|
+
if (!path72.includes("\\")) return path72;
|
|
129945
|
+
return path72.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
|
|
129908
129946
|
}
|
|
129909
129947
|
function segmentKey(segment) {
|
|
129910
129948
|
if (segment.startsWith("**")) return 2;
|
|
@@ -129933,22 +129971,22 @@ function expandModifiers(segments) {
|
|
|
129933
129971
|
return m10[2] === "+" ? [wc2] : [wc2, without];
|
|
129934
129972
|
}
|
|
129935
129973
|
}
|
|
129936
|
-
function normalizePath(
|
|
129937
|
-
if (!
|
|
129974
|
+
function normalizePath(path72) {
|
|
129975
|
+
if (!path72.includes("/.")) return path72;
|
|
129938
129976
|
const r10 = [];
|
|
129939
|
-
for (const s of
|
|
129977
|
+
for (const s of path72.split("/")) if (s === ".") continue;
|
|
129940
129978
|
else if (s === ".." && r10.length > 1) r10.pop();
|
|
129941
129979
|
else r10.push(s);
|
|
129942
129980
|
return r10.join("/") || "/";
|
|
129943
129981
|
}
|
|
129944
|
-
function splitPath(
|
|
129945
|
-
const s =
|
|
129982
|
+
function splitPath(path72) {
|
|
129983
|
+
const s = path72.split("/");
|
|
129946
129984
|
s.shift();
|
|
129947
129985
|
if (s[s.length - 1] === "") s.pop();
|
|
129948
129986
|
return s;
|
|
129949
129987
|
}
|
|
129950
|
-
function splitRoute(
|
|
129951
|
-
const s = splitPath(
|
|
129988
|
+
function splitRoute(path72) {
|
|
129989
|
+
const s = splitPath(path72);
|
|
129952
129990
|
while (s[s.length - 1] === "") s.pop();
|
|
129953
129991
|
return s;
|
|
129954
129992
|
}
|
|
@@ -129964,16 +130002,16 @@ function getMatchParams(segments, paramsMap) {
|
|
|
129964
130002
|
}
|
|
129965
130003
|
return params;
|
|
129966
130004
|
}
|
|
129967
|
-
function addRoute(ctx, method = "",
|
|
130005
|
+
function addRoute(ctx, method = "", path72, data) {
|
|
129968
130006
|
method = method.toUpperCase();
|
|
129969
|
-
if (
|
|
129970
|
-
const groupExpanded = expandGroupDelimiters(
|
|
130007
|
+
if (path72.charCodeAt(0) !== 47) path72 = `/${path72}`;
|
|
130008
|
+
const groupExpanded = expandGroupDelimiters(path72);
|
|
129971
130009
|
if (groupExpanded) {
|
|
129972
130010
|
for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
|
|
129973
130011
|
return;
|
|
129974
130012
|
}
|
|
129975
|
-
|
|
129976
|
-
const segments = splitRoute(
|
|
130013
|
+
path72 = encodeEscapes(path72);
|
|
130014
|
+
const segments = splitRoute(path72);
|
|
129977
130015
|
const expanded = expandModifiers(segments);
|
|
129978
130016
|
if (expanded) {
|
|
129979
130017
|
for (const p of expanded) addRoute(ctx, method, p, data);
|
|
@@ -130064,15 +130102,15 @@ function getParamRegexp(segment, unnamedStart = 0) {
|
|
|
130064
130102
|
const regex2 = _s2.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id2, p) => `(?<${toGroupName(id2)}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i2++)}>`).replace(/\uFFFE(.)/g, (_, c10) => /[.*+?^${}()|[\]\\]/.test(c10) ? `\\${c10}` : c10);
|
|
130065
130103
|
return [new RegExp(`^${regex2}$`), _i2];
|
|
130066
130104
|
}
|
|
130067
|
-
function findRoute(ctx, method = "",
|
|
130068
|
-
if (opts?.normalize)
|
|
130069
|
-
if (
|
|
130070
|
-
const staticNode = ctx.static[
|
|
130105
|
+
function findRoute(ctx, method = "", path72, opts) {
|
|
130106
|
+
if (opts?.normalize) path72 = normalizePath(path72);
|
|
130107
|
+
if (path72.charCodeAt(path72.length - 1) === 47) path72 = path72.slice(0, -1);
|
|
130108
|
+
const staticNode = ctx.static[path72];
|
|
130071
130109
|
if (staticNode && staticNode.methods) {
|
|
130072
130110
|
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
130073
130111
|
if (staticMatch !== void 0) return staticMatch[0];
|
|
130074
130112
|
}
|
|
130075
|
-
const segments = splitPath(
|
|
130113
|
+
const segments = splitPath(path72);
|
|
130076
130114
|
const match = _lookupTree(ctx.root, method, segments, 0);
|
|
130077
130115
|
if (match === void 0) return;
|
|
130078
130116
|
if (opts?.params === false) return match;
|
|
@@ -130272,7 +130310,7 @@ var OpenAPIMatcher = class {
|
|
|
130272
130310
|
this.rootRouter = router;
|
|
130273
130311
|
this.index(router);
|
|
130274
130312
|
}
|
|
130275
|
-
index(router,
|
|
130313
|
+
index(router, path72 = []) {
|
|
130276
130314
|
const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
|
|
130277
130315
|
if (!value(this.filter, contract, path210)) {
|
|
130278
130316
|
return;
|
|
@@ -130287,7 +130325,7 @@ var OpenAPIMatcher = class {
|
|
|
130287
130325
|
contract,
|
|
130288
130326
|
procedure: contract instanceof Procedure ? contract : void 0
|
|
130289
130327
|
});
|
|
130290
|
-
},
|
|
130328
|
+
}, path72);
|
|
130291
130329
|
for (const result of lazyResults) {
|
|
130292
130330
|
const prefix = getOpenAPIMeta(result.router)?.prefix;
|
|
130293
130331
|
this.pendingLazyRouters.add({
|
|
@@ -130374,20 +130412,20 @@ var OpenAPIMatcher = class {
|
|
|
130374
130412
|
return entry.procedure;
|
|
130375
130413
|
}
|
|
130376
130414
|
};
|
|
130377
|
-
function toRou3Pattern(
|
|
130378
|
-
const params = getDynamicPathParams(
|
|
130415
|
+
function toRou3Pattern(path72) {
|
|
130416
|
+
const params = getDynamicPathParams(path72);
|
|
130379
130417
|
if (!params?.length) {
|
|
130380
|
-
return
|
|
130418
|
+
return path72;
|
|
130381
130419
|
}
|
|
130382
130420
|
for (let i10 = params.length - 1; i10 >= 0; i10--) {
|
|
130383
130421
|
const param = params[i10];
|
|
130384
130422
|
const pattern = param.allowsSlash ? `**:${param.parameterName}` : `:${param.parameterName}`;
|
|
130385
|
-
|
|
130423
|
+
path72 = path72.slice(0, param.startIndex) + pattern + path72.slice(param.startIndex + param.segment.length);
|
|
130386
130424
|
}
|
|
130387
|
-
return
|
|
130425
|
+
return path72;
|
|
130388
130426
|
}
|
|
130389
|
-
function toRou3PrefixMatcher(
|
|
130390
|
-
const pattern = toRou3Pattern(
|
|
130427
|
+
function toRou3PrefixMatcher(path72) {
|
|
130428
|
+
const pattern = toRou3Pattern(path72);
|
|
130391
130429
|
return routeToRegExp(pattern === "/" ? "/**" : `${pattern}/**`);
|
|
130392
130430
|
}
|
|
130393
130431
|
function decodeParams(params) {
|
|
@@ -130466,7 +130504,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
130466
130504
|
/**
|
|
130467
130505
|
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
130468
130506
|
*/
|
|
130469
|
-
encodeOutput(output2, procedure,
|
|
130507
|
+
encodeOutput(output2, procedure, path72) {
|
|
130470
130508
|
const meta3 = getOpenAPIMeta(procedure);
|
|
130471
130509
|
const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
|
|
130472
130510
|
const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
|
|
@@ -130479,7 +130517,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
130479
130517
|
}
|
|
130480
130518
|
if (!isValidDetailedOutput(output2)) {
|
|
130481
130519
|
throw new TypeError(`
|
|
130482
|
-
Invalid "detailed" output structure returned by procedure (${
|
|
130520
|
+
Invalid "detailed" output structure returned by procedure (${path72.join(".")}):
|
|
130483
130521
|
\u2022 Expected an object with optional properties:
|
|
130484
130522
|
- status (number <400)
|
|
130485
130523
|
- headers (object)
|
|
@@ -130844,6 +130882,7 @@ init_providersStore();
|
|
|
130844
130882
|
// src/frontdoor/configSchemas.ts
|
|
130845
130883
|
init_zod();
|
|
130846
130884
|
init_schema();
|
|
130885
|
+
init_statusline();
|
|
130847
130886
|
var RemovalConfirmationSchema = external_exports.boolean();
|
|
130848
130887
|
var CredentialWriteSchema = (targets) => external_exports.strictObject({
|
|
130849
130888
|
sources: external_exports.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
@@ -130896,6 +130935,13 @@ var ConfigIdentitySetInputSchema = external_exports.strictObject({
|
|
|
130896
130935
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
130897
130936
|
var ConfigIdentityRemoveInputSchema = external_exports.strictObject({ name: external_exports.string().min(1), confirm: RemovalConfirmationSchema });
|
|
130898
130937
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
130938
|
+
var ConfigStatuslineSetSchema = external_exports.record(external_exports.string(), external_exports.unknown()).superRefine((settings2, context) => {
|
|
130939
|
+
for (const key of Object.keys(settings2)) {
|
|
130940
|
+
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
130941
|
+
context.addIssue({ code: "custom", path: [key], message: `a config write through the API cannot set "${key}": the extra segment's command runs a program, so only your own configuration (the global config, a profile you edit yourself, a directory rule or a command-line assignment) may set it` });
|
|
130942
|
+
}
|
|
130943
|
+
}
|
|
130944
|
+
});
|
|
130899
130945
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
130900
130946
|
var ConfigProfileAddInputSchema = external_exports.strictObject({
|
|
130901
130947
|
name: external_exports.string().min(1),
|
|
@@ -130921,7 +130967,7 @@ var ConfigProfileSetInputSchema = external_exports.strictObject({
|
|
|
130921
130967
|
explain: external_exports.boolean().optional(),
|
|
130922
130968
|
proxyBypass: external_exports.union([external_exports.array(external_exports.string().min(1)), external_exports.literal(false)]).optional(),
|
|
130923
130969
|
statusline: external_exports.strictObject({
|
|
130924
|
-
set:
|
|
130970
|
+
set: ConfigStatuslineSetSchema.optional(),
|
|
130925
130971
|
unset: external_exports.array(external_exports.string()).optional()
|
|
130926
130972
|
}).optional()
|
|
130927
130973
|
}).optional()
|
|
@@ -131047,7 +131093,7 @@ function profileValue(name, paths) {
|
|
|
131047
131093
|
function createConfigApiRouter(deps) {
|
|
131048
131094
|
const authed = doorApiAuth(deps.expectedToken);
|
|
131049
131095
|
const { paths } = deps;
|
|
131050
|
-
const route = (
|
|
131096
|
+
const route = (path72, summary) => authed.meta(openapi({ method: "POST", path: path72, summary, tags: [CONFIG_API_TAG] }));
|
|
131051
131097
|
return {
|
|
131052
131098
|
config: {
|
|
131053
131099
|
identity: {
|
|
@@ -131816,6 +131862,83 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
131816
131862
|
};
|
|
131817
131863
|
}
|
|
131818
131864
|
|
|
131865
|
+
// src/frontdoor/liveSessionRegistry.ts
|
|
131866
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
131867
|
+
init_capability();
|
|
131868
|
+
init_state();
|
|
131869
|
+
function sameStat(recorded, current) {
|
|
131870
|
+
return recorded?.mtimeMs === current.mtimeMs && recorded.sizeBytes === current.sizeBytes;
|
|
131871
|
+
}
|
|
131872
|
+
function createLiveSessionRegistry(ports) {
|
|
131873
|
+
const { fs: fs31, sessionsDir } = ports;
|
|
131874
|
+
const known = /* @__PURE__ */ new Map();
|
|
131875
|
+
let tokens = /* @__PURE__ */ new Set();
|
|
131876
|
+
let bySessionId = /* @__PURE__ */ new Map();
|
|
131877
|
+
const recordNames = () => fs31.readdir(sessionsDir).filter(isSessionRecordName);
|
|
131878
|
+
const rebuildIndexes = () => {
|
|
131879
|
+
const records = [...known.values()].flatMap(({ record: record2 }) => record2 === void 0 ? [] : [record2]);
|
|
131880
|
+
tokens = new Set(records.map((record2) => record2.token));
|
|
131881
|
+
bySessionId = new Map(records.flatMap((record2) => record2.sessionId === void 0 ? [] : [[record2.sessionId, record2]]));
|
|
131882
|
+
};
|
|
131883
|
+
const load = (name, stat) => {
|
|
131884
|
+
known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs31, sessionsDir, name) });
|
|
131885
|
+
};
|
|
131886
|
+
const statOf = (name) => fs31.lstat(import_node_path50.default.join(sessionsDir, name));
|
|
131887
|
+
const reconcile = () => {
|
|
131888
|
+
const names = new Set(recordNames());
|
|
131889
|
+
let changed = false;
|
|
131890
|
+
for (const name of known.keys()) {
|
|
131891
|
+
if (!names.has(name)) {
|
|
131892
|
+
known.delete(name);
|
|
131893
|
+
changed = true;
|
|
131894
|
+
}
|
|
131895
|
+
}
|
|
131896
|
+
for (const name of names) {
|
|
131897
|
+
const held = known.get(name);
|
|
131898
|
+
const stat = statOf(name);
|
|
131899
|
+
if (stat === void 0) {
|
|
131900
|
+
changed = known.delete(name) || changed;
|
|
131901
|
+
} else if (!sameStat(held?.stat, stat)) {
|
|
131902
|
+
load(name, stat);
|
|
131903
|
+
changed = true;
|
|
131904
|
+
}
|
|
131905
|
+
}
|
|
131906
|
+
if (changed) {
|
|
131907
|
+
rebuildIndexes();
|
|
131908
|
+
}
|
|
131909
|
+
return changed;
|
|
131910
|
+
};
|
|
131911
|
+
return {
|
|
131912
|
+
admits: (token) => {
|
|
131913
|
+
if (isLiveCapability(token, tokens)) {
|
|
131914
|
+
return true;
|
|
131915
|
+
}
|
|
131916
|
+
return reconcile() && isLiveCapability(token, tokens);
|
|
131917
|
+
},
|
|
131918
|
+
modelsOf: (sessionId) => {
|
|
131919
|
+
const held = bySessionId.get(sessionId) ?? (reconcile() ? bySessionId.get(sessionId) : void 0);
|
|
131920
|
+
return held?.models;
|
|
131921
|
+
},
|
|
131922
|
+
rescan: () => {
|
|
131923
|
+
known.clear();
|
|
131924
|
+
for (const name of recordNames()) {
|
|
131925
|
+
const stat = statOf(name);
|
|
131926
|
+
if (stat !== void 0) {
|
|
131927
|
+
load(name, stat);
|
|
131928
|
+
}
|
|
131929
|
+
}
|
|
131930
|
+
rebuildIndexes();
|
|
131931
|
+
return [...known.values()].flatMap(({ record: record2 }) => record2 === void 0 ? [] : [summaryOf(record2)]).sort((a10, b) => a10.pid - b.pid);
|
|
131932
|
+
},
|
|
131933
|
+
forget: (pids) => {
|
|
131934
|
+
for (const pid of pids) {
|
|
131935
|
+
known.delete(sessionRecordName(pid));
|
|
131936
|
+
}
|
|
131937
|
+
rebuildIndexes();
|
|
131938
|
+
}
|
|
131939
|
+
};
|
|
131940
|
+
}
|
|
131941
|
+
|
|
131819
131942
|
// src/frontdoor/launchEvents.ts
|
|
131820
131943
|
function createLaunchEventPublisher(hub, now) {
|
|
131821
131944
|
const publisher = hub.publisher(LAUNCH_EVENT_SOURCE);
|
|
@@ -133075,8 +133198,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
133075
133198
|
request7.body.resume();
|
|
133076
133199
|
return;
|
|
133077
133200
|
}
|
|
133078
|
-
const
|
|
133079
|
-
const translated = { method: request7.method, path:
|
|
133201
|
+
const path72 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133202
|
+
const translated = { method: request7.method, path: path72, body, signal: request7.signal };
|
|
133080
133203
|
const routed = await route(translated);
|
|
133081
133204
|
if (request7.signal.aborted) {
|
|
133082
133205
|
return;
|
|
@@ -133697,8 +133820,8 @@ function createAntigravityRouteMount(ports, upstreamBase, provider) {
|
|
|
133697
133820
|
request7.body.resume();
|
|
133698
133821
|
return;
|
|
133699
133822
|
}
|
|
133700
|
-
const
|
|
133701
|
-
const translated = { method: request7.method, path:
|
|
133823
|
+
const path72 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133824
|
+
const translated = { method: request7.method, path: path72, body, signal: request7.signal };
|
|
133702
133825
|
const routed = await route(translated);
|
|
133703
133826
|
if (request7.signal.aborted) {
|
|
133704
133827
|
return;
|
|
@@ -133739,7 +133862,7 @@ function createPassthroughRoute(name, target) {
|
|
|
133739
133862
|
headroomUpstream: target.headroomUpstream,
|
|
133740
133863
|
serve: async (request7, response) => {
|
|
133741
133864
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
133742
|
-
const
|
|
133865
|
+
const path72 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
133743
133866
|
const headers = forwardableHeaders(request7.headers);
|
|
133744
133867
|
delete headers.host;
|
|
133745
133868
|
await new Promise((resolve2) => {
|
|
@@ -133747,7 +133870,7 @@ function createPassthroughRoute(name, target) {
|
|
|
133747
133870
|
host: base.hostname,
|
|
133748
133871
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
133749
133872
|
method: request7.method,
|
|
133750
|
-
path: `${basePath}${
|
|
133873
|
+
path: `${basePath}${path72}${incoming.search}`,
|
|
133751
133874
|
headers,
|
|
133752
133875
|
agent
|
|
133753
133876
|
};
|
|
@@ -133919,13 +134042,13 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
133919
134042
|
}
|
|
133920
134043
|
|
|
133921
134044
|
// src/frontdoor/providerRoute.ts
|
|
133922
|
-
var isRcSelfHostPath = (
|
|
134045
|
+
var isRcSelfHostPath = (path72) => path72 === "/v1/code/sessions" || path72.startsWith("/v1/code/sessions/") || path72 === "/v1/sessions" || path72.startsWith("/v1/sessions/");
|
|
133923
134046
|
function scopeSessionProviderPath(request7) {
|
|
133924
134047
|
if (request7.session.provider === void 0) {
|
|
133925
134048
|
return request7;
|
|
133926
134049
|
}
|
|
133927
|
-
const
|
|
133928
|
-
if (!
|
|
134050
|
+
const path72 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
134051
|
+
if (!path72.startsWith("/v1/") || isRcSelfHostPath(path72)) {
|
|
133929
134052
|
return request7;
|
|
133930
134053
|
}
|
|
133931
134054
|
return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
|
|
@@ -134049,13 +134172,13 @@ function createProviderRouteResolver(deps) {
|
|
|
134049
134172
|
return route;
|
|
134050
134173
|
};
|
|
134051
134174
|
const resolve2 = (request7) => {
|
|
134052
|
-
const
|
|
134053
|
-
const scoped = parseProviderPath(
|
|
134175
|
+
const path72 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
134176
|
+
const scoped = parseProviderPath(path72);
|
|
134054
134177
|
if (scoped === void 0) {
|
|
134055
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
134178
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path72)) {
|
|
134056
134179
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
134057
134180
|
}
|
|
134058
|
-
return
|
|
134181
|
+
return path72.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path72}` };
|
|
134059
134182
|
}
|
|
134060
134183
|
const { provider } = scoped;
|
|
134061
134184
|
let definition;
|
|
@@ -134150,8 +134273,8 @@ function createProviderRouteResolver(deps) {
|
|
|
134150
134273
|
let modelChoice;
|
|
134151
134274
|
const visited = /* @__PURE__ */ new Set();
|
|
134152
134275
|
for (; ; ) {
|
|
134153
|
-
const
|
|
134154
|
-
const scoped = parseProviderPath(
|
|
134276
|
+
const path72 = new URL(current.url, "http://127.0.0.1").pathname;
|
|
134277
|
+
const scoped = parseProviderPath(path72);
|
|
134155
134278
|
const providerName = scoped?.provider ?? current.session.provider;
|
|
134156
134279
|
if (providerName !== void 0 && visited.has(providerName)) {
|
|
134157
134280
|
return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
|
|
@@ -134166,7 +134289,7 @@ function createProviderRouteResolver(deps) {
|
|
|
134166
134289
|
} catch {
|
|
134167
134290
|
routes = void 0;
|
|
134168
134291
|
}
|
|
134169
|
-
const resolvesNames = !nameResolved && !isRcSelfHostPath(
|
|
134292
|
+
const resolvesNames = !nameResolved && !isRcSelfHostPath(path72);
|
|
134170
134293
|
if (resolvesNames) {
|
|
134171
134294
|
const scan2 = await scanRequestHead(current, true);
|
|
134172
134295
|
if (scan2.replayed === void 0) {
|
|
@@ -134205,7 +134328,7 @@ function createProviderRouteResolver(deps) {
|
|
|
134205
134328
|
}
|
|
134206
134329
|
if (routed.provider !== providerName) {
|
|
134207
134330
|
const scopedPrefix = providerName === void 0 ? void 0 : `${PROVIDER_PATH_PREFIX}${encodeURIComponent(providerName)}`;
|
|
134208
|
-
const rest2 = scopedPrefix !== void 0 &&
|
|
134331
|
+
const rest2 = scopedPrefix !== void 0 && path72.startsWith(scopedPrefix) ? path72.slice(scopedPrefix.length) : path72;
|
|
134209
134332
|
const query2 = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
134210
134333
|
const carried = replay;
|
|
134211
134334
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(routed.provider)}${rest2}${query2}`, body: carried.body, headers: carried.headers };
|
|
@@ -134259,7 +134382,7 @@ function createProviderRouteResolver(deps) {
|
|
|
134259
134382
|
const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
134260
134383
|
replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
|
|
134261
134384
|
}
|
|
134262
|
-
const rest = scoped === void 0 ?
|
|
134385
|
+
const rest = scoped === void 0 ? path72 : path72.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
|
|
134263
134386
|
const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
134264
134387
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
|
|
134265
134388
|
}
|
|
@@ -134296,7 +134419,7 @@ init_ensure2();
|
|
|
134296
134419
|
var import_node_child_process8 = require("node:child_process");
|
|
134297
134420
|
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
134298
134421
|
var import_node_net4 = __toESM(require("node:net"), 1);
|
|
134299
|
-
var
|
|
134422
|
+
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
134300
134423
|
|
|
134301
134424
|
// src/frontdoor/handover.ts
|
|
134302
134425
|
init_zod();
|
|
@@ -134382,7 +134505,7 @@ function predecessorOver(channel, isListeningSocket) {
|
|
|
134382
134505
|
|
|
134383
134506
|
// src/frontdoor/realHandover.ts
|
|
134384
134507
|
function spawnSuccessorDoor(paths, invocation) {
|
|
134385
|
-
import_node_fs21.default.mkdirSync(
|
|
134508
|
+
import_node_fs21.default.mkdirSync(import_node_path51.default.dirname(paths.frontdoorLogPath), { recursive: true });
|
|
134386
134509
|
const logFd = import_node_fs21.default.openSync(paths.frontdoorLogPath, "a");
|
|
134387
134510
|
let child;
|
|
134388
134511
|
try {
|
|
@@ -134566,7 +134689,7 @@ function createRcLiveUsage(deps) {
|
|
|
134566
134689
|
}
|
|
134567
134690
|
|
|
134568
134691
|
// src/frontdoor/rcSelfHostMint.ts
|
|
134569
|
-
var
|
|
134692
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
134570
134693
|
init_account();
|
|
134571
134694
|
|
|
134572
134695
|
// src/frontdoor/rcSelfHostLocal.ts
|
|
@@ -134696,7 +134819,7 @@ function readJsonObject(fs31, file2) {
|
|
|
134696
134819
|
return isRecord16(parsed) ? parsed : void 0;
|
|
134697
134820
|
}
|
|
134698
134821
|
function readRcSelfHostRecord(fs31, frontdoorDir) {
|
|
134699
|
-
const parsed = readJsonObject(fs31,
|
|
134822
|
+
const parsed = readJsonObject(fs31, import_node_path52.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
134700
134823
|
if (parsed === void 0) {
|
|
134701
134824
|
return void 0;
|
|
134702
134825
|
}
|
|
@@ -134710,11 +134833,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
134710
134833
|
if (!isIdentityName(deps.identity)) {
|
|
134711
134834
|
throw new Error(`"${deps.identity}" is not a valid identity name.`);
|
|
134712
134835
|
}
|
|
134713
|
-
const identityDir =
|
|
134714
|
-
const credentialsFile =
|
|
134715
|
-
const claudeJsonFile =
|
|
134716
|
-
const recordDir =
|
|
134717
|
-
const recordFile =
|
|
134836
|
+
const identityDir = import_node_path52.default.join(deps.identitiesDir, deps.identity);
|
|
134837
|
+
const credentialsFile = import_node_path52.default.join(identityDir, CREDENTIALS_FILE2);
|
|
134838
|
+
const claudeJsonFile = import_node_path52.default.join(identityDir, CLAUDE_JSON2);
|
|
134839
|
+
const recordDir = import_node_path52.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
134840
|
+
const recordFile = import_node_path52.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
134718
134841
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
134719
134842
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
134720
134843
|
const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -134730,7 +134853,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
134730
134853
|
const organizationUuid = deps.newUuid();
|
|
134731
134854
|
const accountUuid = deps.newUuid();
|
|
134732
134855
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
134733
|
-
deps.fs.mkdirPrivate(
|
|
134856
|
+
deps.fs.mkdirPrivate(import_node_path52.default.dirname(credentialsFile));
|
|
134734
134857
|
deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
|
|
134735
134858
|
`);
|
|
134736
134859
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -135117,7 +135240,7 @@ function registerRcCommand(frontdoor, paths) {
|
|
|
135117
135240
|
}
|
|
135118
135241
|
|
|
135119
135242
|
// src/frontdoor/rcCredentialStore.ts
|
|
135120
|
-
var
|
|
135243
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
135121
135244
|
function isSafeSessionId(sessionId) {
|
|
135122
135245
|
return /^[A-Za-z0-9_-]+$/.test(sessionId);
|
|
135123
135246
|
}
|
|
@@ -135143,7 +135266,7 @@ function sequenceNumOfJson(value2) {
|
|
|
135143
135266
|
}
|
|
135144
135267
|
function createRcCredentialStore(fs31, dir) {
|
|
135145
135268
|
fs31.mkdirPrivate(dir);
|
|
135146
|
-
const fileFor = (sessionId) =>
|
|
135269
|
+
const fileFor = (sessionId) => import_node_path53.default.join(dir, `${sessionId}.json`);
|
|
135147
135270
|
const readParsed = (sessionId) => {
|
|
135148
135271
|
const raw = fs31.readFileUtf8(fileFor(sessionId));
|
|
135149
135272
|
if (raw === void 0) {
|
|
@@ -137702,11 +137825,12 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
137702
137825
|
const observations = createTargetObservationStore(realFarmFs, paths);
|
|
137703
137826
|
const routingSnapshots = /* @__PURE__ */ new Map();
|
|
137704
137827
|
const rcControlToken = lifecycle.predecessor === void 0 ? (0, import_node_crypto25.randomUUID)() : inheritedControlToken(paths);
|
|
137828
|
+
const sessionRegistry = createLiveSessionRegistry({ fs: realFarmFs, sessionsDir: paths.frontdoorSessionsDir });
|
|
137705
137829
|
const resolveRoute = rcObservingResolver(
|
|
137706
137830
|
createProviderRouteResolver({
|
|
137707
137831
|
// Read live so a models-block edit reaches the next request without a door restart.
|
|
137708
137832
|
// The block this session launched with when its directory, profile or committed file added definitions of its own; otherwise the global block, read live so an edit applies to the next request with no relaunch.
|
|
137709
|
-
models: (session) => (session.sessionId === void 0 ? void 0 :
|
|
137833
|
+
models: (session) => (session.sessionId === void 0 ? void 0 : sessionRegistry.modelsOf(session.sessionId)) ?? readModels(paths),
|
|
137710
137834
|
targets: () => targetRefs(paths),
|
|
137711
137835
|
fs: realFsPort,
|
|
137712
137836
|
providersDir: paths.providersDir,
|
|
@@ -137730,7 +137854,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
137730
137854
|
rcTracker,
|
|
137731
137855
|
rcHub
|
|
137732
137856
|
);
|
|
137733
|
-
const isLiveToken = (token) =>
|
|
137857
|
+
const isLiveToken = (token) => sessionRegistry.admits(token);
|
|
137734
137858
|
const usageStore = createUsageStore({
|
|
137735
137859
|
fs: realFarmFs,
|
|
137736
137860
|
paths,
|
|
@@ -137874,6 +137998,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
137874
137998
|
return {
|
|
137875
137999
|
fs: realFarmFs,
|
|
137876
138000
|
paths,
|
|
138001
|
+
registry: sessionRegistry,
|
|
137877
138002
|
ownPid: process.pid,
|
|
137878
138003
|
now: () => Date.now(),
|
|
137879
138004
|
sleep: async (ms2) => {
|
|
@@ -137999,7 +138124,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
137999
138124
|
const leafFor = createLeafCache(loadCa(), () => /* @__PURE__ */ new Date());
|
|
138000
138125
|
const capture = captureFromEnv(process.env, paths.logsDir);
|
|
138001
138126
|
if (capture !== void 0) {
|
|
138002
|
-
log(`capture enabled, recording CONNECT targets and piped exchanges to ${
|
|
138127
|
+
log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path54.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
|
|
138003
138128
|
}
|
|
138004
138129
|
if (rcSelfHostSurface !== void 0) {
|
|
138005
138130
|
log("self-hosted Remote Control surface on: the door serves the CCR session family itself, and its own client-half dials its own transparent surface");
|
|
@@ -138054,6 +138179,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
138054
138179
|
drain: async () => {
|
|
138055
138180
|
if (transparentCapability !== void 0) {
|
|
138056
138181
|
removeFrontDoorSession(realFarmFs, paths.frontdoorSessionsDir, process.pid);
|
|
138182
|
+
sessionRegistry.forget([process.pid]);
|
|
138057
138183
|
}
|
|
138058
138184
|
await server.drain();
|
|
138059
138185
|
rcSelfHostSurface?.close();
|
|
@@ -138088,7 +138214,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
138088
138214
|
cooldownStepMs: DOOR_STALL_BOUND_MS,
|
|
138089
138215
|
cooldownCapMs: DOOR_RESPAWN_COOLDOWN_CAP_MS,
|
|
138090
138216
|
startLockFile: paths.frontdoorLockFile,
|
|
138091
|
-
...process.platform === "darwin" ? { nativeSample: { command: MACOS_SAMPLER, args: ["{pid}", "{seconds}", "-file", "{file}"], directory:
|
|
138217
|
+
...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)), overheadMs: PROBE_TIMEOUT_MS, keep: DOOR_RESPAWN_MAX_GENERATIONS + 1 } } : {}
|
|
138092
138218
|
}),
|
|
138093
138219
|
// 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.
|
|
138094
138220
|
observeLaunchRegistry: createLaunchEventPublisher(doorEvents, () => Date.now()).observe,
|
|
@@ -138202,7 +138328,7 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
138202
138328
|
// src/statusline/commands.ts
|
|
138203
138329
|
var import_node_child_process9 = require("node:child_process");
|
|
138204
138330
|
var import_node_os13 = __toESM(require("node:os"), 1);
|
|
138205
|
-
var
|
|
138331
|
+
var import_node_path62 = __toESM(require("node:path"), 1);
|
|
138206
138332
|
init_commandDeps();
|
|
138207
138333
|
init_statusline();
|
|
138208
138334
|
init_providersStore();
|
|
@@ -138211,13 +138337,13 @@ init_account();
|
|
|
138211
138337
|
init_read();
|
|
138212
138338
|
|
|
138213
138339
|
// src/statusline/client.ts
|
|
138214
|
-
var
|
|
138340
|
+
var import_node_path55 = __toESM(require("node:path"), 1);
|
|
138215
138341
|
function isAntigravityPayload(payload) {
|
|
138216
138342
|
return typeof payload === "object" && payload !== null && "product" in payload && payload.product === "antigravity";
|
|
138217
138343
|
}
|
|
138218
138344
|
var ANTIGRAVITY_SETTINGS_SEGMENTS = [".gemini", "antigravity-cli", "settings.json"];
|
|
138219
138345
|
function antigravityStacksWithDefault(fs31, homeDir) {
|
|
138220
|
-
const raw = fs31.readFileUtf8(
|
|
138346
|
+
const raw = fs31.readFileUtf8(import_node_path55.default.join(homeDir, ...ANTIGRAVITY_SETTINGS_SEGMENTS));
|
|
138221
138347
|
if (raw === void 0) {
|
|
138222
138348
|
return false;
|
|
138223
138349
|
}
|
|
@@ -138647,7 +138773,7 @@ function viewOf(payload) {
|
|
|
138647
138773
|
init_blockingSpawn();
|
|
138648
138774
|
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
138649
138775
|
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
138650
|
-
var
|
|
138776
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
138651
138777
|
|
|
138652
138778
|
// src/statusline/memoryUse.ts
|
|
138653
138779
|
var BYTES_PER_KIBIBYTE = 1024;
|
|
@@ -138686,14 +138812,78 @@ function memoryUseFromMeminfo(text5) {
|
|
|
138686
138812
|
|
|
138687
138813
|
// src/statusline/ports.ts
|
|
138688
138814
|
var RUN_TIMEOUT_MS = 2e3;
|
|
138689
|
-
var
|
|
138690
|
-
|
|
138815
|
+
var STATE_FILE_MODE = 384;
|
|
138816
|
+
var STATE_DIRECTORY_MODE = 448;
|
|
138817
|
+
var RUN_MAX_OUTPUT_BYTES = 1048576;
|
|
138818
|
+
var ULIMIT_BLOCK_BYTES = 512;
|
|
138819
|
+
var RUN_DIRECTORY_PREFIX = "agent-shim-run-";
|
|
138820
|
+
var RUN_DIRECTORY = "run";
|
|
138821
|
+
var RUN_FILE_MODE = 384;
|
|
138822
|
+
var STALE_AFTER_TIMEOUTS = 10;
|
|
138823
|
+
var STALE_RUN_DIRECTORY_MS = RUN_TIMEOUT_MS * STALE_AFTER_TIMEOUTS;
|
|
138824
|
+
function fileSizeLimitedCommand(shell, file2, args) {
|
|
138825
|
+
return { command: shell, args: ["-c", `ulimit -f ${String(RUN_MAX_OUTPUT_BYTES / ULIMIT_BLOCK_BYTES)}; exec "$0" "$@"`, file2, ...args] };
|
|
138826
|
+
}
|
|
138827
|
+
function readOutput(descriptor) {
|
|
138828
|
+
const { size } = import_node_fs23.default.fstatSync(descriptor);
|
|
138829
|
+
if (size >= RUN_MAX_OUTPUT_BYTES) {
|
|
138830
|
+
return void 0;
|
|
138831
|
+
}
|
|
138832
|
+
const buffer2 = Buffer.alloc(size);
|
|
138833
|
+
const read = import_node_fs23.default.readSync(descriptor, buffer2, 0, size, 0);
|
|
138834
|
+
return buffer2.toString("utf8", 0, read);
|
|
138835
|
+
}
|
|
138836
|
+
function sweepStaleRunDirectories(root) {
|
|
138837
|
+
let names;
|
|
138691
138838
|
try {
|
|
138692
|
-
|
|
138839
|
+
names = import_node_fs23.default.readdirSync(root);
|
|
138840
|
+
} catch {
|
|
138841
|
+
return;
|
|
138842
|
+
}
|
|
138843
|
+
for (const name of names.filter((entry) => entry.startsWith(RUN_DIRECTORY_PREFIX))) {
|
|
138844
|
+
const directory = import_node_path56.default.join(root, name);
|
|
138845
|
+
try {
|
|
138846
|
+
if (Date.now() - import_node_fs23.default.lstatSync(directory).mtimeMs > STALE_RUN_DIRECTORY_MS) {
|
|
138847
|
+
discard(directory);
|
|
138848
|
+
}
|
|
138849
|
+
} catch {
|
|
138850
|
+
continue;
|
|
138851
|
+
}
|
|
138852
|
+
}
|
|
138853
|
+
}
|
|
138854
|
+
function runProgram(runRoot, file2, args, cwd, options = {}) {
|
|
138855
|
+
return options.outputInFile === true ? runWithOutputInFile(runRoot, file2, args, cwd) : runWithPipe(file2, args, cwd);
|
|
138856
|
+
}
|
|
138857
|
+
function runWithPipe(file2, args, cwd) {
|
|
138858
|
+
try {
|
|
138859
|
+
const result = spawnSyncBlocking("a statusline command", file2, args, { cwd, encoding: "utf8", timeout: RUN_TIMEOUT_MS, killSignal: "SIGKILL", maxBuffer: RUN_MAX_OUTPUT_BYTES, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
138860
|
+
return result.error === void 0 && result.status === 0 ? result.stdout : void 0;
|
|
138693
138861
|
} catch {
|
|
138694
138862
|
return void 0;
|
|
138695
138863
|
}
|
|
138696
138864
|
}
|
|
138865
|
+
function runWithOutputInFile(runRoot, file2, args, cwd) {
|
|
138866
|
+
let directory;
|
|
138867
|
+
try {
|
|
138868
|
+
sweepStaleRunDirectories(runRoot);
|
|
138869
|
+
import_node_fs23.default.mkdirSync(runRoot, { recursive: true, mode: STATE_DIRECTORY_MODE });
|
|
138870
|
+
directory = import_node_fs23.default.mkdtempSync(import_node_path56.default.join(runRoot, RUN_DIRECTORY_PREFIX));
|
|
138871
|
+
const descriptor = import_node_fs23.default.openSync(import_node_path56.default.join(directory, "stdout"), "wx+", RUN_FILE_MODE);
|
|
138872
|
+
try {
|
|
138873
|
+
const limited = process.platform === "win32" ? { command: file2, args } : fileSizeLimitedCommand("/bin/sh", file2, args);
|
|
138874
|
+
const result = spawnSyncBlocking("a statusline command", limited.command, limited.args, { cwd, timeout: RUN_TIMEOUT_MS, killSignal: "SIGKILL", stdio: ["ignore", descriptor, "ignore"], windowsHide: true });
|
|
138875
|
+
return result.error === void 0 && result.status === 0 ? readOutput(descriptor) : void 0;
|
|
138876
|
+
} finally {
|
|
138877
|
+
import_node_fs23.default.closeSync(descriptor);
|
|
138878
|
+
}
|
|
138879
|
+
} catch {
|
|
138880
|
+
return void 0;
|
|
138881
|
+
} finally {
|
|
138882
|
+
if (directory !== void 0) {
|
|
138883
|
+
discard(directory);
|
|
138884
|
+
}
|
|
138885
|
+
}
|
|
138886
|
+
}
|
|
138697
138887
|
function readText(file2) {
|
|
138698
138888
|
try {
|
|
138699
138889
|
return import_node_fs23.default.readFileSync(file2, "utf8");
|
|
@@ -138701,8 +138891,6 @@ function readText(file2) {
|
|
|
138701
138891
|
return void 0;
|
|
138702
138892
|
}
|
|
138703
138893
|
}
|
|
138704
|
-
var STATE_FILE_MODE = 384;
|
|
138705
|
-
var STATE_DIRECTORY_MODE = 448;
|
|
138706
138894
|
function discard(target) {
|
|
138707
138895
|
try {
|
|
138708
138896
|
import_node_fs23.default.rmSync(target, { force: true, recursive: true });
|
|
@@ -138713,7 +138901,7 @@ function discard(target) {
|
|
|
138713
138901
|
function readMemoryUse() {
|
|
138714
138902
|
const totalBytes = import_node_os12.default.totalmem();
|
|
138715
138903
|
if (process.platform === "darwin") {
|
|
138716
|
-
const output2 =
|
|
138904
|
+
const output2 = runWithPipe("/usr/bin/vm_stat", [], process.cwd());
|
|
138717
138905
|
const usedBytes = output2 === void 0 ? void 0 : usedBytesFromVmStat(output2);
|
|
138718
138906
|
return usedBytes === void 0 ? void 0 : { usedBytes, totalBytes };
|
|
138719
138907
|
}
|
|
@@ -138746,7 +138934,7 @@ function realStatuslinePorts(env, stateDirectory) {
|
|
|
138746
138934
|
return void 0;
|
|
138747
138935
|
}
|
|
138748
138936
|
},
|
|
138749
|
-
run: runProgram,
|
|
138937
|
+
run: (file2, args, cwd, options) => runProgram(import_node_path56.default.join(stateDirectory, RUN_DIRECTORY), file2, args, cwd, options),
|
|
138750
138938
|
entryKind: (target) => {
|
|
138751
138939
|
try {
|
|
138752
138940
|
return import_node_fs23.default.lstatSync(target).isDirectory() ? "directory" : "other";
|
|
@@ -138776,9 +138964,9 @@ function realStatuslinePorts(env, stateDirectory) {
|
|
|
138776
138964
|
}
|
|
138777
138965
|
},
|
|
138778
138966
|
writeText: (target, text5) => {
|
|
138779
|
-
const temporary =
|
|
138967
|
+
const temporary = import_node_path56.default.join(import_node_path56.default.dirname(target), `.${import_node_path56.default.basename(target)}.${String(process.pid)}.tmp`);
|
|
138780
138968
|
try {
|
|
138781
|
-
import_node_fs23.default.mkdirSync(
|
|
138969
|
+
import_node_fs23.default.mkdirSync(import_node_path56.default.dirname(target), { recursive: true, mode: STATE_DIRECTORY_MODE });
|
|
138782
138970
|
import_node_fs23.default.writeFileSync(temporary, text5, { mode: STATE_FILE_MODE });
|
|
138783
138971
|
import_node_fs23.default.renameSync(temporary, target);
|
|
138784
138972
|
} catch {
|
|
@@ -138916,25 +139104,110 @@ function truncateWithEllipsis(text5, columns, ellipsis) {
|
|
|
138916
139104
|
init_blank();
|
|
138917
139105
|
init_graphemes();
|
|
138918
139106
|
var ESCAPE_SEQUENCES = new RegExp(ESCAPE_SEQUENCE_PATTERN, "g");
|
|
139107
|
+
function stripEscapeSequences(text5) {
|
|
139108
|
+
return text5.replace(ESCAPE_SEQUENCES, "");
|
|
139109
|
+
}
|
|
138919
139110
|
var CONTROL_AND_BIDI = /[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u206a-\u206f]/gu;
|
|
138920
139111
|
function sanitiseDisplayText(text5) {
|
|
138921
|
-
return text5
|
|
139112
|
+
return stripEscapeSequences(text5).replace(CONTROL_AND_BIDI, "");
|
|
138922
139113
|
}
|
|
138923
139114
|
function boundedDisplayText(text5) {
|
|
138924
|
-
return
|
|
139115
|
+
return leadingGraphemes(sanitiseDisplayText(text5).trim(), MAX_DISPLAY_TEXT_CHARS).join("").trim();
|
|
138925
139116
|
}
|
|
138926
139117
|
var TAG_SEQUENCE2 = "\\u{1F3F4}[\\u{E0020}-\\u{E007E}]+\\u{E007F}";
|
|
138927
139118
|
var INVISIBLE_FORMAT = new RegExp(`(${TAG_SEQUENCE2})|(?![\\u200C\\u200D])\\p{Cf}`, "gu");
|
|
138928
139119
|
var LINE_SEPARATORS = /[\u2028\u2029]/gu;
|
|
138929
139120
|
var HANGUL_JAMO = "\\u1100-\\u115E\\u1161-\\u11FF\\uA960-\\uA97F\\uD7B0-\\uD7FF";
|
|
138930
139121
|
var STANDALONE_HANGUL_FILLER = new RegExp(`(?<![${HANGUL_JAMO}])[\\u115F\\u1160](?![${HANGUL_JAMO}])`, "gu");
|
|
138931
|
-
|
|
138932
|
-
|
|
138933
|
-
|
|
139122
|
+
var PREPEND_LETTERS = "\\u0D4E\\u{111C2}\\u{111C3}\\u{113D1}\\u{1193F}\\u{11941}\\u{11A84}-\\u{11A89}\\u{11D46}\\u{11F02}";
|
|
139123
|
+
var SPACE_WITH_ATTACHMENTS = new RegExp(`(?<![${PREPEND_LETTERS}]) (?=([\\p{Mn}\\p{Me}\\u200c\\u200d]+))\\1(?![\\p{Mc}\\p{Grapheme_Extend}\\p{Emoji_Modifier}\\u0e33\\u0eb3])`, "gu");
|
|
139124
|
+
function shortenBlankRuns(text5, cap) {
|
|
139125
|
+
return text5.replace(SPACE_WITH_ATTACHMENTS, " ").replace(/ +/gu, (run) => run.length > cap ? " ".repeat(cap) : run);
|
|
139126
|
+
}
|
|
139127
|
+
function visibleDisplayText(text5, limit = Number.POSITIVE_INFINITY) {
|
|
139128
|
+
const cleaned = sanitiseDisplayText(text5).replace(LINE_SEPARATORS, "").replace(BLANK_CELLS_BUT_SPACE, " ").replace(STANDALONE_HANGUL_FILLER, " ").replace(INVISIBLE_FORMAT, (_match, tagSequence) => tagSequence ?? "");
|
|
139129
|
+
const kept = [];
|
|
139130
|
+
for (const grapheme of graphemeStream(Number.isFinite(limit) ? shortenBlankRuns(cleaned, limit + 1) : cleaned)) {
|
|
138934
139131
|
const body = grapheme.replace(/^ /u, "");
|
|
138935
139132
|
const space = body === grapheme ? "" : " ";
|
|
138936
|
-
|
|
138937
|
-
|
|
139133
|
+
const drawn = drawsNothing(body) ? space : grapheme;
|
|
139134
|
+
if (drawn === "") {
|
|
139135
|
+
continue;
|
|
139136
|
+
}
|
|
139137
|
+
kept.push(drawn);
|
|
139138
|
+
if (drawn.trim() !== "" && kept.length > limit && graphemesOf(kept.join("").trimStart()).length > limit) {
|
|
139139
|
+
break;
|
|
139140
|
+
}
|
|
139141
|
+
}
|
|
139142
|
+
return kept.join("").trim();
|
|
139143
|
+
}
|
|
139144
|
+
var NOT_SEPARATOR = /[^\t-\r\u0085\u2028\u2029]/gu;
|
|
139145
|
+
var SEPARATOR2 = /[\t-\r\u0085\u2028\u2029]/gu;
|
|
139146
|
+
var COULD_SHOW = /[^\p{Cf}\p{Cc}\p{Cs}\p{Zs}\p{Zl}\p{Zp}\p{Mn}\p{Me}\p{Default_Ignorable_Code_Point}\u2800]/u;
|
|
139147
|
+
var LONE_HIGH_SURROGATE = /[\uD800-\uDBFF]/gu;
|
|
139148
|
+
var LONE_LOW_SURROGATE = /[\uDC00-\uDFFF]/gy;
|
|
139149
|
+
var NOT_REMOVED_BY_CLEANING = new RegExp("[^[\\p{Cc}\\p{Cf}\\u2028\\u2029]--[\\u200c\\u200d]]", "gv");
|
|
139150
|
+
function joinsSurrogates(text5) {
|
|
139151
|
+
LONE_HIGH_SURROGATE.lastIndex = 0;
|
|
139152
|
+
for (let high = LONE_HIGH_SURROGATE.exec(text5); high !== null; high = LONE_HIGH_SURROGATE.exec(text5)) {
|
|
139153
|
+
NOT_REMOVED_BY_CLEANING.lastIndex = high.index + 1;
|
|
139154
|
+
const next = NOT_REMOVED_BY_CLEANING.exec(text5);
|
|
139155
|
+
if (next === null) {
|
|
139156
|
+
return false;
|
|
139157
|
+
}
|
|
139158
|
+
LONE_LOW_SURROGATE.lastIndex = next.index;
|
|
139159
|
+
if (LONE_LOW_SURROGATE.test(text5)) {
|
|
139160
|
+
return true;
|
|
139161
|
+
}
|
|
139162
|
+
}
|
|
139163
|
+
return false;
|
|
139164
|
+
}
|
|
139165
|
+
function couldShowSomething(text5) {
|
|
139166
|
+
return COULD_SHOW.test(text5) || joinsSurrogates(text5);
|
|
139167
|
+
}
|
|
139168
|
+
function* piecesOf(text5) {
|
|
139169
|
+
let from = 0;
|
|
139170
|
+
for (; ; ) {
|
|
139171
|
+
NOT_SEPARATOR.lastIndex = from;
|
|
139172
|
+
const begins = NOT_SEPARATOR.exec(text5);
|
|
139173
|
+
if (begins === null) {
|
|
139174
|
+
return;
|
|
139175
|
+
}
|
|
139176
|
+
SEPARATOR2.lastIndex = begins.index;
|
|
139177
|
+
const ends = SEPARATOR2.exec(text5);
|
|
139178
|
+
if (ends === null) {
|
|
139179
|
+
yield text5.slice(begins.index);
|
|
139180
|
+
return;
|
|
139181
|
+
}
|
|
139182
|
+
yield text5.slice(begins.index, ends.index);
|
|
139183
|
+
from = SEPARATOR2.lastIndex;
|
|
139184
|
+
}
|
|
139185
|
+
}
|
|
139186
|
+
function visibleWords(text5, limit = Number.POSITIVE_INFINITY, clean = visibleDisplayText) {
|
|
139187
|
+
const words = [];
|
|
139188
|
+
let used = 0;
|
|
139189
|
+
let last = "";
|
|
139190
|
+
for (const piece of piecesOf(stripEscapeSequences(text5))) {
|
|
139191
|
+
if (used > limit) {
|
|
139192
|
+
break;
|
|
139193
|
+
}
|
|
139194
|
+
if (!couldShowSomething(piece)) {
|
|
139195
|
+
continue;
|
|
139196
|
+
}
|
|
139197
|
+
const word = clean(piece, limit - used + 1);
|
|
139198
|
+
if (word !== "") {
|
|
139199
|
+
if (Number.isFinite(limit)) {
|
|
139200
|
+
const joinedEnd = graphemesOf(`${last}${words.length > 0 ? " " : ""}${word}`);
|
|
139201
|
+
used += joinedEnd.length - (words.length > 0 ? 1 : 0);
|
|
139202
|
+
last = joinedEnd[joinedEnd.length - 1] ?? "";
|
|
139203
|
+
}
|
|
139204
|
+
words.push(word);
|
|
139205
|
+
}
|
|
139206
|
+
}
|
|
139207
|
+
return words.join(" ");
|
|
139208
|
+
}
|
|
139209
|
+
function boundedVisibleWords(text5, clean = visibleDisplayText) {
|
|
139210
|
+
return boundedDisplayText(visibleWords(text5, MAX_DISPLAY_TEXT_CHARS, clean));
|
|
138938
139211
|
}
|
|
138939
139212
|
|
|
138940
139213
|
// src/statusline/elements/header/advisor.ts
|
|
@@ -138995,8 +139268,57 @@ function effortSegment({ payload, settings: settings2, t: t10 }) {
|
|
|
138995
139268
|
return level === void 0 ? void 0 : formatEffort(level, settings2.effort.format, t10);
|
|
138996
139269
|
}
|
|
138997
139270
|
|
|
139271
|
+
// src/statusline/elements/header/extra.ts
|
|
139272
|
+
init_zod();
|
|
139273
|
+
var LabelObjectSchema = external_exports.looseObject({ label: external_exports.string() });
|
|
139274
|
+
function* linesOf(text5) {
|
|
139275
|
+
let start = 0;
|
|
139276
|
+
for (; ; ) {
|
|
139277
|
+
const end = text5.indexOf("\n", start);
|
|
139278
|
+
if (end === -1) {
|
|
139279
|
+
yield text5.slice(start);
|
|
139280
|
+
return;
|
|
139281
|
+
}
|
|
139282
|
+
yield text5.slice(start, end);
|
|
139283
|
+
start = end + 1;
|
|
139284
|
+
}
|
|
139285
|
+
}
|
|
139286
|
+
var BYTE_ORDER_MARK = /^\uFEFF/u;
|
|
139287
|
+
function labelOf2(output2) {
|
|
139288
|
+
const text5 = stripEscapeSequences(output2).replace(BYTE_ORDER_MARK, "");
|
|
139289
|
+
let parsed;
|
|
139290
|
+
try {
|
|
139291
|
+
parsed = JSON.parse(text5);
|
|
139292
|
+
} catch {
|
|
139293
|
+
parsed = void 0;
|
|
139294
|
+
}
|
|
139295
|
+
const object3 = LabelObjectSchema.safeParse(parsed);
|
|
139296
|
+
if (object3.success) {
|
|
139297
|
+
return boundedVisibleWords(object3.data.label);
|
|
139298
|
+
}
|
|
139299
|
+
for (const line of linesOf(text5)) {
|
|
139300
|
+
const label2 = couldShowSomething(line) ? boundedVisibleWords(line) : "";
|
|
139301
|
+
if (label2 !== "") {
|
|
139302
|
+
return label2;
|
|
139303
|
+
}
|
|
139304
|
+
}
|
|
139305
|
+
return "";
|
|
139306
|
+
}
|
|
139307
|
+
function extraSegment({ settings: settings2, payload, ports }) {
|
|
139308
|
+
const [program2, ...args] = settings2.extra.command;
|
|
139309
|
+
if (program2 === void 0) {
|
|
139310
|
+
return void 0;
|
|
139311
|
+
}
|
|
139312
|
+
const output2 = ports.run(program2, args, payload.cwd ?? payload.workspace?.current_dir ?? ports.homeDirectory, { outputInFile: true });
|
|
139313
|
+
if (output2 === void 0) {
|
|
139314
|
+
return void 0;
|
|
139315
|
+
}
|
|
139316
|
+
const label2 = labelOf2(output2);
|
|
139317
|
+
return label2 === "" ? void 0 : label2;
|
|
139318
|
+
}
|
|
139319
|
+
|
|
138998
139320
|
// src/statusline/dailyLedger.ts
|
|
138999
|
-
var
|
|
139321
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
139000
139322
|
init_zod();
|
|
139001
139323
|
init_schema2();
|
|
139002
139324
|
var DAILY_LEDGER_DIRECTORY = "daily-cost";
|
|
@@ -139040,19 +139362,19 @@ function advance(existing, carried, cost, nowMs) {
|
|
|
139040
139362
|
return { entry: existing, changed: false };
|
|
139041
139363
|
}
|
|
139042
139364
|
function recordDailySpend(ports, nowMs, sessionId, cost) {
|
|
139043
|
-
const root =
|
|
139365
|
+
const root = import_node_path57.default.join(ports.stateDirectory, DAILY_LEDGER_DIRECTORY);
|
|
139044
139366
|
const today = localDay(nowMs);
|
|
139045
139367
|
const days = (ports.listDirectory(root) ?? []).filter((name) => DAY_NAME.test(name));
|
|
139046
139368
|
const previous = days.filter((day) => day < today).sort().at(-1);
|
|
139047
139369
|
for (const day of days) {
|
|
139048
139370
|
if (day < today && day !== previous) {
|
|
139049
|
-
ports.removePath(
|
|
139371
|
+
ports.removePath(import_node_path57.default.join(root, day));
|
|
139050
139372
|
}
|
|
139051
139373
|
}
|
|
139052
|
-
const todayDirectory =
|
|
139374
|
+
const todayDirectory = import_node_path57.default.join(root, today);
|
|
139053
139375
|
if (sessionId !== void 0 && cost !== void 0 && CLIENT_SESSION_ID_PATTERN.test(sessionId)) {
|
|
139054
|
-
const file2 =
|
|
139055
|
-
const carried = previous === void 0 ? void 0 : parseEntry3(ports.readText(
|
|
139376
|
+
const file2 = import_node_path57.default.join(todayDirectory, `${sessionId}.json`);
|
|
139377
|
+
const carried = previous === void 0 ? void 0 : parseEntry3(ports.readText(import_node_path57.default.join(root, previous, `${sessionId}.json`)));
|
|
139056
139378
|
const next = advance(parseEntry3(ports.readText(file2)), carried, cost, nowMs);
|
|
139057
139379
|
if (next?.changed === true) {
|
|
139058
139380
|
ports.writeText(file2, `${JSON.stringify(next.entry)}
|
|
@@ -139060,7 +139382,7 @@ function recordDailySpend(ports, nowMs, sessionId, cost) {
|
|
|
139060
139382
|
}
|
|
139061
139383
|
}
|
|
139062
139384
|
const entries = (ports.listDirectory(todayDirectory) ?? []).filter((name) => ENTRY_FILE.test(name)).flatMap((name) => {
|
|
139063
|
-
const entry = parseEntry3(ports.readText(
|
|
139385
|
+
const entry = parseEntry3(ports.readText(import_node_path57.default.join(todayDirectory, name)));
|
|
139064
139386
|
return entry === void 0 ? [] : [entry];
|
|
139065
139387
|
});
|
|
139066
139388
|
return entries.length === 0 ? void 0 : entries.reduce((sum2, entry) => sum2 + (entry.totalUsd - entry.baselineUsd), 0);
|
|
@@ -139337,7 +139659,7 @@ function modelSegment(context) {
|
|
|
139337
139659
|
}
|
|
139338
139660
|
|
|
139339
139661
|
// src/statusline/elements/header/outputStyle.ts
|
|
139340
|
-
var
|
|
139662
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
139341
139663
|
init_zod();
|
|
139342
139664
|
var SettingsFileSchema = external_exports.looseObject({ outputStyle: external_exports.string().optional().catch(void 0) });
|
|
139343
139665
|
function outputStyleIn(file2, readText2) {
|
|
@@ -139357,12 +139679,12 @@ function outputStyleIn(file2, readText2) {
|
|
|
139357
139679
|
}
|
|
139358
139680
|
function outputStyleSegment({ payload, ports, t: t10 }) {
|
|
139359
139681
|
const pinned = ports.env.CLAUDE_CONFIG_DIR;
|
|
139360
|
-
const configDirectory = pinned === void 0 || pinned === "" ?
|
|
139682
|
+
const configDirectory = pinned === void 0 || pinned === "" ? import_node_path58.default.join(ports.homeDirectory, ".claude") : pinned;
|
|
139361
139683
|
const projectDirectory = payload.cwd ?? payload.workspace?.current_dir;
|
|
139362
139684
|
const files = [
|
|
139363
|
-
|
|
139364
|
-
|
|
139365
|
-
...projectDirectory === void 0 ? [] : [
|
|
139685
|
+
import_node_path58.default.join(configDirectory, "settings.json"),
|
|
139686
|
+
import_node_path58.default.join(configDirectory, "settings.local.json"),
|
|
139687
|
+
...projectDirectory === void 0 ? [] : [import_node_path58.default.join(projectDirectory, ".claude", "settings.json"), import_node_path58.default.join(projectDirectory, ".claude", "settings.local.json")]
|
|
139366
139688
|
];
|
|
139367
139689
|
const style = files.map((file2) => outputStyleIn(file2, ports.readText)).findLast((name) => name !== void 0);
|
|
139368
139690
|
return style === void 0 ? void 0 : t10("outputStyle.name", { name: style });
|
|
@@ -139452,13 +139774,13 @@ init_zod();
|
|
|
139452
139774
|
|
|
139453
139775
|
// src/statusline/cacheFile.ts
|
|
139454
139776
|
var import_node_crypto26 = require("node:crypto");
|
|
139455
|
-
var
|
|
139777
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
139456
139778
|
var SESSION_CACHE_DIRECTORY = "session";
|
|
139457
139779
|
function cacheDirectory(ports) {
|
|
139458
|
-
return
|
|
139780
|
+
return import_node_path59.default.join(ports.stateDirectory, SESSION_CACHE_DIRECTORY);
|
|
139459
139781
|
}
|
|
139460
139782
|
function cacheFileFor(ports, kind, transcriptPath) {
|
|
139461
|
-
return
|
|
139783
|
+
return import_node_path59.default.join(cacheDirectory(ports), `${kind}-${(0, import_node_crypto26.createHash)("sha256").update(transcriptPath).digest("hex")}.json`);
|
|
139462
139784
|
}
|
|
139463
139785
|
var RETENTION_DAYS = 30;
|
|
139464
139786
|
var HOURS_PER_DAY10 = 24;
|
|
@@ -139473,7 +139795,7 @@ function pruneCache(ports, cutoffMs) {
|
|
|
139473
139795
|
return;
|
|
139474
139796
|
}
|
|
139475
139797
|
for (const name of names) {
|
|
139476
|
-
const file2 =
|
|
139798
|
+
const file2 = import_node_path59.default.join(directory, name);
|
|
139477
139799
|
const modifiedAtMs = ports.modifiedAtMs(file2);
|
|
139478
139800
|
if (modifiedAtMs !== void 0 && modifiedAtMs < cutoffMs) {
|
|
139479
139801
|
ports.removePath(file2);
|
|
@@ -139628,15 +139950,15 @@ function parseNumstat(output2) {
|
|
|
139628
139950
|
if (addedText === void 0 || deletedText === void 0 || pathText === void 0) {
|
|
139629
139951
|
continue;
|
|
139630
139952
|
}
|
|
139631
|
-
const
|
|
139953
|
+
const path72 = pathText === "" ? fields[index + 2] : pathText;
|
|
139632
139954
|
if (pathText === "") {
|
|
139633
139955
|
index += 2;
|
|
139634
139956
|
}
|
|
139635
139957
|
const lines = { added: Number(addedText), deleted: Number(deletedText) };
|
|
139636
|
-
if (
|
|
139958
|
+
if (path72 !== void 0 && Number.isInteger(lines.added) && Number.isInteger(lines.deleted)) {
|
|
139637
139959
|
added += lines.added;
|
|
139638
139960
|
deleted += lines.deleted;
|
|
139639
|
-
byPath.set(
|
|
139961
|
+
byPath.set(path72, lines);
|
|
139640
139962
|
}
|
|
139641
139963
|
}
|
|
139642
139964
|
return { total: { added, deleted }, byPath };
|
|
@@ -139692,7 +140014,7 @@ function readGitStatus(ports, cwd, query) {
|
|
|
139692
140014
|
}
|
|
139693
140015
|
|
|
139694
140016
|
// src/statusline/vcs/jj.ts
|
|
139695
|
-
var
|
|
140017
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
139696
140018
|
var JJ2 = "jj";
|
|
139697
140019
|
var MAX_WALK_DEPTH = 64;
|
|
139698
140020
|
var MAX_LABEL_CODE_POINTS = 64;
|
|
@@ -139705,13 +140027,13 @@ function isJjRepository(ports, cwd) {
|
|
|
139705
140027
|
return false;
|
|
139706
140028
|
}
|
|
139707
140029
|
for (let depth = 0; depth < MAX_WALK_DEPTH; depth += 1) {
|
|
139708
|
-
if (ports.entryKind(
|
|
140030
|
+
if (ports.entryKind(import_node_path60.default.join(directory, ".jj")) === "directory") {
|
|
139709
140031
|
return true;
|
|
139710
140032
|
}
|
|
139711
|
-
if (ports.entryKind(
|
|
140033
|
+
if (ports.entryKind(import_node_path60.default.join(directory, ".git")) !== void 0) {
|
|
139712
140034
|
return false;
|
|
139713
140035
|
}
|
|
139714
|
-
const parent =
|
|
140036
|
+
const parent = import_node_path60.default.dirname(directory);
|
|
139715
140037
|
if (parent === directory) {
|
|
139716
140038
|
return false;
|
|
139717
140039
|
}
|
|
@@ -139872,7 +140194,7 @@ function addedDirsRow({ payload, settings: settings2, palette, t: t10 }) {
|
|
|
139872
140194
|
}
|
|
139873
140195
|
|
|
139874
140196
|
// src/statusline/headerLayout.ts
|
|
139875
|
-
var
|
|
140197
|
+
var SEPARATOR3 = " | ";
|
|
139876
140198
|
function headerUnits(parts, overflow) {
|
|
139877
140199
|
const units = [];
|
|
139878
140200
|
parts.forEach((part, index) => {
|
|
@@ -140174,7 +140496,7 @@ function gitFilesRow(context) {
|
|
|
140174
140496
|
}
|
|
140175
140497
|
|
|
140176
140498
|
// src/statusline/configCounts.ts
|
|
140177
|
-
var
|
|
140499
|
+
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
140178
140500
|
init_zod();
|
|
140179
140501
|
var nameList = external_exports.array(external_exports.unknown()).catch([]).transform((items) => items.filter((item) => typeof item === "string"));
|
|
140180
140502
|
var ConfigFileSchema = external_exports.looseObject({
|
|
@@ -140248,7 +140570,7 @@ function countRules(ports, root) {
|
|
|
140248
140570
|
break;
|
|
140249
140571
|
}
|
|
140250
140572
|
entries += 1;
|
|
140251
|
-
const entry =
|
|
140573
|
+
const entry = import_node_path61.default.join(real, name);
|
|
140252
140574
|
const kind = followedKind(ports, entry);
|
|
140253
140575
|
if (kind === "directory") {
|
|
140254
140576
|
count2 += walk3(entry);
|
|
@@ -140265,33 +140587,33 @@ function countRules(ports, root) {
|
|
|
140265
140587
|
return walk3(root);
|
|
140266
140588
|
}
|
|
140267
140589
|
function sameLocation(ports, left, right) {
|
|
140268
|
-
return (ports.realPath(left) ??
|
|
140590
|
+
return (ports.realPath(left) ?? import_node_path61.default.resolve(left)) === (ports.realPath(right) ?? import_node_path61.default.resolve(right));
|
|
140269
140591
|
}
|
|
140270
140592
|
function configDirectoryOf(ports) {
|
|
140271
140593
|
const pinned = ports.env.CLAUDE_CONFIG_DIR;
|
|
140272
|
-
return pinned === void 0 || pinned === "" ?
|
|
140594
|
+
return pinned === void 0 || pinned === "" ? import_node_path61.default.join(ports.homeDirectory, ".claude") : pinned;
|
|
140273
140595
|
}
|
|
140274
140596
|
function countConfiguration(ports, projectDirectory) {
|
|
140275
140597
|
const userDirectory = configDirectoryOf(ports);
|
|
140276
|
-
const userSettings = readConfigFile(ports,
|
|
140277
|
-
const globalFile = ports.env.CLAUDE_CONFIG_DIR === void 0 || ports.env.CLAUDE_CONFIG_DIR === "" ?
|
|
140598
|
+
const userSettings = readConfigFile(ports, import_node_path61.default.join(userDirectory, "settings.json"));
|
|
140599
|
+
const globalFile = ports.env.CLAUDE_CONFIG_DIR === void 0 || ports.env.CLAUDE_CONFIG_DIR === "" ? import_node_path61.default.join(ports.homeDirectory, ".claude.json") : import_node_path61.default.join(userDirectory, ".claude.json");
|
|
140278
140600
|
const global2 = readConfigFile(ports, globalFile);
|
|
140279
140601
|
const userServers = /* @__PURE__ */ new Set([...namesOf(userSettings), ...namesOf(global2)]);
|
|
140280
140602
|
removeNames(userServers, global2?.disabledMcpServers);
|
|
140281
140603
|
const projectServers = /* @__PURE__ */ new Set();
|
|
140282
|
-
let claudeMd = isFile(ports,
|
|
140283
|
-
let rules = countRules(ports,
|
|
140604
|
+
let claudeMd = isFile(ports, import_node_path61.default.join(userDirectory, "CLAUDE.md")) ? 1 : 0;
|
|
140605
|
+
let rules = countRules(ports, import_node_path61.default.join(userDirectory, "rules"));
|
|
140284
140606
|
let hookEvents = hookEventsOf(userSettings);
|
|
140285
140607
|
if (projectDirectory !== void 0) {
|
|
140286
|
-
const projectClaude =
|
|
140608
|
+
const projectClaude = import_node_path61.default.join(projectDirectory, ".claude");
|
|
140287
140609
|
const projectIsUser = sameLocation(ports, projectClaude, userDirectory);
|
|
140288
|
-
const claudeMdFiles = [
|
|
140610
|
+
const claudeMdFiles = [import_node_path61.default.join(projectDirectory, "CLAUDE.md"), import_node_path61.default.join(projectDirectory, "CLAUDE.local.md"), import_node_path61.default.join(projectClaude, "CLAUDE.local.md"), ...projectIsUser ? [] : [import_node_path61.default.join(projectClaude, "CLAUDE.md")]];
|
|
140289
140611
|
claudeMd += claudeMdFiles.filter((file2) => isFile(ports, file2)).length;
|
|
140290
|
-
const mcpJson = namesOf(readConfigFile(ports,
|
|
140612
|
+
const mcpJson = namesOf(readConfigFile(ports, import_node_path61.default.join(projectDirectory, ".mcp.json")));
|
|
140291
140613
|
if (!projectIsUser) {
|
|
140292
|
-
rules += countRules(ports,
|
|
140293
|
-
const settings2 = readConfigFile(ports,
|
|
140294
|
-
const local = readConfigFile(ports,
|
|
140614
|
+
rules += countRules(ports, import_node_path61.default.join(projectClaude, "rules"));
|
|
140615
|
+
const settings2 = readConfigFile(ports, import_node_path61.default.join(projectClaude, "settings.json"));
|
|
140616
|
+
const local = readConfigFile(ports, import_node_path61.default.join(projectClaude, "settings.local.json"));
|
|
140295
140617
|
hookEvents += hookEventsOf(settings2) + hookEventsOf(local);
|
|
140296
140618
|
for (const name of [...namesOf(settings2), ...namesOf(local)]) {
|
|
140297
140619
|
projectServers.add(name);
|
|
@@ -140341,7 +140663,7 @@ function environmentRow(context) {
|
|
|
140341
140663
|
(count2) => t10("environment.hooks.other", { count: count2 })
|
|
140342
140664
|
)
|
|
140343
140665
|
].filter((part) => part !== void 0);
|
|
140344
|
-
return { kind: "text", lines: packLines(parts.map((part) => palette.paint("label", part)), context.width,
|
|
140666
|
+
return { kind: "text", lines: packLines(parts.map((part) => palette.paint("label", part)), context.width, SEPARATOR3).map((line) => line.join(SEPARATOR3)) };
|
|
140345
140667
|
}
|
|
140346
140668
|
|
|
140347
140669
|
// src/statusline/elements/rows/mcp.ts
|
|
@@ -140513,7 +140835,7 @@ function parenthesised(reset) {
|
|
|
140513
140835
|
return reset === "" ? "" : `(${reset})`;
|
|
140514
140836
|
}
|
|
140515
140837
|
function wrapped(windows, width) {
|
|
140516
|
-
return packLines(windows, width,
|
|
140838
|
+
return packLines(windows, width, SEPARATOR3).map((line) => line.join(SEPARATOR3));
|
|
140517
140839
|
}
|
|
140518
140840
|
function quotaRow(context) {
|
|
140519
140841
|
const { palette, settings: settings2 } = context;
|
|
@@ -140593,11 +140915,11 @@ function targetText(tool, columns) {
|
|
|
140593
140915
|
if (!FILE_TOOLS.includes(tool.name)) {
|
|
140594
140916
|
return truncateWithEllipsis(target, room, ELLIPSIS);
|
|
140595
140917
|
}
|
|
140596
|
-
const
|
|
140597
|
-
if (visibleLength(
|
|
140598
|
-
return
|
|
140918
|
+
const path72 = target.replaceAll("\\", "/");
|
|
140919
|
+
if (visibleLength(path72) <= room) {
|
|
140920
|
+
return path72;
|
|
140599
140921
|
}
|
|
140600
|
-
const file2 =
|
|
140922
|
+
const file2 = path72.split("/").pop() ?? path72;
|
|
140601
140923
|
return visibleLength(DIRECTORY_ELLIPSIS) + visibleLength(file2) > room ? truncateWithEllipsis(file2, room, FILE_ELLIPSIS) : `${DIRECTORY_ELLIPSIS}${file2}`;
|
|
140602
140924
|
}
|
|
140603
140925
|
function finishedByKind(tools) {
|
|
@@ -140634,7 +140956,7 @@ function toolsRow(context) {
|
|
|
140634
140956
|
if (named.length < kinds.length) {
|
|
140635
140957
|
parts.push(label2(t10("more", { count: kinds.length - named.length })));
|
|
140636
140958
|
}
|
|
140637
|
-
return parts.length === 0 ? NO_LINES : { kind: "text", lines: packLines(parts.map((part) => fitToWidth(part, width)), width,
|
|
140959
|
+
return parts.length === 0 ? NO_LINES : { kind: "text", lines: packLines(parts.map((part) => fitToWidth(part, width)), width, SEPARATOR3).map((line) => line.join(SEPARATOR3)) };
|
|
140638
140960
|
}
|
|
140639
140961
|
|
|
140640
140962
|
// src/statusline/transcript/tokens.ts
|
|
@@ -140726,7 +141048,8 @@ var HEADER_ROLES = {
|
|
|
140726
141048
|
dailyCost: "label",
|
|
140727
141049
|
sessionName: "label",
|
|
140728
141050
|
duration: "label",
|
|
140729
|
-
speed: "label"
|
|
141051
|
+
speed: "label",
|
|
141052
|
+
extra: "label"
|
|
140730
141053
|
};
|
|
140731
141054
|
var ELEMENTS = {
|
|
140732
141055
|
header: {
|
|
@@ -140746,11 +141069,18 @@ var ELEMENTS = {
|
|
|
140746
141069
|
dailyCost: dailyCostSegment,
|
|
140747
141070
|
sessionName: sessionNameSegment,
|
|
140748
141071
|
duration: durationSegment,
|
|
140749
|
-
speed: speedSegment
|
|
141072
|
+
speed: speedSegment,
|
|
141073
|
+
extra: extraSegment
|
|
140750
141074
|
},
|
|
140751
141075
|
rows: { context: contextRow, quota: quotaRow, addedDirs: addedDirsRow, gitFiles: gitFilesRow, memory: memoryRow, environment: environmentRow, sessionTime: sessionTimeRow, promptCache: promptCacheRow, compactions: compactionsRow, tokens: tokensRow, tools: toolsRow, skills: skillsRow, mcp: mcpRow, agents: agentsRow, todos: todosRow }
|
|
140752
141076
|
};
|
|
140753
141077
|
|
|
141078
|
+
// src/statusline/elements/customLine.ts
|
|
141079
|
+
function customLineOf({ settings: settings2, palette, width }) {
|
|
141080
|
+
const text5 = visibleDisplayText(settings2.customLine.text);
|
|
141081
|
+
return text5 === "" ? void 0 : palette.paint("custom", truncateToColumns(text5, width));
|
|
141082
|
+
}
|
|
141083
|
+
|
|
140754
141084
|
// src/statusline/identityTranscript.ts
|
|
140755
141085
|
init_zod();
|
|
140756
141086
|
var TRANSCRIPT_CHUNK_BYTES = 65536;
|
|
@@ -141158,7 +141488,7 @@ function isEmpty(output2) {
|
|
|
141158
141488
|
}
|
|
141159
141489
|
function oneLineOf(output2, barCells) {
|
|
141160
141490
|
if (output2.kind === "bars") {
|
|
141161
|
-
return drawInline(output2.cells,
|
|
141491
|
+
return drawInline(output2.cells, SEPARATOR3, barCells);
|
|
141162
141492
|
}
|
|
141163
141493
|
return output2.lines.length === 1 ? output2.lines[0] : void 0;
|
|
141164
141494
|
}
|
|
@@ -141167,8 +141497,8 @@ function alignRight(lines, rightAlign, width) {
|
|
|
141167
141497
|
if (split < 1) {
|
|
141168
141498
|
return void 0;
|
|
141169
141499
|
}
|
|
141170
|
-
const left = lines.slice(0, split).map(({ text: text5 }) => text5).join(
|
|
141171
|
-
const right = lines.slice(split).map(({ text: text5 }) => text5).join(
|
|
141500
|
+
const left = lines.slice(0, split).map(({ text: text5 }) => text5).join(SEPARATOR3);
|
|
141501
|
+
const right = lines.slice(split).map(({ text: text5 }) => text5).join(SEPARATOR3);
|
|
141172
141502
|
return `${left}${" ".repeat(width - visibleLength(left) - visibleLength(right))}${right}`;
|
|
141173
141503
|
}
|
|
141174
141504
|
function itemOf(row) {
|
|
@@ -141183,7 +141513,7 @@ function mergedItems(rows, settings2, width) {
|
|
|
141183
141513
|
const lines = rows.map((row) => ({ name: row.name, text: oneLineOf(row.output, settings2.barCells) }));
|
|
141184
141514
|
const texts = lines.flatMap(({ name, text: text5 }) => text5 === void 0 ? [] : [{ name, text: text5 }]);
|
|
141185
141515
|
if (texts.length === rows.length) {
|
|
141186
|
-
const joined3 = texts.map(({ text: text5 }) => text5).join(
|
|
141516
|
+
const joined3 = texts.map(({ text: text5 }) => text5).join(SEPARATOR3);
|
|
141187
141517
|
if (visibleLength(joined3) <= width) {
|
|
141188
141518
|
return [{ kind: "lines", lines: [alignRight(texts, rightAlign, width) ?? joined3] }];
|
|
141189
141519
|
}
|
|
@@ -141229,7 +141559,7 @@ function layoutRows(rows, settings2, width) {
|
|
|
141229
141559
|
const lines = [];
|
|
141230
141560
|
let units = [];
|
|
141231
141561
|
const flushBars = () => {
|
|
141232
|
-
lines.push(...layoutBarGrid(units, width,
|
|
141562
|
+
lines.push(...layoutBarGrid(units, width, SEPARATOR3, settings2.barCells));
|
|
141233
141563
|
units = [];
|
|
141234
141564
|
};
|
|
141235
141565
|
for (const item of items) {
|
|
@@ -141244,7 +141574,7 @@ function layoutRows(rows, settings2, width) {
|
|
|
141244
141574
|
return lines;
|
|
141245
141575
|
}
|
|
141246
141576
|
function compactUnits(rows, barCells) {
|
|
141247
|
-
return rows.flatMap(({ output: output2 }) => output2.kind === "bars" ? output2.cells.map((cell) => drawInline([cell],
|
|
141577
|
+
return rows.flatMap(({ output: output2 }) => output2.kind === "bars" ? output2.cells.map((cell) => drawInline([cell], SEPARATOR3, barCells)) : [...output2.lines]);
|
|
141248
141578
|
}
|
|
141249
141579
|
|
|
141250
141580
|
// src/statusline/transcript/reader.ts
|
|
@@ -141770,7 +142100,7 @@ function isLive(startedAtMs, nowMs, maxMs) {
|
|
|
141770
142100
|
return startedAtMs === void 0 || nowMs - startedAtMs <= maxMs;
|
|
141771
142101
|
}
|
|
141772
142102
|
function visibleNames(set3) {
|
|
141773
|
-
const names = [...new Set(set3.names.map(visibleDisplayText).filter((name) => name !== ""))];
|
|
142103
|
+
const names = [...new Set(set3.names.map((name) => visibleDisplayText(name)).filter((name) => name !== ""))];
|
|
141774
142104
|
return { names, total: names.length + set3.others.length, exact: set3.overflowed !== true };
|
|
141775
142105
|
}
|
|
141776
142106
|
function activityFactsOf(state, nowMs, limits, newer) {
|
|
@@ -142048,6 +142378,12 @@ function ruleLine(headerLines, width, palette) {
|
|
|
142048
142378
|
const widest = Math.max(MIN_STATUSLINE_COLUMNS, ...headerLines.map(visibleLength));
|
|
142049
142379
|
return palette.paint("label", RULE_CHARACTER.repeat(Math.min(width, widest)));
|
|
142050
142380
|
}
|
|
142381
|
+
function expandedLines(header, drawn, width, palette, settings2) {
|
|
142382
|
+
const headerLines = header.length > 0 ? layoutHeader(header, width, SEPARATOR3).split("\n") : [];
|
|
142383
|
+
const rowLines = layoutRows(drawn, { mergeBars: settings2.layout.mergeBars, merge: settings2.layout.merge, rightAlign: settings2.layout.rightAlign, barCells: settings2.bar.width }, width);
|
|
142384
|
+
const rule = settings2.layout.rule === "belowHeader" && headerLines.length > 0 && rowLines.length > 0 ? [ruleLine(headerLines, width, palette)] : [];
|
|
142385
|
+
return [...headerLines, ...rule, ...rowLines];
|
|
142386
|
+
}
|
|
142051
142387
|
function renderStatuslineBlock(input2) {
|
|
142052
142388
|
const { terminalWidth, settings: settings2 = STATUSLINE_DEFAULTS, elements = ELEMENTS } = input2;
|
|
142053
142389
|
const width = input2.lineWidth ?? lineWidthOf(terminalWidth);
|
|
@@ -142074,13 +142410,12 @@ function renderStatuslineBlock(input2) {
|
|
|
142074
142410
|
});
|
|
142075
142411
|
const header = headerUnits(parts, settings2.git.branchOverflow);
|
|
142076
142412
|
const drawn = settings2.layout.rows.map((name) => ({ name, output: elements.rows[name](context) }));
|
|
142077
|
-
|
|
142078
|
-
|
|
142413
|
+
const body = settings2.layout.mode === "compact" ? packLines([...header, ...compactUnits(drawn, settings2.bar.width)], width, SEPARATOR3).map((line) => line.join(SEPARATOR3)) : expandedLines(header, drawn, width, context.palette, settings2);
|
|
142414
|
+
const custom2 = customLineOf(context);
|
|
142415
|
+
if (custom2 === void 0) {
|
|
142416
|
+
return body.join("\n");
|
|
142079
142417
|
}
|
|
142080
|
-
|
|
142081
|
-
const rowLines = layoutRows(drawn, { mergeBars: settings2.layout.mergeBars, merge: settings2.layout.merge, rightAlign: settings2.layout.rightAlign, barCells: settings2.bar.width }, width);
|
|
142082
|
-
const rule = settings2.layout.rule === "belowHeader" && headerLines.length > 0 && rowLines.length > 0 ? [ruleLine(headerLines, width, context.palette)] : [];
|
|
142083
|
-
return [...headerLines, ...rule, ...rowLines].join("\n");
|
|
142418
|
+
return (settings2.customLine.position === "first" ? [custom2, ...body] : [...body, custom2]).join("\n");
|
|
142084
142419
|
}
|
|
142085
142420
|
|
|
142086
142421
|
// src/statusline/commands.ts
|
|
@@ -142148,7 +142483,7 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
142148
142483
|
} else {
|
|
142149
142484
|
const configDir = process.env.CLAUDE_CONFIG_DIR;
|
|
142150
142485
|
try {
|
|
142151
|
-
account = readAccountMetadataFile(realFarmFs, configDir === void 0 || configDir === "" ?
|
|
142486
|
+
account = readAccountMetadataFile(realFarmFs, configDir === void 0 || configDir === "" ? import_node_path62.default.join(import_node_os13.default.homedir(), ".claude.json") : import_node_path62.default.join(configDir, ".claude.json"));
|
|
142152
142487
|
} catch {
|
|
142153
142488
|
account = void 0;
|
|
142154
142489
|
}
|
|
@@ -144250,8 +144585,8 @@ function getErrorMap2() {
|
|
|
144250
144585
|
|
|
144251
144586
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/helpers/parseUtil.js
|
|
144252
144587
|
var makeIssue = (params) => {
|
|
144253
|
-
const { data, path:
|
|
144254
|
-
const fullPath = [...
|
|
144588
|
+
const { data, path: path72, errorMaps, issueData } = params;
|
|
144589
|
+
const fullPath = [...path72, ...issueData.path || []];
|
|
144255
144590
|
const fullIssue = {
|
|
144256
144591
|
...issueData,
|
|
144257
144592
|
path: fullPath
|
|
@@ -144366,11 +144701,11 @@ var errorUtil;
|
|
|
144366
144701
|
|
|
144367
144702
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/types.js
|
|
144368
144703
|
var ParseInputLazyPath = class {
|
|
144369
|
-
constructor(parent, value2,
|
|
144704
|
+
constructor(parent, value2, path72, key) {
|
|
144370
144705
|
this._cachedPath = [];
|
|
144371
144706
|
this.parent = parent;
|
|
144372
144707
|
this.data = value2;
|
|
144373
|
-
this._path =
|
|
144708
|
+
this._path = path72;
|
|
144374
144709
|
this._key = key;
|
|
144375
144710
|
}
|
|
144376
144711
|
get path() {
|
|
@@ -147933,11 +148268,11 @@ function normalizeObjectSchema(schema) {
|
|
|
147933
148268
|
}
|
|
147934
148269
|
return void 0;
|
|
147935
148270
|
}
|
|
147936
|
-
function getDotPath(
|
|
147937
|
-
if (
|
|
148271
|
+
function getDotPath(path72) {
|
|
148272
|
+
if (path72.length === 0) {
|
|
147938
148273
|
return "object root";
|
|
147939
148274
|
}
|
|
147940
|
-
return
|
|
148275
|
+
return path72.reduce((acc, seg, index) => {
|
|
147941
148276
|
if (index === 0) {
|
|
147942
148277
|
return String(seg);
|
|
147943
148278
|
}
|
|
@@ -151980,7 +152315,7 @@ async function serveMcp(mcp, transport, options = {}) {
|
|
|
151980
152315
|
|
|
151981
152316
|
// src/mcp/permissions.ts
|
|
151982
152317
|
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
151983
|
-
var
|
|
152318
|
+
var import_node_path63 = __toESM(require("node:path"), 1);
|
|
151984
152319
|
init_zod();
|
|
151985
152320
|
init_store();
|
|
151986
152321
|
var StoredMcpPermissionsSchema = external_exports.strictObject({
|
|
@@ -152002,10 +152337,10 @@ function effectiveMcpPermissions(flags, stored2) {
|
|
|
152002
152337
|
return { writes: flags.writes || stored2.writes, remoteControl: flags.remoteControl || stored2.remoteControl, history: flags.history || stored2.history };
|
|
152003
152338
|
}
|
|
152004
152339
|
function watchMcpPermissions(paths, onChange) {
|
|
152005
|
-
const directory =
|
|
152340
|
+
const directory = import_node_path63.default.dirname(paths.mcpPermissionsFile);
|
|
152006
152341
|
import_node_fs24.default.mkdirSync(directory, { recursive: true });
|
|
152007
152342
|
const watcher = import_node_fs24.default.watch(directory, (_event, filename) => {
|
|
152008
|
-
if (filename === null || filename ===
|
|
152343
|
+
if (filename === null || filename === import_node_path63.default.basename(paths.mcpPermissionsFile)) {
|
|
152009
152344
|
onChange();
|
|
152010
152345
|
}
|
|
152011
152346
|
});
|
|
@@ -152318,16 +152653,16 @@ init_credentialCache();
|
|
|
152318
152653
|
|
|
152319
152654
|
// src/identityToken.ts
|
|
152320
152655
|
var import_node_fs25 = __toESM(require("node:fs"), 1);
|
|
152321
|
-
var
|
|
152656
|
+
var import_node_path64 = __toESM(require("node:path"), 1);
|
|
152322
152657
|
init_cliError();
|
|
152323
152658
|
var TOKEN_FILE_MODE = 384;
|
|
152324
152659
|
var TOKEN_DIR_MODE = 448;
|
|
152325
152660
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
152326
152661
|
function identityTokenDir(paths) {
|
|
152327
|
-
return
|
|
152662
|
+
return import_node_path64.default.join(paths.root, "credentials");
|
|
152328
152663
|
}
|
|
152329
152664
|
function identityTokenPath(paths, identityName) {
|
|
152330
|
-
return
|
|
152665
|
+
return import_node_path64.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
152331
152666
|
}
|
|
152332
152667
|
function storeIdentityToken(paths, identityName, raw) {
|
|
152333
152668
|
const token = raw.trim();
|
|
@@ -152338,7 +152673,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
152338
152673
|
import_node_fs25.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
152339
152674
|
import_node_fs25.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
152340
152675
|
const target = identityTokenPath(paths, identityName);
|
|
152341
|
-
const temp =
|
|
152676
|
+
const temp = import_node_path64.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
152342
152677
|
import_node_fs25.default.writeFileSync(temp, `${token}
|
|
152343
152678
|
`, { mode: TOKEN_FILE_MODE });
|
|
152344
152679
|
import_node_fs25.default.renameSync(temp, target);
|
|
@@ -152510,7 +152845,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
152510
152845
|
// src/headroom/commands.ts
|
|
152511
152846
|
var import_node_fs26 = __toESM(require("node:fs"), 1);
|
|
152512
152847
|
var import_node_http5 = __toESM(require("node:http"), 1);
|
|
152513
|
-
var
|
|
152848
|
+
var import_node_path65 = __toESM(require("node:path"), 1);
|
|
152514
152849
|
var import_node_child_process10 = require("node:child_process");
|
|
152515
152850
|
init_commandDeps();
|
|
152516
152851
|
init_configProfilesStore();
|
|
@@ -152701,12 +153036,12 @@ function readInstalledHeadroomCommit() {
|
|
|
152701
153036
|
if (toolDir.status !== 0) {
|
|
152702
153037
|
return void 0;
|
|
152703
153038
|
}
|
|
152704
|
-
const libDir =
|
|
153039
|
+
const libDir = import_node_path65.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
152705
153040
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
152706
|
-
const sitePackages =
|
|
153041
|
+
const sitePackages = import_node_path65.default.join(libDir, python, "site-packages");
|
|
152707
153042
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
152708
153043
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
152709
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
153044
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path65.default.join(sitePackages, entry, "direct_url.json"));
|
|
152710
153045
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
152711
153046
|
}
|
|
152712
153047
|
}
|
|
@@ -152962,7 +153297,7 @@ async function refreshCatalogueForReal(paths, name, env) {
|
|
|
152962
153297
|
init_realPorts();
|
|
152963
153298
|
|
|
152964
153299
|
// src/usage/realJobRunner.ts
|
|
152965
|
-
var
|
|
153300
|
+
var import_node_path66 = __toESM(require("node:path"), 1);
|
|
152966
153301
|
init_conditions();
|
|
152967
153302
|
init_identityClaude();
|
|
152968
153303
|
var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
|
|
@@ -152975,7 +153310,7 @@ ${outcome.trimEnd()}
|
|
|
152975
153310
|
}
|
|
152976
153311
|
function createRealJobRunner(params) {
|
|
152977
153312
|
return async (name, identity, job) => {
|
|
152978
|
-
const logFile =
|
|
153313
|
+
const logFile = import_node_path66.default.join(params.paths.jobLogsDir, `${name}.log`);
|
|
152979
153314
|
const append = (outcome) => {
|
|
152980
153315
|
params.fs.mkdirPrivate(params.paths.jobLogsDir);
|
|
152981
153316
|
params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
|
|
@@ -153032,7 +153367,7 @@ function registerHeadlessCommands(program2, deps) {
|
|
|
153032
153367
|
}
|
|
153033
153368
|
|
|
153034
153369
|
// src/jobs.ts
|
|
153035
|
-
var
|
|
153370
|
+
var import_node_path67 = __toESM(require("node:path"), 1);
|
|
153036
153371
|
init_commandDeps();
|
|
153037
153372
|
init_cliError();
|
|
153038
153373
|
init_schema();
|
|
@@ -153057,7 +153392,7 @@ function jobOf(options) {
|
|
|
153057
153392
|
target: options.identity === void 0 ? { pool: options.pool ?? "" } : { identity: options.identity },
|
|
153058
153393
|
trigger: options.at === void 0 ? { beforeReset: options.beforeReset ?? "fiveHour", lead: options.lead ?? "" } : { at: options.at },
|
|
153059
153394
|
prompt: options.prompt,
|
|
153060
|
-
cwd:
|
|
153395
|
+
cwd: import_node_path67.default.resolve(options.cwd ?? process.cwd()),
|
|
153061
153396
|
timeout: options.timeout,
|
|
153062
153397
|
...options.model === void 0 ? {} : { model: options.model },
|
|
153063
153398
|
...options.allowedTool === void 0 ? {} : { allowedTools: options.allowedTool }
|
|
@@ -153130,7 +153465,7 @@ function registerJobCommand(program2, deps) {
|
|
|
153130
153465
|
console.log(`Allowed tools: ${entry.allowedTools.join(", ")}`);
|
|
153131
153466
|
}
|
|
153132
153467
|
console.log(`Prompt: ${entry.prompt}`);
|
|
153133
|
-
console.log(`Results: ${
|
|
153468
|
+
console.log(`Results: ${import_node_path67.default.join(paths.jobLogsDir, `${name}.log`)}`);
|
|
153134
153469
|
}),
|
|
153135
153470
|
["agent-shim job show digest"]
|
|
153136
153471
|
);
|
|
@@ -153153,7 +153488,7 @@ function registerJobCommand(program2, deps) {
|
|
|
153153
153488
|
throw new UsageError(`No member of the job's pool can be picked right now.`);
|
|
153154
153489
|
}
|
|
153155
153490
|
await createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() })(name, identity, entry);
|
|
153156
|
-
console.log(`Ran job "${name}" as ${identity}; the result is in ${
|
|
153491
|
+
console.log(`Ran job "${name}" as ${identity}; the result is in ${import_node_path67.default.join(paths.jobLogsDir, `${name}.log`)}.`);
|
|
153157
153492
|
}),
|
|
153158
153493
|
["agent-shim job run digest"]
|
|
153159
153494
|
);
|
|
@@ -153317,7 +153652,7 @@ init_providerAliases();
|
|
|
153317
153652
|
|
|
153318
153653
|
// src/providerRename.ts
|
|
153319
153654
|
var import_node_fs27 = __toESM(require("node:fs"), 1);
|
|
153320
|
-
var
|
|
153655
|
+
var import_node_path68 = __toESM(require("node:path"), 1);
|
|
153321
153656
|
init_schema();
|
|
153322
153657
|
init_store();
|
|
153323
153658
|
init_load();
|
|
@@ -153435,7 +153770,7 @@ function rewriteReferences(paths, from, to2) {
|
|
|
153435
153770
|
const launch = renamedLaunch(profile.launch, from, to2);
|
|
153436
153771
|
const models = profile.models === void 0 ? void 0 : renamedModels(profile.models, from, to2);
|
|
153437
153772
|
if (launch !== void 0 || models !== void 0) {
|
|
153438
|
-
applyPatch(
|
|
153773
|
+
applyPatch(import_node_path68.default.join(paths.configProfilesDir, `${name}.json`), ConfigProfileSchema, { ...launch === void 0 ? {} : { launch }, ...models === void 0 ? {} : { models } });
|
|
153439
153774
|
rewritten.push(`profile ${name}`);
|
|
153440
153775
|
}
|
|
153441
153776
|
}
|
|
@@ -154262,7 +154597,7 @@ function registerSessionCommands(program2, deps) {
|
|
|
154262
154597
|
}
|
|
154263
154598
|
|
|
154264
154599
|
// src/usage/commands.ts
|
|
154265
|
-
var
|
|
154600
|
+
var import_node_path69 = __toESM(require("node:path"), 1);
|
|
154266
154601
|
init_commandDeps();
|
|
154267
154602
|
init_realPorts();
|
|
154268
154603
|
init_account();
|
|
@@ -154401,7 +154736,7 @@ function collectAccounts(fs31, paths, identity, probe) {
|
|
|
154401
154736
|
return names.map((name) => ({
|
|
154402
154737
|
identity: name,
|
|
154403
154738
|
account: readAccountMetadata(fs31, paths.identitiesDir, name),
|
|
154404
|
-
signIn: identitySignIn(fs31, probe, { farmRoot:
|
|
154739
|
+
signIn: identitySignIn(fs31, probe, { farmRoot: import_node_path69.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
|
|
154405
154740
|
usage: readUsageSnapshot(fs31, paths.usageSnapshotsDir, name)
|
|
154406
154741
|
}));
|
|
154407
154742
|
}
|
|
@@ -154808,7 +155143,7 @@ function quotaHitOf(fs31, paths, identity, sessionId, sinceMs, nowMs) {
|
|
|
154808
155143
|
}
|
|
154809
155144
|
|
|
154810
155145
|
// src/supervise/move.ts
|
|
154811
|
-
var
|
|
155146
|
+
var import_node_path70 = __toESM(require("node:path"), 1);
|
|
154812
155147
|
init_lock();
|
|
154813
155148
|
init_poolPick();
|
|
154814
155149
|
init_read();
|
|
@@ -154854,7 +155189,7 @@ function createMover(deps) {
|
|
|
154854
155189
|
if (resolution.identity === request7.from) {
|
|
154855
155190
|
return { kind: "stay", reason: `no other member of pool "${pool}" can take it` };
|
|
154856
155191
|
}
|
|
154857
|
-
const transcript =
|
|
155192
|
+
const transcript = import_node_path70.default.join(paths.identitiesDir, resolution.identity, "projects", projectDirNameOf(deps.cwd), `${request7.sessionId}.jsonl`);
|
|
154858
155193
|
if (farmFs.lstat(transcript)?.kind !== "file") {
|
|
154859
155194
|
return { kind: "stay", reason: `${resolution.identity} does not share this conversation's history, so it could not resume it` };
|
|
154860
155195
|
}
|
|
@@ -154888,13 +155223,13 @@ function createIdentityMover(deps) {
|
|
|
154888
155223
|
throw error63;
|
|
154889
155224
|
}
|
|
154890
155225
|
try {
|
|
154891
|
-
if (farmFs.readFileUtf8(
|
|
155226
|
+
if (farmFs.readFileUtf8(import_node_path70.default.join(paths.identitiesDir, request7.to, "identity.json")) === void 0) {
|
|
154892
155227
|
return { kind: "stay", reason: `no identity "${request7.to}"` };
|
|
154893
155228
|
}
|
|
154894
155229
|
if (request7.to === request7.from) {
|
|
154895
155230
|
return { kind: "stay", reason: `the model already runs under this session's identity` };
|
|
154896
155231
|
}
|
|
154897
|
-
const transcript =
|
|
155232
|
+
const transcript = import_node_path70.default.join(paths.identitiesDir, request7.to, "projects", projectDirNameOf(deps.cwd), `${request7.sessionId}.jsonl`);
|
|
154898
155233
|
if (farmFs.lstat(transcript)?.kind !== "file") {
|
|
154899
155234
|
return { kind: "stay", reason: `${request7.to} does not share this conversation's history, so it could not resume it` };
|
|
154900
155235
|
}
|
|
@@ -155473,7 +155808,7 @@ async function runClaude(argvOverride) {
|
|
|
155473
155808
|
// src/cli.ts
|
|
155474
155809
|
async function main() {
|
|
155475
155810
|
aliasLegacyEnv(process.env);
|
|
155476
|
-
const invokedName =
|
|
155811
|
+
const invokedName = import_node_path71.default.basename(process.argv[1] ?? "agent-shim");
|
|
155477
155812
|
if (isInvokedAsClaude(invokedName)) {
|
|
155478
155813
|
await runClaude();
|
|
155479
155814
|
return;
|