claude-use 11.13.0 → 11.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +516 -386
- package/dist/index.cjs +4 -2
- package/dist/index.mjs +4 -2
- 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, path61) {
|
|
322
|
+
if (!path61)
|
|
323
323
|
return obj;
|
|
324
|
-
return
|
|
324
|
+
return path61.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(path61, 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(path61);
|
|
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, path61 = []) => {
|
|
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 }, [...path61, ...issue2.path]));
|
|
1112
1112
|
} else if (issue2.code === "invalid_key") {
|
|
1113
|
-
processError({ issues: issue2.issues }, [...
|
|
1113
|
+
processError({ issues: issue2.issues }, [...path61, ...issue2.path]);
|
|
1114
1114
|
} else if (issue2.code === "invalid_element") {
|
|
1115
|
-
processError({ issues: issue2.issues }, [...
|
|
1115
|
+
processError({ issues: issue2.issues }, [...path61, ...issue2.path]);
|
|
1116
1116
|
} else {
|
|
1117
|
-
const fullpath = [...
|
|
1117
|
+
const fullpath = [...path61, ...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, path61 = []) => {
|
|
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 }, [...path61, ...issue2.path]));
|
|
1161
1161
|
} else if (issue2.code === "invalid_key") {
|
|
1162
|
-
processError({ issues: issue2.issues }, [...
|
|
1162
|
+
processError({ issues: issue2.issues }, [...path61, ...issue2.path]);
|
|
1163
1163
|
} else if (issue2.code === "invalid_element") {
|
|
1164
|
-
processError({ issues: issue2.issues }, [...
|
|
1164
|
+
processError({ issues: issue2.issues }, [...path61, ...issue2.path]);
|
|
1165
1165
|
} else {
|
|
1166
|
-
const fullpath = [...
|
|
1166
|
+
const fullpath = [...path61, ...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 path61 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1206
|
+
for (const seg of path61) {
|
|
1207
1207
|
if (typeof seg === "number")
|
|
1208
1208
|
segs.push(`[${seg}]`);
|
|
1209
1209
|
else if (typeof seg === "symbol")
|
|
@@ -3494,7 +3494,7 @@ var init_schemas = __esm({
|
|
|
3494
3494
|
}
|
|
3495
3495
|
return propValues;
|
|
3496
3496
|
});
|
|
3497
|
-
const
|
|
3497
|
+
const isObject5 = isObject;
|
|
3498
3498
|
const catchall = def.catchall;
|
|
3499
3499
|
let value2;
|
|
3500
3500
|
const memo2 = globalConfig.memoizer;
|
|
@@ -3502,7 +3502,7 @@ var init_schemas = __esm({
|
|
|
3502
3502
|
inst._zod.parse = (payload, ctx) => {
|
|
3503
3503
|
value2 ?? (value2 = _normalized.value);
|
|
3504
3504
|
const input2 = payload.value;
|
|
3505
|
-
if (!
|
|
3505
|
+
if (!isObject5(input2)) {
|
|
3506
3506
|
payload.issues.push({
|
|
3507
3507
|
expected: "object",
|
|
3508
3508
|
code: "invalid_type",
|
|
@@ -3638,7 +3638,7 @@ var init_schemas = __esm({
|
|
|
3638
3638
|
return doc.compile();
|
|
3639
3639
|
};
|
|
3640
3640
|
let fastpass;
|
|
3641
|
-
const
|
|
3641
|
+
const isObject5 = isObject;
|
|
3642
3642
|
const jit = !globalConfig.jitless;
|
|
3643
3643
|
const allowsEval2 = allowsEval;
|
|
3644
3644
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -3647,7 +3647,7 @@ var init_schemas = __esm({
|
|
|
3647
3647
|
inst._zod.parse = (payload, ctx) => {
|
|
3648
3648
|
value2 ?? (value2 = _normalized.value);
|
|
3649
3649
|
const input2 = payload.value;
|
|
3650
|
-
if (!
|
|
3650
|
+
if (!isObject5(input2)) {
|
|
3651
3651
|
payload.issues.push({
|
|
3652
3652
|
expected: "object",
|
|
3653
3653
|
code: "invalid_type",
|
|
@@ -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 path61 = ref.slice(1).split("/").filter(Boolean);
|
|
19203
|
+
if (path61.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 (path61[0] === defsKey) {
|
|
19208
|
+
const key = path61[1] === void 0 ? void 0 : decodeJSONPointerSegment(path61[1]);
|
|
19209
19209
|
if (!key || !ctx.defs[key]) {
|
|
19210
19210
|
throw new Error(`Reference not found: ${ref}`);
|
|
19211
19211
|
}
|
|
@@ -20505,7 +20505,7 @@ var require_common = __commonJS({
|
|
|
20505
20505
|
function isNothing(subject) {
|
|
20506
20506
|
return typeof subject === "undefined" || subject === null;
|
|
20507
20507
|
}
|
|
20508
|
-
function
|
|
20508
|
+
function isObject5(subject) {
|
|
20509
20509
|
return typeof subject === "object" && subject !== null;
|
|
20510
20510
|
}
|
|
20511
20511
|
function toArray2(sequence2) {
|
|
@@ -20534,7 +20534,7 @@ var require_common = __commonJS({
|
|
|
20534
20534
|
return number4 === 0 && Number.NEGATIVE_INFINITY === 1 / number4;
|
|
20535
20535
|
}
|
|
20536
20536
|
module2.exports.isNothing = isNothing;
|
|
20537
|
-
module2.exports.isObject =
|
|
20537
|
+
module2.exports.isObject = isObject5;
|
|
20538
20538
|
module2.exports.toArray = toArray2;
|
|
20539
20539
|
module2.exports.repeat = repeat;
|
|
20540
20540
|
module2.exports.isNegativeZero = isNegativeZero;
|
|
@@ -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
|
|
23716
|
-
var
|
|
23717
|
-
var homedir =
|
|
23718
|
-
var tmpdir =
|
|
23715
|
+
var path61 = require("path");
|
|
23716
|
+
var os13 = require("os");
|
|
23717
|
+
var homedir = os13.homedir();
|
|
23718
|
+
var tmpdir = os13.tmpdir();
|
|
23719
23719
|
var { env } = process;
|
|
23720
23720
|
var macos = (name) => {
|
|
23721
|
-
const library =
|
|
23721
|
+
const library = path61.join(homedir, "Library");
|
|
23722
23722
|
return {
|
|
23723
|
-
data:
|
|
23724
|
-
config:
|
|
23725
|
-
cache:
|
|
23726
|
-
log:
|
|
23727
|
-
temp:
|
|
23723
|
+
data: path61.join(library, "Application Support", name),
|
|
23724
|
+
config: path61.join(library, "Preferences", name),
|
|
23725
|
+
cache: path61.join(library, "Caches", name),
|
|
23726
|
+
log: path61.join(library, "Logs", name),
|
|
23727
|
+
temp: path61.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 || path61.join(homedir, "AppData", "Roaming");
|
|
23732
|
+
const localAppData = env.LOCALAPPDATA || path61.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: path61.join(localAppData, name, "Data"),
|
|
23736
|
+
config: path61.join(appData, name, "Config"),
|
|
23737
|
+
cache: path61.join(localAppData, name, "Cache"),
|
|
23738
|
+
log: path61.join(localAppData, name, "Log"),
|
|
23739
|
+
temp: path61.join(tmpdir, name)
|
|
23740
23740
|
};
|
|
23741
23741
|
};
|
|
23742
23742
|
var linux = (name) => {
|
|
23743
|
-
const username =
|
|
23743
|
+
const username = path61.basename(homedir);
|
|
23744
23744
|
return {
|
|
23745
|
-
data:
|
|
23746
|
-
config:
|
|
23747
|
-
cache:
|
|
23745
|
+
data: path61.join(env.XDG_DATA_HOME || path61.join(homedir, ".local", "share"), name),
|
|
23746
|
+
config: path61.join(env.XDG_CONFIG_HOME || path61.join(homedir, ".config"), name),
|
|
23747
|
+
cache: path61.join(env.XDG_CACHE_HOME || path61.join(homedir, ".cache"), name),
|
|
23748
23748
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
23749
|
-
log:
|
|
23750
|
-
temp:
|
|
23749
|
+
log: path61.join(env.XDG_STATE_HOME || path61.join(homedir, ".local", "state"), name),
|
|
23750
|
+
temp: path61.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, path61) {
|
|
23819
|
+
if (typeof path61 === "string" && Object.prototype.hasOwnProperty.call(source, path61)) {
|
|
23820
|
+
return source[path61];
|
|
23821
23821
|
}
|
|
23822
|
-
const parsedPath = typeof
|
|
23822
|
+
const parsedPath = typeof path61 === "string" ? path61.split(".") : path61;
|
|
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(path61) {
|
|
23846
23846
|
try {
|
|
23847
|
-
const stat = await fs_1.promises.stat(
|
|
23847
|
+
const stat = await fs_1.promises.stat(path61);
|
|
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(path61) {
|
|
23858
23858
|
try {
|
|
23859
|
-
const stat = fs_1.default.statSync(
|
|
23859
|
+
const stat = fs_1.default.statSync(path61);
|
|
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((path61, i10) => `${i10 + 1}. ${path61}`).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(path61) {
|
|
24146
24146
|
try {
|
|
24147
|
-
await promises_1.default.stat(
|
|
24147
|
+
await promises_1.default.stat(path61);
|
|
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(path61) {
|
|
24308
24308
|
try {
|
|
24309
|
-
fs_1.default.statSync(
|
|
24309
|
+
fs_1.default.statSync(path61);
|
|
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((path61) => path61.replace("{name}", moduleName));
|
|
24434
24434
|
if (userConfiguredOptions.mergeSearchPlaces) {
|
|
24435
24435
|
return [...userConfiguredSearchPlaces ?? [], ...toolDefinedSearchPlaces];
|
|
24436
24436
|
}
|
|
@@ -29683,8 +29683,8 @@ var require_utils = __commonJS({
|
|
|
29683
29683
|
}
|
|
29684
29684
|
return output2;
|
|
29685
29685
|
};
|
|
29686
|
-
exports2.basename = (
|
|
29687
|
-
const segs =
|
|
29686
|
+
exports2.basename = (path61, { windows } = {}) => {
|
|
29687
|
+
const segs = path61.split(windows ? /[\\/]/ : "/");
|
|
29688
29688
|
const last = segs[segs.length - 1];
|
|
29689
29689
|
if (last === "") {
|
|
29690
29690
|
return segs[segs.length - 2];
|
|
@@ -31055,7 +31055,7 @@ var require_picomatch = __commonJS({
|
|
|
31055
31055
|
var parse4 = require_parse();
|
|
31056
31056
|
var utils = require_utils();
|
|
31057
31057
|
var constants2 = require_constants();
|
|
31058
|
-
var
|
|
31058
|
+
var isObject5 = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
31059
31059
|
var picomatch3 = (glob, options, returnState = false) => {
|
|
31060
31060
|
if (Array.isArray(glob)) {
|
|
31061
31061
|
const fns = glob.map((input2) => picomatch3(input2, options, returnState));
|
|
@@ -31068,7 +31068,7 @@ var require_picomatch = __commonJS({
|
|
|
31068
31068
|
};
|
|
31069
31069
|
return arrayMatcher;
|
|
31070
31070
|
}
|
|
31071
|
-
const isState =
|
|
31071
|
+
const isState = isObject5(glob) && glob.tokens && glob.input;
|
|
31072
31072
|
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
31073
31073
|
throw new TypeError("Expected pattern to be a non-empty string");
|
|
31074
31074
|
}
|
|
@@ -34093,7 +34093,7 @@ var init_package = __esm({
|
|
|
34093
34093
|
"package.json"() {
|
|
34094
34094
|
package_default = {
|
|
34095
34095
|
name: "claude-use",
|
|
34096
|
-
version: "11.
|
|
34096
|
+
version: "11.14.0",
|
|
34097
34097
|
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.",
|
|
34098
34098
|
license: "MIT",
|
|
34099
34099
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -34210,7 +34210,9 @@ function readAccountMetadata(fs24, identitiesDir, identity) {
|
|
|
34210
34210
|
if (!isIdentityName(identity)) {
|
|
34211
34211
|
throw new Error(`"${identity}" is not a valid identity name.`);
|
|
34212
34212
|
}
|
|
34213
|
-
|
|
34213
|
+
return readAccountMetadataFile(fs24, claudeJsonPath(identitiesDir, identity));
|
|
34214
|
+
}
|
|
34215
|
+
function readAccountMetadataFile(fs24, file2) {
|
|
34214
34216
|
const raw = fs24.readFileUtf8(file2);
|
|
34215
34217
|
if (raw === void 0) {
|
|
34216
34218
|
return void 0;
|
|
@@ -34364,11 +34366,11 @@ function identifyRequest(headers) {
|
|
|
34364
34366
|
function directOrigin2(port) {
|
|
34365
34367
|
return `http://127.0.0.1:${String(port)}`;
|
|
34366
34368
|
}
|
|
34367
|
-
function parseProviderPath(
|
|
34368
|
-
if (!
|
|
34369
|
+
function parseProviderPath(path61) {
|
|
34370
|
+
if (!path61.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
34369
34371
|
return void 0;
|
|
34370
34372
|
}
|
|
34371
|
-
const tail =
|
|
34373
|
+
const tail = path61.slice(PROVIDER_PATH_PREFIX.length);
|
|
34372
34374
|
const slash = tail.indexOf("/");
|
|
34373
34375
|
if (slash <= 0) {
|
|
34374
34376
|
return void 0;
|
|
@@ -34695,12 +34697,12 @@ function decoderFor(encoding) {
|
|
|
34695
34697
|
return void 0;
|
|
34696
34698
|
}
|
|
34697
34699
|
}
|
|
34698
|
-
function destinationOf(
|
|
34699
|
-
const scoped = parseProviderPath(
|
|
34700
|
+
function destinationOf(path61, sessionProvider) {
|
|
34701
|
+
const scoped = parseProviderPath(path61);
|
|
34700
34702
|
if (scoped !== void 0) {
|
|
34701
34703
|
return { provider: scoped.provider, endpoint: scoped.rest };
|
|
34702
34704
|
}
|
|
34703
|
-
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint:
|
|
34705
|
+
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint: path61 };
|
|
34704
34706
|
}
|
|
34705
34707
|
function buildRecord(event, context) {
|
|
34706
34708
|
const { scan } = context;
|
|
@@ -37203,14 +37205,14 @@ var require_util2 = __commonJS({
|
|
|
37203
37205
|
}
|
|
37204
37206
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
37205
37207
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
37206
|
-
let
|
|
37208
|
+
let path61 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
37207
37209
|
if (origin[origin.length - 1] === "/") {
|
|
37208
37210
|
origin = origin.slice(0, origin.length - 1);
|
|
37209
37211
|
}
|
|
37210
|
-
if (
|
|
37211
|
-
|
|
37212
|
+
if (path61 && path61[0] !== "/") {
|
|
37213
|
+
path61 = `/${path61}`;
|
|
37212
37214
|
}
|
|
37213
|
-
return new URL(`${origin}${
|
|
37215
|
+
return new URL(`${origin}${path61}`);
|
|
37214
37216
|
}
|
|
37215
37217
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
37216
37218
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -38031,9 +38033,9 @@ var require_diagnostics = __commonJS({
|
|
|
38031
38033
|
"undici:client:sendHeaders",
|
|
38032
38034
|
(evt) => {
|
|
38033
38035
|
const {
|
|
38034
|
-
request: { method, path:
|
|
38036
|
+
request: { method, path: path61, origin }
|
|
38035
38037
|
} = evt;
|
|
38036
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
38038
|
+
debugLog("sending request to %s %s%s", method, origin, path61);
|
|
38037
38039
|
}
|
|
38038
38040
|
);
|
|
38039
38041
|
}
|
|
@@ -38051,14 +38053,14 @@ var require_diagnostics = __commonJS({
|
|
|
38051
38053
|
"undici:request:headers",
|
|
38052
38054
|
(evt) => {
|
|
38053
38055
|
const {
|
|
38054
|
-
request: { method, path:
|
|
38056
|
+
request: { method, path: path61, origin },
|
|
38055
38057
|
response: { statusCode }
|
|
38056
38058
|
} = evt;
|
|
38057
38059
|
debugLog(
|
|
38058
38060
|
"received response to %s %s%s - HTTP %d",
|
|
38059
38061
|
method,
|
|
38060
38062
|
origin,
|
|
38061
|
-
|
|
38063
|
+
path61,
|
|
38062
38064
|
statusCode
|
|
38063
38065
|
);
|
|
38064
38066
|
}
|
|
@@ -38067,23 +38069,23 @@ var require_diagnostics = __commonJS({
|
|
|
38067
38069
|
"undici:request:trailers",
|
|
38068
38070
|
(evt) => {
|
|
38069
38071
|
const {
|
|
38070
|
-
request: { method, path:
|
|
38072
|
+
request: { method, path: path61, origin }
|
|
38071
38073
|
} = evt;
|
|
38072
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
38074
|
+
debugLog("trailers received from %s %s%s", method, origin, path61);
|
|
38073
38075
|
}
|
|
38074
38076
|
);
|
|
38075
38077
|
diagnosticsChannel.subscribe(
|
|
38076
38078
|
"undici:request:error",
|
|
38077
38079
|
(evt) => {
|
|
38078
38080
|
const {
|
|
38079
|
-
request: { method, path:
|
|
38081
|
+
request: { method, path: path61, origin },
|
|
38080
38082
|
error: error63
|
|
38081
38083
|
} = evt;
|
|
38082
38084
|
debugLog(
|
|
38083
38085
|
"request to %s %s%s errored - %s",
|
|
38084
38086
|
method,
|
|
38085
38087
|
origin,
|
|
38086
|
-
|
|
38088
|
+
path61,
|
|
38087
38089
|
error63.message
|
|
38088
38090
|
);
|
|
38089
38091
|
}
|
|
@@ -38198,7 +38200,7 @@ var require_request = __commonJS({
|
|
|
38198
38200
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
38199
38201
|
var Request2 = class {
|
|
38200
38202
|
constructor(origin, {
|
|
38201
|
-
path:
|
|
38203
|
+
path: path61,
|
|
38202
38204
|
method,
|
|
38203
38205
|
body,
|
|
38204
38206
|
headers,
|
|
@@ -38215,11 +38217,11 @@ var require_request = __commonJS({
|
|
|
38215
38217
|
maxRedirections,
|
|
38216
38218
|
typeOfService
|
|
38217
38219
|
}, handler) {
|
|
38218
|
-
if (typeof
|
|
38220
|
+
if (typeof path61 !== "string") {
|
|
38219
38221
|
throw new InvalidArgumentError2("path must be a string");
|
|
38220
|
-
} else if (
|
|
38222
|
+
} else if (path61[0] !== "/" && !(path61.startsWith("http://") || path61.startsWith("https://")) && method !== "CONNECT") {
|
|
38221
38223
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
38222
|
-
} else if (invalidPathRegex.test(
|
|
38224
|
+
} else if (invalidPathRegex.test(path61)) {
|
|
38223
38225
|
throw new InvalidArgumentError2("invalid request path");
|
|
38224
38226
|
}
|
|
38225
38227
|
if (typeof method !== "string") {
|
|
@@ -38294,7 +38296,7 @@ var require_request = __commonJS({
|
|
|
38294
38296
|
this.completed = false;
|
|
38295
38297
|
this.aborted = false;
|
|
38296
38298
|
this.upgrade = upgrade || null;
|
|
38297
|
-
this.path = query ? serializePathWithQuery(
|
|
38299
|
+
this.path = query ? serializePathWithQuery(path61, query) : path61;
|
|
38298
38300
|
this.origin = origin;
|
|
38299
38301
|
this.protocol = getProtocolFromUrlString(origin);
|
|
38300
38302
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -43476,7 +43478,7 @@ var require_client_h1 = __commonJS({
|
|
|
43476
43478
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
43477
43479
|
}
|
|
43478
43480
|
function writeH1(client, request7) {
|
|
43479
|
-
const { method, path:
|
|
43481
|
+
const { method, path: path61, host, upgrade, blocking, reset } = request7;
|
|
43480
43482
|
let { body, headers, contentLength } = request7;
|
|
43481
43483
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
43482
43484
|
if (util2.isFormDataLike(body)) {
|
|
@@ -43554,7 +43556,7 @@ var require_client_h1 = __commonJS({
|
|
|
43554
43556
|
if (socket.setTypeOfService) {
|
|
43555
43557
|
socket.setTypeOfService(request7.typeOfService);
|
|
43556
43558
|
}
|
|
43557
|
-
let header = `${method} ${
|
|
43559
|
+
let header = `${method} ${path61} HTTP/1.1\r
|
|
43558
43560
|
`;
|
|
43559
43561
|
if (typeof host === "string") {
|
|
43560
43562
|
header += `host: ${host}\r
|
|
@@ -44233,7 +44235,7 @@ var require_client_h2 = __commonJS({
|
|
|
44233
44235
|
const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
|
|
44234
44236
|
const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
|
|
44235
44237
|
const session = client[kHTTP2Session];
|
|
44236
|
-
const { method, path:
|
|
44238
|
+
const { method, path: path61, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
|
|
44237
44239
|
let { body } = request7;
|
|
44238
44240
|
if (upgrade != null && upgrade !== "websocket") {
|
|
44239
44241
|
util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -44302,7 +44304,7 @@ var require_client_h2 = __commonJS({
|
|
|
44302
44304
|
}
|
|
44303
44305
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
44304
44306
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
44305
|
-
headers[HTTP2_HEADER_PATH] =
|
|
44307
|
+
headers[HTTP2_HEADER_PATH] = path61;
|
|
44306
44308
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
44307
44309
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
44308
44310
|
} else {
|
|
@@ -44344,7 +44346,7 @@ var require_client_h2 = __commonJS({
|
|
|
44344
44346
|
stream.setTimeout(headersTimeout);
|
|
44345
44347
|
return true;
|
|
44346
44348
|
}
|
|
44347
|
-
headers[HTTP2_HEADER_PATH] =
|
|
44349
|
+
headers[HTTP2_HEADER_PATH] = path61;
|
|
44348
44350
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
44349
44351
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
44350
44352
|
if (body && typeof body.read === "function") {
|
|
@@ -46696,10 +46698,10 @@ var require_proxy_agent = __commonJS({
|
|
|
46696
46698
|
};
|
|
46697
46699
|
const {
|
|
46698
46700
|
origin,
|
|
46699
|
-
path:
|
|
46701
|
+
path: path61 = "/",
|
|
46700
46702
|
headers = {}
|
|
46701
46703
|
} = opts;
|
|
46702
|
-
opts.path = origin +
|
|
46704
|
+
opts.path = origin + path61;
|
|
46703
46705
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
46704
46706
|
const { host } = new URL(origin);
|
|
46705
46707
|
headers.host = host;
|
|
@@ -48808,20 +48810,20 @@ var require_mock_utils = __commonJS({
|
|
|
48808
48810
|
}
|
|
48809
48811
|
return normalizedQp;
|
|
48810
48812
|
}
|
|
48811
|
-
function safeUrl(
|
|
48812
|
-
if (typeof
|
|
48813
|
-
return
|
|
48813
|
+
function safeUrl(path61) {
|
|
48814
|
+
if (typeof path61 !== "string") {
|
|
48815
|
+
return path61;
|
|
48814
48816
|
}
|
|
48815
|
-
const pathSegments =
|
|
48817
|
+
const pathSegments = path61.split("?", 3);
|
|
48816
48818
|
if (pathSegments.length !== 2) {
|
|
48817
|
-
return
|
|
48819
|
+
return path61;
|
|
48818
48820
|
}
|
|
48819
48821
|
const qp2 = new URLSearchParams(pathSegments.pop());
|
|
48820
48822
|
qp2.sort();
|
|
48821
48823
|
return [...pathSegments, qp2.toString()].join("?");
|
|
48822
48824
|
}
|
|
48823
|
-
function matchKey(mockDispatch2, { path:
|
|
48824
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
48825
|
+
function matchKey(mockDispatch2, { path: path61, method, body, headers }) {
|
|
48826
|
+
const pathMatch = matchValue(mockDispatch2.path, path61);
|
|
48825
48827
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
48826
48828
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
48827
48829
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -48846,8 +48848,8 @@ var require_mock_utils = __commonJS({
|
|
|
48846
48848
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
48847
48849
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
48848
48850
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
48849
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
48850
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
48851
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path61, ignoreTrailingSlash }) => {
|
|
48852
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path61)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path61), resolvedPath);
|
|
48851
48853
|
});
|
|
48852
48854
|
if (matchedMockDispatches.length === 0) {
|
|
48853
48855
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -48886,19 +48888,19 @@ var require_mock_utils = __commonJS({
|
|
|
48886
48888
|
mockDispatches.splice(index, 1);
|
|
48887
48889
|
}
|
|
48888
48890
|
}
|
|
48889
|
-
function removeTrailingSlash(
|
|
48890
|
-
while (
|
|
48891
|
-
|
|
48891
|
+
function removeTrailingSlash(path61) {
|
|
48892
|
+
while (path61.endsWith("/")) {
|
|
48893
|
+
path61 = path61.slice(0, -1);
|
|
48892
48894
|
}
|
|
48893
|
-
if (
|
|
48894
|
-
|
|
48895
|
+
if (path61.length === 0) {
|
|
48896
|
+
path61 = "/";
|
|
48895
48897
|
}
|
|
48896
|
-
return
|
|
48898
|
+
return path61;
|
|
48897
48899
|
}
|
|
48898
48900
|
function buildKey(opts) {
|
|
48899
|
-
const { path:
|
|
48901
|
+
const { path: path61, method, body, headers, query } = opts;
|
|
48900
48902
|
return {
|
|
48901
|
-
path:
|
|
48903
|
+
path: path61,
|
|
48902
48904
|
method,
|
|
48903
48905
|
body,
|
|
48904
48906
|
headers,
|
|
@@ -49588,10 +49590,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
49588
49590
|
}
|
|
49589
49591
|
format(pendingInterceptors) {
|
|
49590
49592
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
49591
|
-
({ method, path:
|
|
49593
|
+
({ method, path: path61, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
49592
49594
|
Method: method,
|
|
49593
49595
|
Origin: origin,
|
|
49594
|
-
Path:
|
|
49596
|
+
Path: path61,
|
|
49595
49597
|
"Status code": statusCode,
|
|
49596
49598
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
49597
49599
|
Invocations: timesInvoked,
|
|
@@ -49673,9 +49675,9 @@ var require_mock_agent = __commonJS({
|
|
|
49673
49675
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
49674
49676
|
const dispatchOpts = { ...opts };
|
|
49675
49677
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
49676
|
-
const [
|
|
49678
|
+
const [path61, searchParams] = dispatchOpts.path.split("?");
|
|
49677
49679
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
49678
|
-
dispatchOpts.path = `${
|
|
49680
|
+
dispatchOpts.path = `${path61}?${normalizedSearchParams}`;
|
|
49679
49681
|
}
|
|
49680
49682
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
49681
49683
|
}
|
|
@@ -50076,12 +50078,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
50076
50078
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
50077
50079
|
*/
|
|
50078
50080
|
async loadSnapshots(filePath) {
|
|
50079
|
-
const
|
|
50080
|
-
if (!
|
|
50081
|
+
const path61 = filePath || this.#snapshotPath;
|
|
50082
|
+
if (!path61) {
|
|
50081
50083
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
50082
50084
|
}
|
|
50083
50085
|
try {
|
|
50084
|
-
const data = await readFile(resolve2(
|
|
50086
|
+
const data = await readFile(resolve2(path61), "utf8");
|
|
50085
50087
|
const parsed = JSON.parse(data);
|
|
50086
50088
|
if (Array.isArray(parsed)) {
|
|
50087
50089
|
this.#snapshots.clear();
|
|
@@ -50095,7 +50097,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
50095
50097
|
if (error63.code === "ENOENT") {
|
|
50096
50098
|
this.#snapshots.clear();
|
|
50097
50099
|
} else {
|
|
50098
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
50100
|
+
throw new UndiciError(`Failed to load snapshots from ${path61}`, { cause: error63 });
|
|
50099
50101
|
}
|
|
50100
50102
|
}
|
|
50101
50103
|
}
|
|
@@ -50106,11 +50108,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
50106
50108
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
50107
50109
|
*/
|
|
50108
50110
|
async saveSnapshots(filePath) {
|
|
50109
|
-
const
|
|
50110
|
-
if (!
|
|
50111
|
+
const path61 = filePath || this.#snapshotPath;
|
|
50112
|
+
if (!path61) {
|
|
50111
50113
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
50112
50114
|
}
|
|
50113
|
-
const resolvedPath = resolve2(
|
|
50115
|
+
const resolvedPath = resolve2(path61);
|
|
50114
50116
|
await mkdir(dirname3(resolvedPath), { recursive: true });
|
|
50115
50117
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
50116
50118
|
hash: hash2,
|
|
@@ -50742,15 +50744,15 @@ var require_redirect_handler = __commonJS({
|
|
|
50742
50744
|
return;
|
|
50743
50745
|
}
|
|
50744
50746
|
const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
50745
|
-
const
|
|
50746
|
-
const redirectUrlString = `${origin}${
|
|
50747
|
+
const path61 = search ? `${pathname}${search}` : pathname;
|
|
50748
|
+
const redirectUrlString = `${origin}${path61}`;
|
|
50747
50749
|
for (const historyUrl of this.history) {
|
|
50748
50750
|
if (historyUrl.toString() === redirectUrlString) {
|
|
50749
50751
|
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.`);
|
|
50750
50752
|
}
|
|
50751
50753
|
}
|
|
50752
50754
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
50753
|
-
this.opts.path =
|
|
50755
|
+
this.opts.path = path61;
|
|
50754
50756
|
this.opts.origin = origin;
|
|
50755
50757
|
this.opts.query = null;
|
|
50756
50758
|
}
|
|
@@ -52510,10 +52512,10 @@ var require_cache_handler = __commonJS({
|
|
|
52510
52512
|
}
|
|
52511
52513
|
return locationUrl.pathname + locationUrl.search;
|
|
52512
52514
|
}
|
|
52513
|
-
function deleteCachedUri(store, cacheKey,
|
|
52515
|
+
function deleteCachedUri(store, cacheKey, path61) {
|
|
52514
52516
|
deleteCachedValue(store, {
|
|
52515
52517
|
...cacheKey,
|
|
52516
|
-
path:
|
|
52518
|
+
path: path61
|
|
52517
52519
|
});
|
|
52518
52520
|
for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
|
|
52519
52521
|
const method = util2.safeHTTPMethods[i10];
|
|
@@ -52521,7 +52523,7 @@ var require_cache_handler = __commonJS({
|
|
|
52521
52523
|
deleteCachedValue(store, {
|
|
52522
52524
|
...cacheKey,
|
|
52523
52525
|
method,
|
|
52524
|
-
path:
|
|
52526
|
+
path: path61
|
|
52525
52527
|
});
|
|
52526
52528
|
}
|
|
52527
52529
|
}
|
|
@@ -52532,9 +52534,9 @@ var require_cache_handler = __commonJS({
|
|
|
52532
52534
|
}
|
|
52533
52535
|
const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
|
|
52534
52536
|
for (let i10 = 0; i10 < values.length; i10++) {
|
|
52535
|
-
const
|
|
52536
|
-
if (
|
|
52537
|
-
deleteCachedUri(store, cacheKey,
|
|
52537
|
+
const path61 = getSameOriginPath(cacheKey, values[i10]);
|
|
52538
|
+
if (path61 !== void 0) {
|
|
52539
|
+
deleteCachedUri(store, cacheKey, path61);
|
|
52538
52540
|
}
|
|
52539
52541
|
}
|
|
52540
52542
|
}
|
|
@@ -57534,11 +57536,11 @@ var require_fetch = __commonJS({
|
|
|
57534
57536
|
function dispatch({ body }) {
|
|
57535
57537
|
const url2 = requestCurrentURL(request7);
|
|
57536
57538
|
const agent = fetchParams.controller.dispatcher;
|
|
57537
|
-
const
|
|
57539
|
+
const path61 = url2.pathname + url2.search;
|
|
57538
57540
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
57539
57541
|
return new Promise((resolve2, reject) => agent.dispatch(
|
|
57540
57542
|
{
|
|
57541
|
-
path: hasTrailingQuestionMark ? `${
|
|
57543
|
+
path: hasTrailingQuestionMark ? `${path61}?` : path61,
|
|
57542
57544
|
origin: url2.origin,
|
|
57543
57545
|
method: request7.method,
|
|
57544
57546
|
body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
|
|
@@ -58485,9 +58487,9 @@ var require_util5 = __commonJS({
|
|
|
58485
58487
|
}
|
|
58486
58488
|
}
|
|
58487
58489
|
}
|
|
58488
|
-
function validateCookiePath(
|
|
58489
|
-
for (let i10 = 0; i10 <
|
|
58490
|
-
const code =
|
|
58490
|
+
function validateCookiePath(path61) {
|
|
58491
|
+
for (let i10 = 0; i10 < path61.length; ++i10) {
|
|
58492
|
+
const code = path61.charCodeAt(i10);
|
|
58491
58493
|
if (code < 32 || // exclude CTLs (0-31)
|
|
58492
58494
|
code > 126 || // exclude DEL and non-ascii
|
|
58493
58495
|
code === 59) {
|
|
@@ -61835,11 +61837,11 @@ var require_undici = __commonJS({
|
|
|
61835
61837
|
if (typeof opts.path !== "string") {
|
|
61836
61838
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
61837
61839
|
}
|
|
61838
|
-
let
|
|
61840
|
+
let path61 = opts.path;
|
|
61839
61841
|
if (!opts.path.startsWith("/")) {
|
|
61840
|
-
|
|
61842
|
+
path61 = `/${path61}`;
|
|
61841
61843
|
}
|
|
61842
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
61844
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path61);
|
|
61843
61845
|
} else {
|
|
61844
61846
|
if (!opts) {
|
|
61845
61847
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -101227,8 +101229,8 @@ var require_utils3 = __commonJS({
|
|
|
101227
101229
|
}
|
|
101228
101230
|
return ind;
|
|
101229
101231
|
}
|
|
101230
|
-
function removeDotSegments(
|
|
101231
|
-
let input2 =
|
|
101232
|
+
function removeDotSegments(path61) {
|
|
101233
|
+
let input2 = path61;
|
|
101232
101234
|
const output2 = [];
|
|
101233
101235
|
let nextSlash = -1;
|
|
101234
101236
|
let len = 0;
|
|
@@ -101637,8 +101639,8 @@ var require_schemes = __commonJS({
|
|
|
101637
101639
|
}
|
|
101638
101640
|
if (wsComponent.resourceName) {
|
|
101639
101641
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
101640
|
-
const
|
|
101641
|
-
wsComponent.path =
|
|
101642
|
+
const path61 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
101643
|
+
wsComponent.path = path61 && path61 !== "/" ? path61 : void 0;
|
|
101642
101644
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
101643
101645
|
wsComponent.resourceName = void 0;
|
|
101644
101646
|
}
|
|
@@ -105165,7 +105167,7 @@ var require_dist2 = __commonJS({
|
|
|
105165
105167
|
});
|
|
105166
105168
|
|
|
105167
105169
|
// src/cli.ts
|
|
105168
|
-
var
|
|
105170
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
105169
105171
|
|
|
105170
105172
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
105171
105173
|
var CommanderError = class extends Error {
|
|
@@ -108278,9 +108280,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
108278
108280
|
* @param {string} [path]
|
|
108279
108281
|
* @return {(string|null|Command)}
|
|
108280
108282
|
*/
|
|
108281
|
-
executableDir(
|
|
108282
|
-
if (
|
|
108283
|
-
this._executableDir =
|
|
108283
|
+
executableDir(path61) {
|
|
108284
|
+
if (path61 === void 0) return this._executableDir;
|
|
108285
|
+
this._executableDir = path61;
|
|
108284
108286
|
return this;
|
|
108285
108287
|
}
|
|
108286
108288
|
/**
|
|
@@ -109929,19 +109931,19 @@ function writePools(paths, pools) {
|
|
|
109929
109931
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
109930
109932
|
}
|
|
109931
109933
|
function poolCycleOf(pools, name) {
|
|
109932
|
-
const walk2 = (current,
|
|
109934
|
+
const walk2 = (current, path61) => {
|
|
109933
109935
|
for (const entry of pools[current]?.identities ?? []) {
|
|
109934
109936
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
109935
109937
|
if (nested === void 0) {
|
|
109936
109938
|
continue;
|
|
109937
109939
|
}
|
|
109938
109940
|
if (nested === name) {
|
|
109939
|
-
return [...
|
|
109941
|
+
return [...path61, nested];
|
|
109940
109942
|
}
|
|
109941
|
-
if (
|
|
109943
|
+
if (path61.includes(nested)) {
|
|
109942
109944
|
continue;
|
|
109943
109945
|
}
|
|
109944
|
-
const found = walk2(nested, [...
|
|
109946
|
+
const found = walk2(nested, [...path61, nested]);
|
|
109945
109947
|
if (found !== void 0) {
|
|
109946
109948
|
return found;
|
|
109947
109949
|
}
|
|
@@ -114713,8 +114715,8 @@ function parseConnectTarget(authority) {
|
|
|
114713
114715
|
}
|
|
114714
114716
|
return { host, port };
|
|
114715
114717
|
}
|
|
114716
|
-
function servedByPipeline(
|
|
114717
|
-
return
|
|
114718
|
+
function servedByPipeline(path61) {
|
|
114719
|
+
return path61?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
114718
114720
|
}
|
|
114719
114721
|
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
114720
114722
|
"connection",
|
|
@@ -115399,11 +115401,11 @@ function createRcSessionTracker(deps) {
|
|
|
115399
115401
|
};
|
|
115400
115402
|
const observeExchange = (request7) => {
|
|
115401
115403
|
const method = (request7.method ?? "").toUpperCase();
|
|
115402
|
-
const
|
|
115403
|
-
if (!
|
|
115404
|
+
const path61 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
|
|
115405
|
+
if (!path61.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
115404
115406
|
return void 0;
|
|
115405
115407
|
}
|
|
115406
|
-
const tail =
|
|
115408
|
+
const tail = path61.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
115407
115409
|
const facts = {
|
|
115408
115410
|
oauthAuthorization: oauthAuthorizationOf(request7.headers),
|
|
115409
115411
|
anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
|
|
@@ -115772,8 +115774,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
115772
115774
|
function isRcReadFileEncoding(value2) {
|
|
115773
115775
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value2);
|
|
115774
115776
|
}
|
|
115775
|
-
function buildRcReadFilePayload(requestId,
|
|
115776
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
115777
|
+
function buildRcReadFilePayload(requestId, path61, options) {
|
|
115778
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path61, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
115777
115779
|
}
|
|
115778
115780
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
115779
115781
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -115875,15 +115877,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
115875
115877
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
115876
115878
|
return result.ok ? { ...result, requestId } : result;
|
|
115877
115879
|
}
|
|
115878
|
-
async function readRcSessionFile(deps, sessionId,
|
|
115879
|
-
if (
|
|
115880
|
+
async function readRcSessionFile(deps, sessionId, path61, options) {
|
|
115881
|
+
if (path61 === "") {
|
|
115880
115882
|
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" };
|
|
115881
115883
|
}
|
|
115882
115884
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
115883
115885
|
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" };
|
|
115884
115886
|
}
|
|
115885
115887
|
const requestId = deps.newUuid();
|
|
115886
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
115888
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path61, options), `read ${path61} from session ${sessionId}`);
|
|
115887
115889
|
return result.ok ? { ...result, requestId } : result;
|
|
115888
115890
|
}
|
|
115889
115891
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -116054,11 +116056,11 @@ function createRcControlHandler(deps) {
|
|
|
116054
116056
|
path: "read-file",
|
|
116055
116057
|
read: (body) => {
|
|
116056
116058
|
const session = bodyString(body, "session");
|
|
116057
|
-
const
|
|
116059
|
+
const path61 = bodyString(body, "path");
|
|
116058
116060
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
116059
116061
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
116060
|
-
const refused2 = session === void 0 ||
|
|
116061
|
-
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,
|
|
116062
|
+
const refused2 = session === void 0 || path61 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
116063
|
+
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, path61, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
116062
116064
|
}
|
|
116063
116065
|
},
|
|
116064
116066
|
{
|
|
@@ -116368,9 +116370,9 @@ function requestIdOfBody(body) {
|
|
|
116368
116370
|
}
|
|
116369
116371
|
function frontDoorRcControl(transport, token) {
|
|
116370
116372
|
const headers = { authorization: `Bearer ${token}` };
|
|
116371
|
-
const listAnswerOf = async (
|
|
116373
|
+
const listAnswerOf = async (path61, what) => {
|
|
116372
116374
|
try {
|
|
116373
|
-
return await transport.request({ method: "GET", path:
|
|
116375
|
+
return await transport.request({ method: "GET", path: path61, headers });
|
|
116374
116376
|
} catch (error63) {
|
|
116375
116377
|
throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
|
|
116376
116378
|
}
|
|
@@ -116442,10 +116444,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
116442
116444
|
}
|
|
116443
116445
|
return pending;
|
|
116444
116446
|
};
|
|
116445
|
-
const writeOf = async (
|
|
116447
|
+
const writeOf = async (path61, body, describeFailure2) => {
|
|
116446
116448
|
let answer;
|
|
116447
116449
|
try {
|
|
116448
|
-
answer = await transport.request({ method: "POST", path:
|
|
116450
|
+
answer = await transport.request({ method: "POST", path: path61, headers: { ...headers, "content-type": "application/json" }, body });
|
|
116449
116451
|
} catch (error63) {
|
|
116450
116452
|
return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
|
|
116451
116453
|
}
|
|
@@ -116476,10 +116478,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
116476
116478
|
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}`),
|
|
116477
116479
|
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}`),
|
|
116478
116480
|
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}`),
|
|
116479
|
-
readFile: async (sessionId,
|
|
116481
|
+
readFile: async (sessionId, path61, options) => await writeOf(
|
|
116480
116482
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
116481
|
-
JSON.stringify({ session: sessionId, path:
|
|
116482
|
-
(status, message) => `reading ${
|
|
116483
|
+
JSON.stringify({ session: sessionId, path: path61, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
116484
|
+
(status, message) => `reading ${path61} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
116483
116485
|
),
|
|
116484
116486
|
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}`),
|
|
116485
116487
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -116773,12 +116775,12 @@ function tlsFacts(options) {
|
|
|
116773
116775
|
}
|
|
116774
116776
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
116775
116777
|
const agent = new ExemptTlsAgent();
|
|
116776
|
-
const post = async (
|
|
116778
|
+
const post = async (path61, headers, body) => await new Promise((resolve2, reject) => {
|
|
116777
116779
|
const options = {
|
|
116778
116780
|
host: target.host,
|
|
116779
116781
|
port: target.port,
|
|
116780
116782
|
method: "POST",
|
|
116781
|
-
path:
|
|
116783
|
+
path: path61,
|
|
116782
116784
|
// 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.
|
|
116783
116785
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
116784
116786
|
agent
|
|
@@ -116843,12 +116845,12 @@ function lateRcStreamDial(resolve2) {
|
|
|
116843
116845
|
}
|
|
116844
116846
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
116845
116847
|
const agent = new ExemptTlsAgent();
|
|
116846
|
-
const request7 = async (method,
|
|
116848
|
+
const request7 = async (method, path61, headers, body, signal) => await new Promise((resolve2, reject) => {
|
|
116847
116849
|
const options = {
|
|
116848
116850
|
host: target.host,
|
|
116849
116851
|
port: target.port,
|
|
116850
116852
|
method,
|
|
116851
|
-
path:
|
|
116853
|
+
path: path61,
|
|
116852
116854
|
// 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.
|
|
116853
116855
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
116854
116856
|
agent,
|
|
@@ -116890,9 +116892,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
116890
116892
|
return { status, body: await readAll(response) };
|
|
116891
116893
|
},
|
|
116892
116894
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
116893
|
-
const
|
|
116895
|
+
const path61 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
116894
116896
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
116895
|
-
const { status, response } = await request7("GET",
|
|
116897
|
+
const { status, response } = await request7("GET", path61, streamHeaders, void 0, signal);
|
|
116896
116898
|
if (!isSuccessful2(status)) {
|
|
116897
116899
|
await readAll(response);
|
|
116898
116900
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -118186,11 +118188,11 @@ function tryOrUndefined(fn2) {
|
|
|
118186
118188
|
return void 0;
|
|
118187
118189
|
}
|
|
118188
118190
|
}
|
|
118189
|
-
function pathToHttpPath(
|
|
118190
|
-
return `/${
|
|
118191
|
+
function pathToHttpPath(path61) {
|
|
118192
|
+
return `/${path61.map(safeEncodeURIComponent).join("/")}`;
|
|
118191
118193
|
}
|
|
118192
|
-
function normalizeHttpPath(
|
|
118193
|
-
const paths =
|
|
118194
|
+
function normalizeHttpPath(path61) {
|
|
118195
|
+
const paths = path61.split("/");
|
|
118194
118196
|
if (paths.at(0) === "") {
|
|
118195
118197
|
paths.shift();
|
|
118196
118198
|
}
|
|
@@ -118375,9 +118377,9 @@ function isPlainObject2(value2) {
|
|
|
118375
118377
|
function getOwn(object3, key) {
|
|
118376
118378
|
return Object.hasOwn(object3, key) ? object3[key] : void 0;
|
|
118377
118379
|
}
|
|
118378
|
-
function get(object3,
|
|
118380
|
+
function get(object3, path61) {
|
|
118379
118381
|
let current = object3;
|
|
118380
|
-
for (const key of
|
|
118382
|
+
for (const key of path61) {
|
|
118381
118383
|
if (!isTypescriptObject(current)) {
|
|
118382
118384
|
return void 0;
|
|
118383
118385
|
}
|
|
@@ -119600,7 +119602,7 @@ function resolveClientRest(rest) {
|
|
|
119600
119602
|
// rest[1] can be undefined if all fields of FriendlyClientOptions are optional
|
|
119601
119603
|
];
|
|
119602
119604
|
}
|
|
119603
|
-
function createORPCClient(link, { path:
|
|
119605
|
+
function createORPCClient(link, { path: path61 = [], ...options } = {}) {
|
|
119604
119606
|
const procedureClient = (...rest) => {
|
|
119605
119607
|
const [input2, callOptions] = resolveClientRest(rest);
|
|
119606
119608
|
const interceptors = [
|
|
@@ -119609,7 +119611,7 @@ function createORPCClient(link, { path: path59 = [], ...options } = {}) {
|
|
|
119609
119611
|
];
|
|
119610
119612
|
return intercept(
|
|
119611
119613
|
interceptors,
|
|
119612
|
-
{ ...callOptions, input: input2, path:
|
|
119614
|
+
{ ...callOptions, input: input2, path: path61 },
|
|
119613
119615
|
({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
|
|
119614
119616
|
);
|
|
119615
119617
|
};
|
|
@@ -119623,7 +119625,7 @@ function createORPCClient(link, { path: path59 = [], ...options } = {}) {
|
|
|
119623
119625
|
if (client === void 0) {
|
|
119624
119626
|
client = createORPCClient(link, {
|
|
119625
119627
|
...options,
|
|
119626
|
-
path: [...
|
|
119628
|
+
path: [...path61, key],
|
|
119627
119629
|
scoped: options.scoped?.[key]
|
|
119628
119630
|
});
|
|
119629
119631
|
cache.set(key, client);
|
|
@@ -119645,24 +119647,24 @@ var BracketNotationSerializer = class {
|
|
|
119645
119647
|
this.internalSerialize(data, "", true, result);
|
|
119646
119648
|
return result;
|
|
119647
119649
|
}
|
|
119648
|
-
internalSerialize(data,
|
|
119650
|
+
internalSerialize(data, path61, isRoot, result) {
|
|
119649
119651
|
if (Array.isArray(data)) {
|
|
119650
119652
|
data.forEach((item, i10) => {
|
|
119651
|
-
this.internalSerialize(item, isRoot ? i10.toString() : `${
|
|
119653
|
+
this.internalSerialize(item, isRoot ? i10.toString() : `${path61}[${i10}]`, false, result);
|
|
119652
119654
|
});
|
|
119653
119655
|
} else if (isPlainObject2(data)) {
|
|
119654
119656
|
for (const key of Object.keys(data)) {
|
|
119655
|
-
this.internalSerialize(data[key], isRoot ? key : `${
|
|
119657
|
+
this.internalSerialize(data[key], isRoot ? key : `${path61}[${key}]`, false, result);
|
|
119656
119658
|
}
|
|
119657
119659
|
} else {
|
|
119658
|
-
result.push([
|
|
119660
|
+
result.push([path61, data]);
|
|
119659
119661
|
}
|
|
119660
119662
|
}
|
|
119661
119663
|
deserialize(serialized) {
|
|
119662
119664
|
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
119663
119665
|
const root = new NullProtoObj();
|
|
119664
|
-
for (const [
|
|
119665
|
-
const segments = this.parsePath(
|
|
119666
|
+
for (const [path61, value2] of serialized) {
|
|
119667
|
+
const segments = this.parsePath(path61);
|
|
119666
119668
|
let currentRef = root;
|
|
119667
119669
|
let nextSegment = segments[0];
|
|
119668
119670
|
for (let i10 = 1; i10 < segments.length; i10++) {
|
|
@@ -119713,13 +119715,13 @@ var BracketNotationSerializer = class {
|
|
|
119713
119715
|
}
|
|
119714
119716
|
return result;
|
|
119715
119717
|
}
|
|
119716
|
-
parsePath(
|
|
119718
|
+
parsePath(path61) {
|
|
119717
119719
|
const segments = [];
|
|
119718
119720
|
let inBrackets = false;
|
|
119719
119721
|
let currentSegment = "";
|
|
119720
|
-
for (let i10 = 0; i10 <
|
|
119721
|
-
const char =
|
|
119722
|
-
const nextChar =
|
|
119722
|
+
for (let i10 = 0; i10 < path61.length; i10++) {
|
|
119723
|
+
const char = path61[i10];
|
|
119724
|
+
const nextChar = path61[i10 + 1];
|
|
119723
119725
|
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
|
|
119724
119726
|
if (nextChar === void 0) {
|
|
119725
119727
|
inBrackets = false;
|
|
@@ -119735,7 +119737,7 @@ var BracketNotationSerializer = class {
|
|
|
119735
119737
|
currentSegment += char;
|
|
119736
119738
|
}
|
|
119737
119739
|
}
|
|
119738
|
-
return inBrackets || segments.length === 0 ? [
|
|
119740
|
+
return inBrackets || segments.length === 0 ? [path61] : segments;
|
|
119739
119741
|
}
|
|
119740
119742
|
};
|
|
119741
119743
|
var INTEGER_PATTERN = /^0$|^[1-9]\d*$/;
|
|
@@ -120308,11 +120310,11 @@ var OpenAPISerializer = class {
|
|
|
120308
120310
|
return json2;
|
|
120309
120311
|
}
|
|
120310
120312
|
const form = new FormData();
|
|
120311
|
-
for (const [
|
|
120313
|
+
for (const [path61, value22] of this.bracketNotation.serialize(json2)) {
|
|
120312
120314
|
if (value22 instanceof Blob) {
|
|
120313
|
-
form.append(
|
|
120315
|
+
form.append(path61, value22);
|
|
120314
120316
|
} else if (value22 !== void 0 && value22 !== null) {
|
|
120315
|
-
form.append(
|
|
120317
|
+
form.append(path61, String(value22));
|
|
120316
120318
|
}
|
|
120317
120319
|
}
|
|
120318
120320
|
return form;
|
|
@@ -120350,30 +120352,30 @@ function isBodylessMethod(method) {
|
|
|
120350
120352
|
return method === "GET" || method === "HEAD";
|
|
120351
120353
|
}
|
|
120352
120354
|
var PARAMETER_NAME_REGEX = /^[\w-]+$/;
|
|
120353
|
-
function getDynamicPathParams(
|
|
120354
|
-
if (!
|
|
120355
|
+
function getDynamicPathParams(path61) {
|
|
120356
|
+
if (!path61.includes("{")) {
|
|
120355
120357
|
return void 0;
|
|
120356
120358
|
}
|
|
120357
|
-
const len =
|
|
120359
|
+
const len = path61.length;
|
|
120358
120360
|
let params;
|
|
120359
120361
|
let index = 1;
|
|
120360
120362
|
while (index < len) {
|
|
120361
120363
|
const segmentStart = index;
|
|
120362
|
-
const slashPos =
|
|
120364
|
+
const slashPos = path61.indexOf("/", index);
|
|
120363
120365
|
const segmentEnd = slashPos === -1 ? len : slashPos;
|
|
120364
|
-
if (segmentEnd > segmentStart &&
|
|
120366
|
+
if (segmentEnd > segmentStart && path61.charCodeAt(segmentStart) === 123 && path61.charCodeAt(segmentEnd - 1) === 125) {
|
|
120365
120367
|
let parameterStart = segmentStart + 1;
|
|
120366
120368
|
let allowsSlash = false;
|
|
120367
|
-
const operator =
|
|
120369
|
+
const operator = path61.charCodeAt(parameterStart);
|
|
120368
120370
|
if (operator === 43) {
|
|
120369
120371
|
allowsSlash = true;
|
|
120370
120372
|
parameterStart++;
|
|
120371
120373
|
}
|
|
120372
|
-
const parameterName =
|
|
120374
|
+
const parameterName = path61.slice(parameterStart, segmentEnd - 1);
|
|
120373
120375
|
if (PARAMETER_NAME_REGEX.test(parameterName)) {
|
|
120374
120376
|
params ??= [];
|
|
120375
120377
|
params.push({
|
|
120376
|
-
segment:
|
|
120378
|
+
segment: path61.slice(segmentStart, segmentEnd),
|
|
120377
120379
|
startIndex: segmentStart,
|
|
120378
120380
|
parameterName,
|
|
120379
120381
|
allowsSlash
|
|
@@ -120416,8 +120418,8 @@ openapi.method = (method) => ({
|
|
|
120416
120418
|
...openapi({ method }),
|
|
120417
120419
|
name: "~openapi/method"
|
|
120418
120420
|
});
|
|
120419
|
-
openapi.path = (
|
|
120420
|
-
...openapi({ path:
|
|
120421
|
+
openapi.path = (path61) => ({
|
|
120422
|
+
...openapi({ path: path61 }),
|
|
120421
120423
|
name: "~openapi/path"
|
|
120422
120424
|
});
|
|
120423
120425
|
openapi.spec = (spec) => ({
|
|
@@ -121278,22 +121280,22 @@ function visitJsonSchemaRefs(value2, visit2, schemaLevel = true, seen = /* @__PU
|
|
|
121278
121280
|
}
|
|
121279
121281
|
}
|
|
121280
121282
|
}
|
|
121281
|
-
function mapJsonSchemaRefs(value2, map2, schemaLevel = true,
|
|
121283
|
+
function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path61 = []) {
|
|
121282
121284
|
if (!value2 || typeof value2 !== "object") {
|
|
121283
121285
|
return value2;
|
|
121284
121286
|
}
|
|
121285
121287
|
if (Array.isArray(value2)) {
|
|
121286
|
-
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...
|
|
121288
|
+
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path61, index]));
|
|
121287
121289
|
}
|
|
121288
121290
|
const result = {};
|
|
121289
121291
|
for (const key of Object.keys(value2)) {
|
|
121290
121292
|
const val = value2[key];
|
|
121291
121293
|
if (key === "$ref" && typeof val === "string") {
|
|
121292
|
-
setOwn(result, key, map2(val, [...
|
|
121294
|
+
setOwn(result, key, map2(val, [...path61, key]));
|
|
121293
121295
|
} else if (!schemaLevel) {
|
|
121294
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...
|
|
121296
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path61, key]));
|
|
121295
121297
|
} else if (JSON_SCHEMA_LOGIC_KEYWORDS.has(key) || JSON_SCHEMA_RECORD_KEYWORDS.has(key)) {
|
|
121296
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...
|
|
121298
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path61, key]));
|
|
121297
121299
|
} else {
|
|
121298
121300
|
setOwn(result, key, val);
|
|
121299
121301
|
}
|
|
@@ -121823,7 +121825,7 @@ function unlazy(maybeLazy) {
|
|
|
121823
121825
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
121824
121826
|
const options = resolveMaybeOptionalOptions(rest);
|
|
121825
121827
|
return async (...[input2, callerOptions]) => {
|
|
121826
|
-
const
|
|
121828
|
+
const path61 = toArray(options.path);
|
|
121827
121829
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
121828
121830
|
const clientContext = callerOptions?.context ?? {};
|
|
121829
121831
|
const context = await value(options.context, clientContext) ?? {};
|
|
@@ -121836,7 +121838,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
121836
121838
|
};
|
|
121837
121839
|
try {
|
|
121838
121840
|
const output2 = await runWithSpan("call_procedure", (span) => {
|
|
121839
|
-
span?.setAttribute("procedure.path",
|
|
121841
|
+
span?.setAttribute("procedure.path", path61);
|
|
121840
121842
|
return intercept(
|
|
121841
121843
|
options.interceptors,
|
|
121842
121844
|
{
|
|
@@ -121844,7 +121846,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
121844
121846
|
// input can be optional if it is undefinable
|
|
121845
121847
|
input: input2,
|
|
121846
121848
|
errors,
|
|
121847
|
-
path:
|
|
121849
|
+
path: path61,
|
|
121848
121850
|
procedure,
|
|
121849
121851
|
signal: callerOptions?.signal,
|
|
121850
121852
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -122095,10 +122097,10 @@ function augmentRouter(router, options) {
|
|
|
122095
122097
|
}
|
|
122096
122098
|
return enhanced;
|
|
122097
122099
|
}
|
|
122098
|
-
function getRouter(router,
|
|
122100
|
+
function getRouter(router, path61) {
|
|
122099
122101
|
let current = router;
|
|
122100
|
-
for (let i10 = 0; i10 <
|
|
122101
|
-
const segment =
|
|
122102
|
+
for (let i10 = 0; i10 < path61.length; i10++) {
|
|
122103
|
+
const segment = path61[i10];
|
|
122102
122104
|
if (!isTypescriptObject(current)) {
|
|
122103
122105
|
return void 0;
|
|
122104
122106
|
}
|
|
@@ -122110,7 +122112,7 @@ function getRouter(router, path59) {
|
|
|
122110
122112
|
continue;
|
|
122111
122113
|
}
|
|
122112
122114
|
const lazied = current;
|
|
122113
|
-
const rest =
|
|
122115
|
+
const rest = path61.slice(i10);
|
|
122114
122116
|
return new Lazy({
|
|
122115
122117
|
...lazied["~orpc"],
|
|
122116
122118
|
async loader() {
|
|
@@ -122125,40 +122127,40 @@ function getRouter(router, path59) {
|
|
|
122125
122127
|
}
|
|
122126
122128
|
return current;
|
|
122127
122129
|
}
|
|
122128
|
-
function walkProcedureContractsSync(router, callback,
|
|
122130
|
+
function walkProcedureContractsSync(router, callback, path61 = []) {
|
|
122129
122131
|
const lazyResults = [];
|
|
122130
|
-
walkProcedureContractsSyncInternal(router, callback,
|
|
122132
|
+
walkProcedureContractsSyncInternal(router, callback, path61.slice(), lazyResults);
|
|
122131
122133
|
return lazyResults;
|
|
122132
122134
|
}
|
|
122133
|
-
function walkProcedureContractsSyncInternal(router, callback,
|
|
122135
|
+
function walkProcedureContractsSyncInternal(router, callback, path61, lazyResults) {
|
|
122134
122136
|
const hiddenContract = getHiddenRouterContract(router);
|
|
122135
122137
|
if (hiddenContract !== void 0) {
|
|
122136
122138
|
router = hiddenContract;
|
|
122137
122139
|
}
|
|
122138
122140
|
if (router instanceof ProcedureContract) {
|
|
122139
|
-
callback(router,
|
|
122141
|
+
callback(router, path61.slice());
|
|
122140
122142
|
return;
|
|
122141
122143
|
}
|
|
122142
122144
|
if (!isTypescriptObject(router)) {
|
|
122143
122145
|
return;
|
|
122144
122146
|
}
|
|
122145
122147
|
for (const [key, value2] of Object.entries(router)) {
|
|
122146
|
-
|
|
122148
|
+
path61.push(key);
|
|
122147
122149
|
if (value2 instanceof Lazy) {
|
|
122148
|
-
lazyResults.push({ router: value2, path:
|
|
122150
|
+
lazyResults.push({ router: value2, path: path61.slice() });
|
|
122149
122151
|
} else {
|
|
122150
|
-
walkProcedureContractsSyncInternal(value2, callback,
|
|
122152
|
+
walkProcedureContractsSyncInternal(value2, callback, path61, lazyResults);
|
|
122151
122153
|
}
|
|
122152
|
-
|
|
122154
|
+
path61.pop();
|
|
122153
122155
|
}
|
|
122154
122156
|
}
|
|
122155
|
-
async function walkProcedureContractsAsync(router, callback,
|
|
122157
|
+
async function walkProcedureContractsAsync(router, callback, path61 = []) {
|
|
122156
122158
|
const hiddenContract = getHiddenRouterContract(router);
|
|
122157
122159
|
if (hiddenContract !== void 0) {
|
|
122158
122160
|
router = hiddenContract;
|
|
122159
122161
|
}
|
|
122160
122162
|
if (router instanceof ProcedureContract) {
|
|
122161
|
-
await callback(router,
|
|
122163
|
+
await callback(router, path61);
|
|
122162
122164
|
return;
|
|
122163
122165
|
}
|
|
122164
122166
|
if (!isTypescriptObject(router)) {
|
|
@@ -122167,9 +122169,9 @@ async function walkProcedureContractsAsync(router, callback, path59 = []) {
|
|
|
122167
122169
|
for (const [key, value2] of Object.entries(router)) {
|
|
122168
122170
|
if (value2 instanceof Lazy) {
|
|
122169
122171
|
const { default: router2 } = await unlazy(value2);
|
|
122170
|
-
await walkProcedureContractsAsync(router2, callback, [...
|
|
122172
|
+
await walkProcedureContractsAsync(router2, callback, [...path61, key]);
|
|
122171
122173
|
} else {
|
|
122172
|
-
await walkProcedureContractsAsync(value2, callback, [...
|
|
122174
|
+
await walkProcedureContractsAsync(value2, callback, [...path61, key]);
|
|
122173
122175
|
}
|
|
122174
122176
|
}
|
|
122175
122177
|
}
|
|
@@ -122655,18 +122657,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
|
|
|
122655
122657
|
}
|
|
122656
122658
|
var OpenAPIGeneratorError = class extends TypeError {
|
|
122657
122659
|
};
|
|
122658
|
-
function toOpenAPIPath(
|
|
122660
|
+
function toOpenAPIPath(path61, dynamicPathParams) {
|
|
122659
122661
|
if (!dynamicPathParams?.length) {
|
|
122660
|
-
return
|
|
122662
|
+
return path61;
|
|
122661
122663
|
}
|
|
122662
122664
|
let normalized = "";
|
|
122663
122665
|
let currentIndex = 0;
|
|
122664
122666
|
for (const param of dynamicPathParams) {
|
|
122665
|
-
normalized +=
|
|
122667
|
+
normalized += path61.slice(currentIndex, param.startIndex);
|
|
122666
122668
|
normalized += `{${param.parameterName}}`;
|
|
122667
122669
|
currentIndex = param.startIndex + param.segment.length;
|
|
122668
122670
|
}
|
|
122669
|
-
normalized +=
|
|
122671
|
+
normalized += path61.slice(currentIndex);
|
|
122670
122672
|
return normalized;
|
|
122671
122673
|
}
|
|
122672
122674
|
function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
|
|
@@ -123100,8 +123102,8 @@ var OpenAPIGenerator = class {
|
|
|
123100
123102
|
customErrorResponseBodySchema: options.customErrorResponseBodySchema
|
|
123101
123103
|
};
|
|
123102
123104
|
const errors = [];
|
|
123103
|
-
await walkProcedureContractsAsync(router, (contract,
|
|
123104
|
-
if (value(options.filter, contract,
|
|
123105
|
+
await walkProcedureContractsAsync(router, (contract, path61) => {
|
|
123106
|
+
if (value(options.filter, contract, path61) === false) {
|
|
123105
123107
|
return;
|
|
123106
123108
|
}
|
|
123107
123109
|
try {
|
|
@@ -123113,7 +123115,7 @@ var OpenAPIGenerator = class {
|
|
|
123113
123115
|
`QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
|
|
123114
123116
|
);
|
|
123115
123117
|
}
|
|
123116
|
-
const postPath = meta3?.path ?? pathToHttpPath(
|
|
123118
|
+
const postPath = meta3?.path ?? pathToHttpPath(path61);
|
|
123117
123119
|
const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
|
|
123118
123120
|
const dynamicPathParams = getDynamicPathParams(httpPath);
|
|
123119
123121
|
const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
|
|
@@ -123122,7 +123124,7 @@ var OpenAPIGenerator = class {
|
|
|
123122
123124
|
operation = meta3.spec;
|
|
123123
123125
|
} else {
|
|
123124
123126
|
operation = {
|
|
123125
|
-
operationId: meta3?.operationId ??
|
|
123127
|
+
operationId: meta3?.operationId ?? path61.join("."),
|
|
123126
123128
|
summary: meta3?.summary,
|
|
123127
123129
|
description: meta3?.description,
|
|
123128
123130
|
deprecated: meta3?.deprecated,
|
|
@@ -123142,7 +123144,7 @@ var OpenAPIGenerator = class {
|
|
|
123142
123144
|
if (!(e14 instanceof OpenAPIGeneratorError)) {
|
|
123143
123145
|
throw e14;
|
|
123144
123146
|
}
|
|
123145
|
-
errors.push(`Procedure at ${
|
|
123147
|
+
errors.push(`Procedure at ${path61.join(".") || "(root)"}: ${e14.message}`);
|
|
123146
123148
|
}
|
|
123147
123149
|
});
|
|
123148
123150
|
if (errors.length) {
|
|
@@ -123987,16 +123989,16 @@ var StandardLink = class {
|
|
|
123987
123989
|
/**
|
|
123988
123990
|
* @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
|
|
123989
123991
|
*/
|
|
123990
|
-
call(
|
|
123991
|
-
return runWithSpan(`${ORPC_NAME}.${
|
|
123992
|
+
call(path61, input2, options) {
|
|
123993
|
+
return runWithSpan(`${ORPC_NAME}.${path61.join("/")}`, (span) => {
|
|
123992
123994
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
123993
|
-
span?.setAttribute("rpc.method",
|
|
123995
|
+
span?.setAttribute("rpc.method", path61.join("."));
|
|
123994
123996
|
if (getTracer() && isAsyncIteratorObject(input2)) {
|
|
123995
123997
|
input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
|
|
123996
123998
|
} else if (getTracer() && input2 instanceof ReadableStream) {
|
|
123997
123999
|
input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
|
|
123998
124000
|
}
|
|
123999
|
-
return intercept(this.interceptors, { ...options, path:
|
|
124001
|
+
return intercept(this.interceptors, { ...options, path: path61, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
124000
124002
|
const tracer = getTracer();
|
|
124001
124003
|
const activeSpan = tracer?.getActiveSpan() ?? span;
|
|
124002
124004
|
let request7 = await runWithSpan(
|
|
@@ -124053,18 +124055,18 @@ var RPCLinkCodec = class {
|
|
|
124053
124055
|
this.headers = options.headers ?? {};
|
|
124054
124056
|
this.serializer = options.serializer ?? new RPCSerializer();
|
|
124055
124057
|
}
|
|
124056
|
-
async encodeInput(input2,
|
|
124057
|
-
let headers = toResolvedStandardHeaders(await value(this.headers, options,
|
|
124058
|
+
async encodeInput(input2, path61, options) {
|
|
124059
|
+
let headers = toResolvedStandardHeaders(await value(this.headers, options, path61, input2));
|
|
124058
124060
|
if (options.lastEventId !== void 0) {
|
|
124059
124061
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
124060
124062
|
}
|
|
124061
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
124062
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
124063
|
+
const expectedMethod = await value(this.expectedMethod, options, path61, input2);
|
|
124064
|
+
const baseUrl = await value(this.baseUrl, options, path61, input2);
|
|
124063
124065
|
const [pathname, search, hash2] = parseStandardUrl(baseUrl);
|
|
124064
|
-
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(
|
|
124066
|
+
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path61)}`;
|
|
124065
124067
|
const serialized = this.serializer.serialize(input2);
|
|
124066
124068
|
if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
124067
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
124069
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path61, input2);
|
|
124068
124070
|
const mergedSearch = new URLSearchParams(search);
|
|
124069
124071
|
mergedSearch.append("data", stringifyJSON(serialized) ?? "");
|
|
124070
124072
|
const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
|
|
@@ -124149,8 +124151,8 @@ var FetchLinkTransport = class {
|
|
|
124149
124151
|
this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
|
|
124150
124152
|
this.toFetchRequestOptions = options.toFetchRequest;
|
|
124151
124153
|
}
|
|
124152
|
-
async send(standardRequest,
|
|
124153
|
-
let origin = await value(this.origin, options,
|
|
124154
|
+
async send(standardRequest, path61, options) {
|
|
124155
|
+
let origin = await value(this.origin, options, path61);
|
|
124154
124156
|
if (origin?.endsWith("/")) {
|
|
124155
124157
|
origin = origin.slice(0, -1);
|
|
124156
124158
|
}
|
|
@@ -124170,7 +124172,7 @@ var FetchLinkTransport = class {
|
|
|
124170
124172
|
}
|
|
124171
124173
|
}
|
|
124172
124174
|
const fetch3 = this.fetch;
|
|
124173
|
-
const response = await fetch3(url2, init, options,
|
|
124175
|
+
const response = await fetch3(url2, init, options, path61);
|
|
124174
124176
|
const standardResponse = toStandardLazyResponse(response);
|
|
124175
124177
|
return standardResponse;
|
|
124176
124178
|
}
|
|
@@ -124561,14 +124563,14 @@ var StandardHandler = class {
|
|
|
124561
124563
|
span?.setAttribute("url.path", request22.url);
|
|
124562
124564
|
return { matched: false };
|
|
124563
124565
|
}
|
|
124564
|
-
const { path:
|
|
124565
|
-
span?.updateName(`${ORPC_NAME}.${
|
|
124566
|
+
const { path: path61, procedure, decodeInput } = matchedOrNot;
|
|
124567
|
+
span?.updateName(`${ORPC_NAME}.${path61.join("/")}`);
|
|
124566
124568
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
124567
|
-
span?.setAttribute("rpc.method",
|
|
124569
|
+
span?.setAttribute("rpc.method", path61.join("."));
|
|
124568
124570
|
try {
|
|
124569
124571
|
const response = await intercept(
|
|
124570
124572
|
this.interceptors,
|
|
124571
|
-
{ context: context2, prefix: prefix2, request: request22, path:
|
|
124573
|
+
{ context: context2, prefix: prefix2, request: request22, path: path61, procedure, decodeInput },
|
|
124572
124574
|
async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
|
|
124573
124575
|
step2 = "decode_input";
|
|
124574
124576
|
let input2 = await runWithSpan("decode_input", decodeInput2);
|
|
@@ -124602,7 +124604,7 @@ var StandardHandler = class {
|
|
|
124602
124604
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
124603
124605
|
cause: e14
|
|
124604
124606
|
}) : toORPCError(e14);
|
|
124605
|
-
const response = await this.codec.encodeError(error63, procedure,
|
|
124607
|
+
const response = await this.codec.encodeError(error63, procedure, path61, { context: context2, prefix: prefix2 });
|
|
124606
124608
|
return { matched: true, response };
|
|
124607
124609
|
}
|
|
124608
124610
|
}
|
|
@@ -124708,7 +124710,7 @@ var RPCMatcher = class {
|
|
|
124708
124710
|
this.rootRouter = router;
|
|
124709
124711
|
this.index(router);
|
|
124710
124712
|
}
|
|
124711
|
-
index(router,
|
|
124713
|
+
index(router, path61 = []) {
|
|
124712
124714
|
const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
|
|
124713
124715
|
if (!value(this.filter, procedure, procedurePath)) {
|
|
124714
124716
|
return;
|
|
@@ -124719,7 +124721,7 @@ var RPCMatcher = class {
|
|
|
124719
124721
|
// contract-first entries have no implementation yet, resolveProcedure fills it in on demand
|
|
124720
124722
|
procedure: procedure instanceof Procedure ? procedure : void 0
|
|
124721
124723
|
});
|
|
124722
|
-
},
|
|
124724
|
+
}, path61);
|
|
124723
124725
|
for (const result of lazyResults) {
|
|
124724
124726
|
this.pendingLazyRouters.set(pathToHttpPath(result.path), result);
|
|
124725
124727
|
}
|
|
@@ -124851,10 +124853,10 @@ var RPCHandlerCodec = class {
|
|
|
124851
124853
|
}
|
|
124852
124854
|
};
|
|
124853
124855
|
}
|
|
124854
|
-
encodeOutput(output2, procedure,
|
|
124856
|
+
encodeOutput(output2, procedure, path61, options) {
|
|
124855
124857
|
return {
|
|
124856
124858
|
headers: {},
|
|
124857
|
-
status: value(this.outputStatus, output2, procedure,
|
|
124859
|
+
status: value(this.outputStatus, output2, procedure, path61, options) ?? DEFAULT_SUCCESS_STATUS,
|
|
124858
124860
|
body: this.serializer.serialize(output2)
|
|
124859
124861
|
};
|
|
124860
124862
|
}
|
|
@@ -124908,39 +124910,39 @@ function createRouter() {
|
|
|
124908
124910
|
static: new NullProtoObj2()
|
|
124909
124911
|
};
|
|
124910
124912
|
}
|
|
124911
|
-
function scanFirstGroup(
|
|
124913
|
+
function scanFirstGroup(path61) {
|
|
124912
124914
|
let i10 = 0;
|
|
124913
124915
|
let depth = 0;
|
|
124914
|
-
for (; i10 <
|
|
124915
|
-
const c10 =
|
|
124916
|
+
for (; i10 < path61.length; i10++) {
|
|
124917
|
+
const c10 = path61.charCodeAt(i10);
|
|
124916
124918
|
if (c10 === 92) i10++;
|
|
124917
124919
|
else if (c10 === 40) depth++;
|
|
124918
124920
|
else if (c10 === 41 && depth > 0) depth--;
|
|
124919
124921
|
else if (c10 === 123 && depth === 0) break;
|
|
124920
124922
|
}
|
|
124921
|
-
if (i10 >=
|
|
124923
|
+
if (i10 >= path61.length) return;
|
|
124922
124924
|
let j10 = i10 + 1;
|
|
124923
124925
|
depth = 0;
|
|
124924
|
-
for (; j10 <
|
|
124925
|
-
const c10 =
|
|
124926
|
+
for (; j10 < path61.length; j10++) {
|
|
124927
|
+
const c10 = path61.charCodeAt(j10);
|
|
124926
124928
|
if (c10 === 92) j10++;
|
|
124927
124929
|
else if (c10 === 40) depth++;
|
|
124928
124930
|
else if (c10 === 41 && depth > 0) depth--;
|
|
124929
124931
|
else if (c10 === 125 && depth === 0) break;
|
|
124930
124932
|
}
|
|
124931
|
-
if (j10 >=
|
|
124932
|
-
const mod =
|
|
124933
|
+
if (j10 >= path61.length) return;
|
|
124934
|
+
const mod = path61[j10 + 1];
|
|
124933
124935
|
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
124934
124936
|
return [
|
|
124935
|
-
|
|
124936
|
-
|
|
124937
|
-
|
|
124937
|
+
path61.slice(0, i10),
|
|
124938
|
+
path61.slice(i10 + 1, j10),
|
|
124939
|
+
path61.slice(j10 + (hasMod ? 2 : 1)),
|
|
124938
124940
|
hasMod ? mod : void 0
|
|
124939
124941
|
];
|
|
124940
124942
|
}
|
|
124941
|
-
function expandGroupDelimiters(
|
|
124942
|
-
if (!
|
|
124943
|
-
const group = scanFirstGroup(
|
|
124943
|
+
function expandGroupDelimiters(path61) {
|
|
124944
|
+
if (!path61.includes("{")) return;
|
|
124945
|
+
const group = scanFirstGroup(path61);
|
|
124944
124946
|
if (!group) return;
|
|
124945
124947
|
const [pre2, body, suf, mod] = group;
|
|
124946
124948
|
if (!mod) return [pre2 + body + suf];
|
|
@@ -125010,9 +125012,9 @@ function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGr
|
|
|
125010
125012
|
}
|
|
125011
125013
|
return [replaced, nextIndex];
|
|
125012
125014
|
}
|
|
125013
|
-
function encodeEscapes(
|
|
125014
|
-
if (!
|
|
125015
|
-
return
|
|
125015
|
+
function encodeEscapes(path61) {
|
|
125016
|
+
if (!path61.includes("\\")) return path61;
|
|
125017
|
+
return path61.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
|
|
125016
125018
|
}
|
|
125017
125019
|
function segmentKey(segment) {
|
|
125018
125020
|
if (segment.startsWith("**")) return 2;
|
|
@@ -125041,22 +125043,22 @@ function expandModifiers(segments) {
|
|
|
125041
125043
|
return m10[2] === "+" ? [wc2] : [wc2, without];
|
|
125042
125044
|
}
|
|
125043
125045
|
}
|
|
125044
|
-
function normalizePath(
|
|
125045
|
-
if (!
|
|
125046
|
+
function normalizePath(path61) {
|
|
125047
|
+
if (!path61.includes("/.")) return path61;
|
|
125046
125048
|
const r10 = [];
|
|
125047
|
-
for (const s of
|
|
125049
|
+
for (const s of path61.split("/")) if (s === ".") continue;
|
|
125048
125050
|
else if (s === ".." && r10.length > 1) r10.pop();
|
|
125049
125051
|
else r10.push(s);
|
|
125050
125052
|
return r10.join("/") || "/";
|
|
125051
125053
|
}
|
|
125052
|
-
function splitPath(
|
|
125053
|
-
const s =
|
|
125054
|
+
function splitPath(path61) {
|
|
125055
|
+
const s = path61.split("/");
|
|
125054
125056
|
s.shift();
|
|
125055
125057
|
if (s[s.length - 1] === "") s.pop();
|
|
125056
125058
|
return s;
|
|
125057
125059
|
}
|
|
125058
|
-
function splitRoute(
|
|
125059
|
-
const s = splitPath(
|
|
125060
|
+
function splitRoute(path61) {
|
|
125061
|
+
const s = splitPath(path61);
|
|
125060
125062
|
while (s[s.length - 1] === "") s.pop();
|
|
125061
125063
|
return s;
|
|
125062
125064
|
}
|
|
@@ -125072,16 +125074,16 @@ function getMatchParams(segments, paramsMap) {
|
|
|
125072
125074
|
}
|
|
125073
125075
|
return params;
|
|
125074
125076
|
}
|
|
125075
|
-
function addRoute(ctx, method = "",
|
|
125077
|
+
function addRoute(ctx, method = "", path61, data) {
|
|
125076
125078
|
method = method.toUpperCase();
|
|
125077
|
-
if (
|
|
125078
|
-
const groupExpanded = expandGroupDelimiters(
|
|
125079
|
+
if (path61.charCodeAt(0) !== 47) path61 = `/${path61}`;
|
|
125080
|
+
const groupExpanded = expandGroupDelimiters(path61);
|
|
125079
125081
|
if (groupExpanded) {
|
|
125080
125082
|
for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
|
|
125081
125083
|
return;
|
|
125082
125084
|
}
|
|
125083
|
-
|
|
125084
|
-
const segments = splitRoute(
|
|
125085
|
+
path61 = encodeEscapes(path61);
|
|
125086
|
+
const segments = splitRoute(path61);
|
|
125085
125087
|
const expanded = expandModifiers(segments);
|
|
125086
125088
|
if (expanded) {
|
|
125087
125089
|
for (const p of expanded) addRoute(ctx, method, p, data);
|
|
@@ -125172,15 +125174,15 @@ function getParamRegexp(segment, unnamedStart = 0) {
|
|
|
125172
125174
|
const regex = _s2.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id2, p) => `(?<${toGroupName(id2)}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i2++)}>`).replace(/\uFFFE(.)/g, (_, c10) => /[.*+?^${}()|[\]\\]/.test(c10) ? `\\${c10}` : c10);
|
|
125173
125175
|
return [new RegExp(`^${regex}$`), _i2];
|
|
125174
125176
|
}
|
|
125175
|
-
function findRoute(ctx, method = "",
|
|
125176
|
-
if (opts?.normalize)
|
|
125177
|
-
if (
|
|
125178
|
-
const staticNode = ctx.static[
|
|
125177
|
+
function findRoute(ctx, method = "", path61, opts) {
|
|
125178
|
+
if (opts?.normalize) path61 = normalizePath(path61);
|
|
125179
|
+
if (path61.charCodeAt(path61.length - 1) === 47) path61 = path61.slice(0, -1);
|
|
125180
|
+
const staticNode = ctx.static[path61];
|
|
125179
125181
|
if (staticNode && staticNode.methods) {
|
|
125180
125182
|
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
125181
125183
|
if (staticMatch !== void 0) return staticMatch[0];
|
|
125182
125184
|
}
|
|
125183
|
-
const segments = splitPath(
|
|
125185
|
+
const segments = splitPath(path61);
|
|
125184
125186
|
const match = _lookupTree(ctx.root, method, segments, 0);
|
|
125185
125187
|
if (match === void 0) return;
|
|
125186
125188
|
if (opts?.params === false) return match;
|
|
@@ -125380,7 +125382,7 @@ var OpenAPIMatcher = class {
|
|
|
125380
125382
|
this.rootRouter = router;
|
|
125381
125383
|
this.index(router);
|
|
125382
125384
|
}
|
|
125383
|
-
index(router,
|
|
125385
|
+
index(router, path61 = []) {
|
|
125384
125386
|
const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
|
|
125385
125387
|
if (!value(this.filter, contract, path210)) {
|
|
125386
125388
|
return;
|
|
@@ -125395,7 +125397,7 @@ var OpenAPIMatcher = class {
|
|
|
125395
125397
|
contract,
|
|
125396
125398
|
procedure: contract instanceof Procedure ? contract : void 0
|
|
125397
125399
|
});
|
|
125398
|
-
},
|
|
125400
|
+
}, path61);
|
|
125399
125401
|
for (const result of lazyResults) {
|
|
125400
125402
|
const prefix = getOpenAPIMeta(result.router)?.prefix;
|
|
125401
125403
|
this.pendingLazyRouters.add({
|
|
@@ -125482,20 +125484,20 @@ var OpenAPIMatcher = class {
|
|
|
125482
125484
|
return entry.procedure;
|
|
125483
125485
|
}
|
|
125484
125486
|
};
|
|
125485
|
-
function toRou3Pattern(
|
|
125486
|
-
const params = getDynamicPathParams(
|
|
125487
|
+
function toRou3Pattern(path61) {
|
|
125488
|
+
const params = getDynamicPathParams(path61);
|
|
125487
125489
|
if (!params?.length) {
|
|
125488
|
-
return
|
|
125490
|
+
return path61;
|
|
125489
125491
|
}
|
|
125490
125492
|
for (let i10 = params.length - 1; i10 >= 0; i10--) {
|
|
125491
125493
|
const param = params[i10];
|
|
125492
125494
|
const pattern = param.allowsSlash ? `**:${param.parameterName}` : `:${param.parameterName}`;
|
|
125493
|
-
|
|
125495
|
+
path61 = path61.slice(0, param.startIndex) + pattern + path61.slice(param.startIndex + param.segment.length);
|
|
125494
125496
|
}
|
|
125495
|
-
return
|
|
125497
|
+
return path61;
|
|
125496
125498
|
}
|
|
125497
|
-
function toRou3PrefixMatcher(
|
|
125498
|
-
const pattern = toRou3Pattern(
|
|
125499
|
+
function toRou3PrefixMatcher(path61) {
|
|
125500
|
+
const pattern = toRou3Pattern(path61);
|
|
125499
125501
|
return routeToRegExp(pattern === "/" ? "/**" : `${pattern}/**`);
|
|
125500
125502
|
}
|
|
125501
125503
|
function decodeParams(params) {
|
|
@@ -125574,7 +125576,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
125574
125576
|
/**
|
|
125575
125577
|
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
125576
125578
|
*/
|
|
125577
|
-
encodeOutput(output2, procedure,
|
|
125579
|
+
encodeOutput(output2, procedure, path61) {
|
|
125578
125580
|
const meta3 = getOpenAPIMeta(procedure);
|
|
125579
125581
|
const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
|
|
125580
125582
|
const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
|
|
@@ -125587,7 +125589,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
125587
125589
|
}
|
|
125588
125590
|
if (!isValidDetailedOutput(output2)) {
|
|
125589
125591
|
throw new TypeError(`
|
|
125590
|
-
Invalid "detailed" output structure returned by procedure (${
|
|
125592
|
+
Invalid "detailed" output structure returned by procedure (${path61.join(".")}):
|
|
125591
125593
|
\u2022 Expected an object with optional properties:
|
|
125592
125594
|
- status (number <400)
|
|
125593
125595
|
- headers (object)
|
|
@@ -126140,7 +126142,7 @@ function profileValue(name, paths) {
|
|
|
126140
126142
|
function createConfigApiRouter(deps) {
|
|
126141
126143
|
const authed = doorApiAuth(deps.expectedToken);
|
|
126142
126144
|
const { paths } = deps;
|
|
126143
|
-
const route = (
|
|
126145
|
+
const route = (path61, summary) => authed.meta(openapi({ method: "POST", path: path61, summary, tags: [CONFIG_API_TAG] }));
|
|
126144
126146
|
return {
|
|
126145
126147
|
config: {
|
|
126146
126148
|
identity: {
|
|
@@ -128089,6 +128091,13 @@ function findBucket(quota, keys) {
|
|
|
128089
128091
|
}
|
|
128090
128092
|
return void 0;
|
|
128091
128093
|
}
|
|
128094
|
+
function selectAntigravityBuckets(quota, model) {
|
|
128095
|
+
const isGemini = (model ?? "").toLowerCase().includes("gemini");
|
|
128096
|
+
return {
|
|
128097
|
+
fiveHour: findBucket(quota, isGemini ? GEMINI_5H_KEYS : THIRD_PARTY_5H_KEYS),
|
|
128098
|
+
weekly: findBucket(quota, isGemini ? GEMINI_WEEKLY_KEYS : THIRD_PARTY_WEEKLY_KEYS)
|
|
128099
|
+
};
|
|
128100
|
+
}
|
|
128092
128101
|
function calculateUtilization(remainingFraction) {
|
|
128093
128102
|
if (remainingFraction === void 0 || !Number.isFinite(remainingFraction)) {
|
|
128094
128103
|
return void 0;
|
|
@@ -128121,13 +128130,7 @@ function parseRetryAfterSeconds(raw, defaultSeconds = DEFAULT_RETRY_AFTER_SECOND
|
|
|
128121
128130
|
function unifiedAntigravityQuotaHeaders(params) {
|
|
128122
128131
|
const rejected = params.rejected === true;
|
|
128123
128132
|
const nowSec = Math.floor(params.nowMs / MS_PER_SECOND8);
|
|
128124
|
-
const
|
|
128125
|
-
const isGemini = modelLower.includes("gemini");
|
|
128126
|
-
const fiveHourKeys = isGemini ? GEMINI_5H_KEYS : THIRD_PARTY_5H_KEYS;
|
|
128127
|
-
const weeklyKeys = isGemini ? GEMINI_WEEKLY_KEYS : THIRD_PARTY_WEEKLY_KEYS;
|
|
128128
|
-
const quota = params.quota ?? {};
|
|
128129
|
-
const b5h = findBucket(quota, fiveHourKeys);
|
|
128130
|
-
const bWk = findBucket(quota, weeklyKeys);
|
|
128133
|
+
const { fiveHour: b5h, weekly: bWk } = selectAntigravityBuckets(params.quota ?? {}, params.model);
|
|
128131
128134
|
const used5h = calculateUtilization(b5h?.remaining_fraction);
|
|
128132
128135
|
const reset5h = calculateResetTimestamp(nowSec, b5h?.reset_in_seconds);
|
|
128133
128136
|
const used7d = calculateUtilization(bWk?.remaining_fraction);
|
|
@@ -128838,8 +128841,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
128838
128841
|
request7.body.resume();
|
|
128839
128842
|
return;
|
|
128840
128843
|
}
|
|
128841
|
-
const
|
|
128842
|
-
const translated = { method: request7.method, path:
|
|
128844
|
+
const path61 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
128845
|
+
const translated = { method: request7.method, path: path61, body, signal: request7.signal };
|
|
128843
128846
|
const routed = await route(translated);
|
|
128844
128847
|
if (request7.signal.aborted) {
|
|
128845
128848
|
return;
|
|
@@ -129439,8 +129442,8 @@ function createAntigravityRouteMount(ports, upstreamBase, provider) {
|
|
|
129439
129442
|
request7.body.resume();
|
|
129440
129443
|
return;
|
|
129441
129444
|
}
|
|
129442
|
-
const
|
|
129443
|
-
const translated = { method: request7.method, path:
|
|
129445
|
+
const path61 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
129446
|
+
const translated = { method: request7.method, path: path61, body, signal: request7.signal };
|
|
129444
129447
|
const routed = await route(translated);
|
|
129445
129448
|
if (request7.signal.aborted) {
|
|
129446
129449
|
return;
|
|
@@ -129474,7 +129477,7 @@ function createPassthroughRoute(name, target) {
|
|
|
129474
129477
|
headroomUpstream: target.headroomUpstream,
|
|
129475
129478
|
serve: async (request7, response) => {
|
|
129476
129479
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
129477
|
-
const
|
|
129480
|
+
const path61 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
129478
129481
|
const headers = forwardableHeaders(request7.headers);
|
|
129479
129482
|
delete headers.host;
|
|
129480
129483
|
await new Promise((resolve2) => {
|
|
@@ -129482,7 +129485,7 @@ function createPassthroughRoute(name, target) {
|
|
|
129482
129485
|
host: base.hostname,
|
|
129483
129486
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
129484
129487
|
method: request7.method,
|
|
129485
|
-
path: `${basePath}${
|
|
129488
|
+
path: `${basePath}${path61}${incoming.search}`,
|
|
129486
129489
|
headers,
|
|
129487
129490
|
agent
|
|
129488
129491
|
};
|
|
@@ -129614,13 +129617,13 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
129614
129617
|
}
|
|
129615
129618
|
|
|
129616
129619
|
// src/frontdoor/providerRoute.ts
|
|
129617
|
-
var isRcSelfHostPath = (
|
|
129620
|
+
var isRcSelfHostPath = (path61) => path61 === "/v1/code/sessions" || path61.startsWith("/v1/code/sessions/") || path61 === "/v1/sessions" || path61.startsWith("/v1/sessions/");
|
|
129618
129621
|
function scopeSessionProviderPath(request7) {
|
|
129619
129622
|
if (request7.session.provider === void 0) {
|
|
129620
129623
|
return request7;
|
|
129621
129624
|
}
|
|
129622
|
-
const
|
|
129623
|
-
if (!
|
|
129625
|
+
const path61 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
129626
|
+
if (!path61.startsWith("/v1/") || isRcSelfHostPath(path61)) {
|
|
129624
129627
|
return request7;
|
|
129625
129628
|
}
|
|
129626
129629
|
return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
|
|
@@ -129663,13 +129666,13 @@ function createProviderRouteResolver(deps) {
|
|
|
129663
129666
|
return route;
|
|
129664
129667
|
};
|
|
129665
129668
|
const resolve2 = (request7) => {
|
|
129666
|
-
const
|
|
129667
|
-
const scoped = parseProviderPath(
|
|
129669
|
+
const path61 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
129670
|
+
const scoped = parseProviderPath(path61);
|
|
129668
129671
|
if (scoped === void 0) {
|
|
129669
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
129672
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path61)) {
|
|
129670
129673
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
129671
129674
|
}
|
|
129672
|
-
return
|
|
129675
|
+
return path61.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path61}` };
|
|
129673
129676
|
}
|
|
129674
129677
|
const { provider } = scoped;
|
|
129675
129678
|
let definition;
|
|
@@ -129755,8 +129758,8 @@ function createProviderRouteResolver(deps) {
|
|
|
129755
129758
|
let replay;
|
|
129756
129759
|
const visited = /* @__PURE__ */ new Set();
|
|
129757
129760
|
for (; ; ) {
|
|
129758
|
-
const
|
|
129759
|
-
const scoped = parseProviderPath(
|
|
129761
|
+
const path61 = new URL(current.url, "http://127.0.0.1").pathname;
|
|
129762
|
+
const scoped = parseProviderPath(path61);
|
|
129760
129763
|
const providerName = scoped?.provider ?? current.session.provider;
|
|
129761
129764
|
if (providerName !== void 0 && visited.has(providerName)) {
|
|
129762
129765
|
return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
|
|
@@ -129814,7 +129817,7 @@ function createProviderRouteResolver(deps) {
|
|
|
129814
129817
|
const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
129815
129818
|
replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
|
|
129816
129819
|
}
|
|
129817
|
-
const rest = scoped === void 0 ?
|
|
129820
|
+
const rest = scoped === void 0 ? path61 : path61.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
|
|
129818
129821
|
const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
129819
129822
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
|
|
129820
129823
|
}
|
|
@@ -133269,13 +133272,36 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
133269
133272
|
|
|
133270
133273
|
// src/statusline/commands.ts
|
|
133271
133274
|
var import_node_child_process7 = require("node:child_process");
|
|
133275
|
+
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
133276
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
133272
133277
|
init_commandDeps();
|
|
133278
|
+
init_providersStore();
|
|
133273
133279
|
init_realPorts();
|
|
133274
133280
|
init_account();
|
|
133275
133281
|
init_read();
|
|
133276
133282
|
|
|
133283
|
+
// src/statusline/client.ts
|
|
133284
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
133285
|
+
function isAntigravityPayload(payload) {
|
|
133286
|
+
return typeof payload === "object" && payload !== null && "product" in payload && payload.product === "antigravity";
|
|
133287
|
+
}
|
|
133288
|
+
var ANTIGRAVITY_SETTINGS_SEGMENTS = [".gemini", "antigravity-cli", "settings.json"];
|
|
133289
|
+
function antigravityStacksWithDefault(fs24, homeDir) {
|
|
133290
|
+
const raw = fs24.readFileUtf8(import_node_path52.default.join(homeDir, ...ANTIGRAVITY_SETTINGS_SEGMENTS));
|
|
133291
|
+
if (raw === void 0) {
|
|
133292
|
+
return false;
|
|
133293
|
+
}
|
|
133294
|
+
const settings2 = JSON.parse(raw);
|
|
133295
|
+
if (typeof settings2 !== "object" || settings2 === null || !("statusLine" in settings2)) {
|
|
133296
|
+
return false;
|
|
133297
|
+
}
|
|
133298
|
+
const statusLine = settings2.statusLine;
|
|
133299
|
+
return typeof statusLine === "object" && statusLine !== null && "stack_with_default" in statusLine && statusLine.stack_with_default === true;
|
|
133300
|
+
}
|
|
133301
|
+
|
|
133277
133302
|
// src/statusline/enrich.ts
|
|
133278
133303
|
var FULL_PERCENT = 100;
|
|
133304
|
+
var MS_PER_SECOND13 = 1e3;
|
|
133279
133305
|
function identityOf(env) {
|
|
133280
133306
|
const headers = env.ANTHROPIC_CUSTOM_HEADERS;
|
|
133281
133307
|
if (headers !== void 0) {
|
|
@@ -133321,38 +133347,88 @@ function windowsOf(states) {
|
|
|
133321
133347
|
}
|
|
133322
133348
|
return { fiveHourUsed, fiveHourResetAt, sevenDayUsed, sevenDayResetAt };
|
|
133323
133349
|
}
|
|
133350
|
+
function isObject4(value2) {
|
|
133351
|
+
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
133352
|
+
}
|
|
133353
|
+
function payloadWindow(rateLimits, key) {
|
|
133354
|
+
const window = rateLimits[key];
|
|
133355
|
+
if (!isObject4(window) || typeof window.used_percentage !== "number" || !Number.isFinite(window.used_percentage)) {
|
|
133356
|
+
return void 0;
|
|
133357
|
+
}
|
|
133358
|
+
const resetsAt = window.resets_at;
|
|
133359
|
+
return {
|
|
133360
|
+
used: Math.min(FULL_PERCENT, Math.max(0, window.used_percentage)),
|
|
133361
|
+
resetAt: typeof resetsAt === "number" && Number.isFinite(resetsAt) ? new Date(resetsAt * MS_PER_SECOND13).toISOString() : void 0
|
|
133362
|
+
};
|
|
133363
|
+
}
|
|
133364
|
+
function payloadWindowsOf(payload) {
|
|
133365
|
+
const rateLimits = isObject4(payload) ? payload.rate_limits : void 0;
|
|
133366
|
+
const five = isObject4(rateLimits) ? payloadWindow(rateLimits, "five_hour") : void 0;
|
|
133367
|
+
const seven = isObject4(rateLimits) ? payloadWindow(rateLimits, "seven_day") : void 0;
|
|
133368
|
+
return { fiveHourUsed: five?.used, fiveHourResetAt: five?.resetAt, sevenDayUsed: seven?.used, sevenDayResetAt: seven?.resetAt };
|
|
133369
|
+
}
|
|
133370
|
+
function antigravityWindowsOf(payload, nowMs) {
|
|
133371
|
+
const quota = isObject4(payload) ? payload.quota : void 0;
|
|
133372
|
+
if (!isObject4(quota)) {
|
|
133373
|
+
return { fiveHourUsed: void 0, fiveHourResetAt: void 0, sevenDayUsed: void 0, sevenDayResetAt: void 0 };
|
|
133374
|
+
}
|
|
133375
|
+
const model = isObject4(payload) && isObject4(payload.model) && typeof payload.model.id === "string" ? payload.model.id : void 0;
|
|
133376
|
+
const buckets = Object.fromEntries(
|
|
133377
|
+
Object.entries(quota).flatMap(([key, bucket]) => {
|
|
133378
|
+
if (!isObject4(bucket)) {
|
|
133379
|
+
return [];
|
|
133380
|
+
}
|
|
133381
|
+
const remaining = bucket.remaining_fraction;
|
|
133382
|
+
const resetIn = bucket.reset_in_seconds;
|
|
133383
|
+
return [[key, { ...typeof remaining === "number" ? { remaining_fraction: remaining } : {}, ...typeof resetIn === "number" ? { reset_in_seconds: resetIn } : {} }]];
|
|
133384
|
+
})
|
|
133385
|
+
);
|
|
133386
|
+
const { fiveHour, weekly } = selectAntigravityBuckets(buckets, model);
|
|
133387
|
+
const windowOf2 = (bucket) => ({
|
|
133388
|
+
used: bucket?.remaining_fraction === void 0 || !Number.isFinite(bucket.remaining_fraction) ? void 0 : (1 - Math.min(1, Math.max(0, bucket.remaining_fraction))) * FULL_PERCENT,
|
|
133389
|
+
resetAt: bucket?.reset_in_seconds === void 0 || !Number.isFinite(bucket.reset_in_seconds) ? void 0 : new Date(nowMs + bucket.reset_in_seconds * MS_PER_SECOND13).toISOString()
|
|
133390
|
+
});
|
|
133391
|
+
const five = windowOf2(fiveHour);
|
|
133392
|
+
const seven = windowOf2(weekly);
|
|
133393
|
+
return { fiveHourUsed: five.used, fiveHourResetAt: five.resetAt, sevenDayUsed: seven.used, sevenDayResetAt: seven.resetAt };
|
|
133394
|
+
}
|
|
133324
133395
|
function enrichStatuslinePayload(params) {
|
|
133325
133396
|
const identity = identityOf(params.env);
|
|
133397
|
+
const clientEmail = isObject4(params.payload) && typeof params.payload.email === "string" && params.payload.email !== "" ? params.payload.email : void 0;
|
|
133398
|
+
const clientPlan = clientEmail !== void 0 && isObject4(params.payload) && typeof params.payload.plan_tier === "string" && params.payload.plan_tier !== "" ? params.payload.plan_tier : void 0;
|
|
133399
|
+
const account = clientEmail === void 0 ? params.account : void 0;
|
|
133326
133400
|
let summary = {
|
|
133327
133401
|
identity,
|
|
133328
133402
|
provider: params.env.AGENT_SHIM_PROVIDER === void 0 || params.env.AGENT_SHIM_PROVIDER === "" ? void 0 : params.env.AGENT_SHIM_PROVIDER,
|
|
133329
133403
|
providerAccountEmail: void 0,
|
|
133330
133404
|
providerAccountSub: void 0,
|
|
133331
133405
|
providerPlan: void 0,
|
|
133332
|
-
loginAccountEmail:
|
|
133333
|
-
|
|
133334
|
-
|
|
133335
|
-
|
|
133336
|
-
|
|
133406
|
+
loginAccountEmail: clientEmail ?? account?.emailAddress,
|
|
133407
|
+
loginPlan: clientPlan,
|
|
133408
|
+
loginRateLimitTier: account?.userRateLimitTier ?? account?.organizationRateLimitTier,
|
|
133409
|
+
loginOrganizationName: account?.organizationName,
|
|
133410
|
+
loginOrganizationType: account?.organizationType,
|
|
133411
|
+
loginSeatTier: account?.seatTier === "none" ? void 0 : account?.seatTier,
|
|
133337
133412
|
fiveHourUsed: void 0,
|
|
133338
133413
|
fiveHourResetAt: void 0,
|
|
133339
133414
|
sevenDayUsed: void 0,
|
|
133340
|
-
sevenDayResetAt: void 0
|
|
133415
|
+
sevenDayResetAt: void 0,
|
|
133416
|
+
providerQuotaWindows: []
|
|
133341
133417
|
};
|
|
133342
133418
|
if (params.snapshot !== void 0) {
|
|
133343
|
-
const scopedName = providerScopedState(params.snapshot, params.env.AGENT_SHIM_PROVIDER);
|
|
133419
|
+
const scopedName = providerScopedState(params.snapshot, params.providerName, params.env.AGENT_SHIM_PROVIDER);
|
|
133344
133420
|
const scopedState = scopedName === void 0 ? void 0 : params.snapshot.providers[scopedName];
|
|
133345
|
-
const states =
|
|
133421
|
+
const states = summary.provider === void 0 ? Object.values(params.snapshot.providers) : scopedState === void 0 ? [] : [scopedState];
|
|
133346
133422
|
let email3;
|
|
133347
133423
|
let sub;
|
|
133348
133424
|
let plan;
|
|
133349
133425
|
for (const state of states) {
|
|
133350
|
-
const
|
|
133351
|
-
const candidateEmail =
|
|
133426
|
+
const providerAccount = state.quota?.account;
|
|
133427
|
+
const candidateEmail = providerAccount?.email;
|
|
133352
133428
|
if (email3 === void 0 && typeof candidateEmail === "string" && candidateEmail !== "") {
|
|
133353
133429
|
email3 = candidateEmail;
|
|
133354
133430
|
}
|
|
133355
|
-
const candidateSub =
|
|
133431
|
+
const candidateSub = providerAccount?.accountId;
|
|
133356
133432
|
if (sub === void 0 && typeof candidateSub === "string" && candidateSub !== "") {
|
|
133357
133433
|
sub = candidateSub;
|
|
133358
133434
|
}
|
|
@@ -133361,7 +133437,17 @@ function enrichStatuslinePayload(params) {
|
|
|
133361
133437
|
plan = candidatePlan;
|
|
133362
133438
|
}
|
|
133363
133439
|
}
|
|
133364
|
-
|
|
133440
|
+
const providerQuotaWindows = [...scopedState?.quota?.windows ?? []].sort((a10, b) => (a10.periodMs ?? Number.POSITIVE_INFINITY) - (b.periodMs ?? Number.POSITIVE_INFINITY)).map((window) => ({ measures: window.measures, utilization: window.utilization, resetsAt: window.resetsAt }));
|
|
133441
|
+
summary = { ...summary, ...windowsOf(states), providerAccountEmail: email3, providerAccountSub: sub, providerPlan: plan, providerQuotaWindows };
|
|
133442
|
+
}
|
|
133443
|
+
if (summary.provider === void 0) {
|
|
133444
|
+
for (const own2 of [antigravityWindowsOf(params.payload, params.nowMs), payloadWindowsOf(params.payload)]) {
|
|
133445
|
+
summary = {
|
|
133446
|
+
...summary,
|
|
133447
|
+
...own2.fiveHourUsed === void 0 ? {} : { fiveHourUsed: own2.fiveHourUsed, fiveHourResetAt: own2.fiveHourResetAt },
|
|
133448
|
+
...own2.sevenDayUsed === void 0 ? {} : { sevenDayUsed: own2.sevenDayUsed, sevenDayResetAt: own2.sevenDayResetAt }
|
|
133449
|
+
};
|
|
133450
|
+
}
|
|
133365
133451
|
}
|
|
133366
133452
|
if (typeof params.payload !== "object" || params.payload === null || Array.isArray(params.payload)) {
|
|
133367
133453
|
return { payload: params.payload, summary };
|
|
@@ -133372,7 +133458,10 @@ function enrichStatuslinePayload(params) {
|
|
|
133372
133458
|
}
|
|
133373
133459
|
return { payload: enriched, summary };
|
|
133374
133460
|
}
|
|
133375
|
-
function providerScopedState(snapshot, providerDisplayName) {
|
|
133461
|
+
function providerScopedState(snapshot, providerName, providerDisplayName) {
|
|
133462
|
+
if (providerName !== void 0 && providerName in snapshot.providers) {
|
|
133463
|
+
return providerName;
|
|
133464
|
+
}
|
|
133376
133465
|
if (providerDisplayName === void 0 || providerDisplayName === "") {
|
|
133377
133466
|
return void 0;
|
|
133378
133467
|
}
|
|
@@ -133653,7 +133742,7 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
|
|
|
133653
133742
|
const account = [summary.providerAccountEmail, summary.providerPlan].filter((part) => part !== void 0);
|
|
133654
133743
|
header.push(new Segment("static", account.length > 0 ? `${summary.provider} \xB7 ${account.join(" \xB7 ")}` : summary.provider));
|
|
133655
133744
|
}
|
|
133656
|
-
const loginPlan = summary.provider === void 0 ? accountPlanLabel(summary) : void 0;
|
|
133745
|
+
const loginPlan = summary.provider === void 0 ? summary.loginPlan ?? accountPlanLabel(summary) : void 0;
|
|
133657
133746
|
const loginOrgName = summary.loginOrganizationType === "claude_team" || summary.loginOrganizationType === "claude_enterprise" ? summary.loginOrganizationName : void 0;
|
|
133658
133747
|
const loginParts = [summary.loginAccountEmail, loginOrgName, loginPlan].filter((part) => part !== void 0);
|
|
133659
133748
|
if (summary.loginAccountEmail !== void 0 && summary.loginAccountEmail !== summary.providerAccountEmail) {
|
|
@@ -133684,6 +133773,14 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
|
|
|
133684
133773
|
const color = statusColor(fraction, true);
|
|
133685
133774
|
quotaGroup.push(new Segment("bar", "", "Wk ", ` ${color}${summary.sevenDayUsed.toFixed(1)}%${RESET} (${formatDuration(secondsUntil(summary.sevenDayResetAt, nowMs))})`, fraction, true));
|
|
133686
133775
|
}
|
|
133776
|
+
if (summary.fiveHourUsed === void 0 && summary.sevenDayUsed === void 0) {
|
|
133777
|
+
for (const window of summary.providerQuotaWindows) {
|
|
133778
|
+
const used = window.utilization * FULL_PERCENT2;
|
|
133779
|
+
const fraction = Math.max(0, Math.min(1, window.utilization));
|
|
133780
|
+
const color = statusColor(fraction, true);
|
|
133781
|
+
quotaGroup.push(new Segment("bar", "", `${window.measures} `, ` ${color}${used.toFixed(1)}%${RESET} (${formatDuration(secondsUntil(window.resetsAt, nowMs))})`, fraction, true));
|
|
133782
|
+
}
|
|
133783
|
+
}
|
|
133687
133784
|
const width = Math.max(TWENTY, terminalWidth - RESERVED_COLUMNS);
|
|
133688
133785
|
const lines = [];
|
|
133689
133786
|
if (header.length > 0) {
|
|
@@ -133696,6 +133793,16 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
|
|
|
133696
133793
|
return lines.join("\n");
|
|
133697
133794
|
}
|
|
133698
133795
|
|
|
133796
|
+
// src/statusline/width.ts
|
|
133797
|
+
var DEFAULT_COLUMNS = 80;
|
|
133798
|
+
function terminalWidthOf(payload, env) {
|
|
133799
|
+
if (typeof payload === "object" && payload !== null && "terminal_width" in payload && typeof payload.terminal_width === "number" && Number.isFinite(payload.terminal_width) && payload.terminal_width > 0) {
|
|
133800
|
+
return Math.floor(payload.terminal_width);
|
|
133801
|
+
}
|
|
133802
|
+
const columns = Number.parseInt(env.COLUMNS ?? "", 10);
|
|
133803
|
+
return Number.isFinite(columns) && columns > 0 ? columns : DEFAULT_COLUMNS;
|
|
133804
|
+
}
|
|
133805
|
+
|
|
133699
133806
|
// src/statusline/commands.ts
|
|
133700
133807
|
function payloadViewOf(payload) {
|
|
133701
133808
|
const empty = { modelDisplayName: void 0, contextUsedPercentage: void 0, contextTotalTokens: void 0, contextWindowTokens: void 0, cacheHitRatio: void 0, cacheReadTokens: void 0, freshInputTokens: void 0 };
|
|
@@ -133733,7 +133840,6 @@ async function readAllStdin() {
|
|
|
133733
133840
|
process.stdin.resume();
|
|
133734
133841
|
});
|
|
133735
133842
|
}
|
|
133736
|
-
var DEFAULT_COLUMNS = 80;
|
|
133737
133843
|
function registerStatuslineCommand(program2, deps) {
|
|
133738
133844
|
withExamples(
|
|
133739
133845
|
program2.command("statusline").description("Serve as a statusline entrypoint: read the client's stdin payload, add the identity's live provider, account and usage windows under an agent_shim key, then run the renderer named in AGENT_SHIM_STATUSLINE_CMD or print the built-in line.").action(async () => {
|
|
@@ -133758,8 +133864,25 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
133758
133864
|
} catch {
|
|
133759
133865
|
account = void 0;
|
|
133760
133866
|
}
|
|
133867
|
+
} else {
|
|
133868
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR;
|
|
133869
|
+
try {
|
|
133870
|
+
account = readAccountMetadataFile(realFarmFs, configDir === void 0 || configDir === "" ? import_node_path53.default.join(import_node_os12.default.homedir(), ".claude.json") : import_node_path53.default.join(configDir, ".claude.json"));
|
|
133871
|
+
} catch {
|
|
133872
|
+
account = void 0;
|
|
133873
|
+
}
|
|
133874
|
+
}
|
|
133875
|
+
const displayName = process.env.AGENT_SHIM_PROVIDER;
|
|
133876
|
+
let providerName;
|
|
133877
|
+
if (displayName !== void 0 && displayName !== "") {
|
|
133878
|
+
try {
|
|
133879
|
+
providerName = listProviders(deps.paths).find((entry) => entry.provider.displayName === displayName)?.name;
|
|
133880
|
+
} catch {
|
|
133881
|
+
providerName = void 0;
|
|
133882
|
+
}
|
|
133761
133883
|
}
|
|
133762
|
-
const
|
|
133884
|
+
const nowMs = Date.now();
|
|
133885
|
+
const { payload: enriched, summary } = enrichStatuslinePayload({ payload, env: process.env, snapshot, account, providerName, nowMs });
|
|
133763
133886
|
const renderer = process.env.AGENT_SHIM_STATUSLINE_CMD;
|
|
133764
133887
|
if (renderer !== void 0 && renderer !== "") {
|
|
133765
133888
|
const child = (0, import_node_child_process7.spawn)("/bin/sh", ["-c", renderer], { stdio: ["pipe", "inherit", "inherit"] });
|
|
@@ -133770,9 +133893,16 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
133770
133893
|
});
|
|
133771
133894
|
return;
|
|
133772
133895
|
}
|
|
133773
|
-
|
|
133774
|
-
|
|
133775
|
-
|
|
133896
|
+
let stackedUnderDefault = false;
|
|
133897
|
+
if (isAntigravityPayload(payload)) {
|
|
133898
|
+
try {
|
|
133899
|
+
stackedUnderDefault = antigravityStacksWithDefault(realFarmFs, import_node_os12.default.homedir());
|
|
133900
|
+
} catch {
|
|
133901
|
+
stackedUnderDefault = false;
|
|
133902
|
+
}
|
|
133903
|
+
}
|
|
133904
|
+
const view = { ...payloadViewOf(payload), ...stackedUnderDefault ? { modelDisplayName: void 0 } : {} };
|
|
133905
|
+
console.log(renderStatuslineBlock(summary, view, terminalWidthOf(payload, process.env), nowMs));
|
|
133776
133906
|
}),
|
|
133777
133907
|
["$ agent-shim statusline # a client's statusline setting names this; it renders or delegates"]
|
|
133778
133908
|
);
|
|
@@ -135796,8 +135926,8 @@ function getErrorMap2() {
|
|
|
135796
135926
|
|
|
135797
135927
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/helpers/parseUtil.js
|
|
135798
135928
|
var makeIssue = (params) => {
|
|
135799
|
-
const { data, path:
|
|
135800
|
-
const fullPath = [...
|
|
135929
|
+
const { data, path: path61, errorMaps, issueData } = params;
|
|
135930
|
+
const fullPath = [...path61, ...issueData.path || []];
|
|
135801
135931
|
const fullIssue = {
|
|
135802
135932
|
...issueData,
|
|
135803
135933
|
path: fullPath
|
|
@@ -135912,11 +136042,11 @@ var errorUtil;
|
|
|
135912
136042
|
|
|
135913
136043
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/types.js
|
|
135914
136044
|
var ParseInputLazyPath = class {
|
|
135915
|
-
constructor(parent, value2,
|
|
136045
|
+
constructor(parent, value2, path61, key) {
|
|
135916
136046
|
this._cachedPath = [];
|
|
135917
136047
|
this.parent = parent;
|
|
135918
136048
|
this.data = value2;
|
|
135919
|
-
this._path =
|
|
136049
|
+
this._path = path61;
|
|
135920
136050
|
this._key = key;
|
|
135921
136051
|
}
|
|
135922
136052
|
get path() {
|
|
@@ -139479,11 +139609,11 @@ function normalizeObjectSchema(schema) {
|
|
|
139479
139609
|
}
|
|
139480
139610
|
return void 0;
|
|
139481
139611
|
}
|
|
139482
|
-
function getDotPath(
|
|
139483
|
-
if (
|
|
139612
|
+
function getDotPath(path61) {
|
|
139613
|
+
if (path61.length === 0) {
|
|
139484
139614
|
return "object root";
|
|
139485
139615
|
}
|
|
139486
|
-
return
|
|
139616
|
+
return path61.reduce((acc, seg, index) => {
|
|
139487
139617
|
if (index === 0) {
|
|
139488
139618
|
return String(seg);
|
|
139489
139619
|
}
|
|
@@ -143526,7 +143656,7 @@ async function serveMcp(mcp, transport, options = {}) {
|
|
|
143526
143656
|
|
|
143527
143657
|
// src/mcp/permissions.ts
|
|
143528
143658
|
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
143529
|
-
var
|
|
143659
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
143530
143660
|
init_zod();
|
|
143531
143661
|
init_store();
|
|
143532
143662
|
var StoredMcpPermissionsSchema = external_exports.strictObject({
|
|
@@ -143548,10 +143678,10 @@ function effectiveMcpPermissions(flags, stored) {
|
|
|
143548
143678
|
return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl, history: flags.history || stored.history };
|
|
143549
143679
|
}
|
|
143550
143680
|
function watchMcpPermissions(paths, onChange) {
|
|
143551
|
-
const directory =
|
|
143681
|
+
const directory = import_node_path54.default.dirname(paths.mcpPermissionsFile);
|
|
143552
143682
|
import_node_fs20.default.mkdirSync(directory, { recursive: true });
|
|
143553
143683
|
const watcher = import_node_fs20.default.watch(directory, (_event, filename) => {
|
|
143554
|
-
if (filename === null || filename ===
|
|
143684
|
+
if (filename === null || filename === import_node_path54.default.basename(paths.mcpPermissionsFile)) {
|
|
143555
143685
|
onChange();
|
|
143556
143686
|
}
|
|
143557
143687
|
});
|
|
@@ -143864,16 +143994,16 @@ init_credentialCache();
|
|
|
143864
143994
|
|
|
143865
143995
|
// src/identityToken.ts
|
|
143866
143996
|
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
143867
|
-
var
|
|
143997
|
+
var import_node_path55 = __toESM(require("node:path"), 1);
|
|
143868
143998
|
init_cliError();
|
|
143869
143999
|
var TOKEN_FILE_MODE = 384;
|
|
143870
144000
|
var TOKEN_DIR_MODE = 448;
|
|
143871
144001
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
143872
144002
|
function identityTokenDir(paths) {
|
|
143873
|
-
return
|
|
144003
|
+
return import_node_path55.default.join(paths.root, "credentials");
|
|
143874
144004
|
}
|
|
143875
144005
|
function identityTokenPath(paths, identityName) {
|
|
143876
|
-
return
|
|
144006
|
+
return import_node_path55.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
143877
144007
|
}
|
|
143878
144008
|
function storeIdentityToken(paths, identityName, raw) {
|
|
143879
144009
|
const token = raw.trim();
|
|
@@ -143884,7 +144014,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
143884
144014
|
import_node_fs21.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
143885
144015
|
import_node_fs21.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
143886
144016
|
const target = identityTokenPath(paths, identityName);
|
|
143887
|
-
const temp =
|
|
144017
|
+
const temp = import_node_path55.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
143888
144018
|
import_node_fs21.default.writeFileSync(temp, `${token}
|
|
143889
144019
|
`, { mode: TOKEN_FILE_MODE });
|
|
143890
144020
|
import_node_fs21.default.renameSync(temp, target);
|
|
@@ -144052,7 +144182,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
144052
144182
|
// src/headroom/commands.ts
|
|
144053
144183
|
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
144054
144184
|
var import_node_http4 = __toESM(require("node:http"), 1);
|
|
144055
|
-
var
|
|
144185
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
144056
144186
|
var import_node_child_process9 = require("node:child_process");
|
|
144057
144187
|
init_commandDeps();
|
|
144058
144188
|
init_realFrontDoorPort();
|
|
@@ -144241,12 +144371,12 @@ function readInstalledHeadroomCommit() {
|
|
|
144241
144371
|
if (toolDir.status !== 0) {
|
|
144242
144372
|
return void 0;
|
|
144243
144373
|
}
|
|
144244
|
-
const libDir =
|
|
144374
|
+
const libDir = import_node_path56.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
144245
144375
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
144246
|
-
const sitePackages =
|
|
144376
|
+
const sitePackages = import_node_path56.default.join(libDir, python, "site-packages");
|
|
144247
144377
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
144248
144378
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
144249
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
144379
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path56.default.join(sitePackages, entry, "direct_url.json"));
|
|
144250
144380
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
144251
144381
|
}
|
|
144252
144382
|
}
|
|
@@ -144395,7 +144525,7 @@ function registerHeadroomCommand(program2, deps) {
|
|
|
144395
144525
|
init_realPorts();
|
|
144396
144526
|
|
|
144397
144527
|
// src/usage/realJobRunner.ts
|
|
144398
|
-
var
|
|
144528
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
144399
144529
|
init_conditions();
|
|
144400
144530
|
init_identityClaude();
|
|
144401
144531
|
var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
|
|
@@ -144408,7 +144538,7 @@ ${outcome.trimEnd()}
|
|
|
144408
144538
|
}
|
|
144409
144539
|
function createRealJobRunner(params) {
|
|
144410
144540
|
return async (name, identity, job) => {
|
|
144411
|
-
const logFile =
|
|
144541
|
+
const logFile = import_node_path57.default.join(params.paths.jobLogsDir, `${name}.log`);
|
|
144412
144542
|
const append = (outcome) => {
|
|
144413
144543
|
params.fs.mkdirPrivate(params.paths.jobLogsDir);
|
|
144414
144544
|
params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
|
|
@@ -144462,7 +144592,7 @@ function registerHeadlessCommands(program2, deps) {
|
|
|
144462
144592
|
}
|
|
144463
144593
|
|
|
144464
144594
|
// src/jobs.ts
|
|
144465
|
-
var
|
|
144595
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
144466
144596
|
init_commandDeps();
|
|
144467
144597
|
init_cliError();
|
|
144468
144598
|
init_schema();
|
|
@@ -144487,7 +144617,7 @@ function jobOf(options) {
|
|
|
144487
144617
|
target: options.identity === void 0 ? { pool: options.pool ?? "" } : { identity: options.identity },
|
|
144488
144618
|
trigger: options.at === void 0 ? { beforeReset: options.beforeReset ?? "fiveHour", lead: options.lead ?? "" } : { at: options.at },
|
|
144489
144619
|
prompt: options.prompt,
|
|
144490
|
-
cwd:
|
|
144620
|
+
cwd: import_node_path58.default.resolve(options.cwd ?? process.cwd()),
|
|
144491
144621
|
timeout: options.timeout,
|
|
144492
144622
|
...options.model === void 0 ? {} : { model: options.model },
|
|
144493
144623
|
...options.allowedTool === void 0 ? {} : { allowedTools: options.allowedTool }
|
|
@@ -144560,7 +144690,7 @@ function registerJobCommand(program2, deps) {
|
|
|
144560
144690
|
console.log(`Allowed tools: ${entry.allowedTools.join(", ")}`);
|
|
144561
144691
|
}
|
|
144562
144692
|
console.log(`Prompt: ${entry.prompt}`);
|
|
144563
|
-
console.log(`Results: ${
|
|
144693
|
+
console.log(`Results: ${import_node_path58.default.join(paths.jobLogsDir, `${name}.log`)}`);
|
|
144564
144694
|
}),
|
|
144565
144695
|
["agent-shim job show digest"]
|
|
144566
144696
|
);
|
|
@@ -144583,7 +144713,7 @@ function registerJobCommand(program2, deps) {
|
|
|
144583
144713
|
throw new UsageError(`No member of the job's pool can be picked right now.`);
|
|
144584
144714
|
}
|
|
144585
144715
|
await createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() })(name, identity, entry);
|
|
144586
|
-
console.log(`Ran job "${name}" as ${identity}; the result is in ${
|
|
144716
|
+
console.log(`Ran job "${name}" as ${identity}; the result is in ${import_node_path58.default.join(paths.jobLogsDir, `${name}.log`)}.`);
|
|
144587
144717
|
}),
|
|
144588
144718
|
["agent-shim job run digest"]
|
|
144589
144719
|
);
|
|
@@ -145109,7 +145239,7 @@ function registerSessionCommands(program2, deps) {
|
|
|
145109
145239
|
}
|
|
145110
145240
|
|
|
145111
145241
|
// src/usage/commands.ts
|
|
145112
|
-
var
|
|
145242
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
145113
145243
|
init_commandDeps();
|
|
145114
145244
|
init_realPorts();
|
|
145115
145245
|
init_account();
|
|
@@ -145247,7 +145377,7 @@ function collectAccounts(fs24, paths, identity, probe) {
|
|
|
145247
145377
|
return names.map((name) => ({
|
|
145248
145378
|
identity: name,
|
|
145249
145379
|
account: readAccountMetadata(fs24, paths.identitiesDir, name),
|
|
145250
|
-
signIn: identitySignIn(fs24, probe, { farmRoot:
|
|
145380
|
+
signIn: identitySignIn(fs24, probe, { farmRoot: import_node_path59.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
|
|
145251
145381
|
usage: readUsageSnapshot(fs24, paths.usageSnapshotsDir, name)
|
|
145252
145382
|
}));
|
|
145253
145383
|
}
|
|
@@ -145596,7 +145726,7 @@ async function runClaude(argvOverride) {
|
|
|
145596
145726
|
// src/cli.ts
|
|
145597
145727
|
async function main() {
|
|
145598
145728
|
aliasLegacyEnv(process.env);
|
|
145599
|
-
const invokedName =
|
|
145729
|
+
const invokedName = import_node_path60.default.basename(process.argv[1] ?? "agent-shim");
|
|
145600
145730
|
if (isInvokedAsClaude(invokedName)) {
|
|
145601
145731
|
await runClaude();
|
|
145602
145732
|
return;
|