πŸ“„ File detail

utils/messagePredicates.ts

🧩 .tsπŸ“ 9 linesπŸ’Ύ 427 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œutils/”, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, …). On the API surface it exposes isHumanTurn β€” mainly functions, hooks, or classes. It composes internal code from types (relative imports). What the file header says: tool_result messages share type:'user' with human turns; the discriminant is the optional toolUseResult field. Four PRs (#23977, #24016, #24022, #24025) independently fixed miscounts from checking type==='user' alone.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

tool_result messages share type:'user' with human turns; the discriminant is the optional toolUseResult field. Four PRs (#23977, #24016, #24022, #24025) independently fixed miscounts from checking type==='user' alone.

πŸ“€ Exports (heuristic)

  • isHumanTurn

πŸ–₯️ Source preview

import type { Message, UserMessage } from '../types/message.js'

// tool_result messages share type:'user' with human turns; the discriminant
// is the optional toolUseResult field. Four PRs (#23977, #24016, #24022,
// #24025) independently fixed miscounts from checking type==='user' alone.
export function isHumanTurn(m: Message): m is UserMessage {
  return m.type === 'user' && !m.isMeta && m.toolUseResult === undefined
}