claude-use 11.87.4 → 11.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli.cjs +1026 -582
- package/dist/index.cjs +531 -185
- package/dist/index.mjs +516 -183
- package/dist/types/index.d.ts +388 -5
- 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, path99) {
|
|
323
|
+
if (!path99)
|
|
324
324
|
return obj;
|
|
325
|
-
return
|
|
325
|
+
return path99.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(path99, 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(path99);
|
|
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, path99 = []) => {
|
|
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 }, [...path99, ...issue2.path]));
|
|
1125
1125
|
} else if (issue2.code === "invalid_key") {
|
|
1126
|
-
processError({ issues: issue2.issues }, [...
|
|
1126
|
+
processError({ issues: issue2.issues }, [...path99, ...issue2.path]);
|
|
1127
1127
|
} else if (issue2.code === "invalid_element") {
|
|
1128
|
-
processError({ issues: issue2.issues }, [...
|
|
1128
|
+
processError({ issues: issue2.issues }, [...path99, ...issue2.path]);
|
|
1129
1129
|
} else {
|
|
1130
|
-
const fullpath = [...
|
|
1130
|
+
const fullpath = [...path99, ...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, path99 = []) => {
|
|
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 }, [...path99, ...issue2.path]));
|
|
1174
1174
|
} else if (issue2.code === "invalid_key") {
|
|
1175
|
-
processError({ issues: issue2.issues }, [...
|
|
1175
|
+
processError({ issues: issue2.issues }, [...path99, ...issue2.path]);
|
|
1176
1176
|
} else if (issue2.code === "invalid_element") {
|
|
1177
|
-
processError({ issues: issue2.issues }, [...
|
|
1177
|
+
processError({ issues: issue2.issues }, [...path99, ...issue2.path]);
|
|
1178
1178
|
} else {
|
|
1179
|
-
const fullpath = [...
|
|
1179
|
+
const fullpath = [...path99, ...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 path99 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1219
|
+
for (const seg of path99) {
|
|
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 path99 = ref.slice(1).split("/").filter(Boolean);
|
|
19252
|
+
if (path99.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 (path99[0] === defsKey) {
|
|
19257
|
+
const key = path99[1] === void 0 ? void 0 : decodeJSONPointerSegment(path99[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 path99 = require("path");
|
|
23765
23765
|
var os24 = require("os");
|
|
23766
23766
|
var homedir = os24.homedir();
|
|
23767
23767
|
var tmpdir2 = os24.tmpdir();
|
|
23768
23768
|
var { env } = process;
|
|
23769
23769
|
var macos = (name) => {
|
|
23770
|
-
const library =
|
|
23770
|
+
const library = path99.join(homedir, "Library");
|
|
23771
23771
|
return {
|
|
23772
|
-
data:
|
|
23773
|
-
config:
|
|
23774
|
-
cache:
|
|
23775
|
-
log:
|
|
23776
|
-
temp:
|
|
23772
|
+
data: path99.join(library, "Application Support", name),
|
|
23773
|
+
config: path99.join(library, "Preferences", name),
|
|
23774
|
+
cache: path99.join(library, "Caches", name),
|
|
23775
|
+
log: path99.join(library, "Logs", name),
|
|
23776
|
+
temp: path99.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 || path99.join(homedir, "AppData", "Roaming");
|
|
23781
|
+
const localAppData = env.LOCALAPPDATA || path99.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: path99.join(localAppData, name, "Data"),
|
|
23785
|
+
config: path99.join(appData, name, "Config"),
|
|
23786
|
+
cache: path99.join(localAppData, name, "Cache"),
|
|
23787
|
+
log: path99.join(localAppData, name, "Log"),
|
|
23788
|
+
temp: path99.join(tmpdir2, name)
|
|
23789
23789
|
};
|
|
23790
23790
|
};
|
|
23791
23791
|
var linux = (name) => {
|
|
23792
|
-
const username =
|
|
23792
|
+
const username = path99.basename(homedir);
|
|
23793
23793
|
return {
|
|
23794
|
-
data:
|
|
23795
|
-
config:
|
|
23796
|
-
cache:
|
|
23794
|
+
data: path99.join(env.XDG_DATA_HOME || path99.join(homedir, ".local", "share"), name),
|
|
23795
|
+
config: path99.join(env.XDG_CONFIG_HOME || path99.join(homedir, ".config"), name),
|
|
23796
|
+
cache: path99.join(env.XDG_CACHE_HOME || path99.join(homedir, ".cache"), name),
|
|
23797
23797
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
23798
|
-
log:
|
|
23799
|
-
temp:
|
|
23798
|
+
log: path99.join(env.XDG_STATE_HOME || path99.join(homedir, ".local", "state"), name),
|
|
23799
|
+
temp: path99.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, path99) {
|
|
23868
|
+
if (typeof path99 === "string" && Object.prototype.hasOwnProperty.call(source, path99)) {
|
|
23869
|
+
return source[path99];
|
|
23870
23870
|
}
|
|
23871
|
-
const parsedPath = typeof
|
|
23871
|
+
const parsedPath = typeof path99 === "string" ? path99.split(".") : path99;
|
|
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(path99) {
|
|
23895
23895
|
try {
|
|
23896
|
-
const stat = await fs_1.promises.stat(
|
|
23896
|
+
const stat = await fs_1.promises.stat(path99);
|
|
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(path99) {
|
|
23907
23907
|
try {
|
|
23908
|
-
const stat = fs_1.default.statSync(
|
|
23908
|
+
const stat = fs_1.default.statSync(path99);
|
|
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((path99, i10) => `${i10 + 1}. ${path99}`).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(path99) {
|
|
24195
24195
|
try {
|
|
24196
|
-
await promises_1.default.stat(
|
|
24196
|
+
await promises_1.default.stat(path99);
|
|
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(path99) {
|
|
24357
24357
|
try {
|
|
24358
|
-
fs_1.default.statSync(
|
|
24358
|
+
fs_1.default.statSync(path99);
|
|
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((path99) => path99.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: path99, keys }) => `${path99.length === 0 ? "" : `${path99.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: path99, values } of ignored) {
|
|
24635
24635
|
let holder = restored2;
|
|
24636
|
-
for (const step2 of
|
|
24636
|
+
for (const step2 of path99) {
|
|
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 = (path99, { windows } = {}) => {
|
|
28815
|
+
const segs = path99.split(windows ? /[\\/]/ : "/");
|
|
28816
28816
|
const last = segs[segs.length - 1];
|
|
28817
28817
|
if (last === "") {
|
|
28818
28818
|
return segs[segs.length - 2];
|
|
@@ -33403,9 +33403,9 @@ var init_identity = __esm({
|
|
|
33403
33403
|
});
|
|
33404
33404
|
|
|
33405
33405
|
// src/statusline/keys.ts
|
|
33406
|
-
function valueAt(source,
|
|
33406
|
+
function valueAt(source, path99) {
|
|
33407
33407
|
let current = source;
|
|
33408
|
-
for (const part of
|
|
33408
|
+
for (const part of path99) {
|
|
33409
33409
|
if (!isPlainObject2(current)) {
|
|
33410
33410
|
return void 0;
|
|
33411
33411
|
}
|
|
@@ -33413,14 +33413,14 @@ function valueAt(source, path98) {
|
|
|
33413
33413
|
}
|
|
33414
33414
|
return current;
|
|
33415
33415
|
}
|
|
33416
|
-
function acceptsNull(
|
|
33417
|
-
const layer =
|
|
33416
|
+
function acceptsNull(path99) {
|
|
33417
|
+
const layer = path99.reduceRight((inner, part) => ({ [part]: inner }), null);
|
|
33418
33418
|
return StatuslineSchema.safeParse(layer).success;
|
|
33419
33419
|
}
|
|
33420
|
-
function keyOf(
|
|
33420
|
+
function keyOf(path99, declared) {
|
|
33421
33421
|
const optional2 = declared instanceof external_exports.ZodOptional;
|
|
33422
33422
|
const leaf = optional2 ? declared.unwrap() : declared;
|
|
33423
|
-
const common = { path:
|
|
33423
|
+
const common = { path: path99.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path99), optional: optional2, unsettable: acceptsNull(path99) };
|
|
33424
33424
|
if (leaf instanceof external_exports.ZodNumber) {
|
|
33425
33425
|
return { ...common, kind: "integer", choices: [] };
|
|
33426
33426
|
}
|
|
@@ -33445,7 +33445,7 @@ function keyOf(path98, declared) {
|
|
|
33445
33445
|
if (leaf instanceof external_exports.ZodArray && leaf.element instanceof external_exports.ZodString) {
|
|
33446
33446
|
return { ...common, kind: "textList", choices: [] };
|
|
33447
33447
|
}
|
|
33448
|
-
throw new TypeError(`statusline setting ${
|
|
33448
|
+
throw new TypeError(`statusline setting ${path99.join(".")} has a kind the key listing does not describe`);
|
|
33449
33449
|
}
|
|
33450
33450
|
function walk(shape, prefix) {
|
|
33451
33451
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof external_exports.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -33476,14 +33476,14 @@ var init_keys = __esm({
|
|
|
33476
33476
|
});
|
|
33477
33477
|
|
|
33478
33478
|
// src/statusline/change.ts
|
|
33479
|
-
function keyNamed(
|
|
33480
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
33479
|
+
function keyNamed(path99) {
|
|
33480
|
+
const found = statuslineKeys().find((key) => key.path === path99);
|
|
33481
33481
|
if (found === void 0) {
|
|
33482
|
-
throw new UsageError(`"${
|
|
33482
|
+
throw new UsageError(`"${path99}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
33483
33483
|
}
|
|
33484
33484
|
return found;
|
|
33485
33485
|
}
|
|
33486
|
-
function textListOf(
|
|
33486
|
+
function textListOf(path99, raw) {
|
|
33487
33487
|
if (raw === "") {
|
|
33488
33488
|
return [];
|
|
33489
33489
|
}
|
|
@@ -33491,10 +33491,10 @@ function textListOf(path98, raw) {
|
|
|
33491
33491
|
try {
|
|
33492
33492
|
parsed = JSON.parse(raw);
|
|
33493
33493
|
} catch {
|
|
33494
|
-
throw new UsageError(`${
|
|
33494
|
+
throw new UsageError(`${path99}: "${raw}" is not a JSON array of strings such as ["git","describe"].`);
|
|
33495
33495
|
}
|
|
33496
33496
|
if (!Array.isArray(parsed) || parsed.some((item) => typeof item !== "string")) {
|
|
33497
|
-
throw new UsageError(`${
|
|
33497
|
+
throw new UsageError(`${path99}: "${raw}" is not a JSON array of strings such as ["git","describe"].`);
|
|
33498
33498
|
}
|
|
33499
33499
|
return parsed;
|
|
33500
33500
|
}
|
|
@@ -33503,42 +33503,42 @@ function parseStatuslineAssignment(text5) {
|
|
|
33503
33503
|
if (split < 1) {
|
|
33504
33504
|
throw new UsageError(`"${text5}" is not <setting>=<value>.`);
|
|
33505
33505
|
}
|
|
33506
|
-
const
|
|
33506
|
+
const path99 = text5.slice(0, split);
|
|
33507
33507
|
const raw = text5.slice(split + 1);
|
|
33508
|
-
const key = keyNamed(
|
|
33508
|
+
const key = keyNamed(path99);
|
|
33509
33509
|
if (key.unsettable && raw === UNSET_WORD) {
|
|
33510
|
-
return { path:
|
|
33510
|
+
return { path: path99, value: null };
|
|
33511
33511
|
}
|
|
33512
33512
|
switch (key.kind) {
|
|
33513
33513
|
case "integer": {
|
|
33514
33514
|
const number6 = Number(raw);
|
|
33515
33515
|
if (raw.trim() === "" || !Number.isFinite(number6)) {
|
|
33516
|
-
throw new UsageError(`${
|
|
33516
|
+
throw new UsageError(`${path99}: "${raw}" is not a number.`);
|
|
33517
33517
|
}
|
|
33518
|
-
return { path:
|
|
33518
|
+
return { path: path99, value: number6 };
|
|
33519
33519
|
}
|
|
33520
33520
|
case "boolean":
|
|
33521
33521
|
if (raw !== "true" && raw !== "false") {
|
|
33522
|
-
throw new UsageError(`${
|
|
33522
|
+
throw new UsageError(`${path99}: "${raw}" is not true or false.`);
|
|
33523
33523
|
}
|
|
33524
|
-
return { path:
|
|
33524
|
+
return { path: path99, value: raw === "true" };
|
|
33525
33525
|
case "text":
|
|
33526
33526
|
case "choice":
|
|
33527
|
-
return { path:
|
|
33527
|
+
return { path: path99, value: raw };
|
|
33528
33528
|
case "colour":
|
|
33529
|
-
return { path:
|
|
33529
|
+
return { path: path99, value: /^\d+$/.test(raw) ? Number(raw) : raw };
|
|
33530
33530
|
case "list":
|
|
33531
|
-
return { path:
|
|
33531
|
+
return { path: path99, value: raw === "" ? [] : raw.split(",") };
|
|
33532
33532
|
case "groups":
|
|
33533
|
-
return { path:
|
|
33533
|
+
return { path: path99, value: raw === "" ? [] : raw.split(";").map((group) => group.split(",")) };
|
|
33534
33534
|
case "textList":
|
|
33535
|
-
return { path:
|
|
33535
|
+
return { path: path99, value: textListOf(path99, raw) };
|
|
33536
33536
|
default:
|
|
33537
33537
|
return key.kind;
|
|
33538
33538
|
}
|
|
33539
33539
|
}
|
|
33540
|
-
function setAt(target,
|
|
33541
|
-
const [head, ...rest] =
|
|
33540
|
+
function setAt(target, path99, value3) {
|
|
33541
|
+
const [head, ...rest] = path99;
|
|
33542
33542
|
if (head === void 0) {
|
|
33543
33543
|
return;
|
|
33544
33544
|
}
|
|
@@ -33551,8 +33551,8 @@ function setAt(target, path98, value3) {
|
|
|
33551
33551
|
target[head] = next;
|
|
33552
33552
|
setAt(next, rest, value3);
|
|
33553
33553
|
}
|
|
33554
|
-
function removeAt(target,
|
|
33555
|
-
const [head, ...rest] =
|
|
33554
|
+
function removeAt(target, path99) {
|
|
33555
|
+
const [head, ...rest] = path99;
|
|
33556
33556
|
if (head === void 0) {
|
|
33557
33557
|
return;
|
|
33558
33558
|
}
|
|
@@ -33570,13 +33570,13 @@ function removeAt(target, path98) {
|
|
|
33570
33570
|
}
|
|
33571
33571
|
function applyStatuslineChange(existing, change) {
|
|
33572
33572
|
const draft = structuredClone(existing ?? {});
|
|
33573
|
-
for (const [
|
|
33574
|
-
keyNamed(
|
|
33575
|
-
setAt(draft,
|
|
33573
|
+
for (const [path99, value3] of Object.entries(change.set ?? {})) {
|
|
33574
|
+
keyNamed(path99);
|
|
33575
|
+
setAt(draft, path99.split("."), value3);
|
|
33576
33576
|
}
|
|
33577
|
-
for (const
|
|
33578
|
-
keyNamed(
|
|
33579
|
-
removeAt(draft,
|
|
33577
|
+
for (const path99 of change.unset ?? []) {
|
|
33578
|
+
keyNamed(path99);
|
|
33579
|
+
removeAt(draft, path99.split("."));
|
|
33580
33580
|
}
|
|
33581
33581
|
const result = StatuslineSchema.safeParse(draft);
|
|
33582
33582
|
if (!result.success) {
|
|
@@ -33814,19 +33814,19 @@ function writePools(paths, pools) {
|
|
|
33814
33814
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
33815
33815
|
}
|
|
33816
33816
|
function poolCycleOf(pools, name) {
|
|
33817
|
-
const walk3 = (current,
|
|
33817
|
+
const walk3 = (current, path99) => {
|
|
33818
33818
|
for (const entry of pools[current]?.identities ?? []) {
|
|
33819
33819
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
33820
33820
|
if (nested === void 0) {
|
|
33821
33821
|
continue;
|
|
33822
33822
|
}
|
|
33823
33823
|
if (nested === name) {
|
|
33824
|
-
return [...
|
|
33824
|
+
return [...path99, nested];
|
|
33825
33825
|
}
|
|
33826
|
-
if (
|
|
33826
|
+
if (path99.includes(nested)) {
|
|
33827
33827
|
continue;
|
|
33828
33828
|
}
|
|
33829
|
-
const found = walk3(nested, [...
|
|
33829
|
+
const found = walk3(nested, [...path99, nested]);
|
|
33830
33830
|
if (found !== void 0) {
|
|
33831
33831
|
return found;
|
|
33832
33832
|
}
|
|
@@ -36217,11 +36217,11 @@ function identifyRequest(headers) {
|
|
|
36217
36217
|
function directOrigin2(port) {
|
|
36218
36218
|
return `http://127.0.0.1:${String(port)}`;
|
|
36219
36219
|
}
|
|
36220
|
-
function parseProviderPath(
|
|
36221
|
-
if (!
|
|
36220
|
+
function parseProviderPath(path99) {
|
|
36221
|
+
if (!path99.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
36222
36222
|
return void 0;
|
|
36223
36223
|
}
|
|
36224
|
-
const tail =
|
|
36224
|
+
const tail = path99.slice(PROVIDER_PATH_PREFIX.length);
|
|
36225
36225
|
const slash = tail.indexOf("/");
|
|
36226
36226
|
if (slash <= 0) {
|
|
36227
36227
|
return void 0;
|
|
@@ -36557,12 +36557,12 @@ function decoderFor(encoding) {
|
|
|
36557
36557
|
return void 0;
|
|
36558
36558
|
}
|
|
36559
36559
|
}
|
|
36560
|
-
function destinationOf(
|
|
36561
|
-
const scoped = parseProviderPath(
|
|
36560
|
+
function destinationOf(path99, sessionProvider) {
|
|
36561
|
+
const scoped = parseProviderPath(path99);
|
|
36562
36562
|
if (scoped !== void 0) {
|
|
36563
36563
|
return { provider: scoped.provider, endpoint: scoped.rest };
|
|
36564
36564
|
}
|
|
36565
|
-
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint:
|
|
36565
|
+
return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint: path99 };
|
|
36566
36566
|
}
|
|
36567
36567
|
function modelChoiceOf(event, servedModel, provider) {
|
|
36568
36568
|
if (event.modelChoice !== void 0) return event.modelChoice;
|
|
@@ -40759,8 +40759,8 @@ function parseConnectTarget(authority) {
|
|
|
40759
40759
|
}
|
|
40760
40760
|
return { host, port };
|
|
40761
40761
|
}
|
|
40762
|
-
function servedByPipeline(
|
|
40763
|
-
return
|
|
40762
|
+
function servedByPipeline(path99) {
|
|
40763
|
+
return path99?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
40764
40764
|
}
|
|
40765
40765
|
function forwardableHeaders(headers) {
|
|
40766
40766
|
const connectionTokens = new Set(
|
|
@@ -41980,7 +41980,7 @@ var init_package = __esm({
|
|
|
41980
41980
|
"package.json"() {
|
|
41981
41981
|
package_default = {
|
|
41982
41982
|
name: "claude-use",
|
|
41983
|
-
version: "11.
|
|
41983
|
+
version: "11.88.0",
|
|
41984
41984
|
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.",
|
|
41985
41985
|
license: "MIT",
|
|
41986
41986
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -43315,14 +43315,14 @@ var require_util2 = __commonJS({
|
|
|
43315
43315
|
}
|
|
43316
43316
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
43317
43317
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
43318
|
-
let
|
|
43318
|
+
let path99 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
43319
43319
|
if (origin[origin.length - 1] === "/") {
|
|
43320
43320
|
origin = origin.slice(0, origin.length - 1);
|
|
43321
43321
|
}
|
|
43322
|
-
if (
|
|
43323
|
-
|
|
43322
|
+
if (path99 && path99[0] !== "/") {
|
|
43323
|
+
path99 = `/${path99}`;
|
|
43324
43324
|
}
|
|
43325
|
-
return new URL(`${origin}${
|
|
43325
|
+
return new URL(`${origin}${path99}`);
|
|
43326
43326
|
}
|
|
43327
43327
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
43328
43328
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -44143,9 +44143,9 @@ var require_diagnostics = __commonJS({
|
|
|
44143
44143
|
"undici:client:sendHeaders",
|
|
44144
44144
|
(evt) => {
|
|
44145
44145
|
const {
|
|
44146
|
-
request: { method, path:
|
|
44146
|
+
request: { method, path: path99, origin }
|
|
44147
44147
|
} = evt;
|
|
44148
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
44148
|
+
debugLog("sending request to %s %s%s", method, origin, path99);
|
|
44149
44149
|
}
|
|
44150
44150
|
);
|
|
44151
44151
|
}
|
|
@@ -44163,14 +44163,14 @@ var require_diagnostics = __commonJS({
|
|
|
44163
44163
|
"undici:request:headers",
|
|
44164
44164
|
(evt) => {
|
|
44165
44165
|
const {
|
|
44166
|
-
request: { method, path:
|
|
44166
|
+
request: { method, path: path99, origin },
|
|
44167
44167
|
response: { statusCode }
|
|
44168
44168
|
} = evt;
|
|
44169
44169
|
debugLog(
|
|
44170
44170
|
"received response to %s %s%s - HTTP %d",
|
|
44171
44171
|
method,
|
|
44172
44172
|
origin,
|
|
44173
|
-
|
|
44173
|
+
path99,
|
|
44174
44174
|
statusCode
|
|
44175
44175
|
);
|
|
44176
44176
|
}
|
|
@@ -44179,23 +44179,23 @@ var require_diagnostics = __commonJS({
|
|
|
44179
44179
|
"undici:request:trailers",
|
|
44180
44180
|
(evt) => {
|
|
44181
44181
|
const {
|
|
44182
|
-
request: { method, path:
|
|
44182
|
+
request: { method, path: path99, origin }
|
|
44183
44183
|
} = evt;
|
|
44184
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
44184
|
+
debugLog("trailers received from %s %s%s", method, origin, path99);
|
|
44185
44185
|
}
|
|
44186
44186
|
);
|
|
44187
44187
|
diagnosticsChannel.subscribe(
|
|
44188
44188
|
"undici:request:error",
|
|
44189
44189
|
(evt) => {
|
|
44190
44190
|
const {
|
|
44191
|
-
request: { method, path:
|
|
44191
|
+
request: { method, path: path99, origin },
|
|
44192
44192
|
error: error63
|
|
44193
44193
|
} = evt;
|
|
44194
44194
|
debugLog(
|
|
44195
44195
|
"request to %s %s%s errored - %s",
|
|
44196
44196
|
method,
|
|
44197
44197
|
origin,
|
|
44198
|
-
|
|
44198
|
+
path99,
|
|
44199
44199
|
error63.message
|
|
44200
44200
|
);
|
|
44201
44201
|
}
|
|
@@ -44310,7 +44310,7 @@ var require_request = __commonJS({
|
|
|
44310
44310
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
44311
44311
|
var Request2 = class {
|
|
44312
44312
|
constructor(origin, {
|
|
44313
|
-
path:
|
|
44313
|
+
path: path99,
|
|
44314
44314
|
method,
|
|
44315
44315
|
body,
|
|
44316
44316
|
headers,
|
|
@@ -44327,11 +44327,11 @@ var require_request = __commonJS({
|
|
|
44327
44327
|
maxRedirections,
|
|
44328
44328
|
typeOfService
|
|
44329
44329
|
}, handler) {
|
|
44330
|
-
if (typeof
|
|
44330
|
+
if (typeof path99 !== "string") {
|
|
44331
44331
|
throw new InvalidArgumentError2("path must be a string");
|
|
44332
|
-
} else if (
|
|
44332
|
+
} else if (path99[0] !== "/" && !(path99.startsWith("http://") || path99.startsWith("https://")) && method !== "CONNECT") {
|
|
44333
44333
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
44334
|
-
} else if (invalidPathRegex.test(
|
|
44334
|
+
} else if (invalidPathRegex.test(path99)) {
|
|
44335
44335
|
throw new InvalidArgumentError2("invalid request path");
|
|
44336
44336
|
}
|
|
44337
44337
|
if (typeof method !== "string") {
|
|
@@ -44406,7 +44406,7 @@ var require_request = __commonJS({
|
|
|
44406
44406
|
this.completed = false;
|
|
44407
44407
|
this.aborted = false;
|
|
44408
44408
|
this.upgrade = upgrade || null;
|
|
44409
|
-
this.path = query ? serializePathWithQuery(
|
|
44409
|
+
this.path = query ? serializePathWithQuery(path99, query) : path99;
|
|
44410
44410
|
this.origin = origin;
|
|
44411
44411
|
this.protocol = getProtocolFromUrlString(origin);
|
|
44412
44412
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -49631,7 +49631,7 @@ var require_client_h1 = __commonJS({
|
|
|
49631
49631
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
49632
49632
|
}
|
|
49633
49633
|
function writeH1(client, request7) {
|
|
49634
|
-
const { method, path:
|
|
49634
|
+
const { method, path: path99, host, upgrade, blocking, reset } = request7;
|
|
49635
49635
|
let { body, headers, contentLength } = request7;
|
|
49636
49636
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
49637
49637
|
if (util2.isFormDataLike(body)) {
|
|
@@ -49709,7 +49709,7 @@ var require_client_h1 = __commonJS({
|
|
|
49709
49709
|
if (socket.setTypeOfService) {
|
|
49710
49710
|
socket.setTypeOfService(request7.typeOfService);
|
|
49711
49711
|
}
|
|
49712
|
-
let header = `${method} ${
|
|
49712
|
+
let header = `${method} ${path99} HTTP/1.1\r
|
|
49713
49713
|
`;
|
|
49714
49714
|
if (typeof host === "string") {
|
|
49715
49715
|
header += `host: ${host}\r
|
|
@@ -50386,7 +50386,7 @@ var require_client_h2 = __commonJS({
|
|
|
50386
50386
|
const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
|
|
50387
50387
|
const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
|
|
50388
50388
|
const session = client[kHTTP2Session];
|
|
50389
|
-
const { method, path:
|
|
50389
|
+
const { method, path: path99, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
|
|
50390
50390
|
let { body } = request7;
|
|
50391
50391
|
if (upgrade != null && upgrade !== "websocket") {
|
|
50392
50392
|
util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -50455,7 +50455,7 @@ var require_client_h2 = __commonJS({
|
|
|
50455
50455
|
}
|
|
50456
50456
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
50457
50457
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
50458
|
-
headers[HTTP2_HEADER_PATH] =
|
|
50458
|
+
headers[HTTP2_HEADER_PATH] = path99;
|
|
50459
50459
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
50460
50460
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
50461
50461
|
} else {
|
|
@@ -50507,7 +50507,7 @@ var require_client_h2 = __commonJS({
|
|
|
50507
50507
|
stream.setTimeout(headersTimeout);
|
|
50508
50508
|
return true;
|
|
50509
50509
|
}
|
|
50510
|
-
headers[HTTP2_HEADER_PATH] =
|
|
50510
|
+
headers[HTTP2_HEADER_PATH] = path99;
|
|
50511
50511
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
50512
50512
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
50513
50513
|
if (body && typeof body.read === "function") {
|
|
@@ -52863,10 +52863,10 @@ var require_proxy_agent = __commonJS({
|
|
|
52863
52863
|
};
|
|
52864
52864
|
const {
|
|
52865
52865
|
origin,
|
|
52866
|
-
path:
|
|
52866
|
+
path: path99 = "/",
|
|
52867
52867
|
headers = {}
|
|
52868
52868
|
} = opts;
|
|
52869
|
-
opts.path = origin +
|
|
52869
|
+
opts.path = origin + path99;
|
|
52870
52870
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
52871
52871
|
const { host } = new URL(origin);
|
|
52872
52872
|
headers.host = host;
|
|
@@ -55026,20 +55026,20 @@ var require_mock_utils = __commonJS({
|
|
|
55026
55026
|
}
|
|
55027
55027
|
return normalizedQp;
|
|
55028
55028
|
}
|
|
55029
|
-
function safeUrl(
|
|
55030
|
-
if (typeof
|
|
55031
|
-
return
|
|
55029
|
+
function safeUrl(path99) {
|
|
55030
|
+
if (typeof path99 !== "string") {
|
|
55031
|
+
return path99;
|
|
55032
55032
|
}
|
|
55033
|
-
const pathSegments =
|
|
55033
|
+
const pathSegments = path99.split("?", 3);
|
|
55034
55034
|
if (pathSegments.length !== 2) {
|
|
55035
|
-
return
|
|
55035
|
+
return path99;
|
|
55036
55036
|
}
|
|
55037
55037
|
const qp2 = new URLSearchParams(pathSegments.pop());
|
|
55038
55038
|
qp2.sort();
|
|
55039
55039
|
return [...pathSegments, qp2.toString()].join("?");
|
|
55040
55040
|
}
|
|
55041
|
-
function matchKey(mockDispatch2, { path:
|
|
55042
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
55041
|
+
function matchKey(mockDispatch2, { path: path99, method, body, headers }) {
|
|
55042
|
+
const pathMatch = matchValue(mockDispatch2.path, path99);
|
|
55043
55043
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
55044
55044
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
55045
55045
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -55064,8 +55064,8 @@ var require_mock_utils = __commonJS({
|
|
|
55064
55064
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
55065
55065
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
55066
55066
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
55067
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
55068
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
55067
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path99, ignoreTrailingSlash }) => {
|
|
55068
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path99)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path99), resolvedPath);
|
|
55069
55069
|
});
|
|
55070
55070
|
if (matchedMockDispatches.length === 0) {
|
|
55071
55071
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -55104,19 +55104,19 @@ var require_mock_utils = __commonJS({
|
|
|
55104
55104
|
mockDispatches.splice(index, 1);
|
|
55105
55105
|
}
|
|
55106
55106
|
}
|
|
55107
|
-
function removeTrailingSlash(
|
|
55108
|
-
while (
|
|
55109
|
-
|
|
55107
|
+
function removeTrailingSlash(path99) {
|
|
55108
|
+
while (path99.endsWith("/")) {
|
|
55109
|
+
path99 = path99.slice(0, -1);
|
|
55110
55110
|
}
|
|
55111
|
-
if (
|
|
55112
|
-
|
|
55111
|
+
if (path99.length === 0) {
|
|
55112
|
+
path99 = "/";
|
|
55113
55113
|
}
|
|
55114
|
-
return
|
|
55114
|
+
return path99;
|
|
55115
55115
|
}
|
|
55116
55116
|
function buildKey(opts) {
|
|
55117
|
-
const { path:
|
|
55117
|
+
const { path: path99, method, body, headers, query } = opts;
|
|
55118
55118
|
return {
|
|
55119
|
-
path:
|
|
55119
|
+
path: path99,
|
|
55120
55120
|
method,
|
|
55121
55121
|
body,
|
|
55122
55122
|
headers,
|
|
@@ -55806,10 +55806,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
55806
55806
|
}
|
|
55807
55807
|
format(pendingInterceptors) {
|
|
55808
55808
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
55809
|
-
({ method, path:
|
|
55809
|
+
({ method, path: path99, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
55810
55810
|
Method: method,
|
|
55811
55811
|
Origin: origin,
|
|
55812
|
-
Path:
|
|
55812
|
+
Path: path99,
|
|
55813
55813
|
"Status code": statusCode,
|
|
55814
55814
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
55815
55815
|
Invocations: timesInvoked,
|
|
@@ -55891,9 +55891,9 @@ var require_mock_agent = __commonJS({
|
|
|
55891
55891
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
55892
55892
|
const dispatchOpts = { ...opts };
|
|
55893
55893
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
55894
|
-
const [
|
|
55894
|
+
const [path99, searchParams] = dispatchOpts.path.split("?");
|
|
55895
55895
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
55896
|
-
dispatchOpts.path = `${
|
|
55896
|
+
dispatchOpts.path = `${path99}?${normalizedSearchParams}`;
|
|
55897
55897
|
}
|
|
55898
55898
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
55899
55899
|
}
|
|
@@ -56294,12 +56294,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
56294
56294
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
56295
56295
|
*/
|
|
56296
56296
|
async loadSnapshots(filePath) {
|
|
56297
|
-
const
|
|
56298
|
-
if (!
|
|
56297
|
+
const path99 = filePath || this.#snapshotPath;
|
|
56298
|
+
if (!path99) {
|
|
56299
56299
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
56300
56300
|
}
|
|
56301
56301
|
try {
|
|
56302
|
-
const data = await readFile(resolve3(
|
|
56302
|
+
const data = await readFile(resolve3(path99), "utf8");
|
|
56303
56303
|
const parsed = JSON.parse(data);
|
|
56304
56304
|
if (Array.isArray(parsed)) {
|
|
56305
56305
|
this.#snapshots.clear();
|
|
@@ -56313,7 +56313,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
56313
56313
|
if (error63.code === "ENOENT") {
|
|
56314
56314
|
this.#snapshots.clear();
|
|
56315
56315
|
} else {
|
|
56316
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
56316
|
+
throw new UndiciError(`Failed to load snapshots from ${path99}`, { cause: error63 });
|
|
56317
56317
|
}
|
|
56318
56318
|
}
|
|
56319
56319
|
}
|
|
@@ -56324,11 +56324,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
56324
56324
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
56325
56325
|
*/
|
|
56326
56326
|
async saveSnapshots(filePath) {
|
|
56327
|
-
const
|
|
56328
|
-
if (!
|
|
56327
|
+
const path99 = filePath || this.#snapshotPath;
|
|
56328
|
+
if (!path99) {
|
|
56329
56329
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
56330
56330
|
}
|
|
56331
|
-
const resolvedPath = resolve3(
|
|
56331
|
+
const resolvedPath = resolve3(path99);
|
|
56332
56332
|
await mkdir(dirname3(resolvedPath), { recursive: true });
|
|
56333
56333
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
56334
56334
|
hash: hash2,
|
|
@@ -56965,15 +56965,15 @@ var require_redirect_handler = __commonJS({
|
|
|
56965
56965
|
}
|
|
56966
56966
|
this.history[kRedirectCacheControl].push(headers["cache-control"]);
|
|
56967
56967
|
const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
56968
|
-
const
|
|
56969
|
-
const redirectUrlString = `${origin}${
|
|
56968
|
+
const path99 = search ? `${pathname}${search}` : pathname;
|
|
56969
|
+
const redirectUrlString = `${origin}${path99}`;
|
|
56970
56970
|
for (const historyUrl of this.history) {
|
|
56971
56971
|
if (historyUrl.toString() === redirectUrlString) {
|
|
56972
56972
|
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.`);
|
|
56973
56973
|
}
|
|
56974
56974
|
}
|
|
56975
56975
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
56976
|
-
this.opts.path =
|
|
56976
|
+
this.opts.path = path99;
|
|
56977
56977
|
this.opts.origin = origin;
|
|
56978
56978
|
this.opts.query = null;
|
|
56979
56979
|
}
|
|
@@ -58741,10 +58741,10 @@ var require_cache_handler = __commonJS({
|
|
|
58741
58741
|
}
|
|
58742
58742
|
return locationUrl.pathname + locationUrl.search;
|
|
58743
58743
|
}
|
|
58744
|
-
function deleteCachedUri(store, cacheKey,
|
|
58744
|
+
function deleteCachedUri(store, cacheKey, path99) {
|
|
58745
58745
|
deleteCachedValue(store, {
|
|
58746
58746
|
...cacheKey,
|
|
58747
|
-
path:
|
|
58747
|
+
path: path99
|
|
58748
58748
|
});
|
|
58749
58749
|
for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
|
|
58750
58750
|
const method = util2.safeHTTPMethods[i10];
|
|
@@ -58752,7 +58752,7 @@ var require_cache_handler = __commonJS({
|
|
|
58752
58752
|
deleteCachedValue(store, {
|
|
58753
58753
|
...cacheKey,
|
|
58754
58754
|
method,
|
|
58755
|
-
path:
|
|
58755
|
+
path: path99
|
|
58756
58756
|
});
|
|
58757
58757
|
}
|
|
58758
58758
|
}
|
|
@@ -58763,9 +58763,9 @@ var require_cache_handler = __commonJS({
|
|
|
58763
58763
|
}
|
|
58764
58764
|
const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
|
|
58765
58765
|
for (let i10 = 0; i10 < values.length; i10++) {
|
|
58766
|
-
const
|
|
58767
|
-
if (
|
|
58768
|
-
deleteCachedUri(store, cacheKey,
|
|
58766
|
+
const path99 = getSameOriginPath(cacheKey, values[i10]);
|
|
58767
|
+
if (path99 !== void 0) {
|
|
58768
|
+
deleteCachedUri(store, cacheKey, path99);
|
|
58769
58769
|
}
|
|
58770
58770
|
}
|
|
58771
58771
|
}
|
|
@@ -63976,11 +63976,11 @@ var require_fetch = __commonJS({
|
|
|
63976
63976
|
function dispatch({ body }) {
|
|
63977
63977
|
const url2 = requestCurrentURL(request7);
|
|
63978
63978
|
const agent = fetchParams.controller.dispatcher;
|
|
63979
|
-
const
|
|
63979
|
+
const path99 = url2.pathname + url2.search;
|
|
63980
63980
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
63981
63981
|
return new Promise((resolve3, reject) => agent.dispatch(
|
|
63982
63982
|
{
|
|
63983
|
-
path: hasTrailingQuestionMark ? `${
|
|
63983
|
+
path: hasTrailingQuestionMark ? `${path99}?` : path99,
|
|
63984
63984
|
origin: url2.origin,
|
|
63985
63985
|
method: request7.method,
|
|
63986
63986
|
body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
|
|
@@ -64927,9 +64927,9 @@ var require_util5 = __commonJS({
|
|
|
64927
64927
|
}
|
|
64928
64928
|
}
|
|
64929
64929
|
}
|
|
64930
|
-
function validateCookiePath(
|
|
64931
|
-
for (let i10 = 0; i10 <
|
|
64932
|
-
const code =
|
|
64930
|
+
function validateCookiePath(path99) {
|
|
64931
|
+
for (let i10 = 0; i10 < path99.length; ++i10) {
|
|
64932
|
+
const code = path99.charCodeAt(i10);
|
|
64933
64933
|
if (code < 32 || // exclude CTLs (0-31)
|
|
64934
64934
|
code > 126 || // exclude DEL and non-ascii
|
|
64935
64935
|
code === 59) {
|
|
@@ -68365,11 +68365,11 @@ var require_undici = __commonJS({
|
|
|
68365
68365
|
if (typeof opts.path !== "string") {
|
|
68366
68366
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
68367
68367
|
}
|
|
68368
|
-
let
|
|
68368
|
+
let path99 = opts.path;
|
|
68369
68369
|
if (!opts.path.startsWith("/")) {
|
|
68370
|
-
|
|
68370
|
+
path99 = `/${path99}`;
|
|
68371
68371
|
}
|
|
68372
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
68372
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path99);
|
|
68373
68373
|
} else {
|
|
68374
68374
|
if (!opts) {
|
|
68375
68375
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -113066,8 +113066,8 @@ var require_utils3 = __commonJS({
|
|
|
113066
113066
|
}
|
|
113067
113067
|
return ind;
|
|
113068
113068
|
}
|
|
113069
|
-
function removeDotSegments(
|
|
113070
|
-
let input2 =
|
|
113069
|
+
function removeDotSegments(path99) {
|
|
113070
|
+
let input2 = path99;
|
|
113071
113071
|
const output2 = [];
|
|
113072
113072
|
let nextSlash = -1;
|
|
113073
113073
|
let len = 0;
|
|
@@ -113141,11 +113141,11 @@ var require_utils3 = __commonJS({
|
|
|
113141
113141
|
}
|
|
113142
113142
|
return output2.join("");
|
|
113143
113143
|
}
|
|
113144
|
-
function removeDotSegmentsRelative(
|
|
113145
|
-
if (
|
|
113146
|
-
return removeDotSegments(
|
|
113144
|
+
function removeDotSegmentsRelative(path99) {
|
|
113145
|
+
if (path99 === "" || path99[0] === "/") {
|
|
113146
|
+
return removeDotSegments(path99);
|
|
113147
113147
|
}
|
|
113148
|
-
const segments =
|
|
113148
|
+
const segments = path99.split("/");
|
|
113149
113149
|
const last = segments.length - 1;
|
|
113150
113150
|
const output2 = [];
|
|
113151
113151
|
let trailingDirectory = false;
|
|
@@ -113508,8 +113508,8 @@ var require_schemes = __commonJS({
|
|
|
113508
113508
|
}
|
|
113509
113509
|
if (wsComponent.resourceName) {
|
|
113510
113510
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
113511
|
-
const
|
|
113512
|
-
wsComponent.path =
|
|
113511
|
+
const path99 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
113512
|
+
wsComponent.path = path99 && path99 !== "/" ? path99 : void 0;
|
|
113513
113513
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
113514
113514
|
wsComponent.resourceName = void 0;
|
|
113515
113515
|
}
|
|
@@ -117060,7 +117060,7 @@ var require_dist2 = __commonJS({
|
|
|
117060
117060
|
});
|
|
117061
117061
|
|
|
117062
117062
|
// src/cli.ts
|
|
117063
|
-
var
|
|
117063
|
+
var import_node_path98 = __toESM(require("node:path"), 1);
|
|
117064
117064
|
|
|
117065
117065
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
117066
117066
|
var CommanderError = class extends Error {
|
|
@@ -120173,9 +120173,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
120173
120173
|
* @param {string} [path]
|
|
120174
120174
|
* @return {(string|null|Command)}
|
|
120175
120175
|
*/
|
|
120176
|
-
executableDir(
|
|
120177
|
-
if (
|
|
120178
|
-
this._executableDir =
|
|
120176
|
+
executableDir(path99) {
|
|
120177
|
+
if (path99 === void 0) return this._executableDir;
|
|
120178
|
+
this._executableDir = path99;
|
|
120179
120179
|
return this;
|
|
120180
120180
|
}
|
|
120181
120181
|
/**
|
|
@@ -122503,7 +122503,7 @@ function statuslineChangeOf(options) {
|
|
|
122503
122503
|
return void 0;
|
|
122504
122504
|
}
|
|
122505
122505
|
const assignments = (options.statusline ?? []).map(parseStatuslineAssignment);
|
|
122506
|
-
return { set: Object.fromEntries(assignments.map(({ path:
|
|
122506
|
+
return { set: Object.fromEntries(assignments.map(({ path: path99, value: value3 }) => [path99, value3])), unset: options.unsetStatusline ?? [] };
|
|
122507
122507
|
}
|
|
122508
122508
|
function registerProfileCommand(program2, deps) {
|
|
122509
122509
|
const { paths } = deps;
|
|
@@ -127065,8 +127065,8 @@ function pathnameOf(url2) {
|
|
|
127065
127065
|
return new URL(url2 ?? "/", "http://127.0.0.1").pathname;
|
|
127066
127066
|
}
|
|
127067
127067
|
function isRcSessionExchange(url2) {
|
|
127068
|
-
const
|
|
127069
|
-
return
|
|
127068
|
+
const path99 = pathnameOf(url2);
|
|
127069
|
+
return path99 === RC_SESSIONS_PATH_PREFIX || path99.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
|
|
127070
127070
|
}
|
|
127071
127071
|
var RC_SESSION_ID_PREFIX = "cse_";
|
|
127072
127072
|
var RC_IDLE_EXPIRY_MS = 45e3;
|
|
@@ -127199,30 +127199,60 @@ function parseRcRequestBody(kind, body) {
|
|
|
127199
127199
|
}
|
|
127200
127200
|
function createRcSessionTracker(deps) {
|
|
127201
127201
|
const entries = /* @__PURE__ */ new Map();
|
|
127202
|
-
const
|
|
127202
|
+
const retirePending = (entry, requestId, reason) => {
|
|
127203
|
+
if (entry.pending.delete(requestId)) {
|
|
127204
|
+
entry.retired.set(requestId, deps.now());
|
|
127205
|
+
deps.onTransition?.({ kind: "pending-retired", session: entry.id, requestId, reason, at: deps.now() });
|
|
127206
|
+
}
|
|
127207
|
+
};
|
|
127208
|
+
const addPending = (entry, pending) => {
|
|
127209
|
+
if (entry.retired.has(pending.requestId)) {
|
|
127210
|
+
return;
|
|
127211
|
+
}
|
|
127212
|
+
const born = !entry.pending.has(pending.requestId);
|
|
127213
|
+
entry.pending.set(pending.requestId, pending);
|
|
127214
|
+
if (born) {
|
|
127215
|
+
deps.onTransition?.({ kind: "pending-born", session: entry.id, requestId: pending.requestId, type: pending.type, summary: pending.summary, at: pending.observedAt });
|
|
127216
|
+
}
|
|
127217
|
+
};
|
|
127218
|
+
const expire = (id2, reason) => {
|
|
127219
|
+
const entry = entries.get(id2);
|
|
127220
|
+
if (entry === void 0) {
|
|
127221
|
+
return;
|
|
127222
|
+
}
|
|
127223
|
+
for (const requestId of [...entry.pending.keys()]) {
|
|
127224
|
+
retirePending(entry, requestId, "session-ended");
|
|
127225
|
+
}
|
|
127203
127226
|
entries.delete(id2);
|
|
127227
|
+
deps.onTransition?.({ kind: "session-ended", session: id2, reason, at: deps.now() });
|
|
127204
127228
|
};
|
|
127205
127229
|
const expirePendings = (entry, now) => {
|
|
127206
127230
|
for (const [requestId, pending] of entry.pending) {
|
|
127207
127231
|
if (now - pending.observedAt >= RC_PENDING_DEADLINE_MS) {
|
|
127208
|
-
entry
|
|
127232
|
+
retirePending(entry, requestId, "expired");
|
|
127233
|
+
}
|
|
127234
|
+
}
|
|
127235
|
+
for (const [requestId, retiredAt] of entry.retired) {
|
|
127236
|
+
if (now - retiredAt >= RC_PENDING_DEADLINE_MS) {
|
|
127237
|
+
entry.retired.delete(requestId);
|
|
127209
127238
|
}
|
|
127210
127239
|
}
|
|
127211
127240
|
};
|
|
127212
127241
|
const sweep = () => {
|
|
127213
127242
|
for (const [id2, entry] of entries) {
|
|
127214
127243
|
if (deps.now() - entry.lastSeenAt >= deps.idleMs) {
|
|
127215
|
-
expire(id2);
|
|
127244
|
+
expire(id2, "expired");
|
|
127216
127245
|
continue;
|
|
127217
127246
|
}
|
|
127218
127247
|
expirePendings(entry, deps.now());
|
|
127219
127248
|
}
|
|
127220
127249
|
};
|
|
127221
|
-
const timer = setInterval(sweep, deps.idleMs);
|
|
127250
|
+
const timer = setInterval(sweep, Math.min(deps.idleMs, RC_PENDING_DEADLINE_MS));
|
|
127222
127251
|
timer.unref();
|
|
127223
127252
|
const birth = (id2, facts) => {
|
|
127224
|
-
const record3 = { id: id2, createdAt: deps.now(), lastSeenAt: deps.now(), ...facts, pending: /* @__PURE__ */ new Map(), workerState: void 0, workerIdleSeconds: void 0, sequenceNum: void 0, liveTasks: /* @__PURE__ */ new Map() };
|
|
127253
|
+
const record3 = { id: id2, createdAt: deps.now(), lastSeenAt: deps.now(), ...facts, pending: /* @__PURE__ */ new Map(), retired: /* @__PURE__ */ new Map(), workerState: void 0, workerIdleSeconds: void 0, sequenceNum: void 0, liveTasks: /* @__PURE__ */ new Map() };
|
|
127225
127254
|
entries.set(id2, record3);
|
|
127255
|
+
deps.onTransition?.({ kind: "session-appeared", session: id2, at: record3.createdAt });
|
|
127226
127256
|
return record3;
|
|
127227
127257
|
};
|
|
127228
127258
|
const persistCredential = (entry) => {
|
|
@@ -127230,6 +127260,13 @@ function createRcSessionTracker(deps) {
|
|
|
127230
127260
|
deps.credentialStore?.write(entry.id, { authorization: entry.oauthAuthorization, anthropicVersion: entry.anthropicVersion, anthropicClientPlatform: entry.anthropicClientPlatform });
|
|
127231
127261
|
}
|
|
127232
127262
|
};
|
|
127263
|
+
const refresh = (entry, facts) => {
|
|
127264
|
+
entry.lastSeenAt = deps.now();
|
|
127265
|
+
entry.oauthAuthorization = facts.oauthAuthorization ?? entry.oauthAuthorization;
|
|
127266
|
+
entry.anthropicVersion = facts.anthropicVersion ?? entry.anthropicVersion;
|
|
127267
|
+
entry.anthropicClientPlatform = facts.anthropicClientPlatform ?? entry.anthropicClientPlatform;
|
|
127268
|
+
persistCredential(entry);
|
|
127269
|
+
};
|
|
127233
127270
|
const observeExchange = (request7) => {
|
|
127234
127271
|
const method = (request7.method ?? "").toUpperCase();
|
|
127235
127272
|
if (!isRcSessionExchange(request7.url)) {
|
|
@@ -127268,7 +127305,12 @@ function createRcSessionTracker(deps) {
|
|
|
127268
127305
|
if (id3 === void 0) {
|
|
127269
127306
|
return;
|
|
127270
127307
|
}
|
|
127271
|
-
|
|
127308
|
+
const existing = entries.get(id3);
|
|
127309
|
+
if (existing === void 0) {
|
|
127310
|
+
persistCredential(birth(id3, facts));
|
|
127311
|
+
return;
|
|
127312
|
+
}
|
|
127313
|
+
refresh(existing, facts);
|
|
127272
127314
|
}
|
|
127273
127315
|
};
|
|
127274
127316
|
}
|
|
@@ -127277,12 +127319,10 @@ function createRcSessionTracker(deps) {
|
|
|
127277
127319
|
if (id2?.startsWith(RC_SESSION_ID_PREFIX) !== true) {
|
|
127278
127320
|
return void 0;
|
|
127279
127321
|
}
|
|
127280
|
-
const
|
|
127281
|
-
|
|
127282
|
-
|
|
127283
|
-
|
|
127284
|
-
entry.anthropicClientPlatform = facts.anthropicClientPlatform ?? entry.anthropicClientPlatform;
|
|
127285
|
-
persistCredential(entry);
|
|
127322
|
+
const tracked = entries.get(id2);
|
|
127323
|
+
if (tracked !== void 0) {
|
|
127324
|
+
refresh(tracked, facts);
|
|
127325
|
+
}
|
|
127286
127326
|
const bodyKind = method === "POST" && rest === `${id2}/worker/events` ? "worker-events" : method === "POST" && rest === `${id2}/events` ? "client-events" : method === "POST" && rest === `${id2}/worker/heartbeat` ? "heartbeat" : method === "PUT" && rest === `${id2}/worker` ? "worker-registration" : void 0;
|
|
127287
127327
|
let chunks = [];
|
|
127288
127328
|
let buffered = 0;
|
|
@@ -127303,10 +127343,10 @@ function createRcSessionTracker(deps) {
|
|
|
127303
127343
|
}
|
|
127304
127344
|
const now = deps.now();
|
|
127305
127345
|
for (const controlRequest of factsOfBody.controlRequests) {
|
|
127306
|
-
entryNow
|
|
127346
|
+
addPending(entryNow, { sessionId: id2, ...controlRequest, observedAt: now });
|
|
127307
127347
|
}
|
|
127308
127348
|
for (const requestId of factsOfBody.answeredRequestIds) {
|
|
127309
|
-
entryNow
|
|
127349
|
+
retirePending(entryNow, requestId, "answered");
|
|
127310
127350
|
}
|
|
127311
127351
|
for (const payload of factsOfBody.payloads) {
|
|
127312
127352
|
entryNow.liveTasks = applyAgentTaskEvent(entryNow.liveTasks, id2, payload, now);
|
|
@@ -127315,7 +127355,11 @@ function createRcSessionTracker(deps) {
|
|
|
127315
127355
|
entryNow.workerIdleSeconds = { value: factsOfBody.idleSeconds, observedAt: now };
|
|
127316
127356
|
}
|
|
127317
127357
|
if (factsOfBody.workerStatus !== void 0) {
|
|
127358
|
+
const previous = entryNow.workerState?.value;
|
|
127318
127359
|
entryNow.workerState = { value: factsOfBody.workerStatus, observedAt: now };
|
|
127360
|
+
if (previous !== factsOfBody.workerStatus) {
|
|
127361
|
+
deps.onTransition?.({ kind: "worker-state", session: id2, state: factsOfBody.workerStatus, ...previous === void 0 ? {} : { previous }, at: now });
|
|
127362
|
+
}
|
|
127319
127363
|
}
|
|
127320
127364
|
};
|
|
127321
127365
|
const archiving = method === "POST" && rest === `${id2}/archive`;
|
|
@@ -127340,10 +127384,13 @@ function createRcSessionTracker(deps) {
|
|
|
127340
127384
|
onResponse: (status, headers) => {
|
|
127341
127385
|
if (singleHeader(headers, CONFLICT_REASON_HEADER) !== void 0 || archiving && isSuccessful(status)) {
|
|
127342
127386
|
deps.credentialStore?.remove(id2);
|
|
127343
|
-
expire(id2);
|
|
127387
|
+
expire(id2, singleHeader(headers, CONFLICT_REASON_HEADER) === void 0 ? "archived" : "conflict");
|
|
127344
127388
|
return;
|
|
127345
127389
|
}
|
|
127346
127390
|
accepted = isSuccessful(status);
|
|
127391
|
+
if (accepted && !entries.has(id2)) {
|
|
127392
|
+
persistCredential(birth(id2, facts));
|
|
127393
|
+
}
|
|
127347
127394
|
file2();
|
|
127348
127395
|
},
|
|
127349
127396
|
onBodyChunk: () => {
|
|
@@ -127408,12 +127455,12 @@ function createRcSessionTracker(deps) {
|
|
|
127408
127455
|
const pending = pendingOfControlRequestPayload(event.payload);
|
|
127409
127456
|
if (pending !== void 0) {
|
|
127410
127457
|
if (event.source === RC_STREAM_WORKER_SOURCE) {
|
|
127411
|
-
entry
|
|
127458
|
+
addPending(entry, { sessionId, ...pending, observedAt: deps.now() });
|
|
127412
127459
|
}
|
|
127413
127460
|
return;
|
|
127414
127461
|
}
|
|
127415
127462
|
for (const requestId of answeredRequestIdsOfControlResponsePayload(event.payload)) {
|
|
127416
|
-
entry
|
|
127463
|
+
retirePending(entry, requestId, "answered");
|
|
127417
127464
|
}
|
|
127418
127465
|
},
|
|
127419
127466
|
liveTasksOf: (sessionId) => {
|
|
@@ -127421,10 +127468,14 @@ function createRcSessionTracker(deps) {
|
|
|
127421
127468
|
return sortedEntries().filter((entry) => sessionId === void 0 || entry.id === sessionId).flatMap((entry) => [...entry.liveTasks.values()].sort((left, right) => left.observedAt - right.observedAt || (left.taskId < right.taskId ? -1 : 1)));
|
|
127422
127469
|
},
|
|
127423
127470
|
completePending: (sessionId, requestId) => {
|
|
127424
|
-
entries.get(sessionId)
|
|
127471
|
+
const entry = entries.get(sessionId);
|
|
127472
|
+
if (entry !== void 0) {
|
|
127473
|
+
retirePending(entry, requestId, "answered");
|
|
127474
|
+
}
|
|
127425
127475
|
},
|
|
127426
127476
|
close: () => {
|
|
127427
127477
|
clearInterval(timer);
|
|
127478
|
+
deps.onClose?.();
|
|
127428
127479
|
}
|
|
127429
127480
|
};
|
|
127430
127481
|
}
|
|
@@ -127604,8 +127655,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
127604
127655
|
function isRcReadFileEncoding(value3) {
|
|
127605
127656
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value3);
|
|
127606
127657
|
}
|
|
127607
|
-
function buildRcReadFilePayload(requestId,
|
|
127608
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
127658
|
+
function buildRcReadFilePayload(requestId, path99, options) {
|
|
127659
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path99, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
127609
127660
|
}
|
|
127610
127661
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
127611
127662
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -127707,15 +127758,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
127707
127758
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
127708
127759
|
return result.ok ? { ...result, requestId } : result;
|
|
127709
127760
|
}
|
|
127710
|
-
async function readRcSessionFile(deps, sessionId,
|
|
127711
|
-
if (
|
|
127761
|
+
async function readRcSessionFile(deps, sessionId, path99, options) {
|
|
127762
|
+
if (path99 === "") {
|
|
127712
127763
|
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" };
|
|
127713
127764
|
}
|
|
127714
127765
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
127715
127766
|
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" };
|
|
127716
127767
|
}
|
|
127717
127768
|
const requestId = deps.newUuid();
|
|
127718
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
127769
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path99, options), `read ${path99} from session ${sessionId}`);
|
|
127719
127770
|
return result.ok ? { ...result, requestId } : result;
|
|
127720
127771
|
}
|
|
127721
127772
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -127898,11 +127949,11 @@ function createRcControlHandler(deps) {
|
|
|
127898
127949
|
path: "read-file",
|
|
127899
127950
|
read: (body) => {
|
|
127900
127951
|
const session = bodyString(body, "session");
|
|
127901
|
-
const
|
|
127952
|
+
const path99 = bodyString(body, "path");
|
|
127902
127953
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
127903
127954
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
127904
|
-
const refused2 = session === void 0 ||
|
|
127905
|
-
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,
|
|
127955
|
+
const refused2 = session === void 0 || path99 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
127956
|
+
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, path99, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
127906
127957
|
}
|
|
127907
127958
|
},
|
|
127908
127959
|
{
|
|
@@ -128212,9 +128263,9 @@ function requestIdOfBody(body) {
|
|
|
128212
128263
|
}
|
|
128213
128264
|
function frontDoorRcControl(transport, token) {
|
|
128214
128265
|
const headers = { authorization: `Bearer ${token}` };
|
|
128215
|
-
const listAnswerOf = async (
|
|
128266
|
+
const listAnswerOf = async (path99, what) => {
|
|
128216
128267
|
try {
|
|
128217
|
-
return await transport.request({ method: "GET", path:
|
|
128268
|
+
return await transport.request({ method: "GET", path: path99, headers });
|
|
128218
128269
|
} catch (error63) {
|
|
128219
128270
|
throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
|
|
128220
128271
|
}
|
|
@@ -128286,10 +128337,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
128286
128337
|
}
|
|
128287
128338
|
return pending;
|
|
128288
128339
|
};
|
|
128289
|
-
const writeOf = async (
|
|
128340
|
+
const writeOf = async (path99, body, describeFailure2) => {
|
|
128290
128341
|
let answer;
|
|
128291
128342
|
try {
|
|
128292
|
-
answer = await transport.request({ method: "POST", path:
|
|
128343
|
+
answer = await transport.request({ method: "POST", path: path99, headers: { ...headers, "content-type": "application/json" }, body });
|
|
128293
128344
|
} catch (error63) {
|
|
128294
128345
|
return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
|
|
128295
128346
|
}
|
|
@@ -128320,10 +128371,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
128320
128371
|
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}`),
|
|
128321
128372
|
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}`),
|
|
128322
128373
|
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}`),
|
|
128323
|
-
readFile: async (sessionId,
|
|
128374
|
+
readFile: async (sessionId, path99, options) => await writeOf(
|
|
128324
128375
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
128325
|
-
JSON.stringify({ session: sessionId, path:
|
|
128326
|
-
(status, message) => `reading ${
|
|
128376
|
+
JSON.stringify({ session: sessionId, path: path99, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
128377
|
+
(status, message) => `reading ${path99} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
128327
128378
|
),
|
|
128328
128379
|
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}`),
|
|
128329
128380
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -128729,12 +128780,12 @@ function tlsFacts(options) {
|
|
|
128729
128780
|
}
|
|
128730
128781
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
128731
128782
|
const agent = new ExemptTlsAgent();
|
|
128732
|
-
const post = async (
|
|
128783
|
+
const post = async (path99, headers, body) => await new Promise((resolve3, reject) => {
|
|
128733
128784
|
const options = {
|
|
128734
128785
|
host: target.host,
|
|
128735
128786
|
port: target.port,
|
|
128736
128787
|
method: "POST",
|
|
128737
|
-
path:
|
|
128788
|
+
path: path99,
|
|
128738
128789
|
// 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.
|
|
128739
128790
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
128740
128791
|
agent
|
|
@@ -128799,12 +128850,12 @@ function lateRcStreamDial(resolve3) {
|
|
|
128799
128850
|
}
|
|
128800
128851
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
128801
128852
|
const agent = new ExemptTlsAgent();
|
|
128802
|
-
const request7 = async (method,
|
|
128853
|
+
const request7 = async (method, path99, headers, body, signal) => await new Promise((resolve3, reject) => {
|
|
128803
128854
|
const options = {
|
|
128804
128855
|
host: target.host,
|
|
128805
128856
|
port: target.port,
|
|
128806
128857
|
method,
|
|
128807
|
-
path:
|
|
128858
|
+
path: path99,
|
|
128808
128859
|
// 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.
|
|
128809
128860
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
128810
128861
|
agent,
|
|
@@ -128846,9 +128897,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
128846
128897
|
return { status, body: await readAll(response) };
|
|
128847
128898
|
},
|
|
128848
128899
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
128849
|
-
const
|
|
128900
|
+
const path99 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
128850
128901
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
128851
|
-
const { status, response } = await request7("GET",
|
|
128902
|
+
const { status, response } = await request7("GET", path99, streamHeaders, void 0, signal);
|
|
128852
128903
|
if (!isSuccessful2(status)) {
|
|
128853
128904
|
await readAll(response);
|
|
128854
128905
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -130528,8 +130579,8 @@ function once(fn) {
|
|
|
130528
130579
|
return result;
|
|
130529
130580
|
};
|
|
130530
130581
|
}
|
|
130531
|
-
function pathToHttpPath(
|
|
130532
|
-
return `/${
|
|
130582
|
+
function pathToHttpPath(path99) {
|
|
130583
|
+
return `/${path99.map(safeEncodeURIComponent).join("/")}`;
|
|
130533
130584
|
}
|
|
130534
130585
|
var TRACER_SYMBOL = /* @__PURE__ */ Symbol.for("ORPC_TRACER");
|
|
130535
130586
|
function getTracer() {
|
|
@@ -131808,7 +131859,7 @@ function resolveClientRest(rest) {
|
|
|
131808
131859
|
// rest[1] can be undefined if all fields of FriendlyClientOptions are optional
|
|
131809
131860
|
];
|
|
131810
131861
|
}
|
|
131811
|
-
function createORPCClient(link, { path:
|
|
131862
|
+
function createORPCClient(link, { path: path99 = [], ...options } = {}) {
|
|
131812
131863
|
const procedureClient = (...rest) => {
|
|
131813
131864
|
const [input2, callOptions] = resolveClientRest(rest);
|
|
131814
131865
|
const interceptors = [
|
|
@@ -131817,7 +131868,7 @@ function createORPCClient(link, { path: path98 = [], ...options } = {}) {
|
|
|
131817
131868
|
];
|
|
131818
131869
|
return intercept(
|
|
131819
131870
|
interceptors,
|
|
131820
|
-
{ ...callOptions, input: input2, path:
|
|
131871
|
+
{ ...callOptions, input: input2, path: path99 },
|
|
131821
131872
|
({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
|
|
131822
131873
|
);
|
|
131823
131874
|
};
|
|
@@ -131831,7 +131882,7 @@ function createORPCClient(link, { path: path98 = [], ...options } = {}) {
|
|
|
131831
131882
|
if (client === void 0) {
|
|
131832
131883
|
client = createORPCClient(link, {
|
|
131833
131884
|
...options,
|
|
131834
|
-
path: [...
|
|
131885
|
+
path: [...path99, key],
|
|
131835
131886
|
scoped: options.scoped?.[key]
|
|
131836
131887
|
});
|
|
131837
131888
|
cache.set(key, client);
|
|
@@ -132072,11 +132123,11 @@ function tryOrUndefined(fn) {
|
|
|
132072
132123
|
return void 0;
|
|
132073
132124
|
}
|
|
132074
132125
|
}
|
|
132075
|
-
function pathToHttpPath2(
|
|
132076
|
-
return `/${
|
|
132126
|
+
function pathToHttpPath2(path99) {
|
|
132127
|
+
return `/${path99.map(safeEncodeURIComponent2).join("/")}`;
|
|
132077
132128
|
}
|
|
132078
|
-
function normalizeHttpPath(
|
|
132079
|
-
const paths =
|
|
132129
|
+
function normalizeHttpPath(path99) {
|
|
132130
|
+
const paths = path99.split("/");
|
|
132080
132131
|
if (paths.at(0) === "") {
|
|
132081
132132
|
paths.shift();
|
|
132082
132133
|
}
|
|
@@ -132261,9 +132312,9 @@ function isPlainObject4(value3) {
|
|
|
132261
132312
|
function getOwn(object3, key) {
|
|
132262
132313
|
return Object.hasOwn(object3, key) ? object3[key] : void 0;
|
|
132263
132314
|
}
|
|
132264
|
-
function get(object3,
|
|
132315
|
+
function get(object3, path99) {
|
|
132265
132316
|
let current = object3;
|
|
132266
|
-
for (const key of
|
|
132317
|
+
for (const key of path99) {
|
|
132267
132318
|
if (!isTypescriptObject2(current)) {
|
|
132268
132319
|
return void 0;
|
|
132269
132320
|
}
|
|
@@ -132504,25 +132555,25 @@ var BracketNotationSerializer = class {
|
|
|
132504
132555
|
this.internalSerialize(data, "", true, result);
|
|
132505
132556
|
return result;
|
|
132506
132557
|
}
|
|
132507
|
-
internalSerialize(data,
|
|
132558
|
+
internalSerialize(data, path99, isRoot, result) {
|
|
132508
132559
|
if (Array.isArray(data)) {
|
|
132509
132560
|
data.forEach((item, i10) => {
|
|
132510
|
-
this.internalSerialize(item, isRoot ? i10.toString() : `${
|
|
132561
|
+
this.internalSerialize(item, isRoot ? i10.toString() : `${path99}[${i10}]`, false, result);
|
|
132511
132562
|
});
|
|
132512
132563
|
} else if (isPlainObject4(data)) {
|
|
132513
132564
|
for (const key of Object.keys(data)) {
|
|
132514
|
-
this.internalSerialize(data[key], isRoot ? key : `${
|
|
132565
|
+
this.internalSerialize(data[key], isRoot ? key : `${path99}[${key}]`, false, result);
|
|
132515
132566
|
}
|
|
132516
132567
|
} else {
|
|
132517
|
-
result.push([
|
|
132568
|
+
result.push([path99, data]);
|
|
132518
132569
|
}
|
|
132519
132570
|
}
|
|
132520
132571
|
deserialize(serialized) {
|
|
132521
132572
|
let arrayPushStyles;
|
|
132522
132573
|
const root = new NullProtoObj2();
|
|
132523
132574
|
let emptySlotsLeft = this.maxDeserializingEmptySlots;
|
|
132524
|
-
for (const [
|
|
132525
|
-
const segments = this.parsePath(
|
|
132575
|
+
for (const [path99, value3] of serialized) {
|
|
132576
|
+
const segments = this.parsePath(path99);
|
|
132526
132577
|
let currentRef = root;
|
|
132527
132578
|
let nextSegment = segments[0];
|
|
132528
132579
|
for (let i10 = 1; i10 < segments.length; i10++) {
|
|
@@ -132582,20 +132633,20 @@ var BracketNotationSerializer = class {
|
|
|
132582
132633
|
}
|
|
132583
132634
|
return result;
|
|
132584
132635
|
}
|
|
132585
|
-
parsePath(
|
|
132586
|
-
const start =
|
|
132587
|
-
if (start === -1 ||
|
|
132588
|
-
return [
|
|
132636
|
+
parsePath(path99) {
|
|
132637
|
+
const start = path99.indexOf("[");
|
|
132638
|
+
if (start === -1 || path99[path99.length - 1] !== "]") {
|
|
132639
|
+
return [path99];
|
|
132589
132640
|
}
|
|
132590
|
-
const segments = [
|
|
132641
|
+
const segments = [path99.slice(0, start)];
|
|
132591
132642
|
let from = start + 1;
|
|
132592
|
-
let to2 =
|
|
132643
|
+
let to2 = path99.indexOf("][", from);
|
|
132593
132644
|
while (to2 !== -1) {
|
|
132594
|
-
segments.push(
|
|
132645
|
+
segments.push(path99.slice(from, to2));
|
|
132595
132646
|
from = to2 + 2;
|
|
132596
|
-
to2 =
|
|
132647
|
+
to2 = path99.indexOf("][", from);
|
|
132597
132648
|
}
|
|
132598
|
-
segments.push(
|
|
132649
|
+
segments.push(path99.slice(from, -1));
|
|
132599
132650
|
return segments;
|
|
132600
132651
|
}
|
|
132601
132652
|
};
|
|
@@ -134093,11 +134144,11 @@ var OpenAPISerializer = class {
|
|
|
134093
134144
|
return json2;
|
|
134094
134145
|
}
|
|
134095
134146
|
const form = new FormData();
|
|
134096
|
-
for (const [
|
|
134147
|
+
for (const [path99, value22] of this.bracketNotation.serialize(json2)) {
|
|
134097
134148
|
if (value22 instanceof Blob) {
|
|
134098
|
-
form.append(
|
|
134149
|
+
form.append(path99, value22);
|
|
134099
134150
|
} else if (value22 !== void 0 && value22 !== null) {
|
|
134100
|
-
form.append(
|
|
134151
|
+
form.append(path99, String(value22));
|
|
134101
134152
|
}
|
|
134102
134153
|
}
|
|
134103
134154
|
return form;
|
|
@@ -134135,30 +134186,30 @@ function isBodylessMethod(method) {
|
|
|
134135
134186
|
return method === "GET" || method === "HEAD";
|
|
134136
134187
|
}
|
|
134137
134188
|
var PARAMETER_NAME_REGEX = /^[\w-]+$/;
|
|
134138
|
-
function getDynamicPathParams(
|
|
134139
|
-
if (!
|
|
134189
|
+
function getDynamicPathParams(path99) {
|
|
134190
|
+
if (!path99.includes("{")) {
|
|
134140
134191
|
return void 0;
|
|
134141
134192
|
}
|
|
134142
|
-
const len =
|
|
134193
|
+
const len = path99.length;
|
|
134143
134194
|
let params;
|
|
134144
134195
|
let index = 1;
|
|
134145
134196
|
while (index < len) {
|
|
134146
134197
|
const segmentStart = index;
|
|
134147
|
-
const slashPos =
|
|
134198
|
+
const slashPos = path99.indexOf("/", index);
|
|
134148
134199
|
const segmentEnd = slashPos === -1 ? len : slashPos;
|
|
134149
|
-
if (segmentEnd > segmentStart &&
|
|
134200
|
+
if (segmentEnd > segmentStart && path99.charCodeAt(segmentStart) === 123 && path99.charCodeAt(segmentEnd - 1) === 125) {
|
|
134150
134201
|
let parameterStart = segmentStart + 1;
|
|
134151
134202
|
let allowsSlash = false;
|
|
134152
|
-
const operator =
|
|
134203
|
+
const operator = path99.charCodeAt(parameterStart);
|
|
134153
134204
|
if (operator === 43) {
|
|
134154
134205
|
allowsSlash = true;
|
|
134155
134206
|
parameterStart++;
|
|
134156
134207
|
}
|
|
134157
|
-
const parameterName =
|
|
134208
|
+
const parameterName = path99.slice(parameterStart, segmentEnd - 1);
|
|
134158
134209
|
if (PARAMETER_NAME_REGEX.test(parameterName)) {
|
|
134159
134210
|
params ??= [];
|
|
134160
134211
|
params.push({
|
|
134161
|
-
segment:
|
|
134212
|
+
segment: path99.slice(segmentStart, segmentEnd),
|
|
134162
134213
|
startIndex: segmentStart,
|
|
134163
134214
|
parameterName,
|
|
134164
134215
|
allowsSlash
|
|
@@ -134201,8 +134252,8 @@ openapi.method = (method) => ({
|
|
|
134201
134252
|
...openapi({ method }),
|
|
134202
134253
|
name: "~openapi/method"
|
|
134203
134254
|
});
|
|
134204
|
-
openapi.path = (
|
|
134205
|
-
...openapi({ path:
|
|
134255
|
+
openapi.path = (path99) => ({
|
|
134256
|
+
...openapi({ path: path99 }),
|
|
134206
134257
|
name: "~openapi/path"
|
|
134207
134258
|
});
|
|
134208
134259
|
openapi.spec = (spec) => ({
|
|
@@ -135121,22 +135172,22 @@ function visitJsonSchemaRefs(value3, visit2, schemaLevel = true, seen = /* @__PU
|
|
|
135121
135172
|
}
|
|
135122
135173
|
}
|
|
135123
135174
|
}
|
|
135124
|
-
function mapJsonSchemaRefs(value3, map3, schemaLevel = true,
|
|
135175
|
+
function mapJsonSchemaRefs(value3, map3, schemaLevel = true, path99 = []) {
|
|
135125
135176
|
if (!value3 || typeof value3 !== "object") {
|
|
135126
135177
|
return value3;
|
|
135127
135178
|
}
|
|
135128
135179
|
if (Array.isArray(value3)) {
|
|
135129
|
-
return value3.map((item, index) => mapJsonSchemaRefs(item, map3, schemaLevel, [...
|
|
135180
|
+
return value3.map((item, index) => mapJsonSchemaRefs(item, map3, schemaLevel, [...path99, index]));
|
|
135130
135181
|
}
|
|
135131
135182
|
const result = {};
|
|
135132
135183
|
for (const key of Object.keys(value3)) {
|
|
135133
135184
|
const val = value3[key];
|
|
135134
135185
|
if (key === "$ref" && typeof val === "string") {
|
|
135135
|
-
setOwn2(result, key, map3(val, [...
|
|
135186
|
+
setOwn2(result, key, map3(val, [...path99, key]));
|
|
135136
135187
|
} else if (!schemaLevel) {
|
|
135137
|
-
setOwn2(result, key, mapJsonSchemaRefs(val, map3, true, [...
|
|
135188
|
+
setOwn2(result, key, mapJsonSchemaRefs(val, map3, true, [...path99, key]));
|
|
135138
135189
|
} else if (JSON_SCHEMA_LOGIC_KEYWORDS.has(key) || JSON_SCHEMA_RECORD_KEYWORDS.has(key)) {
|
|
135139
|
-
setOwn2(result, key, mapJsonSchemaRefs(val, map3, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...
|
|
135190
|
+
setOwn2(result, key, mapJsonSchemaRefs(val, map3, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path99, key]));
|
|
135140
135191
|
} else {
|
|
135141
135192
|
setOwn2(result, key, val);
|
|
135142
135193
|
}
|
|
@@ -135666,7 +135717,7 @@ function unlazy(maybeLazy) {
|
|
|
135666
135717
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
135667
135718
|
const options = resolveMaybeOptionalOptions2(rest);
|
|
135668
135719
|
return async (...[input2, callerOptions]) => {
|
|
135669
|
-
const
|
|
135720
|
+
const path99 = toArray2(options.path);
|
|
135670
135721
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
135671
135722
|
const clientContext = callerOptions?.context ?? {};
|
|
135672
135723
|
const context = await value2(options.context, clientContext) ?? {};
|
|
@@ -135679,7 +135730,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
135679
135730
|
};
|
|
135680
135731
|
try {
|
|
135681
135732
|
const output2 = await runWithSpan2("call_procedure", (span) => {
|
|
135682
|
-
span?.setAttribute("procedure.path",
|
|
135733
|
+
span?.setAttribute("procedure.path", path99);
|
|
135683
135734
|
return intercept2(
|
|
135684
135735
|
options.interceptors,
|
|
135685
135736
|
{
|
|
@@ -135687,7 +135738,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
135687
135738
|
// input can be optional if it is undefinable
|
|
135688
135739
|
input: input2,
|
|
135689
135740
|
errors,
|
|
135690
|
-
path:
|
|
135741
|
+
path: path99,
|
|
135691
135742
|
procedure,
|
|
135692
135743
|
signal: callerOptions?.signal,
|
|
135693
135744
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -135938,10 +135989,10 @@ function augmentRouter(router, options) {
|
|
|
135938
135989
|
}
|
|
135939
135990
|
return enhanced;
|
|
135940
135991
|
}
|
|
135941
|
-
function getRouter(router,
|
|
135992
|
+
function getRouter(router, path99) {
|
|
135942
135993
|
let current = router;
|
|
135943
|
-
for (let i10 = 0; i10 <
|
|
135944
|
-
const segment =
|
|
135994
|
+
for (let i10 = 0; i10 < path99.length; i10++) {
|
|
135995
|
+
const segment = path99[i10];
|
|
135945
135996
|
if (!isTypescriptObject2(current)) {
|
|
135946
135997
|
return void 0;
|
|
135947
135998
|
}
|
|
@@ -135953,7 +136004,7 @@ function getRouter(router, path98) {
|
|
|
135953
136004
|
continue;
|
|
135954
136005
|
}
|
|
135955
136006
|
const lazied = current;
|
|
135956
|
-
const rest =
|
|
136007
|
+
const rest = path99.slice(i10);
|
|
135957
136008
|
return new Lazy({
|
|
135958
136009
|
...lazied["~orpc"],
|
|
135959
136010
|
async loader() {
|
|
@@ -135968,40 +136019,40 @@ function getRouter(router, path98) {
|
|
|
135968
136019
|
}
|
|
135969
136020
|
return current;
|
|
135970
136021
|
}
|
|
135971
|
-
function walkProcedureContractsSync(router, callback,
|
|
136022
|
+
function walkProcedureContractsSync(router, callback, path99 = []) {
|
|
135972
136023
|
const lazyResults = [];
|
|
135973
|
-
walkProcedureContractsSyncInternal(router, callback,
|
|
136024
|
+
walkProcedureContractsSyncInternal(router, callback, path99.slice(), lazyResults);
|
|
135974
136025
|
return lazyResults;
|
|
135975
136026
|
}
|
|
135976
|
-
function walkProcedureContractsSyncInternal(router, callback,
|
|
136027
|
+
function walkProcedureContractsSyncInternal(router, callback, path99, lazyResults) {
|
|
135977
136028
|
const hiddenContract = getHiddenRouterContract(router);
|
|
135978
136029
|
if (hiddenContract !== void 0) {
|
|
135979
136030
|
router = hiddenContract;
|
|
135980
136031
|
}
|
|
135981
136032
|
if (router instanceof ProcedureContract) {
|
|
135982
|
-
callback(router,
|
|
136033
|
+
callback(router, path99.slice());
|
|
135983
136034
|
return;
|
|
135984
136035
|
}
|
|
135985
136036
|
if (!isTypescriptObject2(router)) {
|
|
135986
136037
|
return;
|
|
135987
136038
|
}
|
|
135988
136039
|
for (const [key, value3] of Object.entries(router)) {
|
|
135989
|
-
|
|
136040
|
+
path99.push(key);
|
|
135990
136041
|
if (value3 instanceof Lazy) {
|
|
135991
|
-
lazyResults.push({ router: value3, path:
|
|
136042
|
+
lazyResults.push({ router: value3, path: path99.slice() });
|
|
135992
136043
|
} else {
|
|
135993
|
-
walkProcedureContractsSyncInternal(value3, callback,
|
|
136044
|
+
walkProcedureContractsSyncInternal(value3, callback, path99, lazyResults);
|
|
135994
136045
|
}
|
|
135995
|
-
|
|
136046
|
+
path99.pop();
|
|
135996
136047
|
}
|
|
135997
136048
|
}
|
|
135998
|
-
async function walkProcedureContractsAsync(router, callback,
|
|
136049
|
+
async function walkProcedureContractsAsync(router, callback, path99 = []) {
|
|
135999
136050
|
const hiddenContract = getHiddenRouterContract(router);
|
|
136000
136051
|
if (hiddenContract !== void 0) {
|
|
136001
136052
|
router = hiddenContract;
|
|
136002
136053
|
}
|
|
136003
136054
|
if (router instanceof ProcedureContract) {
|
|
136004
|
-
await callback(router,
|
|
136055
|
+
await callback(router, path99);
|
|
136005
136056
|
return;
|
|
136006
136057
|
}
|
|
136007
136058
|
if (!isTypescriptObject2(router)) {
|
|
@@ -136010,9 +136061,9 @@ async function walkProcedureContractsAsync(router, callback, path98 = []) {
|
|
|
136010
136061
|
for (const [key, value3] of Object.entries(router)) {
|
|
136011
136062
|
if (value3 instanceof Lazy) {
|
|
136012
136063
|
const { default: router2 } = await unlazy(value3);
|
|
136013
|
-
await walkProcedureContractsAsync(router2, callback, [...
|
|
136064
|
+
await walkProcedureContractsAsync(router2, callback, [...path99, key]);
|
|
136014
136065
|
} else {
|
|
136015
|
-
await walkProcedureContractsAsync(value3, callback, [...
|
|
136066
|
+
await walkProcedureContractsAsync(value3, callback, [...path99, key]);
|
|
136016
136067
|
}
|
|
136017
136068
|
}
|
|
136018
136069
|
}
|
|
@@ -136498,18 +136549,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
|
|
|
136498
136549
|
}
|
|
136499
136550
|
var OpenAPIGeneratorError = class extends TypeError {
|
|
136500
136551
|
};
|
|
136501
|
-
function toOpenAPIPath(
|
|
136552
|
+
function toOpenAPIPath(path99, dynamicPathParams) {
|
|
136502
136553
|
if (!dynamicPathParams?.length) {
|
|
136503
|
-
return
|
|
136554
|
+
return path99;
|
|
136504
136555
|
}
|
|
136505
136556
|
let normalized = "";
|
|
136506
136557
|
let currentIndex = 0;
|
|
136507
136558
|
for (const param of dynamicPathParams) {
|
|
136508
|
-
normalized +=
|
|
136559
|
+
normalized += path99.slice(currentIndex, param.startIndex);
|
|
136509
136560
|
normalized += `{${param.parameterName}}`;
|
|
136510
136561
|
currentIndex = param.startIndex + param.segment.length;
|
|
136511
136562
|
}
|
|
136512
|
-
normalized +=
|
|
136563
|
+
normalized += path99.slice(currentIndex);
|
|
136513
136564
|
return normalized;
|
|
136514
136565
|
}
|
|
136515
136566
|
function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
|
|
@@ -136966,8 +137017,8 @@ var OpenAPIGenerator = class {
|
|
|
136966
137017
|
customErrorResponseBodySchema: options.customErrorResponseBodySchema
|
|
136967
137018
|
};
|
|
136968
137019
|
const errors = [];
|
|
136969
|
-
await walkProcedureContractsAsync(router, (contract,
|
|
136970
|
-
if (value2(options.filter, contract,
|
|
137020
|
+
await walkProcedureContractsAsync(router, (contract, path99) => {
|
|
137021
|
+
if (value2(options.filter, contract, path99) === false) {
|
|
136971
137022
|
return;
|
|
136972
137023
|
}
|
|
136973
137024
|
try {
|
|
@@ -136979,7 +137030,7 @@ var OpenAPIGenerator = class {
|
|
|
136979
137030
|
`QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
|
|
136980
137031
|
);
|
|
136981
137032
|
}
|
|
136982
|
-
const postPath = meta3?.path ?? pathToHttpPath2(
|
|
137033
|
+
const postPath = meta3?.path ?? pathToHttpPath2(path99);
|
|
136983
137034
|
const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
|
|
136984
137035
|
const dynamicPathParams = getDynamicPathParams(httpPath);
|
|
136985
137036
|
const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
|
|
@@ -136988,7 +137039,7 @@ var OpenAPIGenerator = class {
|
|
|
136988
137039
|
operation = meta3.spec;
|
|
136989
137040
|
} else {
|
|
136990
137041
|
operation = {
|
|
136991
|
-
operationId: meta3?.operationId ??
|
|
137042
|
+
operationId: meta3?.operationId ?? path99.join("."),
|
|
136992
137043
|
summary: meta3?.summary,
|
|
136993
137044
|
description: meta3?.description,
|
|
136994
137045
|
deprecated: meta3?.deprecated,
|
|
@@ -137008,7 +137059,7 @@ var OpenAPIGenerator = class {
|
|
|
137008
137059
|
if (!(e10 instanceof OpenAPIGeneratorError)) {
|
|
137009
137060
|
throw e10;
|
|
137010
137061
|
}
|
|
137011
|
-
errors.push(`Procedure at ${
|
|
137062
|
+
errors.push(`Procedure at ${path99.join(".") || "(root)"}: ${e10.message}`);
|
|
137012
137063
|
}
|
|
137013
137064
|
});
|
|
137014
137065
|
if (errors.length) {
|
|
@@ -137794,16 +137845,16 @@ var StandardLink = class {
|
|
|
137794
137845
|
/**
|
|
137795
137846
|
* @throws ORPCError, MalformedResponseError, transport-level errors (network failures, timeouts, etc.)
|
|
137796
137847
|
*/
|
|
137797
|
-
call(
|
|
137798
|
-
return runWithSpan(`${ORPC_NAME}.${
|
|
137848
|
+
call(path99, input2, options) {
|
|
137849
|
+
return runWithSpan(`${ORPC_NAME}.${path99.join("/")}`, (span) => {
|
|
137799
137850
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
137800
|
-
span?.setAttribute("rpc.method",
|
|
137851
|
+
span?.setAttribute("rpc.method", path99.join("."));
|
|
137801
137852
|
if (getTracer() && isAsyncIteratorObject(input2)) {
|
|
137802
137853
|
input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
|
|
137803
137854
|
} else if (getTracer() && input2 instanceof ReadableStream) {
|
|
137804
137855
|
input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
|
|
137805
137856
|
}
|
|
137806
|
-
return intercept(this.interceptors, { ...options, path:
|
|
137857
|
+
return intercept(this.interceptors, { ...options, path: path99, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
137807
137858
|
const tracer = getTracer();
|
|
137808
137859
|
const activeSpan = tracer?.getActiveSpan() ?? span;
|
|
137809
137860
|
let request7 = await runWithSpan(
|
|
@@ -137860,18 +137911,18 @@ var RPCLinkCodec = class {
|
|
|
137860
137911
|
this.headers = options.headers ?? {};
|
|
137861
137912
|
this.serializer = options.serializer ?? new RPCSerializer();
|
|
137862
137913
|
}
|
|
137863
|
-
async encodeInput(input2,
|
|
137864
|
-
let headers = toResolvedStandardHeaders(await value(this.headers, options,
|
|
137914
|
+
async encodeInput(input2, path99, options) {
|
|
137915
|
+
let headers = toResolvedStandardHeaders(await value(this.headers, options, path99, input2));
|
|
137865
137916
|
if (options.lastEventId !== void 0) {
|
|
137866
137917
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
137867
137918
|
}
|
|
137868
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
137869
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
137919
|
+
const expectedMethod = await value(this.expectedMethod, options, path99, input2);
|
|
137920
|
+
const baseUrl = await value(this.baseUrl, options, path99, input2);
|
|
137870
137921
|
const [pathname, search, hash2] = parseStandardUrl(baseUrl);
|
|
137871
|
-
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(
|
|
137922
|
+
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path99)}`;
|
|
137872
137923
|
const serialized = this.serializer.serialize(input2);
|
|
137873
137924
|
if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
137874
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
137925
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path99, input2);
|
|
137875
137926
|
const mergedSearch = new URLSearchParams(search);
|
|
137876
137927
|
mergedSearch.append("data", stringifyJSON(serialized) ?? "");
|
|
137877
137928
|
const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
|
|
@@ -137958,8 +138009,8 @@ var FetchLinkTransport = class {
|
|
|
137958
138009
|
this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
|
|
137959
138010
|
this.toFetchRequestOptions = options.toFetchRequest;
|
|
137960
138011
|
}
|
|
137961
|
-
async send(standardRequest,
|
|
137962
|
-
let origin = await value(this.origin, options,
|
|
138012
|
+
async send(standardRequest, path99, options) {
|
|
138013
|
+
let origin = await value(this.origin, options, path99);
|
|
137963
138014
|
if (origin?.endsWith("/")) {
|
|
137964
138015
|
origin = origin.slice(0, -1);
|
|
137965
138016
|
}
|
|
@@ -137979,7 +138030,7 @@ var FetchLinkTransport = class {
|
|
|
137979
138030
|
}
|
|
137980
138031
|
}
|
|
137981
138032
|
const fetch3 = this.fetch;
|
|
137982
|
-
const response = await fetch3(url2, init, options,
|
|
138033
|
+
const response = await fetch3(url2, init, options, path99);
|
|
137983
138034
|
if (response.type === "opaqueredirect") {
|
|
137984
138035
|
throw new TypeError("Unexpected redirect response: redirects are not followed.");
|
|
137985
138036
|
}
|
|
@@ -138566,14 +138617,14 @@ var StandardHandler = class {
|
|
|
138566
138617
|
span?.setAttribute("url.path", request22.url);
|
|
138567
138618
|
return { matched: false };
|
|
138568
138619
|
}
|
|
138569
|
-
const { path:
|
|
138570
|
-
span?.updateName(`${ORPC_NAME2}.${
|
|
138620
|
+
const { path: path99, procedure, decodeInput } = matchedOrNot;
|
|
138621
|
+
span?.updateName(`${ORPC_NAME2}.${path99.join("/")}`);
|
|
138571
138622
|
span?.setAttribute("rpc.system", ORPC_NAME2);
|
|
138572
|
-
span?.setAttribute("rpc.method",
|
|
138623
|
+
span?.setAttribute("rpc.method", path99.join("."));
|
|
138573
138624
|
try {
|
|
138574
138625
|
const response = await intercept2(
|
|
138575
138626
|
this.interceptors,
|
|
138576
|
-
{ context: context2, prefix: prefix2, request: request22, path:
|
|
138627
|
+
{ context: context2, prefix: prefix2, request: request22, path: path99, procedure, decodeInput },
|
|
138577
138628
|
async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
|
|
138578
138629
|
step2 = "decode_input";
|
|
138579
138630
|
let input2 = await runWithSpan2("decode_input", decodeInput2);
|
|
@@ -138607,7 +138658,7 @@ var StandardHandler = class {
|
|
|
138607
138658
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
138608
138659
|
cause: e10
|
|
138609
138660
|
}) : toORPCError2(e10);
|
|
138610
|
-
const response = await this.codec.encodeError(error63, procedure,
|
|
138661
|
+
const response = await this.codec.encodeError(error63, procedure, path99, { context: context2, prefix: prefix2 });
|
|
138611
138662
|
return { matched: true, response };
|
|
138612
138663
|
}
|
|
138613
138664
|
}
|
|
@@ -138714,7 +138765,7 @@ var RPCMatcher = class {
|
|
|
138714
138765
|
this.rootRouter = router;
|
|
138715
138766
|
this.index(router);
|
|
138716
138767
|
}
|
|
138717
|
-
index(router,
|
|
138768
|
+
index(router, path99 = []) {
|
|
138718
138769
|
const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
|
|
138719
138770
|
if (!value2(this.filter, procedure, procedurePath)) {
|
|
138720
138771
|
return;
|
|
@@ -138725,7 +138776,7 @@ var RPCMatcher = class {
|
|
|
138725
138776
|
// contract-first entries have no implementation yet, resolveProcedure fills it in on demand
|
|
138726
138777
|
procedure: procedure instanceof Procedure ? procedure : void 0
|
|
138727
138778
|
});
|
|
138728
|
-
},
|
|
138779
|
+
}, path99);
|
|
138729
138780
|
for (const result of lazyResults) {
|
|
138730
138781
|
this.pendingLazyRouters.set(pathToHttpPath2(result.path), result);
|
|
138731
138782
|
}
|
|
@@ -138857,10 +138908,10 @@ var RPCHandlerCodec = class {
|
|
|
138857
138908
|
}
|
|
138858
138909
|
};
|
|
138859
138910
|
}
|
|
138860
|
-
encodeOutput(output2, procedure,
|
|
138911
|
+
encodeOutput(output2, procedure, path99, options) {
|
|
138861
138912
|
return {
|
|
138862
138913
|
headers: {},
|
|
138863
|
-
status: value2(this.outputStatus, output2, procedure,
|
|
138914
|
+
status: value2(this.outputStatus, output2, procedure, path99, options) ?? DEFAULT_SUCCESS_STATUS,
|
|
138864
138915
|
body: this.serializer.serialize(output2)
|
|
138865
138916
|
};
|
|
138866
138917
|
}
|
|
@@ -138936,19 +138987,19 @@ function matchesZero(m10) {
|
|
|
138936
138987
|
const last = m10.paramsMap[m10.paramsMap.length - 1];
|
|
138937
138988
|
return last[2] || !!last[3] && !last[5];
|
|
138938
138989
|
}
|
|
138939
|
-
function normalizePath(
|
|
138940
|
-
if (!
|
|
138990
|
+
function normalizePath(path99) {
|
|
138991
|
+
if (!path99.includes("/.")) return path99;
|
|
138941
138992
|
const r10 = [];
|
|
138942
138993
|
let s = "";
|
|
138943
|
-
for (s of
|
|
138994
|
+
for (s of path99.split("/")) if (s === ".") continue;
|
|
138944
138995
|
else if (s === "..") {
|
|
138945
138996
|
if (r10.length > 1) r10.pop();
|
|
138946
138997
|
} else r10.push(s);
|
|
138947
138998
|
if (s === "." || s === "..") r10.push("");
|
|
138948
138999
|
return r10.join("/") || "/";
|
|
138949
139000
|
}
|
|
138950
|
-
function splitPath(
|
|
138951
|
-
const s =
|
|
139001
|
+
function splitPath(path99) {
|
|
139002
|
+
const s = path99.split("/");
|
|
138952
139003
|
s.shift();
|
|
138953
139004
|
return s;
|
|
138954
139005
|
}
|
|
@@ -138991,9 +139042,9 @@ function getMatchParams(segments, paramsMap, suffix, slash) {
|
|
|
138991
139042
|
}
|
|
138992
139043
|
return params;
|
|
138993
139044
|
}
|
|
138994
|
-
function encodeEscapes(
|
|
138995
|
-
if (!
|
|
138996
|
-
return
|
|
139045
|
+
function encodeEscapes(path99) {
|
|
139046
|
+
if (!path99.includes("\\")) return path99;
|
|
139047
|
+
return path99.replace(/\\([:(){}\\])/g, (_, c10) => "\uFFFD" + ESCAPABLE.indexOf(c10));
|
|
138997
139048
|
}
|
|
138998
139049
|
function decodeEscapes(segment, prefix) {
|
|
138999
139050
|
return segment.replace(/\uFFFD([0-5])/g, (_, i10) => prefix + ESCAPABLE[i10]);
|
|
@@ -139030,11 +139081,11 @@ function classSetOp(s) {
|
|
|
139030
139081
|
}))) ;
|
|
139031
139082
|
return found;
|
|
139032
139083
|
}
|
|
139033
|
-
function starGroups(
|
|
139034
|
-
if (!
|
|
139084
|
+
function starGroups(path99) {
|
|
139085
|
+
if (!path99.includes("(.*)")) return [path99];
|
|
139035
139086
|
let count2 = 0;
|
|
139036
139087
|
let unnamed;
|
|
139037
|
-
return [
|
|
139088
|
+
return [path99.replace(/\\[\s\S]|(:[A-Za-z_]\w*)?\((?!\?)(\.\*\)(?!\*))?/g, (m10, name, star, at2) => {
|
|
139038
139089
|
if (m10[0] === "\\" || !star) {
|
|
139039
139090
|
if (m10[0] === "(") count2++;
|
|
139040
139091
|
return m10;
|
|
@@ -139043,25 +139094,25 @@ function starGroups(path98) {
|
|
|
139043
139094
|
const k10 = count2;
|
|
139044
139095
|
unnamed = (index) => index === k10 ? name.slice(1) : index > k10 ? index - 1 : index;
|
|
139045
139096
|
} else count2++;
|
|
139046
|
-
return /(^|[^\\])(\\\\)*([)*}?]|:[A-Za-z_]\w*)\{?$/.test(
|
|
139097
|
+
return /(^|[^\\])(\\\\)*([)*}?]|:[A-Za-z_]\w*)\{?$/.test(path99.slice(0, at2)) ? "\uFFFF*" : "*";
|
|
139047
139098
|
}), unnamed];
|
|
139048
139099
|
}
|
|
139049
|
-
function absolutePattern(
|
|
139050
|
-
return /^[/{]/.test(
|
|
139100
|
+
function absolutePattern(path99) {
|
|
139101
|
+
return /^[/{]/.test(path99) ? path99 : `/${path99}`;
|
|
139051
139102
|
}
|
|
139052
|
-
function dotSegments(
|
|
139053
|
-
if (!DOT_SEGMENT.test(
|
|
139054
|
-
const s =
|
|
139103
|
+
function dotSegments(path99) {
|
|
139104
|
+
if (!DOT_SEGMENT.test(path99)) return path99;
|
|
139105
|
+
const s = path99.split("/");
|
|
139055
139106
|
const out = [s[0]];
|
|
139056
139107
|
let dot = false;
|
|
139057
139108
|
for (let i10 = 1; i10 < s.length; i10++) {
|
|
139058
139109
|
const m10 = /^(?:\.|%2e)(\.|%2e)?$/i.exec(s[i10]);
|
|
139059
139110
|
if (m10) {
|
|
139060
|
-
if (m10[1] && (out.length > 1 || out[0]) && !isText(out.pop())) invalidSyntax(DOT_SEGMENT_NEXT_TO,
|
|
139111
|
+
if (m10[1] && (out.length > 1 || out[0]) && !isText(out.pop())) invalidSyntax(DOT_SEGMENT_NEXT_TO, path99);
|
|
139061
139112
|
dot = true;
|
|
139062
139113
|
continue;
|
|
139063
139114
|
}
|
|
139064
|
-
if (dot && /^[:*(]/.test(s[i10])) invalidSyntax(DOT_SEGMENT_NEXT_TO,
|
|
139115
|
+
if (dot && /^[:*(]/.test(s[i10])) invalidSyntax(DOT_SEGMENT_NEXT_TO, path99);
|
|
139065
139116
|
out.push(s[i10]);
|
|
139066
139117
|
dot = false;
|
|
139067
139118
|
}
|
|
@@ -139128,17 +139179,17 @@ function splitStar(segments, input2) {
|
|
|
139128
139179
|
function oneCatchAll(input2) {
|
|
139129
139180
|
throw new Error(`rou3: a route can have only one \`*\`, \`**\`, \`:name+\` or \`:name*\` (${input2})`);
|
|
139130
139181
|
}
|
|
139131
|
-
function splitRoute(
|
|
139132
|
-
const s = splitPath(
|
|
139182
|
+
function splitRoute(path99) {
|
|
139183
|
+
const s = splitPath(path99);
|
|
139133
139184
|
while (s[s.length - 1] === "") s.pop();
|
|
139134
|
-
if (
|
|
139185
|
+
if (path99.includes("**")) {
|
|
139135
139186
|
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)]);
|
|
139136
139187
|
}
|
|
139137
139188
|
return s;
|
|
139138
139189
|
}
|
|
139139
|
-
function expandedRouteId(
|
|
139140
|
-
if (
|
|
139141
|
-
return "/" + splitRoute(encodeEscapes(
|
|
139190
|
+
function expandedRouteId(path99) {
|
|
139191
|
+
if (path99.charCodeAt(0) !== 47) return `{${expandedRouteId(`/${path99}`)}`;
|
|
139192
|
+
return "/" + splitRoute(encodeEscapes(path99)).map((segment) => {
|
|
139142
139193
|
const key = segmentKey(segment);
|
|
139143
139194
|
return typeof key === "string" ? key : segment;
|
|
139144
139195
|
}).join("/");
|
|
@@ -139160,40 +139211,40 @@ function segmentWildcards(segment) {
|
|
|
139160
139211
|
}
|
|
139161
139212
|
return at2;
|
|
139162
139213
|
}
|
|
139163
|
-
function scanFirstGroup(
|
|
139214
|
+
function scanFirstGroup(path99) {
|
|
139164
139215
|
let i10 = 0;
|
|
139165
139216
|
let depth = 0;
|
|
139166
|
-
for (; i10 <
|
|
139167
|
-
const c10 =
|
|
139217
|
+
for (; i10 < path99.length; i10++) {
|
|
139218
|
+
const c10 = path99.charCodeAt(i10);
|
|
139168
139219
|
if (c10 === 92) i10++;
|
|
139169
139220
|
else if (c10 === 40) depth++;
|
|
139170
139221
|
else if (c10 === 41 && depth > 0) depth--;
|
|
139171
139222
|
else if (c10 === 123 && depth === 0) break;
|
|
139172
139223
|
}
|
|
139173
|
-
if (i10 >=
|
|
139224
|
+
if (i10 >= path99.length) return;
|
|
139174
139225
|
let j10 = i10 + 1;
|
|
139175
139226
|
depth = 0;
|
|
139176
|
-
for (; j10 <
|
|
139177
|
-
const c10 =
|
|
139227
|
+
for (; j10 < path99.length; j10++) {
|
|
139228
|
+
const c10 = path99.charCodeAt(j10);
|
|
139178
139229
|
if (c10 === 92) j10++;
|
|
139179
139230
|
else if (c10 === 40) depth++;
|
|
139180
139231
|
else if (c10 === 41 && depth > 0) depth--;
|
|
139181
139232
|
else if (c10 === 125 && depth === 0) break;
|
|
139182
139233
|
}
|
|
139183
|
-
if (j10 >=
|
|
139184
|
-
const mod =
|
|
139234
|
+
if (j10 >= path99.length) return;
|
|
139235
|
+
const mod = path99[j10 + 1];
|
|
139185
139236
|
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
139186
139237
|
return [
|
|
139187
|
-
|
|
139188
|
-
|
|
139189
|
-
|
|
139238
|
+
path99.slice(0, i10),
|
|
139239
|
+
path99.slice(i10 + 1, j10).replace(NAME_CHAR, "\\$&"),
|
|
139240
|
+
path99.slice(j10 + (hasMod ? 2 : 1)).replace(NAME_CHAR, "\\$&"),
|
|
139190
139241
|
hasMod ? mod : void 0
|
|
139191
139242
|
];
|
|
139192
139243
|
}
|
|
139193
139244
|
var NAME_CHAR = /^[\w$\x80-]/;
|
|
139194
|
-
function expandGroupDelimiters(
|
|
139195
|
-
if (!
|
|
139196
|
-
const group = scanFirstGroup(
|
|
139245
|
+
function expandGroupDelimiters(path99, input2 = path99) {
|
|
139246
|
+
if (!path99.includes("{")) return;
|
|
139247
|
+
const group = scanFirstGroup(path99);
|
|
139197
139248
|
if (!group) return;
|
|
139198
139249
|
const [pre2, body, suf, mod] = group;
|
|
139199
139250
|
if (mod === "+" || mod === "*") invalidSyntax(`unsupported \`{}${mod}\``, input2);
|
|
@@ -139295,43 +139346,43 @@ function linearRegExp(regexp) {
|
|
|
139295
139346
|
return source === regexp.source ? regexp : new RegExp(`^${head}${source.slice(1)}`);
|
|
139296
139347
|
}
|
|
139297
139348
|
var upTo = (L, back) => L.replace(/^\\/, "").length < 2 ? `[^/${L}]*` : back ? `(?:[^/](?<!${L}))*` : `(?:(?!${L})[^/])*`;
|
|
139298
|
-
function addRoute(ctx, method = "",
|
|
139349
|
+
function addRoute(ctx, method = "", path99, data) {
|
|
139299
139350
|
method = method.toUpperCase();
|
|
139300
|
-
|
|
139301
|
-
checkConstraints(
|
|
139302
|
-
const resolved = dotSegments(
|
|
139351
|
+
path99 = absolutePattern(path99);
|
|
139352
|
+
checkConstraints(path99);
|
|
139353
|
+
const resolved = dotSegments(path99);
|
|
139303
139354
|
const [route, unnamed] = starGroups(resolved);
|
|
139304
139355
|
variants = void 0;
|
|
139305
|
-
_add(ctx, method, route, data, unnamed && expandedRouteId(resolved),
|
|
139356
|
+
_add(ctx, method, route, data, unnamed && expandedRouteId(resolved), path99, unnamed);
|
|
139306
139357
|
}
|
|
139307
139358
|
var variants;
|
|
139308
|
-
function _add(ctx, method,
|
|
139309
|
-
const groupExpanded = expandGroupDelimiters(
|
|
139359
|
+
function _add(ctx, method, path99, data, route, input2 = path99, unnamed = same) {
|
|
139360
|
+
const groupExpanded = expandGroupDelimiters(path99, input2);
|
|
139310
139361
|
if (groupExpanded) {
|
|
139311
139362
|
if (groupExpanded[1] !== void 0) {
|
|
139312
|
-
route ??= expandedRouteId(
|
|
139363
|
+
route ??= expandedRouteId(path99);
|
|
139313
139364
|
variants ??= {};
|
|
139314
139365
|
}
|
|
139315
139366
|
_add(ctx, method, groupExpanded[0], data, route, input2, unnamed);
|
|
139316
|
-
if (groupExpanded[1] !== void 0) _add(ctx, method, groupExpanded[1], data, route, input2, /[*(]/.test(
|
|
139367
|
+
if (groupExpanded[1] !== void 0) _add(ctx, method, groupExpanded[1], data, route, input2, /[*(]/.test(path99) ? skipGroup(path99, input2, unnamed) : unnamed);
|
|
139317
139368
|
return 0;
|
|
139318
139369
|
}
|
|
139319
|
-
|
|
139320
|
-
const segments = splitRoute(
|
|
139370
|
+
path99 = encodeEscapes(path99);
|
|
139371
|
+
const segments = splitRoute(path99);
|
|
139321
139372
|
const expanded = expandModifiers(segments, input2);
|
|
139322
139373
|
if (expanded) {
|
|
139323
|
-
route ??= expandedRouteId(
|
|
139374
|
+
route ??= expandedRouteId(path99);
|
|
139324
139375
|
variants ??= {};
|
|
139325
139376
|
let count2 = 0;
|
|
139326
139377
|
for (const p of expanded) count2 = _add(ctx, method, p, data, route, input2, unnamed);
|
|
139327
139378
|
return count2;
|
|
139328
139379
|
}
|
|
139329
|
-
const star =
|
|
139380
|
+
const star = path99.includes("*");
|
|
139330
139381
|
const split = star ? splitStar(segments, input2) : void 0;
|
|
139331
139382
|
if (split) {
|
|
139332
139383
|
const [routes, join4, head] = split;
|
|
139333
139384
|
if (routes.length > 1) {
|
|
139334
|
-
route ??= expandedRouteId(
|
|
139385
|
+
route ??= expandedRouteId(path99);
|
|
139335
139386
|
variants ??= {};
|
|
139336
139387
|
}
|
|
139337
139388
|
let count2 = 0;
|
|
@@ -139451,8 +139502,8 @@ function _insert(ctx, method, segments, data, route, input2, unnamed, star, join
|
|
|
139451
139502
|
return _unnamedParamIndex;
|
|
139452
139503
|
}
|
|
139453
139504
|
var same = (index) => index;
|
|
139454
|
-
function skipGroup(
|
|
139455
|
-
const [pre2, body] = scanFirstGroup(
|
|
139505
|
+
function skipGroup(path99, input2, unnamed = same) {
|
|
139506
|
+
const [pre2, body] = scanFirstGroup(path99);
|
|
139456
139507
|
if (!/[*(]/.test(body) && !pre2.endsWith("*")) return unnamed;
|
|
139457
139508
|
const count2 = (p) => _add(createRouter(), "", p, void 0, void 0, input2);
|
|
139458
139509
|
const before = count2(pre2);
|
|
@@ -139514,11 +139565,11 @@ function kindAt(m10, n10, p) {
|
|
|
139514
139565
|
} else if ((suffix && index > suffix[0] ? index - suffix[0] - 1 + end : index) === p) return typeof name === "string" || plain ? 0 : 2;
|
|
139515
139566
|
return 3;
|
|
139516
139567
|
}
|
|
139517
|
-
function findAllRoutes(ctx, method = "",
|
|
139518
|
-
if (opts?.normalize)
|
|
139519
|
-
const slash =
|
|
139520
|
-
if (slash)
|
|
139521
|
-
const segments = splitPath(
|
|
139568
|
+
function findAllRoutes(ctx, method = "", path99, opts) {
|
|
139569
|
+
if (opts?.normalize) path99 = normalizePath(path99);
|
|
139570
|
+
const slash = path99.charCodeAt(path99.length - 1) === 47;
|
|
139571
|
+
if (slash) path99 = path99.slice(0, -1);
|
|
139572
|
+
const segments = splitPath(path99);
|
|
139522
139573
|
const matches2 = _findRanked(ctx, method, segments);
|
|
139523
139574
|
let seen;
|
|
139524
139575
|
for (let i10 = matches2.length - 1; i10 >= 0; i10--) {
|
|
@@ -139575,16 +139626,16 @@ function pushSorted(matches2, match, reverse) {
|
|
|
139575
139626
|
}).sort((a10, b) => a10[1] - b[1]).map((e10) => e10[0]);
|
|
139576
139627
|
for (const m10 of match) matches2.push(m10);
|
|
139577
139628
|
}
|
|
139578
|
-
function findRoute(ctx, method = "",
|
|
139579
|
-
if (opts?.normalize)
|
|
139580
|
-
const slash =
|
|
139581
|
-
if (slash)
|
|
139582
|
-
const staticNode = ctx.static[
|
|
139629
|
+
function findRoute(ctx, method = "", path99, opts) {
|
|
139630
|
+
if (opts?.normalize) path99 = normalizePath(path99);
|
|
139631
|
+
const slash = path99.charCodeAt(path99.length - 1) === 47;
|
|
139632
|
+
if (slash) path99 = path99.slice(0, -1);
|
|
139633
|
+
const staticNode = ctx.static[path99];
|
|
139583
139634
|
if (staticNode && staticNode.methods) {
|
|
139584
139635
|
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
139585
139636
|
if (staticMatch !== void 0) return { data: staticMatch[0].data };
|
|
139586
139637
|
}
|
|
139587
|
-
const segments = splitPath(
|
|
139638
|
+
const segments = splitPath(path99);
|
|
139588
139639
|
let match;
|
|
139589
139640
|
if (segments.includes("") || ctx.root.hasSuffix && hasSuffixMatch(ctx.root, method, segments, 0)) {
|
|
139590
139641
|
const matches2 = _findRanked(ctx, method, segments, true);
|
|
@@ -139880,8 +139931,8 @@ var STAR_SEGMENT = "*/";
|
|
|
139880
139931
|
function routeToRegExp(route = "/") {
|
|
139881
139932
|
route = absolutePattern(route);
|
|
139882
139933
|
addRoute(createRouter(), "", route);
|
|
139883
|
-
const [
|
|
139884
|
-
return new RegExp(determinize(toRegExp(
|
|
139934
|
+
const [path99, unnamed] = starGroups(dotSegments(route));
|
|
139935
|
+
return new RegExp(determinize(toRegExp(path99, route, unnamed).source));
|
|
139885
139936
|
}
|
|
139886
139937
|
function toRegExp(route, input2, unnamed) {
|
|
139887
139938
|
const inlineOptional = inlineOptionalGroup(route, input2, unnamed);
|
|
@@ -140238,7 +140289,7 @@ var OpenAPIMatcher = class {
|
|
|
140238
140289
|
this.rootRouter = router;
|
|
140239
140290
|
this.index(router);
|
|
140240
140291
|
}
|
|
140241
|
-
index(router,
|
|
140292
|
+
index(router, path99 = []) {
|
|
140242
140293
|
const routes = [];
|
|
140243
140294
|
const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
|
|
140244
140295
|
if (!value2(this.filter, contract, path210)) {
|
|
@@ -140259,7 +140310,7 @@ var OpenAPIMatcher = class {
|
|
|
140259
140310
|
...route
|
|
140260
140311
|
}
|
|
140261
140312
|
});
|
|
140262
|
-
},
|
|
140313
|
+
}, path99);
|
|
140263
140314
|
const pendingLazyRouters = lazyResults.map((result) => {
|
|
140264
140315
|
const prefix = getOpenAPIMeta(result.router)?.prefix;
|
|
140265
140316
|
return {
|
|
@@ -140359,10 +140410,10 @@ var OpenAPIMatcher = class {
|
|
|
140359
140410
|
return entry.procedure;
|
|
140360
140411
|
}
|
|
140361
140412
|
};
|
|
140362
|
-
function toRou3Route(
|
|
140363
|
-
const dynamicParams = getDynamicPathParams(
|
|
140413
|
+
function toRou3Route(path99) {
|
|
140414
|
+
const dynamicParams = getDynamicPathParams(path99);
|
|
140364
140415
|
if (!dynamicParams) {
|
|
140365
|
-
return { pattern: toRou3Literal(
|
|
140416
|
+
return { pattern: toRou3Literal(path99) };
|
|
140366
140417
|
}
|
|
140367
140418
|
let pattern = "";
|
|
140368
140419
|
let literalStart = 0;
|
|
@@ -140371,11 +140422,11 @@ function toRou3Route(path98) {
|
|
|
140371
140422
|
for (const param of dynamicParams) {
|
|
140372
140423
|
const key = `p${params.length}`;
|
|
140373
140424
|
params.push([key, param.parameterName]);
|
|
140374
|
-
pattern += toRou3Literal(
|
|
140425
|
+
pattern += toRou3Literal(path99.slice(literalStart, param.startIndex));
|
|
140375
140426
|
literalStart = param.startIndex + param.segment.length;
|
|
140376
140427
|
if (param.allowsSlash) {
|
|
140377
140428
|
if (catchAllKey !== void 0) {
|
|
140378
|
-
throw new TypeError(`OpenAPI path "${
|
|
140429
|
+
throw new TypeError(`OpenAPI path "${path99}" has more than one catch-all param ({+name}), but only one is supported per path.`);
|
|
140379
140430
|
}
|
|
140380
140431
|
catchAllKey = key;
|
|
140381
140432
|
pattern += `:${key}(.*)`;
|
|
@@ -140383,7 +140434,7 @@ function toRou3Route(path98) {
|
|
|
140383
140434
|
pattern += `:${key}`;
|
|
140384
140435
|
}
|
|
140385
140436
|
}
|
|
140386
|
-
pattern += toRou3Literal(
|
|
140437
|
+
pattern += toRou3Literal(path99.slice(literalStart));
|
|
140387
140438
|
return { pattern, params, catchAllKey };
|
|
140388
140439
|
}
|
|
140389
140440
|
var ROU3_SYNTAX_REGEX = /[\\:*?+(){}]|(?<![^/])\.(?=\.?(?:\/|$))/g;
|
|
@@ -140391,8 +140442,8 @@ function toRou3Literal(text5) {
|
|
|
140391
140442
|
const normalized = NORMALIZABLE_PATHNAME_REGEX2.test(text5) ? normalizeRou3Path(text5) : text5;
|
|
140392
140443
|
return normalized.replace(ROU3_SYNTAX_REGEX, "\\$&");
|
|
140393
140444
|
}
|
|
140394
|
-
function normalizeRou3Path(
|
|
140395
|
-
return
|
|
140445
|
+
function normalizeRou3Path(path99) {
|
|
140446
|
+
return path99.split("/").map((segment) => safeDecodeURIComponent2(segment).replace(ROU3_ENCODED_SEGMENT_TEXT_REGEX, safeEncodeURIComponent2)).join("/");
|
|
140396
140447
|
}
|
|
140397
140448
|
function toRou3PrefixMatcher(prefix) {
|
|
140398
140449
|
const catchAll = getDynamicPathParams(prefix)?.find((param) => param.allowsSlash);
|
|
@@ -140482,7 +140533,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
140482
140533
|
/**
|
|
140483
140534
|
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
140484
140535
|
*/
|
|
140485
|
-
encodeOutput(output2, procedure,
|
|
140536
|
+
encodeOutput(output2, procedure, path99) {
|
|
140486
140537
|
const meta3 = getOpenAPIMeta(procedure);
|
|
140487
140538
|
const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
|
|
140488
140539
|
const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
|
|
@@ -140495,7 +140546,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
140495
140546
|
}
|
|
140496
140547
|
if (!isValidDetailedOutput(output2)) {
|
|
140497
140548
|
throw new TypeError(`
|
|
140498
|
-
Invalid "detailed" output structure returned by procedure (${
|
|
140549
|
+
Invalid "detailed" output structure returned by procedure (${path99.join(".")}):
|
|
140499
140550
|
\u2022 Expected an object with optional properties:
|
|
140500
140551
|
- status (number <400)
|
|
140501
140552
|
- headers (object)
|
|
@@ -141108,7 +141159,7 @@ function profileValue(name, paths) {
|
|
|
141108
141159
|
function createConfigApiRouter(deps) {
|
|
141109
141160
|
const authed = doorApiAuth(deps.expectedToken);
|
|
141110
141161
|
const { paths } = deps;
|
|
141111
|
-
const route = (
|
|
141162
|
+
const route = (path99, summary) => authed.meta(openapi({ method: "POST", path: path99, summary, tags: [CONFIG_API_TAG] }));
|
|
141112
141163
|
return {
|
|
141113
141164
|
config: {
|
|
141114
141165
|
identity: {
|
|
@@ -141660,104 +141711,8 @@ function createAgentTreesApiRouter(deps) {
|
|
|
141660
141711
|
};
|
|
141661
141712
|
}
|
|
141662
141713
|
|
|
141663
|
-
// src/frontdoor/
|
|
141664
|
-
|
|
141665
|
-
var FRONTDOOR_API_TAG2 = "frontdoor";
|
|
141666
|
-
var CHECK_API_TAG = "check";
|
|
141667
|
-
var DOCTOR_API_TAG = "doctor";
|
|
141668
|
-
var POOL_API_TAG = "pool";
|
|
141669
|
-
function createControlApiRouter(deps) {
|
|
141670
|
-
const authed = doorApiAuth(deps.expectedToken);
|
|
141671
|
-
return {
|
|
141672
|
-
usage: {
|
|
141673
|
-
list: authed.meta(openapi({ method: "GET", path: "/rest/usage/snapshots", summary: "List every identity's usage snapshot", tags: [USAGE_API_TAG] })).output(UsageListOutputSchema).handler(() => ({ snapshots: deps.usageSnapshots() })),
|
|
141674
|
-
resets: authed.meta(openapi({ method: "GET", path: "/rest/usage/resets", summary: "List every recorded quota window with when it resets", tags: [USAGE_API_TAG] })).output(ResetScheduleSchema).handler(() => collectResets(deps.usageSnapshots(), deps.now())),
|
|
141675
|
-
effectiveWindow: authed.meta(openapi({ method: "GET", path: "/rest/usage/windows", summary: "Read one identity's effective quota windows", tags: [USAGE_API_TAG] })).input(UsageWindowsInputSchema).output(UsageWindowsOutputSchema).handler(({ input: input2 }) => {
|
|
141676
|
-
const snapshot = deps.usageSnapshotOf(input2.identity);
|
|
141677
|
-
if (snapshot === void 0) {
|
|
141678
|
-
throw new ORPCError("NOT_FOUND", { message: `identity ${input2.identity} has no usage snapshot yet, so no quota window has been observed for it` });
|
|
141679
|
-
}
|
|
141680
|
-
const provider = input2.provider ?? ANTHROPIC_PROVIDER;
|
|
141681
|
-
const rateLimit = snapshot.providers[provider]?.rateLimit;
|
|
141682
|
-
const unified = rateLimit?.unified;
|
|
141683
|
-
const now = deps.now();
|
|
141684
|
-
return {
|
|
141685
|
-
identity: snapshot.identity,
|
|
141686
|
-
provider,
|
|
141687
|
-
...rateLimit === void 0 ? {} : { observedAt: rateLimit.observedAt },
|
|
141688
|
-
...unified?.fiveHour === void 0 ? {} : { fiveHour: effectiveWindow(unified.fiveHour, now) },
|
|
141689
|
-
...unified?.sevenDay === void 0 ? {} : { sevenDay: effectiveWindow(unified.sevenDay, now) }
|
|
141690
|
-
};
|
|
141691
|
-
}),
|
|
141692
|
-
live: authed.meta(openapi({ method: "GET", path: "/rest/usage/live", summary: "Read the live rate-limit observations the event backbone files", tags: [USAGE_API_TAG] })).input(RcSessionQuerySchema).output(UsageLiveOutputSchema).handler(({ input: input2 }) => {
|
|
141693
|
-
const sessions = deps.liveRateLimits(input2.session);
|
|
141694
|
-
if (input2.session !== void 0 && sessions.length === 0) {
|
|
141695
|
-
if (deps.list().some((session) => session.id === input2.session)) {
|
|
141696
|
-
throw new ORPCError("NOT_FOUND", { message: `session ${input2.session} has filed no rate_limit_event on its stream yet: the worker emits one only once a turn has completed, so retry after this session's next turn` });
|
|
141697
|
-
}
|
|
141698
|
-
throw new ORPCError("NOT_FOUND", { message: rcSessionNotObservedMessage(input2.session) });
|
|
141699
|
-
}
|
|
141700
|
-
return { latest: deps.latestRateLimit(), sessions };
|
|
141701
|
-
})
|
|
141702
|
-
},
|
|
141703
|
-
frontdoor: {
|
|
141704
|
-
status: authed.meta(openapi({ method: "GET", path: "/rest/frontdoor/status", summary: "Read the front door's status", tags: [FRONTDOOR_API_TAG2] })).output(FrontDoorStatusOutputSchema).handler(() => deps.frontDoorStatus()),
|
|
141705
|
-
sessions: authed.meta(openapi({ method: "GET", path: "/rest/frontdoor/sessions", summary: "Read the front door's session registry", tags: [FRONTDOOR_API_TAG2] })).output(FrontDoorSessionsOutputSchema).handler(() => ({ sessions: deps.frontDoorStatus().sessions }))
|
|
141706
|
-
},
|
|
141707
|
-
check: {
|
|
141708
|
-
// The report's own JSON shape is the contract (the same one `check --json` prints and `checkReportSchema.ts` defines), so the procedure returns exactly that conversion.
|
|
141709
|
-
run: authed.meta(openapi({ method: "GET", path: "/rest/check", summary: "Run the check report for one directory", tags: [CHECK_API_TAG] })).input(CheckRunInputSchema).output(CheckReportJsonSchema).handler(({ input: input2 }) => checkReportToJson(deps.checkReport(input2.path, input2.identity)))
|
|
141710
|
-
},
|
|
141711
|
-
doctor: {
|
|
141712
|
-
run: authed.meta(openapi({ method: "GET", path: "/rest/doctor", summary: "Run the doctor report", tags: [DOCTOR_API_TAG] })).output(DoctorRunOutputSchema).handler(() => deps.doctorReport())
|
|
141713
|
-
},
|
|
141714
|
-
pool: {
|
|
141715
|
-
pick: authed.meta(openapi({ method: "GET", path: "/rest/pool/pick", summary: "Rank one pool exactly as a launch from a directory would right now", tags: [POOL_API_TAG] })).input(PoolPickInputSchema).output(PoolPickReportSchema).handler(({ input: input2 }) => {
|
|
141716
|
-
const report = deps.poolPick(input2.pool, input2.path);
|
|
141717
|
-
if (report === void 0) {
|
|
141718
|
-
const live = deps.poolNames();
|
|
141719
|
-
throw new ORPCError("NOT_FOUND", {
|
|
141720
|
-
message: live.length === 0 ? `no pools are configured, so none is named ${input2.pool}` : `no pool is named ${input2.pool}; the live pools are ${live.map((name) => `"${name}"`).join(", ")}`
|
|
141721
|
-
});
|
|
141722
|
-
}
|
|
141723
|
-
return report;
|
|
141724
|
-
})
|
|
141725
|
-
}
|
|
141726
|
-
};
|
|
141727
|
-
}
|
|
141728
|
-
function createDoorApiRouter(deps) {
|
|
141729
|
-
const control = createControlApiRouter(deps);
|
|
141730
|
-
const lifecycle = createLifecycleApiRouter(deps);
|
|
141731
|
-
return { ...createRcApiRouter(deps), ...control, ...lifecycle, ...createConfigApiRouter(deps), ...createCodexApiRouter(deps), ...createLaunchApiRouter(deps), ...createAgentTreesApiRouter(deps), ...createEventsApiRouter(deps), frontdoor: { ...control.frontdoor, ...lifecycle.frontdoor } };
|
|
141732
|
-
}
|
|
141733
|
-
function createDoorApiNodeHandler(deps) {
|
|
141734
|
-
return doorApiNodeHandlerOf(createDoorApiRouter(deps), deps.expectedToken);
|
|
141735
|
-
}
|
|
141736
|
-
|
|
141737
|
-
// src/frontdoor/doorHealthEvents.ts
|
|
141738
|
-
function createDoorHealthPublisher(hub, now, pid) {
|
|
141739
|
-
const publisher = hub.publisher(DOOR_HEALTH_EVENT_SOURCE);
|
|
141740
|
-
return {
|
|
141741
|
-
generation: (ports) => {
|
|
141742
|
-
publisher.publish({ kind: "generation", pid, providerPort: ports.providerPort, connectPort: ports.connectPort, directPort: ports.directPort, observedAt: now() });
|
|
141743
|
-
},
|
|
141744
|
-
listenerFailed: (listener, message) => {
|
|
141745
|
-
publisher.publish({ kind: "listenerFailed", pid, listener, message, observedAt: now() });
|
|
141746
|
-
},
|
|
141747
|
-
idleShutdown: () => {
|
|
141748
|
-
publisher.publish({ kind: "idleShutdown", pid, observedAt: now() });
|
|
141749
|
-
},
|
|
141750
|
-
binaryTurnover: () => {
|
|
141751
|
-
publisher.publish({ kind: "binaryTurnover", pid, observedAt: now() });
|
|
141752
|
-
},
|
|
141753
|
-
superseded: (ownerPid) => {
|
|
141754
|
-
publisher.publish({ kind: "superseded", pid, ownerPid, observedAt: now() });
|
|
141755
|
-
},
|
|
141756
|
-
drained: () => {
|
|
141757
|
-
publisher.publish({ kind: "drained", pid, observedAt: now() });
|
|
141758
|
-
}
|
|
141759
|
-
};
|
|
141760
|
-
}
|
|
141714
|
+
// src/frontdoor/rcEventLog.ts
|
|
141715
|
+
init_zod();
|
|
141761
141716
|
|
|
141762
141717
|
// src/frontdoor/eventHub.ts
|
|
141763
141718
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -141865,6 +141820,369 @@ function rcFanoutOnDoorHub(fanout, hub) {
|
|
|
141865
141820
|
};
|
|
141866
141821
|
}
|
|
141867
141822
|
|
|
141823
|
+
// src/frontdoor/rcEventLog.ts
|
|
141824
|
+
var RC_SESSION_EVENT_TOKEN_MAX_CHARS = 255;
|
|
141825
|
+
var HIGH_SURROGATE_FIRST = 55296;
|
|
141826
|
+
var HIGH_SURROGATE_LAST = 56319;
|
|
141827
|
+
var LOW_SURROGATE_FIRST = 56320;
|
|
141828
|
+
var LOW_SURROGATE_LAST = 57343;
|
|
141829
|
+
var CUT_MARKER = "...";
|
|
141830
|
+
var RC_SESSION_EVENT_SUMMARY_MAX_CHARS = RC_SESSION_EVENT_TOKEN_MAX_CHARS + " ".length + RC_PENDING_SUMMARY_EXCERPT_CHARS + CUT_MARKER.length;
|
|
141831
|
+
var RC_SESSION_EVENT_GENERATION_MAX_CHARS = "00000000-0000-4000-8000-000000000000".length;
|
|
141832
|
+
var SEQUENCE_MAX_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
141833
|
+
var NUMBER_BYTES = Float64Array.BYTES_PER_ELEMENT;
|
|
141834
|
+
var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
141835
|
+
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
141836
|
+
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
141837
|
+
var RC_PENDING_RETIRE_REASONS = ["answered", "expired", "session-ended"];
|
|
141838
|
+
var transitionBase = { session: external_exports.string(), at: external_exports.number() };
|
|
141839
|
+
var cursorFields = { cursor: external_exports.string(), sequence: external_exports.int().positive() };
|
|
141840
|
+
var sessionAppearedShape = { kind: external_exports.literal("session-appeared"), ...transitionBase };
|
|
141841
|
+
var sessionEndedShape = { kind: external_exports.literal("session-ended"), reason: external_exports.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
141842
|
+
var workerStateShape = { kind: external_exports.literal("worker-state"), state: external_exports.string(), previous: external_exports.string().optional(), ...transitionBase };
|
|
141843
|
+
var pendingBornShape = { kind: external_exports.literal("pending-born"), requestId: external_exports.string(), type: external_exports.string(), summary: external_exports.string(), ...transitionBase };
|
|
141844
|
+
var pendingRetiredShape = { kind: external_exports.literal("pending-retired"), requestId: external_exports.string(), reason: external_exports.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
141845
|
+
var RcSessionTransitionSchema = external_exports.discriminatedUnion("kind", [
|
|
141846
|
+
external_exports.strictObject(sessionAppearedShape),
|
|
141847
|
+
external_exports.strictObject(sessionEndedShape),
|
|
141848
|
+
external_exports.strictObject(workerStateShape),
|
|
141849
|
+
external_exports.strictObject(pendingBornShape),
|
|
141850
|
+
external_exports.strictObject(pendingRetiredShape)
|
|
141851
|
+
]);
|
|
141852
|
+
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
141853
|
+
var RC_SESSION_EVENT_MAX_BYTES = (RC_SESSION_EVENT_GENERATION_MAX_CHARS + ".".length + SEQUENCE_MAX_DIGITS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + KIND_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_SUMMARY_MAX_CHARS) * BYTES_PER_CODE_UNIT + NUMBER_FIELDS * NUMBER_BYTES;
|
|
141854
|
+
var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
|
|
141855
|
+
var RcSessionEventSchema = external_exports.discriminatedUnion("kind", [
|
|
141856
|
+
external_exports.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
141857
|
+
external_exports.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
141858
|
+
external_exports.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
141859
|
+
external_exports.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
141860
|
+
external_exports.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
141861
|
+
]);
|
|
141862
|
+
var RcSessionEventsReadInputSchema = external_exports.strictObject({
|
|
141863
|
+
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
141864
|
+
since: external_exports.string().min(1).optional(),
|
|
141865
|
+
/** One `cse_` session id; every session when omitted. */
|
|
141866
|
+
session: external_exports.string().min(1).optional(),
|
|
141867
|
+
/** The most events one answer carries; every event after `since` when omitted. */
|
|
141868
|
+
limit: external_exports.int().positive().optional()
|
|
141869
|
+
});
|
|
141870
|
+
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
141871
|
+
/** The most events this page carries: by default and at most, the bound the door's event backbone already holds per slow consumer (`DOOR_EVENT_BUFFER_EVENTS`, oRPC's own documented default for that case). A page lands whole in its reader, so a reader receives at most one consumer buffer's worth at a time (at worst `DOOR_EVENT_BUFFER_EVENTS` times `RC_SESSION_EVENT_MAX_BYTES`) and pages on with the cursor for more; a maximum of the whole window would let one page carry the log's entire memory budget into an agent's context. */
|
|
141872
|
+
limit: external_exports.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
141873
|
+
});
|
|
141874
|
+
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
141875
|
+
var RcSessionEventsReadOutputSchema = external_exports.discriminatedUnion("status", [
|
|
141876
|
+
external_exports.strictObject({ status: external_exports.literal("ok"), events: external_exports.readonly(external_exports.array(RcSessionEventSchema)), cursor: external_exports.string(), more: external_exports.boolean(), head: external_exports.string() }),
|
|
141877
|
+
external_exports.strictObject({ status: external_exports.literal("expired"), message: external_exports.string(), head: external_exports.string() })
|
|
141878
|
+
]);
|
|
141879
|
+
var CURSOR_SEPARATOR = ".";
|
|
141880
|
+
var RESYNC_ADVICE = "cursor expired, resync from status: read `rc status` for every session's present state, then resume after the head this answer names";
|
|
141881
|
+
function cursorOf(generation, sequence2) {
|
|
141882
|
+
return `${generation}${CURSOR_SEPARATOR}${String(sequence2)}`;
|
|
141883
|
+
}
|
|
141884
|
+
function parseCursor(cursor3) {
|
|
141885
|
+
const at2 = cursor3.lastIndexOf(CURSOR_SEPARATOR);
|
|
141886
|
+
if (at2 <= 0) {
|
|
141887
|
+
return void 0;
|
|
141888
|
+
}
|
|
141889
|
+
const digits = cursor3.slice(at2 + 1);
|
|
141890
|
+
if (!/^[0-9]+$/.test(digits)) {
|
|
141891
|
+
return void 0;
|
|
141892
|
+
}
|
|
141893
|
+
return { generation: cursor3.slice(0, at2), sequence: Number(digits) };
|
|
141894
|
+
}
|
|
141895
|
+
function codePointBoundary(text5, at2) {
|
|
141896
|
+
const before = text5.charCodeAt(at2 - 1);
|
|
141897
|
+
const after = text5.charCodeAt(at2);
|
|
141898
|
+
const isHigh = before >= HIGH_SURROGATE_FIRST && before <= HIGH_SURROGATE_LAST;
|
|
141899
|
+
const isLow = after >= LOW_SURROGATE_FIRST && after <= LOW_SURROGATE_LAST;
|
|
141900
|
+
return isHigh && isLow ? at2 - 1 : at2;
|
|
141901
|
+
}
|
|
141902
|
+
function bounded2(text5, maxChars) {
|
|
141903
|
+
const kept = text5.length <= maxChars ? text5 : `${text5.slice(0, codePointBoundary(text5, maxChars - CUT_MARKER.length))}${CUT_MARKER}`;
|
|
141904
|
+
return Buffer.from(kept, "utf16le").toString("utf16le");
|
|
141905
|
+
}
|
|
141906
|
+
function boundedTransition(transition) {
|
|
141907
|
+
const session = bounded2(transition.session, RC_SESSION_EVENT_TOKEN_MAX_CHARS);
|
|
141908
|
+
if (transition.kind === "worker-state") {
|
|
141909
|
+
return { ...transition, session, state: bounded2(transition.state, RC_SESSION_EVENT_TOKEN_MAX_CHARS), ...transition.previous === void 0 ? {} : { previous: bounded2(transition.previous, RC_SESSION_EVENT_TOKEN_MAX_CHARS) } };
|
|
141910
|
+
}
|
|
141911
|
+
if (transition.kind === "pending-born") {
|
|
141912
|
+
return { ...transition, session, requestId: bounded2(transition.requestId, RC_SESSION_EVENT_TOKEN_MAX_CHARS), type: bounded2(transition.type, RC_SESSION_EVENT_TOKEN_MAX_CHARS), summary: bounded2(transition.summary, RC_SESSION_EVENT_SUMMARY_MAX_CHARS) };
|
|
141913
|
+
}
|
|
141914
|
+
if (transition.kind === "pending-retired") {
|
|
141915
|
+
return { ...transition, session, requestId: bounded2(transition.requestId, RC_SESSION_EVENT_TOKEN_MAX_CHARS) };
|
|
141916
|
+
}
|
|
141917
|
+
return { ...transition, session };
|
|
141918
|
+
}
|
|
141919
|
+
function createRcSessionEventLog(deps) {
|
|
141920
|
+
if (deps.generation.includes(CURSOR_SEPARATOR)) {
|
|
141921
|
+
throw new Error(`a door generation id must not contain "${CURSOR_SEPARATOR}", which separates a cursor's generation from its sequence`);
|
|
141922
|
+
}
|
|
141923
|
+
if (deps.generation.length > RC_SESSION_EVENT_GENERATION_MAX_CHARS) {
|
|
141924
|
+
throw new Error(`a door generation id must be at most ${String(RC_SESSION_EVENT_GENERATION_MAX_CHARS)} characters, a UUID's length`);
|
|
141925
|
+
}
|
|
141926
|
+
const events = [];
|
|
141927
|
+
let lastSequence = 0;
|
|
141928
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
141929
|
+
let isClosed = false;
|
|
141930
|
+
const expired = (reason) => ({ status: "expired", message: `${reason}; ${RESYNC_ADVICE}`, head: cursorOf(deps.generation, lastSequence) });
|
|
141931
|
+
return {
|
|
141932
|
+
append: (transition) => {
|
|
141933
|
+
lastSequence += 1;
|
|
141934
|
+
events.push({ ...boundedTransition(transition), cursor: cursorOf(deps.generation, lastSequence), sequence: lastSequence });
|
|
141935
|
+
if (events.length > deps.capacity) {
|
|
141936
|
+
events.splice(0, events.length - deps.capacity);
|
|
141937
|
+
}
|
|
141938
|
+
for (const listener of listeners) {
|
|
141939
|
+
listener();
|
|
141940
|
+
}
|
|
141941
|
+
},
|
|
141942
|
+
head: () => cursorOf(deps.generation, lastSequence),
|
|
141943
|
+
read: ({ since, session, limit }) => {
|
|
141944
|
+
let after = 0;
|
|
141945
|
+
if (since !== void 0) {
|
|
141946
|
+
const parsed = parseCursor(since);
|
|
141947
|
+
if (parsed === void 0) {
|
|
141948
|
+
return expired(`"${since}" is not a cursor this door issues`);
|
|
141949
|
+
}
|
|
141950
|
+
if (parsed.generation !== deps.generation) {
|
|
141951
|
+
return expired(`the cursor "${since}" was issued by another generation of the front door, whose events this one never held`);
|
|
141952
|
+
}
|
|
141953
|
+
if (parsed.sequence > lastSequence) {
|
|
141954
|
+
return expired(`the cursor "${since}" names an event past this door's newest`);
|
|
141955
|
+
}
|
|
141956
|
+
const oldest = events[0]?.sequence ?? lastSequence + 1;
|
|
141957
|
+
if (parsed.sequence < oldest - 1) {
|
|
141958
|
+
return expired(`the events after "${since}" have been evicted (the log retains the newest ${String(deps.capacity)} and the oldest it still holds is "${cursorOf(deps.generation, oldest)}")`);
|
|
141959
|
+
}
|
|
141960
|
+
after = parsed.sequence;
|
|
141961
|
+
}
|
|
141962
|
+
const selected2 = [];
|
|
141963
|
+
let cursor3 = cursorOf(deps.generation, lastSequence);
|
|
141964
|
+
let more = false;
|
|
141965
|
+
for (const event of events) {
|
|
141966
|
+
if (event.sequence <= after || session !== void 0 && event.session !== session) {
|
|
141967
|
+
continue;
|
|
141968
|
+
}
|
|
141969
|
+
if (limit !== void 0 && selected2.length === limit) {
|
|
141970
|
+
more = true;
|
|
141971
|
+
cursor3 = selected2.at(-1)?.cursor ?? cursor3;
|
|
141972
|
+
break;
|
|
141973
|
+
}
|
|
141974
|
+
selected2.push(event);
|
|
141975
|
+
}
|
|
141976
|
+
return { status: "ok", events: selected2, cursor: cursor3, more, head: cursorOf(deps.generation, lastSequence) };
|
|
141977
|
+
},
|
|
141978
|
+
onAppend: (listener) => {
|
|
141979
|
+
listeners.add(listener);
|
|
141980
|
+
return () => {
|
|
141981
|
+
listeners.delete(listener);
|
|
141982
|
+
};
|
|
141983
|
+
},
|
|
141984
|
+
close: () => {
|
|
141985
|
+
if (isClosed) {
|
|
141986
|
+
return;
|
|
141987
|
+
}
|
|
141988
|
+
isClosed = true;
|
|
141989
|
+
for (const listener of listeners) {
|
|
141990
|
+
listener();
|
|
141991
|
+
}
|
|
141992
|
+
},
|
|
141993
|
+
closed: () => isClosed
|
|
141994
|
+
};
|
|
141995
|
+
}
|
|
141996
|
+
var RcSessionEventCursorExpiredError = class extends Error {
|
|
141997
|
+
/** The cursor naming the log's newest event at the moment of the refusal: where to resume after once the status read has restated the present. */
|
|
141998
|
+
head;
|
|
141999
|
+
constructor(message, head) {
|
|
142000
|
+
super(message);
|
|
142001
|
+
this.name = "RcSessionEventCursorExpiredError";
|
|
142002
|
+
this.head = head;
|
|
142003
|
+
}
|
|
142004
|
+
};
|
|
142005
|
+
function followRcSessionEvents(log, input2, signal) {
|
|
142006
|
+
return followAfter(log, input2.since ?? log.head(), input2.session, signal);
|
|
142007
|
+
}
|
|
142008
|
+
async function* followAfter(log, since, session, signal) {
|
|
142009
|
+
let cursor3 = since;
|
|
142010
|
+
let onAbort = () => void 0;
|
|
142011
|
+
const aborted2 = new Promise((resolve3) => {
|
|
142012
|
+
onAbort = resolve3;
|
|
142013
|
+
});
|
|
142014
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
142015
|
+
try {
|
|
142016
|
+
for (; ; ) {
|
|
142017
|
+
signal?.throwIfAborted();
|
|
142018
|
+
const closedBeforeRead = log.closed();
|
|
142019
|
+
let detach = () => void 0;
|
|
142020
|
+
const woken = new Promise((resolve3) => {
|
|
142021
|
+
detach = log.onAppend(resolve3);
|
|
142022
|
+
});
|
|
142023
|
+
try {
|
|
142024
|
+
const read = log.read({ since: cursor3, ...session === void 0 ? {} : { session } });
|
|
142025
|
+
if (read.status === "expired") {
|
|
142026
|
+
throw new RcSessionEventCursorExpiredError(read.message, read.head);
|
|
142027
|
+
}
|
|
142028
|
+
if (read.events.length === 0) {
|
|
142029
|
+
cursor3 = read.cursor;
|
|
142030
|
+
if (closedBeforeRead) {
|
|
142031
|
+
return;
|
|
142032
|
+
}
|
|
142033
|
+
await Promise.race([woken, aborted2]);
|
|
142034
|
+
continue;
|
|
142035
|
+
}
|
|
142036
|
+
for (const event of read.events) {
|
|
142037
|
+
yield event;
|
|
142038
|
+
cursor3 = event.cursor;
|
|
142039
|
+
}
|
|
142040
|
+
cursor3 = read.cursor;
|
|
142041
|
+
} finally {
|
|
142042
|
+
detach();
|
|
142043
|
+
}
|
|
142044
|
+
}
|
|
142045
|
+
} finally {
|
|
142046
|
+
signal?.removeEventListener("abort", onAbort);
|
|
142047
|
+
}
|
|
142048
|
+
}
|
|
142049
|
+
|
|
142050
|
+
// src/frontdoor/rcEventLogApi.ts
|
|
142051
|
+
var RC_API_TAG2 = "remote-control";
|
|
142052
|
+
var CURSOR_EXPIRED_CODE = "GONE";
|
|
142053
|
+
async function* sseOf(follower) {
|
|
142054
|
+
try {
|
|
142055
|
+
for await (const event of follower) {
|
|
142056
|
+
yield withEventMeta2(event, { id: event.cursor });
|
|
142057
|
+
}
|
|
142058
|
+
} catch (error63) {
|
|
142059
|
+
if (error63 instanceof RcSessionEventCursorExpiredError) {
|
|
142060
|
+
throw new ORPCError(CURSOR_EXPIRED_CODE, { message: error63.message, data: { head: error63.head } });
|
|
142061
|
+
}
|
|
142062
|
+
throw error63;
|
|
142063
|
+
}
|
|
142064
|
+
}
|
|
142065
|
+
function createRcSessionEventsApiRouter(deps) {
|
|
142066
|
+
const authed = doorApiAuth(deps.expectedToken);
|
|
142067
|
+
return {
|
|
142068
|
+
rcSessions: {
|
|
142069
|
+
events: authed.meta(openapi({ method: "GET", path: "/rest/rc/session-events", summary: "Stream every observed session's state transitions, pending requests and endings (SSE), resumable by cursor", tags: [RC_API_TAG2] })).input(RcSessionEventsStreamInputSchema).output(asyncIteratorObject(RcSessionEventSchema)).handler(({ input: input2, signal, lastEventId }) => sseOf(followRcSessionEvents(deps.sessionEvents, { since: lastEventId ?? input2.since, session: input2.session }, signal))),
|
|
142070
|
+
eventsPage: authed.meta(
|
|
142071
|
+
openapi({
|
|
142072
|
+
method: "POST",
|
|
142073
|
+
path: "/rest/rc/session-events/page",
|
|
142074
|
+
summary: "Read every observed session's state transitions, pending requests and endings after a cursor, one page at a time",
|
|
142075
|
+
tags: [RC_API_TAG2],
|
|
142076
|
+
// A POST because the page size is a number a query string cannot type, but the answer changes nothing.
|
|
142077
|
+
spec: (current) => ({ ...current, [READ_ONLY_OPERATION_EXTENSION]: true })
|
|
142078
|
+
})
|
|
142079
|
+
).input(RcSessionEventsPageInputSchema).output(RcSessionEventsReadOutputSchema).handler(({ input: input2 }) => deps.sessionEvents.read(input2))
|
|
142080
|
+
}
|
|
142081
|
+
};
|
|
142082
|
+
}
|
|
142083
|
+
|
|
142084
|
+
// src/frontdoor/controlApi.ts
|
|
142085
|
+
var USAGE_API_TAG = "usage";
|
|
142086
|
+
var FRONTDOOR_API_TAG2 = "frontdoor";
|
|
142087
|
+
var CHECK_API_TAG = "check";
|
|
142088
|
+
var DOCTOR_API_TAG = "doctor";
|
|
142089
|
+
var POOL_API_TAG = "pool";
|
|
142090
|
+
function createControlApiRouter(deps) {
|
|
142091
|
+
const authed = doorApiAuth(deps.expectedToken);
|
|
142092
|
+
return {
|
|
142093
|
+
usage: {
|
|
142094
|
+
list: authed.meta(openapi({ method: "GET", path: "/rest/usage/snapshots", summary: "List every identity's usage snapshot", tags: [USAGE_API_TAG] })).output(UsageListOutputSchema).handler(() => ({ snapshots: deps.usageSnapshots() })),
|
|
142095
|
+
resets: authed.meta(openapi({ method: "GET", path: "/rest/usage/resets", summary: "List every recorded quota window with when it resets", tags: [USAGE_API_TAG] })).output(ResetScheduleSchema).handler(() => collectResets(deps.usageSnapshots(), deps.now())),
|
|
142096
|
+
effectiveWindow: authed.meta(openapi({ method: "GET", path: "/rest/usage/windows", summary: "Read one identity's effective quota windows", tags: [USAGE_API_TAG] })).input(UsageWindowsInputSchema).output(UsageWindowsOutputSchema).handler(({ input: input2 }) => {
|
|
142097
|
+
const snapshot = deps.usageSnapshotOf(input2.identity);
|
|
142098
|
+
if (snapshot === void 0) {
|
|
142099
|
+
throw new ORPCError("NOT_FOUND", { message: `identity ${input2.identity} has no usage snapshot yet, so no quota window has been observed for it` });
|
|
142100
|
+
}
|
|
142101
|
+
const provider = input2.provider ?? ANTHROPIC_PROVIDER;
|
|
142102
|
+
const rateLimit = snapshot.providers[provider]?.rateLimit;
|
|
142103
|
+
const unified = rateLimit?.unified;
|
|
142104
|
+
const now = deps.now();
|
|
142105
|
+
return {
|
|
142106
|
+
identity: snapshot.identity,
|
|
142107
|
+
provider,
|
|
142108
|
+
...rateLimit === void 0 ? {} : { observedAt: rateLimit.observedAt },
|
|
142109
|
+
...unified?.fiveHour === void 0 ? {} : { fiveHour: effectiveWindow(unified.fiveHour, now) },
|
|
142110
|
+
...unified?.sevenDay === void 0 ? {} : { sevenDay: effectiveWindow(unified.sevenDay, now) }
|
|
142111
|
+
};
|
|
142112
|
+
}),
|
|
142113
|
+
live: authed.meta(openapi({ method: "GET", path: "/rest/usage/live", summary: "Read the live rate-limit observations the event backbone files", tags: [USAGE_API_TAG] })).input(RcSessionQuerySchema).output(UsageLiveOutputSchema).handler(({ input: input2 }) => {
|
|
142114
|
+
const sessions = deps.liveRateLimits(input2.session);
|
|
142115
|
+
if (input2.session !== void 0 && sessions.length === 0) {
|
|
142116
|
+
if (deps.list().some((session) => session.id === input2.session)) {
|
|
142117
|
+
throw new ORPCError("NOT_FOUND", { message: `session ${input2.session} has filed no rate_limit_event on its stream yet: the worker emits one only once a turn has completed, so retry after this session's next turn` });
|
|
142118
|
+
}
|
|
142119
|
+
throw new ORPCError("NOT_FOUND", { message: rcSessionNotObservedMessage(input2.session) });
|
|
142120
|
+
}
|
|
142121
|
+
return { latest: deps.latestRateLimit(), sessions };
|
|
142122
|
+
})
|
|
142123
|
+
},
|
|
142124
|
+
frontdoor: {
|
|
142125
|
+
status: authed.meta(openapi({ method: "GET", path: "/rest/frontdoor/status", summary: "Read the front door's status", tags: [FRONTDOOR_API_TAG2] })).output(FrontDoorStatusOutputSchema).handler(() => deps.frontDoorStatus()),
|
|
142126
|
+
sessions: authed.meta(openapi({ method: "GET", path: "/rest/frontdoor/sessions", summary: "Read the front door's session registry", tags: [FRONTDOOR_API_TAG2] })).output(FrontDoorSessionsOutputSchema).handler(() => ({ sessions: deps.frontDoorStatus().sessions }))
|
|
142127
|
+
},
|
|
142128
|
+
check: {
|
|
142129
|
+
// The report's own JSON shape is the contract (the same one `check --json` prints and `checkReportSchema.ts` defines), so the procedure returns exactly that conversion.
|
|
142130
|
+
run: authed.meta(openapi({ method: "GET", path: "/rest/check", summary: "Run the check report for one directory", tags: [CHECK_API_TAG] })).input(CheckRunInputSchema).output(CheckReportJsonSchema).handler(({ input: input2 }) => checkReportToJson(deps.checkReport(input2.path, input2.identity)))
|
|
142131
|
+
},
|
|
142132
|
+
doctor: {
|
|
142133
|
+
run: authed.meta(openapi({ method: "GET", path: "/rest/doctor", summary: "Run the doctor report", tags: [DOCTOR_API_TAG] })).output(DoctorRunOutputSchema).handler(() => deps.doctorReport())
|
|
142134
|
+
},
|
|
142135
|
+
pool: {
|
|
142136
|
+
pick: authed.meta(openapi({ method: "GET", path: "/rest/pool/pick", summary: "Rank one pool exactly as a launch from a directory would right now", tags: [POOL_API_TAG] })).input(PoolPickInputSchema).output(PoolPickReportSchema).handler(({ input: input2 }) => {
|
|
142137
|
+
const report = deps.poolPick(input2.pool, input2.path);
|
|
142138
|
+
if (report === void 0) {
|
|
142139
|
+
const live = deps.poolNames();
|
|
142140
|
+
throw new ORPCError("NOT_FOUND", {
|
|
142141
|
+
message: live.length === 0 ? `no pools are configured, so none is named ${input2.pool}` : `no pool is named ${input2.pool}; the live pools are ${live.map((name) => `"${name}"`).join(", ")}`
|
|
142142
|
+
});
|
|
142143
|
+
}
|
|
142144
|
+
return report;
|
|
142145
|
+
})
|
|
142146
|
+
}
|
|
142147
|
+
};
|
|
142148
|
+
}
|
|
142149
|
+
function createDoorApiRouter(deps) {
|
|
142150
|
+
const control = createControlApiRouter(deps);
|
|
142151
|
+
const lifecycle = createLifecycleApiRouter(deps);
|
|
142152
|
+
return { ...createRcApiRouter(deps), ...createRcSessionEventsApiRouter(deps), ...control, ...lifecycle, ...createConfigApiRouter(deps), ...createCodexApiRouter(deps), ...createLaunchApiRouter(deps), ...createAgentTreesApiRouter(deps), ...createEventsApiRouter(deps), frontdoor: { ...control.frontdoor, ...lifecycle.frontdoor } };
|
|
142153
|
+
}
|
|
142154
|
+
function createDoorApiNodeHandler(deps) {
|
|
142155
|
+
return doorApiNodeHandlerOf(createDoorApiRouter(deps), deps.expectedToken);
|
|
142156
|
+
}
|
|
142157
|
+
function frontDoorApiClient(port, ca2, token) {
|
|
142158
|
+
return createORPCClient(frontDoorApiLink(port, ca2, token));
|
|
142159
|
+
}
|
|
142160
|
+
|
|
142161
|
+
// src/frontdoor/doorHealthEvents.ts
|
|
142162
|
+
function createDoorHealthPublisher(hub, now, pid) {
|
|
142163
|
+
const publisher = hub.publisher(DOOR_HEALTH_EVENT_SOURCE);
|
|
142164
|
+
return {
|
|
142165
|
+
generation: (ports) => {
|
|
142166
|
+
publisher.publish({ kind: "generation", pid, providerPort: ports.providerPort, connectPort: ports.connectPort, directPort: ports.directPort, observedAt: now() });
|
|
142167
|
+
},
|
|
142168
|
+
listenerFailed: (listener, message) => {
|
|
142169
|
+
publisher.publish({ kind: "listenerFailed", pid, listener, message, observedAt: now() });
|
|
142170
|
+
},
|
|
142171
|
+
idleShutdown: () => {
|
|
142172
|
+
publisher.publish({ kind: "idleShutdown", pid, observedAt: now() });
|
|
142173
|
+
},
|
|
142174
|
+
binaryTurnover: () => {
|
|
142175
|
+
publisher.publish({ kind: "binaryTurnover", pid, observedAt: now() });
|
|
142176
|
+
},
|
|
142177
|
+
superseded: (ownerPid) => {
|
|
142178
|
+
publisher.publish({ kind: "superseded", pid, ownerPid, observedAt: now() });
|
|
142179
|
+
},
|
|
142180
|
+
drained: () => {
|
|
142181
|
+
publisher.publish({ kind: "drained", pid, observedAt: now() });
|
|
142182
|
+
}
|
|
142183
|
+
};
|
|
142184
|
+
}
|
|
142185
|
+
|
|
141868
142186
|
// src/frontdoor/quotaExpiringEvents.ts
|
|
141869
142187
|
init_pick();
|
|
141870
142188
|
var FINAL_SPAN_DENOMINATOR = 30;
|
|
@@ -143348,8 +143666,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
143348
143666
|
request7.body.resume();
|
|
143349
143667
|
return;
|
|
143350
143668
|
}
|
|
143351
|
-
const
|
|
143352
|
-
const translated = { method: request7.method, path:
|
|
143669
|
+
const path99 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
143670
|
+
const translated = { method: request7.method, path: path99, body, signal: request7.signal };
|
|
143353
143671
|
const routed = await route(translated);
|
|
143354
143672
|
if (request7.signal.aborted) {
|
|
143355
143673
|
return;
|
|
@@ -143583,9 +143901,9 @@ function descendExpanded(root, value3, key) {
|
|
|
143583
143901
|
}
|
|
143584
143902
|
}
|
|
143585
143903
|
function relaxRejectedRecursiveProperty(request7, body) {
|
|
143586
|
-
const
|
|
143587
|
-
if (
|
|
143588
|
-
const propertyIndices =
|
|
143904
|
+
const path99 = rejectedPath(body);
|
|
143905
|
+
if (path99 === void 0) return void 0;
|
|
143906
|
+
const propertyIndices = path99.flatMap((part, index) => part === "properties" && path99[index + 1] !== void 0 ? [index] : []).reverse();
|
|
143589
143907
|
if (propertyIndices.length === 0) return void 0;
|
|
143590
143908
|
const copy2 = structuredClone(request7);
|
|
143591
143909
|
let changed = false;
|
|
@@ -143594,14 +143912,14 @@ function relaxRejectedRecursiveProperty(request7, body) {
|
|
|
143594
143912
|
const schema = declaration.parametersJsonSchema;
|
|
143595
143913
|
if (schema === void 0) continue;
|
|
143596
143914
|
let leaf = schema;
|
|
143597
|
-
for (const part of
|
|
143915
|
+
for (const part of path99) leaf = descendExpanded(schema, leaf, part);
|
|
143598
143916
|
if (!record2(leaf) || typeof leaf.$ref !== "string") continue;
|
|
143599
143917
|
let repairedProperty = false;
|
|
143600
143918
|
for (const propertyIndex of propertyIndices) {
|
|
143601
|
-
const name =
|
|
143919
|
+
const name = path99[propertyIndex + 1];
|
|
143602
143920
|
if (name === void 0) continue;
|
|
143603
143921
|
let owner = schema;
|
|
143604
|
-
for (const part of
|
|
143922
|
+
for (const part of path99.slice(0, propertyIndex)) owner = descendExpanded(schema, owner, part);
|
|
143605
143923
|
if (!record2(owner) || !Array.isArray(owner.required) || !owner.required.includes(name) || !record2(owner.properties)) continue;
|
|
143606
143924
|
const property = owner.properties[name];
|
|
143607
143925
|
if (!record2(property)) continue;
|
|
@@ -143615,8 +143933,8 @@ function relaxRejectedRecursiveProperty(request7, body) {
|
|
|
143615
143933
|
}
|
|
143616
143934
|
if (!repairedProperty) {
|
|
143617
143935
|
let parent = schema;
|
|
143618
|
-
for (const part of
|
|
143619
|
-
const key =
|
|
143936
|
+
for (const part of path99.slice(0, -1)) parent = descendExpanded(schema, parent, part);
|
|
143937
|
+
const key = path99.at(-1);
|
|
143620
143938
|
const truncated = { description: "Recursive value: the original tool schema validates this value." };
|
|
143621
143939
|
if (record2(parent) && key !== void 0 && Object.hasOwn(parent, key)) {
|
|
143622
143940
|
parent[key] = truncated;
|
|
@@ -144108,8 +144426,8 @@ function createAntigravityRouteMount(ports, upstreamBase, provider) {
|
|
|
144108
144426
|
request7.body.resume();
|
|
144109
144427
|
return;
|
|
144110
144428
|
}
|
|
144111
|
-
const
|
|
144112
|
-
const translated = { method: request7.method, path:
|
|
144429
|
+
const path99 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
144430
|
+
const translated = { method: request7.method, path: path99, body, signal: request7.signal };
|
|
144113
144431
|
const routed = await route(translated);
|
|
144114
144432
|
if (request7.signal.aborted) {
|
|
144115
144433
|
return;
|
|
@@ -144153,7 +144471,7 @@ function createPassthroughRoute(name, target) {
|
|
|
144153
144471
|
headroomUpstream: target.headroomUpstream,
|
|
144154
144472
|
serve: async (request7, response) => {
|
|
144155
144473
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
144156
|
-
const
|
|
144474
|
+
const path99 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
144157
144475
|
const headers = forwardableHeaders(request7.headers);
|
|
144158
144476
|
delete headers.host;
|
|
144159
144477
|
await new Promise((resolve3) => {
|
|
@@ -144161,7 +144479,7 @@ function createPassthroughRoute(name, target) {
|
|
|
144161
144479
|
host: base.hostname,
|
|
144162
144480
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
144163
144481
|
method: request7.method,
|
|
144164
|
-
path: `${basePath}${
|
|
144482
|
+
path: `${basePath}${path99}${incoming.search}`,
|
|
144165
144483
|
headers,
|
|
144166
144484
|
agent
|
|
144167
144485
|
};
|
|
@@ -144367,13 +144685,13 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
144367
144685
|
}
|
|
144368
144686
|
|
|
144369
144687
|
// src/frontdoor/providerRoute.ts
|
|
144370
|
-
var isRcSelfHostPath = (
|
|
144688
|
+
var isRcSelfHostPath = (path99) => path99 === "/v1/code/sessions" || path99.startsWith("/v1/code/sessions/") || path99 === "/v1/sessions" || path99.startsWith("/v1/sessions/");
|
|
144371
144689
|
function scopeSessionProviderPath(request7) {
|
|
144372
144690
|
if (request7.session.provider === void 0) {
|
|
144373
144691
|
return request7;
|
|
144374
144692
|
}
|
|
144375
|
-
const
|
|
144376
|
-
if (!
|
|
144693
|
+
const path99 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
144694
|
+
if (!path99.startsWith("/v1/") || isRcSelfHostPath(path99)) {
|
|
144377
144695
|
return request7;
|
|
144378
144696
|
}
|
|
144379
144697
|
return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
|
|
@@ -144508,13 +144826,13 @@ function createProviderRouteResolver(deps) {
|
|
|
144508
144826
|
return route;
|
|
144509
144827
|
};
|
|
144510
144828
|
const resolve3 = (request7) => {
|
|
144511
|
-
const
|
|
144512
|
-
const scoped = parseProviderPath(
|
|
144829
|
+
const path99 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
144830
|
+
const scoped = parseProviderPath(path99);
|
|
144513
144831
|
if (scoped === void 0) {
|
|
144514
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
144832
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path99)) {
|
|
144515
144833
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
144516
144834
|
}
|
|
144517
|
-
return
|
|
144835
|
+
return path99.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path99}` };
|
|
144518
144836
|
}
|
|
144519
144837
|
const { provider } = scoped;
|
|
144520
144838
|
let definition;
|
|
@@ -144610,8 +144928,8 @@ function createProviderRouteResolver(deps) {
|
|
|
144610
144928
|
let modelChoice;
|
|
144611
144929
|
const visited = /* @__PURE__ */ new Set();
|
|
144612
144930
|
for (; ; ) {
|
|
144613
|
-
const
|
|
144614
|
-
const scoped = parseProviderPath(
|
|
144931
|
+
const path99 = new URL(current.url, "http://127.0.0.1").pathname;
|
|
144932
|
+
const scoped = parseProviderPath(path99);
|
|
144615
144933
|
const providerName = scoped?.provider ?? current.session.provider;
|
|
144616
144934
|
if (providerName !== void 0 && visited.has(providerName)) {
|
|
144617
144935
|
return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
|
|
@@ -144626,7 +144944,7 @@ function createProviderRouteResolver(deps) {
|
|
|
144626
144944
|
} catch {
|
|
144627
144945
|
routes = void 0;
|
|
144628
144946
|
}
|
|
144629
|
-
const resolvesNames = !nameResolved && !isRcSelfHostPath(
|
|
144947
|
+
const resolvesNames = !nameResolved && !isRcSelfHostPath(path99);
|
|
144630
144948
|
if (resolvesNames) {
|
|
144631
144949
|
const scan2 = await scanRequestHead(current, true);
|
|
144632
144950
|
if (scan2.replayed === void 0) {
|
|
@@ -144665,7 +144983,7 @@ function createProviderRouteResolver(deps) {
|
|
|
144665
144983
|
}
|
|
144666
144984
|
if (routed.provider !== providerName) {
|
|
144667
144985
|
const scopedPrefix = providerName === void 0 ? void 0 : `${PROVIDER_PATH_PREFIX}${encodeURIComponent(providerName)}`;
|
|
144668
|
-
const rest2 = scopedPrefix !== void 0 &&
|
|
144986
|
+
const rest2 = scopedPrefix !== void 0 && path99.startsWith(scopedPrefix) ? path99.slice(scopedPrefix.length) : path99;
|
|
144669
144987
|
const query2 = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
144670
144988
|
const carried = replay;
|
|
144671
144989
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(routed.provider)}${rest2}${query2}`, body: carried.body, headers: carried.headers };
|
|
@@ -144719,7 +145037,7 @@ function createProviderRouteResolver(deps) {
|
|
|
144719
145037
|
const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
144720
145038
|
replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
|
|
144721
145039
|
}
|
|
144722
|
-
const rest = scoped === void 0 ?
|
|
145040
|
+
const rest = scoped === void 0 ? path99 : path99.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
|
|
144723
145041
|
const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
144724
145042
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
|
|
144725
145043
|
}
|
|
@@ -144988,6 +145306,107 @@ function readFrontDoorControlMaterial(fsPort, paths, purpose) {
|
|
|
144988
145306
|
}
|
|
144989
145307
|
return { port: state.port, ca: ca2, token };
|
|
144990
145308
|
}
|
|
145309
|
+
function frontDoorApiFromState(paths, fsPort = realFarmFs) {
|
|
145310
|
+
const { port, ca: ca2, token } = readFrontDoorControlMaterial(fsPort, paths, "its typed API");
|
|
145311
|
+
return frontDoorApiClient(port, ca2, token);
|
|
145312
|
+
}
|
|
145313
|
+
|
|
145314
|
+
// src/frontdoor/rcEventsCommand.ts
|
|
145315
|
+
init_commandDeps();
|
|
145316
|
+
init_cliError();
|
|
145317
|
+
function detailOf(event) {
|
|
145318
|
+
if (event.kind === "session-ended") {
|
|
145319
|
+
return event.reason;
|
|
145320
|
+
}
|
|
145321
|
+
if (event.kind === "worker-state") {
|
|
145322
|
+
return event.previous === void 0 ? event.state : `${event.previous} -> ${event.state}`;
|
|
145323
|
+
}
|
|
145324
|
+
if (event.kind === "pending-born") {
|
|
145325
|
+
return `${event.requestId} ${event.type}${event.summary === "" ? "" : ` ${event.summary}`}`;
|
|
145326
|
+
}
|
|
145327
|
+
if (event.kind === "pending-retired") {
|
|
145328
|
+
return `${event.requestId} ${event.reason}`;
|
|
145329
|
+
}
|
|
145330
|
+
return "";
|
|
145331
|
+
}
|
|
145332
|
+
function formatRcSessionEvent(event) {
|
|
145333
|
+
const detail = detailOf(event);
|
|
145334
|
+
return `${event.cursor} ${new Date(event.at).toISOString()} ${event.session} ${event.kind}${detail === "" ? "" : ` ${detail}`}`;
|
|
145335
|
+
}
|
|
145336
|
+
function expiredHeadOf(error63) {
|
|
145337
|
+
if (!(error63 instanceof ORPCError) || error63.code !== "GONE") {
|
|
145338
|
+
return void 0;
|
|
145339
|
+
}
|
|
145340
|
+
const data = error63.data;
|
|
145341
|
+
return typeof data === "object" && data !== null && "head" in data && typeof data.head === "string" ? data.head : void 0;
|
|
145342
|
+
}
|
|
145343
|
+
var RcSessionEventsStreamEndedError = class extends Error {
|
|
145344
|
+
lastCursor;
|
|
145345
|
+
constructor(cause, lastCursor) {
|
|
145346
|
+
super(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
145347
|
+
this.name = "RcSessionEventsStreamEndedError";
|
|
145348
|
+
this.lastCursor = lastCursor;
|
|
145349
|
+
}
|
|
145350
|
+
};
|
|
145351
|
+
async function printRcSessionEvents(events, options, write) {
|
|
145352
|
+
let last = options.since;
|
|
145353
|
+
try {
|
|
145354
|
+
for await (const event of events) {
|
|
145355
|
+
write(options.json ? JSON.stringify(event) : formatRcSessionEvent(event));
|
|
145356
|
+
last = event.cursor;
|
|
145357
|
+
}
|
|
145358
|
+
} catch (error63) {
|
|
145359
|
+
throw new RcSessionEventsStreamEndedError(error63, last);
|
|
145360
|
+
}
|
|
145361
|
+
return last;
|
|
145362
|
+
}
|
|
145363
|
+
function lastCursorOf(error63, since) {
|
|
145364
|
+
return error63 instanceof RcSessionEventsStreamEndedError ? error63.lastCursor : since;
|
|
145365
|
+
}
|
|
145366
|
+
function resumeHint(lastCursor) {
|
|
145367
|
+
return lastCursor === void 0 ? "no event was printed; follow afresh, or resume after the head `frontdoor rc events` names" : `resume with --since ${lastCursor}`;
|
|
145368
|
+
}
|
|
145369
|
+
function registerRcEventsCommand(rc, paths) {
|
|
145370
|
+
withExamples(
|
|
145371
|
+
rc.command("events").description(
|
|
145372
|
+
"Follow every observed Remote Control session at once: each session appearing or ending, each worker state change (idle, running, requires_action), and each pending control request's birth and retirement, every line tagged with its session and the cursor a later --since resumes after. A cursor the door no longer holds (evicted, or from a previous door) fails naming the head to resume after once `frontdoor rc status` has restated the present. It does not reconnect: when the stream ends or fails (a door restart above all, whose new generation would refuse the cursor anyway), or Ctrl-C leaves it, it names the last cursor printed. Read-only, until Ctrl-C leaves."
|
|
145373
|
+
).argument("[session]", "One cse_ session id, to follow that session alone; every observed session when omitted.").option("--all", "Follow every observed session: the explicit spelling of omitting the session.").option("--since <cursor>", "Resume after this cursor, replaying what was missed; only what happens next when omitted.").option("--json", "Print each event as one JSON line as it arrives.").action(async (session, options) => {
|
|
145374
|
+
if (options.all === true && session !== void 0) {
|
|
145375
|
+
throw new UsageError("name one session or pass --all, not both");
|
|
145376
|
+
}
|
|
145377
|
+
const client = frontDoorApiFromState(paths);
|
|
145378
|
+
const leave = new AbortController();
|
|
145379
|
+
const onInterrupt = () => {
|
|
145380
|
+
leave.abort();
|
|
145381
|
+
};
|
|
145382
|
+
process.once("SIGINT", onInterrupt);
|
|
145383
|
+
try {
|
|
145384
|
+
const stream = await client.rcSessions.events({ ...session === void 0 ? {} : { session }, ...options.since === void 0 ? {} : { since: options.since } }, { signal: leave.signal });
|
|
145385
|
+
const last = await printRcSessionEvents(stream, { json: options.json === true, since: options.since }, (line) => {
|
|
145386
|
+
console.log(line);
|
|
145387
|
+
});
|
|
145388
|
+
console.error(`agent-shim: the event stream ended; ${resumeHint(last)}`);
|
|
145389
|
+
} catch (error63) {
|
|
145390
|
+
if (leave.signal.aborted) {
|
|
145391
|
+
console.error(`agent-shim: left the event stream; ${resumeHint(lastCursorOf(error63, options.since))}`);
|
|
145392
|
+
return;
|
|
145393
|
+
}
|
|
145394
|
+
const cause = error63 instanceof RcSessionEventsStreamEndedError ? error63.cause : error63;
|
|
145395
|
+
const head = expiredHeadOf(cause);
|
|
145396
|
+
if (head !== void 0 && cause instanceof Error) {
|
|
145397
|
+
throw new Error(`${cause.message} (resume with --since ${head})`, { cause: error63 });
|
|
145398
|
+
}
|
|
145399
|
+
if (error63 instanceof RcSessionEventsStreamEndedError) {
|
|
145400
|
+
throw new Error(`${error63.message}; ${resumeHint(error63.lastCursor)}`, { cause: error63 });
|
|
145401
|
+
}
|
|
145402
|
+
throw error63;
|
|
145403
|
+
} finally {
|
|
145404
|
+
process.off("SIGINT", onInterrupt);
|
|
145405
|
+
}
|
|
145406
|
+
}),
|
|
145407
|
+
["agent-shim frontdoor rc events --all", "agent-shim frontdoor rc events --all --since 00000000-0000-4000-8000-000000000000.42 --json"]
|
|
145408
|
+
);
|
|
145409
|
+
}
|
|
144991
145410
|
|
|
144992
145411
|
// src/frontdoor/rcLiveUsage.ts
|
|
144993
145412
|
var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
|
|
@@ -145553,6 +145972,7 @@ function registerRcCommand(frontdoor, paths) {
|
|
|
145553
145972
|
}),
|
|
145554
145973
|
["agent-shim frontdoor rc watch", "agent-shim frontdoor rc watch cse_00000000-0000-4000-8000-000000000000 --json"]
|
|
145555
145974
|
);
|
|
145975
|
+
registerRcEventsCommand(rc, paths);
|
|
145556
145976
|
const selfhost = withExamples(
|
|
145557
145977
|
rc.command("selfhost").description("Mint the local credential behind the door's self-hosted Remote Control surface: the opt-in mode (AGENT_SHIM_FRONTDOOR_RC_SELF_HOST=1 in the door's environment) where the door serves the CCR surface itself and a session activates Remote Control with no Anthropic credential anywhere."),
|
|
145558
145978
|
["agent-shim frontdoor rc selfhost mint rig"]
|
|
@@ -148179,7 +148599,8 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
148179
148599
|
log
|
|
148180
148600
|
}) : void 0;
|
|
148181
148601
|
const rcCredentialStore = createRcCredentialStore(realFarmFs, paths.frontdoorRcCredentialsDir);
|
|
148182
|
-
const
|
|
148602
|
+
const rcSessionEvents = createRcSessionEventLog({ generation: (0, import_node_crypto29.randomUUID)(), capacity: RC_SESSION_EVENT_LOG_CAPACITY });
|
|
148603
|
+
const rcTracker = createRcSessionTracker({ now: () => Date.now(), idleMs: RC_IDLE_EXPIRY_MS, credentialStore: rcCredentialStore, onTransition: rcSessionEvents.append, onClose: rcSessionEvents.close });
|
|
148183
148604
|
const doorEvents = createDoorEventHub();
|
|
148184
148605
|
const usagePublisher = doorEvents.publisher(USAGE_EVENT_SOURCE);
|
|
148185
148606
|
const usageEventNames = createIdentityNameReader(paths);
|
|
@@ -148509,6 +148930,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
148509
148930
|
mcpOAuthCallbackUrl: rcMcpOAuthCallbackUrl,
|
|
148510
148931
|
teleport: rcTeleport,
|
|
148511
148932
|
fanout: rcFanout,
|
|
148933
|
+
sessionEvents: rcSessionEvents,
|
|
148512
148934
|
...controlDeps,
|
|
148513
148935
|
...lifecycleAndCodexDeps,
|
|
148514
148936
|
keychain: doorKeychainProbe(process.platform),
|
|
@@ -148614,7 +149036,11 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
148614
149036
|
});
|
|
148615
149037
|
return { port: handle.port, listening: server, close: handle.close, drain: handle.drain };
|
|
148616
149038
|
},
|
|
148617
|
-
|
|
149039
|
+
// The tracker closes with the hub: its close ends every session-events follower, so a supervisor's open stream ends with the door instead of holding a retiring door's drain open for as long as the subscriber stays connected.
|
|
149040
|
+
closeRcStreamHub: () => {
|
|
149041
|
+
rcHub.close();
|
|
149042
|
+
rcTracker.close();
|
|
149043
|
+
},
|
|
148618
149044
|
respawnChain: {
|
|
148619
149045
|
generation: respawnGeneration,
|
|
148620
149046
|
startNext: async () => {
|
|
@@ -150706,15 +151132,15 @@ function parseNumstat(output2) {
|
|
|
150706
151132
|
if (addedText === void 0 || deletedText === void 0 || pathText === void 0) {
|
|
150707
151133
|
continue;
|
|
150708
151134
|
}
|
|
150709
|
-
const
|
|
151135
|
+
const path99 = pathText === "" ? fields[index + 2] : pathText;
|
|
150710
151136
|
if (pathText === "") {
|
|
150711
151137
|
index += 2;
|
|
150712
151138
|
}
|
|
150713
151139
|
const lines = { added: Number(addedText), deleted: Number(deletedText) };
|
|
150714
|
-
if (
|
|
151140
|
+
if (path99 !== void 0 && Number.isInteger(lines.added) && Number.isInteger(lines.deleted)) {
|
|
150715
151141
|
added += lines.added;
|
|
150716
151142
|
deleted += lines.deleted;
|
|
150717
|
-
byPath.set(
|
|
151143
|
+
byPath.set(path99, lines);
|
|
150718
151144
|
}
|
|
150719
151145
|
}
|
|
150720
151146
|
return { total: { added, deleted }, byPath };
|
|
@@ -151753,11 +152179,11 @@ function targetText(tool, columns) {
|
|
|
151753
152179
|
if (!FILE_TOOLS.includes(tool.name)) {
|
|
151754
152180
|
return truncateWithEllipsis(target, room, ELLIPSIS);
|
|
151755
152181
|
}
|
|
151756
|
-
const
|
|
151757
|
-
if (visibleLength(
|
|
151758
|
-
return
|
|
152182
|
+
const path99 = target.replaceAll("\\", "/");
|
|
152183
|
+
if (visibleLength(path99) <= room) {
|
|
152184
|
+
return path99;
|
|
151759
152185
|
}
|
|
151760
|
-
const file2 =
|
|
152186
|
+
const file2 = path99.split("/").pop() ?? path99;
|
|
151761
152187
|
return visibleLength(DIRECTORY_ELLIPSIS) + visibleLength(file2) > room ? truncateWithEllipsis(file2, room, FILE_ELLIPSIS) : `${DIRECTORY_ELLIPSIS}${file2}`;
|
|
151762
152188
|
}
|
|
151763
152189
|
function finishedByKind(tools) {
|
|
@@ -155514,8 +155940,8 @@ function getErrorMap2() {
|
|
|
155514
155940
|
|
|
155515
155941
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v3/helpers/parseUtil.js
|
|
155516
155942
|
var makeIssue = (params) => {
|
|
155517
|
-
const { data, path:
|
|
155518
|
-
const fullPath = [...
|
|
155943
|
+
const { data, path: path99, errorMaps, issueData } = params;
|
|
155944
|
+
const fullPath = [...path99, ...issueData.path || []];
|
|
155519
155945
|
const fullIssue = {
|
|
155520
155946
|
...issueData,
|
|
155521
155947
|
path: fullPath
|
|
@@ -155630,11 +156056,11 @@ var errorUtil;
|
|
|
155630
156056
|
|
|
155631
156057
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v3/types.js
|
|
155632
156058
|
var ParseInputLazyPath = class {
|
|
155633
|
-
constructor(parent, value3,
|
|
156059
|
+
constructor(parent, value3, path99, key) {
|
|
155634
156060
|
this._cachedPath = [];
|
|
155635
156061
|
this.parent = parent;
|
|
155636
156062
|
this.data = value3;
|
|
155637
|
-
this._path =
|
|
156063
|
+
this._path = path99;
|
|
155638
156064
|
this._key = key;
|
|
155639
156065
|
}
|
|
155640
156066
|
get path() {
|
|
@@ -159197,11 +159623,11 @@ function normalizeObjectSchema(schema) {
|
|
|
159197
159623
|
}
|
|
159198
159624
|
return void 0;
|
|
159199
159625
|
}
|
|
159200
|
-
function getDotPath(
|
|
159201
|
-
if (
|
|
159626
|
+
function getDotPath(path99) {
|
|
159627
|
+
if (path99.length === 0) {
|
|
159202
159628
|
return "object root";
|
|
159203
159629
|
}
|
|
159204
|
-
return
|
|
159630
|
+
return path99.reduce((acc, seg, index) => {
|
|
159205
159631
|
if (index === 0) {
|
|
159206
159632
|
return String(seg);
|
|
159207
159633
|
}
|
|
@@ -164322,6 +164748,9 @@ init_lock();
|
|
|
164322
164748
|
function prefixOf(sessionId) {
|
|
164323
164749
|
return `${sessionId}.hook.`;
|
|
164324
164750
|
}
|
|
164751
|
+
function isSessionStateFile(sessionId, stateFile, filename) {
|
|
164752
|
+
return filename === stateFile || filename.startsWith(prefixOf(sessionId)) && filename.endsWith(".json");
|
|
164753
|
+
}
|
|
164325
164754
|
function hooksPending(fs36, paths, pool, sessionId) {
|
|
164326
164755
|
return fs36.readdir(stateDirOf(paths, pool)).some((name) => name.startsWith(prefixOf(sessionId)) && name.endsWith(".json"));
|
|
164327
164756
|
}
|
|
@@ -166853,7 +167282,7 @@ async function realRefresher(params) {
|
|
|
166853
167282
|
// src/supervise/launch.ts
|
|
166854
167283
|
var import_node_crypto35 = require("node:crypto");
|
|
166855
167284
|
var import_node_fs40 = require("node:fs");
|
|
166856
|
-
var
|
|
167285
|
+
var import_node_path97 = __toESM(require("node:path"), 1);
|
|
166857
167286
|
var import_promises21 = require("node:stream/promises");
|
|
166858
167287
|
init_package();
|
|
166859
167288
|
init_claudeSession();
|
|
@@ -167694,6 +168123,52 @@ async function supervise(deps, first) {
|
|
|
167694
168123
|
}
|
|
167695
168124
|
}
|
|
167696
168125
|
|
|
168126
|
+
// src/supervise/watchSession.ts
|
|
168127
|
+
var import_node_path96 = __toESM(require("node:path"), 1);
|
|
168128
|
+
function watchSessionFiles(params) {
|
|
168129
|
+
const { paths, pool, sessionId, fs: fs36, log, watch } = params;
|
|
168130
|
+
const stateFile = import_node_path96.default.basename(sessionStatePath(paths, pool, sessionId));
|
|
168131
|
+
return (onChange) => {
|
|
168132
|
+
let watchedDir;
|
|
168133
|
+
let transcriptName;
|
|
168134
|
+
let stopTranscripts;
|
|
168135
|
+
let transcriptWarning = "";
|
|
168136
|
+
const followTranscript = () => {
|
|
168137
|
+
const transcript = readSessionState(fs36, paths, pool, sessionId)?.transcriptPath;
|
|
168138
|
+
const directory = transcript === void 0 ? void 0 : import_node_path96.default.dirname(transcript);
|
|
168139
|
+
transcriptName = transcript === void 0 ? void 0 : import_node_path96.default.basename(transcript);
|
|
168140
|
+
if (!params.watchTranscript || directory === watchedDir) {
|
|
168141
|
+
return;
|
|
168142
|
+
}
|
|
168143
|
+
stopTranscripts?.();
|
|
168144
|
+
watchedDir = void 0;
|
|
168145
|
+
stopTranscripts = void 0;
|
|
168146
|
+
if (directory !== void 0 && fs36.lstat(directory) !== void 0) {
|
|
168147
|
+
try {
|
|
168148
|
+
stopTranscripts = watch.existingDirectory(directory, (filename) => filename === transcriptName, "the session transcript", log)(onChange);
|
|
168149
|
+
watchedDir = directory;
|
|
168150
|
+
transcriptWarning = "";
|
|
168151
|
+
} catch (error63) {
|
|
168152
|
+
const warning = `agent-shim: could not watch the session transcript: ${error63 instanceof Error ? error63.message : String(error63)}`;
|
|
168153
|
+
if (warning !== transcriptWarning) {
|
|
168154
|
+
transcriptWarning = warning;
|
|
168155
|
+
log.warn(warning);
|
|
168156
|
+
}
|
|
168157
|
+
}
|
|
168158
|
+
}
|
|
168159
|
+
};
|
|
168160
|
+
const stopState = watch.directory(stateDirOf(paths, pool), (filename) => isSessionStateFile(sessionId, stateFile, filename), "the session's state", log)(() => {
|
|
168161
|
+
followTranscript();
|
|
168162
|
+
onChange();
|
|
168163
|
+
});
|
|
168164
|
+
followTranscript();
|
|
168165
|
+
return () => {
|
|
168166
|
+
stopState();
|
|
168167
|
+
stopTranscripts?.();
|
|
168168
|
+
};
|
|
168169
|
+
};
|
|
168170
|
+
}
|
|
168171
|
+
|
|
167697
168172
|
// src/supervise/launch.ts
|
|
167698
168173
|
function supervisesLaunch(pool, passthrough) {
|
|
167699
168174
|
return pool?.resumeOnLimit === true && !isClaudeSubcommand(passthrough);
|
|
@@ -167730,7 +168205,7 @@ async function runSupervised(params) {
|
|
|
167730
168205
|
const policy = params.pools[pool];
|
|
167731
168206
|
const markSettings = markHooksSettings(selfInvocation([]), paths.root, pool, first.sessionId);
|
|
167732
168207
|
const settingsArgs2 = [...params.extraFlags, ...params.passthrough];
|
|
167733
|
-
const settings2 = hasSettingsArgument(settingsArgs2) ? combineCallerSettings(settingsArgs2, markSettings, (name) => farm.fs.readFileUtf8(
|
|
168208
|
+
const settings2 = hasSettingsArgument(settingsArgs2) ? combineCallerSettings(settingsArgs2, markSettings, (name) => farm.fs.readFileUtf8(import_node_path97.default.resolve(farm.cwd, name))) : void 0;
|
|
167734
168209
|
const plugin = policy?.compactBeforeLimit === true ? stageNativeCompactionPlugin() : void 0;
|
|
167735
168210
|
if (policy?.compactBeforeLimit === true && plugin !== void 0) {
|
|
167736
168211
|
const baseCompaction = createCompactionDeps({
|
|
@@ -167803,43 +168278,12 @@ async function runSupervised(params) {
|
|
|
167803
168278
|
watchChanges: (identity, onChange) => {
|
|
167804
168279
|
const stopPlugin = plugin === void 0 ? void 0 : realWatchExistingDirectory(plugin.directory, (filename) => filename === "ready.json", "the compaction plugin", log)(onChange);
|
|
167805
168280
|
const stopSnapshot = realWatchDirectory(paths.usageSnapshotsDir, (filename) => filename === `${identity}.json`, `${identity}'s usage`, log)(onChange);
|
|
167806
|
-
|
|
167807
|
-
let stopTranscripts;
|
|
167808
|
-
let transcriptWarning = "";
|
|
167809
|
-
const watchTranscript = () => {
|
|
167810
|
-
const transcript = readSessionState(realFarmFs, paths, pool, first.sessionId)?.transcriptPath;
|
|
167811
|
-
const directory = transcript === void 0 ? void 0 : import_node_path96.default.dirname(transcript);
|
|
167812
|
-
if (compaction === void 0 || directory === watchedDir) {
|
|
167813
|
-
return;
|
|
167814
|
-
}
|
|
167815
|
-
stopTranscripts?.();
|
|
167816
|
-
watchedDir = void 0;
|
|
167817
|
-
stopTranscripts = void 0;
|
|
167818
|
-
if (directory !== void 0 && realFarmFs.lstat(directory) !== void 0) {
|
|
167819
|
-
try {
|
|
167820
|
-
stopTranscripts = realWatchExistingDirectory(directory, (filename) => filename.endsWith(".jsonl"), "the session transcripts", log)(onChange);
|
|
167821
|
-
watchedDir = directory;
|
|
167822
|
-
transcriptWarning = "";
|
|
167823
|
-
} catch (error63) {
|
|
167824
|
-
const warning = `agent-shim: could not watch the session transcripts: ${error63 instanceof Error ? error63.message : String(error63)}`;
|
|
167825
|
-
if (warning !== transcriptWarning) {
|
|
167826
|
-
transcriptWarning = warning;
|
|
167827
|
-
log.warn(warning);
|
|
167828
|
-
}
|
|
167829
|
-
}
|
|
167830
|
-
}
|
|
167831
|
-
};
|
|
167832
|
-
const stopState = realWatchDirectory(stateDirOf(paths, pool), (filename) => filename.endsWith(".json"), "the pool's sessions", log)(() => {
|
|
167833
|
-
watchTranscript();
|
|
167834
|
-
onChange();
|
|
167835
|
-
});
|
|
167836
|
-
watchTranscript();
|
|
168281
|
+
const stopSession = watchSessionFiles({ paths, pool, sessionId: first.sessionId, watchTranscript: compaction !== void 0, fs: realFarmFs, log, watch: { directory: realWatchDirectory, existingDirectory: realWatchExistingDirectory } })(onChange);
|
|
167837
168282
|
if (plugin !== void 0 && nativeCompactionReady(plugin)) queueMicrotask(onChange);
|
|
167838
168283
|
return () => {
|
|
167839
168284
|
stopPlugin?.();
|
|
167840
168285
|
stopSnapshot();
|
|
167841
|
-
|
|
167842
|
-
stopTranscripts?.();
|
|
168286
|
+
stopSession();
|
|
167843
168287
|
};
|
|
167844
168288
|
},
|
|
167845
168289
|
quotaHit: (identity, sessionId, sinceMs) => quotaHitOf(realFarmFs, paths, identity, sessionId, sinceMs, farm.now()),
|
|
@@ -168044,7 +168488,7 @@ async function runClaude(argvOverride) {
|
|
|
168044
168488
|
// src/cli.ts
|
|
168045
168489
|
async function main() {
|
|
168046
168490
|
aliasLegacyEnv(process.env);
|
|
168047
|
-
const invokedName =
|
|
168491
|
+
const invokedName = import_node_path98.default.basename(process.argv[1] ?? "agent-shim");
|
|
168048
168492
|
if (isInvokedAsClaude(invokedName)) {
|
|
168049
168493
|
await runClaude();
|
|
168050
168494
|
return;
|