claude-use 11.25.0 → 11.26.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 +2 -0
- package/dist/cli.cjs +1160 -859
- package/dist/index.cjs +176 -102
- package/dist/index.mjs +172 -98
- package/dist/types/index.d.ts +51 -19
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -223,7 +223,7 @@ function isTimeZone(name) {
|
|
|
223
223
|
return false;
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
|
-
var CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, HttpProviderSchema, CodexProviderSchema, AntigravityProviderSchema, ProviderSchema, 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;
|
|
226
|
+
var CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, HttpProviderSchema, CodexProviderSchema, AntigravityProviderSchema, ProviderSchema, 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;
|
|
227
227
|
var init_schema = __esm({
|
|
228
228
|
"src/config/schema.ts"() {
|
|
229
229
|
"use strict";
|
|
@@ -402,6 +402,12 @@ var init_schema = __esm({
|
|
|
402
402
|
description: z.string().min(1).optional()
|
|
403
403
|
});
|
|
404
404
|
PickerModelsSchema = z.array(PickerModelSchema).refine((models) => new Set(models.map((entry) => entry.model)).size === models.length, { message: "pickerModels names a model more than once" });
|
|
405
|
+
ProviderCatalogueSchema = z.strictObject({
|
|
406
|
+
tier: z.enum(CLAUDE_TIERS),
|
|
407
|
+
include: z.array(z.string().min(1)).min(1).optional(),
|
|
408
|
+
exclude: z.array(z.string().min(1)).min(1).optional(),
|
|
409
|
+
url: z.url().optional()
|
|
410
|
+
});
|
|
405
411
|
HttpProviderSchema = z.strictObject({
|
|
406
412
|
$schema: z.string().optional(),
|
|
407
413
|
kind: z.literal("http").optional(),
|
|
@@ -411,6 +417,8 @@ var init_schema = __esm({
|
|
|
411
417
|
env: ProviderEnvSchema.optional(),
|
|
412
418
|
/** Extra models `/model` lists beside the ones the tier settings name. */
|
|
413
419
|
pickerModels: PickerModelsSchema.optional(),
|
|
420
|
+
/** The provider's own model catalogue, listed in `/model` when set. */
|
|
421
|
+
catalogue: ProviderCatalogueSchema.optional(),
|
|
414
422
|
/** Per-request routing: when present, each request this provider would serve is matched against the list in order, and the first definite match is sent to that entry's provider instead (itself resolved exactly as a directly dialled request would be). Unmatched requests stay on this provider. */
|
|
415
423
|
routes: z.array(ProviderRouteSchema).optional()
|
|
416
424
|
});
|
|
@@ -621,7 +629,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
621
629
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
622
630
|
}
|
|
623
631
|
function describeIgnoredKeys(filePath, ignored) {
|
|
624
|
-
const places = ignored.map(({ path:
|
|
632
|
+
const places = ignored.map(({ path: path43, keys }) => `${path43.length === 0 ? "" : `${path43.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
625
633
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
626
634
|
}
|
|
627
635
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -643,9 +651,9 @@ function restoreIgnoredKeys(filePath, value) {
|
|
|
643
651
|
return value;
|
|
644
652
|
}
|
|
645
653
|
const restored = structuredClone(value);
|
|
646
|
-
for (const { path:
|
|
654
|
+
for (const { path: path43, values } of ignored) {
|
|
647
655
|
let holder = restored;
|
|
648
|
-
for (const step of
|
|
656
|
+
for (const step of path43) {
|
|
649
657
|
holder = isRecord(holder) ? holder[step] : void 0;
|
|
650
658
|
}
|
|
651
659
|
if (isRecord(holder)) {
|
|
@@ -2923,7 +2931,7 @@ var init_package = __esm({
|
|
|
2923
2931
|
"package.json"() {
|
|
2924
2932
|
package_default = {
|
|
2925
2933
|
name: "claude-use",
|
|
2926
|
-
version: "11.
|
|
2934
|
+
version: "11.26.0",
|
|
2927
2935
|
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.",
|
|
2928
2936
|
license: "MIT",
|
|
2929
2937
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -6032,6 +6040,7 @@ function buildLayoutPaths(root) {
|
|
|
6032
6040
|
usageDir: path23.join(root, "usage"),
|
|
6033
6041
|
usageLogDir: path23.join(root, "usage", "log"),
|
|
6034
6042
|
usageSnapshotsDir: path23.join(root, "usage", "snapshots"),
|
|
6043
|
+
catalogueDir: path23.join(root, "catalogues"),
|
|
6035
6044
|
usagePicksFile: path23.join(root, "usage", "picks.json"),
|
|
6036
6045
|
usageAnchorsFile: path23.join(root, "usage", "anchors.json"),
|
|
6037
6046
|
usageJobsFile: path23.join(root, "usage", "jobs.json"),
|
|
@@ -6476,7 +6485,10 @@ function loadProvider(providersDir, name, port) {
|
|
|
6476
6485
|
const raw = port.readConfigFile(filePath);
|
|
6477
6486
|
return raw === void 0 ? void 0 : parseProviderFile(filePath, raw);
|
|
6478
6487
|
}
|
|
6479
|
-
function
|
|
6488
|
+
function reportInvalidProvider(name, message) {
|
|
6489
|
+
console.error(`agent-shim: providers/${name}.json is invalid and was skipped: ${message}`);
|
|
6490
|
+
}
|
|
6491
|
+
function listProviders(paths, onInvalid = reportInvalidProvider) {
|
|
6480
6492
|
const names = listProviderNames(
|
|
6481
6493
|
(dir) => fs7.readdirSync(dir),
|
|
6482
6494
|
paths.providersDir
|
|
@@ -6490,7 +6502,7 @@ function listProviders(paths) {
|
|
|
6490
6502
|
if (!(error instanceof ConfigValidationError || error instanceof LegacyProviderFileError)) {
|
|
6491
6503
|
throw error;
|
|
6492
6504
|
}
|
|
6493
|
-
|
|
6505
|
+
onInvalid(name, error.message);
|
|
6494
6506
|
continue;
|
|
6495
6507
|
}
|
|
6496
6508
|
if (provider !== void 0) {
|
|
@@ -6540,6 +6552,9 @@ function addProvider(paths, name, input) {
|
|
|
6540
6552
|
if (kind === "http" && input.baseUrl === void 0) {
|
|
6541
6553
|
throw new ProviderKindMismatchError("An http provider needs --base-url.");
|
|
6542
6554
|
}
|
|
6555
|
+
if (kind !== "http" && input.catalogue !== void 0) {
|
|
6556
|
+
throw new ProviderKindMismatchError("A model catalogue applies only to an http provider.");
|
|
6557
|
+
}
|
|
6543
6558
|
if (kind !== "codex" && !isEmptyCodexConfig(input.codex)) {
|
|
6544
6559
|
throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
|
|
6545
6560
|
}
|
|
@@ -6553,7 +6568,7 @@ function addProvider(paths, name, input) {
|
|
|
6553
6568
|
...input.pickerModels === void 0 || input.pickerModels.length === 0 ? {} : { pickerModels: input.pickerModels }
|
|
6554
6569
|
};
|
|
6555
6570
|
const parsed = ProviderSchema.safeParse(
|
|
6556
|
-
kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input.codex) ? {} : { codex: input.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input.antigravity) ? {} : { antigravity: input.antigravity } } : { ...shared, baseUrl: input.baseUrl }
|
|
6571
|
+
kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input.codex) ? {} : { codex: input.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input.antigravity) ? {} : { antigravity: input.antigravity } } : { ...shared, baseUrl: input.baseUrl, ...input.catalogue === void 0 ? {} : { catalogue: input.catalogue } }
|
|
6557
6572
|
);
|
|
6558
6573
|
if (!parsed.success) {
|
|
6559
6574
|
throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
|
|
@@ -6582,6 +6597,9 @@ function updateProvider(paths, name, input) {
|
|
|
6582
6597
|
if (isAntigravityProvider(existing) && input.baseUrl !== void 0) {
|
|
6583
6598
|
throw new ProviderKindMismatchError(`Provider "${name}" is an antigravity provider, which has no base URL.`);
|
|
6584
6599
|
}
|
|
6600
|
+
if ((isCodexProvider(existing) || isAntigravityProvider(existing)) && input.catalogue !== void 0 && input.catalogue !== false) {
|
|
6601
|
+
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a model catalogue applies only to an http provider.`);
|
|
6602
|
+
}
|
|
6585
6603
|
if (!isCodexProvider(existing) && !isEmptyCodexConfig(input.codex)) {
|
|
6586
6604
|
throw new ProviderKindMismatchError(`Provider "${name}" is not a codex provider; codex settings apply only to a codex provider.`);
|
|
6587
6605
|
}
|
|
@@ -6614,7 +6632,8 @@ function updateProvider(paths, name, input) {
|
|
|
6614
6632
|
};
|
|
6615
6633
|
candidate = { ...existing, ...shared, antigravity: isEmptyAntigravityConfig(antigravity) ? void 0 : antigravity };
|
|
6616
6634
|
} else {
|
|
6617
|
-
|
|
6635
|
+
const catalogue = input.catalogue === void 0 ? existing.catalogue : input.catalogue === false ? void 0 : input.catalogue;
|
|
6636
|
+
candidate = { ...existing, ...shared, catalogue, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
|
|
6618
6637
|
}
|
|
6619
6638
|
const parsed = ProviderSchema.safeParse(candidate);
|
|
6620
6639
|
if (!parsed.success) {
|
|
@@ -8004,6 +8023,49 @@ var init_translate2 = __esm({
|
|
|
8004
8023
|
}
|
|
8005
8024
|
});
|
|
8006
8025
|
|
|
8026
|
+
// src/providerCatalogue.ts
|
|
8027
|
+
import path38 from "node:path";
|
|
8028
|
+
import picomatch4 from "picomatch";
|
|
8029
|
+
import { z as z30 } from "zod";
|
|
8030
|
+
function catalogueCachePath(paths, name) {
|
|
8031
|
+
return path38.join(paths.catalogueDir, `${name}.json`);
|
|
8032
|
+
}
|
|
8033
|
+
function parseCatalogueCache(text) {
|
|
8034
|
+
if (text === void 0) {
|
|
8035
|
+
return void 0;
|
|
8036
|
+
}
|
|
8037
|
+
try {
|
|
8038
|
+
const parsed = CatalogueCacheSchema.safeParse(JSON.parse(text));
|
|
8039
|
+
return parsed.success ? parsed.data : void 0;
|
|
8040
|
+
} catch {
|
|
8041
|
+
return void 0;
|
|
8042
|
+
}
|
|
8043
|
+
}
|
|
8044
|
+
function filterCatalogue(models, catalogue) {
|
|
8045
|
+
const included = catalogue.include === void 0 ? void 0 : picomatch4(catalogue.include, { dot: true });
|
|
8046
|
+
const excluded = catalogue.exclude === void 0 ? void 0 : picomatch4(catalogue.exclude, { dot: true });
|
|
8047
|
+
return models.filter((model) => included?.(model.id) !== false && excluded?.(model.id) !== true);
|
|
8048
|
+
}
|
|
8049
|
+
var DEFAULT_CANDIDATE_URLS, MS_PER_SECOND7, 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;
|
|
8050
|
+
var init_providerCatalogue = __esm({
|
|
8051
|
+
"src/providerCatalogue.ts"() {
|
|
8052
|
+
"use strict";
|
|
8053
|
+
DEFAULT_CANDIDATE_URLS = 2;
|
|
8054
|
+
MS_PER_SECOND7 = 1e3;
|
|
8055
|
+
SECONDS_PER_HOUR2 = 3600;
|
|
8056
|
+
HOURS_PER_DAY5 = 24;
|
|
8057
|
+
MS_PER_HOUR5 = SECONDS_PER_HOUR2 * MS_PER_SECOND7;
|
|
8058
|
+
HOURS_BETWEEN_RETRIES = 1;
|
|
8059
|
+
CATALOGUE_MAX_AGE_MS = HOURS_PER_DAY5 * MS_PER_HOUR5;
|
|
8060
|
+
CATALOGUE_RETRY_MS = HOURS_BETWEEN_RETRIES * MS_PER_HOUR5;
|
|
8061
|
+
CATALOGUE_REQUEST_SECONDS = 10;
|
|
8062
|
+
CATALOGUE_REQUEST_TIMEOUT_MS = CATALOGUE_REQUEST_SECONDS * MS_PER_SECOND7;
|
|
8063
|
+
CATALOGUE_REFRESH_TIMEOUT_MS = DEFAULT_CANDIDATE_URLS * CATALOGUE_REQUEST_TIMEOUT_MS;
|
|
8064
|
+
CatalogueModelSchema = z30.strictObject({ id: z30.string().min(1), name: z30.string().min(1).optional() });
|
|
8065
|
+
CatalogueCacheSchema = z30.strictObject({ fetchedAt: z30.number(), url: z30.string().min(1), models: z30.array(CatalogueModelSchema) });
|
|
8066
|
+
}
|
|
8067
|
+
});
|
|
8068
|
+
|
|
8007
8069
|
// src/launcher/modelPicker.ts
|
|
8008
8070
|
function labelOf(model) {
|
|
8009
8071
|
return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? model.slice(0, -CONTEXT_MARKER_1M.length) : model;
|
|
@@ -8070,14 +8132,23 @@ function declaredRow(entry) {
|
|
|
8070
8132
|
behavesAs: TIER_BEHAVES_AS[entry.tier]
|
|
8071
8133
|
};
|
|
8072
8134
|
}
|
|
8073
|
-
function
|
|
8135
|
+
function catalogueRows(provider, models) {
|
|
8136
|
+
if (provider.kind !== void 0 && provider.kind !== "http" || provider.catalogue === void 0) {
|
|
8137
|
+
return [];
|
|
8138
|
+
}
|
|
8139
|
+
const { tier } = provider.catalogue;
|
|
8140
|
+
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));
|
|
8141
|
+
}
|
|
8142
|
+
function providerModelRows(provider, catalogue = []) {
|
|
8074
8143
|
const derived = provider.kind === "codex" ? codexRows(provider) : provider.kind === "antigravity" ? antigravityRows(provider) : httpRows(provider);
|
|
8075
8144
|
const declared = (provider.pickerModels ?? []).map(declaredRow);
|
|
8076
8145
|
const declaredModels = new Set(declared.map((row) => row.model));
|
|
8077
|
-
|
|
8146
|
+
const named = [...derived.filter((row) => !declaredModels.has(row.model)), ...declared];
|
|
8147
|
+
const taken = new Set(named.map((row) => labelOf(row.model)));
|
|
8148
|
+
return [...named, ...catalogueRows(provider, catalogue).filter((row) => !taken.has(labelOf(row.model)))];
|
|
8078
8149
|
}
|
|
8079
|
-
function modelPickerSettings(provider) {
|
|
8080
|
-
const options = providerModelRows(provider);
|
|
8150
|
+
function modelPickerSettings(provider, catalogue = []) {
|
|
8151
|
+
const options = providerModelRows(provider, catalogue);
|
|
8081
8152
|
return options.length === 0 ? void 0 : JSON.stringify({ modelPicker: { options, replaceBuiltInOptions: true } });
|
|
8082
8153
|
}
|
|
8083
8154
|
var CONTEXT_MARKER_1M, TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
|
|
@@ -8086,6 +8157,7 @@ var init_modelPicker = __esm({
|
|
|
8086
8157
|
"use strict";
|
|
8087
8158
|
init_translate();
|
|
8088
8159
|
init_translate2();
|
|
8160
|
+
init_providerCatalogue();
|
|
8089
8161
|
init_schema();
|
|
8090
8162
|
CONTEXT_MARKER_1M = "[1m]";
|
|
8091
8163
|
TIER_BEHAVES_AS = Object.freeze({
|
|
@@ -8303,7 +8375,7 @@ var init_launchHook = __esm({
|
|
|
8303
8375
|
|
|
8304
8376
|
// src/launcher.ts
|
|
8305
8377
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
8306
|
-
import
|
|
8378
|
+
import path39 from "node:path";
|
|
8307
8379
|
function resolveIdentityCredential(identity, credential, env, port) {
|
|
8308
8380
|
if (port === void 0) {
|
|
8309
8381
|
return { ok: false, status: 1, message: `agent-shim: identity ${identity} needs its credential resolved, but this launcher has no credential port wired` };
|
|
@@ -8419,7 +8491,7 @@ function decideLaunch(params, readOnly) {
|
|
|
8419
8491
|
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
8420
8492
|
globalDefaultConfigProfile: params.globalDefaultConfigProfile
|
|
8421
8493
|
});
|
|
8422
|
-
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs13.readConfigFile(
|
|
8494
|
+
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs13.readConfigFile(path39.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
|
|
8423
8495
|
log.error(
|
|
8424
8496
|
`agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
|
|
8425
8497
|
);
|
|
@@ -8529,7 +8601,8 @@ function decideLaunch(params, readOnly) {
|
|
|
8529
8601
|
log.info(`agent-shim: identity ${loginlessProvider.identity} has no stored login, so Remote Control, which needs one, is off for this launch; provider ${loginlessProvider.provider} runs without it`);
|
|
8530
8602
|
}
|
|
8531
8603
|
const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
|
|
8532
|
-
const
|
|
8604
|
+
const catalogue = selectedProvider === void 0 ? void 0 : parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, selectedProvider.name)));
|
|
8605
|
+
const pickerSettings = selectedProvider === void 0 ? void 0 : modelPickerSettings(selectedProvider.definition, catalogue?.models);
|
|
8533
8606
|
const callerSettings = hasSettingsArgument(parsedArgv.rest);
|
|
8534
8607
|
if (pickerSettings !== void 0 && callerSettings && !readOnly) {
|
|
8535
8608
|
log.info("agent-shim: this launch passes its own --settings, so /model keeps Claude Code's own model names instead of listing the provider's models");
|
|
@@ -8540,7 +8613,7 @@ function decideLaunch(params, readOnly) {
|
|
|
8540
8613
|
extraFlags: splitExtraFlags(env.CLAUDE_EXTRA_FLAGS),
|
|
8541
8614
|
passthrough: withLauncherSettings(params.supervised === void 0 ? parsedArgv.rest : withSupervision(parsedArgv.rest, params.supervised), launcherSettings)
|
|
8542
8615
|
});
|
|
8543
|
-
const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR :
|
|
8616
|
+
const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : path39.join(paths.identitiesDir, identityDecision.name);
|
|
8544
8617
|
const decision = {
|
|
8545
8618
|
identitySource: identityDecision.source,
|
|
8546
8619
|
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
@@ -8581,7 +8654,7 @@ function prepareLaunch(params) {
|
|
|
8581
8654
|
);
|
|
8582
8655
|
const updateCheck = runLaunchUpdateCheck({
|
|
8583
8656
|
mode: params.updateMode ?? "off",
|
|
8584
|
-
checkPath:
|
|
8657
|
+
checkPath: path39.join(paths.root, "update.check"),
|
|
8585
8658
|
currentVersion: package_default.version,
|
|
8586
8659
|
port: params.update
|
|
8587
8660
|
});
|
|
@@ -8729,6 +8802,7 @@ var init_launcher = __esm({
|
|
|
8729
8802
|
init_extraFlags();
|
|
8730
8803
|
init_claudeSession();
|
|
8731
8804
|
init_modelPicker();
|
|
8805
|
+
init_providerCatalogue();
|
|
8732
8806
|
init_pool();
|
|
8733
8807
|
init_resumeContext();
|
|
8734
8808
|
init_lock();
|
|
@@ -8747,12 +8821,12 @@ var init_launcher = __esm({
|
|
|
8747
8821
|
});
|
|
8748
8822
|
|
|
8749
8823
|
// src/ownCli.ts
|
|
8750
|
-
import
|
|
8824
|
+
import path40 from "node:path";
|
|
8751
8825
|
function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string" ? __AGENT_SHIM_DIST_DIR__ : void 0) {
|
|
8752
8826
|
if (distDir === void 0) {
|
|
8753
8827
|
throw new OwnCliPathUnknownError();
|
|
8754
8828
|
}
|
|
8755
|
-
return
|
|
8829
|
+
return path40.join(distDir, OWN_CLI_FILE_NAME);
|
|
8756
8830
|
}
|
|
8757
8831
|
var OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
8758
8832
|
var init_ownCli = __esm({
|
|
@@ -8782,10 +8856,10 @@ var init_selfIdentity = __esm({
|
|
|
8782
8856
|
|
|
8783
8857
|
// src/frontdoor/trust.ts
|
|
8784
8858
|
import { createHash as createHash7 } from "node:crypto";
|
|
8785
|
-
import
|
|
8859
|
+
import path41 from "node:path";
|
|
8786
8860
|
function resolveTrustBundle(params) {
|
|
8787
8861
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs13 } = params;
|
|
8788
|
-
if (inherited === void 0 || inherited === "" ||
|
|
8862
|
+
if (inherited === void 0 || inherited === "" || path41.resolve(inherited) === path41.resolve(caCertFile)) {
|
|
8789
8863
|
return { path: caCertFile };
|
|
8790
8864
|
}
|
|
8791
8865
|
const caPem = fs13.readFileUtf8(caCertFile);
|
|
@@ -8803,7 +8877,7 @@ function resolveTrustBundle(params) {
|
|
|
8803
8877
|
}
|
|
8804
8878
|
const combined = `${inheritedPem.trimEnd()}
|
|
8805
8879
|
${caPem}`;
|
|
8806
|
-
const bundle =
|
|
8880
|
+
const bundle = path41.join(bundlesDir, `${createHash7("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
8807
8881
|
if (!fs13.exists(bundle)) {
|
|
8808
8882
|
fs13.mkdirp(bundlesDir);
|
|
8809
8883
|
fs13.writeFileAtomic(bundle, combined);
|
|
@@ -8881,7 +8955,7 @@ var init_realFrontDoorPort = __esm({
|
|
|
8881
8955
|
|
|
8882
8956
|
// src/launchWiring.ts
|
|
8883
8957
|
import os8 from "node:os";
|
|
8884
|
-
import
|
|
8958
|
+
import path42 from "node:path";
|
|
8885
8959
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
8886
8960
|
function buildFarmRuntime(paths, cwd) {
|
|
8887
8961
|
const home = os8.homedir();
|
|
@@ -8935,7 +9009,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
8935
9009
|
headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
|
|
8936
9010
|
frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
|
|
8937
9011
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
8938
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: realRunPort }, { farmRoot:
|
|
9012
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: realRunPort }, { farmRoot: path42.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
|
|
8939
9013
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
8940
9014
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
8941
9015
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -9210,76 +9284,76 @@ var init_identityClaude = __esm({
|
|
|
9210
9284
|
});
|
|
9211
9285
|
|
|
9212
9286
|
// src/usage/providerQuota.ts
|
|
9213
|
-
import { z as
|
|
9214
|
-
var
|
|
9287
|
+
import { z as z31 } from "zod";
|
|
9288
|
+
var MS_PER_SECOND8, SECONDS_PER_HOUR3, HOURS_PER_DAY6, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
|
|
9215
9289
|
var init_providerQuota = __esm({
|
|
9216
9290
|
"src/usage/providerQuota.ts"() {
|
|
9217
9291
|
"use strict";
|
|
9218
9292
|
init_cloudUpstream();
|
|
9219
9293
|
init_schema2();
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9294
|
+
MS_PER_SECOND8 = 1e3;
|
|
9295
|
+
SECONDS_PER_HOUR3 = 3600;
|
|
9296
|
+
HOURS_PER_DAY6 = 24;
|
|
9223
9297
|
DAYS_PER_MONTH = 30;
|
|
9224
9298
|
ZAI_HOST = "api.z.ai";
|
|
9225
9299
|
ZAI_QUOTA_URL = `https://${ZAI_HOST}/api/monitor/usage/quota/limit`;
|
|
9226
9300
|
ZAI_UNIT_HOURS = 3;
|
|
9227
9301
|
ZAI_UNIT_MONTHS = 5;
|
|
9228
9302
|
ZAI_UNIT_MS = /* @__PURE__ */ new Map([
|
|
9229
|
-
[ZAI_UNIT_HOURS,
|
|
9230
|
-
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH *
|
|
9303
|
+
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND8],
|
|
9304
|
+
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND8]
|
|
9231
9305
|
]);
|
|
9232
|
-
ZaiLimitSchema =
|
|
9233
|
-
type:
|
|
9234
|
-
unit:
|
|
9235
|
-
number:
|
|
9236
|
-
percentage:
|
|
9237
|
-
nextResetTime:
|
|
9238
|
-
usage:
|
|
9239
|
-
currentValue:
|
|
9240
|
-
remaining:
|
|
9306
|
+
ZaiLimitSchema = z31.object({
|
|
9307
|
+
type: z31.string(),
|
|
9308
|
+
unit: z31.number().int(),
|
|
9309
|
+
number: z31.number().int().positive(),
|
|
9310
|
+
percentage: z31.number().nonnegative(),
|
|
9311
|
+
nextResetTime: z31.number().positive().optional(),
|
|
9312
|
+
usage: z31.number().nonnegative().optional(),
|
|
9313
|
+
currentValue: z31.number().nonnegative().optional(),
|
|
9314
|
+
remaining: z31.number().nonnegative().optional()
|
|
9241
9315
|
});
|
|
9242
|
-
ZaiResponseSchema =
|
|
9243
|
-
success:
|
|
9244
|
-
msg:
|
|
9245
|
-
data:
|
|
9316
|
+
ZaiResponseSchema = z31.object({
|
|
9317
|
+
success: z31.boolean(),
|
|
9318
|
+
msg: z31.string().optional(),
|
|
9319
|
+
data: z31.object({ level: z31.string().optional(), limits: z31.array(ZaiLimitSchema) })
|
|
9246
9320
|
});
|
|
9247
9321
|
OPENROUTER_HOST = "openrouter.ai";
|
|
9248
9322
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
9249
9323
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
9250
|
-
MS_PER_DAY3 =
|
|
9251
|
-
OpenRouterKeySchema =
|
|
9252
|
-
data:
|
|
9253
|
-
limit:
|
|
9254
|
-
limit_remaining:
|
|
9255
|
-
limit_reset:
|
|
9256
|
-
is_free_tier:
|
|
9257
|
-
free_model_daily_requests:
|
|
9324
|
+
MS_PER_DAY3 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND8;
|
|
9325
|
+
OpenRouterKeySchema = z31.object({
|
|
9326
|
+
data: z31.object({
|
|
9327
|
+
limit: z31.number().nonnegative().nullable(),
|
|
9328
|
+
limit_remaining: z31.number().nullable(),
|
|
9329
|
+
limit_reset: z31.string().nullable(),
|
|
9330
|
+
is_free_tier: z31.boolean().optional(),
|
|
9331
|
+
free_model_daily_requests: z31.object({ used: z31.number().nonnegative(), limit: z31.number().nonnegative(), remaining: z31.number() }).optional()
|
|
9258
9332
|
})
|
|
9259
9333
|
});
|
|
9260
|
-
OpenRouterCreditsSchema =
|
|
9334
|
+
OpenRouterCreditsSchema = z31.object({ data: z31.object({ total_credits: z31.number().nonnegative(), total_usage: z31.number().nonnegative() }) });
|
|
9261
9335
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
9262
9336
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
9263
9337
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
9264
9338
|
FIVE_HOURS2 = 5;
|
|
9265
9339
|
DAYS_PER_WEEK2 = 7;
|
|
9266
|
-
FIVE_HOURS_MS = FIVE_HOURS2 *
|
|
9267
|
-
WEEK_MS = DAYS_PER_WEEK2 *
|
|
9268
|
-
AntigravityBucketSchema =
|
|
9269
|
-
bucketId:
|
|
9270
|
-
remainingFraction:
|
|
9271
|
-
resetTime:
|
|
9340
|
+
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND8;
|
|
9341
|
+
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND8;
|
|
9342
|
+
AntigravityBucketSchema = z31.object({
|
|
9343
|
+
bucketId: z31.string(),
|
|
9344
|
+
remainingFraction: z31.number().optional(),
|
|
9345
|
+
resetTime: z31.string().optional()
|
|
9272
9346
|
});
|
|
9273
|
-
AntigravitySummarySchema =
|
|
9274
|
-
GoogleTokenInfoSchema =
|
|
9275
|
-
email:
|
|
9276
|
-
sub:
|
|
9347
|
+
AntigravitySummarySchema = z31.object({ groups: z31.array(z31.object({ buckets: z31.array(AntigravityBucketSchema) })) });
|
|
9348
|
+
GoogleTokenInfoSchema = z31.object({
|
|
9349
|
+
email: z31.string().optional(),
|
|
9350
|
+
sub: z31.string().optional()
|
|
9277
9351
|
});
|
|
9278
|
-
AntigravityUserSchema =
|
|
9352
|
+
AntigravityUserSchema = z31.object({
|
|
9279
9353
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
9280
|
-
currentTier:
|
|
9354
|
+
currentTier: z31.object({ name: z31.string().optional(), id: z31.string().optional() }).optional(),
|
|
9281
9355
|
/** The account's paid subscription; absent when the account has none. */
|
|
9282
|
-
paidTier:
|
|
9356
|
+
paidTier: z31.object({ name: z31.string().optional(), id: z31.string().optional() }).optional()
|
|
9283
9357
|
});
|
|
9284
9358
|
}
|
|
9285
9359
|
});
|
|
@@ -9908,8 +9982,8 @@ function parseConnectTarget(authority) {
|
|
|
9908
9982
|
function isInterceptedHost(host, interceptHosts) {
|
|
9909
9983
|
return interceptHosts.includes(host);
|
|
9910
9984
|
}
|
|
9911
|
-
function servedByPipeline(
|
|
9912
|
-
return
|
|
9985
|
+
function servedByPipeline(path43) {
|
|
9986
|
+
return path43?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
9913
9987
|
}
|
|
9914
9988
|
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
9915
9989
|
"connection",
|
|
@@ -10703,11 +10777,11 @@ function createRcSessionTracker(deps) {
|
|
|
10703
10777
|
};
|
|
10704
10778
|
const observeExchange = (request4) => {
|
|
10705
10779
|
const method = (request4.method ?? "").toUpperCase();
|
|
10706
|
-
const
|
|
10707
|
-
if (!
|
|
10780
|
+
const path43 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
|
|
10781
|
+
if (!path43.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
10708
10782
|
return void 0;
|
|
10709
10783
|
}
|
|
10710
|
-
const tail =
|
|
10784
|
+
const tail = path43.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
10711
10785
|
const facts = {
|
|
10712
10786
|
oauthAuthorization: oauthAuthorizationOf(request4.headers),
|
|
10713
10787
|
anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
|
|
@@ -11097,8 +11171,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
11097
11171
|
function isRcReadFileEncoding(value) {
|
|
11098
11172
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
|
|
11099
11173
|
}
|
|
11100
|
-
function buildRcReadFilePayload(requestId,
|
|
11101
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
11174
|
+
function buildRcReadFilePayload(requestId, path43, options) {
|
|
11175
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path43, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
11102
11176
|
}
|
|
11103
11177
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
11104
11178
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -11200,15 +11274,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
11200
11274
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
11201
11275
|
return result.ok ? { ...result, requestId } : result;
|
|
11202
11276
|
}
|
|
11203
|
-
async function readRcSessionFile(deps, sessionId,
|
|
11204
|
-
if (
|
|
11277
|
+
async function readRcSessionFile(deps, sessionId, path43, options) {
|
|
11278
|
+
if (path43 === "") {
|
|
11205
11279
|
return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
|
|
11206
11280
|
}
|
|
11207
11281
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
11208
11282
|
return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
|
|
11209
11283
|
}
|
|
11210
11284
|
const requestId = deps.newUuid();
|
|
11211
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
11285
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path43, options), `read ${path43} from session ${sessionId}`);
|
|
11212
11286
|
return result.ok ? { ...result, requestId } : result;
|
|
11213
11287
|
}
|
|
11214
11288
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -11377,11 +11451,11 @@ function createRcControlHandler(deps) {
|
|
|
11377
11451
|
path: "read-file",
|
|
11378
11452
|
read: (body) => {
|
|
11379
11453
|
const session = bodyString(body, "session");
|
|
11380
|
-
const
|
|
11454
|
+
const path43 = bodyString(body, "path");
|
|
11381
11455
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
11382
11456
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
11383
|
-
const refused2 = session === void 0 ||
|
|
11384
|
-
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session,
|
|
11457
|
+
const refused2 = session === void 0 || path43 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
11458
|
+
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path43, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
11385
11459
|
}
|
|
11386
11460
|
},
|
|
11387
11461
|
{
|
|
@@ -11691,9 +11765,9 @@ function requestIdOfBody(body) {
|
|
|
11691
11765
|
}
|
|
11692
11766
|
function frontDoorRcControl(transport, token) {
|
|
11693
11767
|
const headers = { authorization: `Bearer ${token}` };
|
|
11694
|
-
const listAnswerOf = async (
|
|
11768
|
+
const listAnswerOf = async (path43, what) => {
|
|
11695
11769
|
try {
|
|
11696
|
-
return await transport.request({ method: "GET", path:
|
|
11770
|
+
return await transport.request({ method: "GET", path: path43, headers });
|
|
11697
11771
|
} catch (error) {
|
|
11698
11772
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
11699
11773
|
}
|
|
@@ -11765,10 +11839,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
11765
11839
|
}
|
|
11766
11840
|
return pending;
|
|
11767
11841
|
};
|
|
11768
|
-
const writeOf = async (
|
|
11842
|
+
const writeOf = async (path43, body, describeFailure2) => {
|
|
11769
11843
|
let answer;
|
|
11770
11844
|
try {
|
|
11771
|
-
answer = await transport.request({ method: "POST", path:
|
|
11845
|
+
answer = await transport.request({ method: "POST", path: path43, headers: { ...headers, "content-type": "application/json" }, body });
|
|
11772
11846
|
} catch (error) {
|
|
11773
11847
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
11774
11848
|
}
|
|
@@ -11799,10 +11873,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
11799
11873
|
endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
11800
11874
|
getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
11801
11875
|
getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
11802
|
-
readFile: async (sessionId,
|
|
11876
|
+
readFile: async (sessionId, path43, options) => await writeOf(
|
|
11803
11877
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
11804
|
-
JSON.stringify({ session: sessionId, path:
|
|
11805
|
-
(status, message) => `reading ${
|
|
11878
|
+
JSON.stringify({ session: sessionId, path: path43, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
11879
|
+
(status, message) => `reading ${path43} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
11806
11880
|
),
|
|
11807
11881
|
fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
11808
11882
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -11961,12 +12035,12 @@ function tlsFacts(options) {
|
|
|
11961
12035
|
}
|
|
11962
12036
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
11963
12037
|
const agent = new ExemptTlsAgent();
|
|
11964
|
-
const post = async (
|
|
12038
|
+
const post = async (path43, headers, body) => await new Promise((resolve, reject) => {
|
|
11965
12039
|
const options = {
|
|
11966
12040
|
host: target.host,
|
|
11967
12041
|
port: target.port,
|
|
11968
12042
|
method: "POST",
|
|
11969
|
-
path:
|
|
12043
|
+
path: path43,
|
|
11970
12044
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
11971
12045
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
11972
12046
|
agent
|
|
@@ -12031,12 +12105,12 @@ function lateRcStreamDial(resolve) {
|
|
|
12031
12105
|
}
|
|
12032
12106
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
12033
12107
|
const agent = new ExemptTlsAgent();
|
|
12034
|
-
const request4 = async (method,
|
|
12108
|
+
const request4 = async (method, path43, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
12035
12109
|
const options = {
|
|
12036
12110
|
host: target.host,
|
|
12037
12111
|
port: target.port,
|
|
12038
12112
|
method,
|
|
12039
|
-
path:
|
|
12113
|
+
path: path43,
|
|
12040
12114
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
12041
12115
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
12042
12116
|
agent,
|
|
@@ -12078,9 +12152,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
12078
12152
|
return { status, body: await readAll(response) };
|
|
12079
12153
|
},
|
|
12080
12154
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
12081
|
-
const
|
|
12155
|
+
const path43 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
12082
12156
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
12083
|
-
const { status, response } = await request4("GET",
|
|
12157
|
+
const { status, response } = await request4("GET", path43, streamHeaders, void 0, signal);
|
|
12084
12158
|
if (!isSuccessful2(status)) {
|
|
12085
12159
|
await readAll(response);
|
|
12086
12160
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -13232,19 +13306,19 @@ function writePools(paths, pools) {
|
|
|
13232
13306
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
13233
13307
|
}
|
|
13234
13308
|
function poolCycleOf(pools, name) {
|
|
13235
|
-
const walk = (current,
|
|
13309
|
+
const walk = (current, path43) => {
|
|
13236
13310
|
for (const entry of pools[current]?.identities ?? []) {
|
|
13237
13311
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
13238
13312
|
if (nested === void 0) {
|
|
13239
13313
|
continue;
|
|
13240
13314
|
}
|
|
13241
13315
|
if (nested === name) {
|
|
13242
|
-
return [...
|
|
13316
|
+
return [...path43, nested];
|
|
13243
13317
|
}
|
|
13244
|
-
if (
|
|
13318
|
+
if (path43.includes(nested)) {
|
|
13245
13319
|
continue;
|
|
13246
13320
|
}
|
|
13247
|
-
const found = walk(nested, [...
|
|
13321
|
+
const found = walk(nested, [...path43, nested]);
|
|
13248
13322
|
if (found !== void 0) {
|
|
13249
13323
|
return found;
|
|
13250
13324
|
}
|
|
@@ -15523,7 +15597,7 @@ function profileValue(name, paths) {
|
|
|
15523
15597
|
function createConfigApiRouter(deps) {
|
|
15524
15598
|
const authed = doorApiAuth(deps.expectedToken);
|
|
15525
15599
|
const { paths } = deps;
|
|
15526
|
-
const route = (
|
|
15600
|
+
const route = (path43, summary) => authed.meta(openapi3({ method: "POST", path: path43, summary, tags: [CONFIG_API_TAG] }));
|
|
15527
15601
|
return {
|
|
15528
15602
|
config: {
|
|
15529
15603
|
identity: {
|