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 / under-ceiling.ts
26 lines · 864 BRaw
1import type { EventResult } from 'claude-code'
2
3import Verdicts from './verdicts'
4
5/**
6 * What the `tool.check` hook's failure handler answers on a tool under an
7 * organization's ceiling: its verdict when within the ceiling, else that.
8 *
9 * No verdict stays none, so a run that rejected still fails the call. Where
10 * the organization set no ceiling the verdict passes as it is.
11 *
12 * @param caught the verdict the handler would return, if it has one
13 * @param ceiling the question's `ceiling`, which the engine pins
14 * @returns the verdict the handler returns
15 */
16export function underCeiling(
17 caught: EventResult<'tool.check'> | undefined,
18 ceiling: string | undefined,
19) {
20 const isOver =
21 caught !== undefined &&
22 ceiling !== undefined &&
23 Verdicts.isOverCeiling(caught, ceiling)
24
25 return isOver ? Verdicts.uncheckedCeiling(ceiling) : caught
26}