claude-use 11.56.1 → 11.57.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 +892 -464
- package/dist/index.cjs +20 -4
- package/dist/index.mjs +20 -4
- package/dist/types/index.d.ts +223 -0
- 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, path71) {
|
|
322
|
+
if (!path71)
|
|
323
323
|
return obj;
|
|
324
|
-
return
|
|
324
|
+
return path71.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(path71, 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(path71);
|
|
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, path71 = []) => {
|
|
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 }, [...path71, ...issue2.path]));
|
|
1112
1112
|
} else if (issue2.code === "invalid_key") {
|
|
1113
|
-
processError({ issues: issue2.issues }, [...
|
|
1113
|
+
processError({ issues: issue2.issues }, [...path71, ...issue2.path]);
|
|
1114
1114
|
} else if (issue2.code === "invalid_element") {
|
|
1115
|
-
processError({ issues: issue2.issues }, [...
|
|
1115
|
+
processError({ issues: issue2.issues }, [...path71, ...issue2.path]);
|
|
1116
1116
|
} else {
|
|
1117
|
-
const fullpath = [...
|
|
1117
|
+
const fullpath = [...path71, ...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, path71 = []) => {
|
|
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 }, [...path71, ...issue2.path]));
|
|
1161
1161
|
} else if (issue2.code === "invalid_key") {
|
|
1162
|
-
processError({ issues: issue2.issues }, [...
|
|
1162
|
+
processError({ issues: issue2.issues }, [...path71, ...issue2.path]);
|
|
1163
1163
|
} else if (issue2.code === "invalid_element") {
|
|
1164
|
-
processError({ issues: issue2.issues }, [...
|
|
1164
|
+
processError({ issues: issue2.issues }, [...path71, ...issue2.path]);
|
|
1165
1165
|
} else {
|
|
1166
|
-
const fullpath = [...
|
|
1166
|
+
const fullpath = [...path71, ...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 path71 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1206
|
+
for (const seg of path71) {
|
|
1207
1207
|
if (typeof seg === "number")
|
|
1208
1208
|
segs.push(`[${seg}]`);
|
|
1209
1209
|
else if (typeof seg === "symbol")
|
|
@@ -19199,13 +19199,13 @@ function resolveRef(ref, ctx) {
|
|
|
19199
19199
|
if (!ref.startsWith("#")) {
|
|
19200
19200
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19201
19201
|
}
|
|
19202
|
-
const
|
|
19203
|
-
if (
|
|
19202
|
+
const path71 = ref.slice(1).split("/").filter(Boolean);
|
|
19203
|
+
if (path71.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 (path71[0] === defsKey) {
|
|
19208
|
+
const key = path71[1] === void 0 ? void 0 : decodeJSONPointerSegment(path71[1]);
|
|
19209
19209
|
if (!key || !ctx.defs[key]) {
|
|
19210
19210
|
throw new Error(`Reference not found: ${ref}`);
|
|
19211
19211
|
}
|
|
@@ -23712,42 +23712,42 @@ var require_defaults = __commonJS({
|
|
|
23712
23712
|
var require_env_paths = __commonJS({
|
|
23713
23713
|
"node_modules/.pnpm/env-paths@2.2.1/node_modules/env-paths/index.js"(exports2, module2) {
|
|
23714
23714
|
"use strict";
|
|
23715
|
-
var
|
|
23715
|
+
var path71 = 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 = path71.join(homedir, "Library");
|
|
23722
23722
|
return {
|
|
23723
|
-
data:
|
|
23724
|
-
config:
|
|
23725
|
-
cache:
|
|
23726
|
-
log:
|
|
23727
|
-
temp:
|
|
23723
|
+
data: path71.join(library, "Application Support", name),
|
|
23724
|
+
config: path71.join(library, "Preferences", name),
|
|
23725
|
+
cache: path71.join(library, "Caches", name),
|
|
23726
|
+
log: path71.join(library, "Logs", name),
|
|
23727
|
+
temp: path71.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 || path71.join(homedir, "AppData", "Roaming");
|
|
23732
|
+
const localAppData = env.LOCALAPPDATA || path71.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: path71.join(localAppData, name, "Data"),
|
|
23736
|
+
config: path71.join(appData, name, "Config"),
|
|
23737
|
+
cache: path71.join(localAppData, name, "Cache"),
|
|
23738
|
+
log: path71.join(localAppData, name, "Log"),
|
|
23739
|
+
temp: path71.join(tmpdir, name)
|
|
23740
23740
|
};
|
|
23741
23741
|
};
|
|
23742
23742
|
var linux = (name) => {
|
|
23743
|
-
const username =
|
|
23743
|
+
const username = path71.basename(homedir);
|
|
23744
23744
|
return {
|
|
23745
|
-
data:
|
|
23746
|
-
config:
|
|
23747
|
-
cache:
|
|
23745
|
+
data: path71.join(env.XDG_DATA_HOME || path71.join(homedir, ".local", "share"), name),
|
|
23746
|
+
config: path71.join(env.XDG_CONFIG_HOME || path71.join(homedir, ".config"), name),
|
|
23747
|
+
cache: path71.join(env.XDG_CACHE_HOME || path71.join(homedir, ".cache"), name),
|
|
23748
23748
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
23749
|
-
log:
|
|
23750
|
-
temp:
|
|
23749
|
+
log: path71.join(env.XDG_STATE_HOME || path71.join(homedir, ".local", "state"), name),
|
|
23750
|
+
temp: path71.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, path71) {
|
|
23819
|
+
if (typeof path71 === "string" && Object.prototype.hasOwnProperty.call(source, path71)) {
|
|
23820
|
+
return source[path71];
|
|
23821
23821
|
}
|
|
23822
|
-
const parsedPath = typeof
|
|
23822
|
+
const parsedPath = typeof path71 === "string" ? path71.split(".") : path71;
|
|
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(path71) {
|
|
23846
23846
|
try {
|
|
23847
|
-
const stat = await fs_1.promises.stat(
|
|
23847
|
+
const stat = await fs_1.promises.stat(path71);
|
|
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(path71) {
|
|
23858
23858
|
try {
|
|
23859
|
-
const stat = fs_1.default.statSync(
|
|
23859
|
+
const stat = fs_1.default.statSync(path71);
|
|
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((path71, i10) => `${i10 + 1}. ${path71}`).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(path71) {
|
|
24146
24146
|
try {
|
|
24147
|
-
await promises_1.default.stat(
|
|
24147
|
+
await promises_1.default.stat(path71);
|
|
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(path71) {
|
|
24308
24308
|
try {
|
|
24309
|
-
fs_1.default.statSync(
|
|
24309
|
+
fs_1.default.statSync(path71);
|
|
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((path71) => path71.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: path71, keys }) => `${path71.length === 0 ? "" : `${path71.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: path71, values } of ignored) {
|
|
24586
24586
|
let holder = restored;
|
|
24587
|
-
for (const step2 of
|
|
24587
|
+
for (const step2 of path71) {
|
|
24588
24588
|
holder = isRecord(holder) ? holder[step2] : void 0;
|
|
24589
24589
|
}
|
|
24590
24590
|
if (isRecord(holder)) {
|
|
@@ -25363,8 +25363,8 @@ var init_statusline = __esm({
|
|
|
25363
25363
|
init_zod();
|
|
25364
25364
|
init_blank();
|
|
25365
25365
|
init_graphemes();
|
|
25366
|
-
STATUSLINE_HEADER_SEGMENTS = ["model", "provider", "route", "account", "identity", "headroom", "project", "vcs", "effort", "advisor", "version", "outputStyle"];
|
|
25367
|
-
STATUSLINE_ROWS = ["context", "quota", "addedDirs", "gitFiles"];
|
|
25366
|
+
STATUSLINE_HEADER_SEGMENTS = ["model", "provider", "route", "account", "identity", "headroom", "project", "vcs", "effort", "advisor", "version", "outputStyle", "cost", "dailyCost"];
|
|
25367
|
+
STATUSLINE_ROWS = ["context", "quota", "addedDirs", "gitFiles", "memory", "environment"];
|
|
25368
25368
|
STATUSLINE_COLOUR_NAMES = [
|
|
25369
25369
|
"default",
|
|
25370
25370
|
"dim",
|
|
@@ -25455,6 +25455,12 @@ var init_statusline = __esm({
|
|
|
25455
25455
|
hourCycle: external_exports.enum(STATUSLINE_HOUR_CYCLES).describe("The hour cycle of a wall-clock time: `auto` follows the system locale, `h23` and `h24` are 24-hour time (`h24` writes midnight as 24:00), and `h12` and `h11` are 12-hour time with am or pm (`h11` writes the hour after midnight as 0)."),
|
|
25456
25456
|
seconds: external_exports.boolean().describe("Whether a wall-clock time includes seconds (`14:30:07`).")
|
|
25457
25457
|
},
|
|
25458
|
+
cost: {
|
|
25459
|
+
routed: external_exports.boolean().describe("Whether the cost segments draw for a session routed through a provider or a cloud platform's model id, where the client's own figure is not what was billed; the figure drawn is then priced from the door's usage log with `agent-shim model price`, else the client's own when it is above zero.")
|
|
25460
|
+
},
|
|
25461
|
+
environment: {
|
|
25462
|
+
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.")
|
|
25463
|
+
},
|
|
25458
25464
|
colours: {
|
|
25459
25465
|
context: colourValue.describe("The colour of the context bar and its figures below the warning threshold."),
|
|
25460
25466
|
usage: colourValue.describe("The colour of the quota bars and their figures below the warning threshold."),
|
|
@@ -25499,6 +25505,8 @@ var init_statusline = __esm({
|
|
|
25499
25505
|
bar: external_exports.strictObject(SHAPES.bar).partial().optional(),
|
|
25500
25506
|
usage: external_exports.strictObject(SHAPES.usage).partial().optional(),
|
|
25501
25507
|
clock: external_exports.strictObject(SHAPES.clock).partial().optional(),
|
|
25508
|
+
cost: external_exports.strictObject(SHAPES.cost).partial().optional(),
|
|
25509
|
+
environment: external_exports.strictObject(SHAPES.environment).partial().optional(),
|
|
25502
25510
|
colours: external_exports.strictObject(SHAPES.colours).partial().optional(),
|
|
25503
25511
|
project: external_exports.strictObject(SHAPES.project).partial().optional(),
|
|
25504
25512
|
git: external_exports.strictObject(SHAPES.git).partial().optional(),
|
|
@@ -25516,6 +25524,8 @@ var init_statusline = __esm({
|
|
|
25516
25524
|
bar: external_exports.strictObject(SHAPES.bar),
|
|
25517
25525
|
usage: external_exports.strictObject(SHAPES.usage),
|
|
25518
25526
|
clock: external_exports.strictObject(SHAPES.clock),
|
|
25527
|
+
cost: external_exports.strictObject(SHAPES.cost),
|
|
25528
|
+
environment: external_exports.strictObject(SHAPES.environment),
|
|
25519
25529
|
colours: external_exports.strictObject(SHAPES.colours),
|
|
25520
25530
|
project: external_exports.strictObject(SHAPES.project),
|
|
25521
25531
|
git: external_exports.strictObject(SHAPES.git),
|
|
@@ -25533,6 +25543,8 @@ var init_statusline = __esm({
|
|
|
25533
25543
|
bar: { width: 10, filled: "\u2588", empty: "\u2591" },
|
|
25534
25544
|
usage: { value: "used", bar: true, compact: false, resetLabel: false, modelScoped: false, timeFormat: "relative", threshold: 0, sevenDayThreshold: 0 },
|
|
25535
25545
|
clock: { hourCycle: "auto", seconds: false },
|
|
25546
|
+
cost: { routed: false },
|
|
25547
|
+
environment: { threshold: 0 },
|
|
25536
25548
|
colours: {
|
|
25537
25549
|
context: "green",
|
|
25538
25550
|
usage: "green",
|
|
@@ -30638,8 +30650,8 @@ var require_utils = __commonJS({
|
|
|
30638
30650
|
}
|
|
30639
30651
|
return output2;
|
|
30640
30652
|
};
|
|
30641
|
-
exports2.basename = (
|
|
30642
|
-
const segs =
|
|
30653
|
+
exports2.basename = (path71, { windows } = {}) => {
|
|
30654
|
+
const segs = path71.split(windows ? /[\\/]/ : "/");
|
|
30643
30655
|
const last = segs[segs.length - 1];
|
|
30644
30656
|
if (last === "") {
|
|
30645
30657
|
return segs[segs.length - 2];
|
|
@@ -30721,16 +30733,16 @@ var require_scan = __commonJS({
|
|
|
30721
30733
|
let token = { value: "", depth: 0, isGlob: false };
|
|
30722
30734
|
const eos = () => index >= length;
|
|
30723
30735
|
const peek = () => str.charCodeAt(index + 1);
|
|
30724
|
-
const
|
|
30736
|
+
const advance2 = () => {
|
|
30725
30737
|
prev = code;
|
|
30726
30738
|
return str.charCodeAt(++index);
|
|
30727
30739
|
};
|
|
30728
30740
|
while (index < length) {
|
|
30729
|
-
code =
|
|
30741
|
+
code = advance2();
|
|
30730
30742
|
let next;
|
|
30731
30743
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30732
30744
|
backslashes = token.backslashes = true;
|
|
30733
|
-
code =
|
|
30745
|
+
code = advance2();
|
|
30734
30746
|
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
30735
30747
|
braceEscaped = true;
|
|
30736
30748
|
}
|
|
@@ -30738,17 +30750,17 @@ var require_scan = __commonJS({
|
|
|
30738
30750
|
}
|
|
30739
30751
|
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
30740
30752
|
braces++;
|
|
30741
|
-
while (eos() !== true && (code =
|
|
30753
|
+
while (eos() !== true && (code = advance2())) {
|
|
30742
30754
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30743
30755
|
backslashes = token.backslashes = true;
|
|
30744
|
-
|
|
30756
|
+
advance2();
|
|
30745
30757
|
continue;
|
|
30746
30758
|
}
|
|
30747
30759
|
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
30748
30760
|
braces++;
|
|
30749
30761
|
continue;
|
|
30750
30762
|
}
|
|
30751
|
-
if (braceEscaped !== true && code === CHAR_DOT && (code =
|
|
30763
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance2()) === CHAR_DOT) {
|
|
30752
30764
|
isBrace = token.isBrace = true;
|
|
30753
30765
|
isGlob = token.isGlob = true;
|
|
30754
30766
|
finished = true;
|
|
@@ -30804,10 +30816,10 @@ var require_scan = __commonJS({
|
|
|
30804
30816
|
}
|
|
30805
30817
|
if (scanToEnd === true) {
|
|
30806
30818
|
let parens = 0;
|
|
30807
|
-
while (eos() !== true && (code =
|
|
30819
|
+
while (eos() !== true && (code = advance2())) {
|
|
30808
30820
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30809
30821
|
backslashes = token.backslashes = true;
|
|
30810
|
-
|
|
30822
|
+
advance2();
|
|
30811
30823
|
continue;
|
|
30812
30824
|
}
|
|
30813
30825
|
if (code === CHAR_LEFT_PARENTHESES) {
|
|
@@ -30842,10 +30854,10 @@ var require_scan = __commonJS({
|
|
|
30842
30854
|
break;
|
|
30843
30855
|
}
|
|
30844
30856
|
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
30845
|
-
while (eos() !== true && (next =
|
|
30857
|
+
while (eos() !== true && (next = advance2())) {
|
|
30846
30858
|
if (next === CHAR_BACKWARD_SLASH) {
|
|
30847
30859
|
backslashes = token.backslashes = true;
|
|
30848
|
-
|
|
30860
|
+
advance2();
|
|
30849
30861
|
continue;
|
|
30850
30862
|
}
|
|
30851
30863
|
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
@@ -30869,10 +30881,10 @@ var require_scan = __commonJS({
|
|
|
30869
30881
|
isGlob = token.isGlob = true;
|
|
30870
30882
|
if (scanToEnd === true) {
|
|
30871
30883
|
let parens = 1;
|
|
30872
|
-
while (eos() !== true && (code =
|
|
30884
|
+
while (eos() !== true && (code = advance2())) {
|
|
30873
30885
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30874
30886
|
backslashes = token.backslashes = true;
|
|
30875
|
-
|
|
30887
|
+
advance2();
|
|
30876
30888
|
continue;
|
|
30877
30889
|
}
|
|
30878
30890
|
if (code === CHAR_LEFT_PARENTHESES) {
|
|
@@ -31308,7 +31320,7 @@ var require_parse = __commonJS({
|
|
|
31308
31320
|
let value2;
|
|
31309
31321
|
const eos = () => state.index === len - 1;
|
|
31310
31322
|
const peek = state.peek = (n10 = 1) => input2[state.index + n10];
|
|
31311
|
-
const
|
|
31323
|
+
const advance2 = state.advance = () => input2[++state.index] || "";
|
|
31312
31324
|
const remaining = () => input2.slice(state.index + 1);
|
|
31313
31325
|
const consume = (value3 = "", num = 0) => {
|
|
31314
31326
|
state.consumed += value3;
|
|
@@ -31321,7 +31333,7 @@ var require_parse = __commonJS({
|
|
|
31321
31333
|
const negate = () => {
|
|
31322
31334
|
let count = 1;
|
|
31323
31335
|
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
31324
|
-
|
|
31336
|
+
advance2();
|
|
31325
31337
|
state.start++;
|
|
31326
31338
|
count++;
|
|
31327
31339
|
}
|
|
@@ -31375,7 +31387,7 @@ var require_parse = __commonJS({
|
|
|
31375
31387
|
const output2 = (opts.capture ? "(" : "") + token.open;
|
|
31376
31388
|
increment("parens");
|
|
31377
31389
|
push({ type: type2, value: value3, output: state.output ? "" : ONE_CHAR });
|
|
31378
|
-
push({ type: "paren", extglob: true, value:
|
|
31390
|
+
push({ type: "paren", extglob: true, value: advance2(), output: output2 });
|
|
31379
31391
|
extglobs.push(token);
|
|
31380
31392
|
};
|
|
31381
31393
|
const extglobClose = (token) => {
|
|
@@ -31464,7 +31476,7 @@ var require_parse = __commonJS({
|
|
|
31464
31476
|
return state;
|
|
31465
31477
|
}
|
|
31466
31478
|
while (!eos()) {
|
|
31467
|
-
value2 =
|
|
31479
|
+
value2 = advance2();
|
|
31468
31480
|
if (value2 === "\0") {
|
|
31469
31481
|
continue;
|
|
31470
31482
|
}
|
|
@@ -31491,9 +31503,9 @@ var require_parse = __commonJS({
|
|
|
31491
31503
|
}
|
|
31492
31504
|
}
|
|
31493
31505
|
if (opts.unescape === true) {
|
|
31494
|
-
value2 =
|
|
31506
|
+
value2 = advance2();
|
|
31495
31507
|
} else {
|
|
31496
|
-
value2 +=
|
|
31508
|
+
value2 += advance2();
|
|
31497
31509
|
}
|
|
31498
31510
|
if (state.brackets === 0) {
|
|
31499
31511
|
push({ type: "text", value: value2 });
|
|
@@ -31513,7 +31525,7 @@ var require_parse = __commonJS({
|
|
|
31513
31525
|
if (posix) {
|
|
31514
31526
|
prev.value = pre2 + posix;
|
|
31515
31527
|
state.backtrack = true;
|
|
31516
|
-
|
|
31528
|
+
advance2();
|
|
31517
31529
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
31518
31530
|
bos.output = ONE_CHAR;
|
|
31519
31531
|
}
|
|
@@ -31849,7 +31861,7 @@ var require_parse = __commonJS({
|
|
|
31849
31861
|
prev.value += value2;
|
|
31850
31862
|
state.output += prior.output + prev.output;
|
|
31851
31863
|
state.globstar = true;
|
|
31852
|
-
consume(value2 +
|
|
31864
|
+
consume(value2 + advance2());
|
|
31853
31865
|
push({ type: "slash", value: "/", output: "" });
|
|
31854
31866
|
continue;
|
|
31855
31867
|
}
|
|
@@ -31859,7 +31871,7 @@ var require_parse = __commonJS({
|
|
|
31859
31871
|
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
31860
31872
|
state.output = prev.output;
|
|
31861
31873
|
state.globstar = true;
|
|
31862
|
-
consume(value2 +
|
|
31874
|
+
consume(value2 + advance2());
|
|
31863
31875
|
push({ type: "slash", value: "/", output: "" });
|
|
31864
31876
|
continue;
|
|
31865
31877
|
}
|
|
@@ -32404,9 +32416,9 @@ var init_identity = __esm({
|
|
|
32404
32416
|
});
|
|
32405
32417
|
|
|
32406
32418
|
// src/statusline/keys.ts
|
|
32407
|
-
function valueAt(source,
|
|
32419
|
+
function valueAt(source, path71) {
|
|
32408
32420
|
let current = source;
|
|
32409
|
-
for (const part of
|
|
32421
|
+
for (const part of path71) {
|
|
32410
32422
|
if (!isPlainObject2(current)) {
|
|
32411
32423
|
return void 0;
|
|
32412
32424
|
}
|
|
@@ -32414,8 +32426,8 @@ function valueAt(source, path68) {
|
|
|
32414
32426
|
}
|
|
32415
32427
|
return current;
|
|
32416
32428
|
}
|
|
32417
|
-
function keyOf(
|
|
32418
|
-
const common = { path:
|
|
32429
|
+
function keyOf(path71, leaf) {
|
|
32430
|
+
const common = { path: path71.join("."), description: leaf.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path71) };
|
|
32419
32431
|
if (leaf instanceof external_exports.ZodNumber) {
|
|
32420
32432
|
return { ...common, kind: "integer", choices: [] };
|
|
32421
32433
|
}
|
|
@@ -32434,7 +32446,7 @@ function keyOf(path68, leaf) {
|
|
|
32434
32446
|
if (leaf instanceof external_exports.ZodArray && leaf.element instanceof external_exports.ZodEnum) {
|
|
32435
32447
|
return { ...common, kind: "list", choices: Object.values(leaf.element.enum).map(String) };
|
|
32436
32448
|
}
|
|
32437
|
-
throw new TypeError(`statusline setting ${
|
|
32449
|
+
throw new TypeError(`statusline setting ${path71.join(".")} has a kind the key listing does not describe`);
|
|
32438
32450
|
}
|
|
32439
32451
|
function walk(shape, prefix) {
|
|
32440
32452
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof external_exports.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -32458,10 +32470,10 @@ var init_keys = __esm({
|
|
|
32458
32470
|
});
|
|
32459
32471
|
|
|
32460
32472
|
// src/statusline/change.ts
|
|
32461
|
-
function keyNamed(
|
|
32462
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
32473
|
+
function keyNamed(path71) {
|
|
32474
|
+
const found = statuslineKeys().find((key) => key.path === path71);
|
|
32463
32475
|
if (found === void 0) {
|
|
32464
|
-
throw new UsageError(`"${
|
|
32476
|
+
throw new UsageError(`"${path71}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
32465
32477
|
}
|
|
32466
32478
|
return found;
|
|
32467
32479
|
}
|
|
@@ -32470,35 +32482,35 @@ function parseStatuslineAssignment(text4) {
|
|
|
32470
32482
|
if (split < 1) {
|
|
32471
32483
|
throw new UsageError(`"${text4}" is not <setting>=<value>.`);
|
|
32472
32484
|
}
|
|
32473
|
-
const
|
|
32485
|
+
const path71 = text4.slice(0, split);
|
|
32474
32486
|
const raw = text4.slice(split + 1);
|
|
32475
|
-
const key = keyNamed(
|
|
32487
|
+
const key = keyNamed(path71);
|
|
32476
32488
|
switch (key.kind) {
|
|
32477
32489
|
case "integer": {
|
|
32478
32490
|
const number5 = Number(raw);
|
|
32479
32491
|
if (raw.trim() === "" || !Number.isFinite(number5)) {
|
|
32480
|
-
throw new UsageError(`${
|
|
32492
|
+
throw new UsageError(`${path71}: "${raw}" is not a number.`);
|
|
32481
32493
|
}
|
|
32482
|
-
return { path:
|
|
32494
|
+
return { path: path71, value: number5 };
|
|
32483
32495
|
}
|
|
32484
32496
|
case "boolean":
|
|
32485
32497
|
if (raw !== "true" && raw !== "false") {
|
|
32486
|
-
throw new UsageError(`${
|
|
32498
|
+
throw new UsageError(`${path71}: "${raw}" is not true or false.`);
|
|
32487
32499
|
}
|
|
32488
|
-
return { path:
|
|
32500
|
+
return { path: path71, value: raw === "true" };
|
|
32489
32501
|
case "text":
|
|
32490
32502
|
case "choice":
|
|
32491
|
-
return { path:
|
|
32503
|
+
return { path: path71, value: raw };
|
|
32492
32504
|
case "colour":
|
|
32493
|
-
return { path:
|
|
32505
|
+
return { path: path71, value: /^\d+$/.test(raw) ? Number(raw) : raw };
|
|
32494
32506
|
case "list":
|
|
32495
|
-
return { path:
|
|
32507
|
+
return { path: path71, value: raw === "" ? [] : raw.split(",") };
|
|
32496
32508
|
default:
|
|
32497
32509
|
return key.kind;
|
|
32498
32510
|
}
|
|
32499
32511
|
}
|
|
32500
|
-
function setAt(target,
|
|
32501
|
-
const [head, ...rest] =
|
|
32512
|
+
function setAt(target, path71, value2) {
|
|
32513
|
+
const [head, ...rest] = path71;
|
|
32502
32514
|
if (head === void 0) {
|
|
32503
32515
|
return;
|
|
32504
32516
|
}
|
|
@@ -32511,8 +32523,8 @@ function setAt(target, path68, value2) {
|
|
|
32511
32523
|
target[head] = next;
|
|
32512
32524
|
setAt(next, rest, value2);
|
|
32513
32525
|
}
|
|
32514
|
-
function removeAt(target,
|
|
32515
|
-
const [head, ...rest] =
|
|
32526
|
+
function removeAt(target, path71) {
|
|
32527
|
+
const [head, ...rest] = path71;
|
|
32516
32528
|
if (head === void 0) {
|
|
32517
32529
|
return;
|
|
32518
32530
|
}
|
|
@@ -32530,13 +32542,13 @@ function removeAt(target, path68) {
|
|
|
32530
32542
|
}
|
|
32531
32543
|
function applyStatuslineChange(existing, change) {
|
|
32532
32544
|
const draft = structuredClone(existing ?? {});
|
|
32533
|
-
for (const [
|
|
32534
|
-
keyNamed(
|
|
32535
|
-
setAt(draft,
|
|
32545
|
+
for (const [path71, value2] of Object.entries(change.set ?? {})) {
|
|
32546
|
+
keyNamed(path71);
|
|
32547
|
+
setAt(draft, path71.split("."), value2);
|
|
32536
32548
|
}
|
|
32537
|
-
for (const
|
|
32538
|
-
keyNamed(
|
|
32539
|
-
removeAt(draft,
|
|
32549
|
+
for (const path71 of change.unset ?? []) {
|
|
32550
|
+
keyNamed(path71);
|
|
32551
|
+
removeAt(draft, path71.split("."));
|
|
32540
32552
|
}
|
|
32541
32553
|
const result = StatuslineSchema.safeParse(draft);
|
|
32542
32554
|
if (!result.success) {
|
|
@@ -34773,6 +34785,7 @@ function buildLayoutPaths(root) {
|
|
|
34773
34785
|
usageDir: import_node_path20.default.join(root, "usage"),
|
|
34774
34786
|
usageLogDir: import_node_path20.default.join(root, "usage", "log"),
|
|
34775
34787
|
usageSnapshotsDir: import_node_path20.default.join(root, "usage", "snapshots"),
|
|
34788
|
+
statuslineDir: import_node_path20.default.join(root, "statusline"),
|
|
34776
34789
|
catalogueDir: import_node_path20.default.join(root, "catalogues"),
|
|
34777
34790
|
usagePicksFile: import_node_path20.default.join(root, "usage", "picks.json"),
|
|
34778
34791
|
usageAnchorsFile: import_node_path20.default.join(root, "usage", "anchors.json"),
|
|
@@ -34843,7 +34856,7 @@ function isRateLimitHeader(name) {
|
|
|
34843
34856
|
const lower = name.toLowerCase();
|
|
34844
34857
|
return lower === "retry-after" || lower.startsWith("anthropic-ratelimit-") || lower.startsWith("x-ratelimit-") || lower.startsWith("ratelimit") || lower.startsWith("x-codex-");
|
|
34845
34858
|
}
|
|
34846
|
-
var USAGE_SCHEMA_VERSION, VersionSchema, InstantSchema, TokenCountSchema, TokenUsageSchema, LIMIT_KINDS, LimitClassificationSchema, UsageRecordSchema, QuotaWindowSchema, ExtraUsageSpendSchema, UnifiedRateLimitSchema, RateLimitStateSchema, LimitEventSchema, ProviderQuotaWindowSchema, ProviderAccountSchema, ProviderQuotaSchema, ProviderUsageStateSchema, AccountMetadataSchema, UsageSnapshotSchema;
|
|
34859
|
+
var USAGE_SCHEMA_VERSION, VersionSchema, InstantSchema, CLIENT_SESSION_ID_PATTERN, TokenCountSchema, TokenUsageSchema, LIMIT_KINDS, LimitClassificationSchema, UsageRecordSchema, QuotaWindowSchema, ExtraUsageSpendSchema, UnifiedRateLimitSchema, RateLimitStateSchema, LimitEventSchema, ProviderQuotaWindowSchema, ProviderAccountSchema, ProviderQuotaSchema, ProviderUsageStateSchema, AccountMetadataSchema, UsageSnapshotSchema;
|
|
34847
34860
|
var init_schema2 = __esm({
|
|
34848
34861
|
"src/usage/schema.ts"() {
|
|
34849
34862
|
"use strict";
|
|
@@ -34851,6 +34864,7 @@ var init_schema2 = __esm({
|
|
|
34851
34864
|
USAGE_SCHEMA_VERSION = 1;
|
|
34852
34865
|
VersionSchema = external_exports.literal(USAGE_SCHEMA_VERSION);
|
|
34853
34866
|
InstantSchema = external_exports.iso.datetime();
|
|
34867
|
+
CLIENT_SESSION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
34854
34868
|
TokenCountSchema = external_exports.number().int().nonnegative();
|
|
34855
34869
|
TokenUsageSchema = external_exports.strictObject({
|
|
34856
34870
|
inputTokens: TokenCountSchema.optional(),
|
|
@@ -34880,6 +34894,8 @@ var init_schema2 = __esm({
|
|
|
34880
34894
|
provider: external_exports.string(),
|
|
34881
34895
|
/** The launch's session id, generated per launch. */
|
|
34882
34896
|
sessionId: external_exports.string().optional(),
|
|
34897
|
+
/** The client's own id for the conversation, from the request's `x-claude-code-session-id` header: it changes when the conversation is cleared inside one launch, which `sessionId` does not, so it is what ties a request to the client's per-conversation figures. Absent when the client sent none. */
|
|
34898
|
+
clientSessionId: external_exports.string().regex(CLIENT_SESSION_ID_PATTERN).optional(),
|
|
34883
34899
|
/** The project the launch ran in (its git repository root), when the launch sent one: headroom launches do. */
|
|
34884
34900
|
project: external_exports.string().optional(),
|
|
34885
34901
|
/** Whether the request crossed headroom on its way upstream. Absent on a record written before the door recorded it, and false when the request went direct. */
|
|
@@ -36009,11 +36025,11 @@ function identifyRequest(headers) {
|
|
|
36009
36025
|
function directOrigin2(port) {
|
|
36010
36026
|
return `http://127.0.0.1:${String(port)}`;
|
|
36011
36027
|
}
|
|
36012
|
-
function parseProviderPath(
|
|
36013
|
-
if (!
|
|
36028
|
+
function parseProviderPath(path71) {
|
|
36029
|
+
if (!path71.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
36014
36030
|
return void 0;
|
|
36015
36031
|
}
|
|
36016
|
-
const tail =
|
|
36032
|
+
const tail = path71.slice(PROVIDER_PATH_PREFIX.length);
|
|
36017
36033
|
const slash = tail.indexOf("/");
|
|
36018
36034
|
if (slash <= 0) {
|
|
36019
36035
|
return void 0;
|
|
@@ -36287,8 +36303,8 @@ function parseConnectTarget(authority) {
|
|
|
36287
36303
|
}
|
|
36288
36304
|
return { host, port };
|
|
36289
36305
|
}
|
|
36290
|
-
function servedByPipeline(
|
|
36291
|
-
return
|
|
36306
|
+
function servedByPipeline(path71) {
|
|
36307
|
+
return path71?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
36292
36308
|
}
|
|
36293
36309
|
function forwardableHeaders(headers) {
|
|
36294
36310
|
const connectionTokens = new Set(
|
|
@@ -36766,7 +36782,7 @@ var init_package = __esm({
|
|
|
36766
36782
|
"package.json"() {
|
|
36767
36783
|
package_default = {
|
|
36768
36784
|
name: "claude-use",
|
|
36769
|
-
version: "11.
|
|
36785
|
+
version: "11.57.0",
|
|
36770
36786
|
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.",
|
|
36771
36787
|
license: "MIT",
|
|
36772
36788
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -37289,12 +37305,12 @@ function decoderFor(encoding) {
|
|
|
37289
37305
|
return void 0;
|
|
37290
37306
|
}
|
|
37291
37307
|
}
|
|
37292
|
-
function destinationOf(
|
|
37293
|
-
const scoped = parseProviderPath(
|
|
37308
|
+
function destinationOf(path71, sessionProvider) {
|
|
37309
|
+
const scoped = parseProviderPath(path71);
|
|
37294
37310
|
if (scoped !== void 0) {
|
|
37295
37311
|
return { provider: scoped.provider, endpoint: scoped.rest };
|
|
37296
37312
|
}
|
|
37297
|
-
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint:
|
|
37313
|
+
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint: path71 };
|
|
37298
37314
|
}
|
|
37299
37315
|
function modelChoiceOf(event, servedModel, provider) {
|
|
37300
37316
|
if (event.modelChoice !== void 0) return event.modelChoice;
|
|
@@ -37315,6 +37331,7 @@ function buildRecord(event, context) {
|
|
|
37315
37331
|
...identity === void 0 ? {} : { identity },
|
|
37316
37332
|
provider,
|
|
37317
37333
|
...sessionId === void 0 ? {} : { sessionId },
|
|
37334
|
+
...event.clientSessionId === void 0 ? {} : { clientSessionId: event.clientSessionId },
|
|
37318
37335
|
...projectId === void 0 ? {} : { project: projectId },
|
|
37319
37336
|
viaHeadroom: event.viaHeadroom,
|
|
37320
37337
|
route: event.route,
|
|
@@ -40328,14 +40345,14 @@ var require_util2 = __commonJS({
|
|
|
40328
40345
|
}
|
|
40329
40346
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
40330
40347
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
40331
|
-
let
|
|
40348
|
+
let path71 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
40332
40349
|
if (origin[origin.length - 1] === "/") {
|
|
40333
40350
|
origin = origin.slice(0, origin.length - 1);
|
|
40334
40351
|
}
|
|
40335
|
-
if (
|
|
40336
|
-
|
|
40352
|
+
if (path71 && path71[0] !== "/") {
|
|
40353
|
+
path71 = `/${path71}`;
|
|
40337
40354
|
}
|
|
40338
|
-
return new URL(`${origin}${
|
|
40355
|
+
return new URL(`${origin}${path71}`);
|
|
40339
40356
|
}
|
|
40340
40357
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
40341
40358
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -41156,9 +41173,9 @@ var require_diagnostics = __commonJS({
|
|
|
41156
41173
|
"undici:client:sendHeaders",
|
|
41157
41174
|
(evt) => {
|
|
41158
41175
|
const {
|
|
41159
|
-
request: { method, path:
|
|
41176
|
+
request: { method, path: path71, origin }
|
|
41160
41177
|
} = evt;
|
|
41161
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
41178
|
+
debugLog("sending request to %s %s%s", method, origin, path71);
|
|
41162
41179
|
}
|
|
41163
41180
|
);
|
|
41164
41181
|
}
|
|
@@ -41176,14 +41193,14 @@ var require_diagnostics = __commonJS({
|
|
|
41176
41193
|
"undici:request:headers",
|
|
41177
41194
|
(evt) => {
|
|
41178
41195
|
const {
|
|
41179
|
-
request: { method, path:
|
|
41196
|
+
request: { method, path: path71, origin },
|
|
41180
41197
|
response: { statusCode }
|
|
41181
41198
|
} = evt;
|
|
41182
41199
|
debugLog(
|
|
41183
41200
|
"received response to %s %s%s - HTTP %d",
|
|
41184
41201
|
method,
|
|
41185
41202
|
origin,
|
|
41186
|
-
|
|
41203
|
+
path71,
|
|
41187
41204
|
statusCode
|
|
41188
41205
|
);
|
|
41189
41206
|
}
|
|
@@ -41192,23 +41209,23 @@ var require_diagnostics = __commonJS({
|
|
|
41192
41209
|
"undici:request:trailers",
|
|
41193
41210
|
(evt) => {
|
|
41194
41211
|
const {
|
|
41195
|
-
request: { method, path:
|
|
41212
|
+
request: { method, path: path71, origin }
|
|
41196
41213
|
} = evt;
|
|
41197
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
41214
|
+
debugLog("trailers received from %s %s%s", method, origin, path71);
|
|
41198
41215
|
}
|
|
41199
41216
|
);
|
|
41200
41217
|
diagnosticsChannel.subscribe(
|
|
41201
41218
|
"undici:request:error",
|
|
41202
41219
|
(evt) => {
|
|
41203
41220
|
const {
|
|
41204
|
-
request: { method, path:
|
|
41221
|
+
request: { method, path: path71, origin },
|
|
41205
41222
|
error: error63
|
|
41206
41223
|
} = evt;
|
|
41207
41224
|
debugLog(
|
|
41208
41225
|
"request to %s %s%s errored - %s",
|
|
41209
41226
|
method,
|
|
41210
41227
|
origin,
|
|
41211
|
-
|
|
41228
|
+
path71,
|
|
41212
41229
|
error63.message
|
|
41213
41230
|
);
|
|
41214
41231
|
}
|
|
@@ -41323,7 +41340,7 @@ var require_request = __commonJS({
|
|
|
41323
41340
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
41324
41341
|
var Request2 = class {
|
|
41325
41342
|
constructor(origin, {
|
|
41326
|
-
path:
|
|
41343
|
+
path: path71,
|
|
41327
41344
|
method,
|
|
41328
41345
|
body,
|
|
41329
41346
|
headers,
|
|
@@ -41340,11 +41357,11 @@ var require_request = __commonJS({
|
|
|
41340
41357
|
maxRedirections,
|
|
41341
41358
|
typeOfService
|
|
41342
41359
|
}, handler) {
|
|
41343
|
-
if (typeof
|
|
41360
|
+
if (typeof path71 !== "string") {
|
|
41344
41361
|
throw new InvalidArgumentError2("path must be a string");
|
|
41345
|
-
} else if (
|
|
41362
|
+
} else if (path71[0] !== "/" && !(path71.startsWith("http://") || path71.startsWith("https://")) && method !== "CONNECT") {
|
|
41346
41363
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
41347
|
-
} else if (invalidPathRegex.test(
|
|
41364
|
+
} else if (invalidPathRegex.test(path71)) {
|
|
41348
41365
|
throw new InvalidArgumentError2("invalid request path");
|
|
41349
41366
|
}
|
|
41350
41367
|
if (typeof method !== "string") {
|
|
@@ -41419,7 +41436,7 @@ var require_request = __commonJS({
|
|
|
41419
41436
|
this.completed = false;
|
|
41420
41437
|
this.aborted = false;
|
|
41421
41438
|
this.upgrade = upgrade || null;
|
|
41422
|
-
this.path = query ? serializePathWithQuery(
|
|
41439
|
+
this.path = query ? serializePathWithQuery(path71, query) : path71;
|
|
41423
41440
|
this.origin = origin;
|
|
41424
41441
|
this.protocol = getProtocolFromUrlString(origin);
|
|
41425
41442
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -46601,7 +46618,7 @@ var require_client_h1 = __commonJS({
|
|
|
46601
46618
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
46602
46619
|
}
|
|
46603
46620
|
function writeH1(client, request7) {
|
|
46604
|
-
const { method, path:
|
|
46621
|
+
const { method, path: path71, host, upgrade, blocking, reset } = request7;
|
|
46605
46622
|
let { body, headers, contentLength } = request7;
|
|
46606
46623
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
46607
46624
|
if (util2.isFormDataLike(body)) {
|
|
@@ -46679,7 +46696,7 @@ var require_client_h1 = __commonJS({
|
|
|
46679
46696
|
if (socket.setTypeOfService) {
|
|
46680
46697
|
socket.setTypeOfService(request7.typeOfService);
|
|
46681
46698
|
}
|
|
46682
|
-
let header = `${method} ${
|
|
46699
|
+
let header = `${method} ${path71} HTTP/1.1\r
|
|
46683
46700
|
`;
|
|
46684
46701
|
if (typeof host === "string") {
|
|
46685
46702
|
header += `host: ${host}\r
|
|
@@ -47358,7 +47375,7 @@ var require_client_h2 = __commonJS({
|
|
|
47358
47375
|
const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
|
|
47359
47376
|
const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
|
|
47360
47377
|
const session = client[kHTTP2Session];
|
|
47361
|
-
const { method, path:
|
|
47378
|
+
const { method, path: path71, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
|
|
47362
47379
|
let { body } = request7;
|
|
47363
47380
|
if (upgrade != null && upgrade !== "websocket") {
|
|
47364
47381
|
util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -47427,7 +47444,7 @@ var require_client_h2 = __commonJS({
|
|
|
47427
47444
|
}
|
|
47428
47445
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
47429
47446
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
47430
|
-
headers[HTTP2_HEADER_PATH] =
|
|
47447
|
+
headers[HTTP2_HEADER_PATH] = path71;
|
|
47431
47448
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
47432
47449
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
47433
47450
|
} else {
|
|
@@ -47469,7 +47486,7 @@ var require_client_h2 = __commonJS({
|
|
|
47469
47486
|
stream.setTimeout(headersTimeout);
|
|
47470
47487
|
return true;
|
|
47471
47488
|
}
|
|
47472
|
-
headers[HTTP2_HEADER_PATH] =
|
|
47489
|
+
headers[HTTP2_HEADER_PATH] = path71;
|
|
47473
47490
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
47474
47491
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
47475
47492
|
if (body && typeof body.read === "function") {
|
|
@@ -49821,10 +49838,10 @@ var require_proxy_agent = __commonJS({
|
|
|
49821
49838
|
};
|
|
49822
49839
|
const {
|
|
49823
49840
|
origin,
|
|
49824
|
-
path:
|
|
49841
|
+
path: path71 = "/",
|
|
49825
49842
|
headers = {}
|
|
49826
49843
|
} = opts;
|
|
49827
|
-
opts.path = origin +
|
|
49844
|
+
opts.path = origin + path71;
|
|
49828
49845
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
49829
49846
|
const { host } = new URL(origin);
|
|
49830
49847
|
headers.host = host;
|
|
@@ -51933,20 +51950,20 @@ var require_mock_utils = __commonJS({
|
|
|
51933
51950
|
}
|
|
51934
51951
|
return normalizedQp;
|
|
51935
51952
|
}
|
|
51936
|
-
function safeUrl(
|
|
51937
|
-
if (typeof
|
|
51938
|
-
return
|
|
51953
|
+
function safeUrl(path71) {
|
|
51954
|
+
if (typeof path71 !== "string") {
|
|
51955
|
+
return path71;
|
|
51939
51956
|
}
|
|
51940
|
-
const pathSegments =
|
|
51957
|
+
const pathSegments = path71.split("?", 3);
|
|
51941
51958
|
if (pathSegments.length !== 2) {
|
|
51942
|
-
return
|
|
51959
|
+
return path71;
|
|
51943
51960
|
}
|
|
51944
51961
|
const qp2 = new URLSearchParams(pathSegments.pop());
|
|
51945
51962
|
qp2.sort();
|
|
51946
51963
|
return [...pathSegments, qp2.toString()].join("?");
|
|
51947
51964
|
}
|
|
51948
|
-
function matchKey(mockDispatch2, { path:
|
|
51949
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
51965
|
+
function matchKey(mockDispatch2, { path: path71, method, body, headers }) {
|
|
51966
|
+
const pathMatch = matchValue(mockDispatch2.path, path71);
|
|
51950
51967
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
51951
51968
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
51952
51969
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -51971,8 +51988,8 @@ var require_mock_utils = __commonJS({
|
|
|
51971
51988
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
51972
51989
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
51973
51990
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
51974
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
51975
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
51991
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path71, ignoreTrailingSlash }) => {
|
|
51992
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path71)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path71), resolvedPath);
|
|
51976
51993
|
});
|
|
51977
51994
|
if (matchedMockDispatches.length === 0) {
|
|
51978
51995
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -52011,19 +52028,19 @@ var require_mock_utils = __commonJS({
|
|
|
52011
52028
|
mockDispatches.splice(index, 1);
|
|
52012
52029
|
}
|
|
52013
52030
|
}
|
|
52014
|
-
function removeTrailingSlash(
|
|
52015
|
-
while (
|
|
52016
|
-
|
|
52031
|
+
function removeTrailingSlash(path71) {
|
|
52032
|
+
while (path71.endsWith("/")) {
|
|
52033
|
+
path71 = path71.slice(0, -1);
|
|
52017
52034
|
}
|
|
52018
|
-
if (
|
|
52019
|
-
|
|
52035
|
+
if (path71.length === 0) {
|
|
52036
|
+
path71 = "/";
|
|
52020
52037
|
}
|
|
52021
|
-
return
|
|
52038
|
+
return path71;
|
|
52022
52039
|
}
|
|
52023
52040
|
function buildKey(opts) {
|
|
52024
|
-
const { path:
|
|
52041
|
+
const { path: path71, method, body, headers, query } = opts;
|
|
52025
52042
|
return {
|
|
52026
|
-
path:
|
|
52043
|
+
path: path71,
|
|
52027
52044
|
method,
|
|
52028
52045
|
body,
|
|
52029
52046
|
headers,
|
|
@@ -52713,10 +52730,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
52713
52730
|
}
|
|
52714
52731
|
format(pendingInterceptors) {
|
|
52715
52732
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
52716
|
-
({ method, path:
|
|
52733
|
+
({ method, path: path71, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
52717
52734
|
Method: method,
|
|
52718
52735
|
Origin: origin,
|
|
52719
|
-
Path:
|
|
52736
|
+
Path: path71,
|
|
52720
52737
|
"Status code": statusCode,
|
|
52721
52738
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
52722
52739
|
Invocations: timesInvoked,
|
|
@@ -52798,9 +52815,9 @@ var require_mock_agent = __commonJS({
|
|
|
52798
52815
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
52799
52816
|
const dispatchOpts = { ...opts };
|
|
52800
52817
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
52801
|
-
const [
|
|
52818
|
+
const [path71, searchParams] = dispatchOpts.path.split("?");
|
|
52802
52819
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
52803
|
-
dispatchOpts.path = `${
|
|
52820
|
+
dispatchOpts.path = `${path71}?${normalizedSearchParams}`;
|
|
52804
52821
|
}
|
|
52805
52822
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
52806
52823
|
}
|
|
@@ -53201,12 +53218,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53201
53218
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
53202
53219
|
*/
|
|
53203
53220
|
async loadSnapshots(filePath) {
|
|
53204
|
-
const
|
|
53205
|
-
if (!
|
|
53221
|
+
const path71 = filePath || this.#snapshotPath;
|
|
53222
|
+
if (!path71) {
|
|
53206
53223
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
53207
53224
|
}
|
|
53208
53225
|
try {
|
|
53209
|
-
const data = await readFile(resolve2(
|
|
53226
|
+
const data = await readFile(resolve2(path71), "utf8");
|
|
53210
53227
|
const parsed = JSON.parse(data);
|
|
53211
53228
|
if (Array.isArray(parsed)) {
|
|
53212
53229
|
this.#snapshots.clear();
|
|
@@ -53220,7 +53237,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53220
53237
|
if (error63.code === "ENOENT") {
|
|
53221
53238
|
this.#snapshots.clear();
|
|
53222
53239
|
} else {
|
|
53223
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
53240
|
+
throw new UndiciError(`Failed to load snapshots from ${path71}`, { cause: error63 });
|
|
53224
53241
|
}
|
|
53225
53242
|
}
|
|
53226
53243
|
}
|
|
@@ -53231,11 +53248,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53231
53248
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
53232
53249
|
*/
|
|
53233
53250
|
async saveSnapshots(filePath) {
|
|
53234
|
-
const
|
|
53235
|
-
if (!
|
|
53251
|
+
const path71 = filePath || this.#snapshotPath;
|
|
53252
|
+
if (!path71) {
|
|
53236
53253
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
53237
53254
|
}
|
|
53238
|
-
const resolvedPath = resolve2(
|
|
53255
|
+
const resolvedPath = resolve2(path71);
|
|
53239
53256
|
await mkdir(dirname3(resolvedPath), { recursive: true });
|
|
53240
53257
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
53241
53258
|
hash: hash2,
|
|
@@ -53867,15 +53884,15 @@ var require_redirect_handler = __commonJS({
|
|
|
53867
53884
|
return;
|
|
53868
53885
|
}
|
|
53869
53886
|
const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
53870
|
-
const
|
|
53871
|
-
const redirectUrlString = `${origin}${
|
|
53887
|
+
const path71 = search ? `${pathname}${search}` : pathname;
|
|
53888
|
+
const redirectUrlString = `${origin}${path71}`;
|
|
53872
53889
|
for (const historyUrl of this.history) {
|
|
53873
53890
|
if (historyUrl.toString() === redirectUrlString) {
|
|
53874
53891
|
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.`);
|
|
53875
53892
|
}
|
|
53876
53893
|
}
|
|
53877
53894
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
53878
|
-
this.opts.path =
|
|
53895
|
+
this.opts.path = path71;
|
|
53879
53896
|
this.opts.origin = origin;
|
|
53880
53897
|
this.opts.query = null;
|
|
53881
53898
|
}
|
|
@@ -55635,10 +55652,10 @@ var require_cache_handler = __commonJS({
|
|
|
55635
55652
|
}
|
|
55636
55653
|
return locationUrl.pathname + locationUrl.search;
|
|
55637
55654
|
}
|
|
55638
|
-
function deleteCachedUri(store, cacheKey,
|
|
55655
|
+
function deleteCachedUri(store, cacheKey, path71) {
|
|
55639
55656
|
deleteCachedValue(store, {
|
|
55640
55657
|
...cacheKey,
|
|
55641
|
-
path:
|
|
55658
|
+
path: path71
|
|
55642
55659
|
});
|
|
55643
55660
|
for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
|
|
55644
55661
|
const method = util2.safeHTTPMethods[i10];
|
|
@@ -55646,7 +55663,7 @@ var require_cache_handler = __commonJS({
|
|
|
55646
55663
|
deleteCachedValue(store, {
|
|
55647
55664
|
...cacheKey,
|
|
55648
55665
|
method,
|
|
55649
|
-
path:
|
|
55666
|
+
path: path71
|
|
55650
55667
|
});
|
|
55651
55668
|
}
|
|
55652
55669
|
}
|
|
@@ -55657,9 +55674,9 @@ var require_cache_handler = __commonJS({
|
|
|
55657
55674
|
}
|
|
55658
55675
|
const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
|
|
55659
55676
|
for (let i10 = 0; i10 < values.length; i10++) {
|
|
55660
|
-
const
|
|
55661
|
-
if (
|
|
55662
|
-
deleteCachedUri(store, cacheKey,
|
|
55677
|
+
const path71 = getSameOriginPath(cacheKey, values[i10]);
|
|
55678
|
+
if (path71 !== void 0) {
|
|
55679
|
+
deleteCachedUri(store, cacheKey, path71);
|
|
55663
55680
|
}
|
|
55664
55681
|
}
|
|
55665
55682
|
}
|
|
@@ -60659,11 +60676,11 @@ var require_fetch = __commonJS({
|
|
|
60659
60676
|
function dispatch({ body }) {
|
|
60660
60677
|
const url2 = requestCurrentURL(request7);
|
|
60661
60678
|
const agent = fetchParams.controller.dispatcher;
|
|
60662
|
-
const
|
|
60679
|
+
const path71 = url2.pathname + url2.search;
|
|
60663
60680
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
60664
60681
|
return new Promise((resolve2, reject) => agent.dispatch(
|
|
60665
60682
|
{
|
|
60666
|
-
path: hasTrailingQuestionMark ? `${
|
|
60683
|
+
path: hasTrailingQuestionMark ? `${path71}?` : path71,
|
|
60667
60684
|
origin: url2.origin,
|
|
60668
60685
|
method: request7.method,
|
|
60669
60686
|
body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
|
|
@@ -61610,9 +61627,9 @@ var require_util5 = __commonJS({
|
|
|
61610
61627
|
}
|
|
61611
61628
|
}
|
|
61612
61629
|
}
|
|
61613
|
-
function validateCookiePath(
|
|
61614
|
-
for (let i10 = 0; i10 <
|
|
61615
|
-
const code =
|
|
61630
|
+
function validateCookiePath(path71) {
|
|
61631
|
+
for (let i10 = 0; i10 < path71.length; ++i10) {
|
|
61632
|
+
const code = path71.charCodeAt(i10);
|
|
61616
61633
|
if (code < 32 || // exclude CTLs (0-31)
|
|
61617
61634
|
code > 126 || // exclude DEL and non-ascii
|
|
61618
61635
|
code === 59) {
|
|
@@ -64960,11 +64977,11 @@ var require_undici = __commonJS({
|
|
|
64960
64977
|
if (typeof opts.path !== "string") {
|
|
64961
64978
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
64962
64979
|
}
|
|
64963
|
-
let
|
|
64980
|
+
let path71 = opts.path;
|
|
64964
64981
|
if (!opts.path.startsWith("/")) {
|
|
64965
|
-
|
|
64982
|
+
path71 = `/${path71}`;
|
|
64966
64983
|
}
|
|
64967
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
64984
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path71);
|
|
64968
64985
|
} else {
|
|
64969
64986
|
if (!opts) {
|
|
64970
64987
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -66692,8 +66709,8 @@ function routingRows(facts) {
|
|
|
66692
66709
|
];
|
|
66693
66710
|
}
|
|
66694
66711
|
function farmRow(links, builtDirectories, adopted) {
|
|
66695
|
-
const
|
|
66696
|
-
const parts = [
|
|
66712
|
+
const counted2 = (count, singular, plural2) => `${String(count)} ${count === 1 ? singular : plural2}`;
|
|
66713
|
+
const parts = [counted2(links, "link", "links"), counted2(builtDirectories, "built directory", "built directories"), ...adopted === 0 ? [] : [`${String(adopted)} adopted`]];
|
|
66697
66714
|
return { label: "farm", value: "resynced", detail: parts.join(", ") };
|
|
66698
66715
|
}
|
|
66699
66716
|
function noteRow(text4) {
|
|
@@ -106232,8 +106249,8 @@ var require_utils3 = __commonJS({
|
|
|
106232
106249
|
}
|
|
106233
106250
|
return ind;
|
|
106234
106251
|
}
|
|
106235
|
-
function removeDotSegments(
|
|
106236
|
-
let input2 =
|
|
106252
|
+
function removeDotSegments(path71) {
|
|
106253
|
+
let input2 = path71;
|
|
106237
106254
|
const output2 = [];
|
|
106238
106255
|
let nextSlash = -1;
|
|
106239
106256
|
let len = 0;
|
|
@@ -106642,8 +106659,8 @@ var require_schemes = __commonJS({
|
|
|
106642
106659
|
}
|
|
106643
106660
|
if (wsComponent.resourceName) {
|
|
106644
106661
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
106645
|
-
const
|
|
106646
|
-
wsComponent.path =
|
|
106662
|
+
const path71 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
106663
|
+
wsComponent.path = path71 && path71 !== "/" ? path71 : void 0;
|
|
106647
106664
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
106648
106665
|
wsComponent.resourceName = void 0;
|
|
106649
106666
|
}
|
|
@@ -110170,7 +110187,7 @@ var require_dist2 = __commonJS({
|
|
|
110170
110187
|
});
|
|
110171
110188
|
|
|
110172
110189
|
// src/cli.ts
|
|
110173
|
-
var
|
|
110190
|
+
var import_node_path70 = __toESM(require("node:path"), 1);
|
|
110174
110191
|
|
|
110175
110192
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
110176
110193
|
var CommanderError = class extends Error {
|
|
@@ -113283,9 +113300,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
113283
113300
|
* @param {string} [path]
|
|
113284
113301
|
* @return {(string|null|Command)}
|
|
113285
113302
|
*/
|
|
113286
|
-
executableDir(
|
|
113287
|
-
if (
|
|
113288
|
-
this._executableDir =
|
|
113303
|
+
executableDir(path71) {
|
|
113304
|
+
if (path71 === void 0) return this._executableDir;
|
|
113305
|
+
this._executableDir = path71;
|
|
113289
113306
|
return this;
|
|
113290
113307
|
}
|
|
113291
113308
|
/**
|
|
@@ -114761,19 +114778,19 @@ function writePools(paths, pools) {
|
|
|
114761
114778
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
114762
114779
|
}
|
|
114763
114780
|
function poolCycleOf(pools, name) {
|
|
114764
|
-
const walk3 = (current,
|
|
114781
|
+
const walk3 = (current, path71) => {
|
|
114765
114782
|
for (const entry of pools[current]?.identities ?? []) {
|
|
114766
114783
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
114767
114784
|
if (nested === void 0) {
|
|
114768
114785
|
continue;
|
|
114769
114786
|
}
|
|
114770
114787
|
if (nested === name) {
|
|
114771
|
-
return [...
|
|
114788
|
+
return [...path71, nested];
|
|
114772
114789
|
}
|
|
114773
|
-
if (
|
|
114790
|
+
if (path71.includes(nested)) {
|
|
114774
114791
|
continue;
|
|
114775
114792
|
}
|
|
114776
|
-
const found = walk3(nested, [...
|
|
114793
|
+
const found = walk3(nested, [...path71, nested]);
|
|
114777
114794
|
if (found !== void 0) {
|
|
114778
114795
|
return found;
|
|
114779
114796
|
}
|
|
@@ -115974,7 +115991,7 @@ function statuslineChangeOf(options) {
|
|
|
115974
115991
|
return void 0;
|
|
115975
115992
|
}
|
|
115976
115993
|
const assignments = (options.statusline ?? []).map(parseStatuslineAssignment);
|
|
115977
|
-
return { set: Object.fromEntries(assignments.map(({ path:
|
|
115994
|
+
return { set: Object.fromEntries(assignments.map(({ path: path71, value: value2 }) => [path71, value2])), unset: options.unsetStatusline ?? [] };
|
|
115978
115995
|
}
|
|
115979
115996
|
function registerProfileCommand(program2, deps) {
|
|
115980
115997
|
const { paths } = deps;
|
|
@@ -119641,11 +119658,11 @@ function createRcSessionTracker(deps) {
|
|
|
119641
119658
|
};
|
|
119642
119659
|
const observeExchange = (request7) => {
|
|
119643
119660
|
const method = (request7.method ?? "").toUpperCase();
|
|
119644
|
-
const
|
|
119645
|
-
if (!
|
|
119661
|
+
const path71 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
|
|
119662
|
+
if (!path71.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
119646
119663
|
return void 0;
|
|
119647
119664
|
}
|
|
119648
|
-
const tail =
|
|
119665
|
+
const tail = path71.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
119649
119666
|
const facts = {
|
|
119650
119667
|
oauthAuthorization: oauthAuthorizationOf(request7.headers),
|
|
119651
119668
|
anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
|
|
@@ -120014,8 +120031,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
120014
120031
|
function isRcReadFileEncoding(value2) {
|
|
120015
120032
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value2);
|
|
120016
120033
|
}
|
|
120017
|
-
function buildRcReadFilePayload(requestId,
|
|
120018
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
120034
|
+
function buildRcReadFilePayload(requestId, path71, options) {
|
|
120035
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path71, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
120019
120036
|
}
|
|
120020
120037
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
120021
120038
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -120117,15 +120134,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
120117
120134
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
120118
120135
|
return result.ok ? { ...result, requestId } : result;
|
|
120119
120136
|
}
|
|
120120
|
-
async function readRcSessionFile(deps, sessionId,
|
|
120121
|
-
if (
|
|
120137
|
+
async function readRcSessionFile(deps, sessionId, path71, options) {
|
|
120138
|
+
if (path71 === "") {
|
|
120122
120139
|
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" };
|
|
120123
120140
|
}
|
|
120124
120141
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
120125
120142
|
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" };
|
|
120126
120143
|
}
|
|
120127
120144
|
const requestId = deps.newUuid();
|
|
120128
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
120145
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path71, options), `read ${path71} from session ${sessionId}`);
|
|
120129
120146
|
return result.ok ? { ...result, requestId } : result;
|
|
120130
120147
|
}
|
|
120131
120148
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -120296,11 +120313,11 @@ function createRcControlHandler(deps) {
|
|
|
120296
120313
|
path: "read-file",
|
|
120297
120314
|
read: (body) => {
|
|
120298
120315
|
const session = bodyString(body, "session");
|
|
120299
|
-
const
|
|
120316
|
+
const path71 = bodyString(body, "path");
|
|
120300
120317
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
120301
120318
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
120302
|
-
const refused2 = session === void 0 ||
|
|
120303
|
-
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,
|
|
120319
|
+
const refused2 = session === void 0 || path71 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
120320
|
+
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, path71, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
120304
120321
|
}
|
|
120305
120322
|
},
|
|
120306
120323
|
{
|
|
@@ -120610,9 +120627,9 @@ function requestIdOfBody(body) {
|
|
|
120610
120627
|
}
|
|
120611
120628
|
function frontDoorRcControl(transport, token) {
|
|
120612
120629
|
const headers = { authorization: `Bearer ${token}` };
|
|
120613
|
-
const listAnswerOf = async (
|
|
120630
|
+
const listAnswerOf = async (path71, what) => {
|
|
120614
120631
|
try {
|
|
120615
|
-
return await transport.request({ method: "GET", path:
|
|
120632
|
+
return await transport.request({ method: "GET", path: path71, headers });
|
|
120616
120633
|
} catch (error63) {
|
|
120617
120634
|
throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
|
|
120618
120635
|
}
|
|
@@ -120684,10 +120701,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
120684
120701
|
}
|
|
120685
120702
|
return pending;
|
|
120686
120703
|
};
|
|
120687
|
-
const writeOf = async (
|
|
120704
|
+
const writeOf = async (path71, body, describeFailure2) => {
|
|
120688
120705
|
let answer;
|
|
120689
120706
|
try {
|
|
120690
|
-
answer = await transport.request({ method: "POST", path:
|
|
120707
|
+
answer = await transport.request({ method: "POST", path: path71, headers: { ...headers, "content-type": "application/json" }, body });
|
|
120691
120708
|
} catch (error63) {
|
|
120692
120709
|
return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
|
|
120693
120710
|
}
|
|
@@ -120718,10 +120735,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
120718
120735
|
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}`),
|
|
120719
120736
|
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}`),
|
|
120720
120737
|
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}`),
|
|
120721
|
-
readFile: async (sessionId,
|
|
120738
|
+
readFile: async (sessionId, path71, options) => await writeOf(
|
|
120722
120739
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
120723
|
-
JSON.stringify({ session: sessionId, path:
|
|
120724
|
-
(status, message) => `reading ${
|
|
120740
|
+
JSON.stringify({ session: sessionId, path: path71, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
120741
|
+
(status, message) => `reading ${path71} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
120725
120742
|
),
|
|
120726
120743
|
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}`),
|
|
120727
120744
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -121034,12 +121051,12 @@ function tlsFacts(options) {
|
|
|
121034
121051
|
}
|
|
121035
121052
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
121036
121053
|
const agent = new ExemptTlsAgent();
|
|
121037
|
-
const post = async (
|
|
121054
|
+
const post = async (path71, headers, body) => await new Promise((resolve2, reject) => {
|
|
121038
121055
|
const options = {
|
|
121039
121056
|
host: target.host,
|
|
121040
121057
|
port: target.port,
|
|
121041
121058
|
method: "POST",
|
|
121042
|
-
path:
|
|
121059
|
+
path: path71,
|
|
121043
121060
|
// 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.
|
|
121044
121061
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
121045
121062
|
agent
|
|
@@ -121104,12 +121121,12 @@ function lateRcStreamDial(resolve2) {
|
|
|
121104
121121
|
}
|
|
121105
121122
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
121106
121123
|
const agent = new ExemptTlsAgent();
|
|
121107
|
-
const request7 = async (method,
|
|
121124
|
+
const request7 = async (method, path71, headers, body, signal) => await new Promise((resolve2, reject) => {
|
|
121108
121125
|
const options = {
|
|
121109
121126
|
host: target.host,
|
|
121110
121127
|
port: target.port,
|
|
121111
121128
|
method,
|
|
121112
|
-
path:
|
|
121129
|
+
path: path71,
|
|
121113
121130
|
// 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.
|
|
121114
121131
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
121115
121132
|
agent,
|
|
@@ -121151,9 +121168,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
121151
121168
|
return { status, body: await readAll(response) };
|
|
121152
121169
|
},
|
|
121153
121170
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
121154
|
-
const
|
|
121171
|
+
const path71 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
121155
121172
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
121156
|
-
const { status, response } = await request7("GET",
|
|
121173
|
+
const { status, response } = await request7("GET", path71, streamHeaders, void 0, signal);
|
|
121157
121174
|
if (!isSuccessful2(status)) {
|
|
121158
121175
|
await readAll(response);
|
|
121159
121176
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -122554,11 +122571,11 @@ function tryOrUndefined(fn2) {
|
|
|
122554
122571
|
return void 0;
|
|
122555
122572
|
}
|
|
122556
122573
|
}
|
|
122557
|
-
function pathToHttpPath(
|
|
122558
|
-
return `/${
|
|
122574
|
+
function pathToHttpPath(path71) {
|
|
122575
|
+
return `/${path71.map(safeEncodeURIComponent).join("/")}`;
|
|
122559
122576
|
}
|
|
122560
|
-
function normalizeHttpPath(
|
|
122561
|
-
const paths =
|
|
122577
|
+
function normalizeHttpPath(path71) {
|
|
122578
|
+
const paths = path71.split("/");
|
|
122562
122579
|
if (paths.at(0) === "") {
|
|
122563
122580
|
paths.shift();
|
|
122564
122581
|
}
|
|
@@ -122743,9 +122760,9 @@ function isPlainObject3(value2) {
|
|
|
122743
122760
|
function getOwn(object3, key) {
|
|
122744
122761
|
return Object.hasOwn(object3, key) ? object3[key] : void 0;
|
|
122745
122762
|
}
|
|
122746
|
-
function get(object3,
|
|
122763
|
+
function get(object3, path71) {
|
|
122747
122764
|
let current = object3;
|
|
122748
|
-
for (const key of
|
|
122765
|
+
for (const key of path71) {
|
|
122749
122766
|
if (!isTypescriptObject(current)) {
|
|
122750
122767
|
return void 0;
|
|
122751
122768
|
}
|
|
@@ -123968,7 +123985,7 @@ function resolveClientRest(rest) {
|
|
|
123968
123985
|
// rest[1] can be undefined if all fields of FriendlyClientOptions are optional
|
|
123969
123986
|
];
|
|
123970
123987
|
}
|
|
123971
|
-
function createORPCClient(link, { path:
|
|
123988
|
+
function createORPCClient(link, { path: path71 = [], ...options } = {}) {
|
|
123972
123989
|
const procedureClient = (...rest) => {
|
|
123973
123990
|
const [input2, callOptions] = resolveClientRest(rest);
|
|
123974
123991
|
const interceptors = [
|
|
@@ -123977,7 +123994,7 @@ function createORPCClient(link, { path: path68 = [], ...options } = {}) {
|
|
|
123977
123994
|
];
|
|
123978
123995
|
return intercept(
|
|
123979
123996
|
interceptors,
|
|
123980
|
-
{ ...callOptions, input: input2, path:
|
|
123997
|
+
{ ...callOptions, input: input2, path: path71 },
|
|
123981
123998
|
({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
|
|
123982
123999
|
);
|
|
123983
124000
|
};
|
|
@@ -123991,7 +124008,7 @@ function createORPCClient(link, { path: path68 = [], ...options } = {}) {
|
|
|
123991
124008
|
if (client === void 0) {
|
|
123992
124009
|
client = createORPCClient(link, {
|
|
123993
124010
|
...options,
|
|
123994
|
-
path: [...
|
|
124011
|
+
path: [...path71, key],
|
|
123995
124012
|
scoped: options.scoped?.[key]
|
|
123996
124013
|
});
|
|
123997
124014
|
cache.set(key, client);
|
|
@@ -124013,24 +124030,24 @@ var BracketNotationSerializer = class {
|
|
|
124013
124030
|
this.internalSerialize(data, "", true, result);
|
|
124014
124031
|
return result;
|
|
124015
124032
|
}
|
|
124016
|
-
internalSerialize(data,
|
|
124033
|
+
internalSerialize(data, path71, isRoot, result) {
|
|
124017
124034
|
if (Array.isArray(data)) {
|
|
124018
124035
|
data.forEach((item, i10) => {
|
|
124019
|
-
this.internalSerialize(item, isRoot ? i10.toString() : `${
|
|
124036
|
+
this.internalSerialize(item, isRoot ? i10.toString() : `${path71}[${i10}]`, false, result);
|
|
124020
124037
|
});
|
|
124021
124038
|
} else if (isPlainObject3(data)) {
|
|
124022
124039
|
for (const key of Object.keys(data)) {
|
|
124023
|
-
this.internalSerialize(data[key], isRoot ? key : `${
|
|
124040
|
+
this.internalSerialize(data[key], isRoot ? key : `${path71}[${key}]`, false, result);
|
|
124024
124041
|
}
|
|
124025
124042
|
} else {
|
|
124026
|
-
result.push([
|
|
124043
|
+
result.push([path71, data]);
|
|
124027
124044
|
}
|
|
124028
124045
|
}
|
|
124029
124046
|
deserialize(serialized) {
|
|
124030
124047
|
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
124031
124048
|
const root = new NullProtoObj();
|
|
124032
|
-
for (const [
|
|
124033
|
-
const segments = this.parsePath(
|
|
124049
|
+
for (const [path71, value2] of serialized) {
|
|
124050
|
+
const segments = this.parsePath(path71);
|
|
124034
124051
|
let currentRef = root;
|
|
124035
124052
|
let nextSegment = segments[0];
|
|
124036
124053
|
for (let i10 = 1; i10 < segments.length; i10++) {
|
|
@@ -124081,13 +124098,13 @@ var BracketNotationSerializer = class {
|
|
|
124081
124098
|
}
|
|
124082
124099
|
return result;
|
|
124083
124100
|
}
|
|
124084
|
-
parsePath(
|
|
124101
|
+
parsePath(path71) {
|
|
124085
124102
|
const segments = [];
|
|
124086
124103
|
let inBrackets = false;
|
|
124087
124104
|
let currentSegment = "";
|
|
124088
|
-
for (let i10 = 0; i10 <
|
|
124089
|
-
const char =
|
|
124090
|
-
const nextChar =
|
|
124105
|
+
for (let i10 = 0; i10 < path71.length; i10++) {
|
|
124106
|
+
const char = path71[i10];
|
|
124107
|
+
const nextChar = path71[i10 + 1];
|
|
124091
124108
|
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
|
|
124092
124109
|
if (nextChar === void 0) {
|
|
124093
124110
|
inBrackets = false;
|
|
@@ -124103,7 +124120,7 @@ var BracketNotationSerializer = class {
|
|
|
124103
124120
|
currentSegment += char;
|
|
124104
124121
|
}
|
|
124105
124122
|
}
|
|
124106
|
-
return inBrackets || segments.length === 0 ? [
|
|
124123
|
+
return inBrackets || segments.length === 0 ? [path71] : segments;
|
|
124107
124124
|
}
|
|
124108
124125
|
};
|
|
124109
124126
|
var INTEGER_PATTERN = /^0$|^[1-9]\d*$/;
|
|
@@ -124676,11 +124693,11 @@ var OpenAPISerializer = class {
|
|
|
124676
124693
|
return json2;
|
|
124677
124694
|
}
|
|
124678
124695
|
const form = new FormData();
|
|
124679
|
-
for (const [
|
|
124696
|
+
for (const [path71, value22] of this.bracketNotation.serialize(json2)) {
|
|
124680
124697
|
if (value22 instanceof Blob) {
|
|
124681
|
-
form.append(
|
|
124698
|
+
form.append(path71, value22);
|
|
124682
124699
|
} else if (value22 !== void 0 && value22 !== null) {
|
|
124683
|
-
form.append(
|
|
124700
|
+
form.append(path71, String(value22));
|
|
124684
124701
|
}
|
|
124685
124702
|
}
|
|
124686
124703
|
return form;
|
|
@@ -124718,30 +124735,30 @@ function isBodylessMethod(method) {
|
|
|
124718
124735
|
return method === "GET" || method === "HEAD";
|
|
124719
124736
|
}
|
|
124720
124737
|
var PARAMETER_NAME_REGEX = /^[\w-]+$/;
|
|
124721
|
-
function getDynamicPathParams(
|
|
124722
|
-
if (!
|
|
124738
|
+
function getDynamicPathParams(path71) {
|
|
124739
|
+
if (!path71.includes("{")) {
|
|
124723
124740
|
return void 0;
|
|
124724
124741
|
}
|
|
124725
|
-
const len =
|
|
124742
|
+
const len = path71.length;
|
|
124726
124743
|
let params;
|
|
124727
124744
|
let index = 1;
|
|
124728
124745
|
while (index < len) {
|
|
124729
124746
|
const segmentStart = index;
|
|
124730
|
-
const slashPos =
|
|
124747
|
+
const slashPos = path71.indexOf("/", index);
|
|
124731
124748
|
const segmentEnd = slashPos === -1 ? len : slashPos;
|
|
124732
|
-
if (segmentEnd > segmentStart &&
|
|
124749
|
+
if (segmentEnd > segmentStart && path71.charCodeAt(segmentStart) === 123 && path71.charCodeAt(segmentEnd - 1) === 125) {
|
|
124733
124750
|
let parameterStart = segmentStart + 1;
|
|
124734
124751
|
let allowsSlash = false;
|
|
124735
|
-
const operator =
|
|
124752
|
+
const operator = path71.charCodeAt(parameterStart);
|
|
124736
124753
|
if (operator === 43) {
|
|
124737
124754
|
allowsSlash = true;
|
|
124738
124755
|
parameterStart++;
|
|
124739
124756
|
}
|
|
124740
|
-
const parameterName =
|
|
124757
|
+
const parameterName = path71.slice(parameterStart, segmentEnd - 1);
|
|
124741
124758
|
if (PARAMETER_NAME_REGEX.test(parameterName)) {
|
|
124742
124759
|
params ??= [];
|
|
124743
124760
|
params.push({
|
|
124744
|
-
segment:
|
|
124761
|
+
segment: path71.slice(segmentStart, segmentEnd),
|
|
124745
124762
|
startIndex: segmentStart,
|
|
124746
124763
|
parameterName,
|
|
124747
124764
|
allowsSlash
|
|
@@ -124784,8 +124801,8 @@ openapi.method = (method) => ({
|
|
|
124784
124801
|
...openapi({ method }),
|
|
124785
124802
|
name: "~openapi/method"
|
|
124786
124803
|
});
|
|
124787
|
-
openapi.path = (
|
|
124788
|
-
...openapi({ path:
|
|
124804
|
+
openapi.path = (path71) => ({
|
|
124805
|
+
...openapi({ path: path71 }),
|
|
124789
124806
|
name: "~openapi/path"
|
|
124790
124807
|
});
|
|
124791
124808
|
openapi.spec = (spec) => ({
|
|
@@ -125646,22 +125663,22 @@ function visitJsonSchemaRefs(value2, visit2, schemaLevel = true, seen = /* @__PU
|
|
|
125646
125663
|
}
|
|
125647
125664
|
}
|
|
125648
125665
|
}
|
|
125649
|
-
function mapJsonSchemaRefs(value2, map2, schemaLevel = true,
|
|
125666
|
+
function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path71 = []) {
|
|
125650
125667
|
if (!value2 || typeof value2 !== "object") {
|
|
125651
125668
|
return value2;
|
|
125652
125669
|
}
|
|
125653
125670
|
if (Array.isArray(value2)) {
|
|
125654
|
-
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...
|
|
125671
|
+
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path71, index]));
|
|
125655
125672
|
}
|
|
125656
125673
|
const result = {};
|
|
125657
125674
|
for (const key of Object.keys(value2)) {
|
|
125658
125675
|
const val = value2[key];
|
|
125659
125676
|
if (key === "$ref" && typeof val === "string") {
|
|
125660
|
-
setOwn(result, key, map2(val, [...
|
|
125677
|
+
setOwn(result, key, map2(val, [...path71, key]));
|
|
125661
125678
|
} else if (!schemaLevel) {
|
|
125662
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...
|
|
125679
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path71, key]));
|
|
125663
125680
|
} else if (JSON_SCHEMA_LOGIC_KEYWORDS.has(key) || JSON_SCHEMA_RECORD_KEYWORDS.has(key)) {
|
|
125664
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...
|
|
125681
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path71, key]));
|
|
125665
125682
|
} else {
|
|
125666
125683
|
setOwn(result, key, val);
|
|
125667
125684
|
}
|
|
@@ -126191,7 +126208,7 @@ function unlazy(maybeLazy) {
|
|
|
126191
126208
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
126192
126209
|
const options = resolveMaybeOptionalOptions(rest);
|
|
126193
126210
|
return async (...[input2, callerOptions]) => {
|
|
126194
|
-
const
|
|
126211
|
+
const path71 = toArray(options.path);
|
|
126195
126212
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
126196
126213
|
const clientContext = callerOptions?.context ?? {};
|
|
126197
126214
|
const context = await value(options.context, clientContext) ?? {};
|
|
@@ -126204,7 +126221,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
126204
126221
|
};
|
|
126205
126222
|
try {
|
|
126206
126223
|
const output2 = await runWithSpan("call_procedure", (span) => {
|
|
126207
|
-
span?.setAttribute("procedure.path",
|
|
126224
|
+
span?.setAttribute("procedure.path", path71);
|
|
126208
126225
|
return intercept(
|
|
126209
126226
|
options.interceptors,
|
|
126210
126227
|
{
|
|
@@ -126212,7 +126229,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
126212
126229
|
// input can be optional if it is undefinable
|
|
126213
126230
|
input: input2,
|
|
126214
126231
|
errors,
|
|
126215
|
-
path:
|
|
126232
|
+
path: path71,
|
|
126216
126233
|
procedure,
|
|
126217
126234
|
signal: callerOptions?.signal,
|
|
126218
126235
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -126463,10 +126480,10 @@ function augmentRouter(router, options) {
|
|
|
126463
126480
|
}
|
|
126464
126481
|
return enhanced;
|
|
126465
126482
|
}
|
|
126466
|
-
function getRouter(router,
|
|
126483
|
+
function getRouter(router, path71) {
|
|
126467
126484
|
let current = router;
|
|
126468
|
-
for (let i10 = 0; i10 <
|
|
126469
|
-
const segment =
|
|
126485
|
+
for (let i10 = 0; i10 < path71.length; i10++) {
|
|
126486
|
+
const segment = path71[i10];
|
|
126470
126487
|
if (!isTypescriptObject(current)) {
|
|
126471
126488
|
return void 0;
|
|
126472
126489
|
}
|
|
@@ -126478,7 +126495,7 @@ function getRouter(router, path68) {
|
|
|
126478
126495
|
continue;
|
|
126479
126496
|
}
|
|
126480
126497
|
const lazied = current;
|
|
126481
|
-
const rest =
|
|
126498
|
+
const rest = path71.slice(i10);
|
|
126482
126499
|
return new Lazy({
|
|
126483
126500
|
...lazied["~orpc"],
|
|
126484
126501
|
async loader() {
|
|
@@ -126493,40 +126510,40 @@ function getRouter(router, path68) {
|
|
|
126493
126510
|
}
|
|
126494
126511
|
return current;
|
|
126495
126512
|
}
|
|
126496
|
-
function walkProcedureContractsSync(router, callback,
|
|
126513
|
+
function walkProcedureContractsSync(router, callback, path71 = []) {
|
|
126497
126514
|
const lazyResults = [];
|
|
126498
|
-
walkProcedureContractsSyncInternal(router, callback,
|
|
126515
|
+
walkProcedureContractsSyncInternal(router, callback, path71.slice(), lazyResults);
|
|
126499
126516
|
return lazyResults;
|
|
126500
126517
|
}
|
|
126501
|
-
function walkProcedureContractsSyncInternal(router, callback,
|
|
126518
|
+
function walkProcedureContractsSyncInternal(router, callback, path71, lazyResults) {
|
|
126502
126519
|
const hiddenContract = getHiddenRouterContract(router);
|
|
126503
126520
|
if (hiddenContract !== void 0) {
|
|
126504
126521
|
router = hiddenContract;
|
|
126505
126522
|
}
|
|
126506
126523
|
if (router instanceof ProcedureContract) {
|
|
126507
|
-
callback(router,
|
|
126524
|
+
callback(router, path71.slice());
|
|
126508
126525
|
return;
|
|
126509
126526
|
}
|
|
126510
126527
|
if (!isTypescriptObject(router)) {
|
|
126511
126528
|
return;
|
|
126512
126529
|
}
|
|
126513
126530
|
for (const [key, value2] of Object.entries(router)) {
|
|
126514
|
-
|
|
126531
|
+
path71.push(key);
|
|
126515
126532
|
if (value2 instanceof Lazy) {
|
|
126516
|
-
lazyResults.push({ router: value2, path:
|
|
126533
|
+
lazyResults.push({ router: value2, path: path71.slice() });
|
|
126517
126534
|
} else {
|
|
126518
|
-
walkProcedureContractsSyncInternal(value2, callback,
|
|
126535
|
+
walkProcedureContractsSyncInternal(value2, callback, path71, lazyResults);
|
|
126519
126536
|
}
|
|
126520
|
-
|
|
126537
|
+
path71.pop();
|
|
126521
126538
|
}
|
|
126522
126539
|
}
|
|
126523
|
-
async function walkProcedureContractsAsync(router, callback,
|
|
126540
|
+
async function walkProcedureContractsAsync(router, callback, path71 = []) {
|
|
126524
126541
|
const hiddenContract = getHiddenRouterContract(router);
|
|
126525
126542
|
if (hiddenContract !== void 0) {
|
|
126526
126543
|
router = hiddenContract;
|
|
126527
126544
|
}
|
|
126528
126545
|
if (router instanceof ProcedureContract) {
|
|
126529
|
-
await callback(router,
|
|
126546
|
+
await callback(router, path71);
|
|
126530
126547
|
return;
|
|
126531
126548
|
}
|
|
126532
126549
|
if (!isTypescriptObject(router)) {
|
|
@@ -126535,9 +126552,9 @@ async function walkProcedureContractsAsync(router, callback, path68 = []) {
|
|
|
126535
126552
|
for (const [key, value2] of Object.entries(router)) {
|
|
126536
126553
|
if (value2 instanceof Lazy) {
|
|
126537
126554
|
const { default: router2 } = await unlazy(value2);
|
|
126538
|
-
await walkProcedureContractsAsync(router2, callback, [...
|
|
126555
|
+
await walkProcedureContractsAsync(router2, callback, [...path71, key]);
|
|
126539
126556
|
} else {
|
|
126540
|
-
await walkProcedureContractsAsync(value2, callback, [...
|
|
126557
|
+
await walkProcedureContractsAsync(value2, callback, [...path71, key]);
|
|
126541
126558
|
}
|
|
126542
126559
|
}
|
|
126543
126560
|
}
|
|
@@ -127023,18 +127040,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
|
|
|
127023
127040
|
}
|
|
127024
127041
|
var OpenAPIGeneratorError = class extends TypeError {
|
|
127025
127042
|
};
|
|
127026
|
-
function toOpenAPIPath(
|
|
127043
|
+
function toOpenAPIPath(path71, dynamicPathParams) {
|
|
127027
127044
|
if (!dynamicPathParams?.length) {
|
|
127028
|
-
return
|
|
127045
|
+
return path71;
|
|
127029
127046
|
}
|
|
127030
127047
|
let normalized = "";
|
|
127031
127048
|
let currentIndex = 0;
|
|
127032
127049
|
for (const param of dynamicPathParams) {
|
|
127033
|
-
normalized +=
|
|
127050
|
+
normalized += path71.slice(currentIndex, param.startIndex);
|
|
127034
127051
|
normalized += `{${param.parameterName}}`;
|
|
127035
127052
|
currentIndex = param.startIndex + param.segment.length;
|
|
127036
127053
|
}
|
|
127037
|
-
normalized +=
|
|
127054
|
+
normalized += path71.slice(currentIndex);
|
|
127038
127055
|
return normalized;
|
|
127039
127056
|
}
|
|
127040
127057
|
function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
|
|
@@ -127468,8 +127485,8 @@ var OpenAPIGenerator = class {
|
|
|
127468
127485
|
customErrorResponseBodySchema: options.customErrorResponseBodySchema
|
|
127469
127486
|
};
|
|
127470
127487
|
const errors = [];
|
|
127471
|
-
await walkProcedureContractsAsync(router, (contract,
|
|
127472
|
-
if (value(options.filter, contract,
|
|
127488
|
+
await walkProcedureContractsAsync(router, (contract, path71) => {
|
|
127489
|
+
if (value(options.filter, contract, path71) === false) {
|
|
127473
127490
|
return;
|
|
127474
127491
|
}
|
|
127475
127492
|
try {
|
|
@@ -127481,7 +127498,7 @@ var OpenAPIGenerator = class {
|
|
|
127481
127498
|
`QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
|
|
127482
127499
|
);
|
|
127483
127500
|
}
|
|
127484
|
-
const postPath = meta3?.path ?? pathToHttpPath(
|
|
127501
|
+
const postPath = meta3?.path ?? pathToHttpPath(path71);
|
|
127485
127502
|
const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
|
|
127486
127503
|
const dynamicPathParams = getDynamicPathParams(httpPath);
|
|
127487
127504
|
const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
|
|
@@ -127490,7 +127507,7 @@ var OpenAPIGenerator = class {
|
|
|
127490
127507
|
operation = meta3.spec;
|
|
127491
127508
|
} else {
|
|
127492
127509
|
operation = {
|
|
127493
|
-
operationId: meta3?.operationId ??
|
|
127510
|
+
operationId: meta3?.operationId ?? path71.join("."),
|
|
127494
127511
|
summary: meta3?.summary,
|
|
127495
127512
|
description: meta3?.description,
|
|
127496
127513
|
deprecated: meta3?.deprecated,
|
|
@@ -127510,7 +127527,7 @@ var OpenAPIGenerator = class {
|
|
|
127510
127527
|
if (!(e14 instanceof OpenAPIGeneratorError)) {
|
|
127511
127528
|
throw e14;
|
|
127512
127529
|
}
|
|
127513
|
-
errors.push(`Procedure at ${
|
|
127530
|
+
errors.push(`Procedure at ${path71.join(".") || "(root)"}: ${e14.message}`);
|
|
127514
127531
|
}
|
|
127515
127532
|
});
|
|
127516
127533
|
if (errors.length) {
|
|
@@ -128357,16 +128374,16 @@ var StandardLink = class {
|
|
|
128357
128374
|
/**
|
|
128358
128375
|
* @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
|
|
128359
128376
|
*/
|
|
128360
|
-
call(
|
|
128361
|
-
return runWithSpan(`${ORPC_NAME}.${
|
|
128377
|
+
call(path71, input2, options) {
|
|
128378
|
+
return runWithSpan(`${ORPC_NAME}.${path71.join("/")}`, (span) => {
|
|
128362
128379
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
128363
|
-
span?.setAttribute("rpc.method",
|
|
128380
|
+
span?.setAttribute("rpc.method", path71.join("."));
|
|
128364
128381
|
if (getTracer() && isAsyncIteratorObject(input2)) {
|
|
128365
128382
|
input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
|
|
128366
128383
|
} else if (getTracer() && input2 instanceof ReadableStream) {
|
|
128367
128384
|
input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
|
|
128368
128385
|
}
|
|
128369
|
-
return intercept(this.interceptors, { ...options, path:
|
|
128386
|
+
return intercept(this.interceptors, { ...options, path: path71, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
128370
128387
|
const tracer = getTracer();
|
|
128371
128388
|
const activeSpan = tracer?.getActiveSpan() ?? span;
|
|
128372
128389
|
let request7 = await runWithSpan(
|
|
@@ -128423,18 +128440,18 @@ var RPCLinkCodec = class {
|
|
|
128423
128440
|
this.headers = options.headers ?? {};
|
|
128424
128441
|
this.serializer = options.serializer ?? new RPCSerializer();
|
|
128425
128442
|
}
|
|
128426
|
-
async encodeInput(input2,
|
|
128427
|
-
let headers = toResolvedStandardHeaders(await value(this.headers, options,
|
|
128443
|
+
async encodeInput(input2, path71, options) {
|
|
128444
|
+
let headers = toResolvedStandardHeaders(await value(this.headers, options, path71, input2));
|
|
128428
128445
|
if (options.lastEventId !== void 0) {
|
|
128429
128446
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
128430
128447
|
}
|
|
128431
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
128432
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
128448
|
+
const expectedMethod = await value(this.expectedMethod, options, path71, input2);
|
|
128449
|
+
const baseUrl = await value(this.baseUrl, options, path71, input2);
|
|
128433
128450
|
const [pathname, search, hash2] = parseStandardUrl(baseUrl);
|
|
128434
|
-
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(
|
|
128451
|
+
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path71)}`;
|
|
128435
128452
|
const serialized = this.serializer.serialize(input2);
|
|
128436
128453
|
if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
128437
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
128454
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path71, input2);
|
|
128438
128455
|
const mergedSearch = new URLSearchParams(search);
|
|
128439
128456
|
mergedSearch.append("data", stringifyJSON(serialized) ?? "");
|
|
128440
128457
|
const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
|
|
@@ -128519,8 +128536,8 @@ var FetchLinkTransport = class {
|
|
|
128519
128536
|
this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
|
|
128520
128537
|
this.toFetchRequestOptions = options.toFetchRequest;
|
|
128521
128538
|
}
|
|
128522
|
-
async send(standardRequest,
|
|
128523
|
-
let origin = await value(this.origin, options,
|
|
128539
|
+
async send(standardRequest, path71, options) {
|
|
128540
|
+
let origin = await value(this.origin, options, path71);
|
|
128524
128541
|
if (origin?.endsWith("/")) {
|
|
128525
128542
|
origin = origin.slice(0, -1);
|
|
128526
128543
|
}
|
|
@@ -128540,7 +128557,7 @@ var FetchLinkTransport = class {
|
|
|
128540
128557
|
}
|
|
128541
128558
|
}
|
|
128542
128559
|
const fetch3 = this.fetch;
|
|
128543
|
-
const response = await fetch3(url2, init, options,
|
|
128560
|
+
const response = await fetch3(url2, init, options, path71);
|
|
128544
128561
|
const standardResponse = toStandardLazyResponse(response);
|
|
128545
128562
|
return standardResponse;
|
|
128546
128563
|
}
|
|
@@ -128931,14 +128948,14 @@ var StandardHandler = class {
|
|
|
128931
128948
|
span?.setAttribute("url.path", request22.url);
|
|
128932
128949
|
return { matched: false };
|
|
128933
128950
|
}
|
|
128934
|
-
const { path:
|
|
128935
|
-
span?.updateName(`${ORPC_NAME}.${
|
|
128951
|
+
const { path: path71, procedure, decodeInput } = matchedOrNot;
|
|
128952
|
+
span?.updateName(`${ORPC_NAME}.${path71.join("/")}`);
|
|
128936
128953
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
128937
|
-
span?.setAttribute("rpc.method",
|
|
128954
|
+
span?.setAttribute("rpc.method", path71.join("."));
|
|
128938
128955
|
try {
|
|
128939
128956
|
const response = await intercept(
|
|
128940
128957
|
this.interceptors,
|
|
128941
|
-
{ context: context2, prefix: prefix2, request: request22, path:
|
|
128958
|
+
{ context: context2, prefix: prefix2, request: request22, path: path71, procedure, decodeInput },
|
|
128942
128959
|
async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
|
|
128943
128960
|
step2 = "decode_input";
|
|
128944
128961
|
let input2 = await runWithSpan("decode_input", decodeInput2);
|
|
@@ -128972,7 +128989,7 @@ var StandardHandler = class {
|
|
|
128972
128989
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
128973
128990
|
cause: e14
|
|
128974
128991
|
}) : toORPCError(e14);
|
|
128975
|
-
const response = await this.codec.encodeError(error63, procedure,
|
|
128992
|
+
const response = await this.codec.encodeError(error63, procedure, path71, { context: context2, prefix: prefix2 });
|
|
128976
128993
|
return { matched: true, response };
|
|
128977
128994
|
}
|
|
128978
128995
|
}
|
|
@@ -129078,7 +129095,7 @@ var RPCMatcher = class {
|
|
|
129078
129095
|
this.rootRouter = router;
|
|
129079
129096
|
this.index(router);
|
|
129080
129097
|
}
|
|
129081
|
-
index(router,
|
|
129098
|
+
index(router, path71 = []) {
|
|
129082
129099
|
const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
|
|
129083
129100
|
if (!value(this.filter, procedure, procedurePath)) {
|
|
129084
129101
|
return;
|
|
@@ -129089,7 +129106,7 @@ var RPCMatcher = class {
|
|
|
129089
129106
|
// contract-first entries have no implementation yet, resolveProcedure fills it in on demand
|
|
129090
129107
|
procedure: procedure instanceof Procedure ? procedure : void 0
|
|
129091
129108
|
});
|
|
129092
|
-
},
|
|
129109
|
+
}, path71);
|
|
129093
129110
|
for (const result of lazyResults) {
|
|
129094
129111
|
this.pendingLazyRouters.set(pathToHttpPath(result.path), result);
|
|
129095
129112
|
}
|
|
@@ -129221,10 +129238,10 @@ var RPCHandlerCodec = class {
|
|
|
129221
129238
|
}
|
|
129222
129239
|
};
|
|
129223
129240
|
}
|
|
129224
|
-
encodeOutput(output2, procedure,
|
|
129241
|
+
encodeOutput(output2, procedure, path71, options) {
|
|
129225
129242
|
return {
|
|
129226
129243
|
headers: {},
|
|
129227
|
-
status: value(this.outputStatus, output2, procedure,
|
|
129244
|
+
status: value(this.outputStatus, output2, procedure, path71, options) ?? DEFAULT_SUCCESS_STATUS,
|
|
129228
129245
|
body: this.serializer.serialize(output2)
|
|
129229
129246
|
};
|
|
129230
129247
|
}
|
|
@@ -129278,39 +129295,39 @@ function createRouter() {
|
|
|
129278
129295
|
static: new NullProtoObj2()
|
|
129279
129296
|
};
|
|
129280
129297
|
}
|
|
129281
|
-
function scanFirstGroup(
|
|
129298
|
+
function scanFirstGroup(path71) {
|
|
129282
129299
|
let i10 = 0;
|
|
129283
129300
|
let depth = 0;
|
|
129284
|
-
for (; i10 <
|
|
129285
|
-
const c10 =
|
|
129301
|
+
for (; i10 < path71.length; i10++) {
|
|
129302
|
+
const c10 = path71.charCodeAt(i10);
|
|
129286
129303
|
if (c10 === 92) i10++;
|
|
129287
129304
|
else if (c10 === 40) depth++;
|
|
129288
129305
|
else if (c10 === 41 && depth > 0) depth--;
|
|
129289
129306
|
else if (c10 === 123 && depth === 0) break;
|
|
129290
129307
|
}
|
|
129291
|
-
if (i10 >=
|
|
129308
|
+
if (i10 >= path71.length) return;
|
|
129292
129309
|
let j10 = i10 + 1;
|
|
129293
129310
|
depth = 0;
|
|
129294
|
-
for (; j10 <
|
|
129295
|
-
const c10 =
|
|
129311
|
+
for (; j10 < path71.length; j10++) {
|
|
129312
|
+
const c10 = path71.charCodeAt(j10);
|
|
129296
129313
|
if (c10 === 92) j10++;
|
|
129297
129314
|
else if (c10 === 40) depth++;
|
|
129298
129315
|
else if (c10 === 41 && depth > 0) depth--;
|
|
129299
129316
|
else if (c10 === 125 && depth === 0) break;
|
|
129300
129317
|
}
|
|
129301
|
-
if (j10 >=
|
|
129302
|
-
const mod =
|
|
129318
|
+
if (j10 >= path71.length) return;
|
|
129319
|
+
const mod = path71[j10 + 1];
|
|
129303
129320
|
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
129304
129321
|
return [
|
|
129305
|
-
|
|
129306
|
-
|
|
129307
|
-
|
|
129322
|
+
path71.slice(0, i10),
|
|
129323
|
+
path71.slice(i10 + 1, j10),
|
|
129324
|
+
path71.slice(j10 + (hasMod ? 2 : 1)),
|
|
129308
129325
|
hasMod ? mod : void 0
|
|
129309
129326
|
];
|
|
129310
129327
|
}
|
|
129311
|
-
function expandGroupDelimiters(
|
|
129312
|
-
if (!
|
|
129313
|
-
const group = scanFirstGroup(
|
|
129328
|
+
function expandGroupDelimiters(path71) {
|
|
129329
|
+
if (!path71.includes("{")) return;
|
|
129330
|
+
const group = scanFirstGroup(path71);
|
|
129314
129331
|
if (!group) return;
|
|
129315
129332
|
const [pre2, body, suf, mod] = group;
|
|
129316
129333
|
if (!mod) return [pre2 + body + suf];
|
|
@@ -129380,9 +129397,9 @@ function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGr
|
|
|
129380
129397
|
}
|
|
129381
129398
|
return [replaced, nextIndex];
|
|
129382
129399
|
}
|
|
129383
|
-
function encodeEscapes(
|
|
129384
|
-
if (!
|
|
129385
|
-
return
|
|
129400
|
+
function encodeEscapes(path71) {
|
|
129401
|
+
if (!path71.includes("\\")) return path71;
|
|
129402
|
+
return path71.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
|
|
129386
129403
|
}
|
|
129387
129404
|
function segmentKey(segment) {
|
|
129388
129405
|
if (segment.startsWith("**")) return 2;
|
|
@@ -129411,22 +129428,22 @@ function expandModifiers(segments) {
|
|
|
129411
129428
|
return m10[2] === "+" ? [wc2] : [wc2, without];
|
|
129412
129429
|
}
|
|
129413
129430
|
}
|
|
129414
|
-
function normalizePath(
|
|
129415
|
-
if (!
|
|
129431
|
+
function normalizePath(path71) {
|
|
129432
|
+
if (!path71.includes("/.")) return path71;
|
|
129416
129433
|
const r10 = [];
|
|
129417
|
-
for (const s of
|
|
129434
|
+
for (const s of path71.split("/")) if (s === ".") continue;
|
|
129418
129435
|
else if (s === ".." && r10.length > 1) r10.pop();
|
|
129419
129436
|
else r10.push(s);
|
|
129420
129437
|
return r10.join("/") || "/";
|
|
129421
129438
|
}
|
|
129422
|
-
function splitPath(
|
|
129423
|
-
const s =
|
|
129439
|
+
function splitPath(path71) {
|
|
129440
|
+
const s = path71.split("/");
|
|
129424
129441
|
s.shift();
|
|
129425
129442
|
if (s[s.length - 1] === "") s.pop();
|
|
129426
129443
|
return s;
|
|
129427
129444
|
}
|
|
129428
|
-
function splitRoute(
|
|
129429
|
-
const s = splitPath(
|
|
129445
|
+
function splitRoute(path71) {
|
|
129446
|
+
const s = splitPath(path71);
|
|
129430
129447
|
while (s[s.length - 1] === "") s.pop();
|
|
129431
129448
|
return s;
|
|
129432
129449
|
}
|
|
@@ -129442,16 +129459,16 @@ function getMatchParams(segments, paramsMap) {
|
|
|
129442
129459
|
}
|
|
129443
129460
|
return params;
|
|
129444
129461
|
}
|
|
129445
|
-
function addRoute(ctx, method = "",
|
|
129462
|
+
function addRoute(ctx, method = "", path71, data) {
|
|
129446
129463
|
method = method.toUpperCase();
|
|
129447
|
-
if (
|
|
129448
|
-
const groupExpanded = expandGroupDelimiters(
|
|
129464
|
+
if (path71.charCodeAt(0) !== 47) path71 = `/${path71}`;
|
|
129465
|
+
const groupExpanded = expandGroupDelimiters(path71);
|
|
129449
129466
|
if (groupExpanded) {
|
|
129450
129467
|
for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
|
|
129451
129468
|
return;
|
|
129452
129469
|
}
|
|
129453
|
-
|
|
129454
|
-
const segments = splitRoute(
|
|
129470
|
+
path71 = encodeEscapes(path71);
|
|
129471
|
+
const segments = splitRoute(path71);
|
|
129455
129472
|
const expanded = expandModifiers(segments);
|
|
129456
129473
|
if (expanded) {
|
|
129457
129474
|
for (const p of expanded) addRoute(ctx, method, p, data);
|
|
@@ -129542,15 +129559,15 @@ function getParamRegexp(segment, unnamedStart = 0) {
|
|
|
129542
129559
|
const regex2 = _s2.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id2, p) => `(?<${toGroupName(id2)}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i2++)}>`).replace(/\uFFFE(.)/g, (_, c10) => /[.*+?^${}()|[\]\\]/.test(c10) ? `\\${c10}` : c10);
|
|
129543
129560
|
return [new RegExp(`^${regex2}$`), _i2];
|
|
129544
129561
|
}
|
|
129545
|
-
function findRoute(ctx, method = "",
|
|
129546
|
-
if (opts?.normalize)
|
|
129547
|
-
if (
|
|
129548
|
-
const staticNode = ctx.static[
|
|
129562
|
+
function findRoute(ctx, method = "", path71, opts) {
|
|
129563
|
+
if (opts?.normalize) path71 = normalizePath(path71);
|
|
129564
|
+
if (path71.charCodeAt(path71.length - 1) === 47) path71 = path71.slice(0, -1);
|
|
129565
|
+
const staticNode = ctx.static[path71];
|
|
129549
129566
|
if (staticNode && staticNode.methods) {
|
|
129550
129567
|
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
129551
129568
|
if (staticMatch !== void 0) return staticMatch[0];
|
|
129552
129569
|
}
|
|
129553
|
-
const segments = splitPath(
|
|
129570
|
+
const segments = splitPath(path71);
|
|
129554
129571
|
const match = _lookupTree(ctx.root, method, segments, 0);
|
|
129555
129572
|
if (match === void 0) return;
|
|
129556
129573
|
if (opts?.params === false) return match;
|
|
@@ -129750,7 +129767,7 @@ var OpenAPIMatcher = class {
|
|
|
129750
129767
|
this.rootRouter = router;
|
|
129751
129768
|
this.index(router);
|
|
129752
129769
|
}
|
|
129753
|
-
index(router,
|
|
129770
|
+
index(router, path71 = []) {
|
|
129754
129771
|
const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
|
|
129755
129772
|
if (!value(this.filter, contract, path210)) {
|
|
129756
129773
|
return;
|
|
@@ -129765,7 +129782,7 @@ var OpenAPIMatcher = class {
|
|
|
129765
129782
|
contract,
|
|
129766
129783
|
procedure: contract instanceof Procedure ? contract : void 0
|
|
129767
129784
|
});
|
|
129768
|
-
},
|
|
129785
|
+
}, path71);
|
|
129769
129786
|
for (const result of lazyResults) {
|
|
129770
129787
|
const prefix = getOpenAPIMeta(result.router)?.prefix;
|
|
129771
129788
|
this.pendingLazyRouters.add({
|
|
@@ -129852,20 +129869,20 @@ var OpenAPIMatcher = class {
|
|
|
129852
129869
|
return entry.procedure;
|
|
129853
129870
|
}
|
|
129854
129871
|
};
|
|
129855
|
-
function toRou3Pattern(
|
|
129856
|
-
const params = getDynamicPathParams(
|
|
129872
|
+
function toRou3Pattern(path71) {
|
|
129873
|
+
const params = getDynamicPathParams(path71);
|
|
129857
129874
|
if (!params?.length) {
|
|
129858
|
-
return
|
|
129875
|
+
return path71;
|
|
129859
129876
|
}
|
|
129860
129877
|
for (let i10 = params.length - 1; i10 >= 0; i10--) {
|
|
129861
129878
|
const param = params[i10];
|
|
129862
129879
|
const pattern = param.allowsSlash ? `**:${param.parameterName}` : `:${param.parameterName}`;
|
|
129863
|
-
|
|
129880
|
+
path71 = path71.slice(0, param.startIndex) + pattern + path71.slice(param.startIndex + param.segment.length);
|
|
129864
129881
|
}
|
|
129865
|
-
return
|
|
129882
|
+
return path71;
|
|
129866
129883
|
}
|
|
129867
|
-
function toRou3PrefixMatcher(
|
|
129868
|
-
const pattern = toRou3Pattern(
|
|
129884
|
+
function toRou3PrefixMatcher(path71) {
|
|
129885
|
+
const pattern = toRou3Pattern(path71);
|
|
129869
129886
|
return routeToRegExp(pattern === "/" ? "/**" : `${pattern}/**`);
|
|
129870
129887
|
}
|
|
129871
129888
|
function decodeParams(params) {
|
|
@@ -129944,7 +129961,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
129944
129961
|
/**
|
|
129945
129962
|
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
129946
129963
|
*/
|
|
129947
|
-
encodeOutput(output2, procedure,
|
|
129964
|
+
encodeOutput(output2, procedure, path71) {
|
|
129948
129965
|
const meta3 = getOpenAPIMeta(procedure);
|
|
129949
129966
|
const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
|
|
129950
129967
|
const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
|
|
@@ -129957,7 +129974,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
129957
129974
|
}
|
|
129958
129975
|
if (!isValidDetailedOutput(output2)) {
|
|
129959
129976
|
throw new TypeError(`
|
|
129960
|
-
Invalid "detailed" output structure returned by procedure (${
|
|
129977
|
+
Invalid "detailed" output structure returned by procedure (${path71.join(".")}):
|
|
129961
129978
|
\u2022 Expected an object with optional properties:
|
|
129962
129979
|
- status (number <400)
|
|
129963
129980
|
- headers (object)
|
|
@@ -130525,7 +130542,7 @@ function profileValue(name, paths) {
|
|
|
130525
130542
|
function createConfigApiRouter(deps) {
|
|
130526
130543
|
const authed = doorApiAuth(deps.expectedToken);
|
|
130527
130544
|
const { paths } = deps;
|
|
130528
|
-
const route = (
|
|
130545
|
+
const route = (path71, summary) => authed.meta(openapi({ method: "POST", path: path71, summary, tags: [CONFIG_API_TAG] }));
|
|
130529
130546
|
return {
|
|
130530
130547
|
config: {
|
|
130531
130548
|
identity: {
|
|
@@ -131330,6 +131347,9 @@ function createLaunchEventPublisher(hub, now) {
|
|
|
131330
131347
|
};
|
|
131331
131348
|
}
|
|
131332
131349
|
|
|
131350
|
+
// src/frontdoor/pipeline.ts
|
|
131351
|
+
init_schema2();
|
|
131352
|
+
|
|
131333
131353
|
// src/frontdoor/headroomHop.ts
|
|
131334
131354
|
var http4 = __toESM(require("node:http"), 1);
|
|
131335
131355
|
var import_consumers = require("node:stream/consumers");
|
|
@@ -131530,11 +131550,11 @@ function lineageOf(body) {
|
|
|
131530
131550
|
if (body.length > LINEAGE_BODY_BYTES_LIMIT) {
|
|
131531
131551
|
return void 0;
|
|
131532
131552
|
}
|
|
131533
|
-
const
|
|
131534
|
-
if (
|
|
131553
|
+
const counted2 = walk2(body, false, void 0);
|
|
131554
|
+
if (counted2.abandoned || !counted2.sawMessages) {
|
|
131535
131555
|
return void 0;
|
|
131536
131556
|
}
|
|
131537
|
-
const parentAfter =
|
|
131557
|
+
const parentAfter = counted2.elements > MESSAGES_PER_TURN ? counted2.elements - MESSAGES_PER_TURN : void 0;
|
|
131538
131558
|
const hashed = walk2(body, true, parentAfter);
|
|
131539
131559
|
const combine = (messagesDigest) => (0, import_node_crypto22.createHash)("sha256").update(hashed.threadDigest).update(messagesDigest).digest("hex");
|
|
131540
131560
|
return { ownKey: combine(hashed.messagesDigest), parentKey: hashed.parentDigest === void 0 ? void 0 : combine(hashed.parentDigest) };
|
|
@@ -131780,6 +131800,10 @@ function errorTypeFor(status) {
|
|
|
131780
131800
|
function errorBody(status, message) {
|
|
131781
131801
|
return JSON.stringify({ type: "error", error: { type: errorTypeFor(status), message } });
|
|
131782
131802
|
}
|
|
131803
|
+
function clientSessionIdOf(headers) {
|
|
131804
|
+
const value2 = headers[CLIENT_SESSION_HEADER];
|
|
131805
|
+
return typeof value2 === "string" && CLIENT_SESSION_ID_PATTERN.test(value2) ? value2 : void 0;
|
|
131806
|
+
}
|
|
131783
131807
|
function pathOf(url2) {
|
|
131784
131808
|
const query = url2.indexOf("?");
|
|
131785
131809
|
return query === -1 ? url2 : url2.slice(0, query);
|
|
@@ -131834,7 +131858,7 @@ function createRoutedResponse(response, context) {
|
|
|
131834
131858
|
start: (status, headers) => {
|
|
131835
131859
|
for (const observe of deps.responseObservers) {
|
|
131836
131860
|
try {
|
|
131837
|
-
const body = observe({ session, route, method: request7.method, path: request7.path, servedPath: context.servedPath, receivedAt: request7.receivedAt, viaHeadroom: request7.viaHeadroom, lineage: request7.thread.lineage, modelChoice: request7.modelChoice.value, requestedModel: request7.requestedModel.value, status, headers });
|
|
131861
|
+
const body = observe({ session, route, method: request7.method, path: request7.path, servedPath: context.servedPath, receivedAt: request7.receivedAt, viaHeadroom: request7.viaHeadroom, lineage: request7.thread.lineage, modelChoice: request7.modelChoice.value, requestedModel: request7.requestedModel.value, clientSessionId: request7.clientSessionId, status, headers });
|
|
131838
131862
|
if (body !== void 0) {
|
|
131839
131863
|
bodyObservers.push(body);
|
|
131840
131864
|
}
|
|
@@ -131879,7 +131903,7 @@ function createRoutedResponse(response, context) {
|
|
|
131879
131903
|
}
|
|
131880
131904
|
async function serveRouted(incoming, deps) {
|
|
131881
131905
|
const request7 = { ...incoming, url: withCanonicalProviderTarget(incoming.url, deps.canonicalProvider) };
|
|
131882
|
-
const observed = { method: request7.method, path: pathOf(request7.url), receivedAt: deps.now(), viaHeadroom: false, thread: { lineage: void 0 }, modelChoice: { value: void 0 }, requestedModel: { value: void 0 } };
|
|
131906
|
+
const observed = { method: request7.method, path: pathOf(request7.url), receivedAt: deps.now(), viaHeadroom: false, thread: { lineage: void 0 }, modelChoice: { value: void 0 }, requestedModel: { value: void 0 }, clientSessionId: clientSessionIdOf(incoming.headers) };
|
|
131883
131907
|
const identity = identifyRequest(request7.headers);
|
|
131884
131908
|
const identified = { ...identity, session: { ...identity.session, provider: identity.session.provider === void 0 ? void 0 : deps.canonicalProvider(identity.session.provider) } };
|
|
131885
131909
|
const admission = deps.admit({ url: request7.url, headers: request7.headers, forwardable: identified.forwardableHeaders });
|
|
@@ -132545,8 +132569,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
132545
132569
|
request7.body.resume();
|
|
132546
132570
|
return;
|
|
132547
132571
|
}
|
|
132548
|
-
const
|
|
132549
|
-
const translated = { method: request7.method, path:
|
|
132572
|
+
const path71 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
132573
|
+
const translated = { method: request7.method, path: path71, body, signal: request7.signal };
|
|
132550
132574
|
const routed = await route(translated);
|
|
132551
132575
|
if (request7.signal.aborted) {
|
|
132552
132576
|
return;
|
|
@@ -133167,8 +133191,8 @@ function createAntigravityRouteMount(ports, upstreamBase, provider) {
|
|
|
133167
133191
|
request7.body.resume();
|
|
133168
133192
|
return;
|
|
133169
133193
|
}
|
|
133170
|
-
const
|
|
133171
|
-
const translated = { method: request7.method, path:
|
|
133194
|
+
const path71 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133195
|
+
const translated = { method: request7.method, path: path71, body, signal: request7.signal };
|
|
133172
133196
|
const routed = await route(translated);
|
|
133173
133197
|
if (request7.signal.aborted) {
|
|
133174
133198
|
return;
|
|
@@ -133209,7 +133233,7 @@ function createPassthroughRoute(name, target) {
|
|
|
133209
133233
|
headroomUpstream: target.headroomUpstream,
|
|
133210
133234
|
serve: async (request7, response) => {
|
|
133211
133235
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
133212
|
-
const
|
|
133236
|
+
const path71 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
133213
133237
|
const headers = forwardableHeaders(request7.headers);
|
|
133214
133238
|
delete headers.host;
|
|
133215
133239
|
await new Promise((resolve2) => {
|
|
@@ -133217,7 +133241,7 @@ function createPassthroughRoute(name, target) {
|
|
|
133217
133241
|
host: base.hostname,
|
|
133218
133242
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
133219
133243
|
method: request7.method,
|
|
133220
|
-
path: `${basePath}${
|
|
133244
|
+
path: `${basePath}${path71}${incoming.search}`,
|
|
133221
133245
|
headers,
|
|
133222
133246
|
agent
|
|
133223
133247
|
};
|
|
@@ -133389,13 +133413,13 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
133389
133413
|
}
|
|
133390
133414
|
|
|
133391
133415
|
// src/frontdoor/providerRoute.ts
|
|
133392
|
-
var isRcSelfHostPath = (
|
|
133416
|
+
var isRcSelfHostPath = (path71) => path71 === "/v1/code/sessions" || path71.startsWith("/v1/code/sessions/") || path71 === "/v1/sessions" || path71.startsWith("/v1/sessions/");
|
|
133393
133417
|
function scopeSessionProviderPath(request7) {
|
|
133394
133418
|
if (request7.session.provider === void 0) {
|
|
133395
133419
|
return request7;
|
|
133396
133420
|
}
|
|
133397
|
-
const
|
|
133398
|
-
if (!
|
|
133421
|
+
const path71 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133422
|
+
if (!path71.startsWith("/v1/") || isRcSelfHostPath(path71)) {
|
|
133399
133423
|
return request7;
|
|
133400
133424
|
}
|
|
133401
133425
|
return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
|
|
@@ -133519,13 +133543,13 @@ function createProviderRouteResolver(deps) {
|
|
|
133519
133543
|
return route;
|
|
133520
133544
|
};
|
|
133521
133545
|
const resolve2 = (request7) => {
|
|
133522
|
-
const
|
|
133523
|
-
const scoped = parseProviderPath(
|
|
133546
|
+
const path71 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133547
|
+
const scoped = parseProviderPath(path71);
|
|
133524
133548
|
if (scoped === void 0) {
|
|
133525
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
133549
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path71)) {
|
|
133526
133550
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
133527
133551
|
}
|
|
133528
|
-
return
|
|
133552
|
+
return path71.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path71}` };
|
|
133529
133553
|
}
|
|
133530
133554
|
const { provider } = scoped;
|
|
133531
133555
|
let definition;
|
|
@@ -133617,8 +133641,8 @@ function createProviderRouteResolver(deps) {
|
|
|
133617
133641
|
let modelChoice;
|
|
133618
133642
|
const visited = /* @__PURE__ */ new Set();
|
|
133619
133643
|
for (; ; ) {
|
|
133620
|
-
const
|
|
133621
|
-
const scoped = parseProviderPath(
|
|
133644
|
+
const path71 = new URL(current.url, "http://127.0.0.1").pathname;
|
|
133645
|
+
const scoped = parseProviderPath(path71);
|
|
133622
133646
|
const providerName = scoped?.provider ?? current.session.provider;
|
|
133623
133647
|
if (providerName !== void 0 && visited.has(providerName)) {
|
|
133624
133648
|
return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
|
|
@@ -133633,7 +133657,7 @@ function createProviderRouteResolver(deps) {
|
|
|
133633
133657
|
} catch {
|
|
133634
133658
|
routes = void 0;
|
|
133635
133659
|
}
|
|
133636
|
-
const resolvesNames = !nameResolved && !isRcSelfHostPath(
|
|
133660
|
+
const resolvesNames = !nameResolved && !isRcSelfHostPath(path71);
|
|
133637
133661
|
if (resolvesNames) {
|
|
133638
133662
|
const scan2 = await scanRequestHead(current, true);
|
|
133639
133663
|
if (scan2.replayed === void 0) {
|
|
@@ -133672,7 +133696,7 @@ function createProviderRouteResolver(deps) {
|
|
|
133672
133696
|
}
|
|
133673
133697
|
if (routed.provider !== providerName) {
|
|
133674
133698
|
const scopedPrefix = providerName === void 0 ? void 0 : `${PROVIDER_PATH_PREFIX}${encodeURIComponent(providerName)}`;
|
|
133675
|
-
const rest2 = scopedPrefix !== void 0 &&
|
|
133699
|
+
const rest2 = scopedPrefix !== void 0 && path71.startsWith(scopedPrefix) ? path71.slice(scopedPrefix.length) : path71;
|
|
133676
133700
|
const query2 = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
133677
133701
|
const carried = replay;
|
|
133678
133702
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(routed.provider)}${rest2}${query2}`, body: carried.body, headers: carried.headers };
|
|
@@ -133726,7 +133750,7 @@ function createProviderRouteResolver(deps) {
|
|
|
133726
133750
|
const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
133727
133751
|
replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
|
|
133728
133752
|
}
|
|
133729
|
-
const rest = scoped === void 0 ?
|
|
133753
|
+
const rest = scoped === void 0 ? path71 : path71.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
|
|
133730
133754
|
const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
133731
133755
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
|
|
133732
133756
|
}
|
|
@@ -137361,7 +137385,7 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
137361
137385
|
// src/statusline/commands.ts
|
|
137362
137386
|
var import_node_child_process8 = require("node:child_process");
|
|
137363
137387
|
var import_node_os13 = __toESM(require("node:os"), 1);
|
|
137364
|
-
var
|
|
137388
|
+
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
137365
137389
|
init_commandDeps();
|
|
137366
137390
|
init_statusline();
|
|
137367
137391
|
init_providersStore();
|
|
@@ -137603,7 +137627,8 @@ function enrichStatuslinePayload(params) {
|
|
|
137603
137627
|
quotaFamilies: [],
|
|
137604
137628
|
headroom: params.headroom,
|
|
137605
137629
|
routedTarget: params.routedTarget,
|
|
137606
|
-
...params.modelChoice === void 0 ? {} : { modelChoice: params.modelChoice }
|
|
137630
|
+
...params.modelChoice === void 0 ? {} : { modelChoice: params.modelChoice },
|
|
137631
|
+
...params.doorCostUsd === void 0 ? {} : { doorCostUsd: params.doorCostUsd }
|
|
137607
137632
|
};
|
|
137608
137633
|
if (params.snapshot !== void 0) {
|
|
137609
137634
|
const scopedName = providerScopedState(params.snapshot, params.providerName, params.env.AGENT_SHIM_PROVIDER);
|
|
@@ -137679,6 +137704,77 @@ function providerScopedState(snapshot, providerName, providerDisplayName) {
|
|
|
137679
137704
|
|
|
137680
137705
|
// src/statusline/commands.ts
|
|
137681
137706
|
init_read();
|
|
137707
|
+
init_modelsStore();
|
|
137708
|
+
|
|
137709
|
+
// src/statusline/doorCost.ts
|
|
137710
|
+
init_read();
|
|
137711
|
+
|
|
137712
|
+
// src/statusline/cost.ts
|
|
137713
|
+
var TOKENS_PER_MILLION = 1e6;
|
|
137714
|
+
var CACHE_WRITE_PRICE_RATIO = 1.25;
|
|
137715
|
+
var CACHE_READ_PRICE_RATIO = 0.1;
|
|
137716
|
+
function doorCostUsdOf(records, prices) {
|
|
137717
|
+
let totalUsd = 0;
|
|
137718
|
+
let costed = 0;
|
|
137719
|
+
for (const record2 of records) {
|
|
137720
|
+
const { usage } = record2;
|
|
137721
|
+
if (usage === void 0) {
|
|
137722
|
+
continue;
|
|
137723
|
+
}
|
|
137724
|
+
const price = record2.model === void 0 ? void 0 : prices[`${record2.provider}/${record2.model}`];
|
|
137725
|
+
if (price === void 0) {
|
|
137726
|
+
return void 0;
|
|
137727
|
+
}
|
|
137728
|
+
const inputUsd = ((usage.inputTokens ?? 0) + (usage.cacheCreationInputTokens ?? 0) * CACHE_WRITE_PRICE_RATIO + (usage.cacheReadInputTokens ?? 0) * CACHE_READ_PRICE_RATIO) * price.input;
|
|
137729
|
+
totalUsd += (inputUsd + (usage.outputTokens ?? 0) * price.output) / TOKENS_PER_MILLION;
|
|
137730
|
+
costed += 1;
|
|
137731
|
+
}
|
|
137732
|
+
return costed === 0 ? void 0 : totalUsd;
|
|
137733
|
+
}
|
|
137734
|
+
function isCloudModelId(modelId) {
|
|
137735
|
+
return modelId !== void 0 && (modelId.toLowerCase().includes("anthropic.claude-") || modelId.includes("@"));
|
|
137736
|
+
}
|
|
137737
|
+
function isRoutedSession(summary, payload) {
|
|
137738
|
+
return summary.provider !== void 0 || isCloudModelId(payload.model?.id);
|
|
137739
|
+
}
|
|
137740
|
+
function resolveSessionCost({ summary, payload, settings: settings2 }) {
|
|
137741
|
+
const native = payload.cost?.total_cost_usd;
|
|
137742
|
+
const door = summary.doorCostUsd;
|
|
137743
|
+
if (!isRoutedSession(summary, payload)) {
|
|
137744
|
+
if (native !== void 0) {
|
|
137745
|
+
return { usd: native, source: "native" };
|
|
137746
|
+
}
|
|
137747
|
+
return door === void 0 ? void 0 : { usd: door, source: "estimate" };
|
|
137748
|
+
}
|
|
137749
|
+
if (!settings2.cost.routed) {
|
|
137750
|
+
return void 0;
|
|
137751
|
+
}
|
|
137752
|
+
if (door !== void 0) {
|
|
137753
|
+
return { usd: door, source: "estimate" };
|
|
137754
|
+
}
|
|
137755
|
+
return native !== void 0 && native > 0 ? { usd: native, source: "native" } : void 0;
|
|
137756
|
+
}
|
|
137757
|
+
var CENTS_FROM_USD = 1;
|
|
137758
|
+
var MILLS_FROM_USD = 0.1;
|
|
137759
|
+
var MILL_PLACES = 3;
|
|
137760
|
+
var FINE_PLACES = 4;
|
|
137761
|
+
function formatUsd(usd2) {
|
|
137762
|
+
if (usd2 >= CENTS_FROM_USD) {
|
|
137763
|
+
return `$${usd2.toFixed(2)}`;
|
|
137764
|
+
}
|
|
137765
|
+
return usd2 >= MILLS_FROM_USD ? `$${usd2.toFixed(MILL_PLACES)}` : `$${usd2.toFixed(FINE_PLACES)}`;
|
|
137766
|
+
}
|
|
137767
|
+
|
|
137768
|
+
// src/statusline/doorCost.ts
|
|
137769
|
+
function readDoorCostUsd(params) {
|
|
137770
|
+
const { nowMs, sessionDurationMs } = params;
|
|
137771
|
+
const sinceMs = sessionDurationMs === void 0 ? void 0 : Date.parse(`${segmentDay(nowMs - sessionDurationMs)}T00:00:00.000Z`);
|
|
137772
|
+
const { records } = readUsageLog(params.fs, params.logDir, sinceMs === void 0 ? {} : { sinceMs });
|
|
137773
|
+
return doorCostUsdOf(
|
|
137774
|
+
records.filter((record2) => record2.clientSessionId === params.conversationId),
|
|
137775
|
+
params.prices
|
|
137776
|
+
);
|
|
137777
|
+
}
|
|
137682
137778
|
|
|
137683
137779
|
// src/statusline/payload.ts
|
|
137684
137780
|
init_zod();
|
|
@@ -137734,21 +137830,90 @@ function viewOf(payload) {
|
|
|
137734
137830
|
var import_node_child_process7 = require("node:child_process");
|
|
137735
137831
|
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
137736
137832
|
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
137833
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
137834
|
+
|
|
137835
|
+
// src/statusline/memoryUse.ts
|
|
137836
|
+
var BYTES_PER_KIBIBYTE = 1024;
|
|
137837
|
+
var SMALLER_UNITS = ["B", "KB", "MB", "GB"];
|
|
137838
|
+
var LARGEST_UNIT = "TB";
|
|
137839
|
+
function formatBytes(bytes) {
|
|
137840
|
+
const firstWholeDigits = 10;
|
|
137841
|
+
let value2 = Math.max(0, bytes);
|
|
137842
|
+
for (const unit of SMALLER_UNITS) {
|
|
137843
|
+
if (value2 < BYTES_PER_KIBIBYTE) {
|
|
137844
|
+
return `${value2.toFixed(value2 >= firstWholeDigits || unit === "B" ? 0 : 1)} ${unit}`;
|
|
137845
|
+
}
|
|
137846
|
+
value2 /= BYTES_PER_KIBIBYTE;
|
|
137847
|
+
}
|
|
137848
|
+
return `${value2.toFixed(value2 >= firstWholeDigits ? 0 : 1)} ${LARGEST_UNIT}`;
|
|
137849
|
+
}
|
|
137850
|
+
function usedBytesFromVmStat(output2) {
|
|
137851
|
+
const pageSize = /page size of (\d+) bytes/.exec(output2)?.[1];
|
|
137852
|
+
const active = /Pages active:\s+(\d+)/.exec(output2)?.[1];
|
|
137853
|
+
const wired = /Pages wired down:\s+(\d+)/.exec(output2)?.[1];
|
|
137854
|
+
const compressed = /Pages occupied by compressor:\s+(\d+)/.exec(output2)?.[1];
|
|
137855
|
+
if (pageSize === void 0 || active === void 0 || wired === void 0 || compressed === void 0) {
|
|
137856
|
+
return void 0;
|
|
137857
|
+
}
|
|
137858
|
+
return (Number(active) + Number(wired) + Number(compressed)) * Number(pageSize);
|
|
137859
|
+
}
|
|
137860
|
+
function memoryUseFromMeminfo(text4) {
|
|
137861
|
+
const totalKibibytes = /^MemTotal:\s+(\d+)\s+kB/m.exec(text4)?.[1];
|
|
137862
|
+
const availableKibibytes = /^MemAvailable:\s+(\d+)\s+kB/m.exec(text4)?.[1];
|
|
137863
|
+
if (totalKibibytes === void 0 || availableKibibytes === void 0) {
|
|
137864
|
+
return void 0;
|
|
137865
|
+
}
|
|
137866
|
+
const totalBytes = Number(totalKibibytes) * BYTES_PER_KIBIBYTE;
|
|
137867
|
+
return { totalBytes, usedBytes: totalBytes - Number(availableKibibytes) * BYTES_PER_KIBIBYTE };
|
|
137868
|
+
}
|
|
137869
|
+
|
|
137870
|
+
// src/statusline/ports.ts
|
|
137737
137871
|
var RUN_TIMEOUT_MS = 2e3;
|
|
137738
137872
|
var RUN_MAX_BUFFER_BYTES = 1048576;
|
|
137739
|
-
function
|
|
137873
|
+
function runProgram(file2, args, cwd) {
|
|
137874
|
+
try {
|
|
137875
|
+
return (0, import_node_child_process7.execFileSync)(file2, [...args], { cwd, encoding: "utf8", timeout: RUN_TIMEOUT_MS, maxBuffer: RUN_MAX_BUFFER_BYTES, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
137876
|
+
} catch {
|
|
137877
|
+
return void 0;
|
|
137878
|
+
}
|
|
137879
|
+
}
|
|
137880
|
+
function readText(file2) {
|
|
137881
|
+
try {
|
|
137882
|
+
return import_node_fs22.default.readFileSync(file2, "utf8");
|
|
137883
|
+
} catch {
|
|
137884
|
+
return void 0;
|
|
137885
|
+
}
|
|
137886
|
+
}
|
|
137887
|
+
var STATE_FILE_MODE = 384;
|
|
137888
|
+
var STATE_DIRECTORY_MODE = 448;
|
|
137889
|
+
function discard(target) {
|
|
137890
|
+
try {
|
|
137891
|
+
import_node_fs22.default.rmSync(target, { force: true, recursive: true });
|
|
137892
|
+
} catch {
|
|
137893
|
+
return;
|
|
137894
|
+
}
|
|
137895
|
+
}
|
|
137896
|
+
function readMemoryUse() {
|
|
137897
|
+
const totalBytes = import_node_os12.default.totalmem();
|
|
137898
|
+
if (process.platform === "darwin") {
|
|
137899
|
+
const output2 = runProgram("/usr/bin/vm_stat", [], process.cwd());
|
|
137900
|
+
const usedBytes = output2 === void 0 ? void 0 : usedBytesFromVmStat(output2);
|
|
137901
|
+
return usedBytes === void 0 ? void 0 : { usedBytes, totalBytes };
|
|
137902
|
+
}
|
|
137903
|
+
if (process.platform === "linux") {
|
|
137904
|
+
const meminfo = readText("/proc/meminfo");
|
|
137905
|
+
return meminfo === void 0 ? void 0 : memoryUseFromMeminfo(meminfo);
|
|
137906
|
+
}
|
|
137907
|
+
return { usedBytes: totalBytes - import_node_os12.default.freemem(), totalBytes };
|
|
137908
|
+
}
|
|
137909
|
+
function realStatuslinePorts(env, stateDirectory) {
|
|
137740
137910
|
const { locale, timeZone } = Intl.DateTimeFormat().resolvedOptions();
|
|
137741
137911
|
return {
|
|
137742
137912
|
env,
|
|
137743
137913
|
homeDirectory: import_node_os12.default.homedir(),
|
|
137914
|
+
stateDirectory,
|
|
137744
137915
|
clock: { locale, timeZone },
|
|
137745
|
-
readText
|
|
137746
|
-
try {
|
|
137747
|
-
return import_node_fs22.default.readFileSync(path68, "utf8");
|
|
137748
|
-
} catch {
|
|
137749
|
-
return void 0;
|
|
137750
|
-
}
|
|
137751
|
-
},
|
|
137916
|
+
readText,
|
|
137752
137917
|
readRange: (file2, start, length) => {
|
|
137753
137918
|
try {
|
|
137754
137919
|
const descriptor = import_node_fs22.default.openSync(file2, "r");
|
|
@@ -137764,34 +137929,47 @@ function realStatuslinePorts(env) {
|
|
|
137764
137929
|
return void 0;
|
|
137765
137930
|
}
|
|
137766
137931
|
},
|
|
137767
|
-
run:
|
|
137932
|
+
run: runProgram,
|
|
137933
|
+
entryKind: (target) => {
|
|
137768
137934
|
try {
|
|
137769
|
-
return (
|
|
137935
|
+
return import_node_fs22.default.lstatSync(target).isDirectory() ? "directory" : "other";
|
|
137770
137936
|
} catch {
|
|
137771
137937
|
return void 0;
|
|
137772
137938
|
}
|
|
137773
137939
|
},
|
|
137774
|
-
|
|
137940
|
+
realPath: (target) => {
|
|
137775
137941
|
try {
|
|
137776
|
-
return import_node_fs22.default.
|
|
137942
|
+
return import_node_fs22.default.realpathSync(target);
|
|
137777
137943
|
} catch {
|
|
137778
137944
|
return void 0;
|
|
137779
137945
|
}
|
|
137780
137946
|
},
|
|
137781
|
-
|
|
137947
|
+
modifiedAtMs: (target) => {
|
|
137782
137948
|
try {
|
|
137783
|
-
return import_node_fs22.default.
|
|
137949
|
+
return import_node_fs22.default.statSync(target).mtimeMs;
|
|
137784
137950
|
} catch {
|
|
137785
137951
|
return void 0;
|
|
137786
137952
|
}
|
|
137787
137953
|
},
|
|
137788
|
-
|
|
137954
|
+
listDirectory: (target) => {
|
|
137789
137955
|
try {
|
|
137790
|
-
return import_node_fs22.default.
|
|
137956
|
+
return import_node_fs22.default.readdirSync(target);
|
|
137791
137957
|
} catch {
|
|
137792
137958
|
return void 0;
|
|
137793
137959
|
}
|
|
137794
|
-
}
|
|
137960
|
+
},
|
|
137961
|
+
writeText: (target, text4) => {
|
|
137962
|
+
const temporary = import_node_path56.default.join(import_node_path56.default.dirname(target), `.${import_node_path56.default.basename(target)}.${String(process.pid)}.tmp`);
|
|
137963
|
+
try {
|
|
137964
|
+
import_node_fs22.default.mkdirSync(import_node_path56.default.dirname(target), { recursive: true, mode: STATE_DIRECTORY_MODE });
|
|
137965
|
+
import_node_fs22.default.writeFileSync(temporary, text4, { mode: STATE_FILE_MODE });
|
|
137966
|
+
import_node_fs22.default.renameSync(temporary, target);
|
|
137967
|
+
} catch {
|
|
137968
|
+
discard(temporary);
|
|
137969
|
+
}
|
|
137970
|
+
},
|
|
137971
|
+
removePath: discard,
|
|
137972
|
+
memoryUse: readMemoryUse
|
|
137795
137973
|
};
|
|
137796
137974
|
}
|
|
137797
137975
|
|
|
@@ -138037,6 +138215,90 @@ function effortSegment({ payload, settings: settings2 }) {
|
|
|
138037
138215
|
return level === void 0 ? void 0 : formatEffort(level, settings2.effort.format);
|
|
138038
138216
|
}
|
|
138039
138217
|
|
|
138218
|
+
// src/statusline/dailyLedger.ts
|
|
138219
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
138220
|
+
init_zod();
|
|
138221
|
+
init_schema2();
|
|
138222
|
+
var DAILY_LEDGER_DIRECTORY = "daily-cost";
|
|
138223
|
+
var HOURS_PER_DAY8 = 24;
|
|
138224
|
+
var MS_PER_HOUR5 = 36e5;
|
|
138225
|
+
var SESSION_MAX_AGE_MS = HOURS_PER_DAY8 * MS_PER_HOUR5;
|
|
138226
|
+
var LAST_SEEN_REFRESH_MS = SESSION_MAX_AGE_MS / HOURS_PER_DAY8;
|
|
138227
|
+
var ENTRY_FILE = new RegExp(`^${CLIENT_SESSION_ID_PATTERN.source.slice(1, -1)}\\.json$`);
|
|
138228
|
+
var DAY_NAME = /^\d{4}-\d{2}-\d{2}$/;
|
|
138229
|
+
var usd = external_exports.number().nonnegative();
|
|
138230
|
+
var EntrySchema = external_exports.strictObject({ baselineUsd: usd, totalUsd: usd, source: external_exports.enum(["native", "estimate"]), seenAtMs: external_exports.number().int().positive() });
|
|
138231
|
+
function localDay(nowMs) {
|
|
138232
|
+
const date5 = new Date(nowMs);
|
|
138233
|
+
return `${String(date5.getFullYear())}-${String(date5.getMonth() + 1).padStart(2, "0")}-${String(date5.getDate()).padStart(2, "0")}`;
|
|
138234
|
+
}
|
|
138235
|
+
function parseEntry3(text4) {
|
|
138236
|
+
if (text4 === void 0) {
|
|
138237
|
+
return void 0;
|
|
138238
|
+
}
|
|
138239
|
+
let raw;
|
|
138240
|
+
try {
|
|
138241
|
+
raw = JSON.parse(text4);
|
|
138242
|
+
} catch {
|
|
138243
|
+
return void 0;
|
|
138244
|
+
}
|
|
138245
|
+
const parsed = EntrySchema.safeParse(raw);
|
|
138246
|
+
return parsed.success ? parsed.data : void 0;
|
|
138247
|
+
}
|
|
138248
|
+
function advance(existing, carried, cost, nowMs) {
|
|
138249
|
+
if (existing === void 0) {
|
|
138250
|
+
const carry = carried?.source === cost.source && nowMs - carried.seenAtMs <= SESSION_MAX_AGE_MS ? carried.totalUsd : void 0;
|
|
138251
|
+
const baselineUsd = carry ?? cost.usd;
|
|
138252
|
+
return { entry: { baselineUsd, totalUsd: Math.max(baselineUsd, cost.usd), source: cost.source, seenAtMs: nowMs }, changed: true };
|
|
138253
|
+
}
|
|
138254
|
+
if (existing.source !== cost.source) {
|
|
138255
|
+
return void 0;
|
|
138256
|
+
}
|
|
138257
|
+
if (cost.usd > existing.totalUsd || nowMs - existing.seenAtMs >= LAST_SEEN_REFRESH_MS) {
|
|
138258
|
+
return { entry: { ...existing, totalUsd: Math.max(existing.totalUsd, cost.usd), seenAtMs: nowMs }, changed: true };
|
|
138259
|
+
}
|
|
138260
|
+
return { entry: existing, changed: false };
|
|
138261
|
+
}
|
|
138262
|
+
function recordDailySpend(ports, nowMs, sessionId, cost) {
|
|
138263
|
+
const root = import_node_path57.default.join(ports.stateDirectory, DAILY_LEDGER_DIRECTORY);
|
|
138264
|
+
const today = localDay(nowMs);
|
|
138265
|
+
const days = (ports.listDirectory(root) ?? []).filter((name) => DAY_NAME.test(name));
|
|
138266
|
+
const previous = days.filter((day) => day < today).sort().at(-1);
|
|
138267
|
+
for (const day of days) {
|
|
138268
|
+
if (day < today && day !== previous) {
|
|
138269
|
+
ports.removePath(import_node_path57.default.join(root, day));
|
|
138270
|
+
}
|
|
138271
|
+
}
|
|
138272
|
+
const todayDirectory = import_node_path57.default.join(root, today);
|
|
138273
|
+
if (sessionId !== void 0 && cost !== void 0 && CLIENT_SESSION_ID_PATTERN.test(sessionId)) {
|
|
138274
|
+
const file2 = import_node_path57.default.join(todayDirectory, `${sessionId}.json`);
|
|
138275
|
+
const carried = previous === void 0 ? void 0 : parseEntry3(ports.readText(import_node_path57.default.join(root, previous, `${sessionId}.json`)));
|
|
138276
|
+
const next = advance(parseEntry3(ports.readText(file2)), carried, cost, nowMs);
|
|
138277
|
+
if (next?.changed === true) {
|
|
138278
|
+
ports.writeText(file2, `${JSON.stringify(next.entry)}
|
|
138279
|
+
`);
|
|
138280
|
+
}
|
|
138281
|
+
}
|
|
138282
|
+
const entries = (ports.listDirectory(todayDirectory) ?? []).filter((name) => ENTRY_FILE.test(name)).flatMap((name) => {
|
|
138283
|
+
const entry = parseEntry3(ports.readText(import_node_path57.default.join(todayDirectory, name)));
|
|
138284
|
+
return entry === void 0 ? [] : [entry];
|
|
138285
|
+
});
|
|
138286
|
+
return entries.length === 0 ? void 0 : entries.reduce((sum, entry) => sum + (entry.totalUsd - entry.baselineUsd), 0);
|
|
138287
|
+
}
|
|
138288
|
+
|
|
138289
|
+
// src/statusline/elements/header/cost.ts
|
|
138290
|
+
function costSegment(context) {
|
|
138291
|
+
const cost = resolveSessionCost(context);
|
|
138292
|
+
if (cost === void 0) {
|
|
138293
|
+
return void 0;
|
|
138294
|
+
}
|
|
138295
|
+
return `${cost.source === "native" ? "Cost" : "Est."} ${formatUsd(cost.usd)}`;
|
|
138296
|
+
}
|
|
138297
|
+
function dailyCostSegment(context) {
|
|
138298
|
+
const spend = recordDailySpend(context.ports, context.nowMs, context.payload.session_id, resolveSessionCost(context));
|
|
138299
|
+
return spend === void 0 ? void 0 : `Today ${formatUsd(spend)}`;
|
|
138300
|
+
}
|
|
138301
|
+
|
|
138040
138302
|
// src/statusline/palette.ts
|
|
138041
138303
|
init_statusline();
|
|
138042
138304
|
var RESET = `${ESCAPE}[0m`;
|
|
@@ -138239,11 +138501,11 @@ function modelSegment(context) {
|
|
|
138239
138501
|
}
|
|
138240
138502
|
|
|
138241
138503
|
// src/statusline/elements/header/outputStyle.ts
|
|
138242
|
-
var
|
|
138504
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
138243
138505
|
init_zod();
|
|
138244
138506
|
var SettingsFileSchema = external_exports.looseObject({ outputStyle: external_exports.string().optional().catch(void 0) });
|
|
138245
|
-
function outputStyleIn(file2,
|
|
138246
|
-
const text4 =
|
|
138507
|
+
function outputStyleIn(file2, readText2) {
|
|
138508
|
+
const text4 = readText2(file2);
|
|
138247
138509
|
if (text4 === void 0) {
|
|
138248
138510
|
return void 0;
|
|
138249
138511
|
}
|
|
@@ -138259,12 +138521,12 @@ function outputStyleIn(file2, readText) {
|
|
|
138259
138521
|
}
|
|
138260
138522
|
function outputStyleSegment({ payload, ports }) {
|
|
138261
138523
|
const pinned = ports.env.CLAUDE_CONFIG_DIR;
|
|
138262
|
-
const configDirectory = pinned === void 0 || pinned === "" ?
|
|
138524
|
+
const configDirectory = pinned === void 0 || pinned === "" ? import_node_path58.default.join(ports.homeDirectory, ".claude") : pinned;
|
|
138263
138525
|
const projectDirectory = payload.cwd ?? payload.workspace?.current_dir;
|
|
138264
138526
|
const files = [
|
|
138265
|
-
|
|
138266
|
-
|
|
138267
|
-
...projectDirectory === void 0 ? [] : [
|
|
138527
|
+
import_node_path58.default.join(configDirectory, "settings.json"),
|
|
138528
|
+
import_node_path58.default.join(configDirectory, "settings.local.json"),
|
|
138529
|
+
...projectDirectory === void 0 ? [] : [import_node_path58.default.join(projectDirectory, ".claude", "settings.json"), import_node_path58.default.join(projectDirectory, ".claude", "settings.local.json")]
|
|
138268
138530
|
];
|
|
138269
138531
|
const style = files.map((file2) => outputStyleIn(file2, ports.readText)).findLast((name) => name !== void 0);
|
|
138270
138532
|
return style === void 0 ? void 0 : `style: ${style}`;
|
|
@@ -138420,15 +138682,15 @@ function parseNumstat(output2) {
|
|
|
138420
138682
|
if (addedText === void 0 || deletedText === void 0 || pathText === void 0) {
|
|
138421
138683
|
continue;
|
|
138422
138684
|
}
|
|
138423
|
-
const
|
|
138685
|
+
const path71 = pathText === "" ? fields[index + 2] : pathText;
|
|
138424
138686
|
if (pathText === "") {
|
|
138425
138687
|
index += 2;
|
|
138426
138688
|
}
|
|
138427
138689
|
const lines = { added: Number(addedText), deleted: Number(deletedText) };
|
|
138428
|
-
if (
|
|
138690
|
+
if (path71 !== void 0 && Number.isInteger(lines.added) && Number.isInteger(lines.deleted)) {
|
|
138429
138691
|
added += lines.added;
|
|
138430
138692
|
deleted += lines.deleted;
|
|
138431
|
-
byPath.set(
|
|
138693
|
+
byPath.set(path71, lines);
|
|
138432
138694
|
}
|
|
138433
138695
|
}
|
|
138434
138696
|
return { total: { added, deleted }, byPath };
|
|
@@ -138483,7 +138745,7 @@ function readGitStatus(ports, cwd, query) {
|
|
|
138483
138745
|
}
|
|
138484
138746
|
|
|
138485
138747
|
// src/statusline/vcs/jj.ts
|
|
138486
|
-
var
|
|
138748
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
138487
138749
|
var JJ2 = "jj";
|
|
138488
138750
|
var MAX_WALK_DEPTH = 64;
|
|
138489
138751
|
var MAX_LABEL_CODE_POINTS = 64;
|
|
@@ -138496,13 +138758,13 @@ function isJjRepository(ports, cwd) {
|
|
|
138496
138758
|
return false;
|
|
138497
138759
|
}
|
|
138498
138760
|
for (let depth = 0; depth < MAX_WALK_DEPTH; depth += 1) {
|
|
138499
|
-
if (ports.entryKind(
|
|
138761
|
+
if (ports.entryKind(import_node_path59.default.join(directory, ".jj")) === "directory") {
|
|
138500
138762
|
return true;
|
|
138501
138763
|
}
|
|
138502
|
-
if (ports.entryKind(
|
|
138764
|
+
if (ports.entryKind(import_node_path59.default.join(directory, ".git")) !== void 0) {
|
|
138503
138765
|
return false;
|
|
138504
138766
|
}
|
|
138505
|
-
const parent =
|
|
138767
|
+
const parent = import_node_path59.default.dirname(directory);
|
|
138506
138768
|
if (parent === directory) {
|
|
138507
138769
|
return false;
|
|
138508
138770
|
}
|
|
@@ -138697,9 +138959,137 @@ function gitFilesRow(context) {
|
|
|
138697
138959
|
return { kind: "text", lines: [entries.join(" ")] };
|
|
138698
138960
|
}
|
|
138699
138961
|
|
|
138700
|
-
// src/statusline/
|
|
138701
|
-
|
|
138702
|
-
|
|
138962
|
+
// src/statusline/configCounts.ts
|
|
138963
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
138964
|
+
init_zod();
|
|
138965
|
+
var nameList = external_exports.array(external_exports.unknown()).catch([]).transform((items) => items.filter((item) => typeof item === "string"));
|
|
138966
|
+
var ConfigFileSchema = external_exports.looseObject({
|
|
138967
|
+
mcpServers: external_exports.record(external_exports.string(), external_exports.unknown()).optional().catch(void 0),
|
|
138968
|
+
hooks: external_exports.record(external_exports.string(), external_exports.unknown()).optional().catch(void 0),
|
|
138969
|
+
disabledMcpServers: nameList.optional(),
|
|
138970
|
+
disabledMcpjsonServers: nameList.optional()
|
|
138971
|
+
});
|
|
138972
|
+
var MAX_RULE_DIRECTORIES = 1e3;
|
|
138973
|
+
var MAX_RULE_ENTRIES = 1e4;
|
|
138974
|
+
var BYTES_PER_MEBIBYTE = 1048576;
|
|
138975
|
+
var MAX_CONFIG_FILE_MEBIBYTES = 8;
|
|
138976
|
+
var MAX_CONFIG_FILE_BYTES = MAX_CONFIG_FILE_MEBIBYTES * BYTES_PER_MEBIBYTE;
|
|
138977
|
+
function readConfigFile(ports, file2) {
|
|
138978
|
+
const size = ports.readRange(file2, 0, 0)?.size;
|
|
138979
|
+
if (size === void 0 || size > MAX_CONFIG_FILE_BYTES) {
|
|
138980
|
+
return void 0;
|
|
138981
|
+
}
|
|
138982
|
+
const text4 = ports.readText(file2);
|
|
138983
|
+
if (text4 === void 0) {
|
|
138984
|
+
return void 0;
|
|
138985
|
+
}
|
|
138986
|
+
let raw;
|
|
138987
|
+
try {
|
|
138988
|
+
raw = JSON.parse(text4);
|
|
138989
|
+
} catch {
|
|
138990
|
+
return void 0;
|
|
138991
|
+
}
|
|
138992
|
+
const parsed = ConfigFileSchema.safeParse(raw);
|
|
138993
|
+
return parsed.success ? parsed.data : void 0;
|
|
138994
|
+
}
|
|
138995
|
+
function namesOf(file2) {
|
|
138996
|
+
return new Set(file2?.mcpServers === void 0 ? [] : Object.keys(file2.mcpServers));
|
|
138997
|
+
}
|
|
138998
|
+
function hookEventsOf(file2) {
|
|
138999
|
+
return file2?.hooks === void 0 ? 0 : Object.keys(file2.hooks).length;
|
|
139000
|
+
}
|
|
139001
|
+
function removeNames(servers, names) {
|
|
139002
|
+
if (names === void 0) {
|
|
139003
|
+
return;
|
|
139004
|
+
}
|
|
139005
|
+
for (const name of names) {
|
|
139006
|
+
servers.delete(name);
|
|
139007
|
+
}
|
|
139008
|
+
}
|
|
139009
|
+
function followedKind(ports, target) {
|
|
139010
|
+
const real = ports.realPath(target);
|
|
139011
|
+
return real === void 0 ? void 0 : ports.entryKind(real);
|
|
139012
|
+
}
|
|
139013
|
+
function isFile(ports, file2) {
|
|
139014
|
+
return followedKind(ports, file2) === "other";
|
|
139015
|
+
}
|
|
139016
|
+
function countRules(ports, root) {
|
|
139017
|
+
const visited = /* @__PURE__ */ new Set();
|
|
139018
|
+
let entries = 0;
|
|
139019
|
+
let directories = 0;
|
|
139020
|
+
const walk3 = (directory) => {
|
|
139021
|
+
const real = ports.realPath(directory);
|
|
139022
|
+
if (real === void 0 || visited.has(real) || directories >= MAX_RULE_DIRECTORIES) {
|
|
139023
|
+
return 0;
|
|
139024
|
+
}
|
|
139025
|
+
visited.add(real);
|
|
139026
|
+
directories += 1;
|
|
139027
|
+
const names = ports.listDirectory(real);
|
|
139028
|
+
if (names === void 0) {
|
|
139029
|
+
return 0;
|
|
139030
|
+
}
|
|
139031
|
+
let count = 0;
|
|
139032
|
+
for (const name of names) {
|
|
139033
|
+
if (entries >= MAX_RULE_ENTRIES) {
|
|
139034
|
+
break;
|
|
139035
|
+
}
|
|
139036
|
+
entries += 1;
|
|
139037
|
+
const entry = import_node_path60.default.join(real, name);
|
|
139038
|
+
const kind = followedKind(ports, entry);
|
|
139039
|
+
if (kind === "directory") {
|
|
139040
|
+
count += walk3(entry);
|
|
139041
|
+
} else if (kind === "other" && name.endsWith(".md")) {
|
|
139042
|
+
const target = ports.realPath(entry);
|
|
139043
|
+
if (target !== void 0 && !visited.has(target)) {
|
|
139044
|
+
visited.add(target);
|
|
139045
|
+
count += 1;
|
|
139046
|
+
}
|
|
139047
|
+
}
|
|
139048
|
+
}
|
|
139049
|
+
return count;
|
|
139050
|
+
};
|
|
139051
|
+
return walk3(root);
|
|
139052
|
+
}
|
|
139053
|
+
function sameLocation(ports, left, right) {
|
|
139054
|
+
return (ports.realPath(left) ?? import_node_path60.default.resolve(left)) === (ports.realPath(right) ?? import_node_path60.default.resolve(right));
|
|
139055
|
+
}
|
|
139056
|
+
function configDirectoryOf(ports) {
|
|
139057
|
+
const pinned = ports.env.CLAUDE_CONFIG_DIR;
|
|
139058
|
+
return pinned === void 0 || pinned === "" ? import_node_path60.default.join(ports.homeDirectory, ".claude") : pinned;
|
|
139059
|
+
}
|
|
139060
|
+
function countConfiguration(ports, projectDirectory) {
|
|
139061
|
+
const userDirectory = configDirectoryOf(ports);
|
|
139062
|
+
const userSettings = readConfigFile(ports, import_node_path60.default.join(userDirectory, "settings.json"));
|
|
139063
|
+
const globalFile = ports.env.CLAUDE_CONFIG_DIR === void 0 || ports.env.CLAUDE_CONFIG_DIR === "" ? import_node_path60.default.join(ports.homeDirectory, ".claude.json") : import_node_path60.default.join(userDirectory, ".claude.json");
|
|
139064
|
+
const global2 = readConfigFile(ports, globalFile);
|
|
139065
|
+
const userServers = /* @__PURE__ */ new Set([...namesOf(userSettings), ...namesOf(global2)]);
|
|
139066
|
+
removeNames(userServers, global2?.disabledMcpServers);
|
|
139067
|
+
const projectServers = /* @__PURE__ */ new Set();
|
|
139068
|
+
let claudeMd = isFile(ports, import_node_path60.default.join(userDirectory, "CLAUDE.md")) ? 1 : 0;
|
|
139069
|
+
let rules = countRules(ports, import_node_path60.default.join(userDirectory, "rules"));
|
|
139070
|
+
let hookEvents = hookEventsOf(userSettings);
|
|
139071
|
+
if (projectDirectory !== void 0) {
|
|
139072
|
+
const projectClaude = import_node_path60.default.join(projectDirectory, ".claude");
|
|
139073
|
+
const projectIsUser = sameLocation(ports, projectClaude, userDirectory);
|
|
139074
|
+
const claudeMdFiles = [import_node_path60.default.join(projectDirectory, "CLAUDE.md"), import_node_path60.default.join(projectDirectory, "CLAUDE.local.md"), import_node_path60.default.join(projectClaude, "CLAUDE.local.md"), ...projectIsUser ? [] : [import_node_path60.default.join(projectClaude, "CLAUDE.md")]];
|
|
139075
|
+
claudeMd += claudeMdFiles.filter((file2) => isFile(ports, file2)).length;
|
|
139076
|
+
const mcpJson = namesOf(readConfigFile(ports, import_node_path60.default.join(projectDirectory, ".mcp.json")));
|
|
139077
|
+
if (!projectIsUser) {
|
|
139078
|
+
rules += countRules(ports, import_node_path60.default.join(projectClaude, "rules"));
|
|
139079
|
+
const settings2 = readConfigFile(ports, import_node_path60.default.join(projectClaude, "settings.json"));
|
|
139080
|
+
const local = readConfigFile(ports, import_node_path60.default.join(projectClaude, "settings.local.json"));
|
|
139081
|
+
hookEvents += hookEventsOf(settings2) + hookEventsOf(local);
|
|
139082
|
+
for (const name of [...namesOf(settings2), ...namesOf(local)]) {
|
|
139083
|
+
projectServers.add(name);
|
|
139084
|
+
}
|
|
139085
|
+
removeNames(mcpJson, local?.disabledMcpjsonServers);
|
|
139086
|
+
}
|
|
139087
|
+
for (const name of mcpJson) {
|
|
139088
|
+
projectServers.add(name);
|
|
139089
|
+
}
|
|
139090
|
+
}
|
|
139091
|
+
return { claudeMd, rules, mcpServers: userServers.size + projectServers.size, hookEvents };
|
|
139092
|
+
}
|
|
138703
139093
|
|
|
138704
139094
|
// src/statusline/headerLayout.ts
|
|
138705
139095
|
var SEPARATOR2 = " | ";
|
|
@@ -138768,6 +139158,38 @@ function layoutHeader(texts, maxWidth, separator) {
|
|
|
138768
139158
|
return packLines(texts, maxWidth, separator).map((line) => justify(line, maxWidth, separator)).join("\n");
|
|
138769
139159
|
}
|
|
138770
139160
|
|
|
139161
|
+
// src/statusline/elements/rows/environment.ts
|
|
139162
|
+
function counted(count, singular, plural2) {
|
|
139163
|
+
return count === 0 ? void 0 : `${String(count)} ${count === 1 ? singular : plural2}`;
|
|
139164
|
+
}
|
|
139165
|
+
function environmentRow(context) {
|
|
139166
|
+
const { payload, settings: settings2, palette, ports } = context;
|
|
139167
|
+
const counts = countConfiguration(ports, payload.cwd ?? payload.workspace?.current_dir);
|
|
139168
|
+
const total = counts.claudeMd + counts.rules + counts.mcpServers + counts.hookEvents;
|
|
139169
|
+
if (total === 0 || total < settings2.environment.threshold) {
|
|
139170
|
+
return { kind: "text", lines: [] };
|
|
139171
|
+
}
|
|
139172
|
+
const parts = [counted(counts.claudeMd, "CLAUDE.md", "CLAUDE.md"), counted(counts.rules, "rule", "rules"), counted(counts.mcpServers, "MCP", "MCPs"), counted(counts.hookEvents, "hook", "hooks")].filter((part) => part !== void 0);
|
|
139173
|
+
return { kind: "text", lines: packLines(parts.map((part) => palette.paint("label", part)), context.width, SEPARATOR2).map((line) => line.join(SEPARATOR2)) };
|
|
139174
|
+
}
|
|
139175
|
+
|
|
139176
|
+
// src/statusline/elements/rows/memory.ts
|
|
139177
|
+
function memoryRow(context) {
|
|
139178
|
+
const use2 = context.ports.memoryUse();
|
|
139179
|
+
const cells = [];
|
|
139180
|
+
if (use2 !== void 0 && use2.totalBytes > 0) {
|
|
139181
|
+
const style = barStyleOf(context, "usage");
|
|
139182
|
+
const fraction = Math.max(0, Math.min(1, use2.usedBytes / use2.totalBytes));
|
|
139183
|
+
const percent2 = withColor(statusColor(fraction, true, style), `${(fraction * FULL_PERCENT3).toFixed(1)}%`);
|
|
139184
|
+
cells.push(barCell(context.palette.paint("label", "RAM "), ` ${percent2} (${formatBytes(use2.usedBytes)} / ${formatBytes(use2.totalBytes)})`, fraction, style));
|
|
139185
|
+
}
|
|
139186
|
+
return { kind: "bars", cells };
|
|
139187
|
+
}
|
|
139188
|
+
|
|
139189
|
+
// src/statusline/elements/rows/quota.ts
|
|
139190
|
+
init_statusline();
|
|
139191
|
+
init_pick();
|
|
139192
|
+
|
|
138771
139193
|
// src/statusline/wallClock.ts
|
|
138772
139194
|
var DAY_KEY_LOCALE = "en-CA";
|
|
138773
139195
|
var FORMATTERS = /* @__PURE__ */ new Map();
|
|
@@ -138925,11 +139347,13 @@ var HEADER_ROLES = {
|
|
|
138925
139347
|
effort: "model",
|
|
138926
139348
|
advisor: "label",
|
|
138927
139349
|
version: "label",
|
|
138928
|
-
outputStyle: "label"
|
|
139350
|
+
outputStyle: "label",
|
|
139351
|
+
cost: "label",
|
|
139352
|
+
dailyCost: "label"
|
|
138929
139353
|
};
|
|
138930
139354
|
var ELEMENTS = {
|
|
138931
|
-
header: { model: modelSegment, provider: providerSegment, route: routeSegment, account: accountSegment, identity: identitySegment, headroom: headroomSegment, project: projectSegment, vcs: vcsSegment, effort: effortSegment, advisor: advisorSegment, version: versionSegment, outputStyle: outputStyleSegment },
|
|
138932
|
-
rows: { context: contextRow, quota: quotaRow, addedDirs: addedDirsRow, gitFiles: gitFilesRow }
|
|
139355
|
+
header: { model: modelSegment, provider: providerSegment, route: routeSegment, account: accountSegment, identity: identitySegment, headroom: headroomSegment, project: projectSegment, vcs: vcsSegment, effort: effortSegment, advisor: advisorSegment, version: versionSegment, outputStyle: outputStyleSegment, cost: costSegment, dailyCost: dailyCostSegment },
|
|
139356
|
+
rows: { context: contextRow, quota: quotaRow, addedDirs: addedDirsRow, gitFiles: gitFilesRow, memory: memoryRow, environment: environmentRow }
|
|
138933
139357
|
};
|
|
138934
139358
|
|
|
138935
139359
|
// src/statusline/identityTranscript.ts
|
|
@@ -139129,7 +139553,7 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
139129
139553
|
} else {
|
|
139130
139554
|
const configDir = process.env.CLAUDE_CONFIG_DIR;
|
|
139131
139555
|
try {
|
|
139132
|
-
account = readAccountMetadataFile(realFarmFs, configDir === void 0 || configDir === "" ?
|
|
139556
|
+
account = readAccountMetadataFile(realFarmFs, configDir === void 0 || configDir === "" ? import_node_path61.default.join(import_node_os13.default.homedir(), ".claude.json") : import_node_path61.default.join(configDir, ".claude.json"));
|
|
139133
139557
|
} catch {
|
|
139134
139558
|
account = void 0;
|
|
139135
139559
|
}
|
|
@@ -139166,17 +139590,24 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
139166
139590
|
routedTarget = void 0;
|
|
139167
139591
|
}
|
|
139168
139592
|
}
|
|
139169
|
-
const
|
|
139593
|
+
const clientPayload = parseClientPayload(payload);
|
|
139594
|
+
const enrichParams = { payload, env: process.env, snapshot, account, providerName, nowMs, headroom, routedTarget, ...modelChoice === void 0 ? {} : { modelChoice } };
|
|
139170
139595
|
const renderer = process.env.AGENT_SHIM_STATUSLINE_CMD;
|
|
139171
139596
|
if (renderer !== void 0 && renderer !== "") {
|
|
139172
139597
|
const child = (0, import_node_child_process8.spawn)("/bin/sh", ["-c", renderer], { stdio: ["pipe", "inherit", "inherit"] });
|
|
139173
|
-
child.stdin.end(`${JSON.stringify(
|
|
139598
|
+
child.stdin.end(`${JSON.stringify(enrichStatuslinePayload(enrichParams).payload)}
|
|
139174
139599
|
`);
|
|
139175
139600
|
child.on("close", (code) => {
|
|
139176
139601
|
process.exit(code ?? 0);
|
|
139177
139602
|
});
|
|
139178
139603
|
return;
|
|
139179
139604
|
}
|
|
139605
|
+
const rawSettings = process.env[STATUSLINE_ENV];
|
|
139606
|
+
const settings2 = resolveStatusline(rawSettings === void 0 || rawSettings === "" ? void 0 : statuslineSettingsFromEnv(rawSettings, STATUSLINE_ENV));
|
|
139607
|
+
const conversationId = clientPayload.session_id;
|
|
139608
|
+
const prices = settings2.layout.header.some((name) => name === "cost" || name === "dailyCost") ? readModels(deps.paths)?.prices : void 0;
|
|
139609
|
+
const doorCostUsd = prices === void 0 || conversationId === void 0 ? void 0 : readDoorCostUsd({ fs: realFarmFs, logDir: deps.paths.usageLogDir, prices, conversationId, nowMs, sessionDurationMs: clientPayload.cost?.total_duration_ms });
|
|
139610
|
+
const { summary } = enrichStatuslinePayload({ ...enrichParams, ...doorCostUsd === void 0 ? {} : { doorCostUsd } });
|
|
139180
139611
|
let stackedUnderDefault = false;
|
|
139181
139612
|
if (isAntigravityPayload(payload)) {
|
|
139182
139613
|
try {
|
|
@@ -139185,11 +139616,8 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
139185
139616
|
stackedUnderDefault = false;
|
|
139186
139617
|
}
|
|
139187
139618
|
}
|
|
139188
|
-
const clientPayload = parseClientPayload(payload);
|
|
139189
139619
|
const view = { ...viewOf(clientPayload), ...stackedUnderDefault ? { modelDisplayName: void 0 } : {} };
|
|
139190
|
-
|
|
139191
|
-
const settings2 = resolveStatusline(rawSettings === void 0 || rawSettings === "" ? void 0 : statuslineSettingsFromEnv(rawSettings, STATUSLINE_ENV));
|
|
139192
|
-
console.log(renderStatuslineBlock({ summary, view, payload: clientPayload, terminalWidth: terminalWidthOf(payload, process.env), nowMs, settings: settings2, ports: realStatuslinePorts(process.env) }));
|
|
139620
|
+
console.log(renderStatuslineBlock({ summary, view, payload: clientPayload, terminalWidth: terminalWidthOf(payload, process.env), nowMs, settings: settings2, ports: realStatuslinePorts(process.env, deps.paths.statuslineDir) }));
|
|
139193
139621
|
}),
|
|
139194
139622
|
["$ agent-shim statusline # a client's statusline setting names this; it renders or delegates"]
|
|
139195
139623
|
);
|
|
@@ -141226,8 +141654,8 @@ function getErrorMap2() {
|
|
|
141226
141654
|
|
|
141227
141655
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/helpers/parseUtil.js
|
|
141228
141656
|
var makeIssue = (params) => {
|
|
141229
|
-
const { data, path:
|
|
141230
|
-
const fullPath = [...
|
|
141657
|
+
const { data, path: path71, errorMaps, issueData } = params;
|
|
141658
|
+
const fullPath = [...path71, ...issueData.path || []];
|
|
141231
141659
|
const fullIssue = {
|
|
141232
141660
|
...issueData,
|
|
141233
141661
|
path: fullPath
|
|
@@ -141342,11 +141770,11 @@ var errorUtil;
|
|
|
141342
141770
|
|
|
141343
141771
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/types.js
|
|
141344
141772
|
var ParseInputLazyPath = class {
|
|
141345
|
-
constructor(parent, value2,
|
|
141773
|
+
constructor(parent, value2, path71, key) {
|
|
141346
141774
|
this._cachedPath = [];
|
|
141347
141775
|
this.parent = parent;
|
|
141348
141776
|
this.data = value2;
|
|
141349
|
-
this._path =
|
|
141777
|
+
this._path = path71;
|
|
141350
141778
|
this._key = key;
|
|
141351
141779
|
}
|
|
141352
141780
|
get path() {
|
|
@@ -144909,11 +145337,11 @@ function normalizeObjectSchema(schema) {
|
|
|
144909
145337
|
}
|
|
144910
145338
|
return void 0;
|
|
144911
145339
|
}
|
|
144912
|
-
function getDotPath(
|
|
144913
|
-
if (
|
|
145340
|
+
function getDotPath(path71) {
|
|
145341
|
+
if (path71.length === 0) {
|
|
144914
145342
|
return "object root";
|
|
144915
145343
|
}
|
|
144916
|
-
return
|
|
145344
|
+
return path71.reduce((acc, seg, index) => {
|
|
144917
145345
|
if (index === 0) {
|
|
144918
145346
|
return String(seg);
|
|
144919
145347
|
}
|
|
@@ -148956,7 +149384,7 @@ async function serveMcp(mcp, transport, options = {}) {
|
|
|
148956
149384
|
|
|
148957
149385
|
// src/mcp/permissions.ts
|
|
148958
149386
|
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
148959
|
-
var
|
|
149387
|
+
var import_node_path62 = __toESM(require("node:path"), 1);
|
|
148960
149388
|
init_zod();
|
|
148961
149389
|
init_store();
|
|
148962
149390
|
var StoredMcpPermissionsSchema = external_exports.strictObject({
|
|
@@ -148978,10 +149406,10 @@ function effectiveMcpPermissions(flags, stored) {
|
|
|
148978
149406
|
return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl, history: flags.history || stored.history };
|
|
148979
149407
|
}
|
|
148980
149408
|
function watchMcpPermissions(paths, onChange) {
|
|
148981
|
-
const directory =
|
|
149409
|
+
const directory = import_node_path62.default.dirname(paths.mcpPermissionsFile);
|
|
148982
149410
|
import_node_fs23.default.mkdirSync(directory, { recursive: true });
|
|
148983
149411
|
const watcher = import_node_fs23.default.watch(directory, (_event, filename) => {
|
|
148984
|
-
if (filename === null || filename ===
|
|
149412
|
+
if (filename === null || filename === import_node_path62.default.basename(paths.mcpPermissionsFile)) {
|
|
148985
149413
|
onChange();
|
|
148986
149414
|
}
|
|
148987
149415
|
});
|
|
@@ -149295,16 +149723,16 @@ init_credentialCache();
|
|
|
149295
149723
|
|
|
149296
149724
|
// src/identityToken.ts
|
|
149297
149725
|
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
149298
|
-
var
|
|
149726
|
+
var import_node_path63 = __toESM(require("node:path"), 1);
|
|
149299
149727
|
init_cliError();
|
|
149300
149728
|
var TOKEN_FILE_MODE = 384;
|
|
149301
149729
|
var TOKEN_DIR_MODE = 448;
|
|
149302
149730
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
149303
149731
|
function identityTokenDir(paths) {
|
|
149304
|
-
return
|
|
149732
|
+
return import_node_path63.default.join(paths.root, "credentials");
|
|
149305
149733
|
}
|
|
149306
149734
|
function identityTokenPath(paths, identityName) {
|
|
149307
|
-
return
|
|
149735
|
+
return import_node_path63.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
149308
149736
|
}
|
|
149309
149737
|
function storeIdentityToken(paths, identityName, raw) {
|
|
149310
149738
|
const token = raw.trim();
|
|
@@ -149315,7 +149743,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
149315
149743
|
import_node_fs24.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
149316
149744
|
import_node_fs24.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
149317
149745
|
const target = identityTokenPath(paths, identityName);
|
|
149318
|
-
const temp =
|
|
149746
|
+
const temp = import_node_path63.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
149319
149747
|
import_node_fs24.default.writeFileSync(temp, `${token}
|
|
149320
149748
|
`, { mode: TOKEN_FILE_MODE });
|
|
149321
149749
|
import_node_fs24.default.renameSync(temp, target);
|
|
@@ -149486,7 +149914,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
149486
149914
|
// src/headroom/commands.ts
|
|
149487
149915
|
var import_node_fs25 = __toESM(require("node:fs"), 1);
|
|
149488
149916
|
var import_node_http5 = __toESM(require("node:http"), 1);
|
|
149489
|
-
var
|
|
149917
|
+
var import_node_path64 = __toESM(require("node:path"), 1);
|
|
149490
149918
|
var import_node_child_process10 = require("node:child_process");
|
|
149491
149919
|
init_commandDeps();
|
|
149492
149920
|
init_configProfilesStore();
|
|
@@ -149676,12 +150104,12 @@ function readInstalledHeadroomCommit() {
|
|
|
149676
150104
|
if (toolDir.status !== 0) {
|
|
149677
150105
|
return void 0;
|
|
149678
150106
|
}
|
|
149679
|
-
const libDir =
|
|
150107
|
+
const libDir = import_node_path64.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
149680
150108
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
149681
|
-
const sitePackages =
|
|
150109
|
+
const sitePackages = import_node_path64.default.join(libDir, python, "site-packages");
|
|
149682
150110
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
149683
150111
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
149684
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
150112
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path64.default.join(sitePackages, entry, "direct_url.json"));
|
|
149685
150113
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
149686
150114
|
}
|
|
149687
150115
|
}
|
|
@@ -149937,7 +150365,7 @@ async function refreshCatalogueForReal(paths, name, env) {
|
|
|
149937
150365
|
init_realPorts();
|
|
149938
150366
|
|
|
149939
150367
|
// src/usage/realJobRunner.ts
|
|
149940
|
-
var
|
|
150368
|
+
var import_node_path65 = __toESM(require("node:path"), 1);
|
|
149941
150369
|
init_conditions();
|
|
149942
150370
|
init_identityClaude();
|
|
149943
150371
|
var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
|
|
@@ -149950,7 +150378,7 @@ ${outcome.trimEnd()}
|
|
|
149950
150378
|
}
|
|
149951
150379
|
function createRealJobRunner(params) {
|
|
149952
150380
|
return async (name, identity, job) => {
|
|
149953
|
-
const logFile =
|
|
150381
|
+
const logFile = import_node_path65.default.join(params.paths.jobLogsDir, `${name}.log`);
|
|
149954
150382
|
const append = (outcome) => {
|
|
149955
150383
|
params.fs.mkdirPrivate(params.paths.jobLogsDir);
|
|
149956
150384
|
params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
|
|
@@ -150007,7 +150435,7 @@ function registerHeadlessCommands(program2, deps) {
|
|
|
150007
150435
|
}
|
|
150008
150436
|
|
|
150009
150437
|
// src/jobs.ts
|
|
150010
|
-
var
|
|
150438
|
+
var import_node_path66 = __toESM(require("node:path"), 1);
|
|
150011
150439
|
init_commandDeps();
|
|
150012
150440
|
init_cliError();
|
|
150013
150441
|
init_schema();
|
|
@@ -150032,7 +150460,7 @@ function jobOf(options) {
|
|
|
150032
150460
|
target: options.identity === void 0 ? { pool: options.pool ?? "" } : { identity: options.identity },
|
|
150033
150461
|
trigger: options.at === void 0 ? { beforeReset: options.beforeReset ?? "fiveHour", lead: options.lead ?? "" } : { at: options.at },
|
|
150034
150462
|
prompt: options.prompt,
|
|
150035
|
-
cwd:
|
|
150463
|
+
cwd: import_node_path66.default.resolve(options.cwd ?? process.cwd()),
|
|
150036
150464
|
timeout: options.timeout,
|
|
150037
150465
|
...options.model === void 0 ? {} : { model: options.model },
|
|
150038
150466
|
...options.allowedTool === void 0 ? {} : { allowedTools: options.allowedTool }
|
|
@@ -150105,7 +150533,7 @@ function registerJobCommand(program2, deps) {
|
|
|
150105
150533
|
console.log(`Allowed tools: ${entry.allowedTools.join(", ")}`);
|
|
150106
150534
|
}
|
|
150107
150535
|
console.log(`Prompt: ${entry.prompt}`);
|
|
150108
|
-
console.log(`Results: ${
|
|
150536
|
+
console.log(`Results: ${import_node_path66.default.join(paths.jobLogsDir, `${name}.log`)}`);
|
|
150109
150537
|
}),
|
|
150110
150538
|
["agent-shim job show digest"]
|
|
150111
150539
|
);
|
|
@@ -150128,7 +150556,7 @@ function registerJobCommand(program2, deps) {
|
|
|
150128
150556
|
throw new UsageError(`No member of the job's pool can be picked right now.`);
|
|
150129
150557
|
}
|
|
150130
150558
|
await createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() })(name, identity, entry);
|
|
150131
|
-
console.log(`Ran job "${name}" as ${identity}; the result is in ${
|
|
150559
|
+
console.log(`Ran job "${name}" as ${identity}; the result is in ${import_node_path66.default.join(paths.jobLogsDir, `${name}.log`)}.`);
|
|
150132
150560
|
}),
|
|
150133
150561
|
["agent-shim job run digest"]
|
|
150134
150562
|
);
|
|
@@ -150292,7 +150720,7 @@ init_providerAliases();
|
|
|
150292
150720
|
|
|
150293
150721
|
// src/providerRename.ts
|
|
150294
150722
|
var import_node_fs26 = __toESM(require("node:fs"), 1);
|
|
150295
|
-
var
|
|
150723
|
+
var import_node_path67 = __toESM(require("node:path"), 1);
|
|
150296
150724
|
init_schema();
|
|
150297
150725
|
init_store();
|
|
150298
150726
|
init_load();
|
|
@@ -150409,7 +150837,7 @@ function rewriteReferences(paths, from, to2) {
|
|
|
150409
150837
|
const launch = renamedLaunch(profile.launch, from, to2);
|
|
150410
150838
|
const models = profile.models === void 0 ? void 0 : renamedModels(profile.models, from, to2);
|
|
150411
150839
|
if (launch !== void 0 || models !== void 0) {
|
|
150412
|
-
applyPatch(
|
|
150840
|
+
applyPatch(import_node_path67.default.join(paths.configProfilesDir, `${name}.json`), ConfigProfileSchema, { ...launch === void 0 ? {} : { launch }, ...models === void 0 ? {} : { models } });
|
|
150413
150841
|
rewritten.push(`profile ${name}`);
|
|
150414
150842
|
}
|
|
150415
150843
|
}
|
|
@@ -151236,7 +151664,7 @@ function registerSessionCommands(program2, deps) {
|
|
|
151236
151664
|
}
|
|
151237
151665
|
|
|
151238
151666
|
// src/usage/commands.ts
|
|
151239
|
-
var
|
|
151667
|
+
var import_node_path68 = __toESM(require("node:path"), 1);
|
|
151240
151668
|
init_commandDeps();
|
|
151241
151669
|
init_realPorts();
|
|
151242
151670
|
init_account();
|
|
@@ -151375,7 +151803,7 @@ function collectAccounts(fs30, paths, identity, probe) {
|
|
|
151375
151803
|
return names.map((name) => ({
|
|
151376
151804
|
identity: name,
|
|
151377
151805
|
account: readAccountMetadata(fs30, paths.identitiesDir, name),
|
|
151378
|
-
signIn: identitySignIn(fs30, probe, { farmRoot:
|
|
151806
|
+
signIn: identitySignIn(fs30, probe, { farmRoot: import_node_path68.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
|
|
151379
151807
|
usage: readUsageSnapshot(fs30, paths.usageSnapshotsDir, name)
|
|
151380
151808
|
}));
|
|
151381
151809
|
}
|
|
@@ -151782,7 +152210,7 @@ function quotaHitOf(fs30, paths, identity, sessionId, sinceMs, nowMs) {
|
|
|
151782
152210
|
}
|
|
151783
152211
|
|
|
151784
152212
|
// src/supervise/move.ts
|
|
151785
|
-
var
|
|
152213
|
+
var import_node_path69 = __toESM(require("node:path"), 1);
|
|
151786
152214
|
init_lock();
|
|
151787
152215
|
init_poolPick();
|
|
151788
152216
|
init_read();
|
|
@@ -151828,7 +152256,7 @@ function createMover(deps) {
|
|
|
151828
152256
|
if (resolution.identity === request7.from) {
|
|
151829
152257
|
return { kind: "stay", reason: `no other member of pool "${pool}" can take it` };
|
|
151830
152258
|
}
|
|
151831
|
-
const transcript =
|
|
152259
|
+
const transcript = import_node_path69.default.join(paths.identitiesDir, resolution.identity, "projects", projectDirNameOf(deps.cwd), `${request7.sessionId}.jsonl`);
|
|
151832
152260
|
if (farmFs.lstat(transcript)?.kind !== "file") {
|
|
151833
152261
|
return { kind: "stay", reason: `${resolution.identity} does not share this conversation's history, so it could not resume it` };
|
|
151834
152262
|
}
|
|
@@ -151862,13 +152290,13 @@ function createIdentityMover(deps) {
|
|
|
151862
152290
|
throw error63;
|
|
151863
152291
|
}
|
|
151864
152292
|
try {
|
|
151865
|
-
if (farmFs.readFileUtf8(
|
|
152293
|
+
if (farmFs.readFileUtf8(import_node_path69.default.join(paths.identitiesDir, request7.to, "identity.json")) === void 0) {
|
|
151866
152294
|
return { kind: "stay", reason: `no identity "${request7.to}"` };
|
|
151867
152295
|
}
|
|
151868
152296
|
if (request7.to === request7.from) {
|
|
151869
152297
|
return { kind: "stay", reason: `the model already runs under this session's identity` };
|
|
151870
152298
|
}
|
|
151871
|
-
const transcript =
|
|
152299
|
+
const transcript = import_node_path69.default.join(paths.identitiesDir, request7.to, "projects", projectDirNameOf(deps.cwd), `${request7.sessionId}.jsonl`);
|
|
151872
152300
|
if (farmFs.lstat(transcript)?.kind !== "file") {
|
|
151873
152301
|
return { kind: "stay", reason: `${request7.to} does not share this conversation's history, so it could not resume it` };
|
|
151874
152302
|
}
|
|
@@ -152446,7 +152874,7 @@ async function runClaude(argvOverride) {
|
|
|
152446
152874
|
// src/cli.ts
|
|
152447
152875
|
async function main() {
|
|
152448
152876
|
aliasLegacyEnv(process.env);
|
|
152449
|
-
const invokedName =
|
|
152877
|
+
const invokedName = import_node_path70.default.basename(process.argv[1] ?? "agent-shim");
|
|
152450
152878
|
if (isInvokedAsClaude(invokedName)) {
|
|
152451
152879
|
await runClaude();
|
|
152452
152880
|
return;
|