Follow Discord
Sweep 20 Nov 2026 · 19:55Z Build v2.1.330 547 read Stable v2.1.323 Latest v2.1.330 Next v2.1.330 Feeds RSS JSON llms.txt llms-full.txt Unofficial
Mods API · 03 of 03

Types

Every declaration in the file, verbatim, with the doc comment above it.

Declarations833over 17 pages
Mined from2.1.330the shipped binary

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, 351 to 400 of 833

PromptMediaArgs type # line 11813

Added in 2.1.299

What $.prompt.media(args) takes: which attached item of the prompt being submitted to read, and from where in it.

  export type PromptMediaArgs = {
      /**
       * The item's handle, as `e.attachments` of the `prompt.submit` in flight
       * lists it.
       */
      id: string;
      /**
       * Where the slice starts, in bytes of the item: an earlier read's `next`.
       * Absent, the start.
       */
      offset?: number;
  };

PromptMentionAttached type # line 11834

Added in 2.1.290

How the engine attached a mentioned file, in the names prompt.attachment gives its type.

file: read now, whole or in part. already_read_file: the model holds it unchanged, nothing is sent again. pdf_reference: a PDF too long to inline, named for the model to open by pages.

  export type PromptMentionAttached = 'file' | 'already_read_file' | 'pdf_reference';

PromptMentionInput type # line 11844

Added in 2.1.290

The input of prompt.mention: one file a prompt names after an @, as the engine resolved it and before it is read for the model.

A hook rewrites what is read (path, offset, limit); mention and agentId are pinned. A directory and a path a deny rule covers raise nothing; whether a file is there is the read's to find.

32 lines
  export type PromptMentionInput = {
      /**
       * What followed the `@`, a path as the person typed it, a fragment
       * included (`#L10-20`). Pinned: what the prompt said.
       */
      mention: string;
      /**
       * The file's absolute path, as the engine resolved the mention.
       *
       * `next({ ...e, path })` reads another file, judged by the deny rules
       * where it lands, links followed. One read per mention: a second `next`
       * settles with the first's.
       */
      path: string;
      /**
       * The first line read, counted from 1, when the mention names lines
       * (`#L10`); absent for a whole file. A rewrite is where the read starts.
       */
      offset?: number;
      /**
       * How many lines are read when the mention names lines (`#L10-20` reads
       * 11); absent for a whole file. A rewrite is how many are read.
       */
      limit?: number;
      /**
       * The loop whose prompt carries the mention: a subagent's id, the `id`
       * `$.agent.list()` gives it; absent on main.
       *
       * Pinned: a different value is refused, one left out is kept.
       */
      agentId?: string;
  };

PromptMentionResult type # line 11884

Added in 2.1.290

What a prompt.mention hook returns and what next(e) resolves to: how the file was attached ({ type, context? }), or { deny: reason }.

The file's text is its attachment's, which prompt.attachment rewrites. A hook that answers without next had no file read.

34 lines
  export type PromptMentionResult = {
      /**
       * How the engine attached the file; null when it attached nothing: no
       * file is there, it is too large, or it cannot be read.
       *
       * From a hook answering without `next`: null, nothing was read.
       */
      type: PromptMentionAttached | null;
      /**
       * What the model reads after the prompt's mentioned files and the
       * person never sees, each entry one block. From core, none.
       *
       * An answer keeps every entry its `next` gave, none empty: one with
       * no `context` over a `next` that had one is refused. Past 100,000
       * characters (200,000 together) the model reads a head and a path.
       *
       * @example
       * return { ...result, context: [...(result.context ?? []), mine] }
       */
      context?: readonly string[];
      deny?: undefined;
  } | {
      /**
       * Refuses the mention: nothing of the file is attached, and a read
       * already made is forgotten. The debug log names the reason.
       *
       * From core: a deny rule covers the path a hook passed on. A context
       * beside it is dropped. A hook that throws or outlasts its budget is
       * skipped, and the file is read as if the hook were not there.
       */
      deny: string;
      type?: undefined;
      context?: undefined;
  };

PromptOrigin type # line 11927

In the first published surface (2.1.259) · changed in 2.1.286

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.

116 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 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 ("The <name> plugin
       * sent a message: ...") unless the plugin submitted it `asUser`.
       */
      kind: 'plugin';
      /**
       * The submitting plugin's name.
       */
      name: string;
      /**
       * True when the plugin submitted the text as the person's own words
       * (`$.prompt.submit({ text, asUser: true })`).
       *
       * The model reads it bare; the origin is still the plugin's for every
       * hook and provenance gate.
       */
      asUser?: true;
  };

PromptPaintArgs type # line 12050

Added in 2.1.311

What a plugin's $.prompt.paint(args) takes, and a hook on prompt.paint sees as e and may rewrite.

Whose runs they are is the caller's name, which no argument or hook sets.

18 lines
  export type PromptPaintArgs = {
      /**
       * The draft `decorations` were computed for: nothing paints unless the box
       * reads exactly this. May be left out only with an empty list.
       */
      text?: string;
      /**
       * This plugin's runs over the draft (PromptDecoration), replacing those it
       * painted before; an empty list clears them.
       *
       * Another plugin's stand, a later one winning per style key. The draft's next
       * change drops them, but for a `prompt.edit` hook in the terminal.
       *
       * @example await $.prompt.paint({ text,
       *   decorations: [{ start: 0, end: 4, underline: true }] })
       */
      decorations: PromptDecoration[];
  };

PromptPainted type # line 12078

Added in 2.1.311

What $.prompt.paint resolves to: whether the runs were painted, and the box as it stands (PromptBox).

A mod whose text went stale computes again from text.

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.

17 lines
  export type PromptPainted = {
      /**
       * True once the runs stand over the draft, or a clear took them off; false
       * where the box does not read `text`, or no box can take them.
       */
      isPainted: boolean;
      /**
       * The draft as it stands, which the call did not change; `''` 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`, which the call did
       * not move.
       */
      cursor: number;
  };

PromptSectionInput type # line 12100

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 = {
      /**
       * The section's id (`env_info_simple`, `memory`, ...), the same on every
       * model and the one `prompt.compose` lists; 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 12116

In the first published surface (2.1.259) · changed in 2.1.321

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;
      /**
       * Sends a changed answer at the next turn, rewriting the cache from the
       * system prompt on and dropping the model's earlier thinking.
       *
       * Left out, it waits for a new thread or a compaction. The outermost hook's
       * answer says so: a hook above that keeps it spreads what `next` gave.
       */
      breakPromptCache?: boolean;
  };

PromptSubmitArgs type # line 12135

In the first published surface (2.1.259) · changed in 2.1.269, 2.1.286, 2.1.299

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.

15 lines
  export type PromptSubmitArgs = Omit<PromptSubmitInput, 'origin' | 'turnId' | 'wait' | 'context' | 'command' | 'isMeta'> & {
      /**
       * Submit the text as the person's own words, read bare without the "The
       * <plugin> plugin sent a message" frame; absent means framed.
       *
       * The origin every hook sees stays `{ kind: 'plugin', name, asUser: true }`
       * and the transcript still names the plugin; `@file` mentions and pasted
       * images are not expanded for a plugin's prompt, `asUser` or not.
       * The turn is listed in /rewind, as a typed prompt is.
       *
       * @example
       * await $.prompt.submit({ text: 'what the person typed', asUser: true })
       */
      asUser?: true;
  };

PromptSubmitAttachment type # line 12155

Added in 2.1.277 · changed in 2.1.299

A pasted or attached non-text item of a submitted prompt; its kind, never its bytes, which $.prompt.media reads by the item's id.

22 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;
      /**
       * The engine's handle for the item while this `prompt.submit` is in flight:
       * `$.prompt.media({ id })` reads its bytes.
       *
       * Opaque, and the engine's to set, as the whole list is: whatever a hook
       * passes down for it, the hooks beneath read the engine's.
       */
      id?: string;
  };

PromptSubmitCommand type # line 12185

Added in 2.1.299

The slash command a submission runs, as the engine tells prompt.submit: the command as command.run's hooks left it, their change of arguments included.

const typed = { name: 'review', args: 'the diff' } // "/review the diff"
  export type PromptSubmitCommand = {
      /**
       * Which command, without its slash (`compact`, `hello`), aliases and
       * folds resolved: `command.run`'s `command`.
       */
      name: string;
      /**
       * Everything after the command: what was typed, or what a
       * `command.run` hook left of it; `""` when there was nothing.
       */
      args: string;
  };

PromptSubmitInput type # line 12202

In the first published surface (2.1.259) · changed in 2.1.269, 2.1.277, 2.1.299

The input of prompt.submit: the prompt as typed, after the input became a user message and before it enters the session.

69 lines
  export type PromptSubmitInput = {
      /**
       * The prompt's text as typed, pastes already expanded: what will reach
       * the model, or a slash command's line as `command.run` left it (`command`).
       */
      text: string;
      /**
       * The slash command the submission runs (PromptSubmitCommand), set by the
       * engine; a rewrite of `text` is then not applied, and the person is told.
       *
       * A `{ drop }` stops a skill or prompt command before it is rendered, and only
       * the turn of a built-in that asks the model, which has run. A command that
       * runs as a fork raises no `prompt.submit`. Mask arguments at `command.run`, a
       * skill's body at `skill.prompt`. Pinned: left out it is put back, changed it
       * fails the hook.
       *
       * @example
       * on('prompt.submit', ($, e, next) => next(e.command ? e : masked(e)))
       */
      command?: PromptSubmitCommand;
      /**
       * True, set by the engine, on a prompt the person does not see as typed.
       * Delivered into a running turn it takes a rewrite; starting a turn, none.
       *
       * Pinned: left out it is put back, changed it fails the hook.
       *
       * @example
       * ($, e, next) => (e.isMeta && bad(e) ? { drop: 'no' } : next(masked(e)))
       */
      isMeta?: true;
      /**
       * 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 12280

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.

37 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, a settings hook's block
       * beneath, or the engine's own (a Stop stands, a host's limit reached).
       *
       * A hook's text is shown to the user as the reason; the engine's is
       * logged. After a `next(e)` of the hook's was answered, a drop fails it:
       * its `.catch` is asked, or it is skipped by name, its last `next` kept.
       */
      drop: string;
      text?: undefined;
      context?: undefined;
      origin?: undefined;
  };

PromptSuggestArgs type # line 12322

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 12328

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 12347

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 12368

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 12386

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 12421

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 12460

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 12477

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;

RegisteredToolSpec type # line 12483

Added in 2.1.293

A ToolSpec as $.tool.register hands it on: the input schema filled in, isDeferred as the plugin gave it.

  export type RegisteredToolSpec = {
      name: string;
      description: string;
      inputSchema: Record<string, unknown>;
      isDeferred?: ToolDeferral;
  };

Registration type # line 12503

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.

on(...).catch(($, e, next) => next.called ? next(e) : { deny: "no" })
13 lines
  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 `$`.
       *
       * @remarks `claude plugin validate` lists each gating hook with or
       *   without one.
       */
      readonly catch: (handler: CatchHandler<F>) => void;
  };

RenderChildren type # line 12525

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[];

RenderComponent type # line 12540

In the first published surface (2.1.259) · changed in 2.1.265, 2.1.271, 2.1.277, 2.1.314, 2.1.317, 2.1.323, 2.1.326

Everything ui.render can draw: one name per component that has a render site; a matcher narrows on it.

The permission dialog is drawn by the engine alone, since its answer authorises an action; a plugin adds context with $.ui.notice. Pane is a component whose instances a plugin opens ($.ui.open), Placed another ($.ui.place), and Backdrop the one a plugin sets ($.theme.set), drawn behind the conversation by the desktop and mobile apps alone. AbovePromptList is the band's arrangement of its AbovePrompt rows. ContextMenu is asked as the person opens the menu on a transcript row, and holds the rows a plugin adds to it.

  export type RenderComponent = 'AskUserQuestion' | 'UserMessage' | 'AssistantMessage' | 'ToolUse' | 'ToolResult' | 'ToolGroup' | 'ToolProgress' | 'CommandOutput' | 'Spinner' | 'TurnDuration' | 'InfoNotice' | 'SessionMode' | 'PromptHint' | 'AbovePrompt' | 'AbovePromptList' | 'AgentRow' | 'ContextMenu' | 'Pane' | 'Placed' | 'Backdrop';

RenderElement type # line 12550

In the first published surface (2.1.259) · changed in 2.1.260, 2.1.265, 2.1.267, 2.1.271, 2.1.274, 2.1.275, 2.1.277, 2.1.282, 2.1.283, 2.1.295, 2.1.301, 2.1.307, 2.1.323, 2.1.326

What a render hook returns, and what next(e) resolves to: a plain-data tree of elements (a Box or Text is a StyledElement), strings as children.

Props are an allowlisted subset of Ink's Box/Text props (the ones ElementProps declares); a tree with any other prop fails validation as a whole and the engine's own component is drawn, its props as handed down.

364 lines
  export type RenderElement = StyledElement<'Box', BoxHoverProps> | StyledElement<'Text', TextHoverProps> | {
      /**
       * A button, on every surface: `[ label ]` on the terminal, a native
       * button on a desktop; a press raises `ui.press` (`e.element` the key).
       *
       * Built by `<Button>` or the table's `t.Button`. The `onPress` closure
       * stays in the plugin's own environment under `press.handle`; the host
       * holds the handle for the lifetime of the drawing.
       */
      type: 'Button';
      props: {
          /**
           * The element's address: what `e.element` carries and what a matcher
           * names (`{ element: "explain" }`).
           */
          key: string;
          /**
           * The text drawn on the button; where it holds `children`, the name
           * of the control, which a surface that draws no children draws.
           */
          label: string;
          /**
           * One digit (`"1"`) or one lowercase letter (`"w"`) that presses it
           * while the plugin's site holds the focus; anything else is refused.
           *
           * The band after ctrl+x tab or a click, a focused `Pane`: on keydown,
           * lowercased; never from the composer, save a bare digit in an empty
           * one pressing a band Button. Two of one plugin on one hotkey: the
           * later wins. Two plugins on one hotkey: it presses neither.
           */
          hotkey?: string;
          /**
           * An engine keybinding action (`"app:cycleDiffBase"`) whose chord
           * presses the Button from the prompt; an unknown name is refused.
           *
           * Chords, or a modified key Global or an active context binds, on
           * the terminal while mounted, no dialog up, no engine handler of it
           * mounted; a pane's over the band's over another's, the last drawn.
           */
          action?: string;
          /**
           * Drawn without chrome: the hotkey in the accent color, a colon,
           * then the label (`1: Yes`); without a `hotkey`, the label alone.
           *
           * The focus still inverts it. In JSX the label may be the one string
           * child (`<Button hotkey="1" plain onPress={...}>Yes</Button>`); the
           * key defaults to the label.
           */
          plain?: true;
          /**
           * The label dim at rest, as `Text`'s `dimColor`, and at full strength
           * under the pointer or the focus; absent draws as false.
           */
          dimColor?: TextProps['dimColor'];
          /**
           * `"primary"` marks the main action of several, drawn as the surface
           * marks the one to press; `"secondary"`, and absent, draw as before.
           *
           * The terminal draws a primary in the accent color; `plain` wins over
           * it. Carried to every surface as written, never filled in.
           *
           * @example { key: 'save', label: 'Save', variant: 'primary' }
           */
          variant?: ButtonProps['variant'];
          /**
           * `"dismiss"` marks the Button that closes its site, a drawing hint
           * only: the terminal draws it as without, a desktop its close control.
           *
           * Carried to every surface as written, never filled in.
           *
           * @example { key: 'dismiss', label: 'Dismiss', role: 'dismiss' }
           */
          role?: ButtonProps['role'];
          /**
           * The site's ring starts on this element when the site takes the
           * keyboard; the first drawn of several. Absent draws as before.
           */
          autoFocus?: true;
      };
      /**
       * Where the handler lives: the plugin whose hook drew the element, and
       * the handle its environment keeps the `onPress` closure under.
       *
       * The runtime stamps the plugin as the tree leaves that hook.
       */
      press: {
          plugin: string;
          handle: number;
      };
      /**
       * Label style overrides (the Text set) the surface applies while the
       * nearest keyed Box, or the group `scope` names, is hovered; plain data.
       */
      hover?: TextHoverProps;
      /**
       * What is drawn in the label's place, all of it one pressable: strings
       * and `Text` (a chip, a dim part), any other element refused.
       *
       * Absent for a Button of a label alone, drawn as it always was.
       */
      children?: RenderNode[];
  } | {
      /**
       * A text field on every surface, of one line or of `rows`; a change and
       * Enter raise `ui.input` (`e.element`, `e.kind`, `e.value` the text).
       *
       * Built by `<Input>` or the table's `t.Input`. The `onInput` and
       * `onSubmit` closures stay in the plugin's own environment under
       * `press.handle`, held as a Button's is. A leaf: no children.
       */
      type: 'Input';
      props: {
          /**
           * The element's address: what `e.element` carries and what a matcher
           * names (`{ element: "reply" }`).
           */
          key: string;
          /**
           * Text drawn before the field.
           */
          label?: string;
          /**
           * Text drawn dim in an empty field.
           */
          placeholder?: string;
          /**
           * The text the field holds when drawn.
           */
          value?: string;
          /**
           * What Enter does, drawn beside the field while it has focus.
           */
          submitLabel?: string;
          /**
           * How many lines tall the field is; from 2 it holds several lines.
           * Absent is one.
           */
          rows?: number;
          /**
           * The site's ring starts on this element when the site takes the
           * keyboard; the first drawn of several. Absent draws as before.
           */
          autoFocus?: true;
      };
      /**
       * Where the handlers live: the plugin whose hook drew the element, and
       * the handle its environment keeps the closures under.
       *
       * The runtime stamps the plugin as the tree leaves that hook.
       */
      press: {
          plugin: string;
          handle: number;
      };
      children?: undefined;
  } | {
      /**
       * A one-of-several picker on every surface; a pick raises `ui.select`
       * (`e.element` the key, `e.value` the option's value).
       *
       * Built by `<Select>` or the table's `t.Select`. The `onSelect` closure
       * stays in the plugin's own environment under `press.handle`, held as
       * a Button's is. A leaf: no children.
       */
      type: 'Select';
      props: {
          /**
           * The element's address: what `e.element` carries and what a matcher
           * names (`{ element: "peer" }`).
           */
          key: string;
          /**
           * Text drawn before the current value.
           */
          label?: string;
          /**
           * What can be picked, in the order drawn: each a value and the text
           * drawn for it.
           */
          options: readonly SelectOption[];
          /**
           * Which option is selected when drawn.
           */
          value?: string;
          /**
           * The site's ring starts on this element when the site takes the
           * keyboard; the first drawn of several. Absent draws as before.
           */
          autoFocus?: true;
      };
      /**
       * Where the handler lives: the plugin whose hook drew the element, and
       * the handle its environment keeps the closure under.
       *
       * The runtime stamps the plugin as the tree leaves that hook.
       */
      press: {
          plugin: string;
          handle: number;
      };
      children?: undefined;
  } | {
      /**
       * A hyperlink every surface draws: an OSC 8 span on the terminal (its
       * text then the URL in dim where unsupported), an anchor on desktop.
       *
       * Inline: its children are the text, strings and inline elements;
       * absent children the label, absent both the URL. `href` is drawn as
       * written; one that is no string draws the text plain.
       */
      type: 'Link';
      props: LinkProps;
      children?: RenderNode[];
  } | {
      /**
       * Source code every surface draws with the engine's highlighter, tokens
       * coloured by language; under `format: 'diff'`, unified-diff hunks.
       *
       * A leaf: a dim gutter numbers the lines from `startLine`; a diff has
       * both gutters, markers, add and remove backgrounds. `source` is
       * checked as a Text's string is, or the tree is refused.
       */
      type: 'Code';
      props: CodeProps;
      children?: undefined;
  } | {
      /**
       * A block of markdown every surface draws as it draws an assistant
       * reply's text: its own renderer, theme, hyperlinks and highlighting.
       *
       * Built by `<Markdown>` or the table's `t.Markdown`. A leaf: `text` is
       * checked as a Text's string is, or the tree is refused. Without a
       * `press` its links are the surface's own, opened as it opens links.
       */
      type: 'Markdown';
      props: MarkdownLeafProps;
      /**
       * Whose `key` it is, set by the engine on a keyed one as the tree
       * leaves its hook, as a Box's `part` is.
       */
      part?: PluginStamp;
      children?: undefined;
  } | {
      /**
       * A `Markdown` whose plugin answers the links it drew (`onLinkPress`):
       * a press on one raises `ui.press` with `e.link`, the surface opens none.
       */
      type: 'Markdown';
      props: MarkdownLeafProps;
      /**
       * Where the `onLinkPress` handler lives: the plugin whose hook drew
       * the element, and the handle its environment keeps the closure under.
       *
       * The runtime stamps the plugin as the tree leaves that hook.
       */
      press: {
          plugin: string;
          handle: number;
      };
      children?: undefined;
  } | {
      /**
       * A region one of the plugin's SURFACE MODULES, named by path, draws and
       * handles input for on the drawing thread, without `$` (ClientModule).
       *
       * `Client` from the table. One instance per plugin, drawing and `key`
       * lives while the node stays in the tree, and talks to the plugin's
       * hooks through `ui.message`. The desktop carries it as data.
       */
      type: 'Client';
      props: ClientProps;
      /**
       * Whose surface module `props.module` names: the plugin whose hook
       * drew the element, stamped by the runtime as the tree leaves it.
       */
      client: {
          plugin: string;
      };
      children?: undefined;
  } | {
      /**
       * A vector drawing, the remote surfaces' alone: the SVG markup is the
       * element's data, drawn in an isolated box, off the page.
       *
       * A leaf: hooks above wrap or replace it whole, nothing reaches inside;
       * a press other plugins should see goes on an enclosing Button. On a
       * surface whose table lacks it the tree is refused.
       */
      type: 'Svg';
      props: SvgProps;
      children?: undefined;
  } | {
      /**
       * A `Backdrop`'s scene played on the GPU, over the one `Svg` that shows
       * wherever it does not play (ShaderProps).
       */
      type: 'Shader';
      props: ShaderProps;
      /**
       * Whose file `props.module` names: the plugin whose hook drew the
       * element, stamped by the runtime as the tree leaves it.
       */
      shader?: PluginStamp;
      children?: RenderNode[];
  } | {
      /**
       * How far along a task is, or that it is still running. Hooks above wrap
       * it, replace it or rewrite its props. A mobile client that names it in
       * `draws` is sent this node; any other client, on any surface, gets its
       * Box and Text. A surface module cannot draw one.
       */
      type: 'Progress';
      props: ProgressProps;
      children?: undefined;
  } | {
      /**
       * A grid of terminal cells, the terminal surface's alone: each cell a
       * glyph, a foreground and a background, packed in `props.cells`.
       *
       * A leaf, one node however many cells; hooks above wrap or replace it
       * whole. A mounted one is repainted in place by its plugin's
       * `$.ui.blit`. On a surface whose table lacks it the tree is refused.
       */
      type: 'Raster';
      props: RasterProps;
      /**
       * Whose Raster: the plugin whose hook drew the element, stamped by the
       * runtime as the tree leaves it; the one plugin whose blit reaches it.
       */
      raster: {
          plugin: string;
      };
      children?: undefined;
  } | {
      /**
       * A picture, the terminal surface's alone: `props.source` drawn over a
       * box of cells where the terminal can, `props.alt` where it cannot.
       *
       * A leaf: hooks above wrap or replace it whole; a press other plugins
       * should see goes on an enclosing Button; keyed, its plugin's
       * `$.ui.blit` swaps it. On a surface without it the tree is refused.
       */
      type: 'Image';
      props: ImageProps;
      /**
       * Whose Image: the plugin whose hook drew the element, stamped by the
       * runtime as the tree leaves it; the one plugin whose blit reaches it.
       */
      image: {
          plugin: string;
      };
      children?: undefined;
  } | {
      /**
       * The component core draws itself, with the props held under `ref`.
       */
      type: 'engine';
      /**
       * Which drawing: the number core answered from `next(e)`, under which
       * it holds the props it received; 0, as any number `next` did not hand
       * this hook, draws the props as this hook received them.
       */
      ref: number;
  };

