claude-use 11.13.0 → 11.15.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 +718 -456
- 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.15.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") {
|
|
@@ -44664,7 +44666,7 @@ var require_client = __commonJS({
|
|
|
44664
44666
|
"use strict";
|
|
44665
44667
|
var assert2 = require("node:assert");
|
|
44666
44668
|
var net5 = require("node:net");
|
|
44667
|
-
var
|
|
44669
|
+
var http9 = require("node:http");
|
|
44668
44670
|
var util2 = require_util2();
|
|
44669
44671
|
var { ClientStats } = require_stats();
|
|
44670
44672
|
var { channels } = require_diagnostics();
|
|
@@ -44722,7 +44724,7 @@ var require_client = __commonJS({
|
|
|
44722
44724
|
var connectH1 = require_client_h1();
|
|
44723
44725
|
var connectH2 = require_client_h2();
|
|
44724
44726
|
var kClosedResolve = /* @__PURE__ */ Symbol("kClosedResolve");
|
|
44725
|
-
var getDefaultNodeMaxHeaderSize =
|
|
44727
|
+
var getDefaultNodeMaxHeaderSize = http9 && http9.maxHeaderSize && Number.isInteger(http9.maxHeaderSize) && http9.maxHeaderSize > 0 ? () => http9.maxHeaderSize : () => {
|
|
44726
44728
|
throw new InvalidArgumentError2("http module not available or http.maxHeaderSize invalid");
|
|
44727
44729
|
};
|
|
44728
44730
|
var noop = () => {
|
|
@@ -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 : {};
|
|
@@ -62422,9 +62424,9 @@ function expectedSha256(sidecar) {
|
|
|
62422
62424
|
const first = sidecar.trim().split(/\s+/)[0];
|
|
62423
62425
|
return first === "" ? void 0 : first;
|
|
62424
62426
|
}
|
|
62425
|
-
async function mustDownload(
|
|
62427
|
+
async function mustDownload(http9, url2) {
|
|
62426
62428
|
try {
|
|
62427
|
-
return await
|
|
62429
|
+
return await http9.download(url2);
|
|
62428
62430
|
} catch (error63) {
|
|
62429
62431
|
throw new UpdateDownloadError(`could not download ${url2}: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
62430
62432
|
}
|
|
@@ -64122,8 +64124,8 @@ function zaiWindow(limit) {
|
|
|
64122
64124
|
...limit.remaining === void 0 ? {} : { remaining: limit.remaining }
|
|
64123
64125
|
};
|
|
64124
64126
|
}
|
|
64125
|
-
async function openRouterGet(url2, schema, apiKey,
|
|
64126
|
-
const response = await
|
|
64127
|
+
async function openRouterGet(url2, schema, apiKey, http9, signal) {
|
|
64128
|
+
const response = await http9(url2, { authorization: `Bearer ${apiKey}`, accept: "application/json" }, signal);
|
|
64127
64129
|
if (response.status === HTTP_FORBIDDEN) {
|
|
64128
64130
|
return "forbidden";
|
|
64129
64131
|
}
|
|
@@ -64199,8 +64201,8 @@ var init_providerQuota = __esm({
|
|
|
64199
64201
|
zaiQuotaAdapter = {
|
|
64200
64202
|
source: ZAI_SOURCE,
|
|
64201
64203
|
matches: (baseUrl) => URL.canParse(baseUrl) && new URL(baseUrl).hostname === ZAI_HOST,
|
|
64202
|
-
fetch: async (apiKey,
|
|
64203
|
-
const response = await
|
|
64204
|
+
fetch: async (apiKey, http9, signal, nowMs) => {
|
|
64205
|
+
const response = await http9(ZAI_QUOTA_URL, { authorization: apiKey, accept: "application/json" }, signal);
|
|
64204
64206
|
if (response.status !== HTTP_OK) {
|
|
64205
64207
|
throw new ProviderQuotaError(ZAI_SOURCE, `answered HTTP ${String(response.status)}`);
|
|
64206
64208
|
}
|
|
@@ -64244,12 +64246,12 @@ var init_providerQuota = __esm({
|
|
|
64244
64246
|
openRouterQuotaAdapter = {
|
|
64245
64247
|
source: OPENROUTER_SOURCE,
|
|
64246
64248
|
matches: (baseUrl) => URL.canParse(baseUrl) && new URL(baseUrl).hostname === OPENROUTER_HOST,
|
|
64247
|
-
fetch: async (apiKey,
|
|
64248
|
-
const key = await openRouterGet(OPENROUTER_KEY_URL, OpenRouterKeySchema, apiKey,
|
|
64249
|
+
fetch: async (apiKey, http9, signal, nowMs) => {
|
|
64250
|
+
const key = await openRouterGet(OPENROUTER_KEY_URL, OpenRouterKeySchema, apiKey, http9, signal);
|
|
64249
64251
|
if (key === "forbidden") {
|
|
64250
64252
|
throw new ProviderQuotaError(OPENROUTER_SOURCE, "/api/v1/key refused the key (HTTP 403)");
|
|
64251
64253
|
}
|
|
64252
|
-
const credits = await openRouterGet(OPENROUTER_CREDITS_URL, OpenRouterCreditsSchema, apiKey,
|
|
64254
|
+
const credits = await openRouterGet(OPENROUTER_CREDITS_URL, OpenRouterCreditsSchema, apiKey, http9, signal);
|
|
64253
64255
|
const { limit, limit_remaining: limitRemaining, limit_reset: limitReset, free_model_daily_requests: free, is_free_tier: isFreeTier } = key.data;
|
|
64254
64256
|
const windows = [];
|
|
64255
64257
|
if (limit !== null && limit > 0) {
|
|
@@ -64300,9 +64302,9 @@ var init_providerQuota = __esm({
|
|
|
64300
64302
|
antigravityQuotaAdapter = {
|
|
64301
64303
|
source: ANTIGRAVITY_SOURCE,
|
|
64302
64304
|
matches: (baseUrl) => URL.canParse(baseUrl) && new URL(baseUrl).hostname === ANTIGRAVITY_HOST,
|
|
64303
|
-
fetch: async (apiKey,
|
|
64305
|
+
fetch: async (apiKey, http9, signal, nowMs) => {
|
|
64304
64306
|
const headers = { authorization: `Bearer ${apiKey}`, "content-type": "application/json", "user-agent": CCPA_USER_AGENT };
|
|
64305
|
-
const summaryResponse = await
|
|
64307
|
+
const summaryResponse = await http9(ANTIGRAVITY_QUOTA_URL, headers, signal, { method: "POST", body: JSON.stringify({ project: "aicode-consumers" }) });
|
|
64306
64308
|
if (summaryResponse.status !== HTTP_OK) {
|
|
64307
64309
|
throw new ProviderQuotaError(ANTIGRAVITY_SOURCE, `answered HTTP ${String(summaryResponse.status)}`);
|
|
64308
64310
|
}
|
|
@@ -64316,7 +64318,7 @@ var init_providerQuota = __esm({
|
|
|
64316
64318
|
if (!parsed.success) {
|
|
64317
64319
|
throw new ProviderQuotaError(ANTIGRAVITY_SOURCE, `answered an unexpected shape: ${parsed.error.issues.map((issue2) => `${issue2.path.join(".")}: ${issue2.message}`).join("; ")}`);
|
|
64318
64320
|
}
|
|
64319
|
-
const tokenResponse = await
|
|
64321
|
+
const tokenResponse = await http9(`${GOOGLE_TOKENINFO_URL}?access_token=${encodeURIComponent(apiKey)}`, { accept: "application/json" }, signal);
|
|
64320
64322
|
let account;
|
|
64321
64323
|
if (tokenResponse.status === HTTP_OK) {
|
|
64322
64324
|
try {
|
|
@@ -64328,7 +64330,7 @@ var init_providerQuota = __esm({
|
|
|
64328
64330
|
}
|
|
64329
64331
|
}
|
|
64330
64332
|
let level;
|
|
64331
|
-
const userResponse = await
|
|
64333
|
+
const userResponse = await http9(ANTIGRAVITY_USER_URL, headers, signal, { method: "POST", body: "{}" });
|
|
64332
64334
|
if (userResponse.status === HTTP_OK) {
|
|
64333
64335
|
try {
|
|
64334
64336
|
const tiers = AntigravityUserSchema.parse(JSON.parse(userResponse.text));
|
|
@@ -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
|
}
|
|
@@ -101697,7 +101699,7 @@ var require_schemes = __commonJS({
|
|
|
101697
101699
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
101698
101700
|
return urnComponent;
|
|
101699
101701
|
}
|
|
101700
|
-
var
|
|
101702
|
+
var http9 = (
|
|
101701
101703
|
/** @type {SchemeHandler} */
|
|
101702
101704
|
{
|
|
101703
101705
|
scheme: "http",
|
|
@@ -101710,7 +101712,7 @@ var require_schemes = __commonJS({
|
|
|
101710
101712
|
/** @type {SchemeHandler} */
|
|
101711
101713
|
{
|
|
101712
101714
|
scheme: "https",
|
|
101713
|
-
domainHost:
|
|
101715
|
+
domainHost: http9.domainHost,
|
|
101714
101716
|
parse: httpParse,
|
|
101715
101717
|
serialize: httpSerialize
|
|
101716
101718
|
}
|
|
@@ -101754,7 +101756,7 @@ var require_schemes = __commonJS({
|
|
|
101754
101756
|
var SCHEMES = (
|
|
101755
101757
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
101756
101758
|
{
|
|
101757
|
-
http:
|
|
101759
|
+
http: http9,
|
|
101758
101760
|
https: https6,
|
|
101759
101761
|
ws,
|
|
101760
101762
|
wss,
|
|
@@ -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
|
}
|
|
@@ -114548,23 +114550,23 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
114548
114550
|
};
|
|
114549
114551
|
writeFrontDoorState(fs24, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, ...sticky() });
|
|
114550
114552
|
const previousSticky = lastPort;
|
|
114551
|
-
let
|
|
114553
|
+
let http9;
|
|
114552
114554
|
try {
|
|
114553
|
-
|
|
114555
|
+
http9 = await ports.startProviderListener(lastPort);
|
|
114554
114556
|
} catch (error63) {
|
|
114555
114557
|
ports.doorHealth.listenerFailed("provider", error63 instanceof Error ? error63.message : String(error63));
|
|
114556
114558
|
return fail(`could not start the provider listener: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
114557
114559
|
}
|
|
114558
|
-
if (previousSticky !== void 0 &&
|
|
114559
|
-
ports.log(`agent-shim frontdoor supervisor: sticky port ${String(previousSticky)} was occupied; moving to ${String(
|
|
114560
|
+
if (previousSticky !== void 0 && http9.port !== previousSticky) {
|
|
114561
|
+
ports.log(`agent-shim frontdoor supervisor: sticky port ${String(previousSticky)} was occupied; moving to ${String(http9.port)} (sessions launched against the old port are stale until they relaunch)`);
|
|
114560
114562
|
}
|
|
114561
|
-
lastPort =
|
|
114563
|
+
lastPort = http9.port;
|
|
114562
114564
|
const previousStickyConnect = lastConnectPort;
|
|
114563
114565
|
let connect3;
|
|
114564
114566
|
try {
|
|
114565
114567
|
connect3 = await ports.startConnectListener(lastConnectPort);
|
|
114566
114568
|
} catch (error63) {
|
|
114567
|
-
await
|
|
114569
|
+
await http9.close();
|
|
114568
114570
|
ports.doorHealth.listenerFailed("connect", error63 instanceof Error ? error63.message : String(error63));
|
|
114569
114571
|
return fail(`could not start the CONNECT surface: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
114570
114572
|
}
|
|
@@ -114578,7 +114580,7 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
114578
114580
|
direct = await ports.startDirectListener(lastDirectPort);
|
|
114579
114581
|
} catch (error63) {
|
|
114580
114582
|
await connect3.close();
|
|
114581
|
-
await
|
|
114583
|
+
await http9.close();
|
|
114582
114584
|
ports.doorHealth.listenerFailed("direct", error63 instanceof Error ? error63.message : String(error63));
|
|
114583
114585
|
return fail(`could not start the direct listener: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
114584
114586
|
}
|
|
@@ -114587,10 +114589,10 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
114587
114589
|
}
|
|
114588
114590
|
lastDirectPort = direct.port;
|
|
114589
114591
|
writeFrontDoorDirectRecord(fs24, paths.frontdoorDirectRecordsDir, { pid: ports.ownPid, directPort: direct.port });
|
|
114590
|
-
writeFrontDoorState(fs24, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port:
|
|
114591
|
-
ports.doorHealth.generation({ providerPort:
|
|
114592
|
+
writeFrontDoorState(fs24, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port: http9.port, connectPort: connect3.port, directPort: direct.port, ...sticky() });
|
|
114593
|
+
ports.doorHealth.generation({ providerPort: http9.port, connectPort: connect3.port, directPort: direct.port });
|
|
114592
114594
|
fs24.removeRecursive(paths.frontdoorLockFile);
|
|
114593
|
-
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(
|
|
114595
|
+
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(http9.port)}, CONNECT surface on 127.0.0.1:${String(connect3.port)}`);
|
|
114594
114596
|
const watchdog = ports.startWatchdog?.();
|
|
114595
114597
|
let idleSince;
|
|
114596
114598
|
let ticks = 0;
|
|
@@ -114608,7 +114610,7 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
114608
114610
|
watchdog?.stop();
|
|
114609
114611
|
await direct.close();
|
|
114610
114612
|
await connect3.close();
|
|
114611
|
-
await
|
|
114613
|
+
await http9.close();
|
|
114612
114614
|
ports.closeRcStreamHub();
|
|
114613
114615
|
removeFrontDoorDirectRecord(fs24, paths.frontdoorDirectRecordsDir, ports.ownPid);
|
|
114614
114616
|
};
|
|
@@ -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: {
|
|
@@ -127770,6 +127772,7 @@ function translateRequest(body, config2) {
|
|
|
127770
127772
|
var import_node_crypto21 = require("node:crypto");
|
|
127771
127773
|
|
|
127772
127774
|
// src/antigravity/signatures.ts
|
|
127775
|
+
var UNVERIFIED_THOUGHT_SIGNATURE = "skip_thought_signature_validator";
|
|
127773
127776
|
var MAX_REMEMBERED = 1024;
|
|
127774
127777
|
var signatures = /* @__PURE__ */ new Map();
|
|
127775
127778
|
function rememberToolCallSignature(toolUseId, signature) {
|
|
@@ -127931,8 +127934,8 @@ function messagesToGeminiContents(messages, names, toolIdToName) {
|
|
|
127931
127934
|
name: sanitizedName,
|
|
127932
127935
|
args: isRecord8(block2.input) ? block2.input : {}
|
|
127933
127936
|
},
|
|
127934
|
-
// The relay remembered the signature the backend attached to this exact call; echoing it back is what the backend requires of a repeated function call.
|
|
127935
|
-
|
|
127937
|
+
// The relay remembered the signature the backend attached to this exact call; echoing it back is what the backend requires of a repeated function call. A call with none remembered (made before a door restart, evicted from the bounded store, or produced by another model in a resumed session) gets the backend's documented bypass, since history is resent whole on every request and a single unsigned call would otherwise fail the whole conversation for good.
|
|
127938
|
+
thoughtSignature: signature ?? UNVERIFIED_THOUGHT_SIGNATURE
|
|
127936
127939
|
});
|
|
127937
127940
|
} else if (isToolResultBlock(block2)) {
|
|
127938
127941
|
const toolName = toolIdToName.get(block2.tool_use_id) ?? "unknown_tool";
|
|
@@ -128075,9 +128078,9 @@ init_cloudUpstream();
|
|
|
128075
128078
|
var MS_PER_SECOND8 = 1e3;
|
|
128076
128079
|
var DEFAULT_RETRY_AFTER_SECONDS = 60;
|
|
128077
128080
|
var FRACTION_DIGITS = 3;
|
|
128078
|
-
var EXHAUSTED_FRACTION = "1.000";
|
|
128079
128081
|
var GEMINI_5H_KEYS = ["gemini-5h", "gemini_5h", "gemini"];
|
|
128080
128082
|
var GEMINI_WEEKLY_KEYS = ["gemini-weekly", "gemini_weekly"];
|
|
128083
|
+
var ARGON_WEEKLY_KEYS = ["gemini-argon-wtu-weekly"];
|
|
128081
128084
|
var THIRD_PARTY_5H_KEYS = ["3p-5h", "claude-5h", "3p_5h", "claude_5h", "claude"];
|
|
128082
128085
|
var THIRD_PARTY_WEEKLY_KEYS = ["3p-weekly", "claude-weekly", "3p_weekly", "claude_weekly"];
|
|
128083
128086
|
function findBucket(quota, keys) {
|
|
@@ -128089,6 +128092,17 @@ function findBucket(quota, keys) {
|
|
|
128089
128092
|
}
|
|
128090
128093
|
return void 0;
|
|
128091
128094
|
}
|
|
128095
|
+
function selectAntigravityBuckets(quota, model) {
|
|
128096
|
+
const lower = (model ?? "").toLowerCase();
|
|
128097
|
+
if (lower.includes("argon")) {
|
|
128098
|
+
return { fiveHour: void 0, weekly: findBucket(quota, ARGON_WEEKLY_KEYS) };
|
|
128099
|
+
}
|
|
128100
|
+
const isGemini = lower.includes("gemini");
|
|
128101
|
+
return {
|
|
128102
|
+
fiveHour: findBucket(quota, isGemini ? GEMINI_5H_KEYS : THIRD_PARTY_5H_KEYS),
|
|
128103
|
+
weekly: findBucket(quota, isGemini ? GEMINI_WEEKLY_KEYS : THIRD_PARTY_WEEKLY_KEYS)
|
|
128104
|
+
};
|
|
128105
|
+
}
|
|
128092
128106
|
function calculateUtilization(remainingFraction) {
|
|
128093
128107
|
if (remainingFraction === void 0 || !Number.isFinite(remainingFraction)) {
|
|
128094
128108
|
return void 0;
|
|
@@ -128121,17 +128135,15 @@ function parseRetryAfterSeconds(raw, defaultSeconds = DEFAULT_RETRY_AFTER_SECOND
|
|
|
128121
128135
|
function unifiedAntigravityQuotaHeaders(params) {
|
|
128122
128136
|
const rejected = params.rejected === true;
|
|
128123
128137
|
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);
|
|
128138
|
+
const { fiveHour: b5h, weekly: bWk } = selectAntigravityBuckets(params.quota ?? {}, params.model);
|
|
128131
128139
|
const used5h = calculateUtilization(b5h?.remaining_fraction);
|
|
128132
128140
|
const reset5h = calculateResetTimestamp(nowSec, b5h?.reset_in_seconds);
|
|
128133
128141
|
const used7d = calculateUtilization(bWk?.remaining_fraction);
|
|
128134
128142
|
const reset7d = calculateResetTimestamp(nowSec, bWk?.reset_in_seconds);
|
|
128143
|
+
const exhaustion = rejected ? antigravityQuotaExhaustion(params.quota, params.model, params.nowMs) : void 0;
|
|
128144
|
+
if (rejected && exhaustion === void 0) {
|
|
128145
|
+
return {};
|
|
128146
|
+
}
|
|
128135
128147
|
if (!rejected && used5h === void 0 && reset5h === void 0 && used7d === void 0 && reset7d === void 0) {
|
|
128136
128148
|
return {};
|
|
128137
128149
|
}
|
|
@@ -128143,31 +128155,45 @@ function unifiedAntigravityQuotaHeaders(params) {
|
|
|
128143
128155
|
headers["anthropic-ratelimit-unified-5h-utilization"] = used5h;
|
|
128144
128156
|
headers["anthropic-ratelimit-unified-5h-reset"] = reset5h;
|
|
128145
128157
|
earliestResetSec = Number(reset5h);
|
|
128158
|
+
if (rejected) {
|
|
128159
|
+
headers["anthropic-ratelimit-unified-5h-status"] = exhaustion?.exhaustedWindows.includes("five_hour") === true ? "rejected" : "allowed";
|
|
128160
|
+
}
|
|
128146
128161
|
}
|
|
128147
128162
|
if (used7d !== void 0 && reset7d !== void 0) {
|
|
128148
128163
|
headers["anthropic-ratelimit-unified-7d-utilization"] = used7d;
|
|
128149
128164
|
headers["anthropic-ratelimit-unified-7d-reset"] = reset7d;
|
|
128150
128165
|
const reset7dSec = Number(reset7d);
|
|
128151
128166
|
earliestResetSec = earliestResetSec === void 0 ? reset7dSec : Math.min(earliestResetSec, reset7dSec);
|
|
128152
|
-
|
|
128153
|
-
|
|
128154
|
-
const retrySec = params.retryAfterSeconds ?? DEFAULT_RETRY_AFTER_SECONDS;
|
|
128155
|
-
const fallbackReset = String(nowSec + retrySec);
|
|
128156
|
-
if (headers["anthropic-ratelimit-unified-5h-utilization"] === void 0) {
|
|
128157
|
-
headers["anthropic-ratelimit-unified-5h-utilization"] = EXHAUSTED_FRACTION;
|
|
128158
|
-
headers["anthropic-ratelimit-unified-5h-reset"] = fallbackReset;
|
|
128159
|
-
}
|
|
128160
|
-
if (headers["anthropic-ratelimit-unified-7d-utilization"] === void 0) {
|
|
128161
|
-
headers["anthropic-ratelimit-unified-7d-utilization"] = EXHAUSTED_FRACTION;
|
|
128162
|
-
headers["anthropic-ratelimit-unified-7d-reset"] = fallbackReset;
|
|
128167
|
+
if (rejected) {
|
|
128168
|
+
headers["anthropic-ratelimit-unified-7d-status"] = exhaustion?.exhaustedWindows.includes("seven_day") === true ? "rejected" : "allowed";
|
|
128163
128169
|
}
|
|
128164
|
-
|
|
128170
|
+
}
|
|
128171
|
+
if (exhaustion !== void 0) {
|
|
128172
|
+
headers["anthropic-ratelimit-unified-representative-claim"] = exhaustion.window;
|
|
128173
|
+
headers["anthropic-ratelimit-unified-reset"] = String(exhaustion.resetSec);
|
|
128174
|
+
headers["retry-after"] = String(Math.max(1, exhaustion.resetSec - nowSec));
|
|
128175
|
+
headers["x-should-retry"] = "false";
|
|
128176
|
+
return headers;
|
|
128165
128177
|
}
|
|
128166
128178
|
if (earliestResetSec !== void 0) {
|
|
128167
128179
|
headers["anthropic-ratelimit-unified-reset"] = String(earliestResetSec);
|
|
128168
128180
|
}
|
|
128169
128181
|
return headers;
|
|
128170
128182
|
}
|
|
128183
|
+
function antigravityQuotaExhaustion(quota, model, nowMs) {
|
|
128184
|
+
const { fiveHour, weekly } = selectAntigravityBuckets(quota ?? {}, model);
|
|
128185
|
+
const nowSec = Math.floor(nowMs / MS_PER_SECOND8);
|
|
128186
|
+
const spent = [];
|
|
128187
|
+
for (const [window, bucket] of [["five_hour", fiveHour], ["seven_day", weekly]]) {
|
|
128188
|
+
const remaining = bucket?.remaining_fraction;
|
|
128189
|
+
const resetIn = bucket?.reset_in_seconds;
|
|
128190
|
+
if (remaining !== void 0 && Number.isFinite(remaining) && remaining <= 0 && resetIn !== void 0 && Number.isFinite(resetIn) && resetIn >= 0) {
|
|
128191
|
+
spent.push({ window, resetSec: nowSec + Math.ceil(resetIn) });
|
|
128192
|
+
}
|
|
128193
|
+
}
|
|
128194
|
+
const binding = spent.reduce((latest, next) => latest === void 0 || next.resetSec > latest.resetSec ? next : latest, void 0);
|
|
128195
|
+
return binding === void 0 ? void 0 : { window: binding.window, resetSec: binding.resetSec, exhaustedWindows: spent.map((entry) => entry.window) };
|
|
128196
|
+
}
|
|
128171
128197
|
function isRecord9(value2) {
|
|
128172
128198
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
128173
128199
|
}
|
|
@@ -128235,6 +128261,7 @@ var ANTIGRAVITY_QUOTA_REFRESH_MS = 6e4;
|
|
|
128235
128261
|
function createCachedAntigravityQuotaSource(params) {
|
|
128236
128262
|
let cachedAt = Number.NEGATIVE_INFINITY;
|
|
128237
128263
|
let cached2;
|
|
128264
|
+
let readAtMs = Number.NEGATIVE_INFINITY;
|
|
128238
128265
|
let refresh;
|
|
128239
128266
|
const refreshMs = params.refreshMs ?? ANTIGRAVITY_QUOTA_REFRESH_MS;
|
|
128240
128267
|
const run = async () => {
|
|
@@ -128242,20 +128269,26 @@ function createCachedAntigravityQuotaSource(params) {
|
|
|
128242
128269
|
const read = await params.fetchSummary(nowMs);
|
|
128243
128270
|
if (read !== void 0) {
|
|
128244
128271
|
cached2 = read;
|
|
128272
|
+
readAtMs = nowMs;
|
|
128245
128273
|
}
|
|
128246
128274
|
cachedAt = params.now();
|
|
128247
128275
|
};
|
|
128248
128276
|
return () => {
|
|
128249
128277
|
const nowMs = params.now();
|
|
128250
|
-
if (nowMs - cachedAt
|
|
128251
|
-
|
|
128278
|
+
if (nowMs - cachedAt >= refreshMs) {
|
|
128279
|
+
refresh ??= run().finally(() => {
|
|
128280
|
+
refresh = void 0;
|
|
128281
|
+
});
|
|
128252
128282
|
}
|
|
128253
|
-
|
|
128254
|
-
refresh = void 0;
|
|
128255
|
-
});
|
|
128256
|
-
return cached2;
|
|
128283
|
+
return cached2 === void 0 ? void 0 : ageQuotaMap(cached2, nowMs - readAtMs);
|
|
128257
128284
|
};
|
|
128258
128285
|
}
|
|
128286
|
+
function ageQuotaMap(quota, elapsedMs) {
|
|
128287
|
+
const elapsedSec = elapsedMs / MS_PER_SECOND8;
|
|
128288
|
+
return Object.fromEntries(
|
|
128289
|
+
Object.entries(quota).map(([key, bucket]) => [key, bucket?.reset_in_seconds === void 0 ? bucket : { ...bucket, reset_in_seconds: Math.max(0, bucket.reset_in_seconds - elapsedSec) }])
|
|
128290
|
+
);
|
|
128291
|
+
}
|
|
128259
128292
|
|
|
128260
128293
|
// src/frontdoor/providerRoute.ts
|
|
128261
128294
|
init_credential();
|
|
@@ -128838,8 +128871,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
128838
128871
|
request7.body.resume();
|
|
128839
128872
|
return;
|
|
128840
128873
|
}
|
|
128841
|
-
const
|
|
128842
|
-
const translated = { method: request7.method, path:
|
|
128874
|
+
const path61 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
128875
|
+
const translated = { method: request7.method, path: path61, body, signal: request7.signal };
|
|
128843
128876
|
const routed = await route(translated);
|
|
128844
128877
|
if (request7.signal.aborted) {
|
|
128845
128878
|
return;
|
|
@@ -129212,6 +129245,11 @@ async function* callLocalAntigravity(params) {
|
|
|
129212
129245
|
}
|
|
129213
129246
|
|
|
129214
129247
|
// src/antigravity/route.ts
|
|
129248
|
+
var MS_PER_SECOND10 = 1e3;
|
|
129249
|
+
function exhaustedMessage(exhaustion) {
|
|
129250
|
+
const window = exhaustion.window === "five_hour" ? "5-hour" : "weekly";
|
|
129251
|
+
return `Antigravity ${window} limit reached; it resets at ${new Date(exhaustion.resetSec * MS_PER_SECOND10).toISOString()}.`;
|
|
129252
|
+
}
|
|
129215
129253
|
function createAntigravityRoute(ports) {
|
|
129216
129254
|
const fallbackId = ports.fallbackId ?? (() => (0, import_node_crypto22.randomUUID)());
|
|
129217
129255
|
return async (request7) => {
|
|
@@ -129296,14 +129334,10 @@ function createAntigravityRoute(ports) {
|
|
|
129296
129334
|
} catch (error63) {
|
|
129297
129335
|
if (error63 instanceof AntigravityUpstreamError) {
|
|
129298
129336
|
const is429 = error63.status === HTTP_STATUS.tooManyRequests;
|
|
129299
|
-
const
|
|
129300
|
-
const quotaHeaders3 = unifiedAntigravityQuotaHeaders({
|
|
129301
|
-
|
|
129302
|
-
|
|
129303
|
-
nowMs,
|
|
129304
|
-
retryAfterSeconds: retryAfter,
|
|
129305
|
-
model: requestedModel
|
|
129306
|
-
});
|
|
129337
|
+
const quota = ports.quotaSource?.();
|
|
129338
|
+
const quotaHeaders3 = unifiedAntigravityQuotaHeaders({ quota, rejected: is429, nowMs, model: translated.model });
|
|
129339
|
+
const retryAfter = is429 && quotaHeaders3["retry-after"] === void 0 ? parseRetryAfterSeconds(error63.retryAfter) : void 0;
|
|
129340
|
+
const exhaustion = is429 ? antigravityQuotaExhaustion(quota, translated.model, nowMs) : void 0;
|
|
129307
129341
|
const errorType = is429 ? "rate_limit_error" : "api_error";
|
|
129308
129342
|
return {
|
|
129309
129343
|
status: error63.status,
|
|
@@ -129312,7 +129346,7 @@ function createAntigravityRoute(ports) {
|
|
|
129312
129346
|
...quotaHeaders3,
|
|
129313
129347
|
...retryAfter !== void 0 ? { "retry-after": String(retryAfter) } : {}
|
|
129314
129348
|
},
|
|
129315
|
-
body: JSON.stringify({ type: "error", error: { type: errorType, message: error63.message } })
|
|
129349
|
+
body: JSON.stringify({ type: "error", error: { type: errorType, message: exhaustion === void 0 ? error63.message : exhaustedMessage(exhaustion) } })
|
|
129316
129350
|
};
|
|
129317
129351
|
}
|
|
129318
129352
|
const errMsg = error63 instanceof Error ? error63.message : String(error63);
|
|
@@ -129326,7 +129360,7 @@ function createAntigravityRoute(ports) {
|
|
|
129326
129360
|
quota: ports.quotaSource?.(),
|
|
129327
129361
|
rejected: false,
|
|
129328
129362
|
nowMs,
|
|
129329
|
-
model:
|
|
129363
|
+
model: translated.model
|
|
129330
129364
|
});
|
|
129331
129365
|
const stream = async function* () {
|
|
129332
129366
|
try {
|
|
@@ -129439,8 +129473,8 @@ function createAntigravityRouteMount(ports, upstreamBase, provider) {
|
|
|
129439
129473
|
request7.body.resume();
|
|
129440
129474
|
return;
|
|
129441
129475
|
}
|
|
129442
|
-
const
|
|
129443
|
-
const translated = { method: request7.method, path:
|
|
129476
|
+
const path61 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
129477
|
+
const translated = { method: request7.method, path: path61, body, signal: request7.signal };
|
|
129444
129478
|
const routed = await route(translated);
|
|
129445
129479
|
if (request7.signal.aborted) {
|
|
129446
129480
|
return;
|
|
@@ -129474,7 +129508,7 @@ function createPassthroughRoute(name, target) {
|
|
|
129474
129508
|
headroomUpstream: target.headroomUpstream,
|
|
129475
129509
|
serve: async (request7, response) => {
|
|
129476
129510
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
129477
|
-
const
|
|
129511
|
+
const path61 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
129478
129512
|
const headers = forwardableHeaders(request7.headers);
|
|
129479
129513
|
delete headers.host;
|
|
129480
129514
|
await new Promise((resolve2) => {
|
|
@@ -129482,7 +129516,7 @@ function createPassthroughRoute(name, target) {
|
|
|
129482
129516
|
host: base.hostname,
|
|
129483
129517
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
129484
129518
|
method: request7.method,
|
|
129485
|
-
path: `${basePath}${
|
|
129519
|
+
path: `${basePath}${path61}${incoming.search}`,
|
|
129486
129520
|
headers,
|
|
129487
129521
|
agent
|
|
129488
129522
|
};
|
|
@@ -129614,13 +129648,13 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
129614
129648
|
}
|
|
129615
129649
|
|
|
129616
129650
|
// src/frontdoor/providerRoute.ts
|
|
129617
|
-
var isRcSelfHostPath = (
|
|
129651
|
+
var isRcSelfHostPath = (path61) => path61 === "/v1/code/sessions" || path61.startsWith("/v1/code/sessions/") || path61 === "/v1/sessions" || path61.startsWith("/v1/sessions/");
|
|
129618
129652
|
function scopeSessionProviderPath(request7) {
|
|
129619
129653
|
if (request7.session.provider === void 0) {
|
|
129620
129654
|
return request7;
|
|
129621
129655
|
}
|
|
129622
|
-
const
|
|
129623
|
-
if (!
|
|
129656
|
+
const path61 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
129657
|
+
if (!path61.startsWith("/v1/") || isRcSelfHostPath(path61)) {
|
|
129624
129658
|
return request7;
|
|
129625
129659
|
}
|
|
129626
129660
|
return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
|
|
@@ -129663,13 +129697,13 @@ function createProviderRouteResolver(deps) {
|
|
|
129663
129697
|
return route;
|
|
129664
129698
|
};
|
|
129665
129699
|
const resolve2 = (request7) => {
|
|
129666
|
-
const
|
|
129667
|
-
const scoped = parseProviderPath(
|
|
129700
|
+
const path61 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
129701
|
+
const scoped = parseProviderPath(path61);
|
|
129668
129702
|
if (scoped === void 0) {
|
|
129669
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
129703
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path61)) {
|
|
129670
129704
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
129671
129705
|
}
|
|
129672
|
-
return
|
|
129706
|
+
return path61.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path61}` };
|
|
129673
129707
|
}
|
|
129674
129708
|
const { provider } = scoped;
|
|
129675
129709
|
let definition;
|
|
@@ -129755,8 +129789,8 @@ function createProviderRouteResolver(deps) {
|
|
|
129755
129789
|
let replay;
|
|
129756
129790
|
const visited = /* @__PURE__ */ new Set();
|
|
129757
129791
|
for (; ; ) {
|
|
129758
|
-
const
|
|
129759
|
-
const scoped = parseProviderPath(
|
|
129792
|
+
const path61 = new URL(current.url, "http://127.0.0.1").pathname;
|
|
129793
|
+
const scoped = parseProviderPath(path61);
|
|
129760
129794
|
const providerName = scoped?.provider ?? current.session.provider;
|
|
129761
129795
|
if (providerName !== void 0 && visited.has(providerName)) {
|
|
129762
129796
|
return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
|
|
@@ -129814,7 +129848,7 @@ function createProviderRouteResolver(deps) {
|
|
|
129814
129848
|
const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
129815
129849
|
replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
|
|
129816
129850
|
}
|
|
129817
|
-
const rest = scoped === void 0 ?
|
|
129851
|
+
const rest = scoped === void 0 ? path61 : path61.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
|
|
129818
129852
|
const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
129819
129853
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
|
|
129820
129854
|
}
|
|
@@ -129928,7 +129962,7 @@ init_account();
|
|
|
129928
129962
|
var RC_SELF_HOST_OAUTH_HOST = "platform.claude.com";
|
|
129929
129963
|
var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:claude_code", "user:mcp_servers", "user:file_upload"];
|
|
129930
129964
|
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
129931
|
-
var
|
|
129965
|
+
var MS_PER_SECOND11 = 1e3;
|
|
129932
129966
|
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
129933
129967
|
function isRecord12(value2) {
|
|
129934
129968
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
@@ -129984,7 +130018,7 @@ function createRcSelfHostLocal(deps) {
|
|
|
129984
130018
|
}
|
|
129985
130019
|
if (method === "POST" && pathname.startsWith("/api/eval/")) {
|
|
129986
130020
|
await deps.readBody(request7, CONTROL_BODY_CAP_BYTES);
|
|
129987
|
-
answerServerJson(response, HTTP_STATUS.ok, { features: growthBookFeatures(), dateUpdated: Math.floor(deps.now() /
|
|
130021
|
+
answerServerJson(response, HTTP_STATUS.ok, { features: growthBookFeatures(), dateUpdated: Math.floor(deps.now() / MS_PER_SECOND11) });
|
|
129988
130022
|
return true;
|
|
129989
130023
|
}
|
|
129990
130024
|
if (method === "GET" && pathname === "/api/oauth/profile") {
|
|
@@ -130168,12 +130202,12 @@ function eventExcerpt(text2) {
|
|
|
130168
130202
|
return text2.length <= RC_PENDING_SUMMARY_EXCERPT_CHARS ? text2 : `${text2.slice(0, RC_PENDING_SUMMARY_EXCERPT_CHARS)}...`;
|
|
130169
130203
|
}
|
|
130170
130204
|
var PERCENT_SCALE = 100;
|
|
130171
|
-
var
|
|
130205
|
+
var MS_PER_SECOND12 = 1e3;
|
|
130172
130206
|
function percentOf(fraction) {
|
|
130173
130207
|
return `${String(Math.round(fraction * PERCENT_SCALE))}%`;
|
|
130174
130208
|
}
|
|
130175
130209
|
function resetInstantOf(epochSeconds) {
|
|
130176
|
-
return new Date(epochSeconds *
|
|
130210
|
+
return new Date(epochSeconds * MS_PER_SECOND12).toISOString();
|
|
130177
130211
|
}
|
|
130178
130212
|
function formatRcRateLimitInfo(info) {
|
|
130179
130213
|
const parts = [info.status];
|
|
@@ -131608,7 +131642,7 @@ var RC_COMPAT_SESSIONS_PATH = "/v1/sessions";
|
|
|
131608
131642
|
var RC_SESSION_ID_PREFIX2 = "cse_";
|
|
131609
131643
|
var RC_SELF_HOST_API_BASE_URL = "https://api.anthropic.com";
|
|
131610
131644
|
var HTTP_CONFLICT = 409;
|
|
131611
|
-
var
|
|
131645
|
+
var MS_PER_SECOND13 = 1e3;
|
|
131612
131646
|
var HTTP_SERVICE_UNAVAILABLE2 = 503;
|
|
131613
131647
|
var RC_SELF_HOST_WORKER_JWT_TTL_SECONDS = 46800;
|
|
131614
131648
|
var RC_SELF_HOST_KEEPALIVE_MS = 15e3;
|
|
@@ -131708,7 +131742,7 @@ function parseJsonObject5(body) {
|
|
|
131708
131742
|
function mintWorkerJwt(randomToken, issuedAt) {
|
|
131709
131743
|
const encode3 = (value2) => Buffer.from(JSON.stringify(value2), "utf8").toString("base64url");
|
|
131710
131744
|
const header = encode3({ alg: "HS256", typ: "JWT" });
|
|
131711
|
-
const payload = encode3({ exp: Math.floor((issuedAt + RC_SELF_HOST_WORKER_JWT_TTL_SECONDS *
|
|
131745
|
+
const payload = encode3({ exp: Math.floor((issuedAt + RC_SELF_HOST_WORKER_JWT_TTL_SECONDS * MS_PER_SECOND13) / MS_PER_SECOND13), iat: Math.floor(issuedAt / MS_PER_SECOND13) });
|
|
131712
131746
|
return `${header}.${payload}.${Buffer.from(randomToken(), "utf8").toString("base64url")}`;
|
|
131713
131747
|
}
|
|
131714
131748
|
function createRcSelfHostSurface(deps) {
|
|
@@ -133269,13 +133303,111 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
133269
133303
|
|
|
133270
133304
|
// src/statusline/commands.ts
|
|
133271
133305
|
var import_node_child_process7 = require("node:child_process");
|
|
133306
|
+
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
133307
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
133272
133308
|
init_commandDeps();
|
|
133309
|
+
init_providersStore();
|
|
133273
133310
|
init_realPorts();
|
|
133274
133311
|
init_account();
|
|
133275
133312
|
init_read();
|
|
133276
133313
|
|
|
133314
|
+
// src/statusline/client.ts
|
|
133315
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
133316
|
+
function isAntigravityPayload(payload) {
|
|
133317
|
+
return typeof payload === "object" && payload !== null && "product" in payload && payload.product === "antigravity";
|
|
133318
|
+
}
|
|
133319
|
+
var ANTIGRAVITY_SETTINGS_SEGMENTS = [".gemini", "antigravity-cli", "settings.json"];
|
|
133320
|
+
function antigravityStacksWithDefault(fs24, homeDir) {
|
|
133321
|
+
const raw = fs24.readFileUtf8(import_node_path52.default.join(homeDir, ...ANTIGRAVITY_SETTINGS_SEGMENTS));
|
|
133322
|
+
if (raw === void 0) {
|
|
133323
|
+
return false;
|
|
133324
|
+
}
|
|
133325
|
+
const settings2 = JSON.parse(raw);
|
|
133326
|
+
if (typeof settings2 !== "object" || settings2 === null || !("statusLine" in settings2)) {
|
|
133327
|
+
return false;
|
|
133328
|
+
}
|
|
133329
|
+
const statusLine = settings2.statusLine;
|
|
133330
|
+
return typeof statusLine === "object" && statusLine !== null && "stack_with_default" in statusLine && statusLine.stack_with_default === true;
|
|
133331
|
+
}
|
|
133332
|
+
|
|
133333
|
+
// src/statusline/headroom.ts
|
|
133334
|
+
var import_node_http4 = __toESM(require("node:http"), 1);
|
|
133335
|
+
init_zod();
|
|
133336
|
+
var HEADROOM_TIMEOUT_MS = 500;
|
|
133337
|
+
var HTTP_OK2 = 200;
|
|
133338
|
+
var SessionRowSchema = external_exports.object({
|
|
133339
|
+
tokens_saved: external_exports.number().nonnegative().optional(),
|
|
133340
|
+
savings_percent: external_exports.number().nonnegative().optional(),
|
|
133341
|
+
compression_savings_usd: external_exports.number().nonnegative().optional()
|
|
133342
|
+
});
|
|
133343
|
+
function headroomSessionIdOf(payload, env) {
|
|
133344
|
+
if (typeof payload === "object" && payload !== null && "session_id" in payload && typeof payload.session_id === "string" && payload.session_id.trim() !== "") {
|
|
133345
|
+
return payload.session_id.trim();
|
|
133346
|
+
}
|
|
133347
|
+
for (const line of (env.ANTHROPIC_CUSTOM_HEADERS ?? "").split("\n")) {
|
|
133348
|
+
const separator = line.indexOf(":");
|
|
133349
|
+
if (separator !== -1 && line.slice(0, separator).trim().toLowerCase() === "x-agent-shim-session" && line.slice(separator + 1).trim() !== "") {
|
|
133350
|
+
return line.slice(separator + 1).trim();
|
|
133351
|
+
}
|
|
133352
|
+
}
|
|
133353
|
+
return void 0;
|
|
133354
|
+
}
|
|
133355
|
+
function headroomTargetOf(env, supervisedSocketPath) {
|
|
133356
|
+
const url2 = env.HEADROOM_PROXY_URL?.trim();
|
|
133357
|
+
if (url2 !== void 0 && url2 !== "") {
|
|
133358
|
+
return { kind: "http", baseUrl: url2.replace(/\/+$/, "") };
|
|
133359
|
+
}
|
|
133360
|
+
return supervisedSocketPath === void 0 ? void 0 : { kind: "socket", socketPath: supervisedSocketPath };
|
|
133361
|
+
}
|
|
133362
|
+
async function fetchHeadroomSessionStats(get3, target, sessionId) {
|
|
133363
|
+
let response;
|
|
133364
|
+
try {
|
|
133365
|
+
response = await get3(target, `/stats/sessions/${encodeURIComponent(sessionId)}`, HEADROOM_TIMEOUT_MS);
|
|
133366
|
+
} catch {
|
|
133367
|
+
return void 0;
|
|
133368
|
+
}
|
|
133369
|
+
if (response.status !== HTTP_OK2) {
|
|
133370
|
+
return void 0;
|
|
133371
|
+
}
|
|
133372
|
+
let body;
|
|
133373
|
+
try {
|
|
133374
|
+
body = JSON.parse(response.text);
|
|
133375
|
+
} catch {
|
|
133376
|
+
return void 0;
|
|
133377
|
+
}
|
|
133378
|
+
const row = SessionRowSchema.safeParse(body);
|
|
133379
|
+
if (!row.success) {
|
|
133380
|
+
return void 0;
|
|
133381
|
+
}
|
|
133382
|
+
const stats = { tokensSaved: row.data.tokens_saved, savingsPercent: row.data.savings_percent, savingsUsd: row.data.compression_savings_usd };
|
|
133383
|
+
return stats.tokensSaved === void 0 && stats.savingsPercent === void 0 && stats.savingsUsd === void 0 ? void 0 : stats;
|
|
133384
|
+
}
|
|
133385
|
+
var realHeadroomGet = async (target, requestPath, timeoutMs) => {
|
|
133386
|
+
if (target.kind === "http") {
|
|
133387
|
+
const response = await fetch(`${target.baseUrl}${requestPath}`, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(timeoutMs) });
|
|
133388
|
+
return { status: response.status, text: await response.text() };
|
|
133389
|
+
}
|
|
133390
|
+
return await new Promise((resolve2, reject) => {
|
|
133391
|
+
const request7 = import_node_http4.default.request({ socketPath: target.socketPath, path: requestPath, method: "GET", headers: { accept: "application/json", host: "localhost" }, timeout: timeoutMs }, (response) => {
|
|
133392
|
+
const chunks = [];
|
|
133393
|
+
response.on("data", (chunk) => {
|
|
133394
|
+
chunks.push(chunk);
|
|
133395
|
+
});
|
|
133396
|
+
response.on("end", () => {
|
|
133397
|
+
resolve2({ status: response.statusCode ?? 0, text: Buffer.concat(chunks).toString("utf8") });
|
|
133398
|
+
});
|
|
133399
|
+
});
|
|
133400
|
+
request7.on("timeout", () => {
|
|
133401
|
+
request7.destroy(new Error("headroom lookup timed out"));
|
|
133402
|
+
});
|
|
133403
|
+
request7.on("error", reject);
|
|
133404
|
+
request7.end();
|
|
133405
|
+
});
|
|
133406
|
+
};
|
|
133407
|
+
|
|
133277
133408
|
// src/statusline/enrich.ts
|
|
133278
133409
|
var FULL_PERCENT = 100;
|
|
133410
|
+
var MS_PER_SECOND14 = 1e3;
|
|
133279
133411
|
function identityOf(env) {
|
|
133280
133412
|
const headers = env.ANTHROPIC_CUSTOM_HEADERS;
|
|
133281
133413
|
if (headers !== void 0) {
|
|
@@ -133321,38 +133453,89 @@ function windowsOf(states) {
|
|
|
133321
133453
|
}
|
|
133322
133454
|
return { fiveHourUsed, fiveHourResetAt, sevenDayUsed, sevenDayResetAt };
|
|
133323
133455
|
}
|
|
133456
|
+
function isObject4(value2) {
|
|
133457
|
+
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
133458
|
+
}
|
|
133459
|
+
function payloadWindow(rateLimits, key) {
|
|
133460
|
+
const window = rateLimits[key];
|
|
133461
|
+
if (!isObject4(window) || typeof window.used_percentage !== "number" || !Number.isFinite(window.used_percentage)) {
|
|
133462
|
+
return void 0;
|
|
133463
|
+
}
|
|
133464
|
+
const resetsAt = window.resets_at;
|
|
133465
|
+
return {
|
|
133466
|
+
used: Math.min(FULL_PERCENT, Math.max(0, window.used_percentage)),
|
|
133467
|
+
resetAt: typeof resetsAt === "number" && Number.isFinite(resetsAt) ? new Date(resetsAt * MS_PER_SECOND14).toISOString() : void 0
|
|
133468
|
+
};
|
|
133469
|
+
}
|
|
133470
|
+
function payloadWindowsOf(payload) {
|
|
133471
|
+
const rateLimits = isObject4(payload) ? payload.rate_limits : void 0;
|
|
133472
|
+
const five = isObject4(rateLimits) ? payloadWindow(rateLimits, "five_hour") : void 0;
|
|
133473
|
+
const seven = isObject4(rateLimits) ? payloadWindow(rateLimits, "seven_day") : void 0;
|
|
133474
|
+
return { fiveHourUsed: five?.used, fiveHourResetAt: five?.resetAt, sevenDayUsed: seven?.used, sevenDayResetAt: seven?.resetAt };
|
|
133475
|
+
}
|
|
133476
|
+
function antigravityWindowsOf(payload, nowMs) {
|
|
133477
|
+
const quota = isObject4(payload) ? payload.quota : void 0;
|
|
133478
|
+
if (!isObject4(quota)) {
|
|
133479
|
+
return { fiveHourUsed: void 0, fiveHourResetAt: void 0, sevenDayUsed: void 0, sevenDayResetAt: void 0 };
|
|
133480
|
+
}
|
|
133481
|
+
const model = isObject4(payload) && isObject4(payload.model) && typeof payload.model.id === "string" ? payload.model.id : void 0;
|
|
133482
|
+
const buckets = Object.fromEntries(
|
|
133483
|
+
Object.entries(quota).flatMap(([key, bucket]) => {
|
|
133484
|
+
if (!isObject4(bucket)) {
|
|
133485
|
+
return [];
|
|
133486
|
+
}
|
|
133487
|
+
const remaining = bucket.remaining_fraction;
|
|
133488
|
+
const resetIn = bucket.reset_in_seconds;
|
|
133489
|
+
return [[key, { ...typeof remaining === "number" ? { remaining_fraction: remaining } : {}, ...typeof resetIn === "number" ? { reset_in_seconds: resetIn } : {} }]];
|
|
133490
|
+
})
|
|
133491
|
+
);
|
|
133492
|
+
const { fiveHour, weekly } = selectAntigravityBuckets(buckets, model);
|
|
133493
|
+
const windowOf2 = (bucket) => ({
|
|
133494
|
+
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,
|
|
133495
|
+
resetAt: bucket?.reset_in_seconds === void 0 || !Number.isFinite(bucket.reset_in_seconds) ? void 0 : new Date(nowMs + bucket.reset_in_seconds * MS_PER_SECOND14).toISOString()
|
|
133496
|
+
});
|
|
133497
|
+
const five = windowOf2(fiveHour);
|
|
133498
|
+
const seven = windowOf2(weekly);
|
|
133499
|
+
return { fiveHourUsed: five.used, fiveHourResetAt: five.resetAt, sevenDayUsed: seven.used, sevenDayResetAt: seven.resetAt };
|
|
133500
|
+
}
|
|
133324
133501
|
function enrichStatuslinePayload(params) {
|
|
133325
133502
|
const identity = identityOf(params.env);
|
|
133503
|
+
const clientEmail = isObject4(params.payload) && typeof params.payload.email === "string" && params.payload.email !== "" ? params.payload.email : void 0;
|
|
133504
|
+
const clientPlan = clientEmail !== void 0 && isObject4(params.payload) && typeof params.payload.plan_tier === "string" && params.payload.plan_tier !== "" ? params.payload.plan_tier : void 0;
|
|
133505
|
+
const account = clientEmail === void 0 ? params.account : void 0;
|
|
133326
133506
|
let summary = {
|
|
133327
133507
|
identity,
|
|
133328
133508
|
provider: params.env.AGENT_SHIM_PROVIDER === void 0 || params.env.AGENT_SHIM_PROVIDER === "" ? void 0 : params.env.AGENT_SHIM_PROVIDER,
|
|
133329
133509
|
providerAccountEmail: void 0,
|
|
133330
133510
|
providerAccountSub: void 0,
|
|
133331
133511
|
providerPlan: void 0,
|
|
133332
|
-
loginAccountEmail:
|
|
133333
|
-
|
|
133334
|
-
|
|
133335
|
-
|
|
133336
|
-
|
|
133512
|
+
loginAccountEmail: clientEmail ?? account?.emailAddress,
|
|
133513
|
+
loginPlan: clientPlan,
|
|
133514
|
+
loginRateLimitTier: account?.userRateLimitTier ?? account?.organizationRateLimitTier,
|
|
133515
|
+
loginOrganizationName: account?.organizationName,
|
|
133516
|
+
loginOrganizationType: account?.organizationType,
|
|
133517
|
+
loginSeatTier: account?.seatTier === "none" ? void 0 : account?.seatTier,
|
|
133337
133518
|
fiveHourUsed: void 0,
|
|
133338
133519
|
fiveHourResetAt: void 0,
|
|
133339
133520
|
sevenDayUsed: void 0,
|
|
133340
|
-
sevenDayResetAt: void 0
|
|
133521
|
+
sevenDayResetAt: void 0,
|
|
133522
|
+
providerQuotaWindows: [],
|
|
133523
|
+
headroom: params.headroom
|
|
133341
133524
|
};
|
|
133342
133525
|
if (params.snapshot !== void 0) {
|
|
133343
|
-
const scopedName = providerScopedState(params.snapshot, params.env.AGENT_SHIM_PROVIDER);
|
|
133526
|
+
const scopedName = providerScopedState(params.snapshot, params.providerName, params.env.AGENT_SHIM_PROVIDER);
|
|
133344
133527
|
const scopedState = scopedName === void 0 ? void 0 : params.snapshot.providers[scopedName];
|
|
133345
|
-
const states =
|
|
133528
|
+
const states = summary.provider === void 0 ? Object.values(params.snapshot.providers) : scopedState === void 0 ? [] : [scopedState];
|
|
133346
133529
|
let email3;
|
|
133347
133530
|
let sub;
|
|
133348
133531
|
let plan;
|
|
133349
133532
|
for (const state of states) {
|
|
133350
|
-
const
|
|
133351
|
-
const candidateEmail =
|
|
133533
|
+
const providerAccount = state.quota?.account;
|
|
133534
|
+
const candidateEmail = providerAccount?.email;
|
|
133352
133535
|
if (email3 === void 0 && typeof candidateEmail === "string" && candidateEmail !== "") {
|
|
133353
133536
|
email3 = candidateEmail;
|
|
133354
133537
|
}
|
|
133355
|
-
const candidateSub =
|
|
133538
|
+
const candidateSub = providerAccount?.accountId;
|
|
133356
133539
|
if (sub === void 0 && typeof candidateSub === "string" && candidateSub !== "") {
|
|
133357
133540
|
sub = candidateSub;
|
|
133358
133541
|
}
|
|
@@ -133361,7 +133544,17 @@ function enrichStatuslinePayload(params) {
|
|
|
133361
133544
|
plan = candidatePlan;
|
|
133362
133545
|
}
|
|
133363
133546
|
}
|
|
133364
|
-
|
|
133547
|
+
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 }));
|
|
133548
|
+
summary = { ...summary, ...windowsOf(states), providerAccountEmail: email3, providerAccountSub: sub, providerPlan: plan, providerQuotaWindows };
|
|
133549
|
+
}
|
|
133550
|
+
if (summary.provider === void 0) {
|
|
133551
|
+
for (const own2 of [antigravityWindowsOf(params.payload, params.nowMs), payloadWindowsOf(params.payload)]) {
|
|
133552
|
+
summary = {
|
|
133553
|
+
...summary,
|
|
133554
|
+
...own2.fiveHourUsed === void 0 ? {} : { fiveHourUsed: own2.fiveHourUsed, fiveHourResetAt: own2.fiveHourResetAt },
|
|
133555
|
+
...own2.sevenDayUsed === void 0 ? {} : { sevenDayUsed: own2.sevenDayUsed, sevenDayResetAt: own2.sevenDayResetAt }
|
|
133556
|
+
};
|
|
133557
|
+
}
|
|
133365
133558
|
}
|
|
133366
133559
|
if (typeof params.payload !== "object" || params.payload === null || Array.isArray(params.payload)) {
|
|
133367
133560
|
return { payload: params.payload, summary };
|
|
@@ -133372,7 +133565,10 @@ function enrichStatuslinePayload(params) {
|
|
|
133372
133565
|
}
|
|
133373
133566
|
return { payload: enriched, summary };
|
|
133374
133567
|
}
|
|
133375
|
-
function providerScopedState(snapshot, providerDisplayName) {
|
|
133568
|
+
function providerScopedState(snapshot, providerName, providerDisplayName) {
|
|
133569
|
+
if (providerName !== void 0 && providerName in snapshot.providers) {
|
|
133570
|
+
return providerName;
|
|
133571
|
+
}
|
|
133376
133572
|
if (providerDisplayName === void 0 || providerDisplayName === "") {
|
|
133377
133573
|
return void 0;
|
|
133378
133574
|
}
|
|
@@ -133397,6 +133593,7 @@ var TWENTY = 20;
|
|
|
133397
133593
|
var RESERVED_COLUMNS = 4;
|
|
133398
133594
|
var SEPARATOR2 = " | ";
|
|
133399
133595
|
var FULL_PERCENT2 = 100;
|
|
133596
|
+
var ONE_PERCENT = 1;
|
|
133400
133597
|
var USED_RED_AT = 0.9;
|
|
133401
133598
|
var USED_YELLOW_AT = 0.7;
|
|
133402
133599
|
var ESCAPE_CHAR_CODE = 27;
|
|
@@ -133454,14 +133651,30 @@ function formatDuration(seconds) {
|
|
|
133454
133651
|
}
|
|
133455
133652
|
return `${String(minutes)}m`;
|
|
133456
133653
|
}
|
|
133654
|
+
function headroomText(stats) {
|
|
133655
|
+
if (stats === void 0) {
|
|
133656
|
+
return void 0;
|
|
133657
|
+
}
|
|
133658
|
+
const overall = stats.savingsPercent === void 0 ? void 0 : `${stats.savingsPercent.toFixed(stats.savingsPercent < ONE_PERCENT ? 2 : 1)}% overall`;
|
|
133659
|
+
const parts = [
|
|
133660
|
+
stats.tokensSaved === void 0 ? void 0 : `${formatTokens(stats.tokensSaved)} saved`,
|
|
133661
|
+
overall,
|
|
133662
|
+
stats.savingsUsd === void 0 ? void 0 : `$${stats.savingsUsd.toFixed(2)}`
|
|
133663
|
+
].filter((part) => part !== void 0);
|
|
133664
|
+
return parts.length === 0 ? void 0 : `headroom ${parts.join(" \xB7 ")}`;
|
|
133665
|
+
}
|
|
133666
|
+
function cacheHitText(hitFraction) {
|
|
133667
|
+
const clamped = Math.max(0, Math.min(1, hitFraction));
|
|
133668
|
+
return ` (Cache: ${statusColor(clamped, false)}${(clamped * FULL_PERCENT2).toFixed(0)}%${RESET})`;
|
|
133669
|
+
}
|
|
133457
133670
|
function cacheShareText(view) {
|
|
133458
133671
|
const hitRatio = view.cacheHitRatio;
|
|
133459
133672
|
if (hitRatio !== void 0 && Number.isFinite(hitRatio)) {
|
|
133460
|
-
return
|
|
133673
|
+
return cacheHitText(hitRatio);
|
|
133461
133674
|
}
|
|
133462
133675
|
const promptTotal = (view.cacheReadTokens ?? 0) + (view.freshInputTokens ?? 0);
|
|
133463
133676
|
if (promptTotal > 0 && (view.cacheReadTokens ?? 0) > 0) {
|
|
133464
|
-
return
|
|
133677
|
+
return cacheHitText((view.cacheReadTokens ?? 0) / promptTotal);
|
|
133465
133678
|
}
|
|
133466
133679
|
return "";
|
|
133467
133680
|
}
|
|
@@ -133653,7 +133866,7 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
|
|
|
133653
133866
|
const account = [summary.providerAccountEmail, summary.providerPlan].filter((part) => part !== void 0);
|
|
133654
133867
|
header.push(new Segment("static", account.length > 0 ? `${summary.provider} \xB7 ${account.join(" \xB7 ")}` : summary.provider));
|
|
133655
133868
|
}
|
|
133656
|
-
const loginPlan = summary.provider === void 0 ? accountPlanLabel(summary) : void 0;
|
|
133869
|
+
const loginPlan = summary.provider === void 0 ? summary.loginPlan ?? accountPlanLabel(summary) : void 0;
|
|
133657
133870
|
const loginOrgName = summary.loginOrganizationType === "claude_team" || summary.loginOrganizationType === "claude_enterprise" ? summary.loginOrganizationName : void 0;
|
|
133658
133871
|
const loginParts = [summary.loginAccountEmail, loginOrgName, loginPlan].filter((part) => part !== void 0);
|
|
133659
133872
|
if (summary.loginAccountEmail !== void 0 && summary.loginAccountEmail !== summary.providerAccountEmail) {
|
|
@@ -133664,6 +133877,10 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
|
|
|
133664
133877
|
if (summary.identity !== void 0 && summary.provider !== void 0 && summary.identity !== summary.providerAccountEmail && summary.identity !== summary.loginAccountEmail) {
|
|
133665
133878
|
header.push(new Segment("static", summary.identity));
|
|
133666
133879
|
}
|
|
133880
|
+
const savings = headroomText(summary.headroom);
|
|
133881
|
+
if (savings !== void 0) {
|
|
133882
|
+
header.push(new Segment("static", savings));
|
|
133883
|
+
}
|
|
133667
133884
|
const contextGroup = [];
|
|
133668
133885
|
if (view.contextUsedPercentage !== void 0) {
|
|
133669
133886
|
const fraction = Math.max(0, Math.min(1, view.contextUsedPercentage / FULL_PERCENT2));
|
|
@@ -133684,6 +133901,14 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
|
|
|
133684
133901
|
const color = statusColor(fraction, true);
|
|
133685
133902
|
quotaGroup.push(new Segment("bar", "", "Wk ", ` ${color}${summary.sevenDayUsed.toFixed(1)}%${RESET} (${formatDuration(secondsUntil(summary.sevenDayResetAt, nowMs))})`, fraction, true));
|
|
133686
133903
|
}
|
|
133904
|
+
if (summary.fiveHourUsed === void 0 && summary.sevenDayUsed === void 0) {
|
|
133905
|
+
for (const window of summary.providerQuotaWindows) {
|
|
133906
|
+
const used = window.utilization * FULL_PERCENT2;
|
|
133907
|
+
const fraction = Math.max(0, Math.min(1, window.utilization));
|
|
133908
|
+
const color = statusColor(fraction, true);
|
|
133909
|
+
quotaGroup.push(new Segment("bar", "", `${window.measures} `, ` ${color}${used.toFixed(1)}%${RESET} (${formatDuration(secondsUntil(window.resetsAt, nowMs))})`, fraction, true));
|
|
133910
|
+
}
|
|
133911
|
+
}
|
|
133687
133912
|
const width = Math.max(TWENTY, terminalWidth - RESERVED_COLUMNS);
|
|
133688
133913
|
const lines = [];
|
|
133689
133914
|
if (header.length > 0) {
|
|
@@ -133696,6 +133921,16 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
|
|
|
133696
133921
|
return lines.join("\n");
|
|
133697
133922
|
}
|
|
133698
133923
|
|
|
133924
|
+
// src/statusline/width.ts
|
|
133925
|
+
var DEFAULT_COLUMNS = 80;
|
|
133926
|
+
function terminalWidthOf(payload, env) {
|
|
133927
|
+
if (typeof payload === "object" && payload !== null && "terminal_width" in payload && typeof payload.terminal_width === "number" && Number.isFinite(payload.terminal_width) && payload.terminal_width > 0) {
|
|
133928
|
+
return Math.floor(payload.terminal_width);
|
|
133929
|
+
}
|
|
133930
|
+
const columns = Number.parseInt(env.COLUMNS ?? "", 10);
|
|
133931
|
+
return Number.isFinite(columns) && columns > 0 ? columns : DEFAULT_COLUMNS;
|
|
133932
|
+
}
|
|
133933
|
+
|
|
133699
133934
|
// src/statusline/commands.ts
|
|
133700
133935
|
function payloadViewOf(payload) {
|
|
133701
133936
|
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 +133968,6 @@ async function readAllStdin() {
|
|
|
133733
133968
|
process.stdin.resume();
|
|
133734
133969
|
});
|
|
133735
133970
|
}
|
|
133736
|
-
var DEFAULT_COLUMNS = 80;
|
|
133737
133971
|
function registerStatuslineCommand(program2, deps) {
|
|
133738
133972
|
withExamples(
|
|
133739
133973
|
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 +133992,29 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
133758
133992
|
} catch {
|
|
133759
133993
|
account = void 0;
|
|
133760
133994
|
}
|
|
133995
|
+
} else {
|
|
133996
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR;
|
|
133997
|
+
try {
|
|
133998
|
+
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"));
|
|
133999
|
+
} catch {
|
|
134000
|
+
account = void 0;
|
|
134001
|
+
}
|
|
134002
|
+
}
|
|
134003
|
+
const displayName = process.env.AGENT_SHIM_PROVIDER;
|
|
134004
|
+
let providerName;
|
|
134005
|
+
if (displayName !== void 0 && displayName !== "") {
|
|
134006
|
+
try {
|
|
134007
|
+
providerName = listProviders(deps.paths).find((entry) => entry.provider.displayName === displayName)?.name;
|
|
134008
|
+
} catch {
|
|
134009
|
+
providerName = void 0;
|
|
134010
|
+
}
|
|
133761
134011
|
}
|
|
133762
|
-
const
|
|
134012
|
+
const nowMs = Date.now();
|
|
134013
|
+
const socketTarget = headroomSocketTarget(realFarmFs, realHeadroomSocketTrust, deps.paths);
|
|
134014
|
+
const target = headroomTargetOf(process.env, socketTarget === void 0 || socketTarget.refused !== void 0 ? void 0 : socketTarget.socketPath);
|
|
134015
|
+
const sessionId = headroomSessionIdOf(payload, process.env);
|
|
134016
|
+
const headroom = target === void 0 || sessionId === void 0 ? void 0 : await fetchHeadroomSessionStats(realHeadroomGet, target, sessionId);
|
|
134017
|
+
const { payload: enriched, summary } = enrichStatuslinePayload({ payload, env: process.env, snapshot, account, providerName, nowMs, headroom });
|
|
133763
134018
|
const renderer = process.env.AGENT_SHIM_STATUSLINE_CMD;
|
|
133764
134019
|
if (renderer !== void 0 && renderer !== "") {
|
|
133765
134020
|
const child = (0, import_node_child_process7.spawn)("/bin/sh", ["-c", renderer], { stdio: ["pipe", "inherit", "inherit"] });
|
|
@@ -133770,9 +134025,16 @@ function registerStatuslineCommand(program2, deps) {
|
|
|
133770
134025
|
});
|
|
133771
134026
|
return;
|
|
133772
134027
|
}
|
|
133773
|
-
|
|
133774
|
-
|
|
133775
|
-
|
|
134028
|
+
let stackedUnderDefault = false;
|
|
134029
|
+
if (isAntigravityPayload(payload)) {
|
|
134030
|
+
try {
|
|
134031
|
+
stackedUnderDefault = antigravityStacksWithDefault(realFarmFs, import_node_os12.default.homedir());
|
|
134032
|
+
} catch {
|
|
134033
|
+
stackedUnderDefault = false;
|
|
134034
|
+
}
|
|
134035
|
+
}
|
|
134036
|
+
const view = { ...payloadViewOf(payload), ...stackedUnderDefault ? { modelDisplayName: void 0 } : {} };
|
|
134037
|
+
console.log(renderStatuslineBlock(summary, view, terminalWidthOf(payload, process.env), nowMs));
|
|
133776
134038
|
}),
|
|
133777
134039
|
["$ agent-shim statusline # a client's statusline setting names this; it renders or delegates"]
|
|
133778
134040
|
);
|
|
@@ -135796,8 +136058,8 @@ function getErrorMap2() {
|
|
|
135796
136058
|
|
|
135797
136059
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/helpers/parseUtil.js
|
|
135798
136060
|
var makeIssue = (params) => {
|
|
135799
|
-
const { data, path:
|
|
135800
|
-
const fullPath = [...
|
|
136061
|
+
const { data, path: path61, errorMaps, issueData } = params;
|
|
136062
|
+
const fullPath = [...path61, ...issueData.path || []];
|
|
135801
136063
|
const fullIssue = {
|
|
135802
136064
|
...issueData,
|
|
135803
136065
|
path: fullPath
|
|
@@ -135912,11 +136174,11 @@ var errorUtil;
|
|
|
135912
136174
|
|
|
135913
136175
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/types.js
|
|
135914
136176
|
var ParseInputLazyPath = class {
|
|
135915
|
-
constructor(parent, value2,
|
|
136177
|
+
constructor(parent, value2, path61, key) {
|
|
135916
136178
|
this._cachedPath = [];
|
|
135917
136179
|
this.parent = parent;
|
|
135918
136180
|
this.data = value2;
|
|
135919
|
-
this._path =
|
|
136181
|
+
this._path = path61;
|
|
135920
136182
|
this._key = key;
|
|
135921
136183
|
}
|
|
135922
136184
|
get path() {
|
|
@@ -139479,11 +139741,11 @@ function normalizeObjectSchema(schema) {
|
|
|
139479
139741
|
}
|
|
139480
139742
|
return void 0;
|
|
139481
139743
|
}
|
|
139482
|
-
function getDotPath(
|
|
139483
|
-
if (
|
|
139744
|
+
function getDotPath(path61) {
|
|
139745
|
+
if (path61.length === 0) {
|
|
139484
139746
|
return "object root";
|
|
139485
139747
|
}
|
|
139486
|
-
return
|
|
139748
|
+
return path61.reduce((acc, seg, index) => {
|
|
139487
139749
|
if (index === 0) {
|
|
139488
139750
|
return String(seg);
|
|
139489
139751
|
}
|
|
@@ -143526,7 +143788,7 @@ async function serveMcp(mcp, transport, options = {}) {
|
|
|
143526
143788
|
|
|
143527
143789
|
// src/mcp/permissions.ts
|
|
143528
143790
|
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
143529
|
-
var
|
|
143791
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
143530
143792
|
init_zod();
|
|
143531
143793
|
init_store();
|
|
143532
143794
|
var StoredMcpPermissionsSchema = external_exports.strictObject({
|
|
@@ -143548,10 +143810,10 @@ function effectiveMcpPermissions(flags, stored) {
|
|
|
143548
143810
|
return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl, history: flags.history || stored.history };
|
|
143549
143811
|
}
|
|
143550
143812
|
function watchMcpPermissions(paths, onChange) {
|
|
143551
|
-
const directory =
|
|
143813
|
+
const directory = import_node_path54.default.dirname(paths.mcpPermissionsFile);
|
|
143552
143814
|
import_node_fs20.default.mkdirSync(directory, { recursive: true });
|
|
143553
143815
|
const watcher = import_node_fs20.default.watch(directory, (_event, filename) => {
|
|
143554
|
-
if (filename === null || filename ===
|
|
143816
|
+
if (filename === null || filename === import_node_path54.default.basename(paths.mcpPermissionsFile)) {
|
|
143555
143817
|
onChange();
|
|
143556
143818
|
}
|
|
143557
143819
|
});
|
|
@@ -143864,16 +144126,16 @@ init_credentialCache();
|
|
|
143864
144126
|
|
|
143865
144127
|
// src/identityToken.ts
|
|
143866
144128
|
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
143867
|
-
var
|
|
144129
|
+
var import_node_path55 = __toESM(require("node:path"), 1);
|
|
143868
144130
|
init_cliError();
|
|
143869
144131
|
var TOKEN_FILE_MODE = 384;
|
|
143870
144132
|
var TOKEN_DIR_MODE = 448;
|
|
143871
144133
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
143872
144134
|
function identityTokenDir(paths) {
|
|
143873
|
-
return
|
|
144135
|
+
return import_node_path55.default.join(paths.root, "credentials");
|
|
143874
144136
|
}
|
|
143875
144137
|
function identityTokenPath(paths, identityName) {
|
|
143876
|
-
return
|
|
144138
|
+
return import_node_path55.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
143877
144139
|
}
|
|
143878
144140
|
function storeIdentityToken(paths, identityName, raw) {
|
|
143879
144141
|
const token = raw.trim();
|
|
@@ -143884,7 +144146,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
143884
144146
|
import_node_fs21.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
143885
144147
|
import_node_fs21.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
143886
144148
|
const target = identityTokenPath(paths, identityName);
|
|
143887
|
-
const temp =
|
|
144149
|
+
const temp = import_node_path55.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
143888
144150
|
import_node_fs21.default.writeFileSync(temp, `${token}
|
|
143889
144151
|
`, { mode: TOKEN_FILE_MODE });
|
|
143890
144152
|
import_node_fs21.default.renameSync(temp, target);
|
|
@@ -144051,8 +144313,8 @@ function registerDoctorCommand(program2, deps) {
|
|
|
144051
144313
|
|
|
144052
144314
|
// src/headroom/commands.ts
|
|
144053
144315
|
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
144054
|
-
var
|
|
144055
|
-
var
|
|
144316
|
+
var import_node_http5 = __toESM(require("node:http"), 1);
|
|
144317
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
144056
144318
|
var import_node_child_process9 = require("node:child_process");
|
|
144057
144319
|
init_commandDeps();
|
|
144058
144320
|
init_realFrontDoorPort();
|
|
@@ -144223,7 +144485,7 @@ function headroomProxyArgs(socketPath, allowlistFile, settings2) {
|
|
|
144223
144485
|
}
|
|
144224
144486
|
async function readyOverSocket(socketPath) {
|
|
144225
144487
|
return await new Promise((resolve2) => {
|
|
144226
|
-
const probe =
|
|
144488
|
+
const probe = import_node_http5.default.get({ socketPath, path: "/readyz", timeout: READY_FETCH_TIMEOUT_MS }, (response) => {
|
|
144227
144489
|
response.resume();
|
|
144228
144490
|
resolve2(response.statusCode === HTTP_STATUS.ok);
|
|
144229
144491
|
});
|
|
@@ -144241,12 +144503,12 @@ function readInstalledHeadroomCommit() {
|
|
|
144241
144503
|
if (toolDir.status !== 0) {
|
|
144242
144504
|
return void 0;
|
|
144243
144505
|
}
|
|
144244
|
-
const libDir =
|
|
144506
|
+
const libDir = import_node_path56.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
144245
144507
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
144246
|
-
const sitePackages =
|
|
144508
|
+
const sitePackages = import_node_path56.default.join(libDir, python, "site-packages");
|
|
144247
144509
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
144248
144510
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
144249
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
144511
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path56.default.join(sitePackages, entry, "direct_url.json"));
|
|
144250
144512
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
144251
144513
|
}
|
|
144252
144514
|
}
|
|
@@ -144395,7 +144657,7 @@ function registerHeadroomCommand(program2, deps) {
|
|
|
144395
144657
|
init_realPorts();
|
|
144396
144658
|
|
|
144397
144659
|
// src/usage/realJobRunner.ts
|
|
144398
|
-
var
|
|
144660
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
144399
144661
|
init_conditions();
|
|
144400
144662
|
init_identityClaude();
|
|
144401
144663
|
var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
|
|
@@ -144408,7 +144670,7 @@ ${outcome.trimEnd()}
|
|
|
144408
144670
|
}
|
|
144409
144671
|
function createRealJobRunner(params) {
|
|
144410
144672
|
return async (name, identity, job) => {
|
|
144411
|
-
const logFile =
|
|
144673
|
+
const logFile = import_node_path57.default.join(params.paths.jobLogsDir, `${name}.log`);
|
|
144412
144674
|
const append = (outcome) => {
|
|
144413
144675
|
params.fs.mkdirPrivate(params.paths.jobLogsDir);
|
|
144414
144676
|
params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
|
|
@@ -144462,7 +144724,7 @@ function registerHeadlessCommands(program2, deps) {
|
|
|
144462
144724
|
}
|
|
144463
144725
|
|
|
144464
144726
|
// src/jobs.ts
|
|
144465
|
-
var
|
|
144727
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
144466
144728
|
init_commandDeps();
|
|
144467
144729
|
init_cliError();
|
|
144468
144730
|
init_schema();
|
|
@@ -144487,7 +144749,7 @@ function jobOf(options) {
|
|
|
144487
144749
|
target: options.identity === void 0 ? { pool: options.pool ?? "" } : { identity: options.identity },
|
|
144488
144750
|
trigger: options.at === void 0 ? { beforeReset: options.beforeReset ?? "fiveHour", lead: options.lead ?? "" } : { at: options.at },
|
|
144489
144751
|
prompt: options.prompt,
|
|
144490
|
-
cwd:
|
|
144752
|
+
cwd: import_node_path58.default.resolve(options.cwd ?? process.cwd()),
|
|
144491
144753
|
timeout: options.timeout,
|
|
144492
144754
|
...options.model === void 0 ? {} : { model: options.model },
|
|
144493
144755
|
...options.allowedTool === void 0 ? {} : { allowedTools: options.allowedTool }
|
|
@@ -144560,7 +144822,7 @@ function registerJobCommand(program2, deps) {
|
|
|
144560
144822
|
console.log(`Allowed tools: ${entry.allowedTools.join(", ")}`);
|
|
144561
144823
|
}
|
|
144562
144824
|
console.log(`Prompt: ${entry.prompt}`);
|
|
144563
|
-
console.log(`Results: ${
|
|
144825
|
+
console.log(`Results: ${import_node_path58.default.join(paths.jobLogsDir, `${name}.log`)}`);
|
|
144564
144826
|
}),
|
|
144565
144827
|
["agent-shim job show digest"]
|
|
144566
144828
|
);
|
|
@@ -144583,7 +144845,7 @@ function registerJobCommand(program2, deps) {
|
|
|
144583
144845
|
throw new UsageError(`No member of the job's pool can be picked right now.`);
|
|
144584
144846
|
}
|
|
144585
144847
|
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 ${
|
|
144848
|
+
console.log(`Ran job "${name}" as ${identity}; the result is in ${import_node_path58.default.join(paths.jobLogsDir, `${name}.log`)}.`);
|
|
144587
144849
|
}),
|
|
144588
144850
|
["agent-shim job run digest"]
|
|
144589
144851
|
);
|
|
@@ -145109,7 +145371,7 @@ function registerSessionCommands(program2, deps) {
|
|
|
145109
145371
|
}
|
|
145110
145372
|
|
|
145111
145373
|
// src/usage/commands.ts
|
|
145112
|
-
var
|
|
145374
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
145113
145375
|
init_commandDeps();
|
|
145114
145376
|
init_realPorts();
|
|
145115
145377
|
init_account();
|
|
@@ -145247,7 +145509,7 @@ function collectAccounts(fs24, paths, identity, probe) {
|
|
|
145247
145509
|
return names.map((name) => ({
|
|
145248
145510
|
identity: name,
|
|
145249
145511
|
account: readAccountMetadata(fs24, paths.identitiesDir, name),
|
|
145250
|
-
signIn: identitySignIn(fs24, probe, { farmRoot:
|
|
145512
|
+
signIn: identitySignIn(fs24, probe, { farmRoot: import_node_path59.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
|
|
145251
145513
|
usage: readUsageSnapshot(fs24, paths.usageSnapshotsDir, name)
|
|
145252
145514
|
}));
|
|
145253
145515
|
}
|
|
@@ -145596,7 +145858,7 @@ async function runClaude(argvOverride) {
|
|
|
145596
145858
|
// src/cli.ts
|
|
145597
145859
|
async function main() {
|
|
145598
145860
|
aliasLegacyEnv(process.env);
|
|
145599
|
-
const invokedName =
|
|
145861
|
+
const invokedName = import_node_path60.default.basename(process.argv[1] ?? "agent-shim");
|
|
145600
145862
|
if (isInvokedAsClaude(invokedName)) {
|
|
145601
145863
|
await runClaude();
|
|
145602
145864
|
return;
|