mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -384,7 +384,9 @@ async function countBuiltInToolTokens(
|
||||
|
||||
// Check if tool search is enabled
|
||||
const { isToolSearchEnabled } = await import('./toolSearch.js')
|
||||
const { isDeferredTool } = await import('@claude-code-best/builtin-tools/tools/ToolSearchTool/prompt.js')
|
||||
const { isDeferredTool } = await import(
|
||||
'@claude-code-best/builtin-tools/tools/ToolSearchTool/prompt.js'
|
||||
)
|
||||
const isDeferred = await isToolSearchEnabled(
|
||||
model ?? '',
|
||||
tools,
|
||||
@@ -668,7 +670,9 @@ export async function countMcpToolTokens(
|
||||
// Check if tool search is enabled - if so, MCP tools are deferred
|
||||
// isToolSearchEnabled handles threshold calculation internally for TstAuto mode
|
||||
const { isToolSearchEnabled } = await import('./toolSearch.js')
|
||||
const { isDeferredTool } = await import('@claude-code-best/builtin-tools/tools/ToolSearchTool/prompt.js')
|
||||
const { isDeferredTool } = await import(
|
||||
'@claude-code-best/builtin-tools/tools/ToolSearchTool/prompt.js'
|
||||
)
|
||||
|
||||
const isDeferred = await isToolSearchEnabled(
|
||||
model,
|
||||
@@ -786,12 +790,18 @@ function processAssistantMessage(
|
||||
breakdown: MessageBreakdown,
|
||||
): void {
|
||||
// Process each content block individually
|
||||
const contentBlocks = Array.isArray(msg.message!.content) ? msg.message!.content : []
|
||||
const contentBlocks = Array.isArray(msg.message!.content)
|
||||
? msg.message!.content
|
||||
: []
|
||||
for (const block of contentBlocks) {
|
||||
const blockStr = jsonStringify(block)
|
||||
const blockTokens = roughTokenCountEstimation(blockStr)
|
||||
|
||||
if (typeof block !== 'string' && 'type' in block && block.type === 'tool_use') {
|
||||
if (
|
||||
typeof block !== 'string' &&
|
||||
'type' in block &&
|
||||
block.type === 'tool_use'
|
||||
) {
|
||||
breakdown.toolCallTokens += blockTokens
|
||||
const toolName = ('name' in block ? block.name : undefined) || 'unknown'
|
||||
breakdown.toolCallsByType.set(
|
||||
@@ -819,7 +829,7 @@ function processUserMessage(
|
||||
}
|
||||
|
||||
// Process each content block individually
|
||||
for (const block of (msg.message!.content ?? [])) {
|
||||
for (const block of msg.message!.content ?? []) {
|
||||
const blockStr = jsonStringify(block)
|
||||
const blockTokens = roughTokenCountEstimation(blockStr)
|
||||
|
||||
@@ -875,10 +885,16 @@ async function approximateMessageTokens(
|
||||
for (const msg of microcompactResult.messages) {
|
||||
if (msg.type === 'assistant' && Array.isArray(msg.message!.content)) {
|
||||
for (const block of msg.message!.content) {
|
||||
if (typeof block !== 'string' && 'type' in block && block.type === 'tool_use') {
|
||||
if (
|
||||
typeof block !== 'string' &&
|
||||
'type' in block &&
|
||||
block.type === 'tool_use'
|
||||
) {
|
||||
const toolUseId = 'id' in block ? (block.id as string) : undefined
|
||||
const toolName =
|
||||
(('name' in block ? block.name : undefined) as string | undefined) || 'unknown'
|
||||
(('name' in block ? block.name : undefined) as
|
||||
| string
|
||||
| undefined) || 'unknown'
|
||||
if (toolUseId) {
|
||||
toolUseIdToName.set(toolUseId, toolName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user