RenderEventName type # line 12919

In the first published surface (2.1.259)

The render event: ui.render, one event for every component that has a render site.

  export type RenderEventName = 'ui.render';

RenderInput type # line 12925

In the first published surface (2.1.259)

The input of ui.render: a union discriminated by component, one member per RenderComponent and per RenderSurface.

  export type RenderInput<C extends RenderComponent = RenderComponent, P extends RenderSurface = RenderSurface> = C extends RenderComponent ? P extends RenderSurface ? RenderInputOf<C, P> : never : never;

RenderInputOf type # line 12930

In the first published surface (2.1.259) · changed in 2.1.323

One ui.render input, for a component narrowed to one surface.

44 lines
  export type RenderInputOf<C extends RenderComponent, P extends RenderSurface> = {
      /**
       * Where the tree will be drawn; one literal per member, so
       * `if (e.surface === "terminal")` narrows `e` and `$.ui.resolve(e)`.
       *
       * Over the wire it is what the client declared, a rendering fact and not a
       * trust signal: do not key policy on it.
       */
      surface: P;
      /**
       * Which component this instance is; the key a matcher narrows on.
       */
      component: C;
      /**
       * The instance: the tool_use_id for a dialog or tool row, the message id
       * for a message, the agent id for a spinner.
       *
       * Two drawings of one component are two instances.
       */
      requestId: string;
      /**
       * Whose this drawing is, where it is one plugin's: the plugin an
       * `AbovePrompt` row or `ContextMenu` rows are asked of, the plugin that
       * opened a `Pane`.
       *
       * The engine's word, pinned: a rewrite carries it on as received. It is a
       * default matcher key: a hook leaving it out hears its own plugin's drawings
       * alone here; one naming it is read as written, `{ plugin: "*" }` for all.
       */
      plugin?: string;
      /**
       * The size of what the surface draws into, in character cells, and whether
       * its layout docks a pane; absent where no surface has measured.
       *
       * Part of the envelope: a rewrite keeps it. On the terminal, the interactive
       * screen's, where a change of width re-draws every hooked site once the
       * resize settles; on a remote surface, what it reported.
       */
      viewport?: RenderViewport;
      /**
       * The component's plain-data props.
       */
      props: RenderPropsOf[C];
  };

RenderNode type # line 12978

In the first published surface (2.1.259)

A node of a render tree: an element, or a string (text).

  export type RenderNode = RenderElement | string;

RenderPropsOf type # line 12988

In the first published surface (2.1.259) · changed in 2.1.260, 2.1.265, 2.1.267, 2.1.268, 2.1.269, 2.1.271, 2.1.274, 2.1.275, 2.1.277, 2.1.286, 2.1.290, 2.1.304, 2.1.314, 2.1.317, 2.1.318, 2.1.321, 2.1.323, 2.1.326

The plain-data props of each renderable component, as ui.render sees them under e.props; a hook rewrites them with next({ ...e, props }).

A rewrite is validated by the component and an invalid one draws what its hook received. This table is the plugin-facing render contract; the author's file notes which surfaces raise each member (RENDER_SURFACES_OF).

