claude-use 14.2.4 → 14.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +7733 -6185
- package/dist/index.cjs +1737 -1400
- package/dist/index.mjs +1698 -1361
- package/dist/types/index.d.ts +16 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -690,6 +690,134 @@ var init_statusline = __esm({
|
|
|
690
690
|
}
|
|
691
691
|
});
|
|
692
692
|
|
|
693
|
+
// src/models/identity.ts
|
|
694
|
+
function withoutContextMarker(model) {
|
|
695
|
+
return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? model.slice(0, -CONTEXT_MARKER_1M.length) : model;
|
|
696
|
+
}
|
|
697
|
+
function namesAModel(value) {
|
|
698
|
+
return withoutContextMarker(value).trim() !== "";
|
|
699
|
+
}
|
|
700
|
+
function canonicalText(name) {
|
|
701
|
+
return name.trim().toLowerCase().replace(NON_IDENTITY_BRACKET_RE, "").replace(/[\s_]+/g, "-").replace(/([a-z])(\d+(?:\.\d+)+)/g, "$1-$2").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
702
|
+
}
|
|
703
|
+
function splitVariants(tokens) {
|
|
704
|
+
const variants = [];
|
|
705
|
+
let end = tokens.length;
|
|
706
|
+
for (; ; ) {
|
|
707
|
+
const token = tokens[end - 1];
|
|
708
|
+
if (token === void 0 || !KNOWN_VARIANTS.has(token)) {
|
|
709
|
+
return { familyTokens: tokens.slice(0, end), variants };
|
|
710
|
+
}
|
|
711
|
+
variants.unshift(token);
|
|
712
|
+
end -= 1;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
function versionOf(tokens) {
|
|
716
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
717
|
+
const token = tokens[index];
|
|
718
|
+
const next = tokens[index + 1];
|
|
719
|
+
if (token === void 0) {
|
|
720
|
+
return "";
|
|
721
|
+
}
|
|
722
|
+
if (/^\d+$/.test(token) && next !== void 0 && /^\d+$/.test(next)) {
|
|
723
|
+
return `${token}.${next}`;
|
|
724
|
+
}
|
|
725
|
+
const dotted = /^\d+(?:\.\d+)+$/.exec(token);
|
|
726
|
+
if (dotted !== null) {
|
|
727
|
+
return dotted[0];
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return "";
|
|
731
|
+
}
|
|
732
|
+
function modelIdentity(rawName) {
|
|
733
|
+
const segments = rawName.trim().toLowerCase().split("/");
|
|
734
|
+
const stripped = canonicalText(segments[segments.length - 1] ?? "").split(":")[0] ?? "";
|
|
735
|
+
const withoutDate = stripped.replace(DATE_STAMP_RE, "");
|
|
736
|
+
const tokens = withoutDate.split("-").filter((token) => token !== "");
|
|
737
|
+
const { familyTokens, variants } = splitVariants(tokens);
|
|
738
|
+
const version = versionOf(familyTokens);
|
|
739
|
+
const versionless = familyTokens.filter((token, index) => {
|
|
740
|
+
if (version === "") {
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
const dotted = /^\d+(?:\.\d+)+$/.test(token);
|
|
744
|
+
const previous = familyTokens[index - 1];
|
|
745
|
+
const next = familyTokens[index + 1];
|
|
746
|
+
const insideVersionRun = dotted || /^\d+$/.test(token) && (previous !== void 0 && /^\d+$/.test(previous) || next !== void 0 && /^\d+$/.test(next));
|
|
747
|
+
return !insideVersionRun;
|
|
748
|
+
});
|
|
749
|
+
const family = versionless.join("-");
|
|
750
|
+
const tokenVendor = familyTokens.find((token) => Object.keys(VENDOR_BY_TOKEN).some((key) => token === key || token.startsWith(key)));
|
|
751
|
+
const namespace = segments.length >= 2 ? (segments[0] ?? "").split(":").pop() ?? "" : "";
|
|
752
|
+
const namespaceVendor = VENDOR_BY_NAMESPACE[namespace] ?? "";
|
|
753
|
+
const tokenVendorName = tokenVendor === void 0 ? "" : VENDOR_BY_TOKEN[Object.keys(VENDOR_BY_TOKEN).find((key) => tokenVendor === key || tokenVendor.startsWith(key)) ?? ""] ?? "";
|
|
754
|
+
return {
|
|
755
|
+
vendor: tokenVendorName === "" ? namespaceVendor : tokenVendorName,
|
|
756
|
+
vendorConflict: tokenVendorName !== "" && namespaceVendor !== "" && tokenVendorName !== namespaceVendor,
|
|
757
|
+
family,
|
|
758
|
+
version,
|
|
759
|
+
variant: variants.join("-"),
|
|
760
|
+
familyAndVersion: version === "" ? family : `${family}-${version.replace(/\./g, "-")}`
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
function relateModels(left, right) {
|
|
764
|
+
const a = modelIdentity(left);
|
|
765
|
+
const b = modelIdentity(right);
|
|
766
|
+
if (a.familyAndVersion !== b.familyAndVersion) {
|
|
767
|
+
return sameFamilyOtherVersion(a, b) ? "similar" : "distinct";
|
|
768
|
+
}
|
|
769
|
+
if (a.variant !== b.variant || a.vendorConflict || b.vendorConflict || a.vendor !== "" && b.vendor !== "" && a.vendor !== b.vendor) {
|
|
770
|
+
return "similar";
|
|
771
|
+
}
|
|
772
|
+
return "same";
|
|
773
|
+
}
|
|
774
|
+
function sameFamilyOtherVersion(a, b) {
|
|
775
|
+
if (a.family !== b.family) {
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
if (a.vendor !== "" && b.vendor !== "" && a.vendor !== b.vendor) {
|
|
779
|
+
return false;
|
|
780
|
+
}
|
|
781
|
+
return true;
|
|
782
|
+
}
|
|
783
|
+
var NON_IDENTITY_BRACKET_RE, CONTEXT_MARKER_1M, DATE_STAMP_RE, KNOWN_VARIANTS, VENDOR_BY_NAMESPACE, VENDOR_BY_TOKEN;
|
|
784
|
+
var init_identity = __esm({
|
|
785
|
+
"src/models/identity.ts"() {
|
|
786
|
+
"use strict";
|
|
787
|
+
NON_IDENTITY_BRACKET_RE = /\[[^\]]*\]/g;
|
|
788
|
+
CONTEXT_MARKER_1M = "[1m]";
|
|
789
|
+
DATE_STAMP_RE = /-(?:19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/;
|
|
790
|
+
KNOWN_VARIANTS = /* @__PURE__ */ new Set(["high", "medium", "low", "thinking", "xhigh", "max", "highspeed", "sol", "terra", "luna", "mini", "flash-lite", "turbo"]);
|
|
791
|
+
VENDOR_BY_NAMESPACE = Object.freeze({
|
|
792
|
+
anthropic: "anthropic",
|
|
793
|
+
google: "google",
|
|
794
|
+
openai: "openai",
|
|
795
|
+
zai: "zai",
|
|
796
|
+
"z-ai": "zai",
|
|
797
|
+
minimax: "minimax",
|
|
798
|
+
qwen: "qwen",
|
|
799
|
+
deepseek: "deepseek",
|
|
800
|
+
moonshot: "moonshot",
|
|
801
|
+
meta: "meta",
|
|
802
|
+
mistral: "mistral"
|
|
803
|
+
});
|
|
804
|
+
VENDOR_BY_TOKEN = Object.freeze({
|
|
805
|
+
claude: "anthropic",
|
|
806
|
+
gemini: "google",
|
|
807
|
+
antigravity: "google",
|
|
808
|
+
gpt: "openai",
|
|
809
|
+
glm: "zai",
|
|
810
|
+
minimax: "minimax",
|
|
811
|
+
qwen: "qwen",
|
|
812
|
+
deepseek: "deepseek",
|
|
813
|
+
kimi: "moonshot",
|
|
814
|
+
llama: "meta",
|
|
815
|
+
mistral: "mistral",
|
|
816
|
+
mixtral: "mistral"
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
|
|
693
821
|
// src/versionDiscovery.ts
|
|
694
822
|
function defaultVersionsDir() {
|
|
695
823
|
return import_node_path2.default.join(import_node_os.default.homedir(), ".local", "share", "claude", "versions");
|
|
@@ -821,7 +949,7 @@ function isTimeZone(name) {
|
|
|
821
949
|
return false;
|
|
822
950
|
}
|
|
823
951
|
}
|
|
824
|
-
var import_node_path3, import_zod3, import_trilean, 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, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, MAX_TIMER_DELAY_MS, HttpBaseUrlSchema, HttpProviderSchema, CodexProviderSchema, RouterProviderSchema, AntigravityProviderSchema, ProviderSchema, SELECTION_MODES, VirtualModelSchema, ModelPricesSchema, FamilySettingsSchema, ModelsConfigSchema, ModelsLayerSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, 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, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
|
|
952
|
+
var import_node_path3, import_zod3, import_trilean, 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, TIER_MODEL_ENV_VARIABLES, OTHER_MODEL_ENV_VARIABLES, MODEL_ENV_VARIABLES, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, MAX_TIMER_DELAY_MS, HttpBaseUrlSchema, SERVER_TOOLS_MODES, HttpProviderSchema, CodexProviderSchema, RouterProviderSchema, AntigravityProviderSchema, ProviderSchema, SELECTION_MODES, VirtualModelSchema, ModelPricesSchema, FamilySettingsSchema, ModelsConfigSchema, ModelsLayerSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, 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, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
|
|
825
953
|
var init_schema = __esm({
|
|
826
954
|
"src/config/schema.ts"() {
|
|
827
955
|
"use strict";
|
|
@@ -831,6 +959,7 @@ var init_schema = __esm({
|
|
|
831
959
|
import_node_path3 = __toESM(require("node:path"), 1);
|
|
832
960
|
import_zod3 = require("zod");
|
|
833
961
|
import_trilean = require("trilean");
|
|
962
|
+
init_identity();
|
|
834
963
|
init_versionDiscovery();
|
|
835
964
|
CATEGORY_NAMES = ["secret", "runtime", "history", "knowledge", "settings"];
|
|
836
965
|
OVERRIDABLE_CATEGORIES = ["runtime", "history", "knowledge", "settings"];
|
|
@@ -937,8 +1066,13 @@ var init_schema = __esm({
|
|
|
937
1066
|
});
|
|
938
1067
|
ProviderCredentialSchema = CredentialSchema.extend({ target: import_zod3.z.enum(PROVIDER_CREDENTIAL_TARGETS).optional() });
|
|
939
1068
|
RESERVED_PROVIDER_ENV_KEYS = Object.values(CREDENTIAL_TARGET_VARS);
|
|
1069
|
+
TIER_MODEL_ENV_VARIABLES = ["ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL"];
|
|
1070
|
+
OTHER_MODEL_ENV_VARIABLES = ["ANTHROPIC_MODEL", "ANTHROPIC_SMALL_FAST_MODEL", "ANTHROPIC_DEFAULT_FABLE_MODEL"];
|
|
1071
|
+
MODEL_ENV_VARIABLES = [...OTHER_MODEL_ENV_VARIABLES, ...TIER_MODEL_ENV_VARIABLES];
|
|
940
1072
|
ProviderEnvSchema = import_zod3.z.record(import_zod3.z.string().min(1), import_zod3.z.string()).refine((env) => !Object.keys(env).some((key) => RESERVED_PROVIDER_ENV_KEYS.includes(key)), {
|
|
941
1073
|
message: `env may not set ${RESERVED_PROVIDER_ENV_KEYS.join(", ")}: the credential block's target sets one and agent-shim removes the others`
|
|
1074
|
+
}).refine((env) => !MODEL_ENV_VARIABLES.some((key) => env[key] !== void 0 && env[key] !== "" && !namesAModel(env[key])), {
|
|
1075
|
+
message: `env may not set ${MODEL_ENV_VARIABLES.join(", ")} to a context marker or whitespace alone: a model variable names a model, or is empty to leave the tier unset`
|
|
942
1076
|
});
|
|
943
1077
|
PROVIDER_KINDS = ["http", "codex", "antigravity", "router"];
|
|
944
1078
|
ANTIGRAVITY_MODES = ["cloud", "local"];
|
|
@@ -1041,6 +1175,7 @@ var init_schema = __esm({
|
|
|
1041
1175
|
ctx.addIssue({ code: "custom", message: "a provider's base URL must not name port 0, which nothing listens on: give the port the endpoint serves" });
|
|
1042
1176
|
}
|
|
1043
1177
|
});
|
|
1178
|
+
SERVER_TOOLS_MODES = ["forward", "drop"];
|
|
1044
1179
|
HttpProviderSchema = import_zod3.z.strictObject({
|
|
1045
1180
|
$schema: import_zod3.z.string().optional(),
|
|
1046
1181
|
kind: import_zod3.z.literal("http").optional(),
|
|
@@ -1055,7 +1190,9 @@ var init_schema = __esm({
|
|
|
1055
1190
|
/** The provider's own model catalogue, listed in `/model` when set. */
|
|
1056
1191
|
catalogue: ProviderCatalogueSchema.optional(),
|
|
1057
1192
|
/** Per-request routing: when present, each request this provider would serve is matched against the list in order, and the first definite match is sent to that entry's provider instead (itself resolved exactly as a directly dialled request would be). Unmatched requests stay on this provider. */
|
|
1058
|
-
routes: import_zod3.z.array(ProviderRouteSchema).optional()
|
|
1193
|
+
routes: import_zod3.z.array(ProviderRouteSchema).optional(),
|
|
1194
|
+
/** What happens to tools with no `input_schema` (a `type` and no schema, such as web search) in a request this provider serves. A property of the provider because only its server knows whether it can take them: a backend that implements the Messages API with client tools only (vLLM, SGLang) answers 400 `input_schema: Field required` and fails the whole request, while Anthropic itself and gateways that run them need them forwarded. `forward` (the default) changes nothing for any provider; `drop` removes every tool object with no `input_schema` member before the request is forwarded, which also takes any Anthropic-defined client tool that is given by `type` alone. */
|
|
1195
|
+
serverTools: import_zod3.z.enum(SERVER_TOOLS_MODES).optional()
|
|
1059
1196
|
});
|
|
1060
1197
|
CodexProviderSchema = import_zod3.z.strictObject({
|
|
1061
1198
|
$schema: import_zod3.z.string().optional(),
|
|
@@ -1343,7 +1480,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
1343
1480
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
1344
1481
|
}
|
|
1345
1482
|
function describeIgnoredKeys(filePath, ignored) {
|
|
1346
|
-
const places = ignored.map(({ path:
|
|
1483
|
+
const places = ignored.map(({ path: path56, keys }) => `${path56.length === 0 ? "" : `${path56.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
1347
1484
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
1348
1485
|
}
|
|
1349
1486
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -1365,9 +1502,9 @@ function restoreIgnoredKeys(filePath, value) {
|
|
|
1365
1502
|
return value;
|
|
1366
1503
|
}
|
|
1367
1504
|
const restored = structuredClone(value);
|
|
1368
|
-
for (const { path:
|
|
1505
|
+
for (const { path: path56, values } of ignored) {
|
|
1369
1506
|
let holder = restored;
|
|
1370
|
-
for (const step of
|
|
1507
|
+
for (const step of path56) {
|
|
1371
1508
|
holder = isRecord(holder) ? holder[step] : void 0;
|
|
1372
1509
|
}
|
|
1373
1510
|
if (isRecord(holder)) {
|
|
@@ -4340,6 +4477,43 @@ var init_baseUrlDisplay = __esm({
|
|
|
4340
4477
|
}
|
|
4341
4478
|
});
|
|
4342
4479
|
|
|
4480
|
+
// src/elapsedWindow.ts
|
|
4481
|
+
function within(sinceMs, nowMs, windowMs) {
|
|
4482
|
+
const age = nowMs - sinceMs;
|
|
4483
|
+
return age >= 0 && age < windowMs;
|
|
4484
|
+
}
|
|
4485
|
+
var init_elapsedWindow = __esm({
|
|
4486
|
+
"src/elapsedWindow.ts"() {
|
|
4487
|
+
"use strict";
|
|
4488
|
+
}
|
|
4489
|
+
});
|
|
4490
|
+
|
|
4491
|
+
// src/frontdoor/loggedText.ts
|
|
4492
|
+
var UNSAFE_CLASS, UNSAFE_IN_A_LINE, UNSAFE_CHARACTERS;
|
|
4493
|
+
var init_loggedText = __esm({
|
|
4494
|
+
"src/frontdoor/loggedText.ts"() {
|
|
4495
|
+
"use strict";
|
|
4496
|
+
UNSAFE_CLASS = "[\\p{Cc}\\p{Zl}\\p{Zp}\\p{Cf}]";
|
|
4497
|
+
UNSAFE_IN_A_LINE = new RegExp(UNSAFE_CLASS, "u");
|
|
4498
|
+
UNSAFE_CHARACTERS = new RegExp(UNSAFE_CLASS, "gu");
|
|
4499
|
+
}
|
|
4500
|
+
});
|
|
4501
|
+
|
|
4502
|
+
// src/canonicalJson.ts
|
|
4503
|
+
function canonicalJson(value) {
|
|
4504
|
+
return JSON.stringify(value, (_key, member) => {
|
|
4505
|
+
if (typeof member !== "object" || member === null || Array.isArray(member)) {
|
|
4506
|
+
return member;
|
|
4507
|
+
}
|
|
4508
|
+
return Object.fromEntries(Object.entries(member).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0));
|
|
4509
|
+
});
|
|
4510
|
+
}
|
|
4511
|
+
var init_canonicalJson = __esm({
|
|
4512
|
+
"src/canonicalJson.ts"() {
|
|
4513
|
+
"use strict";
|
|
4514
|
+
}
|
|
4515
|
+
});
|
|
4516
|
+
|
|
4343
4517
|
// src/usage/schema.ts
|
|
4344
4518
|
var import_zod5, USAGE_SCHEMA_VERSION, VersionSchema, InstantSchema, CLIENT_SESSION_ID_PATTERN, TokenCountSchema, TokenUsageSchema, LIMIT_KINDS, LimitClassificationSchema, REQUEST_CLASSES, RequestClassSchema, UsageRecordSchema, QuotaWindowSchema, ExtraUsageSpendSchema, UnifiedRateLimitSchema, RateLimitStateSchema, LimitEventSchema, ProviderQuotaWindowSchema, ProviderAccountSchema, ProviderQuotaSchema, ProviderUsageStateSchema, AccountMetadataSchema, UsageSnapshotSchema;
|
|
4345
4519
|
var init_schema2 = __esm({
|
|
@@ -5029,6 +5203,20 @@ function catalogueCachePath(paths, name, supervisorPid, generation) {
|
|
|
5029
5203
|
const directory = supervisorPid === void 0 || generation === void 0 ? paths.catalogueDir : catalogueGenerationDir(paths, supervisorPid, generation);
|
|
5030
5204
|
return providerFilePath(directory, name);
|
|
5031
5205
|
}
|
|
5206
|
+
function catalogueSettingsPath(paths, name) {
|
|
5207
|
+
return import_node_path11.default.join(import_node_path11.default.dirname(catalogueCachePath(paths, name)), "settings", `${name}.json`);
|
|
5208
|
+
}
|
|
5209
|
+
function parseCatalogueSettings(text) {
|
|
5210
|
+
if (text === void 0) {
|
|
5211
|
+
return void 0;
|
|
5212
|
+
}
|
|
5213
|
+
try {
|
|
5214
|
+
const parsed = CatalogueDigestSchema.safeParse(JSON.parse(text));
|
|
5215
|
+
return parsed.success ? parsed.data : void 0;
|
|
5216
|
+
} catch {
|
|
5217
|
+
return void 0;
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5032
5220
|
function catalogueGenerationDir(paths, supervisorPid, generation) {
|
|
5033
5221
|
return import_node_path11.default.join(paths.catalogueDir, "supervisors", String(supervisorPid), import_zod7.z.uuid().parse(generation));
|
|
5034
5222
|
}
|
|
@@ -5047,21 +5235,31 @@ function parseCatalogueCache(text) {
|
|
|
5047
5235
|
}
|
|
5048
5236
|
}
|
|
5049
5237
|
function isCatalogueStale(cache, nowMs) {
|
|
5050
|
-
return
|
|
5238
|
+
return !within(cache.fetchedAt, nowMs, CATALOGUE_MAX_AGE_MS);
|
|
5051
5239
|
}
|
|
5052
5240
|
function filterCatalogue(models, catalogue) {
|
|
5053
5241
|
const included = catalogue.include === void 0 ? void 0 : (0, import_picomatch4.default)(catalogue.include, { dot: true });
|
|
5054
5242
|
const excluded = catalogue.exclude === void 0 ? void 0 : (0, import_picomatch4.default)(catalogue.exclude, { dot: true });
|
|
5055
5243
|
return models.filter((model) => included?.(model.id) !== false && excluded?.(model.id) !== true);
|
|
5056
5244
|
}
|
|
5057
|
-
|
|
5245
|
+
function catalogueSettingsFingerprint(provider) {
|
|
5246
|
+
return (0, import_node_crypto5.createHash)("sha256").update(canonicalJson([provider.baseUrl, provider.catalogue === void 0 ? false : provider.catalogue.url ?? null, provider.credential])).digest("hex");
|
|
5247
|
+
}
|
|
5248
|
+
function catalogueMatchesSettings(recorded, cache, provider) {
|
|
5249
|
+
return recorded?.fetchedAt === cache.fetchedAt && recorded.settings === catalogueSettingsFingerprint(provider);
|
|
5250
|
+
}
|
|
5251
|
+
var import_picomatch4, import_node_crypto5, import_node_path11, import_zod7, DEFAULT_CANDIDATE_URLS, MS_PER_SECOND4, SECONDS_PER_HOUR, HOURS_PER_DAY2, MS_PER_HOUR, HOURS_BETWEEN_RETRIES, CATALOGUE_MAX_AGE_MS, CATALOGUE_RETRY_MS, CATALOGUE_REQUEST_SECONDS, CATALOGUE_REQUEST_TIMEOUT_MS, CATALOGUE_REFRESH_TIMEOUT_MS, CATALOGUE_MAX_MODELS, CATALOGUE_ENTRY_MAX_BYTES, CATALOGUE_BODY_LIMIT_BYTES, CATALOGUE_WORKER_ALLOWANCE_MS, CATALOGUE_REFRESH_DEADLINE_MS, CatalogueModelSchema, CatalogueCacheSchema, CatalogueDigestSchema;
|
|
5058
5252
|
var init_providerCatalogue = __esm({
|
|
5059
5253
|
"src/providerCatalogue.ts"() {
|
|
5060
5254
|
"use strict";
|
|
5061
5255
|
import_picomatch4 = __toESM(require("picomatch"), 1);
|
|
5256
|
+
import_node_crypto5 = require("node:crypto");
|
|
5062
5257
|
import_node_path11 = __toESM(require("node:path"), 1);
|
|
5063
5258
|
import_zod7 = require("zod");
|
|
5064
5259
|
init_baseUrlDisplay();
|
|
5260
|
+
init_elapsedWindow();
|
|
5261
|
+
init_loggedText();
|
|
5262
|
+
init_canonicalJson();
|
|
5065
5263
|
init_names();
|
|
5066
5264
|
init_doorBounds();
|
|
5067
5265
|
DEFAULT_CANDIDATE_URLS = 2;
|
|
@@ -5075,10 +5273,14 @@ var init_providerCatalogue = __esm({
|
|
|
5075
5273
|
CATALOGUE_REQUEST_SECONDS = 10;
|
|
5076
5274
|
CATALOGUE_REQUEST_TIMEOUT_MS = CATALOGUE_REQUEST_SECONDS * MS_PER_SECOND4;
|
|
5077
5275
|
CATALOGUE_REFRESH_TIMEOUT_MS = DEFAULT_CANDIDATE_URLS * CATALOGUE_REQUEST_TIMEOUT_MS;
|
|
5276
|
+
CATALOGUE_MAX_MODELS = 1e4;
|
|
5277
|
+
CATALOGUE_ENTRY_MAX_BYTES = 1024;
|
|
5278
|
+
CATALOGUE_BODY_LIMIT_BYTES = CATALOGUE_MAX_MODELS * CATALOGUE_ENTRY_MAX_BYTES;
|
|
5078
5279
|
CATALOGUE_WORKER_ALLOWANCE_MS = DOOR_WORKER_START_ALLOWANCE_MS + BLOCKING_STEP_TIMEOUTS_MS.credentialCommand + BLOCKING_STEP_TIMEOUTS_MS.codexVersion;
|
|
5079
5280
|
CATALOGUE_REFRESH_DEADLINE_MS = CATALOGUE_REFRESH_TIMEOUT_MS + CATALOGUE_WORKER_ALLOWANCE_MS;
|
|
5080
5281
|
CatalogueModelSchema = import_zod7.z.strictObject({ id: import_zod7.z.string().min(1), name: import_zod7.z.string().min(1).optional() });
|
|
5081
5282
|
CatalogueCacheSchema = import_zod7.z.strictObject({ fetchedAt: import_zod7.z.number(), url: import_zod7.z.string().min(1), models: import_zod7.z.array(CatalogueModelSchema), credentialFingerprint: import_zod7.z.string().optional(), supervisorPid: import_zod7.z.number().int().positive().optional() });
|
|
5283
|
+
CatalogueDigestSchema = import_zod7.z.strictObject({ settings: import_zod7.z.string().min(1), fetchedAt: import_zod7.z.number() });
|
|
5082
5284
|
}
|
|
5083
5285
|
});
|
|
5084
5286
|
|
|
@@ -5109,17 +5311,6 @@ var init_catalogueCleanup = __esm({
|
|
|
5109
5311
|
});
|
|
5110
5312
|
|
|
5111
5313
|
// src/frontdoor/state.ts
|
|
5112
|
-
function readCatalogueStatus(fs17, paths, pid, generation, name) {
|
|
5113
|
-
const file = import_node_path13.default.join(import_node_path13.default.dirname(catalogueCachePath(paths, name, pid, generation)), `${name}.status.json`);
|
|
5114
|
-
const raw = fs17.readFileUtf8(file);
|
|
5115
|
-
if (raw === void 0) return void 0;
|
|
5116
|
-
try {
|
|
5117
|
-
const value = import_zod9.z.strictObject({ status: import_zod9.z.enum(["running", "ready", "failed"]), fingerprint: import_zod9.z.string().min(1).optional(), recordedAt: import_zod9.z.number().optional() }).safeParse(JSON.parse(raw));
|
|
5118
|
-
return value.success ? value.data : void 0;
|
|
5119
|
-
} catch {
|
|
5120
|
-
return void 0;
|
|
5121
|
-
}
|
|
5122
|
-
}
|
|
5123
5314
|
function launchKeyOf(launch) {
|
|
5124
5315
|
return `${String(launch.pid)}-${String(launch.startedAt)}`;
|
|
5125
5316
|
}
|
|
@@ -5130,7 +5321,12 @@ function writeFrontDoorCodexHome(fs17, frontdoorDir, pid, codexHome, generation)
|
|
|
5130
5321
|
`);
|
|
5131
5322
|
}
|
|
5132
5323
|
function readFrontDoorCodexRecord(fs17, frontdoorDir, pid) {
|
|
5133
|
-
|
|
5324
|
+
let raw;
|
|
5325
|
+
try {
|
|
5326
|
+
raw = fs17.readFileUtf8(import_node_path13.default.join(frontdoorDir, "codex-homes", `${String(pid)}.json`));
|
|
5327
|
+
} catch {
|
|
5328
|
+
return void 0;
|
|
5329
|
+
}
|
|
5134
5330
|
if (raw === void 0) return void 0;
|
|
5135
5331
|
try {
|
|
5136
5332
|
const parsed = import_zod9.z.strictObject({ codexHome: import_zod9.z.string().min(1), generation: import_zod9.z.uuid() }).safeParse(JSON.parse(raw));
|
|
@@ -5317,8 +5513,7 @@ var init_state = __esm({
|
|
|
5317
5513
|
import_zod9 = require("zod");
|
|
5318
5514
|
init_schema();
|
|
5319
5515
|
init_baseUrlDial();
|
|
5320
|
-
|
|
5321
|
-
FRONT_DOOR_PROTOCOL = 8;
|
|
5516
|
+
FRONT_DOOR_PROTOCOL = 9;
|
|
5322
5517
|
FRONT_DOOR_HANDOVER_PROTOCOL = 6;
|
|
5323
5518
|
FrontDoorSessionSchema = import_zod9.z.strictObject({ pid: import_zod9.z.number().int().positive(), startedAt: import_zod9.z.number(), token: import_zod9.z.string().min(1), supervisorPid: import_zod9.z.number().int().positive().optional(), sessionId: import_zod9.z.string().min(1).optional(), identity: import_zod9.z.string().min(1).optional(), models: ModelsConfigSchema.optional() });
|
|
5324
5519
|
MAX_CONTEXT_TEXT_LENGTH = 256;
|
|
@@ -5618,8 +5813,8 @@ function parseConnectTarget(authority) {
|
|
|
5618
5813
|
function isInterceptedHost(host, interceptHosts) {
|
|
5619
5814
|
return interceptHosts.includes(host);
|
|
5620
5815
|
}
|
|
5621
|
-
function servedByPipeline(
|
|
5622
|
-
return
|
|
5816
|
+
function servedByPipeline(path56) {
|
|
5817
|
+
return path56?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
5623
5818
|
}
|
|
5624
5819
|
function forwardableHeaders(headers) {
|
|
5625
5820
|
const connectionTokens = new Set(
|
|
@@ -5667,8 +5862,8 @@ function ensureCa(store, generate) {
|
|
|
5667
5862
|
}
|
|
5668
5863
|
function caParses(ca) {
|
|
5669
5864
|
try {
|
|
5670
|
-
new
|
|
5671
|
-
(0,
|
|
5865
|
+
new import_node_crypto6.X509Certificate(ca.certPem);
|
|
5866
|
+
(0, import_node_crypto6.createPrivateKey)(ca.keyPem);
|
|
5672
5867
|
return true;
|
|
5673
5868
|
} catch {
|
|
5674
5869
|
return false;
|
|
@@ -6005,11 +6200,11 @@ function realConnectCertStore(paths) {
|
|
|
6005
6200
|
}
|
|
6006
6201
|
};
|
|
6007
6202
|
}
|
|
6008
|
-
var
|
|
6203
|
+
var import_node_crypto6, fs3, CONNECT_INTERCEPT_HOST, CONNECT_INTERCEPT_HOSTS, ROUTED_PATH_PREFIX, HTTPS_PORT, HTTP_BAD_GATEWAY, CA_KEY_FILE_MODE, CONNECT_LINE_TOKENS, HEAD_TERMINATOR, MAX_CONNECT_HEAD_BYTES, CONNECT_ESTABLISHED, REFUSAL_HEADER, REFUSAL, CONNECT_LIMITS, CA_VALIDITY_DAYS, LEAF_VALIDITY_DAYS, CA_SUBJECT_COMMON_NAME, MS_PER_DAY, HOP_BY_HOP_HEADERS, TAP_ALPN_PROTOCOLS;
|
|
6009
6204
|
var init_connect = __esm({
|
|
6010
6205
|
"src/frontdoor/connect.ts"() {
|
|
6011
6206
|
"use strict";
|
|
6012
|
-
|
|
6207
|
+
import_node_crypto6 = require("node:crypto");
|
|
6013
6208
|
fs3 = __toESM(require("node:fs"), 1);
|
|
6014
6209
|
init_baseUrlDial();
|
|
6015
6210
|
init_x509();
|
|
@@ -6074,6 +6269,7 @@ var init_http = __esm({
|
|
|
6074
6269
|
methodNotAllowed: 405,
|
|
6075
6270
|
conflict: 409,
|
|
6076
6271
|
payloadTooLarge: 413,
|
|
6272
|
+
unsupportedMediaType: 415,
|
|
6077
6273
|
tooManyRequests: 429,
|
|
6078
6274
|
/** Not sent to anyone: the client is gone. Recorded for a response abandoned because the client disconnected, following the convention nginx uses for the same case. */
|
|
6079
6275
|
clientClosedRequest: 499,
|
|
@@ -6482,8 +6678,8 @@ function pathnameOf(url) {
|
|
|
6482
6678
|
return new URL(url ?? "/", "http://127.0.0.1").pathname;
|
|
6483
6679
|
}
|
|
6484
6680
|
function isRcSessionExchange(url) {
|
|
6485
|
-
const
|
|
6486
|
-
return
|
|
6681
|
+
const path56 = pathnameOf(url);
|
|
6682
|
+
return path56 === RC_SESSIONS_PATH_PREFIX || path56.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
|
|
6487
6683
|
}
|
|
6488
6684
|
function isSuccessful(status) {
|
|
6489
6685
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE;
|
|
@@ -6661,7 +6857,7 @@ function rememberBounded(record, key) {
|
|
|
6661
6857
|
}
|
|
6662
6858
|
}
|
|
6663
6859
|
function droppedKeyOf(requestId) {
|
|
6664
|
-
return requestId.length <= RC_REQUEST_ID_MAX_CHARS ? requestId : (0,
|
|
6860
|
+
return requestId.length <= RC_REQUEST_ID_MAX_CHARS ? requestId : (0, import_node_crypto7.createHash)("sha256").update(requestId).digest("hex");
|
|
6665
6861
|
}
|
|
6666
6862
|
function createRcSessionTracker(deps) {
|
|
6667
6863
|
const entries = /* @__PURE__ */ new Map();
|
|
@@ -7064,11 +7260,11 @@ function rcObserverAsPassthrough(observer) {
|
|
|
7064
7260
|
}
|
|
7065
7261
|
};
|
|
7066
7262
|
}
|
|
7067
|
-
var
|
|
7263
|
+
var import_node_crypto7, RC_SESSIONS_PATH_PREFIX, RC_SESSION_ID_PREFIX, RC_IDLE_EXPIRY_MS, RC_CREATE_RESPONSE_CAP_BYTES, CONFLICT_REASON_HEADER, RC_STREAM_WORKER_SOURCE, HIGH_SURROGATE_FIRST, HIGH_SURROGATE_LAST, RC_WORKER_IDLE, RC_PENDING_PER_SESSION_MAX, RC_REQUEST_ID_MAX_CHARS, RC_RETIRED_TOMBSTONES_MAX, RC_REQUEST_PARSE_CAP_BYTES, RC_PENDING_SUMMARY_EXCERPT_CHARS, SUCCESS_STATUS_MAX_EXCLUSIVE, OAUTH_AUTHORIZATION_PREFIX;
|
|
7068
7264
|
var init_rcSessions = __esm({
|
|
7069
7265
|
"src/frontdoor/rcSessions.ts"() {
|
|
7070
7266
|
"use strict";
|
|
7071
|
-
|
|
7267
|
+
import_node_crypto7 = require("node:crypto");
|
|
7072
7268
|
init_liveTasks();
|
|
7073
7269
|
init_http();
|
|
7074
7270
|
init_rcQuestions();
|
|
@@ -7218,8 +7414,8 @@ function buildRcGetContextUsagePayload(requestId, detail) {
|
|
|
7218
7414
|
function isRcReadFileEncoding(value) {
|
|
7219
7415
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
|
|
7220
7416
|
}
|
|
7221
|
-
function buildRcReadFilePayload(requestId,
|
|
7222
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
7417
|
+
function buildRcReadFilePayload(requestId, path56, options) {
|
|
7418
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path56, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
7223
7419
|
}
|
|
7224
7420
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
7225
7421
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -7353,15 +7549,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
7353
7549
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
7354
7550
|
return result.ok ? { ...result, requestId } : result;
|
|
7355
7551
|
}
|
|
7356
|
-
async function readRcSessionFile(deps, sessionId,
|
|
7357
|
-
if (
|
|
7552
|
+
async function readRcSessionFile(deps, sessionId, path56, options) {
|
|
7553
|
+
if (path56 === "") {
|
|
7358
7554
|
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" };
|
|
7359
7555
|
}
|
|
7360
7556
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
7361
7557
|
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" };
|
|
7362
7558
|
}
|
|
7363
7559
|
const requestId = deps.newUuid();
|
|
7364
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
7560
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path56, options), `read ${path56} from session ${sessionId}`);
|
|
7365
7561
|
return result.ok ? { ...result, requestId } : result;
|
|
7366
7562
|
}
|
|
7367
7563
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -7410,13 +7606,14 @@ async function teleportRcSession(deps, sessionId, marker) {
|
|
|
7410
7606
|
function buildRcMarkReadBody(eventId) {
|
|
7411
7607
|
return eventId === void 0 ? {} : { event_id: eventId };
|
|
7412
7608
|
}
|
|
7413
|
-
var RC_PERMISSION_MODES, RC_CONTEXT_USAGE_DETAILS, RC_READ_FILE_ENCODINGS;
|
|
7609
|
+
var RC_SEND_DELIVERY_NOTE, RC_PERMISSION_MODES, RC_CONTEXT_USAGE_DETAILS, RC_READ_FILE_ENCODINGS;
|
|
7414
7610
|
var init_rcWrites = __esm({
|
|
7415
7611
|
"src/frontdoor/rcWrites.ts"() {
|
|
7416
7612
|
"use strict";
|
|
7417
7613
|
init_http();
|
|
7418
7614
|
init_rcSessions();
|
|
7419
7615
|
init_rcQuestions();
|
|
7616
|
+
RC_SEND_DELIVERY_NOTE = "Claude Code reads it as a message from another session, not as a person typing in an attached client, because the service stamps it with the session's own client platform. Whether it reaches the model is the receiving session's crossSessionInbound setting: with none set, a session that bypasses permission prompts holds it for approval, since the write cannot attest a permission mode.";
|
|
7420
7617
|
RC_PERMISSION_MODES = ["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto"];
|
|
7421
7618
|
RC_CONTEXT_USAGE_DETAILS = ["summary", "full"];
|
|
7422
7619
|
RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
@@ -7738,11 +7935,11 @@ function createRcControlHandler(deps) {
|
|
|
7738
7935
|
path: "read-file",
|
|
7739
7936
|
read: (body) => {
|
|
7740
7937
|
const session = bodyString(body, "session");
|
|
7741
|
-
const
|
|
7938
|
+
const path56 = bodyString(body, "path");
|
|
7742
7939
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
7743
7940
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
7744
|
-
const refused2 = session === void 0 ||
|
|
7745
|
-
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,
|
|
7941
|
+
const refused2 = session === void 0 || path56 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
7942
|
+
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, path56, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
7746
7943
|
}
|
|
7747
7944
|
},
|
|
7748
7945
|
{
|
|
@@ -8065,9 +8262,9 @@ function requestIdOfBody(body) {
|
|
|
8065
8262
|
}
|
|
8066
8263
|
function frontDoorRcControl(transport, token) {
|
|
8067
8264
|
const headers = { authorization: `Bearer ${token}` };
|
|
8068
|
-
const listAnswerOf = async (
|
|
8265
|
+
const listAnswerOf = async (path56, what) => {
|
|
8069
8266
|
try {
|
|
8070
|
-
return await transport.request({ method: "GET", path:
|
|
8267
|
+
return await transport.request({ method: "GET", path: path56, headers });
|
|
8071
8268
|
} catch (error) {
|
|
8072
8269
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
8073
8270
|
}
|
|
@@ -8139,10 +8336,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8139
8336
|
}
|
|
8140
8337
|
return pending;
|
|
8141
8338
|
};
|
|
8142
|
-
const writeOf = async (
|
|
8339
|
+
const writeOf = async (path56, body, describeFailure2) => {
|
|
8143
8340
|
let answer;
|
|
8144
8341
|
try {
|
|
8145
|
-
answer = await transport.request({ method: "POST", path:
|
|
8342
|
+
answer = await transport.request({ method: "POST", path: path56, headers: { ...headers, "content-type": "application/json" }, body });
|
|
8146
8343
|
} catch (error) {
|
|
8147
8344
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
8148
8345
|
}
|
|
@@ -8173,10 +8370,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8173
8370
|
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}`),
|
|
8174
8371
|
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}`),
|
|
8175
8372
|
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}`),
|
|
8176
|
-
readFile: async (sessionId,
|
|
8373
|
+
readFile: async (sessionId, path56, options) => await writeOf(
|
|
8177
8374
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
8178
|
-
JSON.stringify({ session: sessionId, path:
|
|
8179
|
-
(status, message) => `reading ${
|
|
8375
|
+
JSON.stringify({ session: sessionId, path: path56, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
8376
|
+
(status, message) => `reading ${path56} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
8180
8377
|
),
|
|
8181
8378
|
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}`),
|
|
8182
8379
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -8413,12 +8610,12 @@ function tlsFacts(options) {
|
|
|
8413
8610
|
}
|
|
8414
8611
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8415
8612
|
const agent = new ExemptTlsAgent();
|
|
8416
|
-
const post = async (
|
|
8613
|
+
const post = async (path56, headers, body) => await new Promise((resolve, reject) => {
|
|
8417
8614
|
const options = {
|
|
8418
8615
|
host: target.host,
|
|
8419
8616
|
port: target.port,
|
|
8420
8617
|
method: "POST",
|
|
8421
|
-
path:
|
|
8618
|
+
path: path56,
|
|
8422
8619
|
// 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.
|
|
8423
8620
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
8424
8621
|
agent
|
|
@@ -8478,12 +8675,12 @@ function lateRcStreamDial(resolve) {
|
|
|
8478
8675
|
}
|
|
8479
8676
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8480
8677
|
const agent = new ExemptTlsAgent();
|
|
8481
|
-
const request4 = async (method,
|
|
8678
|
+
const request4 = async (method, path56, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
8482
8679
|
const options = {
|
|
8483
8680
|
host: target.host,
|
|
8484
8681
|
port: target.port,
|
|
8485
8682
|
method,
|
|
8486
|
-
path:
|
|
8683
|
+
path: path56,
|
|
8487
8684
|
// 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.
|
|
8488
8685
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
8489
8686
|
agent,
|
|
@@ -8525,9 +8722,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
8525
8722
|
return { status, body: await readAll(response) };
|
|
8526
8723
|
},
|
|
8527
8724
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
8528
|
-
const
|
|
8725
|
+
const path56 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
8529
8726
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
8530
|
-
const { status, response } = await request4("GET",
|
|
8727
|
+
const { status, response } = await request4("GET", path56, streamHeaders, void 0, signal);
|
|
8531
8728
|
if (!isSuccessful2(status)) {
|
|
8532
8729
|
await readAll(response);
|
|
8533
8730
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -8970,7 +9167,7 @@ function loadIdentity(identitiesDir, name, fs17) {
|
|
|
8970
9167
|
return id === void 0 ? void 0 : loadConfigFile(import_node_path15.default.join(identitiesDir, id, "identity.json"), IdentitySchema, fs17.readConfigFile);
|
|
8971
9168
|
}
|
|
8972
9169
|
var import_node_path15, IDENTITY_DECISION_SOURCES, IDENTITY_SOURCE_LABELS, CONFIG_PROFILE_DECISION_SOURCES;
|
|
8973
|
-
var
|
|
9170
|
+
var init_identity2 = __esm({
|
|
8974
9171
|
"src/launcher/identity.ts"() {
|
|
8975
9172
|
"use strict";
|
|
8976
9173
|
import_node_path15 = __toESM(require("node:path"), 1);
|
|
@@ -9019,9 +9216,9 @@ var init_identity = __esm({
|
|
|
9019
9216
|
});
|
|
9020
9217
|
|
|
9021
9218
|
// src/statusline/keys.ts
|
|
9022
|
-
function valueAt(source,
|
|
9219
|
+
function valueAt(source, path56) {
|
|
9023
9220
|
let current = source;
|
|
9024
|
-
for (const part of
|
|
9221
|
+
for (const part of path56) {
|
|
9025
9222
|
if (!isPlainObject(current)) {
|
|
9026
9223
|
return void 0;
|
|
9027
9224
|
}
|
|
@@ -9029,14 +9226,14 @@ function valueAt(source, path55) {
|
|
|
9029
9226
|
}
|
|
9030
9227
|
return current;
|
|
9031
9228
|
}
|
|
9032
|
-
function acceptsNull(
|
|
9033
|
-
const layer =
|
|
9229
|
+
function acceptsNull(path56) {
|
|
9230
|
+
const layer = path56.reduceRight((inner, part) => ({ [part]: inner }), null);
|
|
9034
9231
|
return StatuslineSchema.safeParse(layer).success;
|
|
9035
9232
|
}
|
|
9036
|
-
function keyOf(
|
|
9233
|
+
function keyOf(path56, declared) {
|
|
9037
9234
|
const optional = declared instanceof import_zod13.z.ZodOptional;
|
|
9038
9235
|
const leaf = optional ? declared.unwrap() : declared;
|
|
9039
|
-
const common = { path:
|
|
9236
|
+
const common = { path: path56.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path56), optional, unsettable: acceptsNull(path56) };
|
|
9040
9237
|
if (leaf instanceof import_zod13.z.ZodNumber) {
|
|
9041
9238
|
return { ...common, kind: "integer", choices: [] };
|
|
9042
9239
|
}
|
|
@@ -9061,7 +9258,7 @@ function keyOf(path55, declared) {
|
|
|
9061
9258
|
if (leaf instanceof import_zod13.z.ZodArray && leaf.element instanceof import_zod13.z.ZodString) {
|
|
9062
9259
|
return { ...common, kind: "textList", choices: [] };
|
|
9063
9260
|
}
|
|
9064
|
-
throw new TypeError(`statusline setting ${
|
|
9261
|
+
throw new TypeError(`statusline setting ${path56.join(".")} has a kind the key listing does not describe`);
|
|
9065
9262
|
}
|
|
9066
9263
|
function walk(shape, prefix) {
|
|
9067
9264
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof import_zod13.z.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -9079,15 +9276,15 @@ var init_keys = __esm({
|
|
|
9079
9276
|
});
|
|
9080
9277
|
|
|
9081
9278
|
// src/statusline/change.ts
|
|
9082
|
-
function keyNamed(
|
|
9083
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
9279
|
+
function keyNamed(path56) {
|
|
9280
|
+
const found = statuslineKeys().find((key) => key.path === path56);
|
|
9084
9281
|
if (found === void 0) {
|
|
9085
|
-
throw new UsageError(`"${
|
|
9282
|
+
throw new UsageError(`"${path56}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
9086
9283
|
}
|
|
9087
9284
|
return found;
|
|
9088
9285
|
}
|
|
9089
|
-
function setAt(target,
|
|
9090
|
-
const [head, ...rest] =
|
|
9286
|
+
function setAt(target, path56, value) {
|
|
9287
|
+
const [head, ...rest] = path56;
|
|
9091
9288
|
if (head === void 0) {
|
|
9092
9289
|
return;
|
|
9093
9290
|
}
|
|
@@ -9100,8 +9297,8 @@ function setAt(target, path55, value) {
|
|
|
9100
9297
|
target[head] = next;
|
|
9101
9298
|
setAt(next, rest, value);
|
|
9102
9299
|
}
|
|
9103
|
-
function removeAt(target,
|
|
9104
|
-
const [head, ...rest] =
|
|
9300
|
+
function removeAt(target, path56) {
|
|
9301
|
+
const [head, ...rest] = path56;
|
|
9105
9302
|
if (head === void 0) {
|
|
9106
9303
|
return;
|
|
9107
9304
|
}
|
|
@@ -9119,13 +9316,13 @@ function removeAt(target, path55) {
|
|
|
9119
9316
|
}
|
|
9120
9317
|
function applyStatuslineChange(existing, change) {
|
|
9121
9318
|
const draft = structuredClone(existing ?? {});
|
|
9122
|
-
for (const [
|
|
9123
|
-
keyNamed(
|
|
9124
|
-
setAt(draft,
|
|
9319
|
+
for (const [path56, value] of Object.entries(change.set ?? {})) {
|
|
9320
|
+
keyNamed(path56);
|
|
9321
|
+
setAt(draft, path56.split("."), value);
|
|
9125
9322
|
}
|
|
9126
|
-
for (const
|
|
9127
|
-
keyNamed(
|
|
9128
|
-
removeAt(draft,
|
|
9323
|
+
for (const path56 of change.unset ?? []) {
|
|
9324
|
+
keyNamed(path56);
|
|
9325
|
+
removeAt(draft, path56.split("."));
|
|
9129
9326
|
}
|
|
9130
9327
|
const result = StatuslineSchema.safeParse(draft);
|
|
9131
9328
|
if (!result.success) {
|
|
@@ -9361,19 +9558,19 @@ function writePools(paths, pools) {
|
|
|
9361
9558
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
9362
9559
|
}
|
|
9363
9560
|
function poolCycleOf(pools, name) {
|
|
9364
|
-
const walk2 = (current,
|
|
9561
|
+
const walk2 = (current, path56) => {
|
|
9365
9562
|
for (const entry of pools[current]?.identities ?? []) {
|
|
9366
9563
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
9367
9564
|
if (nested === void 0) {
|
|
9368
9565
|
continue;
|
|
9369
9566
|
}
|
|
9370
9567
|
if (nested === name) {
|
|
9371
|
-
return [...
|
|
9568
|
+
return [...path56, nested];
|
|
9372
9569
|
}
|
|
9373
|
-
if (
|
|
9570
|
+
if (path56.includes(nested)) {
|
|
9374
9571
|
continue;
|
|
9375
9572
|
}
|
|
9376
|
-
const found = walk2(nested, [...
|
|
9573
|
+
const found = walk2(nested, [...path56, nested]);
|
|
9377
9574
|
if (found !== void 0) {
|
|
9378
9575
|
return found;
|
|
9379
9576
|
}
|
|
@@ -9452,7 +9649,7 @@ var init_poolStore = __esm({
|
|
|
9452
9649
|
init_configProfilesStore();
|
|
9453
9650
|
init_store();
|
|
9454
9651
|
init_schema();
|
|
9455
|
-
|
|
9652
|
+
init_identity2();
|
|
9456
9653
|
PoolNotFoundError = class extends CliError {
|
|
9457
9654
|
constructor(poolName) {
|
|
9458
9655
|
super(`No pool named "${poolName}". Run \`agent-shim pool add ${poolName} --identity <name>...\` first.`);
|
|
@@ -9793,7 +9990,7 @@ function listKey(list) {
|
|
|
9793
9990
|
return `${list},appended`;
|
|
9794
9991
|
}
|
|
9795
9992
|
function digest2(value) {
|
|
9796
|
-
return (0,
|
|
9993
|
+
return (0, import_node_crypto8.createHash)("sha256").update(value).digest("hex");
|
|
9797
9994
|
}
|
|
9798
9995
|
function recordedDigests(env) {
|
|
9799
9996
|
const raw = env[INJECTED_ENV];
|
|
@@ -9873,11 +10070,11 @@ function withoutInjected(env) {
|
|
|
9873
10070
|
});
|
|
9874
10071
|
return Object.fromEntries(entries);
|
|
9875
10072
|
}
|
|
9876
|
-
var
|
|
10073
|
+
var import_node_crypto8, import_zod14, INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
|
|
9877
10074
|
var init_injected = __esm({
|
|
9878
10075
|
"src/launcher/injected.ts"() {
|
|
9879
10076
|
"use strict";
|
|
9880
|
-
|
|
10077
|
+
import_node_crypto8 = require("node:crypto");
|
|
9881
10078
|
import_zod14 = require("zod");
|
|
9882
10079
|
init_headers();
|
|
9883
10080
|
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
@@ -9954,7 +10151,7 @@ var init_guard = __esm({
|
|
|
9954
10151
|
|
|
9955
10152
|
// src/usage/signIn.ts
|
|
9956
10153
|
function claudeCodeKeychainService(configDir) {
|
|
9957
|
-
return `${KEYCHAIN_SERVICE_PREFIX}-${(0,
|
|
10154
|
+
return `${KEYCHAIN_SERVICE_PREFIX}-${(0, import_node_crypto9.createHash)("sha256").update(configDir).digest("hex").slice(0, KEYCHAIN_SERVICE_HASH_DIGITS)}`;
|
|
9958
10155
|
}
|
|
9959
10156
|
function keychainHasItem(run, configDir) {
|
|
9960
10157
|
return run.run("security", ["find-generic-password", "-s", claudeCodeKeychainService(configDir)]).status === 0;
|
|
@@ -10005,11 +10202,11 @@ function storedLoginUsable(run, claudeBin, configDir, env) {
|
|
|
10005
10202
|
}
|
|
10006
10203
|
return void 0;
|
|
10007
10204
|
}
|
|
10008
|
-
var
|
|
10205
|
+
var import_node_crypto9, import_node_path19, CREDENTIALS_FILE, KEYCHAIN_SERVICE_PREFIX, KEYCHAIN_SERVICE_HASH_DIGITS, AUTH_STATUS_TIMEOUT_MS;
|
|
10009
10206
|
var init_signIn = __esm({
|
|
10010
10207
|
"src/usage/signIn.ts"() {
|
|
10011
10208
|
"use strict";
|
|
10012
|
-
|
|
10209
|
+
import_node_crypto9 = require("node:crypto");
|
|
10013
10210
|
import_node_path19 = __toESM(require("node:path"), 1);
|
|
10014
10211
|
init_guard();
|
|
10015
10212
|
CREDENTIALS_FILE = ".credentials.json";
|
|
@@ -10148,7 +10345,7 @@ function serialisedFor(entry, owner) {
|
|
|
10148
10345
|
return JSON.stringify({ owner, ...withoutOwner(entry) });
|
|
10149
10346
|
}
|
|
10150
10347
|
function tempPathFor(target) {
|
|
10151
|
-
return import_node_path20.default.join(import_node_path20.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0,
|
|
10348
|
+
return import_node_path20.default.join(import_node_path20.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0, import_node_crypto10.randomUUID)()}`);
|
|
10152
10349
|
}
|
|
10153
10350
|
function processRuns(pid) {
|
|
10154
10351
|
try {
|
|
@@ -10267,11 +10464,11 @@ function createRealCredentialCache(root, keychain = { run: security, platform: p
|
|
|
10267
10464
|
function realCredentialCacheEnv(paths) {
|
|
10268
10465
|
return { port: createRealCredentialCache(paths.root), platform: process.platform, now: () => Date.now() };
|
|
10269
10466
|
}
|
|
10270
|
-
var
|
|
10467
|
+
var import_node_crypto10, import_node_fs5, import_node_path20, CACHE_DIR_MODE, CACHE_FILE_MODE, TEMP_PREFIX, TEMP_NAME, RELEASED_TEMP_NAME;
|
|
10271
10468
|
var init_realCredentialCache = __esm({
|
|
10272
10469
|
"src/realCredentialCache.ts"() {
|
|
10273
10470
|
"use strict";
|
|
10274
|
-
|
|
10471
|
+
import_node_crypto10 = require("node:crypto");
|
|
10275
10472
|
import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
10276
10473
|
import_node_path20 = __toESM(require("node:path"), 1);
|
|
10277
10474
|
init_blockingSpawn();
|
|
@@ -10429,7 +10626,7 @@ function migrateHeadroomState(fs17, files, isRunning) {
|
|
|
10429
10626
|
fs17.removeRecursive(files.legacyStateFile);
|
|
10430
10627
|
}
|
|
10431
10628
|
function hashAllowlist(allowlist) {
|
|
10432
|
-
return (0,
|
|
10629
|
+
return (0, import_node_crypto11.createHash)("sha256").update(allowlist.join("\n")).digest("hex");
|
|
10433
10630
|
}
|
|
10434
10631
|
function formatAllowlistFile(allowlist) {
|
|
10435
10632
|
return allowlist.map((entry) => `${entry}
|
|
@@ -10534,11 +10731,11 @@ function readStartLock(fs17, lockFile) {
|
|
|
10534
10731
|
return void 0;
|
|
10535
10732
|
}
|
|
10536
10733
|
}
|
|
10537
|
-
var
|
|
10734
|
+
var import_node_crypto11, import_node_path21, import_zod15, HeadroomStateSchema, HeadroomSessionSchema, HeadroomLockSchema, HEADROOM_ALLOWLIST_FILE_FLAG, ALLOWLIST_LINE_BREAKS, ALLOWLIST_WHITESPACE, ALLOWLIST_FILE_SEPARATORS, ALLOWLIST_FILE_COMMENT, ALLOWLIST_ENTRY_WHITESPACE, ALLOWLIST_SURROUNDING_WHITESPACE, ALLOWLIST_SAFE_SCHEMES;
|
|
10538
10735
|
var init_state2 = __esm({
|
|
10539
10736
|
"src/headroom/state.ts"() {
|
|
10540
10737
|
"use strict";
|
|
10541
|
-
|
|
10738
|
+
import_node_crypto11 = require("node:crypto");
|
|
10542
10739
|
import_node_path21 = __toESM(require("node:path"), 1);
|
|
10543
10740
|
import_zod15 = require("zod");
|
|
10544
10741
|
init_schema();
|
|
@@ -10781,13 +10978,13 @@ function settingsEnv(settings) {
|
|
|
10781
10978
|
return settings.rolloutChannel === void 0 ? {} : { HEADROOM_ROLLOUT_CHANNEL: settings.rolloutChannel };
|
|
10782
10979
|
}
|
|
10783
10980
|
function hashSettings(settings) {
|
|
10784
|
-
return (0,
|
|
10981
|
+
return (0, import_node_crypto12.createHash)("sha256").update(JSON.stringify([...settingsArgs(settings), JSON.stringify(settingsEnv(settings))])).digest("hex");
|
|
10785
10982
|
}
|
|
10786
|
-
var
|
|
10983
|
+
var import_node_crypto12;
|
|
10787
10984
|
var init_settings = __esm({
|
|
10788
10985
|
"src/headroom/settings.ts"() {
|
|
10789
10986
|
"use strict";
|
|
10790
|
-
|
|
10987
|
+
import_node_crypto12 = require("node:crypto");
|
|
10791
10988
|
}
|
|
10792
10989
|
});
|
|
10793
10990
|
|
|
@@ -11720,7 +11917,7 @@ function realResolveClaudeBinary(isOwnBinary) {
|
|
|
11720
11917
|
function realInstalledClaudeVersions() {
|
|
11721
11918
|
return installedVersions(listVersionsDir(defaultVersionsDir()));
|
|
11722
11919
|
}
|
|
11723
|
-
var import_node_child_process2,
|
|
11920
|
+
var import_node_child_process2, import_node_crypto13, import_node_fs6, import_node_os2, import_node_path24, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS2, DIRECTORY_FLUSH_UNSUPPORTED_CODES, realFarmFs, INT32_BYTE_LENGTH, KEY_POLL_MS, CTRL_C_BYTE, realHoldPort, PS_TIMEOUT_MS, RUN_OUTPUT_LIMIT_MIB, BYTES_PER_MIB2, RUN_OUTPUT_LIMIT_BYTES, realRunPort, ASYNC_RUN_TIMEOUT_MS, realRunAsync, MACOS_GUI_SESSION_MANAGER, realCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, realLogPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT, processPathFacts;
|
|
11724
11921
|
var init_realPorts = __esm({
|
|
11725
11922
|
"src/realPorts.ts"() {
|
|
11726
11923
|
"use strict";
|
|
@@ -11728,7 +11925,7 @@ var init_realPorts = __esm({
|
|
|
11728
11925
|
init_doorBounds();
|
|
11729
11926
|
init_processRole();
|
|
11730
11927
|
import_node_child_process2 = require("node:child_process");
|
|
11731
|
-
|
|
11928
|
+
import_node_crypto13 = require("node:crypto");
|
|
11732
11929
|
import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
11733
11930
|
import_node_os2 = __toESM(require("node:os"), 1);
|
|
11734
11931
|
import_node_path24 = __toESM(require("node:path"), 1);
|
|
@@ -11879,7 +12076,7 @@ var init_realPorts = __esm({
|
|
|
11879
12076
|
},
|
|
11880
12077
|
hashFile(filePath) {
|
|
11881
12078
|
try {
|
|
11882
|
-
return (0,
|
|
12079
|
+
return (0, import_node_crypto13.createHash)("sha256").update(import_node_fs6.default.readFileSync(filePath)).digest("hex");
|
|
11883
12080
|
} catch (error) {
|
|
11884
12081
|
if (isEnoent3(error) || isErrorWithCode(error, "EISDIR")) {
|
|
11885
12082
|
return void 0;
|
|
@@ -13131,7 +13328,7 @@ var init_poolPick = __esm({
|
|
|
13131
13328
|
import_node_path26 = __toESM(require("node:path"), 1);
|
|
13132
13329
|
import_zod19 = require("zod");
|
|
13133
13330
|
init_cliError();
|
|
13134
|
-
|
|
13331
|
+
init_identity2();
|
|
13135
13332
|
init_schema();
|
|
13136
13333
|
init_identityAccounts();
|
|
13137
13334
|
init_account();
|
|
@@ -13157,7 +13354,7 @@ var init_poolPick = __esm({
|
|
|
13157
13354
|
|
|
13158
13355
|
// src/identityRenameJournal.ts
|
|
13159
13356
|
function renamePairFileName(from, to, suffix) {
|
|
13160
|
-
return `${(0,
|
|
13357
|
+
return `${(0, import_node_crypto14.createHash)("sha256").update(`${from}\0${to}`).digest("hex").slice(0, FILE_NAME_HASH_DIGITS)}${suffix}`;
|
|
13161
13358
|
}
|
|
13162
13359
|
function readRenameJournal(fs17, file) {
|
|
13163
13360
|
const raw = fs17.readFileUtf8(file);
|
|
@@ -13228,11 +13425,11 @@ function requireNameFreeOfUnfinishedRename(fs17, directory, name, action, sameNa
|
|
|
13228
13425
|
throw new NameHeldByUnfinishedRenameError(action, name, held, finishabilityOf(held, exists));
|
|
13229
13426
|
}
|
|
13230
13427
|
}
|
|
13231
|
-
var
|
|
13428
|
+
var import_node_crypto14, import_node_path27, import_zod20, RenameJournalSchema, FILE_NAME_HASH_DIGITS, JOURNAL_SUFFIX, RenameJournalUnreadableError, NameHeldByUnfinishedRenameError;
|
|
13232
13429
|
var init_identityRenameJournal = __esm({
|
|
13233
13430
|
"src/identityRenameJournal.ts"() {
|
|
13234
13431
|
"use strict";
|
|
13235
|
-
|
|
13432
|
+
import_node_crypto14 = require("node:crypto");
|
|
13236
13433
|
import_node_path27 = __toESM(require("node:path"), 1);
|
|
13237
13434
|
import_zod20 = require("zod");
|
|
13238
13435
|
init_cliError();
|
|
@@ -13389,7 +13586,7 @@ var init_identityNameRenameRecord = __esm({
|
|
|
13389
13586
|
|
|
13390
13587
|
// src/launcher/launchRecords.ts
|
|
13391
13588
|
function recordFile(directory, pid) {
|
|
13392
|
-
return import_node_path29.default.join(directory, `${String(pid)}.${(0,
|
|
13589
|
+
return import_node_path29.default.join(directory, `${String(pid)}.${(0, import_node_crypto15.randomUUID)()}${RECORD_SUFFIX2}`);
|
|
13393
13590
|
}
|
|
13394
13591
|
function readRecord(fs17, directory, name) {
|
|
13395
13592
|
if (!name.endsWith(RECORD_SUFFIX2)) {
|
|
@@ -13430,12 +13627,12 @@ function liveLaunchesOn(fs17, directory, identity, isRunning) {
|
|
|
13430
13627
|
return record?.identity === identity && isRunning(record.pid) ? [record.pid] : [];
|
|
13431
13628
|
}).sort((left, right) => left - right);
|
|
13432
13629
|
}
|
|
13433
|
-
var import_node_path29,
|
|
13630
|
+
var import_node_path29, import_node_crypto15, import_zod22, LaunchRecordSchema, RECORD_SUFFIX2;
|
|
13434
13631
|
var init_launchRecords = __esm({
|
|
13435
13632
|
"src/launcher/launchRecords.ts"() {
|
|
13436
13633
|
"use strict";
|
|
13437
13634
|
import_node_path29 = __toESM(require("node:path"), 1);
|
|
13438
|
-
|
|
13635
|
+
import_node_crypto15 = require("node:crypto");
|
|
13439
13636
|
import_zod22 = require("zod");
|
|
13440
13637
|
LaunchRecordSchema = import_zod22.z.strictObject({
|
|
13441
13638
|
/** The launcher's process id, which is what tells a launch in progress from a record a crashed launcher left behind. */
|
|
@@ -13838,7 +14035,7 @@ var init_identityStore = __esm({
|
|
|
13838
14035
|
init_store();
|
|
13839
14036
|
init_schema();
|
|
13840
14037
|
init_cliError();
|
|
13841
|
-
|
|
14038
|
+
init_identity2();
|
|
13842
14039
|
init_poolStore();
|
|
13843
14040
|
init_read();
|
|
13844
14041
|
init_credential();
|
|
@@ -13912,7 +14109,7 @@ var init_package = __esm({
|
|
|
13912
14109
|
"package.json"() {
|
|
13913
14110
|
package_default = {
|
|
13914
14111
|
name: "claude-use",
|
|
13915
|
-
version: "14.
|
|
14112
|
+
version: "14.3.1",
|
|
13916
14113
|
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.",
|
|
13917
14114
|
license: "MIT",
|
|
13918
14115
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -14203,326 +14400,422 @@ var init_claudeShim = __esm({
|
|
|
14203
14400
|
}
|
|
14204
14401
|
});
|
|
14205
14402
|
|
|
14206
|
-
// src/
|
|
14207
|
-
function
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
return true;
|
|
14212
|
-
case "false":
|
|
14213
|
-
case "0":
|
|
14214
|
-
return false;
|
|
14215
|
-
default:
|
|
14216
|
-
return void 0;
|
|
14217
|
-
}
|
|
14403
|
+
// src/frontdoor/probe.ts
|
|
14404
|
+
function probeWorkerSource(body) {
|
|
14405
|
+
return `const { workerData } = require("node:worker_threads");
|
|
14406
|
+
${STARTED_SIGNAL_SOURCE}
|
|
14407
|
+
${body}`;
|
|
14218
14408
|
}
|
|
14219
|
-
|
|
14220
|
-
"
|
|
14221
|
-
|
|
14222
|
-
}
|
|
14223
|
-
});
|
|
14224
|
-
|
|
14225
|
-
// src/cli/envBool.ts
|
|
14226
|
-
function parseEnvBool(variable, value) {
|
|
14227
|
-
if (value === void 0 || value === "") {
|
|
14228
|
-
return void 0;
|
|
14229
|
-
}
|
|
14230
|
-
const parsed = parseBoolWord(value);
|
|
14231
|
-
if (parsed === void 0) {
|
|
14232
|
-
throw new InvalidEnvBoolError(variable, value);
|
|
14233
|
-
}
|
|
14234
|
-
return parsed;
|
|
14409
|
+
function requestCatalogueRefreshSync(port, caPem, token, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
14410
|
+
refuseToBlockInRole("a synchronous catalogue refresh request");
|
|
14411
|
+
return workers.start(CATALOGUE_REQUEST_SOURCE, { port, ca: caPem, token }, timeoutMs).verdict();
|
|
14235
14412
|
}
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
"use strict";
|
|
14240
|
-
init_cliError();
|
|
14241
|
-
init_bool();
|
|
14242
|
-
InvalidEnvBoolError = class extends UsageError {
|
|
14243
|
-
constructor(variable, value) {
|
|
14244
|
-
super(`${variable} must be one of true, false, 1 or 0, got "${value}".`);
|
|
14245
|
-
this.variable = variable;
|
|
14246
|
-
this.value = value;
|
|
14247
|
-
this.name = "InvalidEnvBoolError";
|
|
14248
|
-
}
|
|
14249
|
-
variable;
|
|
14250
|
-
value;
|
|
14251
|
-
};
|
|
14252
|
-
}
|
|
14253
|
-
});
|
|
14254
|
-
|
|
14255
|
-
// src/pathNorm.ts
|
|
14256
|
-
function expandTilde(value, home) {
|
|
14257
|
-
if (value === "~") {
|
|
14258
|
-
return home;
|
|
14259
|
-
}
|
|
14260
|
-
if (value.startsWith("~/")) {
|
|
14261
|
-
return import_node_path37.default.join(home, value.slice(2));
|
|
14262
|
-
}
|
|
14263
|
-
return value;
|
|
14413
|
+
function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
14414
|
+
refuseToBlockInRole("a synchronous probe of the front door");
|
|
14415
|
+
return workers.start(PROBE_SOURCE, { port, ca: caPem }, timeoutMs).verdict();
|
|
14264
14416
|
}
|
|
14265
|
-
function
|
|
14266
|
-
|
|
14417
|
+
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
14418
|
+
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
14419
|
+
return workers.start(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, platform: process.platform }, timeoutMs).verdict();
|
|
14267
14420
|
}
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14272
|
-
|
|
14421
|
+
function startAddressProbes(targets, workers = realProbeWorkers, portBase) {
|
|
14422
|
+
refuseToBlockInRole("a synchronous probe of a provider's address");
|
|
14423
|
+
const base = portBase ?? processPortBase();
|
|
14424
|
+
const distinct = /* @__PURE__ */ new Map();
|
|
14425
|
+
for (const target of targets) {
|
|
14426
|
+
distinct.set(targetKey(target), target);
|
|
14273
14427
|
}
|
|
14274
|
-
|
|
14275
|
-
|
|
14276
|
-
|
|
14277
|
-
|
|
14278
|
-
const
|
|
14279
|
-
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
const loaded = loadConfigFile(filepath, ConfigProfileSchema, params.read);
|
|
14283
|
-
if (loaded === void 0) {
|
|
14284
|
-
return void 0;
|
|
14428
|
+
const unique = Array.from(distinct.values());
|
|
14429
|
+
const stride = Math.max(1, Math.floor(DOOR_SOURCE_PORT_COUNT / unique.length));
|
|
14430
|
+
const verdicts = /* @__PURE__ */ new Map();
|
|
14431
|
+
const running = [];
|
|
14432
|
+
const settleOldest = () => {
|
|
14433
|
+
const oldest = running.shift();
|
|
14434
|
+
if (oldest !== void 0) {
|
|
14435
|
+
verdicts.set(oldest.key, oldest.verdict());
|
|
14285
14436
|
}
|
|
14286
|
-
return { name, profile: loaded.config, entryOrder: loaded.entryOrder, filepath: loaded.filepath };
|
|
14287
14437
|
};
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14438
|
+
unique.forEach((target, index) => {
|
|
14439
|
+
if (running.length >= MAX_CONCURRENT_PROBES) {
|
|
14440
|
+
settleOldest();
|
|
14441
|
+
}
|
|
14442
|
+
const portFirst = DOOR_SOURCE_PORT_START + (base + index * stride) % DOOR_SOURCE_PORT_COUNT;
|
|
14443
|
+
try {
|
|
14444
|
+
const started = workers.start(ACCEPT_PROBE_SOURCE, { host: target.host, port: target.port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, portFirst, platform: process.platform }, target.timeoutMs);
|
|
14445
|
+
running.push({ key: targetKey(target), verdict: started.verdict, cancel: started.cancel });
|
|
14446
|
+
} catch (error) {
|
|
14447
|
+
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
14448
|
+
running.push({ key: targetKey(target), verdict: () => ({ ok: false, reason }), cancel: () => void 0 });
|
|
14449
|
+
}
|
|
14293
14450
|
});
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14451
|
+
return {
|
|
14452
|
+
settle: () => {
|
|
14453
|
+
while (running.length > 0) {
|
|
14454
|
+
settleOldest();
|
|
14455
|
+
}
|
|
14456
|
+
return targets.map((target) => {
|
|
14457
|
+
const verdict = verdicts.get(targetKey(target));
|
|
14458
|
+
if (verdict === void 0) {
|
|
14459
|
+
throw new Error("the batch probe settled no verdict for one of its targets");
|
|
14460
|
+
}
|
|
14461
|
+
return verdict;
|
|
14462
|
+
});
|
|
14463
|
+
},
|
|
14464
|
+
cancel: () => {
|
|
14465
|
+
for (const started of running.splice(0)) {
|
|
14466
|
+
started.cancel();
|
|
14467
|
+
}
|
|
14308
14468
|
}
|
|
14309
|
-
levels.push({
|
|
14310
|
-
dir,
|
|
14311
|
-
...portable === void 0 ? {} : { portable: { config: portable.config, entryOrder: portable.entryOrder, filepath: portable.filepath } },
|
|
14312
|
-
...rules.length === 0 ? {} : { rules },
|
|
14313
|
-
...portableLocal === void 0 ? {} : { portableLocal: { config: portableLocal.config, entryOrder: portableLocal.entryOrder, filepath: portableLocal.filepath } }
|
|
14314
|
-
});
|
|
14315
|
-
}
|
|
14316
|
-
const input = {
|
|
14317
|
-
home: params.home,
|
|
14318
|
-
...globalConfig === void 0 ? {} : { globalConfig: { config: globalConfig.config, entryOrder: globalConfig.entryOrder, filepath: globalConfig.filepath } },
|
|
14319
|
-
...params.baseConfigProfile === void 0 ? {} : { baseConfigProfile: params.baseConfigProfile },
|
|
14320
|
-
loadProfile,
|
|
14321
|
-
levels,
|
|
14322
|
-
...params.cliOverride === void 0 ? {} : { cliOverride: params.cliOverride }
|
|
14323
14469
|
};
|
|
14324
|
-
return { input, ...globalConfig === void 0 ? {} : { globalConfig: globalConfig.config } };
|
|
14325
14470
|
}
|
|
14326
|
-
function
|
|
14327
|
-
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
|
|
14338
|
-
|
|
14471
|
+
function startProbeWorker(source, data, timeoutMs, spawn3 = spawnRealWorker, startLimitMs = PROBE_WORKER_START_LIMIT_MS, wait = slicedProbeWait) {
|
|
14472
|
+
const startLimit = performance.now() + startLimitMs;
|
|
14473
|
+
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
14474
|
+
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
14475
|
+
let worker;
|
|
14476
|
+
try {
|
|
14477
|
+
worker = spawn3(`${WORKER_PRELUDE_SOURCE}
|
|
14478
|
+
new Function("require", ${JSON.stringify(source)})(require);`, {
|
|
14479
|
+
eval: true,
|
|
14480
|
+
workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS, startedSlot: STARTED_SLOT, failurePrefix: PROBE_WORKER_FAILURE_PREFIX, claimSlot: CLAIM_SLOT }
|
|
14481
|
+
});
|
|
14482
|
+
} catch (error) {
|
|
14483
|
+
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
14484
|
+
return { verdict: () => ({ ok: false, reason }), cancel: () => void 0 };
|
|
14485
|
+
}
|
|
14486
|
+
worker.on("error", (error) => {
|
|
14487
|
+
if (Atomics.compareExchange(header, CLAIM_SLOT, 0, 1) !== 0) {
|
|
14488
|
+
return;
|
|
14489
|
+
}
|
|
14490
|
+
const bytes = Buffer.from(PROBE_WORKER_FAILURE_PREFIX + error.message, "utf8").subarray(0, REASON_BYTES);
|
|
14491
|
+
new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES).set(bytes);
|
|
14492
|
+
Atomics.store(header, 1, bytes.length);
|
|
14493
|
+
Atomics.store(header, 0, VERDICT_FAILED);
|
|
14494
|
+
Atomics.store(header, STARTED_SLOT, 1);
|
|
14495
|
+
});
|
|
14496
|
+
worker.unref();
|
|
14497
|
+
return {
|
|
14498
|
+
verdict: () => {
|
|
14499
|
+
try {
|
|
14500
|
+
wait(header, STARTED_SLOT, WORKER_NOT_STARTED, Math.max(0, startLimit - performance.now()));
|
|
14501
|
+
if (Atomics.load(header, STARTED_SLOT) === WORKER_NOT_STARTED && Atomics.load(header, 0) === VERDICT_PENDING) {
|
|
14502
|
+
return { ok: false, reason: `the probe worker did not start within ${String(startLimitMs)}ms` };
|
|
14503
|
+
}
|
|
14504
|
+
wait(header, 0, VERDICT_PENDING, timeoutMs + PROBE_WAIT_MARGIN_MS);
|
|
14505
|
+
const verdict = Atomics.load(header, 0);
|
|
14506
|
+
if (verdict === VERDICT_PENDING) {
|
|
14507
|
+
return { ok: false, reason: `the probe did not finish within ${String(timeoutMs + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
14508
|
+
}
|
|
14509
|
+
if (verdict === VERDICT_OK) {
|
|
14510
|
+
return { ok: true };
|
|
14511
|
+
}
|
|
14512
|
+
const length = Atomics.load(header, 1);
|
|
14513
|
+
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
14514
|
+
} finally {
|
|
14515
|
+
void worker.terminate();
|
|
14339
14516
|
}
|
|
14517
|
+
},
|
|
14518
|
+
cancel: () => {
|
|
14519
|
+
void worker.terminate();
|
|
14340
14520
|
}
|
|
14341
|
-
}
|
|
14342
|
-
return { ...identity === void 0 ? {} : { identity }, ...configProfile === void 0 ? {} : { configProfile } };
|
|
14521
|
+
};
|
|
14343
14522
|
}
|
|
14344
|
-
var
|
|
14345
|
-
var
|
|
14346
|
-
"src/
|
|
14523
|
+
var import_node_worker_threads, PROBE_TIMEOUT_MS, PROBE_WAIT_MARGIN_MS, REASON_BYTES, HEADER_SLOTS, STARTED_SLOT, CLAIM_SLOT, PROBE_WORKER_START_LIMIT_MS, STARTED_SIGNAL_SOURCE, PROBE_WORKER_FAILURE_PREFIX, INT32_BYTES, VERDICT_PENDING, WORKER_NOT_STARTED, VERDICT_OK, VERDICT_FAILED, WORKER_PRELUDE_SOURCE, PROBE_SOURCE, CATALOGUE_REQUEST_SOURCE, realProbeWorkers, ACCEPT_PROBE_SOURCE, PROBE_PORT_SHARE_DENOMINATOR, MAX_CONCURRENT_PROBES, PORT_BASE_SPREAD, processPortBase, targetKey, PROBE_WAIT_SLICE_MS, slicedProbeWait, spawnRealWorker;
|
|
14524
|
+
var init_probe = __esm({
|
|
14525
|
+
"src/frontdoor/probe.ts"() {
|
|
14347
14526
|
"use strict";
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14356
|
-
|
|
14527
|
+
init_processRole();
|
|
14528
|
+
import_node_worker_threads = require("node:worker_threads");
|
|
14529
|
+
init_connectEffects();
|
|
14530
|
+
init_doorDial();
|
|
14531
|
+
PROBE_TIMEOUT_MS = 2e3;
|
|
14532
|
+
PROBE_WAIT_MARGIN_MS = 1e3;
|
|
14533
|
+
REASON_BYTES = 1024;
|
|
14534
|
+
HEADER_SLOTS = 4;
|
|
14535
|
+
STARTED_SLOT = 2;
|
|
14536
|
+
CLAIM_SLOT = 3;
|
|
14537
|
+
PROBE_WORKER_START_LIMIT_MS = 1e4;
|
|
14538
|
+
STARTED_SIGNAL_SOURCE = "Atomics.store(new Int32Array(workerData.shared, 0, workerData.headerSlots), workerData.startedSlot, 1); Atomics.notify(new Int32Array(workerData.shared, 0, workerData.headerSlots), workerData.startedSlot);";
|
|
14539
|
+
PROBE_WORKER_FAILURE_PREFIX = "the probe worker failed: ";
|
|
14540
|
+
INT32_BYTES = 4;
|
|
14541
|
+
VERDICT_PENDING = 0;
|
|
14542
|
+
WORKER_NOT_STARTED = 0;
|
|
14543
|
+
VERDICT_OK = 1;
|
|
14544
|
+
VERDICT_FAILED = 2;
|
|
14545
|
+
WORKER_PRELUDE_SOURCE = `
|
|
14546
|
+
(() => {
|
|
14547
|
+
const { workerData } = require("node:worker_threads");
|
|
14548
|
+
const header = new Int32Array(workerData.shared, 0, workerData.headerSlots);
|
|
14549
|
+
const reason = new Uint8Array(workerData.shared, workerData.headerSlots * 4);
|
|
14550
|
+
globalThis.finishProbe = (verdict, message) => {
|
|
14551
|
+
try {
|
|
14552
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
14553
|
+
if (Atomics.compareExchange(header, workerData.claimSlot, 0, 1) === 0) {
|
|
14554
|
+
reason.set(bytes);
|
|
14555
|
+
Atomics.store(header, 1, bytes.length);
|
|
14556
|
+
Atomics.store(header, 0, verdict);
|
|
14557
|
+
}
|
|
14558
|
+
} finally {
|
|
14559
|
+
Atomics.notify(header, 0);
|
|
14560
|
+
}
|
|
14561
|
+
};
|
|
14562
|
+
const fail = (error) => {
|
|
14563
|
+
let message;
|
|
14564
|
+
try {
|
|
14565
|
+
message = workerData.failurePrefix + (error instanceof Error ? error.message : String(error));
|
|
14566
|
+
} catch {
|
|
14567
|
+
message = workerData.failurePrefix + "an error that cannot be described";
|
|
14568
|
+
}
|
|
14569
|
+
try {
|
|
14570
|
+
globalThis.finishProbe(workerData.failed, message);
|
|
14571
|
+
} finally {
|
|
14572
|
+
Atomics.store(header, workerData.startedSlot, 1);
|
|
14573
|
+
Atomics.notify(header, workerData.startedSlot);
|
|
14574
|
+
}
|
|
14575
|
+
};
|
|
14576
|
+
process.on("uncaughtException", fail);
|
|
14577
|
+
process.on("unhandledRejection", fail);
|
|
14578
|
+
// A worker that ends itself (process.exit in a probe source or a library it calls) runs this in its own thread before it goes: the waiting thread cannot hear the exit event of a worker, since its event loop is blocked on the verdict, so the worker says so itself. A verdict already published is not replaced (the writer takes the claim once).
|
|
14579
|
+
process.on("exit", (code) => {
|
|
14580
|
+
globalThis.finishProbe(workerData.failed, workerData.failurePrefix + "the worker exited without a verdict (exit code " + String(code) + ")");
|
|
14581
|
+
});
|
|
14582
|
+
})();
|
|
14583
|
+
`;
|
|
14584
|
+
PROBE_SOURCE = probeWorkerSource(`
|
|
14585
|
+
const https = require("node:https");
|
|
14586
|
+
const { port, ca, timeoutMs, ok, failed } = workerData;
|
|
14587
|
+
const finish = finishProbe;
|
|
14588
|
+
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
14589
|
+
let body = "";
|
|
14590
|
+
response.setEncoding("utf8");
|
|
14591
|
+
response.on("data", (chunk) => { body += chunk; });
|
|
14592
|
+
response.on("end", () => {
|
|
14593
|
+
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
14594
|
+
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
14595
|
+
});
|
|
14596
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
14597
|
+
});
|
|
14598
|
+
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
14599
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
14600
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
14601
|
+
`);
|
|
14602
|
+
CATALOGUE_REQUEST_SOURCE = probeWorkerSource(`
|
|
14603
|
+
const https = require("node:https");
|
|
14604
|
+
const { port, ca, token, timeoutMs, ok, failed } = workerData;
|
|
14605
|
+
const finish = finishProbe;
|
|
14606
|
+
const request = https.request({ host: "127.0.0.1", port, path: "/__agent-shim/orpc/rest/frontdoor/catalogues/refresh", method: "POST", headers: { authorization: "Bearer " + token }, ca: [ca], agent: false }, (response) => {
|
|
14607
|
+
response.resume();
|
|
14608
|
+
response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
|
|
14609
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
14610
|
+
});
|
|
14611
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
14612
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
14613
|
+
request.end();
|
|
14614
|
+
`);
|
|
14615
|
+
realProbeWorkers = { start: (source, data, timeoutMs) => startProbeWorker(source, data, timeoutMs) };
|
|
14616
|
+
ACCEPT_PROBE_SOURCE = probeWorkerSource(`
|
|
14617
|
+
const net = require("node:net");
|
|
14618
|
+
const dns = require("node:dns");
|
|
14619
|
+
const { host, port, portStart, portEnd, portFirst, platform, timeoutMs, ok, failed } = workerData;
|
|
14620
|
+
const finish = finishProbe;
|
|
14621
|
+
const SourcePortRange = ${SourcePortRange.toString()};
|
|
14622
|
+
const createDoorLookup = ${createDoorLookup.toString()};
|
|
14623
|
+
const sourcePortClassifier = ${sourcePortClassifier.toString()};
|
|
14624
|
+
const doorDial = ${doorDial.toString()};
|
|
14625
|
+
const probeAccept = ${probeAccept.toString()};
|
|
14626
|
+
const runAcceptProbe = ${runAcceptProbe.toString()};
|
|
14627
|
+
const startTimer = (callback, ms) => { const timer = setTimeout(callback, ms); return () => { clearTimeout(timer); }; };
|
|
14628
|
+
runAcceptProbe({ net, dns, createDoorLookup, doorDial, probeAccept, SourcePortRange, sourcePortClassifier }, { host, port, portStart, portEnd, portFirst, platform, timeoutMs }, startTimer).then((verdict) => {
|
|
14629
|
+
finish(verdict.ok ? ok : failed, verdict.ok ? "" : verdict.reason);
|
|
14630
|
+
});
|
|
14631
|
+
`);
|
|
14632
|
+
PROBE_PORT_SHARE_DENOMINATOR = 100;
|
|
14633
|
+
MAX_CONCURRENT_PROBES = Math.max(1, Math.floor(DOOR_SOURCE_PORT_COUNT / PROBE_PORT_SHARE_DENOMINATOR));
|
|
14634
|
+
PORT_BASE_SPREAD = 389;
|
|
14635
|
+
processPortBase = () => process.pid * PORT_BASE_SPREAD % DOOR_SOURCE_PORT_COUNT;
|
|
14636
|
+
targetKey = (target) => `${target.host}\0${String(target.port)}\0${String(target.timeoutMs)}`;
|
|
14637
|
+
PROBE_WAIT_SLICE_MS = 1e3;
|
|
14638
|
+
slicedProbeWait = (header, index, value, timeoutMs) => {
|
|
14639
|
+
const end = performance.now() + timeoutMs;
|
|
14640
|
+
for (; ; ) {
|
|
14641
|
+
noteBlockingStep();
|
|
14642
|
+
const left = end - performance.now();
|
|
14643
|
+
if (left <= 0) {
|
|
14644
|
+
return "timed-out";
|
|
14645
|
+
}
|
|
14646
|
+
const answer = Atomics.wait(header, index, value, Math.min(left, PROBE_WAIT_SLICE_MS));
|
|
14647
|
+
if (answer !== "timed-out") {
|
|
14648
|
+
return answer;
|
|
14649
|
+
}
|
|
14650
|
+
}
|
|
14651
|
+
};
|
|
14652
|
+
spawnRealWorker = (source, options) => new import_node_worker_threads.Worker(source, options);
|
|
14357
14653
|
}
|
|
14358
14654
|
});
|
|
14359
14655
|
|
|
14360
|
-
// src/
|
|
14361
|
-
function
|
|
14362
|
-
|
|
14363
|
-
if (!parsed.success) {
|
|
14364
|
-
throw new ConfigValidationError(file, parsed.error.issues);
|
|
14365
|
-
}
|
|
14366
|
-
return parsed.data;
|
|
14656
|
+
// src/providerReachability.ts
|
|
14657
|
+
function providerConnectTimeoutMs(provider) {
|
|
14658
|
+
return provider.connectTimeoutMs ?? DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS;
|
|
14367
14659
|
}
|
|
14368
|
-
function
|
|
14369
|
-
return
|
|
14660
|
+
function couldNotConnectMessage(subject, baseUrl, reason) {
|
|
14661
|
+
return `${subject} could not connect to ${displayBaseUrl(baseUrl)}: ${reason.trim() === "" ? "the connection failed with no reason given" : reason}`;
|
|
14370
14662
|
}
|
|
14371
|
-
function
|
|
14372
|
-
const
|
|
14373
|
-
return
|
|
14663
|
+
function probeProviderReachability(name, provider, probe) {
|
|
14664
|
+
const verdict = probe(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
14665
|
+
return verdict.ok ? { ok: true } : { ok: false, message: couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason) };
|
|
14374
14666
|
}
|
|
14375
|
-
function
|
|
14376
|
-
if (
|
|
14377
|
-
return
|
|
14667
|
+
function startProviderReachability(name, provider, start) {
|
|
14668
|
+
if (start === void 0 || !isHttpProvider(provider)) {
|
|
14669
|
+
return void 0;
|
|
14378
14670
|
}
|
|
14379
|
-
|
|
14671
|
+
const started = start(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
14672
|
+
return {
|
|
14673
|
+
cancel: started.cancel,
|
|
14674
|
+
line: () => {
|
|
14675
|
+
const verdict = started.verdict();
|
|
14676
|
+
return verdict.ok ? void 0 : couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason);
|
|
14677
|
+
}
|
|
14678
|
+
};
|
|
14380
14679
|
}
|
|
14381
|
-
function
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
|
|
14680
|
+
function probeProviderReachabilities(providers, probe) {
|
|
14681
|
+
const http3 = providers.flatMap((entry) => isHttpProvider(entry.provider) ? [{ name: entry.name, provider: entry.provider }] : []);
|
|
14682
|
+
const verdicts = probe(http3.map((entry) => ({ baseUrl: entry.provider.baseUrl, timeoutMs: providerConnectTimeoutMs(entry.provider) })));
|
|
14683
|
+
const lines = /* @__PURE__ */ new Map();
|
|
14684
|
+
http3.forEach((entry, index) => {
|
|
14685
|
+
const verdict = verdicts[index];
|
|
14686
|
+
if (verdict === void 0) {
|
|
14687
|
+
throw new Error("the batch probe answered fewer verdicts than it was given base URLs");
|
|
14385
14688
|
}
|
|
14386
|
-
if (
|
|
14387
|
-
|
|
14689
|
+
if (!verdict.ok) {
|
|
14690
|
+
lines.set(entry.name, couldNotConnectMessage(`provider ${entry.name}`, entry.provider.baseUrl, verdict.reason));
|
|
14388
14691
|
}
|
|
14389
|
-
return { level: "pass", alias, message: `${alias} is a former name of ${target}, still honoured for sessions launched under it. Run \`agent-shim provider unalias ${alias}\` once none is running.` };
|
|
14390
14692
|
});
|
|
14693
|
+
return lines;
|
|
14391
14694
|
}
|
|
14392
|
-
var
|
|
14393
|
-
var
|
|
14394
|
-
"src/
|
|
14695
|
+
var TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS, CONNECT_SYN_RETRANSMISSIONS_TOLERATED, DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS, startBaseUrlBatchProbe, realBaseUrlBatchProbe, realStartBaseUrlProbe, realBaseUrlProbe;
|
|
14696
|
+
var init_providerReachability = __esm({
|
|
14697
|
+
"src/providerReachability.ts"() {
|
|
14395
14698
|
"use strict";
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14699
|
+
init_schema();
|
|
14700
|
+
init_baseUrlDial();
|
|
14701
|
+
init_baseUrlDisplay();
|
|
14702
|
+
init_probe();
|
|
14703
|
+
TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS = 1e3;
|
|
14704
|
+
CONNECT_SYN_RETRANSMISSIONS_TOLERATED = 2;
|
|
14705
|
+
DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS = TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS * (2 ** (CONNECT_SYN_RETRANSMISSIONS_TOLERATED + 1) - 1);
|
|
14706
|
+
startBaseUrlBatchProbe = (targets, workers) => {
|
|
14707
|
+
const started = startAddressProbes(targets.map((target) => ({ ...dialTargetOf(target.baseUrl), timeoutMs: target.timeoutMs })), workers);
|
|
14708
|
+
return { cancel: started.cancel, verdicts: started.settle };
|
|
14709
|
+
};
|
|
14710
|
+
realBaseUrlBatchProbe = (targets, workers) => startBaseUrlBatchProbe(targets, workers).verdicts();
|
|
14711
|
+
realStartBaseUrlProbe = (baseUrl, timeoutMs) => {
|
|
14712
|
+
const started = startBaseUrlBatchProbe([{ baseUrl, timeoutMs }]);
|
|
14713
|
+
return {
|
|
14714
|
+
cancel: started.cancel,
|
|
14715
|
+
verdict: () => {
|
|
14716
|
+
const [verdict] = started.verdicts();
|
|
14717
|
+
if (verdict === void 0) {
|
|
14718
|
+
throw new Error("the batch probe answered no verdict for one base URL");
|
|
14719
|
+
}
|
|
14720
|
+
return verdict;
|
|
14721
|
+
}
|
|
14722
|
+
};
|
|
14723
|
+
};
|
|
14724
|
+
realBaseUrlProbe = (baseUrl, timeoutMs) => realStartBaseUrlProbe(baseUrl, timeoutMs).verdict();
|
|
14401
14725
|
}
|
|
14402
14726
|
});
|
|
14403
14727
|
|
|
14404
|
-
// src/models/
|
|
14405
|
-
function
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
return name.trim().toLowerCase().replace(NON_IDENTITY_BRACKET_RE, "").replace(/[\s_]+/g, "-").replace(/([a-z])(\d+(?:\.\d+)+)/g, "$1-$2").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
14728
|
+
// src/models/tiers.ts
|
|
14729
|
+
function claudeNameTier(model) {
|
|
14730
|
+
const name = model.toLowerCase().replace(/\[1m\]$/, "");
|
|
14731
|
+
const parts = name.split("-");
|
|
14732
|
+
return parts[0] === "claude" ? CLAUDE_TIERS.find((tier) => parts.includes(tier)) : CLAUDE_TIERS.find((tier) => name === tier);
|
|
14410
14733
|
}
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14734
|
+
var TIER_ENV_VARIABLES;
|
|
14735
|
+
var init_tiers = __esm({
|
|
14736
|
+
"src/models/tiers.ts"() {
|
|
14737
|
+
"use strict";
|
|
14738
|
+
init_schema();
|
|
14739
|
+
TIER_ENV_VARIABLES = Object.freeze({
|
|
14740
|
+
fable: "ANTHROPIC_DEFAULT_FABLE_MODEL",
|
|
14741
|
+
opus: "ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
14742
|
+
sonnet: "ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
14743
|
+
haiku: "ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
|
14744
|
+
});
|
|
14421
14745
|
}
|
|
14422
|
-
}
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
14428
|
-
|
|
14429
|
-
}
|
|
14430
|
-
if (/^\d+$/.test(token) && next !== void 0 && /^\d+$/.test(next)) {
|
|
14431
|
-
return `${token}.${next}`;
|
|
14432
|
-
}
|
|
14433
|
-
const dotted = /^\d+(?:\.\d+)+$/.exec(token);
|
|
14434
|
-
if (dotted !== null) {
|
|
14435
|
-
return dotted[0];
|
|
14436
|
-
}
|
|
14746
|
+
});
|
|
14747
|
+
|
|
14748
|
+
// src/models/reservedModelNames.ts
|
|
14749
|
+
function reservedProviderNameReason(name) {
|
|
14750
|
+
const bare = withoutContextMarker(name);
|
|
14751
|
+
if (bare === AUTO_MODEL) {
|
|
14752
|
+
return `"${AUTO_MODEL}" is the model name that follows the server's live model`;
|
|
14437
14753
|
}
|
|
14438
|
-
|
|
14754
|
+
if (CLAUDE_CODE_ALIASES.has(bare.toLowerCase())) {
|
|
14755
|
+
return `"${name}" is a model alias Claude Code resolves itself`;
|
|
14756
|
+
}
|
|
14757
|
+
const tier = claudeNameTier(name);
|
|
14758
|
+
return tier === void 0 ? void 0 : `"${name}" is a Claude model name (the ${tier} tier)`;
|
|
14439
14759
|
}
|
|
14440
|
-
function
|
|
14441
|
-
const
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
const { familyTokens, variants } = splitVariants(tokens);
|
|
14446
|
-
const version = versionOf(familyTokens);
|
|
14447
|
-
const versionless = familyTokens.filter((token, index) => {
|
|
14448
|
-
if (version === "") {
|
|
14449
|
-
return true;
|
|
14450
|
-
}
|
|
14451
|
-
const dotted = /^\d+(?:\.\d+)+$/.test(token);
|
|
14452
|
-
const previous = familyTokens[index - 1];
|
|
14453
|
-
const next = familyTokens[index + 1];
|
|
14454
|
-
const insideVersionRun = dotted || /^\d+$/.test(token) && (previous !== void 0 && /^\d+$/.test(previous) || next !== void 0 && /^\d+$/.test(next));
|
|
14455
|
-
return !insideVersionRun;
|
|
14456
|
-
});
|
|
14457
|
-
const family = versionless.join("-");
|
|
14458
|
-
const tokenVendor = familyTokens.find((token) => Object.keys(VENDOR_BY_TOKEN).some((key) => token === key || token.startsWith(key)));
|
|
14459
|
-
const namespace = segments.length >= 2 ? (segments[0] ?? "").split(":").pop() ?? "" : "";
|
|
14460
|
-
const namespaceVendor = VENDOR_BY_NAMESPACE[namespace] ?? "";
|
|
14461
|
-
const tokenVendorName = tokenVendor === void 0 ? "" : VENDOR_BY_TOKEN[Object.keys(VENDOR_BY_TOKEN).find((key) => tokenVendor === key || tokenVendor.startsWith(key)) ?? ""] ?? "";
|
|
14462
|
-
return {
|
|
14463
|
-
vendor: tokenVendorName === "" ? namespaceVendor : tokenVendorName,
|
|
14464
|
-
vendorConflict: tokenVendorName !== "" && namespaceVendor !== "" && tokenVendorName !== namespaceVendor,
|
|
14465
|
-
family,
|
|
14466
|
-
version,
|
|
14467
|
-
variant: variants.join("-"),
|
|
14468
|
-
familyAndVersion: version === "" ? family : `${family}-${version.replace(/\./g, "-")}`
|
|
14469
|
-
};
|
|
14760
|
+
function requireUnreservedProviderName(name) {
|
|
14761
|
+
const reason = reservedProviderNameReason(name);
|
|
14762
|
+
if (reason !== void 0) {
|
|
14763
|
+
throw new InvalidProviderNameError(name, `must not be a bare model name, because ${reason}`);
|
|
14764
|
+
}
|
|
14470
14765
|
}
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14766
|
+
var AUTO_MODEL, CLAUDE_CODE_ALIASES;
|
|
14767
|
+
var init_reservedModelNames = __esm({
|
|
14768
|
+
"src/models/reservedModelNames.ts"() {
|
|
14769
|
+
"use strict";
|
|
14770
|
+
init_names();
|
|
14771
|
+
init_identity();
|
|
14772
|
+
init_tiers();
|
|
14773
|
+
AUTO_MODEL = "auto";
|
|
14774
|
+
CLAUDE_CODE_ALIASES = /* @__PURE__ */ new Set(["default", "best", "opusplan"]);
|
|
14476
14775
|
}
|
|
14477
|
-
|
|
14478
|
-
|
|
14776
|
+
});
|
|
14777
|
+
|
|
14778
|
+
// src/providerAliases.ts
|
|
14779
|
+
function parseAliases(file, raw) {
|
|
14780
|
+
const parsed = ProviderAliasesSchema.safeParse(raw);
|
|
14781
|
+
if (!parsed.success) {
|
|
14782
|
+
throw new ConfigValidationError(file, parsed.error.issues);
|
|
14479
14783
|
}
|
|
14480
|
-
return
|
|
14784
|
+
return parsed.data;
|
|
14481
14785
|
}
|
|
14482
|
-
function
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14786
|
+
function readProviderAliases(paths) {
|
|
14787
|
+
return readJson(paths.providerAliasesFile, ProviderAliasesSchema) ?? {};
|
|
14788
|
+
}
|
|
14789
|
+
function loadProviderAliases(file, port) {
|
|
14790
|
+
const raw = port.readConfigFile(file);
|
|
14791
|
+
return raw === void 0 ? {} : parseAliases(file, raw);
|
|
14792
|
+
}
|
|
14793
|
+
function canonicalProviderName(name, defined, aliases) {
|
|
14794
|
+
if (defined(name)) {
|
|
14795
|
+
return name;
|
|
14488
14796
|
}
|
|
14489
|
-
return
|
|
14797
|
+
return aliases()[name] ?? name;
|
|
14490
14798
|
}
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14799
|
+
function aliasFindings(aliases, providerNames) {
|
|
14800
|
+
return Object.entries(aliases).map(([alias, target]) => {
|
|
14801
|
+
if (!providerNames.has(target)) {
|
|
14802
|
+
return { level: "fail", alias, message: `${alias} is recorded as a former name of ${target}, which is not a provider. Run \`agent-shim provider unalias ${alias}\`.` };
|
|
14803
|
+
}
|
|
14804
|
+
if (providerNames.has(alias)) {
|
|
14805
|
+
return { level: "warn", alias, message: `${alias} is both a provider and a recorded former name of ${target}; the provider wins. Run \`agent-shim provider unalias ${alias}\`.` };
|
|
14806
|
+
}
|
|
14807
|
+
return { level: "pass", alias, message: `${alias} is a former name of ${target}, still honoured for sessions launched under it. Run \`agent-shim provider unalias ${alias}\` once none is running.` };
|
|
14808
|
+
});
|
|
14809
|
+
}
|
|
14810
|
+
var import_zod30, ProviderAliasesSchema;
|
|
14811
|
+
var init_providerAliases = __esm({
|
|
14812
|
+
"src/providerAliases.ts"() {
|
|
14494
14813
|
"use strict";
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
anthropic: "anthropic",
|
|
14501
|
-
google: "google",
|
|
14502
|
-
openai: "openai",
|
|
14503
|
-
zai: "zai",
|
|
14504
|
-
"z-ai": "zai",
|
|
14505
|
-
minimax: "minimax",
|
|
14506
|
-
qwen: "qwen",
|
|
14507
|
-
deepseek: "deepseek",
|
|
14508
|
-
moonshot: "moonshot",
|
|
14509
|
-
meta: "meta",
|
|
14510
|
-
mistral: "mistral"
|
|
14511
|
-
});
|
|
14512
|
-
VENDOR_BY_TOKEN = Object.freeze({
|
|
14513
|
-
claude: "anthropic",
|
|
14514
|
-
gemini: "google",
|
|
14515
|
-
antigravity: "google",
|
|
14516
|
-
gpt: "openai",
|
|
14517
|
-
glm: "zai",
|
|
14518
|
-
minimax: "minimax",
|
|
14519
|
-
qwen: "qwen",
|
|
14520
|
-
deepseek: "deepseek",
|
|
14521
|
-
kimi: "moonshot",
|
|
14522
|
-
llama: "meta",
|
|
14523
|
-
mistral: "mistral",
|
|
14524
|
-
mixtral: "mistral"
|
|
14525
|
-
});
|
|
14814
|
+
import_zod30 = require("zod");
|
|
14815
|
+
init_cliError();
|
|
14816
|
+
init_load();
|
|
14817
|
+
init_store();
|
|
14818
|
+
ProviderAliasesSchema = import_zod30.z.record(import_zod30.z.string().min(1), import_zod30.z.string().min(1));
|
|
14526
14819
|
}
|
|
14527
14820
|
});
|
|
14528
14821
|
|
|
@@ -14602,7 +14895,7 @@ var FAMILY_PREFIX, VARIANT_SEPARATOR;
|
|
|
14602
14895
|
var init_families = __esm({
|
|
14603
14896
|
"src/models/families.ts"() {
|
|
14604
14897
|
"use strict";
|
|
14605
|
-
|
|
14898
|
+
init_identity();
|
|
14606
14899
|
FAMILY_PREFIX = "family:";
|
|
14607
14900
|
VARIANT_SEPARATOR = "+";
|
|
14608
14901
|
}
|
|
@@ -14741,6 +15034,7 @@ function addProvider(paths, name, input) {
|
|
|
14741
15034
|
throw new ProviderAlreadyExistsError(name);
|
|
14742
15035
|
}
|
|
14743
15036
|
requireNewProviderName(name);
|
|
15037
|
+
requireUnreservedProviderName(name);
|
|
14744
15038
|
const kind = input.kind ?? "http";
|
|
14745
15039
|
if (kind === "codex" && input.baseUrl !== void 0) {
|
|
14746
15040
|
throw new ProviderKindMismatchError("A codex provider has no base URL: the launcher points its sessions at the front-door daemon. Drop --base-url.");
|
|
@@ -14763,6 +15057,9 @@ function addProvider(paths, name, input) {
|
|
|
14763
15057
|
if (kind !== "http" && input.connectTimeoutMs !== void 0) {
|
|
14764
15058
|
throw new ProviderKindMismatchError("A connect timeout applies only to an http provider, the one kind that dials a base URL.");
|
|
14765
15059
|
}
|
|
15060
|
+
if (kind !== "http" && input.serverTools !== void 0) {
|
|
15061
|
+
throw new ProviderKindMismatchError("The server-tools setting applies only to an http provider.");
|
|
15062
|
+
}
|
|
14766
15063
|
if (kind !== "codex" && !isEmptyCodexConfig(input.codex)) {
|
|
14767
15064
|
throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
|
|
14768
15065
|
}
|
|
@@ -14776,7 +15073,7 @@ function addProvider(paths, name, input) {
|
|
|
14776
15073
|
...input.pickerModels === void 0 || input.pickerModels.length === 0 ? {} : { pickerModels: input.pickerModels }
|
|
14777
15074
|
};
|
|
14778
15075
|
const parsed = ProviderSchema.safeParse(
|
|
14779
|
-
kind === "router" ? { kind, displayName: input.displayName } : kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input.codex) ? {} : { codex: input.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input.antigravity) ? {} : { antigravity: input.antigravity } } : { ...shared, baseUrl: input.baseUrl, ...input.connectTimeoutMs === void 0 ? {} : { connectTimeoutMs: input.connectTimeoutMs }, ...input.catalogue === void 0 ? {} : { catalogue: input.catalogue } }
|
|
15076
|
+
kind === "router" ? { kind, displayName: input.displayName } : kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input.codex) ? {} : { codex: input.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input.antigravity) ? {} : { antigravity: input.antigravity } } : { ...shared, baseUrl: input.baseUrl, ...input.connectTimeoutMs === void 0 ? {} : { connectTimeoutMs: input.connectTimeoutMs }, ...input.catalogue === void 0 ? {} : { catalogue: input.catalogue }, ...input.serverTools === void 0 ? {} : { serverTools: input.serverTools } }
|
|
14780
15077
|
);
|
|
14781
15078
|
if (!parsed.success) {
|
|
14782
15079
|
throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
|
|
@@ -14814,6 +15111,9 @@ function updateProvider(paths, name, input) {
|
|
|
14814
15111
|
if ((isCodexProvider(existing) || isAntigravityProvider(existing)) && input.catalogue !== void 0 && input.catalogue !== false) {
|
|
14815
15112
|
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a model catalogue applies only to an http provider.`);
|
|
14816
15113
|
}
|
|
15114
|
+
if ((isCodexProvider(existing) || isAntigravityProvider(existing) || router) && input.serverTools !== void 0) {
|
|
15115
|
+
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; the server-tools setting applies only to an http provider.`);
|
|
15116
|
+
}
|
|
14817
15117
|
if (!isCodexProvider(existing) && !isEmptyCodexConfig(input.codex)) {
|
|
14818
15118
|
throw new ProviderKindMismatchError(`Provider "${name}" is not a codex provider; codex settings apply only to a codex provider.`);
|
|
14819
15119
|
}
|
|
@@ -14852,7 +15152,7 @@ function updateProvider(paths, name, input) {
|
|
|
14852
15152
|
} else {
|
|
14853
15153
|
const catalogue = input.catalogue === void 0 ? existing.catalogue : input.catalogue === false ? void 0 : input.catalogue;
|
|
14854
15154
|
const connectTimeoutMs = input.connectTimeoutMs === void 0 ? existing.connectTimeoutMs : input.connectTimeoutMs === false ? void 0 : input.connectTimeoutMs;
|
|
14855
|
-
candidate = { ...existing, ...shared, catalogue, connectTimeoutMs, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
|
|
15155
|
+
candidate = { ...existing, ...shared, catalogue, connectTimeoutMs, ...input.serverTools === void 0 ? {} : { serverTools: input.serverTools }, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
|
|
14856
15156
|
}
|
|
14857
15157
|
const parsed = ProviderSchema.safeParse(candidate);
|
|
14858
15158
|
if (!parsed.success) {
|
|
@@ -14995,6 +15295,7 @@ var init_providersStore = __esm({
|
|
|
14995
15295
|
init_walk();
|
|
14996
15296
|
init_families();
|
|
14997
15297
|
init_names();
|
|
15298
|
+
init_reservedModelNames();
|
|
14998
15299
|
ProviderNotFoundError = class extends CliError {
|
|
14999
15300
|
constructor(name) {
|
|
15000
15301
|
super(`No provider named "${name}". Run \`agent-shim provider add ${name}\` first.`);
|
|
@@ -15036,513 +15337,477 @@ var init_providersStore = __esm({
|
|
|
15036
15337
|
}
|
|
15037
15338
|
});
|
|
15038
15339
|
|
|
15039
|
-
// src/
|
|
15040
|
-
function
|
|
15041
|
-
|
|
15042
|
-
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
|
|
15047
|
-
|
|
15048
|
-
|
|
15049
|
-
|
|
15050
|
-
return void 0;
|
|
15051
|
-
}
|
|
15052
|
-
function memberProviderResolver(params) {
|
|
15053
|
-
if (params.cliProvider === false) {
|
|
15054
|
-
return () => void 0;
|
|
15340
|
+
// src/cli/bool.ts
|
|
15341
|
+
function parseBoolWord(input) {
|
|
15342
|
+
switch (input) {
|
|
15343
|
+
case "true":
|
|
15344
|
+
case "1":
|
|
15345
|
+
return true;
|
|
15346
|
+
case "false":
|
|
15347
|
+
case "0":
|
|
15348
|
+
return false;
|
|
15349
|
+
default:
|
|
15350
|
+
return void 0;
|
|
15055
15351
|
}
|
|
15056
|
-
const cliProvider = params.cliProvider;
|
|
15057
|
-
const identities = identityReader(params.paths.identitiesDir, params.fs);
|
|
15058
|
-
const cascades = /* @__PURE__ */ new Map();
|
|
15059
|
-
const cascadeOver = (baseConfigProfile) => {
|
|
15060
|
-
const cached = cascades.get(baseConfigProfile);
|
|
15061
|
-
if (cached !== void 0) {
|
|
15062
|
-
return cached;
|
|
15063
|
-
}
|
|
15064
|
-
const loaded = params.loadCascade(baseConfigProfile);
|
|
15065
|
-
cascades.set(baseConfigProfile, loaded);
|
|
15066
|
-
return loaded;
|
|
15067
|
-
};
|
|
15068
|
-
return (name) => {
|
|
15069
|
-
let declared;
|
|
15070
|
-
try {
|
|
15071
|
-
declared = identities.load(name);
|
|
15072
|
-
} catch (error) {
|
|
15073
|
-
if (!(error instanceof ConfigValidationError)) {
|
|
15074
|
-
throw error;
|
|
15075
|
-
}
|
|
15076
|
-
}
|
|
15077
|
-
const profile = decideConfigProfile({
|
|
15078
|
-
env: params.env,
|
|
15079
|
-
...params.cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile: params.cliFlagConfigProfile },
|
|
15080
|
-
...params.directoryRuleConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: params.directoryRuleConfigProfile },
|
|
15081
|
-
...declared?.defaultConfigProfile === void 0 ? {} : { identityDefaultConfigProfile: declared.defaultConfigProfile },
|
|
15082
|
-
...params.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: params.globalDefaultConfigProfile }
|
|
15083
|
-
});
|
|
15084
|
-
const flagged = cliProvider !== void 0 && cliProvider !== "" ? cliProvider : void 0;
|
|
15085
|
-
let named = flagged ?? declared?.provider;
|
|
15086
|
-
try {
|
|
15087
|
-
const cascade = cascadeOver(profile.name);
|
|
15088
|
-
named = flagged ?? cascadeProviderName(cascade, declared?.provider);
|
|
15089
|
-
return selectedProviderName({
|
|
15090
|
-
paths: params.paths,
|
|
15091
|
-
port: params.fs,
|
|
15092
|
-
...cliProvider === void 0 ? {} : { cliProvider },
|
|
15093
|
-
cascade,
|
|
15094
|
-
...declared?.provider === void 0 ? {} : { identityProvider: declared.provider }
|
|
15095
|
-
});
|
|
15096
|
-
} catch (error) {
|
|
15097
|
-
const reason = unreadableFileReason(error);
|
|
15098
|
-
if (reason === void 0) {
|
|
15099
|
-
throw error;
|
|
15100
|
-
}
|
|
15101
|
-
return { ...named === void 0 ? {} : { named }, reason };
|
|
15102
|
-
}
|
|
15103
|
-
};
|
|
15104
15352
|
}
|
|
15105
|
-
var
|
|
15106
|
-
"src/
|
|
15353
|
+
var init_bool = __esm({
|
|
15354
|
+
"src/cli/bool.ts"() {
|
|
15107
15355
|
"use strict";
|
|
15108
|
-
init_load();
|
|
15109
|
-
init_providersStore();
|
|
15110
|
-
init_identity();
|
|
15111
15356
|
}
|
|
15112
15357
|
});
|
|
15113
15358
|
|
|
15114
|
-
// src/
|
|
15115
|
-
function
|
|
15116
|
-
|
|
15117
|
-
|
|
15118
|
-
return fromEnv;
|
|
15359
|
+
// src/cli/envBool.ts
|
|
15360
|
+
function parseEnvBool(variable, value) {
|
|
15361
|
+
if (value === void 0 || value === "") {
|
|
15362
|
+
return void 0;
|
|
15119
15363
|
}
|
|
15120
|
-
const
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
}
|
|
15124
|
-
function isExistingDirectory(candidate) {
|
|
15125
|
-
return import_node_fs12.default.statSync(candidate, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
15126
|
-
}
|
|
15127
|
-
function resolveClaudeHome() {
|
|
15128
|
-
const fromEnv = process.env.AGENT_SHIM_CLAUDE_HOME;
|
|
15129
|
-
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15130
|
-
return fromEnv;
|
|
15364
|
+
const parsed = parseBoolWord(value);
|
|
15365
|
+
if (parsed === void 0) {
|
|
15366
|
+
throw new InvalidEnvBoolError(variable, value);
|
|
15131
15367
|
}
|
|
15132
|
-
return
|
|
15133
|
-
}
|
|
15134
|
-
function buildLayoutPaths(root) {
|
|
15135
|
-
return {
|
|
15136
|
-
root,
|
|
15137
|
-
identitiesDir: import_node_path39.default.join(root, "identities"),
|
|
15138
|
-
configProfilesDir: import_node_path39.default.join(root, "config-profiles"),
|
|
15139
|
-
providersDir: import_node_path39.default.join(root, "providers"),
|
|
15140
|
-
providerAliasesFile: import_node_path39.default.join(root, "provider-aliases.json"),
|
|
15141
|
-
directoryRulesFile: import_node_path39.default.join(root, "directory-rules.json"),
|
|
15142
|
-
activeIdentityFile: import_node_path39.default.join(root, "active-identity"),
|
|
15143
|
-
globalConfigFile: import_node_path39.default.join(root, "config.json"),
|
|
15144
|
-
categoriesLocalFile: import_node_path39.default.join(root, "categories.local.json"),
|
|
15145
|
-
claudeShimFile: import_node_path39.default.join(root, "claude-shim.json"),
|
|
15146
|
-
headroomDir: import_node_path39.default.join(root, "headroom"),
|
|
15147
|
-
headroomStateFile: import_node_path39.default.join(root, "headroom", "state.json"),
|
|
15148
|
-
headroomRoutingFile: import_node_path39.default.join(root, "headroom", "routing.json"),
|
|
15149
|
-
headroomLegacyStateFile: import_node_path39.default.join(root, "headroom", "state.v2.json"),
|
|
15150
|
-
headroomAllowlistFile: import_node_path39.default.join(root, "headroom", "run", "allowlist.txt"),
|
|
15151
|
-
headroomSocketDir: import_node_path39.default.join(root, "headroom", "run"),
|
|
15152
|
-
headroomLockFile: import_node_path39.default.join(root, "headroom", "start.lock"),
|
|
15153
|
-
headroomSessionsDir: import_node_path39.default.join(root, "headroom", "sessions"),
|
|
15154
|
-
logsDir: import_node_path39.default.join(root, "logs"),
|
|
15155
|
-
headroomLogPath: import_node_path39.default.join(root, "logs", "headroom.log"),
|
|
15156
|
-
frontdoorDir: import_node_path39.default.join(root, "frontdoor"),
|
|
15157
|
-
frontdoorCaDir: import_node_path39.default.join(root, "frontdoor", "ca"),
|
|
15158
|
-
frontdoorCaCertFile: import_node_path39.default.join(root, "frontdoor", "ca", "ca.pem"),
|
|
15159
|
-
frontdoorCaKeyFile: import_node_path39.default.join(root, "frontdoor", "ca", "ca.key"),
|
|
15160
|
-
frontdoorCaBundlesDir: import_node_path39.default.join(root, "frontdoor", "ca", "bundles"),
|
|
15161
|
-
chatgptSignInFile: import_node_path39.default.join(root, "codex", "chatgpt-sign-in.json"),
|
|
15162
|
-
frontdoorStateFile: import_node_path39.default.join(root, "frontdoor", "state.json"),
|
|
15163
|
-
frontdoorLockFile: import_node_path39.default.join(root, "frontdoor", "start.lock"),
|
|
15164
|
-
frontdoorControlTokenFile: import_node_path39.default.join(root, "frontdoor", "control-token"),
|
|
15165
|
-
frontdoorSessionsDir: import_node_path39.default.join(root, "frontdoor", "sessions"),
|
|
15166
|
-
frontdoorDirectRecordsDir: import_node_path39.default.join(root, "frontdoor", "direct"),
|
|
15167
|
-
frontdoorDrainingDir: import_node_path39.default.join(root, "frontdoor", "draining"),
|
|
15168
|
-
frontdoorRcCredentialsDir: import_node_path39.default.join(root, "frontdoor", "rc-credentials"),
|
|
15169
|
-
frontdoorLogPath: import_node_path39.default.join(root, "logs", "frontdoor.log"),
|
|
15170
|
-
usageDir: import_node_path39.default.join(root, "usage"),
|
|
15171
|
-
usageLogDir: import_node_path39.default.join(root, "usage", "log"),
|
|
15172
|
-
usageSnapshotsDir: import_node_path39.default.join(root, "usage", "snapshots"),
|
|
15173
|
-
statuslineDir: import_node_path39.default.join(root, "statusline"),
|
|
15174
|
-
catalogueDir: import_node_path39.default.join(root, "catalogues"),
|
|
15175
|
-
usagePicksFile: import_node_path39.default.join(root, "usage", "picks.json"),
|
|
15176
|
-
usageAnchorsFile: import_node_path39.default.join(root, "usage", "anchors.json"),
|
|
15177
|
-
usageJobsFile: import_node_path39.default.join(root, "usage", "jobs.json"),
|
|
15178
|
-
jobLogsDir: import_node_path39.default.join(root, "logs", "jobs"),
|
|
15179
|
-
identityRenamesDir: import_node_path39.default.join(root, "identity-renames"),
|
|
15180
|
-
identityNameRenamesDir: import_node_path39.default.join(root, "identity-name-renames"),
|
|
15181
|
-
launchesDir: import_node_path39.default.join(root, "launches"),
|
|
15182
|
-
superviseDir: import_node_path39.default.join(root, "supervise"),
|
|
15183
|
-
modelMovesDir: import_node_path39.default.join(root, "model-moves"),
|
|
15184
|
-
mcpPermissionsFile: import_node_path39.default.join(root, "mcp", "permissions.json")
|
|
15185
|
-
};
|
|
15186
|
-
}
|
|
15187
|
-
function resolveLayoutPaths() {
|
|
15188
|
-
return buildLayoutPaths(resolveAgentShimHome());
|
|
15368
|
+
return parsed;
|
|
15189
15369
|
}
|
|
15190
|
-
var
|
|
15191
|
-
var
|
|
15192
|
-
"src/
|
|
15370
|
+
var InvalidEnvBoolError;
|
|
15371
|
+
var init_envBool = __esm({
|
|
15372
|
+
"src/cli/envBool.ts"() {
|
|
15193
15373
|
"use strict";
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15374
|
+
init_cliError();
|
|
15375
|
+
init_bool();
|
|
15376
|
+
InvalidEnvBoolError = class extends UsageError {
|
|
15377
|
+
constructor(variable, value) {
|
|
15378
|
+
super(`${variable} must be one of true, false, 1 or 0, got "${value}".`);
|
|
15379
|
+
this.variable = variable;
|
|
15380
|
+
this.value = value;
|
|
15381
|
+
this.name = "InvalidEnvBoolError";
|
|
15382
|
+
}
|
|
15383
|
+
variable;
|
|
15384
|
+
value;
|
|
15385
|
+
};
|
|
15198
15386
|
}
|
|
15199
15387
|
});
|
|
15200
15388
|
|
|
15201
|
-
// src/
|
|
15202
|
-
function
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
|
|
15208
|
-
|
|
15209
|
-
return
|
|
15210
|
-
}
|
|
15211
|
-
function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
15212
|
-
refuseToBlockInRole("a synchronous probe of the front door");
|
|
15213
|
-
return workers.start(PROBE_SOURCE, { port, ca: caPem }, timeoutMs).verdict();
|
|
15389
|
+
// src/pathNorm.ts
|
|
15390
|
+
function expandTilde(value, home) {
|
|
15391
|
+
if (value === "~") {
|
|
15392
|
+
return home;
|
|
15393
|
+
}
|
|
15394
|
+
if (value.startsWith("~/")) {
|
|
15395
|
+
return import_node_path37.default.join(home, value.slice(2));
|
|
15396
|
+
}
|
|
15397
|
+
return value;
|
|
15214
15398
|
}
|
|
15215
|
-
function
|
|
15216
|
-
|
|
15217
|
-
return workers.start(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, platform: process.platform }, timeoutMs).verdict();
|
|
15399
|
+
function normaliseRulePath(rulePath, home) {
|
|
15400
|
+
return import_node_path37.default.resolve(expandTilde(rulePath, home));
|
|
15218
15401
|
}
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
distinct.set(targetKey(target), target);
|
|
15402
|
+
var import_node_path37;
|
|
15403
|
+
var init_pathNorm = __esm({
|
|
15404
|
+
"src/pathNorm.ts"() {
|
|
15405
|
+
"use strict";
|
|
15406
|
+
import_node_path37 = __toESM(require("node:path"), 1);
|
|
15225
15407
|
}
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
const
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
|
|
15408
|
+
});
|
|
15409
|
+
|
|
15410
|
+
// src/launcher/cascade.ts
|
|
15411
|
+
function loadCascadeInput(params) {
|
|
15412
|
+
const globalConfig = loadConfigFile(params.paths.globalConfigFile, GlobalConfigSchema, params.read);
|
|
15413
|
+
const directoryRules = loadConfigFile(params.paths.directoryRulesFile, DirectoryRulesSchema, params.read);
|
|
15414
|
+
const loadProfile = (name) => {
|
|
15415
|
+
const filepath = profileFilePath(params.paths.configProfilesDir, name);
|
|
15416
|
+
const loaded = loadConfigFile(filepath, ConfigProfileSchema, params.read);
|
|
15417
|
+
if (loaded === void 0) {
|
|
15418
|
+
return void 0;
|
|
15234
15419
|
}
|
|
15420
|
+
return { name, profile: loaded.config, entryOrder: loaded.entryOrder, filepath: loaded.filepath };
|
|
15235
15421
|
};
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
}
|
|
15240
|
-
|
|
15241
|
-
try {
|
|
15242
|
-
const started = workers.start(ACCEPT_PROBE_SOURCE, { host: target.host, port: target.port, portStart: DOOR_SOURCE_PORT_START, portEnd: DOOR_SOURCE_PORT_END, portFirst, platform: process.platform }, target.timeoutMs);
|
|
15243
|
-
running.push({ key: targetKey(target), verdict: started.verdict, cancel: started.cancel });
|
|
15244
|
-
} catch (error) {
|
|
15245
|
-
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
15246
|
-
running.push({ key: targetKey(target), verdict: () => ({ ok: false, reason }), cancel: () => void 0 });
|
|
15247
|
-
}
|
|
15422
|
+
const limit = globalConfig?.config.walkUpLimit;
|
|
15423
|
+
const dirs = walkDirectoryAncestors(params.cwd, {
|
|
15424
|
+
home: params.home,
|
|
15425
|
+
...limit === void 0 ? {} : { limit: expandTilde(limit, params.home) },
|
|
15426
|
+
...params.isReadable === void 0 ? {} : { isReadable: params.isReadable }
|
|
15248
15427
|
});
|
|
15249
|
-
|
|
15250
|
-
|
|
15251
|
-
|
|
15252
|
-
|
|
15253
|
-
|
|
15254
|
-
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
|
|
15258
|
-
|
|
15259
|
-
|
|
15260
|
-
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
for (const started of running.splice(0)) {
|
|
15264
|
-
started.cancel();
|
|
15265
|
-
}
|
|
15428
|
+
const levels = [];
|
|
15429
|
+
for (const dir of dirs) {
|
|
15430
|
+
const portable = loadConfigFile(import_node_path38.default.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path38.default.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15431
|
+
const portableLocal = loadConfigFile(import_node_path38.default.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path38.default.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15432
|
+
const rules = (directoryRules?.config.rules ?? []).map((rule, index) => ({ rule, index })).filter(({ rule }) => normaliseRulePath(rule.path, params.home) === dir).map(({ rule, index }) => {
|
|
15433
|
+
const entryOrder = directoryRules?.ruleEntryOrders[index];
|
|
15434
|
+
return {
|
|
15435
|
+
rule,
|
|
15436
|
+
...entryOrder === void 0 ? {} : { entryOrder },
|
|
15437
|
+
filepath: params.paths.directoryRulesFile
|
|
15438
|
+
};
|
|
15439
|
+
});
|
|
15440
|
+
if (portable === void 0 && portableLocal === void 0 && rules.length === 0) {
|
|
15441
|
+
continue;
|
|
15266
15442
|
}
|
|
15267
|
-
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
15273
|
-
let worker;
|
|
15274
|
-
try {
|
|
15275
|
-
worker = spawn3(`${WORKER_PRELUDE_SOURCE}
|
|
15276
|
-
new Function("require", ${JSON.stringify(source)})(require);`, {
|
|
15277
|
-
eval: true,
|
|
15278
|
-
workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS, startedSlot: STARTED_SLOT, failurePrefix: PROBE_WORKER_FAILURE_PREFIX, claimSlot: CLAIM_SLOT }
|
|
15443
|
+
levels.push({
|
|
15444
|
+
dir,
|
|
15445
|
+
...portable === void 0 ? {} : { portable: { config: portable.config, entryOrder: portable.entryOrder, filepath: portable.filepath } },
|
|
15446
|
+
...rules.length === 0 ? {} : { rules },
|
|
15447
|
+
...portableLocal === void 0 ? {} : { portableLocal: { config: portableLocal.config, entryOrder: portableLocal.entryOrder, filepath: portableLocal.filepath } }
|
|
15279
15448
|
});
|
|
15280
|
-
} catch (error) {
|
|
15281
|
-
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
15282
|
-
return { verdict: () => ({ ok: false, reason }), cancel: () => void 0 };
|
|
15283
15449
|
}
|
|
15284
|
-
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
}
|
|
15288
|
-
|
|
15289
|
-
|
|
15290
|
-
|
|
15291
|
-
|
|
15292
|
-
|
|
15293
|
-
|
|
15294
|
-
|
|
15295
|
-
|
|
15296
|
-
|
|
15297
|
-
|
|
15298
|
-
|
|
15299
|
-
|
|
15300
|
-
|
|
15301
|
-
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
if (verdict === VERDICT_OK) {
|
|
15308
|
-
return { ok: true };
|
|
15309
|
-
}
|
|
15310
|
-
const length = Atomics.load(header, 1);
|
|
15311
|
-
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
15312
|
-
} finally {
|
|
15313
|
-
void worker.terminate();
|
|
15450
|
+
const input = {
|
|
15451
|
+
home: params.home,
|
|
15452
|
+
...globalConfig === void 0 ? {} : { globalConfig: { config: globalConfig.config, entryOrder: globalConfig.entryOrder, filepath: globalConfig.filepath } },
|
|
15453
|
+
...params.baseConfigProfile === void 0 ? {} : { baseConfigProfile: params.baseConfigProfile },
|
|
15454
|
+
loadProfile,
|
|
15455
|
+
levels,
|
|
15456
|
+
...params.cliOverride === void 0 ? {} : { cliOverride: params.cliOverride }
|
|
15457
|
+
};
|
|
15458
|
+
return { input, ...globalConfig === void 0 ? {} : { globalConfig: globalConfig.config } };
|
|
15459
|
+
}
|
|
15460
|
+
function readDirectorySelections(loaded) {
|
|
15461
|
+
let identity;
|
|
15462
|
+
let configProfile;
|
|
15463
|
+
for (const level of loaded.input.levels ?? []) {
|
|
15464
|
+
for (const source of [level.portable?.config, ...(level.rules ?? []).map((entry) => entry.rule), level.portableLocal?.config]) {
|
|
15465
|
+
if (source === void 0) {
|
|
15466
|
+
continue;
|
|
15467
|
+
}
|
|
15468
|
+
if (source.identity !== void 0) {
|
|
15469
|
+
identity = source.identity;
|
|
15470
|
+
}
|
|
15471
|
+
if (source.configProfile !== void 0) {
|
|
15472
|
+
configProfile = source.configProfile;
|
|
15314
15473
|
}
|
|
15315
|
-
},
|
|
15316
|
-
cancel: () => {
|
|
15317
|
-
void worker.terminate();
|
|
15318
15474
|
}
|
|
15319
|
-
}
|
|
15475
|
+
}
|
|
15476
|
+
return { ...identity === void 0 ? {} : { identity }, ...configProfile === void 0 ? {} : { configProfile } };
|
|
15320
15477
|
}
|
|
15321
|
-
var
|
|
15322
|
-
var
|
|
15323
|
-
"src/
|
|
15478
|
+
var import_node_path38, PORTABLE_CONFIG_FILENAME, PORTABLE_LOCAL_CONFIG_FILENAME;
|
|
15479
|
+
var init_cascade = __esm({
|
|
15480
|
+
"src/launcher/cascade.ts"() {
|
|
15324
15481
|
"use strict";
|
|
15325
|
-
|
|
15326
|
-
|
|
15327
|
-
|
|
15328
|
-
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
|
|
15339
|
-
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
|
|
15351
|
-
|
|
15352
|
-
|
|
15353
|
-
|
|
15354
|
-
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
|
|
15482
|
+
import_node_path38 = __toESM(require("node:path"), 1);
|
|
15483
|
+
init_load();
|
|
15484
|
+
init_schema();
|
|
15485
|
+
init_pathNorm();
|
|
15486
|
+
init_walk();
|
|
15487
|
+
init_legacy();
|
|
15488
|
+
init_names();
|
|
15489
|
+
PORTABLE_CONFIG_FILENAME = ".agent-shim.json";
|
|
15490
|
+
PORTABLE_LOCAL_CONFIG_FILENAME = ".agent-shim.local.json";
|
|
15491
|
+
}
|
|
15492
|
+
});
|
|
15493
|
+
|
|
15494
|
+
// src/launcher/memberProvider.ts
|
|
15495
|
+
function unreadableFileReason(error) {
|
|
15496
|
+
if (error instanceof ConfigValidationError) {
|
|
15497
|
+
return `${error.filepath} is invalid`;
|
|
15498
|
+
}
|
|
15499
|
+
if (error instanceof ConfigFileNotJsonError) {
|
|
15500
|
+
return error.message.replace(/\.$/, "");
|
|
15501
|
+
}
|
|
15502
|
+
if (error instanceof LegacyProviderFileError) {
|
|
15503
|
+
return `${error.filePath} uses ${error.conversion.fields.join(", ")}, which a credential block replaced`;
|
|
15504
|
+
}
|
|
15505
|
+
return void 0;
|
|
15506
|
+
}
|
|
15507
|
+
function memberProviderResolver(params) {
|
|
15508
|
+
if (params.cliProvider === false) {
|
|
15509
|
+
return () => void 0;
|
|
15510
|
+
}
|
|
15511
|
+
const cliProvider = params.cliProvider;
|
|
15512
|
+
const identities = identityReader(params.paths.identitiesDir, params.fs);
|
|
15513
|
+
const cascades = /* @__PURE__ */ new Map();
|
|
15514
|
+
const cascadeOver = (baseConfigProfile) => {
|
|
15515
|
+
const cached = cascades.get(baseConfigProfile);
|
|
15516
|
+
if (cached !== void 0) {
|
|
15517
|
+
return cached;
|
|
15358
15518
|
}
|
|
15519
|
+
const loaded = params.loadCascade(baseConfigProfile);
|
|
15520
|
+
cascades.set(baseConfigProfile, loaded);
|
|
15521
|
+
return loaded;
|
|
15359
15522
|
};
|
|
15360
|
-
|
|
15361
|
-
let
|
|
15523
|
+
return (name) => {
|
|
15524
|
+
let declared;
|
|
15362
15525
|
try {
|
|
15363
|
-
|
|
15364
|
-
} catch {
|
|
15365
|
-
|
|
15526
|
+
declared = identities.load(name);
|
|
15527
|
+
} catch (error) {
|
|
15528
|
+
if (!(error instanceof ConfigValidationError)) {
|
|
15529
|
+
throw error;
|
|
15530
|
+
}
|
|
15366
15531
|
}
|
|
15532
|
+
const profile = decideConfigProfile({
|
|
15533
|
+
env: params.env,
|
|
15534
|
+
...params.cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile: params.cliFlagConfigProfile },
|
|
15535
|
+
...params.directoryRuleConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: params.directoryRuleConfigProfile },
|
|
15536
|
+
...declared?.defaultConfigProfile === void 0 ? {} : { identityDefaultConfigProfile: declared.defaultConfigProfile },
|
|
15537
|
+
...params.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: params.globalDefaultConfigProfile }
|
|
15538
|
+
});
|
|
15539
|
+
const flagged = cliProvider !== void 0 && cliProvider !== "" ? cliProvider : void 0;
|
|
15540
|
+
let named = flagged ?? declared?.provider;
|
|
15367
15541
|
try {
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15542
|
+
const cascade = cascadeOver(profile.name);
|
|
15543
|
+
named = flagged ?? cascadeProviderName(cascade, declared?.provider);
|
|
15544
|
+
return selectedProviderName({
|
|
15545
|
+
paths: params.paths,
|
|
15546
|
+
port: params.fs,
|
|
15547
|
+
...cliProvider === void 0 ? {} : { cliProvider },
|
|
15548
|
+
cascade,
|
|
15549
|
+
...declared?.provider === void 0 ? {} : { identityProvider: declared.provider }
|
|
15550
|
+
});
|
|
15551
|
+
} catch (error) {
|
|
15552
|
+
const reason = unreadableFileReason(error);
|
|
15553
|
+
if (reason === void 0) {
|
|
15554
|
+
throw error;
|
|
15555
|
+
}
|
|
15556
|
+
return { ...named === void 0 ? {} : { named }, reason };
|
|
15372
15557
|
}
|
|
15373
15558
|
};
|
|
15374
|
-
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
PROBE_SOURCE = probeWorkerSource(`
|
|
15383
|
-
const https = require("node:https");
|
|
15384
|
-
const { port, ca, timeoutMs, ok, failed } = workerData;
|
|
15385
|
-
const finish = finishProbe;
|
|
15386
|
-
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
15387
|
-
let body = "";
|
|
15388
|
-
response.setEncoding("utf8");
|
|
15389
|
-
response.on("data", (chunk) => { body += chunk; });
|
|
15390
|
-
response.on("end", () => {
|
|
15391
|
-
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
15392
|
-
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
15393
|
-
});
|
|
15394
|
-
response.on("error", (error) => finish(failed, error.message));
|
|
15395
|
-
});
|
|
15396
|
-
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
15397
|
-
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
15398
|
-
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
15399
|
-
`);
|
|
15400
|
-
CATALOGUE_REQUEST_SOURCE = probeWorkerSource(`
|
|
15401
|
-
const https = require("node:https");
|
|
15402
|
-
const { port, ca, token, timeoutMs, ok, failed } = workerData;
|
|
15403
|
-
const finish = finishProbe;
|
|
15404
|
-
const request = https.request({ host: "127.0.0.1", port, path: "/__agent-shim/orpc/rest/frontdoor/catalogues/refresh", method: "POST", headers: { authorization: "Bearer " + token }, ca: [ca], agent: false }, (response) => {
|
|
15405
|
-
response.resume();
|
|
15406
|
-
response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
|
|
15407
|
-
response.on("error", (error) => finish(failed, error.message));
|
|
15559
|
+
}
|
|
15560
|
+
var init_memberProvider = __esm({
|
|
15561
|
+
"src/launcher/memberProvider.ts"() {
|
|
15562
|
+
"use strict";
|
|
15563
|
+
init_load();
|
|
15564
|
+
init_providersStore();
|
|
15565
|
+
init_identity2();
|
|
15566
|
+
}
|
|
15408
15567
|
});
|
|
15409
|
-
|
|
15410
|
-
|
|
15411
|
-
|
|
15412
|
-
|
|
15413
|
-
|
|
15414
|
-
|
|
15415
|
-
|
|
15416
|
-
const
|
|
15417
|
-
const
|
|
15418
|
-
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
const
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
|
|
15568
|
+
|
|
15569
|
+
// src/paths.ts
|
|
15570
|
+
function resolveAgentShimHome(env = process.env, home = import_node_os5.default.homedir(), isDirectory = isExistingDirectory) {
|
|
15571
|
+
const fromEnv = env.AGENT_SHIM_HOME;
|
|
15572
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15573
|
+
return fromEnv;
|
|
15574
|
+
}
|
|
15575
|
+
const current = import_node_path39.default.join(home, HOME_DIRNAME);
|
|
15576
|
+
const legacy = import_node_path39.default.join(home, LEGACY_HOME_DIRNAME);
|
|
15577
|
+
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
15578
|
+
}
|
|
15579
|
+
function isExistingDirectory(candidate) {
|
|
15580
|
+
return import_node_fs12.default.statSync(candidate, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
15581
|
+
}
|
|
15582
|
+
function resolveClaudeHome() {
|
|
15583
|
+
const fromEnv = process.env.AGENT_SHIM_CLAUDE_HOME;
|
|
15584
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15585
|
+
return fromEnv;
|
|
15586
|
+
}
|
|
15587
|
+
return import_node_path39.default.join(import_node_os5.default.homedir(), ".claude");
|
|
15588
|
+
}
|
|
15589
|
+
function buildLayoutPaths(root) {
|
|
15590
|
+
return {
|
|
15591
|
+
root,
|
|
15592
|
+
identitiesDir: import_node_path39.default.join(root, "identities"),
|
|
15593
|
+
configProfilesDir: import_node_path39.default.join(root, "config-profiles"),
|
|
15594
|
+
providersDir: import_node_path39.default.join(root, "providers"),
|
|
15595
|
+
providerAliasesFile: import_node_path39.default.join(root, "provider-aliases.json"),
|
|
15596
|
+
directoryRulesFile: import_node_path39.default.join(root, "directory-rules.json"),
|
|
15597
|
+
activeIdentityFile: import_node_path39.default.join(root, "active-identity"),
|
|
15598
|
+
globalConfigFile: import_node_path39.default.join(root, "config.json"),
|
|
15599
|
+
categoriesLocalFile: import_node_path39.default.join(root, "categories.local.json"),
|
|
15600
|
+
claudeShimFile: import_node_path39.default.join(root, "claude-shim.json"),
|
|
15601
|
+
headroomDir: import_node_path39.default.join(root, "headroom"),
|
|
15602
|
+
headroomStateFile: import_node_path39.default.join(root, "headroom", "state.json"),
|
|
15603
|
+
headroomRoutingFile: import_node_path39.default.join(root, "headroom", "routing.json"),
|
|
15604
|
+
headroomLegacyStateFile: import_node_path39.default.join(root, "headroom", "state.v2.json"),
|
|
15605
|
+
headroomAllowlistFile: import_node_path39.default.join(root, "headroom", "run", "allowlist.txt"),
|
|
15606
|
+
headroomSocketDir: import_node_path39.default.join(root, "headroom", "run"),
|
|
15607
|
+
headroomLockFile: import_node_path39.default.join(root, "headroom", "start.lock"),
|
|
15608
|
+
headroomSessionsDir: import_node_path39.default.join(root, "headroom", "sessions"),
|
|
15609
|
+
logsDir: import_node_path39.default.join(root, "logs"),
|
|
15610
|
+
headroomLogPath: import_node_path39.default.join(root, "logs", "headroom.log"),
|
|
15611
|
+
frontdoorDir: import_node_path39.default.join(root, "frontdoor"),
|
|
15612
|
+
frontdoorCaDir: import_node_path39.default.join(root, "frontdoor", "ca"),
|
|
15613
|
+
frontdoorCaCertFile: import_node_path39.default.join(root, "frontdoor", "ca", "ca.pem"),
|
|
15614
|
+
frontdoorCaKeyFile: import_node_path39.default.join(root, "frontdoor", "ca", "ca.key"),
|
|
15615
|
+
frontdoorCaBundlesDir: import_node_path39.default.join(root, "frontdoor", "ca", "bundles"),
|
|
15616
|
+
chatgptSignInFile: import_node_path39.default.join(root, "codex", "chatgpt-sign-in.json"),
|
|
15617
|
+
frontdoorStateFile: import_node_path39.default.join(root, "frontdoor", "state.json"),
|
|
15618
|
+
frontdoorLockFile: import_node_path39.default.join(root, "frontdoor", "start.lock"),
|
|
15619
|
+
frontdoorControlTokenFile: import_node_path39.default.join(root, "frontdoor", "control-token"),
|
|
15620
|
+
frontdoorSessionsDir: import_node_path39.default.join(root, "frontdoor", "sessions"),
|
|
15621
|
+
frontdoorDirectRecordsDir: import_node_path39.default.join(root, "frontdoor", "direct"),
|
|
15622
|
+
frontdoorDrainingDir: import_node_path39.default.join(root, "frontdoor", "draining"),
|
|
15623
|
+
frontdoorRcCredentialsDir: import_node_path39.default.join(root, "frontdoor", "rc-credentials"),
|
|
15624
|
+
frontdoorLogPath: import_node_path39.default.join(root, "logs", "frontdoor.log"),
|
|
15625
|
+
usageDir: import_node_path39.default.join(root, "usage"),
|
|
15626
|
+
usageLogDir: import_node_path39.default.join(root, "usage", "log"),
|
|
15627
|
+
usageSnapshotsDir: import_node_path39.default.join(root, "usage", "snapshots"),
|
|
15628
|
+
statuslineDir: import_node_path39.default.join(root, "statusline"),
|
|
15629
|
+
catalogueDir: import_node_path39.default.join(root, "catalogues"),
|
|
15630
|
+
usagePicksFile: import_node_path39.default.join(root, "usage", "picks.json"),
|
|
15631
|
+
usageAnchorsFile: import_node_path39.default.join(root, "usage", "anchors.json"),
|
|
15632
|
+
usageJobsFile: import_node_path39.default.join(root, "usage", "jobs.json"),
|
|
15633
|
+
jobLogsDir: import_node_path39.default.join(root, "logs", "jobs"),
|
|
15634
|
+
identityRenamesDir: import_node_path39.default.join(root, "identity-renames"),
|
|
15635
|
+
identityNameRenamesDir: import_node_path39.default.join(root, "identity-name-renames"),
|
|
15636
|
+
launchesDir: import_node_path39.default.join(root, "launches"),
|
|
15637
|
+
superviseDir: import_node_path39.default.join(root, "supervise"),
|
|
15638
|
+
modelMovesDir: import_node_path39.default.join(root, "model-moves"),
|
|
15639
|
+
mcpPermissionsFile: import_node_path39.default.join(root, "mcp", "permissions.json")
|
|
15640
|
+
};
|
|
15641
|
+
}
|
|
15642
|
+
function resolveLayoutPaths() {
|
|
15643
|
+
return buildLayoutPaths(resolveAgentShimHome());
|
|
15644
|
+
}
|
|
15645
|
+
var import_node_fs12, import_node_os5, import_node_path39;
|
|
15646
|
+
var init_paths = __esm({
|
|
15647
|
+
"src/paths.ts"() {
|
|
15648
|
+
"use strict";
|
|
15649
|
+
import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
15650
|
+
import_node_os5 = __toESM(require("node:os"), 1);
|
|
15651
|
+
import_node_path39 = __toESM(require("node:path"), 1);
|
|
15652
|
+
init_legacy();
|
|
15653
|
+
}
|
|
15428
15654
|
});
|
|
15429
|
-
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15655
|
+
|
|
15656
|
+
// src/storedCatalogue.ts
|
|
15657
|
+
function catalogueReadFault(error) {
|
|
15658
|
+
if (error instanceof UnreadableCatalogueError) {
|
|
15659
|
+
return error.fault;
|
|
15660
|
+
}
|
|
15661
|
+
const code = error instanceof Error && "code" in error ? error.code : void 0;
|
|
15662
|
+
return typeof code === "string" && /^[A-Z0-9_]{1,32}$/u.test(code) ? code : error instanceof Error ? error.name : "an error";
|
|
15663
|
+
}
|
|
15664
|
+
function catalogueStatusFile(paths, owner, name) {
|
|
15665
|
+
return import_node_path41.default.join(import_node_path41.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), `${name}.status.json`);
|
|
15666
|
+
}
|
|
15667
|
+
function catalogueFailureFile(paths, owner, name) {
|
|
15668
|
+
return import_node_path41.default.join(import_node_path41.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), "failures", `${name}.json`);
|
|
15669
|
+
}
|
|
15670
|
+
var import_node_path41, UnreadableCatalogueError, skipUnreadableCatalogue, TolerantReader, StoredCatalogue;
|
|
15671
|
+
var init_storedCatalogue = __esm({
|
|
15672
|
+
"src/storedCatalogue.ts"() {
|
|
15673
|
+
"use strict";
|
|
15674
|
+
import_node_path41 = __toESM(require("node:path"), 1);
|
|
15675
|
+
init_providerCatalogue();
|
|
15676
|
+
UnreadableCatalogueError = class extends Error {
|
|
15677
|
+
fault;
|
|
15678
|
+
constructor(fault) {
|
|
15679
|
+
super(`stored catalogue cannot be read (${fault})`);
|
|
15680
|
+
this.name = "UnreadableCatalogueError";
|
|
15681
|
+
this.fault = fault;
|
|
15682
|
+
}
|
|
15683
|
+
};
|
|
15684
|
+
skipUnreadableCatalogue = () => void 0;
|
|
15685
|
+
TolerantReader = class {
|
|
15686
|
+
#read;
|
|
15687
|
+
#onUnreadable;
|
|
15688
|
+
constructor(read, onUnreadable) {
|
|
15689
|
+
this.#read = read;
|
|
15690
|
+
this.#onUnreadable = onUnreadable;
|
|
15691
|
+
}
|
|
15692
|
+
/** The text of `file`, `undefined` when it is absent or unreadable (`onUnreadable` returned). */
|
|
15693
|
+
read(file) {
|
|
15694
|
+
try {
|
|
15695
|
+
return this.#read(file);
|
|
15696
|
+
} catch (error) {
|
|
15697
|
+
this.#onUnreadable(catalogueReadFault(error));
|
|
15698
|
+
return void 0;
|
|
15443
15699
|
}
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
|
|
15700
|
+
}
|
|
15701
|
+
/** `take()`, `undefined` when it throws: for a stat of a stored file, which fails the way a read does. The fault is reported as a read's is. */
|
|
15702
|
+
attempt(take) {
|
|
15703
|
+
try {
|
|
15704
|
+
return take();
|
|
15705
|
+
} catch (error) {
|
|
15706
|
+
this.#onUnreadable(catalogueReadFault(error));
|
|
15707
|
+
return void 0;
|
|
15447
15708
|
}
|
|
15448
15709
|
}
|
|
15449
15710
|
};
|
|
15450
|
-
|
|
15711
|
+
StoredCatalogue = class {
|
|
15712
|
+
#paths;
|
|
15713
|
+
#reader;
|
|
15714
|
+
constructor(paths, reader) {
|
|
15715
|
+
this.#paths = paths;
|
|
15716
|
+
this.#reader = reader;
|
|
15717
|
+
}
|
|
15718
|
+
/** The catalogue file of `name`: a Codex provider's is in the directory of the supervisor generation that fetched it (`owner`), an `http` provider's is shared. */
|
|
15719
|
+
cacheText(name, owner) {
|
|
15720
|
+
return this.#reader.read(catalogueCachePath(this.#paths, name, owner?.pid, owner?.generation));
|
|
15721
|
+
}
|
|
15722
|
+
/** The file holding the digest of the settings an `http` provider's catalogue was fetched under. */
|
|
15723
|
+
digestText(name) {
|
|
15724
|
+
return this.#reader.read(catalogueSettingsPath(this.#paths, name));
|
|
15725
|
+
}
|
|
15726
|
+
/** The non-secret binding between a Codex catalogue and the login that fetched it. */
|
|
15727
|
+
bindingText(name, owner) {
|
|
15728
|
+
return this.#reader.read(catalogueBindingPath(this.#paths, name, owner?.pid, owner?.generation));
|
|
15729
|
+
}
|
|
15730
|
+
/** The refresh status the supervisor generation `owner` recorded for `name`. */
|
|
15731
|
+
statusText(owner, name) {
|
|
15732
|
+
return this.#reader.read(catalogueStatusFile(this.#paths, owner, name));
|
|
15733
|
+
}
|
|
15734
|
+
/** The record of why `name`'s last refresh failed in the supervisor generation `owner`. */
|
|
15735
|
+
failureText(owner, name) {
|
|
15736
|
+
return this.#reader.read(catalogueFailureFile(this.#paths, owner, name));
|
|
15737
|
+
}
|
|
15738
|
+
/** What identifies the stored files of an `http` provider's catalogue (the catalogue and its digest) as they are now, or `undefined` when either cannot be named (it cannot be statted, or `revisionOf` knows no revision of it): the key a parse of them is kept under. */
|
|
15739
|
+
revision(name, revisionOf) {
|
|
15740
|
+
const cacheRevision = this.#reader.attempt(() => revisionOf(catalogueCachePath(this.#paths, name)));
|
|
15741
|
+
const digestRevision = this.#reader.attempt(() => revisionOf(catalogueSettingsPath(this.#paths, name)));
|
|
15742
|
+
return cacheRevision === void 0 || digestRevision === void 0 ? void 0 : `${cacheRevision}\0${digestRevision}`;
|
|
15743
|
+
}
|
|
15744
|
+
};
|
|
15451
15745
|
}
|
|
15452
15746
|
});
|
|
15453
15747
|
|
|
15454
|
-
// src/
|
|
15455
|
-
function
|
|
15456
|
-
return
|
|
15457
|
-
}
|
|
15458
|
-
function couldNotConnectMessage(subject, baseUrl, reason) {
|
|
15459
|
-
return `${subject} could not connect to ${displayBaseUrl(baseUrl)}: ${reason.trim() === "" ? "the connection failed with no reason given" : reason}`;
|
|
15460
|
-
}
|
|
15461
|
-
function probeProviderReachability(name, provider, probe) {
|
|
15462
|
-
const verdict = probe(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
15463
|
-
return verdict.ok ? { ok: true } : { ok: false, message: couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason) };
|
|
15748
|
+
// src/tolerantReaders.ts
|
|
15749
|
+
function skippingReader(fs17) {
|
|
15750
|
+
return new TolerantReader((file) => fs17.readFileUtf8(file), skipUnreadableCatalogue);
|
|
15464
15751
|
}
|
|
15465
|
-
|
|
15466
|
-
|
|
15752
|
+
var init_tolerantReaders = __esm({
|
|
15753
|
+
"src/tolerantReaders.ts"() {
|
|
15754
|
+
"use strict";
|
|
15755
|
+
init_storedCatalogue();
|
|
15756
|
+
}
|
|
15757
|
+
});
|
|
15758
|
+
|
|
15759
|
+
// src/frontdoor/catalogueState.ts
|
|
15760
|
+
function readCatalogueFailure(fs17, paths, pid, generation, name) {
|
|
15761
|
+
const raw = new StoredCatalogue(paths, skippingReader(fs17)).failureText({ pid, generation }, name);
|
|
15762
|
+
if (raw === void 0) return void 0;
|
|
15763
|
+
try {
|
|
15764
|
+
const value = import_zod32.z.strictObject({ reason: import_zod32.z.string().max(CATALOGUE_FAILURE_REASON_MAX_CHARS), redirected: import_zod32.z.literal(true).optional(), settings: import_zod32.z.string().optional() }).safeParse(JSON.parse(raw));
|
|
15765
|
+
return value.success ? { reason: value.data.reason, redirected: value.data.redirected === true, settings: value.data.settings } : void 0;
|
|
15766
|
+
} catch {
|
|
15467
15767
|
return void 0;
|
|
15468
15768
|
}
|
|
15469
|
-
const started = start(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
15470
|
-
return {
|
|
15471
|
-
cancel: started.cancel,
|
|
15472
|
-
line: () => {
|
|
15473
|
-
const verdict = started.verdict();
|
|
15474
|
-
return verdict.ok ? void 0 : couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason);
|
|
15475
|
-
}
|
|
15476
|
-
};
|
|
15477
15769
|
}
|
|
15478
|
-
function
|
|
15479
|
-
const
|
|
15480
|
-
|
|
15481
|
-
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
if (!verdict.ok) {
|
|
15488
|
-
lines.set(entry.name, couldNotConnectMessage(`provider ${entry.name}`, entry.provider.baseUrl, verdict.reason));
|
|
15489
|
-
}
|
|
15490
|
-
});
|
|
15491
|
-
return lines;
|
|
15770
|
+
function readCatalogueStatus(fs17, paths, pid, generation, name) {
|
|
15771
|
+
const raw = new StoredCatalogue(paths, skippingReader(fs17)).statusText({ pid, generation }, name);
|
|
15772
|
+
if (raw === void 0) return void 0;
|
|
15773
|
+
try {
|
|
15774
|
+
const value = import_zod32.z.strictObject({ status: import_zod32.z.enum(["running", "ready", "failed"]), fingerprint: import_zod32.z.string().min(1).optional(), recordedAt: import_zod32.z.number().optional() }).safeParse(JSON.parse(raw));
|
|
15775
|
+
return value.success ? value.data : void 0;
|
|
15776
|
+
} catch {
|
|
15777
|
+
return void 0;
|
|
15778
|
+
}
|
|
15492
15779
|
}
|
|
15493
|
-
var
|
|
15494
|
-
var
|
|
15495
|
-
"src/
|
|
15780
|
+
var import_zod32, CATALOGUE_FAILURE_REASON_MAX_CHARS;
|
|
15781
|
+
var init_catalogueState = __esm({
|
|
15782
|
+
"src/frontdoor/catalogueState.ts"() {
|
|
15496
15783
|
"use strict";
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS = 1e3;
|
|
15502
|
-
CONNECT_SYN_RETRANSMISSIONS_TOLERATED = 2;
|
|
15503
|
-
DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS = TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS * (2 ** (CONNECT_SYN_RETRANSMISSIONS_TOLERATED + 1) - 1);
|
|
15504
|
-
startBaseUrlBatchProbe = (targets, workers) => {
|
|
15505
|
-
const started = startAddressProbes(targets.map((target) => ({ ...dialTargetOf(target.baseUrl), timeoutMs: target.timeoutMs })), workers);
|
|
15506
|
-
return { cancel: started.cancel, verdicts: started.settle };
|
|
15507
|
-
};
|
|
15508
|
-
realBaseUrlBatchProbe = (targets, workers) => startBaseUrlBatchProbe(targets, workers).verdicts();
|
|
15509
|
-
realStartBaseUrlProbe = (baseUrl, timeoutMs) => {
|
|
15510
|
-
const started = startBaseUrlBatchProbe([{ baseUrl, timeoutMs }]);
|
|
15511
|
-
return {
|
|
15512
|
-
cancel: started.cancel,
|
|
15513
|
-
verdict: () => {
|
|
15514
|
-
const [verdict] = started.verdicts();
|
|
15515
|
-
if (verdict === void 0) {
|
|
15516
|
-
throw new Error("the batch probe answered no verdict for one base URL");
|
|
15517
|
-
}
|
|
15518
|
-
return verdict;
|
|
15519
|
-
}
|
|
15520
|
-
};
|
|
15521
|
-
};
|
|
15522
|
-
realBaseUrlProbe = (baseUrl, timeoutMs) => realStartBaseUrlProbe(baseUrl, timeoutMs).verdict();
|
|
15784
|
+
import_zod32 = require("zod");
|
|
15785
|
+
init_storedCatalogue();
|
|
15786
|
+
init_tolerantReaders();
|
|
15787
|
+
CATALOGUE_FAILURE_REASON_MAX_CHARS = 600;
|
|
15523
15788
|
}
|
|
15524
15789
|
});
|
|
15525
15790
|
|
|
15526
15791
|
// src/codex/auth.ts
|
|
15527
|
-
var
|
|
15792
|
+
var import_zod33, AuthFileSchema, TokenGrantSchema, CodexAuthError;
|
|
15528
15793
|
var init_auth = __esm({
|
|
15529
15794
|
"src/codex/auth.ts"() {
|
|
15530
15795
|
"use strict";
|
|
15531
|
-
|
|
15532
|
-
AuthFileSchema =
|
|
15533
|
-
tokens:
|
|
15534
|
-
access_token:
|
|
15535
|
-
refresh_token:
|
|
15536
|
-
id_token:
|
|
15537
|
-
account_id:
|
|
15796
|
+
import_zod33 = require("zod");
|
|
15797
|
+
AuthFileSchema = import_zod33.z.looseObject({
|
|
15798
|
+
tokens: import_zod33.z.looseObject({
|
|
15799
|
+
access_token: import_zod33.z.string().optional(),
|
|
15800
|
+
refresh_token: import_zod33.z.string().optional(),
|
|
15801
|
+
id_token: import_zod33.z.string().optional(),
|
|
15802
|
+
account_id: import_zod33.z.string().optional()
|
|
15538
15803
|
}).nullish(),
|
|
15539
|
-
last_refresh:
|
|
15804
|
+
last_refresh: import_zod33.z.string().optional()
|
|
15540
15805
|
});
|
|
15541
|
-
TokenGrantSchema =
|
|
15542
|
-
access_token:
|
|
15543
|
-
refresh_token:
|
|
15544
|
-
id_token:
|
|
15545
|
-
account_id:
|
|
15806
|
+
TokenGrantSchema = import_zod33.z.looseObject({
|
|
15807
|
+
access_token: import_zod33.z.string().min(1).optional(),
|
|
15808
|
+
refresh_token: import_zod33.z.string().min(1).optional(),
|
|
15809
|
+
id_token: import_zod33.z.string().min(1).optional(),
|
|
15810
|
+
account_id: import_zod33.z.string().min(1).optional()
|
|
15546
15811
|
});
|
|
15547
15812
|
CodexAuthError = class extends Error {
|
|
15548
15813
|
constructor(message) {
|
|
@@ -15554,31 +15819,31 @@ var init_auth = __esm({
|
|
|
15554
15819
|
});
|
|
15555
15820
|
|
|
15556
15821
|
// src/codex/siwc.ts
|
|
15557
|
-
var
|
|
15822
|
+
var import_zod34, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
15558
15823
|
var init_siwc = __esm({
|
|
15559
15824
|
"src/codex/siwc.ts"() {
|
|
15560
15825
|
"use strict";
|
|
15561
|
-
|
|
15826
|
+
import_zod34 = require("zod");
|
|
15562
15827
|
SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
15563
15828
|
SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
15564
15829
|
SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
15565
|
-
TokenResponseSchema =
|
|
15566
|
-
access_token:
|
|
15567
|
-
refresh_token:
|
|
15568
|
-
id_token:
|
|
15569
|
-
expires_in:
|
|
15570
|
-
scope:
|
|
15830
|
+
TokenResponseSchema = import_zod34.z.looseObject({
|
|
15831
|
+
access_token: import_zod34.z.string().min(1),
|
|
15832
|
+
refresh_token: import_zod34.z.string().min(1).optional(),
|
|
15833
|
+
id_token: import_zod34.z.string().min(1).optional(),
|
|
15834
|
+
expires_in: import_zod34.z.number().positive(),
|
|
15835
|
+
scope: import_zod34.z.string().optional()
|
|
15571
15836
|
});
|
|
15572
|
-
JwtHeaderSchema =
|
|
15573
|
-
IdTokenClaimsSchema =
|
|
15574
|
-
iss:
|
|
15575
|
-
sub:
|
|
15576
|
-
aud:
|
|
15577
|
-
exp:
|
|
15578
|
-
nonce:
|
|
15579
|
-
email:
|
|
15837
|
+
JwtHeaderSchema = import_zod34.z.looseObject({ alg: import_zod34.z.string(), kid: import_zod34.z.string().optional() });
|
|
15838
|
+
IdTokenClaimsSchema = import_zod34.z.looseObject({
|
|
15839
|
+
iss: import_zod34.z.string(),
|
|
15840
|
+
sub: import_zod34.z.string().min(1),
|
|
15841
|
+
aud: import_zod34.z.union([import_zod34.z.string(), import_zod34.z.array(import_zod34.z.string())]),
|
|
15842
|
+
exp: import_zod34.z.number(),
|
|
15843
|
+
nonce: import_zod34.z.string().optional(),
|
|
15844
|
+
email: import_zod34.z.string().optional()
|
|
15580
15845
|
});
|
|
15581
|
-
JwksSchema =
|
|
15846
|
+
JwksSchema = import_zod34.z.object({ keys: import_zod34.z.array(import_zod34.z.looseObject({ kid: import_zod34.z.string().optional(), kty: import_zod34.z.string() })) });
|
|
15582
15847
|
}
|
|
15583
15848
|
});
|
|
15584
15849
|
|
|
@@ -15596,25 +15861,25 @@ function parseSiwcFile(raw, filePath) {
|
|
|
15596
15861
|
}
|
|
15597
15862
|
return parsed.data;
|
|
15598
15863
|
}
|
|
15599
|
-
var
|
|
15864
|
+
var import_zod35, SiwcGrantSchema, SiwcFileSchema;
|
|
15600
15865
|
var init_siwcStore = __esm({
|
|
15601
15866
|
"src/codex/siwcStore.ts"() {
|
|
15602
15867
|
"use strict";
|
|
15603
|
-
|
|
15868
|
+
import_zod35 = require("zod");
|
|
15604
15869
|
init_auth();
|
|
15605
15870
|
init_siwc();
|
|
15606
|
-
SiwcGrantSchema =
|
|
15607
|
-
clientId:
|
|
15608
|
-
sub:
|
|
15609
|
-
email:
|
|
15610
|
-
idToken:
|
|
15611
|
-
accessToken:
|
|
15612
|
-
refreshToken:
|
|
15613
|
-
scopes:
|
|
15871
|
+
SiwcGrantSchema = import_zod35.z.strictObject({
|
|
15872
|
+
clientId: import_zod35.z.string().min(1),
|
|
15873
|
+
sub: import_zod35.z.string().min(1),
|
|
15874
|
+
email: import_zod35.z.string().optional(),
|
|
15875
|
+
idToken: import_zod35.z.string().min(1),
|
|
15876
|
+
accessToken: import_zod35.z.string().min(1),
|
|
15877
|
+
refreshToken: import_zod35.z.string().min(1),
|
|
15878
|
+
scopes: import_zod35.z.array(import_zod35.z.string()).readonly(),
|
|
15614
15879
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
15615
|
-
expiresAt:
|
|
15880
|
+
expiresAt: import_zod35.z.number()
|
|
15616
15881
|
});
|
|
15617
|
-
SiwcFileSchema =
|
|
15882
|
+
SiwcFileSchema = import_zod35.z.strictObject({ registeredClientId: import_zod35.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
15618
15883
|
}
|
|
15619
15884
|
});
|
|
15620
15885
|
|
|
@@ -15682,7 +15947,7 @@ function parseCatalogueBinding(raw) {
|
|
|
15682
15947
|
}
|
|
15683
15948
|
}
|
|
15684
15949
|
function catalogueCredentialFingerprint(cli, token, accountId) {
|
|
15685
|
-
return (0,
|
|
15950
|
+
return (0, import_node_crypto16.createHash)("sha256").update(JSON.stringify([cli, token, accountId])).digest("hex");
|
|
15686
15951
|
}
|
|
15687
15952
|
function cliCatalogueFingerprint(raw) {
|
|
15688
15953
|
if (raw === void 0) return void 0;
|
|
@@ -15701,36 +15966,21 @@ function signInCatalogueFingerprint(raw, filePath) {
|
|
|
15701
15966
|
const grant = parseSiwcFile(raw, filePath).grant;
|
|
15702
15967
|
return grant === void 0 ? void 0 : catalogueCredentialFingerprint(false, grant.accessToken, void 0);
|
|
15703
15968
|
}
|
|
15704
|
-
function savedCatalogueFingerprint(provider, paths, env, home,
|
|
15705
|
-
if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(read(paths.chatgptSignInFile), paths.chatgptSignInFile);
|
|
15969
|
+
function savedCatalogueFingerprint(provider, paths, env, home, reader) {
|
|
15970
|
+
if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(reader.read(paths.chatgptSignInFile), paths.chatgptSignInFile);
|
|
15706
15971
|
const configuredHome = env.CODEX_HOME;
|
|
15707
|
-
const codexHome = configuredHome === void 0 || configuredHome === "" ?
|
|
15708
|
-
return cliCatalogueFingerprint(read(
|
|
15972
|
+
const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path42.default.join(home, ".codex") : configuredHome;
|
|
15973
|
+
return cliCatalogueFingerprint(reader.read(import_node_path42.default.join(codexHome, "auth.json")));
|
|
15709
15974
|
}
|
|
15710
|
-
var
|
|
15975
|
+
var import_node_crypto16, import_node_path42, import_zod36, CatalogueBindingSchema;
|
|
15711
15976
|
var init_catalogueCredential = __esm({
|
|
15712
15977
|
"src/codex/catalogueCredential.ts"() {
|
|
15713
15978
|
"use strict";
|
|
15714
|
-
|
|
15715
|
-
|
|
15716
|
-
|
|
15979
|
+
import_node_crypto16 = require("node:crypto");
|
|
15980
|
+
import_node_path42 = __toESM(require("node:path"), 1);
|
|
15981
|
+
import_zod36 = require("zod");
|
|
15717
15982
|
init_siwcStore();
|
|
15718
|
-
CatalogueBindingSchema =
|
|
15719
|
-
}
|
|
15720
|
-
});
|
|
15721
|
-
|
|
15722
|
-
// src/models/tiers.ts
|
|
15723
|
-
var TIER_ENV_VARIABLES;
|
|
15724
|
-
var init_tiers = __esm({
|
|
15725
|
-
"src/models/tiers.ts"() {
|
|
15726
|
-
"use strict";
|
|
15727
|
-
init_schema();
|
|
15728
|
-
TIER_ENV_VARIABLES = Object.freeze({
|
|
15729
|
-
fable: "ANTHROPIC_DEFAULT_FABLE_MODEL",
|
|
15730
|
-
opus: "ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
15731
|
-
sonnet: "ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
15732
|
-
haiku: "ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
|
15733
|
-
});
|
|
15983
|
+
CatalogueBindingSchema = import_zod36.z.strictObject({ fingerprint: import_zod36.z.string().min(1), source: import_zod36.z.string().min(1), revision: import_zod36.z.string().min(1) });
|
|
15734
15984
|
}
|
|
15735
15985
|
});
|
|
15736
15986
|
|
|
@@ -15781,64 +16031,64 @@ var init_signatures = __esm({
|
|
|
15781
16031
|
});
|
|
15782
16032
|
|
|
15783
16033
|
// src/codex/anthropic.ts
|
|
15784
|
-
var
|
|
16034
|
+
var import_zod37, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
15785
16035
|
var init_anthropic = __esm({
|
|
15786
16036
|
"src/codex/anthropic.ts"() {
|
|
15787
16037
|
"use strict";
|
|
15788
|
-
|
|
15789
|
-
TextBlockSchema =
|
|
15790
|
-
Base64ImageSourceSchema =
|
|
15791
|
-
UrlImageSourceSchema =
|
|
15792
|
-
ImageBlockSchema =
|
|
15793
|
-
type:
|
|
15794
|
-
source:
|
|
16038
|
+
import_zod37 = require("zod");
|
|
16039
|
+
TextBlockSchema = import_zod37.z.looseObject({ type: import_zod37.z.literal("text"), text: import_zod37.z.string() });
|
|
16040
|
+
Base64ImageSourceSchema = import_zod37.z.looseObject({ type: import_zod37.z.literal("base64"), media_type: import_zod37.z.string().min(1), data: import_zod37.z.string() });
|
|
16041
|
+
UrlImageSourceSchema = import_zod37.z.looseObject({ type: import_zod37.z.literal("url"), url: import_zod37.z.string().min(1) });
|
|
16042
|
+
ImageBlockSchema = import_zod37.z.looseObject({
|
|
16043
|
+
type: import_zod37.z.literal("image"),
|
|
16044
|
+
source: import_zod37.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
15795
16045
|
});
|
|
15796
|
-
ToolUseBlockSchema =
|
|
15797
|
-
type:
|
|
15798
|
-
id:
|
|
15799
|
-
name:
|
|
15800
|
-
input:
|
|
16046
|
+
ToolUseBlockSchema = import_zod37.z.looseObject({
|
|
16047
|
+
type: import_zod37.z.literal("tool_use"),
|
|
16048
|
+
id: import_zod37.z.string().min(1),
|
|
16049
|
+
name: import_zod37.z.string().min(1),
|
|
16050
|
+
input: import_zod37.z.unknown()
|
|
15801
16051
|
});
|
|
15802
|
-
ToolResultContentBlockSchema =
|
|
15803
|
-
ToolResultBlockSchema =
|
|
15804
|
-
type:
|
|
15805
|
-
tool_use_id:
|
|
15806
|
-
content:
|
|
16052
|
+
ToolResultContentBlockSchema = import_zod37.z.union([TextBlockSchema, import_zod37.z.looseObject({ type: import_zod37.z.string() })]);
|
|
16053
|
+
ToolResultBlockSchema = import_zod37.z.looseObject({
|
|
16054
|
+
type: import_zod37.z.literal("tool_result"),
|
|
16055
|
+
tool_use_id: import_zod37.z.string().min(1),
|
|
16056
|
+
content: import_zod37.z.union([import_zod37.z.string(), import_zod37.z.array(ToolResultContentBlockSchema)]).optional()
|
|
15807
16057
|
});
|
|
15808
|
-
OtherBlockSchema =
|
|
15809
|
-
ContentBlockSchema =
|
|
15810
|
-
MessageSchema =
|
|
15811
|
-
role:
|
|
15812
|
-
content:
|
|
16058
|
+
OtherBlockSchema = import_zod37.z.looseObject({ type: import_zod37.z.string() });
|
|
16059
|
+
ContentBlockSchema = import_zod37.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
16060
|
+
MessageSchema = import_zod37.z.looseObject({
|
|
16061
|
+
role: import_zod37.z.enum(["user", "assistant", "system"]),
|
|
16062
|
+
content: import_zod37.z.union([import_zod37.z.string(), import_zod37.z.array(ContentBlockSchema)])
|
|
15813
16063
|
});
|
|
15814
|
-
ToolSchema =
|
|
15815
|
-
name:
|
|
15816
|
-
description:
|
|
15817
|
-
input_schema:
|
|
15818
|
-
allowed_domains:
|
|
15819
|
-
blocked_domains:
|
|
16064
|
+
ToolSchema = import_zod37.z.looseObject({
|
|
16065
|
+
name: import_zod37.z.string().min(1),
|
|
16066
|
+
description: import_zod37.z.string().optional(),
|
|
16067
|
+
input_schema: import_zod37.z.record(import_zod37.z.string(), import_zod37.z.unknown()).optional(),
|
|
16068
|
+
allowed_domains: import_zod37.z.array(import_zod37.z.string()).optional(),
|
|
16069
|
+
blocked_domains: import_zod37.z.array(import_zod37.z.string()).optional()
|
|
15820
16070
|
});
|
|
15821
|
-
ToolChoiceSchema =
|
|
15822
|
-
|
|
15823
|
-
|
|
16071
|
+
ToolChoiceSchema = import_zod37.z.union([
|
|
16072
|
+
import_zod37.z.looseObject({ type: import_zod37.z.enum(["auto", "none", "any"]) }),
|
|
16073
|
+
import_zod37.z.looseObject({ type: import_zod37.z.literal("tool"), name: import_zod37.z.string().min(1) })
|
|
15824
16074
|
]);
|
|
15825
|
-
SystemSchema =
|
|
15826
|
-
MessagesRequestSchema =
|
|
15827
|
-
model:
|
|
16075
|
+
SystemSchema = import_zod37.z.union([import_zod37.z.string(), import_zod37.z.array(import_zod37.z.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
16076
|
+
MessagesRequestSchema = import_zod37.z.looseObject({
|
|
16077
|
+
model: import_zod37.z.string().optional(),
|
|
15828
16078
|
system: SystemSchema.optional(),
|
|
15829
|
-
messages:
|
|
15830
|
-
tools:
|
|
16079
|
+
messages: import_zod37.z.array(MessageSchema),
|
|
16080
|
+
tools: import_zod37.z.array(ToolSchema).optional(),
|
|
15831
16081
|
tool_choice: ToolChoiceSchema.optional(),
|
|
15832
|
-
stream:
|
|
16082
|
+
stream: import_zod37.z.boolean().optional(),
|
|
15833
16083
|
/** `user_id` is stable for one Claude Code session and differs between sessions, which is what makes it the right key for both the backend's prompt cache and its session header. */
|
|
15834
|
-
metadata:
|
|
16084
|
+
metadata: import_zod37.z.looseObject({ user_id: import_zod37.z.string().optional() }).optional(),
|
|
15835
16085
|
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
15836
|
-
output_config:
|
|
16086
|
+
output_config: import_zod37.z.looseObject({ effort: import_zod37.z.string().optional(), format: import_zod37.z.object({ type: import_zod37.z.literal("json_schema"), schema: import_zod37.z.record(import_zod37.z.string(), import_zod37.z.unknown()) }).optional() }).optional()
|
|
15837
16087
|
});
|
|
15838
|
-
CountTokensRequestSchema =
|
|
15839
|
-
system:
|
|
15840
|
-
messages:
|
|
15841
|
-
tools:
|
|
16088
|
+
CountTokensRequestSchema = import_zod37.z.looseObject({
|
|
16089
|
+
system: import_zod37.z.unknown().optional(),
|
|
16090
|
+
messages: import_zod37.z.unknown().optional(),
|
|
16091
|
+
tools: import_zod37.z.unknown().optional()
|
|
15842
16092
|
});
|
|
15843
16093
|
}
|
|
15844
16094
|
});
|
|
@@ -15887,7 +16137,7 @@ var AUTO_ALIAS;
|
|
|
15887
16137
|
var init_translate = __esm({
|
|
15888
16138
|
"src/antigravity/translate.ts"() {
|
|
15889
16139
|
"use strict";
|
|
15890
|
-
|
|
16140
|
+
init_identity();
|
|
15891
16141
|
init_tiers();
|
|
15892
16142
|
init_engine();
|
|
15893
16143
|
init_quota();
|
|
@@ -16048,7 +16298,7 @@ var init_modelPicker = __esm({
|
|
|
16048
16298
|
init_translate2();
|
|
16049
16299
|
init_providerCatalogue();
|
|
16050
16300
|
init_schema();
|
|
16051
|
-
|
|
16301
|
+
init_identity();
|
|
16052
16302
|
init_families();
|
|
16053
16303
|
init_modelsStore();
|
|
16054
16304
|
init_tiers();
|
|
@@ -16068,13 +16318,17 @@ function providerModels(paths) {
|
|
|
16068
16318
|
const supervisorPid = recordedPid !== void 0 && realIsProcessAlive(recordedPid) ? recordedPid : void 0;
|
|
16069
16319
|
const doorRecord = supervisorPid === void 0 ? void 0 : readFrontDoorCodexRecord(realFarmFs, paths.frontdoorDir, supervisorPid);
|
|
16070
16320
|
const doorHome = doorRecord?.codexHome;
|
|
16321
|
+
const reader = new TolerantReader((file) => realFsPort.readFileUtf8(file), skipUnreadableCatalogue);
|
|
16322
|
+
const files = new StoredCatalogue(paths, reader);
|
|
16071
16323
|
return listProviders(paths).flatMap((entry) => {
|
|
16072
16324
|
if (entry.provider.kind === "codex" && supervisorPid !== void 0 && doorRecord === void 0) return [];
|
|
16073
|
-
const
|
|
16325
|
+
const owner = supervisorPid === void 0 || doorRecord === void 0 ? void 0 : { pid: supervisorPid, generation: doorRecord.generation };
|
|
16326
|
+
const stored = parseCatalogueCache(files.cacheText(entry.name, entry.provider.kind === "codex" ? owner : void 0));
|
|
16327
|
+
const catalogue = stored !== void 0 && isHttpProvider(entry.provider) && !catalogueMatchesSettings(parseCatalogueSettings(files.digestText(entry.name)), stored, entry.provider) ? void 0 : stored;
|
|
16074
16328
|
if (entry.provider.kind === "codex") {
|
|
16075
16329
|
if (catalogue !== void 0 && catalogue.supervisorPid !== supervisorPid) return [];
|
|
16076
16330
|
const env = doorHome === void 0 ? process.env : { ...process.env, CODEX_HOME: doorHome };
|
|
16077
|
-
const fingerprint = savedCatalogueFingerprint(entry.provider, paths, env, import_node_os7.default.homedir(),
|
|
16331
|
+
const fingerprint = savedCatalogueFingerprint(entry.provider, paths, env, import_node_os7.default.homedir(), reader);
|
|
16078
16332
|
if (fingerprint === void 0 || catalogue?.credentialFingerprint !== fingerprint) return [];
|
|
16079
16333
|
}
|
|
16080
16334
|
return providerModelRows(entry.provider, catalogue?.models).map((row) => ({ provider: entry.name, model: row.model }));
|
|
@@ -16091,7 +16345,9 @@ var init_targets = __esm({
|
|
|
16091
16345
|
init_catalogueCredential();
|
|
16092
16346
|
init_state();
|
|
16093
16347
|
init_modelPicker();
|
|
16348
|
+
init_schema();
|
|
16094
16349
|
init_providerCatalogue();
|
|
16350
|
+
init_storedCatalogue();
|
|
16095
16351
|
init_providersStore();
|
|
16096
16352
|
init_realPorts();
|
|
16097
16353
|
}
|
|
@@ -16315,7 +16571,7 @@ function ensureFrontDoor(params) {
|
|
|
16315
16571
|
if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
|
|
16316
16572
|
if (state?.port !== void 0 && state.connectPort !== void 0) {
|
|
16317
16573
|
if (supervisorPid === params.launcherPid && params.replace === void 0 && ports.isFrontDoorSupervisor(supervisorPid)) {
|
|
16318
|
-
const token = (0,
|
|
16574
|
+
const token = (0, import_node_crypto17.randomUUID)();
|
|
16319
16575
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid, ...recordOf(params.session) });
|
|
16320
16576
|
return { port: state.port, connectPort: state.connectPort, token, supervisorPid };
|
|
16321
16577
|
}
|
|
@@ -16336,7 +16592,7 @@ function ensureFrontDoor(params) {
|
|
|
16336
16592
|
continue;
|
|
16337
16593
|
}
|
|
16338
16594
|
if (verdict.ok) {
|
|
16339
|
-
const token = (0,
|
|
16595
|
+
const token = (0, import_node_crypto17.randomUUID)();
|
|
16340
16596
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid, ...recordOf(params.session) });
|
|
16341
16597
|
return { port: state.port, connectPort: state.connectPort, token, supervisorPid };
|
|
16342
16598
|
}
|
|
@@ -16389,11 +16645,11 @@ function ensureFrontDoor(params) {
|
|
|
16389
16645
|
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
16390
16646
|
}
|
|
16391
16647
|
}
|
|
16392
|
-
var
|
|
16648
|
+
var import_node_crypto17, FRONTDOOR_START_TIMEOUT_MS, FRONTDOOR_LAUNCHER_POLL_MS, FRONTDOOR_PROBE_ATTEMPTS, FRONTDOOR_EXIT_GRACE_MS, FrontDoorStartError;
|
|
16393
16649
|
var init_ensure2 = __esm({
|
|
16394
16650
|
"src/frontdoor/ensure.ts"() {
|
|
16395
16651
|
"use strict";
|
|
16396
|
-
|
|
16652
|
+
import_node_crypto17 = require("node:crypto");
|
|
16397
16653
|
init_cliError();
|
|
16398
16654
|
init_state2();
|
|
16399
16655
|
init_replacement();
|
|
@@ -16792,7 +17048,7 @@ function buildEnv(params) {
|
|
|
16792
17048
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
16793
17049
|
let providerCustomHeaders;
|
|
16794
17050
|
if (!params.configDirEscapeHatch && params.identityId !== void 0) {
|
|
16795
|
-
env.CLAUDE_CONFIG_DIR =
|
|
17051
|
+
env.CLAUDE_CONFIG_DIR = import_node_path50.default.join(params.identitiesDir, params.identityId);
|
|
16796
17052
|
}
|
|
16797
17053
|
if (params.provider !== void 0) {
|
|
16798
17054
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
@@ -16869,11 +17125,11 @@ function buildEnv(params) {
|
|
|
16869
17125
|
injections.finish();
|
|
16870
17126
|
return env;
|
|
16871
17127
|
}
|
|
16872
|
-
var
|
|
17128
|
+
var import_node_path50, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
|
|
16873
17129
|
var init_flags = __esm({
|
|
16874
17130
|
"src/launcher/flags.ts"() {
|
|
16875
17131
|
"use strict";
|
|
16876
|
-
|
|
17132
|
+
import_node_path50 = __toESM(require("node:path"), 1);
|
|
16877
17133
|
init_envBool();
|
|
16878
17134
|
init_cliError();
|
|
16879
17135
|
init_conditions();
|
|
@@ -16966,7 +17222,7 @@ function newestTranscript(fs17, projectDir) {
|
|
|
16966
17222
|
if (!name.endsWith(".jsonl")) {
|
|
16967
17223
|
continue;
|
|
16968
17224
|
}
|
|
16969
|
-
const candidate =
|
|
17225
|
+
const candidate = import_node_path51.default.join(projectDir, name);
|
|
16970
17226
|
const stat = fs17.lstat(candidate);
|
|
16971
17227
|
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
16972
17228
|
newestMs = stat.mtimeMs;
|
|
@@ -16980,16 +17236,16 @@ function resumedContextTokens(fs17, params) {
|
|
|
16980
17236
|
if (target === void 0) {
|
|
16981
17237
|
return void 0;
|
|
16982
17238
|
}
|
|
16983
|
-
const projectDir =
|
|
16984
|
-
const file = target.kind === "id" ?
|
|
17239
|
+
const projectDir = import_node_path51.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
17240
|
+
const file = target.kind === "id" ? import_node_path51.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
|
|
16985
17241
|
const text = file === void 0 ? void 0 : fs17.readFileUtf8(file);
|
|
16986
17242
|
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
16987
17243
|
}
|
|
16988
|
-
var
|
|
17244
|
+
var import_node_path51;
|
|
16989
17245
|
var init_resumeContext = __esm({
|
|
16990
17246
|
"src/usage/resumeContext.ts"() {
|
|
16991
17247
|
"use strict";
|
|
16992
|
-
|
|
17248
|
+
import_node_path51 = __toESM(require("node:path"), 1);
|
|
16993
17249
|
}
|
|
16994
17250
|
});
|
|
16995
17251
|
|
|
@@ -17486,7 +17742,7 @@ var RESUME_FLAGS, TERMINATOR3, REASONS_LOGGED;
|
|
|
17486
17742
|
var init_pool = __esm({
|
|
17487
17743
|
"src/launcher/pool.ts"() {
|
|
17488
17744
|
"use strict";
|
|
17489
|
-
|
|
17745
|
+
init_identity2();
|
|
17490
17746
|
init_preflight();
|
|
17491
17747
|
init_poolPick();
|
|
17492
17748
|
RESUME_FLAGS = /* @__PURE__ */ new Set(["--continue", "-c", "--resume", "-r"]);
|
|
@@ -17695,7 +17951,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17695
17951
|
const farmIdentity = configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : resolveIdentityId(paths.identitiesDir, identityDecision.name, fs17);
|
|
17696
17952
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
17697
17953
|
if (!readOnly && params.supervised?.member === void 0 && farmIdentity !== void 0 && identityDecision.name !== void 0) {
|
|
17698
|
-
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name,
|
|
17954
|
+
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name, import_node_path52.default.join(paths.identitiesDir, farmIdentity));
|
|
17699
17955
|
}
|
|
17700
17956
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
17701
17957
|
try {
|
|
@@ -17876,25 +18132,27 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17876
18132
|
const doorRecord = doorPid === void 0 ? void 0 : readFrontDoorCodexRecord(params.fs, paths.frontdoorDir, doorPid);
|
|
17877
18133
|
const doorHome = doorRecord?.codexHome;
|
|
17878
18134
|
const catalogueEnv = doorHome === void 0 ? env : { ...env, CODEX_HOME: doorHome };
|
|
18135
|
+
const reader = new TolerantReader((file) => params.fs.readFileUtf8(file), skipUnreadableCatalogue);
|
|
18136
|
+
const stored = new StoredCatalogue(paths, reader);
|
|
17879
18137
|
const listedProviders = listProviderNames(fs17.readdir, paths.providersDir).flatMap((name) => {
|
|
17880
18138
|
try {
|
|
17881
18139
|
const definition = loadProvider(paths.providersDir, name, fs17);
|
|
17882
18140
|
if (definition === void 0) return [];
|
|
17883
|
-
const
|
|
17884
|
-
const
|
|
17885
|
-
const cache = parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, name, catalogueOwner, generation)));
|
|
18141
|
+
const owner = definition.kind === "codex" && doorPid !== void 0 && doorRecord !== void 0 ? { pid: doorPid, generation: doorRecord.generation } : void 0;
|
|
18142
|
+
const cache = parseCatalogueCache(stored.cacheText(name, owner));
|
|
17886
18143
|
if (definition.kind === "codex" && cache !== void 0 && cache.supervisorPid !== doorPid) return [];
|
|
17887
18144
|
if (definition.kind === "codex" && doorPid !== void 0 && doorRecord === void 0) return [];
|
|
17888
18145
|
if (definition.kind === "codex" && readOnly && cache !== void 0) {
|
|
17889
|
-
const binding = parseCatalogueBinding(
|
|
18146
|
+
const binding = parseCatalogueBinding(stored.bindingText(name, owner));
|
|
17890
18147
|
const configuredHome = catalogueEnv.CODEX_HOME;
|
|
17891
|
-
const home = configuredHome === void 0 || configuredHome === "" ?
|
|
17892
|
-
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile :
|
|
18148
|
+
const home = configuredHome === void 0 || configuredHome === "" ? import_node_path52.default.join(import_node_os9.default.homedir(), ".codex") : configuredHome;
|
|
18149
|
+
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : import_node_path52.default.resolve(home, "auth.json");
|
|
17893
18150
|
const revision = params.fs.fileRevision?.(source);
|
|
17894
18151
|
if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
|
|
17895
18152
|
}
|
|
17896
|
-
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, import_node_os9.default.homedir(),
|
|
18153
|
+
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, import_node_os9.default.homedir(), reader) : void 0;
|
|
17897
18154
|
if (definition.kind === "codex" && !readOnly && cache !== void 0 && (fingerprint === void 0 || cache.credentialFingerprint !== fingerprint)) return [];
|
|
18155
|
+
if (isHttpProvider(definition) && cache !== void 0 && !catalogueMatchesSettings(parseCatalogueSettings(stored.digestText(name)), cache, definition)) return [[name, definition, []]];
|
|
17898
18156
|
return [[name, definition, cache?.models ?? []]];
|
|
17899
18157
|
} catch {
|
|
17900
18158
|
return [];
|
|
@@ -17910,7 +18168,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17910
18168
|
return { args: args2, pickerSuppressed: startsSession && pickerSettings !== void 0 && callerSettings };
|
|
17911
18169
|
};
|
|
17912
18170
|
const args = argsForSupervisor().args;
|
|
17913
|
-
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR :
|
|
18171
|
+
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path52.default.join(paths.identitiesDir, farmIdentity);
|
|
17914
18172
|
const decision = {
|
|
17915
18173
|
identitySource: identityDecision.source,
|
|
17916
18174
|
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
@@ -18006,7 +18264,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18006
18264
|
let warnings = [];
|
|
18007
18265
|
const updateCheck = runLaunchUpdateCheck({
|
|
18008
18266
|
mode: params.updateMode ?? "off",
|
|
18009
|
-
checkPath:
|
|
18267
|
+
checkPath: import_node_path52.default.join(paths.root, "update.check"),
|
|
18010
18268
|
currentVersion: package_default.version,
|
|
18011
18269
|
port: params.update
|
|
18012
18270
|
});
|
|
@@ -18029,7 +18287,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18029
18287
|
classification: resyncFarmRuntime.classification,
|
|
18030
18288
|
now: resyncFarmRuntime.now,
|
|
18031
18289
|
uniqueSuffix: resyncFarmRuntime.uniqueSuffix,
|
|
18032
|
-
identityExists: () => params.fs.readConfigFile(
|
|
18290
|
+
identityExists: () => params.fs.readConfigFile(import_node_path52.default.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
|
|
18033
18291
|
lock: resyncFarmRuntime.lock
|
|
18034
18292
|
});
|
|
18035
18293
|
} catch (error) {
|
|
@@ -18063,7 +18321,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18063
18321
|
log.error("agent-shim: this launch routes through the front-door daemon, but this launcher has no front-door port wired; refusing to launch without it.");
|
|
18064
18322
|
proc.exit(1);
|
|
18065
18323
|
}
|
|
18066
|
-
const sessionId = params.supervised?.sessionId ?? (0,
|
|
18324
|
+
const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto18.randomUUID)();
|
|
18067
18325
|
const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
|
|
18068
18326
|
const sessionModels = (0, import_node_util2.isDeepStrictEqual)(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
|
|
18069
18327
|
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels } };
|
|
@@ -18177,15 +18435,15 @@ function runLaunchPlan(plan, spawn3) {
|
|
|
18177
18435
|
function runLauncher(params) {
|
|
18178
18436
|
params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
|
|
18179
18437
|
}
|
|
18180
|
-
var
|
|
18438
|
+
var import_node_crypto18, import_node_os9, import_node_util2, import_node_path52;
|
|
18181
18439
|
var init_launcher = __esm({
|
|
18182
18440
|
"src/launcher.ts"() {
|
|
18183
18441
|
"use strict";
|
|
18184
|
-
|
|
18442
|
+
import_node_crypto18 = require("node:crypto");
|
|
18185
18443
|
import_node_os9 = __toESM(require("node:os"), 1);
|
|
18186
18444
|
init_catalogueCredential();
|
|
18187
18445
|
import_node_util2 = require("node:util");
|
|
18188
|
-
|
|
18446
|
+
import_node_path52 = __toESM(require("node:path"), 1);
|
|
18189
18447
|
init_package();
|
|
18190
18448
|
init_envBool();
|
|
18191
18449
|
init_argv();
|
|
@@ -18196,7 +18454,7 @@ var init_launcher = __esm({
|
|
|
18196
18454
|
init_guard();
|
|
18197
18455
|
init_identityRecords();
|
|
18198
18456
|
init_identityNameRenameRecord();
|
|
18199
|
-
|
|
18457
|
+
init_identity2();
|
|
18200
18458
|
init_flags();
|
|
18201
18459
|
init_extraFlags();
|
|
18202
18460
|
init_claudeSession();
|
|
@@ -18207,6 +18465,7 @@ var init_launcher = __esm({
|
|
|
18207
18465
|
init_modelPicker();
|
|
18208
18466
|
init_state();
|
|
18209
18467
|
init_providerCatalogue();
|
|
18468
|
+
init_storedCatalogue();
|
|
18210
18469
|
init_providersStore();
|
|
18211
18470
|
init_memberProvider();
|
|
18212
18471
|
init_pool();
|
|
@@ -18238,13 +18497,13 @@ function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string"
|
|
|
18238
18497
|
if (distDir === void 0) {
|
|
18239
18498
|
throw new OwnCliPathUnknownError();
|
|
18240
18499
|
}
|
|
18241
|
-
return
|
|
18500
|
+
return import_node_path53.default.join(distDir, OWN_CLI_FILE_NAME);
|
|
18242
18501
|
}
|
|
18243
|
-
var
|
|
18502
|
+
var import_node_path53, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
18244
18503
|
var init_ownCli = __esm({
|
|
18245
18504
|
"src/ownCli.ts"() {
|
|
18246
18505
|
"use strict";
|
|
18247
|
-
|
|
18506
|
+
import_node_path53 = __toESM(require("node:path"), 1);
|
|
18248
18507
|
init_cliError();
|
|
18249
18508
|
OWN_CLI_FILE_NAME = "cli.cjs";
|
|
18250
18509
|
OwnCliPathUnknownError = class extends CliError {
|
|
@@ -18287,7 +18546,7 @@ var init_selfIdentity = __esm({
|
|
|
18287
18546
|
// src/frontdoor/trust.ts
|
|
18288
18547
|
function resolveTrustBundle(params) {
|
|
18289
18548
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs17 } = params;
|
|
18290
|
-
if (inherited === void 0 || inherited === "" ||
|
|
18549
|
+
if (inherited === void 0 || inherited === "" || import_node_path54.default.resolve(inherited) === import_node_path54.default.resolve(caCertFile)) {
|
|
18291
18550
|
return { path: caCertFile };
|
|
18292
18551
|
}
|
|
18293
18552
|
const caPem = fs17.readFileUtf8(caCertFile);
|
|
@@ -18305,19 +18564,19 @@ function resolveTrustBundle(params) {
|
|
|
18305
18564
|
}
|
|
18306
18565
|
const combined = `${inheritedPem.trimEnd()}
|
|
18307
18566
|
${caPem}`;
|
|
18308
|
-
const bundle =
|
|
18567
|
+
const bundle = import_node_path54.default.join(bundlesDir, `${(0, import_node_crypto19.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
18309
18568
|
if (!fs17.exists(bundle)) {
|
|
18310
18569
|
fs17.mkdirp(bundlesDir);
|
|
18311
18570
|
fs17.writeFileAtomic(bundle, combined);
|
|
18312
18571
|
}
|
|
18313
18572
|
return { path: bundle };
|
|
18314
18573
|
}
|
|
18315
|
-
var
|
|
18574
|
+
var import_node_crypto19, import_node_path54, BUNDLE_NAME_HEX_DIGITS;
|
|
18316
18575
|
var init_trust = __esm({
|
|
18317
18576
|
"src/frontdoor/trust.ts"() {
|
|
18318
18577
|
"use strict";
|
|
18319
|
-
|
|
18320
|
-
|
|
18578
|
+
import_node_crypto19 = require("node:crypto");
|
|
18579
|
+
import_node_path54 = __toESM(require("node:path"), 1);
|
|
18321
18580
|
BUNDLE_NAME_HEX_DIGITS = 16;
|
|
18322
18581
|
}
|
|
18323
18582
|
});
|
|
@@ -18366,35 +18625,49 @@ function realFrontDoorPort(paths, spawnDaemon) {
|
|
|
18366
18625
|
return {
|
|
18367
18626
|
waitForCatalogues: (supervisorPid) => {
|
|
18368
18627
|
const timedOut = deadlineAfter(CATALOGUE_REFRESH_DEADLINE_MS);
|
|
18628
|
+
const stored = new StoredCatalogue(paths, new TolerantReader((file) => realFarmFs.readFileUtf8(file), skipUnreadableCatalogue));
|
|
18369
18629
|
let requested = false;
|
|
18370
18630
|
const warnings = /* @__PURE__ */ new Set();
|
|
18371
18631
|
while (!isDeclaredFrontDoor(supervisorPid) && listProviders(paths).map(({ name, provider }) => {
|
|
18372
18632
|
const owner = readFrontDoorCodexRecord(realFarmFs, paths.frontdoorDir, supervisorPid);
|
|
18373
18633
|
const published = owner === void 0 ? void 0 : readCatalogueStatus(realFarmFs, paths, supervisorPid, owner.generation, name);
|
|
18374
|
-
|
|
18634
|
+
const failedUnderCurrentSettings = () => {
|
|
18635
|
+
if (!isHttpProvider(provider) || owner === void 0) return true;
|
|
18636
|
+
if (provider.catalogue === void 0) return false;
|
|
18637
|
+
const recorded = readCatalogueFailure(realFarmFs, paths, supervisorPid, owner.generation, name)?.settings;
|
|
18638
|
+
return recorded === void 0 || recorded === catalogueSettingsFingerprint(provider);
|
|
18639
|
+
};
|
|
18640
|
+
if (provider.kind !== "codex" && published?.status === "failed" && published.recordedAt !== void 0 && within(published.recordedAt, Date.now(), CATALOGUE_RETRY_MS) && failedUnderCurrentSettings()) {
|
|
18375
18641
|
warnings.add(`Catalogue refresh failed for ${name}`);
|
|
18376
18642
|
return false;
|
|
18377
18643
|
}
|
|
18378
18644
|
if (provider.kind === "codex") {
|
|
18379
18645
|
if (owner === void 0) return true;
|
|
18380
|
-
const cache2 = parseCatalogueCache(
|
|
18646
|
+
const cache2 = parseCatalogueCache(stored.cacheText(name, { pid: supervisorPid, generation: owner.generation }));
|
|
18381
18647
|
let fingerprint;
|
|
18648
|
+
let loginFault;
|
|
18382
18649
|
try {
|
|
18383
|
-
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, import_node_os10.default.homedir(), realFarmFs.readFileUtf8)
|
|
18650
|
+
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, import_node_os10.default.homedir(), new TolerantReader((file) => realFarmFs.readFileUtf8(file), (fault) => {
|
|
18651
|
+
loginFault = fault;
|
|
18652
|
+
}));
|
|
18384
18653
|
} catch (error) {
|
|
18385
18654
|
warnings.add(`Cannot read catalogue credentials for ${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
18386
18655
|
return false;
|
|
18387
18656
|
}
|
|
18657
|
+
if (loginFault !== void 0) {
|
|
18658
|
+
warnings.add(`Cannot read the catalogue credentials for ${name} (${loginFault})`);
|
|
18659
|
+
return false;
|
|
18660
|
+
}
|
|
18388
18661
|
const outcome = readCatalogueStatus(realFarmFs, paths, supervisorPid, owner.generation, name);
|
|
18389
|
-
if (outcome?.status === "failed" && outcome.fingerprint === fingerprint && outcome.recordedAt !== void 0 && outcome.recordedAt
|
|
18662
|
+
if (outcome?.status === "failed" && outcome.fingerprint === fingerprint && outcome.recordedAt !== void 0 && within(outcome.recordedAt, Date.now(), CATALOGUE_RETRY_MS)) {
|
|
18390
18663
|
warnings.add(`Catalogue refresh failed for ${name}`);
|
|
18391
18664
|
return false;
|
|
18392
18665
|
}
|
|
18393
18666
|
return cache2 === void 0 || isCatalogueStale(cache2, Date.now()) || cache2.supervisorPid !== supervisorPid || fingerprint === void 0 || cache2.credentialFingerprint !== fingerprint;
|
|
18394
18667
|
}
|
|
18395
18668
|
if (provider.kind !== void 0 && provider.kind !== "http" || provider.catalogue === void 0) return false;
|
|
18396
|
-
const cache = parseCatalogueCache(
|
|
18397
|
-
return cache === void 0 || isCatalogueStale(cache, Date.now());
|
|
18669
|
+
const cache = parseCatalogueCache(stored.cacheText(name));
|
|
18670
|
+
return cache === void 0 || isCatalogueStale(cache, Date.now()) || !catalogueMatchesSettings(parseCatalogueSettings(stored.digestText(name)), cache, provider);
|
|
18398
18671
|
}).some(Boolean)) {
|
|
18399
18672
|
if (timedOut()) return [...warnings, "Timed out waiting for provider catalogues"].join("; ");
|
|
18400
18673
|
if (!requested) {
|
|
@@ -18437,12 +18710,16 @@ var init_realFrontDoorPort = __esm({
|
|
|
18437
18710
|
import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
18438
18711
|
import_node_os10 = __toESM(require("node:os"), 1);
|
|
18439
18712
|
init_providersStore();
|
|
18713
|
+
init_schema();
|
|
18440
18714
|
init_providerCatalogue();
|
|
18715
|
+
init_storedCatalogue();
|
|
18716
|
+
init_elapsedWindow();
|
|
18441
18717
|
init_catalogueCredential();
|
|
18442
18718
|
init_realPorts();
|
|
18443
18719
|
init_doorLog();
|
|
18444
18720
|
init_ensure2();
|
|
18445
18721
|
init_state();
|
|
18722
|
+
init_catalogueState();
|
|
18446
18723
|
init_probe();
|
|
18447
18724
|
init_selfIdentity();
|
|
18448
18725
|
init_trust();
|
|
@@ -18487,7 +18764,7 @@ function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
|
18487
18764
|
...cliOverride === void 0 ? {} : { cliOverride }
|
|
18488
18765
|
}).input,
|
|
18489
18766
|
now: () => Date.now(),
|
|
18490
|
-
uniqueSuffix: `${String(process.pid)}.${(0,
|
|
18767
|
+
uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto20.randomUUID)()}`,
|
|
18491
18768
|
// Zombie-aware on purpose: a previous launcher that crashed out of a resync without releasing the lock may sit unreaped, still answering signal 0 as alive, and must read as a dead holder so this launch takes the lock over instead of timing out.
|
|
18492
18769
|
lock: { pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }
|
|
18493
18770
|
},
|
|
@@ -18515,8 +18792,8 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
18515
18792
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
18516
18793
|
startBaseUrlProbe: realStartBaseUrlProbe,
|
|
18517
18794
|
hold: realHoldPort,
|
|
18518
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot:
|
|
18519
|
-
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin,
|
|
18795
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path55.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
18796
|
+
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, import_node_path55.default.join(paths.identitiesDir, identity), options.proc.env),
|
|
18520
18797
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
18521
18798
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
18522
18799
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -18580,13 +18857,13 @@ function resolveClaudeLaunch(options, run = realRunPort) {
|
|
|
18580
18857
|
};
|
|
18581
18858
|
return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, run, farm: buildFarmRuntime(paths, options.cwd, run) })), warnings };
|
|
18582
18859
|
}
|
|
18583
|
-
var import_node_os11,
|
|
18860
|
+
var import_node_os11, import_node_path55, import_node_crypto20, LaunchRefusedError;
|
|
18584
18861
|
var init_launchWiring = __esm({
|
|
18585
18862
|
"src/launchWiring.ts"() {
|
|
18586
18863
|
"use strict";
|
|
18587
18864
|
import_node_os11 = __toESM(require("node:os"), 1);
|
|
18588
|
-
|
|
18589
|
-
|
|
18865
|
+
import_node_path55 = __toESM(require("node:path"), 1);
|
|
18866
|
+
import_node_crypto20 = require("node:crypto");
|
|
18590
18867
|
init_cliError();
|
|
18591
18868
|
init_claudeShim();
|
|
18592
18869
|
init_classify();
|
|
@@ -18741,7 +19018,7 @@ var init_anthropicUsageRefresh = __esm({
|
|
|
18741
19018
|
"src/usage/anthropicUsageRefresh.ts"() {
|
|
18742
19019
|
"use strict";
|
|
18743
19020
|
init_schema();
|
|
18744
|
-
|
|
19021
|
+
init_identity2();
|
|
18745
19022
|
init_middleware();
|
|
18746
19023
|
init_windowLengths();
|
|
18747
19024
|
init_plan2();
|
|
@@ -18812,11 +19089,11 @@ var init_identityClaude = __esm({
|
|
|
18812
19089
|
});
|
|
18813
19090
|
|
|
18814
19091
|
// src/usage/providerQuota.ts
|
|
18815
|
-
var
|
|
19092
|
+
var import_zod48, MS_PER_SECOND9, SECONDS_PER_HOUR3, HOURS_PER_DAY6, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY2, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
|
|
18816
19093
|
var init_providerQuota = __esm({
|
|
18817
19094
|
"src/usage/providerQuota.ts"() {
|
|
18818
19095
|
"use strict";
|
|
18819
|
-
|
|
19096
|
+
import_zod48 = require("zod");
|
|
18820
19097
|
init_cloudUpstream();
|
|
18821
19098
|
init_schema2();
|
|
18822
19099
|
MS_PER_SECOND9 = 1e3;
|
|
@@ -18831,35 +19108,35 @@ var init_providerQuota = __esm({
|
|
|
18831
19108
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
|
|
18832
19109
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
|
|
18833
19110
|
]);
|
|
18834
|
-
ZaiLimitSchema =
|
|
18835
|
-
type:
|
|
18836
|
-
unit:
|
|
18837
|
-
number:
|
|
18838
|
-
percentage:
|
|
18839
|
-
nextResetTime:
|
|
18840
|
-
usage:
|
|
18841
|
-
currentValue:
|
|
18842
|
-
remaining:
|
|
19111
|
+
ZaiLimitSchema = import_zod48.z.object({
|
|
19112
|
+
type: import_zod48.z.string(),
|
|
19113
|
+
unit: import_zod48.z.number().int(),
|
|
19114
|
+
number: import_zod48.z.number().int().positive(),
|
|
19115
|
+
percentage: import_zod48.z.number().nonnegative(),
|
|
19116
|
+
nextResetTime: import_zod48.z.number().positive().optional(),
|
|
19117
|
+
usage: import_zod48.z.number().nonnegative().optional(),
|
|
19118
|
+
currentValue: import_zod48.z.number().nonnegative().optional(),
|
|
19119
|
+
remaining: import_zod48.z.number().nonnegative().optional()
|
|
18843
19120
|
});
|
|
18844
|
-
ZaiResponseSchema =
|
|
18845
|
-
success:
|
|
18846
|
-
msg:
|
|
18847
|
-
data:
|
|
19121
|
+
ZaiResponseSchema = import_zod48.z.object({
|
|
19122
|
+
success: import_zod48.z.boolean(),
|
|
19123
|
+
msg: import_zod48.z.string().optional(),
|
|
19124
|
+
data: import_zod48.z.object({ level: import_zod48.z.string().optional(), limits: import_zod48.z.array(ZaiLimitSchema) })
|
|
18848
19125
|
});
|
|
18849
19126
|
OPENROUTER_HOST = "openrouter.ai";
|
|
18850
19127
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
18851
19128
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
18852
19129
|
MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
18853
|
-
OpenRouterKeySchema =
|
|
18854
|
-
data:
|
|
18855
|
-
limit:
|
|
18856
|
-
limit_remaining:
|
|
18857
|
-
limit_reset:
|
|
18858
|
-
is_free_tier:
|
|
18859
|
-
free_model_daily_requests:
|
|
19130
|
+
OpenRouterKeySchema = import_zod48.z.object({
|
|
19131
|
+
data: import_zod48.z.object({
|
|
19132
|
+
limit: import_zod48.z.number().nonnegative().nullable(),
|
|
19133
|
+
limit_remaining: import_zod48.z.number().nullable(),
|
|
19134
|
+
limit_reset: import_zod48.z.string().nullable(),
|
|
19135
|
+
is_free_tier: import_zod48.z.boolean().optional(),
|
|
19136
|
+
free_model_daily_requests: import_zod48.z.object({ used: import_zod48.z.number().nonnegative(), limit: import_zod48.z.number().nonnegative(), remaining: import_zod48.z.number() }).optional()
|
|
18860
19137
|
})
|
|
18861
19138
|
});
|
|
18862
|
-
OpenRouterCreditsSchema =
|
|
19139
|
+
OpenRouterCreditsSchema = import_zod48.z.object({ data: import_zod48.z.object({ total_credits: import_zod48.z.number().nonnegative(), total_usage: import_zod48.z.number().nonnegative() }) });
|
|
18863
19140
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
18864
19141
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
18865
19142
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
@@ -18867,21 +19144,21 @@ var init_providerQuota = __esm({
|
|
|
18867
19144
|
DAYS_PER_WEEK2 = 7;
|
|
18868
19145
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
18869
19146
|
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
18870
|
-
AntigravityBucketSchema =
|
|
18871
|
-
bucketId:
|
|
18872
|
-
remainingFraction:
|
|
18873
|
-
resetTime:
|
|
19147
|
+
AntigravityBucketSchema = import_zod48.z.object({
|
|
19148
|
+
bucketId: import_zod48.z.string(),
|
|
19149
|
+
remainingFraction: import_zod48.z.number().optional(),
|
|
19150
|
+
resetTime: import_zod48.z.string().optional()
|
|
18874
19151
|
});
|
|
18875
|
-
AntigravitySummarySchema =
|
|
18876
|
-
GoogleTokenInfoSchema =
|
|
18877
|
-
email:
|
|
18878
|
-
sub:
|
|
19152
|
+
AntigravitySummarySchema = import_zod48.z.object({ groups: import_zod48.z.array(import_zod48.z.object({ buckets: import_zod48.z.array(AntigravityBucketSchema) })) });
|
|
19153
|
+
GoogleTokenInfoSchema = import_zod48.z.object({
|
|
19154
|
+
email: import_zod48.z.string().optional(),
|
|
19155
|
+
sub: import_zod48.z.string().optional()
|
|
18879
19156
|
});
|
|
18880
|
-
AntigravityUserSchema =
|
|
19157
|
+
AntigravityUserSchema = import_zod48.z.object({
|
|
18881
19158
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
18882
|
-
currentTier:
|
|
19159
|
+
currentTier: import_zod48.z.object({ name: import_zod48.z.string().optional(), id: import_zod48.z.string().optional() }).optional(),
|
|
18883
19160
|
/** The account's paid subscription; absent when the account has none. */
|
|
18884
|
-
paidTier:
|
|
19161
|
+
paidTier: import_zod48.z.object({ name: import_zod48.z.string().optional(), id: import_zod48.z.string().optional() }).optional()
|
|
18885
19162
|
});
|
|
18886
19163
|
}
|
|
18887
19164
|
});
|
|
@@ -20123,7 +20400,7 @@ function createRcApiRouter(deps) {
|
|
|
20123
20400
|
const dropped = statuses.flatMap((status) => status.pendingDropped === void 0 ? [] : [{ sessionId: status.id, count: status.pendingDropped }]);
|
|
20124
20401
|
return { pending, ...dropped.length === 0 ? {} : { dropped } };
|
|
20125
20402
|
}),
|
|
20126
|
-
send: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/send", summary: "Send one message into a session", tags: [RC_API_TAG] })).input(RcSendInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.inject(input.session, input.text)) })),
|
|
20403
|
+
send: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/send", summary: "Send one message into a session", description: RC_SEND_DELIVERY_NOTE, tags: [RC_API_TAG] })).input(RcSendInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.inject(input.session, input.text)) })),
|
|
20127
20404
|
answer: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/answer", summary: "Answer one pending control request: approve or deny it, or choose the options of a pending question", tags: [RC_API_TAG] })).input(RcAnswerInputSchema).output(RcAnswerOutputSchema).handler(async ({ input }) => {
|
|
20128
20405
|
const decision = { approve: input.approve, message: input.approve || input.text === void 0 ? void 0 : input.text, ...input.choices === void 0 ? {} : { choices: input.choices } };
|
|
20129
20406
|
return { session: input.session, request: input.request, sequenceNums: delivered(input.session, await deps.answer(input.session, input.request, decision)) };
|
|
@@ -20519,7 +20796,7 @@ var import_openapi9 = require("@orpc/openapi");
|
|
|
20519
20796
|
var import_zod27 = require("zod");
|
|
20520
20797
|
init_schema();
|
|
20521
20798
|
init_claudeVersion();
|
|
20522
|
-
|
|
20799
|
+
init_identity2();
|
|
20523
20800
|
init_projects();
|
|
20524
20801
|
|
|
20525
20802
|
// src/resolve/types.ts
|
|
@@ -20735,8 +21012,8 @@ var ResetRowSchema = import_zod28.z.strictObject({
|
|
|
20735
21012
|
var ResetScheduleSchema = import_zod28.z.strictObject({ resets: import_zod28.z.readonly(import_zod28.z.array(ResetRowSchema)) });
|
|
20736
21013
|
|
|
20737
21014
|
// src/frontdoor/controlSchemas.ts
|
|
20738
|
-
var
|
|
20739
|
-
var
|
|
21015
|
+
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
21016
|
+
var import_zod38 = require("zod");
|
|
20740
21017
|
|
|
20741
21018
|
// src/codex/doctor.ts
|
|
20742
21019
|
function codexIdentityFindings(entry, identity) {
|
|
@@ -20821,7 +21098,56 @@ function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
|
|
|
20821
21098
|
}
|
|
20822
21099
|
|
|
20823
21100
|
// src/doctorReport.ts
|
|
20824
|
-
var
|
|
21101
|
+
var import_node_path43 = __toESM(require("node:path"), 1);
|
|
21102
|
+
init_signIn();
|
|
21103
|
+
init_identityAccounts();
|
|
21104
|
+
init_read();
|
|
21105
|
+
init_providerReachability();
|
|
21106
|
+
|
|
21107
|
+
// src/doctorNameFinding.ts
|
|
21108
|
+
init_names();
|
|
21109
|
+
init_reservedModelNames();
|
|
21110
|
+
function pushNameFinding(push, section, kind, entry) {
|
|
21111
|
+
if (section === "provider") {
|
|
21112
|
+
pushReservedProviderNameFinding(push, entry);
|
|
21113
|
+
}
|
|
21114
|
+
if (isFileName(entry.name)) {
|
|
21115
|
+
return true;
|
|
21116
|
+
}
|
|
21117
|
+
if (!isStoredName(entry.name)) {
|
|
21118
|
+
push(section, "fail", `${entry.path} cannot be used as a ${kind}: its name is ${JSON.stringify(entry.name)}, and a name ${FILE_NAME_RULE}. Rename or remove the file.`, entry.name);
|
|
21119
|
+
return false;
|
|
21120
|
+
}
|
|
21121
|
+
push(
|
|
21122
|
+
section,
|
|
21123
|
+
"warn",
|
|
21124
|
+
`The ${kind} ${JSON.stringify(entry.name)} is stored under a name that does not fit the shape names are given now (a name ${FILE_NAME_RULE}). It still works from your own configuration, but a project file cannot name it. Rename ${entry.path} to a name that fits, and change what names it.`,
|
|
21125
|
+
entry.name
|
|
21126
|
+
);
|
|
21127
|
+
return true;
|
|
21128
|
+
}
|
|
21129
|
+
function pushReservedProviderNameFinding(push, entry) {
|
|
21130
|
+
const reason = reservedProviderNameReason(entry.name);
|
|
21131
|
+
if (reason !== void 0) {
|
|
21132
|
+
push("provider", "warn", `The provider ${JSON.stringify(entry.name)} is called a bare model name: ${reason}, so a session's bare ${JSON.stringify(entry.name)} follows its route and never selects this provider. Rename it, or select it with ${JSON.stringify(`${entry.name}/<model>`)}.`, entry.name);
|
|
21133
|
+
}
|
|
21134
|
+
}
|
|
21135
|
+
|
|
21136
|
+
// src/doctorCatalogueRedirect.ts
|
|
21137
|
+
init_schema();
|
|
21138
|
+
init_providerCatalogue();
|
|
21139
|
+
init_providersStore();
|
|
21140
|
+
function pushCatalogueRedirectFinding(push, providerName, reason) {
|
|
21141
|
+
push("provider", "warn", `The catalogue refresh of provider ${JSON.stringify(providerName)} reached a redirect, which a catalogue read never follows (its request carries the provider's credential, and a redirect target is another origin), so its catalogue is not being kept current. Set the provider's base URL (or its catalogue.url) to the address it redirects to, which running agent-shim provider models <name> --refresh from a shell prints. The refresh recorded: ${JSON.stringify(reason)}.`, providerName);
|
|
21142
|
+
}
|
|
21143
|
+
function currentCatalogueSettings(paths, name) {
|
|
21144
|
+
try {
|
|
21145
|
+
const provider = readProvider(paths, name);
|
|
21146
|
+
return provider === void 0 || !isHttpProvider(provider) || provider.catalogue === void 0 ? void 0 : catalogueSettingsFingerprint(provider);
|
|
21147
|
+
} catch {
|
|
21148
|
+
return void 0;
|
|
21149
|
+
}
|
|
21150
|
+
}
|
|
20825
21151
|
|
|
20826
21152
|
// src/checkReport.ts
|
|
20827
21153
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
@@ -20857,10 +21183,10 @@ init_load();
|
|
|
20857
21183
|
var import_node_os4 = __toESM(require("node:os"), 1);
|
|
20858
21184
|
init_load();
|
|
20859
21185
|
init_cascade();
|
|
20860
|
-
|
|
21186
|
+
init_identity2();
|
|
20861
21187
|
|
|
20862
21188
|
// src/poolPickReport.ts
|
|
20863
|
-
|
|
21189
|
+
init_identity2();
|
|
20864
21190
|
init_poolPick();
|
|
20865
21191
|
function candidateView(candidate) {
|
|
20866
21192
|
return {
|
|
@@ -21381,29 +21707,39 @@ function collectCheckReport(params) {
|
|
|
21381
21707
|
return report;
|
|
21382
21708
|
}
|
|
21383
21709
|
|
|
21384
|
-
// src/
|
|
21385
|
-
|
|
21386
|
-
|
|
21387
|
-
|
|
21388
|
-
|
|
21389
|
-
|
|
21390
|
-
// src/doctorNameFinding.ts
|
|
21391
|
-
init_names();
|
|
21392
|
-
function pushNameFinding(push, section, kind, entry) {
|
|
21393
|
-
if (isFileName(entry.name)) {
|
|
21394
|
-
return true;
|
|
21710
|
+
// src/doctorKeychain.ts
|
|
21711
|
+
function pushKeychainFindings(push, platform, run, identities, agentOf) {
|
|
21712
|
+
if (platform !== "darwin" || run === void 0) {
|
|
21713
|
+
push("keychain", "pass", "Skipped (not macOS).");
|
|
21714
|
+
return;
|
|
21395
21715
|
}
|
|
21396
|
-
|
|
21397
|
-
|
|
21398
|
-
|
|
21716
|
+
for (const entry of identities) {
|
|
21717
|
+
if (agentOf.get(entry.name) === "codex") continue;
|
|
21718
|
+
const result = lookupKeychainService(run, entry.farmRoot);
|
|
21719
|
+
push("keychain", "pass", result.found ? result.note : `${result.note} The sign-in section reports whether a login is stored elsewhere.`, entry.name);
|
|
21399
21720
|
}
|
|
21400
|
-
|
|
21401
|
-
|
|
21402
|
-
|
|
21403
|
-
|
|
21404
|
-
|
|
21405
|
-
|
|
21406
|
-
|
|
21721
|
+
}
|
|
21722
|
+
|
|
21723
|
+
// src/frontdoor/catalogueFailures.ts
|
|
21724
|
+
init_state();
|
|
21725
|
+
init_catalogueState();
|
|
21726
|
+
function providersWithRedirectedCatalogue(fs17, paths, settingsOf2) {
|
|
21727
|
+
const supervisorPid = readFrontDoorState(fs17, paths.frontdoorStateFile)?.supervisorPid;
|
|
21728
|
+
const generation = supervisorPid === void 0 ? void 0 : readFrontDoorCodexRecord(fs17, paths.frontdoorDir, supervisorPid)?.generation;
|
|
21729
|
+
if (supervisorPid === void 0 || generation === void 0) {
|
|
21730
|
+
return /* @__PURE__ */ new Map();
|
|
21731
|
+
}
|
|
21732
|
+
const found = /* @__PURE__ */ new Map();
|
|
21733
|
+
for (const [name, settings] of settingsOf2) {
|
|
21734
|
+
if (readCatalogueStatus(fs17, paths, supervisorPid, generation, name)?.status !== "failed") {
|
|
21735
|
+
continue;
|
|
21736
|
+
}
|
|
21737
|
+
const failure = readCatalogueFailure(fs17, paths, supervisorPid, generation, name);
|
|
21738
|
+
if (settings !== void 0 && failure?.redirected === true && failure.settings === settings) {
|
|
21739
|
+
found.set(name, failure.reason);
|
|
21740
|
+
}
|
|
21741
|
+
}
|
|
21742
|
+
return found;
|
|
21407
21743
|
}
|
|
21408
21744
|
|
|
21409
21745
|
// src/doctorReport.ts
|
|
@@ -21420,7 +21756,7 @@ init_source();
|
|
|
21420
21756
|
// src/models/doctor.ts
|
|
21421
21757
|
init_modelsStore();
|
|
21422
21758
|
init_families();
|
|
21423
|
-
|
|
21759
|
+
init_identity();
|
|
21424
21760
|
function modelsFindings(input) {
|
|
21425
21761
|
const findings = [];
|
|
21426
21762
|
const { models } = input;
|
|
@@ -21683,12 +22019,12 @@ init_identityRenameJournal();
|
|
|
21683
22019
|
init_providerAliases();
|
|
21684
22020
|
init_providersStore();
|
|
21685
22021
|
init_guard();
|
|
21686
|
-
|
|
22022
|
+
init_identity2();
|
|
21687
22023
|
init_poolStore();
|
|
21688
22024
|
|
|
21689
22025
|
// src/poolSharedLogins.ts
|
|
21690
22026
|
init_identityAccounts();
|
|
21691
|
-
|
|
22027
|
+
init_identity2();
|
|
21692
22028
|
function sharedLoginMembers(members, accountOf) {
|
|
21693
22029
|
const known = members.flatMap((identity) => {
|
|
21694
22030
|
const account = poolNameOf(identity) === void 0 ? accountOf(identity) : void 0;
|
|
@@ -21707,7 +22043,7 @@ function describeSharedLoginMembers(poolName, shared) {
|
|
|
21707
22043
|
|
|
21708
22044
|
// src/poolWindowReads.ts
|
|
21709
22045
|
init_schema();
|
|
21710
|
-
|
|
22046
|
+
init_identity2();
|
|
21711
22047
|
init_conditions();
|
|
21712
22048
|
init_middleware();
|
|
21713
22049
|
init_rateLimit();
|
|
@@ -21838,7 +22174,7 @@ function tcpPortEraRecord(raw) {
|
|
|
21838
22174
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
21839
22175
|
}
|
|
21840
22176
|
function pushPathResolution(push, resolution) {
|
|
21841
|
-
const ownDir =
|
|
22177
|
+
const ownDir = import_node_path43.default.dirname(resolution.ownExecutablePath);
|
|
21842
22178
|
switch (resolution.agentShim.status) {
|
|
21843
22179
|
case "ok":
|
|
21844
22180
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -21958,14 +22294,14 @@ function pushProvider(push, entry, cacheEnv, signIn, unreachable) {
|
|
|
21958
22294
|
}
|
|
21959
22295
|
function pushLegacyName(push, params) {
|
|
21960
22296
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
21961
|
-
if (legacyVariables.length === 0 &&
|
|
22297
|
+
if (legacyVariables.length === 0 && import_node_path43.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
21962
22298
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
21963
22299
|
return;
|
|
21964
22300
|
}
|
|
21965
22301
|
for (const name of legacyVariables) {
|
|
21966
22302
|
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);
|
|
21967
22303
|
}
|
|
21968
|
-
if (
|
|
22304
|
+
if (import_node_path43.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
21969
22305
|
push(
|
|
21970
22306
|
"legacy-name",
|
|
21971
22307
|
"warn",
|
|
@@ -22055,7 +22391,7 @@ function runDoctor(params) {
|
|
|
22055
22391
|
push("identity", "warn", `identities/${name} cannot be reached (${code}), so it is not counted as an identity. Repair the permissions of the directory or of what a symlink points through, or remove the entry.`, name);
|
|
22056
22392
|
}
|
|
22057
22393
|
for (const { file, detail } of params.renameJournals?.unreadable ?? []) {
|
|
22058
|
-
push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`,
|
|
22394
|
+
push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`, import_node_path43.default.basename(file));
|
|
22059
22395
|
}
|
|
22060
22396
|
const validIdentityAgents = /* @__PURE__ */ new Map();
|
|
22061
22397
|
const signedInAccounts = [];
|
|
@@ -22181,20 +22517,16 @@ function runDoctor(params) {
|
|
|
22181
22517
|
continue;
|
|
22182
22518
|
}
|
|
22183
22519
|
pushProvider(push, entry, params.credentialCache, params.chatgptSignIn, unreachableLines.get(entry.name));
|
|
22520
|
+
const redirectReason = params.catalogueRedirects?.get(entry.name);
|
|
22521
|
+
if (redirectReason !== void 0) {
|
|
22522
|
+
pushCatalogueRedirectFinding(push, entry.name, redirectReason);
|
|
22523
|
+
}
|
|
22184
22524
|
}
|
|
22185
22525
|
const providerNames = new Set(params.providers.map((entry) => entry.name));
|
|
22186
22526
|
for (const finding of aliasFindings(params.providerAliases ?? {}, providerNames)) {
|
|
22187
22527
|
push("provider", finding.level, finding.message, finding.alias);
|
|
22188
22528
|
}
|
|
22189
|
-
|
|
22190
|
-
push("keychain", "pass", "Skipped (not macOS).");
|
|
22191
|
-
} else {
|
|
22192
|
-
for (const entry of params.identities) {
|
|
22193
|
-
if (validIdentityAgents.get(entry.name) === "codex") continue;
|
|
22194
|
-
const result = lookupKeychainService(params.run, entry.farmRoot);
|
|
22195
|
-
push("keychain", "pass", result.found ? result.note : `${result.note} The sign-in section reports whether a login is stored elsewhere.`, entry.name);
|
|
22196
|
-
}
|
|
22197
|
-
}
|
|
22529
|
+
pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
|
|
22198
22530
|
if (params.directoryRules.raw === void 0) {
|
|
22199
22531
|
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
22200
22532
|
} else {
|
|
@@ -22421,9 +22753,9 @@ function collectDoctorReport(params) {
|
|
|
22421
22753
|
const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
|
|
22422
22754
|
const records = identityRecords(paths);
|
|
22423
22755
|
const displacedIdentities = records.filter((record) => !identityIdExists(paths, record.id) && !unreachableIdentities.some((entry) => entry.name === record.id));
|
|
22424
|
-
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !import_node_fs14.default.existsSync(
|
|
22425
|
-
const farmRoot =
|
|
22426
|
-
const identityPath =
|
|
22756
|
+
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !import_node_fs14.default.existsSync(import_node_path43.default.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
|
|
22757
|
+
const farmRoot = import_node_path43.default.join(paths.identitiesDir, id);
|
|
22758
|
+
const identityPath = import_node_path43.default.join(farmRoot, "identity.json");
|
|
22427
22759
|
return { name: identityNameIn(records, id) ?? id, id, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs14.default.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, id)?.account };
|
|
22428
22760
|
});
|
|
22429
22761
|
const usageSnapshots = {};
|
|
@@ -22441,12 +22773,12 @@ function collectDoctorReport(params) {
|
|
|
22441
22773
|
}
|
|
22442
22774
|
const profileNames = import_node_fs14.default.existsSync(paths.configProfilesDir) ? import_node_fs14.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22443
22775
|
const configProfiles = profileNames.map((name) => {
|
|
22444
|
-
const profilePath =
|
|
22776
|
+
const profilePath = import_node_path43.default.join(paths.configProfilesDir, `${name}.json`);
|
|
22445
22777
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
22446
22778
|
});
|
|
22447
22779
|
const providerNames = import_node_fs14.default.existsSync(paths.providersDir) ? import_node_fs14.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22448
22780
|
const providers = providerNames.map((name) => {
|
|
22449
|
-
const providerPath =
|
|
22781
|
+
const providerPath = import_node_path43.default.join(paths.providersDir, `${name}.json`);
|
|
22450
22782
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
22451
22783
|
});
|
|
22452
22784
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -22458,12 +22790,12 @@ function collectDoctorReport(params) {
|
|
|
22458
22790
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
22459
22791
|
}
|
|
22460
22792
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
22461
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
22793
|
+
const pathDirs = (params.env.PATH ?? "").split(import_node_path43.default.delimiter).filter((dir) => dir !== "");
|
|
22462
22794
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
22463
22795
|
findPathShadow({
|
|
22464
22796
|
pathDirs,
|
|
22465
|
-
targetDir:
|
|
22466
|
-
targetFilename:
|
|
22797
|
+
targetDir: import_node_path43.default.dirname(shimState.targetPath),
|
|
22798
|
+
targetFilename: import_node_path43.default.basename(shimState.targetPath),
|
|
22467
22799
|
findExecutableInDir
|
|
22468
22800
|
}),
|
|
22469
22801
|
shimState.targetPath,
|
|
@@ -22488,9 +22820,10 @@ function collectDoctorReport(params) {
|
|
|
22488
22820
|
providers,
|
|
22489
22821
|
providerAliases: readProviderAliases(paths),
|
|
22490
22822
|
probeBaseUrls: realBaseUrlBatchProbe,
|
|
22823
|
+
catalogueRedirects: providersWithRedirectedCatalogue(realFarmFs, paths, new Map(providers.map((entry) => [entry.name, currentCatalogueSettings(paths, entry.name)]))),
|
|
22491
22824
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
22492
22825
|
unreachableIdentities,
|
|
22493
|
-
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(
|
|
22826
|
+
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(import_node_path43.default.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
|
|
22494
22827
|
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
22495
22828
|
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
22496
22829
|
models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
|
|
@@ -22505,7 +22838,7 @@ function collectDoctorReport(params) {
|
|
|
22505
22838
|
agentShim: refinePathShadow(
|
|
22506
22839
|
findPathShadow({
|
|
22507
22840
|
pathDirs,
|
|
22508
|
-
targetDir:
|
|
22841
|
+
targetDir: import_node_path43.default.dirname(ownExecutablePath),
|
|
22509
22842
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
22510
22843
|
findExecutableInDir
|
|
22511
22844
|
}),
|
|
@@ -22548,93 +22881,93 @@ function collectDoctorReport(params) {
|
|
|
22548
22881
|
init_schema2();
|
|
22549
22882
|
init_rcSchemas();
|
|
22550
22883
|
init_state();
|
|
22551
|
-
var UsageListOutputSchema =
|
|
22552
|
-
var UsageWindowsInputSchema =
|
|
22553
|
-
identity:
|
|
22554
|
-
provider:
|
|
22884
|
+
var UsageListOutputSchema = import_zod38.z.strictObject({ snapshots: import_zod38.z.readonly(import_zod38.z.array(UsageSnapshotSchema)) });
|
|
22885
|
+
var UsageWindowsInputSchema = import_zod38.z.strictObject({
|
|
22886
|
+
identity: import_zod38.z.string().min(1),
|
|
22887
|
+
provider: import_zod38.z.string().min(1).optional()
|
|
22555
22888
|
});
|
|
22556
|
-
var EffectiveWindowSchema =
|
|
22889
|
+
var EffectiveWindowSchema = import_zod38.z.strictObject({
|
|
22557
22890
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
22558
|
-
reset:
|
|
22891
|
+
reset: import_zod38.z.boolean(),
|
|
22559
22892
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
22560
|
-
utilization:
|
|
22893
|
+
utilization: import_zod38.z.number().optional(),
|
|
22561
22894
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
22562
|
-
resetsAtMs:
|
|
22895
|
+
resetsAtMs: import_zod38.z.number().optional(),
|
|
22563
22896
|
/** The window's own status, for a window that has not reset yet. */
|
|
22564
|
-
status:
|
|
22897
|
+
status: import_zod38.z.string().optional()
|
|
22565
22898
|
});
|
|
22566
|
-
var UsageWindowsOutputSchema =
|
|
22567
|
-
identity:
|
|
22568
|
-
provider:
|
|
22899
|
+
var UsageWindowsOutputSchema = import_zod38.z.strictObject({
|
|
22900
|
+
identity: import_zod38.z.string(),
|
|
22901
|
+
provider: import_zod38.z.string(),
|
|
22569
22902
|
/** When the rate-limit state the windows come from was observed. */
|
|
22570
|
-
observedAt:
|
|
22903
|
+
observedAt: import_zod38.z.iso.datetime().optional(),
|
|
22571
22904
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
22572
22905
|
sevenDay: EffectiveWindowSchema.optional()
|
|
22573
22906
|
});
|
|
22574
|
-
var UsageLiveOutputSchema =
|
|
22907
|
+
var UsageLiveOutputSchema = import_zod38.z.strictObject({
|
|
22575
22908
|
/** The freshest observation the door holds, never narrowed by the read's session filter because it is the door's single latest statement of the account's quota; absent while no rate_limit_event has been filed at all. */
|
|
22576
22909
|
latest: RcLiveRateLimitSchema.optional(),
|
|
22577
22910
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
22578
|
-
sessions:
|
|
22911
|
+
sessions: import_zod38.z.readonly(import_zod38.z.array(RcLiveRateLimitSchema))
|
|
22579
22912
|
});
|
|
22580
|
-
var FrontDoorSessionStatusSchema =
|
|
22581
|
-
pid:
|
|
22582
|
-
startedAt:
|
|
22583
|
-
alive:
|
|
22913
|
+
var FrontDoorSessionStatusSchema = import_zod38.z.strictObject({
|
|
22914
|
+
pid: import_zod38.z.int().positive(),
|
|
22915
|
+
startedAt: import_zod38.z.number(),
|
|
22916
|
+
alive: import_zod38.z.boolean()
|
|
22584
22917
|
});
|
|
22585
|
-
var HeadroomSocketTargetSchema =
|
|
22586
|
-
var FrontDoorStatusOutputSchema =
|
|
22918
|
+
var HeadroomSocketTargetSchema = import_zod38.z.union([import_zod38.z.strictObject({ socketPath: import_zod38.z.string() }), import_zod38.z.strictObject({ refused: import_zod38.z.string() })]);
|
|
22919
|
+
var FrontDoorStatusOutputSchema = import_zod38.z.strictObject({
|
|
22587
22920
|
state: FrontDoorStateSchema,
|
|
22588
|
-
supervisorAlive:
|
|
22921
|
+
supervisorAlive: import_zod38.z.boolean(),
|
|
22589
22922
|
/** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
|
|
22590
|
-
draining:
|
|
22591
|
-
sessions:
|
|
22923
|
+
draining: import_zod38.z.readonly(import_zod38.z.array(import_zod38.z.number().int().positive())),
|
|
22924
|
+
sessions: import_zod38.z.readonly(import_zod38.z.array(FrontDoorSessionStatusSchema)),
|
|
22592
22925
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
22593
|
-
logPath:
|
|
22594
|
-
logExists:
|
|
22926
|
+
logPath: import_zod38.z.string(),
|
|
22927
|
+
logExists: import_zod38.z.boolean()
|
|
22595
22928
|
});
|
|
22596
|
-
var FrontDoorSessionsOutputSchema =
|
|
22929
|
+
var FrontDoorSessionsOutputSchema = import_zod38.z.strictObject({ sessions: import_zod38.z.readonly(import_zod38.z.array(FrontDoorSessionStatusSchema)) });
|
|
22597
22930
|
var DOOR_REPORT_ENVIRONMENT_NOTE = "The report is collected in a worker thread of the door under the door's own environment and PATH, as a launch the door plans for itself would inherit them, not under the caller's shell: the identity is the caller's to name, the cascade is read from files at the path, and the environment-driven findings (AGENT_SHIM_IDENTITY, AGENT_SHIM_CONFIG_PROFILE, the Claude Code version pin, the ambient-credential check, and for doctor the PATH and shim findings) describe the door's launch. Run agent-shim check or agent-shim doctor from a shell for the caller's own reading.";
|
|
22598
|
-
var CheckRunInputSchema =
|
|
22599
|
-
path:
|
|
22600
|
-
identity:
|
|
22601
|
-
}).refine((input) =>
|
|
22602
|
-
var PoolPickInputSchema =
|
|
22603
|
-
pool:
|
|
22604
|
-
path:
|
|
22605
|
-
}).refine((input) =>
|
|
22606
|
-
var DoctorFindingSchema =
|
|
22607
|
-
section:
|
|
22608
|
-
subject:
|
|
22609
|
-
severity:
|
|
22610
|
-
message:
|
|
22931
|
+
var CheckRunInputSchema = import_zod38.z.strictObject({
|
|
22932
|
+
path: import_zod38.z.string().min(1),
|
|
22933
|
+
identity: import_zod38.z.string().min(1).optional()
|
|
22934
|
+
}).refine((input) => import_node_path44.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22935
|
+
var PoolPickInputSchema = import_zod38.z.strictObject({
|
|
22936
|
+
pool: import_zod38.z.string().min(1),
|
|
22937
|
+
path: import_zod38.z.string().min(1)
|
|
22938
|
+
}).refine((input) => import_node_path44.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22939
|
+
var DoctorFindingSchema = import_zod38.z.strictObject({
|
|
22940
|
+
section: import_zod38.z.enum(DOCTOR_SECTIONS),
|
|
22941
|
+
subject: import_zod38.z.string().optional(),
|
|
22942
|
+
severity: import_zod38.z.enum(DOCTOR_SEVERITIES),
|
|
22943
|
+
message: import_zod38.z.string()
|
|
22611
22944
|
});
|
|
22612
|
-
var DoctorRunOutputSchema =
|
|
22945
|
+
var DoctorRunOutputSchema = import_zod38.z.strictObject({
|
|
22613
22946
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
22614
|
-
ok:
|
|
22615
|
-
findings:
|
|
22947
|
+
ok: import_zod38.z.boolean(),
|
|
22948
|
+
findings: import_zod38.z.readonly(import_zod38.z.array(DoctorFindingSchema))
|
|
22616
22949
|
});
|
|
22617
|
-
var FrontDoorRestartOutputSchema =
|
|
22618
|
-
action:
|
|
22619
|
-
previousPid:
|
|
22950
|
+
var FrontDoorRestartOutputSchema = import_zod38.z.strictObject({
|
|
22951
|
+
action: import_zod38.z.literal("restarting"),
|
|
22952
|
+
previousPid: import_zod38.z.int().positive()
|
|
22620
22953
|
});
|
|
22621
|
-
var UpdateCheckOutputSchema =
|
|
22622
|
-
current:
|
|
22623
|
-
latest:
|
|
22624
|
-
action:
|
|
22954
|
+
var UpdateCheckOutputSchema = import_zod38.z.strictObject({
|
|
22955
|
+
current: import_zod38.z.string(),
|
|
22956
|
+
latest: import_zod38.z.string(),
|
|
22957
|
+
action: import_zod38.z.enum(["current", "available", "updated"])
|
|
22625
22958
|
});
|
|
22626
|
-
var CodexSignInSchema =
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22959
|
+
var CodexSignInSchema = import_zod38.z.discriminatedUnion("state", [
|
|
22960
|
+
import_zod38.z.strictObject({ state: import_zod38.z.literal("none") }),
|
|
22961
|
+
import_zod38.z.strictObject({ state: import_zod38.z.literal("signed-in"), email: import_zod38.z.string().optional(), planScope: import_zod38.z.boolean(), accessTokenExpiresAt: import_zod38.z.number() }),
|
|
22962
|
+
import_zod38.z.strictObject({ state: import_zod38.z.literal("unreadable"), message: import_zod38.z.string() })
|
|
22630
22963
|
]);
|
|
22631
|
-
var CodexStatusOutputSchema =
|
|
22964
|
+
var CodexStatusOutputSchema = import_zod38.z.strictObject({
|
|
22632
22965
|
signIn: CodexSignInSchema,
|
|
22633
|
-
codexProviders:
|
|
22966
|
+
codexProviders: import_zod38.z.readonly(import_zod38.z.array(import_zod38.z.string()))
|
|
22634
22967
|
});
|
|
22635
|
-
var CodexLogoutOutputSchema =
|
|
22636
|
-
hadGrant:
|
|
22637
|
-
revoked:
|
|
22968
|
+
var CodexLogoutOutputSchema = import_zod38.z.strictObject({
|
|
22969
|
+
hadGrant: import_zod38.z.boolean(),
|
|
22970
|
+
revoked: import_zod38.z.boolean()
|
|
22638
22971
|
});
|
|
22639
22972
|
|
|
22640
22973
|
// src/frontdoor/codexApi.ts
|
|
@@ -22655,20 +22988,21 @@ function createCodexApiRouter(deps) {
|
|
|
22655
22988
|
|
|
22656
22989
|
// src/frontdoor/doorWorker.ts
|
|
22657
22990
|
var import_node_sea2 = require("node:sea");
|
|
22658
|
-
var
|
|
22991
|
+
var import_zod40 = require("zod");
|
|
22659
22992
|
init_cliError();
|
|
22660
22993
|
init_doorBounds();
|
|
22661
22994
|
init_providerCatalogue();
|
|
22662
22995
|
|
|
22663
22996
|
// src/frontdoor/doorWorkerProtocol.ts
|
|
22664
|
-
var
|
|
22997
|
+
var import_zod39 = require("zod");
|
|
22998
|
+
init_providerCatalogue();
|
|
22665
22999
|
var doorWorkerInputSchemas = {
|
|
22666
23000
|
/** `agent-shim check` for `path` as `identity` (the identity a launch there would resolve when absent). */
|
|
22667
|
-
check:
|
|
23001
|
+
check: import_zod39.z.strictObject({ root: import_zod39.z.string().min(1), path: import_zod39.z.string().min(1), identity: import_zod39.z.string().min(1).optional() }),
|
|
22668
23002
|
/** `agent-shim doctor`. */
|
|
22669
|
-
doctor:
|
|
23003
|
+
doctor: import_zod39.z.strictObject({ root: import_zod39.z.string().min(1) }),
|
|
22670
23004
|
/** Fetch and store one provider's model catalogue for the door generation that asked. */
|
|
22671
|
-
"refresh-catalogue":
|
|
23005
|
+
"refresh-catalogue": import_zod39.z.strictObject({ root: import_zod39.z.string().min(1), name: import_zod39.z.string().min(1), supervisorPid: import_zod39.z.int().positive(), generation: import_zod39.z.uuid() })
|
|
22672
23006
|
};
|
|
22673
23007
|
|
|
22674
23008
|
// src/frontdoor/doorWorker.ts
|
|
@@ -22683,15 +23017,18 @@ var DoorWorkerBusyError = class extends CliError {
|
|
|
22683
23017
|
var NEXT_STEP = {
|
|
22684
23018
|
check: "run `agent-shim check` from a shell for the detail",
|
|
22685
23019
|
doctor: "run `agent-shim doctor` from a shell for the detail",
|
|
22686
|
-
"refresh-catalogue": "run `agent-shim provider models --refresh
|
|
23020
|
+
"refresh-catalogue": "run `agent-shim provider models <name> --refresh` from a shell for the detail"
|
|
22687
23021
|
};
|
|
22688
23022
|
var DoorWorkerFailedError = class extends CliError {
|
|
22689
|
-
constructor(task, reason, kind) {
|
|
23023
|
+
constructor(task, reason, kind, redirected = false) {
|
|
22690
23024
|
super(`${task} failed in its worker: ${reason}${task === "an unknown task" ? "" : `; ${NEXT_STEP[task]}`}`);
|
|
22691
23025
|
this.kind = kind;
|
|
22692
23026
|
this.name = "DoorWorkerFailedError";
|
|
23027
|
+
this.redirected = redirected;
|
|
22693
23028
|
}
|
|
22694
23029
|
kind;
|
|
23030
|
+
/** Whether the worker's error said a catalogue read met a redirect: the one fact of a worker's error that crosses the thread besides its class name and code. */
|
|
23031
|
+
redirected;
|
|
22695
23032
|
};
|
|
22696
23033
|
|
|
22697
23034
|
// src/frontdoor/configApi.ts
|
|
@@ -22748,79 +23085,79 @@ init_identityStore();
|
|
|
22748
23085
|
init_keychainLogin();
|
|
22749
23086
|
init_identityNamesLock();
|
|
22750
23087
|
init_lock();
|
|
22751
|
-
|
|
23088
|
+
init_identity2();
|
|
22752
23089
|
init_replayRun();
|
|
22753
23090
|
init_poolStore();
|
|
22754
23091
|
init_baseUrlDisplay();
|
|
22755
23092
|
init_providersStore();
|
|
22756
23093
|
|
|
22757
23094
|
// src/frontdoor/configSchemas.ts
|
|
22758
|
-
var
|
|
23095
|
+
var import_zod41 = require("zod");
|
|
22759
23096
|
init_schema();
|
|
22760
23097
|
init_names();
|
|
22761
23098
|
init_keychainLogin();
|
|
22762
23099
|
init_statusline();
|
|
22763
|
-
var RemovalConfirmationSchema =
|
|
22764
|
-
var CredentialWriteSchema = (targets) =>
|
|
22765
|
-
sources:
|
|
22766
|
-
target:
|
|
22767
|
-
cache:
|
|
23100
|
+
var RemovalConfirmationSchema = import_zod41.z.boolean();
|
|
23101
|
+
var CredentialWriteSchema = (targets) => import_zod41.z.strictObject({
|
|
23102
|
+
sources: import_zod41.z.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
23103
|
+
target: import_zod41.z.enum(targets).optional(),
|
|
23104
|
+
cache: import_zod41.z.union([import_zod41.z.literal(false), CredentialCacheSchema]).optional()
|
|
22768
23105
|
});
|
|
22769
|
-
var CredentialSummarySchema2 =
|
|
22770
|
-
target:
|
|
22771
|
-
sources:
|
|
22772
|
-
|
|
22773
|
-
|
|
22774
|
-
|
|
22775
|
-
|
|
22776
|
-
|
|
22777
|
-
|
|
22778
|
-
|
|
23106
|
+
var CredentialSummarySchema2 = import_zod41.z.strictObject({
|
|
23107
|
+
target: import_zod41.z.enum(CREDENTIAL_TARGETS),
|
|
23108
|
+
sources: import_zod41.z.readonly(import_zod41.z.array(
|
|
23109
|
+
import_zod41.z.discriminatedUnion("kind", [
|
|
23110
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("env"), variable: import_zod41.z.string() }),
|
|
23111
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("file"), path: import_zod41.z.string() }),
|
|
23112
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("command"), program: import_zod41.z.string() }),
|
|
23113
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("op"), reference: import_zod41.z.string() }),
|
|
23114
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("keychain"), service: import_zod41.z.string(), account: import_zod41.z.string().optional() }),
|
|
23115
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("literal") })
|
|
22779
23116
|
])
|
|
22780
23117
|
)),
|
|
22781
23118
|
cache: CredentialCacheSchema.optional()
|
|
22782
23119
|
});
|
|
22783
|
-
var mutationOutput = (kind, action) =>
|
|
22784
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
22785
|
-
var IdentityValueSchema =
|
|
22786
|
-
agent:
|
|
22787
|
-
name:
|
|
22788
|
-
label:
|
|
22789
|
-
defaultConfigProfile:
|
|
22790
|
-
provider:
|
|
22791
|
-
allowAmbientCredential:
|
|
23120
|
+
var mutationOutput = (kind, action) => import_zod41.z.strictObject({ action: import_zod41.z.literal(action), kind: import_zod41.z.literal(kind), name: import_zod41.z.string() });
|
|
23121
|
+
var storedMutationOutput = (kind, action, value) => import_zod41.z.strictObject({ action: import_zod41.z.literal(action), kind: import_zod41.z.literal(kind), name: import_zod41.z.string(), value });
|
|
23122
|
+
var IdentityValueSchema = import_zod41.z.strictObject({
|
|
23123
|
+
agent: import_zod41.z.enum(["claude", "codex"]).optional(),
|
|
23124
|
+
name: import_zod41.z.string(),
|
|
23125
|
+
label: import_zod41.z.string().optional(),
|
|
23126
|
+
defaultConfigProfile: import_zod41.z.string().optional(),
|
|
23127
|
+
provider: import_zod41.z.string().optional(),
|
|
23128
|
+
allowAmbientCredential: import_zod41.z.boolean(),
|
|
22792
23129
|
credential: CredentialSummarySchema2.optional(),
|
|
22793
|
-
anchors:
|
|
23130
|
+
anchors: import_zod41.z.array(AnchorSchema).optional()
|
|
22794
23131
|
});
|
|
22795
23132
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
22796
|
-
var ProviderValueSchema =
|
|
22797
|
-
name:
|
|
22798
|
-
kind:
|
|
22799
|
-
displayName:
|
|
22800
|
-
baseUrl:
|
|
23133
|
+
var ProviderValueSchema = import_zod41.z.strictObject({
|
|
23134
|
+
name: import_zod41.z.string(),
|
|
23135
|
+
kind: import_zod41.z.enum(PROVIDER_KINDS),
|
|
23136
|
+
displayName: import_zod41.z.string(),
|
|
23137
|
+
baseUrl: import_zod41.z.string().optional(),
|
|
22801
23138
|
codex: CodexProviderConfigSchema.optional(),
|
|
22802
23139
|
credential: CredentialSummarySchema2.optional(),
|
|
22803
|
-
env:
|
|
23140
|
+
env: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.string()).optional()
|
|
22804
23141
|
});
|
|
22805
|
-
var ConfigNameInputSchema =
|
|
22806
|
-
var ConfigIdentityAddInputSchema =
|
|
23142
|
+
var ConfigNameInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1) });
|
|
23143
|
+
var ConfigIdentityAddInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), keepKeychainLogin: import_zod41.z.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
|
|
22807
23144
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
22808
|
-
var ConfigIdentitySetInputSchema =
|
|
22809
|
-
name:
|
|
23145
|
+
var ConfigIdentitySetInputSchema = import_zod41.z.strictObject({
|
|
23146
|
+
name: import_zod41.z.string().min(1),
|
|
22810
23147
|
/** The identity's display label; `false` clears it. */
|
|
22811
|
-
label:
|
|
22812
|
-
defaultConfigProfile:
|
|
23148
|
+
label: import_zod41.z.union([IdentityLabelSchema, import_zod41.z.literal(false)]).optional(),
|
|
23149
|
+
defaultConfigProfile: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
22813
23150
|
/** The provider the identity exists for; `false` clears it. */
|
|
22814
|
-
provider:
|
|
22815
|
-
allowAmbientCredential:
|
|
22816
|
-
credential:
|
|
23151
|
+
provider: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
23152
|
+
allowAmbientCredential: import_zod41.z.boolean().optional(),
|
|
23153
|
+
credential: import_zod41.z.union([import_zod41.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
22817
23154
|
/** `false` removes the anchors; a list replaces them. */
|
|
22818
|
-
anchors:
|
|
23155
|
+
anchors: import_zod41.z.union([import_zod41.z.literal(false), import_zod41.z.array(AnchorSchema).min(1)]).optional()
|
|
22819
23156
|
});
|
|
22820
23157
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
22821
|
-
var ConfigIdentityRemoveInputSchema =
|
|
23158
|
+
var ConfigIdentityRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22822
23159
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
22823
|
-
var ConfigStatuslineSetSchema =
|
|
23160
|
+
var ConfigStatuslineSetSchema = import_zod41.z.record(import_zod41.z.string(), import_zod41.z.unknown()).superRefine((settings, context) => {
|
|
22824
23161
|
for (const key of Object.keys(settings)) {
|
|
22825
23162
|
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
22826
23163
|
context.addIssue({ code: "custom", path: [key], message: `a config write through the API cannot set "${key}": the extra segment's command runs a program, so only your own configuration (the global config, a profile you edit yourself, a directory rule or a command-line assignment) may set it` });
|
|
@@ -22828,93 +23165,93 @@ var ConfigStatuslineSetSchema = import_zod40.z.record(import_zod40.z.string(), i
|
|
|
22828
23165
|
}
|
|
22829
23166
|
});
|
|
22830
23167
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
22831
|
-
var ConfigProfileAddInputSchema =
|
|
22832
|
-
name:
|
|
22833
|
-
extends:
|
|
22834
|
-
description:
|
|
23168
|
+
var ConfigProfileAddInputSchema = import_zod41.z.strictObject({
|
|
23169
|
+
name: import_zod41.z.string().min(1),
|
|
23170
|
+
extends: import_zod41.z.array(import_zod41.z.string().min(1)).optional(),
|
|
23171
|
+
description: import_zod41.z.string().optional()
|
|
22835
23172
|
});
|
|
22836
23173
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
22837
|
-
var ConfigProfileSetInputSchema =
|
|
22838
|
-
name:
|
|
22839
|
-
category:
|
|
22840
|
-
entry:
|
|
22841
|
-
extends:
|
|
22842
|
-
description:
|
|
22843
|
-
launch:
|
|
22844
|
-
skipPermissions:
|
|
22845
|
-
remoteControl:
|
|
22846
|
-
headroom:
|
|
22847
|
-
trackUsage:
|
|
22848
|
-
provider:
|
|
22849
|
-
claudeVersion:
|
|
22850
|
-
delay:
|
|
22851
|
-
pause:
|
|
22852
|
-
explain:
|
|
22853
|
-
proxyBypass:
|
|
22854
|
-
statusline:
|
|
23174
|
+
var ConfigProfileSetInputSchema = import_zod41.z.strictObject({
|
|
23175
|
+
name: import_zod41.z.string().min(1),
|
|
23176
|
+
category: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.boolean()).optional(),
|
|
23177
|
+
entry: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.boolean()).optional(),
|
|
23178
|
+
extends: import_zod41.z.union([import_zod41.z.array(import_zod41.z.string().min(1)), import_zod41.z.literal(false)]).optional(),
|
|
23179
|
+
description: import_zod41.z.union([import_zod41.z.string(), import_zod41.z.literal(false)]).optional(),
|
|
23180
|
+
launch: import_zod41.z.strictObject({
|
|
23181
|
+
skipPermissions: import_zod41.z.boolean().optional(),
|
|
23182
|
+
remoteControl: import_zod41.z.boolean().optional(),
|
|
23183
|
+
headroom: import_zod41.z.boolean().optional(),
|
|
23184
|
+
trackUsage: import_zod41.z.boolean().optional(),
|
|
23185
|
+
provider: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
23186
|
+
claudeVersion: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
23187
|
+
delay: import_zod41.z.union([import_zod41.z.string().regex(DURATION_RE), import_zod41.z.literal(false)]).optional(),
|
|
23188
|
+
pause: import_zod41.z.boolean().optional(),
|
|
23189
|
+
explain: import_zod41.z.boolean().optional(),
|
|
23190
|
+
proxyBypass: import_zod41.z.union([import_zod41.z.array(import_zod41.z.string().min(1)), import_zod41.z.literal(false)]).optional(),
|
|
23191
|
+
statusline: import_zod41.z.strictObject({
|
|
22855
23192
|
set: ConfigStatuslineSetSchema.optional(),
|
|
22856
|
-
unset:
|
|
23193
|
+
unset: import_zod41.z.array(import_zod41.z.string()).optional()
|
|
22857
23194
|
}).optional()
|
|
22858
23195
|
}).optional()
|
|
22859
23196
|
});
|
|
22860
23197
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
22861
|
-
var ConfigProfileRemoveInputSchema =
|
|
23198
|
+
var ConfigProfileRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22862
23199
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
22863
23200
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
22864
|
-
var PoolMembersInputSchema =
|
|
22865
|
-
var ConfigPoolAddInputSchema =
|
|
22866
|
-
name:
|
|
23201
|
+
var PoolMembersInputSchema = import_zod41.z.array(import_zod41.z.string().min(1)).min(1);
|
|
23202
|
+
var ConfigPoolAddInputSchema = import_zod41.z.strictObject({
|
|
23203
|
+
name: import_zod41.z.string().min(1),
|
|
22867
23204
|
identities: PoolMembersInputSchema,
|
|
22868
|
-
preference:
|
|
22869
|
-
resumeOnLimit:
|
|
22870
|
-
compactBeforeLimit:
|
|
23205
|
+
preference: import_zod41.z.enum(POOL_PREFERENCES).optional(),
|
|
23206
|
+
resumeOnLimit: import_zod41.z.boolean().optional(),
|
|
23207
|
+
compactBeforeLimit: import_zod41.z.boolean().optional(),
|
|
22871
23208
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
22872
23209
|
});
|
|
22873
23210
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
22874
|
-
var ConfigPoolSetInputSchema =
|
|
22875
|
-
name:
|
|
23211
|
+
var ConfigPoolSetInputSchema = import_zod41.z.strictObject({
|
|
23212
|
+
name: import_zod41.z.string().min(1),
|
|
22876
23213
|
identities: PoolMembersInputSchema.optional(),
|
|
22877
|
-
preference:
|
|
22878
|
-
resumeOnLimit:
|
|
22879
|
-
compactBeforeLimit:
|
|
22880
|
-
compactAtUtilisation:
|
|
23214
|
+
preference: import_zod41.z.union([import_zod41.z.enum(POOL_PREFERENCES), import_zod41.z.literal(false)]).optional(),
|
|
23215
|
+
resumeOnLimit: import_zod41.z.boolean().optional(),
|
|
23216
|
+
compactBeforeLimit: import_zod41.z.boolean().optional(),
|
|
23217
|
+
compactAtUtilisation: import_zod41.z.union([CompactAtUtilisationSchema, import_zod41.z.literal(false)]).optional()
|
|
22881
23218
|
});
|
|
22882
23219
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
22883
|
-
var ConfigPoolRemoveInputSchema =
|
|
23220
|
+
var ConfigPoolRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22884
23221
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
22885
23222
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
22886
|
-
var ConfigProviderAddInputSchema =
|
|
22887
|
-
name:
|
|
22888
|
-
kind:
|
|
22889
|
-
displayName:
|
|
22890
|
-
baseUrl:
|
|
23223
|
+
var ConfigProviderAddInputSchema = import_zod41.z.strictObject({
|
|
23224
|
+
name: import_zod41.z.string().min(1),
|
|
23225
|
+
kind: import_zod41.z.enum(PROVIDER_KINDS).optional(),
|
|
23226
|
+
displayName: import_zod41.z.string().min(1),
|
|
23227
|
+
baseUrl: import_zod41.z.string().min(1).optional(),
|
|
22891
23228
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
22892
23229
|
codex: CodexProviderConfigSchema.optional()
|
|
22893
23230
|
});
|
|
22894
23231
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
22895
|
-
var ConfigProviderSetInputSchema =
|
|
22896
|
-
name:
|
|
22897
|
-
displayName:
|
|
22898
|
-
baseUrl:
|
|
23232
|
+
var ConfigProviderSetInputSchema = import_zod41.z.strictObject({
|
|
23233
|
+
name: import_zod41.z.string().min(1),
|
|
23234
|
+
displayName: import_zod41.z.string().min(1).optional(),
|
|
23235
|
+
baseUrl: import_zod41.z.string().min(1).optional(),
|
|
22899
23236
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
22900
23237
|
codex: CodexProviderConfigSchema.optional()
|
|
22901
23238
|
});
|
|
22902
23239
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
22903
|
-
var ConfigProviderRemoveInputSchema =
|
|
23240
|
+
var ConfigProviderRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22904
23241
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
22905
|
-
var ConfigRuleAddInputSchema =
|
|
22906
|
-
path:
|
|
22907
|
-
configProfile:
|
|
22908
|
-
identity:
|
|
23242
|
+
var ConfigRuleAddInputSchema = import_zod41.z.strictObject({
|
|
23243
|
+
path: import_zod41.z.string().min(1),
|
|
23244
|
+
configProfile: import_zod41.z.string().min(1).optional(),
|
|
23245
|
+
identity: import_zod41.z.string().min(1).optional()
|
|
22909
23246
|
});
|
|
22910
23247
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
22911
|
-
var ConfigRuleSetInputSchema =
|
|
22912
|
-
path:
|
|
22913
|
-
configProfile:
|
|
22914
|
-
identity:
|
|
23248
|
+
var ConfigRuleSetInputSchema = import_zod41.z.strictObject({
|
|
23249
|
+
path: import_zod41.z.string().min(1),
|
|
23250
|
+
configProfile: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
23251
|
+
identity: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional()
|
|
22915
23252
|
});
|
|
22916
23253
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
22917
|
-
var ConfigRuleRemoveInputSchema =
|
|
23254
|
+
var ConfigRuleRemoveInputSchema = import_zod41.z.strictObject({ path: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22918
23255
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
22919
23256
|
|
|
22920
23257
|
// src/frontdoor/configApi.ts
|
|
@@ -22988,7 +23325,7 @@ function profileValue(name, paths) {
|
|
|
22988
23325
|
function createConfigApiRouter(deps) {
|
|
22989
23326
|
const authed = doorApiAuth(deps.expectedToken);
|
|
22990
23327
|
const { paths } = deps;
|
|
22991
|
-
const route = (
|
|
23328
|
+
const route = (path56, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path56, summary, tags: [CONFIG_API_TAG] }));
|
|
22992
23329
|
return {
|
|
22993
23330
|
config: {
|
|
22994
23331
|
identity: {
|
|
@@ -23258,51 +23595,51 @@ var import_openapi4 = require("@orpc/openapi");
|
|
|
23258
23595
|
var import_server3 = require("@orpc/server");
|
|
23259
23596
|
|
|
23260
23597
|
// src/frontdoor/eventSchemas.ts
|
|
23261
|
-
var
|
|
23598
|
+
var import_zod42 = require("zod");
|
|
23262
23599
|
init_schema2();
|
|
23263
23600
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
23264
23601
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
23265
23602
|
var USAGE_EVENT_SOURCE = "usage";
|
|
23266
23603
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
23267
23604
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
23268
|
-
var DoorEventSchema =
|
|
23269
|
-
source:
|
|
23605
|
+
var DoorEventSchema = import_zod42.z.strictObject({
|
|
23606
|
+
source: import_zod42.z.string().min(1),
|
|
23270
23607
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
23271
|
-
sequence:
|
|
23272
|
-
payload:
|
|
23608
|
+
sequence: import_zod42.z.number().int().positive(),
|
|
23609
|
+
payload: import_zod42.z.unknown()
|
|
23273
23610
|
});
|
|
23274
|
-
var DoorEventSourceQuerySchema =
|
|
23275
|
-
sources:
|
|
23611
|
+
var DoorEventSourceQuerySchema = import_zod42.z.strictObject({
|
|
23612
|
+
sources: import_zod42.z.array(import_zod42.z.string().min(1)).min(1).optional()
|
|
23276
23613
|
});
|
|
23277
|
-
var LaunchLifecycleEventSchema =
|
|
23278
|
-
kind:
|
|
23279
|
-
pid:
|
|
23280
|
-
startedAt:
|
|
23281
|
-
observedAt:
|
|
23614
|
+
var LaunchLifecycleEventSchema = import_zod42.z.strictObject({
|
|
23615
|
+
kind: import_zod42.z.enum(["registered", "pruned", "ended"]),
|
|
23616
|
+
pid: import_zod42.z.number().int().positive(),
|
|
23617
|
+
startedAt: import_zod42.z.number(),
|
|
23618
|
+
observedAt: import_zod42.z.number()
|
|
23282
23619
|
});
|
|
23283
|
-
var DoorHealthEventSchema =
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23620
|
+
var DoorHealthEventSchema = import_zod42.z.discriminatedUnion("kind", [
|
|
23621
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("generation"), pid: import_zod42.z.number().int().positive(), providerPort: import_zod42.z.number().int().positive(), connectPort: import_zod42.z.number().int().positive(), directPort: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
|
|
23622
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("listenerFailed"), pid: import_zod42.z.number().int().positive(), listener: import_zod42.z.enum(["provider", "connect", "direct"]), message: import_zod42.z.string(), observedAt: import_zod42.z.number() }),
|
|
23623
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("binaryTurnover"), pid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
|
|
23624
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("idleShutdown"), pid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
|
|
23625
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("superseded"), pid: import_zod42.z.number().int().positive(), ownerPid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
|
|
23626
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("drained"), pid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() })
|
|
23290
23627
|
]);
|
|
23291
|
-
var QuotaExpiringEventSchema =
|
|
23628
|
+
var QuotaExpiringEventSchema = import_zod42.z.strictObject({
|
|
23292
23629
|
/** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
|
|
23293
|
-
id:
|
|
23630
|
+
id: import_zod42.z.string().min(1),
|
|
23294
23631
|
/** The identity's name when the event was published, absent for an identity no longer stored under the id. */
|
|
23295
|
-
name:
|
|
23296
|
-
provider:
|
|
23297
|
-
window:
|
|
23632
|
+
name: import_zod42.z.string().min(1).optional(),
|
|
23633
|
+
provider: import_zod42.z.string().min(1),
|
|
23634
|
+
window: import_zod42.z.enum(["fiveHour", "sevenDay"]),
|
|
23298
23635
|
/** The fraction of the window already used when it was seen expiring, always below one because a fully used window has nothing left to spend. */
|
|
23299
|
-
utilization:
|
|
23300
|
-
resetsAt:
|
|
23301
|
-
observedAt:
|
|
23636
|
+
utilization: import_zod42.z.number().min(0).max(1),
|
|
23637
|
+
resetsAt: import_zod42.z.iso.datetime(),
|
|
23638
|
+
observedAt: import_zod42.z.number()
|
|
23302
23639
|
});
|
|
23303
23640
|
var UsageChangeEventSchema = UsageSnapshotSchema.extend({
|
|
23304
|
-
id:
|
|
23305
|
-
name:
|
|
23641
|
+
id: import_zod42.z.string().min(1),
|
|
23642
|
+
name: import_zod42.z.string().min(1).optional()
|
|
23306
23643
|
});
|
|
23307
23644
|
|
|
23308
23645
|
// src/frontdoor/eventsApi.ts
|
|
@@ -23346,7 +23683,7 @@ function createEventsApiRouter(deps) {
|
|
|
23346
23683
|
// src/frontdoor/lifecycleApi.ts
|
|
23347
23684
|
var import_client4 = require("@orpc/client");
|
|
23348
23685
|
var import_openapi5 = require("@orpc/openapi");
|
|
23349
|
-
var
|
|
23686
|
+
var import_zod43 = require("zod");
|
|
23350
23687
|
init_update();
|
|
23351
23688
|
var FRONTDOOR_API_TAG = "frontdoor";
|
|
23352
23689
|
var UPDATE_API_TAG = "update";
|
|
@@ -23354,7 +23691,7 @@ function createLifecycleApiRouter(deps) {
|
|
|
23354
23691
|
const authed = doorApiAuth(deps.expectedToken);
|
|
23355
23692
|
return {
|
|
23356
23693
|
frontdoor: {
|
|
23357
|
-
refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(
|
|
23694
|
+
refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(import_zod43.z.strictObject({ requested: import_zod43.z.literal(true) })).handler(() => {
|
|
23358
23695
|
deps.refreshCatalogues();
|
|
23359
23696
|
return { requested: true };
|
|
23360
23697
|
}),
|
|
@@ -23390,65 +23727,65 @@ var import_openapi6 = require("@orpc/openapi");
|
|
|
23390
23727
|
init_cliError();
|
|
23391
23728
|
|
|
23392
23729
|
// src/frontdoor/launchSchemas.ts
|
|
23393
|
-
var
|
|
23394
|
-
var
|
|
23730
|
+
var import_node_path45 = __toESM(require("node:path"), 1);
|
|
23731
|
+
var import_zod44 = require("zod");
|
|
23395
23732
|
init_statusline();
|
|
23396
23733
|
init_claudeVersion();
|
|
23397
|
-
|
|
23398
|
-
var LaunchResolveInputSchema =
|
|
23399
|
-
path:
|
|
23734
|
+
init_identity2();
|
|
23735
|
+
var LaunchResolveInputSchema = import_zod44.z.strictObject({
|
|
23736
|
+
path: import_zod44.z.string().min(1),
|
|
23400
23737
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
23401
|
-
argv:
|
|
23738
|
+
argv: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())).optional(),
|
|
23402
23739
|
/** 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. */
|
|
23403
|
-
env:
|
|
23404
|
-
}).refine((input) =>
|
|
23405
|
-
var LaunchPoolDecisionSchema =
|
|
23406
|
-
name:
|
|
23407
|
-
reasons:
|
|
23740
|
+
env: import_zod44.z.record(import_zod44.z.string(), import_zod44.z.string()).optional()
|
|
23741
|
+
}).refine((input) => import_node_path45.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
23742
|
+
var LaunchPoolDecisionSchema = import_zod44.z.strictObject({
|
|
23743
|
+
name: import_zod44.z.string(),
|
|
23744
|
+
reasons: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())),
|
|
23408
23745
|
/** The provider the ranking read for the chosen member, when the launch spends one in place of the member's Claude account. */
|
|
23409
|
-
provider:
|
|
23410
|
-
movedOff:
|
|
23746
|
+
provider: import_zod44.z.string().optional(),
|
|
23747
|
+
movedOff: import_zod44.z.strictObject({ identity: import_zod44.z.string(), reason: import_zod44.z.string() }).optional()
|
|
23411
23748
|
});
|
|
23412
|
-
var LaunchDecisionSchema =
|
|
23413
|
-
identity:
|
|
23414
|
-
identityId:
|
|
23415
|
-
identitySource:
|
|
23749
|
+
var LaunchDecisionSchema = import_zod44.z.strictObject({
|
|
23750
|
+
identity: import_zod44.z.string().optional(),
|
|
23751
|
+
identityId: import_zod44.z.string().optional(),
|
|
23752
|
+
identitySource: import_zod44.z.enum(IDENTITY_DECISION_SOURCES),
|
|
23416
23753
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
23417
23754
|
/** True when `CLAUDE_CONFIG_DIR` was already set and nothing on the command line named an identity; an identity named there outranks the variable and leaves it false. */
|
|
23418
|
-
configDirEscapeHatch:
|
|
23419
|
-
configDir:
|
|
23420
|
-
configProfile:
|
|
23421
|
-
configProfileSource:
|
|
23422
|
-
provider:
|
|
23755
|
+
configDirEscapeHatch: import_zod44.z.boolean(),
|
|
23756
|
+
configDir: import_zod44.z.string().optional(),
|
|
23757
|
+
configProfile: import_zod44.z.string().optional(),
|
|
23758
|
+
configProfileSource: import_zod44.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
23759
|
+
provider: import_zod44.z.string().optional()
|
|
23423
23760
|
});
|
|
23424
|
-
var LaunchFlagsSchema =
|
|
23425
|
-
skipPermissions:
|
|
23426
|
-
remoteControl:
|
|
23427
|
-
headroom:
|
|
23428
|
-
trackUsage:
|
|
23429
|
-
pause:
|
|
23430
|
-
explain:
|
|
23761
|
+
var LaunchFlagsSchema = import_zod44.z.strictObject({
|
|
23762
|
+
skipPermissions: import_zod44.z.boolean(),
|
|
23763
|
+
remoteControl: import_zod44.z.boolean(),
|
|
23764
|
+
headroom: import_zod44.z.boolean(),
|
|
23765
|
+
trackUsage: import_zod44.z.boolean(),
|
|
23766
|
+
pause: import_zod44.z.boolean(),
|
|
23767
|
+
explain: import_zod44.z.boolean(),
|
|
23431
23768
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
23432
|
-
delayMs:
|
|
23769
|
+
delayMs: import_zod44.z.number(),
|
|
23433
23770
|
/** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
|
|
23434
|
-
proxyBypass:
|
|
23771
|
+
proxyBypass: import_zod44.z.array(import_zod44.z.string()).readonly(),
|
|
23435
23772
|
/** How the session's built-in statusline looks, when the launch configures any of it. */
|
|
23436
23773
|
statusline: StatuslineSchema.optional()
|
|
23437
23774
|
});
|
|
23438
|
-
var LaunchResolveOutputSchema =
|
|
23775
|
+
var LaunchResolveOutputSchema = import_zod44.z.strictObject({
|
|
23439
23776
|
decision: LaunchDecisionSchema,
|
|
23440
23777
|
flags: LaunchFlagsSchema,
|
|
23441
|
-
claudeVersion:
|
|
23778
|
+
claudeVersion: import_zod44.z.strictObject({ version: import_zod44.z.string(), source: import_zod44.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
23442
23779
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
23443
|
-
bin:
|
|
23780
|
+
bin: import_zod44.z.string(),
|
|
23444
23781
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
23445
|
-
args:
|
|
23782
|
+
args: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())),
|
|
23446
23783
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
23447
|
-
credential:
|
|
23448
|
-
routing:
|
|
23784
|
+
credential: import_zod44.z.strictObject({ subject: import_zod44.z.enum(["provider", "identity"]), name: import_zod44.z.string(), summary: CredentialSummarySchema }).optional(),
|
|
23785
|
+
routing: import_zod44.z.strictObject({ frontDoor: import_zod44.z.boolean(), headroom: import_zod44.z.boolean() }),
|
|
23449
23786
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
23450
|
-
environment:
|
|
23451
|
-
warnings:
|
|
23787
|
+
environment: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())),
|
|
23788
|
+
warnings: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string()))
|
|
23452
23789
|
});
|
|
23453
23790
|
|
|
23454
23791
|
// src/frontdoor/launchApi.ts
|
|
@@ -23484,24 +23821,24 @@ function createLaunchApiRouter(deps) {
|
|
|
23484
23821
|
// src/frontdoor/agentTreesApi.ts
|
|
23485
23822
|
var import_client6 = require("@orpc/client");
|
|
23486
23823
|
var import_openapi7 = require("@orpc/openapi");
|
|
23487
|
-
var
|
|
23824
|
+
var import_zod45 = require("zod");
|
|
23488
23825
|
init_liveTasks();
|
|
23489
23826
|
init_schema3();
|
|
23490
23827
|
init_cliError();
|
|
23491
|
-
var AgentTreesListInputSchema =
|
|
23828
|
+
var AgentTreesListInputSchema = import_zod45.z.strictObject({
|
|
23492
23829
|
/** Only this identity's sessions. */
|
|
23493
|
-
identity:
|
|
23830
|
+
identity: import_zod45.z.string().optional(),
|
|
23494
23831
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
23495
|
-
all:
|
|
23832
|
+
all: import_zod45.z.boolean().optional()
|
|
23496
23833
|
});
|
|
23497
|
-
var AgentTreesListOutputSchema =
|
|
23498
|
-
var AgentTreesShowInputSchema =
|
|
23834
|
+
var AgentTreesListOutputSchema = import_zod45.z.array(SessionSummarySchema);
|
|
23835
|
+
var AgentTreesShowInputSchema = import_zod45.z.strictObject({
|
|
23499
23836
|
/** A session id, or an unambiguous prefix of one. */
|
|
23500
|
-
session:
|
|
23837
|
+
session: import_zod45.z.string().min(1),
|
|
23501
23838
|
/** Look only in this identity. */
|
|
23502
|
-
identity:
|
|
23839
|
+
identity: import_zod45.z.string().optional()
|
|
23503
23840
|
});
|
|
23504
|
-
var AgentTreesShowOutputSchema =
|
|
23841
|
+
var AgentTreesShowOutputSchema = import_zod45.z.strictObject({ identities: import_zod45.z.array(import_zod45.z.string()), ...MergedAgentTreeSchema.shape });
|
|
23505
23842
|
function asBadRequest(error) {
|
|
23506
23843
|
if (error instanceof CliError) {
|
|
23507
23844
|
throw new import_client6.ORPCError("BAD_REQUEST", { message: error.message });
|
|
@@ -23554,7 +23891,7 @@ var import_openapi8 = require("@orpc/openapi");
|
|
|
23554
23891
|
var import_server4 = require("@orpc/server");
|
|
23555
23892
|
|
|
23556
23893
|
// src/frontdoor/rcEventLog.ts
|
|
23557
|
-
var
|
|
23894
|
+
var import_zod46 = require("zod");
|
|
23558
23895
|
|
|
23559
23896
|
// src/frontdoor/eventHub.ts
|
|
23560
23897
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -23679,46 +24016,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
|
23679
24016
|
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
23680
24017
|
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
23681
24018
|
var RC_PENDING_RETIRE_REASONS = ["answered", "withdrawn", "worker-stopped", "session-ended"];
|
|
23682
|
-
var transitionBase = { session:
|
|
23683
|
-
var cursorFields = { cursor:
|
|
23684
|
-
var sessionAppearedShape = { kind:
|
|
23685
|
-
var sessionEndedShape = { kind:
|
|
23686
|
-
var workerStateShape = { kind:
|
|
23687
|
-
var pendingBornShape = { kind:
|
|
23688
|
-
var pendingRetiredShape = { kind:
|
|
23689
|
-
var RcSessionTransitionSchema =
|
|
23690
|
-
|
|
23691
|
-
|
|
23692
|
-
|
|
23693
|
-
|
|
23694
|
-
|
|
24019
|
+
var transitionBase = { session: import_zod46.z.string(), at: import_zod46.z.number() };
|
|
24020
|
+
var cursorFields = { cursor: import_zod46.z.string(), sequence: import_zod46.z.int().positive() };
|
|
24021
|
+
var sessionAppearedShape = { kind: import_zod46.z.literal("session-appeared"), ...transitionBase };
|
|
24022
|
+
var sessionEndedShape = { kind: import_zod46.z.literal("session-ended"), reason: import_zod46.z.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
24023
|
+
var workerStateShape = { kind: import_zod46.z.literal("worker-state"), state: import_zod46.z.string(), previous: import_zod46.z.string().optional(), ...transitionBase };
|
|
24024
|
+
var pendingBornShape = { kind: import_zod46.z.literal("pending-born"), requestId: import_zod46.z.string(), type: import_zod46.z.string(), summary: import_zod46.z.string(), ...transitionBase };
|
|
24025
|
+
var pendingRetiredShape = { kind: import_zod46.z.literal("pending-retired"), requestId: import_zod46.z.string(), reason: import_zod46.z.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
24026
|
+
var RcSessionTransitionSchema = import_zod46.z.discriminatedUnion("kind", [
|
|
24027
|
+
import_zod46.z.strictObject(sessionAppearedShape),
|
|
24028
|
+
import_zod46.z.strictObject(sessionEndedShape),
|
|
24029
|
+
import_zod46.z.strictObject(workerStateShape),
|
|
24030
|
+
import_zod46.z.strictObject(pendingBornShape),
|
|
24031
|
+
import_zod46.z.strictObject(pendingRetiredShape)
|
|
23695
24032
|
]);
|
|
23696
24033
|
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
23697
24034
|
var RC_SESSION_EVENT_MAX_BYTES = (RC_SESSION_EVENT_GENERATION_MAX_CHARS + ".".length + SEQUENCE_MAX_DIGITS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + KIND_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_SUMMARY_MAX_CHARS) * BYTES_PER_CODE_UNIT + NUMBER_FIELDS * NUMBER_BYTES;
|
|
23698
24035
|
var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
|
|
23699
|
-
var RcSessionEventSchema =
|
|
23700
|
-
|
|
23701
|
-
|
|
23702
|
-
|
|
23703
|
-
|
|
23704
|
-
|
|
24036
|
+
var RcSessionEventSchema = import_zod46.z.discriminatedUnion("kind", [
|
|
24037
|
+
import_zod46.z.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
24038
|
+
import_zod46.z.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
24039
|
+
import_zod46.z.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
24040
|
+
import_zod46.z.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
24041
|
+
import_zod46.z.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
23705
24042
|
]);
|
|
23706
|
-
var RcSessionEventsReadInputSchema =
|
|
24043
|
+
var RcSessionEventsReadInputSchema = import_zod46.z.strictObject({
|
|
23707
24044
|
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
23708
|
-
since:
|
|
24045
|
+
since: import_zod46.z.string().min(1).optional(),
|
|
23709
24046
|
/** One `cse_` session id; every session when omitted. */
|
|
23710
|
-
session:
|
|
24047
|
+
session: import_zod46.z.string().min(1).optional(),
|
|
23711
24048
|
/** The most events one answer carries; every event after `since` when omitted. */
|
|
23712
|
-
limit:
|
|
24049
|
+
limit: import_zod46.z.int().positive().optional()
|
|
23713
24050
|
});
|
|
23714
24051
|
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
23715
24052
|
/** The most events this page carries: by default and at most, the bound the door's event backbone already holds per slow consumer (`DOOR_EVENT_BUFFER_EVENTS`, oRPC's own documented default for that case). A page lands whole in its reader, so a reader receives at most one consumer buffer's worth at a time (at worst `DOOR_EVENT_BUFFER_EVENTS` times `RC_SESSION_EVENT_MAX_BYTES`) and pages on with the cursor for more; a maximum of the whole window would let one page carry the log's entire memory budget into an agent's context. */
|
|
23716
|
-
limit:
|
|
24053
|
+
limit: import_zod46.z.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
23717
24054
|
});
|
|
23718
24055
|
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
23719
|
-
var RcSessionEventsReadOutputSchema =
|
|
23720
|
-
|
|
23721
|
-
|
|
24056
|
+
var RcSessionEventsReadOutputSchema = import_zod46.z.discriminatedUnion("status", [
|
|
24057
|
+
import_zod46.z.strictObject({ status: import_zod46.z.literal("ok"), events: import_zod46.z.readonly(import_zod46.z.array(RcSessionEventSchema)), cursor: import_zod46.z.string(), more: import_zod46.z.boolean(), head: import_zod46.z.string() }),
|
|
24058
|
+
import_zod46.z.strictObject({ status: import_zod46.z.literal("expired"), message: import_zod46.z.string(), head: import_zod46.z.string() })
|
|
23722
24059
|
]);
|
|
23723
24060
|
var CURSOR_SEPARATOR = ".";
|
|
23724
24061
|
var RESYNC_ADVICE = "cursor expired, resync from status: read `rc status` for every session's present state, then resume after the head this answer names";
|
|
@@ -25905,7 +26242,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25905
26242
|
}
|
|
25906
26243
|
|
|
25907
26244
|
// src/frontdoor/rcSelfHostMint.ts
|
|
25908
|
-
var
|
|
26245
|
+
var import_node_path46 = __toESM(require("node:path"), 1);
|
|
25909
26246
|
init_identityRecords();
|
|
25910
26247
|
init_account();
|
|
25911
26248
|
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
@@ -25931,7 +26268,7 @@ function readJsonObject(fs17, file) {
|
|
|
25931
26268
|
return isRecord16(parsed) ? parsed : void 0;
|
|
25932
26269
|
}
|
|
25933
26270
|
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
25934
|
-
const parsed = readJsonObject(fs17,
|
|
26271
|
+
const parsed = readJsonObject(fs17, import_node_path46.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
25935
26272
|
if (parsed === void 0) {
|
|
25936
26273
|
return void 0;
|
|
25937
26274
|
}
|
|
@@ -25949,11 +26286,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25949
26286
|
if (id === void 0) {
|
|
25950
26287
|
throw new Error(`No identity named "${deps.identity}".`);
|
|
25951
26288
|
}
|
|
25952
|
-
const identityDir =
|
|
25953
|
-
const credentialsFile =
|
|
25954
|
-
const claudeJsonFile =
|
|
25955
|
-
const recordDir =
|
|
25956
|
-
const recordFile2 =
|
|
26289
|
+
const identityDir = import_node_path46.default.join(deps.identitiesDir, id);
|
|
26290
|
+
const credentialsFile = import_node_path46.default.join(identityDir, CREDENTIALS_FILE2);
|
|
26291
|
+
const claudeJsonFile = import_node_path46.default.join(identityDir, CLAUDE_JSON2);
|
|
26292
|
+
const recordDir = import_node_path46.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
26293
|
+
const recordFile2 = import_node_path46.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
25957
26294
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
25958
26295
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
25959
26296
|
const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -25969,7 +26306,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25969
26306
|
const organizationUuid = deps.newUuid();
|
|
25970
26307
|
const accountUuid = deps.newUuid();
|
|
25971
26308
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
25972
|
-
deps.fs.mkdirPrivate(
|
|
26309
|
+
deps.fs.mkdirPrivate(import_node_path46.default.dirname(credentialsFile));
|
|
25973
26310
|
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)}
|
|
25974
26311
|
`);
|
|
25975
26312
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -26005,7 +26342,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
26005
26342
|
init_ensure2();
|
|
26006
26343
|
|
|
26007
26344
|
// src/frontdoor/liveSessionRegistry.ts
|
|
26008
|
-
var
|
|
26345
|
+
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
26009
26346
|
init_capability();
|
|
26010
26347
|
init_state();
|
|
26011
26348
|
function sameStat(recorded, current) {
|
|
@@ -26029,7 +26366,7 @@ function createLiveSessionRegistry(ports) {
|
|
|
26029
26366
|
const load = (name, stat) => {
|
|
26030
26367
|
known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs17, sessionsDir, name) });
|
|
26031
26368
|
};
|
|
26032
|
-
const statOf = (name) => fs17.lstat(
|
|
26369
|
+
const statOf = (name) => fs17.lstat(import_node_path47.default.join(sessionsDir, name));
|
|
26033
26370
|
const reconcile = () => {
|
|
26034
26371
|
const names = new Set(recordNames());
|
|
26035
26372
|
let changed = false;
|
|
@@ -26103,8 +26440,8 @@ init_poolPick();
|
|
|
26103
26440
|
init_liveTasks();
|
|
26104
26441
|
|
|
26105
26442
|
// src/agents/read.ts
|
|
26106
|
-
var
|
|
26107
|
-
var
|
|
26443
|
+
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
26444
|
+
var import_zod47 = require("zod");
|
|
26108
26445
|
init_schema3();
|
|
26109
26446
|
var PROJECTS_DIR = "projects";
|
|
26110
26447
|
var TASKS_DIR = "tasks";
|
|
@@ -26130,15 +26467,15 @@ function parseEntry2(project, entry) {
|
|
|
26130
26467
|
}
|
|
26131
26468
|
function listSessions2(fs17, configDir) {
|
|
26132
26469
|
const found = [];
|
|
26133
|
-
for (const project of fs17.readdir(
|
|
26134
|
-
const projectDir =
|
|
26470
|
+
for (const project of fs17.readdir(import_node_path48.default.join(configDir, PROJECTS_DIR))) {
|
|
26471
|
+
const projectDir = import_node_path48.default.join(configDir, PROJECTS_DIR, project);
|
|
26135
26472
|
const entries = /* @__PURE__ */ new Set();
|
|
26136
26473
|
for (const name of fs17.readdir(projectDir)) {
|
|
26137
26474
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
26138
26475
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
26139
26476
|
continue;
|
|
26140
26477
|
}
|
|
26141
|
-
const children = fs17.readdir(
|
|
26478
|
+
const children = fs17.readdir(import_node_path48.default.join(projectDir, name));
|
|
26142
26479
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
26143
26480
|
entries.add(name);
|
|
26144
26481
|
}
|
|
@@ -26158,8 +26495,8 @@ function locateAgents(fs17, configDir, relativeDir, workflowRunId, report) {
|
|
|
26158
26495
|
const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
|
|
26159
26496
|
located.push({
|
|
26160
26497
|
id,
|
|
26161
|
-
metaPath:
|
|
26162
|
-
transcriptPath:
|
|
26498
|
+
metaPath: import_node_path48.default.join(relativeDir, name),
|
|
26499
|
+
transcriptPath: import_node_path48.default.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
|
|
26163
26500
|
workflowRunId
|
|
26164
26501
|
});
|
|
26165
26502
|
}
|
|
@@ -26202,7 +26539,7 @@ function describeFailure(error) {
|
|
|
26202
26539
|
}
|
|
26203
26540
|
function readFileOrReport(fs17, configDir, relative, report) {
|
|
26204
26541
|
try {
|
|
26205
|
-
return fs17.readFileUtf8(
|
|
26542
|
+
return fs17.readFileUtf8(import_node_path48.default.join(configDir, relative));
|
|
26206
26543
|
} catch (error) {
|
|
26207
26544
|
report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
|
|
26208
26545
|
return void 0;
|
|
@@ -26210,7 +26547,7 @@ function readFileOrReport(fs17, configDir, relative, report) {
|
|
|
26210
26547
|
}
|
|
26211
26548
|
function listDirOrReport(fs17, configDir, relative, report) {
|
|
26212
26549
|
try {
|
|
26213
|
-
return fs17.readdir(
|
|
26550
|
+
return fs17.readdir(import_node_path48.default.join(configDir, relative));
|
|
26214
26551
|
} catch (error) {
|
|
26215
26552
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
|
|
26216
26553
|
return [];
|
|
@@ -26224,28 +26561,28 @@ function parseJson2(text) {
|
|
|
26224
26561
|
return void 0;
|
|
26225
26562
|
}
|
|
26226
26563
|
}
|
|
26227
|
-
var TaskFileSchema =
|
|
26228
|
-
var WorkflowRunFileSchema =
|
|
26229
|
-
runId:
|
|
26230
|
-
workflowName:
|
|
26231
|
-
status:
|
|
26232
|
-
startTime:
|
|
26233
|
-
phases:
|
|
26234
|
-
summary:
|
|
26564
|
+
var TaskFileSchema = import_zod47.z.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: import_zod47.z.array(import_zod47.z.string()).default([]), blockedBy: import_zod47.z.array(import_zod47.z.string()).default([]) });
|
|
26565
|
+
var WorkflowRunFileSchema = import_zod47.z.object({
|
|
26566
|
+
runId: import_zod47.z.string(),
|
|
26567
|
+
workflowName: import_zod47.z.string().optional(),
|
|
26568
|
+
status: import_zod47.z.string().optional(),
|
|
26569
|
+
startTime: import_zod47.z.number().optional(),
|
|
26570
|
+
phases: import_zod47.z.array(import_zod47.z.object({ title: import_zod47.z.string() })).default([]),
|
|
26571
|
+
summary: import_zod47.z.string().optional()
|
|
26235
26572
|
});
|
|
26236
26573
|
function summariseSession(fs17, configDir, ref) {
|
|
26237
|
-
const sessionRelative =
|
|
26238
|
-
const subagentsRelative =
|
|
26239
|
-
const workflowsUnderSubagents =
|
|
26574
|
+
const sessionRelative = import_node_path48.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26575
|
+
const subagentsRelative = import_node_path48.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
26576
|
+
const workflowsUnderSubagents = import_node_path48.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26240
26577
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
26241
|
-
let agentCount = fs17.readdir(
|
|
26242
|
-
for (const runDir of fs17.readdir(
|
|
26578
|
+
let agentCount = fs17.readdir(import_node_path48.default.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
26579
|
+
for (const runDir of fs17.readdir(import_node_path48.default.join(configDir, workflowsUnderSubagents))) {
|
|
26243
26580
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26244
|
-
agentCount += fs17.readdir(
|
|
26581
|
+
agentCount += fs17.readdir(import_node_path48.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
26245
26582
|
}
|
|
26246
26583
|
}
|
|
26247
|
-
const workflowRunCount = fs17.readdir(
|
|
26248
|
-
const transcript = fs17.lstat(
|
|
26584
|
+
const workflowRunCount = fs17.readdir(import_node_path48.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
|
|
26585
|
+
const transcript = fs17.lstat(import_node_path48.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
26249
26586
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
26250
26587
|
}
|
|
26251
26588
|
function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
@@ -26253,13 +26590,13 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26253
26590
|
const report = (problem) => {
|
|
26254
26591
|
problems.push(problem);
|
|
26255
26592
|
};
|
|
26256
|
-
const sessionRelative =
|
|
26257
|
-
const subagentsRelative =
|
|
26258
|
-
const workflowsUnderSubagents =
|
|
26593
|
+
const sessionRelative = import_node_path48.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26594
|
+
const subagentsRelative = import_node_path48.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
26595
|
+
const workflowsUnderSubagents = import_node_path48.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26259
26596
|
const located = locateAgents(fs17, configDir, subagentsRelative, void 0, report);
|
|
26260
26597
|
for (const runDir of listDirOrReport(fs17, configDir, workflowsUnderSubagents, report)) {
|
|
26261
26598
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26262
|
-
located.push(...locateAgents(fs17, configDir,
|
|
26599
|
+
located.push(...locateAgents(fs17, configDir, import_node_path48.default.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
26263
26600
|
}
|
|
26264
26601
|
}
|
|
26265
26602
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -26300,7 +26637,7 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26300
26637
|
superseded: ref.superseded,
|
|
26301
26638
|
agents: roots.sort().map(build),
|
|
26302
26639
|
tasks: readTasks(fs17, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
|
|
26303
|
-
workflowRuns: readWorkflowRuns(fs17, configDir,
|
|
26640
|
+
workflowRuns: readWorkflowRuns(fs17, configDir, import_node_path48.default.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
26304
26641
|
problems
|
|
26305
26642
|
};
|
|
26306
26643
|
}
|
|
@@ -26365,12 +26702,12 @@ function ownTaskLists(sessionId) {
|
|
|
26365
26702
|
function readTasks(fs17, configDir, ownLists, sharedLists, report) {
|
|
26366
26703
|
const tasks = [];
|
|
26367
26704
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
26368
|
-
const relativeDir =
|
|
26705
|
+
const relativeDir = import_node_path48.default.join(TASKS_DIR, scope);
|
|
26369
26706
|
for (const name of [...listDirOrReport(fs17, configDir, relativeDir, report)].sort()) {
|
|
26370
26707
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
26371
26708
|
continue;
|
|
26372
26709
|
}
|
|
26373
|
-
const relative =
|
|
26710
|
+
const relative = import_node_path48.default.join(relativeDir, name);
|
|
26374
26711
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26375
26712
|
const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26376
26713
|
if (parsed.success) {
|
|
@@ -26388,7 +26725,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26388
26725
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
26389
26726
|
continue;
|
|
26390
26727
|
}
|
|
26391
|
-
const relative =
|
|
26728
|
+
const relative = import_node_path48.default.join(relativeDir, name);
|
|
26392
26729
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26393
26730
|
const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26394
26731
|
if (!parsed.success) {
|
|
@@ -26404,7 +26741,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26404
26741
|
}
|
|
26405
26742
|
|
|
26406
26743
|
// src/agents/sessions.ts
|
|
26407
|
-
var
|
|
26744
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
26408
26745
|
init_cliError();
|
|
26409
26746
|
var SessionLookupError = class extends CliError {
|
|
26410
26747
|
constructor(message) {
|
|
@@ -26416,7 +26753,7 @@ function historyStores(fs17, configDirOf, identities) {
|
|
|
26416
26753
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
26417
26754
|
for (const identity of identities) {
|
|
26418
26755
|
const configDir = configDirOf(identity);
|
|
26419
|
-
const real = fs17.realpath(
|
|
26756
|
+
const real = fs17.realpath(import_node_path49.default.join(configDir, "projects"));
|
|
26420
26757
|
if (real === void 0) {
|
|
26421
26758
|
continue;
|
|
26422
26759
|
}
|
|
@@ -26518,7 +26855,7 @@ init_load();
|
|
|
26518
26855
|
init_launchWiring();
|
|
26519
26856
|
init_argv();
|
|
26520
26857
|
init_cascade();
|
|
26521
|
-
|
|
26858
|
+
init_identity2();
|
|
26522
26859
|
|
|
26523
26860
|
// src/launcher/poolRefresh.ts
|
|
26524
26861
|
init_anthropicUsageRefresh();
|