Event Table Types
These types map an event name to its input, its result, and its call on $.
Your editor uses them to know the shape of e and next for each event.
For example, $.fs.read(...) is both a call and the event fs.read, so a hook can answer it.
A plugin adds its own nouns by declaration merging into EngineInterface.
Source: the Mod API type file of the 2.1.312 program (schemas/claude-code.d.ts). Official page: Mods Reference.
Example
These aliases give the input and the result of one event by its name.
import type { EventName, EventOf, EventResult } from "claude-code";
type ReadInput = EventOf["fs.read"];
type ReadResult = EventResult<"fs.read">;
To add your own noun, merge into EngineInterface:
declare module "claude-code" {
interface EngineInterface {
voice: { say(text: string): Promise<void> };
}
}
After this, voice.say is also an event, and a hook can use on('voice.say', ...).
How It Works
EventOf joins the events the engine defines (CoreEventOf) with the methods of the nouns that plugins add (NounEventOf). ResultOf does the same for results. Events turns both into one hook type for each event.
Types without Fields
These types are aliases, unions, or plain shapes. Each row gives its use and its shape.
| Type | Status | What it is for | Shape and limits |
|---|---|---|---|
Any | Documented: An official docs page names this item. | The hook that on("*", hook) takes. It runs on every event, including events of plugin nouns that no declaration names. So e is unknown and next is StarNext. | Alias of ($:. Until next. narrows e, a hook can only pass it on, time it, log it, or fail it. |
Any | Documented: An official docs page names this item. | Every key of every variant, index signatures included. | Alias of I extends unknown ? keyof I :. |
Chunk | Documented: An official docs page names this item. | What a hook on streaming event N yields. It is also what its next(e) yields to the hook (see ChunkOf, by name). | Generic alias of Chunk. |
Chunk | Documented: An official docs page names this item. | The chunk type of each streaming event, by name. It is what the stream of the event yields. | Object with fields turn., process.. |
Chunk | Documented: An official docs page names this item. | What every turn. chunk may carry. It is the handle of the engine on the item of its own stream that the engine read the chunk from. A chunk that a hook made has no handle. | Object with the field ref?. A hook that passes a chunk on keeps the handle. A hook that spreads a chunk also keeps it. A chunk that a hook builds afresh has none. |
Core | Documented: An official docs page names this item. | The name of an event that the engine defines itself (a key of CoreEventOf). EventName adds the events of the declared plugin nouns. | Alias of keyof Core. |
Core | Documented: An official docs page names this item. | The argument of each event that the engine defines itself. It covers the events of its call sites (EngineEventOf), the events of the classic hooks (ClassicEventOf), and the calls on $. | Alias of Engine. |
Declared | Documented: An official docs page names this item. | The state events of each declared value, in a union of [plugin, key] pairs with one variant for each pair (it distributes). So a matcher narrows e. | Alias of Pair extends readonly [ infer P extends keyof Plugin. |
Declared | Documented: An official docs page names this item. | e of state. and of state. for one declared value. It has the typed reference of the value. For a write, it also has the change, of the declared type. | Object with fields get, set. |
Declared | Documented: An official docs page names this item. | Every named value that the enabled contracts declare, as one union of [plugin, key] pairs. It is never while PluginState is empty. | Object with fields [P in keyof Plugin. |
Declared | Documented: An official docs page names this item. | What a state. on one declared value carries beside its reference. It carries the value to write and the value that stood there, of the declared type. | Object with fields value, previous, if. |
Engine | Documented: An official docs page names this item. | The events that the engine raises at its call sites, and engine.. The events of the classic settings hooks are in ClassicEventOf. | Object. One key for each event that hooks can handle. The engine skips a hook that fails, and the next hook runs. So a guard needs a . to fail closed. |
Engine | Documented: An official docs page names this item. | The results of the events of the engine. | Object. One key for each event. Its value is the result type that a hook for the event may return. |
Event | Documented: An official docs page names this item. | The engine's own events as calls on $, with one signature each. $. resolves to its result, or to its stream. | Object with one key for each noun that raises events (tool, command, config, prompt, and more). A plugin's call runs the same chain, and the chain skips the calling hook. 10 calls use it, such as $.. |
Event | Documented: An official docs page names this item. | The name of an event: a key of EventOf. It covers the engine's own events (CoreEventName) and the events of the declared plugin nouns (NounEventName). | Alias of keyof Event. |
Event | Documented: An official docs page names this item. | The argument of each event, by event name. A hook receives it as e, and the call on $ takes it. It is plain data, frozen to every depth. | Alias of Core. The engine's own events plus the methods of the nouns that plugins add. |
Event | Documented: An official docs page names this item. | The result of event N: what its hooks return and what their next(e) resolves to. | Generic alias of Result. |
Events | Documented: An official docs page names this item. | The hook signature of each event, ($, e, next), as one mapped type over EventOf. The signature of a streaming event is the generator form (StreamHook). | Object. One hook type for each event. $ is frozen, e is read-only to every depth, and next runs the rest of the chain. |
Kept | Documented: An official docs page names this item. | What next takes in a matched hook. It is the variants of e that the matcher can match (KeptMembers), as declared. So a rewrite of a pinned field passes. | Alias of Matched. |
Namespace | Documented: An official docs page names this item. | The prefixes that a glob may name: one or more whole leading segments of an event name (tool of tool.). The type derives them and includes plugin nouns. | Generic alias of N extends `${infer Head}.. |
Next | Documented: An official docs page names this item. | What next(e) resolves to for event N: the result of the event. At engine., the steps beneath return $ as built so far. | Alias of N extends 'engine.. The type of the value that next gives back. |
Next | Documented: An official docs page names this item. | What next(e) resolves to once e. is the literal T. On tool., it is the result typed for that tool. On every other event, it is O as declared. | Alias of [ N ] extends ['tool.. result is Bash's record after e.. An un-narrowed e names every tool, and result stays unknown. |
No | Documented: An official docs page names this item. | The argument of a call on $ that takes nothing ($.): an object with no keys. | Alias of Record<never, never>. session., session., session., session. and 16 more use it. |
No | Documented: An official docs page names this item. | The events whose argument is exactly NoArgs (session., () => ... of a declared plugin noun). Their overloads come last (LateOverload). | Object with fields [N in Event. |
Noun | Documented: An official docs page names this item. | The methods of the declared plugin nouns as event rows (NounEventRow). There is one row for each <noun>. that is a function. A member that is not a function is no event. | Object with fields [K in Plugin. |
Noun | Documented: An official docs page names this item. | The name of a declared plugin noun's event (voice.). | Alias of keyof Noun. |
Noun | Documented: An official docs page names this item. | The events of the plugin nouns declared on EngineInterface, by name: the argument of each <noun>.. Empty until a plugin declares a noun. | Alias of { [E in Noun. Example: declare module "claude-. |
Noun | Documented: An official docs page names this item. | The result of the event of a declared plugin noun, as its hooks see it: { value } (the answer of the method) or { deny }. | Alias of Value. |
Noun | Documented: An official docs page names this item. | One method of a declared plugin noun as an event row. It has the event name, the argument (the first parameter of the method), and the value (its awaited result). | Object with fields name, args, value. |
Noun | Documented: An official docs page names this item. | What the method of each declared plugin noun answers (the value of the result of its event), by event name. | Alias of { [E in Noun. |
Op | Documented: An official docs page names this item. | The name of a call on $ that the host serves, as an event. | Alias of keyof Op. |
Op | Documented: An official docs page names this item. | The calls on $ that the host serves, as events. e is the argument of the call as it crosses to the host. Hooks can handle every one by name and by on("*"). | Object. One key for each $ call that is also an event, such as fs. and session.. A hook can pass it on, rewrite it, refuse it with { deny }, or answer with { value }. |
Op | Documented: An official docs page names this item. | The result of a call on $, as the hooks of its event see it: { value } (the answer of the call) or { deny }. | Generic alias of Value. |
Op | Documented: An official docs page names this item. | What each call on $ answers (the value of the result of its event), by event name. | Object. One key for each $ call. Its value is the type of the answer of the call. $., $., and $. use it. |
Plugin | Documented: An official docs page names this item. | The nouns that a plugin declared on $ by merging into EngineInterface. It never includes a noun that has the engine's own events (tool, session, ui). | Alias for the names of nouns that plugins add. An identical open call that repeats waits behind the previous one. |
Result | Documented: An official docs page names this item. | What the hook of each event returns, and what its next(e) resolves to, by event name. | Combines Result, Engine, Classic. Object with fields [N in Op, [N in Noun. |
Streaming | Documented: An official docs page names this item. | The events that stream. Their hooks are async generators. next(e) is the stream of everything beneath, and the result is what it returns. | Alias of 'turn.. These two events stream their output in pieces. |
Value | Documented: An official docs page names this item. | The result of a call on $, as the hooks on its event see it. It is { value }, the answer of the call, or { deny }, the reason that the promise of the caller rejects. | Object with fields value, deny?, deny, value?. |