claude-use 11.57.1 → 11.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1102 -630
- package/dist/index.cjs +18 -4
- package/dist/index.mjs +18 -4
- package/dist/types/index.d.ts +331 -1
- 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")
|
|
@@ -9022,8 +9022,8 @@ var init_ko = __esm({
|
|
|
9022
9022
|
});
|
|
9023
9023
|
|
|
9024
9024
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/lt.js
|
|
9025
|
-
function getUnitTypeFromNumber(
|
|
9026
|
-
const abs = Math.abs(
|
|
9025
|
+
function getUnitTypeFromNumber(number6) {
|
|
9026
|
+
const abs = Math.abs(number6);
|
|
9027
9027
|
const last = abs % 10;
|
|
9028
9028
|
const last2 = abs % 100;
|
|
9029
9029
|
if (last2 >= 11 && last2 <= 19 || last === 0)
|
|
@@ -9041,8 +9041,8 @@ var capitalizeFirstCharacter, error33;
|
|
|
9041
9041
|
var init_lt = __esm({
|
|
9042
9042
|
"node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/lt.js"() {
|
|
9043
9043
|
init_util();
|
|
9044
|
-
capitalizeFirstCharacter = (
|
|
9045
|
-
return
|
|
9044
|
+
capitalizeFirstCharacter = (text5) => {
|
|
9045
|
+
return text5.charAt(0).toUpperCase() + text5.slice(1);
|
|
9046
9046
|
};
|
|
9047
9047
|
error33 = () => {
|
|
9048
9048
|
const Sizable = {
|
|
@@ -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
|
}
|
|
@@ -20530,8 +20530,8 @@ var require_common = __commonJS({
|
|
|
20530
20530
|
}
|
|
20531
20531
|
return result;
|
|
20532
20532
|
}
|
|
20533
|
-
function isNegativeZero(
|
|
20534
|
-
return
|
|
20533
|
+
function isNegativeZero(number6) {
|
|
20534
|
+
return number6 === 0 && Number.NEGATIVE_INFINITY === 1 / number6;
|
|
20535
20535
|
}
|
|
20536
20536
|
module2.exports.isNothing = isNothing;
|
|
20537
20537
|
module2.exports.isObject = isObject5;
|
|
@@ -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)) {
|
|
@@ -25322,8 +25322,8 @@ var init_string_width = __esm({
|
|
|
25322
25322
|
});
|
|
25323
25323
|
|
|
25324
25324
|
// src/statusline/blank.ts
|
|
25325
|
-
function drawsNothing(
|
|
25326
|
-
return stringWidth(
|
|
25325
|
+
function drawsNothing(text5) {
|
|
25326
|
+
return stringWidth(text5.replace(BLANK_CELLS, "")) === 0;
|
|
25327
25327
|
}
|
|
25328
25328
|
var BLANK_CELLS;
|
|
25329
25329
|
var init_blank = __esm({
|
|
@@ -25335,8 +25335,8 @@ var init_blank = __esm({
|
|
|
25335
25335
|
});
|
|
25336
25336
|
|
|
25337
25337
|
// src/statusline/graphemes.ts
|
|
25338
|
-
function graphemesOf(
|
|
25339
|
-
return Array.from(SEGMENTER.segment(
|
|
25338
|
+
function graphemesOf(text5) {
|
|
25339
|
+
return Array.from(SEGMENTER.segment(text5), (part) => part.segment);
|
|
25340
25340
|
}
|
|
25341
25341
|
var SEGMENTER;
|
|
25342
25342
|
var init_graphemes = __esm({
|
|
@@ -25350,8 +25350,8 @@ var init_graphemes = __esm({
|
|
|
25350
25350
|
function distinctList(member) {
|
|
25351
25351
|
return external_exports.array(member).refine((items) => new Set(items).size === items.length, "must not repeat an entry");
|
|
25352
25352
|
}
|
|
25353
|
-
function isSingleVisibleGrapheme(
|
|
25354
|
-
return graphemesOf(
|
|
25353
|
+
function isSingleVisibleGrapheme(text5) {
|
|
25354
|
+
return graphemesOf(text5).length === 1 && stringWidth(text5) === 1 && !/[\p{C}\p{Z}]/u.test(text5) && !drawsNothing(text5);
|
|
25355
25355
|
}
|
|
25356
25356
|
function isPlainObject2(value2) {
|
|
25357
25357
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
@@ -25373,7 +25373,7 @@ function resolveStatusline(settings2) {
|
|
|
25373
25373
|
}
|
|
25374
25374
|
return resolved;
|
|
25375
25375
|
}
|
|
25376
|
-
var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_ROWS, STATUSLINE_COLOUR_NAMES, DEFAULT_HEADER_SEGMENTS, DEFAULT_ROWS, STATUSLINE_PATH_LEVELS, STATUSLINE_USAGE_VALUES, STATUSLINE_TIME_FORMATS, STATUSLINE_HOUR_CYCLES, MAX_PERCENT, MAX_STATUSLINE_PALETTE_INDEX, MAX_STATUSLINE_LABEL_COLUMNS, MAX_BAR_CELLS, MAX_ACCOUNT_USER_CHARS, MAX_DISPLAY_TEXT_CHARS, LABEL_RE2, OPTIONAL_LABEL_RE, colourValue, barCharacter, labelText, overrideText, wholePercent, thresholdPercent, SHAPES, StatuslineSchema, ResolvedStatuslineSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
|
|
25376
|
+
var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_ROWS, STATUSLINE_SESSION_TIME_PARTS, PROMPT_CACHE_TTL_SECONDS, STATUSLINE_COLOUR_NAMES, DEFAULT_HEADER_SEGMENTS, DEFAULT_ROWS, STATUSLINE_PATH_LEVELS, STATUSLINE_USAGE_VALUES, STATUSLINE_TIME_FORMATS, STATUSLINE_HOUR_CYCLES, MAX_PERCENT, MAX_STATUSLINE_PALETTE_INDEX, MAX_STATUSLINE_LABEL_COLUMNS, MAX_BAR_CELLS, MAX_ACCOUNT_USER_CHARS, MAX_DISPLAY_TEXT_CHARS, LABEL_RE2, OPTIONAL_LABEL_RE, colourValue, barCharacter, labelText, overrideText, wholePercent, thresholdPercent, SHAPES, StatuslineSchema, ResolvedStatuslineSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
|
|
25377
25377
|
var init_statusline = __esm({
|
|
25378
25378
|
"src/config/statusline.ts"() {
|
|
25379
25379
|
"use strict";
|
|
@@ -25381,8 +25381,10 @@ var init_statusline = __esm({
|
|
|
25381
25381
|
init_zod();
|
|
25382
25382
|
init_blank();
|
|
25383
25383
|
init_graphemes();
|
|
25384
|
-
STATUSLINE_HEADER_SEGMENTS = ["model", "provider", "route", "account", "identity", "headroom", "project", "vcs", "effort", "advisor", "version", "outputStyle", "cost", "dailyCost"];
|
|
25385
|
-
STATUSLINE_ROWS = ["context", "quota", "addedDirs", "gitFiles", "memory", "environment"];
|
|
25384
|
+
STATUSLINE_HEADER_SEGMENTS = ["model", "provider", "route", "account", "identity", "headroom", "project", "vcs", "effort", "advisor", "version", "outputStyle", "cost", "dailyCost", "sessionName", "duration", "speed"];
|
|
25385
|
+
STATUSLINE_ROWS = ["context", "quota", "addedDirs", "gitFiles", "memory", "environment", "sessionTime", "promptCache", "compactions"];
|
|
25386
|
+
STATUSLINE_SESSION_TIME_PARTS = ["started", "lastReply"];
|
|
25387
|
+
PROMPT_CACHE_TTL_SECONDS = { fiveMinutes: 300, oneHour: 3600 };
|
|
25386
25388
|
STATUSLINE_COLOUR_NAMES = [
|
|
25387
25389
|
"default",
|
|
25388
25390
|
"dim",
|
|
@@ -25419,7 +25421,7 @@ var init_statusline = __esm({
|
|
|
25419
25421
|
OPTIONAL_LABEL_RE = /^(?:[^\p{C}\p{Z}]+(?: [^\p{C}\p{Z}]+)*)?$/u;
|
|
25420
25422
|
colourValue = external_exports.union([external_exports.enum(STATUSLINE_COLOUR_NAMES), external_exports.number().int().min(0).max(MAX_STATUSLINE_PALETTE_INDEX), external_exports.string().regex(/^#[0-9a-fA-F]{6}$/, "must be a colour name, a palette index from 0 to 255 or #rrggbb")]);
|
|
25421
25423
|
barCharacter = external_exports.string().refine(isSingleVisibleGrapheme, "must be a single visible character that takes one terminal column");
|
|
25422
|
-
labelText = external_exports.string().refine((
|
|
25424
|
+
labelText = external_exports.string().refine((text5) => stringWidth(text5) <= MAX_STATUSLINE_LABEL_COLUMNS, `must take no more than ${String(MAX_STATUSLINE_LABEL_COLUMNS)} terminal columns`).refine((text5) => !drawsNothing(text5), "must show something: a label of only combining marks or blank characters draws nothing").regex(LABEL_RE2, "must be visible text without control characters");
|
|
25423
25425
|
overrideText = external_exports.string().max(MAX_DISPLAY_TEXT_CHARS).regex(OPTIONAL_LABEL_RE, "must be visible text without control characters");
|
|
25424
25426
|
wholePercent = external_exports.number().int().min(1).max(MAX_PERCENT);
|
|
25425
25427
|
thresholdPercent = external_exports.number().int().min(0).max(MAX_PERCENT);
|
|
@@ -25479,6 +25481,12 @@ var init_statusline = __esm({
|
|
|
25479
25481
|
environment: {
|
|
25480
25482
|
threshold: external_exports.number().int().min(0).describe("The fewest configuration items in total (CLAUDE.md files, rules, MCP servers and hook events) that must exist for the environment row to draw its counts.")
|
|
25481
25483
|
},
|
|
25484
|
+
sessionTime: {
|
|
25485
|
+
parts: distinctList(external_exports.enum(STATUSLINE_SESSION_TIME_PARTS)).describe("The parts of the sessionTime row to draw, in drawing order: when the session started, and how long ago the last response was written; a part left out is hidden, and an empty list hides the row.")
|
|
25486
|
+
},
|
|
25487
|
+
promptCache: {
|
|
25488
|
+
ttlSeconds: external_exports.number().int().min(1).describe("How long the prompt cache lives, in seconds, when the transcript has not yet shown which tier the session writes (five minutes or one hour); the tier the transcript shows takes over once it does.")
|
|
25489
|
+
},
|
|
25482
25490
|
colours: {
|
|
25483
25491
|
context: colourValue.describe("The colour of the context bar and its figures below the warning threshold."),
|
|
25484
25492
|
usage: colourValue.describe("The colour of the quota bars and their figures below the warning threshold."),
|
|
@@ -25525,6 +25533,8 @@ var init_statusline = __esm({
|
|
|
25525
25533
|
clock: external_exports.strictObject(SHAPES.clock).partial().optional(),
|
|
25526
25534
|
cost: external_exports.strictObject(SHAPES.cost).partial().optional(),
|
|
25527
25535
|
environment: external_exports.strictObject(SHAPES.environment).partial().optional(),
|
|
25536
|
+
sessionTime: external_exports.strictObject(SHAPES.sessionTime).partial().optional(),
|
|
25537
|
+
promptCache: external_exports.strictObject(SHAPES.promptCache).partial().optional(),
|
|
25528
25538
|
colours: external_exports.strictObject(SHAPES.colours).partial().optional(),
|
|
25529
25539
|
project: external_exports.strictObject(SHAPES.project).partial().optional(),
|
|
25530
25540
|
git: external_exports.strictObject(SHAPES.git).partial().optional(),
|
|
@@ -25544,6 +25554,8 @@ var init_statusline = __esm({
|
|
|
25544
25554
|
clock: external_exports.strictObject(SHAPES.clock),
|
|
25545
25555
|
cost: external_exports.strictObject(SHAPES.cost),
|
|
25546
25556
|
environment: external_exports.strictObject(SHAPES.environment),
|
|
25557
|
+
sessionTime: external_exports.strictObject(SHAPES.sessionTime),
|
|
25558
|
+
promptCache: external_exports.strictObject(SHAPES.promptCache),
|
|
25547
25559
|
colours: external_exports.strictObject(SHAPES.colours),
|
|
25548
25560
|
project: external_exports.strictObject(SHAPES.project),
|
|
25549
25561
|
git: external_exports.strictObject(SHAPES.git),
|
|
@@ -25563,6 +25575,8 @@ var init_statusline = __esm({
|
|
|
25563
25575
|
clock: { hourCycle: "auto", seconds: false },
|
|
25564
25576
|
cost: { routed: false },
|
|
25565
25577
|
environment: { threshold: 0 },
|
|
25578
|
+
sessionTime: { parts: [...STATUSLINE_SESSION_TIME_PARTS] },
|
|
25579
|
+
promptCache: { ttlSeconds: PROMPT_CACHE_TTL_SECONDS.fiveMinutes },
|
|
25566
25580
|
colours: {
|
|
25567
25581
|
context: "green",
|
|
25568
25582
|
usage: "green",
|
|
@@ -28666,8 +28680,8 @@ function redactHeaders(headers) {
|
|
|
28666
28680
|
}
|
|
28667
28681
|
return result;
|
|
28668
28682
|
}
|
|
28669
|
-
function redactText(
|
|
28670
|
-
return SECRET_BODY_PATTERNS.reduce((accumulated, { pattern, replacement }) => accumulated.replace(pattern, replacement),
|
|
28683
|
+
function redactText(text5) {
|
|
28684
|
+
return SECRET_BODY_PATTERNS.reduce((accumulated, { pattern, replacement }) => accumulated.replace(pattern, replacement), text5);
|
|
28671
28685
|
}
|
|
28672
28686
|
function redactJsonValue(value2) {
|
|
28673
28687
|
if (typeof value2 === "string") {
|
|
@@ -28682,12 +28696,12 @@ function redactJsonValue(value2) {
|
|
|
28682
28696
|
return value2;
|
|
28683
28697
|
}
|
|
28684
28698
|
function redactBody(chunk2) {
|
|
28685
|
-
const
|
|
28699
|
+
const text5 = chunk2.toString("utf8");
|
|
28686
28700
|
try {
|
|
28687
|
-
const parsed = JSON.parse(
|
|
28701
|
+
const parsed = JSON.parse(text5);
|
|
28688
28702
|
return JSON.stringify(redactJsonValue(parsed));
|
|
28689
28703
|
} catch {
|
|
28690
|
-
return redactText(
|
|
28704
|
+
return redactText(text5);
|
|
28691
28705
|
}
|
|
28692
28706
|
}
|
|
28693
28707
|
function captureFromEnv(env, logsDir) {
|
|
@@ -28722,8 +28736,8 @@ function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
|
|
|
28722
28736
|
}
|
|
28723
28737
|
const excerpt2 = chunk2.subarray(0, Math.min(CHUNK_LOG_CAP_BYTES, budget));
|
|
28724
28738
|
stored[direction] += excerpt2.length;
|
|
28725
|
-
const
|
|
28726
|
-
const faithful = Buffer.from(
|
|
28739
|
+
const text5 = excerpt2.toString("utf8");
|
|
28740
|
+
const faithful = Buffer.from(text5, "utf8").equals(excerpt2);
|
|
28727
28741
|
append({
|
|
28728
28742
|
kind: "stream-chunk",
|
|
28729
28743
|
id: id2,
|
|
@@ -28732,7 +28746,7 @@ function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
|
|
|
28732
28746
|
bytes: chunk2.length,
|
|
28733
28747
|
stored: excerpt2.length,
|
|
28734
28748
|
truncated: excerpt2.length < chunk2.length,
|
|
28735
|
-
...faithful ? { body: redactText(
|
|
28749
|
+
...faithful ? { body: redactText(text5) } : { b64: excerpt2.toString("base64") }
|
|
28736
28750
|
});
|
|
28737
28751
|
},
|
|
28738
28752
|
onEnd: () => {
|
|
@@ -29416,8 +29430,8 @@ var init_report = __esm({
|
|
|
29416
29430
|
});
|
|
29417
29431
|
|
|
29418
29432
|
// src/logStyle.ts
|
|
29419
|
-
function styledDiagnostic(style, colour,
|
|
29420
|
-
return
|
|
29433
|
+
function styledDiagnostic(style, colour, text5) {
|
|
29434
|
+
return text5.split("\n").map((line, index) => {
|
|
29421
29435
|
const lead = index === 0 ? DIAGNOSTIC_LEAD.exec(line) : null;
|
|
29422
29436
|
if (lead === null) {
|
|
29423
29437
|
return style([colour], line);
|
|
@@ -29445,7 +29459,7 @@ function createLogPort(sinks, styleFor) {
|
|
|
29445
29459
|
};
|
|
29446
29460
|
}
|
|
29447
29461
|
function styleTextFor(stream) {
|
|
29448
|
-
return (formats,
|
|
29462
|
+
return (formats, text5) => (0, import_node_util3.styleText)([...formats], text5, { stream });
|
|
29449
29463
|
}
|
|
29450
29464
|
var import_node_util3, DIAGNOSTIC_LEAD;
|
|
29451
29465
|
var init_logStyle = __esm({
|
|
@@ -30672,8 +30686,8 @@ var require_utils = __commonJS({
|
|
|
30672
30686
|
}
|
|
30673
30687
|
return output2;
|
|
30674
30688
|
};
|
|
30675
|
-
exports2.basename = (
|
|
30676
|
-
const segs =
|
|
30689
|
+
exports2.basename = (path72, { windows } = {}) => {
|
|
30690
|
+
const segs = path72.split(windows ? /[\\/]/ : "/");
|
|
30677
30691
|
const last = segs[segs.length - 1];
|
|
30678
30692
|
if (last === "") {
|
|
30679
30693
|
return segs[segs.length - 2];
|
|
@@ -32438,9 +32452,9 @@ var init_identity = __esm({
|
|
|
32438
32452
|
});
|
|
32439
32453
|
|
|
32440
32454
|
// src/statusline/keys.ts
|
|
32441
|
-
function valueAt(source,
|
|
32455
|
+
function valueAt(source, path72) {
|
|
32442
32456
|
let current = source;
|
|
32443
|
-
for (const part of
|
|
32457
|
+
for (const part of path72) {
|
|
32444
32458
|
if (!isPlainObject2(current)) {
|
|
32445
32459
|
return void 0;
|
|
32446
32460
|
}
|
|
@@ -32448,8 +32462,8 @@ function valueAt(source, path71) {
|
|
|
32448
32462
|
}
|
|
32449
32463
|
return current;
|
|
32450
32464
|
}
|
|
32451
|
-
function keyOf(
|
|
32452
|
-
const common = { path:
|
|
32465
|
+
function keyOf(path72, leaf) {
|
|
32466
|
+
const common = { path: path72.join("."), description: leaf.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path72) };
|
|
32453
32467
|
if (leaf instanceof external_exports.ZodNumber) {
|
|
32454
32468
|
return { ...common, kind: "integer", choices: [] };
|
|
32455
32469
|
}
|
|
@@ -32468,7 +32482,7 @@ function keyOf(path71, leaf) {
|
|
|
32468
32482
|
if (leaf instanceof external_exports.ZodArray && leaf.element instanceof external_exports.ZodEnum) {
|
|
32469
32483
|
return { ...common, kind: "list", choices: Object.values(leaf.element.enum).map(String) };
|
|
32470
32484
|
}
|
|
32471
|
-
throw new TypeError(`statusline setting ${
|
|
32485
|
+
throw new TypeError(`statusline setting ${path72.join(".")} has a kind the key listing does not describe`);
|
|
32472
32486
|
}
|
|
32473
32487
|
function walk(shape, prefix) {
|
|
32474
32488
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof external_exports.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -32492,47 +32506,47 @@ var init_keys = __esm({
|
|
|
32492
32506
|
});
|
|
32493
32507
|
|
|
32494
32508
|
// src/statusline/change.ts
|
|
32495
|
-
function keyNamed(
|
|
32496
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
32509
|
+
function keyNamed(path72) {
|
|
32510
|
+
const found = statuslineKeys().find((key) => key.path === path72);
|
|
32497
32511
|
if (found === void 0) {
|
|
32498
|
-
throw new UsageError(`"${
|
|
32512
|
+
throw new UsageError(`"${path72}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
32499
32513
|
}
|
|
32500
32514
|
return found;
|
|
32501
32515
|
}
|
|
32502
|
-
function parseStatuslineAssignment(
|
|
32503
|
-
const split =
|
|
32516
|
+
function parseStatuslineAssignment(text5) {
|
|
32517
|
+
const split = text5.indexOf("=");
|
|
32504
32518
|
if (split < 1) {
|
|
32505
|
-
throw new UsageError(`"${
|
|
32519
|
+
throw new UsageError(`"${text5}" is not <setting>=<value>.`);
|
|
32506
32520
|
}
|
|
32507
|
-
const
|
|
32508
|
-
const raw =
|
|
32509
|
-
const key = keyNamed(
|
|
32521
|
+
const path72 = text5.slice(0, split);
|
|
32522
|
+
const raw = text5.slice(split + 1);
|
|
32523
|
+
const key = keyNamed(path72);
|
|
32510
32524
|
switch (key.kind) {
|
|
32511
32525
|
case "integer": {
|
|
32512
|
-
const
|
|
32513
|
-
if (raw.trim() === "" || !Number.isFinite(
|
|
32514
|
-
throw new UsageError(`${
|
|
32526
|
+
const number6 = Number(raw);
|
|
32527
|
+
if (raw.trim() === "" || !Number.isFinite(number6)) {
|
|
32528
|
+
throw new UsageError(`${path72}: "${raw}" is not a number.`);
|
|
32515
32529
|
}
|
|
32516
|
-
return { path:
|
|
32530
|
+
return { path: path72, value: number6 };
|
|
32517
32531
|
}
|
|
32518
32532
|
case "boolean":
|
|
32519
32533
|
if (raw !== "true" && raw !== "false") {
|
|
32520
|
-
throw new UsageError(`${
|
|
32534
|
+
throw new UsageError(`${path72}: "${raw}" is not true or false.`);
|
|
32521
32535
|
}
|
|
32522
|
-
return { path:
|
|
32536
|
+
return { path: path72, value: raw === "true" };
|
|
32523
32537
|
case "text":
|
|
32524
32538
|
case "choice":
|
|
32525
|
-
return { path:
|
|
32539
|
+
return { path: path72, value: raw };
|
|
32526
32540
|
case "colour":
|
|
32527
|
-
return { path:
|
|
32541
|
+
return { path: path72, value: /^\d+$/.test(raw) ? Number(raw) : raw };
|
|
32528
32542
|
case "list":
|
|
32529
|
-
return { path:
|
|
32543
|
+
return { path: path72, value: raw === "" ? [] : raw.split(",") };
|
|
32530
32544
|
default:
|
|
32531
32545
|
return key.kind;
|
|
32532
32546
|
}
|
|
32533
32547
|
}
|
|
32534
|
-
function setAt(target,
|
|
32535
|
-
const [head, ...rest] =
|
|
32548
|
+
function setAt(target, path72, value2) {
|
|
32549
|
+
const [head, ...rest] = path72;
|
|
32536
32550
|
if (head === void 0) {
|
|
32537
32551
|
return;
|
|
32538
32552
|
}
|
|
@@ -32545,8 +32559,8 @@ function setAt(target, path71, value2) {
|
|
|
32545
32559
|
target[head] = next;
|
|
32546
32560
|
setAt(next, rest, value2);
|
|
32547
32561
|
}
|
|
32548
|
-
function removeAt(target,
|
|
32549
|
-
const [head, ...rest] =
|
|
32562
|
+
function removeAt(target, path72) {
|
|
32563
|
+
const [head, ...rest] = path72;
|
|
32550
32564
|
if (head === void 0) {
|
|
32551
32565
|
return;
|
|
32552
32566
|
}
|
|
@@ -32564,13 +32578,13 @@ function removeAt(target, path71) {
|
|
|
32564
32578
|
}
|
|
32565
32579
|
function applyStatuslineChange(existing, change) {
|
|
32566
32580
|
const draft = structuredClone(existing ?? {});
|
|
32567
|
-
for (const [
|
|
32568
|
-
keyNamed(
|
|
32569
|
-
setAt(draft,
|
|
32581
|
+
for (const [path72, value2] of Object.entries(change.set ?? {})) {
|
|
32582
|
+
keyNamed(path72);
|
|
32583
|
+
setAt(draft, path72.split("."), value2);
|
|
32570
32584
|
}
|
|
32571
|
-
for (const
|
|
32572
|
-
keyNamed(
|
|
32573
|
-
removeAt(draft,
|
|
32585
|
+
for (const path72 of change.unset ?? []) {
|
|
32586
|
+
keyNamed(path72);
|
|
32587
|
+
removeAt(draft, path72.split("."));
|
|
32574
32588
|
}
|
|
32575
32589
|
const result = StatuslineSchema.safeParse(draft);
|
|
32576
32590
|
if (!result.success) {
|
|
@@ -35713,7 +35727,7 @@ function keyUsageExtension(bits) {
|
|
|
35713
35727
|
}
|
|
35714
35728
|
function ipv6Groups(address) {
|
|
35715
35729
|
const [head = "", tail] = address.split("::");
|
|
35716
|
-
const split = (
|
|
35730
|
+
const split = (text5) => text5 === "" ? [] : text5.split(":");
|
|
35717
35731
|
const expand = (groups) => groups.flatMap((group) => {
|
|
35718
35732
|
if (!import_node_net.default.isIPv4(group)) {
|
|
35719
35733
|
return [Number.parseInt(group, HEX_RADIX)];
|
|
@@ -36047,11 +36061,11 @@ function identifyRequest(headers) {
|
|
|
36047
36061
|
function directOrigin2(port) {
|
|
36048
36062
|
return `http://127.0.0.1:${String(port)}`;
|
|
36049
36063
|
}
|
|
36050
|
-
function parseProviderPath(
|
|
36051
|
-
if (!
|
|
36064
|
+
function parseProviderPath(path72) {
|
|
36065
|
+
if (!path72.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
36052
36066
|
return void 0;
|
|
36053
36067
|
}
|
|
36054
|
-
const tail =
|
|
36068
|
+
const tail = path72.slice(PROVIDER_PATH_PREFIX.length);
|
|
36055
36069
|
const slash = tail.indexOf("/");
|
|
36056
36070
|
if (slash <= 0) {
|
|
36057
36071
|
return void 0;
|
|
@@ -36325,8 +36339,8 @@ function parseConnectTarget(authority) {
|
|
|
36325
36339
|
}
|
|
36326
36340
|
return { host, port };
|
|
36327
36341
|
}
|
|
36328
|
-
function servedByPipeline(
|
|
36329
|
-
return
|
|
36342
|
+
function servedByPipeline(path72) {
|
|
36343
|
+
return path72?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
36330
36344
|
}
|
|
36331
36345
|
function forwardableHeaders(headers) {
|
|
36332
36346
|
const connectionTokens = new Set(
|
|
@@ -36804,7 +36818,7 @@ var init_package = __esm({
|
|
|
36804
36818
|
"package.json"() {
|
|
36805
36819
|
package_default = {
|
|
36806
36820
|
name: "claude-use",
|
|
36807
|
-
version: "11.
|
|
36821
|
+
version: "11.58.0",
|
|
36808
36822
|
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.",
|
|
36809
36823
|
license: "MIT",
|
|
36810
36824
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -37069,9 +37083,9 @@ function errorInfo(raw) {
|
|
|
37069
37083
|
function isObject3(value2) {
|
|
37070
37084
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
37071
37085
|
}
|
|
37072
|
-
function parseJson2(
|
|
37086
|
+
function parseJson2(text5) {
|
|
37073
37087
|
try {
|
|
37074
|
-
const parsed = JSON.parse(
|
|
37088
|
+
const parsed = JSON.parse(text5);
|
|
37075
37089
|
return parsed;
|
|
37076
37090
|
} catch {
|
|
37077
37091
|
return void 0;
|
|
@@ -37119,26 +37133,26 @@ function createSseScanner() {
|
|
|
37119
37133
|
return void 0;
|
|
37120
37134
|
};
|
|
37121
37135
|
const completeLine = (complete) => {
|
|
37122
|
-
const
|
|
37123
|
-
if (
|
|
37136
|
+
const text5 = complete.endsWith("\r") ? complete.slice(0, -1) : complete;
|
|
37137
|
+
if (text5 === "") {
|
|
37124
37138
|
dispatch();
|
|
37125
37139
|
return;
|
|
37126
37140
|
}
|
|
37127
|
-
if (
|
|
37128
|
-
eventName =
|
|
37141
|
+
if (text5.startsWith("event:")) {
|
|
37142
|
+
eventName = text5.slice("event:".length).trim();
|
|
37129
37143
|
return;
|
|
37130
37144
|
}
|
|
37131
|
-
if (
|
|
37132
|
-
const value2 =
|
|
37145
|
+
if (text5.startsWith("data:")) {
|
|
37146
|
+
const value2 = text5.slice("data:".length);
|
|
37133
37147
|
data.push(value2.startsWith(" ") ? value2.slice(1) : value2);
|
|
37134
37148
|
}
|
|
37135
37149
|
};
|
|
37136
37150
|
return {
|
|
37137
|
-
push: (
|
|
37151
|
+
push: (text5) => {
|
|
37138
37152
|
let start = 0;
|
|
37139
37153
|
for (; ; ) {
|
|
37140
|
-
const newline =
|
|
37141
|
-
const piece = newline === -1 ?
|
|
37154
|
+
const newline = text5.indexOf("\n", start);
|
|
37155
|
+
const piece = newline === -1 ? text5.slice(start) : text5.slice(start, newline);
|
|
37142
37156
|
if (!skipping) {
|
|
37143
37157
|
line += piece;
|
|
37144
37158
|
if (worthKeeping(line) === false) {
|
|
@@ -37252,8 +37266,8 @@ function createJsonScanner() {
|
|
|
37252
37266
|
}
|
|
37253
37267
|
};
|
|
37254
37268
|
return {
|
|
37255
|
-
push: (
|
|
37256
|
-
for (const char of
|
|
37269
|
+
push: (text5) => {
|
|
37270
|
+
for (const char of text5) {
|
|
37257
37271
|
step2(char);
|
|
37258
37272
|
}
|
|
37259
37273
|
},
|
|
@@ -37327,12 +37341,12 @@ function decoderFor(encoding) {
|
|
|
37327
37341
|
return void 0;
|
|
37328
37342
|
}
|
|
37329
37343
|
}
|
|
37330
|
-
function destinationOf(
|
|
37331
|
-
const scoped = parseProviderPath(
|
|
37344
|
+
function destinationOf(path72, sessionProvider) {
|
|
37345
|
+
const scoped = parseProviderPath(path72);
|
|
37332
37346
|
if (scoped !== void 0) {
|
|
37333
37347
|
return { provider: scoped.provider, endpoint: scoped.rest };
|
|
37334
37348
|
}
|
|
37335
|
-
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint:
|
|
37349
|
+
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint: path72 };
|
|
37336
37350
|
}
|
|
37337
37351
|
function modelChoiceOf(event, servedModel, provider) {
|
|
37338
37352
|
if (event.modelChoice !== void 0) return event.modelChoice;
|
|
@@ -37381,13 +37395,13 @@ function createUsageMiddleware(deps) {
|
|
|
37381
37395
|
const scanner = scannerFor(event.headers);
|
|
37382
37396
|
const decoder = scanner === void 0 ? null : decoderFor(headerValue(event.headers, "content-encoding"));
|
|
37383
37397
|
let scanning = scanner !== void 0 && decoder !== void 0;
|
|
37384
|
-
const
|
|
37398
|
+
const text5 = new TextDecoder();
|
|
37385
37399
|
const feed = (bytes, final) => {
|
|
37386
37400
|
if (!scanning || scanner === void 0) {
|
|
37387
37401
|
return;
|
|
37388
37402
|
}
|
|
37389
37403
|
try {
|
|
37390
|
-
scanner.push(
|
|
37404
|
+
scanner.push(text5.decode(bytes, { stream: !final }));
|
|
37391
37405
|
} catch (error63) {
|
|
37392
37406
|
scanning = false;
|
|
37393
37407
|
deps.log(`usage: body scan failed for ${event.route}: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
@@ -40368,14 +40382,14 @@ var require_util2 = __commonJS({
|
|
|
40368
40382
|
}
|
|
40369
40383
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
40370
40384
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
40371
|
-
let
|
|
40385
|
+
let path72 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
40372
40386
|
if (origin[origin.length - 1] === "/") {
|
|
40373
40387
|
origin = origin.slice(0, origin.length - 1);
|
|
40374
40388
|
}
|
|
40375
|
-
if (
|
|
40376
|
-
|
|
40389
|
+
if (path72 && path72[0] !== "/") {
|
|
40390
|
+
path72 = `/${path72}`;
|
|
40377
40391
|
}
|
|
40378
|
-
return new URL(`${origin}${
|
|
40392
|
+
return new URL(`${origin}${path72}`);
|
|
40379
40393
|
}
|
|
40380
40394
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
40381
40395
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -41196,9 +41210,9 @@ var require_diagnostics = __commonJS({
|
|
|
41196
41210
|
"undici:client:sendHeaders",
|
|
41197
41211
|
(evt) => {
|
|
41198
41212
|
const {
|
|
41199
|
-
request: { method, path:
|
|
41213
|
+
request: { method, path: path72, origin }
|
|
41200
41214
|
} = evt;
|
|
41201
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
41215
|
+
debugLog("sending request to %s %s%s", method, origin, path72);
|
|
41202
41216
|
}
|
|
41203
41217
|
);
|
|
41204
41218
|
}
|
|
@@ -41216,14 +41230,14 @@ var require_diagnostics = __commonJS({
|
|
|
41216
41230
|
"undici:request:headers",
|
|
41217
41231
|
(evt) => {
|
|
41218
41232
|
const {
|
|
41219
|
-
request: { method, path:
|
|
41233
|
+
request: { method, path: path72, origin },
|
|
41220
41234
|
response: { statusCode }
|
|
41221
41235
|
} = evt;
|
|
41222
41236
|
debugLog(
|
|
41223
41237
|
"received response to %s %s%s - HTTP %d",
|
|
41224
41238
|
method,
|
|
41225
41239
|
origin,
|
|
41226
|
-
|
|
41240
|
+
path72,
|
|
41227
41241
|
statusCode
|
|
41228
41242
|
);
|
|
41229
41243
|
}
|
|
@@ -41232,23 +41246,23 @@ var require_diagnostics = __commonJS({
|
|
|
41232
41246
|
"undici:request:trailers",
|
|
41233
41247
|
(evt) => {
|
|
41234
41248
|
const {
|
|
41235
|
-
request: { method, path:
|
|
41249
|
+
request: { method, path: path72, origin }
|
|
41236
41250
|
} = evt;
|
|
41237
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
41251
|
+
debugLog("trailers received from %s %s%s", method, origin, path72);
|
|
41238
41252
|
}
|
|
41239
41253
|
);
|
|
41240
41254
|
diagnosticsChannel.subscribe(
|
|
41241
41255
|
"undici:request:error",
|
|
41242
41256
|
(evt) => {
|
|
41243
41257
|
const {
|
|
41244
|
-
request: { method, path:
|
|
41258
|
+
request: { method, path: path72, origin },
|
|
41245
41259
|
error: error63
|
|
41246
41260
|
} = evt;
|
|
41247
41261
|
debugLog(
|
|
41248
41262
|
"request to %s %s%s errored - %s",
|
|
41249
41263
|
method,
|
|
41250
41264
|
origin,
|
|
41251
|
-
|
|
41265
|
+
path72,
|
|
41252
41266
|
error63.message
|
|
41253
41267
|
);
|
|
41254
41268
|
}
|
|
@@ -41363,7 +41377,7 @@ var require_request = __commonJS({
|
|
|
41363
41377
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
41364
41378
|
var Request2 = class {
|
|
41365
41379
|
constructor(origin, {
|
|
41366
|
-
path:
|
|
41380
|
+
path: path72,
|
|
41367
41381
|
method,
|
|
41368
41382
|
body,
|
|
41369
41383
|
headers,
|
|
@@ -41380,11 +41394,11 @@ var require_request = __commonJS({
|
|
|
41380
41394
|
maxRedirections,
|
|
41381
41395
|
typeOfService
|
|
41382
41396
|
}, handler) {
|
|
41383
|
-
if (typeof
|
|
41397
|
+
if (typeof path72 !== "string") {
|
|
41384
41398
|
throw new InvalidArgumentError2("path must be a string");
|
|
41385
|
-
} else if (
|
|
41399
|
+
} else if (path72[0] !== "/" && !(path72.startsWith("http://") || path72.startsWith("https://")) && method !== "CONNECT") {
|
|
41386
41400
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
41387
|
-
} else if (invalidPathRegex.test(
|
|
41401
|
+
} else if (invalidPathRegex.test(path72)) {
|
|
41388
41402
|
throw new InvalidArgumentError2("invalid request path");
|
|
41389
41403
|
}
|
|
41390
41404
|
if (typeof method !== "string") {
|
|
@@ -41459,7 +41473,7 @@ var require_request = __commonJS({
|
|
|
41459
41473
|
this.completed = false;
|
|
41460
41474
|
this.aborted = false;
|
|
41461
41475
|
this.upgrade = upgrade || null;
|
|
41462
|
-
this.path = query ? serializePathWithQuery(
|
|
41476
|
+
this.path = query ? serializePathWithQuery(path72, query) : path72;
|
|
41463
41477
|
this.origin = origin;
|
|
41464
41478
|
this.protocol = getProtocolFromUrlString(origin);
|
|
41465
41479
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -46641,7 +46655,7 @@ var require_client_h1 = __commonJS({
|
|
|
46641
46655
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
46642
46656
|
}
|
|
46643
46657
|
function writeH1(client, request7) {
|
|
46644
|
-
const { method, path:
|
|
46658
|
+
const { method, path: path72, host, upgrade, blocking, reset } = request7;
|
|
46645
46659
|
let { body, headers, contentLength } = request7;
|
|
46646
46660
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
46647
46661
|
if (util2.isFormDataLike(body)) {
|
|
@@ -46719,7 +46733,7 @@ var require_client_h1 = __commonJS({
|
|
|
46719
46733
|
if (socket.setTypeOfService) {
|
|
46720
46734
|
socket.setTypeOfService(request7.typeOfService);
|
|
46721
46735
|
}
|
|
46722
|
-
let header = `${method} ${
|
|
46736
|
+
let header = `${method} ${path72} HTTP/1.1\r
|
|
46723
46737
|
`;
|
|
46724
46738
|
if (typeof host === "string") {
|
|
46725
46739
|
header += `host: ${host}\r
|
|
@@ -47398,7 +47412,7 @@ var require_client_h2 = __commonJS({
|
|
|
47398
47412
|
const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
|
|
47399
47413
|
const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
|
|
47400
47414
|
const session = client[kHTTP2Session];
|
|
47401
|
-
const { method, path:
|
|
47415
|
+
const { method, path: path72, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
|
|
47402
47416
|
let { body } = request7;
|
|
47403
47417
|
if (upgrade != null && upgrade !== "websocket") {
|
|
47404
47418
|
util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -47467,7 +47481,7 @@ var require_client_h2 = __commonJS({
|
|
|
47467
47481
|
}
|
|
47468
47482
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
47469
47483
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
47470
|
-
headers[HTTP2_HEADER_PATH] =
|
|
47484
|
+
headers[HTTP2_HEADER_PATH] = path72;
|
|
47471
47485
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
47472
47486
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
47473
47487
|
} else {
|
|
@@ -47509,7 +47523,7 @@ var require_client_h2 = __commonJS({
|
|
|
47509
47523
|
stream.setTimeout(headersTimeout);
|
|
47510
47524
|
return true;
|
|
47511
47525
|
}
|
|
47512
|
-
headers[HTTP2_HEADER_PATH] =
|
|
47526
|
+
headers[HTTP2_HEADER_PATH] = path72;
|
|
47513
47527
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
47514
47528
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
47515
47529
|
if (body && typeof body.read === "function") {
|
|
@@ -49861,10 +49875,10 @@ var require_proxy_agent = __commonJS({
|
|
|
49861
49875
|
};
|
|
49862
49876
|
const {
|
|
49863
49877
|
origin,
|
|
49864
|
-
path:
|
|
49878
|
+
path: path72 = "/",
|
|
49865
49879
|
headers = {}
|
|
49866
49880
|
} = opts;
|
|
49867
|
-
opts.path = origin +
|
|
49881
|
+
opts.path = origin + path72;
|
|
49868
49882
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
49869
49883
|
const { host } = new URL(origin);
|
|
49870
49884
|
headers.host = host;
|
|
@@ -51973,20 +51987,20 @@ var require_mock_utils = __commonJS({
|
|
|
51973
51987
|
}
|
|
51974
51988
|
return normalizedQp;
|
|
51975
51989
|
}
|
|
51976
|
-
function safeUrl(
|
|
51977
|
-
if (typeof
|
|
51978
|
-
return
|
|
51990
|
+
function safeUrl(path72) {
|
|
51991
|
+
if (typeof path72 !== "string") {
|
|
51992
|
+
return path72;
|
|
51979
51993
|
}
|
|
51980
|
-
const pathSegments =
|
|
51994
|
+
const pathSegments = path72.split("?", 3);
|
|
51981
51995
|
if (pathSegments.length !== 2) {
|
|
51982
|
-
return
|
|
51996
|
+
return path72;
|
|
51983
51997
|
}
|
|
51984
51998
|
const qp2 = new URLSearchParams(pathSegments.pop());
|
|
51985
51999
|
qp2.sort();
|
|
51986
52000
|
return [...pathSegments, qp2.toString()].join("?");
|
|
51987
52001
|
}
|
|
51988
|
-
function matchKey(mockDispatch2, { path:
|
|
51989
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
52002
|
+
function matchKey(mockDispatch2, { path: path72, method, body, headers }) {
|
|
52003
|
+
const pathMatch = matchValue(mockDispatch2.path, path72);
|
|
51990
52004
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
51991
52005
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
51992
52006
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -52011,8 +52025,8 @@ var require_mock_utils = __commonJS({
|
|
|
52011
52025
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
52012
52026
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
52013
52027
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
52014
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
52015
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
52028
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path72, ignoreTrailingSlash }) => {
|
|
52029
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path72)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path72), resolvedPath);
|
|
52016
52030
|
});
|
|
52017
52031
|
if (matchedMockDispatches.length === 0) {
|
|
52018
52032
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -52051,19 +52065,19 @@ var require_mock_utils = __commonJS({
|
|
|
52051
52065
|
mockDispatches.splice(index, 1);
|
|
52052
52066
|
}
|
|
52053
52067
|
}
|
|
52054
|
-
function removeTrailingSlash(
|
|
52055
|
-
while (
|
|
52056
|
-
|
|
52068
|
+
function removeTrailingSlash(path72) {
|
|
52069
|
+
while (path72.endsWith("/")) {
|
|
52070
|
+
path72 = path72.slice(0, -1);
|
|
52057
52071
|
}
|
|
52058
|
-
if (
|
|
52059
|
-
|
|
52072
|
+
if (path72.length === 0) {
|
|
52073
|
+
path72 = "/";
|
|
52060
52074
|
}
|
|
52061
|
-
return
|
|
52075
|
+
return path72;
|
|
52062
52076
|
}
|
|
52063
52077
|
function buildKey(opts) {
|
|
52064
|
-
const { path:
|
|
52078
|
+
const { path: path72, method, body, headers, query } = opts;
|
|
52065
52079
|
return {
|
|
52066
|
-
path:
|
|
52080
|
+
path: path72,
|
|
52067
52081
|
method,
|
|
52068
52082
|
body,
|
|
52069
52083
|
headers,
|
|
@@ -52582,17 +52596,17 @@ var require_mock_call_history = __commonJS({
|
|
|
52582
52596
|
lastCall() {
|
|
52583
52597
|
return this.logs.at(-1);
|
|
52584
52598
|
}
|
|
52585
|
-
nthCall(
|
|
52586
|
-
if (typeof
|
|
52599
|
+
nthCall(number6) {
|
|
52600
|
+
if (typeof number6 !== "number") {
|
|
52587
52601
|
throw new InvalidArgumentError2("nthCall must be called with a number");
|
|
52588
52602
|
}
|
|
52589
|
-
if (!Number.isInteger(
|
|
52603
|
+
if (!Number.isInteger(number6)) {
|
|
52590
52604
|
throw new InvalidArgumentError2("nthCall must be called with an integer");
|
|
52591
52605
|
}
|
|
52592
|
-
if (Math.sign(
|
|
52606
|
+
if (Math.sign(number6) !== 1) {
|
|
52593
52607
|
throw new InvalidArgumentError2("nthCall must be called with a positive value. use firstCall or lastCall instead");
|
|
52594
52608
|
}
|
|
52595
|
-
return this.logs.at(
|
|
52609
|
+
return this.logs.at(number6 - 1);
|
|
52596
52610
|
}
|
|
52597
52611
|
filterCalls(criteria, options) {
|
|
52598
52612
|
if (this.logs.length === 0) {
|
|
@@ -52753,10 +52767,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
52753
52767
|
}
|
|
52754
52768
|
format(pendingInterceptors) {
|
|
52755
52769
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
52756
|
-
({ method, path:
|
|
52770
|
+
({ method, path: path72, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
52757
52771
|
Method: method,
|
|
52758
52772
|
Origin: origin,
|
|
52759
|
-
Path:
|
|
52773
|
+
Path: path72,
|
|
52760
52774
|
"Status code": statusCode,
|
|
52761
52775
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
52762
52776
|
Invocations: timesInvoked,
|
|
@@ -52838,9 +52852,9 @@ var require_mock_agent = __commonJS({
|
|
|
52838
52852
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
52839
52853
|
const dispatchOpts = { ...opts };
|
|
52840
52854
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
52841
|
-
const [
|
|
52855
|
+
const [path72, searchParams] = dispatchOpts.path.split("?");
|
|
52842
52856
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
52843
|
-
dispatchOpts.path = `${
|
|
52857
|
+
dispatchOpts.path = `${path72}?${normalizedSearchParams}`;
|
|
52844
52858
|
}
|
|
52845
52859
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
52846
52860
|
}
|
|
@@ -53241,12 +53255,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53241
53255
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
53242
53256
|
*/
|
|
53243
53257
|
async loadSnapshots(filePath) {
|
|
53244
|
-
const
|
|
53245
|
-
if (!
|
|
53258
|
+
const path72 = filePath || this.#snapshotPath;
|
|
53259
|
+
if (!path72) {
|
|
53246
53260
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
53247
53261
|
}
|
|
53248
53262
|
try {
|
|
53249
|
-
const data = await readFile(resolve2(
|
|
53263
|
+
const data = await readFile(resolve2(path72), "utf8");
|
|
53250
53264
|
const parsed = JSON.parse(data);
|
|
53251
53265
|
if (Array.isArray(parsed)) {
|
|
53252
53266
|
this.#snapshots.clear();
|
|
@@ -53260,7 +53274,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53260
53274
|
if (error63.code === "ENOENT") {
|
|
53261
53275
|
this.#snapshots.clear();
|
|
53262
53276
|
} else {
|
|
53263
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
53277
|
+
throw new UndiciError(`Failed to load snapshots from ${path72}`, { cause: error63 });
|
|
53264
53278
|
}
|
|
53265
53279
|
}
|
|
53266
53280
|
}
|
|
@@ -53271,11 +53285,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53271
53285
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
53272
53286
|
*/
|
|
53273
53287
|
async saveSnapshots(filePath) {
|
|
53274
|
-
const
|
|
53275
|
-
if (!
|
|
53288
|
+
const path72 = filePath || this.#snapshotPath;
|
|
53289
|
+
if (!path72) {
|
|
53276
53290
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
53277
53291
|
}
|
|
53278
|
-
const resolvedPath = resolve2(
|
|
53292
|
+
const resolvedPath = resolve2(path72);
|
|
53279
53293
|
await mkdir(dirname3(resolvedPath), { recursive: true });
|
|
53280
53294
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
53281
53295
|
hash: hash2,
|
|
@@ -53907,15 +53921,15 @@ var require_redirect_handler = __commonJS({
|
|
|
53907
53921
|
return;
|
|
53908
53922
|
}
|
|
53909
53923
|
const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
53910
|
-
const
|
|
53911
|
-
const redirectUrlString = `${origin}${
|
|
53924
|
+
const path72 = search ? `${pathname}${search}` : pathname;
|
|
53925
|
+
const redirectUrlString = `${origin}${path72}`;
|
|
53912
53926
|
for (const historyUrl of this.history) {
|
|
53913
53927
|
if (historyUrl.toString() === redirectUrlString) {
|
|
53914
53928
|
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.`);
|
|
53915
53929
|
}
|
|
53916
53930
|
}
|
|
53917
53931
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
53918
|
-
this.opts.path =
|
|
53932
|
+
this.opts.path = path72;
|
|
53919
53933
|
this.opts.origin = origin;
|
|
53920
53934
|
this.opts.query = null;
|
|
53921
53935
|
}
|
|
@@ -55675,10 +55689,10 @@ var require_cache_handler = __commonJS({
|
|
|
55675
55689
|
}
|
|
55676
55690
|
return locationUrl.pathname + locationUrl.search;
|
|
55677
55691
|
}
|
|
55678
|
-
function deleteCachedUri(store, cacheKey,
|
|
55692
|
+
function deleteCachedUri(store, cacheKey, path72) {
|
|
55679
55693
|
deleteCachedValue(store, {
|
|
55680
55694
|
...cacheKey,
|
|
55681
|
-
path:
|
|
55695
|
+
path: path72
|
|
55682
55696
|
});
|
|
55683
55697
|
for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
|
|
55684
55698
|
const method = util2.safeHTTPMethods[i10];
|
|
@@ -55686,7 +55700,7 @@ var require_cache_handler = __commonJS({
|
|
|
55686
55700
|
deleteCachedValue(store, {
|
|
55687
55701
|
...cacheKey,
|
|
55688
55702
|
method,
|
|
55689
|
-
path:
|
|
55703
|
+
path: path72
|
|
55690
55704
|
});
|
|
55691
55705
|
}
|
|
55692
55706
|
}
|
|
@@ -55697,9 +55711,9 @@ var require_cache_handler = __commonJS({
|
|
|
55697
55711
|
}
|
|
55698
55712
|
const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
|
|
55699
55713
|
for (let i10 = 0; i10 < values.length; i10++) {
|
|
55700
|
-
const
|
|
55701
|
-
if (
|
|
55702
|
-
deleteCachedUri(store, cacheKey,
|
|
55714
|
+
const path72 = getSameOriginPath(cacheKey, values[i10]);
|
|
55715
|
+
if (path72 !== void 0) {
|
|
55716
|
+
deleteCachedUri(store, cacheKey, path72);
|
|
55703
55717
|
}
|
|
55704
55718
|
}
|
|
55705
55719
|
}
|
|
@@ -60699,11 +60713,11 @@ var require_fetch = __commonJS({
|
|
|
60699
60713
|
function dispatch({ body }) {
|
|
60700
60714
|
const url2 = requestCurrentURL(request7);
|
|
60701
60715
|
const agent = fetchParams.controller.dispatcher;
|
|
60702
|
-
const
|
|
60716
|
+
const path72 = url2.pathname + url2.search;
|
|
60703
60717
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
60704
60718
|
return new Promise((resolve2, reject) => agent.dispatch(
|
|
60705
60719
|
{
|
|
60706
|
-
path: hasTrailingQuestionMark ? `${
|
|
60720
|
+
path: hasTrailingQuestionMark ? `${path72}?` : path72,
|
|
60707
60721
|
origin: url2.origin,
|
|
60708
60722
|
method: request7.method,
|
|
60709
60723
|
body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
|
|
@@ -61650,9 +61664,9 @@ var require_util5 = __commonJS({
|
|
|
61650
61664
|
}
|
|
61651
61665
|
}
|
|
61652
61666
|
}
|
|
61653
|
-
function validateCookiePath(
|
|
61654
|
-
for (let i10 = 0; i10 <
|
|
61655
|
-
const code =
|
|
61667
|
+
function validateCookiePath(path72) {
|
|
61668
|
+
for (let i10 = 0; i10 < path72.length; ++i10) {
|
|
61669
|
+
const code = path72.charCodeAt(i10);
|
|
61656
61670
|
if (code < 32 || // exclude CTLs (0-31)
|
|
61657
61671
|
code > 126 || // exclude DEL and non-ascii
|
|
61658
61672
|
code === 59) {
|
|
@@ -65000,11 +65014,11 @@ var require_undici = __commonJS({
|
|
|
65000
65014
|
if (typeof opts.path !== "string") {
|
|
65001
65015
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
65002
65016
|
}
|
|
65003
|
-
let
|
|
65017
|
+
let path72 = opts.path;
|
|
65004
65018
|
if (!opts.path.startsWith("/")) {
|
|
65005
|
-
|
|
65019
|
+
path72 = `/${path72}`;
|
|
65006
65020
|
}
|
|
65007
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
65021
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path72);
|
|
65008
65022
|
} else {
|
|
65009
65023
|
if (!opts) {
|
|
65010
65024
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -66420,8 +66434,8 @@ function countOf(usage, key) {
|
|
|
66420
66434
|
const value2 = key in usage ? Reflect.get(usage, key) : void 0;
|
|
66421
66435
|
return typeof value2 === "number" && Number.isFinite(value2) && value2 >= 0 ? value2 : 0;
|
|
66422
66436
|
}
|
|
66423
|
-
function contextTokensOfTranscript(
|
|
66424
|
-
const lines =
|
|
66437
|
+
function contextTokensOfTranscript(text5) {
|
|
66438
|
+
const lines = text5.split("\n");
|
|
66425
66439
|
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
66426
66440
|
const line = lines[index];
|
|
66427
66441
|
if (line === void 0 || line === "") {
|
|
@@ -66472,8 +66486,8 @@ function resumedContextTokens(fs30, params) {
|
|
|
66472
66486
|
}
|
|
66473
66487
|
const projectDir = import_node_path43.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
66474
66488
|
const file2 = target.kind === "id" ? import_node_path43.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs30, projectDir);
|
|
66475
|
-
const
|
|
66476
|
-
return
|
|
66489
|
+
const text5 = file2 === void 0 ? void 0 : fs30.readFileUtf8(file2);
|
|
66490
|
+
return text5 === void 0 ? void 0 : contextTokensOfTranscript(text5);
|
|
66477
66491
|
}
|
|
66478
66492
|
var import_node_path43;
|
|
66479
66493
|
var init_resumeContext = __esm({
|
|
@@ -66736,8 +66750,8 @@ function farmRow(links, builtDirectories, adopted) {
|
|
|
66736
66750
|
const parts = [counted2(links, "link", "links"), counted2(builtDirectories, "built directory", "built directories"), ...adopted === 0 ? [] : [`${String(adopted)} adopted`]];
|
|
66737
66751
|
return { label: "farm", value: "resynced", detail: parts.join(", ") };
|
|
66738
66752
|
}
|
|
66739
|
-
function noteRow(
|
|
66740
|
-
return { label: "note", value:
|
|
66753
|
+
function noteRow(text5) {
|
|
66754
|
+
return { label: "note", value: text5 };
|
|
66741
66755
|
}
|
|
66742
66756
|
var init_launchReport = __esm({
|
|
66743
66757
|
"src/launcher/launchReport.ts"() {
|
|
@@ -67514,9 +67528,9 @@ function flattenToolResult(content) {
|
|
|
67514
67528
|
}
|
|
67515
67529
|
return content.map((block2) => isTextBlock(block2) ? block2.text : NON_TEXT_TOOL_RESULT).join("\n");
|
|
67516
67530
|
}
|
|
67517
|
-
function systemReminder(
|
|
67531
|
+
function systemReminder(text5) {
|
|
67518
67532
|
return `<system-reminder>
|
|
67519
|
-
${
|
|
67533
|
+
${text5}
|
|
67520
67534
|
</system-reminder>`;
|
|
67521
67535
|
}
|
|
67522
67536
|
function turnBlocks(message) {
|
|
@@ -67753,9 +67767,9 @@ function flattenToolResult2(content) {
|
|
|
67753
67767
|
}
|
|
67754
67768
|
return content.map((block2) => isTextBlock(block2) ? block2.text : NON_TEXT_TOOL_RESULT2).join("\n");
|
|
67755
67769
|
}
|
|
67756
|
-
function systemReminder2(
|
|
67770
|
+
function systemReminder2(text5) {
|
|
67757
67771
|
return `<system-reminder>
|
|
67758
|
-
${
|
|
67772
|
+
${text5}
|
|
67759
67773
|
</system-reminder>`;
|
|
67760
67774
|
}
|
|
67761
67775
|
function turnBlocks2(message) {
|
|
@@ -67880,12 +67894,12 @@ var init_translate2 = __esm({
|
|
|
67880
67894
|
function catalogueCachePath(paths, name) {
|
|
67881
67895
|
return import_node_path44.default.join(paths.catalogueDir, `${name}.json`);
|
|
67882
67896
|
}
|
|
67883
|
-
function parseCatalogueCache(
|
|
67884
|
-
if (
|
|
67897
|
+
function parseCatalogueCache(text5) {
|
|
67898
|
+
if (text5 === void 0) {
|
|
67885
67899
|
return void 0;
|
|
67886
67900
|
}
|
|
67887
67901
|
try {
|
|
67888
|
-
const parsed = CatalogueCacheSchema.safeParse(JSON.parse(
|
|
67902
|
+
const parsed = CatalogueCacheSchema.safeParse(JSON.parse(text5));
|
|
67889
67903
|
return parsed.success ? parsed.data : void 0;
|
|
67890
67904
|
} catch {
|
|
67891
67905
|
return void 0;
|
|
@@ -106319,8 +106333,8 @@ var require_utils3 = __commonJS({
|
|
|
106319
106333
|
}
|
|
106320
106334
|
return ind;
|
|
106321
106335
|
}
|
|
106322
|
-
function removeDotSegments(
|
|
106323
|
-
let input2 =
|
|
106336
|
+
function removeDotSegments(path72) {
|
|
106337
|
+
let input2 = path72;
|
|
106324
106338
|
const output2 = [];
|
|
106325
106339
|
let nextSlash = -1;
|
|
106326
106340
|
let len = 0;
|
|
@@ -106729,8 +106743,8 @@ var require_schemes = __commonJS({
|
|
|
106729
106743
|
}
|
|
106730
106744
|
if (wsComponent.resourceName) {
|
|
106731
106745
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
106732
|
-
const
|
|
106733
|
-
wsComponent.path =
|
|
106746
|
+
const path72 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
106747
|
+
wsComponent.path = path72 && path72 !== "/" ? path72 : void 0;
|
|
106734
106748
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
106735
106749
|
wsComponent.resourceName = void 0;
|
|
106736
106750
|
}
|
|
@@ -107682,7 +107696,7 @@ var require_core2 = __commonJS({
|
|
|
107682
107696
|
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
107683
107697
|
if (!errors || errors.length === 0)
|
|
107684
107698
|
return "No errors";
|
|
107685
|
-
return errors.map((e14) => `${dataVar}${e14.instancePath} ${e14.message}`).reduce((
|
|
107699
|
+
return errors.map((e14) => `${dataVar}${e14.instancePath} ${e14.message}`).reduce((text5, msg) => text5 + separator + msg);
|
|
107686
107700
|
}
|
|
107687
107701
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
107688
107702
|
const rules = this.RULES.all;
|
|
@@ -110257,7 +110271,7 @@ var require_dist2 = __commonJS({
|
|
|
110257
110271
|
});
|
|
110258
110272
|
|
|
110259
110273
|
// src/cli.ts
|
|
110260
|
-
var
|
|
110274
|
+
var import_node_path71 = __toESM(require("node:path"), 1);
|
|
110261
110275
|
|
|
110262
110276
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
110263
110277
|
var CommanderError = class extends Error {
|
|
@@ -113370,9 +113384,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
113370
113384
|
* @param {string} [path]
|
|
113371
113385
|
* @return {(string|null|Command)}
|
|
113372
113386
|
*/
|
|
113373
|
-
executableDir(
|
|
113374
|
-
if (
|
|
113375
|
-
this._executableDir =
|
|
113387
|
+
executableDir(path72) {
|
|
113388
|
+
if (path72 === void 0) return this._executableDir;
|
|
113389
|
+
this._executableDir = path72;
|
|
113376
113390
|
return this;
|
|
113377
113391
|
}
|
|
113378
113392
|
/**
|
|
@@ -113389,9 +113403,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
113389
113403
|
helpWidth: context.helpWidth,
|
|
113390
113404
|
outputHasColors: context.hasColors
|
|
113391
113405
|
});
|
|
113392
|
-
const
|
|
113393
|
-
if (context.hasColors) return
|
|
113394
|
-
return this._outputConfiguration.stripColor(
|
|
113406
|
+
const text5 = helper.formatHelp(this, helper);
|
|
113407
|
+
if (context.hasColors) return text5;
|
|
113408
|
+
return this._outputConfiguration.stripColor(text5);
|
|
113395
113409
|
}
|
|
113396
113410
|
/**
|
|
113397
113411
|
* @typedef HelpContext
|
|
@@ -113551,7 +113565,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
113551
113565
|
* @param {(string | Function)} text - string to add, or a function returning a string
|
|
113552
113566
|
* @return {Command} `this` command for chaining
|
|
113553
113567
|
*/
|
|
113554
|
-
addHelpText(position,
|
|
113568
|
+
addHelpText(position, text5) {
|
|
113555
113569
|
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
113556
113570
|
if (!allowedValues.includes(position)) {
|
|
113557
113571
|
throw new Error(`Unexpected value for position to addHelpText.
|
|
@@ -113560,10 +113574,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
113560
113574
|
const helpEvent = `${position}Help`;
|
|
113561
113575
|
this.on(helpEvent, (context) => {
|
|
113562
113576
|
let helpStr;
|
|
113563
|
-
if (typeof
|
|
113564
|
-
helpStr =
|
|
113577
|
+
if (typeof text5 === "function") {
|
|
113578
|
+
helpStr = text5({ error: context.error, command: context.command });
|
|
113565
113579
|
} else {
|
|
113566
|
-
helpStr =
|
|
113580
|
+
helpStr = text5;
|
|
113567
113581
|
}
|
|
113568
113582
|
if (helpStr) {
|
|
113569
113583
|
context.write(`${helpStr}
|
|
@@ -114848,19 +114862,19 @@ function writePools(paths, pools) {
|
|
|
114848
114862
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
114849
114863
|
}
|
|
114850
114864
|
function poolCycleOf(pools, name) {
|
|
114851
|
-
const walk3 = (current,
|
|
114865
|
+
const walk3 = (current, path72) => {
|
|
114852
114866
|
for (const entry of pools[current]?.identities ?? []) {
|
|
114853
114867
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
114854
114868
|
if (nested === void 0) {
|
|
114855
114869
|
continue;
|
|
114856
114870
|
}
|
|
114857
114871
|
if (nested === name) {
|
|
114858
|
-
return [...
|
|
114872
|
+
return [...path72, nested];
|
|
114859
114873
|
}
|
|
114860
|
-
if (
|
|
114874
|
+
if (path72.includes(nested)) {
|
|
114861
114875
|
continue;
|
|
114862
114876
|
}
|
|
114863
|
-
const found = walk3(nested, [...
|
|
114877
|
+
const found = walk3(nested, [...path72, nested]);
|
|
114864
114878
|
if (found !== void 0) {
|
|
114865
114879
|
return found;
|
|
114866
114880
|
}
|
|
@@ -116061,7 +116075,7 @@ function statuslineChangeOf(options) {
|
|
|
116061
116075
|
return void 0;
|
|
116062
116076
|
}
|
|
116063
116077
|
const assignments = (options.statusline ?? []).map(parseStatuslineAssignment);
|
|
116064
|
-
return { set: Object.fromEntries(assignments.map(({ path:
|
|
116078
|
+
return { set: Object.fromEntries(assignments.map(({ path: path72, value: value2 }) => [path72, value2])), unset: options.unsetStatusline ?? [] };
|
|
116065
116079
|
}
|
|
116066
116080
|
function registerProfileCommand(program2, deps) {
|
|
116067
116081
|
const { paths } = deps;
|
|
@@ -118083,9 +118097,9 @@ function listDirOrReport(fs30, configDir, relative, report) {
|
|
|
118083
118097
|
return [];
|
|
118084
118098
|
}
|
|
118085
118099
|
}
|
|
118086
|
-
function parseJson3(
|
|
118100
|
+
function parseJson3(text5) {
|
|
118087
118101
|
try {
|
|
118088
|
-
const value2 = JSON.parse(
|
|
118102
|
+
const value2 = JSON.parse(text5);
|
|
118089
118103
|
return value2;
|
|
118090
118104
|
} catch {
|
|
118091
118105
|
return void 0;
|
|
@@ -118131,11 +118145,11 @@ function readSessionAgentTree(fs30, configDir, ref, options = {}) {
|
|
|
118131
118145
|
}
|
|
118132
118146
|
const agents = /* @__PURE__ */ new Map();
|
|
118133
118147
|
for (const candidate of located) {
|
|
118134
|
-
const
|
|
118135
|
-
if (
|
|
118148
|
+
const text5 = readFileOrReport(fs30, configDir, candidate.metaPath, report);
|
|
118149
|
+
if (text5 === void 0) {
|
|
118136
118150
|
continue;
|
|
118137
118151
|
}
|
|
118138
|
-
const parsed = AgentMetaSchema.safeParse(parseJson3(
|
|
118152
|
+
const parsed = AgentMetaSchema.safeParse(parseJson3(text5));
|
|
118139
118153
|
if (!parsed.success) {
|
|
118140
118154
|
report({ path: candidate.metaPath, reason: "meta file is not a JSON object with an agentType" });
|
|
118141
118155
|
continue;
|
|
@@ -118179,9 +118193,9 @@ function resolveParents(fs30, configDir, agents, report) {
|
|
|
118179
118193
|
if (cached2 !== void 0) {
|
|
118180
118194
|
return cached2;
|
|
118181
118195
|
}
|
|
118182
|
-
const
|
|
118183
|
-
transcriptCache.set(agent.located.id,
|
|
118184
|
-
return
|
|
118196
|
+
const text5 = readFileOrReport(fs30, configDir, agent.located.transcriptPath, report) ?? "";
|
|
118197
|
+
transcriptCache.set(agent.located.id, text5);
|
|
118198
|
+
return text5;
|
|
118185
118199
|
};
|
|
118186
118200
|
const wouldCycle = (child, parent) => {
|
|
118187
118201
|
for (let cursor3 = parent; cursor3 !== void 0; cursor3 = parentOf4.get(cursor3)) {
|
|
@@ -118238,11 +118252,11 @@ function readTasks(fs30, configDir, ownLists, sharedLists, report) {
|
|
|
118238
118252
|
continue;
|
|
118239
118253
|
}
|
|
118240
118254
|
const relative = import_node_path35.default.join(relativeDir, name);
|
|
118241
|
-
const
|
|
118242
|
-
const parsed = TaskFileSchema.safeParse(
|
|
118255
|
+
const text5 = readFileOrReport(fs30, configDir, relative, report);
|
|
118256
|
+
const parsed = TaskFileSchema.safeParse(text5 === void 0 ? void 0 : parseJson3(text5));
|
|
118243
118257
|
if (parsed.success) {
|
|
118244
118258
|
tasks.push(index < ownLists.length ? parsed.data : { ...parsed.data, taskList: scope });
|
|
118245
|
-
} else if (
|
|
118259
|
+
} else if (text5 !== void 0) {
|
|
118246
118260
|
report({ path: relative, reason: "task file is not a task" });
|
|
118247
118261
|
}
|
|
118248
118262
|
}
|
|
@@ -118256,10 +118270,10 @@ function readWorkflowRuns(fs30, configDir, relativeDir, report) {
|
|
|
118256
118270
|
continue;
|
|
118257
118271
|
}
|
|
118258
118272
|
const relative = import_node_path35.default.join(relativeDir, name);
|
|
118259
|
-
const
|
|
118260
|
-
const parsed = WorkflowRunFileSchema.safeParse(
|
|
118273
|
+
const text5 = readFileOrReport(fs30, configDir, relative, report);
|
|
118274
|
+
const parsed = WorkflowRunFileSchema.safeParse(text5 === void 0 ? void 0 : parseJson3(text5));
|
|
118261
118275
|
if (!parsed.success) {
|
|
118262
|
-
if (
|
|
118276
|
+
if (text5 !== void 0) {
|
|
118263
118277
|
report({ path: relative, reason: "workflow run file is not a run record" });
|
|
118264
118278
|
}
|
|
118265
118279
|
continue;
|
|
@@ -119622,8 +119636,8 @@ function finiteNumber(record2, field) {
|
|
|
119622
119636
|
const value2 = record2 === void 0 ? void 0 : record2[field];
|
|
119623
119637
|
return typeof value2 === "number" && Number.isFinite(value2) ? value2 : void 0;
|
|
119624
119638
|
}
|
|
119625
|
-
function excerpt(
|
|
119626
|
-
return
|
|
119639
|
+
function excerpt(text5) {
|
|
119640
|
+
return text5.length <= RC_PENDING_SUMMARY_EXCERPT_CHARS ? text5 : `${text5.slice(0, RC_PENDING_SUMMARY_EXCERPT_CHARS)}...`;
|
|
119627
119641
|
}
|
|
119628
119642
|
function payloadEventsOf(body) {
|
|
119629
119643
|
const parsed = parseJsonObject(body);
|
|
@@ -119728,11 +119742,11 @@ function createRcSessionTracker(deps) {
|
|
|
119728
119742
|
};
|
|
119729
119743
|
const observeExchange = (request7) => {
|
|
119730
119744
|
const method = (request7.method ?? "").toUpperCase();
|
|
119731
|
-
const
|
|
119732
|
-
if (!
|
|
119745
|
+
const path72 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
|
|
119746
|
+
if (!path72.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
119733
119747
|
return void 0;
|
|
119734
119748
|
}
|
|
119735
|
-
const tail =
|
|
119749
|
+
const tail = path72.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
119736
119750
|
const facts = {
|
|
119737
119751
|
oauthAuthorization: oauthAuthorizationOf(request7.headers),
|
|
119738
119752
|
anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
|
|
@@ -119753,8 +119767,8 @@ function createRcSessionTracker(deps) {
|
|
|
119753
119767
|
if (!accepted2 || buffered2 >= RC_CREATE_RESPONSE_CAP_BYTES) {
|
|
119754
119768
|
return;
|
|
119755
119769
|
}
|
|
119756
|
-
const
|
|
119757
|
-
body = body +
|
|
119770
|
+
const text5 = Buffer.from(chunk2).toString("utf8");
|
|
119771
|
+
body = body + text5.slice(0, RC_CREATE_RESPONSE_CAP_BYTES - buffered2);
|
|
119758
119772
|
buffered2 = body.length;
|
|
119759
119773
|
},
|
|
119760
119774
|
onEnd: () => {
|
|
@@ -119972,13 +119986,13 @@ function teeRoutedResponse(response, observer, onSettled) {
|
|
|
119972
119986
|
}
|
|
119973
119987
|
|
|
119974
119988
|
// src/frontdoor/rcWrites.ts
|
|
119975
|
-
function buildRcUserMessagePayload(uuid3, sessionId,
|
|
119989
|
+
function buildRcUserMessagePayload(uuid3, sessionId, text5) {
|
|
119976
119990
|
return {
|
|
119977
119991
|
type: "user",
|
|
119978
119992
|
uuid: uuid3,
|
|
119979
119993
|
session_id: sessionId,
|
|
119980
119994
|
parent_tool_use_id: null,
|
|
119981
|
-
message: { role: "user", content:
|
|
119995
|
+
message: { role: "user", content: text5 }
|
|
119982
119996
|
};
|
|
119983
119997
|
}
|
|
119984
119998
|
function buildRcEventWriteBody(payload) {
|
|
@@ -120043,7 +120057,7 @@ function rcWriteHeaders(credential) {
|
|
|
120043
120057
|
}
|
|
120044
120058
|
return headers;
|
|
120045
120059
|
}
|
|
120046
|
-
async function injectRcUserMessage(deps, sessionId,
|
|
120060
|
+
async function injectRcUserMessage(deps, sessionId, text5) {
|
|
120047
120061
|
const credential = deps.credentialOf(sessionId);
|
|
120048
120062
|
if (credential === void 0) {
|
|
120049
120063
|
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
@@ -120051,7 +120065,7 @@ async function injectRcUserMessage(deps, sessionId, text4) {
|
|
|
120051
120065
|
if (credential.authorization === void 0) {
|
|
120052
120066
|
return noOAuthCredentialResult(sessionId);
|
|
120053
120067
|
}
|
|
120054
|
-
const body = JSON.stringify(buildRcEventWriteBody(buildRcUserMessagePayload(deps.newUuid(), sessionId,
|
|
120068
|
+
const body = JSON.stringify(buildRcEventWriteBody(buildRcUserMessagePayload(deps.newUuid(), sessionId, text5)));
|
|
120055
120069
|
let answer;
|
|
120056
120070
|
try {
|
|
120057
120071
|
answer = await deps.dial.writeEvents(sessionId, rcWriteHeaders(credential), body);
|
|
@@ -120101,8 +120115,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
120101
120115
|
function isRcReadFileEncoding(value2) {
|
|
120102
120116
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value2);
|
|
120103
120117
|
}
|
|
120104
|
-
function buildRcReadFilePayload(requestId,
|
|
120105
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
120118
|
+
function buildRcReadFilePayload(requestId, path72, options) {
|
|
120119
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path72, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
120106
120120
|
}
|
|
120107
120121
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
120108
120122
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -120204,15 +120218,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
120204
120218
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
120205
120219
|
return result.ok ? { ...result, requestId } : result;
|
|
120206
120220
|
}
|
|
120207
|
-
async function readRcSessionFile(deps, sessionId,
|
|
120208
|
-
if (
|
|
120221
|
+
async function readRcSessionFile(deps, sessionId, path72, options) {
|
|
120222
|
+
if (path72 === "") {
|
|
120209
120223
|
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" };
|
|
120210
120224
|
}
|
|
120211
120225
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
120212
120226
|
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" };
|
|
120213
120227
|
}
|
|
120214
120228
|
const requestId = deps.newUuid();
|
|
120215
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
120229
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path72, options), `read ${path72} from session ${sessionId}`);
|
|
120216
120230
|
return result.ok ? { ...result, requestId } : result;
|
|
120217
120231
|
}
|
|
120218
120232
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -120274,9 +120288,9 @@ var RC_PERMISSION_MODE_LIST = RC_PERMISSION_MODES.join(", ");
|
|
|
120274
120288
|
var CONTROL_PATH_PREFIX = "/__agent-shim/rc";
|
|
120275
120289
|
var CONTROL_BODY_CAP_BYTES = 10485760;
|
|
120276
120290
|
function answerJson(response, status, body) {
|
|
120277
|
-
const
|
|
120278
|
-
response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(
|
|
120279
|
-
response.end(
|
|
120291
|
+
const text5 = JSON.stringify(body);
|
|
120292
|
+
response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text5, "utf8")) });
|
|
120293
|
+
response.end(text5);
|
|
120280
120294
|
}
|
|
120281
120295
|
function isJsonObject(value2) {
|
|
120282
120296
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
@@ -120383,11 +120397,11 @@ function createRcControlHandler(deps) {
|
|
|
120383
120397
|
path: "read-file",
|
|
120384
120398
|
read: (body) => {
|
|
120385
120399
|
const session = bodyString(body, "session");
|
|
120386
|
-
const
|
|
120400
|
+
const path72 = bodyString(body, "path");
|
|
120387
120401
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
120388
120402
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
120389
|
-
const refused2 = session === void 0 ||
|
|
120390
|
-
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,
|
|
120403
|
+
const refused2 = session === void 0 || path72 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
120404
|
+
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 } }) };
|
|
120391
120405
|
}
|
|
120392
120406
|
},
|
|
120393
120407
|
{
|
|
@@ -120525,12 +120539,12 @@ function createRcControlHandler(deps) {
|
|
|
120525
120539
|
answerJson(response, HTTP_STATUS.badRequest, { error: "the answer body must be JSON naming a non-empty session id, request id, and an approve boolean" });
|
|
120526
120540
|
return;
|
|
120527
120541
|
}
|
|
120528
|
-
const
|
|
120529
|
-
if (parsed.approve &&
|
|
120542
|
+
const text5 = "text" in parsed && typeof parsed.text === "string" ? parsed.text : void 0;
|
|
120543
|
+
if (parsed.approve && text5 !== void 0 && text5 !== "") {
|
|
120530
120544
|
answerJson(response, HTTP_STATUS.badRequest, { error: "an approval carries no text (the protocol's allow result has no message field); text is the denial message" });
|
|
120531
120545
|
return;
|
|
120532
120546
|
}
|
|
120533
|
-
const result = await deps.answer(parsed.session, parsed.request, { approve: parsed.approve, message: parsed.approve ? void 0 :
|
|
120547
|
+
const result = await deps.answer(parsed.session, parsed.request, { approve: parsed.approve, message: parsed.approve ? void 0 : text5 });
|
|
120534
120548
|
if (result.ok) {
|
|
120535
120549
|
answerJson(response, HTTP_STATUS.ok, { session: parsed.session, request: parsed.request, sequenceNums: result.sequenceNums });
|
|
120536
120550
|
return;
|
|
@@ -120697,9 +120711,9 @@ function requestIdOfBody(body) {
|
|
|
120697
120711
|
}
|
|
120698
120712
|
function frontDoorRcControl(transport, token) {
|
|
120699
120713
|
const headers = { authorization: `Bearer ${token}` };
|
|
120700
|
-
const listAnswerOf = async (
|
|
120714
|
+
const listAnswerOf = async (path72, what) => {
|
|
120701
120715
|
try {
|
|
120702
|
-
return await transport.request({ method: "GET", path:
|
|
120716
|
+
return await transport.request({ method: "GET", path: path72, headers });
|
|
120703
120717
|
} catch (error63) {
|
|
120704
120718
|
throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
|
|
120705
120719
|
}
|
|
@@ -120771,10 +120785,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
120771
120785
|
}
|
|
120772
120786
|
return pending;
|
|
120773
120787
|
};
|
|
120774
|
-
const writeOf = async (
|
|
120788
|
+
const writeOf = async (path72, body, describeFailure2) => {
|
|
120775
120789
|
let answer;
|
|
120776
120790
|
try {
|
|
120777
|
-
answer = await transport.request({ method: "POST", path:
|
|
120791
|
+
answer = await transport.request({ method: "POST", path: path72, headers: { ...headers, "content-type": "application/json" }, body });
|
|
120778
120792
|
} catch (error63) {
|
|
120779
120793
|
return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
|
|
120780
120794
|
}
|
|
@@ -120793,7 +120807,7 @@ function frontDoorRcControl(transport, token) {
|
|
|
120793
120807
|
listSessions: async () => sessionsOf(await listAnswerOf(`${CONTROL_PATH_PREFIX}/sessions`, "listing the door's Remote Control sessions"), "listing the door's Remote Control sessions"),
|
|
120794
120808
|
statusOf: async (sessionId) => statusesOf(await listAnswerOf(`${CONTROL_PATH_PREFIX}/status${sessionQuery(sessionId)}`, "reading the door's Remote Control session status"), "reading the door's Remote Control session status"),
|
|
120795
120809
|
pendingOf: async (sessionId) => pendingOfAnswer(await listAnswerOf(`${CONTROL_PATH_PREFIX}/pending${sessionQuery(sessionId)}`, "listing the door's pending Remote Control control requests"), "listing the door's pending Remote Control control requests"),
|
|
120796
|
-
sendPrompt: async (sessionId,
|
|
120810
|
+
sendPrompt: async (sessionId, text5) => await writeOf(`${CONTROL_PATH_PREFIX}/inject`, JSON.stringify({ session: sessionId, text: text5 }), (status, message) => `injecting into ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
120797
120811
|
answerRequest: async (sessionId, requestId, decision) => await writeOf(
|
|
120798
120812
|
`${CONTROL_PATH_PREFIX}/answer`,
|
|
120799
120813
|
JSON.stringify({ session: sessionId, request: requestId, approve: decision.approve, ...decision.approve || decision.message === void 0 ? {} : { text: decision.message } }),
|
|
@@ -120805,10 +120819,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
120805
120819
|
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}`),
|
|
120806
120820
|
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}`),
|
|
120807
120821
|
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}`),
|
|
120808
|
-
readFile: async (sessionId,
|
|
120822
|
+
readFile: async (sessionId, path72, options) => await writeOf(
|
|
120809
120823
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
120810
|
-
JSON.stringify({ session: sessionId, path:
|
|
120811
|
-
(status, message) => `reading ${
|
|
120824
|
+
JSON.stringify({ session: sessionId, path: path72, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
120825
|
+
(status, message) => `reading ${path72} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
120812
120826
|
),
|
|
120813
120827
|
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}`),
|
|
120814
120828
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -121121,12 +121135,12 @@ function tlsFacts(options) {
|
|
|
121121
121135
|
}
|
|
121122
121136
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
121123
121137
|
const agent = new ExemptTlsAgent();
|
|
121124
|
-
const post = async (
|
|
121138
|
+
const post = async (path72, headers, body) => await new Promise((resolve2, reject) => {
|
|
121125
121139
|
const options = {
|
|
121126
121140
|
host: target.host,
|
|
121127
121141
|
port: target.port,
|
|
121128
121142
|
method: "POST",
|
|
121129
|
-
path:
|
|
121143
|
+
path: path72,
|
|
121130
121144
|
// 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.
|
|
121131
121145
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
121132
121146
|
agent
|
|
@@ -121191,12 +121205,12 @@ function lateRcStreamDial(resolve2) {
|
|
|
121191
121205
|
}
|
|
121192
121206
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
121193
121207
|
const agent = new ExemptTlsAgent();
|
|
121194
|
-
const request7 = async (method,
|
|
121208
|
+
const request7 = async (method, path72, headers, body, signal) => await new Promise((resolve2, reject) => {
|
|
121195
121209
|
const options = {
|
|
121196
121210
|
host: target.host,
|
|
121197
121211
|
port: target.port,
|
|
121198
121212
|
method,
|
|
121199
|
-
path:
|
|
121213
|
+
path: path72,
|
|
121200
121214
|
// 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.
|
|
121201
121215
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
121202
121216
|
agent,
|
|
@@ -121238,9 +121252,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
121238
121252
|
return { status, body: await readAll(response) };
|
|
121239
121253
|
},
|
|
121240
121254
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
121241
|
-
const
|
|
121255
|
+
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)}`;
|
|
121242
121256
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
121243
|
-
const { status, response } = await request7("GET",
|
|
121257
|
+
const { status, response } = await request7("GET", path72, streamHeaders, void 0, signal);
|
|
121244
121258
|
if (!isSuccessful2(status)) {
|
|
121245
121259
|
await readAll(response);
|
|
121246
121260
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -122506,11 +122520,11 @@ var AsyncIteratorClass = class {
|
|
|
122506
122520
|
return this;
|
|
122507
122521
|
}
|
|
122508
122522
|
};
|
|
122509
|
-
function parseEmptyableJSON(
|
|
122510
|
-
if (!
|
|
122523
|
+
function parseEmptyableJSON(text5) {
|
|
122524
|
+
if (!text5) {
|
|
122511
122525
|
return void 0;
|
|
122512
122526
|
}
|
|
122513
|
-
return JSON.parse(
|
|
122527
|
+
return JSON.parse(text5);
|
|
122514
122528
|
}
|
|
122515
122529
|
function stringifyJSON(value2) {
|
|
122516
122530
|
return JSON.stringify(value2);
|
|
@@ -122641,11 +122655,11 @@ function tryOrUndefined(fn2) {
|
|
|
122641
122655
|
return void 0;
|
|
122642
122656
|
}
|
|
122643
122657
|
}
|
|
122644
|
-
function pathToHttpPath(
|
|
122645
|
-
return `/${
|
|
122658
|
+
function pathToHttpPath(path72) {
|
|
122659
|
+
return `/${path72.map(safeEncodeURIComponent).join("/")}`;
|
|
122646
122660
|
}
|
|
122647
|
-
function normalizeHttpPath(
|
|
122648
|
-
const paths =
|
|
122661
|
+
function normalizeHttpPath(path72) {
|
|
122662
|
+
const paths = path72.split("/");
|
|
122649
122663
|
if (paths.at(0) === "") {
|
|
122650
122664
|
paths.shift();
|
|
122651
122665
|
}
|
|
@@ -122830,9 +122844,9 @@ function isPlainObject3(value2) {
|
|
|
122830
122844
|
function getOwn(object3, key) {
|
|
122831
122845
|
return Object.hasOwn(object3, key) ? object3[key] : void 0;
|
|
122832
122846
|
}
|
|
122833
|
-
function get(object3,
|
|
122847
|
+
function get(object3, path72) {
|
|
122834
122848
|
let current = object3;
|
|
122835
|
-
for (const key of
|
|
122849
|
+
for (const key of path72) {
|
|
122836
122850
|
if (!isTypescriptObject(current)) {
|
|
122837
122851
|
return void 0;
|
|
122838
122852
|
}
|
|
@@ -123561,8 +123575,8 @@ function createORPCErrorFromMalformedResponse(options) {
|
|
|
123561
123575
|
}
|
|
123562
123576
|
var INFERRED_MESSAGE_MIN_LENGTH = 1;
|
|
123563
123577
|
var INFERRED_MESSAGE_MAX_LENGTH = 256;
|
|
123564
|
-
function isInferableMessage(
|
|
123565
|
-
return
|
|
123578
|
+
function isInferableMessage(text5) {
|
|
123579
|
+
return text5.length >= INFERRED_MESSAGE_MIN_LENGTH && text5.length <= INFERRED_MESSAGE_MAX_LENGTH;
|
|
123566
123580
|
}
|
|
123567
123581
|
function inferMalformedResponseMessage(response) {
|
|
123568
123582
|
if (typeof response.body === "string" && isInferableMessage(response.body)) {
|
|
@@ -124055,7 +124069,7 @@ function resolveClientRest(rest) {
|
|
|
124055
124069
|
// rest[1] can be undefined if all fields of FriendlyClientOptions are optional
|
|
124056
124070
|
];
|
|
124057
124071
|
}
|
|
124058
|
-
function createORPCClient(link, { path:
|
|
124072
|
+
function createORPCClient(link, { path: path72 = [], ...options } = {}) {
|
|
124059
124073
|
const procedureClient = (...rest) => {
|
|
124060
124074
|
const [input2, callOptions] = resolveClientRest(rest);
|
|
124061
124075
|
const interceptors = [
|
|
@@ -124064,7 +124078,7 @@ function createORPCClient(link, { path: path71 = [], ...options } = {}) {
|
|
|
124064
124078
|
];
|
|
124065
124079
|
return intercept(
|
|
124066
124080
|
interceptors,
|
|
124067
|
-
{ ...callOptions, input: input2, path:
|
|
124081
|
+
{ ...callOptions, input: input2, path: path72 },
|
|
124068
124082
|
({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
|
|
124069
124083
|
);
|
|
124070
124084
|
};
|
|
@@ -124078,7 +124092,7 @@ function createORPCClient(link, { path: path71 = [], ...options } = {}) {
|
|
|
124078
124092
|
if (client === void 0) {
|
|
124079
124093
|
client = createORPCClient(link, {
|
|
124080
124094
|
...options,
|
|
124081
|
-
path: [...
|
|
124095
|
+
path: [...path72, key],
|
|
124082
124096
|
scoped: options.scoped?.[key]
|
|
124083
124097
|
});
|
|
124084
124098
|
cache.set(key, client);
|
|
@@ -124100,24 +124114,24 @@ var BracketNotationSerializer = class {
|
|
|
124100
124114
|
this.internalSerialize(data, "", true, result);
|
|
124101
124115
|
return result;
|
|
124102
124116
|
}
|
|
124103
|
-
internalSerialize(data,
|
|
124117
|
+
internalSerialize(data, path72, isRoot, result) {
|
|
124104
124118
|
if (Array.isArray(data)) {
|
|
124105
124119
|
data.forEach((item, i10) => {
|
|
124106
|
-
this.internalSerialize(item, isRoot ? i10.toString() : `${
|
|
124120
|
+
this.internalSerialize(item, isRoot ? i10.toString() : `${path72}[${i10}]`, false, result);
|
|
124107
124121
|
});
|
|
124108
124122
|
} else if (isPlainObject3(data)) {
|
|
124109
124123
|
for (const key of Object.keys(data)) {
|
|
124110
|
-
this.internalSerialize(data[key], isRoot ? key : `${
|
|
124124
|
+
this.internalSerialize(data[key], isRoot ? key : `${path72}[${key}]`, false, result);
|
|
124111
124125
|
}
|
|
124112
124126
|
} else {
|
|
124113
|
-
result.push([
|
|
124127
|
+
result.push([path72, data]);
|
|
124114
124128
|
}
|
|
124115
124129
|
}
|
|
124116
124130
|
deserialize(serialized) {
|
|
124117
124131
|
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
124118
124132
|
const root = new NullProtoObj();
|
|
124119
|
-
for (const [
|
|
124120
|
-
const segments = this.parsePath(
|
|
124133
|
+
for (const [path72, value2] of serialized) {
|
|
124134
|
+
const segments = this.parsePath(path72);
|
|
124121
124135
|
let currentRef = root;
|
|
124122
124136
|
let nextSegment = segments[0];
|
|
124123
124137
|
for (let i10 = 1; i10 < segments.length; i10++) {
|
|
@@ -124168,13 +124182,13 @@ var BracketNotationSerializer = class {
|
|
|
124168
124182
|
}
|
|
124169
124183
|
return result;
|
|
124170
124184
|
}
|
|
124171
|
-
parsePath(
|
|
124185
|
+
parsePath(path72) {
|
|
124172
124186
|
const segments = [];
|
|
124173
124187
|
let inBrackets = false;
|
|
124174
124188
|
let currentSegment = "";
|
|
124175
|
-
for (let i10 = 0; i10 <
|
|
124176
|
-
const char =
|
|
124177
|
-
const nextChar =
|
|
124189
|
+
for (let i10 = 0; i10 < path72.length; i10++) {
|
|
124190
|
+
const char = path72[i10];
|
|
124191
|
+
const nextChar = path72[i10 + 1];
|
|
124178
124192
|
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
|
|
124179
124193
|
if (nextChar === void 0) {
|
|
124180
124194
|
inBrackets = false;
|
|
@@ -124190,7 +124204,7 @@ var BracketNotationSerializer = class {
|
|
|
124190
124204
|
currentSegment += char;
|
|
124191
124205
|
}
|
|
124192
124206
|
}
|
|
124193
|
-
return inBrackets || segments.length === 0 ? [
|
|
124207
|
+
return inBrackets || segments.length === 0 ? [path72] : segments;
|
|
124194
124208
|
}
|
|
124195
124209
|
};
|
|
124196
124210
|
var INTEGER_PATTERN = /^0$|^[1-9]\d*$/;
|
|
@@ -124763,11 +124777,11 @@ var OpenAPISerializer = class {
|
|
|
124763
124777
|
return json2;
|
|
124764
124778
|
}
|
|
124765
124779
|
const form = new FormData();
|
|
124766
|
-
for (const [
|
|
124780
|
+
for (const [path72, value22] of this.bracketNotation.serialize(json2)) {
|
|
124767
124781
|
if (value22 instanceof Blob) {
|
|
124768
|
-
form.append(
|
|
124782
|
+
form.append(path72, value22);
|
|
124769
124783
|
} else if (value22 !== void 0 && value22 !== null) {
|
|
124770
|
-
form.append(
|
|
124784
|
+
form.append(path72, String(value22));
|
|
124771
124785
|
}
|
|
124772
124786
|
}
|
|
124773
124787
|
return form;
|
|
@@ -124805,30 +124819,30 @@ function isBodylessMethod(method) {
|
|
|
124805
124819
|
return method === "GET" || method === "HEAD";
|
|
124806
124820
|
}
|
|
124807
124821
|
var PARAMETER_NAME_REGEX = /^[\w-]+$/;
|
|
124808
|
-
function getDynamicPathParams(
|
|
124809
|
-
if (!
|
|
124822
|
+
function getDynamicPathParams(path72) {
|
|
124823
|
+
if (!path72.includes("{")) {
|
|
124810
124824
|
return void 0;
|
|
124811
124825
|
}
|
|
124812
|
-
const len =
|
|
124826
|
+
const len = path72.length;
|
|
124813
124827
|
let params;
|
|
124814
124828
|
let index = 1;
|
|
124815
124829
|
while (index < len) {
|
|
124816
124830
|
const segmentStart = index;
|
|
124817
|
-
const slashPos =
|
|
124831
|
+
const slashPos = path72.indexOf("/", index);
|
|
124818
124832
|
const segmentEnd = slashPos === -1 ? len : slashPos;
|
|
124819
|
-
if (segmentEnd > segmentStart &&
|
|
124833
|
+
if (segmentEnd > segmentStart && path72.charCodeAt(segmentStart) === 123 && path72.charCodeAt(segmentEnd - 1) === 125) {
|
|
124820
124834
|
let parameterStart = segmentStart + 1;
|
|
124821
124835
|
let allowsSlash = false;
|
|
124822
|
-
const operator =
|
|
124836
|
+
const operator = path72.charCodeAt(parameterStart);
|
|
124823
124837
|
if (operator === 43) {
|
|
124824
124838
|
allowsSlash = true;
|
|
124825
124839
|
parameterStart++;
|
|
124826
124840
|
}
|
|
124827
|
-
const parameterName =
|
|
124841
|
+
const parameterName = path72.slice(parameterStart, segmentEnd - 1);
|
|
124828
124842
|
if (PARAMETER_NAME_REGEX.test(parameterName)) {
|
|
124829
124843
|
params ??= [];
|
|
124830
124844
|
params.push({
|
|
124831
|
-
segment:
|
|
124845
|
+
segment: path72.slice(segmentStart, segmentEnd),
|
|
124832
124846
|
startIndex: segmentStart,
|
|
124833
124847
|
parameterName,
|
|
124834
124848
|
allowsSlash
|
|
@@ -124871,8 +124885,8 @@ openapi.method = (method) => ({
|
|
|
124871
124885
|
...openapi({ method }),
|
|
124872
124886
|
name: "~openapi/method"
|
|
124873
124887
|
});
|
|
124874
|
-
openapi.path = (
|
|
124875
|
-
...openapi({ path:
|
|
124888
|
+
openapi.path = (path72) => ({
|
|
124889
|
+
...openapi({ path: path72 }),
|
|
124876
124890
|
name: "~openapi/path"
|
|
124877
124891
|
});
|
|
124878
124892
|
openapi.spec = (spec) => ({
|
|
@@ -125733,22 +125747,22 @@ function visitJsonSchemaRefs(value2, visit2, schemaLevel = true, seen = /* @__PU
|
|
|
125733
125747
|
}
|
|
125734
125748
|
}
|
|
125735
125749
|
}
|
|
125736
|
-
function mapJsonSchemaRefs(value2, map2, schemaLevel = true,
|
|
125750
|
+
function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path72 = []) {
|
|
125737
125751
|
if (!value2 || typeof value2 !== "object") {
|
|
125738
125752
|
return value2;
|
|
125739
125753
|
}
|
|
125740
125754
|
if (Array.isArray(value2)) {
|
|
125741
|
-
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...
|
|
125755
|
+
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path72, index]));
|
|
125742
125756
|
}
|
|
125743
125757
|
const result = {};
|
|
125744
125758
|
for (const key of Object.keys(value2)) {
|
|
125745
125759
|
const val = value2[key];
|
|
125746
125760
|
if (key === "$ref" && typeof val === "string") {
|
|
125747
|
-
setOwn(result, key, map2(val, [...
|
|
125761
|
+
setOwn(result, key, map2(val, [...path72, key]));
|
|
125748
125762
|
} else if (!schemaLevel) {
|
|
125749
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...
|
|
125763
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path72, key]));
|
|
125750
125764
|
} else if (JSON_SCHEMA_LOGIC_KEYWORDS.has(key) || JSON_SCHEMA_RECORD_KEYWORDS.has(key)) {
|
|
125751
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...
|
|
125765
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path72, key]));
|
|
125752
125766
|
} else {
|
|
125753
125767
|
setOwn(result, key, val);
|
|
125754
125768
|
}
|
|
@@ -126278,7 +126292,7 @@ function unlazy(maybeLazy) {
|
|
|
126278
126292
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
126279
126293
|
const options = resolveMaybeOptionalOptions(rest);
|
|
126280
126294
|
return async (...[input2, callerOptions]) => {
|
|
126281
|
-
const
|
|
126295
|
+
const path72 = toArray(options.path);
|
|
126282
126296
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
126283
126297
|
const clientContext = callerOptions?.context ?? {};
|
|
126284
126298
|
const context = await value(options.context, clientContext) ?? {};
|
|
@@ -126291,7 +126305,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
126291
126305
|
};
|
|
126292
126306
|
try {
|
|
126293
126307
|
const output2 = await runWithSpan("call_procedure", (span) => {
|
|
126294
|
-
span?.setAttribute("procedure.path",
|
|
126308
|
+
span?.setAttribute("procedure.path", path72);
|
|
126295
126309
|
return intercept(
|
|
126296
126310
|
options.interceptors,
|
|
126297
126311
|
{
|
|
@@ -126299,7 +126313,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
126299
126313
|
// input can be optional if it is undefinable
|
|
126300
126314
|
input: input2,
|
|
126301
126315
|
errors,
|
|
126302
|
-
path:
|
|
126316
|
+
path: path72,
|
|
126303
126317
|
procedure,
|
|
126304
126318
|
signal: callerOptions?.signal,
|
|
126305
126319
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -126550,10 +126564,10 @@ function augmentRouter(router, options) {
|
|
|
126550
126564
|
}
|
|
126551
126565
|
return enhanced;
|
|
126552
126566
|
}
|
|
126553
|
-
function getRouter(router,
|
|
126567
|
+
function getRouter(router, path72) {
|
|
126554
126568
|
let current = router;
|
|
126555
|
-
for (let i10 = 0; i10 <
|
|
126556
|
-
const segment =
|
|
126569
|
+
for (let i10 = 0; i10 < path72.length; i10++) {
|
|
126570
|
+
const segment = path72[i10];
|
|
126557
126571
|
if (!isTypescriptObject(current)) {
|
|
126558
126572
|
return void 0;
|
|
126559
126573
|
}
|
|
@@ -126565,7 +126579,7 @@ function getRouter(router, path71) {
|
|
|
126565
126579
|
continue;
|
|
126566
126580
|
}
|
|
126567
126581
|
const lazied = current;
|
|
126568
|
-
const rest =
|
|
126582
|
+
const rest = path72.slice(i10);
|
|
126569
126583
|
return new Lazy({
|
|
126570
126584
|
...lazied["~orpc"],
|
|
126571
126585
|
async loader() {
|
|
@@ -126580,40 +126594,40 @@ function getRouter(router, path71) {
|
|
|
126580
126594
|
}
|
|
126581
126595
|
return current;
|
|
126582
126596
|
}
|
|
126583
|
-
function walkProcedureContractsSync(router, callback,
|
|
126597
|
+
function walkProcedureContractsSync(router, callback, path72 = []) {
|
|
126584
126598
|
const lazyResults = [];
|
|
126585
|
-
walkProcedureContractsSyncInternal(router, callback,
|
|
126599
|
+
walkProcedureContractsSyncInternal(router, callback, path72.slice(), lazyResults);
|
|
126586
126600
|
return lazyResults;
|
|
126587
126601
|
}
|
|
126588
|
-
function walkProcedureContractsSyncInternal(router, callback,
|
|
126602
|
+
function walkProcedureContractsSyncInternal(router, callback, path72, lazyResults) {
|
|
126589
126603
|
const hiddenContract = getHiddenRouterContract(router);
|
|
126590
126604
|
if (hiddenContract !== void 0) {
|
|
126591
126605
|
router = hiddenContract;
|
|
126592
126606
|
}
|
|
126593
126607
|
if (router instanceof ProcedureContract) {
|
|
126594
|
-
callback(router,
|
|
126608
|
+
callback(router, path72.slice());
|
|
126595
126609
|
return;
|
|
126596
126610
|
}
|
|
126597
126611
|
if (!isTypescriptObject(router)) {
|
|
126598
126612
|
return;
|
|
126599
126613
|
}
|
|
126600
126614
|
for (const [key, value2] of Object.entries(router)) {
|
|
126601
|
-
|
|
126615
|
+
path72.push(key);
|
|
126602
126616
|
if (value2 instanceof Lazy) {
|
|
126603
|
-
lazyResults.push({ router: value2, path:
|
|
126617
|
+
lazyResults.push({ router: value2, path: path72.slice() });
|
|
126604
126618
|
} else {
|
|
126605
|
-
walkProcedureContractsSyncInternal(value2, callback,
|
|
126619
|
+
walkProcedureContractsSyncInternal(value2, callback, path72, lazyResults);
|
|
126606
126620
|
}
|
|
126607
|
-
|
|
126621
|
+
path72.pop();
|
|
126608
126622
|
}
|
|
126609
126623
|
}
|
|
126610
|
-
async function walkProcedureContractsAsync(router, callback,
|
|
126624
|
+
async function walkProcedureContractsAsync(router, callback, path72 = []) {
|
|
126611
126625
|
const hiddenContract = getHiddenRouterContract(router);
|
|
126612
126626
|
if (hiddenContract !== void 0) {
|
|
126613
126627
|
router = hiddenContract;
|
|
126614
126628
|
}
|
|
126615
126629
|
if (router instanceof ProcedureContract) {
|
|
126616
|
-
await callback(router,
|
|
126630
|
+
await callback(router, path72);
|
|
126617
126631
|
return;
|
|
126618
126632
|
}
|
|
126619
126633
|
if (!isTypescriptObject(router)) {
|
|
@@ -126622,9 +126636,9 @@ async function walkProcedureContractsAsync(router, callback, path71 = []) {
|
|
|
126622
126636
|
for (const [key, value2] of Object.entries(router)) {
|
|
126623
126637
|
if (value2 instanceof Lazy) {
|
|
126624
126638
|
const { default: router2 } = await unlazy(value2);
|
|
126625
|
-
await walkProcedureContractsAsync(router2, callback, [...
|
|
126639
|
+
await walkProcedureContractsAsync(router2, callback, [...path72, key]);
|
|
126626
126640
|
} else {
|
|
126627
|
-
await walkProcedureContractsAsync(value2, callback, [...
|
|
126641
|
+
await walkProcedureContractsAsync(value2, callback, [...path72, key]);
|
|
126628
126642
|
}
|
|
126629
126643
|
}
|
|
126630
126644
|
}
|
|
@@ -127110,18 +127124,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
|
|
|
127110
127124
|
}
|
|
127111
127125
|
var OpenAPIGeneratorError = class extends TypeError {
|
|
127112
127126
|
};
|
|
127113
|
-
function toOpenAPIPath(
|
|
127127
|
+
function toOpenAPIPath(path72, dynamicPathParams) {
|
|
127114
127128
|
if (!dynamicPathParams?.length) {
|
|
127115
|
-
return
|
|
127129
|
+
return path72;
|
|
127116
127130
|
}
|
|
127117
127131
|
let normalized = "";
|
|
127118
127132
|
let currentIndex = 0;
|
|
127119
127133
|
for (const param of dynamicPathParams) {
|
|
127120
|
-
normalized +=
|
|
127134
|
+
normalized += path72.slice(currentIndex, param.startIndex);
|
|
127121
127135
|
normalized += `{${param.parameterName}}`;
|
|
127122
127136
|
currentIndex = param.startIndex + param.segment.length;
|
|
127123
127137
|
}
|
|
127124
|
-
normalized +=
|
|
127138
|
+
normalized += path72.slice(currentIndex);
|
|
127125
127139
|
return normalized;
|
|
127126
127140
|
}
|
|
127127
127141
|
function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
|
|
@@ -127555,8 +127569,8 @@ var OpenAPIGenerator = class {
|
|
|
127555
127569
|
customErrorResponseBodySchema: options.customErrorResponseBodySchema
|
|
127556
127570
|
};
|
|
127557
127571
|
const errors = [];
|
|
127558
|
-
await walkProcedureContractsAsync(router, (contract,
|
|
127559
|
-
if (value(options.filter, contract,
|
|
127572
|
+
await walkProcedureContractsAsync(router, (contract, path72) => {
|
|
127573
|
+
if (value(options.filter, contract, path72) === false) {
|
|
127560
127574
|
return;
|
|
127561
127575
|
}
|
|
127562
127576
|
try {
|
|
@@ -127568,7 +127582,7 @@ var OpenAPIGenerator = class {
|
|
|
127568
127582
|
`QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
|
|
127569
127583
|
);
|
|
127570
127584
|
}
|
|
127571
|
-
const postPath = meta3?.path ?? pathToHttpPath(
|
|
127585
|
+
const postPath = meta3?.path ?? pathToHttpPath(path72);
|
|
127572
127586
|
const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
|
|
127573
127587
|
const dynamicPathParams = getDynamicPathParams(httpPath);
|
|
127574
127588
|
const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
|
|
@@ -127577,7 +127591,7 @@ var OpenAPIGenerator = class {
|
|
|
127577
127591
|
operation = meta3.spec;
|
|
127578
127592
|
} else {
|
|
127579
127593
|
operation = {
|
|
127580
|
-
operationId: meta3?.operationId ??
|
|
127594
|
+
operationId: meta3?.operationId ?? path72.join("."),
|
|
127581
127595
|
summary: meta3?.summary,
|
|
127582
127596
|
description: meta3?.description,
|
|
127583
127597
|
deprecated: meta3?.deprecated,
|
|
@@ -127597,7 +127611,7 @@ var OpenAPIGenerator = class {
|
|
|
127597
127611
|
if (!(e14 instanceof OpenAPIGeneratorError)) {
|
|
127598
127612
|
throw e14;
|
|
127599
127613
|
}
|
|
127600
|
-
errors.push(`Procedure at ${
|
|
127614
|
+
errors.push(`Procedure at ${path72.join(".") || "(root)"}: ${e14.message}`);
|
|
127601
127615
|
}
|
|
127602
127616
|
});
|
|
127603
127617
|
if (errors.length) {
|
|
@@ -128299,15 +128313,15 @@ async function toStandardBody(re, options) {
|
|
|
128299
128313
|
throw new TypeError("Failed to read body: body stream already read");
|
|
128300
128314
|
}
|
|
128301
128315
|
if (hint === "json") {
|
|
128302
|
-
const
|
|
128303
|
-
return parseEmptyableJSON(
|
|
128316
|
+
const text5 = await re.text();
|
|
128317
|
+
return parseEmptyableJSON(text5);
|
|
128304
128318
|
}
|
|
128305
128319
|
if (hint === "form-data") {
|
|
128306
128320
|
return await re.formData();
|
|
128307
128321
|
}
|
|
128308
128322
|
if (hint === "url-search-params") {
|
|
128309
|
-
const
|
|
128310
|
-
return new URLSearchParams(
|
|
128323
|
+
const text5 = await re.text();
|
|
128324
|
+
return new URLSearchParams(text5);
|
|
128311
128325
|
}
|
|
128312
128326
|
if (hint === "event-stream") {
|
|
128313
128327
|
return toAsyncIteratorObject(re.body);
|
|
@@ -128444,16 +128458,16 @@ var StandardLink = class {
|
|
|
128444
128458
|
/**
|
|
128445
128459
|
* @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
|
|
128446
128460
|
*/
|
|
128447
|
-
call(
|
|
128448
|
-
return runWithSpan(`${ORPC_NAME}.${
|
|
128461
|
+
call(path72, input2, options) {
|
|
128462
|
+
return runWithSpan(`${ORPC_NAME}.${path72.join("/")}`, (span) => {
|
|
128449
128463
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
128450
|
-
span?.setAttribute("rpc.method",
|
|
128464
|
+
span?.setAttribute("rpc.method", path72.join("."));
|
|
128451
128465
|
if (getTracer() && isAsyncIteratorObject(input2)) {
|
|
128452
128466
|
input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
|
|
128453
128467
|
} else if (getTracer() && input2 instanceof ReadableStream) {
|
|
128454
128468
|
input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
|
|
128455
128469
|
}
|
|
128456
|
-
return intercept(this.interceptors, { ...options, path:
|
|
128470
|
+
return intercept(this.interceptors, { ...options, path: path72, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
128457
128471
|
const tracer = getTracer();
|
|
128458
128472
|
const activeSpan = tracer?.getActiveSpan() ?? span;
|
|
128459
128473
|
let request7 = await runWithSpan(
|
|
@@ -128510,18 +128524,18 @@ var RPCLinkCodec = class {
|
|
|
128510
128524
|
this.headers = options.headers ?? {};
|
|
128511
128525
|
this.serializer = options.serializer ?? new RPCSerializer();
|
|
128512
128526
|
}
|
|
128513
|
-
async encodeInput(input2,
|
|
128514
|
-
let headers = toResolvedStandardHeaders(await value(this.headers, options,
|
|
128527
|
+
async encodeInput(input2, path72, options) {
|
|
128528
|
+
let headers = toResolvedStandardHeaders(await value(this.headers, options, path72, input2));
|
|
128515
128529
|
if (options.lastEventId !== void 0) {
|
|
128516
128530
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
128517
128531
|
}
|
|
128518
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
128519
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
128532
|
+
const expectedMethod = await value(this.expectedMethod, options, path72, input2);
|
|
128533
|
+
const baseUrl = await value(this.baseUrl, options, path72, input2);
|
|
128520
128534
|
const [pathname, search, hash2] = parseStandardUrl(baseUrl);
|
|
128521
|
-
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(
|
|
128535
|
+
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path72)}`;
|
|
128522
128536
|
const serialized = this.serializer.serialize(input2);
|
|
128523
128537
|
if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
128524
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
128538
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path72, input2);
|
|
128525
128539
|
const mergedSearch = new URLSearchParams(search);
|
|
128526
128540
|
mergedSearch.append("data", stringifyJSON(serialized) ?? "");
|
|
128527
128541
|
const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
|
|
@@ -128606,8 +128620,8 @@ var FetchLinkTransport = class {
|
|
|
128606
128620
|
this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
|
|
128607
128621
|
this.toFetchRequestOptions = options.toFetchRequest;
|
|
128608
128622
|
}
|
|
128609
|
-
async send(standardRequest,
|
|
128610
|
-
let origin = await value(this.origin, options,
|
|
128623
|
+
async send(standardRequest, path72, options) {
|
|
128624
|
+
let origin = await value(this.origin, options, path72);
|
|
128611
128625
|
if (origin?.endsWith("/")) {
|
|
128612
128626
|
origin = origin.slice(0, -1);
|
|
128613
128627
|
}
|
|
@@ -128627,7 +128641,7 @@ var FetchLinkTransport = class {
|
|
|
128627
128641
|
}
|
|
128628
128642
|
}
|
|
128629
128643
|
const fetch3 = this.fetch;
|
|
128630
|
-
const response = await fetch3(url2, init, options,
|
|
128644
|
+
const response = await fetch3(url2, init, options, path72);
|
|
128631
128645
|
const standardResponse = toStandardLazyResponse(response);
|
|
128632
128646
|
return standardResponse;
|
|
128633
128647
|
}
|
|
@@ -128783,16 +128797,16 @@ async function toStandardBody2(req, options = {}) {
|
|
|
128783
128797
|
throw new TypeError("Failed to read body: body stream already read or destroyed");
|
|
128784
128798
|
}
|
|
128785
128799
|
if (hint === "json") {
|
|
128786
|
-
const
|
|
128787
|
-
return parseEmptyableJSON(
|
|
128800
|
+
const text5 = await _streamToString(req);
|
|
128801
|
+
return parseEmptyableJSON(text5);
|
|
128788
128802
|
}
|
|
128789
128803
|
const contentType = req.headers["content-type"];
|
|
128790
128804
|
if (hint === "form-data") {
|
|
128791
128805
|
return _streamToFormData(req, contentType);
|
|
128792
128806
|
}
|
|
128793
128807
|
if (hint === "url-search-params") {
|
|
128794
|
-
const
|
|
128795
|
-
return new URLSearchParams(
|
|
128808
|
+
const text5 = await _streamToString(req);
|
|
128809
|
+
return new URLSearchParams(text5);
|
|
128796
128810
|
}
|
|
128797
128811
|
if (hint === "event-stream") {
|
|
128798
128812
|
return toAsyncIteratorObject2(req);
|
|
@@ -129018,14 +129032,14 @@ var StandardHandler = class {
|
|
|
129018
129032
|
span?.setAttribute("url.path", request22.url);
|
|
129019
129033
|
return { matched: false };
|
|
129020
129034
|
}
|
|
129021
|
-
const { path:
|
|
129022
|
-
span?.updateName(`${ORPC_NAME}.${
|
|
129035
|
+
const { path: path72, procedure, decodeInput } = matchedOrNot;
|
|
129036
|
+
span?.updateName(`${ORPC_NAME}.${path72.join("/")}`);
|
|
129023
129037
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
129024
|
-
span?.setAttribute("rpc.method",
|
|
129038
|
+
span?.setAttribute("rpc.method", path72.join("."));
|
|
129025
129039
|
try {
|
|
129026
129040
|
const response = await intercept(
|
|
129027
129041
|
this.interceptors,
|
|
129028
|
-
{ context: context2, prefix: prefix2, request: request22, path:
|
|
129042
|
+
{ context: context2, prefix: prefix2, request: request22, path: path72, procedure, decodeInput },
|
|
129029
129043
|
async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
|
|
129030
129044
|
step2 = "decode_input";
|
|
129031
129045
|
let input2 = await runWithSpan("decode_input", decodeInput2);
|
|
@@ -129059,7 +129073,7 @@ var StandardHandler = class {
|
|
|
129059
129073
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
129060
129074
|
cause: e14
|
|
129061
129075
|
}) : toORPCError(e14);
|
|
129062
|
-
const response = await this.codec.encodeError(error63, procedure,
|
|
129076
|
+
const response = await this.codec.encodeError(error63, procedure, path72, { context: context2, prefix: prefix2 });
|
|
129063
129077
|
return { matched: true, response };
|
|
129064
129078
|
}
|
|
129065
129079
|
}
|
|
@@ -129165,7 +129179,7 @@ var RPCMatcher = class {
|
|
|
129165
129179
|
this.rootRouter = router;
|
|
129166
129180
|
this.index(router);
|
|
129167
129181
|
}
|
|
129168
|
-
index(router,
|
|
129182
|
+
index(router, path72 = []) {
|
|
129169
129183
|
const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
|
|
129170
129184
|
if (!value(this.filter, procedure, procedurePath)) {
|
|
129171
129185
|
return;
|
|
@@ -129176,7 +129190,7 @@ var RPCMatcher = class {
|
|
|
129176
129190
|
// contract-first entries have no implementation yet, resolveProcedure fills it in on demand
|
|
129177
129191
|
procedure: procedure instanceof Procedure ? procedure : void 0
|
|
129178
129192
|
});
|
|
129179
|
-
},
|
|
129193
|
+
}, path72);
|
|
129180
129194
|
for (const result of lazyResults) {
|
|
129181
129195
|
this.pendingLazyRouters.set(pathToHttpPath(result.path), result);
|
|
129182
129196
|
}
|
|
@@ -129308,10 +129322,10 @@ var RPCHandlerCodec = class {
|
|
|
129308
129322
|
}
|
|
129309
129323
|
};
|
|
129310
129324
|
}
|
|
129311
|
-
encodeOutput(output2, procedure,
|
|
129325
|
+
encodeOutput(output2, procedure, path72, options) {
|
|
129312
129326
|
return {
|
|
129313
129327
|
headers: {},
|
|
129314
|
-
status: value(this.outputStatus, output2, procedure,
|
|
129328
|
+
status: value(this.outputStatus, output2, procedure, path72, options) ?? DEFAULT_SUCCESS_STATUS,
|
|
129315
129329
|
body: this.serializer.serialize(output2)
|
|
129316
129330
|
};
|
|
129317
129331
|
}
|
|
@@ -129365,39 +129379,39 @@ function createRouter() {
|
|
|
129365
129379
|
static: new NullProtoObj2()
|
|
129366
129380
|
};
|
|
129367
129381
|
}
|
|
129368
|
-
function scanFirstGroup(
|
|
129382
|
+
function scanFirstGroup(path72) {
|
|
129369
129383
|
let i10 = 0;
|
|
129370
129384
|
let depth = 0;
|
|
129371
|
-
for (; i10 <
|
|
129372
|
-
const c10 =
|
|
129385
|
+
for (; i10 < path72.length; i10++) {
|
|
129386
|
+
const c10 = path72.charCodeAt(i10);
|
|
129373
129387
|
if (c10 === 92) i10++;
|
|
129374
129388
|
else if (c10 === 40) depth++;
|
|
129375
129389
|
else if (c10 === 41 && depth > 0) depth--;
|
|
129376
129390
|
else if (c10 === 123 && depth === 0) break;
|
|
129377
129391
|
}
|
|
129378
|
-
if (i10 >=
|
|
129392
|
+
if (i10 >= path72.length) return;
|
|
129379
129393
|
let j10 = i10 + 1;
|
|
129380
129394
|
depth = 0;
|
|
129381
|
-
for (; j10 <
|
|
129382
|
-
const c10 =
|
|
129395
|
+
for (; j10 < path72.length; j10++) {
|
|
129396
|
+
const c10 = path72.charCodeAt(j10);
|
|
129383
129397
|
if (c10 === 92) j10++;
|
|
129384
129398
|
else if (c10 === 40) depth++;
|
|
129385
129399
|
else if (c10 === 41 && depth > 0) depth--;
|
|
129386
129400
|
else if (c10 === 125 && depth === 0) break;
|
|
129387
129401
|
}
|
|
129388
|
-
if (j10 >=
|
|
129389
|
-
const mod =
|
|
129402
|
+
if (j10 >= path72.length) return;
|
|
129403
|
+
const mod = path72[j10 + 1];
|
|
129390
129404
|
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
129391
129405
|
return [
|
|
129392
|
-
|
|
129393
|
-
|
|
129394
|
-
|
|
129406
|
+
path72.slice(0, i10),
|
|
129407
|
+
path72.slice(i10 + 1, j10),
|
|
129408
|
+
path72.slice(j10 + (hasMod ? 2 : 1)),
|
|
129395
129409
|
hasMod ? mod : void 0
|
|
129396
129410
|
];
|
|
129397
129411
|
}
|
|
129398
|
-
function expandGroupDelimiters(
|
|
129399
|
-
if (!
|
|
129400
|
-
const group = scanFirstGroup(
|
|
129412
|
+
function expandGroupDelimiters(path72) {
|
|
129413
|
+
if (!path72.includes("{")) return;
|
|
129414
|
+
const group = scanFirstGroup(path72);
|
|
129401
129415
|
if (!group) return;
|
|
129402
129416
|
const [pre2, body, suf, mod] = group;
|
|
129403
129417
|
if (!mod) return [pre2 + body + suf];
|
|
@@ -129467,9 +129481,9 @@ function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGr
|
|
|
129467
129481
|
}
|
|
129468
129482
|
return [replaced, nextIndex];
|
|
129469
129483
|
}
|
|
129470
|
-
function encodeEscapes(
|
|
129471
|
-
if (!
|
|
129472
|
-
return
|
|
129484
|
+
function encodeEscapes(path72) {
|
|
129485
|
+
if (!path72.includes("\\")) return path72;
|
|
129486
|
+
return path72.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
|
|
129473
129487
|
}
|
|
129474
129488
|
function segmentKey(segment) {
|
|
129475
129489
|
if (segment.startsWith("**")) return 2;
|
|
@@ -129498,22 +129512,22 @@ function expandModifiers(segments) {
|
|
|
129498
129512
|
return m10[2] === "+" ? [wc2] : [wc2, without];
|
|
129499
129513
|
}
|
|
129500
129514
|
}
|
|
129501
|
-
function normalizePath(
|
|
129502
|
-
if (!
|
|
129515
|
+
function normalizePath(path72) {
|
|
129516
|
+
if (!path72.includes("/.")) return path72;
|
|
129503
129517
|
const r10 = [];
|
|
129504
|
-
for (const s of
|
|
129518
|
+
for (const s of path72.split("/")) if (s === ".") continue;
|
|
129505
129519
|
else if (s === ".." && r10.length > 1) r10.pop();
|
|
129506
129520
|
else r10.push(s);
|
|
129507
129521
|
return r10.join("/") || "/";
|
|
129508
129522
|
}
|
|
129509
|
-
function splitPath(
|
|
129510
|
-
const s =
|
|
129523
|
+
function splitPath(path72) {
|
|
129524
|
+
const s = path72.split("/");
|
|
129511
129525
|
s.shift();
|
|
129512
129526
|
if (s[s.length - 1] === "") s.pop();
|
|
129513
129527
|
return s;
|
|
129514
129528
|
}
|
|
129515
|
-
function splitRoute(
|
|
129516
|
-
const s = splitPath(
|
|
129529
|
+
function splitRoute(path72) {
|
|
129530
|
+
const s = splitPath(path72);
|
|
129517
129531
|
while (s[s.length - 1] === "") s.pop();
|
|
129518
129532
|
return s;
|
|
129519
129533
|
}
|
|
@@ -129529,16 +129543,16 @@ function getMatchParams(segments, paramsMap) {
|
|
|
129529
129543
|
}
|
|
129530
129544
|
return params;
|
|
129531
129545
|
}
|
|
129532
|
-
function addRoute(ctx, method = "",
|
|
129546
|
+
function addRoute(ctx, method = "", path72, data) {
|
|
129533
129547
|
method = method.toUpperCase();
|
|
129534
|
-
if (
|
|
129535
|
-
const groupExpanded = expandGroupDelimiters(
|
|
129548
|
+
if (path72.charCodeAt(0) !== 47) path72 = `/${path72}`;
|
|
129549
|
+
const groupExpanded = expandGroupDelimiters(path72);
|
|
129536
129550
|
if (groupExpanded) {
|
|
129537
129551
|
for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
|
|
129538
129552
|
return;
|
|
129539
129553
|
}
|
|
129540
|
-
|
|
129541
|
-
const segments = splitRoute(
|
|
129554
|
+
path72 = encodeEscapes(path72);
|
|
129555
|
+
const segments = splitRoute(path72);
|
|
129542
129556
|
const expanded = expandModifiers(segments);
|
|
129543
129557
|
if (expanded) {
|
|
129544
129558
|
for (const p of expanded) addRoute(ctx, method, p, data);
|
|
@@ -129629,15 +129643,15 @@ function getParamRegexp(segment, unnamedStart = 0) {
|
|
|
129629
129643
|
const regex2 = _s2.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id2, p) => `(?<${toGroupName(id2)}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i2++)}>`).replace(/\uFFFE(.)/g, (_, c10) => /[.*+?^${}()|[\]\\]/.test(c10) ? `\\${c10}` : c10);
|
|
129630
129644
|
return [new RegExp(`^${regex2}$`), _i2];
|
|
129631
129645
|
}
|
|
129632
|
-
function findRoute(ctx, method = "",
|
|
129633
|
-
if (opts?.normalize)
|
|
129634
|
-
if (
|
|
129635
|
-
const staticNode = ctx.static[
|
|
129646
|
+
function findRoute(ctx, method = "", path72, opts) {
|
|
129647
|
+
if (opts?.normalize) path72 = normalizePath(path72);
|
|
129648
|
+
if (path72.charCodeAt(path72.length - 1) === 47) path72 = path72.slice(0, -1);
|
|
129649
|
+
const staticNode = ctx.static[path72];
|
|
129636
129650
|
if (staticNode && staticNode.methods) {
|
|
129637
129651
|
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
129638
129652
|
if (staticMatch !== void 0) return staticMatch[0];
|
|
129639
129653
|
}
|
|
129640
|
-
const segments = splitPath(
|
|
129654
|
+
const segments = splitPath(path72);
|
|
129641
129655
|
const match = _lookupTree(ctx.root, method, segments, 0);
|
|
129642
129656
|
if (match === void 0) return;
|
|
129643
129657
|
if (opts?.params === false) return match;
|
|
@@ -129837,7 +129851,7 @@ var OpenAPIMatcher = class {
|
|
|
129837
129851
|
this.rootRouter = router;
|
|
129838
129852
|
this.index(router);
|
|
129839
129853
|
}
|
|
129840
|
-
index(router,
|
|
129854
|
+
index(router, path72 = []) {
|
|
129841
129855
|
const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
|
|
129842
129856
|
if (!value(this.filter, contract, path210)) {
|
|
129843
129857
|
return;
|
|
@@ -129852,7 +129866,7 @@ var OpenAPIMatcher = class {
|
|
|
129852
129866
|
contract,
|
|
129853
129867
|
procedure: contract instanceof Procedure ? contract : void 0
|
|
129854
129868
|
});
|
|
129855
|
-
},
|
|
129869
|
+
}, path72);
|
|
129856
129870
|
for (const result of lazyResults) {
|
|
129857
129871
|
const prefix = getOpenAPIMeta(result.router)?.prefix;
|
|
129858
129872
|
this.pendingLazyRouters.add({
|
|
@@ -129939,20 +129953,20 @@ var OpenAPIMatcher = class {
|
|
|
129939
129953
|
return entry.procedure;
|
|
129940
129954
|
}
|
|
129941
129955
|
};
|
|
129942
|
-
function toRou3Pattern(
|
|
129943
|
-
const params = getDynamicPathParams(
|
|
129956
|
+
function toRou3Pattern(path72) {
|
|
129957
|
+
const params = getDynamicPathParams(path72);
|
|
129944
129958
|
if (!params?.length) {
|
|
129945
|
-
return
|
|
129959
|
+
return path72;
|
|
129946
129960
|
}
|
|
129947
129961
|
for (let i10 = params.length - 1; i10 >= 0; i10--) {
|
|
129948
129962
|
const param = params[i10];
|
|
129949
129963
|
const pattern = param.allowsSlash ? `**:${param.parameterName}` : `:${param.parameterName}`;
|
|
129950
|
-
|
|
129964
|
+
path72 = path72.slice(0, param.startIndex) + pattern + path72.slice(param.startIndex + param.segment.length);
|
|
129951
129965
|
}
|
|
129952
|
-
return
|
|
129966
|
+
return path72;
|
|
129953
129967
|
}
|
|
129954
|
-
function toRou3PrefixMatcher(
|
|
129955
|
-
const pattern = toRou3Pattern(
|
|
129968
|
+
function toRou3PrefixMatcher(path72) {
|
|
129969
|
+
const pattern = toRou3Pattern(path72);
|
|
129956
129970
|
return routeToRegExp(pattern === "/" ? "/**" : `${pattern}/**`);
|
|
129957
129971
|
}
|
|
129958
129972
|
function decodeParams(params) {
|
|
@@ -130031,7 +130045,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
130031
130045
|
/**
|
|
130032
130046
|
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
130033
130047
|
*/
|
|
130034
|
-
encodeOutput(output2, procedure,
|
|
130048
|
+
encodeOutput(output2, procedure, path72) {
|
|
130035
130049
|
const meta3 = getOpenAPIMeta(procedure);
|
|
130036
130050
|
const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
|
|
130037
130051
|
const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
|
|
@@ -130044,7 +130058,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
130044
130058
|
}
|
|
130045
130059
|
if (!isValidDetailedOutput(output2)) {
|
|
130046
130060
|
throw new TypeError(`
|
|
130047
|
-
Invalid "detailed" output structure returned by procedure (${
|
|
130061
|
+
Invalid "detailed" output structure returned by procedure (${path72.join(".")}):
|
|
130048
130062
|
\u2022 Expected an object with optional properties:
|
|
130049
130063
|
- status (number <400)
|
|
130050
130064
|
- headers (object)
|
|
@@ -130612,7 +130626,7 @@ function profileValue(name, paths) {
|
|
|
130612
130626
|
function createConfigApiRouter(deps) {
|
|
130613
130627
|
const authed = doorApiAuth(deps.expectedToken);
|
|
130614
130628
|
const { paths } = deps;
|
|
130615
|
-
const route = (
|
|
130629
|
+
const route = (path72, summary) => authed.meta(openapi({ method: "POST", path: path72, summary, tags: [CONFIG_API_TAG] }));
|
|
130616
130630
|
return {
|
|
130617
130631
|
config: {
|
|
130618
130632
|
identity: {
|
|
@@ -131572,16 +131586,16 @@ function walk2(body, hashing, parentAfter) {
|
|
|
131572
131586
|
continue;
|
|
131573
131587
|
}
|
|
131574
131588
|
const isKey = kind === STRING && depth >= 1 && expectKey[depth - 1] === true;
|
|
131575
|
-
const
|
|
131576
|
-
if (isKey &&
|
|
131589
|
+
const text5 = isKey ? body.toString("latin1", start, end) : void 0;
|
|
131590
|
+
if (isKey && text5 === CACHE_MARKER_KEY) {
|
|
131577
131591
|
skipNextValue = true;
|
|
131578
131592
|
continue;
|
|
131579
131593
|
}
|
|
131580
131594
|
if (depth === 1 && isKey) {
|
|
131581
|
-
topKey =
|
|
131595
|
+
topKey = text5;
|
|
131582
131596
|
}
|
|
131583
131597
|
const closesMessages = kind === CLOSE && inMessages && depth === MESSAGES_ARRAY_DEPTH;
|
|
131584
|
-
if (hashing && !closesMessages && !(depth === 1 && isKey && !THREAD_MEMBER_KEYS.has(
|
|
131598
|
+
if (hashing && !closesMessages && !(depth === 1 && isKey && !THREAD_MEMBER_KEYS.has(text5 ?? ""))) {
|
|
131585
131599
|
const target = inMessages ? messages : depth >= 1 && topKey !== void 0 && THREAD_MEMBER_KEYS.has(topKey) ? thread : void 0;
|
|
131586
131600
|
if (target !== void 0) {
|
|
131587
131601
|
target.update(body.subarray(start, end));
|
|
@@ -132555,8 +132569,8 @@ function createCodexRoute(ports) {
|
|
|
132555
132569
|
if (!parsed.success) {
|
|
132556
132570
|
return errorResponse(HTTP_STATUS.badRequest, "not a count_tokens request");
|
|
132557
132571
|
}
|
|
132558
|
-
const
|
|
132559
|
-
return { status: HTTP_STATUS.ok, headers: { "Content-Type": "application/json" }, body: JSON.stringify({ input_tokens: Math.ceil(
|
|
132572
|
+
const text5 = JSON.stringify({ system: parsed.data.system, messages: parsed.data.messages, tools: parsed.data.tools });
|
|
132573
|
+
return { status: HTTP_STATUS.ok, headers: { "Content-Type": "application/json" }, body: JSON.stringify({ input_tokens: Math.ceil(text5.length / CHARS_PER_TOKEN) }) };
|
|
132560
132574
|
};
|
|
132561
132575
|
return async (request7) => {
|
|
132562
132576
|
if (request7.method === "GET" && request7.path === "/healthz") {
|
|
@@ -132639,8 +132653,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
132639
132653
|
request7.body.resume();
|
|
132640
132654
|
return;
|
|
132641
132655
|
}
|
|
132642
|
-
const
|
|
132643
|
-
const translated = { method: request7.method, path:
|
|
132656
|
+
const path72 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
132657
|
+
const translated = { method: request7.method, path: path72, body, signal: request7.signal };
|
|
132644
132658
|
const routed = await route(translated);
|
|
132645
132659
|
if (request7.signal.aborted) {
|
|
132646
132660
|
return;
|
|
@@ -133261,8 +133275,8 @@ function createAntigravityRouteMount(ports, upstreamBase, provider) {
|
|
|
133261
133275
|
request7.body.resume();
|
|
133262
133276
|
return;
|
|
133263
133277
|
}
|
|
133264
|
-
const
|
|
133265
|
-
const translated = { method: request7.method, path:
|
|
133278
|
+
const path72 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133279
|
+
const translated = { method: request7.method, path: path72, body, signal: request7.signal };
|
|
133266
133280
|
const routed = await route(translated);
|
|
133267
133281
|
if (request7.signal.aborted) {
|
|
133268
133282
|
return;
|
|
@@ -133303,7 +133317,7 @@ function createPassthroughRoute(name, target) {
|
|
|
133303
133317
|
headroomUpstream: target.headroomUpstream,
|
|
133304
133318
|
serve: async (request7, response) => {
|
|
133305
133319
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
133306
|
-
const
|
|
133320
|
+
const path72 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
133307
133321
|
const headers = forwardableHeaders(request7.headers);
|
|
133308
133322
|
delete headers.host;
|
|
133309
133323
|
await new Promise((resolve2) => {
|
|
@@ -133311,7 +133325,7 @@ function createPassthroughRoute(name, target) {
|
|
|
133311
133325
|
host: base.hostname,
|
|
133312
133326
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
133313
133327
|
method: request7.method,
|
|
133314
|
-
path: `${basePath}${
|
|
133328
|
+
path: `${basePath}${path72}${incoming.search}`,
|
|
133315
133329
|
headers,
|
|
133316
133330
|
agent
|
|
133317
133331
|
};
|
|
@@ -133417,28 +133431,28 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
133417
133431
|
const body = request7.body;
|
|
133418
133432
|
const head = [];
|
|
133419
133433
|
let seen = 0;
|
|
133420
|
-
let
|
|
133434
|
+
let text5 = "";
|
|
133421
133435
|
let decided = false;
|
|
133422
133436
|
let ended = false;
|
|
133423
133437
|
let error63;
|
|
133424
133438
|
const replay = new import_node_stream2.PassThrough();
|
|
133425
|
-
const modelIn = () => /"model"\s*:\s*"([^"]+)"/.exec(
|
|
133439
|
+
const modelIn = () => /"model"\s*:\s*"([^"]+)"/.exec(text5)?.[1];
|
|
133426
133440
|
const settled = new Promise((resolve2) => {
|
|
133427
133441
|
const settle2 = () => {
|
|
133428
133442
|
const model = modelIn();
|
|
133429
|
-
const hasImage = /"type"\s*:\s*"image"/.test(
|
|
133443
|
+
const hasImage = /"type"\s*:\s*"image"/.test(text5);
|
|
133430
133444
|
for (const chunk2 of head) {
|
|
133431
133445
|
replay.write(chunk2);
|
|
133432
133446
|
}
|
|
133433
|
-
const maxTokens = /"max_tokens"\s*:\s*([0-9]+)/.exec(
|
|
133447
|
+
const maxTokens = /"max_tokens"\s*:\s*([0-9]+)/.exec(text5)?.[1];
|
|
133434
133448
|
resolve2({
|
|
133435
133449
|
...model === void 0 ? {} : { model },
|
|
133436
133450
|
hasImage,
|
|
133437
|
-
toolsPresent: /"tools"\s*:\s*\[\s*\{/.test(
|
|
133438
|
-
thinking: /"thinking"\s*:\s*\{\s*"type"\s*:\s*"enabled"/.test(
|
|
133451
|
+
toolsPresent: /"tools"\s*:\s*\[\s*\{/.test(text5),
|
|
133452
|
+
thinking: /"thinking"\s*:\s*\{\s*"type"\s*:\s*"enabled"/.test(text5),
|
|
133439
133453
|
...maxTokens === void 0 ? {} : { maxTokens: Number(maxTokens) },
|
|
133440
133454
|
isCountTokens: request7.url.includes("/v1/messages/count_tokens"),
|
|
133441
|
-
...wholeBody ? { whole: true, text:
|
|
133455
|
+
...wholeBody ? { whole: true, text: text5 } : {},
|
|
133442
133456
|
replayed: { ...request7, body: replay }
|
|
133443
133457
|
});
|
|
133444
133458
|
};
|
|
@@ -133454,7 +133468,7 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
133454
133468
|
}
|
|
133455
133469
|
head.push(chunk2);
|
|
133456
133470
|
seen += chunk2.length;
|
|
133457
|
-
|
|
133471
|
+
text5 += chunk2.toString("utf8");
|
|
133458
133472
|
if (!wholeBody && (modelIn() !== void 0 || seen >= REQUEST_SCAN_CAP_BYTES)) {
|
|
133459
133473
|
decided = true;
|
|
133460
133474
|
settle2();
|
|
@@ -133483,13 +133497,13 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
133483
133497
|
}
|
|
133484
133498
|
|
|
133485
133499
|
// src/frontdoor/providerRoute.ts
|
|
133486
|
-
var isRcSelfHostPath = (
|
|
133500
|
+
var isRcSelfHostPath = (path72) => path72 === "/v1/code/sessions" || path72.startsWith("/v1/code/sessions/") || path72 === "/v1/sessions" || path72.startsWith("/v1/sessions/");
|
|
133487
133501
|
function scopeSessionProviderPath(request7) {
|
|
133488
133502
|
if (request7.session.provider === void 0) {
|
|
133489
133503
|
return request7;
|
|
133490
133504
|
}
|
|
133491
|
-
const
|
|
133492
|
-
if (!
|
|
133505
|
+
const path72 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133506
|
+
if (!path72.startsWith("/v1/") || isRcSelfHostPath(path72)) {
|
|
133493
133507
|
return request7;
|
|
133494
133508
|
}
|
|
133495
133509
|
return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
|
|
@@ -133613,13 +133627,13 @@ function createProviderRouteResolver(deps) {
|
|
|
133613
133627
|
return route;
|
|
133614
133628
|
};
|
|
133615
133629
|
const resolve2 = (request7) => {
|
|
133616
|
-
const
|
|
133617
|
-
const scoped = parseProviderPath(
|
|
133630
|
+
const path72 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133631
|
+
const scoped = parseProviderPath(path72);
|
|
133618
133632
|
if (scoped === void 0) {
|
|
133619
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
133633
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path72)) {
|
|
133620
133634
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
133621
133635
|
}
|
|
133622
|
-
return
|
|
133636
|
+
return path72.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path72}` };
|
|
133623
133637
|
}
|
|
133624
133638
|
const { provider } = scoped;
|
|
133625
133639
|
let definition;
|
|
@@ -133711,8 +133725,8 @@ function createProviderRouteResolver(deps) {
|
|
|
133711
133725
|
let modelChoice;
|
|
133712
133726
|
const visited = /* @__PURE__ */ new Set();
|
|
133713
133727
|
for (; ; ) {
|
|
133714
|
-
const
|
|
133715
|
-
const scoped = parseProviderPath(
|
|
133728
|
+
const path72 = new URL(current.url, "http://127.0.0.1").pathname;
|
|
133729
|
+
const scoped = parseProviderPath(path72);
|
|
133716
133730
|
const providerName = scoped?.provider ?? current.session.provider;
|
|
133717
133731
|
if (providerName !== void 0 && visited.has(providerName)) {
|
|
133718
133732
|
return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
|
|
@@ -133727,7 +133741,7 @@ function createProviderRouteResolver(deps) {
|
|
|
133727
133741
|
} catch {
|
|
133728
133742
|
routes = void 0;
|
|
133729
133743
|
}
|
|
133730
|
-
const resolvesNames = !nameResolved && !isRcSelfHostPath(
|
|
133744
|
+
const resolvesNames = !nameResolved && !isRcSelfHostPath(path72);
|
|
133731
133745
|
if (resolvesNames) {
|
|
133732
133746
|
const scan2 = await scanRequestHead(current, true);
|
|
133733
133747
|
if (scan2.replayed === void 0) {
|
|
@@ -133766,7 +133780,7 @@ function createProviderRouteResolver(deps) {
|
|
|
133766
133780
|
}
|
|
133767
133781
|
if (routed.provider !== providerName) {
|
|
133768
133782
|
const scopedPrefix = providerName === void 0 ? void 0 : `${PROVIDER_PATH_PREFIX}${encodeURIComponent(providerName)}`;
|
|
133769
|
-
const rest2 = scopedPrefix !== void 0 &&
|
|
133783
|
+
const rest2 = scopedPrefix !== void 0 && path72.startsWith(scopedPrefix) ? path72.slice(scopedPrefix.length) : path72;
|
|
133770
133784
|
const query2 = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
133771
133785
|
const carried = replay;
|
|
133772
133786
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(routed.provider)}${rest2}${query2}`, body: carried.body, headers: carried.headers };
|
|
@@ -133820,7 +133834,7 @@ function createProviderRouteResolver(deps) {
|
|
|
133820
133834
|
const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
133821
133835
|
replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
|
|
133822
133836
|
}
|
|
133823
|
-
const rest = scoped === void 0 ?
|
|
133837
|
+
const rest = scoped === void 0 ? path72 : path72.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
|
|
133824
133838
|
const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
133825
133839
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
|
|
133826
133840
|
}
|
|
@@ -133958,9 +133972,9 @@ function growthBookFeatures() {
|
|
|
133958
133972
|
};
|
|
133959
133973
|
}
|
|
133960
133974
|
var answerServerJson = (response, status, body) => {
|
|
133961
|
-
const
|
|
133962
|
-
response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(
|
|
133963
|
-
response.end(
|
|
133975
|
+
const text5 = JSON.stringify(body);
|
|
133976
|
+
response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text5, "utf8")) });
|
|
133977
|
+
response.end(text5);
|
|
133964
133978
|
};
|
|
133965
133979
|
function createRcSelfHostLocal(deps) {
|
|
133966
133980
|
return {
|
|
@@ -134171,8 +134185,8 @@ function formatRcPendingList(pending) {
|
|
|
134171
134185
|
}
|
|
134172
134186
|
return pending.map((request7) => `${request7.sessionId} ${request7.requestId} ${request7.type}${request7.summary === "" ? "" : ` ${request7.summary}`} observed ${new Date(request7.observedAt).toISOString()}`);
|
|
134173
134187
|
}
|
|
134174
|
-
function eventExcerpt(
|
|
134175
|
-
return
|
|
134188
|
+
function eventExcerpt(text5) {
|
|
134189
|
+
return text5.length <= RC_PENDING_SUMMARY_EXCERPT_CHARS ? text5 : `${text5.slice(0, RC_PENDING_SUMMARY_EXCERPT_CHARS)}...`;
|
|
134176
134190
|
}
|
|
134177
134191
|
var PERCENT_SCALE = 100;
|
|
134178
134192
|
var MS_PER_SECOND14 = 1e3;
|
|
@@ -135871,9 +135885,9 @@ data: ${JSON.stringify(envelope)}
|
|
|
135871
135885
|
};
|
|
135872
135886
|
const sessionRow = (session) => ({ id: session.id, title: session.title, created_at: new Date(session.createdAt).toISOString(), status: "active", conversation_id: session.conversation.id });
|
|
135873
135887
|
const answerJson2 = async (response, status, body, extraHeaders = {}) => {
|
|
135874
|
-
const
|
|
135875
|
-
response.start(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(
|
|
135876
|
-
await response.write(
|
|
135888
|
+
const text5 = JSON.stringify(body);
|
|
135889
|
+
response.start(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text5, "utf8")), ...extraHeaders });
|
|
135890
|
+
await response.write(text5);
|
|
135877
135891
|
response.end();
|
|
135878
135892
|
};
|
|
135879
135893
|
const noCredential = async (response) => {
|
|
@@ -136275,8 +136289,8 @@ function createSseParser() {
|
|
|
136275
136289
|
let dataLines = [];
|
|
136276
136290
|
let seenAnyText = false;
|
|
136277
136291
|
return {
|
|
136278
|
-
write: (
|
|
136279
|
-
let incoming =
|
|
136292
|
+
write: (text5) => {
|
|
136293
|
+
let incoming = text5;
|
|
136280
136294
|
if (!seenAnyText) {
|
|
136281
136295
|
seenAnyText = true;
|
|
136282
136296
|
incoming = incoming.charCodeAt(0) === SSE_BYTE_ORDER_MARK ? incoming.slice(1) : incoming;
|
|
@@ -137169,7 +137183,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, retire, trackTun
|
|
|
137169
137183
|
startProviderListener: async (preferredPort) => {
|
|
137170
137184
|
const authority = loadCa();
|
|
137171
137185
|
const rcDial = rcSelfHost ? lateRcEventDial(rcSelfHostDialTarget) : realRcEventDial();
|
|
137172
|
-
const rcInject = async (sessionId,
|
|
137186
|
+
const rcInject = async (sessionId, text5) => await injectRcUserMessage({ credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto25.randomUUID }, sessionId, text5);
|
|
137173
137187
|
const rcAnswer = async (sessionId, requestId, decision) => await answerRcControlRequest({ credentialOf: rcTracker.credentialOf, pendingOf: (id2) => rcTracker.pendingOf(id2), completePending: rcTracker.completePending, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial }, sessionId, requestId, decision);
|
|
137174
137188
|
const rcControlRequestDeps = { credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto25.randomUUID };
|
|
137175
137189
|
const rcInterrupt = async (sessionId) => await interruptRcSession(rcControlRequestDeps, sessionId);
|
|
@@ -137455,7 +137469,7 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
137455
137469
|
// src/statusline/commands.ts
|
|
137456
137470
|
var import_node_child_process8 = require("node:child_process");
|
|
137457
137471
|
var import_node_os13 = __toESM(require("node:os"), 1);
|
|
137458
|
-
var
|
|
137472
|
+
var import_node_path62 = __toESM(require("node:path"), 1);
|
|
137459
137473
|
init_commandDeps();
|
|
137460
137474
|
init_statusline();
|
|
137461
137475
|
init_providersStore();
|
|
@@ -137927,9 +137941,9 @@ function usedBytesFromVmStat(output2) {
|
|
|
137927
137941
|
}
|
|
137928
137942
|
return (Number(active) + Number(wired) + Number(compressed)) * Number(pageSize);
|
|
137929
137943
|
}
|
|
137930
|
-
function memoryUseFromMeminfo(
|
|
137931
|
-
const totalKibibytes = /^MemTotal:\s+(\d+)\s+kB/m.exec(
|
|
137932
|
-
const availableKibibytes = /^MemAvailable:\s+(\d+)\s+kB/m.exec(
|
|
137944
|
+
function memoryUseFromMeminfo(text5) {
|
|
137945
|
+
const totalKibibytes = /^MemTotal:\s+(\d+)\s+kB/m.exec(text5)?.[1];
|
|
137946
|
+
const availableKibibytes = /^MemAvailable:\s+(\d+)\s+kB/m.exec(text5)?.[1];
|
|
137933
137947
|
if (totalKibibytes === void 0 || availableKibibytes === void 0) {
|
|
137934
137948
|
return void 0;
|
|
137935
137949
|
}
|
|
@@ -138028,11 +138042,11 @@ function realStatuslinePorts(env, stateDirectory) {
|
|
|
138028
138042
|
return void 0;
|
|
138029
138043
|
}
|
|
138030
138044
|
},
|
|
138031
|
-
writeText: (target,
|
|
138045
|
+
writeText: (target, text5) => {
|
|
138032
138046
|
const temporary = import_node_path56.default.join(import_node_path56.default.dirname(target), `.${import_node_path56.default.basename(target)}.${String(process.pid)}.tmp`);
|
|
138033
138047
|
try {
|
|
138034
138048
|
import_node_fs22.default.mkdirSync(import_node_path56.default.dirname(target), { recursive: true, mode: STATE_DIRECTORY_MODE });
|
|
138035
|
-
import_node_fs22.default.writeFileSync(temporary,
|
|
138049
|
+
import_node_fs22.default.writeFileSync(temporary, text5, { mode: STATE_FILE_MODE });
|
|
138036
138050
|
import_node_fs22.default.renameSync(temporary, target);
|
|
138037
138051
|
} catch {
|
|
138038
138052
|
discard(temporary);
|
|
@@ -138054,13 +138068,13 @@ var ESCAPE = String.fromCharCode(ESCAPE_CHAR_CODE);
|
|
|
138054
138068
|
var BELL = "\\u0007";
|
|
138055
138069
|
var ESCAPE_SEQUENCE_PATTERN = [`${ESCAPE}\\[[0-?]*[ -/]*[@-~]`, `${ESCAPE}\\][^${BELL}${ESCAPE}]*(?:${BELL}|${ESCAPE}\\\\)?`, `${ESCAPE}[@-Z\\\\-_]`].join("|");
|
|
138056
138070
|
var SPLIT_ON_ESCAPES = new RegExp(`(${ESCAPE_SEQUENCE_PATTERN})`);
|
|
138057
|
-
function visibleLength(
|
|
138058
|
-
return stringWidth(
|
|
138071
|
+
function visibleLength(text5) {
|
|
138072
|
+
return stringWidth(text5);
|
|
138059
138073
|
}
|
|
138060
|
-
function truncateToColumns(
|
|
138074
|
+
function truncateToColumns(text5, columns) {
|
|
138061
138075
|
let used = 0;
|
|
138062
138076
|
let kept = "";
|
|
138063
|
-
|
|
138077
|
+
text5.split(SPLIT_ON_ESCAPES).forEach((part, index) => {
|
|
138064
138078
|
if (index % 2 === 1) {
|
|
138065
138079
|
kept += part;
|
|
138066
138080
|
return;
|
|
@@ -138102,8 +138116,8 @@ function measureGrid(rows, separatorLength, baseBarCells) {
|
|
|
138102
138116
|
const fixed = [...prefixWidths, ...suffixWidths].reduce((total, width) => total + width, 0) + columns * (baseBarCells + BRACKET_COLUMNS);
|
|
138103
138117
|
return { rows, columns, prefixWidths, suffixWidths, baseWidth: fixed + separatorLength * (columns - 1) };
|
|
138104
138118
|
}
|
|
138105
|
-
function padTo(
|
|
138106
|
-
return
|
|
138119
|
+
function padTo(text5, width) {
|
|
138120
|
+
return text5 + " ".repeat(Math.max(0, width - visibleLength(text5)));
|
|
138107
138121
|
}
|
|
138108
138122
|
function renderGrid(grid, maxWidth, separator, baseBarCells) {
|
|
138109
138123
|
const separatorLength = visibleLength(separator);
|
|
@@ -138219,19 +138233,19 @@ init_blank();
|
|
|
138219
138233
|
init_graphemes();
|
|
138220
138234
|
var ESCAPE_SEQUENCES = new RegExp(ESCAPE_SEQUENCE_PATTERN, "g");
|
|
138221
138235
|
var CONTROL_AND_BIDI = /[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u206a-\u206f]/gu;
|
|
138222
|
-
function sanitiseDisplayText(
|
|
138223
|
-
return
|
|
138236
|
+
function sanitiseDisplayText(text5) {
|
|
138237
|
+
return text5.replace(ESCAPE_SEQUENCES, "").replace(CONTROL_AND_BIDI, "");
|
|
138224
138238
|
}
|
|
138225
|
-
function boundedDisplayText(
|
|
138226
|
-
return graphemesOf(sanitiseDisplayText(
|
|
138239
|
+
function boundedDisplayText(text5) {
|
|
138240
|
+
return graphemesOf(sanitiseDisplayText(text5).trim()).slice(0, MAX_DISPLAY_TEXT_CHARS).join("").trim();
|
|
138227
138241
|
}
|
|
138228
138242
|
var TAG_SEQUENCE2 = "\\u{1F3F4}[\\u{E0020}-\\u{E007E}]+\\u{E007F}";
|
|
138229
138243
|
var INVISIBLE_FORMAT = new RegExp(`(${TAG_SEQUENCE2})|(?![\\u200C\\u200D])\\p{Cf}`, "gu");
|
|
138230
138244
|
var LINE_SEPARATORS = /[\u2028\u2029]/gu;
|
|
138231
138245
|
var HANGUL_JAMO = "\\u1100-\\u115E\\u1161-\\u11FF\\uA960-\\uA97F\\uD7B0-\\uD7FF";
|
|
138232
138246
|
var STANDALONE_HANGUL_FILLER = new RegExp(`(?<![${HANGUL_JAMO}])[\\u115F\\u1160](?![${HANGUL_JAMO}])`, "gu");
|
|
138233
|
-
function visibleDisplayText(
|
|
138234
|
-
const cleaned = sanitiseDisplayText(
|
|
138247
|
+
function visibleDisplayText(text5) {
|
|
138248
|
+
const cleaned = sanitiseDisplayText(text5).replace(LINE_SEPARATORS, "").replace(BLANK_CELLS, " ").replace(STANDALONE_HANGUL_FILLER, " ").replace(INVISIBLE_FORMAT, (_match, tagSequence) => tagSequence ?? "");
|
|
138235
138249
|
return graphemesOf(cleaned).map((grapheme) => {
|
|
138236
138250
|
const body = grapheme.replace(/^ /u, "");
|
|
138237
138251
|
const space = body === grapheme ? "" : " ";
|
|
@@ -138302,13 +138316,13 @@ function localDay(nowMs) {
|
|
|
138302
138316
|
const date5 = new Date(nowMs);
|
|
138303
138317
|
return `${String(date5.getFullYear())}-${String(date5.getMonth() + 1).padStart(2, "0")}-${String(date5.getDate()).padStart(2, "0")}`;
|
|
138304
138318
|
}
|
|
138305
|
-
function parseEntry3(
|
|
138306
|
-
if (
|
|
138319
|
+
function parseEntry3(text5) {
|
|
138320
|
+
if (text5 === void 0) {
|
|
138307
138321
|
return void 0;
|
|
138308
138322
|
}
|
|
138309
138323
|
let raw;
|
|
138310
138324
|
try {
|
|
138311
|
-
raw = JSON.parse(
|
|
138325
|
+
raw = JSON.parse(text5);
|
|
138312
138326
|
} catch {
|
|
138313
138327
|
return void 0;
|
|
138314
138328
|
}
|
|
@@ -138369,6 +138383,49 @@ function dailyCostSegment(context) {
|
|
|
138369
138383
|
return spend === void 0 ? void 0 : `Today ${formatUsd(spend)}`;
|
|
138370
138384
|
}
|
|
138371
138385
|
|
|
138386
|
+
// src/statusline/elements/sessionFormat.ts
|
|
138387
|
+
var MS_PER_SECOND17 = 1e3;
|
|
138388
|
+
var SECONDS_PER_MINUTE2 = 60;
|
|
138389
|
+
var MINUTES_PER_HOUR4 = 60;
|
|
138390
|
+
var HOURS_PER_DAY9 = 24;
|
|
138391
|
+
function formatElapsed(ms2) {
|
|
138392
|
+
const minutes = Math.floor(ms2 / (MS_PER_SECOND17 * SECONDS_PER_MINUTE2));
|
|
138393
|
+
if (minutes < 1) {
|
|
138394
|
+
return "<1m";
|
|
138395
|
+
}
|
|
138396
|
+
if (minutes < MINUTES_PER_HOUR4) {
|
|
138397
|
+
return `${String(minutes)}m`;
|
|
138398
|
+
}
|
|
138399
|
+
return `${String(Math.floor(minutes / MINUTES_PER_HOUR4))}h ${String(minutes % MINUTES_PER_HOUR4)}m`;
|
|
138400
|
+
}
|
|
138401
|
+
function twoUnits(larger, smaller, largerUnit, smallerUnit) {
|
|
138402
|
+
return smaller > 0 ? `${String(larger)}${largerUnit} ${String(smaller)}${smallerUnit}` : `${String(larger)}${largerUnit}`;
|
|
138403
|
+
}
|
|
138404
|
+
function formatAgo(ms2) {
|
|
138405
|
+
if (ms2 < 0) {
|
|
138406
|
+
return "just now";
|
|
138407
|
+
}
|
|
138408
|
+
const seconds = Math.floor(ms2 / MS_PER_SECOND17);
|
|
138409
|
+
if (seconds < SECONDS_PER_MINUTE2) {
|
|
138410
|
+
return `${String(seconds)}s ago`;
|
|
138411
|
+
}
|
|
138412
|
+
const minutes = Math.floor(seconds / SECONDS_PER_MINUTE2);
|
|
138413
|
+
if (minutes < MINUTES_PER_HOUR4) {
|
|
138414
|
+
return `${String(minutes)}m ago`;
|
|
138415
|
+
}
|
|
138416
|
+
const hours = Math.floor(minutes / MINUTES_PER_HOUR4);
|
|
138417
|
+
if (hours < HOURS_PER_DAY9) {
|
|
138418
|
+
return `${twoUnits(hours, minutes % MINUTES_PER_HOUR4, "h", "m")} ago`;
|
|
138419
|
+
}
|
|
138420
|
+
return `${twoUnits(Math.floor(hours / HOURS_PER_DAY9), hours % HOURS_PER_DAY9, "d", "h")} ago`;
|
|
138421
|
+
}
|
|
138422
|
+
|
|
138423
|
+
// src/statusline/elements/header/duration.ts
|
|
138424
|
+
function durationSegment(context) {
|
|
138425
|
+
const startedAtMs = context.transcript()?.session.startedAtMs;
|
|
138426
|
+
return startedAtMs === void 0 ? void 0 : `\u23F1\uFE0F ${formatElapsed(context.nowMs - startedAtMs)}`;
|
|
138427
|
+
}
|
|
138428
|
+
|
|
138372
138429
|
// src/statusline/palette.ts
|
|
138373
138430
|
init_statusline();
|
|
138374
138431
|
var RESET = `${ESCAPE}[0m`;
|
|
@@ -138418,16 +138475,16 @@ function createPalette(colours, enabled) {
|
|
|
138418
138475
|
};
|
|
138419
138476
|
return {
|
|
138420
138477
|
ansi,
|
|
138421
|
-
paint: (role,
|
|
138478
|
+
paint: (role, text5) => {
|
|
138422
138479
|
const start = ansi(role);
|
|
138423
|
-
return start === "" ?
|
|
138480
|
+
return start === "" ? text5 : `${start}${text5}${RESET}`;
|
|
138424
138481
|
}
|
|
138425
138482
|
};
|
|
138426
138483
|
}
|
|
138427
138484
|
|
|
138428
138485
|
// src/statusline/style.ts
|
|
138429
|
-
var
|
|
138430
|
-
var
|
|
138486
|
+
var SECONDS_PER_MINUTE3 = 60;
|
|
138487
|
+
var MINUTES_PER_HOUR5 = 60;
|
|
138431
138488
|
var SECONDS_PER_DAY = 86400;
|
|
138432
138489
|
var THOUSAND = 1e3;
|
|
138433
138490
|
var MILLION = 1e6;
|
|
@@ -138435,8 +138492,8 @@ var TEN = 10;
|
|
|
138435
138492
|
var TWENTY = 20;
|
|
138436
138493
|
var FULL_PERCENT3 = 100;
|
|
138437
138494
|
var ONE_PERCENT = 1;
|
|
138438
|
-
function withColor(color,
|
|
138439
|
-
return color === "" ?
|
|
138495
|
+
function withColor(color, text5) {
|
|
138496
|
+
return color === "" ? text5 : `${color}${text5}${RESET}`;
|
|
138440
138497
|
}
|
|
138441
138498
|
function statusColor(fraction, isUsedMetric, style) {
|
|
138442
138499
|
const yellowAt = style.bands.warnAt / FULL_PERCENT3;
|
|
@@ -138469,12 +138526,12 @@ function formatDuration(seconds) {
|
|
|
138469
138526
|
if (seconds === void 0 || seconds <= 0) {
|
|
138470
138527
|
return "available";
|
|
138471
138528
|
}
|
|
138472
|
-
if (seconds <
|
|
138529
|
+
if (seconds < SECONDS_PER_MINUTE3) {
|
|
138473
138530
|
return `${String(seconds)}s`;
|
|
138474
138531
|
}
|
|
138475
138532
|
const days = Math.floor(seconds / SECONDS_PER_DAY);
|
|
138476
|
-
const hours = Math.floor(seconds % SECONDS_PER_DAY / (
|
|
138477
|
-
const minutes = Math.floor(seconds % (
|
|
138533
|
+
const hours = Math.floor(seconds % SECONDS_PER_DAY / (MINUTES_PER_HOUR5 * SECONDS_PER_MINUTE3));
|
|
138534
|
+
const minutes = Math.floor(seconds % (MINUTES_PER_HOUR5 * SECONDS_PER_MINUTE3) / SECONDS_PER_MINUTE3);
|
|
138478
138535
|
if (days > 0) {
|
|
138479
138536
|
return `${String(days)}d ${String(hours)}h`;
|
|
138480
138537
|
}
|
|
@@ -138575,13 +138632,13 @@ var import_node_path58 = __toESM(require("node:path"), 1);
|
|
|
138575
138632
|
init_zod();
|
|
138576
138633
|
var SettingsFileSchema = external_exports.looseObject({ outputStyle: external_exports.string().optional().catch(void 0) });
|
|
138577
138634
|
function outputStyleIn(file2, readText2) {
|
|
138578
|
-
const
|
|
138579
|
-
if (
|
|
138635
|
+
const text5 = readText2(file2);
|
|
138636
|
+
if (text5 === void 0) {
|
|
138580
138637
|
return void 0;
|
|
138581
138638
|
}
|
|
138582
138639
|
let parsed;
|
|
138583
138640
|
try {
|
|
138584
|
-
parsed = JSON.parse(
|
|
138641
|
+
parsed = JSON.parse(text5);
|
|
138585
138642
|
} catch {
|
|
138586
138643
|
return void 0;
|
|
138587
138644
|
}
|
|
@@ -138646,7 +138703,7 @@ function workingDirectoryOf(payload) {
|
|
|
138646
138703
|
function inlineAddedDirs({ payload, palette }) {
|
|
138647
138704
|
const { names, more } = addedDirNames(payload.workspace?.added_dirs);
|
|
138648
138705
|
const drawn = [...names.map((name) => `+${name}`), ...more > 0 ? [`+${String(more)} more`] : []];
|
|
138649
|
-
return drawn.length === 0 ? void 0 : drawn.map((
|
|
138706
|
+
return drawn.length === 0 ? void 0 : drawn.map((text5) => palette.paint("label", text5)).join(" ");
|
|
138650
138707
|
}
|
|
138651
138708
|
function projectSegment(context) {
|
|
138652
138709
|
const { payload, settings: settings2 } = context;
|
|
@@ -138676,6 +138733,116 @@ function versionSegment({ payload }) {
|
|
|
138676
138733
|
return version2 === "" ? void 0 : `CC v${version2}`;
|
|
138677
138734
|
}
|
|
138678
138735
|
|
|
138736
|
+
// src/statusline/elements/header/sessionName.ts
|
|
138737
|
+
function sessionNameSegment(context) {
|
|
138738
|
+
return context.transcript()?.session.title;
|
|
138739
|
+
}
|
|
138740
|
+
|
|
138741
|
+
// src/statusline/speed.ts
|
|
138742
|
+
init_zod();
|
|
138743
|
+
|
|
138744
|
+
// src/statusline/cacheFile.ts
|
|
138745
|
+
var import_node_crypto26 = require("node:crypto");
|
|
138746
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
138747
|
+
var SESSION_CACHE_DIRECTORY = "session";
|
|
138748
|
+
function cacheDirectory(ports) {
|
|
138749
|
+
return import_node_path59.default.join(ports.stateDirectory, SESSION_CACHE_DIRECTORY);
|
|
138750
|
+
}
|
|
138751
|
+
function cacheFileFor(ports, kind, transcriptPath) {
|
|
138752
|
+
return import_node_path59.default.join(cacheDirectory(ports), `${kind}-${(0, import_node_crypto26.createHash)("sha256").update(transcriptPath).digest("hex")}.json`);
|
|
138753
|
+
}
|
|
138754
|
+
var RETENTION_DAYS = 30;
|
|
138755
|
+
var HOURS_PER_DAY10 = 24;
|
|
138756
|
+
var MINUTES_PER_HOUR6 = 60;
|
|
138757
|
+
var SECONDS_PER_MINUTE4 = 60;
|
|
138758
|
+
var MS_PER_SECOND18 = 1e3;
|
|
138759
|
+
var CACHE_RETENTION_MS = RETENTION_DAYS * HOURS_PER_DAY10 * MINUTES_PER_HOUR6 * SECONDS_PER_MINUTE4 * MS_PER_SECOND18;
|
|
138760
|
+
function pruneCache(ports, cutoffMs) {
|
|
138761
|
+
const directory = cacheDirectory(ports);
|
|
138762
|
+
const names = ports.listDirectory(directory);
|
|
138763
|
+
if (names === void 0) {
|
|
138764
|
+
return;
|
|
138765
|
+
}
|
|
138766
|
+
for (const name of names) {
|
|
138767
|
+
const file2 = import_node_path59.default.join(directory, name);
|
|
138768
|
+
const modifiedAtMs = ports.modifiedAtMs(file2);
|
|
138769
|
+
if (modifiedAtMs !== void 0 && modifiedAtMs < cutoffMs) {
|
|
138770
|
+
ports.removePath(file2);
|
|
138771
|
+
}
|
|
138772
|
+
}
|
|
138773
|
+
}
|
|
138774
|
+
function loadCache(ports, file2, schema) {
|
|
138775
|
+
const text5 = ports.readText(file2);
|
|
138776
|
+
if (text5 === void 0) {
|
|
138777
|
+
return void 0;
|
|
138778
|
+
}
|
|
138779
|
+
let parsed;
|
|
138780
|
+
try {
|
|
138781
|
+
parsed = JSON.parse(text5);
|
|
138782
|
+
} catch {
|
|
138783
|
+
return void 0;
|
|
138784
|
+
}
|
|
138785
|
+
const result = schema.safeParse(parsed);
|
|
138786
|
+
return result.success ? result.data : void 0;
|
|
138787
|
+
}
|
|
138788
|
+
function saveCache(ports, file2, value2, nowMs) {
|
|
138789
|
+
const isNew = ports.entryKind(file2) === void 0;
|
|
138790
|
+
ports.writeText(file2, JSON.stringify(value2));
|
|
138791
|
+
if (isNew) {
|
|
138792
|
+
pruneCache(ports, nowMs - CACHE_RETENTION_MS);
|
|
138793
|
+
}
|
|
138794
|
+
}
|
|
138795
|
+
|
|
138796
|
+
// src/statusline/speed.ts
|
|
138797
|
+
var SPEED_WINDOW_MS = 2e3;
|
|
138798
|
+
var MIN_SPEED_GAP_MS = 500;
|
|
138799
|
+
var TRANSCRIPT_BYTES_PER_TOKEN = 4;
|
|
138800
|
+
var SpeedSampleSchema = external_exports.strictObject({ at: external_exports.number(), outputTokens: external_exports.number().optional(), transcriptBytes: external_exports.number().optional() });
|
|
138801
|
+
var CACHE_KIND = "speed";
|
|
138802
|
+
var MS_PER_SECOND19 = 1e3;
|
|
138803
|
+
function tokensOf(sample, basis) {
|
|
138804
|
+
const value2 = sample[basis];
|
|
138805
|
+
return basis === "transcriptBytes" && value2 !== void 0 ? value2 / TRANSCRIPT_BYTES_PER_TOKEN : value2;
|
|
138806
|
+
}
|
|
138807
|
+
function speedBetween(previous, current) {
|
|
138808
|
+
const basis = current.outputTokens === void 0 ? "transcriptBytes" : "outputTokens";
|
|
138809
|
+
const now = tokensOf(current, basis);
|
|
138810
|
+
if (now === void 0) {
|
|
138811
|
+
return { tokensPerSecond: void 0, remember: false };
|
|
138812
|
+
}
|
|
138813
|
+
const before = previous === void 0 ? void 0 : tokensOf(previous, basis);
|
|
138814
|
+
if (previous === void 0 || before === void 0 || now < before) {
|
|
138815
|
+
return { tokensPerSecond: void 0, remember: true };
|
|
138816
|
+
}
|
|
138817
|
+
const gapMs = current.at - previous.at;
|
|
138818
|
+
if (gapMs > SPEED_WINDOW_MS || now === before) {
|
|
138819
|
+
return { tokensPerSecond: void 0, remember: true };
|
|
138820
|
+
}
|
|
138821
|
+
if (gapMs < MIN_SPEED_GAP_MS) {
|
|
138822
|
+
return { tokensPerSecond: void 0, remember: false };
|
|
138823
|
+
}
|
|
138824
|
+
return { tokensPerSecond: (now - before) / (gapMs / MS_PER_SECOND19), remember: true };
|
|
138825
|
+
}
|
|
138826
|
+
function trackSpeed(ports, transcriptPath, current) {
|
|
138827
|
+
const file2 = cacheFileFor(ports, CACHE_KIND, transcriptPath);
|
|
138828
|
+
const { tokensPerSecond, remember } = speedBetween(loadCache(ports, file2, SpeedSampleSchema), current);
|
|
138829
|
+
if (remember) {
|
|
138830
|
+
saveCache(ports, file2, current, current.at);
|
|
138831
|
+
}
|
|
138832
|
+
return tokensPerSecond;
|
|
138833
|
+
}
|
|
138834
|
+
|
|
138835
|
+
// src/statusline/elements/header/speed.ts
|
|
138836
|
+
function speedSegment(context) {
|
|
138837
|
+
const transcriptPath = context.payload.transcript_path;
|
|
138838
|
+
if (transcriptPath === void 0 || transcriptPath === "") {
|
|
138839
|
+
return void 0;
|
|
138840
|
+
}
|
|
138841
|
+
const outputTokens = context.payload.context_window?.current_usage?.output_tokens;
|
|
138842
|
+
const tokensPerSecond = trackSpeed(context.ports, transcriptPath, { at: context.nowMs, outputTokens, transcriptBytes: outputTokens === void 0 ? context.transcript()?.bytes : void 0 });
|
|
138843
|
+
return tokensPerSecond === void 0 ? void 0 : `out: ${tokensPerSecond.toFixed(1)} tok/s`;
|
|
138844
|
+
}
|
|
138845
|
+
|
|
138679
138846
|
// src/statusline/vcs/git.ts
|
|
138680
138847
|
var GIT = "git";
|
|
138681
138848
|
var NUL = "\0";
|
|
@@ -138752,15 +138919,15 @@ function parseNumstat(output2) {
|
|
|
138752
138919
|
if (addedText === void 0 || deletedText === void 0 || pathText === void 0) {
|
|
138753
138920
|
continue;
|
|
138754
138921
|
}
|
|
138755
|
-
const
|
|
138922
|
+
const path72 = pathText === "" ? fields[index + 2] : pathText;
|
|
138756
138923
|
if (pathText === "") {
|
|
138757
138924
|
index += 2;
|
|
138758
138925
|
}
|
|
138759
138926
|
const lines = { added: Number(addedText), deleted: Number(deletedText) };
|
|
138760
|
-
if (
|
|
138927
|
+
if (path72 !== void 0 && Number.isInteger(lines.added) && Number.isInteger(lines.deleted)) {
|
|
138761
138928
|
added += lines.added;
|
|
138762
138929
|
deleted += lines.deleted;
|
|
138763
|
-
byPath.set(
|
|
138930
|
+
byPath.set(path72, lines);
|
|
138764
138931
|
}
|
|
138765
138932
|
}
|
|
138766
138933
|
return { total: { added, deleted }, byPath };
|
|
@@ -138815,7 +138982,7 @@ function readGitStatus(ports, cwd, query) {
|
|
|
138815
138982
|
}
|
|
138816
138983
|
|
|
138817
138984
|
// src/statusline/vcs/jj.ts
|
|
138818
|
-
var
|
|
138985
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
138819
138986
|
var JJ2 = "jj";
|
|
138820
138987
|
var MAX_WALK_DEPTH = 64;
|
|
138821
138988
|
var MAX_LABEL_CODE_POINTS = 64;
|
|
@@ -138828,13 +138995,13 @@ function isJjRepository(ports, cwd) {
|
|
|
138828
138995
|
return false;
|
|
138829
138996
|
}
|
|
138830
138997
|
for (let depth = 0; depth < MAX_WALK_DEPTH; depth += 1) {
|
|
138831
|
-
if (ports.entryKind(
|
|
138998
|
+
if (ports.entryKind(import_node_path60.default.join(directory, ".jj")) === "directory") {
|
|
138832
138999
|
return true;
|
|
138833
139000
|
}
|
|
138834
|
-
if (ports.entryKind(
|
|
139001
|
+
if (ports.entryKind(import_node_path60.default.join(directory, ".git")) !== void 0) {
|
|
138835
139002
|
return false;
|
|
138836
139003
|
}
|
|
138837
|
-
const parent =
|
|
139004
|
+
const parent = import_node_path60.default.dirname(directory);
|
|
138838
139005
|
if (parent === directory) {
|
|
138839
139006
|
return false;
|
|
138840
139007
|
}
|
|
@@ -138852,8 +139019,8 @@ var TEMPLATE = [
|
|
|
138852
139019
|
'if(self.conflict(), "1", "0")'
|
|
138853
139020
|
].join(" ++ ");
|
|
138854
139021
|
var ARGS = ["--ignore-working-copy", "--at-operation=@", "--no-pager", "log", "-r", "@", "--no-graph", "--color", "never", "-T", TEMPLATE];
|
|
138855
|
-
function label(
|
|
138856
|
-
const clean = sanitiseDisplayText(
|
|
139022
|
+
function label(text5) {
|
|
139023
|
+
const clean = sanitiseDisplayText(text5).trim();
|
|
138857
139024
|
return clean === "" ? void 0 : Array.from(clean).slice(0, MAX_LABEL_CODE_POINTS).join("");
|
|
138858
139025
|
}
|
|
138859
139026
|
function parse4(output2) {
|
|
@@ -138913,12 +139080,12 @@ function vcsStatusOf(context) {
|
|
|
138913
139080
|
|
|
138914
139081
|
// src/statusline/elements/header/vcs.ts
|
|
138915
139082
|
function aheadText(ahead, { settings: settings2, palette }) {
|
|
138916
|
-
const
|
|
139083
|
+
const text5 = `\u2191${String(ahead)}`;
|
|
138917
139084
|
const { pushCriticalAt, pushWarnAt } = settings2.git;
|
|
138918
139085
|
if (pushCriticalAt > 0 && ahead >= pushCriticalAt) {
|
|
138919
|
-
return palette.paint("critical",
|
|
139086
|
+
return palette.paint("critical", text5);
|
|
138920
139087
|
}
|
|
138921
|
-
return pushWarnAt > 0 && ahead >= pushWarnAt ? palette.paint("warning",
|
|
139088
|
+
return pushWarnAt > 0 && ahead >= pushWarnAt ? palette.paint("warning", text5) : palette.paint("gitBranch", text5);
|
|
138922
139089
|
}
|
|
138923
139090
|
function vcsSegment(context) {
|
|
138924
139091
|
const status = vcsStatusOf(context);
|
|
@@ -138956,10 +139123,19 @@ function addedDirsRow({ payload, settings: settings2, palette }) {
|
|
|
138956
139123
|
if (settings2.project.addedDirsLayout !== "row" || names.length === 0) {
|
|
138957
139124
|
return { kind: "text", lines: [] };
|
|
138958
139125
|
}
|
|
138959
|
-
const drawn = [...names, ...more > 0 ? [`+${String(more)} more`] : []].map((
|
|
139126
|
+
const drawn = [...names, ...more > 0 ? [`+${String(more)} more`] : []].map((text5) => palette.paint("label", text5));
|
|
138960
139127
|
return { kind: "text", lines: [`${palette.paint("label", "Added dirs:")} ${drawn.join(palette.paint("label", ", "))}`] };
|
|
138961
139128
|
}
|
|
138962
139129
|
|
|
139130
|
+
// src/statusline/elements/rows/compactions.ts
|
|
139131
|
+
function compactionsRow(context) {
|
|
139132
|
+
const transcript = context.transcript();
|
|
139133
|
+
if (transcript === void 0 || transcript.session.compactions === 0) {
|
|
139134
|
+
return { kind: "text", lines: [] };
|
|
139135
|
+
}
|
|
139136
|
+
return { kind: "text", lines: [context.palette.paint("label", `Compactions: ${String(transcript.session.compactions)}${transcript.complete ? "" : "+"}`)] };
|
|
139137
|
+
}
|
|
139138
|
+
|
|
138963
139139
|
// src/statusline/elements/context.ts
|
|
138964
139140
|
function barStyleOf({ settings: settings2, palette }, okRole) {
|
|
138965
139141
|
return { bands: settings2.bands, palette, okRole, filled: settings2.bar.filled, empty: settings2.bar.empty };
|
|
@@ -139030,7 +139206,7 @@ function gitFilesRow(context) {
|
|
|
139030
139206
|
}
|
|
139031
139207
|
|
|
139032
139208
|
// src/statusline/configCounts.ts
|
|
139033
|
-
var
|
|
139209
|
+
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
139034
139210
|
init_zod();
|
|
139035
139211
|
var nameList = external_exports.array(external_exports.unknown()).catch([]).transform((items) => items.filter((item) => typeof item === "string"));
|
|
139036
139212
|
var ConfigFileSchema = external_exports.looseObject({
|
|
@@ -139049,13 +139225,13 @@ function readConfigFile(ports, file2) {
|
|
|
139049
139225
|
if (size === void 0 || size > MAX_CONFIG_FILE_BYTES) {
|
|
139050
139226
|
return void 0;
|
|
139051
139227
|
}
|
|
139052
|
-
const
|
|
139053
|
-
if (
|
|
139228
|
+
const text5 = ports.readText(file2);
|
|
139229
|
+
if (text5 === void 0) {
|
|
139054
139230
|
return void 0;
|
|
139055
139231
|
}
|
|
139056
139232
|
let raw;
|
|
139057
139233
|
try {
|
|
139058
|
-
raw = JSON.parse(
|
|
139234
|
+
raw = JSON.parse(text5);
|
|
139059
139235
|
} catch {
|
|
139060
139236
|
return void 0;
|
|
139061
139237
|
}
|
|
@@ -139104,7 +139280,7 @@ function countRules(ports, root) {
|
|
|
139104
139280
|
break;
|
|
139105
139281
|
}
|
|
139106
139282
|
entries += 1;
|
|
139107
|
-
const entry =
|
|
139283
|
+
const entry = import_node_path61.default.join(real, name);
|
|
139108
139284
|
const kind = followedKind(ports, entry);
|
|
139109
139285
|
if (kind === "directory") {
|
|
139110
139286
|
count += walk3(entry);
|
|
@@ -139121,33 +139297,33 @@ function countRules(ports, root) {
|
|
|
139121
139297
|
return walk3(root);
|
|
139122
139298
|
}
|
|
139123
139299
|
function sameLocation(ports, left, right) {
|
|
139124
|
-
return (ports.realPath(left) ??
|
|
139300
|
+
return (ports.realPath(left) ?? import_node_path61.default.resolve(left)) === (ports.realPath(right) ?? import_node_path61.default.resolve(right));
|
|
139125
139301
|
}
|
|
139126
139302
|
function configDirectoryOf(ports) {
|
|
139127
139303
|
const pinned = ports.env.CLAUDE_CONFIG_DIR;
|
|
139128
|
-
return pinned === void 0 || pinned === "" ?
|
|
139304
|
+
return pinned === void 0 || pinned === "" ? import_node_path61.default.join(ports.homeDirectory, ".claude") : pinned;
|
|
139129
139305
|
}
|
|
139130
139306
|
function countConfiguration(ports, projectDirectory) {
|
|
139131
139307
|
const userDirectory = configDirectoryOf(ports);
|
|
139132
|
-
const userSettings = readConfigFile(ports,
|
|
139133
|
-
const globalFile = ports.env.CLAUDE_CONFIG_DIR === void 0 || ports.env.CLAUDE_CONFIG_DIR === "" ?
|
|
139308
|
+
const userSettings = readConfigFile(ports, import_node_path61.default.join(userDirectory, "settings.json"));
|
|
139309
|
+
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");
|
|
139134
139310
|
const global2 = readConfigFile(ports, globalFile);
|
|
139135
139311
|
const userServers = /* @__PURE__ */ new Set([...namesOf(userSettings), ...namesOf(global2)]);
|
|
139136
139312
|
removeNames(userServers, global2?.disabledMcpServers);
|
|
139137
139313
|
const projectServers = /* @__PURE__ */ new Set();
|
|
139138
|
-
let claudeMd = isFile(ports,
|
|
139139
|
-
let rules = countRules(ports,
|
|
139314
|
+
let claudeMd = isFile(ports, import_node_path61.default.join(userDirectory, "CLAUDE.md")) ? 1 : 0;
|
|
139315
|
+
let rules = countRules(ports, import_node_path61.default.join(userDirectory, "rules"));
|
|
139140
139316
|
let hookEvents = hookEventsOf(userSettings);
|
|
139141
139317
|
if (projectDirectory !== void 0) {
|
|
139142
|
-
const projectClaude =
|
|
139318
|
+
const projectClaude = import_node_path61.default.join(projectDirectory, ".claude");
|
|
139143
139319
|
const projectIsUser = sameLocation(ports, projectClaude, userDirectory);
|
|
139144
|
-
const claudeMdFiles = [
|
|
139320
|
+
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")]];
|
|
139145
139321
|
claudeMd += claudeMdFiles.filter((file2) => isFile(ports, file2)).length;
|
|
139146
|
-
const mcpJson = namesOf(readConfigFile(ports,
|
|
139322
|
+
const mcpJson = namesOf(readConfigFile(ports, import_node_path61.default.join(projectDirectory, ".mcp.json")));
|
|
139147
139323
|
if (!projectIsUser) {
|
|
139148
|
-
rules += countRules(ports,
|
|
139149
|
-
const settings2 = readConfigFile(ports,
|
|
139150
|
-
const local = readConfigFile(ports,
|
|
139324
|
+
rules += countRules(ports, import_node_path61.default.join(projectClaude, "rules"));
|
|
139325
|
+
const settings2 = readConfigFile(ports, import_node_path61.default.join(projectClaude, "settings.json"));
|
|
139326
|
+
const local = readConfigFile(ports, import_node_path61.default.join(projectClaude, "settings.local.json"));
|
|
139151
139327
|
hookEvents += hookEventsOf(settings2) + hookEventsOf(local);
|
|
139152
139328
|
for (const name of [...namesOf(settings2), ...namesOf(local)]) {
|
|
139153
139329
|
projectServers.add(name);
|
|
@@ -139180,7 +139356,7 @@ function justify(texts, maxWidth, separator) {
|
|
|
139180
139356
|
return texts.join(separator);
|
|
139181
139357
|
}
|
|
139182
139358
|
const separatorLength = visibleLength(separator);
|
|
139183
|
-
const total = texts.reduce((sum,
|
|
139359
|
+
const total = texts.reduce((sum, text5) => sum + visibleLength(text5), 0) + separatorLength * (texts.length - 1);
|
|
139184
139360
|
const spare = maxWidth - total;
|
|
139185
139361
|
if (spare <= 0) {
|
|
139186
139362
|
return texts.join(separator);
|
|
@@ -139189,7 +139365,7 @@ function justify(texts, maxWidth, separator) {
|
|
|
139189
139365
|
const extraPerGap = Math.floor(spare / gaps);
|
|
139190
139366
|
let remainder = spare % gaps;
|
|
139191
139367
|
const parts = [];
|
|
139192
|
-
texts.forEach((
|
|
139368
|
+
texts.forEach((text5, index) => {
|
|
139193
139369
|
if (index > 0) {
|
|
139194
139370
|
const extra = extraPerGap + (remainder > 0 ? 1 : 0);
|
|
139195
139371
|
if (remainder > 0) {
|
|
@@ -139198,7 +139374,7 @@ function justify(texts, maxWidth, separator) {
|
|
|
139198
139374
|
const left = Math.floor(extra / 2);
|
|
139199
139375
|
parts.push(`${" ".repeat(left + 1)}|${" ".repeat(extra - left + 1)}`);
|
|
139200
139376
|
}
|
|
139201
|
-
parts.push(
|
|
139377
|
+
parts.push(text5);
|
|
139202
139378
|
});
|
|
139203
139379
|
return parts.join("");
|
|
139204
139380
|
}
|
|
@@ -139207,15 +139383,15 @@ function packLines(texts, maxWidth, separator) {
|
|
|
139207
139383
|
const lines = [];
|
|
139208
139384
|
let current = [];
|
|
139209
139385
|
let currentWidth = 0;
|
|
139210
|
-
for (const
|
|
139211
|
-
const width = visibleLength(
|
|
139386
|
+
for (const text5 of texts) {
|
|
139387
|
+
const width = visibleLength(text5);
|
|
139212
139388
|
const added = current.length === 0 ? width : width + separatorLength;
|
|
139213
139389
|
if (current.length > 0 && currentWidth + added > maxWidth) {
|
|
139214
139390
|
lines.push(current);
|
|
139215
|
-
current = [
|
|
139391
|
+
current = [text5];
|
|
139216
139392
|
currentWidth = width;
|
|
139217
139393
|
} else {
|
|
139218
|
-
current.push(
|
|
139394
|
+
current.push(text5);
|
|
139219
139395
|
currentWidth += added;
|
|
139220
139396
|
}
|
|
139221
139397
|
}
|
|
@@ -139256,10 +139432,6 @@ function memoryRow(context) {
|
|
|
139256
139432
|
return { kind: "bars", cells };
|
|
139257
139433
|
}
|
|
139258
139434
|
|
|
139259
|
-
// src/statusline/elements/rows/quota.ts
|
|
139260
|
-
init_statusline();
|
|
139261
|
-
init_pick();
|
|
139262
|
-
|
|
139263
139435
|
// src/statusline/wallClock.ts
|
|
139264
139436
|
var DAY_KEY_LOCALE = "en-CA";
|
|
139265
139437
|
var FORMATTERS = /* @__PURE__ */ new Map();
|
|
@@ -139286,6 +139458,34 @@ function formatWallClock(atMs, nowMs, clock, settings2) {
|
|
|
139286
139458
|
return `${formatterFor(locale, { timeZone, month: "short", day: "numeric" }).format(atMs)} ${time4}`;
|
|
139287
139459
|
}
|
|
139288
139460
|
|
|
139461
|
+
// src/statusline/elements/rows/promptCache.ts
|
|
139462
|
+
var MS_PER_SECOND20 = 1e3;
|
|
139463
|
+
var MIN_WARNING_SECONDS = 60;
|
|
139464
|
+
var WARNING_FRACTION_DENOMINATOR = 5;
|
|
139465
|
+
function warningSecondsOf(ttlSeconds) {
|
|
139466
|
+
return Math.min(ttlSeconds, Math.max(MIN_WARNING_SECONDS, Math.floor(ttlSeconds / WARNING_FRACTION_DENOMINATOR)));
|
|
139467
|
+
}
|
|
139468
|
+
function promptCacheRow(context) {
|
|
139469
|
+
const cache = context.transcript()?.session.promptCache;
|
|
139470
|
+
if (cache === void 0) {
|
|
139471
|
+
return { kind: "text", lines: [] };
|
|
139472
|
+
}
|
|
139473
|
+
const { palette, nowMs, settings: settings2 } = context;
|
|
139474
|
+
const ttlSeconds = cache.ttlSeconds ?? settings2.promptCache.ttlSeconds;
|
|
139475
|
+
const expiresAtMs = cache.anchorAtMs + ttlSeconds * MS_PER_SECOND20;
|
|
139476
|
+
const remainingMs = expiresAtMs - nowMs;
|
|
139477
|
+
const name = palette.paint("label", "Cache");
|
|
139478
|
+
if (remainingMs <= 0) {
|
|
139479
|
+
return { kind: "text", lines: [`${name} ${palette.paint("label", "\u23F1 expired")}`] };
|
|
139480
|
+
}
|
|
139481
|
+
const role = remainingMs <= warningSecondsOf(ttlSeconds) * MS_PER_SECOND20 ? "warning" : "context";
|
|
139482
|
+
return { kind: "text", lines: [`${name} ${palette.paint(role, `\u23F1 until ${formatWallClock(expiresAtMs, nowMs, context.ports.clock, settings2.clock)}`)}`] };
|
|
139483
|
+
}
|
|
139484
|
+
|
|
139485
|
+
// src/statusline/elements/rows/quota.ts
|
|
139486
|
+
init_statusline();
|
|
139487
|
+
init_pick();
|
|
139488
|
+
|
|
139289
139489
|
// src/statusline/resetTime.ts
|
|
139290
139490
|
var AVAILABLE = formatDuration(void 0);
|
|
139291
139491
|
function elapsedPercent(resetMs, periodMs, nowMs) {
|
|
@@ -139367,8 +139567,8 @@ function figuresOf(window, context, style) {
|
|
|
139367
139567
|
const clamped = Math.max(0, Math.min(1, window.fraction));
|
|
139368
139568
|
const used = window.fraction * FULL_PERCENT3;
|
|
139369
139569
|
const shown = settings2.usage.value === "remaining" ? Math.max(0, FULL_PERCENT3 - used) : used;
|
|
139370
|
-
const { text:
|
|
139371
|
-
return { value: withColor(statusColor(clamped, true, style), `${shown.toFixed(1)}%`), reset:
|
|
139570
|
+
const { text: text5, pending } = formatResetTime(window, nowMs, settings2, ports.clock);
|
|
139571
|
+
return { value: withColor(statusColor(clamped, true, style), `${shown.toFixed(1)}%`), reset: text5, pending };
|
|
139372
139572
|
}
|
|
139373
139573
|
function resetSuffix(reset, pending, context) {
|
|
139374
139574
|
if (reset === "") {
|
|
@@ -139404,6 +139604,19 @@ function quotaRow(context) {
|
|
|
139404
139604
|
return { kind: "bars", cells };
|
|
139405
139605
|
}
|
|
139406
139606
|
|
|
139607
|
+
// src/statusline/elements/rows/sessionTime.ts
|
|
139608
|
+
function sessionTimeRow(context) {
|
|
139609
|
+
const session = context.transcript()?.session;
|
|
139610
|
+
const { palette, nowMs, settings: settings2 } = context;
|
|
139611
|
+
const parts = settings2.sessionTime.parts.flatMap((part) => {
|
|
139612
|
+
if (part === "started") {
|
|
139613
|
+
return session?.startedAtMs === void 0 ? [] : `${palette.paint("label", "Started:")} ${formatWallClock(session.startedAtMs, nowMs, context.ports.clock, settings2.clock)}`;
|
|
139614
|
+
}
|
|
139615
|
+
return session?.lastResponseAtMs === void 0 ? [] : `${palette.paint("label", "Last reply:")} ${formatAgo(nowMs - session.lastResponseAtMs)}`;
|
|
139616
|
+
});
|
|
139617
|
+
return { kind: "text", lines: parts.length === 0 ? [] : [parts.join(` ${palette.paint("label", "\u2502")} `)] };
|
|
139618
|
+
}
|
|
139619
|
+
|
|
139407
139620
|
// src/statusline/elements/registry.ts
|
|
139408
139621
|
var HEADER_ROLES = {
|
|
139409
139622
|
model: "model",
|
|
@@ -139419,11 +139632,32 @@ var HEADER_ROLES = {
|
|
|
139419
139632
|
version: "label",
|
|
139420
139633
|
outputStyle: "label",
|
|
139421
139634
|
cost: "label",
|
|
139422
|
-
dailyCost: "label"
|
|
139635
|
+
dailyCost: "label",
|
|
139636
|
+
sessionName: "label",
|
|
139637
|
+
duration: "label",
|
|
139638
|
+
speed: "label"
|
|
139423
139639
|
};
|
|
139424
139640
|
var ELEMENTS = {
|
|
139425
|
-
header: {
|
|
139426
|
-
|
|
139641
|
+
header: {
|
|
139642
|
+
model: modelSegment,
|
|
139643
|
+
provider: providerSegment,
|
|
139644
|
+
route: routeSegment,
|
|
139645
|
+
account: accountSegment,
|
|
139646
|
+
identity: identitySegment,
|
|
139647
|
+
headroom: headroomSegment,
|
|
139648
|
+
project: projectSegment,
|
|
139649
|
+
vcs: vcsSegment,
|
|
139650
|
+
effort: effortSegment,
|
|
139651
|
+
advisor: advisorSegment,
|
|
139652
|
+
version: versionSegment,
|
|
139653
|
+
outputStyle: outputStyleSegment,
|
|
139654
|
+
cost: costSegment,
|
|
139655
|
+
dailyCost: dailyCostSegment,
|
|
139656
|
+
sessionName: sessionNameSegment,
|
|
139657
|
+
duration: durationSegment,
|
|
139658
|
+
speed: speedSegment
|
|
139659
|
+
},
|
|
139660
|
+
rows: { context: contextRow, quota: quotaRow, addedDirs: addedDirsRow, gitFiles: gitFilesRow, memory: memoryRow, environment: environmentRow, sessionTime: sessionTimeRow, promptCache: promptCacheRow, compactions: compactionsRow }
|
|
139427
139661
|
};
|
|
139428
139662
|
|
|
139429
139663
|
// src/statusline/identityTranscript.ts
|
|
@@ -139516,6 +139750,240 @@ function readTranscriptIdentity(ports, transcriptPath) {
|
|
|
139516
139750
|
return floor === 0 ? identityOfLine(decoder.decode(joined2(carry))) ?? NOT_FOUND : NOT_FOUND;
|
|
139517
139751
|
}
|
|
139518
139752
|
|
|
139753
|
+
// src/statusline/transcript/reader.ts
|
|
139754
|
+
var import_node_crypto27 = require("node:crypto");
|
|
139755
|
+
init_zod();
|
|
139756
|
+
|
|
139757
|
+
// src/statusline/transcript/record.ts
|
|
139758
|
+
init_zod();
|
|
139759
|
+
var text4 = external_exports.string().optional().catch(void 0);
|
|
139760
|
+
var number5 = external_exports.number().optional().catch(void 0);
|
|
139761
|
+
var ContentBlockSchema2 = external_exports.looseObject({ type: text4, text: text4 });
|
|
139762
|
+
var TranscriptRecordSchema = external_exports.looseObject({
|
|
139763
|
+
type: text4,
|
|
139764
|
+
subtype: text4,
|
|
139765
|
+
timestamp: text4,
|
|
139766
|
+
/** The session's generated name, written on every record of the session in some versions. */
|
|
139767
|
+
slug: text4,
|
|
139768
|
+
/** The name `/rename` gave the session. */
|
|
139769
|
+
customTitle: text4,
|
|
139770
|
+
/** The title Claude Code generated for the session. */
|
|
139771
|
+
aiTitle: text4,
|
|
139772
|
+
isSidechain: external_exports.boolean().optional().catch(void 0),
|
|
139773
|
+
/** Shared by the records one API request produced. */
|
|
139774
|
+
requestId: text4,
|
|
139775
|
+
message: external_exports.looseObject({
|
|
139776
|
+
content: external_exports.union([external_exports.string(), external_exports.array(ContentBlockSchema2)]).optional().catch(void 0),
|
|
139777
|
+
usage: external_exports.looseObject({
|
|
139778
|
+
cache_creation: external_exports.looseObject({ ephemeral_5m_input_tokens: number5, ephemeral_1h_input_tokens: number5 }).optional().catch(void 0)
|
|
139779
|
+
}).optional().catch(void 0)
|
|
139780
|
+
}).optional().catch(void 0)
|
|
139781
|
+
}).catch({});
|
|
139782
|
+
function parseTranscriptRecord(line) {
|
|
139783
|
+
let parsed;
|
|
139784
|
+
try {
|
|
139785
|
+
parsed = JSON.parse(line);
|
|
139786
|
+
} catch {
|
|
139787
|
+
return void 0;
|
|
139788
|
+
}
|
|
139789
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? TranscriptRecordSchema.parse(parsed) : void 0;
|
|
139790
|
+
}
|
|
139791
|
+
function recordTimeMs(record2) {
|
|
139792
|
+
if (record2.timestamp === void 0) {
|
|
139793
|
+
return void 0;
|
|
139794
|
+
}
|
|
139795
|
+
const ms2 = Date.parse(record2.timestamp);
|
|
139796
|
+
return Number.isNaN(ms2) ? void 0 : ms2;
|
|
139797
|
+
}
|
|
139798
|
+
|
|
139799
|
+
// src/statusline/transcript/session.ts
|
|
139800
|
+
init_zod();
|
|
139801
|
+
init_statusline();
|
|
139802
|
+
var PromptCacheClockSchema = external_exports.strictObject({
|
|
139803
|
+
previousMainAtMs: external_exports.number().optional(),
|
|
139804
|
+
requestId: external_exports.string().optional(),
|
|
139805
|
+
requestAnchorAtMs: external_exports.number().optional(),
|
|
139806
|
+
anchorAtMs: external_exports.number().optional(),
|
|
139807
|
+
/** The tier the latest request that wrote to the cache used. */
|
|
139808
|
+
ttlSeconds: external_exports.union([external_exports.literal(PROMPT_CACHE_TTL_SECONDS.fiveMinutes), external_exports.literal(PROMPT_CACHE_TTL_SECONDS.oneHour)]).optional(),
|
|
139809
|
+
/** The time of a request that has been sent and not yet answered: it has already refreshed the cache. */
|
|
139810
|
+
pendingAtMs: external_exports.number().optional()
|
|
139811
|
+
});
|
|
139812
|
+
var SessionStateSchema2 = external_exports.strictObject({
|
|
139813
|
+
startedAtMs: external_exports.number().optional(),
|
|
139814
|
+
/** True once the start of the transcript was read and held no timestamp, so a timestamp met later is not the session's start. */
|
|
139815
|
+
startUnknown: external_exports.literal(true).optional(),
|
|
139816
|
+
lastAssistantAtMs: external_exports.number().optional(),
|
|
139817
|
+
compactions: external_exports.number().int().nonnegative(),
|
|
139818
|
+
customTitle: external_exports.string().optional(),
|
|
139819
|
+
slug: external_exports.string().optional(),
|
|
139820
|
+
aiTitle: external_exports.string().optional(),
|
|
139821
|
+
cache: PromptCacheClockSchema
|
|
139822
|
+
});
|
|
139823
|
+
var EMPTY_SESSION_STATE = { compactions: 0, cache: {} };
|
|
139824
|
+
var LOCAL_ONLY_USER_TEXT_PREFIXES = ["<command-name>", "<command-message>", "<local-command-", "[Request interrupted by user"];
|
|
139825
|
+
function isLocalOnlyUserText(text5) {
|
|
139826
|
+
return LOCAL_ONLY_USER_TEXT_PREFIXES.some((prefix) => text5.startsWith(prefix));
|
|
139827
|
+
}
|
|
139828
|
+
function opensRequest(record2) {
|
|
139829
|
+
const content = record2.message?.content;
|
|
139830
|
+
if (typeof content === "string") {
|
|
139831
|
+
return !isLocalOnlyUserText(content);
|
|
139832
|
+
}
|
|
139833
|
+
if (Array.isArray(content)) {
|
|
139834
|
+
return content.some((block2) => block2.type === "tool_result") || !content.some((block2) => block2.type === "text" && isLocalOnlyUserText(block2.text ?? ""));
|
|
139835
|
+
}
|
|
139836
|
+
return true;
|
|
139837
|
+
}
|
|
139838
|
+
function ttlOf(record2) {
|
|
139839
|
+
const writes = record2.message?.usage?.cache_creation;
|
|
139840
|
+
if ((writes?.ephemeral_5m_input_tokens ?? 0) > 0) {
|
|
139841
|
+
return PROMPT_CACHE_TTL_SECONDS.fiveMinutes;
|
|
139842
|
+
}
|
|
139843
|
+
return (writes?.ephemeral_1h_input_tokens ?? 0) > 0 ? PROMPT_CACHE_TTL_SECONDS.oneHour : void 0;
|
|
139844
|
+
}
|
|
139845
|
+
function foldPromptCache(cache, record2, atMs) {
|
|
139846
|
+
if (atMs === void 0) {
|
|
139847
|
+
return cache;
|
|
139848
|
+
}
|
|
139849
|
+
let next = cache;
|
|
139850
|
+
if (record2.type === "assistant") {
|
|
139851
|
+
const startsRequest = record2.requestId === void 0 || record2.requestId !== cache.requestId;
|
|
139852
|
+
const requestAnchorAtMs = startsRequest ? cache.previousMainAtMs : cache.requestAnchorAtMs;
|
|
139853
|
+
const anchorAtMs = requestAnchorAtMs !== void 0 && requestAnchorAtMs <= atMs ? requestAnchorAtMs : atMs;
|
|
139854
|
+
const ttlSeconds = ttlOf(record2) ?? cache.ttlSeconds;
|
|
139855
|
+
next = { ...cache, requestId: startsRequest ? record2.requestId : cache.requestId, requestAnchorAtMs, anchorAtMs, ttlSeconds, pendingAtMs: void 0 };
|
|
139856
|
+
}
|
|
139857
|
+
if (record2.type === "user" && opensRequest(record2)) {
|
|
139858
|
+
next = { ...next, pendingAtMs: atMs };
|
|
139859
|
+
}
|
|
139860
|
+
return { ...next, previousMainAtMs: atMs };
|
|
139861
|
+
}
|
|
139862
|
+
function foldSession(state, record2) {
|
|
139863
|
+
const atMs = recordTimeMs(record2);
|
|
139864
|
+
const next = { ...state };
|
|
139865
|
+
if (record2.type === "custom-title" && record2.customTitle !== void 0) {
|
|
139866
|
+
next.customTitle = record2.customTitle;
|
|
139867
|
+
} else if (record2.type === "ai-title" && record2.aiTitle !== void 0) {
|
|
139868
|
+
next.aiTitle = record2.aiTitle;
|
|
139869
|
+
} else if (record2.slug !== void 0) {
|
|
139870
|
+
next.slug = record2.slug;
|
|
139871
|
+
}
|
|
139872
|
+
if (record2.type === "system" && record2.subtype === "compact_boundary" && atMs !== void 0) {
|
|
139873
|
+
next.compactions += 1;
|
|
139874
|
+
}
|
|
139875
|
+
if (atMs !== void 0 && next.startedAtMs === void 0 && next.startUnknown !== true) {
|
|
139876
|
+
next.startedAtMs = atMs;
|
|
139877
|
+
}
|
|
139878
|
+
if (record2.type === "assistant" && atMs !== void 0) {
|
|
139879
|
+
next.lastAssistantAtMs = atMs;
|
|
139880
|
+
}
|
|
139881
|
+
if (record2.isSidechain !== true) {
|
|
139882
|
+
next.cache = foldPromptCache(state.cache, record2, atMs);
|
|
139883
|
+
}
|
|
139884
|
+
return next;
|
|
139885
|
+
}
|
|
139886
|
+
function sessionFactsOf(state) {
|
|
139887
|
+
const { cache } = state;
|
|
139888
|
+
const anchorAtMs = cache.pendingAtMs !== void 0 && (cache.anchorAtMs === void 0 || cache.pendingAtMs > cache.anchorAtMs) ? cache.pendingAtMs : cache.anchorAtMs;
|
|
139889
|
+
return {
|
|
139890
|
+
title: [state.customTitle, state.slug, state.aiTitle].flatMap((name) => name === void 0 ? [] : visibleDisplayText(name)).find((name) => name !== ""),
|
|
139891
|
+
startedAtMs: state.startedAtMs,
|
|
139892
|
+
lastResponseAtMs: state.lastAssistantAtMs,
|
|
139893
|
+
compactions: state.compactions,
|
|
139894
|
+
promptCache: anchorAtMs === void 0 ? void 0 : { anchorAtMs, ttlSeconds: cache.ttlSeconds }
|
|
139895
|
+
};
|
|
139896
|
+
}
|
|
139897
|
+
|
|
139898
|
+
// src/statusline/transcript/reader.ts
|
|
139899
|
+
var MAX_TRANSCRIPT_READ_BYTES = 4194304;
|
|
139900
|
+
var FINGERPRINT_BYTES = 4096;
|
|
139901
|
+
var NEWLINE2 = 10;
|
|
139902
|
+
var CACHE_KIND2 = "transcript";
|
|
139903
|
+
var CACHE_VERSION = 2;
|
|
139904
|
+
var TranscriptCacheSchema = external_exports.strictObject({
|
|
139905
|
+
version: external_exports.literal(CACHE_VERSION),
|
|
139906
|
+
/** A digest of the transcript's first line when this was written: another file at the same path has another one. */
|
|
139907
|
+
fingerprint: external_exports.string(),
|
|
139908
|
+
/** How far into the transcript the state has been folded: always the start of a line. */
|
|
139909
|
+
offset: external_exports.number().int().nonnegative(),
|
|
139910
|
+
/** False once bytes were left unread, so the state may be missing records from before the part read. */
|
|
139911
|
+
complete: external_exports.boolean(),
|
|
139912
|
+
session: SessionStateSchema2
|
|
139913
|
+
});
|
|
139914
|
+
function foldLines(state, bytes) {
|
|
139915
|
+
const end = bytes.lastIndexOf(NEWLINE2) + 1;
|
|
139916
|
+
let folded = state;
|
|
139917
|
+
for (const line of new TextDecoder().decode(bytes.subarray(0, end)).split("\n")) {
|
|
139918
|
+
const record2 = line === "" ? void 0 : parseTranscriptRecord(line);
|
|
139919
|
+
if (record2 !== void 0) {
|
|
139920
|
+
folded = foldSession(folded, record2);
|
|
139921
|
+
}
|
|
139922
|
+
}
|
|
139923
|
+
return { state: folded, consumed: end };
|
|
139924
|
+
}
|
|
139925
|
+
function startOf(head) {
|
|
139926
|
+
const end = head.lastIndexOf(NEWLINE2) + 1;
|
|
139927
|
+
const decoder = new TextDecoder();
|
|
139928
|
+
let from = 0;
|
|
139929
|
+
while (from < end) {
|
|
139930
|
+
const lineEnd = head.indexOf(NEWLINE2, from);
|
|
139931
|
+
const record2 = parseTranscriptRecord(decoder.decode(head.subarray(from, lineEnd)));
|
|
139932
|
+
const atMs = record2 === void 0 ? void 0 : recordTimeMs(record2);
|
|
139933
|
+
if (atMs !== void 0) {
|
|
139934
|
+
return atMs;
|
|
139935
|
+
}
|
|
139936
|
+
from = lineEnd + 1;
|
|
139937
|
+
}
|
|
139938
|
+
return void 0;
|
|
139939
|
+
}
|
|
139940
|
+
function fingerprintOf(head) {
|
|
139941
|
+
const newline = head.subarray(0, FINGERPRINT_BYTES).indexOf(NEWLINE2);
|
|
139942
|
+
return (0, import_node_crypto27.createHash)("sha256").update(head.subarray(0, newline === -1 ? FINGERPRINT_BYTES : newline + 1)).digest("hex");
|
|
139943
|
+
}
|
|
139944
|
+
function readTail(ports, file2, size) {
|
|
139945
|
+
const from = Math.max(0, size - MAX_TRANSCRIPT_READ_BYTES - 1);
|
|
139946
|
+
const range2 = ports.readRange(file2, from, MAX_TRANSCRIPT_READ_BYTES + 1);
|
|
139947
|
+
if (range2 === void 0) {
|
|
139948
|
+
return void 0;
|
|
139949
|
+
}
|
|
139950
|
+
const firstLine = from === 0 ? 0 : range2.bytes.indexOf(NEWLINE2) + 1;
|
|
139951
|
+
return firstLine === 0 && from > 0 ? void 0 : { bytes: range2.bytes.subarray(firstLine), offset: from + firstLine };
|
|
139952
|
+
}
|
|
139953
|
+
function factsOf(range2, cache) {
|
|
139954
|
+
return { bytes: range2.size, complete: cache.complete, session: sessionFactsOf(cache.session) };
|
|
139955
|
+
}
|
|
139956
|
+
var START_UNKNOWN = { startUnknown: true };
|
|
139957
|
+
function readTranscript(ports, transcriptPath, nowMs) {
|
|
139958
|
+
const file2 = cacheFileFor(ports, CACHE_KIND2, transcriptPath);
|
|
139959
|
+
const loaded = loadCache(ports, file2, TranscriptCacheSchema);
|
|
139960
|
+
const head = loaded === void 0 ? void 0 : ports.readRange(transcriptPath, 0, FINGERPRINT_BYTES);
|
|
139961
|
+
const cached2 = loaded !== void 0 && head !== void 0 && head.size >= loaded.offset && fingerprintOf(head.bytes) === loaded.fingerprint ? loaded : void 0;
|
|
139962
|
+
const from = cached2?.offset ?? 0;
|
|
139963
|
+
const first = ports.readRange(transcriptPath, from, MAX_TRANSCRIPT_READ_BYTES);
|
|
139964
|
+
if (first === void 0) {
|
|
139965
|
+
return void 0;
|
|
139966
|
+
}
|
|
139967
|
+
const base = cached2 ?? { version: CACHE_VERSION, fingerprint: "", offset: 0, complete: true, session: EMPTY_SESSION_STATE };
|
|
139968
|
+
const fold = { ports, file: file2, nowMs, range: first, created: cached2 === void 0, head: cached2 === void 0 ? first.bytes : void 0 };
|
|
139969
|
+
if (first.size - from <= MAX_TRANSCRIPT_READ_BYTES) {
|
|
139970
|
+
return foldInto({ ...fold, base, source: { bytes: first.bytes, offset: from } });
|
|
139971
|
+
}
|
|
139972
|
+
const startedAtMs = base.session.startedAtMs ?? (cached2 === void 0 ? startOf(first.bytes) : void 0);
|
|
139973
|
+
const unread = { ...base, complete: false, session: startedAtMs === void 0 ? { ...base.session, ...START_UNKNOWN } : { ...base.session, startedAtMs } };
|
|
139974
|
+
const tail = readTail(ports, transcriptPath, first.size);
|
|
139975
|
+
return tail === void 0 ? factsOf(first, unread) : foldInto({ ...fold, base: unread, source: tail });
|
|
139976
|
+
}
|
|
139977
|
+
function foldInto({ ports, file: file2, nowMs, range: range2, created, head, base, source }) {
|
|
139978
|
+
const { state, consumed } = foldLines(base.session, source.bytes);
|
|
139979
|
+
const next = { ...base, offset: source.offset + consumed, session: state };
|
|
139980
|
+
const fingerprint = created && head !== void 0 ? fingerprintOf(head) : base.fingerprint;
|
|
139981
|
+
if (next.offset > base.offset) {
|
|
139982
|
+
saveCache(ports, file2, { ...next, fingerprint }, nowMs);
|
|
139983
|
+
}
|
|
139984
|
+
return factsOf(range2, next);
|
|
139985
|
+
}
|
|
139986
|
+
|
|
139519
139987
|
// src/statusline/render.ts
|
|
139520
139988
|
var RESERVED_COLUMNS = 4;
|
|
139521
139989
|
function once2(read) {
|
|
@@ -139538,11 +140006,15 @@ function renderStatuslineBlock(input2) {
|
|
|
139538
140006
|
settings: settings2,
|
|
139539
140007
|
palette: createPalette(settings2.colours, colourEnabled(input2.ports.env)),
|
|
139540
140008
|
ports: input2.ports,
|
|
139541
|
-
transcriptIdentity: once2(() => input2.payload.transcript_path === void 0 ? { model: void 0, advisor: void 0 } : readTranscriptIdentity(input2.ports, input2.payload.transcript_path))
|
|
140009
|
+
transcriptIdentity: once2(() => input2.payload.transcript_path === void 0 ? { model: void 0, advisor: void 0 } : readTranscriptIdentity(input2.ports, input2.payload.transcript_path)),
|
|
140010
|
+
transcript: once2(() => {
|
|
140011
|
+
const transcriptPath = input2.payload.transcript_path;
|
|
140012
|
+
return transcriptPath === void 0 || transcriptPath === "" ? void 0 : readTranscript(input2.ports, transcriptPath, input2.nowMs);
|
|
140013
|
+
})
|
|
139542
140014
|
};
|
|
139543
140015
|
const parts = settings2.layout.header.flatMap((name) => {
|
|
139544
|
-
const
|
|
139545
|
-
return
|
|
140016
|
+
const text5 = elements.header[name](context);
|
|
140017
|
+
return text5 === void 0 ? [] : { name, text: context.palette.paint(HEADER_ROLES[name], text5) };
|
|
139546
140018
|
});
|
|
139547
140019
|
const header = headerUnits(parts, settings2.git.branchOverflow);
|
|
139548
140020
|
const lines = [];
|
|
@@ -139623,7 +140095,7 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
139623
140095
|
} else {
|
|
139624
140096
|
const configDir = process.env.CLAUDE_CONFIG_DIR;
|
|
139625
140097
|
try {
|
|
139626
|
-
account = readAccountMetadataFile(realFarmFs, configDir === void 0 || configDir === "" ?
|
|
140098
|
+
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"));
|
|
139627
140099
|
} catch {
|
|
139628
140100
|
account = void 0;
|
|
139629
140101
|
}
|
|
@@ -140523,7 +140995,7 @@ var EmbeddedResourceSchema = object({
|
|
|
140523
140995
|
var ResourceLinkSchema = ResourceSchema.extend({
|
|
140524
140996
|
type: literal("resource_link")
|
|
140525
140997
|
});
|
|
140526
|
-
var
|
|
140998
|
+
var ContentBlockSchema3 = union([
|
|
140527
140999
|
TextContentSchema,
|
|
140528
141000
|
ImageContentSchema,
|
|
140529
141001
|
AudioContentSchema,
|
|
@@ -140532,7 +141004,7 @@ var ContentBlockSchema2 = union([
|
|
|
140532
141004
|
]);
|
|
140533
141005
|
var PromptMessageSchema = object({
|
|
140534
141006
|
role: RoleSchema,
|
|
140535
|
-
content:
|
|
141007
|
+
content: ContentBlockSchema3
|
|
140536
141008
|
});
|
|
140537
141009
|
var GetPromptResultSchema = ResultSchema.extend({
|
|
140538
141010
|
/**
|
|
@@ -140648,7 +141120,7 @@ var CallToolResultSchema = ResultSchema.extend({
|
|
|
140648
141120
|
* If the Tool does not define an outputSchema, this field MUST be present in the result.
|
|
140649
141121
|
* For backwards compatibility, this field is always present, but it may be empty.
|
|
140650
141122
|
*/
|
|
140651
|
-
content: array(
|
|
141123
|
+
content: array(ContentBlockSchema3).default([]),
|
|
140652
141124
|
/**
|
|
140653
141125
|
* An object containing structured tool output.
|
|
140654
141126
|
*
|
|
@@ -140777,7 +141249,7 @@ var ToolChoiceSchema2 = object({
|
|
|
140777
141249
|
var ToolResultContentSchema = object({
|
|
140778
141250
|
type: literal("tool_result"),
|
|
140779
141251
|
toolUseId: string2().describe("The unique identifier for the corresponding tool call."),
|
|
140780
|
-
content: array(
|
|
141252
|
+
content: array(ContentBlockSchema3).default([]),
|
|
140781
141253
|
structuredContent: object({}).loose().optional(),
|
|
140782
141254
|
isError: boolean2().optional(),
|
|
140783
141255
|
/**
|
|
@@ -141724,8 +142196,8 @@ function getErrorMap2() {
|
|
|
141724
142196
|
|
|
141725
142197
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/helpers/parseUtil.js
|
|
141726
142198
|
var makeIssue = (params) => {
|
|
141727
|
-
const { data, path:
|
|
141728
|
-
const fullPath = [...
|
|
142199
|
+
const { data, path: path72, errorMaps, issueData } = params;
|
|
142200
|
+
const fullPath = [...path72, ...issueData.path || []];
|
|
141729
142201
|
const fullIssue = {
|
|
141730
142202
|
...issueData,
|
|
141731
142203
|
path: fullPath
|
|
@@ -141840,11 +142312,11 @@ var errorUtil;
|
|
|
141840
142312
|
|
|
141841
142313
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/types.js
|
|
141842
142314
|
var ParseInputLazyPath = class {
|
|
141843
|
-
constructor(parent, value2,
|
|
142315
|
+
constructor(parent, value2, path72, key) {
|
|
141844
142316
|
this._cachedPath = [];
|
|
141845
142317
|
this.parent = parent;
|
|
141846
142318
|
this.data = value2;
|
|
141847
|
-
this._path =
|
|
142319
|
+
this._path = path72;
|
|
141848
142320
|
this._key = key;
|
|
141849
142321
|
}
|
|
141850
142322
|
get path() {
|
|
@@ -145407,11 +145879,11 @@ function normalizeObjectSchema(schema) {
|
|
|
145407
145879
|
}
|
|
145408
145880
|
return void 0;
|
|
145409
145881
|
}
|
|
145410
|
-
function getDotPath(
|
|
145411
|
-
if (
|
|
145882
|
+
function getDotPath(path72) {
|
|
145883
|
+
if (path72.length === 0) {
|
|
145412
145884
|
return "object root";
|
|
145413
145885
|
}
|
|
145414
|
-
return
|
|
145886
|
+
return path72.reduce((acc, seg, index) => {
|
|
145415
145887
|
if (index === 0) {
|
|
145416
145888
|
return String(seg);
|
|
145417
145889
|
}
|
|
@@ -149454,7 +149926,7 @@ async function serveMcp(mcp, transport, options = {}) {
|
|
|
149454
149926
|
|
|
149455
149927
|
// src/mcp/permissions.ts
|
|
149456
149928
|
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
149457
|
-
var
|
|
149929
|
+
var import_node_path63 = __toESM(require("node:path"), 1);
|
|
149458
149930
|
init_zod();
|
|
149459
149931
|
init_store();
|
|
149460
149932
|
var StoredMcpPermissionsSchema = external_exports.strictObject({
|
|
@@ -149476,10 +149948,10 @@ function effectiveMcpPermissions(flags, stored) {
|
|
|
149476
149948
|
return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl, history: flags.history || stored.history };
|
|
149477
149949
|
}
|
|
149478
149950
|
function watchMcpPermissions(paths, onChange) {
|
|
149479
|
-
const directory =
|
|
149951
|
+
const directory = import_node_path63.default.dirname(paths.mcpPermissionsFile);
|
|
149480
149952
|
import_node_fs23.default.mkdirSync(directory, { recursive: true });
|
|
149481
149953
|
const watcher = import_node_fs23.default.watch(directory, (_event, filename) => {
|
|
149482
|
-
if (filename === null || filename ===
|
|
149954
|
+
if (filename === null || filename === import_node_path63.default.basename(paths.mcpPermissionsFile)) {
|
|
149483
149955
|
onChange();
|
|
149484
149956
|
}
|
|
149485
149957
|
});
|
|
@@ -149644,9 +150116,9 @@ init_cliError();
|
|
|
149644
150116
|
init_argv();
|
|
149645
150117
|
init_legacy();
|
|
149646
150118
|
var COMPLETION_SHELLS = ["bash", "zsh", "fish"];
|
|
149647
|
-
function firstSentence(
|
|
149648
|
-
const end =
|
|
149649
|
-
return end === -1 ?
|
|
150119
|
+
function firstSentence(text5) {
|
|
150120
|
+
const end = text5.search(/\.(\s|$)/);
|
|
150121
|
+
return end === -1 ? text5 : text5.slice(0, end);
|
|
149650
150122
|
}
|
|
149651
150123
|
function collectNodes(program2) {
|
|
149652
150124
|
const help = new Help();
|
|
@@ -149667,11 +150139,11 @@ function collectNodes(program2) {
|
|
|
149667
150139
|
visit2(program2, "root");
|
|
149668
150140
|
return nodes;
|
|
149669
150141
|
}
|
|
149670
|
-
function singleQuote(
|
|
149671
|
-
return `'${
|
|
150142
|
+
function singleQuote(text5) {
|
|
150143
|
+
return `'${text5.replaceAll("'", `'\\''`)}'`;
|
|
149672
150144
|
}
|
|
149673
|
-
function fishQuote(
|
|
149674
|
-
return `'${
|
|
150145
|
+
function fishQuote(text5) {
|
|
150146
|
+
return `'${text5.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'`;
|
|
149675
150147
|
}
|
|
149676
150148
|
function transitionArms(nodes, indent) {
|
|
149677
150149
|
return nodes.flatMap((node2) => [...node2.children].map(([name, child]) => `${indent}${singleQuote(`${node2.id}:${name}`)}) node=${singleQuote(child)} ;;`)).join("\n");
|
|
@@ -149792,16 +150264,16 @@ init_credentialCache();
|
|
|
149792
150264
|
|
|
149793
150265
|
// src/identityToken.ts
|
|
149794
150266
|
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
149795
|
-
var
|
|
150267
|
+
var import_node_path64 = __toESM(require("node:path"), 1);
|
|
149796
150268
|
init_cliError();
|
|
149797
150269
|
var TOKEN_FILE_MODE = 384;
|
|
149798
150270
|
var TOKEN_DIR_MODE = 448;
|
|
149799
150271
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
149800
150272
|
function identityTokenDir(paths) {
|
|
149801
|
-
return
|
|
150273
|
+
return import_node_path64.default.join(paths.root, "credentials");
|
|
149802
150274
|
}
|
|
149803
150275
|
function identityTokenPath(paths, identityName) {
|
|
149804
|
-
return
|
|
150276
|
+
return import_node_path64.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
149805
150277
|
}
|
|
149806
150278
|
function storeIdentityToken(paths, identityName, raw) {
|
|
149807
150279
|
const token = raw.trim();
|
|
@@ -149812,7 +150284,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
149812
150284
|
import_node_fs24.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
149813
150285
|
import_node_fs24.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
149814
150286
|
const target = identityTokenPath(paths, identityName);
|
|
149815
|
-
const temp =
|
|
150287
|
+
const temp = import_node_path64.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
149816
150288
|
import_node_fs24.default.writeFileSync(temp, `${token}
|
|
149817
150289
|
`, { mode: TOKEN_FILE_MODE });
|
|
149818
150290
|
import_node_fs24.default.renameSync(temp, target);
|
|
@@ -149984,7 +150456,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
149984
150456
|
// src/headroom/commands.ts
|
|
149985
150457
|
var import_node_fs25 = __toESM(require("node:fs"), 1);
|
|
149986
150458
|
var import_node_http5 = __toESM(require("node:http"), 1);
|
|
149987
|
-
var
|
|
150459
|
+
var import_node_path65 = __toESM(require("node:path"), 1);
|
|
149988
150460
|
var import_node_child_process9 = require("node:child_process");
|
|
149989
150461
|
init_commandDeps();
|
|
149990
150462
|
init_configProfilesStore();
|
|
@@ -150175,12 +150647,12 @@ function readInstalledHeadroomCommit() {
|
|
|
150175
150647
|
if (toolDir.status !== 0) {
|
|
150176
150648
|
return void 0;
|
|
150177
150649
|
}
|
|
150178
|
-
const libDir =
|
|
150650
|
+
const libDir = import_node_path65.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
150179
150651
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
150180
|
-
const sitePackages =
|
|
150652
|
+
const sitePackages = import_node_path65.default.join(libDir, python, "site-packages");
|
|
150181
150653
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
150182
150654
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
150183
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
150655
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path65.default.join(sitePackages, entry, "direct_url.json"));
|
|
150184
150656
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
150185
150657
|
}
|
|
150186
150658
|
}
|
|
@@ -150411,9 +150883,9 @@ init_providersStore();
|
|
|
150411
150883
|
init_realPorts();
|
|
150412
150884
|
var realCatalogueFetch = async (url2, headers, timeoutMs) => {
|
|
150413
150885
|
const response = await fetch(url2, { headers: { ...headers }, signal: AbortSignal.timeout(timeoutMs) });
|
|
150414
|
-
const
|
|
150886
|
+
const text5 = await response.text();
|
|
150415
150887
|
try {
|
|
150416
|
-
const body = JSON.parse(
|
|
150888
|
+
const body = JSON.parse(text5);
|
|
150417
150889
|
return { status: response.status, body };
|
|
150418
150890
|
} catch {
|
|
150419
150891
|
return { status: response.status, body: void 0 };
|
|
@@ -150436,7 +150908,7 @@ async function refreshCatalogueForReal(paths, name, env) {
|
|
|
150436
150908
|
init_realPorts();
|
|
150437
150909
|
|
|
150438
150910
|
// src/usage/realJobRunner.ts
|
|
150439
|
-
var
|
|
150911
|
+
var import_node_path66 = __toESM(require("node:path"), 1);
|
|
150440
150912
|
init_conditions();
|
|
150441
150913
|
init_identityClaude();
|
|
150442
150914
|
var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
|
|
@@ -150449,7 +150921,7 @@ ${outcome.trimEnd()}
|
|
|
150449
150921
|
}
|
|
150450
150922
|
function createRealJobRunner(params) {
|
|
150451
150923
|
return async (name, identity, job) => {
|
|
150452
|
-
const logFile =
|
|
150924
|
+
const logFile = import_node_path66.default.join(params.paths.jobLogsDir, `${name}.log`);
|
|
150453
150925
|
const append = (outcome) => {
|
|
150454
150926
|
params.fs.mkdirPrivate(params.paths.jobLogsDir);
|
|
150455
150927
|
params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
|
|
@@ -150506,7 +150978,7 @@ function registerHeadlessCommands(program2, deps) {
|
|
|
150506
150978
|
}
|
|
150507
150979
|
|
|
150508
150980
|
// src/jobs.ts
|
|
150509
|
-
var
|
|
150981
|
+
var import_node_path67 = __toESM(require("node:path"), 1);
|
|
150510
150982
|
init_commandDeps();
|
|
150511
150983
|
init_cliError();
|
|
150512
150984
|
init_schema();
|
|
@@ -150531,7 +151003,7 @@ function jobOf(options) {
|
|
|
150531
151003
|
target: options.identity === void 0 ? { pool: options.pool ?? "" } : { identity: options.identity },
|
|
150532
151004
|
trigger: options.at === void 0 ? { beforeReset: options.beforeReset ?? "fiveHour", lead: options.lead ?? "" } : { at: options.at },
|
|
150533
151005
|
prompt: options.prompt,
|
|
150534
|
-
cwd:
|
|
151006
|
+
cwd: import_node_path67.default.resolve(options.cwd ?? process.cwd()),
|
|
150535
151007
|
timeout: options.timeout,
|
|
150536
151008
|
...options.model === void 0 ? {} : { model: options.model },
|
|
150537
151009
|
...options.allowedTool === void 0 ? {} : { allowedTools: options.allowedTool }
|
|
@@ -150604,7 +151076,7 @@ function registerJobCommand(program2, deps) {
|
|
|
150604
151076
|
console.log(`Allowed tools: ${entry.allowedTools.join(", ")}`);
|
|
150605
151077
|
}
|
|
150606
151078
|
console.log(`Prompt: ${entry.prompt}`);
|
|
150607
|
-
console.log(`Results: ${
|
|
151079
|
+
console.log(`Results: ${import_node_path67.default.join(paths.jobLogsDir, `${name}.log`)}`);
|
|
150608
151080
|
}),
|
|
150609
151081
|
["agent-shim job show digest"]
|
|
150610
151082
|
);
|
|
@@ -150627,7 +151099,7 @@ function registerJobCommand(program2, deps) {
|
|
|
150627
151099
|
throw new UsageError(`No member of the job's pool can be picked right now.`);
|
|
150628
151100
|
}
|
|
150629
151101
|
await createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() })(name, identity, entry);
|
|
150630
|
-
console.log(`Ran job "${name}" as ${identity}; the result is in ${
|
|
151102
|
+
console.log(`Ran job "${name}" as ${identity}; the result is in ${import_node_path67.default.join(paths.jobLogsDir, `${name}.log`)}.`);
|
|
150631
151103
|
}),
|
|
150632
151104
|
["agent-shim job run digest"]
|
|
150633
151105
|
);
|
|
@@ -150791,7 +151263,7 @@ init_providerAliases();
|
|
|
150791
151263
|
|
|
150792
151264
|
// src/providerRename.ts
|
|
150793
151265
|
var import_node_fs26 = __toESM(require("node:fs"), 1);
|
|
150794
|
-
var
|
|
151266
|
+
var import_node_path68 = __toESM(require("node:path"), 1);
|
|
150795
151267
|
init_schema();
|
|
150796
151268
|
init_store();
|
|
150797
151269
|
init_load();
|
|
@@ -150908,7 +151380,7 @@ function rewriteReferences(paths, from, to2) {
|
|
|
150908
151380
|
const launch = renamedLaunch(profile.launch, from, to2);
|
|
150909
151381
|
const models = profile.models === void 0 ? void 0 : renamedModels(profile.models, from, to2);
|
|
150910
151382
|
if (launch !== void 0 || models !== void 0) {
|
|
150911
|
-
applyPatch(
|
|
151383
|
+
applyPatch(import_node_path68.default.join(paths.configProfilesDir, `${name}.json`), ConfigProfileSchema, { ...launch === void 0 ? {} : { launch }, ...models === void 0 ? {} : { models } });
|
|
150912
151384
|
rewritten.push(`profile ${name}`);
|
|
150913
151385
|
}
|
|
150914
151386
|
}
|
|
@@ -151735,7 +152207,7 @@ function registerSessionCommands(program2, deps) {
|
|
|
151735
152207
|
}
|
|
151736
152208
|
|
|
151737
152209
|
// src/usage/commands.ts
|
|
151738
|
-
var
|
|
152210
|
+
var import_node_path69 = __toESM(require("node:path"), 1);
|
|
151739
152211
|
init_commandDeps();
|
|
151740
152212
|
init_realPorts();
|
|
151741
152213
|
init_account();
|
|
@@ -151874,7 +152346,7 @@ function collectAccounts(fs30, paths, identity, probe) {
|
|
|
151874
152346
|
return names.map((name) => ({
|
|
151875
152347
|
identity: name,
|
|
151876
152348
|
account: readAccountMetadata(fs30, paths.identitiesDir, name),
|
|
151877
|
-
signIn: identitySignIn(fs30, probe, { farmRoot:
|
|
152349
|
+
signIn: identitySignIn(fs30, probe, { farmRoot: import_node_path69.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
|
|
151878
152350
|
usage: readUsageSnapshot(fs30, paths.usageSnapshotsDir, name)
|
|
151879
152351
|
}));
|
|
151880
152352
|
}
|
|
@@ -152115,7 +152587,7 @@ async function realRefresher(params) {
|
|
|
152115
152587
|
}
|
|
152116
152588
|
|
|
152117
152589
|
// src/supervise/launch.ts
|
|
152118
|
-
var
|
|
152590
|
+
var import_node_crypto28 = require("node:crypto");
|
|
152119
152591
|
init_claudeSession();
|
|
152120
152592
|
init_pool();
|
|
152121
152593
|
init_realPorts();
|
|
@@ -152211,8 +152683,8 @@ function createRealCompactor(params) {
|
|
|
152211
152683
|
sizes = boundarySizes(message);
|
|
152212
152684
|
}
|
|
152213
152685
|
if (message.type === "result") {
|
|
152214
|
-
const
|
|
152215
|
-
return sizes === void 0 ? { kind: "unchanged", reason:
|
|
152686
|
+
const text5 = successfulResult(message);
|
|
152687
|
+
return sizes === void 0 ? { kind: "unchanged", reason: text5 === "" ? "nothing was compacted" : text5 } : { kind: "compacted", ...sizes };
|
|
152216
152688
|
}
|
|
152217
152689
|
}
|
|
152218
152690
|
throw new Error("the compaction ended without a result");
|
|
@@ -152281,7 +152753,7 @@ function quotaHitOf(fs30, paths, identity, sessionId, sinceMs, nowMs) {
|
|
|
152281
152753
|
}
|
|
152282
152754
|
|
|
152283
152755
|
// src/supervise/move.ts
|
|
152284
|
-
var
|
|
152756
|
+
var import_node_path70 = __toESM(require("node:path"), 1);
|
|
152285
152757
|
init_lock();
|
|
152286
152758
|
init_poolPick();
|
|
152287
152759
|
init_read();
|
|
@@ -152327,7 +152799,7 @@ function createMover(deps) {
|
|
|
152327
152799
|
if (resolution.identity === request7.from) {
|
|
152328
152800
|
return { kind: "stay", reason: `no other member of pool "${pool}" can take it` };
|
|
152329
152801
|
}
|
|
152330
|
-
const transcript =
|
|
152802
|
+
const transcript = import_node_path70.default.join(paths.identitiesDir, resolution.identity, "projects", projectDirNameOf(deps.cwd), `${request7.sessionId}.jsonl`);
|
|
152331
152803
|
if (farmFs.lstat(transcript)?.kind !== "file") {
|
|
152332
152804
|
return { kind: "stay", reason: `${resolution.identity} does not share this conversation's history, so it could not resume it` };
|
|
152333
152805
|
}
|
|
@@ -152361,13 +152833,13 @@ function createIdentityMover(deps) {
|
|
|
152361
152833
|
throw error63;
|
|
152362
152834
|
}
|
|
152363
152835
|
try {
|
|
152364
|
-
if (farmFs.readFileUtf8(
|
|
152836
|
+
if (farmFs.readFileUtf8(import_node_path70.default.join(paths.identitiesDir, request7.to, "identity.json")) === void 0) {
|
|
152365
152837
|
return { kind: "stay", reason: `no identity "${request7.to}"` };
|
|
152366
152838
|
}
|
|
152367
152839
|
if (request7.to === request7.from) {
|
|
152368
152840
|
return { kind: "stay", reason: `the model already runs under this session's identity` };
|
|
152369
152841
|
}
|
|
152370
|
-
const transcript =
|
|
152842
|
+
const transcript = import_node_path70.default.join(paths.identitiesDir, request7.to, "projects", projectDirNameOf(deps.cwd), `${request7.sessionId}.jsonl`);
|
|
152371
152843
|
if (farmFs.lstat(transcript)?.kind !== "file") {
|
|
152372
152844
|
return { kind: "stay", reason: `${request7.to} does not share this conversation's history, so it could not resume it` };
|
|
152373
152845
|
}
|
|
@@ -152707,7 +153179,7 @@ async function runSupervised(params) {
|
|
|
152707
153179
|
log.warn(`agent-shim: pool "${pool}" resumes on a spent quota, which needs a POSIX terminal; this launch runs unsupervised`);
|
|
152708
153180
|
return void 0;
|
|
152709
153181
|
}
|
|
152710
|
-
const first = initialConversationOf(params.passthrough, { newId:
|
|
153182
|
+
const first = initialConversationOf(params.passthrough, { newId: import_node_crypto28.randomUUID, latestId: () => latestConversationId(farm.fs, { claudeHome: farm.claudeHome, cwd: farm.cwd }) });
|
|
152711
153183
|
if ("reason" in first) {
|
|
152712
153184
|
log.warn(`agent-shim: pool "${pool}" resumes on a spent quota, but this launch runs unsupervised: ${first.reason}`);
|
|
152713
153185
|
return void 0;
|
|
@@ -152946,7 +153418,7 @@ async function runClaude(argvOverride) {
|
|
|
152946
153418
|
// src/cli.ts
|
|
152947
153419
|
async function main() {
|
|
152948
153420
|
aliasLegacyEnv(process.env);
|
|
152949
|
-
const invokedName =
|
|
153421
|
+
const invokedName = import_node_path71.default.basename(process.argv[1] ?? "agent-shim");
|
|
152950
153422
|
if (isInvokedAsClaude(invokedName)) {
|
|
152951
153423
|
await runClaude();
|
|
152952
153424
|
return;
|