Claude-Code 62 files · 4 subfolders
Copy to Workspace 09-services-overview Shared from "Claude-Code" on Inkdown
Services Overview
The business logic layer — everything that isn't UI, tools, or the query loop.
Analytics & Telemetry
Analytics Service (services/analytics/)
Tracks usage events and feature flags:
TypeScript
logEvent ('tengu_started' , { })
0000_start_here_index_and_recommended_reading_order.md
GrowthBook (services/analytics/growthbook.ts) Feature flag and A/B testing platform:
TypeScript
getFeatureValue_CACHED_MAY_BE_STALE ('tengu_otk_slot_v1' , false )
if (feature ('COORDINATOR_MODE' )) { ... }
refreshGrowthBookAfterAuthChange ()
OpenTelemetry TypeScript
const meter = getMeter ()
const sessionCounter = meter.createCounter ('sessions' )
const tracer = getTracerProvider ()
const eventLogger = getEventLogger ()Attributed counters track:
Sessions
Lines of code changed
PRs created
Commits made
Cost
Tokens
Active time
Compact Services (services/compact/)
Auto-Compact Summarizes old messages when context approaches the limit:
TypeScript
const compactionResult = await autocompact (
messagesForQuery,
toolUseContext,
{ systemPrompt, userContext, systemContext, ... },
querySource,
tracking,
snipTokensFreed
)
Check if context exceeds threshold
If yes, send old messages to compact model (Haiku)
Replace old messages with summary
Track compaction usage for analytics
Micro-Compact Removes redundant tool_use/tool_result pairs:
TypeScript
const microcompactResult = await microcompact (
messagesForQuery,
toolUseContext,
querySource
)
Reactive Compact Triggered reactively when the API returns 413 (prompt too long):
TypeScript
const compacted = await tryReactiveCompact ({
hasAttempted : hasAttemptedReactiveCompact,
querySource,
aborted,
messages,
cacheSafeParams : { ... }
})
Snip Compact Removes the oldest messages:
TypeScript
const snipResult = snipCompactIfNeeded (messagesForQuery)
Context Collapse (services/contextCollapse/) A more aggressive context reduction strategy:
Archives old conversation segments
Stores summaries in a persistent collapse store
projectView() replays the commit log on every entry
Summaries persist across turns (unlike compaction)
TypeScript
initContextCollapse ()
const result = await applyCollapsesIfNeeded (messages, toolUseContext, querySource)
const drained = recoverFromOverflow (messages, querySource)
Session Memory (services/SessionMemory/) Extracts and stores memories from conversations:
TypeScript
initSessionMemory ()
registerMemoryExtractionHook ()
Team Memory Sync (services/teamMemorySync/) Syncs memory across team members:
TypeScript
startTeamMemoryWatcher ()
Settings Sync (services/settingsSync/) Uploads local settings to the cloud:
TypeScript
uploadUserSettingsInBackground ()
if (getIsInteractive ()) { ... }
LSP Service (services/lsp/) Language Server Protocol integration:
TypeScript
initializeLspServerManager ()
hasShownLspRecommendationThisSession ()
Prompt Suggestion (services/PromptSuggestion/) Suggests prompts to the user:
TypeScript
shouldEnablePromptSuggestion ()
Tips (services/tips/) Contextual tips shown to users:
TypeScript
getRelevantTips ()
Rate Limit Management
Claude AI Limits (services/claudeAiLimits.ts) Tracks and displays rate limit status:
TypeScript
checkQuotaStatus ()
registerClaudeAiLimitsHook ()
Rate Limit Messages (services/rateLimitMessages.ts) User-friendly messages for rate limits:
TypeScript
getRateLimitMessage (limitType)
Rate Limit Mocking (services/rateLimitMocking.ts) TypeScript
mockRateLimits (config)
Auto Dream (services/autoDream/) Background processing feature:
Prevent Sleep (services/preventSleep.ts) Keeps the system awake during long operations:
TypeScript
preventSleep ()
allowSleep ()
Notifier (services/notifier.ts) TypeScript
notify (message, options)
VCR (Playback/Recording) (services/vcr.ts) Records and replays API interactions for testing:
TypeScript
recordVcr ()
playbackVcr ()
Voice Services
Voice (services/voice.ts) TypeScript
processVoiceInput ()
Voice Keyterms (services/voiceKeyterms.ts) Domain-specific keyterms for voice:
TypeScript
getVoiceKeyterms (projectRoot)
Voice Stream STT (services/voiceStreamSTT.ts) Streaming speech-to-text:
TypeScript
streamToSTT (audioStream)
Magic Docs (services/MagicDocs/) Auto-generates documentation:
TypeScript
generateMagicDocs ()
Diagnostic Tracking (services/diagnosticTracking.ts) Collects diagnostic information:
TypeScript
trackDiagnostic (name, value)
Internal Logging (services/internalLogging.ts) Internal logging for debugging:
TypeScript
logPermissionContextForAnts ()
Away Summary (services/awaySummary.ts) Summarizes what happened while the user was away:
TypeScript
generateAwaySummary ()
Extract Memories (services/extractMemories/) Memory extraction from conversations:
TypeScript
extractMemories (messages)
Remote Managed Settings (services/remoteManagedSettings/) Enterprise-managed settings:
TypeScript
loadRemoteManagedSettings ()
refreshRemoteManagedSettings ()
securityCheck ()
Policy Limits (services/policyLimits/) Enterprise policy enforcement:
TypeScript
loadPolicyLimits ()
isPolicyAllowed (action)
refreshPolicyLimits ()
OAuth (services/oauth/) TypeScript
startOAuthFlow ()
refreshOAuthToken ()
Plugins (services/plugins/) TypeScript
installPlugin (name)
uninstallPlugin (name)
updatePlugin (name)
listPlugins ()
plugins : {
enabled : Set <string >
disabled : Set <string >
errors : PluginError []
installationStatus : Map <string , InstallationStatus >
needsRefresh : boolean
}
Key Files Reference Directory Purpose services/analytics/Telemetry, GrowthBook, OTel services/api/Anthropic API client services/compact/Context compaction services/contextCollapse/Context collapse services/mcp/MCP servers services/tools/Tool orchestration services/SessionMemory/Session memory services/teamMemorySync/Team memory sync services/settingsSync/Settings sync services/lsp/LSP integration services/plugins/Plugin management services/policyLimits/Enterprise policies services/oauth/OAuth authentication services/remoteManagedSettings/Remote settings services/autoDream/Auto dream services/PromptSuggestion/Prompt suggestions services/tips/Tips services/voice.tsVoice input services/vcr.tsVCR recording/playback services/notifier.tsNotifications services/rateLimitMessages.tsRate limit messages services/awaySummary.tsAway summary services/diagnosticTracking.tsDiagnostics services/internalLogging.tsInternal logging services/MagicDocs/Auto documentation services/extractMemories/Memory extraction services/toolUseSummary/Tool use summaries services/tokenEstimation.tsToken estimation services/claudeAiLimits.tsClaude AI limits services/preventSleep.tsPrevent system sleep services/mockRateLimits.tsRate limit mocking services/voiceKeyterms.tsVoice keyterms services/voiceStreamSTT.tsVoice STT