MCPcopy Index your code
hub / github.com/codeaashu/claude-code / isTerminalToolResult

Function isTerminalToolResult

src/utils/conversationRecovery.ts:348–373  ·  view source on GitHub ↗

* Is this tool_result the output of a tool that legitimately terminates a * turn? SendUserMessage is the canonical case: in brief mode, calling it is * the turn's final act — there is no follow-up assistant text (#20467 * removed it). A transcript ending here means the turn COMPLETED, not that *

(
  result: NormalizedUserMessage,
  messages: NormalizedMessage[],
  resultIdx: number,
)

Source from the content-addressed store, hash-verified

346 * interleaved.
347 */
348function isTerminalToolResult(
349 result: NormalizedUserMessage,
350 messages: NormalizedMessage[],
351 resultIdx: number,
352): boolean {
353 const content = result.message.content
354 if (!Array.isArray(content)) return false
355 const block = content[0]
356 if (block?.type !== 'tool_result') return false
357 const toolUseId = block.tool_use_id
358
359 for (let i = resultIdx - 1; i >= 0; i--) {
360 const msg = messages[i]!
361 if (msg.type !== 'assistant') continue
362 for (const b of msg.message.content) {
363 if (b.type === 'tool_use' && b.id === toolUseId) {
364 return (
365 b.name === BRIEF_TOOL_NAME ||
366 b.name === LEGACY_BRIEF_TOOL_NAME ||
367 b.name === SEND_USER_FILE_TOOL_NAME
368 )
369 }
370 }
371 }
372 return false
373}
374
375/**
376 * Restores skill state from invoked_skills attachments in messages.

Callers 1

detectTurnInterruptionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected