sidekick-shared 0.26.5 → 0.26.6
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/CHANGELOG.md +35 -0
- package/README.md +56 -51
- package/dist/accountChanges.js +21 -2
- package/dist/accountHealth.d.ts +72 -0
- package/dist/accountHealth.js +286 -0
- package/dist/accountLaunch.d.ts +30 -0
- package/dist/accountLaunch.js +124 -0
- package/dist/accountManager.d.ts +33 -8
- package/dist/accountManager.js +183 -50
- package/dist/accountRegistry.d.ts +10 -0
- package/dist/accountRegistry.js +42 -22
- package/dist/accountSwitch.d.ts +43 -0
- package/dist/accountSwitch.js +115 -0
- package/dist/accountSync.d.ts +30 -0
- package/dist/accountSync.js +180 -0
- package/dist/accountSyncTypes.d.ts +25 -0
- package/dist/accountSyncTypes.js +7 -0
- package/dist/accounts.d.ts +58 -6
- package/dist/accounts.js +408 -189
- package/dist/claudeCredentials.d.ts +38 -0
- package/dist/claudeCredentials.js +74 -0
- package/dist/claudeProfiles.d.ts +40 -0
- package/dist/claudeProfiles.js +102 -10
- package/dist/codexAuth.d.ts +32 -0
- package/dist/codexAuth.js +127 -0
- package/dist/codexPaths.d.ts +21 -0
- package/dist/codexPaths.js +117 -0
- package/dist/codexProfiles.d.ts +58 -5
- package/dist/codexProfiles.js +574 -289
- package/dist/credentialIO.d.ts +12 -5
- package/dist/credentialIO.js +63 -29
- package/dist/credentials.d.ts +8 -0
- package/dist/credentials.js +28 -32
- package/dist/ensureDefaultAccounts.d.ts +8 -0
- package/dist/ensureDefaultAccounts.js +42 -82
- package/dist/index.d.ts +27 -10
- package/dist/index.js +61 -9
- package/dist/keepAlive.d.ts +44 -0
- package/dist/keepAlive.js +106 -0
- package/dist/processDetection.d.ts +32 -0
- package/dist/processDetection.js +210 -0
- package/dist/schemas/accountManager.d.ts +283 -1
- package/dist/schemas/accountManager.js +122 -1
- package/dist/schemas/assistantTurn.d.ts +2 -2
- package/dist/schemas/index.d.ts +6 -1
- package/dist/schemas/index.js +14 -1
- package/dist/schemas/observedSessionV1.d.ts +21 -21
- package/dist/schemas/quota.d.ts +18 -18
- package/dist/schemas/quotaHistory.d.ts +1 -1
- package/dist/schemas/stateFile.d.ts +5 -5
- package/dist/terminalSync.d.ts +5 -5
- package/dist/terminalSync.js +7 -112
- package/dist/writers/atomic.d.ts +2 -0
- package/dist/writers/atomic.js +49 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,11 +7,12 @@ exports.DirectoryListingCache = exports.fileFingerprintParts = exports.fileFinge
|
|
|
7
7
|
exports.createSessionProviders = exports.SESSION_PROVIDER_IDS = exports.renderHandoffUrlTemplate = exports.addNote = exports.decisionFingerprint = exports.addDecision = exports.completeTask = exports.addTask = exports.withFileLockSync = exports.updateJsonStoreAtomicSync = exports.updateJsonStoreAtomic = exports.atomicWriteFileSync = exports.atomicWriteJsonSync = exports.atomicWriteJson = exports.readClaudeCodePlanFiles = exports.getPlanAnalytics = exports.writePlans = exports.getLatestPlan = exports.readPlans = exports.readLatestHandoff = exports.readHistory = exports.readNotes = exports.readDecisions = exports.readTasks = exports.migrateLegacyProjectStores = exports.resolveProjectIdentity = exports.getProjectSlugRaw = exports.getProjectSlug = exports.encodeWorkspacePath = exports.getGlobalDataPath = exports.getProjectDataPath = exports.setConfigDir = exports.getDefaultConfigDir = exports.getConfigDirOverride = exports.getConfigDir = exports.CONFIG_DIR_ENV_VAR = exports.MAX_PLANS_PER_PROJECT = exports.PLAN_SCHEMA_VERSION = exports.createEmptyDataStore = exports.createEmptyTokenTotals = exports.HISTORICAL_SESSION_RETENTION_LIMIT = exports.HISTORICAL_DATA_SCHEMA_VERSION = exports.STALENESS_THRESHOLDS = exports.IMPORTANCE_DECAY_FACTORS = exports.KNOWLEDGE_NOTE_SCHEMA_VERSION = exports.DECISION_LOG_SCHEMA_VERSION = exports.normalizeTaskStatus = exports.TASK_PERSISTENCE_SCHEMA_VERSION = exports.isAggregateCodexLimit = exports.splitWatchedPath = void 0;
|
|
8
8
|
exports.listSessionPreviews = exports.readCodexHistory = exports.parseMcpToolName = exports.scanSubagentTraces = exports.findAllSessionsWithWorktrees = exports.discoverWorktreeSiblings = exports.resolveWorktreeMainRepo = exports.getAllClaudeProjectFolders = exports.decodeEncodedPath = exports.getMostRecentlyActiveSessionDir = exports.findSubdirectorySessionDirs = exports.findSessionFilesWithStats = exports.findSessionsInDirectory = exports.findAllClaudeSessions = exports.findActiveClaudeSession = exports.discoverSessionDirectory = exports.getClaudeSessionDirectory = exports.encodeClaudeWorkspacePath = exports.SESSION_ACTIVITY_STALENESS_MS = exports.SESSION_ACTIVITY_GRACE_PERIOD_MS = exports.refreshSessionActivityState = exports.detectSessionActivity = exports.classifySessionActivity = exports.extractTaskInfo = exports.scanSubagentDir = exports.normalizeCodexToolInput = exports.normalizeCodexToolName = exports.extractPatchFilePaths = exports.CodexRolloutParser = exports.parseDbPartData = exports.parseDbMessageData = exports.convertOpenCodeMessage = exports.detectPlanModeFromText = exports.normalizeToolInput = exports.normalizeToolName = exports.TRUNCATION_PATTERNS = exports.JsonlParser = exports.walkRolloutFilesAsync = exports.walkRolloutFiles = exports.findCodexRolloutFile = exports.CodexProvider = exports.getOpenCodeDataDir = exports.OpenCodeProvider = exports.ClaudeCodeProvider = exports.getAllDetectedProviders = exports.detectProvider = exports._resetProviderDetectionCache = exports.getObservedActivityReason = exports.derivePendingUserRequestV1 = exports.createProviderSessionAdapterV1 = void 0;
|
|
9
9
|
exports.PHRASE_CATEGORIES = exports.ALL_PHRASES = exports.HIGHLIGHT_CSS = exports.clearHighlightCache = exports.highlightEvent = exports.formatSessionJson = exports.formatSessionMarkdown = exports.formatSessionText = exports.classifyNoise = exports.shouldMergeWithPrevious = exports.classifyFollowEvent = exports.classifyMessage = exports.getSoftNoiseReason = exports.isHardNoiseFollowEvent = exports.isHardNoise = exports.formatToolSummary = exports.parseLocalDateKey = exports.formatTokenCount = exports.formatLocalDateKey = exports.formatDurationMs = exports.addLocalDays = exports.createJsonlTail = exports.toFollowEvents = exports.resolveSessionPath = exports.createWatcher = exports.parseChangelog = exports.extractProposedPlanShared = exports.parsePlanMarkdownShared = exports.PlanExtractor = exports.segmentAssistantTurn = exports.reasoningSummary = exports.isAssistantTurnSubagentTool = exports.extractTurnSubagents = exports.assistantTurnEventsFromSessionEvents = exports.readSessionContextSnapshot = exports.createSessionContextProjector = exports.calculateSessionContextPressure = exports.buildSessionContextSnapshot = exports.composeContext = exports.FilterEngine = exports.searchSessions = exports.CodexDatabase = exports.OpenCodeDatabase = exports.discoverDebugLogs = exports.collapseDuplicates = exports.filterByLevel = exports.parseDebugLog = exports.readSessionPreviewAsync = exports.readSessionPreview = exports.listSessionPreviewsAsync = void 0;
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
10
|
+
exports.writeAccountRegistry = exports.readAccountRegistry = exports.ensureDefaultAccounts = exports.codexIdentitiesMatch = exports.readCodexAccessTokenExpiry = exports.readCodexLastRefresh = exports.readCodexAuthIdentity = exports.parseCodexAuthJson = exports.CLAUDE_REFRESH_TOKEN_LIFETIME_ESTIMATE_MS = exports.CLAUDE_ACCESS_TOKEN_LIFETIME_MS = exports.resolveClaudeRefreshExpiry = exports.isNewerClaudeCredential = exports.claudeCredentialFreshness = exports.parseClaudeCredentialBlob = exports.readClaudeMaxAccessTokenSync = exports.readClaudeMaxCredentialsRaw = exports.readClaudeMaxCredentials = exports.deleteStoredCredentials = exports.writeActiveCredentials = exports.readActiveCredentials = exports.openInBrowser = exports.parseTranscriptFromEvents = exports.parseTranscript = exports.generateHtmlReport = exports.formatCompactionLedger = exports.calculateCompactionLedger = exports.describeCostProvenance = exports.classifyCostProvenance = exports.calculateCodeImpact = exports.scoreSessionQuality = exports.calculateQualityTrend = exports.PatternExtractor = exports.HeatmapTracker = exports.FrequencyTracker = exports.readErrorHistory = exports.getTopFailingTools = exports.appendErrorHistory = exports.MAX_ERROR_HISTORY_SESSIONS = exports.ERROR_HISTORY_SCHEMA_VERSION = exports.getSnapshotPath = exports.MAX_SNAPSHOT_FILES = exports.pruneSnapshots = exports.isSnapshotValid = exports.deleteSnapshot = exports.loadSnapshot = exports.saveSnapshot = exports.SessionMonitor = exports.parseTodoDependencies = exports.EventAggregator = exports.getRandomPhrase = void 0;
|
|
11
|
+
exports.upsertSavedAccountProfile = exports.getActiveSavedAccount = exports.listSavedAccountProfiles = exports.writeSavedAccountRegistry = exports.readSavedAccountRegistry = exports.getAccountsDir = exports.ACCOUNT_CONSUMER_REACHABILITY = exports.describeAccountConsumer = exports.detectRunningAccountConsumersSync = exports.detectRunningAccountConsumers = exports.findRunningProcessesSync = exports.findRunningProcesses = exports.keepAliveCommand = exports.refreshInactiveAccounts = exports.getAccountLaunchEnv = exports.getHealthSidecarPath = exports.readHealthSidecar = exports.listAccountsWithHealth = exports.getAccountHealth = exports.cleanupAbandonedLogins = exports.syncLiveAccountStateSync = exports.syncLiveAccountState = exports.getLastSwitchPath = exports.readLastSwitch = exports.resolveClaudeLoginCommand = exports.listAllAccounts = exports.getLastSwitch = exports.undoLastSwitch = exports.switchAccountAsync = exports.switchAccount = exports.spawnAccountLogin = exports.finalizeAccountLoginAsync = exports.finalizeAccountLogin = exports.getAccountLoginStatusAsync = exports.getAccountLoginStatus = exports.beginAccountLogin = exports.isMultiAccountEnabled = exports.resolveActiveClaudeAccount = exports.getActiveAccount = exports.listAccounts = exports.removeAccount = exports.reconcileClaudeAuthState = exports.applyActiveClaudeToLiveHome = exports.resolveActiveClaudeHome = exports.cleanupAbandonedClaudeLogins = exports.syncClaudeLiveState = exports.switchToAccountAsync = exports.switchToAccount = exports.addCurrentAccount = exports.readActiveClaudeAccount = void 0;
|
|
12
|
+
exports.withQuotaProjections = exports.projectQuotaWindow = exports.fetchQuota = exports.SEVEN_DAY_WINDOW_MS = exports.QUOTA_PROVIDER_IDS = exports.FIVE_HOUR_WINDOW_MS = exports.AutoSwitchController = exports.decideAutoSwitch = exports.DEFAULT_AUTO_SWITCH_CONFIG = exports.removeLauncher = exports.writeLauncher = exports.CODEX_KEYRING_FIX_HINT = exports.getCodexCredentialStoreMode = exports.cleanupAbandonedCodexLogins = exports.syncCodexLiveState = exports.removeCodexAccount = exports.switchToCodexAccountAsync = exports.switchToCodexAccount = exports.finalizeCodexAccountAsync = exports.finalizeCodexAccount = exports.prepareCodexAccountAsync = exports.prepareCodexAccount = exports.getCodexExecutionEnv = exports.resolveSidekickCodexHome = exports.resolveActiveCodexAccount = exports.getActiveCodexAccount = exports.listCodexAccounts = exports.getSystemCodexHome = exports.getCodexMonitoringHomes = exports.getCodexProfileHome = exports.getCodexProfilesDir = exports.readLiveClaudeIdentity = exports.readClaudeProfileIdentity = exports.isClaudeProfileAuthenticated = exports.CLAUDE_SECURESTORAGE_CONFIG_DIR_ENV = exports.buildClaudeChildEnv = exports.claudeKeychainAccountName = exports.claudeKeychainService = exports.claudeKeychainSuffix = exports.getClaudeConfigPath = exports.getDefaultClaudeHome = exports.getLiveClaudeHome = exports.getClaudeProfileHome = exports.getClaudeProfilesDir = exports.onAccountsChanged = exports.getActiveAccountStatus = exports.ACCOUNT_PROVIDER_IDS = exports.removeSavedAccountProfile = exports.replaceSavedAccountProfiles = exports.setActiveSavedAccount = void 0;
|
|
13
|
+
exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.resolveModelPricing = exports.getModelPricing = exports.parseModelId = exports.DEFAULT_CONTEXT_WINDOW = exports.resolveModelContextWindow = exports.getModelContextWindowSize = exports.selectStatuslineAccount = exports.formatStatusline = exports.estimateTimeToQuota = exports.BurnRateCalculator = exports.RUNTIME_QUOTA_PROVIDER_IDS = exports.MultiProviderQuotaService = exports.resolveZaiQuota = exports.readZaiCredentials = exports.quotaStateFromZaiQuotaLimitPayload = exports.fetchZaiQuotaFromApi = exports.CodexQuotaWatcher = exports.resolveCodexQuotaFromLocalSources = exports.resolveCodexQuota = exports.readLatestCodexQuotaFromRollouts = exports.quotaFromCodexRateLimits = exports.fetchCodexQuotaFromApi = exports.fetchCodexResetCreditsFromApi = exports.getWorkspaceIdFromPath = exports.pruneQuotaHistory = exports.readQuotaHistoryDailyBuckets = exports.readQuotaHistoryRange = exports.appendQuotaHistorySample = exports.quotaFromStatuslinePayload = exports.parseClaudeStatuslinePayload = exports.evaluateQuotaThresholds = exports.describeQuotaThresholdAlert = exports.DEFAULT_QUOTA_THRESHOLDS = exports.QUOTA_FRESH_MAX_AGE_MS = exports.QUOTA_AGING_MAX_AGE_MS = exports.formatQuotaAge = exports.classifyQuotaFreshness = exports.resolveQuota = exports.writeQuotaSnapshot = exports.readQuotaSnapshot = exports.QuotaPoller = exports.describeQuotaFailure = void 0;
|
|
14
|
+
exports.quotaHistoryRuntimeProviderSchema = exports.providerQuotaMapSchema = exports.zaiProviderQuotaStateSchema = exports.codexProviderQuotaStateSchema = exports.claudeProviderQuotaStateSchema = exports.providerQuotaStateSchema = exports.runtimeQuotaProviderSchema = exports.quotaFailureDescriptorSchema = exports.peakHoursStateSchema = exports.codexResetCreditsSnapshotSchema = exports.codexResetCreditSchema = exports.quotaSourceSchema = exports.quotaProviderIdSchema = exports.quotaFailureKindSchema = exports.quotaStateSchema = exports.quotaWindowSchema = exports.extractSessionEvents = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = exports.ToolCallTracker = exports.extractToolCalls = exports.extractToolCall = exports.extractErrorMessage = exports.categorizeError = exports.gatherAssetsForCwd = exports.codexSessions = exports.readCodexAssets = exports.claudeSessions = exports.readClaudeAssets = exports.extractCommands = exports.extractFilePaths = exports.extractUrls = exports.extractTokenUsage = exports.getObservedContextWindowPath = exports.recordObservedContextWindow = exports.loadObservedContextWindows = exports.LITELLM_CATALOG_URL = exports.normalizeLiteLlmContextWindows = exports.normalizeLiteLlmCatalog = exports.hydratePricingCatalog = exports.RESOLVED_MODEL_CATALOG_SCHEMA_VERSION = exports.resolveModelAlias = exports.registerModelAlias = exports.importResolvedModelCatalog = exports.exportResolvedModelCatalog = exports.MODEL_PROVIDER_IDS = exports.formatCost = exports.sortModelIds = void 0;
|
|
15
|
+
exports.fetchProviderServiceStatus = exports.diagnoseProviderFailure = exports.mergeFailingToolWindows = exports.failingToolTrend = exports.FAILING_TOOL_TREND_ARROWS = exports.scopePeakHoursToSessionProvider = exports.PEAK_HOURS_DESCRIPTION = exports.PEAK_HOURS_CACHE_MS = exports.isClaudeCodeSessionProvider = exports.getScheduledPeakHoursState = exports.fetchPeakHoursStatus = exports.DEFAULT_PEAK_HOURS_TIMEOUT_MS = exports.createPeakHoursNotApplicableState = exports._resetPeakHoursCache = exports.runDoctor = exports.getSessionDiagnostics = exports.formatHealthReport = exports.toLegacyProviderStatus = exports.fetchOpenAIStatus = exports.fetchProviderStatus = exports.assistantTurnToolRefSchema = exports.assistantTurnToolGroupStepSchema = exports.assistantTurnTimelineItemSchema = exports.assistantTurnSubagentStatusSchema = exports.assistantTurnSubagentSchema = exports.assistantTurnReasoningTimelineItemSchema = exports.assistantTurnProjectionSchema = exports.assistantTurnProcessStepSchema = exports.assistantTurnProcessSchema = exports.assistantTurnNarrationStepSchema = exports.assistantTurnEventTypeSchema = exports.assistantTurnEventSchema = exports.listAllAccountsResultSchema = exports.savedAccountProfileSchema = exports.accountEntrySchema = exports.accountLoginStatusSchema = exports.beginAccountLoginResultSchema = exports.accountManagerResultSchema = exports.accountProviderIdSchema = exports.activeAccountStatusSchema = exports.activeProviderAccountStatusSchema = exports.quotaHistoryDailyBucketSchema = exports.quotaHistorySampleSchema = void 0;
|
|
15
16
|
var usageNormalization_1 = require("./usageNormalization");
|
|
16
17
|
Object.defineProperty(exports, "normalizeProviderUsage", { enumerable: true, get: function () { return usageNormalization_1.normalizeProviderUsage; } });
|
|
17
18
|
Object.defineProperty(exports, "extractNormalizedUsage", { enumerable: true, get: function () { return usageNormalization_1.extractNormalizedUsage; } });
|
|
@@ -355,10 +356,25 @@ Object.defineProperty(exports, "openInBrowser", { enumerable: true, get: functio
|
|
|
355
356
|
var credentialIO_1 = require("./credentialIO");
|
|
356
357
|
Object.defineProperty(exports, "readActiveCredentials", { enumerable: true, get: function () { return credentialIO_1.readActiveCredentials; } });
|
|
357
358
|
Object.defineProperty(exports, "writeActiveCredentials", { enumerable: true, get: function () { return credentialIO_1.writeActiveCredentials; } });
|
|
359
|
+
Object.defineProperty(exports, "deleteStoredCredentials", { enumerable: true, get: function () { return credentialIO_1.deleteStoredCredentials; } });
|
|
358
360
|
// Credentials
|
|
359
361
|
var credentials_1 = require("./credentials");
|
|
360
362
|
Object.defineProperty(exports, "readClaudeMaxCredentials", { enumerable: true, get: function () { return credentials_1.readClaudeMaxCredentials; } });
|
|
363
|
+
Object.defineProperty(exports, "readClaudeMaxCredentialsRaw", { enumerable: true, get: function () { return credentials_1.readClaudeMaxCredentialsRaw; } });
|
|
361
364
|
Object.defineProperty(exports, "readClaudeMaxAccessTokenSync", { enumerable: true, get: function () { return credentials_1.readClaudeMaxAccessTokenSync; } });
|
|
365
|
+
var claudeCredentials_1 = require("./claudeCredentials");
|
|
366
|
+
Object.defineProperty(exports, "parseClaudeCredentialBlob", { enumerable: true, get: function () { return claudeCredentials_1.parseClaudeCredentialBlob; } });
|
|
367
|
+
Object.defineProperty(exports, "claudeCredentialFreshness", { enumerable: true, get: function () { return claudeCredentials_1.claudeCredentialFreshness; } });
|
|
368
|
+
Object.defineProperty(exports, "isNewerClaudeCredential", { enumerable: true, get: function () { return claudeCredentials_1.isNewerClaudeCredential; } });
|
|
369
|
+
Object.defineProperty(exports, "resolveClaudeRefreshExpiry", { enumerable: true, get: function () { return claudeCredentials_1.resolveClaudeRefreshExpiry; } });
|
|
370
|
+
Object.defineProperty(exports, "CLAUDE_ACCESS_TOKEN_LIFETIME_MS", { enumerable: true, get: function () { return claudeCredentials_1.CLAUDE_ACCESS_TOKEN_LIFETIME_MS; } });
|
|
371
|
+
Object.defineProperty(exports, "CLAUDE_REFRESH_TOKEN_LIFETIME_ESTIMATE_MS", { enumerable: true, get: function () { return claudeCredentials_1.CLAUDE_REFRESH_TOKEN_LIFETIME_ESTIMATE_MS; } });
|
|
372
|
+
var codexAuth_1 = require("./codexAuth");
|
|
373
|
+
Object.defineProperty(exports, "parseCodexAuthJson", { enumerable: true, get: function () { return codexAuth_1.parseAuthJson; } });
|
|
374
|
+
Object.defineProperty(exports, "readCodexAuthIdentity", { enumerable: true, get: function () { return codexAuth_1.readAuthIdentityFromRaw; } });
|
|
375
|
+
Object.defineProperty(exports, "readCodexLastRefresh", { enumerable: true, get: function () { return codexAuth_1.readLastRefresh; } });
|
|
376
|
+
Object.defineProperty(exports, "readCodexAccessTokenExpiry", { enumerable: true, get: function () { return codexAuth_1.readAccessTokenExpiry; } });
|
|
377
|
+
Object.defineProperty(exports, "codexIdentitiesMatch", { enumerable: true, get: function () { return codexAuth_1.identitiesMatch; } });
|
|
362
378
|
// Accounts
|
|
363
379
|
var ensureDefaultAccounts_1 = require("./ensureDefaultAccounts");
|
|
364
380
|
Object.defineProperty(exports, "ensureDefaultAccounts", { enumerable: true, get: function () { return ensureDefaultAccounts_1.ensureDefaultAccounts; } });
|
|
@@ -368,6 +384,9 @@ Object.defineProperty(exports, "writeAccountRegistry", { enumerable: true, get:
|
|
|
368
384
|
Object.defineProperty(exports, "readActiveClaudeAccount", { enumerable: true, get: function () { return accounts_1.readActiveClaudeAccount; } });
|
|
369
385
|
Object.defineProperty(exports, "addCurrentAccount", { enumerable: true, get: function () { return accounts_1.addCurrentAccount; } });
|
|
370
386
|
Object.defineProperty(exports, "switchToAccount", { enumerable: true, get: function () { return accounts_1.switchToAccount; } });
|
|
387
|
+
Object.defineProperty(exports, "switchToAccountAsync", { enumerable: true, get: function () { return accounts_1.switchToAccountAsync; } });
|
|
388
|
+
Object.defineProperty(exports, "syncClaudeLiveState", { enumerable: true, get: function () { return accounts_1.syncClaudeLiveState; } });
|
|
389
|
+
Object.defineProperty(exports, "cleanupAbandonedClaudeLogins", { enumerable: true, get: function () { return accounts_1.cleanupAbandonedClaudeLogins; } });
|
|
371
390
|
Object.defineProperty(exports, "resolveActiveClaudeHome", { enumerable: true, get: function () { return accounts_1.resolveActiveClaudeHome; } });
|
|
372
391
|
Object.defineProperty(exports, "applyActiveClaudeToLiveHome", { enumerable: true, get: function () { return accounts_1.applyActiveClaudeToLiveHome; } });
|
|
373
392
|
Object.defineProperty(exports, "reconcileClaudeAuthState", { enumerable: true, get: function () { return accounts_1.reconcileClaudeAuthState; } });
|
|
@@ -385,8 +404,34 @@ Object.defineProperty(exports, "finalizeAccountLoginAsync", { enumerable: true,
|
|
|
385
404
|
Object.defineProperty(exports, "spawnAccountLogin", { enumerable: true, get: function () { return accountManager_1.spawnAccountLogin; } });
|
|
386
405
|
Object.defineProperty(exports, "switchAccount", { enumerable: true, get: function () { return accountManager_1.switchAccount; } });
|
|
387
406
|
Object.defineProperty(exports, "switchAccountAsync", { enumerable: true, get: function () { return accountManager_1.switchAccountAsync; } });
|
|
407
|
+
Object.defineProperty(exports, "undoLastSwitch", { enumerable: true, get: function () { return accountManager_1.undoLastSwitch; } });
|
|
408
|
+
Object.defineProperty(exports, "getLastSwitch", { enumerable: true, get: function () { return accountManager_1.getLastSwitch; } });
|
|
388
409
|
Object.defineProperty(exports, "listAllAccounts", { enumerable: true, get: function () { return accountManager_1.listAllAccounts; } });
|
|
389
410
|
Object.defineProperty(exports, "resolveClaudeLoginCommand", { enumerable: true, get: function () { return accountManager_1.resolveClaudeLoginCommand; } });
|
|
411
|
+
var accountSwitch_1 = require("./accountSwitch");
|
|
412
|
+
Object.defineProperty(exports, "readLastSwitch", { enumerable: true, get: function () { return accountSwitch_1.readLastSwitch; } });
|
|
413
|
+
Object.defineProperty(exports, "getLastSwitchPath", { enumerable: true, get: function () { return accountSwitch_1.getLastSwitchPath; } });
|
|
414
|
+
var accountSync_1 = require("./accountSync");
|
|
415
|
+
Object.defineProperty(exports, "syncLiveAccountState", { enumerable: true, get: function () { return accountSync_1.syncLiveAccountState; } });
|
|
416
|
+
Object.defineProperty(exports, "syncLiveAccountStateSync", { enumerable: true, get: function () { return accountSync_1.syncLiveAccountStateSync; } });
|
|
417
|
+
Object.defineProperty(exports, "cleanupAbandonedLogins", { enumerable: true, get: function () { return accountSync_1.cleanupAbandonedLogins; } });
|
|
418
|
+
var accountHealth_1 = require("./accountHealth");
|
|
419
|
+
Object.defineProperty(exports, "getAccountHealth", { enumerable: true, get: function () { return accountHealth_1.getAccountHealth; } });
|
|
420
|
+
Object.defineProperty(exports, "listAccountsWithHealth", { enumerable: true, get: function () { return accountHealth_1.listAccountsWithHealth; } });
|
|
421
|
+
Object.defineProperty(exports, "readHealthSidecar", { enumerable: true, get: function () { return accountHealth_1.readHealthSidecar; } });
|
|
422
|
+
Object.defineProperty(exports, "getHealthSidecarPath", { enumerable: true, get: function () { return accountHealth_1.getHealthSidecarPath; } });
|
|
423
|
+
var accountLaunch_1 = require("./accountLaunch");
|
|
424
|
+
Object.defineProperty(exports, "getAccountLaunchEnv", { enumerable: true, get: function () { return accountLaunch_1.getAccountLaunchEnv; } });
|
|
425
|
+
var keepAlive_1 = require("./keepAlive");
|
|
426
|
+
Object.defineProperty(exports, "refreshInactiveAccounts", { enumerable: true, get: function () { return keepAlive_1.refreshInactiveAccounts; } });
|
|
427
|
+
Object.defineProperty(exports, "keepAliveCommand", { enumerable: true, get: function () { return keepAlive_1.keepAliveCommand; } });
|
|
428
|
+
var processDetection_1 = require("./processDetection");
|
|
429
|
+
Object.defineProperty(exports, "findRunningProcesses", { enumerable: true, get: function () { return processDetection_1.findRunningProcesses; } });
|
|
430
|
+
Object.defineProperty(exports, "findRunningProcessesSync", { enumerable: true, get: function () { return processDetection_1.findRunningProcessesSync; } });
|
|
431
|
+
Object.defineProperty(exports, "detectRunningAccountConsumers", { enumerable: true, get: function () { return processDetection_1.detectRunningAccountConsumers; } });
|
|
432
|
+
Object.defineProperty(exports, "detectRunningAccountConsumersSync", { enumerable: true, get: function () { return processDetection_1.detectRunningAccountConsumersSync; } });
|
|
433
|
+
Object.defineProperty(exports, "describeAccountConsumer", { enumerable: true, get: function () { return processDetection_1.describeAccountConsumer; } });
|
|
434
|
+
Object.defineProperty(exports, "ACCOUNT_CONSUMER_REACHABILITY", { enumerable: true, get: function () { return processDetection_1.ACCOUNT_CONSUMER_REACHABILITY; } });
|
|
390
435
|
var accountRegistry_1 = require("./accountRegistry");
|
|
391
436
|
Object.defineProperty(exports, "getAccountsDir", { enumerable: true, get: function () { return accountRegistry_1.getAccountsDir; } });
|
|
392
437
|
Object.defineProperty(exports, "readSavedAccountRegistry", { enumerable: true, get: function () { return accountRegistry_1.readSavedAccountRegistry; } });
|
|
@@ -406,10 +451,17 @@ Object.defineProperty(exports, "onAccountsChanged", { enumerable: true, get: fun
|
|
|
406
451
|
var claudeProfiles_1 = require("./claudeProfiles");
|
|
407
452
|
Object.defineProperty(exports, "getClaudeProfilesDir", { enumerable: true, get: function () { return claudeProfiles_1.getClaudeProfilesDir; } });
|
|
408
453
|
Object.defineProperty(exports, "getClaudeProfileHome", { enumerable: true, get: function () { return claudeProfiles_1.getClaudeProfileHome; } });
|
|
454
|
+
Object.defineProperty(exports, "getLiveClaudeHome", { enumerable: true, get: function () { return claudeProfiles_1.getLiveClaudeHome; } });
|
|
455
|
+
Object.defineProperty(exports, "getDefaultClaudeHome", { enumerable: true, get: function () { return claudeProfiles_1.getDefaultClaudeHome; } });
|
|
456
|
+
Object.defineProperty(exports, "getClaudeConfigPath", { enumerable: true, get: function () { return claudeProfiles_1.getClaudeConfigPath; } });
|
|
409
457
|
Object.defineProperty(exports, "claudeKeychainSuffix", { enumerable: true, get: function () { return claudeProfiles_1.claudeKeychainSuffix; } });
|
|
410
458
|
Object.defineProperty(exports, "claudeKeychainService", { enumerable: true, get: function () { return claudeProfiles_1.claudeKeychainService; } });
|
|
459
|
+
Object.defineProperty(exports, "claudeKeychainAccountName", { enumerable: true, get: function () { return claudeProfiles_1.claudeKeychainAccountName; } });
|
|
460
|
+
Object.defineProperty(exports, "buildClaudeChildEnv", { enumerable: true, get: function () { return claudeProfiles_1.buildClaudeChildEnv; } });
|
|
461
|
+
Object.defineProperty(exports, "CLAUDE_SECURESTORAGE_CONFIG_DIR_ENV", { enumerable: true, get: function () { return claudeProfiles_1.CLAUDE_SECURESTORAGE_CONFIG_DIR_ENV; } });
|
|
411
462
|
Object.defineProperty(exports, "isClaudeProfileAuthenticated", { enumerable: true, get: function () { return claudeProfiles_1.isClaudeProfileAuthenticated; } });
|
|
412
463
|
Object.defineProperty(exports, "readClaudeProfileIdentity", { enumerable: true, get: function () { return claudeProfiles_1.readClaudeProfileIdentity; } });
|
|
464
|
+
Object.defineProperty(exports, "readLiveClaudeIdentity", { enumerable: true, get: function () { return claudeProfiles_1.readLiveClaudeIdentity; } });
|
|
413
465
|
var codexProfiles_1 = require("./codexProfiles");
|
|
414
466
|
Object.defineProperty(exports, "getCodexProfilesDir", { enumerable: true, get: function () { return codexProfiles_1.getCodexProfilesDir; } });
|
|
415
467
|
Object.defineProperty(exports, "getCodexProfileHome", { enumerable: true, get: function () { return codexProfiles_1.getCodexProfileHome; } });
|
|
@@ -427,11 +479,11 @@ Object.defineProperty(exports, "finalizeCodexAccountAsync", { enumerable: true,
|
|
|
427
479
|
Object.defineProperty(exports, "switchToCodexAccount", { enumerable: true, get: function () { return codexProfiles_1.switchToCodexAccount; } });
|
|
428
480
|
Object.defineProperty(exports, "switchToCodexAccountAsync", { enumerable: true, get: function () { return codexProfiles_1.switchToCodexAccountAsync; } });
|
|
429
481
|
Object.defineProperty(exports, "removeCodexAccount", { enumerable: true, get: function () { return codexProfiles_1.removeCodexAccount; } });
|
|
482
|
+
Object.defineProperty(exports, "syncCodexLiveState", { enumerable: true, get: function () { return codexProfiles_1.syncCodexLiveState; } });
|
|
483
|
+
Object.defineProperty(exports, "cleanupAbandonedCodexLogins", { enumerable: true, get: function () { return codexProfiles_1.cleanupAbandonedCodexLogins; } });
|
|
484
|
+
Object.defineProperty(exports, "getCodexCredentialStoreMode", { enumerable: true, get: function () { return codexProfiles_1.getCodexCredentialStoreMode; } });
|
|
485
|
+
Object.defineProperty(exports, "CODEX_KEYRING_FIX_HINT", { enumerable: true, get: function () { return codexProfiles_1.CODEX_KEYRING_FIX_HINT; } });
|
|
430
486
|
var terminalSync_1 = require("./terminalSync");
|
|
431
|
-
Object.defineProperty(exports, "setTerminalActiveProfile", { enumerable: true, get: function () { return terminalSync_1.setTerminalActiveProfile; } });
|
|
432
|
-
Object.defineProperty(exports, "installShellHook", { enumerable: true, get: function () { return terminalSync_1.installShellHook; } });
|
|
433
|
-
Object.defineProperty(exports, "uninstallShellHook", { enumerable: true, get: function () { return terminalSync_1.uninstallShellHook; } });
|
|
434
|
-
Object.defineProperty(exports, "isShellHookInstalled", { enumerable: true, get: function () { return terminalSync_1.isShellHookInstalled; } });
|
|
435
487
|
Object.defineProperty(exports, "writeLauncher", { enumerable: true, get: function () { return terminalSync_1.writeLauncher; } });
|
|
436
488
|
Object.defineProperty(exports, "removeLauncher", { enumerable: true, get: function () { return terminalSync_1.removeLauncher; } });
|
|
437
489
|
var autoSwitch_1 = require("./autoSwitch");
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AccountProviderId } from './accountRegistry';
|
|
2
|
+
export interface KeepAliveRunner {
|
|
3
|
+
(command: string, args: string[], env: NodeJS.ProcessEnv, timeoutMs: number): Promise<{
|
|
4
|
+
status: number | null;
|
|
5
|
+
stdout: string;
|
|
6
|
+
}>;
|
|
7
|
+
}
|
|
8
|
+
export interface RefreshInactiveAccountsOptions {
|
|
9
|
+
providers?: AccountProviderId[];
|
|
10
|
+
/** Per-account CLI timeout. Default 20 s. */
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
/** Report what would run without running it. */
|
|
13
|
+
dryRun?: boolean;
|
|
14
|
+
/** Also refresh accounts whose credential is still fresh. Default false. */
|
|
15
|
+
includeFresh?: boolean;
|
|
16
|
+
runner?: KeepAliveRunner;
|
|
17
|
+
now?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface RefreshInactiveAccountsResult {
|
|
20
|
+
refreshed: Array<{
|
|
21
|
+
id: string;
|
|
22
|
+
providerId: AccountProviderId;
|
|
23
|
+
}>;
|
|
24
|
+
skipped: Array<{
|
|
25
|
+
id: string;
|
|
26
|
+
providerId: AccountProviderId;
|
|
27
|
+
reason: string;
|
|
28
|
+
}>;
|
|
29
|
+
failed: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
providerId: AccountProviderId;
|
|
32
|
+
error: string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
/** The command each CLI runs to load (and refresh) its stored login. */
|
|
36
|
+
export declare function keepAliveCommand(provider: AccountProviderId): {
|
|
37
|
+
command: string;
|
|
38
|
+
args: string[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Serialised, bounded refresh of every inactive account that is `expiring`
|
|
42
|
+
* (or `unknown` for Claude). Never touches the live account.
|
|
43
|
+
*/
|
|
44
|
+
export declare function refreshInactiveAccounts(options?: RefreshInactiveAccountsOptions): Promise<RefreshInactiveAccountsResult>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keepAliveCommand = keepAliveCommand;
|
|
4
|
+
exports.refreshInactiveAccounts = refreshInactiveAccounts;
|
|
5
|
+
/**
|
|
6
|
+
* Opt-in keep-alive for saved-but-inactive accounts. Sidekick never calls the
|
|
7
|
+
* providers' OAuth endpoints itself: it runs the official CLI inside the
|
|
8
|
+
* profile's isolated home and lets the CLI refresh (and rotate) the token
|
|
9
|
+
* where it belongs, then re-reads the store to record the new expiry.
|
|
10
|
+
*/
|
|
11
|
+
const child_process_1 = require("child_process");
|
|
12
|
+
const accountHealth_1 = require("./accountHealth");
|
|
13
|
+
const accountLaunch_1 = require("./accountLaunch");
|
|
14
|
+
/** The command each CLI runs to load (and refresh) its stored login. */
|
|
15
|
+
function keepAliveCommand(provider) {
|
|
16
|
+
if (provider === 'codex')
|
|
17
|
+
return { command: 'codex', args: ['login', 'status'] };
|
|
18
|
+
const override = process.env.SIDEKICK_CLAUDE_KEEPALIVE_ARGS?.trim();
|
|
19
|
+
return { command: 'claude', args: override ? override.split(/\s+/) : ['auth', 'status'] };
|
|
20
|
+
}
|
|
21
|
+
const defaultRunner = (command, args, env, timeoutMs) => new Promise((resolve) => {
|
|
22
|
+
try {
|
|
23
|
+
(0, child_process_1.execFile)(command, args, { encoding: 'utf8', env, timeout: timeoutMs, killSignal: 'SIGKILL', windowsHide: true }, (error, stdout) => {
|
|
24
|
+
const status = error
|
|
25
|
+
? (error.code ?? null)
|
|
26
|
+
: 0;
|
|
27
|
+
resolve({
|
|
28
|
+
status: typeof status === 'number' ? status : null,
|
|
29
|
+
stdout: String(stdout ?? ''),
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
resolve({ status: null, stdout: '' });
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
function eligible(view, includeFresh) {
|
|
38
|
+
if (view.health.isLive)
|
|
39
|
+
return 'live account; the CLI refreshes it in normal use';
|
|
40
|
+
if (view.health.state === 'expired')
|
|
41
|
+
return 'expired; sign in again';
|
|
42
|
+
if (view.health.state === 'missing')
|
|
43
|
+
return 'no stored credentials';
|
|
44
|
+
if (view.health.state === 'fresh' && !includeFresh)
|
|
45
|
+
return 'fresh';
|
|
46
|
+
if (view.providerId === 'codex' && view.health.state === 'unknown')
|
|
47
|
+
return 'api-key login';
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Serialised, bounded refresh of every inactive account that is `expiring`
|
|
52
|
+
* (or `unknown` for Claude). Never touches the live account.
|
|
53
|
+
*/
|
|
54
|
+
async function refreshInactiveAccounts(options = {}) {
|
|
55
|
+
const result = { refreshed: [], skipped: [], failed: [] };
|
|
56
|
+
const timeoutMs = options.timeoutMs ?? 20_000;
|
|
57
|
+
const runner = options.runner ?? defaultRunner;
|
|
58
|
+
const views = (0, accountHealth_1.listAccountsWithHealth)(undefined, { now: options.now }).filter((view) => !options.providers || options.providers.includes(view.providerId));
|
|
59
|
+
for (const view of views) {
|
|
60
|
+
const reason = eligible(view, options.includeFresh ?? false);
|
|
61
|
+
if (reason) {
|
|
62
|
+
result.skipped.push({ id: view.id, providerId: view.providerId, reason });
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const launch = (0, accountLaunch_1.getAccountLaunchEnv)(view.providerId, view.id, { materialize: true });
|
|
66
|
+
if (launch.error) {
|
|
67
|
+
result.skipped.push({ id: view.id, providerId: view.providerId, reason: launch.error });
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const { command, args } = keepAliveCommand(view.providerId);
|
|
71
|
+
if (options.dryRun) {
|
|
72
|
+
result.skipped.push({
|
|
73
|
+
id: view.id,
|
|
74
|
+
providerId: view.providerId,
|
|
75
|
+
reason: `dry run: would run ${command} ${args.join(' ')}`,
|
|
76
|
+
});
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const env = { ...process.env, ...launch.env };
|
|
80
|
+
for (const name of launch.envUnset)
|
|
81
|
+
delete env[name];
|
|
82
|
+
try {
|
|
83
|
+
const run = await runner(command, args, env, timeoutMs);
|
|
84
|
+
const after = (0, accountHealth_1.getAccountHealth)(view.providerId, view.id, {
|
|
85
|
+
probe: 'store',
|
|
86
|
+
now: options.now,
|
|
87
|
+
});
|
|
88
|
+
if (after.state === 'fresh') {
|
|
89
|
+
result.refreshed.push({ id: view.id, providerId: view.providerId });
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
result.failed.push({
|
|
93
|
+
id: view.id,
|
|
94
|
+
providerId: view.providerId,
|
|
95
|
+
error: run.status === 0
|
|
96
|
+
? `${command} ran but the stored credential is still ${after.state}.`
|
|
97
|
+
: `${command} exited with status ${run.status ?? 'unknown'}.`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
result.failed.push({ id: view.id, providerId: view.providerId, error: String(err) });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface RunningProcess {
|
|
2
|
+
pid: number;
|
|
3
|
+
/** The matched name (as passed to the finder). */
|
|
4
|
+
name: string;
|
|
5
|
+
/** The executable as reported by the OS (basename or image name). */
|
|
6
|
+
command: string;
|
|
7
|
+
}
|
|
8
|
+
export type AccountConsumerKind = 'claude-cli' | 'claude-desktop' | 'codex-cli' | 'codex-app' | 'vscode-extension-host';
|
|
9
|
+
export interface RunningAccountConsumer {
|
|
10
|
+
kind: AccountConsumerKind;
|
|
11
|
+
pids: number[];
|
|
12
|
+
/** Whether a live-store switch reaches this consumer once it restarts. */
|
|
13
|
+
switched: boolean;
|
|
14
|
+
/** The user-facing sentence both UIs print for this consumer. */
|
|
15
|
+
reachability: string;
|
|
16
|
+
}
|
|
17
|
+
/** Sync sibling of {@link findRunningProcesses}; blocks up to 4 s. */
|
|
18
|
+
export declare function findRunningProcessesSync(names: string[]): RunningProcess[];
|
|
19
|
+
export declare function findRunningProcesses(names: string[]): Promise<RunningProcess[]>;
|
|
20
|
+
export declare const ACCOUNT_CONSUMER_REACHABILITY: Record<AccountConsumerKind, {
|
|
21
|
+
switched: boolean;
|
|
22
|
+
reachability: string;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Which credential consumers are running right now, with the reachability
|
|
26
|
+
* sentence to show for each. Optionally scoped to one provider.
|
|
27
|
+
*/
|
|
28
|
+
export declare function detectRunningAccountConsumers(provider?: 'claude-code' | 'codex'): Promise<RunningAccountConsumer[]>;
|
|
29
|
+
/** Sync sibling of {@link detectRunningAccountConsumers}; blocks up to 4 s. */
|
|
30
|
+
export declare function detectRunningAccountConsumersSync(provider?: 'claude-code' | 'codex'): RunningAccountConsumer[];
|
|
31
|
+
/** Build a consumer entry for a kind the host detects itself (e.g. its own extension host). */
|
|
32
|
+
export declare function describeAccountConsumer(kind: AccountConsumerKind, pids?: number[]): RunningAccountConsumer;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ACCOUNT_CONSUMER_REACHABILITY = void 0;
|
|
37
|
+
exports.findRunningProcessesSync = findRunningProcessesSync;
|
|
38
|
+
exports.findRunningProcesses = findRunningProcesses;
|
|
39
|
+
exports.detectRunningAccountConsumers = detectRunningAccountConsumers;
|
|
40
|
+
exports.detectRunningAccountConsumersSync = detectRunningAccountConsumersSync;
|
|
41
|
+
exports.describeAccountConsumer = describeAccountConsumer;
|
|
42
|
+
/**
|
|
43
|
+
* Cross-platform detection of running CLI/app processes that hold provider
|
|
44
|
+
* credentials in memory. Bounded, never throws, never spawns a shell.
|
|
45
|
+
*/
|
|
46
|
+
const child_process_1 = require("child_process");
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const PROBE_TIMEOUT_MS = 4000;
|
|
49
|
+
const CLAUDE_NPM_ENTRY = /claude-code[\\/]cli\.js/;
|
|
50
|
+
function parseUnixTable(stdout) {
|
|
51
|
+
const rows = [];
|
|
52
|
+
for (const line of stdout.split('\n')) {
|
|
53
|
+
const match = line.match(/^\s*(\d+)\s+(\S+)\s*(.*)$/);
|
|
54
|
+
if (!match)
|
|
55
|
+
continue;
|
|
56
|
+
rows.push({ pid: Number(match[1]), command: match[2], args: match[3] ?? '' });
|
|
57
|
+
}
|
|
58
|
+
return rows;
|
|
59
|
+
}
|
|
60
|
+
function parseWindowsCsv(stdout) {
|
|
61
|
+
const rows = [];
|
|
62
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
63
|
+
const match = line.match(/^"([^"]+)","(\d+)"/);
|
|
64
|
+
if (!match)
|
|
65
|
+
continue;
|
|
66
|
+
rows.push({ pid: Number(match[2]), command: match[1], args: '' });
|
|
67
|
+
}
|
|
68
|
+
return rows;
|
|
69
|
+
}
|
|
70
|
+
function matchRows(rows, names) {
|
|
71
|
+
const wanted = new Set(names);
|
|
72
|
+
const found = [];
|
|
73
|
+
for (const row of rows) {
|
|
74
|
+
if (!Number.isFinite(row.pid) || row.pid === process.pid)
|
|
75
|
+
continue;
|
|
76
|
+
const base = path.basename(row.command);
|
|
77
|
+
// The native Claude Code binary is invoked through a `claude` symlink but
|
|
78
|
+
// its executable is the versioned file (`.../versions/2.1.273`), so `comm`
|
|
79
|
+
// never says `claude`; argv[0] does.
|
|
80
|
+
const argv0 = row.args.trim().split(/\s+/)[0] ?? '';
|
|
81
|
+
const candidates = [base, base.replace(/\.exe$/i, ''), path.basename(argv0)];
|
|
82
|
+
let name = candidates.find((candidate) => candidate && wanted.has(candidate));
|
|
83
|
+
// An npm-installed `claude` runs under `node`; recognise it by its entry file.
|
|
84
|
+
if (!name &&
|
|
85
|
+
wanted.has('claude') &&
|
|
86
|
+
/^node(\.exe)?$/i.test(base) &&
|
|
87
|
+
CLAUDE_NPM_ENTRY.test(row.args)) {
|
|
88
|
+
name = 'claude';
|
|
89
|
+
}
|
|
90
|
+
if (name)
|
|
91
|
+
found.push({ pid: row.pid, name, command: row.command });
|
|
92
|
+
}
|
|
93
|
+
return found;
|
|
94
|
+
}
|
|
95
|
+
function probeCommand() {
|
|
96
|
+
return process.platform === 'win32'
|
|
97
|
+
? { command: 'tasklist', args: ['/FO', 'CSV', '/NH'] }
|
|
98
|
+
: { command: 'ps', args: ['-axo', 'pid=,comm=,args='] };
|
|
99
|
+
}
|
|
100
|
+
function parseOutput(stdout) {
|
|
101
|
+
return process.platform === 'win32' ? parseWindowsCsv(stdout) : parseUnixTable(stdout);
|
|
102
|
+
}
|
|
103
|
+
/** Sync sibling of {@link findRunningProcesses}; blocks up to 4 s. */
|
|
104
|
+
function findRunningProcessesSync(names) {
|
|
105
|
+
if (names.length === 0)
|
|
106
|
+
return [];
|
|
107
|
+
try {
|
|
108
|
+
const { command, args } = probeCommand();
|
|
109
|
+
const result = (0, child_process_1.spawnSync)(command, args, {
|
|
110
|
+
encoding: 'utf8',
|
|
111
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
112
|
+
timeout: PROBE_TIMEOUT_MS,
|
|
113
|
+
killSignal: 'SIGKILL',
|
|
114
|
+
windowsHide: true,
|
|
115
|
+
});
|
|
116
|
+
if (result.error || result.status !== 0)
|
|
117
|
+
return [];
|
|
118
|
+
return matchRows(parseOutput(String(result.stdout ?? '')), names);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function findRunningProcesses(names) {
|
|
125
|
+
if (names.length === 0)
|
|
126
|
+
return Promise.resolve([]);
|
|
127
|
+
return new Promise((resolve) => {
|
|
128
|
+
try {
|
|
129
|
+
const { command, args } = probeCommand();
|
|
130
|
+
(0, child_process_1.execFile)(command, args, {
|
|
131
|
+
encoding: 'utf8',
|
|
132
|
+
timeout: PROBE_TIMEOUT_MS,
|
|
133
|
+
killSignal: 'SIGKILL',
|
|
134
|
+
windowsHide: true,
|
|
135
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
136
|
+
}, (error, stdout) => {
|
|
137
|
+
resolve(error ? [] : matchRows(parseOutput(String(stdout ?? '')), names));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
resolve([]);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const CONSUMER_PROCESS_NAMES = {
|
|
146
|
+
'claude-cli': 'claude',
|
|
147
|
+
'claude-desktop': 'Claude',
|
|
148
|
+
'codex-cli': 'codex',
|
|
149
|
+
'codex-app': 'Codex',
|
|
150
|
+
};
|
|
151
|
+
exports.ACCOUNT_CONSUMER_REACHABILITY = {
|
|
152
|
+
'claude-cli': {
|
|
153
|
+
switched: true,
|
|
154
|
+
reachability: 'Running claude sessions keep the previous account until restarted; a running session can rotate the refresh token of the account you just left.',
|
|
155
|
+
},
|
|
156
|
+
'claude-desktop': {
|
|
157
|
+
switched: false,
|
|
158
|
+
reachability: 'Claude Desktop is not switched by sidekick (it keeps its own web session) and its embedded engine can rotate the shared CLI token.',
|
|
159
|
+
},
|
|
160
|
+
'codex-cli': {
|
|
161
|
+
switched: true,
|
|
162
|
+
reachability: 'Running codex sessions keep the previous account until restarted.',
|
|
163
|
+
},
|
|
164
|
+
'codex-app': {
|
|
165
|
+
switched: true,
|
|
166
|
+
reachability: 'The Codex app shares the CLI login; restart it to pick up the switch. While running it can refresh and rotate the live token.',
|
|
167
|
+
},
|
|
168
|
+
'vscode-extension-host': {
|
|
169
|
+
switched: true,
|
|
170
|
+
reachability: 'The Claude Code extension host keeps the previous account until the window reloads.',
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
function toConsumer(kind, pids) {
|
|
174
|
+
return { kind, pids, ...exports.ACCOUNT_CONSUMER_REACHABILITY[kind] };
|
|
175
|
+
}
|
|
176
|
+
function groupConsumers(processes, kinds) {
|
|
177
|
+
const consumers = [];
|
|
178
|
+
for (const kind of kinds) {
|
|
179
|
+
const pids = processes.filter((p) => p.name === CONSUMER_PROCESS_NAMES[kind]).map((p) => p.pid);
|
|
180
|
+
if (pids.length > 0)
|
|
181
|
+
consumers.push(toConsumer(kind, pids));
|
|
182
|
+
}
|
|
183
|
+
return consumers;
|
|
184
|
+
}
|
|
185
|
+
function kindsForProvider(provider) {
|
|
186
|
+
if (provider === 'claude-code')
|
|
187
|
+
return ['claude-cli', 'claude-desktop'];
|
|
188
|
+
if (provider === 'codex')
|
|
189
|
+
return ['codex-cli', 'codex-app'];
|
|
190
|
+
return ['claude-cli', 'claude-desktop', 'codex-cli', 'codex-app'];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Which credential consumers are running right now, with the reachability
|
|
194
|
+
* sentence to show for each. Optionally scoped to one provider.
|
|
195
|
+
*/
|
|
196
|
+
async function detectRunningAccountConsumers(provider) {
|
|
197
|
+
const kinds = kindsForProvider(provider);
|
|
198
|
+
const processes = await findRunningProcesses(kinds.map((kind) => CONSUMER_PROCESS_NAMES[kind]));
|
|
199
|
+
return groupConsumers(processes, kinds);
|
|
200
|
+
}
|
|
201
|
+
/** Sync sibling of {@link detectRunningAccountConsumers}; blocks up to 4 s. */
|
|
202
|
+
function detectRunningAccountConsumersSync(provider) {
|
|
203
|
+
const kinds = kindsForProvider(provider);
|
|
204
|
+
const processes = findRunningProcessesSync(kinds.map((kind) => CONSUMER_PROCESS_NAMES[kind]));
|
|
205
|
+
return groupConsumers(processes, kinds);
|
|
206
|
+
}
|
|
207
|
+
/** Build a consumer entry for a kind the host detects itself (e.g. its own extension host). */
|
|
208
|
+
function describeAccountConsumer(kind, pids = []) {
|
|
209
|
+
return toConsumer(kind, pids);
|
|
210
|
+
}
|