agent-shim 14.12.4 → 14.13.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 +1 -1
- package/dist/cli.cjs +134 -7
- package/dist/index.cjs +104 -5
- package/dist/index.mjs +102 -5
- package/dist/types/index.d.ts +1002 -886
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ Every top-level entry in `~/.claude` is classified into one of five categories,
|
|
|
76
76
|
| Category | Default shared? | Example entries |
|
|
77
77
|
|---|---|---|
|
|
78
78
|
| `secret` | **Never** — hardcoded, cannot be overridden by any configuration layer | `.credentials.json`, `backups`, `settings.json.bak*` |
|
|
79
|
-
| `runtime` | No | `daemon*`, `.git*`, `.DS_Store`, `mcp-needs-auth-cache.json`, `codex-quota.json`, `file-transfers`, `shell-snapshots`, `statsig`, `telemetry`, `stats-cache.json`, `usage-data`, `ide`, `cache`, `scheduled_tasks.lock`, `policy-limits.json*`, `remote-settings.json*`, `state` |
|
|
79
|
+
| `runtime` | No | `daemon*`, `.git*`, `.DS_Store`, `mcp-needs-auth-cache.json`, `codex-quota.json`, `file-transfers`, `bridge-spawn`, `child-logs`, `shell-snapshots`, `statsig`, `telemetry`, `stats-cache.json`, `usage-data`, `ide`, `cache`, `scheduled_tasks.lock`, `policy-limits.json*`, `remote-settings.json*`, `state` |
|
|
80
80
|
| `history` | Yes | `projects`, `sessions`, `session-env`, `teams`, `tasks`, `todos`, `history.jsonl`, `transcripts`, `paste-cache`, `file-history`, `plans`, `workflows`, `jobs`, `debug`, `downloads`, `chrome` |
|
|
81
81
|
| `knowledge` | Yes | `skills`, `output-styles`, `agents`, `rules`, `memory`, `commands`, `plugins`, `hooks`, `AGENTS.md`, `CLAUDE.md`, `README.md` |
|
|
82
82
|
| `settings` | Yes | `settings.json`, `settings.local.json` |
|
package/dist/cli.cjs
CHANGED
|
@@ -28135,6 +28135,35 @@ var init_versionDiscovery = __esm({
|
|
|
28135
28135
|
}
|
|
28136
28136
|
});
|
|
28137
28137
|
|
|
28138
|
+
// src/identityGrants.ts
|
|
28139
|
+
function canonicalFeatures(features) {
|
|
28140
|
+
return GRANT_FEATURES.filter((feature) => features.includes(feature));
|
|
28141
|
+
}
|
|
28142
|
+
function withGrant(grants, borrowerId, features) {
|
|
28143
|
+
const held = grants.find((grant) => grant.to === borrowerId)?.features ?? [];
|
|
28144
|
+
const added = { to: borrowerId, features: canonicalFeatures([...held, ...features]) };
|
|
28145
|
+
return [...grants.filter((grant) => grant.to !== borrowerId), added].sort((first, second) => first.to.localeCompare(second.to));
|
|
28146
|
+
}
|
|
28147
|
+
function withoutGrant(grants, borrowerId, features) {
|
|
28148
|
+
return grants.flatMap((grant) => {
|
|
28149
|
+
if (grant.to !== borrowerId) {
|
|
28150
|
+
return [grant];
|
|
28151
|
+
}
|
|
28152
|
+
const kept = features === void 0 ? [] : grant.features.filter((feature) => !features.includes(feature));
|
|
28153
|
+
return kept.length === 0 ? [] : [{ to: grant.to, features: kept }];
|
|
28154
|
+
});
|
|
28155
|
+
}
|
|
28156
|
+
function loginsLentTo(identities, borrowerId) {
|
|
28157
|
+
return identities.flatMap((identity) => identity.id === borrowerId ? [] : (identity.grants ?? []).filter((grant) => grant.to === borrowerId).map((grant) => ({ from: identity.name, features: grant.features })));
|
|
28158
|
+
}
|
|
28159
|
+
var GRANT_FEATURES;
|
|
28160
|
+
var init_identityGrants = __esm({
|
|
28161
|
+
"src/identityGrants.ts"() {
|
|
28162
|
+
"use strict";
|
|
28163
|
+
GRANT_FEATURES = ["remote-control", "artifacts", "connectors", "server-tools"];
|
|
28164
|
+
}
|
|
28165
|
+
});
|
|
28166
|
+
|
|
28138
28167
|
// src/config/schema.ts
|
|
28139
28168
|
function isOverridableCategory(name) {
|
|
28140
28169
|
return OVERRIDABLE_CATEGORIES.some((category) => category === name);
|
|
@@ -28173,7 +28202,7 @@ function isTimeZone(name) {
|
|
|
28173
28202
|
return false;
|
|
28174
28203
|
}
|
|
28175
28204
|
}
|
|
28176
|
-
var import_node_path5, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, TIER_MODEL_ENV_VARIABLES, OTHER_MODEL_ENV_VARIABLES, MODEL_ENV_VARIABLES, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, MAX_TIMER_DELAY_MS, HttpBaseUrlSchema, SERVER_TOOLS_MODES, HttpProviderSchema, CodexProviderSchema, RouterProviderSchema, AntigravityProviderSchema, ProviderSchema, SELECTION_MODES, VirtualModelSchema, ModelPricesSchema, FamilySettingsSchema, ModelsConfigSchema, ModelsLayerSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
|
|
28205
|
+
var import_node_path5, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, TIER_MODEL_ENV_VARIABLES, OTHER_MODEL_ENV_VARIABLES, MODEL_ENV_VARIABLES, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, MAX_TIMER_DELAY_MS, HttpBaseUrlSchema, SERVER_TOOLS_MODES, HttpProviderSchema, CodexProviderSchema, RouterProviderSchema, AntigravityProviderSchema, ProviderSchema, SELECTION_MODES, VirtualModelSchema, ModelPricesSchema, FamilySettingsSchema, ModelsConfigSchema, ModelsLayerSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentityGrantSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
|
|
28177
28206
|
var init_schema = __esm({
|
|
28178
28207
|
"src/config/schema.ts"() {
|
|
28179
28208
|
"use strict";
|
|
@@ -28186,6 +28215,7 @@ var init_schema = __esm({
|
|
|
28186
28215
|
init_identity();
|
|
28187
28216
|
init_versionDiscovery();
|
|
28188
28217
|
init_ownEntry();
|
|
28218
|
+
init_identityGrants();
|
|
28189
28219
|
CATEGORY_NAMES = ["secret", "runtime", "history", "knowledge", "settings"];
|
|
28190
28220
|
OVERRIDABLE_CATEGORIES = ["runtime", "history", "knowledge", "settings"];
|
|
28191
28221
|
CategoryMapSchema = external_exports.strictObject({
|
|
@@ -28635,6 +28665,10 @@ var init_schema = __esm({
|
|
|
28635
28665
|
models: ModelsConfigSchema.optional(),
|
|
28636
28666
|
jobs: external_exports.record(PoolNameSchema, JobSchema).optional()
|
|
28637
28667
|
});
|
|
28668
|
+
IdentityGrantSchema = external_exports.strictObject({
|
|
28669
|
+
to: FileNameSchema,
|
|
28670
|
+
features: external_exports.array(external_exports.enum(GRANT_FEATURES)).min(1)
|
|
28671
|
+
});
|
|
28638
28672
|
IdentitySchema = external_exports.strictObject({
|
|
28639
28673
|
/** The CLI this login belongs to; absent means Claude Code for backwards compatibility. */
|
|
28640
28674
|
agent: external_exports.enum(["claude", "codex"]).optional(),
|
|
@@ -28647,6 +28681,8 @@ var init_schema = __esm({
|
|
|
28647
28681
|
provider: StoredNameSchema.optional(),
|
|
28648
28682
|
allowAmbientCredential: external_exports.boolean().default(false),
|
|
28649
28683
|
credential: CredentialSchema.optional(),
|
|
28684
|
+
/** Which other identities may use this identity's claude.ai login, and for what (`identity grant`). Absent: none may. */
|
|
28685
|
+
grants: external_exports.array(IdentityGrantSchema).min(1).optional(),
|
|
28650
28686
|
/** When this identity's five-hour window should be open: the front door opens one at each anchor if none is. Absent, nothing is opened on a schedule. */
|
|
28651
28687
|
anchors: external_exports.array(AnchorSchema).min(1).optional()
|
|
28652
28688
|
});
|
|
@@ -34325,6 +34361,8 @@ var init_categories_default = __esm({
|
|
|
34325
34361
|
"mcp-needs-auth-cache.json",
|
|
34326
34362
|
"codex-quota.json",
|
|
34327
34363
|
"file-transfers",
|
|
34364
|
+
"bridge-spawn",
|
|
34365
|
+
"child-logs",
|
|
34328
34366
|
"shell-snapshots",
|
|
34329
34367
|
"statsig",
|
|
34330
34368
|
"telemetry",
|
|
@@ -40016,6 +40054,35 @@ function setAllowAmbientCredential(paths, identityName, allow) {
|
|
|
40016
40054
|
allowAmbientCredential: allow
|
|
40017
40055
|
});
|
|
40018
40056
|
}
|
|
40057
|
+
function changeIdentityGrants(paths, parties, change, namesLock) {
|
|
40058
|
+
return withIdentityNamesLock(paths, namesLock, () => {
|
|
40059
|
+
const lenderId = requireStoredIdentityId(paths, parties.lender);
|
|
40060
|
+
const borrowerId = requireStoredIdentityId(paths, parties.borrower);
|
|
40061
|
+
if (lenderId === borrowerId) {
|
|
40062
|
+
throw new UsageError(`Identity "${parties.lender}" already uses its own login, so there is nothing to grant to itself.`);
|
|
40063
|
+
}
|
|
40064
|
+
const lender = readIdentityById(paths, lenderId);
|
|
40065
|
+
const borrower = readIdentityById(paths, borrowerId);
|
|
40066
|
+
if (lender === void 0) {
|
|
40067
|
+
throw identityNotFound(paths, parties.lender);
|
|
40068
|
+
}
|
|
40069
|
+
for (const identity of [lender, borrower]) {
|
|
40070
|
+
if (identity?.agent === "codex") {
|
|
40071
|
+
throw new UsageError(`Identity "${identity.name}" runs Codex, which has no claude.ai login to lend or borrow.`);
|
|
40072
|
+
}
|
|
40073
|
+
}
|
|
40074
|
+
return writeIdentityGrants(paths, lenderId, change(lender.grants ?? [], borrowerId));
|
|
40075
|
+
});
|
|
40076
|
+
}
|
|
40077
|
+
function writeIdentityGrants(paths, id2, grants) {
|
|
40078
|
+
return applyPatch(identityJsonPath(paths, id2), IdentitySchema, { grants: grants.length === 0 ? void 0 : grants.map((grant) => ({ to: grant.to, features: [...grant.features] })) });
|
|
40079
|
+
}
|
|
40080
|
+
function grantIdentityLogin(paths, parties, features, namesLock = realIdentityNamesLockPorts) {
|
|
40081
|
+
return changeIdentityGrants(paths, parties, (grants, borrowerId) => withGrant(grants, borrowerId, features), namesLock);
|
|
40082
|
+
}
|
|
40083
|
+
function revokeIdentityLogin(paths, parties, features, namesLock = realIdentityNamesLockPorts) {
|
|
40084
|
+
return changeIdentityGrants(paths, parties, (grants, borrowerId) => withoutGrant(grants, borrowerId, features), namesLock);
|
|
40085
|
+
}
|
|
40019
40086
|
function setIdentityCredential(paths, identityName, change) {
|
|
40020
40087
|
const id2 = requireStoredIdentityId(paths, identityName);
|
|
40021
40088
|
const existing = readIdentityById(paths, id2);
|
|
@@ -40101,6 +40168,11 @@ function removeIdentityWithLockHeld(paths, name, namesLock) {
|
|
|
40101
40168
|
if (readActiveIdentity2(paths) === name) {
|
|
40102
40169
|
import_node_fs12.default.rmSync(paths.activeIdentityFile);
|
|
40103
40170
|
}
|
|
40171
|
+
for (const listing of listIdentities(paths)) {
|
|
40172
|
+
if (listing.problem === void 0 && listing.identity.grants?.some((grant) => grant.to === id2) === true) {
|
|
40173
|
+
writeIdentityGrants(paths, listing.id, withoutGrant(listing.identity.grants, id2, void 0));
|
|
40174
|
+
}
|
|
40175
|
+
}
|
|
40104
40176
|
return id2;
|
|
40105
40177
|
} finally {
|
|
40106
40178
|
resync.release();
|
|
@@ -40132,6 +40204,7 @@ var init_identityStore = __esm({
|
|
|
40132
40204
|
init_sameDirectory();
|
|
40133
40205
|
init_identityRecords();
|
|
40134
40206
|
init_launchRecords();
|
|
40207
|
+
init_identityGrants();
|
|
40135
40208
|
IdentityNotFoundError = class extends CliError {
|
|
40136
40209
|
constructor(name, remedy2 = `Run \`agent-shim identity add ${name}\` first.`) {
|
|
40137
40210
|
super(`No identity named "${name}". ${remedy2}`);
|
|
@@ -76444,7 +76517,7 @@ var init_package = __esm({
|
|
|
76444
76517
|
"package.json"() {
|
|
76445
76518
|
package_default = {
|
|
76446
76519
|
name: "agent-shim",
|
|
76447
|
-
version: "14.
|
|
76520
|
+
version: "14.13.0",
|
|
76448
76521
|
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.",
|
|
76449
76522
|
license: "MIT",
|
|
76450
76523
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -129078,6 +129151,7 @@ init_schema();
|
|
|
129078
129151
|
init_baseUrlDisplay();
|
|
129079
129152
|
init_providerReachability();
|
|
129080
129153
|
init_identityStore();
|
|
129154
|
+
init_identityGrants();
|
|
129081
129155
|
init_credential();
|
|
129082
129156
|
init_claudeVersion();
|
|
129083
129157
|
init_credentialCache();
|
|
@@ -129273,6 +129347,7 @@ function runCheck(params) {
|
|
|
129273
129347
|
return {
|
|
129274
129348
|
...params.identityName === void 0 ? {} : { identityName: params.identityName },
|
|
129275
129349
|
identitySource: params.identitySource,
|
|
129350
|
+
...params.borrowedLogins === void 0 || params.borrowedLogins.length === 0 ? {} : { borrowedLogins: params.borrowedLogins },
|
|
129276
129351
|
...params.poolPick === void 0 ? {} : { poolPick: params.poolPick },
|
|
129277
129352
|
...params.configProfileName === void 0 ? {} : { configProfileName: params.configProfileName },
|
|
129278
129353
|
configProfileSource: params.configProfileSource,
|
|
@@ -129299,6 +129374,9 @@ function buildProviderReachability(provider, probe) {
|
|
|
129299
129374
|
function formatCheckReport(report) {
|
|
129300
129375
|
const lines = [];
|
|
129301
129376
|
lines.push(`Identity: ${report.identityName ?? "(none)"} (${report.identitySource})`);
|
|
129377
|
+
for (const loan of report.borrowedLogins ?? []) {
|
|
129378
|
+
lines.push(`Borrows the login of ${loan.from} for ${loan.features.join(", ")}.`);
|
|
129379
|
+
}
|
|
129302
129380
|
if (report.poolPick !== void 0) {
|
|
129303
129381
|
const top = report.poolPick.candidates.find((candidate) => candidate.identity === report.poolPick?.pick);
|
|
129304
129382
|
lines.push(`Pool: ${report.poolPick.pool}${top === void 0 ? ", every member is refused right now" : `, would pick ${top.identity} (${top.reasons.join("; ")})`}`);
|
|
@@ -129393,6 +129471,7 @@ function checkReportToJson(report) {
|
|
|
129393
129471
|
const decisions = [...report.resolved.decisions.values()].sort((a10, b) => a10.relPath < b.relPath ? -1 : a10.relPath > b.relPath ? 1 : 0);
|
|
129394
129472
|
return {
|
|
129395
129473
|
identity: { name: report.identityName ?? null, source: report.identitySource },
|
|
129474
|
+
...report.borrowedLogins === void 0 ? {} : { borrowedLogins: report.borrowedLogins },
|
|
129396
129475
|
...report.poolPick === void 0 ? {} : { pool: report.poolPick },
|
|
129397
129476
|
configProfile: { name: report.configProfileName ?? null, source: report.configProfileSource },
|
|
129398
129477
|
layers: report.resolved.assembled.layers.map((layer) => ({ id: layer.id, kind: layer.kind, source: layer.source })),
|
|
@@ -129473,6 +129552,7 @@ function collectCheckReport(params) {
|
|
|
129473
129552
|
...identityDecision.name === void 0 ? {} : { identityName: identityDecision.name },
|
|
129474
129553
|
...identityId === void 0 ? {} : { identityId },
|
|
129475
129554
|
identitySource: identityDecision.source,
|
|
129555
|
+
...identityId === void 0 ? {} : { borrowedLogins: loginsLentTo(listIdentities(paths).flatMap((entry) => entry.problem === void 0 ? [{ id: entry.id, name: entry.name, grants: entry.identity.grants }] : []), identityId) },
|
|
129476
129556
|
...poolPick === void 0 ? {} : { poolPick },
|
|
129477
129557
|
...configProfileDecision.name === void 0 ? {} : { configProfileName: configProfileDecision.name },
|
|
129478
129558
|
configProfileSource: configProfileDecision.source,
|
|
@@ -131872,11 +131952,20 @@ function runDoctor(params) {
|
|
|
131872
131952
|
`${entry.name} is valid and authenticates with ${authenticatesWith}${cache.text}.`,
|
|
131873
131953
|
entry.name
|
|
131874
131954
|
);
|
|
131955
|
+
const keychainItem = params.platform === "darwin" && params.run !== void 0 ? keychainHasItem(params.run, entry.farmRoot) : void 0;
|
|
131956
|
+
for (const grant of validated3.data.grants ?? []) {
|
|
131957
|
+
if (!identityIds.has(grant.to)) {
|
|
131958
|
+
push("identity", "warn", `${entry.name} lends its login to identity id "${grant.to}", which does not exist. Remove that entry from its identity.json.`, entry.name);
|
|
131959
|
+
}
|
|
131960
|
+
}
|
|
131961
|
+
if (validated3.data.grants !== void 0 && keychainItem !== true && !entry.credentialsFilePresent) {
|
|
131962
|
+
push("sign-in", "warn", `${entry.name} lends its login but has none stored, so every borrowed request fails. Run \`agent-shim run @${entry.name}\` and sign in.`, entry.name);
|
|
131963
|
+
}
|
|
131875
131964
|
const standing = credential !== void 0 ? "uses a credential block" : identityProvider !== void 0 ? `exists for provider "${identityProvider}"` : "is signed in";
|
|
131876
131965
|
const signIn = decideSignIn({
|
|
131877
131966
|
hasCredentialBlock: credential !== void 0,
|
|
131878
131967
|
provider: identityProvider,
|
|
131879
|
-
keychainItem
|
|
131968
|
+
keychainItem,
|
|
131880
131969
|
credentialsFile: entry.credentialsFilePresent,
|
|
131881
131970
|
platform: params.platform
|
|
131882
131971
|
});
|
|
@@ -132451,6 +132540,7 @@ function cacheChange(options, existing) {
|
|
|
132451
132540
|
|
|
132452
132541
|
// src/cli/parsers.ts
|
|
132453
132542
|
init_schema();
|
|
132543
|
+
init_identityGrants();
|
|
132454
132544
|
|
|
132455
132545
|
// src/usage/anchor.ts
|
|
132456
132546
|
init_schema();
|
|
@@ -132578,6 +132668,15 @@ function collectRepeated(value3, previous = []) {
|
|
|
132578
132668
|
function collectAnchor(value3, previous = []) {
|
|
132579
132669
|
return [...previous, asInvalidArgument(() => parseAnchor(value3))];
|
|
132580
132670
|
}
|
|
132671
|
+
function collectGrantFeature(value3, previous = []) {
|
|
132672
|
+
return [...previous, asInvalidArgument(() => {
|
|
132673
|
+
const feature = GRANT_FEATURES.find((candidate) => candidate === value3);
|
|
132674
|
+
if (feature === void 0) {
|
|
132675
|
+
throw new Error(`"${value3}" is not one of ${GRANT_FEATURES.join(", ")}`);
|
|
132676
|
+
}
|
|
132677
|
+
return feature;
|
|
132678
|
+
})];
|
|
132679
|
+
}
|
|
132581
132680
|
function parseUtilisationPercent(value3) {
|
|
132582
132681
|
return asInvalidArgument(() => {
|
|
132583
132682
|
const percent2 = CompactAtUtilisationSchema.safeParse(Number(value3));
|
|
@@ -132598,6 +132697,7 @@ function parseDurationOption(value3) {
|
|
|
132598
132697
|
}
|
|
132599
132698
|
|
|
132600
132699
|
// src/identityManager.ts
|
|
132700
|
+
init_identityGrants();
|
|
132601
132701
|
init_classify();
|
|
132602
132702
|
init_schema();
|
|
132603
132703
|
init_credential();
|
|
@@ -132613,7 +132713,8 @@ function identityWriteView(identity) {
|
|
|
132613
132713
|
...identity.provider === void 0 ? {} : { provider: identity.provider },
|
|
132614
132714
|
allowAmbientCredential: identity.allowAmbientCredential,
|
|
132615
132715
|
...identity.credential === void 0 ? {} : { credential: summariseCredential(identity.credential) },
|
|
132616
|
-
...identity.anchors === void 0 ? {} : { anchors: identity.anchors }
|
|
132716
|
+
...identity.anchors === void 0 ? {} : { anchors: identity.anchors },
|
|
132717
|
+
...identity.grants === void 0 ? {} : { grants: identity.grants }
|
|
132617
132718
|
};
|
|
132618
132719
|
}
|
|
132619
132720
|
|
|
@@ -134314,6 +134415,7 @@ async function tryRunAtIdentityShortcut(deps, argv, keychain) {
|
|
|
134314
134415
|
return true;
|
|
134315
134416
|
}
|
|
134316
134417
|
function toIdentityView(paths, { entry, read }, sharesLoginWith) {
|
|
134418
|
+
const nameOf2 = identityLabeller(paths);
|
|
134317
134419
|
const account = read?.account === void 0 ? void 0 : summariseIdentityAccount(read.account);
|
|
134318
134420
|
return {
|
|
134319
134421
|
name: entry.name,
|
|
@@ -134327,7 +134429,8 @@ function toIdentityView(paths, { entry, read }, sharesLoginWith) {
|
|
|
134327
134429
|
...entry.identity.provider === void 0 ? {} : { provider: entry.identity.provider },
|
|
134328
134430
|
allowAmbientCredential: entry.identity.allowAmbientCredential,
|
|
134329
134431
|
...entry.identity.credential === void 0 ? {} : { credential: summariseCredential(entry.identity.credential) },
|
|
134330
|
-
...entry.identity.anchors === void 0 ? {} : { anchors: entry.identity.anchors }
|
|
134432
|
+
...entry.identity.anchors === void 0 ? {} : { anchors: entry.identity.anchors },
|
|
134433
|
+
...entry.identity.grants === void 0 ? {} : { grants: entry.identity.grants.map((grant) => ({ to: nameOf2(grant.to), features: grant.features })) }
|
|
134331
134434
|
} : { problem: entry.problem, ...entry.displaced === void 0 ? {} : { displaced: entry.displaced } },
|
|
134332
134435
|
...account === void 0 ? {} : { account },
|
|
134333
134436
|
...read?.problem === void 0 ? {} : { accountProblem: read.problem },
|
|
@@ -134356,7 +134459,8 @@ function formatIdentityLine(entry, view, shared) {
|
|
|
134356
134459
|
const provider = entry.identity.provider === void 0 ? "" : ` (provider: ${entry.identity.provider})`;
|
|
134357
134460
|
const ambient = entry.identity.allowAmbientCredential ? " [allows ambient credential]" : "";
|
|
134358
134461
|
const credential = entry.identity.credential === void 0 ? "" : ` [credential ${describeCredential(entry.identity.credential)}]`;
|
|
134359
|
-
|
|
134462
|
+
const grants = (view.grants ?? []).map((grant) => ` [lends to ${grant.to}: ${grant.features.join(", ")}]`).join("");
|
|
134463
|
+
return `${marker}${named}${entry.identity.agent === "codex" ? " [codex]" : ""}${label2}${defaultProfile}${provider}${ambient}${credential}${grants}${account}${accountProblem}`;
|
|
134360
134464
|
}
|
|
134361
134465
|
var RENAME_DESCRIPTION = "Rename an identity: change its name and rewrite every reference to it. Its directory, login and usage stay where they are, so it goes ahead while sessions run on it. A rename that was interrupted is finished by running the same command again.";
|
|
134362
134466
|
var MOVE_DESCRIPTION = "Also move the identity's directory to the new name and carry its login across. Only for an identity whose directory has its name; refused while a session is running on it or a launch is starting on it. One that was interrupted is finished by running the same command again.";
|
|
@@ -134544,6 +134648,24 @@ Run \`agent-shim doctor\` for the full detail on every ${kinds.join(" or ")} ent
|
|
|
134544
134648
|
"agent-shim identity set work --no-anchor"
|
|
134545
134649
|
]
|
|
134546
134650
|
);
|
|
134651
|
+
withExamples(
|
|
134652
|
+
identity.command("grant <lender>").description("Let another identity's sessions use this identity's claude.ai login for the named features, through the front door. Nothing is lent until granted.").requiredOption("--to <borrower>", "The identity whose sessions may use the login.").requiredOption("--feature <feature>", `What the login may be used for (repeatable): ${GRANT_FEATURES.join(", ")}.`, collectGrantFeature).option("--json", "Print the result as JSON.").action((lender, options) => {
|
|
134653
|
+
const updated = grantIdentityLogin(paths, { lender, borrower: options.to }, options.feature);
|
|
134654
|
+
reportMutation(options.json, { action: "updated", kind: "identity", name: lender, value: identityWriteView(updated) }, () => {
|
|
134655
|
+
console.log(`Identity "${options.to}" may now use the login of "${lender}" for ${options.feature.join(", ")}.`);
|
|
134656
|
+
});
|
|
134657
|
+
}),
|
|
134658
|
+
["agent-shim identity grant personal --to work --feature artifacts --feature connectors"]
|
|
134659
|
+
);
|
|
134660
|
+
withExamples(
|
|
134661
|
+
identity.command("revoke <lender>").description("Stop another identity's sessions using this identity's claude.ai login, for the named features or for everything.").requiredOption("--to <borrower>", "The identity whose grant is taken back.").option("--feature <feature>", `What to stop (repeatable; everything when absent): ${GRANT_FEATURES.join(", ")}.`, collectGrantFeature).option("--json", "Print the result as JSON.").action((lender, options) => {
|
|
134662
|
+
const updated = revokeIdentityLogin(paths, { lender, borrower: options.to }, options.feature);
|
|
134663
|
+
reportMutation(options.json, { action: "updated", kind: "identity", name: lender, value: identityWriteView(updated) }, () => {
|
|
134664
|
+
console.log(`Identity "${options.to}" may no longer use the login of "${lender}" for ${options.feature === void 0 ? "anything" : options.feature.join(", ")}.`);
|
|
134665
|
+
});
|
|
134666
|
+
}),
|
|
134667
|
+
["agent-shim identity revoke personal --to work --feature connectors", "agent-shim identity revoke personal --to work"]
|
|
134668
|
+
);
|
|
134547
134669
|
withExamples(
|
|
134548
134670
|
identity.command("remove <name>").description(
|
|
134549
134671
|
`Delete an identity and its directory, including its credentials and anything it does not share with ~/.claude, and ${REMOVED_STATE}. Shared data in ~/.claude is kept.`
|
|
@@ -136454,6 +136576,7 @@ var PoolPickReportSchema = external_exports.strictObject({
|
|
|
136454
136576
|
});
|
|
136455
136577
|
|
|
136456
136578
|
// src/checkReportSchema.ts
|
|
136579
|
+
init_identityGrants();
|
|
136457
136580
|
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
136458
136581
|
var CheckLayerViewSchema = external_exports.strictObject({
|
|
136459
136582
|
id: external_exports.int(),
|
|
@@ -136529,6 +136652,8 @@ var CheckClaudeVersionSchema = external_exports.strictObject({
|
|
|
136529
136652
|
});
|
|
136530
136653
|
var CheckReportJsonSchema = external_exports.strictObject({
|
|
136531
136654
|
identity: external_exports.strictObject({ name: external_exports.string().nullable(), source: external_exports.enum(IDENTITY_DECISION_SOURCES) }),
|
|
136655
|
+
/** The logins other identities lend this one through the front door; absent when none does. */
|
|
136656
|
+
borrowedLogins: external_exports.readonly(external_exports.array(external_exports.strictObject({ from: external_exports.string(), features: external_exports.readonly(external_exports.array(external_exports.enum(GRANT_FEATURES))) }))).optional(),
|
|
136532
136657
|
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
136533
136658
|
pool: PoolPickReportSchema.optional(),
|
|
136534
136659
|
configProfile: external_exports.strictObject({ name: external_exports.string().nullable(), source: external_exports.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
@@ -147775,7 +147900,9 @@ var IdentityValueSchema = external_exports.strictObject({
|
|
|
147775
147900
|
provider: external_exports.string().optional(),
|
|
147776
147901
|
allowAmbientCredential: external_exports.boolean(),
|
|
147777
147902
|
credential: CredentialSummarySchema2.optional(),
|
|
147778
|
-
anchors: external_exports.array(AnchorSchema).optional()
|
|
147903
|
+
anchors: external_exports.array(AnchorSchema).optional(),
|
|
147904
|
+
/** Read only here: a grant is made and revoked from the command line alone, so a program driving the door cannot widen what it may reach. */
|
|
147905
|
+
grants: external_exports.array(IdentityGrantSchema).optional()
|
|
147779
147906
|
});
|
|
147780
147907
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
147781
147908
|
var ProviderValueSchema = external_exports.strictObject({
|
package/dist/index.cjs
CHANGED
|
@@ -49,6 +49,8 @@ var init_categories_default = __esm({
|
|
|
49
49
|
"mcp-needs-auth-cache.json",
|
|
50
50
|
"codex-quota.json",
|
|
51
51
|
"file-transfers",
|
|
52
|
+
"bridge-spawn",
|
|
53
|
+
"child-logs",
|
|
52
54
|
"shell-snapshots",
|
|
53
55
|
"statsig",
|
|
54
56
|
"telemetry",
|
|
@@ -924,6 +926,35 @@ var init_versionDiscovery = __esm({
|
|
|
924
926
|
}
|
|
925
927
|
});
|
|
926
928
|
|
|
929
|
+
// src/identityGrants.ts
|
|
930
|
+
function canonicalFeatures(features) {
|
|
931
|
+
return GRANT_FEATURES.filter((feature) => features.includes(feature));
|
|
932
|
+
}
|
|
933
|
+
function withGrant(grants, borrowerId, features) {
|
|
934
|
+
const held = grants.find((grant) => grant.to === borrowerId)?.features ?? [];
|
|
935
|
+
const added = { to: borrowerId, features: canonicalFeatures([...held, ...features]) };
|
|
936
|
+
return [...grants.filter((grant) => grant.to !== borrowerId), added].sort((first, second) => first.to.localeCompare(second.to));
|
|
937
|
+
}
|
|
938
|
+
function withoutGrant(grants, borrowerId, features) {
|
|
939
|
+
return grants.flatMap((grant) => {
|
|
940
|
+
if (grant.to !== borrowerId) {
|
|
941
|
+
return [grant];
|
|
942
|
+
}
|
|
943
|
+
const kept = features === void 0 ? [] : grant.features.filter((feature) => !features.includes(feature));
|
|
944
|
+
return kept.length === 0 ? [] : [{ to: grant.to, features: kept }];
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
function loginsLentTo(identities, borrowerId) {
|
|
948
|
+
return identities.flatMap((identity) => identity.id === borrowerId ? [] : (identity.grants ?? []).filter((grant) => grant.to === borrowerId).map((grant) => ({ from: identity.name, features: grant.features })));
|
|
949
|
+
}
|
|
950
|
+
var GRANT_FEATURES;
|
|
951
|
+
var init_identityGrants = __esm({
|
|
952
|
+
"src/identityGrants.ts"() {
|
|
953
|
+
"use strict";
|
|
954
|
+
GRANT_FEATURES = ["remote-control", "artifacts", "connectors", "server-tools"];
|
|
955
|
+
}
|
|
956
|
+
});
|
|
957
|
+
|
|
927
958
|
// src/config/schema.ts
|
|
928
959
|
function isOverridableCategory(name) {
|
|
929
960
|
return OVERRIDABLE_CATEGORIES.some((category) => category === name);
|
|
@@ -962,7 +993,7 @@ function isTimeZone(name) {
|
|
|
962
993
|
return false;
|
|
963
994
|
}
|
|
964
995
|
}
|
|
965
|
-
var import_node_path3, import_zod3, import_trilean, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, TIER_MODEL_ENV_VARIABLES, OTHER_MODEL_ENV_VARIABLES, MODEL_ENV_VARIABLES, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, MAX_TIMER_DELAY_MS, HttpBaseUrlSchema, SERVER_TOOLS_MODES, HttpProviderSchema, CodexProviderSchema, RouterProviderSchema, AntigravityProviderSchema, ProviderSchema, SELECTION_MODES, VirtualModelSchema, ModelPricesSchema, FamilySettingsSchema, ModelsConfigSchema, ModelsLayerSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
|
|
996
|
+
var import_node_path3, import_zod3, import_trilean, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, TIER_MODEL_ENV_VARIABLES, OTHER_MODEL_ENV_VARIABLES, MODEL_ENV_VARIABLES, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, MAX_TIMER_DELAY_MS, HttpBaseUrlSchema, SERVER_TOOLS_MODES, HttpProviderSchema, CodexProviderSchema, RouterProviderSchema, AntigravityProviderSchema, ProviderSchema, SELECTION_MODES, VirtualModelSchema, ModelPricesSchema, FamilySettingsSchema, ModelsConfigSchema, ModelsLayerSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentityGrantSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
|
|
966
997
|
var init_schema = __esm({
|
|
967
998
|
"src/config/schema.ts"() {
|
|
968
999
|
"use strict";
|
|
@@ -975,6 +1006,7 @@ var init_schema = __esm({
|
|
|
975
1006
|
init_identity();
|
|
976
1007
|
init_versionDiscovery();
|
|
977
1008
|
init_ownEntry();
|
|
1009
|
+
init_identityGrants();
|
|
978
1010
|
CATEGORY_NAMES = ["secret", "runtime", "history", "knowledge", "settings"];
|
|
979
1011
|
OVERRIDABLE_CATEGORIES = ["runtime", "history", "knowledge", "settings"];
|
|
980
1012
|
CategoryMapSchema = import_zod3.z.strictObject({
|
|
@@ -1423,6 +1455,10 @@ var init_schema = __esm({
|
|
|
1423
1455
|
models: ModelsConfigSchema.optional(),
|
|
1424
1456
|
jobs: import_zod3.z.record(PoolNameSchema, JobSchema).optional()
|
|
1425
1457
|
});
|
|
1458
|
+
IdentityGrantSchema = import_zod3.z.strictObject({
|
|
1459
|
+
to: FileNameSchema,
|
|
1460
|
+
features: import_zod3.z.array(import_zod3.z.enum(GRANT_FEATURES)).min(1)
|
|
1461
|
+
});
|
|
1426
1462
|
IdentitySchema = import_zod3.z.strictObject({
|
|
1427
1463
|
/** The CLI this login belongs to; absent means Claude Code for backwards compatibility. */
|
|
1428
1464
|
agent: import_zod3.z.enum(["claude", "codex"]).optional(),
|
|
@@ -1435,6 +1471,8 @@ var init_schema = __esm({
|
|
|
1435
1471
|
provider: StoredNameSchema.optional(),
|
|
1436
1472
|
allowAmbientCredential: import_zod3.z.boolean().default(false),
|
|
1437
1473
|
credential: CredentialSchema.optional(),
|
|
1474
|
+
/** Which other identities may use this identity's claude.ai login, and for what (`identity grant`). Absent: none may. */
|
|
1475
|
+
grants: import_zod3.z.array(IdentityGrantSchema).min(1).optional(),
|
|
1438
1476
|
/** When this identity's five-hour window should be open: the front door opens one at each anchor if none is. Absent, nothing is opened on a schedule. */
|
|
1439
1477
|
anchors: import_zod3.z.array(AnchorSchema).min(1).optional()
|
|
1440
1478
|
});
|
|
@@ -15037,6 +15075,35 @@ function setAllowAmbientCredential(paths, identityName, allow) {
|
|
|
15037
15075
|
allowAmbientCredential: allow
|
|
15038
15076
|
});
|
|
15039
15077
|
}
|
|
15078
|
+
function changeIdentityGrants(paths, parties, change, namesLock) {
|
|
15079
|
+
return withIdentityNamesLock(paths, namesLock, () => {
|
|
15080
|
+
const lenderId = requireStoredIdentityId(paths, parties.lender);
|
|
15081
|
+
const borrowerId = requireStoredIdentityId(paths, parties.borrower);
|
|
15082
|
+
if (lenderId === borrowerId) {
|
|
15083
|
+
throw new UsageError(`Identity "${parties.lender}" already uses its own login, so there is nothing to grant to itself.`);
|
|
15084
|
+
}
|
|
15085
|
+
const lender = readIdentityById(paths, lenderId);
|
|
15086
|
+
const borrower = readIdentityById(paths, borrowerId);
|
|
15087
|
+
if (lender === void 0) {
|
|
15088
|
+
throw identityNotFound(paths, parties.lender);
|
|
15089
|
+
}
|
|
15090
|
+
for (const identity of [lender, borrower]) {
|
|
15091
|
+
if (identity?.agent === "codex") {
|
|
15092
|
+
throw new UsageError(`Identity "${identity.name}" runs Codex, which has no claude.ai login to lend or borrow.`);
|
|
15093
|
+
}
|
|
15094
|
+
}
|
|
15095
|
+
return writeIdentityGrants(paths, lenderId, change(lender.grants ?? [], borrowerId));
|
|
15096
|
+
});
|
|
15097
|
+
}
|
|
15098
|
+
function writeIdentityGrants(paths, id, grants) {
|
|
15099
|
+
return applyPatch(identityJsonPath(paths, id), IdentitySchema, { grants: grants.length === 0 ? void 0 : grants.map((grant) => ({ to: grant.to, features: [...grant.features] })) });
|
|
15100
|
+
}
|
|
15101
|
+
function grantIdentityLogin(paths, parties, features, namesLock = realIdentityNamesLockPorts) {
|
|
15102
|
+
return changeIdentityGrants(paths, parties, (grants, borrowerId) => withGrant(grants, borrowerId, features), namesLock);
|
|
15103
|
+
}
|
|
15104
|
+
function revokeIdentityLogin(paths, parties, features, namesLock = realIdentityNamesLockPorts) {
|
|
15105
|
+
return changeIdentityGrants(paths, parties, (grants, borrowerId) => withoutGrant(grants, borrowerId, features), namesLock);
|
|
15106
|
+
}
|
|
15040
15107
|
function setIdentityCredential(paths, identityName, change) {
|
|
15041
15108
|
const id = requireStoredIdentityId(paths, identityName);
|
|
15042
15109
|
const existing = readIdentityById(paths, id);
|
|
@@ -15119,6 +15186,11 @@ function removeIdentityWithLockHeld(paths, name, namesLock) {
|
|
|
15119
15186
|
if (readActiveIdentity2(paths) === name) {
|
|
15120
15187
|
import_node_fs9.default.rmSync(paths.activeIdentityFile);
|
|
15121
15188
|
}
|
|
15189
|
+
for (const listing of listIdentities(paths)) {
|
|
15190
|
+
if (listing.problem === void 0 && listing.identity.grants?.some((grant) => grant.to === id) === true) {
|
|
15191
|
+
writeIdentityGrants(paths, listing.id, withoutGrant(listing.identity.grants, id, void 0));
|
|
15192
|
+
}
|
|
15193
|
+
}
|
|
15122
15194
|
return id;
|
|
15123
15195
|
} finally {
|
|
15124
15196
|
resync.release();
|
|
@@ -15150,6 +15222,7 @@ var init_identityStore = __esm({
|
|
|
15150
15222
|
init_sameDirectory();
|
|
15151
15223
|
init_identityRecords();
|
|
15152
15224
|
init_launchRecords();
|
|
15225
|
+
init_identityGrants();
|
|
15153
15226
|
IdentityNotFoundError = class extends CliError {
|
|
15154
15227
|
constructor(name, remedy2 = `Run \`agent-shim identity add ${name}\` first.`) {
|
|
15155
15228
|
super(`No identity named "${name}". ${remedy2}`);
|
|
@@ -15210,7 +15283,7 @@ var init_package = __esm({
|
|
|
15210
15283
|
"package.json"() {
|
|
15211
15284
|
package_default = {
|
|
15212
15285
|
name: "agent-shim",
|
|
15213
|
-
version: "14.
|
|
15286
|
+
version: "14.13.0",
|
|
15214
15287
|
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.",
|
|
15215
15288
|
license: "MIT",
|
|
15216
15289
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -20749,6 +20822,7 @@ __export(index_exports, {
|
|
|
20749
20822
|
getRcSessionContextUsage: () => getRcSessionContextUsage,
|
|
20750
20823
|
getRcSessionMcpStatus: () => getRcSessionMcpStatus,
|
|
20751
20824
|
getRcSessionUsage: () => getRcSessionUsage,
|
|
20825
|
+
grantIdentityLogin: () => grantIdentityLogin,
|
|
20752
20826
|
headroomSocketTarget: () => headroomSocketTarget,
|
|
20753
20827
|
identityExists: () => identityExists,
|
|
20754
20828
|
identityIdOf: () => identityIdOf,
|
|
@@ -20844,6 +20918,7 @@ __export(index_exports, {
|
|
|
20844
20918
|
resolveLayoutPaths: () => resolveLayoutPaths,
|
|
20845
20919
|
resolveSupervisorConfig: () => resolveSupervisorConfig,
|
|
20846
20920
|
resyncFarm: () => resyncFarm,
|
|
20921
|
+
revokeIdentityLogin: () => revokeIdentityLogin,
|
|
20847
20922
|
runCheck: () => runCheck,
|
|
20848
20923
|
runClaudeLaunch: () => runClaudeLaunch,
|
|
20849
20924
|
runDoctor: () => runDoctor,
|
|
@@ -22250,6 +22325,7 @@ var PoolPickReportSchema = import_zod28.z.strictObject({
|
|
|
22250
22325
|
});
|
|
22251
22326
|
|
|
22252
22327
|
// src/checkReportSchema.ts
|
|
22328
|
+
init_identityGrants();
|
|
22253
22329
|
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
22254
22330
|
var CheckLayerViewSchema = import_zod29.z.strictObject({
|
|
22255
22331
|
id: import_zod29.z.int(),
|
|
@@ -22325,6 +22401,8 @@ var CheckClaudeVersionSchema = import_zod29.z.strictObject({
|
|
|
22325
22401
|
});
|
|
22326
22402
|
var CheckReportJsonSchema = import_zod29.z.strictObject({
|
|
22327
22403
|
identity: import_zod29.z.strictObject({ name: import_zod29.z.string().nullable(), source: import_zod29.z.enum(IDENTITY_DECISION_SOURCES) }),
|
|
22404
|
+
/** The logins other identities lend this one through the front door; absent when none does. */
|
|
22405
|
+
borrowedLogins: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.strictObject({ from: import_zod29.z.string(), features: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.enum(GRANT_FEATURES))) }))).optional(),
|
|
22328
22406
|
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
22329
22407
|
pool: PoolPickReportSchema.optional(),
|
|
22330
22408
|
configProfile: import_zod29.z.strictObject({ name: import_zod29.z.string().nullable(), source: import_zod29.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
@@ -22677,6 +22755,7 @@ init_schema();
|
|
|
22677
22755
|
init_baseUrlDisplay();
|
|
22678
22756
|
init_providerReachability();
|
|
22679
22757
|
init_identityStore();
|
|
22758
|
+
init_identityGrants();
|
|
22680
22759
|
init_credential();
|
|
22681
22760
|
init_claudeVersion();
|
|
22682
22761
|
init_credentialCache();
|
|
@@ -22872,6 +22951,7 @@ function runCheck(params) {
|
|
|
22872
22951
|
return {
|
|
22873
22952
|
...params.identityName === void 0 ? {} : { identityName: params.identityName },
|
|
22874
22953
|
identitySource: params.identitySource,
|
|
22954
|
+
...params.borrowedLogins === void 0 || params.borrowedLogins.length === 0 ? {} : { borrowedLogins: params.borrowedLogins },
|
|
22875
22955
|
...params.poolPick === void 0 ? {} : { poolPick: params.poolPick },
|
|
22876
22956
|
...params.configProfileName === void 0 ? {} : { configProfileName: params.configProfileName },
|
|
22877
22957
|
configProfileSource: params.configProfileSource,
|
|
@@ -22898,6 +22978,9 @@ function buildProviderReachability(provider, probe) {
|
|
|
22898
22978
|
function formatCheckReport(report) {
|
|
22899
22979
|
const lines = [];
|
|
22900
22980
|
lines.push(`Identity: ${report.identityName ?? "(none)"} (${report.identitySource})`);
|
|
22981
|
+
for (const loan of report.borrowedLogins ?? []) {
|
|
22982
|
+
lines.push(`Borrows the login of ${loan.from} for ${loan.features.join(", ")}.`);
|
|
22983
|
+
}
|
|
22901
22984
|
if (report.poolPick !== void 0) {
|
|
22902
22985
|
const top = report.poolPick.candidates.find((candidate) => candidate.identity === report.poolPick?.pick);
|
|
22903
22986
|
lines.push(`Pool: ${report.poolPick.pool}${top === void 0 ? ", every member is refused right now" : `, would pick ${top.identity} (${top.reasons.join("; ")})`}`);
|
|
@@ -22992,6 +23075,7 @@ function checkReportToJson(report) {
|
|
|
22992
23075
|
const decisions = [...report.resolved.decisions.values()].sort((a, b) => a.relPath < b.relPath ? -1 : a.relPath > b.relPath ? 1 : 0);
|
|
22993
23076
|
return {
|
|
22994
23077
|
identity: { name: report.identityName ?? null, source: report.identitySource },
|
|
23078
|
+
...report.borrowedLogins === void 0 ? {} : { borrowedLogins: report.borrowedLogins },
|
|
22995
23079
|
...report.poolPick === void 0 ? {} : { pool: report.poolPick },
|
|
22996
23080
|
configProfile: { name: report.configProfileName ?? null, source: report.configProfileSource },
|
|
22997
23081
|
layers: report.resolved.assembled.layers.map((layer) => ({ id: layer.id, kind: layer.kind, source: layer.source })),
|
|
@@ -23072,6 +23156,7 @@ function collectCheckReport(params) {
|
|
|
23072
23156
|
...identityDecision.name === void 0 ? {} : { identityName: identityDecision.name },
|
|
23073
23157
|
...identityId === void 0 ? {} : { identityId },
|
|
23074
23158
|
identitySource: identityDecision.source,
|
|
23159
|
+
...identityId === void 0 ? {} : { borrowedLogins: loginsLentTo(listIdentities(paths).flatMap((entry) => entry.problem === void 0 ? [{ id: entry.id, name: entry.name, grants: entry.identity.grants }] : []), identityId) },
|
|
23075
23160
|
...poolPick === void 0 ? {} : { poolPick },
|
|
23076
23161
|
...configProfileDecision.name === void 0 ? {} : { configProfileName: configProfileDecision.name },
|
|
23077
23162
|
configProfileSource: configProfileDecision.source,
|
|
@@ -24783,11 +24868,20 @@ function runDoctor(params) {
|
|
|
24783
24868
|
`${entry.name} is valid and authenticates with ${authenticatesWith}${cache.text}.`,
|
|
24784
24869
|
entry.name
|
|
24785
24870
|
);
|
|
24871
|
+
const keychainItem = params.platform === "darwin" && params.run !== void 0 ? keychainHasItem(params.run, entry.farmRoot) : void 0;
|
|
24872
|
+
for (const grant of validated3.data.grants ?? []) {
|
|
24873
|
+
if (!identityIds.has(grant.to)) {
|
|
24874
|
+
push("identity", "warn", `${entry.name} lends its login to identity id "${grant.to}", which does not exist. Remove that entry from its identity.json.`, entry.name);
|
|
24875
|
+
}
|
|
24876
|
+
}
|
|
24877
|
+
if (validated3.data.grants !== void 0 && keychainItem !== true && !entry.credentialsFilePresent) {
|
|
24878
|
+
push("sign-in", "warn", `${entry.name} lends its login but has none stored, so every borrowed request fails. Run \`agent-shim run @${entry.name}\` and sign in.`, entry.name);
|
|
24879
|
+
}
|
|
24786
24880
|
const standing = credential !== void 0 ? "uses a credential block" : identityProvider !== void 0 ? `exists for provider "${identityProvider}"` : "is signed in";
|
|
24787
24881
|
const signIn = decideSignIn({
|
|
24788
24882
|
hasCredentialBlock: credential !== void 0,
|
|
24789
24883
|
provider: identityProvider,
|
|
24790
|
-
keychainItem
|
|
24884
|
+
keychainItem,
|
|
24791
24885
|
credentialsFile: entry.credentialsFilePresent,
|
|
24792
24886
|
platform: params.platform
|
|
24793
24887
|
});
|
|
@@ -25358,7 +25452,8 @@ function identityWriteView(identity) {
|
|
|
25358
25452
|
...identity.provider === void 0 ? {} : { provider: identity.provider },
|
|
25359
25453
|
allowAmbientCredential: identity.allowAmbientCredential,
|
|
25360
25454
|
...identity.credential === void 0 ? {} : { credential: summariseCredential(identity.credential) },
|
|
25361
|
-
...identity.anchors === void 0 ? {} : { anchors: identity.anchors }
|
|
25455
|
+
...identity.anchors === void 0 ? {} : { anchors: identity.anchors },
|
|
25456
|
+
...identity.grants === void 0 ? {} : { grants: identity.grants }
|
|
25362
25457
|
};
|
|
25363
25458
|
}
|
|
25364
25459
|
|
|
@@ -25431,7 +25526,9 @@ var IdentityValueSchema = import_zod43.z.strictObject({
|
|
|
25431
25526
|
provider: import_zod43.z.string().optional(),
|
|
25432
25527
|
allowAmbientCredential: import_zod43.z.boolean(),
|
|
25433
25528
|
credential: CredentialSummarySchema2.optional(),
|
|
25434
|
-
anchors: import_zod43.z.array(AnchorSchema).optional()
|
|
25529
|
+
anchors: import_zod43.z.array(AnchorSchema).optional(),
|
|
25530
|
+
/** Read only here: a grant is made and revoked from the command line alone, so a program driving the door cannot widen what it may reach. */
|
|
25531
|
+
grants: import_zod43.z.array(IdentityGrantSchema).optional()
|
|
25435
25532
|
});
|
|
25436
25533
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
25437
25534
|
var ProviderValueSchema = import_zod43.z.strictObject({
|
|
@@ -29500,6 +29597,7 @@ init_ownCli();
|
|
|
29500
29597
|
getRcSessionContextUsage,
|
|
29501
29598
|
getRcSessionMcpStatus,
|
|
29502
29599
|
getRcSessionUsage,
|
|
29600
|
+
grantIdentityLogin,
|
|
29503
29601
|
headroomSocketTarget,
|
|
29504
29602
|
identityExists,
|
|
29505
29603
|
identityIdOf,
|
|
@@ -29595,6 +29693,7 @@ init_ownCli();
|
|
|
29595
29693
|
resolveLayoutPaths,
|
|
29596
29694
|
resolveSupervisorConfig,
|
|
29597
29695
|
resyncFarm,
|
|
29696
|
+
revokeIdentityLogin,
|
|
29598
29697
|
runCheck,
|
|
29599
29698
|
runClaudeLaunch,
|
|
29600
29699
|
runDoctor,
|