mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 00:05:51 +00:00
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:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user