style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files)

纯格式化:移除分号、React Compiler import、import 多行展开。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-04 21:56:58 +08:00
parent 141ed7a76e
commit ae7b92f673
104 changed files with 15977 additions and 18419 deletions

View File

@@ -1,62 +1,71 @@
import type { ToolResultBlockParam, ToolUseBlockParam } from '@anthropic-ai/sdk/resources/messages/messages.mjs';
import * as React from 'react';
import { filterToolProgressMessages, findToolByName, type Tools } from '../../Tool.js';
import type { GroupedToolUseMessage } from '../../types/message.js';
import type { buildMessageLookups } from '../../utils/messages.js';
import type {
ToolResultBlockParam,
ToolUseBlockParam,
} from '@anthropic-ai/sdk/resources/messages/messages.mjs'
import * as React from 'react'
import {
filterToolProgressMessages,
findToolByName,
type Tools,
} from '../../Tool.js'
import type { GroupedToolUseMessage } from '../../types/message.js'
import type { buildMessageLookups } from '../../utils/messages.js'
type Props = {
message: GroupedToolUseMessage;
tools: Tools;
lookups: ReturnType<typeof buildMessageLookups>;
inProgressToolUseIDs: Set<string>;
shouldAnimate: boolean;
};
message: GroupedToolUseMessage
tools: Tools
lookups: ReturnType<typeof buildMessageLookups>
inProgressToolUseIDs: Set<string>
shouldAnimate: boolean
}
export function GroupedToolUseContent({
message,
tools,
lookups,
inProgressToolUseIDs,
shouldAnimate
shouldAnimate,
}: Props): React.ReactNode {
const tool = findToolByName(tools, message.toolName);
const tool = findToolByName(tools, message.toolName)
if (!tool?.renderGroupedToolUse) {
return null;
return null
}
// Build a map from tool_use_id to result data
const resultsByToolUseId = new Map<string, {
param: ToolResultBlockParam;
output: unknown;
}>();
const resultsByToolUseId = new Map<
string,
{ param: ToolResultBlockParam; output: unknown }
>()
for (const resultMsg of message.results) {
const contentArr = resultMsg.message.content;
if (!Array.isArray(contentArr)) continue;
for (const content of contentArr) {
if (typeof content === 'string') continue;
for (const content of resultMsg.message.content) {
if (content.type === 'tool_result') {
resultsByToolUseId.set((content as ToolResultBlockParam).tool_use_id, {
param: content as ToolResultBlockParam,
output: resultMsg.toolUseResult
});
resultsByToolUseId.set(content.tool_use_id, {
param: content,
output: resultMsg.toolUseResult,
})
}
}
}
const toolUsesData = message.messages.map(msg => {
const contentArr = msg.message.content;
const rawContent = Array.isArray(contentArr) ? contentArr[0] : undefined;
const content = rawContent as ToolUseBlockParam;
const result = resultsByToolUseId.get(content.id);
const content = msg.message.content[0]
const result = resultsByToolUseId.get(content.id)
return {
param: content,
param: content as ToolUseBlockParam,
isResolved: lookups.resolvedToolUseIDs.has(content.id),
isError: lookups.erroredToolUseIDs.has(content.id),
isInProgress: inProgressToolUseIDs.has(content.id),
progressMessages: filterToolProgressMessages(lookups.progressMessagesByToolUseID.get(content.id) ?? []),
result
};
});
const anyInProgress = toolUsesData.some(d => d.isInProgress);
progressMessages: filterToolProgressMessages(
lookups.progressMessagesByToolUseID.get(content.id) ?? [],
),
result,
}
})
const anyInProgress = toolUsesData.some(d => d.isInProgress)
return tool.renderGroupedToolUse(toolUsesData, {
shouldAnimate: shouldAnimate && anyInProgress,
tools
});
tools,
})
}