Every named declaration in the file, 570 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 13,820 lines of TypeScript mined from build 2.1.283. 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, 251 to 300 of 570
PostModelSwitchHookInput type
#
line 6881
Added in 2.1.265
37 lines
type PostModelSwitchHookInput = (BaseHookInput & {
hook_event_name: 'PostModelSwitch';
}) & {
/**
* Resolved model id the session was running before the switch
*/
from_model: string;
/**
* Resolved model id the session runs after the switch
*/
to_model: string;
/**
* What was asked for (alias such as "opus", a full id, or null for "default")
*/
requested_model: string | null;
/**
* command: /model <name>, the /config Model row, or enabling fast mode when that promotes the model; picker: an interactive model picker; sdk: headless set_model (SDK, Remote Control, IDE); auto: automatic fallback or other programmatic change; resume: model restored while resuming a session
*/
source: 'command' | 'picker' | 'sdk' | 'auto' | 'resume';
/**
* Prompt tokens the next request re-sends: the last main-thread response's input + cache_read + cache_creation + output tokens (0 before the first response; for a server-side tool loop, its last iteration's window, not the summed totals)
*/
context_tokens: number;
/**
* Whether the current model's prompt cache is likely still warm (a switch then forfeits it)
*/
prompt_cache_warm: boolean;
cache_ttl: '5m' | '1h';
/**
* Estimated cost of re-caching context_tokens on to_model at its cache-write rate - the managed modelPricing when set, otherwise list price; excludes the response
*/
estimated_cache_write_usd: number;
/**
* configured: priced at the managed modelPricing setting; catalog: list price; default: to_model unknown, the default tier was assumed
*/
pricing: 'configured' | 'catalog' | 'default';
};
PostToolBatchHookInput type
#
line 6922
Added in 2.1.265
Hook input for the PostToolBatch event. Fired once after every tool call in a batch has resolved, before the next model request. PostToolUse fires per-tool and may run concurrently for parallel tool calls; PostToolBatch fires exactly once with the full batch.
type PostToolBatchHookInput = BaseHookInput & {
hook_event_name: 'PostToolBatch';
tool_calls: PostToolBatchToolCall[];
};
PostToolBatchToolCall type
#
line 6927
Added in 2.1.265
type PostToolBatchToolCall = {
tool_name: string;
tool_input: unknown;
tool_use_id: string;
tool_response?: unknown;
};
PostToolUseFailureHookInput type
#
line 6934
Added in 2.1.265 · changed in 2.1.274
13 lines
type PostToolUseFailureHookInput = BaseHookInput & {
hook_event_name: 'PostToolUseFailure';
tool_name: string;
tool_input: unknown;
tool_use_id: string;
error: string;
is_interrupt?: boolean;
/**
* Tool execution time in milliseconds. Excludes permission-prompt and hook time.
*/
duration_ms?: number;
mcp_server?: McpServerProvenance;
};
PostToolUseHookInput type
#
line 6948
Added in 2.1.265 · changed in 2.1.274
type PostToolUseHookInput = BaseHookInput & {
hook_event_name: 'PostToolUse';
tool_name: string;
tool_input: unknown;
tool_response: unknown;
tool_use_id: string;
/**
* Tool execution time in milliseconds. Excludes permission-prompt and hook time.
*/
duration_ms?: number;
mcp_server?: McpServerProvenance;
};
PreCompactHookInput type
#
line 6961
Added in 2.1.265
type PreCompactHookInput = BaseHookInput & {
hook_event_name: 'PreCompact';
trigger: 'manual' | 'auto';
custom_instructions: string | null;
};
PreModelSwitchHookInput type
#
line 6967
Added in 2.1.265
37 lines
type PreModelSwitchHookInput = (BaseHookInput & {
hook_event_name: 'PreModelSwitch';
}) & {
/**
* Resolved model id the session was running before the switch
*/
from_model: string;
/**
* Resolved model id the session runs after the switch
*/
to_model: string;
/**
* What was asked for (alias such as "opus", a full id, or null for "default")
*/
requested_model: string | null;
/**
* command: /model <name>, the /config Model row, or enabling fast mode when that promotes the model; picker: an interactive model picker; sdk: headless set_model (SDK, Remote Control, IDE)
*/
source: 'command' | 'picker' | 'sdk';
/**
* Prompt tokens the next request re-sends: the last main-thread response's input + cache_read + cache_creation + output tokens (0 before the first response; for a server-side tool loop, its last iteration's window, not the summed totals)
*/
context_tokens: number;
/**
* Whether the current model's prompt cache is likely still warm (a switch then forfeits it)
*/
prompt_cache_warm: boolean;
cache_ttl: '5m' | '1h';
/**
* Estimated cost of re-caching context_tokens on to_model at its cache-write rate - the managed modelPricing when set, otherwise list price; excludes the response
*/
estimated_cache_write_usd: number;
/**
* configured: priced at the managed modelPricing setting; catalog: list price; default: to_model unknown, the default tier was assumed
*/
pricing: 'configured' | 'catalog' | 'default';
};
PressedLink type
#
line 7012
Added in 2.1.274
The link a press landed on: one a Markdown drew, pressed where the surface reports presses (a plain click in the fullscreen terminal).
What the surface knows of the cell pressed, not which occurrence: two links written with one target read the same here.
export type PressedLink = {
/**
* The link's target as the surface drew it: for an `https:` link, the
* href as the markdown wrote it.
*/
href: string;
};
PreToolUseDecision type
#
line 7024
In the first published surface (2.1.259)
The decision of a classic.PreToolUse result: allow, ask, deny, or none.
27 lines
export type PreToolUseDecision = {
/**
* Lets the call run without a permission prompt (the managed-settings
* hooks ran first; a deny from them ended the chain above).
*/
allow: true;
ask?: undefined;
deny?: undefined;
} | {
/**
* Asks the user before the call runs; the text is shown as the reason.
*/
ask: string;
allow?: undefined;
deny?: undefined;
} | {
/**
* Refuses the call; the model receives the text as the reason.
*/
deny: string;
allow?: undefined;
ask?: undefined;
} | {
allow?: undefined;
ask?: undefined;
deny?: undefined;
};
PreToolUseHookInput type
#
line 7052
Added in 2.1.265 · changed in 2.1.274
type PreToolUseHookInput = BaseHookInput & {
hook_event_name: 'PreToolUse';
tool_name: string;
tool_input: unknown;
tool_use_id: string;
mcp_server?: McpServerProvenance;
};
PreToolUseResult type
#
line 7064
In the first published surface (2.1.259)
What a classic.PreToolUse hook returns: one of allow, ask, deny, or none of them, which passes the call on to the normal permission flow.
export type PreToolUseResult = PreToolUseDecision & {
/**
* Replaces the tool's arguments; validated against the tool's schema before
* the tool runs.
*/
updatedInput?: Record<string, unknown>;
/**
* Extra context handed to the model with the call, one entry per note.
*/
additionalContext?: string[];
};
ProcessRunInit type
#
line 7079
Added in 2.1.260 · changed in 2.1.268
Options of $.process.run.
20 lines
export type ProcessRunInit = {
/**
* The child's working directory, relative to the session's or absolute;
* absent, the session's working directory.
*/
cwd?: string;
/**
* Variables set over the host process's own environment.
*/
env?: Record<string, string>;
/**
* Text written to the child's standard input, then closed.
*/
stdin?: string;
/**
* How long the child may run before it is killed and the call rejects,
* in milliseconds; 30 seconds when absent, ten minutes at most.
*/
timeoutMs?: number;
};
ProcessRunResult type
#
line 7103
Added in 2.1.260 · changed in 2.1.268
What $.process.run resolves with once the child has exited.
16 lines
export type ProcessRunResult = {
/**
* The child's exit status; a child ended by a signal reads as 1.
*/
exitCode: number;
/**
* What the child wrote to standard output, as text, cut at the output
* limit.
*/
stdout: string;
/**
* What the child wrote to standard error, as text, cut at the output
* limit.
*/
stderr: string;
};
ProcessSpawnChunk type
#
line 7128
Added in 2.1.280
One piece of a spawned child's output as $.process.spawn streams it: which pipe it came from, and the text.
The text is UTF-8 decoded as it arrived, in order per pipe: a piece ends wherever the child's write did, so a line may span two pieces and one piece may hold several lines; a multi-byte character is never split.
export type ProcessSpawnChunk = {
/**
* The pipe the text came from.
*/
stream: 'stdout' | 'stderr';
/**
* What the child wrote, decoded; never empty. Left unread past about a
* megabyte, the child blocks on its next write until the loop pulls.
*/
text: string;
};
ProcessSpawnRequest type
#
line 7147
Added in 2.1.280
The argument of $.process.spawn(request), and the e its hooks see: the command by its argument vector and how the child is started.
The same rules as $.process.run: no shell, the session's working directory unless one is named, the host's environment with env over it.
22 lines
export type ProcessSpawnRequest = {
/**
* The command and its arguments, `argv[0]` the executable.
*/
argv: readonly string[];
/**
* The child's working directory, relative to the session's or absolute;
* absent, the session's working directory.
*/
cwd?: string;
/**
* Variables set over the host process's own environment.
*/
env?: Record<string, string>;
/**
* Text written to the child's standard input, which is then closed;
* absent, standard input is closed from the start.
*
* A string today; a later form may take the text in pieces.
*/
input?: string;
};
ProcessSpawnResult type
#
line 7174
Added in 2.1.280
How a spawned child ended, as the stream of $.process.spawn returns it once every piece has been read: its exit code, or the signal that did it.
export type ProcessSpawnResult = {
/**
* The child's exit status; null when a signal ended it.
*/
code: number | null;
/**
* What ended the child from outside (`SIGTERM`); null when it exited on
* its own. On Windows a killed child reads as an exit code, this null.
*/
signal: string | null;
};
PromptAttachmentInput type
#
line 7194
Added in 2.1.277
The input of prompt.attachment: one message the engine injects into the conversation for the model on its own, as a request is about to carry it.
A reminder, a mode transition, a listing, a mentioned file, a hook's context: the person never typed it and mostly never sees it. Only an attachment that carries text for the model is raised.
35 lines
export type PromptAttachmentInput = {
/**
* As the engine names the attachment's kind; the key a matcher narrows on.
* Pinned. Builds add and retire kinds: match by name.
*
* Among them `todo_reminder`, `plan_mode`, `plan_mode_exit`, `auto_mode`,
* `auto_mode_exit`, `instructions`, `nested_memory`, `skill_listing`,
* `deferred_tools_delta`, `edited_text_file`, `file`, `queued_command`.
*/
type: string;
/**
* What the model reads for this attachment, inside the engine's framing;
* rewritable with `next({ ...e, text })`.
*
* The `<system-reminder>` wrapper (or the system channel that replaces it)
* goes around what the chain answers, never inside it. An attachment
* rendered as several text blocks hands them joined by newlines.
*/
text: string;
/**
* Who authored the text (PromptAttachmentOrigin): the engine, a settings
* hook, or a plugin's chain context.
*
* Pinned: a different value is refused, one left out is kept.
*/
origin: PromptAttachmentOrigin;
/**
* The loop whose request carries the attachment: a subagent's id, the `id`
* `$.agent.list()` gives it and its `tool.call`s carry; absent on main.
*
* Pinned: a different value is refused, one left out is kept. A subagent
* a hook spawned through `$.agent.spawn` is resolved past that hook.
*/
agentId?: string;
};
PromptAttachmentOrigin type
#
line 7238
Added in 2.1.277
Who authored the text an injected attachment carries, as the engine knows it from the attachment itself; a closed set, pinned on the event.
A hooks module reads e.origin.kind to tell the engine's own prose from a settings hook's output or another plugin's context. next(e) passes it on as received; one left out is put back; no hook sets one.
31 lines
export type PromptAttachmentOrigin = {
/**
* The engine's own prose or framing: a reminder, a mode transition, a
* listing, a notice, an announced context block.
*
* A file the person mentioned, as the engine presents it, and a prompt
* or notification delivered into a running turn are the engine's too.
*/
kind: 'engine';
} | {
/**
* A settings hook's output the engine injects for the model: its
* additional context, a blocking error's note, a stopped continuation.
*/
kind: 'hook';
/**
* The settings hook event that produced it (`SessionStart`,
* `UserPromptSubmit`, `PostToolUse`, ...).
*/
event: string;
} | {
/**
* Text a plugin's hook attached through a chain's `context`
* (`prompt.submit`, `tool.call`), as the model reads it.
*/
kind: 'plugin';
/**
* The chain's event that attached it.
*/
event: string;
};
PromptAttachmentResult type
#
line 7274
Added in 2.1.277
What a prompt.attachment hook returns: the text the model reads for that attachment, or null to leave the attachment out of the request.
export type PromptAttachmentResult = {
text: string | null;
};
PromptBox type
#
line 7285
Added in 2.1.275
The person's prompt box as it stands: the draft and where the cursor is in it; what $.prompt.read() resolves and $.prompt.fill hands back.
No selection: the terminal's box has none of its own, and a surface that binds one adds it here.
export type PromptBox = {
/**
* The draft as typed so far; `''` where the session draws no box.
*/
text: string;
/**
* Where the next typed character lands: an offset into `text` in UTF-16
* code units, 0 at the start, `text.length` at the end.
*/
cursor: number;
};
PromptContextBlock type
#
line 7301
In the first published surface (2.1.259)
One block of the context the first user message carries: a name the engine keys it by and the text under it.
14 lines
export type PromptContextBlock = {
/**
* The key the block renders under (`# name`): `claudeMd`, `userEmail`,
* `attachedProject`, `currentDate`, or a plugin's own.
*
* The field a matcher narrows on; unique among one context's blocks.
*/
name: string;
/**
* The block's text; `claudeMd`'s is the instruction files framed as the
* engine frames them, empty when it announces none.
*/
text: string;
};
PromptContextBlocks type
#
line 7320
In the first published surface (2.1.259)
The context blocks of a conversation's first user message, in the order the engine renders them: what prompt.context takes and answers alike.
export type PromptContextBlocks = {
/**
* From core: `claudeMd` (when instruction files are loaded), `userEmail`,
* `attachedProject`, `currentDate`, each only when present.
*/
blocks: readonly PromptContextBlock[];
};
PromptContextInput type
#
line 7332
In the first published surface (2.1.259) · changed in 2.1.275
The input of prompt.context: the context blocks the engine prepends to a conversation's first user message, and the files behind claudeMd.
15 lines
export type PromptContextInput = {
/**
* From core: `claudeMd` (when instruction files are loaded), `userEmail`,
* `attachedProject`, `currentDate`, each only when present.
*/
blocks: readonly PromptContextBlock[];
/**
* The files behind `claudeMd`, in the order it renders them, `@` imports
* included; empty when it renders none.
*
* Undefined when a hook above rewrote the `claudeMd` text: the files
* behind that text are then unknown, and a hook adds none of its own.
*/
instructionFiles?: readonly InstructionFile[];
};
PromptContextResult type
#
line 7352
In the first published surface (2.1.259) · changed in 2.1.275
What a prompt.context hook returns: the blocks the conversation carries, in order; one left out is not sent.
14 lines
export type PromptContextResult = {
/**
* What the conversation carries, in order.
*/
blocks: readonly PromptContextBlock[];
/**
* The files now behind `claudeMd`; left out, the ones from below stand.
*
* Kept in step with the `claudeMd` text at every link: a changed list
* renders the text the next reader gets, a rewritten text makes the files
* unknown from there on. Every kind is the hook's to add, drop or rewrite.
*/
instructionFiles?: readonly InstructionFile[];
};
PromptEditInput type
#
line 7371
Added in 2.1.277
The input of prompt.edit (prompt-edit/): one edit the person makes in the prompt box, as the draft before it and the splice the editor made of it.
41 lines
export type PromptEditInput = {
/**
* Who edits (PromptEditOrigin): the person at the composer. Pinned:
* `next(e)` passes it on as received.
*/
origin: PromptEditOrigin;
/**
* The one key that made the edit, in `Client` `onKey`'s shape, when one
* did; absent for a paste and for a burst of keys folded into one edit.
*
* Pinned: which key the person pressed is a fact, not the hook's to change.
*/
key?: ClientKeyEvent;
/**
* The draft before the edit. `next({ ...e, text })` applies the edit to
* another draft instead.
*/
text: string;
/**
* Where the person's caret stood in `text` before the edit, 0 to
* `text.length`.
*/
cursor: number;
/**
* Where in `text` the edit begins: the start of the span it replaces, or
* where what was typed goes in; a bare cursor move begins where it lands.
*/
start: number;
/**
* Where the replaced span of `text` ends: `start` for an insertion or a
* move, past it for a deletion (Backspace, a kill).
*/
end: number;
/**
* What goes in between `start` and `end`: the typed or pasted text, `''` for
* a deletion or a move.
*
* `next({ ...e, inputText })` puts in another; the cursor lands after it.
*/
inputText: string;
};
PromptEditOrigin type
#
line 7419
Added in 2.1.277
Who edits the prompt box at prompt.edit, as the engine stamps it where the edit starts; a closed set a matcher narrows on.
next(e) passes it on as received; no hook sets one.
export type PromptEditOrigin = {
/**
* The person, typing or pasting into the main prompt box.
*/
kind: 'composer';
};
PromptEditResult type
#
line 7434
Added in 2.1.277
What a prompt.edit hook returns and what next(e) resolves to: the box after the edit (PromptBox), which the editor then shows.
From core, e.text with the splice applied and the cursor after what went in. Rewrite it ({ ...r, text, cursor }) to change what lands; answer { text: e.text, cursor: e.cursor } without next to consume the key.
export type PromptEditResult = PromptBox;
PromptFillArgs type
#
line 7440
Added in 2.1.268 · changed in 2.1.275
prompt.fill's input as a plugin's $.prompt.fill(args) takes it: no origin (the engine sets the calling plugin's), mode optional.
export type PromptFillArgs = {
/**
* What the box is to take (PromptFillInput `text`).
*/
text: string;
/**
* Where it goes (PromptFillMode); `replace` when left out.
*/
mode?: PromptFillMode;
};
PromptFilled type
#
line 7458
Added in 2.1.275 · changed in 2.1.282
What $.prompt.fill resolves to: whether the box took the text, and the box afterwards (PromptBox) as the caller's own $.prompt.read() reads it.
The box goes to a plugin whose module calls $.prompt.read, through the hooks on it; one that never does, or is refused there, gets the empty box.
25 lines
export type PromptFilled = {
/**
* True once the box holds the text; false where no box could take it or a
* hook kept it out (PromptFillResult).
*/
isFilled: boolean;
/**
* Why the box did not take the text, when the engine itself refused
* (PromptFillResult): `no_composer` where the session binds no box,
* `dialog` while one holds the keys. A hook's refusal carries none, so
* a caller choosing a fallback treats an absent cause as unknown and
* does not act as if no box existed.
*/
refusal?: 'no_composer' | 'dialog';
/**
* The draft after the fill; unchanged when `isFilled` is false; `''` where
* no box is drawn or the caller may not read it (see above).
*/
text: string;
/**
* Where the person types next: an offset into `text`, past the fill's text
* for `insert`, at the end for `replace` and `append`.
*/
cursor: number;
};
PromptFillInput type
#
line 7488
Added in 2.1.268 · changed in 2.1.275
The input of prompt.fill (prompt-fill/): a text about to be put in the prompt box as the person's draft, over it, after it, or at the cursor.
17 lines
export type PromptFillInput = {
/**
* What the box takes; the person edits it or presses Enter.
* `next({ ...e, text })` writes another.
*/
text: string;
/**
* Where the text goes (PromptFillMode): over the draft, after it, or in at
* the cursor. `next({ ...e, mode })` moves it; left out of a rewrite, kept.
*/
mode: PromptFillMode;
/**
* Who writes (PromptFillOrigin), set by the engine where the write
* starts. Pinned: `next(e)` passes it on as received.
*/
origin: PromptFillOrigin;
};
PromptFillMode type
#
line 7515
Added in 2.1.275
Where a prompt.fill puts its text: over the whole draft, after it, or into it at the cursor.
replace empties the box first and leaves the cursor at the text's end; append keeps the draft and adds the text after it, cursor at the end; insert splices the text in at the cursor and moves the cursor past it, so what the person had typed stays on either side.
export type PromptFillMode = 'replace' | 'append' | 'insert';
PromptFillOrigin type
#
line 7523
Added in 2.1.268
Who writes the prompt box at prompt.fill, as the engine stamps it where the write starts; a closed set a matcher narrows on.
next(e) passes it on as received; no hook sets one.
16 lines
export type PromptFillOrigin = {
/**
* The engine writing the box on its own account; reserved for its own
* sites, none of which raises `prompt.fill` as shipped.
*/
kind: 'engine';
} | {
/**
* A plugin's `$.prompt.fill`.
*/
kind: 'plugin';
/**
* The filling plugin's name.
*/
name: string;
};
PromptFillResult type
#
line 7544
Added in 2.1.268 · changed in 2.1.282
What a prompt.fill hook returns and what next(e) resolves to: whether the text went into the prompt box.
22 lines
export type PromptFillResult = {
/**
* True once the box holds the text; false where no box can take it (a
* dialog holds the keys, a headless session has none).
*
* A hook answering `{ isFilled: false }` without `next` keeps the text
* out.
*/
isFilled: boolean;
/**
* Why the box did not take the text, on the two refusals the engine
* itself answers: the session binds no prompt box (`no_composer`:
* headless, or a surface that draws its own composer), or a dialog holds
* the keys (`dialog`), so the write would land under it, unseen. A hook's
* own refusal carries none: the site strips a cause a hook writes itself,
* keeping only one its `next` gave it, passed up as it was. A caller
* branching on the cause treats an absent one as unknown and takes its
* refusing arm; `no_composer` is the only value that says no box exists
* to protect.
*/
refusal?: 'no_composer' | 'dialog';
};
PromptOrigin type
#
line 7575
In the first published surface (2.1.259)
Where a prompt.submit submission came from, as the engine knows it at the site it was queued from; a closed set, never a text prefix.
A hooks module reads e.origin.kind to tell the user's own Enter from a notification, a peer session, a schedule or another plugin. next(e) passes it on as received; an answer may leave it out; no hook sets one.
106 lines
export type PromptOrigin = {
/**
* The user's own gesture at the terminal, as the engine stamped it
* (never presumed from an unstamped command).
*
* Enter at the prompt, typed or queued, or a click on a transcript
* link; a channel the engine cannot attest (a same-user socket) is
* never stamped, and arrives as `unclassified`.
*/
kind: 'composer';
} | {
/**
* The user's message through the Remote Control bridge (a phone or
* web client).
*/
kind: 'bridge';
} | {
/**
* The SDK host's own turn (`claude -p`, the Agent SDK), not typed at
* a terminal.
*/
kind: 'sdk';
} | {
/**
* A background task's notification, dequeued when the session went
* idle or delivered into a running turn (`turnId` set).
*/
kind: 'task-notification';
} | {
/**
* A scheduled task, routine or /loop firing its stored prompt.
*/
kind: 'scheduled-trigger';
} | {
/**
* Another Claude session's message ("Another Claude session sent a
* message"), as a turn of its own or delivered into a running one.
*/
kind: 'peer';
} | {
/**
* Another session's SendMessage delivery, model-authored and framed
* as a notification.
*/
kind: 'peer-send-message';
} | {
/**
* A delivery a coordinating session composed for one of its threads.
*/
kind: 'projects-relay';
} | {
/**
* A message from a channel an MCP server relays (Slack, Telegram).
*/
kind: 'channel';
/**
* The channel server's name.
*/
server: string;
} | {
/**
* A coordinating session's hand-off to a worker session.
*/
kind: 'coordinator';
} | {
/**
* A background observer agent's report to the agent it observes.
*/
kind: 'observer';
} | {
/**
* An activity digest delivered to an observer agent.
*/
kind: 'observer-activity';
} | {
/**
* A programmatic follow-up to a user's UI action, user-initiated but
* not typed this turn.
*/
kind: 'auto-continuation';
} | {
/**
* A turn with no provenance the engine can name: one the ingress
* could not classify, or a command queued with no stamp at all.
*
* An idle notice or a delivery receipt the engine queued isMeta with
* no stamp is one too; the engine frames that shape as a non-user
* source.
*/
kind: 'unclassified';
} | {
/**
* The session's owner pinging it from Slack.
*/
kind: 'slack-ping';
} | {
/**
* A plugin's `$.prompt.submit`; the model reads the prompt under the
* plugin's name unless a hook leaves the origin out of its answer.
*/
kind: 'plugin';
/**
* The submitting plugin's name.
*/
name: string;
};
PromptSectionInput type
#
line 7686
In the first published surface (2.1.259)
The input of prompt.section: one named section of the system prompt, at the moment the engine assembles it.
export type PromptSectionInput = {
/**
* As the engine names the section (`env_info_simple`, `memory`, ...); the
* key a matcher narrows on.
*/
name: string;
/**
* The section's text as core computed it, or null when core omits it.
*/
text: string | null;
};
PromptSectionResult type
#
line 7702
In the first published surface (2.1.259)
What a prompt.section hook returns: the text the prompt carries for that section, or null to leave it out.
export type PromptSectionResult = {
text: string | null;
};
PromptSubmitArgs type
#
line 7713
In the first published surface (2.1.259) · changed in 2.1.269
prompt.submit's input as a plugin's call takes it: origin, turnId and wait are the engine's to set, context the hooks' to attach.
origin is the calling plugin's name; turnId is the turn a prompt typed mid-turn ran over; wait is false, as a plugin's prompt runs once idle.
export type PromptSubmitArgs = Omit<PromptSubmitInput, 'origin' | 'turnId' | 'wait' | 'context'>;
PromptSubmitAttachment type
#
line 7719
Added in 2.1.277
A pasted or attached non-text item of a submitted prompt; its kind, never its bytes.
14 lines
export type PromptSubmitAttachment = {
/**
* The item's kind.
*/
type: 'image' | 'audio' | 'document';
/**
* The item's MIME type (`image/png`), when known.
*/
mediaType?: string;
/**
* The pasted file's name, when it had one.
*/
filename?: string;
};
PromptSubmitInput type
#
line 7738
In the first published surface (2.1.259) · changed in 2.1.269, 2.1.277
The input of prompt.submit: the prompt as typed, after the input became a user message and before it enters the session.
44 lines
export type PromptSubmitInput = {
/**
* The prompt's text as it will reach the model (pastes already expanded).
*/
text: string;
/**
* Present only when the submission carried images or other non-text items.
*/
attachments?: readonly PromptSubmitAttachment[];
/**
* What the model reads beside the prompt and the user never sees, each
* entry one block after the prompt as typed; absent as the engine raises it.
*
* A hook attaches on the way down: `next({ ...e, context: [...(e.context
* ?? []), mine] })`, keeping which it likes; none empty, any length: past
* 100,000 characters (200,000 together) the model reads a head and path.
*/
context?: readonly string[];
/**
* The id of the model turn that was running when the prompt was submitted
* (`turn.start`'s `turnId`): typed over that turn, or delivered into it.
*
* A queued delivery (a peer session's message) reaches the model inside a
* running turn. Absent for a prompt submitted while the session was idle,
* and for a plugin's own (`$.prompt.submit`), which runs once it is idle.
*/
turnId?: string;
/**
* Whether the user asked the prompt to wait its turn (`chat:queueSubmit`,
* `ctrl+x enter` by default): true for that submission, false otherwise.
*
* The engine queues every prompt typed mid-turn either way; the flag is
* for hooks, so one that cancels the running turn on a plain Enter can
* leave a waiting prompt alone. False for a prompt a plugin submitted.
*/
wait: boolean;
/**
* Where the submission came from (PromptOrigin), set by the engine where
* it was queued: the user's Enter, a notification, a peer, a plugin.
*
* `next(e)` passes it on as received; no hook may set one.
*/
origin: PromptOrigin;
};
PromptSubmitResult type
#
line 7791
In the first published surface (2.1.259)
What a prompt.submit hook returns and what next(e) resolves to: the prompt that entered, { text, context?, origin? }, or { drop: reason }.
next(e) resolves once the prompt entered the session and its turn started, or it was queued behind the running one; not when the turn ends, which is turn.complete. A hook answering without next enters nothing.
35 lines
export type PromptSubmitResult = {
/**
* The prompt that entered; from core, the text that arrived at the
* bottom. A rewrite passes it down, `next({ ...e, text })`.
*/
text: string;
/**
* What entered beside the prompt for the model, never shown the user:
* from core, the context that arrived (`e.context`).
*
* Each entry is one block after the prompt as typed. A hook attaches
* context on the way down; one put here after `next` resolved is not
* attached (the prompt had entered), and is logged.
*/
context?: readonly string[];
/**
* Where the prompt entered from: from core, `e.origin` as received;
* absent, the prompt is the user's own.
*
* A hook may put back the origin it received; it may not set another.
*/
origin?: PromptOrigin;
drop?: undefined;
} | {
/**
* The prompt did not enter: a hook's refusal, answered without `next`,
* or a settings hook's block beneath.
*
* The text is shown to the user as the reason.
*/
drop: string;
text?: undefined;
context?: undefined;
origin?: undefined;
};
PromptSuggestArgs type
#
line 7831
Added in 2.1.268
prompt.suggest's input as a plugin's $.prompt.suggest(args) takes it: origin is the engine's to set (the calling plugin's name).
export type PromptSuggestArgs = Omit<PromptSuggestInput, 'origin'>;
PromptSuggestInput type
#
line 7837
Added in 2.1.268
The input of prompt.suggest (prompt-suggest/): a text about to be shown dim in the empty prompt box, for Tab (or the right arrow) to take.
export type PromptSuggestInput = {
/**
* The proposed prompt: shown, not written; taking it puts it in the box
* for editing. `next({ ...e, text })` proposes another.
*/
text: string;
/**
* Who proposes (PromptSuggestOrigin), set by the engine where the
* proposal starts. Pinned: `next(e)` passes it on as received.
*/
origin: PromptSuggestOrigin;
};
PromptSuggestOrigin type
#
line 7856
Added in 2.1.268
Who proposes the text at prompt.suggest, as the engine stamps it where the proposal starts; a closed set a matcher narrows on.
next(e) passes it on as received; no hook sets one.
16 lines
export type PromptSuggestOrigin = {
/**
* The engine's own guess at the person's next prompt, generated after
* a turn (the prompt-suggestion service).
*/
kind: 'suggestion';
} | {
/**
* A plugin's `$.prompt.suggest`.
*/
kind: 'plugin';
/**
* The proposing plugin's name.
*/
name: string;
};
PromptSuggestResult type
#
line 7877
Added in 2.1.268
What a prompt.suggest hook returns and what next(e) resolves to: whether the text is now the box's dim suggestion.
export type PromptSuggestResult = {
/**
* True once the box has the suggestion to show, at once or as soon as a
* dialog gives the box back; false where it cannot show.
*
* It cannot while the box holds text, a turn runs, the text is blank, or
* the session is headless. A hook answering `{ isShown: false }` without
* `next` keeps it from showing.
*/
isShown: boolean;
};
RasterBlitArgs type
#
line 7895
Added in 2.1.277
A $.ui.blit argument repainting one of the caller's mounted Rasters.
columns and rows, when given, must be the mounted size (a resize is a redraw, $.ui.invalidate("ui.render"), not a blit).
26 lines
export type RasterBlitArgs = {
/**
* The site the Raster is drawn in, by the `requestId` this plugin draws
* it under: one of its panes' ids, a tool row's `tool_use_id`, the band's.
*/
requestId: string;
/**
* The Raster's `key` in that drawing.
*/
key: string;
/**
* The new cells, encoded as the element's `cells` are (RasterProps), for
* the mounted `columns * rows`.
*/
cells: string;
/**
* The width the cells are laid out for; refused unless it is the mounted
* Raster's. Absent, the mounted width.
*/
columns?: number;
/**
* The height the cells are laid out for; refused unless it is the mounted
* Raster's. Absent, the mounted height.
*/
rows?: number;
};
RasterProps type
#
line 7930
Added in 2.1.271
The props of Raster, the terminal surface's cell-grid leaf: a fixed box of cells, each a glyph, a foreground and a background, packed in cells.
A leaf: no children, hover or onPress yet; repainted in place by $.ui.blit. Terminal only for now (elsewhere a fragment); its palette paints 1024 distinct color pairs at once and the rest as their nearest.
28 lines
export type RasterProps = {
/**
* The element's address within the drawing: what `$.ui.blit` names to
* repaint it, unique among the Rasters of one tree.
*/
key: string;
/**
* How many terminal columns wide, 1 to 512; the site clips what its body
* cannot show.
*/
columns: number;
/**
* How many terminal rows tall, 1 to 256.
*/
rows: number;
/**
* Every cell, row-major: standard padded base64 of `columns * rows`
* little-endian u32 triplets `[codePoint, foreground, background]`.
*
* A code point is one printable width-1 BMP character (blocks, box drawing,
* braille too), or the tree is refused naming the cell's index; a color is
* `0x00RRGGBB`, or `0x01000000` (bit 24 alone) for the terminal's default.
*
* @example const words = Uint32Array.of(0x2588, 0xff8800, 0x01000000)
* const cells = new Uint8Array(words.buffer).toBase64() // one orange cell
*/
cells: string;
};
ReadFunction type
#
line 7969
Added in 2.1.281
read($, source): the value of an atom (its initial while absent), of a derived value, or under a plain reference; one $.state.get per value.
Made while a ui.render hook draws, it subscribes the drawing as the calls it makes would.
const n = await read($, count)
export type ReadFunction = {
<T>($: StateDollar, source: Atom<T>): Promise<T>;
<T>($: StateDollar, source: Derived<T>): Promise<T>;
<P extends keyof PluginState & string, K extends keyof PluginState[P] & string>($: StateDollar, source: StateRef<P, K>): Promise<StateValue<P, K> | undefined>;
};
Register type
#
line 7986
In the first published surface (2.1.259) · changed in 2.1.267
The hooks module's entry: export function register(on, options). on registers hooks; options is the plugin's configuration (PluginOptions).
The options are fixed for this activation: a change to them reloads the plugin and register runs again with the new object. Hooks close over it. Its return is dropped, a promise awaited: on => on(...) is a module.
on("tool.call", ($, e, next) => e.tool === "Bash" ? { deny: "no" } : next(e))
export type Register = (on: On, options: PluginOptions) => unknown;
Registration type
#
line 7996
Added in 2.1.267
What on(...) returns for a hook of type F: the registration, which takes one .catch (CatchHandler); without it a failed hook is absent.
A second .catch on one registration throws, as does one after register() returned and one on engine.create, whose hook has no budget and whose failure is the load's.
export type Registration<F> = {
/**
* Sets the handler run when the hook throws or overruns its budget; its
* answer within the grace stands as the hook's result for the dispatch.
*
* The budget is HookBudget's `ms` and the grace its `catchMs`, both on
* the clock that stops while the code waits on `next` or `$`.
*/
readonly catch: (handler: CatchHandler<F>) => void;
};
RenderChildren type
#
line 8015
Added in 2.1.267 · changed in 2.1.268
What an element takes as children, as JSX passes them: a node, a number (drawn as its string), a value the factory drops, or a list that may nest.
false, null and undefined are dropped, so {ok && <Text>hi</Text>} and {n > 0 ? <Text>{n}</Text> : null} type; a mapped list beside a sibling nests. The element holds the flat, normalized list of RenderNode.
export type RenderChildren = RenderNode | number | boolean | null | undefined | readonly RenderChildren[];