977 lines
  export type RenderPropsOf = {
      /**
       * The dialog the AskUserQuestion tool opens.
       *
       * A tree for it holds the engine's node once, nothing below it, in at most
       * 12 rows on the terminal and 48 on desktop, vscode and mobile, counted at
       * 40 columns; Markdown on those three alone; no size or place on any.
       *
       * Raised on every attached surface.
       */
      AskUserQuestion: {
          /**
           * The name of the tool whose call opened the dialog (`AskUserQuestion`).
           */
          tool: string;
          /**
           * The tool's `questions` input, as the dialog will draw them; a rewrite
           * must still fit the tool's schema or what it received is drawn. Claude
           * Code's own confirmations are drawn as asked, whatever a rewrite says.
           */
          questions: unknown[];
          /**
           * The call's `metadata.source` (who asked) when the model gave one.
           * Analytics only; never drawn.
           */
          metadataSource?: string;
      };
      /**
       * A user-role transcript row: the person's prompt (`> ...`), a background
       * task's notification, or a message another agent, teammate or session sent.
       *
       * `origin`, `task` and `from` tell them apart and are read-only; a rewrite
       * of `text` draws in the row alone: the stored message, and the model's
       * framing of another party's words as that party's, stay as they were.
       *
       * Raised on every attached surface.
       */
      UserMessage: {
          /**
           * What the row shows: the prompt as typed, a notification's summary, or
           * a message's body less the engine's framing (summary line included).
           * A plugin's prompt is the text it sent; `origin.name` names the plugin.
           *
           * A rewrite is printable text, drawn up to its first 100000 characters
           * where the engine draws the body; a teammate block of several frames or
           * with a summary line keeps the engine's drawing: one string is not those.
           */
          text: string;
          /**
           * Where the stored message came from, as `prompt.submit` named it: the
           * composer's, a task notification's, a peer's, a channel's, a plugin's.
           *
           * `unclassified` for a teammate's (its drain stamps none) and for a
           * message stored before stamps. Read-only.
           */
          origin: PromptOrigin;
          /**
           * Whether the view draws the row in full: the ctrl+o transcript,
           * `--verbose`, a surface with no ctrl+o (an export). Read-only.
           *
           * So does a row under a speaker label whose body fits the label view's
           * cap. False, a message row is one dim line naming its sender (under a
           * speaker label, the capped head of a long body).
           *
           * @remarks A hook that draws a compact row of its own passes when true,
           *   so ctrl+o shows all.
           */
          isExpanded: boolean;
          /**
           * What a notification row (`origin.kind` `task-notification`) reports
           * on: its background task; absent on every other row. Read-only.
           */
          task?: UserMessageTask;
          /**
           * Who sent the message the row carries: another agent of this session, a
           * teammate, another session, a channel; absent otherwise. Read-only.
           */
          from?: UserMessageFrom;
          /**
           * Which of its rows the transcript's viewport shows now: `null` while
           * drawn outside it, absent where the surface does not say. Read-only.
           *
           * Reported once drawn and again when it changes: on a scroll, for the
           * messages at the viewport's edges only. A rewrite carries it on as
           * received; one that changes or drops it is refused.
           */
          onScreen?: OnScreen | null;
      };
      /**
       * One block of an assistant reply in the transcript: its text, or a summary
       * of the text the model wrote between two tool calls.
       *
       * A rewrite changes the drawing and leaves the stored message alone
       * (ctrl+o). `isSummary` tells the two apart.
       *
       * Raised on every attached surface.
       */
      AssistantMessage: {
          /**
           * The block's text, markdown, as the surface's transcript will draw it:
           * what it hides of a reply (the terminal's, a `<context>` block) is gone.
           */
          text: string;
          /**
           * True on the block that draws the bullet opening a reply.
           */
          isFirstOfReply: boolean;
          /**
           * True on a block that holds a summary of the model's text, not the text
           * itself; absent on any other block, and where the surface does not say.
           *
           * Where the terminal marks such a row (a faint ` · summary` after its last
           * line), it marks a rewritten `text` too; a hook's own tree draws without
           * the mark. Read-only.
           *
           * @remarks A rewrite carries it on as received; one that changes or drops
           *   it, or adds it, is refused, the hook that passed it failing.
           */
          isSummary?: true;
          /**
           * Which of its rows the transcript's viewport shows now: `null` while
           * drawn outside it, absent where the surface does not say. Read-only.
           *
           * Reported once drawn and again when it changes: on a scroll, for the
           * messages at the viewport's edges only. A rewrite carries it on as
           * received; one that changes or drops it is refused.
           */
          onScreen?: OnScreen | null;
      };
      /**
       * A tool call's row in the transcript (`Bash(ls -la)` and its result); the
       * call was decided by `tool.call`, so a rewrite here changes the row alone.
       *
       * In mobile apps, a `borderStyle` or `backgroundColor` on the Box that holds
       * the row and something else asks for a card under the row; otherwise a tree
       * that keeps the row usually draws as one quiet line under it, with the rest
       * behind a tap, so plain Text suits a small status.
       *
       * Raised on every attached surface.
       */
      ToolUse: {
          /**
           * The id `tool.call` carried for this call (`e.tool_use_id` there); the
           * same value as the row's `requestId`, where it is looked for. Read-only.
           */
          tool_use_id: string;
          /**
           * Which one the row draws (`Bash`, `Read`, a plugin's tool), as
           * `tool.call` named it.
           */
          tool: string;
          /**
           * The call's input, as the model sent it.
           */
          input: unknown;
          /**
           * True while the call is still running.
           */
          isRunning: boolean;
          /**
           * True when the call ended in an error (a refusal at the dialog is one).
           */
          isErrored: boolean;
          /**
           * True when an abort ended the call: the user's Esc or a plugin's
           * `$.turn.abort` cut it while it ran, or dropped it before it ran.
           *
           * The row draws `Interrupted` for it, as the transcript marker does.
           */
          isInterrupted: boolean;
          /**
           * Whether the view draws the row in full: the ctrl+o transcript,
           * `--verbose`, or a `ToolGroup` that a hook unfolded into rows. Absent
           * where the surface does not say. Read-only.
           *
           * A hook that draws a compact row of its own passes when true, so ctrl+o
           * shows all.
           */
          isExpanded?: boolean;
          /**
           * The stored result once the call has resolved (`{ stdout, stderr, ... }`
           * for Bash: `BuiltinToolResults[tool]`); undefined while it runs.
           *
           * For a call that errored, was refused or an abort cut, it is the text
           * the model read (an `isInterrupted` call: the abort's own). An expanded
           * group's rows draw it inline; a standalone row's is its own `ToolResult`.
           */
          output?: unknown;
          /**
           * Which of its rows the transcript's viewport shows now: `null` while
           * drawn outside it, absent where the surface does not say. Read-only.
           *
           * Reported once drawn and again when it changes: on a scroll, for the
           * messages at the viewport's edges only. A rewrite carries it on as
           * received; one that changes or drops it is refused.
           */
          onScreen?: OnScreen | null;
      };
      /**
       * The result block drawn under a standalone tool row in the transcript,
       * which the tool's own result renderer draws from `output`.
       *
       * A rewrite of `output` is checked against the tool's output schema (one
       * that does not fit draws nothing; one the renderer cannot read hits the
       * row's error boundary). The stored result is untouched.
       *
       * Raised on every attached surface.
       */
      ToolResult: {
          /**
           * The id `tool.call` carried for the call this result belongs to
           * (`e.tool_use_id` there); the same value as `requestId`. Read-only.
           */
          tool_use_id: string;
          /**
           * Which one the result belongs to (`Bash`, `Read`, a plugin's tool).
           * Read-only.
           */
          tool: string;
          /**
           * The tool's own result object (`{ stdout, stderr, interrupted, ... }` for
           * Bash), the same one `ToolUse.output` carries; a rewrite is drawn.
           *
           * A built-in tool's is `BuiltinToolResults[tool]`, the record
           * `tool.call` resolved as `result`.
           */
          output: unknown;
          /**
           * True when the call ended in an error, which draws the error text and not
           * `output`. Read-only.
           */
          isErrored: boolean;
          /**
           * Whether the view draws the row in full: the ctrl+o transcript,
           * `--verbose`. Absent where the surface does not say. Read-only.
           *
           * A hook that draws a compact row of its own passes when true, so ctrl+o
           * shows all.
           */
          isExpanded?: boolean;
          /**
           * Which of its rows the transcript's viewport shows now: `null` while
           * drawn outside it, absent where the surface does not say. Read-only.
           *
           * Reported once drawn and again when it changes: on a scroll, for the
           * messages at the viewport's edges only. A rewrite carries it on as
           * received; one that changes or drops it is refused.
           */
          onScreen?: OnScreen | null;
      };
      /**
       * A run of tool calls the transcript folds into one count line (`Read 3
       * files, ran 2 shell commands`): reads, searches, listings.
       *
       * A hook that sets `isExpanded` unfolds the group where it is, and each row
       * it unfolds into is a `ToolUse` drawing a `ToolUse` hook then sees.
       *
       * @remarks In fullscreen mode the ctrl+o transcript does not fold runs: each
       *   call there is a `ToolUse` row and no `ToolGroup` is drawn.
       *
       * Raised on every attached surface.
       */
      ToolGroup: {
          /**
           * In the order the model made them.
           */
          calls: ReadonlyArray<ToolGroupCall>;
          /**
           * True while the group is the live one: a call in it may still be
           * running and the model's next call may join it.
           */
          isActive: boolean;
          /**
           * Whether each call draws as its own `ToolUse` row, or the group draws
           * one line.
           *
           * True under `--verbose` and in the non-fullscreen ctrl+o transcript. The
           * only prop a rewrite changes on the screen.
           */
          isExpanded: boolean;
          /**
           * True when the group holds nothing but `calls` and the model's thinking
           * between them, and no call errored or was interrupted: no recalled
           * memory, hook timing or other row. What the line shows from the calls'
           * own input and output (paths, patterns, git results) counts as calls.
           * Absent where the surface does not say. Read-only.
           *
           * A hook that draws a group of its own calls in its own way checks it is
           * true. Such a hook still replaces the summary of the current task that
           * the live group's line can show in place of its counts.
           */
          isCallsOnly?: boolean;
          /**
           * Which of its rows the transcript's viewport shows now: `null` while
           * drawn outside it, absent where the surface does not say. Read-only.
           *
           * Reported once drawn and again when it changes: on a scroll, for the
           * messages at the viewport's edges only. A rewrite carries it on as
           * received; one that changes or drops it is refused.
           */
          onScreen?: OnScreen | null;
      };
      /**
       * The output row a slash command printed in the transcript, under its echo
       * (`/cost`'s lines, the `text` a `command.run` hook answered).
       *
       * What the run resolved as text, a `local` command's or a plugin's alike. A
       * rewrite of `text` draws there and the stored row keeps what the model
       * reads; a hook's own tree draws in the row's place, the transcript's width.
       *
       * Raised on every attached surface.
       */
      CommandOutput: {
          /**
           * Which one printed the row, as `command.run` named it (no slash); a
           * hook on its own command matches by it.
           *
           * Read-only: a rewrite carries it on as received; one that changes or
           * drops it is refused and the engine draws its own row.
           */
          command: string;
          /**
           * The arguments the run had, as the echo above the row shows them
           * (`***` for a command that marks its arguments sensitive). Read-only.
           */
          args: string;
          /**
           * The row's text: what the command printed, or the `text` a hook
           * answered under its plugin's name; markdown, as the row draws it.
           */
          text: string;
          /**
           * True when the row is the run's error line (a command that threw),
           * which draws in the error colour and not dim. Read-only.
           */
          isErrored: boolean;
          /**
           * Which of its rows the transcript's viewport shows now: `null` while
           * drawn outside it, absent where the surface does not say. Read-only.
           *
           * Reported once drawn and again when it changes: on a scroll, for the
           * messages at the viewport's edges only. A rewrite carries it on as
           * received; one that changes or drops it is refused.
           */
          onScreen?: OnScreen | null;
      };
      /**
       * One row of the live tool-progress region under a running tool call; today
       * the run-in-background pill. One instance per row.
       *
       * A union on `kind`: other progress kinds join as their props become plain
       * data, each with its own fields, so a hook matches `{ props: { kind:
       * "background_hint" } }` or branches on `e.props.kind` and stays right.
       *
       * Raised on the terminal surface only.
       */
      ToolProgress: {
          /**
           * The tool call the row belongs to, as `tool.call` and the `ToolUse` row
           * carry it. Read-only: a rewrite carries it on as received.
           *
           * While several foreground calls share one pill, the first of them.
           */
          tool_use_id: string;
          /**
           * Which progress row: the run-in-background pill. Read-only.
           */
          kind: 'background_hint';
          /**
           * The pill's text as the engine draws it, dim, under the tool call:
           * `(ctrl+b to run in background)`, or with the person's own binding.
           *
           * A rewrite is drawn in its place, dim; `""` draws nothing. A hook that
           * returns a tree draws that instead.
           */
          hint: string;
      };
      /**
       * The line that animates while a turn runs (`Sauteing... (12s, 300
       * tokens)`); on the desktop, the row that carries the turn's mark.
       *
       * Reads `word` (or `message` while one overrides it), `suffix`, then what
       * the surface keeps and no prop carries: elapsed time, tokens, effort. A
       * hook rewrites the first three, or draws a tree in place of all of it.
       *
       * Raised on the terminal, desktop and vscode surfaces only.
       */
      Spinner: {
          /**
           * Animated by the line (`Sauteing`), as sampled for this turn.
           *
           * On the desktop, what the row says its step is doing (`Creating
           * notes.md`), or `Working` while the row shows no words.
           */
          word: string;
          /**
           * The text drawn instead of the word while a state overrides it, else null.
           */
          message: string | null;
          /**
           * What the engine draws right after the word or message to say the turn is
           * still going: one ellipsis character.
           *
           * Left off a text that already ends in an ellipsis, so a rewritten
           * `message` ending in one shows one. A rewrite is drawn as given (`""`
           * draws the text bare, `" ~"` draws `Sauteing ~`); left out, the engine's.
           */
          suffix: string;
          /**
           * What the turn is doing. The desktop tells `thinking`, `requesting`,
           * `tool-use` and `responding` apart and never says `tool-input`.
           */
          mode: 'requesting' | 'responding' | 'thinking' | 'tool-input' | 'tool-use';
      };
      /**
       * The line that closes a turn in the transcript (`Baked for 3s`); a
       * remote surface draws its own footer.
       *
       * Raised on the terminal surface only.
       */
      TurnDuration: {
          /**
           * The past-tense word the line drew (`Baked`), as sampled for this line.
           */
          word: string;
          /**
           * The turn's duration in milliseconds, as the line formats it (`3s`,
           * `1m 4s`).
           */
          durationMs: number;
          /**
           * Whether the view is the ctrl+o transcript or `--verbose`. Absent where
           * the surface does not say. Read-only.
           *
           * A hook that draws a compact row of its own passes when true, so ctrl+o
           * shows all.
           */
          isExpanded?: boolean;
          /**
           * What the line waits on while it draws only its waiting text
           * (`Waiting for 2 background agents to finish`: no budget, no
           * hidden-messages count), read when the row mounts: the pending agents
           * that started at or before the line's time. That can include an agent
           * the line did not count, such as one resumed since the line, or, in a
           * subagent's transcript, one that is not that subagent's child. Absent
           * while it draws anything else, or when their count differs from the
           * count it draws. Read-only.
           *
           * A hook that redraws the line for its own agents checks that each agent
           * is its own and that `workflows` is 0.
           */
          waitingFor?: WaitingFor;
          /**
           * Which of its rows the transcript's viewport shows now: `null` while
           * drawn outside it, absent where the surface does not say. Read-only.
           *
           * Reported once drawn and again when it changes: on a scroll, for the
           * messages at the viewport's edges only. A rewrite carries it on as
           * received; one that changes or drops it is refused.
           */
          onScreen?: OnScreen | null;
      };
      /**
       * One dim status line under the logo (the model source, an experiment
       * enrollment, a settings hint), with a trailing `/command`.
       *
       * Raised on the terminal surface only.
       */
      InfoNotice: {
          /**
           * The notice's text, flattened to one string.
           */
          text: string;
          /**
           * The slash command appended after the text, or null when the notice has
           * none.
           */
          command: string | null;
          /**
           * Which of its rows the transcript's viewport shows now: `null` while
           * drawn outside it, absent where the surface does not say. Read-only.
           *
           * Reported once drawn and again when it changes: on a scroll, for the
           * messages at the viewport's edges only. A rewrite carries it on as
           * received; one that changes or drops it is refused.
           */
          onScreen?: OnScreen | null;
      };
      /**
       * The dim mode labels at the right of the prompt footer (`focus`, `memory
       * paused`), joined by ` & `. One instance.
       *
       * A hook adds a mode by rewriting `modes`, removes one by filtering, or
       * draws its own tree.
       *
       * Raised on the terminal and desktop surfaces only.
       */
      SessionMode: {
          /**
           * The labels the footer shows, in order; empty when there are none.
           */
          modes: readonly string[];
      };
      /**
       * The dim hint line under the prompt (`? for shortcuts`, `esc to
       * interrupt`, the pills beside them). One instance.
       *
       * A hook rewrites `hint`, drawn in the line's place, sets `tail` to add to
       * the line as the engine draws it, or draws its own tree; `isDraft` and
       * `isWorking` say what the line is for.
       *
       * @remarks On the terminal, until a new answer lands the last keeps its row;
       *   before any, the permission mode alone, or the line already on screen.
       *
       * Raised on the terminal, desktop and mobile surfaces only.
       */
      PromptHint: {
          /**
           * True while the prompt holds typed text. Read-only.
           */
          isDraft: boolean;
          /**
           * True while a model turn is running. Read-only.
           */
          isWorking: boolean;
          /**
           * The line's text as the engine draws it; one string, so a rewrite
           * replaces the line.
           *
           * Read from the drawn line the way the screen reader reads it, one space
           * between parts.
           */
          hint: string;
          /**
           * Text a hook adds after the line; absent as the engine hands it.
           *
           * The terminal keeps the engine's line (its pills stay live) and draws
           * `tail` dim at its end, cut where the row ends and left out where under
           * four columns of it would show; no other surface draws it yet.
           *
           * @remarks A rewritten `hint` replaces the line, `tail` with it.
           */
          tail?: string;
      };
      /**
       * The band directly above the prompt input, where the surveys draw; of its
       * own the engine draws a `[-]` beside the tree, an `n more` row under it.
       *
       * Asked once for each plugin that hooks it, `e.plugin` naming the plugin:
       * a hook draws that plugin's row, or passes. `AbovePromptList` stacks them.
       *
       * A row costs only itself: one that does not validate draws nothing, and so
       * does one past a tree's limits: they count across the rows, kept from the
       * top, and stacking adds a level of depth. While the session hot-reloads a
       * plugin folder that is told as
       * `ui.render (AbovePrompt) refused: a row past the limits of the band`, whose
       * `nothing was drawn` means that row. Another plugin takes a row away by a
       * hook above naming its plugin or `"*"` that answers over it, or an
       * `AbovePromptList` hook leaving it out. On the terminal, a tree that throws
       * while drawn empties the band.
       *
       * The person collapses the band (ctrl+x ctrl+a, `[-]`) or focuses it (a
       * click, ctrl+x tab): an Input types, a Button arms the hotkeys, a tree
       * taller than it scrolls.
       *
       * Raised on every attached surface.
       */
      AbovePrompt: {
          /**
           * True while a survey holds the band; a hook yields to it. Read-only.
           */
          hasSurvey: boolean;
          /**
           * True while the person has collapsed the band: a tree still returns, and
           * nothing of it is on screen. False where the band cannot collapse.
           * Read-only.
           */
          isCollapsed: boolean;
          /**
           * True while a model turn is running. Read-only.
           */
          isWorking: boolean;
          /**
           * Rows the band may take: in fullscreen, what the bottom slot has left
           * above the prompt; otherwise the terminal's height. Read-only.
           *
           * That slot is capped at half the terminal's rows, the prompt's included.
           * A tree of at most `maxRows` rows shows whole; a taller one scrolls in a
           * window of `scroll.bodyRows`.
           *
           * @remarks A bare digit arms only the hotkeys of the Buttons wholly inside
           *   that window, never one scrolled out of view.
           */
          maxRows: number;
          /**
           * Cells the band's tree is laid out in, none under a mark of the engine's:
           * its column's width less the engine's five at the right end. Read-only.
           *
           * The column is the terminal, or the transcript's beside a docked `Pane`;
           * the five hold the `[-]`. A wider tree wraps or truncates as its Text
           * props say; size a table to it rather than to `viewport.columns`.
           */
          bodyColumns: number;
          /**
           * The band's window over a tree taller than `maxRows`: engine-owned,
           * moved by the wheel, and by the person's keys while the band is focused.
           *
           * `bodyRows` is `maxRows` less the `n more` row. Read-only.
           */
          scroll: SiteScroll;
          /**
           * Which transcript is on screen above the band: the main conversation's
           * (no `agentId`) or one agent's, opened from the tasks list.
           *
           * The same band under either; a switch re-runs the hook with the new
           * view. Read-only: a rewrite carries it on as received; one that changes
           * or drops it is refused, the hook that passed it failing.
           */
          view: SiteView;
      };
      /**
       * The band's arrangement once its rows settled, heard by a hook naming it or
       * a bare `on("*")`; what settles is the whole band.
       *
       * Core stacks `rows`. A hook hides or reorders them in what `next(e)` gets,
       * and wraps them by answering around it, never with rows copied by value; an
       * organization's mod wins by the chain's order. A bad answer is passed over:
       * to fail closed, answer no rows in its `.catch`.
       *
       * A wrapper counts toward a tree's limits with the rows. Past one, the rows
       * that no longer fit are left out; where several hooks' wrappers together
       * pass it, the band is blank. While the session hot-reloads a plugin folder
       * either is told as `ui.render (AbovePromptList) refused:`, whatever that
       * line's ending says.
       *
       * Raised on every attached surface.
       */
      AbovePromptList: {
          /**
           * The settled rows that fit, in chain order, one for each plugin that drew
           * one.
           *
           * A rewrite holds rows it was handed, in any order and no more often than
           * they came, compared by value: an unchanged copy passes, one changed or
           * repeated fails the hook. What it leaves is what core stacks.
           */
          rows: readonly AbovePromptRow[];
          /**
           * As `AbovePrompt`'s. Read-only.
           */
          hasSurvey: boolean;
          /**
           * As `AbovePrompt`'s. Read-only.
           */
          isCollapsed: boolean;
          /**
           * As `AbovePrompt`'s. Read-only.
           */
          isWorking: boolean;
          /**
           * As `AbovePrompt`'s: the rows the band may take, all its rows together.
           * Read-only.
           */
          maxRows: number;
          /**
           * As `AbovePrompt`'s. Read-only.
           */
          bodyColumns: number;
          /**
           * As `AbovePrompt`'s: the window over the whole stacked tree. Read-only.
           */
          scroll: SiteScroll;
          /**
           * As `AbovePrompt`'s. Read-only: a rewrite carries it on as received.
           */
          view: SiteView;
      };
      /**
       * One agent's row in the at-a-glance agent list (the terminal's, under the
       * prompt; the desktop's, in the session rail's Background tasks; VS Code's
       * running subagents): a subagent's or a teammate's, `requestId` its `id`.
       *
       * The agent as `$.agent.list()` gives it, `parentId` naming the agent that
       * spawned it (absent when the main loop did); read-only but for `label`, the
       * words the engine's own row shows beside the name. A tree, or `body`,
       * stands for everything after the row's pointer, connector and bullet, dim
       * or bold as the row is selected or viewed. On every surface the surface
       * keeps opening and stopping the agent, and hiding never removes an agent
       * from the full list. Not raised where the layout draws no agent rows, nor
       * for the `main` row, a workflow's or the folded idle summary.
       *
       * Asked for every agent with `hasRow` (in VS Code, a blocking forked skill's
       * too, which has none), drawn now or not, and again as a prop changes;
       * `tokenCount`, `tokenSamples`, `lastRequest`, `usage` and `cost` are read
       * every five seconds, on `$.ui.invalidate` and with a new `status` or
       * `taskStatus`. The last answer stands until the next lands; a new row waits
       * 300 ms at most for its first, then takes its place with no text until it
       * lands (in VS Code and the desktop app, it shows as the engine's).
       *
       * In mobile apps, the background tasks sheet asks only for the subagents on
       * screen. It keeps its own row, draws the tree or `body` under it and shows a
       * changed `label` in the row; a hidden row stays listed, with nothing of the
       * mod's.
       *
       * The desktop shows one line and takes no presses in the tree: a tree stands
       * for the row's words, a Link is drawn as its text and a Button is left out.
       *
       * @example
       * on("ui.render", { component: "AgentRow" }, ($, e, next) =>
       *   next({ ...e, props: { ...e.props, isHidden: e.props.status === "idle" } }))
       *
       * Raised on every attached surface.
       */
      AgentRow: AgentInfo & {
          /**
           * The `id` of every agent with `hasRow`, so each row is asked again as
           * one comes or goes. Read-only.
           */
          rowIds: string[];
          /**
           * The columns a top-level row's body has, where the surface measures
           * them; a nested row's connector takes two a level of them. Read-only.
           */
          columns?: number;
          /**
           * Text drawn as the whole of the row's body in place of the engine's
           * columns, cut at the row's edge; `""` hides the row as `isHidden` does.
           * It arrives set where the person's settings already draw the row; leave
           * it out for the engine's columns.
           *
           * It alone may hold escape sequences: SGR styles and OSC 8 links are
           * drawn, any other is dropped. A line break makes the row taller. A
           * remote surface is sent it as Text and Link elements.
           */
          body?: string;
          /**
           * Whether the row is left out of the list: of its drawing, its count and
           * its keys. A hidden row is still asked, so a hook may show it again.
           *
           * What the last `next` in the chain passed decides, whoever draws: pass
           * `false` to show a row that arrives hidden by the person's settings.
           */
          isHidden: boolean;
      };
      /**
       * The menu the person opens on something in the transcript (a right-click in
       * the desktop app): the rows a plugin adds to it. The engine draws none.
       *
       * Asked once for each plugin that hooks it, `e.plugin` naming the plugin: a
       * hook answers that plugin's rows, or passes with `next(e)` to its plugin's
       * next hook, or adds none. Another plugin takes rows away by a hook above
       * naming their plugin or `"*"` that answers over them.
       *
       * The props say what the pointer was on, each absent when it was on none, so a
       * matcher that names `link` runs only when the menu was opened on a link. A
       * hook can't change them. `e.requestId` names the menu, not the row: read
       * `e.props.row`.
       *
       * The surface makes a row of each `Button`: its `label`, or its text, is the
       * row's label, a dim `Text` inside it the line under the label, and `onPress`
       * runs when the person picks the row. It makes a row of each `Link` to an
       * `https:` address, one line with no second, which it opens on the person's
       * computer. It leaves out the rest of the tree, keeps its own rows whatever a
       * hook answers, and chooses where the rows go and how many it shows.
       *
       * A surface may open the menu before a slow answer arrives; then those rows
       * are missing from that menu. A part too long to hand over whole is absent:
       * text past 64 KB, an address too long for a `Link`. The last answer for the
       * same props stands until a `$.state` value it read changes or
       * `$.ui.invalidate()`.
       *
       * @example
       * on("ui.render",
       *   { component: "ContextMenu", props: { link: { href: /^https:\/\/example\.com\// } } },
       *   ($, e) => {
       *     const { Button } = $.ui.resolve(e)
       *     const fill = () => $.prompt.fill({ text: `Summarize ${e.props.link?.href}` })
       *     return <Button key="summarize" onPress={fill}>Summarize this page</Button>
       *   })
       *
       * Raised on the desktop surface only.
       */
      ContextMenu: {
          /**
           * The transcript row the menu was opened on: the `component` its own
           * `ui.render` hook names, and the id that hook reads as `e.requestId`.
           *
           * Absent where the surface cannot name the row.
           */
          row?: {
              component: RenderComponent;
              requestId: string;
          };
          /**
           * The link under the pointer: `href` is the address as the surface resolved
           * it, and `text` is the link's visible text, when the surface sends it.
           */
          link?: {
              href: string;
              text?: string;
          };
          /**
           * The text the person has selected, when the menu was opened on it.
           */
          selection?: UiSelection;
          /**
           * The code under the pointer: `isBlock` is true for a fenced block, whose
           * `text` is then the whole block, and false for code inside a line.
           */
          code?: {
              text: string;
              isBlock: boolean;
          };
      };
      /**
       * The framed region a plugin opened with `$.ui.open({ id })`: one instance
       * per id (`requestId`), its body the hook's tree, one shown, the rest tabs.
       *
       * Placed by the surface (docked in fullscreen, else above the prompt) and
       * keyed by the person (ctrl+x tab, Esc), who closes it from the engine's mark
       * or ctrl+x x: `ui.close` with origin `person`, which a hook may refuse.
       *
       * Raised on every attached surface.
       */
      Pane: {
          /**
           * Its tab's label while more than one pane is open (with one, the engine
           * draws no title): the `title` it was opened with, or its id.
           *
           * A click on a tab, or Tab onto it and Enter, shows that pane. Read-only
           * here; another `$.ui.open` (or a hook on `ui.open`) retitles.
           */
          title: string;
          /**
           * True while the person has given the pane the keyboard: Tab walks its
           * elements, a Button's `hotkey` presses it, the arrows scroll. Read-only.
           */
          isFocused: boolean;
          /**
           * Present, and true, while keys typed in the terminal may go to something
           * other than the prompt or this pane: a dialog (a permission prompt,
           * `/model`), a search, a field in the band. Read-only.
           */
          isPromptCovered?: true;
          /**
           * Cells across the body, inside the frame, none under a mark of the
           * engine's: the close mark sits on a row of the frame's own. Read-only.
           */
          bodyColumns: number;
          /**
           * Where the surface seated the pane: `dock` beside the transcript (the
           * terminal in fullscreen from 110 columns), or `inline` above the prompt.
           *
           * On the desktop app also `widget`, the small form of a minimized pane.
           * Draw what reads at a glance there: clicks may not reach it. The hook runs
           * again when the seat changes. Treat any other value as `dock`.
           *
           * Read-only: a rewrite carries it on as received; one that changes or
           * drops it is refused, the hook that passed it failing.
           *
           * @example
           * return e.props.placement === "widget" ? glance(e) : fullApp(e)
           */
          placement: 'dock' | 'inline' | 'widget';
          /**
           * The edges of the chat area that a `widget` is anchored on, to align the
           * drawing by: `["bottom", "right"]` in that corner, `["right"]` stacked on
           * another widget there, `[]` in the session rail (the column beside the
           * chat).
           *
           * Absent in every other seat. The hook runs again when they change. Ignore
           * a value outside these four. No call moves a widget.
           *
           * @example
           * const isOnBottom = e.props.anchoredEdges?.includes("bottom") ?? false
           */
          anchoredEdges?: readonly ('top' | 'right' | 'bottom' | 'left')[];
          /**
           * The body's window over the tree: engine-owned, moved by the person's
           * keys while the pane is focused. Read-only.
           *
           * `bodyRows` is the room's rows, never the rows showing: the most the frame
           * may take less the engine's (an inline border's two, the tab row while one
           * shows, a dock's row for the close mark). Inline the frame fits the tree.
           */
          scroll: SiteScroll;
          /**
           * Which transcript is on screen beside the pane: the main conversation's
           * (no `agentId`) or one agent's, opened from the tasks list.
           *
           * The pane stays open across a switch, one instance re-rendered for the
           * view, so a hook draws for the agent in view. Read-only: a rewrite carries
           * it on as received; one that changes or drops it is refused.
           */
          view: SiteView;
      };
      /**
       * A row a plugin placed in the transcript (`$.ui.place`): empty until a hook
       * draws it, in the row's place in the conversation.
       *
       * Every plugin's hook hears every row, so read `plugin` beside `id`. Outside
       * fullscreen a compaction ends the row, and the same id then places a new one.
       *
       * Raised on every attached surface.
       */
      Placed: {
          /**
           * What `$.ui.place` was given, unique among that plugin's rows. Read-only.
           */
          id: string;
          /**
           * Who placed the row, so a hook can leave another's alone. Read-only.
           */
          plugin: string;
          /**
           * Which of its rows the transcript's viewport shows now: `null` while
           * drawn outside it, absent where the surface does not say. Read-only.
           *
           * Reported once drawn and again when it changes: on a scroll, for the
           * messages at the viewport's edges only. A rewrite carries it on as
           * received; one that changes or drops it is refused.
           */
          onScreen?: OnScreen | null;
      };
      /**
       * The session's backdrop (`$.theme.set`), drawn behind the conversation by
       * the desktop and mobile apps alone: empty until a hook draws it.
       *
       * Every plugin's hook hears it, so read `plugin` beside `scene`. The surface
       * sizes the drawing to its window or screen and lets presses through to what
       * is over it. Each surface asks separately, so a hook can read `e.surface` to
       * draw a different scene on each.
       *
       * An answer holds only `Box`, `Text`, `Svg` and one `Shader` (ShaderProps), and
       * an `Svg` is pure vector, or
       * the answer is refused: no `data:` URL, base64, `<image>`, `feImage`,
       * `foreignObject`, `@font-face`, `@import`, `image-set()`, `src()`,
       * `cross-fade()` or `<?xml-stylesheet`; no `url()` or `href` but a local
       * `#fragment`, and no SMIL on an `href`. Nor anything that could hide one of
       * these: a backslash in `<style>` or a tag, a character reference other than
       * `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&apos;`, a control character, an XML
       * declaration with an encoding other than UTF-8, a DOCTYPE, ENTITY or CDATA,
       * `<?`, an element inside `<style>`, a `<style>` with no end tag, or a tag with
       * an attribute that has no value or whose value holds `<` or `>`.
       *
       * A plain comment stands, and its words are read like the rest: an XML one
       * between tags, outside `<style>`, with no `<` or `--` in it, or a closed CSS
       * one in `<style>` or a `style` attribute, outside any string or `url()`. A
       * bare `&` stands in an XML one alone.
       *
       * Raised on the desktop and mobile surfaces only.
       */
      Backdrop: {
          /**
           * The `scene` `$.theme.set` was given in `backdrop`. Read-only.
           */
          scene: string;
          /**
           * Who set the backdrop, so a hook can leave another's alone. Read-only.
           */
          plugin: string;
          /**
           * How the surface frosts its panels over the drawing, defaults filled in;
           * `false` where they stay as they are. Read-only.
           */
          glass: {
              blur: number;
              tint?: string;
              opacity: number;
          } | false;
          /**
           * The `overrideColorScheme` of `$.theme.set`; absent where the plugin named
           * none. Read-only.
           */
          overrideColorScheme?: 'light' | 'dark';
      };
  };

