claude-use 14.2.4 → 14.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +7733 -6185
- package/dist/index.cjs +1737 -1400
- package/dist/index.mjs +1698 -1361
- package/dist/types/index.d.ts +16 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -668,6 +668,134 @@ var init_statusline = __esm({
|
|
|
668
668
|
}
|
|
669
669
|
});
|
|
670
670
|
|
|
671
|
+
// src/models/identity.ts
|
|
672
|
+
function withoutContextMarker(model) {
|
|
673
|
+
return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? model.slice(0, -CONTEXT_MARKER_1M.length) : model;
|
|
674
|
+
}
|
|
675
|
+
function namesAModel(value) {
|
|
676
|
+
return withoutContextMarker(value).trim() !== "";
|
|
677
|
+
}
|
|
678
|
+
function canonicalText(name) {
|
|
679
|
+
return name.trim().toLowerCase().replace(NON_IDENTITY_BRACKET_RE, "").replace(/[\s_]+/g, "-").replace(/([a-z])(\d+(?:\.\d+)+)/g, "$1-$2").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
680
|
+
}
|
|
681
|
+
function splitVariants(tokens) {
|
|
682
|
+
const variants = [];
|
|
683
|
+
let end = tokens.length;
|
|
684
|
+
for (; ; ) {
|
|
685
|
+
const token = tokens[end - 1];
|
|
686
|
+
if (token === void 0 || !KNOWN_VARIANTS.has(token)) {
|
|
687
|
+
return { familyTokens: tokens.slice(0, end), variants };
|
|
688
|
+
}
|
|
689
|
+
variants.unshift(token);
|
|
690
|
+
end -= 1;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
function versionOf(tokens) {
|
|
694
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
695
|
+
const token = tokens[index];
|
|
696
|
+
const next = tokens[index + 1];
|
|
697
|
+
if (token === void 0) {
|
|
698
|
+
return "";
|
|
699
|
+
}
|
|
700
|
+
if (/^\d+$/.test(token) && next !== void 0 && /^\d+$/.test(next)) {
|
|
701
|
+
return `${token}.${next}`;
|
|
702
|
+
}
|
|
703
|
+
const dotted = /^\d+(?:\.\d+)+$/.exec(token);
|
|
704
|
+
if (dotted !== null) {
|
|
705
|
+
return dotted[0];
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return "";
|
|
709
|
+
}
|
|
710
|
+
function modelIdentity(rawName) {
|
|
711
|
+
const segments = rawName.trim().toLowerCase().split("/");
|
|
712
|
+
const stripped = canonicalText(segments[segments.length - 1] ?? "").split(":")[0] ?? "";
|
|
713
|
+
const withoutDate = stripped.replace(DATE_STAMP_RE, "");
|
|
714
|
+
const tokens = withoutDate.split("-").filter((token) => token !== "");
|
|
715
|
+
const { familyTokens, variants } = splitVariants(tokens);
|
|
716
|
+
const version = versionOf(familyTokens);
|
|
717
|
+
const versionless = familyTokens.filter((token, index) => {
|
|
718
|
+
if (version === "") {
|
|
719
|
+
return true;
|
|
720
|
+
}
|
|
721
|
+
const dotted = /^\d+(?:\.\d+)+$/.test(token);
|
|
722
|
+
const previous = familyTokens[index - 1];
|
|
723
|
+
const next = familyTokens[index + 1];
|
|
724
|
+
const insideVersionRun = dotted || /^\d+$/.test(token) && (previous !== void 0 && /^\d+$/.test(previous) || next !== void 0 && /^\d+$/.test(next));
|
|
725
|
+
return !insideVersionRun;
|
|
726
|
+
});
|
|
727
|
+
const family = versionless.join("-");
|
|
728
|
+
const tokenVendor = familyTokens.find((token) => Object.keys(VENDOR_BY_TOKEN).some((key) => token === key || token.startsWith(key)));
|
|
729
|
+
const namespace = segments.length >= 2 ? (segments[0] ?? "").split(":").pop() ?? "" : "";
|
|
730
|
+
const namespaceVendor = VENDOR_BY_NAMESPACE[namespace] ?? "";
|
|
731
|
+
const tokenVendorName = tokenVendor === void 0 ? "" : VENDOR_BY_TOKEN[Object.keys(VENDOR_BY_TOKEN).find((key) => tokenVendor === key || tokenVendor.startsWith(key)) ?? ""] ?? "";
|
|
732
|
+
return {
|
|
733
|
+
vendor: tokenVendorName === "" ? namespaceVendor : tokenVendorName,
|
|
734
|
+
vendorConflict: tokenVendorName !== "" && namespaceVendor !== "" && tokenVendorName !== namespaceVendor,
|
|
735
|
+
family,
|
|
736
|
+
version,
|
|
737
|
+
variant: variants.join("-"),
|
|
738
|
+
familyAndVersion: version === "" ? family : `${family}-${version.replace(/\./g, "-")}`
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
function relateModels(left, right) {
|
|
742
|
+
const a = modelIdentity(left);
|
|
743
|
+
const b = modelIdentity(right);
|
|
744
|
+
if (a.familyAndVersion !== b.familyAndVersion) {
|
|
745
|
+
return sameFamilyOtherVersion(a, b) ? "similar" : "distinct";
|
|
746
|
+
}
|
|
747
|
+
if (a.variant !== b.variant || a.vendorConflict || b.vendorConflict || a.vendor !== "" && b.vendor !== "" && a.vendor !== b.vendor) {
|
|
748
|
+
return "similar";
|
|
749
|
+
}
|
|
750
|
+
return "same";
|
|
751
|
+
}
|
|
752
|
+
function sameFamilyOtherVersion(a, b) {
|
|
753
|
+
if (a.family !== b.family) {
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
if (a.vendor !== "" && b.vendor !== "" && a.vendor !== b.vendor) {
|
|
757
|
+
return false;
|
|
758
|
+
}
|
|
759
|
+
return true;
|
|
760
|
+
}
|
|
761
|
+
var NON_IDENTITY_BRACKET_RE, CONTEXT_MARKER_1M, DATE_STAMP_RE, KNOWN_VARIANTS, VENDOR_BY_NAMESPACE, VENDOR_BY_TOKEN;
|
|
762
|
+
var init_identity = __esm({
|
|
763
|
+
"src/models/identity.ts"() {
|
|
764
|
+
"use strict";
|
|
765
|
+
NON_IDENTITY_BRACKET_RE = /\[[^\]]*\]/g;
|
|
766
|
+
CONTEXT_MARKER_1M = "[1m]";
|
|
767
|
+
DATE_STAMP_RE = /-(?:19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/;
|
|
768
|
+
KNOWN_VARIANTS = /* @__PURE__ */ new Set(["high", "medium", "low", "thinking", "xhigh", "max", "highspeed", "sol", "terra", "luna", "mini", "flash-lite", "turbo"]);
|
|
769
|
+
VENDOR_BY_NAMESPACE = Object.freeze({
|
|
770
|
+
anthropic: "anthropic",
|
|
771
|
+
google: "google",
|
|
772
|
+
openai: "openai",
|
|
773
|
+
zai: "zai",
|
|
774
|
+
"z-ai": "zai",
|
|
775
|
+
minimax: "minimax",
|
|
776
|
+
qwen: "qwen",
|
|
777
|
+
deepseek: "deepseek",
|
|
778
|
+
moonshot: "moonshot",
|
|
779
|
+
meta: "meta",
|
|
780
|
+
mistral: "mistral"
|
|
781
|
+
});
|
|
782
|
+
VENDOR_BY_TOKEN = Object.freeze({
|
|
783
|
+
claude: "anthropic",
|
|
784
|
+
gemini: "google",
|
|
785
|
+
antigravity: "google",
|
|
786
|
+
gpt: "openai",
|
|
787
|
+
glm: "zai",
|
|
788
|
+
minimax: "minimax",
|
|
789
|
+
qwen: "qwen",
|
|
790
|
+
deepseek: "deepseek",
|
|
791
|
+
kimi: "moonshot",
|
|
792
|
+
llama: "meta",
|
|
793
|
+
mistral: "mistral",
|
|
794
|
+
mixtral: "mistral"
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
|
|
671
799
|
// src/versionDiscovery.ts
|
|
672
800
|
import os from "node:os";
|
|
673
801
|
import path2 from "node:path";
|
|
@@ -802,13 +930,14 @@ function isTimeZone(name) {
|
|
|
802
930
|
return false;
|
|
803
931
|
}
|
|
804
932
|
}
|
|
805
|
-
var 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;
|
|
933
|
+
var 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;
|
|
806
934
|
var init_schema = __esm({
|
|
807
935
|
"src/config/schema.ts"() {
|
|
808
936
|
"use strict";
|
|
809
937
|
init_proxyBypass();
|
|
810
938
|
init_names();
|
|
811
939
|
init_statusline();
|
|
940
|
+
init_identity();
|
|
812
941
|
init_versionDiscovery();
|
|
813
942
|
CATEGORY_NAMES = ["secret", "runtime", "history", "knowledge", "settings"];
|
|
814
943
|
OVERRIDABLE_CATEGORIES = ["runtime", "history", "knowledge", "settings"];
|
|
@@ -915,8 +1044,13 @@ var init_schema = __esm({
|
|
|
915
1044
|
});
|
|
916
1045
|
ProviderCredentialSchema = CredentialSchema.extend({ target: z3.enum(PROVIDER_CREDENTIAL_TARGETS).optional() });
|
|
917
1046
|
RESERVED_PROVIDER_ENV_KEYS = Object.values(CREDENTIAL_TARGET_VARS);
|
|
1047
|
+
TIER_MODEL_ENV_VARIABLES = ["ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL"];
|
|
1048
|
+
OTHER_MODEL_ENV_VARIABLES = ["ANTHROPIC_MODEL", "ANTHROPIC_SMALL_FAST_MODEL", "ANTHROPIC_DEFAULT_FABLE_MODEL"];
|
|
1049
|
+
MODEL_ENV_VARIABLES = [...OTHER_MODEL_ENV_VARIABLES, ...TIER_MODEL_ENV_VARIABLES];
|
|
918
1050
|
ProviderEnvSchema = z3.record(z3.string().min(1), z3.string()).refine((env) => !Object.keys(env).some((key) => RESERVED_PROVIDER_ENV_KEYS.includes(key)), {
|
|
919
1051
|
message: `env may not set ${RESERVED_PROVIDER_ENV_KEYS.join(", ")}: the credential block's target sets one and agent-shim removes the others`
|
|
1052
|
+
}).refine((env) => !MODEL_ENV_VARIABLES.some((key) => env[key] !== void 0 && env[key] !== "" && !namesAModel(env[key])), {
|
|
1053
|
+
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`
|
|
920
1054
|
});
|
|
921
1055
|
PROVIDER_KINDS = ["http", "codex", "antigravity", "router"];
|
|
922
1056
|
ANTIGRAVITY_MODES = ["cloud", "local"];
|
|
@@ -1019,6 +1153,7 @@ var init_schema = __esm({
|
|
|
1019
1153
|
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" });
|
|
1020
1154
|
}
|
|
1021
1155
|
});
|
|
1156
|
+
SERVER_TOOLS_MODES = ["forward", "drop"];
|
|
1022
1157
|
HttpProviderSchema = z3.strictObject({
|
|
1023
1158
|
$schema: z3.string().optional(),
|
|
1024
1159
|
kind: z3.literal("http").optional(),
|
|
@@ -1033,7 +1168,9 @@ var init_schema = __esm({
|
|
|
1033
1168
|
/** The provider's own model catalogue, listed in `/model` when set. */
|
|
1034
1169
|
catalogue: ProviderCatalogueSchema.optional(),
|
|
1035
1170
|
/** 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. */
|
|
1036
|
-
routes: z3.array(ProviderRouteSchema).optional()
|
|
1171
|
+
routes: z3.array(ProviderRouteSchema).optional(),
|
|
1172
|
+
/** 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. */
|
|
1173
|
+
serverTools: z3.enum(SERVER_TOOLS_MODES).optional()
|
|
1037
1174
|
});
|
|
1038
1175
|
CodexProviderSchema = z3.strictObject({
|
|
1039
1176
|
$schema: z3.string().optional(),
|
|
@@ -1321,7 +1458,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
1321
1458
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
1322
1459
|
}
|
|
1323
1460
|
function describeIgnoredKeys(filePath, ignored) {
|
|
1324
|
-
const places = ignored.map(({ path:
|
|
1461
|
+
const places = ignored.map(({ path: path56, keys }) => `${path56.length === 0 ? "" : `${path56.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
1325
1462
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
1326
1463
|
}
|
|
1327
1464
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -1343,9 +1480,9 @@ function restoreIgnoredKeys(filePath, value) {
|
|
|
1343
1480
|
return value;
|
|
1344
1481
|
}
|
|
1345
1482
|
const restored = structuredClone(value);
|
|
1346
|
-
for (const { path:
|
|
1483
|
+
for (const { path: path56, values } of ignored) {
|
|
1347
1484
|
let holder = restored;
|
|
1348
|
-
for (const step of
|
|
1485
|
+
for (const step of path56) {
|
|
1349
1486
|
holder = isRecord(holder) ? holder[step] : void 0;
|
|
1350
1487
|
}
|
|
1351
1488
|
if (isRecord(holder)) {
|
|
@@ -4316,6 +4453,43 @@ var init_baseUrlDisplay = __esm({
|
|
|
4316
4453
|
}
|
|
4317
4454
|
});
|
|
4318
4455
|
|
|
4456
|
+
// src/elapsedWindow.ts
|
|
4457
|
+
function within(sinceMs, nowMs, windowMs) {
|
|
4458
|
+
const age = nowMs - sinceMs;
|
|
4459
|
+
return age >= 0 && age < windowMs;
|
|
4460
|
+
}
|
|
4461
|
+
var init_elapsedWindow = __esm({
|
|
4462
|
+
"src/elapsedWindow.ts"() {
|
|
4463
|
+
"use strict";
|
|
4464
|
+
}
|
|
4465
|
+
});
|
|
4466
|
+
|
|
4467
|
+
// src/frontdoor/loggedText.ts
|
|
4468
|
+
var UNSAFE_CLASS, UNSAFE_IN_A_LINE, UNSAFE_CHARACTERS;
|
|
4469
|
+
var init_loggedText = __esm({
|
|
4470
|
+
"src/frontdoor/loggedText.ts"() {
|
|
4471
|
+
"use strict";
|
|
4472
|
+
UNSAFE_CLASS = "[\\p{Cc}\\p{Zl}\\p{Zp}\\p{Cf}]";
|
|
4473
|
+
UNSAFE_IN_A_LINE = new RegExp(UNSAFE_CLASS, "u");
|
|
4474
|
+
UNSAFE_CHARACTERS = new RegExp(UNSAFE_CLASS, "gu");
|
|
4475
|
+
}
|
|
4476
|
+
});
|
|
4477
|
+
|
|
4478
|
+
// src/canonicalJson.ts
|
|
4479
|
+
function canonicalJson(value) {
|
|
4480
|
+
return JSON.stringify(value, (_key, member) => {
|
|
4481
|
+
if (typeof member !== "object" || member === null || Array.isArray(member)) {
|
|
4482
|
+
return member;
|
|
4483
|
+
}
|
|
4484
|
+
return Object.fromEntries(Object.entries(member).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0));
|
|
4485
|
+
});
|
|
4486
|
+
}
|
|
4487
|
+
var init_canonicalJson = __esm({
|
|
4488
|
+
"src/canonicalJson.ts"() {
|
|
4489
|
+
"use strict";
|
|
4490
|
+
}
|
|
4491
|
+
});
|
|
4492
|
+
|
|
4319
4493
|
// src/usage/schema.ts
|
|
4320
4494
|
import { z as z5 } from "zod";
|
|
4321
4495
|
var 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;
|
|
@@ -5001,6 +5175,7 @@ var init_doorBounds = __esm({
|
|
|
5001
5175
|
|
|
5002
5176
|
// src/providerCatalogue.ts
|
|
5003
5177
|
import picomatch4 from "picomatch";
|
|
5178
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
5004
5179
|
import path11 from "node:path";
|
|
5005
5180
|
import { z as z7 } from "zod";
|
|
5006
5181
|
function catalogueCachePath(paths, name, supervisorPid, generation) {
|
|
@@ -5008,6 +5183,20 @@ function catalogueCachePath(paths, name, supervisorPid, generation) {
|
|
|
5008
5183
|
const directory = supervisorPid === void 0 || generation === void 0 ? paths.catalogueDir : catalogueGenerationDir(paths, supervisorPid, generation);
|
|
5009
5184
|
return providerFilePath(directory, name);
|
|
5010
5185
|
}
|
|
5186
|
+
function catalogueSettingsPath(paths, name) {
|
|
5187
|
+
return path11.join(path11.dirname(catalogueCachePath(paths, name)), "settings", `${name}.json`);
|
|
5188
|
+
}
|
|
5189
|
+
function parseCatalogueSettings(text) {
|
|
5190
|
+
if (text === void 0) {
|
|
5191
|
+
return void 0;
|
|
5192
|
+
}
|
|
5193
|
+
try {
|
|
5194
|
+
const parsed = CatalogueDigestSchema.safeParse(JSON.parse(text));
|
|
5195
|
+
return parsed.success ? parsed.data : void 0;
|
|
5196
|
+
} catch {
|
|
5197
|
+
return void 0;
|
|
5198
|
+
}
|
|
5199
|
+
}
|
|
5011
5200
|
function catalogueGenerationDir(paths, supervisorPid, generation) {
|
|
5012
5201
|
return path11.join(paths.catalogueDir, "supervisors", String(supervisorPid), z7.uuid().parse(generation));
|
|
5013
5202
|
}
|
|
@@ -5026,18 +5215,27 @@ function parseCatalogueCache(text) {
|
|
|
5026
5215
|
}
|
|
5027
5216
|
}
|
|
5028
5217
|
function isCatalogueStale(cache, nowMs) {
|
|
5029
|
-
return
|
|
5218
|
+
return !within(cache.fetchedAt, nowMs, CATALOGUE_MAX_AGE_MS);
|
|
5030
5219
|
}
|
|
5031
5220
|
function filterCatalogue(models, catalogue) {
|
|
5032
5221
|
const included = catalogue.include === void 0 ? void 0 : picomatch4(catalogue.include, { dot: true });
|
|
5033
5222
|
const excluded = catalogue.exclude === void 0 ? void 0 : picomatch4(catalogue.exclude, { dot: true });
|
|
5034
5223
|
return models.filter((model) => included?.(model.id) !== false && excluded?.(model.id) !== true);
|
|
5035
5224
|
}
|
|
5036
|
-
|
|
5225
|
+
function catalogueSettingsFingerprint(provider) {
|
|
5226
|
+
return createHash3("sha256").update(canonicalJson([provider.baseUrl, provider.catalogue === void 0 ? false : provider.catalogue.url ?? null, provider.credential])).digest("hex");
|
|
5227
|
+
}
|
|
5228
|
+
function catalogueMatchesSettings(recorded, cache, provider) {
|
|
5229
|
+
return recorded?.fetchedAt === cache.fetchedAt && recorded.settings === catalogueSettingsFingerprint(provider);
|
|
5230
|
+
}
|
|
5231
|
+
var 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;
|
|
5037
5232
|
var init_providerCatalogue = __esm({
|
|
5038
5233
|
"src/providerCatalogue.ts"() {
|
|
5039
5234
|
"use strict";
|
|
5040
5235
|
init_baseUrlDisplay();
|
|
5236
|
+
init_elapsedWindow();
|
|
5237
|
+
init_loggedText();
|
|
5238
|
+
init_canonicalJson();
|
|
5041
5239
|
init_names();
|
|
5042
5240
|
init_doorBounds();
|
|
5043
5241
|
DEFAULT_CANDIDATE_URLS = 2;
|
|
@@ -5051,10 +5249,14 @@ var init_providerCatalogue = __esm({
|
|
|
5051
5249
|
CATALOGUE_REQUEST_SECONDS = 10;
|
|
5052
5250
|
CATALOGUE_REQUEST_TIMEOUT_MS = CATALOGUE_REQUEST_SECONDS * MS_PER_SECOND4;
|
|
5053
5251
|
CATALOGUE_REFRESH_TIMEOUT_MS = DEFAULT_CANDIDATE_URLS * CATALOGUE_REQUEST_TIMEOUT_MS;
|
|
5252
|
+
CATALOGUE_MAX_MODELS = 1e4;
|
|
5253
|
+
CATALOGUE_ENTRY_MAX_BYTES = 1024;
|
|
5254
|
+
CATALOGUE_BODY_LIMIT_BYTES = CATALOGUE_MAX_MODELS * CATALOGUE_ENTRY_MAX_BYTES;
|
|
5054
5255
|
CATALOGUE_WORKER_ALLOWANCE_MS = DOOR_WORKER_START_ALLOWANCE_MS + BLOCKING_STEP_TIMEOUTS_MS.credentialCommand + BLOCKING_STEP_TIMEOUTS_MS.codexVersion;
|
|
5055
5256
|
CATALOGUE_REFRESH_DEADLINE_MS = CATALOGUE_REFRESH_TIMEOUT_MS + CATALOGUE_WORKER_ALLOWANCE_MS;
|
|
5056
5257
|
CatalogueModelSchema = z7.strictObject({ id: z7.string().min(1), name: z7.string().min(1).optional() });
|
|
5057
5258
|
CatalogueCacheSchema = z7.strictObject({ fetchedAt: z7.number(), url: z7.string().min(1), models: z7.array(CatalogueModelSchema), credentialFingerprint: z7.string().optional(), supervisorPid: z7.number().int().positive().optional() });
|
|
5259
|
+
CatalogueDigestSchema = z7.strictObject({ settings: z7.string().min(1), fetchedAt: z7.number() });
|
|
5058
5260
|
}
|
|
5059
5261
|
});
|
|
5060
5262
|
|
|
@@ -5086,17 +5288,6 @@ var init_catalogueCleanup = __esm({
|
|
|
5086
5288
|
// src/frontdoor/state.ts
|
|
5087
5289
|
import path13 from "node:path";
|
|
5088
5290
|
import { z as z9 } from "zod";
|
|
5089
|
-
function readCatalogueStatus(fs17, paths, pid, generation, name) {
|
|
5090
|
-
const file = path13.join(path13.dirname(catalogueCachePath(paths, name, pid, generation)), `${name}.status.json`);
|
|
5091
|
-
const raw = fs17.readFileUtf8(file);
|
|
5092
|
-
if (raw === void 0) return void 0;
|
|
5093
|
-
try {
|
|
5094
|
-
const value = z9.strictObject({ status: z9.enum(["running", "ready", "failed"]), fingerprint: z9.string().min(1).optional(), recordedAt: z9.number().optional() }).safeParse(JSON.parse(raw));
|
|
5095
|
-
return value.success ? value.data : void 0;
|
|
5096
|
-
} catch {
|
|
5097
|
-
return void 0;
|
|
5098
|
-
}
|
|
5099
|
-
}
|
|
5100
5291
|
function launchKeyOf(launch) {
|
|
5101
5292
|
return `${String(launch.pid)}-${String(launch.startedAt)}`;
|
|
5102
5293
|
}
|
|
@@ -5107,7 +5298,12 @@ function writeFrontDoorCodexHome(fs17, frontdoorDir, pid, codexHome, generation)
|
|
|
5107
5298
|
`);
|
|
5108
5299
|
}
|
|
5109
5300
|
function readFrontDoorCodexRecord(fs17, frontdoorDir, pid) {
|
|
5110
|
-
|
|
5301
|
+
let raw;
|
|
5302
|
+
try {
|
|
5303
|
+
raw = fs17.readFileUtf8(path13.join(frontdoorDir, "codex-homes", `${String(pid)}.json`));
|
|
5304
|
+
} catch {
|
|
5305
|
+
return void 0;
|
|
5306
|
+
}
|
|
5111
5307
|
if (raw === void 0) return void 0;
|
|
5112
5308
|
try {
|
|
5113
5309
|
const parsed = z9.strictObject({ codexHome: z9.string().min(1), generation: z9.uuid() }).safeParse(JSON.parse(raw));
|
|
@@ -5292,8 +5488,7 @@ var init_state = __esm({
|
|
|
5292
5488
|
"use strict";
|
|
5293
5489
|
init_schema();
|
|
5294
5490
|
init_baseUrlDial();
|
|
5295
|
-
|
|
5296
|
-
FRONT_DOOR_PROTOCOL = 8;
|
|
5491
|
+
FRONT_DOOR_PROTOCOL = 9;
|
|
5297
5492
|
FRONT_DOOR_HANDOVER_PROTOCOL = 6;
|
|
5298
5493
|
FrontDoorSessionSchema = z9.strictObject({ pid: z9.number().int().positive(), startedAt: z9.number(), token: z9.string().min(1), supervisorPid: z9.number().int().positive().optional(), sessionId: z9.string().min(1).optional(), identity: z9.string().min(1).optional(), models: ModelsConfigSchema.optional() });
|
|
5299
5494
|
MAX_CONTEXT_TEXT_LENGTH = 256;
|
|
@@ -5595,8 +5790,8 @@ function parseConnectTarget(authority) {
|
|
|
5595
5790
|
function isInterceptedHost(host, interceptHosts) {
|
|
5596
5791
|
return interceptHosts.includes(host);
|
|
5597
5792
|
}
|
|
5598
|
-
function servedByPipeline(
|
|
5599
|
-
return
|
|
5793
|
+
function servedByPipeline(path56) {
|
|
5794
|
+
return path56?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
5600
5795
|
}
|
|
5601
5796
|
function forwardableHeaders(headers) {
|
|
5602
5797
|
const connectionTokens = new Set(
|
|
@@ -6049,6 +6244,7 @@ var init_http = __esm({
|
|
|
6049
6244
|
methodNotAllowed: 405,
|
|
6050
6245
|
conflict: 409,
|
|
6051
6246
|
payloadTooLarge: 413,
|
|
6247
|
+
unsupportedMediaType: 415,
|
|
6052
6248
|
tooManyRequests: 429,
|
|
6053
6249
|
/** 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. */
|
|
6054
6250
|
clientClosedRequest: 499,
|
|
@@ -6453,13 +6649,13 @@ var init_rcQuestions = __esm({
|
|
|
6453
6649
|
});
|
|
6454
6650
|
|
|
6455
6651
|
// src/frontdoor/rcSessions.ts
|
|
6456
|
-
import { createHash as
|
|
6652
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
6457
6653
|
function pathnameOf(url) {
|
|
6458
6654
|
return new URL(url ?? "/", "http://127.0.0.1").pathname;
|
|
6459
6655
|
}
|
|
6460
6656
|
function isRcSessionExchange(url) {
|
|
6461
|
-
const
|
|
6462
|
-
return
|
|
6657
|
+
const path56 = pathnameOf(url);
|
|
6658
|
+
return path56 === RC_SESSIONS_PATH_PREFIX || path56.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
|
|
6463
6659
|
}
|
|
6464
6660
|
function isSuccessful(status) {
|
|
6465
6661
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE;
|
|
@@ -6637,7 +6833,7 @@ function rememberBounded(record, key) {
|
|
|
6637
6833
|
}
|
|
6638
6834
|
}
|
|
6639
6835
|
function droppedKeyOf(requestId) {
|
|
6640
|
-
return requestId.length <= RC_REQUEST_ID_MAX_CHARS ? requestId :
|
|
6836
|
+
return requestId.length <= RC_REQUEST_ID_MAX_CHARS ? requestId : createHash4("sha256").update(requestId).digest("hex");
|
|
6641
6837
|
}
|
|
6642
6838
|
function createRcSessionTracker(deps) {
|
|
6643
6839
|
const entries = /* @__PURE__ */ new Map();
|
|
@@ -7193,8 +7389,8 @@ function buildRcGetContextUsagePayload(requestId, detail) {
|
|
|
7193
7389
|
function isRcReadFileEncoding(value) {
|
|
7194
7390
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
|
|
7195
7391
|
}
|
|
7196
|
-
function buildRcReadFilePayload(requestId,
|
|
7197
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
7392
|
+
function buildRcReadFilePayload(requestId, path56, options) {
|
|
7393
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path56, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
7198
7394
|
}
|
|
7199
7395
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
7200
7396
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -7328,15 +7524,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
7328
7524
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
7329
7525
|
return result.ok ? { ...result, requestId } : result;
|
|
7330
7526
|
}
|
|
7331
|
-
async function readRcSessionFile(deps, sessionId,
|
|
7332
|
-
if (
|
|
7527
|
+
async function readRcSessionFile(deps, sessionId, path56, options) {
|
|
7528
|
+
if (path56 === "") {
|
|
7333
7529
|
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" };
|
|
7334
7530
|
}
|
|
7335
7531
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
7336
7532
|
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" };
|
|
7337
7533
|
}
|
|
7338
7534
|
const requestId = deps.newUuid();
|
|
7339
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
7535
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path56, options), `read ${path56} from session ${sessionId}`);
|
|
7340
7536
|
return result.ok ? { ...result, requestId } : result;
|
|
7341
7537
|
}
|
|
7342
7538
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -7385,13 +7581,14 @@ async function teleportRcSession(deps, sessionId, marker) {
|
|
|
7385
7581
|
function buildRcMarkReadBody(eventId) {
|
|
7386
7582
|
return eventId === void 0 ? {} : { event_id: eventId };
|
|
7387
7583
|
}
|
|
7388
|
-
var RC_PERMISSION_MODES, RC_CONTEXT_USAGE_DETAILS, RC_READ_FILE_ENCODINGS;
|
|
7584
|
+
var RC_SEND_DELIVERY_NOTE, RC_PERMISSION_MODES, RC_CONTEXT_USAGE_DETAILS, RC_READ_FILE_ENCODINGS;
|
|
7389
7585
|
var init_rcWrites = __esm({
|
|
7390
7586
|
"src/frontdoor/rcWrites.ts"() {
|
|
7391
7587
|
"use strict";
|
|
7392
7588
|
init_http();
|
|
7393
7589
|
init_rcSessions();
|
|
7394
7590
|
init_rcQuestions();
|
|
7591
|
+
RC_SEND_DELIVERY_NOTE = "Claude Code reads it as a message from another session, not as a person typing in an attached client, because the service stamps it with the session's own client platform. Whether it reaches the model is the receiving session's crossSessionInbound setting: with none set, a session that bypasses permission prompts holds it for approval, since the write cannot attest a permission mode.";
|
|
7395
7592
|
RC_PERMISSION_MODES = ["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto"];
|
|
7396
7593
|
RC_CONTEXT_USAGE_DETAILS = ["summary", "full"];
|
|
7397
7594
|
RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
@@ -7714,11 +7911,11 @@ function createRcControlHandler(deps) {
|
|
|
7714
7911
|
path: "read-file",
|
|
7715
7912
|
read: (body) => {
|
|
7716
7913
|
const session = bodyString(body, "session");
|
|
7717
|
-
const
|
|
7914
|
+
const path56 = bodyString(body, "path");
|
|
7718
7915
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
7719
7916
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
7720
|
-
const refused2 = session === void 0 ||
|
|
7721
|
-
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,
|
|
7917
|
+
const refused2 = session === void 0 || path56 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
7918
|
+
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 } }) };
|
|
7722
7919
|
}
|
|
7723
7920
|
},
|
|
7724
7921
|
{
|
|
@@ -8041,9 +8238,9 @@ function requestIdOfBody(body) {
|
|
|
8041
8238
|
}
|
|
8042
8239
|
function frontDoorRcControl(transport, token) {
|
|
8043
8240
|
const headers = { authorization: `Bearer ${token}` };
|
|
8044
|
-
const listAnswerOf = async (
|
|
8241
|
+
const listAnswerOf = async (path56, what) => {
|
|
8045
8242
|
try {
|
|
8046
|
-
return await transport.request({ method: "GET", path:
|
|
8243
|
+
return await transport.request({ method: "GET", path: path56, headers });
|
|
8047
8244
|
} catch (error) {
|
|
8048
8245
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
8049
8246
|
}
|
|
@@ -8115,10 +8312,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8115
8312
|
}
|
|
8116
8313
|
return pending;
|
|
8117
8314
|
};
|
|
8118
|
-
const writeOf = async (
|
|
8315
|
+
const writeOf = async (path56, body, describeFailure2) => {
|
|
8119
8316
|
let answer;
|
|
8120
8317
|
try {
|
|
8121
|
-
answer = await transport.request({ method: "POST", path:
|
|
8318
|
+
answer = await transport.request({ method: "POST", path: path56, headers: { ...headers, "content-type": "application/json" }, body });
|
|
8122
8319
|
} catch (error) {
|
|
8123
8320
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
8124
8321
|
}
|
|
@@ -8149,10 +8346,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8149
8346
|
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}`),
|
|
8150
8347
|
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}`),
|
|
8151
8348
|
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}`),
|
|
8152
|
-
readFile: async (sessionId,
|
|
8349
|
+
readFile: async (sessionId, path56, options) => await writeOf(
|
|
8153
8350
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
8154
|
-
JSON.stringify({ session: sessionId, path:
|
|
8155
|
-
(status, message) => `reading ${
|
|
8351
|
+
JSON.stringify({ session: sessionId, path: path56, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
8352
|
+
(status, message) => `reading ${path56} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
8156
8353
|
),
|
|
8157
8354
|
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}`),
|
|
8158
8355
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -8393,12 +8590,12 @@ function tlsFacts(options) {
|
|
|
8393
8590
|
}
|
|
8394
8591
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8395
8592
|
const agent = new ExemptTlsAgent();
|
|
8396
|
-
const post = async (
|
|
8593
|
+
const post = async (path56, headers, body) => await new Promise((resolve, reject) => {
|
|
8397
8594
|
const options = {
|
|
8398
8595
|
host: target.host,
|
|
8399
8596
|
port: target.port,
|
|
8400
8597
|
method: "POST",
|
|
8401
|
-
path:
|
|
8598
|
+
path: path56,
|
|
8402
8599
|
// 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.
|
|
8403
8600
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
8404
8601
|
agent
|
|
@@ -8458,12 +8655,12 @@ function lateRcStreamDial(resolve) {
|
|
|
8458
8655
|
}
|
|
8459
8656
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8460
8657
|
const agent = new ExemptTlsAgent();
|
|
8461
|
-
const request4 = async (method,
|
|
8658
|
+
const request4 = async (method, path56, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
8462
8659
|
const options = {
|
|
8463
8660
|
host: target.host,
|
|
8464
8661
|
port: target.port,
|
|
8465
8662
|
method,
|
|
8466
|
-
path:
|
|
8663
|
+
path: path56,
|
|
8467
8664
|
// 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.
|
|
8468
8665
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
8469
8666
|
agent,
|
|
@@ -8505,9 +8702,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
8505
8702
|
return { status, body: await readAll(response) };
|
|
8506
8703
|
},
|
|
8507
8704
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
8508
|
-
const
|
|
8705
|
+
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)}`;
|
|
8509
8706
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
8510
|
-
const { status, response } = await request4("GET",
|
|
8707
|
+
const { status, response } = await request4("GET", path56, streamHeaders, void 0, signal);
|
|
8511
8708
|
if (!isSuccessful2(status)) {
|
|
8512
8709
|
await readAll(response);
|
|
8513
8710
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -8946,7 +9143,7 @@ function loadIdentity(identitiesDir, name, fs17) {
|
|
|
8946
9143
|
return id === void 0 ? void 0 : loadConfigFile(path15.join(identitiesDir, id, "identity.json"), IdentitySchema, fs17.readConfigFile);
|
|
8947
9144
|
}
|
|
8948
9145
|
var IDENTITY_DECISION_SOURCES, IDENTITY_SOURCE_LABELS, CONFIG_PROFILE_DECISION_SOURCES;
|
|
8949
|
-
var
|
|
9146
|
+
var init_identity2 = __esm({
|
|
8950
9147
|
"src/launcher/identity.ts"() {
|
|
8951
9148
|
"use strict";
|
|
8952
9149
|
init_load();
|
|
@@ -8995,9 +9192,9 @@ var init_identity = __esm({
|
|
|
8995
9192
|
|
|
8996
9193
|
// src/statusline/keys.ts
|
|
8997
9194
|
import { z as z13 } from "zod";
|
|
8998
|
-
function valueAt(source,
|
|
9195
|
+
function valueAt(source, path56) {
|
|
8999
9196
|
let current = source;
|
|
9000
|
-
for (const part of
|
|
9197
|
+
for (const part of path56) {
|
|
9001
9198
|
if (!isPlainObject(current)) {
|
|
9002
9199
|
return void 0;
|
|
9003
9200
|
}
|
|
@@ -9005,14 +9202,14 @@ function valueAt(source, path55) {
|
|
|
9005
9202
|
}
|
|
9006
9203
|
return current;
|
|
9007
9204
|
}
|
|
9008
|
-
function acceptsNull(
|
|
9009
|
-
const layer =
|
|
9205
|
+
function acceptsNull(path56) {
|
|
9206
|
+
const layer = path56.reduceRight((inner, part) => ({ [part]: inner }), null);
|
|
9010
9207
|
return StatuslineSchema.safeParse(layer).success;
|
|
9011
9208
|
}
|
|
9012
|
-
function keyOf(
|
|
9209
|
+
function keyOf(path56, declared) {
|
|
9013
9210
|
const optional = declared instanceof z13.ZodOptional;
|
|
9014
9211
|
const leaf = optional ? declared.unwrap() : declared;
|
|
9015
|
-
const common = { path:
|
|
9212
|
+
const common = { path: path56.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path56), optional, unsettable: acceptsNull(path56) };
|
|
9016
9213
|
if (leaf instanceof z13.ZodNumber) {
|
|
9017
9214
|
return { ...common, kind: "integer", choices: [] };
|
|
9018
9215
|
}
|
|
@@ -9037,7 +9234,7 @@ function keyOf(path55, declared) {
|
|
|
9037
9234
|
if (leaf instanceof z13.ZodArray && leaf.element instanceof z13.ZodString) {
|
|
9038
9235
|
return { ...common, kind: "textList", choices: [] };
|
|
9039
9236
|
}
|
|
9040
|
-
throw new TypeError(`statusline setting ${
|
|
9237
|
+
throw new TypeError(`statusline setting ${path56.join(".")} has a kind the key listing does not describe`);
|
|
9041
9238
|
}
|
|
9042
9239
|
function walk(shape, prefix) {
|
|
9043
9240
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof z13.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -9053,15 +9250,15 @@ var init_keys = __esm({
|
|
|
9053
9250
|
});
|
|
9054
9251
|
|
|
9055
9252
|
// src/statusline/change.ts
|
|
9056
|
-
function keyNamed(
|
|
9057
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
9253
|
+
function keyNamed(path56) {
|
|
9254
|
+
const found = statuslineKeys().find((key) => key.path === path56);
|
|
9058
9255
|
if (found === void 0) {
|
|
9059
|
-
throw new UsageError(`"${
|
|
9256
|
+
throw new UsageError(`"${path56}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
9060
9257
|
}
|
|
9061
9258
|
return found;
|
|
9062
9259
|
}
|
|
9063
|
-
function setAt(target,
|
|
9064
|
-
const [head, ...rest] =
|
|
9260
|
+
function setAt(target, path56, value) {
|
|
9261
|
+
const [head, ...rest] = path56;
|
|
9065
9262
|
if (head === void 0) {
|
|
9066
9263
|
return;
|
|
9067
9264
|
}
|
|
@@ -9074,8 +9271,8 @@ function setAt(target, path55, value) {
|
|
|
9074
9271
|
target[head] = next;
|
|
9075
9272
|
setAt(next, rest, value);
|
|
9076
9273
|
}
|
|
9077
|
-
function removeAt(target,
|
|
9078
|
-
const [head, ...rest] =
|
|
9274
|
+
function removeAt(target, path56) {
|
|
9275
|
+
const [head, ...rest] = path56;
|
|
9079
9276
|
if (head === void 0) {
|
|
9080
9277
|
return;
|
|
9081
9278
|
}
|
|
@@ -9093,13 +9290,13 @@ function removeAt(target, path55) {
|
|
|
9093
9290
|
}
|
|
9094
9291
|
function applyStatuslineChange(existing, change) {
|
|
9095
9292
|
const draft = structuredClone(existing ?? {});
|
|
9096
|
-
for (const [
|
|
9097
|
-
keyNamed(
|
|
9098
|
-
setAt(draft,
|
|
9293
|
+
for (const [path56, value] of Object.entries(change.set ?? {})) {
|
|
9294
|
+
keyNamed(path56);
|
|
9295
|
+
setAt(draft, path56.split("."), value);
|
|
9099
9296
|
}
|
|
9100
|
-
for (const
|
|
9101
|
-
keyNamed(
|
|
9102
|
-
removeAt(draft,
|
|
9297
|
+
for (const path56 of change.unset ?? []) {
|
|
9298
|
+
keyNamed(path56);
|
|
9299
|
+
removeAt(draft, path56.split("."));
|
|
9103
9300
|
}
|
|
9104
9301
|
const result = StatuslineSchema.safeParse(draft);
|
|
9105
9302
|
if (!result.success) {
|
|
@@ -9335,19 +9532,19 @@ function writePools(paths, pools) {
|
|
|
9335
9532
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
9336
9533
|
}
|
|
9337
9534
|
function poolCycleOf(pools, name) {
|
|
9338
|
-
const walk2 = (current,
|
|
9535
|
+
const walk2 = (current, path56) => {
|
|
9339
9536
|
for (const entry of pools[current]?.identities ?? []) {
|
|
9340
9537
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
9341
9538
|
if (nested === void 0) {
|
|
9342
9539
|
continue;
|
|
9343
9540
|
}
|
|
9344
9541
|
if (nested === name) {
|
|
9345
|
-
return [...
|
|
9542
|
+
return [...path56, nested];
|
|
9346
9543
|
}
|
|
9347
|
-
if (
|
|
9544
|
+
if (path56.includes(nested)) {
|
|
9348
9545
|
continue;
|
|
9349
9546
|
}
|
|
9350
|
-
const found = walk2(nested, [...
|
|
9547
|
+
const found = walk2(nested, [...path56, nested]);
|
|
9351
9548
|
if (found !== void 0) {
|
|
9352
9549
|
return found;
|
|
9353
9550
|
}
|
|
@@ -9426,7 +9623,7 @@ var init_poolStore = __esm({
|
|
|
9426
9623
|
init_configProfilesStore();
|
|
9427
9624
|
init_store();
|
|
9428
9625
|
init_schema();
|
|
9429
|
-
|
|
9626
|
+
init_identity2();
|
|
9430
9627
|
PoolNotFoundError = class extends CliError {
|
|
9431
9628
|
constructor(poolName) {
|
|
9432
9629
|
super(`No pool named "${poolName}". Run \`agent-shim pool add ${poolName} --identity <name>...\` first.`);
|
|
@@ -9763,13 +9960,13 @@ var init_headers = __esm({
|
|
|
9763
9960
|
});
|
|
9764
9961
|
|
|
9765
9962
|
// src/launcher/injected.ts
|
|
9766
|
-
import { createHash as
|
|
9963
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
9767
9964
|
import { z as z14 } from "zod";
|
|
9768
9965
|
function listKey(list) {
|
|
9769
9966
|
return `${list},appended`;
|
|
9770
9967
|
}
|
|
9771
9968
|
function digest2(value) {
|
|
9772
|
-
return
|
|
9969
|
+
return createHash5("sha256").update(value).digest("hex");
|
|
9773
9970
|
}
|
|
9774
9971
|
function recordedDigests(env) {
|
|
9775
9972
|
const raw = env[INJECTED_ENV];
|
|
@@ -9927,10 +10124,10 @@ var init_guard = __esm({
|
|
|
9927
10124
|
});
|
|
9928
10125
|
|
|
9929
10126
|
// src/usage/signIn.ts
|
|
9930
|
-
import { createHash as
|
|
10127
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
9931
10128
|
import path19 from "node:path";
|
|
9932
10129
|
function claudeCodeKeychainService(configDir) {
|
|
9933
|
-
return `${KEYCHAIN_SERVICE_PREFIX}-${
|
|
10130
|
+
return `${KEYCHAIN_SERVICE_PREFIX}-${createHash6("sha256").update(configDir).digest("hex").slice(0, KEYCHAIN_SERVICE_HASH_DIGITS)}`;
|
|
9934
10131
|
}
|
|
9935
10132
|
function keychainHasItem(run, configDir) {
|
|
9936
10133
|
return run.run("security", ["find-generic-password", "-s", claudeCodeKeychainService(configDir)]).status === 0;
|
|
@@ -10357,7 +10554,7 @@ var init_supervisorProcesses = __esm({
|
|
|
10357
10554
|
});
|
|
10358
10555
|
|
|
10359
10556
|
// src/headroom/state.ts
|
|
10360
|
-
import { createHash as
|
|
10557
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
10361
10558
|
import path21 from "node:path";
|
|
10362
10559
|
import { z as z15 } from "zod";
|
|
10363
10560
|
function parseJson(raw, schema) {
|
|
@@ -10406,7 +10603,7 @@ function migrateHeadroomState(fs17, files, isRunning) {
|
|
|
10406
10603
|
fs17.removeRecursive(files.legacyStateFile);
|
|
10407
10604
|
}
|
|
10408
10605
|
function hashAllowlist(allowlist) {
|
|
10409
|
-
return
|
|
10606
|
+
return createHash7("sha256").update(allowlist.join("\n")).digest("hex");
|
|
10410
10607
|
}
|
|
10411
10608
|
function formatAllowlistFile(allowlist) {
|
|
10412
10609
|
return allowlist.map((entry) => `${entry}
|
|
@@ -10731,7 +10928,7 @@ var init_ensure = __esm({
|
|
|
10731
10928
|
});
|
|
10732
10929
|
|
|
10733
10930
|
// src/headroom/settings.ts
|
|
10734
|
-
import { createHash as
|
|
10931
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
10735
10932
|
function settingsOf(config) {
|
|
10736
10933
|
return {
|
|
10737
10934
|
...config.mode === void 0 ? {} : { mode: config.mode },
|
|
@@ -10756,7 +10953,7 @@ function settingsEnv(settings) {
|
|
|
10756
10953
|
return settings.rolloutChannel === void 0 ? {} : { HEADROOM_ROLLOUT_CHANNEL: settings.rolloutChannel };
|
|
10757
10954
|
}
|
|
10758
10955
|
function hashSettings(settings) {
|
|
10759
|
-
return
|
|
10956
|
+
return createHash8("sha256").update(JSON.stringify([...settingsArgs(settings), JSON.stringify(settingsEnv(settings))])).digest("hex");
|
|
10760
10957
|
}
|
|
10761
10958
|
var init_settings = __esm({
|
|
10762
10959
|
"src/headroom/settings.ts"() {
|
|
@@ -11415,7 +11612,7 @@ var init_logStyle = __esm({
|
|
|
11415
11612
|
|
|
11416
11613
|
// src/realPorts.ts
|
|
11417
11614
|
import { execFile, spawn } from "node:child_process";
|
|
11418
|
-
import { createHash as
|
|
11615
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
11419
11616
|
import fs6 from "node:fs";
|
|
11420
11617
|
import os2 from "node:os";
|
|
11421
11618
|
import path24 from "node:path";
|
|
@@ -11852,7 +12049,7 @@ var init_realPorts = __esm({
|
|
|
11852
12049
|
},
|
|
11853
12050
|
hashFile(filePath) {
|
|
11854
12051
|
try {
|
|
11855
|
-
return
|
|
12052
|
+
return createHash9("sha256").update(fs6.readFileSync(filePath)).digest("hex");
|
|
11856
12053
|
} catch (error) {
|
|
11857
12054
|
if (isEnoent3(error) || isErrorWithCode(error, "EISDIR")) {
|
|
11858
12055
|
return void 0;
|
|
@@ -13104,7 +13301,7 @@ var init_poolPick = __esm({
|
|
|
13104
13301
|
"src/usage/poolPick.ts"() {
|
|
13105
13302
|
"use strict";
|
|
13106
13303
|
init_cliError();
|
|
13107
|
-
|
|
13304
|
+
init_identity2();
|
|
13108
13305
|
init_schema();
|
|
13109
13306
|
init_identityAccounts();
|
|
13110
13307
|
init_account();
|
|
@@ -13129,11 +13326,11 @@ var init_poolPick = __esm({
|
|
|
13129
13326
|
});
|
|
13130
13327
|
|
|
13131
13328
|
// src/identityRenameJournal.ts
|
|
13132
|
-
import { createHash as
|
|
13329
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
13133
13330
|
import path27 from "node:path";
|
|
13134
13331
|
import { z as z20 } from "zod";
|
|
13135
13332
|
function renamePairFileName(from, to, suffix) {
|
|
13136
|
-
return `${
|
|
13333
|
+
return `${createHash10("sha256").update(`${from}\0${to}`).digest("hex").slice(0, FILE_NAME_HASH_DIGITS)}${suffix}`;
|
|
13137
13334
|
}
|
|
13138
13335
|
function readRenameJournal(fs17, file) {
|
|
13139
13336
|
const raw = fs17.readFileUtf8(file);
|
|
@@ -13811,7 +14008,7 @@ var init_identityStore = __esm({
|
|
|
13811
14008
|
init_store();
|
|
13812
14009
|
init_schema();
|
|
13813
14010
|
init_cliError();
|
|
13814
|
-
|
|
14011
|
+
init_identity2();
|
|
13815
14012
|
init_poolStore();
|
|
13816
14013
|
init_read();
|
|
13817
14014
|
init_credential();
|
|
@@ -13885,7 +14082,7 @@ var init_package = __esm({
|
|
|
13885
14082
|
"package.json"() {
|
|
13886
14083
|
package_default = {
|
|
13887
14084
|
name: "claude-use",
|
|
13888
|
-
version: "14.
|
|
14085
|
+
version: "14.3.1",
|
|
13889
14086
|
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.",
|
|
13890
14087
|
license: "MIT",
|
|
13891
14088
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -14176,325 +14373,422 @@ var init_claudeShim = __esm({
|
|
|
14176
14373
|
}
|
|
14177
14374
|
});
|
|
14178
14375
|
|
|
14179
|
-
// src/
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
case "false":
|
|
14186
|
-
case "0":
|
|
14187
|
-
return false;
|
|
14188
|
-
default:
|
|
14189
|
-
return void 0;
|
|
14190
|
-
}
|
|
14376
|
+
// src/frontdoor/probe.ts
|
|
14377
|
+
import { Worker } from "node:worker_threads";
|
|
14378
|
+
function probeWorkerSource(body) {
|
|
14379
|
+
return `const { workerData } = require("node:worker_threads");
|
|
14380
|
+
${STARTED_SIGNAL_SOURCE}
|
|
14381
|
+
${body}`;
|
|
14191
14382
|
}
|
|
14192
|
-
|
|
14193
|
-
"
|
|
14194
|
-
|
|
14195
|
-
}
|
|
14196
|
-
});
|
|
14197
|
-
|
|
14198
|
-
// src/cli/envBool.ts
|
|
14199
|
-
function parseEnvBool(variable, value) {
|
|
14200
|
-
if (value === void 0 || value === "") {
|
|
14201
|
-
return void 0;
|
|
14202
|
-
}
|
|
14203
|
-
const parsed = parseBoolWord(value);
|
|
14204
|
-
if (parsed === void 0) {
|
|
14205
|
-
throw new InvalidEnvBoolError(variable, value);
|
|
14206
|
-
}
|
|
14207
|
-
return parsed;
|
|
14383
|
+
function requestCatalogueRefreshSync(port, caPem, token, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
14384
|
+
refuseToBlockInRole("a synchronous catalogue refresh request");
|
|
14385
|
+
return workers.start(CATALOGUE_REQUEST_SOURCE, { port, ca: caPem, token }, timeoutMs).verdict();
|
|
14208
14386
|
}
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
"use strict";
|
|
14213
|
-
init_cliError();
|
|
14214
|
-
init_bool();
|
|
14215
|
-
InvalidEnvBoolError = class extends UsageError {
|
|
14216
|
-
constructor(variable, value) {
|
|
14217
|
-
super(`${variable} must be one of true, false, 1 or 0, got "${value}".`);
|
|
14218
|
-
this.variable = variable;
|
|
14219
|
-
this.value = value;
|
|
14220
|
-
this.name = "InvalidEnvBoolError";
|
|
14221
|
-
}
|
|
14222
|
-
variable;
|
|
14223
|
-
value;
|
|
14224
|
-
};
|
|
14225
|
-
}
|
|
14226
|
-
});
|
|
14227
|
-
|
|
14228
|
-
// src/pathNorm.ts
|
|
14229
|
-
import path37 from "node:path";
|
|
14230
|
-
function expandTilde(value, home) {
|
|
14231
|
-
if (value === "~") {
|
|
14232
|
-
return home;
|
|
14233
|
-
}
|
|
14234
|
-
if (value.startsWith("~/")) {
|
|
14235
|
-
return path37.join(home, value.slice(2));
|
|
14236
|
-
}
|
|
14237
|
-
return value;
|
|
14387
|
+
function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
14388
|
+
refuseToBlockInRole("a synchronous probe of the front door");
|
|
14389
|
+
return workers.start(PROBE_SOURCE, { port, ca: caPem }, timeoutMs).verdict();
|
|
14238
14390
|
}
|
|
14239
|
-
function
|
|
14240
|
-
|
|
14391
|
+
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
14392
|
+
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
14393
|
+
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();
|
|
14241
14394
|
}
|
|
14242
|
-
|
|
14243
|
-
"
|
|
14244
|
-
|
|
14395
|
+
function startAddressProbes(targets, workers = realProbeWorkers, portBase) {
|
|
14396
|
+
refuseToBlockInRole("a synchronous probe of a provider's address");
|
|
14397
|
+
const base = portBase ?? processPortBase();
|
|
14398
|
+
const distinct = /* @__PURE__ */ new Map();
|
|
14399
|
+
for (const target of targets) {
|
|
14400
|
+
distinct.set(targetKey(target), target);
|
|
14245
14401
|
}
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
const filepath = profileFilePath(params.paths.configProfilesDir, name);
|
|
14255
|
-
const loaded = loadConfigFile(filepath, ConfigProfileSchema, params.read);
|
|
14256
|
-
if (loaded === void 0) {
|
|
14257
|
-
return void 0;
|
|
14402
|
+
const unique = Array.from(distinct.values());
|
|
14403
|
+
const stride = Math.max(1, Math.floor(DOOR_SOURCE_PORT_COUNT / unique.length));
|
|
14404
|
+
const verdicts = /* @__PURE__ */ new Map();
|
|
14405
|
+
const running = [];
|
|
14406
|
+
const settleOldest = () => {
|
|
14407
|
+
const oldest = running.shift();
|
|
14408
|
+
if (oldest !== void 0) {
|
|
14409
|
+
verdicts.set(oldest.key, oldest.verdict());
|
|
14258
14410
|
}
|
|
14259
|
-
return { name, profile: loaded.config, entryOrder: loaded.entryOrder, filepath: loaded.filepath };
|
|
14260
14411
|
};
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14412
|
+
unique.forEach((target, index) => {
|
|
14413
|
+
if (running.length >= MAX_CONCURRENT_PROBES) {
|
|
14414
|
+
settleOldest();
|
|
14415
|
+
}
|
|
14416
|
+
const portFirst = DOOR_SOURCE_PORT_START + (base + index * stride) % DOOR_SOURCE_PORT_COUNT;
|
|
14417
|
+
try {
|
|
14418
|
+
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);
|
|
14419
|
+
running.push({ key: targetKey(target), verdict: started.verdict, cancel: started.cancel });
|
|
14420
|
+
} catch (error) {
|
|
14421
|
+
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
14422
|
+
running.push({ key: targetKey(target), verdict: () => ({ ok: false, reason }), cancel: () => void 0 });
|
|
14423
|
+
}
|
|
14266
14424
|
});
|
|
14267
|
-
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14272
|
-
|
|
14273
|
-
|
|
14274
|
-
|
|
14275
|
-
|
|
14276
|
-
|
|
14277
|
-
|
|
14278
|
-
|
|
14279
|
-
|
|
14280
|
-
|
|
14425
|
+
return {
|
|
14426
|
+
settle: () => {
|
|
14427
|
+
while (running.length > 0) {
|
|
14428
|
+
settleOldest();
|
|
14429
|
+
}
|
|
14430
|
+
return targets.map((target) => {
|
|
14431
|
+
const verdict = verdicts.get(targetKey(target));
|
|
14432
|
+
if (verdict === void 0) {
|
|
14433
|
+
throw new Error("the batch probe settled no verdict for one of its targets");
|
|
14434
|
+
}
|
|
14435
|
+
return verdict;
|
|
14436
|
+
});
|
|
14437
|
+
},
|
|
14438
|
+
cancel: () => {
|
|
14439
|
+
for (const started of running.splice(0)) {
|
|
14440
|
+
started.cancel();
|
|
14441
|
+
}
|
|
14281
14442
|
}
|
|
14282
|
-
levels.push({
|
|
14283
|
-
dir,
|
|
14284
|
-
...portable === void 0 ? {} : { portable: { config: portable.config, entryOrder: portable.entryOrder, filepath: portable.filepath } },
|
|
14285
|
-
...rules.length === 0 ? {} : { rules },
|
|
14286
|
-
...portableLocal === void 0 ? {} : { portableLocal: { config: portableLocal.config, entryOrder: portableLocal.entryOrder, filepath: portableLocal.filepath } }
|
|
14287
|
-
});
|
|
14288
|
-
}
|
|
14289
|
-
const input = {
|
|
14290
|
-
home: params.home,
|
|
14291
|
-
...globalConfig === void 0 ? {} : { globalConfig: { config: globalConfig.config, entryOrder: globalConfig.entryOrder, filepath: globalConfig.filepath } },
|
|
14292
|
-
...params.baseConfigProfile === void 0 ? {} : { baseConfigProfile: params.baseConfigProfile },
|
|
14293
|
-
loadProfile,
|
|
14294
|
-
levels,
|
|
14295
|
-
...params.cliOverride === void 0 ? {} : { cliOverride: params.cliOverride }
|
|
14296
14443
|
};
|
|
14297
|
-
return { input, ...globalConfig === void 0 ? {} : { globalConfig: globalConfig.config } };
|
|
14298
14444
|
}
|
|
14299
|
-
function
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
|
|
14310
|
-
|
|
14311
|
-
|
|
14445
|
+
function startProbeWorker(source, data, timeoutMs, spawn3 = spawnRealWorker, startLimitMs = PROBE_WORKER_START_LIMIT_MS, wait = slicedProbeWait) {
|
|
14446
|
+
const startLimit = performance.now() + startLimitMs;
|
|
14447
|
+
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
14448
|
+
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
14449
|
+
let worker;
|
|
14450
|
+
try {
|
|
14451
|
+
worker = spawn3(`${WORKER_PRELUDE_SOURCE}
|
|
14452
|
+
new Function("require", ${JSON.stringify(source)})(require);`, {
|
|
14453
|
+
eval: true,
|
|
14454
|
+
workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS, startedSlot: STARTED_SLOT, failurePrefix: PROBE_WORKER_FAILURE_PREFIX, claimSlot: CLAIM_SLOT }
|
|
14455
|
+
});
|
|
14456
|
+
} catch (error) {
|
|
14457
|
+
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
14458
|
+
return { verdict: () => ({ ok: false, reason }), cancel: () => void 0 };
|
|
14459
|
+
}
|
|
14460
|
+
worker.on("error", (error) => {
|
|
14461
|
+
if (Atomics.compareExchange(header, CLAIM_SLOT, 0, 1) !== 0) {
|
|
14462
|
+
return;
|
|
14463
|
+
}
|
|
14464
|
+
const bytes = Buffer.from(PROBE_WORKER_FAILURE_PREFIX + error.message, "utf8").subarray(0, REASON_BYTES);
|
|
14465
|
+
new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES).set(bytes);
|
|
14466
|
+
Atomics.store(header, 1, bytes.length);
|
|
14467
|
+
Atomics.store(header, 0, VERDICT_FAILED);
|
|
14468
|
+
Atomics.store(header, STARTED_SLOT, 1);
|
|
14469
|
+
});
|
|
14470
|
+
worker.unref();
|
|
14471
|
+
return {
|
|
14472
|
+
verdict: () => {
|
|
14473
|
+
try {
|
|
14474
|
+
wait(header, STARTED_SLOT, WORKER_NOT_STARTED, Math.max(0, startLimit - performance.now()));
|
|
14475
|
+
if (Atomics.load(header, STARTED_SLOT) === WORKER_NOT_STARTED && Atomics.load(header, 0) === VERDICT_PENDING) {
|
|
14476
|
+
return { ok: false, reason: `the probe worker did not start within ${String(startLimitMs)}ms` };
|
|
14477
|
+
}
|
|
14478
|
+
wait(header, 0, VERDICT_PENDING, timeoutMs + PROBE_WAIT_MARGIN_MS);
|
|
14479
|
+
const verdict = Atomics.load(header, 0);
|
|
14480
|
+
if (verdict === VERDICT_PENDING) {
|
|
14481
|
+
return { ok: false, reason: `the probe did not finish within ${String(timeoutMs + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
14482
|
+
}
|
|
14483
|
+
if (verdict === VERDICT_OK) {
|
|
14484
|
+
return { ok: true };
|
|
14485
|
+
}
|
|
14486
|
+
const length = Atomics.load(header, 1);
|
|
14487
|
+
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
14488
|
+
} finally {
|
|
14489
|
+
void worker.terminate();
|
|
14312
14490
|
}
|
|
14491
|
+
},
|
|
14492
|
+
cancel: () => {
|
|
14493
|
+
void worker.terminate();
|
|
14313
14494
|
}
|
|
14314
|
-
}
|
|
14315
|
-
return { ...identity === void 0 ? {} : { identity }, ...configProfile === void 0 ? {} : { configProfile } };
|
|
14495
|
+
};
|
|
14316
14496
|
}
|
|
14317
|
-
var
|
|
14318
|
-
var
|
|
14319
|
-
"src/
|
|
14497
|
+
var 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;
|
|
14498
|
+
var init_probe = __esm({
|
|
14499
|
+
"src/frontdoor/probe.ts"() {
|
|
14320
14500
|
"use strict";
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
|
|
14501
|
+
init_processRole();
|
|
14502
|
+
init_connectEffects();
|
|
14503
|
+
init_doorDial();
|
|
14504
|
+
PROBE_TIMEOUT_MS = 2e3;
|
|
14505
|
+
PROBE_WAIT_MARGIN_MS = 1e3;
|
|
14506
|
+
REASON_BYTES = 1024;
|
|
14507
|
+
HEADER_SLOTS = 4;
|
|
14508
|
+
STARTED_SLOT = 2;
|
|
14509
|
+
CLAIM_SLOT = 3;
|
|
14510
|
+
PROBE_WORKER_START_LIMIT_MS = 1e4;
|
|
14511
|
+
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);";
|
|
14512
|
+
PROBE_WORKER_FAILURE_PREFIX = "the probe worker failed: ";
|
|
14513
|
+
INT32_BYTES = 4;
|
|
14514
|
+
VERDICT_PENDING = 0;
|
|
14515
|
+
WORKER_NOT_STARTED = 0;
|
|
14516
|
+
VERDICT_OK = 1;
|
|
14517
|
+
VERDICT_FAILED = 2;
|
|
14518
|
+
WORKER_PRELUDE_SOURCE = `
|
|
14519
|
+
(() => {
|
|
14520
|
+
const { workerData } = require("node:worker_threads");
|
|
14521
|
+
const header = new Int32Array(workerData.shared, 0, workerData.headerSlots);
|
|
14522
|
+
const reason = new Uint8Array(workerData.shared, workerData.headerSlots * 4);
|
|
14523
|
+
globalThis.finishProbe = (verdict, message) => {
|
|
14524
|
+
try {
|
|
14525
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
14526
|
+
if (Atomics.compareExchange(header, workerData.claimSlot, 0, 1) === 0) {
|
|
14527
|
+
reason.set(bytes);
|
|
14528
|
+
Atomics.store(header, 1, bytes.length);
|
|
14529
|
+
Atomics.store(header, 0, verdict);
|
|
14530
|
+
}
|
|
14531
|
+
} finally {
|
|
14532
|
+
Atomics.notify(header, 0);
|
|
14533
|
+
}
|
|
14534
|
+
};
|
|
14535
|
+
const fail = (error) => {
|
|
14536
|
+
let message;
|
|
14537
|
+
try {
|
|
14538
|
+
message = workerData.failurePrefix + (error instanceof Error ? error.message : String(error));
|
|
14539
|
+
} catch {
|
|
14540
|
+
message = workerData.failurePrefix + "an error that cannot be described";
|
|
14541
|
+
}
|
|
14542
|
+
try {
|
|
14543
|
+
globalThis.finishProbe(workerData.failed, message);
|
|
14544
|
+
} finally {
|
|
14545
|
+
Atomics.store(header, workerData.startedSlot, 1);
|
|
14546
|
+
Atomics.notify(header, workerData.startedSlot);
|
|
14547
|
+
}
|
|
14548
|
+
};
|
|
14549
|
+
process.on("uncaughtException", fail);
|
|
14550
|
+
process.on("unhandledRejection", fail);
|
|
14551
|
+
// 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).
|
|
14552
|
+
process.on("exit", (code) => {
|
|
14553
|
+
globalThis.finishProbe(workerData.failed, workerData.failurePrefix + "the worker exited without a verdict (exit code " + String(code) + ")");
|
|
14554
|
+
});
|
|
14555
|
+
})();
|
|
14556
|
+
`;
|
|
14557
|
+
PROBE_SOURCE = probeWorkerSource(`
|
|
14558
|
+
const https = require("node:https");
|
|
14559
|
+
const { port, ca, timeoutMs, ok, failed } = workerData;
|
|
14560
|
+
const finish = finishProbe;
|
|
14561
|
+
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
14562
|
+
let body = "";
|
|
14563
|
+
response.setEncoding("utf8");
|
|
14564
|
+
response.on("data", (chunk) => { body += chunk; });
|
|
14565
|
+
response.on("end", () => {
|
|
14566
|
+
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
14567
|
+
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
14568
|
+
});
|
|
14569
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
14570
|
+
});
|
|
14571
|
+
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
14572
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
14573
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
14574
|
+
`);
|
|
14575
|
+
CATALOGUE_REQUEST_SOURCE = probeWorkerSource(`
|
|
14576
|
+
const https = require("node:https");
|
|
14577
|
+
const { port, ca, token, timeoutMs, ok, failed } = workerData;
|
|
14578
|
+
const finish = finishProbe;
|
|
14579
|
+
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) => {
|
|
14580
|
+
response.resume();
|
|
14581
|
+
response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
|
|
14582
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
14583
|
+
});
|
|
14584
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
14585
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
14586
|
+
request.end();
|
|
14587
|
+
`);
|
|
14588
|
+
realProbeWorkers = { start: (source, data, timeoutMs) => startProbeWorker(source, data, timeoutMs) };
|
|
14589
|
+
ACCEPT_PROBE_SOURCE = probeWorkerSource(`
|
|
14590
|
+
const net = require("node:net");
|
|
14591
|
+
const dns = require("node:dns");
|
|
14592
|
+
const { host, port, portStart, portEnd, portFirst, platform, timeoutMs, ok, failed } = workerData;
|
|
14593
|
+
const finish = finishProbe;
|
|
14594
|
+
const SourcePortRange = ${SourcePortRange.toString()};
|
|
14595
|
+
const createDoorLookup = ${createDoorLookup.toString()};
|
|
14596
|
+
const sourcePortClassifier = ${sourcePortClassifier.toString()};
|
|
14597
|
+
const doorDial = ${doorDial.toString()};
|
|
14598
|
+
const probeAccept = ${probeAccept.toString()};
|
|
14599
|
+
const runAcceptProbe = ${runAcceptProbe.toString()};
|
|
14600
|
+
const startTimer = (callback, ms) => { const timer = setTimeout(callback, ms); return () => { clearTimeout(timer); }; };
|
|
14601
|
+
runAcceptProbe({ net, dns, createDoorLookup, doorDial, probeAccept, SourcePortRange, sourcePortClassifier }, { host, port, portStart, portEnd, portFirst, platform, timeoutMs }, startTimer).then((verdict) => {
|
|
14602
|
+
finish(verdict.ok ? ok : failed, verdict.ok ? "" : verdict.reason);
|
|
14603
|
+
});
|
|
14604
|
+
`);
|
|
14605
|
+
PROBE_PORT_SHARE_DENOMINATOR = 100;
|
|
14606
|
+
MAX_CONCURRENT_PROBES = Math.max(1, Math.floor(DOOR_SOURCE_PORT_COUNT / PROBE_PORT_SHARE_DENOMINATOR));
|
|
14607
|
+
PORT_BASE_SPREAD = 389;
|
|
14608
|
+
processPortBase = () => process.pid * PORT_BASE_SPREAD % DOOR_SOURCE_PORT_COUNT;
|
|
14609
|
+
targetKey = (target) => `${target.host}\0${String(target.port)}\0${String(target.timeoutMs)}`;
|
|
14610
|
+
PROBE_WAIT_SLICE_MS = 1e3;
|
|
14611
|
+
slicedProbeWait = (header, index, value, timeoutMs) => {
|
|
14612
|
+
const end = performance.now() + timeoutMs;
|
|
14613
|
+
for (; ; ) {
|
|
14614
|
+
noteBlockingStep();
|
|
14615
|
+
const left = end - performance.now();
|
|
14616
|
+
if (left <= 0) {
|
|
14617
|
+
return "timed-out";
|
|
14618
|
+
}
|
|
14619
|
+
const answer = Atomics.wait(header, index, value, Math.min(left, PROBE_WAIT_SLICE_MS));
|
|
14620
|
+
if (answer !== "timed-out") {
|
|
14621
|
+
return answer;
|
|
14622
|
+
}
|
|
14623
|
+
}
|
|
14624
|
+
};
|
|
14625
|
+
spawnRealWorker = (source, options) => new Worker(source, options);
|
|
14329
14626
|
}
|
|
14330
14627
|
});
|
|
14331
14628
|
|
|
14332
|
-
// src/
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
const parsed = ProviderAliasesSchema.safeParse(raw);
|
|
14336
|
-
if (!parsed.success) {
|
|
14337
|
-
throw new ConfigValidationError(file, parsed.error.issues);
|
|
14338
|
-
}
|
|
14339
|
-
return parsed.data;
|
|
14629
|
+
// src/providerReachability.ts
|
|
14630
|
+
function providerConnectTimeoutMs(provider) {
|
|
14631
|
+
return provider.connectTimeoutMs ?? DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS;
|
|
14340
14632
|
}
|
|
14341
|
-
function
|
|
14342
|
-
return
|
|
14633
|
+
function couldNotConnectMessage(subject, baseUrl, reason) {
|
|
14634
|
+
return `${subject} could not connect to ${displayBaseUrl(baseUrl)}: ${reason.trim() === "" ? "the connection failed with no reason given" : reason}`;
|
|
14343
14635
|
}
|
|
14344
|
-
function
|
|
14345
|
-
const
|
|
14346
|
-
return
|
|
14636
|
+
function probeProviderReachability(name, provider, probe) {
|
|
14637
|
+
const verdict = probe(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
14638
|
+
return verdict.ok ? { ok: true } : { ok: false, message: couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason) };
|
|
14347
14639
|
}
|
|
14348
|
-
function
|
|
14349
|
-
if (
|
|
14350
|
-
return
|
|
14640
|
+
function startProviderReachability(name, provider, start) {
|
|
14641
|
+
if (start === void 0 || !isHttpProvider(provider)) {
|
|
14642
|
+
return void 0;
|
|
14351
14643
|
}
|
|
14352
|
-
|
|
14644
|
+
const started = start(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
14645
|
+
return {
|
|
14646
|
+
cancel: started.cancel,
|
|
14647
|
+
line: () => {
|
|
14648
|
+
const verdict = started.verdict();
|
|
14649
|
+
return verdict.ok ? void 0 : couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason);
|
|
14650
|
+
}
|
|
14651
|
+
};
|
|
14353
14652
|
}
|
|
14354
|
-
function
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
|
|
14653
|
+
function probeProviderReachabilities(providers, probe) {
|
|
14654
|
+
const http3 = providers.flatMap((entry) => isHttpProvider(entry.provider) ? [{ name: entry.name, provider: entry.provider }] : []);
|
|
14655
|
+
const verdicts = probe(http3.map((entry) => ({ baseUrl: entry.provider.baseUrl, timeoutMs: providerConnectTimeoutMs(entry.provider) })));
|
|
14656
|
+
const lines = /* @__PURE__ */ new Map();
|
|
14657
|
+
http3.forEach((entry, index) => {
|
|
14658
|
+
const verdict = verdicts[index];
|
|
14659
|
+
if (verdict === void 0) {
|
|
14660
|
+
throw new Error("the batch probe answered fewer verdicts than it was given base URLs");
|
|
14358
14661
|
}
|
|
14359
|
-
if (
|
|
14360
|
-
|
|
14662
|
+
if (!verdict.ok) {
|
|
14663
|
+
lines.set(entry.name, couldNotConnectMessage(`provider ${entry.name}`, entry.provider.baseUrl, verdict.reason));
|
|
14361
14664
|
}
|
|
14362
|
-
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.` };
|
|
14363
14665
|
});
|
|
14666
|
+
return lines;
|
|
14364
14667
|
}
|
|
14365
|
-
var
|
|
14366
|
-
var
|
|
14367
|
-
"src/
|
|
14668
|
+
var TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS, CONNECT_SYN_RETRANSMISSIONS_TOLERATED, DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS, startBaseUrlBatchProbe, realBaseUrlBatchProbe, realStartBaseUrlProbe, realBaseUrlProbe;
|
|
14669
|
+
var init_providerReachability = __esm({
|
|
14670
|
+
"src/providerReachability.ts"() {
|
|
14368
14671
|
"use strict";
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14672
|
+
init_schema();
|
|
14673
|
+
init_baseUrlDial();
|
|
14674
|
+
init_baseUrlDisplay();
|
|
14675
|
+
init_probe();
|
|
14676
|
+
TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS = 1e3;
|
|
14677
|
+
CONNECT_SYN_RETRANSMISSIONS_TOLERATED = 2;
|
|
14678
|
+
DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS = TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS * (2 ** (CONNECT_SYN_RETRANSMISSIONS_TOLERATED + 1) - 1);
|
|
14679
|
+
startBaseUrlBatchProbe = (targets, workers) => {
|
|
14680
|
+
const started = startAddressProbes(targets.map((target) => ({ ...dialTargetOf(target.baseUrl), timeoutMs: target.timeoutMs })), workers);
|
|
14681
|
+
return { cancel: started.cancel, verdicts: started.settle };
|
|
14682
|
+
};
|
|
14683
|
+
realBaseUrlBatchProbe = (targets, workers) => startBaseUrlBatchProbe(targets, workers).verdicts();
|
|
14684
|
+
realStartBaseUrlProbe = (baseUrl, timeoutMs) => {
|
|
14685
|
+
const started = startBaseUrlBatchProbe([{ baseUrl, timeoutMs }]);
|
|
14686
|
+
return {
|
|
14687
|
+
cancel: started.cancel,
|
|
14688
|
+
verdict: () => {
|
|
14689
|
+
const [verdict] = started.verdicts();
|
|
14690
|
+
if (verdict === void 0) {
|
|
14691
|
+
throw new Error("the batch probe answered no verdict for one base URL");
|
|
14692
|
+
}
|
|
14693
|
+
return verdict;
|
|
14694
|
+
}
|
|
14695
|
+
};
|
|
14696
|
+
};
|
|
14697
|
+
realBaseUrlProbe = (baseUrl, timeoutMs) => realStartBaseUrlProbe(baseUrl, timeoutMs).verdict();
|
|
14373
14698
|
}
|
|
14374
14699
|
});
|
|
14375
14700
|
|
|
14376
|
-
// src/models/
|
|
14377
|
-
function
|
|
14378
|
-
|
|
14379
|
-
|
|
14380
|
-
|
|
14381
|
-
return name.trim().toLowerCase().replace(NON_IDENTITY_BRACKET_RE, "").replace(/[\s_]+/g, "-").replace(/([a-z])(\d+(?:\.\d+)+)/g, "$1-$2").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
14701
|
+
// src/models/tiers.ts
|
|
14702
|
+
function claudeNameTier(model) {
|
|
14703
|
+
const name = model.toLowerCase().replace(/\[1m\]$/, "");
|
|
14704
|
+
const parts = name.split("-");
|
|
14705
|
+
return parts[0] === "claude" ? CLAUDE_TIERS.find((tier) => parts.includes(tier)) : CLAUDE_TIERS.find((tier) => name === tier);
|
|
14382
14706
|
}
|
|
14383
|
-
|
|
14384
|
-
|
|
14385
|
-
|
|
14386
|
-
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
|
|
14392
|
-
|
|
14707
|
+
var TIER_ENV_VARIABLES;
|
|
14708
|
+
var init_tiers = __esm({
|
|
14709
|
+
"src/models/tiers.ts"() {
|
|
14710
|
+
"use strict";
|
|
14711
|
+
init_schema();
|
|
14712
|
+
TIER_ENV_VARIABLES = Object.freeze({
|
|
14713
|
+
fable: "ANTHROPIC_DEFAULT_FABLE_MODEL",
|
|
14714
|
+
opus: "ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
14715
|
+
sonnet: "ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
14716
|
+
haiku: "ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
|
14717
|
+
});
|
|
14393
14718
|
}
|
|
14394
|
-
}
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
}
|
|
14402
|
-
if (/^\d+$/.test(token) && next !== void 0 && /^\d+$/.test(next)) {
|
|
14403
|
-
return `${token}.${next}`;
|
|
14404
|
-
}
|
|
14405
|
-
const dotted = /^\d+(?:\.\d+)+$/.exec(token);
|
|
14406
|
-
if (dotted !== null) {
|
|
14407
|
-
return dotted[0];
|
|
14408
|
-
}
|
|
14719
|
+
});
|
|
14720
|
+
|
|
14721
|
+
// src/models/reservedModelNames.ts
|
|
14722
|
+
function reservedProviderNameReason(name) {
|
|
14723
|
+
const bare = withoutContextMarker(name);
|
|
14724
|
+
if (bare === AUTO_MODEL) {
|
|
14725
|
+
return `"${AUTO_MODEL}" is the model name that follows the server's live model`;
|
|
14409
14726
|
}
|
|
14410
|
-
|
|
14727
|
+
if (CLAUDE_CODE_ALIASES.has(bare.toLowerCase())) {
|
|
14728
|
+
return `"${name}" is a model alias Claude Code resolves itself`;
|
|
14729
|
+
}
|
|
14730
|
+
const tier = claudeNameTier(name);
|
|
14731
|
+
return tier === void 0 ? void 0 : `"${name}" is a Claude model name (the ${tier} tier)`;
|
|
14411
14732
|
}
|
|
14412
|
-
function
|
|
14413
|
-
const
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
const { familyTokens, variants } = splitVariants(tokens);
|
|
14418
|
-
const version = versionOf(familyTokens);
|
|
14419
|
-
const versionless = familyTokens.filter((token, index) => {
|
|
14420
|
-
if (version === "") {
|
|
14421
|
-
return true;
|
|
14422
|
-
}
|
|
14423
|
-
const dotted = /^\d+(?:\.\d+)+$/.test(token);
|
|
14424
|
-
const previous = familyTokens[index - 1];
|
|
14425
|
-
const next = familyTokens[index + 1];
|
|
14426
|
-
const insideVersionRun = dotted || /^\d+$/.test(token) && (previous !== void 0 && /^\d+$/.test(previous) || next !== void 0 && /^\d+$/.test(next));
|
|
14427
|
-
return !insideVersionRun;
|
|
14428
|
-
});
|
|
14429
|
-
const family = versionless.join("-");
|
|
14430
|
-
const tokenVendor = familyTokens.find((token) => Object.keys(VENDOR_BY_TOKEN).some((key) => token === key || token.startsWith(key)));
|
|
14431
|
-
const namespace = segments.length >= 2 ? (segments[0] ?? "").split(":").pop() ?? "" : "";
|
|
14432
|
-
const namespaceVendor = VENDOR_BY_NAMESPACE[namespace] ?? "";
|
|
14433
|
-
const tokenVendorName = tokenVendor === void 0 ? "" : VENDOR_BY_TOKEN[Object.keys(VENDOR_BY_TOKEN).find((key) => tokenVendor === key || tokenVendor.startsWith(key)) ?? ""] ?? "";
|
|
14434
|
-
return {
|
|
14435
|
-
vendor: tokenVendorName === "" ? namespaceVendor : tokenVendorName,
|
|
14436
|
-
vendorConflict: tokenVendorName !== "" && namespaceVendor !== "" && tokenVendorName !== namespaceVendor,
|
|
14437
|
-
family,
|
|
14438
|
-
version,
|
|
14439
|
-
variant: variants.join("-"),
|
|
14440
|
-
familyAndVersion: version === "" ? family : `${family}-${version.replace(/\./g, "-")}`
|
|
14441
|
-
};
|
|
14733
|
+
function requireUnreservedProviderName(name) {
|
|
14734
|
+
const reason = reservedProviderNameReason(name);
|
|
14735
|
+
if (reason !== void 0) {
|
|
14736
|
+
throw new InvalidProviderNameError(name, `must not be a bare model name, because ${reason}`);
|
|
14737
|
+
}
|
|
14442
14738
|
}
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14739
|
+
var AUTO_MODEL, CLAUDE_CODE_ALIASES;
|
|
14740
|
+
var init_reservedModelNames = __esm({
|
|
14741
|
+
"src/models/reservedModelNames.ts"() {
|
|
14742
|
+
"use strict";
|
|
14743
|
+
init_names();
|
|
14744
|
+
init_identity();
|
|
14745
|
+
init_tiers();
|
|
14746
|
+
AUTO_MODEL = "auto";
|
|
14747
|
+
CLAUDE_CODE_ALIASES = /* @__PURE__ */ new Set(["default", "best", "opusplan"]);
|
|
14448
14748
|
}
|
|
14449
|
-
|
|
14450
|
-
|
|
14749
|
+
});
|
|
14750
|
+
|
|
14751
|
+
// src/providerAliases.ts
|
|
14752
|
+
import { z as z30 } from "zod";
|
|
14753
|
+
function parseAliases(file, raw) {
|
|
14754
|
+
const parsed = ProviderAliasesSchema.safeParse(raw);
|
|
14755
|
+
if (!parsed.success) {
|
|
14756
|
+
throw new ConfigValidationError(file, parsed.error.issues);
|
|
14451
14757
|
}
|
|
14452
|
-
return
|
|
14758
|
+
return parsed.data;
|
|
14453
14759
|
}
|
|
14454
|
-
function
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14760
|
+
function readProviderAliases(paths) {
|
|
14761
|
+
return readJson(paths.providerAliasesFile, ProviderAliasesSchema) ?? {};
|
|
14762
|
+
}
|
|
14763
|
+
function loadProviderAliases(file, port) {
|
|
14764
|
+
const raw = port.readConfigFile(file);
|
|
14765
|
+
return raw === void 0 ? {} : parseAliases(file, raw);
|
|
14766
|
+
}
|
|
14767
|
+
function canonicalProviderName(name, defined, aliases) {
|
|
14768
|
+
if (defined(name)) {
|
|
14769
|
+
return name;
|
|
14460
14770
|
}
|
|
14461
|
-
return
|
|
14771
|
+
return aliases()[name] ?? name;
|
|
14462
14772
|
}
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14773
|
+
function aliasFindings(aliases, providerNames) {
|
|
14774
|
+
return Object.entries(aliases).map(([alias, target]) => {
|
|
14775
|
+
if (!providerNames.has(target)) {
|
|
14776
|
+
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}\`.` };
|
|
14777
|
+
}
|
|
14778
|
+
if (providerNames.has(alias)) {
|
|
14779
|
+
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}\`.` };
|
|
14780
|
+
}
|
|
14781
|
+
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.` };
|
|
14782
|
+
});
|
|
14783
|
+
}
|
|
14784
|
+
var ProviderAliasesSchema;
|
|
14785
|
+
var init_providerAliases = __esm({
|
|
14786
|
+
"src/providerAliases.ts"() {
|
|
14466
14787
|
"use strict";
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
VENDOR_BY_NAMESPACE = Object.freeze({
|
|
14472
|
-
anthropic: "anthropic",
|
|
14473
|
-
google: "google",
|
|
14474
|
-
openai: "openai",
|
|
14475
|
-
zai: "zai",
|
|
14476
|
-
"z-ai": "zai",
|
|
14477
|
-
minimax: "minimax",
|
|
14478
|
-
qwen: "qwen",
|
|
14479
|
-
deepseek: "deepseek",
|
|
14480
|
-
moonshot: "moonshot",
|
|
14481
|
-
meta: "meta",
|
|
14482
|
-
mistral: "mistral"
|
|
14483
|
-
});
|
|
14484
|
-
VENDOR_BY_TOKEN = Object.freeze({
|
|
14485
|
-
claude: "anthropic",
|
|
14486
|
-
gemini: "google",
|
|
14487
|
-
antigravity: "google",
|
|
14488
|
-
gpt: "openai",
|
|
14489
|
-
glm: "zai",
|
|
14490
|
-
minimax: "minimax",
|
|
14491
|
-
qwen: "qwen",
|
|
14492
|
-
deepseek: "deepseek",
|
|
14493
|
-
kimi: "moonshot",
|
|
14494
|
-
llama: "meta",
|
|
14495
|
-
mistral: "mistral",
|
|
14496
|
-
mixtral: "mistral"
|
|
14497
|
-
});
|
|
14788
|
+
init_cliError();
|
|
14789
|
+
init_load();
|
|
14790
|
+
init_store();
|
|
14791
|
+
ProviderAliasesSchema = z30.record(z30.string().min(1), z30.string().min(1));
|
|
14498
14792
|
}
|
|
14499
14793
|
});
|
|
14500
14794
|
|
|
@@ -14574,7 +14868,7 @@ var FAMILY_PREFIX, VARIANT_SEPARATOR;
|
|
|
14574
14868
|
var init_families = __esm({
|
|
14575
14869
|
"src/models/families.ts"() {
|
|
14576
14870
|
"use strict";
|
|
14577
|
-
|
|
14871
|
+
init_identity();
|
|
14578
14872
|
FAMILY_PREFIX = "family:";
|
|
14579
14873
|
VARIANT_SEPARATOR = "+";
|
|
14580
14874
|
}
|
|
@@ -14714,6 +15008,7 @@ function addProvider(paths, name, input) {
|
|
|
14714
15008
|
throw new ProviderAlreadyExistsError(name);
|
|
14715
15009
|
}
|
|
14716
15010
|
requireNewProviderName(name);
|
|
15011
|
+
requireUnreservedProviderName(name);
|
|
14717
15012
|
const kind = input.kind ?? "http";
|
|
14718
15013
|
if (kind === "codex" && input.baseUrl !== void 0) {
|
|
14719
15014
|
throw new ProviderKindMismatchError("A codex provider has no base URL: the launcher points its sessions at the front-door daemon. Drop --base-url.");
|
|
@@ -14736,6 +15031,9 @@ function addProvider(paths, name, input) {
|
|
|
14736
15031
|
if (kind !== "http" && input.connectTimeoutMs !== void 0) {
|
|
14737
15032
|
throw new ProviderKindMismatchError("A connect timeout applies only to an http provider, the one kind that dials a base URL.");
|
|
14738
15033
|
}
|
|
15034
|
+
if (kind !== "http" && input.serverTools !== void 0) {
|
|
15035
|
+
throw new ProviderKindMismatchError("The server-tools setting applies only to an http provider.");
|
|
15036
|
+
}
|
|
14739
15037
|
if (kind !== "codex" && !isEmptyCodexConfig(input.codex)) {
|
|
14740
15038
|
throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
|
|
14741
15039
|
}
|
|
@@ -14749,7 +15047,7 @@ function addProvider(paths, name, input) {
|
|
|
14749
15047
|
...input.pickerModels === void 0 || input.pickerModels.length === 0 ? {} : { pickerModels: input.pickerModels }
|
|
14750
15048
|
};
|
|
14751
15049
|
const parsed = ProviderSchema.safeParse(
|
|
14752
|
-
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 } }
|
|
15050
|
+
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 } }
|
|
14753
15051
|
);
|
|
14754
15052
|
if (!parsed.success) {
|
|
14755
15053
|
throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
|
|
@@ -14787,6 +15085,9 @@ function updateProvider(paths, name, input) {
|
|
|
14787
15085
|
if ((isCodexProvider(existing) || isAntigravityProvider(existing)) && input.catalogue !== void 0 && input.catalogue !== false) {
|
|
14788
15086
|
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a model catalogue applies only to an http provider.`);
|
|
14789
15087
|
}
|
|
15088
|
+
if ((isCodexProvider(existing) || isAntigravityProvider(existing) || router) && input.serverTools !== void 0) {
|
|
15089
|
+
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; the server-tools setting applies only to an http provider.`);
|
|
15090
|
+
}
|
|
14790
15091
|
if (!isCodexProvider(existing) && !isEmptyCodexConfig(input.codex)) {
|
|
14791
15092
|
throw new ProviderKindMismatchError(`Provider "${name}" is not a codex provider; codex settings apply only to a codex provider.`);
|
|
14792
15093
|
}
|
|
@@ -14825,7 +15126,7 @@ function updateProvider(paths, name, input) {
|
|
|
14825
15126
|
} else {
|
|
14826
15127
|
const catalogue = input.catalogue === void 0 ? existing.catalogue : input.catalogue === false ? void 0 : input.catalogue;
|
|
14827
15128
|
const connectTimeoutMs = input.connectTimeoutMs === void 0 ? existing.connectTimeoutMs : input.connectTimeoutMs === false ? void 0 : input.connectTimeoutMs;
|
|
14828
|
-
candidate = { ...existing, ...shared, catalogue, connectTimeoutMs, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
|
|
15129
|
+
candidate = { ...existing, ...shared, catalogue, connectTimeoutMs, ...input.serverTools === void 0 ? {} : { serverTools: input.serverTools }, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
|
|
14829
15130
|
}
|
|
14830
15131
|
const parsed = ProviderSchema.safeParse(candidate);
|
|
14831
15132
|
if (!parsed.success) {
|
|
@@ -14967,6 +15268,7 @@ var init_providersStore = __esm({
|
|
|
14967
15268
|
init_walk();
|
|
14968
15269
|
init_families();
|
|
14969
15270
|
init_names();
|
|
15271
|
+
init_reservedModelNames();
|
|
14970
15272
|
ProviderNotFoundError = class extends CliError {
|
|
14971
15273
|
constructor(name) {
|
|
14972
15274
|
super(`No provider named "${name}". Run \`agent-shim provider add ${name}\` first.`);
|
|
@@ -15008,512 +15310,475 @@ var init_providersStore = __esm({
|
|
|
15008
15310
|
}
|
|
15009
15311
|
});
|
|
15010
15312
|
|
|
15011
|
-
// src/
|
|
15012
|
-
function
|
|
15013
|
-
|
|
15014
|
-
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
|
|
15020
|
-
|
|
15021
|
-
|
|
15022
|
-
return void 0;
|
|
15023
|
-
}
|
|
15024
|
-
function memberProviderResolver(params) {
|
|
15025
|
-
if (params.cliProvider === false) {
|
|
15026
|
-
return () => void 0;
|
|
15313
|
+
// src/cli/bool.ts
|
|
15314
|
+
function parseBoolWord(input) {
|
|
15315
|
+
switch (input) {
|
|
15316
|
+
case "true":
|
|
15317
|
+
case "1":
|
|
15318
|
+
return true;
|
|
15319
|
+
case "false":
|
|
15320
|
+
case "0":
|
|
15321
|
+
return false;
|
|
15322
|
+
default:
|
|
15323
|
+
return void 0;
|
|
15027
15324
|
}
|
|
15028
|
-
const cliProvider = params.cliProvider;
|
|
15029
|
-
const identities = identityReader(params.paths.identitiesDir, params.fs);
|
|
15030
|
-
const cascades = /* @__PURE__ */ new Map();
|
|
15031
|
-
const cascadeOver = (baseConfigProfile) => {
|
|
15032
|
-
const cached = cascades.get(baseConfigProfile);
|
|
15033
|
-
if (cached !== void 0) {
|
|
15034
|
-
return cached;
|
|
15035
|
-
}
|
|
15036
|
-
const loaded = params.loadCascade(baseConfigProfile);
|
|
15037
|
-
cascades.set(baseConfigProfile, loaded);
|
|
15038
|
-
return loaded;
|
|
15039
|
-
};
|
|
15040
|
-
return (name) => {
|
|
15041
|
-
let declared;
|
|
15042
|
-
try {
|
|
15043
|
-
declared = identities.load(name);
|
|
15044
|
-
} catch (error) {
|
|
15045
|
-
if (!(error instanceof ConfigValidationError)) {
|
|
15046
|
-
throw error;
|
|
15047
|
-
}
|
|
15048
|
-
}
|
|
15049
|
-
const profile = decideConfigProfile({
|
|
15050
|
-
env: params.env,
|
|
15051
|
-
...params.cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile: params.cliFlagConfigProfile },
|
|
15052
|
-
...params.directoryRuleConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: params.directoryRuleConfigProfile },
|
|
15053
|
-
...declared?.defaultConfigProfile === void 0 ? {} : { identityDefaultConfigProfile: declared.defaultConfigProfile },
|
|
15054
|
-
...params.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: params.globalDefaultConfigProfile }
|
|
15055
|
-
});
|
|
15056
|
-
const flagged = cliProvider !== void 0 && cliProvider !== "" ? cliProvider : void 0;
|
|
15057
|
-
let named = flagged ?? declared?.provider;
|
|
15058
|
-
try {
|
|
15059
|
-
const cascade = cascadeOver(profile.name);
|
|
15060
|
-
named = flagged ?? cascadeProviderName(cascade, declared?.provider);
|
|
15061
|
-
return selectedProviderName({
|
|
15062
|
-
paths: params.paths,
|
|
15063
|
-
port: params.fs,
|
|
15064
|
-
...cliProvider === void 0 ? {} : { cliProvider },
|
|
15065
|
-
cascade,
|
|
15066
|
-
...declared?.provider === void 0 ? {} : { identityProvider: declared.provider }
|
|
15067
|
-
});
|
|
15068
|
-
} catch (error) {
|
|
15069
|
-
const reason = unreadableFileReason(error);
|
|
15070
|
-
if (reason === void 0) {
|
|
15071
|
-
throw error;
|
|
15072
|
-
}
|
|
15073
|
-
return { ...named === void 0 ? {} : { named }, reason };
|
|
15074
|
-
}
|
|
15075
|
-
};
|
|
15076
15325
|
}
|
|
15077
|
-
var
|
|
15078
|
-
"src/
|
|
15326
|
+
var init_bool = __esm({
|
|
15327
|
+
"src/cli/bool.ts"() {
|
|
15079
15328
|
"use strict";
|
|
15080
|
-
init_load();
|
|
15081
|
-
init_providersStore();
|
|
15082
|
-
init_identity();
|
|
15083
15329
|
}
|
|
15084
15330
|
});
|
|
15085
15331
|
|
|
15086
|
-
// src/
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
function resolveAgentShimHome(env = process.env, home = os6.homedir(), isDirectory = isExistingDirectory) {
|
|
15091
|
-
const fromEnv = env.AGENT_SHIM_HOME;
|
|
15092
|
-
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15093
|
-
return fromEnv;
|
|
15332
|
+
// src/cli/envBool.ts
|
|
15333
|
+
function parseEnvBool(variable, value) {
|
|
15334
|
+
if (value === void 0 || value === "") {
|
|
15335
|
+
return void 0;
|
|
15094
15336
|
}
|
|
15095
|
-
const
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
}
|
|
15099
|
-
function isExistingDirectory(candidate) {
|
|
15100
|
-
return fs12.statSync(candidate, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
15101
|
-
}
|
|
15102
|
-
function resolveClaudeHome() {
|
|
15103
|
-
const fromEnv = process.env.AGENT_SHIM_CLAUDE_HOME;
|
|
15104
|
-
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15105
|
-
return fromEnv;
|
|
15337
|
+
const parsed = parseBoolWord(value);
|
|
15338
|
+
if (parsed === void 0) {
|
|
15339
|
+
throw new InvalidEnvBoolError(variable, value);
|
|
15106
15340
|
}
|
|
15107
|
-
return
|
|
15108
|
-
}
|
|
15109
|
-
function buildLayoutPaths(root) {
|
|
15110
|
-
return {
|
|
15111
|
-
root,
|
|
15112
|
-
identitiesDir: path39.join(root, "identities"),
|
|
15113
|
-
configProfilesDir: path39.join(root, "config-profiles"),
|
|
15114
|
-
providersDir: path39.join(root, "providers"),
|
|
15115
|
-
providerAliasesFile: path39.join(root, "provider-aliases.json"),
|
|
15116
|
-
directoryRulesFile: path39.join(root, "directory-rules.json"),
|
|
15117
|
-
activeIdentityFile: path39.join(root, "active-identity"),
|
|
15118
|
-
globalConfigFile: path39.join(root, "config.json"),
|
|
15119
|
-
categoriesLocalFile: path39.join(root, "categories.local.json"),
|
|
15120
|
-
claudeShimFile: path39.join(root, "claude-shim.json"),
|
|
15121
|
-
headroomDir: path39.join(root, "headroom"),
|
|
15122
|
-
headroomStateFile: path39.join(root, "headroom", "state.json"),
|
|
15123
|
-
headroomRoutingFile: path39.join(root, "headroom", "routing.json"),
|
|
15124
|
-
headroomLegacyStateFile: path39.join(root, "headroom", "state.v2.json"),
|
|
15125
|
-
headroomAllowlistFile: path39.join(root, "headroom", "run", "allowlist.txt"),
|
|
15126
|
-
headroomSocketDir: path39.join(root, "headroom", "run"),
|
|
15127
|
-
headroomLockFile: path39.join(root, "headroom", "start.lock"),
|
|
15128
|
-
headroomSessionsDir: path39.join(root, "headroom", "sessions"),
|
|
15129
|
-
logsDir: path39.join(root, "logs"),
|
|
15130
|
-
headroomLogPath: path39.join(root, "logs", "headroom.log"),
|
|
15131
|
-
frontdoorDir: path39.join(root, "frontdoor"),
|
|
15132
|
-
frontdoorCaDir: path39.join(root, "frontdoor", "ca"),
|
|
15133
|
-
frontdoorCaCertFile: path39.join(root, "frontdoor", "ca", "ca.pem"),
|
|
15134
|
-
frontdoorCaKeyFile: path39.join(root, "frontdoor", "ca", "ca.key"),
|
|
15135
|
-
frontdoorCaBundlesDir: path39.join(root, "frontdoor", "ca", "bundles"),
|
|
15136
|
-
chatgptSignInFile: path39.join(root, "codex", "chatgpt-sign-in.json"),
|
|
15137
|
-
frontdoorStateFile: path39.join(root, "frontdoor", "state.json"),
|
|
15138
|
-
frontdoorLockFile: path39.join(root, "frontdoor", "start.lock"),
|
|
15139
|
-
frontdoorControlTokenFile: path39.join(root, "frontdoor", "control-token"),
|
|
15140
|
-
frontdoorSessionsDir: path39.join(root, "frontdoor", "sessions"),
|
|
15141
|
-
frontdoorDirectRecordsDir: path39.join(root, "frontdoor", "direct"),
|
|
15142
|
-
frontdoorDrainingDir: path39.join(root, "frontdoor", "draining"),
|
|
15143
|
-
frontdoorRcCredentialsDir: path39.join(root, "frontdoor", "rc-credentials"),
|
|
15144
|
-
frontdoorLogPath: path39.join(root, "logs", "frontdoor.log"),
|
|
15145
|
-
usageDir: path39.join(root, "usage"),
|
|
15146
|
-
usageLogDir: path39.join(root, "usage", "log"),
|
|
15147
|
-
usageSnapshotsDir: path39.join(root, "usage", "snapshots"),
|
|
15148
|
-
statuslineDir: path39.join(root, "statusline"),
|
|
15149
|
-
catalogueDir: path39.join(root, "catalogues"),
|
|
15150
|
-
usagePicksFile: path39.join(root, "usage", "picks.json"),
|
|
15151
|
-
usageAnchorsFile: path39.join(root, "usage", "anchors.json"),
|
|
15152
|
-
usageJobsFile: path39.join(root, "usage", "jobs.json"),
|
|
15153
|
-
jobLogsDir: path39.join(root, "logs", "jobs"),
|
|
15154
|
-
identityRenamesDir: path39.join(root, "identity-renames"),
|
|
15155
|
-
identityNameRenamesDir: path39.join(root, "identity-name-renames"),
|
|
15156
|
-
launchesDir: path39.join(root, "launches"),
|
|
15157
|
-
superviseDir: path39.join(root, "supervise"),
|
|
15158
|
-
modelMovesDir: path39.join(root, "model-moves"),
|
|
15159
|
-
mcpPermissionsFile: path39.join(root, "mcp", "permissions.json")
|
|
15160
|
-
};
|
|
15161
|
-
}
|
|
15162
|
-
function resolveLayoutPaths() {
|
|
15163
|
-
return buildLayoutPaths(resolveAgentShimHome());
|
|
15341
|
+
return parsed;
|
|
15164
15342
|
}
|
|
15165
|
-
var
|
|
15166
|
-
|
|
15343
|
+
var InvalidEnvBoolError;
|
|
15344
|
+
var init_envBool = __esm({
|
|
15345
|
+
"src/cli/envBool.ts"() {
|
|
15167
15346
|
"use strict";
|
|
15168
|
-
|
|
15347
|
+
init_cliError();
|
|
15348
|
+
init_bool();
|
|
15349
|
+
InvalidEnvBoolError = class extends UsageError {
|
|
15350
|
+
constructor(variable, value) {
|
|
15351
|
+
super(`${variable} must be one of true, false, 1 or 0, got "${value}".`);
|
|
15352
|
+
this.variable = variable;
|
|
15353
|
+
this.value = value;
|
|
15354
|
+
this.name = "InvalidEnvBoolError";
|
|
15355
|
+
}
|
|
15356
|
+
variable;
|
|
15357
|
+
value;
|
|
15358
|
+
};
|
|
15169
15359
|
}
|
|
15170
15360
|
});
|
|
15171
15361
|
|
|
15172
|
-
// src/
|
|
15173
|
-
import
|
|
15174
|
-
function
|
|
15175
|
-
|
|
15176
|
-
|
|
15177
|
-
|
|
15178
|
-
|
|
15179
|
-
|
|
15180
|
-
|
|
15181
|
-
return
|
|
15182
|
-
}
|
|
15183
|
-
function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS, workers = realProbeWorkers) {
|
|
15184
|
-
refuseToBlockInRole("a synchronous probe of the front door");
|
|
15185
|
-
return workers.start(PROBE_SOURCE, { port, ca: caPem }, timeoutMs).verdict();
|
|
15362
|
+
// src/pathNorm.ts
|
|
15363
|
+
import path37 from "node:path";
|
|
15364
|
+
function expandTilde(value, home) {
|
|
15365
|
+
if (value === "~") {
|
|
15366
|
+
return home;
|
|
15367
|
+
}
|
|
15368
|
+
if (value.startsWith("~/")) {
|
|
15369
|
+
return path37.join(home, value.slice(2));
|
|
15370
|
+
}
|
|
15371
|
+
return value;
|
|
15186
15372
|
}
|
|
15187
|
-
function
|
|
15188
|
-
|
|
15189
|
-
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();
|
|
15373
|
+
function normaliseRulePath(rulePath, home) {
|
|
15374
|
+
return path37.resolve(expandTilde(rulePath, home));
|
|
15190
15375
|
}
|
|
15191
|
-
|
|
15192
|
-
|
|
15193
|
-
|
|
15194
|
-
const distinct = /* @__PURE__ */ new Map();
|
|
15195
|
-
for (const target of targets) {
|
|
15196
|
-
distinct.set(targetKey(target), target);
|
|
15376
|
+
var init_pathNorm = __esm({
|
|
15377
|
+
"src/pathNorm.ts"() {
|
|
15378
|
+
"use strict";
|
|
15197
15379
|
}
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15380
|
+
});
|
|
15381
|
+
|
|
15382
|
+
// src/launcher/cascade.ts
|
|
15383
|
+
import path38 from "node:path";
|
|
15384
|
+
function loadCascadeInput(params) {
|
|
15385
|
+
const globalConfig = loadConfigFile(params.paths.globalConfigFile, GlobalConfigSchema, params.read);
|
|
15386
|
+
const directoryRules = loadConfigFile(params.paths.directoryRulesFile, DirectoryRulesSchema, params.read);
|
|
15387
|
+
const loadProfile = (name) => {
|
|
15388
|
+
const filepath = profileFilePath(params.paths.configProfilesDir, name);
|
|
15389
|
+
const loaded = loadConfigFile(filepath, ConfigProfileSchema, params.read);
|
|
15390
|
+
if (loaded === void 0) {
|
|
15391
|
+
return void 0;
|
|
15206
15392
|
}
|
|
15393
|
+
return { name, profile: loaded.config, entryOrder: loaded.entryOrder, filepath: loaded.filepath };
|
|
15207
15394
|
};
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15211
|
-
}
|
|
15212
|
-
|
|
15213
|
-
try {
|
|
15214
|
-
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);
|
|
15215
|
-
running.push({ key: targetKey(target), verdict: started.verdict, cancel: started.cancel });
|
|
15216
|
-
} catch (error) {
|
|
15217
|
-
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
15218
|
-
running.push({ key: targetKey(target), verdict: () => ({ ok: false, reason }), cancel: () => void 0 });
|
|
15219
|
-
}
|
|
15395
|
+
const limit = globalConfig?.config.walkUpLimit;
|
|
15396
|
+
const dirs = walkDirectoryAncestors(params.cwd, {
|
|
15397
|
+
home: params.home,
|
|
15398
|
+
...limit === void 0 ? {} : { limit: expandTilde(limit, params.home) },
|
|
15399
|
+
...params.isReadable === void 0 ? {} : { isReadable: params.isReadable }
|
|
15220
15400
|
});
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
|
|
15225
|
-
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
|
|
15235
|
-
for (const started of running.splice(0)) {
|
|
15236
|
-
started.cancel();
|
|
15237
|
-
}
|
|
15401
|
+
const levels = [];
|
|
15402
|
+
for (const dir of dirs) {
|
|
15403
|
+
const portable = loadConfigFile(path38.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(path38.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15404
|
+
const portableLocal = loadConfigFile(path38.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(path38.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15405
|
+
const rules = (directoryRules?.config.rules ?? []).map((rule, index) => ({ rule, index })).filter(({ rule }) => normaliseRulePath(rule.path, params.home) === dir).map(({ rule, index }) => {
|
|
15406
|
+
const entryOrder = directoryRules?.ruleEntryOrders[index];
|
|
15407
|
+
return {
|
|
15408
|
+
rule,
|
|
15409
|
+
...entryOrder === void 0 ? {} : { entryOrder },
|
|
15410
|
+
filepath: params.paths.directoryRulesFile
|
|
15411
|
+
};
|
|
15412
|
+
});
|
|
15413
|
+
if (portable === void 0 && portableLocal === void 0 && rules.length === 0) {
|
|
15414
|
+
continue;
|
|
15238
15415
|
}
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
|
|
15243
|
-
|
|
15244
|
-
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
15245
|
-
let worker;
|
|
15246
|
-
try {
|
|
15247
|
-
worker = spawn3(`${WORKER_PRELUDE_SOURCE}
|
|
15248
|
-
new Function("require", ${JSON.stringify(source)})(require);`, {
|
|
15249
|
-
eval: true,
|
|
15250
|
-
workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS, startedSlot: STARTED_SLOT, failurePrefix: PROBE_WORKER_FAILURE_PREFIX, claimSlot: CLAIM_SLOT }
|
|
15416
|
+
levels.push({
|
|
15417
|
+
dir,
|
|
15418
|
+
...portable === void 0 ? {} : { portable: { config: portable.config, entryOrder: portable.entryOrder, filepath: portable.filepath } },
|
|
15419
|
+
...rules.length === 0 ? {} : { rules },
|
|
15420
|
+
...portableLocal === void 0 ? {} : { portableLocal: { config: portableLocal.config, entryOrder: portableLocal.entryOrder, filepath: portableLocal.filepath } }
|
|
15251
15421
|
});
|
|
15252
|
-
} catch (error) {
|
|
15253
|
-
const reason = `${PROBE_WORKER_FAILURE_PREFIX}the worker could not be started: ${error instanceof Error ? error.message : String(error)}`;
|
|
15254
|
-
return { verdict: () => ({ ok: false, reason }), cancel: () => void 0 };
|
|
15255
15422
|
}
|
|
15256
|
-
|
|
15257
|
-
|
|
15258
|
-
|
|
15259
|
-
}
|
|
15260
|
-
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
|
|
15267
|
-
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
if (verdict === VERDICT_OK) {
|
|
15280
|
-
return { ok: true };
|
|
15281
|
-
}
|
|
15282
|
-
const length = Atomics.load(header, 1);
|
|
15283
|
-
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
15284
|
-
} finally {
|
|
15285
|
-
void worker.terminate();
|
|
15423
|
+
const input = {
|
|
15424
|
+
home: params.home,
|
|
15425
|
+
...globalConfig === void 0 ? {} : { globalConfig: { config: globalConfig.config, entryOrder: globalConfig.entryOrder, filepath: globalConfig.filepath } },
|
|
15426
|
+
...params.baseConfigProfile === void 0 ? {} : { baseConfigProfile: params.baseConfigProfile },
|
|
15427
|
+
loadProfile,
|
|
15428
|
+
levels,
|
|
15429
|
+
...params.cliOverride === void 0 ? {} : { cliOverride: params.cliOverride }
|
|
15430
|
+
};
|
|
15431
|
+
return { input, ...globalConfig === void 0 ? {} : { globalConfig: globalConfig.config } };
|
|
15432
|
+
}
|
|
15433
|
+
function readDirectorySelections(loaded) {
|
|
15434
|
+
let identity;
|
|
15435
|
+
let configProfile;
|
|
15436
|
+
for (const level of loaded.input.levels ?? []) {
|
|
15437
|
+
for (const source of [level.portable?.config, ...(level.rules ?? []).map((entry) => entry.rule), level.portableLocal?.config]) {
|
|
15438
|
+
if (source === void 0) {
|
|
15439
|
+
continue;
|
|
15440
|
+
}
|
|
15441
|
+
if (source.identity !== void 0) {
|
|
15442
|
+
identity = source.identity;
|
|
15443
|
+
}
|
|
15444
|
+
if (source.configProfile !== void 0) {
|
|
15445
|
+
configProfile = source.configProfile;
|
|
15286
15446
|
}
|
|
15287
|
-
},
|
|
15288
|
-
cancel: () => {
|
|
15289
|
-
void worker.terminate();
|
|
15290
15447
|
}
|
|
15291
|
-
}
|
|
15448
|
+
}
|
|
15449
|
+
return { ...identity === void 0 ? {} : { identity }, ...configProfile === void 0 ? {} : { configProfile } };
|
|
15292
15450
|
}
|
|
15293
|
-
var
|
|
15294
|
-
var
|
|
15295
|
-
"src/
|
|
15451
|
+
var PORTABLE_CONFIG_FILENAME, PORTABLE_LOCAL_CONFIG_FILENAME;
|
|
15452
|
+
var init_cascade = __esm({
|
|
15453
|
+
"src/launcher/cascade.ts"() {
|
|
15296
15454
|
"use strict";
|
|
15297
|
-
|
|
15298
|
-
|
|
15299
|
-
|
|
15300
|
-
|
|
15301
|
-
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
|
|
15322
|
-
|
|
15323
|
-
|
|
15324
|
-
|
|
15325
|
-
|
|
15326
|
-
|
|
15327
|
-
|
|
15328
|
-
|
|
15455
|
+
init_load();
|
|
15456
|
+
init_schema();
|
|
15457
|
+
init_pathNorm();
|
|
15458
|
+
init_walk();
|
|
15459
|
+
init_legacy();
|
|
15460
|
+
init_names();
|
|
15461
|
+
PORTABLE_CONFIG_FILENAME = ".agent-shim.json";
|
|
15462
|
+
PORTABLE_LOCAL_CONFIG_FILENAME = ".agent-shim.local.json";
|
|
15463
|
+
}
|
|
15464
|
+
});
|
|
15465
|
+
|
|
15466
|
+
// src/launcher/memberProvider.ts
|
|
15467
|
+
function unreadableFileReason(error) {
|
|
15468
|
+
if (error instanceof ConfigValidationError) {
|
|
15469
|
+
return `${error.filepath} is invalid`;
|
|
15470
|
+
}
|
|
15471
|
+
if (error instanceof ConfigFileNotJsonError) {
|
|
15472
|
+
return error.message.replace(/\.$/, "");
|
|
15473
|
+
}
|
|
15474
|
+
if (error instanceof LegacyProviderFileError) {
|
|
15475
|
+
return `${error.filePath} uses ${error.conversion.fields.join(", ")}, which a credential block replaced`;
|
|
15476
|
+
}
|
|
15477
|
+
return void 0;
|
|
15478
|
+
}
|
|
15479
|
+
function memberProviderResolver(params) {
|
|
15480
|
+
if (params.cliProvider === false) {
|
|
15481
|
+
return () => void 0;
|
|
15482
|
+
}
|
|
15483
|
+
const cliProvider = params.cliProvider;
|
|
15484
|
+
const identities = identityReader(params.paths.identitiesDir, params.fs);
|
|
15485
|
+
const cascades = /* @__PURE__ */ new Map();
|
|
15486
|
+
const cascadeOver = (baseConfigProfile) => {
|
|
15487
|
+
const cached = cascades.get(baseConfigProfile);
|
|
15488
|
+
if (cached !== void 0) {
|
|
15489
|
+
return cached;
|
|
15329
15490
|
}
|
|
15491
|
+
const loaded = params.loadCascade(baseConfigProfile);
|
|
15492
|
+
cascades.set(baseConfigProfile, loaded);
|
|
15493
|
+
return loaded;
|
|
15330
15494
|
};
|
|
15331
|
-
|
|
15332
|
-
let
|
|
15495
|
+
return (name) => {
|
|
15496
|
+
let declared;
|
|
15333
15497
|
try {
|
|
15334
|
-
|
|
15335
|
-
} catch {
|
|
15336
|
-
|
|
15498
|
+
declared = identities.load(name);
|
|
15499
|
+
} catch (error) {
|
|
15500
|
+
if (!(error instanceof ConfigValidationError)) {
|
|
15501
|
+
throw error;
|
|
15502
|
+
}
|
|
15337
15503
|
}
|
|
15504
|
+
const profile = decideConfigProfile({
|
|
15505
|
+
env: params.env,
|
|
15506
|
+
...params.cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile: params.cliFlagConfigProfile },
|
|
15507
|
+
...params.directoryRuleConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: params.directoryRuleConfigProfile },
|
|
15508
|
+
...declared?.defaultConfigProfile === void 0 ? {} : { identityDefaultConfigProfile: declared.defaultConfigProfile },
|
|
15509
|
+
...params.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: params.globalDefaultConfigProfile }
|
|
15510
|
+
});
|
|
15511
|
+
const flagged = cliProvider !== void 0 && cliProvider !== "" ? cliProvider : void 0;
|
|
15512
|
+
let named = flagged ?? declared?.provider;
|
|
15338
15513
|
try {
|
|
15339
|
-
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15514
|
+
const cascade = cascadeOver(profile.name);
|
|
15515
|
+
named = flagged ?? cascadeProviderName(cascade, declared?.provider);
|
|
15516
|
+
return selectedProviderName({
|
|
15517
|
+
paths: params.paths,
|
|
15518
|
+
port: params.fs,
|
|
15519
|
+
...cliProvider === void 0 ? {} : { cliProvider },
|
|
15520
|
+
cascade,
|
|
15521
|
+
...declared?.provider === void 0 ? {} : { identityProvider: declared.provider }
|
|
15522
|
+
});
|
|
15523
|
+
} catch (error) {
|
|
15524
|
+
const reason = unreadableFileReason(error);
|
|
15525
|
+
if (reason === void 0) {
|
|
15526
|
+
throw error;
|
|
15527
|
+
}
|
|
15528
|
+
return { ...named === void 0 ? {} : { named }, reason };
|
|
15343
15529
|
}
|
|
15344
15530
|
};
|
|
15345
|
-
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
|
|
15351
|
-
|
|
15352
|
-
|
|
15353
|
-
PROBE_SOURCE = probeWorkerSource(`
|
|
15354
|
-
const https = require("node:https");
|
|
15355
|
-
const { port, ca, timeoutMs, ok, failed } = workerData;
|
|
15356
|
-
const finish = finishProbe;
|
|
15357
|
-
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
15358
|
-
let body = "";
|
|
15359
|
-
response.setEncoding("utf8");
|
|
15360
|
-
response.on("data", (chunk) => { body += chunk; });
|
|
15361
|
-
response.on("end", () => {
|
|
15362
|
-
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
15363
|
-
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
15364
|
-
});
|
|
15365
|
-
response.on("error", (error) => finish(failed, error.message));
|
|
15366
|
-
});
|
|
15367
|
-
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
15368
|
-
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
15369
|
-
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
15370
|
-
`);
|
|
15371
|
-
CATALOGUE_REQUEST_SOURCE = probeWorkerSource(`
|
|
15372
|
-
const https = require("node:https");
|
|
15373
|
-
const { port, ca, token, timeoutMs, ok, failed } = workerData;
|
|
15374
|
-
const finish = finishProbe;
|
|
15375
|
-
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) => {
|
|
15376
|
-
response.resume();
|
|
15377
|
-
response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
|
|
15378
|
-
response.on("error", (error) => finish(failed, error.message));
|
|
15531
|
+
}
|
|
15532
|
+
var init_memberProvider = __esm({
|
|
15533
|
+
"src/launcher/memberProvider.ts"() {
|
|
15534
|
+
"use strict";
|
|
15535
|
+
init_load();
|
|
15536
|
+
init_providersStore();
|
|
15537
|
+
init_identity2();
|
|
15538
|
+
}
|
|
15379
15539
|
});
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15385
|
-
|
|
15386
|
-
const
|
|
15387
|
-
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
const
|
|
15391
|
-
const
|
|
15392
|
-
|
|
15393
|
-
|
|
15394
|
-
|
|
15395
|
-
|
|
15396
|
-
|
|
15397
|
-
|
|
15398
|
-
|
|
15540
|
+
|
|
15541
|
+
// src/paths.ts
|
|
15542
|
+
import fs12 from "node:fs";
|
|
15543
|
+
import os6 from "node:os";
|
|
15544
|
+
import path39 from "node:path";
|
|
15545
|
+
function resolveAgentShimHome(env = process.env, home = os6.homedir(), isDirectory = isExistingDirectory) {
|
|
15546
|
+
const fromEnv = env.AGENT_SHIM_HOME;
|
|
15547
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15548
|
+
return fromEnv;
|
|
15549
|
+
}
|
|
15550
|
+
const current = path39.join(home, HOME_DIRNAME);
|
|
15551
|
+
const legacy = path39.join(home, LEGACY_HOME_DIRNAME);
|
|
15552
|
+
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
15553
|
+
}
|
|
15554
|
+
function isExistingDirectory(candidate) {
|
|
15555
|
+
return fs12.statSync(candidate, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
15556
|
+
}
|
|
15557
|
+
function resolveClaudeHome() {
|
|
15558
|
+
const fromEnv = process.env.AGENT_SHIM_CLAUDE_HOME;
|
|
15559
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15560
|
+
return fromEnv;
|
|
15561
|
+
}
|
|
15562
|
+
return path39.join(os6.homedir(), ".claude");
|
|
15563
|
+
}
|
|
15564
|
+
function buildLayoutPaths(root) {
|
|
15565
|
+
return {
|
|
15566
|
+
root,
|
|
15567
|
+
identitiesDir: path39.join(root, "identities"),
|
|
15568
|
+
configProfilesDir: path39.join(root, "config-profiles"),
|
|
15569
|
+
providersDir: path39.join(root, "providers"),
|
|
15570
|
+
providerAliasesFile: path39.join(root, "provider-aliases.json"),
|
|
15571
|
+
directoryRulesFile: path39.join(root, "directory-rules.json"),
|
|
15572
|
+
activeIdentityFile: path39.join(root, "active-identity"),
|
|
15573
|
+
globalConfigFile: path39.join(root, "config.json"),
|
|
15574
|
+
categoriesLocalFile: path39.join(root, "categories.local.json"),
|
|
15575
|
+
claudeShimFile: path39.join(root, "claude-shim.json"),
|
|
15576
|
+
headroomDir: path39.join(root, "headroom"),
|
|
15577
|
+
headroomStateFile: path39.join(root, "headroom", "state.json"),
|
|
15578
|
+
headroomRoutingFile: path39.join(root, "headroom", "routing.json"),
|
|
15579
|
+
headroomLegacyStateFile: path39.join(root, "headroom", "state.v2.json"),
|
|
15580
|
+
headroomAllowlistFile: path39.join(root, "headroom", "run", "allowlist.txt"),
|
|
15581
|
+
headroomSocketDir: path39.join(root, "headroom", "run"),
|
|
15582
|
+
headroomLockFile: path39.join(root, "headroom", "start.lock"),
|
|
15583
|
+
headroomSessionsDir: path39.join(root, "headroom", "sessions"),
|
|
15584
|
+
logsDir: path39.join(root, "logs"),
|
|
15585
|
+
headroomLogPath: path39.join(root, "logs", "headroom.log"),
|
|
15586
|
+
frontdoorDir: path39.join(root, "frontdoor"),
|
|
15587
|
+
frontdoorCaDir: path39.join(root, "frontdoor", "ca"),
|
|
15588
|
+
frontdoorCaCertFile: path39.join(root, "frontdoor", "ca", "ca.pem"),
|
|
15589
|
+
frontdoorCaKeyFile: path39.join(root, "frontdoor", "ca", "ca.key"),
|
|
15590
|
+
frontdoorCaBundlesDir: path39.join(root, "frontdoor", "ca", "bundles"),
|
|
15591
|
+
chatgptSignInFile: path39.join(root, "codex", "chatgpt-sign-in.json"),
|
|
15592
|
+
frontdoorStateFile: path39.join(root, "frontdoor", "state.json"),
|
|
15593
|
+
frontdoorLockFile: path39.join(root, "frontdoor", "start.lock"),
|
|
15594
|
+
frontdoorControlTokenFile: path39.join(root, "frontdoor", "control-token"),
|
|
15595
|
+
frontdoorSessionsDir: path39.join(root, "frontdoor", "sessions"),
|
|
15596
|
+
frontdoorDirectRecordsDir: path39.join(root, "frontdoor", "direct"),
|
|
15597
|
+
frontdoorDrainingDir: path39.join(root, "frontdoor", "draining"),
|
|
15598
|
+
frontdoorRcCredentialsDir: path39.join(root, "frontdoor", "rc-credentials"),
|
|
15599
|
+
frontdoorLogPath: path39.join(root, "logs", "frontdoor.log"),
|
|
15600
|
+
usageDir: path39.join(root, "usage"),
|
|
15601
|
+
usageLogDir: path39.join(root, "usage", "log"),
|
|
15602
|
+
usageSnapshotsDir: path39.join(root, "usage", "snapshots"),
|
|
15603
|
+
statuslineDir: path39.join(root, "statusline"),
|
|
15604
|
+
catalogueDir: path39.join(root, "catalogues"),
|
|
15605
|
+
usagePicksFile: path39.join(root, "usage", "picks.json"),
|
|
15606
|
+
usageAnchorsFile: path39.join(root, "usage", "anchors.json"),
|
|
15607
|
+
usageJobsFile: path39.join(root, "usage", "jobs.json"),
|
|
15608
|
+
jobLogsDir: path39.join(root, "logs", "jobs"),
|
|
15609
|
+
identityRenamesDir: path39.join(root, "identity-renames"),
|
|
15610
|
+
identityNameRenamesDir: path39.join(root, "identity-name-renames"),
|
|
15611
|
+
launchesDir: path39.join(root, "launches"),
|
|
15612
|
+
superviseDir: path39.join(root, "supervise"),
|
|
15613
|
+
modelMovesDir: path39.join(root, "model-moves"),
|
|
15614
|
+
mcpPermissionsFile: path39.join(root, "mcp", "permissions.json")
|
|
15615
|
+
};
|
|
15616
|
+
}
|
|
15617
|
+
function resolveLayoutPaths() {
|
|
15618
|
+
return buildLayoutPaths(resolveAgentShimHome());
|
|
15619
|
+
}
|
|
15620
|
+
var init_paths = __esm({
|
|
15621
|
+
"src/paths.ts"() {
|
|
15622
|
+
"use strict";
|
|
15623
|
+
init_legacy();
|
|
15624
|
+
}
|
|
15399
15625
|
});
|
|
15400
|
-
|
|
15401
|
-
|
|
15402
|
-
|
|
15403
|
-
|
|
15404
|
-
|
|
15405
|
-
|
|
15406
|
-
|
|
15407
|
-
|
|
15408
|
-
|
|
15409
|
-
|
|
15410
|
-
|
|
15411
|
-
|
|
15412
|
-
|
|
15413
|
-
|
|
15626
|
+
|
|
15627
|
+
// src/storedCatalogue.ts
|
|
15628
|
+
import path41 from "node:path";
|
|
15629
|
+
function catalogueReadFault(error) {
|
|
15630
|
+
if (error instanceof UnreadableCatalogueError) {
|
|
15631
|
+
return error.fault;
|
|
15632
|
+
}
|
|
15633
|
+
const code = error instanceof Error && "code" in error ? error.code : void 0;
|
|
15634
|
+
return typeof code === "string" && /^[A-Z0-9_]{1,32}$/u.test(code) ? code : error instanceof Error ? error.name : "an error";
|
|
15635
|
+
}
|
|
15636
|
+
function catalogueStatusFile(paths, owner, name) {
|
|
15637
|
+
return path41.join(path41.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), `${name}.status.json`);
|
|
15638
|
+
}
|
|
15639
|
+
function catalogueFailureFile(paths, owner, name) {
|
|
15640
|
+
return path41.join(path41.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), "failures", `${name}.json`);
|
|
15641
|
+
}
|
|
15642
|
+
var UnreadableCatalogueError, skipUnreadableCatalogue, TolerantReader, StoredCatalogue;
|
|
15643
|
+
var init_storedCatalogue = __esm({
|
|
15644
|
+
"src/storedCatalogue.ts"() {
|
|
15645
|
+
"use strict";
|
|
15646
|
+
init_providerCatalogue();
|
|
15647
|
+
UnreadableCatalogueError = class extends Error {
|
|
15648
|
+
fault;
|
|
15649
|
+
constructor(fault) {
|
|
15650
|
+
super(`stored catalogue cannot be read (${fault})`);
|
|
15651
|
+
this.name = "UnreadableCatalogueError";
|
|
15652
|
+
this.fault = fault;
|
|
15653
|
+
}
|
|
15654
|
+
};
|
|
15655
|
+
skipUnreadableCatalogue = () => void 0;
|
|
15656
|
+
TolerantReader = class {
|
|
15657
|
+
#read;
|
|
15658
|
+
#onUnreadable;
|
|
15659
|
+
constructor(read, onUnreadable) {
|
|
15660
|
+
this.#read = read;
|
|
15661
|
+
this.#onUnreadable = onUnreadable;
|
|
15662
|
+
}
|
|
15663
|
+
/** The text of `file`, `undefined` when it is absent or unreadable (`onUnreadable` returned). */
|
|
15664
|
+
read(file) {
|
|
15665
|
+
try {
|
|
15666
|
+
return this.#read(file);
|
|
15667
|
+
} catch (error) {
|
|
15668
|
+
this.#onUnreadable(catalogueReadFault(error));
|
|
15669
|
+
return void 0;
|
|
15414
15670
|
}
|
|
15415
|
-
|
|
15416
|
-
|
|
15417
|
-
|
|
15671
|
+
}
|
|
15672
|
+
/** `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. */
|
|
15673
|
+
attempt(take) {
|
|
15674
|
+
try {
|
|
15675
|
+
return take();
|
|
15676
|
+
} catch (error) {
|
|
15677
|
+
this.#onUnreadable(catalogueReadFault(error));
|
|
15678
|
+
return void 0;
|
|
15418
15679
|
}
|
|
15419
15680
|
}
|
|
15420
15681
|
};
|
|
15421
|
-
|
|
15682
|
+
StoredCatalogue = class {
|
|
15683
|
+
#paths;
|
|
15684
|
+
#reader;
|
|
15685
|
+
constructor(paths, reader) {
|
|
15686
|
+
this.#paths = paths;
|
|
15687
|
+
this.#reader = reader;
|
|
15688
|
+
}
|
|
15689
|
+
/** 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. */
|
|
15690
|
+
cacheText(name, owner) {
|
|
15691
|
+
return this.#reader.read(catalogueCachePath(this.#paths, name, owner?.pid, owner?.generation));
|
|
15692
|
+
}
|
|
15693
|
+
/** The file holding the digest of the settings an `http` provider's catalogue was fetched under. */
|
|
15694
|
+
digestText(name) {
|
|
15695
|
+
return this.#reader.read(catalogueSettingsPath(this.#paths, name));
|
|
15696
|
+
}
|
|
15697
|
+
/** The non-secret binding between a Codex catalogue and the login that fetched it. */
|
|
15698
|
+
bindingText(name, owner) {
|
|
15699
|
+
return this.#reader.read(catalogueBindingPath(this.#paths, name, owner?.pid, owner?.generation));
|
|
15700
|
+
}
|
|
15701
|
+
/** The refresh status the supervisor generation `owner` recorded for `name`. */
|
|
15702
|
+
statusText(owner, name) {
|
|
15703
|
+
return this.#reader.read(catalogueStatusFile(this.#paths, owner, name));
|
|
15704
|
+
}
|
|
15705
|
+
/** The record of why `name`'s last refresh failed in the supervisor generation `owner`. */
|
|
15706
|
+
failureText(owner, name) {
|
|
15707
|
+
return this.#reader.read(catalogueFailureFile(this.#paths, owner, name));
|
|
15708
|
+
}
|
|
15709
|
+
/** 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. */
|
|
15710
|
+
revision(name, revisionOf) {
|
|
15711
|
+
const cacheRevision = this.#reader.attempt(() => revisionOf(catalogueCachePath(this.#paths, name)));
|
|
15712
|
+
const digestRevision = this.#reader.attempt(() => revisionOf(catalogueSettingsPath(this.#paths, name)));
|
|
15713
|
+
return cacheRevision === void 0 || digestRevision === void 0 ? void 0 : `${cacheRevision}\0${digestRevision}`;
|
|
15714
|
+
}
|
|
15715
|
+
};
|
|
15422
15716
|
}
|
|
15423
15717
|
});
|
|
15424
15718
|
|
|
15425
|
-
// src/
|
|
15426
|
-
function
|
|
15427
|
-
return
|
|
15428
|
-
}
|
|
15429
|
-
function couldNotConnectMessage(subject, baseUrl, reason) {
|
|
15430
|
-
return `${subject} could not connect to ${displayBaseUrl(baseUrl)}: ${reason.trim() === "" ? "the connection failed with no reason given" : reason}`;
|
|
15431
|
-
}
|
|
15432
|
-
function probeProviderReachability(name, provider, probe) {
|
|
15433
|
-
const verdict = probe(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
15434
|
-
return verdict.ok ? { ok: true } : { ok: false, message: couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason) };
|
|
15719
|
+
// src/tolerantReaders.ts
|
|
15720
|
+
function skippingReader(fs17) {
|
|
15721
|
+
return new TolerantReader((file) => fs17.readFileUtf8(file), skipUnreadableCatalogue);
|
|
15435
15722
|
}
|
|
15436
|
-
|
|
15437
|
-
|
|
15723
|
+
var init_tolerantReaders = __esm({
|
|
15724
|
+
"src/tolerantReaders.ts"() {
|
|
15725
|
+
"use strict";
|
|
15726
|
+
init_storedCatalogue();
|
|
15727
|
+
}
|
|
15728
|
+
});
|
|
15729
|
+
|
|
15730
|
+
// src/frontdoor/catalogueState.ts
|
|
15731
|
+
import { z as z32 } from "zod";
|
|
15732
|
+
function readCatalogueFailure(fs17, paths, pid, generation, name) {
|
|
15733
|
+
const raw = new StoredCatalogue(paths, skippingReader(fs17)).failureText({ pid, generation }, name);
|
|
15734
|
+
if (raw === void 0) return void 0;
|
|
15735
|
+
try {
|
|
15736
|
+
const value = z32.strictObject({ reason: z32.string().max(CATALOGUE_FAILURE_REASON_MAX_CHARS), redirected: z32.literal(true).optional(), settings: z32.string().optional() }).safeParse(JSON.parse(raw));
|
|
15737
|
+
return value.success ? { reason: value.data.reason, redirected: value.data.redirected === true, settings: value.data.settings } : void 0;
|
|
15738
|
+
} catch {
|
|
15438
15739
|
return void 0;
|
|
15439
15740
|
}
|
|
15440
|
-
const started = start(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
15441
|
-
return {
|
|
15442
|
-
cancel: started.cancel,
|
|
15443
|
-
line: () => {
|
|
15444
|
-
const verdict = started.verdict();
|
|
15445
|
-
return verdict.ok ? void 0 : couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason);
|
|
15446
|
-
}
|
|
15447
|
-
};
|
|
15448
15741
|
}
|
|
15449
|
-
function
|
|
15450
|
-
const
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
if (!verdict.ok) {
|
|
15459
|
-
lines.set(entry.name, couldNotConnectMessage(`provider ${entry.name}`, entry.provider.baseUrl, verdict.reason));
|
|
15460
|
-
}
|
|
15461
|
-
});
|
|
15462
|
-
return lines;
|
|
15742
|
+
function readCatalogueStatus(fs17, paths, pid, generation, name) {
|
|
15743
|
+
const raw = new StoredCatalogue(paths, skippingReader(fs17)).statusText({ pid, generation }, name);
|
|
15744
|
+
if (raw === void 0) return void 0;
|
|
15745
|
+
try {
|
|
15746
|
+
const value = z32.strictObject({ status: z32.enum(["running", "ready", "failed"]), fingerprint: z32.string().min(1).optional(), recordedAt: z32.number().optional() }).safeParse(JSON.parse(raw));
|
|
15747
|
+
return value.success ? value.data : void 0;
|
|
15748
|
+
} catch {
|
|
15749
|
+
return void 0;
|
|
15750
|
+
}
|
|
15463
15751
|
}
|
|
15464
|
-
var
|
|
15465
|
-
var
|
|
15466
|
-
"src/
|
|
15752
|
+
var CATALOGUE_FAILURE_REASON_MAX_CHARS;
|
|
15753
|
+
var init_catalogueState = __esm({
|
|
15754
|
+
"src/frontdoor/catalogueState.ts"() {
|
|
15467
15755
|
"use strict";
|
|
15468
|
-
|
|
15469
|
-
|
|
15470
|
-
|
|
15471
|
-
init_probe();
|
|
15472
|
-
TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS = 1e3;
|
|
15473
|
-
CONNECT_SYN_RETRANSMISSIONS_TOLERATED = 2;
|
|
15474
|
-
DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS = TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS * (2 ** (CONNECT_SYN_RETRANSMISSIONS_TOLERATED + 1) - 1);
|
|
15475
|
-
startBaseUrlBatchProbe = (targets, workers) => {
|
|
15476
|
-
const started = startAddressProbes(targets.map((target) => ({ ...dialTargetOf(target.baseUrl), timeoutMs: target.timeoutMs })), workers);
|
|
15477
|
-
return { cancel: started.cancel, verdicts: started.settle };
|
|
15478
|
-
};
|
|
15479
|
-
realBaseUrlBatchProbe = (targets, workers) => startBaseUrlBatchProbe(targets, workers).verdicts();
|
|
15480
|
-
realStartBaseUrlProbe = (baseUrl, timeoutMs) => {
|
|
15481
|
-
const started = startBaseUrlBatchProbe([{ baseUrl, timeoutMs }]);
|
|
15482
|
-
return {
|
|
15483
|
-
cancel: started.cancel,
|
|
15484
|
-
verdict: () => {
|
|
15485
|
-
const [verdict] = started.verdicts();
|
|
15486
|
-
if (verdict === void 0) {
|
|
15487
|
-
throw new Error("the batch probe answered no verdict for one base URL");
|
|
15488
|
-
}
|
|
15489
|
-
return verdict;
|
|
15490
|
-
}
|
|
15491
|
-
};
|
|
15492
|
-
};
|
|
15493
|
-
realBaseUrlProbe = (baseUrl, timeoutMs) => realStartBaseUrlProbe(baseUrl, timeoutMs).verdict();
|
|
15756
|
+
init_storedCatalogue();
|
|
15757
|
+
init_tolerantReaders();
|
|
15758
|
+
CATALOGUE_FAILURE_REASON_MAX_CHARS = 600;
|
|
15494
15759
|
}
|
|
15495
15760
|
});
|
|
15496
15761
|
|
|
15497
15762
|
// src/codex/auth.ts
|
|
15498
|
-
import { z as
|
|
15763
|
+
import { z as z33 } from "zod";
|
|
15499
15764
|
var AuthFileSchema, TokenGrantSchema, CodexAuthError;
|
|
15500
15765
|
var init_auth = __esm({
|
|
15501
15766
|
"src/codex/auth.ts"() {
|
|
15502
15767
|
"use strict";
|
|
15503
|
-
AuthFileSchema =
|
|
15504
|
-
tokens:
|
|
15505
|
-
access_token:
|
|
15506
|
-
refresh_token:
|
|
15507
|
-
id_token:
|
|
15508
|
-
account_id:
|
|
15768
|
+
AuthFileSchema = z33.looseObject({
|
|
15769
|
+
tokens: z33.looseObject({
|
|
15770
|
+
access_token: z33.string().optional(),
|
|
15771
|
+
refresh_token: z33.string().optional(),
|
|
15772
|
+
id_token: z33.string().optional(),
|
|
15773
|
+
account_id: z33.string().optional()
|
|
15509
15774
|
}).nullish(),
|
|
15510
|
-
last_refresh:
|
|
15775
|
+
last_refresh: z33.string().optional()
|
|
15511
15776
|
});
|
|
15512
|
-
TokenGrantSchema =
|
|
15513
|
-
access_token:
|
|
15514
|
-
refresh_token:
|
|
15515
|
-
id_token:
|
|
15516
|
-
account_id:
|
|
15777
|
+
TokenGrantSchema = z33.looseObject({
|
|
15778
|
+
access_token: z33.string().min(1).optional(),
|
|
15779
|
+
refresh_token: z33.string().min(1).optional(),
|
|
15780
|
+
id_token: z33.string().min(1).optional(),
|
|
15781
|
+
account_id: z33.string().min(1).optional()
|
|
15517
15782
|
});
|
|
15518
15783
|
CodexAuthError = class extends Error {
|
|
15519
15784
|
constructor(message) {
|
|
@@ -15525,7 +15790,7 @@ var init_auth = __esm({
|
|
|
15525
15790
|
});
|
|
15526
15791
|
|
|
15527
15792
|
// src/codex/siwc.ts
|
|
15528
|
-
import { z as
|
|
15793
|
+
import { z as z34 } from "zod";
|
|
15529
15794
|
var SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
15530
15795
|
var init_siwc = __esm({
|
|
15531
15796
|
"src/codex/siwc.ts"() {
|
|
@@ -15533,28 +15798,28 @@ var init_siwc = __esm({
|
|
|
15533
15798
|
SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
15534
15799
|
SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
15535
15800
|
SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
15536
|
-
TokenResponseSchema =
|
|
15537
|
-
access_token:
|
|
15538
|
-
refresh_token:
|
|
15539
|
-
id_token:
|
|
15540
|
-
expires_in:
|
|
15541
|
-
scope:
|
|
15801
|
+
TokenResponseSchema = z34.looseObject({
|
|
15802
|
+
access_token: z34.string().min(1),
|
|
15803
|
+
refresh_token: z34.string().min(1).optional(),
|
|
15804
|
+
id_token: z34.string().min(1).optional(),
|
|
15805
|
+
expires_in: z34.number().positive(),
|
|
15806
|
+
scope: z34.string().optional()
|
|
15542
15807
|
});
|
|
15543
|
-
JwtHeaderSchema =
|
|
15544
|
-
IdTokenClaimsSchema =
|
|
15545
|
-
iss:
|
|
15546
|
-
sub:
|
|
15547
|
-
aud:
|
|
15548
|
-
exp:
|
|
15549
|
-
nonce:
|
|
15550
|
-
email:
|
|
15808
|
+
JwtHeaderSchema = z34.looseObject({ alg: z34.string(), kid: z34.string().optional() });
|
|
15809
|
+
IdTokenClaimsSchema = z34.looseObject({
|
|
15810
|
+
iss: z34.string(),
|
|
15811
|
+
sub: z34.string().min(1),
|
|
15812
|
+
aud: z34.union([z34.string(), z34.array(z34.string())]),
|
|
15813
|
+
exp: z34.number(),
|
|
15814
|
+
nonce: z34.string().optional(),
|
|
15815
|
+
email: z34.string().optional()
|
|
15551
15816
|
});
|
|
15552
|
-
JwksSchema =
|
|
15817
|
+
JwksSchema = z34.object({ keys: z34.array(z34.looseObject({ kid: z34.string().optional(), kty: z34.string() })) });
|
|
15553
15818
|
}
|
|
15554
15819
|
});
|
|
15555
15820
|
|
|
15556
15821
|
// src/codex/siwcStore.ts
|
|
15557
|
-
import { z as
|
|
15822
|
+
import { z as z35 } from "zod";
|
|
15558
15823
|
function parseSiwcFile(raw, filePath) {
|
|
15559
15824
|
let json;
|
|
15560
15825
|
try {
|
|
@@ -15574,18 +15839,18 @@ var init_siwcStore = __esm({
|
|
|
15574
15839
|
"use strict";
|
|
15575
15840
|
init_auth();
|
|
15576
15841
|
init_siwc();
|
|
15577
|
-
SiwcGrantSchema =
|
|
15578
|
-
clientId:
|
|
15579
|
-
sub:
|
|
15580
|
-
email:
|
|
15581
|
-
idToken:
|
|
15582
|
-
accessToken:
|
|
15583
|
-
refreshToken:
|
|
15584
|
-
scopes:
|
|
15842
|
+
SiwcGrantSchema = z35.strictObject({
|
|
15843
|
+
clientId: z35.string().min(1),
|
|
15844
|
+
sub: z35.string().min(1),
|
|
15845
|
+
email: z35.string().optional(),
|
|
15846
|
+
idToken: z35.string().min(1),
|
|
15847
|
+
accessToken: z35.string().min(1),
|
|
15848
|
+
refreshToken: z35.string().min(1),
|
|
15849
|
+
scopes: z35.array(z35.string()).readonly(),
|
|
15585
15850
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
15586
|
-
expiresAt:
|
|
15851
|
+
expiresAt: z35.number()
|
|
15587
15852
|
});
|
|
15588
|
-
SiwcFileSchema =
|
|
15853
|
+
SiwcFileSchema = z35.strictObject({ registeredClientId: z35.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
15589
15854
|
}
|
|
15590
15855
|
});
|
|
15591
15856
|
|
|
@@ -15643,9 +15908,9 @@ var init_modelsStore = __esm({
|
|
|
15643
15908
|
});
|
|
15644
15909
|
|
|
15645
15910
|
// src/codex/catalogueCredential.ts
|
|
15646
|
-
import { createHash as
|
|
15647
|
-
import
|
|
15648
|
-
import { z as
|
|
15911
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
15912
|
+
import path42 from "node:path";
|
|
15913
|
+
import { z as z36 } from "zod";
|
|
15649
15914
|
function parseCatalogueBinding(raw) {
|
|
15650
15915
|
if (raw === void 0) return void 0;
|
|
15651
15916
|
try {
|
|
@@ -15656,7 +15921,7 @@ function parseCatalogueBinding(raw) {
|
|
|
15656
15921
|
}
|
|
15657
15922
|
}
|
|
15658
15923
|
function catalogueCredentialFingerprint(cli, token, accountId) {
|
|
15659
|
-
return
|
|
15924
|
+
return createHash11("sha256").update(JSON.stringify([cli, token, accountId])).digest("hex");
|
|
15660
15925
|
}
|
|
15661
15926
|
function cliCatalogueFingerprint(raw) {
|
|
15662
15927
|
if (raw === void 0) return void 0;
|
|
@@ -15675,33 +15940,18 @@ function signInCatalogueFingerprint(raw, filePath) {
|
|
|
15675
15940
|
const grant = parseSiwcFile(raw, filePath).grant;
|
|
15676
15941
|
return grant === void 0 ? void 0 : catalogueCredentialFingerprint(false, grant.accessToken, void 0);
|
|
15677
15942
|
}
|
|
15678
|
-
function savedCatalogueFingerprint(provider, paths, env, home,
|
|
15679
|
-
if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(read(paths.chatgptSignInFile), paths.chatgptSignInFile);
|
|
15943
|
+
function savedCatalogueFingerprint(provider, paths, env, home, reader) {
|
|
15944
|
+
if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(reader.read(paths.chatgptSignInFile), paths.chatgptSignInFile);
|
|
15680
15945
|
const configuredHome = env.CODEX_HOME;
|
|
15681
|
-
const codexHome = configuredHome === void 0 || configuredHome === "" ?
|
|
15682
|
-
return cliCatalogueFingerprint(read(
|
|
15946
|
+
const codexHome = configuredHome === void 0 || configuredHome === "" ? path42.join(home, ".codex") : configuredHome;
|
|
15947
|
+
return cliCatalogueFingerprint(reader.read(path42.join(codexHome, "auth.json")));
|
|
15683
15948
|
}
|
|
15684
15949
|
var CatalogueBindingSchema;
|
|
15685
15950
|
var init_catalogueCredential = __esm({
|
|
15686
15951
|
"src/codex/catalogueCredential.ts"() {
|
|
15687
15952
|
"use strict";
|
|
15688
15953
|
init_siwcStore();
|
|
15689
|
-
CatalogueBindingSchema =
|
|
15690
|
-
}
|
|
15691
|
-
});
|
|
15692
|
-
|
|
15693
|
-
// src/models/tiers.ts
|
|
15694
|
-
var TIER_ENV_VARIABLES;
|
|
15695
|
-
var init_tiers = __esm({
|
|
15696
|
-
"src/models/tiers.ts"() {
|
|
15697
|
-
"use strict";
|
|
15698
|
-
init_schema();
|
|
15699
|
-
TIER_ENV_VARIABLES = Object.freeze({
|
|
15700
|
-
fable: "ANTHROPIC_DEFAULT_FABLE_MODEL",
|
|
15701
|
-
opus: "ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
15702
|
-
sonnet: "ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
15703
|
-
haiku: "ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
|
15704
|
-
});
|
|
15954
|
+
CatalogueBindingSchema = z36.strictObject({ fingerprint: z36.string().min(1), source: z36.string().min(1), revision: z36.string().min(1) });
|
|
15705
15955
|
}
|
|
15706
15956
|
});
|
|
15707
15957
|
|
|
@@ -15752,64 +16002,64 @@ var init_signatures = __esm({
|
|
|
15752
16002
|
});
|
|
15753
16003
|
|
|
15754
16004
|
// src/codex/anthropic.ts
|
|
15755
|
-
import { z as
|
|
16005
|
+
import { z as z37 } from "zod";
|
|
15756
16006
|
var TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
15757
16007
|
var init_anthropic = __esm({
|
|
15758
16008
|
"src/codex/anthropic.ts"() {
|
|
15759
16009
|
"use strict";
|
|
15760
|
-
TextBlockSchema =
|
|
15761
|
-
Base64ImageSourceSchema =
|
|
15762
|
-
UrlImageSourceSchema =
|
|
15763
|
-
ImageBlockSchema =
|
|
15764
|
-
type:
|
|
15765
|
-
source:
|
|
16010
|
+
TextBlockSchema = z37.looseObject({ type: z37.literal("text"), text: z37.string() });
|
|
16011
|
+
Base64ImageSourceSchema = z37.looseObject({ type: z37.literal("base64"), media_type: z37.string().min(1), data: z37.string() });
|
|
16012
|
+
UrlImageSourceSchema = z37.looseObject({ type: z37.literal("url"), url: z37.string().min(1) });
|
|
16013
|
+
ImageBlockSchema = z37.looseObject({
|
|
16014
|
+
type: z37.literal("image"),
|
|
16015
|
+
source: z37.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
15766
16016
|
});
|
|
15767
|
-
ToolUseBlockSchema =
|
|
15768
|
-
type:
|
|
15769
|
-
id:
|
|
15770
|
-
name:
|
|
15771
|
-
input:
|
|
16017
|
+
ToolUseBlockSchema = z37.looseObject({
|
|
16018
|
+
type: z37.literal("tool_use"),
|
|
16019
|
+
id: z37.string().min(1),
|
|
16020
|
+
name: z37.string().min(1),
|
|
16021
|
+
input: z37.unknown()
|
|
15772
16022
|
});
|
|
15773
|
-
ToolResultContentBlockSchema =
|
|
15774
|
-
ToolResultBlockSchema =
|
|
15775
|
-
type:
|
|
15776
|
-
tool_use_id:
|
|
15777
|
-
content:
|
|
16023
|
+
ToolResultContentBlockSchema = z37.union([TextBlockSchema, z37.looseObject({ type: z37.string() })]);
|
|
16024
|
+
ToolResultBlockSchema = z37.looseObject({
|
|
16025
|
+
type: z37.literal("tool_result"),
|
|
16026
|
+
tool_use_id: z37.string().min(1),
|
|
16027
|
+
content: z37.union([z37.string(), z37.array(ToolResultContentBlockSchema)]).optional()
|
|
15778
16028
|
});
|
|
15779
|
-
OtherBlockSchema =
|
|
15780
|
-
ContentBlockSchema =
|
|
15781
|
-
MessageSchema =
|
|
15782
|
-
role:
|
|
15783
|
-
content:
|
|
16029
|
+
OtherBlockSchema = z37.looseObject({ type: z37.string() });
|
|
16030
|
+
ContentBlockSchema = z37.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
16031
|
+
MessageSchema = z37.looseObject({
|
|
16032
|
+
role: z37.enum(["user", "assistant", "system"]),
|
|
16033
|
+
content: z37.union([z37.string(), z37.array(ContentBlockSchema)])
|
|
15784
16034
|
});
|
|
15785
|
-
ToolSchema =
|
|
15786
|
-
name:
|
|
15787
|
-
description:
|
|
15788
|
-
input_schema:
|
|
15789
|
-
allowed_domains:
|
|
15790
|
-
blocked_domains:
|
|
16035
|
+
ToolSchema = z37.looseObject({
|
|
16036
|
+
name: z37.string().min(1),
|
|
16037
|
+
description: z37.string().optional(),
|
|
16038
|
+
input_schema: z37.record(z37.string(), z37.unknown()).optional(),
|
|
16039
|
+
allowed_domains: z37.array(z37.string()).optional(),
|
|
16040
|
+
blocked_domains: z37.array(z37.string()).optional()
|
|
15791
16041
|
});
|
|
15792
|
-
ToolChoiceSchema =
|
|
15793
|
-
|
|
15794
|
-
|
|
16042
|
+
ToolChoiceSchema = z37.union([
|
|
16043
|
+
z37.looseObject({ type: z37.enum(["auto", "none", "any"]) }),
|
|
16044
|
+
z37.looseObject({ type: z37.literal("tool"), name: z37.string().min(1) })
|
|
15795
16045
|
]);
|
|
15796
|
-
SystemSchema =
|
|
15797
|
-
MessagesRequestSchema =
|
|
15798
|
-
model:
|
|
16046
|
+
SystemSchema = z37.union([z37.string(), z37.array(z37.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
16047
|
+
MessagesRequestSchema = z37.looseObject({
|
|
16048
|
+
model: z37.string().optional(),
|
|
15799
16049
|
system: SystemSchema.optional(),
|
|
15800
|
-
messages:
|
|
15801
|
-
tools:
|
|
16050
|
+
messages: z37.array(MessageSchema),
|
|
16051
|
+
tools: z37.array(ToolSchema).optional(),
|
|
15802
16052
|
tool_choice: ToolChoiceSchema.optional(),
|
|
15803
|
-
stream:
|
|
16053
|
+
stream: z37.boolean().optional(),
|
|
15804
16054
|
/** `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. */
|
|
15805
|
-
metadata:
|
|
16055
|
+
metadata: z37.looseObject({ user_id: z37.string().optional() }).optional(),
|
|
15806
16056
|
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
15807
|
-
output_config:
|
|
16057
|
+
output_config: z37.looseObject({ effort: z37.string().optional(), format: z37.object({ type: z37.literal("json_schema"), schema: z37.record(z37.string(), z37.unknown()) }).optional() }).optional()
|
|
15808
16058
|
});
|
|
15809
|
-
CountTokensRequestSchema =
|
|
15810
|
-
system:
|
|
15811
|
-
messages:
|
|
15812
|
-
tools:
|
|
16059
|
+
CountTokensRequestSchema = z37.looseObject({
|
|
16060
|
+
system: z37.unknown().optional(),
|
|
16061
|
+
messages: z37.unknown().optional(),
|
|
16062
|
+
tools: z37.unknown().optional()
|
|
15813
16063
|
});
|
|
15814
16064
|
}
|
|
15815
16065
|
});
|
|
@@ -15858,7 +16108,7 @@ var AUTO_ALIAS;
|
|
|
15858
16108
|
var init_translate = __esm({
|
|
15859
16109
|
"src/antigravity/translate.ts"() {
|
|
15860
16110
|
"use strict";
|
|
15861
|
-
|
|
16111
|
+
init_identity();
|
|
15862
16112
|
init_tiers();
|
|
15863
16113
|
init_engine();
|
|
15864
16114
|
init_quota();
|
|
@@ -16019,7 +16269,7 @@ var init_modelPicker = __esm({
|
|
|
16019
16269
|
init_translate2();
|
|
16020
16270
|
init_providerCatalogue();
|
|
16021
16271
|
init_schema();
|
|
16022
|
-
|
|
16272
|
+
init_identity();
|
|
16023
16273
|
init_families();
|
|
16024
16274
|
init_modelsStore();
|
|
16025
16275
|
init_tiers();
|
|
@@ -16040,13 +16290,17 @@ function providerModels(paths) {
|
|
|
16040
16290
|
const supervisorPid = recordedPid !== void 0 && realIsProcessAlive(recordedPid) ? recordedPid : void 0;
|
|
16041
16291
|
const doorRecord = supervisorPid === void 0 ? void 0 : readFrontDoorCodexRecord(realFarmFs, paths.frontdoorDir, supervisorPid);
|
|
16042
16292
|
const doorHome = doorRecord?.codexHome;
|
|
16293
|
+
const reader = new TolerantReader((file) => realFsPort.readFileUtf8(file), skipUnreadableCatalogue);
|
|
16294
|
+
const files = new StoredCatalogue(paths, reader);
|
|
16043
16295
|
return listProviders(paths).flatMap((entry) => {
|
|
16044
16296
|
if (entry.provider.kind === "codex" && supervisorPid !== void 0 && doorRecord === void 0) return [];
|
|
16045
|
-
const
|
|
16297
|
+
const owner = supervisorPid === void 0 || doorRecord === void 0 ? void 0 : { pid: supervisorPid, generation: doorRecord.generation };
|
|
16298
|
+
const stored = parseCatalogueCache(files.cacheText(entry.name, entry.provider.kind === "codex" ? owner : void 0));
|
|
16299
|
+
const catalogue = stored !== void 0 && isHttpProvider(entry.provider) && !catalogueMatchesSettings(parseCatalogueSettings(files.digestText(entry.name)), stored, entry.provider) ? void 0 : stored;
|
|
16046
16300
|
if (entry.provider.kind === "codex") {
|
|
16047
16301
|
if (catalogue !== void 0 && catalogue.supervisorPid !== supervisorPid) return [];
|
|
16048
16302
|
const env = doorHome === void 0 ? process.env : { ...process.env, CODEX_HOME: doorHome };
|
|
16049
|
-
const fingerprint = savedCatalogueFingerprint(entry.provider, paths, env, os8.homedir(),
|
|
16303
|
+
const fingerprint = savedCatalogueFingerprint(entry.provider, paths, env, os8.homedir(), reader);
|
|
16050
16304
|
if (fingerprint === void 0 || catalogue?.credentialFingerprint !== fingerprint) return [];
|
|
16051
16305
|
}
|
|
16052
16306
|
return providerModelRows(entry.provider, catalogue?.models).map((row) => ({ provider: entry.name, model: row.model }));
|
|
@@ -16061,7 +16315,9 @@ var init_targets = __esm({
|
|
|
16061
16315
|
init_catalogueCredential();
|
|
16062
16316
|
init_state();
|
|
16063
16317
|
init_modelPicker();
|
|
16318
|
+
init_schema();
|
|
16064
16319
|
init_providerCatalogue();
|
|
16320
|
+
init_storedCatalogue();
|
|
16065
16321
|
init_providersStore();
|
|
16066
16322
|
init_realPorts();
|
|
16067
16323
|
}
|
|
@@ -16704,7 +16960,7 @@ var init_settings2 = __esm({
|
|
|
16704
16960
|
});
|
|
16705
16961
|
|
|
16706
16962
|
// src/launcher/flags.ts
|
|
16707
|
-
import
|
|
16963
|
+
import path50 from "node:path";
|
|
16708
16964
|
function resolveLaunchFlags(params) {
|
|
16709
16965
|
const statusline = resolveStatuslineSettings(params);
|
|
16710
16966
|
return {
|
|
@@ -16763,7 +17019,7 @@ function buildEnv(params) {
|
|
|
16763
17019
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
16764
17020
|
let providerCustomHeaders;
|
|
16765
17021
|
if (!params.configDirEscapeHatch && params.identityId !== void 0) {
|
|
16766
|
-
env.CLAUDE_CONFIG_DIR =
|
|
17022
|
+
env.CLAUDE_CONFIG_DIR = path50.join(params.identitiesDir, params.identityId);
|
|
16767
17023
|
}
|
|
16768
17024
|
if (params.provider !== void 0) {
|
|
16769
17025
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
@@ -16879,7 +17135,7 @@ var init_extraFlags = __esm({
|
|
|
16879
17135
|
});
|
|
16880
17136
|
|
|
16881
17137
|
// src/usage/resumeContext.ts
|
|
16882
|
-
import
|
|
17138
|
+
import path51 from "node:path";
|
|
16883
17139
|
function projectDirNameOf(cwd) {
|
|
16884
17140
|
return cwd.replace(/[^A-Za-z0-9]/g, "-");
|
|
16885
17141
|
}
|
|
@@ -16937,7 +17193,7 @@ function newestTranscript(fs17, projectDir) {
|
|
|
16937
17193
|
if (!name.endsWith(".jsonl")) {
|
|
16938
17194
|
continue;
|
|
16939
17195
|
}
|
|
16940
|
-
const candidate =
|
|
17196
|
+
const candidate = path51.join(projectDir, name);
|
|
16941
17197
|
const stat = fs17.lstat(candidate);
|
|
16942
17198
|
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
16943
17199
|
newestMs = stat.mtimeMs;
|
|
@@ -16951,8 +17207,8 @@ function resumedContextTokens(fs17, params) {
|
|
|
16951
17207
|
if (target === void 0) {
|
|
16952
17208
|
return void 0;
|
|
16953
17209
|
}
|
|
16954
|
-
const projectDir =
|
|
16955
|
-
const file = target.kind === "id" ?
|
|
17210
|
+
const projectDir = path51.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
17211
|
+
const file = target.kind === "id" ? path51.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
|
|
16956
17212
|
const text = file === void 0 ? void 0 : fs17.readFileUtf8(file);
|
|
16957
17213
|
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
16958
17214
|
}
|
|
@@ -17455,7 +17711,7 @@ var RESUME_FLAGS, TERMINATOR3, REASONS_LOGGED;
|
|
|
17455
17711
|
var init_pool = __esm({
|
|
17456
17712
|
"src/launcher/pool.ts"() {
|
|
17457
17713
|
"use strict";
|
|
17458
|
-
|
|
17714
|
+
init_identity2();
|
|
17459
17715
|
init_preflight();
|
|
17460
17716
|
init_poolPick();
|
|
17461
17717
|
RESUME_FLAGS = /* @__PURE__ */ new Set(["--continue", "-c", "--resume", "-r"]);
|
|
@@ -17566,7 +17822,7 @@ var init_launchHook = __esm({
|
|
|
17566
17822
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17567
17823
|
import os10 from "node:os";
|
|
17568
17824
|
import { isDeepStrictEqual } from "node:util";
|
|
17569
|
-
import
|
|
17825
|
+
import path52 from "node:path";
|
|
17570
17826
|
function resolveIdentityCredential(identity, credential, env, port) {
|
|
17571
17827
|
if (port === void 0) {
|
|
17572
17828
|
return { ok: false, status: 1, message: `agent-shim: identity ${identity.name} needs its credential resolved, but this launcher has no credential port wired` };
|
|
@@ -17668,7 +17924,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17668
17924
|
const farmIdentity = configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : resolveIdentityId(paths.identitiesDir, identityDecision.name, fs17);
|
|
17669
17925
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
17670
17926
|
if (!readOnly && params.supervised?.member === void 0 && farmIdentity !== void 0 && identityDecision.name !== void 0) {
|
|
17671
|
-
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name,
|
|
17927
|
+
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name, path52.join(paths.identitiesDir, farmIdentity));
|
|
17672
17928
|
}
|
|
17673
17929
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
17674
17930
|
try {
|
|
@@ -17849,25 +18105,27 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17849
18105
|
const doorRecord = doorPid === void 0 ? void 0 : readFrontDoorCodexRecord(params.fs, paths.frontdoorDir, doorPid);
|
|
17850
18106
|
const doorHome = doorRecord?.codexHome;
|
|
17851
18107
|
const catalogueEnv = doorHome === void 0 ? env : { ...env, CODEX_HOME: doorHome };
|
|
18108
|
+
const reader = new TolerantReader((file) => params.fs.readFileUtf8(file), skipUnreadableCatalogue);
|
|
18109
|
+
const stored = new StoredCatalogue(paths, reader);
|
|
17852
18110
|
const listedProviders = listProviderNames(fs17.readdir, paths.providersDir).flatMap((name) => {
|
|
17853
18111
|
try {
|
|
17854
18112
|
const definition = loadProvider(paths.providersDir, name, fs17);
|
|
17855
18113
|
if (definition === void 0) return [];
|
|
17856
|
-
const
|
|
17857
|
-
const
|
|
17858
|
-
const cache = parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, name, catalogueOwner, generation)));
|
|
18114
|
+
const owner = definition.kind === "codex" && doorPid !== void 0 && doorRecord !== void 0 ? { pid: doorPid, generation: doorRecord.generation } : void 0;
|
|
18115
|
+
const cache = parseCatalogueCache(stored.cacheText(name, owner));
|
|
17859
18116
|
if (definition.kind === "codex" && cache !== void 0 && cache.supervisorPid !== doorPid) return [];
|
|
17860
18117
|
if (definition.kind === "codex" && doorPid !== void 0 && doorRecord === void 0) return [];
|
|
17861
18118
|
if (definition.kind === "codex" && readOnly && cache !== void 0) {
|
|
17862
|
-
const binding = parseCatalogueBinding(
|
|
18119
|
+
const binding = parseCatalogueBinding(stored.bindingText(name, owner));
|
|
17863
18120
|
const configuredHome = catalogueEnv.CODEX_HOME;
|
|
17864
|
-
const home = configuredHome === void 0 || configuredHome === "" ?
|
|
17865
|
-
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile :
|
|
18121
|
+
const home = configuredHome === void 0 || configuredHome === "" ? path52.join(os10.homedir(), ".codex") : configuredHome;
|
|
18122
|
+
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : path52.resolve(home, "auth.json");
|
|
17866
18123
|
const revision = params.fs.fileRevision?.(source);
|
|
17867
18124
|
if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
|
|
17868
18125
|
}
|
|
17869
|
-
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, os10.homedir(),
|
|
18126
|
+
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, os10.homedir(), reader) : void 0;
|
|
17870
18127
|
if (definition.kind === "codex" && !readOnly && cache !== void 0 && (fingerprint === void 0 || cache.credentialFingerprint !== fingerprint)) return [];
|
|
18128
|
+
if (isHttpProvider(definition) && cache !== void 0 && !catalogueMatchesSettings(parseCatalogueSettings(stored.digestText(name)), cache, definition)) return [[name, definition, []]];
|
|
17871
18129
|
return [[name, definition, cache?.models ?? []]];
|
|
17872
18130
|
} catch {
|
|
17873
18131
|
return [];
|
|
@@ -17883,7 +18141,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17883
18141
|
return { args: args2, pickerSuppressed: startsSession && pickerSettings !== void 0 && callerSettings };
|
|
17884
18142
|
};
|
|
17885
18143
|
const args = argsForSupervisor().args;
|
|
17886
|
-
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR :
|
|
18144
|
+
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : path52.join(paths.identitiesDir, farmIdentity);
|
|
17887
18145
|
const decision = {
|
|
17888
18146
|
identitySource: identityDecision.source,
|
|
17889
18147
|
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
@@ -17979,7 +18237,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
17979
18237
|
let warnings = [];
|
|
17980
18238
|
const updateCheck = runLaunchUpdateCheck({
|
|
17981
18239
|
mode: params.updateMode ?? "off",
|
|
17982
|
-
checkPath:
|
|
18240
|
+
checkPath: path52.join(paths.root, "update.check"),
|
|
17983
18241
|
currentVersion: package_default.version,
|
|
17984
18242
|
port: params.update
|
|
17985
18243
|
});
|
|
@@ -18002,7 +18260,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18002
18260
|
classification: resyncFarmRuntime.classification,
|
|
18003
18261
|
now: resyncFarmRuntime.now,
|
|
18004
18262
|
uniqueSuffix: resyncFarmRuntime.uniqueSuffix,
|
|
18005
|
-
identityExists: () => params.fs.readConfigFile(
|
|
18263
|
+
identityExists: () => params.fs.readConfigFile(path52.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
|
|
18006
18264
|
lock: resyncFarmRuntime.lock
|
|
18007
18265
|
});
|
|
18008
18266
|
} catch (error) {
|
|
@@ -18164,7 +18422,7 @@ var init_launcher = __esm({
|
|
|
18164
18422
|
init_guard();
|
|
18165
18423
|
init_identityRecords();
|
|
18166
18424
|
init_identityNameRenameRecord();
|
|
18167
|
-
|
|
18425
|
+
init_identity2();
|
|
18168
18426
|
init_flags();
|
|
18169
18427
|
init_extraFlags();
|
|
18170
18428
|
init_claudeSession();
|
|
@@ -18175,6 +18433,7 @@ var init_launcher = __esm({
|
|
|
18175
18433
|
init_modelPicker();
|
|
18176
18434
|
init_state();
|
|
18177
18435
|
init_providerCatalogue();
|
|
18436
|
+
init_storedCatalogue();
|
|
18178
18437
|
init_providersStore();
|
|
18179
18438
|
init_memberProvider();
|
|
18180
18439
|
init_pool();
|
|
@@ -18202,12 +18461,12 @@ var init_launcher = __esm({
|
|
|
18202
18461
|
});
|
|
18203
18462
|
|
|
18204
18463
|
// src/ownCli.ts
|
|
18205
|
-
import
|
|
18464
|
+
import path53 from "node:path";
|
|
18206
18465
|
function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string" ? __AGENT_SHIM_DIST_DIR__ : void 0) {
|
|
18207
18466
|
if (distDir === void 0) {
|
|
18208
18467
|
throw new OwnCliPathUnknownError();
|
|
18209
18468
|
}
|
|
18210
|
-
return
|
|
18469
|
+
return path53.join(distDir, OWN_CLI_FILE_NAME);
|
|
18211
18470
|
}
|
|
18212
18471
|
var OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
18213
18472
|
var init_ownCli = __esm({
|
|
@@ -18252,11 +18511,11 @@ var init_selfIdentity = __esm({
|
|
|
18252
18511
|
});
|
|
18253
18512
|
|
|
18254
18513
|
// src/frontdoor/trust.ts
|
|
18255
|
-
import { createHash as
|
|
18256
|
-
import
|
|
18514
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
18515
|
+
import path54 from "node:path";
|
|
18257
18516
|
function resolveTrustBundle(params) {
|
|
18258
18517
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs17 } = params;
|
|
18259
|
-
if (inherited === void 0 || inherited === "" ||
|
|
18518
|
+
if (inherited === void 0 || inherited === "" || path54.resolve(inherited) === path54.resolve(caCertFile)) {
|
|
18260
18519
|
return { path: caCertFile };
|
|
18261
18520
|
}
|
|
18262
18521
|
const caPem = fs17.readFileUtf8(caCertFile);
|
|
@@ -18274,7 +18533,7 @@ function resolveTrustBundle(params) {
|
|
|
18274
18533
|
}
|
|
18275
18534
|
const combined = `${inheritedPem.trimEnd()}
|
|
18276
18535
|
${caPem}`;
|
|
18277
|
-
const bundle =
|
|
18536
|
+
const bundle = path54.join(bundlesDir, `${createHash12("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
18278
18537
|
if (!fs17.exists(bundle)) {
|
|
18279
18538
|
fs17.mkdirp(bundlesDir);
|
|
18280
18539
|
fs17.writeFileAtomic(bundle, combined);
|
|
@@ -18335,35 +18594,49 @@ function realFrontDoorPort(paths, spawnDaemon) {
|
|
|
18335
18594
|
return {
|
|
18336
18595
|
waitForCatalogues: (supervisorPid) => {
|
|
18337
18596
|
const timedOut = deadlineAfter(CATALOGUE_REFRESH_DEADLINE_MS);
|
|
18597
|
+
const stored = new StoredCatalogue(paths, new TolerantReader((file) => realFarmFs.readFileUtf8(file), skipUnreadableCatalogue));
|
|
18338
18598
|
let requested = false;
|
|
18339
18599
|
const warnings = /* @__PURE__ */ new Set();
|
|
18340
18600
|
while (!isDeclaredFrontDoor(supervisorPid) && listProviders(paths).map(({ name, provider }) => {
|
|
18341
18601
|
const owner = readFrontDoorCodexRecord(realFarmFs, paths.frontdoorDir, supervisorPid);
|
|
18342
18602
|
const published = owner === void 0 ? void 0 : readCatalogueStatus(realFarmFs, paths, supervisorPid, owner.generation, name);
|
|
18343
|
-
|
|
18603
|
+
const failedUnderCurrentSettings = () => {
|
|
18604
|
+
if (!isHttpProvider(provider) || owner === void 0) return true;
|
|
18605
|
+
if (provider.catalogue === void 0) return false;
|
|
18606
|
+
const recorded = readCatalogueFailure(realFarmFs, paths, supervisorPid, owner.generation, name)?.settings;
|
|
18607
|
+
return recorded === void 0 || recorded === catalogueSettingsFingerprint(provider);
|
|
18608
|
+
};
|
|
18609
|
+
if (provider.kind !== "codex" && published?.status === "failed" && published.recordedAt !== void 0 && within(published.recordedAt, Date.now(), CATALOGUE_RETRY_MS) && failedUnderCurrentSettings()) {
|
|
18344
18610
|
warnings.add(`Catalogue refresh failed for ${name}`);
|
|
18345
18611
|
return false;
|
|
18346
18612
|
}
|
|
18347
18613
|
if (provider.kind === "codex") {
|
|
18348
18614
|
if (owner === void 0) return true;
|
|
18349
|
-
const cache2 = parseCatalogueCache(
|
|
18615
|
+
const cache2 = parseCatalogueCache(stored.cacheText(name, { pid: supervisorPid, generation: owner.generation }));
|
|
18350
18616
|
let fingerprint;
|
|
18617
|
+
let loginFault;
|
|
18351
18618
|
try {
|
|
18352
|
-
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, os11.homedir(), realFarmFs.readFileUtf8)
|
|
18619
|
+
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, os11.homedir(), new TolerantReader((file) => realFarmFs.readFileUtf8(file), (fault) => {
|
|
18620
|
+
loginFault = fault;
|
|
18621
|
+
}));
|
|
18353
18622
|
} catch (error) {
|
|
18354
18623
|
warnings.add(`Cannot read catalogue credentials for ${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
18355
18624
|
return false;
|
|
18356
18625
|
}
|
|
18626
|
+
if (loginFault !== void 0) {
|
|
18627
|
+
warnings.add(`Cannot read the catalogue credentials for ${name} (${loginFault})`);
|
|
18628
|
+
return false;
|
|
18629
|
+
}
|
|
18357
18630
|
const outcome = readCatalogueStatus(realFarmFs, paths, supervisorPid, owner.generation, name);
|
|
18358
|
-
if (outcome?.status === "failed" && outcome.fingerprint === fingerprint && outcome.recordedAt !== void 0 && outcome.recordedAt
|
|
18631
|
+
if (outcome?.status === "failed" && outcome.fingerprint === fingerprint && outcome.recordedAt !== void 0 && within(outcome.recordedAt, Date.now(), CATALOGUE_RETRY_MS)) {
|
|
18359
18632
|
warnings.add(`Catalogue refresh failed for ${name}`);
|
|
18360
18633
|
return false;
|
|
18361
18634
|
}
|
|
18362
18635
|
return cache2 === void 0 || isCatalogueStale(cache2, Date.now()) || cache2.supervisorPid !== supervisorPid || fingerprint === void 0 || cache2.credentialFingerprint !== fingerprint;
|
|
18363
18636
|
}
|
|
18364
18637
|
if (provider.kind !== void 0 && provider.kind !== "http" || provider.catalogue === void 0) return false;
|
|
18365
|
-
const cache = parseCatalogueCache(
|
|
18366
|
-
return cache === void 0 || isCatalogueStale(cache, Date.now());
|
|
18638
|
+
const cache = parseCatalogueCache(stored.cacheText(name));
|
|
18639
|
+
return cache === void 0 || isCatalogueStale(cache, Date.now()) || !catalogueMatchesSettings(parseCatalogueSettings(stored.digestText(name)), cache, provider);
|
|
18367
18640
|
}).some(Boolean)) {
|
|
18368
18641
|
if (timedOut()) return [...warnings, "Timed out waiting for provider catalogues"].join("; ");
|
|
18369
18642
|
if (!requested) {
|
|
@@ -18404,12 +18677,16 @@ var init_realFrontDoorPort = __esm({
|
|
|
18404
18677
|
"src/frontdoor/realFrontDoorPort.ts"() {
|
|
18405
18678
|
"use strict";
|
|
18406
18679
|
init_providersStore();
|
|
18680
|
+
init_schema();
|
|
18407
18681
|
init_providerCatalogue();
|
|
18682
|
+
init_storedCatalogue();
|
|
18683
|
+
init_elapsedWindow();
|
|
18408
18684
|
init_catalogueCredential();
|
|
18409
18685
|
init_realPorts();
|
|
18410
18686
|
init_doorLog();
|
|
18411
18687
|
init_ensure2();
|
|
18412
18688
|
init_state();
|
|
18689
|
+
init_catalogueState();
|
|
18413
18690
|
init_probe();
|
|
18414
18691
|
init_selfIdentity();
|
|
18415
18692
|
init_trust();
|
|
@@ -18429,7 +18706,7 @@ var init_realFrontDoorPort = __esm({
|
|
|
18429
18706
|
|
|
18430
18707
|
// src/launchWiring.ts
|
|
18431
18708
|
import os12 from "node:os";
|
|
18432
|
-
import
|
|
18709
|
+
import path55 from "node:path";
|
|
18433
18710
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
18434
18711
|
function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
18435
18712
|
const home = os12.homedir();
|
|
@@ -18485,8 +18762,8 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
18485
18762
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
18486
18763
|
startBaseUrlProbe: realStartBaseUrlProbe,
|
|
18487
18764
|
hold: realHoldPort,
|
|
18488
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot:
|
|
18489
|
-
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin,
|
|
18765
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: path55.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
18766
|
+
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, path55.join(paths.identitiesDir, identity), options.proc.env),
|
|
18490
18767
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
18491
18768
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
18492
18769
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -18708,7 +18985,7 @@ var init_anthropicUsageRefresh = __esm({
|
|
|
18708
18985
|
"src/usage/anthropicUsageRefresh.ts"() {
|
|
18709
18986
|
"use strict";
|
|
18710
18987
|
init_schema();
|
|
18711
|
-
|
|
18988
|
+
init_identity2();
|
|
18712
18989
|
init_middleware();
|
|
18713
18990
|
init_windowLengths();
|
|
18714
18991
|
init_plan2();
|
|
@@ -18779,7 +19056,7 @@ var init_identityClaude = __esm({
|
|
|
18779
19056
|
});
|
|
18780
19057
|
|
|
18781
19058
|
// src/usage/providerQuota.ts
|
|
18782
|
-
import { z as
|
|
19059
|
+
import { z as z48 } from "zod";
|
|
18783
19060
|
var 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;
|
|
18784
19061
|
var init_providerQuota = __esm({
|
|
18785
19062
|
"src/usage/providerQuota.ts"() {
|
|
@@ -18798,35 +19075,35 @@ var init_providerQuota = __esm({
|
|
|
18798
19075
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
|
|
18799
19076
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
|
|
18800
19077
|
]);
|
|
18801
|
-
ZaiLimitSchema =
|
|
18802
|
-
type:
|
|
18803
|
-
unit:
|
|
18804
|
-
number:
|
|
18805
|
-
percentage:
|
|
18806
|
-
nextResetTime:
|
|
18807
|
-
usage:
|
|
18808
|
-
currentValue:
|
|
18809
|
-
remaining:
|
|
19078
|
+
ZaiLimitSchema = z48.object({
|
|
19079
|
+
type: z48.string(),
|
|
19080
|
+
unit: z48.number().int(),
|
|
19081
|
+
number: z48.number().int().positive(),
|
|
19082
|
+
percentage: z48.number().nonnegative(),
|
|
19083
|
+
nextResetTime: z48.number().positive().optional(),
|
|
19084
|
+
usage: z48.number().nonnegative().optional(),
|
|
19085
|
+
currentValue: z48.number().nonnegative().optional(),
|
|
19086
|
+
remaining: z48.number().nonnegative().optional()
|
|
18810
19087
|
});
|
|
18811
|
-
ZaiResponseSchema =
|
|
18812
|
-
success:
|
|
18813
|
-
msg:
|
|
18814
|
-
data:
|
|
19088
|
+
ZaiResponseSchema = z48.object({
|
|
19089
|
+
success: z48.boolean(),
|
|
19090
|
+
msg: z48.string().optional(),
|
|
19091
|
+
data: z48.object({ level: z48.string().optional(), limits: z48.array(ZaiLimitSchema) })
|
|
18815
19092
|
});
|
|
18816
19093
|
OPENROUTER_HOST = "openrouter.ai";
|
|
18817
19094
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
18818
19095
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
18819
19096
|
MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
18820
|
-
OpenRouterKeySchema =
|
|
18821
|
-
data:
|
|
18822
|
-
limit:
|
|
18823
|
-
limit_remaining:
|
|
18824
|
-
limit_reset:
|
|
18825
|
-
is_free_tier:
|
|
18826
|
-
free_model_daily_requests:
|
|
19097
|
+
OpenRouterKeySchema = z48.object({
|
|
19098
|
+
data: z48.object({
|
|
19099
|
+
limit: z48.number().nonnegative().nullable(),
|
|
19100
|
+
limit_remaining: z48.number().nullable(),
|
|
19101
|
+
limit_reset: z48.string().nullable(),
|
|
19102
|
+
is_free_tier: z48.boolean().optional(),
|
|
19103
|
+
free_model_daily_requests: z48.object({ used: z48.number().nonnegative(), limit: z48.number().nonnegative(), remaining: z48.number() }).optional()
|
|
18827
19104
|
})
|
|
18828
19105
|
});
|
|
18829
|
-
OpenRouterCreditsSchema =
|
|
19106
|
+
OpenRouterCreditsSchema = z48.object({ data: z48.object({ total_credits: z48.number().nonnegative(), total_usage: z48.number().nonnegative() }) });
|
|
18830
19107
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
18831
19108
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
18832
19109
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
@@ -18834,21 +19111,21 @@ var init_providerQuota = __esm({
|
|
|
18834
19111
|
DAYS_PER_WEEK2 = 7;
|
|
18835
19112
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
18836
19113
|
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
18837
|
-
AntigravityBucketSchema =
|
|
18838
|
-
bucketId:
|
|
18839
|
-
remainingFraction:
|
|
18840
|
-
resetTime:
|
|
19114
|
+
AntigravityBucketSchema = z48.object({
|
|
19115
|
+
bucketId: z48.string(),
|
|
19116
|
+
remainingFraction: z48.number().optional(),
|
|
19117
|
+
resetTime: z48.string().optional()
|
|
18841
19118
|
});
|
|
18842
|
-
AntigravitySummarySchema =
|
|
18843
|
-
GoogleTokenInfoSchema =
|
|
18844
|
-
email:
|
|
18845
|
-
sub:
|
|
19119
|
+
AntigravitySummarySchema = z48.object({ groups: z48.array(z48.object({ buckets: z48.array(AntigravityBucketSchema) })) });
|
|
19120
|
+
GoogleTokenInfoSchema = z48.object({
|
|
19121
|
+
email: z48.string().optional(),
|
|
19122
|
+
sub: z48.string().optional()
|
|
18846
19123
|
});
|
|
18847
|
-
AntigravityUserSchema =
|
|
19124
|
+
AntigravityUserSchema = z48.object({
|
|
18848
19125
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
18849
|
-
currentTier:
|
|
19126
|
+
currentTier: z48.object({ name: z48.string().optional(), id: z48.string().optional() }).optional(),
|
|
18850
19127
|
/** The account's paid subscription; absent when the account has none. */
|
|
18851
|
-
paidTier:
|
|
19128
|
+
paidTier: z48.object({ name: z48.string().optional(), id: z48.string().optional() }).optional()
|
|
18852
19129
|
});
|
|
18853
19130
|
}
|
|
18854
19131
|
});
|
|
@@ -19672,7 +19949,7 @@ function createRcApiRouter(deps) {
|
|
|
19672
19949
|
const dropped = statuses.flatMap((status) => status.pendingDropped === void 0 ? [] : [{ sessionId: status.id, count: status.pendingDropped }]);
|
|
19673
19950
|
return { pending, ...dropped.length === 0 ? {} : { dropped } };
|
|
19674
19951
|
}),
|
|
19675
|
-
send: authed.meta(openapi({ method: "POST", path: "/rest/rc/send", summary: "Send one message into a session", tags: [RC_API_TAG] })).input(RcSendInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.inject(input.session, input.text)) })),
|
|
19952
|
+
send: authed.meta(openapi({ method: "POST", path: "/rest/rc/send", summary: "Send one message into a session", description: RC_SEND_DELIVERY_NOTE, tags: [RC_API_TAG] })).input(RcSendInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.inject(input.session, input.text)) })),
|
|
19676
19953
|
answer: authed.meta(openapi({ method: "POST", path: "/rest/rc/answer", summary: "Answer one pending control request: approve or deny it, or choose the options of a pending question", tags: [RC_API_TAG] })).input(RcAnswerInputSchema).output(RcAnswerOutputSchema).handler(async ({ input }) => {
|
|
19677
19954
|
const decision = { approve: input.approve, message: input.approve || input.text === void 0 ? void 0 : input.text, ...input.choices === void 0 ? {} : { choices: input.choices } };
|
|
19678
19955
|
return { session: input.session, request: input.request, sequenceNums: delivered(input.session, await deps.answer(input.session, input.request, decision)) };
|
|
@@ -20067,7 +20344,7 @@ import { openapi as openapi9 } from "@orpc/openapi";
|
|
|
20067
20344
|
// src/checkReportSchema.ts
|
|
20068
20345
|
init_schema();
|
|
20069
20346
|
init_claudeVersion();
|
|
20070
|
-
|
|
20347
|
+
init_identity2();
|
|
20071
20348
|
init_projects();
|
|
20072
20349
|
import { z as z27 } from "zod";
|
|
20073
20350
|
|
|
@@ -20284,8 +20561,8 @@ var ResetRowSchema = z28.strictObject({
|
|
|
20284
20561
|
var ResetScheduleSchema = z28.strictObject({ resets: z28.readonly(z28.array(ResetRowSchema)) });
|
|
20285
20562
|
|
|
20286
20563
|
// src/frontdoor/controlSchemas.ts
|
|
20287
|
-
import
|
|
20288
|
-
import { z as
|
|
20564
|
+
import path44 from "node:path";
|
|
20565
|
+
import { z as z38 } from "zod";
|
|
20289
20566
|
|
|
20290
20567
|
// src/codex/doctor.ts
|
|
20291
20568
|
function codexIdentityFindings(entry, identity) {
|
|
@@ -20370,7 +20647,56 @@ function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
|
|
|
20370
20647
|
}
|
|
20371
20648
|
|
|
20372
20649
|
// src/doctorReport.ts
|
|
20373
|
-
|
|
20650
|
+
init_signIn();
|
|
20651
|
+
init_identityAccounts();
|
|
20652
|
+
init_read();
|
|
20653
|
+
init_providerReachability();
|
|
20654
|
+
import path43 from "node:path";
|
|
20655
|
+
|
|
20656
|
+
// src/doctorNameFinding.ts
|
|
20657
|
+
init_names();
|
|
20658
|
+
init_reservedModelNames();
|
|
20659
|
+
function pushNameFinding(push, section, kind, entry) {
|
|
20660
|
+
if (section === "provider") {
|
|
20661
|
+
pushReservedProviderNameFinding(push, entry);
|
|
20662
|
+
}
|
|
20663
|
+
if (isFileName(entry.name)) {
|
|
20664
|
+
return true;
|
|
20665
|
+
}
|
|
20666
|
+
if (!isStoredName(entry.name)) {
|
|
20667
|
+
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);
|
|
20668
|
+
return false;
|
|
20669
|
+
}
|
|
20670
|
+
push(
|
|
20671
|
+
section,
|
|
20672
|
+
"warn",
|
|
20673
|
+
`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.`,
|
|
20674
|
+
entry.name
|
|
20675
|
+
);
|
|
20676
|
+
return true;
|
|
20677
|
+
}
|
|
20678
|
+
function pushReservedProviderNameFinding(push, entry) {
|
|
20679
|
+
const reason = reservedProviderNameReason(entry.name);
|
|
20680
|
+
if (reason !== void 0) {
|
|
20681
|
+
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);
|
|
20682
|
+
}
|
|
20683
|
+
}
|
|
20684
|
+
|
|
20685
|
+
// src/doctorCatalogueRedirect.ts
|
|
20686
|
+
init_schema();
|
|
20687
|
+
init_providerCatalogue();
|
|
20688
|
+
init_providersStore();
|
|
20689
|
+
function pushCatalogueRedirectFinding(push, providerName, reason) {
|
|
20690
|
+
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);
|
|
20691
|
+
}
|
|
20692
|
+
function currentCatalogueSettings(paths, name) {
|
|
20693
|
+
try {
|
|
20694
|
+
const provider = readProvider(paths, name);
|
|
20695
|
+
return provider === void 0 || !isHttpProvider(provider) || provider.catalogue === void 0 ? void 0 : catalogueSettingsFingerprint(provider);
|
|
20696
|
+
} catch {
|
|
20697
|
+
return void 0;
|
|
20698
|
+
}
|
|
20699
|
+
}
|
|
20374
20700
|
|
|
20375
20701
|
// src/checkReport.ts
|
|
20376
20702
|
init_cliError();
|
|
@@ -20405,11 +20731,11 @@ init_load();
|
|
|
20405
20731
|
// src/launchSelection.ts
|
|
20406
20732
|
init_load();
|
|
20407
20733
|
init_cascade();
|
|
20408
|
-
|
|
20734
|
+
init_identity2();
|
|
20409
20735
|
import os5 from "node:os";
|
|
20410
20736
|
|
|
20411
20737
|
// src/poolPickReport.ts
|
|
20412
|
-
|
|
20738
|
+
init_identity2();
|
|
20413
20739
|
init_poolPick();
|
|
20414
20740
|
function candidateView(candidate) {
|
|
20415
20741
|
return {
|
|
@@ -20930,29 +21256,39 @@ function collectCheckReport(params) {
|
|
|
20930
21256
|
return report;
|
|
20931
21257
|
}
|
|
20932
21258
|
|
|
20933
|
-
// src/
|
|
20934
|
-
|
|
20935
|
-
|
|
20936
|
-
|
|
20937
|
-
|
|
20938
|
-
|
|
20939
|
-
// src/doctorNameFinding.ts
|
|
20940
|
-
init_names();
|
|
20941
|
-
function pushNameFinding(push, section, kind, entry) {
|
|
20942
|
-
if (isFileName(entry.name)) {
|
|
20943
|
-
return true;
|
|
21259
|
+
// src/doctorKeychain.ts
|
|
21260
|
+
function pushKeychainFindings(push, platform, run, identities, agentOf) {
|
|
21261
|
+
if (platform !== "darwin" || run === void 0) {
|
|
21262
|
+
push("keychain", "pass", "Skipped (not macOS).");
|
|
21263
|
+
return;
|
|
20944
21264
|
}
|
|
20945
|
-
|
|
20946
|
-
|
|
20947
|
-
|
|
21265
|
+
for (const entry of identities) {
|
|
21266
|
+
if (agentOf.get(entry.name) === "codex") continue;
|
|
21267
|
+
const result = lookupKeychainService(run, entry.farmRoot);
|
|
21268
|
+
push("keychain", "pass", result.found ? result.note : `${result.note} The sign-in section reports whether a login is stored elsewhere.`, entry.name);
|
|
20948
21269
|
}
|
|
20949
|
-
|
|
20950
|
-
|
|
20951
|
-
|
|
20952
|
-
|
|
20953
|
-
|
|
20954
|
-
|
|
20955
|
-
|
|
21270
|
+
}
|
|
21271
|
+
|
|
21272
|
+
// src/frontdoor/catalogueFailures.ts
|
|
21273
|
+
init_state();
|
|
21274
|
+
init_catalogueState();
|
|
21275
|
+
function providersWithRedirectedCatalogue(fs17, paths, settingsOf2) {
|
|
21276
|
+
const supervisorPid = readFrontDoorState(fs17, paths.frontdoorStateFile)?.supervisorPid;
|
|
21277
|
+
const generation = supervisorPid === void 0 ? void 0 : readFrontDoorCodexRecord(fs17, paths.frontdoorDir, supervisorPid)?.generation;
|
|
21278
|
+
if (supervisorPid === void 0 || generation === void 0) {
|
|
21279
|
+
return /* @__PURE__ */ new Map();
|
|
21280
|
+
}
|
|
21281
|
+
const found = /* @__PURE__ */ new Map();
|
|
21282
|
+
for (const [name, settings] of settingsOf2) {
|
|
21283
|
+
if (readCatalogueStatus(fs17, paths, supervisorPid, generation, name)?.status !== "failed") {
|
|
21284
|
+
continue;
|
|
21285
|
+
}
|
|
21286
|
+
const failure = readCatalogueFailure(fs17, paths, supervisorPid, generation, name);
|
|
21287
|
+
if (settings !== void 0 && failure?.redirected === true && failure.settings === settings) {
|
|
21288
|
+
found.set(name, failure.reason);
|
|
21289
|
+
}
|
|
21290
|
+
}
|
|
21291
|
+
return found;
|
|
20956
21292
|
}
|
|
20957
21293
|
|
|
20958
21294
|
// src/doctorReport.ts
|
|
@@ -20969,7 +21305,7 @@ init_source();
|
|
|
20969
21305
|
// src/models/doctor.ts
|
|
20970
21306
|
init_modelsStore();
|
|
20971
21307
|
init_families();
|
|
20972
|
-
|
|
21308
|
+
init_identity();
|
|
20973
21309
|
function modelsFindings(input) {
|
|
20974
21310
|
const findings = [];
|
|
20975
21311
|
const { models } = input;
|
|
@@ -21232,12 +21568,12 @@ init_identityRenameJournal();
|
|
|
21232
21568
|
init_providerAliases();
|
|
21233
21569
|
init_providersStore();
|
|
21234
21570
|
init_guard();
|
|
21235
|
-
|
|
21571
|
+
init_identity2();
|
|
21236
21572
|
init_poolStore();
|
|
21237
21573
|
|
|
21238
21574
|
// src/poolSharedLogins.ts
|
|
21239
21575
|
init_identityAccounts();
|
|
21240
|
-
|
|
21576
|
+
init_identity2();
|
|
21241
21577
|
function sharedLoginMembers(members, accountOf) {
|
|
21242
21578
|
const known = members.flatMap((identity) => {
|
|
21243
21579
|
const account = poolNameOf(identity) === void 0 ? accountOf(identity) : void 0;
|
|
@@ -21256,7 +21592,7 @@ function describeSharedLoginMembers(poolName, shared) {
|
|
|
21256
21592
|
|
|
21257
21593
|
// src/poolWindowReads.ts
|
|
21258
21594
|
init_schema();
|
|
21259
|
-
|
|
21595
|
+
init_identity2();
|
|
21260
21596
|
init_conditions();
|
|
21261
21597
|
init_middleware();
|
|
21262
21598
|
init_rateLimit();
|
|
@@ -21387,7 +21723,7 @@ function tcpPortEraRecord(raw) {
|
|
|
21387
21723
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
21388
21724
|
}
|
|
21389
21725
|
function pushPathResolution(push, resolution) {
|
|
21390
|
-
const ownDir =
|
|
21726
|
+
const ownDir = path43.dirname(resolution.ownExecutablePath);
|
|
21391
21727
|
switch (resolution.agentShim.status) {
|
|
21392
21728
|
case "ok":
|
|
21393
21729
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -21507,14 +21843,14 @@ function pushProvider(push, entry, cacheEnv, signIn, unreachable) {
|
|
|
21507
21843
|
}
|
|
21508
21844
|
function pushLegacyName(push, params) {
|
|
21509
21845
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
21510
|
-
if (legacyVariables.length === 0 &&
|
|
21846
|
+
if (legacyVariables.length === 0 && path43.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
21511
21847
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
21512
21848
|
return;
|
|
21513
21849
|
}
|
|
21514
21850
|
for (const name of legacyVariables) {
|
|
21515
21851
|
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);
|
|
21516
21852
|
}
|
|
21517
|
-
if (
|
|
21853
|
+
if (path43.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
21518
21854
|
push(
|
|
21519
21855
|
"legacy-name",
|
|
21520
21856
|
"warn",
|
|
@@ -21604,7 +21940,7 @@ function runDoctor(params) {
|
|
|
21604
21940
|
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);
|
|
21605
21941
|
}
|
|
21606
21942
|
for (const { file, detail } of params.renameJournals?.unreadable ?? []) {
|
|
21607
|
-
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.`,
|
|
21943
|
+
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.`, path43.basename(file));
|
|
21608
21944
|
}
|
|
21609
21945
|
const validIdentityAgents = /* @__PURE__ */ new Map();
|
|
21610
21946
|
const signedInAccounts = [];
|
|
@@ -21730,20 +22066,16 @@ function runDoctor(params) {
|
|
|
21730
22066
|
continue;
|
|
21731
22067
|
}
|
|
21732
22068
|
pushProvider(push, entry, params.credentialCache, params.chatgptSignIn, unreachableLines.get(entry.name));
|
|
22069
|
+
const redirectReason = params.catalogueRedirects?.get(entry.name);
|
|
22070
|
+
if (redirectReason !== void 0) {
|
|
22071
|
+
pushCatalogueRedirectFinding(push, entry.name, redirectReason);
|
|
22072
|
+
}
|
|
21733
22073
|
}
|
|
21734
22074
|
const providerNames = new Set(params.providers.map((entry) => entry.name));
|
|
21735
22075
|
for (const finding of aliasFindings(params.providerAliases ?? {}, providerNames)) {
|
|
21736
22076
|
push("provider", finding.level, finding.message, finding.alias);
|
|
21737
22077
|
}
|
|
21738
|
-
|
|
21739
|
-
push("keychain", "pass", "Skipped (not macOS).");
|
|
21740
|
-
} else {
|
|
21741
|
-
for (const entry of params.identities) {
|
|
21742
|
-
if (validIdentityAgents.get(entry.name) === "codex") continue;
|
|
21743
|
-
const result = lookupKeychainService(params.run, entry.farmRoot);
|
|
21744
|
-
push("keychain", "pass", result.found ? result.note : `${result.note} The sign-in section reports whether a login is stored elsewhere.`, entry.name);
|
|
21745
|
-
}
|
|
21746
|
-
}
|
|
22078
|
+
pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
|
|
21747
22079
|
if (params.directoryRules.raw === void 0) {
|
|
21748
22080
|
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
21749
22081
|
} else {
|
|
@@ -21970,9 +22302,9 @@ function collectDoctorReport(params) {
|
|
|
21970
22302
|
const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
|
|
21971
22303
|
const records = identityRecords(paths);
|
|
21972
22304
|
const displacedIdentities = records.filter((record) => !identityIdExists(paths, record.id) && !unreachableIdentities.some((entry) => entry.name === record.id));
|
|
21973
|
-
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !fs14.existsSync(
|
|
21974
|
-
const farmRoot =
|
|
21975
|
-
const identityPath =
|
|
22305
|
+
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !fs14.existsSync(path43.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
|
|
22306
|
+
const farmRoot = path43.join(paths.identitiesDir, id);
|
|
22307
|
+
const identityPath = path43.join(farmRoot, "identity.json");
|
|
21976
22308
|
return { name: identityNameIn(records, id) ?? id, id, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: fs14.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, id)?.account };
|
|
21977
22309
|
});
|
|
21978
22310
|
const usageSnapshots = {};
|
|
@@ -21990,12 +22322,12 @@ function collectDoctorReport(params) {
|
|
|
21990
22322
|
}
|
|
21991
22323
|
const profileNames = fs14.existsSync(paths.configProfilesDir) ? fs14.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
21992
22324
|
const configProfiles = profileNames.map((name) => {
|
|
21993
|
-
const profilePath =
|
|
22325
|
+
const profilePath = path43.join(paths.configProfilesDir, `${name}.json`);
|
|
21994
22326
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
21995
22327
|
});
|
|
21996
22328
|
const providerNames = fs14.existsSync(paths.providersDir) ? fs14.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
21997
22329
|
const providers = providerNames.map((name) => {
|
|
21998
|
-
const providerPath =
|
|
22330
|
+
const providerPath = path43.join(paths.providersDir, `${name}.json`);
|
|
21999
22331
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
22000
22332
|
});
|
|
22001
22333
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -22007,12 +22339,12 @@ function collectDoctorReport(params) {
|
|
|
22007
22339
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
22008
22340
|
}
|
|
22009
22341
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
22010
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
22342
|
+
const pathDirs = (params.env.PATH ?? "").split(path43.delimiter).filter((dir) => dir !== "");
|
|
22011
22343
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
22012
22344
|
findPathShadow({
|
|
22013
22345
|
pathDirs,
|
|
22014
|
-
targetDir:
|
|
22015
|
-
targetFilename:
|
|
22346
|
+
targetDir: path43.dirname(shimState.targetPath),
|
|
22347
|
+
targetFilename: path43.basename(shimState.targetPath),
|
|
22016
22348
|
findExecutableInDir
|
|
22017
22349
|
}),
|
|
22018
22350
|
shimState.targetPath,
|
|
@@ -22037,9 +22369,10 @@ function collectDoctorReport(params) {
|
|
|
22037
22369
|
providers,
|
|
22038
22370
|
providerAliases: readProviderAliases(paths),
|
|
22039
22371
|
probeBaseUrls: realBaseUrlBatchProbe,
|
|
22372
|
+
catalogueRedirects: providersWithRedirectedCatalogue(realFarmFs, paths, new Map(providers.map((entry) => [entry.name, currentCatalogueSettings(paths, entry.name)]))),
|
|
22040
22373
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
22041
22374
|
unreachableIdentities,
|
|
22042
|
-
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(
|
|
22375
|
+
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(path43.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
|
|
22043
22376
|
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
22044
22377
|
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
22045
22378
|
models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
|
|
@@ -22054,7 +22387,7 @@ function collectDoctorReport(params) {
|
|
|
22054
22387
|
agentShim: refinePathShadow(
|
|
22055
22388
|
findPathShadow({
|
|
22056
22389
|
pathDirs,
|
|
22057
|
-
targetDir:
|
|
22390
|
+
targetDir: path43.dirname(ownExecutablePath),
|
|
22058
22391
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
22059
22392
|
findExecutableInDir
|
|
22060
22393
|
}),
|
|
@@ -22097,93 +22430,93 @@ function collectDoctorReport(params) {
|
|
|
22097
22430
|
init_schema2();
|
|
22098
22431
|
init_rcSchemas();
|
|
22099
22432
|
init_state();
|
|
22100
|
-
var UsageListOutputSchema =
|
|
22101
|
-
var UsageWindowsInputSchema =
|
|
22102
|
-
identity:
|
|
22103
|
-
provider:
|
|
22433
|
+
var UsageListOutputSchema = z38.strictObject({ snapshots: z38.readonly(z38.array(UsageSnapshotSchema)) });
|
|
22434
|
+
var UsageWindowsInputSchema = z38.strictObject({
|
|
22435
|
+
identity: z38.string().min(1),
|
|
22436
|
+
provider: z38.string().min(1).optional()
|
|
22104
22437
|
});
|
|
22105
|
-
var EffectiveWindowSchema =
|
|
22438
|
+
var EffectiveWindowSchema = z38.strictObject({
|
|
22106
22439
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
22107
|
-
reset:
|
|
22440
|
+
reset: z38.boolean(),
|
|
22108
22441
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
22109
|
-
utilization:
|
|
22442
|
+
utilization: z38.number().optional(),
|
|
22110
22443
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
22111
|
-
resetsAtMs:
|
|
22444
|
+
resetsAtMs: z38.number().optional(),
|
|
22112
22445
|
/** The window's own status, for a window that has not reset yet. */
|
|
22113
|
-
status:
|
|
22446
|
+
status: z38.string().optional()
|
|
22114
22447
|
});
|
|
22115
|
-
var UsageWindowsOutputSchema =
|
|
22116
|
-
identity:
|
|
22117
|
-
provider:
|
|
22448
|
+
var UsageWindowsOutputSchema = z38.strictObject({
|
|
22449
|
+
identity: z38.string(),
|
|
22450
|
+
provider: z38.string(),
|
|
22118
22451
|
/** When the rate-limit state the windows come from was observed. */
|
|
22119
|
-
observedAt:
|
|
22452
|
+
observedAt: z38.iso.datetime().optional(),
|
|
22120
22453
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
22121
22454
|
sevenDay: EffectiveWindowSchema.optional()
|
|
22122
22455
|
});
|
|
22123
|
-
var UsageLiveOutputSchema =
|
|
22456
|
+
var UsageLiveOutputSchema = z38.strictObject({
|
|
22124
22457
|
/** 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. */
|
|
22125
22458
|
latest: RcLiveRateLimitSchema.optional(),
|
|
22126
22459
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
22127
|
-
sessions:
|
|
22460
|
+
sessions: z38.readonly(z38.array(RcLiveRateLimitSchema))
|
|
22128
22461
|
});
|
|
22129
|
-
var FrontDoorSessionStatusSchema =
|
|
22130
|
-
pid:
|
|
22131
|
-
startedAt:
|
|
22132
|
-
alive:
|
|
22462
|
+
var FrontDoorSessionStatusSchema = z38.strictObject({
|
|
22463
|
+
pid: z38.int().positive(),
|
|
22464
|
+
startedAt: z38.number(),
|
|
22465
|
+
alive: z38.boolean()
|
|
22133
22466
|
});
|
|
22134
|
-
var HeadroomSocketTargetSchema =
|
|
22135
|
-
var FrontDoorStatusOutputSchema =
|
|
22467
|
+
var HeadroomSocketTargetSchema = z38.union([z38.strictObject({ socketPath: z38.string() }), z38.strictObject({ refused: z38.string() })]);
|
|
22468
|
+
var FrontDoorStatusOutputSchema = z38.strictObject({
|
|
22136
22469
|
state: FrontDoorStateSchema,
|
|
22137
|
-
supervisorAlive:
|
|
22470
|
+
supervisorAlive: z38.boolean(),
|
|
22138
22471
|
/** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
|
|
22139
|
-
draining:
|
|
22140
|
-
sessions:
|
|
22472
|
+
draining: z38.readonly(z38.array(z38.number().int().positive())),
|
|
22473
|
+
sessions: z38.readonly(z38.array(FrontDoorSessionStatusSchema)),
|
|
22141
22474
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
22142
|
-
logPath:
|
|
22143
|
-
logExists:
|
|
22475
|
+
logPath: z38.string(),
|
|
22476
|
+
logExists: z38.boolean()
|
|
22144
22477
|
});
|
|
22145
|
-
var FrontDoorSessionsOutputSchema =
|
|
22478
|
+
var FrontDoorSessionsOutputSchema = z38.strictObject({ sessions: z38.readonly(z38.array(FrontDoorSessionStatusSchema)) });
|
|
22146
22479
|
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.";
|
|
22147
|
-
var CheckRunInputSchema =
|
|
22148
|
-
path:
|
|
22149
|
-
identity:
|
|
22150
|
-
}).refine((input) =>
|
|
22151
|
-
var PoolPickInputSchema =
|
|
22152
|
-
pool:
|
|
22153
|
-
path:
|
|
22154
|
-
}).refine((input) =>
|
|
22155
|
-
var DoctorFindingSchema =
|
|
22156
|
-
section:
|
|
22157
|
-
subject:
|
|
22158
|
-
severity:
|
|
22159
|
-
message:
|
|
22480
|
+
var CheckRunInputSchema = z38.strictObject({
|
|
22481
|
+
path: z38.string().min(1),
|
|
22482
|
+
identity: z38.string().min(1).optional()
|
|
22483
|
+
}).refine((input) => path44.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22484
|
+
var PoolPickInputSchema = z38.strictObject({
|
|
22485
|
+
pool: z38.string().min(1),
|
|
22486
|
+
path: z38.string().min(1)
|
|
22487
|
+
}).refine((input) => path44.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22488
|
+
var DoctorFindingSchema = z38.strictObject({
|
|
22489
|
+
section: z38.enum(DOCTOR_SECTIONS),
|
|
22490
|
+
subject: z38.string().optional(),
|
|
22491
|
+
severity: z38.enum(DOCTOR_SEVERITIES),
|
|
22492
|
+
message: z38.string()
|
|
22160
22493
|
});
|
|
22161
|
-
var DoctorRunOutputSchema =
|
|
22494
|
+
var DoctorRunOutputSchema = z38.strictObject({
|
|
22162
22495
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
22163
|
-
ok:
|
|
22164
|
-
findings:
|
|
22496
|
+
ok: z38.boolean(),
|
|
22497
|
+
findings: z38.readonly(z38.array(DoctorFindingSchema))
|
|
22165
22498
|
});
|
|
22166
|
-
var FrontDoorRestartOutputSchema =
|
|
22167
|
-
action:
|
|
22168
|
-
previousPid:
|
|
22499
|
+
var FrontDoorRestartOutputSchema = z38.strictObject({
|
|
22500
|
+
action: z38.literal("restarting"),
|
|
22501
|
+
previousPid: z38.int().positive()
|
|
22169
22502
|
});
|
|
22170
|
-
var UpdateCheckOutputSchema =
|
|
22171
|
-
current:
|
|
22172
|
-
latest:
|
|
22173
|
-
action:
|
|
22503
|
+
var UpdateCheckOutputSchema = z38.strictObject({
|
|
22504
|
+
current: z38.string(),
|
|
22505
|
+
latest: z38.string(),
|
|
22506
|
+
action: z38.enum(["current", "available", "updated"])
|
|
22174
22507
|
});
|
|
22175
|
-
var CodexSignInSchema =
|
|
22176
|
-
|
|
22177
|
-
|
|
22178
|
-
|
|
22508
|
+
var CodexSignInSchema = z38.discriminatedUnion("state", [
|
|
22509
|
+
z38.strictObject({ state: z38.literal("none") }),
|
|
22510
|
+
z38.strictObject({ state: z38.literal("signed-in"), email: z38.string().optional(), planScope: z38.boolean(), accessTokenExpiresAt: z38.number() }),
|
|
22511
|
+
z38.strictObject({ state: z38.literal("unreadable"), message: z38.string() })
|
|
22179
22512
|
]);
|
|
22180
|
-
var CodexStatusOutputSchema =
|
|
22513
|
+
var CodexStatusOutputSchema = z38.strictObject({
|
|
22181
22514
|
signIn: CodexSignInSchema,
|
|
22182
|
-
codexProviders:
|
|
22515
|
+
codexProviders: z38.readonly(z38.array(z38.string()))
|
|
22183
22516
|
});
|
|
22184
|
-
var CodexLogoutOutputSchema =
|
|
22185
|
-
hadGrant:
|
|
22186
|
-
revoked:
|
|
22517
|
+
var CodexLogoutOutputSchema = z38.strictObject({
|
|
22518
|
+
hadGrant: z38.boolean(),
|
|
22519
|
+
revoked: z38.boolean()
|
|
22187
22520
|
});
|
|
22188
22521
|
|
|
22189
22522
|
// src/frontdoor/codexApi.ts
|
|
@@ -22204,20 +22537,21 @@ function createCodexApiRouter(deps) {
|
|
|
22204
22537
|
|
|
22205
22538
|
// src/frontdoor/doorWorker.ts
|
|
22206
22539
|
import { getAsset, isSea as isSea2 } from "node:sea";
|
|
22207
|
-
import { z as
|
|
22540
|
+
import { z as z40 } from "zod";
|
|
22208
22541
|
init_cliError();
|
|
22209
22542
|
init_doorBounds();
|
|
22210
22543
|
init_providerCatalogue();
|
|
22211
22544
|
|
|
22212
22545
|
// src/frontdoor/doorWorkerProtocol.ts
|
|
22213
|
-
|
|
22546
|
+
init_providerCatalogue();
|
|
22547
|
+
import { z as z39 } from "zod";
|
|
22214
22548
|
var doorWorkerInputSchemas = {
|
|
22215
22549
|
/** `agent-shim check` for `path` as `identity` (the identity a launch there would resolve when absent). */
|
|
22216
|
-
check:
|
|
22550
|
+
check: z39.strictObject({ root: z39.string().min(1), path: z39.string().min(1), identity: z39.string().min(1).optional() }),
|
|
22217
22551
|
/** `agent-shim doctor`. */
|
|
22218
|
-
doctor:
|
|
22552
|
+
doctor: z39.strictObject({ root: z39.string().min(1) }),
|
|
22219
22553
|
/** Fetch and store one provider's model catalogue for the door generation that asked. */
|
|
22220
|
-
"refresh-catalogue":
|
|
22554
|
+
"refresh-catalogue": z39.strictObject({ root: z39.string().min(1), name: z39.string().min(1), supervisorPid: z39.int().positive(), generation: z39.uuid() })
|
|
22221
22555
|
};
|
|
22222
22556
|
|
|
22223
22557
|
// src/frontdoor/doorWorker.ts
|
|
@@ -22232,15 +22566,18 @@ var DoorWorkerBusyError = class extends CliError {
|
|
|
22232
22566
|
var NEXT_STEP = {
|
|
22233
22567
|
check: "run `agent-shim check` from a shell for the detail",
|
|
22234
22568
|
doctor: "run `agent-shim doctor` from a shell for the detail",
|
|
22235
|
-
"refresh-catalogue": "run `agent-shim provider models --refresh
|
|
22569
|
+
"refresh-catalogue": "run `agent-shim provider models <name> --refresh` from a shell for the detail"
|
|
22236
22570
|
};
|
|
22237
22571
|
var DoorWorkerFailedError = class extends CliError {
|
|
22238
|
-
constructor(task, reason, kind) {
|
|
22572
|
+
constructor(task, reason, kind, redirected = false) {
|
|
22239
22573
|
super(`${task} failed in its worker: ${reason}${task === "an unknown task" ? "" : `; ${NEXT_STEP[task]}`}`);
|
|
22240
22574
|
this.kind = kind;
|
|
22241
22575
|
this.name = "DoorWorkerFailedError";
|
|
22576
|
+
this.redirected = redirected;
|
|
22242
22577
|
}
|
|
22243
22578
|
kind;
|
|
22579
|
+
/** 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. */
|
|
22580
|
+
redirected;
|
|
22244
22581
|
};
|
|
22245
22582
|
|
|
22246
22583
|
// src/frontdoor/configApi.ts
|
|
@@ -22297,7 +22634,7 @@ init_identityStore();
|
|
|
22297
22634
|
init_keychainLogin();
|
|
22298
22635
|
init_identityNamesLock();
|
|
22299
22636
|
init_lock();
|
|
22300
|
-
|
|
22637
|
+
init_identity2();
|
|
22301
22638
|
init_replayRun();
|
|
22302
22639
|
init_poolStore();
|
|
22303
22640
|
init_baseUrlDisplay();
|
|
@@ -22308,68 +22645,68 @@ init_schema();
|
|
|
22308
22645
|
init_names();
|
|
22309
22646
|
init_keychainLogin();
|
|
22310
22647
|
init_statusline();
|
|
22311
|
-
import { z as
|
|
22312
|
-
var RemovalConfirmationSchema =
|
|
22313
|
-
var CredentialWriteSchema = (targets) =>
|
|
22314
|
-
sources:
|
|
22315
|
-
target:
|
|
22316
|
-
cache:
|
|
22648
|
+
import { z as z41 } from "zod";
|
|
22649
|
+
var RemovalConfirmationSchema = z41.boolean();
|
|
22650
|
+
var CredentialWriteSchema = (targets) => z41.strictObject({
|
|
22651
|
+
sources: z41.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
22652
|
+
target: z41.enum(targets).optional(),
|
|
22653
|
+
cache: z41.union([z41.literal(false), CredentialCacheSchema]).optional()
|
|
22317
22654
|
});
|
|
22318
|
-
var CredentialSummarySchema2 =
|
|
22319
|
-
target:
|
|
22320
|
-
sources:
|
|
22321
|
-
|
|
22322
|
-
|
|
22323
|
-
|
|
22324
|
-
|
|
22325
|
-
|
|
22326
|
-
|
|
22327
|
-
|
|
22655
|
+
var CredentialSummarySchema2 = z41.strictObject({
|
|
22656
|
+
target: z41.enum(CREDENTIAL_TARGETS),
|
|
22657
|
+
sources: z41.readonly(z41.array(
|
|
22658
|
+
z41.discriminatedUnion("kind", [
|
|
22659
|
+
z41.strictObject({ kind: z41.literal("env"), variable: z41.string() }),
|
|
22660
|
+
z41.strictObject({ kind: z41.literal("file"), path: z41.string() }),
|
|
22661
|
+
z41.strictObject({ kind: z41.literal("command"), program: z41.string() }),
|
|
22662
|
+
z41.strictObject({ kind: z41.literal("op"), reference: z41.string() }),
|
|
22663
|
+
z41.strictObject({ kind: z41.literal("keychain"), service: z41.string(), account: z41.string().optional() }),
|
|
22664
|
+
z41.strictObject({ kind: z41.literal("literal") })
|
|
22328
22665
|
])
|
|
22329
22666
|
)),
|
|
22330
22667
|
cache: CredentialCacheSchema.optional()
|
|
22331
22668
|
});
|
|
22332
|
-
var mutationOutput = (kind, action) =>
|
|
22333
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
22334
|
-
var IdentityValueSchema =
|
|
22335
|
-
agent:
|
|
22336
|
-
name:
|
|
22337
|
-
label:
|
|
22338
|
-
defaultConfigProfile:
|
|
22339
|
-
provider:
|
|
22340
|
-
allowAmbientCredential:
|
|
22669
|
+
var mutationOutput = (kind, action) => z41.strictObject({ action: z41.literal(action), kind: z41.literal(kind), name: z41.string() });
|
|
22670
|
+
var storedMutationOutput = (kind, action, value) => z41.strictObject({ action: z41.literal(action), kind: z41.literal(kind), name: z41.string(), value });
|
|
22671
|
+
var IdentityValueSchema = z41.strictObject({
|
|
22672
|
+
agent: z41.enum(["claude", "codex"]).optional(),
|
|
22673
|
+
name: z41.string(),
|
|
22674
|
+
label: z41.string().optional(),
|
|
22675
|
+
defaultConfigProfile: z41.string().optional(),
|
|
22676
|
+
provider: z41.string().optional(),
|
|
22677
|
+
allowAmbientCredential: z41.boolean(),
|
|
22341
22678
|
credential: CredentialSummarySchema2.optional(),
|
|
22342
|
-
anchors:
|
|
22679
|
+
anchors: z41.array(AnchorSchema).optional()
|
|
22343
22680
|
});
|
|
22344
22681
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
22345
|
-
var ProviderValueSchema =
|
|
22346
|
-
name:
|
|
22347
|
-
kind:
|
|
22348
|
-
displayName:
|
|
22349
|
-
baseUrl:
|
|
22682
|
+
var ProviderValueSchema = z41.strictObject({
|
|
22683
|
+
name: z41.string(),
|
|
22684
|
+
kind: z41.enum(PROVIDER_KINDS),
|
|
22685
|
+
displayName: z41.string(),
|
|
22686
|
+
baseUrl: z41.string().optional(),
|
|
22350
22687
|
codex: CodexProviderConfigSchema.optional(),
|
|
22351
22688
|
credential: CredentialSummarySchema2.optional(),
|
|
22352
|
-
env:
|
|
22689
|
+
env: z41.record(z41.string(), z41.string()).optional()
|
|
22353
22690
|
});
|
|
22354
|
-
var ConfigNameInputSchema =
|
|
22355
|
-
var ConfigIdentityAddInputSchema =
|
|
22691
|
+
var ConfigNameInputSchema = z41.strictObject({ name: z41.string().min(1) });
|
|
22692
|
+
var ConfigIdentityAddInputSchema = z41.strictObject({ name: z41.string().min(1), keepKeychainLogin: z41.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
|
|
22356
22693
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
22357
|
-
var ConfigIdentitySetInputSchema =
|
|
22358
|
-
name:
|
|
22694
|
+
var ConfigIdentitySetInputSchema = z41.strictObject({
|
|
22695
|
+
name: z41.string().min(1),
|
|
22359
22696
|
/** The identity's display label; `false` clears it. */
|
|
22360
|
-
label:
|
|
22361
|
-
defaultConfigProfile:
|
|
22697
|
+
label: z41.union([IdentityLabelSchema, z41.literal(false)]).optional(),
|
|
22698
|
+
defaultConfigProfile: z41.union([z41.string().min(1), z41.literal(false)]).optional(),
|
|
22362
22699
|
/** The provider the identity exists for; `false` clears it. */
|
|
22363
|
-
provider:
|
|
22364
|
-
allowAmbientCredential:
|
|
22365
|
-
credential:
|
|
22700
|
+
provider: z41.union([z41.string().min(1), z41.literal(false)]).optional(),
|
|
22701
|
+
allowAmbientCredential: z41.boolean().optional(),
|
|
22702
|
+
credential: z41.union([z41.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
22366
22703
|
/** `false` removes the anchors; a list replaces them. */
|
|
22367
|
-
anchors:
|
|
22704
|
+
anchors: z41.union([z41.literal(false), z41.array(AnchorSchema).min(1)]).optional()
|
|
22368
22705
|
});
|
|
22369
22706
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
22370
|
-
var ConfigIdentityRemoveInputSchema =
|
|
22707
|
+
var ConfigIdentityRemoveInputSchema = z41.strictObject({ name: z41.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22371
22708
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
22372
|
-
var ConfigStatuslineSetSchema =
|
|
22709
|
+
var ConfigStatuslineSetSchema = z41.record(z41.string(), z41.unknown()).superRefine((settings, context) => {
|
|
22373
22710
|
for (const key of Object.keys(settings)) {
|
|
22374
22711
|
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
22375
22712
|
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` });
|
|
@@ -22377,93 +22714,93 @@ var ConfigStatuslineSetSchema = z40.record(z40.string(), z40.unknown()).superRef
|
|
|
22377
22714
|
}
|
|
22378
22715
|
});
|
|
22379
22716
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
22380
|
-
var ConfigProfileAddInputSchema =
|
|
22381
|
-
name:
|
|
22382
|
-
extends:
|
|
22383
|
-
description:
|
|
22717
|
+
var ConfigProfileAddInputSchema = z41.strictObject({
|
|
22718
|
+
name: z41.string().min(1),
|
|
22719
|
+
extends: z41.array(z41.string().min(1)).optional(),
|
|
22720
|
+
description: z41.string().optional()
|
|
22384
22721
|
});
|
|
22385
22722
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
22386
|
-
var ConfigProfileSetInputSchema =
|
|
22387
|
-
name:
|
|
22388
|
-
category:
|
|
22389
|
-
entry:
|
|
22390
|
-
extends:
|
|
22391
|
-
description:
|
|
22392
|
-
launch:
|
|
22393
|
-
skipPermissions:
|
|
22394
|
-
remoteControl:
|
|
22395
|
-
headroom:
|
|
22396
|
-
trackUsage:
|
|
22397
|
-
provider:
|
|
22398
|
-
claudeVersion:
|
|
22399
|
-
delay:
|
|
22400
|
-
pause:
|
|
22401
|
-
explain:
|
|
22402
|
-
proxyBypass:
|
|
22403
|
-
statusline:
|
|
22723
|
+
var ConfigProfileSetInputSchema = z41.strictObject({
|
|
22724
|
+
name: z41.string().min(1),
|
|
22725
|
+
category: z41.record(z41.string(), z41.boolean()).optional(),
|
|
22726
|
+
entry: z41.record(z41.string(), z41.boolean()).optional(),
|
|
22727
|
+
extends: z41.union([z41.array(z41.string().min(1)), z41.literal(false)]).optional(),
|
|
22728
|
+
description: z41.union([z41.string(), z41.literal(false)]).optional(),
|
|
22729
|
+
launch: z41.strictObject({
|
|
22730
|
+
skipPermissions: z41.boolean().optional(),
|
|
22731
|
+
remoteControl: z41.boolean().optional(),
|
|
22732
|
+
headroom: z41.boolean().optional(),
|
|
22733
|
+
trackUsage: z41.boolean().optional(),
|
|
22734
|
+
provider: z41.union([z41.string().min(1), z41.literal(false)]).optional(),
|
|
22735
|
+
claudeVersion: z41.union([z41.string().min(1), z41.literal(false)]).optional(),
|
|
22736
|
+
delay: z41.union([z41.string().regex(DURATION_RE), z41.literal(false)]).optional(),
|
|
22737
|
+
pause: z41.boolean().optional(),
|
|
22738
|
+
explain: z41.boolean().optional(),
|
|
22739
|
+
proxyBypass: z41.union([z41.array(z41.string().min(1)), z41.literal(false)]).optional(),
|
|
22740
|
+
statusline: z41.strictObject({
|
|
22404
22741
|
set: ConfigStatuslineSetSchema.optional(),
|
|
22405
|
-
unset:
|
|
22742
|
+
unset: z41.array(z41.string()).optional()
|
|
22406
22743
|
}).optional()
|
|
22407
22744
|
}).optional()
|
|
22408
22745
|
});
|
|
22409
22746
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
22410
|
-
var ConfigProfileRemoveInputSchema =
|
|
22747
|
+
var ConfigProfileRemoveInputSchema = z41.strictObject({ name: z41.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22411
22748
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
22412
22749
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
22413
|
-
var PoolMembersInputSchema =
|
|
22414
|
-
var ConfigPoolAddInputSchema =
|
|
22415
|
-
name:
|
|
22750
|
+
var PoolMembersInputSchema = z41.array(z41.string().min(1)).min(1);
|
|
22751
|
+
var ConfigPoolAddInputSchema = z41.strictObject({
|
|
22752
|
+
name: z41.string().min(1),
|
|
22416
22753
|
identities: PoolMembersInputSchema,
|
|
22417
|
-
preference:
|
|
22418
|
-
resumeOnLimit:
|
|
22419
|
-
compactBeforeLimit:
|
|
22754
|
+
preference: z41.enum(POOL_PREFERENCES).optional(),
|
|
22755
|
+
resumeOnLimit: z41.boolean().optional(),
|
|
22756
|
+
compactBeforeLimit: z41.boolean().optional(),
|
|
22420
22757
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
22421
22758
|
});
|
|
22422
22759
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
22423
|
-
var ConfigPoolSetInputSchema =
|
|
22424
|
-
name:
|
|
22760
|
+
var ConfigPoolSetInputSchema = z41.strictObject({
|
|
22761
|
+
name: z41.string().min(1),
|
|
22425
22762
|
identities: PoolMembersInputSchema.optional(),
|
|
22426
|
-
preference:
|
|
22427
|
-
resumeOnLimit:
|
|
22428
|
-
compactBeforeLimit:
|
|
22429
|
-
compactAtUtilisation:
|
|
22763
|
+
preference: z41.union([z41.enum(POOL_PREFERENCES), z41.literal(false)]).optional(),
|
|
22764
|
+
resumeOnLimit: z41.boolean().optional(),
|
|
22765
|
+
compactBeforeLimit: z41.boolean().optional(),
|
|
22766
|
+
compactAtUtilisation: z41.union([CompactAtUtilisationSchema, z41.literal(false)]).optional()
|
|
22430
22767
|
});
|
|
22431
22768
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
22432
|
-
var ConfigPoolRemoveInputSchema =
|
|
22769
|
+
var ConfigPoolRemoveInputSchema = z41.strictObject({ name: z41.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22433
22770
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
22434
22771
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
22435
|
-
var ConfigProviderAddInputSchema =
|
|
22436
|
-
name:
|
|
22437
|
-
kind:
|
|
22438
|
-
displayName:
|
|
22439
|
-
baseUrl:
|
|
22772
|
+
var ConfigProviderAddInputSchema = z41.strictObject({
|
|
22773
|
+
name: z41.string().min(1),
|
|
22774
|
+
kind: z41.enum(PROVIDER_KINDS).optional(),
|
|
22775
|
+
displayName: z41.string().min(1),
|
|
22776
|
+
baseUrl: z41.string().min(1).optional(),
|
|
22440
22777
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
22441
22778
|
codex: CodexProviderConfigSchema.optional()
|
|
22442
22779
|
});
|
|
22443
22780
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
22444
|
-
var ConfigProviderSetInputSchema =
|
|
22445
|
-
name:
|
|
22446
|
-
displayName:
|
|
22447
|
-
baseUrl:
|
|
22781
|
+
var ConfigProviderSetInputSchema = z41.strictObject({
|
|
22782
|
+
name: z41.string().min(1),
|
|
22783
|
+
displayName: z41.string().min(1).optional(),
|
|
22784
|
+
baseUrl: z41.string().min(1).optional(),
|
|
22448
22785
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
22449
22786
|
codex: CodexProviderConfigSchema.optional()
|
|
22450
22787
|
});
|
|
22451
22788
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
22452
|
-
var ConfigProviderRemoveInputSchema =
|
|
22789
|
+
var ConfigProviderRemoveInputSchema = z41.strictObject({ name: z41.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22453
22790
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
22454
|
-
var ConfigRuleAddInputSchema =
|
|
22455
|
-
path:
|
|
22456
|
-
configProfile:
|
|
22457
|
-
identity:
|
|
22791
|
+
var ConfigRuleAddInputSchema = z41.strictObject({
|
|
22792
|
+
path: z41.string().min(1),
|
|
22793
|
+
configProfile: z41.string().min(1).optional(),
|
|
22794
|
+
identity: z41.string().min(1).optional()
|
|
22458
22795
|
});
|
|
22459
22796
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
22460
|
-
var ConfigRuleSetInputSchema =
|
|
22461
|
-
path:
|
|
22462
|
-
configProfile:
|
|
22463
|
-
identity:
|
|
22797
|
+
var ConfigRuleSetInputSchema = z41.strictObject({
|
|
22798
|
+
path: z41.string().min(1),
|
|
22799
|
+
configProfile: z41.union([z41.string().min(1), z41.literal(false)]).optional(),
|
|
22800
|
+
identity: z41.union([z41.string().min(1), z41.literal(false)]).optional()
|
|
22464
22801
|
});
|
|
22465
22802
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
22466
|
-
var ConfigRuleRemoveInputSchema =
|
|
22803
|
+
var ConfigRuleRemoveInputSchema = z41.strictObject({ path: z41.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22467
22804
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
22468
22805
|
|
|
22469
22806
|
// src/frontdoor/configApi.ts
|
|
@@ -22537,7 +22874,7 @@ function profileValue(name, paths) {
|
|
|
22537
22874
|
function createConfigApiRouter(deps) {
|
|
22538
22875
|
const authed = doorApiAuth(deps.expectedToken);
|
|
22539
22876
|
const { paths } = deps;
|
|
22540
|
-
const route = (
|
|
22877
|
+
const route = (path56, summary) => authed.meta(openapi3({ method: "POST", path: path56, summary, tags: [CONFIG_API_TAG] }));
|
|
22541
22878
|
return {
|
|
22542
22879
|
config: {
|
|
22543
22880
|
identity: {
|
|
@@ -22808,50 +23145,50 @@ import { eventIterator as eventIterator2, withEventMeta as withEventMeta2 } from
|
|
|
22808
23145
|
|
|
22809
23146
|
// src/frontdoor/eventSchemas.ts
|
|
22810
23147
|
init_schema2();
|
|
22811
|
-
import { z as
|
|
23148
|
+
import { z as z42 } from "zod";
|
|
22812
23149
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
22813
23150
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
22814
23151
|
var USAGE_EVENT_SOURCE = "usage";
|
|
22815
23152
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
22816
23153
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
22817
|
-
var DoorEventSchema =
|
|
22818
|
-
source:
|
|
23154
|
+
var DoorEventSchema = z42.strictObject({
|
|
23155
|
+
source: z42.string().min(1),
|
|
22819
23156
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
22820
|
-
sequence:
|
|
22821
|
-
payload:
|
|
23157
|
+
sequence: z42.number().int().positive(),
|
|
23158
|
+
payload: z42.unknown()
|
|
22822
23159
|
});
|
|
22823
|
-
var DoorEventSourceQuerySchema =
|
|
22824
|
-
sources:
|
|
23160
|
+
var DoorEventSourceQuerySchema = z42.strictObject({
|
|
23161
|
+
sources: z42.array(z42.string().min(1)).min(1).optional()
|
|
22825
23162
|
});
|
|
22826
|
-
var LaunchLifecycleEventSchema =
|
|
22827
|
-
kind:
|
|
22828
|
-
pid:
|
|
22829
|
-
startedAt:
|
|
22830
|
-
observedAt:
|
|
23163
|
+
var LaunchLifecycleEventSchema = z42.strictObject({
|
|
23164
|
+
kind: z42.enum(["registered", "pruned", "ended"]),
|
|
23165
|
+
pid: z42.number().int().positive(),
|
|
23166
|
+
startedAt: z42.number(),
|
|
23167
|
+
observedAt: z42.number()
|
|
22831
23168
|
});
|
|
22832
|
-
var DoorHealthEventSchema =
|
|
22833
|
-
|
|
22834
|
-
|
|
22835
|
-
|
|
22836
|
-
|
|
22837
|
-
|
|
22838
|
-
|
|
23169
|
+
var DoorHealthEventSchema = z42.discriminatedUnion("kind", [
|
|
23170
|
+
z42.strictObject({ kind: z42.literal("generation"), pid: z42.number().int().positive(), providerPort: z42.number().int().positive(), connectPort: z42.number().int().positive(), directPort: z42.number().int().positive(), observedAt: z42.number() }),
|
|
23171
|
+
z42.strictObject({ kind: z42.literal("listenerFailed"), pid: z42.number().int().positive(), listener: z42.enum(["provider", "connect", "direct"]), message: z42.string(), observedAt: z42.number() }),
|
|
23172
|
+
z42.strictObject({ kind: z42.literal("binaryTurnover"), pid: z42.number().int().positive(), observedAt: z42.number() }),
|
|
23173
|
+
z42.strictObject({ kind: z42.literal("idleShutdown"), pid: z42.number().int().positive(), observedAt: z42.number() }),
|
|
23174
|
+
z42.strictObject({ kind: z42.literal("superseded"), pid: z42.number().int().positive(), ownerPid: z42.number().int().positive(), observedAt: z42.number() }),
|
|
23175
|
+
z42.strictObject({ kind: z42.literal("drained"), pid: z42.number().int().positive(), observedAt: z42.number() })
|
|
22839
23176
|
]);
|
|
22840
|
-
var QuotaExpiringEventSchema =
|
|
23177
|
+
var QuotaExpiringEventSchema = z42.strictObject({
|
|
22841
23178
|
/** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
|
|
22842
|
-
id:
|
|
23179
|
+
id: z42.string().min(1),
|
|
22843
23180
|
/** The identity's name when the event was published, absent for an identity no longer stored under the id. */
|
|
22844
|
-
name:
|
|
22845
|
-
provider:
|
|
22846
|
-
window:
|
|
23181
|
+
name: z42.string().min(1).optional(),
|
|
23182
|
+
provider: z42.string().min(1),
|
|
23183
|
+
window: z42.enum(["fiveHour", "sevenDay"]),
|
|
22847
23184
|
/** 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. */
|
|
22848
|
-
utilization:
|
|
22849
|
-
resetsAt:
|
|
22850
|
-
observedAt:
|
|
23185
|
+
utilization: z42.number().min(0).max(1),
|
|
23186
|
+
resetsAt: z42.iso.datetime(),
|
|
23187
|
+
observedAt: z42.number()
|
|
22851
23188
|
});
|
|
22852
23189
|
var UsageChangeEventSchema = UsageSnapshotSchema.extend({
|
|
22853
|
-
id:
|
|
22854
|
-
name:
|
|
23190
|
+
id: z42.string().min(1),
|
|
23191
|
+
name: z42.string().min(1).optional()
|
|
22855
23192
|
});
|
|
22856
23193
|
|
|
22857
23194
|
// src/frontdoor/eventsApi.ts
|
|
@@ -22896,14 +23233,14 @@ function createEventsApiRouter(deps) {
|
|
|
22896
23233
|
init_update();
|
|
22897
23234
|
import { ORPCError as ORPCError4 } from "@orpc/client";
|
|
22898
23235
|
import { openapi as openapi5 } from "@orpc/openapi";
|
|
22899
|
-
import { z as
|
|
23236
|
+
import { z as z43 } from "zod";
|
|
22900
23237
|
var FRONTDOOR_API_TAG = "frontdoor";
|
|
22901
23238
|
var UPDATE_API_TAG = "update";
|
|
22902
23239
|
function createLifecycleApiRouter(deps) {
|
|
22903
23240
|
const authed = doorApiAuth(deps.expectedToken);
|
|
22904
23241
|
return {
|
|
22905
23242
|
frontdoor: {
|
|
22906
|
-
refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(
|
|
23243
|
+
refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(z43.strictObject({ requested: z43.literal(true) })).handler(() => {
|
|
22907
23244
|
deps.refreshCatalogues();
|
|
22908
23245
|
return { requested: true };
|
|
22909
23246
|
}),
|
|
@@ -22939,65 +23276,65 @@ import { ORPCError as ORPCError5 } from "@orpc/client";
|
|
|
22939
23276
|
import { openapi as openapi6 } from "@orpc/openapi";
|
|
22940
23277
|
|
|
22941
23278
|
// src/frontdoor/launchSchemas.ts
|
|
22942
|
-
import
|
|
22943
|
-
import { z as
|
|
23279
|
+
import path45 from "node:path";
|
|
23280
|
+
import { z as z44 } from "zod";
|
|
22944
23281
|
init_statusline();
|
|
22945
23282
|
init_claudeVersion();
|
|
22946
|
-
|
|
22947
|
-
var LaunchResolveInputSchema =
|
|
22948
|
-
path:
|
|
23283
|
+
init_identity2();
|
|
23284
|
+
var LaunchResolveInputSchema = z44.strictObject({
|
|
23285
|
+
path: z44.string().min(1),
|
|
22949
23286
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
22950
|
-
argv:
|
|
23287
|
+
argv: z44.readonly(z44.array(z44.string())).optional(),
|
|
22951
23288
|
/** 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. */
|
|
22952
|
-
env:
|
|
22953
|
-
}).refine((input) =>
|
|
22954
|
-
var LaunchPoolDecisionSchema =
|
|
22955
|
-
name:
|
|
22956
|
-
reasons:
|
|
23289
|
+
env: z44.record(z44.string(), z44.string()).optional()
|
|
23290
|
+
}).refine((input) => path45.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
23291
|
+
var LaunchPoolDecisionSchema = z44.strictObject({
|
|
23292
|
+
name: z44.string(),
|
|
23293
|
+
reasons: z44.readonly(z44.array(z44.string())),
|
|
22957
23294
|
/** The provider the ranking read for the chosen member, when the launch spends one in place of the member's Claude account. */
|
|
22958
|
-
provider:
|
|
22959
|
-
movedOff:
|
|
23295
|
+
provider: z44.string().optional(),
|
|
23296
|
+
movedOff: z44.strictObject({ identity: z44.string(), reason: z44.string() }).optional()
|
|
22960
23297
|
});
|
|
22961
|
-
var LaunchDecisionSchema =
|
|
22962
|
-
identity:
|
|
22963
|
-
identityId:
|
|
22964
|
-
identitySource:
|
|
23298
|
+
var LaunchDecisionSchema = z44.strictObject({
|
|
23299
|
+
identity: z44.string().optional(),
|
|
23300
|
+
identityId: z44.string().optional(),
|
|
23301
|
+
identitySource: z44.enum(IDENTITY_DECISION_SOURCES),
|
|
22965
23302
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
22966
23303
|
/** 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. */
|
|
22967
|
-
configDirEscapeHatch:
|
|
22968
|
-
configDir:
|
|
22969
|
-
configProfile:
|
|
22970
|
-
configProfileSource:
|
|
22971
|
-
provider:
|
|
23304
|
+
configDirEscapeHatch: z44.boolean(),
|
|
23305
|
+
configDir: z44.string().optional(),
|
|
23306
|
+
configProfile: z44.string().optional(),
|
|
23307
|
+
configProfileSource: z44.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
23308
|
+
provider: z44.string().optional()
|
|
22972
23309
|
});
|
|
22973
|
-
var LaunchFlagsSchema =
|
|
22974
|
-
skipPermissions:
|
|
22975
|
-
remoteControl:
|
|
22976
|
-
headroom:
|
|
22977
|
-
trackUsage:
|
|
22978
|
-
pause:
|
|
22979
|
-
explain:
|
|
23310
|
+
var LaunchFlagsSchema = z44.strictObject({
|
|
23311
|
+
skipPermissions: z44.boolean(),
|
|
23312
|
+
remoteControl: z44.boolean(),
|
|
23313
|
+
headroom: z44.boolean(),
|
|
23314
|
+
trackUsage: z44.boolean(),
|
|
23315
|
+
pause: z44.boolean(),
|
|
23316
|
+
explain: z44.boolean(),
|
|
22980
23317
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
22981
|
-
delayMs:
|
|
23318
|
+
delayMs: z44.number(),
|
|
22982
23319
|
/** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
|
|
22983
|
-
proxyBypass:
|
|
23320
|
+
proxyBypass: z44.array(z44.string()).readonly(),
|
|
22984
23321
|
/** How the session's built-in statusline looks, when the launch configures any of it. */
|
|
22985
23322
|
statusline: StatuslineSchema.optional()
|
|
22986
23323
|
});
|
|
22987
|
-
var LaunchResolveOutputSchema =
|
|
23324
|
+
var LaunchResolveOutputSchema = z44.strictObject({
|
|
22988
23325
|
decision: LaunchDecisionSchema,
|
|
22989
23326
|
flags: LaunchFlagsSchema,
|
|
22990
|
-
claudeVersion:
|
|
23327
|
+
claudeVersion: z44.strictObject({ version: z44.string(), source: z44.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
22991
23328
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
22992
|
-
bin:
|
|
23329
|
+
bin: z44.string(),
|
|
22993
23330
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
22994
|
-
args:
|
|
23331
|
+
args: z44.readonly(z44.array(z44.string())),
|
|
22995
23332
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
22996
|
-
credential:
|
|
22997
|
-
routing:
|
|
23333
|
+
credential: z44.strictObject({ subject: z44.enum(["provider", "identity"]), name: z44.string(), summary: CredentialSummarySchema }).optional(),
|
|
23334
|
+
routing: z44.strictObject({ frontDoor: z44.boolean(), headroom: z44.boolean() }),
|
|
22998
23335
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
22999
|
-
environment:
|
|
23000
|
-
warnings:
|
|
23336
|
+
environment: z44.readonly(z44.array(z44.string())),
|
|
23337
|
+
warnings: z44.readonly(z44.array(z44.string()))
|
|
23001
23338
|
});
|
|
23002
23339
|
|
|
23003
23340
|
// src/frontdoor/launchApi.ts
|
|
@@ -23036,21 +23373,21 @@ init_schema3();
|
|
|
23036
23373
|
init_cliError();
|
|
23037
23374
|
import { ORPCError as ORPCError6 } from "@orpc/client";
|
|
23038
23375
|
import { openapi as openapi7 } from "@orpc/openapi";
|
|
23039
|
-
import { z as
|
|
23040
|
-
var AgentTreesListInputSchema =
|
|
23376
|
+
import { z as z45 } from "zod";
|
|
23377
|
+
var AgentTreesListInputSchema = z45.strictObject({
|
|
23041
23378
|
/** Only this identity's sessions. */
|
|
23042
|
-
identity:
|
|
23379
|
+
identity: z45.string().optional(),
|
|
23043
23380
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
23044
|
-
all:
|
|
23381
|
+
all: z45.boolean().optional()
|
|
23045
23382
|
});
|
|
23046
|
-
var AgentTreesListOutputSchema =
|
|
23047
|
-
var AgentTreesShowInputSchema =
|
|
23383
|
+
var AgentTreesListOutputSchema = z45.array(SessionSummarySchema);
|
|
23384
|
+
var AgentTreesShowInputSchema = z45.strictObject({
|
|
23048
23385
|
/** A session id, or an unambiguous prefix of one. */
|
|
23049
|
-
session:
|
|
23386
|
+
session: z45.string().min(1),
|
|
23050
23387
|
/** Look only in this identity. */
|
|
23051
|
-
identity:
|
|
23388
|
+
identity: z45.string().optional()
|
|
23052
23389
|
});
|
|
23053
|
-
var AgentTreesShowOutputSchema =
|
|
23390
|
+
var AgentTreesShowOutputSchema = z45.strictObject({ identities: z45.array(z45.string()), ...MergedAgentTreeSchema.shape });
|
|
23054
23391
|
function asBadRequest(error) {
|
|
23055
23392
|
if (error instanceof CliError) {
|
|
23056
23393
|
throw new ORPCError6("BAD_REQUEST", { message: error.message });
|
|
@@ -23103,7 +23440,7 @@ import { openapi as openapi8 } from "@orpc/openapi";
|
|
|
23103
23440
|
import { eventIterator as eventIterator3, withEventMeta as withEventMeta3 } from "@orpc/server";
|
|
23104
23441
|
|
|
23105
23442
|
// src/frontdoor/rcEventLog.ts
|
|
23106
|
-
import { z as
|
|
23443
|
+
import { z as z46 } from "zod";
|
|
23107
23444
|
|
|
23108
23445
|
// src/frontdoor/eventHub.ts
|
|
23109
23446
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -23228,46 +23565,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
|
23228
23565
|
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
23229
23566
|
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
23230
23567
|
var RC_PENDING_RETIRE_REASONS = ["answered", "withdrawn", "worker-stopped", "session-ended"];
|
|
23231
|
-
var transitionBase = { session:
|
|
23232
|
-
var cursorFields = { cursor:
|
|
23233
|
-
var sessionAppearedShape = { kind:
|
|
23234
|
-
var sessionEndedShape = { kind:
|
|
23235
|
-
var workerStateShape = { kind:
|
|
23236
|
-
var pendingBornShape = { kind:
|
|
23237
|
-
var pendingRetiredShape = { kind:
|
|
23238
|
-
var RcSessionTransitionSchema =
|
|
23239
|
-
|
|
23240
|
-
|
|
23241
|
-
|
|
23242
|
-
|
|
23243
|
-
|
|
23568
|
+
var transitionBase = { session: z46.string(), at: z46.number() };
|
|
23569
|
+
var cursorFields = { cursor: z46.string(), sequence: z46.int().positive() };
|
|
23570
|
+
var sessionAppearedShape = { kind: z46.literal("session-appeared"), ...transitionBase };
|
|
23571
|
+
var sessionEndedShape = { kind: z46.literal("session-ended"), reason: z46.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
23572
|
+
var workerStateShape = { kind: z46.literal("worker-state"), state: z46.string(), previous: z46.string().optional(), ...transitionBase };
|
|
23573
|
+
var pendingBornShape = { kind: z46.literal("pending-born"), requestId: z46.string(), type: z46.string(), summary: z46.string(), ...transitionBase };
|
|
23574
|
+
var pendingRetiredShape = { kind: z46.literal("pending-retired"), requestId: z46.string(), reason: z46.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
23575
|
+
var RcSessionTransitionSchema = z46.discriminatedUnion("kind", [
|
|
23576
|
+
z46.strictObject(sessionAppearedShape),
|
|
23577
|
+
z46.strictObject(sessionEndedShape),
|
|
23578
|
+
z46.strictObject(workerStateShape),
|
|
23579
|
+
z46.strictObject(pendingBornShape),
|
|
23580
|
+
z46.strictObject(pendingRetiredShape)
|
|
23244
23581
|
]);
|
|
23245
23582
|
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
23246
23583
|
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;
|
|
23247
23584
|
var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
|
|
23248
|
-
var RcSessionEventSchema =
|
|
23249
|
-
|
|
23250
|
-
|
|
23251
|
-
|
|
23252
|
-
|
|
23253
|
-
|
|
23585
|
+
var RcSessionEventSchema = z46.discriminatedUnion("kind", [
|
|
23586
|
+
z46.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
23587
|
+
z46.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
23588
|
+
z46.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
23589
|
+
z46.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
23590
|
+
z46.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
23254
23591
|
]);
|
|
23255
|
-
var RcSessionEventsReadInputSchema =
|
|
23592
|
+
var RcSessionEventsReadInputSchema = z46.strictObject({
|
|
23256
23593
|
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
23257
|
-
since:
|
|
23594
|
+
since: z46.string().min(1).optional(),
|
|
23258
23595
|
/** One `cse_` session id; every session when omitted. */
|
|
23259
|
-
session:
|
|
23596
|
+
session: z46.string().min(1).optional(),
|
|
23260
23597
|
/** The most events one answer carries; every event after `since` when omitted. */
|
|
23261
|
-
limit:
|
|
23598
|
+
limit: z46.int().positive().optional()
|
|
23262
23599
|
});
|
|
23263
23600
|
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
23264
23601
|
/** 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. */
|
|
23265
|
-
limit:
|
|
23602
|
+
limit: z46.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
23266
23603
|
});
|
|
23267
23604
|
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
23268
|
-
var RcSessionEventsReadOutputSchema =
|
|
23269
|
-
|
|
23270
|
-
|
|
23605
|
+
var RcSessionEventsReadOutputSchema = z46.discriminatedUnion("status", [
|
|
23606
|
+
z46.strictObject({ status: z46.literal("ok"), events: z46.readonly(z46.array(RcSessionEventSchema)), cursor: z46.string(), more: z46.boolean(), head: z46.string() }),
|
|
23607
|
+
z46.strictObject({ status: z46.literal("expired"), message: z46.string(), head: z46.string() })
|
|
23271
23608
|
]);
|
|
23272
23609
|
var CURSOR_SEPARATOR = ".";
|
|
23273
23610
|
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";
|
|
@@ -25456,7 +25793,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25456
25793
|
// src/frontdoor/rcSelfHostMint.ts
|
|
25457
25794
|
init_identityRecords();
|
|
25458
25795
|
init_account();
|
|
25459
|
-
import
|
|
25796
|
+
import path46 from "node:path";
|
|
25460
25797
|
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
25461
25798
|
var CLAUDE_JSON2 = ".claude.json";
|
|
25462
25799
|
var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
@@ -25480,7 +25817,7 @@ function readJsonObject(fs17, file) {
|
|
|
25480
25817
|
return isRecord16(parsed) ? parsed : void 0;
|
|
25481
25818
|
}
|
|
25482
25819
|
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
25483
|
-
const parsed = readJsonObject(fs17,
|
|
25820
|
+
const parsed = readJsonObject(fs17, path46.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
25484
25821
|
if (parsed === void 0) {
|
|
25485
25822
|
return void 0;
|
|
25486
25823
|
}
|
|
@@ -25498,11 +25835,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25498
25835
|
if (id === void 0) {
|
|
25499
25836
|
throw new Error(`No identity named "${deps.identity}".`);
|
|
25500
25837
|
}
|
|
25501
|
-
const identityDir =
|
|
25502
|
-
const credentialsFile =
|
|
25503
|
-
const claudeJsonFile =
|
|
25504
|
-
const recordDir =
|
|
25505
|
-
const recordFile2 =
|
|
25838
|
+
const identityDir = path46.join(deps.identitiesDir, id);
|
|
25839
|
+
const credentialsFile = path46.join(identityDir, CREDENTIALS_FILE2);
|
|
25840
|
+
const claudeJsonFile = path46.join(identityDir, CLAUDE_JSON2);
|
|
25841
|
+
const recordDir = path46.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
25842
|
+
const recordFile2 = path46.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
25506
25843
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
25507
25844
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
25508
25845
|
const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -25518,7 +25855,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25518
25855
|
const organizationUuid = deps.newUuid();
|
|
25519
25856
|
const accountUuid = deps.newUuid();
|
|
25520
25857
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
25521
|
-
deps.fs.mkdirPrivate(
|
|
25858
|
+
deps.fs.mkdirPrivate(path46.dirname(credentialsFile));
|
|
25522
25859
|
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)}
|
|
25523
25860
|
`);
|
|
25524
25861
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -25556,7 +25893,7 @@ init_ensure2();
|
|
|
25556
25893
|
// src/frontdoor/liveSessionRegistry.ts
|
|
25557
25894
|
init_capability();
|
|
25558
25895
|
init_state();
|
|
25559
|
-
import
|
|
25896
|
+
import path47 from "node:path";
|
|
25560
25897
|
function sameStat(recorded, current) {
|
|
25561
25898
|
return recorded?.mtimeMs === current.mtimeMs && recorded.sizeBytes === current.sizeBytes;
|
|
25562
25899
|
}
|
|
@@ -25578,7 +25915,7 @@ function createLiveSessionRegistry(ports) {
|
|
|
25578
25915
|
const load = (name, stat) => {
|
|
25579
25916
|
known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs17, sessionsDir, name) });
|
|
25580
25917
|
};
|
|
25581
|
-
const statOf = (name) => fs17.lstat(
|
|
25918
|
+
const statOf = (name) => fs17.lstat(path47.join(sessionsDir, name));
|
|
25582
25919
|
const reconcile = () => {
|
|
25583
25920
|
const names = new Set(recordNames());
|
|
25584
25921
|
let changed = false;
|
|
@@ -25653,8 +25990,8 @@ init_liveTasks();
|
|
|
25653
25990
|
|
|
25654
25991
|
// src/agents/read.ts
|
|
25655
25992
|
init_schema3();
|
|
25656
|
-
import
|
|
25657
|
-
import { z as
|
|
25993
|
+
import path48 from "node:path";
|
|
25994
|
+
import { z as z47 } from "zod";
|
|
25658
25995
|
var PROJECTS_DIR = "projects";
|
|
25659
25996
|
var TASKS_DIR = "tasks";
|
|
25660
25997
|
var SUBAGENTS_DIR = "subagents";
|
|
@@ -25679,15 +26016,15 @@ function parseEntry2(project, entry) {
|
|
|
25679
26016
|
}
|
|
25680
26017
|
function listSessions2(fs17, configDir) {
|
|
25681
26018
|
const found = [];
|
|
25682
|
-
for (const project of fs17.readdir(
|
|
25683
|
-
const projectDir =
|
|
26019
|
+
for (const project of fs17.readdir(path48.join(configDir, PROJECTS_DIR))) {
|
|
26020
|
+
const projectDir = path48.join(configDir, PROJECTS_DIR, project);
|
|
25684
26021
|
const entries = /* @__PURE__ */ new Set();
|
|
25685
26022
|
for (const name of fs17.readdir(projectDir)) {
|
|
25686
26023
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
25687
26024
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
25688
26025
|
continue;
|
|
25689
26026
|
}
|
|
25690
|
-
const children = fs17.readdir(
|
|
26027
|
+
const children = fs17.readdir(path48.join(projectDir, name));
|
|
25691
26028
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
25692
26029
|
entries.add(name);
|
|
25693
26030
|
}
|
|
@@ -25707,8 +26044,8 @@ function locateAgents(fs17, configDir, relativeDir, workflowRunId, report) {
|
|
|
25707
26044
|
const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
|
|
25708
26045
|
located.push({
|
|
25709
26046
|
id,
|
|
25710
|
-
metaPath:
|
|
25711
|
-
transcriptPath:
|
|
26047
|
+
metaPath: path48.join(relativeDir, name),
|
|
26048
|
+
transcriptPath: path48.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
|
|
25712
26049
|
workflowRunId
|
|
25713
26050
|
});
|
|
25714
26051
|
}
|
|
@@ -25751,7 +26088,7 @@ function describeFailure(error) {
|
|
|
25751
26088
|
}
|
|
25752
26089
|
function readFileOrReport(fs17, configDir, relative, report) {
|
|
25753
26090
|
try {
|
|
25754
|
-
return fs17.readFileUtf8(
|
|
26091
|
+
return fs17.readFileUtf8(path48.join(configDir, relative));
|
|
25755
26092
|
} catch (error) {
|
|
25756
26093
|
report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
|
|
25757
26094
|
return void 0;
|
|
@@ -25759,7 +26096,7 @@ function readFileOrReport(fs17, configDir, relative, report) {
|
|
|
25759
26096
|
}
|
|
25760
26097
|
function listDirOrReport(fs17, configDir, relative, report) {
|
|
25761
26098
|
try {
|
|
25762
|
-
return fs17.readdir(
|
|
26099
|
+
return fs17.readdir(path48.join(configDir, relative));
|
|
25763
26100
|
} catch (error) {
|
|
25764
26101
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
|
|
25765
26102
|
return [];
|
|
@@ -25773,28 +26110,28 @@ function parseJson2(text) {
|
|
|
25773
26110
|
return void 0;
|
|
25774
26111
|
}
|
|
25775
26112
|
}
|
|
25776
|
-
var TaskFileSchema =
|
|
25777
|
-
var WorkflowRunFileSchema =
|
|
25778
|
-
runId:
|
|
25779
|
-
workflowName:
|
|
25780
|
-
status:
|
|
25781
|
-
startTime:
|
|
25782
|
-
phases:
|
|
25783
|
-
summary:
|
|
26113
|
+
var TaskFileSchema = z47.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: z47.array(z47.string()).default([]), blockedBy: z47.array(z47.string()).default([]) });
|
|
26114
|
+
var WorkflowRunFileSchema = z47.object({
|
|
26115
|
+
runId: z47.string(),
|
|
26116
|
+
workflowName: z47.string().optional(),
|
|
26117
|
+
status: z47.string().optional(),
|
|
26118
|
+
startTime: z47.number().optional(),
|
|
26119
|
+
phases: z47.array(z47.object({ title: z47.string() })).default([]),
|
|
26120
|
+
summary: z47.string().optional()
|
|
25784
26121
|
});
|
|
25785
26122
|
function summariseSession(fs17, configDir, ref) {
|
|
25786
|
-
const sessionRelative =
|
|
25787
|
-
const subagentsRelative =
|
|
25788
|
-
const workflowsUnderSubagents =
|
|
26123
|
+
const sessionRelative = path48.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26124
|
+
const subagentsRelative = path48.join(sessionRelative, SUBAGENTS_DIR);
|
|
26125
|
+
const workflowsUnderSubagents = path48.join(subagentsRelative, WORKFLOWS_DIR);
|
|
25789
26126
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
25790
|
-
let agentCount = fs17.readdir(
|
|
25791
|
-
for (const runDir of fs17.readdir(
|
|
26127
|
+
let agentCount = fs17.readdir(path48.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
26128
|
+
for (const runDir of fs17.readdir(path48.join(configDir, workflowsUnderSubagents))) {
|
|
25792
26129
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
25793
|
-
agentCount += fs17.readdir(
|
|
26130
|
+
agentCount += fs17.readdir(path48.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
25794
26131
|
}
|
|
25795
26132
|
}
|
|
25796
|
-
const workflowRunCount = fs17.readdir(
|
|
25797
|
-
const transcript = fs17.lstat(
|
|
26133
|
+
const workflowRunCount = fs17.readdir(path48.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
|
|
26134
|
+
const transcript = fs17.lstat(path48.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
25798
26135
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
25799
26136
|
}
|
|
25800
26137
|
function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
@@ -25802,13 +26139,13 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
25802
26139
|
const report = (problem) => {
|
|
25803
26140
|
problems.push(problem);
|
|
25804
26141
|
};
|
|
25805
|
-
const sessionRelative =
|
|
25806
|
-
const subagentsRelative =
|
|
25807
|
-
const workflowsUnderSubagents =
|
|
26142
|
+
const sessionRelative = path48.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26143
|
+
const subagentsRelative = path48.join(sessionRelative, SUBAGENTS_DIR);
|
|
26144
|
+
const workflowsUnderSubagents = path48.join(subagentsRelative, WORKFLOWS_DIR);
|
|
25808
26145
|
const located = locateAgents(fs17, configDir, subagentsRelative, void 0, report);
|
|
25809
26146
|
for (const runDir of listDirOrReport(fs17, configDir, workflowsUnderSubagents, report)) {
|
|
25810
26147
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
25811
|
-
located.push(...locateAgents(fs17, configDir,
|
|
26148
|
+
located.push(...locateAgents(fs17, configDir, path48.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
25812
26149
|
}
|
|
25813
26150
|
}
|
|
25814
26151
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -25849,7 +26186,7 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
25849
26186
|
superseded: ref.superseded,
|
|
25850
26187
|
agents: roots.sort().map(build),
|
|
25851
26188
|
tasks: readTasks(fs17, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
|
|
25852
|
-
workflowRuns: readWorkflowRuns(fs17, configDir,
|
|
26189
|
+
workflowRuns: readWorkflowRuns(fs17, configDir, path48.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
25853
26190
|
problems
|
|
25854
26191
|
};
|
|
25855
26192
|
}
|
|
@@ -25914,12 +26251,12 @@ function ownTaskLists(sessionId) {
|
|
|
25914
26251
|
function readTasks(fs17, configDir, ownLists, sharedLists, report) {
|
|
25915
26252
|
const tasks = [];
|
|
25916
26253
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
25917
|
-
const relativeDir =
|
|
26254
|
+
const relativeDir = path48.join(TASKS_DIR, scope);
|
|
25918
26255
|
for (const name of [...listDirOrReport(fs17, configDir, relativeDir, report)].sort()) {
|
|
25919
26256
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
25920
26257
|
continue;
|
|
25921
26258
|
}
|
|
25922
|
-
const relative =
|
|
26259
|
+
const relative = path48.join(relativeDir, name);
|
|
25923
26260
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
25924
26261
|
const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
25925
26262
|
if (parsed.success) {
|
|
@@ -25937,7 +26274,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
25937
26274
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
25938
26275
|
continue;
|
|
25939
26276
|
}
|
|
25940
|
-
const relative =
|
|
26277
|
+
const relative = path48.join(relativeDir, name);
|
|
25941
26278
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
25942
26279
|
const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
25943
26280
|
if (!parsed.success) {
|
|
@@ -25954,7 +26291,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
25954
26291
|
|
|
25955
26292
|
// src/agents/sessions.ts
|
|
25956
26293
|
init_cliError();
|
|
25957
|
-
import
|
|
26294
|
+
import path49 from "node:path";
|
|
25958
26295
|
var SessionLookupError = class extends CliError {
|
|
25959
26296
|
constructor(message) {
|
|
25960
26297
|
super(message);
|
|
@@ -25965,7 +26302,7 @@ function historyStores(fs17, configDirOf, identities) {
|
|
|
25965
26302
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
25966
26303
|
for (const identity of identities) {
|
|
25967
26304
|
const configDir = configDirOf(identity);
|
|
25968
|
-
const real = fs17.realpath(
|
|
26305
|
+
const real = fs17.realpath(path49.join(configDir, "projects"));
|
|
25969
26306
|
if (real === void 0) {
|
|
25970
26307
|
continue;
|
|
25971
26308
|
}
|
|
@@ -26066,7 +26403,7 @@ init_load();
|
|
|
26066
26403
|
init_launchWiring();
|
|
26067
26404
|
init_argv();
|
|
26068
26405
|
init_cascade();
|
|
26069
|
-
|
|
26406
|
+
init_identity2();
|
|
26070
26407
|
import os13 from "node:os";
|
|
26071
26408
|
|
|
26072
26409
|
// src/launcher/poolRefresh.ts
|