claude-use 11.87.2 → 11.87.3
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 +1167 -620
- package/dist/index.cjs +40 -12
- package/dist/index.mjs +40 -12
- package/dist/types/index.d.ts +5 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -319,10 +319,10 @@ function mergeDefs(...defs) {
|
|
|
319
319
|
function cloneDef(schema) {
|
|
320
320
|
return mergeDefs(schema._zod.def);
|
|
321
321
|
}
|
|
322
|
-
function getElementAtPath(obj,
|
|
323
|
-
if (!
|
|
322
|
+
function getElementAtPath(obj, path97) {
|
|
323
|
+
if (!path97)
|
|
324
324
|
return obj;
|
|
325
|
-
return
|
|
325
|
+
return path97.reduce((acc, key) => acc?.[key], obj);
|
|
326
326
|
}
|
|
327
327
|
function promiseAllObject(promisesObj) {
|
|
328
328
|
const keys = Object.keys(promisesObj);
|
|
@@ -581,11 +581,11 @@ function explicitlyAborted(x3, startIndex = 0) {
|
|
|
581
581
|
}
|
|
582
582
|
return false;
|
|
583
583
|
}
|
|
584
|
-
function prefixIssues(
|
|
584
|
+
function prefixIssues(path97, issues) {
|
|
585
585
|
return issues.map((iss) => {
|
|
586
586
|
var _a4;
|
|
587
587
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
588
|
-
iss.path.unshift(
|
|
588
|
+
iss.path.unshift(path97);
|
|
589
589
|
return iss;
|
|
590
590
|
});
|
|
591
591
|
}
|
|
@@ -1118,16 +1118,16 @@ function flattenError(error63, mapper = (issue2) => issue2.message) {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
function formatError(error63, mapper = (issue2) => issue2.message) {
|
|
1120
1120
|
const fieldErrors = { _errors: [] };
|
|
1121
|
-
const processError = (error64,
|
|
1121
|
+
const processError = (error64, path97 = []) => {
|
|
1122
1122
|
for (const issue2 of error64.issues) {
|
|
1123
1123
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1124
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1124
|
+
issue2.errors.map((issues) => processError({ issues }, [...path97, ...issue2.path]));
|
|
1125
1125
|
} else if (issue2.code === "invalid_key") {
|
|
1126
|
-
processError({ issues: issue2.issues }, [...
|
|
1126
|
+
processError({ issues: issue2.issues }, [...path97, ...issue2.path]);
|
|
1127
1127
|
} else if (issue2.code === "invalid_element") {
|
|
1128
|
-
processError({ issues: issue2.issues }, [...
|
|
1128
|
+
processError({ issues: issue2.issues }, [...path97, ...issue2.path]);
|
|
1129
1129
|
} else {
|
|
1130
|
-
const fullpath = [...
|
|
1130
|
+
const fullpath = [...path97, ...issue2.path];
|
|
1131
1131
|
if (fullpath.length === 0) {
|
|
1132
1132
|
fieldErrors._errors.push(mapper(issue2));
|
|
1133
1133
|
} else {
|
|
@@ -1166,17 +1166,17 @@ function formatError(error63, mapper = (issue2) => issue2.message) {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
function treeifyError(error63, mapper = (issue2) => issue2.message) {
|
|
1168
1168
|
const result = { errors: [] };
|
|
1169
|
-
const processError = (error64,
|
|
1169
|
+
const processError = (error64, path97 = []) => {
|
|
1170
1170
|
var _a4;
|
|
1171
1171
|
for (const issue2 of error64.issues) {
|
|
1172
1172
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1173
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1173
|
+
issue2.errors.map((issues) => processError({ issues }, [...path97, ...issue2.path]));
|
|
1174
1174
|
} else if (issue2.code === "invalid_key") {
|
|
1175
|
-
processError({ issues: issue2.issues }, [...
|
|
1175
|
+
processError({ issues: issue2.issues }, [...path97, ...issue2.path]);
|
|
1176
1176
|
} else if (issue2.code === "invalid_element") {
|
|
1177
|
-
processError({ issues: issue2.issues }, [...
|
|
1177
|
+
processError({ issues: issue2.issues }, [...path97, ...issue2.path]);
|
|
1178
1178
|
} else {
|
|
1179
|
-
const fullpath = [...
|
|
1179
|
+
const fullpath = [...path97, ...issue2.path];
|
|
1180
1180
|
if (fullpath.length === 0) {
|
|
1181
1181
|
result.errors.push(mapper(issue2));
|
|
1182
1182
|
continue;
|
|
@@ -1215,8 +1215,8 @@ function treeifyError(error63, mapper = (issue2) => issue2.message) {
|
|
|
1215
1215
|
}
|
|
1216
1216
|
function toDotPath(_path) {
|
|
1217
1217
|
const segs = [];
|
|
1218
|
-
const
|
|
1219
|
-
for (const seg of
|
|
1218
|
+
const path97 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1219
|
+
for (const seg of path97) {
|
|
1220
1220
|
if (typeof seg === "number")
|
|
1221
1221
|
segs.push(`[${seg}]`);
|
|
1222
1222
|
else if (typeof seg === "symbol")
|
|
@@ -19248,13 +19248,13 @@ function resolveRef(ref, ctx) {
|
|
|
19248
19248
|
if (!ref.startsWith("#")) {
|
|
19249
19249
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19250
19250
|
}
|
|
19251
|
-
const
|
|
19252
|
-
if (
|
|
19251
|
+
const path97 = ref.slice(1).split("/").filter(Boolean);
|
|
19252
|
+
if (path97.length === 0) {
|
|
19253
19253
|
return ctx.rootSchema;
|
|
19254
19254
|
}
|
|
19255
19255
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
19256
|
-
if (
|
|
19257
|
-
const key =
|
|
19256
|
+
if (path97[0] === defsKey) {
|
|
19257
|
+
const key = path97[1] === void 0 ? void 0 : decodeJSONPointerSegment(path97[1]);
|
|
19258
19258
|
if (!key || !ctx.defs[key]) {
|
|
19259
19259
|
throw new Error(`Reference not found: ${ref}`);
|
|
19260
19260
|
}
|
|
@@ -23761,42 +23761,42 @@ var require_defaults = __commonJS({
|
|
|
23761
23761
|
var require_env_paths = __commonJS({
|
|
23762
23762
|
"node_modules/.pnpm/env-paths@2.2.1/node_modules/env-paths/index.js"(exports2, module2) {
|
|
23763
23763
|
"use strict";
|
|
23764
|
-
var
|
|
23764
|
+
var path97 = require("path");
|
|
23765
23765
|
var os24 = require("os");
|
|
23766
23766
|
var homedir = os24.homedir();
|
|
23767
|
-
var
|
|
23767
|
+
var tmpdir2 = os24.tmpdir();
|
|
23768
23768
|
var { env } = process;
|
|
23769
23769
|
var macos = (name) => {
|
|
23770
|
-
const library =
|
|
23770
|
+
const library = path97.join(homedir, "Library");
|
|
23771
23771
|
return {
|
|
23772
|
-
data:
|
|
23773
|
-
config:
|
|
23774
|
-
cache:
|
|
23775
|
-
log:
|
|
23776
|
-
temp:
|
|
23772
|
+
data: path97.join(library, "Application Support", name),
|
|
23773
|
+
config: path97.join(library, "Preferences", name),
|
|
23774
|
+
cache: path97.join(library, "Caches", name),
|
|
23775
|
+
log: path97.join(library, "Logs", name),
|
|
23776
|
+
temp: path97.join(tmpdir2, name)
|
|
23777
23777
|
};
|
|
23778
23778
|
};
|
|
23779
23779
|
var windows = (name) => {
|
|
23780
|
-
const appData = env.APPDATA ||
|
|
23781
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
23780
|
+
const appData = env.APPDATA || path97.join(homedir, "AppData", "Roaming");
|
|
23781
|
+
const localAppData = env.LOCALAPPDATA || path97.join(homedir, "AppData", "Local");
|
|
23782
23782
|
return {
|
|
23783
23783
|
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
23784
|
-
data:
|
|
23785
|
-
config:
|
|
23786
|
-
cache:
|
|
23787
|
-
log:
|
|
23788
|
-
temp:
|
|
23784
|
+
data: path97.join(localAppData, name, "Data"),
|
|
23785
|
+
config: path97.join(appData, name, "Config"),
|
|
23786
|
+
cache: path97.join(localAppData, name, "Cache"),
|
|
23787
|
+
log: path97.join(localAppData, name, "Log"),
|
|
23788
|
+
temp: path97.join(tmpdir2, name)
|
|
23789
23789
|
};
|
|
23790
23790
|
};
|
|
23791
23791
|
var linux = (name) => {
|
|
23792
|
-
const username =
|
|
23792
|
+
const username = path97.basename(homedir);
|
|
23793
23793
|
return {
|
|
23794
|
-
data:
|
|
23795
|
-
config:
|
|
23796
|
-
cache:
|
|
23794
|
+
data: path97.join(env.XDG_DATA_HOME || path97.join(homedir, ".local", "share"), name),
|
|
23795
|
+
config: path97.join(env.XDG_CONFIG_HOME || path97.join(homedir, ".config"), name),
|
|
23796
|
+
cache: path97.join(env.XDG_CACHE_HOME || path97.join(homedir, ".cache"), name),
|
|
23797
23797
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
23798
|
-
log:
|
|
23799
|
-
temp:
|
|
23798
|
+
log: path97.join(env.XDG_STATE_HOME || path97.join(homedir, ".local", "state"), name),
|
|
23799
|
+
temp: path97.join(tmpdir2, username, name)
|
|
23800
23800
|
};
|
|
23801
23801
|
};
|
|
23802
23802
|
var envPaths = (name, options) => {
|
|
@@ -23864,11 +23864,11 @@ var require_util = __commonJS({
|
|
|
23864
23864
|
return result;
|
|
23865
23865
|
}
|
|
23866
23866
|
exports2.emplace = emplace;
|
|
23867
|
-
function getPropertyByPath(source,
|
|
23868
|
-
if (typeof
|
|
23869
|
-
return source[
|
|
23867
|
+
function getPropertyByPath(source, path97) {
|
|
23868
|
+
if (typeof path97 === "string" && Object.prototype.hasOwnProperty.call(source, path97)) {
|
|
23869
|
+
return source[path97];
|
|
23870
23870
|
}
|
|
23871
|
-
const parsedPath = typeof
|
|
23871
|
+
const parsedPath = typeof path97 === "string" ? path97.split(".") : path97;
|
|
23872
23872
|
return parsedPath.reduce((previous, key) => {
|
|
23873
23873
|
if (previous === void 0) {
|
|
23874
23874
|
return previous;
|
|
@@ -23891,9 +23891,9 @@ var require_util = __commonJS({
|
|
|
23891
23891
|
return Object.fromEntries(Object.entries(options).filter(([, value3]) => value3 !== void 0));
|
|
23892
23892
|
}
|
|
23893
23893
|
exports2.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
|
|
23894
|
-
async function isDirectory(
|
|
23894
|
+
async function isDirectory(path97) {
|
|
23895
23895
|
try {
|
|
23896
|
-
const stat = await fs_1.promises.stat(
|
|
23896
|
+
const stat = await fs_1.promises.stat(path97);
|
|
23897
23897
|
return stat.isDirectory();
|
|
23898
23898
|
} catch (e10) {
|
|
23899
23899
|
if (e10.code === "ENOENT") {
|
|
@@ -23903,9 +23903,9 @@ var require_util = __commonJS({
|
|
|
23903
23903
|
}
|
|
23904
23904
|
}
|
|
23905
23905
|
exports2.isDirectory = isDirectory;
|
|
23906
|
-
function isDirectorySync(
|
|
23906
|
+
function isDirectorySync(path97) {
|
|
23907
23907
|
try {
|
|
23908
|
-
const stat = fs_1.default.statSync(
|
|
23908
|
+
const stat = fs_1.default.statSync(path97);
|
|
23909
23909
|
return stat.isDirectory();
|
|
23910
23910
|
} catch (e10) {
|
|
23911
23911
|
if (e10.code === "ENOENT") {
|
|
@@ -24003,7 +24003,7 @@ var require_ExplorerBase = __commonJS({
|
|
|
24003
24003
|
const idx = importStack.indexOf(fullPath);
|
|
24004
24004
|
if (idx !== -1) {
|
|
24005
24005
|
throw new Error(`Circular import detected:
|
|
24006
|
-
${[...importStack, fullPath].map((
|
|
24006
|
+
${[...importStack, fullPath].map((path97, i10) => `${i10 + 1}. ${path97}`).join("\n")} (same as ${idx + 1}.)`);
|
|
24007
24007
|
}
|
|
24008
24008
|
}
|
|
24009
24009
|
}
|
|
@@ -24191,9 +24191,9 @@ var require_Explorer = __commonJS({
|
|
|
24191
24191
|
throw error63;
|
|
24192
24192
|
}
|
|
24193
24193
|
}
|
|
24194
|
-
async #fileExists(
|
|
24194
|
+
async #fileExists(path97) {
|
|
24195
24195
|
try {
|
|
24196
|
-
await promises_1.default.stat(
|
|
24196
|
+
await promises_1.default.stat(path97);
|
|
24197
24197
|
return true;
|
|
24198
24198
|
} catch (e10) {
|
|
24199
24199
|
return false;
|
|
@@ -24353,9 +24353,9 @@ var require_ExplorerSync = __commonJS({
|
|
|
24353
24353
|
throw error63;
|
|
24354
24354
|
}
|
|
24355
24355
|
}
|
|
24356
|
-
#fileExists(
|
|
24356
|
+
#fileExists(path97) {
|
|
24357
24357
|
try {
|
|
24358
|
-
fs_1.default.statSync(
|
|
24358
|
+
fs_1.default.statSync(path97);
|
|
24359
24359
|
return true;
|
|
24360
24360
|
} catch (e10) {
|
|
24361
24361
|
return false;
|
|
@@ -24479,7 +24479,7 @@ var require_dist = __commonJS({
|
|
|
24479
24479
|
};
|
|
24480
24480
|
}
|
|
24481
24481
|
function getResolvedSearchPlaces(moduleName, toolDefinedSearchPlaces, userConfiguredOptions) {
|
|
24482
|
-
const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((
|
|
24482
|
+
const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path97) => path97.replace("{name}", moduleName));
|
|
24483
24483
|
if (userConfiguredOptions.mergeSearchPlaces) {
|
|
24484
24484
|
return [...userConfiguredSearchPlaces ?? [], ...toolDefinedSearchPlaces];
|
|
24485
24485
|
}
|
|
@@ -24609,7 +24609,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
24609
24609
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
24610
24610
|
}
|
|
24611
24611
|
function describeIgnoredKeys(filePath, ignored) {
|
|
24612
|
-
const places = ignored.map(({ path:
|
|
24612
|
+
const places = ignored.map(({ path: path97, keys }) => `${path97.length === 0 ? "" : `${path97.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
24613
24613
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
24614
24614
|
}
|
|
24615
24615
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -24631,9 +24631,9 @@ function restoreIgnoredKeys(filePath, value3) {
|
|
|
24631
24631
|
return value3;
|
|
24632
24632
|
}
|
|
24633
24633
|
const restored2 = structuredClone(value3);
|
|
24634
|
-
for (const { path:
|
|
24634
|
+
for (const { path: path97, values } of ignored) {
|
|
24635
24635
|
let holder = restored2;
|
|
24636
|
-
for (const step2 of
|
|
24636
|
+
for (const step2 of path97) {
|
|
24637
24637
|
holder = isRecord(holder) ? holder[step2] : void 0;
|
|
24638
24638
|
}
|
|
24639
24639
|
if (isRecord(holder)) {
|
|
@@ -28811,8 +28811,8 @@ var require_utils = __commonJS({
|
|
|
28811
28811
|
}
|
|
28812
28812
|
return output2;
|
|
28813
28813
|
};
|
|
28814
|
-
exports2.basename = (
|
|
28815
|
-
const segs =
|
|
28814
|
+
exports2.basename = (path97, { windows } = {}) => {
|
|
28815
|
+
const segs = path97.split(windows ? /[\\/]/ : "/");
|
|
28816
28816
|
const last = segs[segs.length - 1];
|
|
28817
28817
|
if (last === "") {
|
|
28818
28818
|
return segs[segs.length - 2];
|
|
@@ -32968,11 +32968,30 @@ var init_categories_default = __esm({
|
|
|
32968
32968
|
});
|
|
32969
32969
|
|
|
32970
32970
|
// src/config/classify.ts
|
|
32971
|
-
function
|
|
32972
|
-
return
|
|
32971
|
+
function literalClassificationPattern(name) {
|
|
32972
|
+
return GLOB_METACHARACTERS.test(name) ? name.replace(/[\\*?[\]{}!()]/g, "\\$&") : name;
|
|
32973
|
+
}
|
|
32974
|
+
function literalOf(pattern) {
|
|
32975
|
+
if (!GLOB_METACHARACTERS.test(pattern)) return pattern;
|
|
32976
|
+
let literal3 = "";
|
|
32977
|
+
for (let index = 0; index < pattern.length; index += 1) {
|
|
32978
|
+
const character = pattern[index];
|
|
32979
|
+
if (character === void 0) continue;
|
|
32980
|
+
const next = pattern[index + 1];
|
|
32981
|
+
if (character === "\\" && next !== void 0 && (next === "\\" || GLOB_METACHARACTERS.test(next))) {
|
|
32982
|
+
literal3 += next;
|
|
32983
|
+
index += 1;
|
|
32984
|
+
} else if (GLOB_METACHARACTERS.test(character)) {
|
|
32985
|
+
return void 0;
|
|
32986
|
+
} else {
|
|
32987
|
+
literal3 += character;
|
|
32988
|
+
}
|
|
32989
|
+
}
|
|
32990
|
+
return literal3;
|
|
32973
32991
|
}
|
|
32974
32992
|
function compile2(pattern, category, source, ordinal) {
|
|
32975
|
-
const
|
|
32993
|
+
const literal3 = literalOf(pattern);
|
|
32994
|
+
const isExact = literal3 !== void 0;
|
|
32976
32995
|
const matcher = (0, import_picomatch2.default)(pattern, { dot: true, nocase: false });
|
|
32977
32996
|
return {
|
|
32978
32997
|
pattern,
|
|
@@ -32980,7 +32999,7 @@ function compile2(pattern, category, source, ordinal) {
|
|
|
32980
32999
|
source,
|
|
32981
33000
|
isExact,
|
|
32982
33001
|
ordinal,
|
|
32983
|
-
matches: isExact ? (name) => name ===
|
|
33002
|
+
matches: isExact ? (name) => name === literal3 : (name) => matcher(name)
|
|
32984
33003
|
};
|
|
32985
33004
|
}
|
|
32986
33005
|
function compileClassificationPatterns(defaults, overlay2) {
|
|
@@ -33384,9 +33403,9 @@ var init_identity = __esm({
|
|
|
33384
33403
|
});
|
|
33385
33404
|
|
|
33386
33405
|
// src/statusline/keys.ts
|
|
33387
|
-
function valueAt(source,
|
|
33406
|
+
function valueAt(source, path97) {
|
|
33388
33407
|
let current = source;
|
|
33389
|
-
for (const part of
|
|
33408
|
+
for (const part of path97) {
|
|
33390
33409
|
if (!isPlainObject2(current)) {
|
|
33391
33410
|
return void 0;
|
|
33392
33411
|
}
|
|
@@ -33394,14 +33413,14 @@ function valueAt(source, path92) {
|
|
|
33394
33413
|
}
|
|
33395
33414
|
return current;
|
|
33396
33415
|
}
|
|
33397
|
-
function acceptsNull(
|
|
33398
|
-
const layer =
|
|
33416
|
+
function acceptsNull(path97) {
|
|
33417
|
+
const layer = path97.reduceRight((inner, part) => ({ [part]: inner }), null);
|
|
33399
33418
|
return StatuslineSchema.safeParse(layer).success;
|
|
33400
33419
|
}
|
|
33401
|
-
function keyOf(
|
|
33420
|
+
function keyOf(path97, declared) {
|
|
33402
33421
|
const optional2 = declared instanceof external_exports.ZodOptional;
|
|
33403
33422
|
const leaf = optional2 ? declared.unwrap() : declared;
|
|
33404
|
-
const common = { path:
|
|
33423
|
+
const common = { path: path97.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path97), optional: optional2, unsettable: acceptsNull(path97) };
|
|
33405
33424
|
if (leaf instanceof external_exports.ZodNumber) {
|
|
33406
33425
|
return { ...common, kind: "integer", choices: [] };
|
|
33407
33426
|
}
|
|
@@ -33426,7 +33445,7 @@ function keyOf(path92, declared) {
|
|
|
33426
33445
|
if (leaf instanceof external_exports.ZodArray && leaf.element instanceof external_exports.ZodString) {
|
|
33427
33446
|
return { ...common, kind: "textList", choices: [] };
|
|
33428
33447
|
}
|
|
33429
|
-
throw new TypeError(`statusline setting ${
|
|
33448
|
+
throw new TypeError(`statusline setting ${path97.join(".")} has a kind the key listing does not describe`);
|
|
33430
33449
|
}
|
|
33431
33450
|
function walk(shape, prefix) {
|
|
33432
33451
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof external_exports.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -33457,14 +33476,14 @@ var init_keys = __esm({
|
|
|
33457
33476
|
});
|
|
33458
33477
|
|
|
33459
33478
|
// src/statusline/change.ts
|
|
33460
|
-
function keyNamed(
|
|
33461
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
33479
|
+
function keyNamed(path97) {
|
|
33480
|
+
const found = statuslineKeys().find((key) => key.path === path97);
|
|
33462
33481
|
if (found === void 0) {
|
|
33463
|
-
throw new UsageError(`"${
|
|
33482
|
+
throw new UsageError(`"${path97}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
33464
33483
|
}
|
|
33465
33484
|
return found;
|
|
33466
33485
|
}
|
|
33467
|
-
function textListOf(
|
|
33486
|
+
function textListOf(path97, raw) {
|
|
33468
33487
|
if (raw === "") {
|
|
33469
33488
|
return [];
|
|
33470
33489
|
}
|
|
@@ -33472,10 +33491,10 @@ function textListOf(path92, raw) {
|
|
|
33472
33491
|
try {
|
|
33473
33492
|
parsed = JSON.parse(raw);
|
|
33474
33493
|
} catch {
|
|
33475
|
-
throw new UsageError(`${
|
|
33494
|
+
throw new UsageError(`${path97}: "${raw}" is not a JSON array of strings such as ["git","describe"].`);
|
|
33476
33495
|
}
|
|
33477
33496
|
if (!Array.isArray(parsed) || parsed.some((item) => typeof item !== "string")) {
|
|
33478
|
-
throw new UsageError(`${
|
|
33497
|
+
throw new UsageError(`${path97}: "${raw}" is not a JSON array of strings such as ["git","describe"].`);
|
|
33479
33498
|
}
|
|
33480
33499
|
return parsed;
|
|
33481
33500
|
}
|
|
@@ -33484,42 +33503,42 @@ function parseStatuslineAssignment(text5) {
|
|
|
33484
33503
|
if (split < 1) {
|
|
33485
33504
|
throw new UsageError(`"${text5}" is not <setting>=<value>.`);
|
|
33486
33505
|
}
|
|
33487
|
-
const
|
|
33506
|
+
const path97 = text5.slice(0, split);
|
|
33488
33507
|
const raw = text5.slice(split + 1);
|
|
33489
|
-
const key = keyNamed(
|
|
33508
|
+
const key = keyNamed(path97);
|
|
33490
33509
|
if (key.unsettable && raw === UNSET_WORD) {
|
|
33491
|
-
return { path:
|
|
33510
|
+
return { path: path97, value: null };
|
|
33492
33511
|
}
|
|
33493
33512
|
switch (key.kind) {
|
|
33494
33513
|
case "integer": {
|
|
33495
33514
|
const number6 = Number(raw);
|
|
33496
33515
|
if (raw.trim() === "" || !Number.isFinite(number6)) {
|
|
33497
|
-
throw new UsageError(`${
|
|
33516
|
+
throw new UsageError(`${path97}: "${raw}" is not a number.`);
|
|
33498
33517
|
}
|
|
33499
|
-
return { path:
|
|
33518
|
+
return { path: path97, value: number6 };
|
|
33500
33519
|
}
|
|
33501
33520
|
case "boolean":
|
|
33502
33521
|
if (raw !== "true" && raw !== "false") {
|
|
33503
|
-
throw new UsageError(`${
|
|
33522
|
+
throw new UsageError(`${path97}: "${raw}" is not true or false.`);
|
|
33504
33523
|
}
|
|
33505
|
-
return { path:
|
|
33524
|
+
return { path: path97, value: raw === "true" };
|
|
33506
33525
|
case "text":
|
|
33507
33526
|
case "choice":
|
|
33508
|
-
return { path:
|
|
33527
|
+
return { path: path97, value: raw };
|
|
33509
33528
|
case "colour":
|
|
33510
|
-
return { path:
|
|
33529
|
+
return { path: path97, value: /^\d+$/.test(raw) ? Number(raw) : raw };
|
|
33511
33530
|
case "list":
|
|
33512
|
-
return { path:
|
|
33531
|
+
return { path: path97, value: raw === "" ? [] : raw.split(",") };
|
|
33513
33532
|
case "groups":
|
|
33514
|
-
return { path:
|
|
33533
|
+
return { path: path97, value: raw === "" ? [] : raw.split(";").map((group) => group.split(",")) };
|
|
33515
33534
|
case "textList":
|
|
33516
|
-
return { path:
|
|
33535
|
+
return { path: path97, value: textListOf(path97, raw) };
|
|
33517
33536
|
default:
|
|
33518
33537
|
return key.kind;
|
|
33519
33538
|
}
|
|
33520
33539
|
}
|
|
33521
|
-
function setAt(target,
|
|
33522
|
-
const [head, ...rest] =
|
|
33540
|
+
function setAt(target, path97, value3) {
|
|
33541
|
+
const [head, ...rest] = path97;
|
|
33523
33542
|
if (head === void 0) {
|
|
33524
33543
|
return;
|
|
33525
33544
|
}
|
|
@@ -33532,8 +33551,8 @@ function setAt(target, path92, value3) {
|
|
|
33532
33551
|
target[head] = next;
|
|
33533
33552
|
setAt(next, rest, value3);
|
|
33534
33553
|
}
|
|
33535
|
-
function removeAt(target,
|
|
33536
|
-
const [head, ...rest] =
|
|
33554
|
+
function removeAt(target, path97) {
|
|
33555
|
+
const [head, ...rest] = path97;
|
|
33537
33556
|
if (head === void 0) {
|
|
33538
33557
|
return;
|
|
33539
33558
|
}
|
|
@@ -33551,13 +33570,13 @@ function removeAt(target, path92) {
|
|
|
33551
33570
|
}
|
|
33552
33571
|
function applyStatuslineChange(existing, change) {
|
|
33553
33572
|
const draft = structuredClone(existing ?? {});
|
|
33554
|
-
for (const [
|
|
33555
|
-
keyNamed(
|
|
33556
|
-
setAt(draft,
|
|
33573
|
+
for (const [path97, value3] of Object.entries(change.set ?? {})) {
|
|
33574
|
+
keyNamed(path97);
|
|
33575
|
+
setAt(draft, path97.split("."), value3);
|
|
33557
33576
|
}
|
|
33558
|
-
for (const
|
|
33559
|
-
keyNamed(
|
|
33560
|
-
removeAt(draft,
|
|
33577
|
+
for (const path97 of change.unset ?? []) {
|
|
33578
|
+
keyNamed(path97);
|
|
33579
|
+
removeAt(draft, path97.split("."));
|
|
33561
33580
|
}
|
|
33562
33581
|
const result = StatuslineSchema.safeParse(draft);
|
|
33563
33582
|
if (!result.success) {
|
|
@@ -33795,19 +33814,19 @@ function writePools(paths, pools) {
|
|
|
33795
33814
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
33796
33815
|
}
|
|
33797
33816
|
function poolCycleOf(pools, name) {
|
|
33798
|
-
const walk3 = (current,
|
|
33817
|
+
const walk3 = (current, path97) => {
|
|
33799
33818
|
for (const entry of pools[current]?.identities ?? []) {
|
|
33800
33819
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
33801
33820
|
if (nested === void 0) {
|
|
33802
33821
|
continue;
|
|
33803
33822
|
}
|
|
33804
33823
|
if (nested === name) {
|
|
33805
|
-
return [...
|
|
33824
|
+
return [...path97, nested];
|
|
33806
33825
|
}
|
|
33807
|
-
if (
|
|
33826
|
+
if (path97.includes(nested)) {
|
|
33808
33827
|
continue;
|
|
33809
33828
|
}
|
|
33810
|
-
const found = walk3(nested, [...
|
|
33829
|
+
const found = walk3(nested, [...path97, nested]);
|
|
33811
33830
|
if (found !== void 0) {
|
|
33812
33831
|
return found;
|
|
33813
33832
|
}
|
|
@@ -36198,11 +36217,11 @@ function identifyRequest(headers) {
|
|
|
36198
36217
|
function directOrigin2(port) {
|
|
36199
36218
|
return `http://127.0.0.1:${String(port)}`;
|
|
36200
36219
|
}
|
|
36201
|
-
function parseProviderPath(
|
|
36202
|
-
if (!
|
|
36220
|
+
function parseProviderPath(path97) {
|
|
36221
|
+
if (!path97.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
36203
36222
|
return void 0;
|
|
36204
36223
|
}
|
|
36205
|
-
const tail =
|
|
36224
|
+
const tail = path97.slice(PROVIDER_PATH_PREFIX.length);
|
|
36206
36225
|
const slash = tail.indexOf("/");
|
|
36207
36226
|
if (slash <= 0) {
|
|
36208
36227
|
return void 0;
|
|
@@ -36538,12 +36557,12 @@ function decoderFor(encoding) {
|
|
|
36538
36557
|
return void 0;
|
|
36539
36558
|
}
|
|
36540
36559
|
}
|
|
36541
|
-
function destinationOf(
|
|
36542
|
-
const scoped = parseProviderPath(
|
|
36560
|
+
function destinationOf(path97, sessionProvider) {
|
|
36561
|
+
const scoped = parseProviderPath(path97);
|
|
36543
36562
|
if (scoped !== void 0) {
|
|
36544
36563
|
return { provider: scoped.provider, endpoint: scoped.rest };
|
|
36545
36564
|
}
|
|
36546
|
-
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint:
|
|
36565
|
+
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint: path97 };
|
|
36547
36566
|
}
|
|
36548
36567
|
function modelChoiceOf(event, servedModel, provider) {
|
|
36549
36568
|
if (event.modelChoice !== void 0) return event.modelChoice;
|
|
@@ -38709,7 +38728,7 @@ var init_projects = __esm({
|
|
|
38709
38728
|
});
|
|
38710
38729
|
|
|
38711
38730
|
// src/resolve/match.ts
|
|
38712
|
-
function
|
|
38731
|
+
function isExactPattern(pattern) {
|
|
38713
38732
|
return !GLOB_METACHARACTERS2.test(pattern);
|
|
38714
38733
|
}
|
|
38715
38734
|
function literalPrefixOf(pattern) {
|
|
@@ -38936,7 +38955,7 @@ function flattenLayers(layers, options) {
|
|
|
38936
38955
|
...unpacked.when === void 0 ? {} : { when: unpacked.when },
|
|
38937
38956
|
layer: layer.id,
|
|
38938
38957
|
ordinal,
|
|
38939
|
-
isExact:
|
|
38958
|
+
isExact: isExactPattern(pattern),
|
|
38940
38959
|
literalPrefix: literalPrefixOf(pattern),
|
|
38941
38960
|
segmentCount: pattern.split("/").filter((segment) => segment !== "").length,
|
|
38942
38961
|
matches: compileMatcher(pattern)
|
|
@@ -40739,8 +40758,8 @@ function parseConnectTarget(authority) {
|
|
|
40739
40758
|
}
|
|
40740
40759
|
return { host, port };
|
|
40741
40760
|
}
|
|
40742
|
-
function servedByPipeline(
|
|
40743
|
-
return
|
|
40761
|
+
function servedByPipeline(path97) {
|
|
40762
|
+
return path97?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
40744
40763
|
}
|
|
40745
40764
|
function forwardableHeaders(headers) {
|
|
40746
40765
|
const connectionTokens = new Set(
|
|
@@ -41960,7 +41979,7 @@ var init_package = __esm({
|
|
|
41960
41979
|
"package.json"() {
|
|
41961
41980
|
package_default = {
|
|
41962
41981
|
name: "claude-use",
|
|
41963
|
-
version: "11.87.
|
|
41982
|
+
version: "11.87.3",
|
|
41964
41983
|
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.",
|
|
41965
41984
|
license: "MIT",
|
|
41966
41985
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -43295,14 +43314,14 @@ var require_util2 = __commonJS({
|
|
|
43295
43314
|
}
|
|
43296
43315
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
43297
43316
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
43298
|
-
let
|
|
43317
|
+
let path97 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
43299
43318
|
if (origin[origin.length - 1] === "/") {
|
|
43300
43319
|
origin = origin.slice(0, origin.length - 1);
|
|
43301
43320
|
}
|
|
43302
|
-
if (
|
|
43303
|
-
|
|
43321
|
+
if (path97 && path97[0] !== "/") {
|
|
43322
|
+
path97 = `/${path97}`;
|
|
43304
43323
|
}
|
|
43305
|
-
return new URL(`${origin}${
|
|
43324
|
+
return new URL(`${origin}${path97}`);
|
|
43306
43325
|
}
|
|
43307
43326
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
43308
43327
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -44123,9 +44142,9 @@ var require_diagnostics = __commonJS({
|
|
|
44123
44142
|
"undici:client:sendHeaders",
|
|
44124
44143
|
(evt) => {
|
|
44125
44144
|
const {
|
|
44126
|
-
request: { method, path:
|
|
44145
|
+
request: { method, path: path97, origin }
|
|
44127
44146
|
} = evt;
|
|
44128
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
44147
|
+
debugLog("sending request to %s %s%s", method, origin, path97);
|
|
44129
44148
|
}
|
|
44130
44149
|
);
|
|
44131
44150
|
}
|
|
@@ -44143,14 +44162,14 @@ var require_diagnostics = __commonJS({
|
|
|
44143
44162
|
"undici:request:headers",
|
|
44144
44163
|
(evt) => {
|
|
44145
44164
|
const {
|
|
44146
|
-
request: { method, path:
|
|
44165
|
+
request: { method, path: path97, origin },
|
|
44147
44166
|
response: { statusCode }
|
|
44148
44167
|
} = evt;
|
|
44149
44168
|
debugLog(
|
|
44150
44169
|
"received response to %s %s%s - HTTP %d",
|
|
44151
44170
|
method,
|
|
44152
44171
|
origin,
|
|
44153
|
-
|
|
44172
|
+
path97,
|
|
44154
44173
|
statusCode
|
|
44155
44174
|
);
|
|
44156
44175
|
}
|
|
@@ -44159,23 +44178,23 @@ var require_diagnostics = __commonJS({
|
|
|
44159
44178
|
"undici:request:trailers",
|
|
44160
44179
|
(evt) => {
|
|
44161
44180
|
const {
|
|
44162
|
-
request: { method, path:
|
|
44181
|
+
request: { method, path: path97, origin }
|
|
44163
44182
|
} = evt;
|
|
44164
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
44183
|
+
debugLog("trailers received from %s %s%s", method, origin, path97);
|
|
44165
44184
|
}
|
|
44166
44185
|
);
|
|
44167
44186
|
diagnosticsChannel.subscribe(
|
|
44168
44187
|
"undici:request:error",
|
|
44169
44188
|
(evt) => {
|
|
44170
44189
|
const {
|
|
44171
|
-
request: { method, path:
|
|
44190
|
+
request: { method, path: path97, origin },
|
|
44172
44191
|
error: error63
|
|
44173
44192
|
} = evt;
|
|
44174
44193
|
debugLog(
|
|
44175
44194
|
"request to %s %s%s errored - %s",
|
|
44176
44195
|
method,
|
|
44177
44196
|
origin,
|
|
44178
|
-
|
|
44197
|
+
path97,
|
|
44179
44198
|
error63.message
|
|
44180
44199
|
);
|
|
44181
44200
|
}
|
|
@@ -44290,7 +44309,7 @@ var require_request = __commonJS({
|
|
|
44290
44309
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
44291
44310
|
var Request2 = class {
|
|
44292
44311
|
constructor(origin, {
|
|
44293
|
-
path:
|
|
44312
|
+
path: path97,
|
|
44294
44313
|
method,
|
|
44295
44314
|
body,
|
|
44296
44315
|
headers,
|
|
@@ -44307,11 +44326,11 @@ var require_request = __commonJS({
|
|
|
44307
44326
|
maxRedirections,
|
|
44308
44327
|
typeOfService
|
|
44309
44328
|
}, handler) {
|
|
44310
|
-
if (typeof
|
|
44329
|
+
if (typeof path97 !== "string") {
|
|
44311
44330
|
throw new InvalidArgumentError2("path must be a string");
|
|
44312
|
-
} else if (
|
|
44331
|
+
} else if (path97[0] !== "/" && !(path97.startsWith("http://") || path97.startsWith("https://")) && method !== "CONNECT") {
|
|
44313
44332
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
44314
|
-
} else if (invalidPathRegex.test(
|
|
44333
|
+
} else if (invalidPathRegex.test(path97)) {
|
|
44315
44334
|
throw new InvalidArgumentError2("invalid request path");
|
|
44316
44335
|
}
|
|
44317
44336
|
if (typeof method !== "string") {
|
|
@@ -44386,7 +44405,7 @@ var require_request = __commonJS({
|
|
|
44386
44405
|
this.completed = false;
|
|
44387
44406
|
this.aborted = false;
|
|
44388
44407
|
this.upgrade = upgrade || null;
|
|
44389
|
-
this.path = query ? serializePathWithQuery(
|
|
44408
|
+
this.path = query ? serializePathWithQuery(path97, query) : path97;
|
|
44390
44409
|
this.origin = origin;
|
|
44391
44410
|
this.protocol = getProtocolFromUrlString(origin);
|
|
44392
44411
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -49611,7 +49630,7 @@ var require_client_h1 = __commonJS({
|
|
|
49611
49630
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
49612
49631
|
}
|
|
49613
49632
|
function writeH1(client, request7) {
|
|
49614
|
-
const { method, path:
|
|
49633
|
+
const { method, path: path97, host, upgrade, blocking, reset } = request7;
|
|
49615
49634
|
let { body, headers, contentLength } = request7;
|
|
49616
49635
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
49617
49636
|
if (util2.isFormDataLike(body)) {
|
|
@@ -49689,7 +49708,7 @@ var require_client_h1 = __commonJS({
|
|
|
49689
49708
|
if (socket.setTypeOfService) {
|
|
49690
49709
|
socket.setTypeOfService(request7.typeOfService);
|
|
49691
49710
|
}
|
|
49692
|
-
let header = `${method} ${
|
|
49711
|
+
let header = `${method} ${path97} HTTP/1.1\r
|
|
49693
49712
|
`;
|
|
49694
49713
|
if (typeof host === "string") {
|
|
49695
49714
|
header += `host: ${host}\r
|
|
@@ -50366,7 +50385,7 @@ var require_client_h2 = __commonJS({
|
|
|
50366
50385
|
const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
|
|
50367
50386
|
const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
|
|
50368
50387
|
const session = client[kHTTP2Session];
|
|
50369
|
-
const { method, path:
|
|
50388
|
+
const { method, path: path97, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
|
|
50370
50389
|
let { body } = request7;
|
|
50371
50390
|
if (upgrade != null && upgrade !== "websocket") {
|
|
50372
50391
|
util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -50435,7 +50454,7 @@ var require_client_h2 = __commonJS({
|
|
|
50435
50454
|
}
|
|
50436
50455
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
50437
50456
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
50438
|
-
headers[HTTP2_HEADER_PATH] =
|
|
50457
|
+
headers[HTTP2_HEADER_PATH] = path97;
|
|
50439
50458
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
50440
50459
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
50441
50460
|
} else {
|
|
@@ -50487,7 +50506,7 @@ var require_client_h2 = __commonJS({
|
|
|
50487
50506
|
stream.setTimeout(headersTimeout);
|
|
50488
50507
|
return true;
|
|
50489
50508
|
}
|
|
50490
|
-
headers[HTTP2_HEADER_PATH] =
|
|
50509
|
+
headers[HTTP2_HEADER_PATH] = path97;
|
|
50491
50510
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
50492
50511
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
50493
50512
|
if (body && typeof body.read === "function") {
|
|
@@ -52843,10 +52862,10 @@ var require_proxy_agent = __commonJS({
|
|
|
52843
52862
|
};
|
|
52844
52863
|
const {
|
|
52845
52864
|
origin,
|
|
52846
|
-
path:
|
|
52865
|
+
path: path97 = "/",
|
|
52847
52866
|
headers = {}
|
|
52848
52867
|
} = opts;
|
|
52849
|
-
opts.path = origin +
|
|
52868
|
+
opts.path = origin + path97;
|
|
52850
52869
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
52851
52870
|
const { host } = new URL(origin);
|
|
52852
52871
|
headers.host = host;
|
|
@@ -55006,20 +55025,20 @@ var require_mock_utils = __commonJS({
|
|
|
55006
55025
|
}
|
|
55007
55026
|
return normalizedQp;
|
|
55008
55027
|
}
|
|
55009
|
-
function safeUrl(
|
|
55010
|
-
if (typeof
|
|
55011
|
-
return
|
|
55028
|
+
function safeUrl(path97) {
|
|
55029
|
+
if (typeof path97 !== "string") {
|
|
55030
|
+
return path97;
|
|
55012
55031
|
}
|
|
55013
|
-
const pathSegments =
|
|
55032
|
+
const pathSegments = path97.split("?", 3);
|
|
55014
55033
|
if (pathSegments.length !== 2) {
|
|
55015
|
-
return
|
|
55034
|
+
return path97;
|
|
55016
55035
|
}
|
|
55017
55036
|
const qp2 = new URLSearchParams(pathSegments.pop());
|
|
55018
55037
|
qp2.sort();
|
|
55019
55038
|
return [...pathSegments, qp2.toString()].join("?");
|
|
55020
55039
|
}
|
|
55021
|
-
function matchKey(mockDispatch2, { path:
|
|
55022
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
55040
|
+
function matchKey(mockDispatch2, { path: path97, method, body, headers }) {
|
|
55041
|
+
const pathMatch = matchValue(mockDispatch2.path, path97);
|
|
55023
55042
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
55024
55043
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
55025
55044
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -55044,8 +55063,8 @@ var require_mock_utils = __commonJS({
|
|
|
55044
55063
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
55045
55064
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
55046
55065
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
55047
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
55048
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
55066
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path97, ignoreTrailingSlash }) => {
|
|
55067
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path97)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path97), resolvedPath);
|
|
55049
55068
|
});
|
|
55050
55069
|
if (matchedMockDispatches.length === 0) {
|
|
55051
55070
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -55084,19 +55103,19 @@ var require_mock_utils = __commonJS({
|
|
|
55084
55103
|
mockDispatches.splice(index, 1);
|
|
55085
55104
|
}
|
|
55086
55105
|
}
|
|
55087
|
-
function removeTrailingSlash(
|
|
55088
|
-
while (
|
|
55089
|
-
|
|
55106
|
+
function removeTrailingSlash(path97) {
|
|
55107
|
+
while (path97.endsWith("/")) {
|
|
55108
|
+
path97 = path97.slice(0, -1);
|
|
55090
55109
|
}
|
|
55091
|
-
if (
|
|
55092
|
-
|
|
55110
|
+
if (path97.length === 0) {
|
|
55111
|
+
path97 = "/";
|
|
55093
55112
|
}
|
|
55094
|
-
return
|
|
55113
|
+
return path97;
|
|
55095
55114
|
}
|
|
55096
55115
|
function buildKey(opts) {
|
|
55097
|
-
const { path:
|
|
55116
|
+
const { path: path97, method, body, headers, query } = opts;
|
|
55098
55117
|
return {
|
|
55099
|
-
path:
|
|
55118
|
+
path: path97,
|
|
55100
55119
|
method,
|
|
55101
55120
|
body,
|
|
55102
55121
|
headers,
|
|
@@ -55786,10 +55805,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
55786
55805
|
}
|
|
55787
55806
|
format(pendingInterceptors) {
|
|
55788
55807
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
55789
|
-
({ method, path:
|
|
55808
|
+
({ method, path: path97, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
55790
55809
|
Method: method,
|
|
55791
55810
|
Origin: origin,
|
|
55792
|
-
Path:
|
|
55811
|
+
Path: path97,
|
|
55793
55812
|
"Status code": statusCode,
|
|
55794
55813
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
55795
55814
|
Invocations: timesInvoked,
|
|
@@ -55871,9 +55890,9 @@ var require_mock_agent = __commonJS({
|
|
|
55871
55890
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
55872
55891
|
const dispatchOpts = { ...opts };
|
|
55873
55892
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
55874
|
-
const [
|
|
55893
|
+
const [path97, searchParams] = dispatchOpts.path.split("?");
|
|
55875
55894
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
55876
|
-
dispatchOpts.path = `${
|
|
55895
|
+
dispatchOpts.path = `${path97}?${normalizedSearchParams}`;
|
|
55877
55896
|
}
|
|
55878
55897
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
55879
55898
|
}
|
|
@@ -56274,12 +56293,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
56274
56293
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
56275
56294
|
*/
|
|
56276
56295
|
async loadSnapshots(filePath) {
|
|
56277
|
-
const
|
|
56278
|
-
if (!
|
|
56296
|
+
const path97 = filePath || this.#snapshotPath;
|
|
56297
|
+
if (!path97) {
|
|
56279
56298
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
56280
56299
|
}
|
|
56281
56300
|
try {
|
|
56282
|
-
const data = await readFile(resolve3(
|
|
56301
|
+
const data = await readFile(resolve3(path97), "utf8");
|
|
56283
56302
|
const parsed = JSON.parse(data);
|
|
56284
56303
|
if (Array.isArray(parsed)) {
|
|
56285
56304
|
this.#snapshots.clear();
|
|
@@ -56293,7 +56312,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
56293
56312
|
if (error63.code === "ENOENT") {
|
|
56294
56313
|
this.#snapshots.clear();
|
|
56295
56314
|
} else {
|
|
56296
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
56315
|
+
throw new UndiciError(`Failed to load snapshots from ${path97}`, { cause: error63 });
|
|
56297
56316
|
}
|
|
56298
56317
|
}
|
|
56299
56318
|
}
|
|
@@ -56304,11 +56323,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
56304
56323
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
56305
56324
|
*/
|
|
56306
56325
|
async saveSnapshots(filePath) {
|
|
56307
|
-
const
|
|
56308
|
-
if (!
|
|
56326
|
+
const path97 = filePath || this.#snapshotPath;
|
|
56327
|
+
if (!path97) {
|
|
56309
56328
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
56310
56329
|
}
|
|
56311
|
-
const resolvedPath = resolve3(
|
|
56330
|
+
const resolvedPath = resolve3(path97);
|
|
56312
56331
|
await mkdir(dirname3(resolvedPath), { recursive: true });
|
|
56313
56332
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
56314
56333
|
hash: hash2,
|
|
@@ -56945,15 +56964,15 @@ var require_redirect_handler = __commonJS({
|
|
|
56945
56964
|
}
|
|
56946
56965
|
this.history[kRedirectCacheControl].push(headers["cache-control"]);
|
|
56947
56966
|
const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
56948
|
-
const
|
|
56949
|
-
const redirectUrlString = `${origin}${
|
|
56967
|
+
const path97 = search ? `${pathname}${search}` : pathname;
|
|
56968
|
+
const redirectUrlString = `${origin}${path97}`;
|
|
56950
56969
|
for (const historyUrl of this.history) {
|
|
56951
56970
|
if (historyUrl.toString() === redirectUrlString) {
|
|
56952
56971
|
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.`);
|
|
56953
56972
|
}
|
|
56954
56973
|
}
|
|
56955
56974
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
56956
|
-
this.opts.path =
|
|
56975
|
+
this.opts.path = path97;
|
|
56957
56976
|
this.opts.origin = origin;
|
|
56958
56977
|
this.opts.query = null;
|
|
56959
56978
|
}
|
|
@@ -58721,10 +58740,10 @@ var require_cache_handler = __commonJS({
|
|
|
58721
58740
|
}
|
|
58722
58741
|
return locationUrl.pathname + locationUrl.search;
|
|
58723
58742
|
}
|
|
58724
|
-
function deleteCachedUri(store, cacheKey,
|
|
58743
|
+
function deleteCachedUri(store, cacheKey, path97) {
|
|
58725
58744
|
deleteCachedValue(store, {
|
|
58726
58745
|
...cacheKey,
|
|
58727
|
-
path:
|
|
58746
|
+
path: path97
|
|
58728
58747
|
});
|
|
58729
58748
|
for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
|
|
58730
58749
|
const method = util2.safeHTTPMethods[i10];
|
|
@@ -58732,7 +58751,7 @@ var require_cache_handler = __commonJS({
|
|
|
58732
58751
|
deleteCachedValue(store, {
|
|
58733
58752
|
...cacheKey,
|
|
58734
58753
|
method,
|
|
58735
|
-
path:
|
|
58754
|
+
path: path97
|
|
58736
58755
|
});
|
|
58737
58756
|
}
|
|
58738
58757
|
}
|
|
@@ -58743,9 +58762,9 @@ var require_cache_handler = __commonJS({
|
|
|
58743
58762
|
}
|
|
58744
58763
|
const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
|
|
58745
58764
|
for (let i10 = 0; i10 < values.length; i10++) {
|
|
58746
|
-
const
|
|
58747
|
-
if (
|
|
58748
|
-
deleteCachedUri(store, cacheKey,
|
|
58765
|
+
const path97 = getSameOriginPath(cacheKey, values[i10]);
|
|
58766
|
+
if (path97 !== void 0) {
|
|
58767
|
+
deleteCachedUri(store, cacheKey, path97);
|
|
58749
58768
|
}
|
|
58750
58769
|
}
|
|
58751
58770
|
}
|
|
@@ -63956,11 +63975,11 @@ var require_fetch = __commonJS({
|
|
|
63956
63975
|
function dispatch({ body }) {
|
|
63957
63976
|
const url2 = requestCurrentURL(request7);
|
|
63958
63977
|
const agent = fetchParams.controller.dispatcher;
|
|
63959
|
-
const
|
|
63978
|
+
const path97 = url2.pathname + url2.search;
|
|
63960
63979
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
63961
63980
|
return new Promise((resolve3, reject) => agent.dispatch(
|
|
63962
63981
|
{
|
|
63963
|
-
path: hasTrailingQuestionMark ? `${
|
|
63982
|
+
path: hasTrailingQuestionMark ? `${path97}?` : path97,
|
|
63964
63983
|
origin: url2.origin,
|
|
63965
63984
|
method: request7.method,
|
|
63966
63985
|
body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
|
|
@@ -64907,9 +64926,9 @@ var require_util5 = __commonJS({
|
|
|
64907
64926
|
}
|
|
64908
64927
|
}
|
|
64909
64928
|
}
|
|
64910
|
-
function validateCookiePath(
|
|
64911
|
-
for (let i10 = 0; i10 <
|
|
64912
|
-
const code =
|
|
64929
|
+
function validateCookiePath(path97) {
|
|
64930
|
+
for (let i10 = 0; i10 < path97.length; ++i10) {
|
|
64931
|
+
const code = path97.charCodeAt(i10);
|
|
64913
64932
|
if (code < 32 || // exclude CTLs (0-31)
|
|
64914
64933
|
code > 126 || // exclude DEL and non-ascii
|
|
64915
64934
|
code === 59) {
|
|
@@ -68345,11 +68364,11 @@ var require_undici = __commonJS({
|
|
|
68345
68364
|
if (typeof opts.path !== "string") {
|
|
68346
68365
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
68347
68366
|
}
|
|
68348
|
-
let
|
|
68367
|
+
let path97 = opts.path;
|
|
68349
68368
|
if (!opts.path.startsWith("/")) {
|
|
68350
|
-
|
|
68369
|
+
path97 = `/${path97}`;
|
|
68351
68370
|
}
|
|
68352
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
68371
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path97);
|
|
68353
68372
|
} else {
|
|
68354
68373
|
if (!opts) {
|
|
68355
68374
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -70493,7 +70512,7 @@ function withSupervision(passthrough, supervised) {
|
|
|
70493
70512
|
if (supervised.conversation === "as-given") {
|
|
70494
70513
|
return passthrough;
|
|
70495
70514
|
}
|
|
70496
|
-
const conversed = withConversation(passthrough, supervised.conversation, supervised.sessionId);
|
|
70515
|
+
const conversed = withConversation(passthrough, supervised.conversation, supervised.conversationId ?? supervised.sessionId);
|
|
70497
70516
|
if (supervised.model === void 0) {
|
|
70498
70517
|
return conversed;
|
|
70499
70518
|
}
|
|
@@ -70518,11 +70537,64 @@ function withLauncherSettings(passthrough, settings2) {
|
|
|
70518
70537
|
return passthrough;
|
|
70519
70538
|
}
|
|
70520
70539
|
const end = passthrough.indexOf(TERMINATOR2);
|
|
70521
|
-
|
|
70540
|
+
const head = end === -1 ? passthrough : passthrough.slice(0, end);
|
|
70541
|
+
const tail = end === -1 ? [] : passthrough.slice(end);
|
|
70542
|
+
const kept = [];
|
|
70543
|
+
for (let index = 0; index < head.length; index += 1) {
|
|
70544
|
+
const token = head[index];
|
|
70545
|
+
if (token === "--settings") {
|
|
70546
|
+
index += 1;
|
|
70547
|
+
} else if (token !== void 0 && !token.startsWith("--settings=")) {
|
|
70548
|
+
kept.push(token);
|
|
70549
|
+
}
|
|
70550
|
+
}
|
|
70551
|
+
return [...kept, "--settings", settings2, ...tail];
|
|
70522
70552
|
}
|
|
70523
70553
|
function isRecord6(value3) {
|
|
70524
70554
|
return typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
|
|
70525
70555
|
}
|
|
70556
|
+
function isUnknownArray(value3) {
|
|
70557
|
+
return Array.isArray(value3);
|
|
70558
|
+
}
|
|
70559
|
+
function combineCallerSettings(passthrough, launcherSettings, read) {
|
|
70560
|
+
const end = passthrough.indexOf(TERMINATOR2);
|
|
70561
|
+
const head = end === -1 ? passthrough : passthrough.slice(0, end);
|
|
70562
|
+
let argument;
|
|
70563
|
+
for (let index = 0; index < head.length; index += 1) {
|
|
70564
|
+
const token = head[index];
|
|
70565
|
+
if (token === "--settings") {
|
|
70566
|
+
argument = head[index + 1];
|
|
70567
|
+
index += 1;
|
|
70568
|
+
} else if (token?.startsWith("--settings=") === true) {
|
|
70569
|
+
argument = token.slice("--settings=".length);
|
|
70570
|
+
}
|
|
70571
|
+
}
|
|
70572
|
+
if (argument === void 0 || argument === "") {
|
|
70573
|
+
throw new Error("--settings requires a JSON object or settings file");
|
|
70574
|
+
}
|
|
70575
|
+
const contents = argument.trimStart().startsWith("{") ? argument : read(argument);
|
|
70576
|
+
if (contents === void 0) {
|
|
70577
|
+
throw new Error(`cannot read settings file ${argument}`);
|
|
70578
|
+
}
|
|
70579
|
+
const caller = JSON.parse(contents);
|
|
70580
|
+
const added = JSON.parse(launcherSettings);
|
|
70581
|
+
if (!isRecord6(caller) || !isRecord6(added) || !isRecord6(added.hooks)) {
|
|
70582
|
+
throw new Error("settings must be JSON objects with launcher hooks");
|
|
70583
|
+
}
|
|
70584
|
+
const callerHooks = caller.hooks;
|
|
70585
|
+
if (callerHooks !== void 0 && !isRecord6(callerHooks)) {
|
|
70586
|
+
throw new Error("settings hooks must be an object");
|
|
70587
|
+
}
|
|
70588
|
+
const hooks = { ...callerHooks };
|
|
70589
|
+
for (const [event, value3] of Object.entries(added.hooks)) {
|
|
70590
|
+
const existing = hooks[event];
|
|
70591
|
+
if (!isUnknownArray(value3) || existing !== void 0 && !isUnknownArray(existing)) {
|
|
70592
|
+
throw new Error(`settings hooks for ${event} must be arrays`);
|
|
70593
|
+
}
|
|
70594
|
+
hooks[event] = existing === void 0 ? value3 : [...existing, ...value3];
|
|
70595
|
+
}
|
|
70596
|
+
return JSON.stringify({ ...caller, ...added, hooks });
|
|
70597
|
+
}
|
|
70526
70598
|
function mergeSettings(parts) {
|
|
70527
70599
|
const merged = {};
|
|
70528
70600
|
let any2 = false;
|
|
@@ -72999,7 +73071,8 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
72999
73071
|
const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
|
|
73000
73072
|
const globalModels = loadConfigFile(paths.globalConfigFile, GlobalConfigSchema, params.fs.readConfigFile)?.config.models;
|
|
73001
73073
|
const models = launchCascade !== void 0 && params.farm !== void 0 ? cascadeModels : globalModels;
|
|
73002
|
-
const
|
|
73074
|
+
const extraFlags = splitExtraFlags(env.CLAUDE_EXTRA_FLAGS);
|
|
73075
|
+
const callerSettings = hasSettingsArgument([...extraFlags, ...parsedArgv.rest]);
|
|
73003
73076
|
const startsSession = !isClaudeSubcommand(parsedArgv.rest);
|
|
73004
73077
|
const argsForSupervisor = (supervisorPid) => {
|
|
73005
73078
|
const door = readFrontDoorState(params.fs, paths.frontdoorStateFile);
|
|
@@ -73033,10 +73106,10 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
73033
73106
|
}
|
|
73034
73107
|
});
|
|
73035
73108
|
const pickerSettings = modelPickerSettingsFromRows(routedModelRows(models ?? {}, listedProviders), selectedProvider !== void 0);
|
|
73036
|
-
const launcherSettings = mergeSettings([params.supervised?.settings, callerSettings ? void 0 : pickerSettings]);
|
|
73109
|
+
const launcherSettings = params.supervised?.settingsFile ?? mergeSettings([params.supervised?.settings, callerSettings ? void 0 : pickerSettings]);
|
|
73037
73110
|
const args2 = startsSession ? buildArgv({
|
|
73038
73111
|
toolFlags: buildFlagArgs(flags),
|
|
73039
|
-
extraFlags
|
|
73112
|
+
extraFlags,
|
|
73040
73113
|
passthrough: withLauncherSettings(params.supervised === void 0 ? parsedArgv.rest : withSupervision(parsedArgv.rest, params.supervised), launcherSettings)
|
|
73041
73114
|
}) : [...parsedArgv.rest];
|
|
73042
73115
|
return { args: args2, pickerSuppressed: startsSession && pickerSettings !== void 0 && callerSettings };
|
|
@@ -112992,8 +113065,8 @@ var require_utils3 = __commonJS({
|
|
|
112992
113065
|
}
|
|
112993
113066
|
return ind;
|
|
112994
113067
|
}
|
|
112995
|
-
function removeDotSegments(
|
|
112996
|
-
let input2 =
|
|
113068
|
+
function removeDotSegments(path97) {
|
|
113069
|
+
let input2 = path97;
|
|
112997
113070
|
const output2 = [];
|
|
112998
113071
|
let nextSlash = -1;
|
|
112999
113072
|
let len = 0;
|
|
@@ -113067,11 +113140,11 @@ var require_utils3 = __commonJS({
|
|
|
113067
113140
|
}
|
|
113068
113141
|
return output2.join("");
|
|
113069
113142
|
}
|
|
113070
|
-
function removeDotSegmentsRelative(
|
|
113071
|
-
if (
|
|
113072
|
-
return removeDotSegments(
|
|
113143
|
+
function removeDotSegmentsRelative(path97) {
|
|
113144
|
+
if (path97 === "" || path97[0] === "/") {
|
|
113145
|
+
return removeDotSegments(path97);
|
|
113073
113146
|
}
|
|
113074
|
-
const segments =
|
|
113147
|
+
const segments = path97.split("/");
|
|
113075
113148
|
const last = segments.length - 1;
|
|
113076
113149
|
const output2 = [];
|
|
113077
113150
|
let trailingDirectory = false;
|
|
@@ -113434,8 +113507,8 @@ var require_schemes = __commonJS({
|
|
|
113434
113507
|
}
|
|
113435
113508
|
if (wsComponent.resourceName) {
|
|
113436
113509
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
113437
|
-
const
|
|
113438
|
-
wsComponent.path =
|
|
113510
|
+
const path97 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
113511
|
+
wsComponent.path = path97 && path97 !== "/" ? path97 : void 0;
|
|
113439
113512
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
113440
113513
|
wsComponent.resourceName = void 0;
|
|
113441
113514
|
}
|
|
@@ -116986,7 +117059,7 @@ var require_dist2 = __commonJS({
|
|
|
116986
117059
|
});
|
|
116987
117060
|
|
|
116988
117061
|
// src/cli.ts
|
|
116989
|
-
var
|
|
117062
|
+
var import_node_path96 = __toESM(require("node:path"), 1);
|
|
116990
117063
|
|
|
116991
117064
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
116992
117065
|
var CommanderError = class extends Error {
|
|
@@ -120099,9 +120172,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
120099
120172
|
* @param {string} [path]
|
|
120100
120173
|
* @return {(string|null|Command)}
|
|
120101
120174
|
*/
|
|
120102
|
-
executableDir(
|
|
120103
|
-
if (
|
|
120104
|
-
this._executableDir =
|
|
120175
|
+
executableDir(path97) {
|
|
120176
|
+
if (path97 === void 0) return this._executableDir;
|
|
120177
|
+
this._executableDir = path97;
|
|
120105
120178
|
return this;
|
|
120106
120179
|
}
|
|
120107
120180
|
/**
|
|
@@ -121696,6 +121769,39 @@ function writeEntriesPatch(paths, target, patch) {
|
|
|
121696
121769
|
return;
|
|
121697
121770
|
}
|
|
121698
121771
|
}
|
|
121772
|
+
async function configureClassifications(deps, claudeHome) {
|
|
121773
|
+
const names = classifyEntries([...realFarmFs.readdir(claudeHome)].sort(), loadClassification(deps.paths)).unclassified;
|
|
121774
|
+
const categories = ["secret", ...OVERRIDABLE_CATEGORIES];
|
|
121775
|
+
const additions = { secret: [], runtime: [], history: [], knowledge: [], settings: [] };
|
|
121776
|
+
for (const name of names) {
|
|
121777
|
+
const chosen = await deps.prompts.select({
|
|
121778
|
+
message: `Classify "${name}"`,
|
|
121779
|
+
options: [
|
|
121780
|
+
{ value: "skip", label: "Leave unclassified", hint: "excluded until classified" },
|
|
121781
|
+
...categories.map((category) => ({ value: category, label: category, ...category === "secret" ? { hint: "never shared" } : {} }))
|
|
121782
|
+
],
|
|
121783
|
+
initialValue: "skip"
|
|
121784
|
+
});
|
|
121785
|
+
if (deps.prompts.isCancel(chosen)) {
|
|
121786
|
+
deps.prompts.cancel("Cancelled.");
|
|
121787
|
+
return false;
|
|
121788
|
+
}
|
|
121789
|
+
if (chosen !== "skip") {
|
|
121790
|
+
additions[chosen].push(literalClassificationPattern(name));
|
|
121791
|
+
}
|
|
121792
|
+
}
|
|
121793
|
+
if (categories.some((category) => additions[category].length > 0)) {
|
|
121794
|
+
const overlay2 = readJson(deps.paths.categoriesLocalFile, CategoryClassificationOverlaySchema) ?? {};
|
|
121795
|
+
for (const category of categories) {
|
|
121796
|
+
if (additions[category].length > 0) {
|
|
121797
|
+
overlay2[category] = [...overlay2[category] ?? [], ...additions[category]];
|
|
121798
|
+
}
|
|
121799
|
+
}
|
|
121800
|
+
applyPatch(deps.paths.categoriesLocalFile, CategoryClassificationOverlaySchema, overlay2, { defaults: {} });
|
|
121801
|
+
deps.log.info("Updated the local category map.");
|
|
121802
|
+
}
|
|
121803
|
+
return true;
|
|
121804
|
+
}
|
|
121699
121805
|
function parentOf3(relPath) {
|
|
121700
121806
|
const index = relPath.lastIndexOf("/");
|
|
121701
121807
|
return index === -1 ? "" : relPath.slice(0, index);
|
|
@@ -122012,26 +122118,31 @@ async function runConfigure(deps, params) {
|
|
|
122012
122118
|
function registerConfigureCommand(program2, deps) {
|
|
122013
122119
|
const { paths } = deps;
|
|
122014
122120
|
const command = program2.command("configure [path]").description(
|
|
122015
|
-
"
|
|
122121
|
+
"Classify unknown top-level entries, then interactively configure an identity's shared categories or entries."
|
|
122016
122122
|
).option("--identity <name>", "Identity to configure (defaults to the identity a launch here would resolve).").action(async (pathArg, options) => {
|
|
122017
122123
|
const cwd = process.cwd();
|
|
122018
122124
|
if (!deps.isInteractive()) {
|
|
122019
122125
|
throw new ConfigureNeedsTerminalError();
|
|
122020
122126
|
}
|
|
122127
|
+
const configureDeps = { paths, prompts: deps.prompts, log: { info: (message) => {
|
|
122128
|
+
console.log(message);
|
|
122129
|
+
} } };
|
|
122130
|
+
const claudeHome = resolveClaudeHome();
|
|
122131
|
+
if (!await configureClassifications(configureDeps, claudeHome)) {
|
|
122132
|
+
return;
|
|
122133
|
+
}
|
|
122021
122134
|
const identityName = options.identity ?? resolveLaunchIdentity(paths, cwd);
|
|
122022
122135
|
if (identityName === void 0) {
|
|
122023
122136
|
throw new NoIdentityResolvedError(cwd);
|
|
122024
122137
|
}
|
|
122025
122138
|
await runConfigure(
|
|
122026
|
-
|
|
122027
|
-
console.log(message);
|
|
122028
|
-
} } },
|
|
122139
|
+
configureDeps,
|
|
122029
122140
|
{
|
|
122030
122141
|
identityName,
|
|
122031
122142
|
...pathArg === void 0 ? {} : { path: pathArg },
|
|
122032
122143
|
cwd,
|
|
122033
122144
|
home: import_node_os4.default.homedir(),
|
|
122034
|
-
claudeHome
|
|
122145
|
+
claudeHome
|
|
122035
122146
|
}
|
|
122036
122147
|
);
|
|
122037
122148
|
});
|
|
@@ -122391,7 +122502,7 @@ function statuslineChangeOf(options) {
|
|
|
122391
122502
|
return void 0;
|
|
122392
122503
|
}
|
|
122393
122504
|
const assignments = (options.statusline ?? []).map(parseStatuslineAssignment);
|
|
122394
|
-
return { set: Object.fromEntries(assignments.map(({ path:
|
|
122505
|
+
return { set: Object.fromEntries(assignments.map(({ path: path97, value: value3 }) => [path97, value3])), unset: options.unsetStatusline ?? [] };
|
|
122395
122506
|
}
|
|
122396
122507
|
function registerProfileCommand(program2, deps) {
|
|
122397
122508
|
const { paths } = deps;
|
|
@@ -125800,6 +125911,14 @@ var SupervisedSessionSchema = external_exports.strictObject({
|
|
|
125800
125911
|
var SessionStateSchema = external_exports.strictObject({
|
|
125801
125912
|
/** `busy` from the moment a prompt is submitted until the turn ends, `idle` from then until the next prompt: the only times the child can be stopped without losing a turn. */
|
|
125802
125913
|
mark: external_exports.enum(["busy", "idle"]),
|
|
125914
|
+
/** The current Claude conversation when it differs from the launch id, for example after /clear. */
|
|
125915
|
+
conversationId: external_exports.uuid().optional(),
|
|
125916
|
+
/** Claude's own path for the current conversation transcript. */
|
|
125917
|
+
transcriptPath: external_exports.string().min(1).optional(),
|
|
125918
|
+
/** Claude's identifier for the most recently submitted prompt. */
|
|
125919
|
+
promptId: external_exports.uuid().optional(),
|
|
125920
|
+
/** A hook failed to establish the current conversation, so the saved id must not be used for a move. */
|
|
125921
|
+
unavailable: external_exports.literal(true).optional(),
|
|
125803
125922
|
/** The size in tokens of the context as of the last turn that ended; absent until one has. */
|
|
125804
125923
|
contextTokens: external_exports.number().int().nonnegative().optional(),
|
|
125805
125924
|
/** Whether the session was compacted during its stay on the member it runs on now. Set by the supervisor, kept by later marks, and cleared when the session moves. */
|
|
@@ -126945,8 +127064,8 @@ function pathnameOf(url2) {
|
|
|
126945
127064
|
return new URL(url2 ?? "/", "http://127.0.0.1").pathname;
|
|
126946
127065
|
}
|
|
126947
127066
|
function isRcSessionExchange(url2) {
|
|
126948
|
-
const
|
|
126949
|
-
return
|
|
127067
|
+
const path97 = pathnameOf(url2);
|
|
127068
|
+
return path97 === RC_SESSIONS_PATH_PREFIX || path97.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
|
|
126950
127069
|
}
|
|
126951
127070
|
var RC_SESSION_ID_PREFIX = "cse_";
|
|
126952
127071
|
var RC_IDLE_EXPIRY_MS = 45e3;
|
|
@@ -127484,8 +127603,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
127484
127603
|
function isRcReadFileEncoding(value3) {
|
|
127485
127604
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value3);
|
|
127486
127605
|
}
|
|
127487
|
-
function buildRcReadFilePayload(requestId,
|
|
127488
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
127606
|
+
function buildRcReadFilePayload(requestId, path97, options) {
|
|
127607
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path97, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
127489
127608
|
}
|
|
127490
127609
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
127491
127610
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -127587,15 +127706,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
127587
127706
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
127588
127707
|
return result.ok ? { ...result, requestId } : result;
|
|
127589
127708
|
}
|
|
127590
|
-
async function readRcSessionFile(deps, sessionId,
|
|
127591
|
-
if (
|
|
127709
|
+
async function readRcSessionFile(deps, sessionId, path97, options) {
|
|
127710
|
+
if (path97 === "") {
|
|
127592
127711
|
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" };
|
|
127593
127712
|
}
|
|
127594
127713
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
127595
127714
|
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" };
|
|
127596
127715
|
}
|
|
127597
127716
|
const requestId = deps.newUuid();
|
|
127598
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
127717
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path97, options), `read ${path97} from session ${sessionId}`);
|
|
127599
127718
|
return result.ok ? { ...result, requestId } : result;
|
|
127600
127719
|
}
|
|
127601
127720
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -127778,11 +127897,11 @@ function createRcControlHandler(deps) {
|
|
|
127778
127897
|
path: "read-file",
|
|
127779
127898
|
read: (body) => {
|
|
127780
127899
|
const session = bodyString(body, "session");
|
|
127781
|
-
const
|
|
127900
|
+
const path97 = bodyString(body, "path");
|
|
127782
127901
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
127783
127902
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
127784
|
-
const refused2 = session === void 0 ||
|
|
127785
|
-
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,
|
|
127903
|
+
const refused2 = session === void 0 || path97 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
127904
|
+
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, path97, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
127786
127905
|
}
|
|
127787
127906
|
},
|
|
127788
127907
|
{
|
|
@@ -128092,9 +128211,9 @@ function requestIdOfBody(body) {
|
|
|
128092
128211
|
}
|
|
128093
128212
|
function frontDoorRcControl(transport, token) {
|
|
128094
128213
|
const headers = { authorization: `Bearer ${token}` };
|
|
128095
|
-
const listAnswerOf = async (
|
|
128214
|
+
const listAnswerOf = async (path97, what) => {
|
|
128096
128215
|
try {
|
|
128097
|
-
return await transport.request({ method: "GET", path:
|
|
128216
|
+
return await transport.request({ method: "GET", path: path97, headers });
|
|
128098
128217
|
} catch (error63) {
|
|
128099
128218
|
throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
|
|
128100
128219
|
}
|
|
@@ -128166,10 +128285,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
128166
128285
|
}
|
|
128167
128286
|
return pending;
|
|
128168
128287
|
};
|
|
128169
|
-
const writeOf = async (
|
|
128288
|
+
const writeOf = async (path97, body, describeFailure2) => {
|
|
128170
128289
|
let answer;
|
|
128171
128290
|
try {
|
|
128172
|
-
answer = await transport.request({ method: "POST", path:
|
|
128291
|
+
answer = await transport.request({ method: "POST", path: path97, headers: { ...headers, "content-type": "application/json" }, body });
|
|
128173
128292
|
} catch (error63) {
|
|
128174
128293
|
return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
|
|
128175
128294
|
}
|
|
@@ -128200,10 +128319,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
128200
128319
|
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}`),
|
|
128201
128320
|
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}`),
|
|
128202
128321
|
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}`),
|
|
128203
|
-
readFile: async (sessionId,
|
|
128322
|
+
readFile: async (sessionId, path97, options) => await writeOf(
|
|
128204
128323
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
128205
|
-
JSON.stringify({ session: sessionId, path:
|
|
128206
|
-
(status, message) => `reading ${
|
|
128324
|
+
JSON.stringify({ session: sessionId, path: path97, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
128325
|
+
(status, message) => `reading ${path97} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
128207
128326
|
),
|
|
128208
128327
|
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}`),
|
|
128209
128328
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -128609,12 +128728,12 @@ function tlsFacts(options) {
|
|
|
128609
128728
|
}
|
|
128610
128729
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
128611
128730
|
const agent = new ExemptTlsAgent();
|
|
128612
|
-
const post = async (
|
|
128731
|
+
const post = async (path97, headers, body) => await new Promise((resolve3, reject) => {
|
|
128613
128732
|
const options = {
|
|
128614
128733
|
host: target.host,
|
|
128615
128734
|
port: target.port,
|
|
128616
128735
|
method: "POST",
|
|
128617
|
-
path:
|
|
128736
|
+
path: path97,
|
|
128618
128737
|
// 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.
|
|
128619
128738
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
128620
128739
|
agent
|
|
@@ -128679,12 +128798,12 @@ function lateRcStreamDial(resolve3) {
|
|
|
128679
128798
|
}
|
|
128680
128799
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
128681
128800
|
const agent = new ExemptTlsAgent();
|
|
128682
|
-
const request7 = async (method,
|
|
128801
|
+
const request7 = async (method, path97, headers, body, signal) => await new Promise((resolve3, reject) => {
|
|
128683
128802
|
const options = {
|
|
128684
128803
|
host: target.host,
|
|
128685
128804
|
port: target.port,
|
|
128686
128805
|
method,
|
|
128687
|
-
path:
|
|
128806
|
+
path: path97,
|
|
128688
128807
|
// 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.
|
|
128689
128808
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
128690
128809
|
agent,
|
|
@@ -128726,9 +128845,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
128726
128845
|
return { status, body: await readAll(response) };
|
|
128727
128846
|
},
|
|
128728
128847
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
128729
|
-
const
|
|
128848
|
+
const path97 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
128730
128849
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
128731
|
-
const { status, response } = await request7("GET",
|
|
128850
|
+
const { status, response } = await request7("GET", path97, streamHeaders, void 0, signal);
|
|
128732
128851
|
if (!isSuccessful2(status)) {
|
|
128733
128852
|
await readAll(response);
|
|
128734
128853
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -130408,8 +130527,8 @@ function once(fn) {
|
|
|
130408
130527
|
return result;
|
|
130409
130528
|
};
|
|
130410
130529
|
}
|
|
130411
|
-
function pathToHttpPath(
|
|
130412
|
-
return `/${
|
|
130530
|
+
function pathToHttpPath(path97) {
|
|
130531
|
+
return `/${path97.map(safeEncodeURIComponent).join("/")}`;
|
|
130413
130532
|
}
|
|
130414
130533
|
var TRACER_SYMBOL = /* @__PURE__ */ Symbol.for("ORPC_TRACER");
|
|
130415
130534
|
function getTracer() {
|
|
@@ -131688,7 +131807,7 @@ function resolveClientRest(rest) {
|
|
|
131688
131807
|
// rest[1] can be undefined if all fields of FriendlyClientOptions are optional
|
|
131689
131808
|
];
|
|
131690
131809
|
}
|
|
131691
|
-
function createORPCClient(link, { path:
|
|
131810
|
+
function createORPCClient(link, { path: path97 = [], ...options } = {}) {
|
|
131692
131811
|
const procedureClient = (...rest) => {
|
|
131693
131812
|
const [input2, callOptions] = resolveClientRest(rest);
|
|
131694
131813
|
const interceptors = [
|
|
@@ -131697,7 +131816,7 @@ function createORPCClient(link, { path: path92 = [], ...options } = {}) {
|
|
|
131697
131816
|
];
|
|
131698
131817
|
return intercept(
|
|
131699
131818
|
interceptors,
|
|
131700
|
-
{ ...callOptions, input: input2, path:
|
|
131819
|
+
{ ...callOptions, input: input2, path: path97 },
|
|
131701
131820
|
({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
|
|
131702
131821
|
);
|
|
131703
131822
|
};
|
|
@@ -131711,7 +131830,7 @@ function createORPCClient(link, { path: path92 = [], ...options } = {}) {
|
|
|
131711
131830
|
if (client === void 0) {
|
|
131712
131831
|
client = createORPCClient(link, {
|
|
131713
131832
|
...options,
|
|
131714
|
-
path: [...
|
|
131833
|
+
path: [...path97, key],
|
|
131715
131834
|
scoped: options.scoped?.[key]
|
|
131716
131835
|
});
|
|
131717
131836
|
cache.set(key, client);
|
|
@@ -131952,11 +132071,11 @@ function tryOrUndefined(fn) {
|
|
|
131952
132071
|
return void 0;
|
|
131953
132072
|
}
|
|
131954
132073
|
}
|
|
131955
|
-
function pathToHttpPath2(
|
|
131956
|
-
return `/${
|
|
132074
|
+
function pathToHttpPath2(path97) {
|
|
132075
|
+
return `/${path97.map(safeEncodeURIComponent2).join("/")}`;
|
|
131957
132076
|
}
|
|
131958
|
-
function normalizeHttpPath(
|
|
131959
|
-
const paths =
|
|
132077
|
+
function normalizeHttpPath(path97) {
|
|
132078
|
+
const paths = path97.split("/");
|
|
131960
132079
|
if (paths.at(0) === "") {
|
|
131961
132080
|
paths.shift();
|
|
131962
132081
|
}
|
|
@@ -132141,9 +132260,9 @@ function isPlainObject4(value3) {
|
|
|
132141
132260
|
function getOwn(object3, key) {
|
|
132142
132261
|
return Object.hasOwn(object3, key) ? object3[key] : void 0;
|
|
132143
132262
|
}
|
|
132144
|
-
function get(object3,
|
|
132263
|
+
function get(object3, path97) {
|
|
132145
132264
|
let current = object3;
|
|
132146
|
-
for (const key of
|
|
132265
|
+
for (const key of path97) {
|
|
132147
132266
|
if (!isTypescriptObject2(current)) {
|
|
132148
132267
|
return void 0;
|
|
132149
132268
|
}
|
|
@@ -132384,25 +132503,25 @@ var BracketNotationSerializer = class {
|
|
|
132384
132503
|
this.internalSerialize(data, "", true, result);
|
|
132385
132504
|
return result;
|
|
132386
132505
|
}
|
|
132387
|
-
internalSerialize(data,
|
|
132506
|
+
internalSerialize(data, path97, isRoot, result) {
|
|
132388
132507
|
if (Array.isArray(data)) {
|
|
132389
132508
|
data.forEach((item, i10) => {
|
|
132390
|
-
this.internalSerialize(item, isRoot ? i10.toString() : `${
|
|
132509
|
+
this.internalSerialize(item, isRoot ? i10.toString() : `${path97}[${i10}]`, false, result);
|
|
132391
132510
|
});
|
|
132392
132511
|
} else if (isPlainObject4(data)) {
|
|
132393
132512
|
for (const key of Object.keys(data)) {
|
|
132394
|
-
this.internalSerialize(data[key], isRoot ? key : `${
|
|
132513
|
+
this.internalSerialize(data[key], isRoot ? key : `${path97}[${key}]`, false, result);
|
|
132395
132514
|
}
|
|
132396
132515
|
} else {
|
|
132397
|
-
result.push([
|
|
132516
|
+
result.push([path97, data]);
|
|
132398
132517
|
}
|
|
132399
132518
|
}
|
|
132400
132519
|
deserialize(serialized) {
|
|
132401
132520
|
let arrayPushStyles;
|
|
132402
132521
|
const root = new NullProtoObj2();
|
|
132403
132522
|
let emptySlotsLeft = this.maxDeserializingEmptySlots;
|
|
132404
|
-
for (const [
|
|
132405
|
-
const segments = this.parsePath(
|
|
132523
|
+
for (const [path97, value3] of serialized) {
|
|
132524
|
+
const segments = this.parsePath(path97);
|
|
132406
132525
|
let currentRef = root;
|
|
132407
132526
|
let nextSegment = segments[0];
|
|
132408
132527
|
for (let i10 = 1; i10 < segments.length; i10++) {
|
|
@@ -132462,20 +132581,20 @@ var BracketNotationSerializer = class {
|
|
|
132462
132581
|
}
|
|
132463
132582
|
return result;
|
|
132464
132583
|
}
|
|
132465
|
-
parsePath(
|
|
132466
|
-
const start =
|
|
132467
|
-
if (start === -1 ||
|
|
132468
|
-
return [
|
|
132584
|
+
parsePath(path97) {
|
|
132585
|
+
const start = path97.indexOf("[");
|
|
132586
|
+
if (start === -1 || path97[path97.length - 1] !== "]") {
|
|
132587
|
+
return [path97];
|
|
132469
132588
|
}
|
|
132470
|
-
const segments = [
|
|
132589
|
+
const segments = [path97.slice(0, start)];
|
|
132471
132590
|
let from = start + 1;
|
|
132472
|
-
let to2 =
|
|
132591
|
+
let to2 = path97.indexOf("][", from);
|
|
132473
132592
|
while (to2 !== -1) {
|
|
132474
|
-
segments.push(
|
|
132593
|
+
segments.push(path97.slice(from, to2));
|
|
132475
132594
|
from = to2 + 2;
|
|
132476
|
-
to2 =
|
|
132595
|
+
to2 = path97.indexOf("][", from);
|
|
132477
132596
|
}
|
|
132478
|
-
segments.push(
|
|
132597
|
+
segments.push(path97.slice(from, -1));
|
|
132479
132598
|
return segments;
|
|
132480
132599
|
}
|
|
132481
132600
|
};
|
|
@@ -133973,11 +134092,11 @@ var OpenAPISerializer = class {
|
|
|
133973
134092
|
return json2;
|
|
133974
134093
|
}
|
|
133975
134094
|
const form = new FormData();
|
|
133976
|
-
for (const [
|
|
134095
|
+
for (const [path97, value22] of this.bracketNotation.serialize(json2)) {
|
|
133977
134096
|
if (value22 instanceof Blob) {
|
|
133978
|
-
form.append(
|
|
134097
|
+
form.append(path97, value22);
|
|
133979
134098
|
} else if (value22 !== void 0 && value22 !== null) {
|
|
133980
|
-
form.append(
|
|
134099
|
+
form.append(path97, String(value22));
|
|
133981
134100
|
}
|
|
133982
134101
|
}
|
|
133983
134102
|
return form;
|
|
@@ -134015,30 +134134,30 @@ function isBodylessMethod(method) {
|
|
|
134015
134134
|
return method === "GET" || method === "HEAD";
|
|
134016
134135
|
}
|
|
134017
134136
|
var PARAMETER_NAME_REGEX = /^[\w-]+$/;
|
|
134018
|
-
function getDynamicPathParams(
|
|
134019
|
-
if (!
|
|
134137
|
+
function getDynamicPathParams(path97) {
|
|
134138
|
+
if (!path97.includes("{")) {
|
|
134020
134139
|
return void 0;
|
|
134021
134140
|
}
|
|
134022
|
-
const len =
|
|
134141
|
+
const len = path97.length;
|
|
134023
134142
|
let params;
|
|
134024
134143
|
let index = 1;
|
|
134025
134144
|
while (index < len) {
|
|
134026
134145
|
const segmentStart = index;
|
|
134027
|
-
const slashPos =
|
|
134146
|
+
const slashPos = path97.indexOf("/", index);
|
|
134028
134147
|
const segmentEnd = slashPos === -1 ? len : slashPos;
|
|
134029
|
-
if (segmentEnd > segmentStart &&
|
|
134148
|
+
if (segmentEnd > segmentStart && path97.charCodeAt(segmentStart) === 123 && path97.charCodeAt(segmentEnd - 1) === 125) {
|
|
134030
134149
|
let parameterStart = segmentStart + 1;
|
|
134031
134150
|
let allowsSlash = false;
|
|
134032
|
-
const operator =
|
|
134151
|
+
const operator = path97.charCodeAt(parameterStart);
|
|
134033
134152
|
if (operator === 43) {
|
|
134034
134153
|
allowsSlash = true;
|
|
134035
134154
|
parameterStart++;
|
|
134036
134155
|
}
|
|
134037
|
-
const parameterName =
|
|
134156
|
+
const parameterName = path97.slice(parameterStart, segmentEnd - 1);
|
|
134038
134157
|
if (PARAMETER_NAME_REGEX.test(parameterName)) {
|
|
134039
134158
|
params ??= [];
|
|
134040
134159
|
params.push({
|
|
134041
|
-
segment:
|
|
134160
|
+
segment: path97.slice(segmentStart, segmentEnd),
|
|
134042
134161
|
startIndex: segmentStart,
|
|
134043
134162
|
parameterName,
|
|
134044
134163
|
allowsSlash
|
|
@@ -134081,8 +134200,8 @@ openapi.method = (method) => ({
|
|
|
134081
134200
|
...openapi({ method }),
|
|
134082
134201
|
name: "~openapi/method"
|
|
134083
134202
|
});
|
|
134084
|
-
openapi.path = (
|
|
134085
|
-
...openapi({ path:
|
|
134203
|
+
openapi.path = (path97) => ({
|
|
134204
|
+
...openapi({ path: path97 }),
|
|
134086
134205
|
name: "~openapi/path"
|
|
134087
134206
|
});
|
|
134088
134207
|
openapi.spec = (spec) => ({
|
|
@@ -135001,22 +135120,22 @@ function visitJsonSchemaRefs(value3, visit2, schemaLevel = true, seen = /* @__PU
|
|
|
135001
135120
|
}
|
|
135002
135121
|
}
|
|
135003
135122
|
}
|
|
135004
|
-
function mapJsonSchemaRefs(value3, map3, schemaLevel = true,
|
|
135123
|
+
function mapJsonSchemaRefs(value3, map3, schemaLevel = true, path97 = []) {
|
|
135005
135124
|
if (!value3 || typeof value3 !== "object") {
|
|
135006
135125
|
return value3;
|
|
135007
135126
|
}
|
|
135008
135127
|
if (Array.isArray(value3)) {
|
|
135009
|
-
return value3.map((item, index) => mapJsonSchemaRefs(item, map3, schemaLevel, [...
|
|
135128
|
+
return value3.map((item, index) => mapJsonSchemaRefs(item, map3, schemaLevel, [...path97, index]));
|
|
135010
135129
|
}
|
|
135011
135130
|
const result = {};
|
|
135012
135131
|
for (const key of Object.keys(value3)) {
|
|
135013
135132
|
const val = value3[key];
|
|
135014
135133
|
if (key === "$ref" && typeof val === "string") {
|
|
135015
|
-
setOwn2(result, key, map3(val, [...
|
|
135134
|
+
setOwn2(result, key, map3(val, [...path97, key]));
|
|
135016
135135
|
} else if (!schemaLevel) {
|
|
135017
|
-
setOwn2(result, key, mapJsonSchemaRefs(val, map3, true, [...
|
|
135136
|
+
setOwn2(result, key, mapJsonSchemaRefs(val, map3, true, [...path97, key]));
|
|
135018
135137
|
} else if (JSON_SCHEMA_LOGIC_KEYWORDS.has(key) || JSON_SCHEMA_RECORD_KEYWORDS.has(key)) {
|
|
135019
|
-
setOwn2(result, key, mapJsonSchemaRefs(val, map3, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...
|
|
135138
|
+
setOwn2(result, key, mapJsonSchemaRefs(val, map3, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path97, key]));
|
|
135020
135139
|
} else {
|
|
135021
135140
|
setOwn2(result, key, val);
|
|
135022
135141
|
}
|
|
@@ -135546,7 +135665,7 @@ function unlazy(maybeLazy) {
|
|
|
135546
135665
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
135547
135666
|
const options = resolveMaybeOptionalOptions2(rest);
|
|
135548
135667
|
return async (...[input2, callerOptions]) => {
|
|
135549
|
-
const
|
|
135668
|
+
const path97 = toArray2(options.path);
|
|
135550
135669
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
135551
135670
|
const clientContext = callerOptions?.context ?? {};
|
|
135552
135671
|
const context = await value2(options.context, clientContext) ?? {};
|
|
@@ -135559,7 +135678,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
135559
135678
|
};
|
|
135560
135679
|
try {
|
|
135561
135680
|
const output2 = await runWithSpan2("call_procedure", (span) => {
|
|
135562
|
-
span?.setAttribute("procedure.path",
|
|
135681
|
+
span?.setAttribute("procedure.path", path97);
|
|
135563
135682
|
return intercept2(
|
|
135564
135683
|
options.interceptors,
|
|
135565
135684
|
{
|
|
@@ -135567,7 +135686,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
135567
135686
|
// input can be optional if it is undefinable
|
|
135568
135687
|
input: input2,
|
|
135569
135688
|
errors,
|
|
135570
|
-
path:
|
|
135689
|
+
path: path97,
|
|
135571
135690
|
procedure,
|
|
135572
135691
|
signal: callerOptions?.signal,
|
|
135573
135692
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -135818,10 +135937,10 @@ function augmentRouter(router, options) {
|
|
|
135818
135937
|
}
|
|
135819
135938
|
return enhanced;
|
|
135820
135939
|
}
|
|
135821
|
-
function getRouter(router,
|
|
135940
|
+
function getRouter(router, path97) {
|
|
135822
135941
|
let current = router;
|
|
135823
|
-
for (let i10 = 0; i10 <
|
|
135824
|
-
const segment =
|
|
135942
|
+
for (let i10 = 0; i10 < path97.length; i10++) {
|
|
135943
|
+
const segment = path97[i10];
|
|
135825
135944
|
if (!isTypescriptObject2(current)) {
|
|
135826
135945
|
return void 0;
|
|
135827
135946
|
}
|
|
@@ -135833,7 +135952,7 @@ function getRouter(router, path92) {
|
|
|
135833
135952
|
continue;
|
|
135834
135953
|
}
|
|
135835
135954
|
const lazied = current;
|
|
135836
|
-
const rest =
|
|
135955
|
+
const rest = path97.slice(i10);
|
|
135837
135956
|
return new Lazy({
|
|
135838
135957
|
...lazied["~orpc"],
|
|
135839
135958
|
async loader() {
|
|
@@ -135848,40 +135967,40 @@ function getRouter(router, path92) {
|
|
|
135848
135967
|
}
|
|
135849
135968
|
return current;
|
|
135850
135969
|
}
|
|
135851
|
-
function walkProcedureContractsSync(router, callback,
|
|
135970
|
+
function walkProcedureContractsSync(router, callback, path97 = []) {
|
|
135852
135971
|
const lazyResults = [];
|
|
135853
|
-
walkProcedureContractsSyncInternal(router, callback,
|
|
135972
|
+
walkProcedureContractsSyncInternal(router, callback, path97.slice(), lazyResults);
|
|
135854
135973
|
return lazyResults;
|
|
135855
135974
|
}
|
|
135856
|
-
function walkProcedureContractsSyncInternal(router, callback,
|
|
135975
|
+
function walkProcedureContractsSyncInternal(router, callback, path97, lazyResults) {
|
|
135857
135976
|
const hiddenContract = getHiddenRouterContract(router);
|
|
135858
135977
|
if (hiddenContract !== void 0) {
|
|
135859
135978
|
router = hiddenContract;
|
|
135860
135979
|
}
|
|
135861
135980
|
if (router instanceof ProcedureContract) {
|
|
135862
|
-
callback(router,
|
|
135981
|
+
callback(router, path97.slice());
|
|
135863
135982
|
return;
|
|
135864
135983
|
}
|
|
135865
135984
|
if (!isTypescriptObject2(router)) {
|
|
135866
135985
|
return;
|
|
135867
135986
|
}
|
|
135868
135987
|
for (const [key, value3] of Object.entries(router)) {
|
|
135869
|
-
|
|
135988
|
+
path97.push(key);
|
|
135870
135989
|
if (value3 instanceof Lazy) {
|
|
135871
|
-
lazyResults.push({ router: value3, path:
|
|
135990
|
+
lazyResults.push({ router: value3, path: path97.slice() });
|
|
135872
135991
|
} else {
|
|
135873
|
-
walkProcedureContractsSyncInternal(value3, callback,
|
|
135992
|
+
walkProcedureContractsSyncInternal(value3, callback, path97, lazyResults);
|
|
135874
135993
|
}
|
|
135875
|
-
|
|
135994
|
+
path97.pop();
|
|
135876
135995
|
}
|
|
135877
135996
|
}
|
|
135878
|
-
async function walkProcedureContractsAsync(router, callback,
|
|
135997
|
+
async function walkProcedureContractsAsync(router, callback, path97 = []) {
|
|
135879
135998
|
const hiddenContract = getHiddenRouterContract(router);
|
|
135880
135999
|
if (hiddenContract !== void 0) {
|
|
135881
136000
|
router = hiddenContract;
|
|
135882
136001
|
}
|
|
135883
136002
|
if (router instanceof ProcedureContract) {
|
|
135884
|
-
await callback(router,
|
|
136003
|
+
await callback(router, path97);
|
|
135885
136004
|
return;
|
|
135886
136005
|
}
|
|
135887
136006
|
if (!isTypescriptObject2(router)) {
|
|
@@ -135890,9 +136009,9 @@ async function walkProcedureContractsAsync(router, callback, path92 = []) {
|
|
|
135890
136009
|
for (const [key, value3] of Object.entries(router)) {
|
|
135891
136010
|
if (value3 instanceof Lazy) {
|
|
135892
136011
|
const { default: router2 } = await unlazy(value3);
|
|
135893
|
-
await walkProcedureContractsAsync(router2, callback, [...
|
|
136012
|
+
await walkProcedureContractsAsync(router2, callback, [...path97, key]);
|
|
135894
136013
|
} else {
|
|
135895
|
-
await walkProcedureContractsAsync(value3, callback, [...
|
|
136014
|
+
await walkProcedureContractsAsync(value3, callback, [...path97, key]);
|
|
135896
136015
|
}
|
|
135897
136016
|
}
|
|
135898
136017
|
}
|
|
@@ -136378,18 +136497,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
|
|
|
136378
136497
|
}
|
|
136379
136498
|
var OpenAPIGeneratorError = class extends TypeError {
|
|
136380
136499
|
};
|
|
136381
|
-
function toOpenAPIPath(
|
|
136500
|
+
function toOpenAPIPath(path97, dynamicPathParams) {
|
|
136382
136501
|
if (!dynamicPathParams?.length) {
|
|
136383
|
-
return
|
|
136502
|
+
return path97;
|
|
136384
136503
|
}
|
|
136385
136504
|
let normalized = "";
|
|
136386
136505
|
let currentIndex = 0;
|
|
136387
136506
|
for (const param of dynamicPathParams) {
|
|
136388
|
-
normalized +=
|
|
136507
|
+
normalized += path97.slice(currentIndex, param.startIndex);
|
|
136389
136508
|
normalized += `{${param.parameterName}}`;
|
|
136390
136509
|
currentIndex = param.startIndex + param.segment.length;
|
|
136391
136510
|
}
|
|
136392
|
-
normalized +=
|
|
136511
|
+
normalized += path97.slice(currentIndex);
|
|
136393
136512
|
return normalized;
|
|
136394
136513
|
}
|
|
136395
136514
|
function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
|
|
@@ -136846,8 +136965,8 @@ var OpenAPIGenerator = class {
|
|
|
136846
136965
|
customErrorResponseBodySchema: options.customErrorResponseBodySchema
|
|
136847
136966
|
};
|
|
136848
136967
|
const errors = [];
|
|
136849
|
-
await walkProcedureContractsAsync(router, (contract,
|
|
136850
|
-
if (value2(options.filter, contract,
|
|
136968
|
+
await walkProcedureContractsAsync(router, (contract, path97) => {
|
|
136969
|
+
if (value2(options.filter, contract, path97) === false) {
|
|
136851
136970
|
return;
|
|
136852
136971
|
}
|
|
136853
136972
|
try {
|
|
@@ -136859,7 +136978,7 @@ var OpenAPIGenerator = class {
|
|
|
136859
136978
|
`QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
|
|
136860
136979
|
);
|
|
136861
136980
|
}
|
|
136862
|
-
const postPath = meta3?.path ?? pathToHttpPath2(
|
|
136981
|
+
const postPath = meta3?.path ?? pathToHttpPath2(path97);
|
|
136863
136982
|
const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
|
|
136864
136983
|
const dynamicPathParams = getDynamicPathParams(httpPath);
|
|
136865
136984
|
const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
|
|
@@ -136868,7 +136987,7 @@ var OpenAPIGenerator = class {
|
|
|
136868
136987
|
operation = meta3.spec;
|
|
136869
136988
|
} else {
|
|
136870
136989
|
operation = {
|
|
136871
|
-
operationId: meta3?.operationId ??
|
|
136990
|
+
operationId: meta3?.operationId ?? path97.join("."),
|
|
136872
136991
|
summary: meta3?.summary,
|
|
136873
136992
|
description: meta3?.description,
|
|
136874
136993
|
deprecated: meta3?.deprecated,
|
|
@@ -136888,7 +137007,7 @@ var OpenAPIGenerator = class {
|
|
|
136888
137007
|
if (!(e10 instanceof OpenAPIGeneratorError)) {
|
|
136889
137008
|
throw e10;
|
|
136890
137009
|
}
|
|
136891
|
-
errors.push(`Procedure at ${
|
|
137010
|
+
errors.push(`Procedure at ${path97.join(".") || "(root)"}: ${e10.message}`);
|
|
136892
137011
|
}
|
|
136893
137012
|
});
|
|
136894
137013
|
if (errors.length) {
|
|
@@ -137674,16 +137793,16 @@ var StandardLink = class {
|
|
|
137674
137793
|
/**
|
|
137675
137794
|
* @throws ORPCError, MalformedResponseError, transport-level errors (network failures, timeouts, etc.)
|
|
137676
137795
|
*/
|
|
137677
|
-
call(
|
|
137678
|
-
return runWithSpan(`${ORPC_NAME}.${
|
|
137796
|
+
call(path97, input2, options) {
|
|
137797
|
+
return runWithSpan(`${ORPC_NAME}.${path97.join("/")}`, (span) => {
|
|
137679
137798
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
137680
|
-
span?.setAttribute("rpc.method",
|
|
137799
|
+
span?.setAttribute("rpc.method", path97.join("."));
|
|
137681
137800
|
if (getTracer() && isAsyncIteratorObject(input2)) {
|
|
137682
137801
|
input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
|
|
137683
137802
|
} else if (getTracer() && input2 instanceof ReadableStream) {
|
|
137684
137803
|
input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
|
|
137685
137804
|
}
|
|
137686
|
-
return intercept(this.interceptors, { ...options, path:
|
|
137805
|
+
return intercept(this.interceptors, { ...options, path: path97, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
137687
137806
|
const tracer = getTracer();
|
|
137688
137807
|
const activeSpan = tracer?.getActiveSpan() ?? span;
|
|
137689
137808
|
let request7 = await runWithSpan(
|
|
@@ -137740,18 +137859,18 @@ var RPCLinkCodec = class {
|
|
|
137740
137859
|
this.headers = options.headers ?? {};
|
|
137741
137860
|
this.serializer = options.serializer ?? new RPCSerializer();
|
|
137742
137861
|
}
|
|
137743
|
-
async encodeInput(input2,
|
|
137744
|
-
let headers = toResolvedStandardHeaders(await value(this.headers, options,
|
|
137862
|
+
async encodeInput(input2, path97, options) {
|
|
137863
|
+
let headers = toResolvedStandardHeaders(await value(this.headers, options, path97, input2));
|
|
137745
137864
|
if (options.lastEventId !== void 0) {
|
|
137746
137865
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
137747
137866
|
}
|
|
137748
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
137749
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
137867
|
+
const expectedMethod = await value(this.expectedMethod, options, path97, input2);
|
|
137868
|
+
const baseUrl = await value(this.baseUrl, options, path97, input2);
|
|
137750
137869
|
const [pathname, search, hash2] = parseStandardUrl(baseUrl);
|
|
137751
|
-
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(
|
|
137870
|
+
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path97)}`;
|
|
137752
137871
|
const serialized = this.serializer.serialize(input2);
|
|
137753
137872
|
if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
137754
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
137873
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path97, input2);
|
|
137755
137874
|
const mergedSearch = new URLSearchParams(search);
|
|
137756
137875
|
mergedSearch.append("data", stringifyJSON(serialized) ?? "");
|
|
137757
137876
|
const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
|
|
@@ -137838,8 +137957,8 @@ var FetchLinkTransport = class {
|
|
|
137838
137957
|
this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
|
|
137839
137958
|
this.toFetchRequestOptions = options.toFetchRequest;
|
|
137840
137959
|
}
|
|
137841
|
-
async send(standardRequest,
|
|
137842
|
-
let origin = await value(this.origin, options,
|
|
137960
|
+
async send(standardRequest, path97, options) {
|
|
137961
|
+
let origin = await value(this.origin, options, path97);
|
|
137843
137962
|
if (origin?.endsWith("/")) {
|
|
137844
137963
|
origin = origin.slice(0, -1);
|
|
137845
137964
|
}
|
|
@@ -137859,7 +137978,7 @@ var FetchLinkTransport = class {
|
|
|
137859
137978
|
}
|
|
137860
137979
|
}
|
|
137861
137980
|
const fetch3 = this.fetch;
|
|
137862
|
-
const response = await fetch3(url2, init, options,
|
|
137981
|
+
const response = await fetch3(url2, init, options, path97);
|
|
137863
137982
|
if (response.type === "opaqueredirect") {
|
|
137864
137983
|
throw new TypeError("Unexpected redirect response: redirects are not followed.");
|
|
137865
137984
|
}
|
|
@@ -138446,14 +138565,14 @@ var StandardHandler = class {
|
|
|
138446
138565
|
span?.setAttribute("url.path", request22.url);
|
|
138447
138566
|
return { matched: false };
|
|
138448
138567
|
}
|
|
138449
|
-
const { path:
|
|
138450
|
-
span?.updateName(`${ORPC_NAME2}.${
|
|
138568
|
+
const { path: path97, procedure, decodeInput } = matchedOrNot;
|
|
138569
|
+
span?.updateName(`${ORPC_NAME2}.${path97.join("/")}`);
|
|
138451
138570
|
span?.setAttribute("rpc.system", ORPC_NAME2);
|
|
138452
|
-
span?.setAttribute("rpc.method",
|
|
138571
|
+
span?.setAttribute("rpc.method", path97.join("."));
|
|
138453
138572
|
try {
|
|
138454
138573
|
const response = await intercept2(
|
|
138455
138574
|
this.interceptors,
|
|
138456
|
-
{ context: context2, prefix: prefix2, request: request22, path:
|
|
138575
|
+
{ context: context2, prefix: prefix2, request: request22, path: path97, procedure, decodeInput },
|
|
138457
138576
|
async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
|
|
138458
138577
|
step2 = "decode_input";
|
|
138459
138578
|
let input2 = await runWithSpan2("decode_input", decodeInput2);
|
|
@@ -138487,7 +138606,7 @@ var StandardHandler = class {
|
|
|
138487
138606
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
138488
138607
|
cause: e10
|
|
138489
138608
|
}) : toORPCError2(e10);
|
|
138490
|
-
const response = await this.codec.encodeError(error63, procedure,
|
|
138609
|
+
const response = await this.codec.encodeError(error63, procedure, path97, { context: context2, prefix: prefix2 });
|
|
138491
138610
|
return { matched: true, response };
|
|
138492
138611
|
}
|
|
138493
138612
|
}
|
|
@@ -138594,7 +138713,7 @@ var RPCMatcher = class {
|
|
|
138594
138713
|
this.rootRouter = router;
|
|
138595
138714
|
this.index(router);
|
|
138596
138715
|
}
|
|
138597
|
-
index(router,
|
|
138716
|
+
index(router, path97 = []) {
|
|
138598
138717
|
const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
|
|
138599
138718
|
if (!value2(this.filter, procedure, procedurePath)) {
|
|
138600
138719
|
return;
|
|
@@ -138605,7 +138724,7 @@ var RPCMatcher = class {
|
|
|
138605
138724
|
// contract-first entries have no implementation yet, resolveProcedure fills it in on demand
|
|
138606
138725
|
procedure: procedure instanceof Procedure ? procedure : void 0
|
|
138607
138726
|
});
|
|
138608
|
-
},
|
|
138727
|
+
}, path97);
|
|
138609
138728
|
for (const result of lazyResults) {
|
|
138610
138729
|
this.pendingLazyRouters.set(pathToHttpPath2(result.path), result);
|
|
138611
138730
|
}
|
|
@@ -138737,10 +138856,10 @@ var RPCHandlerCodec = class {
|
|
|
138737
138856
|
}
|
|
138738
138857
|
};
|
|
138739
138858
|
}
|
|
138740
|
-
encodeOutput(output2, procedure,
|
|
138859
|
+
encodeOutput(output2, procedure, path97, options) {
|
|
138741
138860
|
return {
|
|
138742
138861
|
headers: {},
|
|
138743
|
-
status: value2(this.outputStatus, output2, procedure,
|
|
138862
|
+
status: value2(this.outputStatus, output2, procedure, path97, options) ?? DEFAULT_SUCCESS_STATUS,
|
|
138744
138863
|
body: this.serializer.serialize(output2)
|
|
138745
138864
|
};
|
|
138746
138865
|
}
|
|
@@ -138816,19 +138935,19 @@ function matchesZero(m10) {
|
|
|
138816
138935
|
const last = m10.paramsMap[m10.paramsMap.length - 1];
|
|
138817
138936
|
return last[2] || !!last[3] && !last[5];
|
|
138818
138937
|
}
|
|
138819
|
-
function normalizePath(
|
|
138820
|
-
if (!
|
|
138938
|
+
function normalizePath(path97) {
|
|
138939
|
+
if (!path97.includes("/.")) return path97;
|
|
138821
138940
|
const r10 = [];
|
|
138822
138941
|
let s = "";
|
|
138823
|
-
for (s of
|
|
138942
|
+
for (s of path97.split("/")) if (s === ".") continue;
|
|
138824
138943
|
else if (s === "..") {
|
|
138825
138944
|
if (r10.length > 1) r10.pop();
|
|
138826
138945
|
} else r10.push(s);
|
|
138827
138946
|
if (s === "." || s === "..") r10.push("");
|
|
138828
138947
|
return r10.join("/") || "/";
|
|
138829
138948
|
}
|
|
138830
|
-
function splitPath(
|
|
138831
|
-
const s =
|
|
138949
|
+
function splitPath(path97) {
|
|
138950
|
+
const s = path97.split("/");
|
|
138832
138951
|
s.shift();
|
|
138833
138952
|
return s;
|
|
138834
138953
|
}
|
|
@@ -138871,9 +138990,9 @@ function getMatchParams(segments, paramsMap, suffix, slash) {
|
|
|
138871
138990
|
}
|
|
138872
138991
|
return params;
|
|
138873
138992
|
}
|
|
138874
|
-
function encodeEscapes(
|
|
138875
|
-
if (!
|
|
138876
|
-
return
|
|
138993
|
+
function encodeEscapes(path97) {
|
|
138994
|
+
if (!path97.includes("\\")) return path97;
|
|
138995
|
+
return path97.replace(/\\([:(){}\\])/g, (_, c10) => "\uFFFD" + ESCAPABLE.indexOf(c10));
|
|
138877
138996
|
}
|
|
138878
138997
|
function decodeEscapes(segment, prefix) {
|
|
138879
138998
|
return segment.replace(/\uFFFD([0-5])/g, (_, i10) => prefix + ESCAPABLE[i10]);
|
|
@@ -138910,11 +139029,11 @@ function classSetOp(s) {
|
|
|
138910
139029
|
}))) ;
|
|
138911
139030
|
return found;
|
|
138912
139031
|
}
|
|
138913
|
-
function starGroups(
|
|
138914
|
-
if (!
|
|
139032
|
+
function starGroups(path97) {
|
|
139033
|
+
if (!path97.includes("(.*)")) return [path97];
|
|
138915
139034
|
let count2 = 0;
|
|
138916
139035
|
let unnamed;
|
|
138917
|
-
return [
|
|
139036
|
+
return [path97.replace(/\\[\s\S]|(:[A-Za-z_]\w*)?\((?!\?)(\.\*\)(?!\*))?/g, (m10, name, star, at2) => {
|
|
138918
139037
|
if (m10[0] === "\\" || !star) {
|
|
138919
139038
|
if (m10[0] === "(") count2++;
|
|
138920
139039
|
return m10;
|
|
@@ -138923,25 +139042,25 @@ function starGroups(path92) {
|
|
|
138923
139042
|
const k10 = count2;
|
|
138924
139043
|
unnamed = (index) => index === k10 ? name.slice(1) : index > k10 ? index - 1 : index;
|
|
138925
139044
|
} else count2++;
|
|
138926
|
-
return /(^|[^\\])(\\\\)*([)*}?]|:[A-Za-z_]\w*)\{?$/.test(
|
|
139045
|
+
return /(^|[^\\])(\\\\)*([)*}?]|:[A-Za-z_]\w*)\{?$/.test(path97.slice(0, at2)) ? "\uFFFF*" : "*";
|
|
138927
139046
|
}), unnamed];
|
|
138928
139047
|
}
|
|
138929
|
-
function absolutePattern(
|
|
138930
|
-
return /^[/{]/.test(
|
|
139048
|
+
function absolutePattern(path97) {
|
|
139049
|
+
return /^[/{]/.test(path97) ? path97 : `/${path97}`;
|
|
138931
139050
|
}
|
|
138932
|
-
function dotSegments(
|
|
138933
|
-
if (!DOT_SEGMENT.test(
|
|
138934
|
-
const s =
|
|
139051
|
+
function dotSegments(path97) {
|
|
139052
|
+
if (!DOT_SEGMENT.test(path97)) return path97;
|
|
139053
|
+
const s = path97.split("/");
|
|
138935
139054
|
const out = [s[0]];
|
|
138936
139055
|
let dot = false;
|
|
138937
139056
|
for (let i10 = 1; i10 < s.length; i10++) {
|
|
138938
139057
|
const m10 = /^(?:\.|%2e)(\.|%2e)?$/i.exec(s[i10]);
|
|
138939
139058
|
if (m10) {
|
|
138940
|
-
if (m10[1] && (out.length > 1 || out[0]) && !isText(out.pop())) invalidSyntax(DOT_SEGMENT_NEXT_TO,
|
|
139059
|
+
if (m10[1] && (out.length > 1 || out[0]) && !isText(out.pop())) invalidSyntax(DOT_SEGMENT_NEXT_TO, path97);
|
|
138941
139060
|
dot = true;
|
|
138942
139061
|
continue;
|
|
138943
139062
|
}
|
|
138944
|
-
if (dot && /^[:*(]/.test(s[i10])) invalidSyntax(DOT_SEGMENT_NEXT_TO,
|
|
139063
|
+
if (dot && /^[:*(]/.test(s[i10])) invalidSyntax(DOT_SEGMENT_NEXT_TO, path97);
|
|
138945
139064
|
out.push(s[i10]);
|
|
138946
139065
|
dot = false;
|
|
138947
139066
|
}
|
|
@@ -139008,17 +139127,17 @@ function splitStar(segments, input2) {
|
|
|
139008
139127
|
function oneCatchAll(input2) {
|
|
139009
139128
|
throw new Error(`rou3: a route can have only one \`*\`, \`**\`, \`:name+\` or \`:name*\` (${input2})`);
|
|
139010
139129
|
}
|
|
139011
|
-
function splitRoute(
|
|
139012
|
-
const s = splitPath(
|
|
139130
|
+
function splitRoute(path97) {
|
|
139131
|
+
const s = splitPath(path97);
|
|
139013
139132
|
while (s[s.length - 1] === "") s.pop();
|
|
139014
|
-
if (
|
|
139133
|
+
if (path97.includes("**")) {
|
|
139015
139134
|
for (let i10 = 0; i10 < s.length; i10++) if (/^\*\*[^:{}]/.test(s[i10])) s.splice(i10, 1, ...s[i10][2] === "*" ? ["**", s[i10].slice(2)] : [s[i10].slice(1)]);
|
|
139016
139135
|
}
|
|
139017
139136
|
return s;
|
|
139018
139137
|
}
|
|
139019
|
-
function expandedRouteId(
|
|
139020
|
-
if (
|
|
139021
|
-
return "/" + splitRoute(encodeEscapes(
|
|
139138
|
+
function expandedRouteId(path97) {
|
|
139139
|
+
if (path97.charCodeAt(0) !== 47) return `{${expandedRouteId(`/${path97}`)}`;
|
|
139140
|
+
return "/" + splitRoute(encodeEscapes(path97)).map((segment) => {
|
|
139022
139141
|
const key = segmentKey(segment);
|
|
139023
139142
|
return typeof key === "string" ? key : segment;
|
|
139024
139143
|
}).join("/");
|
|
@@ -139040,40 +139159,40 @@ function segmentWildcards(segment) {
|
|
|
139040
139159
|
}
|
|
139041
139160
|
return at2;
|
|
139042
139161
|
}
|
|
139043
|
-
function scanFirstGroup(
|
|
139162
|
+
function scanFirstGroup(path97) {
|
|
139044
139163
|
let i10 = 0;
|
|
139045
139164
|
let depth = 0;
|
|
139046
|
-
for (; i10 <
|
|
139047
|
-
const c10 =
|
|
139165
|
+
for (; i10 < path97.length; i10++) {
|
|
139166
|
+
const c10 = path97.charCodeAt(i10);
|
|
139048
139167
|
if (c10 === 92) i10++;
|
|
139049
139168
|
else if (c10 === 40) depth++;
|
|
139050
139169
|
else if (c10 === 41 && depth > 0) depth--;
|
|
139051
139170
|
else if (c10 === 123 && depth === 0) break;
|
|
139052
139171
|
}
|
|
139053
|
-
if (i10 >=
|
|
139172
|
+
if (i10 >= path97.length) return;
|
|
139054
139173
|
let j10 = i10 + 1;
|
|
139055
139174
|
depth = 0;
|
|
139056
|
-
for (; j10 <
|
|
139057
|
-
const c10 =
|
|
139175
|
+
for (; j10 < path97.length; j10++) {
|
|
139176
|
+
const c10 = path97.charCodeAt(j10);
|
|
139058
139177
|
if (c10 === 92) j10++;
|
|
139059
139178
|
else if (c10 === 40) depth++;
|
|
139060
139179
|
else if (c10 === 41 && depth > 0) depth--;
|
|
139061
139180
|
else if (c10 === 125 && depth === 0) break;
|
|
139062
139181
|
}
|
|
139063
|
-
if (j10 >=
|
|
139064
|
-
const mod =
|
|
139182
|
+
if (j10 >= path97.length) return;
|
|
139183
|
+
const mod = path97[j10 + 1];
|
|
139065
139184
|
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
139066
139185
|
return [
|
|
139067
|
-
|
|
139068
|
-
|
|
139069
|
-
|
|
139186
|
+
path97.slice(0, i10),
|
|
139187
|
+
path97.slice(i10 + 1, j10).replace(NAME_CHAR, "\\$&"),
|
|
139188
|
+
path97.slice(j10 + (hasMod ? 2 : 1)).replace(NAME_CHAR, "\\$&"),
|
|
139070
139189
|
hasMod ? mod : void 0
|
|
139071
139190
|
];
|
|
139072
139191
|
}
|
|
139073
139192
|
var NAME_CHAR = /^[\w$\x80-]/;
|
|
139074
|
-
function expandGroupDelimiters(
|
|
139075
|
-
if (!
|
|
139076
|
-
const group = scanFirstGroup(
|
|
139193
|
+
function expandGroupDelimiters(path97, input2 = path97) {
|
|
139194
|
+
if (!path97.includes("{")) return;
|
|
139195
|
+
const group = scanFirstGroup(path97);
|
|
139077
139196
|
if (!group) return;
|
|
139078
139197
|
const [pre2, body, suf, mod] = group;
|
|
139079
139198
|
if (mod === "+" || mod === "*") invalidSyntax(`unsupported \`{}${mod}\``, input2);
|
|
@@ -139175,43 +139294,43 @@ function linearRegExp(regexp) {
|
|
|
139175
139294
|
return source === regexp.source ? regexp : new RegExp(`^${head}${source.slice(1)}`);
|
|
139176
139295
|
}
|
|
139177
139296
|
var upTo = (L, back) => L.replace(/^\\/, "").length < 2 ? `[^/${L}]*` : back ? `(?:[^/](?<!${L}))*` : `(?:(?!${L})[^/])*`;
|
|
139178
|
-
function addRoute(ctx, method = "",
|
|
139297
|
+
function addRoute(ctx, method = "", path97, data) {
|
|
139179
139298
|
method = method.toUpperCase();
|
|
139180
|
-
|
|
139181
|
-
checkConstraints(
|
|
139182
|
-
const resolved = dotSegments(
|
|
139299
|
+
path97 = absolutePattern(path97);
|
|
139300
|
+
checkConstraints(path97);
|
|
139301
|
+
const resolved = dotSegments(path97);
|
|
139183
139302
|
const [route, unnamed] = starGroups(resolved);
|
|
139184
139303
|
variants = void 0;
|
|
139185
|
-
_add(ctx, method, route, data, unnamed && expandedRouteId(resolved),
|
|
139304
|
+
_add(ctx, method, route, data, unnamed && expandedRouteId(resolved), path97, unnamed);
|
|
139186
139305
|
}
|
|
139187
139306
|
var variants;
|
|
139188
|
-
function _add(ctx, method,
|
|
139189
|
-
const groupExpanded = expandGroupDelimiters(
|
|
139307
|
+
function _add(ctx, method, path97, data, route, input2 = path97, unnamed = same) {
|
|
139308
|
+
const groupExpanded = expandGroupDelimiters(path97, input2);
|
|
139190
139309
|
if (groupExpanded) {
|
|
139191
139310
|
if (groupExpanded[1] !== void 0) {
|
|
139192
|
-
route ??= expandedRouteId(
|
|
139311
|
+
route ??= expandedRouteId(path97);
|
|
139193
139312
|
variants ??= {};
|
|
139194
139313
|
}
|
|
139195
139314
|
_add(ctx, method, groupExpanded[0], data, route, input2, unnamed);
|
|
139196
|
-
if (groupExpanded[1] !== void 0) _add(ctx, method, groupExpanded[1], data, route, input2, /[*(]/.test(
|
|
139315
|
+
if (groupExpanded[1] !== void 0) _add(ctx, method, groupExpanded[1], data, route, input2, /[*(]/.test(path97) ? skipGroup(path97, input2, unnamed) : unnamed);
|
|
139197
139316
|
return 0;
|
|
139198
139317
|
}
|
|
139199
|
-
|
|
139200
|
-
const segments = splitRoute(
|
|
139318
|
+
path97 = encodeEscapes(path97);
|
|
139319
|
+
const segments = splitRoute(path97);
|
|
139201
139320
|
const expanded = expandModifiers(segments, input2);
|
|
139202
139321
|
if (expanded) {
|
|
139203
|
-
route ??= expandedRouteId(
|
|
139322
|
+
route ??= expandedRouteId(path97);
|
|
139204
139323
|
variants ??= {};
|
|
139205
139324
|
let count2 = 0;
|
|
139206
139325
|
for (const p of expanded) count2 = _add(ctx, method, p, data, route, input2, unnamed);
|
|
139207
139326
|
return count2;
|
|
139208
139327
|
}
|
|
139209
|
-
const star =
|
|
139328
|
+
const star = path97.includes("*");
|
|
139210
139329
|
const split = star ? splitStar(segments, input2) : void 0;
|
|
139211
139330
|
if (split) {
|
|
139212
139331
|
const [routes, join4, head] = split;
|
|
139213
139332
|
if (routes.length > 1) {
|
|
139214
|
-
route ??= expandedRouteId(
|
|
139333
|
+
route ??= expandedRouteId(path97);
|
|
139215
139334
|
variants ??= {};
|
|
139216
139335
|
}
|
|
139217
139336
|
let count2 = 0;
|
|
@@ -139331,8 +139450,8 @@ function _insert(ctx, method, segments, data, route, input2, unnamed, star, join
|
|
|
139331
139450
|
return _unnamedParamIndex;
|
|
139332
139451
|
}
|
|
139333
139452
|
var same = (index) => index;
|
|
139334
|
-
function skipGroup(
|
|
139335
|
-
const [pre2, body] = scanFirstGroup(
|
|
139453
|
+
function skipGroup(path97, input2, unnamed = same) {
|
|
139454
|
+
const [pre2, body] = scanFirstGroup(path97);
|
|
139336
139455
|
if (!/[*(]/.test(body) && !pre2.endsWith("*")) return unnamed;
|
|
139337
139456
|
const count2 = (p) => _add(createRouter(), "", p, void 0, void 0, input2);
|
|
139338
139457
|
const before = count2(pre2);
|
|
@@ -139394,11 +139513,11 @@ function kindAt(m10, n10, p) {
|
|
|
139394
139513
|
} else if ((suffix && index > suffix[0] ? index - suffix[0] - 1 + end : index) === p) return typeof name === "string" || plain ? 0 : 2;
|
|
139395
139514
|
return 3;
|
|
139396
139515
|
}
|
|
139397
|
-
function findAllRoutes(ctx, method = "",
|
|
139398
|
-
if (opts?.normalize)
|
|
139399
|
-
const slash =
|
|
139400
|
-
if (slash)
|
|
139401
|
-
const segments = splitPath(
|
|
139516
|
+
function findAllRoutes(ctx, method = "", path97, opts) {
|
|
139517
|
+
if (opts?.normalize) path97 = normalizePath(path97);
|
|
139518
|
+
const slash = path97.charCodeAt(path97.length - 1) === 47;
|
|
139519
|
+
if (slash) path97 = path97.slice(0, -1);
|
|
139520
|
+
const segments = splitPath(path97);
|
|
139402
139521
|
const matches2 = _findRanked(ctx, method, segments);
|
|
139403
139522
|
let seen;
|
|
139404
139523
|
for (let i10 = matches2.length - 1; i10 >= 0; i10--) {
|
|
@@ -139455,16 +139574,16 @@ function pushSorted(matches2, match, reverse) {
|
|
|
139455
139574
|
}).sort((a10, b) => a10[1] - b[1]).map((e10) => e10[0]);
|
|
139456
139575
|
for (const m10 of match) matches2.push(m10);
|
|
139457
139576
|
}
|
|
139458
|
-
function findRoute(ctx, method = "",
|
|
139459
|
-
if (opts?.normalize)
|
|
139460
|
-
const slash =
|
|
139461
|
-
if (slash)
|
|
139462
|
-
const staticNode = ctx.static[
|
|
139577
|
+
function findRoute(ctx, method = "", path97, opts) {
|
|
139578
|
+
if (opts?.normalize) path97 = normalizePath(path97);
|
|
139579
|
+
const slash = path97.charCodeAt(path97.length - 1) === 47;
|
|
139580
|
+
if (slash) path97 = path97.slice(0, -1);
|
|
139581
|
+
const staticNode = ctx.static[path97];
|
|
139463
139582
|
if (staticNode && staticNode.methods) {
|
|
139464
139583
|
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
139465
139584
|
if (staticMatch !== void 0) return { data: staticMatch[0].data };
|
|
139466
139585
|
}
|
|
139467
|
-
const segments = splitPath(
|
|
139586
|
+
const segments = splitPath(path97);
|
|
139468
139587
|
let match;
|
|
139469
139588
|
if (segments.includes("") || ctx.root.hasSuffix && hasSuffixMatch(ctx.root, method, segments, 0)) {
|
|
139470
139589
|
const matches2 = _findRanked(ctx, method, segments, true);
|
|
@@ -139760,8 +139879,8 @@ var STAR_SEGMENT = "*/";
|
|
|
139760
139879
|
function routeToRegExp(route = "/") {
|
|
139761
139880
|
route = absolutePattern(route);
|
|
139762
139881
|
addRoute(createRouter(), "", route);
|
|
139763
|
-
const [
|
|
139764
|
-
return new RegExp(determinize(toRegExp(
|
|
139882
|
+
const [path97, unnamed] = starGroups(dotSegments(route));
|
|
139883
|
+
return new RegExp(determinize(toRegExp(path97, route, unnamed).source));
|
|
139765
139884
|
}
|
|
139766
139885
|
function toRegExp(route, input2, unnamed) {
|
|
139767
139886
|
const inlineOptional = inlineOptionalGroup(route, input2, unnamed);
|
|
@@ -140118,7 +140237,7 @@ var OpenAPIMatcher = class {
|
|
|
140118
140237
|
this.rootRouter = router;
|
|
140119
140238
|
this.index(router);
|
|
140120
140239
|
}
|
|
140121
|
-
index(router,
|
|
140240
|
+
index(router, path97 = []) {
|
|
140122
140241
|
const routes = [];
|
|
140123
140242
|
const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
|
|
140124
140243
|
if (!value2(this.filter, contract, path210)) {
|
|
@@ -140139,7 +140258,7 @@ var OpenAPIMatcher = class {
|
|
|
140139
140258
|
...route
|
|
140140
140259
|
}
|
|
140141
140260
|
});
|
|
140142
|
-
},
|
|
140261
|
+
}, path97);
|
|
140143
140262
|
const pendingLazyRouters = lazyResults.map((result) => {
|
|
140144
140263
|
const prefix = getOpenAPIMeta(result.router)?.prefix;
|
|
140145
140264
|
return {
|
|
@@ -140239,10 +140358,10 @@ var OpenAPIMatcher = class {
|
|
|
140239
140358
|
return entry.procedure;
|
|
140240
140359
|
}
|
|
140241
140360
|
};
|
|
140242
|
-
function toRou3Route(
|
|
140243
|
-
const dynamicParams = getDynamicPathParams(
|
|
140361
|
+
function toRou3Route(path97) {
|
|
140362
|
+
const dynamicParams = getDynamicPathParams(path97);
|
|
140244
140363
|
if (!dynamicParams) {
|
|
140245
|
-
return { pattern: toRou3Literal(
|
|
140364
|
+
return { pattern: toRou3Literal(path97) };
|
|
140246
140365
|
}
|
|
140247
140366
|
let pattern = "";
|
|
140248
140367
|
let literalStart = 0;
|
|
@@ -140251,11 +140370,11 @@ function toRou3Route(path92) {
|
|
|
140251
140370
|
for (const param of dynamicParams) {
|
|
140252
140371
|
const key = `p${params.length}`;
|
|
140253
140372
|
params.push([key, param.parameterName]);
|
|
140254
|
-
pattern += toRou3Literal(
|
|
140373
|
+
pattern += toRou3Literal(path97.slice(literalStart, param.startIndex));
|
|
140255
140374
|
literalStart = param.startIndex + param.segment.length;
|
|
140256
140375
|
if (param.allowsSlash) {
|
|
140257
140376
|
if (catchAllKey !== void 0) {
|
|
140258
|
-
throw new TypeError(`OpenAPI path "${
|
|
140377
|
+
throw new TypeError(`OpenAPI path "${path97}" has more than one catch-all param ({+name}), but only one is supported per path.`);
|
|
140259
140378
|
}
|
|
140260
140379
|
catchAllKey = key;
|
|
140261
140380
|
pattern += `:${key}(.*)`;
|
|
@@ -140263,7 +140382,7 @@ function toRou3Route(path92) {
|
|
|
140263
140382
|
pattern += `:${key}`;
|
|
140264
140383
|
}
|
|
140265
140384
|
}
|
|
140266
|
-
pattern += toRou3Literal(
|
|
140385
|
+
pattern += toRou3Literal(path97.slice(literalStart));
|
|
140267
140386
|
return { pattern, params, catchAllKey };
|
|
140268
140387
|
}
|
|
140269
140388
|
var ROU3_SYNTAX_REGEX = /[\\:*?+(){}]|(?<![^/])\.(?=\.?(?:\/|$))/g;
|
|
@@ -140271,8 +140390,8 @@ function toRou3Literal(text5) {
|
|
|
140271
140390
|
const normalized = NORMALIZABLE_PATHNAME_REGEX2.test(text5) ? normalizeRou3Path(text5) : text5;
|
|
140272
140391
|
return normalized.replace(ROU3_SYNTAX_REGEX, "\\$&");
|
|
140273
140392
|
}
|
|
140274
|
-
function normalizeRou3Path(
|
|
140275
|
-
return
|
|
140393
|
+
function normalizeRou3Path(path97) {
|
|
140394
|
+
return path97.split("/").map((segment) => safeDecodeURIComponent2(segment).replace(ROU3_ENCODED_SEGMENT_TEXT_REGEX, safeEncodeURIComponent2)).join("/");
|
|
140276
140395
|
}
|
|
140277
140396
|
function toRou3PrefixMatcher(prefix) {
|
|
140278
140397
|
const catchAll = getDynamicPathParams(prefix)?.find((param) => param.allowsSlash);
|
|
@@ -140362,7 +140481,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
140362
140481
|
/**
|
|
140363
140482
|
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
140364
140483
|
*/
|
|
140365
|
-
encodeOutput(output2, procedure,
|
|
140484
|
+
encodeOutput(output2, procedure, path97) {
|
|
140366
140485
|
const meta3 = getOpenAPIMeta(procedure);
|
|
140367
140486
|
const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
|
|
140368
140487
|
const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
|
|
@@ -140375,7 +140494,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
140375
140494
|
}
|
|
140376
140495
|
if (!isValidDetailedOutput(output2)) {
|
|
140377
140496
|
throw new TypeError(`
|
|
140378
|
-
Invalid "detailed" output structure returned by procedure (${
|
|
140497
|
+
Invalid "detailed" output structure returned by procedure (${path97.join(".")}):
|
|
140379
140498
|
\u2022 Expected an object with optional properties:
|
|
140380
140499
|
- status (number <400)
|
|
140381
140500
|
- headers (object)
|
|
@@ -140988,7 +141107,7 @@ function profileValue(name, paths) {
|
|
|
140988
141107
|
function createConfigApiRouter(deps) {
|
|
140989
141108
|
const authed = doorApiAuth(deps.expectedToken);
|
|
140990
141109
|
const { paths } = deps;
|
|
140991
|
-
const route = (
|
|
141110
|
+
const route = (path97, summary) => authed.meta(openapi({ method: "POST", path: path97, summary, tags: [CONFIG_API_TAG] }));
|
|
140992
141111
|
return {
|
|
140993
141112
|
config: {
|
|
140994
141113
|
identity: {
|
|
@@ -143228,8 +143347,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
143228
143347
|
request7.body.resume();
|
|
143229
143348
|
return;
|
|
143230
143349
|
}
|
|
143231
|
-
const
|
|
143232
|
-
const translated = { method: request7.method, path:
|
|
143350
|
+
const path97 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
143351
|
+
const translated = { method: request7.method, path: path97, body, signal: request7.signal };
|
|
143233
143352
|
const routed = await route(translated);
|
|
143234
143353
|
if (request7.signal.aborted) {
|
|
143235
143354
|
return;
|
|
@@ -143463,9 +143582,9 @@ function descendExpanded(root, value3, key) {
|
|
|
143463
143582
|
}
|
|
143464
143583
|
}
|
|
143465
143584
|
function relaxRejectedRecursiveProperty(request7, body) {
|
|
143466
|
-
const
|
|
143467
|
-
if (
|
|
143468
|
-
const propertyIndices =
|
|
143585
|
+
const path97 = rejectedPath(body);
|
|
143586
|
+
if (path97 === void 0) return void 0;
|
|
143587
|
+
const propertyIndices = path97.flatMap((part, index) => part === "properties" && path97[index + 1] !== void 0 ? [index] : []).reverse();
|
|
143469
143588
|
if (propertyIndices.length === 0) return void 0;
|
|
143470
143589
|
const copy2 = structuredClone(request7);
|
|
143471
143590
|
let changed = false;
|
|
@@ -143474,14 +143593,14 @@ function relaxRejectedRecursiveProperty(request7, body) {
|
|
|
143474
143593
|
const schema = declaration.parametersJsonSchema;
|
|
143475
143594
|
if (schema === void 0) continue;
|
|
143476
143595
|
let leaf = schema;
|
|
143477
|
-
for (const part of
|
|
143596
|
+
for (const part of path97) leaf = descendExpanded(schema, leaf, part);
|
|
143478
143597
|
if (!record2(leaf) || typeof leaf.$ref !== "string") continue;
|
|
143479
143598
|
let repairedProperty = false;
|
|
143480
143599
|
for (const propertyIndex of propertyIndices) {
|
|
143481
|
-
const name =
|
|
143600
|
+
const name = path97[propertyIndex + 1];
|
|
143482
143601
|
if (name === void 0) continue;
|
|
143483
143602
|
let owner = schema;
|
|
143484
|
-
for (const part of
|
|
143603
|
+
for (const part of path97.slice(0, propertyIndex)) owner = descendExpanded(schema, owner, part);
|
|
143485
143604
|
if (!record2(owner) || !Array.isArray(owner.required) || !owner.required.includes(name) || !record2(owner.properties)) continue;
|
|
143486
143605
|
const property = owner.properties[name];
|
|
143487
143606
|
if (!record2(property)) continue;
|
|
@@ -143495,8 +143614,8 @@ function relaxRejectedRecursiveProperty(request7, body) {
|
|
|
143495
143614
|
}
|
|
143496
143615
|
if (!repairedProperty) {
|
|
143497
143616
|
let parent = schema;
|
|
143498
|
-
for (const part of
|
|
143499
|
-
const key =
|
|
143617
|
+
for (const part of path97.slice(0, -1)) parent = descendExpanded(schema, parent, part);
|
|
143618
|
+
const key = path97.at(-1);
|
|
143500
143619
|
const truncated = { description: "Recursive value: the original tool schema validates this value." };
|
|
143501
143620
|
if (record2(parent) && key !== void 0 && Object.hasOwn(parent, key)) {
|
|
143502
143621
|
parent[key] = truncated;
|
|
@@ -143988,8 +144107,8 @@ function createAntigravityRouteMount(ports, upstreamBase, provider) {
|
|
|
143988
144107
|
request7.body.resume();
|
|
143989
144108
|
return;
|
|
143990
144109
|
}
|
|
143991
|
-
const
|
|
143992
|
-
const translated = { method: request7.method, path:
|
|
144110
|
+
const path97 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
144111
|
+
const translated = { method: request7.method, path: path97, body, signal: request7.signal };
|
|
143993
144112
|
const routed = await route(translated);
|
|
143994
144113
|
if (request7.signal.aborted) {
|
|
143995
144114
|
return;
|
|
@@ -144033,7 +144152,7 @@ function createPassthroughRoute(name, target) {
|
|
|
144033
144152
|
headroomUpstream: target.headroomUpstream,
|
|
144034
144153
|
serve: async (request7, response) => {
|
|
144035
144154
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
144036
|
-
const
|
|
144155
|
+
const path97 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
144037
144156
|
const headers = forwardableHeaders(request7.headers);
|
|
144038
144157
|
delete headers.host;
|
|
144039
144158
|
await new Promise((resolve3) => {
|
|
@@ -144041,7 +144160,7 @@ function createPassthroughRoute(name, target) {
|
|
|
144041
144160
|
host: base.hostname,
|
|
144042
144161
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
144043
144162
|
method: request7.method,
|
|
144044
|
-
path: `${basePath}${
|
|
144163
|
+
path: `${basePath}${path97}${incoming.search}`,
|
|
144045
144164
|
headers,
|
|
144046
144165
|
agent
|
|
144047
144166
|
};
|
|
@@ -144247,13 +144366,13 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
144247
144366
|
}
|
|
144248
144367
|
|
|
144249
144368
|
// src/frontdoor/providerRoute.ts
|
|
144250
|
-
var isRcSelfHostPath = (
|
|
144369
|
+
var isRcSelfHostPath = (path97) => path97 === "/v1/code/sessions" || path97.startsWith("/v1/code/sessions/") || path97 === "/v1/sessions" || path97.startsWith("/v1/sessions/");
|
|
144251
144370
|
function scopeSessionProviderPath(request7) {
|
|
144252
144371
|
if (request7.session.provider === void 0) {
|
|
144253
144372
|
return request7;
|
|
144254
144373
|
}
|
|
144255
|
-
const
|
|
144256
|
-
if (!
|
|
144374
|
+
const path97 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
144375
|
+
if (!path97.startsWith("/v1/") || isRcSelfHostPath(path97)) {
|
|
144257
144376
|
return request7;
|
|
144258
144377
|
}
|
|
144259
144378
|
return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
|
|
@@ -144388,13 +144507,13 @@ function createProviderRouteResolver(deps) {
|
|
|
144388
144507
|
return route;
|
|
144389
144508
|
};
|
|
144390
144509
|
const resolve3 = (request7) => {
|
|
144391
|
-
const
|
|
144392
|
-
const scoped = parseProviderPath(
|
|
144510
|
+
const path97 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
144511
|
+
const scoped = parseProviderPath(path97);
|
|
144393
144512
|
if (scoped === void 0) {
|
|
144394
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
144513
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path97)) {
|
|
144395
144514
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
144396
144515
|
}
|
|
144397
|
-
return
|
|
144516
|
+
return path97.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path97}` };
|
|
144398
144517
|
}
|
|
144399
144518
|
const { provider } = scoped;
|
|
144400
144519
|
let definition;
|
|
@@ -144490,8 +144609,8 @@ function createProviderRouteResolver(deps) {
|
|
|
144490
144609
|
let modelChoice;
|
|
144491
144610
|
const visited = /* @__PURE__ */ new Set();
|
|
144492
144611
|
for (; ; ) {
|
|
144493
|
-
const
|
|
144494
|
-
const scoped = parseProviderPath(
|
|
144612
|
+
const path97 = new URL(current.url, "http://127.0.0.1").pathname;
|
|
144613
|
+
const scoped = parseProviderPath(path97);
|
|
144495
144614
|
const providerName = scoped?.provider ?? current.session.provider;
|
|
144496
144615
|
if (providerName !== void 0 && visited.has(providerName)) {
|
|
144497
144616
|
return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
|
|
@@ -144506,7 +144625,7 @@ function createProviderRouteResolver(deps) {
|
|
|
144506
144625
|
} catch {
|
|
144507
144626
|
routes = void 0;
|
|
144508
144627
|
}
|
|
144509
|
-
const resolvesNames = !nameResolved && !isRcSelfHostPath(
|
|
144628
|
+
const resolvesNames = !nameResolved && !isRcSelfHostPath(path97);
|
|
144510
144629
|
if (resolvesNames) {
|
|
144511
144630
|
const scan2 = await scanRequestHead(current, true);
|
|
144512
144631
|
if (scan2.replayed === void 0) {
|
|
@@ -144545,7 +144664,7 @@ function createProviderRouteResolver(deps) {
|
|
|
144545
144664
|
}
|
|
144546
144665
|
if (routed.provider !== providerName) {
|
|
144547
144666
|
const scopedPrefix = providerName === void 0 ? void 0 : `${PROVIDER_PATH_PREFIX}${encodeURIComponent(providerName)}`;
|
|
144548
|
-
const rest2 = scopedPrefix !== void 0 &&
|
|
144667
|
+
const rest2 = scopedPrefix !== void 0 && path97.startsWith(scopedPrefix) ? path97.slice(scopedPrefix.length) : path97;
|
|
144549
144668
|
const query2 = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
144550
144669
|
const carried = replay;
|
|
144551
144670
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(routed.provider)}${rest2}${query2}`, body: carried.body, headers: carried.headers };
|
|
@@ -144599,7 +144718,7 @@ function createProviderRouteResolver(deps) {
|
|
|
144599
144718
|
const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
144600
144719
|
replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
|
|
144601
144720
|
}
|
|
144602
|
-
const rest = scoped === void 0 ?
|
|
144721
|
+
const rest = scoped === void 0 ? path97 : path97.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
|
|
144603
144722
|
const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
144604
144723
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
|
|
144605
144724
|
}
|
|
@@ -150586,15 +150705,15 @@ function parseNumstat(output2) {
|
|
|
150586
150705
|
if (addedText === void 0 || deletedText === void 0 || pathText === void 0) {
|
|
150587
150706
|
continue;
|
|
150588
150707
|
}
|
|
150589
|
-
const
|
|
150708
|
+
const path97 = pathText === "" ? fields[index + 2] : pathText;
|
|
150590
150709
|
if (pathText === "") {
|
|
150591
150710
|
index += 2;
|
|
150592
150711
|
}
|
|
150593
150712
|
const lines = { added: Number(addedText), deleted: Number(deletedText) };
|
|
150594
|
-
if (
|
|
150713
|
+
if (path97 !== void 0 && Number.isInteger(lines.added) && Number.isInteger(lines.deleted)) {
|
|
150595
150714
|
added += lines.added;
|
|
150596
150715
|
deleted += lines.deleted;
|
|
150597
|
-
byPath.set(
|
|
150716
|
+
byPath.set(path97, lines);
|
|
150598
150717
|
}
|
|
150599
150718
|
}
|
|
150600
150719
|
return { total: { added, deleted }, byPath };
|
|
@@ -151633,11 +151752,11 @@ function targetText(tool, columns) {
|
|
|
151633
151752
|
if (!FILE_TOOLS.includes(tool.name)) {
|
|
151634
151753
|
return truncateWithEllipsis(target, room, ELLIPSIS);
|
|
151635
151754
|
}
|
|
151636
|
-
const
|
|
151637
|
-
if (visibleLength(
|
|
151638
|
-
return
|
|
151755
|
+
const path97 = target.replaceAll("\\", "/");
|
|
151756
|
+
if (visibleLength(path97) <= room) {
|
|
151757
|
+
return path97;
|
|
151639
151758
|
}
|
|
151640
|
-
const file2 =
|
|
151759
|
+
const file2 = path97.split("/").pop() ?? path97;
|
|
151641
151760
|
return visibleLength(DIRECTORY_ELLIPSIS) + visibleLength(file2) > room ? truncateWithEllipsis(file2, room, FILE_ELLIPSIS) : `${DIRECTORY_ELLIPSIS}${file2}`;
|
|
151642
151761
|
}
|
|
151643
151762
|
function finishedByKind(tools) {
|
|
@@ -155394,8 +155513,8 @@ function getErrorMap2() {
|
|
|
155394
155513
|
|
|
155395
155514
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v3/helpers/parseUtil.js
|
|
155396
155515
|
var makeIssue = (params) => {
|
|
155397
|
-
const { data, path:
|
|
155398
|
-
const fullPath = [...
|
|
155516
|
+
const { data, path: path97, errorMaps, issueData } = params;
|
|
155517
|
+
const fullPath = [...path97, ...issueData.path || []];
|
|
155399
155518
|
const fullIssue = {
|
|
155400
155519
|
...issueData,
|
|
155401
155520
|
path: fullPath
|
|
@@ -155510,11 +155629,11 @@ var errorUtil;
|
|
|
155510
155629
|
|
|
155511
155630
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v3/types.js
|
|
155512
155631
|
var ParseInputLazyPath = class {
|
|
155513
|
-
constructor(parent, value3,
|
|
155632
|
+
constructor(parent, value3, path97, key) {
|
|
155514
155633
|
this._cachedPath = [];
|
|
155515
155634
|
this.parent = parent;
|
|
155516
155635
|
this.data = value3;
|
|
155517
|
-
this._path =
|
|
155636
|
+
this._path = path97;
|
|
155518
155637
|
this._key = key;
|
|
155519
155638
|
}
|
|
155520
155639
|
get path() {
|
|
@@ -159077,11 +159196,11 @@ function normalizeObjectSchema(schema) {
|
|
|
159077
159196
|
}
|
|
159078
159197
|
return void 0;
|
|
159079
159198
|
}
|
|
159080
|
-
function getDotPath(
|
|
159081
|
-
if (
|
|
159199
|
+
function getDotPath(path97) {
|
|
159200
|
+
if (path97.length === 0) {
|
|
159082
159201
|
return "object root";
|
|
159083
159202
|
}
|
|
159084
|
-
return
|
|
159203
|
+
return path97.reduce((acc, seg, index) => {
|
|
159085
159204
|
if (index === 0) {
|
|
159086
159205
|
return String(seg);
|
|
159087
159206
|
}
|
|
@@ -164193,11 +164312,83 @@ function registerHeadroomCommand(program2, deps) {
|
|
|
164193
164312
|
}
|
|
164194
164313
|
|
|
164195
164314
|
// src/supervise/commands.ts
|
|
164315
|
+
var import_node_fs33 = require("node:fs");
|
|
164196
164316
|
init_realPorts();
|
|
164197
164317
|
|
|
164318
|
+
// src/supervise/hookGuard.ts
|
|
164319
|
+
var import_node_path84 = __toESM(require("node:path"), 1);
|
|
164320
|
+
init_lock();
|
|
164321
|
+
function prefixOf(sessionId) {
|
|
164322
|
+
return `${sessionId}.hook.`;
|
|
164323
|
+
}
|
|
164324
|
+
function hooksPending(fs36, paths, pool, sessionId) {
|
|
164325
|
+
return fs36.readdir(stateDirOf(paths, pool)).some((name) => name.startsWith(prefixOf(sessionId)) && name.endsWith(".json"));
|
|
164326
|
+
}
|
|
164327
|
+
function currentConversation(fs36, paths, pool, sessionId) {
|
|
164328
|
+
const state = readSessionState(fs36, paths, pool, sessionId);
|
|
164329
|
+
return state === void 0 || state.unavailable === true || hooksPending(fs36, paths, pool, sessionId) ? void 0 : state.conversationId ?? sessionId;
|
|
164330
|
+
}
|
|
164331
|
+
function announceHook(deps, pool, sessionId) {
|
|
164332
|
+
const dir = stateDirOf(deps.paths, pool);
|
|
164333
|
+
deps.fs.mkdirPrivate(dir);
|
|
164334
|
+
const marker = import_node_path84.default.join(dir, `${prefixOf(sessionId)}${String(deps.pid)}.json`);
|
|
164335
|
+
const created = deps.fs.writeFileExclusive(marker, `${JSON.stringify({ pid: deps.pid })}
|
|
164336
|
+
`);
|
|
164337
|
+
return {
|
|
164338
|
+
acquire: () => {
|
|
164339
|
+
const lock = acquireIdentityLock({ identity: `mark-${sessionId}`, dir, fs: deps.fs, nowMs: deps.now, pid: deps.pid, isRunning: deps.isRunning, sleep: deps.sleep, ...deps.maxAttempts === void 0 ? {} : { maxAttempts: deps.maxAttempts } });
|
|
164340
|
+
return {
|
|
164341
|
+
finish: (success2, newTurn) => {
|
|
164342
|
+
try {
|
|
164343
|
+
if (success2 && newTurn) {
|
|
164344
|
+
for (const name of deps.fs.readdir(dir)) {
|
|
164345
|
+
if (!name.startsWith(prefixOf(sessionId)) || !name.endsWith(".json")) {
|
|
164346
|
+
continue;
|
|
164347
|
+
}
|
|
164348
|
+
const pidText = name.slice(prefixOf(sessionId).length, -".json".length);
|
|
164349
|
+
const pid = Number(pidText);
|
|
164350
|
+
if (Number.isSafeInteger(pid) && pid > 0 && pid !== deps.pid && !deps.isRunning(pid)) {
|
|
164351
|
+
deps.fs.removeRecursive(import_node_path84.default.join(dir, name));
|
|
164352
|
+
}
|
|
164353
|
+
}
|
|
164354
|
+
}
|
|
164355
|
+
if (success2 && (created || newTurn)) {
|
|
164356
|
+
deps.fs.removeRecursive(marker);
|
|
164357
|
+
}
|
|
164358
|
+
} finally {
|
|
164359
|
+
lock.release();
|
|
164360
|
+
}
|
|
164361
|
+
}
|
|
164362
|
+
};
|
|
164363
|
+
}
|
|
164364
|
+
};
|
|
164365
|
+
}
|
|
164366
|
+
|
|
164198
164367
|
// src/supervise/marks.ts
|
|
164368
|
+
var import_node_path85 = __toESM(require("node:path"), 1);
|
|
164369
|
+
init_zod();
|
|
164199
164370
|
init_resumeContext();
|
|
164200
164371
|
init_shellQuote();
|
|
164372
|
+
var MarkHookInputSchema = external_exports.object({
|
|
164373
|
+
session_id: external_exports.uuid(),
|
|
164374
|
+
transcript_path: external_exports.string().refine(import_node_path85.default.isAbsolute),
|
|
164375
|
+
prompt_id: external_exports.uuid().optional(),
|
|
164376
|
+
hook_event_name: external_exports.enum(["SessionStart", "UserPromptSubmit", "Stop", "StopFailure"]),
|
|
164377
|
+
background_tasks: external_exports.array(external_exports.unknown()).optional(),
|
|
164378
|
+
session_crons: external_exports.array(external_exports.unknown()).optional()
|
|
164379
|
+
});
|
|
164380
|
+
function markFromHook(requested, payload) {
|
|
164381
|
+
const input2 = MarkHookInputSchema.parse(payload);
|
|
164382
|
+
const starts = input2.hook_event_name === "SessionStart" || input2.hook_event_name === "UserPromptSubmit";
|
|
164383
|
+
if (requested === "busy" !== starts) {
|
|
164384
|
+
throw new Error(`unexpected ${input2.hook_event_name} hook for a ${requested} mark`);
|
|
164385
|
+
}
|
|
164386
|
+
if (input2.hook_event_name === "UserPromptSubmit" && input2.prompt_id === void 0) {
|
|
164387
|
+
throw new Error("UserPromptSubmit did not identify its prompt");
|
|
164388
|
+
}
|
|
164389
|
+
const idle = input2.hook_event_name === "Stop" && input2.prompt_id !== void 0 && input2.background_tasks?.length === 0 && input2.session_crons?.length === 0;
|
|
164390
|
+
return { conversationId: input2.session_id, transcriptPath: input2.transcript_path, ...input2.prompt_id === void 0 ? {} : { promptId: input2.prompt_id }, sessionStart: input2.hook_event_name === "SessionStart", mark: idle ? "idle" : "busy" };
|
|
164391
|
+
}
|
|
164201
164392
|
var MARK_HOOK_TIMEOUT_SECONDS = 10;
|
|
164202
164393
|
var SUPERVISE_MARK_COMMAND = "__supervise-mark";
|
|
164203
164394
|
function markHooksSettings(invocation, root, pool, sessionId) {
|
|
@@ -164212,21 +164403,42 @@ function markHooksSettings(invocation, root, pool, sessionId) {
|
|
|
164212
164403
|
]
|
|
164213
164404
|
}
|
|
164214
164405
|
];
|
|
164215
|
-
return JSON.stringify({ hooks: { UserPromptSubmit: hook("busy"), Stop: hook("idle"), StopFailure: hook("idle") } });
|
|
164406
|
+
return JSON.stringify({ hooks: { SessionStart: hook("busy"), UserPromptSubmit: hook("busy"), Stop: hook("idle"), StopFailure: hook("idle") } });
|
|
164407
|
+
}
|
|
164408
|
+
function recordUnknown(context, pool, sessionId) {
|
|
164409
|
+
const previous = readSessionState(context.fs, context.paths, pool, sessionId);
|
|
164410
|
+
writeSessionState(context.fs, context.paths, pool, sessionId, { ...previous, mark: "busy", unavailable: true, at: new Date(context.now()).toISOString() });
|
|
164216
164411
|
}
|
|
164217
|
-
function recordMark(context, pool, sessionId, mark) {
|
|
164412
|
+
function recordMark(context, pool, sessionId, mark, conversationId = sessionId, transcriptPath, promptId, ending2 = false, sessionStart = false) {
|
|
164413
|
+
if (ending2 && promptId === void 0) {
|
|
164414
|
+
recordUnknown(context, pool, sessionId);
|
|
164415
|
+
return;
|
|
164416
|
+
}
|
|
164218
164417
|
const previous = readSessionState(context.fs, context.paths, pool, sessionId);
|
|
164219
|
-
|
|
164418
|
+
if ((mark === "idle" || ending2) && promptId !== void 0 && ((previous?.conversationId ?? sessionId) !== conversationId || previous?.promptId !== promptId)) {
|
|
164419
|
+
return;
|
|
164420
|
+
}
|
|
164421
|
+
const sameConversation = (previous?.conversationId ?? sessionId) === conversationId;
|
|
164422
|
+
const currentPrompt = promptId ?? (sessionStart && sameConversation ? previous?.promptId : void 0);
|
|
164423
|
+
let contextTokens = sameConversation ? previous?.contextTokens : void 0;
|
|
164220
164424
|
if (mark === "idle") {
|
|
164221
|
-
if (context.configDir === void 0) {
|
|
164425
|
+
if (transcriptPath === void 0 && context.configDir === void 0) {
|
|
164222
164426
|
throw new Error("CLAUDE_CONFIG_DIR is not set, so the session's transcript cannot be found");
|
|
164223
164427
|
}
|
|
164224
|
-
|
|
164428
|
+
const transcript = transcriptPath === void 0 ? void 0 : context.fs.readFileUtf8(transcriptPath);
|
|
164429
|
+
if (transcriptPath === void 0 && context.configDir !== void 0) {
|
|
164430
|
+
contextTokens = resumedContextTokens(context.fs, { claudeHome: context.configDir, cwd: context.cwd, passthrough: ["--resume", conversationId] }) ?? contextTokens;
|
|
164431
|
+
} else if (transcript !== void 0) {
|
|
164432
|
+
contextTokens = contextTokensOfTranscript(transcript) ?? contextTokens;
|
|
164433
|
+
}
|
|
164225
164434
|
}
|
|
164226
164435
|
writeSessionState(context.fs, context.paths, pool, sessionId, {
|
|
164227
164436
|
mark,
|
|
164437
|
+
...conversationId === sessionId ? {} : { conversationId },
|
|
164438
|
+
...transcriptPath === void 0 ? {} : { transcriptPath },
|
|
164439
|
+
...currentPrompt === void 0 ? {} : { promptId: currentPrompt },
|
|
164228
164440
|
...contextTokens === void 0 ? {} : { contextTokens },
|
|
164229
|
-
...previous?.compacted === true ? { compacted: true } : {},
|
|
164441
|
+
...sameConversation && previous?.compacted === true ? { compacted: true } : {},
|
|
164230
164442
|
at: new Date(context.now()).toISOString()
|
|
164231
164443
|
});
|
|
164232
164444
|
}
|
|
@@ -164238,12 +164450,27 @@ function isTurnMark(value3) {
|
|
|
164238
164450
|
}
|
|
164239
164451
|
function registerSuperviseMarkCommand(program2, deps) {
|
|
164240
164452
|
program2.command(`${SUPERVISE_MARK_COMMAND} <pool> <session> <mark>`, { hidden: true }).description("Internal: record that a supervised session's turn began or ended. Run by the session's own hooks; never by hand.").action((pool, session, mark) => {
|
|
164453
|
+
const context = { fs: realFarmFs, paths: deps.paths, now: Date.now, configDir: process.env.CLAUDE_CONFIG_DIR, cwd: process.cwd() };
|
|
164454
|
+
let guard;
|
|
164241
164455
|
try {
|
|
164456
|
+
const announcement = announceHook({ fs: realFarmFs, paths: deps.paths, now: Date.now, pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }, pool, session);
|
|
164457
|
+
const raw = (0, import_node_fs33.readFileSync)(0, "utf8");
|
|
164458
|
+
guard = announcement.acquire();
|
|
164242
164459
|
if (!isTurnMark(mark)) {
|
|
164243
164460
|
throw new Error(`"${mark}" is not a turn mark: use busy or idle`);
|
|
164244
164461
|
}
|
|
164245
|
-
|
|
164462
|
+
const payload = JSON.parse(raw);
|
|
164463
|
+
const actual = markFromHook(mark, payload);
|
|
164464
|
+
recordMark(context, pool, session, actual.mark, actual.conversationId, actual.transcriptPath, actual.promptId, mark === "idle", actual.sessionStart);
|
|
164465
|
+
guard.finish(true, mark === "busy");
|
|
164246
164466
|
} catch (error63) {
|
|
164467
|
+
if (guard !== void 0) {
|
|
164468
|
+
try {
|
|
164469
|
+
recordUnknown(context, pool, session);
|
|
164470
|
+
} finally {
|
|
164471
|
+
guard.finish(false, false);
|
|
164472
|
+
}
|
|
164473
|
+
}
|
|
164247
164474
|
console.error(`agent-shim: could not record the turn mark: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
164248
164475
|
deps.exit(1);
|
|
164249
164476
|
}
|
|
@@ -164254,7 +164481,7 @@ function registerSuperviseMarkCommand(program2, deps) {
|
|
|
164254
164481
|
init_zod();
|
|
164255
164482
|
|
|
164256
164483
|
// src/realCatalogueRefresh.ts
|
|
164257
|
-
var
|
|
164484
|
+
var import_node_path86 = __toESM(require("node:path"), 1);
|
|
164258
164485
|
var import_node_os21 = __toESM(require("node:os"), 1);
|
|
164259
164486
|
init_blockingSpawn();
|
|
164260
164487
|
init_translate2();
|
|
@@ -164329,8 +164556,8 @@ async function refreshCatalogueForReal(paths, name, env, ...owner) {
|
|
|
164329
164556
|
const provider = readProvider(paths, name);
|
|
164330
164557
|
const login = provider?.kind === "codex" ? resolveCodexConfig(provider.codex).login : void 0;
|
|
164331
164558
|
const configuredHome = env.CODEX_HOME;
|
|
164332
|
-
const home = configuredHome === void 0 || configuredHome === "" ?
|
|
164333
|
-
const source = login === void 0 ? void 0 : login === "chatgpt-sign-in" ? paths.chatgptSignInFile :
|
|
164559
|
+
const home = configuredHome === void 0 || configuredHome === "" ? import_node_path86.default.join(import_node_os21.default.homedir(), ".codex") : configuredHome;
|
|
164560
|
+
const source = login === void 0 ? void 0 : login === "chatgpt-sign-in" ? paths.chatgptSignInFile : import_node_path86.default.resolve(home, "auth.json");
|
|
164334
164561
|
let revision = source === void 0 ? void 0 : realFsPort.fileRevision?.(source);
|
|
164335
164562
|
const codexAuth = login === void 0 ? void 0 : createCodexRoutePorts((line) => {
|
|
164336
164563
|
console.error(line);
|
|
@@ -164376,7 +164603,7 @@ async function refreshCatalogueForReal(paths, name, env, ...owner) {
|
|
|
164376
164603
|
if (source === void 0 || revision === void 0) throw new Error("Codex login revision is unavailable");
|
|
164377
164604
|
if (realFsPort.fileRevision?.(source) !== revision) throw new Error("Codex login changed during catalogue refresh");
|
|
164378
164605
|
const destination = catalogueBindingPath(paths, providerName, supervisorPid, generation);
|
|
164379
|
-
realFarmFs.mkdirp(
|
|
164606
|
+
realFarmFs.mkdirp(import_node_path86.default.dirname(destination));
|
|
164380
164607
|
realFarmFs.writeFilePrivate(destination, JSON.stringify({ fingerprint, source, revision }));
|
|
164381
164608
|
}
|
|
164382
164609
|
});
|
|
@@ -164386,7 +164613,7 @@ async function refreshCatalogueForReal(paths, name, env, ...owner) {
|
|
|
164386
164613
|
init_realPorts();
|
|
164387
164614
|
|
|
164388
164615
|
// src/usage/realJobRunner.ts
|
|
164389
|
-
var
|
|
164616
|
+
var import_node_path87 = __toESM(require("node:path"), 1);
|
|
164390
164617
|
init_conditions();
|
|
164391
164618
|
init_identityClaude();
|
|
164392
164619
|
var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
|
|
@@ -164399,7 +164626,7 @@ ${outcome.trimEnd()}
|
|
|
164399
164626
|
}
|
|
164400
164627
|
function createRealJobRunner(params) {
|
|
164401
164628
|
return async (name, identity, job) => {
|
|
164402
|
-
const logFile =
|
|
164629
|
+
const logFile = import_node_path87.default.join(params.paths.jobLogsDir, `${name}.log`);
|
|
164403
164630
|
const append = (outcome) => {
|
|
164404
164631
|
params.fs.mkdirPrivate(params.paths.jobLogsDir);
|
|
164405
164632
|
params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
|
|
@@ -164458,7 +164685,7 @@ function registerHeadlessCommands(program2, deps) {
|
|
|
164458
164685
|
}
|
|
164459
164686
|
|
|
164460
164687
|
// src/jobs.ts
|
|
164461
|
-
var
|
|
164688
|
+
var import_node_path88 = __toESM(require("node:path"), 1);
|
|
164462
164689
|
init_commandDeps();
|
|
164463
164690
|
init_cliError();
|
|
164464
164691
|
init_schema();
|
|
@@ -164485,7 +164712,7 @@ function jobOf(options) {
|
|
|
164485
164712
|
target: options.identity === void 0 ? { pool: options.pool ?? "" } : { identity: options.identity },
|
|
164486
164713
|
trigger: options.at === void 0 ? { beforeReset: options.beforeReset ?? "fiveHour", lead: options.lead ?? "" } : { at: options.at },
|
|
164487
164714
|
prompt: options.prompt,
|
|
164488
|
-
cwd:
|
|
164715
|
+
cwd: import_node_path88.default.resolve(options.cwd ?? process.cwd()),
|
|
164489
164716
|
timeout: options.timeout,
|
|
164490
164717
|
...options.model === void 0 ? {} : { model: options.model },
|
|
164491
164718
|
...options.allowedTool === void 0 ? {} : { allowedTools: options.allowedTool }
|
|
@@ -164558,7 +164785,7 @@ function registerJobCommand(program2, deps) {
|
|
|
164558
164785
|
console.log(`Allowed tools: ${entry.allowedTools.join(", ")}`);
|
|
164559
164786
|
}
|
|
164560
164787
|
console.log(`Prompt: ${entry.prompt}`);
|
|
164561
|
-
console.log(`Results: ${
|
|
164788
|
+
console.log(`Results: ${import_node_path88.default.join(paths.jobLogsDir, `${name}.log`)}`);
|
|
164562
164789
|
}),
|
|
164563
164790
|
["agent-shim job show digest"]
|
|
164564
164791
|
);
|
|
@@ -164581,7 +164808,7 @@ function registerJobCommand(program2, deps) {
|
|
|
164581
164808
|
throw new UsageError(`No member of the job's pool can be picked right now.`);
|
|
164582
164809
|
}
|
|
164583
164810
|
await createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() })(name, identity, entry);
|
|
164584
|
-
console.log(`Ran job "${name}" as ${identity}; the result is in ${
|
|
164811
|
+
console.log(`Ran job "${name}" as ${identity}; the result is in ${import_node_path88.default.join(paths.jobLogsDir, `${name}.log`)}.`);
|
|
164585
164812
|
}),
|
|
164586
164813
|
["agent-shim job run digest"]
|
|
164587
164814
|
);
|
|
@@ -164756,14 +164983,14 @@ init_cliError();
|
|
|
164756
164983
|
init_providerCatalogue();
|
|
164757
164984
|
init_state();
|
|
164758
164985
|
init_modelPicker();
|
|
164759
|
-
var
|
|
164986
|
+
var import_node_fs35 = __toESM(require("node:fs"), 1);
|
|
164760
164987
|
var import_node_os22 = __toESM(require("node:os"), 1);
|
|
164761
164988
|
init_credential();
|
|
164762
164989
|
init_providerAliases();
|
|
164763
164990
|
|
|
164764
164991
|
// src/providerRename.ts
|
|
164765
|
-
var
|
|
164766
|
-
var
|
|
164992
|
+
var import_node_fs34 = __toESM(require("node:fs"), 1);
|
|
164993
|
+
var import_node_path89 = __toESM(require("node:path"), 1);
|
|
164767
164994
|
init_zod();
|
|
164768
164995
|
init_schema();
|
|
164769
164996
|
init_store();
|
|
@@ -164808,7 +165035,7 @@ function renameProvider(paths, from, to2, ports) {
|
|
|
164808
165035
|
const previousAliases = readProviderAliases(paths);
|
|
164809
165036
|
writeProviderAliases(paths, aliasesAfterRename(previousAliases, from, to2));
|
|
164810
165037
|
try {
|
|
164811
|
-
|
|
165038
|
+
import_node_fs34.default.renameSync(providerJsonPath(paths, from), providerJsonPath(paths, to2));
|
|
164812
165039
|
} catch (error63) {
|
|
164813
165040
|
writeProviderAliases(paths, previousAliases);
|
|
164814
165041
|
throw error63;
|
|
@@ -164828,26 +165055,26 @@ function moveState(paths, from, to2, ports) {
|
|
|
164828
165055
|
`);
|
|
164829
165056
|
moved.push(`usage ${snapshot.identity}`);
|
|
164830
165057
|
}
|
|
164831
|
-
if (
|
|
164832
|
-
|
|
165058
|
+
if (import_node_fs34.default.existsSync(catalogueCachePath(paths, from))) {
|
|
165059
|
+
import_node_fs34.default.renameSync(catalogueCachePath(paths, from), catalogueCachePath(paths, to2));
|
|
164833
165060
|
moved.push("catalogue");
|
|
164834
165061
|
}
|
|
164835
165062
|
const globalBinding = catalogueBindingPath(paths, from);
|
|
164836
|
-
if (
|
|
164837
|
-
|
|
165063
|
+
if (import_node_fs34.default.existsSync(globalBinding)) {
|
|
165064
|
+
import_node_fs34.default.renameSync(globalBinding, catalogueBindingPath(paths, to2));
|
|
164838
165065
|
if (!moved.includes("catalogue")) moved.push("catalogue");
|
|
164839
165066
|
}
|
|
164840
|
-
const supervisorsDir =
|
|
164841
|
-
if (
|
|
164842
|
-
for (const entry of
|
|
165067
|
+
const supervisorsDir = import_node_path89.default.join(paths.catalogueDir, "supervisors");
|
|
165068
|
+
if (import_node_fs34.default.existsSync(supervisorsDir)) {
|
|
165069
|
+
for (const entry of import_node_fs34.default.readdirSync(supervisorsDir, { withFileTypes: true })) {
|
|
164843
165070
|
const pid = Number(entry.name);
|
|
164844
165071
|
if (!entry.isDirectory() || !Number.isSafeInteger(pid) || pid <= 0 || String(pid) !== entry.name) continue;
|
|
164845
|
-
for (const generation of
|
|
165072
|
+
for (const generation of import_node_fs34.default.readdirSync(import_node_path89.default.join(supervisorsDir, entry.name), { withFileTypes: true })) {
|
|
164846
165073
|
if (!generation.isDirectory() || !external_exports.uuid().safeParse(generation.name).success) continue;
|
|
164847
165074
|
for (const location of [catalogueCachePath, catalogueBindingPath]) {
|
|
164848
165075
|
const source = location(paths, from, pid, generation.name);
|
|
164849
|
-
if (
|
|
164850
|
-
|
|
165076
|
+
if (import_node_fs34.default.existsSync(source)) {
|
|
165077
|
+
import_node_fs34.default.renameSync(source, location(paths, to2, pid, generation.name));
|
|
164851
165078
|
if (!moved.includes("catalogue")) moved.push("catalogue");
|
|
164852
165079
|
}
|
|
164853
165080
|
}
|
|
@@ -164891,7 +165118,7 @@ function rewriteReferences(paths, from, to2) {
|
|
|
164891
165118
|
const launch = renamedLaunch(profile.launch, from, to2);
|
|
164892
165119
|
const models = profile.models === void 0 ? void 0 : renamedModels(profile.models, from, to2);
|
|
164893
165120
|
if (launch !== void 0 || models !== void 0) {
|
|
164894
|
-
applyPatch(
|
|
165121
|
+
applyPatch(import_node_path89.default.join(paths.configProfilesDir, `${name}.json`), ConfigProfileSchema, { ...launch === void 0 ? {} : { launch }, ...models === void 0 ? {} : { models } });
|
|
164895
165122
|
rewritten.push(`profile ${name}`);
|
|
164896
165123
|
}
|
|
164897
165124
|
}
|
|
@@ -165227,7 +165454,7 @@ function registerProviderCommand(program2, deps) {
|
|
|
165227
165454
|
throw new UsageError(`Provider "${name}" has no catalogue setting. Set one with \`agent-shim provider set ${name} --catalogue-tier <tier>\`.`);
|
|
165228
165455
|
}
|
|
165229
165456
|
const catalogueSetting = found.catalogue;
|
|
165230
|
-
const cache = options.refresh === true ? await refreshCatalogueForReal(paths, name, process.env) : parseCatalogueCache(
|
|
165457
|
+
const cache = options.refresh === true ? await refreshCatalogueForReal(paths, name, process.env) : parseCatalogueCache(import_node_fs35.default.existsSync(catalogueCachePath(paths, name)) ? import_node_fs35.default.readFileSync(catalogueCachePath(paths, name), "utf8") : void 0);
|
|
165231
165458
|
if (cache === void 0) {
|
|
165232
165459
|
throw new UsageError(`No catalogue has been fetched for "${name}" yet: the front door fetches it shortly after it starts, or run \`agent-shim provider models ${name} --refresh\`.`);
|
|
165233
165460
|
}
|
|
@@ -165672,9 +165899,9 @@ function registerRuleCommand(program2, deps) {
|
|
|
165672
165899
|
|
|
165673
165900
|
// src/codex/launch.ts
|
|
165674
165901
|
var import_node_crypto33 = require("node:crypto");
|
|
165675
|
-
var
|
|
165902
|
+
var import_node_fs37 = __toESM(require("node:fs"), 1);
|
|
165676
165903
|
var import_node_os23 = __toESM(require("node:os"), 1);
|
|
165677
|
-
var
|
|
165904
|
+
var import_node_path90 = __toESM(require("node:path"), 1);
|
|
165678
165905
|
init_cliError();
|
|
165679
165906
|
init_claudeShim();
|
|
165680
165907
|
init_load();
|
|
@@ -165692,7 +165919,7 @@ init_walk();
|
|
|
165692
165919
|
|
|
165693
165920
|
// src/supervise/realPorts.ts
|
|
165694
165921
|
var import_node_child_process11 = require("node:child_process");
|
|
165695
|
-
var
|
|
165922
|
+
var import_node_fs36 = __toESM(require("node:fs"), 1);
|
|
165696
165923
|
init_realPorts();
|
|
165697
165924
|
init_blockingSpawn();
|
|
165698
165925
|
var realSupervisedSpawnPort = {
|
|
@@ -165737,9 +165964,17 @@ var realTimerPort = {
|
|
|
165737
165964
|
}
|
|
165738
165965
|
};
|
|
165739
165966
|
function realWatchDirectory(directory, accepts, what, log) {
|
|
165967
|
+
return watchDirectory(directory, accepts, what, log, true);
|
|
165968
|
+
}
|
|
165969
|
+
function realWatchExistingDirectory(directory, accepts, what, log) {
|
|
165970
|
+
return watchDirectory(directory, accepts, what, log, false);
|
|
165971
|
+
}
|
|
165972
|
+
function watchDirectory(directory, accepts, what, log, createPrivate) {
|
|
165740
165973
|
return (onChange) => {
|
|
165741
|
-
|
|
165742
|
-
|
|
165974
|
+
if (createPrivate) {
|
|
165975
|
+
realFarmFs.mkdirPrivate(directory);
|
|
165976
|
+
}
|
|
165977
|
+
const watcher = import_node_fs36.default.watch(directory, { persistent: false }, (_event, filename) => {
|
|
165743
165978
|
if (filename === null || accepts(filename)) {
|
|
165744
165979
|
onChange();
|
|
165745
165980
|
}
|
|
@@ -165831,9 +166066,9 @@ function prepareCodexLaunch(options) {
|
|
|
165831
166066
|
const errors = assembleCascade(cascade).diagnostics.filter((item) => item.severity === "error");
|
|
165832
166067
|
if (errors.length > 0) throw new UsageError(errors.map((item) => item.message).join("\n"));
|
|
165833
166068
|
const canonical = canonicalCodexHome(env, options.home);
|
|
165834
|
-
const farmRoot =
|
|
165835
|
-
const relative =
|
|
165836
|
-
if (relative === "" || !relative.startsWith(`..${
|
|
166069
|
+
const farmRoot = import_node_path90.default.join(paths.identitiesDir, id2);
|
|
166070
|
+
const relative = import_node_path90.default.relative(canonical, farmRoot);
|
|
166071
|
+
if (relative === "" || !relative.startsWith(`..${import_node_path90.default.sep}`) && relative !== ".." && !import_node_path90.default.isAbsolute(relative)) throw new UsageError("The canonical Codex home cannot contain an identity home.");
|
|
165837
166072
|
const result = resyncFarm({ ...options, identitiesDir: paths.identitiesDir, identity: id2, claudeHome: canonical, cascade, classification: { defaults: CODEX_CATEGORIES }, lock, ...profile.name === void 0 ? {} : { configProfile: profile.name }, identityExists: () => readIdentityById(paths, id2)?.agent === "codex" });
|
|
165838
166073
|
for (const diagnostic of result.diagnostics) options.warn(diagnostic.message);
|
|
165839
166074
|
return {
|
|
@@ -165860,16 +166095,16 @@ async function runCodex(paths, argv) {
|
|
|
165860
166095
|
const own2 = resolveOwnBinaryCheck(paths, realContentSourcePath());
|
|
165861
166096
|
const resolveBinary = () => {
|
|
165862
166097
|
const explicit = process.env.AGENT_SHIM_CODEX_BIN;
|
|
165863
|
-
const candidates = explicit === void 0 ? (process.env.PATH ?? "").split(
|
|
166098
|
+
const candidates = explicit === void 0 ? (process.env.PATH ?? "").split(import_node_path90.default.delimiter).filter(Boolean).map((dir) => findExecutableInDir(dir, "codex")) : [import_node_path90.default.resolve(explicit)];
|
|
165864
166099
|
for (const candidate of candidates) {
|
|
165865
166100
|
if (candidate !== void 0 && !own2(candidate)) return candidate;
|
|
165866
166101
|
}
|
|
165867
166102
|
throw new UsageError("No real Codex CLI found on PATH. Install Codex or set AGENT_SHIM_CODEX_BIN to its executable.");
|
|
165868
166103
|
};
|
|
165869
|
-
const plan = prepareCodexLaunch({ paths, argv, env: process.env, cwd:
|
|
166104
|
+
const plan = prepareCodexLaunch({ paths, argv, env: process.env, cwd: import_node_fs37.default.realpathSync(process.cwd()), home: import_node_os23.default.homedir(), fs: realFarmFs, read: cosmiconfigReader(), resolveBinary, now: Date.now, pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync, uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto33.randomUUID)()}`, warn: (message) => {
|
|
165870
166105
|
console.error(`agent-shim: ${message}`);
|
|
165871
166106
|
}, ...resolveGitBranch(realRunPort, process.cwd()) });
|
|
165872
|
-
|
|
166107
|
+
import_node_fs37.default.chmodSync(plan.env.CODEX_HOME ?? "", PRIVATE_DIRECTORY_MODE);
|
|
165873
166108
|
process.exitCode = await runCodexChild(plan, realSupervisedSpawnPort, realSignalPort);
|
|
165874
166109
|
}
|
|
165875
166110
|
|
|
@@ -165968,7 +166203,7 @@ function registerSessionCommands(program2, deps) {
|
|
|
165968
166203
|
}
|
|
165969
166204
|
|
|
165970
166205
|
// src/usage/commands.ts
|
|
165971
|
-
var
|
|
166206
|
+
var import_node_path91 = __toESM(require("node:path"), 1);
|
|
165972
166207
|
init_commandDeps();
|
|
165973
166208
|
init_identityStore();
|
|
165974
166209
|
init_realPorts();
|
|
@@ -166103,7 +166338,7 @@ function collectAccounts(fs36, paths, identity, probe) {
|
|
|
166103
166338
|
return {
|
|
166104
166339
|
identity: name,
|
|
166105
166340
|
account: readAccountMetadata(fs36, paths.identitiesDir, id2),
|
|
166106
|
-
signIn: identitySignIn(fs36, probe, { farmRoot:
|
|
166341
|
+
signIn: identitySignIn(fs36, probe, { farmRoot: import_node_path91.default.join(paths.identitiesDir, id2), hasCredentialBlock: stored2?.credential !== void 0, provider: stored2?.provider }),
|
|
166107
166342
|
// Named, like the view around it, by the identity's name; the snapshot is filed under its id.
|
|
166108
166343
|
usage: ((snapshot) => snapshot === void 0 ? void 0 : { ...snapshot, identity: name })(readUsageSnapshot(fs36, paths.usageSnapshotsDir, id2))
|
|
166109
166344
|
};
|
|
@@ -166614,7 +166849,9 @@ async function realRefresher(params) {
|
|
|
166614
166849
|
}
|
|
166615
166850
|
|
|
166616
166851
|
// src/supervise/launch.ts
|
|
166617
|
-
var
|
|
166852
|
+
var import_node_crypto35 = require("node:crypto");
|
|
166853
|
+
var import_node_fs40 = require("node:fs");
|
|
166854
|
+
var import_node_path95 = __toESM(require("node:path"), 1);
|
|
166618
166855
|
init_claudeSession();
|
|
166619
166856
|
init_claudeSubcommand();
|
|
166620
166857
|
init_pool();
|
|
@@ -166634,7 +166871,7 @@ init_preflight();
|
|
|
166634
166871
|
var PERCENT6 = 100;
|
|
166635
166872
|
var asPercent = (fraction) => `${String(Math.round(fraction * PERCENT6))}%`;
|
|
166636
166873
|
function compactableTokens(state) {
|
|
166637
|
-
return state?.mark === "idle" && state.compacted !== true && state.contextTokens !== void 0 && state.contextTokens > 0 ? state.contextTokens : void 0;
|
|
166874
|
+
return state?.mark === "idle" && state.unavailable !== true && state.compacted !== true && state.contextTokens !== void 0 && state.contextTokens > 0 ? state.contextTokens : void 0;
|
|
166638
166875
|
}
|
|
166639
166876
|
function presentWindows(input2) {
|
|
166640
166877
|
const unified = input2.snapshot?.providers[ANTHROPIC_PROVIDER]?.rateLimit?.unified;
|
|
@@ -166679,7 +166916,7 @@ function decideCompaction(input2) {
|
|
|
166679
166916
|
return { compact: false, reason: "a larger session on this member compacts first" };
|
|
166680
166917
|
}
|
|
166681
166918
|
const reason = triggerReason(input2);
|
|
166682
|
-
return reason === void 0 ? { compact: false, reason: "the member's quota has not reached the trigger" } : { compact: true, contextTokens: tokens, reason };
|
|
166919
|
+
return reason === void 0 ? { compact: false, reason: "the member's quota has not reached the trigger" } : { compact: true, contextTokens: tokens, reason, ...own2?.state?.conversationId === void 0 ? {} : { conversationId: own2.state.conversationId } };
|
|
166683
166920
|
}
|
|
166684
166921
|
|
|
166685
166922
|
// src/supervise/realCompact.ts
|
|
@@ -166739,8 +166976,9 @@ function createCompactionDeps(wiring) {
|
|
|
166739
166976
|
return {
|
|
166740
166977
|
shouldCompact: (identity, sessionId) => {
|
|
166741
166978
|
const nowMs = wiring.now();
|
|
166742
|
-
const
|
|
166743
|
-
|
|
166979
|
+
const registry2 = liveSupervised(fs36, paths, pool, wiring.isRunning).filter((session) => session.identity === identity);
|
|
166980
|
+
const sessions = registry2.map((session) => ({ sessionId: session.sessionId, state: readSessionState(fs36, paths, pool, session.sessionId) }));
|
|
166981
|
+
const decision = decideCompaction({
|
|
166744
166982
|
atUtilisation: wiring.policy.compactAtUtilisation,
|
|
166745
166983
|
snapshot: readUsageSnapshot(fs36, paths.usageSnapshotsDir, identity),
|
|
166746
166984
|
records: () => readUsageLog(fs36, paths.usageLogDir, { sinceMs: nowMs - FIVE_HOUR_WINDOW_MS }).records.filter((record3) => record3.identity === identity),
|
|
@@ -166748,6 +166986,15 @@ function createCompactionDeps(wiring) {
|
|
|
166748
166986
|
sessionId,
|
|
166749
166987
|
nowMs
|
|
166750
166988
|
});
|
|
166989
|
+
if (!decision.compact) {
|
|
166990
|
+
return decision;
|
|
166991
|
+
}
|
|
166992
|
+
const own2 = registry2.find((session) => session.sessionId === sessionId);
|
|
166993
|
+
const state = sessions.find((session) => session.sessionId === sessionId)?.state;
|
|
166994
|
+
if (own2 === void 0 || state === void 0 || !wiring.hooksFinished(own2, state)) {
|
|
166995
|
+
return { compact: false, reason: "the turn's Stop hooks have not finished successfully" };
|
|
166996
|
+
}
|
|
166997
|
+
return decision;
|
|
166751
166998
|
},
|
|
166752
166999
|
acquire: (identity) => {
|
|
166753
167000
|
try {
|
|
@@ -166761,14 +167008,27 @@ function createCompactionDeps(wiring) {
|
|
|
166761
167008
|
}
|
|
166762
167009
|
},
|
|
166763
167010
|
compact: wiring.compact,
|
|
166764
|
-
markCompacted: (sessionId, compacted) => {
|
|
166765
|
-
const
|
|
166766
|
-
|
|
166767
|
-
|
|
166768
|
-
|
|
166769
|
-
|
|
166770
|
-
|
|
166771
|
-
|
|
167011
|
+
markCompacted: (sessionId, compacted, conversationId) => {
|
|
167012
|
+
const dir = stateDirOf(paths, pool);
|
|
167013
|
+
fs36.mkdirPrivate(dir);
|
|
167014
|
+
const lock = acquireIdentityLock({ identity: `mark-${sessionId}`, dir, fs: fs36, nowMs: wiring.now, pid: wiring.pid, isRunning: wiring.isRunning, sleep: wiring.sleep });
|
|
167015
|
+
try {
|
|
167016
|
+
const previous = readSessionState(fs36, paths, pool, sessionId);
|
|
167017
|
+
if (conversationId !== void 0 && (previous?.unavailable === true || (previous?.conversationId ?? sessionId) !== conversationId)) return false;
|
|
167018
|
+
writeSessionState(fs36, paths, pool, sessionId, {
|
|
167019
|
+
mark: previous?.mark ?? "idle",
|
|
167020
|
+
...previous?.conversationId === void 0 ? {} : { conversationId: previous.conversationId },
|
|
167021
|
+
...previous?.transcriptPath === void 0 ? {} : { transcriptPath: previous.transcriptPath },
|
|
167022
|
+
...previous?.promptId === void 0 ? {} : { promptId: previous.promptId },
|
|
167023
|
+
...previous?.unavailable === true ? { unavailable: true } : {},
|
|
167024
|
+
...previous?.contextTokens === void 0 ? {} : { contextTokens: previous.contextTokens },
|
|
167025
|
+
...compacted ? { compacted: true } : {},
|
|
167026
|
+
at: new Date(wiring.now()).toISOString()
|
|
167027
|
+
});
|
|
167028
|
+
return true;
|
|
167029
|
+
} finally {
|
|
167030
|
+
lock.release();
|
|
167031
|
+
}
|
|
166772
167032
|
}
|
|
166773
167033
|
};
|
|
166774
167034
|
}
|
|
@@ -166790,8 +167050,142 @@ function quotaHitOf(fs36, paths, identity, sessionId, sinceMs, nowMs) {
|
|
|
166790
167050
|
return void 0;
|
|
166791
167051
|
}
|
|
166792
167052
|
|
|
167053
|
+
// src/supervise/nativeCompact.ts
|
|
167054
|
+
var import_node_crypto34 = require("node:crypto");
|
|
167055
|
+
var import_node_fs38 = require("node:fs");
|
|
167056
|
+
var import_promises20 = require("node:timers/promises");
|
|
167057
|
+
var RESULT_POLL_MS = 250;
|
|
167058
|
+
function nativeCompactionReady(plugin) {
|
|
167059
|
+
return (0, import_node_fs38.existsSync)(plugin.ready);
|
|
167060
|
+
}
|
|
167061
|
+
async function compactInSession(plugin, conversationId, signal) {
|
|
167062
|
+
if (!nativeCompactionReady(plugin)) throw new Error("the in-process compaction plugin did not load");
|
|
167063
|
+
signal.throwIfAborted();
|
|
167064
|
+
const id2 = (0, import_node_crypto34.randomUUID)();
|
|
167065
|
+
const temporary = `${plugin.request}.${id2}`;
|
|
167066
|
+
(0, import_node_fs38.writeFileSync)(temporary, JSON.stringify({ id: id2, conversationId }), { mode: 384 });
|
|
167067
|
+
(0, import_node_fs38.renameSync)(temporary, plugin.request);
|
|
167068
|
+
try {
|
|
167069
|
+
while (!signal.aborted) {
|
|
167070
|
+
signal.throwIfAborted();
|
|
167071
|
+
if ((0, import_node_fs38.existsSync)(plugin.result)) {
|
|
167072
|
+
let value3;
|
|
167073
|
+
try {
|
|
167074
|
+
value3 = JSON.parse((0, import_node_fs38.readFileSync)(plugin.result, "utf8"));
|
|
167075
|
+
} catch (error63) {
|
|
167076
|
+
if (!(error63 instanceof SyntaxError)) throw error63;
|
|
167077
|
+
}
|
|
167078
|
+
if (typeof value3 === "object" && value3 !== null && "id" in value3 && value3.id === id2) {
|
|
167079
|
+
if ("error" in value3 && typeof value3.error === "string") throw new Error(value3.error);
|
|
167080
|
+
if ("kind" in value3 && value3.kind === "unchanged" && "skip" in value3 && typeof value3.skip === "string") return { kind: "unchanged", reason: value3.skip };
|
|
167081
|
+
if ("kind" in value3 && value3.kind === "running") {
|
|
167082
|
+
await (0, import_promises20.setTimeout)(RESULT_POLL_MS, void 0, { signal });
|
|
167083
|
+
continue;
|
|
167084
|
+
}
|
|
167085
|
+
if (!("kind" in value3) || value3.kind !== "compacted") throw new Error("the compaction plugin returned an invalid result");
|
|
167086
|
+
const beforeTokens = "tokensBefore" in value3 && typeof value3.tokensBefore === "number" ? value3.tokensBefore : void 0;
|
|
167087
|
+
const afterTokens = "tokensAfter" in value3 && typeof value3.tokensAfter === "number" ? value3.tokensAfter : void 0;
|
|
167088
|
+
return { kind: "compacted", ...beforeTokens === void 0 ? {} : { beforeTokens }, ...afterTokens === void 0 ? {} : { afterTokens } };
|
|
167089
|
+
}
|
|
167090
|
+
}
|
|
167091
|
+
await (0, import_promises20.setTimeout)(RESULT_POLL_MS, void 0, { signal });
|
|
167092
|
+
}
|
|
167093
|
+
signal.throwIfAborted();
|
|
167094
|
+
throw new Error("compaction wait ended unexpectedly");
|
|
167095
|
+
} finally {
|
|
167096
|
+
(0, import_node_fs38.writeFileSync)(plugin.request, "{}", { mode: 384 });
|
|
167097
|
+
}
|
|
167098
|
+
}
|
|
167099
|
+
|
|
167100
|
+
// src/supervise/nativeCompactionPlugin.ts
|
|
167101
|
+
var import_node_fs39 = require("node:fs");
|
|
167102
|
+
var import_node_os24 = require("node:os");
|
|
167103
|
+
var import_node_path92 = __toESM(require("node:path"), 1);
|
|
167104
|
+
function stageNativeCompactionPlugin() {
|
|
167105
|
+
const directory = (0, import_node_fs39.mkdtempSync)(import_node_path92.default.join((0, import_node_os24.tmpdir)(), "agent-shim-compact-"));
|
|
167106
|
+
const ready = import_node_path92.default.join(directory, "ready.json");
|
|
167107
|
+
const request7 = import_node_path92.default.join(directory, "request.json");
|
|
167108
|
+
const result = import_node_path92.default.join(directory, "result.json");
|
|
167109
|
+
try {
|
|
167110
|
+
(0, import_node_fs39.mkdirSync)(import_node_path92.default.join(directory, ".claude-plugin"), { mode: 448 });
|
|
167111
|
+
(0, import_node_fs39.mkdirSync)(import_node_path92.default.join(directory, "hooks"), { mode: 448 });
|
|
167112
|
+
(0, import_node_fs39.writeFileSync)(import_node_path92.default.join(directory, ".claude-plugin", "plugin.json"), JSON.stringify({ name: "agent-shim-compaction", version: "1.0.0", description: "Compacts supervised sessions in process" }), { mode: 384 });
|
|
167113
|
+
(0, import_node_fs39.writeFileSync)(import_node_path92.default.join(directory, "hooks", "hooks.json"), JSON.stringify({ modules: ["./register.js"] }), { mode: 384 });
|
|
167114
|
+
(0, import_node_fs39.writeFileSync)(import_node_path92.default.join(directory, "hooks", "register.js"), pluginSource(ready, request7, result), { mode: 384 });
|
|
167115
|
+
(0, import_node_fs39.writeFileSync)(request7, "{}", { mode: 384 });
|
|
167116
|
+
(0, import_node_fs39.writeFileSync)(result, "{}", { mode: 384 });
|
|
167117
|
+
return { directory, ready, request: request7, result, release: () => {
|
|
167118
|
+
(0, import_node_fs39.rmSync)(directory, { recursive: true, force: true });
|
|
167119
|
+
} };
|
|
167120
|
+
} catch (error63) {
|
|
167121
|
+
(0, import_node_fs39.rmSync)(directory, { recursive: true, force: true });
|
|
167122
|
+
throw error63;
|
|
167123
|
+
}
|
|
167124
|
+
}
|
|
167125
|
+
function pluginSource(ready, request7, result) {
|
|
167126
|
+
return `export function register(on) {
|
|
167127
|
+
let running = false;
|
|
167128
|
+
let lastRequest;
|
|
167129
|
+
function outcome(id, compacted) {
|
|
167130
|
+
return { id, ...(typeof compacted?.skip === 'string' ? { kind: 'unchanged', skip: compacted.skip } : { kind: 'compacted', tokensBefore: compacted?.tokensBefore, tokensAfter: compacted?.tokensAfter }) };
|
|
167131
|
+
}
|
|
167132
|
+
on('classic.PostCompact', async ($, event, next) => {
|
|
167133
|
+
const answer = await next(event);
|
|
167134
|
+
$.clock.after(0, async () => {
|
|
167135
|
+
const text = await $.fs.read(${JSON.stringify(result)});
|
|
167136
|
+
if (typeof text !== 'string') return;
|
|
167137
|
+
const current = JSON.parse(text);
|
|
167138
|
+
if (current.kind === 'running' && typeof current.id === 'string') {
|
|
167139
|
+
await $.fs.write(${JSON.stringify(result)}, JSON.stringify({ id: current.id, kind: 'compacted' }));
|
|
167140
|
+
}
|
|
167141
|
+
});
|
|
167142
|
+
return answer;
|
|
167143
|
+
});
|
|
167144
|
+
on('session.start', async ($, event, next) => {
|
|
167145
|
+
const answer = await next(event);
|
|
167146
|
+
await $.fs.write(${JSON.stringify(ready)}, JSON.stringify({ ready: true }));
|
|
167147
|
+
$.clock.every(1000, async () => {
|
|
167148
|
+
if (running) return;
|
|
167149
|
+
running = true;
|
|
167150
|
+
try {
|
|
167151
|
+
const text = await $.fs.read(${JSON.stringify(request7)});
|
|
167152
|
+
if (typeof text !== 'string') return;
|
|
167153
|
+
const item = JSON.parse(text);
|
|
167154
|
+
if (typeof item.id !== 'string' || typeof item.conversationId !== 'string' || item.id === lastRequest) return;
|
|
167155
|
+
const priorText = await $.fs.read(${JSON.stringify(result)});
|
|
167156
|
+
if (typeof priorText === 'string') {
|
|
167157
|
+
const prior = JSON.parse(priorText);
|
|
167158
|
+
if (prior.id === item.id) { lastRequest = item.id; return; }
|
|
167159
|
+
}
|
|
167160
|
+
lastRequest = item.id;
|
|
167161
|
+
let response;
|
|
167162
|
+
await $.fs.write(${JSON.stringify(result)}, JSON.stringify({ id: item.id, kind: 'running' }));
|
|
167163
|
+
try {
|
|
167164
|
+
if (await $.session.id() !== item.conversationId) throw new Error('the conversation changed before compaction');
|
|
167165
|
+
const compacted = await $.session.compact({});
|
|
167166
|
+
response = outcome(item.id, compacted);
|
|
167167
|
+
} catch (error) {
|
|
167168
|
+
response = { id: item.id, error: String(error) };
|
|
167169
|
+
}
|
|
167170
|
+
await $.fs.write(${JSON.stringify(result)}, JSON.stringify(response));
|
|
167171
|
+
} finally {
|
|
167172
|
+
running = false;
|
|
167173
|
+
}
|
|
167174
|
+
});
|
|
167175
|
+
return answer;
|
|
167176
|
+
});
|
|
167177
|
+
}
|
|
167178
|
+
`;
|
|
167179
|
+
}
|
|
167180
|
+
function withNativeCompactionPlugin(args, directory) {
|
|
167181
|
+
const end = args.indexOf("--");
|
|
167182
|
+
const result = [...args];
|
|
167183
|
+
result.splice(end === -1 ? result.length : end, 0, "--plugin-dir", directory);
|
|
167184
|
+
return result;
|
|
167185
|
+
}
|
|
167186
|
+
|
|
166793
167187
|
// src/supervise/move.ts
|
|
166794
|
-
var
|
|
167188
|
+
var import_node_path93 = __toESM(require("node:path"), 1);
|
|
166795
167189
|
init_identityRecords();
|
|
166796
167190
|
init_lock();
|
|
166797
167191
|
init_poolPick();
|
|
@@ -166828,7 +167222,7 @@ function createMover(deps) {
|
|
|
166828
167222
|
cwd: deps.cwd,
|
|
166829
167223
|
now: deps.now,
|
|
166830
167224
|
sleep: deps.sleep,
|
|
166831
|
-
passthrough: ["--resume", request7.sessionId],
|
|
167225
|
+
passthrough: ["--resume", request7.conversationId ?? request7.sessionId],
|
|
166832
167226
|
...request7.contextTokens === void 0 ? {} : { resumeContextTokens: request7.contextTokens },
|
|
166833
167227
|
...Object.keys(committed).length === 0 ? {} : { committedContextTokens: committed },
|
|
166834
167228
|
wait: false,
|
|
@@ -166843,7 +167237,7 @@ function createMover(deps) {
|
|
|
166843
167237
|
if (pickedId === request7.from) {
|
|
166844
167238
|
return { kind: "stay", reason: `no other member of pool "${pool}" can take it` };
|
|
166845
167239
|
}
|
|
166846
|
-
const transcript = pickedId === void 0 ? void 0 :
|
|
167240
|
+
const transcript = pickedId === void 0 ? void 0 : import_node_path93.default.join(paths.identitiesDir, pickedId, "projects", projectDirNameOf(deps.cwd), `${request7.conversationId ?? request7.sessionId}.jsonl`);
|
|
166847
167241
|
if (pickedId === void 0 || transcript === void 0 || farmFs.lstat(transcript)?.kind !== "file") {
|
|
166848
167242
|
return { kind: "stay", reason: `${resolution.identity} does not share this conversation's history, so it could not resume it` };
|
|
166849
167243
|
}
|
|
@@ -166885,7 +167279,7 @@ function createIdentityMover(deps) {
|
|
|
166885
167279
|
if (request7.to === request7.from) {
|
|
166886
167280
|
return { kind: "stay", reason: `the model already runs under this session's identity` };
|
|
166887
167281
|
}
|
|
166888
|
-
const transcript =
|
|
167282
|
+
const transcript = import_node_path93.default.join(paths.identitiesDir, request7.to, "projects", projectDirNameOf(deps.cwd), `${request7.conversationId ?? request7.sessionId}.jsonl`);
|
|
166889
167283
|
if (farmFs.lstat(transcript)?.kind !== "file") {
|
|
166890
167284
|
return { kind: "stay", reason: `${toName} does not share this conversation's history, so it could not resume it` };
|
|
166891
167285
|
}
|
|
@@ -166906,6 +167300,60 @@ function createIdentityMover(deps) {
|
|
|
166906
167300
|
};
|
|
166907
167301
|
}
|
|
166908
167302
|
|
|
167303
|
+
// src/supervise/stopSummary.ts
|
|
167304
|
+
init_zod();
|
|
167305
|
+
var FinishedStopSchema = external_exports.object({
|
|
167306
|
+
type: external_exports.literal("system"),
|
|
167307
|
+
subtype: external_exports.literal("stop_hook_summary"),
|
|
167308
|
+
sessionId: external_exports.string(),
|
|
167309
|
+
timestamp: external_exports.iso.datetime(),
|
|
167310
|
+
preventedContinuation: external_exports.literal(false),
|
|
167311
|
+
stopReason: external_exports.literal(""),
|
|
167312
|
+
hookErrors: external_exports.array(external_exports.unknown()).length(0)
|
|
167313
|
+
});
|
|
167314
|
+
function stopHooksFinished(text5, conversationId, markedAt) {
|
|
167315
|
+
if (!text5.endsWith("\n")) {
|
|
167316
|
+
return false;
|
|
167317
|
+
}
|
|
167318
|
+
const lines = text5.split("\n");
|
|
167319
|
+
for (let index = lines.length - 2; index >= 0; index -= 1) {
|
|
167320
|
+
const line = lines[index];
|
|
167321
|
+
if (line === void 0 || line === "") {
|
|
167322
|
+
continue;
|
|
167323
|
+
}
|
|
167324
|
+
let record3;
|
|
167325
|
+
try {
|
|
167326
|
+
record3 = JSON.parse(line);
|
|
167327
|
+
} catch {
|
|
167328
|
+
return false;
|
|
167329
|
+
}
|
|
167330
|
+
if (typeof record3 !== "object" || record3 === null || !("type" in record3)) {
|
|
167331
|
+
return false;
|
|
167332
|
+
}
|
|
167333
|
+
if (record3.type === "user" || record3.type === "assistant" || record3.type === "attachment") {
|
|
167334
|
+
return false;
|
|
167335
|
+
}
|
|
167336
|
+
if (record3.type === "system" && "subtype" in record3 && record3.subtype === "stop_hook_summary") {
|
|
167337
|
+
const parsed = FinishedStopSchema.safeParse(record3);
|
|
167338
|
+
return parsed.success && parsed.data.sessionId === conversationId && Date.parse(parsed.data.timestamp) >= Date.parse(markedAt);
|
|
167339
|
+
}
|
|
167340
|
+
}
|
|
167341
|
+
return false;
|
|
167342
|
+
}
|
|
167343
|
+
|
|
167344
|
+
// src/supervise/settings.ts
|
|
167345
|
+
var import_node_path94 = __toESM(require("node:path"), 1);
|
|
167346
|
+
function stageSupervisedSettings(fs36, paths, pool, sessionId, pid, contents) {
|
|
167347
|
+
const directory = import_node_path94.default.join(superviseDirOf(paths, pool), "settings");
|
|
167348
|
+
const file2 = import_node_path94.default.join(directory, `${sessionId}.${String(pid)}.json`);
|
|
167349
|
+
fs36.mkdirPrivate(directory);
|
|
167350
|
+
fs36.writeFilePrivate(file2, `${contents}
|
|
167351
|
+
`);
|
|
167352
|
+
return { file: file2, release: () => {
|
|
167353
|
+
fs36.removeRecursive(file2);
|
|
167354
|
+
} };
|
|
167355
|
+
}
|
|
167356
|
+
|
|
166909
167357
|
// src/supervise/supervise.ts
|
|
166910
167358
|
init_hold();
|
|
166911
167359
|
init_spawn();
|
|
@@ -166942,11 +167390,16 @@ async function stopChild(deps, child) {
|
|
|
166942
167390
|
deps.resetTerminal();
|
|
166943
167391
|
return result;
|
|
166944
167392
|
}
|
|
166945
|
-
async function runChild2(deps, plan, identity,
|
|
167393
|
+
async function runChild2(deps, plan, identity, compactedConversation, onCompacted) {
|
|
166946
167394
|
const startedMs = deps.now();
|
|
166947
167395
|
const child = deps.spawn.spawn(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
|
|
166948
167396
|
plan.markChildStarted();
|
|
166949
|
-
const state = { terminating: false, leaving: false, checking: false, wakes: 0, declined: false, lastWarning: "" };
|
|
167397
|
+
const state = { terminating: false, leaving: false, checking: false, compacting: false, wakes: 0, declined: false, lastWarning: "" };
|
|
167398
|
+
const liveAbort = new AbortController();
|
|
167399
|
+
let attemptedWake = -1;
|
|
167400
|
+
let liveTask;
|
|
167401
|
+
let compacted = compactedConversation;
|
|
167402
|
+
let recheck = () => void 0;
|
|
166950
167403
|
const stopHandlers = [
|
|
166951
167404
|
...["SIGHUP", "SIGTERM"].map(
|
|
166952
167405
|
(signal) => deps.signals.on(signal, () => {
|
|
@@ -166961,30 +167414,60 @@ async function runChild2(deps, plan, identity, canCompact) {
|
|
|
166961
167414
|
depart = resolve3;
|
|
166962
167415
|
});
|
|
166963
167416
|
const handleRefusal = async (hit) => {
|
|
166964
|
-
const
|
|
167417
|
+
const conversationId = deps.currentConversationId(plan.sessionId);
|
|
167418
|
+
if (conversationId === void 0) {
|
|
167419
|
+
const warning = `agent-shim: cannot move session ${plan.sessionId}: its current conversation is unknown`;
|
|
167420
|
+
if (warning !== state.lastWarning) {
|
|
167421
|
+
state.lastWarning = warning;
|
|
167422
|
+
deps.log.warn(warning);
|
|
167423
|
+
}
|
|
167424
|
+
return;
|
|
167425
|
+
}
|
|
167426
|
+
const outcome = await deps.decideMove({ sessionId: plan.sessionId, ...conversationId === plan.sessionId ? {} : { conversationId }, from: identity, contextTokens: deps.contextTokens(conversationId) });
|
|
166965
167427
|
if (outcome.kind === "move") {
|
|
166966
167428
|
state.leaving = true;
|
|
166967
|
-
depart(outcome);
|
|
167429
|
+
depart({ ...outcome, conversationId });
|
|
166968
167430
|
} else {
|
|
166969
167431
|
state.declined = true;
|
|
166970
167432
|
deps.log.warn(`agent-shim: ${labelOf3(deps, identity)} is out of quota${hit.resetAt === void 0 ? "" : ` until ${hit.resetAt}`}, and this session stays on it: ${outcome.reason}`);
|
|
166971
167433
|
}
|
|
166972
167434
|
};
|
|
166973
167435
|
const considerCompacting = (compaction) => {
|
|
167436
|
+
const live = compaction.live;
|
|
167437
|
+
if (live === void 0 || state.compacting || attemptedWake === state.wakes) return;
|
|
166974
167438
|
const decision = compaction.shouldCompact(identity, plan.sessionId);
|
|
166975
|
-
if (!decision.compact)
|
|
167439
|
+
if (!decision.compact || (decision.conversationId ?? plan.sessionId) === compacted) return;
|
|
167440
|
+
if (!live.ready()) {
|
|
167441
|
+
const warning = `agent-shim: cannot compact session ${plan.sessionId}: the in-process plugin is not ready`;
|
|
167442
|
+
if (warning !== state.lastWarning) {
|
|
167443
|
+
state.lastWarning = warning;
|
|
167444
|
+
deps.log.warn(warning);
|
|
167445
|
+
}
|
|
166976
167446
|
return;
|
|
166977
167447
|
}
|
|
166978
167448
|
const slot = compaction.acquire(identity);
|
|
166979
|
-
if (slot === void 0)
|
|
166980
|
-
|
|
166981
|
-
|
|
166982
|
-
|
|
166983
|
-
|
|
166984
|
-
|
|
166985
|
-
|
|
167449
|
+
if (slot === void 0) return;
|
|
167450
|
+
state.compacting = true;
|
|
167451
|
+
attemptedWake = state.wakes;
|
|
167452
|
+
const conversationId = decision.conversationId ?? plan.sessionId;
|
|
167453
|
+
deps.log.info(`agent-shim: ${decision.reason}; compacting session ${plan.sessionId} in process`);
|
|
167454
|
+
liveTask = live.compact(conversationId, liveAbort.signal).then((result) => {
|
|
167455
|
+
if (result.kind === "compacted") {
|
|
167456
|
+
if (compaction.markCompacted(plan.sessionId, true, conversationId)) {
|
|
167457
|
+
compacted = conversationId;
|
|
167458
|
+
onCompacted(conversationId);
|
|
167459
|
+
}
|
|
167460
|
+
deps.log.info(`agent-shim: compacted session ${plan.sessionId} on ${labelOf3(deps, identity)}`);
|
|
167461
|
+
} else {
|
|
167462
|
+
deps.log.info(`agent-shim: session ${plan.sessionId} was left as it was: ${result.reason}`);
|
|
167463
|
+
}
|
|
167464
|
+
}).catch((error63) => {
|
|
167465
|
+
if (!liveAbort.signal.aborted) deps.log.warn(`agent-shim: could not compact session ${plan.sessionId}: ${messageOf2(error63)}`);
|
|
167466
|
+
}).finally(() => {
|
|
166986
167467
|
slot.release();
|
|
166987
|
-
|
|
167468
|
+
state.compacting = false;
|
|
167469
|
+
if (!liveAbort.signal.aborted && state.wakes > attemptedWake) recheck();
|
|
167470
|
+
});
|
|
166988
167471
|
};
|
|
166989
167472
|
const isLeaving = () => state.leaving;
|
|
166990
167473
|
const check2 = async () => {
|
|
@@ -167000,12 +167483,14 @@ async function runChild2(deps, plan, identity, canCompact) {
|
|
|
167000
167483
|
if (isLeaving()) {
|
|
167001
167484
|
break;
|
|
167002
167485
|
}
|
|
167003
|
-
|
|
167004
|
-
|
|
167005
|
-
|
|
167486
|
+
if (state.compacting) continue;
|
|
167487
|
+
const currentConversation2 = deps.currentConversationId(plan.sessionId);
|
|
167488
|
+
const move = currentConversation2 === void 0 ? void 0 : deps.claimModelMove(plan.sessionId);
|
|
167489
|
+
if (move !== void 0 && currentConversation2 !== void 0) {
|
|
167490
|
+
const outcome = deps.decideRemodel({ sessionId: plan.sessionId, ...currentConversation2 === plan.sessionId ? {} : { conversationId: currentConversation2 }, from: identity, to: move.to, contextTokens: deps.contextTokens(currentConversation2) });
|
|
167006
167491
|
if (outcome.kind === "move") {
|
|
167007
167492
|
state.leaving = true;
|
|
167008
|
-
depart({ kind: "remodel", to: outcome.to, model: move.model });
|
|
167493
|
+
depart({ kind: "remodel", to: outcome.to, model: move.model, conversationId: currentConversation2 });
|
|
167009
167494
|
} else {
|
|
167010
167495
|
deps.log.warn(`agent-shim: session ${plan.sessionId} picked a model under ${labelOf3(deps, move.to)}, but stays on ${labelOf3(deps, identity)}: ${outcome.reason}`);
|
|
167011
167496
|
}
|
|
@@ -167019,7 +167504,7 @@ async function runChild2(deps, plan, identity, canCompact) {
|
|
|
167019
167504
|
continue;
|
|
167020
167505
|
}
|
|
167021
167506
|
state.declined = false;
|
|
167022
|
-
if (
|
|
167507
|
+
if (deps.compaction !== void 0) {
|
|
167023
167508
|
considerCompacting(deps.compaction);
|
|
167024
167509
|
}
|
|
167025
167510
|
} while (handled !== state.wakes);
|
|
@@ -167033,6 +167518,9 @@ async function runChild2(deps, plan, identity, canCompact) {
|
|
|
167033
167518
|
state.checking = false;
|
|
167034
167519
|
}
|
|
167035
167520
|
};
|
|
167521
|
+
recheck = () => {
|
|
167522
|
+
void check2();
|
|
167523
|
+
};
|
|
167036
167524
|
const stopWatching = deps.watchChanges(identity, () => {
|
|
167037
167525
|
void check2();
|
|
167038
167526
|
});
|
|
@@ -167047,17 +167535,16 @@ async function runChild2(deps, plan, identity, canCompact) {
|
|
|
167047
167535
|
return first;
|
|
167048
167536
|
}
|
|
167049
167537
|
deps.log.info(
|
|
167050
|
-
first.kind === "move" ? `agent-shim: ${labelOf3(deps, identity)} is out of quota; resuming session ${plan.sessionId} under ${labelOf3(deps, first.to)} (${first.explanation})` :
|
|
167538
|
+
first.kind === "move" ? `agent-shim: ${labelOf3(deps, identity)} is out of quota; resuming session ${plan.sessionId} under ${labelOf3(deps, first.to)} (${first.explanation})` : `agent-shim: resuming session ${plan.sessionId} under ${labelOf3(deps, first.to)} with ${first.model}, which only runs there`
|
|
167051
167539
|
);
|
|
167052
167540
|
const result = await stopChild(deps, child);
|
|
167053
167541
|
if (state.terminating) {
|
|
167054
|
-
if (first.kind === "compact") {
|
|
167055
|
-
first.slot.release();
|
|
167056
|
-
}
|
|
167057
167542
|
return { kind: "exited", result };
|
|
167058
167543
|
}
|
|
167059
167544
|
return first;
|
|
167060
167545
|
} finally {
|
|
167546
|
+
liveAbort.abort();
|
|
167547
|
+
await liveTask;
|
|
167061
167548
|
stopWatching();
|
|
167062
167549
|
stopWatchingMoves?.();
|
|
167063
167550
|
for (const stop of stopHandlers) {
|
|
@@ -167068,7 +167555,7 @@ async function runChild2(deps, plan, identity, canCompact) {
|
|
|
167068
167555
|
function signalExit(signal) {
|
|
167069
167556
|
return childExitCode({ status: null, signal });
|
|
167070
167557
|
}
|
|
167071
|
-
async function compactSession(deps, compaction, slot, identity, sessionId) {
|
|
167558
|
+
async function compactSession(deps, compaction, slot, identity, sessionId, conversationId = sessionId) {
|
|
167072
167559
|
const abort = new AbortController();
|
|
167073
167560
|
const interrupted = { signal: void 0 };
|
|
167074
167561
|
const stopHandlers = ["SIGINT", "SIGHUP", "SIGTERM"].map(
|
|
@@ -167078,7 +167565,7 @@ async function compactSession(deps, compaction, slot, identity, sessionId) {
|
|
|
167078
167565
|
})
|
|
167079
167566
|
);
|
|
167080
167567
|
try {
|
|
167081
|
-
const result = await compaction.compact({ identity: memberName(deps, identity), sessionId, cwd: deps.cwd }, abort.signal);
|
|
167568
|
+
const result = await compaction.compact({ identity: memberName(deps, identity), sessionId: conversationId, cwd: deps.cwd }, abort.signal);
|
|
167082
167569
|
if (result.kind === "unchanged") {
|
|
167083
167570
|
deps.log.info(`agent-shim: session ${sessionId} was left as it was: ${result.reason}`);
|
|
167084
167571
|
} else {
|
|
@@ -167100,9 +167587,9 @@ async function compactSession(deps, compaction, slot, identity, sessionId) {
|
|
|
167100
167587
|
}
|
|
167101
167588
|
async function supervise(deps, first) {
|
|
167102
167589
|
const { compaction } = deps;
|
|
167103
|
-
const base = { sessionId: first.sessionId, ...first.settings === void 0 ? {} : { settings: first.settings } };
|
|
167590
|
+
const base = { sessionId: first.sessionId, ...first.settings === void 0 ? {} : { settings: first.settings }, ...first.settingsFile === void 0 ? {} : { settingsFile: first.settingsFile } };
|
|
167104
167591
|
let launch = first;
|
|
167105
|
-
let compactedHere
|
|
167592
|
+
let compactedHere;
|
|
167106
167593
|
try {
|
|
167107
167594
|
for (let moved = false; ; moved = true) {
|
|
167108
167595
|
const plan = deps.prepare(launch);
|
|
@@ -167120,7 +167607,9 @@ async function supervise(deps, first) {
|
|
|
167120
167607
|
}
|
|
167121
167608
|
let outcome;
|
|
167122
167609
|
try {
|
|
167123
|
-
outcome = await runChild2(deps, plan, identity,
|
|
167610
|
+
outcome = await runChild2(deps, plan, identity, compactedHere, (conversationId) => {
|
|
167611
|
+
compactedHere = conversationId;
|
|
167612
|
+
});
|
|
167124
167613
|
} finally {
|
|
167125
167614
|
plan.release();
|
|
167126
167615
|
}
|
|
@@ -167130,24 +167619,15 @@ async function supervise(deps, first) {
|
|
|
167130
167619
|
}
|
|
167131
167620
|
return childExitCode(outcome.result);
|
|
167132
167621
|
}
|
|
167133
|
-
|
|
167134
|
-
|
|
167135
|
-
|
|
167136
|
-
if (interrupted !== void 0) {
|
|
167137
|
-
return signalExit(interrupted);
|
|
167138
|
-
}
|
|
167139
|
-
launch = { ...base, conversation: "resume", member: memberName(deps, identity) };
|
|
167140
|
-
continue;
|
|
167141
|
-
}
|
|
167142
|
-
launch = { ...base, conversation: "resume", member: memberName(deps, outcome.to), from: labelOf3(deps, identity), ...outcome.kind === "remodel" ? { model: outcome.model } : {} };
|
|
167143
|
-
const compactedOnOld = compactedHere;
|
|
167144
|
-
compactedHere = false;
|
|
167622
|
+
launch = { ...base, conversation: "resume", ...outcome.conversationId === plan.sessionId ? {} : { conversationId: outcome.conversationId }, member: memberName(deps, outcome.to), from: labelOf3(deps, identity), ...outcome.kind === "remodel" ? { model: outcome.model } : {} };
|
|
167623
|
+
const compactedOnOld = compactedHere === outcome.conversationId;
|
|
167624
|
+
compactedHere = void 0;
|
|
167145
167625
|
if (compaction !== void 0) {
|
|
167146
167626
|
compaction.markCompacted(plan.sessionId, false);
|
|
167147
167627
|
const slot = compactedOnOld ? void 0 : compaction.acquire(outcome.to);
|
|
167148
167628
|
if (slot !== void 0) {
|
|
167149
|
-
const interrupted = await compactSession(deps, compaction, slot, outcome.to, plan.sessionId);
|
|
167150
|
-
compactedHere =
|
|
167629
|
+
const interrupted = await compactSession(deps, compaction, slot, outcome.to, plan.sessionId, outcome.conversationId);
|
|
167630
|
+
compactedHere = outcome.conversationId;
|
|
167151
167631
|
if (interrupted !== void 0) {
|
|
167152
167632
|
return signalExit(interrupted);
|
|
167153
167633
|
}
|
|
@@ -167172,31 +167652,42 @@ async function runSupervised(params) {
|
|
|
167172
167652
|
log.warn(`agent-shim: pool "${pool}" resumes on a spent quota, which needs a POSIX terminal; this launch runs unsupervised`);
|
|
167173
167653
|
return void 0;
|
|
167174
167654
|
}
|
|
167175
|
-
|
|
167655
|
+
if (params.extraFlags.includes("--")) {
|
|
167656
|
+
log.warn(`agent-shim: pool "${pool}" cannot supervise a launch whose extra flags end option parsing`);
|
|
167657
|
+
return void 0;
|
|
167658
|
+
}
|
|
167659
|
+
const first = initialConversationOf(params.passthrough, { newId: import_node_crypto35.randomUUID, latestId: () => latestConversationId(farm.fs, { claudeHome: farm.claudeHome, cwd: farm.cwd }) });
|
|
167176
167660
|
if ("reason" in first) {
|
|
167177
167661
|
log.warn(`agent-shim: pool "${pool}" resumes on a spent quota, but this launch runs unsupervised: ${first.reason}`);
|
|
167178
167662
|
return void 0;
|
|
167179
167663
|
}
|
|
167180
|
-
let launch = first;
|
|
167181
167664
|
let compaction;
|
|
167182
167665
|
const policy = params.pools[pool];
|
|
167183
|
-
|
|
167184
|
-
|
|
167185
|
-
|
|
167186
|
-
|
|
167187
|
-
|
|
167188
|
-
|
|
167189
|
-
|
|
167190
|
-
|
|
167191
|
-
|
|
167192
|
-
|
|
167193
|
-
|
|
167194
|
-
|
|
167195
|
-
|
|
167196
|
-
|
|
167197
|
-
|
|
167198
|
-
|
|
167199
|
-
|
|
167666
|
+
const markSettings = markHooksSettings(selfInvocation([]), paths.root, pool, first.sessionId);
|
|
167667
|
+
const settingsArgs2 = [...params.extraFlags, ...params.passthrough];
|
|
167668
|
+
const settings2 = hasSettingsArgument(settingsArgs2) ? combineCallerSettings(settingsArgs2, markSettings, (name) => farm.fs.readFileUtf8(import_node_path95.default.resolve(farm.cwd, name))) : void 0;
|
|
167669
|
+
const plugin = policy?.compactBeforeLimit === true ? stageNativeCompactionPlugin() : void 0;
|
|
167670
|
+
if (policy?.compactBeforeLimit === true && plugin !== void 0) {
|
|
167671
|
+
const baseCompaction = createCompactionDeps({
|
|
167672
|
+
paths,
|
|
167673
|
+
fs: realFarmFs,
|
|
167674
|
+
pool,
|
|
167675
|
+
policy,
|
|
167676
|
+
pid: farm.lock.pid,
|
|
167677
|
+
now: farm.now,
|
|
167678
|
+
isRunning: farm.lock.isRunning,
|
|
167679
|
+
sleep: farm.lock.sleep,
|
|
167680
|
+
hooksFinished: (session, state) => {
|
|
167681
|
+
if (hooksPending(realFarmFs, paths, pool, session.sessionId)) {
|
|
167682
|
+
return false;
|
|
167683
|
+
}
|
|
167684
|
+
const conversationId = state.conversationId ?? session.sessionId;
|
|
167685
|
+
const text5 = state.transcriptPath === void 0 ? void 0 : realFarmFs.readFileUtf8(state.transcriptPath);
|
|
167686
|
+
return text5 !== void 0 && stopHooksFinished(text5, conversationId, state.at);
|
|
167687
|
+
},
|
|
167688
|
+
compact: createRealCompactor({ paths, spawnDaemon: params.spawnDaemon })
|
|
167689
|
+
});
|
|
167690
|
+
compaction = { ...baseCompaction, live: { ready: () => nativeCompactionReady(plugin), compact: async (conversationId, signal) => await compactInSession(plugin, conversationId, signal) } };
|
|
167200
167691
|
}
|
|
167201
167692
|
const mover = createMover({
|
|
167202
167693
|
paths,
|
|
@@ -167226,64 +167717,119 @@ async function runSupervised(params) {
|
|
|
167226
167717
|
pickMember: resolvePoolLaunch,
|
|
167227
167718
|
log
|
|
167228
167719
|
});
|
|
167229
|
-
|
|
167230
|
-
|
|
167231
|
-
|
|
167232
|
-
|
|
167233
|
-
|
|
167234
|
-
|
|
167235
|
-
|
|
167236
|
-
|
|
167237
|
-
|
|
167238
|
-
|
|
167239
|
-
|
|
167240
|
-
|
|
167241
|
-
|
|
167242
|
-
|
|
167243
|
-
|
|
167244
|
-
|
|
167245
|
-
|
|
167246
|
-
|
|
167247
|
-
|
|
167248
|
-
|
|
167249
|
-
|
|
167250
|
-
|
|
167251
|
-
|
|
167252
|
-
|
|
167253
|
-
|
|
167254
|
-
|
|
167255
|
-
|
|
167256
|
-
|
|
167257
|
-
|
|
167720
|
+
const staged = settings2 === void 0 ? void 0 : stageSupervisedSettings(realFarmFs, paths, pool, first.sessionId, farm.lock.pid, settings2);
|
|
167721
|
+
const launch = { ...first, ...staged === void 0 ? { settings: markSettings } : { settingsFile: staged.file } };
|
|
167722
|
+
try {
|
|
167723
|
+
return await supervise(
|
|
167724
|
+
{
|
|
167725
|
+
pool,
|
|
167726
|
+
cwd: farm.cwd,
|
|
167727
|
+
pid: farm.lock.pid,
|
|
167728
|
+
prepare: (nextLaunch) => {
|
|
167729
|
+
const plan = params.prepare(nextLaunch);
|
|
167730
|
+
if (plugin === void 0) return plan;
|
|
167731
|
+
(0, import_node_fs40.rmSync)(plugin.ready, { force: true });
|
|
167732
|
+
return { ...plan, args: withNativeCompactionPlugin(plan.args, plugin.directory) };
|
|
167733
|
+
},
|
|
167734
|
+
spawn: realSupervisedSpawnPort,
|
|
167735
|
+
signals: realSignalPort,
|
|
167736
|
+
timer: realTimerPort,
|
|
167737
|
+
watchChanges: (identity, onChange) => {
|
|
167738
|
+
const stopPlugin = plugin === void 0 ? void 0 : realWatchExistingDirectory(plugin.directory, (filename) => filename === "ready.json", "the compaction plugin", log)(onChange);
|
|
167739
|
+
const stopSnapshot = realWatchDirectory(paths.usageSnapshotsDir, (filename) => filename === `${identity}.json`, `${identity}'s usage`, log)(onChange);
|
|
167740
|
+
let watchedDir;
|
|
167741
|
+
let stopTranscripts;
|
|
167742
|
+
let transcriptWarning = "";
|
|
167743
|
+
const watchTranscript = () => {
|
|
167744
|
+
const transcript = readSessionState(realFarmFs, paths, pool, first.sessionId)?.transcriptPath;
|
|
167745
|
+
const directory = transcript === void 0 ? void 0 : import_node_path95.default.dirname(transcript);
|
|
167746
|
+
if (compaction === void 0 || directory === watchedDir) {
|
|
167747
|
+
return;
|
|
167748
|
+
}
|
|
167749
|
+
stopTranscripts?.();
|
|
167750
|
+
watchedDir = void 0;
|
|
167751
|
+
stopTranscripts = void 0;
|
|
167752
|
+
if (directory !== void 0 && realFarmFs.lstat(directory) !== void 0) {
|
|
167753
|
+
try {
|
|
167754
|
+
stopTranscripts = realWatchExistingDirectory(directory, (filename) => filename.endsWith(".jsonl"), "the session transcripts", log)(onChange);
|
|
167755
|
+
watchedDir = directory;
|
|
167756
|
+
transcriptWarning = "";
|
|
167757
|
+
} catch (error63) {
|
|
167758
|
+
const warning = `agent-shim: could not watch the session transcripts: ${error63 instanceof Error ? error63.message : String(error63)}`;
|
|
167759
|
+
if (warning !== transcriptWarning) {
|
|
167760
|
+
transcriptWarning = warning;
|
|
167761
|
+
log.warn(warning);
|
|
167762
|
+
}
|
|
167763
|
+
}
|
|
167764
|
+
}
|
|
167765
|
+
};
|
|
167766
|
+
const stopState = realWatchDirectory(stateDirOf(paths, pool), (filename) => filename.endsWith(".json"), "the pool's sessions", log)(() => {
|
|
167767
|
+
watchTranscript();
|
|
167768
|
+
onChange();
|
|
167769
|
+
});
|
|
167770
|
+
watchTranscript();
|
|
167771
|
+
if (plugin !== void 0 && nativeCompactionReady(plugin)) queueMicrotask(onChange);
|
|
167772
|
+
return () => {
|
|
167773
|
+
stopPlugin?.();
|
|
167774
|
+
stopSnapshot();
|
|
167775
|
+
stopState();
|
|
167776
|
+
stopTranscripts?.();
|
|
167777
|
+
};
|
|
167778
|
+
},
|
|
167779
|
+
quotaHit: (identity, sessionId, sinceMs) => quotaHitOf(realFarmFs, paths, identity, sessionId, sinceMs, farm.now()),
|
|
167780
|
+
decideMove: async (request7) => {
|
|
167781
|
+
await refreshPools({ paths, cwd: farm.cwd, poolNames: [pool], spawnDaemon: params.spawnDaemon, log: (line) => {
|
|
167782
|
+
log.warn(line);
|
|
167783
|
+
} });
|
|
167784
|
+
return mover(request7);
|
|
167785
|
+
},
|
|
167786
|
+
contextTokens: (sessionId) => {
|
|
167787
|
+
const state = readSessionState(realFarmFs, paths, pool, first.sessionId);
|
|
167788
|
+
if (state?.transcriptPath === void 0 || (state.conversationId ?? first.sessionId) !== sessionId) {
|
|
167789
|
+
return void 0;
|
|
167790
|
+
}
|
|
167791
|
+
const transcript = realFarmFs.readFileUtf8(state.transcriptPath);
|
|
167792
|
+
return transcript === void 0 ? void 0 : contextTokensOfTranscript(transcript);
|
|
167793
|
+
},
|
|
167794
|
+
currentConversationId: (sessionId) => currentConversation(realFarmFs, paths, pool, sessionId),
|
|
167795
|
+
claimModelMove: (sessionId) => {
|
|
167796
|
+
const request7 = readModelMove(realFarmFs, paths, sessionId);
|
|
167797
|
+
if (request7 === void 0) {
|
|
167798
|
+
return void 0;
|
|
167799
|
+
}
|
|
167800
|
+
removeModelMove(realFarmFs, paths, sessionId);
|
|
167801
|
+
return { to: request7.to, model: request7.model };
|
|
167802
|
+
},
|
|
167803
|
+
decideRemodel: (request7) => identityMover(request7),
|
|
167804
|
+
watchModelMoves: (onChange) => realWatchDirectory(paths.modelMovesDir, () => true, "the model-move requests", log)(onChange),
|
|
167805
|
+
...compaction === void 0 ? {} : { compaction },
|
|
167806
|
+
register: (session) => {
|
|
167807
|
+
registerSupervised(realFarmFs, paths, session);
|
|
167808
|
+
},
|
|
167809
|
+
unregister: (sessionId) => {
|
|
167810
|
+
unregisterSupervised(realFarmFs, paths, pool, sessionId);
|
|
167811
|
+
},
|
|
167812
|
+
resetTerminal,
|
|
167813
|
+
now: farm.now,
|
|
167814
|
+
log,
|
|
167815
|
+
// An identity whose name cannot be read is named by its id, which reaches it, so its relaunch reports the file.
|
|
167816
|
+
nameOf: (id2) => {
|
|
167817
|
+
const record3 = identityRecordsOver(realFarmFs, paths.identitiesDir).find((candidate) => candidate.id === id2);
|
|
167818
|
+
return record3 === void 0 ? void 0 : record3.name ?? record3.id;
|
|
167258
167819
|
}
|
|
167259
|
-
removeModelMove(realFarmFs, paths, sessionId);
|
|
167260
|
-
return { to: request7.to, model: request7.model };
|
|
167261
|
-
},
|
|
167262
|
-
decideRemodel: (request7) => identityMover({ sessionId: request7.sessionId, from: request7.from, to: request7.to, contextTokens: void 0 }),
|
|
167263
|
-
watchModelMoves: (onChange) => realWatchDirectory(paths.modelMovesDir, () => true, "the model-move requests", log)(onChange),
|
|
167264
|
-
...compaction === void 0 ? {} : { compaction },
|
|
167265
|
-
register: (session) => {
|
|
167266
|
-
registerSupervised(realFarmFs, paths, session);
|
|
167267
167820
|
},
|
|
167268
|
-
|
|
167269
|
-
|
|
167270
|
-
|
|
167271
|
-
|
|
167272
|
-
|
|
167273
|
-
|
|
167274
|
-
// An identity whose name cannot be read is named by its id, which reaches it, so its relaunch reports the file.
|
|
167275
|
-
nameOf: (id2) => {
|
|
167276
|
-
const record3 = identityRecordsOver(realFarmFs, paths.identitiesDir).find((candidate) => candidate.id === id2);
|
|
167277
|
-
return record3 === void 0 ? void 0 : record3.name ?? record3.id;
|
|
167278
|
-
}
|
|
167279
|
-
},
|
|
167280
|
-
launch
|
|
167281
|
-
);
|
|
167821
|
+
launch
|
|
167822
|
+
);
|
|
167823
|
+
} finally {
|
|
167824
|
+
staged?.release();
|
|
167825
|
+
plugin?.release();
|
|
167826
|
+
}
|
|
167282
167827
|
}
|
|
167283
167828
|
|
|
167284
167829
|
// src/runClaude.ts
|
|
167285
167830
|
init_launcher();
|
|
167286
167831
|
init_argv();
|
|
167832
|
+
init_extraFlags();
|
|
167287
167833
|
|
|
167288
167834
|
// src/launcher/native.ts
|
|
167289
167835
|
init_cliError();
|
|
@@ -167416,6 +167962,7 @@ async function runClaude(argvOverride) {
|
|
|
167416
167962
|
pools: farm.pools,
|
|
167417
167963
|
farm: farm.runtime,
|
|
167418
167964
|
passthrough: nativeArgv.rest,
|
|
167965
|
+
extraFlags: splitExtraFlags(procForDecision.env.CLAUDE_EXTRA_FLAGS),
|
|
167419
167966
|
// The launch-time update check runs for the first launch only: its notice must not land on the terminal between a stopped child and its relaunch.
|
|
167420
167967
|
prepare: (launch) => prepareLaunch(launch.member === void 0 ? { ...prepareParams, supervised: launch } : { ...prepareParams, update: void 0, supervised: launch }),
|
|
167421
167968
|
spawnDaemon: spawnDetachedSupervisor,
|
|
@@ -167431,7 +167978,7 @@ async function runClaude(argvOverride) {
|
|
|
167431
167978
|
// src/cli.ts
|
|
167432
167979
|
async function main() {
|
|
167433
167980
|
aliasLegacyEnv(process.env);
|
|
167434
|
-
const invokedName =
|
|
167981
|
+
const invokedName = import_node_path96.default.basename(process.argv[1] ?? "agent-shim");
|
|
167435
167982
|
if (isInvokedAsClaude(invokedName)) {
|
|
167436
167983
|
await runClaude();
|
|
167437
167984
|
return;
|