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:
@@ -1927,9 +1927,9 @@ function applyPreservedSegmentRelinks(
|
||||
messages.set(uuid, {
|
||||
...msg,
|
||||
message: {
|
||||
...msg.message,
|
||||
...msg.message!,
|
||||
usage: {
|
||||
...msg.message.usage,
|
||||
...msg.message!.usage,
|
||||
input_tokens: 0,
|
||||
output_tokens: 0,
|
||||
cache_creation_input_tokens: 0,
|
||||
@@ -2131,7 +2131,7 @@ function recoverOrphanedParallelToolResults(
|
||||
// already in chain order, so later iterations overwrite → last wins.
|
||||
const anchorByMsgId = new Map<string, ChainAssistant>()
|
||||
for (const a of chainAssistants) {
|
||||
if (a.message.id) anchorByMsgId.set(a.message.id, a)
|
||||
if (a.message!.id) anchorByMsgId.set(a.message!.id, a)
|
||||
}
|
||||
|
||||
// O(n) precompute: sibling groups and TR index.
|
||||
@@ -2140,15 +2140,15 @@ function recoverOrphanedParallelToolResults(
|
||||
const siblingsByMsgId = new Map<string, TranscriptMessage[]>()
|
||||
const toolResultsByAsst = new Map<UUID, TranscriptMessage[]>()
|
||||
for (const m of messages.values()) {
|
||||
if (m.type === 'assistant' && m.message.id) {
|
||||
const group = siblingsByMsgId.get(m.message.id)
|
||||
if (m.type === 'assistant' && m.message!.id) {
|
||||
const group = siblingsByMsgId.get(m.message!.id)
|
||||
if (group) group.push(m)
|
||||
else siblingsByMsgId.set(m.message.id, [m])
|
||||
else siblingsByMsgId.set(m.message!.id, [m])
|
||||
} else if (
|
||||
m.type === 'user' &&
|
||||
m.parentUuid &&
|
||||
Array.isArray(m.message.content) &&
|
||||
m.message.content.some(b => b.type === 'tool_result')
|
||||
Array.isArray(m.message!.content) &&
|
||||
(m.message!.content as Array<{type: string}>).some(b => b.type === 'tool_result')
|
||||
) {
|
||||
const group = toolResultsByAsst.get(m.parentUuid)
|
||||
if (group) group.push(m)
|
||||
@@ -2164,7 +2164,7 @@ function recoverOrphanedParallelToolResults(
|
||||
const inserts = new Map<UUID, TranscriptMessage[]>()
|
||||
let recoveredCount = 0
|
||||
for (const asst of chainAssistants) {
|
||||
const msgId = asst.message.id
|
||||
const msgId = asst.message!.id
|
||||
if (!msgId || processedGroups.has(msgId)) continue
|
||||
processedGroups.add(msgId)
|
||||
|
||||
@@ -4357,7 +4357,7 @@ export function isLoggableMessage(m: Message): boolean {
|
||||
// user-configured hook output that is useful for session context on resume.
|
||||
if (m.type === 'attachment' && getUserType() !== 'ant') {
|
||||
if (
|
||||
m.attachment.type === 'hook_additional_context' &&
|
||||
m.attachment!.type === 'hook_additional_context' &&
|
||||
isEnvTruthy(process.env.CLAUDE_CODE_SAVE_HOOK_ADDITIONAL_CONTEXT)
|
||||
) {
|
||||
return true
|
||||
@@ -4370,8 +4370,8 @@ export function isLoggableMessage(m: Message): boolean {
|
||||
function collectReplIds(messages: readonly Message[]): Set<string> {
|
||||
const ids = new Set<string>()
|
||||
for (const m of messages) {
|
||||
if (m.type === 'assistant' && Array.isArray(m.message.content)) {
|
||||
for (const b of m.message.content) {
|
||||
if (m.type === 'assistant' && Array.isArray(m.message!.content)) {
|
||||
for (const b of m.message!.content as Array<{type: string; name: string; id: string}>) {
|
||||
if (b.type === 'tool_use' && b.name === REPL_TOOL_NAME) {
|
||||
ids.add(b.id)
|
||||
}
|
||||
@@ -4488,9 +4488,9 @@ export async function findUnresolvedToolUse(
|
||||
// Find the tool use but make sure there's not also a result
|
||||
for (const message of messages.values()) {
|
||||
if (message.type === 'assistant') {
|
||||
const content = message.message.content
|
||||
const content = message.message!.content
|
||||
if (Array.isArray(content)) {
|
||||
for (const block of content) {
|
||||
for (const block of content as Array<{type: string; id: string}>) {
|
||||
if (block.type === 'tool_use' && block.id === toolUseId) {
|
||||
toolUseMessage = message
|
||||
break
|
||||
@@ -4498,9 +4498,9 @@ export async function findUnresolvedToolUse(
|
||||
}
|
||||
}
|
||||
} else if (message.type === 'user') {
|
||||
const content = message.message.content
|
||||
const content = message.message!.content
|
||||
if (Array.isArray(content)) {
|
||||
for (const block of content) {
|
||||
for (const block of content as Array<{type: string; tool_use_id: string}>) {
|
||||
if (
|
||||
block.type === 'tool_result' &&
|
||||
block.tool_use_id === toolUseId
|
||||
@@ -4513,7 +4513,7 @@ export async function findUnresolvedToolUse(
|
||||
}
|
||||
}
|
||||
|
||||
return toolUseMessage
|
||||
return toolUseMessage as AssistantMessage | null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user