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 / tests / fixtures / caught / unchecked.ts
21 lines · 742 BRaw
1import type { Args, EventResult, TraceEntry } from 'claude-code'
2
3/**
4 * The `tool.check` failure handler's `next` for a hook that had not called
5 * it: the call runs the links beneath, which settle as the trace lists.
6 *
7 * @param trace the run beneath, nearest the caller first
8 * @returns the stand-in, answering what the first link settled on
9 */
10export function unchecked(trace: readonly TraceEntry<'tool.check'>[]) {
11 const settled = trace[0]?.returned
12 const isUnsettled = settled === undefined
13
14 return Object.assign(
15 (_e: Args<'tool.check'>): Promise<EventResult<'tool.check'>> =>
16 isUnsettled
17 ? Promise.reject(new Error('nothing settled'))
18 : Promise.resolve(settled),
19 { trace, called: false },
20 )
21}