feat: 问就是封包

This commit is contained in:
claude-code-best
2026-03-31 23:32:58 +08:00
parent d7a729ca68
commit dd9cd782a7
67 changed files with 423 additions and 172 deletions

View File

@@ -125,7 +125,7 @@ ${question}`
function extractSideQuestionResponse(messages: Message[]): string | null {
// Flatten all assistant content blocks across the per-block messages.
const assistantBlocks = messages.flatMap(m =>
m.type === 'assistant' ? m.message.content : [],
m.type === 'assistant' ? (m.message.content as unknown as Array<{ type: string; [key: string]: unknown }>) : [],
)
if (assistantBlocks.length > 0) {
@@ -136,7 +136,7 @@ function extractSideQuestionResponse(messages: Message[]): string | null {
// No text — check if the model tried to call a tool despite instructions.
const toolUse = assistantBlocks.find(b => b.type === 'tool_use')
if (toolUse) {
const toolName = 'name' in toolUse ? toolUse.name : 'a tool'
const toolName = 'name' in toolUse ? (toolUse as any).name : 'a tool'
return `(The model tried to call ${toolName} instead of answering directly. Try rephrasing or ask in the main conversation.)`
}
}
@@ -148,7 +148,7 @@ function extractSideQuestionResponse(messages: Message[]): string | null {
m.type === 'system' && 'subtype' in m && m.subtype === 'api_error',
)
if (apiErr) {
return `(API error: ${formatAPIError(apiErr.error)})`
return `(API error: ${formatAPIError(apiErr.error as any)})`
}
return null