RenderResultOf type # line 13970

In the first published surface (2.1.259)

What a ui.render hook returns and what next(e) resolves to: a RenderElement tree, the same for every component.

  export type RenderResultOf = {
      [C in RenderComponent]: RenderElement;
  };

RenderSurface type # line 13989

In the first published surface (2.1.259) · changed in 2.1.268, 2.1.273, 2.1.299

The surface a render event's component is drawn on, by name. Plugins draw into surfaces; they do not provide them.

The surfaces the plugin was compiled against (the keys of Elements): terminal is Ink, drawing the hook's whole tree; desktop, mobile and vscode (Claude Code Desktop, the mobile app, VS Code) ask over the wire.

A name here is no promise that its host draws. Under a host that attaches no surface, hooks, tools and commands run and nothing drawn shows: $.session.surfaces() is empty there.

  export type RenderSurface = keyof Elements & string;

RenderViewport type # line 13999

In the first published surface (2.1.259) · changed in 2.1.275

The size of what a surface draws into, in character cells of the surface's monospace metric, and whether its layout docks a pane.

On the terminal, the conversation's columns and screen rows; on a remote surface, the pane's width and height over the advance and line height of its code font. Cell-based until the first element lays out in pixels.

27 lines
  export type RenderViewport = {
      /**
       * Cells across. A tree wider than this wraps or truncates, as its Text
       * props say.
       */
      columns: number;
      /**
       * Cells down the whole surface, not the room left for this component.
       *
       * Informational: a change of height alone re-draws nothing and keys no
       * new evaluation, so a hook reads it as of the last width or props change.
       */
      rows: number;
      /**
       * Whether this surface docks a pane beside the transcript, so a pane a
       * plugin opens unasked is a sidebar, not a takeover; absent is unknown.
       *
       * What `command.run`'s `presentation.isFullscreen` says. The terminal always
       * says: `true` fullscreen, `false` on the main screen, fixed per session; a
       * remote surface once its client reports it with the size, absent before.
       *
       * @remarks A remote surface that reports it places panes (`$.ui.open` is
       *   placed there); the mobile app reports `false`. A change re-draws.
       * @example if (e.viewport?.isFullscreen === true) void $.ui.open({ id })
       */
      isFullscreen?: boolean;
  };

