claude-use 9.14.0 → 9.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/cli.cjs +803 -398
- package/dist/index.cjs +25 -9
- package/dist/index.mjs +25 -9
- package/dist/types/index.d.ts +65 -28
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -318,10 +318,10 @@ function mergeDefs(...defs) {
|
|
|
318
318
|
function cloneDef(schema) {
|
|
319
319
|
return mergeDefs(schema._zod.def);
|
|
320
320
|
}
|
|
321
|
-
function getElementAtPath(obj,
|
|
322
|
-
if (!
|
|
321
|
+
function getElementAtPath(obj, path54) {
|
|
322
|
+
if (!path54)
|
|
323
323
|
return obj;
|
|
324
|
-
return
|
|
324
|
+
return path54.reduce((acc, key) => acc?.[key], obj);
|
|
325
325
|
}
|
|
326
326
|
function promiseAllObject(promisesObj) {
|
|
327
327
|
const keys = Object.keys(promisesObj);
|
|
@@ -580,11 +580,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
580
580
|
}
|
|
581
581
|
return false;
|
|
582
582
|
}
|
|
583
|
-
function prefixIssues(
|
|
583
|
+
function prefixIssues(path54, issues) {
|
|
584
584
|
return issues.map((iss) => {
|
|
585
585
|
var _a4;
|
|
586
586
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
587
|
-
iss.path.unshift(
|
|
587
|
+
iss.path.unshift(path54);
|
|
588
588
|
return iss;
|
|
589
589
|
});
|
|
590
590
|
}
|
|
@@ -1105,16 +1105,16 @@ function flattenError(error63, mapper = (issue2) => issue2.message) {
|
|
|
1105
1105
|
}
|
|
1106
1106
|
function formatError(error63, mapper = (issue2) => issue2.message) {
|
|
1107
1107
|
const fieldErrors = { _errors: [] };
|
|
1108
|
-
const processError = (error64,
|
|
1108
|
+
const processError = (error64, path54 = []) => {
|
|
1109
1109
|
for (const issue2 of error64.issues) {
|
|
1110
1110
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1111
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1111
|
+
issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
|
|
1112
1112
|
} else if (issue2.code === "invalid_key") {
|
|
1113
|
-
processError({ issues: issue2.issues }, [...
|
|
1113
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
1114
1114
|
} else if (issue2.code === "invalid_element") {
|
|
1115
|
-
processError({ issues: issue2.issues }, [...
|
|
1115
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
1116
1116
|
} else {
|
|
1117
|
-
const fullpath = [...
|
|
1117
|
+
const fullpath = [...path54, ...issue2.path];
|
|
1118
1118
|
if (fullpath.length === 0) {
|
|
1119
1119
|
fieldErrors._errors.push(mapper(issue2));
|
|
1120
1120
|
} else {
|
|
@@ -1153,17 +1153,17 @@ function formatError(error63, mapper = (issue2) => issue2.message) {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
function treeifyError(error63, mapper = (issue2) => issue2.message) {
|
|
1155
1155
|
const result = { errors: [] };
|
|
1156
|
-
const processError = (error64,
|
|
1156
|
+
const processError = (error64, path54 = []) => {
|
|
1157
1157
|
var _a4;
|
|
1158
1158
|
for (const issue2 of error64.issues) {
|
|
1159
1159
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1160
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1160
|
+
issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
|
|
1161
1161
|
} else if (issue2.code === "invalid_key") {
|
|
1162
|
-
processError({ issues: issue2.issues }, [...
|
|
1162
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
1163
1163
|
} else if (issue2.code === "invalid_element") {
|
|
1164
|
-
processError({ issues: issue2.issues }, [...
|
|
1164
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
1165
1165
|
} else {
|
|
1166
|
-
const fullpath = [...
|
|
1166
|
+
const fullpath = [...path54, ...issue2.path];
|
|
1167
1167
|
if (fullpath.length === 0) {
|
|
1168
1168
|
result.errors.push(mapper(issue2));
|
|
1169
1169
|
continue;
|
|
@@ -1202,8 +1202,8 @@ function treeifyError(error63, mapper = (issue2) => issue2.message) {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
function toDotPath(_path) {
|
|
1204
1204
|
const segs = [];
|
|
1205
|
-
const
|
|
1206
|
-
for (const seg of
|
|
1205
|
+
const path54 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1206
|
+
for (const seg of path54) {
|
|
1207
1207
|
if (typeof seg === "number")
|
|
1208
1208
|
segs.push(`[${seg}]`);
|
|
1209
1209
|
else if (typeof seg === "symbol")
|
|
@@ -19199,13 +19199,13 @@ function resolveRef(ref, ctx) {
|
|
|
19199
19199
|
if (!ref.startsWith("#")) {
|
|
19200
19200
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19201
19201
|
}
|
|
19202
|
-
const
|
|
19203
|
-
if (
|
|
19202
|
+
const path54 = ref.slice(1).split("/").filter(Boolean);
|
|
19203
|
+
if (path54.length === 0) {
|
|
19204
19204
|
return ctx.rootSchema;
|
|
19205
19205
|
}
|
|
19206
19206
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
19207
|
-
if (
|
|
19208
|
-
const key =
|
|
19207
|
+
if (path54[0] === defsKey) {
|
|
19208
|
+
const key = path54[1] === void 0 ? void 0 : decodeJSONPointerSegment(path54[1]);
|
|
19209
19209
|
if (!key || !ctx.defs[key]) {
|
|
19210
19210
|
throw new Error(`Reference not found: ${ref}`);
|
|
19211
19211
|
}
|
|
@@ -23712,42 +23712,42 @@ var require_defaults = __commonJS({
|
|
|
23712
23712
|
var require_env_paths = __commonJS({
|
|
23713
23713
|
"node_modules/.pnpm/env-paths@2.2.1/node_modules/env-paths/index.js"(exports2, module2) {
|
|
23714
23714
|
"use strict";
|
|
23715
|
-
var
|
|
23715
|
+
var path54 = require("path");
|
|
23716
23716
|
var os12 = require("os");
|
|
23717
23717
|
var homedir = os12.homedir();
|
|
23718
23718
|
var tmpdir = os12.tmpdir();
|
|
23719
23719
|
var { env } = process;
|
|
23720
23720
|
var macos = (name) => {
|
|
23721
|
-
const library =
|
|
23721
|
+
const library = path54.join(homedir, "Library");
|
|
23722
23722
|
return {
|
|
23723
|
-
data:
|
|
23724
|
-
config:
|
|
23725
|
-
cache:
|
|
23726
|
-
log:
|
|
23727
|
-
temp:
|
|
23723
|
+
data: path54.join(library, "Application Support", name),
|
|
23724
|
+
config: path54.join(library, "Preferences", name),
|
|
23725
|
+
cache: path54.join(library, "Caches", name),
|
|
23726
|
+
log: path54.join(library, "Logs", name),
|
|
23727
|
+
temp: path54.join(tmpdir, name)
|
|
23728
23728
|
};
|
|
23729
23729
|
};
|
|
23730
23730
|
var windows = (name) => {
|
|
23731
|
-
const appData = env.APPDATA ||
|
|
23732
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
23731
|
+
const appData = env.APPDATA || path54.join(homedir, "AppData", "Roaming");
|
|
23732
|
+
const localAppData = env.LOCALAPPDATA || path54.join(homedir, "AppData", "Local");
|
|
23733
23733
|
return {
|
|
23734
23734
|
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
23735
|
-
data:
|
|
23736
|
-
config:
|
|
23737
|
-
cache:
|
|
23738
|
-
log:
|
|
23739
|
-
temp:
|
|
23735
|
+
data: path54.join(localAppData, name, "Data"),
|
|
23736
|
+
config: path54.join(appData, name, "Config"),
|
|
23737
|
+
cache: path54.join(localAppData, name, "Cache"),
|
|
23738
|
+
log: path54.join(localAppData, name, "Log"),
|
|
23739
|
+
temp: path54.join(tmpdir, name)
|
|
23740
23740
|
};
|
|
23741
23741
|
};
|
|
23742
23742
|
var linux = (name) => {
|
|
23743
|
-
const username =
|
|
23743
|
+
const username = path54.basename(homedir);
|
|
23744
23744
|
return {
|
|
23745
|
-
data:
|
|
23746
|
-
config:
|
|
23747
|
-
cache:
|
|
23745
|
+
data: path54.join(env.XDG_DATA_HOME || path54.join(homedir, ".local", "share"), name),
|
|
23746
|
+
config: path54.join(env.XDG_CONFIG_HOME || path54.join(homedir, ".config"), name),
|
|
23747
|
+
cache: path54.join(env.XDG_CACHE_HOME || path54.join(homedir, ".cache"), name),
|
|
23748
23748
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
23749
|
-
log:
|
|
23750
|
-
temp:
|
|
23749
|
+
log: path54.join(env.XDG_STATE_HOME || path54.join(homedir, ".local", "state"), name),
|
|
23750
|
+
temp: path54.join(tmpdir, username, name)
|
|
23751
23751
|
};
|
|
23752
23752
|
};
|
|
23753
23753
|
var envPaths = (name, options) => {
|
|
@@ -23815,11 +23815,11 @@ var require_util = __commonJS({
|
|
|
23815
23815
|
return result;
|
|
23816
23816
|
}
|
|
23817
23817
|
exports2.emplace = emplace;
|
|
23818
|
-
function getPropertyByPath(source,
|
|
23819
|
-
if (typeof
|
|
23820
|
-
return source[
|
|
23818
|
+
function getPropertyByPath(source, path54) {
|
|
23819
|
+
if (typeof path54 === "string" && Object.prototype.hasOwnProperty.call(source, path54)) {
|
|
23820
|
+
return source[path54];
|
|
23821
23821
|
}
|
|
23822
|
-
const parsedPath = typeof
|
|
23822
|
+
const parsedPath = typeof path54 === "string" ? path54.split(".") : path54;
|
|
23823
23823
|
return parsedPath.reduce((previous, key) => {
|
|
23824
23824
|
if (previous === void 0) {
|
|
23825
23825
|
return previous;
|
|
@@ -23842,9 +23842,9 @@ var require_util = __commonJS({
|
|
|
23842
23842
|
return Object.fromEntries(Object.entries(options).filter(([, value2]) => value2 !== void 0));
|
|
23843
23843
|
}
|
|
23844
23844
|
exports2.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
|
|
23845
|
-
async function isDirectory(
|
|
23845
|
+
async function isDirectory(path54) {
|
|
23846
23846
|
try {
|
|
23847
|
-
const stat = await fs_1.promises.stat(
|
|
23847
|
+
const stat = await fs_1.promises.stat(path54);
|
|
23848
23848
|
return stat.isDirectory();
|
|
23849
23849
|
} catch (e14) {
|
|
23850
23850
|
if (e14.code === "ENOENT") {
|
|
@@ -23854,9 +23854,9 @@ var require_util = __commonJS({
|
|
|
23854
23854
|
}
|
|
23855
23855
|
}
|
|
23856
23856
|
exports2.isDirectory = isDirectory;
|
|
23857
|
-
function isDirectorySync(
|
|
23857
|
+
function isDirectorySync(path54) {
|
|
23858
23858
|
try {
|
|
23859
|
-
const stat = fs_1.default.statSync(
|
|
23859
|
+
const stat = fs_1.default.statSync(path54);
|
|
23860
23860
|
return stat.isDirectory();
|
|
23861
23861
|
} catch (e14) {
|
|
23862
23862
|
if (e14.code === "ENOENT") {
|
|
@@ -23954,7 +23954,7 @@ var require_ExplorerBase = __commonJS({
|
|
|
23954
23954
|
const idx = importStack.indexOf(fullPath);
|
|
23955
23955
|
if (idx !== -1) {
|
|
23956
23956
|
throw new Error(`Circular import detected:
|
|
23957
|
-
${[...importStack, fullPath].map((
|
|
23957
|
+
${[...importStack, fullPath].map((path54, i10) => `${i10 + 1}. ${path54}`).join("\n")} (same as ${idx + 1}.)`);
|
|
23958
23958
|
}
|
|
23959
23959
|
}
|
|
23960
23960
|
}
|
|
@@ -24142,9 +24142,9 @@ var require_Explorer = __commonJS({
|
|
|
24142
24142
|
throw error63;
|
|
24143
24143
|
}
|
|
24144
24144
|
}
|
|
24145
|
-
async #fileExists(
|
|
24145
|
+
async #fileExists(path54) {
|
|
24146
24146
|
try {
|
|
24147
|
-
await promises_1.default.stat(
|
|
24147
|
+
await promises_1.default.stat(path54);
|
|
24148
24148
|
return true;
|
|
24149
24149
|
} catch (e14) {
|
|
24150
24150
|
return false;
|
|
@@ -24304,9 +24304,9 @@ var require_ExplorerSync = __commonJS({
|
|
|
24304
24304
|
throw error63;
|
|
24305
24305
|
}
|
|
24306
24306
|
}
|
|
24307
|
-
#fileExists(
|
|
24307
|
+
#fileExists(path54) {
|
|
24308
24308
|
try {
|
|
24309
|
-
fs_1.default.statSync(
|
|
24309
|
+
fs_1.default.statSync(path54);
|
|
24310
24310
|
return true;
|
|
24311
24311
|
} catch (e14) {
|
|
24312
24312
|
return false;
|
|
@@ -24430,7 +24430,7 @@ var require_dist = __commonJS({
|
|
|
24430
24430
|
};
|
|
24431
24431
|
}
|
|
24432
24432
|
function getResolvedSearchPlaces(moduleName, toolDefinedSearchPlaces, userConfiguredOptions) {
|
|
24433
|
-
const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((
|
|
24433
|
+
const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path54) => path54.replace("{name}", moduleName));
|
|
24434
24434
|
if (userConfiguredOptions.mergeSearchPlaces) {
|
|
24435
24435
|
return [...userConfiguredSearchPlaces ?? [], ...toolDefinedSearchPlaces];
|
|
24436
24436
|
}
|
|
@@ -26807,7 +26807,7 @@ function isTimeZone(name) {
|
|
|
26807
26807
|
return false;
|
|
26808
26808
|
}
|
|
26809
26809
|
}
|
|
26810
|
-
var import_node_path4, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, CODEX_TIERS, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, HttpProviderSchema, CodexProviderSchema, ProviderSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, PoolSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema,
|
|
26810
|
+
var import_node_path4, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, CODEX_TIERS, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, HttpProviderSchema, CodexProviderSchema, ProviderSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
|
|
26811
26811
|
var init_schema = __esm({
|
|
26812
26812
|
"src/config/schema.ts"() {
|
|
26813
26813
|
"use strict";
|
|
@@ -26982,6 +26982,25 @@ var init_schema = __esm({
|
|
|
26982
26982
|
identities: external_exports.array(PoolMemberSchema).min(1).refine((members2) => new Set(members2.map(poolMemberIdentity)).size === members2.length, { message: "pool members must be unique" }),
|
|
26983
26983
|
preference: PoolPreferenceSchema.optional()
|
|
26984
26984
|
});
|
|
26985
|
+
WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
26986
|
+
AnchorSchema = external_exports.strictObject({
|
|
26987
|
+
days: external_exports.array(external_exports.enum(WEEKDAYS)).min(1).refine((days) => new Set(days).size === days.length, "an anchor names each weekday at most once"),
|
|
26988
|
+
time: external_exports.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "a 24-hour time such as 06:00"),
|
|
26989
|
+
timeZone: external_exports.string().refine(isTimeZone, "an IANA time zone such as Europe/London").optional()
|
|
26990
|
+
});
|
|
26991
|
+
JOB_WINDOWS = ["fiveHour", "sevenDay"];
|
|
26992
|
+
JobTriggerSchema = external_exports.union([external_exports.strictObject({ at: external_exports.array(AnchorSchema).min(1) }), external_exports.strictObject({ beforeReset: external_exports.enum(JOB_WINDOWS), lead: external_exports.string().regex(DURATION_RE) })]);
|
|
26993
|
+
JobTargetSchema = external_exports.union([external_exports.strictObject({ identity: IdentitySelectorSchema }), external_exports.strictObject({ pool: PoolNameSchema })]);
|
|
26994
|
+
JobSchema = external_exports.strictObject({
|
|
26995
|
+
target: JobTargetSchema,
|
|
26996
|
+
trigger: JobTriggerSchema,
|
|
26997
|
+
prompt: external_exports.string().min(1),
|
|
26998
|
+
/** The absolute directory the run works in. */
|
|
26999
|
+
cwd: external_exports.string().min(1),
|
|
27000
|
+
timeout: external_exports.string().regex(DURATION_RE),
|
|
27001
|
+
model: external_exports.string().min(1).optional(),
|
|
27002
|
+
allowedTools: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
27003
|
+
});
|
|
26985
27004
|
DirectoryRuleSchema = ConfigProfileSchema.omit({ description: true }).extend({
|
|
26986
27005
|
path: external_exports.string().min(1),
|
|
26987
27006
|
configProfile: external_exports.string().min(1).optional(),
|
|
@@ -27050,13 +27069,8 @@ var init_schema = __esm({
|
|
|
27050
27069
|
headroom: HeadroomGlobalConfigSchema.optional(),
|
|
27051
27070
|
frontdoor: FrontDoorGlobalConfigSchema.optional(),
|
|
27052
27071
|
update: UpdateGlobalConfigSchema.optional(),
|
|
27053
|
-
pools: external_exports.record(PoolNameSchema, PoolSchema).optional()
|
|
27054
|
-
|
|
27055
|
-
WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
27056
|
-
AnchorSchema = external_exports.strictObject({
|
|
27057
|
-
days: external_exports.array(external_exports.enum(WEEKDAYS)).min(1).refine((days) => new Set(days).size === days.length, "an anchor names each weekday at most once"),
|
|
27058
|
-
time: external_exports.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "a 24-hour time such as 06:00"),
|
|
27059
|
-
timeZone: external_exports.string().refine(isTimeZone, "an IANA time zone such as Europe/London").optional()
|
|
27072
|
+
pools: external_exports.record(PoolNameSchema, PoolSchema).optional(),
|
|
27073
|
+
jobs: external_exports.record(PoolNameSchema, JobSchema).optional()
|
|
27060
27074
|
});
|
|
27061
27075
|
IdentitySchema = external_exports.strictObject({
|
|
27062
27076
|
$schema: external_exports.string().optional(),
|
|
@@ -28927,8 +28941,8 @@ var require_utils = __commonJS({
|
|
|
28927
28941
|
}
|
|
28928
28942
|
return output2;
|
|
28929
28943
|
};
|
|
28930
|
-
exports2.basename = (
|
|
28931
|
-
const segs =
|
|
28944
|
+
exports2.basename = (path54, { windows } = {}) => {
|
|
28945
|
+
const segs = path54.split(windows ? /[\\/]/ : "/");
|
|
28932
28946
|
const last = segs[segs.length - 1];
|
|
28933
28947
|
if (last === "") {
|
|
28934
28948
|
return segs[segs.length - 2];
|
|
@@ -32595,6 +32609,8 @@ function buildLayoutPaths(root) {
|
|
|
32595
32609
|
usageSnapshotsDir: import_node_path19.default.join(root, "usage", "snapshots"),
|
|
32596
32610
|
usagePicksFile: import_node_path19.default.join(root, "usage", "picks.json"),
|
|
32597
32611
|
usageAnchorsFile: import_node_path19.default.join(root, "usage", "anchors.json"),
|
|
32612
|
+
usageJobsFile: import_node_path19.default.join(root, "usage", "jobs.json"),
|
|
32613
|
+
jobLogsDir: import_node_path19.default.join(root, "logs", "jobs"),
|
|
32598
32614
|
mcpPermissionsFile: import_node_path19.default.join(root, "mcp", "permissions.json")
|
|
32599
32615
|
};
|
|
32600
32616
|
}
|
|
@@ -33301,7 +33317,7 @@ var init_package = __esm({
|
|
|
33301
33317
|
"package.json"() {
|
|
33302
33318
|
package_default = {
|
|
33303
33319
|
name: "claude-use",
|
|
33304
|
-
version: "9.
|
|
33320
|
+
version: "9.15.0",
|
|
33305
33321
|
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.",
|
|
33306
33322
|
license: "MIT",
|
|
33307
33323
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -33572,11 +33588,11 @@ function identifyRequest(headers) {
|
|
|
33572
33588
|
function directOrigin(port) {
|
|
33573
33589
|
return `http://127.0.0.1:${String(port)}`;
|
|
33574
33590
|
}
|
|
33575
|
-
function parseProviderPath(
|
|
33576
|
-
if (!
|
|
33591
|
+
function parseProviderPath(path54) {
|
|
33592
|
+
if (!path54.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
33577
33593
|
return void 0;
|
|
33578
33594
|
}
|
|
33579
|
-
const tail =
|
|
33595
|
+
const tail = path54.slice(PROVIDER_PATH_PREFIX.length);
|
|
33580
33596
|
const slash = tail.indexOf("/");
|
|
33581
33597
|
if (slash <= 0) {
|
|
33582
33598
|
return void 0;
|
|
@@ -33902,9 +33918,9 @@ function decoderFor(encoding) {
|
|
|
33902
33918
|
return void 0;
|
|
33903
33919
|
}
|
|
33904
33920
|
}
|
|
33905
|
-
function destinationOf(
|
|
33906
|
-
const scoped = parseProviderPath(
|
|
33907
|
-
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint:
|
|
33921
|
+
function destinationOf(path54) {
|
|
33922
|
+
const scoped = parseProviderPath(path54);
|
|
33923
|
+
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint: path54 } : { provider: scoped.provider, endpoint: scoped.rest };
|
|
33908
33924
|
}
|
|
33909
33925
|
function buildRecord(event, context) {
|
|
33910
33926
|
const { scan } = context;
|
|
@@ -36340,14 +36356,14 @@ var require_util2 = __commonJS({
|
|
|
36340
36356
|
}
|
|
36341
36357
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
36342
36358
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
36343
|
-
let
|
|
36359
|
+
let path54 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
36344
36360
|
if (origin[origin.length - 1] === "/") {
|
|
36345
36361
|
origin = origin.slice(0, origin.length - 1);
|
|
36346
36362
|
}
|
|
36347
|
-
if (
|
|
36348
|
-
|
|
36363
|
+
if (path54 && path54[0] !== "/") {
|
|
36364
|
+
path54 = `/${path54}`;
|
|
36349
36365
|
}
|
|
36350
|
-
return new URL(`${origin}${
|
|
36366
|
+
return new URL(`${origin}${path54}`);
|
|
36351
36367
|
}
|
|
36352
36368
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
36353
36369
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -37168,9 +37184,9 @@ var require_diagnostics = __commonJS({
|
|
|
37168
37184
|
"undici:client:sendHeaders",
|
|
37169
37185
|
(evt) => {
|
|
37170
37186
|
const {
|
|
37171
|
-
request: { method, path:
|
|
37187
|
+
request: { method, path: path54, origin }
|
|
37172
37188
|
} = evt;
|
|
37173
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
37189
|
+
debugLog("sending request to %s %s%s", method, origin, path54);
|
|
37174
37190
|
}
|
|
37175
37191
|
);
|
|
37176
37192
|
}
|
|
@@ -37188,14 +37204,14 @@ var require_diagnostics = __commonJS({
|
|
|
37188
37204
|
"undici:request:headers",
|
|
37189
37205
|
(evt) => {
|
|
37190
37206
|
const {
|
|
37191
|
-
request: { method, path:
|
|
37207
|
+
request: { method, path: path54, origin },
|
|
37192
37208
|
response: { statusCode }
|
|
37193
37209
|
} = evt;
|
|
37194
37210
|
debugLog(
|
|
37195
37211
|
"received response to %s %s%s - HTTP %d",
|
|
37196
37212
|
method,
|
|
37197
37213
|
origin,
|
|
37198
|
-
|
|
37214
|
+
path54,
|
|
37199
37215
|
statusCode
|
|
37200
37216
|
);
|
|
37201
37217
|
}
|
|
@@ -37204,23 +37220,23 @@ var require_diagnostics = __commonJS({
|
|
|
37204
37220
|
"undici:request:trailers",
|
|
37205
37221
|
(evt) => {
|
|
37206
37222
|
const {
|
|
37207
|
-
request: { method, path:
|
|
37223
|
+
request: { method, path: path54, origin }
|
|
37208
37224
|
} = evt;
|
|
37209
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
37225
|
+
debugLog("trailers received from %s %s%s", method, origin, path54);
|
|
37210
37226
|
}
|
|
37211
37227
|
);
|
|
37212
37228
|
diagnosticsChannel.subscribe(
|
|
37213
37229
|
"undici:request:error",
|
|
37214
37230
|
(evt) => {
|
|
37215
37231
|
const {
|
|
37216
|
-
request: { method, path:
|
|
37232
|
+
request: { method, path: path54, origin },
|
|
37217
37233
|
error: error63
|
|
37218
37234
|
} = evt;
|
|
37219
37235
|
debugLog(
|
|
37220
37236
|
"request to %s %s%s errored - %s",
|
|
37221
37237
|
method,
|
|
37222
37238
|
origin,
|
|
37223
|
-
|
|
37239
|
+
path54,
|
|
37224
37240
|
error63.message
|
|
37225
37241
|
);
|
|
37226
37242
|
}
|
|
@@ -37335,7 +37351,7 @@ var require_request = __commonJS({
|
|
|
37335
37351
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
37336
37352
|
var Request2 = class {
|
|
37337
37353
|
constructor(origin, {
|
|
37338
|
-
path:
|
|
37354
|
+
path: path54,
|
|
37339
37355
|
method,
|
|
37340
37356
|
body,
|
|
37341
37357
|
headers,
|
|
@@ -37352,11 +37368,11 @@ var require_request = __commonJS({
|
|
|
37352
37368
|
maxRedirections,
|
|
37353
37369
|
typeOfService
|
|
37354
37370
|
}, handler) {
|
|
37355
|
-
if (typeof
|
|
37371
|
+
if (typeof path54 !== "string") {
|
|
37356
37372
|
throw new InvalidArgumentError2("path must be a string");
|
|
37357
|
-
} else if (
|
|
37373
|
+
} else if (path54[0] !== "/" && !(path54.startsWith("http://") || path54.startsWith("https://")) && method !== "CONNECT") {
|
|
37358
37374
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
37359
|
-
} else if (invalidPathRegex.test(
|
|
37375
|
+
} else if (invalidPathRegex.test(path54)) {
|
|
37360
37376
|
throw new InvalidArgumentError2("invalid request path");
|
|
37361
37377
|
}
|
|
37362
37378
|
if (typeof method !== "string") {
|
|
@@ -37431,7 +37447,7 @@ var require_request = __commonJS({
|
|
|
37431
37447
|
this.completed = false;
|
|
37432
37448
|
this.aborted = false;
|
|
37433
37449
|
this.upgrade = upgrade || null;
|
|
37434
|
-
this.path = query ? serializePathWithQuery(
|
|
37450
|
+
this.path = query ? serializePathWithQuery(path54, query) : path54;
|
|
37435
37451
|
this.origin = origin;
|
|
37436
37452
|
this.protocol = getProtocolFromUrlString(origin);
|
|
37437
37453
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -42613,7 +42629,7 @@ var require_client_h1 = __commonJS({
|
|
|
42613
42629
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
42614
42630
|
}
|
|
42615
42631
|
function writeH1(client, request7) {
|
|
42616
|
-
const { method, path:
|
|
42632
|
+
const { method, path: path54, host, upgrade, blocking, reset } = request7;
|
|
42617
42633
|
let { body, headers, contentLength } = request7;
|
|
42618
42634
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
42619
42635
|
if (util2.isFormDataLike(body)) {
|
|
@@ -42691,7 +42707,7 @@ var require_client_h1 = __commonJS({
|
|
|
42691
42707
|
if (socket.setTypeOfService) {
|
|
42692
42708
|
socket.setTypeOfService(request7.typeOfService);
|
|
42693
42709
|
}
|
|
42694
|
-
let header = `${method} ${
|
|
42710
|
+
let header = `${method} ${path54} HTTP/1.1\r
|
|
42695
42711
|
`;
|
|
42696
42712
|
if (typeof host === "string") {
|
|
42697
42713
|
header += `host: ${host}\r
|
|
@@ -43370,7 +43386,7 @@ var require_client_h2 = __commonJS({
|
|
|
43370
43386
|
const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
|
|
43371
43387
|
const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
|
|
43372
43388
|
const session = client[kHTTP2Session];
|
|
43373
|
-
const { method, path:
|
|
43389
|
+
const { method, path: path54, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
|
|
43374
43390
|
let { body } = request7;
|
|
43375
43391
|
if (upgrade != null && upgrade !== "websocket") {
|
|
43376
43392
|
util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -43439,7 +43455,7 @@ var require_client_h2 = __commonJS({
|
|
|
43439
43455
|
}
|
|
43440
43456
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
43441
43457
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
43442
|
-
headers[HTTP2_HEADER_PATH] =
|
|
43458
|
+
headers[HTTP2_HEADER_PATH] = path54;
|
|
43443
43459
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
43444
43460
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
43445
43461
|
} else {
|
|
@@ -43481,7 +43497,7 @@ var require_client_h2 = __commonJS({
|
|
|
43481
43497
|
stream.setTimeout(headersTimeout);
|
|
43482
43498
|
return true;
|
|
43483
43499
|
}
|
|
43484
|
-
headers[HTTP2_HEADER_PATH] =
|
|
43500
|
+
headers[HTTP2_HEADER_PATH] = path54;
|
|
43485
43501
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
43486
43502
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
43487
43503
|
if (body && typeof body.read === "function") {
|
|
@@ -45833,10 +45849,10 @@ var require_proxy_agent = __commonJS({
|
|
|
45833
45849
|
};
|
|
45834
45850
|
const {
|
|
45835
45851
|
origin,
|
|
45836
|
-
path:
|
|
45852
|
+
path: path54 = "/",
|
|
45837
45853
|
headers = {}
|
|
45838
45854
|
} = opts;
|
|
45839
|
-
opts.path = origin +
|
|
45855
|
+
opts.path = origin + path54;
|
|
45840
45856
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
45841
45857
|
const { host } = new URL(origin);
|
|
45842
45858
|
headers.host = host;
|
|
@@ -47945,20 +47961,20 @@ var require_mock_utils = __commonJS({
|
|
|
47945
47961
|
}
|
|
47946
47962
|
return normalizedQp;
|
|
47947
47963
|
}
|
|
47948
|
-
function safeUrl(
|
|
47949
|
-
if (typeof
|
|
47950
|
-
return
|
|
47964
|
+
function safeUrl(path54) {
|
|
47965
|
+
if (typeof path54 !== "string") {
|
|
47966
|
+
return path54;
|
|
47951
47967
|
}
|
|
47952
|
-
const pathSegments =
|
|
47968
|
+
const pathSegments = path54.split("?", 3);
|
|
47953
47969
|
if (pathSegments.length !== 2) {
|
|
47954
|
-
return
|
|
47970
|
+
return path54;
|
|
47955
47971
|
}
|
|
47956
47972
|
const qp2 = new URLSearchParams(pathSegments.pop());
|
|
47957
47973
|
qp2.sort();
|
|
47958
47974
|
return [...pathSegments, qp2.toString()].join("?");
|
|
47959
47975
|
}
|
|
47960
|
-
function matchKey(mockDispatch2, { path:
|
|
47961
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
47976
|
+
function matchKey(mockDispatch2, { path: path54, method, body, headers }) {
|
|
47977
|
+
const pathMatch = matchValue(mockDispatch2.path, path54);
|
|
47962
47978
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
47963
47979
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
47964
47980
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -47983,8 +47999,8 @@ var require_mock_utils = __commonJS({
|
|
|
47983
47999
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
47984
48000
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
47985
48001
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
47986
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
47987
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
48002
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path54, ignoreTrailingSlash }) => {
|
|
48003
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path54)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path54), resolvedPath);
|
|
47988
48004
|
});
|
|
47989
48005
|
if (matchedMockDispatches.length === 0) {
|
|
47990
48006
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -48023,19 +48039,19 @@ var require_mock_utils = __commonJS({
|
|
|
48023
48039
|
mockDispatches.splice(index, 1);
|
|
48024
48040
|
}
|
|
48025
48041
|
}
|
|
48026
|
-
function removeTrailingSlash(
|
|
48027
|
-
while (
|
|
48028
|
-
|
|
48042
|
+
function removeTrailingSlash(path54) {
|
|
48043
|
+
while (path54.endsWith("/")) {
|
|
48044
|
+
path54 = path54.slice(0, -1);
|
|
48029
48045
|
}
|
|
48030
|
-
if (
|
|
48031
|
-
|
|
48046
|
+
if (path54.length === 0) {
|
|
48047
|
+
path54 = "/";
|
|
48032
48048
|
}
|
|
48033
|
-
return
|
|
48049
|
+
return path54;
|
|
48034
48050
|
}
|
|
48035
48051
|
function buildKey(opts) {
|
|
48036
|
-
const { path:
|
|
48052
|
+
const { path: path54, method, body, headers, query } = opts;
|
|
48037
48053
|
return {
|
|
48038
|
-
path:
|
|
48054
|
+
path: path54,
|
|
48039
48055
|
method,
|
|
48040
48056
|
body,
|
|
48041
48057
|
headers,
|
|
@@ -48725,10 +48741,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
48725
48741
|
}
|
|
48726
48742
|
format(pendingInterceptors) {
|
|
48727
48743
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
48728
|
-
({ method, path:
|
|
48744
|
+
({ method, path: path54, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
48729
48745
|
Method: method,
|
|
48730
48746
|
Origin: origin,
|
|
48731
|
-
Path:
|
|
48747
|
+
Path: path54,
|
|
48732
48748
|
"Status code": statusCode,
|
|
48733
48749
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
48734
48750
|
Invocations: timesInvoked,
|
|
@@ -48810,9 +48826,9 @@ var require_mock_agent = __commonJS({
|
|
|
48810
48826
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
48811
48827
|
const dispatchOpts = { ...opts };
|
|
48812
48828
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
48813
|
-
const [
|
|
48829
|
+
const [path54, searchParams] = dispatchOpts.path.split("?");
|
|
48814
48830
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
48815
|
-
dispatchOpts.path = `${
|
|
48831
|
+
dispatchOpts.path = `${path54}?${normalizedSearchParams}`;
|
|
48816
48832
|
}
|
|
48817
48833
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
48818
48834
|
}
|
|
@@ -49213,12 +49229,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
49213
49229
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
49214
49230
|
*/
|
|
49215
49231
|
async loadSnapshots(filePath) {
|
|
49216
|
-
const
|
|
49217
|
-
if (!
|
|
49232
|
+
const path54 = filePath || this.#snapshotPath;
|
|
49233
|
+
if (!path54) {
|
|
49218
49234
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
49219
49235
|
}
|
|
49220
49236
|
try {
|
|
49221
|
-
const data = await readFile(resolve2(
|
|
49237
|
+
const data = await readFile(resolve2(path54), "utf8");
|
|
49222
49238
|
const parsed = JSON.parse(data);
|
|
49223
49239
|
if (Array.isArray(parsed)) {
|
|
49224
49240
|
this.#snapshots.clear();
|
|
@@ -49232,7 +49248,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
49232
49248
|
if (error63.code === "ENOENT") {
|
|
49233
49249
|
this.#snapshots.clear();
|
|
49234
49250
|
} else {
|
|
49235
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
49251
|
+
throw new UndiciError(`Failed to load snapshots from ${path54}`, { cause: error63 });
|
|
49236
49252
|
}
|
|
49237
49253
|
}
|
|
49238
49254
|
}
|
|
@@ -49243,11 +49259,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
49243
49259
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
49244
49260
|
*/
|
|
49245
49261
|
async saveSnapshots(filePath) {
|
|
49246
|
-
const
|
|
49247
|
-
if (!
|
|
49262
|
+
const path54 = filePath || this.#snapshotPath;
|
|
49263
|
+
if (!path54) {
|
|
49248
49264
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
49249
49265
|
}
|
|
49250
|
-
const resolvedPath = resolve2(
|
|
49266
|
+
const resolvedPath = resolve2(path54);
|
|
49251
49267
|
await mkdir(dirname3(resolvedPath), { recursive: true });
|
|
49252
49268
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
49253
49269
|
hash: hash2,
|
|
@@ -49879,15 +49895,15 @@ var require_redirect_handler = __commonJS({
|
|
|
49879
49895
|
return;
|
|
49880
49896
|
}
|
|
49881
49897
|
const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
49882
|
-
const
|
|
49883
|
-
const redirectUrlString = `${origin}${
|
|
49898
|
+
const path54 = search ? `${pathname}${search}` : pathname;
|
|
49899
|
+
const redirectUrlString = `${origin}${path54}`;
|
|
49884
49900
|
for (const historyUrl of this.history) {
|
|
49885
49901
|
if (historyUrl.toString() === redirectUrlString) {
|
|
49886
49902
|
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.`);
|
|
49887
49903
|
}
|
|
49888
49904
|
}
|
|
49889
49905
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
49890
|
-
this.opts.path =
|
|
49906
|
+
this.opts.path = path54;
|
|
49891
49907
|
this.opts.origin = origin;
|
|
49892
49908
|
this.opts.query = null;
|
|
49893
49909
|
}
|
|
@@ -51647,10 +51663,10 @@ var require_cache_handler = __commonJS({
|
|
|
51647
51663
|
}
|
|
51648
51664
|
return locationUrl.pathname + locationUrl.search;
|
|
51649
51665
|
}
|
|
51650
|
-
function deleteCachedUri(store, cacheKey,
|
|
51666
|
+
function deleteCachedUri(store, cacheKey, path54) {
|
|
51651
51667
|
deleteCachedValue(store, {
|
|
51652
51668
|
...cacheKey,
|
|
51653
|
-
path:
|
|
51669
|
+
path: path54
|
|
51654
51670
|
});
|
|
51655
51671
|
for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
|
|
51656
51672
|
const method = util2.safeHTTPMethods[i10];
|
|
@@ -51658,7 +51674,7 @@ var require_cache_handler = __commonJS({
|
|
|
51658
51674
|
deleteCachedValue(store, {
|
|
51659
51675
|
...cacheKey,
|
|
51660
51676
|
method,
|
|
51661
|
-
path:
|
|
51677
|
+
path: path54
|
|
51662
51678
|
});
|
|
51663
51679
|
}
|
|
51664
51680
|
}
|
|
@@ -51669,9 +51685,9 @@ var require_cache_handler = __commonJS({
|
|
|
51669
51685
|
}
|
|
51670
51686
|
const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
|
|
51671
51687
|
for (let i10 = 0; i10 < values.length; i10++) {
|
|
51672
|
-
const
|
|
51673
|
-
if (
|
|
51674
|
-
deleteCachedUri(store, cacheKey,
|
|
51688
|
+
const path54 = getSameOriginPath(cacheKey, values[i10]);
|
|
51689
|
+
if (path54 !== void 0) {
|
|
51690
|
+
deleteCachedUri(store, cacheKey, path54);
|
|
51675
51691
|
}
|
|
51676
51692
|
}
|
|
51677
51693
|
}
|
|
@@ -56671,11 +56687,11 @@ var require_fetch = __commonJS({
|
|
|
56671
56687
|
function dispatch({ body }) {
|
|
56672
56688
|
const url2 = requestCurrentURL(request7);
|
|
56673
56689
|
const agent = fetchParams.controller.dispatcher;
|
|
56674
|
-
const
|
|
56690
|
+
const path54 = url2.pathname + url2.search;
|
|
56675
56691
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
56676
56692
|
return new Promise((resolve2, reject) => agent.dispatch(
|
|
56677
56693
|
{
|
|
56678
|
-
path: hasTrailingQuestionMark ? `${
|
|
56694
|
+
path: hasTrailingQuestionMark ? `${path54}?` : path54,
|
|
56679
56695
|
origin: url2.origin,
|
|
56680
56696
|
method: request7.method,
|
|
56681
56697
|
body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
|
|
@@ -57622,9 +57638,9 @@ var require_util5 = __commonJS({
|
|
|
57622
57638
|
}
|
|
57623
57639
|
}
|
|
57624
57640
|
}
|
|
57625
|
-
function validateCookiePath(
|
|
57626
|
-
for (let i10 = 0; i10 <
|
|
57627
|
-
const code =
|
|
57641
|
+
function validateCookiePath(path54) {
|
|
57642
|
+
for (let i10 = 0; i10 < path54.length; ++i10) {
|
|
57643
|
+
const code = path54.charCodeAt(i10);
|
|
57628
57644
|
if (code < 32 || // exclude CTLs (0-31)
|
|
57629
57645
|
code > 126 || // exclude DEL and non-ascii
|
|
57630
57646
|
code === 59) {
|
|
@@ -60972,11 +60988,11 @@ var require_undici = __commonJS({
|
|
|
60972
60988
|
if (typeof opts.path !== "string") {
|
|
60973
60989
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
60974
60990
|
}
|
|
60975
|
-
let
|
|
60991
|
+
let path54 = opts.path;
|
|
60976
60992
|
if (!opts.path.startsWith("/")) {
|
|
60977
|
-
|
|
60993
|
+
path54 = `/${path54}`;
|
|
60978
60994
|
}
|
|
60979
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
60995
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path54);
|
|
60980
60996
|
} else {
|
|
60981
60997
|
if (!opts) {
|
|
60982
60998
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -99973,8 +99989,8 @@ var require_utils3 = __commonJS({
|
|
|
99973
99989
|
}
|
|
99974
99990
|
return ind;
|
|
99975
99991
|
}
|
|
99976
|
-
function removeDotSegments(
|
|
99977
|
-
let input2 =
|
|
99992
|
+
function removeDotSegments(path54) {
|
|
99993
|
+
let input2 = path54;
|
|
99978
99994
|
const output2 = [];
|
|
99979
99995
|
let nextSlash = -1;
|
|
99980
99996
|
let len = 0;
|
|
@@ -100383,8 +100399,8 @@ var require_schemes = __commonJS({
|
|
|
100383
100399
|
}
|
|
100384
100400
|
if (wsComponent.resourceName) {
|
|
100385
100401
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
100386
|
-
const
|
|
100387
|
-
wsComponent.path =
|
|
100402
|
+
const path54 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
100403
|
+
wsComponent.path = path54 && path54 !== "/" ? path54 : void 0;
|
|
100388
100404
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
100389
100405
|
wsComponent.resourceName = void 0;
|
|
100390
100406
|
}
|
|
@@ -103911,7 +103927,7 @@ var require_dist2 = __commonJS({
|
|
|
103911
103927
|
});
|
|
103912
103928
|
|
|
103913
103929
|
// src/cli.ts
|
|
103914
|
-
var
|
|
103930
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
103915
103931
|
|
|
103916
103932
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
103917
103933
|
var CommanderError = class extends Error {
|
|
@@ -107024,9 +107040,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
107024
107040
|
* @param {string} [path]
|
|
107025
107041
|
* @return {(string|null|Command)}
|
|
107026
107042
|
*/
|
|
107027
|
-
executableDir(
|
|
107028
|
-
if (
|
|
107029
|
-
this._executableDir =
|
|
107043
|
+
executableDir(path54) {
|
|
107044
|
+
if (path54 === void 0) return this._executableDir;
|
|
107045
|
+
this._executableDir = path54;
|
|
107030
107046
|
return this;
|
|
107031
107047
|
}
|
|
107032
107048
|
/**
|
|
@@ -108675,19 +108691,19 @@ function writePools(paths, pools) {
|
|
|
108675
108691
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
108676
108692
|
}
|
|
108677
108693
|
function poolCycleOf(pools, name) {
|
|
108678
|
-
const walk = (current,
|
|
108694
|
+
const walk = (current, path54) => {
|
|
108679
108695
|
for (const entry of pools[current]?.identities ?? []) {
|
|
108680
108696
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
108681
108697
|
if (nested === void 0) {
|
|
108682
108698
|
continue;
|
|
108683
108699
|
}
|
|
108684
108700
|
if (nested === name) {
|
|
108685
|
-
return [...
|
|
108701
|
+
return [...path54, nested];
|
|
108686
108702
|
}
|
|
108687
|
-
if (
|
|
108703
|
+
if (path54.includes(nested)) {
|
|
108688
108704
|
continue;
|
|
108689
108705
|
}
|
|
108690
|
-
const found = walk(nested, [...
|
|
108706
|
+
const found = walk(nested, [...path54, nested]);
|
|
108691
108707
|
if (found !== void 0) {
|
|
108692
108708
|
return found;
|
|
108693
108709
|
}
|
|
@@ -109753,6 +109769,12 @@ function collectRepeated(value2, previous = []) {
|
|
|
109753
109769
|
function collectAnchor(value2, previous = []) {
|
|
109754
109770
|
return [...previous, asInvalidArgument(() => parseAnchor(value2))];
|
|
109755
109771
|
}
|
|
109772
|
+
function parseDurationLiteral(value2) {
|
|
109773
|
+
return asInvalidArgument(() => {
|
|
109774
|
+
parseDuration(value2);
|
|
109775
|
+
return value2;
|
|
109776
|
+
});
|
|
109777
|
+
}
|
|
109756
109778
|
function parseDurationOption(value2) {
|
|
109757
109779
|
return asInvalidArgument(() => parseDuration(value2));
|
|
109758
109780
|
}
|
|
@@ -111623,7 +111645,7 @@ function registerCodexCommand(program2, deps) {
|
|
|
111623
111645
|
|
|
111624
111646
|
// src/frontdoor/commands.ts
|
|
111625
111647
|
var import_node_crypto20 = require("node:crypto");
|
|
111626
|
-
var
|
|
111648
|
+
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
111627
111649
|
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
111628
111650
|
init_commandDeps();
|
|
111629
111651
|
init_schema();
|
|
@@ -111824,6 +111846,63 @@ function registerUpdateCommand(program2, deps, ports = realUpdatePorts) {
|
|
|
111824
111846
|
);
|
|
111825
111847
|
}
|
|
111826
111848
|
|
|
111849
|
+
// src/jobStore.ts
|
|
111850
|
+
init_cliError();
|
|
111851
|
+
init_store();
|
|
111852
|
+
init_schema();
|
|
111853
|
+
var JobNotFoundError = class extends CliError {
|
|
111854
|
+
constructor(jobName) {
|
|
111855
|
+
super(`No job named "${jobName}". Run \`agent-shim job add ${jobName} ...\` first.`);
|
|
111856
|
+
this.jobName = jobName;
|
|
111857
|
+
this.name = "JobNotFoundError";
|
|
111858
|
+
}
|
|
111859
|
+
jobName;
|
|
111860
|
+
};
|
|
111861
|
+
var JobAlreadyExistsError = class extends CliError {
|
|
111862
|
+
constructor(jobName) {
|
|
111863
|
+
super(`A job named "${jobName}" already exists. Remove it with \`agent-shim job remove ${jobName}\` to define it again.`);
|
|
111864
|
+
this.jobName = jobName;
|
|
111865
|
+
this.name = "JobAlreadyExistsError";
|
|
111866
|
+
}
|
|
111867
|
+
jobName;
|
|
111868
|
+
};
|
|
111869
|
+
var InvalidJobNameError = class extends CliError {
|
|
111870
|
+
constructor(attemptedName) {
|
|
111871
|
+
super(`"${attemptedName}" is not a valid job name: it must start with a letter or number and may then contain letters, numbers, dots, hyphens and underscores.`);
|
|
111872
|
+
this.attemptedName = attemptedName;
|
|
111873
|
+
this.name = "InvalidJobNameError";
|
|
111874
|
+
}
|
|
111875
|
+
attemptedName;
|
|
111876
|
+
};
|
|
111877
|
+
function readJobs(paths) {
|
|
111878
|
+
return readGlobalConfig(paths)?.jobs ?? {};
|
|
111879
|
+
}
|
|
111880
|
+
function requireJob(paths, name) {
|
|
111881
|
+
const job = readJobs(paths)[name];
|
|
111882
|
+
if (job === void 0) {
|
|
111883
|
+
throw new JobNotFoundError(name);
|
|
111884
|
+
}
|
|
111885
|
+
return job;
|
|
111886
|
+
}
|
|
111887
|
+
function writeJobs(paths, jobs) {
|
|
111888
|
+
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { jobs }, { defaults: {} });
|
|
111889
|
+
}
|
|
111890
|
+
function addJob(paths, name, job) {
|
|
111891
|
+
if (!PoolNameSchema.safeParse(name).success) {
|
|
111892
|
+
throw new InvalidJobNameError(name);
|
|
111893
|
+
}
|
|
111894
|
+
const jobs = readJobs(paths);
|
|
111895
|
+
if (jobs[name] !== void 0) {
|
|
111896
|
+
throw new JobAlreadyExistsError(name);
|
|
111897
|
+
}
|
|
111898
|
+
writeJobs(paths, { ...jobs, [name]: job });
|
|
111899
|
+
return job;
|
|
111900
|
+
}
|
|
111901
|
+
function removeJob(paths, name) {
|
|
111902
|
+
requireJob(paths, name);
|
|
111903
|
+
writeJobs(paths, Object.fromEntries(Object.entries(readJobs(paths)).filter(([existing]) => existing !== name)));
|
|
111904
|
+
}
|
|
111905
|
+
|
|
111827
111906
|
// src/launcher/poolRefresh.ts
|
|
111828
111907
|
init_anthropicUsageRefresh();
|
|
111829
111908
|
async function refreshStalePoolMembers(params) {
|
|
@@ -111839,6 +111918,65 @@ init_anthropicUsageRefresh();
|
|
|
111839
111918
|
init_poolPick();
|
|
111840
111919
|
init_realAnthropicUsageProbe();
|
|
111841
111920
|
|
|
111921
|
+
// src/usage/realJobRunner.ts
|
|
111922
|
+
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
111923
|
+
init_conditions();
|
|
111924
|
+
init_identityClaude();
|
|
111925
|
+
var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
|
|
111926
|
+
var JOB_ISOLATION_OPTIONS = { settingSources: ["user"], mcpServers: {}, strictMcpConfig: true };
|
|
111927
|
+
function logEntry(name, identity, endedAt, outcome) {
|
|
111928
|
+
return `${endedAt.toISOString()} job ${name} as ${identity}
|
|
111929
|
+
${outcome.trimEnd()}
|
|
111930
|
+
|
|
111931
|
+
`;
|
|
111932
|
+
}
|
|
111933
|
+
function createRealJobRunner(params) {
|
|
111934
|
+
return async (name, identity, job) => {
|
|
111935
|
+
const logFile = import_node_path38.default.join(params.paths.jobLogsDir, `${name}.log`);
|
|
111936
|
+
const append = (outcome) => {
|
|
111937
|
+
params.fs.mkdirPrivate(params.paths.jobLogsDir);
|
|
111938
|
+
params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
|
|
111939
|
+
};
|
|
111940
|
+
try {
|
|
111941
|
+
const result = await withIdentityClaude({ paths: params.paths, spawnDaemon: params.spawnDaemon, cwd: job.cwd, timeoutMs: parseDuration(job.timeout) }, identity, JOB_LAUNCH_FLAGS, async ({ bin, env, cwd, abort }) => {
|
|
111942
|
+
const { query } = await Promise.resolve().then(() => (init_sdk(), sdk_exports));
|
|
111943
|
+
const session = query({
|
|
111944
|
+
prompt: job.prompt,
|
|
111945
|
+
options: {
|
|
111946
|
+
pathToClaudeCodeExecutable: bin,
|
|
111947
|
+
env,
|
|
111948
|
+
cwd,
|
|
111949
|
+
abortController: abort,
|
|
111950
|
+
settingSources: [...JOB_ISOLATION_OPTIONS.settingSources],
|
|
111951
|
+
mcpServers: JOB_ISOLATION_OPTIONS.mcpServers,
|
|
111952
|
+
strictMcpConfig: JOB_ISOLATION_OPTIONS.strictMcpConfig,
|
|
111953
|
+
permissionMode: "dontAsk",
|
|
111954
|
+
...job.model === void 0 ? {} : { model: job.model },
|
|
111955
|
+
...job.allowedTools === void 0 ? {} : { allowedTools: [...job.allowedTools] }
|
|
111956
|
+
}
|
|
111957
|
+
});
|
|
111958
|
+
try {
|
|
111959
|
+
for await (const message of session) {
|
|
111960
|
+
if (message.type === "result") {
|
|
111961
|
+
if (message.subtype !== "success") {
|
|
111962
|
+
throw new Error(`the run ended as ${message.subtype}`);
|
|
111963
|
+
}
|
|
111964
|
+
return message.result;
|
|
111965
|
+
}
|
|
111966
|
+
}
|
|
111967
|
+
throw new Error("the run ended without a result");
|
|
111968
|
+
} finally {
|
|
111969
|
+
session.close();
|
|
111970
|
+
}
|
|
111971
|
+
});
|
|
111972
|
+
append(result);
|
|
111973
|
+
} catch (error63) {
|
|
111974
|
+
append(`FAILED: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
111975
|
+
throw error63;
|
|
111976
|
+
}
|
|
111977
|
+
};
|
|
111978
|
+
}
|
|
111979
|
+
|
|
111842
111980
|
// src/usage/realWindowOpener.ts
|
|
111843
111981
|
init_identityClaude();
|
|
111844
111982
|
var OPENER_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
|
|
@@ -111885,18 +112023,18 @@ function createRealWindowOpener(params) {
|
|
|
111885
112023
|
};
|
|
111886
112024
|
}
|
|
111887
112025
|
|
|
111888
|
-
// src/usage/
|
|
111889
|
-
|
|
112026
|
+
// src/usage/jobKeeper.ts
|
|
112027
|
+
init_conditions();
|
|
112028
|
+
|
|
112029
|
+
// src/usage/handledStamps.ts
|
|
112030
|
+
var import_node_path39 = __toESM(require("node:path"), 1);
|
|
111890
112031
|
init_zod();
|
|
111891
|
-
init_preflight();
|
|
111892
|
-
init_pick();
|
|
111893
|
-
init_middleware();
|
|
111894
112032
|
var STAMPS_SCHEMA_VERSION = 1;
|
|
111895
112033
|
var StampsFileSchema = external_exports.strictObject({
|
|
111896
112034
|
schemaVersion: external_exports.literal(STAMPS_SCHEMA_VERSION),
|
|
111897
112035
|
handled: external_exports.record(external_exports.string().min(1), external_exports.iso.datetime())
|
|
111898
112036
|
});
|
|
111899
|
-
function
|
|
112037
|
+
function readHandled(fs22, file2) {
|
|
111900
112038
|
const raw = fs22.readFileUtf8(file2);
|
|
111901
112039
|
if (raw === void 0) {
|
|
111902
112040
|
return {};
|
|
@@ -111908,14 +112046,30 @@ function readStamps(fs22, file2) {
|
|
|
111908
112046
|
parsed = void 0;
|
|
111909
112047
|
}
|
|
111910
112048
|
const result = StampsFileSchema.safeParse(parsed);
|
|
111911
|
-
return result.success ? Object.fromEntries(Object.entries(result.data.handled).map(([
|
|
112049
|
+
return result.success ? Object.fromEntries(Object.entries(result.data.handled).map(([key, at2]) => [key, Date.parse(at2)])) : {};
|
|
111912
112050
|
}
|
|
111913
|
-
function
|
|
111914
|
-
const next = { schemaVersion: STAMPS_SCHEMA_VERSION, handled: Object.fromEntries(Object.entries(handled).map(([
|
|
111915
|
-
fs22.mkdirPrivate(
|
|
112051
|
+
function writeHandled(fs22, file2, handled) {
|
|
112052
|
+
const next = { schemaVersion: STAMPS_SCHEMA_VERSION, handled: Object.fromEntries(Object.entries(handled).map(([key, at2]) => [key, new Date(at2).toISOString()])) };
|
|
112053
|
+
fs22.mkdirPrivate(import_node_path39.default.dirname(file2));
|
|
111916
112054
|
fs22.writeFilePrivate(file2, `${JSON.stringify(next, null, 2)}
|
|
111917
112055
|
`);
|
|
111918
112056
|
}
|
|
112057
|
+
|
|
112058
|
+
// src/usage/jobKeeper.ts
|
|
112059
|
+
init_middleware();
|
|
112060
|
+
init_preflight();
|
|
112061
|
+
|
|
112062
|
+
// src/usage/windowKeeper.ts
|
|
112063
|
+
init_preflight();
|
|
112064
|
+
init_pick();
|
|
112065
|
+
init_middleware();
|
|
112066
|
+
function refusalReason(identity, snapshot, nowMs) {
|
|
112067
|
+
if (snapshot === void 0) {
|
|
112068
|
+
return void 0;
|
|
112069
|
+
}
|
|
112070
|
+
const candidate = rankPool({ members: [{ identity, snapshot, records: [] }], nowMs, resuming: false }).candidates[0];
|
|
112071
|
+
return candidate?.class === "ineligible" ? `it is refused right now (${candidate.reasons[0] ?? "no reason recorded"})` : void 0;
|
|
112072
|
+
}
|
|
111919
112073
|
function reasonNotToOpen(identity, snapshot, nowMs) {
|
|
111920
112074
|
if (snapshot === void 0) {
|
|
111921
112075
|
return void 0;
|
|
@@ -111928,13 +112082,12 @@ function reasonNotToOpen(identity, snapshot, nowMs) {
|
|
|
111928
112082
|
if (five?.resetsAtMs !== void 0) {
|
|
111929
112083
|
return `a five-hour window is already open, resetting in ${formatAge(five.resetsAtMs - nowMs)}`;
|
|
111930
112084
|
}
|
|
111931
|
-
|
|
111932
|
-
return candidate?.class === "ineligible" ? `it is refused right now (${candidate.reasons[0] ?? "no reason recorded"})` : void 0;
|
|
112085
|
+
return refusalReason(identity, snapshot, nowMs);
|
|
111933
112086
|
}
|
|
111934
112087
|
async function runWindowKeeper(ports) {
|
|
111935
112088
|
const nowMs = ports.nowMs();
|
|
111936
112089
|
const anchored = ports.anchored();
|
|
111937
|
-
const previous =
|
|
112090
|
+
const previous = readHandled(ports.fs, ports.stampsFile);
|
|
111938
112091
|
const handled = Object.fromEntries(anchored.flatMap(({ identity }) => previous[identity] === void 0 ? [] : [[identity, previous[identity]]]));
|
|
111939
112092
|
const outcomes = [];
|
|
111940
112093
|
for (const { identity, anchors } of anchored) {
|
|
@@ -111962,7 +112115,7 @@ async function runWindowKeeper(ports) {
|
|
|
111962
112115
|
outcomes.push({ identity, status: "failed", detail: `anchor ${new Date(due2).toISOString()}: could not open a window: ${error63 instanceof Error ? error63.message : String(error63)}` });
|
|
111963
112116
|
}
|
|
111964
112117
|
}
|
|
111965
|
-
|
|
112118
|
+
writeHandled(ports.fs, ports.stampsFile, handled);
|
|
111966
112119
|
for (const outcome of outcomes) {
|
|
111967
112120
|
if (outcome.status === "opened" || outcome.status === "skipped" || outcome.status === "failed") {
|
|
111968
112121
|
ports.log(`window keeper: ${outcome.identity}: ${outcome.detail}`);
|
|
@@ -111971,6 +112124,109 @@ async function runWindowKeeper(ports) {
|
|
|
111971
112124
|
return outcomes;
|
|
111972
112125
|
}
|
|
111973
112126
|
|
|
112127
|
+
// src/usage/jobKeeper.ts
|
|
112128
|
+
function pendingReset(snapshot, window, nowMs) {
|
|
112129
|
+
const recorded = snapshot?.providers[ANTHROPIC_PROVIDER]?.rateLimit?.unified?.[window];
|
|
112130
|
+
return recorded === void 0 ? void 0 : effectiveWindow(recorded, nowMs).resetsAtMs;
|
|
112131
|
+
}
|
|
112132
|
+
function runJobs(ports) {
|
|
112133
|
+
const nowMs = ports.nowMs();
|
|
112134
|
+
const jobs = ports.jobs();
|
|
112135
|
+
const previous = readHandled(ports.fs, ports.stampsFile);
|
|
112136
|
+
const handled = Object.fromEntries(jobs.flatMap(({ name }) => previous[name] === void 0 ? [] : [[name, previous[name]]]));
|
|
112137
|
+
const outcomes = [];
|
|
112138
|
+
const runs = [];
|
|
112139
|
+
const start = (name, identity, job, stamp, detail) => {
|
|
112140
|
+
handled[name] = stamp;
|
|
112141
|
+
ports.running.add(name);
|
|
112142
|
+
outcomes.push({ name, status: "started", detail });
|
|
112143
|
+
runs.push(
|
|
112144
|
+
ports.run(name, identity, job).catch((error63) => {
|
|
112145
|
+
ports.log(`job ${name}: failed as ${identity}: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
112146
|
+
}).finally(() => {
|
|
112147
|
+
ports.running.delete(name);
|
|
112148
|
+
})
|
|
112149
|
+
);
|
|
112150
|
+
};
|
|
112151
|
+
const resolve2 = (target) => {
|
|
112152
|
+
try {
|
|
112153
|
+
const identity = ports.resolveIdentity(target);
|
|
112154
|
+
return identity === void 0 ? { problem: "no member of its pool can be picked" } : { identity };
|
|
112155
|
+
} catch (error63) {
|
|
112156
|
+
return { problem: error63 instanceof Error ? error63.message : String(error63) };
|
|
112157
|
+
}
|
|
112158
|
+
};
|
|
112159
|
+
const startIfServable = (name, identity, job, stamp, firedFor) => {
|
|
112160
|
+
const refusal2 = refusalReason(identity, ports.snapshot(identity), nowMs);
|
|
112161
|
+
if (refusal2 === void 0) {
|
|
112162
|
+
start(name, identity, job, stamp, `${firedFor}: running as ${identity}`);
|
|
112163
|
+
return;
|
|
112164
|
+
}
|
|
112165
|
+
handled[name] = stamp;
|
|
112166
|
+
outcomes.push({ name, status: "skipped", detail: `${firedFor}: ${identity}: ${refusal2}` });
|
|
112167
|
+
};
|
|
112168
|
+
for (const { name, job } of jobs) {
|
|
112169
|
+
if (ports.running.has(name)) {
|
|
112170
|
+
outcomes.push({ name, status: "running", detail: "a previous run is still going" });
|
|
112171
|
+
continue;
|
|
112172
|
+
}
|
|
112173
|
+
const { trigger } = job;
|
|
112174
|
+
if ("at" in trigger) {
|
|
112175
|
+
const last = handled[name];
|
|
112176
|
+
if (last === void 0) {
|
|
112177
|
+
handled[name] = nowMs;
|
|
112178
|
+
outcomes.push({ name, status: "armed", detail: "schedule noted; the next anchor to fall is the first acted on" });
|
|
112179
|
+
continue;
|
|
112180
|
+
}
|
|
112181
|
+
const due2 = dueAnchor(trigger.at, nowMs, last, ports.timeZone);
|
|
112182
|
+
if (due2 === void 0) {
|
|
112183
|
+
outcomes.push({ name, status: "waiting", detail: "no anchor has fallen since the last handled" });
|
|
112184
|
+
continue;
|
|
112185
|
+
}
|
|
112186
|
+
const firedFor = `anchor ${new Date(due2).toISOString()}`;
|
|
112187
|
+
const { identity: identity2, problem: problem2 } = resolve2(job.target);
|
|
112188
|
+
if (identity2 === void 0) {
|
|
112189
|
+
handled[name] = nowMs;
|
|
112190
|
+
outcomes.push({ name, status: "skipped", detail: `${firedFor}: ${problem2 ?? "no identity"}` });
|
|
112191
|
+
continue;
|
|
112192
|
+
}
|
|
112193
|
+
startIfServable(name, identity2, job, nowMs, firedFor);
|
|
112194
|
+
continue;
|
|
112195
|
+
}
|
|
112196
|
+
const { identity, problem } = resolve2(job.target);
|
|
112197
|
+
if (identity === void 0) {
|
|
112198
|
+
outcomes.push({ name, status: "skipped", detail: problem ?? "no identity" });
|
|
112199
|
+
continue;
|
|
112200
|
+
}
|
|
112201
|
+
const resetsAtMs = pendingReset(ports.snapshot(identity), trigger.beforeReset, nowMs);
|
|
112202
|
+
if (resetsAtMs === void 0) {
|
|
112203
|
+
outcomes.push({ name, status: "skipped", detail: `${identity} has no ${trigger.beforeReset} window to run before` });
|
|
112204
|
+
continue;
|
|
112205
|
+
}
|
|
112206
|
+
if (resetsAtMs - parseDuration(trigger.lead) > nowMs || handled[name] === resetsAtMs) {
|
|
112207
|
+
outcomes.push({ name, status: "waiting", detail: `${trigger.beforeReset} window resets in ${formatAge(resetsAtMs - nowMs)}` });
|
|
112208
|
+
continue;
|
|
112209
|
+
}
|
|
112210
|
+
startIfServable(name, identity, job, resetsAtMs, `${trigger.beforeReset} window resetting in ${formatAge(resetsAtMs - nowMs)}`);
|
|
112211
|
+
}
|
|
112212
|
+
writeHandled(ports.fs, ports.stampsFile, handled);
|
|
112213
|
+
for (const outcome of outcomes) {
|
|
112214
|
+
if ((outcome.status === "started" || outcome.status === "skipped") && handled[outcome.name] !== previous[outcome.name]) {
|
|
112215
|
+
ports.log(`job ${outcome.name}: ${outcome.detail}`);
|
|
112216
|
+
}
|
|
112217
|
+
}
|
|
112218
|
+
return { outcomes, settled: Promise.all(runs).then(() => void 0) };
|
|
112219
|
+
}
|
|
112220
|
+
|
|
112221
|
+
// src/usage/jobTarget.ts
|
|
112222
|
+
init_poolPick();
|
|
112223
|
+
function resolveJobIdentity(deps, target) {
|
|
112224
|
+
if ("identity" in target) {
|
|
112225
|
+
return target.identity;
|
|
112226
|
+
}
|
|
112227
|
+
return rankPoolGraph({ fs: deps.fs, paths: deps.paths, pools: deps.pools, poolName: target.pool, nowMs: deps.nowMs, resuming: false, identityExists: deps.identityExists }).ranking.pick?.identity;
|
|
112228
|
+
}
|
|
112229
|
+
|
|
111974
112230
|
// src/frontdoor/commands.ts
|
|
111975
112231
|
init_realCredentialCache();
|
|
111976
112232
|
|
|
@@ -112080,7 +112336,7 @@ init_capability();
|
|
|
112080
112336
|
|
|
112081
112337
|
// src/frontdoor/capture.ts
|
|
112082
112338
|
var fs15 = __toESM(require("node:fs"), 1);
|
|
112083
|
-
var
|
|
112339
|
+
var path39 = __toESM(require("node:path"), 1);
|
|
112084
112340
|
var SECRET_HEADER_NAME = /authorization|cookie|token|secret|credential|api[-_]key/i;
|
|
112085
112341
|
var SECRET_JSON_KEY = /token|secret|password|credential|authorization|api[-_]key/i;
|
|
112086
112342
|
var SECRET_BODY_PATTERNS = [
|
|
@@ -112124,10 +112380,10 @@ function redactBody(chunk) {
|
|
|
112124
112380
|
}
|
|
112125
112381
|
var CAPTURE_ENV = "AGENT_SHIM_FRONTDOOR_CAPTURE";
|
|
112126
112382
|
function captureFromEnv(env, logsDir) {
|
|
112127
|
-
return env[CAPTURE_ENV] === "1" ? createFileCapture(
|
|
112383
|
+
return env[CAPTURE_ENV] === "1" ? createFileCapture(path39.join(logsDir, "frontdoor-capture.jsonl")) : void 0;
|
|
112128
112384
|
}
|
|
112129
112385
|
function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
|
|
112130
|
-
fs15.mkdirSync(
|
|
112386
|
+
fs15.mkdirSync(path39.dirname(file2), { recursive: true });
|
|
112131
112387
|
let nextId = 0;
|
|
112132
112388
|
const append = (record2) => {
|
|
112133
112389
|
fs15.appendFileSync(file2, `${JSON.stringify({ ts: now().toISOString(), ...record2 })}
|
|
@@ -112546,14 +112802,14 @@ init_capability();
|
|
|
112546
112802
|
init_route();
|
|
112547
112803
|
|
|
112548
112804
|
// src/frontdoor/supervisor.ts
|
|
112549
|
-
var
|
|
112805
|
+
var import_node_path40 = __toESM(require("node:path"), 1);
|
|
112550
112806
|
init_state2();
|
|
112551
112807
|
function watchedInstallEntry(resolvedOwnExecutablePath, siblingExists) {
|
|
112552
|
-
const parsed =
|
|
112808
|
+
const parsed = import_node_path40.default.parse(resolvedOwnExecutablePath);
|
|
112553
112809
|
if (parsed.name === "agent-shim") {
|
|
112554
112810
|
return resolvedOwnExecutablePath;
|
|
112555
112811
|
}
|
|
112556
|
-
const sibling =
|
|
112812
|
+
const sibling = import_node_path40.default.join(parsed.dir, `agent-shim${parsed.ext}`);
|
|
112557
112813
|
return siblingExists(sibling) ? sibling : resolvedOwnExecutablePath;
|
|
112558
112814
|
}
|
|
112559
112815
|
var FRONTDOOR_SUPERVISOR_STILL_RUNNING = -1;
|
|
@@ -112740,8 +112996,8 @@ function parseConnectTarget(authority) {
|
|
|
112740
112996
|
}
|
|
112741
112997
|
return { host, port };
|
|
112742
112998
|
}
|
|
112743
|
-
function servedByPipeline(
|
|
112744
|
-
return
|
|
112999
|
+
function servedByPipeline(path54) {
|
|
113000
|
+
return path54?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
112745
113001
|
}
|
|
112746
113002
|
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
112747
113003
|
"connection",
|
|
@@ -113260,11 +113516,11 @@ function createRcSessionTracker(deps) {
|
|
|
113260
113516
|
};
|
|
113261
113517
|
const observeExchange = (request7) => {
|
|
113262
113518
|
const method = (request7.method ?? "").toUpperCase();
|
|
113263
|
-
const
|
|
113264
|
-
if (!
|
|
113519
|
+
const path54 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
|
|
113520
|
+
if (!path54.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
113265
113521
|
return void 0;
|
|
113266
113522
|
}
|
|
113267
|
-
const tail =
|
|
113523
|
+
const tail = path54.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
113268
113524
|
const facts = {
|
|
113269
113525
|
oauthAuthorization: oauthAuthorizationOf(request7.headers),
|
|
113270
113526
|
anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
|
|
@@ -113625,8 +113881,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
113625
113881
|
function isRcReadFileEncoding(value2) {
|
|
113626
113882
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value2);
|
|
113627
113883
|
}
|
|
113628
|
-
function buildRcReadFilePayload(requestId,
|
|
113629
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
113884
|
+
function buildRcReadFilePayload(requestId, path54, options) {
|
|
113885
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path54, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
113630
113886
|
}
|
|
113631
113887
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
113632
113888
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -113728,15 +113984,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
113728
113984
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
113729
113985
|
return result.ok ? { ...result, requestId } : result;
|
|
113730
113986
|
}
|
|
113731
|
-
async function readRcSessionFile(deps, sessionId,
|
|
113732
|
-
if (
|
|
113987
|
+
async function readRcSessionFile(deps, sessionId, path54, options) {
|
|
113988
|
+
if (path54 === "") {
|
|
113733
113989
|
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" };
|
|
113734
113990
|
}
|
|
113735
113991
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
113736
113992
|
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" };
|
|
113737
113993
|
}
|
|
113738
113994
|
const requestId = deps.newUuid();
|
|
113739
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
113995
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path54, options), `read ${path54} from session ${sessionId}`);
|
|
113740
113996
|
return result.ok ? { ...result, requestId } : result;
|
|
113741
113997
|
}
|
|
113742
113998
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -113907,11 +114163,11 @@ function createRcControlHandler(deps) {
|
|
|
113907
114163
|
path: "read-file",
|
|
113908
114164
|
read: (body) => {
|
|
113909
114165
|
const session = bodyString(body, "session");
|
|
113910
|
-
const
|
|
114166
|
+
const path54 = bodyString(body, "path");
|
|
113911
114167
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
113912
114168
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
113913
|
-
const refused2 = session === void 0 ||
|
|
113914
|
-
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,
|
|
114169
|
+
const refused2 = session === void 0 || path54 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
114170
|
+
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, path54, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
113915
114171
|
}
|
|
113916
114172
|
},
|
|
113917
114173
|
{
|
|
@@ -114221,9 +114477,9 @@ function requestIdOfBody(body) {
|
|
|
114221
114477
|
}
|
|
114222
114478
|
function frontDoorRcControl(transport, token) {
|
|
114223
114479
|
const headers = { authorization: `Bearer ${token}` };
|
|
114224
|
-
const listAnswerOf = async (
|
|
114480
|
+
const listAnswerOf = async (path54, what) => {
|
|
114225
114481
|
try {
|
|
114226
|
-
return await transport.request({ method: "GET", path:
|
|
114482
|
+
return await transport.request({ method: "GET", path: path54, headers });
|
|
114227
114483
|
} catch (error63) {
|
|
114228
114484
|
throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
|
|
114229
114485
|
}
|
|
@@ -114295,10 +114551,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
114295
114551
|
}
|
|
114296
114552
|
return pending;
|
|
114297
114553
|
};
|
|
114298
|
-
const writeOf = async (
|
|
114554
|
+
const writeOf = async (path54, body, describeFailure) => {
|
|
114299
114555
|
let answer;
|
|
114300
114556
|
try {
|
|
114301
|
-
answer = await transport.request({ method: "POST", path:
|
|
114557
|
+
answer = await transport.request({ method: "POST", path: path54, headers: { ...headers, "content-type": "application/json" }, body });
|
|
114302
114558
|
} catch (error63) {
|
|
114303
114559
|
return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
|
|
114304
114560
|
}
|
|
@@ -114329,10 +114585,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
114329
114585
|
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}`),
|
|
114330
114586
|
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}`),
|
|
114331
114587
|
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}`),
|
|
114332
|
-
readFile: async (sessionId,
|
|
114588
|
+
readFile: async (sessionId, path54, options) => await writeOf(
|
|
114333
114589
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
114334
|
-
JSON.stringify({ session: sessionId, path:
|
|
114335
|
-
(status, message) => `reading ${
|
|
114590
|
+
JSON.stringify({ session: sessionId, path: path54, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
114591
|
+
(status, message) => `reading ${path54} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
114336
114592
|
),
|
|
114337
114593
|
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}`),
|
|
114338
114594
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -114626,12 +114882,12 @@ function tlsFacts(options) {
|
|
|
114626
114882
|
}
|
|
114627
114883
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
114628
114884
|
const agent = new ExemptTlsAgent();
|
|
114629
|
-
const post = async (
|
|
114885
|
+
const post = async (path54, headers, body) => await new Promise((resolve2, reject) => {
|
|
114630
114886
|
const options = {
|
|
114631
114887
|
host: target.host,
|
|
114632
114888
|
port: target.port,
|
|
114633
114889
|
method: "POST",
|
|
114634
|
-
path:
|
|
114890
|
+
path: path54,
|
|
114635
114891
|
// 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.
|
|
114636
114892
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
114637
114893
|
agent
|
|
@@ -114696,12 +114952,12 @@ function lateRcStreamDial(resolve2) {
|
|
|
114696
114952
|
}
|
|
114697
114953
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
114698
114954
|
const agent = new ExemptTlsAgent();
|
|
114699
|
-
const request7 = async (method,
|
|
114955
|
+
const request7 = async (method, path54, headers, body, signal) => await new Promise((resolve2, reject) => {
|
|
114700
114956
|
const options = {
|
|
114701
114957
|
host: target.host,
|
|
114702
114958
|
port: target.port,
|
|
114703
114959
|
method,
|
|
114704
|
-
path:
|
|
114960
|
+
path: path54,
|
|
114705
114961
|
// 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.
|
|
114706
114962
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
114707
114963
|
agent,
|
|
@@ -114743,9 +114999,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
114743
114999
|
return { status, body: await readAll(response) };
|
|
114744
115000
|
},
|
|
114745
115001
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
114746
|
-
const
|
|
115002
|
+
const path54 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
114747
115003
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
114748
|
-
const { status, response } = await request7("GET",
|
|
115004
|
+
const { status, response } = await request7("GET", path54, streamHeaders, void 0, signal);
|
|
114749
115005
|
if (!isSuccessful2(status)) {
|
|
114750
115006
|
await readAll(response);
|
|
114751
115007
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -114961,10 +115217,10 @@ init_claudeShim();
|
|
|
114961
115217
|
init_store();
|
|
114962
115218
|
init_realPorts();
|
|
114963
115219
|
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
114964
|
-
var
|
|
115220
|
+
var import_node_path42 = __toESM(require("node:path"), 1);
|
|
114965
115221
|
|
|
114966
115222
|
// src/usage/signIn.ts
|
|
114967
|
-
var
|
|
115223
|
+
var import_node_path41 = __toESM(require("node:path"), 1);
|
|
114968
115224
|
var CREDENTIALS_FILE = ".credentials.json";
|
|
114969
115225
|
function keychainHasItem(run, account) {
|
|
114970
115226
|
return run.run("security", ["find-generic-password", "-a", account]).status === 0;
|
|
@@ -114982,7 +115238,7 @@ function decideSignIn(facts) {
|
|
|
114982
115238
|
return { state: "signed-out", detail: facts.platform === "darwin" ? `no Keychain item and no ${CREDENTIALS_FILE}` : `no ${CREDENTIALS_FILE}` };
|
|
114983
115239
|
}
|
|
114984
115240
|
function credentialsFilePath(farmRoot) {
|
|
114985
|
-
return
|
|
115241
|
+
return import_node_path41.default.join(farmRoot, CREDENTIALS_FILE);
|
|
114986
115242
|
}
|
|
114987
115243
|
function identitySignIn(fs22, probe, identity) {
|
|
114988
115244
|
const probing = !identity.hasCredentialBlock;
|
|
@@ -115108,7 +115364,7 @@ function tcpPortEraRecord(raw) {
|
|
|
115108
115364
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
115109
115365
|
}
|
|
115110
115366
|
function pushPathResolution(push, resolution) {
|
|
115111
|
-
const ownDir =
|
|
115367
|
+
const ownDir = import_node_path42.default.dirname(resolution.ownExecutablePath);
|
|
115112
115368
|
switch (resolution.agentShim.status) {
|
|
115113
115369
|
case "ok":
|
|
115114
115370
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -115207,14 +115463,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
|
|
|
115207
115463
|
}
|
|
115208
115464
|
function pushLegacyName(push, params) {
|
|
115209
115465
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
115210
|
-
if (legacyVariables.length === 0 &&
|
|
115466
|
+
if (legacyVariables.length === 0 && import_node_path42.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
115211
115467
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
115212
115468
|
return;
|
|
115213
115469
|
}
|
|
115214
115470
|
for (const name of legacyVariables) {
|
|
115215
115471
|
push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
|
|
115216
115472
|
}
|
|
115217
|
-
if (
|
|
115473
|
+
if (import_node_path42.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
115218
115474
|
push(
|
|
115219
115475
|
"legacy-name",
|
|
115220
115476
|
"warn",
|
|
@@ -115587,18 +115843,18 @@ function collectDoctorReport(params) {
|
|
|
115587
115843
|
const { paths } = params;
|
|
115588
115844
|
const identityNames = import_node_fs15.default.existsSync(paths.identitiesDir) ? import_node_fs15.default.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
|
|
115589
115845
|
const identities = identityNames.map((name) => {
|
|
115590
|
-
const farmRoot =
|
|
115591
|
-
const identityPath =
|
|
115846
|
+
const farmRoot = import_node_path42.default.join(paths.identitiesDir, name);
|
|
115847
|
+
const identityPath = import_node_path42.default.join(farmRoot, "identity.json");
|
|
115592
115848
|
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs15.default.existsSync(credentialsFilePath(farmRoot)) };
|
|
115593
115849
|
});
|
|
115594
115850
|
const profileNames = import_node_fs15.default.existsSync(paths.configProfilesDir) ? import_node_fs15.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
115595
115851
|
const configProfiles = profileNames.map((name) => {
|
|
115596
|
-
const profilePath =
|
|
115852
|
+
const profilePath = import_node_path42.default.join(paths.configProfilesDir, `${name}.json`);
|
|
115597
115853
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
115598
115854
|
});
|
|
115599
115855
|
const providerNames = import_node_fs15.default.existsSync(paths.providersDir) ? import_node_fs15.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
115600
115856
|
const providers = providerNames.map((name) => {
|
|
115601
|
-
const providerPath =
|
|
115857
|
+
const providerPath = import_node_path42.default.join(paths.providersDir, `${name}.json`);
|
|
115602
115858
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
115603
115859
|
});
|
|
115604
115860
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -115610,12 +115866,12 @@ function collectDoctorReport(params) {
|
|
|
115610
115866
|
binaryDiscovery = { ok: false, message: error63 instanceof Error ? error63.message : String(error63) };
|
|
115611
115867
|
}
|
|
115612
115868
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
115613
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
115869
|
+
const pathDirs = (params.env.PATH ?? "").split(import_node_path42.default.delimiter).filter((dir) => dir !== "");
|
|
115614
115870
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
115615
115871
|
findPathShadow({
|
|
115616
115872
|
pathDirs,
|
|
115617
|
-
targetDir:
|
|
115618
|
-
targetFilename:
|
|
115873
|
+
targetDir: import_node_path42.default.dirname(shimState.targetPath),
|
|
115874
|
+
targetFilename: import_node_path42.default.basename(shimState.targetPath),
|
|
115619
115875
|
findExecutableInDir
|
|
115620
115876
|
}),
|
|
115621
115877
|
shimState.targetPath,
|
|
@@ -115644,7 +115900,7 @@ function collectDoctorReport(params) {
|
|
|
115644
115900
|
agentShim: refinePathShadow(
|
|
115645
115901
|
findPathShadow({
|
|
115646
115902
|
pathDirs,
|
|
115647
|
-
targetDir:
|
|
115903
|
+
targetDir: import_node_path42.default.dirname(ownExecutablePath),
|
|
115648
115904
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
115649
115905
|
findExecutableInDir
|
|
115650
115906
|
}),
|
|
@@ -115907,11 +116163,11 @@ function tryOrUndefined(fn2) {
|
|
|
115907
116163
|
return void 0;
|
|
115908
116164
|
}
|
|
115909
116165
|
}
|
|
115910
|
-
function pathToHttpPath(
|
|
115911
|
-
return `/${
|
|
116166
|
+
function pathToHttpPath(path54) {
|
|
116167
|
+
return `/${path54.map(safeEncodeURIComponent).join("/")}`;
|
|
115912
116168
|
}
|
|
115913
|
-
function normalizeHttpPath(
|
|
115914
|
-
const paths =
|
|
116169
|
+
function normalizeHttpPath(path54) {
|
|
116170
|
+
const paths = path54.split("/");
|
|
115915
116171
|
if (paths.at(0) === "") {
|
|
115916
116172
|
paths.shift();
|
|
115917
116173
|
}
|
|
@@ -116096,9 +116352,9 @@ function isPlainObject2(value2) {
|
|
|
116096
116352
|
function getOwn(object3, key) {
|
|
116097
116353
|
return Object.hasOwn(object3, key) ? object3[key] : void 0;
|
|
116098
116354
|
}
|
|
116099
|
-
function get(object3,
|
|
116355
|
+
function get(object3, path54) {
|
|
116100
116356
|
let current = object3;
|
|
116101
|
-
for (const key of
|
|
116357
|
+
for (const key of path54) {
|
|
116102
116358
|
if (!isTypescriptObject(current)) {
|
|
116103
116359
|
return void 0;
|
|
116104
116360
|
}
|
|
@@ -117321,7 +117577,7 @@ function resolveClientRest(rest) {
|
|
|
117321
117577
|
// rest[1] can be undefined if all fields of FriendlyClientOptions are optional
|
|
117322
117578
|
];
|
|
117323
117579
|
}
|
|
117324
|
-
function createORPCClient(link, { path:
|
|
117580
|
+
function createORPCClient(link, { path: path54 = [], ...options } = {}) {
|
|
117325
117581
|
const procedureClient = (...rest) => {
|
|
117326
117582
|
const [input2, callOptions] = resolveClientRest(rest);
|
|
117327
117583
|
const interceptors = [
|
|
@@ -117330,7 +117586,7 @@ function createORPCClient(link, { path: path52 = [], ...options } = {}) {
|
|
|
117330
117586
|
];
|
|
117331
117587
|
return intercept(
|
|
117332
117588
|
interceptors,
|
|
117333
|
-
{ ...callOptions, input: input2, path:
|
|
117589
|
+
{ ...callOptions, input: input2, path: path54 },
|
|
117334
117590
|
({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
|
|
117335
117591
|
);
|
|
117336
117592
|
};
|
|
@@ -117344,7 +117600,7 @@ function createORPCClient(link, { path: path52 = [], ...options } = {}) {
|
|
|
117344
117600
|
if (client === void 0) {
|
|
117345
117601
|
client = createORPCClient(link, {
|
|
117346
117602
|
...options,
|
|
117347
|
-
path: [...
|
|
117603
|
+
path: [...path54, key],
|
|
117348
117604
|
scoped: options.scoped?.[key]
|
|
117349
117605
|
});
|
|
117350
117606
|
cache.set(key, client);
|
|
@@ -117366,24 +117622,24 @@ var BracketNotationSerializer = class {
|
|
|
117366
117622
|
this.internalSerialize(data, "", true, result);
|
|
117367
117623
|
return result;
|
|
117368
117624
|
}
|
|
117369
|
-
internalSerialize(data,
|
|
117625
|
+
internalSerialize(data, path54, isRoot, result) {
|
|
117370
117626
|
if (Array.isArray(data)) {
|
|
117371
117627
|
data.forEach((item, i10) => {
|
|
117372
|
-
this.internalSerialize(item, isRoot ? i10.toString() : `${
|
|
117628
|
+
this.internalSerialize(item, isRoot ? i10.toString() : `${path54}[${i10}]`, false, result);
|
|
117373
117629
|
});
|
|
117374
117630
|
} else if (isPlainObject2(data)) {
|
|
117375
117631
|
for (const key of Object.keys(data)) {
|
|
117376
|
-
this.internalSerialize(data[key], isRoot ? key : `${
|
|
117632
|
+
this.internalSerialize(data[key], isRoot ? key : `${path54}[${key}]`, false, result);
|
|
117377
117633
|
}
|
|
117378
117634
|
} else {
|
|
117379
|
-
result.push([
|
|
117635
|
+
result.push([path54, data]);
|
|
117380
117636
|
}
|
|
117381
117637
|
}
|
|
117382
117638
|
deserialize(serialized) {
|
|
117383
117639
|
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
117384
117640
|
const root = new NullProtoObj();
|
|
117385
|
-
for (const [
|
|
117386
|
-
const segments = this.parsePath(
|
|
117641
|
+
for (const [path54, value2] of serialized) {
|
|
117642
|
+
const segments = this.parsePath(path54);
|
|
117387
117643
|
let currentRef = root;
|
|
117388
117644
|
let nextSegment = segments[0];
|
|
117389
117645
|
for (let i10 = 1; i10 < segments.length; i10++) {
|
|
@@ -117434,13 +117690,13 @@ var BracketNotationSerializer = class {
|
|
|
117434
117690
|
}
|
|
117435
117691
|
return result;
|
|
117436
117692
|
}
|
|
117437
|
-
parsePath(
|
|
117693
|
+
parsePath(path54) {
|
|
117438
117694
|
const segments = [];
|
|
117439
117695
|
let inBrackets = false;
|
|
117440
117696
|
let currentSegment = "";
|
|
117441
|
-
for (let i10 = 0; i10 <
|
|
117442
|
-
const char =
|
|
117443
|
-
const nextChar =
|
|
117697
|
+
for (let i10 = 0; i10 < path54.length; i10++) {
|
|
117698
|
+
const char = path54[i10];
|
|
117699
|
+
const nextChar = path54[i10 + 1];
|
|
117444
117700
|
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
|
|
117445
117701
|
if (nextChar === void 0) {
|
|
117446
117702
|
inBrackets = false;
|
|
@@ -117456,7 +117712,7 @@ var BracketNotationSerializer = class {
|
|
|
117456
117712
|
currentSegment += char;
|
|
117457
117713
|
}
|
|
117458
117714
|
}
|
|
117459
|
-
return inBrackets || segments.length === 0 ? [
|
|
117715
|
+
return inBrackets || segments.length === 0 ? [path54] : segments;
|
|
117460
117716
|
}
|
|
117461
117717
|
};
|
|
117462
117718
|
var INTEGER_PATTERN = /^0$|^[1-9]\d*$/;
|
|
@@ -118029,11 +118285,11 @@ var OpenAPISerializer = class {
|
|
|
118029
118285
|
return json2;
|
|
118030
118286
|
}
|
|
118031
118287
|
const form = new FormData();
|
|
118032
|
-
for (const [
|
|
118288
|
+
for (const [path54, value22] of this.bracketNotation.serialize(json2)) {
|
|
118033
118289
|
if (value22 instanceof Blob) {
|
|
118034
|
-
form.append(
|
|
118290
|
+
form.append(path54, value22);
|
|
118035
118291
|
} else if (value22 !== void 0 && value22 !== null) {
|
|
118036
|
-
form.append(
|
|
118292
|
+
form.append(path54, String(value22));
|
|
118037
118293
|
}
|
|
118038
118294
|
}
|
|
118039
118295
|
return form;
|
|
@@ -118071,30 +118327,30 @@ function isBodylessMethod(method) {
|
|
|
118071
118327
|
return method === "GET" || method === "HEAD";
|
|
118072
118328
|
}
|
|
118073
118329
|
var PARAMETER_NAME_REGEX = /^[\w-]+$/;
|
|
118074
|
-
function getDynamicPathParams(
|
|
118075
|
-
if (!
|
|
118330
|
+
function getDynamicPathParams(path54) {
|
|
118331
|
+
if (!path54.includes("{")) {
|
|
118076
118332
|
return void 0;
|
|
118077
118333
|
}
|
|
118078
|
-
const len =
|
|
118334
|
+
const len = path54.length;
|
|
118079
118335
|
let params;
|
|
118080
118336
|
let index = 1;
|
|
118081
118337
|
while (index < len) {
|
|
118082
118338
|
const segmentStart = index;
|
|
118083
|
-
const slashPos =
|
|
118339
|
+
const slashPos = path54.indexOf("/", index);
|
|
118084
118340
|
const segmentEnd = slashPos === -1 ? len : slashPos;
|
|
118085
|
-
if (segmentEnd > segmentStart &&
|
|
118341
|
+
if (segmentEnd > segmentStart && path54.charCodeAt(segmentStart) === 123 && path54.charCodeAt(segmentEnd - 1) === 125) {
|
|
118086
118342
|
let parameterStart = segmentStart + 1;
|
|
118087
118343
|
let allowsSlash = false;
|
|
118088
|
-
const operator =
|
|
118344
|
+
const operator = path54.charCodeAt(parameterStart);
|
|
118089
118345
|
if (operator === 43) {
|
|
118090
118346
|
allowsSlash = true;
|
|
118091
118347
|
parameterStart++;
|
|
118092
118348
|
}
|
|
118093
|
-
const parameterName =
|
|
118349
|
+
const parameterName = path54.slice(parameterStart, segmentEnd - 1);
|
|
118094
118350
|
if (PARAMETER_NAME_REGEX.test(parameterName)) {
|
|
118095
118351
|
params ??= [];
|
|
118096
118352
|
params.push({
|
|
118097
|
-
segment:
|
|
118353
|
+
segment: path54.slice(segmentStart, segmentEnd),
|
|
118098
118354
|
startIndex: segmentStart,
|
|
118099
118355
|
parameterName,
|
|
118100
118356
|
allowsSlash
|
|
@@ -118137,8 +118393,8 @@ openapi.method = (method) => ({
|
|
|
118137
118393
|
...openapi({ method }),
|
|
118138
118394
|
name: "~openapi/method"
|
|
118139
118395
|
});
|
|
118140
|
-
openapi.path = (
|
|
118141
|
-
...openapi({ path:
|
|
118396
|
+
openapi.path = (path54) => ({
|
|
118397
|
+
...openapi({ path: path54 }),
|
|
118142
118398
|
name: "~openapi/path"
|
|
118143
118399
|
});
|
|
118144
118400
|
openapi.spec = (spec) => ({
|
|
@@ -118999,22 +119255,22 @@ function visitJsonSchemaRefs(value2, visit2, schemaLevel = true, seen = /* @__PU
|
|
|
118999
119255
|
}
|
|
119000
119256
|
}
|
|
119001
119257
|
}
|
|
119002
|
-
function mapJsonSchemaRefs(value2, map2, schemaLevel = true,
|
|
119258
|
+
function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path54 = []) {
|
|
119003
119259
|
if (!value2 || typeof value2 !== "object") {
|
|
119004
119260
|
return value2;
|
|
119005
119261
|
}
|
|
119006
119262
|
if (Array.isArray(value2)) {
|
|
119007
|
-
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...
|
|
119263
|
+
return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path54, index]));
|
|
119008
119264
|
}
|
|
119009
119265
|
const result = {};
|
|
119010
119266
|
for (const key of Object.keys(value2)) {
|
|
119011
119267
|
const val = value2[key];
|
|
119012
119268
|
if (key === "$ref" && typeof val === "string") {
|
|
119013
|
-
setOwn(result, key, map2(val, [...
|
|
119269
|
+
setOwn(result, key, map2(val, [...path54, key]));
|
|
119014
119270
|
} else if (!schemaLevel) {
|
|
119015
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...
|
|
119271
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path54, key]));
|
|
119016
119272
|
} else if (JSON_SCHEMA_LOGIC_KEYWORDS.has(key) || JSON_SCHEMA_RECORD_KEYWORDS.has(key)) {
|
|
119017
|
-
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...
|
|
119273
|
+
setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path54, key]));
|
|
119018
119274
|
} else {
|
|
119019
119275
|
setOwn(result, key, val);
|
|
119020
119276
|
}
|
|
@@ -119544,7 +119800,7 @@ function unlazy(maybeLazy) {
|
|
|
119544
119800
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
119545
119801
|
const options = resolveMaybeOptionalOptions(rest);
|
|
119546
119802
|
return async (...[input2, callerOptions]) => {
|
|
119547
|
-
const
|
|
119803
|
+
const path54 = toArray(options.path);
|
|
119548
119804
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
119549
119805
|
const clientContext = callerOptions?.context ?? {};
|
|
119550
119806
|
const context = await value(options.context, clientContext) ?? {};
|
|
@@ -119557,7 +119813,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
119557
119813
|
};
|
|
119558
119814
|
try {
|
|
119559
119815
|
const output2 = await runWithSpan("call_procedure", (span) => {
|
|
119560
|
-
span?.setAttribute("procedure.path",
|
|
119816
|
+
span?.setAttribute("procedure.path", path54);
|
|
119561
119817
|
return intercept(
|
|
119562
119818
|
options.interceptors,
|
|
119563
119819
|
{
|
|
@@ -119565,7 +119821,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
119565
119821
|
// input can be optional if it is undefinable
|
|
119566
119822
|
input: input2,
|
|
119567
119823
|
errors,
|
|
119568
|
-
path:
|
|
119824
|
+
path: path54,
|
|
119569
119825
|
procedure,
|
|
119570
119826
|
signal: callerOptions?.signal,
|
|
119571
119827
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -119816,10 +120072,10 @@ function augmentRouter(router, options) {
|
|
|
119816
120072
|
}
|
|
119817
120073
|
return enhanced;
|
|
119818
120074
|
}
|
|
119819
|
-
function getRouter(router,
|
|
120075
|
+
function getRouter(router, path54) {
|
|
119820
120076
|
let current = router;
|
|
119821
|
-
for (let i10 = 0; i10 <
|
|
119822
|
-
const segment =
|
|
120077
|
+
for (let i10 = 0; i10 < path54.length; i10++) {
|
|
120078
|
+
const segment = path54[i10];
|
|
119823
120079
|
if (!isTypescriptObject(current)) {
|
|
119824
120080
|
return void 0;
|
|
119825
120081
|
}
|
|
@@ -119831,7 +120087,7 @@ function getRouter(router, path52) {
|
|
|
119831
120087
|
continue;
|
|
119832
120088
|
}
|
|
119833
120089
|
const lazied = current;
|
|
119834
|
-
const rest =
|
|
120090
|
+
const rest = path54.slice(i10);
|
|
119835
120091
|
return new Lazy({
|
|
119836
120092
|
...lazied["~orpc"],
|
|
119837
120093
|
async loader() {
|
|
@@ -119846,40 +120102,40 @@ function getRouter(router, path52) {
|
|
|
119846
120102
|
}
|
|
119847
120103
|
return current;
|
|
119848
120104
|
}
|
|
119849
|
-
function walkProcedureContractsSync(router, callback,
|
|
120105
|
+
function walkProcedureContractsSync(router, callback, path54 = []) {
|
|
119850
120106
|
const lazyResults = [];
|
|
119851
|
-
walkProcedureContractsSyncInternal(router, callback,
|
|
120107
|
+
walkProcedureContractsSyncInternal(router, callback, path54.slice(), lazyResults);
|
|
119852
120108
|
return lazyResults;
|
|
119853
120109
|
}
|
|
119854
|
-
function walkProcedureContractsSyncInternal(router, callback,
|
|
120110
|
+
function walkProcedureContractsSyncInternal(router, callback, path54, lazyResults) {
|
|
119855
120111
|
const hiddenContract = getHiddenRouterContract(router);
|
|
119856
120112
|
if (hiddenContract !== void 0) {
|
|
119857
120113
|
router = hiddenContract;
|
|
119858
120114
|
}
|
|
119859
120115
|
if (router instanceof ProcedureContract) {
|
|
119860
|
-
callback(router,
|
|
120116
|
+
callback(router, path54.slice());
|
|
119861
120117
|
return;
|
|
119862
120118
|
}
|
|
119863
120119
|
if (!isTypescriptObject(router)) {
|
|
119864
120120
|
return;
|
|
119865
120121
|
}
|
|
119866
120122
|
for (const [key, value2] of Object.entries(router)) {
|
|
119867
|
-
|
|
120123
|
+
path54.push(key);
|
|
119868
120124
|
if (value2 instanceof Lazy) {
|
|
119869
|
-
lazyResults.push({ router: value2, path:
|
|
120125
|
+
lazyResults.push({ router: value2, path: path54.slice() });
|
|
119870
120126
|
} else {
|
|
119871
|
-
walkProcedureContractsSyncInternal(value2, callback,
|
|
120127
|
+
walkProcedureContractsSyncInternal(value2, callback, path54, lazyResults);
|
|
119872
120128
|
}
|
|
119873
|
-
|
|
120129
|
+
path54.pop();
|
|
119874
120130
|
}
|
|
119875
120131
|
}
|
|
119876
|
-
async function walkProcedureContractsAsync(router, callback,
|
|
120132
|
+
async function walkProcedureContractsAsync(router, callback, path54 = []) {
|
|
119877
120133
|
const hiddenContract = getHiddenRouterContract(router);
|
|
119878
120134
|
if (hiddenContract !== void 0) {
|
|
119879
120135
|
router = hiddenContract;
|
|
119880
120136
|
}
|
|
119881
120137
|
if (router instanceof ProcedureContract) {
|
|
119882
|
-
await callback(router,
|
|
120138
|
+
await callback(router, path54);
|
|
119883
120139
|
return;
|
|
119884
120140
|
}
|
|
119885
120141
|
if (!isTypescriptObject(router)) {
|
|
@@ -119888,9 +120144,9 @@ async function walkProcedureContractsAsync(router, callback, path52 = []) {
|
|
|
119888
120144
|
for (const [key, value2] of Object.entries(router)) {
|
|
119889
120145
|
if (value2 instanceof Lazy) {
|
|
119890
120146
|
const { default: router2 } = await unlazy(value2);
|
|
119891
|
-
await walkProcedureContractsAsync(router2, callback, [...
|
|
120147
|
+
await walkProcedureContractsAsync(router2, callback, [...path54, key]);
|
|
119892
120148
|
} else {
|
|
119893
|
-
await walkProcedureContractsAsync(value2, callback, [...
|
|
120149
|
+
await walkProcedureContractsAsync(value2, callback, [...path54, key]);
|
|
119894
120150
|
}
|
|
119895
120151
|
}
|
|
119896
120152
|
}
|
|
@@ -120376,18 +120632,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
|
|
|
120376
120632
|
}
|
|
120377
120633
|
var OpenAPIGeneratorError = class extends TypeError {
|
|
120378
120634
|
};
|
|
120379
|
-
function toOpenAPIPath(
|
|
120635
|
+
function toOpenAPIPath(path54, dynamicPathParams) {
|
|
120380
120636
|
if (!dynamicPathParams?.length) {
|
|
120381
|
-
return
|
|
120637
|
+
return path54;
|
|
120382
120638
|
}
|
|
120383
120639
|
let normalized = "";
|
|
120384
120640
|
let currentIndex = 0;
|
|
120385
120641
|
for (const param of dynamicPathParams) {
|
|
120386
|
-
normalized +=
|
|
120642
|
+
normalized += path54.slice(currentIndex, param.startIndex);
|
|
120387
120643
|
normalized += `{${param.parameterName}}`;
|
|
120388
120644
|
currentIndex = param.startIndex + param.segment.length;
|
|
120389
120645
|
}
|
|
120390
|
-
normalized +=
|
|
120646
|
+
normalized += path54.slice(currentIndex);
|
|
120391
120647
|
return normalized;
|
|
120392
120648
|
}
|
|
120393
120649
|
function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
|
|
@@ -120821,8 +121077,8 @@ var OpenAPIGenerator = class {
|
|
|
120821
121077
|
customErrorResponseBodySchema: options.customErrorResponseBodySchema
|
|
120822
121078
|
};
|
|
120823
121079
|
const errors = [];
|
|
120824
|
-
await walkProcedureContractsAsync(router, (contract,
|
|
120825
|
-
if (value(options.filter, contract,
|
|
121080
|
+
await walkProcedureContractsAsync(router, (contract, path54) => {
|
|
121081
|
+
if (value(options.filter, contract, path54) === false) {
|
|
120826
121082
|
return;
|
|
120827
121083
|
}
|
|
120828
121084
|
try {
|
|
@@ -120834,7 +121090,7 @@ var OpenAPIGenerator = class {
|
|
|
120834
121090
|
`QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
|
|
120835
121091
|
);
|
|
120836
121092
|
}
|
|
120837
|
-
const postPath = meta3?.path ?? pathToHttpPath(
|
|
121093
|
+
const postPath = meta3?.path ?? pathToHttpPath(path54);
|
|
120838
121094
|
const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
|
|
120839
121095
|
const dynamicPathParams = getDynamicPathParams(httpPath);
|
|
120840
121096
|
const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
|
|
@@ -120843,7 +121099,7 @@ var OpenAPIGenerator = class {
|
|
|
120843
121099
|
operation = meta3.spec;
|
|
120844
121100
|
} else {
|
|
120845
121101
|
operation = {
|
|
120846
|
-
operationId: meta3?.operationId ??
|
|
121102
|
+
operationId: meta3?.operationId ?? path54.join("."),
|
|
120847
121103
|
summary: meta3?.summary,
|
|
120848
121104
|
description: meta3?.description,
|
|
120849
121105
|
deprecated: meta3?.deprecated,
|
|
@@ -120863,7 +121119,7 @@ var OpenAPIGenerator = class {
|
|
|
120863
121119
|
if (!(e14 instanceof OpenAPIGeneratorError)) {
|
|
120864
121120
|
throw e14;
|
|
120865
121121
|
}
|
|
120866
|
-
errors.push(`Procedure at ${
|
|
121122
|
+
errors.push(`Procedure at ${path54.join(".") || "(root)"}: ${e14.message}`);
|
|
120867
121123
|
}
|
|
120868
121124
|
});
|
|
120869
121125
|
if (errors.length) {
|
|
@@ -121171,7 +121427,7 @@ var ResetRowSchema = external_exports.strictObject({
|
|
|
121171
121427
|
var ResetScheduleSchema = external_exports.strictObject({ resets: external_exports.readonly(external_exports.array(ResetRowSchema)) });
|
|
121172
121428
|
|
|
121173
121429
|
// src/frontdoor/controlSchemas.ts
|
|
121174
|
-
var
|
|
121430
|
+
var import_node_path43 = __toESM(require("node:path"), 1);
|
|
121175
121431
|
init_zod();
|
|
121176
121432
|
init_schema2();
|
|
121177
121433
|
|
|
@@ -121383,11 +121639,11 @@ var FrontDoorSessionsOutputSchema = external_exports.strictObject({ sessions: ex
|
|
|
121383
121639
|
var CheckRunInputSchema = external_exports.strictObject({
|
|
121384
121640
|
path: external_exports.string().min(1),
|
|
121385
121641
|
identity: external_exports.string().min(1).optional()
|
|
121386
|
-
}).refine((input2) =>
|
|
121642
|
+
}).refine((input2) => import_node_path43.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
121387
121643
|
var PoolPickInputSchema = external_exports.strictObject({
|
|
121388
121644
|
pool: external_exports.string().min(1),
|
|
121389
121645
|
path: external_exports.string().min(1)
|
|
121390
|
-
}).refine((input2) =>
|
|
121646
|
+
}).refine((input2) => import_node_path43.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
121391
121647
|
var DoctorFindingSchema = external_exports.strictObject({
|
|
121392
121648
|
section: external_exports.enum(DOCTOR_SECTIONS),
|
|
121393
121649
|
subject: external_exports.string().optional(),
|
|
@@ -121708,16 +121964,16 @@ var StandardLink = class {
|
|
|
121708
121964
|
/**
|
|
121709
121965
|
* @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
|
|
121710
121966
|
*/
|
|
121711
|
-
call(
|
|
121712
|
-
return runWithSpan(`${ORPC_NAME}.${
|
|
121967
|
+
call(path54, input2, options) {
|
|
121968
|
+
return runWithSpan(`${ORPC_NAME}.${path54.join("/")}`, (span) => {
|
|
121713
121969
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
121714
|
-
span?.setAttribute("rpc.method",
|
|
121970
|
+
span?.setAttribute("rpc.method", path54.join("."));
|
|
121715
121971
|
if (getTracer() && isAsyncIteratorObject(input2)) {
|
|
121716
121972
|
input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
|
|
121717
121973
|
} else if (getTracer() && input2 instanceof ReadableStream) {
|
|
121718
121974
|
input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
|
|
121719
121975
|
}
|
|
121720
|
-
return intercept(this.interceptors, { ...options, path:
|
|
121976
|
+
return intercept(this.interceptors, { ...options, path: path54, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
121721
121977
|
const tracer = getTracer();
|
|
121722
121978
|
const activeSpan = tracer?.getActiveSpan() ?? span;
|
|
121723
121979
|
let request7 = await runWithSpan(
|
|
@@ -121774,18 +122030,18 @@ var RPCLinkCodec = class {
|
|
|
121774
122030
|
this.headers = options.headers ?? {};
|
|
121775
122031
|
this.serializer = options.serializer ?? new RPCSerializer();
|
|
121776
122032
|
}
|
|
121777
|
-
async encodeInput(input2,
|
|
121778
|
-
let headers = toResolvedStandardHeaders(await value(this.headers, options,
|
|
122033
|
+
async encodeInput(input2, path54, options) {
|
|
122034
|
+
let headers = toResolvedStandardHeaders(await value(this.headers, options, path54, input2));
|
|
121779
122035
|
if (options.lastEventId !== void 0) {
|
|
121780
122036
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
121781
122037
|
}
|
|
121782
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
121783
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
122038
|
+
const expectedMethod = await value(this.expectedMethod, options, path54, input2);
|
|
122039
|
+
const baseUrl = await value(this.baseUrl, options, path54, input2);
|
|
121784
122040
|
const [pathname, search, hash2] = parseStandardUrl(baseUrl);
|
|
121785
|
-
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(
|
|
122041
|
+
const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path54)}`;
|
|
121786
122042
|
const serialized = this.serializer.serialize(input2);
|
|
121787
122043
|
if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
121788
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
122044
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path54, input2);
|
|
121789
122045
|
const mergedSearch = new URLSearchParams(search);
|
|
121790
122046
|
mergedSearch.append("data", stringifyJSON(serialized) ?? "");
|
|
121791
122047
|
const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
|
|
@@ -121870,8 +122126,8 @@ var FetchLinkTransport = class {
|
|
|
121870
122126
|
this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
|
|
121871
122127
|
this.toFetchRequestOptions = options.toFetchRequest;
|
|
121872
122128
|
}
|
|
121873
|
-
async send(standardRequest,
|
|
121874
|
-
let origin = await value(this.origin, options,
|
|
122129
|
+
async send(standardRequest, path54, options) {
|
|
122130
|
+
let origin = await value(this.origin, options, path54);
|
|
121875
122131
|
if (origin?.endsWith("/")) {
|
|
121876
122132
|
origin = origin.slice(0, -1);
|
|
121877
122133
|
}
|
|
@@ -121891,7 +122147,7 @@ var FetchLinkTransport = class {
|
|
|
121891
122147
|
}
|
|
121892
122148
|
}
|
|
121893
122149
|
const fetch3 = this.fetch;
|
|
121894
|
-
const response = await fetch3(url2, init, options,
|
|
122150
|
+
const response = await fetch3(url2, init, options, path54);
|
|
121895
122151
|
const standardResponse = toStandardLazyResponse(response);
|
|
121896
122152
|
return standardResponse;
|
|
121897
122153
|
}
|
|
@@ -122282,14 +122538,14 @@ var StandardHandler = class {
|
|
|
122282
122538
|
span?.setAttribute("url.path", request22.url);
|
|
122283
122539
|
return { matched: false };
|
|
122284
122540
|
}
|
|
122285
|
-
const { path:
|
|
122286
|
-
span?.updateName(`${ORPC_NAME}.${
|
|
122541
|
+
const { path: path54, procedure, decodeInput } = matchedOrNot;
|
|
122542
|
+
span?.updateName(`${ORPC_NAME}.${path54.join("/")}`);
|
|
122287
122543
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
122288
|
-
span?.setAttribute("rpc.method",
|
|
122544
|
+
span?.setAttribute("rpc.method", path54.join("."));
|
|
122289
122545
|
try {
|
|
122290
122546
|
const response = await intercept(
|
|
122291
122547
|
this.interceptors,
|
|
122292
|
-
{ context: context2, prefix: prefix2, request: request22, path:
|
|
122548
|
+
{ context: context2, prefix: prefix2, request: request22, path: path54, procedure, decodeInput },
|
|
122293
122549
|
async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
|
|
122294
122550
|
step2 = "decode_input";
|
|
122295
122551
|
let input2 = await runWithSpan("decode_input", decodeInput2);
|
|
@@ -122323,7 +122579,7 @@ var StandardHandler = class {
|
|
|
122323
122579
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
122324
122580
|
cause: e14
|
|
122325
122581
|
}) : toORPCError(e14);
|
|
122326
|
-
const response = await this.codec.encodeError(error63, procedure,
|
|
122582
|
+
const response = await this.codec.encodeError(error63, procedure, path54, { context: context2, prefix: prefix2 });
|
|
122327
122583
|
return { matched: true, response };
|
|
122328
122584
|
}
|
|
122329
122585
|
}
|
|
@@ -122429,7 +122685,7 @@ var RPCMatcher = class {
|
|
|
122429
122685
|
this.rootRouter = router;
|
|
122430
122686
|
this.index(router);
|
|
122431
122687
|
}
|
|
122432
|
-
index(router,
|
|
122688
|
+
index(router, path54 = []) {
|
|
122433
122689
|
const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
|
|
122434
122690
|
if (!value(this.filter, procedure, procedurePath)) {
|
|
122435
122691
|
return;
|
|
@@ -122440,7 +122696,7 @@ var RPCMatcher = class {
|
|
|
122440
122696
|
// contract-first entries have no implementation yet, resolveProcedure fills it in on demand
|
|
122441
122697
|
procedure: procedure instanceof Procedure ? procedure : void 0
|
|
122442
122698
|
});
|
|
122443
|
-
},
|
|
122699
|
+
}, path54);
|
|
122444
122700
|
for (const result of lazyResults) {
|
|
122445
122701
|
this.pendingLazyRouters.set(pathToHttpPath(result.path), result);
|
|
122446
122702
|
}
|
|
@@ -122572,10 +122828,10 @@ var RPCHandlerCodec = class {
|
|
|
122572
122828
|
}
|
|
122573
122829
|
};
|
|
122574
122830
|
}
|
|
122575
|
-
encodeOutput(output2, procedure,
|
|
122831
|
+
encodeOutput(output2, procedure, path54, options) {
|
|
122576
122832
|
return {
|
|
122577
122833
|
headers: {},
|
|
122578
|
-
status: value(this.outputStatus, output2, procedure,
|
|
122834
|
+
status: value(this.outputStatus, output2, procedure, path54, options) ?? DEFAULT_SUCCESS_STATUS,
|
|
122579
122835
|
body: this.serializer.serialize(output2)
|
|
122580
122836
|
};
|
|
122581
122837
|
}
|
|
@@ -122629,39 +122885,39 @@ function createRouter() {
|
|
|
122629
122885
|
static: new NullProtoObj2()
|
|
122630
122886
|
};
|
|
122631
122887
|
}
|
|
122632
|
-
function scanFirstGroup(
|
|
122888
|
+
function scanFirstGroup(path54) {
|
|
122633
122889
|
let i10 = 0;
|
|
122634
122890
|
let depth = 0;
|
|
122635
|
-
for (; i10 <
|
|
122636
|
-
const c10 =
|
|
122891
|
+
for (; i10 < path54.length; i10++) {
|
|
122892
|
+
const c10 = path54.charCodeAt(i10);
|
|
122637
122893
|
if (c10 === 92) i10++;
|
|
122638
122894
|
else if (c10 === 40) depth++;
|
|
122639
122895
|
else if (c10 === 41 && depth > 0) depth--;
|
|
122640
122896
|
else if (c10 === 123 && depth === 0) break;
|
|
122641
122897
|
}
|
|
122642
|
-
if (i10 >=
|
|
122898
|
+
if (i10 >= path54.length) return;
|
|
122643
122899
|
let j10 = i10 + 1;
|
|
122644
122900
|
depth = 0;
|
|
122645
|
-
for (; j10 <
|
|
122646
|
-
const c10 =
|
|
122901
|
+
for (; j10 < path54.length; j10++) {
|
|
122902
|
+
const c10 = path54.charCodeAt(j10);
|
|
122647
122903
|
if (c10 === 92) j10++;
|
|
122648
122904
|
else if (c10 === 40) depth++;
|
|
122649
122905
|
else if (c10 === 41 && depth > 0) depth--;
|
|
122650
122906
|
else if (c10 === 125 && depth === 0) break;
|
|
122651
122907
|
}
|
|
122652
|
-
if (j10 >=
|
|
122653
|
-
const mod =
|
|
122908
|
+
if (j10 >= path54.length) return;
|
|
122909
|
+
const mod = path54[j10 + 1];
|
|
122654
122910
|
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
122655
122911
|
return [
|
|
122656
|
-
|
|
122657
|
-
|
|
122658
|
-
|
|
122912
|
+
path54.slice(0, i10),
|
|
122913
|
+
path54.slice(i10 + 1, j10),
|
|
122914
|
+
path54.slice(j10 + (hasMod ? 2 : 1)),
|
|
122659
122915
|
hasMod ? mod : void 0
|
|
122660
122916
|
];
|
|
122661
122917
|
}
|
|
122662
|
-
function expandGroupDelimiters(
|
|
122663
|
-
if (!
|
|
122664
|
-
const group = scanFirstGroup(
|
|
122918
|
+
function expandGroupDelimiters(path54) {
|
|
122919
|
+
if (!path54.includes("{")) return;
|
|
122920
|
+
const group = scanFirstGroup(path54);
|
|
122665
122921
|
if (!group) return;
|
|
122666
122922
|
const [pre2, body, suf, mod] = group;
|
|
122667
122923
|
if (!mod) return [pre2 + body + suf];
|
|
@@ -122731,9 +122987,9 @@ function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGr
|
|
|
122731
122987
|
}
|
|
122732
122988
|
return [replaced, nextIndex];
|
|
122733
122989
|
}
|
|
122734
|
-
function encodeEscapes(
|
|
122735
|
-
if (!
|
|
122736
|
-
return
|
|
122990
|
+
function encodeEscapes(path54) {
|
|
122991
|
+
if (!path54.includes("\\")) return path54;
|
|
122992
|
+
return path54.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
|
|
122737
122993
|
}
|
|
122738
122994
|
function segmentKey(segment) {
|
|
122739
122995
|
if (segment.startsWith("**")) return 2;
|
|
@@ -122762,22 +123018,22 @@ function expandModifiers(segments) {
|
|
|
122762
123018
|
return m10[2] === "+" ? [wc2] : [wc2, without];
|
|
122763
123019
|
}
|
|
122764
123020
|
}
|
|
122765
|
-
function normalizePath(
|
|
122766
|
-
if (!
|
|
123021
|
+
function normalizePath(path54) {
|
|
123022
|
+
if (!path54.includes("/.")) return path54;
|
|
122767
123023
|
const r10 = [];
|
|
122768
|
-
for (const s of
|
|
123024
|
+
for (const s of path54.split("/")) if (s === ".") continue;
|
|
122769
123025
|
else if (s === ".." && r10.length > 1) r10.pop();
|
|
122770
123026
|
else r10.push(s);
|
|
122771
123027
|
return r10.join("/") || "/";
|
|
122772
123028
|
}
|
|
122773
|
-
function splitPath(
|
|
122774
|
-
const s =
|
|
123029
|
+
function splitPath(path54) {
|
|
123030
|
+
const s = path54.split("/");
|
|
122775
123031
|
s.shift();
|
|
122776
123032
|
if (s[s.length - 1] === "") s.pop();
|
|
122777
123033
|
return s;
|
|
122778
123034
|
}
|
|
122779
|
-
function splitRoute(
|
|
122780
|
-
const s = splitPath(
|
|
123035
|
+
function splitRoute(path54) {
|
|
123036
|
+
const s = splitPath(path54);
|
|
122781
123037
|
while (s[s.length - 1] === "") s.pop();
|
|
122782
123038
|
return s;
|
|
122783
123039
|
}
|
|
@@ -122793,16 +123049,16 @@ function getMatchParams(segments, paramsMap) {
|
|
|
122793
123049
|
}
|
|
122794
123050
|
return params;
|
|
122795
123051
|
}
|
|
122796
|
-
function addRoute(ctx, method = "",
|
|
123052
|
+
function addRoute(ctx, method = "", path54, data) {
|
|
122797
123053
|
method = method.toUpperCase();
|
|
122798
|
-
if (
|
|
122799
|
-
const groupExpanded = expandGroupDelimiters(
|
|
123054
|
+
if (path54.charCodeAt(0) !== 47) path54 = `/${path54}`;
|
|
123055
|
+
const groupExpanded = expandGroupDelimiters(path54);
|
|
122800
123056
|
if (groupExpanded) {
|
|
122801
123057
|
for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
|
|
122802
123058
|
return;
|
|
122803
123059
|
}
|
|
122804
|
-
|
|
122805
|
-
const segments = splitRoute(
|
|
123060
|
+
path54 = encodeEscapes(path54);
|
|
123061
|
+
const segments = splitRoute(path54);
|
|
122806
123062
|
const expanded = expandModifiers(segments);
|
|
122807
123063
|
if (expanded) {
|
|
122808
123064
|
for (const p of expanded) addRoute(ctx, method, p, data);
|
|
@@ -122893,15 +123149,15 @@ function getParamRegexp(segment, unnamedStart = 0) {
|
|
|
122893
123149
|
const regex = _s2.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id2, p) => `(?<${toGroupName(id2)}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i2++)}>`).replace(/\uFFFE(.)/g, (_, c10) => /[.*+?^${}()|[\]\\]/.test(c10) ? `\\${c10}` : c10);
|
|
122894
123150
|
return [new RegExp(`^${regex}$`), _i2];
|
|
122895
123151
|
}
|
|
122896
|
-
function findRoute(ctx, method = "",
|
|
122897
|
-
if (opts?.normalize)
|
|
122898
|
-
if (
|
|
122899
|
-
const staticNode = ctx.static[
|
|
123152
|
+
function findRoute(ctx, method = "", path54, opts) {
|
|
123153
|
+
if (opts?.normalize) path54 = normalizePath(path54);
|
|
123154
|
+
if (path54.charCodeAt(path54.length - 1) === 47) path54 = path54.slice(0, -1);
|
|
123155
|
+
const staticNode = ctx.static[path54];
|
|
122900
123156
|
if (staticNode && staticNode.methods) {
|
|
122901
123157
|
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
122902
123158
|
if (staticMatch !== void 0) return staticMatch[0];
|
|
122903
123159
|
}
|
|
122904
|
-
const segments = splitPath(
|
|
123160
|
+
const segments = splitPath(path54);
|
|
122905
123161
|
const match = _lookupTree(ctx.root, method, segments, 0);
|
|
122906
123162
|
if (match === void 0) return;
|
|
122907
123163
|
if (opts?.params === false) return match;
|
|
@@ -123101,7 +123357,7 @@ var OpenAPIMatcher = class {
|
|
|
123101
123357
|
this.rootRouter = router;
|
|
123102
123358
|
this.index(router);
|
|
123103
123359
|
}
|
|
123104
|
-
index(router,
|
|
123360
|
+
index(router, path54 = []) {
|
|
123105
123361
|
const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
|
|
123106
123362
|
if (!value(this.filter, contract, path210)) {
|
|
123107
123363
|
return;
|
|
@@ -123116,7 +123372,7 @@ var OpenAPIMatcher = class {
|
|
|
123116
123372
|
contract,
|
|
123117
123373
|
procedure: contract instanceof Procedure ? contract : void 0
|
|
123118
123374
|
});
|
|
123119
|
-
},
|
|
123375
|
+
}, path54);
|
|
123120
123376
|
for (const result of lazyResults) {
|
|
123121
123377
|
const prefix = getOpenAPIMeta(result.router)?.prefix;
|
|
123122
123378
|
this.pendingLazyRouters.add({
|
|
@@ -123203,20 +123459,20 @@ var OpenAPIMatcher = class {
|
|
|
123203
123459
|
return entry.procedure;
|
|
123204
123460
|
}
|
|
123205
123461
|
};
|
|
123206
|
-
function toRou3Pattern(
|
|
123207
|
-
const params = getDynamicPathParams(
|
|
123462
|
+
function toRou3Pattern(path54) {
|
|
123463
|
+
const params = getDynamicPathParams(path54);
|
|
123208
123464
|
if (!params?.length) {
|
|
123209
|
-
return
|
|
123465
|
+
return path54;
|
|
123210
123466
|
}
|
|
123211
123467
|
for (let i10 = params.length - 1; i10 >= 0; i10--) {
|
|
123212
123468
|
const param = params[i10];
|
|
123213
123469
|
const pattern = param.allowsSlash ? `**:${param.parameterName}` : `:${param.parameterName}`;
|
|
123214
|
-
|
|
123470
|
+
path54 = path54.slice(0, param.startIndex) + pattern + path54.slice(param.startIndex + param.segment.length);
|
|
123215
123471
|
}
|
|
123216
|
-
return
|
|
123472
|
+
return path54;
|
|
123217
123473
|
}
|
|
123218
|
-
function toRou3PrefixMatcher(
|
|
123219
|
-
const pattern = toRou3Pattern(
|
|
123474
|
+
function toRou3PrefixMatcher(path54) {
|
|
123475
|
+
const pattern = toRou3Pattern(path54);
|
|
123220
123476
|
return routeToRegExp(pattern === "/" ? "/**" : `${pattern}/**`);
|
|
123221
123477
|
}
|
|
123222
123478
|
function decodeParams(params) {
|
|
@@ -123295,7 +123551,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
123295
123551
|
/**
|
|
123296
123552
|
* @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
|
|
123297
123553
|
*/
|
|
123298
|
-
encodeOutput(output2, procedure,
|
|
123554
|
+
encodeOutput(output2, procedure, path54) {
|
|
123299
123555
|
const meta3 = getOpenAPIMeta(procedure);
|
|
123300
123556
|
const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
|
|
123301
123557
|
const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
|
|
@@ -123308,7 +123564,7 @@ var OpenAPIHandlerCodecCore = class {
|
|
|
123308
123564
|
}
|
|
123309
123565
|
if (!isValidDetailedOutput(output2)) {
|
|
123310
123566
|
throw new TypeError(`
|
|
123311
|
-
Invalid "detailed" output structure returned by procedure (${
|
|
123567
|
+
Invalid "detailed" output structure returned by procedure (${path54.join(".")}):
|
|
123312
123568
|
\u2022 Expected an object with optional properties:
|
|
123313
123569
|
- status (number <400)
|
|
123314
123570
|
- headers (object)
|
|
@@ -123860,7 +124116,7 @@ function profileValue(name, paths) {
|
|
|
123860
124116
|
function createConfigApiRouter(deps) {
|
|
123861
124117
|
const authed = doorApiAuth(deps.expectedToken);
|
|
123862
124118
|
const { paths } = deps;
|
|
123863
|
-
const route = (
|
|
124119
|
+
const route = (path54, summary) => authed.meta(openapi({ method: "POST", path: path54, summary, tags: [CONFIG_API_TAG] }));
|
|
123864
124120
|
return {
|
|
123865
124121
|
config: {
|
|
123866
124122
|
identity: {
|
|
@@ -124215,7 +124471,7 @@ function createLifecycleApiRouter(deps) {
|
|
|
124215
124471
|
init_cliError();
|
|
124216
124472
|
|
|
124217
124473
|
// src/frontdoor/launchSchemas.ts
|
|
124218
|
-
var
|
|
124474
|
+
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
124219
124475
|
init_zod();
|
|
124220
124476
|
init_claudeVersion();
|
|
124221
124477
|
init_identity();
|
|
@@ -124225,7 +124481,7 @@ var LaunchResolveInputSchema = external_exports.strictObject({
|
|
|
124225
124481
|
argv: external_exports.readonly(external_exports.array(external_exports.string())).optional(),
|
|
124226
124482
|
/** The launch's inherited environment. Absent means an empty one: the door's own environment is never a substitute for the caller's, so a caller that wants `AGENT_SHIM_*` switches or a `CLAUDE_CONFIG_DIR` considered names them here. Values are read, never reported. */
|
|
124227
124483
|
env: external_exports.record(external_exports.string(), external_exports.string()).optional()
|
|
124228
|
-
}).refine((input2) =>
|
|
124484
|
+
}).refine((input2) => import_node_path44.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
124229
124485
|
var LaunchPoolDecisionSchema = external_exports.strictObject({
|
|
124230
124486
|
name: external_exports.string(),
|
|
124231
124487
|
reasons: external_exports.readonly(external_exports.array(external_exports.string())),
|
|
@@ -125722,8 +125978,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
125722
125978
|
request7.body.resume();
|
|
125723
125979
|
return;
|
|
125724
125980
|
}
|
|
125725
|
-
const
|
|
125726
|
-
const translated = { method: request7.method, path:
|
|
125981
|
+
const path54 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
125982
|
+
const translated = { method: request7.method, path: path54, body, signal: request7.signal };
|
|
125727
125983
|
const routed = await route(translated);
|
|
125728
125984
|
if (request7.signal.aborted) {
|
|
125729
125985
|
return;
|
|
@@ -125757,7 +126013,7 @@ function createPassthroughRoute(name, target) {
|
|
|
125757
126013
|
headroomUpstream: target.headroomUpstream,
|
|
125758
126014
|
serve: async (request7, response) => {
|
|
125759
126015
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
125760
|
-
const
|
|
126016
|
+
const path54 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
125761
126017
|
const headers = forwardableHeaders(request7.headers);
|
|
125762
126018
|
delete headers.host;
|
|
125763
126019
|
await new Promise((resolve2) => {
|
|
@@ -125765,7 +126021,7 @@ function createPassthroughRoute(name, target) {
|
|
|
125765
126021
|
host: base.hostname,
|
|
125766
126022
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
125767
126023
|
method: request7.method,
|
|
125768
|
-
path: `${basePath}${
|
|
126024
|
+
path: `${basePath}${path54}${incoming.search}`,
|
|
125769
126025
|
headers,
|
|
125770
126026
|
agent
|
|
125771
126027
|
};
|
|
@@ -125898,7 +126154,7 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
125898
126154
|
|
|
125899
126155
|
// src/frontdoor/providerRoute.ts
|
|
125900
126156
|
function createProviderRouteResolver(deps) {
|
|
125901
|
-
const isRcSelfHostPath = (
|
|
126157
|
+
const isRcSelfHostPath = (path54) => path54 === "/v1/code/sessions" || path54.startsWith("/v1/code/sessions/") || path54 === "/v1/sessions" || path54.startsWith("/v1/sessions/");
|
|
125902
126158
|
const oauthRoute = createPassthroughRoute("anthropic", { baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`, stripPrefix: void 0, headroomUpstream: void 0 });
|
|
125903
126159
|
const passthroughByTarget = /* @__PURE__ */ new Map();
|
|
125904
126160
|
const passthroughFor = (name, target) => {
|
|
@@ -125912,16 +126168,16 @@ function createProviderRouteResolver(deps) {
|
|
|
125912
126168
|
return route;
|
|
125913
126169
|
};
|
|
125914
126170
|
const resolve2 = (request7) => {
|
|
125915
|
-
const
|
|
125916
|
-
const scoped = parseProviderPath(
|
|
126171
|
+
const path54 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
126172
|
+
const scoped = parseProviderPath(path54);
|
|
125917
126173
|
if (scoped === void 0) {
|
|
125918
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
126174
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path54)) {
|
|
125919
126175
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
125920
126176
|
}
|
|
125921
|
-
if (request7.session.provider !== void 0 &&
|
|
126177
|
+
if (request7.session.provider !== void 0 && path54.startsWith("/v1/") && !isRcSelfHostPath(path54)) {
|
|
125922
126178
|
return resolve2({ ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` });
|
|
125923
126179
|
}
|
|
125924
|
-
return
|
|
126180
|
+
return path54.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path54}` };
|
|
125925
126181
|
}
|
|
125926
126182
|
const { provider } = scoped;
|
|
125927
126183
|
let definition;
|
|
@@ -125974,8 +126230,8 @@ function createProviderRouteResolver(deps) {
|
|
|
125974
126230
|
let replay;
|
|
125975
126231
|
const visited = /* @__PURE__ */ new Set();
|
|
125976
126232
|
for (; ; ) {
|
|
125977
|
-
const
|
|
125978
|
-
const scoped = parseProviderPath(
|
|
126233
|
+
const path54 = new URL(current.url, "http://127.0.0.1").pathname;
|
|
126234
|
+
const scoped = parseProviderPath(path54);
|
|
125979
126235
|
const providerName = scoped?.provider ?? current.session.provider;
|
|
125980
126236
|
if (providerName !== void 0 && visited.has(providerName)) {
|
|
125981
126237
|
return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
|
|
@@ -126033,7 +126289,7 @@ function createProviderRouteResolver(deps) {
|
|
|
126033
126289
|
const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
126034
126290
|
replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
|
|
126035
126291
|
}
|
|
126036
|
-
const rest = scoped === void 0 ?
|
|
126292
|
+
const rest = scoped === void 0 ? path54 : path54.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
|
|
126037
126293
|
const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
126038
126294
|
current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
|
|
126039
126295
|
}
|
|
@@ -126140,7 +126396,7 @@ function createRcLiveUsage(deps) {
|
|
|
126140
126396
|
}
|
|
126141
126397
|
|
|
126142
126398
|
// src/frontdoor/rcSelfHostMint.ts
|
|
126143
|
-
var
|
|
126399
|
+
var import_node_path45 = __toESM(require("node:path"), 1);
|
|
126144
126400
|
init_account();
|
|
126145
126401
|
|
|
126146
126402
|
// src/frontdoor/rcSelfHostLocal.ts
|
|
@@ -126270,7 +126526,7 @@ function readJsonObject(fs22, file2) {
|
|
|
126270
126526
|
return isRecord7(parsed) ? parsed : void 0;
|
|
126271
126527
|
}
|
|
126272
126528
|
function readRcSelfHostRecord(fs22, frontdoorDir) {
|
|
126273
|
-
const parsed = readJsonObject(fs22,
|
|
126529
|
+
const parsed = readJsonObject(fs22, import_node_path45.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
126274
126530
|
if (parsed === void 0) {
|
|
126275
126531
|
return void 0;
|
|
126276
126532
|
}
|
|
@@ -126284,11 +126540,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
126284
126540
|
if (!isIdentityName(deps.identity)) {
|
|
126285
126541
|
throw new Error(`"${deps.identity}" is not a valid identity name.`);
|
|
126286
126542
|
}
|
|
126287
|
-
const identityDir =
|
|
126288
|
-
const credentialsFile =
|
|
126289
|
-
const claudeJsonFile =
|
|
126290
|
-
const recordDir =
|
|
126291
|
-
const recordFile =
|
|
126543
|
+
const identityDir = import_node_path45.default.join(deps.identitiesDir, deps.identity);
|
|
126544
|
+
const credentialsFile = import_node_path45.default.join(identityDir, CREDENTIALS_FILE2);
|
|
126545
|
+
const claudeJsonFile = import_node_path45.default.join(identityDir, CLAUDE_JSON2);
|
|
126546
|
+
const recordDir = import_node_path45.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
126547
|
+
const recordFile = import_node_path45.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
126292
126548
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
126293
126549
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
126294
126550
|
const existingOauth = isRecord7(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -126304,7 +126560,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
126304
126560
|
const organizationUuid = deps.newUuid();
|
|
126305
126561
|
const accountUuid = deps.newUuid();
|
|
126306
126562
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
126307
|
-
deps.fs.mkdirPrivate(
|
|
126563
|
+
deps.fs.mkdirPrivate(import_node_path45.default.dirname(credentialsFile));
|
|
126308
126564
|
deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
|
|
126309
126565
|
`);
|
|
126310
126566
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -126691,7 +126947,7 @@ function registerRcCommand(frontdoor, paths) {
|
|
|
126691
126947
|
}
|
|
126692
126948
|
|
|
126693
126949
|
// src/frontdoor/rcCredentialStore.ts
|
|
126694
|
-
var
|
|
126950
|
+
var import_node_path46 = __toESM(require("node:path"), 1);
|
|
126695
126951
|
function isSafeSessionId(sessionId) {
|
|
126696
126952
|
return /^[A-Za-z0-9_-]+$/.test(sessionId);
|
|
126697
126953
|
}
|
|
@@ -126717,7 +126973,7 @@ function sequenceNumOfJson(value2) {
|
|
|
126717
126973
|
}
|
|
126718
126974
|
function createRcCredentialStore(fs22, dir) {
|
|
126719
126975
|
fs22.mkdirPrivate(dir);
|
|
126720
|
-
const fileFor = (sessionId) =>
|
|
126976
|
+
const fileFor = (sessionId) => import_node_path46.default.join(dir, `${sessionId}.json`);
|
|
126721
126977
|
const readParsed = (sessionId) => {
|
|
126722
126978
|
const raw = fs22.readFileUtf8(fileFor(sessionId));
|
|
126723
126979
|
if (raw === void 0) {
|
|
@@ -129020,6 +129276,26 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
129020
129276
|
keeperRunning = false;
|
|
129021
129277
|
});
|
|
129022
129278
|
}, ANTHROPIC_USAGE_FRESHNESS_MS).unref();
|
|
129279
|
+
const jobRunner = createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() });
|
|
129280
|
+
const runningJobs = /* @__PURE__ */ new Set();
|
|
129281
|
+
setInterval(() => {
|
|
129282
|
+
try {
|
|
129283
|
+
runJobs({
|
|
129284
|
+
fs: realFarmFs,
|
|
129285
|
+
stampsFile: paths.usageJobsFile,
|
|
129286
|
+
nowMs: () => Date.now(),
|
|
129287
|
+
timeZone: machineTimeZone(),
|
|
129288
|
+
jobs: () => Object.entries(readJobs(paths)).map(([name, job]) => ({ name, job })),
|
|
129289
|
+
resolveIdentity: (target) => resolveJobIdentity({ paths, fs: realFarmFs, pools: readPools(paths), nowMs: Date.now(), identityExists: (name) => identityExists(paths, name) }, target),
|
|
129290
|
+
snapshot: (identity) => readUsageSnapshot(realFarmFs, paths.usageSnapshotsDir, identity),
|
|
129291
|
+
run: jobRunner,
|
|
129292
|
+
running: runningJobs,
|
|
129293
|
+
log
|
|
129294
|
+
});
|
|
129295
|
+
} catch (error63) {
|
|
129296
|
+
log(`job keeper failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
129297
|
+
}
|
|
129298
|
+
}, ANTHROPIC_USAGE_FRESHNESS_MS).unref();
|
|
129023
129299
|
const usageMiddleware = createUsageMiddleware({
|
|
129024
129300
|
record: withQuotaRefresh(usageStore.record, quotaRefresher),
|
|
129025
129301
|
defer: (task) => {
|
|
@@ -129163,7 +129439,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
129163
129439
|
const leafFor = createLeafCache(loadCa(), () => /* @__PURE__ */ new Date());
|
|
129164
129440
|
const capture = captureFromEnv(process.env, paths.logsDir);
|
|
129165
129441
|
if (capture !== void 0) {
|
|
129166
|
-
log(`capture enabled, recording CONNECT targets and piped exchanges to ${
|
|
129442
|
+
log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path47.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
|
|
129167
129443
|
}
|
|
129168
129444
|
if (rcSelfHostSurface !== void 0) {
|
|
129169
129445
|
log("self-hosted Remote Control surface on: the door serves the CCR session family itself, and its own client-half dials its own transparent surface");
|
|
@@ -131300,8 +131576,8 @@ function getErrorMap2() {
|
|
|
131300
131576
|
|
|
131301
131577
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/helpers/parseUtil.js
|
|
131302
131578
|
var makeIssue = (params) => {
|
|
131303
|
-
const { data, path:
|
|
131304
|
-
const fullPath = [...
|
|
131579
|
+
const { data, path: path54, errorMaps, issueData } = params;
|
|
131580
|
+
const fullPath = [...path54, ...issueData.path || []];
|
|
131305
131581
|
const fullIssue = {
|
|
131306
131582
|
...issueData,
|
|
131307
131583
|
path: fullPath
|
|
@@ -131416,11 +131692,11 @@ var errorUtil;
|
|
|
131416
131692
|
|
|
131417
131693
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/types.js
|
|
131418
131694
|
var ParseInputLazyPath = class {
|
|
131419
|
-
constructor(parent, value2,
|
|
131695
|
+
constructor(parent, value2, path54, key) {
|
|
131420
131696
|
this._cachedPath = [];
|
|
131421
131697
|
this.parent = parent;
|
|
131422
131698
|
this.data = value2;
|
|
131423
|
-
this._path =
|
|
131699
|
+
this._path = path54;
|
|
131424
131700
|
this._key = key;
|
|
131425
131701
|
}
|
|
131426
131702
|
get path() {
|
|
@@ -134983,11 +135259,11 @@ function normalizeObjectSchema(schema) {
|
|
|
134983
135259
|
}
|
|
134984
135260
|
return void 0;
|
|
134985
135261
|
}
|
|
134986
|
-
function getDotPath(
|
|
134987
|
-
if (
|
|
135262
|
+
function getDotPath(path54) {
|
|
135263
|
+
if (path54.length === 0) {
|
|
134988
135264
|
return "object root";
|
|
134989
135265
|
}
|
|
134990
|
-
return
|
|
135266
|
+
return path54.reduce((acc, seg, index) => {
|
|
134991
135267
|
if (index === 0) {
|
|
134992
135268
|
return String(seg);
|
|
134993
135269
|
}
|
|
@@ -139030,7 +139306,7 @@ async function serveMcp(mcp, transport, options = {}) {
|
|
|
139030
139306
|
|
|
139031
139307
|
// src/mcp/permissions.ts
|
|
139032
139308
|
var import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
139033
|
-
var
|
|
139309
|
+
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
139034
139310
|
init_zod();
|
|
139035
139311
|
init_store();
|
|
139036
139312
|
var StoredMcpPermissionsSchema = external_exports.strictObject({
|
|
@@ -139050,10 +139326,10 @@ function effectiveMcpPermissions(flags, stored) {
|
|
|
139050
139326
|
return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl };
|
|
139051
139327
|
}
|
|
139052
139328
|
function watchMcpPermissions(paths, onChange) {
|
|
139053
|
-
const directory =
|
|
139329
|
+
const directory = import_node_path48.default.dirname(paths.mcpPermissionsFile);
|
|
139054
139330
|
import_node_fs17.default.mkdirSync(directory, { recursive: true });
|
|
139055
139331
|
const watcher = import_node_fs17.default.watch(directory, (_event, filename) => {
|
|
139056
|
-
if (filename === null || filename ===
|
|
139332
|
+
if (filename === null || filename === import_node_path48.default.basename(paths.mcpPermissionsFile)) {
|
|
139057
139333
|
onChange();
|
|
139058
139334
|
}
|
|
139059
139335
|
});
|
|
@@ -139362,16 +139638,16 @@ init_credentialCache();
|
|
|
139362
139638
|
|
|
139363
139639
|
// src/identityToken.ts
|
|
139364
139640
|
var import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
139365
|
-
var
|
|
139641
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
139366
139642
|
init_cliError();
|
|
139367
139643
|
var TOKEN_FILE_MODE = 384;
|
|
139368
139644
|
var TOKEN_DIR_MODE = 448;
|
|
139369
139645
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
139370
139646
|
function identityTokenDir(paths) {
|
|
139371
|
-
return
|
|
139647
|
+
return import_node_path49.default.join(paths.root, "credentials");
|
|
139372
139648
|
}
|
|
139373
139649
|
function identityTokenPath(paths, identityName) {
|
|
139374
|
-
return
|
|
139650
|
+
return import_node_path49.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
139375
139651
|
}
|
|
139376
139652
|
function storeIdentityToken(paths, identityName, raw) {
|
|
139377
139653
|
const token = raw.trim();
|
|
@@ -139382,7 +139658,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
139382
139658
|
import_node_fs18.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
139383
139659
|
import_node_fs18.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
139384
139660
|
const target = identityTokenPath(paths, identityName);
|
|
139385
|
-
const temp =
|
|
139661
|
+
const temp = import_node_path49.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
139386
139662
|
import_node_fs18.default.writeFileSync(temp, `${token}
|
|
139387
139663
|
`, { mode: TOKEN_FILE_MODE });
|
|
139388
139664
|
import_node_fs18.default.renameSync(temp, target);
|
|
@@ -139550,7 +139826,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
139550
139826
|
// src/headroom/commands.ts
|
|
139551
139827
|
var import_node_fs19 = __toESM(require("node:fs"), 1);
|
|
139552
139828
|
var import_node_http4 = __toESM(require("node:http"), 1);
|
|
139553
|
-
var
|
|
139829
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
139554
139830
|
var import_node_child_process6 = require("node:child_process");
|
|
139555
139831
|
init_commandDeps();
|
|
139556
139832
|
init_realFrontDoorPort();
|
|
@@ -139680,12 +139956,12 @@ function readInstalledHeadroomCommit() {
|
|
|
139680
139956
|
if (toolDir.status !== 0) {
|
|
139681
139957
|
return void 0;
|
|
139682
139958
|
}
|
|
139683
|
-
const libDir =
|
|
139959
|
+
const libDir = import_node_path50.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
139684
139960
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
139685
|
-
const sitePackages =
|
|
139961
|
+
const sitePackages = import_node_path50.default.join(libDir, python, "site-packages");
|
|
139686
139962
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
139687
139963
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
139688
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
139964
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path50.default.join(sitePackages, entry, "direct_url.json"));
|
|
139689
139965
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
139690
139966
|
}
|
|
139691
139967
|
}
|
|
@@ -139820,6 +140096,134 @@ function registerHeadroomCommand(program2, deps) {
|
|
|
139820
140096
|
});
|
|
139821
140097
|
}
|
|
139822
140098
|
|
|
140099
|
+
// src/jobs.ts
|
|
140100
|
+
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
140101
|
+
init_commandDeps();
|
|
140102
|
+
init_cliError();
|
|
140103
|
+
init_schema();
|
|
140104
|
+
init_realPorts();
|
|
140105
|
+
function jobOf(options) {
|
|
140106
|
+
if (options.identity === void 0 === (options.pool === void 0)) {
|
|
140107
|
+
throw new UsageError("A job runs as one identity or one pool's pick: pass exactly one of --identity or --pool.");
|
|
140108
|
+
}
|
|
140109
|
+
if (options.at === void 0 === (options.beforeReset === void 0)) {
|
|
140110
|
+
throw new UsageError("A job needs exactly one trigger: pass --at (repeatable) or --before-reset with --lead.");
|
|
140111
|
+
}
|
|
140112
|
+
if (options.beforeReset !== void 0 && options.lead === void 0) {
|
|
140113
|
+
throw new UsageError("--before-reset needs --lead, how long before the window resets the job runs.");
|
|
140114
|
+
}
|
|
140115
|
+
if (options.at !== void 0 && options.lead !== void 0) {
|
|
140116
|
+
throw new UsageError("--lead only goes with --before-reset.");
|
|
140117
|
+
}
|
|
140118
|
+
if (options.prompt === void 0 || options.timeout === void 0) {
|
|
140119
|
+
throw new UsageError("A job needs --prompt, what to run, and --timeout, how long one run may take.");
|
|
140120
|
+
}
|
|
140121
|
+
return {
|
|
140122
|
+
target: options.identity === void 0 ? { pool: options.pool ?? "" } : { identity: options.identity },
|
|
140123
|
+
trigger: options.at === void 0 ? { beforeReset: options.beforeReset ?? "fiveHour", lead: options.lead ?? "" } : { at: options.at },
|
|
140124
|
+
prompt: options.prompt,
|
|
140125
|
+
cwd: import_node_path51.default.resolve(options.cwd ?? process.cwd()),
|
|
140126
|
+
timeout: options.timeout,
|
|
140127
|
+
...options.model === void 0 ? {} : { model: options.model },
|
|
140128
|
+
...options.allowedTool === void 0 ? {} : { allowedTools: options.allowedTool }
|
|
140129
|
+
};
|
|
140130
|
+
}
|
|
140131
|
+
function describeTrigger(job) {
|
|
140132
|
+
return "at" in job.trigger ? `at ${job.trigger.at.map(formatAnchor).join(" ")}` : `${job.trigger.lead} before the ${job.trigger.beforeReset} window resets`;
|
|
140133
|
+
}
|
|
140134
|
+
function describeTarget(job) {
|
|
140135
|
+
return "identity" in job.target ? `identity ${job.target.identity}` : `the pick of pool ${job.target.pool}`;
|
|
140136
|
+
}
|
|
140137
|
+
function registerJobCommand(program2, deps) {
|
|
140138
|
+
const { paths } = deps;
|
|
140139
|
+
const job = withExamples(
|
|
140140
|
+
program2.command("job").description("Manage jobs: prompts the front door runs unattended as an identity, on a schedule or shortly before a quota window resets to use quota that would expire."),
|
|
140141
|
+
["agent-shim job add digest --identity work --before-reset sevenDay --lead 6h --prompt 'summarise open PRs' --timeout 30m", "agent-shim job list"]
|
|
140142
|
+
);
|
|
140143
|
+
withExamples(
|
|
140144
|
+
job.command("add <name>").description("Define a job. Fails if one with this name already exists.").option("--identity <name>", "Run as this identity.").option("--pool <name>", "Run as whichever member of this pool the ranking picks when the job fires.").option("--at <spec>", `Run at these times (repeatable): ${ANCHOR_SYNTAX}.`, collectAnchor).addOption(new Option("--before-reset <window>", "Run once per instance of this quota window, when it has --lead or less left.").choices(JOB_WINDOWS)).option("--lead <duration>", "With --before-reset: how long before the window resets the job runs, a count followed by m, h, d or w, such as 6h.", parseDurationLiteral).option("--prompt <text>", "What to run.").option("--cwd <dir>", "The directory the run works in. Defaults to the current directory.").option("--timeout <duration>", "How long one run may take, such as 30m. A run that goes on longer is stopped.", parseDurationLiteral).option("--model <model>", "The model to run with. Defaults to the settings' own.").option("--allowed-tool <tool>", "A tool the run may use without asking, beyond what its settings allow (repeatable). An unattended run cannot answer a permission prompt, so any other tool is refused.", collectRepeated).option("--json", "Print the result as JSON.").action((name, options) => {
|
|
140145
|
+
const defined = jobOf(options);
|
|
140146
|
+
if ("identity" in defined.target) {
|
|
140147
|
+
requireIdentityNames(paths, [defined.target.identity]);
|
|
140148
|
+
} else {
|
|
140149
|
+
requirePool(paths, defined.target.pool);
|
|
140150
|
+
}
|
|
140151
|
+
const created = addJob(paths, name, defined);
|
|
140152
|
+
reportMutation(options.json, { action: "created", kind: "job", name, value: created }, () => {
|
|
140153
|
+
console.log(`Created job "${name}": runs as ${describeTarget(created)}, ${describeTrigger(created)}.`);
|
|
140154
|
+
});
|
|
140155
|
+
}),
|
|
140156
|
+
["agent-shim job add digest --identity work --at mon-fri@06:00 --prompt 'summarise open PRs' --timeout 30m --cwd ~/work/app", "agent-shim job add burn --pool subs --before-reset fiveHour --lead 20m --prompt 'continue the migration plan' --timeout 20m --allowed-tool Read --allowed-tool Edit"]
|
|
140157
|
+
);
|
|
140158
|
+
withExamples(
|
|
140159
|
+
job.command("list").description("List every job.").option("--json", "Print the jobs as JSON.").action((options) => {
|
|
140160
|
+
const jobs = readJobs(paths);
|
|
140161
|
+
if (options.json === true) {
|
|
140162
|
+
printJson(Object.entries(jobs).map(([name, entry]) => ({ name, ...entry })));
|
|
140163
|
+
return;
|
|
140164
|
+
}
|
|
140165
|
+
const names = Object.keys(jobs).sort();
|
|
140166
|
+
if (names.length === 0) {
|
|
140167
|
+
console.log("No jobs yet. Run `agent-shim job add <name> ...` to create one.");
|
|
140168
|
+
return;
|
|
140169
|
+
}
|
|
140170
|
+
for (const name of names) {
|
|
140171
|
+
const entry = jobs[name];
|
|
140172
|
+
if (entry !== void 0) {
|
|
140173
|
+
console.log(`${name}: ${describeTarget(entry)}, ${describeTrigger(entry)}`);
|
|
140174
|
+
}
|
|
140175
|
+
}
|
|
140176
|
+
}),
|
|
140177
|
+
["agent-shim job list", "agent-shim job list --json"]
|
|
140178
|
+
);
|
|
140179
|
+
withExamples(
|
|
140180
|
+
job.command("show <name>").description("Show one job.").option("--json", "Print the job as JSON.").action((name, options) => {
|
|
140181
|
+
const entry = requireJob(paths, name);
|
|
140182
|
+
if (options.json === true) {
|
|
140183
|
+
printJson({ name, ...entry });
|
|
140184
|
+
return;
|
|
140185
|
+
}
|
|
140186
|
+
console.log(`Job: ${name}`);
|
|
140187
|
+
console.log(`Runs as: ${describeTarget(entry)}`);
|
|
140188
|
+
console.log(`Trigger: ${describeTrigger(entry)}`);
|
|
140189
|
+
console.log(`Directory: ${entry.cwd}`);
|
|
140190
|
+
console.log(`Timeout: ${entry.timeout}`);
|
|
140191
|
+
if (entry.model !== void 0) {
|
|
140192
|
+
console.log(`Model: ${entry.model}`);
|
|
140193
|
+
}
|
|
140194
|
+
if (entry.allowedTools !== void 0) {
|
|
140195
|
+
console.log(`Allowed tools: ${entry.allowedTools.join(", ")}`);
|
|
140196
|
+
}
|
|
140197
|
+
console.log(`Prompt: ${entry.prompt}`);
|
|
140198
|
+
console.log(`Results: ${import_node_path51.default.join(paths.jobLogsDir, `${name}.log`)}`);
|
|
140199
|
+
}),
|
|
140200
|
+
["agent-shim job show digest"]
|
|
140201
|
+
);
|
|
140202
|
+
withExamples(
|
|
140203
|
+
job.command("remove <name>").description("Delete a job.").option("--yes", "Skip the confirmation prompt.").option("--json", "Print the result as JSON.").action(async (name, options) => {
|
|
140204
|
+
requireJob(paths, name);
|
|
140205
|
+
await confirmRemoval(deps, options.yes, `job "${name}"`);
|
|
140206
|
+
removeJob(paths, name);
|
|
140207
|
+
reportMutation(options.json, { action: "removed", kind: "job", name }, () => {
|
|
140208
|
+
console.log(`Removed job "${name}".`);
|
|
140209
|
+
});
|
|
140210
|
+
}),
|
|
140211
|
+
["agent-shim job remove digest --yes"]
|
|
140212
|
+
);
|
|
140213
|
+
withExamples(
|
|
140214
|
+
job.command("run <name>").description("Run a job now, in this terminal, as its trigger would: for a pool the member is picked at this moment. The result is appended to the job's log, and a failure exits non-zero.").action(async (name) => {
|
|
140215
|
+
const entry = requireJob(paths, name);
|
|
140216
|
+
const identity = resolveJobIdentity({ paths, fs: realFarmFs, pools: readPools(paths), nowMs: Date.now(), identityExists: (candidate) => identityExists(paths, candidate) }, entry.target);
|
|
140217
|
+
if (identity === void 0) {
|
|
140218
|
+
throw new UsageError(`No member of the job's pool can be picked right now.`);
|
|
140219
|
+
}
|
|
140220
|
+
await createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() })(name, identity, entry);
|
|
140221
|
+
console.log(`Ran job "${name}" as ${identity}; the result is in ${import_node_path51.default.join(paths.jobLogsDir, `${name}.log`)}.`);
|
|
140222
|
+
}),
|
|
140223
|
+
["agent-shim job run digest"]
|
|
140224
|
+
);
|
|
140225
|
+
}
|
|
140226
|
+
|
|
139823
140227
|
// src/pools.ts
|
|
139824
140228
|
init_commandDeps();
|
|
139825
140229
|
init_cliError();
|
|
@@ -140225,7 +140629,7 @@ function registerRunCommand(program2, handler) {
|
|
|
140225
140629
|
}
|
|
140226
140630
|
|
|
140227
140631
|
// src/usage/commands.ts
|
|
140228
|
-
var
|
|
140632
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
140229
140633
|
init_commandDeps();
|
|
140230
140634
|
init_realPorts();
|
|
140231
140635
|
init_account();
|
|
@@ -140363,7 +140767,7 @@ function collectAccounts(fs22, paths, identity, probe) {
|
|
|
140363
140767
|
return names.map((name) => ({
|
|
140364
140768
|
identity: name,
|
|
140365
140769
|
account: readAccountMetadata(fs22, paths.identitiesDir, name),
|
|
140366
|
-
signIn: identitySignIn(fs22, probe, { farmRoot:
|
|
140770
|
+
signIn: identitySignIn(fs22, probe, { farmRoot: import_node_path52.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
|
|
140367
140771
|
usage: readUsageSnapshot(fs22, paths.usageSnapshotsDir, name)
|
|
140368
140772
|
}));
|
|
140369
140773
|
}
|
|
@@ -140534,6 +140938,7 @@ function buildProgram(deps) {
|
|
|
140534
140938
|
registerIdentityCommand(program2, deps);
|
|
140535
140939
|
registerProfileCommand(program2, deps);
|
|
140536
140940
|
registerPoolCommand(program2, deps);
|
|
140941
|
+
registerJobCommand(program2, deps);
|
|
140537
140942
|
registerProviderCommand(program2, deps);
|
|
140538
140943
|
registerRuleCommand(program2, deps);
|
|
140539
140944
|
registerCredentialCommand(program2, deps, deps.credentialPorts);
|
|
@@ -140708,7 +141113,7 @@ async function runClaude(argvOverride) {
|
|
|
140708
141113
|
// src/cli.ts
|
|
140709
141114
|
async function main() {
|
|
140710
141115
|
aliasLegacyEnv(process.env);
|
|
140711
|
-
const invokedName =
|
|
141116
|
+
const invokedName = import_node_path53.default.basename(process.argv[1] ?? "agent-shim");
|
|
140712
141117
|
if (isInvokedAsClaude(invokedName)) {
|
|
140713
141118
|
await runClaude();
|
|
140714
141119
|
return;
|