style: 完成所有文件的lint

This commit is contained in:
claude-code-best
2026-05-01 21:39:30 +08:00
parent d136872cc9
commit 6182015005
1333 changed files with 68255 additions and 77882 deletions

View File

@@ -1,6 +1,10 @@
import type { BetaUsage as Usage } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs'
import { roughTokenCountEstimationForMessages } from '../services/tokenEstimation.js'
import type { AssistantMessage, ContentItem, Message } from '../types/message.js'
import type {
AssistantMessage,
ContentItem,
Message,
} from '../types/message.js'
import { SYNTHETIC_MESSAGES, SYNTHETIC_MODEL } from './messages.js'
import { jsonStringify } from './slowOperations.js'
@@ -12,7 +16,10 @@ export function getTokenUsage(message: Message): Usage | undefined {
!(
Array.isArray(message.message.content) &&
(message.message.content as ContentItem[])[0]?.type === 'text' &&
SYNTHETIC_MESSAGES.has((message.message.content as Array<ContentItem & { text: string }>)[0]!.text)
SYNTHETIC_MESSAGES.has(
(message.message.content as Array<ContentItem & { text: string }>)[0]!
.text,
)
) &&
message.message.model !== SYNTHETIC_MODEL
) {
@@ -203,11 +210,14 @@ export function getAssistantMessageContentLength(
if (block.type === 'text') {
contentLength += (block as ContentItem & { text: string }).text.length
} else if (block.type === 'thinking') {
contentLength += (block as ContentItem & { thinking: string }).thinking.length
contentLength += (block as ContentItem & { thinking: string }).thinking
.length
} else if (block.type === 'redacted_thinking') {
contentLength += (block as ContentItem & { data: string }).data.length
} else if (block.type === 'tool_use') {
contentLength += jsonStringify((block as ContentItem & { input: unknown }).input).length
contentLength += jsonStringify(
(block as ContentItem & { input: unknown }).input,
).length
}
}
return contentLength
@@ -267,10 +277,16 @@ export function tokenCountWithEstimation(messages: readonly Message[]): number {
}
return (
getTokenCountFromUsage(usage) +
roughTokenCountEstimationForMessages(messages.slice(i + 1) as Parameters<typeof roughTokenCountEstimationForMessages>[0])
roughTokenCountEstimationForMessages(
messages.slice(i + 1) as Parameters<
typeof roughTokenCountEstimationForMessages
>[0],
)
)
}
i--
}
return roughTokenCountEstimationForMessages(messages as Parameters<typeof roughTokenCountEstimationForMessages>[0])
return roughTokenCountEstimationForMessages(
messages as Parameters<typeof roughTokenCountEstimationForMessages>[0],
)
}