Every named declaration in the file, 833 of them, verbatim and in the order Claude Code wrote them, 50 to a page. This is the page to land on from a signature: a verb that returns ToolCallResult links here, at whichever page it is on, and what you get is the declaration itself rather than a description of it.
The source is 22,468 lines of TypeScript mined from build 2.1.330. Anything longer than 12 lines is folded; click the line count to open it. To find a name on another page, search every symbol.
Names on this page, 551 to 600 of 833
ThemeNoiseLayer interface
#
line 17219
Added in 2.1.329
A layer that is one burst of noise.
interface ThemeNoiseLayer extends ThemeLayerMix, ThemeLayerEnvelope {
wave: ThemeNoiseWave;
}
ThemeNoiseScatter interface
#
line 17227
Added in 2.1.329
Bursts of noise that fall at random, scatter times a second on average: 0.02 to 10.
interface ThemeNoiseScatter extends ThemeNoiseLayer {
scatter: number;
}
ThemeNoiseWave type
#
line 17235
Added in 2.1.329
Hiss to rumble, brightest first, and crackle: the ticks of rain on leaves, a fire or gravel.
type ThemeNoiseWave = 'white' | 'pink' | 'brown' | 'crackle';
ThemeNote type
#
line 17241
Added in 2.1.329
A pitch: a note name such as C5, F#3 or Bb2, a number of hertz from 20 to 10,000, or 0 for a rest.
type ThemeNote = string | number;
ThemeResult type
#
line 17253
Added in 2.1.319
What $.theme.set and $.theme.clear resolve to, and what a theme.set or theme.clear hook's { value } holds.
A theme that was set stands for the session either way, so a surface that attaches later draws it; a clear resolves isDrawn: false with its reason.
const set = await $.theme.set({ backdrop: { scene: "lagoon" } })
28 lines
export type ThemeResult = {
/**
* True: a client that says it draws the theme is attached. It says nothing of
* whether that client paints `colors`, follows `overrideColorScheme` or draws
* each part of a look.
*/
isDrawn: true;
/**
* `backdrop`, the `e.requestId` of every backdrop at `ui.render`, where
* `e.props.scene` and `e.props.plugin` say which; `theme` with no scene, a
* still ground included.
*/
requestId: string;
} | {
/**
* False: a client it needs is missing, or the theme was cleared. `reason`
* says which.
*/
isDrawn: false;
/**
* The theme's request id, when it stands for a surface yet to attach.
*/
requestId?: string;
/**
* Why nothing draws it, one line to show or log.
*/
reason: string;
};
ThemeScene type
#
line 17286
Added in 2.1.323 · changed in 2.1.324, 2.1.326
A live scene: what ui.render answers for Backdrop, and how the surface frosts its panels over it.
24 lines
export type ThemeScene = {
/**
* Names the scene among this plugin's: 1 to 64 of letters, digits, `_` and `-`.
* A `ui.render` hook reads it as `e.props.scene`.
*/
scene: string;
/**
* How the surface frosts its panels over the backdrop: absent, the default
* glass; `false`, the panels stay as they are.
*/
glass?: ThemeBackdropGlass | false;
/**
* A ground's key, which no scene has.
*/
color?: never;
/**
* A ground's key, which no scene has.
*/
gradient?: never;
/**
* A ground's key, which no scene has.
*/
vector?: never;
};
ThemeSetArgs type
#
line 17319
Added in 2.1.319 · changed in 2.1.321, 2.1.323, 2.1.329
The argument of $.theme.set: one object of named attributes, so a later attribute is an addition and never a change of the call.
A set names the whole theme, so what it leaves out is gone, and it names at least one attribute. An attribute the build does not know is refused by name, never dropped.
31 lines
export type ThemeSetArgs = {
/**
* What is behind the conversation: a live scene or a still ground. Absent, the
* app's own.
*/
backdrop?: ThemeBackdrop;
/**
* Overrides the person's own mode with `light` or `dark`, so a surface can draw
* its own text to suit. Absent, a surface
* acts as if it named the only mode `colors.inputs` gives, else the person's own
* stands. Set it for a look or a scene made for one mode, where `colors` gives
* both.
*/
overrideColorScheme?: 'light' | 'dark';
/**
* Every surface, word and line of the app, in each mode, by the design system's
* token names. The engine doesn't read it, so a wrong name paints nothing and says
* nothing.
*/
colors?: ThemeColors;
/**
* An ambience and short cues, which the desktop app plays once the person turns
* the theme's sound on. Absent, the theme is silent.
*/
sound?: ThemeSound;
/**
* How the desktop app draws the conversation's own rows: the type of messages,
* and the boxes around messages and tool calls. Absent, the app's own.
*/
style?: ThemeStyle;
};
ThemeSound type
#
line 17374
Added in 2.1.329
The sound attribute of $.theme.set: what the desktop app plays, on the person's own device, once they turn the theme's sound on.
It's numbers, never a recording: the app makes the sound from them. A sound out of range, or too much to work out, is refused with what to change: long releases, many notes and reverb cost the most. To change the mood, set the theme again: a new ambience fades in over the old. The mod is never told whether the sound played. A build that doesn't take sound, such as an older one, refuses the whole set, so catch that and set the theme again without it.
await $.theme.set({
backdrop: { scene: "pond" },
sound: {
ambience: { layers: [{ wave: "pink", drone: true, gain: 0.3 }] },
cues: {
done: { layers: [{ wave: "bell", notes: ["E5", "G5", "C6"], step: 0.1 }] },
},
},
})
44 lines
export type ThemeSound = {
/**
* Plays while the person is using the session's window. It stops while a
* permission prompt or a question waits, and during dictation, a voice call or
* a reply read aloud. Where the theme has cues too, the person can turn the
* ambience off and keep them.
*/
ambience?: ThemeAmbience;
/**
* What the app plays by itself at each of these moments.
*/
cues?: {
/**
* The person sent a message.
*/
send?: ThemeCue;
/**
* Claude began a tool call. It can come often, so keep it short and soft.
*/
tool?: ThemeCue;
/**
* The conversation was compacted.
*/
compact?: ThemeCue;
/**
* Claude finished its turn.
*/
done?: ThemeCue;
/**
* A permission prompt or a question appeared.
*/
ask?: ThemeCue;
/**
* The turn ended in an error.
*/
error?: ThemeCue;
/**
* The person clicked the backdrop where no part of the app covers it. Each
* layer plays one of its notes, the first at the left edge and the last at
* the right, so it takes no `step`.
*/
click?: ThemeCue;
};
};
ThemeStyle type
#
line 17442
Added in 2.1.329
The style attribute of $.theme.set: how the desktop app draws the conversation's own rows.
The words stay the app's text, so selecting, copying, finding and screen readers work as they do with no theme. A permission prompt, a question and a code block keep the app's look. A value out of range is refused with what to change, as is a style of over 1,500 values or 65,536 characters. A rule whose words are under 3:1 on what lies behind them, in the mode showing, draws in the app's own colors, and the other rules still draw. Every color of a fill counts as behind them. Over a backdrop any color can be behind them, so a text color needs an opaque enough fill under it. The mod is never told whether the style drew. A build that doesn't take style, such as an older one, refuses the whole set, so catch that and set the theme again without it.
await $.theme.set({
style: {
Text: { fontFamily: ["cursive"], fontSize: 18 },
UserMessage: { color: "#223", backgroundColor: "#fde68a", rotate: -1 },
},
})
24 lines
export type ThemeStyle = {
/**
* The words of both kinds of message.
*/
Text?: ThemeTypeRule;
/**
* Headings in a message, every level alike.
*/
Heading?: ThemeTypeRule;
/**
* The person's message. With a list of up to 4 rules, each message takes one
* of them and keeps it.
*/
UserMessage?: ThemeMessageRule | readonly ThemeMessageRule[];
/**
* Each run of words in Claude's reply, which has no box until a rule gives it
* one. It takes a list as `UserMessage` does.
*/
AssistantMessage?: ThemeMessageRule | readonly ThemeMessageRule[];
/**
* A tool call's row.
*/
ToolUse?: ThemeToolRule;
};
ThemeStyleColor type
#
line 17473
Added in 2.1.329
A color in style: any ThemeColor, or one of the four message colors that colors.inputs may give for each mode (ThemeColorInputs). Where the mode gives none, a bg- name draws as surface-2 and a text- name as text-primary.
type ThemeStyleColor = ThemeColor | 'bg-user-message' | 'text-user-message' | 'bg-assistant-message' | 'text-assistant-message';
ThemeTiling interface
#
line 17478
Added in 2.1.323
How a drawing or a gradient lies in its box.
13 lines
interface ThemeTiling {
/**
* `[width, height]` in points, such as `[24, 8]`: the box one copy fills under
* `repeat`, each side from 1 to 256. Absent, a drawing takes its own
* size, and a gradient fills its box.
*/
size?: readonly [number, number];
/**
* Tiles the art at its size.
* Absent, a drawing or a gradient stretches to the box.
*/
repeat?: boolean;
}
ThemeToneDrone interface
#
line 17495
Added in 2.1.329
Notes held together without a break.
interface ThemeToneDrone extends ThemeLayerMix {
wave: ThemeToneWave;
/**
* 1 to 16.
*/
notes: readonly ThemeNote[];
drone: true;
}
ThemeToneLayer interface
#
line 17507
Added in 2.1.329
A layer that plays its notes and ends, within 4 seconds.
16 lines
interface ThemeToneLayer extends ThemeLayerMix, ThemeLayerEnvelope {
wave: ThemeToneWave;
/**
* 1 to 16.
*/
notes: readonly ThemeNote[];
/**
* Seconds from one note to the next: 0 to 2. Absent, a cue plays the notes
* together, and a scatter picks one for each hit.
*/
step?: number;
/**
* Semitones each note slides by over its life: -24 to 24.
*/
glide?: number;
}
ThemeToneScatter interface
#
line 17527
Added in 2.1.329
Notes that fall at random, scatter times a second on average: 0.02 to 10.
interface ThemeToneScatter extends ThemeToneLayer {
scatter: number;
}
ThemeToneWave type
#
line 17534
Added in 2.1.329
What a note is played on.
type ThemeToneWave = 'sine' | 'triangle' | 'square' | 'saw' | 'bell';
ThemeToolRule interface
#
line 17540
Added in 2.1.329
How a tool call's row looks: its box, and the color and generic font of its words.
export interface ThemeToolRule extends ThemeBoxRule {
/**
* Over a backdrop, this draws only on an opaque enough fill.
*/
color?: ThemeStyleColor;
fontFamily?: readonly [ThemeGenericFont];
}
ThemeTypeRule interface
#
line 17552
Added in 2.1.329
How a part's words look. Lengths are numbers of points, and a property left out keeps the app's own value.
26 lines
export interface ThemeTypeRule {
/**
* Over a backdrop, this draws only on an opaque enough fill.
*/
color?: ThemeStyleColor;
/**
* A list of one generic font, such as `["serif"]`. The person's accessibility
* settings win (a font, higher contrast), and the app tells them so.
*/
fontFamily?: readonly [ThemeGenericFont];
/**
* 11 to 28.
*/
fontSize?: number;
fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold';
italic?: boolean;
/**
* -1 to 4.
*/
letterSpacing?: number;
/**
* 12 to 48, and no less than `fontSize`. It's points, not a multiple: `24`,
* never `1.5`.
*/
lineHeight?: number;
}
ThemeVector interface
#
line 17582
Added in 2.1.323
A drawing in SVG path data, the text of a path's d attribute.
22 lines
interface ThemeVector extends ThemeTiling {
/**
* A square's side, or `[width, height]`, from 1 to 256.
*/
viewBox: number | readonly [number, number];
/**
* At most 64 paths. A string or `{ d }` is filled by the even-odd rule, and
* `{ d, strokeWidth }` is stroked at a width that doesn't scale, above 0 and at
* most 64. A surface refuses a ground whose `d` isn't whole path data of at most
* 16,384 characters, with no number past 1,000,000 either way.
*/
paths: readonly (string | {
d: string;
strokeWidth?: number;
color?: ThemeColor;
})[];
/**
* Each path's color, where it names none of its own: a path with neither draws
* nothing, and a surface refuses a drawing left with no path.
*/
color?: ThemeColor;
}
ThemeVectorGround interface
#
line 17605
Added in 2.1.323 · changed in 2.1.324, 2.1.326
interface ThemeVectorGround extends ThemeGroundBase {
vector: ThemeVector;
color?: never;
gradient?: never;
}
Tier type
#
line 17673
Added in 2.1.271
One of the chain's five tiers (TIERS), outermost first; on every next.trace entry, and what next.to(e, tier) names.
prepend and append are the plugins an administrator manages. With no managed settings, they are a person's own plugins listed in user settings, except where plugin-authoring's reference says that list is set aside. user is every other plugin a person installs, builtin the plugins bundled in the binary, core the engine's innermost link. --safe-mode and --bare keep an organization's tiers: they turn off what a person installed.
Under an organization's managed settings, a plugin from a marketplace with a remote source (github, git, url or inline settings) takes the organization's tier, with a hooks module or without, when those settings set it true in enabledPlugins and declare that marketplace in extraKnownMarketplaces. Missing either, it stays in user. prependPlugins and appendPlugins set the order: in neither, it is prepend, after the listed ones. A marketplace's pluginDigests is deprecated and ignored, so a new release reaches machines with no settings change.
Claude Code stores a hash (copyHash) on such a plugin's install record when it writes a copy from the marketplace's declared origin that fits this build, and checks the copy against it at each load, so an edit made after that is caught. A copy that doesn't match is fetched afresh once before the first turn. Some starts run no fetch, such as --bare or a session with hooks modules off (a managed disableAllHooks). Under --safe-mode, a listed mod with an unmet dependency stays out until a normal start. Where a fetch ran and the copy still isn't mended, the session carries on and the debug log says listed mod <id> does not run in this session: <why>. A copy that doesn't match runs without its hooks module, and a copy outside its engines["claude-code"] range is off whole.
That is a listed mod's road. An unlisted plugin's version moves only by an update, and no start waits on a fetch for it: with no hash yet, or a copy that doesn't match, it runs in user, module included. Behind the start, the commit its record names is fetched and compared with its folder. The same files earn the hash, and the tier at the next start or reload. A folder that differs (an edit, a file the plugin wrote there) is never repaired: it stays in user until an update or a reinstall. So does one whose record names no commit, or one its marketplace's ref does not hold, or that comes from a repository of its own. A fetch that fails is tried again a day later, and so is a folder that changed and still differs. A one-shot -p run and essential-traffic mode fetch nothing. Ahead of every check, the __pycache__ folders in a cached copy are removed.
A plugin plugin.register marks requiredByOrganization is judged there in the organization's tier when it has no hooks module and is shown to be outside every dev-mods folder and what a link in one leads to (a zip by where it is unpacked). Nothing proves that mark, so it moves neither a module's tier nor the tier an event's provider reads.
A $ call runs through every hook but the calling one, except as follows. A person's hooks don't hear a call an organization's mod makes, or what is raised beneath it while it runs. The organization's mods are those it seats in prepend or append and those it requires in user. So an organization's mod can't call a tool or command a person's mod registered. A noun still answers, and what it raises is its owner's: the organization's hooks, the calling one too, hear a person's. A person's hooks hear what such a call hands on: a model's loop, a skill's inline command, and what goes on once it has answered. A tool.list removal holds for every caller, so the engine asks a person's tool.list hooks about an organization's tool call too. What the engine raises itself is no mod's call.
export type Tier = (typeof TIERS)[number];
TIERS const
#
line 17682
Added in 2.1.267
The chain's five tiers, outermost first: earlier is outer is more authority, and same-event hooks nest in this order and no other way.
Tier says which plugins are in each; a built-in's $ calls still raise everywhere.
const TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
Timer type
#
line 17687
In the first published surface (2.1.259)
A pending timer from $.clock.after / $.clock.every.
export type Timer = {
/**
* Stops it; a stopped timer never fires again.
*/
cancel: () => void;
};
TimerCall type
#
line 17698
In the first published surface (2.1.259)
A timer on $.clock (after, every): fn runs after ms milliseconds, once or until cancel().
export type TimerCall = (ms: number, fn: () => void) => Timer;
ToastOptions type
#
line 17703
In the first published surface (2.1.259)
Options of $.ui.toast.
export type ToastOptions = {
/**
* How long the line stays, in milliseconds; default 4000.
*/
timeoutMs?: number;
};
ToolCallArgs type
#
line 17716
In the first published surface (2.1.259) · changed in 2.1.267
tool.call's input as the call takes it: tool_use_id and agentId may ride along (a hook passing its event's input on) and are dropped.
The run gets its own id and runs in the session's loop.
export type ToolCallArgs = ToolCallEnvelope extends infer I ? I extends ToolCallEnvelope ? Omit<I, 'tool_use_id'> & ToolCallReserved<I['tool']> : never : never;
ToolCallEnvelope type
#
line 17726
Added in 2.1.267
The envelope the two tool events share: the tool, the id of this call, and the tool's arguments spread beside them (e.command for Bash).
A union discriminated by tool: after if (e.tool === "Bash"), e.command is a string and a rewrite is checked against Bash's schema. The e of classic.PreToolUse exactly; tool.call's adds the loop (ToolCallInput).
export type ToolCallEnvelope = BuiltinToolCallInput | McpToolCallInput;
ToolCallInput type
#
line 17737
In the first published surface (2.1.259) · changed in 2.1.267, 2.1.295
The input of tool.call and tool.run: the tool, the call's id, the tool's arguments beside them (e.command for Bash), and agentId in a subagent.
A union discriminated by tool: after if (e.tool === "Bash"), e.command is a string and a rewrite is checked against Bash's schema. tool, tool_use_id and agentId are reserved: a rewrite of any is refused. requestMeta is a hook's to set (ToolRequestMeta). tool.run pins it all.
export type ToolCallInput = ToolCallEnvelope & AgentLoop & ToolRequestMeta;
ToolCallOverloads type
#
line 17743
Added in 2.1.260
$.tool.call(input): resolves with result typed for the tool input names (ToolCallResult), or loosely for an input that names none literally.
type ToolCallOverloads = {
<T extends string>(input: ToolCallArgs & ToolNamed<T>): Promise<ToolCallResult<T>>;
(input: ToolCallArgs): Promise<ToolCallResult>;
};
ToolCallReserved type
#
line 17760
In the first published surface (2.1.259)
The keys tool.call's input carries beside the tool's own arguments, none of which the tool sees (the engine strips them before the tool runs).
consent is the person's own words for the press that raised the call (The user pressed "1: Yes" on ...). It joins the run's context as a human turn, which the permission path reads as the user's request, only when the call answers the person's press, input or pick on this plugin's own element (not one in a desktop Client): made by that element's closure, or by this plugin's hook on that event, before it returns or times out, with no Stop standing since the gesture. Any other call runs as it would without consent.
export type ToolCallReserved<T> = {
tool: T;
tool_use_id?: string;
consent?: string;
};
ToolCallResult type
#
line 17777
In the first published surface (2.1.259) · changed in 2.1.260, 2.1.280
What a tool.call or tool.run hook returns and what next(e) and $.tool.call(input) resolve to: { result, context? } or { deny }.
From core the result is { ref, result, text } or, when the tool reported an error, { ref, result, text, isError }, either with isReadOnly when the tool held the input it ran read-only; ref names core's messages.
90 lines
export type ToolCallResult<Name extends string = string> = {
/**
* Refuses the call: the model receives the text as an error result.
* Absent when the call was answered.
*
* Returned after the tool answered without error it withholds that
* result and undoes nothing: in its place the model reads `<tool> ran,
* and a plugin withheld its result: <text>`.
*/
deny: string;
result?: undefined;
context?: undefined;
ref?: undefined;
text?: undefined;
isError?: undefined;
isReadOnly?: undefined;
} | {
/**
* The tool's output: from core the tool's record, typed per built-in
* tool once `e.tool` and `isError` are narrowed; from a hook, its own.
*
* Core validates a hook's answer against the tool's output schema when
* it has one, maps it for the model with the tool's own mapper, and
* records it in the transcript as the tool's result. Absent on a deny.
*/
result: ToolResultOf<Name>;
/**
* What the model reads after the tool's result and the user never
* sees. From core, none; what `tool.run`'s hooks attach goes ahead of it.
*
* One reminder, as a PostToolUse hook's is, after the managed tier's
* review; none on a plugin's own `$.tool.call`. Kept whole from `next`,
* none empty, any length: past 100,000 (200,000 together) head + path.
*/
context?: readonly string[];
/**
* Set by core on what `next(e)` resolves to: names the messages core
* produced for the call (they stay on the host side).
*
* A hook that returns the object it got makes core use them verbatim.
* Absent on a hook's own `{ result }` and on a deny.
*/
ref?: number;
/**
* Set by core: the result as the model reads it (text blocks joined),
* present whatever the tool, where `result`'s shape varies per tool.
*
* Absent on a hook's own `{ result }`.
*/
text?: string;
/**
* Set by core, present only when the tool held the input it executed
* read-only by its own check (the one its permissions use).
*
* It speaks for this call as run, rewrites included, not for calls it
* causes (a subagent's tools raise their own `tool.call`); for an MCP
* tool, its server's declaration. Bash `ls`: set; a hook's own: never.
*/
isReadOnly?: true;
isError?: undefined;
deny?: undefined;
} | {
/**
* Set by core, present only when the tool reported an error (it threw,
* was interrupted, or answered an error): `text` is what the model read.
*/
isError: true;
/**
* What the transcript stored for the errored call: the error text, or
* undefined when nothing was stored; never the tool's typed record.
*/
result: unknown;
/**
* The error as the model reads it.
*/
text?: string;
/**
* As on an answered result: names the messages core produced.
*/
ref?: number;
/**
* As on an answered result.
*/
context?: readonly string[];
/**
* As on an answered result: the tool held the input it ran read-only.
*/
isReadOnly?: true;
deny?: undefined;
};
ToolCheckApprover type
#
line 17874
Added in 2.1.307
Who answers the asks of a tool.check evaluation.
host, the program that answers a hosted session's asks or a served call's own session; person, a dialog or a card the person answers.
type ToolCheckApprover = 'host' | 'person';
ToolCheckArgs type
#
line 17881
Added in 2.1.269
tool.check's input as $.tool.check takes it: the tool and its arguments; the call's id, agentId, ceiling, isCeilingUnread, approver and isReadOnly are the engine's to set.
type ToolCheckArgs = Pick<ToolCheckInput, 'tool' | 'input'>;
ToolCheckDecision type
#
line 17888
Added in 2.1.269
The verdict of tool.check: run the tool, put it to the mode's decider (the dialog, the auto-mode classifier, a headless host) or, a hook's ask, to a person, or refuse it.
type ToolCheckDecision = 'allow' | 'ask' | 'deny';
ToolCheckInput type
#
line 17898
Added in 2.1.269 · changed in 2.1.290, 2.1.304, 2.1.307, 2.1.328
The input of tool.check: the tool, its arguments, the organization's ceiling if it set one, and on a real call its id and the loop's agentId.
All are the question's identity and are pinned: a hook decides about this call, it does not change it (tool.call rewrites a call). A $.tool.check query is asked outside any loop and carries no agentId.
88 lines
type ToolCheckInput = {
/**
* As the model names it (`Bash`, `mcp__server__tool`); the key a matcher
* narrows on.
*
* A matcher on any name the host declares for the tool admits it.
*/
tool: string;
/**
* The tool's arguments as the permission decision reads them
* (`{ command }` for Bash, `{ file_path, ... }` for the file tools).
*/
input: unknown;
/**
* The call being decided; absent on a query, with `op`, and on an MCP call
* that goes straight to its server (a settings hook's, a `Monitor` watch).
*
* `next.origin` names who raised it: `{ plugin: 'engine', tier: 'core' }`
* for the model's own call, the plugin for its `$.tool.call` or its query,
* `hook:<event>` for a settings `mcp_tool` hook's call. Nobody is asked
* about a call that goes straight out: a deny refuses it, an ask lets it
* run. A refused hook fails, and the call it guards goes on unless the hook
* sets `onFailure: "block"`.
*/
tool_use_id?: string;
/**
* The id of the loop the call is decided in, on a real call inside a
* subagent's or a teammate's loop: the one its `tool.call` carried.
*
* Absent on the main loop and on a query. Which loop, not which plugin
* caused the call (that is `next.origin`).
*/
agentId?: string;
/**
* The most permissive verdict the organization lets the model's call of an
* MCP tool reach: `ask`, or `deny` where an administrator blocked the tool.
* On a plugin's or a settings hook's own call of any tool, also `deny` where
* a managed deny rule covers this input as it would the model's, or covers
* the line it types at Claude Desktop's Terminal as it would in `Bash`.
*
* `deny` is a block on the tool or its connector for the organization or
* the member's role, a host's `always_deny`, or a managed deny rule; not a
* rule or a switch of the person's or a repository's. Behind an SSH host's
* launcher for Claude Desktop, or where `--managed-settings` cannot be read,
* any deny sent as `--settings` or `--disallowedTools` counts as managed,
* the person's switch included; at Desktop's other starts, the second on a
* plugin's own call and on any such line. The engine holds no plugin's or
* settings hook's own call to it: a hook here may.
*
* Set by the engine, never by a query, and pinned. A hook's own `ceiling`,
* on its answer, is dropped. Absent where none is set.
*/
ceiling?: ToolCheckDecision;
/**
* Set by the engine on a plugin's or a settings hook's own call, and pinned:
* managed deny rules exist, and whether one covers the call can't be told.
*
* Matching them failed or stopped short, or they bind only where or as the
* tool runs. The engine refuses nothing on it: a hook here may.
*/
isCeilingUnread?: true;
/**
* Set by the engine, and pinned, where no tool is called: the plugin's call
* on `$` that `tool` and `input` stand for, as it is about to run.
*
* Raised only with `ceiling: "deny"` or `isCeilingUnread`, and only to a hook
* whose matcher names `op`. A file call reads as `Read` or `Write`, a process
* as the `Bash` line of its argv. Nobody is asked: a deny refuses the call.
* Where a hook rewrote the call, `next.origin.tier` is `user`.
*/
op?: 'fs.read' | 'fs.list' | 'fs.write' | 'process.run' | 'process.spawn';
/**
* Who answers this evaluation's asks, known before any hook runs.
*
* `host` where a host's permission callback does, `person` where a person
* can be asked, a pane's card included; absent where nobody can be. Pinned.
*/
approver?: ToolCheckApprover;
/**
* Set by the engine, present only when the tool's own `isReadOnly` holds
* this input read-only, and pinned; a matcher can select reads, never writes.
*
* Absent also means the tool cannot say: a careful hook reads it as a write.
* It is the tool's word, no proof of no effect (a fetch, a sent message, an
* agent that delegates all say it); an MCP tool's is its server's, unproven.
*/
isReadOnly?: true;
};
ToolCheckResult type
#
line 17995
Added in 2.1.269 · changed in 2.1.289, 2.1.290, 2.1.300, 2.1.307
What a tool.check hook returns and what next(e) resolves to: the verdict, why, and what stands behind it, never who answers it.
From core, the engine's declarative decision for the session's mode and rules. A hook may answer any verdict in either direction; the last word up the chain is the decision.
68 lines
type ToolCheckResult = {
/**
* `allow` runs the tool; `ask` puts it to the mode's decider, or to a
* person when a hook made it (`plugin`); `deny` refuses it, the reason the
* model's error.
*
* For a tool that requires the person (a question put to them, a plan to
* approve) a hook only tightens: its `allow` does not dismiss the dialog.
* In plan mode a hook only tightens a call not shown to be a read, too.
* For a tool only auto mode's classifier may allow (a subagent's report) a
* hook's `allow` is ignored and core's verdict stands, except on a mod's
* own `$.tool.call`.
*/
decision: ToolCheckDecision;
/**
* Why, in a sentence: from core the rule or check that decided; from a
* hook, what the model reads on a deny and the dialog shows on an ask.
*/
reason?: string;
/**
* The settings rule that decided, as written (`Bash(git push:*)`).
*
* Absent for a mode or a tool's own check.
*/
rule?: string;
/**
* The classic hook event that decided, or whose ask the verdict was reached
* under (`PreToolUse`), whoever configured the hook.
*
* Absent on a `$.tool.check` query, which runs no classic hook.
*/
hook?: string;
/**
* The key of the option whose own check asked, whoever configured it
* (`permissions.blockReadsOutsideWorkingDirectories`).
*
* From core, for the read block: its ask on a shell command that reads
* outside the working directories or, the block on, leaves the sandbox.
*/
setting?: string;
/**
* The plugin whose hook made this ask, set by the engine and pinned:
* whatever a hook writes here is dropped.
*
* On an `ask` a hook answered, rewording included; one it hands up as it
* heard it keeps what it carried, so core's own names none. Such an ask is
* a person's: the dialog, the host's callback or a PermissionRequest hook
* answers. No classifier's allow settles it, its block still refuses, and
* a rule for the whole tool is not kept; a narrower rule the person saves
* is theirs and settles nothing while the hook asks. Where nobody can be
* asked it is a deny, this verdict's reason the model's error. A tool no
* prompt is raised for keeps its own rule. A hook above may answer anything
* over it.
*/
plugin?: string;
/**
* The most permissive verdict the organization lets the model's call of an
* MCP tool reach: `ask`, or `deny` where an administrator blocked the tool,
* or where a managed deny rule covers a plugin's own call of any tool.
*
* The question's own (`e.ceiling`), set by the engine, on
* every verdict for it, core's and each hook's alike: a hook's own
* `ceiling` is dropped. Where the question has none, it is the one that
* core's check found for this call, on core's verdict and on each hook's
* that asked beneath. Absent where none is set.
*/
ceiling?: ToolCheckDecision;
};
ToolDeferral type
#
line 18070
Added in 2.1.277
Where a tool.describe answer places the tool: true behind ToolSearch (its schema loads when the model asks for it), false in the prompt's list.
Left out of an answer, the placement beneath stands.
export type ToolDeferral = boolean;
ToolDescribeInput type
#
line 18076
In the first published surface (2.1.259) · changed in 2.1.267, 2.1.277, 2.1.326
The input of tool.describe: one tool's description, at the moment the engine first renders the tool's schema for the model.
36 lines
export type ToolDescribeInput = {
/**
* As the model sees the name (`Bash`, `mcp__server__tool`); the key a
* matcher narrows on.
*/
tool: string;
/**
* The tool's description as it computed it.
*/
description: string;
/**
* Present, and true, when the engine lists the tool behind ToolSearch (its
* schema loads when the model asks for it by name); absent for one listed.
*
* By the engine's rule an MCP server's tool, or one that asks to be,
* unless a rule keeps it in front (a plugin's `$.tool.register` tool
* whose spec says `isDeferred: false` is kept in front).
*/
isDeferred?: true;
/**
* Who provides this tool: the plugin and its tier; `{ plugin: "engine",
* tier: "core" }` for a built-in. Pinned: a rewrite is refused.
*
* A configured MCP server's tool is `mcp:<server>`, in `prepend` when the
* policy settings source configures the server, else `user`.
*/
provider: Origin;
/**
* The MCP server this tool comes from, off the connection that listed it, so
* no config file need be read and a server added at runtime is covered.
* Absent on any other tool, a built-in or a `tool.list` hook's among them, and
* on an MCP tool whose server facts are not known. Pinned: a rewrite that
* changes or adds it is refused, and one that leaves it out has it restored.
*/
mcpServer?: ToolMcpServer;
};
ToolDescribeResult type
#
line 18121
In the first published surface (2.1.259) · changed in 2.1.277, 2.1.321
What a tool.describe hook returns: the description the model sees for that tool and, when the hook moves it, where the tool waits (ToolDeferral).
{ description } alone, or { ...(await next(e)), description }, changes the text and keeps the engine's placement; isDeferred: true puts the tool behind ToolSearch, isDeferred: false puts its schema in the prompt's list.
export type ToolDescribeResult = {
description: string;
isDeferred?: ToolDeferral;
/**
* Sends a changed description or placement at the next turn, rewriting the
* whole prompt cache and dropping the model's earlier thinking.
*
* Left out, a description waits for a new thread or a compaction, and a
* placement for a new thread or `/clear`, as a compaction keeps the tool block.
*/
breakPromptCache?: boolean;
};
ToolEnvelope type
#
line 18138
In the first published surface (2.1.259)
{ tool, tool_use_id, ...args } as one flat object type, generic over the tool name and its parsed arguments.
type ToolEnvelope<Name, Arguments> = {
/**
* The name of the tool being called (`Bash`, `mcp__<server>__<tool>`);
* comparing it narrows `e`. Reserved: a rewrite of it is ignored by core.
*/
tool: Name;
/**
* The tool_use block's id: the same at every event of the call and in
* `$.ui.notice`. Reserved: a rewrite of it is ignored by core.
*/
tool_use_id: string;
} & Arguments;
ToolGroupCall type
#
line 18154
In the first published surface (2.1.259) · changed in 2.1.260, 2.1.268
One tool call of a ToolGroup, as ui.render sees it under calls.
33 lines
export type ToolGroupCall = {
/**
* The id `tool.call` carried for this call (`e.tool_use_id` there), so a
* hook that saw the call finds its row in the group. Read-only.
*
* Absent on a desktop host that predates it.
*/
tool_use_id?: string;
/**
* Which one the call ran (`Bash`, `Read`, `Grep`, ...).
*/
tool: string;
/**
* The call's input, as the model sent it.
*/
input: unknown;
/**
* True while the call is still running.
*/
isRunning: boolean;
/**
* True when the call ended in an error.
*/
isErrored: boolean;
/**
* True when an abort ended the call, as on `ToolUse`.
*/
isInterrupted: boolean;
/**
* As on `ToolUse`; undefined while the call runs.
*/
output?: unknown;
};
ToolInfo type
#
line 18266
In the first published surface (2.1.259) · changed in 2.1.323
One tool as $.tool.list() returns it and a tool.list hook answers it.
What the hooks answer the engine's own raise is the session's tool pool: for the model, every agent, foreground or background, ToolSearch and $.tool.call, which also reaches a tool only a deny rule or a blocked ceiling hides, but a hook's removal stops it. A removal deletes the tool from the session, for mods too, even one a deny rule or a ceiling also hides, while a deny rule or a ceiling stops only the model and its agents. The tools of an MCP server that joins later are asked about before a request carries them. What the hooks answer a mod's $.tool.list() is only what that call reads. next(e) holds the tools as the engine built them, with what an earlier answer removed and without what it added, so answer the whole list each time. The order of the list is ignored, so that the prompt cache holds.
The engine raises the event before a thread's first request, once a load of hooks modules is over or 10 seconds have passed, and again when the loaded plugins, the names of the tools or a setting change, or at the turn after $.ui.invalidate('tool.list'). It never raises it per turn: a pool that moves breaks the prompt cache.
Leave an entry out and the tool goes, with what a deny rule on it takes out; what such a rule brings back, such as Glob and Grep without Bash, is asked about too. A tool no deny rule can leave out stays while any other does. A call of a removed tool is refused, by a script, an agent, the host's mcp_call, an mcp_tool settings hook or a Monitor poll, and a running watch of it ends. Those last three don't wait for a hooks load, so one made before a module has loaded isn't refused by what that module removes. A tool a thread already declared stays declared until a compaction, so as not to break the prompt cache, and a call of it is refused saying why. $.ui.ask and $.agent.spawn are the host's: removing their tools does not reach them.
Add { name, description, mcp: false, inputSchema? } under a new name and the tool joins, checked as $.tool.register checks a spec: an entry that fails is left out. A tool.call hook on its name answers its calls, with no permission prompt; a call no hook answers is a tool error naming it. A schema the API refuses is declared with no parameters. New words reach a thread at its next compaction. An mcp__ name, a name a request declares itself (advisor, DeferredToolPlaceholder), or a tool's or a built-in's name in any case or with its words apart, on or off, cannot be added. An entry with the name or alias of a tool that exists leaves that tool as it is: tool.describe changes a description. A deny rule, a --tools list and an agent's tools: hold over an added tool as over any other, a deny rule for the model and its agents alone ($.tool.call says so), and a real tool takes its name when it joins.
A hook that throws, crashes or runs past its 10-second budget is skipped, unless its .catch answers: the answer is what the others said, without what the hook removed or added on any run, and the event is raised again at the next turn. So is one whose $ ops hold it past 30 seconds in all: they are aborted. A crash traced to a mod can unload it, and a mod's removals lapse when it is unloaded, with no retry owed. A { deny } or a list with nothing in it to read leaves the last answer standing, and the event is raised again at the next turn. A turn waits at most 10 seconds for a raise, then goes on with the answer that stood, or the tools as built before the first; the raise goes on, and its answer counts unless a later raise has answered. A $.tool.call of a tool.list hook doesn't wait for the raise: the other hooks are asked about it, and a list that leaves the tool out refuses it, as does a removal that stood; an agent the hook spawns reads the answer that stood, or the tools as built on the first raise. $.prompt.submit and $.command.run are refused there.
Where sec-default is seated, a person's hook can't remove a tool of the organization's managed MCP servers or seated plugins, or bring back a tool an organization's hook removed. Its addition is dropped while managed allowedMcpServers is set, or where the name reads as a tool the organization delivers. A person's hook that overruns or crashes is skipped and sec-default still answers, though that hook can delay the answer. The engine puts no other limit on the answer; a policy is a mod's to hold.
on('tool.list', async ($, e, next) => {
const listed = await next(e)
return listed.value === undefined
? listed
: { value: listed.value.filter(t => t.name !== 'AskUserQuestion') }
})
21 lines
export type ToolInfo = {
/**
* What the model calls it by.
*/
name: string;
/**
* What it does, in the tool's own words (its description; a first sentence at
* most for MCP tools without one).
*/
description: string;
/**
* True for an MCP server's tool.
*/
mcp: boolean;
/**
* On an entry a `tool.list` hook adds: a JSON schema object for the input
* (`{ type: "object", properties, required }`), default `{ type: "object" }`
* as on `$.tool.register`. Never on a tool the session lists.
*/
inputSchema?: Record<string, unknown>;
};
ToolInputOf type
#
line 18294
In the first published surface (2.1.259)
{ tool, tool_use_id, ...args } as one flat object type.
The docs of tool and tool_use_id live on the keyof operand: a mapped type takes its properties' docs from there.
export type ToolInputOf<Name extends string, Arguments> = {
[K in keyof ToolEnvelope<Name, Arguments>]: ToolEnvelope<Name, Arguments>[K];
};
ToolJudgeInput type
#
line 18302
Added in 2.1.326
The input of tool.judge: tool.check's question about a real call. All of it is pinned.
type ToolJudgeInput = ToolCheckInput & {
/**
* The call being judged: the id its `tool.call` and `tool.check` carried.
*
* `next.origin` names a plugin only on its own `$.agent.call`, where its
* allow stands in the classifier's place; on any other call, the engine.
*/
tool_use_id: string;
};
ToolJudgeResult type
#
line 18316
Added in 2.1.326
What a tool.judge hook returns and what next(e) resolves to: a verdict on one call, why, and whose it is.
25 lines
type ToolJudgeResult = {
/**
* From the classifier: `allow` and `deny` are its verdict, `ask` says it
* gave none (an outage, a conversation too long, a session without one).
*
* From a hook: `deny` refuses the call, `ask` puts it to a person (a deny
* where nobody can be asked), and `allow` runs it in the classifier's place
* on a call this plugin made with `$.agent.call` and no hook rewrote. Any
* other allow is held to what a `tool.check` hook's is, and so is one on a
* write in plan mode or a call auto mode always judges by itself.
*/
decision: ToolCheckDecision;
/**
* Why, in a sentence: the classifier's own, or what the caller reads on a
* hook's deny. The dialog shows it on an ask the tool gave no reason for.
*/
reason?: string;
/**
* The plugin whose hook made this answer, set by the engine and pinned:
* whatever a hook writes here is dropped. Absent for the classifier.
*
* An answer a hook hands up as it heard it keeps what it carried.
*/
plugin?: string;
};
ToolMcpServer type
#
line 18352
Added in 2.1.326
The MCP server a tool comes from, as tool.describe reports it (ToolDescribeInput.mcpServer).
on("tool.describe", ($, e, next) => {
if (e.mcpServer?.origin === "https://gateway.corp.example") tag(e.tool)
return next(e)
})
29 lines
export type ToolMcpServer = {
/**
* The transport in the server's config. A config with no `type` reads
* `stdio`.
*/
type: 'stdio' | 'http' | 'sse' | 'ws' | 'sdk' | 'sse-ide' | 'ws-ide' | 'claudeai-proxy';
/**
* Where the server is: scheme, host and a port that is not the default, as
* WHATWG `URL.origin` gives it, of the URL after `${VAR}` expansion. Never a
* login, path, query or fragment.
*
* An entry on a session proxy reads the host dialed, not the server the proxy
* reaches. For `claudeai-proxy`, claude.ai's own connector reads the upstream
* claude.ai states, and any other entry the proxy it dials, never the `url` it
* wrote.
*
* Absent for `stdio` and `sdk`; for a URL that does not parse or has no origin
* of its own; for a connector whose address claude.ai withholds; for a
* `claudeai-proxy` entry with no route to dial; and for a server a cloud
* session's tool container relays, whatever its `type`.
*/
origin?: string;
/**
* The claude.ai connector's id, only where it is vouched for: claude.ai's own
* connector, or the `connectorId` a host states on its own `sdk` entry. Never
* one written in a file, a plugin or `--mcp-config`.
*/
connectorId?: string;
};
ToolNamed type
#
line 18386
Added in 2.1.260
An input that names its tool as the literal T: what next and $.tool.call read to type the call's result per tool (NextResultFor).
type ToolNamed<T extends string> = {
/**
* The name of the tool being called (`Bash`).
*/
readonly tool: T;
};
ToolOfferInput type
#
line 18400
Added in 2.1.328
The input of tool.offer: one tool of a loop's pool, at the moment the engine offers it to that loop's model. Every field is pinned.
Before the loop's first request (or when the tool joins the pool later) and when the model calls the tool: the same event at each.
20 lines
export type ToolOfferInput = {
/**
* The tool's name (`Bash`, `mcp__server__tool`); the key a matcher narrows
* on.
*/
tool: string;
/**
* Who provides this tool, as `tool.describe`'s `provider` says.
*/
provider: Origin;
/**
* The agent whose loop it is; absent for the main conversation.
*/
agentId?: string;
/**
* That agent's type (`Explore`, a plugin's agent); absent for the main
* conversation.
*/
subagentType?: string;
};
ToolOfferResult type
#
line 18425
Added in 2.1.328
What a tool.offer hook returns: whether the loop's model is offered the tool, in its tool list and at its call.
export type ToolOfferResult = {
isOffered: boolean;
};
ToolRequestMeta type
#
line 18432
Added in 2.1.295
What a tool.call hook sets for the request of an MCP server's tool.
16 lines
export type ToolRequestMeta = {
/**
* Entries for the `_meta` of the request this call sends its MCP server,
* set with `next({ ...e, requestMeta })`; never an argument of the tool.
*
* The one key a hook may set is `anthropic/sources`, its value a string
* (JSON for anything structured) of at most 256 KiB in UTF-8: any other
* shape is refused. It is carried only to the session's own relay to a
* connector, which takes it off before a vendor sees the call; a call to
* any other server, and any tool that is not an MCP server's, goes out
* without it. The engine's own request keys are not shown here and stay
* as they are. Left out of a rewrite, what a hook above set is kept; `{}`
* clears it.
*/
requestMeta?: Record<string, string>;
};
ToolResultOf type
#
line 18457
Added in 2.1.260 · changed in 2.1.289
The structured result of the tool named Name: its BuiltinToolResults entry for a built-in tool, else unknown.
Agent's is its entry, an AgentTeammateRecord (a started teammate's) or an AgentCallRecord (a plugin-raised call's). unknown covers an MCP tool, a name the results table lacks, and Name left at string.
export type ToolResultOf<Name extends string> = string extends Name ? unknown : Name extends keyof BuiltinToolResults & string ? BuiltinToolResults[Name] | (Name extends 'Agent' ? AgentCallRecord | AgentTeammateRecord : never) : unknown;