ResolveInput type # line 14035

Added in 2.1.267

The input of ui.resolve: which surface's elements, for which component; a union with one member per surface (ResolveInputOf).

Resolved when the plugins load, ahead of any drawing, so it names the surface and the component and not the props; a ui.render argument is one (it carries both), which is what $.ui.resolve(e) takes.

  export type ResolveInput<C extends RenderComponent = RenderComponent, P extends RenderSurface = RenderSurface> = P extends RenderSurface ? ResolveInputOf<C, P> : never;

ResolveInputOf type # line 14040

Added in 2.1.267

One ui.resolve input, for a component on one surface.

  export type ResolveInputOf<C extends RenderComponent, P extends RenderSurface> = {
      /**
       * Where the table draws; one literal per member, so a hook that narrows
       * it narrows the table `next(e)` resolves to.
       */
      surface: P;
      /**
       * Which drawing the table is resolved for; the key a matcher narrows on.
       */
      component: C;
  };

ResultOf type # line 14056

In the first published surface (2.1.259) · changed in 2.1.265

What each event's hook returns, and what its next(e) resolves to, by event name.

  export type ResultOf = EngineResultOf & ClassicResultOf & {
      [N in OpEventName]: OpEventResult<N>;
  } & {
      [N in NounEventName]: NounEventResult<N>;
  };

