MCPcopy
hub / github.com/codeaashu/claude-code / getTokenUsageAttachment

Function getTokenUsageAttachment

src/utils/attachments.ts:3807–3826  ·  view source on GitHub ↗
(
  messages: Message[],
  model: string,
)

Source from the content-addressed store, hash-verified

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

Callers 1

getAttachmentsFunction · 0.85

Calls 3

isEnvTruthyFunction · 0.85

Tested by

no test coverage detected