mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35:51 +00:00
feat: 全部类型问题解决
This commit is contained in:
@@ -45,6 +45,7 @@ import {
|
||||
formatPreconditionError,
|
||||
getRemoteTaskSessionUrl,
|
||||
registerRemoteAgentTask,
|
||||
type BackgroundRemoteSessionPrecondition,
|
||||
} from '../../tasks/RemoteAgentTask/RemoteAgentTask.js'
|
||||
import { assembleToolPool } from '../../tools.js'
|
||||
import { asAgentId } from '../../types/ids.js'
|
||||
@@ -668,7 +669,7 @@ export const AgentTool = buildTool({
|
||||
if (process.env.USER_TYPE === 'ant' && effectiveIsolation === 'remote') {
|
||||
const eligibility = await checkRemoteAgentEligibility()
|
||||
if (!eligibility.eligible) {
|
||||
const reasons = (eligibility as { eligible: false; errors: Array<{ type: string; message?: string }> }).errors
|
||||
const reasons = (eligibility as { eligible: false; errors: BackgroundRemoteSessionPrecondition[] }).errors
|
||||
.map(formatPreconditionError)
|
||||
.join('\n')
|
||||
throw new Error(`Cannot launch remote agent:\n${reasons}`)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import type {
|
||||
ContentBlock,
|
||||
ToolResultBlockParam,
|
||||
ToolUseBlockParam,
|
||||
} from '@anthropic-ai/sdk/resources/index.mjs'
|
||||
type BetaContentBlock = ContentBlock | ToolResultBlockParam
|
||||
import * as React from 'react'
|
||||
import { ConfigurableShortcutHint } from 'src/components/ConfigurableShortcutHint.js'
|
||||
import {
|
||||
@@ -555,7 +557,7 @@ export function renderToolUseProgressMessage(
|
||||
}
|
||||
const message = msg.data.message
|
||||
return message.message.content.some(
|
||||
content => content.type === 'tool_use',
|
||||
(content: BetaContentBlock) => content.type === 'tool_use',
|
||||
)
|
||||
})
|
||||
|
||||
@@ -630,7 +632,7 @@ export function renderToolUseProgressMessage(
|
||||
return false
|
||||
}
|
||||
return data.message.message.content.some(
|
||||
content => content.type === 'tool_use',
|
||||
(content: BetaContentBlock) => content.type === 'tool_use',
|
||||
)
|
||||
})
|
||||
|
||||
@@ -799,7 +801,7 @@ function calculateAgentStats(progressMessages: ProgressMessage<Progress>[]): {
|
||||
const message = msg.data.message
|
||||
return (
|
||||
message.type === 'user' &&
|
||||
message.message.content.some(content => content.type === 'tool_result')
|
||||
message.message.content.some((content: BetaContentBlock) => content.type === 'tool_result')
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1078,14 +1080,14 @@ export function extractLastToolInfo(
|
||||
const message = msg.data.message
|
||||
return (
|
||||
message.type === 'user' &&
|
||||
message.message.content.some(c => c.type === 'tool_result')
|
||||
message.message.content.some((c: BetaContentBlock) => c.type === 'tool_result')
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
if (lastToolResult?.data.message.type === 'user') {
|
||||
const toolResultBlock = lastToolResult.data.message.message.content.find(
|
||||
c => c.type === 'tool_result',
|
||||
(c: BetaContentBlock) => c.type === 'tool_result',
|
||||
)
|
||||
|
||||
if (toolResultBlock?.type === 'tool_result') {
|
||||
|
||||
@@ -78,7 +78,7 @@ export const FORK_AGENT = {
|
||||
export function isInForkChild(messages: MessageType[]): boolean {
|
||||
return messages.some(m => {
|
||||
if (m.type !== 'user') return false
|
||||
const content = m.message.content
|
||||
const content = m.message!.content
|
||||
if (!Array.isArray(content)) return false
|
||||
return content.some(
|
||||
block =>
|
||||
|
||||
@@ -267,7 +267,7 @@ export const NotebookEditTool = buildTool({
|
||||
}
|
||||
} else {
|
||||
// First try to find the cell by its actual ID
|
||||
const cellIndex = notebook.cells.findIndex(cell => cell.id === cell_id)
|
||||
const cellIndex = notebook.cells.findIndex((cell: NotebookCell) => cell.id === cell_id)
|
||||
|
||||
if (cellIndex === -1) {
|
||||
// If not found, try to parse as a numeric index (cell-N format)
|
||||
@@ -352,7 +352,7 @@ export const NotebookEditTool = buildTool({
|
||||
cellIndex = 0 // Default to inserting at the beginning if no cell_id is provided
|
||||
} else {
|
||||
// First try to find the cell by its actual ID
|
||||
cellIndex = notebook.cells.findIndex(cell => cell.id === cell_id)
|
||||
cellIndex = notebook.cells.findIndex((cell: NotebookCell) => cell.id === cell_id)
|
||||
|
||||
// If not found, try to parse as a numeric index (cell-N format)
|
||||
if (cellIndex === -1) {
|
||||
|
||||
@@ -519,9 +519,9 @@ export async function applyPromptToMarkdown(
|
||||
throw new AbortError()
|
||||
}
|
||||
|
||||
const { content } = assistantMessage.message
|
||||
if (content.length > 0) {
|
||||
const contentBlock = content[0]
|
||||
const { content } = assistantMessage.message!
|
||||
if (content!.length > 0) {
|
||||
const contentBlock = content![0]
|
||||
if (contentBlock && typeof contentBlock === 'object' && 'text' in contentBlock) {
|
||||
return (contentBlock as { text: string }).text
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user