SDKAssistantMessageError type # line 14062

Added in 2.1.265 · changed in 2.1.267, 2.1.268

  type SDKAssistantMessageError = 'authentication_failed' | 'oauth_org_not_allowed' | 'account_on_hold' | 'verification_required' | 'billing_error' | 'rate_limit' | 'overloaded' | 'invalid_request' | 'model_not_found' | 'server_error' | 'unknown' | 'max_output_tokens' | 'cloud_credential_error';

Select type # line 14067

In the first published surface (2.1.259)

The members of T assignable to S; all of T when none is.

  type Select<T, S> = [Extract<T, S>] extends [never] ? T : Extract<T, S>;

Selected type # line 14073

Added in 2.1.265

The events a pattern selects, as a union of names: the one named, every one under a glob's namespace, or every one a negation does not exclude.

  export type Selected<P extends string> = P extends '*' ? EventName : P extends `!${infer Negated}` ? Exclude<EventName, Selected<Negated>> : P extends `${infer Prefix}.*` ? Extract<EventName, `${Prefix}.${string}`> : Extract<EventName, P>;

Selection type # line 14079

In the first published surface (2.1.259) · changed in 2.1.287

The literal each tag key of I is held to by matcher M: one-of arrays flattened, RegExps widened to unknown.

  type Selection<I, M> = {
      [K in keyof M & TagKeys<I, keyof M>]: Literal<M[K] extends readonly (infer One)[] ? One : M[K]>;
  };

