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, 201 to 250 of 833
McpContentBlock type
#
line 7639
In the first published surface (2.1.259)
One block of an MCP result: type and the fields that kind of block carries.
19 lines
export type McpContentBlock = {
/**
* The block's kind: `text`, `image`, `audio`, `resource`, `resource_link`.
*/
type: string;
/**
* Set on a `text` block.
*/
text?: string;
/**
* Set on a `resource_link` (or embedded `resource`) block.
*/
uri?: string;
/**
* Declared by an image, audio or resource block.
*/
mimeType?: string;
[field: string]: unknown;
};
McpServerProvenance type
#
line 7662
Added in 2.1.274
The MCP server serving this tool, for mcp__* tools: name is the server's config key (for source: "sdk", exactly the name the SDK host registered in sdkMcpServers / mcp_set_servers; for any other source, the key as authored in that configuration - untrusted text, the same value mcp_status and system/init report, to be escaped before display), source is where its definition came from - sdk (an in-process server the SDK host runs; only the host can register one, so a configured server of the same name never reads sdk), plugin (a server a plugin ships or registers at runtime), or a config scope (user, project, local, dynamic for --mcp-config / mcp_set_servers process servers, managed, enterprise, claudeai, agent). Key trust on source, not on the name or the tool-name prefix. Absent for non-MCP tools.
type McpServerProvenance = {
name: string;
/**
* sdk | plugin | user | project | local | dynamic | managed | enterprise | claudeai | agent - an open set; treat unknown values as an unrecognized configured source, never as sdk.
*/
source: string;
};
McpToolCallInput type
#
line 7677
In the first published surface (2.1.259)
The MCP branch of a tool.call hook's e (and of $.tool.call's input): one variant per declared tool, else the loose McpToolCallInputFallback.
$.mcp.call(server, tool, args) takes none of these: its parameters are positional, the server and tool by name, then the arguments object.
export type McpToolCallInput = [keyof McpToolInputs] extends [never] ? McpToolCallInputFallback : {
[N in keyof McpToolInputs & string]: ToolInputOf<N, McpToolInputs[N] & Record<string, unknown>>;
}[keyof McpToolInputs & string];
McpToolCallInputFallback type
#
line 7692
In the first published surface (2.1.259)
The e a tool.call (or classic.PreToolUse) hook receives for an MCP tool while no MCP tool is declared: every mcp__* name, loose arguments.
McpToolInputs has no entries until a type root's MCP entry declares the connected tools; also the input of $.tool.call({ tool: "mcp__<server>__<tool>", ... }). Not $.mcp.call's, which is positional:
on("tool.call", { tool: "mcp__gh__issue" }, ($, e, next) => audit(e.title))
13 lines
type McpToolCallInputFallback = {
/**
* The name of the tool being called (`mcp__<server>__<tool>`); comparing
* it narrows `e`. Reserved: a rewrite of it is ignored by core.
*/
tool: McpToolName;
/**
* 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;
[argument: string]: unknown;
};
McpToolInputs interface
#
line 7717
In the first published surface (2.1.259)
The inputs of the MCP tools this project knows, keyed by full tool name, for declaration merging; empty by default, then every MCP tool is loose.
A .d.ts in the author's project (the type root's MCP entry, laid from the connected servers' JSON Schemas, or one written by hand) adds entries under declare module "claude-code"; e.tool === <name> narrows to them.
interface McpToolInputs { "mcp__my_server__send": { to: string } }
export interface McpToolInputs {
}
McpToolName type
#
line 7723
In the first published surface (2.1.259)
The name of an MCP tool as the engine spells it: mcp__<server>__<tool>.
export type McpToolName = `mcp__${string}__${string}`;
McpToolResult type
#
line 7728
In the first published surface (2.1.259)
An MCP tools/call result as the SDK returns it, plain data.
16 lines
export type McpToolResult = {
/**
* The result's content blocks, in order (text, image, resource,
* resource_link, ...).
*/
content: McpContentBlock[];
/**
* True when the server reported the call as failed; the blocks then describe
* the error.
*/
isError: boolean;
/**
* The server's structured result, when its tool declares an output schema.
*/
structuredContent?: unknown;
};
MemberOfFunction type
#
line 7752
Added in 2.1.281
memberOf(family, e): the member of a family for the instance being drawn, keyed by e.requestId; of an atom over a family, that member's.
const open = await read($, memberOf(isOpen, e))
export type MemberOfFunction = {
<T>(family: Atom<T>, e: Pick<RenderInput, 'requestId'>): Atom<T>;
<P extends string, K extends string>(family: StateName<P, K>, e: Pick<RenderInput, 'requestId'>): StateName<P, K> & Readonly<Required<Pick<StateAddress, 'id'>>>;
};
MessageDisplayHookInput type
#
line 7760
Added in 2.1.265
Hook input for the MessageDisplay event. Fired with each batch of newly completed lines while an assistant message streams. Display-only: the stored message and what the model sees are untouched.
23 lines
type MessageDisplayHookInput = BaseHookInput & {
hook_event_name: 'MessageDisplay';
/**
* UUID of the current turn.
*/
turn_id: string;
/**
* UUID of the assistant message being displayed. Stable across every flush of the same message. Not the API msg_... id.
*/
message_id: string;
/**
* Zero-based index of this delta within the message. Increments by one per flush.
*/
index: number;
/**
* True on the message's last flush. Exactly one flush per message has it.
*/
final: boolean;
/**
* The newly completed lines since the prior flush. Always whole lines, except on the final flush which may end mid-line. The delta of the final flush is empty when the message ends on a newline; treat final as the end-of-message signal regardless.
*/
delta: string;
};
ModelApiError type
#
line 7792
Added in 2.1.280
Which kind of API failure ended a model call (a completion, a fork), in the word Claude Code classifies every API error with (StopFailure's).
rate_limit, overloaded and server_error may clear on their own; authentication_failed, billing_error, invalid_request, model_not_found will not; unknown fits none of the named kinds.
export type ModelApiError = ClassicHookInputs['StopFailure']['error'];
ModelCompleteInput type
#
line 7805
Added in 2.1.292
What a hook on model.complete reads as e: the request with its text as strings, as it always was, and the caller's blocks beside them.
A hook written when prompt was only ever a string reads what it read. A caller's list of blocks arrives joined in prompt (or system) and, as given, in promptBlocks (or systemBlocks), where its cache marks are.
on("model.complete", ($, e, next) => (BAD.test(e.prompt) ? NO : next(e)))
53 lines
export type ModelCompleteInput = {
/**
* Which model answers, as the request named it (ModelCompleteRequest).
*/
model: string;
/**
* The one user message, as text: a string as the caller gave it, or the
* texts of its blocks joined in order with nothing between them.
*
* It is what the model is sent: a hook that passes another string down
* has rewritten the prompt, whatever `promptBlocks` still says.
*/
prompt: string;
/**
* What precedes the completion as its system prompt, as text joined as
* `prompt` is; absent when the caller gave none.
*
* Passing `null` or `false` down sends none.
*/
system?: string;
/**
* The caller's blocks of `prompt`, as given, when it gave a list: where
* the cache marks are. Absent for a string.
*
* They place marks and change no text. The leading blocks whose texts,
* joined, still open `prompt` are sent as they stand, marks kept; what is
* left of `prompt` follows unmarked, so a rewritten opening keeps no mark.
*
* @remarks A hook that strips or adds a `cache` here and leaves the texts
* is taken at its word; one that rewrites both keeps them in step.
* @example
* next({ ...e, prompt: e.prompt + NOTE }) // the marks ahead of NOTE hold
*/
promptBlocks?: readonly ModelTextBlock[];
/**
* The caller's blocks of `system`, read against `system` exactly as
* `promptBlocks` is against `prompt`. Absent for a string or none.
*/
systemBlocks?: readonly ModelTextBlock[];
/**
* The reply's token cap, as the request gave it.
*/
maxTokens?: number;
/**
* How hard the model thinks about it, as the request gave it.
*/
effort?: ModelEffort;
/**
* How long the whole call may take, in milliseconds, as the request gave
* it.
*/
timeoutMs?: number;
};
ModelCompleteOptions type
#
line 7863
Added in 2.1.284
Options of $.model.complete: what is no part of the request, so no hook on model.complete reads it on e.
14 lines
export type ModelCompleteOptions = {
/**
* Aborting it cuts the call while it runs: it resolves `aborted`, as when
* its dispatch is aborted. Already aborted, no request is made.
*
* The plugin's own (`new AbortController()`), kept where a later handler
* reaches it, so a Cancel button stops a call an earlier press started;
* it never leaves the plugin's environment, only its firing does.
*
* @example
* const r = await $.model.complete(ask, { signal: stop.signal })
*/
signal?: AbortSignal;
};
ModelCompleteRequest type
#
line 7881
In the first published surface (2.1.259) · changed in 2.1.280, 2.1.292
What $.model.complete takes.
62 lines
export type ModelCompleteRequest = {
/**
* An alias (`haiku`) or a full model id; resolved and allowlist-checked like
* a `--model` value.
*/
model: string;
/**
* The one user message: a string, or blocks of text sent in order
* (ModelTextBlock), any of which may be marked for the prompt cache.
*
* The result always says what happened: the reply's text and usage when
* the model answered, else a `reason` (an API error with its status, a
* reply with no text, or the call cut short).
*
* @remarks Marks go uncounted: one too many is the API's own `api-error`
* (status 400). A hook reads the text joined (ModelCompleteInput).
* @example
* await $.model.complete({ model, prompt: [{ text: RULES, cache: true }] })
*/
prompt: string | readonly ModelTextBlock[];
/**
* Precedes the completion as its system prompt, after the CLI's identity
* block: a string, or blocks of text as `prompt` takes. Default none.
*
* @remarks On Bedrock, Vertex, Foundry or behind a gateway, text marked here
* is found again only while `prompt` opens the same: mark it there.
*/
system?: string | readonly ModelTextBlock[];
/**
* The reply's token cap: any positive integer up to what one reply can
* hold, the model's own output limit or 64000, whichever is lower.
*
* Default 1024. The reply comes back whole, not streamed, and a provider
* ends such a request at ten minutes, hence the 64000. One past the limit
* is refused, naming it.
*/
maxTokens?: number;
/**
* How hard the model thinks about it (ModelEffort): `low` for a cheap
* label, `max` for a hard judgment. Default: the model's own.
*
* Sent as the request's effort where the model takes one and dropped
* where it does not, as the session's own requests do; a value outside
* the five levels is refused.
*
* @example
* await $.model.complete({ model: "haiku", prompt, effort: "low" })
*/
effort?: ModelEffort;
/**
* How long the whole call may take, in milliseconds, before it resolves
* `aborted` and the request is abandoned; default none.
*
* A `$` call's time never counts against the calling hook's budget, so this
* is how a hook bounds the completion itself, by the clock. A positive whole
* number, held to what a timer holds (2147483647); anything else is refused.
*
* @example
* await $.model.complete({ model: "haiku", prompt, timeoutMs: 8000 })
*/
timeoutMs?: number;
};
ModelCompleteResult type
#
line 7955
Added in 2.1.280 · changed in 2.1.318
What one model call resolves to: the reply when the model answered (isAnswered), else which of three things left it without text (reason).
$.model.complete's result whole, and $.model.fork's once it had something to fork. What the provider did never rejects the call, so a plugin branches on isAnswered and reason; usage rides every arm.
const r = await $.model.complete(ask); if (!r.isAnswered) log(r.reason)
116 lines
export type ModelCompleteResult = {
/**
* True: the model answered; `text` and `usage` are its reply.
*
* @example
* if (r.isAnswered) spent += r.usage.output_tokens
*/
isAnswered: true;
/**
* The reply's text: a completion's text blocks joined; on a fork, the
* non-error replies' text joined by newlines.
*/
text: string;
/**
* What the call cost (ModelUsage); on a fork its completions summed.
*
* On a fork `cache_read_input_tokens` is how much of the transcript
* the main thread's prompt cache served: near zero, the fork paid for
* the whole prefix (the entry lapsed, the model changed since, or its
* `effort` could not ride its own message: ModelForkRequest).
*/
usage: ModelUsage;
/**
* On a fork, the effort its last response was asked for: what the
* request's `effort` came to under its limits, or the session's own
* level when it named none. The level stated after `prompt` where the
* model takes effort per message, else the request's own setting. A
* completion's result carries none.
*
* Absent too when the fork's request carried no named level: a model
* that takes none, `CLAUDE_CODE_EFFORT_LEVEL` set to `auto` or `unset`
* with no `maxEffortLevel` setting, or a fork that ran as if it had named
* none in a session on a numeric level.
*
* @example
* if (r.isAnswered) $.ui.log(`${r.effort}: ${r.usage.output_tokens}`)
*/
effort?: ModelEffort;
} | {
isAnswered: false;
/**
* The API answered with an error and no reply carried text.
*
* @example
* if (!r.isAnswered && r.reason === "api-error") retry(r.status)
*/
reason: 'api-error';
/**
* The error reply's HTTP status (429, 500, 529, ...); null when no
* response arrived at all (a dropped connection, a provider timeout).
*/
status: number | null;
/**
* Which kind of failure, as Claude Code classifies API errors; never
* the error's text or body.
*
* `rate_limit`, `overloaded`, `invalid_request`,
* `authentication_failed`, `server_error`, ...; `unknown` when it fits
* none of the named kinds.
*/
error: ModelApiError;
/**
* What the call cost before it failed: all zeros for a completion (its
* one request was the one refused); on a fork, the turns before it.
*/
usage: ModelUsage;
/**
* On a fork, the effort of the last response before the error, as on
* the answered arm; absent when its first request was the one refused.
*/
effort?: ModelEffort;
} | {
isAnswered: false;
/**
* The model replied and its reply carried no text.
*
* A completion whose content held no text block, or a fork answered
* with a tool attempt alone (denied, as every fork tool is) or nothing.
*
* @example
* if (!r.isAnswered && r.reason === "empty-reply") $.ui.log("no words")
*/
reason: 'empty-reply';
/**
* What the call cost.
*/
usage: ModelUsage;
/**
* On a fork, the effort of its last response, as on the answered arm.
*/
effort?: ModelEffort;
} | {
isAnswered: false;
/**
* The call was cut before a reply came; whatever had come back is
* discarded.
*
* The dispatch that made the call was aborted while it ran (escape on
* the turn whose hook called; the plugin's environment unloaded), or a
* completion's own `options.signal` aborted or `timeoutMs` elapsed.
*
* @example
* if (!r.isAnswered && r.reason === "aborted") return next(e)
*/
reason: 'aborted';
/**
* What the call cost before it was cut: all zeros for a completion (no
* response arrived); on a fork, what came back before the abort.
*/
usage: ModelUsage;
/**
* On a fork, the effort of the last response that had started, as on
* the answered arm; absent when none had.
*/
effort?: ModelEffort;
};
ModelEffort type
#
line 8078
Added in 2.1.280
How hard a request asks the model to think, by the levels the engine and turn.step name: low to max, xhigh between high and max.
A model that takes no effort setting is sent none, whatever is asked.
export type ModelEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
ModelForkRequest type
#
line 8083
In the first published surface (2.1.259) · changed in 2.1.318
What $.model.fork takes.
53 lines
export type ModelForkRequest = {
/**
* The one user message, appended to the session's own transcript as the
* main thread last sent it.
*
* The result always says what happened: the reply's text and usage when
* the fork answered, else a `reason` (nothing to fork yet, an API error
* with its status, a reply with no text, or the turn's abort cut it).
*/
prompt: string;
/**
* How hard the fork thinks about it (ModelEffort): `low` for a quick side
* job, whatever the person chose for the main work. Default: the level the
* session runs at, which is the main thread's and no ceiling: a fork may ask
* for more. Where the model does not take effort per message, a level other
* than the session's costs a cache write of the whole conversation: see the
* remarks.
*
* Held to what the person and the organization allow: the organization's
* cap, the `maxEffortLevel` setting and the model's own levels lower what is
* asked, and a model that takes no effort is sent none. A level that
* `CLAUDE_CODE_EFFORT_LEVEL` names is a ceiling: a fork may go under it, and
* one that asks for more runs as if it had named none, as every fork does
* where that variable is `auto` or `unset` (the session then sends no effort,
* or under a `maxEffortLevel` setting the model's default). The result's
* `effort` is what was sent. A value outside the five levels rejects the
* call. The main thread keeps its own level, and its next request and its
* cache entry are as after any fork.
*
* @remarks What a level other than the main thread's costs turns on how
* the model takes effort. Per message: the level is stated after
* `prompt`, everything before it stands as the main thread sent it, and
* the cached transcript is read as for any fork. As one setting of the
* whole request (a model or provider with no per-message effort, a
* conversation whose per-message effort the API refused, a session on a
* numeric level): the level is applied all the same, but the first fork
* at it reads at most the system prompt and tools from the cache and
* writes the whole conversation again as an entry of its own, billed as
* `usage.cache_creation_input_tokens` and waited for, the longer the
* conversation the longer; later forks at that level read that entry
* while it lives. The main thread's entry stands. There are two ways
* round that cost. The person can have the session's model take effort per
* message, with `CLAUDE_CODE_MODEL_CAPABILITIES=per_turn_effort` in their
* shell or in the `env` of their user or managed settings: first-party API
* only, and until the API refuses it. Or the fork can name no effort and
* ask for haste in `prompt` (that it has no tools, and should answer
* straight away without thinking it over), which moves nothing ahead of
* `prompt`, so the cache is read on every model.
* @example
* await $.model.fork({ prompt: "Say that again, shorter.", effort: "low" })
*/
effort?: ModelEffort;
};
ModelForkResult type
#
line 8148
Added in 2.1.268 · changed in 2.1.280
What $.model.fork resolves to: a completion's result (ModelCompleteResult) or that there was nothing to fork yet.
The completion's arms are the reply when the fork answered, else api-error, empty-reply or aborted, usage on each and beside it, once a response came back at a named level, the effort it ran at.
const r = await $.model.fork({ prompt }); if (!r.isAnswered) log(r.reason)
15 lines
export type ModelForkResult = ModelCompleteResult | {
isAnswered: false;
/**
* Nothing to fork, so no request was made: the session holds no
* snapshot of this conversation's main thread that a fork may share.
*
* Until a turn has run to its end, that is while none of its requests
* is out, and on a host that keeps none; again after a `/clear`, or a
* resume that starts the conversation afresh.
*
* @example
* if (!r.isAnswered && r.reason === "nothing-to-fork") return next(e)
*/
reason: 'nothing-to-fork';
};
ModelTextBlock type
#
line 8174
Added in 2.1.292
One block of text in a $.model.complete request's prompt or system: sent as written, in the order given, and markable for the prompt cache.
Put the text every call repeats first and mark its last block (cache); whatever follows the last mark is paid for whole on every call.
const prompt = [{ text: RULES, cache: true }, { text: diff }]
19 lines
export type ModelTextBlock = {
/**
* The block's text, sent as written; an empty one is the API's to
* refuse, as an `api-error` of status 400.
*/
text: string;
/**
* Keeps the request up to and including this block in the prompt cache; a
* call within five minutes that opens with the same text reads it there.
*
* The result's `usage` shows it: `cache_creation_input_tokens` when the
* call wrote, `cache_read_input_tokens` when it read. Both zero, nothing
* was cached: text under the model's minimum, or caching switched off.
*
* @remarks On Bedrock, Vertex, Foundry or behind a gateway the text is found
* again only while `prompt` opens the same way: put the fixed text first.
*/
cache?: true;
};
ModelUsage type
#
line 8212
Added in 2.1.280
What one model call cost, as the API counted it: the four token counts in the API's spelling, summed over the call's responses when it made several.
The one shape every place that reports a call's cost uses: $.model.complete's result on every arm and $.model.fork's on each arm where a request was made (ModelCompleteResult), session.compact's result when core ran the summarizer, turn.step and turn.complete (TurnUsage, which adds the model that answered), and the context breakdown's apiUsage (the live window's last response). All four counts are always present; a count the response left out reads as zero.
These are token counts: dollars a mod works out from them are an estimate too, not the bill (SessionCost).
const r = await $.model.complete(ask); if (r.isAnswered) spend(r.usage)
24 lines
export type ModelUsage = {
/**
* Uncached input tokens the call was answered over: the part of the
* prompt neither read from nor written to the prompt cache.
*/
input_tokens: number;
/**
* Tokens the call generated.
*/
output_tokens: number;
/**
* Input tokens the prompt cache served.
*
* On a fork, how much of the main thread's transcript the cache still
* held: near zero, the fork paid for the whole prefix (the entry had
* lapsed, the model changed since it was made, or the fork's `effort`
* could not ride its own message: ModelForkRequest).
*/
cache_read_input_tokens: number;
/**
* Input tokens the call wrote to the prompt cache.
*/
cache_creation_input_tokens: number;
};
Namespace type
#
line 8241
Added in 2.1.265
The prefixes a glob may name: one or more whole leading segments of an event name (tool of tool.call), derived, plugin nouns included.
export type Namespace<N extends string = EventName> = N extends `${infer Head}.${infer Rest}` ? Head | `${Head}.${Namespace<Rest>}` : never;
NarrowDepth type
#
line 8249
In the first published surface (2.1.259)
How many object or array levels a matcher narrows e through, counted as a tuple's length: the runtime's own limit, which refuses a deeper matcher.
Past it a field keeps its declared type; nothing becomes any.
type NarrowDepth = 8;
Narrowed type
#
line 8259
In the first published surface (2.1.259)
e in a matched hook: the members of the argument union E matcher P can match, each with the keys P names narrowed to what a match implies.
A scalar narrows to the literal, a one-of to what its alternatives give, an object key recursively, an array some element of which must match to a non-empty tuple; other keys, unknown and RegExp-matched fields keep.
export type Narrowed<E, P> = E extends unknown ? NarrowedMember<E, P, []> : never;
NarrowedByAny type
#
line 8269
In the first published surface (2.1.259)
A value of declared type V under a one-of, folded over the tuple into Found: the union of what each alternative narrows V to (NarrowedByOne).
An alternative that cannot match adds nothing, so a one-of none of whose alternatives can is never; a one-of typed as a plain array rather than a tuple narrows by the union of its elements at once.
type NarrowedByAny<V, Alternatives extends readonly unknown[], D extends readonly unknown[], Found = never> = Alternatives extends readonly [infer First, ...infer Rest] ? NarrowedByAny<V, Rest, D, Found | NarrowedByOne<V, First, D>> : Alternatives extends readonly [] ? Found : Found | NarrowedByOne<V, Alternatives[number], D>;
NarrowedByOne type
#
line 8279
In the first published surface (2.1.259)
A value of declared type V under one matcher node Q that is not a one-of, member of V by member; a member that cannot match is never.
An array some element of which must match becomes NonEmpty; a RegExp keeps the member; an object pattern recurses into an object member, one level down; a scalar keeps a member as narrow, and replaces a wider one.
type NarrowedByOne<V, Q, D extends readonly unknown[]> = V extends readonly (infer Item)[] ? [NarrowedValue<Item, Q, [...D, unknown]>] extends [never] ? never : NonEmpty<V, Item> : Q extends RegExp ? V : Q extends object ? V extends object ? NarrowedMember<V, Q, [...D, unknown]> : never : V extends Q ? V : Q extends V ? Q : never;
NarrowedMember type
#
line 8289
In the first published surface (2.1.259)
One object member E under object pattern P, D levels down: never when a key of P is impossible on it (ImpossibleKeys), else E narrowed.
Each key P names is narrowed (NarrowedValue); every other key, and each key's optionality, stays as declared, as does plugin under "*": a default matcher key's wildcard says nothing of the value.
type NarrowedMember<E, P, D extends readonly unknown[]> = [
ImpossibleKeys<E, P, D>
NarrowedValue type
#
line 8302
In the first published surface (2.1.259)
A value of declared type V where the matcher gives Q, D levels down: NarrowedByAny under a one-of (an array), NarrowedByOne otherwise.
As declared once D reaches NarrowDepth, or for a field typed unknown (a tool's input), which no pattern narrows.
type NarrowedValue<V, Q, D extends readonly unknown[]> = D['length'] extends NarrowDepth ? V : unknown extends V ? V : Q extends readonly unknown[] ? NarrowedByAny<V, Q, D> : NarrowedByOne<V, Q, D>;
Negation type
#
line 8311
Added in 2.1.265
! before a name or a glob: every event except the ones it selects. !* would select none, so it is no pattern.
It names no event, so like * it selects no telemetry event for an installed plugin: those are hooked by name.
type Negation = `!${Exclude<EventName | Glob, '*'>}`;
Next type
#
line 8326
In the first published surface (2.1.259) · changed in 2.1.260, 2.1.265, 2.1.267, 2.1.268, 2.1.275, 2.1.328
The rest of the chain, as one hook receives it: made once per dispatch per hook, frozen; next(e) resolves to the downstream result.
Each call runs the hooks below again; core is the last, and below it next rejects. Called with no argument it rejects, naming the hook. A hook that returns without calling it ends the chain; returning nothing is a failure.
76 lines
export type Next<N extends EventName = EventName, E = Args<N>, O = NextResult<N>, S extends {
[K in N]?: unknown;
} = {
[K in N]: Args<K>;
}> = {
<T extends string>(e: E & ToolNamed<T>): Promise<NextResultFor<N, O, T>>;
(e: E): Promise<O>;
/**
* Continues this dispatch at a tier: `next(e)` with every link between
* this hook's own tier and that one skipped, by tier and narrowing only.
*
* A managed hook's: prepend may name user, append, builtin or core, append
* core; it never skips a tier with more authority, so no user hook skips
* the org's. `user` skips each prepend peer below the hook, never one
* above it, and an outer `next.to` to a deeper tier still wins. A literal
* on the hook's own `next`; skipped links are traced.
*/
readonly to: {
<T extends string>(e: E & ToolNamed<T>, tier: TargetTier): Promise<NextResultFor<N, O, T>>;
(e: E, tier: TargetTier): Promise<O>;
};
/**
* Aborts when the call this dispatch belongs to is abandoned: the user
* interrupted, a hook above settled first, or this hook ran out of budget.
*
* Anything the hook started (timers, requests) should stop on it. It is an
* AbortSignal of the plugin's own environment, driven by the chain's.
*/
readonly signal: AbortSignal;
/**
* Whether this dispatch's event is selected by `pattern` (a name, a glob,
* a negation), as a type predicate on `e`: `next.is("tool.call", e)`.
*
* Under a matcher the narrowing includes it. `pattern` names events this
* hook covers (PatternOver); a name outside them is a compile error.
*/
readonly is: <M extends PatternOver<N>>(pattern: M, e: unknown) => e is Frozen<S[Extract<N, Selected<M>>]>;
/**
* The name of this dispatch's event, as a value, for a glob hook to log or
* switch on.
*/
readonly event: N;
/**
* Who raised this dispatch: the calling plugin's name and the tier it sits
* in (NextOrigin); the engine reads `{ plugin: "engine", tier: "core" }`.
*
* Set by the host alone, from the environment the call came from (its own
* MessagePort) and that plugin's seat; nothing a plugin writes reaches it.
* Every hook of one dispatch sees the same origin, and `next.to` keeps it.
*
* @example
* return next.origin.tier === "prepend" ? next.to(e, "append") : next(e)
*/
readonly origin: NextOrigin;
/**
* What settled beneath this hook on its latest `next()` call, the one
* started last: an entry per link beneath, nearest first, the engine's last.
*
* Empty before `next` is called; filled even when `next` rejected; a link
* still running joins in place later, nothing listed leaves; it ends short
* of the engine at a link that answered its last call itself. Data, frozen.
*/
readonly trace: readonly TraceEntry<N, E, O>[];
/**
* How much time this hook runs under and how much is left (NextBudget),
* read fresh on each access; HookBudget says what the clock counts.
*
* It stands still while a `next` or `$` call of the hook's is in flight;
* in a `.catch` handler it is the grace, `ms` being `next.error.budget`;
* at `session.end` it reads the exit's one short bound, which never stops.
*
* @example
* if (next.budget.remainingMs < 2_000) return next(e) // skip the polish
*/
readonly budget: NextBudget;
};
NextBudget type
#
line 8414
Added in 2.1.275
The budget the code reading next.budget runs under: the whole allowance and what is left of it now, plain data read fresh on each access.
In a hook ms is HookBudget's ms; in a .catch handler its catchMs (what next.error.budget names); on a next nothing meters (the engine's own, a test's root one) ms is 0 and remainingMs Infinity.
if (next.budget.remainingMs < 2_000) return next(e) // skip the slow path
19 lines
export type NextBudget = {
/**
* The whole budget in milliseconds; 0 where nothing meters this `next`.
*
* On a dispatch the engine cuts short as a whole (`session.end`: one short
* wall-clock bound for the entire chain, so an exit stays fast whatever is
* loaded) it is no more than that cut left when the hook started, 0 past it.
*/
readonly ms: number;
/**
* What is left of it now, in milliseconds, never below 0; Infinity where
* nothing meters. It stands still while a `next` or `$` call is in flight.
*
* Except under a cut of the whole dispatch (`session.end`): the cut's clock
* never stops, `$` waits included, and this reads no more than it leaves,
* so a later hook in that chain starts with what the earlier ones left.
*/
readonly remainingMs: number;
};
NextOrigin type
#
line 8438
Added in 2.1.328
What next.origin holds: who raised the dispatch (Origin), and whose code that is. Set by the host; an event's provider carries neither field.
16 lines
export type NextOrigin = Origin & {
/**
* On a settings hook's own MCP call alone: whose hook it is. `"unknown"`
* where it may be the organization's and that could not be told.
*/
readonly hookOwner?: 'organization' | 'unknown' | 'person';
/**
* At `tool.check` alone, where the organization's own code made the call as
* it arrived: a plugin managed settings seated, or a hook known as theirs.
*
* The tier does not say so: a person's settings can fill `prepend`, and a
* built-in can sit there. Absent on a call a hook rewrote, and on one a
* model, a script or a `Monitor` watch makes for such a plugin.
*/
readonly isOrganizations?: true;
};
NextResult type
#
line 8462
In the first published surface (2.1.259)
What next(e) resolves to for event N: the event's result, except at engine.create, where the steps beneath return $ as built so far.
A withheld noun is on that $ as a stub, so the built table is typed whole where what a hook returns (EngineCreateResult) is partial.
export type NextResult<N extends EventName> = N extends 'engine.create' ? EngineInterfaceBuilt : EventResult<N>;
NextResultFor type
#
line 8471
Added in 2.1.260
What next(e) resolves to once e.tool is the literal T: on tool.call and tool.run the result typed for that tool; else O as declared.
result is Bash's record after e.tool === "Bash"; an un-narrowed e names every tool, and result stays unknown.
export type NextResultFor<N extends EventName, O, T extends string> = [
N
NoArgs type
#
line 8479
In the first published surface (2.1.259)
The argument of a call on $ that takes nothing ($.session.cwd()): an object with no keys.
type NoArgs = Record<never, never>;
NoArgsEvent type
#
line 8485
In the first published surface (2.1.259) · changed in 2.1.265
The events whose argument is exactly NoArgs (session.cwd, a declared plugin noun's () => ...); their overloads come last (LateOverload).
type NoArgsEvent = {
[N in EventName]: Args<N> extends NoArgs ? NoArgs extends Args<N> ? N : never : never;
}[EventName];
NoEngineInterface type
#
line 8493
In the first published surface (2.1.259)
What an engine.create hook receives as $: nothing. Every property reads as never, so $.model inside the hook is a compile error.
export type NoEngineInterface = {
readonly [noun: string]: never;
};
NonEmpty type
#
line 8504
In the first published surface (2.1.259)
Array type V, of element Item, once some element of it is known to match: a tuple of at least one Item, readonly when V is.
So e still passes wherever the declared array is taken; a V that is already a non-empty tuple is kept as it is.
type NonEmpty<V, Item> = V extends readonly [unknown, ...unknown[]] ? V : V extends Item[] ? [Item, ...Item[]] : readonly [Item, ...Item[]];
NotificationHookInput type
#
line 8506
Added in 2.1.265
type NotificationHookInput = BaseHookInput & {
hook_event_name: 'Notification';
message: string;
title?: string;
notification_type: string;
};
NotifyOptions type
#
line 8516
Added in 2.1.295 · changed in 2.1.321
Options of $.ui.notify.
30 lines
export type NotifyOptions = {
/**
* What heads the notification, sent as the mod gives it: the engine puts
* no name of its own beside it. Left out or empty, the plugin's name.
*/
title?: string;
/**
* A name for this notification, unique within the plugin. Sent again, it
* replaces the one a client holds under that key; `$.ui.cancelNotify` takes
* it back. A terminal has nothing to replace and ignores it.
*/
key?: string;
/**
* Milliseconds a client holds it before raising it, so it can fire with the
* session out of reach. More than 7 days rejects the call on every surface.
* A terminal otherwise ignores it and raises it now.
*/
delayMs?: number;
/**
* The time a client raises it, in epoch milliseconds, for a moment fixed on
* the clock. Never beside `delayMs`. More than 7 days ahead rejects the call
* on every surface. A terminal otherwise ignores it and raises it now.
*/
at?: number;
/**
* With `delayMs` or `at`: a client throws it away if the person returns to
* the session before it fires, so it can only speak to someone who left.
*/
untilBack?: boolean;
};
NounEvent type
#
line 8551
Added in 2.1.265
The declared plugin nouns' methods as event rows (NounEventRow), one per <noun>.<method> that is a function; a member that is not is no event.
type NounEvent = {
[K in PluginNoun]: {
[M in keyof EngineInterface[K] & string]: EngineInterface[K][M] extends (...args: infer Parameters) => infer Result ? NounEventRow<`${K}.${M}`, Parameters extends readonly [] ? NoArgs : Parameters[0], Awaited<Result>> : never;
}[keyof EngineInterface[K] & string];
}[PluginNoun];
NounEventName type
#
line 8560
Added in 2.1.265
The name of a declared plugin noun's event (voice.speak).
type NounEventName = keyof NounEventOf & string;
NounEventOf type
#
line 8569
Added in 2.1.265
The events of the plugin nouns declared on EngineInterface, by name: the argument of each <noun>.<method>. Empty until a plugin declares a noun.
declare module "claude-code" { interface EngineInterface { voice: Voice } }
export type NounEventOf = {
[E in NounEvent as E['name']]: E['args'];
};
NounEventResult type
#
line 8577
Added in 2.1.265
The result of a declared plugin noun's event as its hooks see it: { value } (the method's answer) or { deny }.
type NounEventResult<N extends NounEventName> = ValueOrDeny<NounValueOf[N]>;
NounEventRow type
#
line 8583
Added in 2.1.265
One method of a declared plugin noun as an event row: its event's name, argument (the method's first parameter) and value (its awaited result).
type NounEventRow<Name extends string, Args, Value> = {
name: Name;
args: Args;
value: Value;
};
NounValueOf type
#
line 8593
Added in 2.1.265
What each declared plugin noun's method answers (the value of its event's result), by event name.
type NounValueOf = {
[E in NounEvent as E['name']]: E['value'];
};
On type
#
line 8615
In the first published surface (2.1.259) · changed in 2.1.265, 2.1.267, 2.1.287
Registers hook on the events pattern selects: one by name, every one under a namespace (classic.*), all (*), or all but some (!tool.*).
One function stands on every selected event (next.event says which), under a matcher for the inputs it matches; a plugin's registrations nest in order, first outermost; a repeat throws. Returns the Registration.
A name this build does not know, or a glob that selects no event, refuses the whole module. To span versions, state an engines["claude-code"] range in plugin.json (honoured from 2.1.323; install and update pick the newest version that fits, up to five <name>--v<version> tags back), or hook a glob such as prompt.* and test next.event. A call on $ this build lacks loads, and throws a TypeError where it is made: a try/catch takes it.
export type On = {
<P extends Pattern>(pattern: P, hook: NoInfer<HookFor<P>>): Registration<HookFor<P>>;
<P extends Pattern, const M extends MatcherFor<P>>(pattern: P, matcher: M, hook: NoInfer<MatchedHook<P, M>>): Registration<MatchedHook<P, M>>;
};
OnScreen type
#
line 8633
Added in 2.1.275
The part of a transcript message the surface that drew it has on screen: units first to last of the message's of, counted from its start.
The terminal counts the rows the site laid out, from its first (the blank row the engine draws above a message is its row 0; a hook's tree starts at its own); other surfaces count in their unit, so compare first / of there.
if (e.props.onScreen) shown.set(e.requestId, e.props.onScreen)
else shown.delete(e.requestId) // the band's legend lists `shown`
19 lines
type OnScreen = {
/**
* The unit inside the viewport, from 0: on the terminal, `7` when the
* message's top seven rows are scrolled away.
*/
first: number;
/**
* The unit inside the viewport, inclusive; at least `first`.
*/
last: number;
/**
* The message's whole extent in the same unit, as laid out (a hook's tree
* taller than the engine's counts its own rows); more than `last`.
*
* One surface's numbers say nothing of another's: what the phone shows the
* terminal may not, and each `ui.render` carries its own surface's.
*/
of: number;
};
OpenMatcher type
#
line 8660
In the first published surface (2.1.259) · changed in 2.1.287
The keys a variant with a string index signature (an MCP tool's input) takes beyond its own: another variant's key as typed there; others free.
So a misspelt value for a key some variant declares (command: 5) is refused on every variant, not admitted by the open one.
type OpenMatcher<I, All> = {
readonly [K in Exclude<MatcherKeys<All>, keyof IndexFree<I>>]?: MatcherValue<MatcherValueOf<All, K>>;
} & Readonly<Record<string, unknown>>;
OpEventName type
#
line 8667
In the first published surface (2.1.259)
The name of a call on $ the host serves, as an event.
export type OpEventName = keyof OpEventOf;
OpEventOf type
#
line 8683
In the first published surface (2.1.259)
The calls on $ the host serves, as events: e is the call's argument as it crosses to the host, and every one is hookable by name and by on("*").
A hook above the caller passes it on, rewrites it, refuses it with { deny } or answers with { value }; core is the host's implementation. The calling hook is skipped, and next.origin names the caller.
A person's hooks don't hear a call an organization's mod makes, or what is raised beneath it while it runs. Tier says whose a mod is.
450 lines
export type OpEventOf = {
/**
* The argument of `$.model.complete(request, { signal })`, its text as
* strings and its blocks beside them (ModelCompleteInput).
*
* The signal does not cross, it aborts the call.
*/
'model.complete': ModelCompleteInput;
/**
* The argument of `$.model.classify(text, labels, options)`.
*/
'model.classify': {
text: string;
labels: readonly string[];
options?: ClassifyOptions;
};
/**
* The argument of `$.model.fork(request)`.
*/
'model.fork': ModelForkRequest;
/**
* The clip and how to play it (`shouldLoop`, `gain`); the signal does not
* cross.
*/
'audio.play': {
clip: AudioClip;
shouldLoop: boolean;
gain?: number;
};
/**
* The argument of `$.audio.speak(text, { voice, signal })`; the signal
* does not cross, it aborts the call.
*/
'audio.speak': SpeakRequest;
/**
* The argument of `$.mcp.call(server, tool, args)`.
*/
'mcp.call': {
server: string;
tool: string;
args: Record<string, unknown>;
};
/**
* The argument of `$.mcp.connect(server)`, `next.origin` the calling
* plugin; also raised by the engine, for each server it is about to join by
* itself, `next.origin` the engine's.
*
* A hook on the engine's raise that answers without calling `next` holds
* the server back: nothing is dialed, and `/mcp` lists it as held by that
* hook's plugin until `$.mcp.connect` or a later raise lets it through.
* There `next` answers once the hooks beneath pass, and the dial follows.
*
* @remarks Headless plugin install, sync and reload raise nothing: a server
* they bring in first dials with no hook asked, and one held before stays
* held. Nor is it raised for the dial `$.mcp.connect` itself starts.
*/
'mcp.connect': {
/**
* The server as `$.mcp.connect(server)` spelled it, a key of the caller's
* manifest or a name /mcp lists; on the engine's raise the name /mcp lists
* it under, usually `plugin:<plugin>:<server>`. Pinned: a rewrite is refused.
*/
server: string;
/**
* Who provides the server, as at `tool.describe`: the plugin and its tier,
* or `mcp:<server>` for one that settings configure; the caller for its
* own key. Pinned: a rewrite is refused, and a `$.mcp.connect` that then
* resolves to another provider's server answers `failed`.
*/
provider: Origin;
};
/**
* The argument of `$.session.cwd()`.
*/
'session.cwd': NoArgs;
/**
* The argument of `$.session.root()`.
*/
'session.root': NoArgs;
/**
* The argument of `$.session.model()`.
*/
'session.model': NoArgs;
/**
* The argument of `$.session.turns()`.
*/
'session.turns': NoArgs;
/**
* The argument of `$.session.id()`.
*/
'session.id': NoArgs;
/**
* The argument of `$.session.messages(args)`: `{}` for the main
* conversation, `{ agentId }` for one of its agents, `as` for the form.
*
* `last` or `after` for part of it.
*/
'session.messages': SessionMessagesArgs;
/**
* The argument of `$.session.repo()`.
*/
'session.repo': NoArgs;
/**
* The argument of `$.session.surface()`.
*
* @deprecated with `$.session.surface()`; hook `session.surfaces`
*/
'session.surface': NoArgs;
/**
* The argument of `$.session.surfaces()`.
*/
'session.surfaces': NoArgs;
/**
* The argument of `$.session.authorize()`.
*/
'session.authorize': NoArgs;
/**
* The argument of `$.session.identity()`.
*/
'session.identity': NoArgs;
/**
* The argument of `$.session.usage({ breakdown, columns })`.
*/
'session.usage': SessionUsageArgs;
/**
* The argument of `$.session.version()`.
*/
'session.version': NoArgs;
/**
* The argument of `$.session.info()`.
*/
'session.info': NoArgs;
/**
* The argument of `$.session.machine()`.
*/
'session.machine': NoArgs;
/**
* The argument of `$.turn.abort({ turnId })`.
*/
'turn.abort': {
turnId: string;
};
/**
* The argument of `$.prompt.read()`.
*/
'prompt.read': NoArgs;
/**
* The argument of `$.prompt.paint(...)`: the draft and this plugin's runs.
*/
'prompt.paint': PromptPaintArgs;
/**
* The argument of `$.tool.list()`, and of the engine's own raise of its
* tools: what the hooks answer that raise is the session's tool pool
* (`ToolInfo`).
*/
'tool.list': NoArgs;
/**
* The argument of `$.tool.register(spec)`.
*/
'tool.register': RegisteredToolSpec;
/**
* The argument of `$.command.list()`.
*/
'command.list': NoArgs;
/**
* The argument of `$.command.register(spec)`.
*/
'command.register': CommandSpec;
/**
* The argument of `$.config.list()`.
*/
'config.list': NoArgs;
/**
* The argument of `$.agent.list()`.
*/
'agent.list': NoArgs;
/**
* The argument of `$.agent.limits()`.
*/
'agent.limits': NoArgs;
/**
* The argument of `$.agent.register(spec)`: the agent type as the plugin
* defined it. A hook above rewrites any of it; the type stays the caller's.
*/
'agent.register': AgentSpec;
/**
* The argument of `$.agent.call(args, { signal })`. A hook above may rewrite
* the tool and its input, and the call is then no longer its caller's own at
* `tool.judge`; `agentId` is pinned. The signal does not cross, it cuts the call.
*/
'agent.call': AgentCallArgs;
/**
* The argument of `$.ui.toast(text, { timeoutMs })`.
*/
'ui.toast': {
text: string;
timeoutMs?: number;
};
/**
* The argument of `$.ui.status(text)`; `text` undefined clears the line.
*/
'ui.status': {
text: string | undefined;
};
/**
* The argument of `$.ui.log(text, { to })`; `to` is always present
* (UiLogSink), and `next({ ...e, to: "debug" })` keeps a line off screen.
*/
'ui.log': {
text: string;
to: UiLogSink;
};
/**
* The argument of `$.ui.notice(tool_use_id, text)`.
*/
'ui.notice': {
tool_use_id: string;
text: string | undefined;
};
/**
* The argument of `$.ui.invalidate(event)`.
*/
'ui.invalidate': {
event: InvalidatableEventName;
};
/**
* The argument of `$.ui.open({ id, title, focus })`; a hook above the
* opener may retitle it or refuse it with `{ deny }`, never rename it.
*/
'ui.open': PaneOpenArgs;
/**
* The argument of `$.ui.close({ id })` with `origin` `plugin`; the engine
* raises it too, for the person (`person`) and an unload (`unload`).
*/
'ui.close': PaneCloseInput;
/**
* The argument of `$.ui.panes()`.
*/
'ui.panes': NoArgs;
/**
* The argument of `$.ui.place({ id })`.
*/
'ui.place': UiPlaceArgs;
/**
* The argument of `$.theme.set(attributes)`: the attributes themselves.
*/
'theme.set': ThemeSetArgs;
/**
* The argument of `$.theme.clear()`.
*/
'theme.clear': NoArgs;
/**
* The argument of `$.ui.selection()`.
*/
'ui.selection': NoArgs;
/**
* The argument of `$.ui.copy({ text, surface })`, `surface` filled with
* the session's first when left out; rewritable, deniable, answerable.
*/
'ui.copy': UiCopyArgs;
/**
* The argument of `$.ui.view({ agentId })`: whose transcript the main view
* is to show, none for the main conversation; rewritable and deniable.
*/
'ui.view': SiteView;
/**
* The argument of `$.ui.notify(text, { title, key, delayMs, at, untilBack })`,
* `title` the plugin's name when left out or empty; rewritable, deniable,
* answerable. A rewrite by another plugin's hook is marked, so a client can
* show that it may not be as the sender wrote it.
*
* A notification is heard twice: here, and by `classic.Notification`
* hooks. Two mods that each notify again from a timer on hearing one
* echo each other without end: nothing in the engine stops them.
*/
'ui.notify': {
text: string;
title?: string;
key?: string;
delayMs?: number;
at?: number;
untilBack?: boolean;
};
/**
* The argument of `$.ui.cancelNotify(key)`: the key of the plugin's own
* notification to take back; rewritable, deniable, answerable, like
* `ui.notify`. Only a client's surface holds one to take.
*/
'ui.cancelNotify': CancelNotifyArgs;
/**
* The argument of `$.ui.blit(...)`: a Raster's `cells` or a keyed Image's
* `source`; a hook above may rewrite either with `next`, or `{ deny }`.
*/
'ui.blit': UiBlitArgs;
/**
* The argument of `$.fs.read(path, { as, offset, length })`: `as` is `text`
* unless the caller asked for `bytes`; a range's keys only when given.
*
* A hook that answers in the host's place cuts its answer to the range.
*/
'fs.read': {
path: string;
as: FsReadAs;
offset?: number;
length?: number;
};
/**
* The argument of `$.fs.write(path, text)`.
*/
'fs.write': {
path: string;
text: string;
};
/**
* The argument of `$.fs.list(path)`.
*/
'fs.list': {
path: string;
};
/**
* The argument of `$.fs.exists(path)`.
*/
'fs.exists': {
path: string;
};
/**
* The argument of `$.fs.stat(path, { resolve })`: `resolve` is false
* unless the caller asked where the path lands.
*/
'fs.stat': {
path: string;
resolve: boolean;
};
/**
* The argument of `$.fs.ancestors({ names, of, below })`.
*/
'fs.ancestors': FsAncestorsRequest;
/**
* The argument of `$.store.get(key)`.
*/
'store.get': {
key: string;
};
/**
* The argument of `$.store.set(key, value)`.
*/
'store.set': {
key: string;
value: unknown;
};
/**
* The argument of `$.store.delete(key)`.
*/
'store.delete': {
key: string;
};
/**
* The argument of `$.store.keys()`.
*/
'store.keys': NoArgs;
/**
* The argument of `$.state.get(ref)`: the reference itself, `plugin`, `key`
* and a family member's `id`; identity, pinned.
*/
'state.get': StateGetEvent;
/**
* The argument of `$.state.set(ref, value, { ifVersion })`: the reference,
* the value, the condition, and `previous`, what stood there (the host's).
*
* A hook above rewrites `value` with `next({ ...e, value })`; the
* reference is identity, pinned. Raised by the value's owner alone. A
* `{ deny }` after `next(e)` was answered, a `.catch`'s too, fails the hook.
*/
'state.set': StateSetEvent;
/**
* The argument of `$.clock.now()`.
*/
'clock.now': NoArgs;
/**
* The argument of `$.clock.sleep(ms, { signal })`; the signal does not
* cross, it aborts the dispatch.
*/
'clock.sleep': ClockWait;
/**
* The argument of `$.clock.after(ms, fn)`: the wait before `fn`, which
* stays in the plugin's environment and runs once the dispatch resolves.
*/
'clock.after': ClockWait;
/**
* The argument of `$.clock.every(ms, fn)`, dispatched once per period:
* `fn` runs each time a dispatch resolves, and the next period is asked.
*/
'clock.every': ClockWait;
/**
* The argument of `$.http.fetch(url, init)`.
*/
'http.fetch': {
url: string;
init?: HttpInit;
};
/**
* The argument of `$.process.run(argv, init)`.
*/
'process.run': {
argv: readonly string[];
init?: ProcessRunInit;
};
/**
* The argument of `$.process.spawn(request)`: the request itself.
*
* A hook's `{ deny }` rejects the caller's stream and lets the child go
* (one still running is killed). Once a child of the call handed up a
* piece or its exit, the rejection says it started or ran.
*/
'process.spawn': ProcessSpawnRequest;
/**
* The argument of `$.process.hookEnv()`.
*/
'process.hookEnv': NoArgs;
/**
* The argument of `$.settings.read({ source })`, and the layers the read
* is made of, which the engine fills; rewritable, deniable.
*/
'settings.read': SettingsReadInput;
/**
* The argument of `$.env.get(name)`; `name` is identity, pinned.
*/
'env.get': {
name: string;
};
/**
* The argument of `$.env.set(name, value)`; `name` is identity, pinned,
* and no `value` unsets.
*
* A `{ deny }` after `next(e)` was answered, a `.catch`'s too, fails the
* hook: deny in its place.
*/
'env.set': {
name: string;
value?: string;
};
/**
* The bytes `$.wasm.compile(source)` is about to compile, and the file
* they were read from; `path` is identity, pinned.
*
* A hook replaces them going down (`next({ ...e, base64 })`), coming back
* or by answering alone (`{ value: { base64 } }`), or refuses (`{ deny }`).
*/
'wasm.compile': WasmCompileInput;
};
OpEventResult type
#
line 9138
In the first published surface (2.1.259) · changed in 2.1.265
The result of a call on $ as its event's hooks see it: { value } (the call's answer) or { deny }.
export type OpEventResult<N extends OpEventName = OpEventName> = ValueOrDeny<OpValueOf[N]>;