claude-use 11.56.1 → 11.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1012 -512
- package/dist/index.cjs +66 -31
- package/dist/index.mjs +65 -28
- package/dist/types/index.d.ts +226 -3
- 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)) {
|
|
@@ -24807,6 +24807,24 @@ var init_processRole = __esm({
|
|
|
24807
24807
|
}
|
|
24808
24808
|
});
|
|
24809
24809
|
|
|
24810
|
+
// src/blockingSpawn.ts
|
|
24811
|
+
function spawnSyncBlocking(operation, command, args, options) {
|
|
24812
|
+
refuseToBlockInRole(operation);
|
|
24813
|
+
return (0, import_node_child_process2.spawnSync)(command, args, options ?? {});
|
|
24814
|
+
}
|
|
24815
|
+
function execFileSyncBlocking(operation, file2, args, options) {
|
|
24816
|
+
refuseToBlockInRole(operation);
|
|
24817
|
+
return (0, import_node_child_process2.execFileSync)(file2, args, options ?? {});
|
|
24818
|
+
}
|
|
24819
|
+
var import_node_child_process2;
|
|
24820
|
+
var init_blockingSpawn = __esm({
|
|
24821
|
+
"src/blockingSpawn.ts"() {
|
|
24822
|
+
"use strict";
|
|
24823
|
+
import_node_child_process2 = require("node:child_process");
|
|
24824
|
+
init_processRole();
|
|
24825
|
+
}
|
|
24826
|
+
});
|
|
24827
|
+
|
|
24810
24828
|
// src/versionDiscovery.ts
|
|
24811
24829
|
function defaultVersionsDir() {
|
|
24812
24830
|
return import_node_path3.default.join(import_node_os.default.homedir(), ".local", "share", "claude", "versions");
|
|
@@ -25363,8 +25381,8 @@ var init_statusline = __esm({
|
|
|
25363
25381
|
init_zod();
|
|
25364
25382
|
init_blank();
|
|
25365
25383
|
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"];
|
|
25384
|
+
STATUSLINE_HEADER_SEGMENTS = ["model", "provider", "route", "account", "identity", "headroom", "project", "vcs", "effort", "advisor", "version", "outputStyle", "cost", "dailyCost"];
|
|
25385
|
+
STATUSLINE_ROWS = ["context", "quota", "addedDirs", "gitFiles", "memory", "environment"];
|
|
25368
25386
|
STATUSLINE_COLOUR_NAMES = [
|
|
25369
25387
|
"default",
|
|
25370
25388
|
"dim",
|
|
@@ -25455,6 +25473,12 @@ var init_statusline = __esm({
|
|
|
25455
25473
|
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
25474
|
seconds: external_exports.boolean().describe("Whether a wall-clock time includes seconds (`14:30:07`).")
|
|
25457
25475
|
},
|
|
25476
|
+
cost: {
|
|
25477
|
+
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.")
|
|
25478
|
+
},
|
|
25479
|
+
environment: {
|
|
25480
|
+
threshold: external_exports.number().int().min(0).describe("The fewest configuration items in total (CLAUDE.md files, rules, MCP servers and hook events) that must exist for the environment row to draw its counts.")
|
|
25481
|
+
},
|
|
25458
25482
|
colours: {
|
|
25459
25483
|
context: colourValue.describe("The colour of the context bar and its figures below the warning threshold."),
|
|
25460
25484
|
usage: colourValue.describe("The colour of the quota bars and their figures below the warning threshold."),
|
|
@@ -25499,6 +25523,8 @@ var init_statusline = __esm({
|
|
|
25499
25523
|
bar: external_exports.strictObject(SHAPES.bar).partial().optional(),
|
|
25500
25524
|
usage: external_exports.strictObject(SHAPES.usage).partial().optional(),
|
|
25501
25525
|
clock: external_exports.strictObject(SHAPES.clock).partial().optional(),
|
|
25526
|
+
cost: external_exports.strictObject(SHAPES.cost).partial().optional(),
|
|
25527
|
+
environment: external_exports.strictObject(SHAPES.environment).partial().optional(),
|
|
25502
25528
|
colours: external_exports.strictObject(SHAPES.colours).partial().optional(),
|
|
25503
25529
|
project: external_exports.strictObject(SHAPES.project).partial().optional(),
|
|
25504
25530
|
git: external_exports.strictObject(SHAPES.git).partial().optional(),
|
|
@@ -25516,6 +25542,8 @@ var init_statusline = __esm({
|
|
|
25516
25542
|
bar: external_exports.strictObject(SHAPES.bar),
|
|
25517
25543
|
usage: external_exports.strictObject(SHAPES.usage),
|
|
25518
25544
|
clock: external_exports.strictObject(SHAPES.clock),
|
|
25545
|
+
cost: external_exports.strictObject(SHAPES.cost),
|
|
25546
|
+
environment: external_exports.strictObject(SHAPES.environment),
|
|
25519
25547
|
colours: external_exports.strictObject(SHAPES.colours),
|
|
25520
25548
|
project: external_exports.strictObject(SHAPES.project),
|
|
25521
25549
|
git: external_exports.strictObject(SHAPES.git),
|
|
@@ -25533,6 +25561,8 @@ var init_statusline = __esm({
|
|
|
25533
25561
|
bar: { width: 10, filled: "\u2588", empty: "\u2591" },
|
|
25534
25562
|
usage: { value: "used", bar: true, compact: false, resetLabel: false, modelScoped: false, timeFormat: "relative", threshold: 0, sevenDayThreshold: 0 },
|
|
25535
25563
|
clock: { hourCycle: "auto", seconds: false },
|
|
25564
|
+
cost: { routed: false },
|
|
25565
|
+
environment: { threshold: 0 },
|
|
25536
25566
|
colours: {
|
|
25537
25567
|
context: "green",
|
|
25538
25568
|
usage: "green",
|
|
@@ -29447,16 +29477,14 @@ function realIsProcessAlive(pid) {
|
|
|
29447
29477
|
}
|
|
29448
29478
|
}
|
|
29449
29479
|
function realIsProcessZombie(pid) {
|
|
29450
|
-
|
|
29451
|
-
const result = (0, import_node_child_process2.spawnSync)("ps", ["-o", "stat=", "-p", String(pid)], { encoding: "utf8" });
|
|
29480
|
+
const result = spawnSyncBlocking("a process-table read", "ps", ["-o", "stat=", "-p", String(pid)], { encoding: "utf8" });
|
|
29452
29481
|
return result.status === 0 && result.stdout.trim().startsWith("Z");
|
|
29453
29482
|
}
|
|
29454
29483
|
function realIsProcessRunning(pid) {
|
|
29455
29484
|
return realIsProcessAlive(pid) && !realIsProcessZombie(pid);
|
|
29456
29485
|
}
|
|
29457
29486
|
function realIsFrontDoorSupervisor(pid) {
|
|
29458
|
-
|
|
29459
|
-
const result = (0, import_node_child_process2.spawnSync)("ps", ["-o", "pid=,command=", "-p", String(pid)], { encoding: "utf8" });
|
|
29487
|
+
const result = spawnSyncBlocking("a process-table read", "ps", ["-o", "pid=,command=", "-p", String(pid)], { encoding: "utf8" });
|
|
29460
29488
|
return result.status === 0 && parseFrontDoorSupervisorPids(result.stdout).includes(pid);
|
|
29461
29489
|
}
|
|
29462
29490
|
function leadingContinuationBytes(bytes) {
|
|
@@ -29504,20 +29532,18 @@ function realReadFileTail(filePath, fromByte, maxBytes) {
|
|
|
29504
29532
|
}
|
|
29505
29533
|
}
|
|
29506
29534
|
function realProcessCommandLine(pid) {
|
|
29507
|
-
|
|
29508
|
-
const result = (0, import_node_child_process2.spawnSync)("ps", ["-o", "command=", "-p", String(pid)], { encoding: "utf8", timeout: PS_TIMEOUT_MS });
|
|
29535
|
+
const result = spawnSyncBlocking("a process-table read", "ps", ["-o", "command=", "-p", String(pid)], { encoding: "utf8", timeout: PS_TIMEOUT_MS });
|
|
29509
29536
|
return result.status === 0 ? result.stdout.trim() : void 0;
|
|
29510
29537
|
}
|
|
29511
29538
|
function realFrontDoorLiveness(pids) {
|
|
29512
|
-
refuseToBlockInRole("a synchronous process-table read");
|
|
29513
29539
|
return frontDoorLivenessOf(pids, (asked) => {
|
|
29514
|
-
const result = (
|
|
29540
|
+
const result = spawnSyncBlocking("a process-table read", "ps", ["-o", "pid=,stat=,command=", "-p", asked.map(String).join(",")], { encoding: "utf8", timeout: PS_TIMEOUT_MS });
|
|
29515
29541
|
return { status: result.status, stdout: result.stdout, stderr: result.stderr, ...result.error === void 0 ? {} : { error: result.error } };
|
|
29516
29542
|
});
|
|
29517
29543
|
}
|
|
29518
29544
|
async function readProcessStates(pids) {
|
|
29519
29545
|
return await new Promise((resolve2) => {
|
|
29520
|
-
(0,
|
|
29546
|
+
(0, import_node_child_process3.execFile)("ps", ["-o", "pid=,stat=", "-p", pids.map(String).join(",")], { encoding: "utf8", timeout: PS_TIMEOUT_MS }, (_error, stdout2) => {
|
|
29521
29547
|
const states = /* @__PURE__ */ new Map();
|
|
29522
29548
|
for (const line of stdout2.split("\n")) {
|
|
29523
29549
|
const [pidText, stat] = line.trim().split(/\s+/);
|
|
@@ -29537,12 +29563,19 @@ async function realRunningAmong(pids) {
|
|
|
29537
29563
|
const states = await readProcessStates(existing);
|
|
29538
29564
|
return new Set(existing.filter((pid) => states.get(pid)?.startsWith("Z") !== true));
|
|
29539
29565
|
}
|
|
29566
|
+
async function realRunAsync(command, args) {
|
|
29567
|
+
return await new Promise((resolve2) => {
|
|
29568
|
+
(0, import_node_child_process3.execFile)(command, [...args], { encoding: "utf8", timeout: PS_TIMEOUT_MS }, (error63, stdout2, stderr) => {
|
|
29569
|
+
resolve2({ status: error63 === null ? 0 : typeof error63.code === "number" ? error63.code : null, stdout: stdout2, stderr });
|
|
29570
|
+
});
|
|
29571
|
+
});
|
|
29572
|
+
}
|
|
29540
29573
|
function expandHome(filePath) {
|
|
29541
29574
|
return filePath.startsWith("~/") ? import_node_path9.default.join(import_node_os2.default.homedir(), filePath.slice(1)) : filePath;
|
|
29542
29575
|
}
|
|
29543
29576
|
function hasDesktopSession() {
|
|
29544
29577
|
if (process.platform === "darwin") {
|
|
29545
|
-
const result = (
|
|
29578
|
+
const result = spawnSyncBlocking("a desktop-session check", "launchctl", ["managername"], { encoding: "utf8" });
|
|
29546
29579
|
return result.status === 0 && result.stdout.trim() === MACOS_GUI_SESSION_MANAGER;
|
|
29547
29580
|
}
|
|
29548
29581
|
return hasDisplayServer();
|
|
@@ -29558,7 +29591,7 @@ async function hasDesktopSessionAsync() {
|
|
|
29558
29591
|
return hasDisplayServer();
|
|
29559
29592
|
}
|
|
29560
29593
|
return await new Promise((resolve2) => {
|
|
29561
|
-
(0,
|
|
29594
|
+
(0, import_node_child_process3.execFile)("launchctl", ["managername"], { encoding: "utf8" }, (error63, stdout2) => {
|
|
29562
29595
|
resolve2(error63 === null && stdout2.trim() === MACOS_GUI_SESSION_MANAGER);
|
|
29563
29596
|
});
|
|
29564
29597
|
});
|
|
@@ -29566,7 +29599,7 @@ async function hasDesktopSessionAsync() {
|
|
|
29566
29599
|
async function runCredentialCommand(argv, options) {
|
|
29567
29600
|
const [command, ...args] = argv;
|
|
29568
29601
|
return await new Promise((resolve2) => {
|
|
29569
|
-
const child = (0,
|
|
29602
|
+
const child = (0, import_node_child_process3.spawn)(command, args, { stdio: options.interactive ? ["inherit", "pipe", "inherit"] : ["ignore", "pipe", "pipe"] });
|
|
29570
29603
|
let stdout2 = "";
|
|
29571
29604
|
let stderr = "";
|
|
29572
29605
|
let timedOut = false;
|
|
@@ -29625,7 +29658,7 @@ function selfInvocation(args) {
|
|
|
29625
29658
|
}
|
|
29626
29659
|
function spawnSelfDetached(paths, args) {
|
|
29627
29660
|
const invocation = selfInvocation(args);
|
|
29628
|
-
const child = (0,
|
|
29661
|
+
const child = (0, import_node_child_process3.spawn)(invocation.command, [...invocation.args], { detached: true, stdio: "ignore", env: { ...process.env, AGENT_SHIM_HOME: paths.root } });
|
|
29629
29662
|
child.unref();
|
|
29630
29663
|
}
|
|
29631
29664
|
function detachedDaemonSpawnOptions(logFd, env) {
|
|
@@ -29644,7 +29677,7 @@ function spawnDetachedDaemon(invocation, paths, subcommand, logPath) {
|
|
|
29644
29677
|
import_node_fs3.default.mkdirSync(import_node_path9.default.dirname(logPath), { recursive: true });
|
|
29645
29678
|
const logFd = import_node_fs3.default.openSync(logPath, "a");
|
|
29646
29679
|
try {
|
|
29647
|
-
const child = (0,
|
|
29680
|
+
const child = (0, import_node_child_process3.spawn)(invocation.command, invocation.args, detachedDaemonSpawnOptions(logFd, { ...process.env, AGENT_SHIM_HOME: paths.root }));
|
|
29648
29681
|
child.unref();
|
|
29649
29682
|
if (child.pid === void 0) {
|
|
29650
29683
|
throw new Error(`spawning ${subcommand} returned no pid`);
|
|
@@ -29794,12 +29827,13 @@ function realResolveClaudeBinary(isOwnBinary) {
|
|
|
29794
29827
|
function realInstalledClaudeVersions() {
|
|
29795
29828
|
return installedVersions(listVersionsDir(defaultVersionsDir()));
|
|
29796
29829
|
}
|
|
29797
|
-
var
|
|
29830
|
+
var import_node_child_process3, import_node_crypto4, import_node_fs3, import_node_os2, import_node_path9, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS, realFarmFs, INT32_BYTE_LENGTH, KEY_POLL_MS, CTRL_C_BYTE, realHoldPort, LINE_FEED, UTF8_CONTINUATION_MASK, UTF8_CONTINUATION_BITS, PS_TIMEOUT_MS, realRunPort, MACOS_GUI_SESSION_MANAGER, realCredentialPort, realAsyncCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, realLogPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
|
|
29798
29831
|
var init_realPorts = __esm({
|
|
29799
29832
|
"src/realPorts.ts"() {
|
|
29800
29833
|
"use strict";
|
|
29834
|
+
init_blockingSpawn();
|
|
29801
29835
|
init_processRole();
|
|
29802
|
-
|
|
29836
|
+
import_node_child_process3 = require("node:child_process");
|
|
29803
29837
|
import_node_crypto4 = require("node:crypto");
|
|
29804
29838
|
import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
29805
29839
|
import_node_os2 = __toESM(require("node:os"), 1);
|
|
@@ -29974,7 +30008,7 @@ var init_realPorts = __esm({
|
|
|
29974
30008
|
PS_TIMEOUT_MS = 2e3;
|
|
29975
30009
|
realRunPort = {
|
|
29976
30010
|
run(command, args) {
|
|
29977
|
-
const result = (
|
|
30011
|
+
const result = spawnSyncBlocking("an external command", command, args, { encoding: "utf8" });
|
|
29978
30012
|
return { status: result.status, stdout: result.stdout, stderr: result.stderr };
|
|
29979
30013
|
}
|
|
29980
30014
|
};
|
|
@@ -29997,7 +30031,7 @@ var init_realPorts = __esm({
|
|
|
29997
30031
|
},
|
|
29998
30032
|
runCommand(argv, options) {
|
|
29999
30033
|
const [command, ...args] = argv;
|
|
30000
|
-
const result = (
|
|
30034
|
+
const result = spawnSyncBlocking("a credential command", command, args, {
|
|
30001
30035
|
encoding: "utf8",
|
|
30002
30036
|
timeout: options.timeoutMs,
|
|
30003
30037
|
stdio: options.interactive ? ["inherit", "pipe", "inherit"] : ["ignore", "pipe", "pipe"]
|
|
@@ -30041,7 +30075,7 @@ var init_realPorts = __esm({
|
|
|
30041
30075
|
};
|
|
30042
30076
|
realSpawnPort = {
|
|
30043
30077
|
spawnSync(command, args, options) {
|
|
30044
|
-
const result = (
|
|
30078
|
+
const result = spawnSyncBlocking("a spawned program", command, args, options);
|
|
30045
30079
|
return { status: result.status, signal: result.signal, ...result.error === void 0 ? {} : { error: result.error } };
|
|
30046
30080
|
}
|
|
30047
30081
|
};
|
|
@@ -30638,8 +30672,8 @@ var require_utils = __commonJS({
|
|
|
30638
30672
|
}
|
|
30639
30673
|
return output2;
|
|
30640
30674
|
};
|
|
30641
|
-
exports2.basename = (
|
|
30642
|
-
const segs =
|
|
30675
|
+
exports2.basename = (path71, { windows } = {}) => {
|
|
30676
|
+
const segs = path71.split(windows ? /[\\/]/ : "/");
|
|
30643
30677
|
const last = segs[segs.length - 1];
|
|
30644
30678
|
if (last === "") {
|
|
30645
30679
|
return segs[segs.length - 2];
|
|
@@ -30721,16 +30755,16 @@ var require_scan = __commonJS({
|
|
|
30721
30755
|
let token = { value: "", depth: 0, isGlob: false };
|
|
30722
30756
|
const eos = () => index >= length;
|
|
30723
30757
|
const peek = () => str.charCodeAt(index + 1);
|
|
30724
|
-
const
|
|
30758
|
+
const advance2 = () => {
|
|
30725
30759
|
prev = code;
|
|
30726
30760
|
return str.charCodeAt(++index);
|
|
30727
30761
|
};
|
|
30728
30762
|
while (index < length) {
|
|
30729
|
-
code =
|
|
30763
|
+
code = advance2();
|
|
30730
30764
|
let next;
|
|
30731
30765
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30732
30766
|
backslashes = token.backslashes = true;
|
|
30733
|
-
code =
|
|
30767
|
+
code = advance2();
|
|
30734
30768
|
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
30735
30769
|
braceEscaped = true;
|
|
30736
30770
|
}
|
|
@@ -30738,17 +30772,17 @@ var require_scan = __commonJS({
|
|
|
30738
30772
|
}
|
|
30739
30773
|
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
30740
30774
|
braces++;
|
|
30741
|
-
while (eos() !== true && (code =
|
|
30775
|
+
while (eos() !== true && (code = advance2())) {
|
|
30742
30776
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30743
30777
|
backslashes = token.backslashes = true;
|
|
30744
|
-
|
|
30778
|
+
advance2();
|
|
30745
30779
|
continue;
|
|
30746
30780
|
}
|
|
30747
30781
|
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
30748
30782
|
braces++;
|
|
30749
30783
|
continue;
|
|
30750
30784
|
}
|
|
30751
|
-
if (braceEscaped !== true && code === CHAR_DOT && (code =
|
|
30785
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance2()) === CHAR_DOT) {
|
|
30752
30786
|
isBrace = token.isBrace = true;
|
|
30753
30787
|
isGlob = token.isGlob = true;
|
|
30754
30788
|
finished = true;
|
|
@@ -30804,10 +30838,10 @@ var require_scan = __commonJS({
|
|
|
30804
30838
|
}
|
|
30805
30839
|
if (scanToEnd === true) {
|
|
30806
30840
|
let parens = 0;
|
|
30807
|
-
while (eos() !== true && (code =
|
|
30841
|
+
while (eos() !== true && (code = advance2())) {
|
|
30808
30842
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30809
30843
|
backslashes = token.backslashes = true;
|
|
30810
|
-
|
|
30844
|
+
advance2();
|
|
30811
30845
|
continue;
|
|
30812
30846
|
}
|
|
30813
30847
|
if (code === CHAR_LEFT_PARENTHESES) {
|
|
@@ -30842,10 +30876,10 @@ var require_scan = __commonJS({
|
|
|
30842
30876
|
break;
|
|
30843
30877
|
}
|
|
30844
30878
|
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
30845
|
-
while (eos() !== true && (next =
|
|
30879
|
+
while (eos() !== true && (next = advance2())) {
|
|
30846
30880
|
if (next === CHAR_BACKWARD_SLASH) {
|
|
30847
30881
|
backslashes = token.backslashes = true;
|
|
30848
|
-
|
|
30882
|
+
advance2();
|
|
30849
30883
|
continue;
|
|
30850
30884
|
}
|
|
30851
30885
|
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
@@ -30869,10 +30903,10 @@ var require_scan = __commonJS({
|
|
|
30869
30903
|
isGlob = token.isGlob = true;
|
|
30870
30904
|
if (scanToEnd === true) {
|
|
30871
30905
|
let parens = 1;
|
|
30872
|
-
while (eos() !== true && (code =
|
|
30906
|
+
while (eos() !== true && (code = advance2())) {
|
|
30873
30907
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
30874
30908
|
backslashes = token.backslashes = true;
|
|
30875
|
-
|
|
30909
|
+
advance2();
|
|
30876
30910
|
continue;
|
|
30877
30911
|
}
|
|
30878
30912
|
if (code === CHAR_LEFT_PARENTHESES) {
|
|
@@ -31308,7 +31342,7 @@ var require_parse = __commonJS({
|
|
|
31308
31342
|
let value2;
|
|
31309
31343
|
const eos = () => state.index === len - 1;
|
|
31310
31344
|
const peek = state.peek = (n10 = 1) => input2[state.index + n10];
|
|
31311
|
-
const
|
|
31345
|
+
const advance2 = state.advance = () => input2[++state.index] || "";
|
|
31312
31346
|
const remaining = () => input2.slice(state.index + 1);
|
|
31313
31347
|
const consume = (value3 = "", num = 0) => {
|
|
31314
31348
|
state.consumed += value3;
|
|
@@ -31321,7 +31355,7 @@ var require_parse = __commonJS({
|
|
|
31321
31355
|
const negate = () => {
|
|
31322
31356
|
let count = 1;
|
|
31323
31357
|
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
31324
|
-
|
|
31358
|
+
advance2();
|
|
31325
31359
|
state.start++;
|
|
31326
31360
|
count++;
|
|
31327
31361
|
}
|
|
@@ -31375,7 +31409,7 @@ var require_parse = __commonJS({
|
|
|
31375
31409
|
const output2 = (opts.capture ? "(" : "") + token.open;
|
|
31376
31410
|
increment("parens");
|
|
31377
31411
|
push({ type: type2, value: value3, output: state.output ? "" : ONE_CHAR });
|
|
31378
|
-
push({ type: "paren", extglob: true, value:
|
|
31412
|
+
push({ type: "paren", extglob: true, value: advance2(), output: output2 });
|
|
31379
31413
|
extglobs.push(token);
|
|
31380
31414
|
};
|
|
31381
31415
|
const extglobClose = (token) => {
|
|
@@ -31464,7 +31498,7 @@ var require_parse = __commonJS({
|
|
|
31464
31498
|
return state;
|
|
31465
31499
|
}
|
|
31466
31500
|
while (!eos()) {
|
|
31467
|
-
value2 =
|
|
31501
|
+
value2 = advance2();
|
|
31468
31502
|
if (value2 === "\0") {
|
|
31469
31503
|
continue;
|
|
31470
31504
|
}
|
|
@@ -31491,9 +31525,9 @@ var require_parse = __commonJS({
|
|
|
31491
31525
|
}
|
|
31492
31526
|
}
|
|
31493
31527
|
if (opts.unescape === true) {
|
|
31494
|
-
value2 =
|
|
31528
|
+
value2 = advance2();
|
|
31495
31529
|
} else {
|
|
31496
|
-
value2 +=
|
|
31530
|
+
value2 += advance2();
|
|
31497
31531
|
}
|
|
31498
31532
|
if (state.brackets === 0) {
|
|
31499
31533
|
push({ type: "text", value: value2 });
|
|
@@ -31513,7 +31547,7 @@ var require_parse = __commonJS({
|
|
|
31513
31547
|
if (posix) {
|
|
31514
31548
|
prev.value = pre2 + posix;
|
|
31515
31549
|
state.backtrack = true;
|
|
31516
|
-
|
|
31550
|
+
advance2();
|
|
31517
31551
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
31518
31552
|
bos.output = ONE_CHAR;
|
|
31519
31553
|
}
|
|
@@ -31849,7 +31883,7 @@ var require_parse = __commonJS({
|
|
|
31849
31883
|
prev.value += value2;
|
|
31850
31884
|
state.output += prior.output + prev.output;
|
|
31851
31885
|
state.globstar = true;
|
|
31852
|
-
consume(value2 +
|
|
31886
|
+
consume(value2 + advance2());
|
|
31853
31887
|
push({ type: "slash", value: "/", output: "" });
|
|
31854
31888
|
continue;
|
|
31855
31889
|
}
|
|
@@ -31859,7 +31893,7 @@ var require_parse = __commonJS({
|
|
|
31859
31893
|
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
31860
31894
|
state.output = prev.output;
|
|
31861
31895
|
state.globstar = true;
|
|
31862
|
-
consume(value2 +
|
|
31896
|
+
consume(value2 + advance2());
|
|
31863
31897
|
push({ type: "slash", value: "/", output: "" });
|
|
31864
31898
|
continue;
|
|
31865
31899
|
}
|
|
@@ -32404,9 +32438,9 @@ var init_identity = __esm({
|
|
|
32404
32438
|
});
|
|
32405
32439
|
|
|
32406
32440
|
// src/statusline/keys.ts
|
|
32407
|
-
function valueAt(source,
|
|
32441
|
+
function valueAt(source, path71) {
|
|
32408
32442
|
let current = source;
|
|
32409
|
-
for (const part of
|
|
32443
|
+
for (const part of path71) {
|
|
32410
32444
|
if (!isPlainObject2(current)) {
|
|
32411
32445
|
return void 0;
|
|
32412
32446
|
}
|
|
@@ -32414,8 +32448,8 @@ function valueAt(source, path68) {
|
|
|
32414
32448
|
}
|
|
32415
32449
|
return current;
|
|
32416
32450
|
}
|
|
32417
|
-
function keyOf(
|
|
32418
|
-
const common = { path:
|
|
32451
|
+
function keyOf(path71, leaf) {
|
|
32452
|
+
const common = { path: path71.join("."), description: leaf.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path71) };
|
|
32419
32453
|
if (leaf instanceof external_exports.ZodNumber) {
|
|
32420
32454
|
return { ...common, kind: "integer", choices: [] };
|
|
32421
32455
|
}
|
|
@@ -32434,7 +32468,7 @@ function keyOf(path68, leaf) {
|
|
|
32434
32468
|
if (leaf instanceof external_exports.ZodArray && leaf.element instanceof external_exports.ZodEnum) {
|
|
32435
32469
|
return { ...common, kind: "list", choices: Object.values(leaf.element.enum).map(String) };
|
|
32436
32470
|
}
|
|
32437
|
-
throw new TypeError(`statusline setting ${
|
|
32471
|
+
throw new TypeError(`statusline setting ${path71.join(".")} has a kind the key listing does not describe`);
|
|
32438
32472
|
}
|
|
32439
32473
|
function walk(shape, prefix) {
|
|
32440
32474
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof external_exports.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -32458,10 +32492,10 @@ var init_keys = __esm({
|
|
|
32458
32492
|
});
|
|
32459
32493
|
|
|
32460
32494
|
// src/statusline/change.ts
|
|
32461
|
-
function keyNamed(
|
|
32462
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
32495
|
+
function keyNamed(path71) {
|
|
32496
|
+
const found = statuslineKeys().find((key) => key.path === path71);
|
|
32463
32497
|
if (found === void 0) {
|
|
32464
|
-
throw new UsageError(`"${
|
|
32498
|
+
throw new UsageError(`"${path71}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
32465
32499
|
}
|
|
32466
32500
|
return found;
|
|
32467
32501
|
}
|
|
@@ -32470,35 +32504,35 @@ function parseStatuslineAssignment(text4) {
|
|
|
32470
32504
|
if (split < 1) {
|
|
32471
32505
|
throw new UsageError(`"${text4}" is not <setting>=<value>.`);
|
|
32472
32506
|
}
|
|
32473
|
-
const
|
|
32507
|
+
const path71 = text4.slice(0, split);
|
|
32474
32508
|
const raw = text4.slice(split + 1);
|
|
32475
|
-
const key = keyNamed(
|
|
32509
|
+
const key = keyNamed(path71);
|
|
32476
32510
|
switch (key.kind) {
|
|
32477
32511
|
case "integer": {
|
|
32478
32512
|
const number5 = Number(raw);
|
|
32479
32513
|
if (raw.trim() === "" || !Number.isFinite(number5)) {
|
|
32480
|
-
throw new UsageError(`${
|
|
32514
|
+
throw new UsageError(`${path71}: "${raw}" is not a number.`);
|
|
32481
32515
|
}
|
|
32482
|
-
return { path:
|
|
32516
|
+
return { path: path71, value: number5 };
|
|
32483
32517
|
}
|
|
32484
32518
|
case "boolean":
|
|
32485
32519
|
if (raw !== "true" && raw !== "false") {
|
|
32486
|
-
throw new UsageError(`${
|
|
32520
|
+
throw new UsageError(`${path71}: "${raw}" is not true or false.`);
|
|
32487
32521
|
}
|
|
32488
|
-
return { path:
|
|
32522
|
+
return { path: path71, value: raw === "true" };
|
|
32489
32523
|
case "text":
|
|
32490
32524
|
case "choice":
|
|
32491
|
-
return { path:
|
|
32525
|
+
return { path: path71, value: raw };
|
|
32492
32526
|
case "colour":
|
|
32493
|
-
return { path:
|
|
32527
|
+
return { path: path71, value: /^\d+$/.test(raw) ? Number(raw) : raw };
|
|
32494
32528
|
case "list":
|
|
32495
|
-
return { path:
|
|
32529
|
+
return { path: path71, value: raw === "" ? [] : raw.split(",") };
|
|
32496
32530
|
default:
|
|
32497
32531
|
return key.kind;
|
|
32498
32532
|
}
|
|
32499
32533
|
}
|
|
32500
|
-
function setAt(target,
|
|
32501
|
-
const [head, ...rest] =
|
|
32534
|
+
function setAt(target, path71, value2) {
|
|
32535
|
+
const [head, ...rest] = path71;
|
|
32502
32536
|
if (head === void 0) {
|
|
32503
32537
|
return;
|
|
32504
32538
|
}
|
|
@@ -32511,8 +32545,8 @@ function setAt(target, path68, value2) {
|
|
|
32511
32545
|
target[head] = next;
|
|
32512
32546
|
setAt(next, rest, value2);
|
|
32513
32547
|
}
|
|
32514
|
-
function removeAt(target,
|
|
32515
|
-
const [head, ...rest] =
|
|
32548
|
+
function removeAt(target, path71) {
|
|
32549
|
+
const [head, ...rest] = path71;
|
|
32516
32550
|
if (head === void 0) {
|
|
32517
32551
|
return;
|
|
32518
32552
|
}
|
|
@@ -32530,13 +32564,13 @@ function removeAt(target, path68) {
|
|
|
32530
32564
|
}
|
|
32531
32565
|
function applyStatuslineChange(existing, change) {
|
|
32532
32566
|
const draft = structuredClone(existing ?? {});
|
|
32533
|
-
for (const [
|
|
32534
|
-
keyNamed(
|
|
32535
|
-
setAt(draft,
|
|
32567
|
+
for (const [path71, value2] of Object.entries(change.set ?? {})) {
|
|
32568
|
+
keyNamed(path71);
|
|
32569
|
+
setAt(draft, path71.split("."), value2);
|
|
32536
32570
|
}
|
|
32537
|
-
for (const
|
|
32538
|
-
keyNamed(
|
|
32539
|
-
removeAt(draft,
|
|
32571
|
+
for (const path71 of change.unset ?? []) {
|
|
32572
|
+
keyNamed(path71);
|
|
32573
|
+
removeAt(draft, path71.split("."));
|
|
32540
32574
|
}
|
|
32541
32575
|
const result = StatuslineSchema.safeParse(draft);
|
|
32542
32576
|
if (!result.success) {
|
|
@@ -34773,6 +34807,7 @@ function buildLayoutPaths(root) {
|
|
|
34773
34807
|
usageDir: import_node_path20.default.join(root, "usage"),
|
|
34774
34808
|
usageLogDir: import_node_path20.default.join(root, "usage", "log"),
|
|
34775
34809
|
usageSnapshotsDir: import_node_path20.default.join(root, "usage", "snapshots"),
|
|
34810
|
+
statuslineDir: import_node_path20.default.join(root, "statusline"),
|
|
34776
34811
|
catalogueDir: import_node_path20.default.join(root, "catalogues"),
|
|
34777
34812
|
usagePicksFile: import_node_path20.default.join(root, "usage", "picks.json"),
|
|
34778
34813
|
usageAnchorsFile: import_node_path20.default.join(root, "usage", "anchors.json"),
|
|
@@ -34843,7 +34878,7 @@ function isRateLimitHeader(name) {
|
|
|
34843
34878
|
const lower = name.toLowerCase();
|
|
34844
34879
|
return lower === "retry-after" || lower.startsWith("anthropic-ratelimit-") || lower.startsWith("x-ratelimit-") || lower.startsWith("ratelimit") || lower.startsWith("x-codex-");
|
|
34845
34880
|
}
|
|
34846
|
-
var USAGE_SCHEMA_VERSION, VersionSchema, InstantSchema, TokenCountSchema, TokenUsageSchema, LIMIT_KINDS, LimitClassificationSchema, UsageRecordSchema, QuotaWindowSchema, ExtraUsageSpendSchema, UnifiedRateLimitSchema, RateLimitStateSchema, LimitEventSchema, ProviderQuotaWindowSchema, ProviderAccountSchema, ProviderQuotaSchema, ProviderUsageStateSchema, AccountMetadataSchema, UsageSnapshotSchema;
|
|
34881
|
+
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
34882
|
var init_schema2 = __esm({
|
|
34848
34883
|
"src/usage/schema.ts"() {
|
|
34849
34884
|
"use strict";
|
|
@@ -34851,6 +34886,7 @@ var init_schema2 = __esm({
|
|
|
34851
34886
|
USAGE_SCHEMA_VERSION = 1;
|
|
34852
34887
|
VersionSchema = external_exports.literal(USAGE_SCHEMA_VERSION);
|
|
34853
34888
|
InstantSchema = external_exports.iso.datetime();
|
|
34889
|
+
CLIENT_SESSION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
34854
34890
|
TokenCountSchema = external_exports.number().int().nonnegative();
|
|
34855
34891
|
TokenUsageSchema = external_exports.strictObject({
|
|
34856
34892
|
inputTokens: TokenCountSchema.optional(),
|
|
@@ -34880,6 +34916,8 @@ var init_schema2 = __esm({
|
|
|
34880
34916
|
provider: external_exports.string(),
|
|
34881
34917
|
/** The launch's session id, generated per launch. */
|
|
34882
34918
|
sessionId: external_exports.string().optional(),
|
|
34919
|
+
/** 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. */
|
|
34920
|
+
clientSessionId: external_exports.string().regex(CLIENT_SESSION_ID_PATTERN).optional(),
|
|
34883
34921
|
/** The project the launch ran in (its git repository root), when the launch sent one: headroom launches do. */
|
|
34884
34922
|
project: external_exports.string().optional(),
|
|
34885
34923
|
/** 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 +36047,11 @@ function identifyRequest(headers) {
|
|
|
36009
36047
|
function directOrigin2(port) {
|
|
36010
36048
|
return `http://127.0.0.1:${String(port)}`;
|
|
36011
36049
|
}
|
|
36012
|
-
function parseProviderPath(
|
|
36013
|
-
if (!
|
|
36050
|
+
function parseProviderPath(path71) {
|
|
36051
|
+
if (!path71.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
36014
36052
|
return void 0;
|
|
36015
36053
|
}
|
|
36016
|
-
const tail =
|
|
36054
|
+
const tail = path71.slice(PROVIDER_PATH_PREFIX.length);
|
|
36017
36055
|
const slash = tail.indexOf("/");
|
|
36018
36056
|
if (slash <= 0) {
|
|
36019
36057
|
return void 0;
|
|
@@ -36287,8 +36325,8 @@ function parseConnectTarget(authority) {
|
|
|
36287
36325
|
}
|
|
36288
36326
|
return { host, port };
|
|
36289
36327
|
}
|
|
36290
|
-
function servedByPipeline(
|
|
36291
|
-
return
|
|
36328
|
+
function servedByPipeline(path71) {
|
|
36329
|
+
return path71?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
36292
36330
|
}
|
|
36293
36331
|
function forwardableHeaders(headers) {
|
|
36294
36332
|
const connectionTokens = new Set(
|
|
@@ -36766,7 +36804,7 @@ var init_package = __esm({
|
|
|
36766
36804
|
"package.json"() {
|
|
36767
36805
|
package_default = {
|
|
36768
36806
|
name: "claude-use",
|
|
36769
|
-
version: "11.
|
|
36807
|
+
version: "11.57.1",
|
|
36770
36808
|
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
36809
|
license: "MIT",
|
|
36772
36810
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -37289,12 +37327,12 @@ function decoderFor(encoding) {
|
|
|
37289
37327
|
return void 0;
|
|
37290
37328
|
}
|
|
37291
37329
|
}
|
|
37292
|
-
function destinationOf(
|
|
37293
|
-
const scoped = parseProviderPath(
|
|
37330
|
+
function destinationOf(path71, sessionProvider) {
|
|
37331
|
+
const scoped = parseProviderPath(path71);
|
|
37294
37332
|
if (scoped !== void 0) {
|
|
37295
37333
|
return { provider: scoped.provider, endpoint: scoped.rest };
|
|
37296
37334
|
}
|
|
37297
|
-
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint:
|
|
37335
|
+
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint: path71 };
|
|
37298
37336
|
}
|
|
37299
37337
|
function modelChoiceOf(event, servedModel, provider) {
|
|
37300
37338
|
if (event.modelChoice !== void 0) return event.modelChoice;
|
|
@@ -37315,6 +37353,7 @@ function buildRecord(event, context) {
|
|
|
37315
37353
|
...identity === void 0 ? {} : { identity },
|
|
37316
37354
|
provider,
|
|
37317
37355
|
...sessionId === void 0 ? {} : { sessionId },
|
|
37356
|
+
...event.clientSessionId === void 0 ? {} : { clientSessionId: event.clientSessionId },
|
|
37318
37357
|
...projectId === void 0 ? {} : { project: projectId },
|
|
37319
37358
|
viaHeadroom: event.viaHeadroom,
|
|
37320
37359
|
route: event.route,
|
|
@@ -38200,12 +38239,12 @@ function requireKeychain() {
|
|
|
38200
38239
|
}
|
|
38201
38240
|
}
|
|
38202
38241
|
function security(args, stdin2) {
|
|
38203
|
-
const result = (
|
|
38242
|
+
const result = spawnSyncBlocking("a keychain call", "security", args, { encoding: "utf8", ...stdin2 === void 0 ? {} : { input: stdin2 }, stdio: ["pipe", "pipe", "ignore"] });
|
|
38204
38243
|
return { status: result.status, stdout: result.stdout };
|
|
38205
38244
|
}
|
|
38206
38245
|
async function securityAsync(args, stdin2) {
|
|
38207
38246
|
return await new Promise((resolve2) => {
|
|
38208
|
-
const child = (0,
|
|
38247
|
+
const child = (0, import_node_child_process4.spawn)("security", args, { stdio: ["pipe", "pipe", "ignore"] });
|
|
38209
38248
|
let stdout2 = "";
|
|
38210
38249
|
let settled = false;
|
|
38211
38250
|
const settle2 = (status) => {
|
|
@@ -38315,13 +38354,14 @@ function createAsyncRealCredentialCache(root) {
|
|
|
38315
38354
|
function realAsyncCredentialCacheEnv(paths) {
|
|
38316
38355
|
return { port: createAsyncRealCredentialCache(paths.root), platform: process.platform, now: () => Date.now() };
|
|
38317
38356
|
}
|
|
38318
|
-
var
|
|
38357
|
+
var import_node_child_process4, import_node_fs9, import_node_path29, KEYCHAIN_CACHE_SERVICE, CACHE_DIR_MODE, CACHE_FILE_MODE;
|
|
38319
38358
|
var init_realCredentialCache = __esm({
|
|
38320
38359
|
"src/realCredentialCache.ts"() {
|
|
38321
38360
|
"use strict";
|
|
38322
|
-
|
|
38361
|
+
import_node_child_process4 = require("node:child_process");
|
|
38323
38362
|
import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
38324
38363
|
import_node_path29 = __toESM(require("node:path"), 1);
|
|
38364
|
+
init_blockingSpawn();
|
|
38325
38365
|
init_credentialCache();
|
|
38326
38366
|
KEYCHAIN_CACHE_SERVICE = "agent-shim-credential-cache";
|
|
38327
38367
|
CACHE_DIR_MODE = 448;
|
|
@@ -40328,14 +40368,14 @@ var require_util2 = __commonJS({
|
|
|
40328
40368
|
}
|
|
40329
40369
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
40330
40370
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
40331
|
-
let
|
|
40371
|
+
let path71 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
40332
40372
|
if (origin[origin.length - 1] === "/") {
|
|
40333
40373
|
origin = origin.slice(0, origin.length - 1);
|
|
40334
40374
|
}
|
|
40335
|
-
if (
|
|
40336
|
-
|
|
40375
|
+
if (path71 && path71[0] !== "/") {
|
|
40376
|
+
path71 = `/${path71}`;
|
|
40337
40377
|
}
|
|
40338
|
-
return new URL(`${origin}${
|
|
40378
|
+
return new URL(`${origin}${path71}`);
|
|
40339
40379
|
}
|
|
40340
40380
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
40341
40381
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -41156,9 +41196,9 @@ var require_diagnostics = __commonJS({
|
|
|
41156
41196
|
"undici:client:sendHeaders",
|
|
41157
41197
|
(evt) => {
|
|
41158
41198
|
const {
|
|
41159
|
-
request: { method, path:
|
|
41199
|
+
request: { method, path: path71, origin }
|
|
41160
41200
|
} = evt;
|
|
41161
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
41201
|
+
debugLog("sending request to %s %s%s", method, origin, path71);
|
|
41162
41202
|
}
|
|
41163
41203
|
);
|
|
41164
41204
|
}
|
|
@@ -41176,14 +41216,14 @@ var require_diagnostics = __commonJS({
|
|
|
41176
41216
|
"undici:request:headers",
|
|
41177
41217
|
(evt) => {
|
|
41178
41218
|
const {
|
|
41179
|
-
request: { method, path:
|
|
41219
|
+
request: { method, path: path71, origin },
|
|
41180
41220
|
response: { statusCode }
|
|
41181
41221
|
} = evt;
|
|
41182
41222
|
debugLog(
|
|
41183
41223
|
"received response to %s %s%s - HTTP %d",
|
|
41184
41224
|
method,
|
|
41185
41225
|
origin,
|
|
41186
|
-
|
|
41226
|
+
path71,
|
|
41187
41227
|
statusCode
|
|
41188
41228
|
);
|
|
41189
41229
|
}
|
|
@@ -41192,23 +41232,23 @@ var require_diagnostics = __commonJS({
|
|
|
41192
41232
|
"undici:request:trailers",
|
|
41193
41233
|
(evt) => {
|
|
41194
41234
|
const {
|
|
41195
|
-
request: { method, path:
|
|
41235
|
+
request: { method, path: path71, origin }
|
|
41196
41236
|
} = evt;
|
|
41197
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
41237
|
+
debugLog("trailers received from %s %s%s", method, origin, path71);
|
|
41198
41238
|
}
|
|
41199
41239
|
);
|
|
41200
41240
|
diagnosticsChannel.subscribe(
|
|
41201
41241
|
"undici:request:error",
|
|
41202
41242
|
(evt) => {
|
|
41203
41243
|
const {
|
|
41204
|
-
request: { method, path:
|
|
41244
|
+
request: { method, path: path71, origin },
|
|
41205
41245
|
error: error63
|
|
41206
41246
|
} = evt;
|
|
41207
41247
|
debugLog(
|
|
41208
41248
|
"request to %s %s%s errored - %s",
|
|
41209
41249
|
method,
|
|
41210
41250
|
origin,
|
|
41211
|
-
|
|
41251
|
+
path71,
|
|
41212
41252
|
error63.message
|
|
41213
41253
|
);
|
|
41214
41254
|
}
|
|
@@ -41323,7 +41363,7 @@ var require_request = __commonJS({
|
|
|
41323
41363
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
41324
41364
|
var Request2 = class {
|
|
41325
41365
|
constructor(origin, {
|
|
41326
|
-
path:
|
|
41366
|
+
path: path71,
|
|
41327
41367
|
method,
|
|
41328
41368
|
body,
|
|
41329
41369
|
headers,
|
|
@@ -41340,11 +41380,11 @@ var require_request = __commonJS({
|
|
|
41340
41380
|
maxRedirections,
|
|
41341
41381
|
typeOfService
|
|
41342
41382
|
}, handler) {
|
|
41343
|
-
if (typeof
|
|
41383
|
+
if (typeof path71 !== "string") {
|
|
41344
41384
|
throw new InvalidArgumentError2("path must be a string");
|
|
41345
|
-
} else if (
|
|
41385
|
+
} else if (path71[0] !== "/" && !(path71.startsWith("http://") || path71.startsWith("https://")) && method !== "CONNECT") {
|
|
41346
41386
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
41347
|
-
} else if (invalidPathRegex.test(
|
|
41387
|
+
} else if (invalidPathRegex.test(path71)) {
|
|
41348
41388
|
throw new InvalidArgumentError2("invalid request path");
|
|
41349
41389
|
}
|
|
41350
41390
|
if (typeof method !== "string") {
|
|
@@ -41419,7 +41459,7 @@ var require_request = __commonJS({
|
|
|
41419
41459
|
this.completed = false;
|
|
41420
41460
|
this.aborted = false;
|
|
41421
41461
|
this.upgrade = upgrade || null;
|
|
41422
|
-
this.path = query ? serializePathWithQuery(
|
|
41462
|
+
this.path = query ? serializePathWithQuery(path71, query) : path71;
|
|
41423
41463
|
this.origin = origin;
|
|
41424
41464
|
this.protocol = getProtocolFromUrlString(origin);
|
|
41425
41465
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -46601,7 +46641,7 @@ var require_client_h1 = __commonJS({
|
|
|
46601
46641
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
46602
46642
|
}
|
|
46603
46643
|
function writeH1(client, request7) {
|
|
46604
|
-
const { method, path:
|
|
46644
|
+
const { method, path: path71, host, upgrade, blocking, reset } = request7;
|
|
46605
46645
|
let { body, headers, contentLength } = request7;
|
|
46606
46646
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
46607
46647
|
if (util2.isFormDataLike(body)) {
|
|
@@ -46679,7 +46719,7 @@ var require_client_h1 = __commonJS({
|
|
|
46679
46719
|
if (socket.setTypeOfService) {
|
|
46680
46720
|
socket.setTypeOfService(request7.typeOfService);
|
|
46681
46721
|
}
|
|
46682
|
-
let header = `${method} ${
|
|
46722
|
+
let header = `${method} ${path71} HTTP/1.1\r
|
|
46683
46723
|
`;
|
|
46684
46724
|
if (typeof host === "string") {
|
|
46685
46725
|
header += `host: ${host}\r
|
|
@@ -47358,7 +47398,7 @@ var require_client_h2 = __commonJS({
|
|
|
47358
47398
|
const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
|
|
47359
47399
|
const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
|
|
47360
47400
|
const session = client[kHTTP2Session];
|
|
47361
|
-
const { method, path:
|
|
47401
|
+
const { method, path: path71, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
|
|
47362
47402
|
let { body } = request7;
|
|
47363
47403
|
if (upgrade != null && upgrade !== "websocket") {
|
|
47364
47404
|
util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -47427,7 +47467,7 @@ var require_client_h2 = __commonJS({
|
|
|
47427
47467
|
}
|
|
47428
47468
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
47429
47469
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
47430
|
-
headers[HTTP2_HEADER_PATH] =
|
|
47470
|
+
headers[HTTP2_HEADER_PATH] = path71;
|
|
47431
47471
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
47432
47472
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
47433
47473
|
} else {
|
|
@@ -47469,7 +47509,7 @@ var require_client_h2 = __commonJS({
|
|
|
47469
47509
|
stream.setTimeout(headersTimeout);
|
|
47470
47510
|
return true;
|
|
47471
47511
|
}
|
|
47472
|
-
headers[HTTP2_HEADER_PATH] =
|
|
47512
|
+
headers[HTTP2_HEADER_PATH] = path71;
|
|
47473
47513
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
47474
47514
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
47475
47515
|
if (body && typeof body.read === "function") {
|
|
@@ -49821,10 +49861,10 @@ var require_proxy_agent = __commonJS({
|
|
|
49821
49861
|
};
|
|
49822
49862
|
const {
|
|
49823
49863
|
origin,
|
|
49824
|
-
path:
|
|
49864
|
+
path: path71 = "/",
|
|
49825
49865
|
headers = {}
|
|
49826
49866
|
} = opts;
|
|
49827
|
-
opts.path = origin +
|
|
49867
|
+
opts.path = origin + path71;
|
|
49828
49868
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
49829
49869
|
const { host } = new URL(origin);
|
|
49830
49870
|
headers.host = host;
|
|
@@ -51933,20 +51973,20 @@ var require_mock_utils = __commonJS({
|
|
|
51933
51973
|
}
|
|
51934
51974
|
return normalizedQp;
|
|
51935
51975
|
}
|
|
51936
|
-
function safeUrl(
|
|
51937
|
-
if (typeof
|
|
51938
|
-
return
|
|
51976
|
+
function safeUrl(path71) {
|
|
51977
|
+
if (typeof path71 !== "string") {
|
|
51978
|
+
return path71;
|
|
51939
51979
|
}
|
|
51940
|
-
const pathSegments =
|
|
51980
|
+
const pathSegments = path71.split("?", 3);
|
|
51941
51981
|
if (pathSegments.length !== 2) {
|
|
51942
|
-
return
|
|
51982
|
+
return path71;
|
|
51943
51983
|
}
|
|
51944
51984
|
const qp2 = new URLSearchParams(pathSegments.pop());
|
|
51945
51985
|
qp2.sort();
|
|
51946
51986
|
return [...pathSegments, qp2.toString()].join("?");
|
|
51947
51987
|
}
|
|
51948
|
-
function matchKey(mockDispatch2, { path:
|
|
51949
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
51988
|
+
function matchKey(mockDispatch2, { path: path71, method, body, headers }) {
|
|
51989
|
+
const pathMatch = matchValue(mockDispatch2.path, path71);
|
|
51950
51990
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
51951
51991
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
51952
51992
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -51971,8 +52011,8 @@ var require_mock_utils = __commonJS({
|
|
|
51971
52011
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
51972
52012
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
51973
52013
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
51974
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
51975
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
52014
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path71, ignoreTrailingSlash }) => {
|
|
52015
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path71)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path71), resolvedPath);
|
|
51976
52016
|
});
|
|
51977
52017
|
if (matchedMockDispatches.length === 0) {
|
|
51978
52018
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -52011,19 +52051,19 @@ var require_mock_utils = __commonJS({
|
|
|
52011
52051
|
mockDispatches.splice(index, 1);
|
|
52012
52052
|
}
|
|
52013
52053
|
}
|
|
52014
|
-
function removeTrailingSlash(
|
|
52015
|
-
while (
|
|
52016
|
-
|
|
52054
|
+
function removeTrailingSlash(path71) {
|
|
52055
|
+
while (path71.endsWith("/")) {
|
|
52056
|
+
path71 = path71.slice(0, -1);
|
|
52017
52057
|
}
|
|
52018
|
-
if (
|
|
52019
|
-
|
|
52058
|
+
if (path71.length === 0) {
|
|
52059
|
+
path71 = "/";
|
|
52020
52060
|
}
|
|
52021
|
-
return
|
|
52061
|
+
return path71;
|
|
52022
52062
|
}
|
|
52023
52063
|
function buildKey(opts) {
|
|
52024
|
-
const { path:
|
|
52064
|
+
const { path: path71, method, body, headers, query } = opts;
|
|
52025
52065
|
return {
|
|
52026
|
-
path:
|
|
52066
|
+
path: path71,
|
|
52027
52067
|
method,
|
|
52028
52068
|
body,
|
|
52029
52069
|
headers,
|
|
@@ -52713,10 +52753,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
52713
52753
|
}
|
|
52714
52754
|
format(pendingInterceptors) {
|
|
52715
52755
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
52716
|
-
({ method, path:
|
|
52756
|
+
({ method, path: path71, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
52717
52757
|
Method: method,
|
|
52718
52758
|
Origin: origin,
|
|
52719
|
-
Path:
|
|
52759
|
+
Path: path71,
|
|
52720
52760
|
"Status code": statusCode,
|
|
52721
52761
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
52722
52762
|
Invocations: timesInvoked,
|
|
@@ -52798,9 +52838,9 @@ var require_mock_agent = __commonJS({
|
|
|
52798
52838
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
52799
52839
|
const dispatchOpts = { ...opts };
|
|
52800
52840
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
52801
|
-
const [
|
|
52841
|
+
const [path71, searchParams] = dispatchOpts.path.split("?");
|
|
52802
52842
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
52803
|
-
dispatchOpts.path = `${
|
|
52843
|
+
dispatchOpts.path = `${path71}?${normalizedSearchParams}`;
|
|
52804
52844
|
}
|
|
52805
52845
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
52806
52846
|
}
|
|
@@ -53201,12 +53241,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53201
53241
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
53202
53242
|
*/
|
|
53203
53243
|
async loadSnapshots(filePath) {
|
|
53204
|
-
const
|
|
53205
|
-
if (!
|
|
53244
|
+
const path71 = filePath || this.#snapshotPath;
|
|
53245
|
+
if (!path71) {
|
|
53206
53246
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
53207
53247
|
}
|
|
53208
53248
|
try {
|
|
53209
|
-
const data = await readFile(resolve2(
|
|
53249
|
+
const data = await readFile(resolve2(path71), "utf8");
|
|
53210
53250
|
const parsed = JSON.parse(data);
|
|
53211
53251
|
if (Array.isArray(parsed)) {
|
|
53212
53252
|
this.#snapshots.clear();
|
|
@@ -53220,7 +53260,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53220
53260
|
if (error63.code === "ENOENT") {
|
|
53221
53261
|
this.#snapshots.clear();
|
|
53222
53262
|
} else {
|
|
53223
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
53263
|
+
throw new UndiciError(`Failed to load snapshots from ${path71}`, { cause: error63 });
|
|
53224
53264
|
}
|
|
53225
53265
|
}
|
|
53226
53266
|
}
|
|
@@ -53231,11 +53271,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53231
53271
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
53232
53272
|
*/
|
|
53233
53273
|
async saveSnapshots(filePath) {
|
|
53234
|
-
const
|
|
53235
|
-
if (!
|
|
53274
|
+
const path71 = filePath || this.#snapshotPath;
|
|
53275
|
+
if (!path71) {
|
|
53236
53276
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
53237
53277
|
}
|
|
53238
|
-
const resolvedPath = resolve2(
|
|
53278
|
+
const resolvedPath = resolve2(path71);
|
|
53239
53279
|
await mkdir(dirname3(resolvedPath), { recursive: true });
|
|
53240
53280
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
53241
53281
|
hash: hash2,
|
|
@@ -53867,15 +53907,15 @@ var require_redirect_handler = __commonJS({
|
|
|
53867
53907
|
return;
|
|
53868
53908
|
}
|
|
53869
53909
|
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}${
|
|
53910
|
+
const path71 = search ? `${pathname}${search}` : pathname;
|
|
53911
|
+
const redirectUrlString = `${origin}${path71}`;
|
|
53872
53912
|
for (const historyUrl of this.history) {
|
|
53873
53913
|
if (historyUrl.toString() === redirectUrlString) {
|
|
53874
53914
|
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
53915
|
}
|
|
53876
53916
|
}
|
|
53877
53917
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
53878
|
-
this.opts.path =
|
|
53918
|
+
this.opts.path = path71;
|
|
53879
53919
|
this.opts.origin = origin;
|
|
53880
53920
|
this.opts.query = null;
|
|
53881
53921
|
}
|
|
@@ -55635,10 +55675,10 @@ var require_cache_handler = __commonJS({
|
|
|
55635
55675
|
}
|
|
55636
55676
|
return locationUrl.pathname + locationUrl.search;
|
|
55637
55677
|
}
|
|
55638
|
-
function deleteCachedUri(store, cacheKey,
|
|
55678
|
+
function deleteCachedUri(store, cacheKey, path71) {
|
|
55639
55679
|
deleteCachedValue(store, {
|
|
55640
55680
|
...cacheKey,
|
|
55641
|
-
path:
|
|
55681
|
+
path: path71
|
|
55642
55682
|
});
|
|
55643
55683
|
for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
|
|
55644
55684
|
const method = util2.safeHTTPMethods[i10];
|
|
@@ -55646,7 +55686,7 @@ var require_cache_handler = __commonJS({
|
|
|
55646
55686
|
deleteCachedValue(store, {
|
|
55647
55687
|
...cacheKey,
|
|
55648
55688
|
method,
|
|
55649
|
-
path:
|
|
55689
|
+
path: path71
|
|
55650
55690
|
});
|
|
55651
55691
|
}
|
|
55652
55692
|
}
|
|
@@ -55657,9 +55697,9 @@ var require_cache_handler = __commonJS({
|
|
|
55657
55697
|
}
|
|
55658
55698
|
const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
|
|
55659
55699
|
for (let i10 = 0; i10 < values.length; i10++) {
|
|
55660
|
-
const
|
|
55661
|
-
if (
|
|
55662
|
-
deleteCachedUri(store, cacheKey,
|
|
55700
|
+
const path71 = getSameOriginPath(cacheKey, values[i10]);
|
|
55701
|
+
if (path71 !== void 0) {
|
|
55702
|
+
deleteCachedUri(store, cacheKey, path71);
|
|
55663
55703
|
}
|
|
55664
55704
|
}
|
|
55665
55705
|
}
|
|
@@ -60659,11 +60699,11 @@ var require_fetch = __commonJS({
|
|
|
60659
60699
|
function dispatch({ body }) {
|
|
60660
60700
|
const url2 = requestCurrentURL(request7);
|
|
60661
60701
|
const agent = fetchParams.controller.dispatcher;
|
|
60662
|
-
const
|
|
60702
|
+
const path71 = url2.pathname + url2.search;
|
|
60663
60703
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
60664
60704
|
return new Promise((resolve2, reject) => agent.dispatch(
|
|
60665
60705
|
{
|
|
60666
|
-
path: hasTrailingQuestionMark ? `${
|
|
60706
|
+
path: hasTrailingQuestionMark ? `${path71}?` : path71,
|
|
60667
60707
|
origin: url2.origin,
|
|
60668
60708
|
method: request7.method,
|
|
60669
60709
|
body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
|
|
@@ -61610,9 +61650,9 @@ var require_util5 = __commonJS({
|
|
|
61610
61650
|
}
|
|
61611
61651
|
}
|
|
61612
61652
|
}
|
|
61613
|
-
function validateCookiePath(
|
|
61614
|
-
for (let i10 = 0; i10 <
|
|
61615
|
-
const code =
|
|
61653
|
+
function validateCookiePath(path71) {
|
|
61654
|
+
for (let i10 = 0; i10 < path71.length; ++i10) {
|
|
61655
|
+
const code = path71.charCodeAt(i10);
|
|
61616
61656
|
if (code < 32 || // exclude CTLs (0-31)
|
|
61617
61657
|
code > 126 || // exclude DEL and non-ascii
|
|
61618
61658
|
code === 59) {
|
|
@@ -64960,11 +65000,11 @@ var require_undici = __commonJS({
|
|
|
64960
65000
|
if (typeof opts.path !== "string") {
|
|
64961
65001
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
64962
65002
|
}
|
|
64963
|
-
let
|
|
65003
|
+
let path71 = opts.path;
|
|
64964
65004
|
if (!opts.path.startsWith("/")) {
|
|
64965
|
-
|
|
65005
|
+
path71 = `/${path71}`;
|
|
64966
65006
|
}
|
|
64967
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
65007
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path71);
|
|
64968
65008
|
} else {
|
|
64969
65009
|
if (!opts) {
|
|
64970
65010
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -66692,8 +66732,8 @@ function routingRows(facts) {
|
|
|
66692
66732
|
];
|
|
66693
66733
|
}
|
|
66694
66734
|
function farmRow(links, builtDirectories, adopted) {
|
|
66695
|
-
const
|
|
66696
|
-
const parts = [
|
|
66735
|
+
const counted2 = (count, singular, plural2) => `${String(count)} ${count === 1 ? singular : plural2}`;
|
|
66736
|
+
const parts = [counted2(links, "link", "links"), counted2(builtDirectories, "built directory", "built directories"), ...adopted === 0 ? [] : [`${String(adopted)} adopted`]];
|
|
66697
66737
|
return { label: "farm", value: "resynced", detail: parts.join(", ") };
|
|
66698
66738
|
}
|
|
66699
66739
|
function noteRow(text4) {
|
|
@@ -68939,14 +68979,57 @@ var init_launcher = __esm({
|
|
|
68939
68979
|
}
|
|
68940
68980
|
});
|
|
68941
68981
|
|
|
68982
|
+
// src/replayRun.ts
|
|
68983
|
+
function keyOf2(command, args) {
|
|
68984
|
+
return JSON.stringify([command, args]);
|
|
68985
|
+
}
|
|
68986
|
+
async function resolveWithAsyncRuns(decide, runAsync2) {
|
|
68987
|
+
const answers = /* @__PURE__ */ new Map();
|
|
68988
|
+
const replay = {
|
|
68989
|
+
run: (command, args) => {
|
|
68990
|
+
const answer = answers.get(keyOf2(command, args));
|
|
68991
|
+
if (answer === void 0) {
|
|
68992
|
+
throw new RunNeededError(command, args);
|
|
68993
|
+
}
|
|
68994
|
+
return answer;
|
|
68995
|
+
}
|
|
68996
|
+
};
|
|
68997
|
+
for (; ; ) {
|
|
68998
|
+
try {
|
|
68999
|
+
return decide(replay);
|
|
69000
|
+
} catch (error63) {
|
|
69001
|
+
if (!(error63 instanceof RunNeededError)) {
|
|
69002
|
+
throw error63;
|
|
69003
|
+
}
|
|
69004
|
+
answers.set(keyOf2(error63.command, error63.args), await runAsync2(error63.command, error63.args));
|
|
69005
|
+
}
|
|
69006
|
+
}
|
|
69007
|
+
}
|
|
69008
|
+
var RunNeededError;
|
|
69009
|
+
var init_replayRun = __esm({
|
|
69010
|
+
"src/replayRun.ts"() {
|
|
69011
|
+
"use strict";
|
|
69012
|
+
RunNeededError = class extends Error {
|
|
69013
|
+
constructor(command, args) {
|
|
69014
|
+
super(`no recorded answer for ${command} ${args.join(" ")}`);
|
|
69015
|
+
this.command = command;
|
|
69016
|
+
this.args = args;
|
|
69017
|
+
this.name = "RunNeededError";
|
|
69018
|
+
}
|
|
69019
|
+
command;
|
|
69020
|
+
args;
|
|
69021
|
+
};
|
|
69022
|
+
}
|
|
69023
|
+
});
|
|
69024
|
+
|
|
68942
69025
|
// src/launchWiring.ts
|
|
68943
|
-
function buildFarmRuntime(paths, cwd) {
|
|
69026
|
+
function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
68944
69027
|
const home = import_node_os9.default.homedir();
|
|
68945
69028
|
const read = cosmiconfigReader();
|
|
68946
69029
|
const classification = loadClassification(paths);
|
|
68947
69030
|
const loaded = loadCascadeInput({ paths, home, cwd, read });
|
|
68948
69031
|
const selections = readDirectorySelections(loaded);
|
|
68949
|
-
const git = resolveGitBranch(
|
|
69032
|
+
const git = resolveGitBranch(run, cwd);
|
|
68950
69033
|
const updateMode = resolveUpdateMode(loaded.globalConfig);
|
|
68951
69034
|
return {
|
|
68952
69035
|
runtime: {
|
|
@@ -68993,7 +69076,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
68993
69076
|
frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
|
|
68994
69077
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
68995
69078
|
hold: realHoldPort,
|
|
68996
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: realRunPort }, { farmRoot: import_node_path46.default.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
|
|
69079
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path46.default.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
|
|
68997
69080
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
68998
69081
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
68999
69082
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -69005,7 +69088,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
69005
69088
|
function daemonSpawnerFor(agentShim) {
|
|
69006
69089
|
return agentShim === void 0 ? (spawnPaths, subcommand, logPath) => spawnDaemonThroughScript(agentShimCliPath())(spawnPaths, subcommand, logPath) : spawnDaemonThrough(agentShim);
|
|
69007
69090
|
}
|
|
69008
|
-
function resolveClaudeLaunch(options) {
|
|
69091
|
+
function resolveClaudeLaunch(options, run = realRunPort) {
|
|
69009
69092
|
const paths = options.paths ?? resolveLayoutPaths();
|
|
69010
69093
|
const refusals = [];
|
|
69011
69094
|
const warnings = [];
|
|
@@ -69029,7 +69112,10 @@ function resolveClaudeLaunch(options) {
|
|
|
69029
69112
|
const spawnDaemon = () => {
|
|
69030
69113
|
throw new Error("resolving a launch starts no daemon");
|
|
69031
69114
|
};
|
|
69032
|
-
return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, farm: buildFarmRuntime(paths, options.cwd) })), warnings };
|
|
69115
|
+
return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, run, farm: buildFarmRuntime(paths, options.cwd, run) })), warnings };
|
|
69116
|
+
}
|
|
69117
|
+
async function resolveClaudeLaunchAsync(options, runAsync2 = realRunAsync) {
|
|
69118
|
+
return await resolveWithAsyncRuns((run) => resolveClaudeLaunch(options, run), runAsync2);
|
|
69033
69119
|
}
|
|
69034
69120
|
var import_node_os9, import_node_path46, import_node_crypto21, LaunchRefusedError;
|
|
69035
69121
|
var init_launchWiring = __esm({
|
|
@@ -69048,6 +69134,7 @@ var init_launchWiring = __esm({
|
|
|
69048
69134
|
init_launcher();
|
|
69049
69135
|
init_launchHook();
|
|
69050
69136
|
init_cascade();
|
|
69137
|
+
init_replayRun();
|
|
69051
69138
|
init_paths();
|
|
69052
69139
|
init_signIn();
|
|
69053
69140
|
init_realPorts();
|
|
@@ -106232,8 +106319,8 @@ var require_utils3 = __commonJS({
|
|
|
106232
106319
|
}
|
|
106233
106320
|
return ind;
|
|
106234
106321
|
}
|
|
106235
|
-
function removeDotSegments(
|
|
106236
|
-
let input2 =
|
|
106322
|
+
function removeDotSegments(path71) {
|
|
106323
|
+
let input2 = path71;
|
|
106237
106324
|
const output2 = [];
|
|
106238
106325
|
let nextSlash = -1;
|
|
106239
106326
|
let len = 0;
|
|
@@ -106642,8 +106729,8 @@ var require_schemes = __commonJS({
|
|
|
106642
106729
|
}
|
|
106643
106730
|
if (wsComponent.resourceName) {
|
|
106644
106731
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
106645
|
-
const
|
|
106646
|
-
wsComponent.path =
|
|
106732
|
+
const path71 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
106733
|
+
wsComponent.path = path71 && path71 !== "/" ? path71 : void 0;
|
|
106647
106734
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
106648
106735
|
wsComponent.resourceName = void 0;
|
|
106649
106736
|
}
|
|
@@ -110170,7 +110257,7 @@ var require_dist2 = __commonJS({
|
|
|
110170
110257
|
});
|
|
110171
110258
|
|
|
110172
110259
|
// src/cli.ts
|
|
110173
|
-
var
|
|
110260
|
+
var import_node_path70 = __toESM(require("node:path"), 1);
|
|
110174
110261
|
|
|
110175
110262
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
110176
110263
|
var CommanderError = class extends Error {
|
|
@@ -113283,9 +113370,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
113283
113370
|
* @param {string} [path]
|
|
113284
113371
|
* @return {(string|null|Command)}
|
|
113285
113372
|
*/
|
|
113286
|
-
executableDir(
|
|
113287
|
-
if (
|
|
113288
|
-
this._executableDir =
|
|
113373
|
+
executableDir(path71) {
|
|
113374
|
+
if (path71 === void 0) return this._executableDir;
|
|
113375
|
+
this._executableDir = path71;
|
|
113289
113376
|
return this;
|
|
113290
113377
|
}
|
|
113291
113378
|
/**
|
|
@@ -114761,19 +114848,19 @@ function writePools(paths, pools) {
|
|
|
114761
114848
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
114762
114849
|
}
|
|
114763
114850
|
function poolCycleOf(pools, name) {
|
|
114764
|
-
const walk3 = (current,
|
|
114851
|
+
const walk3 = (current, path71) => {
|
|
114765
114852
|
for (const entry of pools[current]?.identities ?? []) {
|
|
114766
114853
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
114767
114854
|
if (nested === void 0) {
|
|
114768
114855
|
continue;
|
|
114769
114856
|
}
|
|
114770
114857
|
if (nested === name) {
|
|
114771
|
-
return [...
|
|
114858
|
+
return [...path71, nested];
|
|
114772
114859
|
}
|
|
114773
|
-
if (
|
|
114860
|
+
if (path71.includes(nested)) {
|
|
114774
114861
|
continue;
|
|
114775
114862
|
}
|
|
114776
|
-
const found = walk3(nested, [...
|
|
114863
|
+
const found = walk3(nested, [...path71, nested]);
|
|
114777
114864
|
if (found !== void 0) {
|
|
114778
114865
|
return found;
|
|
114779
114866
|
}
|
|
@@ -115974,7 +116061,7 @@ function statuslineChangeOf(options) {
|
|
|
115974
116061
|
return void 0;
|
|
115975
116062
|
}
|
|
115976
116063
|
const assignments = (options.statusline ?? []).map(parseStatuslineAssignment);
|
|
115977
|
-
return { set: Object.fromEntries(assignments.map(({ path:
|
|
116064
|
+
return { set: Object.fromEntries(assignments.map(({ path: path71, value: value2 }) => [path71, value2])), unset: options.unsetStatusline ?? [] };
|
|
115978
116065
|
}
|
|
115979
116066
|
function registerProfileCommand(program2, deps) {
|
|
115980
116067
|
const { paths } = deps;
|
|
@@ -117323,7 +117410,7 @@ async function runSiwcLogout(ports) {
|
|
|
117323
117410
|
}
|
|
117324
117411
|
|
|
117325
117412
|
// src/codex/siwcPorts.ts
|
|
117326
|
-
var
|
|
117413
|
+
var import_node_child_process5 = require("node:child_process");
|
|
117327
117414
|
var import_node_crypto11 = require("node:crypto");
|
|
117328
117415
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
117329
117416
|
|
|
@@ -117389,7 +117476,7 @@ async function listenForCallback(port, state) {
|
|
|
117389
117476
|
}
|
|
117390
117477
|
function openInBrowser(url2) {
|
|
117391
117478
|
const command = process.platform === "darwin" ? { file: "open", args: [url2] } : process.platform === "win32" ? { file: "cmd", args: ["/c", "start", "", url2] } : { file: "xdg-open", args: [url2] };
|
|
117392
|
-
(0,
|
|
117479
|
+
(0, import_node_child_process5.spawn)(command.file, command.args, { detached: true, stdio: "ignore" }).unref();
|
|
117393
117480
|
}
|
|
117394
117481
|
|
|
117395
117482
|
// src/codex/siwcStore.ts
|
|
@@ -118737,14 +118824,14 @@ init_poolPick();
|
|
|
118737
118824
|
init_realAnthropicUsageProbe();
|
|
118738
118825
|
|
|
118739
118826
|
// src/usage/childRun.ts
|
|
118740
|
-
var
|
|
118827
|
+
var import_node_child_process6 = require("node:child_process");
|
|
118741
118828
|
init_realPorts();
|
|
118742
118829
|
var CHILD_GRACE_MS = 3e4;
|
|
118743
118830
|
var STDERR_TAIL_CHARS = 2e3;
|
|
118744
118831
|
async function runChild(options) {
|
|
118745
118832
|
const invocation = (options.invocation ?? selfInvocation)(options.args);
|
|
118746
118833
|
await new Promise((resolve2, reject) => {
|
|
118747
|
-
const child = (0,
|
|
118834
|
+
const child = (0, import_node_child_process6.spawn)(invocation.command, [...invocation.args], { stdio: ["ignore", "ignore", "pipe"], env: { ...process.env, AGENT_SHIM_HOME: options.paths.root } });
|
|
118748
118835
|
let stderr = "";
|
|
118749
118836
|
child.stderr.on("data", (chunk2) => {
|
|
118750
118837
|
stderr = `${stderr}${chunk2.toString()}`.slice(-STDERR_TAIL_CHARS);
|
|
@@ -119641,11 +119728,11 @@ function createRcSessionTracker(deps) {
|
|
|
119641
119728
|
};
|
|
119642
119729
|
const observeExchange = (request7) => {
|
|
119643
119730
|
const method = (request7.method ?? "").toUpperCase();
|
|
119644
|
-
const
|
|
119645
|
-
if (!
|
|
119731
|
+
const path71 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
|
|
119732
|
+
if (!path71.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
119646
119733
|
return void 0;
|
|
119647
119734
|
}
|
|
119648
|
-
const tail =
|
|
119735
|
+
const tail = path71.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
119649
119736
|
const facts = {
|
|
119650
119737
|
oauthAuthorization: oauthAuthorizationOf(request7.headers),
|
|
119651
119738
|
anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
|
|
@@ -120014,8 +120101,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
120014
120101
|
function isRcReadFileEncoding(value2) {
|
|
120015
120102
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value2);
|
|
120016
120103
|
}
|
|
120017
|
-
function buildRcReadFilePayload(requestId,
|
|
120018
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
120104
|
+
function buildRcReadFilePayload(requestId, path71, options) {
|
|
120105
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path71, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
120019
120106
|
}
|
|
120020
120107
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
120021
120108
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -120117,15 +120204,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
120117
120204
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
120118
120205
|
return result.ok ? { ...result, requestId } : result;
|
|
120119
120206
|
}
|
|
120120
|
-
async function readRcSessionFile(deps, sessionId,
|
|
120121
|
-
if (
|
|
120207
|
+
async function readRcSessionFile(deps, sessionId, path71, options) {
|
|
120208
|
+
if (path71 === "") {
|
|
120122
120209
|
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
120210
|
}
|
|
120124
120211
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
120125
120212
|
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
120213
|
}
|
|
120127
120214
|
const requestId = deps.newUuid();
|
|
120128
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
120215
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path71, options), `read ${path71} from session ${sessionId}`);
|
|
120129
120216
|
return result.ok ? { ...result, requestId } : result;
|
|
120130
120217
|
}
|
|
120131
120218
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -120296,11 +120383,11 @@ function createRcControlHandler(deps) {
|
|
|
120296
120383
|
path: "read-file",
|
|
120297
120384
|
read: (body) => {
|
|
120298
120385
|
const session = bodyString(body, "session");
|
|
120299
|
-
const
|
|
120386
|
+
const path71 = bodyString(body, "path");
|
|
120300
120387
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
120301
120388
|
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,
|
|
120389
|
+
const refused2 = session === void 0 || path71 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
120390
|
+
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path71, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
120304
120391
|
}
|
|
120305
120392
|
},
|
|
120306
120393
|
{
|
|
@@ -120610,9 +120697,9 @@ function requestIdOfBody(body) {
|
|
|
120610
120697
|
}
|
|
120611
120698
|
function frontDoorRcControl(transport, token) {
|
|
120612
120699
|
const headers = { authorization: `Bearer ${token}` };
|
|
120613
|
-
const listAnswerOf = async (
|
|
120700
|
+
const listAnswerOf = async (path71, what) => {
|
|
120614
120701
|
try {
|
|
120615
|
-
return await transport.request({ method: "GET", path:
|
|
120702
|
+
return await transport.request({ method: "GET", path: path71, headers });
|
|
120616
120703
|
} catch (error63) {
|
|
120617
120704
|
throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
|
|
120618
120705
|
}
|
|
@@ -120684,10 +120771,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
120684
120771
|
}
|
|
120685
120772
|
return pending;
|
|
120686
120773
|
};
|
|
120687
|
-
const writeOf = async (
|
|
120774
|
+
const writeOf = async (path71, body, describeFailure2) => {
|
|
120688
120775
|
let answer;
|
|
120689
120776
|
try {
|
|
120690
|
-
answer = await transport.request({ method: "POST", path:
|
|
120777
|
+
answer = await transport.request({ method: "POST", path: path71, headers: { ...headers, "content-type": "application/json" }, body });
|
|
120691
120778
|
} catch (error63) {
|
|
120692
120779
|
return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
|
|
120693
120780
|
}
|
|
@@ -120718,10 +120805,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
120718
120805
|
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
120806
|
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
120807
|
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,
|
|
120808
|
+
readFile: async (sessionId, path71, options) => await writeOf(
|
|
120722
120809
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
120723
|
-
JSON.stringify({ session: sessionId, path:
|
|
120724
|
-
(status, message) => `reading ${
|
|
120810
|
+
JSON.stringify({ session: sessionId, path: path71, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
120811
|
+
(status, message) => `reading ${path71} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
120725
120812
|
),
|
|
120726
120813
|
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
120814
|
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 +121121,12 @@ function tlsFacts(options) {
|
|
|
121034
121121
|
}
|
|
121035
121122
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
121036
121123
|
const agent = new ExemptTlsAgent();
|
|
121037
|
-
const post = async (
|
|
121124
|
+
const post = async (path71, headers, body) => await new Promise((resolve2, reject) => {
|
|
121038
121125
|
const options = {
|
|
121039
121126
|
host: target.host,
|
|
121040
121127
|
port: target.port,
|
|
121041
121128
|
method: "POST",
|
|
121042
|
-
path:
|
|
121129
|
+
path: path71,
|
|
121043
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.
|
|
121044
121131
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
121045
121132
|
agent
|
|
@@ -121104,12 +121191,12 @@ function lateRcStreamDial(resolve2) {
|
|
|
121104
121191
|
}
|
|
121105
121192
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
121106
121193
|
const agent = new ExemptTlsAgent();
|
|
121107
|
-
const request7 = async (method,
|
|
121194
|
+
const request7 = async (method, path71, headers, body, signal) => await new Promise((resolve2, reject) => {
|
|
121108
121195
|
const options = {
|
|
121109
121196
|
host: target.host,
|
|
121110
121197
|
port: target.port,
|
|
121111
121198
|
method,
|
|
121112
|
-
path:
|
|
121199
|
+
path: path71,
|
|
121113
121200
|
// 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
121201
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
121115
121202
|
agent,
|
|
@@ -121151,9 +121238,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
121151
121238
|
return { status, body: await readAll(response) };
|
|
121152
121239
|
},
|
|
121153
121240
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
121154
|
-
const
|
|
121241
|
+
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
121242
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
121156
|
-
const { status, response } = await request7("GET",
|
|
121243
|
+
const { status, response } = await request7("GET", path71, streamHeaders, void 0, signal);
|
|
121157
121244
|
if (!isSuccessful2(status)) {
|
|
121158
121245
|
await readAll(response);
|
|
121159
121246
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -122554,11 +122641,11 @@ function tryOrUndefined(fn2) {
|
|
|
122554
122641
|
return void 0;
|
|
122555
122642
|
}
|
|
122556
122643
|
}
|
|
122557
|
-
function pathToHttpPath(
|
|
122558
|
-
return `/${
|
|
122644
|
+
function pathToHttpPath(path71) {
|
|
122645
|
+
return `/${path71.map(safeEncodeURIComponent).join("/")}`;
|
|
122559
122646
|
}
|
|
122560
|
-
function normalizeHttpPath(
|
|
122561
|
-
const paths =
|
|
122647
|
+
function normalizeHttpPath(path71) {
|
|
122648
|
+
const paths = path71.split("/");
|
|
122562
122649
|
if (paths.at(0) === "") {
|
|
122563
122650
|
paths.shift();
|
|
122564
122651
|
}
|
|
@@ -122743,9 +122830,9 @@ function isPlainObject3(value2) {
|
|
|
122743
122830
|
function getOwn(object3, key) {
|
|
122744
122831
|
return Object.hasOwn(object3, key) ? object3[key] : void 0;
|
|
122745
122832
|
}
|
|
122746
|
-
function get(object3,
|
|
122833
|
+
function get(object3, path71) {
|
|
122747
122834
|
let current = object3;
|
|
122748
|
-
for (const key of
|
|
122835
|
+
for (const key of path71) {
|
|
122749
122836
|
if (!isTypescriptObject(current)) {
|
|
122750
122837
|
return void 0;
|
|
122751
122838
|
}
|
|
@@ -123968,7 +124055,7 @@ function resolveClientRest(rest) {
|
|
|
123968
124055
|
// rest[1] can be undefined if all fields of FriendlyClientOptions are optional
|
|
123969
124056
|
];
|
|
123970
124057
|
}
|
|
123971
|
-
function createORPCClient(link, { path:
|
|
124058
|
+
function createORPCClient(link, { path: path71 = [], ...options } = {}) {
|
|
123972
124059
|
const procedureClient = (...rest) => {
|
|
123973
124060
|
const [input2, callOptions] = resolveClientRest(rest);
|
|
123974
124061
|
const interceptors = [
|
|
@@ -123977,7 +124064,7 @@ function createORPCClient(link, { path: path68 = [], ...options } = {}) {
|
|
|
123977
124064
|
];
|
|
123978
124065
|
return intercept(
|
|
123979
124066
|
interceptors,
|
|
123980
|
-
{ ...callOptions, input: input2, path:
|
|
124067
|
+
{ ...callOptions, input: input2, path: path71 },
|
|
123981
124068
|
({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
|
|
123982
124069
|
);
|
|
123983
124070
|
};
|
|
@@ -123991,7 +124078,7 @@ function createORPCClient(link, { path: path68 = [], ...options } = {}) {
|
|
|
123991
124078
|
if (client === void 0) {
|
|
123992
124079
|
client = createORPCClient(link, {
|
|
123993
124080
|
...options,
|
|
123994
|
-
path: [...
|
|
124081
|
+
path: [...path71, key],
|
|
123995
124082
|
scoped: options.scoped?.[key]
|
|
123996
124083
|
});
|
|
123997
124084
|
cache.set(key, client);
|
|
@@ -124013,24 +124100,24 @@ var BracketNotationSerializer = class {
|
|
|
124013
124100
|
this.internalSerialize(data, "", true, result);
|
|
124014
124101
|
return result;
|
|
124015
124102
|
}
|
|
124016
|
-
internalSerialize(data,
|
|
124103
|
+
internalSerialize(data, path71, isRoot, result) {
|
|
124017
124104
|
if (Array.isArray(data)) {
|
|
124018
124105
|
data.forEach((item, i10) => {
|
|
124019
|
-
this.internalSerialize(item, isRoot ? i10.toString() : `${
|
|
124106
|
+
this.internalSerialize(item, isRoot ? i10.toString() : `${path71}[${i10}]`, false, result);
|
|
124020
124107
|
});
|
|
124021
124108
|
} else if (isPlainObject3(data)) {
|
|
124022
124109
|
for (const key of Object.keys(data)) {
|
|
124023
|
-
this.internalSerialize(data[key], isRoot ? key : `${
|
|
124110
|
+
this.internalSerialize(data[key], isRoot ? key : `${path71}[${key}]`, false, result);
|
|
124024
124111
|
}
|
|
124025
124112
|
} else {
|
|
124026
|
-
result.push([
|
|
124113
|
+
result.push([path71, data]);
|
|
124027
124114
|
}
|
|
124028
124115
|
}
|
|
124029
124116
|
deserialize(serialized) {
|
|
124030
124117
|
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
124031
124118
|
const root = new NullProtoObj();
|
|
124032
|
-
for (const [
|
|
124033
|
-
const segments = this.parsePath(
|
|
124119
|
+
for (const [path71, value2] of serialized) {
|
|
124120
|
+
const segments = this.parsePath(path71);
|
|
124034
124121
|
let currentRef = root;
|
|
124035
124122
|
let nextSegment = segments[0];
|
|
124036
124123
|
for (let i10 = 1; i10 < segments.length; i10++) {
|
|
@@ -124081,13 +124168,13 @@ var BracketNotationSerializer = class {
|
|
|
124081
124168
|
}
|
|
124082
124169
|
return result;
|
|
124083
124170
|
}
|
|
124084
|
-
parsePath(
|
|
124171
|
+
parsePath(path71) {
|
|
124085
124172
|
const segments = [];
|
|
124086
124173
|
let inBrackets = false;
|
|
124087
124174
|
let currentSegment = "";
|
|
124088
|
-
for (let i10 = 0; i10 <
|
|
124089
|
-
const char =
|
|
124090
|
-
const nextChar =
|
|
124175
|
+
for (let i10 = 0; i10 < path71.length; i10++) {
|
|
124176
|
+
const char = path71[i10];
|
|
124177
|
+
const nextChar = path71[i10 + 1];
|
|
124091
124178
|
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
|
|
124092
124179
|
if (nextChar === void 0) {
|
|
124093
124180
|
inBrackets = false;
|
|
@@ -124103,7 +124190,7 @@ var BracketNotationSerializer = class {
|
|
|
124103
124190
|
currentSegment += char;
|
|
124104
124191
|
}
|
|
124105
124192
|
}
|
|
124106
|
-
return inBrackets || segments.length === 0 ? [
|
|
124193
|
+
return inBrackets || segments.length === 0 ? [path71] : segments;
|
|
124107
124194
|
}
|
|
124108
124195
|
};
|
|
124109
124196
|
var INTEGER_PATTERN = /^0$|^[1-9]\d*$/;
|
|
@@ -124676,11 +124763,11 @@ var OpenAPISerializer = class {
|
|
|
124676
124763
|
return json2;
|
|
124677
124764
|
}
|
|
124678
124765
|
const form = new FormData();
|
|
124679
|
-
for (const [
|
|
124766
|
+
for (const [path71, value22] of this.bracketNotation.serialize(json2)) {
|
|
124680
124767
|
if (value22 instanceof Blob) {
|
|
124681
|
-
form.append(
|
|
124768
|
+
form.append(path71, value22);
|
|
124682
124769
|
} else if (value22 !== void 0 && value22 !== null) {
|
|
124683
|
-
form.append(
|
|
124770
|
+
form.append(path71, String(value22));
|
|
124684
124771
|
}
|
|
124685
124772
|
}
|
|
124686
124773
|
return form;
|
|
@@ -124718,30 +124805,30 @@ function isBodylessMethod(method) {
|
|
|
124718
124805
|
return method === "GET" || method === "HEAD";
|
|
124719
124806
|
}
|
|
124720
124807
|
var PARAMETER_NAME_REGEX = /^[\w-]+$/;
|
|
124721
|
-
function getDynamicPathParams(
|
|
124722
|
-
if (!
|
|
124808
|
+
function getDynamicPathParams(path71) {
|
|
124809
|
+
if (!path71.includes("{")) {
|
|
124723
124810
|
return void 0;
|
|
124724
124811
|
}
|
|
124725
|
-
const len =
|
|
124812
|
+
const len = path71.length;
|
|
124726
124813
|
let params;
|
|
124727
124814
|
let index = 1;
|
|
124728
124815
|
while (index < len) {
|
|
124729
124816
|
const segmentStart = index;
|
|
124730
|
-
const slashPos =
|
|
124817
|
+
const slashPos = path71.indexOf("/", index);
|
|
124731
124818
|
const segmentEnd = slashPos === -1 ? len : slashPos;
|
|
124732
|
-
if (segmentEnd > segmentStart &&
|
|
124819
|
+
if (segmentEnd > segmentStart && path71.charCodeAt(segmentStart) === 123 && path71.charCodeAt(segmentEnd - 1) === 125) {
|
|
124733
124820
|
let parameterStart = segmentStart + 1;
|
|
124734
124821
|
let allowsSlash = false;
|
|
124735
|
-
const operator =
|
|
124822
|
+
const operator = path71.charCodeAt(parameterStart);
|
|
124736
124823
|
if (operator === 43) {
|
|
124737
124824
|
allowsSlash = true;
|
|
124738
124825
|
parameterStart++;
|
|
124739
124826
|
}
|
|
124740
|
-
const parameterName =
|
|
124827
|
+
const parameterName = path71.slice(parameterStart, segmentEnd - 1);
|
|
124741
124828
|
if (PARAMETER_NAME_REGEX.test(parameterName)) {
|
|
124742
124829
|
params ??= [];
|
|
124743
124830
|
params.push({
|
|
124744
|
-
segment:
|
|
124831
|
+
segment: path71.slice(segmentStart, segmentEnd),
|
|
124745
124832
|
startIndex: segmentStart,
|
|
124746
124833
|
parameterName,
|
|
124747
124834
|
allowsSlash
|
|
@@ -124784,8 +124871,8 @@ openapi.method = (method) => ({
|
|
|
124784
124871
|
...openapi({ method }),
|
|
124785
124872
|
name: "~openapi/method"
|
|
124786
124873
|
});
|
|
124787
|
-
openapi.path = (
|
|
124788
|
-
...openapi({ path:
|
|
124874
|
+
openapi.path = (path71) => ({
|
|
124875
|
+
...openapi({ path: path71 }),
|
|
124789
124876
|
name: "~openapi/path"
|
|
124790
124877
|
});
|
|
124791
124878
|
openapi.spec = (spec) => ({
|
|
@@ -125646,22 +125733,22 @@ function visitJsonSchemaRefs(value2, visit2, schemaLevel = true, seen = /* @__PU
|
|
|
125646
125733
|
}
|
|
125647
125734
|
}
|
|
125648
125735
|
}
|
|
125649
|
-
function mapJsonSchemaRefs(value2, map2, schemaLevel = true,
|
|
125736
|
+
function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path71 = []) {
|
|
125650
125737
|
if (!value2 || typeof value2 !== "object") {
|
|
125651
125738
|
return value2;
|
|
125652
125739
|
}
|
|
125653
125740
|
if (Array.isArray(value2)) {
|
|
125654
|
-
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...
|
|
125741
|
+
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path71, index]));
|
|
125655
125742
|
}
|
|
125656
125743
|
const result = {};
|
|
125657
125744
|
for (const key of Object.keys(value2)) {
|
|
125658
125745
|
const val = value2[key];
|
|
125659
125746
|
if (key === "$ref" && typeof val === "string") {
|
|
125660
|
-
setOwn(result, key, map2(val, [...
|
|
125747
|
+
setOwn(result, key, map2(val, [...path71, key]));
|
|
125661
125748
|
} else if (!schemaLevel) {
|
|
125662
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...
|
|
125749
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path71, key]));
|
|
125663
125750
|
} 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), [...
|
|
125751
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path71, key]));
|
|
125665
125752
|
} else {
|
|
125666
125753
|
setOwn(result, key, val);
|
|
125667
125754
|
}
|
|
@@ -126191,7 +126278,7 @@ function unlazy(maybeLazy) {
|
|
|
126191
126278
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
126192
126279
|
const options = resolveMaybeOptionalOptions(rest);
|
|
126193
126280
|
return async (...[input2, callerOptions]) => {
|
|
126194
|
-
const
|
|
126281
|
+
const path71 = toArray(options.path);
|
|
126195
126282
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
126196
126283
|
const clientContext = callerOptions?.context ?? {};
|
|
126197
126284
|
const context = await value(options.context, clientContext) ?? {};
|
|
@@ -126204,7 +126291,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
126204
126291
|
};
|
|
126205
126292
|
try {
|
|
126206
126293
|
const output2 = await runWithSpan("call_procedure", (span) => {
|
|
126207
|
-
span?.setAttribute("procedure.path",
|
|
126294
|
+
span?.setAttribute("procedure.path", path71);
|
|
126208
126295
|
return intercept(
|
|
126209
126296
|
options.interceptors,
|
|
126210
126297
|
{
|
|
@@ -126212,7 +126299,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
126212
126299
|
// input can be optional if it is undefinable
|
|
126213
126300
|
input: input2,
|
|
126214
126301
|
errors,
|
|
126215
|
-
path:
|
|
126302
|
+
path: path71,
|
|
126216
126303
|
procedure,
|
|
126217
126304
|
signal: callerOptions?.signal,
|
|
126218
126305
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -126463,10 +126550,10 @@ function augmentRouter(router, options) {
|
|
|
126463
126550
|
}
|
|
126464
126551
|
return enhanced;
|
|
126465
126552
|
}
|
|
126466
|
-
function getRouter(router,
|
|
126553
|
+
function getRouter(router, path71) {
|
|
126467
126554
|
let current = router;
|
|
126468
|
-
for (let i10 = 0; i10 <
|
|
126469
|
-
const segment =
|
|
126555
|
+
for (let i10 = 0; i10 < path71.length; i10++) {
|
|
126556
|
+
const segment = path71[i10];
|
|
126470
126557
|
if (!isTypescriptObject(current)) {
|
|
126471
126558
|
return void 0;
|
|
126472
126559
|
}
|
|
@@ -126478,7 +126565,7 @@ function getRouter(router, path68) {
|
|
|
126478
126565
|
continue;
|
|
126479
126566
|
}
|
|
126480
126567
|
const lazied = current;
|
|
126481
|
-
const rest =
|
|
126568
|
+
const rest = path71.slice(i10);
|
|
126482
126569
|
return new Lazy({
|
|
126483
126570
|
...lazied["~orpc"],
|
|
126484
126571
|
async loader() {
|
|
@@ -126493,40 +126580,40 @@ function getRouter(router, path68) {
|
|
|
126493
126580
|
}
|
|
126494
126581
|
return current;
|
|
126495
126582
|
}
|
|
126496
|
-
function walkProcedureContractsSync(router, callback,
|
|
126583
|
+
function walkProcedureContractsSync(router, callback, path71 = []) {
|
|
126497
126584
|
const lazyResults = [];
|
|
126498
|
-
walkProcedureContractsSyncInternal(router, callback,
|
|
126585
|
+
walkProcedureContractsSyncInternal(router, callback, path71.slice(), lazyResults);
|
|
126499
126586
|
return lazyResults;
|
|
126500
126587
|
}
|
|
126501
|
-
function walkProcedureContractsSyncInternal(router, callback,
|
|
126588
|
+
function walkProcedureContractsSyncInternal(router, callback, path71, lazyResults) {
|
|
126502
126589
|
const hiddenContract = getHiddenRouterContract(router);
|
|
126503
126590
|
if (hiddenContract !== void 0) {
|
|
126504
126591
|
router = hiddenContract;
|
|
126505
126592
|
}
|
|
126506
126593
|
if (router instanceof ProcedureContract) {
|
|
126507
|
-
callback(router,
|
|
126594
|
+
callback(router, path71.slice());
|
|
126508
126595
|
return;
|
|
126509
126596
|
}
|
|
126510
126597
|
if (!isTypescriptObject(router)) {
|
|
126511
126598
|
return;
|
|
126512
126599
|
}
|
|
126513
126600
|
for (const [key, value2] of Object.entries(router)) {
|
|
126514
|
-
|
|
126601
|
+
path71.push(key);
|
|
126515
126602
|
if (value2 instanceof Lazy) {
|
|
126516
|
-
lazyResults.push({ router: value2, path:
|
|
126603
|
+
lazyResults.push({ router: value2, path: path71.slice() });
|
|
126517
126604
|
} else {
|
|
126518
|
-
walkProcedureContractsSyncInternal(value2, callback,
|
|
126605
|
+
walkProcedureContractsSyncInternal(value2, callback, path71, lazyResults);
|
|
126519
126606
|
}
|
|
126520
|
-
|
|
126607
|
+
path71.pop();
|
|
126521
126608
|
}
|
|
126522
126609
|
}
|
|
126523
|
-
async function walkProcedureContractsAsync(router, callback,
|
|
126610
|
+
async function walkProcedureContractsAsync(router, callback, path71 = []) {
|
|
126524
126611
|
const hiddenContract = getHiddenRouterContract(router);
|
|
126525
126612
|
if (hiddenContract !== void 0) {
|
|
126526
126613
|
router = hiddenContract;
|
|
126527
126614
|
}
|
|
126528
126615
|
if (router instanceof ProcedureContract) {
|
|
126529
|
-
await callback(router,
|
|
126616
|
+
await callback(router, path71);
|
|
126530
126617
|
return;
|
|
126531
126618
|
}
|
|
126532
126619
|
if (!isTypescriptObject(router)) {
|
|
@@ -126535,9 +126622,9 @@ async function walkProcedureContractsAsync(router, callback, path68 = []) {
|
|
|
126535
126622
|
for (const [key, value2] of Object.entries(router)) {
|
|
126536
126623
|
if (value2 instanceof Lazy) {
|
|
126537
126624
|
const { default: router2 } = await unlazy(value2);
|
|
126538
|
-
await walkProcedureContractsAsync(router2, callback, [...
|
|
126625
|
+
await walkProcedureContractsAsync(router2, callback, [...path71, key]);
|
|
126539
126626
|
} else {
|
|
126540
|
-
await walkProcedureContractsAsync(value2, callback, [...
|
|
126627
|
+
await walkProcedureContractsAsync(value2, callback, [...path71, key]);
|
|
126541
126628
|
}
|
|
126542
126629
|
}
|
|
126543
126630
|
}
|
|
@@ -127023,18 +127110,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
|
|
|
127023
127110
|
}
|
|
127024
127111
|
var OpenAPIGeneratorError = class extends TypeError {
|
|
127025
127112
|
};
|
|
127026
|
-
function toOpenAPIPath(
|
|
127113
|
+
function toOpenAPIPath(path71, dynamicPathParams) {
|
|
127027
127114
|
if (!dynamicPathParams?.length) {
|
|
127028
|
-
return
|
|
127115
|
+
return path71;
|
|
127029
127116
|
}
|
|
127030
127117
|
let normalized = "";
|
|
127031
127118
|
let currentIndex = 0;
|
|
127032
127119
|
for (const param of dynamicPathParams) {
|
|
127033
|
-
normalized +=
|
|
127120
|
+
normalized += path71.slice(currentIndex, param.startIndex);
|
|
127034
127121
|
normalized += `{${param.parameterName}}`;
|
|
127035
127122
|
currentIndex = param.startIndex + param.segment.length;
|
|
127036
127123
|
}
|
|
127037
|
-
normalized +=
|
|
127124
|
+
normalized += path71.slice(currentIndex);
|
|
127038
127125
|
return normalized;
|
|
127039
127126
|
}
|
|
127040
127127
|
function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
|
|
@@ -127468,8 +127555,8 @@ var OpenAPIGenerator = class {
|
|
|
127468
127555
|
customErrorResponseBodySchema: options.customErrorResponseBodySchema
|
|
127469
127556
|
};
|
|
127470
127557
|
const errors = [];
|
|
127471
|
-
await walkProcedureContractsAsync(router, (contract,
|
|
127472
|
-
if (value(options.filter, contract,
|
|
127558
|
+
await walkProcedureContractsAsync(router, (contract, path71) => {
|
|
127559
|
+
if (value(options.filter, contract, path71) === false) {
|
|
127473
127560
|
return;
|
|
127474
127561
|
}
|
|
127475
127562
|
try {
|
|
@@ -127481,7 +127568,7 @@ var OpenAPIGenerator = class {
|
|
|
127481
127568
|
`QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
|
|
127482
127569
|
);
|
|
127483
127570
|
}
|
|
127484
|
-
const postPath = meta3?.path ?? pathToHttpPath(
|
|
127571
|
+
const postPath = meta3?.path ?? pathToHttpPath(path71);
|
|
127485
127572
|
const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
|
|
127486
127573
|
const dynamicPathParams = getDynamicPathParams(httpPath);
|
|
127487
127574
|
const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
|
|
@@ -127490,7 +127577,7 @@ var OpenAPIGenerator = class {
|
|
|
127490
127577
|
operation = meta3.spec;
|
|
127491
127578
|
} else {
|
|
127492
127579
|
operation = {
|
|
127493
|
-
operationId: meta3?.operationId ??
|
|
127580
|
+
operationId: meta3?.operationId ?? path71.join("."),
|
|
127494
127581
|
summary: meta3?.summary,
|
|
127495
127582
|
description: meta3?.description,
|
|
127496
127583
|
deprecated: meta3?.deprecated,
|
|
@@ -127510,7 +127597,7 @@ var OpenAPIGenerator = class {
|
|
|
127510
127597
|
if (!(e14 instanceof OpenAPIGeneratorError)) {
|
|
127511
127598
|
throw e14;
|
|
127512
127599
|
}
|
|
127513
|
-
errors.push(`Procedure at ${
|
|
127600
|
+
errors.push(`Procedure at ${path71.join(".") || "(root)"}: ${e14.message}`);
|
|
127514
127601
|
}
|
|
127515
127602
|
});
|
|
127516
127603
|
if (errors.length) {
|
|
@@ -128357,16 +128444,16 @@ var StandardLink = class {
|
|
|
128357
128444
|
/**
|
|
128358
128445
|
* @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
|
|
128359
128446
|
*/
|
|
128360
|
-
call(
|
|
128361
|
-
return runWithSpan(`${ORPC_NAME}.${
|
|
128447
|
+
call(path71, input2, options) {
|
|
128448
|
+
return runWithSpan(`${ORPC_NAME}.${path71.join("/")}`, (span) => {
|
|
128362
128449
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
128363
|
-
span?.setAttribute("rpc.method",
|
|
128450
|
+
span?.setAttribute("rpc.method", path71.join("."));
|
|
128364
128451
|
if (getTracer() && isAsyncIteratorObject(input2)) {
|
|
128365
128452
|
input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
|
|
128366
128453
|
} else if (getTracer() && input2 instanceof ReadableStream) {
|
|
128367
128454
|
input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
|
|
128368
128455
|
}
|
|
128369
|
-
return intercept(this.interceptors, { ...options, path:
|
|
128456
|
+
return intercept(this.interceptors, { ...options, path: path71, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
128370
128457
|
const tracer = getTracer();
|
|
128371
128458
|
const activeSpan = tracer?.getActiveSpan() ?? span;
|
|
128372
128459
|
let request7 = await runWithSpan(
|
|
@@ -128423,18 +128510,18 @@ var RPCLinkCodec = class {
|
|
|
128423
128510
|
this.headers = options.headers ?? {};
|
|
128424
128511
|
this.serializer = options.serializer ?? new RPCSerializer();
|
|
128425
128512
|
}
|
|
128426
|
-
async encodeInput(input2,
|
|
128427
|
-
let headers = toResolvedStandardHeaders(await value(this.headers, options,
|
|
128513
|
+
async encodeInput(input2, path71, options) {
|
|
128514
|
+
let headers = toResolvedStandardHeaders(await value(this.headers, options, path71, input2));
|
|
128428
128515
|
if (options.lastEventId !== void 0) {
|
|
128429
128516
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
128430
128517
|
}
|
|
128431
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
128432
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
128518
|
+
const expectedMethod = await value(this.expectedMethod, options, path71, input2);
|
|
128519
|
+
const baseUrl = await value(this.baseUrl, options, path71, input2);
|
|
128433
128520
|
const [pathname, search, hash2] = parseStandardUrl(baseUrl);
|
|
128434
|
-
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(
|
|
128521
|
+
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path71)}`;
|
|
128435
128522
|
const serialized = this.serializer.serialize(input2);
|
|
128436
128523
|
if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
128437
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
128524
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path71, input2);
|
|
128438
128525
|
const mergedSearch = new URLSearchParams(search);
|
|
128439
128526
|
mergedSearch.append("data", stringifyJSON(serialized) ?? "");
|
|
128440
128527
|
const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
|
|
@@ -128519,8 +128606,8 @@ var FetchLinkTransport = class {
|
|
|
128519
128606
|
this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
|
|
128520
128607
|
this.toFetchRequestOptions = options.toFetchRequest;
|
|
128521
128608
|
}
|
|
128522
|
-
async send(standardRequest,
|
|
128523
|
-
let origin = await value(this.origin, options,
|
|
128609
|
+
async send(standardRequest, path71, options) {
|
|
128610
|
+
let origin = await value(this.origin, options, path71);
|
|
128524
128611
|
if (origin?.endsWith("/")) {
|
|
128525
128612
|
origin = origin.slice(0, -1);
|
|
128526
128613
|
}
|
|
@@ -128540,7 +128627,7 @@ var FetchLinkTransport = class {
|
|
|
128540
128627
|
}
|
|
128541
128628
|
}
|
|
128542
128629
|
const fetch3 = this.fetch;
|
|
128543
|
-
const response = await fetch3(url2, init, options,
|
|
128630
|
+
const response = await fetch3(url2, init, options, path71);
|
|
128544
128631
|
const standardResponse = toStandardLazyResponse(response);
|
|
128545
128632
|
return standardResponse;
|
|
128546
128633
|
}
|
|
@@ -128931,14 +129018,14 @@ var StandardHandler = class {
|
|
|
128931
129018
|
span?.setAttribute("url.path", request22.url);
|
|
128932
129019
|
return { matched: false };
|
|
128933
129020
|
}
|
|
128934
|
-
const { path:
|
|
128935
|
-
span?.updateName(`${ORPC_NAME}.${
|
|
129021
|
+
const { path: path71, procedure, decodeInput } = matchedOrNot;
|
|
129022
|
+
span?.updateName(`${ORPC_NAME}.${path71.join("/")}`);
|
|
128936
129023
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
128937
|
-
span?.setAttribute("rpc.method",
|
|
129024
|
+
span?.setAttribute("rpc.method", path71.join("."));
|
|
128938
129025
|
try {
|
|
128939
129026
|
const response = await intercept(
|
|
128940
129027
|
this.interceptors,
|
|
128941
|
-
{ context: context2, prefix: prefix2, request: request22, path:
|
|
129028
|
+
{ context: context2, prefix: prefix2, request: request22, path: path71, procedure, decodeInput },
|
|
128942
129029
|
async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
|
|
128943
129030
|
step2 = "decode_input";
|
|
128944
129031
|
let input2 = await runWithSpan("decode_input", decodeInput2);
|
|
@@ -128972,7 +129059,7 @@ var StandardHandler = class {
|
|
|
128972
129059
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
128973
129060
|
cause: e14
|
|
128974
129061
|
}) : toORPCError(e14);
|
|
128975
|
-
const response = await this.codec.encodeError(error63, procedure,
|
|
129062
|
+
const response = await this.codec.encodeError(error63, procedure, path71, { context: context2, prefix: prefix2 });
|
|
128976
129063
|
return { matched: true, response };
|
|
128977
129064
|
}
|
|
128978
129065
|
}
|
|
@@ -129078,7 +129165,7 @@ var RPCMatcher = class {
|
|
|
129078
129165
|
this.rootRouter = router;
|
|
129079
129166
|
this.index(router);
|
|
129080
129167
|
}
|
|
129081
|
-
index(router,
|
|
129168
|
+
index(router, path71 = []) {
|
|
129082
129169
|
const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
|
|
129083
129170
|
if (!value(this.filter, procedure, procedurePath)) {
|
|
129084
129171
|
return;
|
|
@@ -129089,7 +129176,7 @@ var RPCMatcher = class {
|
|
|
129089
129176
|
// contract-first entries have no implementation yet, resolveProcedure fills it in on demand
|
|
129090
129177
|
procedure: procedure instanceof Procedure ? procedure : void 0
|
|
129091
129178
|
});
|
|
129092
|
-
},
|
|
129179
|
+
}, path71);
|
|
129093
129180
|
for (const result of lazyResults) {
|
|
129094
129181
|
this.pendingLazyRouters.set(pathToHttpPath(result.path), result);
|
|
129095
129182
|
}
|
|
@@ -129221,10 +129308,10 @@ var RPCHandlerCodec = class {
|
|
|
129221
129308
|
}
|
|
129222
129309
|
};
|
|
129223
129310
|
}
|
|
129224
|
-
encodeOutput(output2, procedure,
|
|
129311
|
+
encodeOutput(output2, procedure, path71, options) {
|
|
129225
129312
|
return {
|
|
129226
129313
|
headers: {},
|
|
129227
|
-
status: value(this.outputStatus, output2, procedure,
|
|
129314
|
+
status: value(this.outputStatus, output2, procedure, path71, options) ?? DEFAULT_SUCCESS_STATUS,
|
|
129228
129315
|
body: this.serializer.serialize(output2)
|
|
129229
129316
|
};
|
|
129230
129317
|
}
|
|
@@ -129278,39 +129365,39 @@ function createRouter() {
|
|
|
129278
129365
|
static: new NullProtoObj2()
|
|
129279
129366
|
};
|
|
129280
129367
|
}
|
|
129281
|
-
function scanFirstGroup(
|
|
129368
|
+
function scanFirstGroup(path71) {
|
|
129282
129369
|
let i10 = 0;
|
|
129283
129370
|
let depth = 0;
|
|
129284
|
-
for (; i10 <
|
|
129285
|
-
const c10 =
|
|
129371
|
+
for (; i10 < path71.length; i10++) {
|
|
129372
|
+
const c10 = path71.charCodeAt(i10);
|
|
129286
129373
|
if (c10 === 92) i10++;
|
|
129287
129374
|
else if (c10 === 40) depth++;
|
|
129288
129375
|
else if (c10 === 41 && depth > 0) depth--;
|
|
129289
129376
|
else if (c10 === 123 && depth === 0) break;
|
|
129290
129377
|
}
|
|
129291
|
-
if (i10 >=
|
|
129378
|
+
if (i10 >= path71.length) return;
|
|
129292
129379
|
let j10 = i10 + 1;
|
|
129293
129380
|
depth = 0;
|
|
129294
|
-
for (; j10 <
|
|
129295
|
-
const c10 =
|
|
129381
|
+
for (; j10 < path71.length; j10++) {
|
|
129382
|
+
const c10 = path71.charCodeAt(j10);
|
|
129296
129383
|
if (c10 === 92) j10++;
|
|
129297
129384
|
else if (c10 === 40) depth++;
|
|
129298
129385
|
else if (c10 === 41 && depth > 0) depth--;
|
|
129299
129386
|
else if (c10 === 125 && depth === 0) break;
|
|
129300
129387
|
}
|
|
129301
|
-
if (j10 >=
|
|
129302
|
-
const mod =
|
|
129388
|
+
if (j10 >= path71.length) return;
|
|
129389
|
+
const mod = path71[j10 + 1];
|
|
129303
129390
|
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
129304
129391
|
return [
|
|
129305
|
-
|
|
129306
|
-
|
|
129307
|
-
|
|
129392
|
+
path71.slice(0, i10),
|
|
129393
|
+
path71.slice(i10 + 1, j10),
|
|
129394
|
+
path71.slice(j10 + (hasMod ? 2 : 1)),
|
|
129308
129395
|
hasMod ? mod : void 0
|
|
129309
129396
|
];
|
|
129310
129397
|
}
|
|
129311
|
-
function expandGroupDelimiters(
|
|
129312
|
-
if (!
|
|
129313
|
-
const group = scanFirstGroup(
|
|
129398
|
+
function expandGroupDelimiters(path71) {
|
|
129399
|
+
if (!path71.includes("{")) return;
|
|
129400
|
+
const group = scanFirstGroup(path71);
|
|
129314
129401
|
if (!group) return;
|
|
129315
129402
|
const [pre2, body, suf, mod] = group;
|
|
129316
129403
|
if (!mod) return [pre2 + body + suf];
|
|
@@ -129380,9 +129467,9 @@ function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGr
|
|
|
129380
129467
|
}
|
|
129381
129468
|
return [replaced, nextIndex];
|
|
129382
129469
|
}
|
|
129383
|
-
function encodeEscapes(
|
|
129384
|
-
if (!
|
|
129385
|
-
return
|
|
129470
|
+
function encodeEscapes(path71) {
|
|
129471
|
+
if (!path71.includes("\\")) return path71;
|
|
129472
|
+
return path71.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
|
|
129386
129473
|
}
|
|
129387
129474
|
function segmentKey(segment) {
|
|
129388
129475
|
if (segment.startsWith("**")) return 2;
|
|
@@ -129411,22 +129498,22 @@ function expandModifiers(segments) {
|
|
|
129411
129498
|
return m10[2] === "+" ? [wc2] : [wc2, without];
|
|
129412
129499
|
}
|
|
129413
129500
|
}
|
|
129414
|
-
function normalizePath(
|
|
129415
|
-
if (!
|
|
129501
|
+
function normalizePath(path71) {
|
|
129502
|
+
if (!path71.includes("/.")) return path71;
|
|
129416
129503
|
const r10 = [];
|
|
129417
|
-
for (const s of
|
|
129504
|
+
for (const s of path71.split("/")) if (s === ".") continue;
|
|
129418
129505
|
else if (s === ".." && r10.length > 1) r10.pop();
|
|
129419
129506
|
else r10.push(s);
|
|
129420
129507
|
return r10.join("/") || "/";
|
|
129421
129508
|
}
|
|
129422
|
-
function splitPath(
|
|
129423
|
-
const s =
|
|
129509
|
+
function splitPath(path71) {
|
|
129510
|
+
const s = path71.split("/");
|
|
129424
129511
|
s.shift();
|
|
129425
129512
|
if (s[s.length - 1] === "") s.pop();
|
|
129426
129513
|
return s;
|
|
129427
129514
|
}
|
|
129428
|
-
function splitRoute(
|
|
129429
|
-
const s = splitPath(
|
|
129515
|
+
function splitRoute(path71) {
|
|
129516
|
+
const s = splitPath(path71);
|
|
129430
129517
|
while (s[s.length - 1] === "") s.pop();
|
|
129431
129518
|
return s;
|
|
129432
129519
|
}
|
|
@@ -129442,16 +129529,16 @@ function getMatchParams(segments, paramsMap) {
|
|
|
129442
129529
|
}
|
|
129443
129530
|
return params;
|
|
129444
129531
|
}
|
|
129445
|
-
function addRoute(ctx, method = "",
|
|
129532
|
+
function addRoute(ctx, method = "", path71, data) {
|
|
129446
129533
|
method = method.toUpperCase();
|
|
129447
|
-
if (
|
|
129448
|
-
const groupExpanded = expandGroupDelimiters(
|
|
129534
|
+
if (path71.charCodeAt(0) !== 47) path71 = `/${path71}`;
|
|
129535
|
+
const groupExpanded = expandGroupDelimiters(path71);
|
|
129449
129536
|
if (groupExpanded) {
|
|
129450
129537
|
for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
|
|
129451
129538
|
return;
|
|
129452
129539
|
}
|
|
129453
|
-
|
|
129454
|
-
const segments = splitRoute(
|
|
129540
|
+
path71 = encodeEscapes(path71);
|
|
129541
|
+
const segments = splitRoute(path71);
|
|
129455
129542
|
const expanded = expandModifiers(segments);
|
|
129456
129543
|
if (expanded) {
|
|
129457
129544
|
for (const p of expanded) addRoute(ctx, method, p, data);
|
|
@@ -129542,15 +129629,15 @@ function getParamRegexp(segment, unnamedStart = 0) {
|
|
|
129542
129629
|
const regex2 = _s2.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id2, p) => `(?<${toGroupName(id2)}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i2++)}>`).replace(/\uFFFE(.)/g, (_, c10) => /[.*+?^${}()|[\]\\]/.test(c10) ? `\\${c10}` : c10);
|
|
129543
129630
|
return [new RegExp(`^${regex2}$`), _i2];
|
|
129544
129631
|
}
|
|
129545
|
-
function findRoute(ctx, method = "",
|
|
129546
|
-
if (opts?.normalize)
|
|
129547
|
-
if (
|
|
129548
|
-
const staticNode = ctx.static[
|
|
129632
|
+
function findRoute(ctx, method = "", path71, opts) {
|
|
129633
|
+
if (opts?.normalize) path71 = normalizePath(path71);
|
|
129634
|
+
if (path71.charCodeAt(path71.length - 1) === 47) path71 = path71.slice(0, -1);
|
|
129635
|
+
const staticNode = ctx.static[path71];
|
|
129549
129636
|
if (staticNode && staticNode.methods) {
|
|
129550
129637
|
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
129551
129638
|
if (staticMatch !== void 0) return staticMatch[0];
|
|
129552
129639
|
}
|
|
129553
|
-
const segments = splitPath(
|
|
129640
|
+
const segments = splitPath(path71);
|
|
129554
129641
|
const match = _lookupTree(ctx.root, method, segments, 0);
|
|
129555
129642
|
if (match === void 0) return;
|
|
129556
129643
|
if (opts?.params === false) return match;
|
|
@@ -129750,7 +129837,7 @@ var OpenAPIMatcher = class {
|
|
|
129750
129837
|
this.rootRouter = router;
|
|
129751
129838
|
this.index(router);
|
|
129752
129839
|
}
|
|
129753
|
-
index(router,
|
|
129840
|
+
index(router, path71 = []) {
|
|
129754
129841
|
const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
|
|
129755
129842
|
if (!value(this.filter, contract, path210)) {
|
|
129756
129843
|
return;
|
|
@@ -129765,7 +129852,7 @@ var OpenAPIMatcher = class {
|
|
|
129765
129852
|
contract,
|
|
129766
129853
|
procedure: contract instanceof Procedure ? contract : void 0
|
|
129767
129854
|
});
|
|
129768
|
-
},
|
|
129855
|
+
}, path71);
|
|
129769
129856
|
for (const result of lazyResults) {
|
|
129770
129857
|
const prefix = getOpenAPIMeta(result.router)?.prefix;
|
|
129771
129858
|
this.pendingLazyRouters.add({
|
|
@@ -129852,20 +129939,20 @@ var OpenAPIMatcher = class {
|
|
|
129852
129939
|
return entry.procedure;
|
|
129853
129940
|
}
|
|
129854
129941
|
};
|
|
129855
|
-
function toRou3Pattern(
|
|
129856
|
-
const params = getDynamicPathParams(
|
|
129942
|
+
function toRou3Pattern(path71) {
|
|
129943
|
+
const params = getDynamicPathParams(path71);
|
|
129857
129944
|
if (!params?.length) {
|
|
129858
|
-
return
|
|
129945
|
+
return path71;
|
|
129859
129946
|
}
|
|
129860
129947
|
for (let i10 = params.length - 1; i10 >= 0; i10--) {
|
|
129861
129948
|
const param = params[i10];
|
|
129862
129949
|
const pattern = param.allowsSlash ? `**:${param.parameterName}` : `:${param.parameterName}`;
|
|
129863
|
-
|
|
129950
|
+
path71 = path71.slice(0, param.startIndex) + pattern + path71.slice(param.startIndex + param.segment.length);
|
|
129864
129951
|
}
|
|
129865
|
-
return
|
|
129952
|
+
return path71;
|
|
129866
129953
|
}
|
|
129867
|
-
function toRou3PrefixMatcher(
|
|
129868
|
-
const pattern = toRou3Pattern(
|
|
129954
|
+
function toRou3PrefixMatcher(path71) {
|
|
129955
|
+
const pattern = toRou3Pattern(path71);
|
|
129869
129956
|
return routeToRegExp(pattern === "/" ? "/**" : `${pattern}/**`);
|
|
129870
129957
|
}
|
|
129871
129958
|
function decodeParams(params) {
|
|
@@ -129944,7 +130031,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
129944
130031
|
/**
|
|
129945
130032
|
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
129946
130033
|
*/
|
|
129947
|
-
encodeOutput(output2, procedure,
|
|
130034
|
+
encodeOutput(output2, procedure, path71) {
|
|
129948
130035
|
const meta3 = getOpenAPIMeta(procedure);
|
|
129949
130036
|
const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
|
|
129950
130037
|
const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
|
|
@@ -129957,7 +130044,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
129957
130044
|
}
|
|
129958
130045
|
if (!isValidDetailedOutput(output2)) {
|
|
129959
130046
|
throw new TypeError(`
|
|
129960
|
-
Invalid "detailed" output structure returned by procedure (${
|
|
130047
|
+
Invalid "detailed" output structure returned by procedure (${path71.join(".")}):
|
|
129961
130048
|
\u2022 Expected an object with optional properties:
|
|
129962
130049
|
- status (number <400)
|
|
129963
130050
|
- headers (object)
|
|
@@ -130525,7 +130612,7 @@ function profileValue(name, paths) {
|
|
|
130525
130612
|
function createConfigApiRouter(deps) {
|
|
130526
130613
|
const authed = doorApiAuth(deps.expectedToken);
|
|
130527
130614
|
const { paths } = deps;
|
|
130528
|
-
const route = (
|
|
130615
|
+
const route = (path71, summary) => authed.meta(openapi({ method: "POST", path: path71, summary, tags: [CONFIG_API_TAG] }));
|
|
130529
130616
|
return {
|
|
130530
130617
|
config: {
|
|
130531
130618
|
identity: {
|
|
@@ -130956,9 +131043,9 @@ function createLaunchApiRouter(deps) {
|
|
|
130956
131043
|
// A POST because the launch's environment and arguments are a body, but the answer changes nothing.
|
|
130957
131044
|
spec: (current) => ({ ...current, [READ_ONLY_OPERATION_EXTENSION]: true })
|
|
130958
131045
|
})
|
|
130959
|
-
).input(LaunchResolveInputSchema).output(LaunchResolveOutputSchema).handler(({ input: input2 }) => {
|
|
131046
|
+
).input(LaunchResolveInputSchema).output(LaunchResolveOutputSchema).handler(async ({ input: input2 }) => {
|
|
130960
131047
|
try {
|
|
130961
|
-
const { resolution, warnings } = deps.resolveLaunch({ path: input2.path, argv: input2.argv ?? [], env: input2.env ?? {} });
|
|
131048
|
+
const { resolution, warnings } = await deps.resolveLaunch({ path: input2.path, argv: input2.argv ?? [], env: input2.env ?? {} });
|
|
130962
131049
|
return { ...resolution, warnings };
|
|
130963
131050
|
} catch (error63) {
|
|
130964
131051
|
if (error63 instanceof CliError) {
|
|
@@ -131330,6 +131417,9 @@ function createLaunchEventPublisher(hub, now) {
|
|
|
131330
131417
|
};
|
|
131331
131418
|
}
|
|
131332
131419
|
|
|
131420
|
+
// src/frontdoor/pipeline.ts
|
|
131421
|
+
init_schema2();
|
|
131422
|
+
|
|
131333
131423
|
// src/frontdoor/headroomHop.ts
|
|
131334
131424
|
var http4 = __toESM(require("node:http"), 1);
|
|
131335
131425
|
var import_consumers = require("node:stream/consumers");
|
|
@@ -131530,11 +131620,11 @@ function lineageOf(body) {
|
|
|
131530
131620
|
if (body.length > LINEAGE_BODY_BYTES_LIMIT) {
|
|
131531
131621
|
return void 0;
|
|
131532
131622
|
}
|
|
131533
|
-
const
|
|
131534
|
-
if (
|
|
131623
|
+
const counted2 = walk2(body, false, void 0);
|
|
131624
|
+
if (counted2.abandoned || !counted2.sawMessages) {
|
|
131535
131625
|
return void 0;
|
|
131536
131626
|
}
|
|
131537
|
-
const parentAfter =
|
|
131627
|
+
const parentAfter = counted2.elements > MESSAGES_PER_TURN ? counted2.elements - MESSAGES_PER_TURN : void 0;
|
|
131538
131628
|
const hashed = walk2(body, true, parentAfter);
|
|
131539
131629
|
const combine = (messagesDigest) => (0, import_node_crypto22.createHash)("sha256").update(hashed.threadDigest).update(messagesDigest).digest("hex");
|
|
131540
131630
|
return { ownKey: combine(hashed.messagesDigest), parentKey: hashed.parentDigest === void 0 ? void 0 : combine(hashed.parentDigest) };
|
|
@@ -131780,6 +131870,10 @@ function errorTypeFor(status) {
|
|
|
131780
131870
|
function errorBody(status, message) {
|
|
131781
131871
|
return JSON.stringify({ type: "error", error: { type: errorTypeFor(status), message } });
|
|
131782
131872
|
}
|
|
131873
|
+
function clientSessionIdOf(headers) {
|
|
131874
|
+
const value2 = headers[CLIENT_SESSION_HEADER];
|
|
131875
|
+
return typeof value2 === "string" && CLIENT_SESSION_ID_PATTERN.test(value2) ? value2 : void 0;
|
|
131876
|
+
}
|
|
131783
131877
|
function pathOf(url2) {
|
|
131784
131878
|
const query = url2.indexOf("?");
|
|
131785
131879
|
return query === -1 ? url2 : url2.slice(0, query);
|
|
@@ -131834,7 +131928,7 @@ function createRoutedResponse(response, context) {
|
|
|
131834
131928
|
start: (status, headers) => {
|
|
131835
131929
|
for (const observe of deps.responseObservers) {
|
|
131836
131930
|
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 });
|
|
131931
|
+
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
131932
|
if (body !== void 0) {
|
|
131839
131933
|
bodyObservers.push(body);
|
|
131840
131934
|
}
|
|
@@ -131879,7 +131973,7 @@ function createRoutedResponse(response, context) {
|
|
|
131879
131973
|
}
|
|
131880
131974
|
async function serveRouted(incoming, deps) {
|
|
131881
131975
|
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 } };
|
|
131976
|
+
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
131977
|
const identity = identifyRequest(request7.headers);
|
|
131884
131978
|
const identified = { ...identity, session: { ...identity.session, provider: identity.session.provider === void 0 ? void 0 : deps.canonicalProvider(identity.session.provider) } };
|
|
131885
131979
|
const admission = deps.admit({ url: request7.url, headers: request7.headers, forwardable: identified.forwardableHeaders });
|
|
@@ -132545,8 +132639,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
132545
132639
|
request7.body.resume();
|
|
132546
132640
|
return;
|
|
132547
132641
|
}
|
|
132548
|
-
const
|
|
132549
|
-
const translated = { method: request7.method, path:
|
|
132642
|
+
const path71 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
132643
|
+
const translated = { method: request7.method, path: path71, body, signal: request7.signal };
|
|
132550
132644
|
const routed = await route(translated);
|
|
132551
132645
|
if (request7.signal.aborted) {
|
|
132552
132646
|
return;
|
|
@@ -132743,7 +132837,7 @@ init_translate();
|
|
|
132743
132837
|
init_cloudUpstream();
|
|
132744
132838
|
|
|
132745
132839
|
// src/antigravity/localUpstream.ts
|
|
132746
|
-
var
|
|
132840
|
+
var import_node_child_process7 = require("node:child_process");
|
|
132747
132841
|
var import_node_net2 = __toESM(require("node:net"), 1);
|
|
132748
132842
|
var import_node_readline2 = __toESM(require("node:readline"), 1);
|
|
132749
132843
|
init_zod();
|
|
@@ -132768,7 +132862,7 @@ function spawnProcess(command, signal) {
|
|
|
132768
132862
|
throw new Error("ACP command cannot be empty");
|
|
132769
132863
|
}
|
|
132770
132864
|
const args = command.slice(1);
|
|
132771
|
-
const proc = (0,
|
|
132865
|
+
const proc = (0, import_node_child_process7.spawn)(bin, args, {
|
|
132772
132866
|
stdio: ["pipe", "pipe", "inherit"],
|
|
132773
132867
|
signal
|
|
132774
132868
|
});
|
|
@@ -133167,8 +133261,8 @@ function createAntigravityRouteMount(ports, upstreamBase, provider) {
|
|
|
133167
133261
|
request7.body.resume();
|
|
133168
133262
|
return;
|
|
133169
133263
|
}
|
|
133170
|
-
const
|
|
133171
|
-
const translated = { method: request7.method, path:
|
|
133264
|
+
const path71 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133265
|
+
const translated = { method: request7.method, path: path71, body, signal: request7.signal };
|
|
133172
133266
|
const routed = await route(translated);
|
|
133173
133267
|
if (request7.signal.aborted) {
|
|
133174
133268
|
return;
|
|
@@ -133209,7 +133303,7 @@ function createPassthroughRoute(name, target) {
|
|
|
133209
133303
|
headroomUpstream: target.headroomUpstream,
|
|
133210
133304
|
serve: async (request7, response) => {
|
|
133211
133305
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
133212
|
-
const
|
|
133306
|
+
const path71 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
133213
133307
|
const headers = forwardableHeaders(request7.headers);
|
|
133214
133308
|
delete headers.host;
|
|
133215
133309
|
await new Promise((resolve2) => {
|
|
@@ -133217,7 +133311,7 @@ function createPassthroughRoute(name, target) {
|
|
|
133217
133311
|
host: base.hostname,
|
|
133218
133312
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
133219
133313
|
method: request7.method,
|
|
133220
|
-
path: `${basePath}${
|
|
133314
|
+
path: `${basePath}${path71}${incoming.search}`,
|
|
133221
133315
|
headers,
|
|
133222
133316
|
agent
|
|
133223
133317
|
};
|
|
@@ -133389,13 +133483,13 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
133389
133483
|
}
|
|
133390
133484
|
|
|
133391
133485
|
// src/frontdoor/providerRoute.ts
|
|
133392
|
-
var isRcSelfHostPath = (
|
|
133486
|
+
var isRcSelfHostPath = (path71) => path71 === "/v1/code/sessions" || path71.startsWith("/v1/code/sessions/") || path71 === "/v1/sessions" || path71.startsWith("/v1/sessions/");
|
|
133393
133487
|
function scopeSessionProviderPath(request7) {
|
|
133394
133488
|
if (request7.session.provider === void 0) {
|
|
133395
133489
|
return request7;
|
|
133396
133490
|
}
|
|
133397
|
-
const
|
|
133398
|
-
if (!
|
|
133491
|
+
const path71 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133492
|
+
if (!path71.startsWith("/v1/") || isRcSelfHostPath(path71)) {
|
|
133399
133493
|
return request7;
|
|
133400
133494
|
}
|
|
133401
133495
|
return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
|
|
@@ -133519,13 +133613,13 @@ function createProviderRouteResolver(deps) {
|
|
|
133519
133613
|
return route;
|
|
133520
133614
|
};
|
|
133521
133615
|
const resolve2 = (request7) => {
|
|
133522
|
-
const
|
|
133523
|
-
const scoped = parseProviderPath(
|
|
133616
|
+
const path71 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
133617
|
+
const scoped = parseProviderPath(path71);
|
|
133524
133618
|
if (scoped === void 0) {
|
|
133525
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
133619
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path71)) {
|
|
133526
133620
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
133527
133621
|
}
|
|
133528
|
-
return
|
|
133622
|
+
return path71.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path71}` };
|
|
133529
133623
|
}
|
|
133530
133624
|
const { provider } = scoped;
|
|
133531
133625
|
let definition;
|
|
@@ -133617,8 +133711,8 @@ function createProviderRouteResolver(deps) {
|
|
|
133617
133711
|
let modelChoice;
|
|
133618
133712
|
const visited = /* @__PURE__ */ new Set();
|
|
133619
133713
|
for (; ; ) {
|
|
133620
|
-
const
|
|
133621
|
-
const scoped = parseProviderPath(
|
|
133714
|
+
const path71 = new URL(current.url, "http://127.0.0.1").pathname;
|
|
133715
|
+
const scoped = parseProviderPath(path71);
|
|
133622
133716
|
const providerName = scoped?.provider ?? current.session.provider;
|
|
133623
133717
|
if (providerName !== void 0 && visited.has(providerName)) {
|
|
133624
133718
|
return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
|
|
@@ -133633,7 +133727,7 @@ function createProviderRouteResolver(deps) {
|
|
|
133633
133727
|
} catch {
|
|
133634
133728
|
routes = void 0;
|
|
133635
133729
|
}
|
|
133636
|
-
const resolvesNames = !nameResolved && !isRcSelfHostPath(
|
|
133730
|
+
const resolvesNames = !nameResolved && !isRcSelfHostPath(path71);
|
|
133637
133731
|
if (resolvesNames) {
|
|
133638
133732
|
const scan2 = await scanRequestHead(current, true);
|
|
133639
133733
|
if (scan2.replayed === void 0) {
|
|
@@ -133672,7 +133766,7 @@ function createProviderRouteResolver(deps) {
|
|
|
133672
133766
|
}
|
|
133673
133767
|
if (routed.provider !== providerName) {
|
|
133674
133768
|
const scopedPrefix = providerName === void 0 ? void 0 : `${PROVIDER_PATH_PREFIX}${encodeURIComponent(providerName)}`;
|
|
133675
|
-
const rest2 = scopedPrefix !== void 0 &&
|
|
133769
|
+
const rest2 = scopedPrefix !== void 0 && path71.startsWith(scopedPrefix) ? path71.slice(scopedPrefix.length) : path71;
|
|
133676
133770
|
const query2 = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
133677
133771
|
const carried = replay;
|
|
133678
133772
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(routed.provider)}${rest2}${query2}`, body: carried.body, headers: carried.headers };
|
|
@@ -133726,7 +133820,7 @@ function createProviderRouteResolver(deps) {
|
|
|
133726
133820
|
const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
133727
133821
|
replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
|
|
133728
133822
|
}
|
|
133729
|
-
const rest = scoped === void 0 ?
|
|
133823
|
+
const rest = scoped === void 0 ? path71 : path71.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
|
|
133730
133824
|
const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
133731
133825
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
|
|
133732
133826
|
}
|
|
@@ -137109,7 +137203,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, retire, trackTun
|
|
|
137109
137203
|
},
|
|
137110
137204
|
poolNames: () => Object.keys(readPools(paths)).sort(),
|
|
137111
137205
|
// A read-only resolution of what a launch from one directory would do: the launcher's own decision with its effects left out, so a read never recovers or resyncs a farm, starts a daemon, records a pool pick or runs a credential command.
|
|
137112
|
-
resolveLaunch: (request7) =>
|
|
137206
|
+
resolveLaunch: async (request7) => resolveClaudeLaunchAsync({ argv: request7.argv, cwd: request7.path, env: request7.env, paths }),
|
|
137113
137207
|
// The identities are read per call, like the pool table, so an identity added after the door started is listed the moment the CLI would see it.
|
|
137114
137208
|
sessionList: (filters) => collectSessionList(realSessionFs, paths.identitiesDir, listIdentities(paths).map((entry) => entry.name), { ...filters.identity === void 0 ? {} : { identity: filters.identity }, ...filters.all === void 0 ? {} : { all: filters.all } }),
|
|
137115
137209
|
liveTasks: () => rcTracker.liveTasksOf(),
|
|
@@ -137361,7 +137455,7 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
137361
137455
|
// src/statusline/commands.ts
|
|
137362
137456
|
var import_node_child_process8 = require("node:child_process");
|
|
137363
137457
|
var import_node_os13 = __toESM(require("node:os"), 1);
|
|
137364
|
-
var
|
|
137458
|
+
var import_node_path61 = __toESM(require("node:path"), 1);
|
|
137365
137459
|
init_commandDeps();
|
|
137366
137460
|
init_statusline();
|
|
137367
137461
|
init_providersStore();
|
|
@@ -137603,7 +137697,8 @@ function enrichStatuslinePayload(params) {
|
|
|
137603
137697
|
quotaFamilies: [],
|
|
137604
137698
|
headroom: params.headroom,
|
|
137605
137699
|
routedTarget: params.routedTarget,
|
|
137606
|
-
...params.modelChoice === void 0 ? {} : { modelChoice: params.modelChoice }
|
|
137700
|
+
...params.modelChoice === void 0 ? {} : { modelChoice: params.modelChoice },
|
|
137701
|
+
...params.doorCostUsd === void 0 ? {} : { doorCostUsd: params.doorCostUsd }
|
|
137607
137702
|
};
|
|
137608
137703
|
if (params.snapshot !== void 0) {
|
|
137609
137704
|
const scopedName = providerScopedState(params.snapshot, params.providerName, params.env.AGENT_SHIM_PROVIDER);
|
|
@@ -137679,6 +137774,77 @@ function providerScopedState(snapshot, providerName, providerDisplayName) {
|
|
|
137679
137774
|
|
|
137680
137775
|
// src/statusline/commands.ts
|
|
137681
137776
|
init_read();
|
|
137777
|
+
init_modelsStore();
|
|
137778
|
+
|
|
137779
|
+
// src/statusline/doorCost.ts
|
|
137780
|
+
init_read();
|
|
137781
|
+
|
|
137782
|
+
// src/statusline/cost.ts
|
|
137783
|
+
var TOKENS_PER_MILLION = 1e6;
|
|
137784
|
+
var CACHE_WRITE_PRICE_RATIO = 1.25;
|
|
137785
|
+
var CACHE_READ_PRICE_RATIO = 0.1;
|
|
137786
|
+
function doorCostUsdOf(records, prices) {
|
|
137787
|
+
let totalUsd = 0;
|
|
137788
|
+
let costed = 0;
|
|
137789
|
+
for (const record2 of records) {
|
|
137790
|
+
const { usage } = record2;
|
|
137791
|
+
if (usage === void 0) {
|
|
137792
|
+
continue;
|
|
137793
|
+
}
|
|
137794
|
+
const price = record2.model === void 0 ? void 0 : prices[`${record2.provider}/${record2.model}`];
|
|
137795
|
+
if (price === void 0) {
|
|
137796
|
+
return void 0;
|
|
137797
|
+
}
|
|
137798
|
+
const inputUsd = ((usage.inputTokens ?? 0) + (usage.cacheCreationInputTokens ?? 0) * CACHE_WRITE_PRICE_RATIO + (usage.cacheReadInputTokens ?? 0) * CACHE_READ_PRICE_RATIO) * price.input;
|
|
137799
|
+
totalUsd += (inputUsd + (usage.outputTokens ?? 0) * price.output) / TOKENS_PER_MILLION;
|
|
137800
|
+
costed += 1;
|
|
137801
|
+
}
|
|
137802
|
+
return costed === 0 ? void 0 : totalUsd;
|
|
137803
|
+
}
|
|
137804
|
+
function isCloudModelId(modelId) {
|
|
137805
|
+
return modelId !== void 0 && (modelId.toLowerCase().includes("anthropic.claude-") || modelId.includes("@"));
|
|
137806
|
+
}
|
|
137807
|
+
function isRoutedSession(summary, payload) {
|
|
137808
|
+
return summary.provider !== void 0 || isCloudModelId(payload.model?.id);
|
|
137809
|
+
}
|
|
137810
|
+
function resolveSessionCost({ summary, payload, settings: settings2 }) {
|
|
137811
|
+
const native = payload.cost?.total_cost_usd;
|
|
137812
|
+
const door = summary.doorCostUsd;
|
|
137813
|
+
if (!isRoutedSession(summary, payload)) {
|
|
137814
|
+
if (native !== void 0) {
|
|
137815
|
+
return { usd: native, source: "native" };
|
|
137816
|
+
}
|
|
137817
|
+
return door === void 0 ? void 0 : { usd: door, source: "estimate" };
|
|
137818
|
+
}
|
|
137819
|
+
if (!settings2.cost.routed) {
|
|
137820
|
+
return void 0;
|
|
137821
|
+
}
|
|
137822
|
+
if (door !== void 0) {
|
|
137823
|
+
return { usd: door, source: "estimate" };
|
|
137824
|
+
}
|
|
137825
|
+
return native !== void 0 && native > 0 ? { usd: native, source: "native" } : void 0;
|
|
137826
|
+
}
|
|
137827
|
+
var CENTS_FROM_USD = 1;
|
|
137828
|
+
var MILLS_FROM_USD = 0.1;
|
|
137829
|
+
var MILL_PLACES = 3;
|
|
137830
|
+
var FINE_PLACES = 4;
|
|
137831
|
+
function formatUsd(usd2) {
|
|
137832
|
+
if (usd2 >= CENTS_FROM_USD) {
|
|
137833
|
+
return `$${usd2.toFixed(2)}`;
|
|
137834
|
+
}
|
|
137835
|
+
return usd2 >= MILLS_FROM_USD ? `$${usd2.toFixed(MILL_PLACES)}` : `$${usd2.toFixed(FINE_PLACES)}`;
|
|
137836
|
+
}
|
|
137837
|
+
|
|
137838
|
+
// src/statusline/doorCost.ts
|
|
137839
|
+
function readDoorCostUsd(params) {
|
|
137840
|
+
const { nowMs, sessionDurationMs } = params;
|
|
137841
|
+
const sinceMs = sessionDurationMs === void 0 ? void 0 : Date.parse(`${segmentDay(nowMs - sessionDurationMs)}T00:00:00.000Z`);
|
|
137842
|
+
const { records } = readUsageLog(params.fs, params.logDir, sinceMs === void 0 ? {} : { sinceMs });
|
|
137843
|
+
return doorCostUsdOf(
|
|
137844
|
+
records.filter((record2) => record2.clientSessionId === params.conversationId),
|
|
137845
|
+
params.prices
|
|
137846
|
+
);
|
|
137847
|
+
}
|
|
137682
137848
|
|
|
137683
137849
|
// src/statusline/payload.ts
|
|
137684
137850
|
init_zod();
|
|
@@ -137731,24 +137897,93 @@ function viewOf(payload) {
|
|
|
137731
137897
|
}
|
|
137732
137898
|
|
|
137733
137899
|
// src/statusline/ports.ts
|
|
137734
|
-
|
|
137900
|
+
init_blockingSpawn();
|
|
137735
137901
|
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
137736
137902
|
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
137903
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
137904
|
+
|
|
137905
|
+
// src/statusline/memoryUse.ts
|
|
137906
|
+
var BYTES_PER_KIBIBYTE = 1024;
|
|
137907
|
+
var SMALLER_UNITS = ["B", "KB", "MB", "GB"];
|
|
137908
|
+
var LARGEST_UNIT = "TB";
|
|
137909
|
+
function formatBytes(bytes) {
|
|
137910
|
+
const firstWholeDigits = 10;
|
|
137911
|
+
let value2 = Math.max(0, bytes);
|
|
137912
|
+
for (const unit of SMALLER_UNITS) {
|
|
137913
|
+
if (value2 < BYTES_PER_KIBIBYTE) {
|
|
137914
|
+
return `${value2.toFixed(value2 >= firstWholeDigits || unit === "B" ? 0 : 1)} ${unit}`;
|
|
137915
|
+
}
|
|
137916
|
+
value2 /= BYTES_PER_KIBIBYTE;
|
|
137917
|
+
}
|
|
137918
|
+
return `${value2.toFixed(value2 >= firstWholeDigits ? 0 : 1)} ${LARGEST_UNIT}`;
|
|
137919
|
+
}
|
|
137920
|
+
function usedBytesFromVmStat(output2) {
|
|
137921
|
+
const pageSize = /page size of (\d+) bytes/.exec(output2)?.[1];
|
|
137922
|
+
const active = /Pages active:\s+(\d+)/.exec(output2)?.[1];
|
|
137923
|
+
const wired = /Pages wired down:\s+(\d+)/.exec(output2)?.[1];
|
|
137924
|
+
const compressed = /Pages occupied by compressor:\s+(\d+)/.exec(output2)?.[1];
|
|
137925
|
+
if (pageSize === void 0 || active === void 0 || wired === void 0 || compressed === void 0) {
|
|
137926
|
+
return void 0;
|
|
137927
|
+
}
|
|
137928
|
+
return (Number(active) + Number(wired) + Number(compressed)) * Number(pageSize);
|
|
137929
|
+
}
|
|
137930
|
+
function memoryUseFromMeminfo(text4) {
|
|
137931
|
+
const totalKibibytes = /^MemTotal:\s+(\d+)\s+kB/m.exec(text4)?.[1];
|
|
137932
|
+
const availableKibibytes = /^MemAvailable:\s+(\d+)\s+kB/m.exec(text4)?.[1];
|
|
137933
|
+
if (totalKibibytes === void 0 || availableKibibytes === void 0) {
|
|
137934
|
+
return void 0;
|
|
137935
|
+
}
|
|
137936
|
+
const totalBytes = Number(totalKibibytes) * BYTES_PER_KIBIBYTE;
|
|
137937
|
+
return { totalBytes, usedBytes: totalBytes - Number(availableKibibytes) * BYTES_PER_KIBIBYTE };
|
|
137938
|
+
}
|
|
137939
|
+
|
|
137940
|
+
// src/statusline/ports.ts
|
|
137737
137941
|
var RUN_TIMEOUT_MS = 2e3;
|
|
137738
137942
|
var RUN_MAX_BUFFER_BYTES = 1048576;
|
|
137739
|
-
function
|
|
137943
|
+
function runProgram(file2, args, cwd) {
|
|
137944
|
+
try {
|
|
137945
|
+
return execFileSyncBlocking("a statusline command", file2, args, { cwd, encoding: "utf8", timeout: RUN_TIMEOUT_MS, maxBuffer: RUN_MAX_BUFFER_BYTES, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
137946
|
+
} catch {
|
|
137947
|
+
return void 0;
|
|
137948
|
+
}
|
|
137949
|
+
}
|
|
137950
|
+
function readText(file2) {
|
|
137951
|
+
try {
|
|
137952
|
+
return import_node_fs22.default.readFileSync(file2, "utf8");
|
|
137953
|
+
} catch {
|
|
137954
|
+
return void 0;
|
|
137955
|
+
}
|
|
137956
|
+
}
|
|
137957
|
+
var STATE_FILE_MODE = 384;
|
|
137958
|
+
var STATE_DIRECTORY_MODE = 448;
|
|
137959
|
+
function discard(target) {
|
|
137960
|
+
try {
|
|
137961
|
+
import_node_fs22.default.rmSync(target, { force: true, recursive: true });
|
|
137962
|
+
} catch {
|
|
137963
|
+
return;
|
|
137964
|
+
}
|
|
137965
|
+
}
|
|
137966
|
+
function readMemoryUse() {
|
|
137967
|
+
const totalBytes = import_node_os12.default.totalmem();
|
|
137968
|
+
if (process.platform === "darwin") {
|
|
137969
|
+
const output2 = runProgram("/usr/bin/vm_stat", [], process.cwd());
|
|
137970
|
+
const usedBytes = output2 === void 0 ? void 0 : usedBytesFromVmStat(output2);
|
|
137971
|
+
return usedBytes === void 0 ? void 0 : { usedBytes, totalBytes };
|
|
137972
|
+
}
|
|
137973
|
+
if (process.platform === "linux") {
|
|
137974
|
+
const meminfo = readText("/proc/meminfo");
|
|
137975
|
+
return meminfo === void 0 ? void 0 : memoryUseFromMeminfo(meminfo);
|
|
137976
|
+
}
|
|
137977
|
+
return { usedBytes: totalBytes - import_node_os12.default.freemem(), totalBytes };
|
|
137978
|
+
}
|
|
137979
|
+
function realStatuslinePorts(env, stateDirectory) {
|
|
137740
137980
|
const { locale, timeZone } = Intl.DateTimeFormat().resolvedOptions();
|
|
137741
137981
|
return {
|
|
137742
137982
|
env,
|
|
137743
137983
|
homeDirectory: import_node_os12.default.homedir(),
|
|
137984
|
+
stateDirectory,
|
|
137744
137985
|
clock: { locale, timeZone },
|
|
137745
|
-
readText
|
|
137746
|
-
try {
|
|
137747
|
-
return import_node_fs22.default.readFileSync(path68, "utf8");
|
|
137748
|
-
} catch {
|
|
137749
|
-
return void 0;
|
|
137750
|
-
}
|
|
137751
|
-
},
|
|
137986
|
+
readText,
|
|
137752
137987
|
readRange: (file2, start, length) => {
|
|
137753
137988
|
try {
|
|
137754
137989
|
const descriptor = import_node_fs22.default.openSync(file2, "r");
|
|
@@ -137764,34 +137999,47 @@ function realStatuslinePorts(env) {
|
|
|
137764
137999
|
return void 0;
|
|
137765
138000
|
}
|
|
137766
138001
|
},
|
|
137767
|
-
run:
|
|
138002
|
+
run: runProgram,
|
|
138003
|
+
entryKind: (target) => {
|
|
137768
138004
|
try {
|
|
137769
|
-
return (
|
|
138005
|
+
return import_node_fs22.default.lstatSync(target).isDirectory() ? "directory" : "other";
|
|
137770
138006
|
} catch {
|
|
137771
138007
|
return void 0;
|
|
137772
138008
|
}
|
|
137773
138009
|
},
|
|
137774
|
-
|
|
138010
|
+
realPath: (target) => {
|
|
137775
138011
|
try {
|
|
137776
|
-
return import_node_fs22.default.
|
|
138012
|
+
return import_node_fs22.default.realpathSync(target);
|
|
137777
138013
|
} catch {
|
|
137778
138014
|
return void 0;
|
|
137779
138015
|
}
|
|
137780
138016
|
},
|
|
137781
|
-
|
|
138017
|
+
modifiedAtMs: (target) => {
|
|
137782
138018
|
try {
|
|
137783
|
-
return import_node_fs22.default.
|
|
138019
|
+
return import_node_fs22.default.statSync(target).mtimeMs;
|
|
137784
138020
|
} catch {
|
|
137785
138021
|
return void 0;
|
|
137786
138022
|
}
|
|
137787
138023
|
},
|
|
137788
|
-
|
|
138024
|
+
listDirectory: (target) => {
|
|
137789
138025
|
try {
|
|
137790
|
-
return import_node_fs22.default.
|
|
138026
|
+
return import_node_fs22.default.readdirSync(target);
|
|
137791
138027
|
} catch {
|
|
137792
138028
|
return void 0;
|
|
137793
138029
|
}
|
|
137794
|
-
}
|
|
138030
|
+
},
|
|
138031
|
+
writeText: (target, text4) => {
|
|
138032
|
+
const temporary = import_node_path56.default.join(import_node_path56.default.dirname(target), `.${import_node_path56.default.basename(target)}.${String(process.pid)}.tmp`);
|
|
138033
|
+
try {
|
|
138034
|
+
import_node_fs22.default.mkdirSync(import_node_path56.default.dirname(target), { recursive: true, mode: STATE_DIRECTORY_MODE });
|
|
138035
|
+
import_node_fs22.default.writeFileSync(temporary, text4, { mode: STATE_FILE_MODE });
|
|
138036
|
+
import_node_fs22.default.renameSync(temporary, target);
|
|
138037
|
+
} catch {
|
|
138038
|
+
discard(temporary);
|
|
138039
|
+
}
|
|
138040
|
+
},
|
|
138041
|
+
removePath: discard,
|
|
138042
|
+
memoryUse: readMemoryUse
|
|
137795
138043
|
};
|
|
137796
138044
|
}
|
|
137797
138045
|
|
|
@@ -138037,6 +138285,90 @@ function effortSegment({ payload, settings: settings2 }) {
|
|
|
138037
138285
|
return level === void 0 ? void 0 : formatEffort(level, settings2.effort.format);
|
|
138038
138286
|
}
|
|
138039
138287
|
|
|
138288
|
+
// src/statusline/dailyLedger.ts
|
|
138289
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
138290
|
+
init_zod();
|
|
138291
|
+
init_schema2();
|
|
138292
|
+
var DAILY_LEDGER_DIRECTORY = "daily-cost";
|
|
138293
|
+
var HOURS_PER_DAY8 = 24;
|
|
138294
|
+
var MS_PER_HOUR5 = 36e5;
|
|
138295
|
+
var SESSION_MAX_AGE_MS = HOURS_PER_DAY8 * MS_PER_HOUR5;
|
|
138296
|
+
var LAST_SEEN_REFRESH_MS = SESSION_MAX_AGE_MS / HOURS_PER_DAY8;
|
|
138297
|
+
var ENTRY_FILE = new RegExp(`^${CLIENT_SESSION_ID_PATTERN.source.slice(1, -1)}\\.json$`);
|
|
138298
|
+
var DAY_NAME = /^\d{4}-\d{2}-\d{2}$/;
|
|
138299
|
+
var usd = external_exports.number().nonnegative();
|
|
138300
|
+
var EntrySchema = external_exports.strictObject({ baselineUsd: usd, totalUsd: usd, source: external_exports.enum(["native", "estimate"]), seenAtMs: external_exports.number().int().positive() });
|
|
138301
|
+
function localDay(nowMs) {
|
|
138302
|
+
const date5 = new Date(nowMs);
|
|
138303
|
+
return `${String(date5.getFullYear())}-${String(date5.getMonth() + 1).padStart(2, "0")}-${String(date5.getDate()).padStart(2, "0")}`;
|
|
138304
|
+
}
|
|
138305
|
+
function parseEntry3(text4) {
|
|
138306
|
+
if (text4 === void 0) {
|
|
138307
|
+
return void 0;
|
|
138308
|
+
}
|
|
138309
|
+
let raw;
|
|
138310
|
+
try {
|
|
138311
|
+
raw = JSON.parse(text4);
|
|
138312
|
+
} catch {
|
|
138313
|
+
return void 0;
|
|
138314
|
+
}
|
|
138315
|
+
const parsed = EntrySchema.safeParse(raw);
|
|
138316
|
+
return parsed.success ? parsed.data : void 0;
|
|
138317
|
+
}
|
|
138318
|
+
function advance(existing, carried, cost, nowMs) {
|
|
138319
|
+
if (existing === void 0) {
|
|
138320
|
+
const carry = carried?.source === cost.source && nowMs - carried.seenAtMs <= SESSION_MAX_AGE_MS ? carried.totalUsd : void 0;
|
|
138321
|
+
const baselineUsd = carry ?? cost.usd;
|
|
138322
|
+
return { entry: { baselineUsd, totalUsd: Math.max(baselineUsd, cost.usd), source: cost.source, seenAtMs: nowMs }, changed: true };
|
|
138323
|
+
}
|
|
138324
|
+
if (existing.source !== cost.source) {
|
|
138325
|
+
return void 0;
|
|
138326
|
+
}
|
|
138327
|
+
if (cost.usd > existing.totalUsd || nowMs - existing.seenAtMs >= LAST_SEEN_REFRESH_MS) {
|
|
138328
|
+
return { entry: { ...existing, totalUsd: Math.max(existing.totalUsd, cost.usd), seenAtMs: nowMs }, changed: true };
|
|
138329
|
+
}
|
|
138330
|
+
return { entry: existing, changed: false };
|
|
138331
|
+
}
|
|
138332
|
+
function recordDailySpend(ports, nowMs, sessionId, cost) {
|
|
138333
|
+
const root = import_node_path57.default.join(ports.stateDirectory, DAILY_LEDGER_DIRECTORY);
|
|
138334
|
+
const today = localDay(nowMs);
|
|
138335
|
+
const days = (ports.listDirectory(root) ?? []).filter((name) => DAY_NAME.test(name));
|
|
138336
|
+
const previous = days.filter((day) => day < today).sort().at(-1);
|
|
138337
|
+
for (const day of days) {
|
|
138338
|
+
if (day < today && day !== previous) {
|
|
138339
|
+
ports.removePath(import_node_path57.default.join(root, day));
|
|
138340
|
+
}
|
|
138341
|
+
}
|
|
138342
|
+
const todayDirectory = import_node_path57.default.join(root, today);
|
|
138343
|
+
if (sessionId !== void 0 && cost !== void 0 && CLIENT_SESSION_ID_PATTERN.test(sessionId)) {
|
|
138344
|
+
const file2 = import_node_path57.default.join(todayDirectory, `${sessionId}.json`);
|
|
138345
|
+
const carried = previous === void 0 ? void 0 : parseEntry3(ports.readText(import_node_path57.default.join(root, previous, `${sessionId}.json`)));
|
|
138346
|
+
const next = advance(parseEntry3(ports.readText(file2)), carried, cost, nowMs);
|
|
138347
|
+
if (next?.changed === true) {
|
|
138348
|
+
ports.writeText(file2, `${JSON.stringify(next.entry)}
|
|
138349
|
+
`);
|
|
138350
|
+
}
|
|
138351
|
+
}
|
|
138352
|
+
const entries = (ports.listDirectory(todayDirectory) ?? []).filter((name) => ENTRY_FILE.test(name)).flatMap((name) => {
|
|
138353
|
+
const entry = parseEntry3(ports.readText(import_node_path57.default.join(todayDirectory, name)));
|
|
138354
|
+
return entry === void 0 ? [] : [entry];
|
|
138355
|
+
});
|
|
138356
|
+
return entries.length === 0 ? void 0 : entries.reduce((sum, entry) => sum + (entry.totalUsd - entry.baselineUsd), 0);
|
|
138357
|
+
}
|
|
138358
|
+
|
|
138359
|
+
// src/statusline/elements/header/cost.ts
|
|
138360
|
+
function costSegment(context) {
|
|
138361
|
+
const cost = resolveSessionCost(context);
|
|
138362
|
+
if (cost === void 0) {
|
|
138363
|
+
return void 0;
|
|
138364
|
+
}
|
|
138365
|
+
return `${cost.source === "native" ? "Cost" : "Est."} ${formatUsd(cost.usd)}`;
|
|
138366
|
+
}
|
|
138367
|
+
function dailyCostSegment(context) {
|
|
138368
|
+
const spend = recordDailySpend(context.ports, context.nowMs, context.payload.session_id, resolveSessionCost(context));
|
|
138369
|
+
return spend === void 0 ? void 0 : `Today ${formatUsd(spend)}`;
|
|
138370
|
+
}
|
|
138371
|
+
|
|
138040
138372
|
// src/statusline/palette.ts
|
|
138041
138373
|
init_statusline();
|
|
138042
138374
|
var RESET = `${ESCAPE}[0m`;
|
|
@@ -138239,11 +138571,11 @@ function modelSegment(context) {
|
|
|
138239
138571
|
}
|
|
138240
138572
|
|
|
138241
138573
|
// src/statusline/elements/header/outputStyle.ts
|
|
138242
|
-
var
|
|
138574
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
138243
138575
|
init_zod();
|
|
138244
138576
|
var SettingsFileSchema = external_exports.looseObject({ outputStyle: external_exports.string().optional().catch(void 0) });
|
|
138245
|
-
function outputStyleIn(file2,
|
|
138246
|
-
const text4 =
|
|
138577
|
+
function outputStyleIn(file2, readText2) {
|
|
138578
|
+
const text4 = readText2(file2);
|
|
138247
138579
|
if (text4 === void 0) {
|
|
138248
138580
|
return void 0;
|
|
138249
138581
|
}
|
|
@@ -138259,12 +138591,12 @@ function outputStyleIn(file2, readText) {
|
|
|
138259
138591
|
}
|
|
138260
138592
|
function outputStyleSegment({ payload, ports }) {
|
|
138261
138593
|
const pinned = ports.env.CLAUDE_CONFIG_DIR;
|
|
138262
|
-
const configDirectory = pinned === void 0 || pinned === "" ?
|
|
138594
|
+
const configDirectory = pinned === void 0 || pinned === "" ? import_node_path58.default.join(ports.homeDirectory, ".claude") : pinned;
|
|
138263
138595
|
const projectDirectory = payload.cwd ?? payload.workspace?.current_dir;
|
|
138264
138596
|
const files = [
|
|
138265
|
-
|
|
138266
|
-
|
|
138267
|
-
...projectDirectory === void 0 ? [] : [
|
|
138597
|
+
import_node_path58.default.join(configDirectory, "settings.json"),
|
|
138598
|
+
import_node_path58.default.join(configDirectory, "settings.local.json"),
|
|
138599
|
+
...projectDirectory === void 0 ? [] : [import_node_path58.default.join(projectDirectory, ".claude", "settings.json"), import_node_path58.default.join(projectDirectory, ".claude", "settings.local.json")]
|
|
138268
138600
|
];
|
|
138269
138601
|
const style = files.map((file2) => outputStyleIn(file2, ports.readText)).findLast((name) => name !== void 0);
|
|
138270
138602
|
return style === void 0 ? void 0 : `style: ${style}`;
|
|
@@ -138420,15 +138752,15 @@ function parseNumstat(output2) {
|
|
|
138420
138752
|
if (addedText === void 0 || deletedText === void 0 || pathText === void 0) {
|
|
138421
138753
|
continue;
|
|
138422
138754
|
}
|
|
138423
|
-
const
|
|
138755
|
+
const path71 = pathText === "" ? fields[index + 2] : pathText;
|
|
138424
138756
|
if (pathText === "") {
|
|
138425
138757
|
index += 2;
|
|
138426
138758
|
}
|
|
138427
138759
|
const lines = { added: Number(addedText), deleted: Number(deletedText) };
|
|
138428
|
-
if (
|
|
138760
|
+
if (path71 !== void 0 && Number.isInteger(lines.added) && Number.isInteger(lines.deleted)) {
|
|
138429
138761
|
added += lines.added;
|
|
138430
138762
|
deleted += lines.deleted;
|
|
138431
|
-
byPath.set(
|
|
138763
|
+
byPath.set(path71, lines);
|
|
138432
138764
|
}
|
|
138433
138765
|
}
|
|
138434
138766
|
return { total: { added, deleted }, byPath };
|
|
@@ -138483,7 +138815,7 @@ function readGitStatus(ports, cwd, query) {
|
|
|
138483
138815
|
}
|
|
138484
138816
|
|
|
138485
138817
|
// src/statusline/vcs/jj.ts
|
|
138486
|
-
var
|
|
138818
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
138487
138819
|
var JJ2 = "jj";
|
|
138488
138820
|
var MAX_WALK_DEPTH = 64;
|
|
138489
138821
|
var MAX_LABEL_CODE_POINTS = 64;
|
|
@@ -138496,13 +138828,13 @@ function isJjRepository(ports, cwd) {
|
|
|
138496
138828
|
return false;
|
|
138497
138829
|
}
|
|
138498
138830
|
for (let depth = 0; depth < MAX_WALK_DEPTH; depth += 1) {
|
|
138499
|
-
if (ports.entryKind(
|
|
138831
|
+
if (ports.entryKind(import_node_path59.default.join(directory, ".jj")) === "directory") {
|
|
138500
138832
|
return true;
|
|
138501
138833
|
}
|
|
138502
|
-
if (ports.entryKind(
|
|
138834
|
+
if (ports.entryKind(import_node_path59.default.join(directory, ".git")) !== void 0) {
|
|
138503
138835
|
return false;
|
|
138504
138836
|
}
|
|
138505
|
-
const parent =
|
|
138837
|
+
const parent = import_node_path59.default.dirname(directory);
|
|
138506
138838
|
if (parent === directory) {
|
|
138507
138839
|
return false;
|
|
138508
138840
|
}
|
|
@@ -138697,9 +139029,137 @@ function gitFilesRow(context) {
|
|
|
138697
139029
|
return { kind: "text", lines: [entries.join(" ")] };
|
|
138698
139030
|
}
|
|
138699
139031
|
|
|
138700
|
-
// src/statusline/
|
|
138701
|
-
|
|
138702
|
-
|
|
139032
|
+
// src/statusline/configCounts.ts
|
|
139033
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
139034
|
+
init_zod();
|
|
139035
|
+
var nameList = external_exports.array(external_exports.unknown()).catch([]).transform((items) => items.filter((item) => typeof item === "string"));
|
|
139036
|
+
var ConfigFileSchema = external_exports.looseObject({
|
|
139037
|
+
mcpServers: external_exports.record(external_exports.string(), external_exports.unknown()).optional().catch(void 0),
|
|
139038
|
+
hooks: external_exports.record(external_exports.string(), external_exports.unknown()).optional().catch(void 0),
|
|
139039
|
+
disabledMcpServers: nameList.optional(),
|
|
139040
|
+
disabledMcpjsonServers: nameList.optional()
|
|
139041
|
+
});
|
|
139042
|
+
var MAX_RULE_DIRECTORIES = 1e3;
|
|
139043
|
+
var MAX_RULE_ENTRIES = 1e4;
|
|
139044
|
+
var BYTES_PER_MEBIBYTE = 1048576;
|
|
139045
|
+
var MAX_CONFIG_FILE_MEBIBYTES = 8;
|
|
139046
|
+
var MAX_CONFIG_FILE_BYTES = MAX_CONFIG_FILE_MEBIBYTES * BYTES_PER_MEBIBYTE;
|
|
139047
|
+
function readConfigFile(ports, file2) {
|
|
139048
|
+
const size = ports.readRange(file2, 0, 0)?.size;
|
|
139049
|
+
if (size === void 0 || size > MAX_CONFIG_FILE_BYTES) {
|
|
139050
|
+
return void 0;
|
|
139051
|
+
}
|
|
139052
|
+
const text4 = ports.readText(file2);
|
|
139053
|
+
if (text4 === void 0) {
|
|
139054
|
+
return void 0;
|
|
139055
|
+
}
|
|
139056
|
+
let raw;
|
|
139057
|
+
try {
|
|
139058
|
+
raw = JSON.parse(text4);
|
|
139059
|
+
} catch {
|
|
139060
|
+
return void 0;
|
|
139061
|
+
}
|
|
139062
|
+
const parsed = ConfigFileSchema.safeParse(raw);
|
|
139063
|
+
return parsed.success ? parsed.data : void 0;
|
|
139064
|
+
}
|
|
139065
|
+
function namesOf(file2) {
|
|
139066
|
+
return new Set(file2?.mcpServers === void 0 ? [] : Object.keys(file2.mcpServers));
|
|
139067
|
+
}
|
|
139068
|
+
function hookEventsOf(file2) {
|
|
139069
|
+
return file2?.hooks === void 0 ? 0 : Object.keys(file2.hooks).length;
|
|
139070
|
+
}
|
|
139071
|
+
function removeNames(servers, names) {
|
|
139072
|
+
if (names === void 0) {
|
|
139073
|
+
return;
|
|
139074
|
+
}
|
|
139075
|
+
for (const name of names) {
|
|
139076
|
+
servers.delete(name);
|
|
139077
|
+
}
|
|
139078
|
+
}
|
|
139079
|
+
function followedKind(ports, target) {
|
|
139080
|
+
const real = ports.realPath(target);
|
|
139081
|
+
return real === void 0 ? void 0 : ports.entryKind(real);
|
|
139082
|
+
}
|
|
139083
|
+
function isFile(ports, file2) {
|
|
139084
|
+
return followedKind(ports, file2) === "other";
|
|
139085
|
+
}
|
|
139086
|
+
function countRules(ports, root) {
|
|
139087
|
+
const visited = /* @__PURE__ */ new Set();
|
|
139088
|
+
let entries = 0;
|
|
139089
|
+
let directories = 0;
|
|
139090
|
+
const walk3 = (directory) => {
|
|
139091
|
+
const real = ports.realPath(directory);
|
|
139092
|
+
if (real === void 0 || visited.has(real) || directories >= MAX_RULE_DIRECTORIES) {
|
|
139093
|
+
return 0;
|
|
139094
|
+
}
|
|
139095
|
+
visited.add(real);
|
|
139096
|
+
directories += 1;
|
|
139097
|
+
const names = ports.listDirectory(real);
|
|
139098
|
+
if (names === void 0) {
|
|
139099
|
+
return 0;
|
|
139100
|
+
}
|
|
139101
|
+
let count = 0;
|
|
139102
|
+
for (const name of names) {
|
|
139103
|
+
if (entries >= MAX_RULE_ENTRIES) {
|
|
139104
|
+
break;
|
|
139105
|
+
}
|
|
139106
|
+
entries += 1;
|
|
139107
|
+
const entry = import_node_path60.default.join(real, name);
|
|
139108
|
+
const kind = followedKind(ports, entry);
|
|
139109
|
+
if (kind === "directory") {
|
|
139110
|
+
count += walk3(entry);
|
|
139111
|
+
} else if (kind === "other" && name.endsWith(".md")) {
|
|
139112
|
+
const target = ports.realPath(entry);
|
|
139113
|
+
if (target !== void 0 && !visited.has(target)) {
|
|
139114
|
+
visited.add(target);
|
|
139115
|
+
count += 1;
|
|
139116
|
+
}
|
|
139117
|
+
}
|
|
139118
|
+
}
|
|
139119
|
+
return count;
|
|
139120
|
+
};
|
|
139121
|
+
return walk3(root);
|
|
139122
|
+
}
|
|
139123
|
+
function sameLocation(ports, left, right) {
|
|
139124
|
+
return (ports.realPath(left) ?? import_node_path60.default.resolve(left)) === (ports.realPath(right) ?? import_node_path60.default.resolve(right));
|
|
139125
|
+
}
|
|
139126
|
+
function configDirectoryOf(ports) {
|
|
139127
|
+
const pinned = ports.env.CLAUDE_CONFIG_DIR;
|
|
139128
|
+
return pinned === void 0 || pinned === "" ? import_node_path60.default.join(ports.homeDirectory, ".claude") : pinned;
|
|
139129
|
+
}
|
|
139130
|
+
function countConfiguration(ports, projectDirectory) {
|
|
139131
|
+
const userDirectory = configDirectoryOf(ports);
|
|
139132
|
+
const userSettings = readConfigFile(ports, import_node_path60.default.join(userDirectory, "settings.json"));
|
|
139133
|
+
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");
|
|
139134
|
+
const global2 = readConfigFile(ports, globalFile);
|
|
139135
|
+
const userServers = /* @__PURE__ */ new Set([...namesOf(userSettings), ...namesOf(global2)]);
|
|
139136
|
+
removeNames(userServers, global2?.disabledMcpServers);
|
|
139137
|
+
const projectServers = /* @__PURE__ */ new Set();
|
|
139138
|
+
let claudeMd = isFile(ports, import_node_path60.default.join(userDirectory, "CLAUDE.md")) ? 1 : 0;
|
|
139139
|
+
let rules = countRules(ports, import_node_path60.default.join(userDirectory, "rules"));
|
|
139140
|
+
let hookEvents = hookEventsOf(userSettings);
|
|
139141
|
+
if (projectDirectory !== void 0) {
|
|
139142
|
+
const projectClaude = import_node_path60.default.join(projectDirectory, ".claude");
|
|
139143
|
+
const projectIsUser = sameLocation(ports, projectClaude, userDirectory);
|
|
139144
|
+
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")]];
|
|
139145
|
+
claudeMd += claudeMdFiles.filter((file2) => isFile(ports, file2)).length;
|
|
139146
|
+
const mcpJson = namesOf(readConfigFile(ports, import_node_path60.default.join(projectDirectory, ".mcp.json")));
|
|
139147
|
+
if (!projectIsUser) {
|
|
139148
|
+
rules += countRules(ports, import_node_path60.default.join(projectClaude, "rules"));
|
|
139149
|
+
const settings2 = readConfigFile(ports, import_node_path60.default.join(projectClaude, "settings.json"));
|
|
139150
|
+
const local = readConfigFile(ports, import_node_path60.default.join(projectClaude, "settings.local.json"));
|
|
139151
|
+
hookEvents += hookEventsOf(settings2) + hookEventsOf(local);
|
|
139152
|
+
for (const name of [...namesOf(settings2), ...namesOf(local)]) {
|
|
139153
|
+
projectServers.add(name);
|
|
139154
|
+
}
|
|
139155
|
+
removeNames(mcpJson, local?.disabledMcpjsonServers);
|
|
139156
|
+
}
|
|
139157
|
+
for (const name of mcpJson) {
|
|
139158
|
+
projectServers.add(name);
|
|
139159
|
+
}
|
|
139160
|
+
}
|
|
139161
|
+
return { claudeMd, rules, mcpServers: userServers.size + projectServers.size, hookEvents };
|
|
139162
|
+
}
|
|
138703
139163
|
|
|
138704
139164
|
// src/statusline/headerLayout.ts
|
|
138705
139165
|
var SEPARATOR2 = " | ";
|
|
@@ -138768,6 +139228,38 @@ function layoutHeader(texts, maxWidth, separator) {
|
|
|
138768
139228
|
return packLines(texts, maxWidth, separator).map((line) => justify(line, maxWidth, separator)).join("\n");
|
|
138769
139229
|
}
|
|
138770
139230
|
|
|
139231
|
+
// src/statusline/elements/rows/environment.ts
|
|
139232
|
+
function counted(count, singular, plural2) {
|
|
139233
|
+
return count === 0 ? void 0 : `${String(count)} ${count === 1 ? singular : plural2}`;
|
|
139234
|
+
}
|
|
139235
|
+
function environmentRow(context) {
|
|
139236
|
+
const { payload, settings: settings2, palette, ports } = context;
|
|
139237
|
+
const counts = countConfiguration(ports, payload.cwd ?? payload.workspace?.current_dir);
|
|
139238
|
+
const total = counts.claudeMd + counts.rules + counts.mcpServers + counts.hookEvents;
|
|
139239
|
+
if (total === 0 || total < settings2.environment.threshold) {
|
|
139240
|
+
return { kind: "text", lines: [] };
|
|
139241
|
+
}
|
|
139242
|
+
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);
|
|
139243
|
+
return { kind: "text", lines: packLines(parts.map((part) => palette.paint("label", part)), context.width, SEPARATOR2).map((line) => line.join(SEPARATOR2)) };
|
|
139244
|
+
}
|
|
139245
|
+
|
|
139246
|
+
// src/statusline/elements/rows/memory.ts
|
|
139247
|
+
function memoryRow(context) {
|
|
139248
|
+
const use2 = context.ports.memoryUse();
|
|
139249
|
+
const cells = [];
|
|
139250
|
+
if (use2 !== void 0 && use2.totalBytes > 0) {
|
|
139251
|
+
const style = barStyleOf(context, "usage");
|
|
139252
|
+
const fraction = Math.max(0, Math.min(1, use2.usedBytes / use2.totalBytes));
|
|
139253
|
+
const percent2 = withColor(statusColor(fraction, true, style), `${(fraction * FULL_PERCENT3).toFixed(1)}%`);
|
|
139254
|
+
cells.push(barCell(context.palette.paint("label", "RAM "), ` ${percent2} (${formatBytes(use2.usedBytes)} / ${formatBytes(use2.totalBytes)})`, fraction, style));
|
|
139255
|
+
}
|
|
139256
|
+
return { kind: "bars", cells };
|
|
139257
|
+
}
|
|
139258
|
+
|
|
139259
|
+
// src/statusline/elements/rows/quota.ts
|
|
139260
|
+
init_statusline();
|
|
139261
|
+
init_pick();
|
|
139262
|
+
|
|
138771
139263
|
// src/statusline/wallClock.ts
|
|
138772
139264
|
var DAY_KEY_LOCALE = "en-CA";
|
|
138773
139265
|
var FORMATTERS = /* @__PURE__ */ new Map();
|
|
@@ -138925,11 +139417,13 @@ var HEADER_ROLES = {
|
|
|
138925
139417
|
effort: "model",
|
|
138926
139418
|
advisor: "label",
|
|
138927
139419
|
version: "label",
|
|
138928
|
-
outputStyle: "label"
|
|
139420
|
+
outputStyle: "label",
|
|
139421
|
+
cost: "label",
|
|
139422
|
+
dailyCost: "label"
|
|
138929
139423
|
};
|
|
138930
139424
|
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 }
|
|
139425
|
+
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 },
|
|
139426
|
+
rows: { context: contextRow, quota: quotaRow, addedDirs: addedDirsRow, gitFiles: gitFilesRow, memory: memoryRow, environment: environmentRow }
|
|
138933
139427
|
};
|
|
138934
139428
|
|
|
138935
139429
|
// src/statusline/identityTranscript.ts
|
|
@@ -139129,7 +139623,7 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
139129
139623
|
} else {
|
|
139130
139624
|
const configDir = process.env.CLAUDE_CONFIG_DIR;
|
|
139131
139625
|
try {
|
|
139132
|
-
account = readAccountMetadataFile(realFarmFs, configDir === void 0 || configDir === "" ?
|
|
139626
|
+
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
139627
|
} catch {
|
|
139134
139628
|
account = void 0;
|
|
139135
139629
|
}
|
|
@@ -139166,17 +139660,24 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
139166
139660
|
routedTarget = void 0;
|
|
139167
139661
|
}
|
|
139168
139662
|
}
|
|
139169
|
-
const
|
|
139663
|
+
const clientPayload = parseClientPayload(payload);
|
|
139664
|
+
const enrichParams = { payload, env: process.env, snapshot, account, providerName, nowMs, headroom, routedTarget, ...modelChoice === void 0 ? {} : { modelChoice } };
|
|
139170
139665
|
const renderer = process.env.AGENT_SHIM_STATUSLINE_CMD;
|
|
139171
139666
|
if (renderer !== void 0 && renderer !== "") {
|
|
139172
139667
|
const child = (0, import_node_child_process8.spawn)("/bin/sh", ["-c", renderer], { stdio: ["pipe", "inherit", "inherit"] });
|
|
139173
|
-
child.stdin.end(`${JSON.stringify(
|
|
139668
|
+
child.stdin.end(`${JSON.stringify(enrichStatuslinePayload(enrichParams).payload)}
|
|
139174
139669
|
`);
|
|
139175
139670
|
child.on("close", (code) => {
|
|
139176
139671
|
process.exit(code ?? 0);
|
|
139177
139672
|
});
|
|
139178
139673
|
return;
|
|
139179
139674
|
}
|
|
139675
|
+
const rawSettings = process.env[STATUSLINE_ENV];
|
|
139676
|
+
const settings2 = resolveStatusline(rawSettings === void 0 || rawSettings === "" ? void 0 : statuslineSettingsFromEnv(rawSettings, STATUSLINE_ENV));
|
|
139677
|
+
const conversationId = clientPayload.session_id;
|
|
139678
|
+
const prices = settings2.layout.header.some((name) => name === "cost" || name === "dailyCost") ? readModels(deps.paths)?.prices : void 0;
|
|
139679
|
+
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 });
|
|
139680
|
+
const { summary } = enrichStatuslinePayload({ ...enrichParams, ...doorCostUsd === void 0 ? {} : { doorCostUsd } });
|
|
139180
139681
|
let stackedUnderDefault = false;
|
|
139181
139682
|
if (isAntigravityPayload(payload)) {
|
|
139182
139683
|
try {
|
|
@@ -139185,11 +139686,8 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
139185
139686
|
stackedUnderDefault = false;
|
|
139186
139687
|
}
|
|
139187
139688
|
}
|
|
139188
|
-
const clientPayload = parseClientPayload(payload);
|
|
139189
139689
|
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) }));
|
|
139690
|
+
console.log(renderStatuslineBlock({ summary, view, payload: clientPayload, terminalWidth: terminalWidthOf(payload, process.env), nowMs, settings: settings2, ports: realStatuslinePorts(process.env, deps.paths.statuslineDir) }));
|
|
139193
139691
|
}),
|
|
139194
139692
|
["$ agent-shim statusline # a client's statusline setting names this; it renders or delegates"]
|
|
139195
139693
|
);
|
|
@@ -141226,8 +141724,8 @@ function getErrorMap2() {
|
|
|
141226
141724
|
|
|
141227
141725
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/helpers/parseUtil.js
|
|
141228
141726
|
var makeIssue = (params) => {
|
|
141229
|
-
const { data, path:
|
|
141230
|
-
const fullPath = [...
|
|
141727
|
+
const { data, path: path71, errorMaps, issueData } = params;
|
|
141728
|
+
const fullPath = [...path71, ...issueData.path || []];
|
|
141231
141729
|
const fullIssue = {
|
|
141232
141730
|
...issueData,
|
|
141233
141731
|
path: fullPath
|
|
@@ -141342,11 +141840,11 @@ var errorUtil;
|
|
|
141342
141840
|
|
|
141343
141841
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/types.js
|
|
141344
141842
|
var ParseInputLazyPath = class {
|
|
141345
|
-
constructor(parent, value2,
|
|
141843
|
+
constructor(parent, value2, path71, key) {
|
|
141346
141844
|
this._cachedPath = [];
|
|
141347
141845
|
this.parent = parent;
|
|
141348
141846
|
this.data = value2;
|
|
141349
|
-
this._path =
|
|
141847
|
+
this._path = path71;
|
|
141350
141848
|
this._key = key;
|
|
141351
141849
|
}
|
|
141352
141850
|
get path() {
|
|
@@ -144909,11 +145407,11 @@ function normalizeObjectSchema(schema) {
|
|
|
144909
145407
|
}
|
|
144910
145408
|
return void 0;
|
|
144911
145409
|
}
|
|
144912
|
-
function getDotPath(
|
|
144913
|
-
if (
|
|
145410
|
+
function getDotPath(path71) {
|
|
145411
|
+
if (path71.length === 0) {
|
|
144914
145412
|
return "object root";
|
|
144915
145413
|
}
|
|
144916
|
-
return
|
|
145414
|
+
return path71.reduce((acc, seg, index) => {
|
|
144917
145415
|
if (index === 0) {
|
|
144918
145416
|
return String(seg);
|
|
144919
145417
|
}
|
|
@@ -148956,7 +149454,7 @@ async function serveMcp(mcp, transport, options = {}) {
|
|
|
148956
149454
|
|
|
148957
149455
|
// src/mcp/permissions.ts
|
|
148958
149456
|
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
148959
|
-
var
|
|
149457
|
+
var import_node_path62 = __toESM(require("node:path"), 1);
|
|
148960
149458
|
init_zod();
|
|
148961
149459
|
init_store();
|
|
148962
149460
|
var StoredMcpPermissionsSchema = external_exports.strictObject({
|
|
@@ -148978,10 +149476,10 @@ function effectiveMcpPermissions(flags, stored) {
|
|
|
148978
149476
|
return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl, history: flags.history || stored.history };
|
|
148979
149477
|
}
|
|
148980
149478
|
function watchMcpPermissions(paths, onChange) {
|
|
148981
|
-
const directory =
|
|
149479
|
+
const directory = import_node_path62.default.dirname(paths.mcpPermissionsFile);
|
|
148982
149480
|
import_node_fs23.default.mkdirSync(directory, { recursive: true });
|
|
148983
149481
|
const watcher = import_node_fs23.default.watch(directory, (_event, filename) => {
|
|
148984
|
-
if (filename === null || filename ===
|
|
149482
|
+
if (filename === null || filename === import_node_path62.default.basename(paths.mcpPermissionsFile)) {
|
|
148985
149483
|
onChange();
|
|
148986
149484
|
}
|
|
148987
149485
|
});
|
|
@@ -149286,7 +149784,6 @@ function registerCompletionCommand(program2) {
|
|
|
149286
149784
|
}
|
|
149287
149785
|
|
|
149288
149786
|
// src/credentialCommand.ts
|
|
149289
|
-
var import_node_child_process9 = require("node:child_process");
|
|
149290
149787
|
init_commandDeps();
|
|
149291
149788
|
init_cliError();
|
|
149292
149789
|
init_schema();
|
|
@@ -149295,16 +149792,16 @@ init_credentialCache();
|
|
|
149295
149792
|
|
|
149296
149793
|
// src/identityToken.ts
|
|
149297
149794
|
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
149298
|
-
var
|
|
149795
|
+
var import_node_path63 = __toESM(require("node:path"), 1);
|
|
149299
149796
|
init_cliError();
|
|
149300
149797
|
var TOKEN_FILE_MODE = 384;
|
|
149301
149798
|
var TOKEN_DIR_MODE = 448;
|
|
149302
149799
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
149303
149800
|
function identityTokenDir(paths) {
|
|
149304
|
-
return
|
|
149801
|
+
return import_node_path63.default.join(paths.root, "credentials");
|
|
149305
149802
|
}
|
|
149306
149803
|
function identityTokenPath(paths, identityName) {
|
|
149307
|
-
return
|
|
149804
|
+
return import_node_path63.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
149308
149805
|
}
|
|
149309
149806
|
function storeIdentityToken(paths, identityName, raw) {
|
|
149310
149807
|
const token = raw.trim();
|
|
@@ -149315,7 +149812,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
149315
149812
|
import_node_fs24.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
149316
149813
|
import_node_fs24.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
149317
149814
|
const target = identityTokenPath(paths, identityName);
|
|
149318
|
-
const temp =
|
|
149815
|
+
const temp = import_node_path63.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
149319
149816
|
import_node_fs24.default.writeFileSync(temp, `${token}
|
|
149320
149817
|
`, { mode: TOKEN_FILE_MODE });
|
|
149321
149818
|
import_node_fs24.default.renameSync(temp, target);
|
|
@@ -149326,6 +149823,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
149326
149823
|
init_providersStore();
|
|
149327
149824
|
init_realPorts();
|
|
149328
149825
|
init_realCredentialCache();
|
|
149826
|
+
init_blockingSpawn();
|
|
149329
149827
|
async function readStandardInput() {
|
|
149330
149828
|
const chunks = [];
|
|
149331
149829
|
for await (const chunk2 of process.stdin) {
|
|
@@ -149347,7 +149845,7 @@ function realCommandPorts(deps) {
|
|
|
149347
149845
|
cache: createRealCredentialCache(deps.paths.root),
|
|
149348
149846
|
platform: process.platform,
|
|
149349
149847
|
now: () => Date.now(),
|
|
149350
|
-
ssh: (host, remoteCommand, input2) => (
|
|
149848
|
+
ssh: (host, remoteCommand, input2) => spawnSyncBlocking("an ssh run", "ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
|
|
149351
149849
|
};
|
|
149352
149850
|
}
|
|
149353
149851
|
var REMOTE_ROOT_SCRIPT = 'root="${AGENT_SHIM_HOME:-${CLAUDE_USE_HOME:-}}"; if [ -z "$root" ]; then if [ ! -d "$HOME/.agent-shim" ] && [ -d "$HOME/.claude-use" ]; then root="$HOME/.claude-use"; else root="$HOME/.agent-shim"; fi; fi';
|
|
@@ -149486,8 +149984,8 @@ function registerDoctorCommand(program2, deps) {
|
|
|
149486
149984
|
// src/headroom/commands.ts
|
|
149487
149985
|
var import_node_fs25 = __toESM(require("node:fs"), 1);
|
|
149488
149986
|
var import_node_http5 = __toESM(require("node:http"), 1);
|
|
149489
|
-
var
|
|
149490
|
-
var
|
|
149987
|
+
var import_node_path64 = __toESM(require("node:path"), 1);
|
|
149988
|
+
var import_node_child_process9 = require("node:child_process");
|
|
149491
149989
|
init_commandDeps();
|
|
149492
149990
|
init_configProfilesStore();
|
|
149493
149991
|
init_realFrontDoorPort();
|
|
@@ -149543,6 +150041,7 @@ function registerHeadroomRoutingCommands(headroom, deps) {
|
|
|
149543
150041
|
init_settings();
|
|
149544
150042
|
init_source();
|
|
149545
150043
|
init_realPorts();
|
|
150044
|
+
init_blockingSpawn();
|
|
149546
150045
|
init_earlierRelease();
|
|
149547
150046
|
init_state2();
|
|
149548
150047
|
init_socket();
|
|
@@ -149672,16 +150171,16 @@ async function readyOverSocket(socketPath) {
|
|
|
149672
150171
|
}
|
|
149673
150172
|
var HEADROOM_TOOL_NAME = "headroom-ai";
|
|
149674
150173
|
function readInstalledHeadroomCommit() {
|
|
149675
|
-
const toolDir = (
|
|
150174
|
+
const toolDir = spawnSyncBlocking("a headroom tool lookup", "uv", ["tool", "dir"], { encoding: "utf8" });
|
|
149676
150175
|
if (toolDir.status !== 0) {
|
|
149677
150176
|
return void 0;
|
|
149678
150177
|
}
|
|
149679
|
-
const libDir =
|
|
150178
|
+
const libDir = import_node_path64.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
149680
150179
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
149681
|
-
const sitePackages =
|
|
150180
|
+
const sitePackages = import_node_path64.default.join(libDir, python, "site-packages");
|
|
149682
150181
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
149683
150182
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
149684
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
150183
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path64.default.join(sitePackages, entry, "direct_url.json"));
|
|
149685
150184
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
149686
150185
|
}
|
|
149687
150186
|
}
|
|
@@ -149716,7 +150215,7 @@ function realSupervisorPorts(paths) {
|
|
|
149716
150215
|
}
|
|
149717
150216
|
const logFd = import_node_fs25.default.openSync(paths.headroomLogPath, "a");
|
|
149718
150217
|
try {
|
|
149719
|
-
const child = (0,
|
|
150218
|
+
const child = (0, import_node_child_process9.spawn)("headroom", headroomProxyArgs(socketPath, allowlistFile, settings2), {
|
|
149720
150219
|
detached: true,
|
|
149721
150220
|
stdio: ["ignore", logFd, logFd],
|
|
149722
150221
|
env: headroomSpawnEnv(process.env, settings2, trust?.path)
|
|
@@ -149756,7 +150255,7 @@ function realSupervisorPorts(paths) {
|
|
|
149756
150255
|
},
|
|
149757
150256
|
ready: readyOverSocket,
|
|
149758
150257
|
install: (spec) => {
|
|
149759
|
-
const result = (
|
|
150258
|
+
const result = spawnSyncBlocking("a headroom install", "uv", ["tool", "install", spec], { encoding: "utf8", timeout: HEADROOM_INSTALL_TIMEOUT_MS });
|
|
149760
150259
|
if (result.error !== void 0) {
|
|
149761
150260
|
const timedOut = "code" in result.error && result.error.code === "ETIMEDOUT";
|
|
149762
150261
|
return {
|
|
@@ -149773,7 +150272,7 @@ function realSupervisorPorts(paths) {
|
|
|
149773
150272
|
return result.status === 0 ? { ok: true } : { ok: false, error: `uv tool install exited ${String(result.status)}` };
|
|
149774
150273
|
},
|
|
149775
150274
|
headroomVersion: () => {
|
|
149776
|
-
const result = (
|
|
150275
|
+
const result = spawnSyncBlocking("a headroom version check", "headroom", ["--version"], { encoding: "utf8" });
|
|
149777
150276
|
return result.status === 0 ? result.stdout.trim() : void 0;
|
|
149778
150277
|
},
|
|
149779
150278
|
installedCommit: readInstalledHeadroomCommit,
|
|
@@ -149937,7 +150436,7 @@ async function refreshCatalogueForReal(paths, name, env) {
|
|
|
149937
150436
|
init_realPorts();
|
|
149938
150437
|
|
|
149939
150438
|
// src/usage/realJobRunner.ts
|
|
149940
|
-
var
|
|
150439
|
+
var import_node_path65 = __toESM(require("node:path"), 1);
|
|
149941
150440
|
init_conditions();
|
|
149942
150441
|
init_identityClaude();
|
|
149943
150442
|
var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
|
|
@@ -149950,7 +150449,7 @@ ${outcome.trimEnd()}
|
|
|
149950
150449
|
}
|
|
149951
150450
|
function createRealJobRunner(params) {
|
|
149952
150451
|
return async (name, identity, job) => {
|
|
149953
|
-
const logFile =
|
|
150452
|
+
const logFile = import_node_path65.default.join(params.paths.jobLogsDir, `${name}.log`);
|
|
149954
150453
|
const append = (outcome) => {
|
|
149955
150454
|
params.fs.mkdirPrivate(params.paths.jobLogsDir);
|
|
149956
150455
|
params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
|
|
@@ -150007,7 +150506,7 @@ function registerHeadlessCommands(program2, deps) {
|
|
|
150007
150506
|
}
|
|
150008
150507
|
|
|
150009
150508
|
// src/jobs.ts
|
|
150010
|
-
var
|
|
150509
|
+
var import_node_path66 = __toESM(require("node:path"), 1);
|
|
150011
150510
|
init_commandDeps();
|
|
150012
150511
|
init_cliError();
|
|
150013
150512
|
init_schema();
|
|
@@ -150032,7 +150531,7 @@ function jobOf(options) {
|
|
|
150032
150531
|
target: options.identity === void 0 ? { pool: options.pool ?? "" } : { identity: options.identity },
|
|
150033
150532
|
trigger: options.at === void 0 ? { beforeReset: options.beforeReset ?? "fiveHour", lead: options.lead ?? "" } : { at: options.at },
|
|
150034
150533
|
prompt: options.prompt,
|
|
150035
|
-
cwd:
|
|
150534
|
+
cwd: import_node_path66.default.resolve(options.cwd ?? process.cwd()),
|
|
150036
150535
|
timeout: options.timeout,
|
|
150037
150536
|
...options.model === void 0 ? {} : { model: options.model },
|
|
150038
150537
|
...options.allowedTool === void 0 ? {} : { allowedTools: options.allowedTool }
|
|
@@ -150105,7 +150604,7 @@ function registerJobCommand(program2, deps) {
|
|
|
150105
150604
|
console.log(`Allowed tools: ${entry.allowedTools.join(", ")}`);
|
|
150106
150605
|
}
|
|
150107
150606
|
console.log(`Prompt: ${entry.prompt}`);
|
|
150108
|
-
console.log(`Results: ${
|
|
150607
|
+
console.log(`Results: ${import_node_path66.default.join(paths.jobLogsDir, `${name}.log`)}`);
|
|
150109
150608
|
}),
|
|
150110
150609
|
["agent-shim job show digest"]
|
|
150111
150610
|
);
|
|
@@ -150128,7 +150627,7 @@ function registerJobCommand(program2, deps) {
|
|
|
150128
150627
|
throw new UsageError(`No member of the job's pool can be picked right now.`);
|
|
150129
150628
|
}
|
|
150130
150629
|
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 ${
|
|
150630
|
+
console.log(`Ran job "${name}" as ${identity}; the result is in ${import_node_path66.default.join(paths.jobLogsDir, `${name}.log`)}.`);
|
|
150132
150631
|
}),
|
|
150133
150632
|
["agent-shim job run digest"]
|
|
150134
150633
|
);
|
|
@@ -150292,7 +150791,7 @@ init_providerAliases();
|
|
|
150292
150791
|
|
|
150293
150792
|
// src/providerRename.ts
|
|
150294
150793
|
var import_node_fs26 = __toESM(require("node:fs"), 1);
|
|
150295
|
-
var
|
|
150794
|
+
var import_node_path67 = __toESM(require("node:path"), 1);
|
|
150296
150795
|
init_schema();
|
|
150297
150796
|
init_store();
|
|
150298
150797
|
init_load();
|
|
@@ -150409,7 +150908,7 @@ function rewriteReferences(paths, from, to2) {
|
|
|
150409
150908
|
const launch = renamedLaunch(profile.launch, from, to2);
|
|
150410
150909
|
const models = profile.models === void 0 ? void 0 : renamedModels(profile.models, from, to2);
|
|
150411
150910
|
if (launch !== void 0 || models !== void 0) {
|
|
150412
|
-
applyPatch(
|
|
150911
|
+
applyPatch(import_node_path67.default.join(paths.configProfilesDir, `${name}.json`), ConfigProfileSchema, { ...launch === void 0 ? {} : { launch }, ...models === void 0 ? {} : { models } });
|
|
150413
150912
|
rewritten.push(`profile ${name}`);
|
|
150414
150913
|
}
|
|
150415
150914
|
}
|
|
@@ -151236,7 +151735,7 @@ function registerSessionCommands(program2, deps) {
|
|
|
151236
151735
|
}
|
|
151237
151736
|
|
|
151238
151737
|
// src/usage/commands.ts
|
|
151239
|
-
var
|
|
151738
|
+
var import_node_path68 = __toESM(require("node:path"), 1);
|
|
151240
151739
|
init_commandDeps();
|
|
151241
151740
|
init_realPorts();
|
|
151242
151741
|
init_account();
|
|
@@ -151375,7 +151874,7 @@ function collectAccounts(fs30, paths, identity, probe) {
|
|
|
151375
151874
|
return names.map((name) => ({
|
|
151376
151875
|
identity: name,
|
|
151377
151876
|
account: readAccountMetadata(fs30, paths.identitiesDir, name),
|
|
151378
|
-
signIn: identitySignIn(fs30, probe, { farmRoot:
|
|
151877
|
+
signIn: identitySignIn(fs30, probe, { farmRoot: import_node_path68.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
|
|
151379
151878
|
usage: readUsageSnapshot(fs30, paths.usageSnapshotsDir, name)
|
|
151380
151879
|
}));
|
|
151381
151880
|
}
|
|
@@ -151782,7 +152281,7 @@ function quotaHitOf(fs30, paths, identity, sessionId, sinceMs, nowMs) {
|
|
|
151782
152281
|
}
|
|
151783
152282
|
|
|
151784
152283
|
// src/supervise/move.ts
|
|
151785
|
-
var
|
|
152284
|
+
var import_node_path69 = __toESM(require("node:path"), 1);
|
|
151786
152285
|
init_lock();
|
|
151787
152286
|
init_poolPick();
|
|
151788
152287
|
init_read();
|
|
@@ -151828,7 +152327,7 @@ function createMover(deps) {
|
|
|
151828
152327
|
if (resolution.identity === request7.from) {
|
|
151829
152328
|
return { kind: "stay", reason: `no other member of pool "${pool}" can take it` };
|
|
151830
152329
|
}
|
|
151831
|
-
const transcript =
|
|
152330
|
+
const transcript = import_node_path69.default.join(paths.identitiesDir, resolution.identity, "projects", projectDirNameOf(deps.cwd), `${request7.sessionId}.jsonl`);
|
|
151832
152331
|
if (farmFs.lstat(transcript)?.kind !== "file") {
|
|
151833
152332
|
return { kind: "stay", reason: `${resolution.identity} does not share this conversation's history, so it could not resume it` };
|
|
151834
152333
|
}
|
|
@@ -151862,13 +152361,13 @@ function createIdentityMover(deps) {
|
|
|
151862
152361
|
throw error63;
|
|
151863
152362
|
}
|
|
151864
152363
|
try {
|
|
151865
|
-
if (farmFs.readFileUtf8(
|
|
152364
|
+
if (farmFs.readFileUtf8(import_node_path69.default.join(paths.identitiesDir, request7.to, "identity.json")) === void 0) {
|
|
151866
152365
|
return { kind: "stay", reason: `no identity "${request7.to}"` };
|
|
151867
152366
|
}
|
|
151868
152367
|
if (request7.to === request7.from) {
|
|
151869
152368
|
return { kind: "stay", reason: `the model already runs under this session's identity` };
|
|
151870
152369
|
}
|
|
151871
|
-
const transcript =
|
|
152370
|
+
const transcript = import_node_path69.default.join(paths.identitiesDir, request7.to, "projects", projectDirNameOf(deps.cwd), `${request7.sessionId}.jsonl`);
|
|
151872
152371
|
if (farmFs.lstat(transcript)?.kind !== "file") {
|
|
151873
152372
|
return { kind: "stay", reason: `${request7.to} does not share this conversation's history, so it could not resume it` };
|
|
151874
152373
|
}
|
|
@@ -151890,12 +152389,13 @@ function createIdentityMover(deps) {
|
|
|
151890
152389
|
}
|
|
151891
152390
|
|
|
151892
152391
|
// src/supervise/realPorts.ts
|
|
151893
|
-
var
|
|
152392
|
+
var import_node_child_process10 = require("node:child_process");
|
|
151894
152393
|
var import_node_fs28 = __toESM(require("node:fs"), 1);
|
|
151895
152394
|
init_realPorts();
|
|
152395
|
+
init_blockingSpawn();
|
|
151896
152396
|
var realSupervisedSpawnPort = {
|
|
151897
152397
|
spawn(command, args, options) {
|
|
151898
|
-
const child = (0,
|
|
152398
|
+
const child = (0, import_node_child_process10.spawn)(command, [...args], { stdio: options.stdio, env: { ...options.env } });
|
|
151899
152399
|
const exit = new Promise((resolve2) => {
|
|
151900
152400
|
child.once("error", (error63) => {
|
|
151901
152401
|
resolve2({ status: null, signal: null, error: error63 });
|
|
@@ -151957,7 +152457,7 @@ function resetTerminal() {
|
|
|
151957
152457
|
return;
|
|
151958
152458
|
}
|
|
151959
152459
|
process.stdout.write(TERMINAL_RESET);
|
|
151960
|
-
(
|
|
152460
|
+
spawnSyncBlocking("a terminal reset", "stty", ["sane"], { stdio: ["inherit", "ignore", "ignore"] });
|
|
151961
152461
|
}
|
|
151962
152462
|
|
|
151963
152463
|
// src/supervise/supervise.ts
|
|
@@ -152446,7 +152946,7 @@ async function runClaude(argvOverride) {
|
|
|
152446
152946
|
// src/cli.ts
|
|
152447
152947
|
async function main() {
|
|
152448
152948
|
aliasLegacyEnv(process.env);
|
|
152449
|
-
const invokedName =
|
|
152949
|
+
const invokedName = import_node_path70.default.basename(process.argv[1] ?? "agent-shim");
|
|
152450
152950
|
if (isInvokedAsClaude(invokedName)) {
|
|
152451
152951
|
await runClaude();
|
|
152452
152952
|
return;
|