MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getTokenUsageAttachment

Function getTokenUsageAttachment

source code/utils/attachments.ts:3809–3828  ·  view source on GitHub ↗
(
  messages: Message[],
  model: string,
)

Source from the content-addressed store, hash-verified

3807}
3808
3809function getTokenUsageAttachment(
3810 messages: Message[],
3811 model: string,
3812): Attachment[] {
3813 if (!isEnvTruthy(process.env.CLAUDE_CODE_ENABLE_TOKEN_USAGE_ATTACHMENT)) {
3814 return []
3815 }
3816
3817 const contextWindow = getEffectiveContextWindowSize(model)
3818 const usedTokens = tokenCountFromLastAPIResponse(messages)
3819
3820 return [
3821 {
3822 type: 'token_usage',
3823 used: usedTokens,
3824 total: contextWindow,
3825 remaining: contextWindow - usedTokens,
3826 },
3827 ]
3828}
3829
3830function getOutputTokenUsageAttachment(): Attachment[] {
3831 if (feature('TOKEN_BUDGET')) {

Callers 1

getAttachmentsFunction · 0.85

Calls 3

isEnvTruthyFunction · 0.85

Tested by

no test coverage detected