claude-use 11.40.4 → 11.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cli.cjs +262 -31
- package/dist/index.cjs +1410 -1185
- package/dist/index.mjs +1766 -1541
- package/dist/types/index.d.ts +817 -454
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -248,7 +248,7 @@ function isTimeZone(name) {
|
|
|
248
248
|
return false;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
var import_node_path2, import_zod, import_trilean, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, HttpProviderSchema, CodexProviderSchema, RouterProviderSchema, AntigravityProviderSchema, ProviderSchema, SELECTION_MODES, VirtualModelSchema, ModelPricesSchema, ModelsConfigSchema, ModelsLayerSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_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;
|
|
251
|
+
var import_node_path2, import_zod, import_trilean, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, HttpProviderSchema, CodexProviderSchema, RouterProviderSchema, AntigravityProviderSchema, ProviderSchema, SELECTION_MODES, VirtualModelSchema, ModelPricesSchema, FamilySettingsSchema, ModelsConfigSchema, ModelsLayerSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_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;
|
|
252
252
|
var init_schema = __esm({
|
|
253
253
|
"src/config/schema.ts"() {
|
|
254
254
|
"use strict";
|
|
@@ -495,6 +495,14 @@ var init_schema = __esm({
|
|
|
495
495
|
input: import_zod.z.number().positive(),
|
|
496
496
|
output: import_zod.z.number().positive()
|
|
497
497
|
});
|
|
498
|
+
FamilySettingsSchema = import_zod.z.strictObject({
|
|
499
|
+
names: import_zod.z.array(import_zod.z.string().min(1)).optional(),
|
|
500
|
+
mode: import_zod.z.enum(SELECTION_MODES).optional(),
|
|
501
|
+
context: import_zod.z.number().int().positive().optional(),
|
|
502
|
+
vision: import_zod.z.boolean().optional(),
|
|
503
|
+
tools: import_zod.z.boolean().optional(),
|
|
504
|
+
thinking: import_zod.z.boolean().optional()
|
|
505
|
+
});
|
|
498
506
|
ModelsConfigSchema = import_zod.z.strictObject({
|
|
499
507
|
/** Virtual models, by name. */
|
|
500
508
|
virtual: import_zod.z.record(import_zod.z.string().min(1), VirtualModelSchema).optional(),
|
|
@@ -510,7 +518,13 @@ var init_schema = __esm({
|
|
|
510
518
|
/** Model refs hidden from the picker and from routing, whatever else names them. */
|
|
511
519
|
hide: import_zod.z.array(import_zod.z.string().min(1)).optional(),
|
|
512
520
|
/** When set, the only model refs visible; everything else is hidden. */
|
|
513
|
-
show: import_zod.z.array(import_zod.z.string().min(1)).optional()
|
|
521
|
+
show: import_zod.z.array(import_zod.z.string().min(1)).optional(),
|
|
522
|
+
/** Assertions that each group of refs is one model under several names, overriding what the names alone say. */
|
|
523
|
+
same: import_zod.z.array(import_zod.z.array(import_zod.z.string().min(1)).min(2)).optional(),
|
|
524
|
+
/** Assertions that each pair of refs is two models however alike their names look. */
|
|
525
|
+
distinct: import_zod.z.array(import_zod.z.tuple([import_zod.z.string().min(1), import_zod.z.string().min(1)])).optional(),
|
|
526
|
+
/** Per-family settings and the names the normaliser cannot know, by family key. */
|
|
527
|
+
families: import_zod.z.record(import_zod.z.string().min(1), FamilySettingsSchema).optional()
|
|
514
528
|
});
|
|
515
529
|
ModelsLayerSchema = import_zod.z.strictObject({
|
|
516
530
|
virtual: import_zod.z.record(import_zod.z.string().min(1), import_zod.z.union([VirtualModelSchema, import_zod.z.null()])).optional(),
|
|
@@ -522,7 +536,10 @@ var init_schema = __esm({
|
|
|
522
536
|
}).optional(),
|
|
523
537
|
prices: import_zod.z.record(import_zod.z.string().min(1), import_zod.z.union([ModelPricesSchema, import_zod.z.null()])).optional(),
|
|
524
538
|
hide: import_zod.z.array(import_zod.z.string().min(1)).optional(),
|
|
525
|
-
show: import_zod.z.array(import_zod.z.string().min(1)).optional()
|
|
539
|
+
show: import_zod.z.array(import_zod.z.string().min(1)).optional(),
|
|
540
|
+
same: import_zod.z.array(import_zod.z.array(import_zod.z.string().min(1)).min(2)).optional(),
|
|
541
|
+
distinct: import_zod.z.array(import_zod.z.tuple([import_zod.z.string().min(1), import_zod.z.string().min(1)])).optional(),
|
|
542
|
+
families: import_zod.z.record(import_zod.z.string().min(1), import_zod.z.union([FamilySettingsSchema, import_zod.z.null()])).optional()
|
|
526
543
|
});
|
|
527
544
|
ConfigProfileSchema = import_zod.z.strictObject({
|
|
528
545
|
$schema: import_zod.z.string().optional(),
|
|
@@ -1599,6 +1616,26 @@ function mergeModels(current, layer) {
|
|
|
1599
1616
|
if (layer.show !== void 0) {
|
|
1600
1617
|
pieces.show = layer.show;
|
|
1601
1618
|
}
|
|
1619
|
+
if (layer.same !== void 0) {
|
|
1620
|
+
pieces.same = [...current?.same ?? [], ...layer.same.filter((group) => !(current?.same ?? []).some((known) => known.length === group.length && known.every((ref, index) => ref === group[index])))];
|
|
1621
|
+
}
|
|
1622
|
+
if (layer.distinct !== void 0) {
|
|
1623
|
+
pieces.distinct = [...current?.distinct ?? [], ...layer.distinct.filter(([left, right]) => !(current?.distinct ?? []).some(([a, b]) => a === left && b === right))];
|
|
1624
|
+
}
|
|
1625
|
+
if (layer.families !== void 0) {
|
|
1626
|
+
const families = {};
|
|
1627
|
+
for (const [key, settings] of Object.entries(current?.families ?? {})) {
|
|
1628
|
+
if (layer.families[key] === void 0) {
|
|
1629
|
+
families[key] = settings;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
for (const [key, settings] of Object.entries(layer.families)) {
|
|
1633
|
+
if (settings !== null) {
|
|
1634
|
+
families[key] = settings;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
pieces.families = families;
|
|
1638
|
+
}
|
|
1602
1639
|
const merged = modelsOf(pieces);
|
|
1603
1640
|
return Object.keys(merged).length === 0 ? void 0 : merged;
|
|
1604
1641
|
}
|
|
@@ -1608,7 +1645,10 @@ function modelsOf(pieces) {
|
|
|
1608
1645
|
...pieces.tiers === void 0 || Object.keys(pieces.tiers).length === 0 ? {} : { tiers: pieces.tiers },
|
|
1609
1646
|
...pieces.prices === void 0 || Object.keys(pieces.prices).length === 0 ? {} : { prices: pieces.prices },
|
|
1610
1647
|
...pieces.hide === void 0 || pieces.hide.length === 0 ? {} : { hide: [...pieces.hide] },
|
|
1611
|
-
...pieces.show === void 0 || pieces.show.length === 0 ? {} : { show: [...pieces.show] }
|
|
1648
|
+
...pieces.show === void 0 || pieces.show.length === 0 ? {} : { show: [...pieces.show] },
|
|
1649
|
+
...pieces.same === void 0 || pieces.same.length === 0 ? {} : { same: pieces.same.map((group) => [...group]) },
|
|
1650
|
+
...pieces.distinct === void 0 || pieces.distinct.length === 0 ? {} : { distinct: pieces.distinct.map(([left, right]) => [left, right]) },
|
|
1651
|
+
...pieces.families === void 0 || Object.keys(pieces.families).length === 0 ? {} : { families: pieces.families }
|
|
1612
1652
|
};
|
|
1613
1653
|
}
|
|
1614
1654
|
var init_flatten = __esm({
|
|
@@ -3033,7 +3073,7 @@ var init_state = __esm({
|
|
|
3033
3073
|
"use strict";
|
|
3034
3074
|
import_node_path8 = __toESM(require("node:path"), 1);
|
|
3035
3075
|
import_zod3 = require("zod");
|
|
3036
|
-
FRONT_DOOR_PROTOCOL =
|
|
3076
|
+
FRONT_DOOR_PROTOCOL = 4;
|
|
3037
3077
|
FrontDoorSessionSchema = import_zod3.z.strictObject({ pid: import_zod3.z.number().int().positive(), startedAt: import_zod3.z.number(), token: import_zod3.z.string().min(1), supervisorPid: import_zod3.z.number().int().positive().optional() });
|
|
3038
3078
|
FrontDoorStateSchema = import_zod3.z.strictObject({
|
|
3039
3079
|
/**
|
|
@@ -3106,7 +3146,7 @@ var init_package = __esm({
|
|
|
3106
3146
|
"package.json"() {
|
|
3107
3147
|
package_default = {
|
|
3108
3148
|
name: "claude-use",
|
|
3109
|
-
version: "11.
|
|
3149
|
+
version: "11.41.0",
|
|
3110
3150
|
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.",
|
|
3111
3151
|
license: "MIT",
|
|
3112
3152
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -7602,205 +7642,688 @@ var init_modelsStore = __esm({
|
|
|
7602
7642
|
}
|
|
7603
7643
|
});
|
|
7604
7644
|
|
|
7605
|
-
// src/
|
|
7606
|
-
function
|
|
7607
|
-
|
|
7608
|
-
return runProbeWorker(PROBE_SOURCE, { port, ca: caPem });
|
|
7645
|
+
// src/models/identity.ts
|
|
7646
|
+
function withoutContextMarker(model) {
|
|
7647
|
+
return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? model.slice(0, -CONTEXT_MARKER_1M.length) : model;
|
|
7609
7648
|
}
|
|
7610
|
-
function
|
|
7611
|
-
|
|
7612
|
-
return runProbeWorker(ACCEPT_PROBE_SOURCE, { port });
|
|
7649
|
+
function canonicalText(name) {
|
|
7650
|
+
return name.trim().toLowerCase().replace(NON_IDENTITY_BRACKET_RE, "").replace(/[\s_]+/g, "-").replace(/([a-z])(\d+(?:\.\d+)+)/g, "$1-$2").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
7613
7651
|
}
|
|
7614
|
-
function
|
|
7615
|
-
const
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
worker.unref();
|
|
7622
|
-
try {
|
|
7623
|
-
const waited = Atomics.wait(header, 0, VERDICT_PENDING, PROBE_TIMEOUT_MS + PROBE_WAIT_MARGIN_MS);
|
|
7624
|
-
const verdict = Atomics.load(header, 0);
|
|
7625
|
-
if (waited === "timed-out" || verdict === VERDICT_PENDING) {
|
|
7626
|
-
return { ok: false, reason: `the probe did not finish within ${String(PROBE_TIMEOUT_MS + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
7652
|
+
function splitVariants(tokens) {
|
|
7653
|
+
const variants = [];
|
|
7654
|
+
let end = tokens.length;
|
|
7655
|
+
for (; ; ) {
|
|
7656
|
+
const token = tokens[end - 1];
|
|
7657
|
+
if (token === void 0 || !KNOWN_VARIANTS.has(token)) {
|
|
7658
|
+
return { familyTokens: tokens.slice(0, end), variants };
|
|
7627
7659
|
}
|
|
7628
|
-
|
|
7629
|
-
|
|
7660
|
+
variants.unshift(token);
|
|
7661
|
+
end -= 1;
|
|
7662
|
+
}
|
|
7663
|
+
}
|
|
7664
|
+
function versionOf(tokens) {
|
|
7665
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
7666
|
+
const token = tokens[index];
|
|
7667
|
+
const next = tokens[index + 1];
|
|
7668
|
+
if (token === void 0) {
|
|
7669
|
+
return "";
|
|
7670
|
+
}
|
|
7671
|
+
if (/^\d+$/.test(token) && next !== void 0 && /^\d+$/.test(next)) {
|
|
7672
|
+
return `${token}.${next}`;
|
|
7673
|
+
}
|
|
7674
|
+
const dotted = /^\d+(?:\.\d+)+$/.exec(token);
|
|
7675
|
+
if (dotted !== null) {
|
|
7676
|
+
return dotted[0];
|
|
7630
7677
|
}
|
|
7631
|
-
const length = Atomics.load(header, 1);
|
|
7632
|
-
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
7633
|
-
} finally {
|
|
7634
|
-
void worker.terminate();
|
|
7635
7678
|
}
|
|
7679
|
+
return "";
|
|
7636
7680
|
}
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
"
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
const https = require("node:https");
|
|
7654
|
-
const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
7655
|
-
const header = new Int32Array(shared, 0, headerSlots);
|
|
7656
|
-
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
7657
|
-
let done = false;
|
|
7658
|
-
const finish = (verdict, message) => {
|
|
7659
|
-
if (done) return;
|
|
7660
|
-
done = true;
|
|
7661
|
-
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
7662
|
-
reason.set(bytes);
|
|
7663
|
-
Atomics.store(header, 1, bytes.length);
|
|
7664
|
-
Atomics.store(header, 0, verdict);
|
|
7665
|
-
Atomics.notify(header, 0);
|
|
7666
|
-
};
|
|
7667
|
-
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
7668
|
-
let body = "";
|
|
7669
|
-
response.setEncoding("utf8");
|
|
7670
|
-
response.on("data", (chunk) => { body += chunk; });
|
|
7671
|
-
response.on("end", () => {
|
|
7672
|
-
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
7673
|
-
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
7681
|
+
function modelIdentity(rawName) {
|
|
7682
|
+
const segments = rawName.trim().toLowerCase().split("/");
|
|
7683
|
+
const stripped = canonicalText(segments[segments.length - 1] ?? "").split(":")[0] ?? "";
|
|
7684
|
+
const withoutDate = stripped.replace(DATE_STAMP_RE, "");
|
|
7685
|
+
const tokens = withoutDate.split("-").filter((token) => token !== "");
|
|
7686
|
+
const { familyTokens, variants } = splitVariants(tokens);
|
|
7687
|
+
const version = versionOf(familyTokens);
|
|
7688
|
+
const versionless = familyTokens.filter((token, index) => {
|
|
7689
|
+
if (version === "") {
|
|
7690
|
+
return true;
|
|
7691
|
+
}
|
|
7692
|
+
const dotted = /^\d+(?:\.\d+)+$/.test(token);
|
|
7693
|
+
const previous = familyTokens[index - 1];
|
|
7694
|
+
const next = familyTokens[index + 1];
|
|
7695
|
+
const insideVersionRun = dotted || /^\d+$/.test(token) && (previous !== void 0 && /^\d+$/.test(previous) || next !== void 0 && /^\d+$/.test(next));
|
|
7696
|
+
return !insideVersionRun;
|
|
7674
7697
|
});
|
|
7675
|
-
|
|
7698
|
+
const family = versionless.join("-");
|
|
7699
|
+
const tokenVendor = familyTokens.find((token) => Object.keys(VENDOR_BY_TOKEN).some((key) => token === key || token.startsWith(key)));
|
|
7700
|
+
const namespace = segments.length >= 2 ? (segments[0] ?? "").split(":").pop() ?? "" : "";
|
|
7701
|
+
const namespaceVendor = VENDOR_BY_NAMESPACE[namespace] ?? "";
|
|
7702
|
+
const tokenVendorName = tokenVendor === void 0 ? "" : VENDOR_BY_TOKEN[Object.keys(VENDOR_BY_TOKEN).find((key) => tokenVendor === key || tokenVendor.startsWith(key)) ?? ""] ?? "";
|
|
7703
|
+
return {
|
|
7704
|
+
vendor: tokenVendorName === "" ? namespaceVendor : tokenVendorName,
|
|
7705
|
+
vendorConflict: tokenVendorName !== "" && namespaceVendor !== "" && tokenVendorName !== namespaceVendor,
|
|
7706
|
+
family,
|
|
7707
|
+
version,
|
|
7708
|
+
variant: variants.join("-"),
|
|
7709
|
+
familyAndVersion: version === "" ? family : `${family}-${version.replace(/\./g, "-")}`
|
|
7710
|
+
};
|
|
7711
|
+
}
|
|
7712
|
+
function relateModels(left, right) {
|
|
7713
|
+
const a = modelIdentity(left);
|
|
7714
|
+
const b = modelIdentity(right);
|
|
7715
|
+
if (a.familyAndVersion !== b.familyAndVersion) {
|
|
7716
|
+
return sameFamilyOtherVersion(a, b) ? "similar" : "distinct";
|
|
7717
|
+
}
|
|
7718
|
+
if (a.variant !== b.variant || a.vendorConflict || b.vendorConflict || a.vendor !== "" && b.vendor !== "" && a.vendor !== b.vendor) {
|
|
7719
|
+
return "similar";
|
|
7720
|
+
}
|
|
7721
|
+
return "same";
|
|
7722
|
+
}
|
|
7723
|
+
function sameFamilyOtherVersion(a, b) {
|
|
7724
|
+
if (a.family !== b.family) {
|
|
7725
|
+
return false;
|
|
7726
|
+
}
|
|
7727
|
+
if (a.vendor !== "" && b.vendor !== "" && a.vendor !== b.vendor) {
|
|
7728
|
+
return false;
|
|
7729
|
+
}
|
|
7730
|
+
return true;
|
|
7731
|
+
}
|
|
7732
|
+
var NON_IDENTITY_BRACKET_RE, CONTEXT_MARKER_1M, DATE_STAMP_RE, KNOWN_VARIANTS, VENDOR_BY_NAMESPACE, VENDOR_BY_TOKEN;
|
|
7733
|
+
var init_identity2 = __esm({
|
|
7734
|
+
"src/models/identity.ts"() {
|
|
7735
|
+
"use strict";
|
|
7736
|
+
NON_IDENTITY_BRACKET_RE = /\[[^\]]*\]/g;
|
|
7737
|
+
CONTEXT_MARKER_1M = "[1m]";
|
|
7738
|
+
DATE_STAMP_RE = /-(?:19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/;
|
|
7739
|
+
KNOWN_VARIANTS = /* @__PURE__ */ new Set(["high", "medium", "low", "thinking", "xhigh", "max", "highspeed", "sol", "terra", "luna", "mini", "flash-lite", "turbo"]);
|
|
7740
|
+
VENDOR_BY_NAMESPACE = Object.freeze({
|
|
7741
|
+
anthropic: "anthropic",
|
|
7742
|
+
google: "google",
|
|
7743
|
+
openai: "openai",
|
|
7744
|
+
zai: "zai",
|
|
7745
|
+
"z-ai": "zai",
|
|
7746
|
+
minimax: "minimax",
|
|
7747
|
+
qwen: "qwen",
|
|
7748
|
+
deepseek: "deepseek",
|
|
7749
|
+
moonshot: "moonshot",
|
|
7750
|
+
meta: "meta",
|
|
7751
|
+
mistral: "mistral"
|
|
7752
|
+
});
|
|
7753
|
+
VENDOR_BY_TOKEN = Object.freeze({
|
|
7754
|
+
claude: "anthropic",
|
|
7755
|
+
gemini: "google",
|
|
7756
|
+
antigravity: "google",
|
|
7757
|
+
gpt: "openai",
|
|
7758
|
+
glm: "zai",
|
|
7759
|
+
minimax: "minimax",
|
|
7760
|
+
qwen: "qwen",
|
|
7761
|
+
deepseek: "deepseek",
|
|
7762
|
+
kimi: "moonshot",
|
|
7763
|
+
llama: "meta",
|
|
7764
|
+
mistral: "mistral",
|
|
7765
|
+
mixtral: "mistral"
|
|
7766
|
+
});
|
|
7767
|
+
}
|
|
7676
7768
|
});
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
const { workerData } = require("node:worker_threads");
|
|
7683
|
-
const net = require("node:net");
|
|
7684
|
-
const { port, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
7685
|
-
const header = new Int32Array(shared, 0, headerSlots);
|
|
7686
|
-
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
7687
|
-
let done = false;
|
|
7688
|
-
const finish = (verdict, message) => {
|
|
7689
|
-
if (done) return;
|
|
7690
|
-
done = true;
|
|
7691
|
-
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
7692
|
-
reason.set(bytes);
|
|
7693
|
-
Atomics.store(header, 1, bytes.length);
|
|
7694
|
-
Atomics.store(header, 0, verdict);
|
|
7695
|
-
Atomics.notify(header, 0);
|
|
7696
|
-
};
|
|
7697
|
-
const socket = net.connect({ host: "127.0.0.1", port });
|
|
7698
|
-
socket.once("connect", () => { socket.destroy(); finish(ok, ""); });
|
|
7699
|
-
socket.once("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
7700
|
-
setTimeout(() => { socket.destroy(); finish(failed, "no connection accepted within " + String(timeoutMs) + "ms"); }, timeoutMs);
|
|
7701
|
-
`;
|
|
7769
|
+
|
|
7770
|
+
// src/selection/engine.ts
|
|
7771
|
+
var init_engine = __esm({
|
|
7772
|
+
"src/selection/engine.ts"() {
|
|
7773
|
+
"use strict";
|
|
7702
7774
|
}
|
|
7703
7775
|
});
|
|
7704
7776
|
|
|
7705
|
-
// src/
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
|
|
7709
|
-
if (match === null) {
|
|
7710
|
-
throw new Error(`not a plain release version: ${version}`);
|
|
7711
|
-
}
|
|
7712
|
-
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
7713
|
-
};
|
|
7714
|
-
const leftParts = parse(left);
|
|
7715
|
-
const rightParts = parse(right);
|
|
7716
|
-
return leftParts.map((part, index) => part - (rightParts[index] ?? 0)).find((difference) => difference !== 0) ?? 0;
|
|
7717
|
-
}
|
|
7718
|
-
function releaseTagFromUrl(url) {
|
|
7719
|
-
const segment = url.split("?")[0]?.split("/").at(-1);
|
|
7720
|
-
const candidate = segment?.startsWith("v") === true ? segment.slice(1) : void 0;
|
|
7721
|
-
return candidate !== void 0 && /^\d+\.\d+\.\d+$/.test(candidate) ? candidate : void 0;
|
|
7722
|
-
}
|
|
7723
|
-
var LATEST_RELEASE_URL, UpdateChannelError, UpdateConflictError, UpdateDownloadError;
|
|
7724
|
-
var init_update = __esm({
|
|
7725
|
-
"src/update/update.ts"() {
|
|
7777
|
+
// src/antigravity/cloudUpstream.ts
|
|
7778
|
+
var init_cloudUpstream = __esm({
|
|
7779
|
+
"src/antigravity/cloudUpstream.ts"() {
|
|
7726
7780
|
"use strict";
|
|
7727
|
-
init_cliError();
|
|
7728
|
-
LATEST_RELEASE_URL = "https://github.com/ExaDev/agent-shim/releases/latest";
|
|
7729
|
-
UpdateChannelError = class extends CliError {
|
|
7730
|
-
constructor(message) {
|
|
7731
|
-
super(message);
|
|
7732
|
-
this.name = "UpdateChannelError";
|
|
7733
|
-
}
|
|
7734
|
-
};
|
|
7735
|
-
UpdateConflictError = class extends CliError {
|
|
7736
|
-
constructor(message) {
|
|
7737
|
-
super(message);
|
|
7738
|
-
this.name = "UpdateConflictError";
|
|
7739
|
-
}
|
|
7740
|
-
};
|
|
7741
|
-
UpdateDownloadError = class extends CliError {
|
|
7742
|
-
constructor(message) {
|
|
7743
|
-
super(message);
|
|
7744
|
-
this.name = "UpdateDownloadError";
|
|
7745
|
-
}
|
|
7746
|
-
};
|
|
7747
7781
|
}
|
|
7748
7782
|
});
|
|
7749
7783
|
|
|
7750
|
-
// src/
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
}
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7784
|
+
// src/antigravity/quota.ts
|
|
7785
|
+
var SECONDS_PER_HOUR, HOURS_PER_FIVE_HOUR_WINDOW, DAYS_PER_WEEK, HOURS_PER_DAY4, FIVE_HOUR_PERIOD_SECONDS, WEEK_PERIOD_SECONDS;
|
|
7786
|
+
var init_quota = __esm({
|
|
7787
|
+
"src/antigravity/quota.ts"() {
|
|
7788
|
+
"use strict";
|
|
7789
|
+
init_cloudUpstream();
|
|
7790
|
+
SECONDS_PER_HOUR = 3600;
|
|
7791
|
+
HOURS_PER_FIVE_HOUR_WINDOW = 5;
|
|
7792
|
+
DAYS_PER_WEEK = 7;
|
|
7793
|
+
HOURS_PER_DAY4 = 24;
|
|
7794
|
+
FIVE_HOUR_PERIOD_SECONDS = HOURS_PER_FIVE_HOUR_WINDOW * SECONDS_PER_HOUR;
|
|
7795
|
+
WEEK_PERIOD_SECONDS = DAYS_PER_WEEK * HOURS_PER_DAY4 * SECONDS_PER_HOUR;
|
|
7796
|
+
}
|
|
7797
|
+
});
|
|
7798
|
+
|
|
7799
|
+
// src/antigravity/signatures.ts
|
|
7800
|
+
var init_signatures = __esm({
|
|
7801
|
+
"src/antigravity/signatures.ts"() {
|
|
7802
|
+
"use strict";
|
|
7803
|
+
}
|
|
7804
|
+
});
|
|
7805
|
+
|
|
7806
|
+
// src/codex/anthropic.ts
|
|
7807
|
+
var import_zod23, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
7808
|
+
var init_anthropic = __esm({
|
|
7809
|
+
"src/codex/anthropic.ts"() {
|
|
7810
|
+
"use strict";
|
|
7811
|
+
import_zod23 = require("zod");
|
|
7812
|
+
TextBlockSchema = import_zod23.z.looseObject({ type: import_zod23.z.literal("text"), text: import_zod23.z.string() });
|
|
7813
|
+
Base64ImageSourceSchema = import_zod23.z.looseObject({ type: import_zod23.z.literal("base64"), media_type: import_zod23.z.string().min(1), data: import_zod23.z.string() });
|
|
7814
|
+
UrlImageSourceSchema = import_zod23.z.looseObject({ type: import_zod23.z.literal("url"), url: import_zod23.z.string().min(1) });
|
|
7815
|
+
ImageBlockSchema = import_zod23.z.looseObject({
|
|
7816
|
+
type: import_zod23.z.literal("image"),
|
|
7817
|
+
source: import_zod23.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
7818
|
+
});
|
|
7819
|
+
ToolUseBlockSchema = import_zod23.z.looseObject({
|
|
7820
|
+
type: import_zod23.z.literal("tool_use"),
|
|
7821
|
+
id: import_zod23.z.string().min(1),
|
|
7822
|
+
name: import_zod23.z.string().min(1),
|
|
7823
|
+
input: import_zod23.z.unknown()
|
|
7824
|
+
});
|
|
7825
|
+
ToolResultContentBlockSchema = import_zod23.z.union([TextBlockSchema, import_zod23.z.looseObject({ type: import_zod23.z.string() })]);
|
|
7826
|
+
ToolResultBlockSchema = import_zod23.z.looseObject({
|
|
7827
|
+
type: import_zod23.z.literal("tool_result"),
|
|
7828
|
+
tool_use_id: import_zod23.z.string().min(1),
|
|
7829
|
+
content: import_zod23.z.union([import_zod23.z.string(), import_zod23.z.array(ToolResultContentBlockSchema)]).optional()
|
|
7830
|
+
});
|
|
7831
|
+
OtherBlockSchema = import_zod23.z.looseObject({ type: import_zod23.z.string() });
|
|
7832
|
+
ContentBlockSchema = import_zod23.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
7833
|
+
MessageSchema = import_zod23.z.looseObject({
|
|
7834
|
+
role: import_zod23.z.enum(["user", "assistant", "system"]),
|
|
7835
|
+
content: import_zod23.z.union([import_zod23.z.string(), import_zod23.z.array(ContentBlockSchema)])
|
|
7836
|
+
});
|
|
7837
|
+
ToolSchema = import_zod23.z.looseObject({
|
|
7838
|
+
name: import_zod23.z.string().min(1),
|
|
7839
|
+
description: import_zod23.z.string().optional(),
|
|
7840
|
+
input_schema: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.unknown()).optional()
|
|
7841
|
+
});
|
|
7842
|
+
ToolChoiceSchema = import_zod23.z.union([
|
|
7843
|
+
import_zod23.z.looseObject({ type: import_zod23.z.enum(["auto", "none", "any"]) }),
|
|
7844
|
+
import_zod23.z.looseObject({ type: import_zod23.z.literal("tool"), name: import_zod23.z.string().min(1) })
|
|
7845
|
+
]);
|
|
7846
|
+
SystemSchema = import_zod23.z.union([import_zod23.z.string(), import_zod23.z.array(import_zod23.z.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
7847
|
+
MessagesRequestSchema = import_zod23.z.looseObject({
|
|
7848
|
+
model: import_zod23.z.string().optional(),
|
|
7849
|
+
system: SystemSchema.optional(),
|
|
7850
|
+
messages: import_zod23.z.array(MessageSchema),
|
|
7851
|
+
tools: import_zod23.z.array(ToolSchema).optional(),
|
|
7852
|
+
tool_choice: ToolChoiceSchema.optional(),
|
|
7853
|
+
stream: import_zod23.z.boolean().optional(),
|
|
7854
|
+
/** `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. */
|
|
7855
|
+
metadata: import_zod23.z.looseObject({ user_id: import_zod23.z.string().optional() }).optional(),
|
|
7856
|
+
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
7857
|
+
output_config: import_zod23.z.looseObject({ effort: import_zod23.z.string().optional() }).optional()
|
|
7858
|
+
});
|
|
7859
|
+
CountTokensRequestSchema = import_zod23.z.looseObject({
|
|
7860
|
+
system: import_zod23.z.unknown().optional(),
|
|
7861
|
+
messages: import_zod23.z.unknown().optional(),
|
|
7862
|
+
tools: import_zod23.z.unknown().optional()
|
|
7863
|
+
});
|
|
7864
|
+
}
|
|
7865
|
+
});
|
|
7866
|
+
|
|
7867
|
+
// src/antigravity/translate.ts
|
|
7868
|
+
function candidatesOf(target) {
|
|
7869
|
+
return typeof target === "string" ? [target] : target;
|
|
7870
|
+
}
|
|
7871
|
+
function isAntigravityTier(key) {
|
|
7872
|
+
return CLAUDE_TIERS.some((tier) => tier === key);
|
|
7873
|
+
}
|
|
7874
|
+
function resolveAntigravityConfig(config) {
|
|
7875
|
+
const overrides = config?.models ?? {};
|
|
7876
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
7877
|
+
for (const [key, target] of Object.entries(overrides)) {
|
|
7878
|
+
if (!isAntigravityTier(key)) {
|
|
7879
|
+
aliases.set(key.toLowerCase(), candidatesOf(target));
|
|
7880
|
+
}
|
|
7881
|
+
}
|
|
7882
|
+
const tierModel = (tier) => {
|
|
7883
|
+
const target = overrides[tier];
|
|
7884
|
+
return target === void 0 ? ANTIGRAVITY_DEFAULT_TIER_MODELS[tier] : candidatesOf(target);
|
|
7885
|
+
};
|
|
7886
|
+
if (!aliases.has(AUTO_ALIAS)) {
|
|
7887
|
+
aliases.set(AUTO_ALIAS, [...new Set(CLAUDE_TIERS.flatMap(tierModel))]);
|
|
7888
|
+
}
|
|
7889
|
+
return {
|
|
7890
|
+
mode: config?.mode ?? ANTIGRAVITY_DEFAULT_MODE,
|
|
7891
|
+
defaultModel: config?.defaultModel ?? ANTIGRAVITY_DEFAULT_MODEL,
|
|
7892
|
+
models: { fable: tierModel("fable"), opus: tierModel("opus"), sonnet: tierModel("sonnet"), haiku: tierModel("haiku") },
|
|
7893
|
+
aliases,
|
|
7894
|
+
degradeDownTiers: config?.degradeDownTiers ?? false,
|
|
7895
|
+
effort: config?.effort ?? ANTIGRAVITY_DEFAULT_EFFORT,
|
|
7896
|
+
cloud: {
|
|
7897
|
+
endpoint: config?.cloud?.endpoint,
|
|
7898
|
+
projectId: config?.cloud?.projectId,
|
|
7899
|
+
location: config?.cloud?.location
|
|
7900
|
+
},
|
|
7901
|
+
local: {
|
|
7902
|
+
command: config?.local?.command,
|
|
7903
|
+
socketPath: config?.local?.socketPath
|
|
7904
|
+
}
|
|
7905
|
+
};
|
|
7906
|
+
}
|
|
7907
|
+
var AUTO_ALIAS;
|
|
7908
|
+
var init_translate = __esm({
|
|
7909
|
+
"src/antigravity/translate.ts"() {
|
|
7910
|
+
"use strict";
|
|
7911
|
+
init_identity2();
|
|
7912
|
+
init_engine();
|
|
7913
|
+
init_quota();
|
|
7914
|
+
init_signatures();
|
|
7915
|
+
init_schema();
|
|
7916
|
+
init_anthropic();
|
|
7917
|
+
AUTO_ALIAS = "auto";
|
|
7918
|
+
}
|
|
7919
|
+
});
|
|
7920
|
+
|
|
7921
|
+
// src/codex/translate.ts
|
|
7922
|
+
function resolveCodexConfig(config) {
|
|
7923
|
+
const overrides = config?.models;
|
|
7924
|
+
return {
|
|
7925
|
+
defaultModel: config?.defaultModel ?? CODEX_DEFAULT_MODEL,
|
|
7926
|
+
models: {
|
|
7927
|
+
fable: overrides?.fable ?? CODEX_DEFAULT_TIER_MODELS.fable,
|
|
7928
|
+
opus: overrides?.opus ?? CODEX_DEFAULT_TIER_MODELS.opus,
|
|
7929
|
+
sonnet: overrides?.sonnet ?? CODEX_DEFAULT_TIER_MODELS.sonnet,
|
|
7930
|
+
haiku: overrides?.haiku ?? CODEX_DEFAULT_TIER_MODELS.haiku
|
|
7931
|
+
},
|
|
7932
|
+
effort: config?.effort ?? CODEX_DEFAULT_EFFORT,
|
|
7933
|
+
login: config?.login ?? CODEX_DEFAULT_LOGIN
|
|
7934
|
+
};
|
|
7935
|
+
}
|
|
7936
|
+
var init_translate2 = __esm({
|
|
7937
|
+
"src/codex/translate.ts"() {
|
|
7938
|
+
"use strict";
|
|
7939
|
+
init_schema();
|
|
7940
|
+
init_anthropic();
|
|
7941
|
+
}
|
|
7942
|
+
});
|
|
7943
|
+
|
|
7944
|
+
// src/providerCatalogue.ts
|
|
7945
|
+
function catalogueCachePath(paths, name) {
|
|
7946
|
+
return import_node_path30.default.join(paths.catalogueDir, `${name}.json`);
|
|
7947
|
+
}
|
|
7948
|
+
function parseCatalogueCache(text) {
|
|
7949
|
+
if (text === void 0) {
|
|
7950
|
+
return void 0;
|
|
7951
|
+
}
|
|
7952
|
+
try {
|
|
7953
|
+
const parsed = CatalogueCacheSchema.safeParse(JSON.parse(text));
|
|
7954
|
+
return parsed.success ? parsed.data : void 0;
|
|
7955
|
+
} catch {
|
|
7956
|
+
return void 0;
|
|
7957
|
+
}
|
|
7958
|
+
}
|
|
7959
|
+
function filterCatalogue(models, catalogue) {
|
|
7960
|
+
const included = catalogue.include === void 0 ? void 0 : (0, import_picomatch4.default)(catalogue.include, { dot: true });
|
|
7961
|
+
const excluded = catalogue.exclude === void 0 ? void 0 : (0, import_picomatch4.default)(catalogue.exclude, { dot: true });
|
|
7962
|
+
return models.filter((model) => included?.(model.id) !== false && excluded?.(model.id) !== true);
|
|
7963
|
+
}
|
|
7964
|
+
var import_node_path30, import_picomatch4, import_zod24, DEFAULT_CANDIDATE_URLS, MS_PER_SECOND5, SECONDS_PER_HOUR2, HOURS_PER_DAY5, MS_PER_HOUR4, HOURS_BETWEEN_RETRIES, CATALOGUE_MAX_AGE_MS, CATALOGUE_RETRY_MS, CATALOGUE_REQUEST_SECONDS, CATALOGUE_REQUEST_TIMEOUT_MS, CATALOGUE_REFRESH_TIMEOUT_MS, CatalogueModelSchema, CatalogueCacheSchema;
|
|
7965
|
+
var init_providerCatalogue = __esm({
|
|
7966
|
+
"src/providerCatalogue.ts"() {
|
|
7967
|
+
"use strict";
|
|
7968
|
+
import_node_path30 = __toESM(require("node:path"), 1);
|
|
7969
|
+
import_picomatch4 = __toESM(require("picomatch"), 1);
|
|
7970
|
+
import_zod24 = require("zod");
|
|
7971
|
+
DEFAULT_CANDIDATE_URLS = 2;
|
|
7972
|
+
MS_PER_SECOND5 = 1e3;
|
|
7973
|
+
SECONDS_PER_HOUR2 = 3600;
|
|
7974
|
+
HOURS_PER_DAY5 = 24;
|
|
7975
|
+
MS_PER_HOUR4 = SECONDS_PER_HOUR2 * MS_PER_SECOND5;
|
|
7976
|
+
HOURS_BETWEEN_RETRIES = 1;
|
|
7977
|
+
CATALOGUE_MAX_AGE_MS = HOURS_PER_DAY5 * MS_PER_HOUR4;
|
|
7978
|
+
CATALOGUE_RETRY_MS = HOURS_BETWEEN_RETRIES * MS_PER_HOUR4;
|
|
7979
|
+
CATALOGUE_REQUEST_SECONDS = 10;
|
|
7980
|
+
CATALOGUE_REQUEST_TIMEOUT_MS = CATALOGUE_REQUEST_SECONDS * MS_PER_SECOND5;
|
|
7981
|
+
CATALOGUE_REFRESH_TIMEOUT_MS = DEFAULT_CANDIDATE_URLS * CATALOGUE_REQUEST_TIMEOUT_MS;
|
|
7982
|
+
CatalogueModelSchema = import_zod24.z.strictObject({ id: import_zod24.z.string().min(1), name: import_zod24.z.string().min(1).optional() });
|
|
7983
|
+
CatalogueCacheSchema = import_zod24.z.strictObject({ fetchedAt: import_zod24.z.number(), url: import_zod24.z.string().min(1), models: import_zod24.z.array(CatalogueModelSchema) });
|
|
7984
|
+
}
|
|
7985
|
+
});
|
|
7986
|
+
|
|
7987
|
+
// src/launcher/modelPicker.ts
|
|
7988
|
+
function labelOf(model) {
|
|
7989
|
+
return withoutContextMarker(model);
|
|
7990
|
+
}
|
|
7991
|
+
function describedAs(model, description) {
|
|
7992
|
+
return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? `${description}; 1M context` : description;
|
|
7993
|
+
}
|
|
7994
|
+
function joined(parts) {
|
|
7995
|
+
const last = parts[parts.length - 1];
|
|
7996
|
+
return last === void 0 || parts.length === 1 ? last ?? "" : `${parts.slice(0, -1).join(", ")} and ${last}`;
|
|
7997
|
+
}
|
|
7998
|
+
function rowOf2(model, reaches) {
|
|
7999
|
+
const lead = reaches.find((reach) => reach.standing === "first") ?? reaches[0];
|
|
8000
|
+
if (lead === void 0) {
|
|
8001
|
+
throw new Error(`model ${model} is reached by no tier`);
|
|
8002
|
+
}
|
|
8003
|
+
const firsts = reaches.filter((reach) => reach.standing === "first").map((reach) => reach.tier);
|
|
8004
|
+
const fallbacks = reaches.filter((reach) => reach.standing === "fallback").map((reach) => reach.tier);
|
|
8005
|
+
const serves = firsts.length === 0 ? [] : [`Serves the ${joined(firsts)} tier${firsts.length === 1 ? "" : "s"}`];
|
|
8006
|
+
const falls = fallbacks.length === 0 ? [] : [`${serves.length === 0 ? "Fallback" : "fallback"} for ${joined(fallbacks)}`];
|
|
8007
|
+
return { model, label: labelOf(model), description: describedAs(model, [...serves, ...falls].join("; ")), behavesAs: TIER_BEHAVES_AS[lead.tier] };
|
|
8008
|
+
}
|
|
8009
|
+
function rowsOfTable(table) {
|
|
8010
|
+
const reachesByModel = /* @__PURE__ */ new Map();
|
|
8011
|
+
for (const [tier, candidates] of table) {
|
|
8012
|
+
candidates.forEach((model, index) => {
|
|
8013
|
+
const reaches = reachesByModel.get(model) ?? [];
|
|
8014
|
+
if (!reaches.some((reach) => reach.tier === tier)) {
|
|
8015
|
+
reaches.push({ tier, standing: index === 0 ? "first" : "fallback" });
|
|
8016
|
+
}
|
|
8017
|
+
reachesByModel.set(model, reaches);
|
|
8018
|
+
});
|
|
8019
|
+
}
|
|
8020
|
+
return [...reachesByModel].map(([model, reaches]) => rowOf2(model, reaches));
|
|
8021
|
+
}
|
|
8022
|
+
function antigravityRows(provider) {
|
|
8023
|
+
const config = resolveAntigravityConfig(provider.antigravity);
|
|
8024
|
+
const tiers = rowsOfTable(CLAUDE_TIERS.map((tier) => [tier, config.models[tier]]));
|
|
8025
|
+
const behavesAsOf = new Map(tiers.map((row) => [row.model, row.behavesAs]));
|
|
8026
|
+
const aliases = [...config.aliases].flatMap(([alias, candidates]) => {
|
|
8027
|
+
const [first] = candidates;
|
|
8028
|
+
const behavesAs = first === void 0 ? void 0 : behavesAsOf.get(first);
|
|
8029
|
+
const description = alias === AUTO_ALIAS ? `Routes each request to a backend model with quota left, best first (${String(candidates.length)} models)` : `Alias for ${candidates.join(", then ")}`;
|
|
8030
|
+
return behavesAs === void 0 ? [] : [{ model: alias, label: labelOf(alias), description, behavesAs }];
|
|
8031
|
+
});
|
|
8032
|
+
return [...aliases.filter((row) => row.model === AUTO_ALIAS), ...tiers, ...aliases.filter((row) => row.model !== AUTO_ALIAS)];
|
|
8033
|
+
}
|
|
8034
|
+
function codexRows(provider) {
|
|
8035
|
+
const config = resolveCodexConfig(provider.codex);
|
|
8036
|
+
return rowsOfTable(CLAUDE_TIERS.map((tier) => [tier, [config.models[tier]]]));
|
|
8037
|
+
}
|
|
8038
|
+
function httpRows(provider) {
|
|
8039
|
+
const env = provider.env ?? {};
|
|
8040
|
+
const table = CLAUDE_TIERS.flatMap((tier) => {
|
|
8041
|
+
const model = env[TIER_ENV_VARIABLES[tier]];
|
|
8042
|
+
return model === void 0 || model === "" ? [] : [[tier, [model]]];
|
|
8043
|
+
});
|
|
8044
|
+
return rowsOfTable(table);
|
|
8045
|
+
}
|
|
8046
|
+
function declaredRow(entry) {
|
|
8047
|
+
return {
|
|
8048
|
+
model: entry.model,
|
|
8049
|
+
label: entry.label ?? labelOf(entry.model),
|
|
8050
|
+
description: entry.description ?? describedAs(entry.model, `Declared by the provider for the ${entry.tier} tier`),
|
|
8051
|
+
behavesAs: TIER_BEHAVES_AS[entry.tier]
|
|
8052
|
+
};
|
|
8053
|
+
}
|
|
8054
|
+
function catalogueRows(provider, models) {
|
|
8055
|
+
if (provider.kind !== void 0 && provider.kind !== "http" || provider.catalogue === void 0) {
|
|
8056
|
+
return [];
|
|
8057
|
+
}
|
|
8058
|
+
const { tier } = provider.catalogue;
|
|
8059
|
+
return filterCatalogue(models, provider.catalogue).map((model) => ({ model: model.id, label: labelOf(model.id), description: describedAs(model.id, model.name === void 0 ? "Listed by the provider" : `Listed by the provider as ${model.name}`), behavesAs: TIER_BEHAVES_AS[tier] })).sort((left, right) => left.model.localeCompare(right.model));
|
|
8060
|
+
}
|
|
8061
|
+
function providerModelRows(provider, catalogue = []) {
|
|
8062
|
+
const derived = provider.kind === "codex" ? codexRows(provider) : provider.kind === "antigravity" ? antigravityRows(provider) : provider.kind === "router" ? [] : httpRows(provider);
|
|
8063
|
+
const declared = provider.kind === "router" ? [] : (provider.pickerModels ?? []).map(declaredRow);
|
|
8064
|
+
const declaredModels = new Set(declared.map((row) => row.model));
|
|
8065
|
+
const named = [...derived.filter((row) => !declaredModels.has(row.model)), ...declared];
|
|
8066
|
+
const taken = new Set(named.map((row) => labelOf(row.model)));
|
|
8067
|
+
return [...named, ...catalogueRows(provider, catalogue).filter((row) => !taken.has(labelOf(row.model)))];
|
|
8068
|
+
}
|
|
8069
|
+
function routedModelRows(models, providers) {
|
|
8070
|
+
const hidden = new Set(models.hide ?? []);
|
|
8071
|
+
const shown = models.show === void 0 ? void 0 : new Set(models.show);
|
|
8072
|
+
const visible = (model) => shown === void 0 ? !hidden.has(model) : shown.has(model);
|
|
8073
|
+
const tierOf = (model) => {
|
|
8074
|
+
for (const [, provider] of providers) {
|
|
8075
|
+
if (provider.kind !== void 0 && provider.kind !== "http") {
|
|
8076
|
+
continue;
|
|
8077
|
+
}
|
|
8078
|
+
const match = Object.entries(provider.env ?? {}).find(([key, value]) => value === model && key.startsWith("ANTHROPIC_DEFAULT_") && key.endsWith("_MODEL"));
|
|
8079
|
+
if (match !== void 0) {
|
|
8080
|
+
const tier = match[0].replace("ANTHROPIC_DEFAULT_", "").replace("_MODEL", "").toLowerCase();
|
|
8081
|
+
return tier === "fable" || tier === "opus" || tier === "sonnet" || tier === "haiku" ? tier : void 0;
|
|
8082
|
+
}
|
|
8083
|
+
}
|
|
8084
|
+
return void 0;
|
|
8085
|
+
};
|
|
8086
|
+
const virtual = Object.entries(models.virtual ?? {}).flatMap(([name, definition]) => {
|
|
8087
|
+
if (!visible(name)) {
|
|
8088
|
+
return [];
|
|
8089
|
+
}
|
|
8090
|
+
const first = definition.members.find((member) => member.includes("/"));
|
|
8091
|
+
const tier = first === void 0 ? void 0 : tierOf(first.split("/").slice(1).join("/"));
|
|
8092
|
+
const behavesAs = tier === void 0 ? void 0 : TIER_BEHAVES_AS[tier];
|
|
8093
|
+
return behavesAs === void 0 ? [] : [{ model: name, label: name, description: `Virtual (${definition.mode})`, behavesAs }];
|
|
8094
|
+
});
|
|
8095
|
+
const concrete = providers.flatMap(([name, provider]) => providerModelRows(provider).map((row) => ({ ...row, model: `${name}/${row.model}`, label: `${name} / ${row.label}`, description: `${name}: ${row.description}` })));
|
|
8096
|
+
return [...virtual, ...concrete.filter((row) => visible(row.model))];
|
|
8097
|
+
}
|
|
8098
|
+
function modelPickerSettings(provider, catalogue = []) {
|
|
8099
|
+
return modelPickerSettingsFromRows(providerModelRows(provider, catalogue), true);
|
|
8100
|
+
}
|
|
8101
|
+
function modelPickerSettingsFromRows(options, replaceBuiltInOptions) {
|
|
8102
|
+
return options.length === 0 ? void 0 : JSON.stringify({ modelPicker: { options, replaceBuiltInOptions } });
|
|
8103
|
+
}
|
|
8104
|
+
var TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
|
|
8105
|
+
var init_modelPicker = __esm({
|
|
8106
|
+
"src/launcher/modelPicker.ts"() {
|
|
8107
|
+
"use strict";
|
|
8108
|
+
init_translate();
|
|
8109
|
+
init_translate2();
|
|
8110
|
+
init_providerCatalogue();
|
|
8111
|
+
init_schema();
|
|
8112
|
+
init_identity2();
|
|
8113
|
+
TIER_BEHAVES_AS = Object.freeze({
|
|
8114
|
+
fable: "claude-fable-5-1",
|
|
8115
|
+
opus: "claude-opus-5-5",
|
|
8116
|
+
sonnet: "claude-sonnet-5-5",
|
|
8117
|
+
haiku: "claude-haiku-5-5"
|
|
8118
|
+
});
|
|
8119
|
+
TIER_ENV_VARIABLES = Object.freeze({
|
|
8120
|
+
fable: "ANTHROPIC_DEFAULT_FABLE_MODEL",
|
|
8121
|
+
opus: "ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
8122
|
+
sonnet: "ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
8123
|
+
haiku: "ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
|
8124
|
+
});
|
|
8125
|
+
}
|
|
8126
|
+
});
|
|
8127
|
+
|
|
8128
|
+
// src/frontdoor/probe.ts
|
|
8129
|
+
function probeFrontDoorSync(port, caPem) {
|
|
8130
|
+
refuseToBlockInRole("a synchronous probe of the front door");
|
|
8131
|
+
return runProbeWorker(PROBE_SOURCE, { port, ca: caPem });
|
|
8132
|
+
}
|
|
8133
|
+
function probeListenerAcceptSync(port) {
|
|
8134
|
+
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
8135
|
+
return runProbeWorker(ACCEPT_PROBE_SOURCE, { port });
|
|
8136
|
+
}
|
|
8137
|
+
function runProbeWorker(source, data) {
|
|
8138
|
+
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
8139
|
+
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
8140
|
+
const worker = new import_node_worker_threads.Worker(source, {
|
|
8141
|
+
eval: true,
|
|
8142
|
+
workerData: { ...data, timeoutMs: PROBE_TIMEOUT_MS, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS }
|
|
8143
|
+
});
|
|
8144
|
+
worker.unref();
|
|
8145
|
+
try {
|
|
8146
|
+
const waited = Atomics.wait(header, 0, VERDICT_PENDING, PROBE_TIMEOUT_MS + PROBE_WAIT_MARGIN_MS);
|
|
8147
|
+
const verdict = Atomics.load(header, 0);
|
|
8148
|
+
if (waited === "timed-out" || verdict === VERDICT_PENDING) {
|
|
8149
|
+
return { ok: false, reason: `the probe did not finish within ${String(PROBE_TIMEOUT_MS + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
8150
|
+
}
|
|
8151
|
+
if (verdict === VERDICT_OK) {
|
|
8152
|
+
return { ok: true };
|
|
8153
|
+
}
|
|
8154
|
+
const length = Atomics.load(header, 1);
|
|
8155
|
+
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
8156
|
+
} finally {
|
|
8157
|
+
void worker.terminate();
|
|
8158
|
+
}
|
|
8159
|
+
}
|
|
8160
|
+
var import_node_worker_threads, PROBE_TIMEOUT_MS, PROBE_WAIT_MARGIN_MS, REASON_BYTES, HEADER_SLOTS, INT32_BYTES, VERDICT_PENDING, VERDICT_OK, VERDICT_FAILED, PROBE_SOURCE, ACCEPT_PROBE_SOURCE;
|
|
8161
|
+
var init_probe = __esm({
|
|
8162
|
+
"src/frontdoor/probe.ts"() {
|
|
8163
|
+
"use strict";
|
|
8164
|
+
init_processRole();
|
|
8165
|
+
import_node_worker_threads = require("node:worker_threads");
|
|
8166
|
+
PROBE_TIMEOUT_MS = 2e3;
|
|
8167
|
+
PROBE_WAIT_MARGIN_MS = 1e3;
|
|
8168
|
+
REASON_BYTES = 1024;
|
|
8169
|
+
HEADER_SLOTS = 2;
|
|
8170
|
+
INT32_BYTES = 4;
|
|
8171
|
+
VERDICT_PENDING = 0;
|
|
8172
|
+
VERDICT_OK = 1;
|
|
8173
|
+
VERDICT_FAILED = 2;
|
|
8174
|
+
PROBE_SOURCE = `
|
|
8175
|
+
const { workerData } = require("node:worker_threads");
|
|
8176
|
+
const https = require("node:https");
|
|
8177
|
+
const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
8178
|
+
const header = new Int32Array(shared, 0, headerSlots);
|
|
8179
|
+
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
8180
|
+
let done = false;
|
|
8181
|
+
const finish = (verdict, message) => {
|
|
8182
|
+
if (done) return;
|
|
8183
|
+
done = true;
|
|
8184
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
8185
|
+
reason.set(bytes);
|
|
8186
|
+
Atomics.store(header, 1, bytes.length);
|
|
8187
|
+
Atomics.store(header, 0, verdict);
|
|
8188
|
+
Atomics.notify(header, 0);
|
|
8189
|
+
};
|
|
8190
|
+
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
8191
|
+
let body = "";
|
|
8192
|
+
response.setEncoding("utf8");
|
|
8193
|
+
response.on("data", (chunk) => { body += chunk; });
|
|
8194
|
+
response.on("end", () => {
|
|
8195
|
+
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
8196
|
+
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
8197
|
+
});
|
|
8198
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
8199
|
+
});
|
|
8200
|
+
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
8201
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
8202
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
8203
|
+
`;
|
|
8204
|
+
ACCEPT_PROBE_SOURCE = `
|
|
8205
|
+
const { workerData } = require("node:worker_threads");
|
|
8206
|
+
const net = require("node:net");
|
|
8207
|
+
const { port, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
8208
|
+
const header = new Int32Array(shared, 0, headerSlots);
|
|
8209
|
+
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
8210
|
+
let done = false;
|
|
8211
|
+
const finish = (verdict, message) => {
|
|
8212
|
+
if (done) return;
|
|
8213
|
+
done = true;
|
|
8214
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
8215
|
+
reason.set(bytes);
|
|
8216
|
+
Atomics.store(header, 1, bytes.length);
|
|
8217
|
+
Atomics.store(header, 0, verdict);
|
|
8218
|
+
Atomics.notify(header, 0);
|
|
8219
|
+
};
|
|
8220
|
+
const socket = net.connect({ host: "127.0.0.1", port });
|
|
8221
|
+
socket.once("connect", () => { socket.destroy(); finish(ok, ""); });
|
|
8222
|
+
socket.once("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
8223
|
+
setTimeout(() => { socket.destroy(); finish(failed, "no connection accepted within " + String(timeoutMs) + "ms"); }, timeoutMs);
|
|
8224
|
+
`;
|
|
8225
|
+
}
|
|
8226
|
+
});
|
|
8227
|
+
|
|
8228
|
+
// src/update/update.ts
|
|
8229
|
+
function compareVersions3(left, right) {
|
|
8230
|
+
const parse = (version) => {
|
|
8231
|
+
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
|
|
8232
|
+
if (match === null) {
|
|
8233
|
+
throw new Error(`not a plain release version: ${version}`);
|
|
8234
|
+
}
|
|
8235
|
+
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
8236
|
+
};
|
|
8237
|
+
const leftParts = parse(left);
|
|
8238
|
+
const rightParts = parse(right);
|
|
8239
|
+
return leftParts.map((part, index) => part - (rightParts[index] ?? 0)).find((difference) => difference !== 0) ?? 0;
|
|
8240
|
+
}
|
|
8241
|
+
function releaseTagFromUrl(url) {
|
|
8242
|
+
const segment = url.split("?")[0]?.split("/").at(-1);
|
|
8243
|
+
const candidate = segment?.startsWith("v") === true ? segment.slice(1) : void 0;
|
|
8244
|
+
return candidate !== void 0 && /^\d+\.\d+\.\d+$/.test(candidate) ? candidate : void 0;
|
|
8245
|
+
}
|
|
8246
|
+
var LATEST_RELEASE_URL, UpdateChannelError, UpdateConflictError, UpdateDownloadError;
|
|
8247
|
+
var init_update = __esm({
|
|
8248
|
+
"src/update/update.ts"() {
|
|
8249
|
+
"use strict";
|
|
8250
|
+
init_cliError();
|
|
8251
|
+
LATEST_RELEASE_URL = "https://github.com/ExaDev/agent-shim/releases/latest";
|
|
8252
|
+
UpdateChannelError = class extends CliError {
|
|
8253
|
+
constructor(message) {
|
|
8254
|
+
super(message);
|
|
8255
|
+
this.name = "UpdateChannelError";
|
|
8256
|
+
}
|
|
8257
|
+
};
|
|
8258
|
+
UpdateConflictError = class extends CliError {
|
|
8259
|
+
constructor(message) {
|
|
8260
|
+
super(message);
|
|
8261
|
+
this.name = "UpdateConflictError";
|
|
8262
|
+
}
|
|
8263
|
+
};
|
|
8264
|
+
UpdateDownloadError = class extends CliError {
|
|
8265
|
+
constructor(message) {
|
|
8266
|
+
super(message);
|
|
8267
|
+
this.name = "UpdateDownloadError";
|
|
8268
|
+
}
|
|
8269
|
+
};
|
|
8270
|
+
}
|
|
8271
|
+
});
|
|
8272
|
+
|
|
8273
|
+
// src/frontdoor/ensure.ts
|
|
8274
|
+
function ensureFrontDoor(params) {
|
|
8275
|
+
const { paths, ports } = params;
|
|
8276
|
+
const deadline = ports.now() + FRONTDOOR_START_TIMEOUT_MS;
|
|
8277
|
+
let spawned = false;
|
|
8278
|
+
let replaced = false;
|
|
8279
|
+
const distrusted = /* @__PURE__ */ new Set();
|
|
8280
|
+
let lastRejection;
|
|
8281
|
+
let busyDoor;
|
|
8282
|
+
const liveSessionsOn = (doorPid) => listFrontDoorSessions(ports.fs, paths.frontdoorSessionsDir).filter(
|
|
8283
|
+
(session) => session.pid !== params.launcherPid && ports.isRunning(session.pid) && (session.supervisorPid === void 0 || session.supervisorPid === doorPid)
|
|
8284
|
+
).length;
|
|
8285
|
+
const verifyWithRetry = (port) => {
|
|
8286
|
+
let verdict = ports.verifyListener(port);
|
|
8287
|
+
for (let attempt = 1; !verdict.ok && attempt < FRONTDOOR_PROBE_ATTEMPTS; attempt += 1) {
|
|
8288
|
+
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
8289
|
+
verdict = ports.verifyListener(port);
|
|
8290
|
+
}
|
|
8291
|
+
return verdict;
|
|
8292
|
+
};
|
|
8293
|
+
const stopAndAwaitExit = (supervisorPid, failure) => {
|
|
8294
|
+
ports.stopSupervisor(supervisorPid);
|
|
8295
|
+
const graceEnds = ports.now() + FRONTDOOR_EXIT_GRACE_MS;
|
|
8296
|
+
let killed = false;
|
|
8297
|
+
while (ports.isRunning(supervisorPid)) {
|
|
8298
|
+
if (!killed && ports.now() >= graceEnds) {
|
|
8299
|
+
ports.killSupervisor(supervisorPid);
|
|
8300
|
+
killed = true;
|
|
8301
|
+
}
|
|
8302
|
+
if (ports.now() >= deadline) {
|
|
8303
|
+
throw new FrontDoorStartError(`${failure}. Daemon log: ${paths.frontdoorLogPath}`);
|
|
8304
|
+
}
|
|
8305
|
+
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
8306
|
+
}
|
|
8307
|
+
};
|
|
8308
|
+
for (; ; ) {
|
|
8309
|
+
const state = readFrontDoorState(ports.fs, paths.frontdoorStateFile);
|
|
8310
|
+
const supervisorPid = state?.supervisorPid;
|
|
8311
|
+
if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
|
|
8312
|
+
if (state?.port !== void 0 && state.connectPort !== void 0) {
|
|
8313
|
+
if (supervisorPid === params.launcherPid && params.replace !== true && ports.isFrontDoorSupervisor(supervisorPid)) {
|
|
8314
|
+
const token = (0, import_node_crypto10.randomUUID)();
|
|
8315
|
+
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid });
|
|
8316
|
+
return { port: state.port, connectPort: state.connectPort, token };
|
|
8317
|
+
}
|
|
8318
|
+
const verdict = verifyWithRetry(state.port);
|
|
8319
|
+
if (verdict.ok && !replaced && !spawned && (params.replace === true || (state.protocol ?? 0) < FRONT_DOOR_PROTOCOL)) {
|
|
8320
|
+
stopAndAwaitExit(
|
|
8321
|
+
supervisorPid,
|
|
8322
|
+
`the front door (pid ${String(supervisorPid)}, protocol ${String(state.protocol ?? 0)}; this launcher speaks protocol ${String(FRONT_DOOR_PROTOCOL)}) was asked to be replaced and did not exit`
|
|
8323
|
+
);
|
|
8324
|
+
replaced = true;
|
|
8325
|
+
continue;
|
|
8326
|
+
}
|
|
7804
8327
|
if (verdict.ok) {
|
|
7805
8328
|
const token = (0, import_node_crypto10.randomUUID)();
|
|
7806
8329
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid });
|
|
@@ -8252,7 +8775,7 @@ function buildEnv(params) {
|
|
|
8252
8775
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
8253
8776
|
let providerCustomHeaders;
|
|
8254
8777
|
if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
|
|
8255
|
-
env.CLAUDE_CONFIG_DIR =
|
|
8778
|
+
env.CLAUDE_CONFIG_DIR = import_node_path37.default.join(params.identitiesDir, params.resolvedIdentityName);
|
|
8256
8779
|
}
|
|
8257
8780
|
if (params.provider !== void 0) {
|
|
8258
8781
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
@@ -8272,777 +8795,380 @@ function buildEnv(params) {
|
|
|
8272
8795
|
env[variable] = value;
|
|
8273
8796
|
}
|
|
8274
8797
|
}
|
|
8275
|
-
if (params.frontdoor !== void 0) {
|
|
8276
|
-
env.ANTHROPIC_CUSTOM_HEADERS = mergeAnthropicCustomHeaders(
|
|
8277
|
-
[
|
|
8278
|
-
...parentCustomHeaders === void 0 ? [] : [parentCustomHeaders],
|
|
8279
|
-
...providerCustomHeaders === void 0 ? [] : [providerCustomHeaders]
|
|
8280
|
-
],
|
|
8281
|
-
[
|
|
8282
|
-
...params.resolvedIdentityName === void 0 ? [] : [{ name: IDENTITY_HEADER, value: params.resolvedIdentityName }],
|
|
8283
|
-
{ name: SESSION_HEADER, value: params.sessionId },
|
|
8284
|
-
{ name: AUTH_HEADER, value: params.frontdoor.sessionToken },
|
|
8285
|
-
...params.provider === void 0 ? [] : [{ name: PROVIDER_HEADER, value: params.provider.name }],
|
|
8286
|
-
...params.routeByName ? [{ name: ROUTE_BY_NAME_HEADER, value: "1" }] : [],
|
|
8287
|
-
...params.headroom === void 0 ? [] : [
|
|
8288
|
-
{ name: HEADROOM_FLAG_HEADER, value: "1" },
|
|
8289
|
-
{ name: PROJECT_ID_HEADER, value: params.headroom.projectId }
|
|
8290
|
-
]
|
|
8291
|
-
]
|
|
8292
|
-
);
|
|
8293
|
-
env.NODE_EXTRA_CA_CERTS = params.frontdoor.trustBundlePath;
|
|
8294
|
-
env.HTTPS_PROXY = connectProxyUrl(params.frontdoor.connectPort, params.frontdoor.sessionToken);
|
|
8295
|
-
env.NO_PROXY = withLoopbackHosts(env.NO_PROXY);
|
|
8296
|
-
env.no_proxy = withLoopbackHosts(env.no_proxy);
|
|
8297
|
-
}
|
|
8298
|
-
return env;
|
|
8299
|
-
}
|
|
8300
|
-
var import_node_path36, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
|
|
8301
|
-
var init_flags = __esm({
|
|
8302
|
-
"src/launcher/flags.ts"() {
|
|
8303
|
-
"use strict";
|
|
8304
|
-
import_node_path36 = __toESM(require("node:path"), 1);
|
|
8305
|
-
init_envBool();
|
|
8306
|
-
init_cliError();
|
|
8307
|
-
init_conditions();
|
|
8308
|
-
init_credential();
|
|
8309
|
-
init_headers();
|
|
8310
|
-
init_capability();
|
|
8311
|
-
init_route();
|
|
8312
|
-
LOOPBACK_HOSTS = ["127.0.0.1", "localhost", "::1"];
|
|
8313
|
-
PROVIDER_SESSION_PLACEHOLDER = "agent-shim-provider-session";
|
|
8314
|
-
}
|
|
8315
|
-
});
|
|
8316
|
-
|
|
8317
|
-
// src/launcher/extraFlags.ts
|
|
8318
|
-
function splitExtraFlags(value) {
|
|
8319
|
-
if (value === void 0) {
|
|
8320
|
-
return [];
|
|
8321
|
-
}
|
|
8322
|
-
const trimmed = value.trim();
|
|
8323
|
-
if (trimmed === "") {
|
|
8324
|
-
return [];
|
|
8325
|
-
}
|
|
8326
|
-
return trimmed.split(/\s+/);
|
|
8327
|
-
}
|
|
8328
|
-
var init_extraFlags = __esm({
|
|
8329
|
-
"src/launcher/extraFlags.ts"() {
|
|
8330
|
-
"use strict";
|
|
8331
|
-
}
|
|
8332
|
-
});
|
|
8333
|
-
|
|
8334
|
-
// src/usage/resumeContext.ts
|
|
8335
|
-
function projectDirNameOf(cwd) {
|
|
8336
|
-
return cwd.replace(/[^A-Za-z0-9]/g, "-");
|
|
8337
|
-
}
|
|
8338
|
-
function resumeTargetOf(passthrough) {
|
|
8339
|
-
const end = passthrough.indexOf("--");
|
|
8340
|
-
const tokens = end === -1 ? passthrough : passthrough.slice(0, end);
|
|
8341
|
-
for (const [index, token] of tokens.entries()) {
|
|
8342
|
-
if (token === "--continue" || token === "-c") {
|
|
8343
|
-
return { kind: "latest" };
|
|
8344
|
-
}
|
|
8345
|
-
if (token === "--resume" || token === "-r") {
|
|
8346
|
-
const next = tokens[index + 1];
|
|
8347
|
-
return next === void 0 || next.startsWith("-") ? void 0 : { kind: "id", id: next };
|
|
8348
|
-
}
|
|
8349
|
-
if (token.startsWith("--resume=")) {
|
|
8350
|
-
const id = token.slice("--resume=".length);
|
|
8351
|
-
return id === "" ? void 0 : { kind: "id", id };
|
|
8352
|
-
}
|
|
8353
|
-
}
|
|
8354
|
-
return void 0;
|
|
8355
|
-
}
|
|
8356
|
-
function countOf(usage, key) {
|
|
8357
|
-
const value = key in usage ? Reflect.get(usage, key) : void 0;
|
|
8358
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
8359
|
-
}
|
|
8360
|
-
function contextTokensOfTranscript(text) {
|
|
8361
|
-
const lines = text.split("\n");
|
|
8362
|
-
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
8363
|
-
const line = lines[index];
|
|
8364
|
-
if (line === void 0 || line === "") {
|
|
8365
|
-
continue;
|
|
8366
|
-
}
|
|
8367
|
-
let parsed;
|
|
8368
|
-
try {
|
|
8369
|
-
parsed = JSON.parse(line);
|
|
8370
|
-
} catch {
|
|
8371
|
-
continue;
|
|
8372
|
-
}
|
|
8373
|
-
if (typeof parsed !== "object" || parsed === null || !("type" in parsed) || parsed.type !== "assistant" || !("message" in parsed)) {
|
|
8374
|
-
continue;
|
|
8375
|
-
}
|
|
8376
|
-
const { message } = parsed;
|
|
8377
|
-
if (typeof message !== "object" || message === null || !("usage" in message) || typeof message.usage !== "object" || message.usage === null) {
|
|
8378
|
-
continue;
|
|
8379
|
-
}
|
|
8380
|
-
const { usage } = message;
|
|
8381
|
-
return countOf(usage, "input_tokens") + countOf(usage, "cache_read_input_tokens") + countOf(usage, "cache_creation_input_tokens");
|
|
8382
|
-
}
|
|
8383
|
-
return void 0;
|
|
8384
|
-
}
|
|
8385
|
-
function newestTranscript(fs13, projectDir) {
|
|
8386
|
-
let newest;
|
|
8387
|
-
let newestMs = -Infinity;
|
|
8388
|
-
for (const name of fs13.readdir(projectDir)) {
|
|
8389
|
-
if (!name.endsWith(".jsonl")) {
|
|
8390
|
-
continue;
|
|
8391
|
-
}
|
|
8392
|
-
const candidate = import_node_path37.default.join(projectDir, name);
|
|
8393
|
-
const stat = fs13.lstat(candidate);
|
|
8394
|
-
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
8395
|
-
newestMs = stat.mtimeMs;
|
|
8396
|
-
newest = candidate;
|
|
8397
|
-
}
|
|
8398
|
-
}
|
|
8399
|
-
return newest;
|
|
8400
|
-
}
|
|
8401
|
-
function resumedContextTokens(fs13, params) {
|
|
8402
|
-
const target = resumeTargetOf(params.passthrough);
|
|
8403
|
-
if (target === void 0) {
|
|
8404
|
-
return void 0;
|
|
8405
|
-
}
|
|
8406
|
-
const projectDir = import_node_path37.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
8407
|
-
const file = target.kind === "id" ? import_node_path37.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs13, projectDir);
|
|
8408
|
-
const text = file === void 0 ? void 0 : fs13.readFileUtf8(file);
|
|
8409
|
-
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
8410
|
-
}
|
|
8411
|
-
var import_node_path37;
|
|
8412
|
-
var init_resumeContext = __esm({
|
|
8413
|
-
"src/usage/resumeContext.ts"() {
|
|
8414
|
-
"use strict";
|
|
8415
|
-
import_node_path37 = __toESM(require("node:path"), 1);
|
|
8416
|
-
}
|
|
8417
|
-
});
|
|
8418
|
-
|
|
8419
|
-
// src/launcher/claudeSession.ts
|
|
8420
|
-
function isFlag(token) {
|
|
8421
|
-
return token?.startsWith("-") === true;
|
|
8422
|
-
}
|
|
8423
|
-
function withConversation(passthrough, conversation, id) {
|
|
8424
|
-
const end = passthrough.indexOf(TERMINATOR2);
|
|
8425
|
-
const head = end === -1 ? passthrough : passthrough.slice(0, end);
|
|
8426
|
-
const tail = end === -1 ? [] : passthrough.slice(end);
|
|
8427
|
-
const kept = [];
|
|
8428
|
-
for (let index = 0; index < head.length; index += 1) {
|
|
8429
|
-
const token = head[index];
|
|
8430
|
-
if (token === void 0 || CONTINUE_FLAGS.has(token) || token.startsWith("--resume=") || token.startsWith("--session-id=")) {
|
|
8431
|
-
continue;
|
|
8432
|
-
}
|
|
8433
|
-
if (VALUED_CONVERSATION_FLAGS.has(token)) {
|
|
8434
|
-
if (!isFlag(head[index + 1]) && head[index + 1] !== void 0) {
|
|
8435
|
-
index += 1;
|
|
8436
|
-
}
|
|
8437
|
-
continue;
|
|
8438
|
-
}
|
|
8439
|
-
kept.push(token);
|
|
8440
|
-
}
|
|
8441
|
-
return [...kept, conversation === "start" ? "--session-id" : "--resume", id, ...tail];
|
|
8442
|
-
}
|
|
8443
|
-
function hasSettingsArgument(passthrough) {
|
|
8444
|
-
const end = passthrough.indexOf(TERMINATOR2);
|
|
8445
|
-
return (end === -1 ? passthrough : passthrough.slice(0, end)).some((token) => token === "--settings" || token.startsWith("--settings="));
|
|
8446
|
-
}
|
|
8447
|
-
function withSupervision(passthrough, supervised) {
|
|
8448
|
-
if (supervised.conversation === "as-given") {
|
|
8449
|
-
return passthrough;
|
|
8450
|
-
}
|
|
8451
|
-
const conversed = withConversation(passthrough, supervised.conversation, supervised.sessionId);
|
|
8452
|
-
if (supervised.model === void 0) {
|
|
8453
|
-
return conversed;
|
|
8454
|
-
}
|
|
8455
|
-
const end = conversed.indexOf(TERMINATOR2);
|
|
8456
|
-
const head = end === -1 ? conversed : conversed.slice(0, end);
|
|
8457
|
-
const tail = end === -1 ? [] : conversed.slice(end);
|
|
8458
|
-
const kept = [];
|
|
8459
|
-
for (let index = 0; index < head.length; index += 1) {
|
|
8460
|
-
const token = head[index];
|
|
8461
|
-
if (token === "--model") {
|
|
8462
|
-
index += 1;
|
|
8463
|
-
continue;
|
|
8464
|
-
}
|
|
8465
|
-
if (token !== void 0 && !token.startsWith("--model=")) {
|
|
8466
|
-
kept.push(token);
|
|
8467
|
-
}
|
|
8468
|
-
}
|
|
8469
|
-
return [...kept, "--model", supervised.model, ...tail];
|
|
8470
|
-
}
|
|
8471
|
-
function withLauncherSettings(passthrough, settings) {
|
|
8472
|
-
if (settings === void 0) {
|
|
8473
|
-
return passthrough;
|
|
8474
|
-
}
|
|
8475
|
-
const end = passthrough.indexOf(TERMINATOR2);
|
|
8476
|
-
return end === -1 ? [...passthrough, "--settings", settings] : [...passthrough.slice(0, end), "--settings", settings, ...passthrough.slice(end)];
|
|
8477
|
-
}
|
|
8478
|
-
function isRecord15(value) {
|
|
8479
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8480
|
-
}
|
|
8481
|
-
function mergeSettings(parts) {
|
|
8482
|
-
const merged = {};
|
|
8483
|
-
let any = false;
|
|
8484
|
-
for (const part of parts) {
|
|
8485
|
-
if (part === void 0) {
|
|
8486
|
-
continue;
|
|
8487
|
-
}
|
|
8488
|
-
const parsed = JSON.parse(part);
|
|
8489
|
-
if (!isRecord15(parsed)) {
|
|
8490
|
-
throw new Error("a launch's settings part is not a JSON object");
|
|
8491
|
-
}
|
|
8492
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
8493
|
-
if (key in merged) {
|
|
8494
|
-
throw new Error(`two launch settings parts both set "${key}"`);
|
|
8495
|
-
}
|
|
8496
|
-
merged[key] = value;
|
|
8497
|
-
}
|
|
8498
|
-
any = true;
|
|
8499
|
-
}
|
|
8500
|
-
return any ? JSON.stringify(merged) : void 0;
|
|
8501
|
-
}
|
|
8502
|
-
var TERMINATOR2, VALUED_CONVERSATION_FLAGS, CONTINUE_FLAGS;
|
|
8503
|
-
var init_claudeSession = __esm({
|
|
8504
|
-
"src/launcher/claudeSession.ts"() {
|
|
8505
|
-
"use strict";
|
|
8506
|
-
init_resumeContext();
|
|
8507
|
-
TERMINATOR2 = "--";
|
|
8508
|
-
VALUED_CONVERSATION_FLAGS = /* @__PURE__ */ new Set(["--resume", "-r", "--session-id"]);
|
|
8509
|
-
CONTINUE_FLAGS = /* @__PURE__ */ new Set(["--continue", "-c"]);
|
|
8510
|
-
}
|
|
8511
|
-
});
|
|
8512
|
-
|
|
8513
|
-
// src/launcher/diagnostics.ts
|
|
8514
|
-
function diagnosticLines(diagnostics) {
|
|
8515
|
-
const unclassified = [...new Set(diagnostics.filter((diagnostic) => diagnostic.code === "UNCLASSIFIED_ENTRY").map((diagnostic) => diagnostic.subject))];
|
|
8516
|
-
const lines = [];
|
|
8517
|
-
let unclassifiedReported = false;
|
|
8518
|
-
for (const diagnostic of diagnostics) {
|
|
8519
|
-
if (diagnostic.severity === "info") {
|
|
8520
|
-
continue;
|
|
8521
|
-
}
|
|
8522
|
-
if (diagnostic.code === "UNCLASSIFIED_ENTRY") {
|
|
8523
|
-
if (!unclassifiedReported) {
|
|
8524
|
-
unclassifiedReported = true;
|
|
8525
|
-
const names = unclassified.filter((name) => name !== void 0);
|
|
8526
|
-
lines.push({ severity: diagnostic.severity, text: `agent-shim: ${diagnostic.code}: ${unclassifiedEntrySummary(names)}
|
|
8527
|
-
${unclassifiedEntryFix(names)}.` });
|
|
8528
|
-
}
|
|
8529
|
-
continue;
|
|
8530
|
-
}
|
|
8531
|
-
lines.push({ severity: diagnostic.severity, text: `agent-shim: ${diagnostic.code}: ${diagnostic.message}` });
|
|
8532
|
-
}
|
|
8533
|
-
return lines;
|
|
8534
|
-
}
|
|
8535
|
-
function printDiagnosticLines(log, lines, options) {
|
|
8536
|
-
for (const line of lines) {
|
|
8537
|
-
if (line.severity === "error" && !options.errorsAsWarnings) {
|
|
8538
|
-
log.error(line.text);
|
|
8539
|
-
} else {
|
|
8540
|
-
log.warn(line.text);
|
|
8541
|
-
}
|
|
8798
|
+
if (params.frontdoor !== void 0) {
|
|
8799
|
+
env.ANTHROPIC_CUSTOM_HEADERS = mergeAnthropicCustomHeaders(
|
|
8800
|
+
[
|
|
8801
|
+
...parentCustomHeaders === void 0 ? [] : [parentCustomHeaders],
|
|
8802
|
+
...providerCustomHeaders === void 0 ? [] : [providerCustomHeaders]
|
|
8803
|
+
],
|
|
8804
|
+
[
|
|
8805
|
+
...params.resolvedIdentityName === void 0 ? [] : [{ name: IDENTITY_HEADER, value: params.resolvedIdentityName }],
|
|
8806
|
+
{ name: SESSION_HEADER, value: params.sessionId },
|
|
8807
|
+
{ name: AUTH_HEADER, value: params.frontdoor.sessionToken },
|
|
8808
|
+
...params.provider === void 0 ? [] : [{ name: PROVIDER_HEADER, value: params.provider.name }],
|
|
8809
|
+
...params.routeByName ? [{ name: ROUTE_BY_NAME_HEADER, value: "1" }] : [],
|
|
8810
|
+
...params.headroom === void 0 ? [] : [
|
|
8811
|
+
{ name: HEADROOM_FLAG_HEADER, value: "1" },
|
|
8812
|
+
{ name: PROJECT_ID_HEADER, value: params.headroom.projectId }
|
|
8813
|
+
]
|
|
8814
|
+
]
|
|
8815
|
+
);
|
|
8816
|
+
env.NODE_EXTRA_CA_CERTS = params.frontdoor.trustBundlePath;
|
|
8817
|
+
env.HTTPS_PROXY = connectProxyUrl(params.frontdoor.connectPort, params.frontdoor.sessionToken);
|
|
8818
|
+
env.NO_PROXY = withLoopbackHosts(env.NO_PROXY);
|
|
8819
|
+
env.no_proxy = withLoopbackHosts(env.no_proxy);
|
|
8542
8820
|
}
|
|
8821
|
+
return env;
|
|
8543
8822
|
}
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
var init_diagnostics = __esm({
|
|
8548
|
-
"src/launcher/diagnostics.ts"() {
|
|
8823
|
+
var import_node_path37, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
|
|
8824
|
+
var init_flags = __esm({
|
|
8825
|
+
"src/launcher/flags.ts"() {
|
|
8549
8826
|
"use strict";
|
|
8550
|
-
|
|
8827
|
+
import_node_path37 = __toESM(require("node:path"), 1);
|
|
8828
|
+
init_envBool();
|
|
8829
|
+
init_cliError();
|
|
8830
|
+
init_conditions();
|
|
8831
|
+
init_credential();
|
|
8832
|
+
init_headers();
|
|
8833
|
+
init_capability();
|
|
8834
|
+
init_route();
|
|
8835
|
+
LOOPBACK_HOSTS = ["127.0.0.1", "localhost", "::1"];
|
|
8836
|
+
PROVIDER_SESSION_PLACEHOLDER = "agent-shim-provider-session";
|
|
8551
8837
|
}
|
|
8552
8838
|
});
|
|
8553
8839
|
|
|
8554
|
-
// src/launcher/
|
|
8555
|
-
function
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
function holdBeforeLaunch(hold, port, log) {
|
|
8559
|
-
if (port === void 0 || !port.attended() || !hold.pause && hold.delayMs <= 0) {
|
|
8560
|
-
return "go";
|
|
8561
|
-
}
|
|
8562
|
-
if (hold.pause) {
|
|
8563
|
-
log.info("agent-shim: paused before launch; press any key to start, or Ctrl-C to cancel");
|
|
8564
|
-
return port.waitForKey() === "interrupt" ? "cancelled" : "go";
|
|
8840
|
+
// src/launcher/extraFlags.ts
|
|
8841
|
+
function splitExtraFlags(value) {
|
|
8842
|
+
if (value === void 0) {
|
|
8843
|
+
return [];
|
|
8565
8844
|
}
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
}
|
|
8570
|
-
var LAUNCH_CANCELLED_EXIT, MS_PER_SECOND7;
|
|
8571
|
-
var init_hold = __esm({
|
|
8572
|
-
"src/launcher/hold.ts"() {
|
|
8573
|
-
"use strict";
|
|
8574
|
-
LAUNCH_CANCELLED_EXIT = 130;
|
|
8575
|
-
MS_PER_SECOND7 = 1e3;
|
|
8845
|
+
const trimmed = value.trim();
|
|
8846
|
+
if (trimmed === "") {
|
|
8847
|
+
return [];
|
|
8576
8848
|
}
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
// src/usage/candidateText.ts
|
|
8580
|
-
function candidateHeading(candidate) {
|
|
8581
|
-
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
8582
|
-
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
8583
|
-
return `[${candidate.class}${score}]${dry}`;
|
|
8849
|
+
return trimmed.split(/\s+/);
|
|
8584
8850
|
}
|
|
8585
|
-
var
|
|
8586
|
-
"src/
|
|
8851
|
+
var init_extraFlags = __esm({
|
|
8852
|
+
"src/launcher/extraFlags.ts"() {
|
|
8587
8853
|
"use strict";
|
|
8588
8854
|
}
|
|
8589
8855
|
});
|
|
8590
8856
|
|
|
8591
|
-
// src/
|
|
8592
|
-
function
|
|
8593
|
-
|
|
8594
|
-
if (pool.movedOff !== void 0) {
|
|
8595
|
-
return { detail: `moved off ${pool.movedOff.identity}: ${pool.movedOff.reason}`, ...reason === void 0 ? {} : { notes: [reason] } };
|
|
8596
|
-
}
|
|
8597
|
-
return reason === void 0 ? {} : { detail: reason };
|
|
8598
|
-
}
|
|
8599
|
-
function rankingNotes(ranking, picked) {
|
|
8600
|
-
return ranking.flatMap((candidate, index) => [
|
|
8601
|
-
`${String(index + 1)}. ${candidate.identity} ${candidateHeading(candidate)}${candidate.identity === picked ? " (picked)" : ""}`,
|
|
8602
|
-
` ${candidate.reasons.join("; ")}`
|
|
8603
|
-
]);
|
|
8604
|
-
}
|
|
8605
|
-
function decisionRows(facts) {
|
|
8606
|
-
return [
|
|
8607
|
-
{ label: "identity", value: facts.identity ?? "(none)", detail: facts.identitySource },
|
|
8608
|
-
...facts.pool === void 0 ? [] : [
|
|
8609
|
-
{
|
|
8610
|
-
label: "pool",
|
|
8611
|
-
value: facts.pool.name,
|
|
8612
|
-
...poolDetail(facts.pool),
|
|
8613
|
-
...facts.ranking === void 0 ? {} : { notes: rankingNotes(facts.ranking, facts.identity) }
|
|
8614
|
-
}
|
|
8615
|
-
],
|
|
8616
|
-
...facts.profile === void 0 ? [] : [{ label: "profile", value: facts.profile.name, detail: facts.profile.source }],
|
|
8617
|
-
...facts.provider === void 0 ? [] : [{ label: "provider", value: facts.provider.name, detail: `credential ${facts.provider.credential}` }],
|
|
8618
|
-
...facts.identityCredential === void 0 ? [] : [{ label: "credential", value: facts.identityCredential, detail: "the identity's own" }]
|
|
8619
|
-
];
|
|
8620
|
-
}
|
|
8621
|
-
function pinnedVersionRow(version, source) {
|
|
8622
|
-
return { label: "claude", value: version, detail: `pinned by ${source}` };
|
|
8857
|
+
// src/usage/resumeContext.ts
|
|
8858
|
+
function projectDirNameOf(cwd) {
|
|
8859
|
+
return cwd.replace(/[^A-Za-z0-9]/g, "-");
|
|
8623
8860
|
}
|
|
8624
|
-
function
|
|
8625
|
-
|
|
8626
|
-
|
|
8861
|
+
function resumeTargetOf(passthrough) {
|
|
8862
|
+
const end = passthrough.indexOf("--");
|
|
8863
|
+
const tokens = end === -1 ? passthrough : passthrough.slice(0, end);
|
|
8864
|
+
for (const [index, token] of tokens.entries()) {
|
|
8865
|
+
if (token === "--continue" || token === "-c") {
|
|
8866
|
+
return { kind: "latest" };
|
|
8867
|
+
}
|
|
8868
|
+
if (token === "--resume" || token === "-r") {
|
|
8869
|
+
const next = tokens[index + 1];
|
|
8870
|
+
return next === void 0 || next.startsWith("-") ? void 0 : { kind: "id", id: next };
|
|
8871
|
+
}
|
|
8872
|
+
if (token.startsWith("--resume=")) {
|
|
8873
|
+
const id = token.slice("--resume=".length);
|
|
8874
|
+
return id === "" ? void 0 : { kind: "id", id };
|
|
8875
|
+
}
|
|
8627
8876
|
}
|
|
8628
|
-
return
|
|
8629
|
-
{
|
|
8630
|
-
label: "routing",
|
|
8631
|
-
value: `front door 127.0.0.1:${String(facts.frontDoor.port)}`,
|
|
8632
|
-
...facts.provider ? {} : { detail: `OAuth via CONNECT 127.0.0.1:${String(facts.frontDoor.connectPort)}` }
|
|
8633
|
-
},
|
|
8634
|
-
...facts.headroom === void 0 ? [] : [{ label: "headroom", value: "on", detail: `project ${facts.headroom.projectId}` }]
|
|
8635
|
-
];
|
|
8636
|
-
}
|
|
8637
|
-
function farmRow(links, builtDirectories, adopted) {
|
|
8638
|
-
const counted = (count, singular, plural) => `${String(count)} ${count === 1 ? singular : plural}`;
|
|
8639
|
-
const parts = [counted(links, "link", "links"), counted(builtDirectories, "built directory", "built directories"), ...adopted === 0 ? [] : [`${String(adopted)} adopted`]];
|
|
8640
|
-
return { label: "farm", value: "resynced", detail: parts.join(", ") };
|
|
8877
|
+
return void 0;
|
|
8641
8878
|
}
|
|
8642
|
-
function
|
|
8643
|
-
|
|
8879
|
+
function countOf(usage, key) {
|
|
8880
|
+
const value = key in usage ? Reflect.get(usage, key) : void 0;
|
|
8881
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
8644
8882
|
}
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8883
|
+
function contextTokensOfTranscript(text) {
|
|
8884
|
+
const lines = text.split("\n");
|
|
8885
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
8886
|
+
const line = lines[index];
|
|
8887
|
+
if (line === void 0 || line === "") {
|
|
8888
|
+
continue;
|
|
8889
|
+
}
|
|
8890
|
+
let parsed;
|
|
8891
|
+
try {
|
|
8892
|
+
parsed = JSON.parse(line);
|
|
8893
|
+
} catch {
|
|
8894
|
+
continue;
|
|
8895
|
+
}
|
|
8896
|
+
if (typeof parsed !== "object" || parsed === null || !("type" in parsed) || parsed.type !== "assistant" || !("message" in parsed)) {
|
|
8897
|
+
continue;
|
|
8898
|
+
}
|
|
8899
|
+
const { message } = parsed;
|
|
8900
|
+
if (typeof message !== "object" || message === null || !("usage" in message) || typeof message.usage !== "object" || message.usage === null) {
|
|
8901
|
+
continue;
|
|
8902
|
+
}
|
|
8903
|
+
const { usage } = message;
|
|
8904
|
+
return countOf(usage, "input_tokens") + countOf(usage, "cache_read_input_tokens") + countOf(usage, "cache_creation_input_tokens");
|
|
8649
8905
|
}
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
// src/models/identity.ts
|
|
8653
|
-
function withoutContextMarker(model) {
|
|
8654
|
-
return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? model.slice(0, -CONTEXT_MARKER_1M.length) : model;
|
|
8906
|
+
return void 0;
|
|
8655
8907
|
}
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
deepseek: "deepseek",
|
|
8670
|
-
moonshot: "moonshot",
|
|
8671
|
-
meta: "meta",
|
|
8672
|
-
mistral: "mistral"
|
|
8673
|
-
});
|
|
8674
|
-
VENDOR_BY_TOKEN = Object.freeze({
|
|
8675
|
-
claude: "anthropic",
|
|
8676
|
-
gemini: "google",
|
|
8677
|
-
antigravity: "google",
|
|
8678
|
-
gpt: "openai",
|
|
8679
|
-
glm: "zai",
|
|
8680
|
-
minimax: "minimax",
|
|
8681
|
-
qwen: "qwen",
|
|
8682
|
-
deepseek: "deepseek",
|
|
8683
|
-
kimi: "moonshot",
|
|
8684
|
-
llama: "meta",
|
|
8685
|
-
mistral: "mistral",
|
|
8686
|
-
mixtral: "mistral"
|
|
8687
|
-
});
|
|
8688
|
-
}
|
|
8689
|
-
});
|
|
8690
|
-
|
|
8691
|
-
// src/selection/engine.ts
|
|
8692
|
-
var init_engine = __esm({
|
|
8693
|
-
"src/selection/engine.ts"() {
|
|
8694
|
-
"use strict";
|
|
8695
|
-
}
|
|
8696
|
-
});
|
|
8697
|
-
|
|
8698
|
-
// src/antigravity/cloudUpstream.ts
|
|
8699
|
-
var init_cloudUpstream = __esm({
|
|
8700
|
-
"src/antigravity/cloudUpstream.ts"() {
|
|
8701
|
-
"use strict";
|
|
8702
|
-
}
|
|
8703
|
-
});
|
|
8704
|
-
|
|
8705
|
-
// src/antigravity/quota.ts
|
|
8706
|
-
var SECONDS_PER_HOUR, HOURS_PER_FIVE_HOUR_WINDOW, DAYS_PER_WEEK, HOURS_PER_DAY4, FIVE_HOUR_PERIOD_SECONDS, WEEK_PERIOD_SECONDS;
|
|
8707
|
-
var init_quota = __esm({
|
|
8708
|
-
"src/antigravity/quota.ts"() {
|
|
8709
|
-
"use strict";
|
|
8710
|
-
init_cloudUpstream();
|
|
8711
|
-
SECONDS_PER_HOUR = 3600;
|
|
8712
|
-
HOURS_PER_FIVE_HOUR_WINDOW = 5;
|
|
8713
|
-
DAYS_PER_WEEK = 7;
|
|
8714
|
-
HOURS_PER_DAY4 = 24;
|
|
8715
|
-
FIVE_HOUR_PERIOD_SECONDS = HOURS_PER_FIVE_HOUR_WINDOW * SECONDS_PER_HOUR;
|
|
8716
|
-
WEEK_PERIOD_SECONDS = DAYS_PER_WEEK * HOURS_PER_DAY4 * SECONDS_PER_HOUR;
|
|
8908
|
+
function newestTranscript(fs13, projectDir) {
|
|
8909
|
+
let newest;
|
|
8910
|
+
let newestMs = -Infinity;
|
|
8911
|
+
for (const name of fs13.readdir(projectDir)) {
|
|
8912
|
+
if (!name.endsWith(".jsonl")) {
|
|
8913
|
+
continue;
|
|
8914
|
+
}
|
|
8915
|
+
const candidate = import_node_path38.default.join(projectDir, name);
|
|
8916
|
+
const stat = fs13.lstat(candidate);
|
|
8917
|
+
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
8918
|
+
newestMs = stat.mtimeMs;
|
|
8919
|
+
newest = candidate;
|
|
8920
|
+
}
|
|
8717
8921
|
}
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8922
|
+
return newest;
|
|
8923
|
+
}
|
|
8924
|
+
function resumedContextTokens(fs13, params) {
|
|
8925
|
+
const target = resumeTargetOf(params.passthrough);
|
|
8926
|
+
if (target === void 0) {
|
|
8927
|
+
return void 0;
|
|
8724
8928
|
}
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8929
|
+
const projectDir = import_node_path38.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
8930
|
+
const file = target.kind === "id" ? import_node_path38.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs13, projectDir);
|
|
8931
|
+
const text = file === void 0 ? void 0 : fs13.readFileUtf8(file);
|
|
8932
|
+
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
8933
|
+
}
|
|
8934
|
+
var import_node_path38;
|
|
8935
|
+
var init_resumeContext = __esm({
|
|
8936
|
+
"src/usage/resumeContext.ts"() {
|
|
8731
8937
|
"use strict";
|
|
8732
|
-
|
|
8733
|
-
TextBlockSchema = import_zod29.z.looseObject({ type: import_zod29.z.literal("text"), text: import_zod29.z.string() });
|
|
8734
|
-
Base64ImageSourceSchema = import_zod29.z.looseObject({ type: import_zod29.z.literal("base64"), media_type: import_zod29.z.string().min(1), data: import_zod29.z.string() });
|
|
8735
|
-
UrlImageSourceSchema = import_zod29.z.looseObject({ type: import_zod29.z.literal("url"), url: import_zod29.z.string().min(1) });
|
|
8736
|
-
ImageBlockSchema = import_zod29.z.looseObject({
|
|
8737
|
-
type: import_zod29.z.literal("image"),
|
|
8738
|
-
source: import_zod29.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
8739
|
-
});
|
|
8740
|
-
ToolUseBlockSchema = import_zod29.z.looseObject({
|
|
8741
|
-
type: import_zod29.z.literal("tool_use"),
|
|
8742
|
-
id: import_zod29.z.string().min(1),
|
|
8743
|
-
name: import_zod29.z.string().min(1),
|
|
8744
|
-
input: import_zod29.z.unknown()
|
|
8745
|
-
});
|
|
8746
|
-
ToolResultContentBlockSchema = import_zod29.z.union([TextBlockSchema, import_zod29.z.looseObject({ type: import_zod29.z.string() })]);
|
|
8747
|
-
ToolResultBlockSchema = import_zod29.z.looseObject({
|
|
8748
|
-
type: import_zod29.z.literal("tool_result"),
|
|
8749
|
-
tool_use_id: import_zod29.z.string().min(1),
|
|
8750
|
-
content: import_zod29.z.union([import_zod29.z.string(), import_zod29.z.array(ToolResultContentBlockSchema)]).optional()
|
|
8751
|
-
});
|
|
8752
|
-
OtherBlockSchema = import_zod29.z.looseObject({ type: import_zod29.z.string() });
|
|
8753
|
-
ContentBlockSchema = import_zod29.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
8754
|
-
MessageSchema = import_zod29.z.looseObject({
|
|
8755
|
-
role: import_zod29.z.enum(["user", "assistant", "system"]),
|
|
8756
|
-
content: import_zod29.z.union([import_zod29.z.string(), import_zod29.z.array(ContentBlockSchema)])
|
|
8757
|
-
});
|
|
8758
|
-
ToolSchema = import_zod29.z.looseObject({
|
|
8759
|
-
name: import_zod29.z.string().min(1),
|
|
8760
|
-
description: import_zod29.z.string().optional(),
|
|
8761
|
-
input_schema: import_zod29.z.record(import_zod29.z.string(), import_zod29.z.unknown()).optional()
|
|
8762
|
-
});
|
|
8763
|
-
ToolChoiceSchema = import_zod29.z.union([
|
|
8764
|
-
import_zod29.z.looseObject({ type: import_zod29.z.enum(["auto", "none", "any"]) }),
|
|
8765
|
-
import_zod29.z.looseObject({ type: import_zod29.z.literal("tool"), name: import_zod29.z.string().min(1) })
|
|
8766
|
-
]);
|
|
8767
|
-
SystemSchema = import_zod29.z.union([import_zod29.z.string(), import_zod29.z.array(import_zod29.z.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
8768
|
-
MessagesRequestSchema = import_zod29.z.looseObject({
|
|
8769
|
-
model: import_zod29.z.string().optional(),
|
|
8770
|
-
system: SystemSchema.optional(),
|
|
8771
|
-
messages: import_zod29.z.array(MessageSchema),
|
|
8772
|
-
tools: import_zod29.z.array(ToolSchema).optional(),
|
|
8773
|
-
tool_choice: ToolChoiceSchema.optional(),
|
|
8774
|
-
stream: import_zod29.z.boolean().optional(),
|
|
8775
|
-
/** `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. */
|
|
8776
|
-
metadata: import_zod29.z.looseObject({ user_id: import_zod29.z.string().optional() }).optional(),
|
|
8777
|
-
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
8778
|
-
output_config: import_zod29.z.looseObject({ effort: import_zod29.z.string().optional() }).optional()
|
|
8779
|
-
});
|
|
8780
|
-
CountTokensRequestSchema = import_zod29.z.looseObject({
|
|
8781
|
-
system: import_zod29.z.unknown().optional(),
|
|
8782
|
-
messages: import_zod29.z.unknown().optional(),
|
|
8783
|
-
tools: import_zod29.z.unknown().optional()
|
|
8784
|
-
});
|
|
8938
|
+
import_node_path38 = __toESM(require("node:path"), 1);
|
|
8785
8939
|
}
|
|
8786
8940
|
});
|
|
8787
8941
|
|
|
8788
|
-
// src/
|
|
8789
|
-
function
|
|
8790
|
-
return
|
|
8942
|
+
// src/launcher/claudeSession.ts
|
|
8943
|
+
function isFlag(token) {
|
|
8944
|
+
return token?.startsWith("-") === true;
|
|
8791
8945
|
}
|
|
8792
|
-
function
|
|
8793
|
-
|
|
8946
|
+
function withConversation(passthrough, conversation, id) {
|
|
8947
|
+
const end = passthrough.indexOf(TERMINATOR2);
|
|
8948
|
+
const head = end === -1 ? passthrough : passthrough.slice(0, end);
|
|
8949
|
+
const tail = end === -1 ? [] : passthrough.slice(end);
|
|
8950
|
+
const kept = [];
|
|
8951
|
+
for (let index = 0; index < head.length; index += 1) {
|
|
8952
|
+
const token = head[index];
|
|
8953
|
+
if (token === void 0 || CONTINUE_FLAGS.has(token) || token.startsWith("--resume=") || token.startsWith("--session-id=")) {
|
|
8954
|
+
continue;
|
|
8955
|
+
}
|
|
8956
|
+
if (VALUED_CONVERSATION_FLAGS.has(token)) {
|
|
8957
|
+
if (!isFlag(head[index + 1]) && head[index + 1] !== void 0) {
|
|
8958
|
+
index += 1;
|
|
8959
|
+
}
|
|
8960
|
+
continue;
|
|
8961
|
+
}
|
|
8962
|
+
kept.push(token);
|
|
8963
|
+
}
|
|
8964
|
+
return [...kept, conversation === "start" ? "--session-id" : "--resume", id, ...tail];
|
|
8794
8965
|
}
|
|
8795
|
-
function
|
|
8796
|
-
const
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8966
|
+
function hasSettingsArgument(passthrough) {
|
|
8967
|
+
const end = passthrough.indexOf(TERMINATOR2);
|
|
8968
|
+
return (end === -1 ? passthrough : passthrough.slice(0, end)).some((token) => token === "--settings" || token.startsWith("--settings="));
|
|
8969
|
+
}
|
|
8970
|
+
function withSupervision(passthrough, supervised) {
|
|
8971
|
+
if (supervised.conversation === "as-given") {
|
|
8972
|
+
return passthrough;
|
|
8973
|
+
}
|
|
8974
|
+
const conversed = withConversation(passthrough, supervised.conversation, supervised.sessionId);
|
|
8975
|
+
if (supervised.model === void 0) {
|
|
8976
|
+
return conversed;
|
|
8977
|
+
}
|
|
8978
|
+
const end = conversed.indexOf(TERMINATOR2);
|
|
8979
|
+
const head = end === -1 ? conversed : conversed.slice(0, end);
|
|
8980
|
+
const tail = end === -1 ? [] : conversed.slice(end);
|
|
8981
|
+
const kept = [];
|
|
8982
|
+
for (let index = 0; index < head.length; index += 1) {
|
|
8983
|
+
const token = head[index];
|
|
8984
|
+
if (token === "--model") {
|
|
8985
|
+
index += 1;
|
|
8986
|
+
continue;
|
|
8987
|
+
}
|
|
8988
|
+
if (token !== void 0 && !token.startsWith("--model=")) {
|
|
8989
|
+
kept.push(token);
|
|
8801
8990
|
}
|
|
8802
8991
|
}
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
aliases.set(AUTO_ALIAS, [...new Set(CLAUDE_TIERS.flatMap(tierModel))]);
|
|
8992
|
+
return [...kept, "--model", supervised.model, ...tail];
|
|
8993
|
+
}
|
|
8994
|
+
function withLauncherSettings(passthrough, settings) {
|
|
8995
|
+
if (settings === void 0) {
|
|
8996
|
+
return passthrough;
|
|
8809
8997
|
}
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
local: {
|
|
8823
|
-
command: config?.local?.command,
|
|
8824
|
-
socketPath: config?.local?.socketPath
|
|
8998
|
+
const end = passthrough.indexOf(TERMINATOR2);
|
|
8999
|
+
return end === -1 ? [...passthrough, "--settings", settings] : [...passthrough.slice(0, end), "--settings", settings, ...passthrough.slice(end)];
|
|
9000
|
+
}
|
|
9001
|
+
function isRecord15(value) {
|
|
9002
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9003
|
+
}
|
|
9004
|
+
function mergeSettings(parts) {
|
|
9005
|
+
const merged = {};
|
|
9006
|
+
let any = false;
|
|
9007
|
+
for (const part of parts) {
|
|
9008
|
+
if (part === void 0) {
|
|
9009
|
+
continue;
|
|
8825
9010
|
}
|
|
8826
|
-
|
|
9011
|
+
const parsed = JSON.parse(part);
|
|
9012
|
+
if (!isRecord15(parsed)) {
|
|
9013
|
+
throw new Error("a launch's settings part is not a JSON object");
|
|
9014
|
+
}
|
|
9015
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
9016
|
+
if (key in merged) {
|
|
9017
|
+
throw new Error(`two launch settings parts both set "${key}"`);
|
|
9018
|
+
}
|
|
9019
|
+
merged[key] = value;
|
|
9020
|
+
}
|
|
9021
|
+
any = true;
|
|
9022
|
+
}
|
|
9023
|
+
return any ? JSON.stringify(merged) : void 0;
|
|
8827
9024
|
}
|
|
8828
|
-
var
|
|
8829
|
-
var
|
|
8830
|
-
"src/
|
|
9025
|
+
var TERMINATOR2, VALUED_CONVERSATION_FLAGS, CONTINUE_FLAGS;
|
|
9026
|
+
var init_claudeSession = __esm({
|
|
9027
|
+
"src/launcher/claudeSession.ts"() {
|
|
8831
9028
|
"use strict";
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
init_schema();
|
|
8837
|
-
init_anthropic();
|
|
8838
|
-
AUTO_ALIAS = "auto";
|
|
9029
|
+
init_resumeContext();
|
|
9030
|
+
TERMINATOR2 = "--";
|
|
9031
|
+
VALUED_CONVERSATION_FLAGS = /* @__PURE__ */ new Set(["--resume", "-r", "--session-id"]);
|
|
9032
|
+
CONTINUE_FLAGS = /* @__PURE__ */ new Set(["--continue", "-c"]);
|
|
8839
9033
|
}
|
|
8840
9034
|
});
|
|
8841
9035
|
|
|
8842
|
-
// src/
|
|
8843
|
-
function
|
|
8844
|
-
const
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
9036
|
+
// src/launcher/diagnostics.ts
|
|
9037
|
+
function diagnosticLines(diagnostics) {
|
|
9038
|
+
const unclassified = [...new Set(diagnostics.filter((diagnostic) => diagnostic.code === "UNCLASSIFIED_ENTRY").map((diagnostic) => diagnostic.subject))];
|
|
9039
|
+
const lines = [];
|
|
9040
|
+
let unclassifiedReported = false;
|
|
9041
|
+
for (const diagnostic of diagnostics) {
|
|
9042
|
+
if (diagnostic.severity === "info") {
|
|
9043
|
+
continue;
|
|
9044
|
+
}
|
|
9045
|
+
if (diagnostic.code === "UNCLASSIFIED_ENTRY") {
|
|
9046
|
+
if (!unclassifiedReported) {
|
|
9047
|
+
unclassifiedReported = true;
|
|
9048
|
+
const names = unclassified.filter((name) => name !== void 0);
|
|
9049
|
+
lines.push({ severity: diagnostic.severity, text: `agent-shim: ${diagnostic.code}: ${unclassifiedEntrySummary(names)}
|
|
9050
|
+
${unclassifiedEntryFix(names)}.` });
|
|
9051
|
+
}
|
|
9052
|
+
continue;
|
|
9053
|
+
}
|
|
9054
|
+
lines.push({ severity: diagnostic.severity, text: `agent-shim: ${diagnostic.code}: ${diagnostic.message}` });
|
|
9055
|
+
}
|
|
9056
|
+
return lines;
|
|
8856
9057
|
}
|
|
8857
|
-
|
|
8858
|
-
|
|
9058
|
+
function printDiagnosticLines(log, lines, options) {
|
|
9059
|
+
for (const line of lines) {
|
|
9060
|
+
if (line.severity === "error" && !options.errorsAsWarnings) {
|
|
9061
|
+
log.error(line.text);
|
|
9062
|
+
} else {
|
|
9063
|
+
log.warn(line.text);
|
|
9064
|
+
}
|
|
9065
|
+
}
|
|
9066
|
+
}
|
|
9067
|
+
function reportDiagnostics(log, diagnostics, options) {
|
|
9068
|
+
printDiagnosticLines(log, diagnosticLines(diagnostics), options);
|
|
9069
|
+
}
|
|
9070
|
+
var init_diagnostics = __esm({
|
|
9071
|
+
"src/launcher/diagnostics.ts"() {
|
|
8859
9072
|
"use strict";
|
|
8860
|
-
|
|
8861
|
-
init_anthropic();
|
|
9073
|
+
init_decide();
|
|
8862
9074
|
}
|
|
8863
9075
|
});
|
|
8864
9076
|
|
|
8865
|
-
// src/
|
|
8866
|
-
function
|
|
8867
|
-
return
|
|
9077
|
+
// src/launcher/hold.ts
|
|
9078
|
+
function describeDelay(ms) {
|
|
9079
|
+
return ms % MS_PER_SECOND8 === 0 ? `${String(ms / MS_PER_SECOND8)}s` : `${String(ms)}ms`;
|
|
8868
9080
|
}
|
|
8869
|
-
function
|
|
8870
|
-
if (
|
|
8871
|
-
return
|
|
9081
|
+
function holdBeforeLaunch(hold, port, log) {
|
|
9082
|
+
if (port === void 0 || !port.attended() || !hold.pause && hold.delayMs <= 0) {
|
|
9083
|
+
return "go";
|
|
8872
9084
|
}
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
return
|
|
8876
|
-
} catch {
|
|
8877
|
-
return void 0;
|
|
9085
|
+
if (hold.pause) {
|
|
9086
|
+
log.info("agent-shim: paused before launch; press any key to start, or Ctrl-C to cancel");
|
|
9087
|
+
return port.waitForKey() === "interrupt" ? "cancelled" : "go";
|
|
8878
9088
|
}
|
|
9089
|
+
log.info(`agent-shim: starting in ${describeDelay(hold.delayMs)}`);
|
|
9090
|
+
port.sleep(hold.delayMs);
|
|
9091
|
+
return "go";
|
|
8879
9092
|
}
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
var import_node_path38, import_picomatch4, import_zod30, DEFAULT_CANDIDATE_URLS, MS_PER_SECOND8, SECONDS_PER_HOUR2, HOURS_PER_DAY5, MS_PER_HOUR5, HOURS_BETWEEN_RETRIES, CATALOGUE_MAX_AGE_MS, CATALOGUE_RETRY_MS, CATALOGUE_REQUEST_SECONDS, CATALOGUE_REQUEST_TIMEOUT_MS, CATALOGUE_REFRESH_TIMEOUT_MS, CatalogueModelSchema, CatalogueCacheSchema;
|
|
8886
|
-
var init_providerCatalogue = __esm({
|
|
8887
|
-
"src/providerCatalogue.ts"() {
|
|
8888
|
-
"use strict";
|
|
8889
|
-
import_node_path38 = __toESM(require("node:path"), 1);
|
|
8890
|
-
import_picomatch4 = __toESM(require("picomatch"), 1);
|
|
8891
|
-
import_zod30 = require("zod");
|
|
8892
|
-
DEFAULT_CANDIDATE_URLS = 2;
|
|
9093
|
+
var LAUNCH_CANCELLED_EXIT, MS_PER_SECOND8;
|
|
9094
|
+
var init_hold = __esm({
|
|
9095
|
+
"src/launcher/hold.ts"() {
|
|
9096
|
+
"use strict";
|
|
9097
|
+
LAUNCH_CANCELLED_EXIT = 130;
|
|
8893
9098
|
MS_PER_SECOND8 = 1e3;
|
|
8894
|
-
SECONDS_PER_HOUR2 = 3600;
|
|
8895
|
-
HOURS_PER_DAY5 = 24;
|
|
8896
|
-
MS_PER_HOUR5 = SECONDS_PER_HOUR2 * MS_PER_SECOND8;
|
|
8897
|
-
HOURS_BETWEEN_RETRIES = 1;
|
|
8898
|
-
CATALOGUE_MAX_AGE_MS = HOURS_PER_DAY5 * MS_PER_HOUR5;
|
|
8899
|
-
CATALOGUE_RETRY_MS = HOURS_BETWEEN_RETRIES * MS_PER_HOUR5;
|
|
8900
|
-
CATALOGUE_REQUEST_SECONDS = 10;
|
|
8901
|
-
CATALOGUE_REQUEST_TIMEOUT_MS = CATALOGUE_REQUEST_SECONDS * MS_PER_SECOND8;
|
|
8902
|
-
CATALOGUE_REFRESH_TIMEOUT_MS = DEFAULT_CANDIDATE_URLS * CATALOGUE_REQUEST_TIMEOUT_MS;
|
|
8903
|
-
CatalogueModelSchema = import_zod30.z.strictObject({ id: import_zod30.z.string().min(1), name: import_zod30.z.string().min(1).optional() });
|
|
8904
|
-
CatalogueCacheSchema = import_zod30.z.strictObject({ fetchedAt: import_zod30.z.number(), url: import_zod30.z.string().min(1), models: import_zod30.z.array(CatalogueModelSchema) });
|
|
8905
9099
|
}
|
|
8906
9100
|
});
|
|
8907
9101
|
|
|
8908
|
-
// src/
|
|
8909
|
-
function
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? `${description}; 1M context` : description;
|
|
8914
|
-
}
|
|
8915
|
-
function joined(parts) {
|
|
8916
|
-
const last = parts[parts.length - 1];
|
|
8917
|
-
return last === void 0 || parts.length === 1 ? last ?? "" : `${parts.slice(0, -1).join(", ")} and ${last}`;
|
|
9102
|
+
// src/usage/candidateText.ts
|
|
9103
|
+
function candidateHeading(candidate) {
|
|
9104
|
+
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
9105
|
+
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
9106
|
+
return `[${candidate.class}${score}]${dry}`;
|
|
8918
9107
|
}
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
throw new Error(`model ${model} is reached by no tier`);
|
|
9108
|
+
var init_candidateText = __esm({
|
|
9109
|
+
"src/usage/candidateText.ts"() {
|
|
9110
|
+
"use strict";
|
|
8923
9111
|
}
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
const reachesByModel = /* @__PURE__ */ new Map();
|
|
8932
|
-
for (const [tier, candidates] of table) {
|
|
8933
|
-
candidates.forEach((model, index) => {
|
|
8934
|
-
const reaches = reachesByModel.get(model) ?? [];
|
|
8935
|
-
if (!reaches.some((reach) => reach.tier === tier)) {
|
|
8936
|
-
reaches.push({ tier, standing: index === 0 ? "first" : "fallback" });
|
|
8937
|
-
}
|
|
8938
|
-
reachesByModel.set(model, reaches);
|
|
8939
|
-
});
|
|
9112
|
+
});
|
|
9113
|
+
|
|
9114
|
+
// src/launcher/launchReport.ts
|
|
9115
|
+
function poolDetail(pool) {
|
|
9116
|
+
const [reason] = pool.reasons;
|
|
9117
|
+
if (pool.movedOff !== void 0) {
|
|
9118
|
+
return { detail: `moved off ${pool.movedOff.identity}: ${pool.movedOff.reason}`, ...reason === void 0 ? {} : { notes: [reason] } };
|
|
8940
9119
|
}
|
|
8941
|
-
return
|
|
8942
|
-
}
|
|
8943
|
-
function antigravityRows(provider) {
|
|
8944
|
-
const config = resolveAntigravityConfig(provider.antigravity);
|
|
8945
|
-
const tiers = rowsOfTable(CLAUDE_TIERS.map((tier) => [tier, config.models[tier]]));
|
|
8946
|
-
const behavesAsOf = new Map(tiers.map((row) => [row.model, row.behavesAs]));
|
|
8947
|
-
const aliases = [...config.aliases].flatMap(([alias, candidates]) => {
|
|
8948
|
-
const [first] = candidates;
|
|
8949
|
-
const behavesAs = first === void 0 ? void 0 : behavesAsOf.get(first);
|
|
8950
|
-
const description = alias === AUTO_ALIAS ? `Routes each request to a backend model with quota left, best first (${String(candidates.length)} models)` : `Alias for ${candidates.join(", then ")}`;
|
|
8951
|
-
return behavesAs === void 0 ? [] : [{ model: alias, label: labelOf(alias), description, behavesAs }];
|
|
8952
|
-
});
|
|
8953
|
-
return [...aliases.filter((row) => row.model === AUTO_ALIAS), ...tiers, ...aliases.filter((row) => row.model !== AUTO_ALIAS)];
|
|
9120
|
+
return reason === void 0 ? {} : { detail: reason };
|
|
8954
9121
|
}
|
|
8955
|
-
function
|
|
8956
|
-
|
|
8957
|
-
|
|
9122
|
+
function rankingNotes(ranking, picked) {
|
|
9123
|
+
return ranking.flatMap((candidate, index) => [
|
|
9124
|
+
`${String(index + 1)}. ${candidate.identity} ${candidateHeading(candidate)}${candidate.identity === picked ? " (picked)" : ""}`,
|
|
9125
|
+
` ${candidate.reasons.join("; ")}`
|
|
9126
|
+
]);
|
|
8958
9127
|
}
|
|
8959
|
-
function
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
9128
|
+
function decisionRows(facts) {
|
|
9129
|
+
return [
|
|
9130
|
+
{ label: "identity", value: facts.identity ?? "(none)", detail: facts.identitySource },
|
|
9131
|
+
...facts.pool === void 0 ? [] : [
|
|
9132
|
+
{
|
|
9133
|
+
label: "pool",
|
|
9134
|
+
value: facts.pool.name,
|
|
9135
|
+
...poolDetail(facts.pool),
|
|
9136
|
+
...facts.ranking === void 0 ? {} : { notes: rankingNotes(facts.ranking, facts.identity) }
|
|
9137
|
+
}
|
|
9138
|
+
],
|
|
9139
|
+
...facts.profile === void 0 ? [] : [{ label: "profile", value: facts.profile.name, detail: facts.profile.source }],
|
|
9140
|
+
...facts.provider === void 0 ? [] : [{ label: "provider", value: facts.provider.name, detail: `credential ${facts.provider.credential}` }],
|
|
9141
|
+
...facts.identityCredential === void 0 ? [] : [{ label: "credential", value: facts.identityCredential, detail: "the identity's own" }]
|
|
9142
|
+
];
|
|
8966
9143
|
}
|
|
8967
|
-
function
|
|
8968
|
-
return {
|
|
8969
|
-
model: entry.model,
|
|
8970
|
-
label: entry.label ?? labelOf(entry.model),
|
|
8971
|
-
description: entry.description ?? describedAs(entry.model, `Declared by the provider for the ${entry.tier} tier`),
|
|
8972
|
-
behavesAs: TIER_BEHAVES_AS[entry.tier]
|
|
8973
|
-
};
|
|
9144
|
+
function pinnedVersionRow(version, source) {
|
|
9145
|
+
return { label: "claude", value: version, detail: `pinned by ${source}` };
|
|
8974
9146
|
}
|
|
8975
|
-
function
|
|
8976
|
-
if (
|
|
9147
|
+
function routingRows(facts) {
|
|
9148
|
+
if (facts.frontDoor === void 0) {
|
|
8977
9149
|
return [];
|
|
8978
9150
|
}
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
const taken = new Set(named.map((row) => labelOf(row.model)));
|
|
8988
|
-
return [...named, ...catalogueRows(provider, catalogue).filter((row) => !taken.has(labelOf(row.model)))];
|
|
8989
|
-
}
|
|
8990
|
-
function routedModelRows(models, providers) {
|
|
8991
|
-
const hidden = new Set(models.hide ?? []);
|
|
8992
|
-
const shown = models.show === void 0 ? void 0 : new Set(models.show);
|
|
8993
|
-
const visible = (model) => shown === void 0 ? !hidden.has(model) : shown.has(model);
|
|
8994
|
-
const tierOf = (model) => {
|
|
8995
|
-
for (const [, provider] of providers) {
|
|
8996
|
-
if (provider.kind !== void 0 && provider.kind !== "http") {
|
|
8997
|
-
continue;
|
|
8998
|
-
}
|
|
8999
|
-
const match = Object.entries(provider.env ?? {}).find(([key, value]) => value === model && key.startsWith("ANTHROPIC_DEFAULT_") && key.endsWith("_MODEL"));
|
|
9000
|
-
if (match !== void 0) {
|
|
9001
|
-
const tier = match[0].replace("ANTHROPIC_DEFAULT_", "").replace("_MODEL", "").toLowerCase();
|
|
9002
|
-
return tier === "fable" || tier === "opus" || tier === "sonnet" || tier === "haiku" ? tier : void 0;
|
|
9003
|
-
}
|
|
9004
|
-
}
|
|
9005
|
-
return void 0;
|
|
9006
|
-
};
|
|
9007
|
-
const virtual = Object.entries(models.virtual ?? {}).flatMap(([name, definition]) => {
|
|
9008
|
-
if (!visible(name)) {
|
|
9009
|
-
return [];
|
|
9010
|
-
}
|
|
9011
|
-
const first = definition.members.find((member) => member.includes("/"));
|
|
9012
|
-
const tier = first === void 0 ? void 0 : tierOf(first.split("/").slice(1).join("/"));
|
|
9013
|
-
const behavesAs = tier === void 0 ? void 0 : TIER_BEHAVES_AS[tier];
|
|
9014
|
-
return behavesAs === void 0 ? [] : [{ model: name, label: name, description: `Virtual (${definition.mode})`, behavesAs }];
|
|
9015
|
-
});
|
|
9016
|
-
const concrete = providers.flatMap(([name, provider]) => providerModelRows(provider).map((row) => ({ ...row, model: `${name}/${row.model}`, label: `${name} / ${row.label}`, description: `${name}: ${row.description}` })));
|
|
9017
|
-
return [...virtual, ...concrete.filter((row) => visible(row.model))];
|
|
9151
|
+
return [
|
|
9152
|
+
{
|
|
9153
|
+
label: "routing",
|
|
9154
|
+
value: `front door 127.0.0.1:${String(facts.frontDoor.port)}`,
|
|
9155
|
+
...facts.provider ? {} : { detail: `OAuth via CONNECT 127.0.0.1:${String(facts.frontDoor.connectPort)}` }
|
|
9156
|
+
},
|
|
9157
|
+
...facts.headroom === void 0 ? [] : [{ label: "headroom", value: "on", detail: `project ${facts.headroom.projectId}` }]
|
|
9158
|
+
];
|
|
9018
9159
|
}
|
|
9019
|
-
function
|
|
9020
|
-
|
|
9160
|
+
function farmRow(links, builtDirectories, adopted) {
|
|
9161
|
+
const counted = (count, singular, plural) => `${String(count)} ${count === 1 ? singular : plural}`;
|
|
9162
|
+
const parts = [counted(links, "link", "links"), counted(builtDirectories, "built directory", "built directories"), ...adopted === 0 ? [] : [`${String(adopted)} adopted`]];
|
|
9163
|
+
return { label: "farm", value: "resynced", detail: parts.join(", ") };
|
|
9021
9164
|
}
|
|
9022
|
-
function
|
|
9023
|
-
return
|
|
9165
|
+
function noteRow(text) {
|
|
9166
|
+
return { label: "note", value: text };
|
|
9024
9167
|
}
|
|
9025
|
-
var
|
|
9026
|
-
|
|
9027
|
-
"src/launcher/modelPicker.ts"() {
|
|
9168
|
+
var init_launchReport = __esm({
|
|
9169
|
+
"src/launcher/launchReport.ts"() {
|
|
9028
9170
|
"use strict";
|
|
9029
|
-
|
|
9030
|
-
init_translate2();
|
|
9031
|
-
init_providerCatalogue();
|
|
9032
|
-
init_schema();
|
|
9033
|
-
init_identity2();
|
|
9034
|
-
TIER_BEHAVES_AS = Object.freeze({
|
|
9035
|
-
fable: "claude-fable-5-1",
|
|
9036
|
-
opus: "claude-opus-5-5",
|
|
9037
|
-
sonnet: "claude-sonnet-5-5",
|
|
9038
|
-
haiku: "claude-haiku-5-5"
|
|
9039
|
-
});
|
|
9040
|
-
TIER_ENV_VARIABLES = Object.freeze({
|
|
9041
|
-
fable: "ANTHROPIC_DEFAULT_FABLE_MODEL",
|
|
9042
|
-
opus: "ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
9043
|
-
sonnet: "ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
9044
|
-
haiku: "ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
|
9045
|
-
});
|
|
9171
|
+
init_candidateText();
|
|
9046
9172
|
}
|
|
9047
9173
|
});
|
|
9048
9174
|
|
|
@@ -15188,8 +15314,8 @@ var ResetRowSchema = import_zod18.z.strictObject({
|
|
|
15188
15314
|
var ResetScheduleSchema = import_zod18.z.strictObject({ resets: import_zod18.z.readonly(import_zod18.z.array(ResetRowSchema)) });
|
|
15189
15315
|
|
|
15190
15316
|
// src/frontdoor/controlSchemas.ts
|
|
15191
|
-
var
|
|
15192
|
-
var
|
|
15317
|
+
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
15318
|
+
var import_zod25 = require("zod");
|
|
15193
15319
|
|
|
15194
15320
|
// src/doctorReport.ts
|
|
15195
15321
|
init_claudeShim();
|
|
@@ -15365,7 +15491,7 @@ function removeIdentity(paths, name) {
|
|
|
15365
15491
|
// src/doctorReport.ts
|
|
15366
15492
|
init_realPorts();
|
|
15367
15493
|
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
15368
|
-
var
|
|
15494
|
+
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
15369
15495
|
init_signIn();
|
|
15370
15496
|
|
|
15371
15497
|
// src/codex/siwcStore.ts
|
|
@@ -15456,6 +15582,57 @@ init_source();
|
|
|
15456
15582
|
|
|
15457
15583
|
// src/models/doctor.ts
|
|
15458
15584
|
init_modelsStore();
|
|
15585
|
+
|
|
15586
|
+
// src/models/families.ts
|
|
15587
|
+
init_identity2();
|
|
15588
|
+
var FAMILY_PREFIX = "family:";
|
|
15589
|
+
var VARIANT_SEPARATOR = "+";
|
|
15590
|
+
function modelOf(ref) {
|
|
15591
|
+
const slash = ref.indexOf("/");
|
|
15592
|
+
return slash === -1 ? ref : ref.slice(slash + 1);
|
|
15593
|
+
}
|
|
15594
|
+
function familyKeyOf(rawModel) {
|
|
15595
|
+
const identity = modelIdentity(rawModel);
|
|
15596
|
+
return identity.variant === "" ? identity.familyAndVersion : `${identity.familyAndVersion}${VARIANT_SEPARATOR}${identity.variant}`;
|
|
15597
|
+
}
|
|
15598
|
+
function assertionsOf(models) {
|
|
15599
|
+
return { same: models?.same ?? [], distinct: models?.distinct ?? [] };
|
|
15600
|
+
}
|
|
15601
|
+
function sameModel(left, right, assertions) {
|
|
15602
|
+
if (assertions.distinct.some(([a, b]) => a === left && b === right || a === right && b === left)) {
|
|
15603
|
+
return false;
|
|
15604
|
+
}
|
|
15605
|
+
const leftGroup = assertions.same.find((group) => group.includes(left));
|
|
15606
|
+
const rightGroup = assertions.same.find((group) => group.includes(right));
|
|
15607
|
+
if (leftGroup !== void 0 && leftGroup === rightGroup) {
|
|
15608
|
+
return true;
|
|
15609
|
+
}
|
|
15610
|
+
if (leftGroup !== void 0 && !leftGroup.includes(right) || rightGroup !== void 0 && !rightGroup.includes(left)) {
|
|
15611
|
+
return false;
|
|
15612
|
+
}
|
|
15613
|
+
return relateModels(modelOf(left), modelOf(right)) === "same";
|
|
15614
|
+
}
|
|
15615
|
+
function pinnedTo(settings, ref) {
|
|
15616
|
+
return settings?.names?.some((name) => name === ref || name === modelOf(ref)) === true;
|
|
15617
|
+
}
|
|
15618
|
+
function buildFamilies(refs, models) {
|
|
15619
|
+
const assertions = assertionsOf(models);
|
|
15620
|
+
const settingsByKey = models?.families ?? {};
|
|
15621
|
+
const groups = [];
|
|
15622
|
+
for (const ref of refs) {
|
|
15623
|
+
const pinnedKey = Object.entries(settingsByKey).find(([, settings]) => pinnedTo(settings, ref))?.[0];
|
|
15624
|
+
const joined2 = groups.find((group) => pinnedKey === void 0 ? group.refs.some((first) => sameModel(first, ref, assertions)) : group.key === pinnedKey);
|
|
15625
|
+
if (joined2 !== void 0) {
|
|
15626
|
+
joined2.refs.push(ref);
|
|
15627
|
+
} else {
|
|
15628
|
+
groups.push({ key: pinnedKey ?? familyKeyOf(modelOf(ref)), refs: [ref] });
|
|
15629
|
+
}
|
|
15630
|
+
}
|
|
15631
|
+
return groups.map((group) => ({ key: group.key, refs: group.refs, settings: settingsByKey[group.key] ?? {} }));
|
|
15632
|
+
}
|
|
15633
|
+
|
|
15634
|
+
// src/models/doctor.ts
|
|
15635
|
+
init_identity2();
|
|
15459
15636
|
function modelsFindings(input) {
|
|
15460
15637
|
const findings = [];
|
|
15461
15638
|
const { models } = input;
|
|
@@ -15500,6 +15677,38 @@ function modelsFindings(input) {
|
|
|
15500
15677
|
findings.push({ severity: "fail", message: `Tier ${tier} points at "${ref}", which names nothing defined.` });
|
|
15501
15678
|
}
|
|
15502
15679
|
}
|
|
15680
|
+
const modelOfRef = (ref) => ref.slice(ref.indexOf("/") + 1);
|
|
15681
|
+
for (const group of models.same ?? []) {
|
|
15682
|
+
for (let outer = 0; outer < group.length; outer += 1) {
|
|
15683
|
+
for (let inner = outer + 1; inner < group.length; inner += 1) {
|
|
15684
|
+
const left = group[outer] ?? "";
|
|
15685
|
+
const right = group[inner] ?? "";
|
|
15686
|
+
if (!left.startsWith("acct:") && !right.startsWith("acct:") && relateModels(modelOfRef(left), modelOfRef(right)) === "distinct") {
|
|
15687
|
+
findings.push({ severity: "warn", message: `"${left}" and "${right}" are asserted to be one model, but their names say they are different models; check the assertion is not a typo.` });
|
|
15688
|
+
}
|
|
15689
|
+
if ((models.distinct ?? []).some(([a, b]) => a === left && b === right || a === right && b === left)) {
|
|
15690
|
+
findings.push({ severity: "fail", message: `"${left}" and "${right}" are asserted to be both one model and two models.` });
|
|
15691
|
+
}
|
|
15692
|
+
}
|
|
15693
|
+
}
|
|
15694
|
+
}
|
|
15695
|
+
for (const [name, model] of Object.entries(models.virtual ?? {})) {
|
|
15696
|
+
const concrete = model.members.filter((member) => memberKindOf(member, models) === "provider" && member.includes("/"));
|
|
15697
|
+
const looksAlike = concrete.flatMap((left, index) => concrete.slice(index + 1).filter((right) => relateModels(modelOfRef(left), modelOfRef(right)) === "same").map((right) => [left, right]));
|
|
15698
|
+
for (const [left, right] of looksAlike) {
|
|
15699
|
+
findings.push({ severity: "warn", message: `Virtual model "${name}" lists "${left}" and "${right}", which look like one model; a member ${FAMILY_PREFIX}${familyKeyOf(modelOfRef(left))} names every target of it.` });
|
|
15700
|
+
}
|
|
15701
|
+
}
|
|
15702
|
+
if (input.targets !== void 0) {
|
|
15703
|
+
const families = buildFamilies(input.targets, models);
|
|
15704
|
+
for (const [name, model] of Object.entries(models.virtual ?? {})) {
|
|
15705
|
+
for (const member of model.members.filter((entry) => entry.startsWith(FAMILY_PREFIX))) {
|
|
15706
|
+
if (!families.some((family) => `${FAMILY_PREFIX}${family.key}` === member)) {
|
|
15707
|
+
findings.push({ severity: "warn", message: `Virtual model "${name}" names ${member}, but no target the providers offer belongs to that family.` });
|
|
15708
|
+
}
|
|
15709
|
+
}
|
|
15710
|
+
}
|
|
15711
|
+
}
|
|
15503
15712
|
const hidden = new Set(models.hide ?? []);
|
|
15504
15713
|
const shown = new Set(models.show ?? []);
|
|
15505
15714
|
for (const ref of hidden) {
|
|
@@ -15510,6 +15719,21 @@ function modelsFindings(input) {
|
|
|
15510
15719
|
return findings;
|
|
15511
15720
|
}
|
|
15512
15721
|
|
|
15722
|
+
// src/models/targets.ts
|
|
15723
|
+
init_modelPicker();
|
|
15724
|
+
init_providerCatalogue();
|
|
15725
|
+
init_providersStore();
|
|
15726
|
+
init_realPorts();
|
|
15727
|
+
function providerModels(paths) {
|
|
15728
|
+
return listProviders(paths).flatMap((entry) => {
|
|
15729
|
+
const catalogue = parseCatalogueCache(realFsPort.readFileUtf8(catalogueCachePath(paths, entry.name)));
|
|
15730
|
+
return providerModelRows(entry.provider, catalogue?.models).map((row) => ({ provider: entry.name, model: row.model }));
|
|
15731
|
+
});
|
|
15732
|
+
}
|
|
15733
|
+
function targetRefs(paths) {
|
|
15734
|
+
return providerModels(paths).map((entry) => `${entry.provider}/${entry.model}`);
|
|
15735
|
+
}
|
|
15736
|
+
|
|
15513
15737
|
// src/doctorReport.ts
|
|
15514
15738
|
init_configProfilesStore();
|
|
15515
15739
|
|
|
@@ -15735,7 +15959,7 @@ function tcpPortEraRecord(raw) {
|
|
|
15735
15959
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
15736
15960
|
}
|
|
15737
15961
|
function pushPathResolution(push, resolution) {
|
|
15738
|
-
const ownDir =
|
|
15962
|
+
const ownDir = import_node_path31.default.dirname(resolution.ownExecutablePath);
|
|
15739
15963
|
switch (resolution.agentShim.status) {
|
|
15740
15964
|
case "ok":
|
|
15741
15965
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -15839,14 +16063,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
|
|
|
15839
16063
|
}
|
|
15840
16064
|
function pushLegacyName(push, params) {
|
|
15841
16065
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
15842
|
-
if (legacyVariables.length === 0 &&
|
|
16066
|
+
if (legacyVariables.length === 0 && import_node_path31.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
15843
16067
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
15844
16068
|
return;
|
|
15845
16069
|
}
|
|
15846
16070
|
for (const name of legacyVariables) {
|
|
15847
16071
|
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);
|
|
15848
16072
|
}
|
|
15849
|
-
if (
|
|
16073
|
+
if (import_node_path31.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
15850
16074
|
push(
|
|
15851
16075
|
"legacy-name",
|
|
15852
16076
|
"warn",
|
|
@@ -16063,7 +16287,7 @@ function runDoctor(params) {
|
|
|
16063
16287
|
if (models === void 0) {
|
|
16064
16288
|
push("models", "pass", "No models block configured.");
|
|
16065
16289
|
} else {
|
|
16066
|
-
for (const finding of modelsFindings({ models, providers: params.providers.map((entry) => entry.name), identities: params.identities.map((entry) => entry.name) })) {
|
|
16290
|
+
for (const finding of modelsFindings({ models, providers: params.providers.map((entry) => entry.name), identities: params.identities.map((entry) => entry.name), ...params.modelTargets === void 0 ? {} : { targets: params.modelTargets } })) {
|
|
16067
16291
|
push("models", finding.severity, finding.message);
|
|
16068
16292
|
}
|
|
16069
16293
|
push("models", "pass", "The models block is consistent.");
|
|
@@ -16245,18 +16469,18 @@ function collectDoctorReport(params) {
|
|
|
16245
16469
|
const { paths } = params;
|
|
16246
16470
|
const identityNames = import_node_fs10.default.existsSync(paths.identitiesDir) ? import_node_fs10.default.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
|
|
16247
16471
|
const identities = identityNames.map((name) => {
|
|
16248
|
-
const farmRoot =
|
|
16249
|
-
const identityPath =
|
|
16472
|
+
const farmRoot = import_node_path31.default.join(paths.identitiesDir, name);
|
|
16473
|
+
const identityPath = import_node_path31.default.join(farmRoot, "identity.json");
|
|
16250
16474
|
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs10.default.existsSync(credentialsFilePath(farmRoot)) };
|
|
16251
16475
|
});
|
|
16252
16476
|
const profileNames = import_node_fs10.default.existsSync(paths.configProfilesDir) ? import_node_fs10.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
16253
16477
|
const configProfiles = profileNames.map((name) => {
|
|
16254
|
-
const profilePath =
|
|
16478
|
+
const profilePath = import_node_path31.default.join(paths.configProfilesDir, `${name}.json`);
|
|
16255
16479
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
16256
16480
|
});
|
|
16257
16481
|
const providerNames = import_node_fs10.default.existsSync(paths.providersDir) ? import_node_fs10.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
16258
16482
|
const providers = providerNames.map((name) => {
|
|
16259
|
-
const providerPath =
|
|
16483
|
+
const providerPath = import_node_path31.default.join(paths.providersDir, `${name}.json`);
|
|
16260
16484
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
16261
16485
|
});
|
|
16262
16486
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -16268,12 +16492,12 @@ function collectDoctorReport(params) {
|
|
|
16268
16492
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
16269
16493
|
}
|
|
16270
16494
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
16271
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
16495
|
+
const pathDirs = (params.env.PATH ?? "").split(import_node_path31.default.delimiter).filter((dir) => dir !== "");
|
|
16272
16496
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
16273
16497
|
findPathShadow({
|
|
16274
16498
|
pathDirs,
|
|
16275
|
-
targetDir:
|
|
16276
|
-
targetFilename:
|
|
16499
|
+
targetDir: import_node_path31.default.dirname(shimState.targetPath),
|
|
16500
|
+
targetFilename: import_node_path31.default.basename(shimState.targetPath),
|
|
16277
16501
|
findExecutableInDir
|
|
16278
16502
|
}),
|
|
16279
16503
|
shimState.targetPath,
|
|
@@ -16297,6 +16521,7 @@ function collectDoctorReport(params) {
|
|
|
16297
16521
|
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
16298
16522
|
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
16299
16523
|
models: parsedModelsOf(paths),
|
|
16524
|
+
modelTargets: targetRefs(paths),
|
|
16300
16525
|
categoriesLocal: { path: paths.categoriesLocalFile, raw: realFsPort.readFileUtf8(paths.categoriesLocalFile) },
|
|
16301
16526
|
activeIdentity: { path: paths.activeIdentityFile, raw: realFsPort.readFileUtf8(paths.activeIdentityFile) },
|
|
16302
16527
|
binaryDiscovery,
|
|
@@ -16307,7 +16532,7 @@ function collectDoctorReport(params) {
|
|
|
16307
16532
|
agentShim: refinePathShadow(
|
|
16308
16533
|
findPathShadow({
|
|
16309
16534
|
pathDirs,
|
|
16310
|
-
targetDir:
|
|
16535
|
+
targetDir: import_node_path31.default.dirname(ownExecutablePath),
|
|
16311
16536
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
16312
16537
|
findExecutableInDir
|
|
16313
16538
|
}),
|
|
@@ -16348,90 +16573,90 @@ function collectDoctorReport(params) {
|
|
|
16348
16573
|
// src/frontdoor/controlSchemas.ts
|
|
16349
16574
|
init_schema2();
|
|
16350
16575
|
init_state();
|
|
16351
|
-
var UsageListOutputSchema =
|
|
16352
|
-
var UsageWindowsInputSchema =
|
|
16353
|
-
identity:
|
|
16354
|
-
provider:
|
|
16576
|
+
var UsageListOutputSchema = import_zod25.z.strictObject({ snapshots: import_zod25.z.readonly(import_zod25.z.array(UsageSnapshotSchema)) });
|
|
16577
|
+
var UsageWindowsInputSchema = import_zod25.z.strictObject({
|
|
16578
|
+
identity: import_zod25.z.string().min(1),
|
|
16579
|
+
provider: import_zod25.z.string().min(1).optional()
|
|
16355
16580
|
});
|
|
16356
|
-
var EffectiveWindowSchema =
|
|
16581
|
+
var EffectiveWindowSchema = import_zod25.z.strictObject({
|
|
16357
16582
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
16358
|
-
reset:
|
|
16583
|
+
reset: import_zod25.z.boolean(),
|
|
16359
16584
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
16360
|
-
utilization:
|
|
16585
|
+
utilization: import_zod25.z.number().optional(),
|
|
16361
16586
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
16362
|
-
resetsAtMs:
|
|
16587
|
+
resetsAtMs: import_zod25.z.number().optional(),
|
|
16363
16588
|
/** The window's own status, for a window that has not reset yet. */
|
|
16364
|
-
status:
|
|
16589
|
+
status: import_zod25.z.string().optional()
|
|
16365
16590
|
});
|
|
16366
|
-
var UsageWindowsOutputSchema =
|
|
16367
|
-
identity:
|
|
16368
|
-
provider:
|
|
16591
|
+
var UsageWindowsOutputSchema = import_zod25.z.strictObject({
|
|
16592
|
+
identity: import_zod25.z.string(),
|
|
16593
|
+
provider: import_zod25.z.string(),
|
|
16369
16594
|
/** When the rate-limit state the windows come from was observed. */
|
|
16370
|
-
observedAt:
|
|
16595
|
+
observedAt: import_zod25.z.iso.datetime().optional(),
|
|
16371
16596
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
16372
16597
|
sevenDay: EffectiveWindowSchema.optional()
|
|
16373
16598
|
});
|
|
16374
|
-
var UsageLiveOutputSchema =
|
|
16599
|
+
var UsageLiveOutputSchema = import_zod25.z.strictObject({
|
|
16375
16600
|
/** 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. */
|
|
16376
16601
|
latest: RcLiveRateLimitSchema.optional(),
|
|
16377
16602
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
16378
|
-
sessions:
|
|
16603
|
+
sessions: import_zod25.z.readonly(import_zod25.z.array(RcLiveRateLimitSchema))
|
|
16379
16604
|
});
|
|
16380
|
-
var FrontDoorSessionStatusSchema =
|
|
16381
|
-
pid:
|
|
16382
|
-
startedAt:
|
|
16383
|
-
alive:
|
|
16605
|
+
var FrontDoorSessionStatusSchema = import_zod25.z.strictObject({
|
|
16606
|
+
pid: import_zod25.z.int().positive(),
|
|
16607
|
+
startedAt: import_zod25.z.number(),
|
|
16608
|
+
alive: import_zod25.z.boolean()
|
|
16384
16609
|
});
|
|
16385
|
-
var HeadroomSocketTargetSchema =
|
|
16386
|
-
var FrontDoorStatusOutputSchema =
|
|
16610
|
+
var HeadroomSocketTargetSchema = import_zod25.z.union([import_zod25.z.strictObject({ socketPath: import_zod25.z.string() }), import_zod25.z.strictObject({ refused: import_zod25.z.string() })]);
|
|
16611
|
+
var FrontDoorStatusOutputSchema = import_zod25.z.strictObject({
|
|
16387
16612
|
state: FrontDoorStateSchema,
|
|
16388
|
-
supervisorAlive:
|
|
16389
|
-
sessions:
|
|
16613
|
+
supervisorAlive: import_zod25.z.boolean(),
|
|
16614
|
+
sessions: import_zod25.z.readonly(import_zod25.z.array(FrontDoorSessionStatusSchema)),
|
|
16390
16615
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
16391
|
-
logPath:
|
|
16392
|
-
logExists:
|
|
16616
|
+
logPath: import_zod25.z.string(),
|
|
16617
|
+
logExists: import_zod25.z.boolean()
|
|
16393
16618
|
});
|
|
16394
|
-
var FrontDoorSessionsOutputSchema =
|
|
16395
|
-
var CheckRunInputSchema =
|
|
16396
|
-
path:
|
|
16397
|
-
identity:
|
|
16398
|
-
}).refine((input) =>
|
|
16399
|
-
var PoolPickInputSchema =
|
|
16400
|
-
pool:
|
|
16401
|
-
path:
|
|
16402
|
-
}).refine((input) =>
|
|
16403
|
-
var DoctorFindingSchema =
|
|
16404
|
-
section:
|
|
16405
|
-
subject:
|
|
16406
|
-
severity:
|
|
16407
|
-
message:
|
|
16619
|
+
var FrontDoorSessionsOutputSchema = import_zod25.z.strictObject({ sessions: import_zod25.z.readonly(import_zod25.z.array(FrontDoorSessionStatusSchema)) });
|
|
16620
|
+
var CheckRunInputSchema = import_zod25.z.strictObject({
|
|
16621
|
+
path: import_zod25.z.string().min(1),
|
|
16622
|
+
identity: import_zod25.z.string().min(1).optional()
|
|
16623
|
+
}).refine((input) => import_node_path32.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
16624
|
+
var PoolPickInputSchema = import_zod25.z.strictObject({
|
|
16625
|
+
pool: import_zod25.z.string().min(1),
|
|
16626
|
+
path: import_zod25.z.string().min(1)
|
|
16627
|
+
}).refine((input) => import_node_path32.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
16628
|
+
var DoctorFindingSchema = import_zod25.z.strictObject({
|
|
16629
|
+
section: import_zod25.z.enum(DOCTOR_SECTIONS),
|
|
16630
|
+
subject: import_zod25.z.string().optional(),
|
|
16631
|
+
severity: import_zod25.z.enum(DOCTOR_SEVERITIES),
|
|
16632
|
+
message: import_zod25.z.string()
|
|
16408
16633
|
});
|
|
16409
|
-
var DoctorRunOutputSchema =
|
|
16634
|
+
var DoctorRunOutputSchema = import_zod25.z.strictObject({
|
|
16410
16635
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
16411
|
-
ok:
|
|
16412
|
-
findings:
|
|
16636
|
+
ok: import_zod25.z.boolean(),
|
|
16637
|
+
findings: import_zod25.z.readonly(import_zod25.z.array(DoctorFindingSchema))
|
|
16413
16638
|
});
|
|
16414
|
-
var FrontDoorRestartOutputSchema =
|
|
16415
|
-
action:
|
|
16416
|
-
previousPid:
|
|
16639
|
+
var FrontDoorRestartOutputSchema = import_zod25.z.strictObject({
|
|
16640
|
+
action: import_zod25.z.literal("restarting"),
|
|
16641
|
+
previousPid: import_zod25.z.int().positive()
|
|
16417
16642
|
});
|
|
16418
|
-
var UpdateCheckOutputSchema =
|
|
16419
|
-
current:
|
|
16420
|
-
latest:
|
|
16421
|
-
action:
|
|
16643
|
+
var UpdateCheckOutputSchema = import_zod25.z.strictObject({
|
|
16644
|
+
current: import_zod25.z.string(),
|
|
16645
|
+
latest: import_zod25.z.string(),
|
|
16646
|
+
action: import_zod25.z.enum(["current", "available", "updated"])
|
|
16422
16647
|
});
|
|
16423
|
-
var CodexSignInSchema =
|
|
16424
|
-
|
|
16425
|
-
|
|
16426
|
-
|
|
16648
|
+
var CodexSignInSchema = import_zod25.z.discriminatedUnion("state", [
|
|
16649
|
+
import_zod25.z.strictObject({ state: import_zod25.z.literal("none") }),
|
|
16650
|
+
import_zod25.z.strictObject({ state: import_zod25.z.literal("signed-in"), email: import_zod25.z.string().optional(), planScope: import_zod25.z.boolean(), accessTokenExpiresAt: import_zod25.z.number() }),
|
|
16651
|
+
import_zod25.z.strictObject({ state: import_zod25.z.literal("unreadable"), message: import_zod25.z.string() })
|
|
16427
16652
|
]);
|
|
16428
|
-
var CodexStatusOutputSchema =
|
|
16653
|
+
var CodexStatusOutputSchema = import_zod25.z.strictObject({
|
|
16429
16654
|
signIn: CodexSignInSchema,
|
|
16430
|
-
codexProviders:
|
|
16655
|
+
codexProviders: import_zod25.z.readonly(import_zod25.z.array(import_zod25.z.string()))
|
|
16431
16656
|
});
|
|
16432
|
-
var CodexLogoutOutputSchema =
|
|
16433
|
-
hadGrant:
|
|
16434
|
-
revoked:
|
|
16657
|
+
var CodexLogoutOutputSchema = import_zod25.z.strictObject({
|
|
16658
|
+
hadGrant: import_zod25.z.boolean(),
|
|
16659
|
+
revoked: import_zod25.z.boolean()
|
|
16435
16660
|
});
|
|
16436
16661
|
|
|
16437
16662
|
// src/frontdoor/codexApi.ts
|
|
@@ -16588,144 +16813,144 @@ init_identity();
|
|
|
16588
16813
|
init_providersStore();
|
|
16589
16814
|
|
|
16590
16815
|
// src/frontdoor/configSchemas.ts
|
|
16591
|
-
var
|
|
16816
|
+
var import_zod26 = require("zod");
|
|
16592
16817
|
init_schema();
|
|
16593
|
-
var RemovalConfirmationSchema =
|
|
16594
|
-
var CredentialWriteSchema = (targets) =>
|
|
16595
|
-
sources:
|
|
16596
|
-
target:
|
|
16597
|
-
cache:
|
|
16818
|
+
var RemovalConfirmationSchema = import_zod26.z.boolean();
|
|
16819
|
+
var CredentialWriteSchema = (targets) => import_zod26.z.strictObject({
|
|
16820
|
+
sources: import_zod26.z.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
16821
|
+
target: import_zod26.z.enum(targets).optional(),
|
|
16822
|
+
cache: import_zod26.z.union([import_zod26.z.literal(false), CredentialCacheSchema]).optional()
|
|
16598
16823
|
});
|
|
16599
|
-
var CredentialSummarySchema2 =
|
|
16600
|
-
target:
|
|
16601
|
-
sources:
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
|
|
16608
|
-
|
|
16824
|
+
var CredentialSummarySchema2 = import_zod26.z.strictObject({
|
|
16825
|
+
target: import_zod26.z.enum(CREDENTIAL_TARGETS),
|
|
16826
|
+
sources: import_zod26.z.readonly(import_zod26.z.array(
|
|
16827
|
+
import_zod26.z.discriminatedUnion("kind", [
|
|
16828
|
+
import_zod26.z.strictObject({ kind: import_zod26.z.literal("env"), variable: import_zod26.z.string() }),
|
|
16829
|
+
import_zod26.z.strictObject({ kind: import_zod26.z.literal("file"), path: import_zod26.z.string() }),
|
|
16830
|
+
import_zod26.z.strictObject({ kind: import_zod26.z.literal("command"), program: import_zod26.z.string() }),
|
|
16831
|
+
import_zod26.z.strictObject({ kind: import_zod26.z.literal("op"), reference: import_zod26.z.string() }),
|
|
16832
|
+
import_zod26.z.strictObject({ kind: import_zod26.z.literal("keychain"), service: import_zod26.z.string(), account: import_zod26.z.string().optional() }),
|
|
16833
|
+
import_zod26.z.strictObject({ kind: import_zod26.z.literal("literal") })
|
|
16609
16834
|
])
|
|
16610
16835
|
)),
|
|
16611
16836
|
cache: CredentialCacheSchema.optional()
|
|
16612
16837
|
});
|
|
16613
|
-
var mutationOutput = (kind, action) =>
|
|
16614
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
16615
|
-
var IdentityValueSchema =
|
|
16616
|
-
name:
|
|
16617
|
-
defaultConfigProfile:
|
|
16618
|
-
allowAmbientCredential:
|
|
16838
|
+
var mutationOutput = (kind, action) => import_zod26.z.strictObject({ action: import_zod26.z.literal(action), kind: import_zod26.z.literal(kind), name: import_zod26.z.string() });
|
|
16839
|
+
var storedMutationOutput = (kind, action, value) => import_zod26.z.strictObject({ action: import_zod26.z.literal(action), kind: import_zod26.z.literal(kind), name: import_zod26.z.string(), value });
|
|
16840
|
+
var IdentityValueSchema = import_zod26.z.strictObject({
|
|
16841
|
+
name: import_zod26.z.string(),
|
|
16842
|
+
defaultConfigProfile: import_zod26.z.string().optional(),
|
|
16843
|
+
allowAmbientCredential: import_zod26.z.boolean(),
|
|
16619
16844
|
credential: CredentialSummarySchema2.optional(),
|
|
16620
|
-
anchors:
|
|
16845
|
+
anchors: import_zod26.z.array(AnchorSchema).optional()
|
|
16621
16846
|
});
|
|
16622
16847
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
16623
|
-
var ProviderValueSchema =
|
|
16624
|
-
name:
|
|
16625
|
-
kind:
|
|
16626
|
-
displayName:
|
|
16627
|
-
baseUrl:
|
|
16848
|
+
var ProviderValueSchema = import_zod26.z.strictObject({
|
|
16849
|
+
name: import_zod26.z.string(),
|
|
16850
|
+
kind: import_zod26.z.enum(PROVIDER_KINDS),
|
|
16851
|
+
displayName: import_zod26.z.string(),
|
|
16852
|
+
baseUrl: import_zod26.z.string().optional(),
|
|
16628
16853
|
codex: CodexProviderConfigSchema.optional(),
|
|
16629
16854
|
credential: CredentialSummarySchema2.optional(),
|
|
16630
|
-
env:
|
|
16855
|
+
env: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.string()).optional()
|
|
16631
16856
|
});
|
|
16632
|
-
var ConfigNameInputSchema =
|
|
16857
|
+
var ConfigNameInputSchema = import_zod26.z.strictObject({ name: import_zod26.z.string().min(1) });
|
|
16633
16858
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
16634
|
-
var ConfigIdentitySetInputSchema =
|
|
16635
|
-
name:
|
|
16636
|
-
defaultConfigProfile:
|
|
16637
|
-
allowAmbientCredential:
|
|
16638
|
-
credential:
|
|
16859
|
+
var ConfigIdentitySetInputSchema = import_zod26.z.strictObject({
|
|
16860
|
+
name: import_zod26.z.string().min(1),
|
|
16861
|
+
defaultConfigProfile: import_zod26.z.union([import_zod26.z.string().min(1), import_zod26.z.literal(false)]).optional(),
|
|
16862
|
+
allowAmbientCredential: import_zod26.z.boolean().optional(),
|
|
16863
|
+
credential: import_zod26.z.union([import_zod26.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
16639
16864
|
/** `false` removes the anchors; a list replaces them. */
|
|
16640
|
-
anchors:
|
|
16865
|
+
anchors: import_zod26.z.union([import_zod26.z.literal(false), import_zod26.z.array(AnchorSchema).min(1)]).optional()
|
|
16641
16866
|
});
|
|
16642
16867
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
16643
|
-
var ConfigIdentityRemoveInputSchema =
|
|
16868
|
+
var ConfigIdentityRemoveInputSchema = import_zod26.z.strictObject({ name: import_zod26.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
16644
16869
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
16645
16870
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
16646
|
-
var ConfigProfileAddInputSchema =
|
|
16647
|
-
name:
|
|
16648
|
-
extends:
|
|
16649
|
-
description:
|
|
16871
|
+
var ConfigProfileAddInputSchema = import_zod26.z.strictObject({
|
|
16872
|
+
name: import_zod26.z.string().min(1),
|
|
16873
|
+
extends: import_zod26.z.array(import_zod26.z.string().min(1)).optional(),
|
|
16874
|
+
description: import_zod26.z.string().optional()
|
|
16650
16875
|
});
|
|
16651
16876
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
16652
|
-
var ConfigProfileSetInputSchema =
|
|
16653
|
-
name:
|
|
16654
|
-
category:
|
|
16655
|
-
entry:
|
|
16656
|
-
extends:
|
|
16657
|
-
description:
|
|
16658
|
-
launch:
|
|
16659
|
-
skipPermissions:
|
|
16660
|
-
remoteControl:
|
|
16661
|
-
headroom:
|
|
16662
|
-
trackUsage:
|
|
16663
|
-
provider:
|
|
16664
|
-
claudeVersion:
|
|
16665
|
-
delay:
|
|
16666
|
-
pause:
|
|
16667
|
-
explain:
|
|
16668
|
-
routeByName:
|
|
16877
|
+
var ConfigProfileSetInputSchema = import_zod26.z.strictObject({
|
|
16878
|
+
name: import_zod26.z.string().min(1),
|
|
16879
|
+
category: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.boolean()).optional(),
|
|
16880
|
+
entry: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.boolean()).optional(),
|
|
16881
|
+
extends: import_zod26.z.union([import_zod26.z.array(import_zod26.z.string().min(1)), import_zod26.z.literal(false)]).optional(),
|
|
16882
|
+
description: import_zod26.z.union([import_zod26.z.string(), import_zod26.z.literal(false)]).optional(),
|
|
16883
|
+
launch: import_zod26.z.strictObject({
|
|
16884
|
+
skipPermissions: import_zod26.z.boolean().optional(),
|
|
16885
|
+
remoteControl: import_zod26.z.boolean().optional(),
|
|
16886
|
+
headroom: import_zod26.z.boolean().optional(),
|
|
16887
|
+
trackUsage: import_zod26.z.boolean().optional(),
|
|
16888
|
+
provider: import_zod26.z.union([import_zod26.z.string().min(1), import_zod26.z.literal(false)]).optional(),
|
|
16889
|
+
claudeVersion: import_zod26.z.union([import_zod26.z.string().min(1), import_zod26.z.literal(false)]).optional(),
|
|
16890
|
+
delay: import_zod26.z.union([import_zod26.z.string().regex(DURATION_RE), import_zod26.z.literal(false)]).optional(),
|
|
16891
|
+
pause: import_zod26.z.boolean().optional(),
|
|
16892
|
+
explain: import_zod26.z.boolean().optional(),
|
|
16893
|
+
routeByName: import_zod26.z.boolean().optional()
|
|
16669
16894
|
}).optional()
|
|
16670
16895
|
});
|
|
16671
16896
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
16672
|
-
var ConfigProfileRemoveInputSchema =
|
|
16897
|
+
var ConfigProfileRemoveInputSchema = import_zod26.z.strictObject({ name: import_zod26.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
16673
16898
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
16674
16899
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
16675
|
-
var PoolMembersInputSchema =
|
|
16676
|
-
var ConfigPoolAddInputSchema =
|
|
16677
|
-
name:
|
|
16900
|
+
var PoolMembersInputSchema = import_zod26.z.array(import_zod26.z.string().min(1)).min(1);
|
|
16901
|
+
var ConfigPoolAddInputSchema = import_zod26.z.strictObject({
|
|
16902
|
+
name: import_zod26.z.string().min(1),
|
|
16678
16903
|
identities: PoolMembersInputSchema,
|
|
16679
|
-
preference:
|
|
16680
|
-
resumeOnLimit:
|
|
16681
|
-
compactBeforeLimit:
|
|
16904
|
+
preference: import_zod26.z.enum(POOL_PREFERENCES).optional(),
|
|
16905
|
+
resumeOnLimit: import_zod26.z.boolean().optional(),
|
|
16906
|
+
compactBeforeLimit: import_zod26.z.boolean().optional(),
|
|
16682
16907
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
16683
16908
|
});
|
|
16684
16909
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
16685
|
-
var ConfigPoolSetInputSchema =
|
|
16686
|
-
name:
|
|
16910
|
+
var ConfigPoolSetInputSchema = import_zod26.z.strictObject({
|
|
16911
|
+
name: import_zod26.z.string().min(1),
|
|
16687
16912
|
identities: PoolMembersInputSchema.optional(),
|
|
16688
|
-
preference:
|
|
16689
|
-
resumeOnLimit:
|
|
16690
|
-
compactBeforeLimit:
|
|
16691
|
-
compactAtUtilisation:
|
|
16913
|
+
preference: import_zod26.z.union([import_zod26.z.enum(POOL_PREFERENCES), import_zod26.z.literal(false)]).optional(),
|
|
16914
|
+
resumeOnLimit: import_zod26.z.boolean().optional(),
|
|
16915
|
+
compactBeforeLimit: import_zod26.z.boolean().optional(),
|
|
16916
|
+
compactAtUtilisation: import_zod26.z.union([CompactAtUtilisationSchema, import_zod26.z.literal(false)]).optional()
|
|
16692
16917
|
});
|
|
16693
16918
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
16694
|
-
var ConfigPoolRemoveInputSchema =
|
|
16919
|
+
var ConfigPoolRemoveInputSchema = import_zod26.z.strictObject({ name: import_zod26.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
16695
16920
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
16696
16921
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
16697
|
-
var ConfigProviderAddInputSchema =
|
|
16698
|
-
name:
|
|
16699
|
-
kind:
|
|
16700
|
-
displayName:
|
|
16701
|
-
baseUrl:
|
|
16922
|
+
var ConfigProviderAddInputSchema = import_zod26.z.strictObject({
|
|
16923
|
+
name: import_zod26.z.string().min(1),
|
|
16924
|
+
kind: import_zod26.z.enum(PROVIDER_KINDS).optional(),
|
|
16925
|
+
displayName: import_zod26.z.string().min(1),
|
|
16926
|
+
baseUrl: import_zod26.z.string().min(1).optional(),
|
|
16702
16927
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
16703
16928
|
codex: CodexProviderConfigSchema.optional()
|
|
16704
16929
|
});
|
|
16705
16930
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
16706
|
-
var ConfigProviderSetInputSchema =
|
|
16707
|
-
name:
|
|
16708
|
-
displayName:
|
|
16709
|
-
baseUrl:
|
|
16931
|
+
var ConfigProviderSetInputSchema = import_zod26.z.strictObject({
|
|
16932
|
+
name: import_zod26.z.string().min(1),
|
|
16933
|
+
displayName: import_zod26.z.string().min(1).optional(),
|
|
16934
|
+
baseUrl: import_zod26.z.string().min(1).optional(),
|
|
16710
16935
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
16711
16936
|
codex: CodexProviderConfigSchema.optional()
|
|
16712
16937
|
});
|
|
16713
16938
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
16714
|
-
var ConfigProviderRemoveInputSchema =
|
|
16939
|
+
var ConfigProviderRemoveInputSchema = import_zod26.z.strictObject({ name: import_zod26.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
16715
16940
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
16716
|
-
var ConfigRuleAddInputSchema =
|
|
16717
|
-
path:
|
|
16718
|
-
configProfile:
|
|
16719
|
-
identity:
|
|
16941
|
+
var ConfigRuleAddInputSchema = import_zod26.z.strictObject({
|
|
16942
|
+
path: import_zod26.z.string().min(1),
|
|
16943
|
+
configProfile: import_zod26.z.string().min(1).optional(),
|
|
16944
|
+
identity: import_zod26.z.string().min(1).optional()
|
|
16720
16945
|
});
|
|
16721
16946
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
16722
|
-
var ConfigRuleSetInputSchema =
|
|
16723
|
-
path:
|
|
16724
|
-
configProfile:
|
|
16725
|
-
identity:
|
|
16947
|
+
var ConfigRuleSetInputSchema = import_zod26.z.strictObject({
|
|
16948
|
+
path: import_zod26.z.string().min(1),
|
|
16949
|
+
configProfile: import_zod26.z.union([import_zod26.z.string().min(1), import_zod26.z.literal(false)]).optional(),
|
|
16950
|
+
identity: import_zod26.z.union([import_zod26.z.string().min(1), import_zod26.z.literal(false)]).optional()
|
|
16726
16951
|
});
|
|
16727
16952
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
16728
|
-
var ConfigRuleRemoveInputSchema =
|
|
16953
|
+
var ConfigRuleRemoveInputSchema = import_zod26.z.strictObject({ path: import_zod26.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
16729
16954
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
16730
16955
|
|
|
16731
16956
|
// src/frontdoor/configApi.ts
|
|
@@ -17037,43 +17262,43 @@ var import_openapi4 = require("@orpc/openapi");
|
|
|
17037
17262
|
var import_server3 = require("@orpc/server");
|
|
17038
17263
|
|
|
17039
17264
|
// src/frontdoor/eventSchemas.ts
|
|
17040
|
-
var
|
|
17265
|
+
var import_zod27 = require("zod");
|
|
17041
17266
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
17042
17267
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
17043
17268
|
var USAGE_EVENT_SOURCE = "usage";
|
|
17044
17269
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
17045
17270
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
17046
|
-
var DoorEventSchema =
|
|
17047
|
-
source:
|
|
17271
|
+
var DoorEventSchema = import_zod27.z.strictObject({
|
|
17272
|
+
source: import_zod27.z.string().min(1),
|
|
17048
17273
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
17049
|
-
sequence:
|
|
17050
|
-
payload:
|
|
17274
|
+
sequence: import_zod27.z.number().int().positive(),
|
|
17275
|
+
payload: import_zod27.z.unknown()
|
|
17051
17276
|
});
|
|
17052
|
-
var DoorEventSourceQuerySchema =
|
|
17053
|
-
sources:
|
|
17277
|
+
var DoorEventSourceQuerySchema = import_zod27.z.strictObject({
|
|
17278
|
+
sources: import_zod27.z.array(import_zod27.z.string().min(1)).min(1).optional()
|
|
17054
17279
|
});
|
|
17055
|
-
var LaunchLifecycleEventSchema =
|
|
17056
|
-
kind:
|
|
17057
|
-
pid:
|
|
17058
|
-
startedAt:
|
|
17059
|
-
observedAt:
|
|
17280
|
+
var LaunchLifecycleEventSchema = import_zod27.z.strictObject({
|
|
17281
|
+
kind: import_zod27.z.enum(["registered", "pruned", "ended"]),
|
|
17282
|
+
pid: import_zod27.z.number().int().positive(),
|
|
17283
|
+
startedAt: import_zod27.z.number(),
|
|
17284
|
+
observedAt: import_zod27.z.number()
|
|
17060
17285
|
});
|
|
17061
|
-
var DoorHealthEventSchema =
|
|
17062
|
-
|
|
17063
|
-
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17286
|
+
var DoorHealthEventSchema = import_zod27.z.discriminatedUnion("kind", [
|
|
17287
|
+
import_zod27.z.strictObject({ kind: import_zod27.z.literal("generation"), pid: import_zod27.z.number().int().positive(), providerPort: import_zod27.z.number().int().positive(), connectPort: import_zod27.z.number().int().positive(), directPort: import_zod27.z.number().int().positive(), observedAt: import_zod27.z.number() }),
|
|
17288
|
+
import_zod27.z.strictObject({ kind: import_zod27.z.literal("listenerFailed"), pid: import_zod27.z.number().int().positive(), listener: import_zod27.z.enum(["provider", "connect", "direct"]), message: import_zod27.z.string(), observedAt: import_zod27.z.number() }),
|
|
17289
|
+
import_zod27.z.strictObject({ kind: import_zod27.z.literal("binaryTurnover"), pid: import_zod27.z.number().int().positive(), observedAt: import_zod27.z.number() }),
|
|
17290
|
+
import_zod27.z.strictObject({ kind: import_zod27.z.literal("idleShutdown"), pid: import_zod27.z.number().int().positive(), observedAt: import_zod27.z.number() }),
|
|
17291
|
+
import_zod27.z.strictObject({ kind: import_zod27.z.literal("superseded"), pid: import_zod27.z.number().int().positive(), ownerPid: import_zod27.z.number().int().positive(), observedAt: import_zod27.z.number() }),
|
|
17292
|
+
import_zod27.z.strictObject({ kind: import_zod27.z.literal("drained"), pid: import_zod27.z.number().int().positive(), observedAt: import_zod27.z.number() })
|
|
17068
17293
|
]);
|
|
17069
|
-
var QuotaExpiringEventSchema =
|
|
17070
|
-
identity:
|
|
17071
|
-
provider:
|
|
17072
|
-
window:
|
|
17294
|
+
var QuotaExpiringEventSchema = import_zod27.z.strictObject({
|
|
17295
|
+
identity: import_zod27.z.string().min(1),
|
|
17296
|
+
provider: import_zod27.z.string().min(1),
|
|
17297
|
+
window: import_zod27.z.enum(["fiveHour", "sevenDay"]),
|
|
17073
17298
|
/** 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. */
|
|
17074
|
-
utilization:
|
|
17075
|
-
resetsAt:
|
|
17076
|
-
observedAt:
|
|
17299
|
+
utilization: import_zod27.z.number().min(0).max(1),
|
|
17300
|
+
resetsAt: import_zod27.z.iso.datetime(),
|
|
17301
|
+
observedAt: import_zod27.z.number()
|
|
17077
17302
|
});
|
|
17078
17303
|
|
|
17079
17304
|
// src/frontdoor/eventsApi.ts
|
|
@@ -17156,57 +17381,57 @@ var import_openapi6 = require("@orpc/openapi");
|
|
|
17156
17381
|
init_cliError();
|
|
17157
17382
|
|
|
17158
17383
|
// src/frontdoor/launchSchemas.ts
|
|
17159
|
-
var
|
|
17160
|
-
var
|
|
17384
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
17385
|
+
var import_zod28 = require("zod");
|
|
17161
17386
|
init_claudeVersion();
|
|
17162
17387
|
init_identity();
|
|
17163
|
-
var LaunchResolveInputSchema =
|
|
17164
|
-
path:
|
|
17388
|
+
var LaunchResolveInputSchema = import_zod28.z.strictObject({
|
|
17389
|
+
path: import_zod28.z.string().min(1),
|
|
17165
17390
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
17166
|
-
argv:
|
|
17391
|
+
argv: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())).optional(),
|
|
17167
17392
|
/** 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. */
|
|
17168
|
-
env:
|
|
17169
|
-
}).refine((input) =>
|
|
17170
|
-
var LaunchPoolDecisionSchema =
|
|
17171
|
-
name:
|
|
17172
|
-
reasons:
|
|
17173
|
-
movedOff:
|
|
17393
|
+
env: import_zod28.z.record(import_zod28.z.string(), import_zod28.z.string()).optional()
|
|
17394
|
+
}).refine((input) => import_node_path33.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
17395
|
+
var LaunchPoolDecisionSchema = import_zod28.z.strictObject({
|
|
17396
|
+
name: import_zod28.z.string(),
|
|
17397
|
+
reasons: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())),
|
|
17398
|
+
movedOff: import_zod28.z.strictObject({ identity: import_zod28.z.string(), reason: import_zod28.z.string() }).optional()
|
|
17174
17399
|
});
|
|
17175
|
-
var LaunchDecisionSchema =
|
|
17176
|
-
identity:
|
|
17177
|
-
identitySource:
|
|
17400
|
+
var LaunchDecisionSchema = import_zod28.z.strictObject({
|
|
17401
|
+
identity: import_zod28.z.string().optional(),
|
|
17402
|
+
identitySource: import_zod28.z.enum(IDENTITY_DECISION_SOURCES),
|
|
17178
17403
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
17179
|
-
configDirEscapeHatch:
|
|
17180
|
-
configDir:
|
|
17181
|
-
configProfile:
|
|
17182
|
-
configProfileSource:
|
|
17183
|
-
provider:
|
|
17404
|
+
configDirEscapeHatch: import_zod28.z.boolean(),
|
|
17405
|
+
configDir: import_zod28.z.string().optional(),
|
|
17406
|
+
configProfile: import_zod28.z.string().optional(),
|
|
17407
|
+
configProfileSource: import_zod28.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
17408
|
+
provider: import_zod28.z.string().optional()
|
|
17184
17409
|
});
|
|
17185
|
-
var LaunchFlagsSchema =
|
|
17186
|
-
skipPermissions:
|
|
17187
|
-
remoteControl:
|
|
17188
|
-
headroom:
|
|
17189
|
-
trackUsage:
|
|
17190
|
-
pause:
|
|
17191
|
-
explain:
|
|
17192
|
-
routeByName:
|
|
17410
|
+
var LaunchFlagsSchema = import_zod28.z.strictObject({
|
|
17411
|
+
skipPermissions: import_zod28.z.boolean(),
|
|
17412
|
+
remoteControl: import_zod28.z.boolean(),
|
|
17413
|
+
headroom: import_zod28.z.boolean(),
|
|
17414
|
+
trackUsage: import_zod28.z.boolean(),
|
|
17415
|
+
pause: import_zod28.z.boolean(),
|
|
17416
|
+
explain: import_zod28.z.boolean(),
|
|
17417
|
+
routeByName: import_zod28.z.boolean(),
|
|
17193
17418
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
17194
|
-
delayMs:
|
|
17419
|
+
delayMs: import_zod28.z.number()
|
|
17195
17420
|
});
|
|
17196
|
-
var LaunchResolveOutputSchema =
|
|
17421
|
+
var LaunchResolveOutputSchema = import_zod28.z.strictObject({
|
|
17197
17422
|
decision: LaunchDecisionSchema,
|
|
17198
17423
|
flags: LaunchFlagsSchema,
|
|
17199
|
-
claudeVersion:
|
|
17424
|
+
claudeVersion: import_zod28.z.strictObject({ version: import_zod28.z.string(), source: import_zod28.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
17200
17425
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
17201
|
-
bin:
|
|
17426
|
+
bin: import_zod28.z.string(),
|
|
17202
17427
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
17203
|
-
args:
|
|
17428
|
+
args: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())),
|
|
17204
17429
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
17205
|
-
credential:
|
|
17206
|
-
routing:
|
|
17430
|
+
credential: import_zod28.z.strictObject({ subject: import_zod28.z.enum(["provider", "identity"]), name: import_zod28.z.string(), summary: CredentialSummarySchema }).optional(),
|
|
17431
|
+
routing: import_zod28.z.strictObject({ frontDoor: import_zod28.z.boolean(), headroom: import_zod28.z.boolean(), routeByName: import_zod28.z.boolean() }),
|
|
17207
17432
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
17208
|
-
environment:
|
|
17209
|
-
warnings:
|
|
17433
|
+
environment: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())),
|
|
17434
|
+
warnings: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string()))
|
|
17210
17435
|
});
|
|
17211
17436
|
|
|
17212
17437
|
// src/frontdoor/launchApi.ts
|
|
@@ -17242,22 +17467,22 @@ function createLaunchApiRouter(deps) {
|
|
|
17242
17467
|
// src/frontdoor/agentTreesApi.ts
|
|
17243
17468
|
var import_client6 = require("@orpc/client");
|
|
17244
17469
|
var import_openapi7 = require("@orpc/openapi");
|
|
17245
|
-
var
|
|
17470
|
+
var import_zod29 = require("zod");
|
|
17246
17471
|
init_cliError();
|
|
17247
|
-
var AgentTreesListInputSchema =
|
|
17472
|
+
var AgentTreesListInputSchema = import_zod29.z.strictObject({
|
|
17248
17473
|
/** Only this identity's sessions. */
|
|
17249
|
-
identity:
|
|
17474
|
+
identity: import_zod29.z.string().optional(),
|
|
17250
17475
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
17251
|
-
all:
|
|
17476
|
+
all: import_zod29.z.boolean().optional()
|
|
17252
17477
|
});
|
|
17253
|
-
var AgentTreesListOutputSchema =
|
|
17254
|
-
var AgentTreesShowInputSchema =
|
|
17478
|
+
var AgentTreesListOutputSchema = import_zod29.z.array(SessionSummarySchema);
|
|
17479
|
+
var AgentTreesShowInputSchema = import_zod29.z.strictObject({
|
|
17255
17480
|
/** A session id, or an unambiguous prefix of one. */
|
|
17256
|
-
session:
|
|
17481
|
+
session: import_zod29.z.string().min(1),
|
|
17257
17482
|
/** Look only in this identity. */
|
|
17258
|
-
identity:
|
|
17483
|
+
identity: import_zod29.z.string().optional()
|
|
17259
17484
|
});
|
|
17260
|
-
var AgentTreesShowOutputSchema =
|
|
17485
|
+
var AgentTreesShowOutputSchema = import_zod29.z.strictObject({ identities: import_zod29.z.array(import_zod29.z.string()), ...MergedAgentTreeSchema.shape });
|
|
17261
17486
|
function asBadRequest(error) {
|
|
17262
17487
|
if (error instanceof CliError) {
|
|
17263
17488
|
throw new import_client6.ORPCError("BAD_REQUEST", { message: error.message });
|
|
@@ -17643,11 +17868,11 @@ function createDoorHealthPublisher(hub, now, pid) {
|
|
|
17643
17868
|
|
|
17644
17869
|
// src/frontdoor/quotaExpiringEvents.ts
|
|
17645
17870
|
init_schema2();
|
|
17646
|
-
var
|
|
17871
|
+
var MS_PER_HOUR5 = 36e5;
|
|
17647
17872
|
var MS_PER_DAY2 = 864e5;
|
|
17648
17873
|
var FIVE_HOUR_WINDOW_HOURS = 5;
|
|
17649
17874
|
var SEVEN_DAY_WINDOW_DAYS = 7;
|
|
17650
|
-
var FIVE_HOUR_WINDOW_MS2 = FIVE_HOUR_WINDOW_HOURS *
|
|
17875
|
+
var FIVE_HOUR_WINDOW_MS2 = FIVE_HOUR_WINDOW_HOURS * MS_PER_HOUR5;
|
|
17651
17876
|
var SEVEN_DAY_WINDOW_MS2 = SEVEN_DAY_WINDOW_DAYS * MS_PER_DAY2;
|
|
17652
17877
|
var FINAL_SPAN_DENOMINATOR = 30;
|
|
17653
17878
|
var QUOTA_EXPIRING_WINDOW_FRACTION = 1 / FINAL_SPAN_DENOMINATOR;
|
|
@@ -18340,7 +18565,7 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
18340
18565
|
var RC_SELF_HOST_OAUTH_HOST = "platform.claude.com";
|
|
18341
18566
|
var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:claude_code", "user:mcp_servers", "user:file_upload"];
|
|
18342
18567
|
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
18343
|
-
var
|
|
18568
|
+
var MS_PER_SECOND6 = 1e3;
|
|
18344
18569
|
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
18345
18570
|
function isRecord12(value) {
|
|
18346
18571
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -18396,7 +18621,7 @@ function createRcSelfHostLocal(deps) {
|
|
|
18396
18621
|
}
|
|
18397
18622
|
if (method === "POST" && pathname.startsWith("/api/eval/")) {
|
|
18398
18623
|
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
18399
|
-
answerServerJson(response, HTTP_STATUS.ok, { features: growthBookFeatures(), dateUpdated: Math.floor(deps.now() /
|
|
18624
|
+
answerServerJson(response, HTTP_STATUS.ok, { features: growthBookFeatures(), dateUpdated: Math.floor(deps.now() / MS_PER_SECOND6) });
|
|
18400
18625
|
return true;
|
|
18401
18626
|
}
|
|
18402
18627
|
if (method === "GET" && pathname === "/api/oauth/profile") {
|
|
@@ -18695,7 +18920,7 @@ var RC_COMPAT_SESSIONS_PATH = "/v1/sessions";
|
|
|
18695
18920
|
var RC_SESSION_ID_PREFIX2 = "cse_";
|
|
18696
18921
|
var RC_SELF_HOST_API_BASE_URL = "https://api.anthropic.com";
|
|
18697
18922
|
var HTTP_CONFLICT = 409;
|
|
18698
|
-
var
|
|
18923
|
+
var MS_PER_SECOND7 = 1e3;
|
|
18699
18924
|
var HTTP_SERVICE_UNAVAILABLE2 = 503;
|
|
18700
18925
|
var RC_SELF_HOST_WORKER_JWT_TTL_SECONDS = 46800;
|
|
18701
18926
|
var RC_SELF_HOST_KEEPALIVE_MS = 15e3;
|
|
@@ -18795,7 +19020,7 @@ function parseJsonObject5(body) {
|
|
|
18795
19020
|
function mintWorkerJwt(randomToken, issuedAt) {
|
|
18796
19021
|
const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
|
|
18797
19022
|
const header = encode({ alg: "HS256", typ: "JWT" });
|
|
18798
|
-
const payload = encode({ exp: Math.floor((issuedAt + RC_SELF_HOST_WORKER_JWT_TTL_SECONDS *
|
|
19023
|
+
const payload = encode({ exp: Math.floor((issuedAt + RC_SELF_HOST_WORKER_JWT_TTL_SECONDS * MS_PER_SECOND7) / MS_PER_SECOND7), iat: Math.floor(issuedAt / MS_PER_SECOND7) });
|
|
18799
19024
|
return `${header}.${payload}.${Buffer.from(randomToken(), "utf8").toString("base64url")}`;
|
|
18800
19025
|
}
|
|
18801
19026
|
function createRcSelfHostSurface(deps) {
|
|
@@ -19338,7 +19563,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
19338
19563
|
}
|
|
19339
19564
|
|
|
19340
19565
|
// src/frontdoor/rcSelfHostMint.ts
|
|
19341
|
-
var
|
|
19566
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
19342
19567
|
init_account();
|
|
19343
19568
|
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
19344
19569
|
var CLAUDE_JSON2 = ".claude.json";
|
|
@@ -19363,7 +19588,7 @@ function readJsonObject(fs13, file) {
|
|
|
19363
19588
|
return isRecord14(parsed) ? parsed : void 0;
|
|
19364
19589
|
}
|
|
19365
19590
|
function readRcSelfHostRecord(fs13, frontdoorDir) {
|
|
19366
|
-
const parsed = readJsonObject(fs13,
|
|
19591
|
+
const parsed = readJsonObject(fs13, import_node_path34.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
19367
19592
|
if (parsed === void 0) {
|
|
19368
19593
|
return void 0;
|
|
19369
19594
|
}
|
|
@@ -19377,11 +19602,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
19377
19602
|
if (!isIdentityName(deps.identity)) {
|
|
19378
19603
|
throw new Error(`"${deps.identity}" is not a valid identity name.`);
|
|
19379
19604
|
}
|
|
19380
|
-
const identityDir =
|
|
19381
|
-
const credentialsFile =
|
|
19382
|
-
const claudeJsonFile =
|
|
19383
|
-
const recordDir =
|
|
19384
|
-
const recordFile =
|
|
19605
|
+
const identityDir = import_node_path34.default.join(deps.identitiesDir, deps.identity);
|
|
19606
|
+
const credentialsFile = import_node_path34.default.join(identityDir, CREDENTIALS_FILE2);
|
|
19607
|
+
const claudeJsonFile = import_node_path34.default.join(identityDir, CLAUDE_JSON2);
|
|
19608
|
+
const recordDir = import_node_path34.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
19609
|
+
const recordFile = import_node_path34.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
19385
19610
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
19386
19611
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
19387
19612
|
const existingOauth = isRecord14(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -19397,7 +19622,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
19397
19622
|
const organizationUuid = deps.newUuid();
|
|
19398
19623
|
const accountUuid = deps.newUuid();
|
|
19399
19624
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
19400
|
-
deps.fs.mkdirPrivate(
|
|
19625
|
+
deps.fs.mkdirPrivate(import_node_path34.default.dirname(credentialsFile));
|
|
19401
19626
|
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)}
|
|
19402
19627
|
`);
|
|
19403
19628
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -19439,8 +19664,8 @@ init_plan2();
|
|
|
19439
19664
|
init_poolPick();
|
|
19440
19665
|
|
|
19441
19666
|
// src/agents/read.ts
|
|
19442
|
-
var
|
|
19443
|
-
var
|
|
19667
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
19668
|
+
var import_zod30 = require("zod");
|
|
19444
19669
|
var PROJECTS_DIR = "projects";
|
|
19445
19670
|
var TASKS_DIR = "tasks";
|
|
19446
19671
|
var SUBAGENTS_DIR = "subagents";
|
|
@@ -19465,15 +19690,15 @@ function parseEntry2(project, entry) {
|
|
|
19465
19690
|
}
|
|
19466
19691
|
function listSessions2(fs13, configDir) {
|
|
19467
19692
|
const found = [];
|
|
19468
|
-
for (const project of fs13.readdir(
|
|
19469
|
-
const projectDir =
|
|
19693
|
+
for (const project of fs13.readdir(import_node_path35.default.join(configDir, PROJECTS_DIR))) {
|
|
19694
|
+
const projectDir = import_node_path35.default.join(configDir, PROJECTS_DIR, project);
|
|
19470
19695
|
const entries = /* @__PURE__ */ new Set();
|
|
19471
19696
|
for (const name of fs13.readdir(projectDir)) {
|
|
19472
19697
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
19473
19698
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
19474
19699
|
continue;
|
|
19475
19700
|
}
|
|
19476
|
-
const children = fs13.readdir(
|
|
19701
|
+
const children = fs13.readdir(import_node_path35.default.join(projectDir, name));
|
|
19477
19702
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
19478
19703
|
entries.add(name);
|
|
19479
19704
|
}
|
|
@@ -19493,8 +19718,8 @@ function locateAgents(fs13, configDir, relativeDir, workflowRunId, report) {
|
|
|
19493
19718
|
const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
|
|
19494
19719
|
located.push({
|
|
19495
19720
|
id,
|
|
19496
|
-
metaPath:
|
|
19497
|
-
transcriptPath:
|
|
19721
|
+
metaPath: import_node_path35.default.join(relativeDir, name),
|
|
19722
|
+
transcriptPath: import_node_path35.default.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
|
|
19498
19723
|
workflowRunId
|
|
19499
19724
|
});
|
|
19500
19725
|
}
|
|
@@ -19537,7 +19762,7 @@ function describeFailure(error) {
|
|
|
19537
19762
|
}
|
|
19538
19763
|
function readFileOrReport(fs13, configDir, relative, report) {
|
|
19539
19764
|
try {
|
|
19540
|
-
return fs13.readFileUtf8(
|
|
19765
|
+
return fs13.readFileUtf8(import_node_path35.default.join(configDir, relative));
|
|
19541
19766
|
} catch (error) {
|
|
19542
19767
|
report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
|
|
19543
19768
|
return void 0;
|
|
@@ -19545,7 +19770,7 @@ function readFileOrReport(fs13, configDir, relative, report) {
|
|
|
19545
19770
|
}
|
|
19546
19771
|
function listDirOrReport(fs13, configDir, relative, report) {
|
|
19547
19772
|
try {
|
|
19548
|
-
return fs13.readdir(
|
|
19773
|
+
return fs13.readdir(import_node_path35.default.join(configDir, relative));
|
|
19549
19774
|
} catch (error) {
|
|
19550
19775
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
|
|
19551
19776
|
return [];
|
|
@@ -19559,28 +19784,28 @@ function parseJson2(text) {
|
|
|
19559
19784
|
return void 0;
|
|
19560
19785
|
}
|
|
19561
19786
|
}
|
|
19562
|
-
var TaskFileSchema =
|
|
19563
|
-
var WorkflowRunFileSchema =
|
|
19564
|
-
runId:
|
|
19565
|
-
workflowName:
|
|
19566
|
-
status:
|
|
19567
|
-
startTime:
|
|
19568
|
-
phases:
|
|
19569
|
-
summary:
|
|
19787
|
+
var TaskFileSchema = import_zod30.z.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: import_zod30.z.array(import_zod30.z.string()).default([]), blockedBy: import_zod30.z.array(import_zod30.z.string()).default([]) });
|
|
19788
|
+
var WorkflowRunFileSchema = import_zod30.z.object({
|
|
19789
|
+
runId: import_zod30.z.string(),
|
|
19790
|
+
workflowName: import_zod30.z.string().optional(),
|
|
19791
|
+
status: import_zod30.z.string().optional(),
|
|
19792
|
+
startTime: import_zod30.z.number().optional(),
|
|
19793
|
+
phases: import_zod30.z.array(import_zod30.z.object({ title: import_zod30.z.string() })).default([]),
|
|
19794
|
+
summary: import_zod30.z.string().optional()
|
|
19570
19795
|
});
|
|
19571
19796
|
function summariseSession(fs13, configDir, ref) {
|
|
19572
|
-
const sessionRelative =
|
|
19573
|
-
const subagentsRelative =
|
|
19574
|
-
const workflowsUnderSubagents =
|
|
19797
|
+
const sessionRelative = import_node_path35.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
19798
|
+
const subagentsRelative = import_node_path35.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
19799
|
+
const workflowsUnderSubagents = import_node_path35.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
19575
19800
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
19576
|
-
let agentCount = fs13.readdir(
|
|
19577
|
-
for (const runDir of fs13.readdir(
|
|
19801
|
+
let agentCount = fs13.readdir(import_node_path35.default.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
19802
|
+
for (const runDir of fs13.readdir(import_node_path35.default.join(configDir, workflowsUnderSubagents))) {
|
|
19578
19803
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
19579
|
-
agentCount += fs13.readdir(
|
|
19804
|
+
agentCount += fs13.readdir(import_node_path35.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
19580
19805
|
}
|
|
19581
19806
|
}
|
|
19582
|
-
const workflowRunCount = fs13.readdir(
|
|
19583
|
-
const transcript = fs13.lstat(
|
|
19807
|
+
const workflowRunCount = fs13.readdir(import_node_path35.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
|
|
19808
|
+
const transcript = fs13.lstat(import_node_path35.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
19584
19809
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
19585
19810
|
}
|
|
19586
19811
|
function readSessionAgentTree(fs13, configDir, ref, options = {}) {
|
|
@@ -19588,13 +19813,13 @@ function readSessionAgentTree(fs13, configDir, ref, options = {}) {
|
|
|
19588
19813
|
const report = (problem) => {
|
|
19589
19814
|
problems.push(problem);
|
|
19590
19815
|
};
|
|
19591
|
-
const sessionRelative =
|
|
19592
|
-
const subagentsRelative =
|
|
19593
|
-
const workflowsUnderSubagents =
|
|
19816
|
+
const sessionRelative = import_node_path35.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
19817
|
+
const subagentsRelative = import_node_path35.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
19818
|
+
const workflowsUnderSubagents = import_node_path35.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
19594
19819
|
const located = locateAgents(fs13, configDir, subagentsRelative, void 0, report);
|
|
19595
19820
|
for (const runDir of listDirOrReport(fs13, configDir, workflowsUnderSubagents, report)) {
|
|
19596
19821
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
19597
|
-
located.push(...locateAgents(fs13, configDir,
|
|
19822
|
+
located.push(...locateAgents(fs13, configDir, import_node_path35.default.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
19598
19823
|
}
|
|
19599
19824
|
}
|
|
19600
19825
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -19635,7 +19860,7 @@ function readSessionAgentTree(fs13, configDir, ref, options = {}) {
|
|
|
19635
19860
|
superseded: ref.superseded,
|
|
19636
19861
|
agents: roots.sort().map(build),
|
|
19637
19862
|
tasks: readTasks(fs13, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
|
|
19638
|
-
workflowRuns: readWorkflowRuns(fs13, configDir,
|
|
19863
|
+
workflowRuns: readWorkflowRuns(fs13, configDir, import_node_path35.default.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
19639
19864
|
problems
|
|
19640
19865
|
};
|
|
19641
19866
|
}
|
|
@@ -19700,12 +19925,12 @@ function ownTaskLists(sessionId) {
|
|
|
19700
19925
|
function readTasks(fs13, configDir, ownLists, sharedLists, report) {
|
|
19701
19926
|
const tasks = [];
|
|
19702
19927
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
19703
|
-
const relativeDir =
|
|
19928
|
+
const relativeDir = import_node_path35.default.join(TASKS_DIR, scope);
|
|
19704
19929
|
for (const name of [...listDirOrReport(fs13, configDir, relativeDir, report)].sort()) {
|
|
19705
19930
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
19706
19931
|
continue;
|
|
19707
19932
|
}
|
|
19708
|
-
const relative =
|
|
19933
|
+
const relative = import_node_path35.default.join(relativeDir, name);
|
|
19709
19934
|
const text = readFileOrReport(fs13, configDir, relative, report);
|
|
19710
19935
|
const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
19711
19936
|
if (parsed.success) {
|
|
@@ -19723,7 +19948,7 @@ function readWorkflowRuns(fs13, configDir, relativeDir, report) {
|
|
|
19723
19948
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
19724
19949
|
continue;
|
|
19725
19950
|
}
|
|
19726
|
-
const relative =
|
|
19951
|
+
const relative = import_node_path35.default.join(relativeDir, name);
|
|
19727
19952
|
const text = readFileOrReport(fs13, configDir, relative, report);
|
|
19728
19953
|
const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
19729
19954
|
if (!parsed.success) {
|
|
@@ -19739,7 +19964,7 @@ function readWorkflowRuns(fs13, configDir, relativeDir, report) {
|
|
|
19739
19964
|
}
|
|
19740
19965
|
|
|
19741
19966
|
// src/agents/sessions.ts
|
|
19742
|
-
var
|
|
19967
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
19743
19968
|
init_cliError();
|
|
19744
19969
|
var SessionLookupError = class extends CliError {
|
|
19745
19970
|
constructor(message) {
|
|
@@ -19748,13 +19973,13 @@ var SessionLookupError = class extends CliError {
|
|
|
19748
19973
|
}
|
|
19749
19974
|
};
|
|
19750
19975
|
function identityConfigDir(identitiesDir, identity) {
|
|
19751
|
-
return
|
|
19976
|
+
return import_node_path36.default.join(identitiesDir, identity);
|
|
19752
19977
|
}
|
|
19753
19978
|
function historyStores(fs13, identitiesDir, identities) {
|
|
19754
19979
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
19755
19980
|
for (const identity of identities) {
|
|
19756
19981
|
const configDir = identityConfigDir(identitiesDir, identity);
|
|
19757
|
-
const real = fs13.realpath(
|
|
19982
|
+
const real = fs13.realpath(import_node_path36.default.join(configDir, "projects"));
|
|
19758
19983
|
if (real === void 0) {
|
|
19759
19984
|
continue;
|
|
19760
19985
|
}
|