SelectOption type # line 14087

Added in 2.1.260

One option of a Select: the value onSelect and ui.select carry, and the text drawn for it (the value when absent).

  export type SelectOption = {
      value: string;
      label?: string;
  };

SelectProps type # line 14100

Added in 2.1.260 · changed in 2.1.271

The props of Select, every surface's one-of-several picker: an address, a label, the options, the one selected, the closure a pick runs. A leaf.

Focused through the same ring as Button (abovePrompt:focus); keys reach it only while it has focus (arrows move, Enter picks) and Esc always returns to the prompt; a pick raises ui.select, its bottom onSelect.

33 lines
  export type SelectProps = {
      /**
       * The element's address: `e.element` at `ui.select`, what a matcher names.
       */
      key: string;
      /**
       * Text drawn before the current value.
       */
      label?: string;
      /**
       * What can be picked, in the order drawn; at least one, values unique.
       */
      options: readonly SelectOption[];
      /**
       * Which option is selected when drawn; the person's pick replaces it
       * until the hook draws another.
       */
      value?: string;
      /**
       * The site's focus ring starts here when the site takes the keyboard,
       * instead of on nothing, as the DOM's `autofocus`: Enter acts on it at once.
       *
       * A pane opened with `focus`, or the person's focus chord or click, is the
       * take. Of several in one site the first drawn wins; it raises `ui.focus`,
       * origin this plugin. A ring the person has moved stays where it was put.
       */
      autoFocus?: true;
      /**
       * Runs on a pick with the option's value, in the plugin's own environment:
       * the bottom of a `ui.select` chain. No model turn unless it asks one.
       */
      onSelect: (value: string, e: UiSelectArgument) => void;
  };

SessionAppendArgs type # line 14142

Added in 2.1.285

session.append's input as a plugin's $.session.append(args) takes it: the row's kind and text, and the loop it joins.

Its door (note), origin (the calling plugin) and id are the engine's to set; a hook above, or the organization's policy plugin, may rewrite or refuse it like any call on $.

50 lines
  type SessionAppendArgs = {
      /**
       * The row: `type: "user"` for a row the model reads and the person does not
       * see as typed, `"system"` for a notice the model never reads.
       *
       * Its `content` is text blocks alone (one, for a notice): the bottom
       * refuses any other block, and any other row type, with the reason. A
       * notice is stored at once.
       *
       * A `user` row waits for the next request of its loop (on an idle main, the
       * next turn that calls the model) and is stored where that request sends
       * it, never between a call and its result.
       *
       * It goes out as a reminder under a line naming the plugin; a reminder tag
       * around the text is not doubled. Right behind tool results it is a system
       * message on a model that takes them, as a `tool.call` context is.
       *
       * It is folded into the result instead on other models, when sent after a
       * restart, and where managed PostToolUse hooks are set or managed settings
       * have not loaded cleanly. Anywhere else it is fenced in the user turn.
       *
       * A result that takes no folded text (search results) holds it back to a
       * later request, or to the next turn when no later result takes it: text
       * behind the result would end the round's screening.
       *
       * It is never the person's words, even when it quotes them: a reminder to
       * the model and to auto mode's server classifier, a plugin's message to its
       * client classifier. A prompt is `$.prompt.submit`.
       *
       * A waiting row survives a restart once a copy of it is stored, which is
       * when no loop is there to take it. The copy is sent once, fenced or folded,
       * even when its plugin is off or gone (`--safe-mode`, `--bare`).
       *
       * It is lost with the process while its loop runs, until a request of that
       * loop carries it or the loop ends, and while main ends in a call with no
       * result.
       *
       * It is lost too on an idle headless session that exits before its next
       * write, and when both a `/compact` and a restart come while it waits.
       */
      message: {
          type: 'user' | 'system';
          content: ApiContentBlock[];
      };
      /**
       * The running subagent whose conversation the row joins; absent for main.
       * One that names no running loop is refused.
       */
      agentId?: string;
  };

SessionAppendDoor type # line 14202

Added in 2.1.285 · changed in 2.1.299

Which door a row came in by, decided from the row alone; a closed set, pinned on the event and the key a matcher narrows on.

queue is no row of the conversation: it is the text of a message queue record (the transcript file's queue-operation entries), a prompt's or a machine-made one's alike, raised as a user row the conversation never keeps, a prompt's as prompt.submit left it.

  type SessionAppendDoor = 'prompt' | 'command' | 'response' | 'tool-result' | 'tool-message' | 'delivery' | 'attachment' | 'hook-context' | 'note' | 'compaction' | 'notice' | 'queue';

SessionAppendInput type # line 14212

Added in 2.1.285

The input of session.append: one row being appended to a conversation of this session, by the engine site that originates it or by a plugin's call.

Not on e, so stored as made: a tool result's structured record, the row's timestamps, parent links and provenance stamps, an attachment's payload (the model reads its recorded rendering, which content rewrites).

29 lines
  type SessionAppendInput = {
      /**
       * The row as it will be kept (SessionAppendMessage). Its `content` is a
       * hook's to rewrite; the engine puts back what it pins.
       */
      message: SessionAppendMessage;
      /**
       * Which door the row came in by (SessionAppendDoor); the key a matcher
       * narrows on. Pinned.
       */
      door: SessionAppendDoor;
      /**
       * Who caused the row (SessionAppendOrigin): the person, the model, a tool,
       * the engine, a settings hook, a plugin. Pinned.
       */
      origin: SessionAppendOrigin;
      /**
       * The row's id, the same in the transcript file and on every later read,
       * so a hook can keep a table by row before calling `next`. Pinned.
       */
      uuid: string;
      /**
       * The loop whose conversation keeps the row: a subagent's id, as `turn.step`
       * and `tool.call` carry it; absent on main.
       *
       * Pinned: a different value is refused, one left out is kept.
       */
      agentId?: string;
  };

SessionAppendMessage type # line 14249

Added in 2.1.285

One row of a conversation as session.append hands it: how the transcript files it, under which role a request carries it, and its blocks.

{ role, content } of a row a request carries is an ApiMessage, so code written for $.session.messages({ as: "api" }) reads it unchanged.

36 lines
  type SessionAppendMessage = {
      /**
       * How the transcript files the row: `user`, `assistant`, `attachment` (what
       * the engine injects beside the conversation), `system` (a notice).
       *
       * Pinned, as `name`, `role` and `isMeta` are: left out it is kept, changed
       * it fails the hook.
       */
      type: 'user' | 'assistant' | 'attachment' | 'system';
      /**
       * An attachment's type (`queued_command`, `nested_memory`, ...) or a
       * notice's subtype (`compact_boundary`, `local_command`, ...). Pinned.
       *
       * Absent on user and assistant rows. Builds add and retire names.
       */
      name?: string;
      /**
       * Under which role a request carries the row; absent when none does (a
       * notice, a record with no bytes on the wire, a virtual row). Pinned.
       */
      role?: 'user' | 'assistant';
      /**
       * True on a user-side row the person does not see as typed (a reminder, a
       * nudge, a delivery's text). Pinned.
       */
      isMeta?: true;
      /**
       * The row's blocks in order (ApiContentBlock): an attachment's as the
       * engine recorded its rendering, a notice's as one text block.
       *
       * Rewritable: text blocks, a tool_result's `content` and `is_error`. Media
       * blocks may be dropped or moved, not changed or added. Thinking, tool_use,
       * unknown kinds and every tool_result's `tool_use_id` are put back.
       */
      content: ApiContentBlock[];
  };

SessionAppendOrigin type # line 14290

Added in 2.1.285

Who caused a row, as the engine knows it from the row itself: a submission's sender, an injected row's author, the model, or the tool that was called.

20 lines
  type SessionAppendOrigin = PromptOrigin | PromptAttachmentOrigin | {
      /**
       * A block of the model's response, or the engine's stand-in for one.
       */
      kind: 'model';
      /**
       * Whose response it is: the id the response names.
       */
      model: string;
  } | {
      /**
       * A tool call's result, or a row a tool handed over beside it.
       */
      kind: 'tool';
      /**
       * Which one was called, by name; `unknown` when no call of that id is
       * found.
       */
      tool: string;
  };

SessionAppendResult type # line 14323

Added in 2.1.285

What a session.append hook returns and what next(e) resolves to: the row as the session stored it, or { deny: reason } for a plugin's own call.

next(e) resolves once the row is kept. A hook relays it unchanged: one that answers without next, or another row, is skipped. Only a plugin's own append (door note) may be refused, in place of next: nothing is stored.

A plugin's own user row resolves once it is accepted, as the row asked for. The request that carries it stores it, as a plugin_note attachment, and raises the event no second time.

24 lines
  type SessionAppendResult = {
      /**
       * The row as stored: what arrived at the bottom, the pinned parts put
       * back.
       */
      message: SessionAppendMessage;
      /**
       * The stored row's id: the same in the transcript file and on every
       * later read.
       *
       * A plugin's own `user` row sent only after a restart or a rewind is
       * stored under a new one.
       */
      uuid: string;
      deny?: undefined;
  } | {
      /**
       * Refuses a plugin's own append, so nothing is stored: the call
       * resolves to this, the reason the refusing hook gave.
       */
      deny: string;
      message?: undefined;
      uuid?: undefined;
  };
Feedback