spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / sec-default / hooks / held-verdict / verdicts / ranking / handed-to.ts
17 lines · 671 BRaw
1import type { TraceEntry } from 'claude-code'
2
3/**
4 * The verdict handed up to one link of a run: what the nearest link beneath
5 * it that settled on anything settled on.
6 *
7 * Undefined for a link that answered without calling `next`: the trace ends
8 * short of the engine there, and nothing beneath it ran.
9 *
10 * @param trace a run as `next.trace` lists it, nearest the caller first
11 * @param at the link's place in that list
12 * @returns the verdict, or undefined when nothing settled beneath the link
13 */
14export const handedTo = (
15 trace: readonly TraceEntry<'tool.check'>[],
16 at: number,
17) => trace.slice(at + 1).find(link => link.returned !== undefined)?.returned