claude-use 14.2.3 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +7729 -6182
- package/dist/index.cjs +1734 -1398
- package/dist/index.mjs +1695 -1359
- package/dist/types/index.d.ts +14 -1
- 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) {
|
|
@@ -7738,11 +7934,11 @@ function createRcControlHandler(deps) {
|
|
|
7738
7934
|
path: "read-file",
|
|
7739
7935
|
read: (body) => {
|
|
7740
7936
|
const session = bodyString(body, "session");
|
|
7741
|
-
const
|
|
7937
|
+
const path56 = bodyString(body, "path");
|
|
7742
7938
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
7743
7939
|
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,
|
|
7940
|
+
const refused2 = session === void 0 || path56 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
7941
|
+
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
7942
|
}
|
|
7747
7943
|
},
|
|
7748
7944
|
{
|
|
@@ -8065,9 +8261,9 @@ function requestIdOfBody(body) {
|
|
|
8065
8261
|
}
|
|
8066
8262
|
function frontDoorRcControl(transport, token) {
|
|
8067
8263
|
const headers = { authorization: `Bearer ${token}` };
|
|
8068
|
-
const listAnswerOf = async (
|
|
8264
|
+
const listAnswerOf = async (path56, what) => {
|
|
8069
8265
|
try {
|
|
8070
|
-
return await transport.request({ method: "GET", path:
|
|
8266
|
+
return await transport.request({ method: "GET", path: path56, headers });
|
|
8071
8267
|
} catch (error) {
|
|
8072
8268
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
8073
8269
|
}
|
|
@@ -8139,10 +8335,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8139
8335
|
}
|
|
8140
8336
|
return pending;
|
|
8141
8337
|
};
|
|
8142
|
-
const writeOf = async (
|
|
8338
|
+
const writeOf = async (path56, body, describeFailure2) => {
|
|
8143
8339
|
let answer;
|
|
8144
8340
|
try {
|
|
8145
|
-
answer = await transport.request({ method: "POST", path:
|
|
8341
|
+
answer = await transport.request({ method: "POST", path: path56, headers: { ...headers, "content-type": "application/json" }, body });
|
|
8146
8342
|
} catch (error) {
|
|
8147
8343
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
8148
8344
|
}
|
|
@@ -8173,10 +8369,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8173
8369
|
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
8370
|
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
8371
|
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,
|
|
8372
|
+
readFile: async (sessionId, path56, options) => await writeOf(
|
|
8177
8373
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
8178
|
-
JSON.stringify({ session: sessionId, path:
|
|
8179
|
-
(status, message) => `reading ${
|
|
8374
|
+
JSON.stringify({ session: sessionId, path: path56, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
8375
|
+
(status, message) => `reading ${path56} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
8180
8376
|
),
|
|
8181
8377
|
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
8378
|
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 +8609,12 @@ function tlsFacts(options) {
|
|
|
8413
8609
|
}
|
|
8414
8610
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8415
8611
|
const agent = new ExemptTlsAgent();
|
|
8416
|
-
const post = async (
|
|
8612
|
+
const post = async (path56, headers, body) => await new Promise((resolve, reject) => {
|
|
8417
8613
|
const options = {
|
|
8418
8614
|
host: target.host,
|
|
8419
8615
|
port: target.port,
|
|
8420
8616
|
method: "POST",
|
|
8421
|
-
path:
|
|
8617
|
+
path: path56,
|
|
8422
8618
|
// 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
8619
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
8424
8620
|
agent
|
|
@@ -8478,12 +8674,12 @@ function lateRcStreamDial(resolve) {
|
|
|
8478
8674
|
}
|
|
8479
8675
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8480
8676
|
const agent = new ExemptTlsAgent();
|
|
8481
|
-
const request4 = async (method,
|
|
8677
|
+
const request4 = async (method, path56, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
8482
8678
|
const options = {
|
|
8483
8679
|
host: target.host,
|
|
8484
8680
|
port: target.port,
|
|
8485
8681
|
method,
|
|
8486
|
-
path:
|
|
8682
|
+
path: path56,
|
|
8487
8683
|
// 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
8684
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
8489
8685
|
agent,
|
|
@@ -8525,9 +8721,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
8525
8721
|
return { status, body: await readAll(response) };
|
|
8526
8722
|
},
|
|
8527
8723
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
8528
|
-
const
|
|
8724
|
+
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
8725
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
8530
|
-
const { status, response } = await request4("GET",
|
|
8726
|
+
const { status, response } = await request4("GET", path56, streamHeaders, void 0, signal);
|
|
8531
8727
|
if (!isSuccessful2(status)) {
|
|
8532
8728
|
await readAll(response);
|
|
8533
8729
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -8970,7 +9166,7 @@ function loadIdentity(identitiesDir, name, fs17) {
|
|
|
8970
9166
|
return id === void 0 ? void 0 : loadConfigFile(import_node_path15.default.join(identitiesDir, id, "identity.json"), IdentitySchema, fs17.readConfigFile);
|
|
8971
9167
|
}
|
|
8972
9168
|
var import_node_path15, IDENTITY_DECISION_SOURCES, IDENTITY_SOURCE_LABELS, CONFIG_PROFILE_DECISION_SOURCES;
|
|
8973
|
-
var
|
|
9169
|
+
var init_identity2 = __esm({
|
|
8974
9170
|
"src/launcher/identity.ts"() {
|
|
8975
9171
|
"use strict";
|
|
8976
9172
|
import_node_path15 = __toESM(require("node:path"), 1);
|
|
@@ -9019,9 +9215,9 @@ var init_identity = __esm({
|
|
|
9019
9215
|
});
|
|
9020
9216
|
|
|
9021
9217
|
// src/statusline/keys.ts
|
|
9022
|
-
function valueAt(source,
|
|
9218
|
+
function valueAt(source, path56) {
|
|
9023
9219
|
let current = source;
|
|
9024
|
-
for (const part of
|
|
9220
|
+
for (const part of path56) {
|
|
9025
9221
|
if (!isPlainObject(current)) {
|
|
9026
9222
|
return void 0;
|
|
9027
9223
|
}
|
|
@@ -9029,14 +9225,14 @@ function valueAt(source, path55) {
|
|
|
9029
9225
|
}
|
|
9030
9226
|
return current;
|
|
9031
9227
|
}
|
|
9032
|
-
function acceptsNull(
|
|
9033
|
-
const layer =
|
|
9228
|
+
function acceptsNull(path56) {
|
|
9229
|
+
const layer = path56.reduceRight((inner, part) => ({ [part]: inner }), null);
|
|
9034
9230
|
return StatuslineSchema.safeParse(layer).success;
|
|
9035
9231
|
}
|
|
9036
|
-
function keyOf(
|
|
9232
|
+
function keyOf(path56, declared) {
|
|
9037
9233
|
const optional = declared instanceof import_zod13.z.ZodOptional;
|
|
9038
9234
|
const leaf = optional ? declared.unwrap() : declared;
|
|
9039
|
-
const common = { path:
|
|
9235
|
+
const common = { path: path56.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path56), optional, unsettable: acceptsNull(path56) };
|
|
9040
9236
|
if (leaf instanceof import_zod13.z.ZodNumber) {
|
|
9041
9237
|
return { ...common, kind: "integer", choices: [] };
|
|
9042
9238
|
}
|
|
@@ -9061,7 +9257,7 @@ function keyOf(path55, declared) {
|
|
|
9061
9257
|
if (leaf instanceof import_zod13.z.ZodArray && leaf.element instanceof import_zod13.z.ZodString) {
|
|
9062
9258
|
return { ...common, kind: "textList", choices: [] };
|
|
9063
9259
|
}
|
|
9064
|
-
throw new TypeError(`statusline setting ${
|
|
9260
|
+
throw new TypeError(`statusline setting ${path56.join(".")} has a kind the key listing does not describe`);
|
|
9065
9261
|
}
|
|
9066
9262
|
function walk(shape, prefix) {
|
|
9067
9263
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof import_zod13.z.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -9079,15 +9275,15 @@ var init_keys = __esm({
|
|
|
9079
9275
|
});
|
|
9080
9276
|
|
|
9081
9277
|
// src/statusline/change.ts
|
|
9082
|
-
function keyNamed(
|
|
9083
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
9278
|
+
function keyNamed(path56) {
|
|
9279
|
+
const found = statuslineKeys().find((key) => key.path === path56);
|
|
9084
9280
|
if (found === void 0) {
|
|
9085
|
-
throw new UsageError(`"${
|
|
9281
|
+
throw new UsageError(`"${path56}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
9086
9282
|
}
|
|
9087
9283
|
return found;
|
|
9088
9284
|
}
|
|
9089
|
-
function setAt(target,
|
|
9090
|
-
const [head, ...rest] =
|
|
9285
|
+
function setAt(target, path56, value) {
|
|
9286
|
+
const [head, ...rest] = path56;
|
|
9091
9287
|
if (head === void 0) {
|
|
9092
9288
|
return;
|
|
9093
9289
|
}
|
|
@@ -9100,8 +9296,8 @@ function setAt(target, path55, value) {
|
|
|
9100
9296
|
target[head] = next;
|
|
9101
9297
|
setAt(next, rest, value);
|
|
9102
9298
|
}
|
|
9103
|
-
function removeAt(target,
|
|
9104
|
-
const [head, ...rest] =
|
|
9299
|
+
function removeAt(target, path56) {
|
|
9300
|
+
const [head, ...rest] = path56;
|
|
9105
9301
|
if (head === void 0) {
|
|
9106
9302
|
return;
|
|
9107
9303
|
}
|
|
@@ -9119,13 +9315,13 @@ function removeAt(target, path55) {
|
|
|
9119
9315
|
}
|
|
9120
9316
|
function applyStatuslineChange(existing, change) {
|
|
9121
9317
|
const draft = structuredClone(existing ?? {});
|
|
9122
|
-
for (const [
|
|
9123
|
-
keyNamed(
|
|
9124
|
-
setAt(draft,
|
|
9318
|
+
for (const [path56, value] of Object.entries(change.set ?? {})) {
|
|
9319
|
+
keyNamed(path56);
|
|
9320
|
+
setAt(draft, path56.split("."), value);
|
|
9125
9321
|
}
|
|
9126
|
-
for (const
|
|
9127
|
-
keyNamed(
|
|
9128
|
-
removeAt(draft,
|
|
9322
|
+
for (const path56 of change.unset ?? []) {
|
|
9323
|
+
keyNamed(path56);
|
|
9324
|
+
removeAt(draft, path56.split("."));
|
|
9129
9325
|
}
|
|
9130
9326
|
const result = StatuslineSchema.safeParse(draft);
|
|
9131
9327
|
if (!result.success) {
|
|
@@ -9361,19 +9557,19 @@ function writePools(paths, pools) {
|
|
|
9361
9557
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
9362
9558
|
}
|
|
9363
9559
|
function poolCycleOf(pools, name) {
|
|
9364
|
-
const walk2 = (current,
|
|
9560
|
+
const walk2 = (current, path56) => {
|
|
9365
9561
|
for (const entry of pools[current]?.identities ?? []) {
|
|
9366
9562
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
9367
9563
|
if (nested === void 0) {
|
|
9368
9564
|
continue;
|
|
9369
9565
|
}
|
|
9370
9566
|
if (nested === name) {
|
|
9371
|
-
return [...
|
|
9567
|
+
return [...path56, nested];
|
|
9372
9568
|
}
|
|
9373
|
-
if (
|
|
9569
|
+
if (path56.includes(nested)) {
|
|
9374
9570
|
continue;
|
|
9375
9571
|
}
|
|
9376
|
-
const found = walk2(nested, [...
|
|
9572
|
+
const found = walk2(nested, [...path56, nested]);
|
|
9377
9573
|
if (found !== void 0) {
|
|
9378
9574
|
return found;
|
|
9379
9575
|
}
|
|
@@ -9452,7 +9648,7 @@ var init_poolStore = __esm({
|
|
|
9452
9648
|
init_configProfilesStore();
|
|
9453
9649
|
init_store();
|
|
9454
9650
|
init_schema();
|
|
9455
|
-
|
|
9651
|
+
init_identity2();
|
|
9456
9652
|
PoolNotFoundError = class extends CliError {
|
|
9457
9653
|
constructor(poolName) {
|
|
9458
9654
|
super(`No pool named "${poolName}". Run \`agent-shim pool add ${poolName} --identity <name>...\` first.`);
|
|
@@ -9793,7 +9989,7 @@ function listKey(list) {
|
|
|
9793
9989
|
return `${list},appended`;
|
|
9794
9990
|
}
|
|
9795
9991
|
function digest2(value) {
|
|
9796
|
-
return (0,
|
|
9992
|
+
return (0, import_node_crypto8.createHash)("sha256").update(value).digest("hex");
|
|
9797
9993
|
}
|
|
9798
9994
|
function recordedDigests(env) {
|
|
9799
9995
|
const raw = env[INJECTED_ENV];
|
|
@@ -9873,11 +10069,11 @@ function withoutInjected(env) {
|
|
|
9873
10069
|
});
|
|
9874
10070
|
return Object.fromEntries(entries);
|
|
9875
10071
|
}
|
|
9876
|
-
var
|
|
10072
|
+
var import_node_crypto8, import_zod14, INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
|
|
9877
10073
|
var init_injected = __esm({
|
|
9878
10074
|
"src/launcher/injected.ts"() {
|
|
9879
10075
|
"use strict";
|
|
9880
|
-
|
|
10076
|
+
import_node_crypto8 = require("node:crypto");
|
|
9881
10077
|
import_zod14 = require("zod");
|
|
9882
10078
|
init_headers();
|
|
9883
10079
|
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
@@ -9954,7 +10150,7 @@ var init_guard = __esm({
|
|
|
9954
10150
|
|
|
9955
10151
|
// src/usage/signIn.ts
|
|
9956
10152
|
function claudeCodeKeychainService(configDir) {
|
|
9957
|
-
return `${KEYCHAIN_SERVICE_PREFIX}-${(0,
|
|
10153
|
+
return `${KEYCHAIN_SERVICE_PREFIX}-${(0, import_node_crypto9.createHash)("sha256").update(configDir).digest("hex").slice(0, KEYCHAIN_SERVICE_HASH_DIGITS)}`;
|
|
9958
10154
|
}
|
|
9959
10155
|
function keychainHasItem(run, configDir) {
|
|
9960
10156
|
return run.run("security", ["find-generic-password", "-s", claudeCodeKeychainService(configDir)]).status === 0;
|
|
@@ -10005,11 +10201,11 @@ function storedLoginUsable(run, claudeBin, configDir, env) {
|
|
|
10005
10201
|
}
|
|
10006
10202
|
return void 0;
|
|
10007
10203
|
}
|
|
10008
|
-
var
|
|
10204
|
+
var import_node_crypto9, import_node_path19, CREDENTIALS_FILE, KEYCHAIN_SERVICE_PREFIX, KEYCHAIN_SERVICE_HASH_DIGITS, AUTH_STATUS_TIMEOUT_MS;
|
|
10009
10205
|
var init_signIn = __esm({
|
|
10010
10206
|
"src/usage/signIn.ts"() {
|
|
10011
10207
|
"use strict";
|
|
10012
|
-
|
|
10208
|
+
import_node_crypto9 = require("node:crypto");
|
|
10013
10209
|
import_node_path19 = __toESM(require("node:path"), 1);
|
|
10014
10210
|
init_guard();
|
|
10015
10211
|
CREDENTIALS_FILE = ".credentials.json";
|
|
@@ -10148,7 +10344,7 @@ function serialisedFor(entry, owner) {
|
|
|
10148
10344
|
return JSON.stringify({ owner, ...withoutOwner(entry) });
|
|
10149
10345
|
}
|
|
10150
10346
|
function tempPathFor(target) {
|
|
10151
|
-
return import_node_path20.default.join(import_node_path20.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0,
|
|
10347
|
+
return import_node_path20.default.join(import_node_path20.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0, import_node_crypto10.randomUUID)()}`);
|
|
10152
10348
|
}
|
|
10153
10349
|
function processRuns(pid) {
|
|
10154
10350
|
try {
|
|
@@ -10267,11 +10463,11 @@ function createRealCredentialCache(root, keychain = { run: security, platform: p
|
|
|
10267
10463
|
function realCredentialCacheEnv(paths) {
|
|
10268
10464
|
return { port: createRealCredentialCache(paths.root), platform: process.platform, now: () => Date.now() };
|
|
10269
10465
|
}
|
|
10270
|
-
var
|
|
10466
|
+
var import_node_crypto10, import_node_fs5, import_node_path20, CACHE_DIR_MODE, CACHE_FILE_MODE, TEMP_PREFIX, TEMP_NAME, RELEASED_TEMP_NAME;
|
|
10271
10467
|
var init_realCredentialCache = __esm({
|
|
10272
10468
|
"src/realCredentialCache.ts"() {
|
|
10273
10469
|
"use strict";
|
|
10274
|
-
|
|
10470
|
+
import_node_crypto10 = require("node:crypto");
|
|
10275
10471
|
import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
10276
10472
|
import_node_path20 = __toESM(require("node:path"), 1);
|
|
10277
10473
|
init_blockingSpawn();
|
|
@@ -10429,7 +10625,7 @@ function migrateHeadroomState(fs17, files, isRunning) {
|
|
|
10429
10625
|
fs17.removeRecursive(files.legacyStateFile);
|
|
10430
10626
|
}
|
|
10431
10627
|
function hashAllowlist(allowlist) {
|
|
10432
|
-
return (0,
|
|
10628
|
+
return (0, import_node_crypto11.createHash)("sha256").update(allowlist.join("\n")).digest("hex");
|
|
10433
10629
|
}
|
|
10434
10630
|
function formatAllowlistFile(allowlist) {
|
|
10435
10631
|
return allowlist.map((entry) => `${entry}
|
|
@@ -10534,11 +10730,11 @@ function readStartLock(fs17, lockFile) {
|
|
|
10534
10730
|
return void 0;
|
|
10535
10731
|
}
|
|
10536
10732
|
}
|
|
10537
|
-
var
|
|
10733
|
+
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
10734
|
var init_state2 = __esm({
|
|
10539
10735
|
"src/headroom/state.ts"() {
|
|
10540
10736
|
"use strict";
|
|
10541
|
-
|
|
10737
|
+
import_node_crypto11 = require("node:crypto");
|
|
10542
10738
|
import_node_path21 = __toESM(require("node:path"), 1);
|
|
10543
10739
|
import_zod15 = require("zod");
|
|
10544
10740
|
init_schema();
|
|
@@ -10781,13 +10977,13 @@ function settingsEnv(settings) {
|
|
|
10781
10977
|
return settings.rolloutChannel === void 0 ? {} : { HEADROOM_ROLLOUT_CHANNEL: settings.rolloutChannel };
|
|
10782
10978
|
}
|
|
10783
10979
|
function hashSettings(settings) {
|
|
10784
|
-
return (0,
|
|
10980
|
+
return (0, import_node_crypto12.createHash)("sha256").update(JSON.stringify([...settingsArgs(settings), JSON.stringify(settingsEnv(settings))])).digest("hex");
|
|
10785
10981
|
}
|
|
10786
|
-
var
|
|
10982
|
+
var import_node_crypto12;
|
|
10787
10983
|
var init_settings = __esm({
|
|
10788
10984
|
"src/headroom/settings.ts"() {
|
|
10789
10985
|
"use strict";
|
|
10790
|
-
|
|
10986
|
+
import_node_crypto12 = require("node:crypto");
|
|
10791
10987
|
}
|
|
10792
10988
|
});
|
|
10793
10989
|
|
|
@@ -11720,7 +11916,7 @@ function realResolveClaudeBinary(isOwnBinary) {
|
|
|
11720
11916
|
function realInstalledClaudeVersions() {
|
|
11721
11917
|
return installedVersions(listVersionsDir(defaultVersionsDir()));
|
|
11722
11918
|
}
|
|
11723
|
-
var import_node_child_process2,
|
|
11919
|
+
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
11920
|
var init_realPorts = __esm({
|
|
11725
11921
|
"src/realPorts.ts"() {
|
|
11726
11922
|
"use strict";
|
|
@@ -11728,7 +11924,7 @@ var init_realPorts = __esm({
|
|
|
11728
11924
|
init_doorBounds();
|
|
11729
11925
|
init_processRole();
|
|
11730
11926
|
import_node_child_process2 = require("node:child_process");
|
|
11731
|
-
|
|
11927
|
+
import_node_crypto13 = require("node:crypto");
|
|
11732
11928
|
import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
11733
11929
|
import_node_os2 = __toESM(require("node:os"), 1);
|
|
11734
11930
|
import_node_path24 = __toESM(require("node:path"), 1);
|
|
@@ -11879,7 +12075,7 @@ var init_realPorts = __esm({
|
|
|
11879
12075
|
},
|
|
11880
12076
|
hashFile(filePath) {
|
|
11881
12077
|
try {
|
|
11882
|
-
return (0,
|
|
12078
|
+
return (0, import_node_crypto13.createHash)("sha256").update(import_node_fs6.default.readFileSync(filePath)).digest("hex");
|
|
11883
12079
|
} catch (error) {
|
|
11884
12080
|
if (isEnoent3(error) || isErrorWithCode(error, "EISDIR")) {
|
|
11885
12081
|
return void 0;
|
|
@@ -13131,7 +13327,7 @@ var init_poolPick = __esm({
|
|
|
13131
13327
|
import_node_path26 = __toESM(require("node:path"), 1);
|
|
13132
13328
|
import_zod19 = require("zod");
|
|
13133
13329
|
init_cliError();
|
|
13134
|
-
|
|
13330
|
+
init_identity2();
|
|
13135
13331
|
init_schema();
|
|
13136
13332
|
init_identityAccounts();
|
|
13137
13333
|
init_account();
|
|
@@ -13157,7 +13353,7 @@ var init_poolPick = __esm({
|
|
|
13157
13353
|
|
|
13158
13354
|
// src/identityRenameJournal.ts
|
|
13159
13355
|
function renamePairFileName(from, to, suffix) {
|
|
13160
|
-
return `${(0,
|
|
13356
|
+
return `${(0, import_node_crypto14.createHash)("sha256").update(`${from}\0${to}`).digest("hex").slice(0, FILE_NAME_HASH_DIGITS)}${suffix}`;
|
|
13161
13357
|
}
|
|
13162
13358
|
function readRenameJournal(fs17, file) {
|
|
13163
13359
|
const raw = fs17.readFileUtf8(file);
|
|
@@ -13228,11 +13424,11 @@ function requireNameFreeOfUnfinishedRename(fs17, directory, name, action, sameNa
|
|
|
13228
13424
|
throw new NameHeldByUnfinishedRenameError(action, name, held, finishabilityOf(held, exists));
|
|
13229
13425
|
}
|
|
13230
13426
|
}
|
|
13231
|
-
var
|
|
13427
|
+
var import_node_crypto14, import_node_path27, import_zod20, RenameJournalSchema, FILE_NAME_HASH_DIGITS, JOURNAL_SUFFIX, RenameJournalUnreadableError, NameHeldByUnfinishedRenameError;
|
|
13232
13428
|
var init_identityRenameJournal = __esm({
|
|
13233
13429
|
"src/identityRenameJournal.ts"() {
|
|
13234
13430
|
"use strict";
|
|
13235
|
-
|
|
13431
|
+
import_node_crypto14 = require("node:crypto");
|
|
13236
13432
|
import_node_path27 = __toESM(require("node:path"), 1);
|
|
13237
13433
|
import_zod20 = require("zod");
|
|
13238
13434
|
init_cliError();
|
|
@@ -13389,7 +13585,7 @@ var init_identityNameRenameRecord = __esm({
|
|
|
13389
13585
|
|
|
13390
13586
|
// src/launcher/launchRecords.ts
|
|
13391
13587
|
function recordFile(directory, pid) {
|
|
13392
|
-
return import_node_path29.default.join(directory, `${String(pid)}.${(0,
|
|
13588
|
+
return import_node_path29.default.join(directory, `${String(pid)}.${(0, import_node_crypto15.randomUUID)()}${RECORD_SUFFIX2}`);
|
|
13393
13589
|
}
|
|
13394
13590
|
function readRecord(fs17, directory, name) {
|
|
13395
13591
|
if (!name.endsWith(RECORD_SUFFIX2)) {
|
|
@@ -13430,12 +13626,12 @@ function liveLaunchesOn(fs17, directory, identity, isRunning) {
|
|
|
13430
13626
|
return record?.identity === identity && isRunning(record.pid) ? [record.pid] : [];
|
|
13431
13627
|
}).sort((left, right) => left - right);
|
|
13432
13628
|
}
|
|
13433
|
-
var import_node_path29,
|
|
13629
|
+
var import_node_path29, import_node_crypto15, import_zod22, LaunchRecordSchema, RECORD_SUFFIX2;
|
|
13434
13630
|
var init_launchRecords = __esm({
|
|
13435
13631
|
"src/launcher/launchRecords.ts"() {
|
|
13436
13632
|
"use strict";
|
|
13437
13633
|
import_node_path29 = __toESM(require("node:path"), 1);
|
|
13438
|
-
|
|
13634
|
+
import_node_crypto15 = require("node:crypto");
|
|
13439
13635
|
import_zod22 = require("zod");
|
|
13440
13636
|
LaunchRecordSchema = import_zod22.z.strictObject({
|
|
13441
13637
|
/** The launcher's process id, which is what tells a launch in progress from a record a crashed launcher left behind. */
|
|
@@ -13838,7 +14034,7 @@ var init_identityStore = __esm({
|
|
|
13838
14034
|
init_store();
|
|
13839
14035
|
init_schema();
|
|
13840
14036
|
init_cliError();
|
|
13841
|
-
|
|
14037
|
+
init_identity2();
|
|
13842
14038
|
init_poolStore();
|
|
13843
14039
|
init_read();
|
|
13844
14040
|
init_credential();
|
|
@@ -13912,7 +14108,7 @@ var init_package = __esm({
|
|
|
13912
14108
|
"package.json"() {
|
|
13913
14109
|
package_default = {
|
|
13914
14110
|
name: "claude-use",
|
|
13915
|
-
version: "14.
|
|
14111
|
+
version: "14.3.0",
|
|
13916
14112
|
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
14113
|
license: "MIT",
|
|
13918
14114
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -14203,326 +14399,422 @@ var init_claudeShim = __esm({
|
|
|
14203
14399
|
}
|
|
14204
14400
|
});
|
|
14205
14401
|
|
|
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
|
-
}
|
|
14402
|
+
// src/frontdoor/probe.ts
|
|
14403
|
+
function probeWorkerSource(body) {
|
|
14404
|
+
return `const { workerData } = require("node:worker_threads");
|
|
14405
|
+
${STARTED_SIGNAL_SOURCE}
|
|
14406
|
+
${body}`;
|
|
14218
14407
|
}
|
|
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;
|
|
14408
|
+
function requestCatalogueRefreshSync(port, caPem, token, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
14409
|
+
refuseToBlockInRole("a synchronous catalogue refresh request");
|
|
14410
|
+
return workers.start(CATALOGUE_REQUEST_SOURCE, { port, ca: caPem, token }, timeoutMs).verdict();
|
|
14235
14411
|
}
|
|
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;
|
|
14412
|
+
function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
14413
|
+
refuseToBlockInRole("a synchronous probe of the front door");
|
|
14414
|
+
return workers.start(PROBE_SOURCE, { port, ca: caPem }, timeoutMs).verdict();
|
|
14264
14415
|
}
|
|
14265
|
-
function
|
|
14266
|
-
|
|
14416
|
+
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
14417
|
+
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
14418
|
+
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
14419
|
}
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14272
|
-
|
|
14420
|
+
function startAddressProbes(targets, workers = realProbeWorkers, portBase) {
|
|
14421
|
+
refuseToBlockInRole("a synchronous probe of a provider's address");
|
|
14422
|
+
const base = portBase ?? processPortBase();
|
|
14423
|
+
const distinct = /* @__PURE__ */ new Map();
|
|
14424
|
+
for (const target of targets) {
|
|
14425
|
+
distinct.set(targetKey(target), target);
|
|
14273
14426
|
}
|
|
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;
|
|
14427
|
+
const unique = Array.from(distinct.values());
|
|
14428
|
+
const stride = Math.max(1, Math.floor(DOOR_SOURCE_PORT_COUNT / unique.length));
|
|
14429
|
+
const verdicts = /* @__PURE__ */ new Map();
|
|
14430
|
+
const running = [];
|
|
14431
|
+
const settleOldest = () => {
|
|
14432
|
+
const oldest = running.shift();
|
|
14433
|
+
if (oldest !== void 0) {
|
|
14434
|
+
verdicts.set(oldest.key, oldest.verdict());
|
|
14285
14435
|
}
|
|
14286
|
-
return { name, profile: loaded.config, entryOrder: loaded.entryOrder, filepath: loaded.filepath };
|
|
14287
14436
|
};
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14437
|
+
unique.forEach((target, index) => {
|
|
14438
|
+
if (running.length >= MAX_CONCURRENT_PROBES) {
|
|
14439
|
+
settleOldest();
|
|
14440
|
+
}
|
|
14441
|
+
const portFirst = DOOR_SOURCE_PORT_START + (base + index * stride) % DOOR_SOURCE_PORT_COUNT;
|
|
14442
|
+
try {
|
|
14443
|
+
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);
|
|
14444
|
+
running.push({ key: targetKey(target), verdict: started.verdict, cancel: started.cancel });
|
|
14445
|
+
} catch (error) {
|
|
14446
|
+
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
14447
|
+
running.push({ key: targetKey(target), verdict: () => ({ ok: false, reason }), cancel: () => void 0 });
|
|
14448
|
+
}
|
|
14293
14449
|
});
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14450
|
+
return {
|
|
14451
|
+
settle: () => {
|
|
14452
|
+
while (running.length > 0) {
|
|
14453
|
+
settleOldest();
|
|
14454
|
+
}
|
|
14455
|
+
return targets.map((target) => {
|
|
14456
|
+
const verdict = verdicts.get(targetKey(target));
|
|
14457
|
+
if (verdict === void 0) {
|
|
14458
|
+
throw new Error("the batch probe settled no verdict for one of its targets");
|
|
14459
|
+
}
|
|
14460
|
+
return verdict;
|
|
14461
|
+
});
|
|
14462
|
+
},
|
|
14463
|
+
cancel: () => {
|
|
14464
|
+
for (const started of running.splice(0)) {
|
|
14465
|
+
started.cancel();
|
|
14466
|
+
}
|
|
14308
14467
|
}
|
|
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
14468
|
};
|
|
14324
|
-
return { input, ...globalConfig === void 0 ? {} : { globalConfig: globalConfig.config } };
|
|
14325
14469
|
}
|
|
14326
|
-
function
|
|
14327
|
-
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
|
|
14338
|
-
|
|
14470
|
+
function startProbeWorker(source, data, timeoutMs, spawn3 = spawnRealWorker, startLimitMs = PROBE_WORKER_START_LIMIT_MS, wait = slicedProbeWait) {
|
|
14471
|
+
const startLimit = performance.now() + startLimitMs;
|
|
14472
|
+
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
14473
|
+
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
14474
|
+
let worker;
|
|
14475
|
+
try {
|
|
14476
|
+
worker = spawn3(`${WORKER_PRELUDE_SOURCE}
|
|
14477
|
+
new Function("require", ${JSON.stringify(source)})(require);`, {
|
|
14478
|
+
eval: true,
|
|
14479
|
+
workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS, startedSlot: STARTED_SLOT, failurePrefix: PROBE_WORKER_FAILURE_PREFIX, claimSlot: CLAIM_SLOT }
|
|
14480
|
+
});
|
|
14481
|
+
} catch (error) {
|
|
14482
|
+
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
14483
|
+
return { verdict: () => ({ ok: false, reason }), cancel: () => void 0 };
|
|
14484
|
+
}
|
|
14485
|
+
worker.on("error", (error) => {
|
|
14486
|
+
if (Atomics.compareExchange(header, CLAIM_SLOT, 0, 1) !== 0) {
|
|
14487
|
+
return;
|
|
14488
|
+
}
|
|
14489
|
+
const bytes = Buffer.from(PROBE_WORKER_FAILURE_PREFIX + error.message, "utf8").subarray(0, REASON_BYTES);
|
|
14490
|
+
new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES).set(bytes);
|
|
14491
|
+
Atomics.store(header, 1, bytes.length);
|
|
14492
|
+
Atomics.store(header, 0, VERDICT_FAILED);
|
|
14493
|
+
Atomics.store(header, STARTED_SLOT, 1);
|
|
14494
|
+
});
|
|
14495
|
+
worker.unref();
|
|
14496
|
+
return {
|
|
14497
|
+
verdict: () => {
|
|
14498
|
+
try {
|
|
14499
|
+
wait(header, STARTED_SLOT, WORKER_NOT_STARTED, Math.max(0, startLimit - performance.now()));
|
|
14500
|
+
if (Atomics.load(header, STARTED_SLOT) === WORKER_NOT_STARTED && Atomics.load(header, 0) === VERDICT_PENDING) {
|
|
14501
|
+
return { ok: false, reason: `the probe worker did not start within ${String(startLimitMs)}ms` };
|
|
14502
|
+
}
|
|
14503
|
+
wait(header, 0, VERDICT_PENDING, timeoutMs + PROBE_WAIT_MARGIN_MS);
|
|
14504
|
+
const verdict = Atomics.load(header, 0);
|
|
14505
|
+
if (verdict === VERDICT_PENDING) {
|
|
14506
|
+
return { ok: false, reason: `the probe did not finish within ${String(timeoutMs + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
14507
|
+
}
|
|
14508
|
+
if (verdict === VERDICT_OK) {
|
|
14509
|
+
return { ok: true };
|
|
14510
|
+
}
|
|
14511
|
+
const length = Atomics.load(header, 1);
|
|
14512
|
+
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
14513
|
+
} finally {
|
|
14514
|
+
void worker.terminate();
|
|
14339
14515
|
}
|
|
14516
|
+
},
|
|
14517
|
+
cancel: () => {
|
|
14518
|
+
void worker.terminate();
|
|
14340
14519
|
}
|
|
14341
|
-
}
|
|
14342
|
-
return { ...identity === void 0 ? {} : { identity }, ...configProfile === void 0 ? {} : { configProfile } };
|
|
14520
|
+
};
|
|
14343
14521
|
}
|
|
14344
|
-
var
|
|
14345
|
-
var
|
|
14346
|
-
"src/
|
|
14522
|
+
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;
|
|
14523
|
+
var init_probe = __esm({
|
|
14524
|
+
"src/frontdoor/probe.ts"() {
|
|
14347
14525
|
"use strict";
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14356
|
-
|
|
14526
|
+
init_processRole();
|
|
14527
|
+
import_node_worker_threads = require("node:worker_threads");
|
|
14528
|
+
init_connectEffects();
|
|
14529
|
+
init_doorDial();
|
|
14530
|
+
PROBE_TIMEOUT_MS = 2e3;
|
|
14531
|
+
PROBE_WAIT_MARGIN_MS = 1e3;
|
|
14532
|
+
REASON_BYTES = 1024;
|
|
14533
|
+
HEADER_SLOTS = 4;
|
|
14534
|
+
STARTED_SLOT = 2;
|
|
14535
|
+
CLAIM_SLOT = 3;
|
|
14536
|
+
PROBE_WORKER_START_LIMIT_MS = 1e4;
|
|
14537
|
+
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);";
|
|
14538
|
+
PROBE_WORKER_FAILURE_PREFIX = "the probe worker failed: ";
|
|
14539
|
+
INT32_BYTES = 4;
|
|
14540
|
+
VERDICT_PENDING = 0;
|
|
14541
|
+
WORKER_NOT_STARTED = 0;
|
|
14542
|
+
VERDICT_OK = 1;
|
|
14543
|
+
VERDICT_FAILED = 2;
|
|
14544
|
+
WORKER_PRELUDE_SOURCE = `
|
|
14545
|
+
(() => {
|
|
14546
|
+
const { workerData } = require("node:worker_threads");
|
|
14547
|
+
const header = new Int32Array(workerData.shared, 0, workerData.headerSlots);
|
|
14548
|
+
const reason = new Uint8Array(workerData.shared, workerData.headerSlots * 4);
|
|
14549
|
+
globalThis.finishProbe = (verdict, message) => {
|
|
14550
|
+
try {
|
|
14551
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
14552
|
+
if (Atomics.compareExchange(header, workerData.claimSlot, 0, 1) === 0) {
|
|
14553
|
+
reason.set(bytes);
|
|
14554
|
+
Atomics.store(header, 1, bytes.length);
|
|
14555
|
+
Atomics.store(header, 0, verdict);
|
|
14556
|
+
}
|
|
14557
|
+
} finally {
|
|
14558
|
+
Atomics.notify(header, 0);
|
|
14559
|
+
}
|
|
14560
|
+
};
|
|
14561
|
+
const fail = (error) => {
|
|
14562
|
+
let message;
|
|
14563
|
+
try {
|
|
14564
|
+
message = workerData.failurePrefix + (error instanceof Error ? error.message : String(error));
|
|
14565
|
+
} catch {
|
|
14566
|
+
message = workerData.failurePrefix + "an error that cannot be described";
|
|
14567
|
+
}
|
|
14568
|
+
try {
|
|
14569
|
+
globalThis.finishProbe(workerData.failed, message);
|
|
14570
|
+
} finally {
|
|
14571
|
+
Atomics.store(header, workerData.startedSlot, 1);
|
|
14572
|
+
Atomics.notify(header, workerData.startedSlot);
|
|
14573
|
+
}
|
|
14574
|
+
};
|
|
14575
|
+
process.on("uncaughtException", fail);
|
|
14576
|
+
process.on("unhandledRejection", fail);
|
|
14577
|
+
// 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).
|
|
14578
|
+
process.on("exit", (code) => {
|
|
14579
|
+
globalThis.finishProbe(workerData.failed, workerData.failurePrefix + "the worker exited without a verdict (exit code " + String(code) + ")");
|
|
14580
|
+
});
|
|
14581
|
+
})();
|
|
14582
|
+
`;
|
|
14583
|
+
PROBE_SOURCE = probeWorkerSource(`
|
|
14584
|
+
const https = require("node:https");
|
|
14585
|
+
const { port, ca, timeoutMs, ok, failed } = workerData;
|
|
14586
|
+
const finish = finishProbe;
|
|
14587
|
+
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
14588
|
+
let body = "";
|
|
14589
|
+
response.setEncoding("utf8");
|
|
14590
|
+
response.on("data", (chunk) => { body += chunk; });
|
|
14591
|
+
response.on("end", () => {
|
|
14592
|
+
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
14593
|
+
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
14594
|
+
});
|
|
14595
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
14596
|
+
});
|
|
14597
|
+
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
14598
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
14599
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
14600
|
+
`);
|
|
14601
|
+
CATALOGUE_REQUEST_SOURCE = probeWorkerSource(`
|
|
14602
|
+
const https = require("node:https");
|
|
14603
|
+
const { port, ca, token, timeoutMs, ok, failed } = workerData;
|
|
14604
|
+
const finish = finishProbe;
|
|
14605
|
+
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) => {
|
|
14606
|
+
response.resume();
|
|
14607
|
+
response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
|
|
14608
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
14609
|
+
});
|
|
14610
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
14611
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
14612
|
+
request.end();
|
|
14613
|
+
`);
|
|
14614
|
+
realProbeWorkers = { start: (source, data, timeoutMs) => startProbeWorker(source, data, timeoutMs) };
|
|
14615
|
+
ACCEPT_PROBE_SOURCE = probeWorkerSource(`
|
|
14616
|
+
const net = require("node:net");
|
|
14617
|
+
const dns = require("node:dns");
|
|
14618
|
+
const { host, port, portStart, portEnd, portFirst, platform, timeoutMs, ok, failed } = workerData;
|
|
14619
|
+
const finish = finishProbe;
|
|
14620
|
+
const SourcePortRange = ${SourcePortRange.toString()};
|
|
14621
|
+
const createDoorLookup = ${createDoorLookup.toString()};
|
|
14622
|
+
const sourcePortClassifier = ${sourcePortClassifier.toString()};
|
|
14623
|
+
const doorDial = ${doorDial.toString()};
|
|
14624
|
+
const probeAccept = ${probeAccept.toString()};
|
|
14625
|
+
const runAcceptProbe = ${runAcceptProbe.toString()};
|
|
14626
|
+
const startTimer = (callback, ms) => { const timer = setTimeout(callback, ms); return () => { clearTimeout(timer); }; };
|
|
14627
|
+
runAcceptProbe({ net, dns, createDoorLookup, doorDial, probeAccept, SourcePortRange, sourcePortClassifier }, { host, port, portStart, portEnd, portFirst, platform, timeoutMs }, startTimer).then((verdict) => {
|
|
14628
|
+
finish(verdict.ok ? ok : failed, verdict.ok ? "" : verdict.reason);
|
|
14629
|
+
});
|
|
14630
|
+
`);
|
|
14631
|
+
PROBE_PORT_SHARE_DENOMINATOR = 100;
|
|
14632
|
+
MAX_CONCURRENT_PROBES = Math.max(1, Math.floor(DOOR_SOURCE_PORT_COUNT / PROBE_PORT_SHARE_DENOMINATOR));
|
|
14633
|
+
PORT_BASE_SPREAD = 389;
|
|
14634
|
+
processPortBase = () => process.pid * PORT_BASE_SPREAD % DOOR_SOURCE_PORT_COUNT;
|
|
14635
|
+
targetKey = (target) => `${target.host}\0${String(target.port)}\0${String(target.timeoutMs)}`;
|
|
14636
|
+
PROBE_WAIT_SLICE_MS = 1e3;
|
|
14637
|
+
slicedProbeWait = (header, index, value, timeoutMs) => {
|
|
14638
|
+
const end = performance.now() + timeoutMs;
|
|
14639
|
+
for (; ; ) {
|
|
14640
|
+
noteBlockingStep();
|
|
14641
|
+
const left = end - performance.now();
|
|
14642
|
+
if (left <= 0) {
|
|
14643
|
+
return "timed-out";
|
|
14644
|
+
}
|
|
14645
|
+
const answer = Atomics.wait(header, index, value, Math.min(left, PROBE_WAIT_SLICE_MS));
|
|
14646
|
+
if (answer !== "timed-out") {
|
|
14647
|
+
return answer;
|
|
14648
|
+
}
|
|
14649
|
+
}
|
|
14650
|
+
};
|
|
14651
|
+
spawnRealWorker = (source, options) => new import_node_worker_threads.Worker(source, options);
|
|
14357
14652
|
}
|
|
14358
14653
|
});
|
|
14359
14654
|
|
|
14360
|
-
// src/
|
|
14361
|
-
function
|
|
14362
|
-
|
|
14363
|
-
if (!parsed.success) {
|
|
14364
|
-
throw new ConfigValidationError(file, parsed.error.issues);
|
|
14365
|
-
}
|
|
14366
|
-
return parsed.data;
|
|
14655
|
+
// src/providerReachability.ts
|
|
14656
|
+
function providerConnectTimeoutMs(provider) {
|
|
14657
|
+
return provider.connectTimeoutMs ?? DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS;
|
|
14367
14658
|
}
|
|
14368
|
-
function
|
|
14369
|
-
return
|
|
14659
|
+
function couldNotConnectMessage(subject, baseUrl, reason) {
|
|
14660
|
+
return `${subject} could not connect to ${displayBaseUrl(baseUrl)}: ${reason.trim() === "" ? "the connection failed with no reason given" : reason}`;
|
|
14370
14661
|
}
|
|
14371
|
-
function
|
|
14372
|
-
const
|
|
14373
|
-
return
|
|
14662
|
+
function probeProviderReachability(name, provider, probe) {
|
|
14663
|
+
const verdict = probe(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
14664
|
+
return verdict.ok ? { ok: true } : { ok: false, message: couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason) };
|
|
14374
14665
|
}
|
|
14375
|
-
function
|
|
14376
|
-
if (
|
|
14377
|
-
return
|
|
14666
|
+
function startProviderReachability(name, provider, start) {
|
|
14667
|
+
if (start === void 0 || !isHttpProvider(provider)) {
|
|
14668
|
+
return void 0;
|
|
14378
14669
|
}
|
|
14379
|
-
|
|
14670
|
+
const started = start(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
14671
|
+
return {
|
|
14672
|
+
cancel: started.cancel,
|
|
14673
|
+
line: () => {
|
|
14674
|
+
const verdict = started.verdict();
|
|
14675
|
+
return verdict.ok ? void 0 : couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason);
|
|
14676
|
+
}
|
|
14677
|
+
};
|
|
14380
14678
|
}
|
|
14381
|
-
function
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
|
|
14679
|
+
function probeProviderReachabilities(providers, probe) {
|
|
14680
|
+
const http3 = providers.flatMap((entry) => isHttpProvider(entry.provider) ? [{ name: entry.name, provider: entry.provider }] : []);
|
|
14681
|
+
const verdicts = probe(http3.map((entry) => ({ baseUrl: entry.provider.baseUrl, timeoutMs: providerConnectTimeoutMs(entry.provider) })));
|
|
14682
|
+
const lines = /* @__PURE__ */ new Map();
|
|
14683
|
+
http3.forEach((entry, index) => {
|
|
14684
|
+
const verdict = verdicts[index];
|
|
14685
|
+
if (verdict === void 0) {
|
|
14686
|
+
throw new Error("the batch probe answered fewer verdicts than it was given base URLs");
|
|
14385
14687
|
}
|
|
14386
|
-
if (
|
|
14387
|
-
|
|
14688
|
+
if (!verdict.ok) {
|
|
14689
|
+
lines.set(entry.name, couldNotConnectMessage(`provider ${entry.name}`, entry.provider.baseUrl, verdict.reason));
|
|
14388
14690
|
}
|
|
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
14691
|
});
|
|
14692
|
+
return lines;
|
|
14391
14693
|
}
|
|
14392
|
-
var
|
|
14393
|
-
var
|
|
14394
|
-
"src/
|
|
14694
|
+
var TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS, CONNECT_SYN_RETRANSMISSIONS_TOLERATED, DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS, startBaseUrlBatchProbe, realBaseUrlBatchProbe, realStartBaseUrlProbe, realBaseUrlProbe;
|
|
14695
|
+
var init_providerReachability = __esm({
|
|
14696
|
+
"src/providerReachability.ts"() {
|
|
14395
14697
|
"use strict";
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14698
|
+
init_schema();
|
|
14699
|
+
init_baseUrlDial();
|
|
14700
|
+
init_baseUrlDisplay();
|
|
14701
|
+
init_probe();
|
|
14702
|
+
TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS = 1e3;
|
|
14703
|
+
CONNECT_SYN_RETRANSMISSIONS_TOLERATED = 2;
|
|
14704
|
+
DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS = TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS * (2 ** (CONNECT_SYN_RETRANSMISSIONS_TOLERATED + 1) - 1);
|
|
14705
|
+
startBaseUrlBatchProbe = (targets, workers) => {
|
|
14706
|
+
const started = startAddressProbes(targets.map((target) => ({ ...dialTargetOf(target.baseUrl), timeoutMs: target.timeoutMs })), workers);
|
|
14707
|
+
return { cancel: started.cancel, verdicts: started.settle };
|
|
14708
|
+
};
|
|
14709
|
+
realBaseUrlBatchProbe = (targets, workers) => startBaseUrlBatchProbe(targets, workers).verdicts();
|
|
14710
|
+
realStartBaseUrlProbe = (baseUrl, timeoutMs) => {
|
|
14711
|
+
const started = startBaseUrlBatchProbe([{ baseUrl, timeoutMs }]);
|
|
14712
|
+
return {
|
|
14713
|
+
cancel: started.cancel,
|
|
14714
|
+
verdict: () => {
|
|
14715
|
+
const [verdict] = started.verdicts();
|
|
14716
|
+
if (verdict === void 0) {
|
|
14717
|
+
throw new Error("the batch probe answered no verdict for one base URL");
|
|
14718
|
+
}
|
|
14719
|
+
return verdict;
|
|
14720
|
+
}
|
|
14721
|
+
};
|
|
14722
|
+
};
|
|
14723
|
+
realBaseUrlProbe = (baseUrl, timeoutMs) => realStartBaseUrlProbe(baseUrl, timeoutMs).verdict();
|
|
14401
14724
|
}
|
|
14402
14725
|
});
|
|
14403
14726
|
|
|
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, "");
|
|
14727
|
+
// src/models/tiers.ts
|
|
14728
|
+
function claudeNameTier(model) {
|
|
14729
|
+
const name = model.toLowerCase().replace(/\[1m\]$/, "");
|
|
14730
|
+
const parts = name.split("-");
|
|
14731
|
+
return parts[0] === "claude" ? CLAUDE_TIERS.find((tier) => parts.includes(tier)) : CLAUDE_TIERS.find((tier) => name === tier);
|
|
14410
14732
|
}
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14733
|
+
var TIER_ENV_VARIABLES;
|
|
14734
|
+
var init_tiers = __esm({
|
|
14735
|
+
"src/models/tiers.ts"() {
|
|
14736
|
+
"use strict";
|
|
14737
|
+
init_schema();
|
|
14738
|
+
TIER_ENV_VARIABLES = Object.freeze({
|
|
14739
|
+
fable: "ANTHROPIC_DEFAULT_FABLE_MODEL",
|
|
14740
|
+
opus: "ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
14741
|
+
sonnet: "ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
14742
|
+
haiku: "ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
|
14743
|
+
});
|
|
14421
14744
|
}
|
|
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
|
-
}
|
|
14745
|
+
});
|
|
14746
|
+
|
|
14747
|
+
// src/models/reservedModelNames.ts
|
|
14748
|
+
function reservedProviderNameReason(name) {
|
|
14749
|
+
const bare = withoutContextMarker(name);
|
|
14750
|
+
if (bare === AUTO_MODEL) {
|
|
14751
|
+
return `"${AUTO_MODEL}" is the model name that follows the server's live model`;
|
|
14437
14752
|
}
|
|
14438
|
-
|
|
14753
|
+
if (CLAUDE_CODE_ALIASES.has(bare.toLowerCase())) {
|
|
14754
|
+
return `"${name}" is a model alias Claude Code resolves itself`;
|
|
14755
|
+
}
|
|
14756
|
+
const tier = claudeNameTier(name);
|
|
14757
|
+
return tier === void 0 ? void 0 : `"${name}" is a Claude model name (the ${tier} tier)`;
|
|
14439
14758
|
}
|
|
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
|
-
};
|
|
14759
|
+
function requireUnreservedProviderName(name) {
|
|
14760
|
+
const reason = reservedProviderNameReason(name);
|
|
14761
|
+
if (reason !== void 0) {
|
|
14762
|
+
throw new InvalidProviderNameError(name, `must not be a bare model name, because ${reason}`);
|
|
14763
|
+
}
|
|
14470
14764
|
}
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14765
|
+
var AUTO_MODEL, CLAUDE_CODE_ALIASES;
|
|
14766
|
+
var init_reservedModelNames = __esm({
|
|
14767
|
+
"src/models/reservedModelNames.ts"() {
|
|
14768
|
+
"use strict";
|
|
14769
|
+
init_names();
|
|
14770
|
+
init_identity();
|
|
14771
|
+
init_tiers();
|
|
14772
|
+
AUTO_MODEL = "auto";
|
|
14773
|
+
CLAUDE_CODE_ALIASES = /* @__PURE__ */ new Set(["default", "best", "opusplan"]);
|
|
14476
14774
|
}
|
|
14477
|
-
|
|
14478
|
-
|
|
14775
|
+
});
|
|
14776
|
+
|
|
14777
|
+
// src/providerAliases.ts
|
|
14778
|
+
function parseAliases(file, raw) {
|
|
14779
|
+
const parsed = ProviderAliasesSchema.safeParse(raw);
|
|
14780
|
+
if (!parsed.success) {
|
|
14781
|
+
throw new ConfigValidationError(file, parsed.error.issues);
|
|
14479
14782
|
}
|
|
14480
|
-
return
|
|
14783
|
+
return parsed.data;
|
|
14481
14784
|
}
|
|
14482
|
-
function
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14785
|
+
function readProviderAliases(paths) {
|
|
14786
|
+
return readJson(paths.providerAliasesFile, ProviderAliasesSchema) ?? {};
|
|
14787
|
+
}
|
|
14788
|
+
function loadProviderAliases(file, port) {
|
|
14789
|
+
const raw = port.readConfigFile(file);
|
|
14790
|
+
return raw === void 0 ? {} : parseAliases(file, raw);
|
|
14791
|
+
}
|
|
14792
|
+
function canonicalProviderName(name, defined, aliases) {
|
|
14793
|
+
if (defined(name)) {
|
|
14794
|
+
return name;
|
|
14488
14795
|
}
|
|
14489
|
-
return
|
|
14796
|
+
return aliases()[name] ?? name;
|
|
14490
14797
|
}
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14798
|
+
function aliasFindings(aliases, providerNames) {
|
|
14799
|
+
return Object.entries(aliases).map(([alias, target]) => {
|
|
14800
|
+
if (!providerNames.has(target)) {
|
|
14801
|
+
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}\`.` };
|
|
14802
|
+
}
|
|
14803
|
+
if (providerNames.has(alias)) {
|
|
14804
|
+
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}\`.` };
|
|
14805
|
+
}
|
|
14806
|
+
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.` };
|
|
14807
|
+
});
|
|
14808
|
+
}
|
|
14809
|
+
var import_zod30, ProviderAliasesSchema;
|
|
14810
|
+
var init_providerAliases = __esm({
|
|
14811
|
+
"src/providerAliases.ts"() {
|
|
14494
14812
|
"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
|
-
});
|
|
14813
|
+
import_zod30 = require("zod");
|
|
14814
|
+
init_cliError();
|
|
14815
|
+
init_load();
|
|
14816
|
+
init_store();
|
|
14817
|
+
ProviderAliasesSchema = import_zod30.z.record(import_zod30.z.string().min(1), import_zod30.z.string().min(1));
|
|
14526
14818
|
}
|
|
14527
14819
|
});
|
|
14528
14820
|
|
|
@@ -14602,7 +14894,7 @@ var FAMILY_PREFIX, VARIANT_SEPARATOR;
|
|
|
14602
14894
|
var init_families = __esm({
|
|
14603
14895
|
"src/models/families.ts"() {
|
|
14604
14896
|
"use strict";
|
|
14605
|
-
|
|
14897
|
+
init_identity();
|
|
14606
14898
|
FAMILY_PREFIX = "family:";
|
|
14607
14899
|
VARIANT_SEPARATOR = "+";
|
|
14608
14900
|
}
|
|
@@ -14741,6 +15033,7 @@ function addProvider(paths, name, input) {
|
|
|
14741
15033
|
throw new ProviderAlreadyExistsError(name);
|
|
14742
15034
|
}
|
|
14743
15035
|
requireNewProviderName(name);
|
|
15036
|
+
requireUnreservedProviderName(name);
|
|
14744
15037
|
const kind = input.kind ?? "http";
|
|
14745
15038
|
if (kind === "codex" && input.baseUrl !== void 0) {
|
|
14746
15039
|
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 +15056,9 @@ function addProvider(paths, name, input) {
|
|
|
14763
15056
|
if (kind !== "http" && input.connectTimeoutMs !== void 0) {
|
|
14764
15057
|
throw new ProviderKindMismatchError("A connect timeout applies only to an http provider, the one kind that dials a base URL.");
|
|
14765
15058
|
}
|
|
15059
|
+
if (kind !== "http" && input.serverTools !== void 0) {
|
|
15060
|
+
throw new ProviderKindMismatchError("The server-tools setting applies only to an http provider.");
|
|
15061
|
+
}
|
|
14766
15062
|
if (kind !== "codex" && !isEmptyCodexConfig(input.codex)) {
|
|
14767
15063
|
throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
|
|
14768
15064
|
}
|
|
@@ -14776,7 +15072,7 @@ function addProvider(paths, name, input) {
|
|
|
14776
15072
|
...input.pickerModels === void 0 || input.pickerModels.length === 0 ? {} : { pickerModels: input.pickerModels }
|
|
14777
15073
|
};
|
|
14778
15074
|
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 } }
|
|
15075
|
+
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
15076
|
);
|
|
14781
15077
|
if (!parsed.success) {
|
|
14782
15078
|
throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
|
|
@@ -14814,6 +15110,9 @@ function updateProvider(paths, name, input) {
|
|
|
14814
15110
|
if ((isCodexProvider(existing) || isAntigravityProvider(existing)) && input.catalogue !== void 0 && input.catalogue !== false) {
|
|
14815
15111
|
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a model catalogue applies only to an http provider.`);
|
|
14816
15112
|
}
|
|
15113
|
+
if ((isCodexProvider(existing) || isAntigravityProvider(existing) || router) && input.serverTools !== void 0) {
|
|
15114
|
+
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; the server-tools setting applies only to an http provider.`);
|
|
15115
|
+
}
|
|
14817
15116
|
if (!isCodexProvider(existing) && !isEmptyCodexConfig(input.codex)) {
|
|
14818
15117
|
throw new ProviderKindMismatchError(`Provider "${name}" is not a codex provider; codex settings apply only to a codex provider.`);
|
|
14819
15118
|
}
|
|
@@ -14852,7 +15151,7 @@ function updateProvider(paths, name, input) {
|
|
|
14852
15151
|
} else {
|
|
14853
15152
|
const catalogue = input.catalogue === void 0 ? existing.catalogue : input.catalogue === false ? void 0 : input.catalogue;
|
|
14854
15153
|
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 } };
|
|
15154
|
+
candidate = { ...existing, ...shared, catalogue, connectTimeoutMs, ...input.serverTools === void 0 ? {} : { serverTools: input.serverTools }, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
|
|
14856
15155
|
}
|
|
14857
15156
|
const parsed = ProviderSchema.safeParse(candidate);
|
|
14858
15157
|
if (!parsed.success) {
|
|
@@ -14995,6 +15294,7 @@ var init_providersStore = __esm({
|
|
|
14995
15294
|
init_walk();
|
|
14996
15295
|
init_families();
|
|
14997
15296
|
init_names();
|
|
15297
|
+
init_reservedModelNames();
|
|
14998
15298
|
ProviderNotFoundError = class extends CliError {
|
|
14999
15299
|
constructor(name) {
|
|
15000
15300
|
super(`No provider named "${name}". Run \`agent-shim provider add ${name}\` first.`);
|
|
@@ -15036,513 +15336,477 @@ var init_providersStore = __esm({
|
|
|
15036
15336
|
}
|
|
15037
15337
|
});
|
|
15038
15338
|
|
|
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;
|
|
15339
|
+
// src/cli/bool.ts
|
|
15340
|
+
function parseBoolWord(input) {
|
|
15341
|
+
switch (input) {
|
|
15342
|
+
case "true":
|
|
15343
|
+
case "1":
|
|
15344
|
+
return true;
|
|
15345
|
+
case "false":
|
|
15346
|
+
case "0":
|
|
15347
|
+
return false;
|
|
15348
|
+
default:
|
|
15349
|
+
return void 0;
|
|
15055
15350
|
}
|
|
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
15351
|
}
|
|
15105
|
-
var
|
|
15106
|
-
"src/
|
|
15352
|
+
var init_bool = __esm({
|
|
15353
|
+
"src/cli/bool.ts"() {
|
|
15107
15354
|
"use strict";
|
|
15108
|
-
init_load();
|
|
15109
|
-
init_providersStore();
|
|
15110
|
-
init_identity();
|
|
15111
15355
|
}
|
|
15112
15356
|
});
|
|
15113
15357
|
|
|
15114
|
-
// src/
|
|
15115
|
-
function
|
|
15116
|
-
|
|
15117
|
-
|
|
15118
|
-
return fromEnv;
|
|
15358
|
+
// src/cli/envBool.ts
|
|
15359
|
+
function parseEnvBool(variable, value) {
|
|
15360
|
+
if (value === void 0 || value === "") {
|
|
15361
|
+
return void 0;
|
|
15119
15362
|
}
|
|
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;
|
|
15363
|
+
const parsed = parseBoolWord(value);
|
|
15364
|
+
if (parsed === void 0) {
|
|
15365
|
+
throw new InvalidEnvBoolError(variable, value);
|
|
15131
15366
|
}
|
|
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());
|
|
15367
|
+
return parsed;
|
|
15189
15368
|
}
|
|
15190
|
-
var
|
|
15191
|
-
var
|
|
15192
|
-
"src/
|
|
15369
|
+
var InvalidEnvBoolError;
|
|
15370
|
+
var init_envBool = __esm({
|
|
15371
|
+
"src/cli/envBool.ts"() {
|
|
15193
15372
|
"use strict";
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15373
|
+
init_cliError();
|
|
15374
|
+
init_bool();
|
|
15375
|
+
InvalidEnvBoolError = class extends UsageError {
|
|
15376
|
+
constructor(variable, value) {
|
|
15377
|
+
super(`${variable} must be one of true, false, 1 or 0, got "${value}".`);
|
|
15378
|
+
this.variable = variable;
|
|
15379
|
+
this.value = value;
|
|
15380
|
+
this.name = "InvalidEnvBoolError";
|
|
15381
|
+
}
|
|
15382
|
+
variable;
|
|
15383
|
+
value;
|
|
15384
|
+
};
|
|
15198
15385
|
}
|
|
15199
15386
|
});
|
|
15200
15387
|
|
|
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();
|
|
15388
|
+
// src/pathNorm.ts
|
|
15389
|
+
function expandTilde(value, home) {
|
|
15390
|
+
if (value === "~") {
|
|
15391
|
+
return home;
|
|
15392
|
+
}
|
|
15393
|
+
if (value.startsWith("~/")) {
|
|
15394
|
+
return import_node_path37.default.join(home, value.slice(2));
|
|
15395
|
+
}
|
|
15396
|
+
return value;
|
|
15214
15397
|
}
|
|
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();
|
|
15398
|
+
function normaliseRulePath(rulePath, home) {
|
|
15399
|
+
return import_node_path37.default.resolve(expandTilde(rulePath, home));
|
|
15218
15400
|
}
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
distinct.set(targetKey(target), target);
|
|
15401
|
+
var import_node_path37;
|
|
15402
|
+
var init_pathNorm = __esm({
|
|
15403
|
+
"src/pathNorm.ts"() {
|
|
15404
|
+
"use strict";
|
|
15405
|
+
import_node_path37 = __toESM(require("node:path"), 1);
|
|
15225
15406
|
}
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
const
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
|
|
15407
|
+
});
|
|
15408
|
+
|
|
15409
|
+
// src/launcher/cascade.ts
|
|
15410
|
+
function loadCascadeInput(params) {
|
|
15411
|
+
const globalConfig = loadConfigFile(params.paths.globalConfigFile, GlobalConfigSchema, params.read);
|
|
15412
|
+
const directoryRules = loadConfigFile(params.paths.directoryRulesFile, DirectoryRulesSchema, params.read);
|
|
15413
|
+
const loadProfile = (name) => {
|
|
15414
|
+
const filepath = profileFilePath(params.paths.configProfilesDir, name);
|
|
15415
|
+
const loaded = loadConfigFile(filepath, ConfigProfileSchema, params.read);
|
|
15416
|
+
if (loaded === void 0) {
|
|
15417
|
+
return void 0;
|
|
15234
15418
|
}
|
|
15419
|
+
return { name, profile: loaded.config, entryOrder: loaded.entryOrder, filepath: loaded.filepath };
|
|
15235
15420
|
};
|
|
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
|
-
}
|
|
15421
|
+
const limit = globalConfig?.config.walkUpLimit;
|
|
15422
|
+
const dirs = walkDirectoryAncestors(params.cwd, {
|
|
15423
|
+
home: params.home,
|
|
15424
|
+
...limit === void 0 ? {} : { limit: expandTilde(limit, params.home) },
|
|
15425
|
+
...params.isReadable === void 0 ? {} : { isReadable: params.isReadable }
|
|
15248
15426
|
});
|
|
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
|
-
}
|
|
15427
|
+
const levels = [];
|
|
15428
|
+
for (const dir of dirs) {
|
|
15429
|
+
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);
|
|
15430
|
+
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);
|
|
15431
|
+
const rules = (directoryRules?.config.rules ?? []).map((rule, index) => ({ rule, index })).filter(({ rule }) => normaliseRulePath(rule.path, params.home) === dir).map(({ rule, index }) => {
|
|
15432
|
+
const entryOrder = directoryRules?.ruleEntryOrders[index];
|
|
15433
|
+
return {
|
|
15434
|
+
rule,
|
|
15435
|
+
...entryOrder === void 0 ? {} : { entryOrder },
|
|
15436
|
+
filepath: params.paths.directoryRulesFile
|
|
15437
|
+
};
|
|
15438
|
+
});
|
|
15439
|
+
if (portable === void 0 && portableLocal === void 0 && rules.length === 0) {
|
|
15440
|
+
continue;
|
|
15266
15441
|
}
|
|
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 }
|
|
15442
|
+
levels.push({
|
|
15443
|
+
dir,
|
|
15444
|
+
...portable === void 0 ? {} : { portable: { config: portable.config, entryOrder: portable.entryOrder, filepath: portable.filepath } },
|
|
15445
|
+
...rules.length === 0 ? {} : { rules },
|
|
15446
|
+
...portableLocal === void 0 ? {} : { portableLocal: { config: portableLocal.config, entryOrder: portableLocal.entryOrder, filepath: portableLocal.filepath } }
|
|
15279
15447
|
});
|
|
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
15448
|
}
|
|
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();
|
|
15449
|
+
const input = {
|
|
15450
|
+
home: params.home,
|
|
15451
|
+
...globalConfig === void 0 ? {} : { globalConfig: { config: globalConfig.config, entryOrder: globalConfig.entryOrder, filepath: globalConfig.filepath } },
|
|
15452
|
+
...params.baseConfigProfile === void 0 ? {} : { baseConfigProfile: params.baseConfigProfile },
|
|
15453
|
+
loadProfile,
|
|
15454
|
+
levels,
|
|
15455
|
+
...params.cliOverride === void 0 ? {} : { cliOverride: params.cliOverride }
|
|
15456
|
+
};
|
|
15457
|
+
return { input, ...globalConfig === void 0 ? {} : { globalConfig: globalConfig.config } };
|
|
15458
|
+
}
|
|
15459
|
+
function readDirectorySelections(loaded) {
|
|
15460
|
+
let identity;
|
|
15461
|
+
let configProfile;
|
|
15462
|
+
for (const level of loaded.input.levels ?? []) {
|
|
15463
|
+
for (const source of [level.portable?.config, ...(level.rules ?? []).map((entry) => entry.rule), level.portableLocal?.config]) {
|
|
15464
|
+
if (source === void 0) {
|
|
15465
|
+
continue;
|
|
15466
|
+
}
|
|
15467
|
+
if (source.identity !== void 0) {
|
|
15468
|
+
identity = source.identity;
|
|
15469
|
+
}
|
|
15470
|
+
if (source.configProfile !== void 0) {
|
|
15471
|
+
configProfile = source.configProfile;
|
|
15314
15472
|
}
|
|
15315
|
-
},
|
|
15316
|
-
cancel: () => {
|
|
15317
|
-
void worker.terminate();
|
|
15318
15473
|
}
|
|
15319
|
-
}
|
|
15474
|
+
}
|
|
15475
|
+
return { ...identity === void 0 ? {} : { identity }, ...configProfile === void 0 ? {} : { configProfile } };
|
|
15320
15476
|
}
|
|
15321
|
-
var
|
|
15322
|
-
var
|
|
15323
|
-
"src/
|
|
15477
|
+
var import_node_path38, PORTABLE_CONFIG_FILENAME, PORTABLE_LOCAL_CONFIG_FILENAME;
|
|
15478
|
+
var init_cascade = __esm({
|
|
15479
|
+
"src/launcher/cascade.ts"() {
|
|
15324
15480
|
"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
|
-
|
|
15481
|
+
import_node_path38 = __toESM(require("node:path"), 1);
|
|
15482
|
+
init_load();
|
|
15483
|
+
init_schema();
|
|
15484
|
+
init_pathNorm();
|
|
15485
|
+
init_walk();
|
|
15486
|
+
init_legacy();
|
|
15487
|
+
init_names();
|
|
15488
|
+
PORTABLE_CONFIG_FILENAME = ".agent-shim.json";
|
|
15489
|
+
PORTABLE_LOCAL_CONFIG_FILENAME = ".agent-shim.local.json";
|
|
15490
|
+
}
|
|
15491
|
+
});
|
|
15492
|
+
|
|
15493
|
+
// src/launcher/memberProvider.ts
|
|
15494
|
+
function unreadableFileReason(error) {
|
|
15495
|
+
if (error instanceof ConfigValidationError) {
|
|
15496
|
+
return `${error.filepath} is invalid`;
|
|
15497
|
+
}
|
|
15498
|
+
if (error instanceof ConfigFileNotJsonError) {
|
|
15499
|
+
return error.message.replace(/\.$/, "");
|
|
15500
|
+
}
|
|
15501
|
+
if (error instanceof LegacyProviderFileError) {
|
|
15502
|
+
return `${error.filePath} uses ${error.conversion.fields.join(", ")}, which a credential block replaced`;
|
|
15503
|
+
}
|
|
15504
|
+
return void 0;
|
|
15505
|
+
}
|
|
15506
|
+
function memberProviderResolver(params) {
|
|
15507
|
+
if (params.cliProvider === false) {
|
|
15508
|
+
return () => void 0;
|
|
15509
|
+
}
|
|
15510
|
+
const cliProvider = params.cliProvider;
|
|
15511
|
+
const identities = identityReader(params.paths.identitiesDir, params.fs);
|
|
15512
|
+
const cascades = /* @__PURE__ */ new Map();
|
|
15513
|
+
const cascadeOver = (baseConfigProfile) => {
|
|
15514
|
+
const cached = cascades.get(baseConfigProfile);
|
|
15515
|
+
if (cached !== void 0) {
|
|
15516
|
+
return cached;
|
|
15358
15517
|
}
|
|
15518
|
+
const loaded = params.loadCascade(baseConfigProfile);
|
|
15519
|
+
cascades.set(baseConfigProfile, loaded);
|
|
15520
|
+
return loaded;
|
|
15359
15521
|
};
|
|
15360
|
-
|
|
15361
|
-
let
|
|
15522
|
+
return (name) => {
|
|
15523
|
+
let declared;
|
|
15362
15524
|
try {
|
|
15363
|
-
|
|
15364
|
-
} catch {
|
|
15365
|
-
|
|
15525
|
+
declared = identities.load(name);
|
|
15526
|
+
} catch (error) {
|
|
15527
|
+
if (!(error instanceof ConfigValidationError)) {
|
|
15528
|
+
throw error;
|
|
15529
|
+
}
|
|
15366
15530
|
}
|
|
15531
|
+
const profile = decideConfigProfile({
|
|
15532
|
+
env: params.env,
|
|
15533
|
+
...params.cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile: params.cliFlagConfigProfile },
|
|
15534
|
+
...params.directoryRuleConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: params.directoryRuleConfigProfile },
|
|
15535
|
+
...declared?.defaultConfigProfile === void 0 ? {} : { identityDefaultConfigProfile: declared.defaultConfigProfile },
|
|
15536
|
+
...params.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: params.globalDefaultConfigProfile }
|
|
15537
|
+
});
|
|
15538
|
+
const flagged = cliProvider !== void 0 && cliProvider !== "" ? cliProvider : void 0;
|
|
15539
|
+
let named = flagged ?? declared?.provider;
|
|
15367
15540
|
try {
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15541
|
+
const cascade = cascadeOver(profile.name);
|
|
15542
|
+
named = flagged ?? cascadeProviderName(cascade, declared?.provider);
|
|
15543
|
+
return selectedProviderName({
|
|
15544
|
+
paths: params.paths,
|
|
15545
|
+
port: params.fs,
|
|
15546
|
+
...cliProvider === void 0 ? {} : { cliProvider },
|
|
15547
|
+
cascade,
|
|
15548
|
+
...declared?.provider === void 0 ? {} : { identityProvider: declared.provider }
|
|
15549
|
+
});
|
|
15550
|
+
} catch (error) {
|
|
15551
|
+
const reason = unreadableFileReason(error);
|
|
15552
|
+
if (reason === void 0) {
|
|
15553
|
+
throw error;
|
|
15554
|
+
}
|
|
15555
|
+
return { ...named === void 0 ? {} : { named }, reason };
|
|
15372
15556
|
}
|
|
15373
15557
|
};
|
|
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));
|
|
15558
|
+
}
|
|
15559
|
+
var init_memberProvider = __esm({
|
|
15560
|
+
"src/launcher/memberProvider.ts"() {
|
|
15561
|
+
"use strict";
|
|
15562
|
+
init_load();
|
|
15563
|
+
init_providersStore();
|
|
15564
|
+
init_identity2();
|
|
15565
|
+
}
|
|
15408
15566
|
});
|
|
15409
|
-
|
|
15410
|
-
|
|
15411
|
-
|
|
15412
|
-
|
|
15413
|
-
|
|
15414
|
-
|
|
15415
|
-
|
|
15416
|
-
const
|
|
15417
|
-
const
|
|
15418
|
-
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
const
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
|
|
15567
|
+
|
|
15568
|
+
// src/paths.ts
|
|
15569
|
+
function resolveAgentShimHome(env = process.env, home = import_node_os5.default.homedir(), isDirectory = isExistingDirectory) {
|
|
15570
|
+
const fromEnv = env.AGENT_SHIM_HOME;
|
|
15571
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15572
|
+
return fromEnv;
|
|
15573
|
+
}
|
|
15574
|
+
const current = import_node_path39.default.join(home, HOME_DIRNAME);
|
|
15575
|
+
const legacy = import_node_path39.default.join(home, LEGACY_HOME_DIRNAME);
|
|
15576
|
+
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
15577
|
+
}
|
|
15578
|
+
function isExistingDirectory(candidate) {
|
|
15579
|
+
return import_node_fs12.default.statSync(candidate, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
15580
|
+
}
|
|
15581
|
+
function resolveClaudeHome() {
|
|
15582
|
+
const fromEnv = process.env.AGENT_SHIM_CLAUDE_HOME;
|
|
15583
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15584
|
+
return fromEnv;
|
|
15585
|
+
}
|
|
15586
|
+
return import_node_path39.default.join(import_node_os5.default.homedir(), ".claude");
|
|
15587
|
+
}
|
|
15588
|
+
function buildLayoutPaths(root) {
|
|
15589
|
+
return {
|
|
15590
|
+
root,
|
|
15591
|
+
identitiesDir: import_node_path39.default.join(root, "identities"),
|
|
15592
|
+
configProfilesDir: import_node_path39.default.join(root, "config-profiles"),
|
|
15593
|
+
providersDir: import_node_path39.default.join(root, "providers"),
|
|
15594
|
+
providerAliasesFile: import_node_path39.default.join(root, "provider-aliases.json"),
|
|
15595
|
+
directoryRulesFile: import_node_path39.default.join(root, "directory-rules.json"),
|
|
15596
|
+
activeIdentityFile: import_node_path39.default.join(root, "active-identity"),
|
|
15597
|
+
globalConfigFile: import_node_path39.default.join(root, "config.json"),
|
|
15598
|
+
categoriesLocalFile: import_node_path39.default.join(root, "categories.local.json"),
|
|
15599
|
+
claudeShimFile: import_node_path39.default.join(root, "claude-shim.json"),
|
|
15600
|
+
headroomDir: import_node_path39.default.join(root, "headroom"),
|
|
15601
|
+
headroomStateFile: import_node_path39.default.join(root, "headroom", "state.json"),
|
|
15602
|
+
headroomRoutingFile: import_node_path39.default.join(root, "headroom", "routing.json"),
|
|
15603
|
+
headroomLegacyStateFile: import_node_path39.default.join(root, "headroom", "state.v2.json"),
|
|
15604
|
+
headroomAllowlistFile: import_node_path39.default.join(root, "headroom", "run", "allowlist.txt"),
|
|
15605
|
+
headroomSocketDir: import_node_path39.default.join(root, "headroom", "run"),
|
|
15606
|
+
headroomLockFile: import_node_path39.default.join(root, "headroom", "start.lock"),
|
|
15607
|
+
headroomSessionsDir: import_node_path39.default.join(root, "headroom", "sessions"),
|
|
15608
|
+
logsDir: import_node_path39.default.join(root, "logs"),
|
|
15609
|
+
headroomLogPath: import_node_path39.default.join(root, "logs", "headroom.log"),
|
|
15610
|
+
frontdoorDir: import_node_path39.default.join(root, "frontdoor"),
|
|
15611
|
+
frontdoorCaDir: import_node_path39.default.join(root, "frontdoor", "ca"),
|
|
15612
|
+
frontdoorCaCertFile: import_node_path39.default.join(root, "frontdoor", "ca", "ca.pem"),
|
|
15613
|
+
frontdoorCaKeyFile: import_node_path39.default.join(root, "frontdoor", "ca", "ca.key"),
|
|
15614
|
+
frontdoorCaBundlesDir: import_node_path39.default.join(root, "frontdoor", "ca", "bundles"),
|
|
15615
|
+
chatgptSignInFile: import_node_path39.default.join(root, "codex", "chatgpt-sign-in.json"),
|
|
15616
|
+
frontdoorStateFile: import_node_path39.default.join(root, "frontdoor", "state.json"),
|
|
15617
|
+
frontdoorLockFile: import_node_path39.default.join(root, "frontdoor", "start.lock"),
|
|
15618
|
+
frontdoorControlTokenFile: import_node_path39.default.join(root, "frontdoor", "control-token"),
|
|
15619
|
+
frontdoorSessionsDir: import_node_path39.default.join(root, "frontdoor", "sessions"),
|
|
15620
|
+
frontdoorDirectRecordsDir: import_node_path39.default.join(root, "frontdoor", "direct"),
|
|
15621
|
+
frontdoorDrainingDir: import_node_path39.default.join(root, "frontdoor", "draining"),
|
|
15622
|
+
frontdoorRcCredentialsDir: import_node_path39.default.join(root, "frontdoor", "rc-credentials"),
|
|
15623
|
+
frontdoorLogPath: import_node_path39.default.join(root, "logs", "frontdoor.log"),
|
|
15624
|
+
usageDir: import_node_path39.default.join(root, "usage"),
|
|
15625
|
+
usageLogDir: import_node_path39.default.join(root, "usage", "log"),
|
|
15626
|
+
usageSnapshotsDir: import_node_path39.default.join(root, "usage", "snapshots"),
|
|
15627
|
+
statuslineDir: import_node_path39.default.join(root, "statusline"),
|
|
15628
|
+
catalogueDir: import_node_path39.default.join(root, "catalogues"),
|
|
15629
|
+
usagePicksFile: import_node_path39.default.join(root, "usage", "picks.json"),
|
|
15630
|
+
usageAnchorsFile: import_node_path39.default.join(root, "usage", "anchors.json"),
|
|
15631
|
+
usageJobsFile: import_node_path39.default.join(root, "usage", "jobs.json"),
|
|
15632
|
+
jobLogsDir: import_node_path39.default.join(root, "logs", "jobs"),
|
|
15633
|
+
identityRenamesDir: import_node_path39.default.join(root, "identity-renames"),
|
|
15634
|
+
identityNameRenamesDir: import_node_path39.default.join(root, "identity-name-renames"),
|
|
15635
|
+
launchesDir: import_node_path39.default.join(root, "launches"),
|
|
15636
|
+
superviseDir: import_node_path39.default.join(root, "supervise"),
|
|
15637
|
+
modelMovesDir: import_node_path39.default.join(root, "model-moves"),
|
|
15638
|
+
mcpPermissionsFile: import_node_path39.default.join(root, "mcp", "permissions.json")
|
|
15639
|
+
};
|
|
15640
|
+
}
|
|
15641
|
+
function resolveLayoutPaths() {
|
|
15642
|
+
return buildLayoutPaths(resolveAgentShimHome());
|
|
15643
|
+
}
|
|
15644
|
+
var import_node_fs12, import_node_os5, import_node_path39;
|
|
15645
|
+
var init_paths = __esm({
|
|
15646
|
+
"src/paths.ts"() {
|
|
15647
|
+
"use strict";
|
|
15648
|
+
import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
15649
|
+
import_node_os5 = __toESM(require("node:os"), 1);
|
|
15650
|
+
import_node_path39 = __toESM(require("node:path"), 1);
|
|
15651
|
+
init_legacy();
|
|
15652
|
+
}
|
|
15428
15653
|
});
|
|
15429
|
-
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15654
|
+
|
|
15655
|
+
// src/storedCatalogue.ts
|
|
15656
|
+
function catalogueReadFault(error) {
|
|
15657
|
+
if (error instanceof UnreadableCatalogueError) {
|
|
15658
|
+
return error.fault;
|
|
15659
|
+
}
|
|
15660
|
+
const code = error instanceof Error && "code" in error ? error.code : void 0;
|
|
15661
|
+
return typeof code === "string" && /^[A-Z0-9_]{1,32}$/u.test(code) ? code : error instanceof Error ? error.name : "an error";
|
|
15662
|
+
}
|
|
15663
|
+
function catalogueStatusFile(paths, owner, name) {
|
|
15664
|
+
return import_node_path41.default.join(import_node_path41.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), `${name}.status.json`);
|
|
15665
|
+
}
|
|
15666
|
+
function catalogueFailureFile(paths, owner, name) {
|
|
15667
|
+
return import_node_path41.default.join(import_node_path41.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), "failures", `${name}.json`);
|
|
15668
|
+
}
|
|
15669
|
+
var import_node_path41, UnreadableCatalogueError, skipUnreadableCatalogue, TolerantReader, StoredCatalogue;
|
|
15670
|
+
var init_storedCatalogue = __esm({
|
|
15671
|
+
"src/storedCatalogue.ts"() {
|
|
15672
|
+
"use strict";
|
|
15673
|
+
import_node_path41 = __toESM(require("node:path"), 1);
|
|
15674
|
+
init_providerCatalogue();
|
|
15675
|
+
UnreadableCatalogueError = class extends Error {
|
|
15676
|
+
fault;
|
|
15677
|
+
constructor(fault) {
|
|
15678
|
+
super(`stored catalogue cannot be read (${fault})`);
|
|
15679
|
+
this.name = "UnreadableCatalogueError";
|
|
15680
|
+
this.fault = fault;
|
|
15681
|
+
}
|
|
15682
|
+
};
|
|
15683
|
+
skipUnreadableCatalogue = () => void 0;
|
|
15684
|
+
TolerantReader = class {
|
|
15685
|
+
#read;
|
|
15686
|
+
#onUnreadable;
|
|
15687
|
+
constructor(read, onUnreadable) {
|
|
15688
|
+
this.#read = read;
|
|
15689
|
+
this.#onUnreadable = onUnreadable;
|
|
15690
|
+
}
|
|
15691
|
+
/** The text of `file`, `undefined` when it is absent or unreadable (`onUnreadable` returned). */
|
|
15692
|
+
read(file) {
|
|
15693
|
+
try {
|
|
15694
|
+
return this.#read(file);
|
|
15695
|
+
} catch (error) {
|
|
15696
|
+
this.#onUnreadable(catalogueReadFault(error));
|
|
15697
|
+
return void 0;
|
|
15443
15698
|
}
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
|
|
15699
|
+
}
|
|
15700
|
+
/** `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. */
|
|
15701
|
+
attempt(take) {
|
|
15702
|
+
try {
|
|
15703
|
+
return take();
|
|
15704
|
+
} catch (error) {
|
|
15705
|
+
this.#onUnreadable(catalogueReadFault(error));
|
|
15706
|
+
return void 0;
|
|
15447
15707
|
}
|
|
15448
15708
|
}
|
|
15449
15709
|
};
|
|
15450
|
-
|
|
15710
|
+
StoredCatalogue = class {
|
|
15711
|
+
#paths;
|
|
15712
|
+
#reader;
|
|
15713
|
+
constructor(paths, reader) {
|
|
15714
|
+
this.#paths = paths;
|
|
15715
|
+
this.#reader = reader;
|
|
15716
|
+
}
|
|
15717
|
+
/** 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. */
|
|
15718
|
+
cacheText(name, owner) {
|
|
15719
|
+
return this.#reader.read(catalogueCachePath(this.#paths, name, owner?.pid, owner?.generation));
|
|
15720
|
+
}
|
|
15721
|
+
/** The file holding the digest of the settings an `http` provider's catalogue was fetched under. */
|
|
15722
|
+
digestText(name) {
|
|
15723
|
+
return this.#reader.read(catalogueSettingsPath(this.#paths, name));
|
|
15724
|
+
}
|
|
15725
|
+
/** The non-secret binding between a Codex catalogue and the login that fetched it. */
|
|
15726
|
+
bindingText(name, owner) {
|
|
15727
|
+
return this.#reader.read(catalogueBindingPath(this.#paths, name, owner?.pid, owner?.generation));
|
|
15728
|
+
}
|
|
15729
|
+
/** The refresh status the supervisor generation `owner` recorded for `name`. */
|
|
15730
|
+
statusText(owner, name) {
|
|
15731
|
+
return this.#reader.read(catalogueStatusFile(this.#paths, owner, name));
|
|
15732
|
+
}
|
|
15733
|
+
/** The record of why `name`'s last refresh failed in the supervisor generation `owner`. */
|
|
15734
|
+
failureText(owner, name) {
|
|
15735
|
+
return this.#reader.read(catalogueFailureFile(this.#paths, owner, name));
|
|
15736
|
+
}
|
|
15737
|
+
/** 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. */
|
|
15738
|
+
revision(name, revisionOf) {
|
|
15739
|
+
const cacheRevision = this.#reader.attempt(() => revisionOf(catalogueCachePath(this.#paths, name)));
|
|
15740
|
+
const digestRevision = this.#reader.attempt(() => revisionOf(catalogueSettingsPath(this.#paths, name)));
|
|
15741
|
+
return cacheRevision === void 0 || digestRevision === void 0 ? void 0 : `${cacheRevision}\0${digestRevision}`;
|
|
15742
|
+
}
|
|
15743
|
+
};
|
|
15451
15744
|
}
|
|
15452
15745
|
});
|
|
15453
15746
|
|
|
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) };
|
|
15747
|
+
// src/tolerantReaders.ts
|
|
15748
|
+
function skippingReader(fs17) {
|
|
15749
|
+
return new TolerantReader((file) => fs17.readFileUtf8(file), skipUnreadableCatalogue);
|
|
15464
15750
|
}
|
|
15465
|
-
|
|
15466
|
-
|
|
15751
|
+
var init_tolerantReaders = __esm({
|
|
15752
|
+
"src/tolerantReaders.ts"() {
|
|
15753
|
+
"use strict";
|
|
15754
|
+
init_storedCatalogue();
|
|
15755
|
+
}
|
|
15756
|
+
});
|
|
15757
|
+
|
|
15758
|
+
// src/frontdoor/catalogueState.ts
|
|
15759
|
+
function readCatalogueFailure(fs17, paths, pid, generation, name) {
|
|
15760
|
+
const raw = new StoredCatalogue(paths, skippingReader(fs17)).failureText({ pid, generation }, name);
|
|
15761
|
+
if (raw === void 0) return void 0;
|
|
15762
|
+
try {
|
|
15763
|
+
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));
|
|
15764
|
+
return value.success ? { reason: value.data.reason, redirected: value.data.redirected === true, settings: value.data.settings } : void 0;
|
|
15765
|
+
} catch {
|
|
15467
15766
|
return void 0;
|
|
15468
15767
|
}
|
|
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
15768
|
}
|
|
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;
|
|
15769
|
+
function readCatalogueStatus(fs17, paths, pid, generation, name) {
|
|
15770
|
+
const raw = new StoredCatalogue(paths, skippingReader(fs17)).statusText({ pid, generation }, name);
|
|
15771
|
+
if (raw === void 0) return void 0;
|
|
15772
|
+
try {
|
|
15773
|
+
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));
|
|
15774
|
+
return value.success ? value.data : void 0;
|
|
15775
|
+
} catch {
|
|
15776
|
+
return void 0;
|
|
15777
|
+
}
|
|
15492
15778
|
}
|
|
15493
|
-
var
|
|
15494
|
-
var
|
|
15495
|
-
"src/
|
|
15779
|
+
var import_zod32, CATALOGUE_FAILURE_REASON_MAX_CHARS;
|
|
15780
|
+
var init_catalogueState = __esm({
|
|
15781
|
+
"src/frontdoor/catalogueState.ts"() {
|
|
15496
15782
|
"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();
|
|
15783
|
+
import_zod32 = require("zod");
|
|
15784
|
+
init_storedCatalogue();
|
|
15785
|
+
init_tolerantReaders();
|
|
15786
|
+
CATALOGUE_FAILURE_REASON_MAX_CHARS = 600;
|
|
15523
15787
|
}
|
|
15524
15788
|
});
|
|
15525
15789
|
|
|
15526
15790
|
// src/codex/auth.ts
|
|
15527
|
-
var
|
|
15791
|
+
var import_zod33, AuthFileSchema, TokenGrantSchema, CodexAuthError;
|
|
15528
15792
|
var init_auth = __esm({
|
|
15529
15793
|
"src/codex/auth.ts"() {
|
|
15530
15794
|
"use strict";
|
|
15531
|
-
|
|
15532
|
-
AuthFileSchema =
|
|
15533
|
-
tokens:
|
|
15534
|
-
access_token:
|
|
15535
|
-
refresh_token:
|
|
15536
|
-
id_token:
|
|
15537
|
-
account_id:
|
|
15795
|
+
import_zod33 = require("zod");
|
|
15796
|
+
AuthFileSchema = import_zod33.z.looseObject({
|
|
15797
|
+
tokens: import_zod33.z.looseObject({
|
|
15798
|
+
access_token: import_zod33.z.string().optional(),
|
|
15799
|
+
refresh_token: import_zod33.z.string().optional(),
|
|
15800
|
+
id_token: import_zod33.z.string().optional(),
|
|
15801
|
+
account_id: import_zod33.z.string().optional()
|
|
15538
15802
|
}).nullish(),
|
|
15539
|
-
last_refresh:
|
|
15803
|
+
last_refresh: import_zod33.z.string().optional()
|
|
15540
15804
|
});
|
|
15541
|
-
TokenGrantSchema =
|
|
15542
|
-
access_token:
|
|
15543
|
-
refresh_token:
|
|
15544
|
-
id_token:
|
|
15545
|
-
account_id:
|
|
15805
|
+
TokenGrantSchema = import_zod33.z.looseObject({
|
|
15806
|
+
access_token: import_zod33.z.string().min(1).optional(),
|
|
15807
|
+
refresh_token: import_zod33.z.string().min(1).optional(),
|
|
15808
|
+
id_token: import_zod33.z.string().min(1).optional(),
|
|
15809
|
+
account_id: import_zod33.z.string().min(1).optional()
|
|
15546
15810
|
});
|
|
15547
15811
|
CodexAuthError = class extends Error {
|
|
15548
15812
|
constructor(message) {
|
|
@@ -15554,31 +15818,31 @@ var init_auth = __esm({
|
|
|
15554
15818
|
});
|
|
15555
15819
|
|
|
15556
15820
|
// src/codex/siwc.ts
|
|
15557
|
-
var
|
|
15821
|
+
var import_zod34, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
15558
15822
|
var init_siwc = __esm({
|
|
15559
15823
|
"src/codex/siwc.ts"() {
|
|
15560
15824
|
"use strict";
|
|
15561
|
-
|
|
15825
|
+
import_zod34 = require("zod");
|
|
15562
15826
|
SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
15563
15827
|
SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
15564
15828
|
SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
15565
|
-
TokenResponseSchema =
|
|
15566
|
-
access_token:
|
|
15567
|
-
refresh_token:
|
|
15568
|
-
id_token:
|
|
15569
|
-
expires_in:
|
|
15570
|
-
scope:
|
|
15829
|
+
TokenResponseSchema = import_zod34.z.looseObject({
|
|
15830
|
+
access_token: import_zod34.z.string().min(1),
|
|
15831
|
+
refresh_token: import_zod34.z.string().min(1).optional(),
|
|
15832
|
+
id_token: import_zod34.z.string().min(1).optional(),
|
|
15833
|
+
expires_in: import_zod34.z.number().positive(),
|
|
15834
|
+
scope: import_zod34.z.string().optional()
|
|
15571
15835
|
});
|
|
15572
|
-
JwtHeaderSchema =
|
|
15573
|
-
IdTokenClaimsSchema =
|
|
15574
|
-
iss:
|
|
15575
|
-
sub:
|
|
15576
|
-
aud:
|
|
15577
|
-
exp:
|
|
15578
|
-
nonce:
|
|
15579
|
-
email:
|
|
15836
|
+
JwtHeaderSchema = import_zod34.z.looseObject({ alg: import_zod34.z.string(), kid: import_zod34.z.string().optional() });
|
|
15837
|
+
IdTokenClaimsSchema = import_zod34.z.looseObject({
|
|
15838
|
+
iss: import_zod34.z.string(),
|
|
15839
|
+
sub: import_zod34.z.string().min(1),
|
|
15840
|
+
aud: import_zod34.z.union([import_zod34.z.string(), import_zod34.z.array(import_zod34.z.string())]),
|
|
15841
|
+
exp: import_zod34.z.number(),
|
|
15842
|
+
nonce: import_zod34.z.string().optional(),
|
|
15843
|
+
email: import_zod34.z.string().optional()
|
|
15580
15844
|
});
|
|
15581
|
-
JwksSchema =
|
|
15845
|
+
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
15846
|
}
|
|
15583
15847
|
});
|
|
15584
15848
|
|
|
@@ -15596,25 +15860,25 @@ function parseSiwcFile(raw, filePath) {
|
|
|
15596
15860
|
}
|
|
15597
15861
|
return parsed.data;
|
|
15598
15862
|
}
|
|
15599
|
-
var
|
|
15863
|
+
var import_zod35, SiwcGrantSchema, SiwcFileSchema;
|
|
15600
15864
|
var init_siwcStore = __esm({
|
|
15601
15865
|
"src/codex/siwcStore.ts"() {
|
|
15602
15866
|
"use strict";
|
|
15603
|
-
|
|
15867
|
+
import_zod35 = require("zod");
|
|
15604
15868
|
init_auth();
|
|
15605
15869
|
init_siwc();
|
|
15606
|
-
SiwcGrantSchema =
|
|
15607
|
-
clientId:
|
|
15608
|
-
sub:
|
|
15609
|
-
email:
|
|
15610
|
-
idToken:
|
|
15611
|
-
accessToken:
|
|
15612
|
-
refreshToken:
|
|
15613
|
-
scopes:
|
|
15870
|
+
SiwcGrantSchema = import_zod35.z.strictObject({
|
|
15871
|
+
clientId: import_zod35.z.string().min(1),
|
|
15872
|
+
sub: import_zod35.z.string().min(1),
|
|
15873
|
+
email: import_zod35.z.string().optional(),
|
|
15874
|
+
idToken: import_zod35.z.string().min(1),
|
|
15875
|
+
accessToken: import_zod35.z.string().min(1),
|
|
15876
|
+
refreshToken: import_zod35.z.string().min(1),
|
|
15877
|
+
scopes: import_zod35.z.array(import_zod35.z.string()).readonly(),
|
|
15614
15878
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
15615
|
-
expiresAt:
|
|
15879
|
+
expiresAt: import_zod35.z.number()
|
|
15616
15880
|
});
|
|
15617
|
-
SiwcFileSchema =
|
|
15881
|
+
SiwcFileSchema = import_zod35.z.strictObject({ registeredClientId: import_zod35.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
15618
15882
|
}
|
|
15619
15883
|
});
|
|
15620
15884
|
|
|
@@ -15682,7 +15946,7 @@ function parseCatalogueBinding(raw) {
|
|
|
15682
15946
|
}
|
|
15683
15947
|
}
|
|
15684
15948
|
function catalogueCredentialFingerprint(cli, token, accountId) {
|
|
15685
|
-
return (0,
|
|
15949
|
+
return (0, import_node_crypto16.createHash)("sha256").update(JSON.stringify([cli, token, accountId])).digest("hex");
|
|
15686
15950
|
}
|
|
15687
15951
|
function cliCatalogueFingerprint(raw) {
|
|
15688
15952
|
if (raw === void 0) return void 0;
|
|
@@ -15701,36 +15965,21 @@ function signInCatalogueFingerprint(raw, filePath) {
|
|
|
15701
15965
|
const grant = parseSiwcFile(raw, filePath).grant;
|
|
15702
15966
|
return grant === void 0 ? void 0 : catalogueCredentialFingerprint(false, grant.accessToken, void 0);
|
|
15703
15967
|
}
|
|
15704
|
-
function savedCatalogueFingerprint(provider, paths, env, home,
|
|
15705
|
-
if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(read(paths.chatgptSignInFile), paths.chatgptSignInFile);
|
|
15968
|
+
function savedCatalogueFingerprint(provider, paths, env, home, reader) {
|
|
15969
|
+
if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(reader.read(paths.chatgptSignInFile), paths.chatgptSignInFile);
|
|
15706
15970
|
const configuredHome = env.CODEX_HOME;
|
|
15707
|
-
const codexHome = configuredHome === void 0 || configuredHome === "" ?
|
|
15708
|
-
return cliCatalogueFingerprint(read(
|
|
15971
|
+
const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path42.default.join(home, ".codex") : configuredHome;
|
|
15972
|
+
return cliCatalogueFingerprint(reader.read(import_node_path42.default.join(codexHome, "auth.json")));
|
|
15709
15973
|
}
|
|
15710
|
-
var
|
|
15974
|
+
var import_node_crypto16, import_node_path42, import_zod36, CatalogueBindingSchema;
|
|
15711
15975
|
var init_catalogueCredential = __esm({
|
|
15712
15976
|
"src/codex/catalogueCredential.ts"() {
|
|
15713
15977
|
"use strict";
|
|
15714
|
-
|
|
15715
|
-
|
|
15716
|
-
|
|
15978
|
+
import_node_crypto16 = require("node:crypto");
|
|
15979
|
+
import_node_path42 = __toESM(require("node:path"), 1);
|
|
15980
|
+
import_zod36 = require("zod");
|
|
15717
15981
|
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
|
-
});
|
|
15982
|
+
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
15983
|
}
|
|
15735
15984
|
});
|
|
15736
15985
|
|
|
@@ -15781,64 +16030,64 @@ var init_signatures = __esm({
|
|
|
15781
16030
|
});
|
|
15782
16031
|
|
|
15783
16032
|
// src/codex/anthropic.ts
|
|
15784
|
-
var
|
|
16033
|
+
var import_zod37, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
15785
16034
|
var init_anthropic = __esm({
|
|
15786
16035
|
"src/codex/anthropic.ts"() {
|
|
15787
16036
|
"use strict";
|
|
15788
|
-
|
|
15789
|
-
TextBlockSchema =
|
|
15790
|
-
Base64ImageSourceSchema =
|
|
15791
|
-
UrlImageSourceSchema =
|
|
15792
|
-
ImageBlockSchema =
|
|
15793
|
-
type:
|
|
15794
|
-
source:
|
|
16037
|
+
import_zod37 = require("zod");
|
|
16038
|
+
TextBlockSchema = import_zod37.z.looseObject({ type: import_zod37.z.literal("text"), text: import_zod37.z.string() });
|
|
16039
|
+
Base64ImageSourceSchema = import_zod37.z.looseObject({ type: import_zod37.z.literal("base64"), media_type: import_zod37.z.string().min(1), data: import_zod37.z.string() });
|
|
16040
|
+
UrlImageSourceSchema = import_zod37.z.looseObject({ type: import_zod37.z.literal("url"), url: import_zod37.z.string().min(1) });
|
|
16041
|
+
ImageBlockSchema = import_zod37.z.looseObject({
|
|
16042
|
+
type: import_zod37.z.literal("image"),
|
|
16043
|
+
source: import_zod37.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
15795
16044
|
});
|
|
15796
|
-
ToolUseBlockSchema =
|
|
15797
|
-
type:
|
|
15798
|
-
id:
|
|
15799
|
-
name:
|
|
15800
|
-
input:
|
|
16045
|
+
ToolUseBlockSchema = import_zod37.z.looseObject({
|
|
16046
|
+
type: import_zod37.z.literal("tool_use"),
|
|
16047
|
+
id: import_zod37.z.string().min(1),
|
|
16048
|
+
name: import_zod37.z.string().min(1),
|
|
16049
|
+
input: import_zod37.z.unknown()
|
|
15801
16050
|
});
|
|
15802
|
-
ToolResultContentBlockSchema =
|
|
15803
|
-
ToolResultBlockSchema =
|
|
15804
|
-
type:
|
|
15805
|
-
tool_use_id:
|
|
15806
|
-
content:
|
|
16051
|
+
ToolResultContentBlockSchema = import_zod37.z.union([TextBlockSchema, import_zod37.z.looseObject({ type: import_zod37.z.string() })]);
|
|
16052
|
+
ToolResultBlockSchema = import_zod37.z.looseObject({
|
|
16053
|
+
type: import_zod37.z.literal("tool_result"),
|
|
16054
|
+
tool_use_id: import_zod37.z.string().min(1),
|
|
16055
|
+
content: import_zod37.z.union([import_zod37.z.string(), import_zod37.z.array(ToolResultContentBlockSchema)]).optional()
|
|
15807
16056
|
});
|
|
15808
|
-
OtherBlockSchema =
|
|
15809
|
-
ContentBlockSchema =
|
|
15810
|
-
MessageSchema =
|
|
15811
|
-
role:
|
|
15812
|
-
content:
|
|
16057
|
+
OtherBlockSchema = import_zod37.z.looseObject({ type: import_zod37.z.string() });
|
|
16058
|
+
ContentBlockSchema = import_zod37.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
16059
|
+
MessageSchema = import_zod37.z.looseObject({
|
|
16060
|
+
role: import_zod37.z.enum(["user", "assistant", "system"]),
|
|
16061
|
+
content: import_zod37.z.union([import_zod37.z.string(), import_zod37.z.array(ContentBlockSchema)])
|
|
15813
16062
|
});
|
|
15814
|
-
ToolSchema =
|
|
15815
|
-
name:
|
|
15816
|
-
description:
|
|
15817
|
-
input_schema:
|
|
15818
|
-
allowed_domains:
|
|
15819
|
-
blocked_domains:
|
|
16063
|
+
ToolSchema = import_zod37.z.looseObject({
|
|
16064
|
+
name: import_zod37.z.string().min(1),
|
|
16065
|
+
description: import_zod37.z.string().optional(),
|
|
16066
|
+
input_schema: import_zod37.z.record(import_zod37.z.string(), import_zod37.z.unknown()).optional(),
|
|
16067
|
+
allowed_domains: import_zod37.z.array(import_zod37.z.string()).optional(),
|
|
16068
|
+
blocked_domains: import_zod37.z.array(import_zod37.z.string()).optional()
|
|
15820
16069
|
});
|
|
15821
|
-
ToolChoiceSchema =
|
|
15822
|
-
|
|
15823
|
-
|
|
16070
|
+
ToolChoiceSchema = import_zod37.z.union([
|
|
16071
|
+
import_zod37.z.looseObject({ type: import_zod37.z.enum(["auto", "none", "any"]) }),
|
|
16072
|
+
import_zod37.z.looseObject({ type: import_zod37.z.literal("tool"), name: import_zod37.z.string().min(1) })
|
|
15824
16073
|
]);
|
|
15825
|
-
SystemSchema =
|
|
15826
|
-
MessagesRequestSchema =
|
|
15827
|
-
model:
|
|
16074
|
+
SystemSchema = import_zod37.z.union([import_zod37.z.string(), import_zod37.z.array(import_zod37.z.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
16075
|
+
MessagesRequestSchema = import_zod37.z.looseObject({
|
|
16076
|
+
model: import_zod37.z.string().optional(),
|
|
15828
16077
|
system: SystemSchema.optional(),
|
|
15829
|
-
messages:
|
|
15830
|
-
tools:
|
|
16078
|
+
messages: import_zod37.z.array(MessageSchema),
|
|
16079
|
+
tools: import_zod37.z.array(ToolSchema).optional(),
|
|
15831
16080
|
tool_choice: ToolChoiceSchema.optional(),
|
|
15832
|
-
stream:
|
|
16081
|
+
stream: import_zod37.z.boolean().optional(),
|
|
15833
16082
|
/** `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:
|
|
16083
|
+
metadata: import_zod37.z.looseObject({ user_id: import_zod37.z.string().optional() }).optional(),
|
|
15835
16084
|
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
15836
|
-
output_config:
|
|
16085
|
+
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
16086
|
});
|
|
15838
|
-
CountTokensRequestSchema =
|
|
15839
|
-
system:
|
|
15840
|
-
messages:
|
|
15841
|
-
tools:
|
|
16087
|
+
CountTokensRequestSchema = import_zod37.z.looseObject({
|
|
16088
|
+
system: import_zod37.z.unknown().optional(),
|
|
16089
|
+
messages: import_zod37.z.unknown().optional(),
|
|
16090
|
+
tools: import_zod37.z.unknown().optional()
|
|
15842
16091
|
});
|
|
15843
16092
|
}
|
|
15844
16093
|
});
|
|
@@ -15887,7 +16136,7 @@ var AUTO_ALIAS;
|
|
|
15887
16136
|
var init_translate = __esm({
|
|
15888
16137
|
"src/antigravity/translate.ts"() {
|
|
15889
16138
|
"use strict";
|
|
15890
|
-
|
|
16139
|
+
init_identity();
|
|
15891
16140
|
init_tiers();
|
|
15892
16141
|
init_engine();
|
|
15893
16142
|
init_quota();
|
|
@@ -16048,7 +16297,7 @@ var init_modelPicker = __esm({
|
|
|
16048
16297
|
init_translate2();
|
|
16049
16298
|
init_providerCatalogue();
|
|
16050
16299
|
init_schema();
|
|
16051
|
-
|
|
16300
|
+
init_identity();
|
|
16052
16301
|
init_families();
|
|
16053
16302
|
init_modelsStore();
|
|
16054
16303
|
init_tiers();
|
|
@@ -16068,13 +16317,17 @@ function providerModels(paths) {
|
|
|
16068
16317
|
const supervisorPid = recordedPid !== void 0 && realIsProcessAlive(recordedPid) ? recordedPid : void 0;
|
|
16069
16318
|
const doorRecord = supervisorPid === void 0 ? void 0 : readFrontDoorCodexRecord(realFarmFs, paths.frontdoorDir, supervisorPid);
|
|
16070
16319
|
const doorHome = doorRecord?.codexHome;
|
|
16320
|
+
const reader = new TolerantReader((file) => realFsPort.readFileUtf8(file), skipUnreadableCatalogue);
|
|
16321
|
+
const files = new StoredCatalogue(paths, reader);
|
|
16071
16322
|
return listProviders(paths).flatMap((entry) => {
|
|
16072
16323
|
if (entry.provider.kind === "codex" && supervisorPid !== void 0 && doorRecord === void 0) return [];
|
|
16073
|
-
const
|
|
16324
|
+
const owner = supervisorPid === void 0 || doorRecord === void 0 ? void 0 : { pid: supervisorPid, generation: doorRecord.generation };
|
|
16325
|
+
const stored = parseCatalogueCache(files.cacheText(entry.name, entry.provider.kind === "codex" ? owner : void 0));
|
|
16326
|
+
const catalogue = stored !== void 0 && isHttpProvider(entry.provider) && !catalogueMatchesSettings(parseCatalogueSettings(files.digestText(entry.name)), stored, entry.provider) ? void 0 : stored;
|
|
16074
16327
|
if (entry.provider.kind === "codex") {
|
|
16075
16328
|
if (catalogue !== void 0 && catalogue.supervisorPid !== supervisorPid) return [];
|
|
16076
16329
|
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(),
|
|
16330
|
+
const fingerprint = savedCatalogueFingerprint(entry.provider, paths, env, import_node_os7.default.homedir(), reader);
|
|
16078
16331
|
if (fingerprint === void 0 || catalogue?.credentialFingerprint !== fingerprint) return [];
|
|
16079
16332
|
}
|
|
16080
16333
|
return providerModelRows(entry.provider, catalogue?.models).map((row) => ({ provider: entry.name, model: row.model }));
|
|
@@ -16091,7 +16344,9 @@ var init_targets = __esm({
|
|
|
16091
16344
|
init_catalogueCredential();
|
|
16092
16345
|
init_state();
|
|
16093
16346
|
init_modelPicker();
|
|
16347
|
+
init_schema();
|
|
16094
16348
|
init_providerCatalogue();
|
|
16349
|
+
init_storedCatalogue();
|
|
16095
16350
|
init_providersStore();
|
|
16096
16351
|
init_realPorts();
|
|
16097
16352
|
}
|
|
@@ -16315,7 +16570,7 @@ function ensureFrontDoor(params) {
|
|
|
16315
16570
|
if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
|
|
16316
16571
|
if (state?.port !== void 0 && state.connectPort !== void 0) {
|
|
16317
16572
|
if (supervisorPid === params.launcherPid && params.replace === void 0 && ports.isFrontDoorSupervisor(supervisorPid)) {
|
|
16318
|
-
const token = (0,
|
|
16573
|
+
const token = (0, import_node_crypto17.randomUUID)();
|
|
16319
16574
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid, ...recordOf(params.session) });
|
|
16320
16575
|
return { port: state.port, connectPort: state.connectPort, token, supervisorPid };
|
|
16321
16576
|
}
|
|
@@ -16336,7 +16591,7 @@ function ensureFrontDoor(params) {
|
|
|
16336
16591
|
continue;
|
|
16337
16592
|
}
|
|
16338
16593
|
if (verdict.ok) {
|
|
16339
|
-
const token = (0,
|
|
16594
|
+
const token = (0, import_node_crypto17.randomUUID)();
|
|
16340
16595
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid, ...recordOf(params.session) });
|
|
16341
16596
|
return { port: state.port, connectPort: state.connectPort, token, supervisorPid };
|
|
16342
16597
|
}
|
|
@@ -16389,11 +16644,11 @@ function ensureFrontDoor(params) {
|
|
|
16389
16644
|
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
16390
16645
|
}
|
|
16391
16646
|
}
|
|
16392
|
-
var
|
|
16647
|
+
var import_node_crypto17, FRONTDOOR_START_TIMEOUT_MS, FRONTDOOR_LAUNCHER_POLL_MS, FRONTDOOR_PROBE_ATTEMPTS, FRONTDOOR_EXIT_GRACE_MS, FrontDoorStartError;
|
|
16393
16648
|
var init_ensure2 = __esm({
|
|
16394
16649
|
"src/frontdoor/ensure.ts"() {
|
|
16395
16650
|
"use strict";
|
|
16396
|
-
|
|
16651
|
+
import_node_crypto17 = require("node:crypto");
|
|
16397
16652
|
init_cliError();
|
|
16398
16653
|
init_state2();
|
|
16399
16654
|
init_replacement();
|
|
@@ -16792,7 +17047,7 @@ function buildEnv(params) {
|
|
|
16792
17047
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
16793
17048
|
let providerCustomHeaders;
|
|
16794
17049
|
if (!params.configDirEscapeHatch && params.identityId !== void 0) {
|
|
16795
|
-
env.CLAUDE_CONFIG_DIR =
|
|
17050
|
+
env.CLAUDE_CONFIG_DIR = import_node_path50.default.join(params.identitiesDir, params.identityId);
|
|
16796
17051
|
}
|
|
16797
17052
|
if (params.provider !== void 0) {
|
|
16798
17053
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
@@ -16869,11 +17124,11 @@ function buildEnv(params) {
|
|
|
16869
17124
|
injections.finish();
|
|
16870
17125
|
return env;
|
|
16871
17126
|
}
|
|
16872
|
-
var
|
|
17127
|
+
var import_node_path50, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
|
|
16873
17128
|
var init_flags = __esm({
|
|
16874
17129
|
"src/launcher/flags.ts"() {
|
|
16875
17130
|
"use strict";
|
|
16876
|
-
|
|
17131
|
+
import_node_path50 = __toESM(require("node:path"), 1);
|
|
16877
17132
|
init_envBool();
|
|
16878
17133
|
init_cliError();
|
|
16879
17134
|
init_conditions();
|
|
@@ -16966,7 +17221,7 @@ function newestTranscript(fs17, projectDir) {
|
|
|
16966
17221
|
if (!name.endsWith(".jsonl")) {
|
|
16967
17222
|
continue;
|
|
16968
17223
|
}
|
|
16969
|
-
const candidate =
|
|
17224
|
+
const candidate = import_node_path51.default.join(projectDir, name);
|
|
16970
17225
|
const stat = fs17.lstat(candidate);
|
|
16971
17226
|
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
16972
17227
|
newestMs = stat.mtimeMs;
|
|
@@ -16980,16 +17235,16 @@ function resumedContextTokens(fs17, params) {
|
|
|
16980
17235
|
if (target === void 0) {
|
|
16981
17236
|
return void 0;
|
|
16982
17237
|
}
|
|
16983
|
-
const projectDir =
|
|
16984
|
-
const file = target.kind === "id" ?
|
|
17238
|
+
const projectDir = import_node_path51.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
17239
|
+
const file = target.kind === "id" ? import_node_path51.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
|
|
16985
17240
|
const text = file === void 0 ? void 0 : fs17.readFileUtf8(file);
|
|
16986
17241
|
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
16987
17242
|
}
|
|
16988
|
-
var
|
|
17243
|
+
var import_node_path51;
|
|
16989
17244
|
var init_resumeContext = __esm({
|
|
16990
17245
|
"src/usage/resumeContext.ts"() {
|
|
16991
17246
|
"use strict";
|
|
16992
|
-
|
|
17247
|
+
import_node_path51 = __toESM(require("node:path"), 1);
|
|
16993
17248
|
}
|
|
16994
17249
|
});
|
|
16995
17250
|
|
|
@@ -17486,7 +17741,7 @@ var RESUME_FLAGS, TERMINATOR3, REASONS_LOGGED;
|
|
|
17486
17741
|
var init_pool = __esm({
|
|
17487
17742
|
"src/launcher/pool.ts"() {
|
|
17488
17743
|
"use strict";
|
|
17489
|
-
|
|
17744
|
+
init_identity2();
|
|
17490
17745
|
init_preflight();
|
|
17491
17746
|
init_poolPick();
|
|
17492
17747
|
RESUME_FLAGS = /* @__PURE__ */ new Set(["--continue", "-c", "--resume", "-r"]);
|
|
@@ -17695,7 +17950,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17695
17950
|
const farmIdentity = configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : resolveIdentityId(paths.identitiesDir, identityDecision.name, fs17);
|
|
17696
17951
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
17697
17952
|
if (!readOnly && params.supervised?.member === void 0 && farmIdentity !== void 0 && identityDecision.name !== void 0) {
|
|
17698
|
-
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name,
|
|
17953
|
+
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name, import_node_path52.default.join(paths.identitiesDir, farmIdentity));
|
|
17699
17954
|
}
|
|
17700
17955
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
17701
17956
|
try {
|
|
@@ -17876,25 +18131,27 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17876
18131
|
const doorRecord = doorPid === void 0 ? void 0 : readFrontDoorCodexRecord(params.fs, paths.frontdoorDir, doorPid);
|
|
17877
18132
|
const doorHome = doorRecord?.codexHome;
|
|
17878
18133
|
const catalogueEnv = doorHome === void 0 ? env : { ...env, CODEX_HOME: doorHome };
|
|
18134
|
+
const reader = new TolerantReader((file) => params.fs.readFileUtf8(file), skipUnreadableCatalogue);
|
|
18135
|
+
const stored = new StoredCatalogue(paths, reader);
|
|
17879
18136
|
const listedProviders = listProviderNames(fs17.readdir, paths.providersDir).flatMap((name) => {
|
|
17880
18137
|
try {
|
|
17881
18138
|
const definition = loadProvider(paths.providersDir, name, fs17);
|
|
17882
18139
|
if (definition === void 0) return [];
|
|
17883
|
-
const
|
|
17884
|
-
const
|
|
17885
|
-
const cache = parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, name, catalogueOwner, generation)));
|
|
18140
|
+
const owner = definition.kind === "codex" && doorPid !== void 0 && doorRecord !== void 0 ? { pid: doorPid, generation: doorRecord.generation } : void 0;
|
|
18141
|
+
const cache = parseCatalogueCache(stored.cacheText(name, owner));
|
|
17886
18142
|
if (definition.kind === "codex" && cache !== void 0 && cache.supervisorPid !== doorPid) return [];
|
|
17887
18143
|
if (definition.kind === "codex" && doorPid !== void 0 && doorRecord === void 0) return [];
|
|
17888
18144
|
if (definition.kind === "codex" && readOnly && cache !== void 0) {
|
|
17889
|
-
const binding = parseCatalogueBinding(
|
|
18145
|
+
const binding = parseCatalogueBinding(stored.bindingText(name, owner));
|
|
17890
18146
|
const configuredHome = catalogueEnv.CODEX_HOME;
|
|
17891
|
-
const home = configuredHome === void 0 || configuredHome === "" ?
|
|
17892
|
-
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile :
|
|
18147
|
+
const home = configuredHome === void 0 || configuredHome === "" ? import_node_path52.default.join(import_node_os9.default.homedir(), ".codex") : configuredHome;
|
|
18148
|
+
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : import_node_path52.default.resolve(home, "auth.json");
|
|
17893
18149
|
const revision = params.fs.fileRevision?.(source);
|
|
17894
18150
|
if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
|
|
17895
18151
|
}
|
|
17896
|
-
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, import_node_os9.default.homedir(),
|
|
18152
|
+
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, import_node_os9.default.homedir(), reader) : void 0;
|
|
17897
18153
|
if (definition.kind === "codex" && !readOnly && cache !== void 0 && (fingerprint === void 0 || cache.credentialFingerprint !== fingerprint)) return [];
|
|
18154
|
+
if (isHttpProvider(definition) && cache !== void 0 && !catalogueMatchesSettings(parseCatalogueSettings(stored.digestText(name)), cache, definition)) return [[name, definition, []]];
|
|
17898
18155
|
return [[name, definition, cache?.models ?? []]];
|
|
17899
18156
|
} catch {
|
|
17900
18157
|
return [];
|
|
@@ -17910,7 +18167,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17910
18167
|
return { args: args2, pickerSuppressed: startsSession && pickerSettings !== void 0 && callerSettings };
|
|
17911
18168
|
};
|
|
17912
18169
|
const args = argsForSupervisor().args;
|
|
17913
|
-
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR :
|
|
18170
|
+
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path52.default.join(paths.identitiesDir, farmIdentity);
|
|
17914
18171
|
const decision = {
|
|
17915
18172
|
identitySource: identityDecision.source,
|
|
17916
18173
|
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
@@ -18006,7 +18263,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18006
18263
|
let warnings = [];
|
|
18007
18264
|
const updateCheck = runLaunchUpdateCheck({
|
|
18008
18265
|
mode: params.updateMode ?? "off",
|
|
18009
|
-
checkPath:
|
|
18266
|
+
checkPath: import_node_path52.default.join(paths.root, "update.check"),
|
|
18010
18267
|
currentVersion: package_default.version,
|
|
18011
18268
|
port: params.update
|
|
18012
18269
|
});
|
|
@@ -18029,7 +18286,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18029
18286
|
classification: resyncFarmRuntime.classification,
|
|
18030
18287
|
now: resyncFarmRuntime.now,
|
|
18031
18288
|
uniqueSuffix: resyncFarmRuntime.uniqueSuffix,
|
|
18032
|
-
identityExists: () => params.fs.readConfigFile(
|
|
18289
|
+
identityExists: () => params.fs.readConfigFile(import_node_path52.default.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
|
|
18033
18290
|
lock: resyncFarmRuntime.lock
|
|
18034
18291
|
});
|
|
18035
18292
|
} catch (error) {
|
|
@@ -18063,7 +18320,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18063
18320
|
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
18321
|
proc.exit(1);
|
|
18065
18322
|
}
|
|
18066
|
-
const sessionId = params.supervised?.sessionId ?? (0,
|
|
18323
|
+
const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto18.randomUUID)();
|
|
18067
18324
|
const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
|
|
18068
18325
|
const sessionModels = (0, import_node_util2.isDeepStrictEqual)(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
|
|
18069
18326
|
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels } };
|
|
@@ -18177,15 +18434,15 @@ function runLaunchPlan(plan, spawn3) {
|
|
|
18177
18434
|
function runLauncher(params) {
|
|
18178
18435
|
params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
|
|
18179
18436
|
}
|
|
18180
|
-
var
|
|
18437
|
+
var import_node_crypto18, import_node_os9, import_node_util2, import_node_path52;
|
|
18181
18438
|
var init_launcher = __esm({
|
|
18182
18439
|
"src/launcher.ts"() {
|
|
18183
18440
|
"use strict";
|
|
18184
|
-
|
|
18441
|
+
import_node_crypto18 = require("node:crypto");
|
|
18185
18442
|
import_node_os9 = __toESM(require("node:os"), 1);
|
|
18186
18443
|
init_catalogueCredential();
|
|
18187
18444
|
import_node_util2 = require("node:util");
|
|
18188
|
-
|
|
18445
|
+
import_node_path52 = __toESM(require("node:path"), 1);
|
|
18189
18446
|
init_package();
|
|
18190
18447
|
init_envBool();
|
|
18191
18448
|
init_argv();
|
|
@@ -18196,7 +18453,7 @@ var init_launcher = __esm({
|
|
|
18196
18453
|
init_guard();
|
|
18197
18454
|
init_identityRecords();
|
|
18198
18455
|
init_identityNameRenameRecord();
|
|
18199
|
-
|
|
18456
|
+
init_identity2();
|
|
18200
18457
|
init_flags();
|
|
18201
18458
|
init_extraFlags();
|
|
18202
18459
|
init_claudeSession();
|
|
@@ -18207,6 +18464,7 @@ var init_launcher = __esm({
|
|
|
18207
18464
|
init_modelPicker();
|
|
18208
18465
|
init_state();
|
|
18209
18466
|
init_providerCatalogue();
|
|
18467
|
+
init_storedCatalogue();
|
|
18210
18468
|
init_providersStore();
|
|
18211
18469
|
init_memberProvider();
|
|
18212
18470
|
init_pool();
|
|
@@ -18238,13 +18496,13 @@ function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string"
|
|
|
18238
18496
|
if (distDir === void 0) {
|
|
18239
18497
|
throw new OwnCliPathUnknownError();
|
|
18240
18498
|
}
|
|
18241
|
-
return
|
|
18499
|
+
return import_node_path53.default.join(distDir, OWN_CLI_FILE_NAME);
|
|
18242
18500
|
}
|
|
18243
|
-
var
|
|
18501
|
+
var import_node_path53, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
18244
18502
|
var init_ownCli = __esm({
|
|
18245
18503
|
"src/ownCli.ts"() {
|
|
18246
18504
|
"use strict";
|
|
18247
|
-
|
|
18505
|
+
import_node_path53 = __toESM(require("node:path"), 1);
|
|
18248
18506
|
init_cliError();
|
|
18249
18507
|
OWN_CLI_FILE_NAME = "cli.cjs";
|
|
18250
18508
|
OwnCliPathUnknownError = class extends CliError {
|
|
@@ -18287,7 +18545,7 @@ var init_selfIdentity = __esm({
|
|
|
18287
18545
|
// src/frontdoor/trust.ts
|
|
18288
18546
|
function resolveTrustBundle(params) {
|
|
18289
18547
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs17 } = params;
|
|
18290
|
-
if (inherited === void 0 || inherited === "" ||
|
|
18548
|
+
if (inherited === void 0 || inherited === "" || import_node_path54.default.resolve(inherited) === import_node_path54.default.resolve(caCertFile)) {
|
|
18291
18549
|
return { path: caCertFile };
|
|
18292
18550
|
}
|
|
18293
18551
|
const caPem = fs17.readFileUtf8(caCertFile);
|
|
@@ -18305,19 +18563,19 @@ function resolveTrustBundle(params) {
|
|
|
18305
18563
|
}
|
|
18306
18564
|
const combined = `${inheritedPem.trimEnd()}
|
|
18307
18565
|
${caPem}`;
|
|
18308
|
-
const bundle =
|
|
18566
|
+
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
18567
|
if (!fs17.exists(bundle)) {
|
|
18310
18568
|
fs17.mkdirp(bundlesDir);
|
|
18311
18569
|
fs17.writeFileAtomic(bundle, combined);
|
|
18312
18570
|
}
|
|
18313
18571
|
return { path: bundle };
|
|
18314
18572
|
}
|
|
18315
|
-
var
|
|
18573
|
+
var import_node_crypto19, import_node_path54, BUNDLE_NAME_HEX_DIGITS;
|
|
18316
18574
|
var init_trust = __esm({
|
|
18317
18575
|
"src/frontdoor/trust.ts"() {
|
|
18318
18576
|
"use strict";
|
|
18319
|
-
|
|
18320
|
-
|
|
18577
|
+
import_node_crypto19 = require("node:crypto");
|
|
18578
|
+
import_node_path54 = __toESM(require("node:path"), 1);
|
|
18321
18579
|
BUNDLE_NAME_HEX_DIGITS = 16;
|
|
18322
18580
|
}
|
|
18323
18581
|
});
|
|
@@ -18366,35 +18624,49 @@ function realFrontDoorPort(paths, spawnDaemon) {
|
|
|
18366
18624
|
return {
|
|
18367
18625
|
waitForCatalogues: (supervisorPid) => {
|
|
18368
18626
|
const timedOut = deadlineAfter(CATALOGUE_REFRESH_DEADLINE_MS);
|
|
18627
|
+
const stored = new StoredCatalogue(paths, new TolerantReader((file) => realFarmFs.readFileUtf8(file), skipUnreadableCatalogue));
|
|
18369
18628
|
let requested = false;
|
|
18370
18629
|
const warnings = /* @__PURE__ */ new Set();
|
|
18371
18630
|
while (!isDeclaredFrontDoor(supervisorPid) && listProviders(paths).map(({ name, provider }) => {
|
|
18372
18631
|
const owner = readFrontDoorCodexRecord(realFarmFs, paths.frontdoorDir, supervisorPid);
|
|
18373
18632
|
const published = owner === void 0 ? void 0 : readCatalogueStatus(realFarmFs, paths, supervisorPid, owner.generation, name);
|
|
18374
|
-
|
|
18633
|
+
const failedUnderCurrentSettings = () => {
|
|
18634
|
+
if (!isHttpProvider(provider) || owner === void 0) return true;
|
|
18635
|
+
if (provider.catalogue === void 0) return false;
|
|
18636
|
+
const recorded = readCatalogueFailure(realFarmFs, paths, supervisorPid, owner.generation, name)?.settings;
|
|
18637
|
+
return recorded === void 0 || recorded === catalogueSettingsFingerprint(provider);
|
|
18638
|
+
};
|
|
18639
|
+
if (provider.kind !== "codex" && published?.status === "failed" && published.recordedAt !== void 0 && within(published.recordedAt, Date.now(), CATALOGUE_RETRY_MS) && failedUnderCurrentSettings()) {
|
|
18375
18640
|
warnings.add(`Catalogue refresh failed for ${name}`);
|
|
18376
18641
|
return false;
|
|
18377
18642
|
}
|
|
18378
18643
|
if (provider.kind === "codex") {
|
|
18379
18644
|
if (owner === void 0) return true;
|
|
18380
|
-
const cache2 = parseCatalogueCache(
|
|
18645
|
+
const cache2 = parseCatalogueCache(stored.cacheText(name, { pid: supervisorPid, generation: owner.generation }));
|
|
18381
18646
|
let fingerprint;
|
|
18647
|
+
let loginFault;
|
|
18382
18648
|
try {
|
|
18383
|
-
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, import_node_os10.default.homedir(), realFarmFs.readFileUtf8)
|
|
18649
|
+
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, import_node_os10.default.homedir(), new TolerantReader((file) => realFarmFs.readFileUtf8(file), (fault) => {
|
|
18650
|
+
loginFault = fault;
|
|
18651
|
+
}));
|
|
18384
18652
|
} catch (error) {
|
|
18385
18653
|
warnings.add(`Cannot read catalogue credentials for ${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
18386
18654
|
return false;
|
|
18387
18655
|
}
|
|
18656
|
+
if (loginFault !== void 0) {
|
|
18657
|
+
warnings.add(`Cannot read the catalogue credentials for ${name} (${loginFault})`);
|
|
18658
|
+
return false;
|
|
18659
|
+
}
|
|
18388
18660
|
const outcome = readCatalogueStatus(realFarmFs, paths, supervisorPid, owner.generation, name);
|
|
18389
|
-
if (outcome?.status === "failed" && outcome.fingerprint === fingerprint && outcome.recordedAt !== void 0 && outcome.recordedAt
|
|
18661
|
+
if (outcome?.status === "failed" && outcome.fingerprint === fingerprint && outcome.recordedAt !== void 0 && within(outcome.recordedAt, Date.now(), CATALOGUE_RETRY_MS)) {
|
|
18390
18662
|
warnings.add(`Catalogue refresh failed for ${name}`);
|
|
18391
18663
|
return false;
|
|
18392
18664
|
}
|
|
18393
18665
|
return cache2 === void 0 || isCatalogueStale(cache2, Date.now()) || cache2.supervisorPid !== supervisorPid || fingerprint === void 0 || cache2.credentialFingerprint !== fingerprint;
|
|
18394
18666
|
}
|
|
18395
18667
|
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());
|
|
18668
|
+
const cache = parseCatalogueCache(stored.cacheText(name));
|
|
18669
|
+
return cache === void 0 || isCatalogueStale(cache, Date.now()) || !catalogueMatchesSettings(parseCatalogueSettings(stored.digestText(name)), cache, provider);
|
|
18398
18670
|
}).some(Boolean)) {
|
|
18399
18671
|
if (timedOut()) return [...warnings, "Timed out waiting for provider catalogues"].join("; ");
|
|
18400
18672
|
if (!requested) {
|
|
@@ -18437,12 +18709,16 @@ var init_realFrontDoorPort = __esm({
|
|
|
18437
18709
|
import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
18438
18710
|
import_node_os10 = __toESM(require("node:os"), 1);
|
|
18439
18711
|
init_providersStore();
|
|
18712
|
+
init_schema();
|
|
18440
18713
|
init_providerCatalogue();
|
|
18714
|
+
init_storedCatalogue();
|
|
18715
|
+
init_elapsedWindow();
|
|
18441
18716
|
init_catalogueCredential();
|
|
18442
18717
|
init_realPorts();
|
|
18443
18718
|
init_doorLog();
|
|
18444
18719
|
init_ensure2();
|
|
18445
18720
|
init_state();
|
|
18721
|
+
init_catalogueState();
|
|
18446
18722
|
init_probe();
|
|
18447
18723
|
init_selfIdentity();
|
|
18448
18724
|
init_trust();
|
|
@@ -18487,7 +18763,7 @@ function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
|
18487
18763
|
...cliOverride === void 0 ? {} : { cliOverride }
|
|
18488
18764
|
}).input,
|
|
18489
18765
|
now: () => Date.now(),
|
|
18490
|
-
uniqueSuffix: `${String(process.pid)}.${(0,
|
|
18766
|
+
uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto20.randomUUID)()}`,
|
|
18491
18767
|
// 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
18768
|
lock: { pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }
|
|
18493
18769
|
},
|
|
@@ -18515,8 +18791,8 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
18515
18791
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
18516
18792
|
startBaseUrlProbe: realStartBaseUrlProbe,
|
|
18517
18793
|
hold: realHoldPort,
|
|
18518
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot:
|
|
18519
|
-
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin,
|
|
18794
|
+
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",
|
|
18795
|
+
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, import_node_path55.default.join(paths.identitiesDir, identity), options.proc.env),
|
|
18520
18796
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
18521
18797
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
18522
18798
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -18580,13 +18856,13 @@ function resolveClaudeLaunch(options, run = realRunPort) {
|
|
|
18580
18856
|
};
|
|
18581
18857
|
return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, run, farm: buildFarmRuntime(paths, options.cwd, run) })), warnings };
|
|
18582
18858
|
}
|
|
18583
|
-
var import_node_os11,
|
|
18859
|
+
var import_node_os11, import_node_path55, import_node_crypto20, LaunchRefusedError;
|
|
18584
18860
|
var init_launchWiring = __esm({
|
|
18585
18861
|
"src/launchWiring.ts"() {
|
|
18586
18862
|
"use strict";
|
|
18587
18863
|
import_node_os11 = __toESM(require("node:os"), 1);
|
|
18588
|
-
|
|
18589
|
-
|
|
18864
|
+
import_node_path55 = __toESM(require("node:path"), 1);
|
|
18865
|
+
import_node_crypto20 = require("node:crypto");
|
|
18590
18866
|
init_cliError();
|
|
18591
18867
|
init_claudeShim();
|
|
18592
18868
|
init_classify();
|
|
@@ -18741,7 +19017,7 @@ var init_anthropicUsageRefresh = __esm({
|
|
|
18741
19017
|
"src/usage/anthropicUsageRefresh.ts"() {
|
|
18742
19018
|
"use strict";
|
|
18743
19019
|
init_schema();
|
|
18744
|
-
|
|
19020
|
+
init_identity2();
|
|
18745
19021
|
init_middleware();
|
|
18746
19022
|
init_windowLengths();
|
|
18747
19023
|
init_plan2();
|
|
@@ -18812,11 +19088,11 @@ var init_identityClaude = __esm({
|
|
|
18812
19088
|
});
|
|
18813
19089
|
|
|
18814
19090
|
// src/usage/providerQuota.ts
|
|
18815
|
-
var
|
|
19091
|
+
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
19092
|
var init_providerQuota = __esm({
|
|
18817
19093
|
"src/usage/providerQuota.ts"() {
|
|
18818
19094
|
"use strict";
|
|
18819
|
-
|
|
19095
|
+
import_zod48 = require("zod");
|
|
18820
19096
|
init_cloudUpstream();
|
|
18821
19097
|
init_schema2();
|
|
18822
19098
|
MS_PER_SECOND9 = 1e3;
|
|
@@ -18831,35 +19107,35 @@ var init_providerQuota = __esm({
|
|
|
18831
19107
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
|
|
18832
19108
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
|
|
18833
19109
|
]);
|
|
18834
|
-
ZaiLimitSchema =
|
|
18835
|
-
type:
|
|
18836
|
-
unit:
|
|
18837
|
-
number:
|
|
18838
|
-
percentage:
|
|
18839
|
-
nextResetTime:
|
|
18840
|
-
usage:
|
|
18841
|
-
currentValue:
|
|
18842
|
-
remaining:
|
|
19110
|
+
ZaiLimitSchema = import_zod48.z.object({
|
|
19111
|
+
type: import_zod48.z.string(),
|
|
19112
|
+
unit: import_zod48.z.number().int(),
|
|
19113
|
+
number: import_zod48.z.number().int().positive(),
|
|
19114
|
+
percentage: import_zod48.z.number().nonnegative(),
|
|
19115
|
+
nextResetTime: import_zod48.z.number().positive().optional(),
|
|
19116
|
+
usage: import_zod48.z.number().nonnegative().optional(),
|
|
19117
|
+
currentValue: import_zod48.z.number().nonnegative().optional(),
|
|
19118
|
+
remaining: import_zod48.z.number().nonnegative().optional()
|
|
18843
19119
|
});
|
|
18844
|
-
ZaiResponseSchema =
|
|
18845
|
-
success:
|
|
18846
|
-
msg:
|
|
18847
|
-
data:
|
|
19120
|
+
ZaiResponseSchema = import_zod48.z.object({
|
|
19121
|
+
success: import_zod48.z.boolean(),
|
|
19122
|
+
msg: import_zod48.z.string().optional(),
|
|
19123
|
+
data: import_zod48.z.object({ level: import_zod48.z.string().optional(), limits: import_zod48.z.array(ZaiLimitSchema) })
|
|
18848
19124
|
});
|
|
18849
19125
|
OPENROUTER_HOST = "openrouter.ai";
|
|
18850
19126
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
18851
19127
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
18852
19128
|
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:
|
|
19129
|
+
OpenRouterKeySchema = import_zod48.z.object({
|
|
19130
|
+
data: import_zod48.z.object({
|
|
19131
|
+
limit: import_zod48.z.number().nonnegative().nullable(),
|
|
19132
|
+
limit_remaining: import_zod48.z.number().nullable(),
|
|
19133
|
+
limit_reset: import_zod48.z.string().nullable(),
|
|
19134
|
+
is_free_tier: import_zod48.z.boolean().optional(),
|
|
19135
|
+
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
19136
|
})
|
|
18861
19137
|
});
|
|
18862
|
-
OpenRouterCreditsSchema =
|
|
19138
|
+
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
19139
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
18864
19140
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
18865
19141
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
@@ -18867,21 +19143,21 @@ var init_providerQuota = __esm({
|
|
|
18867
19143
|
DAYS_PER_WEEK2 = 7;
|
|
18868
19144
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
18869
19145
|
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
18870
|
-
AntigravityBucketSchema =
|
|
18871
|
-
bucketId:
|
|
18872
|
-
remainingFraction:
|
|
18873
|
-
resetTime:
|
|
19146
|
+
AntigravityBucketSchema = import_zod48.z.object({
|
|
19147
|
+
bucketId: import_zod48.z.string(),
|
|
19148
|
+
remainingFraction: import_zod48.z.number().optional(),
|
|
19149
|
+
resetTime: import_zod48.z.string().optional()
|
|
18874
19150
|
});
|
|
18875
|
-
AntigravitySummarySchema =
|
|
18876
|
-
GoogleTokenInfoSchema =
|
|
18877
|
-
email:
|
|
18878
|
-
sub:
|
|
19151
|
+
AntigravitySummarySchema = import_zod48.z.object({ groups: import_zod48.z.array(import_zod48.z.object({ buckets: import_zod48.z.array(AntigravityBucketSchema) })) });
|
|
19152
|
+
GoogleTokenInfoSchema = import_zod48.z.object({
|
|
19153
|
+
email: import_zod48.z.string().optional(),
|
|
19154
|
+
sub: import_zod48.z.string().optional()
|
|
18879
19155
|
});
|
|
18880
|
-
AntigravityUserSchema =
|
|
19156
|
+
AntigravityUserSchema = import_zod48.z.object({
|
|
18881
19157
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
18882
|
-
currentTier:
|
|
19158
|
+
currentTier: import_zod48.z.object({ name: import_zod48.z.string().optional(), id: import_zod48.z.string().optional() }).optional(),
|
|
18883
19159
|
/** The account's paid subscription; absent when the account has none. */
|
|
18884
|
-
paidTier:
|
|
19160
|
+
paidTier: import_zod48.z.object({ name: import_zod48.z.string().optional(), id: import_zod48.z.string().optional() }).optional()
|
|
18885
19161
|
});
|
|
18886
19162
|
}
|
|
18887
19163
|
});
|
|
@@ -20519,7 +20795,7 @@ var import_openapi9 = require("@orpc/openapi");
|
|
|
20519
20795
|
var import_zod27 = require("zod");
|
|
20520
20796
|
init_schema();
|
|
20521
20797
|
init_claudeVersion();
|
|
20522
|
-
|
|
20798
|
+
init_identity2();
|
|
20523
20799
|
init_projects();
|
|
20524
20800
|
|
|
20525
20801
|
// src/resolve/types.ts
|
|
@@ -20735,8 +21011,8 @@ var ResetRowSchema = import_zod28.z.strictObject({
|
|
|
20735
21011
|
var ResetScheduleSchema = import_zod28.z.strictObject({ resets: import_zod28.z.readonly(import_zod28.z.array(ResetRowSchema)) });
|
|
20736
21012
|
|
|
20737
21013
|
// src/frontdoor/controlSchemas.ts
|
|
20738
|
-
var
|
|
20739
|
-
var
|
|
21014
|
+
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
21015
|
+
var import_zod38 = require("zod");
|
|
20740
21016
|
|
|
20741
21017
|
// src/codex/doctor.ts
|
|
20742
21018
|
function codexIdentityFindings(entry, identity) {
|
|
@@ -20821,7 +21097,56 @@ function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
|
|
|
20821
21097
|
}
|
|
20822
21098
|
|
|
20823
21099
|
// src/doctorReport.ts
|
|
20824
|
-
var
|
|
21100
|
+
var import_node_path43 = __toESM(require("node:path"), 1);
|
|
21101
|
+
init_signIn();
|
|
21102
|
+
init_identityAccounts();
|
|
21103
|
+
init_read();
|
|
21104
|
+
init_providerReachability();
|
|
21105
|
+
|
|
21106
|
+
// src/doctorNameFinding.ts
|
|
21107
|
+
init_names();
|
|
21108
|
+
init_reservedModelNames();
|
|
21109
|
+
function pushNameFinding(push, section, kind, entry) {
|
|
21110
|
+
if (section === "provider") {
|
|
21111
|
+
pushReservedProviderNameFinding(push, entry);
|
|
21112
|
+
}
|
|
21113
|
+
if (isFileName(entry.name)) {
|
|
21114
|
+
return true;
|
|
21115
|
+
}
|
|
21116
|
+
if (!isStoredName(entry.name)) {
|
|
21117
|
+
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);
|
|
21118
|
+
return false;
|
|
21119
|
+
}
|
|
21120
|
+
push(
|
|
21121
|
+
section,
|
|
21122
|
+
"warn",
|
|
21123
|
+
`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.`,
|
|
21124
|
+
entry.name
|
|
21125
|
+
);
|
|
21126
|
+
return true;
|
|
21127
|
+
}
|
|
21128
|
+
function pushReservedProviderNameFinding(push, entry) {
|
|
21129
|
+
const reason = reservedProviderNameReason(entry.name);
|
|
21130
|
+
if (reason !== void 0) {
|
|
21131
|
+
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);
|
|
21132
|
+
}
|
|
21133
|
+
}
|
|
21134
|
+
|
|
21135
|
+
// src/doctorCatalogueRedirect.ts
|
|
21136
|
+
init_schema();
|
|
21137
|
+
init_providerCatalogue();
|
|
21138
|
+
init_providersStore();
|
|
21139
|
+
function pushCatalogueRedirectFinding(push, providerName, reason) {
|
|
21140
|
+
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);
|
|
21141
|
+
}
|
|
21142
|
+
function currentCatalogueSettings(paths, name) {
|
|
21143
|
+
try {
|
|
21144
|
+
const provider = readProvider(paths, name);
|
|
21145
|
+
return provider === void 0 || !isHttpProvider(provider) || provider.catalogue === void 0 ? void 0 : catalogueSettingsFingerprint(provider);
|
|
21146
|
+
} catch {
|
|
21147
|
+
return void 0;
|
|
21148
|
+
}
|
|
21149
|
+
}
|
|
20825
21150
|
|
|
20826
21151
|
// src/checkReport.ts
|
|
20827
21152
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
@@ -20857,10 +21182,10 @@ init_load();
|
|
|
20857
21182
|
var import_node_os4 = __toESM(require("node:os"), 1);
|
|
20858
21183
|
init_load();
|
|
20859
21184
|
init_cascade();
|
|
20860
|
-
|
|
21185
|
+
init_identity2();
|
|
20861
21186
|
|
|
20862
21187
|
// src/poolPickReport.ts
|
|
20863
|
-
|
|
21188
|
+
init_identity2();
|
|
20864
21189
|
init_poolPick();
|
|
20865
21190
|
function candidateView(candidate) {
|
|
20866
21191
|
return {
|
|
@@ -21381,29 +21706,39 @@ function collectCheckReport(params) {
|
|
|
21381
21706
|
return report;
|
|
21382
21707
|
}
|
|
21383
21708
|
|
|
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;
|
|
21709
|
+
// src/doctorKeychain.ts
|
|
21710
|
+
function pushKeychainFindings(push, platform, run, identities, agentOf) {
|
|
21711
|
+
if (platform !== "darwin" || run === void 0) {
|
|
21712
|
+
push("keychain", "pass", "Skipped (not macOS).");
|
|
21713
|
+
return;
|
|
21395
21714
|
}
|
|
21396
|
-
|
|
21397
|
-
|
|
21398
|
-
|
|
21715
|
+
for (const entry of identities) {
|
|
21716
|
+
if (agentOf.get(entry.name) === "codex") continue;
|
|
21717
|
+
const result = lookupKeychainService(run, entry.farmRoot);
|
|
21718
|
+
push("keychain", "pass", result.found ? result.note : `${result.note} The sign-in section reports whether a login is stored elsewhere.`, entry.name);
|
|
21399
21719
|
}
|
|
21400
|
-
|
|
21401
|
-
|
|
21402
|
-
|
|
21403
|
-
|
|
21404
|
-
|
|
21405
|
-
|
|
21406
|
-
|
|
21720
|
+
}
|
|
21721
|
+
|
|
21722
|
+
// src/frontdoor/catalogueFailures.ts
|
|
21723
|
+
init_state();
|
|
21724
|
+
init_catalogueState();
|
|
21725
|
+
function providersWithRedirectedCatalogue(fs17, paths, settingsOf2) {
|
|
21726
|
+
const supervisorPid = readFrontDoorState(fs17, paths.frontdoorStateFile)?.supervisorPid;
|
|
21727
|
+
const generation = supervisorPid === void 0 ? void 0 : readFrontDoorCodexRecord(fs17, paths.frontdoorDir, supervisorPid)?.generation;
|
|
21728
|
+
if (supervisorPid === void 0 || generation === void 0) {
|
|
21729
|
+
return /* @__PURE__ */ new Map();
|
|
21730
|
+
}
|
|
21731
|
+
const found = /* @__PURE__ */ new Map();
|
|
21732
|
+
for (const [name, settings] of settingsOf2) {
|
|
21733
|
+
if (readCatalogueStatus(fs17, paths, supervisorPid, generation, name)?.status !== "failed") {
|
|
21734
|
+
continue;
|
|
21735
|
+
}
|
|
21736
|
+
const failure = readCatalogueFailure(fs17, paths, supervisorPid, generation, name);
|
|
21737
|
+
if (settings !== void 0 && failure?.redirected === true && failure.settings === settings) {
|
|
21738
|
+
found.set(name, failure.reason);
|
|
21739
|
+
}
|
|
21740
|
+
}
|
|
21741
|
+
return found;
|
|
21407
21742
|
}
|
|
21408
21743
|
|
|
21409
21744
|
// src/doctorReport.ts
|
|
@@ -21420,7 +21755,7 @@ init_source();
|
|
|
21420
21755
|
// src/models/doctor.ts
|
|
21421
21756
|
init_modelsStore();
|
|
21422
21757
|
init_families();
|
|
21423
|
-
|
|
21758
|
+
init_identity();
|
|
21424
21759
|
function modelsFindings(input) {
|
|
21425
21760
|
const findings = [];
|
|
21426
21761
|
const { models } = input;
|
|
@@ -21683,12 +22018,12 @@ init_identityRenameJournal();
|
|
|
21683
22018
|
init_providerAliases();
|
|
21684
22019
|
init_providersStore();
|
|
21685
22020
|
init_guard();
|
|
21686
|
-
|
|
22021
|
+
init_identity2();
|
|
21687
22022
|
init_poolStore();
|
|
21688
22023
|
|
|
21689
22024
|
// src/poolSharedLogins.ts
|
|
21690
22025
|
init_identityAccounts();
|
|
21691
|
-
|
|
22026
|
+
init_identity2();
|
|
21692
22027
|
function sharedLoginMembers(members, accountOf) {
|
|
21693
22028
|
const known = members.flatMap((identity) => {
|
|
21694
22029
|
const account = poolNameOf(identity) === void 0 ? accountOf(identity) : void 0;
|
|
@@ -21707,7 +22042,7 @@ function describeSharedLoginMembers(poolName, shared) {
|
|
|
21707
22042
|
|
|
21708
22043
|
// src/poolWindowReads.ts
|
|
21709
22044
|
init_schema();
|
|
21710
|
-
|
|
22045
|
+
init_identity2();
|
|
21711
22046
|
init_conditions();
|
|
21712
22047
|
init_middleware();
|
|
21713
22048
|
init_rateLimit();
|
|
@@ -21838,7 +22173,7 @@ function tcpPortEraRecord(raw) {
|
|
|
21838
22173
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
21839
22174
|
}
|
|
21840
22175
|
function pushPathResolution(push, resolution) {
|
|
21841
|
-
const ownDir =
|
|
22176
|
+
const ownDir = import_node_path43.default.dirname(resolution.ownExecutablePath);
|
|
21842
22177
|
switch (resolution.agentShim.status) {
|
|
21843
22178
|
case "ok":
|
|
21844
22179
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -21958,14 +22293,14 @@ function pushProvider(push, entry, cacheEnv, signIn, unreachable) {
|
|
|
21958
22293
|
}
|
|
21959
22294
|
function pushLegacyName(push, params) {
|
|
21960
22295
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
21961
|
-
if (legacyVariables.length === 0 &&
|
|
22296
|
+
if (legacyVariables.length === 0 && import_node_path43.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
21962
22297
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
21963
22298
|
return;
|
|
21964
22299
|
}
|
|
21965
22300
|
for (const name of legacyVariables) {
|
|
21966
22301
|
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
22302
|
}
|
|
21968
|
-
if (
|
|
22303
|
+
if (import_node_path43.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
21969
22304
|
push(
|
|
21970
22305
|
"legacy-name",
|
|
21971
22306
|
"warn",
|
|
@@ -22055,7 +22390,7 @@ function runDoctor(params) {
|
|
|
22055
22390
|
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
22391
|
}
|
|
22057
22392
|
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.`,
|
|
22393
|
+
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
22394
|
}
|
|
22060
22395
|
const validIdentityAgents = /* @__PURE__ */ new Map();
|
|
22061
22396
|
const signedInAccounts = [];
|
|
@@ -22181,20 +22516,16 @@ function runDoctor(params) {
|
|
|
22181
22516
|
continue;
|
|
22182
22517
|
}
|
|
22183
22518
|
pushProvider(push, entry, params.credentialCache, params.chatgptSignIn, unreachableLines.get(entry.name));
|
|
22519
|
+
const redirectReason = params.catalogueRedirects?.get(entry.name);
|
|
22520
|
+
if (redirectReason !== void 0) {
|
|
22521
|
+
pushCatalogueRedirectFinding(push, entry.name, redirectReason);
|
|
22522
|
+
}
|
|
22184
22523
|
}
|
|
22185
22524
|
const providerNames = new Set(params.providers.map((entry) => entry.name));
|
|
22186
22525
|
for (const finding of aliasFindings(params.providerAliases ?? {}, providerNames)) {
|
|
22187
22526
|
push("provider", finding.level, finding.message, finding.alias);
|
|
22188
22527
|
}
|
|
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
|
-
}
|
|
22528
|
+
pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
|
|
22198
22529
|
if (params.directoryRules.raw === void 0) {
|
|
22199
22530
|
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
22200
22531
|
} else {
|
|
@@ -22421,9 +22752,9 @@ function collectDoctorReport(params) {
|
|
|
22421
22752
|
const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
|
|
22422
22753
|
const records = identityRecords(paths);
|
|
22423
22754
|
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 =
|
|
22755
|
+
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) => {
|
|
22756
|
+
const farmRoot = import_node_path43.default.join(paths.identitiesDir, id);
|
|
22757
|
+
const identityPath = import_node_path43.default.join(farmRoot, "identity.json");
|
|
22427
22758
|
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
22759
|
});
|
|
22429
22760
|
const usageSnapshots = {};
|
|
@@ -22441,12 +22772,12 @@ function collectDoctorReport(params) {
|
|
|
22441
22772
|
}
|
|
22442
22773
|
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
22774
|
const configProfiles = profileNames.map((name) => {
|
|
22444
|
-
const profilePath =
|
|
22775
|
+
const profilePath = import_node_path43.default.join(paths.configProfilesDir, `${name}.json`);
|
|
22445
22776
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
22446
22777
|
});
|
|
22447
22778
|
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
22779
|
const providers = providerNames.map((name) => {
|
|
22449
|
-
const providerPath =
|
|
22780
|
+
const providerPath = import_node_path43.default.join(paths.providersDir, `${name}.json`);
|
|
22450
22781
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
22451
22782
|
});
|
|
22452
22783
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -22458,12 +22789,12 @@ function collectDoctorReport(params) {
|
|
|
22458
22789
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
22459
22790
|
}
|
|
22460
22791
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
22461
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
22792
|
+
const pathDirs = (params.env.PATH ?? "").split(import_node_path43.default.delimiter).filter((dir) => dir !== "");
|
|
22462
22793
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
22463
22794
|
findPathShadow({
|
|
22464
22795
|
pathDirs,
|
|
22465
|
-
targetDir:
|
|
22466
|
-
targetFilename:
|
|
22796
|
+
targetDir: import_node_path43.default.dirname(shimState.targetPath),
|
|
22797
|
+
targetFilename: import_node_path43.default.basename(shimState.targetPath),
|
|
22467
22798
|
findExecutableInDir
|
|
22468
22799
|
}),
|
|
22469
22800
|
shimState.targetPath,
|
|
@@ -22488,9 +22819,10 @@ function collectDoctorReport(params) {
|
|
|
22488
22819
|
providers,
|
|
22489
22820
|
providerAliases: readProviderAliases(paths),
|
|
22490
22821
|
probeBaseUrls: realBaseUrlBatchProbe,
|
|
22822
|
+
catalogueRedirects: providersWithRedirectedCatalogue(realFarmFs, paths, new Map(providers.map((entry) => [entry.name, currentCatalogueSettings(paths, entry.name)]))),
|
|
22491
22823
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
22492
22824
|
unreachableIdentities,
|
|
22493
|
-
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(
|
|
22825
|
+
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
22826
|
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
22495
22827
|
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
22496
22828
|
models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
|
|
@@ -22505,7 +22837,7 @@ function collectDoctorReport(params) {
|
|
|
22505
22837
|
agentShim: refinePathShadow(
|
|
22506
22838
|
findPathShadow({
|
|
22507
22839
|
pathDirs,
|
|
22508
|
-
targetDir:
|
|
22840
|
+
targetDir: import_node_path43.default.dirname(ownExecutablePath),
|
|
22509
22841
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
22510
22842
|
findExecutableInDir
|
|
22511
22843
|
}),
|
|
@@ -22548,93 +22880,93 @@ function collectDoctorReport(params) {
|
|
|
22548
22880
|
init_schema2();
|
|
22549
22881
|
init_rcSchemas();
|
|
22550
22882
|
init_state();
|
|
22551
|
-
var UsageListOutputSchema =
|
|
22552
|
-
var UsageWindowsInputSchema =
|
|
22553
|
-
identity:
|
|
22554
|
-
provider:
|
|
22883
|
+
var UsageListOutputSchema = import_zod38.z.strictObject({ snapshots: import_zod38.z.readonly(import_zod38.z.array(UsageSnapshotSchema)) });
|
|
22884
|
+
var UsageWindowsInputSchema = import_zod38.z.strictObject({
|
|
22885
|
+
identity: import_zod38.z.string().min(1),
|
|
22886
|
+
provider: import_zod38.z.string().min(1).optional()
|
|
22555
22887
|
});
|
|
22556
|
-
var EffectiveWindowSchema =
|
|
22888
|
+
var EffectiveWindowSchema = import_zod38.z.strictObject({
|
|
22557
22889
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
22558
|
-
reset:
|
|
22890
|
+
reset: import_zod38.z.boolean(),
|
|
22559
22891
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
22560
|
-
utilization:
|
|
22892
|
+
utilization: import_zod38.z.number().optional(),
|
|
22561
22893
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
22562
|
-
resetsAtMs:
|
|
22894
|
+
resetsAtMs: import_zod38.z.number().optional(),
|
|
22563
22895
|
/** The window's own status, for a window that has not reset yet. */
|
|
22564
|
-
status:
|
|
22896
|
+
status: import_zod38.z.string().optional()
|
|
22565
22897
|
});
|
|
22566
|
-
var UsageWindowsOutputSchema =
|
|
22567
|
-
identity:
|
|
22568
|
-
provider:
|
|
22898
|
+
var UsageWindowsOutputSchema = import_zod38.z.strictObject({
|
|
22899
|
+
identity: import_zod38.z.string(),
|
|
22900
|
+
provider: import_zod38.z.string(),
|
|
22569
22901
|
/** When the rate-limit state the windows come from was observed. */
|
|
22570
|
-
observedAt:
|
|
22902
|
+
observedAt: import_zod38.z.iso.datetime().optional(),
|
|
22571
22903
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
22572
22904
|
sevenDay: EffectiveWindowSchema.optional()
|
|
22573
22905
|
});
|
|
22574
|
-
var UsageLiveOutputSchema =
|
|
22906
|
+
var UsageLiveOutputSchema = import_zod38.z.strictObject({
|
|
22575
22907
|
/** 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
22908
|
latest: RcLiveRateLimitSchema.optional(),
|
|
22577
22909
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
22578
|
-
sessions:
|
|
22910
|
+
sessions: import_zod38.z.readonly(import_zod38.z.array(RcLiveRateLimitSchema))
|
|
22579
22911
|
});
|
|
22580
|
-
var FrontDoorSessionStatusSchema =
|
|
22581
|
-
pid:
|
|
22582
|
-
startedAt:
|
|
22583
|
-
alive:
|
|
22912
|
+
var FrontDoorSessionStatusSchema = import_zod38.z.strictObject({
|
|
22913
|
+
pid: import_zod38.z.int().positive(),
|
|
22914
|
+
startedAt: import_zod38.z.number(),
|
|
22915
|
+
alive: import_zod38.z.boolean()
|
|
22584
22916
|
});
|
|
22585
|
-
var HeadroomSocketTargetSchema =
|
|
22586
|
-
var FrontDoorStatusOutputSchema =
|
|
22917
|
+
var HeadroomSocketTargetSchema = import_zod38.z.union([import_zod38.z.strictObject({ socketPath: import_zod38.z.string() }), import_zod38.z.strictObject({ refused: import_zod38.z.string() })]);
|
|
22918
|
+
var FrontDoorStatusOutputSchema = import_zod38.z.strictObject({
|
|
22587
22919
|
state: FrontDoorStateSchema,
|
|
22588
|
-
supervisorAlive:
|
|
22920
|
+
supervisorAlive: import_zod38.z.boolean(),
|
|
22589
22921
|
/** 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:
|
|
22922
|
+
draining: import_zod38.z.readonly(import_zod38.z.array(import_zod38.z.number().int().positive())),
|
|
22923
|
+
sessions: import_zod38.z.readonly(import_zod38.z.array(FrontDoorSessionStatusSchema)),
|
|
22592
22924
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
22593
|
-
logPath:
|
|
22594
|
-
logExists:
|
|
22925
|
+
logPath: import_zod38.z.string(),
|
|
22926
|
+
logExists: import_zod38.z.boolean()
|
|
22595
22927
|
});
|
|
22596
|
-
var FrontDoorSessionsOutputSchema =
|
|
22928
|
+
var FrontDoorSessionsOutputSchema = import_zod38.z.strictObject({ sessions: import_zod38.z.readonly(import_zod38.z.array(FrontDoorSessionStatusSchema)) });
|
|
22597
22929
|
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:
|
|
22930
|
+
var CheckRunInputSchema = import_zod38.z.strictObject({
|
|
22931
|
+
path: import_zod38.z.string().min(1),
|
|
22932
|
+
identity: import_zod38.z.string().min(1).optional()
|
|
22933
|
+
}).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" });
|
|
22934
|
+
var PoolPickInputSchema = import_zod38.z.strictObject({
|
|
22935
|
+
pool: import_zod38.z.string().min(1),
|
|
22936
|
+
path: import_zod38.z.string().min(1)
|
|
22937
|
+
}).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" });
|
|
22938
|
+
var DoctorFindingSchema = import_zod38.z.strictObject({
|
|
22939
|
+
section: import_zod38.z.enum(DOCTOR_SECTIONS),
|
|
22940
|
+
subject: import_zod38.z.string().optional(),
|
|
22941
|
+
severity: import_zod38.z.enum(DOCTOR_SEVERITIES),
|
|
22942
|
+
message: import_zod38.z.string()
|
|
22611
22943
|
});
|
|
22612
|
-
var DoctorRunOutputSchema =
|
|
22944
|
+
var DoctorRunOutputSchema = import_zod38.z.strictObject({
|
|
22613
22945
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
22614
|
-
ok:
|
|
22615
|
-
findings:
|
|
22946
|
+
ok: import_zod38.z.boolean(),
|
|
22947
|
+
findings: import_zod38.z.readonly(import_zod38.z.array(DoctorFindingSchema))
|
|
22616
22948
|
});
|
|
22617
|
-
var FrontDoorRestartOutputSchema =
|
|
22618
|
-
action:
|
|
22619
|
-
previousPid:
|
|
22949
|
+
var FrontDoorRestartOutputSchema = import_zod38.z.strictObject({
|
|
22950
|
+
action: import_zod38.z.literal("restarting"),
|
|
22951
|
+
previousPid: import_zod38.z.int().positive()
|
|
22620
22952
|
});
|
|
22621
|
-
var UpdateCheckOutputSchema =
|
|
22622
|
-
current:
|
|
22623
|
-
latest:
|
|
22624
|
-
action:
|
|
22953
|
+
var UpdateCheckOutputSchema = import_zod38.z.strictObject({
|
|
22954
|
+
current: import_zod38.z.string(),
|
|
22955
|
+
latest: import_zod38.z.string(),
|
|
22956
|
+
action: import_zod38.z.enum(["current", "available", "updated"])
|
|
22625
22957
|
});
|
|
22626
|
-
var CodexSignInSchema =
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22958
|
+
var CodexSignInSchema = import_zod38.z.discriminatedUnion("state", [
|
|
22959
|
+
import_zod38.z.strictObject({ state: import_zod38.z.literal("none") }),
|
|
22960
|
+
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() }),
|
|
22961
|
+
import_zod38.z.strictObject({ state: import_zod38.z.literal("unreadable"), message: import_zod38.z.string() })
|
|
22630
22962
|
]);
|
|
22631
|
-
var CodexStatusOutputSchema =
|
|
22963
|
+
var CodexStatusOutputSchema = import_zod38.z.strictObject({
|
|
22632
22964
|
signIn: CodexSignInSchema,
|
|
22633
|
-
codexProviders:
|
|
22965
|
+
codexProviders: import_zod38.z.readonly(import_zod38.z.array(import_zod38.z.string()))
|
|
22634
22966
|
});
|
|
22635
|
-
var CodexLogoutOutputSchema =
|
|
22636
|
-
hadGrant:
|
|
22637
|
-
revoked:
|
|
22967
|
+
var CodexLogoutOutputSchema = import_zod38.z.strictObject({
|
|
22968
|
+
hadGrant: import_zod38.z.boolean(),
|
|
22969
|
+
revoked: import_zod38.z.boolean()
|
|
22638
22970
|
});
|
|
22639
22971
|
|
|
22640
22972
|
// src/frontdoor/codexApi.ts
|
|
@@ -22655,20 +22987,21 @@ function createCodexApiRouter(deps) {
|
|
|
22655
22987
|
|
|
22656
22988
|
// src/frontdoor/doorWorker.ts
|
|
22657
22989
|
var import_node_sea2 = require("node:sea");
|
|
22658
|
-
var
|
|
22990
|
+
var import_zod40 = require("zod");
|
|
22659
22991
|
init_cliError();
|
|
22660
22992
|
init_doorBounds();
|
|
22661
22993
|
init_providerCatalogue();
|
|
22662
22994
|
|
|
22663
22995
|
// src/frontdoor/doorWorkerProtocol.ts
|
|
22664
|
-
var
|
|
22996
|
+
var import_zod39 = require("zod");
|
|
22997
|
+
init_providerCatalogue();
|
|
22665
22998
|
var doorWorkerInputSchemas = {
|
|
22666
22999
|
/** `agent-shim check` for `path` as `identity` (the identity a launch there would resolve when absent). */
|
|
22667
|
-
check:
|
|
23000
|
+
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
23001
|
/** `agent-shim doctor`. */
|
|
22669
|
-
doctor:
|
|
23002
|
+
doctor: import_zod39.z.strictObject({ root: import_zod39.z.string().min(1) }),
|
|
22670
23003
|
/** Fetch and store one provider's model catalogue for the door generation that asked. */
|
|
22671
|
-
"refresh-catalogue":
|
|
23004
|
+
"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
23005
|
};
|
|
22673
23006
|
|
|
22674
23007
|
// src/frontdoor/doorWorker.ts
|
|
@@ -22683,15 +23016,18 @@ var DoorWorkerBusyError = class extends CliError {
|
|
|
22683
23016
|
var NEXT_STEP = {
|
|
22684
23017
|
check: "run `agent-shim check` from a shell for the detail",
|
|
22685
23018
|
doctor: "run `agent-shim doctor` from a shell for the detail",
|
|
22686
|
-
"refresh-catalogue": "run `agent-shim provider models --refresh
|
|
23019
|
+
"refresh-catalogue": "run `agent-shim provider models <name> --refresh` from a shell for the detail"
|
|
22687
23020
|
};
|
|
22688
23021
|
var DoorWorkerFailedError = class extends CliError {
|
|
22689
|
-
constructor(task, reason, kind) {
|
|
23022
|
+
constructor(task, reason, kind, redirected = false) {
|
|
22690
23023
|
super(`${task} failed in its worker: ${reason}${task === "an unknown task" ? "" : `; ${NEXT_STEP[task]}`}`);
|
|
22691
23024
|
this.kind = kind;
|
|
22692
23025
|
this.name = "DoorWorkerFailedError";
|
|
23026
|
+
this.redirected = redirected;
|
|
22693
23027
|
}
|
|
22694
23028
|
kind;
|
|
23029
|
+
/** 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. */
|
|
23030
|
+
redirected;
|
|
22695
23031
|
};
|
|
22696
23032
|
|
|
22697
23033
|
// src/frontdoor/configApi.ts
|
|
@@ -22748,79 +23084,79 @@ init_identityStore();
|
|
|
22748
23084
|
init_keychainLogin();
|
|
22749
23085
|
init_identityNamesLock();
|
|
22750
23086
|
init_lock();
|
|
22751
|
-
|
|
23087
|
+
init_identity2();
|
|
22752
23088
|
init_replayRun();
|
|
22753
23089
|
init_poolStore();
|
|
22754
23090
|
init_baseUrlDisplay();
|
|
22755
23091
|
init_providersStore();
|
|
22756
23092
|
|
|
22757
23093
|
// src/frontdoor/configSchemas.ts
|
|
22758
|
-
var
|
|
23094
|
+
var import_zod41 = require("zod");
|
|
22759
23095
|
init_schema();
|
|
22760
23096
|
init_names();
|
|
22761
23097
|
init_keychainLogin();
|
|
22762
23098
|
init_statusline();
|
|
22763
|
-
var RemovalConfirmationSchema =
|
|
22764
|
-
var CredentialWriteSchema = (targets) =>
|
|
22765
|
-
sources:
|
|
22766
|
-
target:
|
|
22767
|
-
cache:
|
|
23099
|
+
var RemovalConfirmationSchema = import_zod41.z.boolean();
|
|
23100
|
+
var CredentialWriteSchema = (targets) => import_zod41.z.strictObject({
|
|
23101
|
+
sources: import_zod41.z.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
23102
|
+
target: import_zod41.z.enum(targets).optional(),
|
|
23103
|
+
cache: import_zod41.z.union([import_zod41.z.literal(false), CredentialCacheSchema]).optional()
|
|
22768
23104
|
});
|
|
22769
|
-
var CredentialSummarySchema2 =
|
|
22770
|
-
target:
|
|
22771
|
-
sources:
|
|
22772
|
-
|
|
22773
|
-
|
|
22774
|
-
|
|
22775
|
-
|
|
22776
|
-
|
|
22777
|
-
|
|
22778
|
-
|
|
23105
|
+
var CredentialSummarySchema2 = import_zod41.z.strictObject({
|
|
23106
|
+
target: import_zod41.z.enum(CREDENTIAL_TARGETS),
|
|
23107
|
+
sources: import_zod41.z.readonly(import_zod41.z.array(
|
|
23108
|
+
import_zod41.z.discriminatedUnion("kind", [
|
|
23109
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("env"), variable: import_zod41.z.string() }),
|
|
23110
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("file"), path: import_zod41.z.string() }),
|
|
23111
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("command"), program: import_zod41.z.string() }),
|
|
23112
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("op"), reference: import_zod41.z.string() }),
|
|
23113
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("keychain"), service: import_zod41.z.string(), account: import_zod41.z.string().optional() }),
|
|
23114
|
+
import_zod41.z.strictObject({ kind: import_zod41.z.literal("literal") })
|
|
22779
23115
|
])
|
|
22780
23116
|
)),
|
|
22781
23117
|
cache: CredentialCacheSchema.optional()
|
|
22782
23118
|
});
|
|
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:
|
|
23119
|
+
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() });
|
|
23120
|
+
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 });
|
|
23121
|
+
var IdentityValueSchema = import_zod41.z.strictObject({
|
|
23122
|
+
agent: import_zod41.z.enum(["claude", "codex"]).optional(),
|
|
23123
|
+
name: import_zod41.z.string(),
|
|
23124
|
+
label: import_zod41.z.string().optional(),
|
|
23125
|
+
defaultConfigProfile: import_zod41.z.string().optional(),
|
|
23126
|
+
provider: import_zod41.z.string().optional(),
|
|
23127
|
+
allowAmbientCredential: import_zod41.z.boolean(),
|
|
22792
23128
|
credential: CredentialSummarySchema2.optional(),
|
|
22793
|
-
anchors:
|
|
23129
|
+
anchors: import_zod41.z.array(AnchorSchema).optional()
|
|
22794
23130
|
});
|
|
22795
23131
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
22796
|
-
var ProviderValueSchema =
|
|
22797
|
-
name:
|
|
22798
|
-
kind:
|
|
22799
|
-
displayName:
|
|
22800
|
-
baseUrl:
|
|
23132
|
+
var ProviderValueSchema = import_zod41.z.strictObject({
|
|
23133
|
+
name: import_zod41.z.string(),
|
|
23134
|
+
kind: import_zod41.z.enum(PROVIDER_KINDS),
|
|
23135
|
+
displayName: import_zod41.z.string(),
|
|
23136
|
+
baseUrl: import_zod41.z.string().optional(),
|
|
22801
23137
|
codex: CodexProviderConfigSchema.optional(),
|
|
22802
23138
|
credential: CredentialSummarySchema2.optional(),
|
|
22803
|
-
env:
|
|
23139
|
+
env: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.string()).optional()
|
|
22804
23140
|
});
|
|
22805
|
-
var ConfigNameInputSchema =
|
|
22806
|
-
var ConfigIdentityAddInputSchema =
|
|
23141
|
+
var ConfigNameInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1) });
|
|
23142
|
+
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
23143
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
22808
|
-
var ConfigIdentitySetInputSchema =
|
|
22809
|
-
name:
|
|
23144
|
+
var ConfigIdentitySetInputSchema = import_zod41.z.strictObject({
|
|
23145
|
+
name: import_zod41.z.string().min(1),
|
|
22810
23146
|
/** The identity's display label; `false` clears it. */
|
|
22811
|
-
label:
|
|
22812
|
-
defaultConfigProfile:
|
|
23147
|
+
label: import_zod41.z.union([IdentityLabelSchema, import_zod41.z.literal(false)]).optional(),
|
|
23148
|
+
defaultConfigProfile: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
22813
23149
|
/** The provider the identity exists for; `false` clears it. */
|
|
22814
|
-
provider:
|
|
22815
|
-
allowAmbientCredential:
|
|
22816
|
-
credential:
|
|
23150
|
+
provider: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
23151
|
+
allowAmbientCredential: import_zod41.z.boolean().optional(),
|
|
23152
|
+
credential: import_zod41.z.union([import_zod41.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
22817
23153
|
/** `false` removes the anchors; a list replaces them. */
|
|
22818
|
-
anchors:
|
|
23154
|
+
anchors: import_zod41.z.union([import_zod41.z.literal(false), import_zod41.z.array(AnchorSchema).min(1)]).optional()
|
|
22819
23155
|
});
|
|
22820
23156
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
22821
|
-
var ConfigIdentityRemoveInputSchema =
|
|
23157
|
+
var ConfigIdentityRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22822
23158
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
22823
|
-
var ConfigStatuslineSetSchema =
|
|
23159
|
+
var ConfigStatuslineSetSchema = import_zod41.z.record(import_zod41.z.string(), import_zod41.z.unknown()).superRefine((settings, context) => {
|
|
22824
23160
|
for (const key of Object.keys(settings)) {
|
|
22825
23161
|
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
22826
23162
|
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 +23164,93 @@ var ConfigStatuslineSetSchema = import_zod40.z.record(import_zod40.z.string(), i
|
|
|
22828
23164
|
}
|
|
22829
23165
|
});
|
|
22830
23166
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
22831
|
-
var ConfigProfileAddInputSchema =
|
|
22832
|
-
name:
|
|
22833
|
-
extends:
|
|
22834
|
-
description:
|
|
23167
|
+
var ConfigProfileAddInputSchema = import_zod41.z.strictObject({
|
|
23168
|
+
name: import_zod41.z.string().min(1),
|
|
23169
|
+
extends: import_zod41.z.array(import_zod41.z.string().min(1)).optional(),
|
|
23170
|
+
description: import_zod41.z.string().optional()
|
|
22835
23171
|
});
|
|
22836
23172
|
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:
|
|
23173
|
+
var ConfigProfileSetInputSchema = import_zod41.z.strictObject({
|
|
23174
|
+
name: import_zod41.z.string().min(1),
|
|
23175
|
+
category: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.boolean()).optional(),
|
|
23176
|
+
entry: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.boolean()).optional(),
|
|
23177
|
+
extends: import_zod41.z.union([import_zod41.z.array(import_zod41.z.string().min(1)), import_zod41.z.literal(false)]).optional(),
|
|
23178
|
+
description: import_zod41.z.union([import_zod41.z.string(), import_zod41.z.literal(false)]).optional(),
|
|
23179
|
+
launch: import_zod41.z.strictObject({
|
|
23180
|
+
skipPermissions: import_zod41.z.boolean().optional(),
|
|
23181
|
+
remoteControl: import_zod41.z.boolean().optional(),
|
|
23182
|
+
headroom: import_zod41.z.boolean().optional(),
|
|
23183
|
+
trackUsage: import_zod41.z.boolean().optional(),
|
|
23184
|
+
provider: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
23185
|
+
claudeVersion: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
23186
|
+
delay: import_zod41.z.union([import_zod41.z.string().regex(DURATION_RE), import_zod41.z.literal(false)]).optional(),
|
|
23187
|
+
pause: import_zod41.z.boolean().optional(),
|
|
23188
|
+
explain: import_zod41.z.boolean().optional(),
|
|
23189
|
+
proxyBypass: import_zod41.z.union([import_zod41.z.array(import_zod41.z.string().min(1)), import_zod41.z.literal(false)]).optional(),
|
|
23190
|
+
statusline: import_zod41.z.strictObject({
|
|
22855
23191
|
set: ConfigStatuslineSetSchema.optional(),
|
|
22856
|
-
unset:
|
|
23192
|
+
unset: import_zod41.z.array(import_zod41.z.string()).optional()
|
|
22857
23193
|
}).optional()
|
|
22858
23194
|
}).optional()
|
|
22859
23195
|
});
|
|
22860
23196
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
22861
|
-
var ConfigProfileRemoveInputSchema =
|
|
23197
|
+
var ConfigProfileRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22862
23198
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
22863
23199
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
22864
|
-
var PoolMembersInputSchema =
|
|
22865
|
-
var ConfigPoolAddInputSchema =
|
|
22866
|
-
name:
|
|
23200
|
+
var PoolMembersInputSchema = import_zod41.z.array(import_zod41.z.string().min(1)).min(1);
|
|
23201
|
+
var ConfigPoolAddInputSchema = import_zod41.z.strictObject({
|
|
23202
|
+
name: import_zod41.z.string().min(1),
|
|
22867
23203
|
identities: PoolMembersInputSchema,
|
|
22868
|
-
preference:
|
|
22869
|
-
resumeOnLimit:
|
|
22870
|
-
compactBeforeLimit:
|
|
23204
|
+
preference: import_zod41.z.enum(POOL_PREFERENCES).optional(),
|
|
23205
|
+
resumeOnLimit: import_zod41.z.boolean().optional(),
|
|
23206
|
+
compactBeforeLimit: import_zod41.z.boolean().optional(),
|
|
22871
23207
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
22872
23208
|
});
|
|
22873
23209
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
22874
|
-
var ConfigPoolSetInputSchema =
|
|
22875
|
-
name:
|
|
23210
|
+
var ConfigPoolSetInputSchema = import_zod41.z.strictObject({
|
|
23211
|
+
name: import_zod41.z.string().min(1),
|
|
22876
23212
|
identities: PoolMembersInputSchema.optional(),
|
|
22877
|
-
preference:
|
|
22878
|
-
resumeOnLimit:
|
|
22879
|
-
compactBeforeLimit:
|
|
22880
|
-
compactAtUtilisation:
|
|
23213
|
+
preference: import_zod41.z.union([import_zod41.z.enum(POOL_PREFERENCES), import_zod41.z.literal(false)]).optional(),
|
|
23214
|
+
resumeOnLimit: import_zod41.z.boolean().optional(),
|
|
23215
|
+
compactBeforeLimit: import_zod41.z.boolean().optional(),
|
|
23216
|
+
compactAtUtilisation: import_zod41.z.union([CompactAtUtilisationSchema, import_zod41.z.literal(false)]).optional()
|
|
22881
23217
|
});
|
|
22882
23218
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
22883
|
-
var ConfigPoolRemoveInputSchema =
|
|
23219
|
+
var ConfigPoolRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22884
23220
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
22885
23221
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
22886
|
-
var ConfigProviderAddInputSchema =
|
|
22887
|
-
name:
|
|
22888
|
-
kind:
|
|
22889
|
-
displayName:
|
|
22890
|
-
baseUrl:
|
|
23222
|
+
var ConfigProviderAddInputSchema = import_zod41.z.strictObject({
|
|
23223
|
+
name: import_zod41.z.string().min(1),
|
|
23224
|
+
kind: import_zod41.z.enum(PROVIDER_KINDS).optional(),
|
|
23225
|
+
displayName: import_zod41.z.string().min(1),
|
|
23226
|
+
baseUrl: import_zod41.z.string().min(1).optional(),
|
|
22891
23227
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
22892
23228
|
codex: CodexProviderConfigSchema.optional()
|
|
22893
23229
|
});
|
|
22894
23230
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
22895
|
-
var ConfigProviderSetInputSchema =
|
|
22896
|
-
name:
|
|
22897
|
-
displayName:
|
|
22898
|
-
baseUrl:
|
|
23231
|
+
var ConfigProviderSetInputSchema = import_zod41.z.strictObject({
|
|
23232
|
+
name: import_zod41.z.string().min(1),
|
|
23233
|
+
displayName: import_zod41.z.string().min(1).optional(),
|
|
23234
|
+
baseUrl: import_zod41.z.string().min(1).optional(),
|
|
22899
23235
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
22900
23236
|
codex: CodexProviderConfigSchema.optional()
|
|
22901
23237
|
});
|
|
22902
23238
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
22903
|
-
var ConfigProviderRemoveInputSchema =
|
|
23239
|
+
var ConfigProviderRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22904
23240
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
22905
|
-
var ConfigRuleAddInputSchema =
|
|
22906
|
-
path:
|
|
22907
|
-
configProfile:
|
|
22908
|
-
identity:
|
|
23241
|
+
var ConfigRuleAddInputSchema = import_zod41.z.strictObject({
|
|
23242
|
+
path: import_zod41.z.string().min(1),
|
|
23243
|
+
configProfile: import_zod41.z.string().min(1).optional(),
|
|
23244
|
+
identity: import_zod41.z.string().min(1).optional()
|
|
22909
23245
|
});
|
|
22910
23246
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
22911
|
-
var ConfigRuleSetInputSchema =
|
|
22912
|
-
path:
|
|
22913
|
-
configProfile:
|
|
22914
|
-
identity:
|
|
23247
|
+
var ConfigRuleSetInputSchema = import_zod41.z.strictObject({
|
|
23248
|
+
path: import_zod41.z.string().min(1),
|
|
23249
|
+
configProfile: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
|
|
23250
|
+
identity: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional()
|
|
22915
23251
|
});
|
|
22916
23252
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
22917
|
-
var ConfigRuleRemoveInputSchema =
|
|
23253
|
+
var ConfigRuleRemoveInputSchema = import_zod41.z.strictObject({ path: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22918
23254
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
22919
23255
|
|
|
22920
23256
|
// src/frontdoor/configApi.ts
|
|
@@ -22988,7 +23324,7 @@ function profileValue(name, paths) {
|
|
|
22988
23324
|
function createConfigApiRouter(deps) {
|
|
22989
23325
|
const authed = doorApiAuth(deps.expectedToken);
|
|
22990
23326
|
const { paths } = deps;
|
|
22991
|
-
const route = (
|
|
23327
|
+
const route = (path56, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path56, summary, tags: [CONFIG_API_TAG] }));
|
|
22992
23328
|
return {
|
|
22993
23329
|
config: {
|
|
22994
23330
|
identity: {
|
|
@@ -23258,51 +23594,51 @@ var import_openapi4 = require("@orpc/openapi");
|
|
|
23258
23594
|
var import_server3 = require("@orpc/server");
|
|
23259
23595
|
|
|
23260
23596
|
// src/frontdoor/eventSchemas.ts
|
|
23261
|
-
var
|
|
23597
|
+
var import_zod42 = require("zod");
|
|
23262
23598
|
init_schema2();
|
|
23263
23599
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
23264
23600
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
23265
23601
|
var USAGE_EVENT_SOURCE = "usage";
|
|
23266
23602
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
23267
23603
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
23268
|
-
var DoorEventSchema =
|
|
23269
|
-
source:
|
|
23604
|
+
var DoorEventSchema = import_zod42.z.strictObject({
|
|
23605
|
+
source: import_zod42.z.string().min(1),
|
|
23270
23606
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
23271
|
-
sequence:
|
|
23272
|
-
payload:
|
|
23607
|
+
sequence: import_zod42.z.number().int().positive(),
|
|
23608
|
+
payload: import_zod42.z.unknown()
|
|
23273
23609
|
});
|
|
23274
|
-
var DoorEventSourceQuerySchema =
|
|
23275
|
-
sources:
|
|
23610
|
+
var DoorEventSourceQuerySchema = import_zod42.z.strictObject({
|
|
23611
|
+
sources: import_zod42.z.array(import_zod42.z.string().min(1)).min(1).optional()
|
|
23276
23612
|
});
|
|
23277
|
-
var LaunchLifecycleEventSchema =
|
|
23278
|
-
kind:
|
|
23279
|
-
pid:
|
|
23280
|
-
startedAt:
|
|
23281
|
-
observedAt:
|
|
23613
|
+
var LaunchLifecycleEventSchema = import_zod42.z.strictObject({
|
|
23614
|
+
kind: import_zod42.z.enum(["registered", "pruned", "ended"]),
|
|
23615
|
+
pid: import_zod42.z.number().int().positive(),
|
|
23616
|
+
startedAt: import_zod42.z.number(),
|
|
23617
|
+
observedAt: import_zod42.z.number()
|
|
23282
23618
|
});
|
|
23283
|
-
var DoorHealthEventSchema =
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23619
|
+
var DoorHealthEventSchema = import_zod42.z.discriminatedUnion("kind", [
|
|
23620
|
+
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() }),
|
|
23621
|
+
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() }),
|
|
23622
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("binaryTurnover"), pid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
|
|
23623
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("idleShutdown"), pid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
|
|
23624
|
+
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() }),
|
|
23625
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("drained"), pid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() })
|
|
23290
23626
|
]);
|
|
23291
|
-
var QuotaExpiringEventSchema =
|
|
23627
|
+
var QuotaExpiringEventSchema = import_zod42.z.strictObject({
|
|
23292
23628
|
/** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
|
|
23293
|
-
id:
|
|
23629
|
+
id: import_zod42.z.string().min(1),
|
|
23294
23630
|
/** 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:
|
|
23631
|
+
name: import_zod42.z.string().min(1).optional(),
|
|
23632
|
+
provider: import_zod42.z.string().min(1),
|
|
23633
|
+
window: import_zod42.z.enum(["fiveHour", "sevenDay"]),
|
|
23298
23634
|
/** 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:
|
|
23635
|
+
utilization: import_zod42.z.number().min(0).max(1),
|
|
23636
|
+
resetsAt: import_zod42.z.iso.datetime(),
|
|
23637
|
+
observedAt: import_zod42.z.number()
|
|
23302
23638
|
});
|
|
23303
23639
|
var UsageChangeEventSchema = UsageSnapshotSchema.extend({
|
|
23304
|
-
id:
|
|
23305
|
-
name:
|
|
23640
|
+
id: import_zod42.z.string().min(1),
|
|
23641
|
+
name: import_zod42.z.string().min(1).optional()
|
|
23306
23642
|
});
|
|
23307
23643
|
|
|
23308
23644
|
// src/frontdoor/eventsApi.ts
|
|
@@ -23346,7 +23682,7 @@ function createEventsApiRouter(deps) {
|
|
|
23346
23682
|
// src/frontdoor/lifecycleApi.ts
|
|
23347
23683
|
var import_client4 = require("@orpc/client");
|
|
23348
23684
|
var import_openapi5 = require("@orpc/openapi");
|
|
23349
|
-
var
|
|
23685
|
+
var import_zod43 = require("zod");
|
|
23350
23686
|
init_update();
|
|
23351
23687
|
var FRONTDOOR_API_TAG = "frontdoor";
|
|
23352
23688
|
var UPDATE_API_TAG = "update";
|
|
@@ -23354,7 +23690,7 @@ function createLifecycleApiRouter(deps) {
|
|
|
23354
23690
|
const authed = doorApiAuth(deps.expectedToken);
|
|
23355
23691
|
return {
|
|
23356
23692
|
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(
|
|
23693
|
+
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
23694
|
deps.refreshCatalogues();
|
|
23359
23695
|
return { requested: true };
|
|
23360
23696
|
}),
|
|
@@ -23390,65 +23726,65 @@ var import_openapi6 = require("@orpc/openapi");
|
|
|
23390
23726
|
init_cliError();
|
|
23391
23727
|
|
|
23392
23728
|
// src/frontdoor/launchSchemas.ts
|
|
23393
|
-
var
|
|
23394
|
-
var
|
|
23729
|
+
var import_node_path45 = __toESM(require("node:path"), 1);
|
|
23730
|
+
var import_zod44 = require("zod");
|
|
23395
23731
|
init_statusline();
|
|
23396
23732
|
init_claudeVersion();
|
|
23397
|
-
|
|
23398
|
-
var LaunchResolveInputSchema =
|
|
23399
|
-
path:
|
|
23733
|
+
init_identity2();
|
|
23734
|
+
var LaunchResolveInputSchema = import_zod44.z.strictObject({
|
|
23735
|
+
path: import_zod44.z.string().min(1),
|
|
23400
23736
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
23401
|
-
argv:
|
|
23737
|
+
argv: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())).optional(),
|
|
23402
23738
|
/** 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:
|
|
23739
|
+
env: import_zod44.z.record(import_zod44.z.string(), import_zod44.z.string()).optional()
|
|
23740
|
+
}).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" });
|
|
23741
|
+
var LaunchPoolDecisionSchema = import_zod44.z.strictObject({
|
|
23742
|
+
name: import_zod44.z.string(),
|
|
23743
|
+
reasons: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())),
|
|
23408
23744
|
/** 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:
|
|
23745
|
+
provider: import_zod44.z.string().optional(),
|
|
23746
|
+
movedOff: import_zod44.z.strictObject({ identity: import_zod44.z.string(), reason: import_zod44.z.string() }).optional()
|
|
23411
23747
|
});
|
|
23412
|
-
var LaunchDecisionSchema =
|
|
23413
|
-
identity:
|
|
23414
|
-
identityId:
|
|
23415
|
-
identitySource:
|
|
23748
|
+
var LaunchDecisionSchema = import_zod44.z.strictObject({
|
|
23749
|
+
identity: import_zod44.z.string().optional(),
|
|
23750
|
+
identityId: import_zod44.z.string().optional(),
|
|
23751
|
+
identitySource: import_zod44.z.enum(IDENTITY_DECISION_SOURCES),
|
|
23416
23752
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
23417
23753
|
/** 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:
|
|
23754
|
+
configDirEscapeHatch: import_zod44.z.boolean(),
|
|
23755
|
+
configDir: import_zod44.z.string().optional(),
|
|
23756
|
+
configProfile: import_zod44.z.string().optional(),
|
|
23757
|
+
configProfileSource: import_zod44.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
23758
|
+
provider: import_zod44.z.string().optional()
|
|
23423
23759
|
});
|
|
23424
|
-
var LaunchFlagsSchema =
|
|
23425
|
-
skipPermissions:
|
|
23426
|
-
remoteControl:
|
|
23427
|
-
headroom:
|
|
23428
|
-
trackUsage:
|
|
23429
|
-
pause:
|
|
23430
|
-
explain:
|
|
23760
|
+
var LaunchFlagsSchema = import_zod44.z.strictObject({
|
|
23761
|
+
skipPermissions: import_zod44.z.boolean(),
|
|
23762
|
+
remoteControl: import_zod44.z.boolean(),
|
|
23763
|
+
headroom: import_zod44.z.boolean(),
|
|
23764
|
+
trackUsage: import_zod44.z.boolean(),
|
|
23765
|
+
pause: import_zod44.z.boolean(),
|
|
23766
|
+
explain: import_zod44.z.boolean(),
|
|
23431
23767
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
23432
|
-
delayMs:
|
|
23768
|
+
delayMs: import_zod44.z.number(),
|
|
23433
23769
|
/** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
|
|
23434
|
-
proxyBypass:
|
|
23770
|
+
proxyBypass: import_zod44.z.array(import_zod44.z.string()).readonly(),
|
|
23435
23771
|
/** How the session's built-in statusline looks, when the launch configures any of it. */
|
|
23436
23772
|
statusline: StatuslineSchema.optional()
|
|
23437
23773
|
});
|
|
23438
|
-
var LaunchResolveOutputSchema =
|
|
23774
|
+
var LaunchResolveOutputSchema = import_zod44.z.strictObject({
|
|
23439
23775
|
decision: LaunchDecisionSchema,
|
|
23440
23776
|
flags: LaunchFlagsSchema,
|
|
23441
|
-
claudeVersion:
|
|
23777
|
+
claudeVersion: import_zod44.z.strictObject({ version: import_zod44.z.string(), source: import_zod44.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
23442
23778
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
23443
|
-
bin:
|
|
23779
|
+
bin: import_zod44.z.string(),
|
|
23444
23780
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
23445
|
-
args:
|
|
23781
|
+
args: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())),
|
|
23446
23782
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
23447
|
-
credential:
|
|
23448
|
-
routing:
|
|
23783
|
+
credential: import_zod44.z.strictObject({ subject: import_zod44.z.enum(["provider", "identity"]), name: import_zod44.z.string(), summary: CredentialSummarySchema }).optional(),
|
|
23784
|
+
routing: import_zod44.z.strictObject({ frontDoor: import_zod44.z.boolean(), headroom: import_zod44.z.boolean() }),
|
|
23449
23785
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
23450
|
-
environment:
|
|
23451
|
-
warnings:
|
|
23786
|
+
environment: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())),
|
|
23787
|
+
warnings: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string()))
|
|
23452
23788
|
});
|
|
23453
23789
|
|
|
23454
23790
|
// src/frontdoor/launchApi.ts
|
|
@@ -23484,24 +23820,24 @@ function createLaunchApiRouter(deps) {
|
|
|
23484
23820
|
// src/frontdoor/agentTreesApi.ts
|
|
23485
23821
|
var import_client6 = require("@orpc/client");
|
|
23486
23822
|
var import_openapi7 = require("@orpc/openapi");
|
|
23487
|
-
var
|
|
23823
|
+
var import_zod45 = require("zod");
|
|
23488
23824
|
init_liveTasks();
|
|
23489
23825
|
init_schema3();
|
|
23490
23826
|
init_cliError();
|
|
23491
|
-
var AgentTreesListInputSchema =
|
|
23827
|
+
var AgentTreesListInputSchema = import_zod45.z.strictObject({
|
|
23492
23828
|
/** Only this identity's sessions. */
|
|
23493
|
-
identity:
|
|
23829
|
+
identity: import_zod45.z.string().optional(),
|
|
23494
23830
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
23495
|
-
all:
|
|
23831
|
+
all: import_zod45.z.boolean().optional()
|
|
23496
23832
|
});
|
|
23497
|
-
var AgentTreesListOutputSchema =
|
|
23498
|
-
var AgentTreesShowInputSchema =
|
|
23833
|
+
var AgentTreesListOutputSchema = import_zod45.z.array(SessionSummarySchema);
|
|
23834
|
+
var AgentTreesShowInputSchema = import_zod45.z.strictObject({
|
|
23499
23835
|
/** A session id, or an unambiguous prefix of one. */
|
|
23500
|
-
session:
|
|
23836
|
+
session: import_zod45.z.string().min(1),
|
|
23501
23837
|
/** Look only in this identity. */
|
|
23502
|
-
identity:
|
|
23838
|
+
identity: import_zod45.z.string().optional()
|
|
23503
23839
|
});
|
|
23504
|
-
var AgentTreesShowOutputSchema =
|
|
23840
|
+
var AgentTreesShowOutputSchema = import_zod45.z.strictObject({ identities: import_zod45.z.array(import_zod45.z.string()), ...MergedAgentTreeSchema.shape });
|
|
23505
23841
|
function asBadRequest(error) {
|
|
23506
23842
|
if (error instanceof CliError) {
|
|
23507
23843
|
throw new import_client6.ORPCError("BAD_REQUEST", { message: error.message });
|
|
@@ -23554,7 +23890,7 @@ var import_openapi8 = require("@orpc/openapi");
|
|
|
23554
23890
|
var import_server4 = require("@orpc/server");
|
|
23555
23891
|
|
|
23556
23892
|
// src/frontdoor/rcEventLog.ts
|
|
23557
|
-
var
|
|
23893
|
+
var import_zod46 = require("zod");
|
|
23558
23894
|
|
|
23559
23895
|
// src/frontdoor/eventHub.ts
|
|
23560
23896
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -23679,46 +24015,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
|
23679
24015
|
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
23680
24016
|
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
23681
24017
|
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
|
-
|
|
24018
|
+
var transitionBase = { session: import_zod46.z.string(), at: import_zod46.z.number() };
|
|
24019
|
+
var cursorFields = { cursor: import_zod46.z.string(), sequence: import_zod46.z.int().positive() };
|
|
24020
|
+
var sessionAppearedShape = { kind: import_zod46.z.literal("session-appeared"), ...transitionBase };
|
|
24021
|
+
var sessionEndedShape = { kind: import_zod46.z.literal("session-ended"), reason: import_zod46.z.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
24022
|
+
var workerStateShape = { kind: import_zod46.z.literal("worker-state"), state: import_zod46.z.string(), previous: import_zod46.z.string().optional(), ...transitionBase };
|
|
24023
|
+
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 };
|
|
24024
|
+
var pendingRetiredShape = { kind: import_zod46.z.literal("pending-retired"), requestId: import_zod46.z.string(), reason: import_zod46.z.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
24025
|
+
var RcSessionTransitionSchema = import_zod46.z.discriminatedUnion("kind", [
|
|
24026
|
+
import_zod46.z.strictObject(sessionAppearedShape),
|
|
24027
|
+
import_zod46.z.strictObject(sessionEndedShape),
|
|
24028
|
+
import_zod46.z.strictObject(workerStateShape),
|
|
24029
|
+
import_zod46.z.strictObject(pendingBornShape),
|
|
24030
|
+
import_zod46.z.strictObject(pendingRetiredShape)
|
|
23695
24031
|
]);
|
|
23696
24032
|
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
23697
24033
|
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
24034
|
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
|
-
|
|
24035
|
+
var RcSessionEventSchema = import_zod46.z.discriminatedUnion("kind", [
|
|
24036
|
+
import_zod46.z.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
24037
|
+
import_zod46.z.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
24038
|
+
import_zod46.z.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
24039
|
+
import_zod46.z.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
24040
|
+
import_zod46.z.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
23705
24041
|
]);
|
|
23706
|
-
var RcSessionEventsReadInputSchema =
|
|
24042
|
+
var RcSessionEventsReadInputSchema = import_zod46.z.strictObject({
|
|
23707
24043
|
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
23708
|
-
since:
|
|
24044
|
+
since: import_zod46.z.string().min(1).optional(),
|
|
23709
24045
|
/** One `cse_` session id; every session when omitted. */
|
|
23710
|
-
session:
|
|
24046
|
+
session: import_zod46.z.string().min(1).optional(),
|
|
23711
24047
|
/** The most events one answer carries; every event after `since` when omitted. */
|
|
23712
|
-
limit:
|
|
24048
|
+
limit: import_zod46.z.int().positive().optional()
|
|
23713
24049
|
});
|
|
23714
24050
|
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
23715
24051
|
/** 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:
|
|
24052
|
+
limit: import_zod46.z.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
23717
24053
|
});
|
|
23718
24054
|
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
23719
|
-
var RcSessionEventsReadOutputSchema =
|
|
23720
|
-
|
|
23721
|
-
|
|
24055
|
+
var RcSessionEventsReadOutputSchema = import_zod46.z.discriminatedUnion("status", [
|
|
24056
|
+
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() }),
|
|
24057
|
+
import_zod46.z.strictObject({ status: import_zod46.z.literal("expired"), message: import_zod46.z.string(), head: import_zod46.z.string() })
|
|
23722
24058
|
]);
|
|
23723
24059
|
var CURSOR_SEPARATOR = ".";
|
|
23724
24060
|
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 +26241,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25905
26241
|
}
|
|
25906
26242
|
|
|
25907
26243
|
// src/frontdoor/rcSelfHostMint.ts
|
|
25908
|
-
var
|
|
26244
|
+
var import_node_path46 = __toESM(require("node:path"), 1);
|
|
25909
26245
|
init_identityRecords();
|
|
25910
26246
|
init_account();
|
|
25911
26247
|
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
@@ -25931,7 +26267,7 @@ function readJsonObject(fs17, file) {
|
|
|
25931
26267
|
return isRecord16(parsed) ? parsed : void 0;
|
|
25932
26268
|
}
|
|
25933
26269
|
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
25934
|
-
const parsed = readJsonObject(fs17,
|
|
26270
|
+
const parsed = readJsonObject(fs17, import_node_path46.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
25935
26271
|
if (parsed === void 0) {
|
|
25936
26272
|
return void 0;
|
|
25937
26273
|
}
|
|
@@ -25949,11 +26285,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25949
26285
|
if (id === void 0) {
|
|
25950
26286
|
throw new Error(`No identity named "${deps.identity}".`);
|
|
25951
26287
|
}
|
|
25952
|
-
const identityDir =
|
|
25953
|
-
const credentialsFile =
|
|
25954
|
-
const claudeJsonFile =
|
|
25955
|
-
const recordDir =
|
|
25956
|
-
const recordFile2 =
|
|
26288
|
+
const identityDir = import_node_path46.default.join(deps.identitiesDir, id);
|
|
26289
|
+
const credentialsFile = import_node_path46.default.join(identityDir, CREDENTIALS_FILE2);
|
|
26290
|
+
const claudeJsonFile = import_node_path46.default.join(identityDir, CLAUDE_JSON2);
|
|
26291
|
+
const recordDir = import_node_path46.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
26292
|
+
const recordFile2 = import_node_path46.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
25957
26293
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
25958
26294
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
25959
26295
|
const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -25969,7 +26305,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25969
26305
|
const organizationUuid = deps.newUuid();
|
|
25970
26306
|
const accountUuid = deps.newUuid();
|
|
25971
26307
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
25972
|
-
deps.fs.mkdirPrivate(
|
|
26308
|
+
deps.fs.mkdirPrivate(import_node_path46.default.dirname(credentialsFile));
|
|
25973
26309
|
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
26310
|
`);
|
|
25975
26311
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -26005,7 +26341,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
26005
26341
|
init_ensure2();
|
|
26006
26342
|
|
|
26007
26343
|
// src/frontdoor/liveSessionRegistry.ts
|
|
26008
|
-
var
|
|
26344
|
+
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
26009
26345
|
init_capability();
|
|
26010
26346
|
init_state();
|
|
26011
26347
|
function sameStat(recorded, current) {
|
|
@@ -26029,7 +26365,7 @@ function createLiveSessionRegistry(ports) {
|
|
|
26029
26365
|
const load = (name, stat) => {
|
|
26030
26366
|
known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs17, sessionsDir, name) });
|
|
26031
26367
|
};
|
|
26032
|
-
const statOf = (name) => fs17.lstat(
|
|
26368
|
+
const statOf = (name) => fs17.lstat(import_node_path47.default.join(sessionsDir, name));
|
|
26033
26369
|
const reconcile = () => {
|
|
26034
26370
|
const names = new Set(recordNames());
|
|
26035
26371
|
let changed = false;
|
|
@@ -26103,8 +26439,8 @@ init_poolPick();
|
|
|
26103
26439
|
init_liveTasks();
|
|
26104
26440
|
|
|
26105
26441
|
// src/agents/read.ts
|
|
26106
|
-
var
|
|
26107
|
-
var
|
|
26442
|
+
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
26443
|
+
var import_zod47 = require("zod");
|
|
26108
26444
|
init_schema3();
|
|
26109
26445
|
var PROJECTS_DIR = "projects";
|
|
26110
26446
|
var TASKS_DIR = "tasks";
|
|
@@ -26130,15 +26466,15 @@ function parseEntry2(project, entry) {
|
|
|
26130
26466
|
}
|
|
26131
26467
|
function listSessions2(fs17, configDir) {
|
|
26132
26468
|
const found = [];
|
|
26133
|
-
for (const project of fs17.readdir(
|
|
26134
|
-
const projectDir =
|
|
26469
|
+
for (const project of fs17.readdir(import_node_path48.default.join(configDir, PROJECTS_DIR))) {
|
|
26470
|
+
const projectDir = import_node_path48.default.join(configDir, PROJECTS_DIR, project);
|
|
26135
26471
|
const entries = /* @__PURE__ */ new Set();
|
|
26136
26472
|
for (const name of fs17.readdir(projectDir)) {
|
|
26137
26473
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
26138
26474
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
26139
26475
|
continue;
|
|
26140
26476
|
}
|
|
26141
|
-
const children = fs17.readdir(
|
|
26477
|
+
const children = fs17.readdir(import_node_path48.default.join(projectDir, name));
|
|
26142
26478
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
26143
26479
|
entries.add(name);
|
|
26144
26480
|
}
|
|
@@ -26158,8 +26494,8 @@ function locateAgents(fs17, configDir, relativeDir, workflowRunId, report) {
|
|
|
26158
26494
|
const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
|
|
26159
26495
|
located.push({
|
|
26160
26496
|
id,
|
|
26161
|
-
metaPath:
|
|
26162
|
-
transcriptPath:
|
|
26497
|
+
metaPath: import_node_path48.default.join(relativeDir, name),
|
|
26498
|
+
transcriptPath: import_node_path48.default.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
|
|
26163
26499
|
workflowRunId
|
|
26164
26500
|
});
|
|
26165
26501
|
}
|
|
@@ -26202,7 +26538,7 @@ function describeFailure(error) {
|
|
|
26202
26538
|
}
|
|
26203
26539
|
function readFileOrReport(fs17, configDir, relative, report) {
|
|
26204
26540
|
try {
|
|
26205
|
-
return fs17.readFileUtf8(
|
|
26541
|
+
return fs17.readFileUtf8(import_node_path48.default.join(configDir, relative));
|
|
26206
26542
|
} catch (error) {
|
|
26207
26543
|
report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
|
|
26208
26544
|
return void 0;
|
|
@@ -26210,7 +26546,7 @@ function readFileOrReport(fs17, configDir, relative, report) {
|
|
|
26210
26546
|
}
|
|
26211
26547
|
function listDirOrReport(fs17, configDir, relative, report) {
|
|
26212
26548
|
try {
|
|
26213
|
-
return fs17.readdir(
|
|
26549
|
+
return fs17.readdir(import_node_path48.default.join(configDir, relative));
|
|
26214
26550
|
} catch (error) {
|
|
26215
26551
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
|
|
26216
26552
|
return [];
|
|
@@ -26224,28 +26560,28 @@ function parseJson2(text) {
|
|
|
26224
26560
|
return void 0;
|
|
26225
26561
|
}
|
|
26226
26562
|
}
|
|
26227
|
-
var TaskFileSchema =
|
|
26228
|
-
var WorkflowRunFileSchema =
|
|
26229
|
-
runId:
|
|
26230
|
-
workflowName:
|
|
26231
|
-
status:
|
|
26232
|
-
startTime:
|
|
26233
|
-
phases:
|
|
26234
|
-
summary:
|
|
26563
|
+
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([]) });
|
|
26564
|
+
var WorkflowRunFileSchema = import_zod47.z.object({
|
|
26565
|
+
runId: import_zod47.z.string(),
|
|
26566
|
+
workflowName: import_zod47.z.string().optional(),
|
|
26567
|
+
status: import_zod47.z.string().optional(),
|
|
26568
|
+
startTime: import_zod47.z.number().optional(),
|
|
26569
|
+
phases: import_zod47.z.array(import_zod47.z.object({ title: import_zod47.z.string() })).default([]),
|
|
26570
|
+
summary: import_zod47.z.string().optional()
|
|
26235
26571
|
});
|
|
26236
26572
|
function summariseSession(fs17, configDir, ref) {
|
|
26237
|
-
const sessionRelative =
|
|
26238
|
-
const subagentsRelative =
|
|
26239
|
-
const workflowsUnderSubagents =
|
|
26573
|
+
const sessionRelative = import_node_path48.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26574
|
+
const subagentsRelative = import_node_path48.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
26575
|
+
const workflowsUnderSubagents = import_node_path48.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26240
26576
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
26241
|
-
let agentCount = fs17.readdir(
|
|
26242
|
-
for (const runDir of fs17.readdir(
|
|
26577
|
+
let agentCount = fs17.readdir(import_node_path48.default.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
26578
|
+
for (const runDir of fs17.readdir(import_node_path48.default.join(configDir, workflowsUnderSubagents))) {
|
|
26243
26579
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26244
|
-
agentCount += fs17.readdir(
|
|
26580
|
+
agentCount += fs17.readdir(import_node_path48.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
26245
26581
|
}
|
|
26246
26582
|
}
|
|
26247
|
-
const workflowRunCount = fs17.readdir(
|
|
26248
|
-
const transcript = fs17.lstat(
|
|
26583
|
+
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;
|
|
26584
|
+
const transcript = fs17.lstat(import_node_path48.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
26249
26585
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
26250
26586
|
}
|
|
26251
26587
|
function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
@@ -26253,13 +26589,13 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26253
26589
|
const report = (problem) => {
|
|
26254
26590
|
problems.push(problem);
|
|
26255
26591
|
};
|
|
26256
|
-
const sessionRelative =
|
|
26257
|
-
const subagentsRelative =
|
|
26258
|
-
const workflowsUnderSubagents =
|
|
26592
|
+
const sessionRelative = import_node_path48.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26593
|
+
const subagentsRelative = import_node_path48.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
26594
|
+
const workflowsUnderSubagents = import_node_path48.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26259
26595
|
const located = locateAgents(fs17, configDir, subagentsRelative, void 0, report);
|
|
26260
26596
|
for (const runDir of listDirOrReport(fs17, configDir, workflowsUnderSubagents, report)) {
|
|
26261
26597
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26262
|
-
located.push(...locateAgents(fs17, configDir,
|
|
26598
|
+
located.push(...locateAgents(fs17, configDir, import_node_path48.default.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
26263
26599
|
}
|
|
26264
26600
|
}
|
|
26265
26601
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -26300,7 +26636,7 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26300
26636
|
superseded: ref.superseded,
|
|
26301
26637
|
agents: roots.sort().map(build),
|
|
26302
26638
|
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,
|
|
26639
|
+
workflowRuns: readWorkflowRuns(fs17, configDir, import_node_path48.default.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
26304
26640
|
problems
|
|
26305
26641
|
};
|
|
26306
26642
|
}
|
|
@@ -26365,12 +26701,12 @@ function ownTaskLists(sessionId) {
|
|
|
26365
26701
|
function readTasks(fs17, configDir, ownLists, sharedLists, report) {
|
|
26366
26702
|
const tasks = [];
|
|
26367
26703
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
26368
|
-
const relativeDir =
|
|
26704
|
+
const relativeDir = import_node_path48.default.join(TASKS_DIR, scope);
|
|
26369
26705
|
for (const name of [...listDirOrReport(fs17, configDir, relativeDir, report)].sort()) {
|
|
26370
26706
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
26371
26707
|
continue;
|
|
26372
26708
|
}
|
|
26373
|
-
const relative =
|
|
26709
|
+
const relative = import_node_path48.default.join(relativeDir, name);
|
|
26374
26710
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26375
26711
|
const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26376
26712
|
if (parsed.success) {
|
|
@@ -26388,7 +26724,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26388
26724
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
26389
26725
|
continue;
|
|
26390
26726
|
}
|
|
26391
|
-
const relative =
|
|
26727
|
+
const relative = import_node_path48.default.join(relativeDir, name);
|
|
26392
26728
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26393
26729
|
const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26394
26730
|
if (!parsed.success) {
|
|
@@ -26404,7 +26740,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26404
26740
|
}
|
|
26405
26741
|
|
|
26406
26742
|
// src/agents/sessions.ts
|
|
26407
|
-
var
|
|
26743
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
26408
26744
|
init_cliError();
|
|
26409
26745
|
var SessionLookupError = class extends CliError {
|
|
26410
26746
|
constructor(message) {
|
|
@@ -26416,7 +26752,7 @@ function historyStores(fs17, configDirOf, identities) {
|
|
|
26416
26752
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
26417
26753
|
for (const identity of identities) {
|
|
26418
26754
|
const configDir = configDirOf(identity);
|
|
26419
|
-
const real = fs17.realpath(
|
|
26755
|
+
const real = fs17.realpath(import_node_path49.default.join(configDir, "projects"));
|
|
26420
26756
|
if (real === void 0) {
|
|
26421
26757
|
continue;
|
|
26422
26758
|
}
|
|
@@ -26518,7 +26854,7 @@ init_load();
|
|
|
26518
26854
|
init_launchWiring();
|
|
26519
26855
|
init_argv();
|
|
26520
26856
|
init_cascade();
|
|
26521
|
-
|
|
26857
|
+
init_identity2();
|
|
26522
26858
|
|
|
26523
26859
|
// src/launcher/poolRefresh.ts
|
|
26524
26860
|
init_anthropicUsageRefresh();
|