feat: 完成第二版类型清理

This commit is contained in:
claude-code-best
2026-03-31 23:03:47 +08:00
parent 4c0a655a1c
commit d7a729ca68
604 changed files with 595 additions and 953 deletions

File diff suppressed because one or more lines are too long

View File

@@ -139,6 +139,7 @@ import type {
ConnectedMCPServer,
MCPServerConnection,
McpSdkServerConfig,
McpStdioServerConfig,
ScopedMcpServerConfig,
ServerResource,
} from './types.js'
@@ -903,7 +904,7 @@ export const connectToServer = memoize(
)
logMCPDebug(name, `claude.ai proxy transport created successfully`)
} else if (
(serverRef.type === 'stdio' || !serverRef.type) &&
((serverRef as ScopedMcpServerConfig).type === 'stdio' || !(serverRef as ScopedMcpServerConfig).type) &&
isClaudeInChromeMCPServer(name)
) {
// Run the Chrome MCP server in-process to avoid spawning a ~325 MB subprocess
@@ -916,7 +917,7 @@ export const connectToServer = memoize(
const { createLinkedTransportPair } = await import(
'./InProcessTransport.js'
)
const context = createChromeContext(serverRef.env)
const context = createChromeContext((serverRef as McpStdioServerConfig).env)
inProcessServer = createClaudeForChromeMcpServer(context)
const [clientTransport, serverTransport] = createLinkedTransportPair()
await inProcessServer.connect(serverTransport)
@@ -924,7 +925,7 @@ export const connectToServer = memoize(
logMCPDebug(name, `In-process Chrome MCP server started`)
} else if (
feature('CHICAGO_MCP') &&
(serverRef.type === 'stdio' || !serverRef.type) &&
((serverRef as ScopedMcpServerConfig).type === 'stdio' || !(serverRef as ScopedMcpServerConfig).type) &&
isComputerUseMCPServer!(name)
) {
// Run the Computer Use MCP server in-process — same rationale as
@@ -941,23 +942,24 @@ export const connectToServer = memoize(
await inProcessServer.connect(serverTransport)
transport = clientTransport
logMCPDebug(name, `In-process Computer Use MCP server started`)
} else if (serverRef.type === 'stdio' || !serverRef.type) {
} else if ((serverRef as ScopedMcpServerConfig).type === 'stdio' || !(serverRef as ScopedMcpServerConfig).type) {
const stdioRef = serverRef as McpStdioServerConfig
const finalCommand =
process.env.CLAUDE_CODE_SHELL_PREFIX || serverRef.command
process.env.CLAUDE_CODE_SHELL_PREFIX || stdioRef.command
const finalArgs = process.env.CLAUDE_CODE_SHELL_PREFIX
? [[serverRef.command, ...serverRef.args].join(' ')]
: serverRef.args
? [[stdioRef.command, ...stdioRef.args].join(' ')]
: stdioRef.args
transport = new StdioClientTransport({
command: finalCommand,
args: finalArgs,
env: {
...subprocessEnv(),
...serverRef.env,
...stdioRef.env,
} as Record<string, string>,
stderr: 'pipe', // prevents error output from the MCP server from printing to the UI
})
} else {
throw new Error(`Unsupported server type: ${serverRef.type}`)
throw new Error(`Unsupported server type: ${(serverRef as ScopedMcpServerConfig).type}`)
}
// Set up stderr logging for stdio transport before connecting in case there are any stderr
@@ -3245,10 +3247,11 @@ async function callMCPTool({
}
function extractToolUseId(message: AssistantMessage): string | undefined {
if (message.message.content[0]?.type !== 'tool_use') {
const firstBlock = (message.message.content as ContentBlockParam[] | undefined)?.[0]
if (!firstBlock || typeof firstBlock === 'string' || firstBlock.type !== 'tool_use') {
return undefined
}
return message.message.content[0].id
return firstBlock.id
}
/**