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 / telemetry / hooks / gate / served / served.ts
19 lines · 701 BRaw
1import type { GateNext } from '../gate-next'
2import { REFUSED } from '../refused'
3import { SERVED_TIERS } from '../served-tiers'
4
5/**
6 * The gate on `telemetry.log` and `telemetry.mark`: a caller seated in
7 * SERVED_TIERS goes on beneath, any other is REFUSED; no origin throws.
8 *
9 * @param e the entry as the caller passed it
10 * @param next the hooks beneath, carrying who raised the call
11 * @returns what beneath answers, or the refusal
12 */
13export function served<E, R>(e: E, next: GateNext<E, R>): R | typeof REFUSED {
14 if (next.origin?.tier === undefined) {
15 throw new Error('$.telemetry: the call names no origin')
16 }
17
18 return SERVED_TIERS.includes(next.origin.tier) ? next(e) : REFUSED
19}